diff options
author | Jan Holesovsky <kendy@suse.cz> | 2011-03-11 14:24:23 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@suse.cz> | 2011-03-11 14:24:23 +0100 |
commit | 67d2af6fac2d9bad52a6b1f6e0cbd1229eb88a42 (patch) | |
tree | 898019746162b464578da9c8345158a74321c904 /toolkit/source | |
parent | 86fb5fff88be611785b7908aac2a44475d77705f (diff) | |
parent | e2a3d487efb2bd5e582eb10e4150530c3f7377c5 (diff) |
Merge commit 'ooo/DEV300_m101' into intm101
The following builds for me:
basebmp, basegfx, comphelper, dtrans, i18npool, i18nutil, l10ntools, o3tl,
psprint_config, regexp, rsc, sax, sot, tools, ucbhelper, unotools, vcl
The rest still needs fixing ;-)
Conflicts:
canvas/prj/build.lst
canvas/source/cairo/cairo_textlayout.cxx
canvas/source/directx/dx_winstuff.hxx
canvas/source/tools/image.cxx
canvas/source/vcl/canvashelper.cxx
comphelper/inc/comphelper/documentconstants.hxx
comphelper/inc/comphelper/optionalvalue.hxx
comphelper/inc/comphelper/querydeep.hxx
comphelper/prj/build.lst
comphelper/qa/complex/makefile.mk
comphelper/qa/string/test_string_noadditional.cxx
comphelper/source/misc/componentmodule.cxx
comphelper/source/misc/mimeconfighelper.cxx
comphelper/source/misc/querydeep.cxx
comphelper/source/misc/uieventslogger.cxx
comphelper/source/property/TypeGeneration.cxx
comphelper/test/uno_iterators/uno_iterators.cxx
comphelper/util/makefile.mk
cppcanvas/source/mtfrenderer/implrenderer.cxx
dtrans/prj/build.lst
dtrans/source/generic/dtrans.cxx
dtrans/source/win32/dtobj/FmtFilter.cxx
i18npool/prj/build.lst
i18npool/source/localedata/data/localedata_others.map
i18npool/source/localedata/data/makefile.mk
i18npool/source/localedata/localedata.cxx
i18npool/source/localedata/saxparser.cxx
i18npool/source/registerservices/registerservices.cxx
i18npool/source/search/textsearch.cxx
l10ntools/inc/cfgmerge.hxx
l10ntools/inc/export.hxx
l10ntools/inc/gsicheck.hxx
l10ntools/inc/l10ntools/vosapp.hxx
l10ntools/inc/tagtest.hxx
l10ntools/inc/xmlparse.hxx
l10ntools/layout/layoutparse.cxx
l10ntools/layout/tralay.cxx
l10ntools/source/cfgmerge.cxx
l10ntools/source/export.cxx
l10ntools/source/export2.cxx
l10ntools/source/gsicheck.cxx
l10ntools/source/help/HelpLinker.cxx
l10ntools/source/lngex.cxx
l10ntools/source/lngmerge.cxx
l10ntools/source/merge.cxx
l10ntools/source/tagtest.cxx
l10ntools/source/xmlparse.cxx
padmin/source/fontentry.cxx
padmin/source/padialog.cxx
padmin/source/padialog.src
padmin/source/pamain.cxx
rsc/inc/rscarray.hxx
rsc/inc/rscclass.hxx
rsc/inc/rscclobj.hxx
rsc/inc/rsccont.hxx
rsc/inc/rscdb.hxx
rsc/inc/rscdef.hxx
rsc/inc/rscmgr.hxx
rsc/inc/rscrange.hxx
rsc/inc/rsctop.hxx
rsc/inc/vclrsc.hxx
rsc/source/parser/rscdb.cxx
rsc/source/parser/rscicpx.cxx
rsc/source/parser/rscinit.cxx
rsc/source/prj/start.cxx
rsc/source/res/rscarray.cxx
rsc/source/res/rscclass.cxx
rsc/source/res/rscclobj.cxx
rsc/source/res/rsccont.cxx
rsc/source/res/rscmgr.cxx
rsc/source/res/rscrange.cxx
rsc/source/res/rsctop.cxx
rsc/source/rsc/rsc.cxx
rsc/source/tools/rscdef.cxx
rsc/source/tools/rsctools.cxx
sax/source/expatwrap/sax_expat.cxx
sax/source/fastparser/facreg.cxx
sax/source/tools/fastserializer.cxx
sot/inc/sot/filelist.hxx
sot/inc/sot/object.hxx
sot/source/base/factory.cxx
sot/source/base/filelist.cxx
sot/source/sdstor/stg.cxx
sot/source/sdstor/stgcache.cxx
sot/source/sdstor/stgole.cxx
sot/source/sdstor/stgstrms.cxx
sot/source/sdstor/storage.cxx
sot/source/sdstor/ucbstorage.cxx
svl/inc/svl/cenumitm.hxx
svl/inc/svl/cintitem.hxx
svl/inc/svl/cntwall.hxx
svl/inc/svl/ctypeitm.hxx
svl/inc/svl/custritm.hxx
svl/inc/svl/dateitem.hxx
svl/inc/svl/filerec.hxx
svl/inc/svl/globalnameitem.hxx
svl/inc/svl/ilstitem.hxx
svl/inc/svl/imageitm.hxx
svl/inc/svl/intitem.hxx
svl/inc/svl/itempool.hxx
svl/inc/svl/itemset.hxx
svl/inc/svl/lckbitem.hxx
svl/inc/svl/poolitem.hxx
svl/inc/svl/ptitem.hxx
svl/inc/svl/rectitem.hxx
svl/inc/svl/sfontitm.hxx
svl/inc/svl/slstitm.hxx
svl/inc/svl/srchitem.hxx
svl/inc/svl/svarray.hxx
svl/inc/svl/svdde.hxx
svl/inc/svl/svstdarr.hxx
svl/inc/svl/szitem.hxx
svl/inc/svl/visitem.hxx
svl/inc/svl/zforlist.hxx
svl/inc/svl/zformat.hxx
svl/prj/build.lst
svl/qa/complex/ConfigItems/helper/ConfigItemTest.cxx
svl/qa/complex/ConfigItems/helper/makefile.mk
svl/qa/makefile.mk
svl/source/filepicker/pickerhelper.cxx
svl/source/filerec/filerec.cxx
svl/source/items/cenumitm.cxx
svl/source/items/cintitem.cxx
svl/source/items/cntwall.cxx
svl/source/items/ctypeitm.cxx
svl/source/items/custritm.cxx
svl/source/items/dateitem.cxx
svl/source/items/globalnameitem.cxx
svl/source/items/ilstitem.cxx
svl/source/items/imageitm.cxx
svl/source/items/intitem.cxx
svl/source/items/itempool.cxx
svl/source/items/itemprop.cxx
svl/source/items/itemset.cxx
svl/source/items/lckbitem.cxx
svl/source/items/poolio.cxx
svl/source/items/poolitem.cxx
svl/source/items/ptitem.cxx
svl/source/items/rectitem.cxx
svl/source/items/slstitm.cxx
svl/source/items/srchitem.cxx
svl/source/items/style.cxx
svl/source/items/szitem.cxx
svl/source/items/visitem.cxx
svl/source/items/whiter.cxx
svl/source/memtools/svarray.cxx
svl/source/misc/PasswordHelper.cxx
svl/source/misc/adrparse.cxx
svl/source/misc/lngmisc.cxx
svl/source/notify/brdcst.cxx
svl/source/notify/listener.cxx
svl/source/notify/listenerbase.cxx
svl/source/numbers/makefile.mk
svl/source/numbers/nbdll.cxx
svl/source/numbers/zforfind.cxx
svl/source/numbers/zforlist.cxx
svl/source/numbers/zformat.cxx
svl/source/numbers/zforscan.cxx
svl/source/passwordcontainer/passwordcontainer.cxx
svl/source/svdde/ddecli.cxx
svl/source/svdde/ddeimp.hxx
svl/source/svdde/ddemlos2.h
svl/source/svdde/ddesvr.cxx
svl/source/undo/undo.cxx
svl/source/uno/registerservices.cxx
svl/util/makefile.mk
svtools/bmpmaker/bmpsum.cxx
svtools/bmpmaker/g2g.cxx
svtools/bmpmaker/makefile.mk
svtools/inc/borderhelper.hxx
svtools/inc/svtools/accessiblefactory.hxx
svtools/inc/svtools/apearcfg.hxx
svtools/inc/svtools/brwbox.hxx
svtools/inc/svtools/ctrlbox.hxx
svtools/inc/svtools/ctrltool.hxx
svtools/inc/svtools/editbrowsebox.hxx
svtools/inc/svtools/ehdl.hxx
svtools/inc/svtools/embedhlp.hxx
svtools/inc/svtools/filter.hxx
svtools/inc/svtools/ivctrl.hxx
svtools/inc/svtools/parhtml.hxx
svtools/inc/svtools/printdlg.hxx
svtools/inc/svtools/rtftoken.h
svtools/inc/svtools/ruler.hxx
svtools/inc/svtools/svicnvw.hxx
svtools/inc/svtools/svlbitm.hxx
svtools/inc/svtools/svlbox.hxx
svtools/inc/svtools/svtreebx.hxx
svtools/inc/svtools/tabbar.hxx
svtools/inc/svtools/table/abstracttablecontrol.hxx
svtools/inc/svtools/taskbar.hxx
svtools/inc/svtools/textview.hxx
svtools/inc/svtools/valueset.hxx
svtools/source/brwbox/brwbox1.cxx
svtools/source/brwbox/brwbox2.cxx
svtools/source/brwbox/datwin.cxx
svtools/source/brwbox/datwin.hxx
svtools/source/brwbox/makefile.mk
svtools/source/config/apearcfg.cxx
svtools/source/config/htmlcfg.cxx
svtools/source/config/menuoptions.cxx
svtools/source/config/miscopt.cxx
svtools/source/contnr/cont_pch.cxx
svtools/source/contnr/ctrdll.cxx
svtools/source/contnr/fileview.cxx
svtools/source/contnr/imivctl1.cxx
svtools/source/contnr/ivctrl.cxx
svtools/source/contnr/makefile.mk
svtools/source/contnr/svcontnr.src
svtools/source/contnr/svicnvw.cxx
svtools/source/contnr/svimpbox.cxx
svtools/source/contnr/svimpicn.cxx
svtools/source/contnr/svlbitm.cxx
svtools/source/contnr/svtreebx.cxx
svtools/source/contnr/templwin.cxx
svtools/source/contnr/templwin.hxx
svtools/source/control/asynclink.cxx
svtools/source/control/ctrlbox.cxx
svtools/source/control/ctrldll.cxx
svtools/source/control/ctrltool.cxx
svtools/source/control/filectrl.cxx
svtools/source/control/filectrl.src
svtools/source/control/headbar.cxx
svtools/source/control/inettbc.cxx
svtools/source/control/makefile.mk
svtools/source/control/prgsbar.cxx
svtools/source/control/roadmap.cxx
svtools/source/control/ruler.cxx
svtools/source/control/scriptedtext.cxx
svtools/source/control/stdmenu.cxx
svtools/source/control/tabbar.cxx
svtools/source/control/taskbar.cxx
svtools/source/control/taskbox.cxx
svtools/source/control/taskmisc.cxx
svtools/source/control/taskstat.cxx
svtools/source/control/valueacc.cxx
svtools/source/control/valueset.cxx
svtools/source/dialogs/addresstemplate.cxx
svtools/source/dialogs/addresstemplate.src
svtools/source/dialogs/colrdlg.src
svtools/source/dialogs/filedlg2.cxx
svtools/source/dialogs/filedlg2.hxx
svtools/source/dialogs/makefile.mk
svtools/source/dialogs/printdlg.cxx
svtools/source/dialogs/printdlg.src
svtools/source/dialogs/propctrl.cxx
svtools/source/dialogs/propctrl.hxx
svtools/source/dialogs/property.cxx
svtools/source/edit/makefile.mk
svtools/source/edit/sychconv.cxx
svtools/source/edit/syntaxhighlight.cxx
svtools/source/edit/textdoc.cxx
svtools/source/edit/texteng.cxx
svtools/source/edit/textundo.cxx
svtools/source/edit/textview.cxx
svtools/source/filter.vcl/filter/SvFilterOptionsDialog.cxx
svtools/source/filter.vcl/filter/dlgejpg.cxx
svtools/source/filter.vcl/filter/dlgejpg.hxx
svtools/source/filter.vcl/filter/dlgejpg.src
svtools/source/filter.vcl/filter/dlgepng.cxx
svtools/source/filter.vcl/filter/dlgepng.hxx
svtools/source/filter.vcl/filter/dlgepng.src
svtools/source/filter.vcl/filter/dlgexpor.cxx
svtools/source/filter.vcl/filter/dlgexpor.hxx
svtools/source/filter.vcl/filter/dlgexpor.src
svtools/source/filter.vcl/filter/filter2.cxx
svtools/source/filter.vcl/filter/makefile.mk
svtools/source/filter.vcl/filter/sgfbram.cxx
svtools/source/filter.vcl/filter/sgvmain.cxx
svtools/source/filter.vcl/filter/sgvspln.cxx
svtools/source/filter.vcl/filter/strings.src
svtools/source/filter.vcl/jpeg/makefile.mk
svtools/source/filter.vcl/wmf/emfwr.cxx
svtools/source/filter.vcl/wmf/emfwr.hxx
svtools/source/filter.vcl/wmf/enhwmf.cxx
svtools/source/filter.vcl/wmf/winmtf.hxx
svtools/source/filter.vcl/wmf/wmfwr.cxx
svtools/source/filter.vcl/wmf/wmfwr.hxx
svtools/source/graphic/grfcache.cxx
svtools/source/graphic/grfcache.hxx
svtools/source/graphic/grfmgr.cxx
svtools/source/graphic/makefile.mk
svtools/source/inc/accessibletableimp.hxx
svtools/source/inc/svimpbox.hxx
svtools/source/java/patchjavaerror.src
svtools/source/misc/ehdl.cxx
svtools/source/misc/errtxt.src
svtools/source/misc/helpagentwindow.cxx
svtools/source/misc/imagemgr.cxx
svtools/source/misc/imagemgr.src
svtools/source/misc/imageresourceaccess.cxx
svtools/source/misc/imap.cxx
svtools/source/misc/langtab.src
svtools/source/misc/makefile.mk
svtools/source/misc/svtdata.cxx
svtools/source/misc/templatefoldercache.cxx
svtools/source/misc/transfer2.cxx
svtools/source/misc/undo.src
svtools/source/plugapp/commtest.cxx
svtools/source/plugapp/commtest.src
svtools/source/plugapp/makefile.mk
svtools/source/plugapp/testtool.src
svtools/source/productregistration/productregistration.cxx
svtools/source/svhtml/htmlkywd.cxx
svtools/source/svhtml/parhtml.cxx
svtools/source/svrtf/rtfkey2.cxx
svtools/source/svrtf/rtfkeywd.cxx
svtools/source/table/defaultinputhandler.cxx
svtools/source/table/makefile.mk
svtools/source/table/tablecontrol.cxx
svtools/source/table/tablecontrol_impl.cxx
svtools/source/table/tablecontrol_impl.hxx
svtools/source/table/tabledatawindow.cxx
svtools/source/table/tablegeometry.cxx
svtools/source/table/tablegeometry.hxx
svtools/source/toolpanel/makefile.mk
svtools/source/toolpanel/toolpaneldrawer.cxx
svtools/source/uno/addrtempuno.cxx
svtools/source/uno/miscservices.cxx
svtools/source/uno/svtxgridcontrol.cxx
svtools/source/uno/svtxgridcontrol.hxx
svtools/source/uno/toolboxcontroller.cxx
svtools/source/uno/treecontrolpeer.cxx
svtools/source/uno/unocontroltablemodel.cxx
svtools/source/uno/unocontroltablemodel.hxx
svtools/source/uno/unoimap.cxx
svtools/source/urlobj/inetimg.cxx
svtools/util/makefile.mk
svtools/workben/browser.cxx
svtools/workben/cui/makefile.mk
svtools/workben/makefile.mk
svtools/workben/stest.cxx
svtools/workben/toolpanel/makefile.mk
svtools/workben/urange.cxx
toolkit/inc/toolkit/awt/vclxdevice.hxx
toolkit/inc/toolkit/awt/vclxgraphics.hxx
toolkit/inc/toolkit/awt/vclxwindows.hxx
toolkit/inc/toolkit/controls/dialogcontrol.hxx
toolkit/inc/toolkit/helper/property.hxx
toolkit/inc/toolkit/helper/servicenames.hxx
toolkit/inc/toolkit/helper/throbberimpl.hxx
toolkit/qa/complex/toolkit/accessibility/_XAccessibleComponent.java
toolkit/source/awt/asynccallback.cxx
toolkit/source/awt/vclxgraphics.cxx
toolkit/source/awt/vclxtoolkit.cxx
toolkit/source/awt/vclxwindow.cxx
toolkit/source/awt/xsimpleanimation.cxx
toolkit/source/awt/xthrobber.cxx
toolkit/source/controls/dialogcontrol.cxx
toolkit/source/controls/grid/defaultgridcolumnmodel.cxx
toolkit/source/controls/grid/defaultgriddatamodel.cxx
toolkit/source/controls/grid/gridcontrol.cxx
toolkit/source/controls/grid/initguard.hxx
toolkit/source/controls/unocontrol.cxx
toolkit/source/controls/unocontrolcontainer.cxx
toolkit/source/controls/unocontrols.cxx
toolkit/source/helper/listenermultiplexer.cxx
toolkit/source/helper/property.cxx
toolkit/source/helper/registerservices.cxx
toolkit/source/helper/servicenames.cxx
toolkit/source/helper/throbberimpl.cxx
toolkit/source/helper/tkresmgr.cxx
tools/StaticLibrary_ooopathutils.mk
tools/bootstrp/addexes/makefile.mk
tools/bootstrp/addexes2/makefile.mk
tools/bootstrp/addexes2/mkfilt.cxx
tools/bootstrp/command.cxx
tools/bootstrp/cppdep.cxx
tools/bootstrp/iserver.cxx
tools/bootstrp/makefile.mk
tools/bootstrp/mkcreate.cxx
tools/bootstrp/prj.cxx
tools/bootstrp/rscdep.cxx
tools/bootstrp/sstring.cxx
tools/inc/bootstrp/command.hxx
tools/inc/bootstrp/mkcreate.hxx
tools/inc/bootstrp/prj.hxx
tools/inc/bootstrp/sstring.hxx
tools/inc/tools/agapi.hxx
tools/inc/tools/agitem.hxx
tools/inc/tools/chapi.hxx
tools/inc/tools/download.hxx
tools/inc/tools/eacopier.hxx
tools/inc/tools/fract.hxx
tools/inc/tools/fsys.hxx
tools/inc/tools/geninfo.hxx
tools/inc/tools/globname.hxx
tools/inc/tools/inetmime.hxx
tools/inc/tools/multisel.hxx
tools/inc/tools/poly.hxx
tools/inc/tools/postsys.h
tools/inc/tools/postwin.h
tools/inc/tools/presys.h
tools/inc/tools/prewin.h
tools/inc/tools/pstm.hxx
tools/inc/tools/ref.hxx
tools/inc/tools/simplerm.hxx
tools/inc/tools/solar.h
tools/inc/tools/table.hxx
tools/inc/tools/urlkeys.hxx
tools/inc/tools/urlobj.hxx
tools/prj/build.lst
tools/prj/d.lst
tools/qa/makefile.mk
tools/source/communi/geninfo.cxx
tools/source/debug/debug.cxx
tools/source/fsys/dirent.cxx
tools/source/fsys/tdir.cxx
tools/source/fsys/unx.cxx
tools/source/fsys/urlobj.cxx
tools/source/generic/color.cxx
tools/source/generic/config.cxx
tools/source/generic/fract.cxx
tools/source/inet/inetmime.cxx
tools/source/memtools/multisel.cxx
tools/source/memtools/table.cxx
tools/source/rc/resmgr.cxx
tools/source/ref/globname.cxx
tools/source/ref/pstm.cxx
tools/source/solar/solar.c
tools/source/stream/strmos2.cxx
tools/source/stream/strmunx.cxx
tools/source/stream/strmwnt.cxx
tools/source/string/makefile.mk
tools/source/testtoolloader/testtoolloader.cxx
tools/test/makefile.mk
tools/util/makefile.mk
tools/win/inc/dll.hxx
tools/win/inc/parser.hxx
tools/win/inc/shellex.h
tools/win/inc/shutil.h
tools/win/inc/toolsdll.hxx
tools/win/inc/winshell.hxx
tools/workben/makefile.mk
ucbhelper/source/client/proxydecider.cxx
ucbhelper/workben/ucbexplorer/ucbexplorer.hrc
unotools/inc/unotools/unotunnelhelper.hxx
unotools/source/config/fltrcfg.cxx
unotools/source/config/lingucfg.cxx
unotools/source/config/misccfg.cxx
unotools/source/config/pathoptions.cxx
unotools/source/config/searchopt.cxx
unotools/source/i18n/localedatawrapper.cxx
unotools/source/ucbhelper/localfilehelper.cxx
unotools/source/ucbhelper/ucbhelper.cxx
unotools/source/ucbhelper/xtempfile.cxx
vcl/aqua/inc/salbmp.h
vcl/aqua/inc/salgdi.h
vcl/aqua/inc/salinst.h
vcl/aqua/source/app/salinst.cxx
vcl/aqua/source/gdi/aquaprintaccessoryview.mm
vcl/aqua/source/gdi/salgdi.cxx
vcl/aqua/source/gdi/salprn.cxx
vcl/aqua/source/window/salframeview.mm
vcl/aqua/source/window/salobj.cxx
vcl/inc/vcl/bitmap.hxx
vcl/inc/vcl/brdwin.hxx
vcl/inc/vcl/button.hxx
vcl/inc/vcl/cmdevt.hxx
vcl/inc/vcl/cvtgrf.hxx
vcl/inc/vcl/dialog.hxx
vcl/inc/vcl/dockwin.hxx
vcl/inc/vcl/event.hxx
vcl/inc/vcl/fixed.hxx
vcl/inc/vcl/fldunit.hxx
vcl/inc/vcl/floatwin.hxx
vcl/inc/vcl/gdimtf.hxx
vcl/inc/vcl/glyphcache.hxx
vcl/inc/vcl/graphite_adaptors.hxx
vcl/inc/vcl/graphite_features.hxx
vcl/inc/vcl/graphite_layout.hxx
vcl/inc/vcl/ilstbox.hxx
vcl/inc/vcl/image.h
vcl/inc/vcl/imgctrl.hxx
vcl/inc/vcl/impbmpconv.hxx
vcl/inc/vcl/impprn.hxx
vcl/inc/vcl/jobset.h
vcl/inc/vcl/keycodes.hxx
vcl/inc/vcl/lstbox.hxx
vcl/inc/vcl/mapunit.hxx
vcl/inc/vcl/menu.hxx
vcl/inc/vcl/msgbox.hxx
vcl/inc/vcl/outdev.hxx
vcl/inc/vcl/prndlg.hxx
vcl/inc/vcl/salatype.hxx
vcl/inc/vcl/salbmp.hxx
vcl/inc/vcl/salgdi.hxx
vcl/inc/vcl/salinst.hxx
vcl/inc/vcl/seleng.hxx
vcl/inc/vcl/settings.hxx
vcl/inc/vcl/smartid.hxx
vcl/inc/vcl/status.hxx
vcl/inc/vcl/strhelper.hxx
vcl/inc/vcl/svapp.hxx
vcl/inc/vcl/svdata.hxx
vcl/inc/vcl/syschild.hxx
vcl/inc/vcl/sysdata.hxx
vcl/inc/vcl/taskpanelist.hxx
vcl/inc/vcl/toolbox.hxx
vcl/inc/vcl/vclevent.hxx
vcl/inc/vcl/windata.hxx
vcl/inc/vcl/window.hxx
vcl/inc/vcl/wintypes.hxx
vcl/os2/source/app/salinst.cxx
vcl/os2/source/gdi/salgdi.cxx
vcl/os2/source/window/salmenu.cxx
vcl/os2/source/window/salobj.cxx
vcl/prj/build.lst
vcl/source/app/dbggui.cxx
vcl/source/app/help.cxx
vcl/source/app/idlemgr.cxx
vcl/source/app/settings.cxx
vcl/source/app/svapp.cxx
vcl/source/app/svdata.cxx
vcl/source/app/svmain.cxx
vcl/source/app/svmainhook.cxx
vcl/source/app/unohelp.cxx
vcl/source/app/vclevent.cxx
vcl/source/control/button.cxx
vcl/source/control/combobox.cxx
vcl/source/control/edit.cxx
vcl/source/control/field.cxx
vcl/source/control/fixed.cxx
vcl/source/control/ilstbox.cxx
vcl/source/control/imgctrl.cxx
vcl/source/control/makefile.mk
vcl/source/control/tabctrl.cxx
vcl/source/gdi/bitmap.cxx
vcl/source/gdi/bitmap2.cxx
vcl/source/gdi/bitmap4.cxx
vcl/source/gdi/bmpconv.cxx
vcl/source/gdi/cvtsvm.cxx
vcl/source/gdi/font.cxx
vcl/source/gdi/gdimtf.cxx
vcl/source/gdi/image.cxx
vcl/source/gdi/impimage.cxx
vcl/source/gdi/jobset.cxx
vcl/source/gdi/makefile.mk
vcl/source/gdi/metaact.cxx
vcl/source/gdi/outdev.cxx
vcl/source/gdi/outdev3.cxx
vcl/source/gdi/outdev4.cxx
vcl/source/gdi/outdevnative.cxx
vcl/source/gdi/pdfwriter.cxx
vcl/source/gdi/pdfwriter_impl.cxx
vcl/source/gdi/print3.cxx
vcl/source/gdi/salmisc.cxx
vcl/source/glyphs/gcach_ftyp.cxx
vcl/source/glyphs/gcach_ftyp.hxx
vcl/source/glyphs/glyphcache.cxx
vcl/source/glyphs/graphite_cache.cxx
vcl/source/glyphs/graphite_layout.cxx
vcl/source/glyphs/graphite_textsrc.hxx
vcl/source/helper/canvasbitmap.cxx
vcl/source/helper/smartid.cxx
vcl/source/helper/xconnection.cxx
vcl/source/src/btntext.src
vcl/source/src/images.src
vcl/source/src/print.src
vcl/source/window/accel.cxx
vcl/source/window/accmgr.cxx
vcl/source/window/brdwin.cxx
vcl/source/window/btndlg.cxx
vcl/source/window/dlgctrl.cxx
vcl/source/window/javachild.cxx
vcl/source/window/menu.cxx
vcl/source/window/msgbox.cxx
vcl/source/window/printdlg.cxx
vcl/source/window/status.cxx
vcl/source/window/syschild.cxx
vcl/source/window/toolbox.cxx
vcl/source/window/toolbox2.cxx
vcl/source/window/window.cxx
vcl/source/window/window2.cxx
vcl/source/window/wrkwin.cxx
vcl/unx/gtk/app/gtkdata.cxx
vcl/unx/gtk/app/gtkinst.cxx
vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
vcl/unx/gtk/window/gtkframe.cxx
vcl/unx/gtk/window/gtkobject.cxx
vcl/unx/headless/svpbmp.hxx
vcl/unx/headless/svpgdi.cxx
vcl/unx/headless/svpgdi.hxx
vcl/unx/headless/svpinst.cxx
vcl/unx/headless/svpinst.hxx
vcl/unx/headless/svpprn.cxx
vcl/unx/headless/svpprn.hxx
vcl/unx/headless/svppspgraphics.cxx
vcl/unx/headless/svppspgraphics.hxx
vcl/unx/headless/svptext.cxx
vcl/unx/inc/dtint.hxx
vcl/unx/inc/plugins/gtk/gtkdata.hxx
vcl/unx/inc/pspgraphics.h
vcl/unx/inc/salbmp.h
vcl/unx/inc/saldata.hxx
vcl/unx/inc/saldisp.hxx
vcl/unx/inc/salgdi.h
vcl/unx/inc/salinst.h
vcl/unx/inc/xfont.hxx
vcl/unx/kde/kdedata.cxx
vcl/unx/kde4/KDESalGraphics.cxx
vcl/unx/source/app/keysymnames.cxx
vcl/unx/source/app/saldata.cxx
vcl/unx/source/app/saldisp.cxx
vcl/unx/source/app/salinst.cxx
vcl/unx/source/app/wmadaptor.cxx
vcl/unx/source/dtrans/X11_selection.cxx
vcl/unx/source/dtrans/X11_service.cxx
vcl/unx/source/gdi/makefile.mk
vcl/unx/source/gdi/pspgraphics.cxx
vcl/unx/source/gdi/salgdi.cxx
vcl/unx/source/gdi/salgdi3.cxx
vcl/unx/source/gdi/salprnpsp.cxx
vcl/unx/source/gdi/xfont.cxx
vcl/unx/source/gdi/xlfd_attr.cxx
vcl/unx/source/gdi/xlfd_attr.hxx
vcl/unx/source/gdi/xlfd_extd.cxx
vcl/unx/source/gdi/xlfd_extd.hxx
vcl/unx/source/gdi/xlfd_smpl.cxx
vcl/unx/source/gdi/xlfd_smpl.hxx
vcl/unx/source/printer/ppdparser.cxx
vcl/unx/source/printer/printerinfomanager.cxx
vcl/unx/source/window/salframe.cxx
vcl/unx/source/window/salmenu.cxx
vcl/unx/source/window/salobj.cxx
vcl/util/makefile2.pmk
vcl/win/inc/salbmp.h
vcl/win/inc/saldata.hxx
vcl/win/inc/salgdi.h
vcl/win/inc/salinst.h
vcl/win/source/app/saldata.cxx
vcl/win/source/app/salinst.cxx
vcl/win/source/gdi/salgdi.cxx
vcl/win/source/gdi/salgdi3.cxx
vcl/win/source/gdi/salprn.cxx
vcl/win/source/gdi/winlayout.cxx
vcl/win/source/window/salframe.cxx
vcl/win/source/window/salobj.cxx
vcl/workben/outdevgrind.cxx
vos/inc/vos/execabl.hxx
vos/inc/vos/macros.hxx
vos/inc/vos/pipe.hxx
vos/inc/vos/process.hxx
vos/inc/vos/refernce.hxx
vos/inc/vos/signal.hxx
vos/inc/vos/socket.hxx
vos/inc/vos/stream.hxx
vos/inc/vos/thread.hxx
vos/source/pipe.cxx
vos/source/process.cxx
vos/source/signal.cxx
vos/source/thread.cxx
vos/source/timer.cxx
Diffstat (limited to 'toolkit/source')
73 files changed, 7621 insertions, 2788 deletions
diff --git a/toolkit/source/awt/animatedimagespeer.cxx b/toolkit/source/awt/animatedimagespeer.cxx new file mode 100755 index 000000000000..69c08ee51520 --- /dev/null +++ b/toolkit/source/awt/animatedimagespeer.cxx @@ -0,0 +1,538 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General 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_toolkit.hxx" + +#include "toolkit/awt/animatedimagespeer.hxx" +#include "toolkit/helper/property.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/awt/XAnimatedImages.hpp> +#include <com/sun/star/awt/Size.hpp> +#include <com/sun/star/graphic/XGraphicProvider.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/graphic/XGraphic.hpp> +#include <com/sun/star/awt/ImageScaleMode.hpp> +/** === end UNO includes === **/ + +#include <comphelper/componentcontext.hxx> +#include <comphelper/namedvaluecollection.hxx> +#include <comphelper/processfactory.hxx> +#include <rtl/ustrbuf.hxx> +#include <tools/diagnose_ex.h> +#include <tools/urlobj.hxx> +#include <vcl/throbber.hxx> + +#include <limits> + +//...................................................................................................................... +namespace toolkit +{ +//...................................................................................................................... + + /** === 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::EventObject; + using ::com::sun::star::container::ContainerEvent; + using ::com::sun::star::awt::XAnimatedImages; + using ::com::sun::star::awt::Size; + using ::com::sun::star::lang::XMultiServiceFactory; + using ::com::sun::star::graphic::XGraphicProvider; + using ::com::sun::star::beans::XPropertySet; + using ::com::sun::star::graphic::XGraphic; + /** === end UNO using === **/ + namespace ImageScaleMode = ::com::sun::star::awt::ImageScaleMode; + + //================================================================================================================== + //= AnimatedImagesPeer_Data + //================================================================================================================== + struct CachedImage + { + ::rtl::OUString sImageURL; + mutable Reference< XGraphic > xGraphic; + + CachedImage() + :sImageURL() + ,xGraphic() + { + } + + CachedImage( ::rtl::OUString const& i_imageURL ) + :sImageURL( i_imageURL ) + ,xGraphic() + { + } + }; + + struct AnimatedImagesPeer_Data + { + AnimatedImagesPeer& rAntiImpl; + ::std::vector< ::std::vector< CachedImage > > aCachedImageSets; + + AnimatedImagesPeer_Data( AnimatedImagesPeer& i_antiImpl ) + :rAntiImpl( i_antiImpl ) + ,aCachedImageSets() + { + } + }; + + //================================================================================================================== + //= helper + //================================================================================================================== + namespace + { + //-------------------------------------------------------------------------------------------------------------- + ::rtl::OUString lcl_getHighContrastURL( ::rtl::OUString const& i_imageURL ) + { + INetURLObject aURL( i_imageURL ); + if ( aURL.GetProtocol() != INET_PROT_PRIV_SOFFICE ) + { + OSL_VERIFY( aURL.insertName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "hicontrast" ) ), false, 0 ) ); + return aURL.GetMainURL( INetURLObject::NO_DECODE ); + } + // the private: scheme is not considered to be hierarchical by INetURLObject, so manually insert the + // segment + const sal_Int32 separatorPos = i_imageURL.indexOf( '/' ); + ENSURE_OR_RETURN( separatorPos != -1, "lcl_getHighContrastURL: unsipported URL scheme - cannot automatically determine HC version!", i_imageURL ); + + ::rtl::OUStringBuffer composer; + composer.append( i_imageURL.copy( 0, separatorPos ) ); + composer.appendAscii( "/hicontrast" ); + composer.append( i_imageURL.copy( separatorPos ) ); + return composer.makeStringAndClear(); + } + + //-------------------------------------------------------------------------------------------------------------- + bool lcl_ensureImage_throw( Reference< XGraphicProvider > const& i_graphicProvider, const bool i_isHighContrast, const CachedImage& i_cachedImage ) + { + if ( !i_cachedImage.xGraphic.is() ) + { + ::comphelper::NamedValueCollection aMediaProperties; + if ( i_isHighContrast ) + { + // try (to find) the high-contrast version of the graphic first + aMediaProperties.put( "URL", lcl_getHighContrastURL( i_cachedImage.sImageURL ) ); + i_cachedImage.xGraphic.set( i_graphicProvider->queryGraphic( aMediaProperties.getPropertyValues() ), UNO_QUERY ); + } + if ( !i_cachedImage.xGraphic.is() ) + { + aMediaProperties.put( "URL", i_cachedImage.sImageURL ); + i_cachedImage.xGraphic.set( i_graphicProvider->queryGraphic( aMediaProperties.getPropertyValues() ), UNO_QUERY ); + } + } + return i_cachedImage.xGraphic.is(); + } + + //-------------------------------------------------------------------------------------------------------------- + Size lcl_getGraphicSizePixel( Reference< XGraphic > const& i_graphic ) + { + Size aSizePixel; + try + { + if ( i_graphic.is() ) + { + const Reference< XPropertySet > xGraphicProps( i_graphic, UNO_QUERY_THROW ); + OSL_VERIFY( xGraphicProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SizePixel" ) ) ) >>= aSizePixel ); + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return aSizePixel; + } + + //-------------------------------------------------------------------------------------------------------------- + void lcl_init( Sequence< ::rtl::OUString > const& i_imageURLs, ::std::vector< CachedImage >& o_images ) + { + o_images.resize(0); + size_t count = size_t( i_imageURLs.getLength() ); + o_images.reserve( count ); + for ( size_t i = 0; i < count; ++i ) + { + o_images.push_back( CachedImage( i_imageURLs[i] ) ); + } + } + + //-------------------------------------------------------------------------------------------------------------- + void lcl_updateImageList_nothrow( AnimatedImagesPeer_Data& i_data ) + { + Throbber* pThrobber = dynamic_cast< Throbber* >( i_data.rAntiImpl.GetWindow() ); + if ( pThrobber == NULL ) + return; + + try + { + // collect the image sizes of the different image sets + const ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); + const Reference< XGraphicProvider > xGraphicProvider( aContext.createComponent( "com.sun.star.graphic.GraphicProvider" ), UNO_QUERY_THROW ); + + const bool isHighContrast = pThrobber->GetSettings().GetStyleSettings().GetHighContrastMode(); + + sal_Int32 nPreferredSet = -1; + const size_t nImageSetCount = i_data.aCachedImageSets.size(); + if ( nImageSetCount < 2 ) + { + nPreferredSet = sal_Int32( nImageSetCount ) - 1; + } + else + { + ::std::vector< Size > aImageSizes( nImageSetCount ); + for ( sal_Int32 nImageSet = 0; size_t( nImageSet ) < nImageSetCount; ++nImageSet ) + { + ::std::vector< CachedImage > const& rImageSet( i_data.aCachedImageSets[ nImageSet ] ); + if ( ( rImageSet.empty() ) + || ( !lcl_ensureImage_throw( xGraphicProvider, isHighContrast, rImageSet[0] ) ) + ) + { + aImageSizes[ nImageSet ] = Size( ::std::numeric_limits< long >::max(), ::std::numeric_limits< long >::max() ); + } + else + { + aImageSizes[ nImageSet ] = lcl_getGraphicSizePixel( rImageSet[0].xGraphic ); + } + } + + // find the set with the smallest difference between window size and image size + const ::Size aWindowSizePixel = pThrobber->GetSizePixel(); + long nMinimalDistance = ::std::numeric_limits< long >::max(); + for ( ::std::vector< Size >::const_iterator check = aImageSizes.begin(); + check != aImageSizes.end(); + ++check + ) + { + if ( ( check->Width > aWindowSizePixel.Width() ) + || ( check->Height > aWindowSizePixel.Height() ) + ) + // do not use an image set which doesn't fit into the window + continue; + + const sal_Int64 distance = + ( aWindowSizePixel.Width() - check->Width ) * ( aWindowSizePixel.Width() - check->Width ) + + ( aWindowSizePixel.Height() - check->Height ) * ( aWindowSizePixel.Height() - check->Height ); + if ( distance < nMinimalDistance ) + { + nMinimalDistance = distance; + nPreferredSet = check - aImageSizes.begin(); + } + } + } + + // found a set? + Sequence< Reference< XGraphic > > aImages; + if ( ( nPreferredSet >= 0 ) && ( size_t( nPreferredSet ) < nImageSetCount ) ) + { + // => set the images + ::std::vector< CachedImage > const& rImageSet( i_data.aCachedImageSets[ nPreferredSet ] ); + aImages.realloc( rImageSet.size() ); + sal_Int32 imageIndex = 0; + for ( ::std::vector< CachedImage >::const_iterator cachedImage = rImageSet.begin(); + cachedImage != rImageSet.end(); + ++cachedImage, ++imageIndex + ) + { + lcl_ensureImage_throw( xGraphicProvider, isHighContrast, *cachedImage ); + aImages[ imageIndex ] = cachedImage->xGraphic; + } + } + pThrobber->setImageList( aImages ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + + //-------------------------------------------------------------------------------------------------------------- + void lcl_updateImageList_nothrow( AnimatedImagesPeer_Data& i_data, const Reference< XAnimatedImages >& i_images ) + { + try + { + const sal_Int32 nImageSetCount = i_images->getImageSetCount(); + i_data.aCachedImageSets.resize(0); + for ( sal_Int32 set = 0; set < nImageSetCount; ++set ) + { + const Sequence< ::rtl::OUString > aImageURLs( i_images->getImageSet( set ) ); + ::std::vector< CachedImage > aImages; + lcl_init( aImageURLs, aImages ); + i_data.aCachedImageSets.push_back( aImages ); + } + + lcl_updateImageList_nothrow( i_data ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + } + + //================================================================================================================== + //= AnimatedImagesPeer + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + AnimatedImagesPeer::AnimatedImagesPeer() + :AnimatedImagesPeer_Base() + ,m_pData( new AnimatedImagesPeer_Data( *this ) ) + { + } + + //------------------------------------------------------------------------------------------------------------------ + AnimatedImagesPeer::~AnimatedImagesPeer() + { + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesPeer::startAnimation( ) throw (RuntimeException) + { + ::osl::MutexGuard aGuard( GetMutex() ); + Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) ); + if ( pThrobber != NULL) + pThrobber->start(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesPeer::stopAnimation( ) throw (RuntimeException) + { + ::osl::MutexGuard aGuard( GetMutex() ); + Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) ); + if ( pThrobber != NULL) + pThrobber->stop(); + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Bool SAL_CALL AnimatedImagesPeer::isAnimationRunning( ) throw (RuntimeException) + { + ::osl::MutexGuard aGuard( GetMutex() ); + Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) ); + if ( pThrobber != NULL) + return pThrobber->isRunning(); + return sal_False; + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesPeer::setProperty( const ::rtl::OUString& i_propertyName, const Any& i_value ) throw(RuntimeException) + { + ::osl::MutexGuard aGuard( GetMutex() ); + + Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) ); + if ( pThrobber == NULL ) + { + VCLXWindow::setProperty( i_propertyName, i_value ); + return; + } + + const sal_uInt16 nPropertyId = GetPropertyId( i_propertyName ); + switch ( nPropertyId ) + { + case BASEPROPERTY_STEP_TIME: + { + sal_Int32 nStepTime( 0 ); + if ( i_value >>= nStepTime ) + pThrobber->setStepTime( nStepTime ); + break; + } + case BASEPROPERTY_AUTO_REPEAT: + { + sal_Bool bRepeat( sal_True ); + if ( i_value >>= bRepeat ) + pThrobber->setRepeat( bRepeat ); + break; + } + + case BASEPROPERTY_IMAGE_SCALE_MODE: + { + sal_Int16 nScaleMode( ImageScaleMode::Anisotropic ); + ImageControl* pImageControl = dynamic_cast< ImageControl* >( GetWindow() ); + if ( pImageControl && ( i_value >>= nScaleMode ) ) + { + pImageControl->SetScaleMode( nScaleMode ); + } + } + break; + + default: + AnimatedImagesPeer_Base::setProperty( i_propertyName, i_value ); + break; + } + } + + //------------------------------------------------------------------------------------------------------------------ + Any SAL_CALL AnimatedImagesPeer::getProperty( const ::rtl::OUString& i_propertyName ) throw(RuntimeException) + { + ::osl::MutexGuard aGuard( GetMutex() ); + + Any aReturn; + + Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) ); + if ( pThrobber == NULL ) + return VCLXWindow::getProperty( i_propertyName ); + + const sal_uInt16 nPropertyId = GetPropertyId( i_propertyName ); + switch ( nPropertyId ) + { + case BASEPROPERTY_STEP_TIME: + aReturn <<= pThrobber->getStepTime(); + break; + + case BASEPROPERTY_AUTO_REPEAT: + aReturn <<= pThrobber->getRepeat(); + break; + + case BASEPROPERTY_IMAGE_SCALE_MODE: + { + ImageControl const* pImageControl = dynamic_cast< ImageControl* >( GetWindow() ); + aReturn <<= ( pImageControl ? pImageControl->GetScaleMode() : ImageScaleMode::Anisotropic ); + } + break; + + default: + aReturn = AnimatedImagesPeer_Base::getProperty( i_propertyName ); + break; + } + + return aReturn; + } + + //------------------------------------------------------------------------------------------------------------------ + void AnimatedImagesPeer::ProcessWindowEvent( const VclWindowEvent& i_windowEvent ) + { + switch ( i_windowEvent.GetId() ) + { + case VCLEVENT_WINDOW_RESIZE: + lcl_updateImageList_nothrow( *m_pData ); + break; + } + + AnimatedImagesPeer_Base::ProcessWindowEvent( i_windowEvent ); + } + + //------------------------------------------------------------------------------------------------------------------ + void AnimatedImagesPeer::impl_updateImages_nolck( const Reference< XInterface >& i_animatedImages ) + { + ::osl::MutexGuard aGuard( GetMutex() ); + + lcl_updateImageList_nothrow( *m_pData, Reference< XAnimatedImages >( i_animatedImages, UNO_QUERY_THROW ) ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesPeer::elementInserted( const ContainerEvent& i_event ) throw (RuntimeException) + { + ::osl::MutexGuard aGuard( GetMutex() ); + Reference< XAnimatedImages > xAnimatedImages( i_event.Source, UNO_QUERY_THROW ); + + sal_Int32 nPosition(0); + OSL_VERIFY( i_event.Accessor >>= nPosition ); + size_t position = size_t( nPosition ); + if ( position > m_pData->aCachedImageSets.size() ) + { + OSL_ENSURE( false, "AnimatedImagesPeer::elementInserted: illegal accessor/index!" ); + lcl_updateImageList_nothrow( *m_pData, xAnimatedImages ); + } + + Sequence< ::rtl::OUString > aImageURLs; + OSL_VERIFY( i_event.Element >>= aImageURLs ); + ::std::vector< CachedImage > aImages; + lcl_init( aImageURLs, aImages ); + m_pData->aCachedImageSets.insert( m_pData->aCachedImageSets.begin() + position, aImages ); + lcl_updateImageList_nothrow( *m_pData ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesPeer::elementRemoved( const ContainerEvent& i_event ) throw (RuntimeException) + { + ::osl::MutexGuard aGuard( GetMutex() ); + Reference< XAnimatedImages > xAnimatedImages( i_event.Source, UNO_QUERY_THROW ); + + sal_Int32 nPosition(0); + OSL_VERIFY( i_event.Accessor >>= nPosition ); + size_t position = size_t( nPosition ); + if ( position >= m_pData->aCachedImageSets.size() ) + { + OSL_ENSURE( false, "AnimatedImagesPeer::elementRemoved: illegal accessor/index!" ); + lcl_updateImageList_nothrow( *m_pData, xAnimatedImages ); + } + + m_pData->aCachedImageSets.erase( m_pData->aCachedImageSets.begin() + position ); + lcl_updateImageList_nothrow( *m_pData ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesPeer::elementReplaced( const ContainerEvent& i_event ) throw (RuntimeException) + { + ::osl::MutexGuard aGuard( GetMutex() ); + Reference< XAnimatedImages > xAnimatedImages( i_event.Source, UNO_QUERY_THROW ); + + sal_Int32 nPosition(0); + OSL_VERIFY( i_event.Accessor >>= nPosition ); + size_t position = size_t( nPosition ); + if ( position >= m_pData->aCachedImageSets.size() ) + { + OSL_ENSURE( false, "AnimatedImagesPeer::elementReplaced: illegal accessor/index!" ); + lcl_updateImageList_nothrow( *m_pData, xAnimatedImages ); + } + + Sequence< ::rtl::OUString > aImageURLs; + OSL_VERIFY( i_event.Element >>= aImageURLs ); + ::std::vector< CachedImage > aImages; + lcl_init( aImageURLs, aImages ); + m_pData->aCachedImageSets[ position ] = aImages; + lcl_updateImageList_nothrow( *m_pData ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesPeer::disposing( const EventObject& i_event ) throw (RuntimeException) + { + VCLXWindow::disposing( i_event ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesPeer::modified( const EventObject& i_event ) throw (RuntimeException) + { + impl_updateImages_nolck( i_event.Source ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesPeer::dispose( ) throw(RuntimeException) + { + AnimatedImagesPeer_Base::dispose(); + ::osl::MutexGuard aGuard( GetMutex() ); + m_pData->aCachedImageSets.resize(0); + } + +//...................................................................................................................... +} // namespace toolkit +//...................................................................................................................... diff --git a/toolkit/source/awt/asynccallback.cxx b/toolkit/source/awt/asynccallback.cxx index e912e83bd12e..672c939d8fd4 100644 --- a/toolkit/source/awt/asynccallback.cxx +++ b/toolkit/source/awt/asynccallback.cxx @@ -194,10 +194,5 @@ void * SAL_CALL comp_AsyncCallback_component_getFactory( implName, serviceManager, registryKey, entries); } -sal_Bool SAL_CALL comp_AsyncCallback_component_writeInfo( - void * serviceManager, void * registryKey) -{ - return ::cppu::component_writeInfoHelper(serviceManager, registryKey, entries); -} -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file diff --git a/toolkit/source/awt/makefile.mk b/toolkit/source/awt/makefile.mk deleted file mode 100644 index 88b40a597410..000000000000 --- a/toolkit/source/awt/makefile.mk +++ /dev/null @@ -1,84 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=..$/.. - -PRJNAME=toolkit -TARGET=awt - -ENABLE_EXCEPTIONS=TRUE - -# --- Settings ----------------------------------------------------- - -.INCLUDE : settings.mk -.INCLUDE : $(PRJ)$/util$/makefile.pmk - -# --- Files -------------------------------------------------------- - -.IF "$(GUIBASE)"=="aqua" -CFLAGSCXX+=$(OBJCXXFLAGS) -.ENDIF # "$(GUIBASE)"=="aqua" - -SLOFILES= \ - $(SLO)$/stylesettings.obj \ - $(SLO)$/vclxaccessiblecomponent.obj \ - $(SLO)$/vclxbitmap.obj \ - $(SLO)$/vclxcontainer.obj \ - $(SLO)$/vclxdevice.obj \ - $(SLO)$/vclxfont.obj \ - $(SLO)$/vclxgraphics.obj \ - $(SLO)$/vclxmenu.obj \ - $(SLO)$/vclxpointer.obj \ - $(SLO)$/vclxprinter.obj \ - $(SLO)$/vclxregion.obj \ - $(SLO)$/vclxsystemdependentwindow.obj \ - $(SLO)$/vclxtoolkit.obj \ - $(SLO)$/vclxtopwindow.obj \ - $(SLO)$/vclxwindow.obj \ - $(SLO)$/vclxwindow1.obj \ - $(SLO)$/vclxwindows.obj \ - $(SLO)$/vclxspinbutton.obj \ - $(SLO)$/xsimpleanimation.obj \ - $(SLO)$/xthrobber.obj \ - $(SLO)$/asynccallback.obj\ - $(SLO)/vclxbutton.obj\ - $(SLO)/vclxdialog.obj\ - $(SLO)/vclxfixedline.obj\ - $(SLO)/vclxplugin.obj\ - $(SLO)/vclxscroller.obj\ - $(SLO)/vclxsplitter.obj\ - $(SLO)/vclxtabcontrol.obj\ - $(SLO)/vclxtabpage.obj - -SRS1NAME=$(TARGET) -SRC1FILES=\ - xthrobber.src - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk - diff --git a/toolkit/source/awt/vclxaccessiblecomponent.cxx b/toolkit/source/awt/vclxaccessiblecomponent.cxx index e8626333aad5..66a2a4bf1cb3 100644 --- a/toolkit/source/awt/vclxaccessiblecomponent.cxx +++ b/toolkit/source/awt/vclxaccessiblecomponent.cxx @@ -249,9 +249,9 @@ void VCLXAccessibleComponent::ProcessWindowEvent( const VclWindowEvent& rVclWind { Window* pWindow = (Window*) rVclWindowEvent.GetData(); DBG_ASSERT( pWindow, "VCLEVENT_WINDOW_CHILDDESTROYED - Window=?" ); - if ( pWindow->GetAccessible( FALSE ).is() ) + if ( pWindow->GetAccessible( sal_False ).is() ) { - aOldValue <<= pWindow->GetAccessible( FALSE ); + aOldValue <<= pWindow->GetAccessible( sal_False ); NotifyAccessibleEvent( accessibility::AccessibleEventId::CHILD, aOldValue, aNewValue ); } } @@ -446,7 +446,7 @@ void VCLXAccessibleComponent::FillAccessibleRelationSet( utl::AccessibleRelation Window* pWindow = GetWindow(); if ( pWindow ) { - Window *pLabeledBy = pWindow->GetLabeledBy(); + Window *pLabeledBy = pWindow->GetAccessibleRelationLabeledBy(); if ( pLabeledBy && pLabeledBy != pWindow ) { uno::Sequence< uno::Reference< uno::XInterface > > aSequence(1); @@ -454,7 +454,7 @@ void VCLXAccessibleComponent::FillAccessibleRelationSet( utl::AccessibleRelation rRelationSet.AddRelation( accessibility::AccessibleRelation( accessibility::AccessibleRelationType::LABELED_BY, aSequence ) ); } - Window* pLabelFor = pWindow->GetLabelFor(); + Window* pLabelFor = pWindow->GetAccessibleRelationLabelFor(); if ( pLabelFor && pLabelFor != pWindow ) { uno::Sequence< uno::Reference< uno::XInterface > > aSequence(1); @@ -569,7 +569,7 @@ uno::Reference< accessibility::XAccessible > VCLXAccessibleComponent::getAccessi uno::Reference< accessibility::XAccessible > xAcc; if ( GetWindow() ) { - Window* pChild = GetWindow()->GetAccessibleChildWindow( (USHORT)i ); + Window* pChild = GetWindow()->GetAccessibleChildWindow( (sal_uInt16)i ); if ( pChild ) xAcc = pChild->GetAccessible(); } @@ -621,7 +621,7 @@ sal_Int32 VCLXAccessibleComponent::getAccessibleIndexInParent( ) throw (uno::Ru if ( pParent ) { /* - for ( USHORT n = pParent->GetAccessibleChildWindowCount(); n; ) + for ( sal_uInt16 n = pParent->GetAccessibleChildWindowCount(); n; ) { Window* pChild = pParent->GetAccessibleChildWindow( --n ); if ( pChild == GetWindow() ) diff --git a/toolkit/source/awt/vclxdialog.cxx b/toolkit/source/awt/vclxdialog.cxx index d75ada7de73e..066cadc06978 100644 --- a/toolkit/source/awt/vclxdialog.cxx +++ b/toolkit/source/awt/vclxdialog.cxx @@ -202,13 +202,13 @@ void VCLXDialog::setTitle( const ::rtl::OUString& Title ) throw(::com::sun::star pWindow->SetText( Title ); } -void VCLXDialog::setHelpId( sal_Int32 id ) throw(::com::sun::star::uno::RuntimeException) +void VCLXDialog::setHelpId( const rtl::OUString& rId ) throw(::com::sun::star::uno::RuntimeException) { SolarMutexGuard aGuard; Window* pWindow = GetWindow(); if ( pWindow ) - pWindow->SetHelpId( id ); + pWindow->SetHelpId( rtl::OUStringToOString( rId, RTL_TEXTENCODING_UTF8 ) ); } ::rtl::OUString VCLXDialog::getTitle() throw(::com::sun::star::uno::RuntimeException) diff --git a/toolkit/source/awt/vclxdialog.hxx b/toolkit/source/awt/vclxdialog.hxx index e7d92aad59c7..785f6b3b7e48 100644 --- a/toolkit/source/awt/vclxdialog.hxx +++ b/toolkit/source/awt/vclxdialog.hxx @@ -98,7 +98,7 @@ public: // ::com::sun::star::awt::XDialog2 void SAL_CALL endDialog( sal_Int32 nResult ) throw(::com::sun::star::uno::RuntimeException); - void SAL_CALL setHelpId( sal_Int32 id ) throw(::com::sun::star::uno::RuntimeException); + void SAL_CALL setHelpId( const rtl::OUString& id ) throw(::com::sun::star::uno::RuntimeException); }; diff --git a/toolkit/source/awt/vclxfont.cxx b/toolkit/source/awt/vclxfont.cxx index 66461db68e77..28224c30232d 100644 --- a/toolkit/source/awt/vclxfont.cxx +++ b/toolkit/source/awt/vclxfont.cxx @@ -63,7 +63,7 @@ void VCLXFont::Init( ::com::sun::star::awt::XDevice& rxDev, const Font& rFont ) maFont = rFont; } -BOOL VCLXFont::ImplAssertValidFontMetric() +sal_Bool VCLXFont::ImplAssertValidFontMetric() { if ( !mpFontMetric && mxDevice.is() ) { @@ -76,7 +76,7 @@ BOOL VCLXFont::ImplAssertValidFontMetric() pOutDev->SetFont( aOldFont ); } } - return mpFontMetric ? TRUE : FALSE; + return mpFontMetric ? sal_True : sal_False; } @@ -150,7 +150,7 @@ sal_Int16 VCLXFont::getCharWidth( sal_Unicode c ) throw(::com::sun::star::uno::R sal_Int16 nCount = nLast-nFirst + 1; aSeq = ::com::sun::star::uno::Sequence<sal_Int16>( nCount ); - for ( USHORT n = 0; n < nCount; n++ ) + for ( sal_uInt16 n = 0; n < nCount; n++ ) { aSeq.getArray()[n] = sal::static_int_cast< sal_Int16 >( pOutDev->GetTextWidth( @@ -205,7 +205,7 @@ void VCLXFont::getKernPairs( ::com::sun::star::uno::Sequence< sal_Unicode >& rnC Font aOldFont = pOutDev->GetFont(); pOutDev->SetFont( maFont ); - ULONG nPairs = pOutDev->GetKerningPairCount(); + sal_uLong nPairs = pOutDev->GetKerningPairCount(); if ( nPairs ) { KerningPair* pData = new KerningPair[ nPairs ]; @@ -219,7 +219,7 @@ void VCLXFont::getKernPairs( ::com::sun::star::uno::Sequence< sal_Unicode >& rnC sal_Unicode* pChars2 = rnChars2.getArray(); sal_Int16* pKerns = rnKerns.getArray(); - for ( ULONG n = 0; n < nPairs; n++ ) + for ( sal_uLong n = 0; n < nPairs; n++ ) { pChars1[n] = pData[n].nChar1; pChars2[n] = pData[n].nChar2; diff --git a/toolkit/source/awt/vclxmenu.cxx b/toolkit/source/awt/vclxmenu.cxx index 3257da29fb49..919986fa49f6 100644 --- a/toolkit/source/awt/vclxmenu.cxx +++ b/toolkit/source/awt/vclxmenu.cxx @@ -108,7 +108,7 @@ VCLXMenu::~VCLXMenu() } } -BOOL VCLXMenu::IsPopupMenu() const +sal_Bool VCLXMenu::IsPopupMenu() const { return (mpMenu && ! mpMenu->IsMenuBar()); } @@ -721,7 +721,7 @@ namespace sal_Bool bMod1 = ((aAWTKey.Modifiers & css::awt::KeyModifier::MOD1 ) == css::awt::KeyModifier::MOD1 ); sal_Bool bMod2 = ((aAWTKey.Modifiers & css::awt::KeyModifier::MOD2 ) == css::awt::KeyModifier::MOD2 ); sal_Bool bMod3 = ((aAWTKey.Modifiers & css::awt::KeyModifier::MOD3 ) == css::awt::KeyModifier::MOD3 ); - USHORT nKey = (USHORT)aAWTKey.KeyCode; + sal_uInt16 nKey = (sal_uInt16)aAWTKey.KeyCode; return KeyCode(nKey, bShift, bMod1, bMod2, bMod3); } @@ -1089,7 +1089,7 @@ DBG_NAME(VCLXMenuBar); VCLXMenuBar::VCLXMenuBar() { DBG_CTOR( VCLXMenuBar, 0 ); - ImplCreateMenu( FALSE ); + ImplCreateMenu( sal_False ); } VCLXMenuBar::VCLXMenuBar( MenuBar* pMenuBar ) : VCLXMenu( (Menu *)pMenuBar ) @@ -1106,7 +1106,7 @@ DBG_NAME(VCLXPopupMenu); VCLXPopupMenu::VCLXPopupMenu() { DBG_CTOR( VCLXPopupMenu, 0 ); - ImplCreateMenu( TRUE ); + ImplCreateMenu( sal_True ); } VCLXPopupMenu::VCLXPopupMenu( PopupMenu* pPopMenu ) : VCLXMenu( (Menu *)pPopMenu ) diff --git a/toolkit/source/awt/vclxplugin.hxx b/toolkit/source/awt/vclxplugin.hxx index 340fa453441f..458fef360d57 100644 --- a/toolkit/source/awt/vclxplugin.hxx +++ b/toolkit/source/awt/vclxplugin.hxx @@ -30,7 +30,7 @@ #define LAYOUT_AWT_VCLXPLUGIN_HXX #include <toolkit/awt/vclxwindow.hxx> -#include <vcl/wintypes.hxx> +#include <tools/wintypes.hxx> class Control; namespace layoutimpl diff --git a/toolkit/source/awt/vclxregion.cxx b/toolkit/source/awt/vclxregion.cxx index 99a1924cecd1..f7df2a3291b3 100644 --- a/toolkit/source/awt/vclxregion.cxx +++ b/toolkit/source/awt/vclxregion.cxx @@ -155,7 +155,7 @@ void VCLXRegion::xOrRegion( const ::com::sun::star::uno::Reference< ::com::sun:: { ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - ULONG nRects = maRegion.GetRectCount(); + sal_uLong nRects = maRegion.GetRectCount(); ::com::sun::star::uno::Sequence< ::com::sun::star::awt::Rectangle > aRects( nRects ); Rectangle aRect; diff --git a/toolkit/source/awt/vclxtabcontrol.cxx b/toolkit/source/awt/vclxtabcontrol.cxx index 40566b886676..cc3940c92784 100644 --- a/toolkit/source/awt/vclxtabcontrol.cxx +++ b/toolkit/source/awt/vclxtabcontrol.cxx @@ -123,7 +123,7 @@ TabControl *VCLXTabControl::getTabControl() const throw (uno::RuntimeException) sal_Int32 SAL_CALL VCLXTabControl::insertTab() throw (uno::RuntimeException) { TabControl *pTabControl = getTabControl(); - USHORT id = sal::static_int_cast< USHORT >( mTabId++ ); + sal_uInt16 id = sal::static_int_cast< sal_uInt16 >( mTabId++ ); rtl::OUString title (RTL_CONSTASCII_USTRINGPARAM( "" ) ); pTabControl->InsertPage( id, title.getStr(), TAB_APPEND ); pTabControl->SetTabPage( id, new TabPage( pTabControl ) ); @@ -133,17 +133,17 @@ sal_Int32 SAL_CALL VCLXTabControl::insertTab() throw (uno::RuntimeException) void SAL_CALL VCLXTabControl::removeTab( sal_Int32 ID ) throw (uno::RuntimeException, IndexOutOfBoundsException) { TabControl *pTabControl = getTabControl(); - if ( pTabControl->GetTabPage( sal::static_int_cast< USHORT >( ID ) ) == NULL ) + if ( pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ) == NULL ) throw IndexOutOfBoundsException(); - pTabControl->RemovePage( sal::static_int_cast< USHORT >( ID ) ); + pTabControl->RemovePage( sal::static_int_cast< sal_uInt16 >( ID ) ); } void SAL_CALL VCLXTabControl::activateTab( sal_Int32 ID ) throw (uno::RuntimeException, IndexOutOfBoundsException) { TabControl *pTabControl = getTabControl(); - if ( pTabControl->GetTabPage( sal::static_int_cast< USHORT >( ID ) ) == NULL ) + if ( pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ) == NULL ) throw IndexOutOfBoundsException(); - pTabControl->SelectTabPage( sal::static_int_cast< USHORT >( ID ) ); + pTabControl->SelectTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ); } sal_Int32 SAL_CALL VCLXTabControl::getActiveTabID() throw (uno::RuntimeException) @@ -181,7 +181,7 @@ void SAL_CALL VCLXTabControl::removeTabListener( const uno::Reference< awt::XTab void SAL_CALL VCLXTabControl::setTabProps( sal_Int32 ID, const uno::Sequence< NamedValue >& Properties ) throw (uno::RuntimeException, IndexOutOfBoundsException) { TabControl *pTabControl = getTabControl(); - if ( pTabControl->GetTabPage( sal::static_int_cast< USHORT >( ID ) ) == NULL ) + if ( pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ) == NULL ) throw IndexOutOfBoundsException(); for ( int i = 0; i < Properties.getLength(); i++ ) @@ -192,7 +192,7 @@ void SAL_CALL VCLXTabControl::setTabProps( sal_Int32 ID, const uno::Sequence< Na if ( name == rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ) ) { rtl::OUString title = value.get<rtl::OUString>(); - pTabControl->SetPageText( sal::static_int_cast< USHORT >( ID ), title.getStr() ); + pTabControl->SetPageText( sal::static_int_cast< sal_uInt16 >( ID ), title.getStr() ); } } } @@ -201,7 +201,7 @@ uno::Sequence< NamedValue > SAL_CALL VCLXTabControl::getTabProps( sal_Int32 ID ) throw (IndexOutOfBoundsException, uno::RuntimeException) { TabControl *pTabControl = getTabControl(); - if ( pTabControl->GetTabPage( sal::static_int_cast< USHORT >( ID ) ) == NULL ) + if ( pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ) == NULL ) throw IndexOutOfBoundsException(); #define ADD_PROP( seq, i, name, val ) { \ @@ -212,8 +212,8 @@ uno::Sequence< NamedValue > SAL_CALL VCLXTabControl::getTabProps( sal_Int32 ID ) } uno::Sequence< NamedValue > props( 2 ); - ADD_PROP( props, 0, "Title", rtl::OUString( pTabControl->GetPageText( sal::static_int_cast< USHORT >( ID ) ) ) ); - ADD_PROP( props, 1, "Position", pTabControl->GetPagePos( sal::static_int_cast< USHORT >( ID ) ) ); + ADD_PROP( props, 0, "Title", rtl::OUString( pTabControl->GetPageText( sal::static_int_cast< sal_uInt16 >( ID ) ) ) ); + ADD_PROP( props, 1, "Position", pTabControl->GetPagePos( sal::static_int_cast< sal_uInt16 >( ID ) ) ); #undef ADD_PROP return props; } @@ -224,7 +224,7 @@ void SAL_CALL VCLXTabControl::draw( sal_Int32 nX, sal_Int32 nY ) throw(uno::Runt SolarMutexGuard aGuard; TabControl *pTabControl = getTabControl(); - TabPage *pTabPage = pTabControl->GetTabPage( sal::static_int_cast< USHORT >( getActiveTabID() ) ); + TabPage *pTabPage = pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( getActiveTabID() ) ); if ( pTabPage ) { ::Point aPos( nX, nY ); @@ -385,8 +385,8 @@ void SAL_CALL VCLXTabControl::allocateArea (awt::Rectangle const &area) if ( active ) { - ::Rectangle label_rect = pTabControl->GetTabBounds( sal::static_int_cast< USHORT >( i+1 ) ); - ::Rectangle page_rect = pTabControl->GetTabPageBounds( sal::static_int_cast< USHORT >( i+1 ) ); + ::Rectangle label_rect = pTabControl->GetTabBounds( sal::static_int_cast< sal_uInt16 >( i+1 ) ); + ::Rectangle page_rect = pTabControl->GetTabPageBounds( sal::static_int_cast< sal_uInt16 >( i+1 ) ); awt::Rectangle childRect; childRect.X = page_rect.Left(); @@ -419,7 +419,7 @@ awt::Size SAL_CALL VCLXTabControl::getMinimumSize() if ( child->mxChild.is() ) { // set the title prop here... - pTabControl->SetPageText( sal::static_int_cast< USHORT >( i+1 ), child->maTitle.getStr() ); + pTabControl->SetPageText( sal::static_int_cast< sal_uInt16 >( i+1 ), child->maTitle.getStr() ); awt::Size childSize( child->mxChild->getMinimumSize() ); childrenSize.Width = SAL_MAX( childSize.Width, childrenSize.Width ); @@ -459,7 +459,7 @@ void VCLXTabControl::ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent case VCLEVENT_TABPAGE_REMOVEDALL: case VCLEVENT_TABPAGE_PAGETEXTCHANGED: { - ULONG page = (ULONG) _rVclWindowEvent.GetData(); + sal_uLong page = (sal_uLong) _rVclWindowEvent.GetData(); for ( std::list< uno::Reference < awt::XTabListener > >::iterator it = mxTabListeners.begin(); it != mxTabListeners.end(); ++it ) @@ -485,7 +485,7 @@ void VCLXTabControl::ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent case VCLEVENT_TABPAGE_REMOVEDALL: for ( int i = 1; i < mTabId; i++) { - if ( pTabControl->GetTabPage( sal::static_int_cast< USHORT >( i ) ) ) + if ( pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( i ) ) ) listener->removed( i ); } break; diff --git a/toolkit/source/awt/vclxtabpagecontainer.cxx b/toolkit/source/awt/vclxtabpagecontainer.cxx new file mode 100644 index 000000000000..01f6fddd10d8 --- /dev/null +++ b/toolkit/source/awt/vclxtabpagecontainer.cxx @@ -0,0 +1,233 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General 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_toolkit.hxx" + +#include <toolkit/awt/vclxtabpagecontainer.hxx> +#include <com/sun/star/awt/tab/XTabPageModel.hpp> +#include <com/sun/star/awt/XControl.hpp> +#include <vcl/tabpage.hxx> +#include <vcl/tabctrl.hxx> +#include <toolkit/helper/property.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <toolkit/helper/tkresmgr.hxx> +#include <cppuhelper/typeprovider.hxx> + +using ::rtl::OUString; +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::container; +using namespace ::com::sun::star::view; +// ---------------------------------------------------- +// class VCLXTabPageContainer +// ---------------------------------------------------- +void VCLXTabPageContainer::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) +{ + VCLXWindow::ImplGetPropertyIds( rIds ); +} + +VCLXTabPageContainer::VCLXTabPageContainer() : + m_aTabPageListeners( *this ) +{ +} + +VCLXTabPageContainer::~VCLXTabPageContainer() +{ +#ifndef __SUNPRO_CC + OSL_TRACE ("%s", __FUNCTION__); +#endif +} + +void SAL_CALL VCLXTabPageContainer::draw( sal_Int32 nX, sal_Int32 nY ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard( GetMutex() ); + TabControl* pTabControl = (TabControl*)GetWindow(); + if ( pTabControl ) + { + TabPage *pTabPage = pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( pTabControl->GetCurPageId( ) ) ); + if ( pTabPage ) + { + ::Point aPos( nX, nY ); + ::Size aSize = pTabPage->GetSizePixel(); + + OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() ); + aPos = pDev->PixelToLogic( aPos ); + aSize = pDev->PixelToLogic( aSize ); + + pTabPage->Draw( pDev, aPos, aSize, 0 ); + } + } + + VCLXWindow::draw( nX, nY ); +/* + if ( pWindow ) + { + OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() ); + if ( !pDev ) + pDev = pWindow->GetParent(); + + Size aSize = pDev->PixelToLogic( pWindow->GetSizePixel() ); + Point aPos = pDev->PixelToLogic( Point( nX, nY ) ); + + pWindow->Draw( pDev, aPos, aSize, WINDOW_DRAW_NOCONTROLS ); + } +*/ +} + +::com::sun::star::awt::DeviceInfo VCLXTabPageContainer::getInfo() throw(RuntimeException) +{ + ::com::sun::star::awt::DeviceInfo aInfo = VCLXDevice::getInfo(); + return aInfo; +} + +void SAL_CALL VCLXTabPageContainer::setProperty(const ::rtl::OUString& PropertyName, const Any& Value ) throw(RuntimeException) +{ + ::osl::MutexGuard aGuard( GetMutex() ); + + TabControl* pTabPage = (TabControl*)GetWindow(); + if ( pTabPage ) + { + VCLXWindow::setProperty( PropertyName, Value ); + } +} +::sal_Int16 SAL_CALL VCLXTabPageContainer::getActiveTabPageID() throw (RuntimeException) +{ + TabControl* pTabCtrl = (TabControl*)GetWindow(); + return pTabCtrl != NULL ? pTabCtrl->GetCurPageId( ) : 0; +} +void SAL_CALL VCLXTabPageContainer::setActiveTabPageID( ::sal_Int16 _activetabpageid ) throw (RuntimeException) +{ + TabControl* pTabCtrl = (TabControl*)GetWindow(); + if ( pTabCtrl ) + pTabCtrl->SelectTabPage(_activetabpageid); +} +::sal_Int32 SAL_CALL VCLXTabPageContainer::getTabPageCount( ) throw (RuntimeException) +{ + TabControl* pTabCtrl = (TabControl*)GetWindow(); + return pTabCtrl != NULL ? pTabCtrl->GetPageCount() : 0; +} +::sal_Bool SAL_CALL VCLXTabPageContainer::isTabPageActive( ::sal_Int16 tabPageIndex ) throw (RuntimeException) +{ + return (getActiveTabPageID() == tabPageIndex); +} +Reference< ::com::sun::star::awt::tab::XTabPage > SAL_CALL VCLXTabPageContainer::getTabPage( ::sal_Int16 tabPageIndex ) throw (RuntimeException) +{ + return (tabPageIndex >= 0 && tabPageIndex < static_cast<sal_Int16>(m_aTabPages.size())) ? m_aTabPages[tabPageIndex] : NULL; +} +Reference< ::com::sun::star::awt::tab::XTabPage > SAL_CALL VCLXTabPageContainer::getTabPageByID( ::sal_Int16 tabPageID ) throw (RuntimeException) +{ + ::osl::ClearableMutexGuard aGuard( GetMutex() ); + Reference< ::com::sun::star::awt::tab::XTabPage > xTabPage; + ::std::vector< Reference< ::com::sun::star::awt::tab::XTabPage > >::iterator aIter = m_aTabPages.begin(); + ::std::vector< Reference< ::com::sun::star::awt::tab::XTabPage > >::iterator aEnd = m_aTabPages.end(); + for(;aIter != aEnd;++aIter) + { + Reference< awt::XControl > xControl(*aIter,UNO_QUERY ); + Reference< awt::tab::XTabPageModel > xP( xControl->getModel(), UNO_QUERY ); + if ( tabPageID == xP->getTabPageID() ) + { + xTabPage = *aIter; + break; + } + } + return xTabPage; +} +void SAL_CALL VCLXTabPageContainer::addTabPageListener( const Reference< ::com::sun::star::awt::tab::XTabPageContainerListener >& listener ) throw (RuntimeException) +{ + m_aTabPageListeners.addInterface( listener ); +} +void SAL_CALL VCLXTabPageContainer::removeTabPageListener( const Reference< ::com::sun::star::awt::tab::XTabPageContainerListener >& listener ) throw (RuntimeException) +{ + m_aTabPageListeners.removeInterface( listener ); +} + +void VCLXTabPageContainer::ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent ) +{ + ::osl::ClearableMutexGuard aGuard( GetMutex() ); + TabControl* pTabControl = static_cast< TabControl* >( GetWindow() ); + if ( pTabControl ) + { + switch ( _rVclWindowEvent.GetId() ) + { + case VCLEVENT_TABPAGE_ACTIVATE: + { +// allocateArea( maAllocation ); + sal_uLong page = (sal_uLong)_rVclWindowEvent.GetData(); + awt::tab::TabPageActivatedEvent aEvent(NULL,page); + m_aTabPageListeners.tabPageActivated(aEvent); + break; + } + default: + aGuard.clear(); + VCLXWindow::ProcessWindowEvent( _rVclWindowEvent ); + break; + } + } +} +void SAL_CALL VCLXTabPageContainer::disposing( const ::com::sun::star::lang::EventObject& /*Source*/ ) throw (::com::sun::star::uno::RuntimeException) +{ +} +void SAL_CALL VCLXTabPageContainer::elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException) +{ + ::osl::MutexGuard aGuard( GetMutex() ); + TabControl* pTabCtrl = (TabControl*)GetWindow(); + Reference< ::com::sun::star::awt::tab::XTabPage > xTabPage(Event.Element,uno::UNO_QUERY); + if ( pTabCtrl && xTabPage.is() ) + { + Reference< awt::XControl > xControl(xTabPage,UNO_QUERY ); + Reference< awt::tab::XTabPageModel > xP( xControl->getModel(), UNO_QUERY ); + sal_Int16 nPageID = xP->getTabPageID(); + + Window* pWindow = VCLUnoHelper::GetWindow(xControl->getPeer()); + TabPage* pPage = (TabPage*)pWindow; + pTabCtrl->InsertPage(nPageID,pPage->GetText()); + + pPage->Hide(); + pTabCtrl->SetTabPage(nPageID,pPage); + pTabCtrl->SetHelpText(nPageID,xP->getTooltip()); + pTabCtrl->SetPageImage(nPageID,TkResMgr::getImageFromURL(xP->getImageURL())); + pTabCtrl->SelectTabPage(nPageID); + m_aTabPages.push_back(xTabPage); + } +} +void SAL_CALL VCLXTabPageContainer::elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException) +{ + ::osl::MutexGuard aGuard( GetMutex() ); + TabControl* pTabCtrl = (TabControl*)GetWindow(); + Reference< ::com::sun::star::awt::tab::XTabPage > xTabPage(Event.Element,uno::UNO_QUERY); + if ( pTabCtrl && xTabPage.is() ) + { + Reference< awt::XControl > xControl(xTabPage,UNO_QUERY ); + Reference< awt::tab::XTabPageModel > xP( xControl->getModel(), UNO_QUERY ); + pTabCtrl->RemovePage(xP->getTabPageID()); + m_aTabPages.erase(::std::remove(m_aTabPages.begin(),m_aTabPages.end(),xTabPage)); + } +} +void SAL_CALL VCLXTabPageContainer::elementReplaced( const ::com::sun::star::container::ContainerEvent& /*Event*/ ) throw (::com::sun::star::uno::RuntimeException) +{ +} diff --git a/toolkit/source/awt/vclxtabpagemodel.cxx b/toolkit/source/awt/vclxtabpagemodel.cxx new file mode 100644 index 000000000000..c7145992bd7f --- /dev/null +++ b/toolkit/source/awt/vclxtabpagemodel.cxx @@ -0,0 +1,150 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General 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_toolkit.hxx" + +#include <toolkit/awt/vclxtabpagemodel.hxx> +#include <vcl/tabpage.hxx> +#include <vcl/tabctrl.hxx> +#include <toolkit/helper/property.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <toolkit/helper/unopropertyarrayhelper.hxx> +#include <cppuhelper/typeprovider.hxx> +// ---------------------------------------------------- +// class VCLXDialog +// ---------------------------------------------------- + +VCLXTabPageModel::VCLXTabPageModel() +{ +} + +VCLXTabPageModel::~VCLXTabPageModel() +{ +#ifndef __SUNPRO_CC + OSL_TRACE ("%s", __FUNCTION__); +#endif +} + +void SAL_CALL VCLXTabPageModel::draw( sal_Int32 nX, sal_Int32 nY ) throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::MutexGuard aGuard( GetMutex() ); + Window* pWindow = GetWindow(); + + if ( pWindow ) + { + OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() ); + if ( !pDev ) + pDev = pWindow->GetParent(); + + Size aSize = pDev->PixelToLogic( pWindow->GetSizePixel() ); + Point aPos = pDev->PixelToLogic( Point( nX, nY ) ); + + pWindow->Draw( pDev, aPos, aSize, WINDOW_DRAW_NOCONTROLS ); + } +} + +::com::sun::star::awt::DeviceInfo VCLXTabPageModel::getInfo() throw(::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::awt::DeviceInfo aInfo;// = VCLXDevice::getInfo(); + return aInfo; +} + + +void SAL_CALL VCLXTabPageModel::setProperty( + const ::rtl::OUString& /*PropertyName*/, + const ::com::sun::star::uno::Any& /*Value*/ ) +throw(::com::sun::star::uno::RuntimeException) +{ + ::osl::MutexGuard aGuard( GetMutex() ); + + /*TabPage* pTabPage = (TabPage*)GetWindow(); + if ( pTabPage ) + { + VCLXWindow::setProperty( PropertyName, Value ); + }*/ +} +//XTabPageModel +::sal_Int16 SAL_CALL VCLXTabPageModel::getTabPageID() throw (::com::sun::star::uno::RuntimeException) +{ + return 0; +} +::sal_Bool SAL_CALL VCLXTabPageModel::getEnabled() throw (::com::sun::star::uno::RuntimeException) +{ + return false; +} +void SAL_CALL VCLXTabPageModel::setEnabled( ::sal_Bool _enabled ) throw (::com::sun::star::uno::RuntimeException) +{ + //TabControl* pTabControl = (TabControl*)GetWindow(); + //if ( pTabControl ) + // pTabControl->EnablePage(0, true); +} +::rtl::OUString SAL_CALL VCLXTabPageModel::getTitle() throw (::com::sun::star::uno::RuntimeException) +{ + //TabControl* pTabControl = (TabControl*)GetWindow(); + //if ( pTabControl ) + // return pTabControl->GetPageText(0); + //else + return ::rtl::OUString::createFromAscii(""); +} +void SAL_CALL VCLXTabPageModel::setTitle( const ::rtl::OUString& _title ) throw (::com::sun::star::uno::RuntimeException) +{ + //TabControl* pTabControl = (TabControl*)GetWindow(); + //if ( pTabControl ) + // pTabControl->SetPageText(0, _title); + +} +::rtl::OUString SAL_CALL VCLXTabPageModel::getImageURL() throw (::com::sun::star::uno::RuntimeException) +{ + return ::rtl::OUString::createFromAscii(""); +} +void SAL_CALL VCLXTabPageModel::setImageURL( const ::rtl::OUString& /*_imageurl*/ ) throw (::com::sun::star::uno::RuntimeException) +{ + //m_sImageURL = _imageurl; +} +::rtl::OUString SAL_CALL VCLXTabPageModel::getTooltip() throw (::com::sun::star::uno::RuntimeException) +{ + //return m_sTooltip; + return ::rtl::OUString::createFromAscii(""); +} +void SAL_CALL VCLXTabPageModel::setTooltip( const ::rtl::OUString& _tooltip ) throw (::com::sun::star::uno::RuntimeException) +{ + (void)_tooltip; +} +::cppu::IPropertyArrayHelper& VCLXTabPageModel::getInfoHelper() +{ + static UnoPropertyArrayHelper* pHelper = NULL; + if ( !pHelper ) + { + com::sun::star::uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds(); + pHelper = new UnoPropertyArrayHelper( aIDs ); + } + return *pHelper; +} +::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > VCLXTabPageModel::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException) +{ + static ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); + return xInfo; +} diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx index cdac85f86885..72b9e05688c8 100644 --- a/toolkit/source/awt/vclxtoolkit.cxx +++ b/toolkit/source/awt/vclxtoolkit.cxx @@ -35,6 +35,7 @@ #include <tools/svwin.h> #include <stdio.h> +#include <com/sun/star/awt/ImageScaleMode.hpp> #include <com/sun/star/awt/WindowAttribute.hpp> #include <com/sun/star/awt/VclWindowPeerAttribute.hpp> #include <com/sun/star/awt/WindowClass.hpp> @@ -69,9 +70,12 @@ #include <toolkit/awt/vclxsystemdependentwindow.hxx> #include <toolkit/awt/vclxregion.hxx> #include <toolkit/awt/vclxtoolkit.hxx> +#include <toolkit/awt/vclxtabpagecontainer.hxx> +#include <toolkit/awt/vclxtabpagemodel.hxx> #include <toolkit/awt/xsimpleanimation.hxx> #include <toolkit/awt/xthrobber.hxx> +#include <toolkit/awt/animatedimagespeer.hxx> #include <toolkit/awt/vclxtopwindow.hxx> #include <toolkit/awt/vclxwindow.hxx> #include <toolkit/helper/vclunohelper.hxx> @@ -113,6 +117,7 @@ #include <vcl/virdev.hxx> #include <vcl/window.hxx> #include <vcl/wrkwin.hxx> +#include <vcl/throbber.hxx> #include "toolkit/awt/vclxspinbutton.hxx" #include <tools/debug.hxx> @@ -313,6 +318,7 @@ static ComponentInfo aComponentInfos [] = { "scrollbar", WINDOW_SCROLLBAR }, { "scrollbarbox", WINDOW_SCROLLBARBOX }, { "simpleanimation", WINDOW_CONTROL }, + { "animatedimages", WINDOW_CONTROL }, { "spinbutton", WINDOW_SPINBUTTON }, { "spinfield", WINDOW_SPINFIELD }, { "throbber", WINDOW_CONTROL }, @@ -329,7 +335,9 @@ static ComponentInfo aComponentInfos [] = { "tristatebox", WINDOW_TRISTATEBOX }, { "warningbox", WINDOW_WARNINGBOX }, { "window", WINDOW_WINDOW }, - { "workwindow", WINDOW_WORKWINDOW } + { "workwindow", WINDOW_WORKWINDOW }, + { "tabpagecontainer", WINDOW_CONTROL }, + { "tabpagemodel", WINDOW_TABPAGE } }; extern "C" @@ -384,7 +392,7 @@ sal_uInt16 ImplGetComponentType( const String& rServiceName ) // ---------------------------------------------------- static sal_Int32 nVCLToolkitInstanceCount = 0; -static BOOL bInitedByVCLToolkit = sal_False; +static sal_Bool bInitedByVCLToolkit = sal_False; //static cppu::OInterfaceContainerHelper * pToolkits = 0; static osl::Mutex & getInitMutex() @@ -687,7 +695,7 @@ Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, break; case WINDOW_CURRENCYFIELD: pNewWindow = new CurrencyField( pParent, nWinBits ); - static_cast<CurrencyField*>(pNewWindow)->EnableEmptyFieldValue( TRUE ); + static_cast<CurrencyField*>(pNewWindow)->EnableEmptyFieldValue( sal_True ); *ppNewComp = new VCLXNumericField; ((VCLXFormattedSpinField*)*ppNewComp)->SetFormatter( (FormatterBase*)(CurrencyField*)pNewWindow ); break; @@ -696,7 +704,7 @@ Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, break; case WINDOW_DATEFIELD: pNewWindow = new DateField( pParent, nWinBits ); - static_cast<DateField*>(pNewWindow)->EnableEmptyFieldValue( TRUE ); + static_cast<DateField*>(pNewWindow)->EnableEmptyFieldValue( sal_True ); *ppNewComp = new VCLXDateField; ((VCLXFormattedSpinField*)*ppNewComp)->SetFormatter( (FormatterBase*)(DateField*)pNewWindow ); break; @@ -738,7 +746,7 @@ Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, *ppNewComp = new VCLXFrame; // Frame control needs to recieve // Mouse events - pGroupBox->SetMouseTransparent( FALSE ); + pGroupBox->SetMouseTransparent( sal_False ); } } break; @@ -811,7 +819,7 @@ Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, break; case WINDOW_NUMERICFIELD: pNewWindow = new NumericField( pParent, nWinBits ); - static_cast<NumericField*>(pNewWindow)->EnableEmptyFieldValue( TRUE ); + static_cast<NumericField*>(pNewWindow)->EnableEmptyFieldValue( sal_True ); *ppNewComp = new VCLXNumericField; ((VCLXFormattedSpinField*)*ppNewComp)->SetFormatter( (FormatterBase*)(NumericField*)pNewWindow ); break; @@ -843,12 +851,12 @@ Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, // Since the VCLXRadioButton really cares for it's RadioCheck settings, this is important: // if we enable it, the VCLXRadioButton will use RadioButton::Check instead of RadioButton::SetState // This leads to a strange behaviour if the control is newly created: when settings the initial - // state to "checked", the RadioButton::Check (called because RadioCheck=TRUE) will uncheck + // state to "checked", the RadioButton::Check (called because RadioCheck=sal_True) will uncheck // _all_other_ radio buttons in the same group. However, at this moment the grouping of the controls // is not really valid: the controls are grouped after they have been created, but we're still in // the creation process, so the RadioButton::Check relies on invalid grouping information. // 07.08.2001 - #87254# - frank.schoenheit@sun.com - static_cast<RadioButton*>(pNewWindow)->EnableRadioCheck( FALSE ); + static_cast<RadioButton*>(pNewWindow)->EnableRadioCheck( sal_False ); break; case WINDOW_SCROLLBAR: pNewWindow = new ScrollBar( pParent, nWinBits ); @@ -886,15 +894,26 @@ Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, pNewWindow = new TabDialog( pParent, nWinBits ); break; case WINDOW_TABPAGE: - pNewWindow = new TabPage( pParent, nWinBits ); - *ppNewComp = new VCLXTabPage; + /* + if ( rDescriptor.WindowServiceName.equalsIgnoreAsciiCase( + ::rtl::OUString::createFromAscii("tabpagemodel") ) ) + { + pNewWindow = new TabControl( pParent, nWinBits ); + *ppNewComp = new VCLXTabPageContainer; + } + else + */ + { + pNewWindow = new TabPage( pParent, nWinBits ); + *ppNewComp = new VCLXTabPage; + } break; case WINDOW_TIMEBOX: pNewWindow = new TimeBox( pParent, nWinBits ); break; case WINDOW_TIMEFIELD: pNewWindow = new TimeField( pParent, nWinBits ); - static_cast<TimeField*>(pNewWindow)->EnableEmptyFieldValue( TRUE ); + static_cast<TimeField*>(pNewWindow)->EnableEmptyFieldValue( sal_True ); *ppNewComp = new VCLXTimeField; ((VCLXFormattedSpinField*)*ppNewComp)->SetFormatter( (FormatterBase*)(TimeField*)pNewWindow ); break; @@ -1002,22 +1021,35 @@ Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, } break; case WINDOW_CONTROL: - if ( rDescriptor.WindowServiceName.equalsIgnoreAsciiCase( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("simpleanimation")) ) ) + if ( aServiceName.EqualsAscii( "simpleanimation" ) ) { - nWinBits |= WB_SCALE; - pNewWindow = new FixedImage( pParent, nWinBits ); + pNewWindow = new Throbber( pParent, nWinBits, Throbber::IMAGES_NONE ); + ((Throbber*)pNewWindow)->SetScaleMode( css::awt::ImageScaleMode::Anisotropic ); + // (compatibility) *ppNewComp = new ::toolkit::XSimpleAnimation; } - else if ( rDescriptor.WindowServiceName.equalsIgnoreAsciiCase( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("throbber")) ) ) + else if ( aServiceName.EqualsAscii( "throbber" ) ) { - nWinBits |= WB_SCALE; - pNewWindow = new FixedImage( pParent, nWinBits ); + pNewWindow = new Throbber( pParent, nWinBits, Throbber::IMAGES_NONE ); + ((Throbber*)pNewWindow)->SetScaleMode( css::awt::ImageScaleMode::Anisotropic ); + // (compatibility) *ppNewComp = new ::toolkit::XThrobber; } + else if ( rDescriptor.WindowServiceName.equalsIgnoreAsciiCase( + ::rtl::OUString::createFromAscii("tabpagecontainer") ) ) + { + pNewWindow = new TabControl( pParent, nWinBits ); + *ppNewComp = new VCLXTabPageContainer; + } + else if ( aServiceName.EqualsAscii( "animatedimages" ) ) + { + pNewWindow = new Throbber( pParent, nWinBits ); + *ppNewComp = new ::toolkit::AnimatedImagesPeer; + } break; - default: DBG_ERRORFILE( "UNO3!" ); + default: + OSL_ENSURE( false, "VCLXToolkit::ImplCreateWindow: unknown window type!" ); + break; } } @@ -1061,7 +1093,7 @@ css::uno::Reference< css::awt::XWindowPeer > VCLXToolkit::ImplCreateWindow( // try to load the lib if ( !fnSvtCreateWindow && !hSvToolsLib ) { - ::rtl::OUString aLibName = ::vcl::unohelper::CreateLibraryName( "svt", TRUE ); + ::rtl::OUString aLibName = ::vcl::unohelper::CreateLibraryName( "svt", sal_True ); hSvToolsLib = osl_loadModuleRelative( &thisModule, aLibName.pData, SAL_LOADMODULE_DEFAULT ); if ( hSvToolsLib ) @@ -1108,11 +1140,11 @@ css::uno::Reference< css::awt::XWindowPeer > VCLXToolkit::ImplCreateWindow( } else { - pNewComp->SetCreatedWithToolkit( TRUE ); + pNewComp->SetCreatedWithToolkit( sal_True ); xRef = pNewComp; pNewWindow->SetComponentInterface( xRef ); } - DBG_ASSERT( pNewWindow->GetComponentInterface( FALSE ) == xRef, + DBG_ASSERT( pNewWindow->GetComponentInterface( sal_False ) == xRef, "VCLXToolkit::createWindow: did #133706# resurge?" ); if ( rDescriptor.WindowAttributes & ::com::sun::star::awt::WindowAttribute::SHOW ) diff --git a/toolkit/source/awt/vclxwindow.cxx b/toolkit/source/awt/vclxwindow.cxx index 243f682f1097..2169203e5916 100644 --- a/toolkit/source/awt/vclxwindow.cxx +++ b/toolkit/source/awt/vclxwindow.cxx @@ -66,8 +66,9 @@ #include <vcl/tabpage.hxx> #include <vcl/button.hxx> #include <comphelper/asyncnotification.hxx> +#include <comphelper/flagguard.hxx> #include "stylesettings.hxx" - +#include <tools/urlobj.hxx> #include <toolkit/helper/unopropertyarrayhelper.hxx> #include <boost/bind.hpp> @@ -93,32 +94,6 @@ namespace WritingMode2 = ::com::sun::star::text::WritingMode2; namespace MouseWheelBehavior = ::com::sun::star::awt::MouseWheelBehavior; //==================================================================== -//= misc helpers -//==================================================================== -namespace -{ - //................................................................ - //. FlagGuard - //................................................................ - class FlagGuard - { - private: - bool& m_rFlag; - - public: - FlagGuard( bool& _rFlag ) - :m_rFlag( _rFlag ) - { - m_rFlag = true; - } - ~FlagGuard() - { - m_rFlag = false; - } - }; -} - -//==================================================================== //= VCLXWindowImpl //==================================================================== class SAL_DLLPRIVATE VCLXWindowImpl @@ -148,7 +123,7 @@ private: TopWindowListenerMultiplexer maTopWindowListeners; CallbackArray maCallbackEvents; - ULONG mnCallbackEventId; + sal_uLong mnCallbackEventId; public: bool mbDisposing : 1; @@ -156,7 +131,7 @@ public: bool mbSynthesizingVCLEvent : 1; bool mbWithDefaultProps : 1; - ULONG mnListenerLockLevel; + sal_uLong mnListenerLockLevel; sal_Int16 mnWritingMode; sal_Int16 mnContextWritingMode; @@ -889,7 +864,7 @@ void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) { if ( mpImpl->getDockableWindowListeners().getLength() ) { - BOOL *p_bFloating = (BOOL*)rVclWindowEvent.GetData(); + sal_Bool *p_bFloating = (sal_Bool*)rVclWindowEvent.GetData(); ::com::sun::star::lang::EventObject aEvent; aEvent.Source = (::cppu::OWeakObject*)this; @@ -948,7 +923,7 @@ void VCLXWindow::SetSynthesizingVCLEvent( sal_Bool _b ) mpImpl->mbSynthesizingVCLEvent = _b; } -BOOL VCLXWindow::IsSynthesizingVCLEvent() const +sal_Bool VCLXWindow::IsSynthesizingVCLEvent() const { return mpImpl->mbSynthesizingVCLEvent; } @@ -1089,7 +1064,7 @@ void VCLXWindow::setEnable( sal_Bool bEnable ) throw(::com::sun::star::uno::Runt Window* pWindow = GetWindow(); if ( pWindow ) { - pWindow->Enable( bEnable, FALSE ); // #95824# without children! + pWindow->Enable( bEnable, sal_False ); // #95824# without children! pWindow->EnableInput( bEnable ); } } @@ -1114,7 +1089,7 @@ void VCLXWindow::addWindowListener( const ::com::sun::star::uno::Reference< ::co // #100119# Get all resize events, even if height or width 0, or invisible if ( GetWindow() ) - GetWindow()->EnableAllResize( TRUE ); + GetWindow()->EnableAllResize( sal_True ); } void VCLXWindow::removeWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException) @@ -1347,7 +1322,7 @@ namespace toolkit (aStyleSettings.*pSetter)( Color( nColor ) ); aSettings.SetStyleSettings( aStyleSettings ); - _pWindow->SetSettings( aSettings, TRUE ); + _pWindow->SetSettings( aSettings, sal_True ); } } @@ -1423,11 +1398,11 @@ namespace { void lcl_updateWritingMode( Window& _rWindow, const sal_Int16 _nWritingMode, const sal_Int16 _nContextWritingMode ) { - BOOL bEnableRTL = FALSE; + sal_Bool bEnableRTL = sal_False; switch ( _nWritingMode ) { - case WritingMode2::LR_TB: bEnableRTL = FALSE; break; - case WritingMode2::RL_TB: bEnableRTL = TRUE; break; + case WritingMode2::LR_TB: bEnableRTL = sal_False; break; + case WritingMode2::RL_TB: bEnableRTL = sal_True; break; case WritingMode2::CONTEXT: { // consult our ContextWritingMode. If it has an explicit RTL/LTR value, then use @@ -1435,8 +1410,8 @@ namespace // own window for its RTL mode switch ( _nContextWritingMode ) { - case WritingMode2::LR_TB: bEnableRTL = FALSE; break; - case WritingMode2::RL_TB: bEnableRTL = TRUE; break; + case WritingMode2::LR_TB: bEnableRTL = sal_False; break; + case WritingMode2::RL_TB: bEnableRTL = sal_True; break; case WritingMode2::CONTEXT: { const Window* pParent = _rWindow.GetParent(); @@ -1507,7 +1482,7 @@ void VCLXWindow::setProperty( const ::rtl::OUString& PropertyName, const ::com:: AllSettings aSettings = pWindow->GetSettings(); MouseSettings aMouseSettings = aSettings.GetMouseSettings(); - USHORT nVclBehavior( MOUSE_WHEEL_FOCUS_ONLY ); + sal_uInt16 nVclBehavior( MOUSE_WHEEL_FOCUS_ONLY ); switch ( nWheelBehavior ) { case MouseWheelBehavior::SCROLL_DISABLED: nVclBehavior = MOUSE_WHEEL_DISABLE; break; @@ -1519,7 +1494,7 @@ void VCLXWindow::setProperty( const ::rtl::OUString& PropertyName, const ::com:: aMouseSettings.SetWheelBehavior( nVclBehavior ); aSettings.SetMouseSettings( aMouseSettings ); - pWindow->SetSettings( aSettings, TRUE ); + pWindow->SetSettings( aSettings, sal_True ); } break; @@ -1594,17 +1569,11 @@ void VCLXWindow::setProperty( const ::rtl::OUString& PropertyName, const ::com:: ::rtl::OUString aURL; if ( Value >>= aURL ) { - String aHelpURL( aURL ); - String aPattern( RTL_CONSTASCII_USTRINGPARAM( "HID:" ) ); - if ( aHelpURL.CompareIgnoreCaseToAscii( aPattern, aPattern.Len() ) == COMPARE_EQUAL ) - { - String aID = aHelpURL.Copy( aPattern.Len() ); - pWindow->SetHelpId( aID.ToInt32() ); - } + INetURLObject aHelpURL( aURL ); + if ( aHelpURL.GetProtocol() == INET_PROT_HID ) + pWindow->SetHelpId( rtl::OUStringToOString( aHelpURL.GetURLPath(), RTL_TEXTENCODING_UTF8 ) ); else - { - pWindow->SetSmartHelpId( SmartId( aHelpURL ) ); - } + pWindow->SetHelpId( rtl::OUStringToOString( aURL, RTL_TEXTENCODING_UTF8 ) ); } } break; @@ -1680,7 +1649,7 @@ void VCLXWindow::setProperty( const ::rtl::OUString& PropertyName, const ::com:: // support transparency only for special controls pWindow->SetBackground(); pWindow->SetControlBackground(); - pWindow->SetPaintTransparent( TRUE ); + pWindow->SetPaintTransparent( sal_True ); break; } @@ -1713,7 +1682,7 @@ void VCLXWindow::setProperty( const ::rtl::OUString& PropertyName, const ::com:: case WINDOW_RADIOBUTTON: case WINDOW_GROUPBOX: case WINDOW_FIXEDLINE: - pWindow->SetPaintTransparent( FALSE ); + pWindow->SetPaintTransparent( sal_False ); default: ; } pWindow->Invalidate(); // Falls das Control nicht drauf reagiert @@ -1945,7 +1914,7 @@ void VCLXWindow::setProperty( const ::rtl::OUString& PropertyName, const ::com:: case BASEPROPERTY_REPEAT: { - sal_Bool bRepeat( FALSE ); + sal_Bool bRepeat( sal_False ); Value >>= bRepeat; WinBits nStyle = pWindow->GetStyle(); @@ -1968,7 +1937,7 @@ void VCLXWindow::setProperty( const ::rtl::OUString& PropertyName, const ::com:: aMouseSettings.SetButtonRepeat( nRepeatDelay ); aSettings.SetMouseSettings( aMouseSettings ); - pWindow->SetSettings( aSettings, TRUE ); + pWindow->SetSettings( aSettings, sal_True ); } } break; @@ -2023,7 +1992,7 @@ void VCLXWindow::setProperty( const ::rtl::OUString& PropertyName, const ::com:: case BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR: { - USHORT nVclBehavior = GetWindow()->GetSettings().GetMouseSettings().GetWheelBehavior(); + sal_uInt16 nVclBehavior = GetWindow()->GetSettings().GetMouseSettings().GetWheelBehavior(); sal_Int16 nBehavior = MouseWheelBehavior::SCROLL_FOCUS_ONLY; switch ( nVclBehavior ) { @@ -2075,19 +2044,8 @@ void VCLXWindow::setProperty( const ::rtl::OUString& PropertyName, const ::com:: break; case BASEPROPERTY_HELPURL: { - SmartId aSmartId = GetWindow()->GetSmartHelpId(); - if( aSmartId.HasString() ) - { - String aStrHelpId = aSmartId.GetStr(); - aProp <<= ::rtl::OUString( aStrHelpId ); - } - else - { - ::rtl::OUStringBuffer aURL; - aURL.appendAscii( "HID:" ); - aURL.append( (sal_Int32) GetWindow()->GetHelpId() ); - aProp <<= aURL.makeStringAndClear(); - } + rtl::OUString aHelpId( rtl::OStringToOUString( GetWindow()->GetHelpId(), RTL_TEXTENCODING_UTF8 ) ); + aProp <<= ::rtl::OUString( aHelpId ); } break; case BASEPROPERTY_FONTDESCRIPTOR: @@ -2358,9 +2316,9 @@ void VCLXWindow::draw( sal_Int32 nX, sal_Int32 nY ) throw(::com::sun::star::uno: // #i40647# / 2005-01-18 / frank.schoenheit@sun.com if ( !mpImpl->getDrawingOntoParent_ref() ) { - FlagGuard aDrawingflagGuard( mpImpl->getDrawingOntoParent_ref() ); + ::comphelper::FlagGuard aDrawingflagGuard( mpImpl->getDrawingOntoParent_ref() ); - BOOL bWasVisible = pWindow->IsVisible(); + sal_Bool bWasVisible = pWindow->IsVisible(); Point aOldPos( pWindow->GetPosPixel() ); if ( bWasVisible && aOldPos == aPos ) @@ -2385,7 +2343,7 @@ void VCLXWindow::draw( sal_Int32 nX, sal_Int32 nY ) throw(::com::sun::star::uno: pWindow->SetPosPixel( aOldPos ); if ( bWasVisible ) - pWindow->Show( TRUE ); + pWindow->Show( sal_True ); } } else if ( pDev ) @@ -2404,12 +2362,12 @@ void VCLXWindow::draw( sal_Int32 nX, sal_Int32 nY ) throw(::com::sun::star::uno: } else { - BOOL bOldNW =pWindow->IsNativeWidgetEnabled(); + sal_Bool bOldNW =pWindow->IsNativeWidgetEnabled(); if( bOldNW ) - pWindow->EnableNativeWidget(FALSE); + pWindow->EnableNativeWidget(sal_False); pWindow->PaintToDevice( pDev, aP, aSz ); if( bOldNW ) - pWindow->EnableNativeWidget(TRUE); + pWindow->EnableNativeWidget(sal_True); } } } @@ -2505,7 +2463,7 @@ sal_Bool SAL_CALL VCLXWindow::isFloating( ) throw (::com::sun::star::uno::Runti if( pWindow ) return Window::GetDockingManager()->IsFloating( pWindow ); else - return FALSE; + return sal_False; } void SAL_CALL VCLXWindow::setFloatingMode( sal_Bool bFloating ) throw (::com::sun::star::uno::RuntimeException) @@ -2525,7 +2483,7 @@ sal_Bool SAL_CALL VCLXWindow::isLocked( ) throw (::com::sun::star::uno::Runtime if( pWindow ) return Window::GetDockingManager()->IsLocked( pWindow ); else - return FALSE; + return sal_False; } void SAL_CALL VCLXWindow::lock( ) throw (::com::sun::star::uno::RuntimeException) @@ -2556,7 +2514,7 @@ sal_Bool SAL_CALL VCLXWindow::isInPopupMode( ) throw (::com::sun::star::uno::Ru { // TODO: remove interface in the next incompatible build SolarMutexGuard aGuard; - return FALSE; + return sal_False; } @@ -2598,7 +2556,7 @@ sal_Bool SAL_CALL VCLXWindow::isVisible( ) throw (::com::sun::star::uno::Runtim if( GetWindow() ) return GetWindow()->IsVisible(); else - return FALSE; + return sal_False; } sal_Bool SAL_CALL VCLXWindow::isActive( ) throw (::com::sun::star::uno::RuntimeException) @@ -2607,7 +2565,7 @@ sal_Bool SAL_CALL VCLXWindow::isActive( ) throw (::com::sun::star::uno::Runtime if( GetWindow() ) return GetWindow()->IsActive(); else - return FALSE; + return sal_False; } @@ -2617,7 +2575,7 @@ sal_Bool SAL_CALL VCLXWindow::isEnabled( ) throw (::com::sun::star::uno::Runtim if( GetWindow() ) return GetWindow()->IsEnabled(); else - return FALSE; + return sal_False; } sal_Bool SAL_CALL VCLXWindow::hasFocus( ) throw (::com::sun::star::uno::RuntimeException) @@ -2626,7 +2584,7 @@ sal_Bool SAL_CALL VCLXWindow::hasFocus( ) throw (::com::sun::star::uno::Runtime if( GetWindow() ) return GetWindow()->HasFocus(); else - return FALSE; + return sal_False; } // ::com::sun::star::beans::XPropertySetInfo diff --git a/toolkit/source/awt/vclxwindow1.cxx b/toolkit/source/awt/vclxwindow1.cxx index 5f1640a69139..de6be4c34ef7 100644 --- a/toolkit/source/awt/vclxwindow1.cxx +++ b/toolkit/source/awt/vclxwindow1.cxx @@ -93,7 +93,7 @@ void VCLXWindow::SetSystemParent_Impl( const com::sun::star::uno::Any& rHandle ) // create system parent data SystemParentData aSysParentData; aSysParentData.nSize = sizeof ( SystemParentData ); -#if defined( WIN ) || defined( WNT ) || defined ( OS2 ) +#if defined( WNT ) || defined ( OS2 ) aSysParentData.hWnd = (HWND) nHandle; #elif defined( QUARTZ ) aSysParentData.pView = reinterpret_cast<NSView*>(nHandle); diff --git a/toolkit/source/awt/vclxwindows.cxx b/toolkit/source/awt/vclxwindows.cxx index 3031cb70b6cc..cb1dbff80386 100644 --- a/toolkit/source/awt/vclxwindows.cxx +++ b/toolkit/source/awt/vclxwindows.cxx @@ -38,6 +38,7 @@ #include <toolkit/helper/imagealign.hxx> #include <toolkit/helper/accessibilityclient.hxx> #include <toolkit/helper/fixedhyperbase.hxx> +#include <toolkit/helper/tkresmgr.hxx> #include <cppuhelper/typeprovider.hxx> #include <com/sun/star/awt/VisualEffect.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> @@ -61,6 +62,7 @@ #include <vcl/scrbar.hxx> #include <vcl/svapp.hxx> #include <vcl/tabpage.hxx> +#include <vcl/tabctrl.hxx> #include <tools/diagnose_ex.h> #include <boost/bind.hpp> @@ -134,24 +136,24 @@ namespace toolkit sal_Int32 nWhiteLuminance = Color( COL_WHITE ).GetLuminance(); Color aLightShadow( nBackgroundColor ); - aLightShadow.IncreaseLuminance( (UINT8)( ( nWhiteLuminance - nBackgroundLuminance ) * 2 / 3 ) ); + aLightShadow.IncreaseLuminance( (sal_uInt8)( ( nWhiteLuminance - nBackgroundLuminance ) * 2 / 3 ) ); aStyleSettings.SetLightBorderColor( aLightShadow ); Color aLight( nBackgroundColor ); - aLight.IncreaseLuminance( (UINT8)( ( nWhiteLuminance - nBackgroundLuminance ) * 1 / 3 ) ); + aLight.IncreaseLuminance( (sal_uInt8)( ( nWhiteLuminance - nBackgroundLuminance ) * 1 / 3 ) ); aStyleSettings.SetLightColor( aLight ); Color aShadow( nBackgroundColor ); - aShadow.DecreaseLuminance( (UINT8)( nBackgroundLuminance * 1 / 3 ) ); + aShadow.DecreaseLuminance( (sal_uInt8)( nBackgroundLuminance * 1 / 3 ) ); aStyleSettings.SetShadowColor( aShadow ); Color aDarkShadow( nBackgroundColor ); - aDarkShadow.DecreaseLuminance( (UINT8)( nBackgroundLuminance * 2 / 3 ) ); + aDarkShadow.DecreaseLuminance( (sal_uInt8)( nBackgroundLuminance * 2 / 3 ) ); aStyleSettings.SetDarkShadowColor( aDarkShadow ); } aSettings.SetStyleSettings( aStyleSettings ); - _pWindow->SetSettings( aSettings, TRUE ); + _pWindow->SetSettings( aSettings, sal_True ); } Any getButtonLikeFaceColor( const Window* _pWindow ) @@ -172,7 +174,7 @@ namespace toolkit _pWindow->SetStyle( nStyle ); } - static void setVisualEffect( const Any& _rValue, Window* _pWindow, void (StyleSettings::*pSetter)( USHORT ), sal_Int16 _nFlatBits, sal_Int16 _n3DBits ) + static void setVisualEffect( const Any& _rValue, Window* _pWindow ) { AllSettings aSettings = _pWindow->GetSettings(); StyleSettings aStyleSettings = aSettings.GetStyleSettings(); @@ -182,22 +184,22 @@ namespace toolkit switch ( nStyle ) { case FLAT: - (aStyleSettings.*pSetter)( _nFlatBits ); + aStyleSettings.SetOptions( aStyleSettings.GetOptions() & ~STYLE_OPTION_MONO ); break; case LOOK3D: default: - (aStyleSettings.*pSetter)( _n3DBits ); + aStyleSettings.SetOptions( aStyleSettings.GetOptions() | STYLE_OPTION_MONO ); } aSettings.SetStyleSettings( aStyleSettings ); _pWindow->SetSettings( aSettings ); } - static Any getVisualEffect( Window* _pWindow, USHORT (StyleSettings::*pGetter)( ) const, sal_Int16 _nFlatBits ) + static Any getVisualEffect( Window* _pWindow ) { Any aEffect; StyleSettings aStyleSettings = _pWindow->GetSettings().GetStyleSettings(); - if ( (aStyleSettings.*pGetter)() == _nFlatBits ) + if ( (aStyleSettings.GetOptions() & STYLE_OPTION_MONO) ) aEffect <<= (sal_Int16)FLAT; else aEffect <<= (sal_Int16)LOOK3D; @@ -218,7 +220,7 @@ void VCLXGraphicControl::ImplSetNewImage() { OSL_PRECOND( GetWindow(), "VCLXGraphicControl::ImplSetNewImage: window is required to be not-NULL!" ); Button* pButton = static_cast< Button* >( GetWindow() ); - pButton->SetModeBitmap( GetBitmap() ); + pButton->SetModeImage( GetImage() ); } void VCLXGraphicControl::setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, short Flags ) throw(::com::sun::star::uno::RuntimeException) @@ -658,14 +660,14 @@ void VCLXImageControl::ImplSetNewImage() { OSL_PRECOND( GetWindow(), "VCLXImageControl::ImplSetNewImage: window is required to be not-NULL!" ); ImageControl* pControl = static_cast< ImageControl* >( GetWindow() ); - pControl->SetBitmap( GetBitmap() ); + pControl->SetImage( GetImage() ); } ::com::sun::star::awt::Size VCLXImageControl::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException) { SolarMutexGuard aGuard; - Size aSz = GetBitmap().GetSizePixel(); + Size aSz = GetImage().GetSizePixel(); aSz = ImplCalcWindowSize( aSz ); return AWTSize(aSz); @@ -959,7 +961,7 @@ void VCLXCheckBox::setProperty( const ::rtl::OUString& PropertyName, const ::com switch ( nPropType ) { case BASEPROPERTY_VISUALEFFECT: - ::toolkit::setVisualEffect( Value, pCheckBox, &StyleSettings::SetCheckBoxStyle, STYLE_CHECKBOX_MONO, STYLE_CHECKBOX_WIN ); + ::toolkit::setVisualEffect( Value, pCheckBox ); break; case BASEPROPERTY_TRISTATE: @@ -996,7 +998,7 @@ void VCLXCheckBox::setProperty( const ::rtl::OUString& PropertyName, const ::com switch ( nPropType ) { case BASEPROPERTY_VISUALEFFECT: - aProp = ::toolkit::getVisualEffect( pCheckBox, &StyleSettings::GetCheckBoxStyle, STYLE_CHECKBOX_MONO ); + aProp = ::toolkit::getVisualEffect( pCheckBox ); break; case BASEPROPERTY_TRISTATE: aProp <<= (sal_Bool)pCheckBox->IsTriStateEnabled(); @@ -1131,7 +1133,7 @@ void VCLXRadioButton::setProperty( const ::rtl::OUString& PropertyName, const :: switch ( nPropType ) { case BASEPROPERTY_VISUALEFFECT: - ::toolkit::setVisualEffect( Value, pButton, &StyleSettings::SetRadioButtonStyle, STYLE_RADIOBUTTON_MONO, STYLE_RADIOBUTTON_WIN ); + ::toolkit::setVisualEffect( Value, pButton ); break; case BASEPROPERTY_STATE: @@ -1139,7 +1141,7 @@ void VCLXRadioButton::setProperty( const ::rtl::OUString& PropertyName, const :: sal_Int16 n = sal_Int16(); if ( Value >>= n ) { - BOOL b = n ? sal_True : sal_False; + sal_Bool b = n ? sal_True : sal_False; if ( pButton->IsRadioCheckEnabled() ) pButton->Check( b ); else @@ -1174,7 +1176,7 @@ void VCLXRadioButton::setProperty( const ::rtl::OUString& PropertyName, const :: switch ( nPropType ) { case BASEPROPERTY_VISUALEFFECT: - aProp = ::toolkit::getVisualEffect( pButton, &StyleSettings::GetRadioButtonStyle, STYLE_RADIOBUTTON_MONO ); + aProp = ::toolkit::getVisualEffect( pButton ); break; case BASEPROPERTY_STATE: aProp <<= (sal_Int16) ( pButton->IsChecked() ? 1 : 0 ); @@ -1307,11 +1309,11 @@ void VCLXRadioButton::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent aEvent.ActionCommand = maActionCommand; maActionListeners.actionPerformed( aEvent ); } - ImplClickedOrToggled( FALSE ); + ImplClickedOrToggled( sal_False ); break; case VCLEVENT_RADIOBUTTON_TOGGLE: - ImplClickedOrToggled( TRUE ); + ImplClickedOrToggled( sal_True ); break; default: @@ -1320,7 +1322,7 @@ void VCLXRadioButton::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent } } -void VCLXRadioButton::ImplClickedOrToggled( BOOL bToggled ) +void VCLXRadioButton::ImplClickedOrToggled( sal_Bool bToggled ) { // In the formulars, RadioChecked is not enabled, call itemStateChanged only for click // In the dialog editor, RadioChecked is enabled, call itemStateChanged only for bToggled @@ -1712,14 +1714,14 @@ void VCLXListBox::selectItemsPos( const ::com::sun::star::uno::Sequence<sal_Int1 ListBox* pBox = (ListBox*) GetWindow(); if ( pBox ) { - BOOL bChanged = FALSE; + sal_Bool bChanged = sal_False; for ( sal_uInt16 n = (sal_uInt16)aPositions.getLength(); n; ) { - USHORT nPos = (USHORT) aPositions.getConstArray()[--n]; + sal_uInt16 nPos = (sal_uInt16) aPositions.getConstArray()[--n]; if ( pBox->IsEntryPosSelected( nPos ) != bSelect ) { pBox->SelectEntryPos( nPos, bSelect ); - bChanged = TRUE; + bChanged = sal_True; } } @@ -2063,34 +2065,32 @@ void VCLXListBox::ImplCallItemListeners() maItemListeners.itemStateChanged( aEvent ); } } - namespace { - Image lcl_getImageFromURL( const ::rtl::OUString& i_rImageURL ) - { - if ( !i_rImageURL.getLength() ) - return Image(); + Image lcl_getImageFromURL( const ::rtl::OUString& i_rImageURL ) + { + if ( !i_rImageURL.getLength() ) + return Image(); try { - ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); - Reference< XGraphicProvider > xProvider; - if ( aContext.createComponent( "com.sun.star.graphic.GraphicProvider", xProvider ) ) - { - ::comphelper::NamedValueCollection aMediaProperties; - aMediaProperties.put( "URL", i_rImageURL ); - Reference< XGraphic > xGraphic = xProvider->queryGraphic( aMediaProperties.getPropertyValues() ); + ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); + Reference< XGraphicProvider > xProvider; + if ( aContext.createComponent( "com.sun.star.graphic.GraphicProvider", xProvider ) ) + { + ::comphelper::NamedValueCollection aMediaProperties; + aMediaProperties.put( "URL", i_rImageURL ); + Reference< XGraphic > xGraphic = xProvider->queryGraphic( aMediaProperties.getPropertyValues() ); return Image( xGraphic ); - } - } - catch( const uno::Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - return Image(); - } + } + } + catch( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return Image(); + } } - void SAL_CALL VCLXListBox::listItemInserted( const ItemListEvent& i_rEvent ) throw (RuntimeException) { SolarMutexGuard aGuard; @@ -2102,7 +2102,7 @@ void SAL_CALL VCLXListBox::listItemInserted( const ItemListEvent& i_rEvent ) thr "VCLXListBox::listItemInserted: illegal (inconsistent) item position!" ); pListBox->InsertEntry( i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : ::rtl::OUString(), - i_rEvent.ItemImageURL.IsPresent ? lcl_getImageFromURL( i_rEvent.ItemImageURL.Value ) : Image(), + i_rEvent.ItemImageURL.IsPresent ? TkResMgr::getImageFromURL( i_rEvent.ItemImageURL.Value ) : Image(), i_rEvent.ItemPosition ); } @@ -2132,7 +2132,7 @@ void SAL_CALL VCLXListBox::listItemModified( const ItemListEvent& i_rEvent ) thr // VCL's ListBox does not support changing an entry's text or image, so remove and re-insert const ::rtl::OUString sNewText = i_rEvent.ItemText.IsPresent ? i_rEvent.ItemText.Value : ::rtl::OUString( pListBox->GetEntry( i_rEvent.ItemPosition ) ); - const Image aNewImage( i_rEvent.ItemImageURL.IsPresent ? lcl_getImageFromURL( i_rEvent.ItemImageURL.Value ) : pListBox->GetEntryImage( i_rEvent.ItemPosition ) ); + const Image aNewImage( i_rEvent.ItemImageURL.IsPresent ? TkResMgr::getImageFromURL( i_rEvent.ItemImageURL.Value ) : pListBox->GetEntryImage( i_rEvent.ItemPosition ) ); pListBox->RemoveEntry( i_rEvent.ItemPosition ); pListBox->InsertEntry( sNewText, aNewImage, i_rEvent.ItemPosition ); @@ -2322,13 +2322,13 @@ void SAL_CALL VCLXDialog::endDialog( ::sal_Int32 i_result ) throw (RuntimeExcept pDialog->EndDialog( i_result ); } -void SAL_CALL VCLXDialog::setHelpId( ::sal_Int32 i_id ) throw (RuntimeException) +void SAL_CALL VCLXDialog::setHelpId( const ::rtl::OUString& rId ) throw (RuntimeException) { SolarMutexGuard aGuard; Window* pWindow = GetWindow(); if ( pWindow ) - pWindow->SetHelpId( i_id ); + pWindow->SetHelpId( rtl::OUStringToOString( rId, RTL_TEXTENCODING_UTF8 ) ); } void VCLXDialog::setTitle( const ::rtl::OUString& Title ) throw(::com::sun::star::uno::RuntimeException) @@ -2672,10 +2672,10 @@ sal_Int32 SAL_CALL VCLXMultiPage::insertTab() throw (uno::RuntimeException) return static_cast< sal_Int32 >( insertTab( pTab, title ) ); } -USHORT VCLXMultiPage::insertTab( TabPage* pPage, rtl::OUString& sTitle ) +sal_uInt16 VCLXMultiPage::insertTab( TabPage* pPage, rtl::OUString& sTitle ) { TabControl *pTabControl = getTabControl(); - USHORT id = sal::static_int_cast< USHORT >( mTabId++ ); + sal_uInt16 id = sal::static_int_cast< sal_uInt16 >( mTabId++ ); pTabControl->InsertPage( id, sTitle.getStr(), TAB_APPEND ); pTabControl->SetTabPage( id, pPage ); return id; @@ -2684,18 +2684,18 @@ USHORT VCLXMultiPage::insertTab( TabPage* pPage, rtl::OUString& sTitle ) void SAL_CALL VCLXMultiPage::removeTab( sal_Int32 ID ) throw (uno::RuntimeException, lang::IndexOutOfBoundsException) { TabControl *pTabControl = getTabControl(); - if ( pTabControl->GetTabPage( sal::static_int_cast< USHORT >( ID ) ) == NULL ) + if ( pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ) == NULL ) throw lang::IndexOutOfBoundsException(); - pTabControl->RemovePage( sal::static_int_cast< USHORT >( ID ) ); + pTabControl->RemovePage( sal::static_int_cast< sal_uInt16 >( ID ) ); } void SAL_CALL VCLXMultiPage::activateTab( sal_Int32 ID ) throw (uno::RuntimeException, lang::IndexOutOfBoundsException) { TabControl *pTabControl = getTabControl(); OSL_TRACE("Attempting to activate tab %d, active tab is %d, numtabs is %d", ID, getActiveTabID(), getWindows().getLength() ); - if ( pTabControl->GetTabPage( sal::static_int_cast< USHORT >( ID ) ) == NULL ) + if ( pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ) == NULL ) throw lang::IndexOutOfBoundsException(); - pTabControl->SelectTabPage( sal::static_int_cast< USHORT >( ID ) ); + pTabControl->SelectTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ); } sal_Int32 SAL_CALL VCLXMultiPage::getActiveTabID() throw (uno::RuntimeException) @@ -2719,7 +2719,7 @@ void SAL_CALL VCLXMultiPage::setTabProps( sal_Int32 ID, const uno::Sequence< bea { SolarMutexGuard aGuard; TabControl *pTabControl = getTabControl(); - if ( pTabControl->GetTabPage( sal::static_int_cast< USHORT >( ID ) ) == NULL ) + if ( pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ) == NULL ) throw lang::IndexOutOfBoundsException(); for ( int i = 0; i < Properties.getLength(); i++ ) @@ -2730,7 +2730,7 @@ void SAL_CALL VCLXMultiPage::setTabProps( sal_Int32 ID, const uno::Sequence< bea if ( name == rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ) ) { rtl::OUString title = value.get<rtl::OUString>(); - pTabControl->SetPageText( sal::static_int_cast< USHORT >( ID ), title.getStr() ); + pTabControl->SetPageText( sal::static_int_cast< sal_uInt16 >( ID ), title.getStr() ); } } } @@ -2740,7 +2740,7 @@ uno::Sequence< beans::NamedValue > SAL_CALL VCLXMultiPage::getTabProps( sal_Int3 { SolarMutexGuard aGuard; TabControl *pTabControl = getTabControl(); - if ( pTabControl->GetTabPage( sal::static_int_cast< USHORT >( ID ) ) == NULL ) + if ( pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ) == NULL ) throw lang::IndexOutOfBoundsException(); #define ADD_PROP( seq, i, name, val ) { \ @@ -2751,8 +2751,8 @@ uno::Sequence< beans::NamedValue > SAL_CALL VCLXMultiPage::getTabProps( sal_Int3 } uno::Sequence< beans::NamedValue > props( 2 ); - ADD_PROP( props, 0, "Title", rtl::OUString( pTabControl->GetPageText( sal::static_int_cast< USHORT >( ID ) ) ) ); - ADD_PROP( props, 1, "Position", pTabControl->GetPagePos( sal::static_int_cast< USHORT >( ID ) ) ); + ADD_PROP( props, 0, "Title", rtl::OUString( pTabControl->GetPageText( sal::static_int_cast< sal_uInt16 >( ID ) ) ) ); + ADD_PROP( props, 1, "Position", pTabControl->GetPagePos( sal::static_int_cast< sal_uInt16 >( ID ) ) ); #undef ADD_PROP return props; } @@ -2763,14 +2763,14 @@ void VCLXMultiPage::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) { case VCLEVENT_TABPAGE_DEACTIVATE: { - ULONG nPageID = (ULONG)( rVclWindowEvent.GetData() ); + sal_uLong nPageID = (sal_uLong)( rVclWindowEvent.GetData() ); maTabListeners.deactivated( nPageID ); break; } case VCLEVENT_TABPAGE_ACTIVATE: { - ULONG nPageID = (ULONG)( rVclWindowEvent.GetData() ); + sal_uLong nPageID = (sal_uLong)( rVclWindowEvent.GetData() ); maTabListeners.activated( nPageID ); break; } @@ -2888,6 +2888,15 @@ throw(::com::sun::star::uno::RuntimeException) } } break; + case BASEPROPERTY_TITLE: + { + ::rtl::OUString sTitle; + if ( Value >>= sTitle ) + { + pTabPage->SetText(sTitle); + } + } + break; default: { @@ -3594,7 +3603,7 @@ void VCLXScrollBar::setProperty( const ::rtl::OUString& PropertyName, const ::co } AllSettings aSettings( pScrollBar->GetSettings() ); StyleSettings aStyle( aSettings.GetStyleSettings() ); - ULONG nDragOptions = aStyle.GetDragFullOptions(); + sal_uLong nDragOptions = aStyle.GetDragFullOptions(); if ( bDo ) nDragOptions |= DRAGFULL_OPTION_SCROLL; else diff --git a/toolkit/source/awt/xsimpleanimation.cxx b/toolkit/source/awt/xsimpleanimation.cxx index f11dd3f547a5..b67768ddfebf 100644 --- a/toolkit/source/awt/xsimpleanimation.cxx +++ b/toolkit/source/awt/xsimpleanimation.cxx @@ -30,9 +30,8 @@ #include "precompiled_toolkit.hxx" #include "toolkit/awt/xsimpleanimation.hxx" #include "toolkit/helper/property.hxx" -#include "toolkit/helper/throbberimpl.hxx" #include <tools/debug.hxx> - +#include <vcl/throbber.hxx> #include <vcl/svapp.hxx> //........................................................................ @@ -51,53 +50,40 @@ namespace toolkit XSimpleAnimation::XSimpleAnimation() { DBG_CTOR( XSimpleAnimation, NULL ); - mbRepeat = sal_True; - mnStepTime = 100; - mpThrobber = new Throbber_Impl( this, mnStepTime, mbRepeat ); } //-------------------------------------------------------------------- XSimpleAnimation::~XSimpleAnimation() { DBG_DTOR( XSimpleAnimation, NULL ); - delete mpThrobber; } //-------------------------------------------------------------------- - IMPLEMENT_FORWARD_XINTERFACE2( XSimpleAnimation, VCLXWindow, XSimpleAnimation_Base ) - - //-------------------------------------------------------------------- - IMPLEMENT_FORWARD_XTYPEPROVIDER2( XSimpleAnimation, VCLXWindow, XSimpleAnimation_Base ) - - //-------------------------------------------------------------------- void SAL_CALL XSimpleAnimation::start() throw ( uno::RuntimeException ) { - mpThrobber->start(); + ::osl::MutexGuard aGuard( GetMutex() ); + Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) ); + if ( pThrobber != NULL) + pThrobber->start(); } //-------------------------------------------------------------------- void SAL_CALL XSimpleAnimation::stop() throw ( uno::RuntimeException ) { - mpThrobber->stop(); + ::osl::MutexGuard aGuard( GetMutex() ); + Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) ); + if ( pThrobber != NULL) + pThrobber->stop(); } //-------------------------------------------------------------------- void SAL_CALL XSimpleAnimation::setImageList( const uno::Sequence< uno::Reference< graphic::XGraphic > >& rImageList ) throw ( uno::RuntimeException ) { - mpThrobber->setImageList( rImageList ); - } - - //-------------------------------------------------------------------- - void XSimpleAnimation::ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent ) - { - // TODO: XSimpleAnimation::ProcessWindowEvent - //Reference< XSimpleAnimation > xKeepAlive( this ); - //SpinButton* pSpinButton = static_cast< SpinButton* >( GetWindow() ); - //if ( !pSpinButton ) - // return; - - VCLXWindow::ProcessWindowEvent( _rVclWindowEvent ); + ::osl::MutexGuard aGuard( GetMutex() ); + Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) ); + if ( pThrobber != NULL) + pThrobber->setImageList( rImageList ); } //-------------------------------------------------------------------- @@ -106,33 +92,31 @@ namespace toolkit { SolarMutexGuard aGuard; - if ( GetWindow() ) + Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) ); + if ( pThrobber == NULL ) + { + VCLXWindow::setProperty( PropertyName, Value ); + return; + } + + sal_uInt16 nPropertyId = GetPropertyId( PropertyName ); + switch ( nPropertyId ) { - sal_uInt16 nPropertyId = GetPropertyId( PropertyName ); - switch ( nPropertyId ) - { - case BASEPROPERTY_STEP_TIME: { - sal_Int32 nStepTime( 0 ); - if ( Value >>= nStepTime ) - { - mnStepTime = nStepTime; - mpThrobber->setStepTime( mnStepTime ); - } - - break; - } - case BASEPROPERTY_REPEAT: { - sal_Bool bRepeat( sal_True ); - if ( Value >>= bRepeat ) - { - mbRepeat = bRepeat; - mpThrobber->setRepeat( mbRepeat ); - } - break; - } - default: - VCLXWindow::setProperty( PropertyName, Value ); + case BASEPROPERTY_STEP_TIME: { + sal_Int32 nStepTime( 0 ); + if ( Value >>= nStepTime ) + pThrobber->setStepTime( nStepTime ); + + break; } + case BASEPROPERTY_REPEAT: { + sal_Bool bRepeat( sal_True ); + if ( Value >>= bRepeat ) + pThrobber->setRepeat( bRepeat ); + break; + } + default: + VCLXWindow::setProperty( PropertyName, Value ); } } @@ -142,22 +126,22 @@ namespace toolkit { SolarMutexGuard aGuard; - uno::Any aReturn; + Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) ); + if ( pThrobber == NULL ) + return VCLXWindow::getProperty( PropertyName ); - if ( GetWindow() ) + uno::Any aReturn; + sal_uInt16 nPropertyId = GetPropertyId( PropertyName ); + switch ( nPropertyId ) { - sal_uInt16 nPropertyId = GetPropertyId( PropertyName ); - switch ( nPropertyId ) - { - case BASEPROPERTY_STEP_TIME: - aReturn <<= mnStepTime; - break; - case BASEPROPERTY_REPEAT: - aReturn <<= mbRepeat; - break; - default: - aReturn = VCLXWindow::getProperty( PropertyName ); - } + case BASEPROPERTY_STEP_TIME: + aReturn <<= pThrobber->getStepTime(); + break; + case BASEPROPERTY_REPEAT: + aReturn <<= pThrobber->getRepeat(); + break; + default: + aReturn = VCLXWindow::getProperty( PropertyName ); } return aReturn; } diff --git a/toolkit/source/awt/xthrobber.cxx b/toolkit/source/awt/xthrobber.cxx index 5f015953132c..bc96712eb0ef 100644 --- a/toolkit/source/awt/xthrobber.cxx +++ b/toolkit/source/awt/xthrobber.cxx @@ -31,13 +31,13 @@ #include "toolkit/awt/xthrobber.hxx" #include "toolkit/helper/property.hxx" #include <toolkit/helper/tkresmgr.hxx> -#include <toolkit/helper/throbberimpl.hxx> #include "xthrobber.hrc" #include <tools/debug.hxx> #include <vcl/fixed.hxx> #include <vcl/timer.hxx> #include <vcl/svapp.hxx> +#include <vcl/throbber.hxx> //........................................................................ namespace toolkit @@ -55,88 +55,49 @@ namespace toolkit XThrobber::XThrobber() { DBG_CTOR( XThrobber, NULL ); - - mpThrobber = new Throbber_Impl( this, 100, sal_True ); - - InitImageList(); } //-------------------------------------------------------------------- XThrobber::~XThrobber() { DBG_DTOR( XThrobber, NULL ); - delete mpThrobber; } //-------------------------------------------------------------------- - IMPLEMENT_FORWARD_XINTERFACE2( XThrobber, VCLXWindow, XThrobber_Base ) - - //-------------------------------------------------------------------- - IMPLEMENT_FORWARD_XTYPEPROVIDER2( XThrobber, VCLXWindow, XThrobber_Base ) - - //-------------------------------------------------------------------- void SAL_CALL XThrobber::start() throw ( uno::RuntimeException ) { - mpThrobber->start(); + ::osl::MutexGuard aGuard( GetMutex() ); + Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) ); + if ( pThrobber != NULL) + pThrobber->start(); } //-------------------------------------------------------------------- void SAL_CALL XThrobber::stop() throw ( uno::RuntimeException ) { - mpThrobber->stop(); - } - - //-------------------------------------------------------------------- - void XThrobber::ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent ) - { - static bool bInit = false; - if ( !bInit ) - { - // Images won't be shown if set too early - mpThrobber->initImage(); - bInit = true; - } - // TODO: XSimpleAnimation::ProcessWindowEvent - //Reference< XSimpleAnimation > xKeepAlive( this ); - //SpinButton* pSpinButton = static_cast< SpinButton* >( GetWindow() ); - //if ( !pSpinButton ) - // return; - - VCLXWindow::ProcessWindowEvent( _rVclWindowEvent ); - } - - //-------------------------------------------------------------------- - void SAL_CALL XThrobber::setProperty( const ::rtl::OUString& PropertyName, const uno::Any& Value ) - throw( uno::RuntimeException ) - { SolarMutexGuard aGuard; - - if ( GetWindow() ) - { - VCLXWindow::setProperty( PropertyName, Value ); - } + Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) ); + if ( pThrobber != NULL) + pThrobber->stop(); } //-------------------------------------------------------------------- - uno::Any SAL_CALL XThrobber::getProperty( const ::rtl::OUString& PropertyName ) - throw( uno::RuntimeException ) + void XThrobber::SetWindow( Window* pWindow ) { - SolarMutexGuard aGuard; - - uno::Any aReturn; - - if ( GetWindow() ) - { - aReturn = VCLXWindow::getProperty( PropertyName ); - } - return aReturn; + XThrobber_Base::SetWindow( pWindow ); + InitImageList(); } //-------------------------------------------------------------------- void SAL_CALL XThrobber::InitImageList() throw( uno::RuntimeException ) { - SolarMutexGuard aGuard; + ::osl::MutexGuard aGuard( GetMutex() ); + + Throbber* pThrobber( dynamic_cast< Throbber* >( GetWindow() ) ); + if ( pThrobber == NULL) + return; + uno::Sequence< uno::Reference< graphic::XGraphic > > aImageList(12); sal_uInt16 nIconIdStart = RID_TK_ICON_THROBBER_START; @@ -146,7 +107,7 @@ namespace toolkit aImageList[i] = aImage.GetXGraphic(); } - mpThrobber->setImageList( aImageList ); + pThrobber->setImageList( aImageList ); } //........................................................................ diff --git a/toolkit/source/controls/animatedimages.cxx b/toolkit/source/controls/animatedimages.cxx new file mode 100755 index 000000000000..c2fd91f1ea46 --- /dev/null +++ b/toolkit/source/controls/animatedimages.cxx @@ -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 "precompiled_toolkit.hxx" + +#include "toolkit/controls/animatedimages.hxx" +#include "toolkit/helper/servicenames.hxx" +#include "toolkit/helper/property.hxx" +#include "toolkit/helper/unopropertyarrayhelper.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/lang/DisposedException.hpp> +#include <com/sun/star/awt/VisualEffect.hpp> +#include <com/sun/star/awt/ImageScaleMode.hpp> +#include <com/sun/star/util/XModifyListener.hpp> +/** === end UNO includes === **/ + +//...................................................................................................................... +namespace toolkit +{ +//...................................................................................................................... + + /** === 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::container::ContainerEvent; + using ::com::sun::star::container::XContainerListener; + using ::com::sun::star::beans::XPropertySetInfo; + using ::com::sun::star::lang::DisposedException; + using ::com::sun::star::lang::IndexOutOfBoundsException; + using ::com::sun::star::lang::EventObject; + using ::com::sun::star::awt::XControlModel; + using ::com::sun::star::awt::XAnimatedImages; + using ::com::sun::star::lang::IllegalArgumentException; + using ::com::sun::star::awt::XWindowPeer; + using ::com::sun::star::util::XModifyListener; + using ::com::sun::star::awt::XToolkit; + using ::com::sun::star::lang::XMultiServiceFactory; + /** === end UNO using === **/ + namespace VisualEffect = ::com::sun::star::awt::VisualEffect; + namespace ImageScaleMode = ::com::sun::star::awt::ImageScaleMode; + + //================================================================================================================== + //= AnimatedImagesControl + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + AnimatedImagesControl::AnimatedImagesControl( Reference< XMultiServiceFactory > const & i_factory ) + :AnimatedImagesControl_Base( i_factory ) + { + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString AnimatedImagesControl::GetComponentServiceName() + { + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AnimatedImages" ) ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesControl::startAnimation( ) throw (RuntimeException) + { + Reference< XAnimation > xAnimation( getPeer(), UNO_QUERY ); + if ( xAnimation.is() ) + xAnimation->startAnimation(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesControl::stopAnimation( ) throw (RuntimeException) + { + Reference< XAnimation > xAnimation( getPeer(), UNO_QUERY ); + if ( xAnimation.is() ) + xAnimation->stopAnimation(); + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Bool SAL_CALL AnimatedImagesControl::isAnimationRunning( ) throw (RuntimeException) + { + Reference< XAnimation > xAnimation( getPeer(), UNO_QUERY ); + if ( xAnimation.is() ) + return xAnimation->isAnimationRunning(); + return sal_False; + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL AnimatedImagesControl::getImplementationName( ) throw(RuntimeException) + { + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.toolkit.AnimatedImagesControl" ) ); + } + + //------------------------------------------------------------------------------------------------------------------ + Sequence< ::rtl::OUString > SAL_CALL AnimatedImagesControl::getSupportedServiceNames() throw(RuntimeException) + { + Sequence< ::rtl::OUString > aServices( AnimatedImagesControl_Base::getSupportedServiceNames() ); + aServices.realloc( aServices.getLength() + 1 ); + aServices[ aServices.getLength() - 1 ] = ::rtl::OUString::createFromAscii( szServiceName_AnimatedImagesControl ); + return aServices; + } + + //------------------------------------------------------------------------------------------------------------------ + namespace + { + void lcl_updatePeer( Reference< XWindowPeer > const& i_peer, Reference< XControlModel > const& i_model ) + { + const Reference< XModifyListener > xPeerModify( i_peer, UNO_QUERY ); + if ( xPeerModify.is() ) + { + EventObject aEvent; + aEvent.Source = i_model; + xPeerModify->modified( aEvent ); + } + } + } + + //------------------------------------------------------------------------------------------------------------------ + sal_Bool SAL_CALL AnimatedImagesControl::setModel( const Reference< XControlModel >& i_rModel ) throw ( RuntimeException ) + { + const Reference< XAnimatedImages > xOldContainer( getModel(), UNO_QUERY ); + const Reference< XAnimatedImages > xNewContainer( i_rModel, UNO_QUERY ); + + if ( !AnimatedImagesControl_Base::setModel( i_rModel ) ) + return sal_False; + + if ( xOldContainer.is() ) + xOldContainer->removeContainerListener( this ); + + if ( xNewContainer.is() ) + xNewContainer->addContainerListener( this ); + + lcl_updatePeer( getPeer(), getModel() ); + + return sal_True; + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesControl::createPeer( const Reference< XToolkit >& i_toolkit, const Reference< XWindowPeer >& i_parentPeer ) throw(RuntimeException) + { + AnimatedImagesControl_Base::createPeer( i_toolkit, i_parentPeer ); + + lcl_updatePeer( getPeer(), getModel() ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesControl::elementInserted( const ContainerEvent& i_event ) throw (RuntimeException) + { + const Reference< XContainerListener > xPeerListener( getPeer(), UNO_QUERY ); + if ( xPeerListener.is() ) + xPeerListener->elementInserted( i_event ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesControl::elementRemoved( const ContainerEvent& i_event ) throw (RuntimeException) + { + const Reference< XContainerListener > xPeerListener( getPeer(), UNO_QUERY ); + if ( xPeerListener.is() ) + xPeerListener->elementRemoved( i_event ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesControl::elementReplaced( const ContainerEvent& i_event ) throw (RuntimeException) + { + const Reference< XContainerListener > xPeerListener( getPeer(), UNO_QUERY ); + if ( xPeerListener.is() ) + xPeerListener->elementReplaced( i_event ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesControl::disposing( const EventObject& i_event ) throw (RuntimeException) + { + UnoControlBase::disposing( i_event ); + } + + //================================================================================================================== + //= AnimatedImagesControlModel_Data + //================================================================================================================== + struct AnimatedImagesControlModel_Data + { + ::std::vector< Sequence< ::rtl::OUString > > aImageSets; + }; + + namespace + { + void lcl_checkIndex( const AnimatedImagesControlModel_Data& i_data, const sal_Int32 i_index, const Reference< XInterface >& i_context, + const bool i_forInsert = false ) + { + if ( ( i_index < 0 ) || ( size_t( i_index ) > i_data.aImageSets.size() + ( i_forInsert ? 1 : 0 ) ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), i_context ); + } + + void lcl_notify( ::osl::ClearableMutexGuard& i_guard, ::cppu::OBroadcastHelper& i_broadcaseHelper, + void ( SAL_CALL XContainerListener::*i_notificationMethod )( const ContainerEvent& ), + const sal_Int32 i_accessor, const Sequence< ::rtl::OUString >& i_imageURLs, const Reference< XInterface >& i_context ) + { + ::cppu::OInterfaceContainerHelper* pContainerListeners = i_broadcaseHelper.getContainer( XContainerListener::static_type() ); + if ( pContainerListeners == NULL ) + return; + + ContainerEvent aEvent; + aEvent.Source = i_context; + aEvent.Accessor <<= i_accessor; + aEvent.Element <<= i_imageURLs; + + i_guard.clear(); + pContainerListeners->notifyEach( i_notificationMethod, aEvent ); + } + } + + //================================================================================================================== + //= AnimatedImagesControlModel + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + AnimatedImagesControlModel::AnimatedImagesControlModel( Reference< XMultiServiceFactory > const & i_factory ) + :AnimatedImagesControlModel_Base( i_factory ) + ,m_pData( new AnimatedImagesControlModel_Data ) + { + ImplRegisterProperty( BASEPROPERTY_AUTO_REPEAT ); + ImplRegisterProperty( BASEPROPERTY_BORDER ); + ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR ); + ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR ); + ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL ); + ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE ); + ImplRegisterProperty( BASEPROPERTY_HELPTEXT ); + ImplRegisterProperty( BASEPROPERTY_HELPURL ); + ImplRegisterProperty( BASEPROPERTY_IMAGE_SCALE_MODE ); + ImplRegisterProperty( BASEPROPERTY_STEP_TIME ); + } + + //------------------------------------------------------------------------------------------------------------------ + AnimatedImagesControlModel::AnimatedImagesControlModel( const AnimatedImagesControlModel& i_copySource ) + :AnimatedImagesControlModel_Base( i_copySource ) + ,m_pData( new AnimatedImagesControlModel_Data( *i_copySource.m_pData ) ) + { + } + + //------------------------------------------------------------------------------------------------------------------ + AnimatedImagesControlModel::~AnimatedImagesControlModel() + { + } + + //------------------------------------------------------------------------------------------------------------------ + UnoControlModel* AnimatedImagesControlModel::Clone() const + { + return new AnimatedImagesControlModel( *this ); + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XPropertySetInfo > SAL_CALL AnimatedImagesControlModel::getPropertySetInfo( ) throw(RuntimeException) + { + static Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); + return xInfo; + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL AnimatedImagesControlModel::getServiceName() throw(RuntimeException) + { + return ::rtl::OUString::createFromAscii( szServiceName_AnimatedImagesControlModel ); + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL AnimatedImagesControlModel::getImplementationName( ) throw(RuntimeException) + { + return ::rtl::OUString::createFromAscii( "org.openoffice.comp.toolkit.AnimatedImagesControlModel" ); + } + + //------------------------------------------------------------------------------------------------------------------ + Sequence< ::rtl::OUString > SAL_CALL AnimatedImagesControlModel::getSupportedServiceNames() throw(RuntimeException) + { + Sequence< ::rtl::OUString > aServiceNames(2); + aServiceNames[0] = ::rtl::OUString::createFromAscii( szServiceName_AnimatedImagesControlModel ); + aServiceNames[1] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.UnoControlModel" ); + return aServiceNames; + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 i_handle, const Any& i_value ) throw (Exception) + { + switch ( i_handle ) + { + case BASEPROPERTY_IMAGE_SCALE_MODE: + { + sal_Int16 nImageScaleMode( ImageScaleMode::Anisotropic ); + OSL_VERIFY( i_value >>= nImageScaleMode ); // convertFastPropertyValue ensures that this has the proper type + if ( ( nImageScaleMode != ImageScaleMode::None ) + && ( nImageScaleMode != ImageScaleMode::Isotropic ) + && ( nImageScaleMode != ImageScaleMode::Anisotropic ) + ) + throw IllegalArgumentException( ::rtl::OUString(), *this, 1 ); + } + break; + } + + AnimatedImagesControlModel_Base::setFastPropertyValue_NoBroadcast( i_handle, i_value ); + } + + //------------------------------------------------------------------------------------------------------------------ + Any AnimatedImagesControlModel::ImplGetDefaultValue( sal_uInt16 i_propertyId ) const + { + switch ( i_propertyId ) + { + case BASEPROPERTY_DEFAULTCONTROL: + return makeAny( ::rtl::OUString::createFromAscii( szServiceName_AnimatedImagesControl ) ); + + case BASEPROPERTY_BORDER: + return makeAny( VisualEffect::NONE ); + + case BASEPROPERTY_STEP_TIME: + return makeAny( (sal_Int32) 100 ); + + case BASEPROPERTY_AUTO_REPEAT: + return makeAny( (sal_Bool)sal_True ); + + case BASEPROPERTY_IMAGE_SCALE_MODE: + return makeAny( ImageScaleMode::None ); + + default: + return UnoControlModel::ImplGetDefaultValue( i_propertyId ); + } + } + + //------------------------------------------------------------------------------------------------------------------ + ::cppu::IPropertyArrayHelper& SAL_CALL AnimatedImagesControlModel::getInfoHelper() + { + static UnoPropertyArrayHelper* pHelper = NULL; + if ( !pHelper ) + { + Sequence< sal_Int32 > aIDs = ImplGetPropertyIds(); + pHelper = new UnoPropertyArrayHelper( aIDs ); + } + return *pHelper; + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL AnimatedImagesControlModel::getStepTime() throw (RuntimeException) + { + sal_Int32 nStepTime( 100 ); + OSL_VERIFY( getPropertyValue( GetPropertyName( BASEPROPERTY_STEP_TIME ) ) >>= nStepTime ); + return nStepTime; + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesControlModel::setStepTime( ::sal_Int32 i_stepTime ) throw (RuntimeException) + { + setPropertyValue( GetPropertyName( BASEPROPERTY_STEP_TIME ), makeAny( i_stepTime ) ); + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Bool SAL_CALL AnimatedImagesControlModel::getAutoRepeat() throw (RuntimeException) + { + sal_Bool bAutoRepeat( sal_True ); + OSL_VERIFY( getPropertyValue( GetPropertyName( BASEPROPERTY_AUTO_REPEAT ) ) >>= bAutoRepeat ); + return bAutoRepeat; + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesControlModel::setAutoRepeat( ::sal_Bool i_autoRepeat ) throw (RuntimeException) + { + setPropertyValue( GetPropertyName( BASEPROPERTY_AUTO_REPEAT ), makeAny( i_autoRepeat ) ); + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int16 SAL_CALL AnimatedImagesControlModel::getScaleMode() throw (RuntimeException) + { + sal_Int16 nImageScaleMode( ImageScaleMode::Anisotropic ); + OSL_VERIFY( getPropertyValue( GetPropertyName( BASEPROPERTY_IMAGE_SCALE_MODE ) ) >>= nImageScaleMode ); + return nImageScaleMode; + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesControlModel::setScaleMode( ::sal_Int16 i_scaleMode ) throw (IllegalArgumentException, RuntimeException) + { + setPropertyValue( GetPropertyName( BASEPROPERTY_IMAGE_SCALE_MODE ), makeAny( i_scaleMode ) ); + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL AnimatedImagesControlModel::getImageSetCount( ) throw (RuntimeException) + { + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + if ( GetBroadcastHelper().bDisposed || GetBroadcastHelper().bInDispose ) + throw DisposedException(); + + return m_pData->aImageSets.size(); + } + + //------------------------------------------------------------------------------------------------------------------ + Sequence< ::rtl::OUString > SAL_CALL AnimatedImagesControlModel::getImageSet( ::sal_Int32 i_index ) throw (IndexOutOfBoundsException, RuntimeException) + { + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + if ( GetBroadcastHelper().bDisposed || GetBroadcastHelper().bInDispose ) + throw DisposedException(); + + lcl_checkIndex( *m_pData, i_index, *this ); + + return m_pData->aImageSets[ i_index ]; + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesControlModel::insertImageSet( ::sal_Int32 i_index, const Sequence< ::rtl::OUString >& i_imageURLs ) throw (IndexOutOfBoundsException, RuntimeException) + { + ::osl::ClearableMutexGuard aGuard( GetMutex() ); + // sanity checks + if ( GetBroadcastHelper().bDisposed || GetBroadcastHelper().bInDispose ) + throw DisposedException(); + + lcl_checkIndex( *m_pData, i_index, *this, true ); + + // actaul insertion + m_pData->aImageSets.insert( m_pData->aImageSets.begin() + i_index, i_imageURLs ); + + // listener notification + lcl_notify( aGuard, BrdcstHelper, &XContainerListener::elementInserted, i_index, i_imageURLs, *this ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesControlModel::replaceImageSet( ::sal_Int32 i_index, const Sequence< ::rtl::OUString >& i_imageURLs ) throw (IndexOutOfBoundsException, RuntimeException) + { + ::osl::ClearableMutexGuard aGuard( GetMutex() ); + // sanity checks + if ( GetBroadcastHelper().bDisposed || GetBroadcastHelper().bInDispose ) + throw DisposedException(); + + lcl_checkIndex( *m_pData, i_index, *this ); + + // actaul insertion + m_pData->aImageSets[ i_index ] = i_imageURLs; + + // listener notification + lcl_notify( aGuard, BrdcstHelper, &XContainerListener::elementReplaced, i_index, i_imageURLs, *this ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesControlModel::removeImageSet( ::sal_Int32 i_index ) throw (IndexOutOfBoundsException, RuntimeException) + { + ::osl::ClearableMutexGuard aGuard( GetMutex() ); + // sanity checks + if ( GetBroadcastHelper().bDisposed || GetBroadcastHelper().bInDispose ) + throw DisposedException(); + + lcl_checkIndex( *m_pData, i_index, *this ); + + // actual removal + ::std::vector< Sequence< ::rtl::OUString > >::iterator removalPos = m_pData->aImageSets.begin() + i_index; + Sequence< ::rtl::OUString > aRemovedElement( *removalPos ); + m_pData->aImageSets.erase( removalPos ); + + // listener notification + lcl_notify( aGuard, BrdcstHelper, &XContainerListener::elementRemoved, i_index, aRemovedElement, *this ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesControlModel::addContainerListener( const Reference< XContainerListener >& i_listener ) throw (RuntimeException) + { + BrdcstHelper.addListener( XContainerListener::static_type(), i_listener ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL AnimatedImagesControlModel::removeContainerListener( const Reference< XContainerListener >& i_listener ) throw (RuntimeException) + { + BrdcstHelper.removeListener( XContainerListener::static_type(), i_listener ); + } + +//...................................................................................................................... +} // namespace toolkit +//...................................................................................................................... diff --git a/toolkit/source/controls/controlmodelcontainerbase.cxx b/toolkit/source/controls/controlmodelcontainerbase.cxx new file mode 100644 index 000000000000..a630a274adfe --- /dev/null +++ b/toolkit/source/controls/controlmodelcontainerbase.cxx @@ -0,0 +1,1859 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_toolkit.hxx" + +#include <toolkit/controls/controlmodelcontainerbase.hxx> +#include <vcl/svapp.hxx> +#include <vcl/window.hxx> +#include <vcl/wall.hxx> +#include <toolkit/helper/property.hxx> +#include <toolkit/helper/unopropertyarrayhelper.hxx> +#include <toolkit/controls/geometrycontrolmodel.hxx> +#include <toolkit/controls/unocontrols.hxx> +#include "toolkit/controls/formattedcontrol.hxx" +#include "toolkit/controls/roadmapcontrol.hxx" +#include "toolkit/controls/tkscrollbar.hxx" +#include <toolkit/controls/stdtabcontroller.hxx> +#include <com/sun/star/awt/PosSize.hpp> +#include <com/sun/star/awt/WindowAttribute.hpp> +#include <com/sun/star/resource/XStringResourceResolver.hpp> +#include <com/sun/star/graphic/XGraphicProvider.hpp> +#include <tools/list.hxx> +#include <cppuhelper/typeprovider.hxx> +#include <tools/debug.hxx> +#include <tools/diagnose_ex.h> +#include <comphelper/processfactory.hxx> +#include <vcl/svapp.hxx> +#include <vcl/outdev.hxx> +#include <comphelper/types.hxx> + +#include <comphelper/componentcontext.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <toolkit/helper/tkresmgr.hxx> +#include <unotools/ucbstreamhelper.hxx> +#include <vcl/graph.hxx> +#include <vcl/image.hxx> + +#include "tree/treecontrol.hxx" +#include "grid/gridcontrol.hxx" +#include <toolkit/controls/tabpagecontainer.hxx> + +#include <map> +#include <algorithm> +#include <functional> +#include "tools/urlobj.hxx" +#include "osl/file.hxx" + +#include <boost/bind.hpp> + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::awt; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::util; +using namespace toolkit; + +#define PROPERTY_RESOURCERESOLVER ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ResourceResolver" )) + +//HELPER +::rtl::OUString getPhysicalLocation( const ::com::sun::star::uno::Any& rbase, const ::com::sun::star::uno::Any& rUrl ); + +struct LanguageDependentProp +{ + const char* pPropName; + sal_Int32 nPropNameLength; +}; + +// ---------------------------------------------------------------------------- +namespace +{ + static const Sequence< ::rtl::OUString >& lcl_getLanguageDependentProperties() + { + static Sequence< ::rtl::OUString > s_aLanguageDependentProperties; + if ( s_aLanguageDependentProperties.getLength() == 0 ) + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if ( s_aLanguageDependentProperties.getLength() == 0 ) + { + s_aLanguageDependentProperties.realloc( 2 ); + s_aLanguageDependentProperties[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HelpText" ) ); + s_aLanguageDependentProperties[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ); + // note: properties must be sorted + } + } + return s_aLanguageDependentProperties; + } +} + +// ---------------------------------------------------------------------------- +// functor for disposing a control model +struct DisposeControlModel : public ::std::unary_function< Reference< XControlModel >, void > +{ + void operator()( Reference< XControlModel >& _rxModel ) + { + try + { + ::comphelper::disposeComponent( _rxModel ); + } + catch( const Exception& ) + { + DBG_ERROR( "DisposeControlModel::(): caught an exception while disposing a component!" ); + } + } +}; + +// ---------------------------------------------------------------------------- +// functor for searching control model by name +struct FindControlModel : public ::std::unary_function< ControlModelContainerBase::UnoControlModelHolder, bool > +{ +private: + const ::rtl::OUString& m_rName; + +public: + FindControlModel( const ::rtl::OUString& _rName ) : m_rName( _rName ) { } + + bool operator()( const ControlModelContainerBase::UnoControlModelHolder& _rCompare ) + { + return ( _rCompare.second == m_rName ) ? true : false; + } +}; + +// ---------------------------------------------------------------------------- +// functor for cloning a control model, and insertion into a target list +struct CloneControlModel : public ::std::unary_function< ControlModelContainerBase::UnoControlModelHolder, void > +{ +private: + ControlModelContainerBase::UnoControlModelHolderList& m_rTargetList; + +public: + CloneControlModel( ControlModelContainerBase::UnoControlModelHolderList& _rTargetList ) + :m_rTargetList( _rTargetList ) + { + } + + void operator()( const ControlModelContainerBase::UnoControlModelHolder& _rSource ) + { + // clone the source object + Reference< XCloneable > xCloneSource( _rSource.first, UNO_QUERY ); + Reference< XControlModel > xClone( xCloneSource->createClone(), UNO_QUERY ); + // add to target list + m_rTargetList.push_back( ControlModelContainerBase::UnoControlModelHolder( xClone, _rSource.second ) ); + } +}; + +// ---------------------------------------------------------------------------- +// functor for comparing a XControlModel with a given reference +struct CompareControlModel : public ::std::unary_function< ControlModelContainerBase::UnoControlModelHolder, bool > +{ +private: + Reference< XControlModel > m_xReference; +public: + CompareControlModel( const Reference< XControlModel >& _rxReference ) : m_xReference( _rxReference ) { } + + bool operator()( const ControlModelContainerBase::UnoControlModelHolder& _rCompare ) + { + return ( _rCompare.first.get() == m_xReference.get() ) ? true : false; + } +}; + +// ---------------------------------------------------------------------------- +static void lcl_throwIllegalArgumentException( ) +{ // throwing is expensive (in terms of code size), thus we hope the compiler does not inline this .... + throw IllegalArgumentException(); +} + +// ---------------------------------------------------------------------------- +static void lcl_throwNoSuchElementException( ) +{ // throwing is expensive (in terms of code size), thus we hope the compiler does not inline this .... + throw NoSuchElementException(); +} + +// ---------------------------------------------------------------------------- +static void lcl_throwElementExistException( ) +{ // throwing is expensive (in terms of code size), thus we hope the compiler does not inline this .... + throw ElementExistException(); +} + +// ---------------------------------------------------------------------------- +static const ::rtl::OUString& getTabIndexPropertyName( ) +{ + static const ::rtl::OUString s_sTabIndexProperty( RTL_CONSTASCII_USTRINGPARAM( "TabIndex" ) ); + return s_sTabIndexProperty; +} + +// ---------------------------------------------------------------------------- +static const ::rtl::OUString& getStepPropertyName( ) +{ + static const ::rtl::OUString s_sStepProperty( RTL_CONSTASCII_USTRINGPARAM( "Step" ) ); + return s_sStepProperty; +} + +// ---------------------------------------------------- +// class ControlModelContainerBase +// ---------------------------------------------------- +ControlModelContainerBase::ControlModelContainerBase( const Reference< XMultiServiceFactory >& i_factory ) + :ControlModelContainer_IBase( i_factory ) + ,maContainerListeners( *this ) + ,maChangeListeners ( GetMutex() ) + ,mbGroupsUpToDate( sal_False ) +{ +} + +ControlModelContainerBase::ControlModelContainerBase( const ControlModelContainerBase& rModel ) + : ControlModelContainer_IBase( rModel ) + , maContainerListeners( *this ) + , maChangeListeners ( GetMutex() ) + , mbGroupsUpToDate( sal_False ) +{ +} + +ControlModelContainerBase::~ControlModelContainerBase() +{ + maModels.clear(); + mbGroupsUpToDate = sal_False; +} + +Any ControlModelContainerBase::ImplGetDefaultValue( sal_uInt16 nPropId ) const +{ + Any aAny; + + switch ( nPropId ) + { + case BASEPROPERTY_DEFAULTCONTROL: + aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlDialog ); + break; + default: + aAny = UnoControlModel::ImplGetDefaultValue( nPropId ); + } + + return aAny; +} + +::cppu::IPropertyArrayHelper& ControlModelContainerBase::getInfoHelper() +{ + static UnoPropertyArrayHelper* pHelper = NULL; + if ( !pHelper ) + { + Sequence<sal_Int32> aIDs = ImplGetPropertyIds(); + pHelper = new UnoPropertyArrayHelper( aIDs ); + } + return *pHelper; +} + +void SAL_CALL ControlModelContainerBase::dispose( ) throw(RuntimeException) +{ + // ==================================================================== + // tell our listeners + { + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + EventObject aDisposeEvent; + aDisposeEvent.Source = static_cast< XAggregation* >( static_cast< ::cppu::OWeakAggObject* >( this ) ); + + maContainerListeners.disposeAndClear( aDisposeEvent ); + maChangeListeners.disposeAndClear( aDisposeEvent ); + } + + // ==================================================================== + // call the base class + UnoControlModel::dispose(); + + // ==================================================================== + // dispose our child models + // for this, collect the models (we collect them from maModels, and this is modified when disposing children) + ::std::vector< Reference< XControlModel > > aChildModels( maModels.size() ); + + ::std::transform( + maModels.begin(), maModels.end(), // source range + aChildModels.begin(), // target location + ::boost::bind( &UnoControlModelHolder::first, _1 ) // operation to apply -> select the XControlModel part + ); + + // now dispose + ::std::for_each( aChildModels.begin(), aChildModels.end(), DisposeControlModel() ); + aChildModels.clear(); + + mbGroupsUpToDate = sal_False; +} + +// XMultiPropertySet +Reference< XPropertySetInfo > ControlModelContainerBase::getPropertySetInfo( ) throw(RuntimeException) +{ + static Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); + return xInfo; +} +void ControlModelContainerBase::Clone_Impl(ControlModelContainerBase& _rClone) const +{ + // clone all children + ::std::for_each( + maModels.begin(), maModels.end(), + CloneControlModel( _rClone.maModels ) + ); +} +UnoControlModel* ControlModelContainerBase::Clone() const +{ + // clone the container itself + ControlModelContainerBase* pClone = new ControlModelContainerBase( *this ); + Clone_Impl(*pClone); + + return pClone; +} + +ControlModelContainerBase::UnoControlModelHolderList::iterator ControlModelContainerBase::ImplFindElement( const ::rtl::OUString& rName ) +{ + return ::std::find_if( maModels.begin(), maModels.end(), FindControlModel( rName ) ); +} + +// ::XMultiServiceFactory +Reference< XInterface > ControlModelContainerBase::createInstance( const ::rtl::OUString& aServiceSpecifier ) throw(Exception, RuntimeException) +{ + SolarMutexGuard aSolarGuard; + + OGeometryControlModel_Base* pNewModel = NULL; + + const Reference< XMultiServiceFactory > xFactory( maContext.getLegacyServiceFactory() ); + if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlEditModel ) == 0 ) + pNewModel = new OGeometryControlModel< UnoControlEditModel >( xFactory ); + else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlFormattedFieldModel ) == 0 ) + pNewModel = new OGeometryControlModel< UnoControlFormattedFieldModel >( xFactory ); + else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlFileControlModel ) == 0 ) + pNewModel = new OGeometryControlModel< UnoControlFileControlModel >( xFactory ); + else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlButtonModel ) == 0 ) + pNewModel = new OGeometryControlModel< UnoControlButtonModel >( xFactory ); + else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlImageControlModel ) == 0 ) + pNewModel = new OGeometryControlModel< UnoControlImageControlModel >( xFactory ); + else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlRadioButtonModel ) == 0 ) + pNewModel = new OGeometryControlModel< UnoControlRadioButtonModel >( xFactory ); + else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlCheckBoxModel ) == 0 ) + pNewModel = new OGeometryControlModel< UnoControlCheckBoxModel >( xFactory ); + else if ( aServiceSpecifier.compareToAscii( szServiceName_UnoControlFixedHyperlinkModel ) == 0 ) + pNewModel = new OGeometryControlModel< UnoControlFixedHyperlinkModel >( xFactory ); + else if ( aServiceSpecifier.compareToAscii( szServiceName_UnoControlFixedTextModel ) == 0 ) + pNewModel = new OGeometryControlModel< UnoControlFixedTextModel >( xFactory ); + else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlGroupBoxModel ) == 0 ) + pNewModel = new OGeometryControlModel< UnoControlGroupBoxModel >( xFactory ); + else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlListBoxModel ) == 0 ) + pNewModel = new OGeometryControlModel< UnoControlListBoxModel >( xFactory ); + else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlComboBoxModel ) == 0 ) + pNewModel = new OGeometryControlModel< UnoControlComboBoxModel >( xFactory ); + else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlDateFieldModel ) == 0 ) + pNewModel = new OGeometryControlModel< UnoControlDateFieldModel >( xFactory ); + else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlTimeFieldModel ) == 0 ) + pNewModel = new OGeometryControlModel< UnoControlTimeFieldModel >( xFactory ); + else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlNumericFieldModel ) == 0 ) + pNewModel = new OGeometryControlModel< UnoControlNumericFieldModel >( xFactory ); + else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlCurrencyFieldModel ) == 0 ) + pNewModel = new OGeometryControlModel< UnoControlCurrencyFieldModel >( xFactory ); + else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlPatternFieldModel ) == 0 ) + pNewModel = new OGeometryControlModel< UnoControlPatternFieldModel >( xFactory ); + else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlProgressBarModel ) == 0 ) + pNewModel = new OGeometryControlModel< UnoControlProgressBarModel >( xFactory ); + else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlScrollBarModel ) == 0 ) + pNewModel = new OGeometryControlModel< UnoControlScrollBarModel >( xFactory ); + else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlFixedLineModel ) == 0 ) + pNewModel = new OGeometryControlModel< UnoControlFixedLineModel >( xFactory ); + else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlRoadmapModel ) == 0 ) + pNewModel = new OGeometryControlModel< UnoControlRoadmapModel >( xFactory ); + else if ( aServiceSpecifier.compareToAscii( szServiceName_TreeControlModel ) == 0 ) + pNewModel = new OGeometryControlModel< UnoTreeModel >( xFactory ); + else if ( aServiceSpecifier.compareToAscii( szServiceName_GridControlModel ) == 0 ) + pNewModel = new OGeometryControlModel< UnoGridModel >( xFactory ); + else if ( aServiceSpecifier.compareToAscii( szServiceName_UnoControlTabPageContainerModel ) == 0 ) + pNewModel = new OGeometryControlModel< UnoControlTabPageContainerModel >( xFactory ); + + if ( !pNewModel ) + { + if ( xFactory.is() ) + { + Reference< XInterface > xObject = xFactory->createInstance( aServiceSpecifier ); + Reference< XServiceInfo > xSI( xObject, UNO_QUERY ); + Reference< XCloneable > xCloneAccess( xSI, UNO_QUERY ); + Reference< XAggregation > xAgg( xCloneAccess, UNO_QUERY ); + if ( xAgg.is() ) + { + if ( xSI->supportsService( ::rtl::OUString::createFromAscii( "com.sun.star.awt.UnoControlModel" ) ) ) + { + // release 3 of the 4 references we have to the object + xAgg.clear(); + xSI.clear(); + xObject.clear(); + + pNewModel = new OCommonGeometryControlModel( xCloneAccess, aServiceSpecifier ); + } + } + } + } + + Reference< XInterface > xNewModel = (::cppu::OWeakObject*)pNewModel; + return xNewModel; +} + +Reference< XInterface > ControlModelContainerBase::createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier, const Sequence< Any >& /* Arguments */ ) throw(Exception, RuntimeException) +{ + return createInstance( ServiceSpecifier ); +} + +Sequence< ::rtl::OUString > ControlModelContainerBase::getAvailableServiceNames() throw(RuntimeException) +{ + static Sequence< ::rtl::OUString >* pNamesSeq = NULL; + if ( !pNamesSeq ) + { + pNamesSeq = new Sequence< ::rtl::OUString >( 23 ); + ::rtl::OUString* pNames = pNamesSeq->getArray(); + pNames[0] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlEditModel ); + pNames[1] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlFormattedFieldModel ); + pNames[2] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlFileControlModel ); + pNames[3] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlButtonModel ); + pNames[4] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlImageControlModel ); + pNames[5] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlRadioButtonModel ); + pNames[6] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlCheckBoxModel ); + pNames[7] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlFixedTextModel ); + pNames[8] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlGroupBoxModel ); + pNames[9] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlListBoxModel ); + pNames[10] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlComboBoxModel ); + pNames[11] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlDateFieldModel ); + pNames[12] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlTimeFieldModel ); + pNames[13] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlNumericFieldModel ); + pNames[14] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlCurrencyFieldModel ); + pNames[15] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlPatternFieldModel ); + pNames[16] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlProgressBarModel ); + pNames[17] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlScrollBarModel ); + pNames[18] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlFixedLineModel ); + pNames[19] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlRoadmapModel ); + pNames[20] = ::rtl::OUString::createFromAscii( szServiceName_TreeControlModel ); + pNames[21] = ::rtl::OUString::createFromAscii( szServiceName_GridControlModel ); + pNames[22] = ::rtl::OUString::createFromAscii( szServiceName_UnoControlTabPageContainerModel ); + + } + return *pNamesSeq; +} + +// XContainer +void ControlModelContainerBase::addContainerListener( const Reference< XContainerListener >& l ) throw(RuntimeException) +{ + maContainerListeners.addInterface( l ); +} + +void ControlModelContainerBase::removeContainerListener( const Reference< XContainerListener >& l ) throw(RuntimeException) +{ + maContainerListeners.removeInterface( l ); +} + +// XElementAcces +Type ControlModelContainerBase::getElementType() throw(RuntimeException) +{ + Type aType = getCppuType( ( Reference< XControlModel>* ) NULL ); + return aType; +} + +sal_Bool ControlModelContainerBase::hasElements() throw(RuntimeException) +{ + return !maModels.empty(); +} + +// XNameContainer, XNameReplace, XNameAccess +void ControlModelContainerBase::replaceByName( const ::rtl::OUString& aName, const Any& aElement ) throw(IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException) +{ + SolarMutexGuard aSolarGuard; + + Reference< XControlModel > xNewModel; + aElement >>= xNewModel; + if ( !xNewModel.is() ) + lcl_throwIllegalArgumentException(); + + UnoControlModelHolderList::iterator aElementPos = ImplFindElement( aName ); + if ( maModels.end() == aElementPos ) + lcl_throwNoSuchElementException(); + + // stop listening at the old model + stopControlListening( aElementPos->first ); + Reference< XControlModel > xReplaced( aElementPos->first ); + // remember the new model, and start listening + aElementPos->first = xNewModel; + startControlListening( xNewModel ); + + ContainerEvent aEvent; + aEvent.Source = *this; + aEvent.Element = aElement; + aEvent.ReplacedElement <<= xReplaced; + aEvent.Accessor <<= aName; + + // notify the container listener + maContainerListeners.elementReplaced( aEvent ); + + // our "tab controller model" has potentially changed -> notify this + implNotifyTabModelChange( aName ); +} + +Any ControlModelContainerBase::getByName( const ::rtl::OUString& aName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException) +{ + UnoControlModelHolderList::iterator aElementPos = ImplFindElement( aName ); + if ( maModels.end() == aElementPos ) + lcl_throwNoSuchElementException(); + + return makeAny( aElementPos->first ); +} + +Sequence< ::rtl::OUString > ControlModelContainerBase::getElementNames() throw(RuntimeException) +{ + Sequence< ::rtl::OUString > aNames( maModels.size() ); + + ::std::transform( + maModels.begin(), maModels.end(), // source range + aNames.getArray(), // target range + ::boost::bind( &UnoControlModelHolder::second, _1 ) // operator to apply: select the second element (the name) + ); + + return aNames; +} + +sal_Bool ControlModelContainerBase::hasByName( const ::rtl::OUString& aName ) throw(RuntimeException) +{ + return maModels.end() != ImplFindElement( aName ); +} + +void ControlModelContainerBase::insertByName( const ::rtl::OUString& aName, const Any& aElement ) throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException) +{ + SolarMutexGuard aSolarGuard; + + Reference< XControlModel > xM; + aElement >>= xM; + + if ( xM.is() ) + { + Reference< beans::XPropertySet > xProps( xM, UNO_QUERY ); + if ( xProps.is() ) + { + + Reference< beans::XPropertySetInfo > xPropInfo = xProps.get()->getPropertySetInfo(); + + ::rtl::OUString sImageSourceProperty = GetPropertyName( BASEPROPERTY_IMAGEURL ); + if ( xPropInfo.get()->hasPropertyByName( sImageSourceProperty ) && ImplHasProperty(BASEPROPERTY_DIALOGSOURCEURL) ) + { + Any aUrl = xProps.get()->getPropertyValue( sImageSourceProperty ); + + ::rtl::OUString absoluteUrl = + getPhysicalLocation( getPropertyValue( GetPropertyName( BASEPROPERTY_DIALOGSOURCEURL ) ), aUrl ); + + aUrl <<= absoluteUrl; + + xProps.get()->setPropertyValue( sImageSourceProperty , aUrl ); + } + } + } + + + + if ( !aName.getLength() || !xM.is() ) + lcl_throwIllegalArgumentException(); + + UnoControlModelHolderList::iterator aElementPos = ImplFindElement( aName ); + if ( maModels.end() != aElementPos ) + lcl_throwElementExistException(); + + maModels.push_back( UnoControlModelHolder( xM, aName ) ); + mbGroupsUpToDate = sal_False; + startControlListening( xM ); + + ContainerEvent aEvent; + aEvent.Source = *this; + aEvent.Element <<= aElement; + aEvent.Accessor <<= aName; + maContainerListeners.elementInserted( aEvent ); + + // our "tab controller model" has potentially changed -> notify this + implNotifyTabModelChange( aName ); +} + +void ControlModelContainerBase::removeByName( const ::rtl::OUString& aName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException) +{ + SolarMutexGuard aSolarGuard; + + UnoControlModelHolderList::iterator aElementPos = ImplFindElement( aName ); + if ( maModels.end() == aElementPos ) + lcl_throwNoSuchElementException(); + + ContainerEvent aEvent; + aEvent.Source = *this; + aEvent.Element <<= aElementPos->first; + aEvent.Accessor <<= aName; + maContainerListeners.elementRemoved( aEvent ); + + stopControlListening( aElementPos->first ); + Reference< XPropertySet > xPS( aElementPos->first, UNO_QUERY ); + maModels.erase( aElementPos ); + mbGroupsUpToDate = sal_False; + + if ( xPS.is() ) + try + { + xPS->setPropertyValue( PROPERTY_RESOURCERESOLVER, makeAny( Reference< resource::XStringResourceResolver >() ) ); + } + catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); } + + // our "tab controller model" has potentially changed -> notify this + implNotifyTabModelChange( aName ); +} + +// ---------------------------------------------------------------------------- +sal_Bool SAL_CALL ControlModelContainerBase::getGroupControl( ) throw (RuntimeException) +{ + return sal_True; +} + +// ---------------------------------------------------------------------------- +void SAL_CALL ControlModelContainerBase::setGroupControl( sal_Bool ) throw (RuntimeException) +{ + DBG_ERROR( "UnoControlDialogModel::setGroupControl: explicit grouping not supported" ); +} + +// ---------------------------------------------------------------------------- +void SAL_CALL ControlModelContainerBase::setControlModels( const Sequence< Reference< XControlModel > >& _rControls ) throw (RuntimeException) +{ + SolarMutexGuard aSolarGuard; + + // set the tab indexes according to the order of models in the sequence + const Reference< XControlModel >* pControls = _rControls.getConstArray( ); + const Reference< XControlModel >* pControlsEnd = _rControls.getConstArray( ) + _rControls.getLength(); + + sal_Int16 nTabIndex = 1; + + for ( ; pControls != pControlsEnd; ++pControls ) + { + // look up the control in our own structure. This is to prevent invalid arguments + UnoControlModelHolderList::const_iterator aPos = + ::std::find_if( + maModels.begin(), maModels.end(), + CompareControlModel( *pControls ) + ); + if ( maModels.end() != aPos ) + { + // okay, this is an existent model + // now set the TabIndex property (if applicable) + Reference< XPropertySet > xProps( aPos->first, UNO_QUERY ); + Reference< XPropertySetInfo > xPSI; + if ( xProps.is() ) + xPSI = xProps->getPropertySetInfo(); + if ( xPSI.is() && xPSI->hasPropertyByName( getTabIndexPropertyName() ) ) + xProps->setPropertyValue( getTabIndexPropertyName(), makeAny( nTabIndex++ ) ); + } + mbGroupsUpToDate = sal_False; + } +} + + +typedef ::std::multimap< sal_Int32, Reference< XControlModel >, ::std::less< sal_Int32 > > MapIndexToModel; + +// ---------------------------------------------------------------------------- +Sequence< Reference< XControlModel > > SAL_CALL ControlModelContainerBase::getControlModels( ) throw (RuntimeException) +{ + SolarMutexGuard aSolarGuard; + + MapIndexToModel aSortedModels; + // will be the sorted container of all models which have a tab index property + ::std::vector< Reference< XControlModel > > aUnindexedModels; + // will be the container of all models which do not have a tab index property + + UnoControlModelHolderList::const_iterator aLoop = maModels.begin(); + for ( ; aLoop != maModels.end(); ++aLoop ) + { + Reference< XControlModel > xModel( aLoop->first ); + + // see if the model has a TabIndex property + Reference< XPropertySet > xControlProps( xModel, UNO_QUERY ); + Reference< XPropertySetInfo > xPSI; + if ( xControlProps.is() ) + xPSI = xControlProps->getPropertySetInfo( ); + DBG_ASSERT( xPSI.is(), "UnoControlDialogModel::getControlModels: invalid child model!" ); + + // has it? + if ( xPSI.is() && xPSI->hasPropertyByName( getTabIndexPropertyName() ) ) + { // yes + sal_Int32 nTabIndex = -1; + xControlProps->getPropertyValue( getTabIndexPropertyName() ) >>= nTabIndex; + + aSortedModels.insert( MapIndexToModel::value_type( nTabIndex, xModel ) ); + } + else if ( xModel.is() ) + // no, it hasn't, but we have to include it, anyway + aUnindexedModels.push_back( xModel ); + } + + // okay, here we have a container of all our models, sorted by tab index, + // plus a container of "unindexed" models + // -> merge them + Sequence< Reference< XControlModel > > aReturn( aUnindexedModels.size() + aSortedModels.size() ); + ::std::transform( + aSortedModels.begin(), aSortedModels.end(), + ::std::copy( aUnindexedModels.begin(), aUnindexedModels.end(), aReturn.getArray() ), + ::boost::bind( &MapIndexToModel::value_type::second, _1 ) + ); + + return aReturn; +} + +// ---------------------------------------------------------------------------- +void SAL_CALL ControlModelContainerBase::setGroup( const Sequence< Reference< XControlModel > >&, const ::rtl::OUString& ) throw (RuntimeException) +{ + // not supported. We have only implicit grouping: + // We only have a sequence of control models, and we _know_ (yes, that's a HACK relying on + // implementation details) that VCL does grouping according to the order of controls automatically + // At least VCL does this for all we're interested in: Radio buttons. + DBG_ERROR( "UnoControlDialogModel::setGroup: grouping not supported" ); +} + +////----- XInitialization ------------------------------------------------------------------- +void SAL_CALL ControlModelContainerBase::initialize (const Sequence<Any>& rArguments) throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException) +{ + sal_Int16 nPageId = -1; + if ( rArguments.getLength() == 1 ) + { + if ( !( rArguments[ 0 ] >>= nPageId )) + throw lang::IllegalArgumentException(); + m_nTabPageId = nPageId; + } + else + m_nTabPageId = -1; +} +::sal_Int16 SAL_CALL ControlModelContainerBase::getTabPageID() throw (::com::sun::star::uno::RuntimeException) +{ + return m_nTabPageId; +} +::sal_Bool SAL_CALL ControlModelContainerBase::getEnabled() throw (::com::sun::star::uno::RuntimeException) +{ + return m_bEnabled; +} +void SAL_CALL ControlModelContainerBase::setEnabled( ::sal_Bool _enabled ) throw (::com::sun::star::uno::RuntimeException) +{ + m_bEnabled = _enabled; +} +::rtl::OUString SAL_CALL ControlModelContainerBase::getTitle() throw (::com::sun::star::uno::RuntimeException) +{ + SolarMutexGuard aSolarGuard; + Reference<XPropertySet> xThis(*this,UNO_QUERY); + ::rtl::OUString sTitle; + xThis->getPropertyValue(GetPropertyName(BASEPROPERTY_TITLE)) >>= sTitle; + return sTitle; + //return m_sTitle; +} +void SAL_CALL ControlModelContainerBase::setTitle( const ::rtl::OUString& _title ) throw (::com::sun::star::uno::RuntimeException) +{ + SolarMutexGuard aSolarGuard; + Reference<XPropertySet> xThis(*this,UNO_QUERY); + xThis->setPropertyValue(GetPropertyName(BASEPROPERTY_TITLE),makeAny(_title)); +} +::rtl::OUString SAL_CALL ControlModelContainerBase::getImageURL() throw (::com::sun::star::uno::RuntimeException) +{ + return m_sImageURL; +} +void SAL_CALL ControlModelContainerBase::setImageURL( const ::rtl::OUString& _imageurl ) throw (::com::sun::star::uno::RuntimeException) +{ + m_sImageURL = _imageurl; +} +::rtl::OUString SAL_CALL ControlModelContainerBase::getTooltip() throw (::com::sun::star::uno::RuntimeException) +{ + return m_sTooltip; +} +void SAL_CALL ControlModelContainerBase::setTooltip( const ::rtl::OUString& _tooltip ) throw (::com::sun::star::uno::RuntimeException) +{ + m_sTooltip = _tooltip; +} + +// ---------------------------------------------------------------------------- +namespace +{ + enum GroupingMachineState + { + eLookingForGroup, + eExpandingGroup + }; + + // ........................................................................ + static sal_Int32 lcl_getDialogStep( const Reference< XControlModel >& _rxModel ) + { + sal_Int32 nStep = 0; + try + { + Reference< XPropertySet > xModelProps( _rxModel, UNO_QUERY ); + xModelProps->getPropertyValue( getStepPropertyName() ) >>= nStep; + } + catch( const Exception& ) + { + DBG_ERROR( "lcl_getDialogStep: caught an exception while determining the dialog page!" ); + } + return nStep; + } +} + +// ---------------------------------------------------------------------------- +sal_Int32 SAL_CALL ControlModelContainerBase::getGroupCount( ) throw (RuntimeException) +{ + SolarMutexGuard aSolarGuard; + + implUpdateGroupStructure(); + + return maGroups.size(); +} + +// ---------------------------------------------------------------------------- +void SAL_CALL ControlModelContainerBase::getGroup( sal_Int32 _nGroup, Sequence< Reference< XControlModel > >& _rGroup, ::rtl::OUString& _rName ) throw (RuntimeException) +{ + SolarMutexGuard aSolarGuard; + + implUpdateGroupStructure(); + + if ( ( _nGroup < 0 ) || ( _nGroup >= (sal_Int32)maGroups.size() ) ) + { + DBG_ERROR( "UnoControlDialogModel::getGroup: invalid argument and I am not allowed to throw an exception!" ); + _rGroup.realloc( 0 ); + _rName = ::rtl::OUString(); + } + else + { + AllGroups::const_iterator aGroupPos = maGroups.begin() + _nGroup; + _rGroup.realloc( aGroupPos->size() ); + // copy the models + ::std::copy( aGroupPos->begin(), aGroupPos->end(), _rGroup.getArray() ); + // give the group a name + _rName = ::rtl::OUString::valueOf( _nGroup ); + } +} + +// ---------------------------------------------------------------------------- +void SAL_CALL ControlModelContainerBase::getGroupByName( const ::rtl::OUString& _rName, Sequence< Reference< XControlModel > >& _rGroup ) throw (RuntimeException) +{ + SolarMutexGuard aSolarGuard; + + ::rtl::OUString sDummyName; + getGroup( _rName.toInt32( ), _rGroup, sDummyName ); +} + +// ---------------------------------------------------------------------------- +void SAL_CALL ControlModelContainerBase::addChangesListener( const Reference< XChangesListener >& _rxListener ) throw (RuntimeException) +{ + maChangeListeners.addInterface( _rxListener ); +} + +// ---------------------------------------------------------------------------- +void SAL_CALL ControlModelContainerBase::removeChangesListener( const Reference< XChangesListener >& _rxListener ) throw (RuntimeException) +{ + maChangeListeners.removeInterface( _rxListener ); +} + +// ---------------------------------------------------------------------------- +void ControlModelContainerBase::implNotifyTabModelChange( const ::rtl::OUString& _rAccessor ) +{ + // multiplex to our change listeners: + // the changes event + ChangesEvent aEvent; + aEvent.Source = *this; + aEvent.Base <<= aEvent.Source; // the "base of the changes root" is also ourself + aEvent.Changes.realloc( 1 ); // exactly one change + aEvent.Changes[ 0 ].Accessor <<= _rAccessor; + + + Sequence< Reference< XInterface > > aChangeListeners( maChangeListeners.getElements() ); + const Reference< XInterface >* pListener = aChangeListeners.getConstArray(); + const Reference< XInterface >* pListenerEnd = aChangeListeners.getConstArray() + aChangeListeners.getLength(); + for ( ; pListener != pListenerEnd; ++pListener ) + { + if ( pListener->is() ) + static_cast< XChangesListener* >( pListener->get() )->changesOccurred( aEvent ); + } +} + + +// ---------------------------------------------------------------------------- +void ControlModelContainerBase::implUpdateGroupStructure() +{ + if ( mbGroupsUpToDate ) + // nothing to do + return; + + // conditions for a group: + // * all elements of the group are radio buttons + // * all elements of the group are on the same dialog page + // * in the overall control order (determined by the tab index), all elements are subsequent + + maGroups.clear(); + + Sequence< Reference< XControlModel > > aControlModels = getControlModels(); + const Reference< XControlModel >* pControlModels = aControlModels.getConstArray(); + const Reference< XControlModel >* pControlModelsEnd = pControlModels + aControlModels.getLength(); + + // in extreme we have as much groups as controls + maGroups.reserve( aControlModels.getLength() ); + + GroupingMachineState eState = eLookingForGroup; // the current state of our machine + Reference< XServiceInfo > xModelSI; // for checking for a radion button + AllGroups::iterator aCurrentGroup = maGroups.end(); // the group which we're currently building + sal_Int32 nCurrentGroupStep = -1; // the step which all controls of the current group belong to + sal_Bool bIsRadioButton; // is it a radio button? + +#if OSL_DEBUG_LEVEL > 1 + ::std::vector< ::rtl::OUString > aCurrentGroupLabels; +#endif + + for ( ; pControlModels != pControlModelsEnd; ++pControlModels ) + { + // we'll need this in every state + xModelSI = xModelSI.query( *pControlModels ); + bIsRadioButton = xModelSI.is() && xModelSI->supportsService( ::rtl::OUString::createFromAscii( szServiceName2_UnoControlRadioButtonModel ) ); + + switch ( eState ) + { + case eLookingForGroup: + { + if ( !bIsRadioButton ) + // this is no radio button -> still looking for the beginning of a group + continue; + // the current model is a radio button + // -> we found the beginning of a new group + // create the place for this group + size_t nGroups = maGroups.size(); + maGroups.resize( nGroups + 1 ); + aCurrentGroup = maGroups.begin() + nGroups; + // and add the (only, til now) member + aCurrentGroup->push_back( *pControlModels ); + + // get the step which all controls of this group now have to belong to + nCurrentGroupStep = lcl_getDialogStep( *pControlModels ); + // new state: looking for further members + eState = eExpandingGroup; + +#if OSL_DEBUG_LEVEL > 1 + Reference< XPropertySet > xModelProps( *pControlModels, UNO_QUERY ); + ::rtl::OUString sLabel; + if ( xModelProps.is() && xModelProps->getPropertySetInfo().is() && xModelProps->getPropertySetInfo()->hasPropertyByName( ::rtl::OUString::createFromAscii( "Label" ) ) ) + xModelProps->getPropertyValue( ::rtl::OUString::createFromAscii( "Label" ) ) >>= sLabel; + aCurrentGroupLabels.push_back( sLabel ); +#endif + } + break; + + case eExpandingGroup: + { + if ( !bIsRadioButton ) + { // no radio button -> the group is done + aCurrentGroup = maGroups.end(); + eState = eLookingForGroup; +#if OSL_DEBUG_LEVEL > 1 + aCurrentGroupLabels.clear(); +#endif + continue; + } + + // it is a radio button - is it on the proper page? + const sal_Int32 nThisModelStep = lcl_getDialogStep( *pControlModels ); + if ( ( nThisModelStep == nCurrentGroupStep ) // the current button is on the same dialog page + || ( 0 == nThisModelStep ) // the current button appears on all pages + ) + { + // -> it belongs to the same group + aCurrentGroup->push_back( *pControlModels ); + // state still is eExpandingGroup - we're looking for further elements + eState = eExpandingGroup; + +#if OSL_DEBUG_LEVEL > 1 + Reference< XPropertySet > xModelProps( *pControlModels, UNO_QUERY ); + ::rtl::OUString sLabel; + if ( xModelProps.is() && xModelProps->getPropertySetInfo().is() && xModelProps->getPropertySetInfo()->hasPropertyByName( ::rtl::OUString::createFromAscii( "Label" ) ) ) + xModelProps->getPropertyValue( ::rtl::OUString::createFromAscii( "Label" ) ) >>= sLabel; + aCurrentGroupLabels.push_back( sLabel ); +#endif + continue; + } + + // it's a radio button, but on a different page + // -> we open a new group for it + + // close the old group + aCurrentGroup = maGroups.end(); +#if OSL_DEBUG_LEVEL > 1 + aCurrentGroupLabels.clear(); +#endif + + // open a new group + size_t nGroups = maGroups.size(); + maGroups.resize( nGroups + 1 ); + aCurrentGroup = maGroups.begin() + nGroups; + // and add the (only, til now) member + aCurrentGroup->push_back( *pControlModels ); + + nCurrentGroupStep = nThisModelStep; + + // state is the same: we still are looking for further elements of the current group + eState = eExpandingGroup; +#if OSL_DEBUG_LEVEL > 1 + Reference< XPropertySet > xModelProps( *pControlModels, UNO_QUERY ); + ::rtl::OUString sLabel; + if ( xModelProps.is() && xModelProps->getPropertySetInfo().is() && xModelProps->getPropertySetInfo()->hasPropertyByName( ::rtl::OUString::createFromAscii( "Label" ) ) ) + xModelProps->getPropertyValue( ::rtl::OUString::createFromAscii( "Label" ) ) >>= sLabel; + aCurrentGroupLabels.push_back( sLabel ); +#endif + } + break; + } + } + + mbGroupsUpToDate = sal_True; +} + +// ---------------------------------------------------------------------------- +void SAL_CALL ControlModelContainerBase::propertyChange( const PropertyChangeEvent& _rEvent ) throw (RuntimeException) +{ + SolarMutexGuard aSolarGuard; + + DBG_ASSERT( 0 == _rEvent.PropertyName.compareToAscii( "TabIndex" ), + "UnoControlDialogModel::propertyChange: not listening for this property!" ); + + // the accessor for the changed element + ::rtl::OUString sAccessor; + UnoControlModelHolderList::const_iterator aPos = + ::std::find_if( + maModels.begin(), maModels.end(), + CompareControlModel( Reference< XControlModel >( _rEvent.Source, UNO_QUERY ) ) + ); + OSL_ENSURE( maModels.end() != aPos, "UnoControlDialogModel::propertyChange: don't know this model!" ); + if ( maModels.end() != aPos ) + sAccessor = aPos->second; + + // our groups are not up-to-date + mbGroupsUpToDate = sal_False; + + // notify + implNotifyTabModelChange( sAccessor ); +} + +// ---------------------------------------------------------------------------- +void SAL_CALL ControlModelContainerBase::disposing( const EventObject& /*rEvent*/ ) throw (RuntimeException) +{ +} + +// ---------------------------------------------------------------------------- +void ControlModelContainerBase::startControlListening( const Reference< XControlModel >& _rxChildModel ) +{ + SolarMutexGuard aSolarGuard; + + Reference< XPropertySet > xModelProps( _rxChildModel, UNO_QUERY ); + Reference< XPropertySetInfo > xPSI; + if ( xModelProps.is() ) + xPSI = xModelProps->getPropertySetInfo(); + + if ( xPSI.is() && xPSI->hasPropertyByName( getTabIndexPropertyName() ) ) + xModelProps->addPropertyChangeListener( getTabIndexPropertyName(), this ); +} + +// ---------------------------------------------------------------------------- +void ControlModelContainerBase::stopControlListening( const Reference< XControlModel >& _rxChildModel ) +{ + SolarMutexGuard aSolarGuard; + + Reference< XPropertySet > xModelProps( _rxChildModel, UNO_QUERY ); + Reference< XPropertySetInfo > xPSI; + if ( xModelProps.is() ) + xPSI = xModelProps->getPropertySetInfo(); + + if ( xPSI.is() && xPSI->hasPropertyByName( getTabIndexPropertyName() ) ) + xModelProps->removePropertyChangeListener( getTabIndexPropertyName(), this ); +} + +// ============================================================================ +// = class ResourceListener +// ============================================================================ + +ResourceListener::ResourceListener( + const Reference< util::XModifyListener >& rListener ) : + OWeakObject(), + m_xListener( rListener ), + m_bListening( false ) +{ +} + +ResourceListener::~ResourceListener() +{ +} + +// XInterface +Any SAL_CALL ResourceListener::queryInterface( const Type& rType ) +throw ( RuntimeException ) +{ + Any a = ::cppu::queryInterface( + rType , + static_cast< XModifyListener* >( this ), + static_cast< XEventListener* >( this )); + + if ( a.hasValue() ) + return a; + + return OWeakObject::queryInterface( rType ); +} + +void SAL_CALL ResourceListener::acquire() throw () +{ + OWeakObject::acquire(); +} + +void SAL_CALL ResourceListener::release() throw () +{ + OWeakObject::release(); +} + +void ResourceListener::startListening( + const Reference< resource::XStringResourceResolver >& rResource ) +{ + Reference< util::XModifyBroadcaster > xModifyBroadcaster( rResource, UNO_QUERY ); + + { + // --- SAFE --- + ::osl::ResettableGuard < ::osl::Mutex > aGuard( m_aMutex ); + bool bListening( m_bListening ); + bool bResourceSet( m_xResource.is() ); + aGuard.clear(); + // --- SAFE --- + + if ( bListening && bResourceSet ) + stopListening(); + + // --- SAFE --- + aGuard.reset(); + m_xResource = rResource; + aGuard.clear(); + // --- SAFE --- + } + + Reference< util::XModifyListener > xThis( static_cast<OWeakObject*>( this ), UNO_QUERY ); + if ( xModifyBroadcaster.is() ) + { + try + { + xModifyBroadcaster->addModifyListener( xThis ); + + // --- SAFE --- + ::osl::ResettableGuard < ::osl::Mutex > aGuard( m_aMutex ); + m_bListening = true; + // --- SAFE --- + } + catch ( RuntimeException& ) + { + throw; + } + catch ( Exception& ) + { + } + } +} + +void ResourceListener::stopListening() +{ + Reference< util::XModifyBroadcaster > xModifyBroadcaster; + + // --- SAFE --- + ::osl::ResettableGuard < ::osl::Mutex > aGuard( m_aMutex ); + if ( m_bListening && m_xResource.is() ) + xModifyBroadcaster = Reference< util::XModifyBroadcaster >( m_xResource, UNO_QUERY ); + aGuard.clear(); + // --- SAFE --- + + Reference< util::XModifyListener > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY ); + if ( xModifyBroadcaster.is() ) + { + try + { + // --- SAFE --- + aGuard.reset(); + m_bListening = false; + m_xResource.clear(); + aGuard.clear(); + // --- SAFE --- + + xModifyBroadcaster->removeModifyListener( xThis ); + } + catch ( RuntimeException& ) + { + throw; + } + catch ( Exception& ) + { + } + } +} + +// XModifyListener +void SAL_CALL ResourceListener::modified( + const lang::EventObject& aEvent ) +throw ( RuntimeException ) +{ + Reference< util::XModifyListener > xListener; + + // --- SAFE --- + ::osl::ResettableGuard < ::osl::Mutex > aGuard( m_aMutex ); + xListener = m_xListener; + aGuard.clear(); + // --- SAFE --- + + if ( xListener.is() ) + { + try + { + xListener->modified( aEvent ); + } + catch ( RuntimeException& ) + { + throw; + } + catch ( Exception& ) + { + } + } +} + +// XEventListener +void SAL_CALL ResourceListener::disposing( + const EventObject& Source ) +throw ( RuntimeException ) +{ + Reference< lang::XEventListener > xListener; + Reference< resource::XStringResourceResolver > xResource; + + // --- SAFE --- + ::osl::ResettableGuard < ::osl::Mutex > aGuard( m_aMutex ); + Reference< XInterface > xIfacRes( m_xResource, UNO_QUERY ); + Reference< XInterface > xIfacList( m_xListener, UNO_QUERY ); + aGuard.clear(); + // --- SAFE --- + + if ( Source.Source == xIfacRes ) + { + // --- SAFE --- + aGuard.reset(); + m_bListening = false; + xResource = m_xResource; + xListener = Reference< lang::XEventListener >( m_xListener, UNO_QUERY ); + m_xResource.clear(); + aGuard.clear(); + // --- SAFE --- + + if ( xListener.is() ) + { + try + { + xListener->disposing( Source ); + } + catch ( RuntimeException& ) + { + throw; + } + catch ( Exception& ) + { + } + } + } + else if ( Source.Source == xIfacList ) + { + // --- SAFE --- + aGuard.reset(); + m_bListening = false; + xListener = Reference< lang::XEventListener >( m_xListener, UNO_QUERY ); + xResource = m_xResource; + m_xResource.clear(); + m_xListener.clear(); + aGuard.clear(); + // --- SAFE --- + + // Remove ourself as listener from resource resolver + Reference< util::XModifyBroadcaster > xModifyBroadcaster( xResource, UNO_QUERY ); + Reference< util::XModifyListener > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY ); + if ( xModifyBroadcaster.is() ) + { + try + { + xModifyBroadcaster->removeModifyListener( xThis ); + } + catch ( RuntimeException& ) + { + throw; + } + catch ( Exception& ) + { + } + } + } +} + +//=============================================================== +// ---------------------------------------------------- +// class DialogContainerControl +// ---------------------------------------------------- +ControlContainerBase::ControlContainerBase( const Reference< XMultiServiceFactory >& i_factory ) + :ContainerControl_IBase( i_factory ) + ,mbSizeModified(false) + ,mbPosModified(false) +{ + maComponentInfos.nWidth = 280; + maComponentInfos.nHeight = 400; + mxListener = new ResourceListener( Reference< util::XModifyListener >( + static_cast< OWeakObject* >( this ), UNO_QUERY )); +} + +ControlContainerBase::~ControlContainerBase() +{ +} + +void ControlContainerBase::createPeer( const Reference< XToolkit > & rxToolkit, const Reference< XWindowPeer > & rParentPeer ) throw(RuntimeException) +{ + SolarMutexGuard aSolarGuard; + UnoControlContainer::createPeer( rxToolkit, rParentPeer ); +} + +void ControlContainerBase::ImplInsertControl( Reference< XControlModel >& rxModel, const ::rtl::OUString& rName ) +{ + Reference< XPropertySet > xP( rxModel, UNO_QUERY ); + + ::rtl::OUString aDefCtrl; + xP->getPropertyValue( GetPropertyName( BASEPROPERTY_DEFAULTCONTROL ) ) >>= aDefCtrl; + Reference < XControl > xCtrl; + maContext.createComponent( aDefCtrl, xCtrl ); + + DBG_ASSERT( xCtrl.is(), "UnoDialogControl::ImplInsertControl: could not create the control!" ); + if ( xCtrl.is() ) + { + xCtrl->setModel( rxModel ); + addControl( rName, xCtrl ); + // will implicitly call addingControl, where we can add the PropertiesChangeListener to the model + // (which we formerly did herein) + // 08.01.2001 - 96008 - fs@openoffice.org + + ImplSetPosSize( xCtrl ); + } +} + +void ControlContainerBase::ImplRemoveControl( Reference< XControlModel >& rxModel ) +{ + Sequence< Reference< XControl > > aControls = getControls(); + Reference< XControl > xCtrl = StdTabController::FindControl( aControls, rxModel ); + if ( xCtrl.is() ) + { + removeControl( xCtrl ); + try + { + Reference< XComponent > const xControlComp( xCtrl, UNO_QUERY_THROW ); + xControlComp->dispose(); + } + catch( Exception const & ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } +} + +void ControlContainerBase::ImplSetPosSize( Reference< XControl >& rxCtrl ) +{ + Reference< XPropertySet > xP( rxCtrl->getModel(), UNO_QUERY ); + + sal_Int32 nX = 0, nY = 0, nWidth = 0, nHeight = 0; + xP->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PositionX" ) ) ) >>= nX; + xP->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PositionY" ) ) ) >>= nY; + xP->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Width" ) ) ) >>= nWidth; + xP->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Height" ) ) ) >>= nHeight; + MapMode aMode( MAP_APPFONT ); + OutputDevice*pOutDev = Application::GetDefaultDevice(); + if ( pOutDev ) + { + ::Size aTmp( nX, nY ); + aTmp = pOutDev->LogicToPixel( aTmp, aMode ); + nX = aTmp.Width(); + nY = aTmp.Height(); + aTmp = ::Size( nWidth, nHeight ); + aTmp = pOutDev->LogicToPixel( aTmp, aMode ); + nWidth = aTmp.Width(); + nHeight = aTmp.Height(); + } + else + { + Reference< XWindowPeer > xPeer = ImplGetCompatiblePeer( sal_True ); + Reference< XDevice > xD( xPeer, UNO_QUERY ); + + SimpleFontMetric aFM; + FontDescriptor aFD; + Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_FONTDESCRIPTOR ) ); + aVal >>= aFD; + if ( aFD.StyleName.getLength() ) + { + Reference< XFont > xFont = xD->getFont( aFD ); + aFM = xFont->getFontMetric(); + } + else + { + Reference< XGraphics > xG = xD->createGraphics(); + aFM = xG->getFontMetric(); + } + + sal_Int16 nH = aFM.Ascent + aFM.Descent; + sal_Int16 nW = nH/2; // calculate avarage width?! + + nX *= nW; + nX /= 4; + nWidth *= nW; + nWidth /= 4; + nY *= nH; + nY /= 8; + nHeight *= nH; + nHeight /= 8; + } + Reference < XWindow > xW( rxCtrl, UNO_QUERY ); + xW->setPosSize( nX, nY, nWidth, nHeight, PosSize::POSSIZE ); +} + +void ControlContainerBase::dispose() throw(RuntimeException) +{ + SolarMutexGuard aSolarGuard; + + EventObject aEvt; + aEvt.Source = static_cast< ::cppu::OWeakObject* >( this ); + // Notify our listener helper about dispose + // --- SAFE --- + ::osl::ResettableGuard< ::osl::Mutex > aGuard( GetMutex() ); + Reference< XEventListener > xListener( mxListener, UNO_QUERY ); + mxListener.clear(); + aGuard.clear(); + // --- SAFE --- + + if ( xListener.is() ) + xListener->disposing( aEvt ); + UnoControlContainer::dispose(); +} + +void SAL_CALL ControlContainerBase::disposing( + const EventObject& Source ) +throw(RuntimeException) +{ + UnoControlContainer::disposing( Source ); +} + +sal_Bool ControlContainerBase::setModel( const Reference< XControlModel >& rxModel ) throw(RuntimeException) +{ + SolarMutexGuard aSolarGuard; + + // destroy the old tab controller, if existent + if ( mxTabController.is() ) + { + mxTabController->setModel( NULL ); // just to be sure, should not be necessary + removeTabController( mxTabController ); + ::comphelper::disposeComponent( mxTabController ); // just to be sure, should not be necessary + mxTabController.clear(); + } + + if ( getModel().is() ) + { + Sequence< Reference< XControl > > aControls = getControls(); + const Reference< XControl >* pCtrls = aControls.getConstArray(); + const Reference< XControl >* pCtrlsEnd = pCtrls + aControls.getLength(); + + for ( ; pCtrls < pCtrlsEnd; ++pCtrls ) + removeControl( *pCtrls ); + // will implicitly call removingControl, which will remove the PropertyChangeListener + // (which we formerly did herein) + // 08.01.2001 - 96008 - fs@openoffice.org + + Reference< XContainer > xC( getModel(), UNO_QUERY ); + if ( xC.is() ) + xC->removeContainerListener( this ); + + Reference< XChangesNotifier > xChangeNotifier( getModel(), UNO_QUERY ); + if ( xChangeNotifier.is() ) + xChangeNotifier->removeChangesListener( this ); + } + + sal_Bool bRet = UnoControl::setModel( rxModel ); + + if ( getModel().is() ) + { + Reference< XNameAccess > xNA( getModel(), UNO_QUERY ); + if ( xNA.is() ) + { + Sequence< ::rtl::OUString > aNames = xNA->getElementNames(); + const ::rtl::OUString* pNames = aNames.getConstArray(); + sal_uInt32 nCtrls = aNames.getLength(); + + Reference< XControlModel > xCtrlModel; + for( sal_uInt32 n = 0; n < nCtrls; ++n, ++pNames ) + { + xNA->getByName( *pNames ) >>= xCtrlModel; + ImplInsertControl( xCtrlModel, *pNames ); + } + } + + Reference< XContainer > xC( getModel(), UNO_QUERY ); + if ( xC.is() ) + xC->addContainerListener( this ); + + Reference< XChangesNotifier > xChangeNotifier( getModel(), UNO_QUERY ); + if ( xChangeNotifier.is() ) + xChangeNotifier->addChangesListener( this ); + } + + Reference< XTabControllerModel > xTabbing( getModel(), UNO_QUERY ); + if ( xTabbing.is() ) + { + mxTabController = new StdTabController; + mxTabController->setModel( xTabbing ); + addTabController( mxTabController ); + } + ImplStartListingForResourceEvents(); + + return bRet; +} +void ControlContainerBase::setDesignMode( sal_Bool bOn ) throw(RuntimeException) +{ + SolarMutexGuard aSolarGuard; + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + + UnoControl::setDesignMode( bOn ); + + Sequence< Reference< XControl > > xCtrls = getControls(); + sal_Int32 nControls = xCtrls.getLength(); + Reference< XControl >* pControls = xCtrls.getArray(); + for ( sal_Int32 n = 0; n < nControls; n++ ) + pControls[n]->setDesignMode( bOn ); + + // #109067# in design mode the tab controller is not notified about + // tab index changes, therefore the tab order must be activated + // when switching from design mode to live mode + if ( mxTabController.is() && !bOn ) + mxTabController->activateTabOrder(); +} + +void ControlContainerBase::elementInserted( const ContainerEvent& Event ) throw(RuntimeException) +{ + SolarMutexGuard aSolarGuard; + + Reference< XControlModel > xModel; + ::rtl::OUString aName; + + Event.Accessor >>= aName; + Event.Element >>= xModel; + ENSURE_OR_RETURN_VOID( xModel.is(), "UnoDialogControl::elementInserted: illegal element!" ); + try + { + ImplInsertControl( xModel, aName ); + } + catch ( const RuntimeException& e ) { throw; } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } +} + +void ControlContainerBase::elementRemoved( const ContainerEvent& Event ) throw(RuntimeException) +{ + SolarMutexGuard aSolarGuard; + + Reference< XControlModel > xModel; + Event.Element >>= xModel; + ENSURE_OR_RETURN_VOID( xModel.is(), "UnoDialogControl::elementRemoved: illegal element!" ); + try + { + ImplRemoveControl( xModel ); + } + catch ( const RuntimeException& e ) { throw; } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } +} + +void ControlContainerBase::elementReplaced( const ContainerEvent& Event ) throw(RuntimeException) +{ + SolarMutexGuard aSolarGuard; + + Reference< XControlModel > xModel; + Event.ReplacedElement >>= xModel; + try + { + OSL_ENSURE( xModel.is(), "UnoDialogControl::elementReplaced: invalid ReplacedElement!" ); + if ( xModel.is() ) + ImplRemoveControl( xModel ); + } + catch ( const RuntimeException& e ) { throw; } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + ::rtl::OUString aName; + Event.Accessor >>= aName; + Event.Element >>= xModel; + ENSURE_OR_RETURN_VOID( xModel.is(), "UnoDialogControl::elementReplaced: invalid new element!" ); + try + { + ImplInsertControl( xModel, aName ); + } + catch ( const RuntimeException& e ) { throw; } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } +} + +// XPropertiesChangeListener +void ControlContainerBase::ImplModelPropertiesChanged( const Sequence< PropertyChangeEvent >& rEvents ) throw(RuntimeException) +{ + if( !isDesignMode() && !mbCreatingCompatiblePeer ) + { + ::rtl::OUString s1( RTL_CONSTASCII_USTRINGPARAM( "PositionX" ) ); + ::rtl::OUString s2( RTL_CONSTASCII_USTRINGPARAM( "PositionY" ) ); + ::rtl::OUString s3( RTL_CONSTASCII_USTRINGPARAM( "Width" ) ); + ::rtl::OUString s4( RTL_CONSTASCII_USTRINGPARAM( "Height" ) ); + + sal_Int32 nLen = rEvents.getLength(); + for( sal_Int32 i = 0; i < nLen; i++ ) + { + const PropertyChangeEvent& rEvt = rEvents.getConstArray()[i]; + Reference< XControlModel > xModel( rEvt.Source, UNO_QUERY ); + sal_Bool bOwnModel = (XControlModel*)xModel.get() == (XControlModel*)getModel().get(); + if ( ( rEvt.PropertyName == s1 ) || + ( rEvt.PropertyName == s2 ) || + ( rEvt.PropertyName == s3 ) || + ( rEvt.PropertyName == s4 ) ) + { + if ( bOwnModel ) + { + if ( !mbPosModified && !mbSizeModified ) + { + // Don't set new pos/size if we get new values from window listener + Reference< XControl > xThis( (XAggregation*)(::cppu::OWeakAggObject*)this, UNO_QUERY ); + ImplSetPosSize( xThis ); + } + } + else + { + Sequence<Reference<XControl> > aControlSequence(getControls()); + Reference<XControl> aControlRef( StdTabController::FindControl( aControlSequence, xModel ) ); + ImplSetPosSize( aControlRef ); + } + break; + } + } + } + + UnoControlContainer::ImplModelPropertiesChanged( rEvents ); +} + +void ControlContainerBase::addingControl( const Reference< XControl >& _rxControl ) +{ + SolarMutexGuard aSolarGuard; + UnoControlContainer::addingControl( _rxControl ); + + if ( _rxControl.is() ) + { + Reference< XMultiPropertySet > xProps( _rxControl->getModel(), UNO_QUERY ); + if ( xProps.is() ) + { + Sequence< ::rtl::OUString > aNames( 4 ); + ::rtl::OUString* pNames = aNames.getArray(); + *pNames++ = ::rtl::OUString::createFromAscii( "PositionX" ); + *pNames++ = ::rtl::OUString::createFromAscii( "PositionY" ); + *pNames++ = ::rtl::OUString::createFromAscii( "Width" ); + *pNames++ = ::rtl::OUString::createFromAscii( "Height" ); + + xProps->addPropertiesChangeListener( aNames, this ); + } + } +} + +void ControlContainerBase::removingControl( const Reference< XControl >& _rxControl ) +{ + SolarMutexGuard aSolarGuard; + UnoControlContainer::removingControl( _rxControl ); + + if ( _rxControl.is() ) + { + Reference< XMultiPropertySet > xProps( _rxControl->getModel(), UNO_QUERY ); + if ( xProps.is() ) + xProps->removePropertiesChangeListener( this ); + } + +} + +void SAL_CALL ControlContainerBase::changesOccurred( const ChangesEvent& ) throw (RuntimeException) +{ + SolarMutexGuard aSolarGuard; + // a tab controller model may have changed + + // #109067# in design mode don't notify the tab controller + // about tab index changes + if ( mxTabController.is() && !mbDesignMode ) + mxTabController->activateTabOrder(); +} +void lcl_ApplyResolverToNestedContainees( const Reference< resource::XStringResourceResolver >& xStringResourceResolver, const Reference< XControlContainer >& xContainer ) +{ + rtl::OUString aPropName( PROPERTY_RESOURCERESOLVER ); + + Any xNewStringResourceResolver; xNewStringResourceResolver <<= xStringResourceResolver; + + Sequence< rtl::OUString > aPropNames(1); + aPropNames[0] = aPropName; + + const Sequence< Reference< awt::XControl > > aSeq = xContainer->getControls(); + for ( sal_Int32 i = 0; i < aSeq.getLength(); i++ ) + { + Reference< XControl > xControl( aSeq[i] ); + Reference< XPropertySet > xPropertySet; + + if ( xControl.is() ) + xPropertySet = Reference< XPropertySet >( xControl->getModel(), UNO_QUERY ); + + if ( !xPropertySet.is() ) + continue; + + try + { + Reference< resource::XStringResourceResolver > xCurrStringResourceResolver; + Any aOldValue = xPropertySet->getPropertyValue( aPropName ); + if ( ( aOldValue >>= xCurrStringResourceResolver ) + && ( xStringResourceResolver == xCurrStringResourceResolver ) + ) + { + Reference< XMultiPropertySet > xMultiPropSet( xPropertySet, UNO_QUERY ); + Reference< XPropertiesChangeListener > xListener( xPropertySet, UNO_QUERY ); + xMultiPropSet->firePropertiesChangeEvent( aPropNames, xListener ); + } + else + xPropertySet->setPropertyValue( aPropName, xNewStringResourceResolver ); + } + /*catch ( NoSuchElementException& )*/ // that's nonsense, this is never thrown above ... + catch ( const Exception& ) + { + } + + uno::Reference< XControlContainer > xNestedContainer( xControl, uno::UNO_QUERY ); + if ( xNestedContainer.is() ) + lcl_ApplyResolverToNestedContainees( xStringResourceResolver, xNestedContainer ); + + } + +} +void ControlContainerBase::ImplStartListingForResourceEvents() +{ + Reference< resource::XStringResourceResolver > xStringResourceResolver; + + ImplGetPropertyValue( PROPERTY_RESOURCERESOLVER ) >>= xStringResourceResolver; + + // Add our helper as listener to retrieve notifications about changes + Reference< util::XModifyListener > rListener( mxListener ); + ResourceListener* pResourceListener = static_cast< ResourceListener* >( rListener.get() ); + + // resource listener will stop listening if resolver reference is empty + if ( pResourceListener ) + pResourceListener->startListening( xStringResourceResolver ); + ImplUpdateResourceResolver(); +} + +void ControlContainerBase::ImplUpdateResourceResolver() +{ + rtl::OUString aPropName( PROPERTY_RESOURCERESOLVER ); + Reference< resource::XStringResourceResolver > xStringResourceResolver; + + ImplGetPropertyValue( aPropName ) >>= xStringResourceResolver; + if ( !xStringResourceResolver.is() ) + return; + + lcl_ApplyResolverToNestedContainees( xStringResourceResolver, this ); + + // propagate resource resolver changes to language dependent props of the dialog + Reference< XPropertySet > xPropertySet( getModel(), UNO_QUERY ); + if ( xPropertySet.is() ) + { + Reference< XMultiPropertySet > xMultiPropSet( xPropertySet, UNO_QUERY ); + Reference< XPropertiesChangeListener > xListener( xPropertySet, UNO_QUERY ); + xMultiPropSet->firePropertiesChangeEvent( lcl_getLanguageDependentProperties(), xListener ); + } +} + + +uno::Reference< graphic::XGraphic > ControlContainerBase::Impl_getGraphicFromURL_nothrow( const ::rtl::OUString& _rURL ) +{ + uno::Reference< graphic::XGraphic > xGraphic; + if ( !_rURL.getLength() ) + return xGraphic; + + try + { + uno::Reference< graphic::XGraphicProvider > xProvider; + if ( maContext.createComponent( "com.sun.star.graphic.GraphicProvider", xProvider ) ) + { + uno::Sequence< beans::PropertyValue > aMediaProperties(1); + aMediaProperties[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) ); + aMediaProperties[0].Value <<= _rURL; + xGraphic = xProvider->queryGraphic( aMediaProperties ); + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + return xGraphic; +} +//// ---------------------------------------------------- +//// Helper Method to convert relative url to physical location +//// ---------------------------------------------------- + +::rtl::OUString getPhysicalLocation( const ::com::sun::star::uno::Any& rbase, const ::com::sun::star::uno::Any& rUrl ) +{ + + ::rtl::OUString baseLocation; + ::rtl::OUString url; + + rbase >>= baseLocation; + rUrl >>= url; + + ::rtl::OUString absoluteURL( url ); + if ( url.getLength() > 0 ) + { + INetURLObject urlObj(baseLocation); + urlObj.removeSegment(); + baseLocation = urlObj.GetMainURL( INetURLObject::NO_DECODE ); + + const INetURLObject protocolCheck( url ); + const INetProtocol protocol = protocolCheck.GetProtocol(); + if ( protocol == INET_PROT_NOT_VALID ) + { + ::rtl::OUString testAbsoluteURL; + if ( ::osl::FileBase::E_None == ::osl::FileBase::getAbsoluteFileURL( baseLocation, url, testAbsoluteURL ) ) + absoluteURL = testAbsoluteURL; + } + } + + return absoluteURL; +} + diff --git a/toolkit/source/controls/dialogcontrol.cxx b/toolkit/source/controls/dialogcontrol.cxx index 952cf533e0bb..22c35f77bd61 100644 --- a/toolkit/source/controls/dialogcontrol.cxx +++ b/toolkit/source/controls/dialogcontrol.cxx @@ -36,15 +36,7 @@ #include <toolkit/controls/dialogcontrol.hxx> #include <toolkit/helper/property.hxx> #include <toolkit/helper/unopropertyarrayhelper.hxx> -#include <toolkit/controls/geometrycontrolmodel.hxx> -#include <toolkit/controls/unocontrols.hxx> -#include "toolkit/controls/formattedcontrol.hxx" -#include "toolkit/controls/roadmapcontrol.hxx" -#include "toolkit/controls/tkscrollbar.hxx" #include <toolkit/controls/stdtabcontroller.hxx> -#include <toolkit/controls/tksimpleanimation.hxx> -#include <toolkit/controls/tkthrobber.hxx> - #include <com/sun/star/awt/PosSize.hpp> #include <com/sun/star/awt/WindowAttribute.hpp> #include <com/sun/star/resource/XStringResourceResolver.hpp> @@ -52,20 +44,14 @@ #include <cppuhelper/typeprovider.hxx> #include <tools/debug.hxx> #include <tools/diagnose_ex.h> -#include <comphelper/processfactory.hxx> +#include <comphelper/sequence.hxx> #include <vcl/svapp.hxx> #include <vcl/outdev.hxx> -#include <comphelper/types.hxx> -#include <comphelper/componentcontext.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <unotools/ucbstreamhelper.hxx> #include <vcl/graph.hxx> #include <vcl/image.hxx> - -#include "tree/treecontrol.hxx" -#include "grid/gridcontrol.hxx" - #include <map> #include <boost/unordered_map.hpp> #include <algorithm> @@ -86,161 +72,16 @@ using namespace ::com::sun::star::container; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::util; using namespace ::com::sun::star::script; -using namespace toolkit; -#define PROPERTY_RESOURCERESOLVER ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ResourceResolver" )) #define PROPERTY_DIALOGSOURCEURL ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DialogSourceURL" )) #define PROPERTY_IMAGEURL ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ImageURL" )) #define PROPERTY_GRAPHIC ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Graphic" )) - -//HELPER +// +////HELPER ::rtl::OUString getPhysicalLocation( const ::com::sun::star::uno::Any& rbase, const ::com::sun::star::uno::Any& rUrl ); uno::Reference< graphic::XGraphic > getGraphicFromURL_nothrow( uno::Reference< graphic::XGraphicObject >& rxGrfObj, const ::rtl::OUString& _rURL ); -struct LanguageDependentProp -{ - const char* pPropName; - sal_Int32 nPropNameLength; -}; - -// ---------------------------------------------------------------------------- -namespace -{ - static const Sequence< ::rtl::OUString >& lcl_getLanguageDependentProperties() - { - static Sequence< ::rtl::OUString > s_aLanguageDependentProperties; - if ( s_aLanguageDependentProperties.getLength() == 0 ) - { - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if ( s_aLanguageDependentProperties.getLength() == 0 ) - { - s_aLanguageDependentProperties.realloc( 2 ); - s_aLanguageDependentProperties[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HelpText" ) ); - s_aLanguageDependentProperties[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ); - // note: properties must be sorted - } - } - return s_aLanguageDependentProperties; - } - - static ::rtl::OUString lcl_GetStringProperty( const ::rtl::OUString& sProperty, const Reference< XPropertySet >& xSet ) - { - ::rtl::OUString sValue; - Reference< XPropertySetInfo > xPSI; - if (xSet.is() && (xPSI = xSet->getPropertySetInfo()).is() && - xPSI->hasPropertyByName( sProperty ) ) - { - xSet->getPropertyValue( sProperty ) >>= sValue; - } - return sValue; - } - -} - -// ---------------------------------------------------------------------------- -// functor for disposing a control model -struct DisposeControlModel : public ::std::unary_function< Reference< XControlModel >, void > -{ - void operator()( Reference< XControlModel >& _rxModel ) - { - try - { - ::comphelper::disposeComponent( _rxModel ); - } - catch( const Exception& ) - { - OSL_FAIL( "DisposeControlModel::(): caught an exception while disposing a component!" ); - } - } -}; - -// ---------------------------------------------------------------------------- -// functor for searching control model by name -struct FindControlModel : public ::std::unary_function< UnoControlDialogModel::UnoControlModelHolder, bool > -{ -private: - const ::rtl::OUString& m_rName; - -public: - FindControlModel( const ::rtl::OUString& _rName ) : m_rName( _rName ) { } - - bool operator()( const UnoControlDialogModel::UnoControlModelHolder& _rCompare ) - { - return ( _rCompare.second == m_rName ) ? true : false; - } -}; - -// ---------------------------------------------------------------------------- -// functor for cloning a control model, and insertion into a target list -struct CloneControlModel : public ::std::unary_function< UnoControlDialogModel::UnoControlModelHolder, void > -{ -private: - UnoControlDialogModel::UnoControlModelHolderList& m_rTargetList; - -public: - CloneControlModel( UnoControlDialogModel::UnoControlModelHolderList& _rTargetList ) - :m_rTargetList( _rTargetList ) - { - } - - void operator()( const UnoControlDialogModel::UnoControlModelHolder& _rSource ) - { - // clone the source object - Reference< XCloneable > xCloneSource( _rSource.first, UNO_QUERY ); - Reference< XControlModel > xClone( xCloneSource->createClone(), UNO_QUERY ); - // add to target list - m_rTargetList.push_back( UnoControlDialogModel::UnoControlModelHolder( xClone, _rSource.second ) ); - } -}; - -// ---------------------------------------------------------------------------- -// functor for comparing a XControlModel with a given reference -struct CompareControlModel : public ::std::unary_function< UnoControlDialogModel::UnoControlModelHolder, bool > -{ -private: - Reference< XControlModel > m_xReference; -public: - CompareControlModel( const Reference< XControlModel >& _rxReference ) : m_xReference( _rxReference ) { } - - bool operator()( const UnoControlDialogModel::UnoControlModelHolder& _rCompare ) - { - return ( _rCompare.first.get() == m_xReference.get() ) ? true : false; - } -}; - -// ---------------------------------------------------------------------------- -static void lcl_throwIllegalArgumentException( ) -{ // throwing is expensive (in terms of code size), thus we hope the compiler does not inline this .... - throw IllegalArgumentException(); -} - -// ---------------------------------------------------------------------------- -static void lcl_throwNoSuchElementException( ) -{ // throwing is expensive (in terms of code size), thus we hope the compiler does not inline this .... - throw NoSuchElementException(); -} - -// ---------------------------------------------------------------------------- -static void lcl_throwElementExistException( ) -{ // throwing is expensive (in terms of code size), thus we hope the compiler does not inline this .... - throw ElementExistException(); -} - -// ---------------------------------------------------------------------------- -static const ::rtl::OUString& getTabIndexPropertyName( ) -{ - static const ::rtl::OUString s_sTabIndexProperty( RTL_CONSTASCII_USTRINGPARAM( "TabIndex" ) ); - return s_sTabIndexProperty; -} - -// ---------------------------------------------------------------------------- -static const ::rtl::OUString& getStepPropertyName( ) -{ - static const ::rtl::OUString s_sStepProperty( RTL_CONSTASCII_USTRINGPARAM( "Step" ) ); - return s_sStepProperty; -} - // we probably will need both a hash of control models and hash of controls // => use some template magic @@ -368,20 +209,14 @@ UnoControlDialogModel::~UnoControlDialogModel() mbGroupsUpToDate = sal_False; } -Any UnoControlDialogModel::queryAggregation( const Type & rType ) throw(RuntimeException) +UnoControlModel* UnoControlDialogModel::Clone() const { - Any aRet( UnoControlDialogModel_IBase::queryInterface( rType ) ); - return (aRet.hasValue() ? aRet : UnoControlDialogModel_Base::queryAggregation( rType )); -} + // clone the container itself + UnoControlDialogModel* pClone = new UnoControlDialogModel( *this ); -// XTypeProvider -IMPL_IMPLEMENTATION_ID( UnoControlDialogModel ) -Sequence< Type > UnoControlDialogModel::getTypes() throw(RuntimeException) -{ - return ::comphelper::concatSequences( - UnoControlDialogModel_IBase::getTypes(), - UnoControlDialogModel_Base::getTypes() - ); + Clone_Impl(*pClone); + + return pClone; } ::rtl::OUString UnoControlDialogModel::getServiceName( ) throw(RuntimeException) @@ -450,42 +285,6 @@ Any UnoControlDialogModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const return *pHelper; } -void SAL_CALL UnoControlDialogModel::dispose( ) throw(RuntimeException) -{ - // ==================================================================== - // tell our listeners - { - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - - EventObject aDisposeEvent; - aDisposeEvent.Source = static_cast< XAggregation* >( static_cast< ::cppu::OWeakAggObject* >( this ) ); - - maContainerListeners.disposeAndClear( aDisposeEvent ); - maChangeListeners.disposeAndClear( aDisposeEvent ); - } - - // ==================================================================== - // call the base class - UnoControlModel::dispose(); - - // ==================================================================== - // dispose our child models - // for this, collect the models (we collect them from maModels, and this is modified when disposing children) - ::std::vector< Reference< XControlModel > > aChildModels( maModels.size() ); - - ::std::transform( - maModels.begin(), maModels.end(), // source range - aChildModels.begin(), // target location - ::o3tl::select1st< UnoControlModelHolder >( ) // operation to apply -> select the XControlModel part - ); - - // now dispose - ::std::for_each( aChildModels.begin(), aChildModels.end(), DisposeControlModel() ); - aChildModels.clear(); - - mbGroupsUpToDate = sal_False; -} - // XMultiPropertySet Reference< XPropertySetInfo > UnoControlDialogModel::getPropertySetInfo( ) throw(RuntimeException) { @@ -493,175 +292,6 @@ Reference< XPropertySetInfo > UnoControlDialogModel::getPropertySetInfo( ) thro return xInfo; } -UnoControlModel* UnoControlDialogModel::Clone() const -{ - // clone the container itself - UnoControlDialogModel* pClone = new UnoControlDialogModel( *this ); - - // clone all children - ::std::for_each( - maModels.begin(), maModels.end(), - CloneControlModel( pClone->maModels ) - ); - - return pClone; -} - -UnoControlDialogModel::UnoControlModelHolderList::iterator UnoControlDialogModel::ImplFindElement( const ::rtl::OUString& rName ) -{ - return ::std::find_if( maModels.begin(), maModels.end(), FindControlModel( rName ) ); -} - -// ::XMultiServiceFactory -Reference< XInterface > UnoControlDialogModel::createInstance( const ::rtl::OUString& aServiceSpecifier ) throw(Exception, RuntimeException) -{ - SolarMutexGuard aSolarGuard; - - OGeometryControlModel_Base* pNewModel = NULL; - - if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlEditModel ) == 0 ) - pNewModel = new OGeometryControlModel< UnoControlEditModel >; - else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlFormattedFieldModel ) == 0 ) - pNewModel = new OGeometryControlModel< UnoControlFormattedFieldModel >; - else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlFileControlModel ) == 0 ) - pNewModel = new OGeometryControlModel< UnoControlFileControlModel >; - else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlButtonModel ) == 0 ) - pNewModel = new OGeometryControlModel< UnoControlButtonModel >; - else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlImageControlModel ) == 0 ) - pNewModel = new OGeometryControlModel< UnoControlImageControlModel >; - else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlRadioButtonModel ) == 0 ) - pNewModel = new OGeometryControlModel< UnoControlRadioButtonModel >; - else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlCheckBoxModel ) == 0 ) - pNewModel = new OGeometryControlModel< UnoControlCheckBoxModel >; - else if ( aServiceSpecifier.compareToAscii( szServiceName_UnoControlFixedHyperlinkModel ) == 0 ) - pNewModel = new OGeometryControlModel< UnoControlFixedHyperlinkModel >; - else if ( aServiceSpecifier.compareToAscii( szServiceName_UnoControlFixedTextModel ) == 0 ) - pNewModel = new OGeometryControlModel< UnoControlFixedTextModel >; - else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlGroupBoxModel ) == 0 ) - pNewModel = new OGeometryControlModel< UnoControlGroupBoxModel >; - else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlListBoxModel ) == 0 ) - pNewModel = new OGeometryControlModel< UnoControlListBoxModel >; - else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlComboBoxModel ) == 0 ) - pNewModel = new OGeometryControlModel< UnoControlComboBoxModel >; - else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlDateFieldModel ) == 0 ) - pNewModel = new OGeometryControlModel< UnoControlDateFieldModel >; - else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlTimeFieldModel ) == 0 ) - pNewModel = new OGeometryControlModel< UnoControlTimeFieldModel >; - else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlNumericFieldModel ) == 0 ) - pNewModel = new OGeometryControlModel< UnoControlNumericFieldModel >; - else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlCurrencyFieldModel ) == 0 ) - pNewModel = new OGeometryControlModel< UnoControlCurrencyFieldModel >; - else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlPatternFieldModel ) == 0 ) - pNewModel = new OGeometryControlModel< UnoControlPatternFieldModel >; - else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlProgressBarModel ) == 0 ) - pNewModel = new OGeometryControlModel< UnoControlProgressBarModel >; - else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlScrollBarModel ) == 0 ) - pNewModel = new OGeometryControlModel< UnoControlScrollBarModel >; - else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlFixedLineModel ) == 0 ) - pNewModel = new OGeometryControlModel< UnoControlFixedLineModel >; - else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoControlRoadmapModel ) == 0 ) - pNewModel = new OGeometryControlModel< UnoControlRoadmapModel >; - else if ( aServiceSpecifier.compareToAscii( szServiceName_TreeControlModel ) == 0 ) - pNewModel = new OGeometryControlModel< UnoTreeModel >; - else if ( aServiceSpecifier.compareToAscii( szServiceName_GridControlModel ) == 0 ) - pNewModel = new OGeometryControlModel< UnoGridModel >; - else if ( aServiceSpecifier.compareToAscii( szServiceName_UnoMultiPageModel ) == 0 ) - pNewModel = new OGeometryControlModel< UnoMultiPageModel >; - else if ( aServiceSpecifier.compareToAscii( szServiceName_UnoFrameModel ) == 0 ) - pNewModel = new OGeometryControlModel< UnoFrameModel >; - else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoSimpleAnimationControlModel ) == 0 ) - pNewModel = new OGeometryControlModel< UnoSimpleAnimationControlModel >; - else if ( aServiceSpecifier.compareToAscii( szServiceName2_UnoThrobberControlModel ) == 0 ) - pNewModel = new OGeometryControlModel< UnoThrobberControlModel >; - - if ( !pNewModel ) - { - Reference< XMultiServiceFactory > xORB( ::comphelper::getProcessServiceFactory() ); - if ( xORB.is() ) - { - Reference< XInterface > xObject = xORB->createInstance( aServiceSpecifier ); - Reference< XServiceInfo > xSI( xObject, UNO_QUERY ); - Reference< XCloneable > xCloneAccess( xSI, UNO_QUERY ); - Reference< XAggregation > xAgg( xCloneAccess, UNO_QUERY ); - if ( xAgg.is() ) - { - if ( xSI->supportsService( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlModel")) ) ) - { - // release 3 of the 4 references we have to the object - xAgg.clear(); - xSI.clear(); - xObject.clear(); - - pNewModel = new OCommonGeometryControlModel( xCloneAccess, aServiceSpecifier ); - } - } - } - } - - Reference< XInterface > xNewModel = (::cppu::OWeakObject*)pNewModel; - return xNewModel; -} - -Reference< XInterface > UnoControlDialogModel::createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier, const Sequence< Any >& /* Arguments */ ) throw(Exception, RuntimeException) -{ - return createInstance( ServiceSpecifier ); -} - -Sequence< ::rtl::OUString > UnoControlDialogModel::getAvailableServiceNames() throw(RuntimeException) -{ - static Sequence< ::rtl::OUString >* pNamesSeq = NULL; - if ( !pNamesSeq ) - { - pNamesSeq = new Sequence< ::rtl::OUString >( 26 ); - ::rtl::OUString* pNames = pNamesSeq->getArray(); - pNames[0] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlEditModel ); - pNames[1] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlFormattedFieldModel ); - pNames[2] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlFileControlModel ); - pNames[3] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlButtonModel ); - pNames[4] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlImageControlModel ); - pNames[5] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlRadioButtonModel ); - pNames[6] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlCheckBoxModel ); - pNames[7] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlFixedTextModel ); - pNames[8] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlGroupBoxModel ); - pNames[9] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlListBoxModel ); - pNames[10] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlComboBoxModel ); - pNames[11] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlDateFieldModel ); - pNames[12] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlTimeFieldModel ); - pNames[13] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlNumericFieldModel ); - pNames[14] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlCurrencyFieldModel ); - pNames[15] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlPatternFieldModel ); - pNames[16] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlProgressBarModel ); - pNames[17] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlScrollBarModel ); - pNames[18] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlFixedLineModel ); - pNames[19] = ::rtl::OUString::createFromAscii( szServiceName2_UnoControlRoadmapModel ); - pNames[20] = ::rtl::OUString::createFromAscii( szServiceName_TreeControlModel ); - pNames[21] = ::rtl::OUString::createFromAscii( szServiceName_GridControlModel ); - pNames[22] = ::rtl::OUString::createFromAscii( szServiceName2_UnoSimpleAnimationControlModel ); - pNames[23] = ::rtl::OUString::createFromAscii( szServiceName2_UnoThrobberControlModel ); - pNames[24] = ::rtl::OUString::createFromAscii( szServiceName_UnoMultiPageModel ); - pNames[25] = ::rtl::OUString::createFromAscii( szServiceName_UnoFrameModel ); - } - return *pNamesSeq; -} - -// XContainer -void UnoControlDialogModel::addContainerListener( const Reference< XContainerListener >& l ) throw(RuntimeException) -{ - maContainerListeners.addInterface( l ); -} - -void UnoControlDialogModel::removeContainerListener( const Reference< XContainerListener >& l ) throw(RuntimeException) -{ - maContainerListeners.removeInterface( l ); -} - -// XElementAcces -Type UnoControlDialogModel::getElementType() throw(RuntimeException) -{ - Type aType = getCppuType( ( Reference< XControlModel>* ) NULL ); - return aType; -} - void UnoControlDialogModel::updateUserFormChildren( const Reference< XNameContainer >& xAllChildren, const rtl::OUString& aName, ChildOperation Operation, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& xTarget ) throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException) { if ( Operation < Insert || Operation > Remove ) @@ -1575,119 +1205,21 @@ UnoDialogControl::UnoDialogControl() : // XInterface Any UnoDialogControl::queryAggregation( const Type & rType ) throw(RuntimeException) { - Any aRet( UnoDialogControl_IBase::queryInterface( rType ) ); - return (aRet.hasValue() ? aRet : UnoControlContainer::queryAggregation( rType )); + uno::Any aRet = ::cppu::queryInterface( rType, SAL_STATIC_CAST( awt::XTopWindow*, this ) ); + if ( !aRet.hasValue() ) + aRet = ::cppu::queryInterface( rType, SAL_STATIC_CAST( awt::XDialog*, this ) ); + if ( !aRet.hasValue() ) + aRet = ::cppu::queryInterface( rType, SAL_STATIC_CAST( awt::XWindowListener*, this ) ); + return (aRet.hasValue() ? aRet : ControlContainerBase::queryAggregation( rType )); } -// XTypeProvider -IMPL_IMPLEMENTATION_ID( UnoDialogControl ) -Sequence< Type > UnoDialogControl::getTypes() throw(RuntimeException) -{ - return ::comphelper::concatSequences( - UnoDialogControl_IBase::getTypes(), - UnoControlContainer::getTypes() - ); -} - -void UnoDialogControl::ImplInsertControl( Reference< XControlModel >& rxModel, const ::rtl::OUString& rName ) -{ - Reference< XPropertySet > xP( rxModel, UNO_QUERY ); - - ::rtl::OUString aDefCtrl; - xP->getPropertyValue( GetPropertyName( BASEPROPERTY_DEFAULTCONTROL ) ) >>= aDefCtrl; - - // Add our own resource resolver to a newly created control - Reference< resource::XStringResourceResolver > xStringResourceResolver; - rtl::OUString aPropName( PROPERTY_RESOURCERESOLVER ); - - Any aAny; - ImplGetPropertyValue( aPropName ) >>= xStringResourceResolver; - - aAny <<= xStringResourceResolver; - xP->setPropertyValue( aPropName, aAny ); - - Reference< XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory(); - Reference < XControl > xCtrl( xMSF->createInstance( aDefCtrl ), UNO_QUERY ); - - DBG_ASSERT( xCtrl.is(), "UnoDialogControl::ImplInsertControl: could not create the control!" ); - if ( xCtrl.is() ) - { - xCtrl->setModel( rxModel ); - addControl( rName, xCtrl ); - // will implicitly call addingControl, where we can add the PropertiesChangeListener to the model - // (which we formerly did herein) - - ImplSetPosSize( xCtrl ); - } -} - -void UnoDialogControl::ImplRemoveControl( Reference< XControlModel >& rxModel ) -{ - Sequence< Reference< XControl > > aControls = getControls(); - Reference< XControl > xCtrl = StdTabController::FindControl( aControls, rxModel ); - if ( xCtrl.is() ) - removeControl( xCtrl ); -} - -void UnoDialogControl::ImplSetPosSize( Reference< XControl >& rxCtrl ) -{ - Reference< XPropertySet > xP( rxCtrl->getModel(), UNO_QUERY ); - - sal_Int32 nX = 0, nY = 0, nWidth = 0, nHeight = 0; - xP->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PositionX" ) ) ) >>= nX; - xP->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PositionY" ) ) ) >>= nY; - xP->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Width" ) ) ) >>= nWidth; - xP->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Height" ) ) ) >>= nHeight; - - // Currentley we are simply using MAP_APPFONT - OutputDevice*pOutDev = Application::GetDefaultDevice(); - DBG_ASSERT( pOutDev, "Missing Default Device!" ); - if ( pOutDev ) - { - ::Size aTmp( nX, nY ); - aTmp = pOutDev->LogicToPixel( aTmp, MAP_APPFONT ); - nX = aTmp.Width(); - nY = aTmp.Height(); - aTmp = ::Size( nWidth, nHeight ); - aTmp = pOutDev->LogicToPixel( aTmp, MAP_APPFONT ); - nWidth = aTmp.Width(); - nHeight = aTmp.Height(); - } - else - { - Reference< XWindowPeer > xPeer = ImplGetCompatiblePeer( sal_True ); - Reference< XDevice > xD( xPeer, UNO_QUERY ); - - SimpleFontMetric aFM; - FontDescriptor aFD; - Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_FONTDESCRIPTOR ) ); - aVal >>= aFD; - if ( aFD.StyleName.getLength() ) - { - Reference< XFont > xFont = xD->getFont( aFD ); - aFM = xFont->getFontMetric(); - } - else - { - Reference< XGraphics > xG = xD->createGraphics(); - aFM = xG->getFontMetric(); - } - - sal_Int16 nH = aFM.Ascent + aFM.Descent; - sal_Int16 nW = nH/2; // calculate avarage width?! - - nX *= nW; - nX /= 4; - nWidth *= nW; - nWidth /= 4; - nY *= nH; - nY /= 8; - nHeight *= nH; - nHeight /= 8; - } - Reference < XWindow > xW( rxCtrl, UNO_QUERY ); - xW->setPosSize( nX, nY, nWidth, nHeight, PosSize::POSSIZE ); -} + //lang::XTypeProvider +IMPL_XTYPEPROVIDER_START( UnoDialogControl) + getCppuType( ( uno::Reference< awt::XTopWindow>* ) NULL ), + getCppuType( ( uno::Reference< awt::XDialog>* ) NULL ), + getCppuType( ( uno::Reference< awt::XWindowListener>* ) NULL ), + ControlContainerBase::getTypes() +IMPL_XTYPEPROVIDER_END void UnoDialogControl::dispose() throw(RuntimeException) { @@ -1696,115 +1228,21 @@ void UnoDialogControl::dispose() throw(RuntimeException) EventObject aEvt; aEvt.Source = static_cast< ::cppu::OWeakObject* >( this ); maTopWindowListeners.disposeAndClear( aEvt ); - - // Notify our listener helper about dispose - // --- SAFE --- - ::osl::ResettableGuard< ::osl::Mutex > aGuard( GetMutex() ); - Reference< XEventListener > xListener( mxListener, UNO_QUERY ); - mxListener.clear(); - aGuard.clear(); - // --- SAFE --- - - if ( xListener.is() ) - xListener->disposing( aEvt ); - - UnoControlContainer::dispose(); + ControlContainerBase::dispose(); } void SAL_CALL UnoDialogControl::disposing( const EventObject& Source ) throw(RuntimeException) { - rtl::OUString aPropName( PROPERTY_RESOURCERESOLVER ); - Reference< resource::XStringResourceResolver > xStringResourceResolver; - - ImplGetPropertyValue( aPropName ) >>= xStringResourceResolver; - Reference< XInterface > xIfac( xStringResourceResolver, UNO_QUERY ); - - if ( Source.Source == xIfac ) - { - Any aAny; - - // Reset resource resolver reference - ImplSetPropertyValue( aPropName, aAny, sal_True ); - ImplUpdateResourceResolver(); - } - else - { - UnoControlContainer::disposing( Source ); - } + ControlContainerBase::disposing( Source ); } sal_Bool UnoDialogControl::setModel( const Reference< XControlModel >& rxModel ) throw(RuntimeException) { SolarMutexGuard aSolarGuard; - - // destroy the old tab controller, if existent - if ( mxTabController.is() ) - { - mxTabController->setModel( NULL ); // just to be sure, should not be necessary - removeTabController( mxTabController ); - ::comphelper::disposeComponent( mxTabController ); // just to be sure, should not be necessary - mxTabController.clear(); - } - - if ( getModel().is() ) - { - Sequence< Reference< XControl > > aControls = getControls(); - const Reference< XControl >* pCtrls = aControls.getConstArray(); - const Reference< XControl >* pCtrlsEnd = pCtrls + aControls.getLength(); - - for ( ; pCtrls < pCtrlsEnd; ++pCtrls ) - removeControl( *pCtrls ); - // will implicitly call removingControl, which will remove the PropertyChangeListener - // (which we formerly did herein) - - Reference< XContainer > xC( getModel(), UNO_QUERY ); - if ( xC.is() ) - xC->removeContainerListener( this ); - - Reference< XChangesNotifier > xChangeNotifier( getModel(), UNO_QUERY ); - if ( xChangeNotifier.is() ) - xChangeNotifier->removeChangesListener( this ); - } - - sal_Bool bRet = UnoControl::setModel( rxModel ); - - if ( getModel().is() ) - { - Reference< XNameAccess > xNA( getModel(), UNO_QUERY ); - if ( xNA.is() ) - { - Sequence< ::rtl::OUString > aNames = xNA->getElementNames(); - const ::rtl::OUString* pNames = aNames.getConstArray(); - sal_uInt32 nCtrls = aNames.getLength(); - - Reference< XControlModel > xCtrlModel; - for( sal_uInt32 n = 0; n < nCtrls; ++n, ++pNames ) - { - xNA->getByName( *pNames ) >>= xCtrlModel; - ImplInsertControl( xCtrlModel, *pNames ); - } - } - - Reference< XContainer > xC( getModel(), UNO_QUERY ); - if ( xC.is() ) - xC->addContainerListener( this ); - - Reference< XChangesNotifier > xChangeNotifier( getModel(), UNO_QUERY ); - if ( xChangeNotifier.is() ) - xChangeNotifier->addChangesListener( this ); - } - - Reference< XTabControllerModel > xTabbing( getModel(), UNO_QUERY ); - if ( xTabbing.is() ) - { - mxTabController = new StdTabController; - mxTabController->setModel( xTabbing ); - addTabController( mxTabController ); - } + sal_Bool bRet = ControlContainerBase::setModel( rxModel ); ImplStartListingForResourceEvents(); - return bRet; } @@ -1969,13 +1407,11 @@ void UnoDialogControl::setMenuBar( const Reference< XMenuBar >& rxMenuBar ) thro xTW->setMenuBar( mxMenuBar ); } } - static ::Size ImplMapPixelToAppFont( OutputDevice* pOutDev, const ::Size& aSize ) { ::Size aTmp = pOutDev->PixelToLogic( aSize, MAP_APPFONT ); return aTmp; } - // ::com::sun::star::awt::XWindowListener void SAL_CALL UnoDialogControl::windowResized( const ::com::sun::star::awt::WindowEvent& e ) throw (::com::sun::star::uno::RuntimeException) @@ -2315,6 +1751,7 @@ throw (RuntimeException) ImplUpdateResourceResolver(); } +void UnoDialogControl::ImplModelPropertiesChanged( const Sequence< PropertyChangeEvent >& rEvents ) throw(RuntimeException) // ---------------------------------------------------- // Helper Method to convert relative url to physical location // ---------------------------------------------------- diff --git a/toolkit/source/controls/formattedcontrol.cxx b/toolkit/source/controls/formattedcontrol.cxx index e83749d3a6da..fc8b49ddebe6 100644 --- a/toolkit/source/controls/formattedcontrol.cxx +++ b/toolkit/source/controls/formattedcontrol.cxx @@ -126,8 +126,9 @@ namespace toolkit // = UnoControlFormattedFieldModel // =================================================================== // ------------------------------------------------------------------- - UnoControlFormattedFieldModel::UnoControlFormattedFieldModel() - :m_bRevokedAsClient( false ) + UnoControlFormattedFieldModel::UnoControlFormattedFieldModel( const Reference< XMultiServiceFactory >& i_factory ) + :UnoControlModel( i_factory ) + ,m_bRevokedAsClient( false ) ,m_bSettingValueAndText( false ) { ImplRegisterProperty( BASEPROPERTY_ALIGN ); @@ -434,7 +435,8 @@ namespace toolkit // = UnoFormattedFieldControl // =================================================================== // ------------------------------------------------------------------- - UnoFormattedFieldControl::UnoFormattedFieldControl() + UnoFormattedFieldControl::UnoFormattedFieldControl( const Reference< XMultiServiceFactory >& i_factory ) + :UnoSpinFieldControl( i_factory ) { } @@ -458,7 +460,7 @@ namespace toolkit aValues[0] = xPeer->getProperty( aNames[0] ); aValues[1] = xPeer->getProperty( aNames[1] ); - ImplSetPropertyValues( aNames, aValues, FALSE ); + ImplSetPropertyValues( aNames, aValues, sal_False ); if ( GetTextListeners().getLength() ) GetTextListeners().textChanged( e ); diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx index 4a644484b599..56eddb34fce4 100644 --- a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx +++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx @@ -28,175 +28,367 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_toolkit.hxx" + #include "defaultgridcolumnmodel.hxx" -#include <comphelper/sequence.hxx> -#include <toolkit/helper/servicenames.hxx> +#include "gridcolumn.hxx" + +/** === begin UNO includes === **/ #include <com/sun/star/awt/XVclWindowPeer.hpp> -#include <rtl/ref.hxx> +/** === end UNO includes === **/ -using ::rtl::OUString; -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::awt; -using namespace ::com::sun::star::awt::grid; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::style; +#include <comphelper/sequence.hxx> +#include <comphelper/componentguard.hxx> +#include <toolkit/helper/servicenames.hxx> +#include <rtl/ustrbuf.hxx> +#include <tools/diagnose_ex.h> +//...................................................................................................................... namespace toolkit +//...................................................................................................................... { + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::lang::XMultiServiceFactory; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::awt::grid::XGridColumn; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::lang::XMultiServiceFactory; + using ::com::sun::star::lang::XComponent; + using ::com::sun::star::lang::EventObject; + using ::com::sun::star::container::XContainerListener; + using ::com::sun::star::container::ContainerEvent; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::lang::IndexOutOfBoundsException; + using ::com::sun::star::util::XCloneable; + using ::com::sun::star::lang::IllegalArgumentException; + /** === end UNO using === **/ + + //================================================================================================================== + //= DefaultGridColumnModel + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + DefaultGridColumnModel::DefaultGridColumnModel( const Reference< XMultiServiceFactory >& i_factory ) + :DefaultGridColumnModel_Base( m_aMutex ) + ,m_aContext( i_factory ) + ,m_aContainerListeners( m_aMutex ) + ,m_aColumns() + { + } -/////////////////////////////////////////////////////////////////////// -// class DefaultGridColumnModel -/////////////////////////////////////////////////////////////////////// - -DefaultGridColumnModel::DefaultGridColumnModel(const Reference< XMultiServiceFactory >& xFactory) -: columns(std::vector< Reference< XGridColumn > >()) - ,m_nColumnHeaderHeight(0) - ,m_xFactory(xFactory) -{ -} + //------------------------------------------------------------------------------------------------------------------ + DefaultGridColumnModel::DefaultGridColumnModel( DefaultGridColumnModel const & i_copySource ) + :cppu::BaseMutex() + ,DefaultGridColumnModel_Base( m_aMutex ) + ,m_aContext( i_copySource.m_aContext ) + ,m_aContainerListeners( m_aMutex ) + ,m_aColumns() + { + Columns aColumns; + aColumns.reserve( i_copySource.m_aColumns.size() ); + try + { + for ( Columns::const_iterator col = i_copySource.m_aColumns.begin(); + col != i_copySource.m_aColumns.end(); + ++col + ) + { + Reference< XCloneable > const xCloneable( *col, UNO_QUERY_THROW ); + Reference< XGridColumn > const xClone( xCloneable->createClone(), UNO_QUERY_THROW ); + + GridColumn* const pGridColumn = GridColumn::getImplementation( xClone ); + if ( pGridColumn == NULL ) + throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "invalid clone source implementation" ) ), *this ); + // that's indeed a RuntimeException, not an IllegalArgumentException or some such: + // a DefaultGridColumnModel implementation whose columns are not GridColumn implementations + // is borked. + pGridColumn->setIndex( col - i_copySource.m_aColumns.begin() ); + + aColumns.push_back( xClone ); + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + if ( aColumns.size() == i_copySource.m_aColumns.size() ) + m_aColumns.swap( aColumns ); + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + DefaultGridColumnModel::~DefaultGridColumnModel() + { + } -DefaultGridColumnModel::~DefaultGridColumnModel() -{ -} + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL DefaultGridColumnModel::getColumnCount() throw (RuntimeException) + { + return m_aColumns.size(); + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + Reference< XGridColumn > SAL_CALL DefaultGridColumnModel::createColumn( ) throw (RuntimeException) + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); + return new GridColumn(); + } -::sal_Int32 SAL_CALL DefaultGridColumnModel::getColumnCount() throw (::com::sun::star::uno::RuntimeException) -{ - return columns.size(); -} + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL DefaultGridColumnModel::addColumn( const Reference< XGridColumn > & i_column ) throw (RuntimeException, IllegalArgumentException) + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); -//--------------------------------------------------------------------- + GridColumn* const pGridColumn = GridColumn::getImplementation( i_column ); + if ( pGridColumn == NULL ) + throw IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "invalid column implementation" ) ), *this, 1 ); -::sal_Int32 SAL_CALL DefaultGridColumnModel::addColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & column) throw (::com::sun::star::uno::RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - Reference<XGridColumn> xColumn(column); - columns.push_back(xColumn); - sal_Int32 index = columns.size() - 1; - xColumn->setIndex(index); - return index; -} + m_aColumns.push_back( i_column ); + sal_Int32 index = m_aColumns.size() - 1; + pGridColumn->setIndex( index ); -//--------------------------------------------------------------------- + // fire insertion notifications + ContainerEvent aEvent; + aEvent.Source = *this; + aEvent.Accessor <<= index; + aEvent.Element <<= i_column; -::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > > SAL_CALL DefaultGridColumnModel::getColumns() throw (::com::sun::star::uno::RuntimeException) -{ - return comphelper::containerToSequence(columns); -} + aGuard.clear(); + m_aContainerListeners.notifyEach( &XContainerListener::elementInserted, aEvent ); -//--------------------------------------------------------------------- + return index; + } -::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > SAL_CALL DefaultGridColumnModel::getColumn(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException) -{ - if ( index >=0 && index < ((sal_Int32)columns.size())) + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridColumnModel::removeColumn( ::sal_Int32 i_columnIndex ) throw (RuntimeException, IndexOutOfBoundsException) { - return columns[index]; + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); + + if ( ( i_columnIndex < 0 ) || ( size_t( i_columnIndex ) >= m_aColumns.size() ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); + + Columns::iterator const pos = m_aColumns.begin() + i_columnIndex; + Reference< XGridColumn > const xColumn( *pos ); + m_aColumns.erase( pos ); + + // update indexes of all subsequent columns + sal_Int32 columnIndex( i_columnIndex ); + for ( Columns::iterator updatePos = m_aColumns.begin() + columnIndex; + updatePos != m_aColumns.end(); + ++updatePos, ++columnIndex + ) + { + GridColumn* pColumnImpl = GridColumn::getImplementation( *updatePos ); + ENSURE_OR_CONTINUE( pColumnImpl, "DefaultGridColumnModel::removeColumn: invalid column implementation!" ); + pColumnImpl->setIndex( columnIndex ); + } + + // fire removal notifications + ContainerEvent aEvent; + aEvent.Source = *this; + aEvent.Accessor <<= i_columnIndex; + aEvent.Element <<= xColumn; + + aGuard.clear(); + m_aContainerListeners.notifyEach( &XContainerListener::elementRemoved, aEvent ); + + // dispose the removed column + try + { + Reference< XComponent > const xColComp( xColumn, UNO_QUERY_THROW ); + xColComp->dispose(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } - else - return Reference< XGridColumn >(); -} -//--------------------------------------------------------------------- -void SAL_CALL DefaultGridColumnModel::setColumnHeaderHeight(sal_Int32 _value) throw (::com::sun::star::uno::RuntimeException) -{ - m_nColumnHeaderHeight = _value; -} -//--------------------------------------------------------------------- -sal_Int32 SAL_CALL DefaultGridColumnModel::getColumnHeaderHeight() throw (::com::sun::star::uno::RuntimeException) -{ - return m_nColumnHeaderHeight; -} - -//--------------------------------------------------------------------- -void SAL_CALL DefaultGridColumnModel::setDefaultColumns(sal_Int32 rowElements) throw (::com::sun::star::uno::RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - for(sal_Int32 i=0;i<rowElements;i++) + //------------------------------------------------------------------------------------------------------------------ + Sequence< Reference< XGridColumn > > SAL_CALL DefaultGridColumnModel::getColumns() throw (RuntimeException) { - Reference<XGridColumn> xColumn( m_xFactory->createInstance ( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.grid.GridColumn")) ), UNO_QUERY ); - columns.push_back(xColumn); - xColumn->setIndex(i); + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); + return ::comphelper::containerToSequence( m_aColumns ); } -} -::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > SAL_CALL DefaultGridColumnModel::copyColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & column) throw (::com::sun::star::uno::RuntimeException) -{ - Reference<XGridColumn> xColumn( m_xFactory->createInstance ( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.grid.GridColumn")) ), UNO_QUERY ); - xColumn->setColumnWidth(column->getColumnWidth()); - xColumn->setPreferredWidth(column->getPreferredWidth()); - xColumn->setMaxWidth(column->getMaxWidth()); - xColumn->setMinWidth(column->getMinWidth()); - xColumn->setPreferredWidth(column->getPreferredWidth()); - xColumn->setResizeable(column->getResizeable()); - xColumn->setTitle(column->getTitle()); - xColumn->setHorizontalAlign(column->getHorizontalAlign()); - return xColumn; -} -//--------------------------------------------------------------------- -// XComponent -//--------------------------------------------------------------------- - -void SAL_CALL DefaultGridColumnModel::dispose() throw (RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - ::com::sun::star::lang::EventObject aEvent; - aEvent.Source.set( static_cast< ::cppu::OWeakObject* >( this ) ); - BrdcstHelper.aLC.disposeAndClear( aEvent ); - -} + //------------------------------------------------------------------------------------------------------------------ + Reference< XGridColumn > SAL_CALL DefaultGridColumnModel::getColumn(::sal_Int32 index) throw (IndexOutOfBoundsException, RuntimeException) + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); -//--------------------------------------------------------------------- + if ( index >=0 && index < ((sal_Int32)m_aColumns.size())) + return m_aColumns[index]; -void SAL_CALL DefaultGridColumnModel::addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException) -{ - BrdcstHelper.addListener( XEventListener::static_type(), xListener ); -} + throw IndexOutOfBoundsException(); + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridColumnModel::setDefaultColumns(sal_Int32 rowElements) throw (RuntimeException) + { + ::std::vector< ContainerEvent > aRemovedColumns; + ::std::vector< ContainerEvent > aInsertedColumns; + + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); + + // remove existing columns + while ( !m_aColumns.empty() ) + { + const size_t lastColIndex = m_aColumns.size() - 1; + + ContainerEvent aEvent; + aEvent.Source = *this; + aEvent.Accessor <<= sal_Int32( lastColIndex ); + aEvent.Element <<= m_aColumns[ lastColIndex ]; + aRemovedColumns.push_back( aEvent ); + + m_aColumns.erase( m_aColumns.begin() + lastColIndex ); + } + + // add new columns + for ( sal_Int32 i=0; i<rowElements; ++i ) + { + ::rtl::Reference< GridColumn > const pGridColumn = new GridColumn(); + Reference< XGridColumn > const xColumn( pGridColumn.get() ); + ::rtl::OUStringBuffer colTitle; + colTitle.appendAscii( "Column " ); + colTitle.append( i + 1 ); + pGridColumn->setTitle( colTitle.makeStringAndClear() ); + pGridColumn->setColumnWidth( 80 /* APPFONT */ ); + pGridColumn->setFlexibility( 1 ); + pGridColumn->setResizeable( sal_True ); + pGridColumn->setDataColumnIndex( i ); + + ContainerEvent aEvent; + aEvent.Source = *this; + aEvent.Accessor <<= i; + aEvent.Element <<= xColumn; + aInsertedColumns.push_back( aEvent ); + + m_aColumns.push_back( xColumn ); + pGridColumn->setIndex( i ); + } + } + + // fire removal notifications + for ( ::std::vector< ContainerEvent >::const_iterator event = aRemovedColumns.begin(); + event != aRemovedColumns.end(); + ++event + ) + { + m_aContainerListeners.notifyEach( &XContainerListener::elementRemoved, *event ); + } + + // fire insertion notifications + for ( ::std::vector< ContainerEvent >::const_iterator event = aInsertedColumns.begin(); + event != aInsertedColumns.end(); + ++event + ) + { + m_aContainerListeners.notifyEach( &XContainerListener::elementInserted, *event ); + } + + // dispose removed columns + for ( ::std::vector< ContainerEvent >::const_iterator event = aRemovedColumns.begin(); + event != aRemovedColumns.end(); + ++event + ) + { + try + { + const Reference< XComponent > xColComp( event->Element, UNO_QUERY_THROW ); + xColComp->dispose(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + } -void SAL_CALL DefaultGridColumnModel::removeEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException) -{ - BrdcstHelper.removeListener( XEventListener::static_type(), xListener ); -} + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL DefaultGridColumnModel::getImplementationName( ) throw (RuntimeException) + { + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.toolkit.DefaultGridColumnModel" ) ); + } -//--------------------------------------------------------------------- -// XServiceInfo -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + sal_Bool SAL_CALL DefaultGridColumnModel::supportsService( const ::rtl::OUString& i_serviceName ) throw (RuntimeException) + { + const Sequence< ::rtl::OUString > aServiceNames( getSupportedServiceNames() ); + for ( sal_Int32 i=0; i<aServiceNames.getLength(); ++i ) + if ( aServiceNames[i] == i_serviceName ) + return sal_True; + return sal_False; + } -::rtl::OUString SAL_CALL DefaultGridColumnModel::getImplementationName( ) throw (RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - static const OUString aImplName( RTL_CONSTASCII_USTRINGPARAM( "toolkit.DefaultGridColumnModel" ) ); - return aImplName; -} + //------------------------------------------------------------------------------------------------------------------ + Sequence< ::rtl::OUString > SAL_CALL DefaultGridColumnModel::getSupportedServiceNames( ) throw (RuntimeException) + { + const ::rtl::OUString aServiceName( ::rtl::OUString::createFromAscii( szServiceName_DefaultGridColumnModel ) ); + const Sequence< ::rtl::OUString > aSeq( &aServiceName, 1 ); + return aSeq; + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridColumnModel::addContainerListener( const Reference< XContainerListener >& i_listener ) throw (RuntimeException) + { + if ( i_listener.is() ) + m_aContainerListeners.addInterface( i_listener ); + } -sal_Bool SAL_CALL DefaultGridColumnModel::supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - return ServiceName.equalsAscii( szServiceName_DefaultGridColumnModel ); -} + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridColumnModel::removeContainerListener( const Reference< XContainerListener >& i_listener ) throw (RuntimeException) + { + if ( i_listener.is() ) + m_aContainerListeners.removeInterface( i_listener ); + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridColumnModel::disposing() + { + DefaultGridColumnModel_Base::disposing(); + + EventObject aEvent( *this ); + m_aContainerListeners.disposeAndClear( aEvent ); + + ::osl::MutexGuard aGuard( m_aMutex ); + + // remove, dispose and clear columns + while ( !m_aColumns.empty() ) + { + try + { + const Reference< XComponent > xColComponent( m_aColumns[ 0 ], UNO_QUERY_THROW ); + xColComponent->dispose(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + m_aColumns.erase( m_aColumns.begin() ); + } + + Columns aEmpty; + m_aColumns.swap( aEmpty ); + } -::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL DefaultGridColumnModel::getSupportedServiceNames( ) throw (RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - static const OUString aServiceName( OUString::createFromAscii( szServiceName_DefaultGridColumnModel ) ); - static const Sequence< OUString > aSeq( &aServiceName, 1 ); - return aSeq; -} + //------------------------------------------------------------------------------------------------------------------ + Reference< XCloneable > SAL_CALL DefaultGridColumnModel::createClone( ) throw (RuntimeException) + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); + return new DefaultGridColumnModel( *this ); + } -} +//...................................................................................................................... +} // namespace toolkit +//...................................................................................................................... -Reference< XInterface > SAL_CALL DefaultGridColumnModel_CreateInstance( const Reference< XMultiServiceFactory >& _rFactory) +//---------------------------------------------------------------------------------------------------------------------- +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL DefaultGridColumnModel_CreateInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rFactory) { - return Reference < XInterface >( ( ::cppu::OWeakObject* ) new ::toolkit::DefaultGridColumnModel( _rFactory ) ); + return ::com::sun::star::uno::Reference < ::com::sun::star::uno::XInterface >( ( ::cppu::OWeakObject* ) new ::toolkit::DefaultGridColumnModel( _rFactory ) ); } - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx index 7f01b625e62c..1cdc1ab30c0d 100644 --- a/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx +++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx @@ -26,75 +26,73 @@ * ************************************************************************/ -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_toolkit.hxx" +/** === begin UNO includes === **/ #include <com/sun/star/awt/grid/XGridColumnModel.hpp> #include <com/sun/star/awt/grid/XGridColumn.hpp> #include <com/sun/star/lang/XEventListener.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp> -#include <cppuhelper/implbase2.hxx> -#include <cppuhelper/implbase3.hxx> -#include <rtl/ref.hxx> -#include <vector> -#include <toolkit/helper/mutexandbroadcasthelper.hxx> -#include <com/sun/star/util/Color.hpp> #include <com/sun/star/style/VerticalAlignment.hpp> -#include <com/sun/star/awt/grid/XGridColumnListener.hpp> +#include <com/sun/star/util/Color.hpp> +/** === end UNO includes === **/ -using ::rtl::OUString; -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::awt; -using namespace ::com::sun::star::awt::grid; -using namespace ::com::sun::star::lang; +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/compbase2.hxx> +#include <comphelper/componentcontext.hxx> +#include <vector> + +namespace comphelper +{ + class ComponentGuard; +} namespace toolkit { //enum broadcast_type { column_added, column_removed, column_changed}; -class DefaultGridColumnModel : public ::cppu::WeakImplHelper2< XGridColumnModel, XServiceInfo >, - public MutexAndBroadcastHelper +typedef ::cppu::WeakComponentImplHelper2 < ::com::sun::star::awt::grid::XGridColumnModel + , ::com::sun::star::lang::XServiceInfo + > DefaultGridColumnModel_Base; + +class DefaultGridColumnModel :public ::cppu::BaseMutex + ,public DefaultGridColumnModel_Base { public: - DefaultGridColumnModel(const Reference< XMultiServiceFactory >& xFactory); + DefaultGridColumnModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory ); + DefaultGridColumnModel( DefaultGridColumnModel const & i_copySource ); virtual ~DefaultGridColumnModel(); // XGridColumnModel - - //virtual ::sal_Bool SAL_CALL getColumnSelectionAllowed() throw (::com::sun::star::uno::RuntimeException); - //virtual void SAL_CALL setColumnSelectionAllowed(::sal_Bool the_value) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getColumnCount() throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL addColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & column) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > SAL_CALL createColumn( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL addColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & column) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException); + virtual void SAL_CALL removeColumn( ::sal_Int32 i_columnIndex ) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IndexOutOfBoundsException); virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > > SAL_CALL getColumns() throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > SAL_CALL getColumn(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException); - //virtual void SAL_CALL addColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException); - //virtual void SAL_CALL removeColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException); - virtual void SAL_CALL setColumnHeaderHeight( sal_Int32 _value) throw (com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getColumnHeaderHeight() throw (com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > SAL_CALL getColumn(::sal_Int32 index) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setDefaultColumns(sal_Int32 rowElements) throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > SAL_CALL copyColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & column) throw (::com::sun::star::uno::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); // 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); -private: - /*void broadcast( broadcast_type eType, const GridColumnEvent& aEvent ); - void broadcast_changed( ::rtl::OUString name, Any oldValue, Any newValue, sal_Int32 index,const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & rColumn ); - void broadcast_add( sal_Int32 index,const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & rColumn ); - void broadcast_remove( sal_Int32 index, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & rColumn );*/ + // XContainer + virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + + // XCloneable + virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException); + + // OComponentHelper + virtual void SAL_CALL disposing(); + +private: + typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > > Columns; - std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > > columns; - sal_Bool selectionAllowed; - sal_Int32 m_nColumnHeaderHeight; - Reference< XMultiServiceFactory > m_xFactory; + ::comphelper::ComponentContext m_aContext; + ::cppu::OInterfaceContainerHelper m_aContainerListeners; + Columns m_aColumns; }; } diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.cxx b/toolkit/source/controls/grid/defaultgriddatamodel.cxx index 1a4e9b36ab45..aae6d61a4692 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.cxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.cxx @@ -28,318 +28,411 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_toolkit.hxx" + #include "defaultgriddatamodel.hxx" -#include <comphelper/sequence.hxx> + +#include <comphelper/stlunosequence.hxx> +#include <comphelper/componentguard.hxx> #include <toolkit/helper/servicenames.hxx> +#include <tools/diagnose_ex.h> #include <rtl/ref.hxx> -using ::rtl::OUString; -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::awt; -using namespace ::com::sun::star::awt::grid; -using namespace ::com::sun::star::lang; - -#define ROWHEIGHT ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "RowHeight" )) -#define ROWHEADERS ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "RowHeaders" )) -#define CELLUPDATED ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "CellUpdated" )) -#define ROWUPDATED ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "RowUpdated" )) -#define ROWHEADERWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "RowHeaderWidth" )) +#include <algorithm> +//...................................................................................................................... namespace toolkit +//...................................................................................................................... { + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::lang::XComponent; + using ::com::sun::star::lang::EventObject; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::util::XCloneable; + /** === end UNO using === **/ + + using ::comphelper::stl_begin; + using ::comphelper::stl_end; + + //================================================================================================================== + //= DefaultGridDataModel + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + DefaultGridDataModel::DefaultGridDataModel() + :DefaultGridDataModel_Base( m_aMutex ) + ,m_aRowHeaders() + ,m_nColumnCount(0) + { + } -/////////////////////////////////////////////////////////////////////// -// class DefaultGridDataModel -/////////////////////////////////////////////////////////////////////// + //------------------------------------------------------------------------------------------------------------------ + DefaultGridDataModel::DefaultGridDataModel( DefaultGridDataModel const & i_copySource ) + :cppu::BaseMutex() + ,DefaultGridDataModel_Base( m_aMutex ) + ,m_aData( i_copySource.m_aData ) + ,m_aRowHeaders( i_copySource.m_aRowHeaders ) + ,m_nColumnCount( i_copySource.m_nColumnCount ) + { + } -DefaultGridDataModel::DefaultGridDataModel() -: rowHeight(0), - rowHeaders(std::vector< ::rtl::OUString >()), - m_nRowHeaderWidth(10) -{ -} + //------------------------------------------------------------------------------------------------------------------ + DefaultGridDataModel::~DefaultGridDataModel() + { + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void DefaultGridDataModel::broadcast( GridDataEvent const & i_event, + void ( SAL_CALL XGridDataListener::*i_listenerMethod )( GridDataEvent const & ), ::comphelper::ComponentGuard & i_instanceLock ) + { + ::cppu::OInterfaceContainerHelper* pListeners = rBHelper.getContainer( XGridDataListener::static_type() ); + if ( !pListeners ) + return; -DefaultGridDataModel::~DefaultGridDataModel() -{ -} + i_instanceLock.clear(); + pListeners->notifyEach( i_listenerMethod, i_event ); + } -void DefaultGridDataModel::broadcast( broadcast_type eType, const GridDataEvent& aEvent ) throw (::com::sun::star::uno::RuntimeException) -{ - ::cppu::OInterfaceContainerHelper* pIter = BrdcstHelper.getContainer( XGridDataListener::static_type() ); - if( pIter ) + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL DefaultGridDataModel::getRowCount() throw (::com::sun::star::uno::RuntimeException) { - ::cppu::OInterfaceIteratorHelper aListIter(*pIter); - while(aListIter.hasMoreElements()) - { - XGridDataListener* pListener = static_cast<XGridDataListener*>(aListIter.next()); - switch( eType ) - { - case row_added: pListener->rowAdded(aEvent); break; - case row_removed: pListener->rowRemoved(aEvent); break; - case data_changed: pListener->dataChanged(aEvent); break; - } - } + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); + return m_aData.size(); } -} -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL DefaultGridDataModel::getColumnCount() throw (::com::sun::star::uno::RuntimeException) + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); + return m_nColumnCount; + } -void DefaultGridDataModel::broadcast_changed( ::rtl::OUString name, sal_Int32 index, Any oldValue, Any newValue) throw (::com::sun::star::uno::RuntimeException) -{ - Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - GridDataEvent aEvent( xSource, name, oldValue, newValue, index, ::rtl::OUString(), Sequence< Any >()); - broadcast( data_changed, aEvent); -} + //------------------------------------------------------------------------------------------------------------------ + DefaultGridDataModel::CellData const & DefaultGridDataModel::impl_getCellData_throw( sal_Int32 const i_column, sal_Int32 const i_row ) const + { + if ( ( i_row < 0 ) || ( size_t( i_row ) > m_aData.size() ) + || ( i_column < 0 ) || ( i_column > m_nColumnCount ) + ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *const_cast< DefaultGridDataModel* >( this ) ); -//--------------------------------------------------------------------- + RowData const & rRow( m_aData[ i_row ] ); + if ( size_t( i_column ) < rRow.size() ) + return rRow[ i_column ]; -void DefaultGridDataModel::broadcast_add( sal_Int32 index, const ::rtl::OUString & headerName, - ::com::sun::star::uno::Sequence< Any > rowData ) throw (::com::sun::star::uno::RuntimeException) -{ - Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - GridDataEvent aEvent( xSource, ::rtl::OUString(), Any(), Any(), index, headerName, (const ::com::sun::star::uno::Sequence< Any >&)rowData ); - broadcast( row_added, aEvent); -} + static CellData s_aEmpty; + return s_aEmpty; + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + DefaultGridDataModel::RowData& DefaultGridDataModel::impl_getRowDataAccess_throw( sal_Int32 const i_rowIndex, size_t const i_requiredColumnCount ) + { + OSL_ENSURE( i_requiredColumnCount <= size_t( m_nColumnCount ), "DefaultGridDataModel::impl_getRowDataAccess_throw: invalid column count!" ); + if ( ( i_rowIndex < 0 ) || ( size_t( i_rowIndex ) >= m_aData.size() ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); + + RowData& rRowData( m_aData[ i_rowIndex ] ); + if ( rRowData.size() < i_requiredColumnCount ) + rRowData.resize( i_requiredColumnCount ); + return rRowData; + } -void DefaultGridDataModel::broadcast_remove( sal_Int32 index, const ::rtl::OUString & headerName, - ::com::sun::star::uno::Sequence< Any > rowData ) throw (::com::sun::star::uno::RuntimeException) -{ - Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - GridDataEvent aEvent( xSource, ::rtl::OUString(), Any(), Any(), index, headerName, rowData ); - broadcast( row_removed, aEvent); -} + //------------------------------------------------------------------------------------------------------------------ + DefaultGridDataModel::CellData& DefaultGridDataModel::impl_getCellDataAccess_throw( sal_Int32 const i_columnIndex, sal_Int32 const i_rowIndex ) + { + if ( ( i_columnIndex < 0 ) || ( i_columnIndex >= m_nColumnCount ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); -//--------------------------------------------------------------------- + RowData& rRowData( impl_getRowDataAccess_throw( i_rowIndex, size_t( i_columnIndex + 1 ) ) ); + return rRowData[ i_columnIndex ]; + } -//--------------------------------------------------------------------- -// XDefaultGridDataModel -//--------------------------------------------------------------------- -::sal_Int32 SAL_CALL DefaultGridDataModel::getRowHeight() throw (::com::sun::star::uno::RuntimeException) -{ - return rowHeight; -} + //------------------------------------------------------------------------------------------------------------------ + Any SAL_CALL DefaultGridDataModel::getCellData( ::sal_Int32 i_column, ::sal_Int32 i_row ) throw (RuntimeException, IndexOutOfBoundsException) + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); + return impl_getCellData_throw( i_column, i_row ).first; + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + Any SAL_CALL DefaultGridDataModel::getCellToolTip( ::sal_Int32 i_column, ::sal_Int32 i_row ) throw (RuntimeException, IndexOutOfBoundsException) + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); + return impl_getCellData_throw( i_column, i_row ).second; + } -void SAL_CALL DefaultGridDataModel::setRowHeight(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) -{ - sal_Int32 oldValue = rowHeight; - rowHeight = value; + //------------------------------------------------------------------------------------------------------------------ + Any SAL_CALL DefaultGridDataModel::getRowHeading( ::sal_Int32 i_row ) throw (RuntimeException, IndexOutOfBoundsException) + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); - broadcast_changed( ROWHEIGHT, 0, Any(oldValue), Any(value)); -} + if ( ( i_row < 0 ) || ( size_t( i_row ) >= m_aRowHeaders.size() ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); -//--------------------------------------------------------------------- + return m_aRowHeaders[ i_row ]; + } -::sal_Int32 SAL_CALL DefaultGridDataModel::getRowCount() throw (::com::sun::star::uno::RuntimeException) -{ - return data.size(); -} + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridDataModel::addRow( const Any& i_heading, const Sequence< Any >& i_data ) throw (RuntimeException) + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); -//--------------------------------------------------------------------- + sal_Int32 const columnCount = i_data.getLength(); -::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL DefaultGridDataModel::getRowHeaders() throw (::com::sun::star::uno::RuntimeException) -{ - return comphelper::containerToSequence(rowHeaders); -} + // store header name + m_aRowHeaders.push_back( i_heading ); -//--------------------------------------------------------------------- + // store row m_aData + impl_addRow( i_data ); -void SAL_CALL DefaultGridDataModel::setRowHeaders(const ::com::sun::star::uno::Sequence< ::rtl::OUString > & value) throw (::com::sun::star::uno::RuntimeException) -{ - ::com::sun::star::uno::Sequence< ::rtl::OUString > oldValue( comphelper::containerToSequence(rowHeaders) ); + // update column count + if ( columnCount > m_nColumnCount ) + m_nColumnCount = columnCount; - std::vector< rtl::OUString>::iterator iterator; - int i = 0; - int sequenceSize = value.getLength(); + sal_Int32 const rowIndex = sal_Int32( m_aData.size() - 1 ); + broadcast( + GridDataEvent( *this, -1, -1, rowIndex, rowIndex ), + &XGridDataListener::rowsInserted, + aGuard + ); + } - for(iterator = rowHeaders.begin(); iterator != rowHeaders.end(); ++iterator) + //------------------------------------------------------------------------------------------------------------------ + void DefaultGridDataModel::impl_addRow( Sequence< Any > const & i_rowData, sal_Int32 const i_assumedColCount ) { - if ( sequenceSize > i ) - *iterator = value[i]; - else - *iterator = ::rtl::OUString(); - i++; + OSL_PRECOND( ( i_assumedColCount <= 0 ) || ( i_assumedColCount >= i_rowData.getLength() ), + "DefaultGridDataModel::impl_addRow: invalid column count!" ); + + RowData newRow( i_assumedColCount > 0 ? i_assumedColCount : i_rowData.getLength() ); + RowData::iterator cellData = newRow.begin(); + for ( const Any* pData = stl_begin( i_rowData ); pData != stl_end( i_rowData ); ++pData, ++cellData ) + cellData->first = *pData; + + m_aData.push_back( newRow ); } - broadcast_changed( ROWHEADERS, 0, Any(oldValue), Any(comphelper::containerToSequence(rowHeaders)) ); -} + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridDataModel::addRows( const Sequence< Any >& i_headings, const Sequence< Sequence< Any > >& i_data ) throw (IllegalArgumentException, RuntimeException) + { + if ( i_headings.getLength() != i_data.getLength() ) + throw IllegalArgumentException( ::rtl::OUString(), *this, -1 ); -//--------------------------------------------------------------------- + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); -void SAL_CALL DefaultGridDataModel::addRow(const ::rtl::OUString & headername, const ::com::sun::star::uno::Sequence< Any > & rRowdata) throw (::com::sun::star::uno::RuntimeException) -{ - // store header name - rowHeaders.push_back(headername); + sal_Int32 const rowCount = i_headings.getLength(); + if ( rowCount == 0 ) + return; - // store row data - std::vector< Any > newRow; - for ( int i = 0; i < rRowdata.getLength();i++) - { - newRow.push_back(rRowdata[i]); - } + // determine max col count in the new data + sal_Int32 maxColCount = 0; + for ( sal_Int32 row=0; row<rowCount; ++row ) + if ( i_data[row].getLength() > maxColCount ) + maxColCount = i_data[row].getLength(); - data.push_back( newRow ); + if ( maxColCount < m_nColumnCount ) + maxColCount = m_nColumnCount; - broadcast_add( data.size()-1, headername, comphelper::containerToSequence(newRow)); + for ( sal_Int32 row=0; row<rowCount; ++row ) + { + m_aRowHeaders.push_back( i_headings[row] ); + impl_addRow( i_data[row], maxColCount ); + } -} + if ( maxColCount > m_nColumnCount ) + m_nColumnCount = maxColCount; -//--------------------------------------------------------------------- + sal_Int32 const firstRow = sal_Int32( m_aData.size() - rowCount ); + sal_Int32 const lastRow = sal_Int32( m_aData.size() - 1 ); + broadcast( + GridDataEvent( *this, -1, -1, firstRow, lastRow ), + &XGridDataListener::rowsInserted, + aGuard + ); + } -void SAL_CALL DefaultGridDataModel::removeRow(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException) -{ - if ( index >= 0 && index <= getRowCount()-1) + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridDataModel::removeRow( ::sal_Int32 i_rowIndex ) throw (IndexOutOfBoundsException, RuntimeException) { - ::rtl::OUString headerName( (::rtl::OUString) rowHeaders[index] ); - rowHeaders.erase(rowHeaders.begin() + index); + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); - Sequence< Any >& rowData ( (Sequence< Any >&)data[index] ); - data.erase(data.begin() + index); - broadcast_remove( index, headerName, rowData); + if ( ( i_rowIndex < 0 ) || ( size_t( i_rowIndex ) >= m_aData.size() ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); + + m_aRowHeaders.erase( m_aRowHeaders.begin() + i_rowIndex ); + m_aData.erase( m_aData.begin() + i_rowIndex ); + + broadcast( + GridDataEvent( *this, -1, -1, i_rowIndex, i_rowIndex ), + &XGridDataListener::rowsRemoved, + aGuard + ); } - else - return; -} -//--------------------------------------------------------------------- -::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< Any > > SAL_CALL DefaultGridDataModel::getData() throw (::com::sun::star::uno::RuntimeException) -{ - std::vector< std::vector< Any > >::iterator iterator; - std::vector< Sequence< Any > > dummyContainer(0); + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridDataModel::removeAllRows( ) throw (RuntimeException) + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); + + m_aRowHeaders.clear(); + m_aData.clear(); + broadcast( + GridDataEvent( *this, -1, -1, -1, -1 ), + &XGridDataListener::rowsRemoved, + aGuard + ); + } - for(iterator = data.begin(); iterator != data.end(); ++iterator) + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridDataModel::updateCellData( ::sal_Int32 i_columnIndex, ::sal_Int32 i_rowIndex, const Any& i_value ) throw (IndexOutOfBoundsException, RuntimeException) { - Sequence< Any > cols(comphelper::containerToSequence(*iterator)); - dummyContainer.push_back( cols ); + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); + + impl_getCellDataAccess_throw( i_columnIndex, i_rowIndex ).first = i_value; + + broadcast( + GridDataEvent( *this, i_columnIndex, i_columnIndex, i_rowIndex, i_rowIndex ), + &XGridDataListener::dataChanged, + aGuard + ); } - Sequence< Sequence< Any > > dataSequence(comphelper::containerToSequence(dummyContainer)); - return dataSequence; -} + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridDataModel::updateRowData( const Sequence< ::sal_Int32 >& i_columnIndexes, ::sal_Int32 i_rowIndex, const Sequence< Any >& i_values ) throw (IndexOutOfBoundsException, IllegalArgumentException, RuntimeException) + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); -//--------------------------------------------------------------------- + if ( ( i_rowIndex < 0 ) || ( size_t( i_rowIndex ) >= m_aData.size() ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); -void SAL_CALL DefaultGridDataModel::addDataListener( const Reference< XGridDataListener >& xListener ) throw (RuntimeException) -{ - BrdcstHelper.addListener( XGridDataListener::static_type(), xListener ); -} + if ( i_columnIndexes.getLength() != i_values.getLength() ) + throw IllegalArgumentException( ::rtl::OUString(), *this, 1 ); -//--------------------------------------------------------------------- + sal_Int32 const columnCount = i_columnIndexes.getLength(); + if ( columnCount == 0 ) + return; -void SAL_CALL DefaultGridDataModel::removeDataListener( const Reference< XGridDataListener >& xListener ) throw (RuntimeException) -{ - BrdcstHelper.removeListener( XGridDataListener::static_type(), xListener ); -} -//--------------------------------------------------------------------- -void SAL_CALL DefaultGridDataModel::removeAll() throw (RuntimeException) -{ - rowHeaders.clear(); - data.clear(); - broadcast_remove( -1, ::rtl::OUString(), 0); -} -//--------------------------------------------------------------------- -void SAL_CALL DefaultGridDataModel::setRowHeaderWidth(sal_Int32 _value) throw (::com::sun::star::uno::RuntimeException) -{ - sal_Int32 oldValue = m_nRowHeaderWidth; - m_nRowHeaderWidth = _value; - broadcast_changed( ROWHEADERWIDTH, 0, Any(oldValue), Any(_value) ); -} -//--------------------------------------------------------------------- -sal_Int32 SAL_CALL DefaultGridDataModel::getRowHeaderWidth() throw (::com::sun::star::uno::RuntimeException) -{ - return m_nRowHeaderWidth; -} -//--------------------------------------------------------------------- -void SAL_CALL DefaultGridDataModel::updateCell(::sal_Int32 row, ::sal_Int32 column, const Any& value) throw (::com::sun::star::uno::RuntimeException) -{ - if(row >= 0 && row < (signed)data.size()) - { - if(column >= 0 && column < (signed)data[0].size()) + for ( sal_Int32 col = 0; col < columnCount; ++col ) { - data[row][column] = value; - Sequence< Any >dataSeq(comphelper::containerToSequence(data[row])); - broadcast_changed( CELLUPDATED, row, Any(column), value ); + if ( ( i_columnIndexes[col] < 0 ) || ( i_columnIndexes[col] > m_nColumnCount ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); } - } -} -//--------------------------------------------------------------------- -void SAL_CALL DefaultGridDataModel::updateRow(::sal_Int32 row, const ::com::sun::star::uno::Sequence< ::sal_Int32 > & columns, const ::com::sun::star::uno::Sequence< Any > & values) throw (::com::sun::star::uno::RuntimeException) -{ - if(row >= 0 && row < (signed)data.size()) - { - if(columns.getLength() == values.getLength()) + + RowData& rDataRow = m_aData[ i_rowIndex ]; + for ( sal_Int32 col = 0; col < columnCount; ++col ) { - for(int i = 0; i < columns.getLength(); i++) - data[row][i] = values[i]; - Sequence< Any >dataSeq(comphelper::containerToSequence(data[row])); - broadcast_changed( ROWUPDATED, row, Any(columns), Any(values) ); + sal_Int32 const columnIndex = i_columnIndexes[ col ]; + if ( size_t( columnIndex ) >= rDataRow.size() ) + rDataRow.resize( columnIndex + 1 ); + + rDataRow[ columnIndex ].first = i_values[ col ]; } + + sal_Int32 const firstAffectedColumn = *::std::min_element( stl_begin( i_columnIndexes ), stl_end( i_columnIndexes ) ); + sal_Int32 const lastAffectedColumn = *::std::max_element( stl_begin( i_columnIndexes ), stl_end( i_columnIndexes ) ); + broadcast( + GridDataEvent( *this, firstAffectedColumn, lastAffectedColumn, i_rowIndex, i_rowIndex ), + &XGridDataListener::dataChanged, + aGuard + ); } -} -//--------------------------------------------------------------------- -// XComponent -//--------------------------------------------------------------------- -void SAL_CALL DefaultGridDataModel::dispose() throw (RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridDataModel::updateRowHeading( ::sal_Int32 i_rowIndex, const Any& i_heading ) throw (IndexOutOfBoundsException, RuntimeException) + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); - ::com::sun::star::lang::EventObject aEvent; - aEvent.Source.set( static_cast< ::cppu::OWeakObject* >( this ) ); - BrdcstHelper.aLC.disposeAndClear( aEvent ); + if ( ( i_rowIndex < 0 ) || ( size_t( i_rowIndex ) >= m_aRowHeaders.size() ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); -} + m_aRowHeaders[ i_rowIndex ] = i_heading; -//--------------------------------------------------------------------- + broadcast( + GridDataEvent( *this, -1, -1, i_rowIndex, i_rowIndex ), + &XGridDataListener::rowHeadingChanged, + aGuard + ); + } -void SAL_CALL DefaultGridDataModel::addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException) -{ - BrdcstHelper.addListener( XEventListener::static_type(), xListener ); -} + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridDataModel::updateCellToolTip( ::sal_Int32 i_columnIndex, ::sal_Int32 i_rowIndex, const Any& i_value ) throw (IndexOutOfBoundsException, RuntimeException) + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); + impl_getCellDataAccess_throw( i_columnIndex, i_rowIndex ).second = i_value; + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridDataModel::updateRowToolTip( ::sal_Int32 i_rowIndex, const Any& i_value ) throw (IndexOutOfBoundsException, RuntimeException) + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); -void SAL_CALL DefaultGridDataModel::removeEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException) -{ - BrdcstHelper.removeListener( XEventListener::static_type(), xListener ); -} -//--------------------------------------------------------------------- -// XServiceInfo -//--------------------------------------------------------------------- + RowData& rRowData = impl_getRowDataAccess_throw( i_rowIndex, m_nColumnCount ); + for ( RowData::iterator cell = rRowData.begin(); cell != rRowData.end(); ++cell ) + cell->second = i_value; + } -::rtl::OUString SAL_CALL DefaultGridDataModel::getImplementationName( ) throw (RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - static const OUString aImplName( RTL_CONSTASCII_USTRINGPARAM( "toolkit.DefaultGridDataModel" ) ); - return aImplName; -} + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridDataModel::addGridDataListener( const Reference< grid::XGridDataListener >& i_listener ) throw (RuntimeException) + { + rBHelper.addListener( XGridDataListener::static_type(), i_listener ); + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridDataModel::removeGridDataListener( const Reference< grid::XGridDataListener >& i_listener ) throw (RuntimeException) + { + rBHelper.removeListener( XGridDataListener::static_type(), i_listener ); + } -sal_Bool SAL_CALL DefaultGridDataModel::supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - return ServiceName.equalsAscii( szServiceName_DefaultGridDataModel ); -} + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridDataModel::disposing() + { + ::com::sun::star::lang::EventObject aEvent; + aEvent.Source.set( *this ); + rBHelper.aLC.disposeAndClear( aEvent ); -//--------------------------------------------------------------------- + ::osl::MutexGuard aGuard( m_aMutex ); + GridData aEmptyData; + m_aData.swap( aEmptyData ); -::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL DefaultGridDataModel::getSupportedServiceNames( ) throw (RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - static const OUString aServiceName( OUString::createFromAscii( szServiceName_DefaultGridDataModel ) ); - static const Sequence< OUString > aSeq( &aServiceName, 1 ); - return aSeq; -} + ::std::vector< Any > aEmptyRowHeaders; + m_aRowHeaders.swap( aEmptyRowHeaders ); -} + m_nColumnCount = 0; + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL DefaultGridDataModel::getImplementationName( ) throw (RuntimeException) + { + static const ::rtl::OUString aImplName( RTL_CONSTASCII_USTRINGPARAM( "toolkit.DefaultGridDataModel" ) ); + return aImplName; + } + + //------------------------------------------------------------------------------------------------------------------ + sal_Bool SAL_CALL DefaultGridDataModel::supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException) + { + return ServiceName.equalsAscii( szServiceName_DefaultGridDataModel ); + } + + //------------------------------------------------------------------------------------------------------------------ + Sequence< ::rtl::OUString > SAL_CALL DefaultGridDataModel::getSupportedServiceNames( ) throw (RuntimeException) + { + static const ::rtl::OUString aServiceName( ::rtl::OUString::createFromAscii( szServiceName_DefaultGridDataModel ) ); + static const Sequence< ::rtl::OUString > aSeq( &aServiceName, 1 ); + return aSeq; + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XCloneable > SAL_CALL DefaultGridDataModel::createClone( ) throw (RuntimeException) + { + return new DefaultGridDataModel( *this ); + } + +//...................................................................................................................... +} // namespace toolkit +//...................................................................................................................... Reference< XInterface > SAL_CALL DefaultGridDataModel_CreateInstance( const Reference< XMultiServiceFactory >& ) { diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.hxx b/toolkit/source/controls/grid/defaultgriddatamodel.hxx index ac6282a0eaef..b7fcf01c4f5b 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.hxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.hxx @@ -26,60 +26,68 @@ * ************************************************************************/ -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_toolkit.hxx" -#include <com/sun/star/awt/grid/XGridDataModel.hpp> -#include <com/sun/star/awt/grid/GridDataEvent.hpp> -#include <com/sun/star/awt/grid/XGridDataListener.hpp> -#include <com/sun/star/awt/XControl.hpp> -#include <com/sun/star/lang/XEventListener.hpp> +#include <com/sun/star/awt/grid/XMutableGridDataModel.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XUnoTunnel.hpp> -#include <cppuhelper/implbase2.hxx> -#include <cppuhelper/implbase3.hxx> -#include <rtl/ref.hxx> -#include <vector> + +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/compbase2.hxx> #include <toolkit/helper/mutexandbroadcasthelper.hxx> -using ::rtl::OUString; +#include <vector> + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::awt; using namespace ::com::sun::star::awt::grid; using namespace ::com::sun::star::lang; +namespace comphelper +{ + class ComponentGuard; +} + namespace toolkit { enum broadcast_type { row_added, row_removed, data_changed}; -class DefaultGridDataModel : public ::cppu::WeakImplHelper2< XGridDataModel, XServiceInfo >, - public MutexAndBroadcastHelper +typedef ::cppu::WeakComponentImplHelper2 < XMutableGridDataModel + , XServiceInfo + > DefaultGridDataModel_Base; + +class DefaultGridDataModel :public ::cppu::BaseMutex + ,public DefaultGridDataModel_Base { public: DefaultGridDataModel(); + DefaultGridDataModel( DefaultGridDataModel const & i_copySource ); virtual ~DefaultGridDataModel(); + // XMutableGridDataModel + virtual void SAL_CALL addRow( const Any& i_heading, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Data ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addRows( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any>& Headings, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& Data ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeRow( ::sal_Int32 RowIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeAllRows( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateCellData( ::sal_Int32 ColumnIndex, ::sal_Int32 RowIndex, const ::com::sun::star::uno::Any& Value ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateRowData( const ::com::sun::star::uno::Sequence< ::sal_Int32 >& ColumnIndexes, ::sal_Int32 RowIndex, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Values ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateRowHeading( ::sal_Int32 RowIndex, const ::com::sun::star::uno::Any& Heading ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateCellToolTip( ::sal_Int32 ColumnIndex, ::sal_Int32 RowIndex, const ::com::sun::star::uno::Any& Value ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateRowToolTip( ::sal_Int32 RowIndex, const ::com::sun::star::uno::Any& Value ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addGridDataListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeGridDataListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); + // XGridDataModel - virtual ::sal_Int32 SAL_CALL getRowHeight() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setRowHeight(::sal_Int32 the_value) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getRowCount() throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getRowHeaders() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setRowHeaders(const ::com::sun::star::uno::Sequence< ::rtl::OUString > & value) throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< Any > > SAL_CALL getData() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addRow(const ::rtl::OUString & headername, const ::com::sun::star::uno::Sequence< Any > & data) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeRow(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addDataListener( const Reference< XGridDataListener >& xListener ) throw (RuntimeException); - virtual void SAL_CALL removeDataListener( const Reference< XGridDataListener >& xListener ) throw (RuntimeException); - virtual void SAL_CALL removeAll() throw (RuntimeException); - virtual void SAL_CALL setRowHeaderWidth(sal_Int32 _value) throw (::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getRowHeaderWidth() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL updateCell( ::sal_Int32 row, ::sal_Int32 column, const ::com::sun::star::uno::Any& value ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL updateRow( ::sal_Int32 row, const ::com::sun::star::uno::Sequence< ::sal_Int32 >& columns, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& values ) throw (::com::sun::star::uno::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); + virtual ::sal_Int32 SAL_CALL getColumnCount() throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getCellData( ::sal_Int32 Column, ::sal_Int32 Row ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getCellToolTip( ::sal_Int32 Column, ::sal_Int32 Row ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getRowHeading( ::sal_Int32 RowIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + + // OComponentHelper + virtual void SAL_CALL disposing(); + + // XCloneable + virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException); // XServiceInfo virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (RuntimeException); @@ -87,16 +95,25 @@ public: virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException); private: + typedef ::std::pair< Any, Any > CellData; + typedef ::std::vector< CellData > RowData; + typedef ::std::vector< RowData > GridData; + + void broadcast( + GridDataEvent const & i_event, + void ( SAL_CALL ::com::sun::star::awt::grid::XGridDataListener::*i_listenerMethod )( ::com::sun::star::awt::grid::GridDataEvent const & ), + ::comphelper::ComponentGuard & i_instanceLock + ); + + void impl_addRow( Sequence< Any > const & i_rowData, sal_Int32 const i_assumedColCount = -1 ); - void broadcast( broadcast_type eType, const GridDataEvent& aEvent ) throw (::com::sun::star::uno::RuntimeException); - void broadcast_changed( ::rtl::OUString name, sal_Int32 index, Any oldValue, Any newValue ) throw (::com::sun::star::uno::RuntimeException); - void broadcast_add( sal_Int32 index, const ::rtl::OUString & headerName, const ::com::sun::star::uno::Sequence< Any > rowData ) throw (::com::sun::star::uno::RuntimeException); - void broadcast_remove( sal_Int32 index, const ::rtl::OUString & headerName, const ::com::sun::star::uno::Sequence< Any > rowData ) throw (::com::sun::star::uno::RuntimeException); + CellData const & impl_getCellData_throw( sal_Int32 const i_columnIndex, sal_Int32 const i_rowIndex ) const; + CellData& impl_getCellDataAccess_throw( sal_Int32 const i_columnIndex, sal_Int32 const i_rowIndex ); + RowData& impl_getRowDataAccess_throw( sal_Int32 const i_rowIndex, size_t const i_requiredColumnCount ); - sal_Int32 rowHeight; - std::vector< std::vector < Any > > data; - std::vector< ::rtl::OUString > rowHeaders; - sal_Int32 m_nRowHeaderWidth; + GridData m_aData; + ::std::vector< ::com::sun::star::uno::Any > m_aRowHeaders; + sal_Int32 m_nColumnCount; }; } diff --git a/toolkit/source/controls/grid/gridcolumn.cxx b/toolkit/source/controls/grid/gridcolumn.cxx index 8c1645e2f6ae..0e7253509e7a 100644 --- a/toolkit/source/controls/grid/gridcolumn.cxx +++ b/toolkit/source/controls/grid/gridcolumn.cxx @@ -26,282 +26,306 @@ * ************************************************************************/ -// MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_toolkit.hxx" #include "gridcolumn.hxx" + #include <comphelper/sequence.hxx> +#include <cppuhelper/typeprovider.hxx> #include <toolkit/helper/servicenames.hxx> -#include <rtl/ref.hxx> - -using ::rtl::OUString; -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::awt; -using namespace ::com::sun::star::awt::grid; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::style; - -#define COLWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ColWidth" )) -#define MAXWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "MaxWidth" )) -#define MINWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "MinWidth" )) -#define PREFWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "PrefWidth" )) -#define HALIGN ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "HAlign" )) -#define TITLE ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Title" )) -#define COLRESIZE ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ColumnResize" )) -#define UPDATE ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "UpdateWidth" )) namespace toolkit { - -/////////////////////////////////////////////////////////////////////// -// class GridColumn -/////////////////////////////////////////////////////////////////////// - -GridColumn::GridColumn() -: identifier(Any()) -,index(0) -,columnWidth(4) -,preferredWidth(0) -,maxWidth(0) -,minWidth(0) -,bResizeable(true) -,horizontalAlign(HorizontalAlignment(0)) -{ -} - -//--------------------------------------------------------------------- - -GridColumn::~GridColumn() -{ -} - -//--------------------------------------------------------------------- - -void GridColumn::broadcast( broadcast_column_type eType, const GridColumnEvent& aEvent ) -{ - ::cppu::OInterfaceContainerHelper* pIter = BrdcstHelper.getContainer( XGridColumnListener::static_type() ); - if( pIter ) - { - ::cppu::OInterfaceIteratorHelper aListIter(*pIter); - while(aListIter.hasMoreElements()) - { - XGridColumnListener* pListener = static_cast<XGridColumnListener*>(aListIter.next()); - switch( eType ) - { - case column_attribute_changed: pListener->columnChanged(aEvent); break; - } - } + using namespace ::com::sun::star; + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::awt; + using namespace ::com::sun::star::awt::grid; + using namespace ::com::sun::star::lang; + using namespace ::com::sun::star::util; + using namespace ::com::sun::star::style; + + //================================================================================================================== + //= DefaultGridColumnModel + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + GridColumn::GridColumn() + :GridColumn_Base( m_aMutex ) + ,m_aIdentifier() + ,m_nIndex(-1) + ,m_nDataColumnIndex(-1) + ,m_nColumnWidth(4) + ,m_nMaxWidth(0) + ,m_nMinWidth(0) + ,m_nFlexibility(1) + ,m_bResizeable(true) + ,m_eHorizontalAlign( HorizontalAlignment_LEFT ) + { } -} - -//--------------------------------------------------------------------- - -void GridColumn::broadcast_changed(::rtl::OUString name, Any oldValue, Any newValue) -{ - Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - GridColumnEvent aEvent( xSource, name, oldValue, newValue, index); - broadcast( column_attribute_changed, aEvent); -} - -void SAL_CALL GridColumn::updateColumn(const ::rtl::OUString& name, sal_Int32 width) throw (::com::sun::star::uno::RuntimeException) -{ - if(PREFWIDTH == name) - preferredWidth = width; - else if (COLWIDTH == name) - columnWidth = width; -} -//--------------------------------------------------------------------- -// XGridColumn -//--------------------------------------------------------------------- - -::com::sun::star::uno::Any SAL_CALL GridColumn::getIdentifier() throw (::com::sun::star::uno::RuntimeException) -{ - return identifier; -} -//--------------------------------------------------------------------- - -void SAL_CALL GridColumn::setIdentifier(const ::com::sun::star::uno::Any & value) throw (::com::sun::star::uno::RuntimeException) -{ - value >>= identifier; -} + //------------------------------------------------------------------------------------------------------------------ + GridColumn::GridColumn( GridColumn const & i_copySource ) + :cppu::BaseMutex() + ,GridColumn_Base( m_aMutex ) + ,m_aIdentifier( i_copySource.m_aIdentifier ) + ,m_nIndex( -1 ) + ,m_nDataColumnIndex( i_copySource.m_nDataColumnIndex ) + ,m_nColumnWidth( i_copySource.m_nColumnWidth ) + ,m_nMaxWidth( i_copySource.m_nMaxWidth ) + ,m_nMinWidth( i_copySource.m_nMinWidth ) + ,m_nFlexibility( i_copySource.m_nFlexibility ) + ,m_bResizeable( i_copySource.m_bResizeable ) + ,m_sTitle( i_copySource.m_sTitle ) + ,m_sHelpText( i_copySource.m_sHelpText ) + ,m_eHorizontalAlign( i_copySource.m_eHorizontalAlign ) + { + } -//-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + GridColumn::~GridColumn() + { + } -::sal_Int32 SAL_CALL GridColumn::getColumnWidth() throw (::com::sun::star::uno::RuntimeException) -{ - broadcast_changed(UPDATE, Any(columnWidth), Any()); - return columnWidth; -} + //------------------------------------------------------------------------------------------------------------------ + void GridColumn::broadcast_changed( sal_Char const * const i_asciiAttributeName, Any i_oldValue, Any i_newValue, + ::comphelper::ComponentGuard& i_Guard ) + { + Reference< XInterface > const xSource( static_cast< ::cppu::OWeakObject* >( this ) ); + GridColumnEvent const aEvent( + xSource, ::rtl::OUString::createFromAscii( i_asciiAttributeName ), + i_oldValue, i_newValue, m_nIndex + ); -//-------------------------------------------------------------------- + ::cppu::OInterfaceContainerHelper* pIter = rBHelper.getContainer( XGridColumnListener::static_type() ); -void SAL_CALL GridColumn::setColumnWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) -{ - columnWidth = value; - broadcast_changed(COLWIDTH, Any(columnWidth),Any(value)); -} -//-------------------------------------------------------------------- + i_Guard.clear(); + if( pIter ) + pIter->notifyEach( &XGridColumnListener::columnChanged, aEvent ); + } -::sal_Int32 SAL_CALL GridColumn::getPreferredWidth() throw (::com::sun::star::uno::RuntimeException) -{ - broadcast_changed(UPDATE, Any(preferredWidth), Any()); - return preferredWidth; -} + //------------------------------------------------------------------------------------------------------------------ + ::com::sun::star::uno::Any SAL_CALL GridColumn::getIdentifier() throw (::com::sun::star::uno::RuntimeException) + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); + return m_aIdentifier; + } -//-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::setIdentifier(const ::com::sun::star::uno::Any & value) throw (::com::sun::star::uno::RuntimeException) + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); + m_aIdentifier = value; + } -void SAL_CALL GridColumn::setPreferredWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) -{ - preferredWidth = value; - broadcast_changed(PREFWIDTH, Any(preferredWidth),Any(value)); -} -//-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL GridColumn::getColumnWidth() throw (::com::sun::star::uno::RuntimeException) + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); + return m_nColumnWidth; + } -::sal_Int32 SAL_CALL GridColumn::getMaxWidth() throw (::com::sun::star::uno::RuntimeException) -{ - return maxWidth; -} + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::setColumnWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) + { + impl_set( m_nColumnWidth, value, "ColumnWidth" ); + } -//-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL GridColumn::getMaxWidth() throw (::com::sun::star::uno::RuntimeException) + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); + return m_nMaxWidth; + } -void SAL_CALL GridColumn::setMaxWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) -{ - maxWidth = value; - broadcast_changed(MAXWIDTH, Any(maxWidth),Any(value)); -} -//-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::setMaxWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) + { + impl_set( m_nMaxWidth, value, "MaxWidth" ); + } -::sal_Int32 SAL_CALL GridColumn::getMinWidth() throw (::com::sun::star::uno::RuntimeException) -{ - return minWidth; -} + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL GridColumn::getMinWidth() throw (::com::sun::star::uno::RuntimeException) + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); + return m_nMinWidth; + } -//-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::setMinWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) + { + impl_set( m_nMinWidth, value, "MinWidth" ); + } -void SAL_CALL GridColumn::setMinWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) -{ - minWidth = value; - broadcast_changed(MINWIDTH, Any(minWidth),Any(value)); -} + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL GridColumn::getTitle() throw (::com::sun::star::uno::RuntimeException) + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); + return m_sTitle; + } -//-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::setTitle(const ::rtl::OUString & value) throw (::com::sun::star::uno::RuntimeException) + { + impl_set( m_sTitle, value, "Title" ); + } -::rtl::OUString SAL_CALL GridColumn::getTitle() throw (::com::sun::star::uno::RuntimeException) -{ - return title; -} + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL GridColumn::getHelpText() throw (RuntimeException) + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); + return m_sHelpText; + } -//-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::setHelpText( const ::rtl::OUString & value ) throw (RuntimeException) + { + impl_set( m_sHelpText, value, "HelpText" ); + } -void SAL_CALL GridColumn::setTitle(const ::rtl::OUString & value) throw (::com::sun::star::uno::RuntimeException) -{ - title = value; - broadcast_changed(TITLE, Any(title),Any(value)); -} -//-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + sal_Bool SAL_CALL GridColumn::getResizeable() throw (::com::sun::star::uno::RuntimeException) + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); + return m_bResizeable; + } -sal_Bool SAL_CALL GridColumn::getResizeable() throw (::com::sun::star::uno::RuntimeException) -{ - return bResizeable; -} + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::setResizeable(sal_Bool value) throw (::com::sun::star::uno::RuntimeException) + { + impl_set( m_bResizeable, value, "Resizeable" ); + } -//-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL GridColumn::getFlexibility() throw (RuntimeException) + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); + return m_nFlexibility; + } -void SAL_CALL GridColumn::setResizeable(sal_Bool value) throw (::com::sun::star::uno::RuntimeException) -{ - bResizeable = value; - broadcast_changed(COLRESIZE, Any(bResizeable),Any(value)); -} -//--------------------------------------------------------------------- -HorizontalAlignment SAL_CALL GridColumn::getHorizontalAlign() throw (::com::sun::star::uno::RuntimeException) -{ - return horizontalAlign; -} -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::setFlexibility( ::sal_Int32 i_value ) throw (IllegalArgumentException, RuntimeException) + { + if ( i_value < 0 ) + throw IllegalArgumentException( ::rtl::OUString(), *this, 1 ); + impl_set( m_nFlexibility, i_value, "Flexibility" ); + } -void SAL_CALL GridColumn::setHorizontalAlign(HorizontalAlignment align) throw (::com::sun::star::uno::RuntimeException) -{ - horizontalAlign = align; - broadcast_changed(HALIGN, Any(horizontalAlign),Any(align)); -} -//--------------------------------------------------------------------- -void SAL_CALL GridColumn::addColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException) -{ - BrdcstHelper.addListener( XGridColumnListener::static_type(), xListener ); -} + //------------------------------------------------------------------------------------------------------------------ + HorizontalAlignment SAL_CALL GridColumn::getHorizontalAlign() throw (::com::sun::star::uno::RuntimeException) + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); + return m_eHorizontalAlign; + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::setHorizontalAlign(HorizontalAlignment align) throw (::com::sun::star::uno::RuntimeException) + { + impl_set( m_eHorizontalAlign, align, "HorizontalAlign" ); + } -void SAL_CALL GridColumn::removeColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException) -{ - BrdcstHelper.removeListener( XGridColumnListener::static_type(), xListener ); -} + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::addGridColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException) + { + rBHelper.addListener( XGridColumnListener::static_type(), xListener ); + } -//--------------------------------------------------------------------- -// XComponent -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::removeGridColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException) + { + rBHelper.removeListener( XGridColumnListener::static_type(), xListener ); + } -void SAL_CALL GridColumn::dispose() throw (RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::disposing() + { + ::osl::MutexGuard aGuard( m_aMutex ); + m_aIdentifier.clear(); + m_sTitle = m_sHelpText = ::rtl::OUString(); + } - ::com::sun::star::lang::EventObject aEvent; - aEvent.Source.set( static_cast< ::cppu::OWeakObject* >( this ) ); - BrdcstHelper.aLC.disposeAndClear( aEvent ); -} + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL GridColumn::getIndex() throw (RuntimeException) + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); + return m_nIndex; + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void GridColumn::setIndex( sal_Int32 const i_index ) + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); + m_nIndex = i_index; + } -void SAL_CALL GridColumn::addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException) -{ - BrdcstHelper.addListener( XEventListener::static_type(), xListener ); -} + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL GridColumn::getDataColumnIndex() throw(RuntimeException) + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); + return m_nDataColumnIndex; + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::setDataColumnIndex( ::sal_Int32 i_dataColumnIndex ) throw(RuntimeException) + { + impl_set( m_nDataColumnIndex, i_dataColumnIndex, "DataColumnIndex" ); + } -void SAL_CALL GridColumn::removeEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException) -{ - BrdcstHelper.removeListener( XEventListener::static_type(), xListener ); -} -void SAL_CALL GridColumn::setIndex(sal_Int32 _nIndex) throw (::com::sun::star::uno::RuntimeException) -{ - index = _nIndex; -} -//--------------------------------------------------------------------- -// XServiceInfo -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL GridColumn::getImplementationName( ) throw (RuntimeException) + { + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.toolkit.GridColumn" ) ); + } -::rtl::OUString SAL_CALL GridColumn::getImplementationName( ) throw (RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - static const OUString aImplName( RTL_CONSTASCII_USTRINGPARAM( "toolkit.GridColumn" ) ); - return aImplName; -} + //------------------------------------------------------------------------------------------------------------------ + sal_Bool SAL_CALL GridColumn::supportsService( const ::rtl::OUString& i_serviceName ) throw (RuntimeException) + { + const Sequence< ::rtl::OUString > aServiceNames( getSupportedServiceNames() ); + for ( sal_Int32 i=0; i<aServiceNames.getLength(); ++i ) + if ( aServiceNames[i] == i_serviceName ) + return sal_True; + return sal_False; + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL GridColumn::getSupportedServiceNames( ) throw (RuntimeException) + { + const ::rtl::OUString aServiceName( ::rtl::OUString::createFromAscii( szServiceName_GridColumn ) ); + const Sequence< ::rtl::OUString > aSeq( &aServiceName, 1 ); + return aSeq; + } -sal_Bool SAL_CALL GridColumn::supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - return ServiceName.equalsAscii( szServiceName_GridColumn ); -} + //------------------------------------------------------------------------------------------------------------------ + Reference< XCloneable > SAL_CALL GridColumn::createClone( ) throw (RuntimeException) + { + return new GridColumn( *this ); + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + sal_Int64 SAL_CALL GridColumn::getSomething( const Sequence< sal_Int8 >& i_identifier ) throw(RuntimeException) + { + if ( ( i_identifier.getLength() == 16 ) && ( i_identifier == getUnoTunnelId() ) ) + return ::sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ) ); + return 0; + } -::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL GridColumn::getSupportedServiceNames( ) throw (RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - static const OUString aServiceName( OUString::createFromAscii( szServiceName_GridColumn ) ); - static const Sequence< OUString > aSeq( &aServiceName, 1 ); - return aSeq; -} + //------------------------------------------------------------------------------------------------------------------ + Sequence< sal_Int8 > GridColumn::getUnoTunnelId() throw() + { + static ::cppu::OImplementationId const aId; + return aId.getImplementationId(); + } + //------------------------------------------------------------------------------------------------------------------ + GridColumn* GridColumn::getImplementation( const Reference< XInterface >& i_component ) + { + Reference< XUnoTunnel > const xTunnel( i_component, UNO_QUERY ); + if ( xTunnel.is() ) + return reinterpret_cast< GridColumn* >( ::sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething( getUnoTunnelId() ) ) ); + return NULL; + } } -Reference< XInterface > SAL_CALL GridColumn_CreateInstance( const Reference< XMultiServiceFactory >& ) +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL GridColumn_CreateInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& ) { - return Reference < XInterface >( ( ::cppu::OWeakObject* ) new ::toolkit::GridColumn ); + return *( new ::toolkit::GridColumn ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/controls/grid/gridcolumn.hxx b/toolkit/source/controls/grid/gridcolumn.hxx index 4d582201d128..87fe85afce94 100644 --- a/toolkit/source/controls/grid/gridcolumn.hxx +++ b/toolkit/source/controls/grid/gridcolumn.hxx @@ -26,83 +26,111 @@ * ************************************************************************/ -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_toolkit.hxx" + #include <com/sun/star/awt/grid/XGridColumn.hpp> -#include <com/sun/star/awt/grid/XGridColumnListener.hpp> -#include <com/sun/star/awt/grid/GridColumnEvent.hpp> #include <com/sun/star/lang/XEventListener.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp> -#include <cppuhelper/implbase2.hxx> -#include <cppuhelper/implbase3.hxx> +#include <com/sun/star/style/HorizontalAlignment.hpp> + +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/compbase3.hxx> +#include <comphelper/componentguard.hxx> #include <rtl/ref.hxx> -#include <vector> #include <toolkit/helper/mutexandbroadcasthelper.hxx> -#include <com/sun/star/style/HorizontalAlignment.hpp> -using ::rtl::OUString; -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::awt; -using namespace ::com::sun::star::awt::grid; -using namespace ::com::sun::star::lang; +#include <vector> namespace toolkit { -enum broadcast_column_type { column_attribute_changed}; -class GridColumn : public ::cppu::WeakImplHelper2< XGridColumn, XServiceInfo >, - public MutexAndBroadcastHelper +typedef ::cppu::WeakComponentImplHelper3 < ::com::sun::star::awt::grid::XGridColumn + , ::com::sun::star::lang::XServiceInfo + , ::com::sun::star::lang::XUnoTunnel + > GridColumn_Base; +class GridColumn :public ::cppu::BaseMutex + ,public GridColumn_Base { public: GridColumn(); + GridColumn( GridColumn const & i_copySource ); virtual ~GridColumn(); - // XGridColumn + // ::com::sun::star::awt::grid::XGridColumn virtual ::com::sun::star::uno::Any SAL_CALL getIdentifier() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setIdentifier(const ::com::sun::star::uno::Any & value) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getColumnWidth() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setColumnWidth(::sal_Int32 the_value) throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getPreferredWidth() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPreferredWidth(::sal_Int32 the_value) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getMaxWidth() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setMaxWidth(::sal_Int32 the_value) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getMinWidth() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setMinWidth(::sal_Int32 the_value) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Bool SAL_CALL getResizeable() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setResizeable(::sal_Bool the_value) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getFlexibility() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setFlexibility( ::sal_Int32 _flexibility ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getTitle() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setTitle(const ::rtl::OUString & value) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getHelpText() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setHelpText(const ::rtl::OUString & value) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getIndex() throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getDataColumnIndex() throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDataColumnIndex( ::sal_Int32 i_dataColumnIndex ) throw(::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::style::HorizontalAlignment SAL_CALL getHorizontalAlign() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setHorizontalAlign(::com::sun::star::style::HorizontalAlignment align) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addColumnListener( const Reference< XGridColumnListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeColumnListener( const Reference< XGridColumnListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL updateColumn( const ::rtl::OUString& name, ::sal_Int32 width ) throw (::com::sun::star::uno::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); + virtual void SAL_CALL addGridColumnListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeGridColumnListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + + // OComponentHelper + virtual void SAL_CALL disposing(); + + // XCloneable (base of XGridColumn) + virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException); // XServiceInfo - virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (RuntimeException); - virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException); + 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); + + // XUnoTunnel and friends + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& i_identifier ) throw(::com::sun::star::uno::RuntimeException); + static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelId() throw(); + static GridColumn* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& i_component ); + + // attribute access + void setIndex( sal_Int32 const i_index ); - virtual void SAL_CALL setIndex(sal_Int32 _nIndex)throw (::com::sun::star::uno::RuntimeException); private: - void broadcast( broadcast_column_type eType, const GridColumnEvent& aEvent ); - void broadcast_changed( ::rtl::OUString name, Any oldValue, Any newValue); - - Any identifier; - sal_Int32 index; - sal_Int32 columnWidth; - sal_Int32 preferredWidth; - sal_Int32 maxWidth; - sal_Int32 minWidth; - sal_Bool bResizeable; - ::rtl::OUString title; - ::com::sun::star::style::HorizontalAlignment horizontalAlign; + void broadcast_changed( + sal_Char const * const i_asciiAttributeName, + ::com::sun::star::uno::Any i_oldValue, + ::com::sun::star::uno::Any i_newValue, + ::comphelper::ComponentGuard& i_Guard + ); + + template< class TYPE > + void impl_set( TYPE & io_attribute, TYPE const & i_newValue, sal_Char const * i_attributeName ) + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); + if ( io_attribute == i_newValue ) + return; + + TYPE const aOldValue( io_attribute ); + io_attribute = i_newValue; + broadcast_changed( i_attributeName, ::com::sun::star::uno::makeAny( aOldValue ), ::com::sun::star::uno::makeAny( io_attribute ), aGuard ); + } + + ::com::sun::star::uno::Any m_aIdentifier; + sal_Int32 m_nIndex; + sal_Int32 m_nDataColumnIndex; + sal_Int32 m_nColumnWidth; + sal_Int32 m_nMaxWidth; + sal_Int32 m_nMinWidth; + sal_Int32 m_nFlexibility; + sal_Bool m_bResizeable; + ::rtl::OUString m_sTitle; + ::rtl::OUString m_sHelpText; + ::com::sun::star::style::HorizontalAlignment m_eHorizontalAlign; }; } diff --git a/toolkit/source/controls/grid/gridcontrol.cxx b/toolkit/source/controls/grid/gridcontrol.cxx index 9289352720bc..1aeb53fa42fb 100644 --- a/toolkit/source/controls/grid/gridcontrol.cxx +++ b/toolkit/source/controls/grid/gridcontrol.cxx @@ -29,22 +29,27 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_toolkit.hxx" -#include <gridcontrol.hxx> +#include "gridcontrol.hxx" +#include "grideventforwarder.hxx" #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/view/SelectionType.hpp> #include <com/sun/star/awt/grid/XGridDataModel.hpp> +#include <com/sun/star/awt/grid/XMutableGridDataModel.hpp> +#include <com/sun/star/awt/grid/DefaultGridDataModel.hpp> +#include <com/sun/star/awt/grid/SortableGridDataModel.hpp> #include <com/sun/star/awt/grid/XGridColumnModel.hpp> -#include <com/sun/star/awt/grid/ScrollBarMode.hpp> #include <toolkit/helper/unopropertyarrayhelper.hxx> #include <toolkit/helper/property.hxx> #include <com/sun/star/awt/XVclWindowPeer.hpp> #include <comphelper/processfactory.hxx> -#include <osl/diagnose.h> +#include <tools/diagnose_ex.h> +#include <tools/color.hxx> using ::rtl::OUString; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::awt; using namespace ::com::sun::star::awt::grid; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::beans; @@ -53,10 +58,28 @@ using namespace ::com::sun::star::view; namespace toolkit { -// ---------------------------------------------------- -// class UnoGridModel -// ---------------------------------------------------- -UnoGridModel::UnoGridModel() +//====================================================================================================================== +//= UnoGridModel +//====================================================================================================================== +namespace +{ + Reference< XGridDataModel > lcl_getDefaultDataModel_throw( ::comphelper::ComponentContext const & i_context ) + { + Reference< XMutableGridDataModel > const xDelegatorModel( DefaultGridDataModel::create( i_context.getUNOContext() ), UNO_QUERY_THROW ); + Reference< XGridDataModel > const xDataModel( SortableGridDataModel::create( i_context.getUNOContext(), xDelegatorModel ), UNO_QUERY_THROW ); + return xDataModel; + } + + Reference< XGridColumnModel > lcl_getDefaultColumnModel_throw( ::comphelper::ComponentContext const & i_context ) + { + Reference< XGridColumnModel > const xColumnModel( i_context.createComponent( "com.sun.star.awt.grid.DefaultGridColumnModel" ), UNO_QUERY_THROW ); + return xColumnModel; + } +} + +//---------------------------------------------------------------------------------------------------------------------- +UnoGridModel::UnoGridModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ) + :UnoControlModel( i_factory ) { ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR ); ImplRegisterProperty( BASEPROPERTY_BORDER ); @@ -72,36 +95,131 @@ UnoGridModel::UnoGridModel() ImplRegisterProperty( BASEPROPERTY_VSCROLL ); ImplRegisterProperty( BASEPROPERTY_TABSTOP ); ImplRegisterProperty( BASEPROPERTY_GRID_SHOWROWHEADER ); + ImplRegisterProperty( BASEPROPERTY_ROW_HEADER_WIDTH ); ImplRegisterProperty( BASEPROPERTY_GRID_SHOWCOLUMNHEADER ); - ImplRegisterProperty( BASEPROPERTY_GRID_DATAMODEL ); - ImplRegisterProperty( BASEPROPERTY_GRID_COLUMNMODEL ); + ImplRegisterProperty( BASEPROPERTY_COLUMN_HEADER_HEIGHT ); + ImplRegisterProperty( BASEPROPERTY_ROW_HEIGHT ); + ImplRegisterProperty( BASEPROPERTY_GRID_DATAMODEL, makeAny( lcl_getDefaultDataModel_throw( maContext ) ) ); + ImplRegisterProperty( BASEPROPERTY_GRID_COLUMNMODEL, makeAny( lcl_getDefaultColumnModel_throw( maContext ) ) ); ImplRegisterProperty( BASEPROPERTY_GRID_SELECTIONMODE ); ImplRegisterProperty( BASEPROPERTY_FONTRELIEF ); ImplRegisterProperty( BASEPROPERTY_FONTEMPHASISMARK ); ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR ); ImplRegisterProperty( BASEPROPERTY_TEXTCOLOR ); - ImplRegisterProperty( BASEPROPERTY_VERTICALALIGN ); - ImplRegisterProperty( BASEPROPERTY_GRID_EVEN_ROW_BACKGROUND ); - ImplRegisterProperty( BASEPROPERTY_GRID_HEADER_BACKGROUND ); + ImplRegisterProperty( BASEPROPERTY_TEXTLINECOLOR ); + ImplRegisterProperty( BASEPROPERTY_USE_GRID_LINES ); ImplRegisterProperty( BASEPROPERTY_GRID_LINE_COLOR ); - ImplRegisterProperty( BASEPROPERTY_GRID_ROW_BACKGROUND ); + ImplRegisterProperty( BASEPROPERTY_GRID_HEADER_BACKGROUND ); + ImplRegisterProperty( BASEPROPERTY_GRID_HEADER_TEXT_COLOR ); + ImplRegisterProperty( BASEPROPERTY_GRID_ROW_BACKGROUND_COLORS ); + ImplRegisterProperty( BASEPROPERTY_VERTICALALIGN ); } +//---------------------------------------------------------------------------------------------------------------------- UnoGridModel::UnoGridModel( const UnoGridModel& rModel ) -: UnoControlModel( rModel ) + :UnoControlModel( rModel ) { + osl_incrementInterlockedCount( &m_refCount ); + { + Reference< XGridDataModel > xDataModel; + // clone the data model + const Reference< XFastPropertySet > xCloneSource( &const_cast< UnoGridModel& >( rModel ) ); + try + { + const Reference< XCloneable > xCloneable( xCloneSource->getFastPropertyValue( BASEPROPERTY_GRID_DATAMODEL ), UNO_QUERY_THROW ); + xDataModel.set( xCloneable->createClone(), UNO_QUERY_THROW ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + if ( !xDataModel.is() ) + xDataModel = lcl_getDefaultDataModel_throw( maContext ); + UnoControlModel::setFastPropertyValue_NoBroadcast( BASEPROPERTY_GRID_DATAMODEL, makeAny( xDataModel ) ); + // do *not* use setFastPropertyValue here: The UnoControlModel ctor did a simple copy of all property values, + // so before this call here, we share our data model with the own of the clone source. setFastPropertyValue, + // then, disposes the old data model - which means the data model which in fact belongs to the clone source. + // so, call the UnoControlModel's impl-method for setting the value. + + // clone the column model + Reference< XGridColumnModel > xColumnModel; + try + { + const Reference< XCloneable > xCloneable( xCloneSource->getFastPropertyValue( BASEPROPERTY_GRID_COLUMNMODEL ), UNO_QUERY_THROW ); + xColumnModel.set( xCloneable->createClone(), UNO_QUERY_THROW ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + if ( !xColumnModel.is() ) + xColumnModel = lcl_getDefaultColumnModel_throw( maContext ); + UnoControlModel::setFastPropertyValue_NoBroadcast( BASEPROPERTY_GRID_COLUMNMODEL, makeAny( xColumnModel ) ); + // same comment as above: do not use our own setPropertyValue here. + } + osl_decrementInterlockedCount( &m_refCount ); } +//---------------------------------------------------------------------------------------------------------------------- UnoControlModel* UnoGridModel::Clone() const { return new UnoGridModel( *this ); } +//---------------------------------------------------------------------------------------------------------------------- +namespace +{ + void lcl_dispose_nothrow( const Any& i_component ) + { + try + { + const Reference< XComponent > xComponent( i_component, UNO_QUERY_THROW ); + xComponent->dispose(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } +} + +//---------------------------------------------------------------------------------------------------------------------- +void SAL_CALL UnoGridModel::dispose( ) throw(RuntimeException) +{ + lcl_dispose_nothrow( getFastPropertyValue( BASEPROPERTY_GRID_COLUMNMODEL ) ); + lcl_dispose_nothrow( getFastPropertyValue( BASEPROPERTY_GRID_DATAMODEL ) ); + + UnoControlModel::dispose(); +} + +//---------------------------------------------------------------------------------------------------------------------- +void SAL_CALL UnoGridModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw (Exception) +{ + Any aOldSubModel; + if ( ( nHandle == BASEPROPERTY_GRID_COLUMNMODEL ) || ( nHandle == BASEPROPERTY_GRID_DATAMODEL ) ) + { + aOldSubModel = getFastPropertyValue( nHandle ); + if ( aOldSubModel == rValue ) + { + OSL_ENSURE( false, "UnoGridModel::setFastPropertyValue_NoBroadcast: setting the same value, again!" ); + // shouldn't this have been caught by convertFastPropertyValue? + aOldSubModel.clear(); + } + } + + UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle, rValue ); + + if ( aOldSubModel.hasValue() ) + lcl_dispose_nothrow( aOldSubModel ); +} + +//---------------------------------------------------------------------------------------------------------------------- OUString UnoGridModel::getServiceName() throw(RuntimeException) { return OUString::createFromAscii( szServiceName_GridControlModel ); } +//---------------------------------------------------------------------------------------------------------------------- Any UnoGridModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const { switch( nPropId ) @@ -111,27 +229,26 @@ Any UnoGridModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const case BASEPROPERTY_GRID_SELECTIONMODE: return uno::makeAny( SelectionType(1) ); case BASEPROPERTY_GRID_SHOWROWHEADER: + case BASEPROPERTY_USE_GRID_LINES: return uno::makeAny( (sal_Bool)sal_False ); + case BASEPROPERTY_ROW_HEADER_WIDTH: + return uno::makeAny( sal_Int32( 10 ) ); case BASEPROPERTY_GRID_SHOWCOLUMNHEADER: - return uno::makeAny( (sal_Bool)sal_False ); - case BASEPROPERTY_GRID_DATAMODEL: - return uno::makeAny( Reference<XGridDataModel> ()); - case BASEPROPERTY_GRID_COLUMNMODEL: - return uno::makeAny(Reference<XGridColumnModel>() ); - case BASEPROPERTY_GRID_EVEN_ROW_BACKGROUND: - return uno::makeAny( com::sun::star::util::Color(0xFFFFFF) ); + return uno::makeAny( (sal_Bool)sal_True ); + case BASEPROPERTY_COLUMN_HEADER_HEIGHT: + case BASEPROPERTY_ROW_HEIGHT: case BASEPROPERTY_GRID_HEADER_BACKGROUND: - return uno::makeAny( com::sun::star::util::Color(0xFFFFFF) ); + case BASEPROPERTY_GRID_HEADER_TEXT_COLOR: case BASEPROPERTY_GRID_LINE_COLOR: - return uno::makeAny( com::sun::star::util::Color(0xFFFFFF) ); - case BASEPROPERTY_GRID_ROW_BACKGROUND: - return uno::makeAny(com::sun::star::util::Color(0xFFFFFF) ); + case BASEPROPERTY_GRID_ROW_BACKGROUND_COLORS: + return Any(); default: return UnoControlModel::ImplGetDefaultValue( nPropId ); } } +//---------------------------------------------------------------------------------------------------------------------- ::cppu::IPropertyArrayHelper& UnoGridModel::getInfoHelper() { static UnoPropertyArrayHelper* pHelper = NULL; @@ -143,6 +260,7 @@ Any UnoGridModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const return *pHelper; } +//---------------------------------------------------------------------------------------------------------------------- // XMultiPropertySet Reference< XPropertySetInfo > UnoGridModel::getPropertySetInfo( ) throw(RuntimeException) { @@ -151,20 +269,29 @@ Reference< XPropertySetInfo > UnoGridModel::getPropertySetInfo( ) throw(Runtime } -// ---------------------------------------------------- -// class UnoGridControl -// ---------------------------------------------------- -UnoGridControl::UnoGridControl() -: mSelectionMode(SelectionType(1)), - m_aSelectionListeners( *this ) +//====================================================================================================================== +//= UnoGridControl +//====================================================================================================================== +UnoGridControl::UnoGridControl( const Reference< XMultiServiceFactory >& i_factory ) + :UnoGridControl_Base( i_factory ) + ,mSelectionMode(SelectionType(1)) + ,m_aSelectionListeners( *this ) + ,m_pEventForwarder( new GridEventForwarder( *this ) ) +{ +} + +//---------------------------------------------------------------------------------------------------------------------- +UnoGridControl::~UnoGridControl() { } +//---------------------------------------------------------------------------------------------------------------------- OUString UnoGridControl::GetComponentServiceName() { return OUString(RTL_CONSTASCII_USTRINGPARAM("Grid")); } +//---------------------------------------------------------------------------------------------------------------------- void SAL_CALL UnoGridControl::dispose( ) throw(RuntimeException) { lang::EventObject aEvt; @@ -173,115 +300,157 @@ void SAL_CALL UnoGridControl::dispose( ) throw(RuntimeException) UnoControl::dispose(); } -void UnoGridControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException) +//---------------------------------------------------------------------------------------------------------------------- +void SAL_CALL UnoGridControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException) { UnoControlBase::createPeer( rxToolkit, rParentPeer ); - Reference< XGridControl > xGrid( getPeer(), UNO_QUERY_THROW ); + const Reference< XGridControl > xGrid( getPeer(), UNO_QUERY_THROW ); xGrid->addSelectionListener(&m_aSelectionListeners); +} - Reference<XGridDataListener> xListener ( getPeer(), UNO_QUERY_THROW ); - Reference<XGridColumnListener> xColListener ( getPeer(), UNO_QUERY_THROW ); - Reference<XPropertySet> xPropSet ( getModel(), UNO_QUERY_THROW ); - - Reference<XGridDataModel> xGridDataModel ( xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("GridDataModel"))), UNO_QUERY_THROW ); - if(xGridDataModel != NULL) - xGridDataModel->addDataListener(xListener); - Reference<XGridColumnModel> xGridColumnModel ( xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("ColumnModel"))), UNO_QUERY_THROW ); - if(xGridColumnModel != NULL) +//---------------------------------------------------------------------------------------------------------------------- +namespace +{ + void lcl_setEventForwarding( const Reference< XControlModel >& i_gridControlModel, const ::boost::scoped_ptr< GridEventForwarder >& i_listener, + bool const i_add ) { - for(int i = 0;i<xGridColumnModel->getColumnCount();i++) + const Reference< XPropertySet > xModelProps( i_gridControlModel, UNO_QUERY ); + if ( !xModelProps.is() ) + return; + + try { - xGridColumnModel->getColumn(i)->addColumnListener(xColListener); + Reference< XContainer > const xColModel( + xModelProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ColumnModel" ) ) ), + UNO_QUERY_THROW ); + if ( i_add ) + xColModel->addContainerListener( i_listener.get() ); + else + xColModel->removeContainerListener( i_listener.get() ); + + Reference< XGridDataModel > const xDataModel( + xModelProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "GridDataModel" ) ) ), + UNO_QUERY_THROW + ); + Reference< XMutableGridDataModel > const xMutableDataModel( xDataModel, UNO_QUERY ); + if ( xMutableDataModel.is() ) + { + if ( i_add ) + xMutableDataModel->addGridDataListener( i_listener.get() ); + else + xMutableDataModel->removeGridDataListener( i_listener.get() ); + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); } } } +//---------------------------------------------------------------------------------------------------------------------- +sal_Bool SAL_CALL UnoGridControl::setModel( const Reference< XControlModel >& i_model ) throw(RuntimeException) +{ + lcl_setEventForwarding( getModel(), m_pEventForwarder, false ); + if ( !UnoGridControl_Base::setModel( i_model ) ) + return sal_False; + lcl_setEventForwarding( getModel(), m_pEventForwarder, true ); + return sal_True; +} -// ------------------------------------------------------------------- -// XGridControl - -::sal_Int32 UnoGridControl::getItemIndexAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException) +//---------------------------------------------------------------------------------------------------------------------- +::sal_Int32 UnoGridControl::getRowAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException) { - Reference< XGridControl > xGrid ( getPeer(), UNO_QUERY_THROW ); - return xGrid->getItemIndexAtPoint( x, y ); + Reference< XGridControl > const xGrid ( getPeer(), UNO_QUERY_THROW ); + return xGrid->getRowAtPoint( x, y ); } -void SAL_CALL UnoGridControl::setToolTip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& text, const ::com::sun::star::uno::Sequence< ::sal_Int32 >& columns) throw (::com::sun::star::uno::RuntimeException) +//---------------------------------------------------------------------------------------------------------------------- +::sal_Int32 UnoGridControl::getColumnAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException) { - Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->setToolTip( text, columns ); + Reference< XGridControl > const xGrid ( getPeer(), UNO_QUERY_THROW ); + return xGrid->getColumnAtPoint( x, y ); } -// ------------------------------------------------------------------- -// XGridSelection -// ------------------------------------------------------------------- -::sal_Int32 SAL_CALL UnoGridControl::getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException) +//---------------------------------------------------------------------------------------------------------------------- +::sal_Int32 SAL_CALL UnoGridControl::getCurrentColumn( ) throw (RuntimeException) { - return Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->getMinSelectionIndex(); + Reference< XGridControl > const xGrid ( getPeer(), UNO_QUERY_THROW ); + return xGrid->getCurrentColumn(); } -::sal_Int32 SAL_CALL UnoGridControl::getMaxSelectionIndex() throw (::com::sun::star::uno::RuntimeException) +//---------------------------------------------------------------------------------------------------------------------- +::sal_Int32 SAL_CALL UnoGridControl::getCurrentRow( ) throw (RuntimeException) { - return Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->getMaxSelectionIndex(); + Reference< XGridControl > const xGrid ( getPeer(), UNO_QUERY_THROW ); + return xGrid->getCurrentRow(); } -void SAL_CALL UnoGridControl::selectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException) +//---------------------------------------------------------------------------------------------------------------------- +void SAL_CALL UnoGridControl::selectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException) { - Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->selectRows( rangeOfRows); + Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->selectRow( i_rowIndex ); } +//---------------------------------------------------------------------------------------------------------------------- void SAL_CALL UnoGridControl::selectAllRows() throw (::com::sun::star::uno::RuntimeException) { Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->selectAllRows(); } -void SAL_CALL UnoGridControl::deselectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException) + +//---------------------------------------------------------------------------------------------------------------------- +void SAL_CALL UnoGridControl::deselectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException) { - Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->deselectRows( rangeOfRows); + Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->deselectRow( i_rowIndex ); } +//---------------------------------------------------------------------------------------------------------------------- void SAL_CALL UnoGridControl::deselectAllRows() throw (::com::sun::star::uno::RuntimeException) { Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->deselectAllRows(); } + +//---------------------------------------------------------------------------------------------------------------------- ::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL UnoGridControl::getSelection() throw (::com::sun::star::uno::RuntimeException) { return Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->getSelection(); } +//---------------------------------------------------------------------------------------------------------------------- ::sal_Bool SAL_CALL UnoGridControl::isSelectionEmpty() throw (::com::sun::star::uno::RuntimeException) { return Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->isSelectionEmpty(); } +//---------------------------------------------------------------------------------------------------------------------- ::sal_Bool SAL_CALL UnoGridControl::isSelectedIndex(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException) { return Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->isSelectedIndex( index ); } -void SAL_CALL UnoGridControl::selectRow(::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException) -{ - Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->selectRow( y ); -} - +//---------------------------------------------------------------------------------------------------------------------- void SAL_CALL UnoGridControl::addSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException) { m_aSelectionListeners.addInterface( listener ); } +//---------------------------------------------------------------------------------------------------------------------- void SAL_CALL UnoGridControl::removeSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException) { m_aSelectionListeners.removeInterface( listener ); } + }//namespace toolkit -Reference< XInterface > SAL_CALL GridControl_CreateInstance( const Reference< XMultiServiceFactory >& ) +Reference< XInterface > SAL_CALL GridControl_CreateInstance( const Reference< XMultiServiceFactory >& i_factory ) { - return Reference < XInterface >( ( ::cppu::OWeakObject* ) new ::toolkit::UnoGridControl ); + return Reference < XInterface >( ( ::cppu::OWeakObject* ) new ::toolkit::UnoGridControl( i_factory ) ); } -Reference< XInterface > SAL_CALL GridControlModel_CreateInstance( const Reference< XMultiServiceFactory >& ) +Reference< XInterface > SAL_CALL GridControlModel_CreateInstance( const Reference< XMultiServiceFactory >& i_factory ) { - return Reference < XInterface >( ( ::cppu::OWeakObject* ) new ::toolkit::UnoGridModel ); + return Reference < XInterface >( ( ::cppu::OWeakObject* ) new ::toolkit::UnoGridModel( i_factory ) ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/controls/grid/gridcontrol.hxx b/toolkit/source/controls/grid/gridcontrol.hxx index 564e752e618e..97283e7827b5 100644 --- a/toolkit/source/controls/grid/gridcontrol.hxx +++ b/toolkit/source/controls/grid/gridcontrol.hxx @@ -31,21 +31,20 @@ #include <com/sun/star/awt/grid/XGridControl.hpp> #include <com/sun/star/view/SelectionType.hpp> + #include <toolkit/controls/unocontrolbase.hxx> #include <toolkit/controls/unocontrolmodel.hxx> #include <toolkit/helper/servicenames.hxx> #include <cppuhelper/implbase1.hxx> #include <comphelper/sequence.hxx> - #include <toolkit/helper/listenermultiplexer.hxx> -namespace toolkit { +#include <boost/scoped_ptr.hpp> + +namespace toolkit +{ -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::awt; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::container; +class GridEventForwarder; // =================================================================== // = UnoGridModel @@ -53,21 +52,27 @@ using namespace ::com::sun::star::container; class UnoGridModel : public UnoControlModel { protected: - Any ImplGetDefaultValue( sal_uInt16 nPropId ) const; + ::com::sun::star::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const; ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); public: - UnoGridModel(); + UnoGridModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); UnoGridModel( const UnoGridModel& rModel ); UnoControlModel* Clone() const; + // ::com::sun::star::lang::XComponent + void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException); + // ::com::sun::star::beans::XMultiPropertySet ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); // ::com::sun::star::io::XPersistObject ::rtl::OUString SAL_CALL getServiceName() throw(::com::sun::star::uno::RuntimeException); + // OPropertySetHelper + void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception); + // XServiceInfo DECLIMPL_SERVICEINFO_DERIVED( UnoGridModel, UnoControlModel, szServiceName_GridControlModel ) }; @@ -76,10 +81,13 @@ public: // =================================================================== // = UnoGridControl // =================================================================== -class UnoGridControl : public ::cppu::ImplInheritanceHelper1< UnoControlBase, ::com::sun::star::awt::grid::XGridControl > +typedef ::cppu::ImplInheritanceHelper1 < UnoControlBase + , ::com::sun::star::awt::grid::XGridControl + > UnoGridControl_Base; +class UnoGridControl : public UnoGridControl_Base { public: - UnoGridControl(); + UnoGridControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); ::rtl::OUString GetComponentServiceName(); // ::com::sun::star::lang::XComponent @@ -87,24 +95,22 @@ public: // ::com::sun::star::awt::XControl 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); + sal_Bool SAL_CALL setModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxModel ) throw(::com::sun::star::uno::RuntimeException); // ::com::sun::star::awt::grid::XGridControl - - virtual ::sal_Int32 SAL_CALL getItemIndexAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setToolTip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& text, const ::com::sun::star::uno::Sequence< ::sal_Int32 >& columns) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getColumnAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getRowAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getCurrentColumn( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getCurrentRow( ) throw (::com::sun::star::uno::RuntimeException); // ::com::sun::star::awt::grid::XGridSelection - - virtual ::sal_Int32 SAL_CALL getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getMaxSelectionIndex() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL selectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL selectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL selectAllRows() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL deselectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL deselectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL deselectAllRows() throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL getSelection() throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Bool SAL_CALL isSelectionEmpty() throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Bool SAL_CALL isSelectedIndex(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL selectRow(::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL addSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL removeSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException); @@ -112,9 +118,14 @@ public: DECLIMPL_SERVICEINFO_DERIVED( UnoGridControl, UnoControlBase, szServiceName_GridControl ) using UnoControl::getPeer; + +protected: + ~UnoGridControl(); + private: - ::com::sun::star::view::SelectionType mSelectionMode; - SelectionListenerMultiplexer m_aSelectionListeners; + ::com::sun::star::view::SelectionType mSelectionMode; + SelectionListenerMultiplexer m_aSelectionListeners; + ::boost::scoped_ptr< GridEventForwarder > m_pEventForwarder; }; } // toolkit diff --git a/toolkit/source/controls/grid/grideventforwarder.cxx b/toolkit/source/controls/grid/grideventforwarder.cxx new file mode 100755 index 000000000000..c3760b8315a3 --- /dev/null +++ b/toolkit/source/controls/grid/grideventforwarder.cxx @@ -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 "precompiled_toolkit.hxx" + +#include "grideventforwarder.hxx" +#include "gridcontrol.hxx" + +/** === begin UNO includes === **/ +/** === end UNO includes === **/ + +//...................................................................................................................... +namespace toolkit +{ +//...................................................................................................................... + + /** === 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::awt::grid::GridDataEvent; + using ::com::sun::star::container::ContainerEvent; + using ::com::sun::star::lang::EventObject; + /** === end UNO using === **/ + + //================================================================================================================== + //= GridEventForwarder + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + GridEventForwarder::GridEventForwarder( UnoGridControl& i_parent ) + :m_parent( i_parent ) + { + } + + //------------------------------------------------------------------------------------------------------------------ + GridEventForwarder::~GridEventForwarder() + { + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridEventForwarder::acquire() throw() + { + m_parent.acquire(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridEventForwarder::release() throw() + { + m_parent.release(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridEventForwarder::rowsInserted( const GridDataEvent& i_event ) throw (RuntimeException) + { + Reference< XGridDataListener > xPeer( m_parent.getPeer(), UNO_QUERY ); + if ( xPeer.is() ) + xPeer->rowsInserted( i_event ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridEventForwarder::rowsRemoved( const GridDataEvent& i_event ) throw (RuntimeException) + { + Reference< XGridDataListener > xPeer( m_parent.getPeer(), UNO_QUERY ); + if ( xPeer.is() ) + xPeer->rowsRemoved( i_event ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridEventForwarder::dataChanged( const GridDataEvent& i_event ) throw (RuntimeException) + { + Reference< XGridDataListener > xPeer( m_parent.getPeer(), UNO_QUERY ); + if ( xPeer.is() ) + xPeer->dataChanged( i_event ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridEventForwarder::rowHeadingChanged( const GridDataEvent& i_event ) throw (RuntimeException) + { + Reference< XGridDataListener > xPeer( m_parent.getPeer(), UNO_QUERY ); + if ( xPeer.is() ) + xPeer->rowHeadingChanged( i_event ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridEventForwarder::elementInserted( const ContainerEvent& i_event ) throw (RuntimeException) + { + Reference< XContainerListener > xPeer( m_parent.getPeer(), UNO_QUERY ); + if ( xPeer.is() ) + xPeer->elementInserted( i_event ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridEventForwarder::elementRemoved( const ContainerEvent& i_event ) throw (RuntimeException) + { + Reference< XContainerListener > xPeer( m_parent.getPeer(), UNO_QUERY ); + if ( xPeer.is() ) + xPeer->elementRemoved( i_event ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridEventForwarder::elementReplaced( const ContainerEvent& i_event ) throw (RuntimeException) + { + Reference< XContainerListener > xPeer( m_parent.getPeer(), UNO_QUERY ); + if ( xPeer.is() ) + xPeer->elementReplaced( i_event ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridEventForwarder::disposing( const EventObject& i_event ) throw (RuntimeException) + { + Reference< XEventListener > xPeer( m_parent.getPeer(), UNO_QUERY ); + if ( xPeer.is() ) + xPeer->disposing( i_event ); + } + +//...................................................................................................................... +} // namespace toolkit +//...................................................................................................................... diff --git a/toolkit/source/controls/grid/grideventforwarder.hxx b/toolkit/source/controls/grid/grideventforwarder.hxx new file mode 100755 index 000000000000..5a8b03f57037 --- /dev/null +++ b/toolkit/source/controls/grid/grideventforwarder.hxx @@ -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. + * + ************************************************************************/ + +#ifndef TOOLKIT_GRIDEVENTFORWARDER_HXX +#define TOOLKIT_GRIDEVENTFORWARDER_HXX + +/** === begin UNO includes === **/ +#include <com/sun/star/awt/grid/XGridDataListener.hpp> +#include <com/sun/star/awt/grid/XGridColumnListener.hpp> +#include <com/sun/star/container/XContainerListener.hpp> +/** === end UNO includes === **/ + +#include <cppuhelper/implbase2.hxx> + +//...................................................................................................................... +namespace toolkit +{ +//...................................................................................................................... + + class UnoGridControl; + + //================================================================================================================== + //= GridEventForwarder + //================================================================================================================== + typedef ::cppu::ImplHelper2 < ::com::sun::star::awt::grid::XGridDataListener + , ::com::sun::star::container::XContainerListener + > GridEventForwarder_Base; + + class GridEventForwarder : public GridEventForwarder_Base + { + public: + GridEventForwarder( UnoGridControl& i_parent ); + virtual ~GridEventForwarder(); + + public: + // XInterface + virtual void SAL_CALL acquire() throw(); + virtual void SAL_CALL release() throw(); + + // XGridDataListener + virtual void SAL_CALL rowsInserted( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL rowsRemoved( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL dataChanged( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL rowHeadingChanged( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::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); + + // XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& i_event ) throw (::com::sun::star::uno::RuntimeException); + + private: + UnoGridControl& m_parent; + }; + +//...................................................................................................................... +} // namespace toolkit +//...................................................................................................................... + +#endif // TOOLKIT_GRIDEVENTFORWARDER_HXX diff --git a/toolkit/source/controls/grid/initguard.hxx b/toolkit/source/controls/grid/initguard.hxx new file mode 100755 index 000000000000..138cdd8c894c --- /dev/null +++ b/toolkit/source/controls/grid/initguard.hxx @@ -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. + * + ************************************************************************/ + +#ifndef SVTOOLS_INITGUARD_HXX +#define SVTOOLS_INITGUARD_HXX + +/** === begin UNO includes === **/ +#include <com/sun/star/lang/NotInitializedException.hpp> +/** === end UNO includes === **/ + +#include <comphelper/componentguard.hxx> + +//...................................................................................................................... +namespace toolkit +{ +//...................................................................................................................... + + //================================================================================================================== + //= InitGuard + //================================================================================================================== + template < class IMPL > + class InitGuard : public ::comphelper::ComponentGuard + { + public: + InitGuard( IMPL& i_component, ::cppu::OBroadcastHelper & i_broadcastHelper ) + :comphelper::ComponentGuard( i_component, i_broadcastHelper ) + { + if ( !i_component.isInitialized() ) + throw ::com::sun::star::lang::NotInitializedException( ::rtl::OUString(), *&i_component ); + } + + ~InitGuard() + { + } + }; + +//...................................................................................................................... +} // namespace toolkit +//...................................................................................................................... + +#endif // SVTOOLS_INITGUARD_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file diff --git a/toolkit/source/controls/grid/makefile.mk b/toolkit/source/controls/grid/makefile.mk deleted file mode 100644 index 70bfc34b9d02..000000000000 --- a/toolkit/source/controls/grid/makefile.mk +++ /dev/null @@ -1,50 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=..$/..$/.. - -PRJNAME=toolkit -TARGET=grid - -ENABLE_EXCEPTIONS=TRUE - -# --- Settings ----------------------------------------------------- - -.INCLUDE : settings.mk -.INCLUDE : $(PRJ)$/util$/makefile.pmk - -# --- Files -------------------------------------------------------- - -SLOFILES= \ - $(SLO)$/gridcontrol.obj\ - $(SLO)$/defaultgriddatamodel.obj\ - $(SLO)$/defaultgridcolumnmodel.obj\ - $(SLO)$/gridcolumn.obj - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk diff --git a/toolkit/source/controls/grid/sortablegriddatamodel.cxx b/toolkit/source/controls/grid/sortablegriddatamodel.cxx new file mode 100755 index 000000000000..77a2ffa1637b --- /dev/null +++ b/toolkit/source/controls/grid/sortablegriddatamodel.cxx @@ -0,0 +1,877 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General 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_toolkit.hxx" + +#include "sortablegriddatamodel.hxx" +#include "toolkit/helper/servicenames.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/i18n/XCollator.hpp> +#include <com/sun/star/lang/IllegalArgumentException.hpp> +#include <com/sun/star/ucb/AlreadyInitializedException.hpp> +/** === end UNO includes === **/ + +#include <comphelper/anycompare.hxx> +#include <cppuhelper/typeprovider.hxx> +#include <tools/diagnose_ex.h> +#include <tools/debug.hxx> +#include <vcl/svapp.hxx> + +#include <set> + +//...................................................................................................................... +namespace toolkit +{ +//...................................................................................................................... + + /** === begin UNO using === **/ + using ::com::sun::star::uno::TypeClass; + using ::com::sun::star::uno::TypeClass_VOID; + 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::IndexOutOfBoundsException; + using ::com::sun::star::lang::IllegalArgumentException; + using ::com::sun::star::awt::grid::XGridDataListener; + using ::com::sun::star::beans::Pair; + using ::com::sun::star::util::XCloneable; + using ::com::sun::star::i18n::XCollator; + using ::com::sun::star::lang::IllegalArgumentException; + using ::com::sun::star::lang::XMultiServiceFactory; + using ::com::sun::star::awt::grid::GridDataEvent; + using ::com::sun::star::lang::EventObject; + using ::com::sun::star::ucb::AlreadyInitializedException; + /** === end UNO using === **/ + +#ifdef DBG_UTIL + const char* SortableGridDataModel_checkInvariants( const void* _pInstance ) + { + return static_cast< const SortableGridDataModel* >( _pInstance )->checkInvariants(); + } + + //------------------------------------------------------------------------------------------------------------------ + const char* SortableGridDataModel::checkInvariants() const + { + if ( m_publicToPrivateRowIndex.size() != m_privateToPublicRowIndex.size() ) + return "inconsistent index maps"; + + if ( m_delegator.is() ) + { + if ( m_publicToPrivateRowIndex.size() != size_t( m_delegator->getRowCount() ) ) + return "wrong cached row count"; + } + else + { + if ( !m_publicToPrivateRowIndex.empty() ) + return "disposed or not initialized, but having a non-empty map"; + } + + for ( size_t publicIndex=0; publicIndex<m_publicToPrivateRowIndex.size(); ++publicIndex ) + { + ::sal_Int32 const privateIndex = m_publicToPrivateRowIndex[ publicIndex ]; + if ( ( privateIndex < 0 ) || ( size_t( privateIndex ) >= m_privateToPublicRowIndex.size() ) ) + return "invalid cached private index"; + + if ( m_privateToPublicRowIndex[ privateIndex ] != sal_Int32( publicIndex ) ) + return "index map traversal not commutavive"; + } + + if ( impl_isSorted_nothrow() && m_publicToPrivateRowIndex.empty() ) + return "sorted, but no row index translation tables"; + + if ( !impl_isSorted_nothrow() && !m_publicToPrivateRowIndex.empty() ) + return "unsorted, but have index translation tables"; + + return NULL; + } +#endif + +#define DBG_CHECK_ME() \ + DBG_CHKTHIS( SortableGridDataModel, SortableGridDataModel_checkInvariants ) + + //------------------------------------------------------------------------------------------------------------------ + namespace + { + template< class STLCONTAINER > + static void lcl_clear( STLCONTAINER& i_container ) + { + STLCONTAINER empty; + empty.swap( i_container ); + } + } + + //================================================================================================================== + //= SortableGridDataModel + //================================================================================================================== + DBG_NAME( SortableGridDataModel ) + //------------------------------------------------------------------------------------------------------------------ + SortableGridDataModel::SortableGridDataModel( Reference< XMultiServiceFactory > const & i_factory ) + :SortableGridDataModel_Base( m_aMutex ) + ,SortableGridDataModel_PrivateBase() + ,m_context( i_factory ) + ,m_isInitialized( false ) + ,m_delegator() + ,m_collator() + ,m_currentSortColumn( -1 ) + ,m_sortAscending( true ) + ,m_publicToPrivateRowIndex() + ,m_privateToPublicRowIndex() + { + DBG_CTOR( SortableGridDataModel, SortableGridDataModel_checkInvariants ); + } + + //------------------------------------------------------------------------------------------------------------------ + SortableGridDataModel::SortableGridDataModel( SortableGridDataModel const & i_copySource ) + :cppu::BaseMutex() + ,SortableGridDataModel_Base( m_aMutex ) + ,SortableGridDataModel_PrivateBase() + ,m_context( i_copySource.m_context ) + ,m_isInitialized( true ) + ,m_delegator() + ,m_collator( i_copySource.m_collator ) + ,m_currentSortColumn( i_copySource.m_currentSortColumn ) + ,m_sortAscending( i_copySource.m_sortAscending ) + ,m_publicToPrivateRowIndex( i_copySource.m_publicToPrivateRowIndex ) + ,m_privateToPublicRowIndex( i_copySource.m_privateToPublicRowIndex ) + { + DBG_CTOR( SortableGridDataModel, SortableGridDataModel_checkInvariants ); + + ENSURE_OR_THROW( i_copySource.m_delegator.is(), + "not expected to be called for a disposed copy source!" ); + m_delegator.set( i_copySource.m_delegator->createClone(), UNO_QUERY_THROW ); + } + + //------------------------------------------------------------------------------------------------------------------ + SortableGridDataModel::~SortableGridDataModel() + { + if ( !rBHelper.bDisposed ) + { + acquire(); + dispose(); + } + + DBG_DTOR( SortableGridDataModel, SortableGridDataModel_checkInvariants ); + } + + //------------------------------------------------------------------------------------------------------------------ + Any SAL_CALL SortableGridDataModel::queryInterface( const Type& aType ) throw (RuntimeException) + { + Any aReturn( SortableGridDataModel_Base::queryInterface( aType ) ); + if ( !aReturn.hasValue() ) + aReturn = SortableGridDataModel_PrivateBase::queryInterface( aType ); + return aReturn; + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::acquire( ) throw () + { + SortableGridDataModel_Base::acquire(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::release( ) throw () + { + SortableGridDataModel_Base::release(); + } + + //------------------------------------------------------------------------------------------------------------------ + Sequence< Type > SAL_CALL SortableGridDataModel::getTypes( ) throw (RuntimeException) + { + return SortableGridDataModel_Base::getTypes(); + // don't expose the types got via SortableGridDataModel_PrivateBase - they're private, after all + } + + //------------------------------------------------------------------------------------------------------------------ + Sequence< ::sal_Int8 > SAL_CALL SortableGridDataModel::getImplementationId( ) throw (RuntimeException) + { + static ::cppu::OImplementationId aId; + return aId.getImplementationId(); + } + + //------------------------------------------------------------------------------------------------------------------ + namespace + { + Reference< XCollator > lcl_loadDefaultCollator_throw( ::comphelper::ComponentContext const & i_context ) + { + Reference< XCollator > const xCollator( i_context.createComponent( "com.sun.star.i18n.Collator" ), UNO_QUERY_THROW ); + xCollator->loadDefaultCollator( Application::GetSettings().GetLocale(), 0 ); + return xCollator; + } + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::initialize( const Sequence< Any >& i_arguments ) throw (Exception, RuntimeException) + { + ::comphelper::ComponentGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + + if ( m_delegator.is() ) + throw AlreadyInitializedException( ::rtl::OUString(), *this ); + + Reference< XMutableGridDataModel > xDelegator; + Reference< XCollator > xCollator; + switch ( i_arguments.getLength() ) + { + case 1: // SortableGridDataModel.create( XMutableGridDataModel ) + xDelegator.set( i_arguments[0], UNO_QUERY ); + xCollator = lcl_loadDefaultCollator_throw( m_context ); + break; + + case 2: // SortableGridDataModel.createWithCollator( XMutableGridDataModel, XCollator ) + xDelegator.set( i_arguments[0], UNO_QUERY ); + xCollator.set( i_arguments[1], UNO_QUERY ); + if ( !xCollator.is() ) + throw IllegalArgumentException( ::rtl::OUString(), *this, 2 ); + break; + } + if ( !xDelegator.is() ) + throw IllegalArgumentException( ::rtl::OUString(), *this, 1 ); + + m_delegator = xDelegator; + m_collator = xCollator; + + m_delegator->addGridDataListener( this ); + + m_isInitialized = true; + } + + //------------------------------------------------------------------------------------------------------------------ + GridDataEvent SortableGridDataModel::impl_createPublicEvent( GridDataEvent const & i_originalEvent ) const + { + GridDataEvent aEvent( i_originalEvent ); + aEvent.Source = *const_cast< SortableGridDataModel* >( this ); + aEvent.FirstRow = impl_getPublicRowIndex_nothrow( aEvent.FirstRow ); + aEvent.LastRow = impl_getPublicRowIndex_nothrow( aEvent.LastRow ); + return aEvent; + } + + //------------------------------------------------------------------------------------------------------------------ + void SortableGridDataModel::impl_broadcast( void ( SAL_CALL XGridDataListener::*i_listenerMethod )( const GridDataEvent & ), + GridDataEvent const & i_publicEvent, MethodGuard& i_instanceLock ) + { + ::cppu::OInterfaceContainerHelper* pListeners = rBHelper.getContainer( XGridDataListener::static_type() ); + if ( pListeners == NULL ) + return; + + i_instanceLock.clear(); + pListeners->notifyEach( i_listenerMethod, i_publicEvent ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::rowsInserted( const GridDataEvent& i_event ) throw (RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + + // if the data is not sorted, broadcast the event unchanged + if ( !impl_isSorted_nothrow() ) + { + GridDataEvent const aEvent( impl_createPublicEvent( i_event ) ); + impl_broadcast( &XGridDataListener::rowsInserted, aEvent, aGuard ); + return; + } + + bool needReIndex = false; + if ( i_event.FirstRow > i_event.LastRow ) + { + OSL_ENSURE( false, "SortableGridDataModel::rowsInserted: invalid event - invalid row indexes!" ); + needReIndex = true; + } + else if ( size_t( i_event.FirstRow ) > m_privateToPublicRowIndex.size() ) + { + OSL_ENSURE( false, "SortableGridDataModel::rowsInserted: invalid event - too large row index!" ); + needReIndex = true; + } + + if ( needReIndex ) + { + impl_rebuildIndexesAndNotify( aGuard ); + return; + } + + // we do not insert the new rows into the sort order - if somebody adds rows while we're sorted, s/he has + // to resort. Instead, we simply append the rows, no matter where they were inserted in the delegator data + // model. + sal_Int32 const nPublicFirstRow = sal_Int32( m_privateToPublicRowIndex.size() ); + sal_Int32 nPublicLastRow = nPublicFirstRow; + for ( sal_Int32 newRow = i_event.FirstRow; newRow <= i_event.LastRow; ++newRow, ++nPublicLastRow ) + { + m_privateToPublicRowIndex.push_back( nPublicLastRow ); + m_publicToPrivateRowIndex.push_back( nPublicLastRow ); + } + + // broadcast the event + GridDataEvent const aEvent( *this, -1, -1, nPublicFirstRow, nPublicLastRow ); + impl_broadcast( &XGridDataListener::rowsInserted, aEvent, aGuard ); + } + + //------------------------------------------------------------------------------------------------------------------ + namespace + { + void lcl_decrementValuesGreaterThan( ::std::vector< ::sal_Int32 > & io_indexMap, sal_Int32 const i_threshold ) + { + for ( ::std::vector< ::sal_Int32 >::iterator loop = io_indexMap.begin(); + loop != io_indexMap.end(); + ++loop + ) + { + if ( *loop >= i_threshold ) + --*loop; + } + } + } + + //------------------------------------------------------------------------------------------------------------------ + void SortableGridDataModel::impl_rebuildIndexesAndNotify( MethodGuard& i_instanceLock ) + { + OSL_PRECOND( impl_isSorted_nothrow(), "SortableGridDataModel::impl_rebuildIndexesAndNotify: illegal call!" ); + + // clear the indexes + lcl_clear( m_publicToPrivateRowIndex ); + lcl_clear( m_privateToPublicRowIndex ); + + // broadcast an artificial event, saying that all rows have been removed + GridDataEvent const aRemovalEvent( *this, -1, -1, -1, -1 ); + impl_broadcast( &XGridDataListener::rowsRemoved, aRemovalEvent, i_instanceLock ); + i_instanceLock.reset(); + + // rebuild the index + impl_reIndex_nothrow( m_currentSortColumn, m_sortAscending ); + + // broadcast an artificial event, saying that n rows have been added + GridDataEvent const aAdditionEvent( *this, -1, -1, 0, m_delegator->getRowCount() - 1 ); + impl_broadcast( &XGridDataListener::rowsInserted, aAdditionEvent, i_instanceLock ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::rowsRemoved( const GridDataEvent& i_event ) throw (RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + + // if the data is not sorted, broadcast the event unchanged + if ( !impl_isSorted_nothrow() ) + { + GridDataEvent const aEvent( impl_createPublicEvent( i_event ) ); + impl_broadcast( &XGridDataListener::rowsRemoved, aEvent, aGuard ); + return; + } + + // if all rows have been removed, also simply multiplex to own listeners + if ( i_event.FirstRow < 0 ) + { + lcl_clear( m_publicToPrivateRowIndex ); + lcl_clear( m_privateToPublicRowIndex ); + GridDataEvent aEvent( i_event ); + aEvent.Source = *this; + impl_broadcast( &XGridDataListener::rowsRemoved, aEvent, aGuard ); + return; + } + + bool needReIndex = false; + if ( i_event.FirstRow != i_event.LastRow ) + { + OSL_ENSURE( false, "SortableGridDataModel::rowsRemoved: missing implementation - removal of multiple rows!" ); + needReIndex = true; + } + else if ( size_t( i_event.FirstRow ) >= m_privateToPublicRowIndex.size() ) + { + OSL_ENSURE( false, "SortableGridDataModel::rowsRemoved: inconsistent/wrong data!" ); + needReIndex = true; + } + + if ( needReIndex ) + { + impl_rebuildIndexesAndNotify( aGuard ); + return; + } + + // build public event version + GridDataEvent const aEvent( impl_createPublicEvent( i_event ) ); + + // remove the entries from the index maps + sal_Int32 const privateIndex = i_event.FirstRow; + sal_Int32 const publicIndex = aEvent.FirstRow; + + m_publicToPrivateRowIndex.erase( m_publicToPrivateRowIndex.begin() + publicIndex ); + m_privateToPublicRowIndex.erase( m_privateToPublicRowIndex.begin() + privateIndex ); + + // adjust remaining entries in the index maps + lcl_decrementValuesGreaterThan( m_publicToPrivateRowIndex, privateIndex ); + lcl_decrementValuesGreaterThan( m_privateToPublicRowIndex, publicIndex ); + + // broadcast the event + impl_broadcast( &XGridDataListener::rowsRemoved, aEvent, aGuard ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::dataChanged( const GridDataEvent& i_event ) throw (RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + + GridDataEvent const aEvent( impl_createPublicEvent( i_event ) ); + impl_broadcast( &XGridDataListener::dataChanged, aEvent, aGuard ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::rowHeadingChanged( const GridDataEvent& i_event ) throw (RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + + GridDataEvent const aEvent( impl_createPublicEvent( i_event ) ); + impl_broadcast( &XGridDataListener::rowHeadingChanged, aEvent, aGuard ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::disposing( const EventObject& i_event ) throw (RuntimeException) + { + // not interested in + OSL_UNUSED( i_event ); + } + + //------------------------------------------------------------------------------------------------------------------ + namespace + { + class CellDataLessComparison : public ::std::binary_function< sal_Int32, sal_Int32, bool > + { + public: + CellDataLessComparison( + ::std::vector< Any > const & i_data, + ::comphelper::IKeyPredicateLess& i_predicate, + sal_Bool const i_sortAscending + ) + :m_data( i_data ) + ,m_predicate( i_predicate ) + ,m_sortAscending( i_sortAscending ) + { + } + + bool operator()( sal_Int32 const i_lhs, sal_Int32 const i_rhs ) const + { + Any const & lhs = m_data[ i_lhs ]; + Any const & rhs = m_data[ i_rhs ]; + // <VOID/> is less than everything else + if ( !lhs.hasValue() ) + return m_sortAscending; + if ( !rhs.hasValue() ) + return !m_sortAscending; + + // actually compare + if ( m_sortAscending ) + return m_predicate.isLess( lhs, rhs ); + else + return m_predicate.isLess( rhs, lhs ); + } + + private: + ::std::vector< Any > const & m_data; + ::comphelper::IKeyPredicateLess const & m_predicate; + sal_Bool const m_sortAscending; + }; + } + + //------------------------------------------------------------------------------------------------------------------ + void SortableGridDataModel::impl_reIndex_nothrow( ::sal_Int32 const i_columnIndex, sal_Bool const i_sortAscending ) + { + ::sal_Int32 const rowCount( getRowCount() ); + ::std::vector< ::sal_Int32 > aPublicToPrivate( rowCount ); + + try + { + // build an unsorted translation table, and retrieve the unsorted data + ::std::vector< Any > aColumnData( rowCount ); + Type dataType; + for ( ::sal_Int32 rowIndex = 0; rowIndex < rowCount; ++rowIndex ) + { + aColumnData[ rowIndex ] = m_delegator->getCellData( i_columnIndex, rowIndex ); + aPublicToPrivate[ rowIndex ] = rowIndex; + + // determine the data types we assume for the complete column + if ( ( dataType.getTypeClass() == TypeClass_VOID ) && aColumnData[ rowIndex ].hasValue() ) + dataType = aColumnData[ rowIndex ].getValueType(); + } + + // get predicate object + ::std::auto_ptr< ::comphelper::IKeyPredicateLess > const pPredicate( ::comphelper::getStandardLessPredicate( dataType, m_collator ) ); + ENSURE_OR_RETURN_VOID( pPredicate.get(), "SortableGridDataModel::impl_reIndex_nothrow: no sortable data found!" ); + + // then sort + CellDataLessComparison const aComparator( aColumnData, *pPredicate, i_sortAscending ); + ::std::sort( aPublicToPrivate.begin(), aPublicToPrivate.end(), aComparator ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + return; + } + + // also build the "private to public" mapping + ::std::vector< sal_Int32 > aPrivateToPublic( aPublicToPrivate.size() ); + for ( size_t i=0; i<aPublicToPrivate.size(); ++i ) + aPrivateToPublic[ aPublicToPrivate[i] ] = i; + + m_publicToPrivateRowIndex.swap( aPublicToPrivate ); + m_privateToPublicRowIndex.swap( aPrivateToPublic ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::sortByColumn( ::sal_Int32 i_columnIndex, ::sal_Bool i_sortAscending ) throw (IndexOutOfBoundsException, RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + + if ( ( i_columnIndex < 0 ) || ( i_columnIndex >= getColumnCount() ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); + + impl_reIndex_nothrow( i_columnIndex, i_sortAscending ); + + m_currentSortColumn = i_columnIndex; + m_sortAscending = i_sortAscending; + + impl_broadcast( + &XGridDataListener::dataChanged, + GridDataEvent( *this, -1, -1, -1, -1 ), + aGuard + ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::removeColumnSort( ) throw (RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + + lcl_clear( m_publicToPrivateRowIndex ); + lcl_clear( m_privateToPublicRowIndex ); + + m_currentSortColumn = -1; + m_sortAscending = sal_True; + + impl_broadcast( + &XGridDataListener::dataChanged, + GridDataEvent( *this, -1, -1, -1, -1 ), + aGuard + ); + } + + //------------------------------------------------------------------------------------------------------------------ + Pair< ::sal_Int32, ::sal_Bool > SAL_CALL SortableGridDataModel::getCurrentSortOrder( ) throw (RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + + return Pair< ::sal_Int32, ::sal_Bool >( m_currentSortColumn, m_sortAscending ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::addRow( const Any& i_heading, const Sequence< Any >& i_data ) throw (RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + + Reference< XMutableGridDataModel > const delegator( m_delegator ); + aGuard.clear(); + delegator->addRow( i_heading, i_data ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::addRows( const Sequence< Any >& i_headings, const Sequence< Sequence< Any > >& i_data ) throw (IllegalArgumentException, RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + + Reference< XMutableGridDataModel > const delegator( m_delegator ); + aGuard.clear(); + delegator->addRows( i_headings, i_data ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::removeRow( ::sal_Int32 i_rowIndex ) throw (IndexOutOfBoundsException, RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + + ::sal_Int32 const rowIndex = impl_getPrivateRowIndex_throw( i_rowIndex ); + + Reference< XMutableGridDataModel > const delegator( m_delegator ); + aGuard.clear(); + delegator->removeRow( rowIndex ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::removeAllRows( ) throw (RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + + Reference< XMutableGridDataModel > const delegator( m_delegator ); + aGuard.clear(); + delegator->removeAllRows(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::updateCellData( ::sal_Int32 i_columnIndex, ::sal_Int32 i_rowIndex, const Any& i_value ) throw (IndexOutOfBoundsException, RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + + ::sal_Int32 const rowIndex = impl_getPrivateRowIndex_throw( i_rowIndex ); + + Reference< XMutableGridDataModel > const delegator( m_delegator ); + aGuard.clear(); + delegator->updateCellData( i_columnIndex, rowIndex, i_value ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::updateRowData( const Sequence< ::sal_Int32 >& i_columnIndexes, ::sal_Int32 i_rowIndex, const Sequence< Any >& i_values ) throw (IndexOutOfBoundsException, IllegalArgumentException, RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + + ::sal_Int32 const rowIndex = impl_getPrivateRowIndex_throw( i_rowIndex ); + + Reference< XMutableGridDataModel > const delegator( m_delegator ); + aGuard.clear(); + delegator->updateRowData( i_columnIndexes, rowIndex, i_values ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::updateRowHeading( ::sal_Int32 i_rowIndex, const Any& i_heading ) throw (IndexOutOfBoundsException, RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + + ::sal_Int32 const rowIndex = impl_getPrivateRowIndex_throw( i_rowIndex ); + + Reference< XMutableGridDataModel > const delegator( m_delegator ); + aGuard.clear(); + delegator->updateRowHeading( rowIndex, i_heading ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::updateCellToolTip( ::sal_Int32 i_columnIndex, ::sal_Int32 i_rowIndex, const Any& i_value ) throw (IndexOutOfBoundsException, RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + + ::sal_Int32 const rowIndex = impl_getPrivateRowIndex_throw( i_rowIndex ); + + Reference< XMutableGridDataModel > const delegator( m_delegator ); + aGuard.clear(); + delegator->updateCellToolTip( i_columnIndex, rowIndex, i_value ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::updateRowToolTip( ::sal_Int32 i_rowIndex, const Any& i_value ) throw (IndexOutOfBoundsException, RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + + ::sal_Int32 const rowIndex = impl_getPrivateRowIndex_throw( i_rowIndex ); + + Reference< XMutableGridDataModel > const delegator( m_delegator ); + aGuard.clear(); + delegator->updateRowToolTip( rowIndex, i_value ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::addGridDataListener( const Reference< XGridDataListener >& i_listener ) throw (RuntimeException) + { + rBHelper.addListener( XGridDataListener::static_type(), i_listener ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::removeGridDataListener( const Reference< XGridDataListener >& i_listener ) throw (RuntimeException) + { + rBHelper.removeListener( XGridDataListener::static_type(), i_listener ); + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL SortableGridDataModel::getRowCount() throw (RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + + Reference< XMutableGridDataModel > const delegator( m_delegator ); + aGuard.clear(); + return delegator->getRowCount(); + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL SortableGridDataModel::getColumnCount() throw (RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + + Reference< XMutableGridDataModel > const delegator( m_delegator ); + aGuard.clear(); + return delegator->getColumnCount(); + } + + //------------------------------------------------------------------------------------------------------------------ + Any SAL_CALL SortableGridDataModel::getCellData( ::sal_Int32 i_columnIndex, ::sal_Int32 i_rowIndex ) throw (IndexOutOfBoundsException, RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + + ::sal_Int32 const rowIndex = impl_getPrivateRowIndex_throw( i_rowIndex ); + + Reference< XMutableGridDataModel > const delegator( m_delegator ); + aGuard.clear(); + return delegator->getCellData( i_columnIndex, rowIndex ); + } + + //------------------------------------------------------------------------------------------------------------------ + Any SAL_CALL SortableGridDataModel::getCellToolTip( ::sal_Int32 i_columnIndex, ::sal_Int32 i_rowIndex ) throw (IndexOutOfBoundsException, RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + + ::sal_Int32 const rowIndex = impl_getPrivateRowIndex_throw( i_rowIndex ); + + Reference< XMutableGridDataModel > const delegator( m_delegator ); + aGuard.clear(); + return delegator->getCellToolTip( i_columnIndex, rowIndex ); + } + + //------------------------------------------------------------------------------------------------------------------ + Any SAL_CALL SortableGridDataModel::getRowHeading( ::sal_Int32 i_rowIndex ) throw (IndexOutOfBoundsException, RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + + ::sal_Int32 const rowIndex = impl_getPrivateRowIndex_throw( i_rowIndex ); + + Reference< XMutableGridDataModel > const delegator( m_delegator ); + aGuard.clear(); + return delegator->getRowHeading( rowIndex ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::disposing() + { + m_currentSortColumn = -1; + + Reference< XComponent > const delegatorComponent( m_delegator.get() ); + m_delegator->removeGridDataListener( this ); + m_delegator.clear(); + delegatorComponent->dispose(); + + Reference< XComponent > const collatorComponent( m_collator, UNO_QUERY ); + m_collator.clear(); + if ( collatorComponent.is() ) + collatorComponent->dispose(); + + lcl_clear( m_publicToPrivateRowIndex ); + lcl_clear( m_privateToPublicRowIndex ); + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XCloneable > SAL_CALL SortableGridDataModel::createClone( ) throw (RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + + return new SortableGridDataModel( *this ); + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL SortableGridDataModel::getImplementationName( ) throw (RuntimeException) + { + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.toolkit.SortableGridDataModel" ) ); + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Bool SAL_CALL SortableGridDataModel::supportsService( const ::rtl::OUString& i_serviceName ) throw (RuntimeException) + { + Sequence< ::rtl::OUString > const aServiceNames( getSupportedServiceNames() ); + for ( sal_Int32 i=0; i<aServiceNames.getLength(); ++i ) + if ( aServiceNames[i] == i_serviceName ) + return sal_True; + return sal_False; + } + + //------------------------------------------------------------------------------------------------------------------ + Sequence< ::rtl::OUString > SAL_CALL SortableGridDataModel::getSupportedServiceNames( ) throw (RuntimeException) + { + Sequence< ::rtl::OUString > aServiceNames(1); + aServiceNames[0] = ::rtl::OUString::createFromAscii( szServiceName_SortableGridDataModel ); + return aServiceNames; + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SortableGridDataModel::impl_getPrivateRowIndex_throw( ::sal_Int32 const i_publicRowIndex ) const + { + if ( ( i_publicRowIndex < 0 ) || ( i_publicRowIndex >= m_delegator->getRowCount() ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *const_cast< SortableGridDataModel* >( this ) ); + + if ( !impl_isSorted_nothrow() ) + // no need to translate anything + return i_publicRowIndex; + + ENSURE_OR_RETURN( size_t( i_publicRowIndex ) < m_publicToPrivateRowIndex.size(), + "SortableGridDataModel::impl_getPrivateRowIndex_throw: inconsistency!", i_publicRowIndex ); + // obviously the translation table contains too few elements - it should have exactly |getRowCount()| + // elements + + return m_publicToPrivateRowIndex[ i_publicRowIndex ]; + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SortableGridDataModel::impl_getPublicRowIndex_nothrow( ::sal_Int32 const i_privateRowIndex ) const + { + if ( !impl_isSorted_nothrow() ) + // no need to translate anything + return i_privateRowIndex; + + if ( i_privateRowIndex < 0 ) + return i_privateRowIndex; + + ENSURE_OR_RETURN( size_t( i_privateRowIndex ) < m_privateToPublicRowIndex.size(), + "SortableGridDataModel::impl_getPublicRowIndex_nothrow: invalid index!", i_privateRowIndex ); + + return m_privateToPublicRowIndex[ i_privateRowIndex ]; + } + +//...................................................................................................................... +} // namespace toolkit +//...................................................................................................................... + +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SortableGridDataModel_CreateInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ) +{ + return *( new ::toolkit::SortableGridDataModel( i_factory ) ); +} diff --git a/toolkit/source/controls/grid/sortablegriddatamodel.hxx b/toolkit/source/controls/grid/sortablegriddatamodel.hxx new file mode 100755 index 000000000000..50f08d3a7113 --- /dev/null +++ b/toolkit/source/controls/grid/sortablegriddatamodel.hxx @@ -0,0 +1,198 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General 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 TOOLKIT_SORTABLEGRIDDATAMODEL_HXX +#define TOOLKIT_SORTABLEGRIDDATAMODEL_HXX + +#include "initguard.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/awt/grid/XSortableMutableGridDataModel.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/i18n/XCollator.hpp> +#include <com/sun/star/awt/grid/XGridDataListener.hpp> +/** === end UNO includes === **/ + +#include <comphelper/componentcontext.hxx> +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/compbase3.hxx> +#include <cppuhelper/implbase1.hxx> + +//...................................................................................................................... +namespace toolkit +{ +//...................................................................................................................... + + class SortableGridDataModel; + typedef InitGuard< SortableGridDataModel > MethodGuard; + + //================================================================================================================== + //= SortableGridDataModel + //================================================================================================================== + typedef ::cppu::WeakComponentImplHelper3 < ::com::sun::star::awt::grid::XSortableMutableGridDataModel + , ::com::sun::star::lang::XServiceInfo + , ::com::sun::star::lang::XInitialization + > SortableGridDataModel_Base; + typedef ::cppu::ImplHelper1 < ::com::sun::star::awt::grid::XGridDataListener + > SortableGridDataModel_PrivateBase; + class SortableGridDataModel :public ::cppu::BaseMutex + ,public SortableGridDataModel_Base + ,public SortableGridDataModel_PrivateBase + { + public: + SortableGridDataModel( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > const & i_factory ); + SortableGridDataModel( SortableGridDataModel const & i_copySource ); + + bool isInitialized() const { return m_isInitialized; } + +#ifdef DBG_UTIL + const char* checkInvariants() const; +#endif + + protected: + ~SortableGridDataModel(); + + public: + // XSortableGridData + virtual void SAL_CALL sortByColumn( ::sal_Int32 ColumnIndex, ::sal_Bool SortAscending ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeColumnSort( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::beans::Pair< ::sal_Int32, ::sal_Bool > SAL_CALL getCurrentSortOrder( ) throw (::com::sun::star::uno::RuntimeException); + + // XMutableGridDataModel + virtual void SAL_CALL addRow( const ::com::sun::star::uno::Any& Heading, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Data ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addRows( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Headings, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& Data ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeRow( ::sal_Int32 RowIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeAllRows( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateCellData( ::sal_Int32 ColumnIndex, ::sal_Int32 RowIndex, const ::com::sun::star::uno::Any& Value ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateRowData( const ::com::sun::star::uno::Sequence< ::sal_Int32 >& ColumnIndexes, ::sal_Int32 RowIndex, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Values ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateRowHeading( ::sal_Int32 RowIndex, const ::com::sun::star::uno::Any& Heading ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateCellToolTip( ::sal_Int32 ColumnIndex, ::sal_Int32 RowIndex, const ::com::sun::star::uno::Any& Value ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL updateRowToolTip( ::sal_Int32 RowIndex, const ::com::sun::star::uno::Any& Value ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addGridDataListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeGridDataListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataListener >& Listener ) throw (::com::sun::star::uno::RuntimeException); + + // XGridDataModel + virtual ::sal_Int32 SAL_CALL getRowCount() throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getColumnCount() throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getCellData( ::sal_Int32 Column, ::sal_Int32 Row ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getCellToolTip( ::sal_Int32 Column, ::sal_Int32 Row ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getRowHeading( ::sal_Int32 RowIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + + // OComponentHelper + virtual void SAL_CALL disposing(); + + // XCloneable + virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) 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); + + // 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); + + // XGridDataListener + virtual void SAL_CALL rowsInserted( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL rowsRemoved( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL dataChanged( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL rowHeadingChanged( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + + // XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& i_event ) throw (::com::sun::star::uno::RuntimeException); + + // 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 (); + + // 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); + + private: + /** translates the given public index into one to be passed to our delegator + @throws ::com::sun::star::lang::IndexOutOfBoundsException + if the given index does not denote a valid row + */ + ::sal_Int32 impl_getPrivateRowIndex_throw( ::sal_Int32 const i_publicRowIndex ) const; + + /** translates the given private row index to a public one + */ + ::sal_Int32 impl_getPublicRowIndex_nothrow( ::sal_Int32 const i_privateRowIndex ) const; + + inline bool impl_isSorted_nothrow() const + { + return m_currentSortColumn >= 0; + } + + /** rebuilds the index translation structure. + + Neither <member>m_currentSortColumn</member> nor <member>m_sortAscending</member> are touched by this method. + Also, the given column index is not checked, this is the responsibility of the caller. + */ + void impl_reIndex_nothrow( ::sal_Int32 const i_columnIndex, sal_Bool const i_sortAscending ); + + /** translates the given event, obtained from our delegator, to a version which can be broadcasted to our own + clients. + */ + ::com::sun::star::awt::grid::GridDataEvent + impl_createPublicEvent( ::com::sun::star::awt::grid::GridDataEvent const & i_originalEvent ) const; + + /** broadcasts the given event to our registered XGridDataListeners + */ + void impl_broadcast( + void ( SAL_CALL ::com::sun::star::awt::grid::XGridDataListener::*i_listenerMethod )( const ::com::sun::star::awt::grid::GridDataEvent & ), + ::com::sun::star::awt::grid::GridDataEvent const & i_publicEvent, + MethodGuard& i_instanceLock + ); + + /** rebuilds our indexes, notifying row removal and row addition events + + First, a rowsRemoved event is notified to our registered listeners. Then, the index translation tables are + rebuilt, and a rowsInserted event is notified. + + Only to be called when we're sorted. + */ + void impl_rebuildIndexesAndNotify( MethodGuard& i_instanceLock ); + + private: + ::comphelper::ComponentContext m_context; + bool m_isInitialized; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XMutableGridDataModel > m_delegator; + ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XCollator > m_collator; + ::sal_Int32 m_currentSortColumn; + ::sal_Bool m_sortAscending; + ::std::vector< ::sal_Int32 > m_publicToPrivateRowIndex; + ::std::vector< ::sal_Int32 > m_privateToPublicRowIndex; + }; + +//...................................................................................................................... +} // namespace toolkit +//...................................................................................................................... + +#endif // TOOLKIT_SORTABLEGRIDDATAMODEL_HXX diff --git a/toolkit/source/controls/makefile.mk b/toolkit/source/controls/makefile.mk deleted file mode 100644 index 1ce9f7b22c8c..000000000000 --- a/toolkit/source/controls/makefile.mk +++ /dev/null @@ -1,66 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=..$/.. - -PRJNAME=toolkit -TARGET=controls - -ENABLE_EXCEPTIONS=TRUE - -# --- Settings ----------------------------------------------------- - -.INCLUDE : settings.mk -.INCLUDE : $(PRJ)$/util$/makefile.pmk - - -# --- Files -------------------------------------------------------- - -SLOFILES= \ - $(SLO)$/accessiblecontrolcontext.obj \ - $(SLO)$/geometrycontrolmodel.obj \ - $(SLO)$/eventcontainer.obj \ - $(SLO)$/stdtabcontroller.obj \ - $(SLO)$/stdtabcontrollermodel.obj \ - $(SLO)$/unocontrol.obj \ - $(SLO)$/unocontrolbase.obj \ - $(SLO)$/unocontrolcontainer.obj \ - $(SLO)$/unocontrolcontainermodel.obj \ - $(SLO)$/unocontrolmodel.obj \ - $(SLO)$/unocontrols.obj \ - $(SLO)$/formattedcontrol.obj \ - $(SLO)$/roadmapcontrol.obj \ - $(SLO)$/roadmapentry.obj \ - $(SLO)$/dialogcontrol.obj \ - $(SLO)$/tkscrollbar.obj \ - $(SLO)$/tkspinbutton.obj \ - $(SLO)$/tksimpleanimation.obj \ - $(SLO)$/tkthrobber.obj - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk diff --git a/toolkit/source/controls/roadmapcontrol.cxx b/toolkit/source/controls/roadmapcontrol.cxx index adb38b8ca05c..f72e4126e527 100644 --- a/toolkit/source/controls/roadmapcontrol.cxx +++ b/toolkit/source/controls/roadmapcontrol.cxx @@ -65,7 +65,9 @@ static void lcl_throwIndexOutOfBoundsException( ) // = UnoControlRoadmapModel // =================================================================== // ------------------------------------------------------------------- - UnoControlRoadmapModel::UnoControlRoadmapModel() : maContainerListeners( *this ) + UnoControlRoadmapModel::UnoControlRoadmapModel( const Reference< XMultiServiceFactory >& i_factory ) + :UnoControlRoadmapModel_Base( i_factory ) + ,maContainerListeners( *this ) { ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR ); ImplRegisterProperty( BASEPROPERTY_BORDER ); @@ -367,7 +369,9 @@ static void lcl_throwIndexOutOfBoundsException( ) // = UnoRoadmapControl // =================================================================== // ------------------------------------------------------------------- - UnoRoadmapControl::UnoRoadmapControl(): maItemListeners( *this ) + UnoRoadmapControl::UnoRoadmapControl( const Reference< XMultiServiceFactory >& i_factory ) + :UnoControlRoadmap_Base( i_factory ) + ,maItemListeners( *this ) { } diff --git a/toolkit/source/controls/spinningprogress.cxx b/toolkit/source/controls/spinningprogress.cxx new file mode 100755 index 000000000000..cb02274e3997 --- /dev/null +++ b/toolkit/source/controls/spinningprogress.cxx @@ -0,0 +1,140 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General 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_toolkit.hxx" + +#include "toolkit/controls/spinningprogress.hxx" +#include "toolkit/helper/servicenames.hxx" +#include "toolkit/helper/unopropertyarrayhelper.hxx" + +/** === begin UNO includes === **/ +/** === end UNO includes === **/ + +#include <rtl/ustrbuf.hxx> +#include <tools/diagnose_ex.h> +#include <vcl/throbber.hxx> + +//...................................................................................................................... +namespace toolkit +{ +//...................................................................................................................... + + /** === 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::XPropertySetInfo; + using ::com::sun::star::lang::XMultiServiceFactory; + /** === end UNO using === **/ + + //================================================================================================================== + //= SpinningProgressControlModel + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + SpinningProgressControlModel::SpinningProgressControlModel( Reference< XMultiServiceFactory > const & i_factory ) + :SpinningProgressControlModel_Base( i_factory ) + { + // default image sets + osl_incrementInterlockedCount( &m_refCount ); + { + try + { + Throbber::ImageSet aImageSets[] = + { + Throbber::IMAGES_16_PX, Throbber::IMAGES_32_PX, Throbber::IMAGES_64_PX + }; + for ( size_t i=0; i < sizeof( aImageSets ) / sizeof( aImageSets[0] ); ++i ) + { + const ::std::vector< ::rtl::OUString > aDefaultURLs( Throbber::getDefaultImageURLs( aImageSets[i] ) ); + const Sequence< ::rtl::OUString > aImageURLs( &aDefaultURLs[0], aDefaultURLs.size() ); + insertImageSet( i, aImageURLs ); + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + osl_decrementInterlockedCount( &m_refCount ); + } + + //------------------------------------------------------------------------------------------------------------------ + SpinningProgressControlModel::SpinningProgressControlModel( const SpinningProgressControlModel& i_copySource ) + :SpinningProgressControlModel_Base( i_copySource ) + { + } + + //------------------------------------------------------------------------------------------------------------------ + SpinningProgressControlModel::~SpinningProgressControlModel() + { + } + + //------------------------------------------------------------------------------------------------------------------ + UnoControlModel* SpinningProgressControlModel::Clone() const + { + return new SpinningProgressControlModel( *this ); + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XPropertySetInfo > SAL_CALL SpinningProgressControlModel::getPropertySetInfo( ) throw(RuntimeException) + { + static Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); + return xInfo; + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL SpinningProgressControlModel::getServiceName() throw(RuntimeException) + { + return ::rtl::OUString::createFromAscii( szServiceName_SpinningProgressControlModel ); + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL SpinningProgressControlModel::getImplementationName( ) throw(RuntimeException) + { + return ::rtl::OUString::createFromAscii( "org.openoffice.comp.toolkit.SpinningProgressControlModel" ); + } + + //------------------------------------------------------------------------------------------------------------------ + Sequence< ::rtl::OUString > SAL_CALL SpinningProgressControlModel::getSupportedServiceNames() throw(RuntimeException) + { + Sequence< ::rtl::OUString > aServiceNames(3); + aServiceNames[0] = ::rtl::OUString::createFromAscii( szServiceName_SpinningProgressControlModel ); + aServiceNames[1] = ::rtl::OUString::createFromAscii( szServiceName_AnimatedImagesControlModel ); + aServiceNames[2] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.UnoControlModel" ); + return aServiceNames; + } + +//...................................................................................................................... +} // namespace toolkit +//...................................................................................................................... diff --git a/toolkit/source/controls/tabpagecontainer.cxx b/toolkit/source/controls/tabpagecontainer.cxx new file mode 100644 index 000000000000..222f98105c9a --- /dev/null +++ b/toolkit/source/controls/tabpagecontainer.cxx @@ -0,0 +1,294 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_toolkit.hxx" + +#include <toolkit/controls/tabpagecontainer.hxx> + +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <toolkit/helper/unopropertyarrayhelper.hxx> +#include <toolkit/helper/property.hxx> +#include <toolkit/controls/geometrycontrolmodel.hxx> +#include <com/sun/star/awt/XVclWindowPeer.hpp> +#include <comphelper/processfactory.hxx> +#include <osl/diagnose.h> +#include <vcl/svapp.hxx> +#include <com/sun/star/awt/XControlModel.hpp> +#include <tools/diagnose_ex.h> + +using ::rtl::OUString; +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::container; +using namespace ::com::sun::star::view; + +#define WRONG_TYPE_EXCEPTION "Type must be ::com::sun::star::awt::tab::XTabPageModel!" +// ---------------------------------------------------- +// class UnoControlTabPageContainerModel +// ---------------------------------------------------- +UnoControlTabPageContainerModel::UnoControlTabPageContainerModel( const Reference< XMultiServiceFactory >& i_factory ) + :UnoControlTabPageContainerModel_Base( i_factory ) + ,maContainerListeners( *this ) +{ + ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR ); + ImplRegisterProperty( BASEPROPERTY_BORDER ); + ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR ); + ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL ); + ImplRegisterProperty( BASEPROPERTY_ENABLED ); + ImplRegisterProperty( BASEPROPERTY_HELPTEXT ); + ImplRegisterProperty( BASEPROPERTY_HELPURL ); + ImplRegisterProperty( BASEPROPERTY_PRINTABLE ); + ImplRegisterProperty( BASEPROPERTY_TEXT ); +} + +::rtl::OUString UnoControlTabPageContainerModel::getServiceName() throw(RuntimeException) +{ + return ::rtl::OUString::createFromAscii( szServiceName_UnoControlTabPageContainerModel ); +} + +uno::Any UnoControlTabPageContainerModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const +{ + switch(nPropId) + { + case BASEPROPERTY_DEFAULTCONTROL: + return uno::makeAny( ::rtl::OUString::createFromAscii( szServiceName_UnoControlTabPageContainer ) ); + case BASEPROPERTY_BORDER: + return uno::makeAny((sal_Int16) 0); // No Border + default: + return UnoControlModel::ImplGetDefaultValue( nPropId ); + } +} + +::cppu::IPropertyArrayHelper& UnoControlTabPageContainerModel::getInfoHelper() +{ + static UnoPropertyArrayHelper* pHelper = NULL; + if ( !pHelper ) + { + com::sun::star::uno::Sequence<sal_Int32> aIDs = ImplGetPropertyIds(); + pHelper = new UnoPropertyArrayHelper( aIDs ); + } + return *pHelper; +} +Reference< ::com::sun::star::beans::XPropertySetInfo > UnoControlTabPageContainerModel::getPropertySetInfo( ) throw(RuntimeException) +{ + static Reference< ::com::sun::star::beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); + return xInfo; +} + +void SAL_CALL UnoControlTabPageContainerModel::insertByIndex( ::sal_Int32 nIndex, const com::sun::star::uno::Any& aElement) throw (IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, uno::RuntimeException) +{ + SolarMutexGuard aSolarGuard; + uno::Reference < ::awt::tab::XTabPageModel > xTabPageModel; + if(aElement >>= xTabPageModel) + { + if ( sal_Int32( m_aTabPageVector.size()) ==nIndex ) + m_aTabPageVector.push_back( xTabPageModel ); + else if ( sal_Int32( m_aTabPageVector.size()) > nIndex ) + { + std::vector< uno::Reference< ::awt::tab::XTabPageModel > >::iterator aIter = m_aTabPageVector.begin(); + aIter += nIndex; + m_aTabPageVector.insert( aIter, xTabPageModel ); + } + else + throw IndexOutOfBoundsException( ::rtl::OUString(), (OWeakObject *)this ); + ContainerEvent aEvent; + aEvent.Source = *this; + aEvent.Element <<= aElement; + aEvent.Accessor <<= ::rtl::OUString::valueOf(nIndex); + maContainerListeners.elementInserted( aEvent ); + } + else + throw IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( WRONG_TYPE_EXCEPTION )), + (OWeakObject *)this, 2 ); +} +// ----------------------------------------------------------------------------- +void SAL_CALL UnoControlTabPageContainerModel::removeByIndex( ::sal_Int32 /*Index*/ ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ +} +// XIndexReplace +void SAL_CALL UnoControlTabPageContainerModel::replaceByIndex( ::sal_Int32 /*Index*/, const uno::Any& /*Element*/ ) throw (lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ +} +// ----------------------------------------------------------------------------- +// XIndexAccess +::sal_Int32 SAL_CALL UnoControlTabPageContainerModel::getCount( ) throw (uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + return sal_Int32( m_aTabPageVector.size()); +} +// ----------------------------------------------------------------------------- +uno::Any SAL_CALL UnoControlTabPageContainerModel::getByIndex( ::sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + if ( nIndex < 0 || nIndex > sal_Int32(m_aTabPageVector.size()) ) + throw lang::IndexOutOfBoundsException(); + return uno::makeAny(m_aTabPageVector[nIndex]); +} +// ----------------------------------------------------------------------------- +// XElementAccess +uno::Type SAL_CALL UnoControlTabPageContainerModel::getElementType( ) throw (uno::RuntimeException) +{ + return ::getCppuType(static_cast< Reference< com::sun::star::awt::XControlModel>* >(NULL)); +} +// ----------------------------------------------------------------------------- +::sal_Bool SAL_CALL UnoControlTabPageContainerModel::hasElements( ) throw (uno::RuntimeException) +{ + ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + return !m_aTabPageVector.empty(); +} +// XContainer +void UnoControlTabPageContainerModel::addContainerListener( const Reference< XContainerListener >& l ) throw(RuntimeException) +{ + maContainerListeners.addInterface( l ); +} + +void UnoControlTabPageContainerModel::removeContainerListener( const Reference< XContainerListener >& l ) throw(RuntimeException) +{ + maContainerListeners.removeInterface( l ); +} + +// ---------------------------------------------------- +// class UnoControlTabPageContainer +// ---------------------------------------------------- +UnoControlTabPageContainer::UnoControlTabPageContainer( const Reference< XMultiServiceFactory >& i_factory ) + :UnoControlTabPageContainer_Base( i_factory ) + ,m_aTabPageListeners( *this ) +{ +} + +OUString UnoControlTabPageContainer::GetComponentServiceName() +{ + return OUString::createFromAscii( "TabPageContainer" ); +} + +void SAL_CALL UnoControlTabPageContainer::dispose( ) throw(RuntimeException) +{ + lang::EventObject aEvt; + aEvt.Source = (::cppu::OWeakObject*)this; + m_aTabPageListeners.disposeAndClear( aEvt ); + UnoControl::dispose(); +} + +void UnoControlTabPageContainer::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException) +{ + UnoControlBase::createPeer( rxToolkit, rParentPeer ); + + Reference< XTabPageContainer > xTPContainer( getPeer(), UNO_QUERY_THROW ); + if ( m_aTabPageListeners.getLength() ) + xTPContainer->addTabPageListener(&m_aTabPageListeners); +} + +// ------------------------------------------------------------------- +// XTabPageContainer + +::sal_Int16 SAL_CALL UnoControlTabPageContainer::getActiveTabPageID() throw (RuntimeException) +{ + SolarMutexGuard aSolarGuard; + Reference< XTabPageContainer > xTPContainer( getPeer(), UNO_QUERY_THROW ); + return xTPContainer->getActiveTabPageID(); +} +void SAL_CALL UnoControlTabPageContainer::setActiveTabPageID( ::sal_Int16 _activetabpageid ) throw (RuntimeException) +{ + SolarMutexGuard aSolarGuard; + Reference< XTabPageContainer > xTPContainer( getPeer(), UNO_QUERY_THROW ); + xTPContainer->setActiveTabPageID(_activetabpageid); +} +::sal_Int32 SAL_CALL UnoControlTabPageContainer::getTabPageCount( ) throw (RuntimeException) +{ + SolarMutexGuard aSolarGuard; + Reference< XTabPageContainer > xTPContainer( getPeer(), UNO_QUERY_THROW ); + return xTPContainer->getTabPageCount(); +} +::sal_Bool SAL_CALL UnoControlTabPageContainer::isTabPageActive( ::sal_Int16 tabPageIndex ) throw (RuntimeException) +{ + SolarMutexGuard aSolarGuard; + Reference< XTabPageContainer > xTPContainer( getPeer(), UNO_QUERY_THROW ); + return xTPContainer->isTabPageActive(tabPageIndex); +} +Reference< ::com::sun::star::awt::tab::XTabPage > SAL_CALL UnoControlTabPageContainer::getTabPage( ::sal_Int16 tabPageIndex ) throw (RuntimeException) +{ + SolarMutexGuard aSolarGuard; + Reference< XTabPageContainer > xTPContainer( getPeer(), UNO_QUERY_THROW ); + return xTPContainer->getTabPage(tabPageIndex); +} +Reference< ::com::sun::star::awt::tab::XTabPage > SAL_CALL UnoControlTabPageContainer::getTabPageByID( ::sal_Int16 tabPageID ) throw (RuntimeException) +{ + SolarMutexGuard aSolarGuard; + Reference< XTabPageContainer > xTPContainer( getPeer(), UNO_QUERY_THROW ); + return xTPContainer->getTabPageByID(tabPageID); +} +void SAL_CALL UnoControlTabPageContainer::addTabPageListener( const Reference< ::com::sun::star::awt::tab::XTabPageContainerListener >& listener ) throw (RuntimeException) +{ + m_aTabPageListeners.addInterface( listener ); + if( getPeer().is() && m_aTabPageListeners.getLength() == 1 ) + { + uno::Reference < awt::tab::XTabPageContainer > xTabPageContainer( getPeer(), uno::UNO_QUERY ); + xTabPageContainer->addTabPageListener( &m_aTabPageListeners ); + } +} +void SAL_CALL UnoControlTabPageContainer::removeTabPageListener( const Reference< ::com::sun::star::awt::tab::XTabPageContainerListener >& listener ) throw (RuntimeException) +{ + if( getPeer().is() && m_aTabPageListeners.getLength() == 1 ) + { + uno::Reference < awt::tab::XTabPageContainer > xTabPageContainer( getPeer(), uno::UNO_QUERY ); + xTabPageContainer->addTabPageListener( &m_aTabPageListeners ); + } + m_aTabPageListeners.removeInterface( listener ); +} + +void UnoControlTabPageContainer::updateFromModel() +{ + UnoControlTabPageContainer_Base::updateFromModel(); + Reference< XContainerListener > xContainerListener( getPeer(), UNO_QUERY ); + ENSURE_OR_RETURN_VOID( xContainerListener.is(), "UnoListBoxControl::updateFromModel: a peer which is no ItemListListener?!" ); + + ContainerEvent aEvent; + aEvent.Source = getModel(); + Sequence< Reference< XControl > > aControls = getControls(); + const Reference< XControl >* pCtrls = aControls.getConstArray(); + const Reference< XControl >* pCtrlsEnd = pCtrls + aControls.getLength(); + + for ( ; pCtrls < pCtrlsEnd; ++pCtrls ) + { + aEvent.Element <<= *pCtrls; + xContainerListener->elementInserted( aEvent ); + } +} +void SAL_CALL UnoControlTabPageContainer::addControl( const ::rtl::OUString& Name, const Reference< ::com::sun::star::awt::XControl >& Control ) throw (RuntimeException) +{ + SolarMutexGuard aSolarGuard; + ControlContainerBase::addControl(Name,Control); + Reference< XContainerListener > xContainerListener( getPeer(), UNO_QUERY ); + ContainerEvent aEvent; + aEvent.Source = getModel(); + aEvent.Element <<= Control; + xContainerListener->elementInserted( aEvent ); +} + diff --git a/toolkit/source/controls/tabpagemodel.cxx b/toolkit/source/controls/tabpagemodel.cxx new file mode 100644 index 000000000000..74e3c6b01000 --- /dev/null +++ b/toolkit/source/controls/tabpagemodel.cxx @@ -0,0 +1,395 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_toolkit.hxx" + +#include <vcl/svapp.hxx> +#include <vcl/window.hxx> +#include <vcl/wall.hxx> +#include <toolkit/controls/tabpagemodel.hxx> +#include <toolkit/helper/property.hxx> +#include <toolkit/helper/unopropertyarrayhelper.hxx> +#include <toolkit/controls/stdtabcontroller.hxx> +#include <com/sun/star/awt/PosSize.hpp> +#include <com/sun/star/awt/WindowAttribute.hpp> +#include <com/sun/star/awt/UnoControlDialogModelProvider.hpp> +#include <com/sun/star/resource/XStringResourceResolver.hpp> +#include <com/sun/star/graphic/XGraphicProvider.hpp> +#include <tools/list.hxx> +#include <cppuhelper/typeprovider.hxx> +#include <tools/debug.hxx> +#include <tools/diagnose_ex.h> +#include <comphelper/sequence.hxx> +#include <vcl/svapp.hxx> +#include <vcl/outdev.hxx> + +#include <toolkit/helper/vclunohelper.hxx> +#include <unotools/ucbstreamhelper.hxx> +#include <vcl/graph.hxx> +#include <vcl/image.hxx> +#include <toolkit/controls/geometrycontrolmodel.hxx> + +#include <map> +#include <algorithm> +#include <functional> +#include "tools/urlobj.hxx" +#include "osl/file.hxx" + +#include <com/sun/star/beans/XPropertySet.hpp> + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::awt; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::util; + +////HELPER +::rtl::OUString getPhysicalLocation( const ::com::sun::star::uno::Any& rbase, const ::com::sun::star::uno::Any& rUrl ); + +// ---------------------------------------------------- +// class TabPageModel +// ---------------------------------------------------- + +//TabPageModel::TabPageModel() +//{ +//} +//TabPageModel::TabPageModel( uno::Reference< uno::XComponentContext > const & xCompContext) +//{ +// (void) xCompContext; +//} +// +//TabPageModel::~TabPageModel() +//{ +//} +// +//////----- XInitialization ------------------------------------------------------------------- +//void SAL_CALL TabPageModel::initialize (const Sequence<Any>& rArguments) +//{ +// sal_Int16 nPageId; +// if ( rArguments.getLength() == 1 ) +// { +// if ( !( rArguments[ 0 ] >>= nPageId )) +// throw lang::IllegalArgumentException(); +// m_nTabPageId = nPageId; +// } +// else +// m_nTabPageId = -1; +//} +//::sal_Int16 SAL_CALL TabPageModel::getTabPageID() throw (::com::sun::star::uno::RuntimeException) +//{ +// return m_nTabPageId; +//} +//::sal_Bool SAL_CALL TabPageModel::getEnabled() throw (::com::sun::star::uno::RuntimeException) +//{ +// return m_bEnabled; +//} +//void SAL_CALL TabPageModel::setEnabled( ::sal_Bool _enabled ) throw (::com::sun::star::uno::RuntimeException) +//{ +// m_bEnabled = _enabled; +//} +//::rtl::OUString SAL_CALL TabPageModel::getTitle() throw (::com::sun::star::uno::RuntimeException) +//{ +// return m_sTitle; +//} +//void SAL_CALL TabPageModel::setTitle( const ::rtl::OUString& _title ) throw (::com::sun::star::uno::RuntimeException) +//{ +// m_sTitle = _title; +//} +//::rtl::OUString SAL_CALL TabPageModel::getImageURL() throw (::com::sun::star::uno::RuntimeException) +//{ +// return m_sImageURL; +//} +//void SAL_CALL TabPageModel::setImageURL( const ::rtl::OUString& _imageurl ) throw (::com::sun::star::uno::RuntimeException) +//{ +// m_sImageURL = _imageurl; +//} +//::rtl::OUString SAL_CALL TabPageModel::getTooltip() throw (::com::sun::star::uno::RuntimeException) +//{ +// return m_sTooltip; +//} +//void SAL_CALL TabPageModel::setTooltip( const ::rtl::OUString& _tooltip ) throw (::com::sun::star::uno::RuntimeException) +//{ +// m_sTooltip = _tooltip; +//} + +// ---------------------------------------------------- +// class UnoControlTabPageModel +// ---------------------------------------------------- +UnoControlTabPageModel::UnoControlTabPageModel( Reference< XMultiServiceFactory > const & i_factory ) + :ControlModelContainerBase( i_factory ) +{ + ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL ); + ImplRegisterProperty( BASEPROPERTY_TITLE ); + ImplRegisterProperty( BASEPROPERTY_HELPTEXT ); + ImplRegisterProperty( BASEPROPERTY_HELPURL ); + ImplRegisterProperty( BASEPROPERTY_IMAGEURL ); + ImplRegisterProperty( BASEPROPERTY_ENABLED ); +} + +::rtl::OUString UnoControlTabPageModel::getServiceName( ) throw(RuntimeException) +{ + return ::rtl::OUString::createFromAscii( szServiceName_UnoControlTabPageModel ); +} + +Any UnoControlTabPageModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const +{ + Any aAny; + + switch ( nPropId ) + { + case BASEPROPERTY_DEFAULTCONTROL: + aAny <<= ::rtl::OUString::createFromAscii( szServiceName_UnoControlTabPage ); + break; + default: + aAny = UnoControlModel::ImplGetDefaultValue( nPropId ); + } + + return aAny; +} + +::cppu::IPropertyArrayHelper& UnoControlTabPageModel::getInfoHelper() +{ + static UnoPropertyArrayHelper* pHelper = NULL; + if ( !pHelper ) + { + Sequence<sal_Int32> aIDs = ImplGetPropertyIds(); + pHelper = new UnoPropertyArrayHelper( aIDs ); + } + return *pHelper; +} +// beans::XMultiPropertySet +uno::Reference< beans::XPropertySetInfo > UnoControlTabPageModel::getPropertySetInfo( ) throw(uno::RuntimeException) +{ + static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); + return xInfo; +} +////----- XInitialization ------------------------------------------------------------------- +void SAL_CALL UnoControlTabPageModel::initialize (const Sequence<Any>& rArguments) + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException) +{ + sal_Int16 nPageId = -1; + if ( rArguments.getLength() == 1 ) + { + if ( !( rArguments[ 0 ] >>= nPageId )) + throw lang::IllegalArgumentException(); + m_nTabPageId = nPageId; + } + else if ( rArguments.getLength() == 2 ) + { + if ( !( rArguments[ 0 ] >>= nPageId )) + throw lang::IllegalArgumentException(); + m_nTabPageId = nPageId; + ::rtl::OUString sURL; + if ( !( rArguments[ 1 ] >>= sURL )) + throw lang::IllegalArgumentException(); + Reference<container::XNameContainer > xDialogModel = awt::UnoControlDialogModelProvider::create( maContext.getUNOContext(),sURL); + if ( xDialogModel.is() ) + { + Sequence< ::rtl::OUString> aNames = xDialogModel->getElementNames(); + const ::rtl::OUString* pIter = aNames.getConstArray(); + const ::rtl::OUString* pEnd = pIter + aNames.getLength(); + for(;pIter != pEnd;++pIter) + { + try + { + Any aElement(xDialogModel->getByName(*pIter)); + xDialogModel->removeByName(*pIter); + insertByName(*pIter,aElement); + } + catch(const Exception& ex) + { + (void)ex; + } + } + Reference<XPropertySet> xDialogProp(xDialogModel,UNO_QUERY); + if ( xDialogProp.is() ) + { + static const ::rtl::OUString s_sResourceResolver(RTL_CONSTASCII_USTRINGPARAM("ResourceResolver")); + Reference<XPropertySet> xThis(*this,UNO_QUERY); + xThis->setPropertyValue(s_sResourceResolver,xDialogProp->getPropertyValue(s_sResourceResolver)); + xThis->setPropertyValue(GetPropertyName(BASEPROPERTY_TITLE),xDialogProp->getPropertyValue(GetPropertyName(BASEPROPERTY_TITLE))); + xThis->setPropertyValue(GetPropertyName(BASEPROPERTY_IMAGEURL),xDialogProp->getPropertyValue(GetPropertyName(BASEPROPERTY_IMAGEURL))); + xThis->setPropertyValue(GetPropertyName(BASEPROPERTY_HELPTEXT),xDialogProp->getPropertyValue(GetPropertyName(BASEPROPERTY_HELPTEXT))); + xThis->setPropertyValue(GetPropertyName(BASEPROPERTY_ENABLED),xDialogProp->getPropertyValue(GetPropertyName(BASEPROPERTY_ENABLED))); + xThis->setPropertyValue(GetPropertyName(BASEPROPERTY_HELPURL),xDialogProp->getPropertyValue(GetPropertyName(BASEPROPERTY_HELPURL))); + } + } + } + else + m_nTabPageId = -1; +} +//===== Service =============================================================== +::rtl::OUString UnoControlTabPageModel_getImplementationName (void) throw(RuntimeException) +{ + return rtl::OUString::createFromAscii("com.sun.star.awt.tab.UnoControlTabPageModel"); +} + +Sequence<rtl::OUString> SAL_CALL UnoControlTabPageModel_getSupportedServiceNames (void) + throw (RuntimeException) +{ + static const ::rtl::OUString sServiceName( + ::rtl::OUString::createFromAscii("com.sun.star.awt.tab.UnoControlTabPageModel")); + return Sequence<rtl::OUString>(&sServiceName, 1); +} +//============================================================================= +// = class UnoControlTabPage +// ============================================================================ + +UnoControlTabPage::UnoControlTabPage( const Reference< XMultiServiceFactory >& i_factory ) + :UnoControlTabPage_Base( i_factory ) + ,m_bWindowListener(false) +{ + maComponentInfos.nWidth = 280; + maComponentInfos.nHeight = 400; +} +UnoControlTabPage::~UnoControlTabPage() +{ +} + +::rtl::OUString UnoControlTabPage::GetComponentServiceName() +{ + return ::rtl::OUString::createFromAscii( "TabPageModel" ); +} + +void UnoControlTabPage::dispose() throw(RuntimeException) +{ + SolarMutexGuard aSolarGuard; + + EventObject aEvt; + aEvt.Source = static_cast< ::cppu::OWeakObject* >( this ); + ControlContainerBase::dispose(); +} + +void SAL_CALL UnoControlTabPage::disposing( const EventObject& Source )throw(RuntimeException) +{ + ControlContainerBase::disposing( Source ); +} + +void UnoControlTabPage::createPeer( const Reference< XToolkit > & rxToolkit, const Reference< XWindowPeer > & rParentPeer ) throw(RuntimeException) +{ + SolarMutexGuard aSolarGuard; + ImplUpdateResourceResolver(); + + UnoControlContainer::createPeer( rxToolkit, rParentPeer ); + + Reference < tab::XTabPage > xTabPage( getPeer(), UNO_QUERY ); + if ( xTabPage.is() ) + { + if ( !m_bWindowListener ) + { + Reference< XWindowListener > xWL( static_cast< cppu::OWeakObject*>( this ), UNO_QUERY ); + addWindowListener( xWL ); + m_bWindowListener = true; + } + } +} + +static ::Size ImplMapPixelToAppFont( OutputDevice* pOutDev, const ::Size& aSize ) +{ + ::Size aTmp = pOutDev->PixelToLogic( aSize, MAP_APPFONT ); + return aTmp; +} +// ::com::sun::star::awt::XWindowListener +void SAL_CALL UnoControlTabPage::windowResized( const ::com::sun::star::awt::WindowEvent& e ) +throw (::com::sun::star::uno::RuntimeException) +{ + OutputDevice*pOutDev = Application::GetDefaultDevice(); + DBG_ASSERT( pOutDev, "Missing Default Device!" ); + if ( pOutDev && !mbSizeModified ) + { + // Currentley we are simply using MAP_APPFONT + ::Size aAppFontSize( e.Width, e.Height ); + + Reference< XControl > xDialogControl( *this, UNO_QUERY_THROW ); + Reference< XDevice > xDialogDevice( xDialogControl->getPeer(), UNO_QUERY ); + OSL_ENSURE( xDialogDevice.is(), "UnoDialogControl::windowResized: no peer, but a windowResized event?" ); + if ( xDialogDevice.is() ) + { + DeviceInfo aDeviceInfo( xDialogDevice->getInfo() ); + aAppFontSize.Width() -= aDeviceInfo.LeftInset + aDeviceInfo.RightInset; + aAppFontSize.Height() -= aDeviceInfo.TopInset + aDeviceInfo.BottomInset; + } + + aAppFontSize = ImplMapPixelToAppFont( pOutDev, aAppFontSize ); + + // Remember that changes have been done by listener. No need to + // update the position because of property change event. + mbSizeModified = true; + Sequence< rtl::OUString > aProps( 2 ); + Sequence< Any > aValues( 2 ); + // Properties in a sequence must be sorted! + aProps[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Height" )); + aProps[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Width" )); + aValues[0] <<= aAppFontSize.Height(); + aValues[1] <<= aAppFontSize.Width(); + + ImplSetPropertyValues( aProps, aValues, true ); + mbSizeModified = false; + } +} + +void SAL_CALL UnoControlTabPage::windowMoved( const ::com::sun::star::awt::WindowEvent& e ) +throw (::com::sun::star::uno::RuntimeException) +{ + OutputDevice*pOutDev = Application::GetDefaultDevice(); + DBG_ASSERT( pOutDev, "Missing Default Device!" ); + if ( pOutDev && !mbPosModified ) + { + // Currentley we are simply using MAP_APPFONT + Any aAny; + ::Size aTmp( e.X, e.Y ); + aTmp = ImplMapPixelToAppFont( pOutDev, aTmp ); + + // Remember that changes have been done by listener. No need to + // update the position because of property change event. + mbPosModified = true; + Sequence< rtl::OUString > aProps( 2 ); + Sequence< Any > aValues( 2 ); + aProps[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PositionX" )); + aProps[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PositionY" )); + aValues[0] <<= aTmp.Width(); + aValues[1] <<= aTmp.Height(); + + ImplSetPropertyValues( aProps, aValues, true ); + mbPosModified = false; + } +} + +void SAL_CALL UnoControlTabPage::windowShown( const ::com::sun::star::lang::EventObject& e ) +throw (::com::sun::star::uno::RuntimeException) +{ + (void)e; +} + +void SAL_CALL UnoControlTabPage::windowHidden( const ::com::sun::star::lang::EventObject& e ) +throw (::com::sun::star::uno::RuntimeException) +{ + (void)e; +} diff --git a/toolkit/source/controls/tkscrollbar.cxx b/toolkit/source/controls/tkscrollbar.cxx index 179cbe17b9ab..d32a849ae0e8 100644 --- a/toolkit/source/controls/tkscrollbar.cxx +++ b/toolkit/source/controls/tkscrollbar.cxx @@ -48,7 +48,8 @@ namespace toolkit //= UnoControlScrollBarModel //==================================================================== //-------------------------------------------------------------------- - UnoControlScrollBarModel::UnoControlScrollBarModel() + UnoControlScrollBarModel::UnoControlScrollBarModel( const uno::Reference< lang::XMultiServiceFactory >& i_factory ) + :UnoControlModel( i_factory ) { UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXScrollBar ); } @@ -97,8 +98,9 @@ namespace toolkit //==================================================================== //= UnoControlScrollBarModel //==================================================================== - UnoScrollBarControl::UnoScrollBarControl() - : maAdjustmentListeners( *this ) + UnoScrollBarControl::UnoScrollBarControl( const uno::Reference< lang::XMultiServiceFactory >& i_factory ) + :UnoControlBase( i_factory ) + ,maAdjustmentListeners( *this ) { } diff --git a/toolkit/source/controls/tksimpleanimation.cxx b/toolkit/source/controls/tksimpleanimation.cxx index 2ac9d1f1d478..e5760c215ce2 100644 --- a/toolkit/source/controls/tksimpleanimation.cxx +++ b/toolkit/source/controls/tksimpleanimation.cxx @@ -45,7 +45,8 @@ namespace toolkit //= UnoSimpleAnimationControlModel //==================================================================== //-------------------------------------------------------------------- - UnoSimpleAnimationControlModel::UnoSimpleAnimationControlModel() + UnoSimpleAnimationControlModel::UnoSimpleAnimationControlModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ) + :UnoControlModel( i_factory ) { ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL ); ImplRegisterProperty( BASEPROPERTY_REPEAT ); @@ -120,7 +121,8 @@ namespace toolkit //= UnoSimpleAnimationControl //==================================================================== //-------------------------------------------------------------------- - UnoSimpleAnimationControl::UnoSimpleAnimationControl() + UnoSimpleAnimationControl::UnoSimpleAnimationControl( const uno::Reference< lang::XMultiServiceFactory >& i_factory ) + :UnoSimpleAnimationControl_Base( i_factory ) { } @@ -131,27 +133,6 @@ namespace toolkit } //-------------------------------------------------------------------- - uno::Any UnoSimpleAnimationControl::queryAggregation( const uno::Type & rType ) - throw( uno::RuntimeException ) - { - uno::Any aRet = UnoControlBase::queryAggregation( rType ); - if ( !aRet.hasValue() ) - aRet = UnoSimpleAnimationControl_Base::queryInterface( rType ); - return aRet; - } - - //-------------------------------------------------------------------- - IMPLEMENT_FORWARD_XTYPEPROVIDER2( UnoSimpleAnimationControl, UnoControlBase, UnoSimpleAnimationControl_Base ) - - //-------------------------------------------------------------------- - void UnoSimpleAnimationControl::dispose() throw( uno::RuntimeException ) - { - ::osl::ClearableMutexGuard aGuard( GetMutex() ); - - UnoControl::dispose(); - } - - //-------------------------------------------------------------------- ::rtl::OUString SAL_CALL UnoSimpleAnimationControl::getImplementationName() throw( uno::RuntimeException ) { @@ -162,26 +143,20 @@ namespace toolkit uno::Sequence< ::rtl::OUString > SAL_CALL UnoSimpleAnimationControl::getSupportedServiceNames() throw( uno::RuntimeException ) { - uno::Sequence< ::rtl::OUString > aServices( UnoControlBase::getSupportedServiceNames() ); + uno::Sequence< ::rtl::OUString > aServices( UnoSimpleAnimationControl_Base::getSupportedServiceNames() ); aServices.realloc( aServices.getLength() + 1 ); aServices[ aServices.getLength() - 1 ] = ::rtl::OUString::createFromAscii( szServiceName_UnoSimpleAnimationControl ); return aServices; } //-------------------------------------------------------------------- - void UnoSimpleAnimationControl::createPeer( const uno::Reference< awt::XToolkit > &rxToolkit, - const uno::Reference< awt::XWindowPeer > &rParentPeer ) - throw( uno::RuntimeException ) - { - UnoControl::createPeer( rxToolkit, rParentPeer ); - } - - //-------------------------------------------------------------------- void SAL_CALL UnoSimpleAnimationControl::start() throw ( uno::RuntimeException ) { - ::osl::MutexGuard aGuard( GetMutex() ); - - uno::Reference< XSimpleAnimation > xAnimation( getPeer(), uno::UNO_QUERY ); + uno::Reference< XSimpleAnimation > xAnimation; + { + ::osl::MutexGuard aGuard( GetMutex() ); + xAnimation.set( getPeer(), uno::UNO_QUERY ); + } if ( xAnimation.is() ) xAnimation->start(); } @@ -189,9 +164,11 @@ namespace toolkit //-------------------------------------------------------------------- void SAL_CALL UnoSimpleAnimationControl::stop() throw ( uno::RuntimeException ) { - ::osl::MutexGuard aGuard( GetMutex() ); - - uno::Reference< XSimpleAnimation > xAnimation( getPeer(), uno::UNO_QUERY ); + uno::Reference< XSimpleAnimation > xAnimation; + { + ::osl::MutexGuard aGuard( GetMutex() ); + xAnimation.set( getPeer(), uno::UNO_QUERY ); + } if ( xAnimation.is() ) xAnimation->stop(); } @@ -200,9 +177,11 @@ namespace toolkit void SAL_CALL UnoSimpleAnimationControl::setImageList( const uno::Sequence< uno::Reference< graphic::XGraphic > >& ImageList ) throw ( uno::RuntimeException ) { - ::osl::MutexGuard aGuard( GetMutex() ); - - uno::Reference< XSimpleAnimation > xAnimation( getPeer(), uno::UNO_QUERY ); + uno::Reference< XSimpleAnimation > xAnimation; + { + ::osl::MutexGuard aGuard( GetMutex() ); + xAnimation.set( getPeer(), uno::UNO_QUERY ); + } if ( xAnimation.is() ) xAnimation->setImageList( ImageList ); } diff --git a/toolkit/source/controls/tkspinbutton.cxx b/toolkit/source/controls/tkspinbutton.cxx index 6006c6514161..2dc7c14b78bd 100644 --- a/toolkit/source/controls/tkspinbutton.cxx +++ b/toolkit/source/controls/tkspinbutton.cxx @@ -51,7 +51,8 @@ namespace toolkit //= UnoSpinButtonModel //==================================================================== //-------------------------------------------------------------------- - UnoSpinButtonModel::UnoSpinButtonModel() + UnoSpinButtonModel::UnoSpinButtonModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ) + :UnoControlModel( i_factory ) { ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR ); ImplRegisterProperty( BASEPROPERTY_BORDER ); @@ -138,8 +139,9 @@ namespace toolkit //= UnoSpinButtonControl //==================================================================== //-------------------------------------------------------------------- - UnoSpinButtonControl::UnoSpinButtonControl() - :maAdjustmentListeners( *this ) + UnoSpinButtonControl::UnoSpinButtonControl( const Reference< XMultiServiceFactory >& i_factory ) + :UnoControlBase( i_factory ) + ,maAdjustmentListeners( *this ) { } diff --git a/toolkit/source/controls/tkthrobber.cxx b/toolkit/source/controls/tkthrobber.cxx index b93ccda7c5ba..a70b7acc8175 100644 --- a/toolkit/source/controls/tkthrobber.cxx +++ b/toolkit/source/controls/tkthrobber.cxx @@ -45,7 +45,8 @@ namespace toolkit //= UnoThrobberControlModel //==================================================================== //-------------------------------------------------------------------- - UnoThrobberControlModel::UnoThrobberControlModel() + UnoThrobberControlModel::UnoThrobberControlModel( const uno::Reference< lang::XMultiServiceFactory >& i_factory ) + :UnoControlModel( i_factory ) { ImplRegisterProperty( BASEPROPERTY_BORDER ); ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR ); @@ -118,7 +119,8 @@ namespace toolkit //= UnoThrobberControl //==================================================================== //-------------------------------------------------------------------- - UnoThrobberControl::UnoThrobberControl() + UnoThrobberControl::UnoThrobberControl( const uno::Reference< lang::XMultiServiceFactory >& i_factory ) + :UnoControlBase( i_factory ) { } diff --git a/toolkit/source/controls/tree/makefile.mk b/toolkit/source/controls/tree/makefile.mk deleted file mode 100644 index 4e72b62b416b..000000000000 --- a/toolkit/source/controls/tree/makefile.mk +++ /dev/null @@ -1,48 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=..$/..$/.. - -PRJNAME=toolkit -TARGET=tree - -ENABLE_EXCEPTIONS=TRUE - -# --- Settings ----------------------------------------------------- - -.INCLUDE : settings.mk -.INCLUDE : $(PRJ)$/util$/makefile.pmk - -# --- Files -------------------------------------------------------- - -SLOFILES= \ - $(SLO)$/treecontrol.obj\ - $(SLO)$/treedatamodel.obj - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk diff --git a/toolkit/source/controls/tree/treecontrol.cxx b/toolkit/source/controls/tree/treecontrol.cxx index 4e5fa657c33e..81d2c41f6139 100644 --- a/toolkit/source/controls/tree/treecontrol.cxx +++ b/toolkit/source/controls/tree/treecontrol.cxx @@ -54,7 +54,8 @@ namespace toolkit // ---------------------------------------------------- // class UnoTreeModel // ---------------------------------------------------- -UnoTreeModel::UnoTreeModel() +UnoTreeModel::UnoTreeModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ) + :UnoControlModel( i_factory ) { ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR ); ImplRegisterProperty( BASEPROPERTY_BORDER ); @@ -73,7 +74,7 @@ UnoTreeModel::UnoTreeModel() ImplRegisterProperty( BASEPROPERTY_TREE_ROOTDISPLAYED ); ImplRegisterProperty( BASEPROPERTY_TREE_SHOWSHANDLES ); ImplRegisterProperty( BASEPROPERTY_TREE_SHOWSROOTHANDLES ); - ImplRegisterProperty( BASEPROPERTY_TREE_ROWHEIGHT ); + ImplRegisterProperty( BASEPROPERTY_ROW_HEIGHT ); ImplRegisterProperty( BASEPROPERTY_TREE_INVOKESSTOPNODEEDITING ); ImplRegisterProperty( BASEPROPERTY_HIDEINACTIVESELECTION ); } @@ -99,7 +100,7 @@ Any UnoTreeModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const { case BASEPROPERTY_TREE_SELECTIONTYPE: return Any( SelectionType_NONE ); - case BASEPROPERTY_TREE_ROWHEIGHT: + case BASEPROPERTY_ROW_HEIGHT: return Any( sal_Int32( 0 ) ); case BASEPROPERTY_TREE_DATAMODEL: return Any( Reference< XTreeDataModel >( 0 ) ); @@ -139,8 +140,9 @@ Reference< XPropertySetInfo > UnoTreeModel::getPropertySetInfo( ) throw(Runtime // ---------------------------------------------------- // class UnoTreeControl // ---------------------------------------------------- -UnoTreeControl::UnoTreeControl() -: maSelectionListeners( *this ) +UnoTreeControl::UnoTreeControl( const Reference< XMultiServiceFactory >& i_factory ) +: UnoTreeControl_Base( i_factory ) +, maSelectionListeners( *this ) , maTreeExpansionListeners( *this ) , maTreeEditListeners( *this ) { @@ -451,14 +453,14 @@ void UnoTreeControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolk } -Reference< XInterface > SAL_CALL TreeControl_CreateInstance( const Reference< XMultiServiceFactory >& ) +Reference< XInterface > SAL_CALL TreeControl_CreateInstance( const Reference< XMultiServiceFactory >& i_factory ) { - return Reference < XInterface >( ( ::cppu::OWeakObject* ) new ::toolkit::UnoTreeControl ); + return Reference < XInterface >( ( ::cppu::OWeakObject* ) new ::toolkit::UnoTreeControl( i_factory ) ); } -Reference< XInterface > SAL_CALL TreeControlModel_CreateInstance( const Reference< XMultiServiceFactory >& ) +Reference< XInterface > SAL_CALL TreeControlModel_CreateInstance( const Reference< XMultiServiceFactory >& i_factory ) { - return Reference < XInterface >( ( ::cppu::OWeakObject* ) new ::toolkit::UnoTreeModel ); + return Reference < XInterface >( ( ::cppu::OWeakObject* ) new ::toolkit::UnoTreeModel( i_factory ) ); } void SAL_CALL TreeEditListenerMultiplexer::nodeEditing( const Reference< XTreeNode >& Node ) throw (RuntimeException, ::com::sun::star::util::VetoException) diff --git a/toolkit/source/controls/tree/treecontrol.hxx b/toolkit/source/controls/tree/treecontrol.hxx index a6f037f9c56a..61f6f6e59d71 100644 --- a/toolkit/source/controls/tree/treecontrol.hxx +++ b/toolkit/source/controls/tree/treecontrol.hxx @@ -55,7 +55,7 @@ protected: ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); public: - UnoTreeModel(); + UnoTreeModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); UnoTreeModel( const UnoTreeModel& rModel ); UnoControlModel* Clone() const; @@ -74,10 +74,11 @@ public: // =================================================================== // = UnoTreeControl // =================================================================== -class UnoTreeControl : public ::cppu::ImplInheritanceHelper1< UnoControlBase, ::com::sun::star::awt::tree::XTreeControl > +typedef ::cppu::ImplInheritanceHelper1< UnoControlBase, ::com::sun::star::awt::tree::XTreeControl > UnoTreeControl_Base; +class UnoTreeControl : public UnoTreeControl_Base { public: - UnoTreeControl(); + UnoTreeControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); ::rtl::OUString GetComponentServiceName(); // ::com::sun::star::lang::XComponent diff --git a/toolkit/source/controls/unocontrol.cxx b/toolkit/source/controls/unocontrol.cxx index d0bae3c244c3..d759e05e318d 100644 --- a/toolkit/source/controls/unocontrol.cxx +++ b/toolkit/source/controls/unocontrol.cxx @@ -51,6 +51,7 @@ #include <vcl/svapp.hxx> #include <vcl/wrkwin.hxx> #include <comphelper/stl_types.hxx> +#include <comphelper/processfactory.hxx> #include <toolkit/helper/property.hxx> #include <toolkit/helper/servicenames.hxx> #include <toolkit/helper/vclunohelper.hxx> @@ -163,7 +164,26 @@ struct UnoControl_Data // ---------------------------------------------------- DBG_NAME( UnoControl ) UnoControl::UnoControl() - : maDisposeListeners( *this ) + :maContext( ::comphelper::getProcessServiceFactory() ) + ,maDisposeListeners( *this ) + ,maWindowListeners( *this ) + ,maFocusListeners( *this ) + ,maKeyListeners( *this ) + ,maMouseListeners( *this ) + ,maMouseMotionListeners( *this ) + ,maPaintListeners( *this ) + ,maModeChangeListeners( GetMutex() ) + ,mpData( new UnoControl_Data ) +{ + DBG_CTOR( UnoControl, NULL ); + OSL_ENSURE( false, "UnoControl::UnoControl: not implemented. Well, not really." ); + // just implemented to let the various FooImplInheritanceHelper compile, you should use the + // version taking a service factory +} + +UnoControl::UnoControl( const Reference< XMultiServiceFactory >& i_factory ) + : maContext( i_factory ) + , maDisposeListeners( *this ) , maWindowListeners( *this ) , maFocusListeners( *this ) , maKeyListeners( *this ) diff --git a/toolkit/source/controls/unocontrolbase.cxx b/toolkit/source/controls/unocontrolbase.cxx index 254fefe54cd0..c2622946009b 100644 --- a/toolkit/source/controls/unocontrolbase.cxx +++ b/toolkit/source/controls/unocontrolbase.cxx @@ -33,6 +33,7 @@ #include <toolkit/controls/unocontrolbase.hxx> #include <toolkit/helper/property.hxx> +#include <comphelper/processfactory.hxx> #include <tools/debug.hxx> @@ -40,6 +41,14 @@ // class UnoControlBase // ---------------------------------------------------- +UnoControlBase::UnoControlBase() + :UnoControl( ::comphelper::getProcessServiceFactory() ) +{ + OSL_ENSURE( false, "UnoControlBase::UnoControlBase: not implemented. Well, not really." ); + // just implemented to let the various FooImplInheritanceHelper compile, you should use the + // version taking a service factory +} + sal_Bool UnoControlBase::ImplHasProperty( sal_uInt16 nPropId ) { ::rtl::OUString aPropName( GetPropertyName( nPropId ) ); diff --git a/toolkit/source/controls/unocontrolcontainer.cxx b/toolkit/source/controls/unocontrolcontainer.cxx index b67ec421db96..c73bd401bf51 100644 --- a/toolkit/source/controls/unocontrolcontainer.cxx +++ b/toolkit/source/controls/unocontrolcontainer.cxx @@ -410,13 +410,16 @@ void SAL_CALL DialogStepChangedListener::propertyChange( const beans::PropertyC // ---------------------------------------------------- // class UnoControlContainer // ---------------------------------------------------- -UnoControlContainer::UnoControlContainer() : maCListeners( *this ) +UnoControlContainer::UnoControlContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ) + :UnoControlContainer_Base( i_factory ) + ,maCListeners( *this ) { mpControls = new UnoControlHolderList; } -UnoControlContainer::UnoControlContainer( uno::Reference< awt::XWindowPeer > xP ) - : maCListeners( *this ) +UnoControlContainer::UnoControlContainer( const uno::Reference< lang::XMultiServiceFactory >& i_factory, const uno::Reference< awt::XWindowPeer >& xP ) + :UnoControlContainer_Base( i_factory ) + ,maCListeners( *this ) { setPeer( xP ); mbDisposePeer = sal_False; diff --git a/toolkit/source/controls/unocontrolcontainermodel.cxx b/toolkit/source/controls/unocontrolcontainermodel.cxx index c29886dadf5f..a3fba37b273b 100644 --- a/toolkit/source/controls/unocontrolcontainermodel.cxx +++ b/toolkit/source/controls/unocontrolcontainermodel.cxx @@ -37,7 +37,8 @@ // ---------------------------------------------------- // class UnoControlContainerModel // ---------------------------------------------------- -UnoControlContainerModel::UnoControlContainerModel() +UnoControlContainerModel::UnoControlContainerModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ) + :UnoControlModel( i_factory ) { ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR ); ImplRegisterProperty( BASEPROPERTY_BORDER ); diff --git a/toolkit/source/controls/unocontrolmodel.cxx b/toolkit/source/controls/unocontrolmodel.cxx index 2493dfe4289b..42da982f97a4 100644 --- a/toolkit/source/controls/unocontrolmodel.cxx +++ b/toolkit/source/controls/unocontrolmodel.cxx @@ -42,7 +42,6 @@ #include <toolkit/controls/unocontrolmodel.hxx> #include <toolkit/helper/macros.hxx> #include <cppuhelper/typeprovider.hxx> -#include <cppuhelper/extract.hxx> #include <rtl/memory.h> #include <rtl/uuid.h> #include <tools/diagnose_ex.h> @@ -60,6 +59,7 @@ #include <unotools/configmgr.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/sequence.hxx> +#include <comphelper/extract.hxx> #include <vcl/svapp.hxx> #include <uno/data.h> @@ -155,7 +155,24 @@ static void lcl_ImplMergeFontProperty( FontDescriptor& rFD, sal_uInt16 nPropId, // class UnoControlModel // ---------------------------------------------------- UnoControlModel::UnoControlModel() - : OPropertySetHelper( BrdcstHelper ), maDisposeListeners( *this ) + :UnoControlModel_Base() + ,MutexAndBroadcastHelper() + ,OPropertySetHelper( BrdcstHelper ) + ,maDisposeListeners( *this ) + ,maContext( ::comphelper::getProcessServiceFactory() ) +{ + OSL_ENSURE( false, "UnoControlModel::UnoControlModel: not implemented. Well, not really." ); + // just implemented to let the various FooImplInheritanceHelper compile, you should use the + // version taking a service factory + mpData = new ImplPropertyTable; +} + +UnoControlModel::UnoControlModel( const Reference< XMultiServiceFactory >& i_factory ) + :UnoControlModel_Base() + ,MutexAndBroadcastHelper() + ,OPropertySetHelper( BrdcstHelper ) + ,maDisposeListeners( *this ) + ,maContext( i_factory ) { // Die Properties muessen vom Model in die Tabelle gestopft werden, // nur vorhandene Properties sind gueltige Properties, auch wenn VOID. @@ -163,18 +180,11 @@ UnoControlModel::UnoControlModel() } UnoControlModel::UnoControlModel( const UnoControlModel& rModel ) - : XControlModel() - , XPropertyState() - , XPersistObject() - , XComponent() - , XServiceInfo() - , XTypeProvider() - , XUnoTunnel() - , XCloneable() + : UnoControlModel_Base() , MutexAndBroadcastHelper() , OPropertySetHelper( BrdcstHelper ) - , OWeakAggObject() , maDisposeListeners( *this ) + , maContext( rModel.maContext ) { mpData = new ImplPropertyTable; @@ -405,7 +415,7 @@ sal_Bool UnoControlModel::ImplHasProperty( sal_uInt16 nPropId ) const aLocale.Country = sDefaultCurrency.copy( nSepPos + 1 ); } - LocaleDataWrapper aLocaleInfo( ::comphelper::getProcessServiceFactory(), aLocale ); + LocaleDataWrapper aLocaleInfo( maContext.getLegacyServiceFactory(), aLocale ); if ( !sBankSymbol.getLength() ) sBankSymbol = aLocaleInfo.getCurrBankSymbol(); @@ -488,36 +498,20 @@ void UnoControlModel::ImplRegisterProperties( const std::list< sal_uInt16 > &rId // ::com::sun::star::uno::XInterface ::com::sun::star::uno::Any UnoControlModel::queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) { - ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, - SAL_STATIC_CAST( ::com::sun::star::awt::XControlModel*, this ), - SAL_STATIC_CAST( ::com::sun::star::io::XPersistObject*, this ), - SAL_STATIC_CAST( ::com::sun::star::lang::XComponent*, this ), - SAL_STATIC_CAST( ::com::sun::star::lang::XServiceInfo*, this ), - SAL_STATIC_CAST( ::com::sun::star::util::XCloneable*, this ), - SAL_STATIC_CAST( ::com::sun::star::beans::XPropertyState*, this ), - SAL_STATIC_CAST( ::com::sun::star::beans::XMultiPropertySet*, this ), - SAL_STATIC_CAST( ::com::sun::star::beans::XFastPropertySet*, this ), - SAL_STATIC_CAST( ::com::sun::star::beans::XPropertySet*, this ), - SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ), - SAL_STATIC_CAST( ::com::sun::star::lang::XUnoTunnel*, this ) ); - return (aRet.hasValue() ? aRet : OWeakAggObject::queryAggregation( rType )); + Any aRet = UnoControlModel_Base::queryAggregation( rType ); + if ( !aRet.hasValue() ) + aRet = ::cppu::OPropertySetHelper::queryInterface( rType ); + return aRet; } // ::com::sun::star::lang::XUnoTunnel IMPL_XUNOTUNNEL( UnoControlModel ) +// XInterface +IMPLEMENT_FORWARD_REFCOUNT( UnoControlModel, UnoControlModel_Base ) + // ::com::sun::star::lang::XTypeProvider -IMPL_XTYPEPROVIDER_START( UnoControlModel ) - getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel>* ) NULL ), - getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::io::XPersistObject>* ) NULL ), - getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent>* ) NULL ), - getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XServiceInfo>* ) NULL ), - getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable>* ) NULL ), - getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState>* ) NULL ), - getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XMultiPropertySet>* ) NULL ), - getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet>* ) NULL ), - getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>* ) NULL ) -IMPL_XTYPEPROVIDER_END +IMPLEMENT_FORWARD_XTYPEPROVIDER2( UnoControlModel, UnoControlModel_Base, ::cppu::OPropertySetHelper ) uno::Reference< util::XCloneable > UnoControlModel::createClone() throw(::com::sun::star::uno::RuntimeException) @@ -536,6 +530,8 @@ void UnoControlModel::dispose( ) throw(::com::sun::star::uno::RuntimeException) aEvt.Source = (::com::sun::star::uno::XAggregation*)(::cppu::OWeakAggObject*)this; maDisposeListeners.disposeAndClear( aEvt ); + BrdcstHelper.aLC.disposeAndClear( aEvt ); + // let the property set helper notify our property listeners OPropertySetHelper::disposing(); } @@ -1157,7 +1153,7 @@ sal_Bool UnoControlModel::convertFastPropertyValue( Any & rConvertedValue, Any & } else { - BOOL bConverted = FALSE; + sal_Bool bConverted = sal_False; // 13.03.2001 - 84923 - frank.schoenheit@germany.sun.com switch (pDestType->getTypeClass()) diff --git a/toolkit/source/controls/unocontrols.cxx b/toolkit/source/controls/unocontrols.cxx index d7d651935bfc..1094c70223ea 100644 --- a/toolkit/source/controls/unocontrols.cxx +++ b/toolkit/source/controls/unocontrols.cxx @@ -43,7 +43,6 @@ #include <toolkit/controls/formattedcontrol.hxx> #include <toolkit/controls/roadmapcontrol.hxx> #include <toolkit/controls/unocontrols.hxx> -#include <toolkit/controls/geometrycontrolmodel.hxx> #include <toolkit/controls/stdtabcontroller.hxx> #include <toolkit/helper/property.hxx> #include <toolkit/helper/unopropertyarrayhelper.hxx> @@ -94,7 +93,8 @@ using namespace ::toolkit; // ---------------------------------------------------- // class UnoControlEditModel // ---------------------------------------------------- -UnoControlEditModel::UnoControlEditModel() +UnoControlEditModel::UnoControlEditModel( const Reference< XMultiServiceFactory >& i_factory ) + :UnoControlModel( i_factory ) { UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXEdit ); } @@ -145,8 +145,9 @@ uno::Reference< beans::XPropertySetInfo > UnoControlEditModel::getPropertySetInf // ---------------------------------------------------- // class UnoEditControl // ---------------------------------------------------- -UnoEditControl::UnoEditControl() - :maTextListeners( *this ) +UnoEditControl::UnoEditControl( const Reference< XMultiServiceFactory >& i_factory ) + :UnoControlBase( i_factory ) + ,maTextListeners( *this ) ,mnMaxTextLen( 0 ) ,mbSetTextInPeer( sal_False ) ,mbSetMaxTextLenInPeer( sal_False ) @@ -155,7 +156,7 @@ UnoEditControl::UnoEditControl() maComponentInfos.nWidth = 100; maComponentInfos.nHeight = 12; mnMaxTextLen = 0; - mbSetMaxTextLenInPeer = FALSE; + mbSetMaxTextLenInPeer = sal_False; } uno::Any SAL_CALL UnoEditControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException) @@ -459,7 +460,8 @@ void UnoEditControl::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) t // ---------------------------------------------------- // class UnoControlFileControlModel // ---------------------------------------------------- -UnoControlFileControlModel::UnoControlFileControlModel() +UnoControlFileControlModel::UnoControlFileControlModel( const Reference< XMultiServiceFactory >& i_factory ) + :UnoControlModel( i_factory ) { ImplRegisterProperty( BASEPROPERTY_ALIGN ); ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR ); @@ -518,7 +520,8 @@ uno::Reference< beans::XPropertySetInfo > UnoControlFileControlModel::getPropert // ---------------------------------------------------- // class UnoFileControl // ---------------------------------------------------- -UnoFileControl::UnoFileControl() +UnoFileControl::UnoFileControl( const Reference< XMultiServiceFactory >& i_factory ) + :UnoEditControl( i_factory ) { } @@ -537,6 +540,7 @@ uno::Any GraphicControlModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const return UnoControlModel::ImplGetDefaultValue( nPropId ); } + uno::Reference< graphic::XGraphic > ImageHelper::getGraphicAndGraphicObjectFromURL_nothrow( uno::Reference< graphic::XGraphicObject >& xOutGraphicObj, const ::rtl::OUString& _rURL ) { uno::Reference< graphic::XGraphic > xGraphic; @@ -546,7 +550,6 @@ uno::Any GraphicControlModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const // graphic manager uniqueid rtl::OUString sID = _rURL.copy( sizeof( UNO_NAME_GRAPHOBJ_URLPREFIX ) - 1 ); // get the DefaultContext - ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); xOutGraphicObj = graphic::GraphicObject::createWithId( aContext.getUNOContext(), sID ); } else // linked @@ -557,9 +560,8 @@ uno::Any GraphicControlModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const try { - ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); uno::Reference< graphic::XGraphicProvider > xProvider; - if ( aContext.createComponent( "com.sun.star.graphic.GraphicProvider", xProvider ) ) + if ( maContext.createComponent( "com.sun.star.graphic.GraphicProvider", xProvider ) ) { uno::Sequence< beans::PropertyValue > aMediaProperties(1); aMediaProperties[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) ); @@ -592,7 +594,7 @@ void SAL_CALL GraphicControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 n mbAdjustingGraphic = true; ::rtl::OUString sImageURL; OSL_VERIFY( rValue >>= sImageURL ); - setPropertyValue( GetPropertyName( BASEPROPERTY_GRAPHIC ), uno::makeAny( ImageHelper::getGraphicAndGraphicObjectFromURL_nothrow( mxGrfObj, sImageURL ) ) ); + setDependentFastPropertyValue( BASEPROPERTY_GRAPHIC, uno::makeAny( ImageHelper::getGraphicAndGraphicObjectFromURL_nothrow( mxGrfObj, sImageURL ) ) ); mbAdjustingGraphic = false; } break; @@ -601,7 +603,7 @@ void SAL_CALL GraphicControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 n if ( !mbAdjustingGraphic && ImplHasProperty( BASEPROPERTY_IMAGEURL ) ) { mbAdjustingGraphic = true; - setPropertyValue( GetPropertyName( BASEPROPERTY_IMAGEURL ), uno::makeAny( ::rtl::OUString() ) ); + setDependentFastPropertyValue( BASEPROPERTY_IMAGEURL, uno::makeAny( ::rtl::OUString() ) ); mbAdjustingGraphic = false; } break; @@ -612,7 +614,7 @@ void SAL_CALL GraphicControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 n mbAdjustingImagePosition = true; sal_Int16 nUNOValue = 0; OSL_VERIFY( rValue >>= nUNOValue ); - setPropertyValue( GetPropertyName( BASEPROPERTY_IMAGEPOSITION ), uno::makeAny( getExtendedImagePosition( nUNOValue ) ) ); + setDependentFastPropertyValue( BASEPROPERTY_IMAGEPOSITION, uno::makeAny( getExtendedImagePosition( nUNOValue ) ) ); mbAdjustingImagePosition = false; } break; @@ -622,7 +624,7 @@ void SAL_CALL GraphicControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 n mbAdjustingImagePosition = true; sal_Int16 nUNOValue = 0; OSL_VERIFY( rValue >>= nUNOValue ); - setPropertyValue( GetPropertyName( BASEPROPERTY_IMAGEALIGN ), uno::makeAny( getCompatibleImageAlign( translateImagePosition( nUNOValue ) ) ) ); + setDependentFastPropertyValue( BASEPROPERTY_IMAGEALIGN, uno::makeAny( getCompatibleImageAlign( translateImagePosition( nUNOValue ) ) ) ); mbAdjustingImagePosition = false; } break; @@ -638,7 +640,8 @@ void SAL_CALL GraphicControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 n // ---------------------------------------------------- // class UnoControlButtonModel // ---------------------------------------------------- -UnoControlButtonModel::UnoControlButtonModel() +UnoControlButtonModel::UnoControlButtonModel( const Reference< XMultiServiceFactory >& i_factory ) + :GraphicControlModel( i_factory ) { UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXButton ); @@ -694,9 +697,10 @@ uno::Reference< beans::XPropertySetInfo > UnoControlButtonModel::getPropertySetI // ---------------------------------------------------- // class UnoButtonControl // ---------------------------------------------------- -UnoButtonControl::UnoButtonControl() - : maActionListeners( *this ) - , maItemListeners( *this ) +UnoButtonControl::UnoButtonControl( const uno::Reference< lang::XMultiServiceFactory >& i_factory ) + :UnoButtonControl_Base( i_factory ) + ,maActionListeners( *this ) + ,maItemListeners( *this ) { maComponentInfos.nWidth = 50; maComponentInfos.nHeight = 14; @@ -833,8 +837,9 @@ awt::Size UnoButtonControl::calcAdjustedSize( const awt::Size& rNewSize ) throw( // ---------------------------------------------------- // class UnoControlImageControlModel // ---------------------------------------------------- -UnoControlImageControlModel::UnoControlImageControlModel() - :mbAdjustingImageScaleMode( false ) +UnoControlImageControlModel::UnoControlImageControlModel( const Reference< XMultiServiceFactory >& i_factory ) + :GraphicControlModel( i_factory ) + ,mbAdjustingImageScaleMode( false ) { UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXImageControl ); } @@ -888,7 +893,7 @@ void SAL_CALL UnoControlImageControlModel::setFastPropertyValue_NoBroadcast( sal mbAdjustingImageScaleMode = true; sal_Int16 nScaleMode( awt::ImageScaleMode::Anisotropic ); OSL_VERIFY( _rValue >>= nScaleMode ); - setPropertyValue( GetPropertyName( BASEPROPERTY_SCALEIMAGE ), uno::makeAny( sal_Bool( nScaleMode != awt::ImageScaleMode::None ) ) ); + setDependentFastPropertyValue( BASEPROPERTY_SCALEIMAGE, uno::makeAny( sal_Bool( nScaleMode != awt::ImageScaleMode::None ) ) ); mbAdjustingImageScaleMode = false; } break; @@ -898,7 +903,7 @@ void SAL_CALL UnoControlImageControlModel::setFastPropertyValue_NoBroadcast( sal mbAdjustingImageScaleMode = true; sal_Bool bScale = sal_True; OSL_VERIFY( _rValue >>= bScale ); - setPropertyValue( GetPropertyName( BASEPROPERTY_IMAGE_SCALE_MODE ), uno::makeAny( bScale ? awt::ImageScaleMode::Anisotropic : awt::ImageScaleMode::None ) ); + setDependentFastPropertyValue( BASEPROPERTY_IMAGE_SCALE_MODE, uno::makeAny( bScale ? awt::ImageScaleMode::Anisotropic : awt::ImageScaleMode::None ) ); mbAdjustingImageScaleMode = false; } break; @@ -914,8 +919,9 @@ void SAL_CALL UnoControlImageControlModel::setFastPropertyValue_NoBroadcast( sal // ---------------------------------------------------- // class UnoImageControlControl // ---------------------------------------------------- -UnoImageControlControl::UnoImageControlControl() - : maActionListeners( *this ) +UnoImageControlControl::UnoImageControlControl( const Reference< XMultiServiceFactory >& i_factory ) + :UnoImageControlControl_Base( i_factory ) + ,maActionListeners( *this ) { // Woher die Defaults nehmen? maComponentInfos.nWidth = 100; @@ -958,7 +964,8 @@ awt::Size UnoImageControlControl::calcAdjustedSize( const awt::Size& rNewSize ) // ---------------------------------------------------- // class UnoControlRadioButtonModel // ---------------------------------------------------- -UnoControlRadioButtonModel::UnoControlRadioButtonModel() +UnoControlRadioButtonModel::UnoControlRadioButtonModel( const Reference< XMultiServiceFactory >& i_factory ) + :GraphicControlModel( i_factory ) { UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXRadioButton ); } @@ -1005,8 +1012,10 @@ uno::Reference< beans::XPropertySetInfo > UnoControlRadioButtonModel::getPropert // ---------------------------------------------------- // class UnoRadioButtonControl // ---------------------------------------------------- -UnoRadioButtonControl::UnoRadioButtonControl() - : maItemListeners( *this ), maActionListeners( *this ) +UnoRadioButtonControl::UnoRadioButtonControl( const Reference< XMultiServiceFactory >& i_factory ) + :UnoRadioButtonControl_Base( i_factory ) + ,maItemListeners( *this ) + ,maActionListeners( *this ) { maComponentInfos.nWidth = 100; maComponentInfos.nHeight = 12; @@ -1165,7 +1174,8 @@ awt::Size UnoRadioButtonControl::calcAdjustedSize( const awt::Size& rNewSize ) t // ---------------------------------------------------- // class UnoControlCheckBoxModel // ---------------------------------------------------- -UnoControlCheckBoxModel::UnoControlCheckBoxModel() +UnoControlCheckBoxModel::UnoControlCheckBoxModel( const Reference< XMultiServiceFactory >& i_factory ) + :GraphicControlModel( i_factory ) { UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXCheckBox ); } @@ -1212,8 +1222,9 @@ uno::Reference< beans::XPropertySetInfo > UnoControlCheckBoxModel::getPropertySe // ---------------------------------------------------- // class UnoCheckBoxControl // ---------------------------------------------------- -UnoCheckBoxControl::UnoCheckBoxControl() - : maItemListeners( *this ), maActionListeners( *this ) +UnoCheckBoxControl::UnoCheckBoxControl( const uno::Reference< lang::XMultiServiceFactory >& i_factory ) + :UnoCheckBoxControl_Base( i_factory ) + ,maItemListeners( *this ), maActionListeners( *this ) { maComponentInfos.nWidth = 100; maComponentInfos.nHeight = 12; @@ -1348,7 +1359,8 @@ awt::Size UnoCheckBoxControl::calcAdjustedSize( const awt::Size& rNewSize ) thro // ---------------------------------------------------- // class UnoControlFixedHyperlinkModel // ---------------------------------------------------- -UnoControlFixedHyperlinkModel::UnoControlFixedHyperlinkModel() +UnoControlFixedHyperlinkModel::UnoControlFixedHyperlinkModel( const Reference< XMultiServiceFactory >& i_factory ) + :UnoControlModel( i_factory ) { UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXFixedHyperlink ); } @@ -1403,8 +1415,9 @@ uno::Reference< beans::XPropertySetInfo > UnoControlFixedHyperlinkModel::getProp // ---------------------------------------------------- // class UnoFixedHyperlinkControl // ---------------------------------------------------- -UnoFixedHyperlinkControl::UnoFixedHyperlinkControl() - : maActionListeners( *this ) +UnoFixedHyperlinkControl::UnoFixedHyperlinkControl( const Reference< XMultiServiceFactory >& i_factory ) + :UnoControlBase( i_factory ) + ,maActionListeners( *this ) { maComponentInfos.nWidth = 100; maComponentInfos.nHeight = 12; @@ -1533,7 +1546,8 @@ void UnoFixedHyperlinkControl::removeActionListener(const uno::Reference< awt::X // ---------------------------------------------------- // class UnoControlFixedTextModel // ---------------------------------------------------- -UnoControlFixedTextModel::UnoControlFixedTextModel() +UnoControlFixedTextModel::UnoControlFixedTextModel( const Reference< XMultiServiceFactory >& i_factory ) + :UnoControlModel( i_factory ) { UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXFixedText ); } @@ -1583,7 +1597,8 @@ uno::Reference< beans::XPropertySetInfo > UnoControlFixedTextModel::getPropertyS // ---------------------------------------------------- // class UnoFixedTextControl // ---------------------------------------------------- -UnoFixedTextControl::UnoFixedTextControl() +UnoFixedTextControl::UnoFixedTextControl( const Reference< XMultiServiceFactory >& i_factory ) + :UnoControlBase( i_factory ) { maComponentInfos.nWidth = 100; maComponentInfos.nHeight = 12; @@ -1663,7 +1678,8 @@ awt::Size UnoFixedTextControl::calcAdjustedSize( const awt::Size& rNewSize ) thr // ---------------------------------------------------- // class UnoControlGroupBoxModel // ---------------------------------------------------- -UnoControlGroupBoxModel::UnoControlGroupBoxModel() +UnoControlGroupBoxModel::UnoControlGroupBoxModel( const Reference< XMultiServiceFactory >& i_factory ) + :UnoControlModel( i_factory ) { ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL ); ImplRegisterProperty( BASEPROPERTY_ENABLED ); @@ -1714,7 +1730,8 @@ uno::Reference< beans::XPropertySetInfo > UnoControlGroupBoxModel::getPropertySe // ---------------------------------------------------- // class UnoGroupBoxControl // ---------------------------------------------------- -UnoGroupBoxControl::UnoGroupBoxControl() +UnoGroupBoxControl::UnoGroupBoxControl( const Reference< XMultiServiceFactory >& i_factory ) + :UnoControlBase( i_factory ) { maComponentInfos.nWidth = 100; maComponentInfos.nHeight = 100; @@ -1801,6 +1818,11 @@ struct UnoControlListBoxModel_Data return aItems; } + void copyItems( const UnoControlListBoxModel_Data& i_copySource ) + { + m_aListItems = i_copySource.m_aListItems; + } + void setAllItems( const ::std::vector< ListItem >& i_rItems ) { m_aListItems = i_rItems; @@ -1831,27 +1853,23 @@ private: // = UnoControlListBoxModel // ===================================================================================================================== // --------------------------------------------------------------------------------------------------------------------- -UnoControlListBoxModel::UnoControlListBoxModel() - :UnoControlListBoxModel_Base() - ,m_pData( new UnoControlListBoxModel_Data( *this ) ) - ,m_aItemListListeners( GetMutex() ) -{ - UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXListBox ); -} -// --------------------------------------------------------------------------------------------------------------------- -UnoControlListBoxModel::UnoControlListBoxModel(bool) - :UnoControlListBoxModel_Base() +UnoControlListBoxModel::UnoControlListBoxModel( const Reference< XMultiServiceFactory >& i_factory, ConstructorMode const i_mode ) + :UnoControlListBoxModel_Base( i_factory ) ,m_pData( new UnoControlListBoxModel_Data( *this ) ) ,m_aItemListListeners( GetMutex() ) { + if ( i_mode == ConstructDefault ) + { + UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXListBox ); + } } - // --------------------------------------------------------------------------------------------------------------------- UnoControlListBoxModel::UnoControlListBoxModel( const UnoControlListBoxModel& i_rSource ) :UnoControlListBoxModel_Base( i_rSource ) ,m_pData( new UnoControlListBoxModel_Data( *this ) ) ,m_aItemListListeners( GetMutex() ) { + m_pData->copyItems( *i_rSource.m_pData ); } UnoControlListBoxModel::~UnoControlListBoxModel() { @@ -1862,6 +1880,7 @@ IMPL_SERVICEINFO_DERIVED( UnoControlListBoxModel, UnoControlModel, szServiceName { return ::rtl::OUString::createFromAscii( szServiceName_UnoControlListBoxModel ); } + // --------------------------------------------------------------------------------------------------------------------- uno::Any UnoControlListBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const { @@ -1917,7 +1936,7 @@ void SAL_CALL UnoControlListBoxModel::setFastPropertyValue_NoBroadcast( sal_Int3 uno::Sequence<sal_Int16> aSeq; uno::Any aAny; aAny <<= aSeq; - setPropertyValue( GetPropertyName( BASEPROPERTY_SELECTEDITEMS ), aAny ); + setDependentFastPropertyValue( BASEPROPERTY_SELECTEDITEMS, aAny ); if ( !m_pData->m_bSettingLegacyProperty ) { @@ -2277,8 +2296,9 @@ void UnoControlListBoxModel::impl_notifyItemListEvent_nolck( const sal_Int32 i_n // ---------------------------------------------------- // class UnoListBoxControl // ---------------------------------------------------- -UnoListBoxControl::UnoListBoxControl() - :maActionListeners( *this ) +UnoListBoxControl::UnoListBoxControl( const Reference< XMultiServiceFactory >& i_factory ) + :UnoListBoxControl_Base( i_factory ) + ,maActionListeners( *this ) ,maItemListeners( *this ) { maComponentInfos.nWidth = 100; @@ -2707,7 +2727,8 @@ ItemListenerMultiplexer& UnoListBoxControl::getItemListeners() // ---------------------------------------------------- // class UnoControlComboBoxModel // ---------------------------------------------------- -UnoControlComboBoxModel::UnoControlComboBoxModel() : UnoControlListBoxModel(true) +UnoControlComboBoxModel::UnoControlComboBoxModel( const Reference< XMultiServiceFactory >& i_factory ) + :UnoControlListBoxModel( i_factory, ConstructWithoutProperties ) { UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXComboBox ); } @@ -2782,9 +2803,10 @@ uno::Any UnoControlComboBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) cons // ---------------------------------------------------- // class UnoComboBoxControl // ---------------------------------------------------- -UnoComboBoxControl::UnoComboBoxControl() - : maActionListeners( *this ), - maItemListeners( *this ) +UnoComboBoxControl::UnoComboBoxControl( const Reference< XMultiServiceFactory >& i_factory ) + :UnoEditControl( i_factory ) + ,maActionListeners( *this ) + ,maItemListeners( *this ) { maComponentInfos.nWidth = 100; maComponentInfos.nHeight = 12; @@ -3102,7 +3124,9 @@ sal_Int16 UnoComboBoxControl::getDropDownLineCount() throw(uno::RuntimeException // ---------------------------------------------------- // UnoSpinFieldControl // ---------------------------------------------------- -UnoSpinFieldControl::UnoSpinFieldControl() : maSpinListeners( *this ) +UnoSpinFieldControl::UnoSpinFieldControl( const Reference< XMultiServiceFactory >& i_factory ) + :UnoEditControl( i_factory ) + ,maSpinListeners( *this ) { mbRepeat = sal_False; } @@ -3192,7 +3216,8 @@ void UnoSpinFieldControl::enableRepeat( sal_Bool bRepeat ) throw(::com::sun::sta // ---------------------------------------------------- // class UnoControlDateFieldModel // ---------------------------------------------------- -UnoControlDateFieldModel::UnoControlDateFieldModel() +UnoControlDateFieldModel::UnoControlDateFieldModel( const Reference< XMultiServiceFactory >& i_factory ) + :UnoControlModel( i_factory ) { UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXDateField ); } @@ -3237,7 +3262,8 @@ uno::Reference< beans::XPropertySetInfo > UnoControlDateFieldModel::getPropertyS // ---------------------------------------------------- // class UnoDateFieldControl // ---------------------------------------------------- -UnoDateFieldControl::UnoDateFieldControl() +UnoDateFieldControl::UnoDateFieldControl( const Reference< XMultiServiceFactory >& i_factory ) + :UnoSpinFieldControl( i_factory ) { mnFirst = Date( 1, 1, 1900 ).GetDate(); mnLast = Date( 31, 12, 2200 ).GetDate(); @@ -3432,7 +3458,8 @@ sal_Bool UnoDateFieldControl::isStrictFormat() throw(uno::RuntimeException) // ---------------------------------------------------- // class UnoControlTimeFieldModel // ---------------------------------------------------- -UnoControlTimeFieldModel::UnoControlTimeFieldModel() +UnoControlTimeFieldModel::UnoControlTimeFieldModel( const Reference< XMultiServiceFactory >& i_factory ) + :UnoControlModel( i_factory ) { UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXTimeField ); } @@ -3477,7 +3504,8 @@ uno::Reference< beans::XPropertySetInfo > UnoControlTimeFieldModel::getPropertyS // ---------------------------------------------------- // class UnoTimeFieldControl // ---------------------------------------------------- -UnoTimeFieldControl::UnoTimeFieldControl() +UnoTimeFieldControl::UnoTimeFieldControl( const Reference< XMultiServiceFactory >& i_factory ) + :UnoSpinFieldControl( i_factory ) { mnFirst = Time( 0, 0 ).GetTime(); mnLast = Time( 23, 59, 59, 99 ).GetTime(); @@ -3631,7 +3659,8 @@ sal_Bool UnoTimeFieldControl::isStrictFormat() throw(uno::RuntimeException) // ---------------------------------------------------- // class UnoControlNumericFieldModel // ---------------------------------------------------- -UnoControlNumericFieldModel::UnoControlNumericFieldModel() +UnoControlNumericFieldModel::UnoControlNumericFieldModel( const Reference< XMultiServiceFactory >& i_factory ) + :UnoControlModel( i_factory ) { UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXNumericField ); } @@ -3676,7 +3705,8 @@ uno::Reference< beans::XPropertySetInfo > UnoControlNumericFieldModel::getProper // ---------------------------------------------------- // class UnoNumericFieldControl // ---------------------------------------------------- -UnoNumericFieldControl::UnoNumericFieldControl() +UnoNumericFieldControl::UnoNumericFieldControl( const Reference< XMultiServiceFactory >& i_factory ) + :UnoSpinFieldControl( i_factory ) { mnFirst = 0; mnLast = 0x7FFFFFFF; @@ -3827,7 +3857,8 @@ sal_Int16 UnoNumericFieldControl::getDecimalDigits() throw(uno::RuntimeException // ---------------------------------------------------- // class UnoControlCurrencyFieldModel // ---------------------------------------------------- -UnoControlCurrencyFieldModel::UnoControlCurrencyFieldModel() +UnoControlCurrencyFieldModel::UnoControlCurrencyFieldModel( const Reference< XMultiServiceFactory >& i_factory ) + :UnoControlModel( i_factory ) { UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXCurrencyField ); } @@ -3876,7 +3907,8 @@ uno::Reference< beans::XPropertySetInfo > UnoControlCurrencyFieldModel::getPrope // ---------------------------------------------------- // class UnoCurrencyFieldControl // ---------------------------------------------------- -UnoCurrencyFieldControl::UnoCurrencyFieldControl() +UnoCurrencyFieldControl::UnoCurrencyFieldControl( const Reference< XMultiServiceFactory >& i_factory ) + :UnoSpinFieldControl( i_factory ) { mnFirst = 0; mnLast = 0x7FFFFFFF; @@ -4026,7 +4058,8 @@ sal_Int16 UnoCurrencyFieldControl::getDecimalDigits() throw(uno::RuntimeExceptio // ---------------------------------------------------- // class UnoControlPatternFieldModel // ---------------------------------------------------- -UnoControlPatternFieldModel::UnoControlPatternFieldModel() +UnoControlPatternFieldModel::UnoControlPatternFieldModel( const Reference< XMultiServiceFactory >& i_factory ) + :UnoControlModel( i_factory ) { UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXPatternField ); } @@ -4069,7 +4102,8 @@ uno::Reference< beans::XPropertySetInfo > UnoControlPatternFieldModel::getProper // ---------------------------------------------------- // class UnoPatternFieldControl // ---------------------------------------------------- -UnoPatternFieldControl::UnoPatternFieldControl() +UnoPatternFieldControl::UnoPatternFieldControl( const Reference< XMultiServiceFactory >& i_factory ) + :UnoSpinFieldControl( i_factory ) { } @@ -4158,7 +4192,8 @@ sal_Bool UnoPatternFieldControl::isStrictFormat() throw(uno::RuntimeException) // ---------------------------------------------------- // class UnoControlProgressBarModel // ---------------------------------------------------- -UnoControlProgressBarModel::UnoControlProgressBarModel() +UnoControlProgressBarModel::UnoControlProgressBarModel( const Reference< XMultiServiceFactory >& i_factory ) + :UnoControlModel( i_factory ) { ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR ); ImplRegisterProperty( BASEPROPERTY_BORDER ); @@ -4214,7 +4249,8 @@ uno::Reference< beans::XPropertySetInfo > UnoControlProgressBarModel::getPropert // ---------------------------------------------------- // class UnoProgressBarControl // ---------------------------------------------------- -UnoProgressBarControl::UnoProgressBarControl() +UnoProgressBarControl::UnoProgressBarControl( const Reference< XMultiServiceFactory >& i_factory ) + :UnoControlBase( i_factory ) { } @@ -4290,7 +4326,8 @@ sal_Int32 UnoProgressBarControl::getValue() throw(::com::sun::star::uno::Runtime // ---------------------------------------------------- // class UnoControlFixedLineModel // ---------------------------------------------------- -UnoControlFixedLineModel::UnoControlFixedLineModel() +UnoControlFixedLineModel::UnoControlFixedLineModel( const Reference< XMultiServiceFactory >& i_factory ) + :UnoControlModel( i_factory ) { ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR ); ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL ); @@ -4341,7 +4378,8 @@ uno::Reference< beans::XPropertySetInfo > UnoControlFixedLineModel::getPropertyS // ---------------------------------------------------- // class UnoFixedLineControl // ---------------------------------------------------- -UnoFixedLineControl::UnoFixedLineControl() +UnoFixedLineControl::UnoFixedLineControl( const Reference< XMultiServiceFactory >& i_factory ) + :UnoControlBase( i_factory ) { maComponentInfos.nWidth = 100; // ?? maComponentInfos.nHeight = 100; // ?? diff --git a/toolkit/source/helper/listenermultiplexer.cxx b/toolkit/source/helper/listenermultiplexer.cxx index f8011846aa3c..fcad9bd5e287 100644 --- a/toolkit/source/helper/listenermultiplexer.cxx +++ b/toolkit/source/helper/listenermultiplexer.cxx @@ -227,4 +227,9 @@ IMPL_LISTENERMULTIPLEXER_BASEMETHODS( TreeEditListenerMultiplexer, ::com::sun::s IMPL_LISTENERMULTIPLEXER_BASEMETHODS( SelectionListenerMultiplexer, ::com::sun::star::awt::grid::XGridSelectionListener ) IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( SelectionListenerMultiplexer, ::com::sun::star::awt::grid::XGridSelectionListener, selectionChanged, ::com::sun::star::awt::grid::GridSelectionEvent ) -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ +// ---------------------------------------------------- +// class SelectionListenerMultiplexer +// ---------------------------------------------------- +IMPL_LISTENERMULTIPLEXER_BASEMETHODS( TabPageListenerMultiplexer, ::com::sun::star::awt::tab::XTabPageContainerListener ) +IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD( TabPageListenerMultiplexer, ::com::sun::star::awt::tab::XTabPageContainerListener, tabPageActivated, ::com::sun::star::awt::tab::TabPageActivatedEvent ) +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file diff --git a/toolkit/source/helper/makefile.mk b/toolkit/source/helper/makefile.mk deleted file mode 100644 index bf10b0aa0178..000000000000 --- a/toolkit/source/helper/makefile.mk +++ /dev/null @@ -1,64 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=..$/.. - -PRJNAME=toolkit -TARGET=helper - -ENABLE_EXCEPTIONS=TRUE - -# --- Settings ----------------------------------------------------- - -.INCLUDE : settings.mk - -.INCLUDE : $(PRJ)$/util$/makefile.pmk - - -# --- Files -------------------------------------------------------- - -SLOFILES= \ - $(SLO)$/listenermultiplexer.obj \ - $(SLO)$/property.obj \ - $(SLO)$/registerservices.obj \ - $(SLO)$/servicenames.obj \ - $(SLO)$/tkresmgr.obj \ - $(SLO)$/unomemorystream.obj \ - $(SLO)$/unopropertyarrayhelper.obj \ - $(SLO)$/unowrapper.obj \ - $(SLO)$/vclunohelper.obj \ - $(SLO)$/externallock.obj \ - $(SLO)$/imagealign.obj \ - $(SLO)$/throbberimpl.obj \ - $(SLO)$/formpdfexport.obj \ - $(SLO)$/accessibilityclient.obj \ - $(SLO)$/fixedhyperbase.obj - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk - diff --git a/toolkit/source/helper/property.cxx b/toolkit/source/helper/property.cxx index 0702fd88720f..50358d779877 100644 --- a/toolkit/source/helper/property.cxx +++ b/toolkit/source/helper/property.cxx @@ -49,7 +49,6 @@ #include <com/sun/star/awt/tree/XTreeDataModel.hpp> #include <com/sun/star/awt/grid/XGridDataModel.hpp> #include <com/sun/star/awt/grid/XGridColumnModel.hpp> -#include <com/sun/star/awt/grid/ScrollBarMode.hpp> #include <com/sun/star/view/SelectionType.hpp> #include <com/sun/star/style/VerticalAlignment.hpp> #include <com/sun/star/util/XNumberFormatsSupplier.hpp> @@ -68,6 +67,7 @@ using ::com::sun::star::uno::Reference; using ::com::sun::star::awt::XDevice; using ::com::sun::star::awt::FontDescriptor; using ::com::sun::star::style::VerticalAlignment; +using ::com::sun::star::graphic::XGraphic; struct ImplPropertyInfo { @@ -183,7 +183,7 @@ ImplPropertyInfo* ImplGetPropertyInfos( sal_uInt16& rElementCount ) DECL_PROP_3 ( "FormatKey", FORMATKEY, sal_Int32, BOUND, MAYBEVOID, TRANSIENT ), DECL_PROP_3 ( "FormatsSupplier", FORMATSSUPPLIER, Reference< ::com::sun::star::util::XNumberFormatsSupplier >, BOUND, MAYBEVOID, TRANSIENT ), - DECL_PROP_2 ( "Graphic", GRAPHIC, Reference< ::com::sun::star::graphic::XGraphic >, BOUND, TRANSIENT ), + DECL_PROP_2 ( "Graphic", GRAPHIC, Reference< XGraphic >, BOUND, TRANSIENT ), DECL_PROP_2 ( "GroupName", GROUPNAME, ::rtl::OUString, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "HelpText", HELPTEXT, ::rtl::OUString, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "HelpURL", HELPURL, ::rtl::OUString, BOUND, MAYBEDEFAULT ), @@ -221,6 +221,7 @@ ImplPropertyInfo* ImplGetPropertyInfos( sal_uInt16& rElementCount ) DECL_PROP_2 ( "PushButtonType", PUSHBUTTONTYPE, sal_Int16, BOUND, MAYBEDEFAULT), DECL_PROP_2 ( "ReadOnly", READONLY, bool, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "Repeat", REPEAT, bool, BOUND, MAYBEDEFAULT ), + DECL_PROP_2 ( "AutoRepeat", AUTO_REPEAT, sal_Bool, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "RepeatDelay", REPEAT_DELAY, sal_Int32, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "ScaleImage", SCALEIMAGE, bool, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "ScaleMode", IMAGE_SCALE_MODE, sal_Int16, BOUND, MAYBEDEFAULT ), @@ -274,23 +275,26 @@ ImplPropertyInfo* ImplGetPropertyInfos( sal_uInt16& rElementCount ) DECL_PROP_2 ( "RootDisplayed", TREE_ROOTDISPLAYED, sal_Bool, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "ShowsHandles", TREE_SHOWSHANDLES, sal_Bool, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "ShowsRootHandles", TREE_SHOWSROOTHANDLES, sal_Bool, BOUND, MAYBEDEFAULT ), - DECL_PROP_3 ( "RowHeight", TREE_ROWHEIGHT, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ), + DECL_PROP_3 ( "RowHeight", ROW_HEIGHT, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ), DECL_PROP_2 ( "InvokesStopNodeEditing", TREE_INVOKESSTOPNODEEDITING, sal_Bool, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "DialogSourceURL", DIALOGSOURCEURL, ::rtl::OUString, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "URL", URL, ::rtl::OUString, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "WritingMode", WRITING_MODE, sal_Int16, BOUND, MAYBEDEFAULT ), DECL_PROP_3 ( "ContextWritingMode", CONTEXT_WRITING_MODE, sal_Int16, BOUND, MAYBEDEFAULT, TRANSIENT ), - DECL_PROP_2 ( "ShowRowHeader", GRID_SHOWROWHEADER, sal_Bool, BOUND, MAYBEDEFAULT ), - DECL_PROP_2 ( "ShowColumnHeader", GRID_SHOWCOLUMNHEADER, sal_Bool, BOUND, MAYBEDEFAULT ), - DECL_PROP_3 ( "GridDataModel", GRID_DATAMODEL, Reference< ::com::sun::star::awt::grid::XGridDataModel >, BOUND, MAYBEDEFAULT, MAYBEVOID ), - DECL_PROP_3 ( "ColumnModel", GRID_COLUMNMODEL, Reference< ::com::sun::star::awt::grid::XGridColumnModel >, BOUND, MAYBEDEFAULT, MAYBEVOID ), + DECL_PROP_2 ( "ShowRowHeader", GRID_SHOWROWHEADER, sal_Bool, BOUND, MAYBEDEFAULT ), + DECL_PROP_2 ( "RowHeaderWidth", ROW_HEADER_WIDTH, sal_Int32, BOUND, MAYBEDEFAULT ), + DECL_PROP_2 ( "ShowColumnHeader", GRID_SHOWCOLUMNHEADER, sal_Bool, BOUND, MAYBEDEFAULT ), + DECL_PROP_3 ( "ColumnHeaderHeight", COLUMN_HEADER_HEIGHT, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ), + DECL_PROP_1 ( "GridDataModel", GRID_DATAMODEL, Reference< ::com::sun::star::awt::grid::XGridDataModel >, BOUND ), + DECL_PROP_1 ( "ColumnModel", GRID_COLUMNMODEL, Reference< ::com::sun::star::awt::grid::XGridColumnModel >, BOUND ), DECL_PROP_3 ( "SelectionModel", GRID_SELECTIONMODE, ::com::sun::star::view::SelectionType, BOUND, MAYBEDEFAULT, MAYBEVOID ), DECL_PROP_2 ( "EnableVisible", ENABLEVISIBLE, sal_Bool, BOUND, MAYBEDEFAULT ), DECL_PROP_3 ( "ReferenceDevice", REFERENCE_DEVICE, Reference< XDevice >,BOUND, MAYBEDEFAULT, TRANSIENT ), - DECL_PROP_3 ( "EvenRowBackgroundColor", GRID_EVEN_ROW_BACKGROUND, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ), - DECL_PROP_3 ( "HeaderBackgroundColor", GRID_HEADER_BACKGROUND, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ), - DECL_PROP_3 ( "GridLineColor", GRID_LINE_COLOR, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ), - DECL_PROP_3 ( "RowBackgroundColor", GRID_ROW_BACKGROUND, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ), + DECL_PROP_3 ( "HeaderBackgroundColor", GRID_HEADER_BACKGROUND, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ), + DECL_PROP_3 ( "HeaderTextColor", GRID_HEADER_TEXT_COLOR, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ), + DECL_PROP_3 ( "GridLineColor", GRID_LINE_COLOR, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ), + DECL_PROP_3 ( "RowBackgroundColors", GRID_ROW_BACKGROUND_COLORS, Sequence< sal_Int32 >, BOUND, MAYBEDEFAULT, MAYBEVOID ), + DECL_PROP_2 ( "UseGridLines", USE_GRID_LINES, sal_Bool, BOUND, MAYBEDEFAULT ), DECL_DEP_PROP_3 ( "MultiPageValue", MULTIPAGEVALUE, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ), DECL_PROP_3 ( "AllDialogChildren", USERFORMCONTAINEES, Reference< ::com::sun::star::container::XNameContainer >, BOUND, MAYBEDEFAULT, MAYBEVOID ), }; diff --git a/toolkit/source/helper/registerservices.cxx b/toolkit/source/helper/registerservices.cxx index 7fbe410df046..c28615b34162 100644 --- a/toolkit/source/helper/registerservices.cxx +++ b/toolkit/source/helper/registerservices.cxx @@ -52,8 +52,14 @@ #include "toolkit/controls/tkspinbutton.hxx" #include <toolkit/controls/tksimpleanimation.hxx> #include <toolkit/controls/tkthrobber.hxx> +#include <toolkit/controls/animatedimages.hxx> +#include <toolkit/controls/spinningprogress.hxx> #include <toolkit/controls/dialogcontrol.hxx> +#include <toolkit/controls/tabpagemodel.hxx> +#include <toolkit/controls/tabpagecontainer.hxx> #include "toolkit/dllapi.h" +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> namespace toolkit { @@ -120,88 +126,98 @@ namespace toolkit { return ::com::sun::star::uno::Reference < ::com::sun::star::uno::XInterface >( ( ::cppu::OWeakObject* ) new ImplName ); } #define IMPL_CREATEINSTANCE2( ImplName ) \ - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ImplName##_CreateInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rSMgr) \ - { return ::com::sun::star::uno::Reference < ::com::sun::star::uno::XInterface >( ( ::cppu::OWeakObject* ) new ImplName( rSMgr ) ); } + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ImplName##_CreateInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ) \ + { return ::com::sun::star::uno::Reference < ::com::sun::star::uno::XInterface >( ( ::cppu::OWeakObject* ) new ImplName( i_factory ) ); } -::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL UnoControlDialogModel_CreateInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& ) +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL UnoControlDialogModel_CreateInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ) { - return ::com::sun::star::uno::Reference < ::com::sun::star::uno::XInterface >( ( ::cppu::OWeakObject* ) new OGeometryControlModel<UnoControlDialogModel> ); + return ::com::sun::star::uno::Reference < ::com::sun::star::uno::XInterface >( ( ::cppu::OWeakObject* ) new OGeometryControlModel<UnoControlDialogModel>( i_factory ) ); } -#define CHECKANDCREATEFACTORY( ImplName, ServiceName1, ServiceName2 ) \ - pRet = tryCreateFactory( sImplementationName, "stardiv.Toolkit." #ImplName, \ +#define GET_FACTORY_WITH_IMPL_PREFIX( ClassName, ImplNamePrefix, ServiceName1, ServiceName2 ) \ + pRet = tryCreateFactory( sImplementationName, ImplNamePrefix "." #ClassName, \ ServiceName1, ServiceName2, \ - ImplName##_CreateInstance, xServiceFactory \ + ClassName##_CreateInstance, xServiceFactory \ ); \ if ( pRet ) \ return pRet; \ +#define GET_FACTORY( ImplName, ServiceName1, ServiceName2 ) \ + GET_FACTORY_WITH_IMPL_PREFIX( ImplName, "stardiv.Toolkit", ServiceName1, ServiceName2 ) + using namespace toolkit; IMPL_CREATEINSTANCE2( VCLXToolkit ) IMPL_CREATEINSTANCE( StdTabController ) IMPL_CREATEINSTANCE( StdTabControllerModel ) -IMPL_CREATEINSTANCE( UnoButtonControl ) -IMPL_CREATEINSTANCE( UnoCheckBoxControl ) -IMPL_CREATEINSTANCE( UnoComboBoxControl ) -IMPL_CREATEINSTANCE( UnoControlButtonModel ) -IMPL_CREATEINSTANCE( UnoControlCheckBoxModel ) -IMPL_CREATEINSTANCE( UnoControlComboBoxModel ) -IMPL_CREATEINSTANCE( UnoControlContainer ) -IMPL_CREATEINSTANCE( UnoControlContainerModel ) -IMPL_CREATEINSTANCE( UnoControlCurrencyFieldModel ) -IMPL_CREATEINSTANCE( UnoControlDateFieldModel ) -IMPL_CREATEINSTANCE( UnoControlEditModel ) -IMPL_CREATEINSTANCE( UnoControlFileControlModel ) -IMPL_CREATEINSTANCE( UnoControlFixedHyperlinkModel ) -IMPL_CREATEINSTANCE( UnoControlFixedTextModel ) -IMPL_CREATEINSTANCE( UnoControlFormattedFieldModel ) -IMPL_CREATEINSTANCE( UnoControlGroupBoxModel ) -IMPL_CREATEINSTANCE( UnoControlImageControlModel ) -IMPL_CREATEINSTANCE( UnoControlListBoxModel ) -IMPL_CREATEINSTANCE( UnoControlNumericFieldModel ) -IMPL_CREATEINSTANCE( UnoControlPatternFieldModel ) -IMPL_CREATEINSTANCE( UnoControlRadioButtonModel ) -IMPL_CREATEINSTANCE( UnoControlTimeFieldModel ) -IMPL_CREATEINSTANCE( UnoControlProgressBarModel ) -IMPL_CREATEINSTANCE( UnoControlScrollBarModel ) -IMPL_CREATEINSTANCE( UnoSpinButtonModel ) -IMPL_CREATEINSTANCE( UnoMultiPageModel ) -IMPL_CREATEINSTANCE( UnoPageModel ) -IMPL_CREATEINSTANCE( UnoFrameModel ) -IMPL_CREATEINSTANCE( UnoControlFixedLineModel ) -IMPL_CREATEINSTANCE( UnoCurrencyFieldControl ) -IMPL_CREATEINSTANCE( UnoDateFieldControl ) -IMPL_CREATEINSTANCE( UnoDialogControl ) -IMPL_CREATEINSTANCE( UnoEditControl ) -IMPL_CREATEINSTANCE( UnoFileControl ) -IMPL_CREATEINSTANCE( UnoFixedHyperlinkControl ) -IMPL_CREATEINSTANCE( UnoFixedTextControl ) -IMPL_CREATEINSTANCE( UnoFormattedFieldControl ) -IMPL_CREATEINSTANCE( UnoGroupBoxControl ) -IMPL_CREATEINSTANCE( UnoImageControlControl ) -IMPL_CREATEINSTANCE( UnoListBoxControl ) -IMPL_CREATEINSTANCE( UnoNumericFieldControl ) -IMPL_CREATEINSTANCE( UnoPatternFieldControl ) -IMPL_CREATEINSTANCE( UnoRadioButtonControl ) -IMPL_CREATEINSTANCE( UnoTimeFieldControl ) -IMPL_CREATEINSTANCE( UnoProgressBarControl ) -IMPL_CREATEINSTANCE( UnoScrollBarControl ) -IMPL_CREATEINSTANCE( UnoSpinButtonControl ) +IMPL_CREATEINSTANCE2( UnoButtonControl ) +IMPL_CREATEINSTANCE2( UnoCheckBoxControl ) +IMPL_CREATEINSTANCE2( UnoComboBoxControl ) +IMPL_CREATEINSTANCE2( UnoControlButtonModel ) +IMPL_CREATEINSTANCE2( UnoControlCheckBoxModel ) +IMPL_CREATEINSTANCE2( UnoControlComboBoxModel ) +IMPL_CREATEINSTANCE2( UnoControlContainer ) +IMPL_CREATEINSTANCE2( UnoControlContainerModel ) +IMPL_CREATEINSTANCE2( UnoControlCurrencyFieldModel ) +IMPL_CREATEINSTANCE2( UnoControlDateFieldModel ) +IMPL_CREATEINSTANCE2( UnoControlEditModel ) +IMPL_CREATEINSTANCE2( UnoControlFileControlModel ) +IMPL_CREATEINSTANCE2( UnoControlFixedHyperlinkModel ) +IMPL_CREATEINSTANCE2( UnoControlFixedTextModel ) +IMPL_CREATEINSTANCE2( UnoControlFormattedFieldModel ) +IMPL_CREATEINSTANCE2( UnoControlGroupBoxModel ) +IMPL_CREATEINSTANCE2( UnoControlImageControlModel ) +IMPL_CREATEINSTANCE2( UnoControlListBoxModel ) +IMPL_CREATEINSTANCE2( UnoControlNumericFieldModel ) +IMPL_CREATEINSTANCE2( UnoControlPatternFieldModel ) +IMPL_CREATEINSTANCE2( UnoControlRadioButtonModel ) +IMPL_CREATEINSTANCE2( UnoControlTimeFieldModel ) +IMPL_CREATEINSTANCE2( UnoControlProgressBarModel ) +IMPL_CREATEINSTANCE2( UnoControlScrollBarModel ) +IMPL_CREATEINSTANCE2( UnoSpinButtonModel ) +IMPL_CREATEINSTANCE2( UnoMultiPageModel ) +IMPL_CREATEINSTANCE2( UnoPageModel ) +IMPL_CREATEINSTANCE2( UnoFrameModel ) +IMPL_CREATEINSTANCE2( UnoControlFixedLineModel ) +IMPL_CREATEINSTANCE2( UnoCurrencyFieldControl ) +IMPL_CREATEINSTANCE2( UnoDateFieldControl ) +IMPL_CREATEINSTANCE2( UnoDialogControl ) +IMPL_CREATEINSTANCE2( UnoEditControl ) +IMPL_CREATEINSTANCE2( UnoFileControl ) +IMPL_CREATEINSTANCE2( UnoFixedHyperlinkControl ) +IMPL_CREATEINSTANCE2( UnoFixedTextControl ) +IMPL_CREATEINSTANCE2( UnoFormattedFieldControl ) +IMPL_CREATEINSTANCE2( UnoGroupBoxControl ) +IMPL_CREATEINSTANCE2( UnoImageControlControl ) +IMPL_CREATEINSTANCE2( UnoListBoxControl ) +IMPL_CREATEINSTANCE2( UnoNumericFieldControl ) +IMPL_CREATEINSTANCE2( UnoPatternFieldControl ) +IMPL_CREATEINSTANCE2( UnoRadioButtonControl ) +IMPL_CREATEINSTANCE2( UnoTimeFieldControl ) +IMPL_CREATEINSTANCE2( UnoProgressBarControl ) +IMPL_CREATEINSTANCE2( UnoScrollBarControl ) +IMPL_CREATEINSTANCE2( UnoSpinButtonControl ) +IMPL_CREATEINSTANCE2( UnoFixedLineControl ) IMPL_CREATEINSTANCE( UnoMultiPageControl ) IMPL_CREATEINSTANCE( UnoPageControl ) IMPL_CREATEINSTANCE( UnoFrameControl ) -IMPL_CREATEINSTANCE( UnoFixedLineControl ) IMPL_CREATEINSTANCE( VCLXMenuBar ) IMPL_CREATEINSTANCE( VCLXPointer ) IMPL_CREATEINSTANCE( VCLXPopupMenu ) IMPL_CREATEINSTANCE( VCLXPrinterServer ) -IMPL_CREATEINSTANCE( UnoRoadmapControl ) -IMPL_CREATEINSTANCE( UnoControlRoadmapModel ) -IMPL_CREATEINSTANCE( UnoSimpleAnimationControl ) -IMPL_CREATEINSTANCE( UnoSimpleAnimationControlModel ) -IMPL_CREATEINSTANCE( UnoThrobberControl ) -IMPL_CREATEINSTANCE( UnoThrobberControlModel ) +IMPL_CREATEINSTANCE2( UnoRoadmapControl ) +IMPL_CREATEINSTANCE2( UnoControlRoadmapModel ) +IMPL_CREATEINSTANCE2( UnoSimpleAnimationControl ) +IMPL_CREATEINSTANCE2( UnoSimpleAnimationControlModel ) +IMPL_CREATEINSTANCE2( UnoThrobberControl ) +IMPL_CREATEINSTANCE2( UnoThrobberControlModel ) +IMPL_CREATEINSTANCE2( UnoControlTabPage ) +IMPL_CREATEINSTANCE2( UnoControlTabPageModel ) +IMPL_CREATEINSTANCE2( UnoControlTabPageContainer ) +IMPL_CREATEINSTANCE2( UnoControlTabPageContainerModel ) +IMPL_CREATEINSTANCE2( AnimatedImagesControl ) +IMPL_CREATEINSTANCE2( AnimatedImagesControlModel ) +IMPL_CREATEINSTANCE2( SpinningProgressControlModel ) extern ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL TreeControl_CreateInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& ); extern ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL TreeControlModel_CreateInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& ); @@ -211,11 +227,10 @@ extern ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL extern ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL DefaultGridDataModel_CreateInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& ); extern ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL DefaultGridColumnModel_CreateInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& ); extern ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL GridColumn_CreateInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& ); +extern ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SortableGridDataModel_CreateInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& ); -extern sal_Bool SAL_CALL comp_AsyncCallback_component_writeInfo( void * serviceManager, void * registryKey ); extern void * SAL_CALL comp_AsyncCallback_component_getFactory( const char * implName, void * serviceManager, void * registryKey ); -extern sal_Bool SAL_CALL comp_Layout_component_writeInfo( void * serviceManager, void * registryKey ); extern void * SAL_CALL comp_Layout_component_getFactory( const char * implName, void * serviceManager, void * registryKey ); extern "C" @@ -226,97 +241,6 @@ TOOLKIT_DLLPUBLIC void SAL_CALL component_getImplementationEnvironment( const sa *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } -TOOLKIT_DLLPUBLIC sal_Bool SAL_CALL component_writeInfo( void* _pServiceManager, void* _pRegistryKey ) -{ - if (_pRegistryKey) - { - ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > xRegistryKey = - static_cast< ::com::sun::star::registry::XRegistryKey* >( _pRegistryKey ); - - registerServices( xRegistryKey, "VCLXToolkit", szServiceName_Toolkit, szServiceName2_Toolkit ); - registerServices( xRegistryKey, "VCLXPopupMenu", szServiceName_PopupMenu, szServiceName2_PopupMenu ); - registerServices( xRegistryKey, "VCLXMenuBar", szServiceName_MenuBar, szServiceName2_MenuBar ); - registerServices( xRegistryKey, "VCLXPointer", szServiceName_Pointer, szServiceName2_Pointer ); - registerServices( xRegistryKey, "UnoControlContainer", szServiceName_UnoControlContainer, szServiceName2_UnoControlContainer ); - registerServices( xRegistryKey, "UnoControlContainerModel", szServiceName_UnoControlContainerModel, szServiceName2_UnoControlContainerModel ); - registerServices( xRegistryKey, "StdTabController", szServiceName_TabController, szServiceName2_TabController ); - registerServices( xRegistryKey, "StdTabControllerModel", szServiceName_TabControllerModel, szServiceName2_TabControllerModel ); - registerServices( xRegistryKey, "UnoDialogControl", szServiceName_UnoControlDialog, szServiceName2_UnoControlDialog ); - registerServices( xRegistryKey, "UnoControlDialogModel", szServiceName_UnoControlDialogModel, szServiceName2_UnoControlDialogModel ); - registerServices( xRegistryKey, "UnoEditControl", szServiceName_UnoControlEdit, szServiceName2_UnoControlEdit ); - registerServices( xRegistryKey, "UnoControlEditModel", szServiceName_UnoControlEditModel, szServiceName2_UnoControlEditModel ); - registerServices( xRegistryKey, "UnoDateFieldControl", szServiceName_UnoControlDateField, szServiceName2_UnoControlDateField ); - registerServices( xRegistryKey, "UnoControlDateFieldModel", szServiceName_UnoControlDateFieldModel, szServiceName2_UnoControlDateFieldModel ); - registerServices( xRegistryKey, "UnoTimeFieldControl", szServiceName_UnoControlTimeField, szServiceName2_UnoControlTimeField ); - registerServices( xRegistryKey, "UnoControlTimeFieldModel", szServiceName_UnoControlTimeFieldModel, szServiceName2_UnoControlTimeFieldModel ); - registerServices( xRegistryKey, "UnoNumericFieldControl", szServiceName_UnoControlNumericField, szServiceName2_UnoControlNumericField ); - registerServices( xRegistryKey, "UnoControlNumericFieldModel", szServiceName_UnoControlNumericFieldModel, szServiceName2_UnoControlNumericFieldModel ); - registerServices( xRegistryKey, "UnoCurrencyFieldControl", szServiceName_UnoControlCurrencyField, szServiceName2_UnoControlCurrencyField ); - registerServices( xRegistryKey, "UnoControlCurrencyFieldModel", szServiceName_UnoControlCurrencyFieldModel, szServiceName2_UnoControlCurrencyFieldModel ); - registerServices( xRegistryKey, "UnoPatternFieldControl", szServiceName_UnoControlPatternField, szServiceName2_UnoControlPatternField ); - registerServices( xRegistryKey, "UnoControlPatternFieldModel", szServiceName_UnoControlPatternFieldModel, szServiceName2_UnoControlPatternFieldModel ); - registerServices( xRegistryKey, "UnoFormattedFieldControl", szServiceName_UnoControlFormattedField, szServiceName2_UnoControlFormattedField ); - registerServices( xRegistryKey, "UnoControlFormattedFieldModel", szServiceName_UnoControlFormattedFieldModel, szServiceName2_UnoControlFormattedFieldModel ); - registerServices( xRegistryKey, "UnoFileControl", szServiceName_UnoControlFileControl, szServiceName2_UnoControlFileControl ); - registerServices( xRegistryKey, "UnoControlFileControlModel", szServiceName_UnoControlFileControlModel, szServiceName2_UnoControlFileControlModel ); - registerServices( xRegistryKey, "UnoButtonControl", szServiceName_UnoControlButton, szServiceName2_UnoControlButton ); - registerServices( xRegistryKey, "UnoControlButtonModel", szServiceName_UnoControlButtonModel, szServiceName2_UnoControlButtonModel ); - registerServices( xRegistryKey, "UnoImageControlControl", szServiceName_UnoControlImageButton, szServiceName2_UnoControlImageButton ); - registerServices( xRegistryKey, "UnoControlImageControlModel", szServiceName_UnoControlImageButtonModel, szServiceName2_UnoControlImageButtonModel ); - registerServices( xRegistryKey, "UnoImageControlControl", szServiceName_UnoControlImageControl, szServiceName2_UnoControlImageControl ); - registerServices( xRegistryKey, "UnoControlImageControlModel", szServiceName_UnoControlImageControlModel, szServiceName2_UnoControlImageControlModel ); - registerServices( xRegistryKey, "UnoRadioButtonControl", szServiceName_UnoControlRadioButton, szServiceName2_UnoControlRadioButton ); - registerServices( xRegistryKey, "UnoControlRadioButtonModel", szServiceName_UnoControlRadioButtonModel, szServiceName2_UnoControlRadioButtonModel ); - registerServices( xRegistryKey, "UnoCheckBoxControl", szServiceName_UnoControlCheckBox, szServiceName2_UnoControlCheckBox ); - registerServices( xRegistryKey, "UnoControlCheckBoxModel", szServiceName_UnoControlCheckBoxModel, szServiceName2_UnoControlCheckBoxModel ); - registerServices( xRegistryKey, "UnoListBoxControl", szServiceName_UnoControlListBox, szServiceName2_UnoControlListBox ); - registerServices( xRegistryKey, "UnoControlListBoxModel", szServiceName_UnoControlListBoxModel, szServiceName2_UnoControlListBoxModel ); - registerServices( xRegistryKey, "UnoComboBoxControl", szServiceName_UnoControlComboBox, szServiceName2_UnoControlComboBox ); - registerServices( xRegistryKey, "UnoControlComboBoxModel", szServiceName_UnoControlComboBoxModel, szServiceName2_UnoControlComboBoxModel ); - registerServices( xRegistryKey, "UnoFixedTextControl", szServiceName_UnoControlFixedText, szServiceName2_UnoControlFixedText ); - registerServices( xRegistryKey, "UnoControlFixedTextModel", szServiceName_UnoControlFixedTextModel, szServiceName2_UnoControlFixedTextModel ); - registerServices( xRegistryKey, "UnoGroupBoxControl", szServiceName_UnoControlGroupBox, szServiceName2_UnoControlGroupBox ); - registerServices( xRegistryKey, "UnoControlGroupBoxModel", szServiceName_UnoControlGroupBoxModel, szServiceName2_UnoControlGroupBoxModel ); - registerServices( xRegistryKey, "UnoProgressBarControl", szServiceName_UnoControlProgressBar, szServiceName2_UnoControlProgressBar ); - registerServices( xRegistryKey, "UnoControlProgressBarModel", szServiceName_UnoControlProgressBarModel, szServiceName2_UnoControlProgressBarModel ); - registerServices( xRegistryKey, "UnoScrollBarControl", szServiceName_UnoControlScrollBar, szServiceName2_UnoControlScrollBar ); - registerServices( xRegistryKey, "UnoControlScrollBarModel", szServiceName_UnoControlScrollBarModel, szServiceName2_UnoControlScrollBarModel ); - registerServices( xRegistryKey, "UnoSpinButtonModel", szServiceName_UnoSpinButtonModel ); - registerServices( xRegistryKey, "UnoSpinButtonControl", szServiceName_UnoSpinButtonControl ); - registerServices( xRegistryKey, "UnoMultiPageModel", szServiceName_UnoMultiPageModel ); - registerServices( xRegistryKey, "UnoMultiPageControl", szServiceName_UnoMultiPageControl ); - registerServices( xRegistryKey, "UnoPageModel", szServiceName_UnoPageModel ); - registerServices( xRegistryKey, "UnoPageControl", szServiceName_UnoPageControl ); - registerServices( xRegistryKey, "UnoFrameModel", szServiceName_UnoFrameModel ); - registerServices( xRegistryKey, "UnoFrameControl", szServiceName_UnoFrameControl ); - registerServices( xRegistryKey, "UnoFixedLineControl", szServiceName_UnoControlFixedLine, szServiceName2_UnoControlFixedLine ); - registerServices( xRegistryKey, "UnoControlFixedLineModel", szServiceName_UnoControlFixedLineModel, szServiceName2_UnoControlFixedLineModel ); - registerServices( xRegistryKey, "VCLXPrinterServer", szServiceName_PrinterServer, szServiceName2_PrinterServer ); - registerServices( xRegistryKey, "UnoRoadmapControl", szServiceName_UnoControlRoadmap, szServiceName2_UnoControlRoadmap ); - registerServices( xRegistryKey, "UnoControlRoadmapModel", szServiceName_UnoControlRoadmapModel, szServiceName2_UnoControlRoadmapModel ); - registerServices( xRegistryKey, "TreeControl", szServiceName_TreeControl ); - registerServices( xRegistryKey, "TreeControlModel", szServiceName_TreeControlModel ); - registerServices( xRegistryKey, "MutableTreeDataModel", szServiceName_MutableTreeDataModel ); - registerServices( xRegistryKey, "UnoSimpleAnimationControlModel", szServiceName_UnoSimpleAnimationControlModel, szServiceName2_UnoSimpleAnimationControlModel ); - registerServices( xRegistryKey, "UnoSimpleAnimationControl", szServiceName_UnoSimpleAnimationControl, szServiceName2_UnoSimpleAnimationControl ); - registerServices( xRegistryKey, "UnoThrobberControlModel", szServiceName_UnoThrobberControlModel, szServiceName2_UnoThrobberControlModel ); - registerServices( xRegistryKey, "UnoThrobberControl", szServiceName_UnoThrobberControl, szServiceName2_UnoThrobberControl ); - registerServices( xRegistryKey, "UnoFixedHyperlinkControl", szServiceName_UnoControlFixedHyperlink ); - registerServices( xRegistryKey, "UnoControlFixedHyperlinkModel", szServiceName_UnoControlFixedHyperlinkModel ); - registerServices( xRegistryKey, "GridControl", szServiceName_GridControl ); - registerServices( xRegistryKey, "GridControlModel", szServiceName_GridControlModel ); - registerServices( xRegistryKey, "DefaultGridDataModel", szServiceName_DefaultGridDataModel ); - registerServices( xRegistryKey, "DefaultGridColumnModel", szServiceName_DefaultGridColumnModel ); - registerServices( xRegistryKey, "GridColumn", szServiceName_GridColumn ); - - comp_AsyncCallback_component_writeInfo( _pServiceManager, _pRegistryKey ); - comp_Layout_component_writeInfo( _pServiceManager, _pRegistryKey ); - - return sal_True; - } - return sal_False; -} - TOOLKIT_DLLPUBLIC void* SAL_CALL component_getFactory( const sal_Char* sImplementationName, void* _pServiceManager, void* _pRegistryKey ) { void* pRet = NULL; @@ -325,87 +249,92 @@ TOOLKIT_DLLPUBLIC void* SAL_CALL component_getFactory( const sal_Char* sImplemen { ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory = static_cast< ::com::sun::star::lang::XMultiServiceFactory* >( _pServiceManager ); - CHECKANDCREATEFACTORY( VCLXToolkit, szServiceName_Toolkit, szServiceName2_Toolkit ) - CHECKANDCREATEFACTORY( VCLXPopupMenu, szServiceName_PopupMenu, szServiceName2_PopupMenu ) - CHECKANDCREATEFACTORY( VCLXMenuBar, szServiceName_MenuBar, szServiceName2_MenuBar ) - CHECKANDCREATEFACTORY( VCLXPointer, szServiceName_Pointer, szServiceName2_Pointer ) - CHECKANDCREATEFACTORY( UnoControlContainer, szServiceName_UnoControlContainer, szServiceName2_UnoControlContainer ) - CHECKANDCREATEFACTORY( UnoControlContainerModel, szServiceName_UnoControlContainerModel, szServiceName2_UnoControlContainerModel ) - CHECKANDCREATEFACTORY( StdTabController, szServiceName_TabController, szServiceName2_TabController ) - CHECKANDCREATEFACTORY( StdTabControllerModel, szServiceName_TabControllerModel, szServiceName2_TabControllerModel ) - CHECKANDCREATEFACTORY( UnoDialogControl, szServiceName_UnoControlDialog, szServiceName2_UnoControlDialog ) - CHECKANDCREATEFACTORY( UnoControlDialogModel, szServiceName_UnoControlDialogModel, szServiceName2_UnoControlDialogModel ) - CHECKANDCREATEFACTORY( UnoEditControl, szServiceName_UnoControlEdit, szServiceName2_UnoControlEdit ) - CHECKANDCREATEFACTORY( UnoControlEditModel, szServiceName_UnoControlEditModel, szServiceName2_UnoControlEditModel ) - CHECKANDCREATEFACTORY( UnoDateFieldControl, szServiceName_UnoControlDateField, szServiceName2_UnoControlDateField ) - CHECKANDCREATEFACTORY( UnoControlDateFieldModel, szServiceName_UnoControlDateFieldModel, szServiceName2_UnoControlDateFieldModel ) - CHECKANDCREATEFACTORY( UnoTimeFieldControl, szServiceName_UnoControlTimeField, szServiceName2_UnoControlTimeField ) - CHECKANDCREATEFACTORY( UnoControlTimeFieldModel, szServiceName_UnoControlTimeFieldModel, szServiceName2_UnoControlTimeFieldModel ) - CHECKANDCREATEFACTORY( UnoNumericFieldControl, szServiceName_UnoControlNumericField, szServiceName2_UnoControlNumericField ) - CHECKANDCREATEFACTORY( UnoControlNumericFieldModel, szServiceName_UnoControlNumericFieldModel, szServiceName2_UnoControlNumericFieldModel ) - CHECKANDCREATEFACTORY( UnoCurrencyFieldControl, szServiceName_UnoControlCurrencyField, szServiceName2_UnoControlCurrencyField ) - CHECKANDCREATEFACTORY( UnoControlCurrencyFieldModel, szServiceName_UnoControlCurrencyFieldModel, szServiceName2_UnoControlCurrencyFieldModel ) - CHECKANDCREATEFACTORY( UnoPatternFieldControl, szServiceName_UnoControlPatternField, szServiceName2_UnoControlPatternField ) - CHECKANDCREATEFACTORY( UnoControlPatternFieldModel, szServiceName_UnoControlPatternFieldModel, szServiceName2_UnoControlPatternFieldModel ) - CHECKANDCREATEFACTORY( UnoFormattedFieldControl, szServiceName_UnoControlFormattedField, szServiceName2_UnoControlFormattedField ) - CHECKANDCREATEFACTORY( UnoControlFormattedFieldModel, szServiceName_UnoControlFormattedFieldModel, szServiceName2_UnoControlFormattedFieldModel ) - CHECKANDCREATEFACTORY( UnoFileControl, szServiceName_UnoControlFileControl, szServiceName2_UnoControlFileControl ) - CHECKANDCREATEFACTORY( UnoControlFileControlModel, szServiceName_UnoControlFileControlModel, szServiceName2_UnoControlFileControlModel ) - CHECKANDCREATEFACTORY( UnoButtonControl, szServiceName_UnoControlButton, szServiceName2_UnoControlButton ) - CHECKANDCREATEFACTORY( UnoControlButtonModel, szServiceName_UnoControlButtonModel, szServiceName2_UnoControlButtonModel ) - CHECKANDCREATEFACTORY( UnoImageControlControl, szServiceName_UnoControlImageButton, szServiceName2_UnoControlImageButton ) - CHECKANDCREATEFACTORY( UnoControlImageControlModel, szServiceName_UnoControlImageButtonModel, szServiceName2_UnoControlImageButtonModel ) - CHECKANDCREATEFACTORY( UnoImageControlControl, szServiceName_UnoControlImageControl, szServiceName2_UnoControlImageControl ) - CHECKANDCREATEFACTORY( UnoControlImageControlModel, szServiceName_UnoControlImageControlModel, szServiceName2_UnoControlImageControlModel ) - CHECKANDCREATEFACTORY( UnoRadioButtonControl, szServiceName_UnoControlRadioButton, szServiceName2_UnoControlRadioButton ) - CHECKANDCREATEFACTORY( UnoControlRadioButtonModel, szServiceName_UnoControlRadioButtonModel, szServiceName2_UnoControlRadioButtonModel ) - CHECKANDCREATEFACTORY( UnoCheckBoxControl, szServiceName_UnoControlCheckBox, szServiceName2_UnoControlCheckBox ) - CHECKANDCREATEFACTORY( UnoControlCheckBoxModel, szServiceName_UnoControlCheckBoxModel, szServiceName2_UnoControlCheckBoxModel ) - CHECKANDCREATEFACTORY( UnoListBoxControl, szServiceName_UnoControlListBox, szServiceName2_UnoControlListBox ) - CHECKANDCREATEFACTORY( UnoControlListBoxModel, szServiceName_UnoControlListBoxModel, szServiceName2_UnoControlListBoxModel ) - CHECKANDCREATEFACTORY( UnoComboBoxControl, szServiceName_UnoControlComboBox, szServiceName2_UnoControlComboBox ) - CHECKANDCREATEFACTORY( UnoControlComboBoxModel, szServiceName_UnoControlComboBoxModel, szServiceName2_UnoControlComboBoxModel ) - CHECKANDCREATEFACTORY( UnoFixedTextControl, szServiceName_UnoControlFixedText, szServiceName2_UnoControlFixedText ) - CHECKANDCREATEFACTORY( UnoControlFixedTextModel, szServiceName_UnoControlFixedTextModel, szServiceName2_UnoControlFixedTextModel ) - CHECKANDCREATEFACTORY( UnoGroupBoxControl, szServiceName_UnoControlGroupBox, szServiceName2_UnoControlGroupBox ) - CHECKANDCREATEFACTORY( UnoControlGroupBoxModel, szServiceName_UnoControlGroupBoxModel, szServiceName2_UnoControlGroupBoxModel ) - CHECKANDCREATEFACTORY( UnoProgressBarControl, szServiceName_UnoControlProgressBar, szServiceName2_UnoControlProgressBar ) - CHECKANDCREATEFACTORY( UnoControlProgressBarModel, szServiceName_UnoControlProgressBarModel, szServiceName2_UnoControlProgressBarModel ) - CHECKANDCREATEFACTORY( UnoScrollBarControl, szServiceName_UnoControlScrollBar, szServiceName2_UnoControlScrollBar ) - CHECKANDCREATEFACTORY( UnoControlScrollBarModel, szServiceName_UnoControlScrollBarModel, szServiceName2_UnoControlScrollBarModel ) - CHECKANDCREATEFACTORY( UnoFixedLineControl, szServiceName_UnoControlFixedLine, szServiceName2_UnoControlFixedLine ) - CHECKANDCREATEFACTORY( UnoControlFixedLineModel, szServiceName_UnoControlFixedLineModel, szServiceName2_UnoControlFixedLineModel ) - CHECKANDCREATEFACTORY( VCLXPrinterServer, szServiceName_PrinterServer, szServiceName2_PrinterServer ) - CHECKANDCREATEFACTORY( UnoRoadmapControl, szServiceName_UnoControlRoadmap, szServiceName2_UnoControlRoadmap ) - CHECKANDCREATEFACTORY( UnoControlRoadmapModel, szServiceName_UnoControlRoadmapModel, szServiceName2_UnoControlRoadmapModel ) - CHECKANDCREATEFACTORY( UnoMultiPageModel, szServiceName_UnoMultiPageModel, NULL ) - CHECKANDCREATEFACTORY( UnoMultiPageControl, szServiceName_UnoMultiPageControl, NULL ) - CHECKANDCREATEFACTORY( UnoPageModel, szServiceName_UnoPageModel, NULL ) - CHECKANDCREATEFACTORY( UnoPageControl, szServiceName_UnoPageControl, NULL ) - CHECKANDCREATEFACTORY( UnoFrameModel, szServiceName_UnoFrameModel, NULL ) - CHECKANDCREATEFACTORY( UnoFrameControl, szServiceName_UnoFrameControl, NULL ) - CHECKANDCREATEFACTORY( UnoSpinButtonModel, szServiceName_UnoSpinButtonModel, NULL ) - CHECKANDCREATEFACTORY( UnoSpinButtonControl, szServiceName_UnoSpinButtonControl, NULL ) - CHECKANDCREATEFACTORY( TreeControl, szServiceName_TreeControl, NULL ) - CHECKANDCREATEFACTORY( TreeControlModel, szServiceName_TreeControlModel, NULL ) - CHECKANDCREATEFACTORY( MutableTreeDataModel, szServiceName_MutableTreeDataModel, NULL ) - CHECKANDCREATEFACTORY( UnoSimpleAnimationControlModel, szServiceName_UnoSimpleAnimationControlModel, szServiceName2_UnoSimpleAnimationControlModel ) - CHECKANDCREATEFACTORY( UnoSimpleAnimationControl, szServiceName_UnoSimpleAnimationControl, szServiceName2_UnoSimpleAnimationControl ) - CHECKANDCREATEFACTORY( UnoThrobberControlModel, szServiceName_UnoThrobberControlModel, szServiceName2_UnoThrobberControlModel ) - CHECKANDCREATEFACTORY( UnoThrobberControl, szServiceName_UnoThrobberControl, szServiceName2_UnoThrobberControl ) - CHECKANDCREATEFACTORY( UnoFixedHyperlinkControl, szServiceName_UnoControlFixedHyperlink, NULL ) - CHECKANDCREATEFACTORY( UnoControlFixedHyperlinkModel, szServiceName_UnoControlFixedHyperlinkModel, NULL ) - CHECKANDCREATEFACTORY( GridControl, szServiceName_GridControl, NULL ); - CHECKANDCREATEFACTORY( GridControlModel, szServiceName_GridControlModel, NULL ); - CHECKANDCREATEFACTORY( DefaultGridDataModel, szServiceName_DefaultGridDataModel, NULL ); - CHECKANDCREATEFACTORY( DefaultGridColumnModel, szServiceName_DefaultGridColumnModel, NULL ); - CHECKANDCREATEFACTORY( GridColumn, szServiceName_GridColumn, NULL ); - + GET_FACTORY( VCLXToolkit, szServiceName_Toolkit, szServiceName2_Toolkit ) + GET_FACTORY( VCLXPopupMenu, szServiceName_PopupMenu, szServiceName2_PopupMenu ) + GET_FACTORY( VCLXMenuBar, szServiceName_MenuBar, szServiceName2_MenuBar ) + GET_FACTORY( VCLXPointer, szServiceName_Pointer, szServiceName2_Pointer ) + GET_FACTORY( UnoControlContainer, szServiceName_UnoControlContainer, szServiceName2_UnoControlContainer ) + GET_FACTORY( UnoControlContainerModel, szServiceName_UnoControlContainerModel, szServiceName2_UnoControlContainerModel ) + GET_FACTORY( StdTabController, szServiceName_TabController, szServiceName2_TabController ) + GET_FACTORY( StdTabControllerModel, szServiceName_TabControllerModel, szServiceName2_TabControllerModel ) + GET_FACTORY( UnoDialogControl, szServiceName_UnoControlDialog, szServiceName2_UnoControlDialog ) + GET_FACTORY( UnoControlDialogModel, szServiceName_UnoControlDialogModel, szServiceName2_UnoControlDialogModel ) + GET_FACTORY( UnoEditControl, szServiceName_UnoControlEdit, szServiceName2_UnoControlEdit ) + GET_FACTORY( UnoControlEditModel, szServiceName_UnoControlEditModel, szServiceName2_UnoControlEditModel ) + GET_FACTORY( UnoDateFieldControl, szServiceName_UnoControlDateField, szServiceName2_UnoControlDateField ) + GET_FACTORY( UnoControlDateFieldModel, szServiceName_UnoControlDateFieldModel, szServiceName2_UnoControlDateFieldModel ) + GET_FACTORY( UnoTimeFieldControl, szServiceName_UnoControlTimeField, szServiceName2_UnoControlTimeField ) + GET_FACTORY( UnoControlTimeFieldModel, szServiceName_UnoControlTimeFieldModel, szServiceName2_UnoControlTimeFieldModel ) + GET_FACTORY( UnoNumericFieldControl, szServiceName_UnoControlNumericField, szServiceName2_UnoControlNumericField ) + GET_FACTORY( UnoControlNumericFieldModel, szServiceName_UnoControlNumericFieldModel, szServiceName2_UnoControlNumericFieldModel ) + GET_FACTORY( UnoCurrencyFieldControl, szServiceName_UnoControlCurrencyField, szServiceName2_UnoControlCurrencyField ) + GET_FACTORY( UnoControlCurrencyFieldModel, szServiceName_UnoControlCurrencyFieldModel, szServiceName2_UnoControlCurrencyFieldModel ) + GET_FACTORY( UnoPatternFieldControl, szServiceName_UnoControlPatternField, szServiceName2_UnoControlPatternField ) + GET_FACTORY( UnoControlPatternFieldModel, szServiceName_UnoControlPatternFieldModel, szServiceName2_UnoControlPatternFieldModel ) + GET_FACTORY( UnoFormattedFieldControl, szServiceName_UnoControlFormattedField, szServiceName2_UnoControlFormattedField ) + GET_FACTORY( UnoControlFormattedFieldModel, szServiceName_UnoControlFormattedFieldModel, szServiceName2_UnoControlFormattedFieldModel ) + GET_FACTORY( UnoFileControl, szServiceName_UnoControlFileControl, szServiceName2_UnoControlFileControl ) + GET_FACTORY( UnoControlFileControlModel, szServiceName_UnoControlFileControlModel, szServiceName2_UnoControlFileControlModel ) + GET_FACTORY( UnoButtonControl, szServiceName_UnoControlButton, szServiceName2_UnoControlButton ) + GET_FACTORY( UnoControlButtonModel, szServiceName_UnoControlButtonModel, szServiceName2_UnoControlButtonModel ) + GET_FACTORY( UnoImageControlControl, szServiceName_UnoControlImageButton, szServiceName2_UnoControlImageButton ) + GET_FACTORY( UnoControlImageControlModel, szServiceName_UnoControlImageButtonModel, szServiceName2_UnoControlImageButtonModel ) + GET_FACTORY( UnoImageControlControl, szServiceName_UnoControlImageControl, szServiceName2_UnoControlImageControl ) + GET_FACTORY( UnoControlImageControlModel, szServiceName_UnoControlImageControlModel, szServiceName2_UnoControlImageControlModel ) + GET_FACTORY( UnoRadioButtonControl, szServiceName_UnoControlRadioButton, szServiceName2_UnoControlRadioButton ) + GET_FACTORY( UnoControlRadioButtonModel, szServiceName_UnoControlRadioButtonModel, szServiceName2_UnoControlRadioButtonModel ) + GET_FACTORY( UnoCheckBoxControl, szServiceName_UnoControlCheckBox, szServiceName2_UnoControlCheckBox ) + GET_FACTORY( UnoControlCheckBoxModel, szServiceName_UnoControlCheckBoxModel, szServiceName2_UnoControlCheckBoxModel ) + GET_FACTORY( UnoListBoxControl, szServiceName_UnoControlListBox, szServiceName2_UnoControlListBox ) + GET_FACTORY( UnoControlListBoxModel, szServiceName_UnoControlListBoxModel, szServiceName2_UnoControlListBoxModel ) + GET_FACTORY( UnoComboBoxControl, szServiceName_UnoControlComboBox, szServiceName2_UnoControlComboBox ) + GET_FACTORY( UnoControlComboBoxModel, szServiceName_UnoControlComboBoxModel, szServiceName2_UnoControlComboBoxModel ) + GET_FACTORY( UnoFixedTextControl, szServiceName_UnoControlFixedText, szServiceName2_UnoControlFixedText ) + GET_FACTORY( UnoControlFixedTextModel, szServiceName_UnoControlFixedTextModel, szServiceName2_UnoControlFixedTextModel ) + GET_FACTORY( UnoGroupBoxControl, szServiceName_UnoControlGroupBox, szServiceName2_UnoControlGroupBox ) + GET_FACTORY( UnoControlGroupBoxModel, szServiceName_UnoControlGroupBoxModel, szServiceName2_UnoControlGroupBoxModel ) + GET_FACTORY( UnoProgressBarControl, szServiceName_UnoControlProgressBar, szServiceName2_UnoControlProgressBar ) + GET_FACTORY( UnoControlProgressBarModel, szServiceName_UnoControlProgressBarModel, szServiceName2_UnoControlProgressBarModel ) + GET_FACTORY( UnoScrollBarControl, szServiceName_UnoControlScrollBar, szServiceName2_UnoControlScrollBar ) + GET_FACTORY( UnoControlScrollBarModel, szServiceName_UnoControlScrollBarModel, szServiceName2_UnoControlScrollBarModel ) + GET_FACTORY( UnoFixedLineControl, szServiceName_UnoControlFixedLine, szServiceName2_UnoControlFixedLine ) + GET_FACTORY( UnoControlFixedLineModel, szServiceName_UnoControlFixedLineModel, szServiceName2_UnoControlFixedLineModel ) + GET_FACTORY( VCLXPrinterServer, szServiceName_PrinterServer, szServiceName2_PrinterServer ) + GET_FACTORY( UnoRoadmapControl, szServiceName_UnoControlRoadmap, szServiceName2_UnoControlRoadmap ) + GET_FACTORY( UnoControlRoadmapModel, szServiceName_UnoControlRoadmapModel, szServiceName2_UnoControlRoadmapModel ) + GET_FACTORY( UnoMultiPageModel, szServiceName_UnoMultiPageModel, NULL ) + GET_FACTORY( UnoMultiPageControl, szServiceName_UnoMultiPageControl, NULL ) + GET_FACTORY( UnoPageModel, szServiceName_UnoPageModel, NULL ) + GET_FACTORY( UnoPageControl, szServiceName_UnoPageControl, NULL ) + GET_FACTORY( UnoFrameModel, szServiceName_UnoFrameModel, NULL ) + GET_FACTORY( UnoFrameControl, szServiceName_UnoFrameControl, NULL ) + GET_FACTORY( UnoSpinButtonModel, szServiceName_UnoSpinButtonModel, NULL ) + GET_FACTORY( UnoSpinButtonControl, szServiceName_UnoSpinButtonControl, NULL ) + GET_FACTORY( TreeControl, szServiceName_TreeControl, NULL ) + GET_FACTORY( TreeControlModel, szServiceName_TreeControlModel, NULL ) + GET_FACTORY( MutableTreeDataModel, szServiceName_MutableTreeDataModel, NULL ) + GET_FACTORY( UnoSimpleAnimationControlModel, szServiceName_UnoSimpleAnimationControlModel, szServiceName2_UnoSimpleAnimationControlModel ) + GET_FACTORY( UnoSimpleAnimationControl, szServiceName_UnoSimpleAnimationControl, szServiceName2_UnoSimpleAnimationControl ) + GET_FACTORY( UnoThrobberControlModel, szServiceName_UnoThrobberControlModel, szServiceName2_UnoThrobberControlModel ) + GET_FACTORY( UnoThrobberControl, szServiceName_UnoThrobberControl, szServiceName2_UnoThrobberControl ) + GET_FACTORY( UnoFixedHyperlinkControl, szServiceName_UnoControlFixedHyperlink, NULL ) + GET_FACTORY( UnoControlFixedHyperlinkModel, szServiceName_UnoControlFixedHyperlinkModel, NULL ) + GET_FACTORY( GridControl, szServiceName_GridControl, NULL ); + GET_FACTORY( GridControlModel, szServiceName_GridControlModel, NULL ); + GET_FACTORY( DefaultGridDataModel, szServiceName_DefaultGridDataModel, NULL ); + GET_FACTORY( DefaultGridColumnModel, szServiceName_DefaultGridColumnModel, NULL ); + GET_FACTORY_WITH_IMPL_PREFIX( GridColumn, "org.openoffice.comp.toolkit", szServiceName_GridColumn, NULL ); + GET_FACTORY_WITH_IMPL_PREFIX( SortableGridDataModel, "org.openoffice.comp.toolkit", szServiceName_SortableGridDataModel, NULL ); + GET_FACTORY_WITH_IMPL_PREFIX( AnimatedImagesControl, "org.openoffice.comp.toolkit", szServiceName_AnimatedImagesControl, NULL ) + GET_FACTORY_WITH_IMPL_PREFIX( AnimatedImagesControlModel, "org.openoffice.comp.toolkit", szServiceName_AnimatedImagesControlModel, NULL ) + GET_FACTORY_WITH_IMPL_PREFIX( SpinningProgressControlModel, "org.openoffice.comp.toolkit", szServiceName_SpinningProgressControlModel, NULL ) + GET_FACTORY( UnoControlTabPageModel, szServiceName_UnoControlTabPageModel, NULL ) + GET_FACTORY( UnoControlTabPage, szServiceName_UnoControlTabPage, NULL ) + GET_FACTORY( UnoControlTabPageContainerModel, szServiceName_UnoControlTabPageContainerModel, NULL ) + GET_FACTORY( UnoControlTabPageContainer, szServiceName_UnoControlTabPageContainer, NULL ) if ( rtl_str_compare( sImplementationName, "com.sun.star.awt.comp.AsyncCallback" ) == 0 ) return comp_AsyncCallback_component_getFactory( sImplementationName, _pServiceManager, _pRegistryKey ); - - if( pRet == 0 ) pRet = comp_Layout_component_getFactory( sImplementationName, _pServiceManager, _pRegistryKey ); } diff --git a/toolkit/source/helper/servicenames.cxx b/toolkit/source/helper/servicenames.cxx index 9e30f0e8e42e..4c8f11c69484 100644 --- a/toolkit/source/helper/servicenames.cxx +++ b/toolkit/source/helper/servicenames.cxx @@ -96,6 +96,9 @@ const sal_Char szServiceName_UnoMultiPageModel[] = "com.sun.star.awt.UnoMultiPag const sal_Char szServiceName_UnoPageControl[] = "com.sun.star.awt.UnoControlPage"; const sal_Char szServiceName_UnoPageModel[] = "com.sun.star.awt.UnoPageModel"; const sal_Char szServiceName_UnoFrameControl[] = "com.sun.star.awt.UnoControlFrame"; +const sal_Char szServiceName_AnimatedImagesControl[] = "com.sun.star.awt.AnimatedImagesControl"; +const sal_Char szServiceName_AnimatedImagesControlModel[] = "com.sun.star.awt.AnimatedImagesControlModel"; +const sal_Char szServiceName_SpinningProgressControlModel[] = "com.sun.star.awt.SpinningProgressControlModel"; const sal_Char szServiceName_UnoFrameModel[] = "com.sun.star.awt.UnoFrameModel"; const sal_Char szServiceName_TreeControl[] = "com.sun.star.awt.tree.TreeControl"; const sal_Char szServiceName_TreeControlModel[] = "com.sun.star.awt.tree.TreeControlModel"; @@ -111,5 +114,10 @@ const sal_Char szServiceName_GridControlModel[] = "com.sun.star.awt.grid.UnoCont const sal_Char szServiceName_DefaultGridDataModel[] = "com.sun.star.awt.grid.DefaultGridDataModel"; const sal_Char szServiceName_DefaultGridColumnModel[] = "com.sun.star.awt.grid.DefaultGridColumnModel"; const sal_Char szServiceName_GridColumn[] = "com.sun.star.awt.grid.GridColumn"; +const sal_Char szServiceName_UnoControlTabPage[] = "com.sun.star.awt.tab.UnoControlTabPage"; +const sal_Char szServiceName_UnoControlTabPageModel[] = "com.sun.star.awt.tab.UnoControlTabPageModel"; +const sal_Char szServiceName_UnoControlTabPageContainerModel[] = "com.sun.star.awt.tab.UnoControlTabPageContainerModel"; +const sal_Char szServiceName_UnoControlTabPageContainer[] = "com.sun.star.awt.tab.UnoControlTabPageContainer"; +const sal_Char szServiceName_SortableGridDataModel[] = "com.sun.star.awt.grid.SortableGridDataModel"; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/helper/throbberimpl.cxx b/toolkit/source/helper/throbberimpl.cxx deleted file mode 100644 index d11a13661148..000000000000 --- a/toolkit/source/helper/throbberimpl.cxx +++ /dev/null @@ -1,128 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General 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_toolkit.hxx" -#include <toolkit/helper/throbberimpl.hxx> - -#include <vcl/svapp.hxx> -#include <vcl/fixed.hxx> - -//........................................................................ -namespace toolkit -//........................................................................ -{ - using namespace ::com::sun::star; - - //-------------------------------------------------------------------- - Throbber_Impl::Throbber_Impl( uno::Reference< VCLXWindow > xParent, - sal_Int32 nStepTime, - sal_Bool bRepeat ) - { - mxParent = xParent; - mbRepeat = bRepeat; - mnStepTime = nStepTime; - maWaitTimer.SetTimeout( mnStepTime ); - maWaitTimer.SetTimeoutHdl( LINK( this, Throbber_Impl, TimeOutHdl ) ); - } - - //-------------------------------------------------------------------- - Throbber_Impl::~Throbber_Impl() - { - maWaitTimer.Stop(); - mxParent = NULL; - } - - //-------------------------------------------------------------------- - void Throbber_Impl::start() throw ( uno::RuntimeException ) - { - SolarMutexGuard aGuard; - - mnCurStep = 0; - maWaitTimer.Start(); - } - - //-------------------------------------------------------------------- - void Throbber_Impl::stop() throw ( uno::RuntimeException ) - { - SolarMutexGuard aGuard; - - maWaitTimer.Stop(); - } - - //-------------------------------------------------------------------- - void Throbber_Impl::setImageList( const uno::Sequence< uno::Reference< graphic::XGraphic > >& rImageList ) - throw ( uno::RuntimeException ) - { - SolarMutexGuard aGuard; - - maImageList = rImageList; - - mnStepCount = maImageList.getLength(); - FixedImage* pImage = static_cast< FixedImage* >( mxParent->GetWindow() ); - if ( pImage ) - { - if ( mnStepCount ) - pImage->SetImage( maImageList[ 0 ] ); - else - pImage->SetImage( Image() ); - } - } - - //-------------------------------------------------------------------- - void Throbber_Impl::initImage() - throw ( uno::RuntimeException ) - { - FixedImage* pImage = static_cast< FixedImage* >( mxParent->GetWindow() ); - if ( pImage && maImageList.getLength() ) - pImage->SetImage( maImageList[ 0 ] ); - } - - // ----------------------------------------------------------------------- - IMPL_LINK( Throbber_Impl, TimeOutHdl, Throbber_Impl*, EMPTYARG ) - { - SolarMutexGuard aGuard; - - FixedImage* pImage = static_cast< FixedImage* >( mxParent->GetWindow() ); - - if ( !pImage || !maImageList.getLength() ) - return 0; - - if ( mnCurStep < mnStepCount - 1 ) - mnCurStep += 1; - else - mnCurStep = 0; - - pImage->SetImage( maImageList[ mnCurStep ] ); - - return 0; - } - -//........................................................................ -} // namespacetoolkit -//........................................................................ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/helper/tkresmgr.cxx b/toolkit/source/helper/tkresmgr.cxx index 0fad4faba19f..8c4901326cf4 100644 --- a/toolkit/source/helper/tkresmgr.cxx +++ b/toolkit/source/helper/tkresmgr.cxx @@ -30,12 +30,19 @@ #include "precompiled_toolkit.hxx" #include <toolkit/helper/tkresmgr.hxx> #include <tools/simplerm.hxx> +#include <comphelper/processfactory.hxx> +#include <comphelper/componentcontext.hxx> +#include <comphelper/namedvaluecollection.hxx> +#include <com/sun/star/graphic/XGraphicProvider.hpp> #include <tools/resmgr.hxx> - +#include <tools/diagnose_ex.h> #include <vcl/svapp.hxx> - +using ::com::sun::star::uno::Reference; +using ::com::sun::star::graphic::XGraphic; +using ::com::sun::star::graphic::XGraphicProvider; +using namespace ::com::sun::star; // ----------------------------------------------------------------------------- // TkResMgr // ----------------------------------------------------------------------------- @@ -97,5 +104,28 @@ Image TkResMgr::loadImage( sal_uInt16 nResId ) } // ----------------------------------------------------------------------------- +Image TkResMgr::getImageFromURL( const ::rtl::OUString& i_rImageURL ) +{ + if ( !i_rImageURL.getLength() ) + return Image(); + + try + { + ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); + Reference< XGraphicProvider > xProvider; + if ( aContext.createComponent( "com.sun.star.graphic.GraphicProvider", xProvider ) ) + { + ::comphelper::NamedValueCollection aMediaProperties; + aMediaProperties.put( "URL", i_rImageURL ); + Reference< XGraphic > xGraphic = xProvider->queryGraphic( aMediaProperties.getPropertyValues() ); + return Image( xGraphic ); + } + } + catch( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return Image(); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/helper/unopropertyarrayhelper.cxx b/toolkit/source/helper/unopropertyarrayhelper.cxx index 8d7e9a8ae024..f265a1bdf08c 100644 --- a/toolkit/source/helper/unopropertyarrayhelper.cxx +++ b/toolkit/source/helper/unopropertyarrayhelper.cxx @@ -100,7 +100,7 @@ sal_Bool UnoPropertyArrayHelper::fillPropertyMembersByHandle( ::rtl::OUString * for ( sal_uInt32 n = 0; n < nProps; n++ ) { - sal_uInt16 nId = (sal_uInt16)(sal_uIntPtr)aSortedPropsIds.GetObject( n ); + sal_uInt16 nId = (sal_uInt16)(sal_uLong)aSortedPropsIds.GetObject( n ); pProps[n].Name = GetPropertyName( nId ); pProps[n].Handle = nId; pProps[n].Type = *GetPropertyType( nId ); diff --git a/toolkit/source/helper/unowrapper.cxx b/toolkit/source/helper/unowrapper.cxx index d9e79be6b59e..01cef532a60f 100644 --- a/toolkit/source/helper/unowrapper.cxx +++ b/toolkit/source/helper/unowrapper.cxx @@ -70,7 +70,6 @@ using namespace ::com::sun::star; // instead of only a <VCLXWindow> instance, especially regarding its // corresponding accessibility API. case WINDOW_METRICBOX: - // <-- case WINDOW_COMBOBOX: return new VCLXComboBox; case WINDOW_SPINFIELD: case WINDOW_NUMERICFIELD: @@ -270,7 +269,7 @@ void UnoWrapper::WindowDestroyed( Window* pWindow ) Window* pClient = pChild->GetWindow( WINDOW_CLIENT ); if ( pClient->GetWindowPeer() ) { - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xComp( pClient->GetComponentInterface( FALSE ), ::com::sun::star::uno::UNO_QUERY ); + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xComp( pClient->GetComponentInterface( sal_False ), ::com::sun::star::uno::UNO_QUERY ); xComp->dispose(); } @@ -287,7 +286,7 @@ void UnoWrapper::WindowDestroyed( Window* pWindow ) if ( pClient->GetWindowPeer() && lcl_ImplIsParent( pWindow, pClient ) ) { - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xComp( pClient->GetComponentInterface( FALSE ), ::com::sun::star::uno::UNO_QUERY ); + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xComp( pClient->GetComponentInterface( sal_False ), ::com::sun::star::uno::UNO_QUERY ); xComp->dispose(); } @@ -299,7 +298,7 @@ void UnoWrapper::WindowDestroyed( Window* pWindow ) pParent->GetWindowPeer()->notifyWindowRemoved( *pWindow ); VCLXWindow* pWindowPeer = pWindow->GetWindowPeer(); - uno::Reference< lang::XComponent > xWindowPeerComp( pWindow->GetComponentInterface( FALSE ), uno::UNO_QUERY ); + uno::Reference< lang::XComponent > xWindowPeerComp( pWindow->GetComponentInterface( sal_False ), uno::UNO_QUERY ); OSL_ENSURE( ( pWindowPeer != NULL ) == ( xWindowPeerComp.is() == sal_True ), "UnoWrapper::WindowDestroyed: inconsistency in the window's peers!" ); if ( pWindowPeer ) diff --git a/toolkit/source/helper/vclunohelper.cxx b/toolkit/source/helper/vclunohelper.cxx index a9f62f823d58..e2755f8a8112 100644 --- a/toolkit/source/helper/vclunohelper.cxx +++ b/toolkit/source/helper/vclunohelper.cxx @@ -214,10 +214,11 @@ Polygon VCLUnoHelper::CreatePolygon( const ::com::sun::star::uno::Sequence< sal_ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer> VCLUnoHelper::CreateControlContainer( Window* pWindow ) { - UnoControlContainer* pContainer = new UnoControlContainer( pWindow->GetComponentInterface( sal_True ) ); + const uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); + UnoControlContainer* pContainer = new UnoControlContainer( xFactory, pWindow->GetComponentInterface( sal_True ) ); ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > x = pContainer; - UnoControlModel* pContainerModel = new UnoControlContainerModel; + UnoControlModel* pContainerModel = new UnoControlContainerModel( xFactory ); pContainer->setModel( (::com::sun::star::awt::XControlModel*)pContainerModel ); return x; diff --git a/toolkit/source/layout/core/factory.cxx b/toolkit/source/layout/core/factory.cxx index ff52c3d14446..4cf442798d42 100644 --- a/toolkit/source/layout/core/factory.cxx +++ b/toolkit/source/layout/core/factory.cxx @@ -58,33 +58,6 @@ void * SAL_CALL comp_Layout_component_getFactory( const char * pImplName, void * return pRet; } -sal_Bool SAL_CALL comp_Layout_component_writeInfo( void * /*serviceManager*/, void * pRegistryKey ) - { - if ( pRegistryKey ) - { - try - { - uno::Reference< registry::XRegistryKey > xKey( reinterpret_cast< registry::XRegistryKey* >( pRegistryKey ) ); - uno::Reference< registry::XRegistryKey > xNewKey; - - xNewKey = xKey->createKey( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + - LayoutFactory::impl_staticGetImplementationName() + - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES") ) ); - - const uno::Sequence< ::rtl::OUString > aServices = LayoutFactory::impl_staticGetSupportedServiceNames(); - for ( sal_Int32 i = 0; i < aServices.getLength(); i++ ) - xNewKey->createKey( aServices.getConstArray()[i] ); - - return sal_True; - } - catch (registry::InvalidRegistryException &) - { - OSL_ENSURE( sal_False, "### InvalidRegistryException!" ); - } - } - return sal_False; - } - // Component registration ::rtl::OUString SAL_CALL LayoutFactory::impl_staticGetImplementationName() { diff --git a/toolkit/source/layout/core/helper.cxx b/toolkit/source/layout/core/helper.cxx index 43a1a1e6e2c3..c61502bb6de3 100644 --- a/toolkit/source/layout/core/helper.cxx +++ b/toolkit/source/layout/core/helper.cxx @@ -365,7 +365,7 @@ Window* WidgetFactory::sfx2CreateWindow (VCLXWindow** component, Window* parent, if (!mSfx2Library) { - OUString libraryName = ::vcl::unohelper::CreateLibraryName ("sfx", TRUE); + OUString libraryName = ::vcl::unohelper::CreateLibraryName ("sfx", sal_True); mSfx2Library = osl_loadModuleRelative (&thisModule, libraryName.pData, SAL_LOADMODULE_DEFAULT); if (mSfx2Library) { diff --git a/toolkit/source/layout/core/import.cxx b/toolkit/source/layout/core/import.cxx index 6a0ca24d8c45..52b2defe9272 100644 --- a/toolkit/source/layout/core/import.cxx +++ b/toolkit/source/layout/core/import.cxx @@ -102,7 +102,7 @@ SAL_THROW (()) if ( findAndRemove( "help-id", aProps, aHelpId ) ) { OSL_TRACE("Setting help-id: %s", OUSTRING_CSTR( aHelpId ) ); - xDialog->setHelpId( aHelpId.toInt32 () ); + xDialog->setHelpId( aHelpId ); } } // DEBUG: else if ( pParent == NULL ) diff --git a/toolkit/source/layout/core/makefile.mk b/toolkit/source/layout/core/makefile.mk deleted file mode 100644 index 2c90921799af..000000000000 --- a/toolkit/source/layout/core/makefile.mk +++ /dev/null @@ -1,65 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=../../.. -PRJNAME=toolkit -TARGET=layout-core -ENABLE_EXCEPTIONS=true - -# --- Settings ----------------------------------------------------- - -.INCLUDE : settings.mk -.INCLUDE : $(PRJ)$/util$/makefile.pmk - -# --- Files -------------------------------------------------------- - -# FIXME: This is bad, hmkay -CFLAGS+= -I$(PRJ)/source - -SLOFILES= \ - $(SLO)$/bin.obj \ - $(SLO)$/box-base.obj \ - $(SLO)$/box.obj \ - $(SLO)$/byteseq.obj \ - $(SLO)$/container.obj \ - $(SLO)$/dialogbuttonhbox.obj \ - $(SLO)$/factory.obj \ - $(SLO)$/flow.obj \ - $(SLO)$/helper.obj \ - $(SLO)$/import.obj \ - $(SLO)$/localized-string.obj \ - $(SLO)$/proplist.obj \ - $(SLO)$/root.obj \ - $(SLO)$/table.obj \ - $(SLO)$/timer.obj \ - $(SLO)$/translate.obj\ - $(SLO)$/vcl.obj\ -# - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk diff --git a/toolkit/source/layout/core/vcl.cxx b/toolkit/source/layout/core/vcl.cxx index 9fc861506a00..2b9d2d3c4f5d 100644 --- a/toolkit/source/layout/core/vcl.cxx +++ b/toolkit/source/layout/core/vcl.cxx @@ -50,7 +50,7 @@ static PushButton* get_button (Dialog const* dialog, sal_uInt32 type) , mClosing (false)\ {\ }\ - BOOL Closing##cls::Close ()\ + sal_Bool Closing##cls::Close ()\ {\ if (mClosing)\ EndDialog (false);\ diff --git a/toolkit/source/layout/core/vcl.hxx b/toolkit/source/layout/core/vcl.hxx index 45c01314782b..bcf6cfb700f1 100644 --- a/toolkit/source/layout/core/vcl.hxx +++ b/toolkit/source/layout/core/vcl.hxx @@ -37,7 +37,7 @@ public:\ bool mClosing;\ Closing##cls (Window* parent, WinBits bits);\ - virtual BOOL Close ();\ + virtual sal_Bool Close ();\ } DECLARE_CLOSING_DIALOG (Dialog); diff --git a/toolkit/source/layout/vcl/makefile.mk b/toolkit/source/layout/vcl/makefile.mk deleted file mode 100644 index 529ddc31d97e..000000000000 --- a/toolkit/source/layout/vcl/makefile.mk +++ /dev/null @@ -1,52 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=../../.. -PRJNAME=toolkit -TARGET=layout-vcl -ENABLE_EXCEPTIONS=true - -# --- Settings ----------------------------------------------------- - -.INCLUDE : settings.mk -.INCLUDE : $(PRJ)$/util$/makefile.pmk - -.IF "$(COMNAME)" == "gcc3" -CFLAGS+=-Wall -fno-default-inline -.ENDIF - -# --- Files -------------------------------------------------------- - -SLOFILES= \ - $(SLO)$/wrapper.obj \ - $(SLO)$/wbutton.obj \ - $(SLO)$/wcontainer.obj \ - $(SLO)$/wfield.obj - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk diff --git a/toolkit/source/layout/vcl/wrapper.cxx b/toolkit/source/layout/vcl/wrapper.cxx index 2664005fd159..d7a6ef81fa30 100644 --- a/toolkit/source/layout/vcl/wrapper.cxx +++ b/toolkit/source/layout/vcl/wrapper.cxx @@ -305,13 +305,17 @@ void Window::setRes (ResId const& res) { return Resource::ReadStringRes (); } + rtl::OString ReadByteStringRes() + { + return Resource::ReadByteStringRes(); + } }; Resource_open_up r (res); #endif /* !RESOURCE_PUBLISH_PROTECTED */ - if (sal_uInt32 help_id = (sal_uInt32)r.GetLongRes (static_cast<char *> (r.GetClassRes ()) + 12)) - SetHelpId (help_id); sal_uInt32 mask = r.ReadLongRes (); + if (mask & WINDOW_HELPID) + SetHelpId (r.ReadByteStringRes()); if ( mask & WINDOW_TEXT ) SetText( r.ReadStringRes ()); } @@ -367,26 +371,16 @@ VCLXWindow* Window::GetVCLXWindow() const return GetWindow()->GetParent(); } -void Window::SetHelpId( sal_uIntPtr id ) +void Window::SetHelpId( const rtl::OString& id ) { GetWindow()->SetHelpId( id ); } -sal_uIntPtr Window::GetHelpId() const +const rtl::OString& Window::GetHelpId() const { return GetWindow()->GetHelpId(); } -void Window::SetSmartHelpId( SmartId const& id, SmartIdUpdateMode mode ) -{ - GetWindow()->SetSmartHelpId( id, mode ); -} - -SmartId Window::GetSmartHelpId() const -{ - return GetWindow()->GetSmartHelpId(); -} - void Window::EnterWait () { GetWindow()->EnterWait (); @@ -867,7 +861,7 @@ void Dialog::Initialize (SfxChildWinInfo*) , yesButton (this, "BTN_YES") MessageBox::MessageBox (::Window *parent, char const* message, - char const* yes, char const* no, sal_uIntPtr help_id, + char const* yes, char const* no, const rtl::OString& help_id, char const* xml_file, char const* id) : MESSAGE_BOX_MEMBER_INIT { @@ -877,7 +871,7 @@ MessageBox::MessageBox (::Window *parent, char const* message, } MessageBox::MessageBox (::Window *parent, OUString const& message, - OUString yes, OUString no, sal_uIntPtr help_id, + OUString yes, OUString no, const rtl::OString& help_id, char const* xml_file, char const* id) : MESSAGE_BOX_MEMBER_INIT { @@ -891,7 +885,7 @@ MessageBox::MessageBox (::Window *parent, OUString const& message, #endif /* !__GNUC__ */ MessageBox::MessageBox (::Window *parent, WinBits bits, char const* message, - char const* yes, char const* no, sal_uIntPtr help_id, + char const* yes, char const* no, const rtl::OString& help_id, char const* xml_file, char const* id) : MESSAGE_BOX_MEMBER_INIT { @@ -904,7 +898,7 @@ MessageBox::MessageBox (::Window *parent, WinBits bits, char const* message, } MessageBox::MessageBox (::Window *parent, WinBits bits, OUString const& message, - OUString yes, OUString no, sal_uIntPtr help_id, + OUString yes, OUString no, const rtl::OString& help_id, char const* xml_file, char const* id) : MESSAGE_BOX_MEMBER_INIT { @@ -917,7 +911,7 @@ MessageBox::MessageBox (::Window *parent, WinBits bits, OUString const& message, } void MessageBox::bits_init (WinBits bits, OUString const& message, - OUString yes, OUString no, sal_uIntPtr help_id) + OUString yes, OUString no, const rtl::OString& help_id) { if ( bits & ( WB_OK_CANCEL | WB_OK )) yes = Button::GetStandardText ( BUTTON_OK ); @@ -942,12 +936,12 @@ void MessageBox::bits_init (WinBits bits, OUString const& message, init (message, yes, no, help_id); } -void MessageBox::init (char const* message, char const* yes, char const* no, sal_uIntPtr help_id) +void MessageBox::init (char const* message, char const* yes, char const* no, const rtl::OString& help_id) { init ( OUString::createFromAscii (message), OUString::createFromAscii (yes), OUString::createFromAscii (no), help_id); } -void MessageBox::init (OUString const& message, OUString const& yes, OUString const& no, sal_uIntPtr help_id) +void MessageBox::init (OUString const& message, OUString const& yes, OUString const& no, const rtl::OString& help_id) { imageError.Hide (); imageInfo.Hide (); @@ -975,28 +969,28 @@ void MessageBox::init (OUString const& message, OUString const& yes, OUString co #undef MESSAGE_BOX_IMPL #define MESSAGE_BOX_IMPL(Name)\ Name##Box::Name##Box (::Window *parent, char const* message,\ - char const* yes, char const* no, sal_uIntPtr help_id,\ + char const* yes, char const* no, const rtl::OString& help_id,\ char const* xml_file, char const* id)\ : MessageBox (parent, message, yes, no, help_id, xml_file, id)\ {\ image##Name.Show ();\ }\ Name##Box::Name##Box (::Window *parent, OUString const& message,\ - OUString yes, OUString no, sal_uIntPtr help_id,\ + OUString yes, OUString no, const rtl::OString& help_id,\ char const* xml_file, char const* id)\ : MessageBox (parent, message, yes, no, help_id, xml_file, id)\ {\ image##Name.Show ();\ }\ Name##Box::Name##Box (::Window *parent, WinBits bits, char const* message,\ - char const* yes, char const* no, sal_uIntPtr help_id,\ + char const* yes, char const* no, const rtl::OString& help_id,\ char const* xml_file, char const* id)\ : MessageBox (parent, bits, message, yes, no, help_id, xml_file, id)\ {\ image##Name.Show ();\ }\ Name##Box::Name##Box (::Window *parent, WinBits bits, OUString const& message,\ - OUString yes, OUString no, sal_uIntPtr help_id,\ + OUString yes, OUString no, const rtl::OString& help_id,\ char const* xml_file, char const* id)\ : MessageBox (parent, bits, message, yes, no, help_id, xml_file, id)\ {\ @@ -1489,7 +1483,7 @@ LocalizedString::operator String() return getImpl ().maString; } -String LocalizedString::GetToken (USHORT i, sal_Char c) +String LocalizedString::GetToken (sal_uInt16 i, sal_Char c) { return getString ().GetToken (i, c); } |