diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2016-02-13 16:08:01 +1100 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2016-02-17 20:11:28 +0000 |
commit | a93f7792af5a8ce53ef1dc57380624476e14f933 (patch) | |
tree | 98923db2af7d0e325ec2363d29d833f55c05591a /vcl/qa/cppunit/mapmode.cxx | |
parent | 398fcdd3abcab3dbd0418dbae87ed4ca7451315c (diff) |
tdf#85761 vcl: JPEG export does not save PPI values correctly
JPEG values are currently hardcoded to 96PPI when we export JPEGs. The
Graphic class doesn't have an easy way to get the PPI, but this can
actually be calculated from the pref size and pref map mode (no idea
why it is called "Pref").
Interestingly, you need to get a multiplier to work this out, relative
to units of 100th mm. The EPS filter code had a function that does
exactly this, but it's entirely based on MapMode units so it was really
implemented in the wrong class IMO. I have thus moved it out of PSWriter
and into MapMode.
This also fixes tdf#65695, which was partially fixed, but had the JPEG
PPI hardcoded to 96dpi.
Also fixes tdf#97481.
Change-Id: Iedb674141dd4e22fcbfb7be357dc777f732aa3aa
Reviewed-on: https://gerrit.libreoffice.org/22339
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Reviewed-on: https://gerrit.libreoffice.org/22380
Diffstat (limited to 'vcl/qa/cppunit/mapmode.cxx')
-rw-r--r-- | vcl/qa/cppunit/mapmode.cxx | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/mapmode.cxx b/vcl/qa/cppunit/mapmode.cxx new file mode 100644 index 000000000000..87c20a3bd666 --- /dev/null +++ b/vcl/qa/cppunit/mapmode.cxx @@ -0,0 +1,65 @@ +/* -*- 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 <test/bootstrapfixture.hxx> +#include <cppunit/TestAssert.h> +#include <cppunit/TestFixture.h> + +#include <osl/file.hxx> +#include <osl/process.h> + +#include <vcl/mapmod.hxx> + +class VclMapModeTest : public test::BootstrapFixture +{ +public: + VclMapModeTest() : BootstrapFixture(true, false) {} + + void testMultiplier(); + + CPPUNIT_TEST_SUITE(VclMapModeTest); + CPPUNIT_TEST(testMultiplier); + CPPUNIT_TEST_SUITE_END(); +}; + +void VclMapModeTest::testMultiplier() +{ + MapMode aMapMode; + CPPUNIT_ASSERT_MESSAGE( "Default map mode is MAP_PIXEL, multiplier should be 1", aMapMode.GetUnitMultiplier() == 1 ); + aMapMode.SetMapUnit( MAP_SYSFONT ); + CPPUNIT_ASSERT_MESSAGE( "Map mode is MAP_SYSFONT, multiplier should be 1", aMapMode.GetUnitMultiplier() == 1 ); + aMapMode.SetMapUnit( MAP_APPFONT ); + CPPUNIT_ASSERT_MESSAGE( "Map mode is MAP_APPFONT, multiplier should be 1", aMapMode.GetUnitMultiplier() == 1 ); + aMapMode.SetMapUnit( MAP_100TH_MM ); + CPPUNIT_ASSERT_MESSAGE( "Map mode is MAP_100TH_MM, multiplier should be 1", aMapMode.GetUnitMultiplier() == 1 ); + aMapMode.SetMapUnit( MAP_10TH_MM ); + CPPUNIT_ASSERT_MESSAGE( "Map mode is MAP_10TH_MM, multiplier should be 10", aMapMode.GetUnitMultiplier() == 10 ); + aMapMode.SetMapUnit( MAP_MM ); + CPPUNIT_ASSERT_MESSAGE( "Map mode is MAP_MM, multiplier should be 100", aMapMode.GetUnitMultiplier() == 100 ); + aMapMode.SetMapUnit( MAP_CM ); + CPPUNIT_ASSERT_MESSAGE( "Map mode is MAP_CM, multiplier should be 1000", aMapMode.GetUnitMultiplier() == 1000 ); + aMapMode.SetMapUnit( MAP_1000TH_INCH ); + CPPUNIT_ASSERT_MESSAGE( "Map mode is MAP_1000TH_INCH, multiplier should be 2.54", aMapMode.GetUnitMultiplier() == 2.54 ); + aMapMode.SetMapUnit( MAP_100TH_INCH ); + CPPUNIT_ASSERT_MESSAGE( "Map mode is MAP_100TH_INCH, multiplier should be 2.54", aMapMode.GetUnitMultiplier() == 25.4 ); + aMapMode.SetMapUnit( MAP_10TH_INCH ); + CPPUNIT_ASSERT_MESSAGE( "Map mode is MAP_10TH_INCH, multiplier should be 254", aMapMode.GetUnitMultiplier() == 254 ); + aMapMode.SetMapUnit( MAP_INCH ); + CPPUNIT_ASSERT_MESSAGE( "Map mode is MAP_INCH, multiplier should be 2540", aMapMode.GetUnitMultiplier() == 2540 ); + aMapMode.SetMapUnit( MAP_TWIP ); + CPPUNIT_ASSERT_MESSAGE( "Map mode is MAP_TWIP, multiplier should be 1.76388889", aMapMode.GetUnitMultiplier() == 1.76388889 ); + aMapMode.SetMapUnit( MAP_POINT ); + CPPUNIT_ASSERT_MESSAGE( "Map mode is MAP_POINT, multiplier should be 35.27777778", aMapMode.GetUnitMultiplier() == 35.27777778 ); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(VclMapModeTest); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |