Author: alg
Date: Thu Jan 16 21:42:27 2014
New Revision: 1558923
URL: http://svn.apache.org/r1558923
Log:
Added better export fallbacks to old FillAttributes for Gradient, Hatch and
FillFloatTransparence settings
Modified:
openoffice/branches/alg_writerframes/main/sw/inc/hintids.hxx
openoffice/branches/alg_writerframes/main/sw/source/core/unocore/unobrushitemhelper.cxx
openoffice/branches/alg_writerframes/main/sw/source/core/unocore/unoframe.cxx
Modified: openoffice/branches/alg_writerframes/main/sw/inc/hintids.hxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/alg_writerframes/main/sw/inc/hintids.hxx?rev=1558923&r1=1558922&r2=1558923&view=diff
==============================================================================
--- openoffice/branches/alg_writerframes/main/sw/inc/hintids.hxx (original)
+++ openoffice/branches/alg_writerframes/main/sw/inc/hintids.hxx Thu Jan 16
21:42:27 2014
@@ -281,13 +281,13 @@ RES_UNKNOWNATR_END
enum RES_FMT
{
RES_FMT_BEGIN = RES_UNKNOWNATR_END,
- RES_CHRFMT = RES_FMT_BEGIN,
- RES_FRMFMT,
- RES_FLYFRMFMT,
- RES_TXTFMTCOLL,
- RES_GRFFMTCOLL,
- RES_DRAWFRMFMT,
- RES_CONDTXTFMTCOLL,
+ RES_CHRFMT = RES_FMT_BEGIN, // 144
+ RES_FRMFMT, // 145
+ RES_FLYFRMFMT, // 146
+ RES_TXTFMTCOLL, // 147
+ RES_GRFFMTCOLL, // 148
+ RES_DRAWFRMFMT, // 149
+ RES_CONDTXTFMTCOLL, // 150
RES_FMT_END
};
@@ -295,7 +295,7 @@ RES_FMT_END
enum RES_MSG
{
RES_MSG_BEGIN = RES_FMT_END,
- RES_OBJECTDYING = RES_MSG_BEGIN,
+ RES_OBJECTDYING = RES_MSG_BEGIN, // 151
RES_FMT_CHG,
RES_ATTRSET_CHG,
RES_FRM_SIZECHG,
Modified:
openoffice/branches/alg_writerframes/main/sw/source/core/unocore/unobrushitemhelper.cxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/alg_writerframes/main/sw/source/core/unocore/unobrushitemhelper.cxx?rev=1558923&r1=1558922&r2=1558923&view=diff
==============================================================================
---
openoffice/branches/alg_writerframes/main/sw/source/core/unocore/unobrushitemhelper.cxx
(original)
+++
openoffice/branches/alg_writerframes/main/sw/source/core/unocore/unobrushitemhelper.cxx
Thu Jan 16 21:42:27 2014
@@ -133,6 +133,43 @@ void setSvxBrushItemAsFillAttributesToTa
}
//UUUU
+sal_uInt16 getTransparenceForSvxBrushItem(const SfxItemSet& rSourceSet,
sal_Bool bSearchInParents)
+{
+ sal_uInt16 nFillTransparence(static_cast< const XFillTransparenceItem&
>(rSourceSet.Get(XATTR_FILLTRANSPARENCE, bSearchInParents)).GetValue());
+ const SfxPoolItem* pGradientItem = 0;
+
+ if(SFX_ITEM_SET == rSourceSet.GetItemState(XATTR_FILLFLOATTRANSPARENCE,
bSearchInParents, &pGradientItem)
+ && static_cast< const XFillFloatTransparenceItem*
>(pGradientItem)->IsEnabled())
+ {
+ const XGradient& rGradient = static_cast< const
XFillFloatTransparenceItem* >(pGradientItem)->GetGradientValue();
+ const sal_uInt16
nStartLuminance(rGradient.GetStartColor().GetLuminance());
+ const sal_uInt16 nEndLuminance(rGradient.GetEndColor().GetLuminance());
+
+ // luminance is [0..255], transparence needs to be in [0..100].Maximum
is 51200, thus sal_uInt16 is okay to use
+ nFillTransparence = static_cast< sal_uInt16 >(((nStartLuminance +
nEndLuminance) * 100) / 512);
+ }
+
+ return nFillTransparence;
+}
+
+//UUUU
+SvxBrushItem getSvxBrushItemForSolid(const SfxItemSet& rSourceSet, sal_Bool
bSearchInParents)
+{
+ Color aFillColor(static_cast< const XFillColorItem&
>(rSourceSet.Get(XATTR_FILLCOLOR, bSearchInParents)).GetColorValue());
+
+ // get evtl. mixed transparence
+ const sal_uInt16
nFillTransparence(getTransparenceForSvxBrushItem(rSourceSet, bSearchInParents));
+
+ if(0 != nFillTransparence)
+ {
+ // nFillTransparence is in range [0..100] and needs to be in [0..255]
unsigned
+ aFillColor.SetTransparency(static_cast< sal_uInt8 >((nFillTransparence
* 255) / 100));
+ }
+
+ return SvxBrushItem(aFillColor, RES_BACKGROUND);
+}
+
+//UUUU
SvxBrushItem getSvxBrushItemFromSourceSet(const SfxItemSet& rSourceSet,
sal_Bool bSearchInParents)
{
SvxBrushItem aRetval(RES_BACKGROUND);
@@ -154,21 +191,60 @@ SvxBrushItem getSvxBrushItemFromSourceSe
case XFILL_SOLID:
{
// create SvxBrushItem with fill color
- Color aFillColor(static_cast< const XFillColorItem&
>(rSourceSet.Get(XATTR_FILLCOLOR, bSearchInParents)).GetColorValue());
- const sal_uInt16 nFillTransparence(static_cast< const
XFillTransparenceItem& >(rSourceSet.Get(XATTR_FILLTRANSPARENCE,
bSearchInParents)).GetValue());
+ aRetval = getSvxBrushItemForSolid(rSourceSet, bSearchInParents);
+ break;
+ }
+ case XFILL_GRADIENT:
+ {
+ // cannot be directly supported, but do the best possible
+ const XGradient aXGradient(static_cast< const XFillGradientItem&
>(rSourceSet.Get(XATTR_FILLGRADIENT)).GetGradientValue());
+ const basegfx::BColor
aStartColor(aXGradient.GetStartColor().getBColor() *
(aXGradient.GetStartIntens() * 0.01));
+ const basegfx::BColor
aEndColor(aXGradient.GetEndColor().getBColor() * (aXGradient.GetEndIntens() *
0.01));
+
+ // use half/half mixed color from gradient start and end
+ Color aMixedColor((aStartColor + aEndColor) * 0.5);
+
+ // get evtl. mixed transparence
+ const sal_uInt16
nFillTransparence(getTransparenceForSvxBrushItem(rSourceSet, bSearchInParents));
if(0 != nFillTransparence)
{
// nFillTransparence is in range [0..100] and needs to be in
[0..255] unsigned
- aFillColor.SetTransparency(static_cast< sal_uInt8
>((nFillTransparence * 255) / 100));
+ aMixedColor.SetTransparency(static_cast< sal_uInt8
>((nFillTransparence * 255) / 100));
}
- aRetval = SvxBrushItem(aFillColor, RES_BACKGROUND);
+ aRetval = SvxBrushItem(aMixedColor, RES_BACKGROUND);
+ break;
}
- case XFILL_GRADIENT:
case XFILL_HATCH:
{
- // cannot be supported
+ // cannot be directly supported, but do the best possible
+ const XHatch& rHatch(static_cast< const XFillHatchItem&
>(rSourceSet.Get(XATTR_FILLHATCH)).GetHatchValue());
+ const bool bFillBackground(static_cast< const XFillBackgroundItem&
>(rSourceSet.Get(XATTR_FILLBACKGROUND)).GetValue());
+
+ if(bFillBackground)
+ {
+ // hatch is background-filled, use FillColor as if XFILL_SOLID
+ aRetval = getSvxBrushItemForSolid(rSourceSet,
bSearchInParents);
+ }
+ else
+ {
+ // hatch is not background-filled and using hatch color would
be too dark; compensate
+ // somewhat by making it more transparent
+ Color aHatchColor(rHatch.GetColor());
+
+ // get evtl. mixed transparence
+ sal_uInt16
nFillTransparence(getTransparenceForSvxBrushItem(rSourceSet, bSearchInParents));
+
+ // take half orig transparence, add half transparent, clamp
result
+ nFillTransparence =
basegfx::clamp((sal_uInt16)((nFillTransparence / 2) + 50), (sal_uInt16)0,
(sal_uInt16)255);
+
+ // nFillTransparence is in range [0..100] and needs to be in
[0..255] unsigned
+ aHatchColor.SetTransparency(static_cast< sal_uInt8
>((nFillTransparence * 255) / 100));
+
+ aRetval = SvxBrushItem(aHatchColor, RES_BACKGROUND);
+ }
+
break;
}
case XFILL_BITMAP:
@@ -213,7 +289,8 @@ SvxBrushItem getSvxBrushItemFromSourceSe
// create with given graphic and position
aRetval = SvxBrushItem(aGraphic, aSvxGraphicPosition,
RES_BACKGROUND);
- const sal_uInt16 nFillTransparence(static_cast< const
XFillTransparenceItem& >(rSourceSet.Get(XATTR_FILLTRANSPARENCE,
bSearchInParents)).GetValue());
+ // get evtl. mixed transparence
+ const sal_uInt16
nFillTransparence(getTransparenceForSvxBrushItem(rSourceSet, bSearchInParents));
if(0 != nFillTransparence)
{
Modified:
openoffice/branches/alg_writerframes/main/sw/source/core/unocore/unoframe.cxx
URL:
http://svn.apache.org/viewvc/openoffice/branches/alg_writerframes/main/sw/source/core/unocore/unoframe.cxx?rev=1558923&r1=1558922&r2=1558923&view=diff
==============================================================================
---
openoffice/branches/alg_writerframes/main/sw/source/core/unocore/unoframe.cxx
(original)
+++
openoffice/branches/alg_writerframes/main/sw/source/core/unocore/unoframe.cxx
Thu Jan 16 21:42:27 2014
@@ -2307,11 +2307,21 @@ bool SwXFrame::needToMapFillItemsToSvxBr
return false;
}
- if(XFILL_SOLID == pXFillStyleItem->GetValue() || XFILL_BITMAP ==
pXFillStyleItem->GetValue())
+ //UUUU here different FillStyles can be excluded for export; it will
depend on the
+ // 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.
+ // For now, take them all - except XFILL_NONE
+
+ if(XFILL_NONE != pXFillStyleItem->GetValue())
{
return true;
}
+ //if(XFILL_SOLID == pXFillStyleItem->GetValue() || XFILL_BITMAP ==
pXFillStyleItem->GetValue())
+ //{
+ // return true;
+ //}
+
return false;
}