From 95780ec73990f96dc16fc677c895d00fa1360008 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Sat, 21 Jan 2012 12:02:46 +0100 Subject: refactor concept for c++ based subsequenttests --- sc/CppunitTest_sc_cellrangeobj.mk | 142 +++++++++ sc/CppunitTest_sc_cellrangesbase.mk | 143 --------- sc/CppunitTest_sc_databaserangeobj.mk | 3 +- sc/CppunitTest_sc_datapilotdescriptorbase.mk | 143 --------- sc/CppunitTest_sc_datapilotfieldobj.mk | 3 +- sc/CppunitTest_sc_datapilottableobj.mk | 142 +++++++++ sc/CppunitTest_sc_namedrangeobj.mk | 3 +- sc/CppunitTest_sc_namedrangesobj.mk | 142 +++++++++ sc/CppunitTest_sc_spreadsheetobj.mk | 139 --------- sc/CppunitTest_sc_tablesheetsobj.mk | 139 +++++++++ sc/Module_sc.mk | 14 +- sc/qa/extras/cellproperties.cxx | 148 --------- sc/qa/extras/datapilotfieldobj.cxx | 264 ---------------- sc/qa/extras/sccellrangeobj.cxx | 116 +++++++ sc/qa/extras/scdatabaserangeobj.cxx | 106 +++++++ sc/qa/extras/scdatapilotfieldobj.cxx | 123 ++++++++ sc/qa/extras/scdatapilottableobj.cxx | 129 ++++++++ sc/qa/extras/scnamedrangeobj.cxx | 117 +++++++ sc/qa/extras/scnamedrangesobj.cxx | 110 +++++++ sc/qa/extras/sctablesheetsobj.cxx | 138 +++++++++ sc/qa/extras/tableautoformatfield.cxx | 131 -------- sc/qa/extras/testdocuments/rangenamessrc.ods | Bin 9250 -> 9089 bytes sc/qa/extras/xcellrangesquery.cxx | 196 ------------ sc/qa/extras/xdatabaserange.cxx | 209 ------------- sc/qa/extras/xdatapilotdescriptor.cxx | 311 ------------------- sc/qa/extras/xdatapilotfieldgrouping.cxx | 149 --------- sc/qa/extras/xdatapilottable.cxx | 149 --------- sc/qa/extras/xnamecontainer.cxx | 85 ----- sc/qa/extras/xnamedrange.cxx | 201 ------------ sc/qa/extras/xnamedranges.cxx | 259 ---------------- sc/qa/extras/xspreadsheets2.cxx | 447 --------------------------- 31 files changed, 1415 insertions(+), 2986 deletions(-) create mode 100644 sc/CppunitTest_sc_cellrangeobj.mk delete mode 100644 sc/CppunitTest_sc_cellrangesbase.mk delete mode 100644 sc/CppunitTest_sc_datapilotdescriptorbase.mk create mode 100644 sc/CppunitTest_sc_datapilottableobj.mk create mode 100644 sc/CppunitTest_sc_namedrangesobj.mk delete mode 100644 sc/CppunitTest_sc_spreadsheetobj.mk create mode 100644 sc/CppunitTest_sc_tablesheetsobj.mk delete mode 100644 sc/qa/extras/cellproperties.cxx delete mode 100644 sc/qa/extras/datapilotfieldobj.cxx create mode 100644 sc/qa/extras/sccellrangeobj.cxx create mode 100644 sc/qa/extras/scdatabaserangeobj.cxx create mode 100644 sc/qa/extras/scdatapilotfieldobj.cxx create mode 100644 sc/qa/extras/scdatapilottableobj.cxx create mode 100644 sc/qa/extras/scnamedrangeobj.cxx create mode 100644 sc/qa/extras/scnamedrangesobj.cxx create mode 100644 sc/qa/extras/sctablesheetsobj.cxx delete mode 100644 sc/qa/extras/tableautoformatfield.cxx delete mode 100644 sc/qa/extras/xcellrangesquery.cxx delete mode 100644 sc/qa/extras/xdatabaserange.cxx delete mode 100644 sc/qa/extras/xdatapilotdescriptor.cxx delete mode 100644 sc/qa/extras/xdatapilotfieldgrouping.cxx delete mode 100644 sc/qa/extras/xdatapilottable.cxx delete mode 100644 sc/qa/extras/xnamecontainer.cxx delete mode 100644 sc/qa/extras/xnamedrange.cxx delete mode 100644 sc/qa/extras/xnamedranges.cxx delete mode 100644 sc/qa/extras/xspreadsheets2.cxx (limited to 'sc') diff --git a/sc/CppunitTest_sc_cellrangeobj.mk b/sc/CppunitTest_sc_cellrangeobj.mk new file mode 100644 index 000000000000..c72a1c283e08 --- /dev/null +++ b/sc/CppunitTest_sc_cellrangeobj.mk @@ -0,0 +1,142 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +#************************************************************************* +# Version: MPL 1.1 / GPLv3+ / LGPLv3+ +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License or as specified alternatively below. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Initial Developer of the Original Code is +# Markus Mohrhard +# Portions created by the Initial Developer are Copyright (C) 2011 the +# Initial Developer. All Rights Reserved. +# +# Major Contributor(s): +# +# For minor contributions see the git repository. +# +# Alternatively, the contents of this file may be used under the terms of +# either the GNU General Public License Version 3 or later (the "GPLv3+"), or +# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), +# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable +# instead of those above. +#************************************************************************* + +$(eval $(call gb_CppunitTest_CppunitTest,sc_cellrangesbase)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sc_cellrangesbase, \ + sc/qa/extras/sccellrangeobj\ +)) + +$(eval $(call gb_CppunitTest_add_linked_libs,sc_cellrangesbase, \ + avmedia \ + basegfx \ + comphelper \ + cppu \ + cppuhelper \ + drawinglayer \ + editeng \ + fileacc \ + for \ + forui \ + i18nisolang1 \ + msfilter \ + oox \ + sal \ + salhelper \ + sax \ + sb \ + sc \ + sfx \ + sot \ + svl \ + svt \ + svx \ + svxcore \ + test \ + tl \ + tk \ + subsequenttest \ + ucbhelper \ + unotest \ + utl \ + vbahelper \ + vcl \ + xo \ + $(gb_STDLIBS) \ +)) + +$(eval $(call gb_CppunitTest_set_include,sc_cellrangesbase,\ + -I$(realpath $(SRCDIR)/sc/source/ui/inc) \ + -I$(realpath $(SRCDIR)/sc/inc) \ + $$(INCLUDE) \ + -I$(OUTDIR)/inc \ +)) + +$(eval $(call gb_CppunitTest_add_api,sc_cellrangesbase,\ + offapi \ + udkapi \ +)) + +$(eval $(call gb_CppunitTest_uses_ure,sc_cellrangesbase)) + +$(eval $(call gb_CppunitTest_add_type_rdbs,sc_cellrangesbase,\ + types \ +)) + +$(eval $(call gb_CppunitTest_add_components,sc_cellrangesbase,\ + basic/util/sb \ + comphelper/util/comphelp \ + configmgr/source/configmgr \ + dbaccess/util/dba \ + fileaccess/source/fileacc \ + filter/source/config/cache/filterconfig1 \ + forms/util/frm \ + framework/util/fwk \ + i18npool/util/i18npool \ + oox/util/oox \ + package/source/xstor/xstor \ + package/util/package2 \ + sax/source/expatwrap/expwrap \ + sax/source/fastparser/fastsax \ + sc/util/sc \ + sc/util/scd \ + sc/util/scfilt \ + sc/util/vbaobj \ + scripting/source/basprov/basprov \ + scripting/util/scriptframe \ + sfx2/util/sfx \ + sot/util/sot \ + svl/source/fsstor/fsstorage \ + toolkit/util/tk \ + ucb/source/core/ucb1 \ + ucb/source/ucp/file/ucpfile1 \ + ucb/source/ucp/tdoc/ucptdoc1 \ + unotools/util/utl \ + unoxml/source/rdf/unordf \ + unoxml/source/service/unoxml \ +)) + +$(eval $(call gb_CppunitTest_set_args,sc_cellrangesbase,\ + --headless \ + --protector unoexceptionprotector$(gb_Library_DLLEXT) unoexceptionprotector \ + "-env:CONFIGURATION_LAYERS=xcsxcu:$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry) module:$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry/spool) xcsxcu:$(call gb_CppunitTarget__make_url,$(OUTDIR)/unittest/registry)" \ +)) + # .../spool is required for the (somewhat strange) filter configuration + +# we need to +# a) explicitly depend on library msword because it is not implied by a link +# relation +# b) explicitly depend on the sc resource files needed at unit-test runtime +$(call gb_CppunitTest_get_target,sc_cellrangesbase) : \ + $(WORKDIR)/AllLangRes/sc \ + $(call gb_Library_get_target,localedata_en) \ + $(call gb_Library_get_target,scfilt) \ + +# vim: set noet sw=4 ts=4: diff --git a/sc/CppunitTest_sc_cellrangesbase.mk b/sc/CppunitTest_sc_cellrangesbase.mk deleted file mode 100644 index 12c96a866561..000000000000 --- a/sc/CppunitTest_sc_cellrangesbase.mk +++ /dev/null @@ -1,143 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -#************************************************************************* -# Version: MPL 1.1 / GPLv3+ / LGPLv3+ -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License or as specified alternatively below. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Initial Developer of the Original Code is -# Markus Mohrhard -# Portions created by the Initial Developer are Copyright (C) 2011 the -# Initial Developer. All Rights Reserved. -# -# Major Contributor(s): -# -# For minor contributions see the git repository. -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 3 or later (the "GPLv3+"), or -# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), -# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable -# instead of those above. -#************************************************************************* - -$(eval $(call gb_CppunitTest_CppunitTest,sc_cellrangesbase)) - -$(eval $(call gb_CppunitTest_add_exception_objects,sc_cellrangesbase, \ - sc/qa/extras/xcellrangesquery \ - sc/qa/extras/cellproperties \ -)) - -$(eval $(call gb_CppunitTest_add_linked_libs,sc_cellrangesbase, \ - avmedia \ - basegfx \ - comphelper \ - cppu \ - cppuhelper \ - drawinglayer \ - editeng \ - fileacc \ - for \ - forui \ - i18nisolang1 \ - msfilter \ - oox \ - sal \ - salhelper \ - sax \ - sb \ - sc \ - sfx \ - sot \ - svl \ - svt \ - svx \ - svxcore \ - test \ - tl \ - tk \ - subsequenttest \ - ucbhelper \ - unotest \ - utl \ - vbahelper \ - vcl \ - xo \ - $(gb_STDLIBS) \ -)) - -$(eval $(call gb_CppunitTest_set_include,sc_cellrangesbase,\ - -I$(realpath $(SRCDIR)/sc/source/ui/inc) \ - -I$(realpath $(SRCDIR)/sc/inc) \ - $$(INCLUDE) \ - -I$(OUTDIR)/inc \ -)) - -$(eval $(call gb_CppunitTest_add_api,sc_cellrangesbase,\ - offapi \ - udkapi \ -)) - -$(eval $(call gb_CppunitTest_uses_ure,sc_cellrangesbase)) - -$(eval $(call gb_CppunitTest_add_type_rdbs,sc_cellrangesbase,\ - types \ -)) - -$(eval $(call gb_CppunitTest_add_components,sc_cellrangesbase,\ - basic/util/sb \ - comphelper/util/comphelp \ - configmgr/source/configmgr \ - dbaccess/util/dba \ - fileaccess/source/fileacc \ - filter/source/config/cache/filterconfig1 \ - forms/util/frm \ - framework/util/fwk \ - i18npool/util/i18npool \ - oox/util/oox \ - package/source/xstor/xstor \ - package/util/package2 \ - sax/source/expatwrap/expwrap \ - sax/source/fastparser/fastsax \ - sc/util/sc \ - sc/util/scd \ - sc/util/scfilt \ - sc/util/vbaobj \ - scripting/source/basprov/basprov \ - scripting/util/scriptframe \ - sfx2/util/sfx \ - sot/util/sot \ - svl/source/fsstor/fsstorage \ - toolkit/util/tk \ - ucb/source/core/ucb1 \ - ucb/source/ucp/file/ucpfile1 \ - ucb/source/ucp/tdoc/ucptdoc1 \ - unotools/util/utl \ - unoxml/source/rdf/unordf \ - unoxml/source/service/unoxml \ -)) - -$(eval $(call gb_CppunitTest_set_args,sc_cellrangesbase,\ - --headless \ - --protector unoexceptionprotector$(gb_Library_DLLEXT) unoexceptionprotector \ - "-env:CONFIGURATION_LAYERS=xcsxcu:$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry) module:$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry/spool) xcsxcu:$(call gb_CppunitTarget__make_url,$(OUTDIR)/unittest/registry)" \ -)) - # .../spool is required for the (somewhat strange) filter configuration - -# we need to -# a) explicitly depend on library msword because it is not implied by a link -# relation -# b) explicitly depend on the sc resource files needed at unit-test runtime -$(call gb_CppunitTest_get_target,sc_cellrangesbase) : \ - $(WORKDIR)/AllLangRes/sc \ - $(call gb_Library_get_target,localedata_en) \ - $(call gb_Library_get_target,scfilt) \ - -# vim: set noet sw=4 ts=4: diff --git a/sc/CppunitTest_sc_databaserangeobj.mk b/sc/CppunitTest_sc_databaserangeobj.mk index a5ba678610f3..d201ca81d4b1 100644 --- a/sc/CppunitTest_sc_databaserangeobj.mk +++ b/sc/CppunitTest_sc_databaserangeobj.mk @@ -31,7 +31,7 @@ $(eval $(call gb_CppunitTest_CppunitTest,sc_databaserangeobj)) $(eval $(call gb_CppunitTest_add_exception_objects,sc_databaserangeobj, \ - sc/qa/extras/xdatabaserange \ + sc/qa/extras/scdatabaserangeobj \ )) $(eval $(call gb_CppunitTest_add_linked_libs,sc_databaserangeobj, \ @@ -55,6 +55,7 @@ $(eval $(call gb_CppunitTest_add_linked_libs,sc_databaserangeobj, \ sc \ sfx \ sot \ + subsequenttest \ svl \ svt \ svx \ diff --git a/sc/CppunitTest_sc_datapilotdescriptorbase.mk b/sc/CppunitTest_sc_datapilotdescriptorbase.mk deleted file mode 100644 index 31a49b80a8f7..000000000000 --- a/sc/CppunitTest_sc_datapilotdescriptorbase.mk +++ /dev/null @@ -1,143 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -#************************************************************************* -# Version: MPL 1.1 / GPLv3+ / LGPLv3+ -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License or as specified alternatively below. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Initial Developer of the Original Code is -# Markus Mohrhard -# Portions created by the Initial Developer are Copyright (C) 2011 the -# Initial Developer. All Rights Reserved. -# -# Major Contributor(s): -# -# For minor contributions see the git repository. -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 3 or later (the "GPLv3+"), or -# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), -# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable -# instead of those above. -#************************************************************************* - -$(eval $(call gb_CppunitTest_CppunitTest,sc_datapilotdescriptorbase)) - -$(eval $(call gb_CppunitTest_add_exception_objects,sc_datapilotdescriptorbase, \ - sc/qa/extras/xdatapilotdescriptor \ - sc/qa/extras/xdatapilottable \ -)) - -$(eval $(call gb_CppunitTest_add_linked_libs,sc_datapilotdescriptorbase, \ - avmedia \ - basegfx \ - comphelper \ - cppu \ - cppuhelper \ - drawinglayer \ - editeng \ - fileacc \ - for \ - forui \ - i18nisolang1 \ - msfilter \ - oox \ - sal \ - salhelper \ - sax \ - sb \ - sc \ - sfx \ - sot \ - svl \ - svt \ - svx \ - svxcore \ - test \ - tl \ - tk \ - subsequenttest \ - ucbhelper \ - unotest \ - utl \ - vbahelper \ - vcl \ - xo \ - $(gb_STDLIBS) \ -)) - -$(eval $(call gb_CppunitTest_set_include,sc_datapilotdescriptorbase,\ - -I$(realpath $(SRCDIR)/sc/source/ui/inc) \ - -I$(realpath $(SRCDIR)/sc/inc) \ - $$(INCLUDE) \ - -I$(OUTDIR)/inc \ -)) - -$(eval $(call gb_CppunitTest_add_api,sc_datapilotdescriptorbase,\ - offapi \ - udkapi \ -)) - -$(eval $(call gb_CppunitTest_uses_ure,sc_datapilotdescriptorbase)) - -$(eval $(call gb_CppunitTest_add_type_rdbs,sc_datapilotdescriptorbase,\ - types \ -)) - -$(eval $(call gb_CppunitTest_add_components,sc_datapilotdescriptorbase,\ - basic/util/sb \ - comphelper/util/comphelp \ - configmgr/source/configmgr \ - dbaccess/util/dba \ - fileaccess/source/fileacc \ - filter/source/config/cache/filterconfig1 \ - forms/util/frm \ - framework/util/fwk \ - i18npool/util/i18npool \ - oox/util/oox \ - package/source/xstor/xstor \ - package/util/package2 \ - sax/source/expatwrap/expwrap \ - sax/source/fastparser/fastsax \ - sc/util/sc \ - sc/util/scd \ - sc/util/scfilt \ - sc/util/vbaobj \ - scripting/source/basprov/basprov \ - scripting/util/scriptframe \ - sfx2/util/sfx \ - sot/util/sot \ - svl/source/fsstor/fsstorage \ - toolkit/util/tk \ - ucb/source/core/ucb1 \ - ucb/source/ucp/file/ucpfile1 \ - ucb/source/ucp/tdoc/ucptdoc1 \ - unotools/util/utl \ - unoxml/source/rdf/unordf \ - unoxml/source/service/unoxml \ -)) - -$(eval $(call gb_CppunitTest_set_args,sc_datapilotdescriptorbase,\ - --headless \ - --protector unoexceptionprotector$(gb_Library_DLLEXT) unoexceptionprotector \ - "-env:CONFIGURATION_LAYERS=xcsxcu:$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry) module:$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry/spool) xcsxcu:$(call gb_CppunitTarget__make_url,$(OUTDIR)/unittest/registry)" \ -)) - # .../spool is required for the (somewhat strange) filter configuration - -# we need to -# a) explicitly depend on library msword because it is not implied by a link -# relation -# b) explicitly depend on the sc resource files needed at unit-test runtime -$(call gb_CppunitTest_get_target,sc_datapilotdescriptorbase) : \ - $(WORKDIR)/AllLangRes/sc \ - $(call gb_Library_get_target,localedata_en) \ - $(call gb_Library_get_target,scfilt) \ - -# vim: set noet sw=4 ts=4: diff --git a/sc/CppunitTest_sc_datapilotfieldobj.mk b/sc/CppunitTest_sc_datapilotfieldobj.mk index 5898d3d57ef9..01f8c418cd79 100644 --- a/sc/CppunitTest_sc_datapilotfieldobj.mk +++ b/sc/CppunitTest_sc_datapilotfieldobj.mk @@ -31,8 +31,7 @@ $(eval $(call gb_CppunitTest_CppunitTest,sc_datapilotfieldobj)) $(eval $(call gb_CppunitTest_add_exception_objects,sc_datapilotfieldobj, \ - sc/qa/extras/datapilotfieldobj \ - sc/qa/extras/xdatapilotfieldgrouping \ + sc/qa/extras/scdatapilotfieldobj \ )) $(eval $(call gb_CppunitTest_add_linked_libs,sc_datapilotfieldobj, \ diff --git a/sc/CppunitTest_sc_datapilottableobj.mk b/sc/CppunitTest_sc_datapilottableobj.mk new file mode 100644 index 000000000000..05bca552c35e --- /dev/null +++ b/sc/CppunitTest_sc_datapilottableobj.mk @@ -0,0 +1,142 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +#************************************************************************* +# Version: MPL 1.1 / GPLv3+ / LGPLv3+ +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License or as specified alternatively below. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Initial Developer of the Original Code is +# Markus Mohrhard +# Portions created by the Initial Developer are Copyright (C) 2011 the +# Initial Developer. All Rights Reserved. +# +# Major Contributor(s): +# +# For minor contributions see the git repository. +# +# Alternatively, the contents of this file may be used under the terms of +# either the GNU General Public License Version 3 or later (the "GPLv3+"), or +# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), +# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable +# instead of those above. +#************************************************************************* + +$(eval $(call gb_CppunitTest_CppunitTest,sc_datapilottableobj)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sc_datapilottableobj, \ + sc/qa/extras/scdatapilottableobj \ +)) + +$(eval $(call gb_CppunitTest_add_linked_libs,sc_datapilottableobj, \ + avmedia \ + basegfx \ + comphelper \ + cppu \ + cppuhelper \ + drawinglayer \ + editeng \ + fileacc \ + for \ + forui \ + i18nisolang1 \ + msfilter \ + oox \ + sal \ + salhelper \ + sax \ + sb \ + sc \ + sfx \ + sot \ + svl \ + svt \ + svx \ + svxcore \ + test \ + tl \ + tk \ + subsequenttest \ + ucbhelper \ + unotest \ + utl \ + vbahelper \ + vcl \ + xo \ + $(gb_STDLIBS) \ +)) + +$(eval $(call gb_CppunitTest_set_include,sc_datapilottableobj,\ + -I$(realpath $(SRCDIR)/sc/source/ui/inc) \ + -I$(realpath $(SRCDIR)/sc/inc) \ + $$(INCLUDE) \ + -I$(OUTDIR)/inc \ +)) + +$(eval $(call gb_CppunitTest_add_api,sc_datapilottableobj,\ + offapi \ + udkapi \ +)) + +$(eval $(call gb_CppunitTest_uses_ure,sc_datapilottableobj)) + +$(eval $(call gb_CppunitTest_add_type_rdbs,sc_datapilottableobj,\ + types \ +)) + +$(eval $(call gb_CppunitTest_add_components,sc_datapilottableobj,\ + basic/util/sb \ + comphelper/util/comphelp \ + configmgr/source/configmgr \ + dbaccess/util/dba \ + fileaccess/source/fileacc \ + filter/source/config/cache/filterconfig1 \ + forms/util/frm \ + framework/util/fwk \ + i18npool/util/i18npool \ + oox/util/oox \ + package/source/xstor/xstor \ + package/util/package2 \ + sax/source/expatwrap/expwrap \ + sax/source/fastparser/fastsax \ + sc/util/sc \ + sc/util/scd \ + sc/util/scfilt \ + sc/util/vbaobj \ + scripting/source/basprov/basprov \ + scripting/util/scriptframe \ + sfx2/util/sfx \ + sot/util/sot \ + svl/source/fsstor/fsstorage \ + toolkit/util/tk \ + ucb/source/core/ucb1 \ + ucb/source/ucp/file/ucpfile1 \ + ucb/source/ucp/tdoc/ucptdoc1 \ + unotools/util/utl \ + unoxml/source/rdf/unordf \ + unoxml/source/service/unoxml \ +)) + +$(eval $(call gb_CppunitTest_set_args,sc_datapilottableobj,\ + --headless \ + --protector unoexceptionprotector$(gb_Library_DLLEXT) unoexceptionprotector \ + "-env:CONFIGURATION_LAYERS=xcsxcu:$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry) module:$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry/spool) xcsxcu:$(call gb_CppunitTarget__make_url,$(OUTDIR)/unittest/registry)" \ +)) + # .../spool is required for the (somewhat strange) filter configuration + +# we need to +# a) explicitly depend on library msword because it is not implied by a link +# relation +# b) explicitly depend on the sc resource files needed at unit-test runtime +$(call gb_CppunitTest_get_target,sc_datapilottableobj) : \ + $(WORKDIR)/AllLangRes/sc \ + $(call gb_Library_get_target,localedata_en) \ + $(call gb_Library_get_target,scfilt) \ + +# vim: set noet sw=4 ts=4: diff --git a/sc/CppunitTest_sc_namedrangeobj.mk b/sc/CppunitTest_sc_namedrangeobj.mk index bd2d7d9662b1..948e84de2fb5 100644 --- a/sc/CppunitTest_sc_namedrangeobj.mk +++ b/sc/CppunitTest_sc_namedrangeobj.mk @@ -31,8 +31,7 @@ $(eval $(call gb_CppunitTest_CppunitTest,sc_namedrangeobj)) $(eval $(call gb_CppunitTest_add_exception_objects,sc_namedrangeobj, \ - sc/qa/extras/xnamedranges \ - sc/qa/extras/xnamedrange \ + sc/qa/extras/scnamedrangeobj \ )) $(eval $(call gb_CppunitTest_add_linked_libs,sc_namedrangeobj, \ diff --git a/sc/CppunitTest_sc_namedrangesobj.mk b/sc/CppunitTest_sc_namedrangesobj.mk new file mode 100644 index 000000000000..6a4e968d8b58 --- /dev/null +++ b/sc/CppunitTest_sc_namedrangesobj.mk @@ -0,0 +1,142 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +#************************************************************************* +# Version: MPL 1.1 / GPLv3+ / LGPLv3+ +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License or as specified alternatively below. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Initial Developer of the Original Code is +# Markus Mohrhard +# Portions created by the Initial Developer are Copyright (C) 2011 the +# Initial Developer. All Rights Reserved. +# +# Major Contributor(s): +# +# For minor contributions see the git repository. +# +# Alternatively, the contents of this file may be used under the terms of +# either the GNU General Public License Version 3 or later (the "GPLv3+"), or +# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), +# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable +# instead of those above. +#************************************************************************* + +$(eval $(call gb_CppunitTest_CppunitTest,sc_namedrangesobj)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sc_namedrangesobj, \ + sc/qa/extras/scnamedrangesobj \ +)) + +$(eval $(call gb_CppunitTest_add_linked_libs,sc_namedrangesobj, \ + avmedia \ + basegfx \ + comphelper \ + cppu \ + cppuhelper \ + drawinglayer \ + editeng \ + fileacc \ + for \ + forui \ + i18nisolang1 \ + msfilter \ + oox \ + sal \ + salhelper \ + sax \ + sb \ + sc \ + sfx \ + sot \ + svl \ + svt \ + svx \ + svxcore \ + test \ + tl \ + tk \ + subsequenttest \ + ucbhelper \ + unotest \ + utl \ + vbahelper \ + vcl \ + xo \ + $(gb_STDLIBS) \ +)) + +$(eval $(call gb_CppunitTest_set_include,sc_namedrangesobj,\ + -I$(realpath $(SRCDIR)/sc/source/ui/inc) \ + -I$(realpath $(SRCDIR)/sc/inc) \ + $$(INCLUDE) \ + -I$(OUTDIR)/inc \ +)) + +$(eval $(call gb_CppunitTest_add_api,sc_namedrangesobj,\ + offapi \ + udkapi \ +)) + +$(eval $(call gb_CppunitTest_uses_ure,sc_namedrangesobj)) + +$(eval $(call gb_CppunitTest_add_type_rdbs,sc_namedrangesobj,\ + types \ +)) + +$(eval $(call gb_CppunitTest_add_components,sc_namedrangesobj,\ + basic/util/sb \ + comphelper/util/comphelp \ + configmgr/source/configmgr \ + dbaccess/util/dba \ + fileaccess/source/fileacc \ + filter/source/config/cache/filterconfig1 \ + forms/util/frm \ + framework/util/fwk \ + i18npool/util/i18npool \ + oox/util/oox \ + package/source/xstor/xstor \ + package/util/package2 \ + sax/source/expatwrap/expwrap \ + sax/source/fastparser/fastsax \ + sc/util/sc \ + sc/util/scd \ + sc/util/scfilt \ + sc/util/vbaobj \ + scripting/source/basprov/basprov \ + scripting/util/scriptframe \ + sfx2/util/sfx \ + sot/util/sot \ + svl/source/fsstor/fsstorage \ + toolkit/util/tk \ + ucb/source/core/ucb1 \ + ucb/source/ucp/file/ucpfile1 \ + ucb/source/ucp/tdoc/ucptdoc1 \ + unotools/util/utl \ + unoxml/source/rdf/unordf \ + unoxml/source/service/unoxml \ +)) + +$(eval $(call gb_CppunitTest_set_args,sc_namedrangesobj,\ + --headless \ + --protector unoexceptionprotector$(gb_Library_DLLEXT) unoexceptionprotector \ + "-env:CONFIGURATION_LAYERS=xcsxcu:$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry) module:$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry/spool) xcsxcu:$(call gb_CppunitTarget__make_url,$(OUTDIR)/unittest/registry)" \ +)) + # .../spool is required for the (somewhat strange) filter configuration + +# we need to +# a) explicitly depend on library msword because it is not implied by a link +# relation +# b) explicitly depend on the sc resource files needed at unit-test runtime +$(call gb_CppunitTest_get_target,sc_namedrangesobj) : \ + $(WORKDIR)/AllLangRes/sc \ + $(call gb_Library_get_target,localedata_en) \ + $(call gb_Library_get_target,scfilt) \ + +# vim: set noet sw=4 ts=4: diff --git a/sc/CppunitTest_sc_spreadsheetobj.mk b/sc/CppunitTest_sc_spreadsheetobj.mk deleted file mode 100644 index 29779bd952bf..000000000000 --- a/sc/CppunitTest_sc_spreadsheetobj.mk +++ /dev/null @@ -1,139 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -#************************************************************************* -# Version: MPL 1.1 / GPLv3+ / LGPLv3+ -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License or as specified alternatively below. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Initial Developer of the Original Code is -# Markus Mohrhard -# Portions created by the Initial Developer are Copyright (C) 2011 the -# Initial Developer. All Rights Reserved. -# -# Major Contributor(s): -# -# For minor contributions see the git repository. -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 3 or later (the "GPLv3+"), or -# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), -# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable -# instead of those above. -#************************************************************************* - -$(eval $(call gb_CppunitTest_CppunitTest,sc_spreadsheetobj)) - -$(eval $(call gb_CppunitTest_add_exception_objects,sc_spreadsheetobj, \ - sc/qa/extras/xspreadsheets2 \ -)) - -$(eval $(call gb_CppunitTest_add_linked_libs,sc_spreadsheetobj, \ - avmedia \ - basegfx \ - comphelper \ - cppu \ - cppuhelper \ - drawinglayer \ - editeng \ - fileacc \ - for \ - forui \ - i18nisolang1 \ - msfilter \ - oox \ - sal \ - salhelper \ - sax \ - sb \ - sc \ - sfx \ - sot \ - subsequenttest \ - svl \ - svt \ - svx \ - svxcore \ - test \ - tl \ - tk \ - ucbhelper \ - unotest \ - utl \ - vbahelper \ - vcl \ - xo \ - $(gb_STDLIBS) \ -)) - -$(eval $(call gb_CppunitTest_set_include,sc_spreadsheetobj,\ - -I$(realpath $(SRCDIR)/sc/source/ui/inc) \ - -I$(realpath $(SRCDIR)/sc/inc) \ - $$(INCLUDE) \ - -I$(OUTDIR)/inc \ -)) - -$(eval $(call gb_CppunitTest_add_api,sc_spreadsheetobj,\ - offapi \ - udkapi \ -)) - -$(eval $(call gb_CppunitTest_uses_ure,sc_spreadsheetobj)) - -$(eval $(call gb_CppunitTest_add_type_rdbs,sc_spreadsheetobj,\ - types \ -)) - -$(eval $(call gb_CppunitTest_add_components,sc_spreadsheetobj,\ - basic/util/sb \ - comphelper/util/comphelp \ - configmgr/source/configmgr \ - dbaccess/util/dba \ - fileaccess/source/fileacc \ - filter/source/config/cache/filterconfig1 \ - forms/util/frm \ - framework/util/fwk \ - i18npool/util/i18npool \ - oox/util/oox \ - package/source/xstor/xstor \ - package/util/package2 \ - sax/source/expatwrap/expwrap \ - sax/source/fastparser/fastsax \ - sc/util/sc \ - sc/util/scd \ - sc/util/scfilt \ - sc/util/vbaobj \ - scripting/source/basprov/basprov \ - scripting/util/scriptframe \ - sfx2/util/sfx \ - sot/util/sot \ - svl/source/fsstor/fsstorage \ - toolkit/util/tk \ - ucb/source/core/ucb1 \ - ucb/source/ucp/file/ucpfile1 \ - ucb/source/ucp/tdoc/ucptdoc1 \ - unotools/util/utl \ - unoxml/source/rdf/unordf \ - unoxml/source/service/unoxml \ -)) - -$(eval $(call gb_CppunitTest_set_args,sc_spreadsheetobj,\ - --headless \ - --protector unoexceptionprotector$(gb_Library_DLLEXT) unoexceptionprotector \ - "-env:CONFIGURATION_LAYERS=xcsxcu:$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry) module:$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry/spool) xcsxcu:$(call gb_CppunitTarget__make_url,$(OUTDIR)/unittest/registry)" \ -)) - # .../spool is required for the (somewhat strange) filter configuration - -# we need to -# a) explicitly depend on library msword because it is not implied by a link -# relation -# b) explicitly depend on the sc resource files needed at unit-test runtime -$(call gb_CppunitTest_get_target,sc_spreadsheetobj) : $(call gb_Library_get_target,scfilt) $(WORKDIR)/AllLangRes/sc - -# vim: set noet sw=4 ts=4: diff --git a/sc/CppunitTest_sc_tablesheetsobj.mk b/sc/CppunitTest_sc_tablesheetsobj.mk new file mode 100644 index 000000000000..c7f43d0c7018 --- /dev/null +++ b/sc/CppunitTest_sc_tablesheetsobj.mk @@ -0,0 +1,139 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +#************************************************************************* +# Version: MPL 1.1 / GPLv3+ / LGPLv3+ +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License or as specified alternatively below. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Initial Developer of the Original Code is +# Markus Mohrhard +# Portions created by the Initial Developer are Copyright (C) 2011 the +# Initial Developer. All Rights Reserved. +# +# Major Contributor(s): +# +# For minor contributions see the git repository. +# +# Alternatively, the contents of this file may be used under the terms of +# either the GNU General Public License Version 3 or later (the "GPLv3+"), or +# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), +# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable +# instead of those above. +#************************************************************************* + +$(eval $(call gb_CppunitTest_CppunitTest,sc_spreadsheetobj)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sc_spreadsheetobj, \ + sc/qa/extras/sctablesheetsobj \ +)) + +$(eval $(call gb_CppunitTest_add_linked_libs,sc_spreadsheetobj, \ + avmedia \ + basegfx \ + comphelper \ + cppu \ + cppuhelper \ + drawinglayer \ + editeng \ + fileacc \ + for \ + forui \ + i18nisolang1 \ + msfilter \ + oox \ + sal \ + salhelper \ + sax \ + sb \ + sc \ + sfx \ + sot \ + subsequenttest \ + svl \ + svt \ + svx \ + svxcore \ + test \ + tl \ + tk \ + ucbhelper \ + unotest \ + utl \ + vbahelper \ + vcl \ + xo \ + $(gb_STDLIBS) \ +)) + +$(eval $(call gb_CppunitTest_set_include,sc_spreadsheetobj,\ + -I$(realpath $(SRCDIR)/sc/source/ui/inc) \ + -I$(realpath $(SRCDIR)/sc/inc) \ + $$(INCLUDE) \ + -I$(OUTDIR)/inc \ +)) + +$(eval $(call gb_CppunitTest_add_api,sc_spreadsheetobj,\ + offapi \ + udkapi \ +)) + +$(eval $(call gb_CppunitTest_uses_ure,sc_spreadsheetobj)) + +$(eval $(call gb_CppunitTest_add_type_rdbs,sc_spreadsheetobj,\ + types \ +)) + +$(eval $(call gb_CppunitTest_add_components,sc_spreadsheetobj,\ + basic/util/sb \ + comphelper/util/comphelp \ + configmgr/source/configmgr \ + dbaccess/util/dba \ + fileaccess/source/fileacc \ + filter/source/config/cache/filterconfig1 \ + forms/util/frm \ + framework/util/fwk \ + i18npool/util/i18npool \ + oox/util/oox \ + package/source/xstor/xstor \ + package/util/package2 \ + sax/source/expatwrap/expwrap \ + sax/source/fastparser/fastsax \ + sc/util/sc \ + sc/util/scd \ + sc/util/scfilt \ + sc/util/vbaobj \ + scripting/source/basprov/basprov \ + scripting/util/scriptframe \ + sfx2/util/sfx \ + sot/util/sot \ + svl/source/fsstor/fsstorage \ + toolkit/util/tk \ + ucb/source/core/ucb1 \ + ucb/source/ucp/file/ucpfile1 \ + ucb/source/ucp/tdoc/ucptdoc1 \ + unotools/util/utl \ + unoxml/source/rdf/unordf \ + unoxml/source/service/unoxml \ +)) + +$(eval $(call gb_CppunitTest_set_args,sc_spreadsheetobj,\ + --headless \ + --protector unoexceptionprotector$(gb_Library_DLLEXT) unoexceptionprotector \ + "-env:CONFIGURATION_LAYERS=xcsxcu:$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry) module:$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry/spool) xcsxcu:$(call gb_CppunitTarget__make_url,$(OUTDIR)/unittest/registry)" \ +)) + # .../spool is required for the (somewhat strange) filter configuration + +# we need to +# a) explicitly depend on library msword because it is not implied by a link +# relation +# b) explicitly depend on the sc resource files needed at unit-test runtime +$(call gb_CppunitTest_get_target,sc_spreadsheetobj) : $(call gb_Library_get_target,scfilt) $(WORKDIR)/AllLangRes/sc + +# vim: set noet sw=4 ts=4: diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk index 266f82277958..d7d28ef03d47 100644 --- a/sc/Module_sc.mk +++ b/sc/Module_sc.mk @@ -35,21 +35,21 @@ $(eval $(call gb_Module_add_targets,sc,\ )) $(eval $(call gb_Module_add_check_targets,sc,\ - CppunitTest_sc_filters_test \ CppunitTest_sc_ucalc \ + CppunitTest_sc_filters_test \ )) $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\ - CppunitTest_sc_cellrangesbase \ - CppunitTest_sc_datapilotdescriptorbase \ + JunitTest_sc_complex \ + JunitTest_sc_unoapi \ + CppunitTest_sc_cellrangeobj \ + CppunitTest_sc_datapilottableobj \ CppunitTest_sc_datapilotfieldobj \ CppunitTest_sc_macros_test \ CppunitTest_sc_namedrangeobj \ - CppunitTest_sc_spreadsheetobj \ + CppunitTest_sc_namedrangesobj \ + CppunitTest_sc_tablesheetsobj \ CppunitTest_sc_subsequent_filters_test \ - CppunitTest_sc_tableautoformatfield \ - JunitTest_sc_complex \ - JunitTest_sc_unoapi \ )) # vim: set noet sw=4 ts=4: diff --git a/sc/qa/extras/cellproperties.cxx b/sc/qa/extras/cellproperties.cxx deleted file mode 100644 index 29379153c54a..000000000000 --- a/sc/qa/extras/cellproperties.cxx +++ /dev/null @@ -1,148 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * Version: MPL 1.1 / GPLv3+ / LGPLv3+ - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License or as specified alternatively below. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Major Contributor(s): - * Copyright (C) 2011 Markus Mohrhard (initial developer) - * - * All Rights Reserved. - * - * For minor contributions see the git repository. - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 3 or later (the "GPLv3+"), or - * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), - * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable - * instead of those above. - */ - -#include - -#include -#include -#include -#include -#include -#include - -namespace ScCellRangeBase { - -#define NUMBER_OF_TESTS 2 - -class ScCellProperties : public UnoApiTest -{ -public: - virtual void setUp(); - virtual void tearDown(); - - void testVertJustify(); - void testRotateReference(); - CPPUNIT_TEST_SUITE(ScCellProperties); - CPPUNIT_TEST(testVertJustify); - CPPUNIT_TEST(testRotateReference); - CPPUNIT_TEST_SUITE_END(); - -private: - uno::Reference < beans::XPropertySet > init(); - - static int nTest; - static uno::Reference< lang::XComponent > xComponent; -}; - -int ScCellProperties::nTest = 0; -uno::Reference< lang::XComponent > ScCellProperties::xComponent; - - -void ScCellProperties::testVertJustify() -{ - uno::Reference< beans::XPropertySet > xCellRangeBase = init(); - rtl::OUString aVertJustify(RTL_CONSTASCII_USTRINGPARAM("VertJustify")); - uno::Any aOldVertJustify = xCellRangeBase->getPropertyValue(aVertJustify); - sal_Int32 aValue = 0; - CPPUNIT_ASSERT(aOldVertJustify >>= aValue); - std::cout << "Old VertJustify value: " << aValue << std::endl; - - uno::Any aNewVertJustify; - aNewVertJustify <<= static_cast(3); - xCellRangeBase->setPropertyValue(aVertJustify, aNewVertJustify); - uno::Any aVertJustifyControllValue = xCellRangeBase->getPropertyValue(aVertJustify); - CPPUNIT_ASSERT(aVertJustifyControllValue >>= aValue); - std::cout << "New VertJustify value: " << aValue << std::endl; - CPPUNIT_ASSERT_MESSAGE("value has not been changed", aValue == 3); -} - -void ScCellProperties::testRotateReference() -{ - uno::Reference< beans::XPropertySet > xCellRangeBase = init(); - rtl::OUString aRotateReference(RTL_CONSTASCII_USTRINGPARAM("RotateReference")); - uno::Any aOldRotateReference = xCellRangeBase->getPropertyValue(aRotateReference); - sal_Int32 aValue = 0; - CPPUNIT_ASSERT(aOldRotateReference >>= aValue); - std::cout << "Old RotateReference Value: " << aValue << std::endl; - - uno::Any aNewRotateReference; - aNewRotateReference <<= static_cast(3); - xCellRangeBase->setPropertyValue(aRotateReference, aNewRotateReference); - uno::Any aRotateReferenceControllValue = xCellRangeBase->getPropertyValue(aRotateReference); - CPPUNIT_ASSERT(aRotateReferenceControllValue >>= aValue); - std::cout << "New RotateReference value: " << aValue << std::endl; - CPPUNIT_ASSERT_MESSAGE("value has not been changed", aValue == 3); -} - -uno::Reference< beans::XPropertySet > ScCellProperties::init() -{ - rtl::OUString aFileURL; - const rtl::OUString aFileBase(RTL_CONSTASCII_USTRINGPARAM("xcellrangesquery.ods")); - createFileURL(aFileBase, aFileURL); - if( !xComponent.is()) - xComponent = loadFromDesktop(aFileURL); - uno::Reference< sheet::XSpreadsheetDocument> xDoc (xComponent, UNO_QUERY_THROW); - CPPUNIT_ASSERT(xDoc.is()); - - uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW); - uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW); - - CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is()); - - uno::Reference< table::XCellRange > xCellRange(xSheet->getCellRangeByPosition(0,0,3,4), UNO_QUERY_THROW); - CPPUNIT_ASSERT(xCellRange.is()); - - uno::Reference< beans::XPropertySet > xReturn(xCellRange, UNO_QUERY_THROW); - - CPPUNIT_ASSERT_MESSAGE("Could not create object of type XPropertySet", xReturn.is()); - return xReturn; -} - -void ScCellProperties::setUp() -{ - nTest += 1; - UnoApiTest::setUp(); -} - -void ScCellProperties::tearDown() -{ - if (nTest == NUMBER_OF_TESTS) - { - uno::Reference< util::XCloseable > xCloseable(xComponent, UNO_QUERY_THROW); - xCloseable->close( false ); - } - - UnoApiTest::tearDown(); - -} - -CPPUNIT_TEST_SUITE_REGISTRATION(ScCellProperties); - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/qa/extras/datapilotfieldobj.cxx b/sc/qa/extras/datapilotfieldobj.cxx deleted file mode 100644 index 8ebc424b4f2d..000000000000 --- a/sc/qa/extras/datapilotfieldobj.cxx +++ /dev/null @@ -1,264 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * Version: MPL 1.1 / GPLv3+ / LGPLv3+ - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License or as specified alternatively below. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Major Contributor(s): - * Copyright (C) 2011 Markus Mohrhard (initial developer) - * - * All Rights Reserved. - * - * For minor contributions see the git repository. - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 3 or later (the "GPLv3+"), or - * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), - * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable - * instead of those above. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace ScDataPilotFieldObj { - -class ScDataPilotField : public UnoApiTest -{ - - uno::Reference< beans::XPropertySet > init(); - - void testSortInfo(); - void testLayoutInfo(); - void testAutoShowInfo(); - void testReference(); - void testIsGroupField(); - - CPPUNIT_TEST_SUITE(ScDataPilotField); - CPPUNIT_TEST(testSortInfo); - CPPUNIT_TEST(testLayoutInfo); - CPPUNIT_TEST(testAutoShowInfo); - CPPUNIT_TEST(testReference); - CPPUNIT_TEST(testIsGroupField); - CPPUNIT_TEST_SUITE_END(); -}; - -void ScDataPilotField::testSortInfo() -{ - uno::Reference< beans::XPropertySet> xPropSet = init(); - sheet::DataPilotFieldSortInfo aSortInfoValue; - rtl::OUString aSortInfo(RTL_CONSTASCII_USTRINGPARAM("SortInfo")); - aSortInfoValue.Field = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Col1")); - aSortInfoValue.IsAscending = false; - aSortInfoValue.Mode = sheet::DataPilotFieldSortMode::MANUAL; - uno::Any xValue; - xValue <<= aSortInfoValue; - xPropSet->setPropertyValue(aSortInfo, xValue); - - sheet::DataPilotFieldSortInfo aNewSortInfoValue; - xValue = xPropSet->getPropertyValue(aSortInfo); - CPPUNIT_ASSERT( xValue >>= aNewSortInfoValue ); - CPPUNIT_ASSERT_MESSAGE("set value should be the same as got value", aNewSortInfoValue.Field == aSortInfoValue.Field - && aNewSortInfoValue.Mode == aSortInfoValue.Mode && aNewSortInfoValue.IsAscending == aSortInfoValue.IsAscending); - - //setting HasSortInfo only makes sense for false, for true the uno implementation does nothing - sal_Bool bHasSortInfo; - rtl::OUString aHasSortInfo(RTL_CONSTASCII_USTRINGPARAM("HasSortInfo")); - xValue = xPropSet->getPropertyValue(aHasSortInfo); - CPPUNIT_ASSERT( xValue >>= bHasSortInfo ); - CPPUNIT_ASSERT_MESSAGE("should have sort info", bHasSortInfo); - - bHasSortInfo = false; - xValue <<= bHasSortInfo; - xPropSet->setPropertyValue(aHasSortInfo, xValue); - - xValue = xPropSet->getPropertyValue(aHasSortInfo); - CPPUNIT_ASSERT( xValue >>= bHasSortInfo ); - CPPUNIT_ASSERT_MESSAGE("should have no sort info", !bHasSortInfo); -} - -void ScDataPilotField::testLayoutInfo() -{ - uno::Reference< beans::XPropertySet > xPropSet = init(); - sheet::DataPilotFieldLayoutInfo aLayoutInfoValue; - rtl::OUString aLayoutInfo(RTL_CONSTASCII_USTRINGPARAM("LayoutInfo")); - aLayoutInfoValue.AddEmptyLines = false; - aLayoutInfoValue.LayoutMode = sheet::DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_BOTTOM; - uno::Any xValue; - xValue <<= aLayoutInfoValue; - xPropSet->setPropertyValue(aLayoutInfo, xValue); - - sheet::DataPilotFieldLayoutInfo aNewLayoutInfoValue; - xValue = xPropSet->getPropertyValue(aLayoutInfo); - CPPUNIT_ASSERT( xValue >>= aNewLayoutInfoValue ); - CPPUNIT_ASSERT_MESSAGE("set value should be the same as the got value", aNewLayoutInfoValue.LayoutMode == aLayoutInfoValue.LayoutMode && - aNewLayoutInfoValue.AddEmptyLines == aLayoutInfoValue.AddEmptyLines); - - //setting HasLayoutInfo only makes sense for false, tor true the uno implementation does nothing - sal_Bool bHasLayoutInfo; - rtl::OUString aHasLayoutInfo(RTL_CONSTASCII_USTRINGPARAM("HasLayoutInfo")); - xValue = xPropSet->getPropertyValue(aHasLayoutInfo); - CPPUNIT_ASSERT( xValue >>= bHasLayoutInfo ); - CPPUNIT_ASSERT_MESSAGE("should have layout information", bHasLayoutInfo); - - bHasLayoutInfo = false; - xValue <<= bHasLayoutInfo; - xPropSet->setPropertyValue(aHasLayoutInfo, xValue); - - xValue = xPropSet->getPropertyValue(aHasLayoutInfo); - CPPUNIT_ASSERT( xValue >>= bHasLayoutInfo ); - CPPUNIT_ASSERT_MESSAGE("should have no longer sort information", !bHasLayoutInfo); -} - -void ScDataPilotField::testAutoShowInfo() -{ - uno::Reference< beans::XPropertySet > xPropSet = init(); - sheet::DataPilotFieldAutoShowInfo aAutoShowInfoValue; - aAutoShowInfoValue.DataField = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Col1")); - aAutoShowInfoValue.IsEnabled = true; - rtl::OUString aAutoShowInfo(RTL_CONSTASCII_USTRINGPARAM("AutoShowInfo")); - uno::Any xValue; - xValue <<= aAutoShowInfoValue; - xPropSet->setPropertyValue(aAutoShowInfo, xValue); - - sheet::DataPilotFieldAutoShowInfo aNewAutoShowInfoValue; - xValue = xPropSet->getPropertyValue(aAutoShowInfo); - CPPUNIT_ASSERT( xValue >>= aNewAutoShowInfoValue ); - CPPUNIT_ASSERT_MESSAGE("set value should be the same as the got value", aNewAutoShowInfoValue.DataField == aAutoShowInfoValue.DataField && - aNewAutoShowInfoValue.IsEnabled == aAutoShowInfoValue.IsEnabled); - - //setting HasLayoutInfo only makes sense for false, tor true the uno implementation does nothing - sal_Bool bHasAutoShowInfo; - rtl::OUString aHasAutoShowInfo(RTL_CONSTASCII_USTRINGPARAM("HasAutoShowInfo")); - xValue = xPropSet->getPropertyValue(aHasAutoShowInfo); - CPPUNIT_ASSERT( xValue >>= bHasAutoShowInfo ); - CPPUNIT_ASSERT_MESSAGE("should have AutoShow information", bHasAutoShowInfo); - - bHasAutoShowInfo = false; - xValue <<= bHasAutoShowInfo; - xPropSet->setPropertyValue(aHasAutoShowInfo, xValue); - - xValue = xPropSet->getPropertyValue(aHasAutoShowInfo); - CPPUNIT_ASSERT( xValue >>= bHasAutoShowInfo ); - CPPUNIT_ASSERT_MESSAGE("should have no longer AutoShow information", !bHasAutoShowInfo); -} - -void ScDataPilotField::testReference() -{ - uno::Reference< beans::XPropertySet > xPropSet = init(); - sheet::DataPilotFieldReference aReferenceValue; - aReferenceValue.ReferenceField = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Col1")); - aReferenceValue.ReferenceItemType = sheet::DataPilotFieldReferenceItemType::NAMED; - rtl::OUString aReference(RTL_CONSTASCII_USTRINGPARAM("Reference")); - uno::Any xValue; - xValue <<= aReferenceValue; - xPropSet->setPropertyValue(aReference, xValue); - - sheet::DataPilotFieldReference aNewReferenceValue; - xValue = xPropSet->getPropertyValue(aReference); - CPPUNIT_ASSERT( xValue >>= aNewReferenceValue ); - CPPUNIT_ASSERT_MESSAGE("set value should be the same as the got value", aReferenceValue.ReferenceField == aNewReferenceValue.ReferenceField - && aReferenceValue.ReferenceItemType == aNewReferenceValue.ReferenceItemType); - - //setting HasReference only makes sense for false, tor true the uno implementation does nothing - sal_Bool bHasReference; - rtl::OUString aHasReference(RTL_CONSTASCII_USTRINGPARAM("HasReference")); - xValue = xPropSet->getPropertyValue(aHasReference); - CPPUNIT_ASSERT( xValue >>= bHasReference ); - CPPUNIT_ASSERT_MESSAGE("should have Reference information", bHasReference); - - bHasReference = false; - xValue <<= bHasReference; - xPropSet->setPropertyValue(aHasReference, xValue); - - xValue = xPropSet->getPropertyValue(aHasReference); - CPPUNIT_ASSERT( xValue >>= bHasReference ); - CPPUNIT_ASSERT_MESSAGE("should have no longer reference information", !bHasReference); -} - -void ScDataPilotField::testIsGroupField() -{ - uno::Reference< beans::XPropertySet > xPropSet = init(); - uno::Any xValue; - rtl::OUString aIsGroupField(RTL_CONSTASCII_USTRINGPARAM("IsGroupField")); - sal_Bool bIsGroupField; - - xValue = xPropSet->getPropertyValue(aIsGroupField); - CPPUNIT_ASSERT( xValue >>= bIsGroupField); - //only setting to false is supported - if (bIsGroupField) - { - bIsGroupField = false; - xValue <<= bIsGroupField; - - xPropSet->setPropertyValue(aIsGroupField, xValue); - xValue = xPropSet->getPropertyValue(aIsGroupField); - CPPUNIT_ASSERT(xValue >>= bIsGroupField); - CPPUNIT_ASSERT_MESSAGE("setting IsGroupField is supported and should have happened", !bIsGroupField); - } - else - std::cout << "Could not test IsGroupField" << std::endl; -} - -uno::Reference< beans::XPropertySet > ScDataPilotField::init() -{ - rtl::OUString aFileURL; - const rtl::OUString aFileBase(RTL_CONSTASCII_USTRINGPARAM("scdatapilotfieldobj.ods")); - createFileURL(aFileBase, aFileURL); - std::cout << rtl::OUStringToOString(aFileURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl; - static uno::Reference< lang::XComponent > xComponent; - if( !xComponent.is()) - xComponent = loadFromDesktop(aFileURL); - uno::Reference< sheet::XSpreadsheetDocument> xDoc (xComponent, UNO_QUERY_THROW); - uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW); - uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(1), UNO_QUERY_THROW); - - CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is()); - uno::Reference< sheet::XDataPilotTablesSupplier > xDPTS(xSheet, UNO_QUERY_THROW); - CPPUNIT_ASSERT(xDPTS.is()); - uno::Reference< sheet::XDataPilotTables > xDPT = xDPTS->getDataPilotTables(); - CPPUNIT_ASSERT(xDPT.is()); - uno::Sequence aElementNames = xDPT->getElementNames(); - for (int i = 0; i < aElementNames.getLength(); ++i) - { - std::cout << "PivotTable: " << aElementNames[i] << std::endl; - } - - uno::Reference< sheet::XDataPilotDescriptor > xDPDsc(xDPT->getByName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataPilot1"))),UNO_QUERY_THROW); - - CPPUNIT_ASSERT(xDPDsc.is()); - uno::Reference< container::XIndexAccess > xIA( xDPDsc->getDataPilotFields(), UNO_QUERY_THROW); - uno::Reference< beans::XPropertySet > xReturnValue( xIA->getByIndex(0), UNO_QUERY_THROW); - CPPUNIT_ASSERT(xReturnValue.is()); - return xReturnValue; -} - -CPPUNIT_TEST_SUITE_REGISTRATION(ScDataPilotField); - -CPPUNIT_PLUGIN_IMPLEMENT(); - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/qa/extras/sccellrangeobj.cxx b/sc/qa/extras/sccellrangeobj.cxx new file mode 100644 index 000000000000..20a191c1f5a7 --- /dev/null +++ b/sc/qa/extras/sccellrangeobj.cxx @@ -0,0 +1,116 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License or as specified alternatively below. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * Major Contributor(s): + * Copyright (C) 2011 Markus Mohrhard (initial developer) + * + * All Rights Reserved. + * + * For minor contributions see the git repository. + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ + +#include +#include +#include + +#include +#include +#include + +namespace sc_apitest { + +#define NUMBER_OF_TESTS 8 + +class ScCellRangeObj : public UnoApiTest, apitest::XCellRangesQuery, apitest::CellProperties +{ +public: + virtual void setUp(); + virtual void tearDown(); + virtual uno::Reference< uno::XInterface > init(); + + CPPUNIT_TEST_SUITE(ScCellRangeObj); + CPPUNIT_TEST(testQueryColumnDifference); + CPPUNIT_TEST(testQueryContentDifference); + CPPUNIT_TEST(testQueryEmptyCells); + //CPPUNIT_TEST(testQueryFormulaCells); + CPPUNIT_TEST(testQueryIntersection); + CPPUNIT_TEST(testQueryRowDifference); + CPPUNIT_TEST(testQueryVisibleCells); + CPPUNIT_TEST(testVertJustify); + CPPUNIT_TEST(testRotateReference); + CPPUNIT_TEST_SUITE_END(); + +private: + static sal_Int32 nTest; + static uno::Reference< lang::XComponent > mxComponent; +}; + +sal_Int32 ScCellRangeObj::nTest = 0; +uno::Reference< lang::XComponent > ScCellRangeObj::mxComponent; + +uno::Reference< uno::XInterface > ScCellRangeObj::init() +{ + rtl::OUString aFileURL; + const rtl::OUString aFileBase(RTL_CONSTASCII_USTRINGPARAM("xcellrangesquery.ods")); + createFileURL(aFileBase, aFileURL); + std::cout << rtl::OUStringToOString(aFileURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl; + if( !mxComponent.is()) + mxComponent = loadFromDesktop(aFileURL); + uno::Reference< sheet::XSpreadsheetDocument> xDoc (mxComponent, UNO_QUERY_THROW); + uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW); + uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW); + + CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is()); + + uno::Reference xReturn(xSheet->getCellRangeByPosition(0,0,3,4), UNO_QUERY_THROW); + + CPPUNIT_ASSERT_MESSAGE("Could not create object of type XCellRangesQuery", xReturn.is()); + return xReturn; +} + +void ScCellRangeObj::setUp() +{ + nTest++; + CPPUNIT_ASSERT(nTest <= NUMBER_OF_TESTS); + UnoApiTest::setUp(); +} + +void ScCellRangeObj::tearDown() +{ + if (nTest == NUMBER_OF_TESTS) + { + closeDocument(mxComponent); + } + + UnoApiTest::tearDown(); + + if (nTest == NUMBER_OF_TESTS) + { + mxDesktop->terminate(); + } +} + +CPPUNIT_TEST_SUITE_REGISTRATION(ScCellRangeObj); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/qa/extras/scdatabaserangeobj.cxx b/sc/qa/extras/scdatabaserangeobj.cxx new file mode 100644 index 000000000000..69a3d48dcee6 --- /dev/null +++ b/sc/qa/extras/scdatabaserangeobj.cxx @@ -0,0 +1,106 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License or as specified alternatively below. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * Major Contributor(s): + * Copyright (C) 2012 Markus Mohrhard (initial developer) + * + * All Rights Reserved. + * + * For minor contributions see the git repository. + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ + +#include +#include + +#include +#include +#include +#include + + +namespace sc_apitest { + +#define NUMBER_OF_TESTS 3 + +class ScDatabaseRangeObj : public UnoApiTest, apitest::XDatabaseRange +{ +public: + virtual void setUp(); + virtual void tearDown(); + + virtual uno::Reference< uno::XInterface > init( const rtl::OUString& rDBName ); + + CPPUNIT_TEST_SUITE(ScDatabaseRangeObj); + CPPUNIT_TEST(testDataArea); + CPPUNIT_TEST(testGetSortDescriptor); + CPPUNIT_TEST(testGetSubtotalDescriptor); + CPPUNIT_TEST_SUITE_END(); +private: + static sal_Int32 nTest; + static uno::Reference< lang::XComponent > mxComponent; +}; + +sal_Int32 ScDatabaseRangeObj::nTest = 0; +uno::Reference< lang::XComponent > ScDatabaseRangeObj::mxComponent; + +uno::Reference< uno::XInterface > ScDatabaseRangeObj::init( const rtl::OUString& rDBName ) +{ + rtl::OUString aFileURL; + createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("xdatabaserange.ods")), aFileURL); + if(!mxComponent.is()) + mxComponent = loadFromDesktop(aFileURL); + CPPUNIT_ASSERT(mxComponent.is()); + + uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW); + uno::Reference< beans::XPropertySet > xPropSet(xDoc, UNO_QUERY_THROW); + uno::Reference< container::XNameAccess > xNameAccess( xPropSet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DatabaseRanges"))), UNO_QUERY_THROW); + uno::Reference< sheet::XDatabaseRange > xDBRange( xNameAccess->getByName(rDBName), UNO_QUERY_THROW); + CPPUNIT_ASSERT(xDBRange.is()); + return xDBRange; +} + +void ScDatabaseRangeObj::setUp() +{ + nTest++; + UnoApiTest::setUp(); +} + +void ScDatabaseRangeObj::tearDown() +{ + if (nTest == NUMBER_OF_TESTS) + { + closeDocument(mxComponent); + } + + UnoApiTest::tearDown(); + + if (nTest == NUMBER_OF_TESTS) + { + mxDesktop->terminate(); + } +} + +CPPUNIT_TEST_SUITE_REGISTRATION(ScDatabaseRangeObj); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/qa/extras/scdatapilotfieldobj.cxx b/sc/qa/extras/scdatapilotfieldobj.cxx new file mode 100644 index 000000000000..ff67e4620b75 --- /dev/null +++ b/sc/qa/extras/scdatapilotfieldobj.cxx @@ -0,0 +1,123 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License or as specified alternatively below. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * Major Contributor(s): + * Copyright (C) 2012 Markus Mohrhard (initial developer) + * + * All Rights Reserved. + * + * For minor contributions see the git repository. + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ + +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace sc_apitest { + +#define NUMBER_OF_TESTS 6 + +class ScDataPilotFieldObj : public UnoApiTest, apitest::XDataPilotFieldGrouping, + apitest::DataPilotField +{ +public: + virtual void setUp(); + virtual void tearDown(); + virtual uno::Reference< uno::XInterface > init(); + + CPPUNIT_TEST_SUITE(ScDataPilotFieldObj); + CPPUNIT_TEST(testSortInfo); + CPPUNIT_TEST(testLayoutInfo); + CPPUNIT_TEST(testAutoShowInfo); + CPPUNIT_TEST(testReference); + CPPUNIT_TEST(testIsGroupField); + CPPUNIT_TEST(testCreateNameGroup); + // see fdo# + //CPPUNIT_TEST(testCreateDateGroup); + CPPUNIT_TEST_SUITE_END(); +private: + static sal_Int32 nTest; + static uno::Reference< lang::XComponent > mxComponent; +}; + +sal_Int32 ScDataPilotFieldObj::nTest = 0; +uno::Reference< lang::XComponent > ScDataPilotFieldObj::mxComponent; + +uno::Reference< uno::XInterface > ScDataPilotFieldObj::init() +{ + rtl::OUString aFileURL; + createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("scdatapilotfieldobj.ods")), aFileURL); + if(!mxComponent.is()) + mxComponent = loadFromDesktop(aFileURL); + CPPUNIT_ASSERT(mxComponent.is()); + + uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW); + uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW); + uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(1), UNO_QUERY_THROW); + + CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is()); + uno::Reference< sheet::XDataPilotTablesSupplier > xDPTS(xSheet, UNO_QUERY_THROW); + CPPUNIT_ASSERT(xDPTS.is()); + uno::Reference< sheet::XDataPilotTables > xDPT = xDPTS->getDataPilotTables(); + CPPUNIT_ASSERT(xDPT.is()); + uno::Sequence aElementNames = xDPT->getElementNames(); + + uno::Reference< sheet::XDataPilotDescriptor > xDPDsc(xDPT->getByName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataPilot1"))),UNO_QUERY_THROW); + CPPUNIT_ASSERT(xDPDsc.is()); + uno::Reference< container::XIndexAccess > xIA( xDPDsc->getDataPilotFields(), UNO_QUERY_THROW); + uno::Reference< uno::XInterface > xReturnValue( xIA->getByIndex(0), UNO_QUERY_THROW); + CPPUNIT_ASSERT(xReturnValue.is()); + return xReturnValue; +} + +void ScDataPilotFieldObj::setUp() +{ + nTest++; + UnoApiTest::setUp(); +} + +void ScDataPilotFieldObj::tearDown() +{ + if (nTest == NUMBER_OF_TESTS) + { + closeDocument(mxComponent); + } + + UnoApiTest::tearDown(); + + if (nTest == NUMBER_OF_TESTS) + { + mxDesktop->terminate(); + } +} + +CPPUNIT_TEST_SUITE_REGISTRATION(ScDataPilotFieldObj); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/qa/extras/scdatapilottableobj.cxx b/sc/qa/extras/scdatapilottableobj.cxx new file mode 100644 index 000000000000..6d07b8fb8838 --- /dev/null +++ b/sc/qa/extras/scdatapilottableobj.cxx @@ -0,0 +1,129 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License or as specified alternatively below. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * Major Contributor(s): + * Copyright (C) 2012 Markus Mohrhard (initial developer) + * + * All Rights Reserved. + * + * For minor contributions see the git repository. + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ + +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace sc_apitest { + +#define NUMBER_OF_TESTS 9 + +class ScDataPilotTableObj : public UnoApiTest, apitest::XDataPilotDescriptor, apitest::XDataPilotTable +{ +public: + virtual void setUp(); + virtual void tearDown(); + virtual uno::Reference< uno::XInterface > init(); + + CPPUNIT_TEST_SUITE(ScDataPilotTableObj); + //CPPUNIT_TEST(testRefresh); + //CPPUNIT_TEST(testGetHiddenFields); + CPPUNIT_TEST(testGetOutputRange); + CPPUNIT_TEST(testSourceRange); + CPPUNIT_TEST(testTag); + CPPUNIT_TEST(testGetFilterDescriptor); + CPPUNIT_TEST(testGetDataPilotFields); + CPPUNIT_TEST(testGetColumnFields); + CPPUNIT_TEST(testGetRowFields); + CPPUNIT_TEST(testGetPageFields); + CPPUNIT_TEST(testGetDataFields); + CPPUNIT_TEST_SUITE_END(); + +private: + static sal_Int32 nTest; + static uno::Reference< lang::XComponent > mxComponent; +}; + +sal_Int32 ScDataPilotTableObj::nTest = 0; +uno::Reference< lang::XComponent > ScDataPilotTableObj::mxComponent; + +uno::Reference< uno::XInterface > ScDataPilotTableObj::init() +{ + rtl::OUString aFileURL; + createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScDataPilotTableObj.ods")), aFileURL); + if(!mxComponent.is()) + mxComponent = loadFromDesktop(aFileURL); + CPPUNIT_ASSERT(mxComponent.is()); + + uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW); + uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW); + uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW); + + // set variables from xdatapilottable.[ch]xx + xCellForChange = xSheet->getCellByPosition( 1, 5 ); + xCellForCheck = xSheet->getCellByPosition( 7, 11 ); + CPPUNIT_ASSERT(xCellForCheck.is()); + CPPUNIT_ASSERT(xCellForChange.is()); + + CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is()); + uno::Reference< sheet::XDataPilotTablesSupplier > xDPTS(xSheet, UNO_QUERY_THROW); + CPPUNIT_ASSERT(xDPTS.is()); + uno::Reference< sheet::XDataPilotTables > xDPT = xDPTS->getDataPilotTables(); + CPPUNIT_ASSERT(xDPT.is()); + + uno::Reference< sheet::XDataPilotTable > xDPTable(xDPT->getByName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataPilotTable"))),UNO_QUERY_THROW); + + CPPUNIT_ASSERT(xDPTable.is()); + return xDPTable; +} + +void ScDataPilotTableObj::setUp() +{ + nTest++; + UnoApiTest::setUp(); +} + +void ScDataPilotTableObj::tearDown() +{ + if (nTest == NUMBER_OF_TESTS) + { + closeDocument(mxComponent); + } + + UnoApiTest::tearDown(); + + if (nTest == NUMBER_OF_TESTS) + { + mxDesktop->terminate(); + } +} + +CPPUNIT_TEST_SUITE_REGISTRATION(ScDataPilotTableObj); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/qa/extras/scnamedrangeobj.cxx b/sc/qa/extras/scnamedrangeobj.cxx new file mode 100644 index 000000000000..2d7240276ed0 --- /dev/null +++ b/sc/qa/extras/scnamedrangeobj.cxx @@ -0,0 +1,117 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License or as specified alternatively below. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * Major Contributor(s): + * Copyright (C) 2012 Markus Mohrhard (initial developer) + * + * All Rights Reserved. + * + * For minor contributions see the git repository. + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ + +#include +#include + +#include +#include +#include + +namespace sc_apitest { + +#define NUMBER_OF_TESTS 6 + +class ScNamedRangeObj : public UnoApiTest, apitest::XNamedRange +{ +public: + virtual void setUp(); + virtual void tearDown(); + + virtual uno::Reference< uno::XInterface > init(); + virtual uno::Reference< sheet::XNamedRange > getNamedRange(const rtl::OUString& rRangeName); + + CPPUNIT_TEST_SUITE(ScNamedRangeObj); + CPPUNIT_TEST(testGetContent); + CPPUNIT_TEST(testSetContent); + CPPUNIT_TEST(testGetType); + CPPUNIT_TEST(testSetType); + CPPUNIT_TEST(testGetReferencePosition); + CPPUNIT_TEST(testSetReferencePosition); + CPPUNIT_TEST_SUITE_END(); +private: + static sal_Int32 nTest; + static uno::Reference< lang::XComponent > mxComponent; +}; + +sal_Int32 ScNamedRangeObj::nTest = 0; +uno::Reference< lang::XComponent > ScNamedRangeObj::mxComponent; + +uno::Reference< sheet::XNamedRange> ScNamedRangeObj::getNamedRange(const rtl::OUString& rRangeName) +{ + uno::Reference< container::XNameAccess > xNamedAccess(init(), UNO_QUERY_THROW); + uno::Reference< sheet::XNamedRange > xNamedRange(xNamedAccess->getByName(rRangeName), UNO_QUERY_THROW); + CPPUNIT_ASSERT(xNamedRange.is()); + + return xNamedRange; +} + +uno::Reference< uno::XInterface > ScNamedRangeObj::init() +{ + rtl::OUString aFileURL; + createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rangenames.ods")), aFileURL); + if(!mxComponent.is()) + mxComponent = loadFromDesktop(aFileURL); + CPPUNIT_ASSERT(mxComponent.is()); + + uno::Reference< beans::XPropertySet > xPropSet (mxComponent, UNO_QUERY_THROW); + rtl::OUString aNamedRangesPropertyString(RTL_CONSTASCII_USTRINGPARAM("NamedRanges")); + uno::Reference< container::XNameAccess > xNamedRangesNameAccess(xPropSet->getPropertyValue(aNamedRangesPropertyString), UNO_QUERY_THROW); + CPPUNIT_ASSERT(xNamedRangesNameAccess.is()); + + return xNamedRangesNameAccess; +} + +void ScNamedRangeObj::setUp() +{ + nTest++; + UnoApiTest::setUp(); +} + +void ScNamedRangeObj::tearDown() +{ + if (nTest == NUMBER_OF_TESTS) + { + closeDocument(mxComponent); + } + + UnoApiTest::tearDown(); + + if (nTest == NUMBER_OF_TESTS) + { + mxDesktop->terminate(); + } +} + +CPPUNIT_TEST_SUITE_REGISTRATION(ScNamedRangeObj); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/qa/extras/scnamedrangesobj.cxx b/sc/qa/extras/scnamedrangesobj.cxx new file mode 100644 index 000000000000..f6d2322eadd5 --- /dev/null +++ b/sc/qa/extras/scnamedrangesobj.cxx @@ -0,0 +1,110 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License or as specified alternatively below. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * Major Contributor(s): + * Copyright (C) 2012 Markus Mohrhard (initial developer) + * + * All Rights Reserved. + * + * For minor contributions see the git repository. + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ + +#include +#include + +#include +#include +#include + +namespace sc_apitest { + +#define NUMBER_OF_TESTS 3 + +class ScNamedRangesObj : public UnoApiTest, apitest::XNamedRanges +{ +public: + virtual void setUp(); + virtual void tearDown(); + + virtual uno::Reference< uno::XInterface > init(sal_Int32 nSheet); + + CPPUNIT_TEST_SUITE(ScNamedRangesObj); + CPPUNIT_TEST(testAddNewByName); + CPPUNIT_TEST(testAddNewFromTitles); + //CPPUNIT_TEST_EXCEPTION(testRemoveByName, uno::RuntimeException); + CPPUNIT_TEST(testOutputList); + CPPUNIT_TEST_SUITE_END(); + +private: + static sal_Int32 nTest; + static uno::Reference< lang::XComponent > mxComponent; +}; + +sal_Int32 ScNamedRangesObj::nTest = 0; +uno::Reference< lang::XComponent > ScNamedRangesObj::mxComponent; + +uno::Reference< uno::XInterface > ScNamedRangesObj::init(sal_Int32 nSheet) +{ + rtl::OUString aFileURL; + createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rangenames.ods")), aFileURL); + if(!mxComponent.is()) + mxComponent = loadFromDesktop(aFileURL); + CPPUNIT_ASSERT(mxComponent.is()); + + uno::Reference< beans::XPropertySet > xPropSet (mxComponent, UNO_QUERY_THROW); + rtl::OUString aNamedRangesPropertyString(RTL_CONSTASCII_USTRINGPARAM("NamedRanges")); + uno::Reference< sheet::XNamedRanges > xNamedRanges(xPropSet->getPropertyValue(aNamedRangesPropertyString), UNO_QUERY_THROW); + + //set value from xnamedranges.hxx + uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW); + uno::Reference< container::XIndexAccess > xIndexAccess(xDoc->getSheets(), UNO_QUERY_THROW); + xSheet = uno::Reference< sheet::XSpreadsheet >(xIndexAccess->getByIndex(nSheet),UNO_QUERY_THROW); + + return xNamedRanges; +} + +void ScNamedRangesObj::setUp() +{ + nTest++; + UnoApiTest::setUp(); +} + +void ScNamedRangesObj::tearDown() +{ + if (nTest == NUMBER_OF_TESTS) + { + closeDocument(mxComponent); + } + + UnoApiTest::tearDown(); + + if (nTest == NUMBER_OF_TESTS) + { + mxDesktop->terminate(); + } +} + +CPPUNIT_TEST_SUITE_REGISTRATION(ScNamedRangesObj); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/qa/extras/sctablesheetsobj.cxx b/sc/qa/extras/sctablesheetsobj.cxx new file mode 100644 index 000000000000..8b0b5e963f19 --- /dev/null +++ b/sc/qa/extras/sctablesheetsobj.cxx @@ -0,0 +1,138 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License or as specified alternatively below. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * Major Contributor(s): + * Copyright (C) 2012 Markus Mohrhard (initial developer) + * + * All Rights Reserved. + * + * For minor contributions see the git repository. + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ + +#include +#include +#include + +#include +#include + +namespace sc_apitest { + +#define NUMBER_OF_TESTS 13 + +class ScTableSheetsObj : public UnoApiTest, public ::apitest::XSpreadsheets2, apitest::XNameContainer +{ +public: + ScTableSheetsObj(); + + virtual void setUp(); + virtual void tearDown(); + + CPPUNIT_TEST_SUITE(ScTableSheetsObj); + CPPUNIT_TEST(testImportValue); + CPPUNIT_TEST(testImportString); + CPPUNIT_TEST(testImportedSheetNameAndIndex); + CPPUNIT_TEST(testImportString); + CPPUNIT_TEST(testImportValue); + CPPUNIT_TEST(testImportFormulaBasicMath); + CPPUNIT_TEST(testImportFormulaWithNamedRange); + CPPUNIT_TEST(testImportOverExistingNamedRange); + CPPUNIT_TEST(testImportNamedRangeDefinedInSource); + CPPUNIT_TEST(testImportNamedRangeRedefinedInSource); + CPPUNIT_TEST(testImportNewNamedRange); + CPPUNIT_TEST(testImportCellStyle); + CPPUNIT_TEST(testRemoveByName); + CPPUNIT_TEST_SUITE_END(); + + virtual uno::Reference< lang::XComponent > getComponent(); + virtual void createFileURL(const rtl::OUString& rFileBase, rtl::OUString& rFileURL); + virtual uno::Reference< lang::XComponent > loadFromDesktop(const rtl::OUString& rString); + virtual uno::Reference< uno::XInterface > init(); +protected: + static uno::Reference< lang::XComponent > mxComponent; + static sal_Int32 nTest; +}; + +uno::Reference< lang::XComponent > ScTableSheetsObj::mxComponent; +sal_Int32 ScTableSheetsObj::nTest = 0; + +ScTableSheetsObj::ScTableSheetsObj(): + apitest::XNameContainer(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Sheet2"))) +{ + +} + +uno::Reference< lang::XComponent > ScTableSheetsObj::getComponent() +{ + return mxComponent; +} + +void ScTableSheetsObj::createFileURL(const rtl::OUString& rFileBase, rtl::OUString& rFileURL) +{ + UnoApiTest::createFileURL(rFileBase, rFileURL); +} + +uno::Reference< lang::XComponent > ScTableSheetsObj::loadFromDesktop(const rtl::OUString& rString) +{ + return UnoApiTest::loadFromDesktop(rString); +} + +uno::Reference< uno::XInterface > ScTableSheetsObj::init() +{ + rtl::OUString aFileURL; + createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rangenamessrc.ods")), aFileURL); + if(!mxComponent.is()) + mxComponent = loadFromDesktop(aFileURL); + CPPUNIT_ASSERT(mxComponent.is()); + xDocument = uno::Reference< sheet::XSpreadsheetDocument >(mxComponent, UNO_QUERY_THROW); + uno::Reference< uno::XInterface > xReturn( xDocument->getSheets(), UNO_QUERY_THROW); + + return xReturn; +} + +void ScTableSheetsObj::setUp() +{ + nTest++; + CPPUNIT_ASSERT(nTest <= NUMBER_OF_TESTS); + UnoApiTest::setUp(); +} + +void ScTableSheetsObj::tearDown() +{ + if (nTest == NUMBER_OF_TESTS) + { + closeDocument(mxComponent); + } + + UnoApiTest::tearDown(); + + if (nTest == NUMBER_OF_TESTS) + { + mxDesktop->terminate(); + } +} + +CPPUNIT_TEST_SUITE_REGISTRATION(ScTableSheetsObj); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/qa/extras/tableautoformatfield.cxx b/sc/qa/extras/tableautoformatfield.cxx deleted file mode 100644 index ac0ad8c53692..000000000000 --- a/sc/qa/extras/tableautoformatfield.cxx +++ /dev/null @@ -1,131 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * Version: MPL 1.1 / GPLv3+ / LGPLv3+ - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License or as specified alternatively below. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Major Contributor(s): - * Copyright (C) 2011 Markus Mohrhard (initial developer) - * - * All Rights Reserved. - * - * For minor contributions see the git repository. - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 3 or later (the "GPLv3+"), or - * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), - * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable - * instead of those above. - */ - -#include - -#include - -#include - -namespace ScAutoFormatFieldObj { - -#define NUMBER_OF_TESTS 2 - -class ScTableAutoFormatField : public UnoApiTest -{ -public: - - virtual void setUp(); - virtual void tearDown(); - - uno::Reference< beans::XPropertySet > init(); void testRotateReference(); - void testVertJustify(); - - CPPUNIT_TEST_SUITE(ScTableAutoFormatField); - CPPUNIT_TEST(testRotateReference); - CPPUNIT_TEST(testVertJustify); - CPPUNIT_TEST_SUITE_END(); - -private: - - static int nTest; -}; - -int ScTableAutoFormatField::nTest = 0; - -uno::Reference< beans::XPropertySet > ScTableAutoFormatField::init() -{ - uno::Reference< container::XIndexAccess > xAutoFormatFields( m_xSFactory->createInstance(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.TableAutoFormats"))), UNO_QUERY_THROW ); - CPPUNIT_ASSERT(xAutoFormatFields.is()); - uno::Reference< container::XIndexAccess > xIndex( xAutoFormatFields->getByIndex(0), UNO_QUERY_THROW ); - CPPUNIT_ASSERT(xIndex.is()); - uno::Reference< beans::XPropertySet > xReturn( xIndex->getByIndex(0), UNO_QUERY_THROW ); - CPPUNIT_ASSERT_MESSAGE("could not create table auto formats", xReturn.is()); - return xReturn; -} - -void ScTableAutoFormatField::testRotateReference() -{ - uno::Reference< beans::XPropertySet > xTableAutoFormatField = init(); - rtl::OUString aRotateReference(RTL_CONSTASCII_USTRINGPARAM("RotateReference")); - uno::Any aOldRotateReference = xTableAutoFormatField->getPropertyValue(aRotateReference); - sal_Int32 aValue = 0; - CPPUNIT_ASSERT(aOldRotateReference >>= aValue); - std::cout << "Old RotateReferene Value: " << aValue << std::endl; - - uno::Any aNewRotateReference; - aNewRotateReference <<= static_cast(3); - xTableAutoFormatField->setPropertyValue(aRotateReference, aNewRotateReference); - uno::Any aRotateReferenceControllValue = xTableAutoFormatField->getPropertyValue(aRotateReference); - CPPUNIT_ASSERT(aRotateReferenceControllValue >>= aValue); - std::cout << "New VertJustify value: " << aValue << std::endl; - CPPUNIT_ASSERT_MESSAGE("value has not been changed", aValue == 3); -} - -void ScTableAutoFormatField::testVertJustify() -{ - uno::Reference< beans::XPropertySet > xTableAutoFormatField = init(); - rtl::OUString aVertJustify(RTL_CONSTASCII_USTRINGPARAM("VertJustify")); - uno::Any aOldVertJustify = xTableAutoFormatField->getPropertyValue(aVertJustify); - sal_Int32 aValue = 0; - CPPUNIT_ASSERT(aOldVertJustify >>= aValue); - std::cout << "Old VertJustify value: " << aValue << std::endl; - - uno::Any aNewVertJustify; - aNewVertJustify <<= static_cast(3); - xTableAutoFormatField->setPropertyValue(aVertJustify, aNewVertJustify); - uno::Any aVertJustifyControllValue = xTableAutoFormatField->getPropertyValue(aVertJustify); - CPPUNIT_ASSERT(aVertJustifyControllValue >>= aValue); - std::cout << "New VertJustify value: " << aValue << std::endl; - CPPUNIT_ASSERT_MESSAGE("value has not been changed", aValue == 3); -} - -void ScTableAutoFormatField::setUp() -{ - nTest += 1; - UnoApiTest::setUp(); -} - -void ScTableAutoFormatField::tearDown() -{ - UnoApiTest::tearDown(); - - if (nTest == NUMBER_OF_TESTS) - { - mxDesktop->terminate(); - uno::Reference< lang::XComponent>(m_xContext, UNO_QUERY_THROW)->dispose(); - } -} - -CPPUNIT_TEST_SUITE_REGISTRATION(ScTableAutoFormatField); - -CPPUNIT_PLUGIN_IMPLEMENT(); - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/qa/extras/testdocuments/rangenamessrc.ods b/sc/qa/extras/testdocuments/rangenamessrc.ods index f6546e960c8f..d22702bda2da 100644 Binary files a/sc/qa/extras/testdocuments/rangenamessrc.ods and b/sc/qa/extras/testdocuments/rangenamessrc.ods differ diff --git a/sc/qa/extras/xcellrangesquery.cxx b/sc/qa/extras/xcellrangesquery.cxx deleted file mode 100644 index a5a5a6fb926c..000000000000 --- a/sc/qa/extras/xcellrangesquery.cxx +++ /dev/null @@ -1,196 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * Version: MPL 1.1 / GPLv3+ / LGPLv3+ - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License or as specified alternatively below. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Major Contributor(s): - * [ Copyright (C) 2011 Markus Mohrhard (initial developer) ] - * - * All Rights Reserved. - * - * For minor contributions see the git repository. - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 3 or later (the "GPLv3+"), or - * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), - * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable - * instead of those above. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include - -using namespace com::sun::star; - - -namespace ScCellRangeBase { - -#define NUMBER_OF_TESTS 5 - -class ScXCellRangesQuery : public UnoApiTest -{ -public: - - virtual void setUp(); - virtual void tearDown(); - - //Testcases - void testQueryColumnDifference(); - void testQueryContentDifference(); - void testQueryEmptyCells(); - void testQueryFormulaCells(); - void testQueryIntersection(); - void testQueryRowDifference(); - void testQueryVisibleCells(); - - CPPUNIT_TEST_SUITE(ScXCellRangesQuery); - CPPUNIT_TEST(testQueryColumnDifference); - CPPUNIT_TEST(testQueryContentDifference); - CPPUNIT_TEST(testQueryEmptyCells); - //looks broken - //CPPUNIT_TEST(testQueryFormulaCells); - CPPUNIT_TEST(testQueryIntersection); - CPPUNIT_TEST(testQueryRowDifference); - CPPUNIT_TEST_SUITE_END(); - -private: - uno::Reference init(); - - static int nTest; - static uno::Reference< lang::XComponent > xComponent; -}; - -int ScXCellRangesQuery::nTest = 0; -uno::Reference< lang::XComponent > ScXCellRangesQuery::xComponent; - -uno::Reference ScXCellRangesQuery::init() -{ - rtl::OUString aFileURL; - const rtl::OUString aFileBase(RTL_CONSTASCII_USTRINGPARAM("xcellrangesquery.ods")); - createFileURL(aFileBase, aFileURL); - std::cout << rtl::OUStringToOString(aFileURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl; - if( !xComponent.is()) - xComponent = loadFromDesktop(aFileURL); - uno::Reference< sheet::XSpreadsheetDocument> xDoc (xComponent, UNO_QUERY_THROW); - uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW); - uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW); - - CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is()); - - uno::Reference xReturn(xSheet->getCellRangeByPosition(0,0,3,4), UNO_QUERY_THROW); - - CPPUNIT_ASSERT_MESSAGE("Could not create object of type XCellRangesQuery", xReturn.is()); - return xReturn; -} - -void ScXCellRangesQuery::testQueryColumnDifference() -{ - rtl::OUString aExpected(RTL_CONSTASCII_USTRINGPARAM("Sheet1.B1:C1,Sheet1.B3:C5")); - uno::Reference xCellRangesQuery = init(); - uno::Reference xRanges = xCellRangesQuery->queryColumnDifferences(table::CellAddress(0, 1, 1)); - rtl::OUString aResult = xRanges->getRangeAddressesAsString(); - std::cout << "testQueryColumnDifference: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl; - CPPUNIT_ASSERT_MESSAGE("testQueryColumnDifference", aResult == aExpected); -} - -void ScXCellRangesQuery::testQueryContentDifference() -{ - rtl::OUString aExpected(RTL_CONSTASCII_USTRINGPARAM("Sheet1.B2:B3")); - uno::Reference xCellRangesQuery = init(); - uno::Reference xRanges = xCellRangesQuery->queryContentCells(sheet::CellFlags::VALUE); - rtl::OUString aResult = xRanges->getRangeAddressesAsString(); - std::cout << "testQueryContentDifference: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl; - CPPUNIT_ASSERT_MESSAGE("testQueryContentDifference", aResult == aExpected); -} - -void ScXCellRangesQuery::testQueryEmptyCells() -{ - rtl::OUString aExpected(RTL_CONSTASCII_USTRINGPARAM("Sheet1.A1:A5,Sheet1.B1:C1,Sheet1.B5,Sheet1.C3:C5,Sheet1.D1:D5")); - uno::Reference xCellRangesQuery = init(); - uno::Reference xRanges = xCellRangesQuery->queryEmptyCells(); - rtl::OUString aResult = xRanges->getRangeAddressesAsString(); - std::cout << "testQueryEmptyCells: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl; - CPPUNIT_ASSERT_MESSAGE("testQueryEmptyCells", aResult == aExpected); -} - -void ScXCellRangesQuery::testQueryFormulaCells() -{ - rtl::OUString aExpected(RTL_CONSTASCII_USTRINGPARAM("Sheet1.C2")); - uno::Reference xCellRangesQuery = init(); - uno::Reference xRanges = xCellRangesQuery->queryFormulaCells(sheet::CellFlags::FORMULA); - rtl::OUString aResult = xRanges->getRangeAddressesAsString(); - std::cout << "testQueryFormulaCells: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl; - CPPUNIT_ASSERT_MESSAGE("testQueryFormulaCells", aResult == aExpected); -} - -void ScXCellRangesQuery::testQueryIntersection() -{ - rtl::OUString aExpected(RTL_CONSTASCII_USTRINGPARAM("Sheet1.D4:D5")); - uno::Reference xCellRangesQuery = init(); - uno::Reference xRanges = xCellRangesQuery->queryIntersection(table::CellRangeAddress(0,3,3,7,7)); - rtl::OUString aResult = xRanges->getRangeAddressesAsString(); - std::cout << "testQueryIntersection: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl; - CPPUNIT_ASSERT_MESSAGE("testQueryFormulaCells", aResult == aExpected); -} - -void ScXCellRangesQuery::testQueryRowDifference() -{ - rtl::OUString aExpected(RTL_CONSTASCII_USTRINGPARAM("Sheet1.A2:A4,Sheet1.C2:D4")); - uno::Reference xCellRangesQuery = init(); - uno::Reference xRanges = xCellRangesQuery->queryRowDifferences(table::CellAddress(0,1,1)); - rtl::OUString aResult = xRanges->getRangeAddressesAsString(); - std::cout << "testQueryRowDifference: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl; - CPPUNIT_ASSERT_MESSAGE("testQueryFormulaCells", aResult == aExpected); -} - -void ScXCellRangesQuery::testQueryVisibleCells() -{ - rtl::OUString aExpected(RTL_CONSTASCII_USTRINGPARAM("Sheet1.A2")); - uno::Reference xCellRangesQuery = init(); - uno::Reference xRanges = xCellRangesQuery->queryVisibleCells(); - rtl::OUString aResult = xRanges->getRangeAddressesAsString(); - std::cout << "testQueryVisibleCells: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl; - CPPUNIT_ASSERT_MESSAGE("testQueryFormulaCells", aResult == aExpected); -} - -void ScXCellRangesQuery::setUp() -{ - nTest += 1; - UnoApiTest::setUp(); -} - -void ScXCellRangesQuery::tearDown() -{ - if (nTest == NUMBER_OF_TESTS) - { - uno::Reference< util::XCloseable > xCloseable(xComponent, UNO_QUERY_THROW); - xCloseable->close( false ); - } - - UnoApiTest::tearDown(); - -} - -CPPUNIT_TEST_SUITE_REGISTRATION(ScXCellRangesQuery); - -CPPUNIT_PLUGIN_IMPLEMENT(); - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/qa/extras/xdatabaserange.cxx b/sc/qa/extras/xdatabaserange.cxx deleted file mode 100644 index 22a2680c9805..000000000000 --- a/sc/qa/extras/xdatabaserange.cxx +++ /dev/null @@ -1,209 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * Version: MPL 1.1 / GPLv3+ / LGPLv3+ - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License or as specified alternatively below. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Major Contributor(s): - * Copyright (C) 2012 Markus Mohrhard (initial developer) - * - * All Rights Reserved. - * - * For minor contributions see the git repository. - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 3 or later (the "GPLv3+"), or - * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), - * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable - * instead of those above. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace ScDatabaseRangeObj { - -#define NUMBER_OF_TESTS 3 - -class ScXDatabaseRange : public UnoApiTest -{ - virtual void setUp(); - virtual void tearDown(); - - void testDataArea(); - void testGetSortDescriptor(); - void testGetSubtotalDescriptor(); - - CPPUNIT_TEST_SUITE(ScXDatabaseRange); - CPPUNIT_TEST(testDataArea); - CPPUNIT_TEST(testGetSortDescriptor); - CPPUNIT_TEST(testGetSubtotalDescriptor); - CPPUNIT_TEST_SUITE_END(); -private: - uno::Reference< sheet::XDatabaseRange > init(const rtl::OUString& rName); - - static int nTest; - static uno::Reference< lang::XComponent > xComponent; -}; - -int ScXDatabaseRange::nTest = 0; -uno::Reference< lang::XComponent > ScXDatabaseRange::xComponent; - -/** - * tests setDataArea and getDataArea - */ -void ScXDatabaseRange::testDataArea() -{ - uno::Reference< sheet::XDatabaseRange > xDBRange = init(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataArea"))); - - table::CellRangeAddress aCellAddress; - aCellAddress.Sheet = 0; - aCellAddress.StartColumn = 1; - aCellAddress.EndColumn = 4; - aCellAddress.StartRow = 2; - aCellAddress.EndRow = 5; - xDBRange->setDataArea(aCellAddress); - table::CellRangeAddress aValue; - aValue = xDBRange->getDataArea(); - CPPUNIT_ASSERT( aCellAddress.Sheet == aValue.Sheet ); - CPPUNIT_ASSERT( aCellAddress.StartRow == aValue.StartRow ); - CPPUNIT_ASSERT( aCellAddress.EndRow == aValue.EndRow ); - CPPUNIT_ASSERT( aCellAddress.StartColumn == aValue.StartColumn ); - CPPUNIT_ASSERT( aCellAddress.EndColumn == aValue.EndColumn ); -} - -void ScXDatabaseRange::testGetSubtotalDescriptor() -{ - uno::Reference< sheet::XDatabaseRange > xDBRange = init(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SubtotalDescriptor"))); - uno::Reference< sheet::XSubTotalDescriptor> xSubtotalDescr = xDBRange->getSubTotalDescriptor(); - CPPUNIT_ASSERT(xSubtotalDescr.is()); -} - -void ScXDatabaseRange::testGetSortDescriptor() -{ - uno::Reference< sheet::XDatabaseRange > xDBRange = init(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SortDescriptor"))); - uno::Sequence< beans::PropertyValue > xSortDescr = xDBRange->getSortDescriptor(); - for (sal_Int32 i = 0; i < xSortDescr.getLength(); ++i) - { - beans::PropertyValue xProp = xSortDescr[i]; - //std::cout << "Prop " << i << " Name: " << rtl::OUString(xProp.Name) << std::endl; - - if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsSortColumns"))) - { - sal_Bool bIsSortColumns; - xProp.Value >>= bIsSortColumns; - CPPUNIT_ASSERT(bIsSortColumns == false); - } - else if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ContainsHeader"))) - { - sal_Bool bContainsHeader; - xProp.Value >>= bContainsHeader; - CPPUNIT_ASSERT(bContainsHeader == true); - } - else if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MaxFieldCount"))) - { - sal_Int32 nMaxFieldCount; - xProp.Value >>= nMaxFieldCount; - std::cout << "Value: " << nMaxFieldCount << std::endl; - - } - else if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SortFields"))) - { - - } - else if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BindFormatsToContent"))) - { - sal_Bool bBindFormatsToContent; - xProp.Value >>= bBindFormatsToContent; - CPPUNIT_ASSERT(bBindFormatsToContent == true); - } - else if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CopyOutputData"))) - { - sal_Bool bCopyOutputData; - xProp.Value >>= bCopyOutputData; - CPPUNIT_ASSERT(bCopyOutputData == false); - } - else if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OutputPosition"))) - { - - } - else if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsUserListEnabled"))) - { - sal_Bool bIsUserListEnabled; - xProp.Value >>= bIsUserListEnabled; - CPPUNIT_ASSERT(bIsUserListEnabled == false); - - } - else if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UserListIndex"))) - { - sal_Int32 nUserListIndex; - xProp.Value >>= nUserListIndex; - CPPUNIT_ASSERT(nUserListIndex == 0); - } - } -} - -uno::Reference< sheet::XDatabaseRange > ScXDatabaseRange::init(const rtl::OUString& rName) -{ - rtl::OUString aFileURL; - const rtl::OUString aFileBase(RTL_CONSTASCII_USTRINGPARAM("xdatabaserange.ods")); - createFileURL(aFileBase, aFileURL); - std::cout << rtl::OUStringToOString(aFileURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl; - if( !xComponent.is()) - xComponent = loadFromDesktop(aFileURL); - uno::Reference< sheet::XSpreadsheetDocument> xDoc (xComponent, UNO_QUERY_THROW); - uno::Reference< beans::XPropertySet > xPropSet(xDoc,UNO_QUERY_THROW); - uno::Reference< sheet::XDatabaseRanges > xDBRanges( xPropSet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DatabaseRanges"))), UNO_QUERY_THROW ); - uno::Reference< container::XNameAccess > xName( xDBRanges, UNO_QUERY_THROW); - uno::Reference< sheet::XDatabaseRange > xDBRange( xName->getByName(rName), UNO_QUERY_THROW); - CPPUNIT_ASSERT(xDBRange.is()); - return xDBRange; -} - -void ScXDatabaseRange::setUp() -{ - nTest += 1; - UnoApiTest::setUp(); -} - -void ScXDatabaseRange::tearDown() -{ - if (nTest == NUMBER_OF_TESTS) - { - uno::Reference< util::XCloseable > xCloseable(xComponent, UNO_QUERY_THROW); - xCloseable->close( false ); - } - - UnoApiTest::tearDown(); - - if (nTest == NUMBER_OF_TESTS) - { - mxDesktop->terminate(); - uno::Reference< lang::XComponent>(m_xContext, UNO_QUERY_THROW)->dispose(); - } -} - -CPPUNIT_TEST_SUITE_REGISTRATION(ScXDatabaseRange); - -CPPUNIT_PLUGIN_IMPLEMENT(); - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/qa/extras/xdatapilotdescriptor.cxx b/sc/qa/extras/xdatapilotdescriptor.cxx deleted file mode 100644 index e58c1453b2b5..000000000000 --- a/sc/qa/extras/xdatapilotdescriptor.cxx +++ /dev/null @@ -1,311 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * Version: MPL 1.1 / GPLv3+ / LGPLv3+ - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License or as specified alternatively below. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Major Contributor(s): - * Copyright (C) 2012 Markus Mohrhard (initial developer) - * - * All Rights Reserved. - * - * For minor contributions see the git repository. - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 3 or later (the "GPLv3+"), or - * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), - * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable - * instead of those above. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -namespace ScDataPilotDescriptorBase -{ - -#define NUMBER_OF_TESTS 9 - -class ScXDataPilotDescriptor : public UnoApiTest -{ -public: - - virtual void setUp(); - virtual void tearDown(); - - void testSourceRange(); - void testTag(); - void testGetFilterDescriptor(); - void testGetDataPilotFields(); - void testGetColumnFields(); - void testGetRowFields(); - void testGetPageFields(); - void testGetDataFields(); - void testGetHiddenFields(); - CPPUNIT_TEST_SUITE(ScXDataPilotDescriptor); - CPPUNIT_TEST(testSourceRange); - CPPUNIT_TEST(testTag); - CPPUNIT_TEST(testGetFilterDescriptor); - CPPUNIT_TEST(testGetDataPilotFields); - CPPUNIT_TEST(testGetColumnFields); - CPPUNIT_TEST(testGetRowFields); - CPPUNIT_TEST(testGetPageFields); - CPPUNIT_TEST(testGetDataFields); - CPPUNIT_TEST(testGetHiddenFields); - CPPUNIT_TEST_SUITE_END(); - - -private: - - uno::Reference< sheet::XDataPilotDescriptor > init(); - - void testGetDataPilotFields_Impl( uno::Reference< sheet::XDataPilotDescriptor > xDescr ); - - void checkName( uno::Reference< container::XIndexAccess > xIndex, sal_Int32 nIndex ); - static std::vector maFieldNames; - static int nTest; - static uno::Reference< lang::XComponent > xComponent; -}; - -std::vector< rtl::OUString > ScXDataPilotDescriptor::maFieldNames; -int ScXDataPilotDescriptor::nTest = 0; -uno::Reference< lang::XComponent > ScXDataPilotDescriptor::xComponent; - -void ScXDataPilotDescriptor::testTag() -{ - rtl::OUString aTag(RTL_CONSTASCII_USTRINGPARAM("DataPilotDescriptor_Tag")); - uno::Reference< sheet::XDataPilotDescriptor > xDescr = init(); - xDescr->setTag(aTag); - rtl::OUString aNewTag = xDescr->getTag(); - CPPUNIT_ASSERT( aTag == aNewTag ); -} - -void ScXDataPilotDescriptor::testSourceRange() -{ - uno::Reference< sheet::XDataPilotDescriptor > xDescr = init(); - table::CellRangeAddress aOldAddress = xDescr->getSourceRange(); - - table::CellRangeAddress aAddress; - aAddress.Sheet = 1; - aAddress.StartColumn = 1; - aAddress.StartRow = 1; - aAddress.EndColumn = 5; - aAddress.EndRow = 5; - xDescr->setSourceRange(aAddress); - - table::CellRangeAddress aReturn; - aReturn = xDescr->getSourceRange(); - - CPPUNIT_ASSERT(aAddress.Sheet == aReturn.Sheet); - CPPUNIT_ASSERT(aAddress.StartColumn == aReturn.StartColumn); - CPPUNIT_ASSERT(aAddress.StartRow == aReturn.StartRow); - CPPUNIT_ASSERT(aAddress.EndColumn == aReturn.EndColumn); - CPPUNIT_ASSERT(aAddress.EndRow == aReturn.EndRow); - - //restore old settings - xDescr->setSourceRange(aOldAddress); -} - -void ScXDataPilotDescriptor::testGetFilterDescriptor() -{ - uno::Reference< sheet::XDataPilotDescriptor > xDescr = init(); - uno::Reference< sheet::XSheetFilterDescriptor > xSheetFilterDescr = xDescr->getFilterDescriptor(); - CPPUNIT_ASSERT(xSheetFilterDescr.is()); -} - -void ScXDataPilotDescriptor::testGetDataPilotFields_Impl( uno::Reference< sheet::XDataPilotDescriptor > xDescr) -{ - uno::Reference< container::XIndexAccess > xIndex(xDescr->getDataPilotFields(), UNO_QUERY_THROW); - CPPUNIT_ASSERT( xIndex.is()); - - sal_Int32 nCount = xIndex->getCount(); - - rtl::OUString aOrientation(RTL_CONSTASCII_USTRINGPARAM("Orientation")); - for (sal_Int32 i = 0; i < nCount && i < 5; ++i) - { - uno::Reference< container::XNamed > xNamed( xIndex->getByIndex( i ), UNO_QUERY_THROW); - CPPUNIT_ASSERT(xNamed.is()); - rtl::OUString aName = xNamed->getName(); - maFieldNames.push_back(aName); - CPPUNIT_ASSERT( !aName.equalsAscii("Data") ); - - uno::Reference< beans::XPropertySet > xPropSet( xNamed, UNO_QUERY_THROW); - CPPUNIT_ASSERT( xPropSet.is() ); - - switch ( i % 5 ) - { - case 0: - { - uno::Any aAny; - aAny<<= sheet::DataPilotFieldOrientation_COLUMN; - xPropSet->setPropertyValue(aOrientation, aAny); - } - break; - case 1: - { - uno::Any aAny; - aAny<<= sheet::DataPilotFieldOrientation_ROW; - xPropSet->setPropertyValue(aOrientation, aAny); - } - break; - case 2: - { - uno::Any aAny; - aAny<<= sheet::DataPilotFieldOrientation_DATA; - xPropSet->setPropertyValue(aOrientation, aAny); - } - break; - case 3: - { - uno::Any aAny; - aAny<<= sheet::DataPilotFieldOrientation_HIDDEN; - xPropSet->setPropertyValue(aOrientation, aAny); - } - break; - case 4: - { - uno::Any aAny; - aAny<<= sheet::DataPilotFieldOrientation_PAGE; - xPropSet->setPropertyValue(aOrientation, aAny); - } - break; - default: - break; - } - } -} - -void ScXDataPilotDescriptor::testGetDataPilotFields() -{ - uno::Reference< sheet::XDataPilotDescriptor > xDescr = init(); - testGetDataPilotFields_Impl( xDescr ); -} - -void ScXDataPilotDescriptor::testGetColumnFields() -{ - uno::Reference< sheet::XDataPilotDescriptor > xDescr = init(); - uno::Reference< container::XIndexAccess > xIndex(xDescr->getColumnFields(), UNO_QUERY_THROW); - - checkName( xIndex, 0 ); -} - -void ScXDataPilotDescriptor::testGetRowFields() -{ - uno::Reference< sheet::XDataPilotDescriptor > xDescr = init(); - uno::Reference< container::XIndexAccess > xIndex(xDescr->getRowFields(), UNO_QUERY_THROW); - - //checkName( xIndex, 1 ); -} - -void ScXDataPilotDescriptor::testGetPageFields() -{ - uno::Reference< sheet::XDataPilotDescriptor > xDescr = init(); - uno::Reference< container::XIndexAccess > xIndex(xDescr->getPageFields(), UNO_QUERY_THROW); - - checkName( xIndex, 4 ); -} - -void ScXDataPilotDescriptor::testGetDataFields() -{ - uno::Reference< sheet::XDataPilotDescriptor > xDescr = init(); - uno::Reference< container::XIndexAccess > xIndex(xDescr->getDataFields(), UNO_QUERY_THROW); - - checkName( xIndex, 2 ); -} - -void ScXDataPilotDescriptor::testGetHiddenFields() -{ - uno::Reference< sheet::XDataPilotDescriptor > xDescr = init(); - uno::Reference< container::XIndexAccess > xIndex(xDescr->getHiddenFields(), UNO_QUERY_THROW); - - checkName( xIndex, 3 ); -} - -uno::Reference< sheet::XDataPilotDescriptor> ScXDataPilotDescriptor::init() -{ - rtl::OUString aFileURL; - const rtl::OUString aFileBase(RTL_CONSTASCII_USTRINGPARAM("ScDataPilotTableObj.ods")); - createFileURL(aFileBase, aFileURL); - std::cout << rtl::OUStringToOString(aFileURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl; - if( !xComponent.is()) - xComponent = loadFromDesktop(aFileURL); - uno::Reference< sheet::XSpreadsheetDocument> xDoc (xComponent, UNO_QUERY_THROW); - uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW); - uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW); - - CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is()); - uno::Reference< sheet::XDataPilotTablesSupplier > xDPTS(xSheet, UNO_QUERY_THROW); - CPPUNIT_ASSERT(xDPTS.is()); - uno::Reference< sheet::XDataPilotTables > xDPT = xDPTS->getDataPilotTables(); - CPPUNIT_ASSERT(xDPT.is()); - uno::Sequence aElementNames = xDPT->getElementNames(); - - uno::Reference< sheet::XDataPilotDescriptor > xDPDsc(xDPT->getByName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataPilotTable"))),UNO_QUERY_THROW); - - testGetDataPilotFields_Impl( xDPDsc ); - - CPPUNIT_ASSERT(xDPDsc.is()); - return xDPDsc; -} - -void ScXDataPilotDescriptor::checkName( uno::Reference< container::XIndexAccess > xIndex, sal_Int32 nIndex ) -{ - CPPUNIT_ASSERT(xIndex.is()); - CPPUNIT_ASSERT(maFieldNames.size() >= static_cast(nIndex)); - - for (sal_Int32 i = 0; i < xIndex->getCount(); ++i) - { - uno::Reference< container::XNamed > xNamed( xIndex->getByIndex(i), UNO_QUERY_THROW); - CPPUNIT_ASSERT( xNamed->getName() == maFieldNames[nIndex] ); - } -} - -void ScXDataPilotDescriptor::setUp() -{ - nTest += 1; - UnoApiTest::setUp(); -} - -void ScXDataPilotDescriptor::tearDown() -{ - if (nTest == NUMBER_OF_TESTS) - { - uno::Reference< util::XCloseable > xCloseable(xComponent, UNO_QUERY_THROW); - xCloseable->close( false ); - } - - UnoApiTest::tearDown(); - - if (nTest == NUMBER_OF_TESTS) - { - mxDesktop->terminate(); - uno::Reference< lang::XComponent>(m_xContext, UNO_QUERY_THROW)->dispose(); - } -} - -CPPUNIT_TEST_SUITE_REGISTRATION(ScXDataPilotDescriptor); - -CPPUNIT_PLUGIN_IMPLEMENT(); - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/qa/extras/xdatapilotfieldgrouping.cxx b/sc/qa/extras/xdatapilotfieldgrouping.cxx deleted file mode 100644 index 4ee9a1c37028..000000000000 --- a/sc/qa/extras/xdatapilotfieldgrouping.cxx +++ /dev/null @@ -1,149 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * Version: MPL 1.1 / GPLv3+ / LGPLv3+ - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License or as specified alternatively below. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Major Contributor(s): - * Copyright (C) 2011 Markus Mohrhard (initial developer) - * - * All Rights Reserved. - * - * For minor contributions see the git repository. - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 3 or later (the "GPLv3+"), or - * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), - * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable - * instead of those above. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace ScDataPilotFieldObj { - -#define NUMBER_OF_TESTS 1 - -class ScXDataPilotFieldGrouping : public UnoApiTest -{ -public: - void testCreateNameGroup(); - void testCreateDateGroup(); - - virtual void setUp(); - virtual void tearDown(); - - CPPUNIT_TEST_SUITE(ScXDataPilotFieldGrouping); - CPPUNIT_TEST(testCreateNameGroup); - //broken: fdo#43609 - //CPPUNIT_TEST(testCreateDateGroup); - CPPUNIT_TEST_SUITE_END(); - - uno::Reference< sheet::XDataPilotFieldGrouping > init(); - -private: - static int nTest; - static uno::Reference< lang::XComponent > xComponent; -}; - -int ScXDataPilotFieldGrouping::nTest = 0; -uno::Reference< lang::XComponent > ScXDataPilotFieldGrouping::xComponent; - -void ScXDataPilotFieldGrouping::testCreateNameGroup() -{ - uno::Reference< sheet::XDataPilotFieldGrouping > xDataPilotFieldGrouping = init(); - uno::Reference< sheet::XDataPilotField > xDataPilotField( xDataPilotFieldGrouping, UNO_QUERY_THROW ); - uno::Reference< container::XNameAccess > xNameAccess( xDataPilotField->getItems(), UNO_QUERY_THROW ); - CPPUNIT_ASSERT(xNameAccess->hasElements()); - - uno::Sequence< rtl::OUString > aElements = xNameAccess->getElementNames(); - xDataPilotFieldGrouping->createNameGroup( aElements ); -} - -void ScXDataPilotFieldGrouping::testCreateDateGroup() -{ - uno::Reference< sheet::XDataPilotFieldGrouping > xDataPilotFieldGrouping = init(); - sheet::DataPilotFieldGroupInfo aGroupInfo; - aGroupInfo.GroupBy = sheet::DataPilotFieldGroupBy::MONTHS; - aGroupInfo.HasDateValues = true; - xDataPilotFieldGrouping->createDateGroup(aGroupInfo); -} - -uno::Reference< sheet::XDataPilotFieldGrouping> ScXDataPilotFieldGrouping::init() -{ - rtl::OUString aFileURL; - const rtl::OUString aFileBase(RTL_CONSTASCII_USTRINGPARAM("scdatapilotfieldobj.ods")); - createFileURL(aFileBase, aFileURL); - std::cout << rtl::OUStringToOString(aFileURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl; - if( !xComponent.is()) - xComponent = loadFromDesktop(aFileURL); - uno::Reference< sheet::XSpreadsheetDocument> xDoc (xComponent, UNO_QUERY_THROW); - uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW); - uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(1), UNO_QUERY_THROW); - - CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is()); - uno::Reference< sheet::XDataPilotTablesSupplier > xDPTS(xSheet, UNO_QUERY_THROW); - CPPUNIT_ASSERT(xDPTS.is()); - uno::Reference< sheet::XDataPilotTables > xDPT = xDPTS->getDataPilotTables(); - CPPUNIT_ASSERT(xDPT.is()); - uno::Sequence aElementNames = xDPT->getElementNames(); - for (int i = 0; i < aElementNames.getLength(); ++i) - { - std::cout << "PivotTable: " << aElementNames[i] << std::endl; - } - - uno::Reference< sheet::XDataPilotDescriptor > xDPDsc(xDPT->getByName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataPilot1"))),UNO_QUERY_THROW); - - CPPUNIT_ASSERT(xDPDsc.is()); - uno::Reference< container::XIndexAccess > xIA( xDPDsc->getDataPilotFields(), UNO_QUERY_THROW); - uno::Reference< sheet::XDataPilotFieldGrouping > xReturnValue( xIA->getByIndex(0), UNO_QUERY_THROW); - CPPUNIT_ASSERT(xReturnValue.is()); - return xReturnValue; -} - -void ScXDataPilotFieldGrouping::setUp() -{ - nTest += 1; - UnoApiTest::setUp(); -} - -void ScXDataPilotFieldGrouping::tearDown() -{ - if (nTest == NUMBER_OF_TESTS) - { - uno::Reference< util::XCloseable > xCloseable(xComponent, UNO_QUERY_THROW); - xCloseable->close( false ); - } - - UnoApiTest::tearDown(); - - if (nTest == NUMBER_OF_TESTS) - { - mxDesktop->terminate(); - uno::Reference< lang::XComponent>(m_xContext, UNO_QUERY_THROW)->dispose(); - } -} - -CPPUNIT_TEST_SUITE_REGISTRATION(ScXDataPilotFieldGrouping); - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/qa/extras/xdatapilottable.cxx b/sc/qa/extras/xdatapilottable.cxx deleted file mode 100644 index c19c484d8e96..000000000000 --- a/sc/qa/extras/xdatapilottable.cxx +++ /dev/null @@ -1,149 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * Version: MPL 1.1 / GPLv3+ / LGPLv3+ - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License or as specified alternatively below. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Major Contributor(s): - * Copyright (C) 2012 Markus Mohrhard (initial developer) - * - * All Rights Reserved. - * - * For minor contributions see the git repository. - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 3 or later (the "GPLv3+"), or - * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), - * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable - * instead of those above. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace ScDataPilotDescriptorBase -{ - -#define NUMBER_OF_TESTS 2 - -class ScXDataPilotTable : public UnoApiTest -{ -public: - - virtual void setUp(); - virtual void tearDown(); - - void testGetOutputRange(); - void testRefresh(); - CPPUNIT_TEST_SUITE(ScXDataPilotTable); - CPPUNIT_TEST(testGetOutputRange); - CPPUNIT_TEST(testRefresh); - CPPUNIT_TEST_SUITE_END(); -private: - - uno::Reference< sheet::XDataPilotTable > init(); - - static int nTest; - static uno::Reference< lang::XComponent > xComponent; - - uno::Reference< table::XCell > xCellForChange; - uno::Reference< table::XCell > xCellForCheck; -}; - -int ScXDataPilotTable::nTest = 0; -uno::Reference< lang::XComponent > ScXDataPilotTable::xComponent; - -void ScXDataPilotTable::testGetOutputRange() -{ - uno::Reference< sheet::XDataPilotTable > xDPTable = init(); - - table::CellRangeAddress aRange = xDPTable->getOutputRange(); - CPPUNIT_ASSERT( aRange.Sheet == 0 ); - CPPUNIT_ASSERT( aRange.StartColumn == 7 ); - CPPUNIT_ASSERT( aRange.StartRow == 8 ); -} - -void ScXDataPilotTable::testRefresh() -{ - uno::Reference< sheet::XDataPilotTable > xDPTable = init(); - xCellForChange->setValue( 5 ); - - double aOldData = xCellForCheck->getValue(); - xDPTable->refresh(); - double aNewData = xCellForCheck->getValue(); - CPPUNIT_ASSERT_MESSAGE("value needs to change", aOldData != aNewData); -} - -uno::Reference< sheet::XDataPilotTable > ScXDataPilotTable::init() -{ - rtl::OUString aFileURL; - const rtl::OUString aFileBase(RTL_CONSTASCII_USTRINGPARAM("ScDataPilotTableObj.ods")); - createFileURL(aFileBase, aFileURL); - std::cout << rtl::OUStringToOString(aFileURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl; - if( !xComponent.is()) - xComponent = loadFromDesktop(aFileURL); - uno::Reference< sheet::XSpreadsheetDocument> xDoc (xComponent, UNO_QUERY_THROW); - uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW); - uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW); - - // set variables - xCellForChange = xSheet->getCellByPosition( 1, 5 ); - xCellForCheck = xSheet->getCellByPosition( 7, 11 ); - - CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is()); - uno::Reference< sheet::XDataPilotTablesSupplier > xDPTS(xSheet, UNO_QUERY_THROW); - CPPUNIT_ASSERT(xDPTS.is()); - uno::Reference< sheet::XDataPilotTables > xDPT = xDPTS->getDataPilotTables(); - CPPUNIT_ASSERT(xDPT.is()); - uno::Sequence aElementNames = xDPT->getElementNames(); - - uno::Reference< sheet::XDataPilotTable > xDPTable(xDPT->getByName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataPilotTable"))),UNO_QUERY_THROW); - - CPPUNIT_ASSERT(xDPTable.is()); - return xDPTable; -} - -void ScXDataPilotTable::setUp() -{ - nTest += 1; - UnoApiTest::setUp(); -} - -void ScXDataPilotTable::tearDown() -{ - if (nTest == NUMBER_OF_TESTS) - { - uno::Reference< util::XCloseable > xCloseable(xComponent, UNO_QUERY_THROW); - xCloseable->close( false ); - } - - UnoApiTest::tearDown(); - - if (nTest == NUMBER_OF_TESTS) - { - mxDesktop->terminate(); - uno::Reference< lang::XComponent>(m_xContext, UNO_QUERY_THROW)->dispose(); - } -} - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/qa/extras/xnamecontainer.cxx b/sc/qa/extras/xnamecontainer.cxx deleted file mode 100644 index 0a4233577ed4..000000000000 --- a/sc/qa/extras/xnamecontainer.cxx +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * Version: MPL 1.1 / GPLv3+ / LGPLv3+ - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License or as specified alternatively below. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Major Contributor(s): - * Copyright (C) 2011 Markus Mohrhard (initial developer) - * - * All Rights Reserved. - * - * For minor contributions see the git repository. - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 3 or later (the "GPLv3+"), or - * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), - * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable - * instead of those above. - */ - -#include -#include -#include - - -namespace ScTableSheetsObj -{ - -class ScXNameContainer : public UnoApiTest -{ - uno::Reference< container::XNameContainer > init(); - - void testRemoveByName(); - - CPPUNIT_TEST_SUITE(ScXNameContainer); - CPPUNIT_TEST(testRemoveByName); - CPPUNIT_TEST_SUITE_END(); -}; - -void ScXNameContainer::testRemoveByName() -{ - rtl::OUString aSheet2(RTL_CONSTASCII_USTRINGPARAM("Sheet2")); - uno::Reference< container::XNameContainer > xNameContainer = init(); - CPPUNIT_ASSERT(xNameContainer->hasByName(aSheet2)); - xNameContainer->removeByName(aSheet2); - CPPUNIT_ASSERT(!xNameContainer->hasByName(aSheet2)); - - bool bExceptionThrown = false; - try - { - xNameContainer->removeByName(aSheet2); - } - catch( const container::NoSuchElementException& ) - { - std::cout << "Exception Caught" << std::endl; - bExceptionThrown = true; - } - - CPPUNIT_ASSERT_MESSAGE("no exception thrown", bExceptionThrown); -} - -uno::Reference< container::XNameContainer > ScXNameContainer::init() -{ - uno::Reference< lang::XComponent > xComponent; - xComponent = loadFromDesktop(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/scalc"))); - CPPUNIT_ASSERT(xComponent.is()); - uno::Reference< sheet::XSpreadsheetDocument> xDoc (xComponent, UNO_QUERY_THROW); - uno::Reference< container::XNameContainer > xNameContainer ( xDoc->getSheets(), UNO_QUERY_THROW); - CPPUNIT_ASSERT(xNameContainer.is()); - return xNameContainer; -} - -CPPUNIT_TEST_SUITE_REGISTRATION(ScXNameContainer); - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/qa/extras/xnamedrange.cxx b/sc/qa/extras/xnamedrange.cxx deleted file mode 100644 index 616c8353b79f..000000000000 --- a/sc/qa/extras/xnamedrange.cxx +++ /dev/null @@ -1,201 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * Version: MPL 1.1 / GPLv3+ / LGPLv3+ - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License or as specified alternatively below. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Major Contributor(s): - * Copyright (C) 2011 Laurent Godard lgodard.libre@laposte.net (initial developer) - * - * All Rights Reserved. - * - * For minor contributions see the git repository. - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 3 or later (the "GPLv3+"), or - * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), - * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable - * instead of those above. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -namespace ScNamedRangeObj { - -class ScXNamedRange : public UnoApiTest -{ - uno::Reference< sheet::XSpreadsheetDocument> init(); - uno::Reference< sheet::XNamedRange> getTestedNamedRange(const rtl::OUString&); - - // XNamedRange - void testGetContent(); - void testSetContent(); - void testGetType(); - void testSetType(); - void testGetReferencePosition(); - void testSetReferencePosition(); - - CPPUNIT_TEST_SUITE(ScXNamedRange); - CPPUNIT_TEST(testGetContent); - CPPUNIT_TEST(testSetContent); - CPPUNIT_TEST(testGetType); - CPPUNIT_TEST(testSetType); - CPPUNIT_TEST(testGetReferencePosition); - CPPUNIT_TEST(testSetReferencePosition); - CPPUNIT_TEST_SUITE_END(); -}; - - -void ScXNamedRange::testGetContent() -{ - rtl::OUString aTestedNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("initial1")); - uno::Reference< sheet::XNamedRange > xNamedRange = getTestedNamedRange(aTestedNamedRangeString); - - rtl::OUString aExpectedContent(RTL_CONSTASCII_USTRINGPARAM("$Sheet1.$B$1")); - CPPUNIT_ASSERT_MESSAGE("Wrong expected content for initial1 on GetContent", xNamedRange->getContent().equals(aExpectedContent)); -} - -void ScXNamedRange::testSetContent() -{ - rtl::OUString aTestedNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("initial1")); - uno::Reference< sheet::XNamedRange > xNamedRange = getTestedNamedRange(aTestedNamedRangeString); - - rtl::OUString aExpectedContent; - - // test a cell - aExpectedContent = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("D1")); - xNamedRange->setContent(aExpectedContent); - CPPUNIT_ASSERT_MESSAGE("Wrong expected content for initial1 after SetContent a cell", xNamedRange->getContent().equals(aExpectedContent)); - - // test a cellrange - aExpectedContent = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("D1:D10")); - xNamedRange->setContent(aExpectedContent); - CPPUNIT_ASSERT_MESSAGE("Wrong expected content for initial1 after SetContent a cellrange", xNamedRange->getContent().equals(aExpectedContent)); - - // test a formula - aExpectedContent = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=D10")); - xNamedRange->setContent(aExpectedContent); - aExpectedContent = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("D10")); - CPPUNIT_ASSERT_MESSAGE("Wrong expected content for initial1 after SetContent a formula", xNamedRange->getContent().equals(aExpectedContent)); - -} - -void ScXNamedRange::testGetType() -{ - rtl::OUString aTestedNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("initial1")); - uno::Reference< sheet::XNamedRange > xNamedRange = getTestedNamedRange(aTestedNamedRangeString); - CPPUNIT_ASSERT_MESSAGE("Wrong expected Type", xNamedRange->getType() == 0); -} - -void ScXNamedRange::testSetType() -{ - rtl::OUString aTestedNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("initial1")); - uno::Reference< sheet::XNamedRange > xNamedRange = getTestedNamedRange(aTestedNamedRangeString); - - sal_Int32 nType = ::sheet::NamedRangeFlag::ROW_HEADER;; - xNamedRange->setType(nType); - CPPUNIT_ASSERT_MESSAGE("Wrong expected Type ROW_HEADER after setting it", xNamedRange->getType() == nType); - - nType = ::sheet::NamedRangeFlag::COLUMN_HEADER; - xNamedRange->setType(nType); - CPPUNIT_ASSERT_MESSAGE("Wrong expected Type COLUMN_HEADER after setting it", xNamedRange->getType() == nType); - - nType = ::sheet::NamedRangeFlag::FILTER_CRITERIA; - xNamedRange->setType(nType); - CPPUNIT_ASSERT_MESSAGE("Wrong expected Type FILTER_CRITERIA after setting it", xNamedRange->getType() == nType); - - nType = ::sheet::NamedRangeFlag::PRINT_AREA; - xNamedRange->setType(nType); - CPPUNIT_ASSERT_MESSAGE("Wrong expected Type PRINT_AREA after setting it", xNamedRange->getType() == nType); - - nType = 0; - xNamedRange->setType(nType); - CPPUNIT_ASSERT_MESSAGE("Wrong expected Type 0 after setting it", xNamedRange->getType() == nType); -} - -void ScXNamedRange::testGetReferencePosition() -{ - rtl::OUString aTestedNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("initial2")); - uno::Reference< sheet::XNamedRange > xNamedRange = getTestedNamedRange(aTestedNamedRangeString); - - table::CellAddress xCellAddress = xNamedRange->getReferencePosition(); - // the expeted address is on B1, as it was the active cell when intial2 created - CPPUNIT_ASSERT_MESSAGE("Wrong SHEET reference position", xCellAddress.Sheet == 0); - CPPUNIT_ASSERT_MESSAGE("Wrong COLUMN reference position", xCellAddress.Column == 1); - CPPUNIT_ASSERT_MESSAGE("Wrong ROW reference position", xCellAddress.Row == 0); -} - -void ScXNamedRange::testSetReferencePosition() -{ - rtl::OUString aTestedNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("initial1")); - uno::Reference< sheet::XNamedRange > xNamedRange = getTestedNamedRange(aTestedNamedRangeString); - - table::CellAddress aBaseAddress = table::CellAddress(1,2,3); - - xNamedRange->setReferencePosition(aBaseAddress); - - table::CellAddress xCellAddress = xNamedRange->getReferencePosition(); - CPPUNIT_ASSERT_MESSAGE("Wrong SHEET reference position after setting it", xCellAddress.Sheet == 1); - CPPUNIT_ASSERT_MESSAGE("Wrong COLUMN reference position after setting it", xCellAddress.Column == 2); - CPPUNIT_ASSERT_MESSAGE("Wrong ROW reference position after setting it", xCellAddress.Row == 3); -} - -uno::Reference< sheet::XSpreadsheetDocument> ScXNamedRange::init() -{ - rtl::OUString aFileURL; - const rtl::OUString aFileBase(RTL_CONSTASCII_USTRINGPARAM("rangenames.ods")); - createFileURL(aFileBase, aFileURL); - static uno::Reference< lang::XComponent > xComponent; - if( !xComponent.is()) - xComponent = loadFromDesktop(aFileURL); - uno::Reference< sheet::XSpreadsheetDocument> xDoc (xComponent, UNO_QUERY_THROW); - CPPUNIT_ASSERT(xDoc.is()); - - return xDoc; -} - -uno::Reference< sheet::XNamedRange> ScXNamedRange::getTestedNamedRange(const rtl::OUString& aTestedNamedRangeString) -{ - uno::Reference< sheet::XSpreadsheetDocument> xDoc = init(); - uno::Reference< beans::XPropertySet > xPropSet (xDoc, UNO_QUERY_THROW); - rtl::OUString aNamedRangesPropertyString(RTL_CONSTASCII_USTRINGPARAM("NamedRanges")); - uno::Reference< container::XNameAccess > xNamedRangesNameAccess(xPropSet->getPropertyValue(aNamedRangesPropertyString), UNO_QUERY_THROW); - - uno::Reference< sheet::XNamedRange > xNamedRange(xNamedRangesNameAccess->getByName(aTestedNamedRangeString), UNO_QUERY_THROW); - - return xNamedRange; -} - -CPPUNIT_TEST_SUITE_REGISTRATION(ScXNamedRange); - -CPPUNIT_PLUGIN_IMPLEMENT(); - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/qa/extras/xnamedranges.cxx b/sc/qa/extras/xnamedranges.cxx deleted file mode 100644 index 70a599698e57..000000000000 --- a/sc/qa/extras/xnamedranges.cxx +++ /dev/null @@ -1,259 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * Version: MPL 1.1 / GPLv3+ / LGPLv3+ - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License or as specified alternatively below. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Major Contributor(s): - * Copyright (C) 2011 Laurent Godard lgodard.libre@laposte.net (initial developer) - * - * All Rights Reserved. - * - * For minor contributions see the git repository. - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 3 or later (the "GPLv3+"), or - * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), - * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable - * instead of those above. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -namespace ScNamedRangesObj { - -class ScXNamedRanges : public UnoApiTest -{ - uno::Reference< sheet::XSpreadsheetDocument> init(); - - // XNamedRanges - void testAddNewByName(); - void testAddNewFromTitles(); - void testRemoveByName(); - void testOutputList(); - - CPPUNIT_TEST_SUITE(ScXNamedRanges); - CPPUNIT_TEST(testAddNewByName); - CPPUNIT_TEST(testAddNewFromTitles); - //fix first warning in ExceptionsTestCaseDecorator - //CPPUNIT_TEST_EXCEPTION(testRemoveByName, uno::RuntimeException); - CPPUNIT_TEST(testOutputList); - CPPUNIT_TEST_SUITE_END(); -}; - - -void ScXNamedRanges::testAddNewByName() -{ - uno::Reference< sheet::XSpreadsheetDocument> xDoc = init(); - uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW); - uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW); - - uno::Reference< beans::XPropertySet > xPropSet (xDoc, UNO_QUERY_THROW); - rtl::OUString aNamedRangesString(RTL_CONSTASCII_USTRINGPARAM("NamedRanges")); - uno::Reference< sheet::XNamedRanges > xNamedRanges(xPropSet->getPropertyValue(aNamedRangesString), UNO_QUERY_THROW); - uno::Reference< container::XNameAccess > xNamedRangesNameAccess(xPropSet->getPropertyValue(aNamedRangesString), UNO_QUERY_THROW); - - table::CellAddress aBaseAddress = table::CellAddress(0,0,0); - - sal_Int32 nType = 0; - rtl::OUString aContent1(RTL_CONSTASCII_USTRINGPARAM("D1")); - rtl::OUString aName1(RTL_CONSTASCII_USTRINGPARAM("type_0")); - xNamedRanges->addNewByName(aName1, aContent1, aBaseAddress, nType); - CPPUNIT_ASSERT_MESSAGE("Failed to create Namedrange Type 0 - Normal case", xNamedRanges->hasByName(aName1)); - - nType = ::sheet::NamedRangeFlag::COLUMN_HEADER; - rtl::OUString aContent2(RTL_CONSTASCII_USTRINGPARAM("D2")); - rtl::OUString aName2(RTL_CONSTASCII_USTRINGPARAM("type_COLUMN_HEADER")); - xNamedRanges->addNewByName(aName2, aContent2, aBaseAddress, nType); - CPPUNIT_ASSERT_MESSAGE("Failed to create Namedrange Type COLUMN_HEADER", xNamedRanges->hasByName(aName2)); - - nType = ::sheet::NamedRangeFlag::FILTER_CRITERIA; - rtl::OUString aContent3(RTL_CONSTASCII_USTRINGPARAM("D3")); - rtl::OUString aName3(RTL_CONSTASCII_USTRINGPARAM("type_FILTER_CRITERIA")); - xNamedRanges->addNewByName(aName3, aContent3, aBaseAddress, nType); - CPPUNIT_ASSERT_MESSAGE("Failed to create Namedrange Type FILTER_CRITERIA", xNamedRanges->hasByName(aName3)); - - nType = ::sheet::NamedRangeFlag::PRINT_AREA; - rtl::OUString aContent4(RTL_CONSTASCII_USTRINGPARAM("D4")); - rtl::OUString aName4(RTL_CONSTASCII_USTRINGPARAM("type_PRINT_AREA")); - xNamedRanges->addNewByName(aName4, aContent4, aBaseAddress, nType); - CPPUNIT_ASSERT_MESSAGE("Failed to create Namedrange Type PRINT_AREA", xNamedRanges->hasByName(aName4)); - - nType = ::sheet::NamedRangeFlag::ROW_HEADER; - rtl::OUString aContent5(RTL_CONSTASCII_USTRINGPARAM("D5")); - rtl::OUString aName5(RTL_CONSTASCII_USTRINGPARAM("type_ROW_HEADER")); - xNamedRanges->addNewByName(aName5, aContent5, aBaseAddress, nType); - CPPUNIT_ASSERT_MESSAGE("Failed to create Namedrange Type ROW_HEADER", xNamedRanges->hasByName(aName5)); - -} - -void ScXNamedRanges::testAddNewFromTitles() -{ - - uno::Reference< sheet::XSpreadsheetDocument> xDoc = init(); - uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW); - uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(1), UNO_QUERY_THROW); - - uno::Reference< beans::XPropertySet > xPropSet (xDoc, UNO_QUERY_THROW); - rtl::OUString aNamedRangesString(RTL_CONSTASCII_USTRINGPARAM("NamedRanges")); - uno::Reference< sheet::XNamedRanges > xNamedRanges(xPropSet->getPropertyValue(aNamedRangesString), UNO_QUERY_THROW); - uno::Reference< container::XIndexAccess > xNamedRangesIndex(xPropSet->getPropertyValue(aNamedRangesString), UNO_QUERY_THROW); - uno::Reference< container::XNameAccess > xNamedRangesNameAccess(xPropSet->getPropertyValue(aNamedRangesString), UNO_QUERY_THROW); - - table::CellRangeAddress aCellRangeAddress = table::CellRangeAddress(1,0,0,3,3); - - rtl::OUString aString; - uno::Reference< table::XCell > xCell; - - xNamedRanges->addNewFromTitles(aCellRangeAddress, sheet::Border_TOP); - - for (sal_Int32 i = 1; i < 4; i++) - { - // verify namedrange exists - xCell = xSheet->getCellByPosition(i,0); - uno::Reference< text::XTextRange > xTextRange(xCell, UNO_QUERY_THROW); - aString = xTextRange->getString(); - std::cout << "verify " << aString << std::endl; - CPPUNIT_ASSERT_MESSAGE("Non existing NamedRange", xNamedRanges->hasByName(aString)); - - // verify it points on the right cell - uno::Any aNr = xNamedRangesNameAccess->getByName(aString); - uno::Reference< sheet::XNamedRange > xNamedRange(aNr, UNO_QUERY_THROW); - - uno::Reference< sheet::XCellRangeReferrer > xCellRangeRef(xNamedRange, UNO_QUERY_THROW); - uno::Reference< sheet::XCellRangeAddressable > xCellRangeAdr(xCellRangeRef->getReferredCells(), UNO_QUERY_THROW); - table::CellRangeAddress cellRangeAddress = xCellRangeAdr->getRangeAddress(); - - CPPUNIT_ASSERT(cellRangeAddress.EndColumn == i && cellRangeAddress.StartColumn == i); - CPPUNIT_ASSERT(cellRangeAddress.StartRow == 1); - CPPUNIT_ASSERT(cellRangeAddress.EndRow == 3); - CPPUNIT_ASSERT(cellRangeAddress.Sheet == 1); - } - - xNamedRanges->addNewFromTitles(aCellRangeAddress, sheet::Border_LEFT); - - for (sal_Int32 i = 1; i < 4; i++) - { - // verify namedrange exists - xCell = xSheet->getCellByPosition(0,i); - uno::Reference< text::XTextRange > xTextRange(xCell, UNO_QUERY_THROW); - aString = xTextRange->getString(); - std::cout << "verify " << aString << std::endl; - CPPUNIT_ASSERT_MESSAGE("Non existing NamedRange", xNamedRanges->hasByName(aString)); - - // verify it points on the right cell - uno::Any aNr= xNamedRangesNameAccess->getByName(aString); - uno::Reference< sheet::XNamedRange > xNamedRange(aNr, UNO_QUERY_THROW); - - uno::Reference< sheet::XCellRangeReferrer > xCellRangeRef(xNamedRange, UNO_QUERY_THROW); - uno::Reference< sheet::XCellRangeAddressable > xCellRangeAdr(xCellRangeRef->getReferredCells(), UNO_QUERY_THROW); - table::CellRangeAddress cellRangeAddress = xCellRangeAdr->getRangeAddress(); - - CPPUNIT_ASSERT(cellRangeAddress.EndRow == i && cellRangeAddress.StartRow == i); - CPPUNIT_ASSERT(cellRangeAddress.StartColumn == 1); - CPPUNIT_ASSERT(cellRangeAddress.EndColumn == 3); - CPPUNIT_ASSERT(cellRangeAddress.Sheet == 1); - } -} - -void ScXNamedRanges::testRemoveByName() -{ - uno::Reference< sheet::XSpreadsheetDocument> xDoc = init(); - uno::Reference< beans::XPropertySet > xPropSet (xDoc, UNO_QUERY_THROW); - rtl::OUString aNamedRangesString(RTL_CONSTASCII_USTRINGPARAM("NamedRanges")); - uno::Reference< sheet::XNamedRanges > xNamedRanges(xPropSet->getPropertyValue(aNamedRangesString), UNO_QUERY_THROW); - uno::Reference< container::XIndexAccess > xIndex(xPropSet->getPropertyValue(aNamedRangesString), UNO_QUERY_THROW); - - rtl::OUString aNr1(RTL_CONSTASCII_USTRINGPARAM("initial1")); - bool bHasIt = xNamedRanges->hasByName(aNr1); - CPPUNIT_ASSERT_MESSAGE("NamedRange initial1 des not exits, can't remove it", bHasIt); - - if (bHasIt) - { - // remove existing - sal_Int32 nInitialCount = xIndex->getCount(); - xNamedRanges->removeByName(aNr1); - sal_Int32 nNewCount = xIndex->getCount(); - CPPUNIT_ASSERT_MESSAGE("NamedRange initial1 not removed", nNewCount == nInitialCount - 1); - CPPUNIT_ASSERT_MESSAGE("Wrong NamedRange removed, initial1 still present", !xNamedRanges->hasByName(aNr1)); - // try to remove non existing - rtl::OUString aNr2(RTL_CONSTASCII_USTRINGPARAM("dummyNonExistingNamedRange")); - xNamedRanges->removeByName(aNr2);// an exception should be raised here - } -} - -void ScXNamedRanges::testOutputList() -{ - - uno::Reference< sheet::XSpreadsheetDocument> xDoc = init(); - uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW); - uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW); - - table::CellAddress xCellAddress = table::CellAddress (0,2,0); - - uno::Reference< beans::XPropertySet > xPropSet (xDoc, UNO_QUERY_THROW); - rtl::OUString aNamedRangesString(RTL_CONSTASCII_USTRINGPARAM("NamedRanges")); - uno::Reference< sheet::XNamedRanges > xNamedRanges(xPropSet->getPropertyValue(aNamedRangesString), UNO_QUERY_THROW); - uno::Reference< container::XIndexAccess > xNamedRangesIndex(xPropSet->getPropertyValue(aNamedRangesString), UNO_QUERY_THROW); - sal_Int32 nElementsCount = xNamedRangesIndex->getCount(); - - xNamedRanges->outputList(xCellAddress); - - rtl::OUString aString; - uno::Reference< table::XCell > xCell; - - for (sal_Int32 i = 0; i < nElementsCount; i++) - { - xCell = xSheet->getCellByPosition(2,i); - uno::Reference< text::XTextRange > xTextRange(xCell, UNO_QUERY_THROW); - aString = xTextRange->getString(); - std::cout << "verify " << aString << std::endl; - CPPUNIT_ASSERT_MESSAGE("Non existing NamedRange", xNamedRanges->hasByName(aString)); - } -} - -uno::Reference< sheet::XSpreadsheetDocument> ScXNamedRanges::init() -{ - rtl::OUString aFileURL; - const rtl::OUString aFileBase(RTL_CONSTASCII_USTRINGPARAM("rangenames.ods")); - createFileURL(aFileBase, aFileURL); - static uno::Reference< lang::XComponent > xComponent; - if( !xComponent.is()) - xComponent = loadFromDesktop(aFileURL); - uno::Reference< sheet::XSpreadsheetDocument> xDoc (xComponent, UNO_QUERY_THROW); - CPPUNIT_ASSERT(xDoc.is()); - - return xDoc; -} - -CPPUNIT_TEST_SUITE_REGISTRATION(ScXNamedRanges); - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/qa/extras/xspreadsheets2.cxx b/sc/qa/extras/xspreadsheets2.cxx deleted file mode 100644 index f694556b0313..000000000000 --- a/sc/qa/extras/xspreadsheets2.cxx +++ /dev/null @@ -1,447 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * Version: MPL 1.1 / GPLv3+ / LGPLv3+ - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License or as specified alternatively below. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Major Contributor(s): - * Copyright (C) 2011 Laurent Godard lgodard.libre@laposte.net (initial developer) - * - * All Rights Reserved. - * - * For minor contributions see the git repository. - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 3 or later (the "GPLv3+"), or - * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), - * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable - * instead of those above. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - - - -namespace ScSpreadsheetObj { - -#define NUMBER_OF_TESTS 1 - -class ScXSpreadsheets2 : public UnoApiTest -{ -public: - - virtual void setUp(); - virtual void tearDown(); - - // XSpreadsheets2 - void testImportedSheetNameAndIndex(); - void testImportString(); - void testImportValue(); - void testImportFormulaBasicMath(); - void testImportFormulaWithNamedRange(); - void testImportOverExistingNamedRange(); - void testImportNamedRangeDefinedInSource(); - void testImportNamedRangeRedefinedInSource(); - void testImportNewNamedRange(); - void testImportCellStyle(); - - CPPUNIT_TEST_SUITE(ScXSpreadsheets2); - CPPUNIT_TEST(testImportedSheetNameAndIndex); - CPPUNIT_TEST(testImportString); - CPPUNIT_TEST(testImportValue); - CPPUNIT_TEST(testImportFormulaBasicMath); - CPPUNIT_TEST(testImportFormulaWithNamedRange); - CPPUNIT_TEST(testImportOverExistingNamedRange); - CPPUNIT_TEST(testImportNamedRangeDefinedInSource); - CPPUNIT_TEST(testImportNamedRangeRedefinedInSource); - CPPUNIT_TEST(testImportNewNamedRange); - CPPUNIT_TEST(testImportCellStyle); - - CPPUNIT_TEST_SUITE_END(); - -private: - uno::Reference< sheet::XSpreadsheetDocument> getDoc(const rtl::OUString, uno::Reference< lang::XComponent >&); - uno::Reference< sheet::XNamedRanges> getNamedRanges(uno::Reference< sheet::XSpreadsheetDocument >); - void importSheetToCopy(); - bool isExternalReference(const rtl::OUString aDestContent, const rtl::OUString aSrcContent ); - - static int nTest; - static uno::Reference< lang::XComponent > xComponent; - - static bool bIsSheetImported; - static uno::Reference< sheet::XSpreadsheetDocument> xSrcDoc; - static uno::Reference< sheet::XSpreadsheetDocument> xDestDoc; - static uno::Reference< container::XNameAccess > xSrcNamedRangesNameAccess; - static uno::Reference< container::XNameAccess > xDestNamedRangesNameAccess; - static uno::Reference< container::XNameAccess > xDestSheetNameAccess; - static uno::Reference< sheet::XSpreadsheet > xDestSheet; - static uno::Reference< sheet::XSpreadsheet > xSrcSheet; - static sal_Int32 nDestPosEffective; - static rtl::OUString aSrcSheetName; - static rtl::OUString aSrcFileBase; - static rtl::OUString aDestFileBase; - static sal_Int32 nDestPos; -}; - -int ScXSpreadsheets2::nTest = 0; -uno::Reference< lang::XComponent > ScXSpreadsheets2::xComponent; - -bool ScXSpreadsheets2::bIsSheetImported = false; -uno::Reference< sheet::XSpreadsheetDocument> ScXSpreadsheets2::xSrcDoc; -uno::Reference< sheet::XSpreadsheetDocument> ScXSpreadsheets2::xDestDoc; -uno::Reference< container::XNameAccess > ScXSpreadsheets2::xSrcNamedRangesNameAccess; -uno::Reference< container::XNameAccess > ScXSpreadsheets2::xDestNamedRangesNameAccess; -uno::Reference< container::XNameAccess > ScXSpreadsheets2::xDestSheetNameAccess; -uno::Reference< sheet::XSpreadsheet > ScXSpreadsheets2::xDestSheet; -uno::Reference< sheet::XSpreadsheet > ScXSpreadsheets2::xSrcSheet; -rtl::OUString ScXSpreadsheets2::aSrcSheetName(RTL_CONSTASCII_USTRINGPARAM("SheetToCopy")); -rtl::OUString ScXSpreadsheets2::aSrcFileBase(RTL_CONSTASCII_USTRINGPARAM("rangenamessrc.ods")); -rtl::OUString ScXSpreadsheets2::aDestFileBase(RTL_CONSTASCII_USTRINGPARAM("rangenames.ods")); -sal_Int32 ScXSpreadsheets2::nDestPos = 0; -sal_Int32 ScXSpreadsheets2::nDestPosEffective = 0; - -void ScXSpreadsheets2::testImportedSheetNameAndIndex() -{ -/** - Verfiy that the imported sheet has the correct name and is placed at the right requested index -*/ - - importSheetToCopy(); - - CPPUNIT_ASSERT_MESSAGE("Wrong sheet name", xDestSheetNameAccess->hasByName(aSrcSheetName)); - CPPUNIT_ASSERT_MESSAGE("Wrong sheet index", nDestPosEffective == nDestPos); - -} - -void ScXSpreadsheets2::testImportString() -{ -/** - tests the cell A1 containing a string correctly imported -*/ - importSheetToCopy(); - - uno::Reference< table::XCell > xSrcCell = xSrcSheet->getCellByPosition(0,0); - uno::Reference< text::XTextRange > xSrcTextRange(xSrcCell, UNO_QUERY_THROW); - rtl::OUString aSrcString = xSrcTextRange->getString(); - - uno::Reference< table::XCell > xDestCell = xDestSheet->getCellByPosition(0,0); - uno::Reference< text::XTextRange > xDestTextRange(xDestCell, UNO_QUERY_THROW); - rtl::OUString aDestString = xDestTextRange->getString(); - - CPPUNIT_ASSERT_MESSAGE("Wrong string imported", aDestString.equals(aSrcString)); -} - -void ScXSpreadsheets2::testImportValue() -{ -/** - tests the cell B1 containing a value correctly imported -*/ - importSheetToCopy(); - - uno::Reference< table::XCell > xSrcCell = xSrcSheet->getCellByPosition(1,0); - sal_Int32 aSrcValue = xSrcCell->getValue(); - - uno::Reference< table::XCell > xDestCell = xDestSheet->getCellByPosition(1,0); - sal_Int32 aDestValue = xDestCell->getValue(); - - CPPUNIT_ASSERT_MESSAGE("Wrong value imported", aSrcValue == aDestValue); -} - -void ScXSpreadsheets2::testImportFormulaBasicMath() -{ -/** - tests the cell C1 containing an arithmetic formula correctly imported -*/ - importSheetToCopy(); - - uno::Reference< table::XCell > xSrcCell = xSrcSheet->getCellByPosition(2,0); - rtl::OUString aSrcFormula = xSrcCell->getFormula(); - - uno::Reference< table::XCell > xDestCell = xDestSheet->getCellByPosition(2,0); - rtl::OUString aDestFormula = xDestCell->getFormula(); - - // potential problem later: formulas might be adjusted - // add some tests that the formulas are correctly adjusted - CPPUNIT_ASSERT_MESSAGE("Wrong formula imported", aDestFormula.equals(aSrcFormula)); -} - -void ScXSpreadsheets2::testImportFormulaWithNamedRange() -{ -/** - tests the cell D1 containing a formula that uses a NamedRange expression -*/ - importSheetToCopy(); - - uno::Reference< table::XCell > xSrcCell = xSrcSheet->getCellByPosition(3,0); - rtl::OUString aSrcFormula = xSrcCell->getFormula(); - - uno::Reference< table::XCell > xDestCell = xDestSheet->getCellByPosition(3,0); - rtl::OUString aDestFormula = xDestCell->getFormula(); - - CPPUNIT_ASSERT_MESSAGE("Wrong Namedrange formula imported", aDestFormula.equals(aSrcFormula)); -} - -void ScXSpreadsheets2::testImportOverExistingNamedRange() -{ -/** - Both Source and Target file define the named range initial1 - in Source, initial1 is defined outside the copied sheet - In Target, after import sheet, initial1 should point on its initial definition $Sheet1.$B$1 - - NEED MORE WORK -*/ - importSheetToCopy(); - - rtl::OUString aNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("initial1")); - - uno::Any aNr = xDestNamedRangesNameAccess->getByName(aNamedRangeString); - uno::Reference< sheet::XNamedRange > xDestNamedRange(aNr, UNO_QUERY_THROW); - rtl::OUString aNrDestContent = xDestNamedRange->getContent(); - - rtl::OUString aExpectedContent(RTL_CONSTASCII_USTRINGPARAM("$Sheet1.$B$1")); - - std::cout << "testImportSheet : initial1 aNrDestContent " << aNrDestContent << std::endl; - CPPUNIT_ASSERT_MESSAGE("Wrong address for initial1", aNrDestContent.equals(aExpectedContent)); - -} - -void ScXSpreadsheets2::testImportNamedRangeDefinedInSource() -{ -/** - in Source file, InSheetRangeName named range is defined in the copied sheet - it does not exists in target file - test that the range named is created in target and that it points in the target copied sheet -*/ - importSheetToCopy(); - - // New range name defined in imported sheet $SheetToCopy.$A$7 - rtl::OUString aNewInSheetNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("InSheetRangeName")); - CPPUNIT_ASSERT_MESSAGE("InSheetRangeName", xDestNamedRangesNameAccess->hasByName(aNewInSheetNamedRangeString)); - - uno::Any aNewInSheetNr = xDestNamedRangesNameAccess->getByName(aNewInSheetNamedRangeString); - uno::Reference< sheet::XNamedRange > xDestNewInSheetNamedRange(aNewInSheetNr, UNO_QUERY_THROW); - rtl::OUString aNewInSheetNrDestContent = xDestNewInSheetNamedRange->getContent(); - rtl::OUString aNewInSheetExpectedContent(RTL_CONSTASCII_USTRINGPARAM("$SheetToCopy.$A$7")); - - std::cout << "testImportSheet : InSheetRangeName content " << aNewInSheetNrDestContent << std::endl; - std::cout << "testImportSheet : InSheetRangeName expected " << aNewInSheetExpectedContent << std::endl; - CPPUNIT_ASSERT_MESSAGE("Wrong address for InSheetRangeName", aNewInSheetNrDestContent.equals(aNewInSheetExpectedContent)); -} - -void ScXSpreadsheets2::testImportNamedRangeRedefinedInSource() -{ -/** - in Source file, initial2 named range is defined in the copied sheet - it is defined in another sheet of target file - test that the range named points in the target copied sheet -*/ - importSheetToCopy(); - - // the source file redefines an existing named range in the imported sheet --> the target should not be changed - rtl::OUString aRedefinedInSheetNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("initial2")); - CPPUNIT_ASSERT_MESSAGE("aRedefinedInSheetNamedRangeString", xDestNamedRangesNameAccess->hasByName(aRedefinedInSheetNamedRangeString)); - - uno::Any aRedefinedInSheetNr = xDestNamedRangesNameAccess->getByName(aRedefinedInSheetNamedRangeString); - uno::Reference< sheet::XNamedRange > xDestRedefinedInSheetNamedRange(aRedefinedInSheetNr, UNO_QUERY_THROW); - rtl::OUString aRedefinedInSheetNrDestContent = xDestRedefinedInSheetNamedRange->getContent(); - rtl::OUString aRedefinedInSheetExpectedContent(RTL_CONSTASCII_USTRINGPARAM("$Sheet1.$B$2")); - std::cout << "testImportSheet : initial2 content " << aRedefinedInSheetNrDestContent << std::endl; - CPPUNIT_ASSERT_MESSAGE("Wrong address for Redefined InSheet named range", aRedefinedInSheetNrDestContent.equals(aRedefinedInSheetExpectedContent)); -} - -void ScXSpreadsheets2::testImportNewNamedRange() -{ -/** - in Soucre file, new_rangename range named is defined outside the copied sheet - it does not exists in target file - test that new_rangename is created and its content points to source file as an external reference -*/ - importSheetToCopy(); - - //formula with a non-existant named range in dest - new_rangename - rtl::OUString aNewNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("new_rangename")); - CPPUNIT_ASSERT_MESSAGE("New NamedRange not created", xDestNamedRangesNameAccess->hasByName(aNewNamedRangeString)); - - // verify the content of this new namedrange, pointing on $Sheet1.$B$1 in source. This address is already defined in target as NR content - - uno::Any aNewNr = xDestNamedRangesNameAccess->getByName(aNewNamedRangeString); - uno::Reference< sheet::XNamedRange > xDestNewNamedRange(aNewNr, UNO_QUERY_THROW); - rtl::OUString aNewNrDestContent = xDestNewNamedRange->getContent(); - - rtl::OUString aNewExpectedContent(RTL_CONSTASCII_USTRINGPARAM("$Sheet1.$B$1")); - - std::cout << "testImportSheet : new_rangename aNewExpectedContent " << aNewExpectedContent << std::endl; - std::cout << "testImportSheet : new_rangename aNewNrDestContent " << aNewNrDestContent << std::endl; - CPPUNIT_ASSERT_MESSAGE("Wrong New NamedRange formula string value", isExternalReference(aNewNrDestContent, aNewExpectedContent)); -} - -void ScXSpreadsheets2::testImportCellStyle() -{ -/** - in source file, imported sheet uses a cellstyle that does not exists in target - test that - - an imported cell D1 uses the right cellStyle - - the cellStyle is created in CellStyles family - - a property of the cellStyle (VertJustify) is correctly set -*/ - importSheetToCopy(); - - uno::Reference< table::XCell > xSrcCell = xSrcSheet->getCellByPosition(3,0); - uno::Reference< table::XCell > xDestCell = xDestSheet->getCellByPosition(3,0); - - //new style created in dest - uno::Reference< beans::XPropertySet > xSrcCellPropSet (xSrcCell, UNO_QUERY_THROW); - const rtl::OUString aCellProperty(RTL_CONSTASCII_USTRINGPARAM("CellStyle")); - rtl::OUString aSrcStyleName; - CPPUNIT_ASSERT(xSrcCellPropSet->getPropertyValue(aCellProperty) >>= aSrcStyleName); - - uno::Reference< beans::XPropertySet > xDestCellPropSet (xSrcCell, UNO_QUERY_THROW); - rtl::OUString aDestStyleName; - CPPUNIT_ASSERT(xDestCellPropSet->getPropertyValue(aCellProperty) >>= aDestStyleName); - - CPPUNIT_ASSERT_MESSAGE("Wrong imported Cell Style", aDestStyleName.equals(aSrcStyleName)); - - uno::Reference< style::XStyleFamiliesSupplier > xFamiliesSupplier (xDestDoc, UNO_QUERY_THROW); - uno::Reference< container::XNameAccess > xFamiliesNameAccess (xFamiliesSupplier->getStyleFamilies(), UNO_QUERY_THROW); - rtl::OUString aCellFamilyName(RTL_CONSTASCII_USTRINGPARAM("CellStyles")); - uno::Any xCellStylesFamily = xFamiliesNameAccess->getByName(aCellFamilyName); - uno::Reference< container::XNameContainer > xCellStylesFamilyNameAccess (xCellStylesFamily, UNO_QUERY_THROW); - - CPPUNIT_ASSERT_MESSAGE("New cell style not present", xCellStylesFamilyNameAccess->hasByName(aDestStyleName)); - - uno::Any aCellStyle = xCellStylesFamilyNameAccess->getByName(aDestStyleName); - uno::Reference< beans::XPropertySet > xCellStyleProp (aCellStyle, UNO_QUERY_THROW); - rtl::OUString aProperty(RTL_CONSTASCII_USTRINGPARAM("VertJustify")); - sal_Int32 aVertJustify = 0; - CPPUNIT_ASSERT(xCellStyleProp->getPropertyValue(aProperty) >>= aVertJustify); - - CPPUNIT_ASSERT_MESSAGE("New style: VertJustify not set", aVertJustify == table::CellVertJustify_CENTER); -} - -uno::Reference< sheet::XSpreadsheetDocument> ScXSpreadsheets2::getDoc(const rtl::OUString aFileBase, uno::Reference< lang::XComponent >& xComp) -{ - rtl::OUString aFileURL; - createFileURL(aFileBase, aFileURL); - - if (!xComp.is()) - xComp = loadFromDesktop(aFileURL); - - CPPUNIT_ASSERT(xComp.is()); - - uno::Reference< sheet::XSpreadsheetDocument > xDoc(xComp, UNO_QUERY_THROW); - CPPUNIT_ASSERT(xDoc.is()); - return xDoc; -} - -uno::Reference< sheet::XNamedRanges> ScXSpreadsheets2::getNamedRanges(uno::Reference< sheet::XSpreadsheetDocument> xDoc) -{ - uno::Reference< beans::XPropertySet > xPropSet (xDoc, UNO_QUERY_THROW); - rtl::OUString NamedRangesPropertyString(RTL_CONSTASCII_USTRINGPARAM("NamedRanges")); - uno::Reference< sheet::XNamedRanges > xNamedRanges(xPropSet->getPropertyValue(NamedRangesPropertyString), UNO_QUERY_THROW); - CPPUNIT_ASSERT(xNamedRanges.is()); - - return xNamedRanges; -} - -void ScXSpreadsheets2::importSheetToCopy() -{ - if (!bIsSheetImported) - { - xSrcDoc = getDoc(aSrcFileBase, xComponent); - CPPUNIT_ASSERT(xSrcDoc.is()); - xSrcNamedRangesNameAccess = uno::Reference< container::XNameAccess> (getNamedRanges(xSrcDoc), UNO_QUERY_THROW); - - uno::Reference< lang::XComponent > xDestComponent; - xDestDoc = getDoc(aDestFileBase, xDestComponent); - CPPUNIT_ASSERT(xDestDoc.is()); - xDestNamedRangesNameAccess = uno::Reference< container::XNameAccess > (getNamedRanges(xDestDoc), UNO_QUERY_THROW); - - // import sheet - uno::Reference< sheet::XSpreadsheets2 > xDestSheets (xDestDoc->getSheets(), UNO_QUERY_THROW); - nDestPosEffective = xDestSheets->importSheet(xSrcDoc, aSrcSheetName, nDestPos); - - uno::Reference< container::XNameAccess > xSrcSheetNameAccess (xSrcDoc->getSheets(), UNO_QUERY_THROW); - xSrcSheet = uno::Reference< sheet::XSpreadsheet > (xSrcSheetNameAccess->getByName(aSrcSheetName), UNO_QUERY_THROW); - - xDestSheetNameAccess = uno::Reference< container::XNameAccess > (xDestDoc->getSheets(), UNO_QUERY_THROW); - xDestSheet = uno::Reference< sheet::XSpreadsheet > ( xDestSheetNameAccess->getByName(aSrcSheetName), UNO_QUERY_THROW); - - bIsSheetImported = true; - } -} - -bool ScXSpreadsheets2::isExternalReference(rtl::OUString aDestContent, rtl::OUString aSrcContent ) -{ - rtl::OUString aStart(RTL_CONSTASCII_USTRINGPARAM("'file://")); - const sal_Char* sSrcContent = rtl::OUStringToOString( aSrcContent, RTL_TEXTENCODING_UTF8 ).getStr(); - - return (aDestContent.endsWithIgnoreAsciiCaseAsciiL(sSrcContent, aSrcContent.getLength()) // same cell address - && aDestContent.indexOf(aStart)==0 // starts with 'file:// - && aDestContent.indexOf(aSrcFileBase)>0); // contains source file name -} - -void ScXSpreadsheets2::setUp() -{ - nTest += 1; - UnoApiTest::setUp(); -} - -void ScXSpreadsheets2::tearDown() -{ - //closing the document fails ATM - if (nTest == NUMBER_OF_TESTS) - { - //uno::Reference< util::XCloseable > xCloseable(xComponent, UNO_QUERY_THROW); - //xCloseable->close( false ); - } - - UnoApiTest::tearDown(); - - if (nTest == NUMBER_OF_TESTS) - { - //mxDesktop->terminate(); - //uno::Reference< lang::XComponent>(m_xContext, UNO_QUERY_THROW)->dispose(); - } -} - -CPPUNIT_TEST_SUITE_REGISTRATION(ScXSpreadsheets2); - -CPPUNIT_PLUGIN_IMPLEMENT(); - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit