fdo65400: fix for Character Shading being lost
This bug fixes the DOCX import and export filters, adds a new property
to the document model and updates the UNO API.
There is no need to add layout \ UI updates, because in Word
the only way to turn this on\off is using a simple button,
and there is no way to control the shading color itself.
However, ODF import \ export filters should be updated in a future
commit.
Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport.cxx
Change-Id: I1d34cec79289e38c08e42a4c6265d998e1edfdef
Reviewed-on: https://gerrit.libreoffice.org/4452
Reviewed-by: Miklos Vajna <vmiklos@suse.cz>
diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx
index 566a375..8dedafd 100644
--- a/editeng/source/items/frmitems.cxx
+++ b/editeng/source/items/frmitems.cxx
@@ -41,6 +41,7 @@
#include <com/sun/star/awt/Size.hpp>
#include <com/sun/star/text/WritingMode2.hpp>
#include <com/sun/star/frame/status/UpperLowerMarginScale.hpp>
#include <com/sun/star/drawing/ShadingPattern.hpp>
#include <unotools/ucbstreamhelper.hxx>
#include <limits.h>
@@ -79,6 +80,7 @@
using namespace ::editeng;
using namespace ::rtl;
using namespace ::com::sun::star;
using namespace ::com::sun::star::drawing;
using namespace ::com::sun::star::table::BorderLineStyle;
@@ -3322,12 +3324,13 @@ SvxBrushItem::SvxBrushItem( sal_uInt16 _nWhich ) :
SfxPoolItem( _nWhich ),
aColor ( COL_TRANSPARENT ),
pImpl ( new SvxBrushItem_Impl( 0 ) ),
pStrLink ( NULL ),
pStrFilter ( NULL ),
eGraphicPos ( GPOS_NONE ),
bLoadAgain ( sal_True )
aColor ( COL_TRANSPARENT ),
nShadingValue ( ShadingPattern::CLEAR ),
pImpl ( new SvxBrushItem_Impl( 0 ) ),
pStrLink ( NULL ),
pStrFilter ( NULL ),
eGraphicPos ( GPOS_NONE ),
bLoadAgain ( sal_True )
{
}
@@ -3338,12 +3341,13 @@ SvxBrushItem::SvxBrushItem( const Color& rColor, sal_uInt16 _nWhich) :
SfxPoolItem( _nWhich ),
aColor ( rColor ),
pImpl ( new SvxBrushItem_Impl( 0 ) ),
pStrLink ( NULL ),
pStrFilter ( NULL ),
eGraphicPos ( GPOS_NONE ),
bLoadAgain ( sal_True )
aColor ( rColor ),
nShadingValue ( ShadingPattern::CLEAR ),
pImpl ( new SvxBrushItem_Impl( 0 ) ),
pStrLink ( NULL ),
pStrFilter ( NULL ),
eGraphicPos ( GPOS_NONE ),
bLoadAgain ( sal_True )
{
}
@@ -3355,12 +3359,13 @@ SvxBrushItem::SvxBrushItem( const Graphic& rGraphic, SvxGraphicPosition ePos,
SfxPoolItem( _nWhich ),
aColor ( COL_TRANSPARENT ),
pImpl ( new SvxBrushItem_Impl( new GraphicObject( rGraphic ) ) ),
pStrLink ( NULL ),
pStrFilter ( NULL ),
eGraphicPos ( ( GPOS_NONE != ePos ) ? ePos : GPOS_MM ),
bLoadAgain ( sal_True )
aColor ( COL_TRANSPARENT ),
nShadingValue ( ShadingPattern::CLEAR ),
pImpl ( new SvxBrushItem_Impl( new GraphicObject( rGraphic ) ) ),
pStrLink ( NULL ),
pStrFilter ( NULL ),
eGraphicPos ( ( GPOS_NONE != ePos ) ? ePos : GPOS_MM ),
bLoadAgain ( sal_True )
{
DBG_ASSERT( GPOS_NONE != ePos, "SvxBrushItem-Ctor with GPOS_NONE == ePos" );
@@ -3373,12 +3378,13 @@ SvxBrushItem::SvxBrushItem( const GraphicObject& rGraphicObj,
SfxPoolItem( _nWhich ),
aColor ( COL_TRANSPARENT ),
pImpl ( new SvxBrushItem_Impl( new GraphicObject( rGraphicObj ) ) ),
pStrLink ( NULL ),
pStrFilter ( NULL ),
eGraphicPos ( ( GPOS_NONE != ePos ) ? ePos : GPOS_MM ),
bLoadAgain ( sal_True )
aColor ( COL_TRANSPARENT ),
nShadingValue ( ShadingPattern::CLEAR ),
pImpl ( new SvxBrushItem_Impl( new GraphicObject( rGraphicObj ) ) ),
pStrLink ( NULL ),
pStrFilter ( NULL ),
eGraphicPos ( ( GPOS_NONE != ePos ) ? ePos : GPOS_MM ),
bLoadAgain ( sal_True )
{
DBG_ASSERT( GPOS_NONE != ePos, "SvxBrushItem-Ctor with GPOS_NONE == ePos" );
@@ -3392,12 +3398,13 @@ SvxBrushItem::SvxBrushItem(
SfxPoolItem( _nWhich ),
aColor ( COL_TRANSPARENT ),
pImpl ( new SvxBrushItem_Impl( NULL ) ),
pStrLink ( new String( rLink ) ),
pStrFilter ( new String( rFilter ) ),
eGraphicPos ( ( GPOS_NONE != ePos ) ? ePos : GPOS_MM ),
bLoadAgain ( sal_True )
aColor ( COL_TRANSPARENT ),
nShadingValue ( ShadingPattern::CLEAR ),
pImpl ( new SvxBrushItem_Impl( NULL ) ),
pStrLink ( new String( rLink ) ),
pStrFilter ( new String( rFilter ) ),
eGraphicPos ( ( GPOS_NONE != ePos ) ? ePos : GPOS_MM ),
bLoadAgain ( sal_True )
{
DBG_ASSERT( GPOS_NONE != ePos, "SvxBrushItem-Ctor with GPOS_NONE == ePos" );
@@ -3410,11 +3417,12 @@ SvxBrushItem::SvxBrushItem( SvStream& rStream, sal_uInt16 nVersion,
SfxPoolItem( _nWhich ),
aColor ( COL_TRANSPARENT ),
pImpl ( new SvxBrushItem_Impl( NULL ) ),
pStrLink ( NULL ),
pStrFilter ( NULL ),
eGraphicPos ( GPOS_NONE )
aColor ( COL_TRANSPARENT ),
nShadingValue ( ShadingPattern::CLEAR ),
pImpl ( new SvxBrushItem_Impl( NULL ) ),
pStrLink ( NULL ),
pStrFilter ( NULL ),
eGraphicPos ( GPOS_NONE )
{
sal_Bool bTrans;
@@ -3525,12 +3533,12 @@ SvxBrushItem::SvxBrushItem( SvStream& rStream, sal_uInt16 nVersion,
SvxBrushItem::SvxBrushItem( const SvxBrushItem& rItem ) :
SfxPoolItem( rItem.Which() ),
pImpl ( new SvxBrushItem_Impl( NULL ) ),
pStrLink ( NULL ),
pStrFilter ( NULL ),
eGraphicPos ( GPOS_NONE ),
bLoadAgain ( sal_True )
nShadingValue ( ShadingPattern::CLEAR ),
pImpl ( new SvxBrushItem_Impl( NULL ) ),
pStrLink ( NULL ),
pStrFilter ( NULL ),
eGraphicPos ( GPOS_NONE ),
bLoadAgain ( sal_True )
{
*this = rItem;
@@ -3616,9 +3624,16 @@ bool SvxBrushItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
rVal <<= sFilter;
}
break;
case MID_GRAPHIC_TRANSPARENCY :
case MID_GRAPHIC_TRANSPARENCY:
rVal <<= pImpl->nGraphicTransparency;
break;
case MID_SHADING_VALUE:
{
rVal <<= (sal_Int32)(nShadingValue);
}
break;
}
return true;
@@ -3732,6 +3747,16 @@ bool SvxBrushItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
}
}
break;
case MID_SHADING_VALUE:
{
sal_uInt32 nVal = 0;
if (!(rVal >>= nVal))
return false;
SetShadingValue( nVal );
}
break;
}
return true;
@@ -3800,6 +3825,9 @@ SvxBrushItem& SvxBrushItem::operator=( const SvxBrushItem& rItem )
pImpl->pGraphicObject = new GraphicObject( *rItem.pImpl->pGraphicObject );
}
}
nShadingValue = rItem.nShadingValue;
pImpl->nGraphicTransparency = rItem.pImpl->nGraphicTransparency;
return *this;
}
@@ -3840,6 +3868,11 @@ int SvxBrushItem::operator==( const SfxPoolItem& rAttr ) const
( *pImpl->pGraphicObject == *rCmp.pImpl->pGraphicObject );
}
}
if (bEqual)
{
bEqual = nShadingValue == rCmp.nShadingValue;
}
}
return bEqual;
@@ -4049,6 +4082,11 @@ void SvxBrushItem::SetGraphicFilter( const String& rNew )
}
}
void SvxBrushItem::SetShadingValue( const sal_uInt32 nNew )
{
nShadingValue = nNew;
}
//static
SvxGraphicPosition SvxBrushItem::WallpaperStyle2GraphicPos( WallpaperStyle eStyle )
{
@@ -4097,11 +4135,12 @@ WallpaperStyle SvxBrushItem::GraphicPos2WallpaperStyle( SvxGraphicPosition ePos
}
SvxBrushItem::SvxBrushItem( const CntWallpaperItem& rItem, sal_uInt16 _nWhich ) :
SfxPoolItem( _nWhich ),
pImpl( new SvxBrushItem_Impl( 0 ) ),
pStrLink(0),
pStrFilter(0),
bLoadAgain( sal_True )
SfxPoolItem ( _nWhich ),
nShadingValue ( ShadingPattern::CLEAR ),
pImpl ( new SvxBrushItem_Impl( 0 ) ),
pStrLink ( 0),
pStrFilter ( 0),
bLoadAgain ( sal_True )
{
aColor = rItem.GetColor();
diff --git a/include/editeng/brushitem.hxx b/include/editeng/brushitem.hxx
index c7130bd..d18882a 100644
--- a/include/editeng/brushitem.hxx
+++ b/include/editeng/brushitem.hxx
@@ -49,6 +49,7 @@ class SvxBrushItem_Impl;
class EDITENG_DLLPUBLIC SvxBrushItem : public SfxPoolItem
{
Color aColor;
sal_Int32 nShadingValue;
SvxBrushItem_Impl* pImpl;
String* pStrLink;
String* pStrFilter;
@@ -104,11 +105,13 @@ public:
void PurgeMedium() const;
sal_uInt32 GetShadingValue() const { return nShadingValue; }
const Graphic* GetGraphic() const;
const GraphicObject* GetGraphicObject() const;
const String* GetGraphicLink() const { return pStrLink; }
const String* GetGraphicFilter() const { return pStrFilter; }
void SetShadingValue( const sal_uInt32 nNew );
void SetGraphicPos( SvxGraphicPosition eNew );
void SetGraphic( const Graphic& rNew );
void SetGraphicObject( const GraphicObject& rNewObj );
diff --git a/include/editeng/memberids.hrc b/include/editeng/memberids.hrc
index 1dbe7ba..9152c36 100644
--- a/include/editeng/memberids.hrc
+++ b/include/editeng/memberids.hrc
@@ -171,6 +171,7 @@
#define MID_GRAPHIC_TRANSPARENCY 8
#define MID_BACK_COLOR_R_G_B 9
#define MID_BACK_COLOR_TRANSPARENCY 10
#define MID_SHADING_VALUE 11
//SvxFmtBreakItem
#define MID_BREAK_BEFORE 0
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index a96bcd4..e6e19a9 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -2305,6 +2305,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,offapi/com/sun/star/drawing,\
ProjectionMode \
RectanglePoint \
ShadeMode \
ShadingPattern \
SnapObjectType \
TextAdjust \
TextAnimationDirection \
diff --git a/offapi/com/sun/star/drawing/ShadingPattern.idl b/offapi/com/sun/star/drawing/ShadingPattern.idl
new file mode 100644
index 0000000..abc3190
--- /dev/null
+++ b/offapi/com/sun/star/drawing/ShadingPattern.idl
@@ -0,0 +1,225 @@
/* -*- 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/.
*/
#ifndef __com_sun_star_drawing_ShadingPattern_idl__
#define __com_sun_star_drawing_ShadingPattern_idl__
module com { module sun { module star { module drawing {
/** The ShadingPattern determines the background color pattern against
which characters and graphics are displayed, typically in tables.
The color can be no color or it can be a specific color with
a transparency or pattern value.
*/
constants ShadingPattern
{
/* Clear */
const long CLEAR = 0x0000;
/* Solid */
const long SOLID = 0x0001;
/* 5% - pct5 */
const long PCT5 = 0x0002;
/* 10% - pct10 */
const long PCT10 = 0x0003;
/* 20% - pct20 */
const long PCT20 = 0x0004;
/* 25% - pct25 */
const long PCT25 = 0x0005;
/* 30% - pct30 */
const long PCT30 = 0x0006;
/* 40% - pct40 */
const long PCT40 = 0x0007;
/* 50% - pct50 */
const long PCT50 = 0x0008;
/* 60% - pct60 */
const long PCT60 = 0x0009;
/* 70% - pct70 */
const long PCT70 = 0x000A;
/* 75% - pct75 */
const long PCT75 = 0x000B;
/* 80% - pct80 */
const long PCT80 = 0x000C;
/* 90% - pct90 */
const long PCT90 = 0x000D;
/* Horizontal Stripe */
const long HORZ_STRIPE = 0x000E;
/* Vertical Stripe */
const long VERT_STRIPE = 0x000F;
/* Reverse Diagonal Stripe */
const long REVERSE_DIAG_STRIPE = 0x0010;
/* Diagonal Stripe */
const long DIAG_STRIPE = 0x0011;
/* Horizontal Cross */
const long HORZ_CROSS = 0x0012;
/* Diagonal Cross */
const long DIAG_CROSS = 0x0013;
/* Thin Horizontal Stripe */
const long THIN_HORZ_STRIPE = 0x0014;
/* Thin Vertical Stripe */
const long THIN_VERT_STRIPE = 0x0015;
/* Thin Reverse Diagonal Stripe */
const long THIN_REVERSE_DIAG_STRIPE = 0x0016;
/* Thin Diagonal Stripe */
const long THIN_DIAG_STRIPE = 0x0017;
/* Thin Horizontal Cross */
const long THIN_HORZ_CROSS = 0x0018;
/* Thin Diagonal Cross */
const long THIN_DIAG_CROSS = 0x0019;
/* Unused 1 */
const long UNUSED_1 = 0x001A;
/* Unused 2 */
const long UNUSED_2 = 0x001B;
/* Unused 3 */
const long UNUSED_3 = 0x001C;
/* Unused 4 */
const long UNUSED_4 = 0x001D;
/* Unused 5 */
const long UNUSED_5 = 0x001E;
/* Unused 6 */
const long UNUSED_6 = 0x001F;
/* Unused 7 */
const long UNUSED_7 = 0x0020;
/* Unused 8 */
const long UNUSED_8 = 0x0021;
/* Unused 9 */
const long UNUSED_9 = 0x0022;
/* 2.5% */
const long PCT2 = 0x0023;
/* 7.5% */
const long PCT7 = 0x0024;
/* 12.5% - pct12 */
const long PCT12 = 0x0025;
/* 15% - pct15 */
const long PCT15 = 0x0026;
/* 17.5% */
const long PCT17 = 0x0027;
/* 22.5% */
const long PCT22 = 0x0028;
/* 27.5% */
const long PCT27 = 0x0029;
/* 32.5% */
const long PCT32 = 0x002A;
/* 35% - pct35 */
const long PCT35 = 0x002B;
/* 37.5% - pct37 */
const long PCT37 = 0x002C;
/* 42.5% */
const long PCT42 = 0x002D;
/* 45% - pct45 */
const long PCT45 = 0x002E;
/* 47.5% */
const long PCT47 = 0x002F;
/* 52.5% */
const long PCT52 = 0x0030;
/* 55% - pct55 */
const long PCT55 = 0x0031;
/* 57.5% */
const long PCT57 = 0x0032;
/* 62.5% - pct62 */
const long PCT62 = 0x0033;
/* 65% - pct65 */
const long PCT65 = 0x0034;
/* 67.5% */
const long PCT67 = 0x0035;
/* 72.5% */
const long PCT72 = 0x0036;
/* 77.5% */
const long PCT77 = 0x0037;
/* 82.5% */
const long PCT82 = 0x0038;
/* 85% - pct85 */
const long PCT85 = 0x0039;
/* 87.5% - pct87 */
const long PCT87 = 0x003A;
/* 92.5% */
const long PCT92 = 0x003B;
/* 95% - pct95 */
const long PCT95 = 0x003C;
/* 97.5% */
const long PCT97 = 0x003D;
/* Nil */
const long NIL = 0xFFFF;
};
}; }; }; };
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/offapi/com/sun/star/style/CharacterProperties.idl b/offapi/com/sun/star/style/CharacterProperties.idl
index 067a42c..8ba1a61 100644
--- a/offapi/com/sun/star/style/CharacterProperties.idl
+++ b/offapi/com/sun/star/style/CharacterProperties.idl
@@ -118,6 +118,11 @@ published service CharacterProperties
[optional, property] com::sun::star::util::Color CharBackColor;
/** This optional property contains the text shading value.
*/
[optional, property] long CharShadingValue;
/** This property determines if the text background color is set to
transparent.
*/
diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx
index fb6e9d3..68a1f4b 100644
--- a/sw/inc/unoprnms.hxx
+++ b/sw/inc/unoprnms.hxx
@@ -822,7 +822,9 @@ enum SwPropNameIds
/* 0760 */ UNO_NAME_DEFAULT_PAGE_MODE,
/* 0761 */ SW_PROPNAME_END
/* 0761 */ UNO_NAME_CHAR_SHADING_VALUE,
/* 0762 */ SW_PROPNAME_END
// new items in this array must match SwPropNameTab aPropNameTab
};
diff --git a/sw/qa/extras/ooxmlexport/data/fdo65400.docx b/sw/qa/extras/ooxmlexport/data/fdo65400.docx
new file mode 100644
index 0000000..c247e9f
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/fdo65400.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index b4d855a..db12382 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -84,6 +84,7 @@ public:
void testFdo64238_a();
void testFdo64238_b();
void testFdo56679();
void testFdo65400();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -142,6 +143,7 @@ void Test::run()
{"fdo64238_a.docx", &Test::testFdo64238_a},
{"fdo64238_b.docx", &Test::testFdo64238_b},
{"fdo56679.docx", &Test::testFdo56679},
{"fdo65400.docx", &Test::testFdo65400},
};
// Don't test the first import of these, for some reason those tests fail
const char* aBlacklist[] = {
@@ -865,6 +867,17 @@ void Test::testFdo56679()
CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFF0000), getProperty<sal_Int32>(xText, "CharUnderlineColor"));
}
void Test::testFdo65400()
{
// The problem was that if in Word you choose 'Character Shading' - then the text portion
// is marked with 'w:shd val=pct15'. LO did not store this value and so when importing and exporting
// this value was lost (and so Word did not show 'Character Shading' was on)
uno::Reference< text::XTextRange > paragraph1 = getParagraph( 1 );
uno::Reference< text::XTextRange > shaded = getRun( paragraph1, 2, "normal" );
CPPUNIT_ASSERT_EQUAL( sal_Int32( 0x0026 ), getProperty< sal_Int32 >( shaded, "CharShadingValue" ));
CPPUNIT_ASSERT_EQUAL( sal_Int32( 0xd8d8d8 ), getProperty< sal_Int32 >( shaded, "CharBackColor" ));
}
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/unocore/unomap.cxx b/sw/source/core/unocore/unomap.cxx
index 8a0bc61..da8857c 100644
--- a/sw/source/core/unocore/unomap.cxx
+++ b/sw/source/core/unocore/unomap.cxx
@@ -234,7 +234,8 @@ SwUnoPropertyMapProvider::~SwUnoPropertyMapProvider()
{ SW_PROP_NMID(UNO_NAME_CHAR_RELIEF), RES_CHRATR_RELIEF, CPPU_E2T(CPPUTYPE_INT16), PropertyAttribute::MAYBEVOID, MID_RELIEF }, \
{ SW_PROP_NMID(UNO_NAME_SNAP_TO_GRID), RES_PARATR_SNAPTOGRID, CPPU_E2T(CPPUTYPE_BOOLEAN), PropertyAttribute::MAYBEVOID, 0 }, \
{ SW_PROP_NMID(UNO_NAME_PARA_IS_CONNECT_BORDER), RES_PARATR_CONNECT_BORDER, CPPU_E2T(CPPUTYPE_BOOLEAN), PropertyAttribute::MAYBEVOID, 0}, \
{ SW_PROP_NMID(UNO_NAME_WRITING_MODE), RES_FRAMEDIR, CPPU_E2T(CPPUTYPE_INT16), PROPERTY_NONE, 0 },
{ SW_PROP_NMID(UNO_NAME_WRITING_MODE), RES_FRAMEDIR, CPPU_E2T(CPPUTYPE_INT16), PROPERTY_NONE, 0 }, \
{ SW_PROP_NMID(UNO_NAME_CHAR_SHADING_VALUE), RES_CHRATR_BACKGROUND, CPPU_E2T(CPPUTYPE_INT32), PROPERTY_NONE, MID_SHADING_VALUE },
#define COMMON_CRSR_PARA_PROPERTIES_WITHOUT_FN \
COMMON_CRSR_PARA_PROPERTIES_WITHOUT_FN_01 \
diff --git a/sw/source/core/unocore/unoprnms.cxx b/sw/source/core/unocore/unoprnms.cxx
index f28e927..8e1c7ce 100644
--- a/sw/source/core/unocore/unoprnms.cxx
+++ b/sw/source/core/unocore/unoprnms.cxx
@@ -789,7 +789,8 @@ const SwPropNameTab aPropNameTab = {
/* 0757 UNO_NAME_FILL_STYLE */ {MAP_CHAR_LEN("FillStyle")},
/* 0758 UNO_NAME_FILL_GRADIENT */ {MAP_CHAR_LEN("FillGradient")},
/* 0759 UNO_NAME_FILL_GRADIENT_NAME */ {MAP_CHAR_LEN("FillGradientName")},
/* 0760 UNO_NAME_DEFAULT_PAGE_MODE */ {MAP_CHAR_LEN("DefaultPageMode")}
/* 0760 UNO_NAME_DEFAULT_PAGE_MODE */ {MAP_CHAR_LEN("DefaultPageMode")},
/* 0761 UNO_NAME_CHAR_SHADING_VALUE */ {MAP_CHAR_LEN("CharShadingValue")},
// new items in this array must match enum SwPropNameIds
};
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index ddda9dd..03e717b 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -103,6 +103,7 @@
#include <com/sun/star/i18n/ScriptType.hpp>
#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/drawing/ShadingPattern.hpp>
#if OSL_DEBUG_LEVEL > 1
#include <stdio.h>
@@ -117,6 +118,7 @@ using namespace nsSwDocInfoSubType;
using namespace nsFieldFlags;
using namespace sw::util;
using namespace ::com::sun::star;
using namespace ::com::sun::star::drawing;
class FFDataWriterHelper
{
@@ -3713,12 +3715,29 @@ void DocxAttributeOutput::CharAnimatedText( const SvxBlinkItem& rBlink )
m_pSerializer->singleElementNS(XML_w, XML_effect, FSNS( XML_w, XML_val ), "none", FSEND );
}
#define MSWORD_CH_SHADING_CLR 0xD8D8D8 // This color is the same color as the ms-word's character shading color.
#define MSWORD_CH_SHADING_FILL "FFFFFF" // The attribute w:fill of w:shd, for MS-Word's character shading,
#define MSWORD_CH_SHADING_COLOR "auto" // The attribute w:color of w:shd, for MS-Word's character shading,
#define MSWORD_CH_SHADING_VAL "pct15" // The attribute w:value of w:shd, for MS-Word's character shading,
void DocxAttributeOutput::CharBackground( const SvxBrushItem& rBrush )
{
m_pSerializer->singleElementNS( XML_w, XML_shd,
// Check if the brush shading pattern is 'PCT15'. If so - write it back to the DOCX
if (rBrush.GetShadingValue() == ShadingPattern::PCT15)
{
m_pSerializer->singleElementNS( XML_w, XML_shd,
FSNS( XML_w, XML_val ), MSWORD_CH_SHADING_VAL,
FSNS( XML_w, XML_color ), MSWORD_CH_SHADING_COLOR,
FSNS( XML_w, XML_fill ), MSWORD_CH_SHADING_FILL,
FSEND );
}
else
{
m_pSerializer->singleElementNS( XML_w, XML_shd,
FSNS( XML_w, XML_fill ), msfilter::util::ConvertColor( rBrush.GetColor() ).getStr(),
FSNS( XML_w, XML_val ), "clear",
FSEND );
}
}
void DocxAttributeOutput::CharFontCJK( const SvxFontItem& rFont )
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 0d9a638..6435e3c 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -4449,75 +4449,74 @@ void SwWW8Shade::SetShade(ColorData nFore, ColorData nBack, sal_uInt16 nIndex)
{
static const sal_uLong eMSGrayScale[] =
{
// Nul-Brush
0, // 0
// Clear-Brush
0, // 0 clear
// Solid-Brush
1000, // 1
// promillemaessig abgestufte Schattierungen
50, // 2
100, // 3
200, // 4
250, // 5
300, // 6
400, // 7
500, // 8
600, // 9
700, // 10
750, // 11
800, // 12
900, // 13
333, // 14 Dark Horizontal
333, // 15 Dark Vertical
333, // 16 Dark Forward Diagonal
333, // 17 Dark Backward Diagonal
333, // 18 Dark Cross
333, // 19 Dark Diagonal Cross
333, // 20 Horizontal
333, // 21 Vertical
333, // 22 Forward Diagonal
333, // 23 Backward Diagonal
333, // 24 Cross
333, // 25 Diagonal Cross
// neun Nummern ohne Bedeutung in Ver8
500, // 26
500, // 27
500, // 28
500, // 29
500, // 30
500, // 31
500, // 32
500, // 33
500, // 34
// und weiter gehts mit tollen Schattierungen ;-)
25, // 35
75, // 36
125, // 37
150, // 38
175, // 39
225, // 40
275, // 41
325, // 42
350, // 43
375, // 44
425, // 45
450, // 46
475, // 47
525, // 48
550, // 49
575, // 50
625, // 51
650, // 52
675, // 53
725, // 54
775, // 55
825, // 56
850, // 57
875, // 58
925, // 59
950, // 60
975, // 61
// und zu guter Letzt:
970
1000, // 1 solid
// Percent values
50, // 2 pct5
100, // 3 pct10
200, // 4 pct20
250, // 5 pct25
300, // 6 pct30
400, // 7 pct40
500, // 8 pct50
600, // 9 pct60
700, // 10 pct70
750, // 11 pct75
800, // 12 pct80
900, // 13 pct90
// Special cases
333, // 14 Dark Horizontal
333, // 15 Dark Vertical
333, // 16 Dark Forward Diagonal
333, // 17 Dark Backward Diagonal
333, // 18 Dark Cross
333, // 19 Dark Diagonal Cross
333, // 20 Horizontal
333, // 21 Vertical
333, // 22 Forward Diagonal
333, // 23 Backward Diagonal
333, // 24 Cross
333, // 25 Diagonal Cross
// Undefined values in DOC spec-sheet
500, // 26
500, // 27
500, // 28
500, // 29
500, // 30
500, // 31
500, // 32
500, // 33
500, // 34
// Different shading types
25, // 35 [available in DOC, not available in DOCX]
75, // 36 [available in DOC, not available in DOCX]
125, // 37 pct12
150, // 38 pct15
175, // 39 [available in DOC, not available in DOCX]
225, // 40 [available in DOC, not available in DOCX]
275, // 41 [available in DOC, not available in DOCX]
325, // 42 [available in DOC, not available in DOCX]
350, // 43 pct35
375, // 44 pct37
425, // 45 [available in DOC, not available in DOCX]
450, // 46 pct45
475, // 47 [available in DOC, not available in DOCX]
525, // 48 [available in DOC, not available in DOCX]
550, // 49 pct55
575, // 50 [available in DOC, not available in DOCX]
625, // 51 pct62
650, // 52 pct65
675, // 53 [available in DOC, not available in DOCX]
725, // 54 [available in DOC, not available in DOCX]
775, // 55 [available in DOC, not available in DOCX]
825, // 56 [available in DOC, not available in DOCX]
850, // 57 pct85
875, // 58 pct87
925, // 59 [available in DOC, not available in DOCX]
950, // 60 pct95
975 // 61 [available in DOC, not available in DOCX]
};// 62
diff --git a/writerfilter/source/dmapper/CellColorHandler.cxx b/writerfilter/source/dmapper/CellColorHandler.cxx
index d509723..58069d8 100644
--- a/writerfilter/source/dmapper/CellColorHandler.cxx
+++ b/writerfilter/source/dmapper/CellColorHandler.cxx
@@ -21,6 +21,7 @@
#include <doctok/resourceids.hxx>
#include <ConversionHelper.hxx>
#include <ooxml/resourceids.hxx>
#include <com/sun/star/drawing/ShadingPattern.hpp>
#include <sal/macros.h>
#include "dmapperLoggers.hxx"
@@ -29,13 +30,13 @@
namespace writerfilter {
namespace dmapper {
using namespace ::com::sun::star;
using namespace ::com::sun::star::drawing;
using namespace ::writerfilter;
CellColorHandler::CellColorHandler() :
LoggedProperties(dmapper_logger, "CellColorHandler"),
m_nShadowType( 0 ),
m_nShadingPattern( ShadingPattern::CLEAR ),
m_nColor( 0xffffffff ),
m_nFillColor( 0xffffffff ),
m_OutputFormat( Form )
@@ -48,6 +49,7 @@ CellColorHandler::~CellColorHandler()
void CellColorHandler::lcl_attribute(Id rName, Value & rVal)
{
OUString stringValue = rVal.getString();
sal_Int32 nIntValue = rVal.getInt();
switch( rName )
{
@@ -61,7 +63,7 @@ void CellColorHandler::lcl_attribute(Id rName, Value & rVal)
{
//might be clear, pct5...90, some hatch types
//TODO: The values need symbolic names!
m_nShadowType = nIntValue; //clear == 0, solid: 1, pct5: 2, pct50:8, pct95: x3c, horzStripe:0x0e, thinVertStripe: 0x15
m_nShadingPattern = nIntValue; //clear == 0, solid: 1, pct5: 2, pct50:8, pct95: x3c, horzStripe:0x0e, thinVertStripe: 0x15
}
break;
case NS_ooxml::LN_CT_Shd_fill:
@@ -93,88 +95,89 @@ void CellColorHandler::lcl_sprm(Sprm & rSprm)
TablePropertyMapPtr CellColorHandler::getProperties()
{
TablePropertyMapPtr pPropertyMap(new TablePropertyMap);
//code from binary word filter
// Code from binary word filter (the values are out of 1000)
static const sal_Int32 eMSGrayScale[] =
{
// Nul-Brush
0, // 0
// Clear-Brush
0, // 0 clear
// Solid-Brush
1000, // 1
// percent values
50, // 2
100, // 3
200, // 4
250, // 5
300, // 6
400, // 7
500, // 8
600, // 9
700, // 10
750, // 11
800, // 12
900, // 13
333, // 14 Dark Horizontal
333, // 15 Dark Vertical
333, // 16 Dark Forward Diagonal
333, // 17 Dark Backward Diagonal
333, // 18 Dark Cross
333, // 19 Dark Diagonal Cross
333, // 20 Horizontal
333, // 21 Vertical
333, // 22 Forward Diagonal
333, // 23 Backward Diagonal
333, // 24 Cross
333, // 25 Diagonal Cross
// some undefined values
500, // 26
500, // 27
500, // 28
500, // 29
500, // 30
500, // 31
500, // 32
500, // 33
500, // 34
// different shading types
25, // 35
75, // 36
125, // 37
150, // 38
175, // 39
225, // 40
275, // 41
325, // 42
350, // 43
375, // 44
425, // 45
450, // 46
475, // 47
525, // 48
550, // 49
575, // 50
625, // 51
650, // 52
675, // 53
725, // 54
775, // 55
825, // 56
850, // 57
875, // 58
925, // 59
950, // 60
975, // 61
// und zu guter Letzt:
970
1000, // 1 solid
// Percent values
50, // 2 pct5
100, // 3 pct10
200, // 4 pct20
250, // 5 pct25
300, // 6 pct30
400, // 7 pct40
500, // 8 pct50
600, // 9 pct60
700, // 10 pct70
750, // 11 pct75
800, // 12 pct80
900, // 13 pct90
// Special cases
333, // 14 Dark Horizontal
333, // 15 Dark Vertical
333, // 16 Dark Forward Diagonal
333, // 17 Dark Backward Diagonal
333, // 18 Dark Cross
333, // 19 Dark Diagonal Cross
333, // 20 Horizontal
333, // 21 Vertical
333, // 22 Forward Diagonal
333, // 23 Backward Diagonal
333, // 24 Cross
333, // 25 Diagonal Cross
// Undefined values in DOC spec-sheet
500, // 26
500, // 27
500, // 28
500, // 29
500, // 30
500, // 31
500, // 32
500, // 33
500, // 34
// Different shading types
25, // 35 [available in DOC, not available in DOCX]
75, // 36 [available in DOC, not available in DOCX]
125, // 37 pct12
150, // 38 pct15
175, // 39 [available in DOC, not available in DOCX]
225, // 40 [available in DOC, not available in DOCX]
275, // 41 [available in DOC, not available in DOCX]
325, // 42 [available in DOC, not available in DOCX]
350, // 43 pct35
375, // 44 pct37
425, // 45 [available in DOC, not available in DOCX]
450, // 46 pct45
475, // 47 [available in DOC, not available in DOCX]
525, // 48 [available in DOC, not available in DOCX]
550, // 49 pct55
575, // 50 [available in DOC, not available in DOCX]
625, // 51 pct62
650, // 52 pct65
675, // 53 [available in DOC, not available in DOCX]
725, // 54 [available in DOC, not available in DOCX]
775, // 55 [available in DOC, not available in DOCX]
825, // 56 [available in DOC, not available in DOCX]
850, // 57 pct85
875, // 58 pct87
925, // 59 [available in DOC, not available in DOCX]
950, // 60 pct95
975 // 61 [available in DOC, not available in DOCX]
};// 62
if( m_nShadowType >= (sal_Int32)SAL_N_ELEMENTS( eMSGrayScale ) )
m_nShadowType = 0;
sal_Int32 nWW8BrushStyle = eMSGrayScale[m_nShadowType];
if( m_nShadingPattern >= (sal_Int32)SAL_N_ELEMENTS( eMSGrayScale ) )
m_nShadingPattern = 0;
sal_Int32 nWW8BrushStyle = eMSGrayScale[m_nShadingPattern];
sal_Int32 nApplyColor = 0;
if( !nWW8BrushStyle )
{
// Null-Brush
nApplyColor = m_nFillColor;
// Clear-Brush
nApplyColor = m_nFillColor;
}
else
{
@@ -191,6 +194,79 @@ TablePropertyMapPtr CellColorHandler::getProperties()
nApplyColor = ( (nRed/1000) << 0x10 ) + ((nGreen/1000) << 8) + nBlue/1000;
}
// Check if it is a 'Character'
if (m_OutputFormat == Character)
{
static sal_Int32 aWWShadingPatterns[ ] =
{
ShadingPattern::CLEAR,
ShadingPattern::SOLID,
ShadingPattern::PCT5,
ShadingPattern::PCT10,
ShadingPattern::PCT20,
ShadingPattern::PCT25,
ShadingPattern::PCT30,
ShadingPattern::PCT40,
ShadingPattern::PCT50,
ShadingPattern::PCT60,
ShadingPattern::PCT70,
ShadingPattern::PCT75,
ShadingPattern::PCT80,
ShadingPattern::PCT90,
ShadingPattern::HORZ_STRIPE,
ShadingPattern::VERT_STRIPE,
ShadingPattern::REVERSE_DIAG_STRIPE,
ShadingPattern::DIAG_STRIPE,
ShadingPattern::HORZ_CROSS,
ShadingPattern::DIAG_CROSS,
ShadingPattern::THIN_HORZ_STRIPE,
ShadingPattern::THIN_VERT_STRIPE,
ShadingPattern::THIN_REVERSE_DIAG_STRIPE,
ShadingPattern::THIN_DIAG_STRIPE,
ShadingPattern::THIN_HORZ_CROSS,
ShadingPattern::THIN_DIAG_CROSS,
ShadingPattern::UNUSED_1,
ShadingPattern::UNUSED_2,
ShadingPattern::UNUSED_3,
ShadingPattern::UNUSED_4,
ShadingPattern::UNUSED_5,
ShadingPattern::UNUSED_6,
ShadingPattern::UNUSED_7,
ShadingPattern::UNUSED_8,
ShadingPattern::UNUSED_9,
ShadingPattern::PCT2,
ShadingPattern::PCT7,
ShadingPattern::PCT12,
ShadingPattern::PCT15,
ShadingPattern::PCT17,
ShadingPattern::PCT22,
ShadingPattern::PCT27,
ShadingPattern::PCT32,
ShadingPattern::PCT35,
ShadingPattern::PCT37,
ShadingPattern::PCT42,
ShadingPattern::PCT45,
ShadingPattern::PCT47,
ShadingPattern::PCT52,
ShadingPattern::PCT55,
ShadingPattern::PCT57,
ShadingPattern::PCT62,
ShadingPattern::PCT65,
ShadingPattern::PCT67,
ShadingPattern::PCT72,
ShadingPattern::PCT77,
ShadingPattern::PCT82,
ShadingPattern::PCT85,
ShadingPattern::PCT87,
ShadingPattern::PCT92,
ShadingPattern::PCT95,
ShadingPattern::PCT97
};
// Write the shading pattern property
pPropertyMap->Insert(PROP_CHAR_SHADING_VALUE, false, uno::makeAny( aWWShadingPatterns[m_nShadingPattern] ));
}
pPropertyMap->Insert( m_OutputFormat == Form ? PROP_BACK_COLOR
: m_OutputFormat == Paragraph ? PROP_PARA_BACK_COLOR
: PROP_CHAR_BACK_COLOR, false, uno::makeAny( nApplyColor ));
diff --git a/writerfilter/source/dmapper/CellColorHandler.hxx b/writerfilter/source/dmapper/CellColorHandler.hxx
index 05881ee..27f18fd 100644
--- a/writerfilter/source/dmapper/CellColorHandler.hxx
+++ b/writerfilter/source/dmapper/CellColorHandler.hxx
@@ -32,7 +32,7 @@ class WRITERFILTER_DLLPRIVATE CellColorHandler : public LoggedProperties
public:
enum OutputFormat { Form, Paragraph, Character }; // for what part of the document
private:
sal_Int32 m_nShadowType;
sal_Int32 m_nShadingPattern;
sal_Int32 m_nColor;
sal_Int32 m_nFillColor;
OutputFormat m_OutputFormat;
diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx
index e506ee8..dd57a84 100644
--- a/writerfilter/source/dmapper/PropertyIds.cxx
+++ b/writerfilter/source/dmapper/PropertyIds.cxx
@@ -325,6 +325,7 @@ const OUString& PropertyNameSupplier::GetName( PropertyIds eId ) const
case PROP_IS_WIDTH_RELATIVE: sName = "IsWidthRelative"; break;
case PROP_GRAPHIC_URL: sName = "GraphicURL"; break;
case PROP_GRAPHIC_BITMAP: sName = "GraphicBitmap"; break;
case PROP_CHAR_SHADING_VALUE: sName = "CharShadingValue"; break;
}
::std::pair<PropertyNameMap_t::iterator,bool> aInsertIt =
m_pImpl->aNameMap.insert( PropertyNameMap_t::value_type( eId, sName ));
diff --git a/writerfilter/source/dmapper/PropertyIds.hxx b/writerfilter/source/dmapper/PropertyIds.hxx
index 1c6b83e..1357c1d 100644
--- a/writerfilter/source/dmapper/PropertyIds.hxx
+++ b/writerfilter/source/dmapper/PropertyIds.hxx
@@ -296,6 +296,7 @@ enum PropertyIds
,PROP_IS_WIDTH_RELATIVE
,PROP_GRAPHIC_URL
,PROP_GRAPHIC_BITMAP
,PROP_CHAR_SHADING_VALUE
};
struct PropertyNameSupplier_Impl;
class PropertyNameSupplier
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
index e9b2d6a..e0d35a9 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -21582,10 +21582,23 @@
<attribute name="shadow" tokenid="rtf:FSHADOW"/>
<attribute name="frame" tokenid="rtf:FFRAME"/>
</resource>
<!-- This DOCX values will be mapped to match the 'DOC' values that are defined here: -->
<!-- http://msdn.microsoft.com/en-us/library/dd945712(v=office.12).aspx -->
<resource name="ST_Shd" resource="List">
<value tokenid="0">nil</value>
<value tokenid="0">clear</value>
<value tokenid="1">solid</value>
<value tokenid="2">pct5</value>
<value tokenid="3">pct10</value>
<value tokenid="4">pct20</value>
<value tokenid="5">pct25</value>
<value tokenid="6">pct30</value>
<value tokenid="7">pct40</value>
<value tokenid="8">pct50</value>
<value tokenid="9">pct60</value>
<value tokenid="10">pct70</value>
<value tokenid="11">pct75</value>
<value tokenid="12">pct80</value>
<value tokenid="13">pct90</value>
<value tokenid="14">horzStripe</value>
<value tokenid="15">vertStripe</value>
<value tokenid="17">reverseDiagStripe</value>
@@ -21598,29 +21611,18 @@
<value tokenid="22">thinDiagStripe</value>
<value tokenid="24">thinHorzCross</value>
<value tokenid="25">thinDiagCross</value>
<value tokenid="2">pct5</value>
<value tokenid="3">pct10</value>
<value tokenid="27">pct12</value>
<value tokenid="28">pct15</value>
<value tokenid="4">pct20</value>
<value tokenid="5">pct25</value>
<value tokenid="6">pct30</value>
<value tokenid="37">pct12</value>
<value tokenid="38">pct15</value>
<value tokenid="43">pct35</value>
<value tokenid="44">pct37</value>
<value tokenid="7">pct40</value>
<value tokenid="46">pct45</value>
<value tokenid="8">pct50</value>
<value tokenid="49">pct55</value>
<value tokenid="9">pct60</value>
<value tokenid="51">pct62</value>
<value tokenid="52">pct65</value>
<value tokenid="10">pct70</value>
<value tokenid="11">pct75</value>
<value tokenid="12">pct80</value>
<value tokenid="57">pct85</value>
<value tokenid="58">pct87</value>
<value tokenid="13">pct90</value>
<value tokenid="60">pct95</value>
<value tokenid="65535">nil</value>
</resource>
<resource name="CT_Shd" resource="Properties" tag="attribute">
<attribute name="val" tokenid="ooxml:CT_Shd_val"/>