97 Commits
Author SHA1 Message Date
Xisco Fauli 6985cb97b6 BootstrapFixture: move validate to UnoApiTest and adapt it a bit
it's the only place where it's used

Change-Id: Iaf74e959dcedc27ab1781157e1d2f01a41be5e8c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198590
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-02-03 16:50:18 +01:00
Xisco Fauli 374e7cd1a4 resolves tdf#149567: odfvalidator: do not validate password protected files
Running "java -jar odfvalidator-0.9.0-jar-with-dependencies.jar test.odt"
it fails with
ene 30, 2026 1:09:49 P. M. org.odftoolkit.odfdom.pkg.ZipHelper entriesToMap
INFORMACIÓN: ZIP ENTRY not found
/home/xisco/Descargas/test.odt:  Fatal: ZIP entry 'mimetype': only DEFLATED entries can have EXT descriptor
/home/xisco/Descargas/test.odt:  Fatal: The document is encrypted. Validation of encrypted documents is not supported.
/home/xisco/Descargas/test.odt/META-INF/manifest.xml[2,194]:  Error: unexpected attribute "manifest:version"
/home/xisco/Descargas/test.odt/META-INF/manifest.xml[6,136]:  Error: tag name "manifest:start-key-generation" is not allowed. Possible tag names are: <key-derivation>

Change-Id: I185e9cd5227a07cd7fd07379c8925b9a8296d0a3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198426
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2026-01-30 14:51:36 +01:00
Xisco Fauli b2cbeda648 related tdf#149567: odfvalidator: do not validate FODT files
Running "java -jar odfvalidator-0.9.0-jar-with-dependencies.jar test.odt"
it fails with
org.odftoolkit.odfdom.pkg.OdfValidationException; The ODF package 'file:///home/xisco/Descargas/test.fodt' shall be a ZIP file!
	at org.odftoolkit.odfdom.pkg.OdfPackage.readZip(OdfPackage.java:542)
	at org.odftoolkit.odfdom.pkg.OdfPackage.initializeZip(OdfPackage.java:519)
	at org.odftoolkit.odfdom.pkg.OdfPackage.<init>(OdfPackage.java:293)
	at org.odftoolkit.odfdom.pkg.OdfPackage.loadPackage(OdfPackage.java:456)
	at org.odftoolkit.odfvalidator.ODFFileValidator.getPackage(ODFFileValidator.java:58)
	at org.odftoolkit.odfvalidator.ODFRootPackageValidator.getPackage(ODFRootPackageValidator.java:59)
	at org.odftoolkit.odfvalidator.ODFPackageValidator._validate(ODFPackageValidator.java:101)
	at org.odftoolkit.odfvalidator.ODFPackageValidator.validate(ODFPackageValidator.java:86)
	at org.odftoolkit.odfvalidator.ODFValidator.validateFile(ODFValidator.java:180)
	at org.odftoolkit.odfvalidator.ODFValidator.validate(ODFValidator.java:129)
	at org.odftoolkit.odfvalidator.Main.main(Main.java:230)

Change-Id: I0df2dcaa195ca4b145e870b276eef6962db7dad6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198410
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2026-01-30 14:18:29 +01:00
Noel Grandin 4da8f78016 we dont need this officeotron workaround anymore
ever since
    commit e4978f9079cda7abb7bb424503d780566c728adf
    Author: Karthik Godha <karthik.godha@collabora.com>
    Date:   Mon Nov 24 19:16:51 2025 +0530
    Update OOXML schema to follow ECMA-376 5th edition

which was part of officeotron 0.8.1

Change-Id: I0b9f8ff0d513ced06cda9f4257454ee756b28322
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197175
Reviewed-by: Michael Stahl <michael.stahl@collabora.com>
Tested-by: Jenkins
2026-01-14 07:43:29 +01:00
Noel Grandin 49a1acfd91 update to officeotron 0.8.8
which means we no longer need the workaround

Change-Id: Ibdc47750a7d5eacc9a1e2251e145379f0464b7f4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197174
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2026-01-14 07:43:17 +01:00
Justin Luth de25c6c546 tdf#165207 xlsx/pptx: always use errata uri in docProps/core.xml
This fixes a longstanding bug that has gone unnoticed
since nobody saves to the "Office Open XML" filters
and the problem is only seen in MS Office.

So what does this patch fix?
Basically, all of the meta-data was not being read by MS Office,
which primarily means no create/modify dates, subject, title etc.
Every time we saved to OOXML formats (except OOXML 2007),
we caused MS Office to be incapable
of understanding anything in docProps/core.xml.
Telltale sign: when MS Office round-trips
with an added docProps/core0.xml.

The spec says that ISO 29500 formats should be using
    officedocuments/2006/relationships/metadata/core-properties
and thus our untouched 2010-era coding
specified all of that for export (and more recently for import).

> 2.1.33 Part 1 Section 15.2.11.1, Core File Properties Part
> The standard specifies a source relationship
> for the Core File Properties part as follows:
> .../officedocument/.../core-properties.
> HOWEVER: Office uses the following source relationship
> for the Core File Properties part:
> .../package/.../core-properties.

Thus reality is much different than the spec,
so throw the spec out the window and always write
    package/2006/relationships/metadata/core-properties

Bug 165207 doesn't affect LO in any way - it only affect MSOffice.
If there was already a unit test writing out to _rels/.rels
I would have added a test for this, but since there isn't
I won't bother since I don't see any value in doing so.

Change-Id: I582448adb568ecb630f2fd64712ce372875f71df
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195014
Tested-by: Jenkins
Reviewed-by: Justin Luth <jluth@mail.com>
2025-12-05 23:30:13 +01:00
Justin Luth e4b629c1ee tdf#165207 tdf#164201 docx: always use errata uri in docProps/core.xml
This patch effectively replaces (and thus contains a revert of)
25.8 commit d97085cc6c.

This fixes a longstanding bug that became more prominent in 7.6
when mstahl renamed docx filters to promote Word 2010,
and then again in 25.2 when my bug 164201 patches
told command-line convert-to to export using Word 2010 filter,
and finally in 25.8 for interactive round-tripping of existing files.

So what does this patch fix?
Basically, all of the meta-data was not being read by MS Word,
which primarily means no create/modify dates, subject, title etc.
Every time we saved to DOCX format (except DOCX 2007), we caused Word
to be incapable of understanding anything in docProps/core.xml.
Telltale sign: when MS Word round-trips with added docProps/core0.xml.

The spec says that DOCX 2010 should be using
    officedocuments/2006/relationships/metadata/core-properties
and thus our untouched 2010-era coding
specified all of that for import and export.

But reality seems to be much different than the spec,
(and some errata-sounding documentation agrees),
so throw the spec out the window and always write
    package/2006/relationships/metadata/core-properties
(but only for DOCX - Excel and Powerpoint follow the spec...)

That meant that I also had to rewrite our import logic,
but that was already suggested by mstahl in
https://gerrit.libreoffice.org/c/core/+/178048

Bug 165207 doesn't affect LO in any way.
If there was already a unit test writing out to _rels/.rels
I would have added a test for this, but since there isn't
I won't bother since I don't see any value in doing so.
Plus, we already have validity checks to cover this kind of stuff.

The retained the unit test ensures import logic is still correct:
make CppunitTest_sw_ooxmlexport20 CPPUNIT_TEST_NAME=testTdf158855

A uiwriter4 test depends on the previous patch in this bug report.
(See earlier versions of my patchset for details)

officeotron sounds like they WANT to report invalidation errors
based only on spec, so no point in trying to "submit a patch".

Change-Id: Ib76803bf0c9f3791f9078846f00c118099ef67cd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181463
Tested-by: Jenkins
Reviewed-by: Justin Luth <jluth@mail.com>
2025-02-22 18:42:40 +01:00
Xisco Fauli 746c35baf6 ODF 1.4: schema: rename to OpenDocument-v1.3*
Change-Id: I83ac72accf2bbddd3ca74790654327bb9e86dba4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172765
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2024-09-24 14:21:15 +02:00
Mike Kaganski 275aebc508 tdf#163064: pic element is required here, after all
In commit cf15306ccf (ERROR: Invalid
content was found starting with element 'p:pic'., 2014-12-22), the
pic element inside the oleObj element was only alloswed for the old
revision of ECMA-736 export, because that was considered invalid by
officeotron. However, as of ECMA-376-1:2016,  this element is
mandatory; CT_OleObject definition in Annex A has:

 <xsd:element name="pic" type="CT_Picture" minOccurs="1" maxOccurs="1"/>

and Annex L (Primer) has L.7.2.5 "Embeddings in a PresentationML
Document" saying:

 The oleObj element shall have a pic child element that (optionally)
 contains the image data to be used in place of loading the actual
 object data.

The omission of this in the export is the reason of tdf#163064. So
here I filter out the error from the validation results, which is
not ideal (I have no way to know if the found pic is really in the
oleObj, or somewhere else), but a lesser evil, compared to required
exclusion of all tests that export OLE objects.

Change-Id: Ia73a49da7347e8ff22c626e211b55ba1e0625070
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173761
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
2024-09-21 22:33:12 +02:00
Xisco Fauli 83a8d5a275 BootstrapFixture: get rid of mxComponentContext
Change-Id: I0318485c3c0159277e47096e0c7e0df8ed109ea4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169865
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2024-07-02 15:35:00 +02:00
Noel Grandin 008f4273ae loplugin:ostr in test
Change-Id: Ie261167fc3e1ed9073210e0f8b179455da340c83
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167620
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
2024-05-14 11:47:53 +02:00
Noel Grandin 00659bcdbb improve readability of VirtualDevice constructor
(a) It is not obvious what DeviceFormat::DEFAULT means
(b) There are two parameters (each with two states), but only really 2
possible overall states

So
(1) use more useful names
(2) combine the two parameters into one enum

Change-Id: Ic0595b39e032cc9e019b88326389d055b977da00
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146589
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-02-07 10:19:32 +00:00
Noel Grandin 4b95451f85 split utl::TempFile into fast and named variants
which makes it easier to know what each variant requires
to stay on it's happy path

Change-Id: I3275a2543573367714bc78092e882f6535507285
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140469
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-09-29 09:11:18 +02:00
Noel Grandin 5200a73627 use more string_view in various
found by examining uses of OUString::copy() for likely places

Change-Id: I6ff20e7b273ad6005410b82719183c1122f8c018
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133617
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-05-01 08:30:18 +02:00
Luboš Luňák 2e33af67e0 move HAVE_EXPORT_VALIDATION from config_features.h
So that so much stuff doesn't get rebuilt on --with-java change.

Change-Id: I87388590a4fd218fd22e68ba0edd290831f6f0fb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133570
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2022-04-29 06:55:04 +02:00
Mike Kaganski a144acfdf6 Fix some DPI-dependent tests
Change-Id: I3c669802ac558379498c877c8ac4796bbff80f82
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131096
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
2022-03-07 12:53:27 +01:00
Michael Stahl ba8fe774a1 test: capture stderr of odfvalidator too
It will be used when https://github.com/tdf/odftoolkit/pull/121 is
merged.

Change-Id: I78d2b52ffc05fdd446ea7b673c2a7ebab26efc2a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120943
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2021-08-24 18:58:32 +02:00
Stephan Bergmann e854abe076 Avoid external processes picking up instdir/program/libnspr4.so
...which is a problem in ASan builds, as seen with a failing
CppunitTest_sd_import_tests (among lots of other similarly failing tests):

> Exception in thread "main" java.lang.UnsatisfiedLinkError: /usr/lib/jvm/java-11-openjdk-11.0.11.0.9-5.fc34.x86_64/lib/libsystemconf.so: ~/lo/core/instdir/program/libnspr4.so: undefined symbol: __asan_option_detect_stack_use_after_return
> 	at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
> 	at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2442)
> 	at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2498)
> 	at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2694)
> 	at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2648)
> 	at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:830)
> 	at java.base/java.lang.System.loadLibrary(System.java:1873)
> 	at java.base/java.security.SystemConfigurator$1.run(SystemConfigurator.java:67)
> 	at java.base/java.security.SystemConfigurator$1.run(SystemConfigurator.java:65)
> 	at java.base/java.security.AccessController.doPrivileged(Native Method)
> 	at java.base/java.security.SystemConfigurator.<clinit>(SystemConfigurator.java:65)
> 	at java.base/java.security.Security.initialize(Security.java:208)
> 	at java.base/java.security.Security$2.run(Security.java:93)
> 	at java.base/java.security.Security$2.run(Security.java:91)
> 	at java.base/java.security.AccessController.doPrivileged(Native Method)
> 	at java.base/java.security.Security.<clinit>(Security.java:91)
> 	at java.base/sun.security.jca.ProviderList.<init>(ProviderList.java:176)
> 	at java.base/sun.security.jca.ProviderList$2.run(ProviderList.java:94)
> 	at java.base/sun.security.jca.ProviderList$2.run(ProviderList.java:92)
> 	at java.base/java.security.AccessController.doPrivileged(Native Method)
> 	at java.base/sun.security.jca.ProviderList.fromSecurityProperties(ProviderList.java:91)
> 	at java.base/sun.security.jca.Providers.<clinit>(Providers.java:54)
> 	at java.base/java.security.SecureRandom.getDefaultPRNG(SecureRandom.java:264)
> 	at java.base/java.security.SecureRandom.<init>(SecureRandom.java:219)
> 	at java.base/java.util.UUID$Holder.<clinit>(UUID.java:101)
> 	at java.base/java.util.UUID.randomUUID(UUID.java:147)
> 	at org.probatron.officeotron.sessionstorage.Store.putZippedResource(Unknown Source)
> 	at org.probatron.officeotron.CommandLineSubmission.<init>(Unknown Source)
> 	at org.probatron.officeotron.Driver.main(Unknown Source)
> warn:svl.items:1258842:1258842:svl/source/items/itempool.cxx:358: old secondary pool: EditEngineItemPool of pool: XOutdevItemPool must be empty.
> ~/lo/core/test/source/bootstrapfixture.cxx:232:SdImportTest::testDocumentLayout
> equality assertion failed
> - Expected: 0
> - Actual  : 256
> - failed to execute: sh ~/lo/core/bin/officeotron.sh ~/lo/tmp/SdImportTest__testDocumentLayout_16w8dw.tmp > ~/lo/tmp/SdImportTest__testDocumentLayout_16w8dy.tmp

The solution reuses the arg-env bootstrap variable already used by
test::OfficeConnection::setUp (unotest/source/cpp/officeconnection.cxx) and for
that makes test::getArgumnet available outside Library_unotest.  (For
simplicity, it adds the relevant gb_CppunitTest_add_arguments calls
unconditionally to the various *.mk files, even though the data is only used
conditionally for non-_WIN32 in test::BootstrapFixture::validate in
test/source/bootstrapfixture.cxx, at least for now.)

Not sure what exactly started to cause this issue now for my ASan builds on
Fedora 34.

Change-Id: I7a4d6c0e36b94935442c6c91d5ee967fcad61763
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119317
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-07-21 15:27:02 +02:00
Michael Stahl 7f3c9da5a0 schema: update to ODF 1.3 OS
Change-Id: I97e28612aeeebed709da9ad621250c6b26e55f92
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116734
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2021-06-10 19:07:36 +02:00
Mike Kaganski 6dfc7354d7 Exclude tests based on device color depth, not RDP
After 5c9ba1f47d, the failures on Jenkins
(see 21191d0d89) made it apparent that
(at least some of) Jenkins builds also run in RDP sessions. Since the
tests excluded in commit 9c6142ec26 never
failed in Jenkins builds before, it is wrong to exclude all those tests
in all RDP sessions: our CI would not test those on Windows.

In the meanwhile, I discovered that the system that failed the tests
actually had 16-bit color depth, despite RDP being configured to use
32-bit colors; that was the reason why the colors were modified on
roundtrip. So it is better to test the actual problem to exclude tests.

This reimplements the check that was introduced in commit
9c6142ec26 to test default virtual device
color depth.

Change-Id: I329a3e2d8eca21732c77dcacf15394d1246b2e18
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113460
Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-04-01 17:39:54 +02:00
Stephan Bergmann 042033f1e6 loplugin:stringviewparam: operator +
Change-Id: I044dd21b63d7eb03224675584fa143009c6b6008
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108418
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2020-12-29 16:42:33 +01:00
Stephan Bergmann 62128cda92 Strength-reduce some OUStringToOString("..."+...)
...to "..."+OUStringToOString(...), in preparation of making OUStringToOString
take a std::u16string_view

Change-Id: Ic01ca249d4d0eb58ac959ffdf96471308a3715dc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107600
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2020-12-11 17:33:57 +01:00
Mike Kaganski 269e36ece4 Introduce BootstrapFixture::IsDefaultDPI convenience function
It should be used to conditionally disable tests that are unreliable
in non-default-DPI environments. The workaround implemented by use
of the function should be temporary, until a proper fix is found.

Change-Id: Ie236226fcfd0ffb054149efc2b7a1727506c4ad0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106661
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2020-11-26 10:59:15 +01:00
Miklos Vajna b3c18cdc07 test: log the validator cmdline
The validator cmdline is fairly nontrivial, log it so that in case it
fails, one can invoke it manually without having to hunt down the string
in a debugger.

Change-Id: Id18c6d67f1b3b78da31e8be8c60f703623b80309
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89875
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
2020-03-03 13:43:58 +01:00
Miklos Vajna 75a7932bb4 test: move component context from subclasses to BootstrapFixture
To avoid duplication.

Change-Id: I0ee7c26d5d55bd868ead04c77e7f4ef2582f90e2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88138
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2020-02-07 09:13:50 +01:00
Caolán McNamara 3d826d780a make some headers private
as shown with ./bin/find-headers-to-move-inside-modules.py

Change-Id: I7662417e76fe00c0fc352957560e104b6c2a3d61
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87850
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2020-02-03 20:24:00 +01:00
Gabor Kelemen 7ac769c1a9 tdf#42949 Fix IWYU warnings in test/
Found with bin/find-unneeded-includes
Only removal proposals are dealt with here.

Change-Id: Id1ee9b6d44315443d023bdfbf9ae8e5aa2158ab2
Reviewed-on: https://gerrit.libreoffice.org/85171
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2019-12-19 10:20:04 +01:00
Noel Grandin f13c6ad5f0 new loplugin:bufferadd
look for OUStringBuffer append sequences that can be turned
into creating an OUString with + operations

Change-Id: Ica840dc096000307b4a105fb4d9ec7588a15ade6
Reviewed-on: https://gerrit.libreoffice.org/80809
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-10-15 14:33:57 +02:00
Noel Grandin cdbac696fb simplify "a = a +" to "a +="
mostly so that my stringadd loplugin can point out places to improve

Change-Id: I9920ee1c99cdb6b811ba67ff9d8e32aa261884b5
Reviewed-on: https://gerrit.libreoffice.org/80618
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-10-11 07:18:11 +02:00
Michael Stahl ecce69dc55 test: check validator exit code *after* checking validator output
ODF validator may now actually exit with non-0 since commit
b14e2f6c63c18894286c99ee8dde9070e24b41c2 - look for validation errors in
this case too.

Change-Id: I36f4437c54d9a60afee0663a0b9be206773c5378
Reviewed-on: https://gerrit.libreoffice.org/75964
Tested-by: Jenkins
Reviewed-by: Michael Stahl <Michael.Stahl@cib.de>
2019-07-20 16:50:37 +02:00
Stephan Bergmann 206b5b2661 New loplugin:external
...warning about (for now only) functions and variables with external linkage
that likely don't need it.

The problems with moving entities into unnamed namespacs and breaking ADL
(as alluded to in comments in compilerplugins/clang/external.cxx) are
illustrated by the fact that while

  struct S1 { int f() { return 0; } };
  int f(S1 s) { return s.f(); }
  namespace N {
    struct S2: S1 { int f() { return 1; } };
    int f(S2 s) { return s.f(); }
  }
  int main() { return f(N::S2()); }

returns 1, both moving just the struct S2 into an nunnamed namespace,

  struct S1 { int f() { return 0; } };
  int f(S1 s) { return s.f(); }
  namespace N {
    namespace { struct S2: S1 { int f() { return 1; } }; }
    int f(S2 s) { return s.f(); }
  }
  int main() { return f(N::S2()); }

as well as moving just the function f overload into an unnamed namespace,

  struct S1 { int f() { return 0; } };
  int f(S1 s) { return s.f(); }
  namespace N {
    struct S2: S1 { int f() { return 1; } };
    namespace { int f(S2 s) { return s.f(); } }
  }
  int main() { return f(N::S2()); }

would each change the program to return 0 instead.

Change-Id: I4d09f7ac5e8f9bcd6e6bde4712608444b642265c
Reviewed-on: https://gerrit.libreoffice.org/60539
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-09-17 09:05:38 +02:00
Stephan Bergmann e7a3329fd0 DeInitVCL in PythonTest
After b9757f5cfd "loplugin:useuniqueptr in
vcl/svdata" ASan/UBSan builds started to fail (like
<https://ci.libreoffice.org//job/lo_ubsan/1025/>) at the end of
PythonTest_dbaccess_python (and probably other PythonTests), when during exit
the static utl::ConfigManager instance already happens to be destroyed by the
time the static ImplSVData's mpSettingsConfigItem is destroyed (which would
normally be cleared during DeInitVCL, if PythonTests would call that, and which
in the past had thus simply been leaked in PythonTests when that
mpSettingsConfigItem was a plain pointer instead of std::unique_ptr).

So ensure that PythonTests that initialize VCL also call DeInitVCL, via a new
private_deinitTestEnvironment, complementing the existing
private_initTestEnvironment.

However, while private_initTestEnvironment is called once (typically via
UnoInProcess.setUp, which internally makes sure to only call it once) as soon as
the first executed test needs it, private_deinitTestEnvironment must be called
once after the lasts test needing it has executed.  The only way that I found to
do that is to override unittest.TextTestResult's stopTestRun method, which is
called once after all tests have been executed.  Hence a new test runner setup
in unotest/source/python/org/libreoffice/unittest.py that is now called from
solenv/gbuild/PythonTest.mk.

That revealed a few places in PythonTests that didn't yet close/delete documents
that they had opened, which has now been added.

One remaining problem then is that classes like SwXTextDocument and friends call
Application::GetSolarMutex from their dtors, via sw::UnoImplPtrDeleter (a "Smart
pointer class ensuring that the pointed object is deleted with a locked
SolarMutex", sw/inc/unobaseclass.hxx).  That means that any PyUNO proxies to
such C++ objects that remain alive after private_deinitTestEnvironment will
cause issues at exit, when Python does a final garbage collection of those
objects.  The ultimate fix will be to remove that unhelpful UnoImplPtrDeleter
and its locking of SolarMutex from the dtors of UNO objects; until then, the
Python code is now sprinkled with some HACKs to make sure all those PyUNO
proxies are released in a timely fashion (see the comment in
unotest/source/python/org/libreoffice/unittest.py for details).  (Also, it would
probably help if UnoInProcess didn't keep a local self.xDoc around referencing
(just) the last result of calling one of its open* methods, confusingly making
it the responsibility of UnoInProcess to close that one document while making it
the responsibility of the test code making the other UnoInProcess.open* calls to
close any other documents.)

Change-Id: Ief27c81e2b763e9be20cbf3234b68924315f13be
Reviewed-on: https://gerrit.libreoffice.org/60100
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-09-07 07:31:48 +02:00
Gabor Kelemen 82828c6c40 Add missing sal/log.hxx headers
rtl/string.hxx and rtl/ustring.hxx both unnecessarily #include <sal/log.hxx> (and don't make use of it themselves), but many other files happen to depend on it.
This is a continuation of commit 6ff2d84ade to be able to remove those unneeded includes.

This commit adds missing headers to every file found by:
grep -FwL sal/log.hxx $(git grep -Elw 'SAL_INFO|SAL_INFO_IF|SAL_WARN|SAL_WARN_IF|SAL_DETAIL_LOG_STREAM|SAL_WHERE|SAL_STREAM|SAL_DEBUG')
to directories from test to vbahelper

Change-Id: Ia7f773511624099505d6a36a8d6e23c0cde4a737
Reviewed-on: https://gerrit.libreoffice.org/58225
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
2018-08-02 17:58:40 +02:00
Michael Stahl 6947cee055 schema: ODF 1.3 + libreoffice extensions schema
Build this with RelaxNG <include> feature instead of a complete schema.

This isn't bad but could work better if the schema were a little more
modular...

In order to track down all the uses of extension namespaces like loext,
invoke the validator without "-e".

Change-Id: I92a666fc54c25d66cea38decdc188d60de2a0b74
Reviewed-on: https://gerrit.libreoffice.org/56488
Tested-by: Jenkins
Reviewed-by: Michael Stahl <Michael.Stahl@cib.de>
2018-06-29 12:59:55 +02:00
Michael Stahl e8b1dab67f test: invoke ODF validator with custom schemas
This requires a new validator jar for the -m flag to specify
MathML schema.

Change-Id: If99cf70f386a16a90ba676f8f5ff65a537c9ce56
Reviewed-on: https://gerrit.libreoffice.org/56487
Tested-by: Jenkins
Reviewed-by: Michael Stahl <Michael.Stahl@cib.de>
2018-06-29 12:59:30 +02:00
Noel Grandin 23b0844973 loplugin: look for CPPUNIT_ASSERT_EQUALS with params swapped
idea originally from either tml or moggi, can't remember which

Change-Id: Id78d75035036d3aa1666e33469c6eeb38f9e624d
Reviewed-on: https://gerrit.libreoffice.org/55126
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-06-01 09:14:25 +02:00
Michael Stahl e57462cd7b test: force EnableHeadlessMode() for PythonTest
Clearly this should be on, but we can't easily pass in a command line
argument like is done in CppunitTest because that doesn't end up in
rtl_getAppCommandArg(), which is empty since it's the python.bin process,
so we'd have to find a way to get the argv from python first...

Change-Id: I9321a9f933f388a659643898e0dc38f295f2068c
Reviewed-on: https://gerrit.libreoffice.org/54083
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Stahl <Michael.Stahl@cib.de>
2018-05-11 10:15:05 +02:00
Stephan Bergmann 34307a8a7d loplugin:includeform: test
Change-Id: Ibcbb5b002e8326c484547a825cb295d0f5158a3b
2017-10-23 22:45:50 +02:00
Jan-Marek Glogowski 141fe1c5e7 Process all pending events during Cppunit setUp
Larger unit tests collect a lot of events, which are just processed
on shutdown. But since the Scheduler is just an unsorted linked
list, processing these in order is O(n^2) for lookup, which really
adds up, e.g. sw_ooxmlexport8 has 35047 tasks on shutdown.

So this just processes all pending events before running each unit
test.

Also adds missing spellchecking components to some calc tests.

Change-Id: Icf12146015afc17a1f52f79c18f248b72650ad46
Reviewed-on: https://gerrit.libreoffice.org/43199
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
2017-10-06 19:21:19 +02:00
Caolán McNamara b1d829e52e move resmgr to unotools
and the vast majority of translations is to the ui language so default
ctor with that arg

and now drop OModuleResourceClient

Change-Id: I3b85a560ffdfe5f019c2271ac56a5fe4a361522b
2017-08-01 13:42:21 +01:00
Stephan Bergmann 85c6f985ce loplugin:casttovoid: test
Change-Id: I7e948fe35ce26eb5a3b627ac75f579826dd5ff9d
2017-07-02 22:28:19 +02:00
Chris Sherlock 201f05f9bf vcl: move RegisterDisplay() from ErrorHandler to ErrorRegistry
It is the error registry that should register the display, not
the error handler. Move this function to the class that is
responsible for it.

Change-Id: I95ca1662b907a7f38a42a39ec729b35fd530bb79
Reviewed-on: https://gerrit.libreoffice.org/36853
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Chris Sherlock <chris.sherlock79@gmail.com>
2017-04-27 08:12:28 +02:00
Chris Sherlock 3b85b72d64 errinf.hxx moved out of tools and into vcl module
ErrorInfo has a hard depency on VCL, yet is in the tools package. It is more
appropriate to have it reside in the VCL module.

Change-Id: Ica54a46c3a7f86cf0331ed7245234bea69c05650
Reviewed-on: https://gerrit.libreoffice.org/36839
Reviewed-by: Chris Sherlock <chris.sherlock79@gmail.com>
Tested-by: Chris Sherlock <chris.sherlock79@gmail.com>
2017-04-25 10:55:17 +02:00
Miklos Vajna 3902bb7a45 Revert "comphelper: fix MSVC hang in ThreadPool::shutdown()"
As it causes "unopkg.bin:
/home/tdf/lode/jenkins/workspace/lo_gerrit/Config/linux_clang_dbgutil_64/comphelper/source/misc/threadpool.cxx:96:
comphelper::ThreadPool::~ThreadPool(): Assertion `mbTerminate' failed."
in
<https://ci.libreoffice.org/job/lo_gerrit/8283/Config=linux_clang_dbgutil_64/console>
and also locally. Revert till it's clear if that assert() should be a
SAL_WARN() or unopkg has to be fixed.

This reverts commit 9899ffd244.

Change-Id: I72902f7da410012340aa8231d84c6871a3f7b976
2017-03-13 12:11:04 +01:00
Michael Stahl 9899ffd244 comphelper: fix MSVC hang in ThreadPool::shutdown()
Commit aa68c99d88 added some code using
std::condition_variable to comphelper.

Built with MSVC 2017, this causes many cppunittester.exe processes to
deadlock in ThreadPool::shutdown():

    maTasksChanged.notify_all();

This ultimately calls NtReleaseKeyedEvent(), which never returns.

The reason appears to be a bug in Windows 7, for which a "hotfix"[1] is
avaiable here, but it's apparently not distributed via Windows Update
so we likely can't rely on users or even developers having this installed.

However, the documentation of DllMain[2] and ExitProcess[3] indicates
that during shutdown, by the time global destructors are invoked
all threads other than the one that called ExitProcess have already
been terminated.

Returning from main() implicitly calls ExitProcess [4].

As it turns out the problem only happens for some CppUnitTests because
soffice.bin will call ThreadPool::shutdown() from Desktop::doShutdown()
while it is still safe.

[1] http://support.microsoft.com/kb/2582203
[2] https://msdn.microsoft.com/en-US/library/windows/desktop/ms682583(v=vs.85).aspx
[3] https://msdn.microsoft.com/en-us/library/windows/desktop/ms682658(v=vs.85).aspx
[4] https://blogs.msdn.microsoft.com/oldnewthing/20100827-00/?p=13023

Change-Id: I6137461ca7efe9a5fbe4f8f8478fb96de3570469
Reviewed-on: https://gerrit.libreoffice.org/35066
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
2017-03-11 10:08:06 +00:00
Stephan Bergmann 106ea87205 Remove _TYPED suffix from tools/link.hxx macros
...which was introduced with 3ead3ad52f "Gradually
typed Link" to distinguish the new, typed versions from the old, untyped ones,
but is no longer necessary since 382eb1a23c
"remove untyped Link<>" removed the old versions.

Change-Id: I494025df486a16a45861fcd8192dfe0275b1103c
2016-10-05 07:56:12 +02:00
Stephan Bergmann 4714083279 Remove duplication of "set up VCL" code
The "this is called from pyuno" version in test/source/bootstrapfixture.cxx had
had an empty deinitHook, but it appears to not hurt to give it the same
deinitHook as the version in test/source/vclbootstrapprotector.cxx had had.

Make test::setUpVcl accessible from outside module test for an upcoming use in
<https://gerrit.libreoffice.org/#/c/28322/16> "tdf#99402: fix Metafile Font
handling".

Change-Id: I1d609445690b6ee5e331aa322cd4bf434a3de78e
2016-08-29 17:54:04 +02:00
Noel Grandin 6e72f0251b new loplugin unnecessary override
Change-Id: I88d3e33823d68745b98625050a8a274f9ef04bcb
Reviewed-on: https://gerrit.libreoffice.org/27135
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Stephan Bergmann <sbergman@redhat.com>
2016-07-15 14:05:41 +00:00
Vasily Melenchuk c3453ea246 Add MS binary format validator support in test fixture
bffvalidator (Microsoft Office Binary File Format Validator) can now be
used for verification of MS binary export tests

Change-Id: Ibc65e64726a454cdd33946006b36427b9cc6fbd2
Reviewed-on: https://gerrit.libreoffice.org/26405
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2016-06-17 11:20:06 +00:00
Stephan Bergmann c838f2ed9f loplugin:salbool: Automatic rewrite of sal_False/True
Change-Id: Ie66903c2aae5535a507e1549b58d892b80237842
2016-04-20 17:27:27 +02:00