diff options
author | Tobias Lippert <drtl@fastmail.fm> | 2014-08-07 22:30:58 +0200 |
---|---|---|
committer | Matúš Kukan <matus.kukan@collabora.com> | 2014-09-19 21:53:55 +0000 |
commit | 5013ac55090ab7a64b9549df67196aa5c7479542 (patch) | |
tree | b8305cc98935855ae69413b6afd1f1805591df41 /svx/qa | |
parent | 234b5de79fd10bd99b75d7b968581af7b6ffe44b (diff) |
fdo#84061 Fix setting text style sheet listeners in SdrTextObj
The code in SdrTextObj::ImpSetTextStyleSheetListeners is obviously not
working correctly.
The families of the stylesheets are appended to the name of the family
for further usage.
An encoded string looks like "STYLE_NAME|3 "
The family is then extracted by copying the first (length-6) bytes,
e.g., "STYLE_NAME" in this example. Then another copy starting a
position 1 is created, e.g., "TYLE_NAME". This string is cast to an
Int32. Since this is not possible, 0 is returned, and the originally
stored family is lost.
This patch corrects this behavior, and adds a unit test.
Change-Id: I60c0add6e4b670acbbc264cc77672452f282f737
Reviewed-on: https://gerrit.libreoffice.org/10818
Reviewed-by: Matúš Kukan <matus.kukan@collabora.com>
Tested-by: Matúš Kukan <matus.kukan@collabora.com>
Diffstat (limited to 'svx/qa')
-rw-r--r-- | svx/qa/unit/svdraw/test_SdrTextObject.cxx | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/svx/qa/unit/svdraw/test_SdrTextObject.cxx b/svx/qa/unit/svdraw/test_SdrTextObject.cxx new file mode 100644 index 000000000000..fe16805ade14 --- /dev/null +++ b/svx/qa/unit/svdraw/test_SdrTextObject.cxx @@ -0,0 +1,48 @@ +/* -*- 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 <svx/svdotext.hxx> +#include <rtl/ustring.hxx> + +#include <cppunit/TestAssert.h> +#include <cppunit/TestFixture.h> +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/plugin/TestPlugIn.h> + +#include <boost/foreach.hpp> + +class SdrTextObjTest : public CppUnit::TestFixture { +public: + void AllFamiliesCanBeRestoredFromSavedString(); + + CPPUNIT_TEST_SUITE(SdrTextObjTest); + CPPUNIT_TEST(AllFamiliesCanBeRestoredFromSavedString); + CPPUNIT_TEST_SUITE_END(); +}; + +void SdrTextObjTest::AllFamiliesCanBeRestoredFromSavedString() { + std::vector<SfxStyleFamily> allFamilies; + allFamilies.push_back(SFX_STYLE_FAMILY_CHAR); + allFamilies.push_back(SFX_STYLE_FAMILY_PARA); + allFamilies.push_back(SFX_STYLE_FAMILY_PAGE); + allFamilies.push_back(SFX_STYLE_FAMILY_PSEUDO); + + BOOST_FOREACH(SfxStyleFamily family, allFamilies) { + OUString styleName = "styleName"; + SdrTextObj::AppendFamilyToStyleName(styleName, family); + SfxStyleFamily readFamily = SdrTextObj::ReadFamilyFromStyleName(styleName); + CPPUNIT_ASSERT_EQUAL(family, readFamily); + } +} + +CPPUNIT_TEST_SUITE_REGISTRATION(SdrTextObjTest); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |