diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-07-30 21:18:46 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-07-31 10:04:09 +0200 |
commit | 6353c51e8bf66fe223080db649fc07e62a3a6c97 (patch) | |
tree | 111c6ea992efd848027e38cd8841eff8a2c64feb /sw | |
parent | 87f0e1f1016826cd63c2c740ae37e7242fb4c6a8 (diff) |
sw: introduce a Library_swqahelper
So it is no longer necessary to define all SwModelTestBase functions
inline.
Change-Id: Ia1055ff967b3614102275ec92607c85ec063fce7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99820
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw')
96 files changed, 1399 insertions, 758 deletions
diff --git a/sw/CppunitTest_sw_core_accessibilitycheck.mk b/sw/CppunitTest_sw_core_accessibilitycheck.mk index 3927603c400b..0d102842a6e1 100644 --- a/sw/CppunitTest_sw_core_accessibilitycheck.mk +++ b/sw/CppunitTest_sw_core_accessibilitycheck.mk @@ -25,6 +25,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_core_accessibilitycheck, \ svx \ sfx \ sw \ + swqahelper \ test \ unotest \ utl \ diff --git a/sw/CppunitTest_sw_core_crsr.mk b/sw/CppunitTest_sw_core_crsr.mk index 895b3ff63e57..9fa24a4ebc0e 100644 --- a/sw/CppunitTest_sw_core_crsr.mk +++ b/sw/CppunitTest_sw_core_crsr.mk @@ -25,6 +25,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_core_crsr, \ sfx \ svxcore \ sw \ + swqahelper \ test \ unotest \ utl \ diff --git a/sw/CppunitTest_sw_core_doc.mk b/sw/CppunitTest_sw_core_doc.mk index 856f007cb9b1..ba2555099e3b 100644 --- a/sw/CppunitTest_sw_core_doc.mk +++ b/sw/CppunitTest_sw_core_doc.mk @@ -25,6 +25,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_core_doc, \ sal \ sfx \ sw \ + swqahelper \ test \ unotest \ utl \ diff --git a/sw/CppunitTest_sw_core_frmedt.mk b/sw/CppunitTest_sw_core_frmedt.mk index 5f283bdadfba..9138002d97ca 100644 --- a/sw/CppunitTest_sw_core_frmedt.mk +++ b/sw/CppunitTest_sw_core_frmedt.mk @@ -25,6 +25,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_core_frmedt, \ sfx \ svxcore \ sw \ + swqahelper \ test \ unotest \ utl \ diff --git a/sw/CppunitTest_sw_core_layout.mk b/sw/CppunitTest_sw_core_layout.mk index 1801e66a713d..b875fd851053 100644 --- a/sw/CppunitTest_sw_core_layout.mk +++ b/sw/CppunitTest_sw_core_layout.mk @@ -24,6 +24,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_core_layout, \ sal \ sfx \ sw \ + swqahelper \ test \ unotest \ utl \ diff --git a/sw/CppunitTest_sw_core_objectpositioning.mk b/sw/CppunitTest_sw_core_objectpositioning.mk index e083c199d74c..d66cc9197602 100644 --- a/sw/CppunitTest_sw_core_objectpositioning.mk +++ b/sw/CppunitTest_sw_core_objectpositioning.mk @@ -25,6 +25,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_core_objectpositioning, \ sfx \ svxcore \ sw \ + swqahelper \ test \ unotest \ utl \ diff --git a/sw/CppunitTest_sw_core_text.mk b/sw/CppunitTest_sw_core_text.mk index cb901fde29f2..b0c4d03fac38 100644 --- a/sw/CppunitTest_sw_core_text.mk +++ b/sw/CppunitTest_sw_core_text.mk @@ -24,6 +24,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_core_text, \ sal \ sfx \ sw \ + swqahelper \ test \ unotest \ utl \ diff --git a/sw/CppunitTest_sw_core_txtnode.mk b/sw/CppunitTest_sw_core_txtnode.mk index 2f09165d86cb..54aa0865cce3 100644 --- a/sw/CppunitTest_sw_core_txtnode.mk +++ b/sw/CppunitTest_sw_core_txtnode.mk @@ -25,6 +25,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_core_txtnode, \ sfx \ svxcore \ sw \ + swqahelper \ test \ unotest \ utl \ diff --git a/sw/CppunitTest_sw_core_unocore.mk b/sw/CppunitTest_sw_core_unocore.mk index 6ff38dfc1890..568b10babfc4 100644 --- a/sw/CppunitTest_sw_core_unocore.mk +++ b/sw/CppunitTest_sw_core_unocore.mk @@ -31,6 +31,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_core_unocore, \ svt \ svxcore \ sw \ + swqahelper \ test \ unotest \ vcl \ diff --git a/sw/CppunitTest_sw_docbookexport.mk b/sw/CppunitTest_sw_docbookexport.mk index b22229501f9e..7c0f208a7993 100644 --- a/sw/CppunitTest_sw_docbookexport.mk +++ b/sw/CppunitTest_sw_docbookexport.mk @@ -25,6 +25,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_docbookexport, \ sal \ sfx \ sw \ + swqahelper \ test \ tl \ unotest \ diff --git a/sw/CppunitTest_sw_fodfexport.mk b/sw/CppunitTest_sw_fodfexport.mk index d64e58fc0bb0..0a07239fe12e 100644 --- a/sw/CppunitTest_sw_fodfexport.mk +++ b/sw/CppunitTest_sw_fodfexport.mk @@ -24,6 +24,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_fodfexport, \ sal \ sfx \ sw \ + swqahelper \ test \ tl \ unotest \ diff --git a/sw/CppunitTest_sw_globalfilter.mk b/sw/CppunitTest_sw_globalfilter.mk index 3baefd56cd80..dc5d00a76d43 100644 --- a/sw/CppunitTest_sw_globalfilter.mk +++ b/sw/CppunitTest_sw_globalfilter.mk @@ -25,6 +25,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_globalfilter, \ sfx \ svt \ sw \ + swqahelper \ test \ tl \ unotest \ diff --git a/sw/CppunitTest_sw_htmlexport.mk b/sw/CppunitTest_sw_htmlexport.mk index 3315566bb087..5941e906889f 100644 --- a/sw/CppunitTest_sw_htmlexport.mk +++ b/sw/CppunitTest_sw_htmlexport.mk @@ -27,6 +27,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_htmlexport, \ sfx \ sot \ sw \ + swqahelper \ svl \ svt \ test \ diff --git a/sw/CppunitTest_sw_htmlimport.mk b/sw/CppunitTest_sw_htmlimport.mk index 61e33f10e4fc..5843f2fae398 100644 --- a/sw/CppunitTest_sw_htmlimport.mk +++ b/sw/CppunitTest_sw_htmlimport.mk @@ -28,6 +28,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_htmlimport, \ svl \ svt \ sw \ + swqahelper \ test \ tl \ unotest \ diff --git a/sw/CppunitTest_sw_layoutwriter.mk b/sw/CppunitTest_sw_layoutwriter.mk index 481402fe0bf2..a7e88dbf91c8 100644 --- a/sw/CppunitTest_sw_layoutwriter.mk +++ b/sw/CppunitTest_sw_layoutwriter.mk @@ -31,6 +31,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_layoutwriter, \ svt \ svxcore \ sw \ + swqahelper \ test \ unotest \ vcl \ diff --git a/sw/CppunitTest_sw_mailmerge.mk b/sw/CppunitTest_sw_mailmerge.mk index 8768ece34f28..efc7f77aa522 100644 --- a/sw/CppunitTest_sw_mailmerge.mk +++ b/sw/CppunitTest_sw_mailmerge.mk @@ -23,6 +23,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_mailmerge, \ sfx \ svl \ sw \ + swqahelper \ test \ tl \ unotest \ diff --git a/sw/CppunitTest_sw_odfexport.mk b/sw/CppunitTest_sw_odfexport.mk index ff603b76e2f1..bd8c0cc4581f 100644 --- a/sw/CppunitTest_sw_odfexport.mk +++ b/sw/CppunitTest_sw_odfexport.mk @@ -25,6 +25,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_odfexport, \ sfx \ svl \ sw \ + swqahelper \ test \ tl \ unotest \ diff --git a/sw/CppunitTest_sw_odfimport.mk b/sw/CppunitTest_sw_odfimport.mk index a99026e971fc..61a1547dd473 100644 --- a/sw/CppunitTest_sw_odfimport.mk +++ b/sw/CppunitTest_sw_odfimport.mk @@ -25,6 +25,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_odfimport, \ svt \ sfx \ sw \ + swqahelper \ test \ unotest \ vcl \ diff --git a/sw/CppunitTest_sw_ooxmlexport8.mk b/sw/CppunitTest_sw_ooxmlexport8.mk index d5344cb1b78e..68d9621b647d 100644 --- a/sw/CppunitTest_sw_ooxmlexport8.mk +++ b/sw/CppunitTest_sw_ooxmlexport8.mk @@ -30,6 +30,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_ooxmlexport8, \ utl \ sfx \ sw \ + swqahelper \ tl \ vcl \ svxcore \ diff --git a/sw/CppunitTest_sw_ooxmlimport.mk b/sw/CppunitTest_sw_ooxmlimport.mk index c6d111e5acc9..f4273f909e18 100644 --- a/sw/CppunitTest_sw_ooxmlimport.mk +++ b/sw/CppunitTest_sw_ooxmlimport.mk @@ -30,6 +30,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_ooxmlimport, \ unotest \ utl \ sw \ + swqahelper \ tl \ vcl \ svxcore \ diff --git a/sw/CppunitTest_sw_ooxmlimport2.mk b/sw/CppunitTest_sw_ooxmlimport2.mk index f47d7e35830b..97fc1e7b1e6d 100644 --- a/sw/CppunitTest_sw_ooxmlimport2.mk +++ b/sw/CppunitTest_sw_ooxmlimport2.mk @@ -30,6 +30,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_ooxmlimport2, \ unotest \ utl \ sw \ + swqahelper \ tl \ vcl \ svxcore \ diff --git a/sw/CppunitTest_sw_rtfexport.mk b/sw/CppunitTest_sw_rtfexport.mk index f2d62dc0b70a..f8ca21aa1f47 100644 --- a/sw/CppunitTest_sw_rtfexport.mk +++ b/sw/CppunitTest_sw_rtfexport.mk @@ -24,6 +24,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_rtfexport, \ sal \ sfx \ sw \ + swqahelper \ test \ unotest \ utl \ diff --git a/sw/CppunitTest_sw_rtfexport2.mk b/sw/CppunitTest_sw_rtfexport2.mk index b771af3f9abd..d507d4e50287 100644 --- a/sw/CppunitTest_sw_rtfexport2.mk +++ b/sw/CppunitTest_sw_rtfexport2.mk @@ -25,6 +25,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_rtfexport2, \ sal \ sfx \ sw \ + swqahelper \ test \ unotest \ utl \ diff --git a/sw/CppunitTest_sw_rtfexport3.mk b/sw/CppunitTest_sw_rtfexport3.mk index b447fad21a10..377defd2a197 100644 --- a/sw/CppunitTest_sw_rtfexport3.mk +++ b/sw/CppunitTest_sw_rtfexport3.mk @@ -24,6 +24,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_rtfexport3, \ sal \ sfx \ sw \ + swqahelper \ test \ unotest \ utl \ diff --git a/sw/CppunitTest_sw_rtfexport4.mk b/sw/CppunitTest_sw_rtfexport4.mk index 4d35bcb718a2..0c39ff4834e9 100644 --- a/sw/CppunitTest_sw_rtfexport4.mk +++ b/sw/CppunitTest_sw_rtfexport4.mk @@ -25,6 +25,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_rtfexport4, \ svl \ sfx \ sw \ + swqahelper \ test \ unotest \ utl \ diff --git a/sw/CppunitTest_sw_rtfexport5.mk b/sw/CppunitTest_sw_rtfexport5.mk index af0d2a90666c..67a69accb9a1 100644 --- a/sw/CppunitTest_sw_rtfexport5.mk +++ b/sw/CppunitTest_sw_rtfexport5.mk @@ -25,6 +25,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_rtfexport5, \ sal \ sfx \ sw \ + swqahelper \ test \ unotest \ utl \ diff --git a/sw/CppunitTest_sw_rtfimport.mk b/sw/CppunitTest_sw_rtfimport.mk index 3732ed9eb845..5934885405ef 100644 --- a/sw/CppunitTest_sw_rtfimport.mk +++ b/sw/CppunitTest_sw_rtfimport.mk @@ -25,6 +25,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_rtfimport, \ sfx \ i18nlangtag \ sw \ + swqahelper \ test \ unotest \ vcl \ diff --git a/sw/CppunitTest_sw_tiledrendering.mk b/sw/CppunitTest_sw_tiledrendering.mk index b1c333a1692e..8697cbf11209 100644 --- a/sw/CppunitTest_sw_tiledrendering.mk +++ b/sw/CppunitTest_sw_tiledrendering.mk @@ -28,6 +28,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_tiledrendering, \ svt \ svxcore \ sw \ + swqahelper \ test \ unotest \ vcl \ diff --git a/sw/CppunitTest_sw_txtexport.mk b/sw/CppunitTest_sw_txtexport.mk index 2f4940f59e92..2eae07fd2a35 100644 --- a/sw/CppunitTest_sw_txtexport.mk +++ b/sw/CppunitTest_sw_txtexport.mk @@ -25,6 +25,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_txtexport, \ sal \ sfx \ sw \ + swqahelper \ test \ tl \ unotest \ diff --git a/sw/CppunitTest_sw_uibase_dochdl.mk b/sw/CppunitTest_sw_uibase_dochdl.mk index 14cf57687a8f..36494c0e7a8c 100644 --- a/sw/CppunitTest_sw_uibase_dochdl.mk +++ b/sw/CppunitTest_sw_uibase_dochdl.mk @@ -28,6 +28,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_uibase_dochdl, \ svx \ svxcore \ sw \ + swqahelper \ test \ unotest \ utl \ diff --git a/sw/CppunitTest_sw_uibase_frmdlg.mk b/sw/CppunitTest_sw_uibase_frmdlg.mk index 5c2b8b7283b7..5225def8fc2f 100644 --- a/sw/CppunitTest_sw_uibase_frmdlg.mk +++ b/sw/CppunitTest_sw_uibase_frmdlg.mk @@ -28,6 +28,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_uibase_frmdlg, \ svx \ svxcore \ sw \ + swqahelper \ test \ unotest \ utl \ diff --git a/sw/CppunitTest_sw_uibase_shells.mk b/sw/CppunitTest_sw_uibase_shells.mk index 9734b395bca6..44901cc56d85 100644 --- a/sw/CppunitTest_sw_uibase_shells.mk +++ b/sw/CppunitTest_sw_uibase_shells.mk @@ -28,6 +28,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_uibase_shells, \ svx \ svxcore \ sw \ + swqahelper \ test \ unotest \ utl \ diff --git a/sw/CppunitTest_sw_uiwriter.mk b/sw/CppunitTest_sw_uiwriter.mk index 85ea9337c1d4..ed29b2cdaed6 100644 --- a/sw/CppunitTest_sw_uiwriter.mk +++ b/sw/CppunitTest_sw_uiwriter.mk @@ -34,6 +34,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_uiwriter, \ svt \ svxcore \ sw \ + swqahelper \ test \ unotest \ vcl \ diff --git a/sw/CppunitTest_sw_unowriter.mk b/sw/CppunitTest_sw_unowriter.mk index 3c49c49c9236..e71456088a58 100644 --- a/sw/CppunitTest_sw_unowriter.mk +++ b/sw/CppunitTest_sw_unowriter.mk @@ -31,6 +31,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_unowriter, \ svt \ svxcore \ sw \ + swqahelper \ test \ unotest \ vcl \ diff --git a/sw/CppunitTest_sw_ww8export.mk b/sw/CppunitTest_sw_ww8export.mk index 506aa2ae7080..0d79d53d9d57 100644 --- a/sw/CppunitTest_sw_ww8export.mk +++ b/sw/CppunitTest_sw_ww8export.mk @@ -29,6 +29,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_ww8export, \ sfx \ svl \ sw \ + swqahelper \ tl \ )) diff --git a/sw/CppunitTest_sw_ww8export2.mk b/sw/CppunitTest_sw_ww8export2.mk index a70f63f0deb1..a6ecae976280 100644 --- a/sw/CppunitTest_sw_ww8export2.mk +++ b/sw/CppunitTest_sw_ww8export2.mk @@ -29,6 +29,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_ww8export2, \ unotest \ utl \ sw \ + swqahelper \ tl \ svxcore \ )) diff --git a/sw/CppunitTest_sw_ww8export3.mk b/sw/CppunitTest_sw_ww8export3.mk index fd30e423de99..a0b3e3837f5a 100644 --- a/sw/CppunitTest_sw_ww8export3.mk +++ b/sw/CppunitTest_sw_ww8export3.mk @@ -29,6 +29,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_ww8export3, \ unotest \ utl \ sw \ + swqahelper \ tl \ )) diff --git a/sw/CppunitTest_sw_ww8import.mk b/sw/CppunitTest_sw_ww8import.mk index 6b248fb5f926..3fddcd5cb9c8 100644 --- a/sw/CppunitTest_sw_ww8import.mk +++ b/sw/CppunitTest_sw_ww8import.mk @@ -29,6 +29,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_ww8import, \ sfx \ svl \ sw \ + swqahelper \ tl \ utl \ )) diff --git a/sw/CppunitTest_sw_xhtmlexport.mk b/sw/CppunitTest_sw_xhtmlexport.mk index 70c3af41d6d8..16aa42c71569 100644 --- a/sw/CppunitTest_sw_xhtmlexport.mk +++ b/sw/CppunitTest_sw_xhtmlexport.mk @@ -25,6 +25,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_xhtmlexport, \ sal \ sfx \ sw \ + swqahelper \ test \ tl \ unotest \ diff --git a/sw/Library_swqahelper.mk b/sw/Library_swqahelper.mk new file mode 100644 index 000000000000..6c089e63cf60 --- /dev/null +++ b/sw/Library_swqahelper.mk @@ -0,0 +1,62 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Library_Library,swqahelper)) + +$(eval $(call gb_Library_set_include,swqahelper,\ + -I$(SRCDIR)/sw/inc \ + -I$(SRCDIR)/sw/source/core/inc \ + -I$(SRCDIR)/sw/qa/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_Library_use_externals,swqahelper, \ + boost_headers \ + cppunit \ + libxml2 \ +)) + +$(eval $(call gb_Library_add_defs,swqahelper,\ + -DSWQAHELPER_DLLIMPLEMENTATION \ +)) + +$(eval $(call gb_Library_use_api,swqahelper,\ + udkapi \ + offapi \ + oovbaapi \ +)) + +$(eval $(call gb_Library_use_libraries,swqahelper,\ + comphelper \ + cppu \ + cppuhelper \ + editeng \ + for \ + sal \ + sw \ + sfx \ + sot \ + svl \ + svt \ + svx \ + svxcore \ + test \ + tl \ + unotest \ + utl \ + ucbhelper \ + unotest \ + vcl \ +)) + +$(eval $(call gb_Library_add_exception_objects,swqahelper,\ + sw/qa/unit/swmodeltestbase \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk index 1dd4f34cc61f..66d27573ec98 100644 --- a/sw/Module_sw.mk +++ b/sw/Module_sw.mk @@ -49,6 +49,7 @@ endif ifneq ($(OS),iOS) $(eval $(call gb_Module_add_check_targets,sw,\ + Library_swqahelper \ CppunitTest_sw_uibase_unit \ )) diff --git a/sw/ooxmlexport_setup.mk b/sw/ooxmlexport_setup.mk index a367bbc05ce6..85763f591b43 100644 --- a/sw/ooxmlexport_setup.mk +++ b/sw/ooxmlexport_setup.mk @@ -18,6 +18,7 @@ define sw_ooxmlexport_libraries sfx \ svl \ sw \ + swqahelper \ test \ tl \ unotest \ diff --git a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx index 61902aabc459..40cf5d905bac 100644 --- a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx +++ b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx @@ -10,6 +10,8 @@ #include <swmodeltestbase.hxx> #include <wrtsh.hxx> #include <AccessibilityCheck.hxx> +#include <unotxdoc.hxx> +#include <docsh.hxx> class AccessibilityCheckTest : public SwModelTestBase { diff --git a/sw/qa/core/crsr/crsr.cxx b/sw/qa/core/crsr/crsr.cxx index 9345fdde6dd6..6c503e81cb90 100644 --- a/sw/qa/core/crsr/crsr.cxx +++ b/sw/qa/core/crsr/crsr.cxx @@ -12,6 +12,9 @@ #include <com/sun/star/awt/FontWeight.hpp> #include <com/sun/star/text/ControlCharacter.hpp> #include <com/sun/star/view/XLineCursor.hpp> +#include <com/sun/star/text/XTextDocument.hpp> +#include <com/sun/star/text/XTextViewCursorSupplier.hpp> +#include <com/sun/star/text/XTextViewCursor.hpp> #include <comphelper/propertysequence.hxx> #include <svl/srchitem.hxx> diff --git a/sw/qa/core/doc/doc.cxx b/sw/qa/core/doc/doc.cxx index 4c0afbd538cd..b2c3ec7e7bdf 100644 --- a/sw/qa/core/doc/doc.cxx +++ b/sw/qa/core/doc/doc.cxx @@ -18,6 +18,7 @@ #include <wrtsh.hxx> #include <fmtanchr.hxx> #include <frameformats.hxx> +#include <docsh.hxx> char const DATA_DIRECTORY[] = "/sw/qa/core/doc/data/"; diff --git a/sw/qa/core/frmedt/frmedt.cxx b/sw/qa/core/frmedt/frmedt.cxx index f661db647644..b4074a73e12d 100644 --- a/sw/qa/core/frmedt/frmedt.cxx +++ b/sw/qa/core/frmedt/frmedt.cxx @@ -10,6 +10,7 @@ #include <swmodeltestbase.hxx> #include <com/sun/star/text/VertOrientation.hpp> +#include <com/sun/star/drawing/XDrawPageSupplier.hpp> #include <svx/svdpage.hxx> @@ -19,6 +20,8 @@ #include <drawdoc.hxx> #include <dcontact.hxx> #include <frameformats.hxx> +#include <unotxdoc.hxx> +#include <docsh.hxx> char const DATA_DIRECTORY[] = "/sw/qa/core/frmedt/data/"; diff --git a/sw/qa/core/layout/layout.cxx b/sw/qa/core/layout/layout.cxx index 44a7edf5c213..8decbdf8e98c 100644 --- a/sw/qa/core/layout/layout.cxx +++ b/sw/qa/core/layout/layout.cxx @@ -12,6 +12,8 @@ #include <vcl/gdimtf.hxx> #include <wrtsh.hxx> +#include <docsh.hxx> +#include <unotxdoc.hxx> char const DATA_DIRECTORY[] = "/sw/qa/core/layout/data/"; diff --git a/sw/qa/core/objectpositioning/objectpositioning.cxx b/sw/qa/core/objectpositioning/objectpositioning.cxx index 52a09642b86a..edd4d2bdcab7 100644 --- a/sw/qa/core/objectpositioning/objectpositioning.cxx +++ b/sw/qa/core/objectpositioning/objectpositioning.cxx @@ -10,8 +10,11 @@ #include <swmodeltestbase.hxx> #include <com/sun/star/text/VertOrientation.hpp> +#include <com/sun/star/drawing/XDrawPageSupplier.hpp> #include <wrtsh.hxx> +#include <unotxdoc.hxx> +#include <docsh.hxx> char const DATA_DIRECTORY[] = "/sw/qa/core/objectpositioning/data/"; diff --git a/sw/qa/core/text/text.cxx b/sw/qa/core/text/text.cxx index 32debf5091db..6122bab09911 100644 --- a/sw/qa/core/text/text.cxx +++ b/sw/qa/core/text/text.cxx @@ -11,6 +11,8 @@ #include <vcl/gdimtf.hxx> +#include <docsh.hxx> +#include <unotxdoc.hxx> #include <wrtsh.hxx> char const DATA_DIRECTORY[] = "/sw/qa/core/text/data/"; diff --git a/sw/qa/core/txtnode/txtnode.cxx b/sw/qa/core/txtnode/txtnode.cxx index c13e75f691c2..217c32f51f5f 100644 --- a/sw/qa/core/txtnode/txtnode.cxx +++ b/sw/qa/core/txtnode/txtnode.cxx @@ -14,6 +14,8 @@ #include <fmtanchr.hxx> #include <frameformats.hxx> #include <wrtsh.hxx> +#include <unotxdoc.hxx> +#include <docsh.hxx> char const DATA_DIRECTORY[] = "/sw/qa/core/txtnode/data/"; diff --git a/sw/qa/core/unocore/unocore.cxx b/sw/qa/core/unocore/unocore.cxx index 38a700463846..a831dd5a0e27 100644 --- a/sw/qa/core/unocore/unocore.cxx +++ b/sw/qa/core/unocore/unocore.cxx @@ -14,6 +14,8 @@ #include <wrtsh.hxx> #include <unotextrange.hxx> +#include <unotxdoc.hxx> +#include <docsh.hxx> using namespace ::com::sun::star; diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx index 5b3e84ace854..ed20dd790e1b 100644 --- a/sw/qa/extras/globalfilter/globalfilter.cxx +++ b/sw/qa/extras/globalfilter/globalfilter.cxx @@ -33,6 +33,7 @@ #include <IDocumentMarkAccess.hxx> #include <IMark.hxx> #include <com/sun/star/awt/FontWeight.hpp> +#include <unotools/mediadescriptor.hxx> class Test : public SwModelTestBase { diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx index ec08d491e64f..c6136e807bc9 100644 --- a/sw/qa/extras/htmlexport/htmlexport.cxx +++ b/sw/qa/extras/htmlexport/htmlexport.cxx @@ -7,9 +7,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include <memory> #include <swmodeltestbase.hxx> +#include <memory> + #include <com/sun/star/document/XEmbeddedObjectSupplier2.hpp> #include <com/sun/star/embed/ElementModes.hpp> #include <com/sun/star/io/XActiveDataStreamer.hpp> @@ -18,14 +19,12 @@ #include <com/sun/star/frame/DispatchHelper.hpp> #include <com/sun/star/style/ParagraphAdjust.hpp> #include <com/sun/star/awt/FontUnderline.hpp> - -#include <svtools/htmlcfg.hxx> -#include <swmodule.hxx> -#include <swdll.hxx> -#include <usrpref.hxx> -#include <wrtsh.hxx> -#include <ndtxt.hxx> -#include <paratr.hxx> +#include <com/sun/star/text/XTextTablesSupplier.hpp> +#include <com/sun/star/text/XTextTable.hpp> +#include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp> +#include <com/sun/star/document/XStorageBasedDocument.hpp> +#include <com/sun/star/frame/XStorable.hpp> +#include <com/sun/star/packages/zip/ZipFileAccess.hpp> #include <test/htmltesttools.hxx> #include <tools/urlobj.hxx> @@ -38,6 +37,20 @@ #include <filter/msfilter/rtfutil.hxx> #include <sot/storage.hxx> #include <svl/eitem.hxx> +#include <vcl/svapp.hxx> +#include <unotools/mediadescriptor.hxx> +#include <svtools/htmlcfg.hxx> +#include <unotools/ucbstreamhelper.hxx> +#include <comphelper/processfactory.hxx> + +#include <swmodule.hxx> +#include <swdll.hxx> +#include <usrpref.hxx> +#include <wrtsh.hxx> +#include <ndtxt.hxx> +#include <paratr.hxx> +#include <docsh.hxx> +#include <unotxdoc.hxx> class HtmlExportTest : public SwModelTestBase, public HtmlTestTools { diff --git a/sw/qa/extras/htmlimport/htmlimport.cxx b/sw/qa/extras/htmlimport/htmlimport.cxx index 7f5486dad321..45260d167011 100644 --- a/sw/qa/extras/htmlimport/htmlimport.cxx +++ b/sw/qa/extras/htmlimport/htmlimport.cxx @@ -14,7 +14,10 @@ #include <com/sun/star/drawing/FillStyle.hpp> #include <com/sun/star/drawing/BitmapMode.hpp> #include <com/sun/star/document/XEmbeddedObjectSupplier2.hpp> +#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> #include <com/sun/star/embed/XInplaceObject.hpp> +#include <com/sun/star/text/XTextTable.hpp> + #include <tools/datetime.hxx> #include <sfx2/linkmgr.hxx> #include <comphelper/propertyvalue.hxx> @@ -27,6 +30,7 @@ #include <fmtflcnt.hxx> #include <fmtfsize.hxx> #include <frameformats.hxx> +#include <unotxdoc.hxx> class HtmlImportTest : public SwModelTestBase { diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index 6d719976579c..28e4bd568c22 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -21,6 +21,8 @@ #include <editeng/fhgtitem.hxx> #include <editeng/postitem.hxx> #include <editeng/unolingu.hxx> +#include <comphelper/sequence.hxx> + #include <fmtanchr.hxx> #include <fmtfsize.hxx> #include <fmtcntnt.hxx> @@ -36,6 +38,10 @@ #include <frmatr.hxx> #include <IDocumentSettingAccess.hxx> #include <config_features.h> +#include <unotxdoc.hxx> +#include <rootfrm.hxx> +#include <docsh.hxx> +#include <IDocumentLayoutAccess.hxx> char const DATA_DIRECTORY[] = "/sw/qa/extras/layout/data/"; diff --git a/sw/qa/extras/mailmerge/mailmerge.cxx b/sw/qa/extras/mailmerge/mailmerge.cxx index a4f5e0bbeffa..17d92d3789ac 100644 --- a/sw/qa/extras/mailmerge/mailmerge.cxx +++ b/sw/qa/extras/mailmerge/mailmerge.cxx @@ -23,12 +23,17 @@ #include <tools/urlobj.hxx> #include <unotools/localfilehelper.hxx> +#include <comphelper/sequence.hxx> #include <wrtsh.hxx> #include <ndtxt.hxx> #include <pagefrm.hxx> #include <unoprnms.hxx> #include <dbmgr.hxx> +#include <unotxdoc.hxx> +#include <docsh.hxx> +#include <IDocumentLayoutAccess.hxx> +#include <rootfrm.hxx> /** * Maps database URIs to the registered database names for quick lookups diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index 04d9729dcfa4..443492c4b42b 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -32,17 +32,34 @@ #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp> #include <com/sun/star/text/XTextField.hpp> #include <com/sun/star/text/WritingMode2.hpp> +#include <com/sun/star/util/XModifiable.hpp> +#include <com/sun/star/text/XTextFieldsSupplier.hpp> +#include <com/sun/star/container/XIndexContainer.hpp> +#include <com/sun/star/document/XStorageBasedDocument.hpp> +#include <com/sun/star/text/XTextFramesSupplier.hpp> +#include <com/sun/star/text/XDocumentIndexesSupplier.hpp> +#include <com/sun/star/text/XTextDocument.hpp> +#include <com/sun/star/util/XRefreshable.hpp> +#include <com/sun/star/container/XContentEnumerationAccess.hpp> +#include <com/sun/star/text/XTextTable.hpp> + #include <comphelper/storagehelper.hxx> #include <comphelper/fileformat.h> #include <comphelper/propertysequence.hxx> #include <unotools/streamwrap.hxx> #include <svl/PasswordHelper.hxx> +#include <comphelper/sequenceashashmap.hxx> + #include <docufld.hxx> // for SwHiddenTextField::ParseIfFieldDefinition() method call #include <unoprnms.hxx> #include <sortedobjs.hxx> #include <flyfrm.hxx> #include <ftnidx.hxx> #include <txtftn.hxx> +#include <unotxdoc.hxx> +#include <docsh.hxx> +#include <IDocumentLayoutAccess.hxx> +#include <rootfrm.hxx> class Test : public SwModelTestBase { diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx index 70d5a158b22c..5f7ccd68db4f 100644 --- a/sw/qa/extras/odfimport/odfimport.cxx +++ b/sw/qa/extras/odfimport/odfimport.cxx @@ -33,6 +33,13 @@ #include <com/sun/star/util/XNumberFormatTypes.hpp> #include <com/sun/star/util/XNumberFormatsSupplier.hpp> #include <com/sun/star/lang/Locale.hpp> +#include <com/sun/star/text/XTextFieldsSupplier.hpp> +#include <com/sun/star/util/XRefreshable.hpp> +#include <com/sun/star/text/XTextDocument.hpp> +#include <com/sun/star/drawing/XDrawPageSupplier.hpp> +#include <com/sun/star/container/XIndexContainer.hpp> +#include <com/sun/star/drawing/XDrawPage.hpp> +#include <com/sun/star/text/XTextFramesSupplier.hpp> #include <IDocumentSettingAccess.hxx> #include <wrtsh.hxx> @@ -42,6 +49,8 @@ #include <edtwin.hxx> #include <olmenu.hxx> #include <hintids.hxx> +#include <docsh.hxx> +#include <unotxdoc.hxx> typedef std::map<OUString, css::uno::Sequence< css::table::BorderLine> > AllBordersMap; typedef std::pair<OUString, css::uno::Sequence< css::table::BorderLine> > StringSequencePair; diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 27a361484e28..edb377403043 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -19,8 +19,18 @@ #include <com/sun/star/text/XTextRangeCompare.hpp> #include <com/sun/star/text/WritingMode2.hpp> #include <com/sun/star/text/TableColumnSeparator.hpp> +#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> +#include <com/sun/star/frame/XStorable.hpp> +#include <com/sun/star/text/XTextTablesSupplier.hpp> +#include <com/sun/star/text/XTextTable.hpp> +#include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp> +#include <com/sun/star/text/XTextFieldsSupplier.hpp> +#include <com/sun/star/packages/zip/ZipFileAccess.hpp> + #include <o3tl/cppunittraitshelper.hxx> #include <oox/drawingml/drawingmltypes.hxx> +#include <comphelper/sequenceashashmap.hxx> +#include <comphelper/processfactory.hxx> class Test : public SwModelTestBase { diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx index 259ac71cd4c7..26fab6d03426 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx @@ -43,15 +43,29 @@ #include <com/sun/star/style/CaseMap.hpp> #include <com/sun/star/document/XFilter.hpp> #include <com/sun/star/document/XImporter.hpp> +#include <com/sun/star/text/XTextTablesSupplier.hpp> +#include <com/sun/star/text/XTextTable.hpp> +#include <com/sun/star/table/XTableRows.hpp> +#include <com/sun/star/text/XFootnotesSupplier.hpp> +#include <com/sun/star/text/XTextDocument.hpp> +#include <com/sun/star/text/XDocumentIndexesSupplier.hpp> +#include <com/sun/star/util/XModifiable.hpp> +#include <com/sun/star/text/XEndnotesSupplier.hpp> +#include <com/sun/star/beans/XPropertyState.hpp> + #include <unotools/fltrcfg.hxx> #include <comphelper/sequenceashashmap.hxx> -#include <swtypes.hxx> -#include <drawdoc.hxx> -#include <IDocumentDrawModelAccess.hxx> #include <oox/drawingml/drawingmltypes.hxx> #include <unotools/streamwrap.hxx> #include <comphelper/propertysequence.hxx> #include <svx/svdpage.hxx> +#include <unotools/ucbstreamhelper.hxx> + +#include <swtypes.hxx> +#include <drawdoc.hxx> +#include <IDocumentDrawModelAccess.hxx> +#include <unotxdoc.hxx> +#include <docsh.hxx> class Test : public SwModelTestBase { diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx index 096e23d3fa3f..bc80088f7a94 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx @@ -20,6 +20,18 @@ #include <com/sun/star/text/RubyPosition.hpp> #include <com/sun/star/text/XDocumentIndex.hpp> #include <com/sun/star/drawing/FillStyle.hpp> +#include <com/sun/star/text/XTextTablesSupplier.hpp> +#include <com/sun/star/text/XTextTable.hpp> +#include <com/sun/star/style/TabStop.hpp> +#include <com/sun/star/text/XTextDocument.hpp> +#include <com/sun/star/text/XDocumentIndexesSupplier.hpp> +#include <com/sun/star/packages/zip/ZipFileAccess.hpp> + +#include <comphelper/processfactory.hxx> +#include <comphelper/sequenceashashmap.hxx> + +#include <unotxdoc.hxx> +#include <docsh.hxx> class Test : public SwModelTestBase { diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx index fd0976601c44..739362d71c4c 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx @@ -16,6 +16,9 @@ #include <com/sun/star/text/XBookmarksSupplier.hpp> #include <com/sun/star/text/XFormField.hpp> #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp> +#include <com/sun/star/text/XTextFieldsSupplier.hpp> +#include <com/sun/star/text/XTextDocument.hpp> +#include <com/sun/star/document/XViewDataSupplier.hpp> class Test : public SwModelTestBase { diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx index e59c3ded1524..b0cce67a1b9c 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx @@ -16,14 +16,20 @@ #include <com/sun/star/text/XTextFrame.hpp> #include <com/sun/star/drawing/XControlShape.hpp> #include <com/sun/star/style/ParagraphAdjust.hpp> +#include <com/sun/star/text/XTextSectionsSupplier.hpp> +#include <com/sun/star/text/XTextTable.hpp> + #include <editeng/escapementitem.hxx> #include <editeng/frmdiritem.hxx> #include <IDocumentSettingAccess.hxx> #include <xmloff/odffields.hxx> +#include <comphelper/sequenceashashmap.hxx> #include <editsh.hxx> #include <frmatr.hxx> #include <frameformats.hxx> +#include <unotxdoc.hxx> +#include <docsh.hxx> class Test : public SwModelTestBase { diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx index 47fa3b72a8db..899e2646438b 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx @@ -10,22 +10,35 @@ #include <swmodeltestbase.hxx> #include <com/sun/star/awt/FontUnderline.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <IDocumentSettingAccess.hxx> - -#include <editsh.hxx> -#include <frmatr.hxx> -#include <tools/lineend.hxx> -#include <oox/drawingml/drawingmltypes.hxx> -#include <com/sun/star/table/ShadowFormat.hpp> -#include <com/sun/star/text/TableColumnSeparator.hpp> -#include <com/sun/star/text/XDocumentIndex.hpp> -#include <com/sun/star/text/RelOrientation.hpp> #include <com/sun/star/awt/FontWeight.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/frame/XStorable.hpp> #include <com/sun/star/style/LineSpacing.hpp> #include <com/sun/star/style/LineSpacingMode.hpp> +#include <com/sun/star/style/ParagraphAdjust.hpp> +#include <com/sun/star/table/ShadowFormat.hpp> +#include <com/sun/star/table/XTableRows.hpp> +#include <com/sun/star/text/RelOrientation.hpp> +#include <com/sun/star/text/TableColumnSeparator.hpp> #include <com/sun/star/text/XDependentTextField.hpp> +#include <com/sun/star/text/XDocumentIndex.hpp> +#include <com/sun/star/text/XDocumentIndexesSupplier.hpp> +#include <com/sun/star/text/XFootnotesSupplier.hpp> #include <com/sun/star/text/XTextContentAppend.hpp> +#include <com/sun/star/text/XTextDocument.hpp> +#include <com/sun/star/text/XTextFieldsSupplier.hpp> +#include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp> +#include <com/sun/star/text/XTextTable.hpp> +#include <com/sun/star/text/XTextTablesSupplier.hpp> + +#include <comphelper/sequenceashashmap.hxx> +#include <oox/drawingml/drawingmltypes.hxx> +#include <tools/lineend.hxx> +#include <unotools/mediadescriptor.hxx> + +#include <IDocumentSettingAccess.hxx> +#include <editsh.hxx> +#include <frmatr.hxx> char const DATA_DIRECTORY[] = "/sw/qa/extras/ooxmlexport/data/"; diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx index 6c6dca1e70ed..7d83cadf520e 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx @@ -11,6 +11,10 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/text/RelOrientation.hpp> +#include <com/sun/star/text/XTextViewCursorSupplier.hpp> +#include <com/sun/star/text/XPageCursor.hpp> +#include <com/sun/star/text/XTextTable.hpp> +#include <com/sun/star/text/XTextTablesSupplier.hpp> char const DATA_DIRECTORY[] = "/sw/qa/extras/ooxmlexport/data/"; diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx index 1676fa8c09e5..7c215c5c67fa 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx @@ -9,6 +9,8 @@ #include <swmodeltestbase.hxx> +#include <string> + #include <com/sun/star/awt/XBitmap.hpp> #include <com/sun/star/drawing/FillStyle.hpp> #include <com/sun/star/drawing/LineStyle.hpp> @@ -23,12 +25,15 @@ #include <com/sun/star/style/LineSpacingMode.hpp> #include <com/sun/star/table/BorderLine2.hpp> #include <com/sun/star/table/ShadowFormat.hpp> -//#include <com/sun/star/awt/FontWeight.hpp> // keep for testTableStylerPrSz #include <com/sun/star/text/WritingMode2.hpp> #include <com/sun/star/text/WrapTextMode.hpp> -#include <oox/drawingml/drawingmltypes.hxx> +#include <com/sun/star/text/XTextDocument.hpp> +#include <com/sun/star/text/XTextTablesSupplier.hpp> +#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> +#include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp> +#include <com/sun/star/text/XTextFieldsSupplier.hpp> -#include <string> +#include <oox/drawingml/drawingmltypes.hxx> class Test : public SwModelTestBase { diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx index cedff600d3e4..d3558b59e6e8 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx @@ -22,7 +22,10 @@ #include <com/sun/star/text/WritingMode2.hpp> #include <com/sun/star/xml/dom/XDocument.hpp> #include <com/sun/star/style/BreakType.hpp> + #include <ftninfo.hxx> +#include <docsh.hxx> +#include <unotxdoc.hxx> class Test : public SwModelTestBase { diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx index 0c20e7d9815a..953a2434ba3f 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx @@ -21,11 +21,17 @@ #include <com/sun/star/table/BorderLine2.hpp> #include <com/sun/star/text/XPageCursor.hpp> #include <com/sun/star/util/Date.hpp> -#include <unotools/tempfile.hxx> +#include <com/sun/star/drawing/XShapes.hpp> +#include <com/sun/star/drawing/XDrawPageSupplier.hpp> +#include <com/sun/star/packages/zip/ZipFileAccess.hpp> +#include <com/sun/star/text/XTextFieldsSupplier.hpp> +#include <com/sun/star/text/XTextTablesSupplier.hpp> + #include <config_features.h> +#include <unotools/tempfile.hxx> #include <comphelper/configuration.hxx> #include <officecfg/Office/Writer.hxx> - +#include <vcl/svapp.hxx> class Test : public SwModelTestBase { diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx index c4208ada642a..f3b9d6b2ecf3 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx @@ -19,10 +19,16 @@ #include <com/sun/star/table/BorderLine2.hpp> #include <com/sun/star/rdf/URI.hpp> #include <com/sun/star/rdf/Statement.hpp> +#include <com/sun/star/rdf/XDocumentMetadataAccess.hpp> +#include <com/sun/star/text/XTextSectionsSupplier.hpp> + #include <o3tl/cppunittraitshelper.hxx> +#include <comphelper/processfactory.hxx> #include <ndindex.hxx> #include <pam.hxx> +#include <unotxdoc.hxx> +#include <docsh.hxx> class Test : public SwModelTestBase { diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx index efbef3e23acb..0e69e4884a43 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx @@ -9,8 +9,6 @@ #include <swmodeltestbase.hxx> - - #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp> #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp> #include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp> @@ -19,13 +17,16 @@ #include <com/sun/star/drawing/LineJoint.hpp> #include <com/sun/star/drawing/LineStyle.hpp> #include <com/sun/star/drawing/TextVerticalAdjust.hpp> +#include <com/sun/star/drawing/XShapes.hpp> #include <com/sun/star/style/LineSpacing.hpp> #include <com/sun/star/style/LineSpacingMode.hpp> #include <com/sun/star/text/GraphicCrop.hpp> #include <com/sun/star/text/VertOrientation.hpp> #include <com/sun/star/text/WrapTextMode.hpp> +#include <com/sun/star/packages/zip/ZipFileAccess.hpp> #include <comphelper/sequenceashashmap.hxx> +#include <comphelper/processfactory.hxx> class Test : public SwModelTestBase { diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx index cb0ed231aabe..208c0354d264 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx @@ -9,15 +9,19 @@ #include <swmodeltestbase.hxx> - #include <com/sun/star/drawing/Hatch.hpp> #include <com/sun/star/drawing/PointSequenceSequence.hpp> #include <com/sun/star/drawing/TextVerticalAdjust.hpp> -#include <pagedesc.hxx> +#include <com/sun/star/packages/zip/ZipFileAccess.hpp> +#include <com/sun/star/text/XTextTable.hpp> +#include <config_features.h> #include <comphelper/sequenceashashmap.hxx> +#include <comphelper/processfactory.hxx> -#include <config_features.h> +#include <pagedesc.hxx> +#include <unotxdoc.hxx> +#include <docsh.hxx> class Test : public SwModelTestBase { diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx index d94a2e5236c6..e405504b9b8b 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx @@ -41,14 +41,23 @@ #include <com/sun/star/view/XFormLayerAccess.hpp> #include <com/sun/star/table/BorderLine2.hpp> #include <com/sun/star/table/TableBorder2.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/drawing/XShapes2.hpp> +#include <com/sun/star/text/XNumberingRulesSupplier.hpp> +#include <com/sun/star/text/XTextTablesSupplier.hpp> +#include <com/sun/star/drawing/XShapes.hpp> +#include <com/sun/star/text/XTextFieldsSupplier.hpp> + #include <unotools/fltrcfg.hxx> #include <comphelper/sequenceashashmap.hxx> #include <oox/drawingml/drawingmltypes.hxx> #include <xmloff/odffields.hxx> + #include <IDocumentMarkAccess.hxx> #include <IMark.hxx> - #include <bordertest.hxx> +#include <unotxdoc.hxx> +#include <docsh.hxx> class Test : public SwModelTestBase { diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx index f9c51b3b24de..c87e1319f13e 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx @@ -33,10 +33,16 @@ #include <com/sun/star/style/ParagraphAdjust.hpp> #include <com/sun/star/drawing/XControlShape.hpp> #include <com/sun/star/text/TextContentAnchorType.hpp> +#include <com/sun/star/packages/zip/ZipFileAccess.hpp> +#include <com/sun/star/text/XTextTable.hpp> -#include <ftninfo.hxx> #include <sfx2/docfile.hxx> #include <sfx2/docfilt.hxx> +#include <comphelper/processfactory.hxx> + +#include <docsh.hxx> +#include <ftninfo.hxx> +#include <unotxdoc.hxx> class Test : public SwModelTestBase { diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx index db10f3043510..08374e532af5 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx @@ -8,9 +8,15 @@ */ #include <swmodeltestbase.hxx> + +#include <com/sun/star/text/XTextFieldsSupplier.hpp> + #include <xmloff/odffields.hxx> + #include <IDocumentMarkAccess.hxx> #include <IMark.hxx> +#include <docsh.hxx> +#include <unotxdoc.hxx> class Test : public SwModelTestBase { diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index c1001d1275a0..937721f2f07d 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -19,7 +19,6 @@ #include <swmodeltestbase.hxx> -#include <basegfx/polygon/b2dpolypolygontools.hxx> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/document/XEmbeddedObjectSupplier2.hpp> #include <com/sun/star/drawing/PointSequenceSequence.hpp> @@ -45,17 +44,27 @@ #include <com/sun/star/style/ParagraphAdjust.hpp> #include <com/sun/star/text/SizeType.hpp> #include <com/sun/star/util/DateTime.hpp> +#include <com/sun/star/text/GraphicCrop.hpp> +#include <com/sun/star/drawing/HomogenMatrix3.hpp> +#include <com/sun/star/awt/CharSet.hpp> +#include <com/sun/star/text/WritingMode2.hpp> +#include <com/sun/star/text/XTextSectionsSupplier.hpp> +#include <com/sun/star/text/XTextDocument.hpp> +#include <com/sun/star/drawing/XShapes.hpp> +#include <com/sun/star/table/XTableRows.hpp> +#include <com/sun/star/text/XTextTablesSupplier.hpp> +#include <com/sun/star/text/XTextTable.hpp> + +#include <basegfx/polygon/b2dpolypolygontools.hxx> #include <o3tl/cppunittraitshelper.hxx> #include <unotools/fltrcfg.hxx> #include <comphelper/sequenceashashmap.hxx> -#include <com/sun/star/text/GraphicCrop.hpp> #include <tools/datetimeutils.hxx> #include <oox/drawingml/drawingmltypes.hxx> #include <unotools/streamwrap.hxx> #include <comphelper/propertysequence.hxx> -#include <com/sun/star/drawing/HomogenMatrix3.hpp> -#include <com/sun/star/awt/CharSet.hpp> -#include <com/sun/star/text/WritingMode2.hpp> +#include <osl/time.h> +#include <comphelper/processfactory.hxx> class Test : public SwModelTestBase { diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx index 78e79add953a..4d36aa063eb1 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx @@ -15,18 +15,27 @@ #endif #include <swmodeltestbase.hxx> -#include <wrtsh.hxx> + #include <com/sun/star/document/XEmbeddedObjectSupplier2.hpp> #include <com/sun/star/embed/Aspects.hpp> #include <com/sun/star/text/WritingMode2.hpp> #include <com/sun/star/style/BreakType.hpp> +#include <com/sun/star/text/XTextDocument.hpp> +#include <com/sun/star/container/XContentEnumerationAccess.hpp> +#include <com/sun/star/text/XTextTable.hpp> + #include <xmloff/odffields.hxx> + +#include <wrtsh.hxx> #include <IDocumentMarkAccess.hxx> #include <IMark.hxx> #include <sortedobjs.hxx> #include <anchoredobject.hxx> #include <fmtftn.hxx> #include <ftnidx.hxx> +#include <unotxdoc.hxx> +#include <docsh.hxx> +#include <rootfrm.hxx> class Test : public SwModelTestBase { diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx index f472a7ac446f..323ebeed608f 100644 --- a/sw/qa/extras/rtfexport/rtfexport.cxx +++ b/sw/qa/extras/rtfexport/rtfexport.cxx @@ -31,6 +31,17 @@ #include <com/sun/star/text/RubyPosition.hpp> #include <com/sun/star/text/XTextColumns.hpp> #include <com/sun/star/text/HoriOrientation.hpp> +#include <com/sun/star/text/XTextDocument.hpp> +#include <com/sun/star/text/XTextFramesSupplier.hpp> +#include <com/sun/star/text/XTextTable.hpp> +#include <com/sun/star/text/XLineNumberingProperties.hpp> +#include <com/sun/star/text/XTextFieldsSupplier.hpp> +#include <com/sun/star/text/XTextTablesSupplier.hpp> +#include <com/sun/star/text/XBookmarksSupplier.hpp> + +#include <comphelper/sequenceashashmap.hxx> + +using namespace css; class Test : public SwModelTestBase { diff --git a/sw/qa/extras/rtfexport/rtfexport3.cxx b/sw/qa/extras/rtfexport/rtfexport3.cxx index 7bb20cbb410e..a04e1bab9752 100644 --- a/sw/qa/extras/rtfexport/rtfexport3.cxx +++ b/sw/qa/extras/rtfexport/rtfexport3.cxx @@ -13,6 +13,14 @@ #include <com/sun/star/text/XFootnotesSupplier.hpp> #include <com/sun/star/text/TextContentAnchorType.hpp> #include <com/sun/star/awt/FontWeight.hpp> +#include <com/sun/star/text/XEndnotesSupplier.hpp> +#include <com/sun/star/text/XTextTablesSupplier.hpp> +#include <com/sun/star/text/XTextTable.hpp> +#include <com/sun/star/style/TabStop.hpp> + +#include <comphelper/sequenceashashmap.hxx> + +using namespace css; class Test : public SwModelTestBase { diff --git a/sw/qa/extras/rtfexport/rtfexport4.cxx b/sw/qa/extras/rtfexport/rtfexport4.cxx index d0906fae9b3a..32d1889b032e 100644 --- a/sw/qa/extras/rtfexport/rtfexport4.cxx +++ b/sw/qa/extras/rtfexport/rtfexport4.cxx @@ -13,15 +13,20 @@ #include <com/sun/star/text/WritingMode2.hpp> #include <com/sun/star/text/XDocumentIndex.hpp> #include <com/sun/star/style/ParagraphAdjust.hpp> +#include <com/sun/star/style/TabStop.hpp> +#include <com/sun/star/text/XTextTable.hpp> #include <o3tl/cppunittraitshelper.hxx> #include <svx/swframetypes.hxx> #include <doc.hxx> +#include <docsh.hxx> #include <unotxdoc.hxx> #include <pam.hxx> #include <fmtanchr.hxx> #include <frameformats.hxx> +using namespace css; + /** Split these tests into their own file because they are really really slow */ diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx b/sw/qa/extras/rtfexport/rtfexport5.cxx index b5fbe1ba8741..b430d611fc33 100644 --- a/sw/qa/extras/rtfexport/rtfexport5.cxx +++ b/sw/qa/extras/rtfexport/rtfexport5.cxx @@ -30,6 +30,9 @@ #include <com/sun/star/text/WritingMode2.hpp> #include <com/sun/star/graphic/XGraphic.hpp> #include <com/sun/star/text/XTextContentAppend.hpp> +#include <com/sun/star/text/XTextDocument.hpp> +#include <com/sun/star/beans/XPropertyState.hpp> +#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> #include <rtl/ustring.hxx> #include <vcl/svapp.hxx> @@ -37,6 +40,8 @@ #include <comphelper/sequenceashashmap.hxx> #include <i18nlangtag/languagetag.hxx> +using namespace css; + class Test : public SwModelTestBase { public: diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 1e960e443079..a0dc9958351e 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -42,6 +42,12 @@ #include <com/sun/star/text/HoriOrientation.hpp> #include <com/sun/star/text/VertOrientation.hpp> #include <com/sun/star/text/XFormField.hpp> +#include <com/sun/star/lang/Locale.hpp> +#include <com/sun/star/drawing/XShapes.hpp> +#include <com/sun/star/text/XTextDocument.hpp> +#include <com/sun/star/text/XTextSectionsSupplier.hpp> +#include <com/sun/star/beans/XPropertyState.hpp> + #include <o3tl/cppunittraitshelper.hxx> #include <rtl/ustring.hxx> #include <vcl/settings.hxx> diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 346efb75897b..8891ef5efcdf 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -7,13 +7,17 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include <swmodeltestbase.hxx> + #include <string> + #include <boost/property_tree/json_parser.hpp> #include <com/sun/star/frame/DispatchResultState.hpp> #include <com/sun/star/frame/XDispatchResultListener.hpp> #include <com/sun/star/frame/XStorable.hpp> -#include <swmodeltestbase.hxx> +#include <com/sun/star/frame/Desktop.hpp> + #include <test/helper/transferable.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <comphelper/dispatchcommand.hxx> @@ -28,28 +32,33 @@ #include <svl/srchitem.hxx> #include <svl/slstitm.hxx> #include <svl/stritem.hxx> -#include <drawdoc.hxx> -#include <ndtxt.hxx> -#include <wrtsh.hxx> -#include <view.hxx> -#include <UndoManager.hxx> -#include <cmdid.h> #include <sfx2/viewsh.hxx> #include <sfx2/bindings.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/viewfrm.hxx> #include <sfx2/lokhelper.hxx> -#include <redline.hxx> -#include <IDocumentDrawModelAccess.hxx> -#include <IDocumentRedlineAccess.hxx> #include <vcl/scheduler.hxx> #include <vcl/vclevent.hxx> #include <vcl/bitmapaccess.hxx> #include <svx/svxids.hrc> -#include <flddat.hxx> -#include <basesh.hxx> #include <vcl/ITiledRenderable.hxx> #include <tools/json_writer.hxx> +#include <unotools/mediadescriptor.hxx> +#include <comphelper/processfactory.hxx> + +#include <drawdoc.hxx> +#include <ndtxt.hxx> +#include <wrtsh.hxx> +#include <view.hxx> +#include <UndoManager.hxx> +#include <cmdid.h> +#include <redline.hxx> +#include <IDocumentDrawModelAccess.hxx> +#include <IDocumentRedlineAccess.hxx> +#include <flddat.hxx> +#include <basesh.hxx> +#include <unotxdoc.hxx> +#include <docsh.hxx> char const DATA_DIRECTORY[] = "/sw/qa/extras/tiledrendering/data/"; diff --git a/sw/qa/extras/txtexport/txtexport.cxx b/sw/qa/extras/txtexport/txtexport.cxx index 36fa884044c1..d7246d05aced 100644 --- a/sw/qa/extras/txtexport/txtexport.cxx +++ b/sw/qa/extras/txtexport/txtexport.cxx @@ -12,6 +12,8 @@ #include <shellio.hxx> #include <unotextrange.hxx> #include <iodetect.hxx> +#include <unotxdoc.hxx> +#include <docsh.hxx> class TxtImportTest : public SwModelTestBase { diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index f6ca40db5bfa..b0d572026f61 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -98,6 +98,8 @@ #include <com/sun/star/document/XEmbeddedObjectSupplier2.hpp> #include <com/sun/star/drawing/XShape.hpp> #include <com/sun/star/linguistic2/XLinguProperties.hpp> +#include <com/sun/star/text/XTextViewCursorSupplier.hpp> +#include <com/sun/star/text/XPageCursor.hpp> #include <o3tl/cppunittraitshelper.hxx> #include <o3tl/make_shared.hxx> #include <osl/file.hxx> @@ -129,6 +131,10 @@ #include <wrthtml.hxx> #include <dbmgr.hxx> #include <frameformats.hxx> +#include <docsh.hxx> +#include <unotxdoc.hxx> +#include <comphelper/processfactory.hxx> +#include <rootfrm.hxx> namespace { diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 64e82663bdaf..2b31e2694038 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -17,6 +17,8 @@ #include <com/sun/star/style/LineSpacing.hpp> #include <com/sun/star/text/TableColumnSeparator.hpp> #include <com/sun/star/view/XSelectionSupplier.hpp> +#include <com/sun/star/text/XTextTable.hpp> +#include <com/sun/star/table/XTableRows.hpp> #include <comphelper/propertysequence.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <i18nlangtag/languagetag.hxx> @@ -50,6 +52,13 @@ #include <shellio.hxx> #include <editeng/fontitem.hxx> #include <tools/json_writer.hxx> +#include <docsh.hxx> +#include <unotxdoc.hxx> +#include <IDocumentLayoutAccess.hxx> +#include <rootfrm.hxx> +#include <unotools/mediadescriptor.hxx> +#include <com/sun/star/packages/zip/ZipFileAccess.hpp> +#include <comphelper/processfactory.hxx> namespace { diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx index 47bfca6c5451..df2567abe7dd 100644 --- a/sw/qa/extras/uiwriter/uiwriter3.cxx +++ b/sw/qa/extras/uiwriter/uiwriter3.cxx @@ -11,6 +11,10 @@ #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <vcl/scheduler.hxx> #include <com/sun/star/text/TextContentAnchorType.hpp> +#include <com/sun/star/text/XTextTablesSupplier.hpp> +#include <com/sun/star/text/XTextTable.hpp> +#include <com/sun/star/text/XTextViewCursorSupplier.hpp> +#include <com/sun/star/text/XPageCursor.hpp> #include <comphelper/propertysequence.hxx> #include <boost/property_tree/json_parser.hpp> #include <frameformats.hxx> @@ -20,6 +24,8 @@ #include <tools/json_writer.hxx> #include <wrtsh.hxx> +#include <unotxdoc.hxx> +#include <docsh.hxx> namespace { diff --git a/sw/qa/extras/unowriter/unowriter.cxx b/sw/qa/extras/unowriter/unowriter.cxx index f9040938ef56..859c8bff3f4b 100644 --- a/sw/qa/extras/unowriter/unowriter.cxx +++ b/sw/qa/extras/unowriter/unowriter.cxx @@ -8,6 +8,7 @@ */ #include <swmodeltestbase.hxx> + #include <com/sun/star/awt/FontSlant.hpp> #include <com/sun/star/table/XCellRange.hpp> #include <com/sun/star/text/TextContentAnchorType.hpp> @@ -17,6 +18,7 @@ #include <com/sun/star/text/XTextPortionAppend.hpp> #include <com/sun/star/text/XTextContentAppend.hpp> #include <com/sun/star/text/XTextRangeCompare.hpp> +#include <com/sun/star/text/XPasteListener.hpp> #include <com/sun/star/rdf/URI.hpp> #include <com/sun/star/rdf/URIs.hpp> #include <com/sun/star/awt/XDevice.hpp> @@ -24,9 +26,19 @@ #include <com/sun/star/graphic/XGraphic.hpp> #include <com/sun/star/style/LineSpacing.hpp> #include <com/sun/star/view/XSelectionSupplier.hpp> +#include <com/sun/star/text/XTextDocument.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/view/XRenderable.hpp> +#include <com/sun/star/text/XTextViewCursorSupplier.hpp> +#include <com/sun/star/text/XTextTable.hpp> +#include <com/sun/star/text/XPageCursor.hpp> + #include <comphelper/propertyvalue.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <vcl/graphicfilter.hxx> +#include <comphelper/sequenceashashmap.hxx> +#include <comphelper/processfactory.hxx> + #include <wrtsh.hxx> #include <ndtxt.hxx> #include <swdtflvr.hxx> @@ -36,6 +48,8 @@ #include <AnnotationWin.hxx> #include <flyfrm.hxx> #include <fmtanchr.hxx> +#include <unotxdoc.hxx> +#include <docsh.hxx> using namespace ::com::sun::star; diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx index 19126fdcca0c..fecb25b1b8e5 100644 --- a/sw/qa/extras/ww8export/ww8export.cxx +++ b/sw/qa/extras/ww8export/ww8export.cxx @@ -9,12 +9,10 @@ #include <swmodeltestbase.hxx> -//#include <com/sun/star/text/XDependentTextField.hpp> - -#include <IDocumentSettingAccess.hxx> #include <com/sun/star/awt/FontWeight.hpp> #include <com/sun/star/awt/Size.hpp> #include <com/sun/star/awt/XBitmap.hpp> +#include <com/sun/star/beans/XPropertyState.hpp> #include <com/sun/star/form/validation/XValidatableFormComponent.hpp> #include <com/sun/star/frame/XStorable.hpp> #include <com/sun/star/graphic/XGraphic.hpp> @@ -33,23 +31,26 @@ #include <com/sun/star/view/DocumentZoomType.hpp> #include <com/sun/star/rdf/URI.hpp> #include <com/sun/star/rdf/Statement.hpp> -//#include <vcl/svapp.hxx> -#include <grfatr.hxx> -#include <pagedesc.hxx> -#include <ndgrf.hxx> +#include <com/sun/star/text/XTextViewCursorSupplier.hpp> +#include <com/sun/star/text/XPageCursor.hpp> +#include <config_features.h> #include <sfx2/bindings.hxx> #include <sfx2/request.hxx> +#include <comphelper/processfactory.hxx> #include <cmdid.h> #include <envimg.hxx> #include <swmodule.hxx> #include <view.hxx> #include <wrtsh.hxx> - -#include <config_features.h> - +#include <grfatr.hxx> +#include <pagedesc.hxx> +#include <ndgrf.hxx> #include <bordertest.hxx> +#include <IDocumentSettingAccess.hxx> +#include <docsh.hxx> +#include <unotxdoc.hxx> class Test : public SwModelTestBase { diff --git a/sw/qa/extras/ww8export/ww8export2.cxx b/sw/qa/extras/ww8export/ww8export2.cxx index 2146edd7079b..48391d594236 100644 --- a/sw/qa/extras/ww8export/ww8export2.cxx +++ b/sw/qa/extras/ww8export/ww8export2.cxx @@ -22,11 +22,16 @@ #include <com/sun/star/text/VertOrientation.hpp> #include <com/sun/star/text/WrapTextMode.hpp> #include <com/sun/star/text/TextContentAnchorType.hpp> +#include <com/sun/star/text/XFootnotesSupplier.hpp> +#include <com/sun/star/text/XEndnotesSupplier.hpp> -#include <ftninfo.hxx> #include <svx/svdpage.hxx> + +#include <ftninfo.hxx> #include <drawdoc.hxx> #include <IDocumentDrawModelAccess.hxx> +#include <docsh.hxx> +#include <unotxdoc.hxx> class Test : public SwModelTestBase { diff --git a/sw/qa/extras/ww8export/ww8export3.cxx b/sw/qa/extras/ww8export/ww8export3.cxx index 512cce9ca4bc..2c6f4e1f0fe0 100644 --- a/sw/qa/extras/ww8export/ww8export3.cxx +++ b/sw/qa/extras/ww8export/ww8export3.cxx @@ -9,7 +9,6 @@ #include <swmodeltestbase.hxx> -#include <IDocumentSettingAccess.hxx> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/container/XIndexAccess.hpp> #include <com/sun/star/drawing/FillStyle.hpp> @@ -21,6 +20,18 @@ #include <com/sun/star/text/XTextTablesSupplier.hpp> #include <com/sun/star/text/WritingMode2.hpp> #include <com/sun/star/text/XTextContentAppend.hpp> +#include <com/sun/star/frame/XStorable.hpp> +#include <com/sun/star/text/XTextSectionsSupplier.hpp> +#include <com/sun/star/text/XFootnotesSupplier.hpp> +#include <com/sun/star/text/XTextDocument.hpp> +#include <com/sun/star/text/XLineNumberingProperties.hpp> +#include <com/sun/star/drawing/XDrawPagesSupplier.hpp> + +#include <comphelper/sequenceashashmap.hxx> + +#include <IDocumentSettingAccess.hxx> +#include <docsh.hxx> +#include <unotxdoc.hxx> class Test : public SwModelTestBase { diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx index 8a085472ea4a..30c8210a3153 100644 --- a/sw/qa/extras/ww8import/ww8import.cxx +++ b/sw/qa/extras/ww8import/ww8import.cxx @@ -11,18 +11,24 @@ #include <com/sun/star/text/XTextColumns.hpp> #include <com/sun/star/text/XTextTablesSupplier.hpp> +#include <com/sun/star/text/XTextSectionsSupplier.hpp> #include <com/sun/star/graphic/XGraphic.hpp> -#include <viscrs.hxx> -#include <wrtsh.hxx> -#include <ndgrf.hxx> -#include <fmtsrnd.hxx> -#include <frameformats.hxx> + #include <editeng/boxitem.hxx> #include <editeng/lrspitem.hxx> #include <editeng/ulspitem.hxx> #include <sfx2/docfile.hxx> #include <sfx2/docfilt.hxx> +#include <viscrs.hxx> +#include <wrtsh.hxx> +#include <ndgrf.hxx> +#include <fmtsrnd.hxx> +#include <frameformats.hxx> +#include <docsh.hxx> +#include <unotxdoc.hxx> +#include <IDocumentLayoutAccess.hxx> + class Test : public SwModelTestBase { public: diff --git a/sw/qa/inc/swmodeltestbase.hxx b/sw/qa/inc/swmodeltestbase.hxx index a0170896ac80..6193be33afc3 100644 --- a/sw/qa/inc/swmodeltestbase.hxx +++ b/sw/qa/inc/swmodeltestbase.hxx @@ -11,44 +11,23 @@ #define INCLUDED_SW_QA_INC_SWMODELTESTBASE_HXX #include <memory> -#include <com/sun/star/container/XContentEnumerationAccess.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/container/XNameAccess.hpp> -#include <com/sun/star/document/XFilter.hpp> -#include <com/sun/star/document/XImporter.hpp> -#include <com/sun/star/frame/Desktop.hpp> -#include <com/sun/star/packages/zip/ZipFileAccess.hpp> -#include <com/sun/star/style/XStyleFamiliesSupplier.hpp> -#include <com/sun/star/style/XAutoStylesSupplier.hpp> +#include <com/sun/star/drawing/XShape.hpp> #include <com/sun/star/style/XAutoStyleFamily.hpp> -#include <com/sun/star/text/XPageCursor.hpp> -#include <com/sun/star/text/XTextDocument.hpp> #include <com/sun/star/text/XTextRange.hpp> -#include <com/sun/star/text/XTextTable.hpp> -#include <com/sun/star/text/XTextViewCursorSupplier.hpp> #include <com/sun/star/table/XCell.hpp> #include <com/sun/star/table/BorderLine2.hpp> #include <com/sun/star/xml/AttributeData.hpp> +#include "swqahelperdllapi.h" #include <test/bootstrapfixture.hxx> #include <test/xmltesttools.hxx> #include <test/testinteractionhandler.hxx> #include <unotest/macros_test.hxx> -#include <unotools/streamwrap.hxx> -#include <unotools/ucbstreamhelper.hxx> -#include <rtl/ustrbuf.hxx> -#include <sfx2/app.hxx> -#include <comphelper/processfactory.hxx> -#include <comphelper/sequence.hxx> #include <unotools/tempfile.hxx> -#include <unotools/mediadescriptor.hxx> -#include <unotxdoc.hxx> -#include <docsh.hxx> #include <doc.hxx> -#include <IDocumentLayoutAccess.hxx> -#include <rootfrm.hxx> - -using namespace css; /** * Macro to declare a new test (with full round-trip. To test @@ -140,7 +119,7 @@ using namespace css; void TestName::verify() /// Base class for filter tests loading or roundtripping a document, then asserting the document model. -class SwModelTestBase : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools +class SWQAHELPER_DLLPUBLIC SwModelTestBase : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools { private: OUString maFilterOptions; @@ -148,7 +127,7 @@ private: OUString maImportFilterName; protected: - uno::Reference< lang::XComponent > mxComponent; + css::uno::Reference< css::lang::XComponent > mxComponent; rtl::Reference<TestInteractionHandler> xInteractionHandler; @@ -189,27 +168,7 @@ protected: virtual OUString getTestName() { return OUString(); } /// Copy&paste helper. - void paste(const OUString& aFilename, uno::Reference<text::XTextRange> const& xTextRange) - { - uno::Reference<document::XFilter> xFilter( - m_xSFactory->createInstance("com.sun.star.comp.Writer.RtfFilter"), - uno::UNO_QUERY_THROW); - uno::Reference<document::XImporter> xImporter(xFilter, uno::UNO_QUERY_THROW); - xImporter->setTargetDocument(mxComponent); - uno::Sequence<beans::PropertyValue> aDescriptor(3); - aDescriptor[0].Name = "InputStream"; - std::unique_ptr<SvStream> pStream = utl::UcbStreamHelper::CreateStream( - m_directories.getURLFromSrc("/sw/qa/extras/") + aFilename, - StreamMode::STD_READ); - CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, pStream->GetError()); - uno::Reference<io::XStream> xStream(new utl::OStreamWrapper(std::move(pStream))); - aDescriptor[0].Value <<= xStream; - aDescriptor[1].Name = "InsertMode"; - aDescriptor[1].Value <<= true; - aDescriptor[2].Name = "TextInsertModeRange"; - aDescriptor[2].Value <<= xTextRange; - CPPUNIT_ASSERT(xFilter->filter(aDescriptor)); - } + void paste(const OUString& aFilename, css::uno::Reference<css::text::XTextRange> const& xTextRange); public: void setFilterOptions(const OUString &rFilterOptions) @@ -227,90 +186,32 @@ public: maImportFilterName = rFilterName; } - SwModelTestBase(const OUString& pTestDocumentPath = OUString(), const char* pFilter = "") - : mpXmlBuffer(nullptr) - , mpTestDocumentPath(pTestDocumentPath) - , mpFilter(pFilter) - , mnStartTime(0) - , mbExported(false) - { - maTempFile.EnableKillingFile(); - } - - virtual void setUp() override - { - test::BootstrapFixture::setUp(); - mxDesktop.set(css::frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory()))); - SfxApplication::GetOrCreate(); - } + SwModelTestBase(const OUString& pTestDocumentPath = OUString(), const char* pFilter = ""); - virtual void tearDown() override - { - if (mxComponent.is()) - mxComponent->dispose(); + void setUp() override; - test::BootstrapFixture::tearDown(); - } + void tearDown() override; protected: /** * Helper func used by each unit test to test the 'import' code. * (Loads the requested file and then calls 'verify' method) */ - void executeImportTest(const char* filename, const char* pPassword = nullptr) - { - // If the testcase is stored in some other format, it's pointless to test. - if (mustTestImportOf(filename)) - { - maTempFile.EnableKillingFile(false); - header(); - std::unique_ptr<Resetter> const pChanges(preTest(filename)); - load(mpTestDocumentPath, filename, pPassword); - verify(); - finish(); - maTempFile.EnableKillingFile(); - } - } + void executeImportTest(const char* filename, const char* pPassword = nullptr); /** * Helper func used by each unit test to test the 'export' code. * (Loads the requested file, calls 'verify' function, save it to temp file, load the * temp file and then calls 'verify' function again) */ - void executeLoadVerifyReloadVerify(const char* filename, const char* pPassword = nullptr) - { - maTempFile.EnableKillingFile(false); - header(); - std::unique_ptr<Resetter> const pChanges(preTest(filename)); - load(mpTestDocumentPath, filename, pPassword); - if (mustTestImportOf(filename)) - { - verify(); - } - postLoad(filename); - reload(mpFilter, filename, pPassword); - verify(); - finish(); - maTempFile.EnableKillingFile(); - } + void executeLoadVerifyReloadVerify(const char* filename, const char* pPassword = nullptr); /** * Helper func used by each unit test to test the 'export' code. * (Loads the requested file, save it to temp file, load the * temp file and then calls 'verify' method) */ - void executeLoadReloadVerify(const char* filename, const char* pPassword = nullptr) - { - maTempFile.EnableKillingFile(false); - header(); - std::unique_ptr<Resetter> const pChanges(preTest(filename)); - load(mpTestDocumentPath, filename, pPassword); - postLoad(filename); - reload(mpFilter, filename, pPassword); - verify(); - finish(); - maTempFile.EnableKillingFile(); - } + void executeLoadReloadVerify(const char* filename, const char* pPassword = nullptr); /** * Helper func used by each unit test to test the 'export' code. @@ -318,18 +219,7 @@ protected: * the initial document condition), exports with the desired * export filter and then calls 'verify' method) */ - void executeImportExport(const char* filename, const char* pPassword) - { - maTempFile.EnableKillingFile(false); - header(); - std::unique_ptr<Resetter> const pChanges(preTest(filename)); - load(mpTestDocumentPath, filename, pPassword); - save(OUString::createFromAscii(mpFilter), maTempFile); - maTempFile.EnableKillingFile(false); - verify(); - finish(); - maTempFile.EnableKillingFile(); - } + void executeImportExport(const char* filename, const char* pPassword); /** * Function overridden by unit test. See DECLARE_SW_*_TEST macros @@ -376,137 +266,35 @@ protected: } protected: - void dumpLayout(const uno::Reference< lang::XComponent > & rComponent) - { - // create the xml writer - mpXmlBuffer = xmlBufferCreate(); - xmlTextWriterPtr pXmlWriter = xmlNewTextWriterMemory(mpXmlBuffer, 0); - xmlTextWriterStartDocument(pXmlWriter, nullptr, nullptr, nullptr); - - // create the dump - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(rComponent.get()); - CPPUNIT_ASSERT(pTextDoc); - SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); - SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); - pLayout->dumpAsXml(pXmlWriter); - - // delete xml writer - xmlTextWriterEndDocument(pXmlWriter); - xmlFreeTextWriter(pXmlWriter); - } + void dumpLayout(const css::uno::Reference< css::lang::XComponent > & rComponent); - void discardDumpedLayout() - { - if (mpXmlBuffer) - { - xmlBufferFree(mpXmlBuffer); - mpXmlBuffer = nullptr; - } - } + void discardDumpedLayout(); - void calcLayout() - { - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get()); - CPPUNIT_ASSERT(pTextDoc); - SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); - pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); - } + void calcLayout(); /// Get the length of the whole document. - int getLength() const - { - uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); - uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); - OUStringBuffer aBuf; - while (xParaEnum->hasMoreElements()) - { - uno::Reference<container::XEnumerationAccess> xRangeEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY); - uno::Reference<container::XEnumeration> xRangeEnum = xRangeEnumAccess->createEnumeration(); - while (xRangeEnum->hasMoreElements()) - { - uno::Reference<text::XTextRange> xRange(xRangeEnum->nextElement(), uno::UNO_QUERY); - aBuf.append(xRange->getString()); - } - } - return aBuf.getLength(); - } + int getLength() const; /// Get a family of styles, see com.sun.star.style.StyleFamilies for possible values. - uno::Reference<container::XNameAccess> getStyles(const OUString& aFamily) - { - uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XNameAccess> xStyleFamilies = xStyleFamiliesSupplier->getStyleFamilies(); - uno::Reference<container::XNameAccess> xStyleFamily(xStyleFamilies->getByName(aFamily), uno::UNO_QUERY); - return xStyleFamily; - } + css::uno::Reference<css::container::XNameAccess> getStyles(const OUString& aFamily); /// Get a family of auto styles, see com.sun.star.style.StyleFamilies for possible values. - uno::Reference<style::XAutoStyleFamily> getAutoStyles(const OUString& aFamily) - { - uno::Reference< style::XAutoStylesSupplier > xAutoStylesSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference< style::XAutoStyles > xAutoStyles(xAutoStylesSupplier->getAutoStyles()); - uno::Reference< style::XAutoStyleFamily > xAutoStyleFamily(xAutoStyles->getByName(aFamily), uno::UNO_QUERY); - return xAutoStyleFamily; - } + css::uno::Reference<css::style::XAutoStyleFamily> getAutoStyles(const OUString& aFamily); /// Similar to parseExport(), but this gives the xmlDocPtr of the layout dump. - xmlDocUniquePtr parseLayoutDump() - { - if (!mpXmlBuffer) - dumpLayout(mxComponent); - - return xmlDocUniquePtr(xmlParseMemory(reinterpret_cast<const char*>(xmlBufferContent(mpXmlBuffer)), xmlBufferLength(mpXmlBuffer))); - } + xmlDocUniquePtr parseLayoutDump(); /** * Extract a value from the layout dump using an XPath expression and an attribute name. * * If the attribute is omitted, the text of the node is returned. */ - OUString parseDump(const OString& aXPath, const OString& aAttribute = OString()) - { - xmlDocUniquePtr pXmlDoc = parseLayoutDump(); - - xmlXPathContextPtr pXmlXpathCtx = xmlXPathNewContext(pXmlDoc.get()); - xmlXPathObjectPtr pXmlXpathObj = xmlXPathEvalExpression(BAD_CAST(aXPath.getStr()), pXmlXpathCtx); - CPPUNIT_ASSERT_MESSAGE("xpath evaluation failed", pXmlXpathObj); - xmlChar *pXpathStrResult; - if (pXmlXpathObj->type == XPATH_NODESET) - { - xmlNodeSetPtr pXmlNodes = pXmlXpathObj->nodesetval; - CPPUNIT_ASSERT_EQUAL_MESSAGE("xpath should match exactly 1 node", - 1, xmlXPathNodeSetGetLength(pXmlNodes)); - xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0]; - if (aAttribute.getLength()) - pXpathStrResult = xmlGetProp(pXmlNode, BAD_CAST(aAttribute.getStr())); - else - pXpathStrResult = xmlNodeGetContent(pXmlNode); - } - else - { - // the xpath expression evaluated to a value, not a node - CPPUNIT_ASSERT_EQUAL_MESSAGE( - "attr name should not be supplied when xpath evals to a value", - sal_Int32(0), aAttribute.getLength()); - pXpathStrResult = xmlXPathCastToString(pXmlXpathObj); - CPPUNIT_ASSERT_MESSAGE("xpath result cannot be cast to string", - pXpathStrResult); - } - - OUString aRet(reinterpret_cast<char*>(pXpathStrResult), - xmlStrlen(pXpathStrResult), RTL_TEXTENCODING_UTF8); - xmlFree(pXpathStrResult); - xmlFree(pXmlXpathObj); - xmlFree(pXmlXpathCtx); - - return aRet; - } + OUString parseDump(const OString& aXPath, const OString& aAttribute = OString()); template< typename T > - T getProperty( const uno::Any& obj, const OUString& name ) const + T getProperty( const css::uno::Any& obj, const OUString& name ) const { - uno::Reference< beans::XPropertySet > properties( obj, uno::UNO_QUERY_THROW ); + css::uno::Reference< css::beans::XPropertySet > properties( obj, uno::UNO_QUERY_THROW ); T data; if (!css::uno::fromAny(properties->getPropertyValue(name), &data)) { @@ -518,9 +306,9 @@ protected: } template< typename T > - T getProperty( const uno::Reference< uno::XInterface >& obj, const OUString& name ) const + T getProperty( const css::uno::Reference< css::uno::XInterface >& obj, const OUString& name ) const { - uno::Reference< beans::XPropertySet > properties( obj, uno::UNO_QUERY_THROW ); + css::uno::Reference< css::beans::XPropertySet > properties( obj, uno::UNO_QUERY_THROW ); T data = T(); if (!(properties->getPropertyValue(name) >>= data)) { @@ -531,200 +319,47 @@ protected: return data; } - bool hasProperty(const uno::Reference<uno::XInterface>& obj, const OUString& name) const - { - uno::Reference<beans::XPropertySet> properties(obj, uno::UNO_QUERY_THROW); - return properties->getPropertySetInfo()->hasPropertyByName(name); - } - - xml::AttributeData getUserDefineAttribute(const uno::Any& obj, const OUString& name, const OUString& rValue) const - { - uno::Reference<container::XNameContainer> attrsCnt(getProperty<uno::Any>(obj, "UserDefinedAttributes"), uno::UNO_QUERY_THROW); - - xml::AttributeData aValue; - attrsCnt->getByName(name) >>= aValue; - if (!rValue.isEmpty()) - CPPUNIT_ASSERT_EQUAL_MESSAGE("attribute of cell does not contain expected value", rValue, aValue.Value); + bool hasProperty(const css::uno::Reference<css::uno::XInterface>& obj, const OUString& name) const; - return aValue; - } + css::xml::AttributeData getUserDefineAttribute(const css::uno::Any& obj, const OUString& name, const OUString& rValue) const; - int getParagraphs( uno::Reference<text::XText> const & xText ) - { - int nRet = 0; - if ( ! xText.is() ) - return nRet; - - uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xText->getText(), uno::UNO_QUERY); - uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); - while (xParaEnum->hasMoreElements()) - { - xParaEnum->nextElement(); - nRet++; - } - return nRet; - } + int getParagraphs( css::uno::Reference<text::XText> const & xText ); /// Get number of paragraphs of the document. - int getParagraphs() - { - uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); - return getParagraphs( xTextDocument->getText() ); - } + int getParagraphs(); - uno::Reference<text::XTextContent> getParagraphOrTable(int number, uno::Reference<text::XText> const & xText = uno::Reference<text::XText>()) const - { - assert(number != 0); // this thing is 1-based - uno::Reference<container::XEnumerationAccess> paraEnumAccess; - if (xText.is()) - paraEnumAccess.set(xText, uno::UNO_QUERY); - else - { - uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY); - paraEnumAccess.set(textDocument->getText(), uno::UNO_QUERY); - } - uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration(); - for( int i = 1; - i < number; - ++i ) - paraEnum->nextElement(); - uno::Reference< text::XTextContent> const xElem(paraEnum->nextElement(), - uno::UNO_QUERY_THROW); - return xElem; - } + css::uno::Reference<css::text::XTextContent> getParagraphOrTable(int number, css::uno::Reference<css::text::XText> const & xText = css::uno::Reference<css::text::XText>()) const; // Get paragraph (counted from 1), optionally check it contains the given text. - uno::Reference< text::XTextRange > getParagraph( int number, const OUString& content = OUString() ) const - { - uno::Reference<text::XTextRange> const xParagraph( - getParagraphOrTable(number), uno::UNO_QUERY_THROW); - if( !content.isEmpty()) - CPPUNIT_ASSERT_EQUAL_MESSAGE( "paragraph does not have expected content", content, xParagraph->getString()); - return xParagraph; - } + css::uno::Reference< css::text::XTextRange > getParagraph( int number, const OUString& content = OUString() ) const; - sal_Int16 getNumberingTypeOfParagraph(int nPara) - { - sal_Int16 nNumberingType = -1; - uno::Reference<text::XTextRange> xPara(getParagraph(nPara)); - uno::Reference< beans::XPropertySet > properties( xPara, uno::UNO_QUERY); - bool isNumber = false; - properties->getPropertyValue("NumberingIsNumber") >>= isNumber; - if (isNumber) - { - uno::Reference<container::XIndexAccess> xLevels( properties->getPropertyValue("NumberingRules"), uno::UNO_QUERY); - sal_Int16 nNumberingLevel = -1; - properties->getPropertyValue("NumberingLevel") >>= nNumberingLevel; - if (nNumberingLevel >= 0 && nNumberingLevel < xLevels->getCount()) - { - uno::Sequence< beans::PropertyValue > aPropertyValue; - xLevels->getByIndex(nNumberingLevel) >>= aPropertyValue; - auto pProp = std::find_if(aPropertyValue.begin(), aPropertyValue.end(), - [](const beans::PropertyValue& rProp) { return rProp.Name == "NumberingType"; }); - if (pProp != aPropertyValue.end()) - nNumberingType = pProp->Value.get<sal_Int16>(); - } - } - return nNumberingType; - } + sal_Int16 getNumberingTypeOfParagraph(int nPara); - uno::Reference<text::XTextRange> getParagraphOfText(int number, uno::Reference<text::XText> const & xText, const OUString& content = OUString()) const - { - uno::Reference<text::XTextRange> const xParagraph(getParagraphOrTable(number, xText), uno::UNO_QUERY_THROW); - if (!content.isEmpty()) - CPPUNIT_ASSERT_EQUAL_MESSAGE( "paragraph does not contain expected content", content, xParagraph->getString()); - return xParagraph; - } + css::uno::Reference<css::text::XTextRange> getParagraphOfText(int number, css::uno::Reference<css::text::XText> const & xText, const OUString& content = OUString()) const; /// get nth object/fly that is anchored AT paragraph - uno::Reference<beans::XPropertySet> getParagraphAnchoredObject( - int const index, uno::Reference<text::XTextRange> const & xPara) const - { - uno::Reference<container::XContentEnumerationAccess> xContentEnumAccess(xPara, uno::UNO_QUERY); - uno::Reference<container::XEnumeration> xContentEnum = xContentEnumAccess->createContentEnumeration("com.sun.star.text.TextContent"); - for (int i = 1; i < index; ++i) - { - xContentEnum->nextElement(); - } - return uno::Reference<beans::XPropertySet>(xContentEnum->nextElement(), uno::UNO_QUERY); - } + css::uno::Reference<css::beans::XPropertySet> getParagraphAnchoredObject( + int const index, css::uno::Reference<css::text::XTextRange> const & xPara) const; /// Get run (counted from 1) of a paragraph, optionally check it contains the given text. - uno::Reference<text::XTextRange> getRun(uno::Reference<text::XTextRange> const & xParagraph, int number, const OUString& content = OUString()) const - { - uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParagraph, uno::UNO_QUERY); - uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration(); - for (int i = 1; i < number; ++i) - xRunEnum->nextElement(); - uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), uno::UNO_QUERY); - if( !content.isEmpty()) - CPPUNIT_ASSERT_EQUAL_MESSAGE( "run does not contain expected content", content, xRun->getString()); - return xRun; - } + css::uno::Reference<css::text::XTextRange> getRun(uno::Reference<css::text::XTextRange> const & xParagraph, int number, const OUString& content = OUString()) const; /// Get math formula string of a run. - OUString getFormula(uno::Reference<text::XTextRange> const & xRun) const - { - uno::Reference<container::XContentEnumerationAccess> xContentEnumAccess(xRun, uno::UNO_QUERY); - uno::Reference<container::XEnumeration> xContentEnum = xContentEnumAccess->createContentEnumeration(""); - uno::Reference<beans::XPropertySet> xFormula(xContentEnum->nextElement(), uno::UNO_QUERY); - return getProperty<OUString>(getProperty< uno::Reference<beans::XPropertySet> >(xFormula, "Model"), "Formula"); - } + OUString getFormula(css::uno::Reference<css::text::XTextRange> const & xRun) const; /// get cell of a table; table can be retrieved with getParagraphOrTable - uno::Reference<table::XCell> getCell( - uno::Reference<uno::XInterface> const& xTableIfc, - OUString const& rCell, OUString const& rContent = OUString()) - { - uno::Reference<text::XTextTable> const xTable(xTableIfc, - uno::UNO_QUERY_THROW); - uno::Reference<table::XCell> const xCell( - xTable->getCellByName(rCell), uno::UNO_SET_THROW); - if (!rContent.isEmpty()) - { - uno::Reference<text::XText> const xCellText(xCell, - uno::UNO_QUERY_THROW); - CPPUNIT_ASSERT_EQUAL_MESSAGE("cell does not contain expected content", rContent, xCellText->getString()); - } - return xCell; - } + css::uno::Reference<css::table::XCell> getCell( + css::uno::Reference<css::uno::XInterface> const& xTableIfc, + OUString const& rCell, OUString const& rContent = OUString()); /// Get shape (counted from 1) - uno::Reference<drawing::XShape> getShape(int number) - { - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); - uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(number - 1), uno::UNO_QUERY); - return xShape; - } + css::uno::Reference<css::drawing::XShape> getShape(int number); /// Get shape by name - uno::Reference<drawing::XShape> getShapeByName(const OUString& aName) - { - uno::Reference<drawing::XShape> xRet; - - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); - for (sal_Int32 i = 0; i < xDrawPage->getCount(); ++i) - { - uno::Reference<container::XNamed> xShape(xDrawPage->getByIndex(i), uno::UNO_QUERY); - if (xShape->getName() == aName) - { - xRet.set(xShape, uno::UNO_QUERY); - break; - } - } + css::uno::Reference<css::drawing::XShape> getShapeByName(const OUString& aName); - return xRet; - } /// Get TextFrame by name - uno::Reference<drawing::XShape> getTextFrameByName(const OUString& aName) - { - uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XNameAccess> xNameAccess = xTextFramesSupplier->getTextFrames(); - uno::Reference<drawing::XShape> xShape(xNameAccess->getByName(aName), uno::UNO_QUERY); - return xShape; - } + css::uno::Reference<css::drawing::XShape> getTextFrameByName(const OUString& aName); void header() { @@ -736,190 +371,22 @@ protected: return loadURL(m_directories.getURLFromSrc(pDir) + OUString::createFromAscii(pName), pName, pPassword); } - void setTestInteractionHandler(const char* pPassword, std::vector<beans::PropertyValue>& rFilterOptions) - { - OUString sPassword = OUString::createFromAscii(pPassword); - rFilterOptions.emplace_back(); - xInteractionHandler = rtl::Reference<TestInteractionHandler>(new TestInteractionHandler(sPassword)); - uno::Reference<task::XInteractionHandler2> const xInteraction(xInteractionHandler.get()); - rFilterOptions[0].Name = "InteractionHandler"; - rFilterOptions[0].Value <<= xInteraction; - } - - void loadURL(OUString const& rURL, const char* pName, const char* pPassword = nullptr) - { - if (mxComponent.is()) - mxComponent->dispose(); - - std::vector<beans::PropertyValue> aFilterOptions; + void setTestInteractionHandler(const char* pPassword, std::vector<beans::PropertyValue>& rFilterOptions); - if (pPassword) - { - setTestInteractionHandler(pPassword, aFilterOptions); - } - - if (!maImportFilterOptions.isEmpty()) - { - beans::PropertyValue aValue; - aValue.Name = "FilterOptions"; - aValue.Value <<= maImportFilterOptions; - aFilterOptions.push_back(aValue); - } + void loadURL(OUString const& rURL, const char* pName, const char* pPassword = nullptr); - if (!maImportFilterName.isEmpty()) - { - beans::PropertyValue aValue; - aValue.Name = "FilterName"; - aValue.Value <<= maImportFilterName; - aFilterOptions.push_back(aValue); - } - - // Output name early, so in the case of a hang, the name of the hanging input file is visible. - if (pName) - std::cout << pName << ":\n"; - mnStartTime = osl_getGlobalTimer(); - mxComponent = loadFromDesktop(rURL, "com.sun.star.text.TextDocument", comphelper::containerToSequence(aFilterOptions)); - - if (pPassword) - { - CPPUNIT_ASSERT_MESSAGE("Password set but not requested", xInteractionHandler->wasPasswordRequested()); - } - - discardDumpedLayout(); - if (pName && mustCalcLayoutOf(pName)) - calcLayout(); - } - - void reload(const char* pFilter, const char* filename, const char* pPassword = nullptr) - { - uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); - OUString aFilterName = OUString::createFromAscii(pFilter); - utl::MediaDescriptor aMediaDescriptor; - aMediaDescriptor["FilterName"] <<= aFilterName; - if (!maFilterOptions.isEmpty()) - aMediaDescriptor["FilterOptions"] <<= maFilterOptions; - if (pPassword) - { - if (strcmp(pFilter, "Office Open XML Text")) - { - aMediaDescriptor["Password"] <<= OUString::createFromAscii(pPassword); - } - else - { - OUString sPassword = OUString::createFromAscii(pPassword); - css::uno::Sequence<css::beans::NamedValue> aEncryptionData { - { "CryptoType", css::uno::makeAny(OUString("Standard")) }, - { "OOXPassword", css::uno::makeAny(sPassword) } - }; - aMediaDescriptor[utl::MediaDescriptor::PROP_ENCRYPTIONDATA()] <<= aEncryptionData; - } - } - xStorable->storeToURL(maTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList()); - uno::Reference<lang::XComponent> xComponent(xStorable, uno::UNO_QUERY); - xComponent->dispose(); - mbExported = true; - - std::vector<beans::PropertyValue> aFilterOptions; - if (pPassword) - { - setTestInteractionHandler(pPassword, aFilterOptions); - } - - if (!maImportFilterOptions.isEmpty()) - { - beans::PropertyValue aValue; - aValue.Name = "FilterOptions"; - aValue.Value <<= maImportFilterOptions; - aFilterOptions.push_back(aValue); - } - - if (!maImportFilterName.isEmpty()) - { - beans::PropertyValue aValue; - aValue.Name = "FilterName"; - aValue.Value <<= maImportFilterName; - aFilterOptions.push_back(aValue); - } - - mxComponent = loadFromDesktop(maTempFile.GetURL(), "com.sun.star.text.TextDocument", comphelper::containerToSequence(aFilterOptions)); - if (pPassword) - { - CPPUNIT_ASSERT_MESSAGE("Password set but not requested", xInteractionHandler->wasPasswordRequested()); - } - if (mustValidate(filename) || aFilterName == "writer8" - || aFilterName == "OpenDocument Text Flat XML") - { - if(aFilterName == "Office Open XML Text") - { - // too many validation errors right now - validate(maTempFile.GetFileName(), test::OOXML); - } - else if(aFilterName == "writer8" - || aFilterName == "OpenDocument Text Flat XML") - { - validate(maTempFile.GetFileName(), test::ODF); - } - else if(aFilterName == "MS Word 97") - { - validate(maTempFile.GetFileName(), test::MSBINARY); - } - else - { - OString aMessage = OStringLiteral("validation requested, but don't know how to validate ") + - filename + - " (" + - OUStringToOString(aFilterName, RTL_TEXTENCODING_UTF8) + - ")"; - CPPUNIT_FAIL(aMessage.getStr()); - } - } - discardDumpedLayout(); - if (mustCalcLayoutOf(filename)) - calcLayout(); - } + void reload(const char* pFilter, const char* filename, const char* pPassword = nullptr); /// Save the loaded document to a tempfile. Can be used to check the resulting docx/odt directly as a ZIP file. - void save(const OUString& aFilterName, utl::TempFile& rTempFile) - { - rTempFile.EnableKillingFile(); - uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); - utl::MediaDescriptor aMediaDescriptor; - aMediaDescriptor["FilterName"] <<= aFilterName; - if (!maFilterOptions.isEmpty()) - aMediaDescriptor["FilterOptions"] <<= maFilterOptions; - xStorable->storeToURL(rTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList()); - // TODO: for now, validate only ODF here - if (aFilterName == "writer8" - || aFilterName == "OpenDocument Text Flat XML") - { - validate(rTempFile.GetFileName(), test::ODF); - } - } + void save(const OUString& aFilterName, utl::TempFile& rTempFile); - void finish() - { - sal_uInt32 nEndTime = osl_getGlobalTimer(); - std::cout << (nEndTime - mnStartTime) << std::endl; - discardDumpedLayout(); - } + void finish(); /// Get page count. - int getPages() const - { - uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); - uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY); - uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY); - xCursor->jumpToLastPage(); - return xCursor->getPage(); - } + int getPages() const; /// Get shape count. - int getShapes() const - { - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage(); - return xDraws->getCount(); - } + int getShapes() const; /** * Given that some problem doesn't affect the result in the importer, we @@ -927,121 +394,32 @@ protected: * xml stream, and asserting an XPath expression. This method returns the * xml stream, so that you can do the asserting. */ - xmlDocUniquePtr parseExport(const OUString& rStreamName = OUString("word/document.xml")) - { - if (!mbExported) - return nullptr; - - return parseExportInternal( maTempFile.GetURL(), rStreamName ); - } + xmlDocUniquePtr parseExport(const OUString& rStreamName = OUString("word/document.xml")); /** * Returns an xml stream of an exported file. * To be used when the exporter doesn't create zip archives, but single files * (like Flat ODF Export) */ - xmlDocUniquePtr parseExportedFile() - { - auto stream(SvFileStream(maTempFile.GetURL(), StreamMode::READ | StreamMode::TEMPORARY)); - return parseXmlStream(&stream); - } - - std::unique_ptr<SvStream> parseExportStream(const OUString& url, const OUString& rStreamName) - { - // Read the stream we're interested in. - uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), url); - uno::Reference<io::XInputStream> xInputStream(xNameAccess->getByName(rStreamName), uno::UNO_QUERY); - CPPUNIT_ASSERT(xInputStream.is()); - std::unique_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true)); - return pStream; - } + xmlDocUniquePtr parseExportedFile(); - xmlDocUniquePtr parseExportInternal(const OUString& url, const OUString& rStreamName) - { - std::unique_ptr<SvStream> pStream(parseExportStream(url, rStreamName)); + std::unique_ptr<SvStream> parseExportStream(const OUString& url, const OUString& rStreamName); - xmlDocUniquePtr pXmlDoc = parseXmlStream(pStream.get()); - pXmlDoc->name = reinterpret_cast<char *>(xmlStrdup(reinterpret_cast<xmlChar const *>(OUStringToOString(url, RTL_TEXTENCODING_UTF8).getStr()))); - return pXmlDoc; - } + xmlDocUniquePtr parseExportInternal(const OUString& url, const OUString& rStreamName); /** * Helper method to return nodes represented by rXPath. */ - virtual void registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx) override - { - // docx - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("w"), BAD_CAST("http://schemas.openxmlformats.org/wordprocessingml/2006/main")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("v"), BAD_CAST("urn:schemas-microsoft-com:vml")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("mc"), BAD_CAST("http://schemas.openxmlformats.org/markup-compatibility/2006")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("wps"), BAD_CAST("http://schemas.microsoft.com/office/word/2010/wordprocessingShape")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("wpg"), BAD_CAST("http://schemas.microsoft.com/office/word/2010/wordprocessingGroup")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("wp"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("wp14"), BAD_CAST("http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("a"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/main")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("pic"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/picture")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("rels"), BAD_CAST("http://schemas.openxmlformats.org/package/2006/relationships")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("w14"), BAD_CAST("http://schemas.microsoft.com/office/word/2010/wordml")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("m"), BAD_CAST("http://schemas.openxmlformats.org/officeDocument/2006/math")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("ContentType"), BAD_CAST("http://schemas.openxmlformats.org/package/2006/content-types")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("lc"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("extended-properties"), BAD_CAST("http://schemas.openxmlformats.org/officeDocument/2006/extended-properties")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("a14"), BAD_CAST("http://schemas.microsoft.com/office/drawing/2010/main")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("c"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/chart")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("o"), BAD_CAST("urn:schemas-microsoft-com:office:office")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("w10"), BAD_CAST("urn:schemas-microsoft-com:office:word")); - // odt - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("office"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:office:1.0")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("style"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:style:1.0")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("text"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:text:1.0")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("table"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:table:1.0")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("draw"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:drawing:1.0")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("fo"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("config"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:config:1.0")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("xlink"), BAD_CAST("http://www.w3.org/1999/xlink")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("dc"), BAD_CAST("http://purl.org/dc/elements/1.1/")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("meta"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:meta:1.0")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("number"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("svg"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("chart"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:chart:1.0")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("dr3d"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("math"), BAD_CAST("http://www.w3.org/1998/Math/MathML")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("form"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:form:1.0")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("script"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:script:1.0")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("ooo"), BAD_CAST("http://openoffice.org/2004/office")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("ooow"), BAD_CAST("http://openoffice.org/2004/writer")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("oooc"), BAD_CAST("http://openoffice.org/2004/calc")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("dom"), BAD_CAST("http://www.w3.org/2001/xml-events")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("xforms"), BAD_CAST("http://www.w3.org/2002/xforms")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("xsd"), BAD_CAST("http://www.w3.org/2001/XMLSchema")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("xsi"), BAD_CAST("http://www.w3.org/2001/XMLSchema-instance")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("rpt"), BAD_CAST("http://openoffice.org/2005/report")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("of"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:of:1.2")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("xhtml"), BAD_CAST("http://www.w3.org/1999/xhtml")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("grddl"), BAD_CAST("http://www.w3.org/2003/g/data-view#")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("officeooo"), BAD_CAST("http://openoffice.org/2009/office")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("tableooo"), BAD_CAST("http://openoffice.org/2009/table")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("drawooo"), BAD_CAST("http://openoffice.org/2010/draw")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("calcext"), BAD_CAST("urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("loext"), BAD_CAST("urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("field"), BAD_CAST("urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("formx"), BAD_CAST("urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0")); - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("css3t"), BAD_CAST("http://www.w3.org/TR/css3-text/")); - // reqif-xhtml - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("reqif-xhtml"), BAD_CAST("http://www.w3.org/1999/xhtml")); - } + void registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx) override; - SwDoc* createSwDoc(const OUString& rDataDirectory = OUString(), const char* pName = nullptr) - { - if (rDataDirectory.isEmpty() || !pName) - loadURL("private:factory/swriter", nullptr); - else - load(rDataDirectory, pName); - - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - CPPUNIT_ASSERT(pTextDoc); - return pTextDoc->GetDocShell()->GetDoc(); - } + /** + * Creates a new document to be used with the internal sw/ API. + * + * Examples: + * SwDoc* pDoc = createSwDoc(); + * SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "test.fodt"); + */ + SwDoc* createSwDoc(const OUString& rDataDirectory = OUString(), const char* pName = nullptr); }; /** @@ -1055,10 +433,10 @@ protected: * use that macro instead. **/ inline void assertBorderEqual( - const table::BorderLine2& rExpected, const table::BorderLine2& rActual, + const css::table::BorderLine2& rExpected, const css::table::BorderLine2& rActual, const CppUnit::SourceLine& rSourceLine ) { - CPPUNIT_NS::assertEquals<util::Color>( rExpected.Color, rActual.Color, rSourceLine, "different Color" ); + CPPUNIT_NS::assertEquals<css::util::Color>( rExpected.Color, rActual.Color, rSourceLine, "different Color" ); CPPUNIT_NS::assertEquals<sal_Int16>( rExpected.InnerLineWidth, rActual.InnerLineWidth, rSourceLine, "different InnerLineWidth" ); CPPUNIT_NS::assertEquals<sal_Int16>( rExpected.OuterLineWidth, rActual.OuterLineWidth, rSourceLine, "different OuterLineWidth" ); CPPUNIT_NS::assertEquals<sal_Int16>( rExpected.LineDistance, rActual.LineDistance, rSourceLine, "different LineDistance" ); diff --git a/sw/qa/inc/swqahelperdllapi.h b/sw/qa/inc/swqahelperdllapi.h new file mode 100644 index 000000000000..1bda57679176 --- /dev/null +++ b/sw/qa/inc/swqahelperdllapi.h @@ -0,0 +1,20 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include <sal/types.h> + +#if defined(SWQAHELPER_DLLIMPLEMENTATION) +#define SWQAHELPER_DLLPUBLIC SAL_DLLPUBLIC_EXPORT +#else +#define SWQAHELPER_DLLPUBLIC SAL_DLLPUBLIC_IMPORT +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/uibase/dochdl/dochdl.cxx b/sw/qa/uibase/dochdl/dochdl.cxx index 1de97968da2e..88ad5f7545d0 100644 --- a/sw/qa/uibase/dochdl/dochdl.cxx +++ b/sw/qa/uibase/dochdl/dochdl.cxx @@ -11,8 +11,9 @@ #include <vcl/transfer.hxx> -#include <wrtsh.hxx> +#include <docsh.hxx> #include <swdtflvr.hxx> +#include <wrtsh.hxx> /// Covers sw/source/uibase/dochdl/ fixes. class SwUibaseDochdlTest : public SwModelTestBase diff --git a/sw/qa/uibase/shells/shells.cxx b/sw/qa/uibase/shells/shells.cxx index e8fc09418713..15e20fc4d8f9 100644 --- a/sw/qa/uibase/shells/shells.cxx +++ b/sw/qa/uibase/shells/shells.cxx @@ -9,6 +9,9 @@ #include <swmodeltestbase.hxx> +#include <com/sun/star/frame/XStorable.hpp> +#include <com/sun/star/packages/zip/ZipFileAccess.hpp> + #include <sfx2/dispatch.hxx> #include <sfx2/viewfrm.hxx> #include <vcl/GraphicObject.hxx> @@ -17,6 +20,7 @@ #include <editeng/adjustitem.hxx> #include <editeng/outlobj.hxx> #include <editeng/editobj.hxx> +#include <comphelper/processfactory.hxx> #include <IDocumentContentOperations.hxx> #include <cmdid.h> @@ -25,6 +29,8 @@ #include <wrtsh.hxx> #include <IDocumentDrawModelAccess.hxx> #include <drawdoc.hxx> +#include <unotxdoc.hxx> +#include <docsh.hxx> char const DATA_DIRECTORY[] = "/sw/qa/uibase/shells/data/"; diff --git a/sw/qa/unit/swmodeltestbase.cxx b/sw/qa/unit/swmodeltestbase.cxx new file mode 100644 index 000000000000..709d47321617 --- /dev/null +++ b/sw/qa/unit/swmodeltestbase.cxx @@ -0,0 +1,828 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <swmodeltestbase.hxx> + +#include <com/sun/star/container/XContentEnumerationAccess.hpp> +#include <com/sun/star/document/XFilter.hpp> +#include <com/sun/star/document/XImporter.hpp> +#include <com/sun/star/frame/Desktop.hpp> +#include <com/sun/star/packages/zip/ZipFileAccess.hpp> +#include <com/sun/star/text/XPageCursor.hpp> +#include <com/sun/star/text/XTextTable.hpp> +#include <com/sun/star/text/XTextViewCursorSupplier.hpp> + +#include <comphelper/processfactory.hxx> +#include <comphelper/sequence.hxx> +#include <rtl/ustrbuf.hxx> +#include <sfx2/app.hxx> +#include <unotools/mediadescriptor.hxx> +#include <unotools/streamwrap.hxx> +#include <unotools/ucbstreamhelper.hxx> + +#include <IDocumentLayoutAccess.hxx> +#include <docsh.hxx> +#include <rootfrm.hxx> +#include <unotxdoc.hxx> +#include <viewsh.hxx> + +using namespace css; + +void SwModelTestBase::paste(const OUString& aFilename, + uno::Reference<text::XTextRange> const& xTextRange) +{ + uno::Reference<document::XFilter> xFilter( + m_xSFactory->createInstance("com.sun.star.comp.Writer.RtfFilter"), uno::UNO_QUERY_THROW); + uno::Reference<document::XImporter> xImporter(xFilter, uno::UNO_QUERY_THROW); + xImporter->setTargetDocument(mxComponent); + uno::Sequence<beans::PropertyValue> aDescriptor(3); + aDescriptor[0].Name = "InputStream"; + std::unique_ptr<SvStream> pStream = utl::UcbStreamHelper::CreateStream( + m_directories.getURLFromSrc("/sw/qa/extras/") + aFilename, StreamMode::STD_READ); + CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, pStream->GetError()); + uno::Reference<io::XStream> xStream(new utl::OStreamWrapper(std::move(pStream))); + aDescriptor[0].Value <<= xStream; + aDescriptor[1].Name = "InsertMode"; + aDescriptor[1].Value <<= true; + aDescriptor[2].Name = "TextInsertModeRange"; + aDescriptor[2].Value <<= xTextRange; + CPPUNIT_ASSERT(xFilter->filter(aDescriptor)); +} + +SwModelTestBase::SwModelTestBase(const OUString& pTestDocumentPath, const char* pFilter) + : mpXmlBuffer(nullptr) + , mpTestDocumentPath(pTestDocumentPath) + , mpFilter(pFilter) + , mnStartTime(0) + , mbExported(false) +{ + maTempFile.EnableKillingFile(); +} + +void SwModelTestBase::setUp() +{ + test::BootstrapFixture::setUp(); + mxDesktop.set( + css::frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory()))); + SfxApplication::GetOrCreate(); +} + +void SwModelTestBase::tearDown() +{ + if (mxComponent.is()) + mxComponent->dispose(); + + test::BootstrapFixture::tearDown(); +} + +void SwModelTestBase::executeImportTest(const char* filename, const char* pPassword) +{ + // If the testcase is stored in some other format, it's pointless to test. + if (mustTestImportOf(filename)) + { + maTempFile.EnableKillingFile(false); + header(); + std::unique_ptr<Resetter> const pChanges(preTest(filename)); + load(mpTestDocumentPath, filename, pPassword); + verify(); + finish(); + maTempFile.EnableKillingFile(); + } +} + +void SwModelTestBase::executeLoadVerifyReloadVerify(const char* filename, const char* pPassword) +{ + maTempFile.EnableKillingFile(false); + header(); + std::unique_ptr<Resetter> const pChanges(preTest(filename)); + load(mpTestDocumentPath, filename, pPassword); + if (mustTestImportOf(filename)) + { + verify(); + } + postLoad(filename); + reload(mpFilter, filename, pPassword); + verify(); + finish(); + maTempFile.EnableKillingFile(); +} + +void SwModelTestBase::executeLoadReloadVerify(const char* filename, const char* pPassword) +{ + maTempFile.EnableKillingFile(false); + header(); + std::unique_ptr<Resetter> const pChanges(preTest(filename)); + load(mpTestDocumentPath, filename, pPassword); + postLoad(filename); + reload(mpFilter, filename, pPassword); + verify(); + finish(); + maTempFile.EnableKillingFile(); +} + +void SwModelTestBase::executeImportExport(const char* filename, const char* pPassword) +{ + maTempFile.EnableKillingFile(false); + header(); + std::unique_ptr<Resetter> const pChanges(preTest(filename)); + load(mpTestDocumentPath, filename, pPassword); + save(OUString::createFromAscii(mpFilter), maTempFile); + maTempFile.EnableKillingFile(false); + verify(); + finish(); + maTempFile.EnableKillingFile(); +} + +void SwModelTestBase::dumpLayout(const uno::Reference<lang::XComponent>& rComponent) +{ + // create the xml writer + mpXmlBuffer = xmlBufferCreate(); + xmlTextWriterPtr pXmlWriter = xmlNewTextWriterMemory(mpXmlBuffer, 0); + xmlTextWriterStartDocument(pXmlWriter, nullptr, nullptr, nullptr); + + // create the dump + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(rComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + pLayout->dumpAsXml(pXmlWriter); + + // delete xml writer + xmlTextWriterEndDocument(pXmlWriter); + xmlFreeTextWriter(pXmlWriter); +} + +void SwModelTestBase::discardDumpedLayout() +{ + if (mpXmlBuffer) + { + xmlBufferFree(mpXmlBuffer); + mpXmlBuffer = nullptr; + } +} + +void SwModelTestBase::calcLayout() +{ + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); + pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); +} + +int SwModelTestBase::getLength() const +{ + uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), + uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); + OUStringBuffer aBuf; + while (xParaEnum->hasMoreElements()) + { + uno::Reference<container::XEnumerationAccess> xRangeEnumAccess(xParaEnum->nextElement(), + uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xRangeEnum = xRangeEnumAccess->createEnumeration(); + while (xRangeEnum->hasMoreElements()) + { + uno::Reference<text::XTextRange> xRange(xRangeEnum->nextElement(), uno::UNO_QUERY); + aBuf.append(xRange->getString()); + } + } + return aBuf.getLength(); +} + +uno::Reference<container::XNameAccess> SwModelTestBase::getStyles(const OUString& aFamily) +{ + uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(mxComponent, + uno::UNO_QUERY); + uno::Reference<container::XNameAccess> xStyleFamilies + = xStyleFamiliesSupplier->getStyleFamilies(); + uno::Reference<container::XNameAccess> xStyleFamily(xStyleFamilies->getByName(aFamily), + uno::UNO_QUERY); + return xStyleFamily; +} + +uno::Reference<style::XAutoStyleFamily> SwModelTestBase::getAutoStyles(const OUString& aFamily) +{ + uno::Reference<style::XAutoStylesSupplier> xAutoStylesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<style::XAutoStyles> xAutoStyles(xAutoStylesSupplier->getAutoStyles()); + uno::Reference<style::XAutoStyleFamily> xAutoStyleFamily(xAutoStyles->getByName(aFamily), + uno::UNO_QUERY); + return xAutoStyleFamily; +} + +xmlDocUniquePtr SwModelTestBase::parseLayoutDump() +{ + if (!mpXmlBuffer) + dumpLayout(mxComponent); + + return xmlDocUniquePtr( + xmlParseMemory(reinterpret_cast<const char*>(xmlBufferContent(mpXmlBuffer)), + xmlBufferLength(mpXmlBuffer))); +} + +OUString SwModelTestBase::parseDump(const OString& aXPath, const OString& aAttribute) +{ + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + + xmlXPathContextPtr pXmlXpathCtx = xmlXPathNewContext(pXmlDoc.get()); + xmlXPathObjectPtr pXmlXpathObj + = xmlXPathEvalExpression(BAD_CAST(aXPath.getStr()), pXmlXpathCtx); + CPPUNIT_ASSERT_MESSAGE("xpath evaluation failed", pXmlXpathObj); + xmlChar* pXpathStrResult; + if (pXmlXpathObj->type == XPATH_NODESET) + { + xmlNodeSetPtr pXmlNodes = pXmlXpathObj->nodesetval; + CPPUNIT_ASSERT_EQUAL_MESSAGE("xpath should match exactly 1 node", 1, + xmlXPathNodeSetGetLength(pXmlNodes)); + xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0]; + if (aAttribute.getLength()) + pXpathStrResult = xmlGetProp(pXmlNode, BAD_CAST(aAttribute.getStr())); + else + pXpathStrResult = xmlNodeGetContent(pXmlNode); + } + else + { + // the xpath expression evaluated to a value, not a node + CPPUNIT_ASSERT_EQUAL_MESSAGE("attr name should not be supplied when xpath evals to a value", + sal_Int32(0), aAttribute.getLength()); + pXpathStrResult = xmlXPathCastToString(pXmlXpathObj); + CPPUNIT_ASSERT_MESSAGE("xpath result cannot be cast to string", pXpathStrResult); + } + + OUString aRet(reinterpret_cast<char*>(pXpathStrResult), xmlStrlen(pXpathStrResult), + RTL_TEXTENCODING_UTF8); + xmlFree(pXpathStrResult); + xmlFree(pXmlXpathObj); + xmlFree(pXmlXpathCtx); + + return aRet; +} + +bool SwModelTestBase::hasProperty(const uno::Reference<uno::XInterface>& obj, + const OUString& name) const +{ + uno::Reference<beans::XPropertySet> properties(obj, uno::UNO_QUERY_THROW); + return properties->getPropertySetInfo()->hasPropertyByName(name); +} + +xml::AttributeData SwModelTestBase::getUserDefineAttribute(const uno::Any& obj, + const OUString& name, + const OUString& rValue) const +{ + uno::Reference<container::XNameContainer> attrsCnt( + getProperty<uno::Any>(obj, "UserDefinedAttributes"), uno::UNO_QUERY_THROW); + + xml::AttributeData aValue; + attrsCnt->getByName(name) >>= aValue; + if (!rValue.isEmpty()) + CPPUNIT_ASSERT_EQUAL_MESSAGE("attribute of cell does not contain expected value", rValue, + aValue.Value); + + return aValue; +} + +int SwModelTestBase::getParagraphs(uno::Reference<text::XText> const& xText) +{ + int nRet = 0; + if (!xText.is()) + return nRet; + + uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xText->getText(), uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); + while (xParaEnum->hasMoreElements()) + { + xParaEnum->nextElement(); + nRet++; + } + return nRet; +} + +int SwModelTestBase::getParagraphs() +{ + uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); + return getParagraphs(xTextDocument->getText()); +} + +uno::Reference<text::XTextContent> +SwModelTestBase::getParagraphOrTable(int number, uno::Reference<text::XText> const& xText) const +{ + assert(number != 0); // this thing is 1-based + uno::Reference<container::XEnumerationAccess> paraEnumAccess; + if (xText.is()) + paraEnumAccess.set(xText, uno::UNO_QUERY); + else + { + uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY); + paraEnumAccess.set(textDocument->getText(), uno::UNO_QUERY); + } + uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration(); + for (int i = 1; i < number; ++i) + paraEnum->nextElement(); + uno::Reference<text::XTextContent> const xElem(paraEnum->nextElement(), uno::UNO_QUERY_THROW); + return xElem; +} + +uno::Reference<text::XTextRange> SwModelTestBase::getParagraph(int number, + const OUString& content) const +{ + uno::Reference<text::XTextRange> const xParagraph(getParagraphOrTable(number), + uno::UNO_QUERY_THROW); + if (!content.isEmpty()) + CPPUNIT_ASSERT_EQUAL_MESSAGE("paragraph does not have expected content", content, + xParagraph->getString()); + return xParagraph; +} + +sal_Int16 SwModelTestBase::getNumberingTypeOfParagraph(int nPara) +{ + sal_Int16 nNumberingType = -1; + uno::Reference<text::XTextRange> xPara(getParagraph(nPara)); + uno::Reference<beans::XPropertySet> properties(xPara, uno::UNO_QUERY); + bool isNumber = false; + properties->getPropertyValue("NumberingIsNumber") >>= isNumber; + if (isNumber) + { + uno::Reference<container::XIndexAccess> xLevels( + properties->getPropertyValue("NumberingRules"), uno::UNO_QUERY); + sal_Int16 nNumberingLevel = -1; + properties->getPropertyValue("NumberingLevel") >>= nNumberingLevel; + if (nNumberingLevel >= 0 && nNumberingLevel < xLevels->getCount()) + { + uno::Sequence<beans::PropertyValue> aPropertyValue; + xLevels->getByIndex(nNumberingLevel) >>= aPropertyValue; + auto pProp = std::find_if( + aPropertyValue.begin(), aPropertyValue.end(), + [](const beans::PropertyValue& rProp) { return rProp.Name == "NumberingType"; }); + if (pProp != aPropertyValue.end()) + nNumberingType = pProp->Value.get<sal_Int16>(); + } + } + return nNumberingType; +} + +uno::Reference<text::XTextRange> +SwModelTestBase::getParagraphOfText(int number, uno::Reference<text::XText> const& xText, + const OUString& content) const +{ + uno::Reference<text::XTextRange> const xParagraph(getParagraphOrTable(number, xText), + uno::UNO_QUERY_THROW); + if (!content.isEmpty()) + CPPUNIT_ASSERT_EQUAL_MESSAGE("paragraph does not contain expected content", content, + xParagraph->getString()); + return xParagraph; +} + +uno::Reference<beans::XPropertySet> +SwModelTestBase::getParagraphAnchoredObject(int const index, + uno::Reference<text::XTextRange> const& xPara) const +{ + uno::Reference<container::XContentEnumerationAccess> xContentEnumAccess(xPara, uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xContentEnum + = xContentEnumAccess->createContentEnumeration("com.sun.star.text.TextContent"); + for (int i = 1; i < index; ++i) + { + xContentEnum->nextElement(); + } + return uno::Reference<beans::XPropertySet>(xContentEnum->nextElement(), uno::UNO_QUERY); +} + +uno::Reference<text::XTextRange> +SwModelTestBase::getRun(uno::Reference<text::XTextRange> const& xParagraph, int number, + const OUString& content) const +{ + uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParagraph, uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration(); + for (int i = 1; i < number; ++i) + xRunEnum->nextElement(); + uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), uno::UNO_QUERY); + if (!content.isEmpty()) + CPPUNIT_ASSERT_EQUAL_MESSAGE("run does not contain expected content", content, + xRun->getString()); + return xRun; +} + +OUString SwModelTestBase::getFormula(uno::Reference<text::XTextRange> const& xRun) const +{ + uno::Reference<container::XContentEnumerationAccess> xContentEnumAccess(xRun, uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xContentEnum + = xContentEnumAccess->createContentEnumeration(""); + uno::Reference<beans::XPropertySet> xFormula(xContentEnum->nextElement(), uno::UNO_QUERY); + return getProperty<OUString>( + getProperty<uno::Reference<beans::XPropertySet>>(xFormula, "Model"), "Formula"); +} + +uno::Reference<table::XCell> +SwModelTestBase::getCell(uno::Reference<uno::XInterface> const& xTableIfc, OUString const& rCell, + OUString const& rContent) +{ + uno::Reference<text::XTextTable> const xTable(xTableIfc, uno::UNO_QUERY_THROW); + uno::Reference<table::XCell> const xCell(xTable->getCellByName(rCell), uno::UNO_SET_THROW); + if (!rContent.isEmpty()) + { + uno::Reference<text::XText> const xCellText(xCell, uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL_MESSAGE("cell does not contain expected content", rContent, + xCellText->getString()); + } + return xCell; +} + +uno::Reference<drawing::XShape> SwModelTestBase::getShape(int number) +{ + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); + uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(number - 1), uno::UNO_QUERY); + return xShape; +} + +uno::Reference<drawing::XShape> SwModelTestBase::getShapeByName(const OUString& aName) +{ + uno::Reference<drawing::XShape> xRet; + + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); + for (sal_Int32 i = 0; i < xDrawPage->getCount(); ++i) + { + uno::Reference<container::XNamed> xShape(xDrawPage->getByIndex(i), uno::UNO_QUERY); + if (xShape->getName() == aName) + { + xRet.set(xShape, uno::UNO_QUERY); + break; + } + } + + return xRet; +} + +uno::Reference<drawing::XShape> SwModelTestBase::getTextFrameByName(const OUString& aName) +{ + uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XNameAccess> xNameAccess = xTextFramesSupplier->getTextFrames(); + uno::Reference<drawing::XShape> xShape(xNameAccess->getByName(aName), uno::UNO_QUERY); + return xShape; +} + +void SwModelTestBase::setTestInteractionHandler(const char* pPassword, + std::vector<beans::PropertyValue>& rFilterOptions) +{ + OUString sPassword = OUString::createFromAscii(pPassword); + rFilterOptions.emplace_back(); + xInteractionHandler + = rtl::Reference<TestInteractionHandler>(new TestInteractionHandler(sPassword)); + uno::Reference<task::XInteractionHandler2> const xInteraction(xInteractionHandler.get()); + rFilterOptions[0].Name = "InteractionHandler"; + rFilterOptions[0].Value <<= xInteraction; +} + +void SwModelTestBase::loadURL(OUString const& rURL, const char* pName, const char* pPassword) +{ + if (mxComponent.is()) + mxComponent->dispose(); + + std::vector<beans::PropertyValue> aFilterOptions; + + if (pPassword) + { + setTestInteractionHandler(pPassword, aFilterOptions); + } + + if (!maImportFilterOptions.isEmpty()) + { + beans::PropertyValue aValue; + aValue.Name = "FilterOptions"; + aValue.Value <<= maImportFilterOptions; + aFilterOptions.push_back(aValue); + } + + if (!maImportFilterName.isEmpty()) + { + beans::PropertyValue aValue; + aValue.Name = "FilterName"; + aValue.Value <<= maImportFilterName; + aFilterOptions.push_back(aValue); + } + + // Output name early, so in the case of a hang, the name of the hanging input file is visible. + if (pName) + std::cout << pName << ":\n"; + mnStartTime = osl_getGlobalTimer(); + mxComponent = loadFromDesktop(rURL, "com.sun.star.text.TextDocument", + comphelper::containerToSequence(aFilterOptions)); + + if (pPassword) + { + CPPUNIT_ASSERT_MESSAGE("Password set but not requested", + xInteractionHandler->wasPasswordRequested()); + } + + discardDumpedLayout(); + if (pName && mustCalcLayoutOf(pName)) + calcLayout(); +} + +void SwModelTestBase::reload(const char* pFilter, const char* filename, const char* pPassword) +{ + uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); + OUString aFilterName = OUString::createFromAscii(pFilter); + utl::MediaDescriptor aMediaDescriptor; + aMediaDescriptor["FilterName"] <<= aFilterName; + if (!maFilterOptions.isEmpty()) + aMediaDescriptor["FilterOptions"] <<= maFilterOptions; + if (pPassword) + { + if (strcmp(pFilter, "Office Open XML Text")) + { + aMediaDescriptor["Password"] <<= OUString::createFromAscii(pPassword); + } + else + { + OUString sPassword = OUString::createFromAscii(pPassword); + css::uno::Sequence<css::beans::NamedValue> aEncryptionData{ + { "CryptoType", css::uno::makeAny(OUString("Standard")) }, + { "OOXPassword", css::uno::makeAny(sPassword) } + }; + aMediaDescriptor[utl::MediaDescriptor::PROP_ENCRYPTIONDATA()] <<= aEncryptionData; + } + } + xStorable->storeToURL(maTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList()); + uno::Reference<lang::XComponent> xComponent(xStorable, uno::UNO_QUERY); + xComponent->dispose(); + mbExported = true; + + std::vector<beans::PropertyValue> aFilterOptions; + if (pPassword) + { + setTestInteractionHandler(pPassword, aFilterOptions); + } + + if (!maImportFilterOptions.isEmpty()) + { + beans::PropertyValue aValue; + aValue.Name = "FilterOptions"; + aValue.Value <<= maImportFilterOptions; + aFilterOptions.push_back(aValue); + } + + if (!maImportFilterName.isEmpty()) + { + beans::PropertyValue aValue; + aValue.Name = "FilterName"; + aValue.Value <<= maImportFilterName; + aFilterOptions.push_back(aValue); + } + + mxComponent = loadFromDesktop(maTempFile.GetURL(), "com.sun.star.text.TextDocument", + comphelper::containerToSequence(aFilterOptions)); + if (pPassword) + { + CPPUNIT_ASSERT_MESSAGE("Password set but not requested", + xInteractionHandler->wasPasswordRequested()); + } + if (mustValidate(filename) || aFilterName == "writer8" + || aFilterName == "OpenDocument Text Flat XML") + { + if (aFilterName == "Office Open XML Text") + { + // too many validation errors right now + validate(maTempFile.GetFileName(), test::OOXML); + } + else if (aFilterName == "writer8" || aFilterName == "OpenDocument Text Flat XML") + { + validate(maTempFile.GetFileName(), test::ODF); + } + else if (aFilterName == "MS Word 97") + { + validate(maTempFile.GetFileName(), test::MSBINARY); + } + else + { + OString aMessage + = OStringLiteral("validation requested, but don't know how to validate ") + filename + + " (" + OUStringToOString(aFilterName, RTL_TEXTENCODING_UTF8) + ")"; + CPPUNIT_FAIL(aMessage.getStr()); + } + } + discardDumpedLayout(); + if (mustCalcLayoutOf(filename)) + calcLayout(); +} + +void SwModelTestBase::save(const OUString& aFilterName, utl::TempFile& rTempFile) +{ + rTempFile.EnableKillingFile(); + uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); + utl::MediaDescriptor aMediaDescriptor; + aMediaDescriptor["FilterName"] <<= aFilterName; + if (!maFilterOptions.isEmpty()) + aMediaDescriptor["FilterOptions"] <<= maFilterOptions; + xStorable->storeToURL(rTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList()); + // TODO: for now, validate only ODF here + if (aFilterName == "writer8" || aFilterName == "OpenDocument Text Flat XML") + { + validate(rTempFile.GetFileName(), test::ODF); + } +} + +void SwModelTestBase::finish() +{ + sal_uInt32 nEndTime = osl_getGlobalTimer(); + std::cout << (nEndTime - mnStartTime) << std::endl; + discardDumpedLayout(); +} + +int SwModelTestBase::getPages() const +{ + uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier( + xModel->getCurrentController(), uno::UNO_QUERY); + uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), + uno::UNO_QUERY); + xCursor->jumpToLastPage(); + return xCursor->getPage(); +} + +int SwModelTestBase::getShapes() const +{ + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xDraws = xDrawPageSupplier->getDrawPage(); + return xDraws->getCount(); +} + +xmlDocUniquePtr SwModelTestBase::parseExport(const OUString& rStreamName) +{ + if (!mbExported) + return nullptr; + + return parseExportInternal(maTempFile.GetURL(), rStreamName); +} + +xmlDocUniquePtr SwModelTestBase::parseExportedFile() +{ + auto stream(SvFileStream(maTempFile.GetURL(), StreamMode::READ | StreamMode::TEMPORARY)); + return parseXmlStream(&stream); +} + +std::unique_ptr<SvStream> SwModelTestBase::parseExportStream(const OUString& url, + const OUString& rStreamName) +{ + // Read the stream we're interested in. + uno::Reference<packages::zip::XZipFileAccess2> xNameAccess + = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), + url); + uno::Reference<io::XInputStream> xInputStream(xNameAccess->getByName(rStreamName), + uno::UNO_QUERY); + CPPUNIT_ASSERT(xInputStream.is()); + std::unique_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true)); + return pStream; +} + +xmlDocUniquePtr SwModelTestBase::parseExportInternal(const OUString& url, + const OUString& rStreamName) +{ + std::unique_ptr<SvStream> pStream(parseExportStream(url, rStreamName)); + + xmlDocUniquePtr pXmlDoc = parseXmlStream(pStream.get()); + pXmlDoc->name = reinterpret_cast<char*>(xmlStrdup( + reinterpret_cast<xmlChar const*>(OUStringToOString(url, RTL_TEXTENCODING_UTF8).getStr()))); + return pXmlDoc; +} + +void SwModelTestBase::registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx) +{ + // docx + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("w"), + BAD_CAST("http://schemas.openxmlformats.org/wordprocessingml/2006/main")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("v"), BAD_CAST("urn:schemas-microsoft-com:vml")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("mc"), + BAD_CAST("http://schemas.openxmlformats.org/markup-compatibility/2006")); + xmlXPathRegisterNs( + pXmlXpathCtx, BAD_CAST("wps"), + BAD_CAST("http://schemas.microsoft.com/office/word/2010/wordprocessingShape")); + xmlXPathRegisterNs( + pXmlXpathCtx, BAD_CAST("wpg"), + BAD_CAST("http://schemas.microsoft.com/office/word/2010/wordprocessingGroup")); + xmlXPathRegisterNs( + pXmlXpathCtx, BAD_CAST("wp"), + BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing")); + xmlXPathRegisterNs( + pXmlXpathCtx, BAD_CAST("wp14"), + BAD_CAST("http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("a"), + BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/main")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("pic"), + BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/picture")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("rels"), + BAD_CAST("http://schemas.openxmlformats.org/package/2006/relationships")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("w14"), + BAD_CAST("http://schemas.microsoft.com/office/word/2010/wordml")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("m"), + BAD_CAST("http://schemas.openxmlformats.org/officeDocument/2006/math")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("ContentType"), + BAD_CAST("http://schemas.openxmlformats.org/package/2006/content-types")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("lc"), + BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas")); + xmlXPathRegisterNs( + pXmlXpathCtx, BAD_CAST("extended-properties"), + BAD_CAST("http://schemas.openxmlformats.org/officeDocument/2006/extended-properties")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("a14"), + BAD_CAST("http://schemas.microsoft.com/office/drawing/2010/main")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("c"), + BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/chart")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("o"), + BAD_CAST("urn:schemas-microsoft-com:office:office")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("w10"), + BAD_CAST("urn:schemas-microsoft-com:office:word")); + // odt + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("office"), + BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:office:1.0")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("style"), + BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:style:1.0")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("text"), + BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:text:1.0")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("table"), + BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:table:1.0")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("draw"), + BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:drawing:1.0")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("fo"), + BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("config"), + BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:config:1.0")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("xlink"), BAD_CAST("http://www.w3.org/1999/xlink")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("dc"), BAD_CAST("http://purl.org/dc/elements/1.1/")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("meta"), + BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:meta:1.0")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("number"), + BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("svg"), + BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("chart"), + BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:chart:1.0")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("dr3d"), + BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("math"), + BAD_CAST("http://www.w3.org/1998/Math/MathML")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("form"), + BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:form:1.0")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("script"), + BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:script:1.0")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("ooo"), + BAD_CAST("http://openoffice.org/2004/office")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("ooow"), + BAD_CAST("http://openoffice.org/2004/writer")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("oooc"), BAD_CAST("http://openoffice.org/2004/calc")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("dom"), + BAD_CAST("http://www.w3.org/2001/xml-events")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("xforms"), BAD_CAST("http://www.w3.org/2002/xforms")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("xsd"), BAD_CAST("http://www.w3.org/2001/XMLSchema")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("xsi"), + BAD_CAST("http://www.w3.org/2001/XMLSchema-instance")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("rpt"), + BAD_CAST("http://openoffice.org/2005/report")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("of"), + BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:of:1.2")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("xhtml"), BAD_CAST("http://www.w3.org/1999/xhtml")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("grddl"), + BAD_CAST("http://www.w3.org/2003/g/data-view#")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("officeooo"), + BAD_CAST("http://openoffice.org/2009/office")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("tableooo"), + BAD_CAST("http://openoffice.org/2009/table")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("drawooo"), + BAD_CAST("http://openoffice.org/2010/draw")); + xmlXPathRegisterNs( + pXmlXpathCtx, BAD_CAST("calcext"), + BAD_CAST("urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0")); + xmlXPathRegisterNs( + pXmlXpathCtx, BAD_CAST("loext"), + BAD_CAST("urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0")); + xmlXPathRegisterNs( + pXmlXpathCtx, BAD_CAST("field"), + BAD_CAST("urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0")); + xmlXPathRegisterNs( + pXmlXpathCtx, BAD_CAST("formx"), + BAD_CAST("urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("css3t"), + BAD_CAST("http://www.w3.org/TR/css3-text/")); + // reqif-xhtml + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("reqif-xhtml"), + BAD_CAST("http://www.w3.org/1999/xhtml")); +} + +SwDoc* SwModelTestBase::createSwDoc(const OUString& rDataDirectory, const char* pName) +{ + if (rDataDirectory.isEmpty() || !pName) + loadURL("private:factory/swriter", nullptr); + else + load(rDataDirectory, pName); + + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + return pTextDoc->GetDocShell()->GetDoc(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |