Files
odfstudio/include/test/bootstrapfixture.hxx
T
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

72 lines
2.3 KiB
C++

/* -*- 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/config.h>
#include <rtl/string.hxx>
#include <tools/link.hxx>
#include <vcl/salctype.hxx>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/lang/XMultiComponentFactory.hpp>
#include <cppunit/TestAssert.h>
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/plugin/TestPlugIn.h>
#include <unotest/bootstrapfixturebase.hxx>
#include <test/testdllapi.hxx>
namespace test
{
enum ValidationFormat
{
OOXML,
ODF,
MSBINARY
};
// Class to do lots of heavy-lifting UNO & environment
// bootstrapping for unit tests, such that we can use
// almost an entire LibreOffice during compile - so
// that we can get pieces of code alone to beat them up.
// NB. this class is instantiated multiple times during a
// run of unit tests ...
class OOO_DLLPUBLIC_TEST BootstrapFixture : public BootstrapFixtureBase
{
bool m_bNeedUCB;
bool m_bAssertOnDialog;
protected:
// A convenience function to be used to conditionally exclude tests not behaving properly
// on UI scaling other than 1:1. Using this should be considered a temporary workaround,
// until a proper fix is implemented that either considers the DPI properly in the test, or
// makes the invariants that test uses independent of DPI.
static bool IsDefaultDPI();
static std::pair<double, double> getDPIScaling();
public:
DECL_DLLPRIVATE_STATIC_LINK(BootstrapFixture, ImplInitFilterHdl, ConvertData&, bool);
BootstrapFixture(bool bAssertOnDialog = true, bool bNeedUCB = true);
virtual ~BootstrapFixture() override;
virtual void setUp() override;
void validate(const OUString& rURL, std::u16string_view rFilter) const;
// Allows to exclude tests dependent on color depth of the default virtual device
static sal_uInt16 getDefaultDeviceBitCount();
};
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */