diff options
Diffstat (limited to 'toolkit')
161 files changed, 12498 insertions, 5593 deletions
diff --git a/toolkit/inc/makefile.mk b/toolkit/AllLangResTarget_tk.mk index 41100071a4d8..e127bef851c6 100644 --- a/toolkit/inc/makefile.mk +++ b/toolkit/AllLangResTarget_tk.mk @@ -2,7 +2,7 @@ # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # -# Copyright 2000, 2010 Oracle and/or its affiliates. +# Copyright 2000, 2011 Oracle and/or its affiliates. # # OpenOffice.org - a multi-platform office productivity suite # @@ -24,25 +24,22 @@ # for a copy of the LGPLv3 License. # #************************************************************************* -PRJ=.. -PRJNAME=toolkit -TARGET=inc +$(eval $(call gb_AllLangResTarget_AllLangResTarget,tk)) -# --- Settings ----------------------------------------------------- +$(eval $(call gb_AllLangResTarget_set_reslocation,tk,toolkit)) -.INCLUDE : settings.mk -.INCLUDE : $(PRJ)$/util$/makefile.pmk +$(eval $(call gb_AllLangResTarget_add_srs,tk,\ + toolkit/awt \ +)) -# --- Files -------------------------------------------------------- -# --- Targets ------------------------------------------------------- +$(eval $(call gb_SrsTarget_SrsTarget,toolkit/awt)) -.INCLUDE : target.mk - -.IF "$(ENABLE_PCH)"!="" -ALLTAR : \ - $(SLO)$/precompiled.pch \ - $(SLO)$/precompiled_ex.pch - -.ENDIF # "$(ENABLE_PCH)"!="" +$(eval $(call gb_SrsTarget_set_include,toolkit/awt,\ + $$(INCLUDE) \ + -I$(SRCDIR)/toolkit/source/awt \ +)) +$(eval $(call gb_SrsTarget_add_files,toolkit/awt,\ + toolkit/source/awt/xthrobber.src \ +)) diff --git a/toolkit/source/layout/vcl/makefile.mk b/toolkit/JunitTest_toolkit_unoapi.mk index 529ddc31d97e..27dc89e13478 100644..100755 --- a/toolkit/source/layout/vcl/makefile.mk +++ b/toolkit/JunitTest_toolkit_unoapi.mk @@ -2,7 +2,7 @@ # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # -# Copyright 2000, 2010 Oracle and/or its affiliates. +# Copyright 2000, 2011 Oracle and/or its affiliates. # # OpenOffice.org - a multi-platform office productivity suite # @@ -25,28 +25,29 @@ # #************************************************************************* -PRJ=../../.. -PRJNAME=toolkit -TARGET=layout-vcl -ENABLE_EXCEPTIONS=true +$(eval $(call gb_JunitTest_JunitTest,toolkit_unoapi)) -# --- Settings ----------------------------------------------------- +$(eval $(call gb_JunitTest_set_defs,toolkit_unoapi,\ + $$(DEFS) \ + -Dorg.openoffice.test.arg.sce=$(SRCDIR)/toolkit/qa/unoapi/toolkit.sce \ + -Dorg.openoffice.test.arg.xcl=$(SRCDIR)/toolkit/qa/unoapi/knownissues.xcl \ + -Dorg.openoffice.test.arg.tdoc=$(SRCDIR)/toolkit/qa/unoapi/testdocuments \ +)) -.INCLUDE : settings.mk -.INCLUDE : $(PRJ)$/util$/makefile.pmk +$(eval $(call gb_JunitTest_add_jars,toolkit_unoapi,\ + $(OUTDIR)/bin/OOoRunner.jar \ + $(OUTDIR)/bin/ridl.jar \ + $(OUTDIR)/bin/test.jar \ + $(OUTDIR)/bin/unoil.jar \ + $(OUTDIR)/bin/jurt.jar \ +)) -.IF "$(COMNAME)" == "gcc3" -CFLAGS+=-Wall -fno-default-inline -.ENDIF +$(eval $(call gb_JunitTest_add_sourcefiles,toolkit_unoapi,\ + toolkit/qa/unoapi/Test \ +)) -# --- Files -------------------------------------------------------- +$(eval $(call gb_JunitTest_add_classes,toolkit_unoapi,\ + org.openoffice.toolkit.qa.unoapi.Test \ +)) -SLOFILES= \ - $(SLO)$/wrapper.obj \ - $(SLO)$/wbutton.obj \ - $(SLO)$/wcontainer.obj \ - $(SLO)$/wfield.obj - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk +# vim: set noet sw=4 ts=4: diff --git a/toolkit/Library_tk.mk b/toolkit/Library_tk.mk new file mode 100644 index 000000000000..e0dbfd59d5bb --- /dev/null +++ b/toolkit/Library_tk.mk @@ -0,0 +1,172 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2011 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +$(eval $(call gb_Library_Library,tk)) + +$(eval $(call gb_Library_set_componentfile,tk,toolkit/util/tk)) + +$(eval $(call gb_Library_add_package_headers,tk,toolkit_inc)) + +#$(eval $(call gb_Library_add_precompiled_header,tk,$(SRCDIR)/toolkit/inc/pch/precompiled_toolkit)) + +$(eval $(call gb_Library_set_include,tk,\ + $$(INCLUDE) \ + -I$(SRCDIR)/toolkit/inc \ + -I$(SRCDIR)/toolkit/inc/pch \ + -I$(SRCDIR)/toolkit/source \ + -I$(OUTDIR)/inc/offuh \ +)) + +$(eval $(call gb_Library_set_defs,tk,\ + $$(DEFS) \ + -DTOOLKIT_DLLIMPLEMENTATION \ +)) + +$(eval $(call gb_Library_add_linked_libs,tk,\ + comphelper \ + cppu \ + cppuhelper \ + sal \ + tl \ + utl \ + vcl \ + $(gb_STDLIBS) \ +)) + +$(eval $(call gb_Library_add_exception_objects,tk,\ + toolkit/source/awt/asynccallback \ + toolkit/source/awt/stylesettings \ + toolkit/source/awt/vclxaccessiblecomponent \ + toolkit/source/awt/vclxbitmap \ + toolkit/source/awt/vclxbutton \ + toolkit/source/awt/vclxcontainer \ + toolkit/source/awt/vclxdevice \ + toolkit/source/awt/vclxdialog \ + toolkit/source/awt/vclxfixedline \ + toolkit/source/awt/vclxfont \ + toolkit/source/awt/vclxgraphics \ + toolkit/source/awt/vclxmenu \ + toolkit/source/awt/vclxplugin \ + toolkit/source/awt/vclxpointer \ + toolkit/source/awt/vclxprinter \ + toolkit/source/awt/vclxregion \ + toolkit/source/awt/vclxscroller \ + toolkit/source/awt/vclxspinbutton \ + toolkit/source/awt/vclxsplitter \ + toolkit/source/awt/vclxsystemdependentwindow \ + toolkit/source/awt/vclxtabcontrol \ + toolkit/source/awt/vclxtabpage \ + toolkit/source/awt/vclxtabpagecontainer \ + toolkit/source/awt/animatedimagespeer \ + toolkit/source/awt/vclxtoolkit \ + toolkit/source/awt/vclxtopwindow \ + toolkit/source/awt/vclxwindow \ + toolkit/source/awt/vclxwindow1 \ + toolkit/source/awt/vclxwindows \ + toolkit/source/awt/xsimpleanimation \ + toolkit/source/awt/xthrobber \ + toolkit/source/controls/accessiblecontrolcontext \ + toolkit/source/controls/controlmodelcontainerbase \ + toolkit/source/controls/dialogcontrol \ + toolkit/source/controls/eventcontainer \ + toolkit/source/controls/formattedcontrol \ + toolkit/source/controls/geometrycontrolmodel \ + toolkit/source/controls/grid/defaultgridcolumnmodel \ + toolkit/source/controls/grid/defaultgriddatamodel \ + toolkit/source/controls/grid/gridcolumn \ + toolkit/source/controls/grid/grideventforwarder \ + toolkit/source/controls/grid/sortablegriddatamodel \ + toolkit/source/controls/grid/gridcontrol \ + toolkit/source/controls/roadmapcontrol \ + toolkit/source/controls/roadmapentry \ + toolkit/source/controls/tabpagecontainer \ + toolkit/source/controls/tabpagemodel \ + toolkit/source/controls/stdtabcontroller \ + toolkit/source/controls/stdtabcontrollermodel \ + toolkit/source/controls/tkscrollbar \ + toolkit/source/controls/tksimpleanimation \ + toolkit/source/controls/tkspinbutton \ + toolkit/source/controls/tkthrobber \ + toolkit/source/controls/animatedimages \ + toolkit/source/controls/spinningprogress \ + toolkit/source/controls/tree/treecontrol \ + toolkit/source/controls/tree/treedatamodel \ + toolkit/source/controls/unocontrol \ + toolkit/source/controls/unocontrolbase \ + toolkit/source/controls/unocontrolcontainer \ + toolkit/source/controls/unocontrolcontainermodel \ + toolkit/source/controls/unocontrolmodel \ + toolkit/source/controls/unocontrols \ + toolkit/source/helper/accessibilityclient \ + toolkit/source/helper/externallock \ + toolkit/source/helper/fixedhyperbase \ + toolkit/source/helper/formpdfexport \ + toolkit/source/helper/imagealign \ + toolkit/source/helper/listenermultiplexer \ + toolkit/source/helper/property \ + toolkit/source/helper/registerservices \ + toolkit/source/helper/servicenames \ + toolkit/source/helper/tkresmgr \ + toolkit/source/helper/unomemorystream \ + toolkit/source/helper/unopropertyarrayhelper \ + toolkit/source/helper/unowrapper \ + toolkit/source/helper/vclunohelper \ + toolkit/source/layout/core/bin \ + toolkit/source/layout/core/box \ + toolkit/source/layout/core/box-base \ + toolkit/source/layout/core/byteseq \ + toolkit/source/layout/core/container \ + toolkit/source/layout/core/dialogbuttonhbox \ + toolkit/source/layout/core/factory \ + toolkit/source/layout/core/flow \ + toolkit/source/layout/core/helper \ + toolkit/source/layout/core/import \ + toolkit/source/layout/core/localized-string \ + toolkit/source/layout/core/proplist \ + toolkit/source/layout/core/root \ + toolkit/source/layout/core/table \ + toolkit/source/layout/core/timer \ + toolkit/source/layout/core/translate \ + toolkit/source/layout/core/vcl \ + toolkit/source/layout/vcl/wbutton \ + toolkit/source/layout/vcl/wcontainer \ + toolkit/source/layout/vcl/wfield \ + toolkit/source/layout/vcl/wrapper \ +)) + +ifeq ($(GUIBASE),aqua) +$(eval $(call gb_Library_set_cxxflags,tk,\ + $$(CXXFLAGS) $(gb_OBJCXXFLAGS))) +endif + +ifeq ($(OS),LINUX) +$(eval $(call gb_Library_add_linked_libs,tk,\ + X11 \ +)) +endif + +# vim: set noet sw=4 ts=4: diff --git a/toolkit/uiconfig/layout/makefile.mk b/toolkit/Makefile index 46d0b187b744..a79aff831024 100644 --- a/toolkit/uiconfig/layout/makefile.mk +++ b/toolkit/Makefile @@ -25,30 +25,14 @@ # #************************************************************************* -PRJ=../.. -PRJNAME=toolkit -TARGET=layout +ifeq ($(strip $(SOLARENV)),) +$(error No environment set!) +endif -.INCLUDE : settings.mk +gb_PARTIALBUILD := T +GBUILDDIR := $(SOLARENV)/gbuild +include $(GBUILDDIR)/gbuild.mk -.IF "$(ENABLE_LAYOUT)" == "TRUE" +$(eval $(call gb_Module_make_global_targets,$(shell ls $(dir $(realpath $(firstword $(MAKEFILE_LIST))))/Module*.mk))) -all: ALLTAR - -XML_FILES=\ - message-box.xml\ - tab-dialog.xml\ - -# - -.INCLUDE : layout.mk - -.ELSE # ENABLE_LAYOUT != TRUE -all .PHONY: -.ENDIF # ENABLE_LAYOUT != TRUE - -.INCLUDE : target.mk - -localize.sdf: - echo '#empty' | cat - > $@ - rm -f *-$@ +# vim: set noet sw=4 ts=4: diff --git a/toolkit/qa/unoapi/makefile.mk b/toolkit/Module_toolkit.mk index 9517601c3917..858aecd1c13d 100644 --- a/toolkit/qa/unoapi/makefile.mk +++ b/toolkit/Module_toolkit.mk @@ -1,7 +1,8 @@ #************************************************************************* -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # -# Copyright 2000, 2010 Oracle and/or its affiliates. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2011 Oracle and/or its affiliates. # # OpenOffice.org - a multi-platform office productivity suite # @@ -21,28 +22,21 @@ # version 3 along with OpenOffice.org. If not, see # <http://www.openoffice.org/license.html> # for a copy of the LGPLv3 License. -#***********************************************************************/ - -.IF "$(OOO_SUBSEQUENT_TESTS)" == "" -nothing .PHONY: -.ELSE - -PRJ = ../.. -PRJNAME = toolkit -TARGET = qa_unoapi +# +#************************************************************************* -.IF "$(OOO_JUNIT_JAR)" != "" -PACKAGE = org/openoffice/toolkit/qa/unoapi -JAVATESTFILES = Test.java -JAVAFILES = $(JAVATESTFILES) -JARFILES = OOoRunner.jar ridl.jar test.jar -EXTRAJARFILES = $(OOO_JUNIT_JAR) -.END +$(eval $(call gb_Module_Module,toolkit)) -.INCLUDE: settings.mk -.INCLUDE: target.mk -.INCLUDE: installationtest.mk +$(eval $(call gb_Module_add_targets,toolkit,\ + AllLangResTarget_tk \ + Library_tk \ + Package_inc \ + Package_source \ + Package_util \ +)) -ALLTAR : javatest +$(eval $(call gb_Module_add_subsequentcheck_targets,toolkit,\ + JunitTest_toolkit_unoapi \ +)) -.END +# vim: set noet sw=4 ts=4: diff --git a/toolkit/Package_inc.mk b/toolkit/Package_inc.mk new file mode 100644 index 000000000000..03d49fe6a45e --- /dev/null +++ b/toolkit/Package_inc.mk @@ -0,0 +1,66 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2011 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +$(eval $(call gb_Package_Package,toolkit_inc,$(SRCDIR)/toolkit/inc)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/layout/layout-post.hxx,layout/layout-post.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/layout/layout-pre.hxx,layout/layout-pre.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/layout/layout.hxx,layout/layout.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/awt/vclxaccessiblecomponent.hxx,toolkit/awt/vclxaccessiblecomponent.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/awt/vclxcontainer.hxx,toolkit/awt/vclxcontainer.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/awt/vclxdevice.hxx,toolkit/awt/vclxdevice.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/awt/vclxfont.hxx,toolkit/awt/vclxfont.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/awt/vclxmenu.hxx,toolkit/awt/vclxmenu.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/awt/vclxsystemdependentwindow.hxx,toolkit/awt/vclxsystemdependentwindow.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/awt/vclxtoolkit.hxx,toolkit/awt/vclxtoolkit.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/awt/vclxtopwindow.hxx,toolkit/awt/vclxtopwindow.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/awt/vclxwindow.hxx,toolkit/awt/vclxwindow.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/awt/vclxwindows.hxx,toolkit/awt/vclxwindows.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/controls/unocontrol.hxx,toolkit/controls/unocontrol.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/controls/unocontrolbase.hxx,toolkit/controls/unocontrolbase.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/controls/unocontrolmodel.hxx,toolkit/controls/unocontrolmodel.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/controls/unocontrols.hxx,toolkit/controls/unocontrols.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/dllapi.h,toolkit/dllapi.h)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/helper/accessibilityclient.hxx,toolkit/helper/accessibilityclient.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/helper/accessiblefactory.hxx,toolkit/helper/accessiblefactory.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/helper/convert.hxx,toolkit/helper/convert.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/helper/emptyfontdescriptor.hxx,toolkit/helper/emptyfontdescriptor.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/helper/externallock.hxx,toolkit/helper/externallock.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/helper/fixedhyperbase.hxx,toolkit/helper/fixedhyperbase.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/helper/formpdfexport.hxx,toolkit/helper/formpdfexport.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/helper/imagealign.hxx,toolkit/helper/imagealign.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/helper/listenermultiplexer.hxx,toolkit/helper/listenermultiplexer.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/helper/macros.hxx,toolkit/helper/macros.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/helper/mutexandbroadcasthelper.hxx,toolkit/helper/mutexandbroadcasthelper.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/helper/mutexhelper.hxx,toolkit/helper/mutexhelper.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/helper/property.hxx,toolkit/helper/property.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/helper/servicenames.hxx,toolkit/helper/servicenames.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/helper/tkresmgr.hxx,toolkit/helper/tkresmgr.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/helper/unomemorystream.hxx,toolkit/helper/unomemorystream.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/helper/unopropertyarrayhelper.hxx,toolkit/helper/unopropertyarrayhelper.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/helper/unowrapper.hxx,toolkit/helper/unowrapper.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/helper/vclunohelper.hxx,toolkit/helper/vclunohelper.hxx)) +$(eval $(call gb_Package_add_file,toolkit_inc,inc/toolkit/unohlp.hxx,toolkit/helper/vclunohelper.hxx)) diff --git a/toolkit/Package_source.mk b/toolkit/Package_source.mk new file mode 100644 index 000000000000..6dd69fda6098 --- /dev/null +++ b/toolkit/Package_source.mk @@ -0,0 +1,47 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2011 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +$(eval $(call gb_Package_Package,toolkit_source,$(SRCDIR)/toolkit/source)) +$(eval $(call gb_Package_add_file,toolkit_source,inc/layout/core/bin.hxx,layout/core/bin.hxx)) +$(eval $(call gb_Package_add_file,toolkit_source,inc/layout/core/box-base.hxx,layout/core/box-base.hxx)) +$(eval $(call gb_Package_add_file,toolkit_source,inc/layout/core/box.hxx,layout/core/box.hxx)) +$(eval $(call gb_Package_add_file,toolkit_source,inc/layout/core/container.hxx,layout/core/container.hxx)) +$(eval $(call gb_Package_add_file,toolkit_source,inc/layout/core/dialogbuttonhbox.hxx,layout/core/dialogbuttonhbox.hxx)) +$(eval $(call gb_Package_add_file,toolkit_source,inc/layout/core/factory.hxx,layout/core/factory.hxx)) +$(eval $(call gb_Package_add_file,toolkit_source,inc/layout/core/flow.hxx,layout/core/flow.hxx)) +$(eval $(call gb_Package_add_file,toolkit_source,inc/layout/core/helper.hxx,layout/core/helper.hxx)) +$(eval $(call gb_Package_add_file,toolkit_source,inc/layout/core/import.hxx,layout/core/import.hxx)) +$(eval $(call gb_Package_add_file,toolkit_source,inc/layout/core/localized-string.hxx,layout/core/localized-string.hxx)) +$(eval $(call gb_Package_add_file,toolkit_source,inc/layout/core/precompiled_xmlscript.hxx,layout/core/precompiled_xmlscript.hxx)) +$(eval $(call gb_Package_add_file,toolkit_source,inc/layout/core/proplist.hxx,layout/core/proplist.hxx)) +$(eval $(call gb_Package_add_file,toolkit_source,inc/layout/core/root.hxx,layout/core/root.hxx)) +$(eval $(call gb_Package_add_file,toolkit_source,inc/layout/core/table.hxx,layout/core/table.hxx)) +$(eval $(call gb_Package_add_file,toolkit_source,inc/layout/core/timer.hxx,layout/core/timer.hxx)) +$(eval $(call gb_Package_add_file,toolkit_source,inc/layout/core/translate.hxx,layout/core/translate.hxx)) +$(eval $(call gb_Package_add_file,toolkit_source,inc/layout/core/vcl.hxx,layout/core/vcl.hxx)) +$(eval $(call gb_Package_add_file,toolkit_source,inc/layout/vcl/wrapper.hxx,layout/vcl/wrapper.hxx)) +$(eval $(call gb_Package_add_file,toolkit_source,inc/toolkit/awt/vclxdialog.hxx,awt/vclxdialog.hxx)) diff --git a/toolkit/source/controls/tree/makefile.mk b/toolkit/Package_util.mk index 4e72b62b416b..b8580d0205c8 100644 --- a/toolkit/source/controls/tree/makefile.mk +++ b/toolkit/Package_util.mk @@ -2,7 +2,7 @@ # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # -# Copyright 2000, 2010 Oracle and/or its affiliates. +# Copyright 2000, 2011 Oracle and/or its affiliates. # # OpenOffice.org - a multi-platform office productivity suite # @@ -25,24 +25,5 @@ # #************************************************************************* -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 +$(eval $(call gb_Package_Package,toolkit_util,$(SRCDIR)/toolkit/util)) +$(eval $(call gb_Package_add_file,toolkit_util,xml/toolkit.xml,toolkit.xml)) diff --git a/toolkit/inc/layout/layout.hxx b/toolkit/inc/layout/layout.hxx index 9322cdc2924d..083214407e7a 100644 --- a/toolkit/inc/layout/layout.hxx +++ b/toolkit/inc/layout/layout.hxx @@ -39,10 +39,9 @@ #include <tools/string.hxx> #include <vcl/bitmap.hxx> #include <vcl/combobox.h> -#include <vcl/fldunit.hxx> +#include <tools/fldunit.hxx> #include <vcl/lstbox.h> -#include <vcl/smartid.hxx> -#include <vcl/wintypes.hxx> +#include <tools/wintypes.hxx> class Button; class ComboBox; @@ -161,10 +160,8 @@ public: String GetText() const; void SetStyle( WinBits style ); void SetUpdateMode( bool mode ); - void SetHelpId( sal_uIntPtr id ); - sal_uIntPtr GetHelpId() const; - void SetSmartHelpId( SmartId const&, SmartIdUpdateMode mode=SMART_SET_SMART ); - SmartId GetSmartHelpId() const; + void SetHelpId( const rtl::OString& id ); + const rtl::OString& GetHelpId() const; void EnterWait (); void LeaveWait (); bool IsWait () const; @@ -579,20 +576,20 @@ public: #define DECL_MESSAGE_BOX_CTORS(Name)\ public:\ Name##Box (::Window *parent, char const* message,\ - char const* yes=0, char const* no=0, sal_uIntPtr help_id=0,\ + char const* yes=0, char const* no=0, const rtl::OString& help_id=rtl::OString(),\ char const* xml_file="message-box.xml", char const* id="message-box");\ Name##Box (::Window *parent, rtl::OUString const& message,\ rtl::OUString yes=String (),\ rtl::OUString no=String (),\ - sal_uIntPtr help_id=0,\ + const rtl::OString& help_id=rtl::OString(),\ char const* xml_file="message-box.xml", char const* id="message-box");\ Name##Box (::Window *parent, WinBits, char const* message,\ - char const* yes=0, char const* no=0, sal_uIntPtr help_id=0,\ + char const* yes=0, char const* no=0, const rtl::OString& help_id=rtl::OString(),\ char const* xml_file="message-box.xml", char const* id="message-box");\ Name##Box (::Window *parent, WinBits, rtl::OUString const& message,\ rtl::OUString yes=String (),\ rtl::OUString no=String (),\ - sal_uIntPtr help_id=0,\ + const rtl::OString& help_id=rtl::OString(),\ char const* xml_file="message-box.xml", char const* id="message-box")\ class TOOLKIT_DLLPUBLIC MessageBox : public Dialog @@ -613,10 +610,10 @@ protected: YesButton yesButton; void bits_init (WinBits bits, rtl::OUString const& message, - rtl::OUString yes, rtl::OUString, sal_uIntPtr help_id); + rtl::OUString yes, rtl::OUString, const rtl::OString& help_id); void init (rtl::OUString const& message, - rtl::OUString const& yes, rtl::OUString const& no, sal_uIntPtr help_id); - void init (char const* message, char const* yes, char const* no, sal_uIntPtr help_id); + rtl::OUString const& yes, rtl::OUString const& no, const rtl::OString& help_id); + void init (char const* message, char const* yes, char const* no, const rtl::OString& help_id); }; #define CLASS_MESSAGE_BOX(Name)\ @@ -794,7 +791,7 @@ public: operator String(); String getString (); rtl::OUString getOUString (); - String GetToken (USHORT i, sal_Char c); + String GetToken (sal_uInt16 i, sal_Char c); }; class InPlugImpl; diff --git a/toolkit/inc/pch/precompiled_toolkit.hxx b/toolkit/inc/pch/precompiled_toolkit.hxx index 2a078fe1a8ba..c2c86fe35611 100644 --- a/toolkit/inc/pch/precompiled_toolkit.hxx +++ b/toolkit/inc/pch/precompiled_toolkit.hxx @@ -326,7 +326,7 @@ #include "vcl/gradient.hxx" #include "vcl/image.hxx" #include "vcl/jobset.hxx" -#include "vcl/mapunit.hxx" +#include "tools/mapunit.hxx" #include "vcl/menu.hxx" #include "vcl/metric.hxx" #include "vcl/outdev.hxx" diff --git a/toolkit/inc/toolkit/awt/animatedimagespeer.hxx b/toolkit/inc/toolkit/awt/animatedimagespeer.hxx new file mode 100755 index 000000000000..b9bdecdf0e47 --- /dev/null +++ b/toolkit/inc/toolkit/awt/animatedimagespeer.hxx @@ -0,0 +1,106 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef TOOLKIT_ANIMATEDIMAGEPEER_HXX +#define TOOLKIT_ANIMATEDIMAGEPEER_HXX + +#include "toolkit/awt/vclxwindow.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/awt/XAnimation.hpp> +#include <com/sun/star/util/XModifyListener.hpp> +/** === end UNO includes === **/ + +#include <cppuhelper/implbase3.hxx> + +#include <boost/scoped_ptr.hpp> +#include <boost/noncopyable.hpp> + +//...................................................................................................................... +namespace toolkit +{ +//...................................................................................................................... + + //================================================================================================================== + //= AnimatedImagesPeer + //================================================================================================================== + struct AnimatedImagesPeer_Data; + typedef ::cppu::ImplInheritanceHelper3 < VCLXWindow + , ::com::sun::star::awt::XAnimation + , ::com::sun::star::container::XContainerListener + , ::com::sun::star::util::XModifyListener + > AnimatedImagesPeer_Base; + + class AnimatedImagesPeer :public AnimatedImagesPeer_Base + ,public ::boost::noncopyable + { + public: + AnimatedImagesPeer(); + + protected: + ~AnimatedImagesPeer(); + + public: + // XAnimation + virtual void SAL_CALL startAnimation( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL stopAnimation( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL isAnimationRunning( ) throw (::com::sun::star::uno::RuntimeException); + + // VclWindowPeer + virtual void SAL_CALL setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getProperty( const ::rtl::OUString& PropertyName ) 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); + + // XModifyListener + virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& i_event ) throw (::com::sun::star::uno::RuntimeException); + + // XComponent + void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException); + + protected: + void ProcessWindowEvent( const VclWindowEvent& i_windowEvent ); + + private: + /** updates our images with the ones from the givem XAnimatedImages component + */ + void impl_updateImages_nolck( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& i_animatedImages ); + + private: + ::boost::scoped_ptr< AnimatedImagesPeer_Data > m_pData; + }; + +//...................................................................................................................... +} // namespace toolkit +//...................................................................................................................... + +#endif // TOOLKIT_ANIMATEDIMAGEPEER_HXX diff --git a/toolkit/inc/toolkit/awt/vclxaccessiblecomponent.hxx b/toolkit/inc/toolkit/awt/vclxaccessiblecomponent.hxx index 24eae01f8e9d..0b88ee59bb56 100644 --- a/toolkit/inc/toolkit/awt/vclxaccessiblecomponent.hxx +++ b/toolkit/inc/toolkit/awt/vclxaccessiblecomponent.hxx @@ -75,8 +75,8 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow> mxWindow; VCLXWindow* mpVCLXindow; - ULONG nDummy1; - ULONG nDummy2; + sal_uLong nDummy1; + sal_uLong nDummy2; void* pDummy1; VCLExternalSolarLock* m_pSolarLock; diff --git a/toolkit/inc/toolkit/awt/vclxcontainer.hxx b/toolkit/inc/toolkit/awt/vclxcontainer.hxx index 3e95d8f9811f..fa66ba43af99 100644 --- a/toolkit/inc/toolkit/awt/vclxcontainer.hxx +++ b/toolkit/inc/toolkit/awt/vclxcontainer.hxx @@ -43,7 +43,7 @@ // class VCLXContainer // ---------------------------------------------------- -class VCLXContainer : public ::com::sun::star::awt::XVclContainer, +class TOOLKIT_DLLPUBLIC VCLXContainer : public ::com::sun::star::awt::XVclContainer, public ::com::sun::star::awt::XVclContainerPeer, public VCLXWindow { diff --git a/toolkit/inc/toolkit/awt/vclxdevice.hxx b/toolkit/inc/toolkit/awt/vclxdevice.hxx index d7d144edff98..fba5ec764a86 100644 --- a/toolkit/inc/toolkit/awt/vclxdevice.hxx +++ b/toolkit/inc/toolkit/awt/vclxdevice.hxx @@ -45,7 +45,7 @@ class VirtualDevice; // class VCLXDevice // ---------------------------------------------------- -// For using nDummy, no incompatible update, add a BOOL bCreatedWithToolkitMember later... +// For using nDummy, no incompatible update, add a sal_Bool bCreatedWithToolkitMember later... #define FLAGS_CREATEDWITHTOOLKIT 0x00000001 class TOOLKIT_DLLPUBLIC VCLXDevice : public ::com::sun::star::awt::XDevice, diff --git a/toolkit/inc/toolkit/awt/vclxfont.hxx b/toolkit/inc/toolkit/awt/vclxfont.hxx index 3aa432071251..a35ec3aa1875 100644 --- a/toolkit/inc/toolkit/awt/vclxfont.hxx +++ b/toolkit/inc/toolkit/awt/vclxfont.hxx @@ -54,7 +54,7 @@ private: FontMetric* mpFontMetric; protected: - BOOL ImplAssertValidFontMetric(); + sal_Bool ImplAssertValidFontMetric(); ::osl::Mutex& GetMutex() { return maMutex; } public: diff --git a/toolkit/inc/toolkit/awt/vclxmenu.hxx b/toolkit/inc/toolkit/awt/vclxmenu.hxx index ad41e04033f9..74bdeeefa4d3 100644 --- a/toolkit/inc/toolkit/awt/vclxmenu.hxx +++ b/toolkit/inc/toolkit/awt/vclxmenu.hxx @@ -83,7 +83,7 @@ public: Menu* GetMenu() const { return mpMenu; } - BOOL IsPopupMenu() const; + sal_Bool IsPopupMenu() const; // ::com::sun::star::uno::XInterface ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); diff --git a/toolkit/inc/toolkit/awt/vclxtabpagecontainer.hxx b/toolkit/inc/toolkit/awt/vclxtabpagecontainer.hxx new file mode 100644 index 000000000000..d4fe2a727b43 --- /dev/null +++ b/toolkit/inc/toolkit/awt/vclxtabpagecontainer.hxx @@ -0,0 +1,90 @@ +// ---------------------------------------------------- +// class VCLXDialog +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General 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_AWT_VCLXTABPAGECONTAINER_HXX_ +#define _TOOLKIT_AWT_VCLXTABPAGECONTAINER_HXX_ + +#include <toolkit/dllapi.h> +#include <com/sun/star/beans/PropertyValues.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/beans/PropertyState.hpp> +#include <com/sun/star/beans/XPropertySetInfo.hpp> +#include <com/sun/star/container/XContainerListener.hpp> +#include "toolkit/awt/vclxwindow.hxx" +//#include <com/sun/star/awt/tab/XTabPageModel.hpp> +#include <com/sun/star/awt/tab/XTabPageContainer.hpp> +#include <toolkit/helper/listenermultiplexer.hxx> +#include <cppuhelper/implbase2.hxx> +#include <toolkit/awt/vclxcontainer.hxx> + +// ---------------------------------------------------- +typedef ::cppu::ImplInheritanceHelper2 < VCLXContainer + , ::com::sun::star::awt::tab::XTabPageContainer + , ::com::sun::star::container::XContainerListener + > VCLXTabPageContainer_Base; +class VCLXTabPageContainer : public VCLXTabPageContainer_Base +{ +public: + VCLXTabPageContainer(); + ~VCLXTabPageContainer(); + + // ::com::sun::star::awt::XView + void SAL_CALL draw( sal_Int32 nX, sal_Int32 nY ) throw(::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::awt::XDevice, + ::com::sun::star::awt::DeviceInfo SAL_CALL getInfo() throw(::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::awt::grid::XTabPageContainer + virtual ::sal_Int16 SAL_CALL getActiveTabPageID() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setActiveTabPageID( ::sal_Int16 _activetabpageid ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getTabPageCount( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL isTabPageActive( ::sal_Int16 tabPageIndex ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::tab::XTabPage > SAL_CALL getTabPage( ::sal_Int16 tabPageIndex ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::tab::XTabPage > SAL_CALL getTabPageByID( ::sal_Int16 tabPageID ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addTabPageListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tab::XTabPageContainerListener >& listener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeTabPageListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tab::XTabPageContainerListener >& listener ) throw (::com::sun::star::uno::RuntimeException); + + static void ImplGetPropertyIds( std::list< sal_uInt16 > &aIds ); + virtual void GetPropertyIds( std::list< sal_uInt16 > &aIds ) { return ImplGetPropertyIds( aIds ); } + + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); + 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); + + // ::com::sun::star::awt::XVclWindowPeer + void SAL_CALL setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException); +protected: + virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ); +private: + sal_Int16 m_nActiveTabPageId; + TabPageListenerMultiplexer m_aTabPageListeners; + ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::awt::tab::XTabPage > > m_aTabPages; +}; +#endif // _TOOLKIT_AWT_VCLXTABPAGEMODEL_HXX_ diff --git a/toolkit/inc/toolkit/awt/vclxtabpagemodel.hxx b/toolkit/inc/toolkit/awt/vclxtabpagemodel.hxx new file mode 100644 index 000000000000..670ed25c0f2d --- /dev/null +++ b/toolkit/inc/toolkit/awt/vclxtabpagemodel.hxx @@ -0,0 +1,82 @@ +// ---------------------------------------------------- +// class VCLXDialog +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General 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_AWT_VCLXTABPAGEMODEL_HXX_ +#define _TOOLKIT_AWT_VCLXTABPAGEMODEL_HXX_ + +#include <toolkit/dllapi.h> +#include <com/sun/star/beans/PropertyValues.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/beans/PropertyState.hpp> +#include <com/sun/star/beans/XPropertySetInfo.hpp> +#include "toolkit/awt/vclxwindow.hxx" +#include <toolkit/controls/unocontrolmodel.hxx> +#include <com/sun/star/awt/tab/XTabPageModel.hpp> +#include <com/sun/star/awt/tab/XTabPage.hpp> +#include "forward.hxx" +#include <cppuhelper/implbase1.hxx> +// ---------------------------------------------------- +typedef ::cppu::AggImplInheritanceHelper1 < UnoControlModel, + ::com::sun::star::awt::tab::XTabPageModel + > VCLXTabPageModel_Base; +class VCLXTabPageModel : public VCLXTabPageModel_Base +{ +public: + VCLXTabPageModel(); + VCLXTabPageModel( const VCLXTabPageModel& rModel ) : VCLXTabPageModel_Base( rModel ) {;} + ~VCLXTabPageModel(); + + // ::com::sun::star::awt::XView + void SAL_CALL draw( sal_Int32 nX, sal_Int32 nY ) throw(::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::awt::XDevice, + ::com::sun::star::awt::DeviceInfo SAL_CALL getInfo() throw(::com::sun::star::uno::RuntimeException); + + // virtual void GetPropertyIds( std::list< sal_uInt16 > &aIds ) { return ImplGetPropertyIds( aIds ); } + UnoControlModel* Clone() const { return new VCLXTabPageModel( *this ); } + + // ::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::awt::XVclWindowPeer + void SAL_CALL setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::awt::tab::XTabPageModel + virtual ::sal_Int16 SAL_CALL getTabPageID() throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getEnabled() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setEnabled( ::sal_Bool _enabled ) throw (::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& _title ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getImageURL() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setImageURL( const ::rtl::OUString& _imageurl ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getTooltip() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setTooltip( const ::rtl::OUString& _tooltip ) throw (::com::sun::star::uno::RuntimeException); +protected: + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); +}; +#endif // _TOOLKIT_AWT_VCLXTABPAGEMODEL_HXX_ diff --git a/toolkit/inc/toolkit/awt/vclxtoolkit.hxx b/toolkit/inc/toolkit/awt/vclxtoolkit.hxx index 314168738d93..e706d9cc4a81 100644 --- a/toolkit/inc/toolkit/awt/vclxtoolkit.hxx +++ b/toolkit/inc/toolkit/awt/vclxtoolkit.hxx @@ -42,7 +42,7 @@ #include <osl/mutex.hxx> #include <osl/module.h> #include <tools/link.hxx> -#include <vcl/wintypes.hxx> +#include <tools/wintypes.hxx> #include <toolkit/dllapi.h> diff --git a/toolkit/inc/toolkit/awt/vclxtopwindow.hxx b/toolkit/inc/toolkit/awt/vclxtopwindow.hxx index 76bdf0b8dceb..16f9910391d0 100644 --- a/toolkit/inc/toolkit/awt/vclxtopwindow.hxx +++ b/toolkit/inc/toolkit/awt/vclxtopwindow.hxx @@ -91,7 +91,7 @@ public: // class VCLXTopWindow // ---------------------------------------------------- -class VCLXTopWindow: public VCLXTopWindow_Base, +class TOOLKIT_DLLPUBLIC VCLXTopWindow: public VCLXTopWindow_Base, public VCLXContainer { protected: diff --git a/toolkit/inc/toolkit/awt/vclxwindow.hxx b/toolkit/inc/toolkit/awt/vclxwindow.hxx index fb3ca32b590a..e5c60349a2f7 100644 --- a/toolkit/inc/toolkit/awt/vclxwindow.hxx +++ b/toolkit/inc/toolkit/awt/vclxwindow.hxx @@ -101,7 +101,7 @@ protected: CreateAccessibleContext(); void SetSynthesizingVCLEvent( sal_Bool b ); - BOOL IsSynthesizingVCLEvent() const; + sal_Bool IsSynthesizingVCLEvent() const; void SetSystemParent_Impl( const com::sun::star::uno::Any& rHandle ); diff --git a/toolkit/inc/toolkit/awt/vclxwindows.hxx b/toolkit/inc/toolkit/awt/vclxwindows.hxx index a487c9080ec0..89de37a048fd 100644 --- a/toolkit/inc/toolkit/awt/vclxwindows.hxx +++ b/toolkit/inc/toolkit/awt/vclxwindows.hxx @@ -124,7 +124,7 @@ private: Image maImage; protected: - BitmapEx GetBitmap() const { return maImage.GetBitmapEx(); } + const Image& GetImage() const { return maImage; } protected: // ::com::sun::star::awt::XWindow @@ -295,7 +295,7 @@ private: ::rtl::OUString maActionCommand; protected: - void ImplClickedOrToggled( BOOL bToggled ); + void ImplClickedOrToggled( sal_Bool bToggled ); void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ); virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > CreateAccessibleContext(); @@ -414,7 +414,7 @@ public: // ---------------------------------------------------- // class VCLXDialog // ---------------------------------------------------- -class VCLXDialog : public ::com::sun::star::awt::XDialog2, +class TOOLKIT_DLLPUBLIC VCLXDialog : public ::com::sun::star::awt::XDialog2, public ::com::sun::star::document::XVbaMethodParameter, //liuchen 2009-6-22, add the support of input/output parameters to VBA UserForm_QueryClose event public VCLXTopWindow { @@ -433,7 +433,7 @@ public: // ::com::sun::star::awt::XDialog2 virtual void SAL_CALL endDialog( ::sal_Int32 Result ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setHelpId( ::sal_Int32 Id ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setHelpId( const rtl::OUString& Id ) throw (::com::sun::star::uno::RuntimeException); // ::com::sun::star::awt::XDialog void SAL_CALL setTitle( const ::rtl::OUString& Title ) throw(::com::sun::star::uno::RuntimeException); diff --git a/toolkit/inc/toolkit/awt/xsimpleanimation.hxx b/toolkit/inc/toolkit/awt/xsimpleanimation.hxx index 74ae6f619d24..e00c01082045 100644 --- a/toolkit/inc/toolkit/awt/xsimpleanimation.hxx +++ b/toolkit/inc/toolkit/awt/xsimpleanimation.hxx @@ -34,40 +34,28 @@ #include <comphelper/uno3.hxx> #include <com/sun/star/awt/XSimpleAnimation.hpp> +#include <boost/scoped_ptr.hpp> + //........................................................................ namespace toolkit { - class Throbber_Impl; //........................................................................ //==================================================================== //= XSimpleAnimation //==================================================================== - typedef ::cppu::ImplHelper1 < ::com::sun::star::awt::XSimpleAnimation - > XSimpleAnimation_Base; + typedef ::cppu::ImplInheritanceHelper1 < VCLXWindow + , ::com::sun::star::awt::XSimpleAnimation + > XSimpleAnimation_Base; - class XSimpleAnimation :public VCLXWindow - ,public XSimpleAnimation_Base + class XSimpleAnimation : public XSimpleAnimation_Base { - private: - //::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > > maImageList; - sal_Bool mbRepeat; - sal_Int32 mnStepTime; - - Throbber_Impl *mpThrobber; - public: XSimpleAnimation(); protected: ~XSimpleAnimation(); - // XInterface - DECLARE_XINTERFACE() - - // XTypeProvider - DECLARE_XTYPEPROVIDER() - // XSimpleAnimation virtual void SAL_CALL start() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL stop() throw (::com::sun::star::uno::RuntimeException); @@ -77,9 +65,6 @@ namespace toolkit virtual void SAL_CALL setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Any SAL_CALL getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException); - // VCLXWindow - void ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent ); - private: XSimpleAnimation( const XSimpleAnimation& ); // never implemented XSimpleAnimation& operator=( const XSimpleAnimation& ); // never implemented diff --git a/toolkit/inc/toolkit/awt/xthrobber.hxx b/toolkit/inc/toolkit/awt/xthrobber.hxx index 8b87fec352cc..1ea916c56072 100644 --- a/toolkit/inc/toolkit/awt/xthrobber.hxx +++ b/toolkit/inc/toolkit/awt/xthrobber.hxx @@ -34,23 +34,25 @@ #include <comphelper/uno3.hxx> #include <com/sun/star/awt/XThrobber.hpp> +#include <boost/scoped_ptr.hpp> +#include <boost/noncopyable.hpp> + //........................................................................ namespace toolkit { //........................................................................ - class Throbber_Impl; //==================================================================== //= XThrobber //==================================================================== - typedef ::cppu::ImplHelper1 < ::com::sun::star::awt::XThrobber - > XThrobber_Base; + typedef ::cppu::ImplInheritanceHelper1 < VCLXWindow + , ::com::sun::star::awt::XThrobber + > XThrobber_Base; - class XThrobber :public VCLXWindow - ,public XThrobber_Base + class XThrobber :public XThrobber_Base + ,public ::boost::noncopyable { private: - Throbber_Impl *mpThrobber; void SAL_CALL InitImageList() throw(::com::sun::star::uno::RuntimeException); public: @@ -59,22 +61,12 @@ namespace toolkit protected: ~XThrobber(); - // XInterface - DECLARE_XINTERFACE() - - // XTypeProvider - DECLARE_XTYPEPROVIDER() - // XThrobber virtual void SAL_CALL start() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL stop() throw (::com::sun::star::uno::RuntimeException); - // VclWindowPeer - virtual void SAL_CALL setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException); - // VCLXWindow - void ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent ); + virtual void SetWindow( Window* pWindow ); private: XThrobber( const XThrobber& ); // never implemented diff --git a/toolkit/inc/toolkit/controls/animatedimages.hxx b/toolkit/inc/toolkit/controls/animatedimages.hxx new file mode 100755 index 000000000000..c19ed5e5451c --- /dev/null +++ b/toolkit/inc/toolkit/controls/animatedimages.hxx @@ -0,0 +1,144 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General 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_ANIMATEDIMAGES_HXX +#define TOOLKIT_ANIMATEDIMAGES_HXX + +#include "toolkit/controls/unocontrolbase.hxx" +#include "toolkit/controls/unocontrolmodel.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/awt/XAnimation.hpp> +#include <com/sun/star/awt/XAnimatedImages.hpp> +#include <com/sun/star/container/XContainerListener.hpp> +/** === end UNO includes === **/ + +#include <cppuhelper/implbase1.hxx> +#include <cppuhelper/implbase2.hxx> + +#include <boost/scoped_ptr.hpp> + +//...................................................................................................................... +namespace toolkit +{ +//...................................................................................................................... + + //================================================================================================================== + //= + //================================================================================================================== + typedef ::cppu::AggImplInheritanceHelper2 < UnoControlBase + , ::com::sun::star::awt::XAnimation + , ::com::sun::star::container::XContainerListener + > AnimatedImagesControl_Base; + + class AnimatedImagesControl : public AnimatedImagesControl_Base + { + public: + AnimatedImagesControl( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > const & i_factory ); + ::rtl::OUString GetComponentServiceName(); + + // XAnimation + virtual void SAL_CALL startAnimation( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL stopAnimation( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL isAnimationRunning( ) throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); + + // XControl + sal_Bool SAL_CALL setModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& i_rModel ) throw ( ::com::sun::star::uno::RuntimeException ); + void SAL_CALL createPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit >& i_toolkit, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& i_parentPeer ) 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); + }; + + //================================================================================================================== + //= AnimatedImagesControlModel + //================================================================================================================== + struct AnimatedImagesControlModel_Data; + typedef ::cppu::AggImplInheritanceHelper1 < UnoControlModel + , ::com::sun::star::awt::XAnimatedImages + > AnimatedImagesControlModel_Base; + class AnimatedImagesControlModel : public AnimatedImagesControlModel_Base + { + public: + AnimatedImagesControlModel( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > const & i_factory ); + AnimatedImagesControlModel( const AnimatedImagesControlModel& i_copySource ); + + virtual UnoControlModel* Clone() const; + + // XPropertySet + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); + + // XPersistObject + ::rtl::OUString SAL_CALL getServiceName() throw(::com::sun::star::uno::RuntimeException); + + // XServiceInfo + ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); + + // XAnimatedImages + virtual ::sal_Int32 SAL_CALL getStepTime() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setStepTime( ::sal_Int32 _steptime ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getAutoRepeat() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setAutoRepeat( ::sal_Bool _autorepeat ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int16 SAL_CALL getScaleMode() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setScaleMode( ::sal_Int16 _scalemode ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getImageSetCount( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getImageSet( ::sal_Int32 i_index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL insertImageSet( ::sal_Int32 i_index, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& i_imageURLs ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL replaceImageSet( ::sal_Int32 i_index, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& i_imageURLs ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeImageSet( ::sal_Int32 i_index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + + // XAnimatedImages::XContainer + virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& i_listener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& i_listener ) throw (::com::sun::star::uno::RuntimeException); + + protected: + ~AnimatedImagesControlModel(); + + ::com::sun::star::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); + void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception); + + private: + ::boost::scoped_ptr< AnimatedImagesControlModel_Data > + m_pData; + }; + +//...................................................................................................................... +} // namespace toolkit +//...................................................................................................................... + +#endif // TOOLKIT_ANIMATEDIMAGES_HXX diff --git a/toolkit/inc/toolkit/controls/controlmodelcontainerbase.hxx b/toolkit/inc/toolkit/controls/controlmodelcontainerbase.hxx new file mode 100644 index 000000000000..3090eba68749 --- /dev/null +++ b/toolkit/inc/toolkit/controls/controlmodelcontainerbase.hxx @@ -0,0 +1,265 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef TOOLKIT_CONTROL_MODEL_CONTAINERBASE_HXX +#define TOOLKIT_CONTROL_MODEL_CONTAINERBASE_HXX + +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/container/XContainer.hpp> +#include <com/sun/star/awt/XTabControllerModel.hpp> +#include <com/sun/star/util/XChangesNotifier.hpp> +#include <com/sun/star/util/XChangesListener.hpp> +#include <com/sun/star/util/XModifyListener.hpp> +#include <com/sun/star/beans/XPropertyChangeListener.hpp> +#include <com/sun/star/resource/XStringResourceResolver.hpp> +#include <cppuhelper/implbase8.hxx> +#include <cppuhelper/implbase2.hxx> +#include <toolkit/helper/listenermultiplexer.hxx> +#include <toolkit/controls/unocontrolmodel.hxx> +#include <toolkit/controls/unocontrolcontainer.hxx> +#include <cppuhelper/propshlp.hxx> +#include <cppuhelper/basemutex.hxx> +#include <com/sun/star/graphic/XGraphic.hpp> +#include <com/sun/star/awt/tab/XTabPageModel.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +// ---------------------------------------------------- +// class ControlModelContainerBase +// ---------------------------------------------------- +typedef UnoControlModel ControlModel_Base; +typedef ::cppu::AggImplInheritanceHelper8 < ControlModel_Base + , ::com::sun::star::lang::XMultiServiceFactory + , ::com::sun::star::container::XContainer + , ::com::sun::star::container::XNameContainer + , ::com::sun::star::awt::XTabControllerModel + , ::com::sun::star::util::XChangesNotifier + , ::com::sun::star::beans::XPropertyChangeListener + , ::com::sun::star::awt::tab::XTabPageModel + , ::com::sun::star::lang::XInitialization + > ControlModelContainer_IBase; + +class ControlModelContainerBase : public ControlModelContainer_IBase +{ +public: + // would like to make this typedef private, too, but the Forte 7 compiler does have + // problems with this ..... + typedef ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >, ::rtl::OUString > + UnoControlModelHolder; +private: + typedef ::std::list< UnoControlModelHolder > UnoControlModelHolderList; + + // for grouping control models (XTabControllerModel::getGroupXXX) + typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > > + ModelGroup; + typedef ::std::vector< ModelGroup > AllGroups; + + friend struct CloneControlModel; + friend struct FindControlModel; + friend struct CompareControlModel; + +protected: + ContainerListenerMultiplexer maContainerListeners; + ::cppu::OInterfaceContainerHelper maChangeListeners; + UnoControlModelHolderList maModels; + + AllGroups maGroups; + sal_Bool mbGroupsUpToDate; + + bool m_bEnabled; + ::rtl::OUString m_sTitle; + ::rtl::OUString m_sImageURL; + ::rtl::OUString m_sTooltip; + sal_Int16 m_nTabPageId; + + void Clone_Impl(ControlModelContainerBase& _rClone) const; + +protected: + ::com::sun::star::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); + + UnoControlModelHolderList::iterator ImplFindElement( const ::rtl::OUString& rName ); + +public: + ControlModelContainerBase( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); + ControlModelContainerBase( const ControlModelContainerBase& rModel ); + ~ControlModelContainerBase(); + + UnoControlModel* Clone() const; + + // ::com::sun::star::container::XContainer + void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); + void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::container::XElementAcces + ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException); + sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::container::XNameContainer, XNameReplace, XNameAccess + void SAL_CALL replaceByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw(::com::sun::star::uno::RuntimeException); + sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException); + void SAL_CALL insertByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + void SAL_CALL removeByName( const ::rtl::OUString& Name ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::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::lang::XMultiServiceFactory + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstance( const ::rtl::OUString& aServiceSpecifier ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Arguments ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableServiceNames( ) throw(::com::sun::star::uno::RuntimeException); + + // XComponent + void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException); + + // XTabControllerModel + virtual sal_Bool SAL_CALL getGroupControl( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setGroupControl( sal_Bool GroupControl ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setControlModels( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& Controls ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > > SAL_CALL getControlModels( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setGroup( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& Group, const ::rtl::OUString& GroupName ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getGroupCount( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL getGroup( sal_Int32 nGroup, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& Group, ::rtl::OUString& Name ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL getGroupByName( const ::rtl::OUString& Name, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& Group ) throw (::com::sun::star::uno::RuntimeException); + + // XChangesNotifier + virtual void SAL_CALL addChangesListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XChangesListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeChangesListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XChangesListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); + + // XPropertyChangeListener + virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (::com::sun::star::uno::RuntimeException); + + // XEventListener + using cppu::OPropertySetHelper::disposing; + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& evt ) throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + DECLIMPL_SERVICEINFO_DERIVED(ControlModelContainerBase, ControlModel_Base, "toolkit.ControlModelContainerBase" ) + + // XInitialization + virtual void SAL_CALL initialize (const com::sun::star::uno::Sequence<com::sun::star::uno::Any>& rArguments) + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); + + // ::com::sun::star::awt::tab::XTabPageModel + virtual ::sal_Int16 SAL_CALL getTabPageID() throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getEnabled() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setEnabled( ::sal_Bool _enabled ) throw (::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& _title ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getImageURL() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setImageURL( const ::rtl::OUString& _imageurl ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getTooltip() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setTooltip( const ::rtl::OUString& _tooltip ) throw (::com::sun::star::uno::RuntimeException); + +protected: + void startControlListening( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& _rxChildModel ); + void stopControlListening( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& _rxChildModel ); + + void implNotifyTabModelChange( const ::rtl::OUString& _rAccessor ); + + void implUpdateGroupStructure(); +}; + +class ResourceListener :public ::com::sun::star::util::XModifyListener, + public ::cppu::OWeakObject, + public ::cppu::BaseMutex +{ + public: + ResourceListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& xListener ); + virtual ~ResourceListener(); + + void startListening( const ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceResolver >& rResource ); + void stopListening(); + + // 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 (); + + // XModifyListener + virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException); + + // XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); + + private: + ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceResolver > m_xResource; + ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener > m_xListener; + bool m_bListening; +}; + +typedef ::cppu::AggImplInheritanceHelper2 < UnoControlContainer + , ::com::sun::star::container::XContainerListener + , ::com::sun::star::util::XChangesListener + > ContainerControl_IBase; + +class ControlContainerBase : public ContainerControl_IBase +{ +protected: + bool mbSizeModified; + bool mbPosModified; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabController > mxTabController; + ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener > mxListener; + + void ImplInsertControl( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxModel, const ::rtl::OUString& rName ); + void ImplRemoveControl( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxModel ); + virtual void ImplSetPosSize( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& rxCtrl ); + void ImplUpdateResourceResolver(); + void ImplStartListingForResourceEvents(); + ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > Impl_getGraphicFromURL_nothrow( const ::rtl::OUString& _rURL ); + + ControlContainerBase(); + +public: + ControlContainerBase( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); + ~ControlContainerBase(); + + DECLIMPL_SERVICEINFO_DERIVED( ControlContainerBase, UnoControlBase, "toolkit.ControlContainerBase" ) + + void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); + void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException); + + 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); + + // ::com::sun::star::container::XContainerListener + void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException); + void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException); + void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException); + + // XChangesListener + virtual void SAL_CALL changesOccurred( const ::com::sun::star::util::ChangesEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::awt::XControl + sal_Bool SAL_CALL setModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& Model ) throw(::com::sun::star::uno::RuntimeException); + void SAL_CALL setDesignMode( sal_Bool bOn ) throw(::com::sun::star::uno::RuntimeException); +protected: + virtual void ImplModelPropertiesChanged( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyChangeEvent >& rEvents ) throw(::com::sun::star::uno::RuntimeException); + virtual void removingControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl ); + virtual void addingControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl ); +}; +#endif diff --git a/toolkit/inc/toolkit/controls/dialogcontrol.hxx b/toolkit/inc/toolkit/controls/dialogcontrol.hxx index 6adec8eeae4f..aa223d8c65df 100644 --- a/toolkit/inc/toolkit/controls/dialogcontrol.hxx +++ b/toolkit/inc/toolkit/controls/dialogcontrol.hxx @@ -29,28 +29,17 @@ #ifndef TOOLKIT_DIALOG_CONTROL_HXX #define TOOLKIT_DIALOG_CONTROL_HXX -#include <com/sun/star/container/XNameContainer.hpp> -#include <com/sun/star/container/XContainer.hpp> -#include <com/sun/star/awt/XTabControllerModel.hpp> +#include <toolkit/controls/controlmodelcontainerbase.hxx> #include <com/sun/star/awt/XTopWindow.hpp> -#include <com/sun/star/util/XChangesNotifier.hpp> -#include <com/sun/star/util/XChangesListener.hpp> +#include <com/sun/star/awt/XDialog.hpp> #include <com/sun/star/awt/XTabListener.hpp> #include <com/sun/star/awt/XSimpleTabController.hpp> -#include <com/sun/star/util/XModifyListener.hpp> -#include <com/sun/star/beans/XPropertyChangeListener.hpp> -#include <com/sun/star/awt/XDialog2.hpp> #include <com/sun/star/resource/XStringResourceResolver.hpp> #include <com/sun/star/graphic/XGraphicObject.hpp> -#include <cppuhelper/implbase6.hxx> -#include <cppuhelper/implbase5.hxx> #include <cppuhelper/implbase2.hxx> -#include <toolkit/helper/listenermultiplexer.hxx> -#include <toolkit/controls/unocontrolmodel.hxx> #include "toolkit/helper/servicenames.hxx" #include "toolkit/helper/macros.hxx" #include <toolkit/controls/unocontrolcontainer.hxx> -#include <cppuhelper/propshlp.hxx> #include <cppuhelper/basemutex.hxx> #include <list> #include <map> @@ -59,139 +48,38 @@ // ---------------------------------------------------- // class UnoControlDialogModel // ---------------------------------------------------- -typedef UnoControlModel UnoControlDialogModel_Base; -typedef ::cppu::ImplHelper6 < ::com::sun::star::lang::XMultiServiceFactory - , ::com::sun::star::container::XContainer - , ::com::sun::star::container::XNameContainer - , ::com::sun::star::awt::XTabControllerModel - , ::com::sun::star::util::XChangesNotifier - , ::com::sun::star::beans::XPropertyChangeListener - > UnoControlDialogModel_IBase; - -class UnoControlDialogModel : public UnoControlDialogModel_IBase - , public UnoControlDialogModel_Base + +class UnoControlDialogModel : public ControlModelContainerBase { -public: enum ChildOperation { Insert = 0, Remove }; - // would like to make this typedef private, too, but the Forte 7 compiler does have - // problems with this ..... - typedef ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >, ::rtl::OUString > - UnoControlModelHolder; protected: void updateUserFormChildren( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& xAllChildren, const rtl::OUString& aName, ChildOperation Operation, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& xTarget ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - typedef ::std::list< UnoControlModelHolder > UnoControlModelHolderList; - - // for grouping control models (XTabControllerModel::getGroupXXX) - typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > > - ModelGroup; - typedef ::std::vector< ModelGroup > AllGroups; - - friend struct CloneControlModel; - friend struct FindControlModel; - friend struct CompareControlModel; - - ContainerListenerMultiplexer maContainerListeners; - ::cppu::OInterfaceContainerHelper maChangeListeners; - UnoControlModelHolderList maModels; - - AllGroups maGroups; - sal_Bool mbGroupsUpToDate; - ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphicObject > mxGrfObj; bool mbAdjustingGraphic; ::com::sun::star::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const; ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); - - UnoControlModelHolderList::iterator ImplFindElement( const ::rtl::OUString& rName ); - public: - // bRegProps = false => subclass will register its own props + UnoControlDialogModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); UnoControlDialogModel( bool bRegProps = true ); UnoControlDialogModel( const UnoControlDialogModel& rModel ); ~UnoControlDialogModel(); UnoControlModel* Clone() const; - ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) { return UnoControlModel::queryInterface(rType); } - ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); - void SAL_CALL acquire() throw() { OWeakAggObject::acquire(); } - void SAL_CALL release() throw() { OWeakAggObject::release(); } - - // ::com::sun::star::lang::XTypeProvider - ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw(::com::sun::star::uno::RuntimeException); - ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException); - - // ::com::sun::star::container::XContainer - void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); - void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); - - // ::com::sun::star::container::XElementAcces - ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException); - sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException); - - // ::com::sun::star::container::XIndexContainer, XIndexReplace, XIndexAcces - // void SAL_CALL replaceByIndex( sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) = 0; - // sal_Int32 SAL_CALL getCount( ) throw(::com::sun::star::uno::RuntimeException) = 0; - // ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) = 0; - // void SAL_CALL insertByIndex( sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) = 0; - // void SAL_CALL removeByIndex( sal_Int32 Index ) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) = 0; - - // ::com::sun::star::container::XNameContainer, XNameReplace, XNameAccess - void SAL_CALL replaceByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw(::com::sun::star::uno::RuntimeException); - sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException); - void SAL_CALL insertByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - void SAL_CALL removeByName( const ::rtl::OUString& Name ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::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::lang::XMultiServiceFactory - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstance( const ::rtl::OUString& aServiceSpecifier ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Arguments ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); - ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableServiceNames( ) throw(::com::sun::star::uno::RuntimeException); // ::com::sun::star::io::XPersistObject ::rtl::OUString SAL_CALL getServiceName() throw(::com::sun::star::uno::RuntimeException); - // XComponent - void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException); - - // XTabControllerModel - virtual sal_Bool SAL_CALL getGroupControl( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setGroupControl( sal_Bool GroupControl ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setControlModels( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& Controls ) throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > > SAL_CALL getControlModels( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setGroup( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& Group, const ::rtl::OUString& GroupName ) throw (::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getGroupCount( ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL getGroup( sal_Int32 nGroup, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& Group, ::rtl::OUString& Name ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL getGroupByName( const ::rtl::OUString& Name, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > >& Group ) throw (::com::sun::star::uno::RuntimeException); - - // XChangesNotifier - virtual void SAL_CALL addChangesListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XChangesListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeChangesListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XChangesListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); - - // XPropertyChangeListener - virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (::com::sun::star::uno::RuntimeException); - - // XEventListener - using cppu::OPropertySetHelper::disposing; - virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& evt ) throw (::com::sun::star::uno::RuntimeException); - // XServiceInfo - DECLIMPL_SERVICEINFO_DERIVED( UnoControlDialogModel,UnoControlDialogModel_Base, szServiceName2_UnoControlDialogModel ) + DECLIMPL_SERVICEINFO_DERIVED( UnoControlDialogModel, ControlModelContainerBase, szServiceName2_UnoControlDialogModel ) -protected: - void startControlListening( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& _rxChildModel ); - void stopControlListening( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& _rxChildModel ); // ::cppu::OPropertySetHelper void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception); - - void implNotifyTabModelChange( const ::rtl::OUString& _rAccessor ); - - void implUpdateGroupStructure(); private: void AddRadioButtonToGroup ( const ::com::sun::star::uno::Reference< XControlModel >& rControlModel, @@ -200,70 +88,25 @@ private: ModelGroup*& rpCurrentGroup ); void AddRadioButtonGroup ( ::std::map< ::rtl::OUString, ModelGroup >& pNamedGroups ); -}; - -// ---------------------------------------------------- -// class UnoDialogControl -// ---------------------------------------------------- -typedef ::cppu::ImplHelper6 < ::com::sun::star::container::XContainerListener - , ::com::sun::star::awt::XTopWindow - , ::com::sun::star::awt::XDialog2 - , ::com::sun::star::util::XChangesListener - , ::com::sun::star::util::XModifyListener - , ::com::sun::star::awt::XWindowListener - > UnoDialogControl_IBase; - -class ResourceListener :public ::com::sun::star::util::XModifyListener, - public ::cppu::OWeakObject, - public ::cppu::BaseMutex -{ - public: - ResourceListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& xListener ); - virtual ~ResourceListener(); - - void startListening( const ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceResolver >& rResource ); - void stopListening(); - - // 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 (); - // XModifyListener - virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException); - // XEventListener - virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); - - private: - ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceResolver > m_xResource; - ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener > m_xListener; - bool m_bListening; }; -class UnoDialogControl :public UnoControlContainer - ,public UnoDialogControl_IBase +class UnoDialogControl :public ControlContainerBase, + public ::com::sun::star::awt::XTopWindow, + public ::com::sun::star::awt::XDialog, + public ::com::sun::star::awt::XWindowListener { private: ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMenuBar > mxMenuBar; - ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabController > mxTabController; - ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener > mxListener; TopWindowListenerMultiplexer maTopWindowListeners; bool mbWindowListener; - bool mbSizeModified; - bool mbPosModified; - -protected: - void ImplInsertControl( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxModel, const ::rtl::OUString& rName ); - void ImplRemoveControl( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxModel ); - void ImplSetPosSize( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& rxCtrl ); - void ImplUpdateResourceResolver(); - void ImplStartListingForResourceEvents(); public: - UnoDialogControl(); + UnoDialogControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); + ~UnoDialogControl(); ::rtl::OUString GetComponentServiceName(); ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) { return UnoControlContainer::queryInterface(rType); } @@ -288,14 +131,6 @@ public: virtual void SAL_CALL windowShown( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL windowHidden( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException); - // ::com::sun::star::container::XContainerListener - void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException); - void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException); - void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw(::com::sun::star::uno::RuntimeException); - - // ::com::sun::star::awt::XDialog2 - virtual void SAL_CALL endDialog( ::sal_Int32 Result ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setHelpId( ::sal_Int32 Id ) throw (::com::sun::star::uno::RuntimeException); // ::com::sun::star::awt::XDialog void SAL_CALL setTitle( const ::rtl::OUString& Title ) throw(::com::sun::star::uno::RuntimeException); @@ -309,10 +144,6 @@ public: // ::com::sun::star::awt::XControl sal_Bool SAL_CALL setModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& Model ) throw(::com::sun::star::uno::RuntimeException); - void SAL_CALL setDesignMode( sal_Bool bOn ) throw(::com::sun::star::uno::RuntimeException); - - // XChangesListener - virtual void SAL_CALL changesOccurred( const ::com::sun::star::util::ChangesEvent& Event ) throw (::com::sun::star::uno::RuntimeException); // XModifyListener virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException); @@ -321,9 +152,8 @@ public: DECLIMPL_SERVICEINFO( UnoDialogControl, szServiceName2_UnoControlDialog ) protected: - virtual void ImplModelPropertiesChanged( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyChangeEvent >& rEvents ) throw(::com::sun::star::uno::RuntimeException); + // virtual void ImplModelPropertiesChanged( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyChangeEvent >& rEvents ) throw(::com::sun::star::uno::RuntimeException); virtual void PrepareWindowDescriptor( ::com::sun::star::awt::WindowDescriptor& rDesc ); - protected: virtual void removingControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl ); virtual void addingControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl ); diff --git a/toolkit/inc/toolkit/controls/formattedcontrol.hxx b/toolkit/inc/toolkit/controls/formattedcontrol.hxx index 40ba795487cc..525e67dc6027 100644 --- a/toolkit/inc/toolkit/controls/formattedcontrol.hxx +++ b/toolkit/inc/toolkit/controls/formattedcontrol.hxx @@ -68,8 +68,11 @@ namespace toolkit ) throw (::com::sun::star::uno::Exception); public: - UnoControlFormattedFieldModel(); - UnoControlFormattedFieldModel( const UnoControlFormattedFieldModel& rModel ) : UnoControlModel( rModel ) {;} + UnoControlFormattedFieldModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); + UnoControlFormattedFieldModel( const UnoControlFormattedFieldModel& rModel ) + :UnoControlModel( rModel ) + { + } UnoControlModel* Clone() const { return new UnoControlFormattedFieldModel( *this ); } @@ -111,7 +114,7 @@ namespace toolkit class UnoFormattedFieldControl : public UnoSpinFieldControl { public: - UnoFormattedFieldControl(); + UnoFormattedFieldControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); ::rtl::OUString GetComponentServiceName(); // ::com::sun::star::awt::XTextListener diff --git a/toolkit/inc/toolkit/controls/geometrycontrolmodel.hxx b/toolkit/inc/toolkit/controls/geometrycontrolmodel.hxx index fe57638c43ad..3bb3e0f3be49 100644 --- a/toolkit/inc/toolkit/controls/geometrycontrolmodel.hxx +++ b/toolkit/inc/toolkit/controls/geometrycontrolmodel.hxx @@ -186,7 +186,7 @@ FORWARD_DECLARE_INTERFACE( script, XNameContainer ) ,public ::comphelper::OAggregationArrayUsageHelper< OTemplateInstanceDisambiguation< CONTROLMODEL > > { public: - OGeometryControlModel(); + OGeometryControlModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); private: OGeometryControlModel(::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable >& _rxAggregateInstance); diff --git a/toolkit/inc/toolkit/controls/geometrycontrolmodel_impl.hxx b/toolkit/inc/toolkit/controls/geometrycontrolmodel_impl.hxx index 725b6998ec01..7eb5d0966282 100644 --- a/toolkit/inc/toolkit/controls/geometrycontrolmodel_impl.hxx +++ b/toolkit/inc/toolkit/controls/geometrycontrolmodel_impl.hxx @@ -33,11 +33,17 @@ //==================================================================== //-------------------------------------------------------------------- template <class CONTROLMODEL> -OGeometryControlModel<CONTROLMODEL>::OGeometryControlModel() - :OGeometryControlModel_Base(new CONTROLMODEL) +OGeometryControlModel<CONTROLMODEL>::OGeometryControlModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ) + :OGeometryControlModel_Base(new CONTROLMODEL( i_factory ) ) { } +//template <class CONTROLMODEL> +//OGeometryControlModel<CONTROLMODEL>::OGeometryControlModel(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & i_xCompContext) +// :OGeometryControlModel_Base(new CONTROLMODEL(i_xCompContext)) +//{ +//} +// //-------------------------------------------------------------------- template <class CONTROLMODEL> OGeometryControlModel<CONTROLMODEL>::OGeometryControlModel(::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable >& _rxAggregateInstance) diff --git a/toolkit/inc/toolkit/controls/roadmapcontrol.hxx b/toolkit/inc/toolkit/controls/roadmapcontrol.hxx index 3669e7b795ba..d570216fbccd 100644 --- a/toolkit/inc/toolkit/controls/roadmapcontrol.hxx +++ b/toolkit/inc/toolkit/controls/roadmapcontrol.hxx @@ -46,37 +46,37 @@ #include <cppuhelper/implbase4.hxx> - #include <comphelper/uno3.hxx> -typedef GraphicControlModel UnoControlRoadmapModel_Base; +//........................................................................ +namespace toolkit +{ +//........................................................................ + typedef GraphicControlModel UnoControlRoadmapModel_Base; -typedef ::cppu::ImplHelper3 < ::com::sun::star::lang::XSingleServiceFactory - , ::com::sun::star::container::XContainer - , ::com::sun::star::container::XIndexContainer - > UnoControlRoadmapModel_IBase; + typedef ::cppu::ImplHelper3 < ::com::sun::star::lang::XSingleServiceFactory + , ::com::sun::star::container::XContainer + , ::com::sun::star::container::XIndexContainer + > UnoControlRoadmapModel_IBase; -typedef UnoControlBase UnoControlRoadmap_Base; -typedef ::cppu::ImplHelper4 < ::com::sun::star::awt::XItemEventBroadcaster - , ::com::sun::star::container::XContainerListener - , ::com::sun::star::awt::XItemListener - , ::com::sun::star::beans::XPropertyChangeListener - > UnoControlRoadmap_IBase; + typedef UnoControlBase UnoControlRoadmap_Base; + typedef ::cppu::ImplHelper4 < ::com::sun::star::awt::XItemEventBroadcaster + , ::com::sun::star::container::XContainerListener + , ::com::sun::star::awt::XItemListener + , ::com::sun::star::beans::XPropertyChangeListener + > UnoControlRoadmap_IBase; -typedef ::cppu::ImplHelper2< ::com::sun::star::container::XContainerListener, - ::com::sun::star::awt::XItemEventBroadcaster> SVTXRoadmap_Base; + typedef ::cppu::ImplHelper2< ::com::sun::star::container::XContainerListener, + ::com::sun::star::awt::XItemEventBroadcaster> SVTXRoadmap_Base; -//........................................................................ -namespace toolkit{ -//........................................................................ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::awt; using namespace ::com::sun::star::lang; @@ -111,7 +111,7 @@ namespace toolkit{ ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); public: - UnoControlRoadmapModel(); + UnoControlRoadmapModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); UnoControlRoadmapModel( const UnoControlRoadmapModel& rModel ) : UnoControlRoadmapModel_Base( rModel ), UnoControlRoadmapModel_IBase( rModel ), @@ -168,7 +168,7 @@ namespace toolkit{ private: ItemListenerMultiplexer maItemListeners; public: - UnoRoadmapControl(); + UnoRoadmapControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); ::rtl::OUString GetComponentServiceName(); void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException) { UnoControlBase::disposing( Source ); } diff --git a/toolkit/inc/toolkit/controls/spinningprogress.hxx b/toolkit/inc/toolkit/controls/spinningprogress.hxx new file mode 100755 index 000000000000..e0a676b2aa86 --- /dev/null +++ b/toolkit/inc/toolkit/controls/spinningprogress.hxx @@ -0,0 +1,70 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef TOOLKIT_SPINNINGPROGRESS_HXX +#define TOOLKIT_SPINNINGPROGRESS_HXX + +#include "toolkit/controls/animatedimages.hxx" + +/** === begin UNO includes === **/ +/** === end UNO includes === **/ + +//...................................................................................................................... +namespace toolkit +{ +//...................................................................................................................... + + //================================================================================================================== + //= SpinningProgressControlModel + //================================================================================================================== + typedef AnimatedImagesControlModel SpinningProgressControlModel_Base; + class SpinningProgressControlModel : public SpinningProgressControlModel_Base + { + public: + SpinningProgressControlModel( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > const & i_factory ); + SpinningProgressControlModel( const SpinningProgressControlModel& i_copySource ); + + virtual UnoControlModel* Clone() const; + + // XPropertySet + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); + + // XPersistObject + ::rtl::OUString SAL_CALL getServiceName() throw(::com::sun::star::uno::RuntimeException); + + // XServiceInfo + ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); + + protected: + ~SpinningProgressControlModel(); + }; + +//...................................................................................................................... +} // namespace toolkit +//...................................................................................................................... + +#endif // TOOLKIT_SPINNINGPROGRESS_HXX diff --git a/toolkit/inc/toolkit/controls/tabpagecontainer.hxx b/toolkit/inc/toolkit/controls/tabpagecontainer.hxx new file mode 100644 index 000000000000..c7a2e3b8ef90 --- /dev/null +++ b/toolkit/inc/toolkit/controls/tabpagecontainer.hxx @@ -0,0 +1,147 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General 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_TABPAGE_CONTAINER_HXX +#define TOOLKIT_TABPAGE_CONTAINER_HXX + +#include <com/sun/star/awt/tab/XTabPageContainer.hpp> +#include <com/sun/star/awt/tab/XTabPageContainerModel.hpp> +#include <com/sun/star/awt/tab/XTabPageContainerListener.hpp> +#include <com/sun/star/awt/tab/XTabPage.hpp> +#include <com/sun/star/awt/tab/XTabPageModel.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/controls/controlmodelcontainerbase.hxx> +#include <toolkit/controls/unocontrolmodel.hxx> +#include <toolkit/helper/listenermultiplexer.hxx> + +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 ::com::sun::star::awt::tab::UnoControlTabPageContainerModel +// ------------------------------------------------------------------ +typedef ::cppu::AggImplInheritanceHelper1 < UnoControlModel + , ::com::sun::star::awt::tab::XTabPageContainerModel + > UnoControlTabPageContainerModel_Base; +class UnoControlTabPageContainerModel : public UnoControlTabPageContainerModel_Base +{ +private: + std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::awt::tab::XTabPageModel > > m_aTabPageVector; + ContainerListenerMultiplexer maContainerListeners; +protected: + ::com::sun::star::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); + // ::com::sun::star::beans::XMultiPropertySet + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); + +public: + UnoControlTabPageContainerModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); + UnoControlTabPageContainerModel( const UnoControlTabPageContainerModel& rModel ) : UnoControlTabPageContainerModel_Base( rModel ),maContainerListeners( *this ) {;} + + UnoControlModel* Clone() const { return new UnoControlTabPageContainerModel( *this ); } + + // ::com::sun::star::io::XPersistObject + ::rtl::OUString SAL_CALL getServiceName() throw(::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::lang::XServiceInfo + DECLIMPL_SERVICEINFO_DERIVED( UnoControlTabPageContainerModel, UnoControlModel, szServiceName_UnoControlTabPageContainerModel ) + // XIndexContainer + virtual void SAL_CALL insertByIndex( sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) + throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeByIndex( sal_Int32 Index ) + throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XIndexReplace + virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) + throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() throw (::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) + throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw (::com::sun::star::uno::RuntimeException); + //{ + //return ::getCppuType((com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >*)0); + //} + + virtual sal_Bool SAL_CALL hasElements() throw (::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::container::XContainer + void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); + void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw(::com::sun::star::uno::RuntimeException); +}; +// =================================================================== +// = UnoControlTabPageContainer +// =================================================================== +typedef ::cppu::AggImplInheritanceHelper1 < ControlContainerBase + , ::com::sun::star::awt::tab::XTabPageContainer + > UnoControlTabPageContainer_Base; +class UnoControlTabPageContainer : public UnoControlTabPageContainer_Base +{ +public: + UnoControlTabPageContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); + ::rtl::OUString GetComponentServiceName(); + + // ::com::sun::star::lang::XComponent + void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException); + + // ::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); + + // ::com::sun::star::awt::tab::XTabPageContainer + virtual ::sal_Int16 SAL_CALL getActiveTabPageID() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setActiveTabPageID( ::sal_Int16 _activetabpageid ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getTabPageCount( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL isTabPageActive( ::sal_Int16 tabPageIndex ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::tab::XTabPage > SAL_CALL getTabPage( ::sal_Int16 tabPageIndex ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::tab::XTabPage > SAL_CALL getTabPageByID( ::sal_Int16 tabPageID ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addTabPageListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tab::XTabPageContainerListener >& listener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeTabPageListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::tab::XTabPageContainerListener >& listener ) throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL addControl( const ::rtl::OUString& Name, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& Control ) throw (::com::sun::star::uno::RuntimeException); + // ::com::sun::star::lang::XServiceInfo + DECLIMPL_SERVICEINFO_DERIVED( UnoControlTabPageContainer, UnoControlBase, szServiceName_UnoControlTabPageContainer ) + +// using UnoControl::getPeer; +protected: + virtual void updateFromModel(); +private: + TabPageListenerMultiplexer m_aTabPageListeners; + sal_Int16 m_nActiveTabPageId; +}; + +#endif // _TOOLKIT_TABPAGE_CONTAINER_HXX diff --git a/toolkit/inc/toolkit/controls/tabpagemodel.hxx b/toolkit/inc/toolkit/controls/tabpagemodel.hxx new file mode 100644 index 000000000000..08938669fa58 --- /dev/null +++ b/toolkit/inc/toolkit/controls/tabpagemodel.hxx @@ -0,0 +1,146 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General 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_TABPAGE_MODEL_HXX +#define TOOLKIT_TABPAGE_MODEL_HXX + +#include <toolkit/controls/controlmodelcontainerbase.hxx> +#include <com/sun/star/awt/tab/XTabPageModel.hpp> +#include <com/sun/star/awt/tab/XTabPage.hpp> +#include <com/sun/star/resource/XStringResourceResolver.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include "toolkit/helper/servicenames.hxx" +#include "toolkit/helper/macros.hxx" +#include <toolkit/controls/unocontrolcontainer.hxx> +#include <cppuhelper/basemutex.hxx> +#include <list> +#include <cppuhelper/implbase2.hxx> + +// ---------------------------------------------------- +// class TabPageModel +// ---------------------------------------------------- +//typedef ::cppu::ImplHelper2< ::com::sun::star::awt::tab::XTabPageModel, +// ::com::sun::star::lang::XInitialization +// > TabPageAccess_BASE; +// +//class TabPageModel : public TabPageAccess_BASE +//{ +// +//private: +// bool m_bEnabled; +// ::rtl::OUString m_sTitle; +// ::rtl::OUString m_sImageURL; +// ::rtl::OUString m_sTooltip; +// sal_Int16 m_nTabPageId; +// +//public: +// TabPageModel(); +// explicit TabPageModel( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xCompContext); +// ~TabPageModel(); +// +// // XInitialization +// virtual void SAL_CALL initialize (const com::sun::star::uno::Sequence<com::sun::star::uno::Any>& rArguments) +// throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); +// +// ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); +// void SAL_CALL acquire() throw() { OWeakAggObject::acquire(); } +// void SAL_CALL release() throw() { OWeakAggObject::release(); } +// +// // ::com::sun::star::lang::XTypeProvider +// //::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw(::com::sun::star::uno::RuntimeException); +// //::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException); +// +// // ::com::sun::star::awt::tab::XTabPageModel +// virtual ::sal_Int16 SAL_CALL getTabPageID() throw (::com::sun::star::uno::RuntimeException); +// virtual ::sal_Bool SAL_CALL getEnabled() throw (::com::sun::star::uno::RuntimeException); +// virtual void SAL_CALL setEnabled( ::sal_Bool _enabled ) throw (::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& _title ) throw (::com::sun::star::uno::RuntimeException); +// virtual ::rtl::OUString SAL_CALL getImageURL() throw (::com::sun::star::uno::RuntimeException); +// virtual void SAL_CALL setImageURL( const ::rtl::OUString& _imageurl ) throw (::com::sun::star::uno::RuntimeException); +// virtual ::rtl::OUString SAL_CALL getTooltip() throw (::com::sun::star::uno::RuntimeException); +// virtual void SAL_CALL setTooltip( const ::rtl::OUString& _tooltip ) throw (::com::sun::star::uno::RuntimeException); +//}; +// ---------------------------------------------------- +// class UnoControlTabPageModel +// ---------------------------------------------------- + +class UnoControlTabPageModel : public ControlModelContainerBase + //public TabPageModel +{ +protected: + ::com::sun::star::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const; + ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); +public: + UnoControlTabPageModel( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > const & i_factory); + + // ::com::sun::star::io::XPersistObject + ::rtl::OUString SAL_CALL getServiceName() 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); + // XInitialization + virtual void SAL_CALL initialize (const com::sun::star::uno::Sequence<com::sun::star::uno::Any>& rArguments) + throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException); + + // XServiceInfo + DECLIMPL_SERVICEINFO_DERIVED( UnoControlTabPageModel, ControlModelContainerBase, szServiceName_UnoControlTabPageModel ) + +}; + +// ---------------------------------------------------- +// class UnoTabPageControl +// ---------------------------------------------------- +typedef ::cppu::AggImplInheritanceHelper2 < ControlContainerBase + , ::com::sun::star::awt::tab::XTabPage + , ::com::sun::star::awt::XWindowListener + > UnoControlTabPage_Base; +class UnoControlTabPage : public UnoControlTabPage_Base +{ +private: + bool m_bWindowListener; +public: + + UnoControlTabPage( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); + ~UnoControlTabPage(); + ::rtl::OUString GetComponentServiceName(); + + 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); + void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); + void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::awt::XWindowListener + virtual void SAL_CALL windowResized( const ::com::sun::star::awt::WindowEvent& e ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL windowMoved( const ::com::sun::star::awt::WindowEvent& e ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL windowShown( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL windowHidden( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException); + // ::com::sun::star::lang::XServiceInfo + DECLIMPL_SERVICEINFO( UnoControlTabPage, szServiceName_UnoControlTabPage) +}; + +#endif // TOOLKIT_TABPAGE_MODEL_HXX diff --git a/toolkit/inc/toolkit/controls/tkscrollbar.hxx b/toolkit/inc/toolkit/controls/tkscrollbar.hxx index 3cd3427345b4..d51dceef32c2 100644 --- a/toolkit/inc/toolkit/controls/tkscrollbar.hxx +++ b/toolkit/inc/toolkit/controls/tkscrollbar.hxx @@ -51,7 +51,7 @@ namespace toolkit ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); public: - UnoControlScrollBarModel(); + UnoControlScrollBarModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); UnoControlScrollBarModel( const UnoControlScrollBarModel& rModel ) : UnoControlModel( rModel ) {;} UnoControlModel* Clone() const { return new UnoControlScrollBarModel( *this ); } @@ -77,7 +77,7 @@ namespace toolkit AdjustmentListenerMultiplexer maAdjustmentListeners; public: - UnoScrollBarControl(); + UnoScrollBarControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); ::rtl::OUString GetComponentServiceName(); ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) { return UnoControlBase::queryInterface(rType); } diff --git a/toolkit/inc/toolkit/controls/tksimpleanimation.hxx b/toolkit/inc/toolkit/controls/tksimpleanimation.hxx index cddaffb01e6f..944d9cfcb1fe 100644 --- a/toolkit/inc/toolkit/controls/tksimpleanimation.hxx +++ b/toolkit/inc/toolkit/controls/tksimpleanimation.hxx @@ -52,7 +52,7 @@ namespace toolkit ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); public: - UnoSimpleAnimationControlModel(); + UnoSimpleAnimationControlModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); UnoSimpleAnimationControlModel( const UnoSimpleAnimationControlModel& rModel ) : UnoControlModel( rModel ) {;} UnoControlModel* Clone() const { return new UnoSimpleAnimationControlModel( *this ); } @@ -72,28 +72,18 @@ namespace toolkit //= UnoSimpleAnimationControl //==================================================================== - typedef ::cppu::ImplHelper1 < ::com::sun::star::awt::XSimpleAnimation - > UnoSimpleAnimationControl_Base; + typedef ::cppu::AggImplInheritanceHelper1 < UnoControlBase + , ::com::sun::star::awt::XSimpleAnimation + > UnoSimpleAnimationControl_Base; - class UnoSimpleAnimationControl :public UnoControlBase - ,public UnoSimpleAnimationControl_Base + class UnoSimpleAnimationControl : public UnoSimpleAnimationControl_Base { private: public: - UnoSimpleAnimationControl(); + UnoSimpleAnimationControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); ::rtl::OUString GetComponentServiceName(); - DECLARE_UNO3_AGG_DEFAULTS( UnoSimpleAnimationControl, UnoControlBase ); - ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); - - 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); - void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException) { UnoControlBase::disposing( Source ); } - void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException); - - // XTypeProvider - DECLARE_XTYPEPROVIDER() - // XSimpleAnimation virtual void SAL_CALL start() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL stop() throw (::com::sun::star::uno::RuntimeException); diff --git a/toolkit/inc/toolkit/controls/tkspinbutton.hxx b/toolkit/inc/toolkit/controls/tkspinbutton.hxx index 645540be002c..6be8c21e0d0d 100644 --- a/toolkit/inc/toolkit/controls/tkspinbutton.hxx +++ b/toolkit/inc/toolkit/controls/tkspinbutton.hxx @@ -52,7 +52,7 @@ namespace toolkit ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); public: - UnoSpinButtonModel(); + UnoSpinButtonModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); UnoSpinButtonModel( const UnoSpinButtonModel& rModel ) : UnoControlModel( rModel ) {;} UnoControlModel* Clone() const { return new UnoSpinButtonModel( *this ); } @@ -83,7 +83,7 @@ namespace toolkit AdjustmentListenerMultiplexer maAdjustmentListeners; public: - UnoSpinButtonControl(); + UnoSpinButtonControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); ::rtl::OUString GetComponentServiceName(); DECLARE_UNO3_AGG_DEFAULTS( UnoSpinButtonControl, UnoControlBase ); diff --git a/toolkit/inc/toolkit/controls/tkthrobber.hxx b/toolkit/inc/toolkit/controls/tkthrobber.hxx index 9e9b25914bda..0add98c51b85 100644 --- a/toolkit/inc/toolkit/controls/tkthrobber.hxx +++ b/toolkit/inc/toolkit/controls/tkthrobber.hxx @@ -52,7 +52,7 @@ namespace toolkit ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); public: - UnoThrobberControlModel(); + UnoThrobberControlModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); UnoThrobberControlModel( const UnoThrobberControlModel& rModel ) : UnoControlModel( rModel ) {;} UnoControlModel* Clone() const { return new UnoThrobberControlModel( *this ); } @@ -81,7 +81,7 @@ namespace toolkit private: public: - UnoThrobberControl(); + UnoThrobberControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); ::rtl::OUString GetComponentServiceName(); DECLARE_UNO3_AGG_DEFAULTS( UnoThrobberControl, UnoControlBase ); diff --git a/toolkit/inc/toolkit/controls/unocontrol.hxx b/toolkit/inc/toolkit/controls/unocontrol.hxx index 5b2f9a894b94..d7d141148771 100644 --- a/toolkit/inc/toolkit/controls/unocontrol.hxx +++ b/toolkit/inc/toolkit/controls/unocontrol.hxx @@ -48,6 +48,7 @@ #include <cppuhelper/interfacecontainer.hxx> #include <cppuhelper/weakref.hxx> #include <cppuhelper/implbase9.hxx> +#include <comphelper/componentcontext.hxx> #include <com/sun/star/util/XModeChangeBroadcaster.hpp> #include <com/sun/star/awt/XVclWindowPeer.hpp> @@ -94,6 +95,7 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::awt::XVclWindowPeer > mxVclWindowPeer; // just to avoid the query_interface thing protected: + const ::comphelper::ComponentContext maContext; EventListenerMultiplexer maDisposeListeners; WindowListenerMultiplexer maWindowListeners; FocusListenerMultiplexer maFocusListeners; @@ -143,8 +145,11 @@ protected: virtual sal_Bool requiresNewPeer( const ::rtl::OUString& _rPropertyName ) const; -public: +protected: UnoControl(); + +public: + UnoControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); ~UnoControl(); UnoControlComponentInfos& GetComponentInfos() { return maComponentInfos; } diff --git a/toolkit/inc/toolkit/controls/unocontrolbase.hxx b/toolkit/inc/toolkit/controls/unocontrolbase.hxx index 2d21f3f82c84..aa2036935344 100644 --- a/toolkit/inc/toolkit/controls/unocontrolbase.hxx +++ b/toolkit/inc/toolkit/controls/unocontrolbase.hxx @@ -40,6 +40,14 @@ class TOOLKIT_DLLPUBLIC UnoControlBase : public UnoControl { protected: + UnoControlBase(); + +protected: + UnoControlBase( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ) + :UnoControl( i_factory ) + { + } + sal_Bool ImplHasProperty( sal_uInt16 nProp ); sal_Bool ImplHasProperty( const ::rtl::OUString& aPropertyName ); void ImplSetPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue, sal_Bool bUpdateThis ); diff --git a/toolkit/inc/toolkit/controls/unocontrolcontainer.hxx b/toolkit/inc/toolkit/controls/unocontrolcontainer.hxx index d2b225d23411..e29fab5b8350 100644 --- a/toolkit/inc/toolkit/controls/unocontrolcontainer.hxx +++ b/toolkit/inc/toolkit/controls/unocontrolcontainer.hxx @@ -65,8 +65,9 @@ protected: void ImplActivateTabControllers(); public: - UnoControlContainer(); - UnoControlContainer( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xPeer ); + UnoControlContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); + UnoControlContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory, + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& xPeer ); ~UnoControlContainer(); diff --git a/toolkit/inc/toolkit/controls/unocontrolcontainermodel.hxx b/toolkit/inc/toolkit/controls/unocontrolcontainermodel.hxx index 21a338a0f2a7..8d4d97836989 100644 --- a/toolkit/inc/toolkit/controls/unocontrolcontainermodel.hxx +++ b/toolkit/inc/toolkit/controls/unocontrolcontainermodel.hxx @@ -46,7 +46,7 @@ protected: ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); public: - UnoControlContainerModel(); + UnoControlContainerModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); UnoControlContainerModel( const UnoControlContainerModel& rModel ) : UnoControlModel( rModel ) {;} UnoControlModel* Clone() const { return new UnoControlContainerModel( *this ); } diff --git a/toolkit/inc/toolkit/controls/unocontrolmodel.hxx b/toolkit/inc/toolkit/controls/unocontrolmodel.hxx index e46780b3b052..7aba0ec710ee 100644 --- a/toolkit/inc/toolkit/controls/unocontrolmodel.hxx +++ b/toolkit/inc/toolkit/controls/unocontrolmodel.hxx @@ -45,6 +45,9 @@ #include <cppuhelper/propshlp.hxx> #include <cppuhelper/interfacecontainer.hxx> +#include <cppuhelper/implbase7.hxx> +#include <comphelper/componentcontext.hxx> +#include <comphelper/uno3.hxx> #include <list> @@ -54,21 +57,25 @@ class ImplPropertyTable; // class UnoControlModel // ---------------------------------------------------- -class TOOLKIT_DLLPUBLIC UnoControlModel : public ::com::sun::star::awt::XControlModel, - public ::com::sun::star::beans::XPropertyState, - public ::com::sun::star::io::XPersistObject, - public ::com::sun::star::lang::XComponent, - public ::com::sun::star::lang::XServiceInfo, - public ::com::sun::star::lang::XTypeProvider, - public ::com::sun::star::lang::XUnoTunnel, - public ::com::sun::star::util::XCloneable, - public MutexAndBroadcastHelper, - public ::cppu::OPropertySetHelper, - public ::cppu::OWeakAggObject +typedef ::cppu::WeakAggImplHelper7 < ::com::sun::star::awt::XControlModel + , ::com::sun::star::beans::XPropertyState + , ::com::sun::star::io::XPersistObject + , ::com::sun::star::lang::XComponent + , ::com::sun::star::lang::XServiceInfo + , ::com::sun::star::lang::XUnoTunnel + , ::com::sun::star::util::XCloneable + > UnoControlModel_Base; + +class TOOLKIT_DLLPUBLIC UnoControlModel :public UnoControlModel_Base + ,public MutexAndBroadcastHelper + ,public ::cppu::OPropertySetHelper { private: - ImplPropertyTable* mpData; - EventListenerMultiplexer maDisposeListeners; + ImplPropertyTable* mpData; + EventListenerMultiplexer maDisposeListeners; + +protected: + const ::comphelper::ComponentContext maContext; protected: void ImplRegisterProperty( sal_uInt16 nPropType ); @@ -100,18 +107,21 @@ protected: sal_Int32 _nSecondHandle /// second handle, which should supersede _nFirstHandle in the sequence ) const; -public: +protected: UnoControlModel(); +public: + UnoControlModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); UnoControlModel( const UnoControlModel& rModel ); ~UnoControlModel(); virtual UnoControlModel* Clone() const = 0; - // ::com::sun::star::uno::XAggregation + // ::com::sun::star::uno::XInterface ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) { return OWeakAggObject::queryInterface(rType); } - void SAL_CALL acquire() throw() { OWeakAggObject::acquire(); } - void SAL_CALL release() throw() { OWeakAggObject::release(); } + void SAL_CALL acquire() throw(); + void SAL_CALL release() throw(); + // ::com::sun::star::uno::XAggregation ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); // ::com::sun::star::lang::XUnoTunnel @@ -123,10 +133,7 @@ public: ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone() throw(::com::sun::star::uno::RuntimeException); // ::com::sun::star::lang::XTypeProvider - ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw(::com::sun::star::uno::RuntimeException); - ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException); - - // ::com::sun::star::awt::XControlModel + DECLARE_XTYPEPROVIDER() // ::com::sun::star::lang::XComponent void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException); diff --git a/toolkit/inc/toolkit/controls/unocontrols.hxx b/toolkit/inc/toolkit/controls/unocontrols.hxx index 531467f359be..7c928ded5485 100644 --- a/toolkit/inc/toolkit/controls/unocontrols.hxx +++ b/toolkit/inc/toolkit/controls/unocontrols.hxx @@ -93,7 +93,7 @@ protected: ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); public: - UnoControlEditModel(); + UnoControlEditModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); UnoControlEditModel( const UnoControlEditModel& rModel ) : UnoControlModel( rModel ) {;} UnoControlModel* Clone() const { return new UnoControlEditModel( *this ); } @@ -127,7 +127,7 @@ private: // They only support XTextComponent, so keep the text // here, maybe there is no Peer when calling setText()... ::rtl::OUString maText; - USHORT mnMaxTextLen; + sal_uInt16 mnMaxTextLen; sal_Bool mbSetTextInPeer; sal_Bool mbSetMaxTextLenInPeer; @@ -135,7 +135,7 @@ private: public: - UnoEditControl(); + UnoEditControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); ::rtl::OUString GetComponentServiceName(); TextListenerMultiplexer& GetTextListeners() { return maTextListeners; } @@ -196,7 +196,7 @@ protected: ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); public: - UnoControlFileControlModel(); + UnoControlFileControlModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); UnoControlFileControlModel( const UnoControlFileControlModel& rModel ) : UnoControlModel( rModel ) {;} UnoControlModel* Clone() const { return new UnoControlFileControlModel( *this ); } @@ -217,7 +217,7 @@ public: class UnoFileControl : public UnoEditControl { public: - UnoFileControl(); + UnoFileControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); ::rtl::OUString GetComponentServiceName(); // ::com::sun::star::lang::XServiceInfo @@ -236,7 +236,12 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphicObject > mxGrfObj; protected: - GraphicControlModel() : mbAdjustingImagePosition( false ), mbAdjustingGraphic( false ) { } + GraphicControlModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ) + :UnoControlModel( i_factory ) + ,mbAdjustingImagePosition( false ) + ,mbAdjustingGraphic( false ) + { + } GraphicControlModel( const GraphicControlModel& _rSource ) : UnoControlModel( _rSource ), mbAdjustingImagePosition( false ), mbAdjustingGraphic( false ) { } // ::cppu::OPropertySetHelper @@ -252,14 +257,14 @@ private: // ---------------------------------------------------- // class UnoControlButtonModel // ---------------------------------------------------- -class UnoControlButtonModel : public GraphicControlModel +class UnoControlButtonModel : public GraphicControlModel { protected: ::com::sun::star::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const; ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); public: - UnoControlButtonModel(); + UnoControlButtonModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); UnoControlButtonModel( const UnoControlButtonModel& rModel ) : GraphicControlModel( rModel ) {;} UnoControlModel* Clone() const { return new UnoControlButtonModel( *this ); } @@ -292,7 +297,7 @@ private: public: - UnoButtonControl(); + UnoButtonControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); ::rtl::OUString GetComponentServiceName(); 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); @@ -337,7 +342,7 @@ protected: ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); public: - UnoControlImageControlModel(); + UnoControlImageControlModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); UnoControlImageControlModel( const UnoControlImageControlModel& rModel ) : GraphicControlModel( rModel ), mbAdjustingImageScaleMode( false ) { } UnoControlModel* Clone() const { return new UnoControlImageControlModel( *this ); } @@ -369,7 +374,7 @@ private: public: - UnoImageControlControl(); + UnoImageControlControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); ::rtl::OUString GetComponentServiceName(); void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException); @@ -397,7 +402,7 @@ protected: ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); public: - UnoControlRadioButtonModel(); + UnoControlRadioButtonModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); UnoControlRadioButtonModel( const UnoControlRadioButtonModel& rModel ) : GraphicControlModel( rModel ) {;} UnoControlModel* Clone() const { return new UnoControlRadioButtonModel( *this ); } @@ -431,7 +436,7 @@ private: public: - UnoRadioButtonControl(); + UnoRadioButtonControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); ::rtl::OUString GetComponentServiceName(); 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); @@ -476,7 +481,7 @@ protected: ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); public: - UnoControlCheckBoxModel(); + UnoControlCheckBoxModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); UnoControlCheckBoxModel( const UnoControlCheckBoxModel& rModel ) : GraphicControlModel( rModel ) {;} UnoControlModel* Clone() const { return new UnoControlCheckBoxModel( *this ); } @@ -509,7 +514,7 @@ private: public: - UnoCheckBoxControl(); + UnoCheckBoxControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); ~UnoCheckBoxControl(){;} ::rtl::OUString GetComponentServiceName(); @@ -557,7 +562,7 @@ protected: ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); public: - UnoControlFixedHyperlinkModel(); + UnoControlFixedHyperlinkModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); UnoControlFixedHyperlinkModel( const UnoControlFixedHyperlinkModel& rModel ) : UnoControlModel( rModel ) {;} UnoControlModel* Clone() const { return new UnoControlFixedHyperlinkModel( *this ); } @@ -583,7 +588,7 @@ private: ActionListenerMultiplexer maActionListeners; public: - UnoFixedHyperlinkControl(); + UnoFixedHyperlinkControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); ::rtl::OUString GetComponentServiceName(); @@ -631,7 +636,7 @@ protected: ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); public: - UnoControlFixedTextModel(); + UnoControlFixedTextModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); UnoControlFixedTextModel( const UnoControlFixedTextModel& rModel ) : UnoControlModel( rModel ) {;} UnoControlModel* Clone() const { return new UnoControlFixedTextModel( *this ); } @@ -655,7 +660,7 @@ class UnoFixedTextControl : public UnoControlBase, public ::com::sun::star::awt::XLayoutConstrains { public: - UnoFixedTextControl(); + UnoFixedTextControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); ::rtl::OUString GetComponentServiceName(); ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) { return UnoControlBase::queryInterface(rType); } @@ -696,7 +701,7 @@ protected: ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); public: - UnoControlGroupBoxModel(); + UnoControlGroupBoxModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); UnoControlGroupBoxModel( const UnoControlGroupBoxModel& rModel ) : UnoControlModel( rModel ) {;} UnoControlModel* Clone() const { return new UnoControlGroupBoxModel( *this ); } @@ -718,7 +723,7 @@ public: class UnoGroupBoxControl : public UnoControlBase { public: - UnoGroupBoxControl(); + UnoGroupBoxControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); ::rtl::OUString GetComponentServiceName(); sal_Bool SAL_CALL isTransparent( ) throw(::com::sun::star::uno::RuntimeException); @@ -735,12 +740,20 @@ struct UnoControlListBoxModel_Data; typedef ::cppu::AggImplInheritanceHelper1 < UnoControlModel , ::com::sun::star::awt::XItemList > UnoControlListBoxModel_Base; -class TOOLKIT_DLLPUBLIC UnoControlListBoxModel :public UnoControlListBoxModel_Base +class TOOLKIT_DLLPUBLIC UnoControlListBoxModel : public UnoControlListBoxModel_Base { protected: - UnoControlListBoxModel(bool asComboBox); + enum ConstructorMode + { + ConstructDefault, + ConstructWithoutProperties + }; + public: - UnoControlListBoxModel(); + UnoControlListBoxModel( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory, + ConstructorMode const i_mode = ConstructDefault + ); UnoControlListBoxModel( const UnoControlListBoxModel& i_rSource ); ~UnoControlListBoxModel(); @@ -838,7 +851,7 @@ typedef ::cppu::AggImplInheritanceHelper5 < UnoControlBase class TOOLKIT_DLLPUBLIC UnoListBoxControl : public UnoListBoxControl_Base { public: - UnoListBoxControl(); + UnoListBoxControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); ::rtl::OUString GetComponentServiceName(); 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); @@ -918,7 +931,7 @@ protected: ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); public: - UnoControlComboBoxModel(); + UnoControlComboBoxModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); UnoControlComboBoxModel( const UnoControlComboBoxModel& rModel ) : UnoControlListBoxModel( rModel ) {;} UnoControlModel* Clone() const { return new UnoControlComboBoxModel( *this ); } @@ -952,7 +965,7 @@ private: public: - UnoComboBoxControl(); + UnoComboBoxControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); ::rtl::OUString GetComponentServiceName(); 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); @@ -1016,10 +1029,10 @@ class UnoSpinFieldControl : public UnoEditControl, { private: SpinListenerMultiplexer maSpinListeners; - BOOL mbRepeat; + sal_Bool mbRepeat; public: - UnoSpinFieldControl(); + UnoSpinFieldControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) { return UnoEditControl::queryInterface(rType); } ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); @@ -1057,7 +1070,7 @@ protected: ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); public: - UnoControlDateFieldModel(); + UnoControlDateFieldModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); UnoControlDateFieldModel( const UnoControlDateFieldModel& rModel ) : UnoControlModel( rModel ) {;} UnoControlModel* Clone() const { return new UnoControlDateFieldModel( *this ); } @@ -1084,7 +1097,7 @@ private: sal_Int32 mnLast; sal_Bool mbLongFormat; public: - UnoDateFieldControl(); + UnoDateFieldControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); ::rtl::OUString GetComponentServiceName(); ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) { return UnoSpinFieldControl::queryInterface(rType); } @@ -1133,7 +1146,7 @@ protected: ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); public: - UnoControlTimeFieldModel(); + UnoControlTimeFieldModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); UnoControlTimeFieldModel( const UnoControlTimeFieldModel& rModel ) : UnoControlModel( rModel ) {;} UnoControlModel* Clone() const { return new UnoControlTimeFieldModel( *this ); } @@ -1160,7 +1173,7 @@ private: sal_Int32 mnLast; public: - UnoTimeFieldControl(); + UnoTimeFieldControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); ::rtl::OUString GetComponentServiceName(); ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) { return UnoSpinFieldControl::queryInterface(rType); } @@ -1208,7 +1221,7 @@ protected: ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); public: - UnoControlNumericFieldModel(); + UnoControlNumericFieldModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); UnoControlNumericFieldModel( const UnoControlNumericFieldModel& rModel ) : UnoControlModel( rModel ) {;} UnoControlModel* Clone() const { return new UnoControlNumericFieldModel( *this ); } @@ -1235,7 +1248,7 @@ private: double mnLast; public: - UnoNumericFieldControl(); + UnoNumericFieldControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); ::rtl::OUString GetComponentServiceName(); ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) { return UnoSpinFieldControl::queryInterface(rType); } @@ -1285,7 +1298,7 @@ protected: ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); public: - UnoControlCurrencyFieldModel(); + UnoControlCurrencyFieldModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); UnoControlCurrencyFieldModel( const UnoControlCurrencyFieldModel& rModel ) : UnoControlModel( rModel ) {;} UnoControlModel* Clone() const { return new UnoControlCurrencyFieldModel( *this ); } @@ -1312,7 +1325,7 @@ private: double mnLast; public: - UnoCurrencyFieldControl(); + UnoCurrencyFieldControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); ::rtl::OUString GetComponentServiceName(); ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) { return UnoSpinFieldControl::queryInterface(rType); } @@ -1361,7 +1374,7 @@ protected: ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); public: - UnoControlPatternFieldModel(); + UnoControlPatternFieldModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); UnoControlPatternFieldModel( const UnoControlPatternFieldModel& rModel ) : UnoControlModel( rModel ) {;} UnoControlModel* Clone() const { return new UnoControlPatternFieldModel( *this ); } @@ -1387,7 +1400,7 @@ protected: void ImplSetPeerProperty( const ::rtl::OUString& rPropName, const ::com::sun::star::uno::Any& rVal ); public: - UnoPatternFieldControl(); + UnoPatternFieldControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); ::rtl::OUString GetComponentServiceName(); ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) { return UnoSpinFieldControl::queryInterface(rType); } @@ -1422,7 +1435,7 @@ protected: ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); public: - UnoControlProgressBarModel(); + UnoControlProgressBarModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); UnoControlProgressBarModel( const UnoControlProgressBarModel& rModel ) : UnoControlModel( rModel ) {;} UnoControlModel* Clone() const { return new UnoControlProgressBarModel( *this ); } @@ -1444,7 +1457,7 @@ class UnoProgressBarControl : public UnoControlBase, public ::com::sun::star::awt::XProgressBar { public: - UnoProgressBarControl(); + UnoProgressBarControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); ::rtl::OUString GetComponentServiceName(); ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) { return UnoControlBase::queryInterface(rType); } @@ -1478,7 +1491,7 @@ protected: ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); public: - UnoControlFixedLineModel(); + UnoControlFixedLineModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); UnoControlFixedLineModel( const UnoControlFixedLineModel& rModel ) : UnoControlModel( rModel ) {;} UnoControlModel* Clone() const { return new UnoControlFixedLineModel( *this ); } @@ -1500,7 +1513,7 @@ public: class UnoFixedLineControl : public UnoControlBase { public: - UnoFixedLineControl(); + UnoFixedLineControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); ::rtl::OUString GetComponentServiceName(); sal_Bool SAL_CALL isTransparent( ) throw(::com::sun::star::uno::RuntimeException); @@ -1511,6 +1524,7 @@ public: }; + #endif // _TOOLKIT_HELPER_UNOCONTROLS_HXX_ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/toolkit/helper/listenermultiplexer.hxx b/toolkit/inc/toolkit/helper/listenermultiplexer.hxx index ac38197bc5f1..46de6c4ad8d5 100644 --- a/toolkit/inc/toolkit/helper/listenermultiplexer.hxx +++ b/toolkit/inc/toolkit/helper/listenermultiplexer.hxx @@ -57,6 +57,7 @@ #include <toolkit/helper/mutexhelper.hxx> #include <toolkit/helper/macros.hxx> #include <com/sun/star/awt/grid/XGridSelectionListener.hpp> +#include <com/sun/star/awt/tab/XTabPageContainerListener.hpp> // ---------------------------------------------------- // class ListenerMultiplexerBase // ---------------------------------------------------- @@ -264,6 +265,13 @@ DECL_LISTENERMULTIPLEXER_START_DLLPUB( SelectionListenerMultiplexer, ::com::sun: void SAL_CALL selectionChanged( const ::com::sun::star::awt::grid::GridSelectionEvent& aEvent ) throw (::com::sun::star::uno::RuntimeException); DECL_LISTENERMULTIPLEXER_END +// ---------------------------------------------------- +// class TabPageListenerMultiplexer +// ---------------------------------------------------- +DECL_LISTENERMULTIPLEXER_START_DLLPUB( TabPageListenerMultiplexer, ::com::sun::star::awt::tab::XTabPageContainerListener ) + void SAL_CALL tabPageActivated( const ::com::sun::star::awt::tab::TabPageActivatedEvent& aEvent ) throw (::com::sun::star::uno::RuntimeException); +DECL_LISTENERMULTIPLEXER_END + #endif // _TOOLKIT_HELPER_LISTENERMULTIPLEXER_HXX_ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/toolkit/helper/mutexandbroadcasthelper.hxx b/toolkit/inc/toolkit/helper/mutexandbroadcasthelper.hxx index f9d5eec31a2b..4bc4d4d59825 100644 --- a/toolkit/inc/toolkit/helper/mutexandbroadcasthelper.hxx +++ b/toolkit/inc/toolkit/helper/mutexandbroadcasthelper.hxx @@ -40,19 +40,13 @@ class MutexAndBroadcastHelper public: MutexAndBroadcastHelper() : BrdcstHelper( Mutex ) {} - ::osl::Mutex Mutex; ::cppu::OBroadcastHelper BrdcstHelper; ::osl::Mutex& GetMutex() { return Mutex; } - + ::cppu::OBroadcastHelper& GetBroadcastHelper() { return BrdcstHelper; } }; - - - - - #endif // _TOOLKIT_HELPER_MUTEXANDBROADCASTHELPER_HXX diff --git a/toolkit/inc/toolkit/helper/property.hxx b/toolkit/inc/toolkit/helper/property.hxx index 9b077cab2709..dd4bdd1f7d40 100644 --- a/toolkit/inc/toolkit/helper/property.hxx +++ b/toolkit/inc/toolkit/helper/property.hxx @@ -178,7 +178,7 @@ namespace rtl { #define BASEPROPERTY_TREE_ROOTDISPLAYED 127 #define BASEPROPERTY_TREE_SHOWSHANDLES 128 #define BASEPROPERTY_TREE_SHOWSROOTHANDLES 129 -#define BASEPROPERTY_TREE_ROWHEIGHT 130 +#define BASEPROPERTY_ROW_HEIGHT 130 #define BASEPROPERTY_TREE_INVOKESSTOPNODEEDITING 131 #define BASEPROPERTY_TREE_END 131 #define BASEPROPERTY_DIALOGSOURCEURL 132 @@ -198,15 +198,19 @@ namespace rtl { #define BASEPROPERTY_REFERENCE_DEVICE 146 #define BASEPROPERTY_HIGHCONTRASTMODE 147 -#define BASEPROPERTY_GRID_EVEN_ROW_BACKGROUND 148 -#define BASEPROPERTY_GRID_HEADER_BACKGROUND 149 -#define BASEPROPERTY_GRID_LINE_COLOR 150 -#define BASEPROPERTY_GRID_ROW_BACKGROUND 151 +#define BASEPROPERTY_GRID_HEADER_BACKGROUND 148 +#define BASEPROPERTY_GRID_HEADER_TEXT_COLOR 149 +#define BASEPROPERTY_GRID_ROW_BACKGROUND_COLORS 150 +#define BASEPROPERTY_GRID_LINE_COLOR 151 #define BASEPROPERTY_MULTISELECTION_SIMPLEMODE 152 #define BASEPROPERTY_ITEM_SEPARATOR_POS 153 #define BASEPROPERTY_GROUPNAME 154 // ::rtl::OUString #define BASEPROPERTY_MULTIPAGEVALUE 155 // sal_Int32 #define BASEPROPERTY_USERFORMCONTAINEES 156 // css::container::XNameContainer +#define BASEPROPERTY_AUTO_REPEAT 157 +#define BASEPROPERTY_ROW_HEADER_WIDTH 158 +#define BASEPROPERTY_COLUMN_HEADER_HEIGHT 159 +#define BASEPROPERTY_USE_GRID_LINES 160 // Keine gebundenen Properties, werden immer aus der Property BASEPROPERTY_FONTDESCRIPTOR entnommen. diff --git a/toolkit/inc/toolkit/helper/servicenames.hxx b/toolkit/inc/toolkit/helper/servicenames.hxx index 0a98bdf4bb25..b0ce59b05d02 100644 --- a/toolkit/inc/toolkit/helper/servicenames.hxx +++ b/toolkit/inc/toolkit/helper/servicenames.hxx @@ -104,13 +104,24 @@ extern const sal_Char szServiceName_GridControlModel[]; extern const sal_Char szServiceName_DefaultGridDataModel[]; extern const sal_Char szServiceName_DefaultGridColumnModel[]; extern const sal_Char szServiceName_GridColumn[]; +extern const sal_Char __FAR_DATA szServiceName_SortableGridDataModel[]; extern const sal_Char szServiceName_UnoSimpleAnimationControl[], szServiceName2_UnoSimpleAnimationControl[]; extern const sal_Char szServiceName_UnoSimpleAnimationControlModel[], szServiceName2_UnoSimpleAnimationControlModel[]; extern const sal_Char szServiceName_UnoThrobberControl[], szServiceName2_UnoThrobberControl[]; extern const sal_Char szServiceName_UnoThrobberControlModel[], szServiceName2_UnoThrobberControlModel[]; +extern const sal_Char szServiceName_AnimatedImagesControl[]; +extern const sal_Char szServiceName_AnimatedImagesControlModel[]; +extern const sal_Char szServiceName_SpinningProgressControlModel[]; extern const sal_Char szServiceName_UnoControlFixedHyperlink[], szServiceName_UnoControlFixedHyperlinkModel[]; +extern const sal_Char szServiceName_UnoControlTabPageModel[], szServiceName2_UnoControlTabPageModel[]; +extern const sal_Char szServiceName_UnoControlTabPage[]; +extern const sal_Char szServiceName_UnoControlTabPageContainerModel[]; +extern const sal_Char szServiceName_UnoControlTabPageContainer[]; + +// ExtUnoWrapper: +extern const char szServiceName_ImageProducer[], szServiceName2_ImageProducer[]; #endif // _TOOLKIT_HELPER_SERVICENAMES_HXX_ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/toolkit/helper/throbberimpl.hxx b/toolkit/inc/toolkit/helper/throbberimpl.hxx deleted file mode 100644 index b2c7a5771f78..000000000000 --- a/toolkit/inc/toolkit/helper/throbberimpl.hxx +++ /dev/null @@ -1,87 +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. - * - ************************************************************************/ - -#ifndef _TOOLKIT_HELPER_THROBBERIMPL_HXX_ -#define _TOOLKIT_HELPER_THROBBERIMPL_HXX_ - -#include <toolkit/awt/vclxwindow.hxx> -#include <com/sun/star/uno/Reference.hxx> - -#include <com/sun/star/graphic/XGraphic.hpp> -#include <vcl/timer.hxx> -#include <osl/mutex.hxx> - -//........................................................................ -namespace toolkit -//........................................................................ -{ -#define CSS_UNO ::com::sun::star::uno -#define CSS_GRAPHIC ::com::sun::star::graphic - - class Throbber_Impl - { - private: - CSS_UNO::Sequence< CSS_UNO::Reference< CSS_GRAPHIC::XGraphic > > maImageList; - CSS_UNO::Reference< VCLXWindow > mxParent; - - sal_Bool mbRepeat; - sal_Int32 mnStepTime; - sal_Int32 mnCurStep; - sal_Int32 mnStepCount; - AutoTimer maWaitTimer; - - DECL_LINK( TimeOutHdl, Throbber_Impl* ); - - public: - Throbber_Impl( CSS_UNO::Reference< VCLXWindow > xParent, - sal_Int32 nStepTime, - sal_Bool bRepeat ); - ~Throbber_Impl(); - - // Properties - void setStepTime( sal_Int32 nStepTime ) { mnStepTime = nStepTime; } - void setRepeat( sal_Bool bRepeat ) { mbRepeat = bRepeat; } - - // XSimpleAnimation - void start() throw ( CSS_UNO::RuntimeException ); - void stop() throw ( CSS_UNO::RuntimeException ); - void setImageList( const CSS_UNO::Sequence< CSS_UNO::Reference< CSS_GRAPHIC::XGraphic > >& ImageList ) - throw ( CSS_UNO::RuntimeException ); - // Helpers - void initImage() throw ( CSS_UNO::RuntimeException ); - }; -//........................................................................ -#undef CSS_UNO -#undef CSS_GRAPHIC - -} // namespacetoolkit -//........................................................................ - -#endif //_TOOLKIT_HELPER_THROBBERIMPL_HXX_ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/inc/toolkit/helper/tkresmgr.hxx b/toolkit/inc/toolkit/helper/tkresmgr.hxx index 9d04fab909b4..17c65919bdc0 100644 --- a/toolkit/inc/toolkit/helper/tkresmgr.hxx +++ b/toolkit/inc/toolkit/helper/tkresmgr.hxx @@ -71,6 +71,7 @@ public: // loads the image with the specified resource id static Image loadImage( sal_uInt16 nResId ); + static Image getImageFromURL( const ::rtl::OUString& i_rImageURL ); }; diff --git a/toolkit/inc/toolkit/helper/unowrapper.hxx b/toolkit/inc/toolkit/helper/unowrapper.hxx index 75bb4b6dcab9..0518768bf952 100644 --- a/toolkit/inc/toolkit/helper/unowrapper.hxx +++ b/toolkit/inc/toolkit/helper/unowrapper.hxx @@ -67,11 +67,11 @@ public: void WindowDestroyed( Window* pWindow ); void WindowEvent_Move( Window* pWindow ); void WindowEvent_Resize( Window* pWindow ); - void WindowEvent_Show( Window* pWindow, BOOL bShow ); + void WindowEvent_Show( Window* pWindow, sal_Bool bShow ); void WindowEvent_Close( Window* pWindow ); void WindowEvent_Minimize( Window* pWindow ); void WindowEvent_Normalize( Window* pWindow ); - void WindowEvent_Activate( Window* pWindow, BOOL bActivated ); + void WindowEvent_Activate( Window* pWindow, sal_Bool bActivated ); void WindowEvent_MouseButtonUp( Window* pWindow, const MouseEvent& rEvt ); void WindowEvent_MouseButtonDown( Window* pWindow, const MouseEvent& rEvt ); void WindowEvent_MouseMove( Window* pWindow, const MouseEvent& rEvt ); diff --git a/toolkit/inc/toolkit/helper/vclunohelper.hxx b/toolkit/inc/toolkit/helper/vclunohelper.hxx index fafff3fc07dc..ba8844eb277c 100644 --- a/toolkit/inc/toolkit/helper/vclunohelper.hxx +++ b/toolkit/inc/toolkit/helper/vclunohelper.hxx @@ -65,8 +65,8 @@ namespace com { namespace sun { namespace star { namespace awt { #include <vcl/bitmapex.hxx> #include <vcl/region.hxx> #include <vcl/metric.hxx> -#include <vcl/mapunit.hxx> -#include <vcl/fldunit.hxx> +#include <tools/mapunit.hxx> +#include <tools/fldunit.hxx> #include <tools/poly.hxx> class Window; diff --git a/toolkit/prj/build.lst b/toolkit/prj/build.lst index 126eea24c66c..e11d32c435bf 100644 --- a/toolkit/prj/build.lst +++ b/toolkit/prj/build.lst @@ -1,14 +1,3 @@ -ti toolkit : vcl NULL -ti toolkit usr1 - all ti_mkout NULL -ti toolkit\prj get - all ti_prj NULL -ti toolkit\inc nmake - all ti_inc NULL -ti toolkit\uiconfig\layout nmake - all ti_uiconfig_layout NULL -ti toolkit\source\helper nmake - all ti_helper ti_inc NULL -ti toolkit\source\awt nmake - all ti_awt ti_inc NULL -ti toolkit\source\controls nmake - all ti_controls ti_inc NULL -ti toolkit\source\controls\tree nmake - all ti_tree NULL -ti toolkit\source\controls\grid nmake - all ti_grid NULL -ti toolkit\source\layout\core nmake - all ti_layout_core NULL -ti toolkit\source\layout\vcl nmake - all ti_layout_vcl NULL -ti toolkit\util nmake - all ti_util ti_awt ti_controls ti_layout_core ti_helper ti_tree ti_grid ti_layout_vcl NULL -ti toolkit\qa\unoapi nmake - all ti_qa_unoapi NULL +ti toolkit : LIBXSLT:libxslt vcl qadevOOo test NULL +ti toolkit\prj nmake - all ti_prj NULL +ti toolkit\qa\complex\toolkit nmake - all ti_complex_toolkit NULL diff --git a/toolkit/prj/d.lst b/toolkit/prj/d.lst index 375485c96e4d..e69de29bb2d1 100644 --- a/toolkit/prj/d.lst +++ b/toolkit/prj/d.lst @@ -1,65 +0,0 @@ -mkdir: %COMMON_DEST%\bin%_EXT%\hid -mkdir: %_DEST%\inc%_EXT%\toolkit -mkdir: %_DEST%\inc%_EXT%\toolkit\helper -mkdir: %_DEST%\inc%_EXT%\toolkit\awt -mkdir: %_DEST%\inc%_EXT%\toolkit\controls - -..\%COMMON_OUTDIR%\misc\*.hid %COMMON_DEST%\bin%_EXT%\hid\*.hid -..\%__SRC%\lib\itk.lib %_DEST%\lib%_EXT%\itk.lib -..\%__SRC%\lib\lib*.so %_DEST%\lib%_EXT% -..\%__SRC%\lib\*.sl %_DEST%\lib%_EXT%\*.sl -..\%__SRC%\lib\*.a %_DEST%\lib%_EXT%\*.a -..\%__SRC%\lib\*.dylib %_DEST%\lib%_EXT%\*.dylib -..\%__SRC%\bin\tk*.res %_DEST%\bin%_EXT%\tk*res -..\%__SRC%\bin\tk?????.sym %_DEST%\bin%_EXT%\tk?????.sym -..\%__SRC%\bin\tk?????.dll %_DEST%\bin%_EXT%\tk?????.dll -..\%__SRC%\misc\tk?????.map %_DEST%\bin%_EXT%\tk?????.map - -..\util\toolkit.xml %_DEST%\xml%_EXT%\toolkit.xml - -..\inc\toolkit\awt\vclxaccessiblecomponent.hxx %_DEST%\inc%_EXT%\toolkit\awt\vclxaccessiblecomponent.hxx -..\inc\toolkit\awt\vclxcontainer.hxx %_DEST%\inc%_EXT%\toolkit\awt\vclxcontainer.hxx -..\inc\toolkit\awt\vclxdevice.hxx %_DEST%\inc%_EXT%\toolkit\awt\vclxdevice.hxx -..\inc\toolkit\awt\vclxfont.hxx %_DEST%\inc%_EXT%\toolkit\awt\vclxfont.hxx -..\inc\toolkit\awt\vclxtopwindow.hxx %_DEST%\inc%_EXT%\toolkit\awt\vclxtopwindow.hxx -..\inc\toolkit\awt\vclxtoolkit.hxx %_DEST%\inc%_EXT%\toolkit\awt\vclxtoolkit.hxx -..\inc\toolkit\awt\vclxwindow.hxx %_DEST%\inc%_EXT%\toolkit\awt\vclxwindow.hxx -..\inc\toolkit\awt\vclxsystemdependentwindow.hxx %_DEST%\inc%_EXT%\toolkit\awt\vclxsystemdependentwindow.hxx -..\source\awt\vclxdialog.hxx %_DEST%\inc%_EXT%\toolkit\awt\vclxdialog.hxx -..\inc\toolkit\awt\vclxwindows.hxx %_DEST%\inc%_EXT%\toolkit\awt\vclxwindows.hxx -..\inc\toolkit\awt\vclxmenu.hxx %_DEST%\inc%_EXT%\toolkit\awt\vclxmenu.hxx - -..\inc\toolkit\controls\unocontrol.hxx %_DEST%\inc%_EXT%\toolkit\controls\unocontrol.hxx -..\inc\toolkit\controls\unocontrols.hxx %_DEST%\inc%_EXT%\toolkit\controls\unocontrols.hxx -..\inc\toolkit\controls\unocontrolmodel.hxx %_DEST%\inc%_EXT%\toolkit\controls\unocontrolmodel.hxx -..\inc\toolkit\controls\unocontrolbase.hxx %_DEST%\inc%_EXT%\toolkit\controls\unocontrolbase.hxx -..\inc\toolkit\helper\servicenames.hxx %_DEST%\inc%_EXT%\toolkit\helper\servicenames.hxx - -..\inc\toolkit\helper\emptyfontdescriptor.hxx %_DEST%\inc%_EXT%\toolkit\helper\emptyfontdescriptor.hxx -..\inc\toolkit\helper\vclunohelper.hxx %_DEST%\inc%_EXT%\toolkit\helper\vclunohelper.hxx -..\inc\toolkit\helper\convert.hxx %_DEST%\inc%_EXT%\toolkit\helper\convert.hxx -..\inc\toolkit\helper\property.hxx %_DEST%\inc%_EXT%\toolkit\helper\property.hxx -..\inc\toolkit\helper\macros.hxx %_DEST%\inc%_EXT%\toolkit\helper\macros.hxx -..\inc\toolkit\helper\mutexhelper.hxx %_DEST%\inc%_EXT%\toolkit\helper\mutexhelper.hxx -..\inc\toolkit\helper\mutexandbroadcasthelper.hxx %_DEST%\inc%_EXT%\toolkit\helper\mutexandbroadcasthelper.hxx -..\inc\toolkit\helper\listenermultiplexer.hxx %_DEST%\inc%_EXT%\toolkit\helper\listenermultiplexer.hxx -..\inc\toolkit\helper\unowrapper.hxx %_DEST%\inc%_EXT%\toolkit\helper\unowrapper.hxx -..\inc\toolkit\helper\externallock.hxx %_DEST%\inc%_EXT%\toolkit\helper\externallock.hxx -..\inc\toolkit\helper\formpdfexport.hxx %_DEST%\inc%_EXT%\toolkit\helper/formpdfexport.hxx -..\inc\toolkit\helper\accessiblefactory.hxx %_DEST%\inc%_EXT%\toolkit\helper\accessiblefactory.hxx -..\inc\toolkit\helper\fixedhyperbase.hxx %_DEST%\inc%_EXT%\toolkit\helper\fixedhyperbase.hxx -..\inc\toolkit\helper\unopropertyarrayhelper.hxx %_DEST%\inc%_EXT%\toolkit\helper\unopropertyarrayhelper.hxx - -..\inc\toolkit\helper\vclunohelper.hxx %_DEST%\inc%_EXT%\toolkit\unohlp.hxx -..\inc\toolkit\dllapi.h %_DEST%\inc%_EXT%\toolkit\dllapi.h - -mkdir: %_DEST%\inc%_EXT%\layout -..\%__SRC%\lib\*.dylib %_DEST%\lib%_EXT%\*.dylib - -..\inc\layout\*.hxx %_DEST%\inc%_EXT%\layout\*.hxx -mkdir: %_DEST%\inc%_EXT%\layout\core -..\source\layout\core\*.hxx %_DEST%\inc%_EXT%\layout\core\*.hxx -mkdir: %_DEST%\inc%_EXT%\layout\vcl -..\source\layout\vcl\*.hxx %_DEST%\inc%_EXT%\layout\vcl\*.hxx - -..\%__SRC%\bin\*-layout.zip %_DEST%\pck%_EXT%\*.* diff --git a/toolkit/util/makefile.pmk b/toolkit/prj/makefile.mk index f04a39bac91b..e312a7ccab65 100644 --- a/toolkit/util/makefile.pmk +++ b/toolkit/prj/makefile.mk @@ -25,12 +25,16 @@ # #************************************************************************* -# Reduction of exported symbols: -CDEFS += -DTOOLKIT_DLLIMPLEMENTATION -VISIBILITY_HIDDEN=TRUE +PRJ=.. +TARGET=prj -CFLAGS+=-I$(PRJ)/source +.INCLUDE : settings.mk -.IF "$(ENABLE_LAYOUT)" == "TRUE" -CFLAGS+=-DTEST_LAYOUT=1 -.ENDIF # ENABLE_LAYOUT == TRUE +.IF "$(VERBOSE)"!="" +VERBOSEFLAG := +.ELSE +VERBOSEFLAG := -s +.ENDIF + +all: + cd $(PRJ) && $(GNUMAKE) $(VERBOSEFLAG) -r -j$(MAXPROCESS) $(gb_MAKETARGET) && $(GNUMAKE) $(VERBOSEFLAG) -r deliverlog diff --git a/toolkit/qa/complex/toolkit/AccessibleStatusBar.java b/toolkit/qa/complex/toolkit/AccessibleStatusBar.java new file mode 100755 index 000000000000..d4f2329d8f31 --- /dev/null +++ b/toolkit/qa/complex/toolkit/AccessibleStatusBar.java @@ -0,0 +1,338 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package complex.toolkit; + +import complex.toolkit.accessibility._XAccessibleEventBroadcaster; +import complex.toolkit.accessibility._XAccessibleExtendedComponent; +import complex.toolkit.accessibility._XAccessibleComponent; +import complex.toolkit.accessibility._XAccessibleContext; +import java.util.logging.Logger; +import java.util.logging.Level; +import util.SOfficeFactory; +import util.AccessibilityTools; +import com.sun.star.awt.XWindow; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XServiceInfo; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.XInterface; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.util.XCloseable; +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.awt.XExtendedToolkit; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openoffice.test.OfficeConnection; +import static org.junit.Assert.*; + +/** + * + */ +public class AccessibleStatusBar { + + XInterface testObject = null; + XMultiServiceFactory xMSF = null; + XWindow xWindow = null; + + private XMultiServiceFactory getMSF() + { + final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager()); + return xMSF1; + } + + + /** + * Sleeps for 0.5 sec. to allow StarOffice to react on <code> + * reset</code> call. + */ + private void shortWait() { + try { + Thread.sleep(500) ; + } catch (InterruptedException e) { + System.out.println("While waiting :" + e) ; + } + } + + /** + * Check document types + */ + @Test + public void checkDocs() { + checkWriterDoc(); + checkMathDoc(); + checkDrawDoc(); + checkImpressDoc(); + checkCalcDoc(); + } + + /** + * Test the interfaces on a writer document + */ + public void checkWriterDoc() { + xMSF = getMSF(); + SOfficeFactory xSOF = SOfficeFactory.getFactory(xMSF); + XTextDocument xTextDoc = null; + try { + System.out.println("****** Open a new writer document"); + xTextDoc = xSOF.createTextDoc("_blank"); + getTestObject(); + } + catch(com.sun.star.uno.Exception e) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); + } + runAllInterfaceTests(); + + if (xTextDoc != null) { + XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, xTextDoc); + try { + xClose.close(false); + } + catch(com.sun.star.util.CloseVetoException e) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); + } + } + } + + /** + * Test the interfaces on a math document + */ + public void checkMathDoc() { + xMSF = getMSF(); + SOfficeFactory xSOF = SOfficeFactory.getFactory(xMSF); + XComponent xMathDoc = null; + try { + System.out.println("****** Open a new math document"); + xMathDoc = xSOF.createMathDoc("_blank"); + getTestObject(); + } + catch(com.sun.star.uno.Exception e) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); + } + runAllInterfaceTests(); + + if (xMathDoc != null) { + XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, xMathDoc); + try { + xClose.close(false); + } + catch(com.sun.star.util.CloseVetoException e) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); + } + } + } + + /** + * Test the interfaces on a draw document + */ + public void checkDrawDoc() { + xMSF = getMSF(); + SOfficeFactory xSOF = SOfficeFactory.getFactory(xMSF); + XComponent xDrawDoc = null; + try { + System.out.println("****** Open a new draw document"); + xDrawDoc = xSOF.createDrawDoc("_blank"); + getTestObject(); + } + catch(com.sun.star.uno.Exception e) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); + } + runAllInterfaceTests(); + + if (xDrawDoc != null) { + XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, xDrawDoc); + try { + xClose.close(false); + } + catch(com.sun.star.util.CloseVetoException e) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); + } + } + } + + /** + * Test the interfaces on an impress document + */ + public void checkImpressDoc() { + xMSF = getMSF(); + SOfficeFactory xSOF = SOfficeFactory.getFactory(xMSF); + XComponent xImpressDoc = null; + try { + System.out.println("****** Open a new impress document"); + xImpressDoc = xSOF.createImpressDoc("_blank"); + getTestObject(); + } + catch(com.sun.star.uno.Exception e) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); + } + runAllInterfaceTests(); + + if (xImpressDoc != null) { + XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, xImpressDoc); + try { + xClose.close(false); + } + catch(com.sun.star.util.CloseVetoException e) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); + } + } + } + /** + * Test the interfaces on an calc document + */ + public void checkCalcDoc() { + xMSF = getMSF(); + SOfficeFactory xSOF = SOfficeFactory.getFactory(xMSF); + XSpreadsheetDocument xSpreadsheetDoc = null; + try { + System.out.println("****** Open a new calc document"); + xSpreadsheetDoc = xSOF.createCalcDoc("_blank"); + shortWait(); + getTestObject(); + } + catch(com.sun.star.uno.Exception e) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); + } + runAllInterfaceTests(); + + if (xSpreadsheetDoc != null) { + XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, xSpreadsheetDoc); + try { + xClose.close(false); + } + catch(com.sun.star.util.CloseVetoException e) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); + } + } + } + + public void getTestObject() { + try { + XInterface xIfc = (XInterface) xMSF.createInstance( + "com.sun.star.awt.Toolkit") ; + XExtendedToolkit tk = UnoRuntime.queryInterface(XExtendedToolkit.class, xIfc); + + shortWait(); + xWindow = UnoRuntime.queryInterface(XWindow.class, tk.getActiveTopWindow()); + + shortWait(); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + XAccessibleContext parentContext = null; + + System.out.println("Get the accessible status bar."); + parentContext = AccessibilityTools.getAccessibleObjectForRole( + xRoot, AccessibleRole.STATUS_BAR, ""); + shortWait(); + System.out.println("...OK."); + + XServiceInfo xSI = UnoRuntime.queryInterface(XServiceInfo.class, parentContext); + String[] services = xSI.getSupportedServiceNames(); + System.out.println("*****"); + System.out.println("* Implementation Name: " + xSI.getImplementationName()); + for (int i=0; i<services.length; i++) + { + System.out.println("* ServiceName " + i + ": " + services[i]); + } + System.out.println("*****"); + testObject=parentContext; + } + catch(com.sun.star.uno.Exception e) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); + } + catch(Throwable t) { + System.out.println("Got throwable:"); + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", t ); + } + } + + public void runAllInterfaceTests() { + System.out.println("*** Now testing XAccessibleComponent ***"); + _XAccessibleComponent _xAccCompTest = + new _XAccessibleComponent(testObject); + assertTrue("failed: XAccessibleComponent::getBounds", _xAccCompTest._getBounds()); + assertTrue("failed: XAccessibleComponent::contains", _xAccCompTest._containsPoint()); + assertTrue("failed: XAccessibleComponent::getAccessibleAt", _xAccCompTest._getAccessibleAtPoint()); + assertTrue("failed: XAccessibleComponent::getBackground", _xAccCompTest._getBackground()); + assertTrue("failed: XAccessibleComponent::getForeground", _xAccCompTest._getForeground()); + assertTrue("failed: XAccessibleComponent::getLocation", _xAccCompTest._getLocation()); + assertTrue("failed: XAccessibleComponent::getLocationOnScreen", _xAccCompTest._getLocationOnScreen()); + assertTrue("failed: XAccessibleComponent::getSize", _xAccCompTest._getSize()); + assertTrue("failed: XAccessibleComponent::grabFocus", _xAccCompTest._grabFocus()); + + System.out.println("*** Now testing XAccessibleContext ***"); + _XAccessibleContext _xAccContext = + new _XAccessibleContext(testObject); + assertTrue("failed: XAccessibleContext::getAccessibleChildCount", _xAccContext._getAccessibleChildCount()); + assertTrue("failed: XAccessibleContext::getAccessibleChild", _xAccContext._getAccessibleChild()); + assertTrue("failed: XAccessibleContext::getAccessibleDescription", _xAccContext._getAccessibleDescription()); + assertTrue("failed: XAccessibleContext::getAccessibleName", _xAccContext._getAccessibleName()); + assertTrue("failed: XAccessibleContext::getAccessibleParent", _xAccContext._getAccessibleParent()); + assertTrue("failed: XAccessibleContext::getAccessibleIndexInParent", _xAccContext._getAccessibleIndexInParent()); + assertTrue("failed: XAccessibleContext::getAccessibleRelationSet", _xAccContext._getAccessibleRelationSet()); + assertTrue("failed: XAccessibleContext::getAccessibleRole", _xAccContext._getAccessibleRole()); + assertTrue("failed: XAccessibleContext::getAccessibleStateSet", _xAccContext._getAccessibleStateSet()); + assertTrue("failed: XAccessibleContext::getLocale", _xAccContext._getLocale()); + + System.out.println("*** Now testing XAccessibleExtendedComponent ***"); + _XAccessibleExtendedComponent _xAccExtComp = + new _XAccessibleExtendedComponent(testObject); + assertTrue("failed: XAccessibleExtendedComponent::getFont", _xAccExtComp._getFont()); + assertTrue("failed: XAccessibleExtendedComponent::getTitledBorderText", _xAccExtComp._getTitledBorderText()); + assertTrue("failed: XAccessibleExtendedComponent::getToolTipText", _xAccExtComp._getToolTipText()); + + System.out.println("*** Now testing XAccessibleEventBroadcaster ***"); + _XAccessibleEventBroadcaster _xAccEvBcast = + new _XAccessibleEventBroadcaster(testObject, xWindow); + assertTrue("failed: XAccessibleEventBroadcaster::addEventListener", _xAccEvBcast._addEventListener()); + assertTrue("failed: XAccessibleEventBroadcaster::removeEventListener", _xAccEvBcast._removeEventListener()); + } + + + + + @BeforeClass + public static void setUpConnection() throws Exception { + System.out.println("setUpConnection()"); + connection.setUp(); + } + + @AfterClass + public static void tearDownConnection() + throws InterruptedException, com.sun.star.uno.Exception + { + System.out.println("tearDownConnection()"); + connection.tearDown(); + } + + private static final OfficeConnection connection = new OfficeConnection(); + +} diff --git a/toolkit/qa/complex/toolkit/AccessibleStatusBarItem.java b/toolkit/qa/complex/toolkit/AccessibleStatusBarItem.java new file mode 100755 index 000000000000..edd84651d45e --- /dev/null +++ b/toolkit/qa/complex/toolkit/AccessibleStatusBarItem.java @@ -0,0 +1,381 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package complex.toolkit; + +import java.util.logging.Logger; +import java.util.logging.Level; +import complex.toolkit.accessibility._XAccessibleEventBroadcaster; +import complex.toolkit.accessibility._XAccessibleExtendedComponent; +import complex.toolkit.accessibility._XAccessibleText; +import complex.toolkit.accessibility._XAccessibleComponent; +import complex.toolkit.accessibility._XAccessibleContext; +import util.SOfficeFactory; +import util.AccessibilityTools; +import com.sun.star.awt.XWindow; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XServiceInfo; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.XInterface; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.util.XCloseable; +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.awt.XExtendedToolkit; + + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openoffice.test.OfficeConnection; +import static org.junit.Assert.*; + +/** + * + */ +public class AccessibleStatusBarItem { + + XMultiServiceFactory xMSF = null; + XAccessibleContext testObject = null; + XWindow xWindow = null; + + /** + * Sleeps for a certain time. + * @param Thread is sleeping for this time in milliseconds. + */ + private void shortWait() { + try { + Thread.sleep(500); + } catch (InterruptedException e) { + System.out.println("While waiting :" + e) ; + } + } + + /** + * Check document types + */ + @Test + public void checkDocs() + { + checkWriterDoc(); + checkMathDoc(); + checkDrawDoc(); + checkImpressDoc(); + checkCalcDoc(); + } + + private XMultiServiceFactory getMSF() + { + final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager()); + return xMSF1; + } + + /** + * Test the interfaces on a writer document + */ + private void checkWriterDoc() { + xMSF = getMSF(); + SOfficeFactory xSOF = SOfficeFactory.getFactory(xMSF); + XTextDocument xTextDoc = null; + try { + System.out.println("****** Open a new writer document"); + xTextDoc = xSOF.createTextDoc("_blank"); + getTestObject(); + } + catch(com.sun.star.uno.Exception e) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); + } + runAllInterfaceTests(); + + if (xTextDoc != null) { + XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, xTextDoc); + try { + xClose.close(false); + } + catch(com.sun.star.util.CloseVetoException e) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); + } + } + } + + /** + * Test the interfaces on a math document + */ + public void checkMathDoc() { + xMSF = getMSF(); + SOfficeFactory xSOF = SOfficeFactory.getFactory(xMSF); + XComponent xMathDoc = null; + try { + System.out.println("****** Open a new math document"); + xMathDoc = xSOF.createMathDoc("_blank"); + getTestObject(); + } + catch(com.sun.star.uno.Exception e) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); + } + runAllInterfaceTests(); + + if (xMathDoc != null) { + XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, xMathDoc); + try { + xClose.close(false); + } + catch(com.sun.star.util.CloseVetoException e) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); + } + } + } + + /** + * Test the interfaces on a draw document + */ + public void checkDrawDoc() { + xMSF = getMSF(); + SOfficeFactory xSOF = SOfficeFactory.getFactory(xMSF); + XComponent xDrawDoc = null; + try { + System.out.println("****** Open a new draw document"); + xDrawDoc = xSOF.createDrawDoc("_blank"); + getTestObject(); + } + catch(com.sun.star.uno.Exception e) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); + } + runAllInterfaceTests(); + + if (xDrawDoc != null) { + XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, xDrawDoc); + try { + xClose.close(false); + } + catch(com.sun.star.util.CloseVetoException e) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); + } + } + } + + /** + * Test the interfaces on an impress document + */ + public void checkImpressDoc() { + xMSF = getMSF(); + SOfficeFactory xSOF = SOfficeFactory.getFactory(xMSF); + XComponent xImpressDoc = null; + try { + System.out.println("****** Open a new impress document"); + xImpressDoc = xSOF.createImpressDoc("_blank"); + getTestObject(); + } + catch(com.sun.star.uno.Exception e) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); + } + runAllInterfaceTests(); + + if (xImpressDoc != null) { + XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, xImpressDoc); + try { + xClose.close(false); + } + catch(com.sun.star.util.CloseVetoException e) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); + } + } + } + /** + * Test the interfaces on an calc document + */ + public void checkCalcDoc() { + xMSF = getMSF(); + SOfficeFactory xSOF = SOfficeFactory.getFactory(xMSF); + XSpreadsheetDocument xSpreadsheetDoc = null; + try { + System.out.println("****** Open a new calc document"); + xSpreadsheetDoc = xSOF.createCalcDoc("_blank"); + shortWait(); + getTestObject(); + } + catch(com.sun.star.uno.Exception e) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); + } + runAllInterfaceTests(); + + if (xSpreadsheetDoc != null) { + XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, xSpreadsheetDoc); + try { + xClose.close(false); + } + catch(com.sun.star.util.CloseVetoException e) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); + } + } + } + + public void getTestObject() { + try { + XInterface xIfc = (XInterface) xMSF.createInstance( + "com.sun.star.awt.Toolkit") ; + XExtendedToolkit tk = + UnoRuntime.queryInterface(XExtendedToolkit.class,xIfc); + + shortWait(); + xWindow = UnoRuntime.queryInterface( + XWindow.class,tk.getActiveTopWindow()); + + shortWait(); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + XAccessibleContext parentContext = null; + + System.out.println("Get the accessible status bar."); + parentContext = AccessibilityTools.getAccessibleObjectForRole( + xRoot, AccessibleRole.STATUS_BAR, ""); + shortWait(); + if ( parentContext == null ) { + fail("Could not create a test object."); + } + System.out.println("...OK."); + + testObject=parentContext; + } + catch(com.sun.star.uno.Exception e) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", e ); + } + catch(Throwable t) { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, "caught an exception", t ); + } + } + + public void runAllInterfaceTests() { + int count = testObject.getAccessibleChildCount(); + System.out.println("*****"); + System.out.println("**** Found items to test: " + count); + for (int i=0;i<count;i++){ + System.out.println("**** Now testing StatusBarItem " + i + "."); + XAccessible object = null; + try { + object = testObject.getAccessibleChild(i); + } + catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("* Cannot get item Nr: " + i); + continue; + } + XServiceInfo xSI = UnoRuntime.queryInterface( + XServiceInfo.class,object); + String[] services = xSI.getSupportedServiceNames(); + System.out.println("* Implementation Name: " + xSI.getImplementationName()); + String accName = object.getAccessibleContext().getAccessibleName(); + System.out.println("* Accessible Name: " + accName); + for (int j=0; i<services.length; i++) + { + System.out.println("* ServiceName "+i+": "+ services[j]); + } + System.out.println("*****"); + + System.out.println("*** Now testing XAccessibleComponent ***"); + _XAccessibleComponent _xAccCompTest = + new _XAccessibleComponent(object); + assertTrue("failed: "+accName+" - XAccessibleComponent::getBounds", _xAccCompTest._getBounds()); + assertTrue("failed: "+accName+" - XAccessibleComponent::contains", _xAccCompTest._containsPoint()); + assertTrue("failed: "+accName+" - XAccessibleComponent::getAccessibleAt", _xAccCompTest._getAccessibleAtPoint()); + assertTrue("failed: "+accName+" - XAccessibleComponent::getBackground", _xAccCompTest._getBackground()); + assertTrue("failed: "+accName+" - XAccessibleComponent::getForeground", _xAccCompTest._getForeground()); + assertTrue("failed: "+accName+" - XAccessibleComponent::getLocation", _xAccCompTest._getLocation()); + assertTrue("failed: "+accName+" - XAccessibleComponent::getLocationOnScreen", _xAccCompTest._getLocationOnScreen()); + assertTrue("failed: "+accName+" - XAccessibleComponent::getSize", _xAccCompTest._getSize()); + assertTrue("failed: "+accName+" - XAccessibleComponent::grabFocus", _xAccCompTest._grabFocus()); + + System.out.println("*** Now testing XAccessibleContext ***"); + _XAccessibleContext _xAccContext = + new _XAccessibleContext(object); + assertTrue("failed: "+accName+" - XAccessibleContext::getAccessibleChildCount", _xAccContext._getAccessibleChildCount()); + assertTrue("failed: "+accName+" - XAccessibleContext::getAccessibleChild", _xAccContext._getAccessibleChild()); + assertTrue("failed: "+accName+" - XAccessibleContext::getAccessibleDescription", _xAccContext._getAccessibleDescription()); + assertTrue("failed: "+accName+" - XAccessibleContext::getAccessibleName", _xAccContext._getAccessibleName()); + assertTrue("failed: "+accName+" - XAccessibleContext::getAccessibleParent", _xAccContext._getAccessibleParent()); + assertTrue("failed: "+accName+" - XAccessibleContext::getAccessibleIndexInParent", _xAccContext._getAccessibleIndexInParent()); + assertTrue("failed: "+accName+" - XAccessibleContext::getAccessibleRelationSet", _xAccContext._getAccessibleRelationSet()); + assertTrue("failed: "+accName+" - XAccessibleContext::getAccessibleRole", _xAccContext._getAccessibleRole()); + assertTrue("failed: "+accName+" - XAccessibleContext::getAccessibleStateSet", _xAccContext._getAccessibleStateSet()); + assertTrue("failed: "+accName+" - XAccessibleContext::getLocale", _xAccContext._getLocale()); + + System.out.println("*** Now testing XAccessibleExtendedComponent ***"); + _XAccessibleExtendedComponent _xAccExtComp = + new _XAccessibleExtendedComponent(object); + assertTrue("failed: "+accName+" - XAccessibleExtendedComponent::getFont", _xAccExtComp._getFont()); + assertTrue("failed: "+accName+" - XAccessibleExtendedComponent::getTitledBorderText", _xAccExtComp._getTitledBorderText()); + assertTrue("failed: "+accName+" - XAccessibleExtendedComponent::getToolTipText", _xAccExtComp._getToolTipText()); + + System.out.println("*** Now testing XAccessibleEventBroadcaster ***"); + _XAccessibleEventBroadcaster _xAccEvBcast = + new _XAccessibleEventBroadcaster(object, xWindow); + assertTrue("failed: "+accName+" - XAccessibleEventBroadcaster::addEventListener", _xAccEvBcast._addEventListener()); + assertTrue("failed: "+accName+" - XAccessibleEventBroadcaster::removeEventListener", _xAccEvBcast._removeEventListener()); + + System.out.println("*** Now testing XAccessibleText ***"); + _XAccessibleText _xAccText = + new _XAccessibleText(object, xMSF, "true"); + assertTrue("failed: "+accName+" - XAccessibleText::getText", _xAccText._getText()); + assertTrue("failed: "+accName+" - XAccessibleText::getCharacterCount", _xAccText._getCharacterCount()); + assertTrue("failed: "+accName+" - XAccessibleText::getCharacterBounds", _xAccText._getCharacterBounds()); + assertTrue("failed: "+accName+" - XAccessibleText::setSelection", _xAccText._setSelection()); + assertTrue("failed: "+accName+" - XAccessibleText::copyText", _xAccText._copyText()); + assertTrue("failed: "+accName+" - XAccessibleText::getCharacter", _xAccText._getCharacter()); + assertTrue("failed: "+accName+" - XAccessibleText::getCharacterAttributes", _xAccText._getCharacterAttributes()); + assertTrue("failed: "+accName+" - XAccessibleText::getIndexAtPoint", _xAccText._getIndexAtPoint()); + assertTrue("failed: "+accName+" - XAccessibleText::getSelectedText", _xAccText._getSelectedText()); + assertTrue("failed: "+accName+" - XAccessibleText::getSelectionEnd", _xAccText._getSelectionEnd()); + assertTrue("failed: "+accName+" - XAccessibleText::getSelectionStart", _xAccText._getSelectionStart()); + assertTrue("failed: "+accName+" - XAccessibleText::getTextAtIndex", _xAccText._getTextAtIndex()); + assertTrue("failed: "+accName+" - XAccessibleText::getTextBeforeIndex", _xAccText._getTextBeforeIndex()); + assertTrue("failed: "+accName+" - XAccessibleText::getBehindIndex", _xAccText._getTextBehindIndex()); + assertTrue("failed: "+accName+" - XAccessibleText::getTextRange", _xAccText._getTextRange()); + assertTrue("failed: "+accName+" - XAccessibleText::setCaretPosition", _xAccText._setCaretPosition()); + assertTrue("failed: "+accName+" - XAccessibleText::getCaretPosition", _xAccText._getCaretPosition()); + } + } + + + + + @BeforeClass public static void setUpConnection() throws Exception { + System.out.println("setUpConnection()"); + connection.setUp(); + } + + @AfterClass public static void tearDownConnection() + throws InterruptedException, com.sun.star.uno.Exception + { + System.out.println("tearDownConnection()"); + connection.tearDown(); + } + + private static final OfficeConnection connection = new OfficeConnection(); + + +} diff --git a/toolkit/qa/complex/toolkit/Assert.java b/toolkit/qa/complex/toolkit/Assert.java new file mode 100755 index 000000000000..93b1a2c490e1 --- /dev/null +++ b/toolkit/qa/complex/toolkit/Assert.java @@ -0,0 +1,234 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + *************************************************************************/ + +package complex.toolkit; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import com.sun.star.uno.UnoRuntime; +import static org.junit.Assert.*; + +/** + * provides assertion capabilities not found in {@link org.junit.Assert} + * @author frank.schoenheit@oracle.com + */ +public class Assert +{ + // -------------------------------------------------------------------------------------------------------- + /** invokes a given method on a given object, and assures a certain exception is caught + * @param i_message + * is the message to print when the check fails + * @param i_object + * is the object to invoke the method on + * @param i_methodName + * is the name of the method to invoke + * @param i_methodArgs + * are the arguments to pass to the method. + * @param i_argClasses + * are the classes to assume for the arguments of the methods + * @param i_expectedExceptionClass + * is the class of the exception to be caught. If this is null, + * it means that <em>no</em> exception must be throw by invoking the method. + */ + public static void assertException( final String i_message, final Object i_object, final String i_methodName, + final Class[] i_argClasses, final Object[] i_methodArgs, final Class i_expectedExceptionClass ) + { + Class objectClass = i_object.getClass(); + + boolean noExceptionAllowed = ( i_expectedExceptionClass == null ); + + boolean caughtExpected = noExceptionAllowed ? true : false; + try + { + Method method = impl_getMethod( objectClass, i_methodName, i_argClasses ); + method.invoke(i_object, i_methodArgs ); + } + catch ( NoSuchMethodException e ) + { + StringBuilder message = new StringBuilder(); + message.append( "no such method: " ).append( objectClass.getName() ).append( "." ).append( i_methodName ).append( "( " ); + for ( int i=0; i<i_argClasses.length; ++i ) + { + message.append( i_argClasses[i].getName() ); + if ( i<i_argClasses.length - 1 ) + message.append( ", " ); + } + message.append( " )" ); + fail( message.toString() ); + } + catch ( InvocationTargetException e ) + { + caughtExpected = noExceptionAllowed + ? false + : ( e.getTargetException().getClass().equals( i_expectedExceptionClass ) ); + } + catch( Exception e ) + { + caughtExpected = false; + } + + assertTrue( i_message, caughtExpected ); + } + + /** + * retrieves a method, given by name and parameter signature, from the given class + * + * The method does somewhat more than simply calling {@link Class.getMethod}. In particular, it recognizes + * primitiive parameter types, and attempts to find a method taking the given primitive type, instead of the + * type represented by the parameter class. + * + * For instance, if you have a method <code>foo( int )</code>, {@link Class.getMethod} would not return this + * method when you pass <code>Integer.class</code>. <code>impl_getMethod</code> will recognize this, and + * properly retrieve the method. + * + * Note: <code>impl_getMethod</code> is limited in that it will not try all possible combinations of primitive + * and non-primitive types. That is, a method like <code>foo( int, Integer, int )</code> is likely to not be + * found. + * + * @param i_obbjectClass + * @param i_methodName + * @param i_argClasses + * @return + */ + private static Method impl_getMethod( final Class i_objectClass, final String i_methodName, final Class[] i_argClasses ) throws NoSuchMethodException + { + try + { + return i_objectClass.getMethod( i_methodName, i_argClasses ); + } + catch ( NoSuchMethodException ex ) + { + } + + int substitutedTypes = 0; + int substitutedTypesLastRound = 0; + final Class[][] substitutionTable = new Class[][] { + new Class[] { Long.class, long.class }, + new Class[] { Integer.class, int.class }, + new Class[] { Short.class, short.class }, + new Class[] { Byte.class, byte.class }, + new Class[] { Double.class, double.class }, + new Class[] { Float.class, float.class }, + new Class[] { Character.class, char.class } + }; + do + { + substitutedTypes = 0; + final Class[] argClasses = new Class[ i_argClasses.length ]; + for ( int i=0; i < argClasses.length; ++i ) + { + argClasses[i] = i_argClasses[i]; + if ( substitutedTypes > substitutedTypesLastRound ) + continue; + + for ( int c=0; c<substitutionTable.length; ++c ) + { + if ( i_argClasses[i].equals( substitutionTable[c][0] ) ) + { + argClasses[i] = substitutionTable[c][1]; + ++substitutedTypes; + break; + } + } + } + if ( substitutedTypes == substitutedTypesLastRound ) + throw new NoSuchMethodException(); + substitutedTypesLastRound = substitutedTypes; + + try + { + return i_objectClass.getMethod( i_methodName, argClasses ); + } + catch ( NoSuchMethodException e ) + { + } + } + while ( substitutedTypes > 0 ); + throw new NoSuchMethodException(); + } + + /** invokes a given method on a given object, and assures a certain exception is caught + * @param i_message is the message to print when the check fails + * @param i_object is the object to invoke the method on + * @param i_methodName is the name of the method to invoke + * @param i_methodArgs are the arguments to pass to the method. Those implicitly define + * the classes of the arguments of the method which is called. + * @param i_expectedExceptionClass is the class of the exception to be caught. If this is null, + * it means that <em>no</em> exception must be throw by invoking the method. + */ + public static void assertException( final String i_message, final Object i_object, final String i_methodName, + final Object[] i_methodArgs, final Class i_expectedExceptionClass ) + { + Class[] argClasses = new Class[ i_methodArgs.length ]; + for ( int i=0; i<i_methodArgs.length; ++i ) + argClasses[i] = i_methodArgs[i].getClass(); + assertException( i_message, i_object, i_methodName, argClasses, i_methodArgs, i_expectedExceptionClass ); + } + + /** invokes a given method on a given object, and assures a certain exception is caught + * @param i_object is the object to invoke the method on + * @param i_methodName is the name of the method to invoke + * @param i_methodArgs are the arguments to pass to the method. Those implicitly define + * the classes of the arguments of the method which is called. + * @param i_expectedExceptionClass is the class of the exception to be caught. If this is null, + * it means that <em>no</em> exception must be throw by invoking the method. + */ + public static void assertException( final Object i_object, final String i_methodName, final Object[] i_methodArgs, + final Class i_expectedExceptionClass ) + { + assertException( + "did not catch the expected exception (" + + ( ( i_expectedExceptionClass == null ) ? "none" : i_expectedExceptionClass.getName() ) + + ") while calling " + i_object.getClass().getName() + "." + i_methodName, + i_object, i_methodName, i_methodArgs, i_expectedExceptionClass ); + } + + /** invokes a given method on a given object, and assures a certain exception is caught + * @param i_object is the object to invoke the method on + * @param i_methodName is the name of the method to invoke + * @param i_methodArgs are the arguments to pass to the method + * @param i_argClasses are the classes to assume for the arguments of the methods + * @param i_expectedExceptionClass is the class of the exception to be caught. If this is null, + * it means that <em>no</em> exception must be throw by invoking the method. + */ + public static void assertException( final Object i_object, final String i_methodName, final Class[] i_argClasses, + final Object[] i_methodArgs, final Class i_expectedExceptionClass ) + { + assertException( + "did not catch the expected exception (" + + ( ( i_expectedExceptionClass == null ) ? "none" : i_expectedExceptionClass.getName() ) + + ") while calling " + i_object.getClass().getName() + "." + i_methodName, + i_object, i_methodName, i_argClasses, i_methodArgs, i_expectedExceptionClass ); + } + + // -------------------------------------------------------------------------------------------------------- + public static void assertException( Object i_object, Class _unoInterfaceClass, String i_methodName, Object[] i_methodArgs, + Class i_expectedExceptionClass ) + { + assertException( UnoRuntime.queryInterface( _unoInterfaceClass, i_object ), i_methodName, + i_methodArgs, i_expectedExceptionClass ); + } +} diff --git a/toolkit/qa/complex/toolkit/CallbackClass.java b/toolkit/qa/complex/toolkit/CallbackClass.java deleted file mode 100644 index efc0ef91f7c0..000000000000 --- a/toolkit/qa/complex/toolkit/CallbackClass.java +++ /dev/null @@ -1,67 +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. - * - ************************************************************************/ - -package complex.toolkit; - -import com.sun.star.awt.XCallback; -import lib.MultiMethodTest; -import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.uno.XInterface; -import com.sun.star.uno.UnoRuntime; -import share.LogWriter; - -/** - * Testing <code>com.sun.star.awt.XRequestCallback</code> - * interface methods : - * <ul> - * <li><code> addCallback()</code></li> - * </ul> <p> - * @see com.sun.star.awt.XRequestCallback - */ -public class CallbackClass implements XCallback{ - - private LogWriter log; - - private XMultiServiceFactory xMSF; - - - public CallbackClass(LogWriter log, XMultiServiceFactory xMSF ) { - - this.xMSF = xMSF; - this.log = log; - } - - - /** - * Callback method which will be called by the asynchronous - * service where we have added our request before. - */ - public void notify( Object aData ) { - - log.println("callback called successfully" ); - } -} diff --git a/toolkit/qa/complex/toolkit/CheckAccessibleStatusBar.java b/toolkit/qa/complex/toolkit/CheckAccessibleStatusBar.java deleted file mode 100755 index fee95f2e6de0..000000000000 --- a/toolkit/qa/complex/toolkit/CheckAccessibleStatusBar.java +++ /dev/null @@ -1,331 +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. - * - ************************************************************************/ - -package complex.toolkit; - -import complexlib.ComplexTestCase; -import util.SOfficeFactory; -import util.AccessibilityTools; -import complex.toolkit.interface_tests._XAccessibleComponent; -import complex.toolkit.interface_tests._XAccessibleContext; -import complex.toolkit.interface_tests._XAccessibleExtendedComponent; -import complex.toolkit.interface_tests._XAccessibleEventBroadcaster; -import com.sun.star.awt.XWindow; -import com.sun.star.chart.XChartDocument; -import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.lang.XComponent; -import com.sun.star.lang.XServiceInfo; -import com.sun.star.sheet.XSpreadsheetDocument; -import com.sun.star.text.XTextDocument; -import com.sun.star.uno.XInterface; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.util.XCloseable; -import com.sun.star.accessibility.AccessibleRole; -import com.sun.star.accessibility.XAccessible; -import com.sun.star.accessibility.XAccessibleContext; -import com.sun.star.awt.XExtendedToolkit; -import java.io.PrintWriter; - -/** - * - */ -public class CheckAccessibleStatusBar extends ComplexTestCase { - - XInterface testObject = null; - XMultiServiceFactory xMSF = null; - XWindow xWindow = null; - - public String[] getTestMethodNames() { - return new String[]{"checkDocs"};//WriterDoc", "checkDrawDoc", -// "checkMathDoc", "checkImpressDoc", "checkCalcDoc"}; - } - -/* public String getTestObjectName() { - return "com.sun.star.awt.AccessibleStatusBar"; - } -*/ - /** - * Sleeps for 0.5 sec. to allow StarOffice to react on <code> - * reset</code> call. - */ - private void shortWait() { - try { - Thread.sleep(500) ; - } catch (InterruptedException e) { - log.println("While waiting :" + e) ; - } - } - - /** - * Check document types - */ - public void checkDocs() { - Object doc = param.get("DocType"); - String testDocType; - if (doc == null) - testDocType = "all"; - else - testDocType = (String)doc; - - System.out.println("Param was " + doc); - System.out.println("DocType " + testDocType); - if (testDocType.equalsIgnoreCase("writer") || testDocType.equalsIgnoreCase("all")) - checkWriterDoc(); - if (testDocType.equalsIgnoreCase("math") || testDocType.equalsIgnoreCase("all")) - checkMathDoc(); - if (testDocType.equalsIgnoreCase("draw") || testDocType.equalsIgnoreCase("all")) - checkDrawDoc(); - if (testDocType.equalsIgnoreCase("impress") || testDocType.equalsIgnoreCase("all")) - checkImpressDoc(); - if (testDocType.equalsIgnoreCase("calc") || testDocType.equalsIgnoreCase("all")) - checkCalcDoc(); - - } - - /** - * Test the interfaces on a writer document - */ - public void checkWriterDoc() { - xMSF = (XMultiServiceFactory)param.getMSF(); - SOfficeFactory xSOF = SOfficeFactory.getFactory(xMSF); - XTextDocument xTextDoc = null; - try { - log.println("****** Open a new writer document"); - xTextDoc = xSOF.createTextDoc("_blank"); - getTestObject(); - } - catch(com.sun.star.uno.Exception e) { - e.printStackTrace(); - } - runAllInterfaceTests(); - - if (xTextDoc != null) { - XCloseable xClose = (XCloseable)UnoRuntime.queryInterface(XCloseable.class, xTextDoc); - try { - xClose.close(false); - } - catch(com.sun.star.util.CloseVetoException e) { - e.printStackTrace(); - } - } - } - - /** - * Test the interfaces on a math document - */ - public void checkMathDoc() { - xMSF = (XMultiServiceFactory)param.getMSF(); - SOfficeFactory xSOF = SOfficeFactory.getFactory(xMSF); - XComponent xMathDoc = null; - try { - log.println("****** Open a new math document"); - xMathDoc = xSOF.createMathDoc("_blank"); - getTestObject(); - } - catch(com.sun.star.uno.Exception e) { - e.printStackTrace(); - } - runAllInterfaceTests(); - - if (xMathDoc != null) { - XCloseable xClose = (XCloseable)UnoRuntime.queryInterface(XCloseable.class, xMathDoc); - try { - xClose.close(false); - } - catch(com.sun.star.util.CloseVetoException e) { - e.printStackTrace(); - } - } - } - - /** - * Test the interfaces on a draw document - */ - public void checkDrawDoc() { - xMSF = (XMultiServiceFactory)param.getMSF(); - SOfficeFactory xSOF = SOfficeFactory.getFactory(xMSF); - XComponent xDrawDoc = null; - try { - log.println("****** Open a new draw document"); - xDrawDoc = xSOF.createDrawDoc("_blank"); - getTestObject(); - } - catch(com.sun.star.uno.Exception e) { - e.printStackTrace(); - } - runAllInterfaceTests(); - - if (xDrawDoc != null) { - XCloseable xClose = (XCloseable)UnoRuntime.queryInterface(XCloseable.class, xDrawDoc); - try { - xClose.close(false); - } - catch(com.sun.star.util.CloseVetoException e) { - e.printStackTrace(); - } - } - } - - /** - * Test the interfaces on an impress document - */ - public void checkImpressDoc() { - xMSF = (XMultiServiceFactory)param.getMSF(); - SOfficeFactory xSOF = SOfficeFactory.getFactory(xMSF); - XComponent xImpressDoc = null; - try { - log.println("****** Open a new impress document"); - xImpressDoc = xSOF.createImpressDoc("_blank"); - getTestObject(); - } - catch(com.sun.star.uno.Exception e) { - e.printStackTrace(); - } - runAllInterfaceTests(); - - if (xImpressDoc != null) { - XCloseable xClose = (XCloseable)UnoRuntime.queryInterface(XCloseable.class, xImpressDoc); - try { - xClose.close(false); - } - catch(com.sun.star.util.CloseVetoException e) { - e.printStackTrace(); - } - } - } - /** - * Test the interfaces on an calc document - */ - public void checkCalcDoc() { - xMSF = (XMultiServiceFactory)param.getMSF(); - SOfficeFactory xSOF = SOfficeFactory.getFactory(xMSF); - XSpreadsheetDocument xSpreadsheetDoc = null; - try { - log.println("****** Open a new calc document"); - xSpreadsheetDoc = xSOF.createCalcDoc("_blank"); - shortWait(); - getTestObject(); - } - catch(com.sun.star.uno.Exception e) { - e.printStackTrace(); - } - runAllInterfaceTests(); - - if (xSpreadsheetDoc != null) { - XCloseable xClose = (XCloseable)UnoRuntime.queryInterface(XCloseable.class, xSpreadsheetDoc); - try { - xClose.close(false); - } - catch(com.sun.star.util.CloseVetoException e) { - e.printStackTrace(); - } - } - } - - public void getTestObject() { - try { - XInterface xIfc = (XInterface) xMSF.createInstance( - "com.sun.star.awt.Toolkit") ; - XExtendedToolkit tk = (XExtendedToolkit) - UnoRuntime.queryInterface(XExtendedToolkit.class,xIfc); - - shortWait(); - xWindow = (XWindow)UnoRuntime.queryInterface( - XWindow.class,tk.getActiveTopWindow()); - - shortWait(); - AccessibilityTools at = new AccessibilityTools(); - XAccessible xRoot = at.getAccessibleObject(xWindow); - XAccessibleContext parentContext = null; - - log.println("Get the accessible status bar."); - parentContext = at.getAccessibleObjectForRole( - xRoot, AccessibleRole.STATUS_BAR, ""); - shortWait(); - log.println("...OK."); - - XServiceInfo xSI = (XServiceInfo)UnoRuntime.queryInterface( - XServiceInfo.class,parentContext); - String[] services = xSI.getSupportedServiceNames(); - log.println("*****"); - log.println("* Implementation Name: " + xSI.getImplementationName()); - for (int i=0; i<services.length; i++) - log.println("* ServiceName "+i+": "+ services[i]); - log.println("*****"); - testObject=parentContext; - } - catch(com.sun.star.uno.Exception e) { - e.printStackTrace(); - } - catch(Throwable t) { - System.out.println("Got throwable:"); - t.printStackTrace(); - } - } - - public void runAllInterfaceTests() { - log.println("*** Now testing XAccessibleComponent ***"); - _XAccessibleComponent _xAccCompTest = - new _XAccessibleComponent(testObject, log); - assure("failed: XAccessibleComponent::getBounds", _xAccCompTest._getBounds()); - assure("failed: XAccessibleComponent::contains", _xAccCompTest._containsPoint()); - assure("failed: XAccessibleComponent::getAccessibleAt", _xAccCompTest._getAccessibleAtPoint()); - assure("failed: XAccessibleComponent::getBackground", _xAccCompTest._getBackground()); - assure("failed: XAccessibleComponent::getForeground", _xAccCompTest._getForeground()); - assure("failed: XAccessibleComponent::getLocation", _xAccCompTest._getLocation()); - assure("failed: XAccessibleComponent::getLocationOnScreen", _xAccCompTest._getLocationOnScreen()); - assure("failed: XAccessibleComponent::getSize", _xAccCompTest._getSize()); - assure("failed: XAccessibleComponent::grabFocus", _xAccCompTest._grabFocus()); - - log.println("*** Now testing XAccessibleContext ***"); - _XAccessibleContext _xAccContext = - new _XAccessibleContext(testObject, log); - assure("failed: XAccessibleContext::getAccessibleChildCount", _xAccContext._getAccessibleChildCount()); - assure("failed: XAccessibleContext::getAccessibleChild", _xAccContext._getAccessibleChild()); - assure("failed: XAccessibleContext::getAccessibleDescription", _xAccContext._getAccessibleDescription()); - assure("failed: XAccessibleContext::getAccessibleName", _xAccContext._getAccessibleName()); - assure("failed: XAccessibleContext::getAccessibleParent", _xAccContext._getAccessibleParent()); - assure("failed: XAccessibleContext::getAccessibleIndexInParent", _xAccContext._getAccessibleIndexInParent()); - assure("failed: XAccessibleContext::getAccessibleRelationSet", _xAccContext._getAccessibleRelationSet()); - assure("failed: XAccessibleContext::getAccessibleRole", _xAccContext._getAccessibleRole()); - assure("failed: XAccessibleContext::getAccessibleStateSet", _xAccContext._getAccessibleStateSet()); - assure("failed: XAccessibleContext::getLocale", _xAccContext._getLocale()); - - log.println("*** Now testing XAccessibleExtendedComponent ***"); - _XAccessibleExtendedComponent _xAccExtComp = - new _XAccessibleExtendedComponent(testObject, log); - assure("failed: XAccessibleExtendedComponent::getFont", _xAccExtComp._getFont()); - assure("failed: XAccessibleExtendedComponent::getTitledBorderText", _xAccExtComp._getTitledBorderText()); - assure("failed: XAccessibleExtendedComponent::getToolTipText", _xAccExtComp._getToolTipText()); - - log.println("*** Now testing XAccessibleEventBroadcaster ***"); - _XAccessibleEventBroadcaster _xAccEvBcast = - new _XAccessibleEventBroadcaster(testObject, log, "Pfff", xWindow); - assure("failed: XAccessibleEventBroadcaster::addEventListener", _xAccEvBcast._addEventListener()); - assure("failed: XAccessibleEventBroadcaster::removeEventListener", _xAccEvBcast._removeEventListener()); - } -} diff --git a/toolkit/qa/complex/toolkit/CheckAccessibleStatusBarItem.java b/toolkit/qa/complex/toolkit/CheckAccessibleStatusBarItem.java deleted file mode 100755 index 36394732ce78..000000000000 --- a/toolkit/qa/complex/toolkit/CheckAccessibleStatusBarItem.java +++ /dev/null @@ -1,385 +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. - * - ************************************************************************/ - -package complex.toolkit; - -import complexlib.ComplexTestCase; -import util.SOfficeFactory; -import complexlib.ComplexTestCase; -import util.SOfficeFactory; -import util.AccessibilityTools; -import complex.toolkit.interface_tests._XAccessibleComponent; -import complex.toolkit.interface_tests._XAccessibleContext; -import complex.toolkit.interface_tests._XAccessibleEventBroadcaster; -import complex.toolkit.interface_tests._XAccessibleExtendedComponent; -import complex.toolkit.interface_tests._XAccessibleText; -import com.sun.star.awt.XWindow; -import com.sun.star.chart.XChartDocument; -import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.lang.XComponent; -import com.sun.star.lang.XServiceInfo; -import com.sun.star.sheet.XSpreadsheetDocument; -import com.sun.star.text.XTextDocument; -import com.sun.star.uno.XInterface; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.util.XCloseable; -import com.sun.star.accessibility.AccessibleRole; -import com.sun.star.accessibility.XAccessible; -import com.sun.star.accessibility.XAccessibleContext; -import com.sun.star.awt.XExtendedToolkit; -import java.io.PrintWriter; -/** - * - */ -public class CheckAccessibleStatusBarItem extends ComplexTestCase { - - XMultiServiceFactory xMSF = null; - XAccessibleContext testObject = null; - XWindow xWindow = null; - - - public String[] getTestMethodNames() { - return new String[]{"checkDocs"};//{"checkWriterDoc", "checkDrawDoc", -// "checkMathDoc", "checkImpressDoc", "checkCalcDoc"}; - } - - /** - * Sleeps for 0.5 sec. to allow StarOffice to react on <code> - * reset</code> call. - */ - private void shortWait() { - shortWait(500) ; - } - - /** - * Sleeps for a certain time. - * @param Thread is sleeping for this time in milliseconds. - */ - private void shortWait(int time) { - try { - Thread.sleep(500); - } catch (InterruptedException e) { - log.println("While waiting :" + e) ; - } - } - - /** - * Check document types - */ - public void checkDocs() { - Object doc = param.get("DocType"); - String testDocType; - if (doc == null) - testDocType = "all"; - else - testDocType = (String)doc; - - System.out.println("Param was " + doc); - System.out.println("DocType " + testDocType); - if (testDocType.equalsIgnoreCase("writer") || testDocType.equalsIgnoreCase("all")) - checkWriterDoc(); - if (testDocType.equalsIgnoreCase("math") || testDocType.equalsIgnoreCase("all")) - checkMathDoc(); - if (testDocType.equalsIgnoreCase("draw") || testDocType.equalsIgnoreCase("all")) - checkDrawDoc(); - if (testDocType.equalsIgnoreCase("impress") || testDocType.equalsIgnoreCase("all")) - checkImpressDoc(); - if (testDocType.equalsIgnoreCase("calc") || testDocType.equalsIgnoreCase("all")) - checkCalcDoc(); - - } - - /** - * Test the interfaces on a writer document - */ - public void checkWriterDoc() { - xMSF = (XMultiServiceFactory)param.getMSF(); - SOfficeFactory xSOF = SOfficeFactory.getFactory(xMSF); - XTextDocument xTextDoc = null; - try { - log.println("****** Open a new writer document"); - xTextDoc = xSOF.createTextDoc("_blank"); - getTestObject(); - } - catch(com.sun.star.uno.Exception e) { - e.printStackTrace(); - } - runAllInterfaceTests(); - - if (xTextDoc != null) { - XCloseable xClose = (XCloseable)UnoRuntime.queryInterface(XCloseable.class, xTextDoc); - try { - xClose.close(false); - } - catch(com.sun.star.util.CloseVetoException e) { - e.printStackTrace(); - } - } - } - - /** - * Test the interfaces on a math document - */ - public void checkMathDoc() { - xMSF = (XMultiServiceFactory)param.getMSF(); - SOfficeFactory xSOF = SOfficeFactory.getFactory(xMSF); - XComponent xMathDoc = null; - try { - log.println("****** Open a new math document"); - xMathDoc = xSOF.createMathDoc("_blank"); - getTestObject(); - } - catch(com.sun.star.uno.Exception e) { - e.printStackTrace(); - } - runAllInterfaceTests(); - - if (xMathDoc != null) { - XCloseable xClose = (XCloseable)UnoRuntime.queryInterface(XCloseable.class, xMathDoc); - try { - xClose.close(false); - } - catch(com.sun.star.util.CloseVetoException e) { - e.printStackTrace(); - } - } - } - - /** - * Test the interfaces on a draw document - */ - public void checkDrawDoc() { - xMSF = (XMultiServiceFactory)param.getMSF(); - SOfficeFactory xSOF = SOfficeFactory.getFactory(xMSF); - XComponent xDrawDoc = null; - try { - log.println("****** Open a new draw document"); - xDrawDoc = xSOF.createDrawDoc("_blank"); - getTestObject(); - } - catch(com.sun.star.uno.Exception e) { - e.printStackTrace(); - } - runAllInterfaceTests(); - - if (xDrawDoc != null) { - XCloseable xClose = (XCloseable)UnoRuntime.queryInterface(XCloseable.class, xDrawDoc); - try { - xClose.close(false); - } - catch(com.sun.star.util.CloseVetoException e) { - e.printStackTrace(); - } - } - } - - /** - * Test the interfaces on an impress document - */ - public void checkImpressDoc() { - xMSF = (XMultiServiceFactory)param.getMSF(); - SOfficeFactory xSOF = SOfficeFactory.getFactory(xMSF); - XComponent xImpressDoc = null; - try { - log.println("****** Open a new impress document"); - xImpressDoc = xSOF.createImpressDoc("_blank"); - getTestObject(); - } - catch(com.sun.star.uno.Exception e) { - e.printStackTrace(); - } - runAllInterfaceTests(); - - if (xImpressDoc != null) { - XCloseable xClose = (XCloseable)UnoRuntime.queryInterface(XCloseable.class, xImpressDoc); - try { - xClose.close(false); - } - catch(com.sun.star.util.CloseVetoException e) { - e.printStackTrace(); - } - } - } - /** - * Test the interfaces on an calc document - */ - public void checkCalcDoc() { - xMSF = (XMultiServiceFactory)param.getMSF(); - SOfficeFactory xSOF = SOfficeFactory.getFactory(xMSF); - XSpreadsheetDocument xSpreadsheetDoc = null; - try { - log.println("****** Open a new calc document"); - xSpreadsheetDoc = xSOF.createCalcDoc("_blank"); - shortWait(); - getTestObject(); - } - catch(com.sun.star.uno.Exception e) { - e.printStackTrace(); - } - runAllInterfaceTests(); - - if (xSpreadsheetDoc != null) { - XCloseable xClose = (XCloseable)UnoRuntime.queryInterface(XCloseable.class, xSpreadsheetDoc); - try { - xClose.close(false); - } - catch(com.sun.star.util.CloseVetoException e) { - e.printStackTrace(); - } - } - } - - public void getTestObject() { - try { - XInterface xIfc = (XInterface) xMSF.createInstance( - "com.sun.star.awt.Toolkit") ; - XExtendedToolkit tk = (XExtendedToolkit) - UnoRuntime.queryInterface(XExtendedToolkit.class,xIfc); - - shortWait(); - xWindow = (XWindow)UnoRuntime.queryInterface( - XWindow.class,tk.getActiveTopWindow()); - - shortWait(); - AccessibilityTools at = new AccessibilityTools(); - XAccessible xRoot = at.getAccessibleObject(xWindow); - XAccessibleContext parentContext = null; - - log.println("Get the accessible status bar."); - parentContext = at.getAccessibleObjectForRole( - xRoot, AccessibleRole.STATUS_BAR, ""); - shortWait(); - if ( parentContext == null ) { - log.println("Could not get the test object: set the correct focus in the next 30 seconds."); - shortWait(30000); - parentContext = at.getAccessibleObjectForRole( - xRoot, AccessibleRole.STATUS_BAR, ""); - - if ( parentContext == null ) - failed("Could not create a test object."); - } - log.println("...OK."); - - testObject=parentContext; - } - catch(com.sun.star.uno.Exception e) { - e.printStackTrace(); - } - catch(Throwable t) { - System.out.println("Got throwable:"); - t.printStackTrace(); - } - } - - public void runAllInterfaceTests() { - int count = testObject.getAccessibleChildCount(); - log.println("*****"); - log.println("**** Found items to test: " + count); - for (int i=0;i<count;i++){ - log.println("**** Now testing StatusBarItem " + i + "."); - XAccessible object = null; - try { - object = testObject.getAccessibleChild(i); - } - catch(com.sun.star.lang.IndexOutOfBoundsException e) { - System.out.println("* Cannot get item Nr: " + i); - continue; - } - XServiceInfo xSI = (XServiceInfo)UnoRuntime.queryInterface( - XServiceInfo.class,object); - String[] services = xSI.getSupportedServiceNames(); - log.println("* Implementation Name: " + xSI.getImplementationName()); - String accName = object.getAccessibleContext().getAccessibleName(); - log.println("* Accessible Name: " + accName); - for (int j=0; i<services.length; i++) - log.println("* ServiceName "+i+": "+ services[j]); - log.println("*****"); - - log.println("*** Now testing XAccessibleComponent ***"); - _XAccessibleComponent _xAccCompTest = - new _XAccessibleComponent(object, log); - assure("failed: "+accName+" - XAccessibleComponent::getBounds", _xAccCompTest._getBounds(), true); - assure("failed: "+accName+" - XAccessibleComponent::contains", _xAccCompTest._containsPoint(), true); - assure("failed: "+accName+" - XAccessibleComponent::getAccessibleAt", _xAccCompTest._getAccessibleAtPoint(), true); - assure("failed: "+accName+" - XAccessibleComponent::getBackground", _xAccCompTest._getBackground(), true); - assure("failed: "+accName+" - XAccessibleComponent::getForeground", _xAccCompTest._getForeground(), true); - assure("failed: "+accName+" - XAccessibleComponent::getLocation", _xAccCompTest._getLocation(), true); - assure("failed: "+accName+" - XAccessibleComponent::getLocationOnScreen", _xAccCompTest._getLocationOnScreen(), true); - assure("failed: "+accName+" - XAccessibleComponent::getSize", _xAccCompTest._getSize(), true); - assure("failed: "+accName+" - XAccessibleComponent::grabFocus", _xAccCompTest._grabFocus(), true); - - log.println("*** Now testing XAccessibleContext ***"); - _XAccessibleContext _xAccContext = - new _XAccessibleContext(object, log); - assure("failed: "+accName+" - XAccessibleContext::getAccessibleChildCount", _xAccContext._getAccessibleChildCount(), true); - assure("failed: "+accName+" - XAccessibleContext::getAccessibleChild", _xAccContext._getAccessibleChild(), true); - assure("failed: "+accName+" - XAccessibleContext::getAccessibleDescription", _xAccContext._getAccessibleDescription(), true); - assure("failed: "+accName+" - XAccessibleContext::getAccessibleName", _xAccContext._getAccessibleName(), true); - assure("failed: "+accName+" - XAccessibleContext::getAccessibleParent", _xAccContext._getAccessibleParent(), true); - assure("failed: "+accName+" - XAccessibleContext::getAccessibleIndexInParent", _xAccContext._getAccessibleIndexInParent(), true); - assure("failed: "+accName+" - XAccessibleContext::getAccessibleRelationSet", _xAccContext._getAccessibleRelationSet(), true); - assure("failed: "+accName+" - XAccessibleContext::getAccessibleRole", _xAccContext._getAccessibleRole(), true); - assure("failed: "+accName+" - XAccessibleContext::getAccessibleStateSet", _xAccContext._getAccessibleStateSet(), true); - assure("failed: "+accName+" - XAccessibleContext::getLocale", _xAccContext._getLocale(), true); - - log.println("*** Now testing XAccessibleExtendedComponent ***"); - _XAccessibleExtendedComponent _xAccExtComp = - new _XAccessibleExtendedComponent(object, log); - assure("failed: "+accName+" - XAccessibleExtendedComponent::getFont", _xAccExtComp._getFont(), true); - assure("failed: "+accName+" - XAccessibleExtendedComponent::getTitledBorderText", _xAccExtComp._getTitledBorderText(), true); - assure("failed: "+accName+" - XAccessibleExtendedComponent::getToolTipText", _xAccExtComp._getToolTipText(), true); - - log.println("*** Now testing XAccessibleEventBroadcaster ***"); - _XAccessibleEventBroadcaster _xAccEvBcast = - new _XAccessibleEventBroadcaster(object, log, "Pfff", xWindow); - assure("failed: "+accName+" - XAccessibleEventBroadcaster::addEventListener", _xAccEvBcast._addEventListener(), true); - assure("failed: "+accName+" - XAccessibleEventBroadcaster::removeEventListener", _xAccEvBcast._removeEventListener(), true); - - log.println("*** Now testing XAccessibleText ***"); - _XAccessibleText _xAccText = - new _XAccessibleText(object, log, xMSF, "true"); - assure("failed: "+accName+" - XAccessibleText::getText", _xAccText._getText(), true); - assure("failed: "+accName+" - XAccessibleText::getCharacterCount", _xAccText._getCharacterCount(), true); - assure("failed: "+accName+" - XAccessibleText::getCharacterBounds", _xAccText._getCharacterBounds(), true); - assure("failed: "+accName+" - XAccessibleText::setSelection", _xAccText._setSelection(), true); - assure("failed: "+accName+" - XAccessibleText::copyText", _xAccText._copyText(), true); - assure("failed: "+accName+" - XAccessibleText::getCharacter", _xAccText._getCharacter(), true); - assure("failed: "+accName+" - XAccessibleText::getCharacterAttributes", _xAccText._getCharacterAttributes(), true); - assure("failed: "+accName+" - XAccessibleText::getIndexAtPoint", _xAccText._getIndexAtPoint(), true); - assure("failed: "+accName+" - XAccessibleText::getSelectedText", _xAccText._getSelectedText(), true); - assure("failed: "+accName+" - XAccessibleText::getSelectionEnd", _xAccText._getSelectionEnd(), true); - assure("failed: "+accName+" - XAccessibleText::getSelectionStart", _xAccText._getSelectionStart(), true); - assure("failed: "+accName+" - XAccessibleText::getTextAtIndex", _xAccText._getTextAtIndex(), true); - assure("failed: "+accName+" - XAccessibleText::getTextBeforeIndex", _xAccText._getTextBeforeIndex(), true); - assure("failed: "+accName+" - XAccessibleText::getBehindIndex", _xAccText._getTextBehindIndex(), true); - assure("failed: "+accName+" - XAccessibleText::getTextRange", _xAccText._getTextRange(), true); - assure("failed: "+accName+" - XAccessibleText::setCaretPosition", _xAccText._setCaretPosition(), true); - assure("failed: "+accName+" - XAccessibleText::getCaretPosition", _xAccText._getCaretPosition(), true); - } - } - -} diff --git a/toolkit/qa/complex/toolkit/CheckAsyncCallback.java b/toolkit/qa/complex/toolkit/CheckAsyncCallback.java deleted file mode 100644 index cc184f3c1a73..000000000000 --- a/toolkit/qa/complex/toolkit/CheckAsyncCallback.java +++ /dev/null @@ -1,127 +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. - * - ************************************************************************/ - -package complex.toolkit; - -import complexlib.ComplexTestCase; -import util.SOfficeFactory; -import complex.toolkit.interface_tests._XRequestCallback; -import complex.toolkit.CallbackClass; -import com.sun.star.awt.XRequestCallback; -import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.lang.XComponent; -import com.sun.star.lang.XServiceInfo; -import com.sun.star.uno.XInterface; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.awt.XExtendedToolkit; -import java.io.PrintWriter; - -/** - * - */ -public class CheckAsyncCallback extends ComplexTestCase { - - - XInterface testObject = null; - XMultiServiceFactory xMSF = null; - - public String[] getTestMethodNames() { - return new String[]{"checkService"}; - } - -/* public String getTestObjectName() { - return "com.sun.star.awt.AccessibleStatusBar"; - } -*/ - /** - * Sleeps for 0.5 sec. to allow StarOffice to react on <code> - * reset</code> call. - */ - private void shortWait() { - try { - Thread.sleep(500) ; - } catch (InterruptedException e) { - log.println("While waiting :" + e) ; - } - } - - /** - * Check services - */ - public void checkService() { - checkAsyncCallbackService(); - - } - - /** - * Test the interfaces - */ - public void checkAsyncCallbackService() { - runAllInterfaceTests(); - } - - public void getTestObject() { - try { - xMSF = (XMultiServiceFactory)param.getMSF(); - SOfficeFactory xSOF = SOfficeFactory.getFactory(xMSF); - - XRequestCallback xAsyncCallback = null; - - XInterface xIfc = (XInterface)xMSF.createInstance( - "com.sun.star.awt.AsyncCallback" ); - xAsyncCallback = (XRequestCallback) - UnoRuntime.queryInterface(XRequestCallback.class,xIfc); - - testObject=xAsyncCallback; - } - catch(com.sun.star.uno.Exception e) { - e.printStackTrace(); - } - catch(Throwable t) { - System.out.println("Got throwable:"); - t.printStackTrace(); - } - } - - public void runAllInterfaceTests() { - getTestObject(); - log.println("*** Now testing XRequestCallback ***"); - _XRequestCallback _xRequestCallback = - new _XRequestCallback(testObject, log, xMSF ); - assure("failed: XRequestCallback::addCallback", _xRequestCallback._addCallback()); - } - - public void checkCallback() { - getTestObject(); - log.println("*** Now testing asynchronous callback service ***"); - XRequestCallback xAsyncCallback = null; - xAsyncCallback = (XRequestCallback) - UnoRuntime.queryInterface( XRequestCallback.class, testObject ); - CallbackClass aCallbackClass = new CallbackClass( log, xMSF ); - xAsyncCallback.addCallback( aCallbackClass, null ); - } -} diff --git a/toolkit/qa/complex/toolkit/GridControl.java b/toolkit/qa/complex/toolkit/GridControl.java new file mode 100755 index 000000000000..a06a52342417 --- /dev/null +++ b/toolkit/qa/complex/toolkit/GridControl.java @@ -0,0 +1,687 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2011 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + *************************************************************************/ + +package complex.toolkit; + +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlContainer; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.grid.DefaultGridDataModel; +import com.sun.star.awt.grid.XGridColumn; +import com.sun.star.awt.grid.XGridColumnModel; +import com.sun.star.awt.grid.XGridDataModel; +import com.sun.star.awt.grid.XMutableGridDataModel; +import com.sun.star.awt.grid.XSortableMutableGridDataModel; +import com.sun.star.beans.Pair; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.ContainerEvent; +import com.sun.star.container.XContainerListener; +import com.sun.star.container.XNameContainer; +import com.sun.star.lang.EventObject; +import com.sun.star.lang.IndexOutOfBoundsException; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XEventListener; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloneable; +import complex.toolkit.awtgrid.DummyColumn; +import complex.toolkit.awtgrid.TMutableGridDataModel; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.junit.Assert.*; +import org.openoffice.test.OfficeConnection; + +/** is a unit test for the grid control related implementations + * @author frank.schoenheit@sun.com + */ +public class GridControl +{ + // ----------------------------------------------------------------------------------------------------------------- + public GridControl() + { + m_context = m_connection.getComponentContext(); + } + + // ----------------------------------------------------------------------------------------------------------------- + private static void impl_dispose( final Object... i_components ) + { + for ( int i=0; i<i_components.length; ++i ) + { + if ( i_components[i] != null ) + { + final XComponent component = UnoRuntime.queryInterface( XComponent.class, i_components[i] ); + component.dispose(); + } + } + } + + // ----------------------------------------------------------------------------------------------------------------- + private void impl_recreateGridModel() throws Exception + { + impl_dispose( m_gridControlModel, m_columnModel, m_dataModel ); + + // create a grid control model, and ensure it has a proper data and column model already + m_gridControlModel = UnoRuntime.queryInterface( XPropertySet.class, + createInstance( "com.sun.star.awt.grid.UnoControlGridModel" ) ); + assertNotNull( "grid control model does not provide XPropertySet interface", m_gridControlModel ); + + // ensure that the model has default column/data models + m_columnModel = UnoRuntime.queryInterface( XGridColumnModel.class, m_gridControlModel.getPropertyValue( "ColumnModel" ) ); + assertNotNull( "the control model is expected to have an initial column model", m_columnModel ); + final XGridDataModel dataModel = UnoRuntime.queryInterface( XGridDataModel.class, m_gridControlModel.getPropertyValue( "GridDataModel" ) ); + assertNotNull( "the control model is expected to have an initial data model", dataModel ); + m_dataModel = UnoRuntime.queryInterface( XSortableMutableGridDataModel.class, + dataModel ); + assertNotNull( "the out-of-the-box data model should be mutable and sortable", m_dataModel ); + } + + // ----------------------------------------------------------------------------------------------------------------- + @Test + public void testGridControlCloning() throws Exception + { + impl_recreateGridModel(); + + // give the test something to compare, actually + XGridColumnModel columnModel = UnoRuntime.queryInterface( XGridColumnModel.class, + m_gridControlModel.getPropertyValue( "ColumnModel" ) ); + columnModel.setDefaultColumns( 10 ); + + // clone the grid model + final XCloneable cloneable = UnoRuntime.queryInterface( XCloneable.class, m_gridControlModel ); + assertNotNull( "all UnoControlModel's are expected to be cloneable", cloneable ); + + final XInterface clone = cloneable.createClone(); + final XPropertySet clonedProps = UnoRuntime.queryInterface( XPropertySet.class, clone ); + + // TODO: check all those generic properties for equality + + // the data model and the column model should have been cloned, too + // in particular, the clone should not share the sub models with the orignal + final XMutableGridDataModel originalDataModel = UnoRuntime.queryInterface( XMutableGridDataModel.class, + m_gridControlModel.getPropertyValue( "GridDataModel" ) ); + final XMutableGridDataModel clonedDataModel = UnoRuntime.queryInterface( XMutableGridDataModel.class, + clonedProps.getPropertyValue( "GridDataModel" ) ); + assertFalse( "data model should not be shared after cloning", UnoRuntime.areSame( originalDataModel, clonedDataModel ) ); + impl_assertEquality( originalDataModel, clonedDataModel ); + + final XGridColumnModel originalColumnModel = columnModel; + final XGridColumnModel clonedColumnModel = UnoRuntime.queryInterface( XGridColumnModel.class, + clonedProps.getPropertyValue( "ColumnModel" ) ); + assertFalse( "column model should not be shared after cloning", UnoRuntime.areSame( originalColumnModel, clonedColumnModel ) ); + impl_assertEquality( originalColumnModel, clonedColumnModel ); + } + + // ----------------------------------------------------------------------------------------------------------------- + @Test + public void testDisposal() throws Exception + { + impl_recreateGridModel(); + + final int columnCount = 3; + m_columnModel.setDefaultColumns( columnCount ); + + // add disposal listeners to all columns so far + final XGridColumn[] columns = m_columnModel.getColumns(); + assertEquals( "creating default columns resulted in unexpected column count", columnCount, columns.length ); + final DisposeListener[] columnListeners = new DisposeListener[columnCount]; + for ( int i=0; i<columnCount; ++i ) + columnListeners[i] = new DisposeListener( columns[i] ); + + // add another column, and check that upon removal, it is disposed + final int newColumnIndex = m_columnModel.addColumn( m_columnModel.createColumn() ); + final DisposeListener columnListener = new DisposeListener( m_columnModel.getColumn( newColumnIndex ) ); + m_columnModel.removeColumn( newColumnIndex ); + assertTrue( "explicit column removal is expected to dispose the column", columnListener.isDisposed() ); + + // by definition, the grid control model is the owner of both the column and the data model. So, setting + // a new column/data model should implicitly dispose the old models + final DisposeListener oldDataModelListener = new DisposeListener( m_dataModel ); + final DisposeListener oldColumnModelListener = new DisposeListener( m_columnModel ); + + final Object newDataModel = createInstance( "com.sun.star.awt.grid.DefaultGridDataModel" ); + final Object newColumnModel = createInstance( "com.sun.star.awt.grid.DefaultGridColumnModel" ); + final DisposeListener newDataModelListener = new DisposeListener( newDataModel ); + final DisposeListener newColumnModelListener = new DisposeListener( newColumnModel ); + + m_gridControlModel.setPropertyValue( "GridDataModel", newDataModel ); + assertTrue( "setting a new data model failed", impl_areSameInterface( newDataModel, m_gridControlModel.getPropertyValue( "GridDataModel" ) ) ); + m_gridControlModel.setPropertyValue( "ColumnModel", newColumnModel ); + assertTrue( "setting a new column model failed", impl_areSameInterface( newColumnModel, m_gridControlModel.getPropertyValue( "ColumnModel" ) ) ); + + assertTrue( "old data model has not been disposed", oldDataModelListener.isDisposed() ); + assertTrue( "old column model has not been disposed", oldColumnModelListener.isDisposed() ); + for ( int i=0; i<columnCount; ++i ) + assertTrue( "column no. " + i + " has not been disposed", columnListeners[i].isDisposed() ); + + // the same holds if the grid control model itself is disposed - it should dispose the depending models, too + assertFalse( "new data model is already disposed - this is unexpected", newDataModelListener.isDisposed() ); + assertFalse( "new column model is already disposed - this is unexpected", newColumnModelListener.isDisposed() ); + impl_dispose( m_gridControlModel ); + assertTrue( "new data model is not disposed after disposing the grid column model", newDataModelListener.isDisposed() ); + assertTrue( "new column model is not disposed after disposing the grid column model", newColumnModelListener.isDisposed() ); + } + + // ----------------------------------------------------------------------------------------------------------------- + /** + * tests various aspects of the <code>XMutableGridDataModel</code> interface + */ + @Test + public void testMutableGridDataModel() throws Exception + { + impl_recreateGridModel(); + + TMutableGridDataModel test = new TMutableGridDataModel( m_dataModel ); + test.testAddRow(); + test.testAddRows(); + test.testRemoveRow(); + test.testRemoveAllRows(); + test.testUpdateCellData(); + test.testUpdateRowData(); + test.testUpdateRowHeading(); + test.cleanup(); + + // a somehwat less straight-forward test: the data model is expected to implicitly increase its column count + // when you add a row which has more columns than currently known + final XMutableGridDataModel dataModel = DefaultGridDataModel.create( m_context ); + dataModel.addRow( 0, new Object[] { 1 } ); + assertEquals( "unexpected column count after adding the most simple row", 1, dataModel.getColumnCount() ); + dataModel.addRow( 1, new Object[] { 1, 2 } ); + assertEquals( "implicit extension of the column count doesn't work", 2, dataModel.getColumnCount() ); + } + + // ----------------------------------------------------------------------------------------------------------------- + @Test + public void testGridColumnModel() throws Exception + { + impl_recreateGridModel(); + + ColumnModelListener listener = new ColumnModelListener(); + m_columnModel.addContainerListener( listener ); + + // insert default columns into the previously empty model, ensure we get the right notifications + final int defaultColumnsCount = 3; + m_columnModel.setDefaultColumns( defaultColumnsCount ); + impl_assertColumnModelConsistency(); + List< ContainerEvent > events = listener.assertExclusiveInsertionEvents(); + listener.reset(); + assertEquals( "wrong number of events fired by setDefaulColumns", defaultColumnsCount, events.size() ); + for ( int i=0; i<defaultColumnsCount; ++i ) + { + final ContainerEvent event = events.get(i); + final int index = impl_assertInteger( event.Accessor ); + assertEquals( "unexpected Accessor value in insert notification", i, index ); + assertTrue( "wrong column object notified in insert notification", + impl_areSameInterface( event.Element, m_columnModel.getColumn(i) ) ); + } + + // insert some more default columns, ensure that all previously existing columns are removed + final int moreDefaultColumnsCount = 5; + m_columnModel.setDefaultColumns( moreDefaultColumnsCount ); + impl_assertColumnModelConsistency(); + assertEquals( "setting default columns is expected to remove all previously existing columns", + moreDefaultColumnsCount, m_columnModel.getColumnCount() ); + + // in this situation, both removal and insertion events have been notified + final List< ContainerEvent > removalEvents = listener.getRemovalEvents(); + final List< ContainerEvent > insertionEvents = listener.getInsertionEvents(); + listener.reset(); + + // for the removal events, check the indexes + assertEquals( "wrong number of columns removed (or notified) upon setting default columns", + defaultColumnsCount, removalEvents.size() ); + for ( int i=0; i<removalEvents.size(); ++i ) + { + final ContainerEvent event = removalEvents.get(i); + final int removedIndex = impl_assertInteger( event.Accessor ); + + // The implementation is allowed to remove the columns from the beginning, in which case the + // index of the removed column must always be 0, since e.g. the second column has index 0 + // after the first column (which previously had index 0) had been removed. + // Alternatively, the implementation is allowed to remove columns from the end, which means + // that the column index given in the event is steadily increasing. + assertTrue( "unexpected column removal event column index", + ( removedIndex == 0 ) || ( removedIndex == removalEvents.size() - 1 - i ) ); + } + + // for the insertion events, check the indexes as well + assertEquals( "wrong number of insertion events when setting default columns over existing columns", + moreDefaultColumnsCount, insertionEvents.size() ); + for ( int i=0; i<insertionEvents.size(); ++i ) + { + final ContainerEvent event = insertionEvents.get(i); + final int index = impl_assertInteger( event.Accessor ); + assertEquals( i, index ); + } + + // okay, remove all those columns + while ( m_columnModel.getColumnCount() != 0 ) + { + final int columnCount = m_columnModel.getColumnCount(); + final int removeColumnIndex = m_randomGenerator.nextInt( columnCount ); + m_columnModel.removeColumn( removeColumnIndex ); + events = listener.assertExclusiveRemovalEvents(); + listener.reset(); + assertEquals( "removing a single column should notify a single event", 1, events.size() ); + final ContainerEvent event = events.get(0); + final int removalIndex = impl_assertInteger( event.Accessor ); + assertEquals( "removing an arbitrary column does not notify the proper accessor", + removeColumnIndex, removalIndex ); + } + + // calling addColumn with a column not created by the given model/implementatoion should not succeed + boolean caughtExpected = false; + try + { + m_columnModel.addColumn( new DummyColumn() ); + } + catch( final com.sun.star.lang.IllegalArgumentException e ) + { + assertTrue( impl_areSameInterface( e.Context, m_columnModel ) ); + caughtExpected = true; + } + assertTrue( "adding a dummy (self-implemented) grid column to the model should not succeed", caughtExpected ); + + // adding a single column to the end should succeed, properly notify, and still be consistent + final XGridColumn newColumn = m_columnModel.createColumn(); + m_columnModel.addColumn( newColumn ); + impl_assertColumnModelConsistency(); + events = listener.assertExclusiveInsertionEvents(); + listener.reset(); + assertEquals( "addColumn notifies the wrong number of insertion events", 1, events.size() ); + final int insertionIndex = impl_assertInteger( events.get(0).Accessor ); + assertEquals( insertionIndex, newColumn.getIndex() ); + } + + // ----------------------------------------------------------------------------------------------------------------- + @Test + public void testSortableDataModel() throws Exception + { + impl_recreateGridModel(); + + final int colCount = 3; + final int rowCount = 10; + // initialize with some data + final Object[][] data = new Object[][] { + new Object[] { 15, 17, 0 }, + new Object[] { 9, 8, 14 }, + new Object[] { 17, 2, 16 }, + new Object[] { 0, 7, 14 }, + new Object[] { 10, 16, 16 }, + new Object[] { 2, 8, 10 }, + new Object[] { 4, 8, 3 }, + new Object[] { 7, 9, 0 }, + new Object[] { 15, 6, 19 }, + new Object[] { 2, 14, 19 } + }; + final Object[] rowHeadings = new Object[] { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 + }; + // ensure consistency of the test data + assertEquals( rowHeadings.length, rowCount ); + assertEquals( data.length, rowCount ); + for ( Object[] rowData : data ) + assertEquals( rowData.length, colCount ); + + // add the test data + m_dataModel.addRows( rowHeadings, data ); + assertEquals( rowCount, m_dataModel.getRowCount() ); + assertEquals( colCount, m_dataModel.getColumnCount() ); + + // sort by each column + for ( int colIndex = 0; colIndex < colCount; ++colIndex ) + { + for ( boolean ascending : new boolean[] { true, false } ) + { + m_dataModel.sortByColumn( colIndex, ascending ); + Pair currentSortOrder = m_dataModel.getCurrentSortOrder(); + assertEquals( "invalid current sort column (column " + colIndex + ")", ((Integer)currentSortOrder.First).intValue(), colIndex ); + assertEquals( "invalid current sort direction", ((Boolean)currentSortOrder.Second).booleanValue(), ascending ); + + /*for ( int i=0; i<rowCount; ++i ) + { + for ( int j=0; j<colCount; ++j ) + System.out.print( m_dataModel.getCellData( j, i ).toString() + ", " ); + System.out.println(); + }*/ + + // verify the data is actually sorted by this column + for ( int rowIndex = 0; rowIndex < rowCount - 1; ++rowIndex ) + { + final Object currentValue = m_dataModel.getCellData( colIndex, rowIndex ); + final int currentIntValue = impl_assertInteger( currentValue ); + final Object nextValue = m_dataModel.getCellData( colIndex, rowIndex + 1 ); + final int nextIntValue = impl_assertInteger( nextValue ); + assertTrue( "data in row " + rowIndex + " is actually not sorted " + ( ascending ? "ascending" : "descending" ), + ascending ? currentIntValue <= nextIntValue + : currentIntValue >= nextIntValue ); + + // ensure the data in the other columns, and the row headings, are sorted as well + final Object rowHeading = m_dataModel.getRowHeading( rowIndex ); + final int unsortedRowIndex = impl_assertInteger( rowHeading ); + for ( int innerColIndex = 0; innerColIndex < colCount; ++innerColIndex ) + { + assertEquals( "sorted row " + rowIndex + ", unsorted row " + unsortedRowIndex + ", col " + innerColIndex + + ": wrong data", + data[unsortedRowIndex][innerColIndex], m_dataModel.getCellData( innerColIndex, rowIndex ) ); + } + } + } + } + } + + // ----------------------------------------------------------------------------------------------------------------- + @Test + public void testModelViewInteraction() throws Exception + { + final List< Object > disposables = new ArrayList< Object >(); + try + { + // create a siple dialog model/control/peer trinity + final XControlModel dialogModel = createInstance( XControlModel.class, "com.sun.star.awt.UnoControlDialogModel" ); + disposables.add( dialogModel ); + final XPropertySet dialogProps = UnoRuntime.queryInterface( XPropertySet.class, dialogModel ); + dialogProps.setPropertyValue( "Width", 200 ); + dialogProps.setPropertyValue( "Height", 100 ); + dialogProps.setPropertyValue( "Title", "Grid Control Unit Test" ); + final XControl dialogControl = createInstance( XControl.class, "com.sun.star.awt.UnoControlDialog" ); + disposables.add( dialogControl ); + dialogControl.setModel( dialogModel ); + dialogControl.createPeer( createInstance( XToolkit.class, "com.sun.star.awt.Toolkit" ), null ); + + // insert a grid control model + final XMultiServiceFactory controlModelFactory = UnoRuntime.queryInterface( XMultiServiceFactory.class, + dialogModel ); + XPropertySet gridModelProps = UnoRuntime.queryInterface( XPropertySet.class, + controlModelFactory.createInstance( "com.sun.star.awt.grid.UnoControlGridModel" ) ); + disposables.add( gridModelProps ); + gridModelProps.setPropertyValue( "PositionX", 6 ); + gridModelProps.setPropertyValue( "PositionY", 6 ); + gridModelProps.setPropertyValue( "Width", 188 ); + gridModelProps.setPropertyValue( "Height", 88 ); + final XNameContainer modelContainer = UnoRuntime.queryInterface( XNameContainer.class, dialogModel ); + modelContainer.insertByName( "grid", gridModelProps ); + + // check the respective control has been created + final XControlContainer controlContainer = UnoRuntime.queryInterface( XControlContainer.class, dialogControl ); + final XControl gridControl = controlContainer.getControl( "grid" ); + assertNotNull( "no grid control created in the dialog", gridControl ); + + // in the current implementation (not sure this is a good idea at all), the control (more precise: the peer) + // ensures that if there are no columns in the column model, but in the data model, then the column model + // will implicitly have the needed columns added. + // To ensure that clients which rely on this do not break in the future, check this here. + final XMutableGridDataModel dataModel = UnoRuntime.queryInterface( XMutableGridDataModel.class, + gridModelProps.getPropertyValue( "GridDataModel" ) ); + assertNotNull( dataModel ); + assertEquals( 0, dataModel.getColumnCount() ); + + final XGridColumnModel columnModel = UnoRuntime.queryInterface( XGridColumnModel.class, + gridModelProps.getPropertyValue( "ColumnModel" ) ); + assertNotNull( columnModel ); + assertEquals( 0, columnModel.getColumnCount() ); + + dataModel.addRow( null, new Object[] { 1, 2, 3 } ); + assertEquals( 3, dataModel.getColumnCount() ); + assertEquals( 3, columnModel.getColumnCount() ); + } + finally + { + impl_dispose( disposables.toArray()); + } + } + + // ----------------------------------------------------------------------------------------------------------------- + private int impl_assertInteger( final Object i_object ) + { + assertTrue( i_object instanceof Integer ); + return ((Integer)i_object).intValue(); + } + + // ----------------------------------------------------------------------------------------------------------------- + private void impl_assertColumnModelConsistency() throws IndexOutOfBoundsException + { + for ( int col = 0; col < m_columnModel.getColumnCount(); ++col ) + { + final XGridColumn column = m_columnModel.getColumn( col ); + assertNotNull( column ); + assertEquals( "column/model inconsistency: column " + col + " has a wrong index!", col, column.getIndex() ); + } + + final XGridColumn[] allColumns = m_columnModel.getColumns(); + assertEquals( "getColumns returns the wrong number of column objects", + m_columnModel.getColumnCount(), allColumns.length ); + for ( int col = 0; col < m_columnModel.getColumnCount(); ++col ) + { + assertTrue( "getColumns inconsistency", impl_areSameInterface( allColumns[col], m_columnModel.getColumn(col) ) ); + } + } + + // ----------------------------------------------------------------------------------------------------------------- + private void impl_assertEquality( final XGridDataModel i_reference, final XGridDataModel i_compare ) throws IndexOutOfBoundsException + { + assertNotNull( i_reference ); + assertNotNull( i_compare ); + + assertEquals( "data model comparison: wrong column counts", i_reference.getColumnCount(), i_compare.getColumnCount() ); + assertEquals( "data model comparison: wrong row counts", i_reference.getRowCount(), i_compare.getRowCount() ); + + for ( int row = 0; row < i_reference.getRowCount(); ++row ) + { + assertEquals( "data model comparison: wrong row heading content in row " + row, + i_reference.getRowHeading( row ) ); + for ( int col = 0; col < i_reference.getRowCount(); ++col ) + { + assertEquals( "data model comparison: wrong cell content in cell (" + col + ", " + row + ")", + i_reference.getCellData( col, row ) ); + assertEquals( "data model comparison: wrong tooltip content in cell (" + col + ", " + row + ")", + i_reference.getCellToolTip( col, row ) ); + } + } + } + + // ----------------------------------------------------------------------------------------------------------------- + private void impl_assertEquality( final XGridColumnModel i_reference, final XGridColumnModel i_compare ) throws IndexOutOfBoundsException + { + assertEquals( "column model comparison: wrong column counts", i_reference.getColumnCount(), i_compare.getColumnCount() ); + for ( int col = 0; col < i_reference.getColumnCount(); ++col ) + { + final XGridColumn referenceColumn = i_reference.getColumn( col ); + final XGridColumn compareColumn = i_compare.getColumn( col ); + impl_assertEquality( referenceColumn, compareColumn ); + } + } + + // ----------------------------------------------------------------------------------------------------------------- + private void impl_assertEquality( final XGridColumn i_reference, final XGridColumn i_compare ) + { + final Method[] methods = XGridColumn.class.getMethods(); + for ( int m=0; m<methods.length; ++m ) + { + if ( !methods[m].getName().startsWith( "get" ) ) + continue; + try + { + final Object referenceValue = methods[m].invoke( i_reference ); + final Object compareValue = methods[m].invoke( i_compare ); + assertEquals( "grid column comparison: column attribute '" + methods[m].getName().substring(3) + "' does not match", + referenceValue, compareValue ); + } + catch ( java.lang.Exception ex ) + { + fail( " could not retrieve object attributes: " + ex.toString() ); + } + } + } + + // ----------------------------------------------------------------------------------------------------------------- + private boolean impl_areSameInterface( final Object i_lhs, final Object i_rhs ) + { + final XInterface lhs = UnoRuntime.queryInterface( XInterface.class, i_lhs ); + final XInterface rhs = UnoRuntime.queryInterface( XInterface.class, i_rhs ); + return UnoRuntime.areSame( lhs, rhs ); + } + + // ----------------------------------------------------------------------------------------------------------------- + @BeforeClass + public static void setUpConnection() throws java.lang.Exception + { + System.out.println( "--------------------------------------------------------------------------------" ); + System.out.println( "starting class: " + GridControl.class.getName() ); + System.out.print( "connecting ... " ); + m_connection.setUp(); + System.out.println( "done."); + + final long seed = m_randomGenerator.nextLong(); + m_randomGenerator.setSeed( seed ); + System.out.println( "seeding random number generator with " + seed ); + } + + // ----------------------------------------------------------------------------------------------------------------- + @AfterClass + public static void tearDownConnection() + throws InterruptedException, com.sun.star.uno.Exception + { + System.out.println(); + System.out.println( "tearing down connection" ); + m_connection.tearDown(); + System.out.println( "finished class: " + GridControl.class.getName() ); + System.out.println( "--------------------------------------------------------------------------------" ); + } + + // ----------------------------------------------------------------------------------------------------------------- + public <T> T createInstance( Class<T> i_interfaceClass, final String i_serviceIndentifer ) throws Exception + { + return UnoRuntime.queryInterface( i_interfaceClass, createInstance( i_serviceIndentifer ) ); + } + + // ----------------------------------------------------------------------------------------------------------------- + private Object createInstance( final String i_serviceName ) throws Exception + { + Object instance = m_context.getServiceManager().createInstanceWithContext( i_serviceName, m_context ); + assertNotNull( "could not create an instance of '" + i_serviceName + "'", instance ); + return instance; + } + // ----------------------------------------------------------------------------------------------------------------- + private static final class DisposeListener implements XEventListener + { + DisposeListener( final Object i_component ) + { + m_component = UnoRuntime.queryInterface( XComponent.class, i_component ); + assertNotNull( m_component ); + m_component.addEventListener( this ); + } + + public void disposing( EventObject i_event ) + { + assertTrue( UnoRuntime.areSame( i_event.Source, m_component ) ); + m_isDisposed = true; + } + + final boolean isDisposed() { return m_isDisposed; } + + private final XComponent m_component; + private boolean m_isDisposed; + }; + + // ----------------------------------------------------------------------------------------------------------------- + private static final class ColumnModelListener implements XContainerListener + { + ColumnModelListener() + { + } + + public void elementInserted( ContainerEvent i_event ) + { + m_insertionEvents.add( i_event ); + } + + public void elementRemoved( ContainerEvent i_event ) + { + m_removalEvents.add( i_event ); + } + + public void elementReplaced( ContainerEvent i_event ) + { + m_replacementEvents.add( i_event ); + } + + public void disposing( EventObject eo ) + { + m_isDisposed = true; + } + + private List< ContainerEvent > assertExclusiveInsertionEvents() + { + assertFalse( m_insertionEvents.isEmpty() ); + assertTrue( m_removalEvents.isEmpty() ); + assertTrue( m_replacementEvents.isEmpty() ); + return m_insertionEvents; + } + + private List< ContainerEvent > assertExclusiveRemovalEvents() + { + assertTrue( m_insertionEvents.isEmpty() ); + assertFalse( m_removalEvents.isEmpty() ); + assertTrue( m_replacementEvents.isEmpty() ); + return m_removalEvents; + } + + private void reset() + { + m_insertionEvents = new ArrayList< ContainerEvent >(); + m_removalEvents = new ArrayList< ContainerEvent >(); + m_replacementEvents = new ArrayList< ContainerEvent >(); + } + + private List< ContainerEvent > getInsertionEvents() { return m_insertionEvents; } + private List< ContainerEvent > getRemovalEvents() { return m_removalEvents; } + + final boolean isDisposed() { return m_isDisposed; } + + private List< ContainerEvent > m_insertionEvents = new ArrayList< ContainerEvent >(); + private List< ContainerEvent > m_removalEvents = new ArrayList< ContainerEvent >(); + private List< ContainerEvent > m_replacementEvents = new ArrayList< ContainerEvent >(); + private boolean m_isDisposed = false; + }; + + // ----------------------------------------------------------------------------------------------------------------- + private static final OfficeConnection m_connection = new OfficeConnection(); + private static Random m_randomGenerator = new Random(); + private final XComponentContext m_context; + + private XPropertySet m_gridControlModel; + private XGridColumnModel m_columnModel; + private XSortableMutableGridDataModel m_dataModel; +} diff --git a/toolkit/qa/complex/toolkit/UnitConversion.java b/toolkit/qa/complex/toolkit/UnitConversion.java new file mode 100644 index 000000000000..b4cf8a8e1490 --- /dev/null +++ b/toolkit/qa/complex/toolkit/UnitConversion.java @@ -0,0 +1,247 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package complex.toolkit; + +import com.sun.star.awt.XUnitConversion; +import com.sun.star.uno.UnoRuntime; + +import com.sun.star.awt.XWindow; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.awt.XWindowPeer; + +import util.DesktopTools; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openoffice.test.OfficeConnection; +import static org.junit.Assert.*; + +/** + * This complex test is only for testing the com.sun.star.awt.XUnitConversion methods + * These are converter methods to get the size of a well known awt component + * in a com.sun.star.util.MeasureUnit you want. + * You don't need to know the factors to calculate by hand. + * + * @author ll93751 + */ +public class UnitConversion +{ + /** + * returns the delta value between a and b + * @param a + * @param b + * @return + */ + private int delta(int a, int b) + { + final int n = Math.abs(a - b); + return n; + } + + private XUnitConversion m_xConversion = null; + + /** + * Not really a check, + * only a simple test call to convertSizeToLogic(...) with different parameters + * @param _aSize + * @param _aMeasureUnit + * @param _sEinheit + */ + private void checkSize(com.sun.star.awt.Size _aSize, short _aMeasureUnit, String _sEinheit) + { + try + { + com.sun.star.awt.Size aSizeIn = m_xConversion.convertSizeToLogic(_aSize, _aMeasureUnit); + System.out.println("Window size:"); + System.out.println("Width:" + aSizeIn.Width + " " + _sEinheit); + System.out.println("Height:" + aSizeIn.Height + " " + _sEinheit); + System.out.println(""); + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + System.out.println("Caught IllegalArgumentException in convertSizeToLogic with '" + _sEinheit + "' " + e.getMessage()); + } + } + + /** + * The real test function + * 1. try to get the XMultiServiceFactory of an already running office. Therefore make sure an (open|star)office is running with + * parameters like -accept="socket,host=localhost,port=8100;urp;" + * 2. try to create an empty window + * 3. try to convert the WindowPeer to an XWindow + * 4. try to resize and move the window to an other position, so we get a well knowing position and size. + * 5. run some more tests + * + * If no test fails, the test is well done and returns with 'PASSED, OK' + * + */ + @Test + public void testXUnitConversion() + { + final XMultiServiceFactory xMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager()); + + assertNotNull("failed: There is no office.", xMSF); + + // create a window + XWindowPeer xWindowPeer = DesktopTools.createFloatingWindow(xMSF); + assertNotNull("failed: there is no window peer", xWindowPeer); + + + // resize and move the window to a well known position and size + XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, xWindowPeer); + assertNotNull("failed: there is no window, cast wrong?", xWindow); + + xWindow.setVisible(Boolean.TRUE); + + int x = 100; + int y = 100; + int width = 640; + int height = 480; + xWindow.setPosSize(x, y, width, height, com.sun.star.awt.PosSize.POSSIZE); + + com.sun.star.awt.Rectangle aRect = xWindow.getPosSize(); + com.sun.star.awt.Point aPoint = new com.sun.star.awt.Point(aRect.X, aRect.Y); + com.sun.star.awt.Size aSize = new com.sun.star.awt.Size(aRect.Width, aRect.Height); + + System.out.println("Window position and size in pixel:"); + System.out.println("X:" + aPoint.X); + System.out.println("Y:" + aPoint.Y); + System.out.println("Width:" + aSize.Width); + System.out.println("Height:" + aSize.Height); + System.out.println(""); + + assertTrue("Window pos size wrong", aSize.Width == width && aSize.Height == height && aPoint.X == x && aPoint.Y == y); + + m_xConversion = UnoRuntime.queryInterface(XUnitConversion.class, xWindowPeer); + + // try to get the position of the window in 1/100mm with the XUnitConversion method + try + { + com.sun.star.awt.Point aPointInMM_100TH = m_xConversion.convertPointToLogic(aPoint, com.sun.star.util.MeasureUnit.MM_100TH); + System.out.println("Window position:"); + System.out.println("X:" + aPointInMM_100TH.X + " 1/100mm"); + System.out.println("Y:" + aPointInMM_100TH.Y + " 1/100mm"); + System.out.println(""); + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + fail("failed: IllegalArgumentException caught in convertPointToLogic " + e.getMessage()); + } + + // try to get the size of the window in 1/100mm with the XUnitConversion method + com.sun.star.awt.Size aSizeInMM_100TH = null; + com.sun.star.awt.Size aSizeInMM_10TH = null; + try + { + aSizeInMM_100TH = m_xConversion.convertSizeToLogic(aSize, com.sun.star.util.MeasureUnit.MM_100TH); + System.out.println("Window size:"); + System.out.println("Width:" + aSizeInMM_100TH.Width + " 1/100mm"); + System.out.println("Height:" + aSizeInMM_100TH.Height + " 1/100mm"); + System.out.println(""); + + // try to get the size of the window in 1/10mm with the XUnitConversion method + + aSizeInMM_10TH = m_xConversion.convertSizeToLogic(aSize, com.sun.star.util.MeasureUnit.MM_10TH); + System.out.println("Window size:"); + System.out.println("Width:" + aSizeInMM_10TH.Width + " 1/10mm"); + System.out.println("Height:" + aSizeInMM_10TH.Height + " 1/10mm"); + System.out.println(""); + + // check the size with a delta which must be smaller a given difference + assertTrue("Size.Width not correct", delta(aSizeInMM_100TH.Width, aSizeInMM_10TH.Width * 10) < 10); + assertTrue("Size.Height not correct", delta(aSizeInMM_100TH.Height, aSizeInMM_10TH.Height * 10) < 10); + + // new + checkSize(aSize, com.sun.star.util.MeasureUnit.PIXEL, "pixel"); + checkSize(aSize, com.sun.star.util.MeasureUnit.APPFONT, "appfont"); + checkSize(aSize, com.sun.star.util.MeasureUnit.SYSFONT, "sysfont"); + + // simply check some more parameters + checkSize(aSize, com.sun.star.util.MeasureUnit.MM, "mm"); + checkSize(aSize, com.sun.star.util.MeasureUnit.CM, "cm"); + checkSize(aSize, com.sun.star.util.MeasureUnit.INCH_1000TH, "1/1000inch"); + checkSize(aSize, com.sun.star.util.MeasureUnit.INCH_100TH, "1/100inch"); + checkSize(aSize, com.sun.star.util.MeasureUnit.INCH_10TH, "1/10inch"); + checkSize(aSize, com.sun.star.util.MeasureUnit.INCH, "inch"); + // checkSize(aSize, com.sun.star.util.MeasureUnit.M, "m"); + checkSize(aSize, com.sun.star.util.MeasureUnit.POINT, "point"); + checkSize(aSize, com.sun.star.util.MeasureUnit.TWIP, "twip"); + // checkSize(aSize, com.sun.star.util.MeasureUnit.KM, "km"); + // checkSize(aSize, com.sun.star.util.MeasureUnit.PICA, "pica"); + // checkSize(aSize, com.sun.star.util.MeasureUnit.FOOT, "foot"); + // checkSize(aSize, com.sun.star.util.MeasureUnit.MILE, "mile"); + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + fail("failed: IllegalArgumentException caught in convertSizeToLogic " + e.getMessage()); + } + + // convert the 1/100mm window size back to pixel + try + { + com.sun.star.awt.Size aNewSize = m_xConversion.convertSizeToPixel(aSizeInMM_100TH, com.sun.star.util.MeasureUnit.MM_100TH); + System.out.println("Window size:"); + System.out.println("Width:" + aNewSize.Width + " pixel"); + System.out.println("Height:" + aNewSize.Height + " pixel"); + + // assure the pixels are the same as we already know + assertTrue("failed: Size from pixel to 1/100mm to pixel", aSize.Width == aNewSize.Width && aSize.Height == aNewSize.Height); + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + fail("failed: IllegalArgumentException caught in convertSizeToPixel " + e.getMessage()); + } + + // close the window. + // IMHO a little bit stupid, but the XWindow doesn't support a XCloseable interface + xWindow.dispose(); + } + + @BeforeClass + public static void setUpConnection() throws Exception + { + System.out.println( "--------------------------------------------------------------------------------" ); + System.out.println( "starting class: " + UnitConversion.class.getName() ); + System.out.println( "connecting ..." ); + connection.setUp(); + } + + @AfterClass + public static void tearDownConnection() + throws InterruptedException, com.sun.star.uno.Exception + { + System.out.println(); + System.out.println( "tearing down connection" ); + connection.tearDown(); + System.out.println( "finished class: " + UnitConversion.class.getName() ); + System.out.println( "--------------------------------------------------------------------------------" ); + } + + private static final OfficeConnection connection = new OfficeConnection(); +} diff --git a/toolkit/qa/complex/toolkit/interface_tests/_XAccessibleComponent.java b/toolkit/qa/complex/toolkit/accessibility/_XAccessibleComponent.java index 5c3a58c35f16..d1025979a0bf 100644 --- a/toolkit/qa/complex/toolkit/interface_tests/_XAccessibleComponent.java +++ b/toolkit/qa/complex/toolkit/accessibility/_XAccessibleComponent.java @@ -25,9 +25,8 @@ * ************************************************************************/ -package complex.toolkit.interface_tests; +package complex.toolkit.accessibility; -import share.LogWriter; import com.sun.star.awt.Point; import com.sun.star.awt.Rectangle; import com.sun.star.awt.Size; @@ -56,7 +55,7 @@ import java.util.Vector; */ public class _XAccessibleComponent { - private LogWriter log; + // private LogWriter log; public XAccessibleComponent oObj = null; @@ -67,11 +66,12 @@ public class _XAccessibleComponent { /** * Constructor + * @param object */ - public _XAccessibleComponent(XInterface object, LogWriter log) { - oObj = (XAccessibleComponent)UnoRuntime.queryInterface( + public _XAccessibleComponent(XInterface object/*, LogWriter log*/) { + oObj = UnoRuntime.queryInterface( XAccessibleComponent.class, object); - this.log = log; + // this.log = log; } /** @@ -87,7 +87,8 @@ public class _XAccessibleComponent { * <ul> * <li> <code> getBounds() </code> : to have size of a component.</li> * </ul> - */ + * @return + */ public boolean _containsPoint() { boolean result = true ; @@ -96,13 +97,13 @@ public class _XAccessibleComponent { //while (!oObj.containsPoint(new Point(curX, bounds.Y)) && curX < bounds.Width+bounds.X) { while (!oObj.containsPoint(new Point(curX, 0)) && curX < bounds.Width) { curX++; - }; + } //if ((bounds.X <= curX) && (curX < bounds.Width+bounds.X)) { if (curX < bounds.Width) { - log.println("Upper bound of box contains point (" + System.out.println("Upper bound of box contains point (" + curX + ",0) - OK"); } else { - log.println + System.out.println ("Upper bound of box contains no component points - FAILED"); result = false; } @@ -112,15 +113,15 @@ public class _XAccessibleComponent { while (!oObj.containsPoint(new Point(curX, bounds.Height - 1)) && curX < bounds.Width) { - log.println("Contains returns false for ("+curX+","+bounds.Height+")"); + System.out.println("Contains returns false for ("+curX+","+bounds.Height+")"); curX++; - }; + } //if ((bounds.X <= curX) && (curX < bounds.Width+bounds.X)) { if (curX < bounds.Width) { - log.println("Lower bound of box contains point (" + System.out.println("Lower bound of box contains point (" + curX + "," + (bounds.Height - 1) + ") - OK"); } else { - log.println + System.out.println ("Lower bound of box contains no component points - FAILED"); result = false; } @@ -129,13 +130,13 @@ public class _XAccessibleComponent { //while (!oObj.containsPoint(new Point(bounds.X, curY)) && curY < bounds.Height+bounds.Y) { while (!oObj.containsPoint(new Point(0, curY)) && curY < bounds.Height) { curY++; - }; + } //if ((bounds.Y <= curY) && (curY < bounds.Height+bounds.Y)) { if (curY < bounds.Height) { - log.println("Left bound of box contains point (0," + System.out.println("Left bound of box contains point (0," + curY + ") - OK"); } else { - log.println + System.out.println ("Left bound of box contains no component points - FAILED"); result = false; } @@ -145,13 +146,13 @@ public class _XAccessibleComponent { // && curY < bounds.Height+bounds.Y) { while (!oObj.containsPoint(new Point(bounds.Width - 1, curY)) && curY < bounds.Height) { curY++; - }; + } //if ((bounds.Y <= curY) && (curY < bounds.Height + bounds.Y)) { if (curY < bounds.Height) { - log.println("Right bound of box contains point (" + System.out.println("Right bound of box contains point (" + (bounds.Width - 1) + "," + curY + ") - OK"); } else { - log.println + System.out.println ("Right bound of box contains no component points - FAILED"); result = false; } @@ -162,10 +163,10 @@ public class _XAccessibleComponent { locRes &= !oObj.containsPoint(new Point(x, bounds.Height+bounds.Y)); } if (locRes) { - log.println("Outer upper and lower bounds contain no component " + System.out.println("Outer upper and lower bounds contain no component " + "points - OK"); } else { - log.println("Outer upper and lower bounds CONTAIN some component " + System.out.println("Outer upper and lower bounds CONTAIN some component " + "points - FAILED"); result = false; } @@ -176,10 +177,10 @@ public class _XAccessibleComponent { locRes &= !oObj.containsPoint(new Point(bounds.X+bounds.Width, y)); } if (locRes) { - log.println("Outer left and right bounds contain no component " + System.out.println("Outer left and right bounds contain no component " + "points - OK"); } else { - log.println("Outer left and right bounds CONTAIN some component " + System.out.println("Outer left and right bounds CONTAIN some component " + "points - FAILED"); result = false; } @@ -198,6 +199,7 @@ public class _XAccessibleComponent { * Has <b> OK </b> status if in the first cases the right children * are returned, and in the second <code>null</code> or * another child is returned. + * @return */ public boolean _getAccessibleAtPoint() { @@ -207,23 +209,26 @@ public class _XAccessibleComponent { if (children.length > 0) { for (int i = 0; i < children.length; i++) { Rectangle chBnd = children[i].getBounds(); - if (chBnd.X == -1) continue; - log.println("Checking child with bounds " + + if (chBnd.X == -1) + { + continue; + } + System.out.println("Checking child with bounds " + "(" + chBnd.X + "," + chBnd.Y + "),(" + chBnd.Width + "," + chBnd.Height + "): " + util.AccessibilityTools.accessibleToString(children[i])); - log.println("finding the point which lies on the component"); + System.out.println("finding the point which lies on the component"); int curX = 0; int curY = 0; while (!children[i].containsPoint(new Point(curX, curY)) && curX < chBnd.Width) { curX++; curY++; - }; + } if (curX==chBnd.Width) { - log.println("Couldn't find a point with contains"); + System.out.println("Couldn't find a point with contains"); continue; } @@ -231,29 +236,29 @@ public class _XAccessibleComponent { XAccessible xAcc = oObj.getAccessibleAtPoint (new Point(chBnd.X , chBnd.Y)); if (xAcc == null) { - log.println("The child not found at point (" + System.out.println("The child not found at point (" + (chBnd.X ) + "," + chBnd.Y + ") - FAILED"); result = false; } else { - XAccessible xAccCh = (XAccessible) UnoRuntime.queryInterface + XAccessible xAccCh = UnoRuntime.queryInterface (XAccessible.class, children[i]); - log.println("Child found at point (" + System.out.println("Child found at point (" + (chBnd.X ) + "," + chBnd.Y + ") - OK"); boolean res = util.AccessibilityTools.equals(xAccCh, xAcc); if (!res) { int expIndex = xAccCh.getAccessibleContext().getAccessibleIndexInParent(); int gotIndex = xAcc.getAccessibleContext().getAccessibleIndexInParent(); if (expIndex < gotIndex) { - log.println("The children found is not the same"); - log.println("The expected child " + + System.out.println("The children found is not the same"); + System.out.println("The expected child " + xAccCh.getAccessibleContext().getAccessibleName()); - log.println("is hidden behind the found Child "); - log.println(xAcc.getAccessibleContext().getAccessibleName()+" - OK"); + System.out.println("is hidden behind the found Child "); + System.out.println(xAcc.getAccessibleContext().getAccessibleName()+" - OK"); } else { - log.println("The children found is not the same - FAILED"); - log.println("Expected: " + System.out.println("The children found is not the same - FAILED"); + System.out.println("Expected: " +xAccCh.getAccessibleContext().getAccessibleName()); - log.println("Found: " + System.out.println("Found: " +xAcc.getAccessibleContext().getAccessibleName()); result = false ; } @@ -264,22 +269,21 @@ public class _XAccessibleComponent { xAcc = oObj.getAccessibleAtPoint (new Point(chBnd.X - 1, chBnd.Y - 1)); if (xAcc == null) { - log.println("No children found at point (" + System.out.println("No children found at point (" + (chBnd.X - 1) + "," + (chBnd.Y - 1) + ") - OK"); result &= true; } else { - XAccessible xAccCh = (XAccessible) UnoRuntime.queryInterface - (XAccessible.class, children[i]); + XAccessible xAccCh = UnoRuntime.queryInterface(XAccessible.class, children[i]); boolean res = util.AccessibilityTools.equals(xAccCh, xAcc); if (res) { - log.println("The same child found outside " + System.out.println("The same child found outside " + "its bounds - FAILED"); result = false ; } } } } else { - log.println("There are no children supporting " + System.out.println("There are no children supporting " + "XAccessibleComponent"); } @@ -291,6 +295,7 @@ public class _XAccessibleComponent { * * Has <b> OK </b> status if boundary position (x,y) is not negative * and size (Width, Height) is greater than 0. + * @return */ public boolean _getBounds() { boolean result = true ; @@ -300,7 +305,7 @@ public class _XAccessibleComponent { && bounds.X >=0 && bounds.Y >=0 && bounds.Width >0 && bounds.Height >0; - log.println("Bounds = " + (bounds != null + System.out.println("Bounds = " + (bounds != null ? "(" + bounds.X + "," + bounds.Y + "),(" + bounds.Width + "," + bounds.Height + ")" : "null")); @@ -317,6 +322,7 @@ public class _XAccessibleComponent { * <ul> * <li> <code> getBounds() </code> : to have bounds </li> * </ul> + * @return */ public boolean _getLocation() { @@ -341,6 +347,7 @@ public class _XAccessibleComponent { * <li> <code> getBounds() </code> : to have location of the component * relative to its parent</li> * </ul> + * @return */ public boolean _getLocationOnScreen() { @@ -348,11 +355,11 @@ public class _XAccessibleComponent { boolean result = true ; Point loc = oObj.getLocationOnScreen(); - log.println("Location is (" + loc.X + "," + loc.Y + ")"); + System.out.println("Location is (" + loc.X + "," + loc.Y + ")"); if (parent != null) { Point parLoc = parent.getLocationOnScreen(); - log.println("Parent location is (" + System.out.println("Parent location is (" + parLoc.X + "," + parLoc.Y + ")"); result &= parLoc.X + bounds.X == loc.X; @@ -371,6 +378,7 @@ public class _XAccessibleComponent { * <ul> * <li> <code> getBounds() </code> </li> * </ul> + * @return */ public boolean _getSize() { @@ -387,6 +395,7 @@ public class _XAccessibleComponent { * Just calls the method. <p> * * Has <b> OK </b> status if no runtime exceptions occurred. + * @return */ public boolean _grabFocus() { @@ -404,26 +413,26 @@ public class _XAccessibleComponent { * such children were not found or some error occurred. */ private XAccessibleComponent[] getChildrenComponents() { - XAccessible xAcc = (XAccessible) UnoRuntime.queryInterface - (XAccessible.class, oObj) ; + XAccessible xAcc = UnoRuntime.queryInterface(XAccessible.class, oObj) ; if (xAcc == null) { - log.println("Component doesn't support XAccessible."); + System.out.println("Component doesn't support XAccessible."); return new XAccessibleComponent[0]; } XAccessibleContext xAccCon = xAcc.getAccessibleContext(); int cnt = xAccCon.getAccessibleChildCount(); // for cases when too many children exist checking only first 50 - if (cnt > 50) cnt = 50 ; + if (cnt > 50) + { + cnt = 50; + } Vector childComp = new Vector(); for (int i = 0; i < cnt; i++) { try { XAccessible child = xAccCon.getAccessibleChild(i); XAccessibleContext xAccConCh = child.getAccessibleContext(); - XAccessibleComponent xChAccComp = (XAccessibleComponent) - UnoRuntime.queryInterface(XAccessibleComponent.class, - xAccConCh); + XAccessibleComponent xChAccComp = UnoRuntime.queryInterface(XAccessibleComponent.class, xAccConCh); if (xChAccComp != null) { childComp.add(xChAccComp) ; } @@ -442,10 +451,9 @@ public class _XAccessibleComponent { * has no parent or some errors occurred. */ private XAccessibleComponent getParentComponent() { - XAccessible xAcc = (XAccessible) UnoRuntime.queryInterface - (XAccessible.class, oObj) ; + XAccessible xAcc = UnoRuntime.queryInterface(XAccessible.class, oObj) ; if (xAcc == null) { - log.println("Component doesn't support XAccessible."); + System.out.println("Component doesn't support XAccessible."); return null; } @@ -453,14 +461,13 @@ public class _XAccessibleComponent { XAccessible xAccPar = xAccCon.getAccessibleParent(); if (xAccPar == null) { - log.println("Component has no accessible parent."); + System.out.println("Component has no accessible parent."); return null; } XAccessibleContext xAccConPar = xAccPar.getAccessibleContext(); - XAccessibleComponent parent = (XAccessibleComponent) - UnoRuntime.queryInterface(XAccessibleComponent.class, xAccConPar); + XAccessibleComponent parent = UnoRuntime.queryInterface(XAccessibleComponent.class, xAccConPar); if (parent == null) { - log.println + System.out.println ("Accessible parent doesn't support XAccessibleComponent"); return null; } @@ -470,19 +477,21 @@ public class _XAccessibleComponent { /** * Just calls the method. + * @return */ public boolean _getForeground() { int forColor = oObj.getForeground(); - log.println("getForeground(): " + forColor); + System.out.println("getForeground(): " + forColor); return true; } /** * Just calls the method. + * @return */ public boolean _getBackground() { int backColor = oObj.getBackground(); - log.println("getBackground(): " + backColor); + System.out.println("getBackground(): " + backColor); return true; } diff --git a/toolkit/qa/complex/toolkit/interface_tests/_XAccessibleContext.java b/toolkit/qa/complex/toolkit/accessibility/_XAccessibleContext.java index 230eb3d098d3..14debda92cd8 100755 --- a/toolkit/qa/complex/toolkit/interface_tests/_XAccessibleContext.java +++ b/toolkit/qa/complex/toolkit/accessibility/_XAccessibleContext.java @@ -25,7 +25,7 @@ * ************************************************************************/ -package complex.toolkit.interface_tests; +package complex.toolkit.accessibility; import com.sun.star.lang.Locale; import com.sun.star.uno.XInterface; @@ -35,9 +35,9 @@ import com.sun.star.accessibility.XAccessible; import com.sun.star.accessibility.XAccessibleContext; import com.sun.star.accessibility.XAccessibleRelationSet; import com.sun.star.accessibility.XAccessibleStateSet; -import com.sun.star.accessibility.AccessibleRelationType; +// import com.sun.star.accessibility.AccessibleRelationType; import util.AccessibilityTools; -import share.LogWriter; +// import share.LogWriter; /** * Testing <code>com.sun.star.accessibility.XAccessibleContext</code> @@ -59,7 +59,7 @@ import share.LogWriter; */ public class _XAccessibleContext { - private LogWriter log; + // private LogWriter log; private static final String className = "com.sun.star.accessibility.XAccessibleContext" ; @@ -69,19 +69,19 @@ public class _XAccessibleContext { private int childCount = 0; private XAccessible parent = null ; - public _XAccessibleContext(XInterface object, LogWriter log) { - oObj = (XAccessibleContext)UnoRuntime.queryInterface( - XAccessibleContext.class, object); - this.log = log; + public _XAccessibleContext(XInterface object) { + oObj = UnoRuntime.queryInterface(XAccessibleContext.class, object); + // this.log = log; } /** * Calls the method and stores the number of children. <p> * Has <b> OK </b> status if non-negative number rutrned. + * @return */ public boolean _getAccessibleChildCount() { childCount = oObj.getAccessibleChildCount(); - log.println("" + childCount + " children found."); + System.out.println("" + childCount + " children found."); return childCount > -1; } @@ -96,40 +96,44 @@ public class _XAccessibleContext { * <li> <code> getAccessibleChildCount() </code> : to have a number of * children </li> * </ul> + * @return */ public boolean _getAccessibleChild() { boolean bOK = true; int counter = childCount; - if (childCount > 500) counter = 500; + if (childCount > 500) + { + counter = 500; + } for (int i = 0; i < counter; i++) { try { XAccessible ch = oObj.getAccessibleChild(i) ; XAccessibleContext chAC = ch.getAccessibleContext(); - log.println(" Child " + i + ": " + + System.out.println(" Child " + i + ": " + chAC.getAccessibleDescription()) ; if (!AccessibilityTools.equals (chAC.getAccessibleParent().getAccessibleContext(), oObj)){ - log.println("Role:"); - log.println("Getting: "+chAC.getAccessibleParent().getAccessibleContext().getAccessibleRole()); - log.println("Expected: "+oObj.getAccessibleRole()); + System.out.println("Role:"); + System.out.println("Getting: "+chAC.getAccessibleParent().getAccessibleContext().getAccessibleRole()); + System.out.println("Expected: "+oObj.getAccessibleRole()); - log.println("ImplementationName:"); - log.println("Getting: "+util.utils.getImplName(chAC.getAccessibleParent().getAccessibleContext())); - log.println("Expected: "+util.utils.getImplName(oObj)); + System.out.println("ImplementationName:"); + System.out.println("Getting: "+util.utils.getImplName(chAC.getAccessibleParent().getAccessibleContext())); + System.out.println("Expected: "+util.utils.getImplName(oObj)); - log.println("The parent of child and component "+ + System.out.println("The parent of child and component "+ "itself differ."); - log.println("Getting(Description): " + System.out.println("Getting(Description): " +chAC.getAccessibleParent().getAccessibleContext().getAccessibleDescription()); - log.println("Expected(Description): " + System.out.println("Expected(Description): " +oObj.getAccessibleDescription()); bOK = false; } else { - log.println("Getting the expected Child -- OK"); + System.out.println("Getting the expected Child -- OK"); } } catch (com.sun.star.lang.IndexOutOfBoundsException e) { e.printStackTrace(); @@ -144,6 +148,7 @@ public class _XAccessibleContext { * Just gets the parent. <p> * * Has <b> OK </b> status if parent is not null. + * @return */ public boolean _getAccessibleParent() { // assume that the component is not ROOT @@ -163,6 +168,7 @@ public class _XAccessibleContext { * <ul> * <li> <code> getAccessibleParent() </code> : to have a parent </li> * </ul> + * @return */ public boolean _getAccessibleIndexInParent() { @@ -174,8 +180,8 @@ public class _XAccessibleContext { bOK &= AccessibilityTools.equals( parentAC.getAccessibleChild(idx).getAccessibleContext(),oObj); if (!bOK) { - log.println("Expected: "+util.utils.getImplName(oObj)); - log.println("Getting: "+util.utils.getImplName( + System.out.println("Expected: "+util.utils.getImplName(oObj)); + System.out.println("Getting: "+util.utils.getImplName( parentAC.getAccessibleChild(idx).getAccessibleContext())); } } catch (com.sun.star.lang.IndexOutOfBoundsException e) { @@ -189,10 +195,11 @@ public class _XAccessibleContext { * Get the accessible role of component. <p> * * Has <b> OK </b> status if non-negative number rutrned. + * @return */ public boolean _getAccessibleRole() { short role = oObj.getAccessibleRole(); - log.println("The role is " + role); + System.out.println("The role is " + role); return role > -1; } @@ -200,10 +207,11 @@ public class _XAccessibleContext { * Get the accessible name of the component. <p> * * Has <b> OK </b> status if the name has non-zero length. + * @return */ public boolean _getAccessibleName() { String name = oObj.getAccessibleName(); - log.println("The name is '" + name + "'"); + System.out.println("The name is '" + name + "'"); return name != null; } @@ -211,10 +219,11 @@ public class _XAccessibleContext { * Get the accessible description of the component. <p> * * Has <b> OK </b> status if the description has non-zero length. + * @return */ public boolean _getAccessibleDescription() { String descr = oObj.getAccessibleDescription(); - log.println("The description is '" + descr + "'"); + System.out.println("The description is '" + descr + "'"); return descr != null; } @@ -222,6 +231,7 @@ public class _XAccessibleContext { * Just gets the set. <p> * * Has <b> OK </b> status if the set is not null. + * @return */ public boolean _getAccessibleRelationSet() { XAccessibleRelationSet set = oObj.getAccessibleRelationSet(); @@ -232,6 +242,7 @@ public class _XAccessibleContext { * Just gets the set. <p> * * Has <b> OK </b> status if the set is not null. + * @return */ public boolean _getAccessibleStateSet() { XAccessibleStateSet set = oObj.getAccessibleStateSet(); @@ -244,12 +255,13 @@ public class _XAccessibleContext { * Has <b> OK </b> status if <code>Country</code> and * <code>Language</code> fields of locale structure * are not empty. + * @return */ public boolean _getLocale() { Locale loc = null ; try { loc = oObj.getLocale(); - log.println("The locale is " + loc.Language + "," + loc.Country); + System.out.println("The locale is " + loc.Language + "," + loc.Country); } catch (IllegalAccessibleComponentStateException e) { e.printStackTrace(); } diff --git a/toolkit/qa/complex/toolkit/interface_tests/_XAccessibleEventBroadcaster.java b/toolkit/qa/complex/toolkit/accessibility/_XAccessibleEventBroadcaster.java index 18a20d02e233..535c7ce36c68 100755 --- a/toolkit/qa/complex/toolkit/interface_tests/_XAccessibleEventBroadcaster.java +++ b/toolkit/qa/complex/toolkit/accessibility/_XAccessibleEventBroadcaster.java @@ -25,7 +25,7 @@ * ************************************************************************/ -package complex.toolkit.interface_tests; +package complex.toolkit.accessibility; import com.sun.star.lang.EventObject; import com.sun.star.awt.Rectangle; @@ -33,13 +33,11 @@ import com.sun.star.awt.PosSize; import com.sun.star.awt.XWindow; import com.sun.star.accessibility.AccessibleEventObject; import com.sun.star.accessibility.XAccessible; -import com.sun.star.accessibility.XAccessibleComponent; import com.sun.star.accessibility.XAccessibleEventBroadcaster; import com.sun.star.accessibility.XAccessibleEventListener; import com.sun.star.accessibility.XAccessibleContext; import com.sun.star.uno.XInterface; import com.sun.star.uno.UnoRuntime; -import share.LogWriter; /** * Testing <code> @@ -62,12 +60,7 @@ import share.LogWriter; */ public class _XAccessibleEventBroadcaster { - private LogWriter log; - private static final String className = - "com.sun.star.accessibility.XAccessibleEventBroadcaster" ; - public XAccessibleEventBroadcaster oObj = null; - public String EventMsg = ""; EventProducer prod = null ; EvListener list = new EvListener(); @@ -97,7 +90,7 @@ public class _XAccessibleEventBroadcaster { private class EvListener implements XAccessibleEventListener { public AccessibleEventObject notifiedEvent = null ; public void notifyEvent(AccessibleEventObject ev) { - log.println("Listener, Event : " + ev.EventId); + System.out.println("Listener, Event : " + ev.EventId); System.out.println("EventID: " + ev.EventId); Object old=ev.OldValue; if (old instanceof com.sun.star.accessibility.XAccessible) { @@ -116,24 +109,25 @@ public class _XAccessibleEventBroadcaster { /** * c'tor + * @param object + * @param eventMessage + * @param window */ - public _XAccessibleEventBroadcaster(XInterface object, LogWriter log, String eventMessage, XWindow window) { - oObj = (XAccessibleEventBroadcaster)UnoRuntime.queryInterface( - XAccessibleEventBroadcaster.class, object); - this.log = log; + public _XAccessibleEventBroadcaster(XInterface object, XWindow window) { + oObj = UnoRuntime.queryInterface(XAccessibleEventBroadcaster.class, object); prod = new EventProducer(window); - EventMsg = eventMessage; } /** * Adds two listeners and fires event by mean of object relation. <p> * Has <b> OK </b> status if both listeners were called + * @return */ public boolean _addEventListener() { - log.println("adding two listeners"); + System.out.println("adding two listeners"); oObj.addEventListener(list); boolean isTransient = chkTransient(oObj); - log.println("fire event"); + System.out.println("fire event"); prod.fireEvent() ; try { @@ -146,15 +140,14 @@ public class _XAccessibleEventBroadcaster { if (list.notifiedEvent == null) { if (!isTransient) { - log.println("listener wasn't called"); + System.out.println("listener wasn't called"); works = false; } else { - log.println("Object is Transient, listener isn't expected to be called"); + System.out.println("Object is Transient, listener isn't expected to be called"); } oObj.removeEventListener(list); } -// log.println(EventMsg); return works; } @@ -168,15 +161,16 @@ public class _XAccessibleEventBroadcaster { * <ul> * <li> <code>addEventListener()</code> : to have added listeners </li> * </ul> + * @return */ public boolean _removeEventListener() { list.notifiedEvent = null; - log.println("remove first listener"); + System.out.println("remove first listener"); oObj.removeEventListener(list); - log.println("fire event"); + System.out.println("fire event"); prod.fireEvent() ; try { @@ -186,7 +180,7 @@ public class _XAccessibleEventBroadcaster { } if (list.notifiedEvent == null) { - log.println("listener wasn't called -- OK"); + System.out.println("listener wasn't called -- OK"); } return list.notifiedEvent == null; @@ -194,8 +188,7 @@ public class _XAccessibleEventBroadcaster { } protected static boolean chkTransient(Object Testcase) { - XAccessibleContext accCon = (XAccessibleContext) - UnoRuntime.queryInterface(XAccessibleContext.class,Testcase); + XAccessibleContext accCon = UnoRuntime.queryInterface(XAccessibleContext.class, Testcase); if (accCon.getAccessibleStateSet().contains( com.sun.star.accessibility.AccessibleStateType.TRANSIENT)){ if (!accCon.getAccessibleParent().getAccessibleContext().getAccessibleStateSet().contains( diff --git a/toolkit/qa/complex/toolkit/interface_tests/_XAccessibleExtendedComponent.java b/toolkit/qa/complex/toolkit/accessibility/_XAccessibleExtendedComponent.java index e022e60d90c0..551b00acada7 100755 --- a/toolkit/qa/complex/toolkit/interface_tests/_XAccessibleExtendedComponent.java +++ b/toolkit/qa/complex/toolkit/accessibility/_XAccessibleExtendedComponent.java @@ -25,16 +25,16 @@ * ************************************************************************/ -package complex.toolkit.interface_tests; +package complex.toolkit.accessibility; -import lib.MultiMethodTest; +// import lib.MultiMethodTest; import com.sun.star.accessibility.XAccessibleExtendedComponent; -import com.sun.star.accessibility.XAccessibleStateSet; -import com.sun.star.accessibility.AccessibleStateType; +// import com.sun.star.accessibility.XAccessibleStateSet; +// import com.sun.star.accessibility.AccessibleStateType; import com.sun.star.awt.XFont; import com.sun.star.uno.XInterface; import com.sun.star.uno.UnoRuntime; -import share.LogWriter; +// import share.LogWriter; /** * Testing <code>com.sun.star.accessibility.XAccessibleExtendedComponent</code> @@ -51,7 +51,7 @@ import share.LogWriter; */ public class _XAccessibleExtendedComponent { - private LogWriter log; + // private LogWriter log; private static final String className = "com.sun.star.accessibility.XAccessibleExtendedComponent" ; @@ -62,38 +62,40 @@ public class _XAccessibleExtendedComponent { return className; } - public _XAccessibleExtendedComponent(XInterface object, LogWriter log) { - oObj = (XAccessibleExtendedComponent)UnoRuntime.queryInterface( - XAccessibleExtendedComponent.class, object); - this.log = log; + public _XAccessibleExtendedComponent(XInterface object/*, LogWriter log*/) { + oObj = UnoRuntime.queryInterface(XAccessibleExtendedComponent.class, object); + // this.log = log; } /** * Just calls the method. + * @return */ public boolean _getFont() { XFont font = oObj.getFont(); - log.println("getFont(): " + font); + System.out.println("getFont(): " + font); return true; } /** * Calls the method and checks returned value. * Has OK status if returned value isn't null. + * @return */ public boolean _getTitledBorderText() { String titleBorderText = oObj.getTitledBorderText(); - log.println("getTitledBorderText(): '" + titleBorderText + "'"); + System.out.println("getTitledBorderText(): '" + titleBorderText + "'"); return titleBorderText != null; } /** * Calls the method and checks returned value. * Has OK status if returned value isn't null. + * @return */ public boolean _getToolTipText() { String toolTipText = oObj.getToolTipText(); - log.println("getToolTipText(): '" + toolTipText + "'"); + System.out.println("getToolTipText(): '" + toolTipText + "'"); return toolTipText != null; } } diff --git a/toolkit/qa/complex/toolkit/interface_tests/_XAccessibleText.java b/toolkit/qa/complex/toolkit/accessibility/_XAccessibleText.java index d6357e8f24bc..a12d93a2d9e2 100755 --- a/toolkit/qa/complex/toolkit/interface_tests/_XAccessibleText.java +++ b/toolkit/qa/complex/toolkit/accessibility/_XAccessibleText.java @@ -25,10 +25,10 @@ * ************************************************************************/ -package complex.toolkit.interface_tests; +package complex.toolkit.accessibility; import com.sun.star.accessibility.XAccessibleText; -import lib.MultiMethodTest; +// import lib.MultiMethodTest; //import lib.StatusException; //import lib.Status; import com.sun.star.beans.PropertyValue; @@ -39,7 +39,7 @@ import com.sun.star.accessibility.AccessibleTextType; import com.sun.star.accessibility.TextSegment; import com.sun.star.uno.XInterface; import com.sun.star.uno.UnoRuntime; -import share.LogWriter; +// import share.LogWriter; /** * Testing <code>com.sun.star.accessibility.XAccessibleText</code> @@ -76,7 +76,7 @@ import share.LogWriter; */ public class _XAccessibleText { - private LogWriter log; + // private LogWriter log; private static final String className = "com.sun.star.accessibility.XAccessibleText" ; @@ -91,11 +91,10 @@ public class _XAccessibleText { String editOnly = null; - public _XAccessibleText(XInterface object, LogWriter log, XMultiServiceFactory xMSF, String editOnly) { - oObj = (XAccessibleText)UnoRuntime.queryInterface( - XAccessibleText.class, object); + public _XAccessibleText(XInterface object, XMultiServiceFactory xMSF, String editOnly) { + oObj = UnoRuntime.queryInterface(XAccessibleText.class, object); this.xMSF = xMSF; - this.log = log; + // this.log = log; this.editOnly = editOnly; } @@ -107,11 +106,12 @@ public class _XAccessibleText { * <ul> * <li> <code>setCaretPosition()</code> </li> * </ul> + * @return */ public boolean _getCaretPosition() { if (editOnly != null) { - log.println(editOnly); + System.out.println(editOnly); return true; } @@ -123,7 +123,7 @@ public class _XAccessibleText { } int carPos = oObj.getCaretPosition(); - log.println("getCaretPosition: " + carPos); + System.out.println("getCaretPosition: " + carPos); res = carPos == (chCount - 1); } return res; @@ -138,36 +138,37 @@ public class _XAccessibleText { * <ul> * <li> <code>getCharacterCount()</code> </li> * </ul> + * @return */ public boolean _setCaretPosition() { boolean res = true; try { - log.println("setCaretPosition(-1):"); + System.out.println("setCaretPosition(-1):"); oObj.setCaretPosition(-1); res &= false; - log.println("exception was expected"); + System.out.println("exception was expected"); } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("expected exception"); + System.out.println("expected exception"); res &= true; } try { - log.println("setCaretPosition(chCount+1):"); + System.out.println("setCaretPosition(chCount+1):"); oObj.setCaretPosition(chCount+1); res &= false; - log.println("exception was expected"); + System.out.println("exception was expected"); } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("expected exception"); + System.out.println("expected exception"); res &= true; } if ( chCount > 0 ) { try { - log.println("setCaretPosition(chCount - 1)"); + System.out.println("setCaretPosition(chCount - 1)"); oObj.setCaretPosition(chCount - 1); res &= true; } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("unexpected exception"); + System.out.println("unexpected exception"); e.printStackTrace(); res &= false; } @@ -186,46 +187,47 @@ public class _XAccessibleText { * <ul> * <li> <code>getCharacterCount()</code> </li> * </ul> + * @return */ public boolean _getCharacter() { boolean res = true; try { - log.println("getCharacter(-1)"); + System.out.println("getCharacter(-1)"); oObj.getCharacter(-1); - log.println("Exception was expected"); + System.out.println("Exception was expected"); res = false; } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("Expected exception"); + System.out.println("Expected exception"); res = true; } try { - log.println("getCharacter(chCount)"); + System.out.println("getCharacter(chCount)"); oObj.getCharacter(chCount); - log.println("Exception was expected"); + System.out.println("Exception was expected"); res &= false; } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("Expected exception"); + System.out.println("Expected exception"); res &= true; } try { - log.println("Checking of every character in the text..."); + System.out.println("Checking of every character in the text..."); boolean isEqCh = true; for(int i = 0; i < chCount; i++) { char ch = oObj.getCharacter(i); isEqCh = ch == text.charAt(i); res &= isEqCh; if (!isEqCh) { - log.println("At the position " + i + + System.out.println("At the position " + i + "was expected character: " + text.charAt(i)); - log.println("but was returned: " + ch); + System.out.println("but was returned: " + ch); break; } } } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("Unexpected exception"); + System.out.println("Unexpected exception"); e.printStackTrace(); res &= false; } @@ -243,38 +245,39 @@ public class _XAccessibleText { * <ul> * <li> <code>getCharacterCount()</code> </li> * </ul> + * @return */ public boolean _getCharacterAttributes() { boolean res = true; try { - log.println("getCharacterAttributes(-1)"); + System.out.println("getCharacterAttributes(-1)"); oObj.getCharacterAttributes(-1, new String[0]); - log.println("Exception was expected"); + System.out.println("Exception was expected"); res &= false; } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("Expected exception"); + System.out.println("Expected exception"); res &= true; } try { - log.println("getCharacterAttributes(chCount)"); + System.out.println("getCharacterAttributes(chCount)"); oObj.getCharacterAttributes(chCount, new String[0]); - log.println("Exception was expected"); + System.out.println("Exception was expected"); res &= false; } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("Expected exception"); + System.out.println("Expected exception"); res &= true; } try { if ( chCount > 0 ) { - log.println("getCharacterAttributes(chCount-1)"); + System.out.println("getCharacterAttributes(chCount-1)"); PropertyValue[] props = oObj.getCharacterAttributes(chCount - 1, new String[0]); res &= props != null; } } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("Unexpected exception"); + System.out.println("Unexpected exception"); e.printStackTrace(); res &= false; } @@ -293,41 +296,42 @@ public class _XAccessibleText { * <ul> * <li> <code>getCharacterCount()</code> </li> * </ul> + * @return */ public boolean _getCharacterBounds() { boolean res = true; try { - log.println("getCharacterBounds(-1)"); + System.out.println("getCharacterBounds(-1)"); oObj.getCharacterBounds(-1); - log.println("Exception was expected"); + System.out.println("Exception was expected"); res &= false; } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("Expected exception"); + System.out.println("Expected exception"); res &= true; } try { - log.println("getCharacterBounds(chCount)"); + System.out.println("getCharacterBounds(chCount)"); oObj.getCharacterBounds(chCount); - log.println("Exception was expected"); + System.out.println("Exception was expected"); res &= false; } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("Expected exception"); + System.out.println("Expected exception"); res &= true; } try { if (chCount > 0) { - log.println("getCharacterBounds(chCount-1)"); + System.out.println("getCharacterBounds(chCount-1)"); chBounds = oObj.getCharacterBounds(chCount-1); res &= chBounds != null; - log.println("rect: " + chBounds.X + ", " + chBounds.Y + ", " + + System.out.println("rect: " + chBounds.X + ", " + chBounds.Y + ", " + chBounds.Width + ", " + chBounds.Height); } } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("Unexpected exception"); + System.out.println("Unexpected exception"); e.printStackTrace(); res &= false; } @@ -340,10 +344,11 @@ public class _XAccessibleText { * Calls the method and stores a returned value to the variable * <code>chCount</code>. * Has OK status if a returned value is equal to the text length. + * @return */ public boolean _getCharacterCount() { chCount = oObj.getCharacterCount(); - log.println("Character count:" + chCount); + System.out.println("Character count:" + chCount); boolean res = chCount == text.length(); return res; } @@ -358,21 +363,22 @@ public class _XAccessibleText { * <ul> * <li> <code>getCharacterBounds()</code> </li> * </ul> + * @return */ public boolean _getIndexAtPoint() { boolean res = true; - log.println("getIndexAtPoint(-1, -1):"); + System.out.println("getIndexAtPoint(-1, -1):"); Point pt = new Point(-1, -1); int index = oObj.getIndexAtPoint(pt); - log.println(Integer.toString(index)); + System.out.println(Integer.toString(index)); res &= index == -1; if (chBounds != null) { pt = new Point(chBounds.X , chBounds.Y ); - log.println("getIndexAtPoint(" + pt.X + ", " + pt.Y + "):"); + System.out.println("getIndexAtPoint(" + pt.X + ", " + pt.Y + "):"); index = oObj.getIndexAtPoint(pt); - log.println(Integer.toString(index)); + System.out.println(Integer.toString(index)); res &= index == (chCount - 1); } @@ -386,40 +392,41 @@ public class _XAccessibleText { * <ul> * <li> <code>setSelection()</code> </li> * </ul> + * @return */ public boolean _getSelectedText() { if (editOnly != null) { - log.println(editOnly); + System.out.println(editOnly); return true; } boolean res = true; try { - log.println("setSelection(0, 0)"); + System.out.println("setSelection(0, 0)"); oObj.setSelection(0, 0); - log.println("getSelectedText():"); + System.out.println("getSelectedText():"); String txt = oObj.getSelectedText(); - log.println("'" + txt + "'"); + System.out.println("'" + txt + "'"); res &= txt.length() == 0; - log.println("setSelection(0, chCount)"); + System.out.println("setSelection(0, chCount)"); oObj.setSelection(0, chCount); - log.println("getSelectedText():"); + System.out.println("getSelectedText():"); txt = oObj.getSelectedText(); - log.println("'" + txt + "'"); + System.out.println("'" + txt + "'"); res &= txt.equals(text); if (chCount > 2) { - log.println("setSelection(1, chCount-1)"); + System.out.println("setSelection(1, chCount-1)"); oObj.setSelection(1, chCount - 1); - log.println("getSelectedText():"); + System.out.println("getSelectedText():"); txt = oObj.getSelectedText(); - log.println("'" + txt + "'"); + System.out.println("'" + txt + "'"); res &= txt.equals(text.substring(1, chCount - 1)); } } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("Unexpected exception"); + System.out.println("Unexpected exception"); e.printStackTrace(); res &= false; } @@ -434,31 +441,32 @@ public class _XAccessibleText { * <ul> * <li> <code>setSelection()</code> </li> * </ul> + * @return */ public boolean _getSelectionStart() { if (editOnly != null) { - log.println(editOnly); + System.out.println(editOnly); return true; } boolean res = true; try { - log.println("setSelection(0, chCount)"); + System.out.println("setSelection(0, chCount)"); oObj.setSelection(0, chCount); int start = oObj.getSelectionStart(); - log.println("getSelectionStart():" + start); + System.out.println("getSelectionStart():" + start); res &= start == 0; if (chCount > 2) { - log.println("setSelection(1, chCount-1)"); + System.out.println("setSelection(1, chCount-1)"); oObj.setSelection(1, chCount - 1); start = oObj.getSelectionStart(); - log.println("getSelectionStart():" + start); + System.out.println("getSelectionStart():" + start); res &= start == 1; } } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("Unexpected exception"); + System.out.println("Unexpected exception"); e.printStackTrace(); res &= false; } @@ -473,31 +481,32 @@ public class _XAccessibleText { * <ul> * <li> <code>setSelection()</code> </li> * </ul> + * @return */ public boolean _getSelectionEnd() { if (editOnly != null) { - log.println(editOnly); + System.out.println(editOnly); return true; } boolean res = true; try { - log.println("setSelection(0, chCount)"); + System.out.println("setSelection(0, chCount)"); oObj.setSelection(0, chCount); int end = oObj.getSelectionEnd(); - log.println("getSelectionEnd():" + end); + System.out.println("getSelectionEnd():" + end); res &= end == chCount; if (chCount > 2) { - log.println("setSelection(1, chCount-1)"); + System.out.println("setSelection(1, chCount-1)"); oObj.setSelection(1, chCount - 1); end = oObj.getSelectionEnd(); - log.println("getSelectionEnd():" + end); + System.out.println("getSelectionEnd():" + end); res &= end == chCount - 1; } } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("Unexpected exception"); + System.out.println("Unexpected exception"); e.printStackTrace(); res &= false; } @@ -513,67 +522,68 @@ public class _XAccessibleText { * <ul> * <li> <code>getCharacterCount()</code> </li> * </ul> + * @return */ public boolean _setSelection() { boolean res = true; boolean locRes = true; if (editOnly != null) { - log.println(editOnly); + System.out.println(editOnly); return true; } try { - log.println("setSelection(-1, chCount-1):"); + System.out.println("setSelection(-1, chCount-1):"); locRes = oObj.setSelection(-1, chCount - 1); - log.println(locRes + " exception was expected"); + System.out.println(locRes + " exception was expected"); res &= !locRes; } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("Expected exception"); + System.out.println("Expected exception"); res &= true; } try { - log.println("setSelection(0, chCount+1):"); + System.out.println("setSelection(0, chCount+1):"); locRes = oObj.setSelection(0, chCount + 1); - log.println(locRes + " excepion was expected"); + System.out.println(locRes + " excepion was expected"); res &= !locRes; } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("Expected exception"); + System.out.println("Expected exception"); res &= true; } try { if (chCount > 2) { - log.println("setSelection(1, chCount-1):"); + System.out.println("setSelection(1, chCount-1):"); locRes = oObj.setSelection(1, chCount - 1); - log.println(Boolean.toString(locRes)); + System.out.println(Boolean.toString(locRes)); res &= locRes; - log.println("setSelection(chCount-1, 1):"); + System.out.println("setSelection(chCount-1, 1):"); locRes = oObj.setSelection(chCount - 1, 1); - log.println(Boolean.toString(locRes)); + System.out.println(Boolean.toString(locRes)); res &= locRes; } if (chCount > 1) { - log.println("setSelection(0, chCount-1):"); + System.out.println("setSelection(0, chCount-1):"); locRes = oObj.setSelection(0, chCount-1); - log.println(Boolean.toString(locRes)); + System.out.println(Boolean.toString(locRes)); res &= locRes; - log.println("setSelection(chCount-1, 0):"); + System.out.println("setSelection(chCount-1, 0):"); locRes = oObj.setSelection(chCount-1, 0); - log.println(Boolean.toString(locRes)); + System.out.println(Boolean.toString(locRes)); res &= locRes; } - log.println("setSelection(0, 0):"); + System.out.println("setSelection(0, 0):"); locRes = oObj.setSelection(0, 0); - log.println(Boolean.toString(locRes)); + System.out.println(Boolean.toString(locRes)); res &= locRes; } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("Unexpected exception"); + System.out.println("Unexpected exception"); e.printStackTrace(); res &= false; } @@ -585,10 +595,11 @@ public class _XAccessibleText { * Calls the method and checks returned value. * Has OK status if returned string is not null * received from relation. + * @return */ public boolean _getText() { text = oObj.getText(); - log.println("getText: '" + text + "'"); + System.out.println("getText: '" + text + "'"); return (text != null); } @@ -602,6 +613,7 @@ public class _XAccessibleText { * <ul> * <li> <code>getCharacterCount()</code> </li> * </ul> + * @return */ public boolean _getTextRange() { boolean res = true; @@ -609,75 +621,75 @@ public class _XAccessibleText { try { if (chCount > 3) { - log.println("getTextRange(1, chCount - 2): "); + System.out.println("getTextRange(1, chCount - 2): "); String txtRange = oObj.getTextRange(1, chCount - 2); - log.println(txtRange); + System.out.println(txtRange); locRes = txtRange.equals(text.substring(1, chCount - 2)); res &= locRes; if (!locRes) { - log.println("Was expected: " + + System.out.println("Was expected: " + text.substring(1, chCount - 2)); } } if (chCount > 0) { - log.println("getTextRange(0, chCount-1): "); + System.out.println("getTextRange(0, chCount-1): "); String txtRange = oObj.getTextRange(0, chCount-1); - log.println(txtRange); + System.out.println(txtRange); locRes = txtRange.equals(text.substring(0, chCount - 1)); res &= locRes; if (!locRes) { - log.println("Was expected: " + + System.out.println("Was expected: " + text.substring(0, chCount - 1)); } - log.println("getTextRange(chCount, 0): "); + System.out.println("getTextRange(chCount, 0): "); txtRange = oObj.getTextRange(chCount, 0); - log.println(txtRange); + System.out.println(txtRange); res &= txtRange.equals(text); - log.println("getTextRange(0, 0): "); + System.out.println("getTextRange(0, 0): "); txtRange = oObj.getTextRange(0, 0); - log.println(txtRange); + System.out.println(txtRange); locRes = txtRange.equals(""); res &= locRes; if (!locRes) { - log.println("Empty string was expected"); + System.out.println("Empty string was expected"); } } } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("Unexpected exception"); + System.out.println("Unexpected exception"); e.printStackTrace(); res &= false; } try { - log.println("getTextRange(-1, chCount - 1): "); + System.out.println("getTextRange(-1, chCount - 1): "); String txtRange = oObj.getTextRange(-1, chCount - 1); - log.println("Exception was expected"); + System.out.println("Exception was expected"); res &= false; } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("Expected exception"); + System.out.println("Expected exception"); res &= true; } try { - log.println("getTextRange(0, chCount + 1): "); + System.out.println("getTextRange(0, chCount + 1): "); String txtRange = oObj.getTextRange(0, chCount + 1); - log.println("Exception was expected"); + System.out.println("Exception was expected"); res &= false; } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("Expected exception"); + System.out.println("Expected exception"); res &= true; } try { - log.println("getTextRange(chCount+1, -1): "); + System.out.println("getTextRange(chCount+1, -1): "); String txtRange = oObj.getTextRange(chCount+1, -1); - log.println("Exception was expected"); + System.out.println("Exception was expected"); res &= false; } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("Expected exception"); + System.out.println("Expected exception"); res &= true; } @@ -694,62 +706,63 @@ public class _XAccessibleText { * <ul> * <li> <code>getCharacterCount()</code> </li> * </ul> + * @return */ public boolean _getTextAtIndex() { boolean res = true; try { - log.println("getTextAtIndex(-1, AccessibleTextType.PARAGRAPH):"); + System.out.println("getTextAtIndex(-1, AccessibleTextType.PARAGRAPH):"); TextSegment txt = oObj.getTextAtIndex(-1, AccessibleTextType.PARAGRAPH); - log.println("Exception was expected"); + System.out.println("Exception was expected"); res &= false; } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("Expected exception"); + System.out.println("Expected exception"); res &= true; } catch(com.sun.star.lang.IllegalArgumentException e) { - log.println("Expected exception"); + System.out.println("Expected exception"); res &= true; } try { - log.println("getTextAtIndex(chCount+1," + + System.out.println("getTextAtIndex(chCount+1," + " AccessibleTextType.PARAGRAPH):"); TextSegment txt = oObj.getTextAtIndex(chCount + 1, AccessibleTextType.PARAGRAPH); - log.println("Exception was expected"); + System.out.println("Exception was expected"); res &= false; } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("Expected exception"); + System.out.println("Expected exception"); res &= true; } catch(com.sun.star.lang.IllegalArgumentException e) { - log.println("Expected exception"); + System.out.println("Expected exception"); res &= true; } try { if ( chCount > 0 ) { - log.println("getTextAtIndex(chCount," + + System.out.println("getTextAtIndex(chCount," + " AccessibleTextType.PARAGRAPH):"); TextSegment txt = oObj.getTextAtIndex(chCount, AccessibleTextType.PARAGRAPH); - log.println("'" + txt.SegmentText + "'"); + System.out.println("'" + txt.SegmentText + "'"); res &= txt.SegmentText.length() == 0; - log.println("getTextAtIndex(1," + + System.out.println("getTextAtIndex(1," + " AccessibleTextType.PARAGRAPH):"); txt = oObj.getTextAtIndex(1, AccessibleTextType.PARAGRAPH); - log.println("'" + txt.SegmentText + "'"); + System.out.println("'" + txt.SegmentText + "'"); res &= txt.SegmentText.equals(text); } } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("Unexpected exception"); + System.out.println("Unexpected exception"); e.printStackTrace(); res &= false; } catch(com.sun.star.lang.IllegalArgumentException e) { - log.println("Unexpected exception"); + System.out.println("Unexpected exception"); res &= false; } @@ -767,78 +780,79 @@ public class _XAccessibleText { * <ul> * <li> <code>getCharacterCount()</code> </li> * </ul> + * @return */ public boolean _getTextBeforeIndex() { boolean res = true; try { - log.println("getTextBeforeIndex(-1, AccessibleTextType.PARAGRAPH):"); + System.out.println("getTextBeforeIndex(-1, AccessibleTextType.PARAGRAPH):"); TextSegment txt = oObj.getTextBeforeIndex(-1, AccessibleTextType.PARAGRAPH); - log.println("Exception was expected"); + System.out.println("Exception was expected"); res &= false; } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("Expected exception"); + System.out.println("Expected exception"); res &= true; } catch(com.sun.star.lang.IllegalArgumentException e) { - log.println("Expected exception"); + System.out.println("Expected exception"); res &= true; } try { - log.println("getTextBeforeIndex(chCount+1, " + + System.out.println("getTextBeforeIndex(chCount+1, " + "AccessibleTextType.PARAGRAPH):"); TextSegment txt = oObj.getTextBeforeIndex(chCount + 1, AccessibleTextType.PARAGRAPH); - log.println("Exception was expected"); + System.out.println("Exception was expected"); res &= false; } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("Expected exception"); + System.out.println("Expected exception"); res &= true; } catch(com.sun.star.lang.IllegalArgumentException e) { - log.println("Expected exception"); + System.out.println("Expected exception"); res &= true; } TextSegment txt = null; try { if (chCount > 0) { - log.println("getTextBeforeIndex(chCount," + + System.out.println("getTextBeforeIndex(chCount," + " AccessibleTextType.PARAGRAPH):"); txt = oObj.getTextBeforeIndex(chCount, AccessibleTextType.PARAGRAPH); - log.println("'" + txt.SegmentText + "'"); + System.out.println("'" + txt.SegmentText + "'"); res &= txt.SegmentText.length() == chCount ; - log.println("getTextBeforeIndex(1," + + System.out.println("getTextBeforeIndex(1," + " AccessibleTextType.PARAGRAPH):"); txt = oObj.getTextBeforeIndex(1, AccessibleTextType.PARAGRAPH); - log.println("'" + txt.SegmentText + "'"); + System.out.println("'" + txt.SegmentText + "'"); res &= txt.SegmentText.length() == 0; } if (chCount > 2) { - log.println("getTextBeforeIndex(chCount-1," + + System.out.println("getTextBeforeIndex(chCount-1," + " AccessibleTextType.CHARACTER):"); txt = oObj.getTextBeforeIndex(chCount - 1, AccessibleTextType.CHARACTER); - log.println("'" + txt.SegmentText + "'"); + System.out.println("'" + txt.SegmentText + "'"); res &= txt.SegmentText.equals(text.substring(chCount - 2, chCount - 1)); - log.println("getTextBeforeIndex(2," + + System.out.println("getTextBeforeIndex(2," + " AccessibleTextType.CHARACTER):"); txt = oObj.getTextBeforeIndex(2, AccessibleTextType.CHARACTER); - log.println("'" + txt.SegmentText + "'"); + System.out.println("'" + txt.SegmentText + "'"); res &= txt.SegmentText.equals(text.substring(1, 2)); } } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("Unexpected exception"); + System.out.println("Unexpected exception"); e.printStackTrace(); res &= false; } catch(com.sun.star.lang.IllegalArgumentException e) { - log.println("Unexpected exception"); + System.out.println("Unexpected exception"); res &= false; } @@ -856,79 +870,80 @@ public class _XAccessibleText { * <ul> * <li> <code>getCharacterCount()</code> </li> * </ul> + * @return */ public boolean _getTextBehindIndex() { boolean res = true; try { - log.println("getTextBehindIndex(-1, AccessibleTextType.PARAGRAPH):"); + System.out.println("getTextBehindIndex(-1, AccessibleTextType.PARAGRAPH):"); TextSegment txt = oObj.getTextBehindIndex(-1, AccessibleTextType.PARAGRAPH); - log.println("Exception was expected"); + System.out.println("Exception was expected"); res &= false; } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("Expected exception"); + System.out.println("Expected exception"); res &= true; } catch(com.sun.star.lang.IllegalArgumentException e) { - log.println("Expected exception"); + System.out.println("Expected exception"); res &= true; } try { - log.println("getTextBehindIndex(chCount+1, " + + System.out.println("getTextBehindIndex(chCount+1, " + "AccessibleTextType.PARAGRAPH):"); TextSegment txt = oObj.getTextBehindIndex(chCount + 1, AccessibleTextType.PARAGRAPH); - log.println("Exception was expected"); + System.out.println("Exception was expected"); res &= false; } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("Expected exception"); + System.out.println("Expected exception"); res &= true; } catch(com.sun.star.lang.IllegalArgumentException e) { - log.println("Expected exception"); + System.out.println("Expected exception"); res &= true; } try { if ( chCount > 0 ) { - log.println("getTextBehindIndex(chCount," + + System.out.println("getTextBehindIndex(chCount," + " AccessibleTextType.PARAGRAPH):"); TextSegment txt = oObj.getTextBehindIndex(chCount, AccessibleTextType.PARAGRAPH); - log.println("'" + txt.SegmentText + "'"); + System.out.println("'" + txt.SegmentText + "'"); res &= txt.SegmentText.length() == 0; - log.println("getTextBehindIndex(chCount-1," + + System.out.println("getTextBehindIndex(chCount-1," + " AccessibleTextType.PARAGRAPH):"); txt = oObj.getTextBehindIndex(chCount - 1, AccessibleTextType.PARAGRAPH); - log.println("'" + txt.SegmentText + "'"); + System.out.println("'" + txt.SegmentText + "'"); res &= txt.SegmentText.length() == 0; } if ( chCount > 1 ) { - log.println("getTextBehindIndex(1," + + System.out.println("getTextBehindIndex(1," + " AccessibleTextType.CHARACTER):"); TextSegment txt = oObj.getTextBehindIndex(1, AccessibleTextType.CHARACTER); - log.println("'" + txt.SegmentText + "'"); + System.out.println("'" + txt.SegmentText + "'"); res &= txt.SegmentText.equals(text.substring(2, 3)); } if (chCount > 2) { - log.println("getTextBehindIndex(chCount-2," + + System.out.println("getTextBehindIndex(chCount-2," + " AccessibleTextType.CHARACTER):"); TextSegment txt = oObj.getTextBehindIndex(chCount - 2, AccessibleTextType.CHARACTER); - log.println("'" + txt.SegmentText + "'"); + System.out.println("'" + txt.SegmentText + "'"); res &= txt.SegmentText.equals(text.substring(chCount - 1, chCount)); } } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("Unexpected exception"); + System.out.println("Unexpected exception"); e.printStackTrace(); res &= false; } catch(com.sun.star.lang.IllegalArgumentException e) { - log.println("Unexpected exception"); + System.out.println("Unexpected exception"); res &= false; } @@ -942,40 +957,41 @@ public class _XAccessibleText { * Has OK status if exception was thrown for invalid parameters, * if exception wasn't thrown for valid parameter and if returned value for * valid parameter is equal to <code>true</code>. + * @return */ public boolean _copyText() { boolean res = true; boolean locRes = true; if (editOnly != null) { - log.println(editOnly); + System.out.println(editOnly); return true; } try { - log.println("copyText(-1,chCount):"); + System.out.println("copyText(-1,chCount):"); oObj.copyText(-1, chCount); - log.println("Exception was expected"); + System.out.println("Exception was expected"); res &= false; } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("Expected exception"); + System.out.println("Expected exception"); res &= true; } try { - log.println("copyText(0,chCount+1):"); + System.out.println("copyText(0,chCount+1):"); oObj.copyText(0, chCount + 1); - log.println("Exception was expected"); + System.out.println("Exception was expected"); res &= false; } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("Expected exception"); + System.out.println("Expected exception"); res &= true; } try { - log.println("copyText(0,chCount):"); + System.out.println("copyText(0,chCount):"); locRes = oObj.copyText(0, chCount); - log.println(""+locRes); + System.out.println(""+locRes); res &= locRes; String cbText = null; @@ -983,31 +999,31 @@ public class _XAccessibleText { cbText = util.SysUtils.getSysClipboardText(xMSF); } catch (com.sun.star.uno.Exception e) { - log.println("Couldn't access system clipboard :"); + System.out.println("Couldn't access system clipboard :"); e.printStackTrace(); } - log.println("Clipboard: '" + cbText + "'"); + System.out.println("Clipboard: '" + cbText + "'"); res &= text.equals(cbText); if (chCount > 2) { - log.println("copyText(1,chCount-1):"); + System.out.println("copyText(1,chCount-1):"); locRes = oObj.copyText(1, chCount - 1); - log.println(""+locRes); + System.out.println(""+locRes); res &= locRes; try { cbText = util.SysUtils.getSysClipboardText(xMSF); } catch (com.sun.star.uno.Exception e) { - log.println("Couldn't access system clipboard :"); + System.out.println("Couldn't access system clipboard :"); e.printStackTrace(); } - log.println("Clipboard: '" + cbText + "'"); + System.out.println("Clipboard: '" + cbText + "'"); res &= text.substring(1, chCount - 1).equals(cbText); } } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("Unexpected exception"); + System.out.println("Unexpected exception"); e.printStackTrace(); res &= false; } diff --git a/toolkit/qa/complex/toolkit/awtgrid/DummyColumn.java b/toolkit/qa/complex/toolkit/awtgrid/DummyColumn.java new file mode 100755 index 000000000000..11e4a4b19f80 --- /dev/null +++ b/toolkit/qa/complex/toolkit/awtgrid/DummyColumn.java @@ -0,0 +1,180 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + *************************************************************************/ + +package complex.toolkit.awtgrid; + +import com.sun.star.awt.grid.XGridColumn; +import com.sun.star.awt.grid.XGridColumnListener; +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.lang.XEventListener; +import com.sun.star.style.HorizontalAlignment; +import com.sun.star.util.XCloneable; + +/** + * a dummy implementation of css.awt.grid.XGridColumn + * @author frank.schoenheit@oracle.com + */ +public class DummyColumn implements XGridColumn +{ + public DummyColumn() + { + } + + public Object getIdentifier() + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public void setIdentifier( Object o ) + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public int getColumnWidth() + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public void setColumnWidth( int i ) + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public int getMinWidth() + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public void setMinWidth( int i ) + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public int getMaxWidth() + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public void setMaxWidth( int i ) + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public boolean getResizeable() + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public void setResizeable( boolean bln ) + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public int getFlexibility() + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public void setFlexibility( int i ) throws IllegalArgumentException + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public HorizontalAlignment getHorizontalAlign() + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public void setHorizontalAlign( HorizontalAlignment ha ) + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public String getTitle() + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public void setTitle( String string ) + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public String getHelpText() + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public void setHelpText( String string ) + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public int getIndex() + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public int getDataColumnIndex() + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public void setDataColumnIndex( int i ) + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public void addGridColumnListener( XGridColumnListener xl ) + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public void removeGridColumnListener( XGridColumnListener xl ) + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public void dispose() + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public void addEventListener( XEventListener xl ) + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public void removeEventListener( XEventListener xl ) + { + throw new UnsupportedOperationException( "Not supported yet." ); + } + + public XCloneable createClone() + { + throw new UnsupportedOperationException( "Not supported yet." ); + } +} diff --git a/toolkit/qa/complex/toolkit/awtgrid/GridDataListener.java b/toolkit/qa/complex/toolkit/awtgrid/GridDataListener.java new file mode 100755 index 000000000000..c31f27796cf1 --- /dev/null +++ b/toolkit/qa/complex/toolkit/awtgrid/GridDataListener.java @@ -0,0 +1,98 @@ +package complex.toolkit.awtgrid; + +import com.sun.star.awt.grid.GridDataEvent; +import com.sun.star.awt.grid.XGridDataListener; +import com.sun.star.lang.EventObject; +import static org.junit.Assert.*; + +final public class GridDataListener implements XGridDataListener +{ + public GridDataListener() + { + } + + public void rowsInserted( GridDataEvent i_event ) + { + assertNull( m_rowInsertionEvent ); + m_rowInsertionEvent = i_event; + } + + public void rowsRemoved( GridDataEvent i_event ) + { + assertNull( m_rowRemovalEvent ); + m_rowRemovalEvent = i_event; + } + + public void dataChanged( GridDataEvent i_event ) + { + assertNull( m_dataChangeEvent ); + m_dataChangeEvent = i_event; + } + + public void rowHeadingChanged( GridDataEvent i_event ) + { + assertNull( m_rowHeadingChangeEvent ); + m_rowHeadingChangeEvent = i_event; + } + + public void disposing( EventObject eo ) + { + m_disposed = true; + } + + public final GridDataEvent assertSingleRowInsertionEvent() + { + assertNotNull( m_rowInsertionEvent ); + assertNull( m_rowRemovalEvent ); + assertNull( m_dataChangeEvent ); + assertNull( m_rowHeadingChangeEvent ); + assertFalse( m_disposed ); + return m_rowInsertionEvent; + } + + public final GridDataEvent assertSingleRowRemovalEvent() + { + assertNull( m_rowInsertionEvent ); + assertNotNull( m_rowRemovalEvent ); + assertNull( m_dataChangeEvent ); + assertNull( m_rowHeadingChangeEvent ); + assertFalse( m_disposed ); + return m_rowRemovalEvent; + } + + public final GridDataEvent assertSingleDataChangeEvent() + { + assertNull( m_rowInsertionEvent ); + assertNull( m_rowRemovalEvent ); + assertNotNull( m_dataChangeEvent ); + assertNull( m_rowHeadingChangeEvent ); + assertFalse( m_disposed ); + return m_dataChangeEvent; + } + + public final GridDataEvent assertSingleRowHeadingChangeEvent() + { + assertNull( m_rowInsertionEvent ); + assertNull( m_rowRemovalEvent ); + assertNull( m_dataChangeEvent ); + assertNotNull( m_rowHeadingChangeEvent ); + assertFalse( m_disposed ); + return m_rowHeadingChangeEvent; + } + + public final boolean isDisposed() + { + return m_disposed; + } + + public final void reset() + { + m_rowInsertionEvent = m_rowRemovalEvent = m_dataChangeEvent = m_rowHeadingChangeEvent = null; + // m_disposed is not reset intentionally + } + private GridDataEvent m_rowInsertionEvent = null; + private GridDataEvent m_rowRemovalEvent = null; + private GridDataEvent m_dataChangeEvent = null; + private GridDataEvent m_rowHeadingChangeEvent = null; + private boolean m_disposed = false; +} diff --git a/toolkit/qa/complex/toolkit/awtgrid/TMutableGridDataModel.java b/toolkit/qa/complex/toolkit/awtgrid/TMutableGridDataModel.java new file mode 100755 index 000000000000..c550dd9a047d --- /dev/null +++ b/toolkit/qa/complex/toolkit/awtgrid/TMutableGridDataModel.java @@ -0,0 +1,314 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + *************************************************************************/ + +package complex.toolkit.awtgrid; + +import java.lang.reflect.Method; +import com.sun.star.awt.grid.GridDataEvent; +import com.sun.star.awt.grid.XMutableGridDataModel; +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.lang.IndexOutOfBoundsException; +import static org.junit.Assert.*; +import static complex.toolkit.Assert.*; + +/** test for the <code>css.awt.grid.XMutableGridData</code> interface + * + * @author frank.schoenheit@oracle.com + */ +public class TMutableGridDataModel +{ + public TMutableGridDataModel( final XMutableGridDataModel i_dataModel ) + { + m_dataModel = i_dataModel; + + m_listener = new GridDataListener(); + m_dataModel.addGridDataListener( m_listener ); + } + + /* + * tests the XMutableGridDataModel.addRow method + */ + public void testAddRow() throws IndexOutOfBoundsException + { + m_dataModel.addRow( 1, m_rowValues[0] ); + GridDataEvent event = m_listener.assertSingleRowInsertionEvent(); + m_listener.reset(); + assertEquals( "row insertion: wrong FirstRow (1)", 0, event.FirstRow ); + assertEquals( "row insertion: wrong LastRow (1)", 0, event.LastRow ); + impl_assertRowData( 0 ); + + m_dataModel.addRow( 2, m_rowValues[1] ); + event = m_listener.assertSingleRowInsertionEvent(); + m_listener.reset(); + assertEquals( "row insertion: wrong FirstRow (2)", 1, event.FirstRow ); + assertEquals( "row insertion: wrong LastRow (2)", 1, event.LastRow ); + impl_assertRowData( 1 ); + } + + /** + * tests the XMutableGridDataModel.addRows method + */ + public void testAddRows() throws IndexOutOfBoundsException, IllegalArgumentException + { + assertEquals( "precondition not met: call this directly after testAddRow, please!", 2, m_dataModel.getRowCount() ); + + m_dataModel.addRows( new Object[] { "3", 4.0, "5" }, new Object[][] { m_rowValues[2], m_rowValues[3], m_rowValues[4] } ); + GridDataEvent event = m_listener.assertSingleRowInsertionEvent(); + assertEquals( "row insertion: wrong FirstRow (1)", 2, event.FirstRow ); + assertEquals( "row insertion: wrong LastRow (1)", 4, event.LastRow ); + m_listener.reset(); + + assertEquals( "data model's row count is not adjusted when adding rows", m_rowValues.length, m_dataModel.getRowCount() ); + assertEquals( "data model's column count is not adjusted when adding rows", m_rowValues[0].length, m_dataModel.getColumnCount() ); + for ( int row=0; row<m_rowValues.length; ++row ) + { + for ( int col=0; col<m_rowValues[row].length; ++col ) + { + assertEquals( "added row values are not preserved", + m_rowValues[row][col], m_dataModel.getCellData( col, row ) ); + } + } + + assertException( "addRows is expected to throw when invoked with different-sized arrays", + m_dataModel, "addRows", new Object[] { new Object[0], new Object[1][2] }, IllegalArgumentException.class ); + } + + /** + * tests the XMutableGridDataModel.removeRow method + */ + public void testRemoveRow() throws IndexOutOfBoundsException + { + assertEquals( "precondition not met: call this directly after testAddRows, please!", m_rowValues.length, m_dataModel.getRowCount() ); + + final int rowToRemove = 2; + m_dataModel.removeRow( rowToRemove ); + GridDataEvent event = m_listener.assertSingleRowRemovalEvent(); + assertEquals( "incorrect notification of row removal (FirstRow)", rowToRemove, event.FirstRow ); + assertEquals( "incorrect notification of row removal (LastRow)", rowToRemove, event.LastRow ); + m_listener.reset(); + + assertEquals( "data model's row count does not reflect the removed row", m_rowValues.length - 1, m_dataModel.getRowCount() ); + for ( int row = rowToRemove; row<m_rowValues.length-1; ++row ) + { + for ( int col=0; col<m_rowValues[row].length; ++col ) + { + assertEquals( "unexpected row values after removing a row (col: " + col + ", row: " + row + ")", + m_rowValues[row+1][col], m_dataModel.getCellData( col, row ) ); + } + } + + assertException( "removeRow silently ignores an invalid index (1)", + m_dataModel, "removeRow", new Object[] { -1 }, IndexOutOfBoundsException.class ); + assertException( "removeRow silently ignores an invalid index (2)", + m_dataModel, "removeRow", new Object[] { m_dataModel.getRowCount() }, IndexOutOfBoundsException.class ); + } + + /** + * tests the XMutableGridDataModel.removeAllRows method + */ + public void testRemoveAllRows() + { + assertEquals( "precondition not met: call this directly after testRemoveRow, please!", m_rowValues.length - 1, m_dataModel.getRowCount() ); + + m_dataModel.removeAllRows(); + final GridDataEvent event = m_listener.assertSingleRowRemovalEvent(); + if ( event.FirstRow != -1 ) + { // notifying "-1" is allowed, this means "all rows affected", by definition + assertEquals( "removeAllRows is not notifying properly (1)", 0, event.FirstRow ); + assertEquals( "removeAllRows is not notifying properly (2)", m_rowValues.length - 1, event.LastRow ); + } + m_listener.reset(); + } + + /** + * tests the XMutableGridDataModel.updateCellData method + */ + public void testUpdateCellData() throws IndexOutOfBoundsException, IllegalArgumentException + { + assertEquals( "precondition not met: call this directly after testRemoveAllRows, please!", 0, m_dataModel.getRowCount() ); + + m_dataModel.addRows( new Object[] { 1, 2, 3, 4, 5 }, m_rowValues ); + m_listener.assertSingleRowInsertionEvent(); + m_listener.reset(); + + final Object[][] modifyValues = new Object[][] { + new Object[] { 2, 1, "text" }, + new Object[] { 3, 0, null }, + new Object[] { 0, 4, new Double( 33.0 ) } + }; + for ( int i = 0; i < modifyValues.length; ++i ) + { + final int row = ((Integer)modifyValues[i][0]).intValue(); + final int col = ((Integer)modifyValues[i][1]).intValue(); + final Object value = modifyValues[i][2]; + m_dataModel.updateCellData( col, row, value ); + + final GridDataEvent event = m_listener.assertSingleDataChangeEvent(); + assertEquals( "data change notification: FirstRow is invalid", row, event.FirstRow ); + assertEquals( "data change notification: LastRow is invalid", row, event.LastRow ); + assertEquals( "data change notification: FirstColumn is invalid", col, event.FirstColumn ); + assertEquals( "data change notification: LastColumn is invalid", col, event.LastColumn ); + m_listener.reset(); + + assertEquals( "data change at (" + col + ", " + row + ") not successful", value, m_dataModel.getCellData( col, row ) ); + } + + assertException( "updateCellData silently ignores an invalid index (1)", + m_dataModel, "updateCellData", new Class[] { int.class, int.class, Object.class }, + new Object[] { -1, -1, "text" }, IndexOutOfBoundsException.class ); + assertException( "updateCellData silently ignores an invalid index (2)", + m_dataModel, "updateCellData", new Class[] { int.class, int.class, Object.class }, + new Object[] { 0, m_dataModel.getRowCount(), "text" }, IndexOutOfBoundsException.class ); + assertException( "updateCellData silently ignores an invalid index (3)", + m_dataModel, "updateCellData", new Class[] { int.class, int.class, Object.class }, + new Object[] { m_dataModel.getColumnCount(), 0, "text" }, IndexOutOfBoundsException.class ); + } + + /** + * tests the XMutableGridDataModel.updateRowData method + */ + public void testUpdateRowData() throws IndexOutOfBoundsException, IllegalArgumentException + { + assertEquals( "precondition not met: call this directly after testRemoveAllRows, please!", m_rowValues.length, m_dataModel.getRowCount() ); + + // get data from before the update + final Object[][] preUpdateValues = impl_getCurrentData(); + + // do the update + final int[] colIndexes = new int[] { + 0, 3, 4 + }; + final Object[] values = new Object[] { + 13, null, 42.0 + }; + final int rowToUpdate = 2; + m_dataModel.updateRowData( colIndexes, rowToUpdate, values ); + final GridDataEvent event = m_listener.assertSingleDataChangeEvent(); + assertEquals( "row update notification: FirstRow is invalid", rowToUpdate, event.FirstRow ); + assertEquals( "row update notification: LastRow is invalid", rowToUpdate, event.LastRow ); + assertEquals( "row update notification: FirstColumn is invalid", 0, event.FirstColumn ); + assertEquals( "row update notification: LastColumn is invalid", 4, event.LastColumn ); + m_listener.reset(); + + // reflect the changes made in the pre-update data + for ( int i=0; i<colIndexes.length; ++i ) + { + preUpdateValues[rowToUpdate][colIndexes[i]] = values[i]; + } + + // get data from after the update + final Object[][] postUpdateValues = impl_getCurrentData(); + + // ensure both the manually updated pre-update data and the post-update data are identical + assertArrayEquals( preUpdateValues, postUpdateValues ); + + + assertException( "updateRowData silently ignores an invalid index (1)", + m_dataModel, "updateRowData", new Class[] { int[].class, int.class, Object[].class }, + new Object[] { new int[] { -1 }, 0, new Object[] { "text" } }, IndexOutOfBoundsException.class ); + assertException( "updateRowData silently ignores an invalid index (2)", + m_dataModel, "updateRowData", new Class[] { int[].class, int.class, Object[].class }, + new Object[] { new int[] { 0 }, -1, new Object[] { "" } }, IndexOutOfBoundsException.class ); + assertException( "updateRowData silently ignores different-sized arrays", + m_dataModel, "updateRowData", new Class[] { int[].class, int.class, Object[].class }, + new Object[] { new int[] { 0, 0 }, 0, new Object[] { "" } }, IllegalArgumentException.class ); + } + + /** + * tests the XMutableGridDataModel.updateRowHeading method + */ + public void testUpdateRowHeading() throws IndexOutOfBoundsException + { + assertEquals( "precondition not met: call this directly after testUpdateRowData, please!", m_rowValues.length, m_dataModel.getRowCount() ); + + final Object[] preUpdateHeadings = impl_getCurrentRowHeadings(); + + final int rowToUpdate = 2; + final String valueToUpdate = "some text"; + m_dataModel.updateRowHeading( rowToUpdate, valueToUpdate ); + final GridDataEvent event = m_listener.assertSingleRowHeadingChangeEvent(); + assertEquals( "row heading update notification: FirstRow is invalid", rowToUpdate, event.FirstRow ); + assertEquals( "row heading update notification: FirstRow is invalid", rowToUpdate, event.LastRow ); + m_listener.reset(); + + preUpdateHeadings[rowToUpdate] = valueToUpdate; + + final Object[] postUpdateHeadings = impl_getCurrentRowHeadings(); + assertArrayEquals( preUpdateHeadings, postUpdateHeadings ); + + assertException( "updateRowHeading silently ignores an invalid index", + m_dataModel, "updateRowHeading", new Class[] { int.class, Object.class }, + new Object[] { -1, "" }, IndexOutOfBoundsException.class ); + } + + public void cleanup() + { + m_dataModel.removeGridDataListener( m_listener ); + } + + private Object[][] impl_getCurrentData() throws IndexOutOfBoundsException + { + final int rowCount = m_dataModel.getRowCount(); + final int colCount = m_dataModel.getColumnCount(); + final Object[][] data = new Object[rowCount][colCount]; + for ( int row=0; row<rowCount; ++row ) + { + for ( int col=0; col<colCount; ++col ) + { + data[row][col] = m_dataModel.getCellData( col, row ); + } + } + return data; + } + + private Object[] impl_getCurrentRowHeadings() throws IndexOutOfBoundsException + { + final int rowCount = m_dataModel.getRowCount(); + final Object[] headings = new Object[rowCount]; + for ( int row=0; row<rowCount; ++row ) + headings[row] = m_dataModel.getRowHeading( row ); + return headings; + } + + private void impl_assertRowData( final int i_rowIndex ) throws IndexOutOfBoundsException + { + for ( int i=0; i<m_rowValues[i_rowIndex].length; ++i ) + { + assertEquals( m_rowValues[i_rowIndex][i], m_dataModel.getCellData( i, i_rowIndex ) ); + } + } + + private final XMutableGridDataModel m_dataModel; + private final GridDataListener m_listener; + + private final static Object[][] m_rowValues = new Object[][] { + new Object[] { 1, 2, "3", 4, 5 }, + new Object[] { 2, 3, 4, "5", 6 }, + new Object[] { "3", 4, 5, 6, 7 }, + new Object[] { 4, 5, 6, 7, "8" }, + new Object[] { 5, "6", 7, 8, 9 }, + }; +} diff --git a/toolkit/qa/complex/toolkit/interface_tests/_XRequestCallback.java b/toolkit/qa/complex/toolkit/interface_tests/_XRequestCallback.java deleted file mode 100644 index 472412e80aa6..000000000000 --- a/toolkit/qa/complex/toolkit/interface_tests/_XRequestCallback.java +++ /dev/null @@ -1,88 +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. - * - ************************************************************************/ - -package complex.toolkit.interface_tests; - -import com.sun.star.awt.XRequestCallback; -import lib.MultiMethodTest; -import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.uno.XInterface; -import com.sun.star.uno.UnoRuntime; -import share.LogWriter; - -/** - * Testing <code>com.sun.star.awt.XRequestCallback</code> - * interface methods : - * <ul> - * <li><code> addCallback()</code></li> - * </ul> <p> - * @see com.sun.star.awt.XRequestCallback - */ -public class _XRequestCallback { - - private LogWriter log; - - private static final String className = - "com.sun.star.awt.XRequestCallback" ; - - public XRequestCallback oObj = null; - private XMultiServiceFactory xMSF; - - String text = null; - - - public _XRequestCallback(XInterface object, LogWriter log, XMultiServiceFactory xMSF ) { - oObj = (XRequestCallback)UnoRuntime.queryInterface( - XRequestCallback.class, object); - this.xMSF = xMSF; - this.log = log; - } - - - /** - * Calls the method and checks returned value. - * Has OK status if returned value is equal to <code>chCount - 1</code>. - * The following method tests are to be executed before: - * <ul> - * <li> <code>addCallback()</code> </li> - * </ul> - */ - public boolean _addCallback() { - - boolean res = true; - try { - Object a = new Object(); - oObj.addCallback( null, a ); - } catch (com.sun.star.uno.RuntimeException ie) { - res = false; - } - log.println("addCallback called" ); - - return res; - } - -} diff --git a/toolkit/qa/complex/toolkit/interface_tests/makefile.mk b/toolkit/qa/complex/toolkit/interface_tests/makefile.mk deleted file mode 100755 index 0e324109f28d..000000000000 --- a/toolkit/qa/complex/toolkit/interface_tests/makefile.mk +++ /dev/null @@ -1,57 +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 = ..$/..$/..$/.. -TARGET = Toolkit -PRJNAME = $(TARGET) -PACKAGE = complex$/toolkit$/interface_tests - -# --- Settings ----------------------------------------------------- -.INCLUDE: settings.mk - - -#----- compile .java files ----------------------------------------- - -JARFILES = mysql.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar -JAVAFILES = _XAccessibleComponent.java \ - _XAccessibleContext.java \ - _XAccessibleExtendedComponent.java \ - _XAccessibleEventBroadcaster.java \ - _XAccessibleText.java \ - _XRequestCallback.java -JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) - -# --- Targets ------------------------------------------------------ - -.IF "$(depend)" == "" -ALL : ALLTAR -.ELSE -ALL: ALLDEP -.ENDIF - -.INCLUDE : target.mk - diff --git a/toolkit/qa/complex/toolkit/makefile.mk b/toolkit/qa/complex/toolkit/makefile.mk index 3a4e096719bb..ecb173f9bdac 100755 --- a/toolkit/qa/complex/toolkit/makefile.mk +++ b/toolkit/qa/complex/toolkit/makefile.mk @@ -25,58 +25,73 @@ # #************************************************************************* -PRJ = ..$/..$/.. -TARGET = Toolkit -PRJNAME = $(TARGET) -PACKAGE = complex$/toolkit +.IF "$(OOO_JUNIT_JAR)" == "" +nothing .PHONY: + @echo ----------------------------------------------------- + @echo - JUnit not available, not building anything + @echo ----------------------------------------------------- +.ELSE # IF "$(OOO_JUNIT_JAR)" != "" + +PRJ = ../../.. +PRJNAME = toolkit +TARGET = qa_complex_toolkit +PACKAGE = complex/toolkit # --- Settings ----------------------------------------------------- .INCLUDE: settings.mk - #----- compile .java files ----------------------------------------- -JARFILES = mysql.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar -JAVAFILES = CheckAccessibleStatusBar.java CheckAccessibleStatusBarItem.java CheckAsyncCallback.java CallbackClass.java -JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) -SUBDIRS = interface_tests +JARFILES = OOoRunnerLight.jar ridl.jar test.jar unoil.jar +EXTRAJARFILES = $(OOO_JUNIT_JAR) -#----- make a jar from compiled files ------------------------------ +JAVAFILES = \ + $(JAVATESTFILES) \ + accessibility/_XAccessibleComponent.java \ + accessibility/_XAccessibleContext.java \ + accessibility/_XAccessibleEventBroadcaster.java \ + accessibility/_XAccessibleExtendedComponent.java \ + accessibility/_XAccessibleText.java \ + Assert.java \ + awtgrid/GridDataListener.java \ + awtgrid/TMutableGridDataModel.java \ + awtgrid/DummyColumn.java \ -MAXLINELENGTH = 100000 +#----- create a jar from compiled files ---------------------------- -JARCLASSDIRS = $(PACKAGE) JARTARGET = $(TARGET).jar -JARCOMPRESS = TRUE -# --- Parameters for the test -------------------------------------- +#----- JUnit tests class ------------------------------------------- -# start an office if the parameter is set for the makefile -.IF "$(OFFICE)" == "" -CT_APPEXECCOMMAND = -.ELSE -CT_APPEXECCOMMAND = -AppExecutionCommand "$(OFFICE)$/soffice -accept=socket,host=localhost,port=8100;urp;" -.ENDIF +JAVATESTFILES = \ + GridControl.java \ + UnitConversion.java \ -# test base is java complex -CT_TESTBASE = -tb java_complex -# build up package name with "." instead of $/ -CT_PACKAGE = -o $(PACKAGE:s\$/\.\) +# disabled for now - the tests fail on at least one platform +# no issue, yet (not sure this is worth it. Don't know who to give the issue to, and don't know whether the test really makes sense) +DISABLED_JAVA_TEST_FILES=\ + AccessibleStatusBar.java\ + AccessibleStatusBarItem.java -# start the runner application -CT_APP = org.openoffice.Runner # --- Targets ------------------------------------------------------ -.INCLUDE : target.mk +.INCLUDE: target.mk + +ALL : ALLTAR + +# --- subsequent tests --------------------------------------------- + +.IF "$(OOO_SUBSEQUENT_TESTS)" != "" + +.INCLUDE: installationtest.mk -run: \ - CheckAccessibleStatusBarItem +ALLTAR : javatest -CheckAccessibleStatusBar: - +java -cp $(CLASSPATH) $(CT_APP) $(CT_APPEXECCOMMAND) $(CT_TESTBASE) $(CT_PACKAGE).CheckAccessibleStatusBar + # Sample how to debug + # JAVAIFLAGS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y -CheckAccessibleStatusBarItem: - +java -cp $(CLASSPATH) $(CT_APP) $(CT_APPEXECCOMMAND) $(CT_TESTBASE) $(CT_PACKAGE).CheckAccessibleStatusBarItem +.END # "$(OOO_SUBSEQUENT_TESTS)" == "" +.END # ELSE "$(OOO_JUNIT_JAR)" != "" diff --git a/toolkit/qa/complex/xunitconversion/XUnitConversionTest.java b/toolkit/qa/complex/xunitconversion/XUnitConversionTest.java deleted file mode 100644 index 654f5ec69da5..000000000000 --- a/toolkit/qa/complex/xunitconversion/XUnitConversionTest.java +++ /dev/null @@ -1,222 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package complex.xunitconversion; - -import com.sun.star.awt.XUnitConversion; -import com.sun.star.uno.UnoRuntime; -import complexlib.ComplexTestCase; -import com.sun.star.awt.XWindow; -import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.awt.XWindowPeer; - -import util.DesktopTools; - -/** - * This complex test is only for testing the com.sun.star.awt.XUnitConversion methods - * These are converter methods to get the size of a well known awt component - * in a com.sun.star.util.MeasureUnit you want. - * You don't need to know the factors to calculate by hand. - * - * @author ll93751 - */ -public class XUnitConversionTest extends ComplexTestCase -{ - public String[] getTestMethodNames() - { - return new String[]{"testXUnitConversion"}; // function name of the test method - } - - /** - * returns the delta value between a and b - * @param a - * @param b - * @return - */ - private int delta(int a, int b) - { - final int n = Math.abs(a - b); - return n; - } - - private XUnitConversion m_xConversion = null; - - /** - * Not really a check, - * only a simple test call to convertSizeToLogic(...) with different parameters - * @param _aSize - * @param _aMeasureUnit - * @param _sEinheit - */ - private void checkSize(com.sun.star.awt.Size _aSize, short _aMeasureUnit, String _sEinheit) - { - try - { - com.sun.star.awt.Size aSizeIn = m_xConversion.convertSizeToLogic(_aSize, _aMeasureUnit); - log.println("Window size:"); - log.println("Width:" + aSizeIn.Width + " " + _sEinheit); - log.println("Height:" + aSizeIn.Height + " " + _sEinheit); - log.println(""); - } - catch (com.sun.star.lang.IllegalArgumentException e) - { - log.println("Caught IllegalArgumentException in convertSizeToLogic with '" + _sEinheit + "' " + e.getMessage()); - } - } - -/** - * The real test function - * 1. try to get the XMultiServiceFactory of an already running office. Therefore make sure an (open|star)office is running with - * parameters like -accept="socket,host=localhost,port=8100;urp;" - * 2. try to create an empty window - * 3. try to convert the WindowPeer to an XWindow - * 4. try to resize and move the window to an other position, so we get a well knowing position and size. - * 5. run some more tests - * - * If no test fails, the test is well done and returns with 'PASSED, OK' - * - */ public void testXUnitConversion() - { - XMultiServiceFactory xMSF = (XMultiServiceFactory) param.getMSF(); - assure("failed: There is no office.", xMSF != null); - - // create a window - XWindowPeer xWindowPeer = DesktopTools.createFloatingWindow(xMSF); - assure("failed: there is no window peer", xWindowPeer != null); - - - // resize and move the window to a well known position and size - XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, xWindowPeer); - assure("failed: there is no window, cast wrong?", xWindow != null); - - xWindow.setVisible(Boolean.TRUE); - - int x = 100; - int y = 100; - int width = 640; - int height = 480; - xWindow.setPosSize(x, y, width, height, com.sun.star.awt.PosSize.POSSIZE); - - com.sun.star.awt.Rectangle aRect = xWindow.getPosSize(); - com.sun.star.awt.Point aPoint = new com.sun.star.awt.Point(aRect.X, aRect.Y); - com.sun.star.awt.Size aSize = new com.sun.star.awt.Size(aRect.Width, aRect.Height); - - log.println("Window position and size in pixel:"); - log.println("X:" + aPoint.X); - log.println("Y:" + aPoint.Y); - log.println("Width:" + aSize.Width); - log.println("Height:" + aSize.Height); - log.println(""); - - assure("Window pos size wrong", aSize.Width == width && aSize.Height == height && aPoint.X == x && aPoint.Y == y); - - // XToolkit aToolkit = xWindowPeer.getToolkit(); - m_xConversion = (XUnitConversion) UnoRuntime.queryInterface(XUnitConversion.class, xWindowPeer); - - // try to get the position of the window in 1/100mm with the XUnitConversion method - try - { - com.sun.star.awt.Point aPointInMM_100TH = m_xConversion.convertPointToLogic(aPoint, com.sun.star.util.MeasureUnit.MM_100TH); - log.println("Window position:"); - log.println("X:" + aPointInMM_100TH.X + " 1/100mm"); - log.println("Y:" + aPointInMM_100TH.Y + " 1/100mm"); - log.println(""); - } - catch (com.sun.star.lang.IllegalArgumentException e) - { - assure("failed: IllegalArgumentException caught in convertPointToLogic " + e.getMessage(), Boolean.FALSE); - } - - // try to get the size of the window in 1/100mm with the XUnitConversion method - com.sun.star.awt.Size aSizeInMM_100TH = null; - com.sun.star.awt.Size aSizeInMM_10TH = null; - try - { - aSizeInMM_100TH = m_xConversion.convertSizeToLogic(aSize, com.sun.star.util.MeasureUnit.MM_100TH); - log.println("Window size:"); - log.println("Width:" + aSizeInMM_100TH.Width + " 1/100mm"); - log.println("Height:" + aSizeInMM_100TH.Height + " 1/100mm"); - log.println(""); - - // try to get the size of the window in 1/10mm with the XUnitConversion method - - aSizeInMM_10TH = m_xConversion.convertSizeToLogic(aSize, com.sun.star.util.MeasureUnit.MM_10TH); - log.println("Window size:"); - log.println("Width:" + aSizeInMM_10TH.Width + " 1/10mm"); - log.println("Height:" + aSizeInMM_10TH.Height + " 1/10mm"); - log.println(""); - - // check the size with a delta which must be smaller a given difference - assure("Size.Width not correct", delta(aSizeInMM_100TH.Width, aSizeInMM_10TH.Width * 10) < 10); - assure("Size.Height not correct", delta(aSizeInMM_100TH.Height, aSizeInMM_10TH.Height * 10) < 10); - - // new - checkSize(aSize, com.sun.star.util.MeasureUnit.PIXEL, "pixel"); - checkSize(aSize, com.sun.star.util.MeasureUnit.APPFONT, "appfont"); - checkSize(aSize, com.sun.star.util.MeasureUnit.SYSFONT, "sysfont"); - - // simply check some more parameters - checkSize(aSize, com.sun.star.util.MeasureUnit.MM, "mm"); - checkSize(aSize, com.sun.star.util.MeasureUnit.CM, "cm"); - checkSize(aSize, com.sun.star.util.MeasureUnit.INCH_1000TH, "1/1000inch"); - checkSize(aSize, com.sun.star.util.MeasureUnit.INCH_100TH, "1/100inch"); - checkSize(aSize, com.sun.star.util.MeasureUnit.INCH_10TH, "1/10inch"); - checkSize(aSize, com.sun.star.util.MeasureUnit.INCH, "inch"); - // checkSize(aSize, com.sun.star.util.MeasureUnit.M, "m"); - checkSize(aSize, com.sun.star.util.MeasureUnit.POINT, "point"); - checkSize(aSize, com.sun.star.util.MeasureUnit.TWIP, "twip"); - // checkSize(aSize, com.sun.star.util.MeasureUnit.KM, "km"); - // checkSize(aSize, com.sun.star.util.MeasureUnit.PICA, "pica"); - // checkSize(aSize, com.sun.star.util.MeasureUnit.FOOT, "foot"); - // checkSize(aSize, com.sun.star.util.MeasureUnit.MILE, "mile"); - } - catch (com.sun.star.lang.IllegalArgumentException e) - { - assure("failed: IllegalArgumentException caught in convertSizeToLogic " + e.getMessage(), Boolean.FALSE); - } - - // convert the 1/100mm window size back to pixel - try - { - com.sun.star.awt.Size aNewSize = m_xConversion.convertSizeToPixel(aSizeInMM_100TH, com.sun.star.util.MeasureUnit.MM_100TH); - log.println("Window size:"); - log.println("Width:" + aNewSize.Width + " pixel"); - log.println("Height:" + aNewSize.Height + " pixel"); - - // assure the pixels are the same as we already know - assure("failed: Size from pixel to 1/100mm to pixel", aSize.Width == aNewSize.Width && aSize.Height == aNewSize.Height); - } - catch (com.sun.star.lang.IllegalArgumentException e) - { - assure("failed: IllegalArgumentException caught in convertSizeToPixel " + e.getMessage(), Boolean.FALSE); - } - - // close the window. - // IMHO a little bit stupid, but the XWindow doesn't support a XCloseable interface - xWindow.dispose(); - } -} diff --git a/toolkit/qa/complex/xunitconversion/makefile.mk b/toolkit/qa/complex/xunitconversion/makefile.mk deleted file mode 100644 index 18b59ee19f18..000000000000 --- a/toolkit/qa/complex/xunitconversion/makefile.mk +++ /dev/null @@ -1,77 +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 = ..$/..$/.. -TARGET = XUnitConversionTest -PRJNAME = $(TARGET) -PACKAGE = complex$/xunitconversion - -# --- Settings ----------------------------------------------------- -.INCLUDE: settings.mk - - -#----- compile .java files ----------------------------------------- - -JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar -JAVAFILES = XUnitConversionTest.java -JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) -SUBDIRS = - -#----- make a jar from compiled files ------------------------------ - -MAXLINELENGTH = 100000 - -JARCLASSDIRS = $(PACKAGE) -JARTARGET = $(TARGET).jar -JARCOMPRESS = TRUE - -# --- Parameters for the test -------------------------------------- - -# start an office if the parameter is set for the makefile -.IF "$(OFFICE)" == "" -CT_APPEXECCOMMAND = -.ELSE -CT_APPEXECCOMMAND = -AppExecutionCommand "$(OFFICE)$/soffice -accept=socket,host=localhost,port=8100;urp;" -.ENDIF - -# test base is java complex -CT_TESTBASE = -tb java_complex - -# build up package name with "." instead of $/ -CT_PACKAGE = -o $(PACKAGE:s\$/\.\) - -# start the runner application -CT_APP = org.openoffice.Runner - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk - -run: $(JAVAFILES) XUnitConversionTest - -XUnitConversionTest: - +java -cp $(CLASSPATH) $(CT_APP) $(CT_APPEXECCOMMAND) $(CT_TESTBASE) $(CT_PACKAGE).XUnitConversionTest diff --git a/toolkit/qa/unoapi/Test.java b/toolkit/qa/unoapi/Test.java index f27d882314d2..0543fee83f9f 100644 --- a/toolkit/qa/unoapi/Test.java +++ b/toolkit/qa/unoapi/Test.java @@ -27,6 +27,7 @@ package org.openoffice.toolkit.qa.unoapi; import org.openoffice.Runner; import org.openoffice.test.OfficeConnection; +import org.openoffice.test.Argument; import static org.junit.Assert.*; public final class Test { @@ -43,8 +44,8 @@ public final class Test { @org.junit.Test public void test() { assertTrue( Runner.run( - "-sce", "toolkit.sce", "-xcl", "knownissues.xcl", "-tdoc", - "testdocuments", "-cs", connection.getDescription())); + "-sce", Argument.get("sce"), "-xcl", Argument.get("xcl"), "-tdoc", + Argument.get("tdoc"), "-cs", connection.getDescription())); } private final OfficeConnection connection = new OfficeConnection(); diff --git a/toolkit/qa/unoapi/knownissues.xcl b/toolkit/qa/unoapi/knownissues.xcl index 429d7693c833..273b4b72dbe2 100644 --- a/toolkit/qa/unoapi/knownissues.xcl +++ b/toolkit/qa/unoapi/knownissues.xcl @@ -178,7 +178,6 @@ toolkit.UnoControlDialogModel::com::sun::star::lang::XComponent toolkit.UnoControlFileControlModel::com::sun::star::lang::XComponent toolkit.UnoControlGroupBox::com::sun::star::lang::XComponent toolkit.UnoControlContainer::com::sun::star::lang::XComponent -toolkit.MutableTreeDataModel::com::sun::star::lang::XComponent toolkit.UnoControlFixedText::com::sun::star::lang::XComponent toolkit.UnoControlListBox::com::sun::star::lang::XComponent toolkit.UnoControlCheckBoxModel::com::sun::star::lang::XComponent @@ -241,12 +240,21 @@ toolkit.AccessibleMenu::com::sun::star::accessibility::XAccessibleValue toolkit.AccessibleMenuBar::com::sun::star::accessibility::XAccessibleEventBroadcaster toolkit.AccessibleMenuBar::com::sun::star::accessibility::XAccessibleSelection -### i111076 ### -toolkit.Toolkit::com::sun::star::awt::XDataTransferProviderAccess - ### i111113 ### toolkit.AccessibleStatusBarItem::com::sun::star::accessibility::XAccessibleComponent toolkit.AccessibleStatusBarItem::com::sun::star::accessibility::XAccessibleContext ### i111195 ### toolkit.AccessibleScrollBar::com::sun::star::accessibility::XAccessibleValue + +### i113489 ### +toolkit.AccessibleMenu::com::sun::star::accessibility::XAccessibleText +toolkit.AccessibleMenuBar::com::sun::star::accessibility::XAccessibleComponent +toolkit.AccessibleMenuSeparator::com::sun::star::accessibility::XAccessibleComponent + +### i114213 ### +toolkit.AccessibleMenu::com::sun::star::accessibility::XAccessibleSelection + +### i114636 ### +toolkit.AccessibleScrollBar::com::sun::star::accessibility::XAccessibleAction +toolkit.AccessibleScrollBar::com::sun::star::accessibility::XAccessibleContext diff --git a/toolkit/qa/unoapi/toolkit.sce b/toolkit/qa/unoapi/toolkit.sce index 5a148feee573..00af010d23d6 100644 --- a/toolkit/qa/unoapi/toolkit.sce +++ b/toolkit/qa/unoapi/toolkit.sce @@ -8,10 +8,10 @@ #i86110 -o toolkit.AccessibleList #i86110 -o toolkit.AccessibleListBox #i86110 -o toolkit.AccessibleListItem -#i111047# -o toolkit.AccessibleMenu -#i111047# -o toolkit.AccessibleMenuBar +-o toolkit.AccessibleMenu +-o toolkit.AccessibleMenuBar #i86009 -o toolkit.AccessibleMenuItem -#i111047# -o toolkit.AccessibleMenuSeparator +-o toolkit.AccessibleMenuSeparator #i52607 -o toolkit.AccessiblePopupMenu #i86107,i86110 -o toolkit.AccessibleRadioButton -o toolkit.AccessibleScrollBar 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/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/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); } diff --git a/toolkit/src2xml/src-sw.lst b/toolkit/src2xml/src-sw.lst index 8d43400462d8..a0e7245fc4f4 100644 --- a/toolkit/src2xml/src-sw.lst +++ b/toolkit/src2xml/src-sw.lst @@ -51,7 +51,6 @@ ../../sw/source/ui/fldui/DropDownFieldDialog.src ../../sw/source/ui/fldui/fldui.src ../../sw/source/ui/fmtui/tmpdlg.src -../../sw/source/ui/fmtui/fmtui.src ../../sw/source/ui/index/cnttab.src ../../sw/source/ui/index/multmrk.src ../../sw/source/ui/index/idxmrk.src diff --git a/toolkit/src2xml/src.lst b/toolkit/src2xml/src.lst index 524262cf54c1..44143571b0dc 100644 --- a/toolkit/src2xml/src.lst +++ b/toolkit/src2xml/src.lst @@ -170,7 +170,6 @@ ../../sw/source/ui/fldui/DropDownFieldDialog.src ../../sw/source/ui/fldui/fldui.src ../../sw/source/ui/fmtui/tmpdlg.src -../../sw/source/ui/fmtui/fmtui.src ../../sw/source/ui/index/cnttab.src ../../sw/source/ui/index/multmrk.src ../../sw/source/ui/index/idxmrk.src diff --git a/toolkit/test/accessibility/makefile.mk b/toolkit/test/accessibility/makefile.mk deleted file mode 100644 index cc6f410f7404..000000000000 --- a/toolkit/test/accessibility/makefile.mk +++ /dev/null @@ -1,127 +0,0 @@ -# This is the dmake version. - -# copied from settings.mk -SOLARBINDIR=$(SOLARVERSION)$/$(INPATH)$/bin$(UPDMINOREXT) - -# Please modify the following lines to match your environment: -# If you use the run: target at the end of the file, then adapt port number. -PORT_NUMBER = 5678 - -# The following variables probably don't need to be changed. -JAVAC = javac -JAVA = java -# The JAR_PATH points to the jar files of your local office installation. -JAR_PATH = $(SOLARBINDIR)$/ - - -# The rest of this makefile should not need to be touched. - -all : AccessibilityWorkBench - -JAR_FILES = \ - unoil.jar \ - ridl.jar \ - jurt.jar \ - juh.jar \ - java_uno.jar - -JAVA_FILES = \ - AccTreeNode.java \ - AccessibilityTree.java \ - AccessibilityTreeModel.java \ - AccessibilityTreeModelBase.java \ - AccessibilityWorkBench.java \ - AccessibleActionHandler.java \ - AccessibleActionNode.java \ - AccessibleCellHandler.java \ - AccessibleComponentHandler.java \ - AccessibleContextHandler.java \ - AccessibleEditableTextHandler.java \ - AccessibleExtendedComponentHandler.java \ - AccessibleHyperlinkHandler.java \ - AccessibleHypertextHandler.java \ - AccessibleImageHandler.java \ - AccessibleRelationHandler.java \ - AccessibleSelectionHandler.java \ - AccessibleTableHandler.java \ - AccessibleTextHandler.java \ - AccessibleTreeCellRenderer.java \ - AccessibleTreeHandler.java \ - AccessibleTreeNode.java \ - AccessibleUNOHandler.java \ - Canvas.java \ - CanvasShape.java \ - ChildEventHandler.java \ - ContextEventHandler.java \ - EventHandler.java \ - EventListener.java \ - EventLogger.java \ - EventQueue.java \ - FrameActionListener.java \ - GeometryEventHandler.java \ - HelpWindow.java \ - InformationWriter.java \ - MessageArea.java \ - NodeFactory.java \ - NodeHandler.java \ - NodeMap.java \ - OfficeConnection.java \ - Options.java \ - QueuedListener.java \ - QueuedTopWindowListener.java \ - SelectionDialog.java \ - SimpleOffice.java \ - StringNode.java \ - TableEventHandler.java \ - TextLogger.java \ - TextUpdateListener.java \ - TopWindowListener.java \ - VectorNode.java - -JAVA_CLASSPATHS := \ - . \ - $(foreach,i,$(JAR_FILES) $(JAR_PATH)$i) \ - $(CLASSPATH) - -CLASSPATH !:=$(JAVA_CLASSPATHS:t$(PATH_SEPERATOR)) - -JFLAGS = -deprecation -classpath $(CLASSPATH) - -%.class : %.java - $(JAVAC) $(JFLAGS) $< - -%.class : %.java - $(JAVAC) $(JFLAGS) $< - -AccessibilityWorkBench : ObjectView Tools $(JAVA_FILES:b:+".class") - -ObjectView .SETDIR=ov : - @echo "making package ObjectView" - dmake - -Tools .SETDIR=tools : - @echo "making package Tools" - dmake - -# Remove all class files. -clean : ObjectView.clean Tools.clean - rm *.class - rm AccessibilityWorkBench.jar -ObjectView.clean .SETDIR=ov : - rm *.class -Tools.clean .SETDIR=tools : - rm *.class - -# Create a jar file of all files neccessary to build and run the work bench. -dist: AccessibilityWorkBench.jar - -AccessibilityWorkBench.jar: $(JAVA_FILES:b:+".class") jawb.mf - jar -cfm AccessibilityWorkBench.jar jawb.mf *.class ov\*.class tools\*.class - -# Example of how to run the work bench. -run: all - $(JAVA) -classpath $(CLASSPATH) AccessibilityWorkBench -p $(PORT_NUMBER) - -runjar: all dist - $(JAVA) -classpath $(CLASSPATH) -jar AccessibilityWorkBench.jar -p $(PORT_NUMBER) - diff --git a/toolkit/test/accessibility/ov/makefile.mk b/toolkit/test/accessibility/ov/makefile.mk deleted file mode 100644 index 56fb563eeee0..000000000000 --- a/toolkit/test/accessibility/ov/makefile.mk +++ /dev/null @@ -1,51 +0,0 @@ -# This is the dmake version. - -# copied from settings.mk -SOLARBINDIR=$(SOLARVERSION)$/$(INPATH)$/bin$(UPDMINOREXT) - -# Please modify the following lines to match your environment: -# If you use the run: target at the end of the file, then adapt port number. -PORT_NUMBER = 5678 - -# The following variables probably don't need to be changed. -JAVAC = javac -JAVA = java -# The JAR_PATH points to the jar files of your local office installation. -JAR_PATH = $(SOLARBINDIR)$/ - - -# The rest of this makefile should not need to be touched. - -all : ov - -JAR_FILES = \ - unoil.jar \ - ridl.jar \ - jurt.jar \ - juh.jar \ - java_uno.jar - -JAVA_FILES = \ - ov/ObjectViewContainer.java \ - ov/ObjectView.java \ - ov/ListeningObjectView.java \ - ov/ContextView.java \ - ov/FocusView.java \ - ov/SelectionView.java \ - ov/TextView.java -# ov/StateSetView.java \ - - -JAVA_CLASSPATHS := \ - . .. \ - $(foreach,i,$(JAR_FILES) $(JAR_PATH)$i) \ - $(CLASSPATH) - -CLASSPATH !:=$(JAVA_CLASSPATHS:t$(PATH_SEPERATOR)) - -JFLAGS = -deprecation -classpath $(CLASSPATH) - -%.class : %.java - $(JAVAC) $(JFLAGS) $< - -ov : $(JAVA_FILES:b:+".class") diff --git a/toolkit/test/accessibility/tools/makefile.mk b/toolkit/test/accessibility/tools/makefile.mk deleted file mode 100644 index 045ba6f65b49..000000000000 --- a/toolkit/test/accessibility/tools/makefile.mk +++ /dev/null @@ -1,42 +0,0 @@ -# copied from settings.mk -SOLARBINDIR=$(SOLARVERSION)$/$(INPATH)$/bin$(UPDMINOREXT) - -# Please modify the following lines to match your environment: -# If you use the run: target at the end of the file, then adapt port number. -PORT_NUMBER = 5678 - -# The following variables probably don't need to be changed. -JAVAC = javac -JAVA = java -# The JAR_PATH points to the jar files of your local office installation. -JAR_PATH = $(SOLARBINDIR)$/ - - -# The rest of this makefile should not need to be touched. - -all : tools - -JAR_FILES = \ - unoil.jar \ - ridl.jar \ - jurt.jar \ - juh.jar \ - java_uno.jar - -JAVA_FILES = \ - tools/NameProvider.java - - -JAVA_CLASSPATHS := \ - . .. \ - $(foreach,i,$(JAR_FILES) $(JAR_PATH)$i) \ - $(CLASSPATH) - -CLASSPATH !:=$(JAVA_CLASSPATHS:t$(PATH_SEPERATOR)) - -JFLAGS = -deprecation -classpath $(CLASSPATH) - -%.class : %.java - $(JAVAC) $(JFLAGS) $< - -tools : $(JAVA_FILES:b:+".class") diff --git a/toolkit/util/makefile.mk b/toolkit/util/makefile.mk deleted file mode 100644 index 48d534a8a9b3..000000000000 --- a/toolkit/util/makefile.mk +++ /dev/null @@ -1,85 +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. -# -#************************************************************************* - -# tk.dxp should contain all c functions that have to be exported. MT 2001/11/29 - -PRJ=.. - -PRJNAME=toolkit -TARGET=tk -TARGET2=tka -USE_DEFFILE=TRUE - -# --- Settings ----------------------------------------------------------- - -.INCLUDE : settings.mk -.INCLUDE : $(PRJ)$/util$/makefile.pmk - - -# --- Allgemein ---------------------------------------------------------- - -# ======================================================================== -# = tk lib: the "classic" toolkit library - -LIB1TARGET= $(SLB)$/$(TARGET).lib -LIB1FILES= $(SLB)$/awt.lib \ - $(SLB)$/tree.lib \ - $(SLB)$/grid.lib \ - $(SLB)$/controls.lib \ - $(SLB)$/helper.lib\ - $(SLB)$/layout-core.lib \ - $(SLB)$/layout-vcl.lib - -SHL1TARGET= tk$(DLLPOSTFIX) -SHL1IMPLIB= itk -SHL1USE_EXPORTS=name - -SHL1STDLIBS=\ - $(VCLLIB) \ - $(UNOTOOLSLIB) \ - $(TOOLSLIB) \ - $(COMPHELPERLIB) \ - $(CPPUHELPERLIB) \ - $(CPPULIB) \ - $(SALLIB) - -SHL1LIBS= $(LIB1TARGET) -SHL1DEF= $(MISC)$/$(SHL1TARGET).def -SHL1DEPN=$(LIB1TARGET) - -DEF1NAME =$(SHL1TARGET) -DEF1DEPN =$(LIB1TARGET) -DEF1DES =TK -DEFLIB1NAME =tk - -RESLIB1IMAGES=$(PRJ)$/source$/awt -RES1FILELIST=$(SRS)$/awt.srs -RESLIB1NAME=$(TARGET) -RESLIB1SRSFILES=$(RES1FILELIST) - -# --- Footer ------------------------------------------------------------- -.INCLUDE : target.mk diff --git a/toolkit/util/tk.component b/toolkit/util/tk.component new file mode 100644 index 000000000000..690b3f324498 --- /dev/null +++ b/toolkit/util/tk.component @@ -0,0 +1,322 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.awt.comp.AsyncCallback"> + <service name="com.sun.star.awt.AsyncCallback"/> + </implementation> + <implementation name="com.sun.star.comp.awt.Layout"> + <service name="com.sun.star.awt.Layout"/> + <service name="com.sun.star.comp.awt.Layout"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoControlTabPage"> + <service name="com.sun.star.awt.tab.UnoControlTabPage"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoControlTabPageModel"> + <service name="com.sun.star.awt.tab.UnoControlTabPageModel"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoControlTabPageContainerModel"> + <service name="com.sun.star.awt.tab.UnoControlTabPageContainerModel"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoControlTabPageContainer"> + <service name="com.sun.star.awt.tab.UnoControlTabPageContainer"/> + </implementation> + <implementation name="stardiv.Toolkit.DefaultGridColumnModel"> + <service name="com.sun.star.awt.grid.DefaultGridColumnModel"/> + </implementation> + <implementation name="stardiv.Toolkit.DefaultGridDataModel"> + <service name="com.sun.star.awt.grid.DefaultGridDataModel"/> + </implementation> + <implementation name="org.openoffice.comp.toolkit.GridColumn"> + <service name="com.sun.star.awt.grid.GridColumn"/> + </implementation> + <implementation name="org.openoffice.comp.toolkit.SortableGridDataModel"> + <service name="com.sun.star.awt.grid.SortableGridDataModel"/> + </implementation> + <implementation name="stardiv.Toolkit.GridControl"> + <service name="com.sun.star.awt.grid.UnoControlGrid"/> + </implementation> + <implementation name="stardiv.Toolkit.GridControlModel"> + <service name="com.sun.star.awt.grid.UnoControlGridModel"/> + </implementation> + <implementation name="stardiv.Toolkit.MutableTreeDataModel"> + <service name="com.sun.star.awt.tree.MutableTreeDataModel"/> + </implementation> + <implementation name="stardiv.Toolkit.StdTabController"> + <service name="com.sun.star.awt.TabController"/> + <service name="stardiv.vcl.control.TabController"/> + </implementation> + <implementation name="stardiv.Toolkit.StdTabControllerModel"> + <service name="com.sun.star.awt.TabControllerModel"/> + <service name="stardiv.vcl.controlmodel.TabController"/> + </implementation> + <implementation name="stardiv.Toolkit.TreeControl"> + <service name="com.sun.star.awt.tree.TreeControl"/> + </implementation> + <implementation name="stardiv.Toolkit.TreeControlModel"> + <service name="com.sun.star.awt.tree.TreeControlModel"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoButtonControl"> + <service name="com.sun.star.awt.UnoControlButton"/> + <service name="stardiv.vcl.control.Button"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoCheckBoxControl"> + <service name="com.sun.star.awt.UnoControlCheckBox"/> + <service name="stardiv.vcl.control.CheckBox"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoComboBoxControl"> + <service name="com.sun.star.awt.UnoControlComboBox"/> + <service name="stardiv.vcl.control.ComboBox"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoControlButtonModel"> + <service name="com.sun.star.awt.UnoControlButtonModel"/> + <service name="stardiv.vcl.controlmodel.Button"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoControlCheckBoxModel"> + <service name="com.sun.star.awt.UnoControlCheckBoxModel"/> + <service name="stardiv.vcl.controlmodel.CheckBox"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoControlComboBoxModel"> + <service name="com.sun.star.awt.UnoControlComboBoxModel"/> + <service name="stardiv.vcl.controlmodel.ComboBox"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoControlContainer"> + <service name="com.sun.star.awt.UnoControlContainer"/> + <service name="stardiv.vcl.control.ControlContainer"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoControlContainerModel"> + <service name="com.sun.star.awt.UnoControlContainerModel"/> + <service name="stardiv.vcl.controlmodel.ControlContainer"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoControlCurrencyFieldModel"> + <service name="com.sun.star.awt.UnoControlCurrencyFieldModel"/> + <service name="stardiv.vcl.controlmodel.CurrencyField"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoControlDateFieldModel"> + <service name="com.sun.star.awt.UnoControlDateFieldModel"/> + <service name="stardiv.vcl.controlmodel.DateField"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoControlDialogModel"> + <service name="com.sun.star.awt.UnoControlDialogModel"/> + <service name="stardiv.vcl.controlmodel.Dialog"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoControlEditModel"> + <service name="com.sun.star.awt.UnoControlEditModel"/> + <service name="stardiv.vcl.controlmodel.Edit"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoControlFileControlModel"> + <service name="com.sun.star.awt.UnoControlFileControlModel"/> + <service name="stardiv.vcl.controlmodel.FileControl"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoControlFixedHyperlinkModel"> + <service name="com.sun.star.awt.UnoControlFixedHyperlinkModel"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoControlFixedLineModel"> + <service name="com.sun.star.awt.UnoControlFixedLineModel"/> + <service name="stardiv.vcl.controlmodel.FixedLine"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoControlFixedTextModel"> + <service name="com.sun.star.awt.UnoControlFixedTextModel"/> + <service name="stardiv.vcl.controlmodel.FixedText"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoControlFormattedFieldModel"> + <service name="com.sun.star.awt.UnoControlFormattedFieldModel"/> + <service name="stardiv.vcl.controlmodel.FormattedField"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoControlGroupBoxModel"> + <service name="com.sun.star.awt.UnoControlGroupBoxModel"/> + <service name="stardiv.vcl.controlmodel.GroupBox"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoControlImageControlModel"> + <service name="com.sun.star.awt.UnoControlImageButtonModel"/> + <service name="com.sun.star.awt.UnoControlImageControlModel"/> + <service name="stardiv.vcl.controlmodel.ImageButton"/> + <service name="stardiv.vcl.controlmodel.ImageControl"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoControlListBoxModel"> + <service name="com.sun.star.awt.UnoControlListBoxModel"/> + <service name="stardiv.vcl.controlmodel.ListBox"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoControlNumericFieldModel"> + <service name="com.sun.star.awt.UnoControlNumericFieldModel"/> + <service name="stardiv.vcl.controlmodel.NumericField"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoControlPatternFieldModel"> + <service name="com.sun.star.awt.UnoControlPatternFieldModel"/> + <service name="stardiv.vcl.controlmodel.PatternField"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoControlProgressBarModel"> + <service name="com.sun.star.awt.UnoControlProgressBarModel"/> + <service name="stardiv.vcl.controlmodel.ProgressBar"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoControlRadioButtonModel"> + <service name="com.sun.star.awt.UnoControlRadioButtonModel"/> + <service name="stardiv.vcl.controlmodel.RadioButton"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoControlRoadmapModel"> + <service name="com.sun.star.awt.UnoControlRoadmapModel"/> + <service name="stardiv.vcl.controlmodel.Roadmap"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoControlScrollBarModel"> + <service name="com.sun.star.awt.UnoControlScrollBarModel"/> + <service name="stardiv.vcl.controlmodel.ScrollBar"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoControlTimeFieldModel"> + <service name="com.sun.star.awt.UnoControlTimeFieldModel"/> + <service name="stardiv.vcl.controlmodel.TimeField"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoCurrencyFieldControl"> + <service name="com.sun.star.awt.UnoControlCurrencyField"/> + <service name="stardiv.vcl.control.CurrencyField"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoDateFieldControl"> + <service name="com.sun.star.awt.UnoControlDateField"/> + <service name="stardiv.vcl.control.DateField"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoDialogControl"> + <service name="com.sun.star.awt.UnoControlDialog"/> + <service name="stardiv.vcl.control.Dialog"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoEditControl"> + <service name="com.sun.star.awt.UnoControlEdit"/> + <service name="stardiv.vcl.control.Edit"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoFileControl"> + <service name="com.sun.star.awt.UnoControlFileControl"/> + <service name="stardiv.vcl.control.FileControl"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoFixedHyperlinkControl"> + <service name="com.sun.star.awt.UnoControlFixedHyperlink"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoFixedLineControl"> + <service name="com.sun.star.awt.UnoControlFixedLine"/> + <service name="stardiv.vcl.control.FixedLine"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoFixedTextControl"> + <service name="com.sun.star.awt.UnoControlFixedText"/> + <service name="stardiv.vcl.control.FixedText"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoFormattedFieldControl"> + <service name="com.sun.star.awt.UnoControlFormattedField"/> + <service name="stardiv.vcl.control.FormattedField"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoGroupBoxControl"> + <service name="com.sun.star.awt.UnoControlGroupBox"/> + <service name="stardiv.vcl.control.GroupBox"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoImageControlControl"> + <service name="com.sun.star.awt.UnoControlImageButton"/> + <service name="com.sun.star.awt.UnoControlImageControl"/> + <service name="stardiv.vcl.control.ImageButton"/> + <service name="stardiv.vcl.control.ImageControl"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoListBoxControl"> + <service name="com.sun.star.awt.UnoControlListBox"/> + <service name="stardiv.vcl.control.ListBox"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoNumericFieldControl"> + <service name="com.sun.star.awt.UnoControlNumericField"/> + <service name="stardiv.vcl.control.NumericField"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoPatternFieldControl"> + <service name="com.sun.star.awt.UnoControlPatternField"/> + <service name="stardiv.vcl.control.PatternField"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoProgressBarControl"> + <service name="com.sun.star.awt.UnoControlProgressBar"/> + <service name="stardiv.vcl.control.ProgressBar"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoRadioButtonControl"> + <service name="com.sun.star.awt.UnoControlRadioButton"/> + <service name="stardiv.vcl.control.RadioButton"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoRoadmapControl"> + <service name="com.sun.star.awt.UnoControlRoadmap"/> + <service name="stardiv.vcl.control.Roadmap"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoScrollBarControl"> + <service name="com.sun.star.awt.UnoControlScrollBar"/> + <service name="stardiv.vcl.control.ScrollBar"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoSimpleAnimationControl"> + <service name="com.sun.star.awt.UnoControlSimpleAnimation"/> + <service name="com.sun.star.awt.UnoSimpleAnimationControl"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoSimpleAnimationControlModel"> + <service name="com.sun.star.awt.UnoControlSimpleAnimationModel"/> + <service name="com.sun.star.awt.UnoSimpleAnimationControlModel"/> + </implementation> + <implementation name="org.openoffice.comp.toolkit.SpinningProgressControlModel"> + <service name="com.sun.star.awt.SpinningProgressControlModel"/> + </implementation> + <implementation name="org.openoffice.comp.toolkit.AnimatedImagesControlModel"> + <service name="com.sun.star.awt.AnimatedImagesControlModel"/> + </implementation> + <implementation name="org.openoffice.comp.toolkit.AnimatedImagesControl"> + <service name="com.sun.star.awt.AnimatedImagesControl"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoSpinButtonControl"> + <service name="com.sun.star.awt.UnoControlSpinButton"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoSpinButtonModel"> + <service name="com.sun.star.awt.UnoControlSpinButtonModel"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoThrobberControl"> + <service name="com.sun.star.awt.UnoControlThrobber"/> + <service name="com.sun.star.awt.UnoThrobberControl"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoThrobberControlModel"> + <service name="com.sun.star.awt.UnoControlThrobberModel"/> + <service name="com.sun.star.awt.UnoThrobberControlModel"/> + </implementation> + <implementation name="stardiv.Toolkit.UnoTimeFieldControl"> + <service name="com.sun.star.awt.UnoControlTimeField"/> + <service name="stardiv.vcl.control.TimeField"/> + </implementation> + <implementation name="stardiv.Toolkit.VCLXMenuBar"> + <service name="com.sun.star.awt.MenuBar"/> + <service name="stardiv.vcl.MenuBar"/> + </implementation> + <implementation name="stardiv.Toolkit.VCLXPointer"> + <service name="com.sun.star.awt.Pointer"/> + <service name="stardiv.vcl.Pointer"/> + </implementation> + <implementation name="stardiv.Toolkit.VCLXPopupMenu"> + <service name="com.sun.star.awt.PopupMenu"/> + <service name="stardiv.vcl.PopupMenu"/> + </implementation> + <implementation name="stardiv.Toolkit.VCLXPrinterServer"> + <service name="com.sun.star.awt.PrinterServer"/> + <service name="stardiv.vcl.PrinterServer"/> + </implementation> + <implementation name="stardiv.Toolkit.VCLXToolkit"> + <service name="com.sun.star.awt.Toolkit"/> + <service name="stardiv.vcl.VclToolkit"/> + </implementation> +</component> diff --git a/toolkit/workben/layout/makefile.mk b/toolkit/workben/layout/makefile.mk deleted file mode 100644 index 53797e5a3102..000000000000 --- a/toolkit/workben/layout/makefile.mk +++ /dev/null @@ -1,151 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=../.. -PRJNAME=toolkit -TARGET=test -TARGETTYPE=GUI -LIBTARGET=NO -ENABLE_EXCEPTIONS=TRUE - -.INCLUDE : settings.mk - -.IF "$(ENABLE_LAYOUT)" == "TRUE" - -# Allow zoom and wordcount to be built without depending on svx,sv,sfx2 -CFLAGS += -I../$(PRJ)/svx/inc -I../$(PRJ)/svtools/inc -I../$(PRJ)/sfx2/inc -I../$(PRJ)/sc/inc -I../$(PRJ)/sc/source/ui/inc -I../$(PRJ)/sw/inc - -.INCLUDE : $(PRJ)$/util$/makefile.pmk - -.IF "$(COMNAME)" == "gcc3" -CFLAGS+=-Wall -Wno-non-virtual-dtor -.ENDIF - -CXXFILES=\ - editor.cxx \ - plugin.cxx \ - recover.cxx \ - wordcountdialog.cxx \ - test.cxx \ - zoom.cxx - -OBJFILES=\ - $(OBJ)$/editor.obj \ - $(OBJ)$/plugin.obj \ - $(OBJ)$/recover.obj \ - $(OBJ)$/test.obj \ - $(OBJ)$/tpsort.obj \ - $(OBJ)$/sortdlg.obj \ - $(OBJ)$/wordcountdialog.obj \ - $(OBJ)$/zoom.obj - -APP1TARGET=$(TARGET) -APP1OBJS=$(OBJFILES) -APP1STDLIBS= \ - $(TOOLSLIB) \ - $(COMPHELPERLIB) \ - $(VCLLIB) \ - $(CPPULIB) \ - $(CPPUHELPERLIB) \ - $(SALLIB) \ - $(XMLSCRIPTLIB) \ - $(TKLIB) \ - $(SVXLIB) \ - $(ISCLIB) \ -# - -svtools = $(INCCOM)/svtools -default: ALLTAR - -.INCLUDE : target.mk - -XML_FILES=\ - insert-sheet.xml\ - message-box.xml\ - move-copy-sheet.xml\ - recover.xml\ - sort-options.xml\ - string-input.xml\ - tab-dialog.xml\ - wordcount.xml\ - zoom.xml\ - -TRALAY=$(AUGMENT_LIBRARY_PATH) tralay -XML_LANGS=$(alllangiso) - -ALLTAR: localize.sdf $(BIN)/testrc $(svtools) $(foreach,i,$(XML_FILES) en-US/$i) - -$(XML_LANGS:f:t"/%.xml ")/%.xml: %.xml - $(TRALAY) -m localize.sdf -o . -l $(XML_LANGS:f:t" -l ") $< - rm -rf en-US - -$(BIN)/%: %.in - cp $< $@ - -$(svtools): -# FIXME: there's a bug in svtools layout or usage -# Include files are in svtools/inc, but are referenced as <svtools/..> -# They probably should be in svtools/inc/svtools -# This means that include files can only be included after svtools -# is built, which would mean a circular dependency, -# because svtools depends on toolkit. - ln -sf ..$/$(PRJ)$/svtools$/inc $(INCCOM)$/svtools - -dist .PHONY : - cp -pv message-box.xml $(PRJ)/uiconfig/layout - cp -pv tab-dialog.xml $(PRJ)/uiconfig/layout - $(SHELL) ./un-test.sh zoom.cxx > ../$(PRJ)/svx/source/dialog/zoom.cxx - $(SHELL) ./un-test.sh zoom.hxx > ../$(PRJ)/svx/source/dialog/zoom.hxx - touch ../$(PRJ)/svx/source/dialog/dlgfact.cxx - cp -pv zoom.xml ../$(PRJ)/svx/uiconfig/layout - $(SHELL) ./un-test.sh wordcountdialog.cxx > ../$(PRJ)/sw/source/ui/dialog/wordcountdialog.cxx - $(SHELL) ./un-test.sh wordcountdialog.hxx > ../$(PRJ)/sw/source/ui/inc/wordcountdialog.hxx - touch ../$(PRJ)/sw/source/ui/dialog/swdlgfact.cxx - cp -pv wordcount.xml ../$(PRJ)/sw/uiconfig/layout - # FIXME: broken setup - ln -sf ../inc/wordcountdialog.hxx ../$(PRJ)/sw/source/ui/dialog/wordcountdialog.hxx - $(SHELL) ./un-test.sh tpsort.cxx > ../$(PRJ)/sc/source/ui/dbgui/tpsort.cxx - $(SHELL) ./un-test.sh tpsort.hxx > ../$(PRJ)/sc/source/ui/inc/tpsort.hxx - $(SHELL) ./un-test.sh sortdlg.cxx > ../$(PRJ)/sc/source/ui/dbgui/sortdlg.cxx - $(SHELL) ./un-test.sh sortdlg.hxx > ../$(PRJ)/sc/source/ui/inc/sortdlg.hxx - touch ../$(PRJ)/sc/source/ui/attrdlg/scdlgfact.cxx - touch ../$(PRJ)/sc/source/ui/view/cellsh2.cxx - cp -pv insert-sheet.xml ../$(PRJ)/sc/uiconfig/layout - cp -pv move-copy-sheet.xml ../$(PRJ)/sc/uiconfig/layout - cp -pv sort-options.xml ../$(PRJ)/sc/uiconfig/layout - cp -pv string-input.xml ../$(PRJ)/sc/uiconfig/layout - -localize.sdf: $(PRJ)/../svx/source/dialog/localize.sdf $(PRJ)/../sw/source/ui/dialog/localize.sdf $(PRJ)/../sc/source/ui/src/localize.sdf - grep sortdlg.src $(PRJ)/../sc/source/ui/src/localize.sdf | awk -F'\t' '{{printf "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", "layout", "sc\\uiconfig\\layout\\sort-options.xml", $$3, "layout", $$6 "_label", "", "", $$8, "0", $$10, $$11, $$12, "", $$14, $$15}}' | sed -e 's/\(\(FL\|STR\)_[^\t]*\)_label/\1_text/' -e 's/\t_label/\tRID_SCDLG_SORT_title/' > sort-options-$@ - grep wordcountdialog.src $(PRJ)/../sw/source/ui/dialog/localize.sdf | awk -F'\t' '{{printf "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", "layout", "sw\\uiconfig\\layout\\wordcount.xml", $$3, "layout", $$6 "_label", "", "", $$8, "0", $$10, $$11, $$12, "", $$14, $$15}}' | sed -e 's/\(\(FL\|STR\)_[^\t]*\)_label/\1_text/' -e 's/\t_label/\tDLG_WORDCOUNT_title/' > wordcount-$@ - grep zoom.src $(PRJ)/source/dialog/localize.sdf | awk -F'\t' '{{printf "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", "layout", "svx\\uiconfig\\layout\\zoom.xml", $$3, "layout", $$6 "_label", "", "", $$8, "0", $$10, $$11, $$12, "", $$14, $$15}}' | sed -e 's/\(\(FL\|STR\)_[^\t]*\)_label/\1_text/' -e 's/\t_label/\tRID_SVXDLG_ZOOM_title/' > zoom-$@ - echo '#empty' | cat - sort-options-$@ wordcount-$@ zoom-$@ > $@ - rm -f *-$@ - -.ELSE # ENABLE_LAYOUT != TRUE -all .PHONY: -.ENDIF # ENABLE_LAYOUT != TRUE diff --git a/toolkit/workben/layout/sortdlg.src b/toolkit/workben/layout/sortdlg.src index f9980f36002c..f52758f61785 100644 --- a/toolkit/workben/layout/sortdlg.src +++ b/toolkit/workben/layout/sortdlg.src @@ -33,6 +33,7 @@ TabPage RID_SCPAGE_SORT_FIELDS Size = MAP_APPFONT ( 260 , 185 ) ; ListBox LB_SORT1 { + HelpID = "toolkit:ListBox:RID_SCPAGE_SORT_FIELDS:LB_SORT1"; Border = TRUE ; Pos = MAP_APPFONT ( 12 , 19 ) ; Size = MAP_APPFONT ( 154 , 90 ) ; @@ -41,6 +42,7 @@ TabPage RID_SCPAGE_SORT_FIELDS }; RadioButton BTN_UP1 { + HelpID = "toolkit:RadioButton:RID_SCPAGE_SORT_FIELDS:BTN_UP1"; Pos = MAP_APPFONT ( 172 , 14 ) ; Size = MAP_APPFONT ( 79 , 10 ) ; Text [ en-US ] = "~Ascending" ; @@ -48,6 +50,7 @@ TabPage RID_SCPAGE_SORT_FIELDS }; RadioButton BTN_DOWN1 { + HelpID = "toolkit:RadioButton:RID_SCPAGE_SORT_FIELDS:BTN_DOWN1"; Pos = MAP_APPFONT ( 172 , 28 ) ; Size = MAP_APPFONT ( 79 , 10 ) ; Text [ en-US ] = "~Descending" ; @@ -61,6 +64,7 @@ TabPage RID_SCPAGE_SORT_FIELDS }; ListBox LB_SORT2 { + HelpID = "toolkit:ListBox:RID_SCPAGE_SORT_FIELDS:LB_SORT2"; Border = TRUE ; Pos = MAP_APPFONT ( 12 , 60 ) ; Size = MAP_APPFONT ( 154 , 90 ) ; @@ -69,6 +73,7 @@ TabPage RID_SCPAGE_SORT_FIELDS }; RadioButton BTN_UP2 { + HelpID = "toolkit:RadioButton:RID_SCPAGE_SORT_FIELDS:BTN_UP2"; Pos = MAP_APPFONT ( 172 , 55 ) ; Size = MAP_APPFONT ( 79 , 10 ) ; Text [ en-US ] = "A~scending" ; @@ -76,6 +81,7 @@ TabPage RID_SCPAGE_SORT_FIELDS }; RadioButton BTN_DOWN2 { + HelpID = "toolkit:RadioButton:RID_SCPAGE_SORT_FIELDS:BTN_DOWN2"; Pos = MAP_APPFONT ( 172 , 69 ) ; Size = MAP_APPFONT ( 79 , 10 ) ; Text [ en-US ] = "D~escending" ; @@ -89,6 +95,7 @@ TabPage RID_SCPAGE_SORT_FIELDS }; ListBox LB_SORT3 { + HelpID = "toolkit:ListBox:RID_SCPAGE_SORT_FIELDS:LB_SORT3"; Border = TRUE ; Pos = MAP_APPFONT ( 12 , 101 ) ; Size = MAP_APPFONT ( 154 , 90 ) ; @@ -97,6 +104,7 @@ TabPage RID_SCPAGE_SORT_FIELDS }; RadioButton BTN_UP3 { + HelpID = "toolkit:RadioButton:RID_SCPAGE_SORT_FIELDS:BTN_UP3"; Pos = MAP_APPFONT ( 172 , 96 ) ; Size = MAP_APPFONT ( 79 , 10 ) ; Text [ en-US ] = "As~cending" ; @@ -104,6 +112,7 @@ TabPage RID_SCPAGE_SORT_FIELDS }; RadioButton BTN_DOWN3 { + HelpID = "toolkit:RadioButton:RID_SCPAGE_SORT_FIELDS:BTN_DOWN3"; Pos = MAP_APPFONT ( 172 , 110 ) ; Size = MAP_APPFONT ( 79 , 10 ) ; Text [ en-US ] = "Desce~nding" ; @@ -126,6 +135,7 @@ TabPage RID_SCPAGE_SORT_OPTIONS Size = MAP_APPFONT ( 260 , 185 ) ; CheckBox BTN_CASESENSITIVE { + HelpID = "toolkit:CheckBox:RID_SCPAGE_SORT_OPTIONS:BTN_CASESENSITIVE"; Pos = MAP_APPFONT ( 12 , 6 ) ; Size = MAP_APPFONT ( 242 , 10 ) ; Text [ en-US ] = "Case ~sensitive" ; @@ -133,6 +143,7 @@ TabPage RID_SCPAGE_SORT_OPTIONS }; CheckBox BTN_LABEL { + HelpID = "toolkit:CheckBox:RID_SCPAGE_SORT_OPTIONS:BTN_LABEL"; Pos = MAP_APPFONT ( 12 , 20 ) ; Size = MAP_APPFONT ( 242 , 10 ) ; TabStop = TRUE ; @@ -147,6 +158,7 @@ TabPage RID_SCPAGE_SORT_OPTIONS }; CheckBox BTN_FORMATS { + HelpID = "toolkit:CheckBox:RID_SCPAGE_SORT_OPTIONS:BTN_FORMATS"; Pos = MAP_APPFONT ( 12 , 34 ) ; Size = MAP_APPFONT ( 242 , 10 ) ; Text [ en-US ] = "Include ~formats" ; @@ -154,6 +166,7 @@ TabPage RID_SCPAGE_SORT_OPTIONS }; CheckBox BTN_NATURALSORT { + HelpID = "toolkit:CheckBox:RID_SCPAGE_SORT_OPTIONS:BTN_NATURALSORT"; Pos = MAP_APPFONT ( 12 , 48 ) ; Size = MAP_APPFONT ( 242 , 10 ) ; Text [ de ] = "Enable ~natural sort" ; @@ -165,6 +178,7 @@ TabPage RID_SCPAGE_SORT_OPTIONS }; CheckBox BTN_COPYRESULT { + HelpID = "toolkit:CheckBox:RID_SCPAGE_SORT_OPTIONS:BTN_COPYRESULT"; Pos = MAP_APPFONT ( 12 , 62 ) ; Size = MAP_APPFONT ( 242 , 10 ) ; Text [ en-US ] = "~Copy sort results to:" ; @@ -172,6 +186,7 @@ TabPage RID_SCPAGE_SORT_OPTIONS }; ListBox LB_OUTAREA { + HelpID = "toolkit:ListBox:RID_SCPAGE_SORT_OPTIONS:LB_OUTAREA"; Border = TRUE ; Pos = MAP_APPFONT ( 20 , 73 ) ; Size = MAP_APPFONT ( 93 , 90 ) ; @@ -180,6 +195,7 @@ TabPage RID_SCPAGE_SORT_OPTIONS }; Edit ED_OUTAREA { + HelpID = "toolkit:Edit:RID_SCPAGE_SORT_OPTIONS:ED_OUTAREA"; Disable = TRUE ; Border = TRUE ; Pos = MAP_APPFONT ( 119 , 73 ) ; @@ -188,6 +204,7 @@ TabPage RID_SCPAGE_SORT_OPTIONS }; CheckBox BTN_SORT_USER { + HelpID = "toolkit:CheckBox:RID_SCPAGE_SORT_OPTIONS:BTN_SORT_USER"; Pos = MAP_APPFONT ( 12 , 89 ) ; Size = MAP_APPFONT ( 242 , 10 ) ; Text [ en-US ] = "Custom sort ~order" ; @@ -195,6 +212,7 @@ TabPage RID_SCPAGE_SORT_OPTIONS }; ListBox LB_SORT_USER { + HelpID = "toolkit:ListBox:RID_SCPAGE_SORT_OPTIONS:LB_SORT_USER"; Disable = TRUE ; Border = TRUE ; Pos = MAP_APPFONT ( 20 , 100 ) ; @@ -210,6 +228,7 @@ TabPage RID_SCPAGE_SORT_OPTIONS }; ListBox LB_LANGUAGE { + HelpID = "toolkit:ListBox:RID_SCPAGE_SORT_OPTIONS:LB_LANGUAGE"; Border = TRUE ; Pos = MAP_APPFONT ( 12 , 129 ) ; Size = MAP_APPFONT ( 101 , 90 ) ; @@ -225,6 +244,7 @@ TabPage RID_SCPAGE_SORT_OPTIONS }; ListBox LB_ALGORITHM { + HelpID = "toolkit:ListBox:RID_SCPAGE_SORT_OPTIONS:LB_ALGORITHM"; Border = TRUE ; Pos = MAP_APPFONT ( 119 , 129 ) ; Size = MAP_APPFONT ( 132 , 90 ) ; @@ -239,6 +259,7 @@ TabPage RID_SCPAGE_SORT_OPTIONS }; RadioButton BTN_TOP_DOWN { + HelpID = "toolkit:RadioButton:RID_SCPAGE_SORT_OPTIONS:BTN_TOP_DOWN"; Pos = MAP_APPFONT ( 12 , 158 ) ; Size = MAP_APPFONT ( 242 , 10 ) ; Text [ en-US ] = "~Top to bottom (sort rows)" ; @@ -246,6 +267,7 @@ TabPage RID_SCPAGE_SORT_OPTIONS }; RadioButton BTN_LEFT_RIGHT { + HelpID = "toolkit:RadioButton:RID_SCPAGE_SORT_OPTIONS:BTN_LEFT_RIGHT"; Pos = MAP_APPFONT ( 12 , 172 ) ; Size = MAP_APPFONT ( 242 , 10 ) ; Text [ en-US ] = "L~eft to right (sort columns)" ; diff --git a/toolkit/workben/makefile.mk b/toolkit/workben/makefile.mk deleted file mode 100644 index 8e54c7737a20..000000000000 --- a/toolkit/workben/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=unodialog -LIBTARGET=NO -ENABLE_EXCEPTIONS=TRUE - - -# --- Settings ----------------------------------------------------- - -.INCLUDE : settings.mk - -# --- Files -------------------------------------------------------- - -CXXFILES= unodialog.cxx - -OBJFILES= $(OBJ)$/unodialog.obj - - -APP2NOSAL= TRUE -APP2TARGET= unodialog -APP2OBJS= $(OBJ)$/unodialog.obj -APP2STDLIBS=$(TOOLSLIB) \ - $(SOTLIB) \ - $(COMPHELPERLIB) \ - $(CPPULIB) \ - $(CPPUHELPERLIB) \ - $(VCLLIB) \ - $(SALLIB) - -# $(SVTOOLLIB) \ - -APP2DEF= $(MISC)$/unodialog.def - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk - - -# ------------------------------------------------------------------ -# Windows -# ------------------------------------------------------------------ - -.IF "$(GUI)" == "WIN" - -$(MISC)$/unodialog.def: makefile.mk - echo NAME unodialog >$@ - echo DESCRIPTION 'StarView - Testprogramm' >>$@ - echo EXETYPE WINDOWS >>$@ - echo STUB 'winSTUB.EXE' >>$@ - echo PROTMODE >>$@ - echo CODE PRELOAD MOVEABLE DISCARDABLE >>$@ - echo DATA PRELOAD MOVEABLE MULTIPLE >>$@ - echo HEAPSIZE 8192 >>$@ - echo STACKSIZE 32768 >>$@ - -.ENDIF |