tdf#92524 ooxmlexport: recognize COL_AUTO for RES_BACKGROUND

FormatBackground was always returning the actual color
instead of AUTO when the color was COL_AUTO because ConvertColor
is being passed Color.GetRGBColor() instead of just Color.

There are three sections here:
-XML_fillcolor: looks like it accepts values like "green" and
"teal". Unclear from documenation whether auto is allowed.
-XML_srgbClr: only accepts rgb number, not auto
-XML_fill: needs this fix - test document available.

Since the section can't globally handle "auto", I left XML_fillcolor
alone, waiting for a proof bug report.

Change-Id: Idecb6a32fba814a6fb3aeb6cc015d793ba6f8cf9
Reviewed-on: https://gerrit.libreoffice.org/43975
Reviewed-by: Justin Luth <justin_luth@sil.org>
Tested-by: Justin Luth <justin_luth@sil.org>
This commit is contained in:
Justin Luth 2017-10-28 09:14:32 +03:00
parent d30522e46c
commit 9b8a99a188
5 changed files with 71 additions and 1 deletions

View file

@ -0,0 +1,14 @@
# -*- 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 sw_ooxmlexport_test,11))
# vim: set noet sw=4 ts=4:

View file

@ -65,6 +65,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\
CppunitTest_sw_ooxmlexport8 \
CppunitTest_sw_ooxmlexport9 \
CppunitTest_sw_ooxmlexport10 \
CppunitTest_sw_ooxmlexport11 \
CppunitTest_sw_ooxmlfieldexport \
CppunitTest_sw_ooxmlw14export \
CppunitTest_sw_ooxmlencryption \

Binary file not shown.

View file

@ -0,0 +1,51 @@
/* -*- 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/awt/Size.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/text/XFootnote.hpp>
#include <com/sun/star/text/XPageCursor.hpp>
#include <com/sun/star/text/XTextColumns.hpp>
#include <com/sun/star/text/XTextFrame.hpp>
#include <com/sun/star/text/XTextFramesSupplier.hpp>
#include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
#include <sfx2/docfile.hxx>
#include <sfx2/docfilt.hxx>
#include <svx/xfillit0.hxx>
class Test : public SwModelTestBase
{
public:
Test() : SwModelTestBase("/sw/qa/extras/ooxmlexport/data/", "Office Open XML Text") {}
protected:
/**
* Blacklist handling
*/
bool mustTestImportOf(const char* filename) const override {
// If the testcase is stored in some other format, it's pointless to test.
return OString(filename).endsWith(".docx");
}
};
DECLARE_OOXMLEXPORT_TEST(testTdf92524_autoColor, "tdf92524_autoColor.doc")
{
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(getParagraph(1), "FillStyle"));
CPPUNIT_ASSERT_EQUAL(COL_AUTO, getProperty<sal_uInt32>(getParagraph(1), "ParaBackColor"));
}
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -8109,7 +8109,8 @@ boost::optional<sal_Int32> lcl_getDmlAlpha(const SvxBrushItem& rBrush)
void DocxAttributeOutput::FormatBackground( const SvxBrushItem& rBrush )
{
OString sColor = msfilter::util::ConvertColor( rBrush.GetColor().GetRGBColor() );
const Color aColor = rBrush.GetColor();
OString sColor = msfilter::util::ConvertColor( aColor.GetRGBColor() );
boost::optional<sal_Int32> oAlpha = lcl_getDmlAlpha(rBrush);
if (m_rExport.SdrExporter().getTextFrameSyntax())
{
@ -8159,6 +8160,9 @@ void DocxAttributeOutput::FormatBackground( const SvxBrushItem& rBrush )
OString sOriginalFill = OUStringToOString(
m_sOriginalBackgroundColor, RTL_TEXTENCODING_UTF8 );
if ( aColor == COL_AUTO )
sColor = "auto";
if( !m_pBackgroundAttrList.is() )
{
m_pBackgroundAttrList = FastSerializerHelper::createAttrList();