Kaydet (Commit) c3e49660 authored tarafından Michael Stahl's avatar Michael Stahl

tdf#90640: sw: ODF export: be consistent when exporting RES_BACKGROUND

The emulation of legacy RES_BACKGROUND properties claims that (unless
fillstyle is NONE) all of them are direct values, which causes export of
legacy attributes like style:background-transparency without
corresponding non-legacy draw:opacity.

Especially problematic for style:background-transparency, which is set
to 100% if style is bitmap, which is the reasonable default for API
backward compatibility of BackColorTransparency, but wrong for ODF.

Change-Id: I1fa4fa5df45eb00cbfcd2e171b4862c4e195cc7d
üst 822cb231
...@@ -77,7 +77,7 @@ bool UCB_IsDirectory( const OUString& rURL ); ...@@ -77,7 +77,7 @@ bool UCB_IsDirectory( const OUString& rURL );
///UUUU helper to check if fill style is set to color or bitmap ///UUUU helper to check if fill style is set to color or bitmap
/// and thus formally used SvxBrushItem parts need to be mapped /// and thus formally used SvxBrushItem parts need to be mapped
/// for backwards compatibility /// for backwards compatibility
bool needToMapFillItemsToSvxBrushItemTypes(const SfxItemSet& rSet); bool needToMapFillItemsToSvxBrushItemTypes(const SfxItemSet& rSet, sal_uInt16 const nMemberId);
} }
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
//UUUU //UUUU
#include <svx/xfillit0.hxx> #include <svx/xfillit0.hxx>
#include <editeng/memberids.hrc>
#include <svl/itemset.hxx> #include <svl/itemset.hxx>
using namespace com::sun::star; using namespace com::sun::star;
...@@ -268,7 +269,8 @@ bool UCB_GetFileListOfFolder( const OUString& rURL, ...@@ -268,7 +269,8 @@ bool UCB_GetFileListOfFolder( const OUString& rURL,
} }
//UUUU //UUUU
bool needToMapFillItemsToSvxBrushItemTypes(const SfxItemSet& rSet) bool needToMapFillItemsToSvxBrushItemTypes(const SfxItemSet& rSet,
sal_uInt16 const nMID)
{ {
const XFillStyleItem* pXFillStyleItem(static_cast< const XFillStyleItem* >(rSet.GetItem(XATTR_FILLSTYLE, false))); const XFillStyleItem* pXFillStyleItem(static_cast< const XFillStyleItem* >(rSet.GetItem(XATTR_FILLSTYLE, false)));
...@@ -280,17 +282,50 @@ bool needToMapFillItemsToSvxBrushItemTypes(const SfxItemSet& rSet) ...@@ -280,17 +282,50 @@ bool needToMapFillItemsToSvxBrushItemTypes(const SfxItemSet& rSet)
// here different FillStyles can be excluded for export; it will depend on the // here different FillStyles can be excluded for export; it will depend on the
// quality these fallbacks can reach. That again is done in getSvxBrushItemFromSourceSet, // quality these fallbacks can reach. That again is done in getSvxBrushItemFromSourceSet,
// take a look there how the superset of DrawObject FillStyles is mapped to SvxBrushItem. // take a look there how the superset of DrawObject FillStyles is mapped to SvxBrushItem.
// For now, take them all - except drawing::FillStyle_NONE switch (pXFillStyleItem->GetValue())
if(drawing::FillStyle_NONE != pXFillStyleItem->GetValue())
{ {
return true; case drawing::FillStyle_NONE:
return false; // ignoring some extremely limited XFillColorItem eval
break;
case drawing::FillStyle_SOLID:
case drawing::FillStyle_GRADIENT: // gradient and hatch don't exist in
case drawing::FillStyle_HATCH: // SvxBrushItem so average color is emulated
switch (nMID)
{
case MID_BACK_COLOR:
// Gradient/Hatch always have emulated color
return (drawing::FillStyle_SOLID != nMID)
|| SfxItemState::SET == rSet.GetItemState(XATTR_FILLCOLOR)
|| SfxItemState::SET == rSet.GetItemState(XATTR_FILLTRANSPARENCE)
|| SfxItemState::SET == rSet.GetItemState(XATTR_FILLFLOATTRANSPARENCE);
case MID_BACK_COLOR_R_G_B:
// Gradient/Hatch always have emulated color
return (drawing::FillStyle_SOLID != nMID)
|| SfxItemState::SET == rSet.GetItemState(XATTR_FILLCOLOR);
case MID_BACK_COLOR_TRANSPARENCY:
return SfxItemState::SET == rSet.GetItemState(XATTR_FILLTRANSPARENCE)
|| SfxItemState::SET == rSet.GetItemState(XATTR_FILLFLOATTRANSPARENCE);
}
break;
case drawing::FillStyle_BITMAP:
switch (nMID)
{
case MID_GRAPHIC_URL:
return SfxItemState::SET == rSet.GetItemState(XATTR_FILLBITMAP);
case MID_GRAPHIC_POSITION:
return SfxItemState::SET == rSet.GetItemState(XATTR_FILLBMP_STRETCH)
|| SfxItemState::SET == rSet.GetItemState(XATTR_FILLBMP_TILE)
|| SfxItemState::SET == rSet.GetItemState(XATTR_FILLBMP_POS);
case MID_GRAPHIC_TRANSPARENT:
case MID_GRAPHIC_TRANSPARENCY:
return SfxItemState::SET == rSet.GetItemState(XATTR_FILLTRANSPARENCE)
|| SfxItemState::SET == rSet.GetItemState(XATTR_FILLFLOATTRANSPARENCE);
}
break;
default:
assert(false);
} }
// if(XFILL_SOLID == pXFillStyleItem->GetValue() || XFILL_BITMAP == pXFillStyleItem->GetValue())
// {
// return true;
// }
return false; return false;
} }
......
...@@ -2406,13 +2406,16 @@ uno::Sequence< beans::PropertyState > SwXFrame::getPropertyStates( ...@@ -2406,13 +2406,16 @@ uno::Sequence< beans::PropertyState > SwXFrame::getPropertyStates(
pStates[i] = beans::PropertyState_AMBIGUOUS_VALUE; pStates[i] = beans::PropertyState_AMBIGUOUS_VALUE;
} }
} }
//UUUU for FlyFrames we need to mark all properties from type RES_BACKGROUND //UUUU for FlyFrames we need to mark the used properties from type RES_BACKGROUND
// as beans::PropertyState_DIRECT_VALUE to let users of this property call // as beans::PropertyState_DIRECT_VALUE to let users of this property call
// getPropertyValue where the member properties will be mapped from the // getPropertyValue where the member properties will be mapped from the
// fill attributes to the according SvxBrushItem entries // fill attributes to the according SvxBrushItem entries
else if(RES_BACKGROUND == pEntry->nWID && SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(rFmtSet)) else if (RES_BACKGROUND == pEntry->nWID)
{ {
pStates[i] = beans::PropertyState_DIRECT_VALUE; if (SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(rFmtSet, pEntry->nMemberId))
pStates[i] = beans::PropertyState_DIRECT_VALUE;
else
pStates[i] = beans::PropertyState_DEFAULT_VALUE;
} }
else else
{ {
......
...@@ -1031,11 +1031,12 @@ static beans::PropertyState lcl_SwXParagraph_getPropertyState( ...@@ -1031,11 +1031,12 @@ static beans::PropertyState lcl_SwXParagraph_getPropertyState(
{ {
if(*ppSet) if(*ppSet)
{ {
if(SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(**ppSet)) if (SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(**ppSet,
rEntry.nMemberId))
{ {
eRet = beans::PropertyState_DIRECT_VALUE; eRet = beans::PropertyState_DIRECT_VALUE;
bDone = true;
} }
bDone = true;
} }
break; break;
} }
......
...@@ -2920,14 +2920,20 @@ uno::Sequence< beans::PropertyState > SwXStyle::getPropertyStates( ...@@ -2920,14 +2920,20 @@ uno::Sequence< beans::PropertyState > SwXStyle::getPropertyStates(
bDone = true; bDone = true;
} }
//UUUU for FlyFrames we need to mark all properties from type RES_BACKGROUND //UUUU for FlyFrames we need to mark the used properties from type RES_BACKGROUND
// as beans::PropertyState_DIRECT_VALUE to let users of this property call // as beans::PropertyState_DIRECT_VALUE to let users of this property call
// getPropertyValue where the member properties will be mapped from the // getPropertyValue where the member properties will be mapped from the
// fill attributes to the according SvxBrushItem entries // fill attributes to the according SvxBrushItem entries
if(!bDone && RES_BACKGROUND == pEntry->nWID if (!bDone && RES_BACKGROUND == pEntry->nWID)
&& SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(*pSourceSet))
{ {
pStates[i] = beans::PropertyState_DIRECT_VALUE; if (SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(*pSourceSet, pEntry->nMemberId))
{
pStates[i] = beans::PropertyState_DIRECT_VALUE;
}
else
{
pStates[i] = beans::PropertyState_DEFAULT_VALUE;
}
bDone = true; bDone = true;
} }
...@@ -4870,11 +4876,16 @@ uno::Sequence< beans::PropertyState > SwXAutoStyle::getPropertyStates( ...@@ -4870,11 +4876,16 @@ uno::Sequence< beans::PropertyState > SwXAutoStyle::getPropertyStates(
} }
case RES_BACKGROUND: case RES_BACKGROUND:
{ {
if(SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(*mpSet)) if (SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(*mpSet,
pEntry->nMemberId))
{ {
pStates[i] = beans::PropertyState_DIRECT_VALUE; pStates[i] = beans::PropertyState_DIRECT_VALUE;
bDone = true;
} }
else
{
pStates[i] = beans::PropertyState_DEFAULT_VALUE;
}
bDone = true;
break; break;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment