xref: /AOO42X/main/svx/source/unodraw/unobrushitemhelper.cxx (revision b1c5455db1639c48e26c568e4fa7ee78ca5d60ee)
156b35d86SArmin Le Grand /**************************************************************
256b35d86SArmin Le Grand  *
356b35d86SArmin Le Grand  * Licensed to the Apache Software Foundation (ASF) under one
456b35d86SArmin Le Grand  * or more contributor license agreements.  See the NOTICE file
556b35d86SArmin Le Grand  * distributed with this work for additional information
656b35d86SArmin Le Grand  * regarding copyright ownership.  The ASF licenses this file
756b35d86SArmin Le Grand  * to you under the Apache License, Version 2.0 (the
856b35d86SArmin Le Grand  * "License"); you may not use this file except in compliance
956b35d86SArmin Le Grand  * with the License.  You may obtain a copy of the License at
1056b35d86SArmin Le Grand  *
1156b35d86SArmin Le Grand  *   http://www.apache.org/licenses/LICENSE-2.0
1256b35d86SArmin Le Grand  *
1356b35d86SArmin Le Grand  * Unless required by applicable law or agreed to in writing,
1456b35d86SArmin Le Grand  * software distributed under the License is distributed on an
1556b35d86SArmin Le Grand  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1656b35d86SArmin Le Grand  * KIND, either express or implied.  See the License for the
1756b35d86SArmin Le Grand  * specific language governing permissions and limitations
1856b35d86SArmin Le Grand  * under the License.
1956b35d86SArmin Le Grand  *
2056b35d86SArmin Le Grand  *************************************************************/
2156b35d86SArmin Le Grand 
2256b35d86SArmin Le Grand // MARKER(update_precomp.py): autogen include statement, do not remove
2356b35d86SArmin Le Grand #include "precompiled_svx.hxx"
2456b35d86SArmin Le Grand 
2556b35d86SArmin Le Grand #include <svx/unobrushitemhelper.hxx>
2656b35d86SArmin Le Grand #include <svx/xfillit0.hxx>
2756b35d86SArmin Le Grand #include <svx/xbtmpit.hxx>
2856b35d86SArmin Le Grand #include <svx/xgrscit.hxx>
2956b35d86SArmin Le Grand #include <svx/xflbmtit.hxx>
3056b35d86SArmin Le Grand #include <svx/xflbmpit.hxx>
3156b35d86SArmin Le Grand #include <svx/xflbmsxy.hxx>
3256b35d86SArmin Le Grand #include <svx/xflbmsxy.hxx>
3356b35d86SArmin Le Grand #include <svx/xflftrit.hxx>
3456b35d86SArmin Le Grand #include <svx/xsflclit.hxx>
3556b35d86SArmin Le Grand #include <svx/xflbmsli.hxx>
3656b35d86SArmin Le Grand #include <svx/xflbtoxy.hxx>
3756b35d86SArmin Le Grand #include <svx/xflbstit.hxx>
3856b35d86SArmin Le Grand #include <svx/xflboxy.hxx>
3956b35d86SArmin Le Grand #include <svx/xflbckit.hxx>
4056b35d86SArmin Le Grand #include <svx/xflclit.hxx>
4156b35d86SArmin Le Grand #include <svx/xfltrit.hxx>
4256b35d86SArmin Le Grand #include <svx/xflhtit.hxx>
4356b35d86SArmin Le Grand #include <svx/unoshape.hxx>
4456b35d86SArmin Le Grand 
4556b35d86SArmin Le Grand //UUUU
setSvxBrushItemAsFillAttributesToTargetSet(const SvxBrushItem & rBrush,SfxItemSet & rToSet)4656b35d86SArmin Le Grand void setSvxBrushItemAsFillAttributesToTargetSet(const SvxBrushItem& rBrush, SfxItemSet& rToSet)
4756b35d86SArmin Le Grand {
4856b35d86SArmin Le Grand     // Clear all items from the DrawingLayer FillStyle range (if we have any). All
4956b35d86SArmin Le Grand     // items that need to be set will be set as hard attributes
5056b35d86SArmin Le Grand     for(sal_uInt16 a(XATTR_FILL_FIRST); rToSet.Count() && a < XATTR_FILL_LAST; a++)
5156b35d86SArmin Le Grand     {
5256b35d86SArmin Le Grand         rToSet.ClearItem(a);
5356b35d86SArmin Le Grand     }
5456b35d86SArmin Le Grand 
5556b35d86SArmin Le Grand     const sal_uInt8 nTransparency(rBrush.GetColor().GetTransparency());
5656b35d86SArmin Le Grand 
5756b35d86SArmin Le Grand     if(0xff != nTransparency)
5856b35d86SArmin Le Grand     {
5956b35d86SArmin Le Grand         // we have a color fill
6056b35d86SArmin Le Grand         const Color aColor(rBrush.GetColor().GetRGBColor());
6156b35d86SArmin Le Grand 
6256b35d86SArmin Le Grand         rToSet.Put(XFillStyleItem(XFILL_SOLID));
6356b35d86SArmin Le Grand         rToSet.Put(XFillColorItem(String(), aColor));
6456b35d86SArmin Le Grand 
65*09ef3841SArmin Le Grand         // #125189# nTransparency is in range [0..254], convert to [0..100] which is used in
66*09ef3841SArmin Le Grand         // XFillTransparenceItem (caution with the range which is in an *item-specific* range)
67*09ef3841SArmin Le Grand         rToSet.Put(XFillTransparenceItem((((sal_Int32)nTransparency * 100) + 127) / 254));
6856b35d86SArmin Le Grand     }
6956b35d86SArmin Le Grand     else if(GPOS_NONE != rBrush.GetGraphicPos())
7056b35d86SArmin Le Grand     {
7156b35d86SArmin Le Grand         // we have a graphic fill, set fill style
7256b35d86SArmin Le Grand         rToSet.Put(XFillStyleItem(XFILL_BITMAP));
7356b35d86SArmin Le Grand 
7456b35d86SArmin Le Grand         // set graphic (if available)
7556b35d86SArmin Le Grand         const Graphic* pGraphic = rBrush.GetGraphic();
7656b35d86SArmin Le Grand 
7756b35d86SArmin Le Grand         if(pGraphic)
7856b35d86SArmin Le Grand         {
7956b35d86SArmin Le Grand             rToSet.Put(XFillBitmapItem(String(), *pGraphic));
8056b35d86SArmin Le Grand         }
8156b35d86SArmin Le Grand         else
8256b35d86SArmin Le Grand         {
8356b35d86SArmin Le Grand             OSL_ENSURE(false, "Could not get Graphic from SvxBrushItem (!)");
8456b35d86SArmin Le Grand         }
8556b35d86SArmin Le Grand 
8656b35d86SArmin Le Grand         if(GPOS_AREA == rBrush.GetGraphicPos())
8756b35d86SArmin Le Grand         {
8856b35d86SArmin Le Grand             // stretch, also means no tile (both items are defaulted to true)
8956b35d86SArmin Le Grand             rToSet.Put(XFillBmpStretchItem(true));
9056b35d86SArmin Le Grand             rToSet.Put(XFillBmpTileItem(false));
9156b35d86SArmin Le Grand 
9256b35d86SArmin Le Grand             // default for strech is also top-left, but this will not be visible
9356b35d86SArmin Le Grand             rToSet.Put(XFillBmpPosItem(RP_LT));
9456b35d86SArmin Le Grand         }
9556b35d86SArmin Le Grand         else if(GPOS_TILED == rBrush.GetGraphicPos())
9656b35d86SArmin Le Grand         {
9756b35d86SArmin Le Grand             // tiled, also means no stretch (both items are defaulted to true)
9856b35d86SArmin Le Grand             rToSet.Put(XFillBmpStretchItem(false));
9956b35d86SArmin Le Grand             rToSet.Put(XFillBmpTileItem(true));
10056b35d86SArmin Le Grand 
10156b35d86SArmin Le Grand             // default for tiled is top-left
10256b35d86SArmin Le Grand             rToSet.Put(XFillBmpPosItem(RP_LT));
10356b35d86SArmin Le Grand         }
10456b35d86SArmin Le Grand         else
10556b35d86SArmin Le Grand         {
10656b35d86SArmin Le Grand             // everything else means no tile and no stretch
10756b35d86SArmin Le Grand             rToSet.Put(XFillBmpStretchItem(false));
10856b35d86SArmin Le Grand             rToSet.Put(XFillBmpTileItem(false));
10956b35d86SArmin Le Grand 
11056b35d86SArmin Le Grand             RECT_POINT aRectPoint(RP_MM);
11156b35d86SArmin Le Grand 
11256b35d86SArmin Le Grand             switch(rBrush.GetGraphicPos())
11356b35d86SArmin Le Grand             {
11456b35d86SArmin Le Grand                 case GPOS_LT: aRectPoint = RP_LT; break;
11556b35d86SArmin Le Grand                 case GPOS_MT: aRectPoint = RP_MT; break;
11656b35d86SArmin Le Grand                 case GPOS_RT: aRectPoint = RP_RT; break;
11756b35d86SArmin Le Grand                 case GPOS_LM: aRectPoint = RP_LM; break;
11856b35d86SArmin Le Grand                 case GPOS_MM: aRectPoint = RP_MM; break;
11956b35d86SArmin Le Grand                 case GPOS_RM: aRectPoint = RP_RM; break;
12056b35d86SArmin Le Grand                 case GPOS_LB: aRectPoint = RP_LB; break;
12156b35d86SArmin Le Grand                 case GPOS_MB: aRectPoint = RP_MB; break;
12256b35d86SArmin Le Grand                 case GPOS_RB: aRectPoint = RP_RB; break;
12356b35d86SArmin Le Grand                 default: break; // GPOS_NONE, GPOS_AREA and GPOS_TILED already handled
12456b35d86SArmin Le Grand             }
12556b35d86SArmin Le Grand 
12656b35d86SArmin Le Grand             rToSet.Put(XFillBmpPosItem(aRectPoint));
12756b35d86SArmin Le Grand         }
12856b35d86SArmin Le Grand 
12956b35d86SArmin Le Grand         // check for graphic's transparency
13056b35d86SArmin Le Grand         const sal_Int8 nGraphicTransparency(rBrush.getGraphicTransparency());
13156b35d86SArmin Le Grand 
13256b35d86SArmin Le Grand         if(0 != nGraphicTransparency)
13356b35d86SArmin Le Grand         {
13456b35d86SArmin Le Grand             // nGraphicTransparency is in range [0..100]
13556b35d86SArmin Le Grand             rToSet.Put(XFillTransparenceItem(nGraphicTransparency));
13656b35d86SArmin Le Grand         }
13756b35d86SArmin Le Grand     }
13856b35d86SArmin Le Grand     else
13956b35d86SArmin Le Grand     {
14056b35d86SArmin Le Grand         // GPOS_NONE == rBrush.GetGraphicPos() && 0xff == rBrush.GetColor().GetTransparency(),
14156b35d86SArmin Le Grand         // still need to rescue the color used. There are sequences used on the UNO API at
14256b35d86SArmin Le Grand         // import time (OLE. e.g. chart) which first set RGB color (MID_BACK_COLOR_R_G_B,
14356b35d86SArmin Le Grand         // color stays transparent) and then set transparency (MID_BACK_COLOR_TRANSPARENCY)
14456b35d86SArmin Le Grand         // to zero later. When not saving the color, it will be lost.
14556b35d86SArmin Le Grand         // Also need to set the FillStyle to NONE to express the 0xff transparency flag; this
14656b35d86SArmin Le Grand         // is needed when e.g. first transparency is set to 0xff and then a Graphic gets set.
14756b35d86SArmin Le Grand         // When not changing the FillStyle, the next getSvxBrushItemFromSourceSet *will* return
14856b35d86SArmin Le Grand         // to XFILL_SOLID with the rescued color.
14956b35d86SArmin Le Grand         const Color aColor(rBrush.GetColor().GetRGBColor());
15056b35d86SArmin Le Grand 
15156b35d86SArmin Le Grand         rToSet.Put(XFillStyleItem(XFILL_NONE));
15256b35d86SArmin Le Grand         rToSet.Put(XFillColorItem(String(), aColor));
15356b35d86SArmin Le Grand     }
15456b35d86SArmin Le Grand }
15556b35d86SArmin Le Grand 
15656b35d86SArmin Le Grand //UUUU
getTransparenceForSvxBrushItem(const SfxItemSet & rSourceSet,sal_Bool bSearchInParents)15756b35d86SArmin Le Grand sal_uInt16 getTransparenceForSvxBrushItem(const SfxItemSet& rSourceSet, sal_Bool bSearchInParents)
15856b35d86SArmin Le Grand {
15956b35d86SArmin Le Grand     sal_uInt16 nFillTransparence(static_cast< const XFillTransparenceItem& >(rSourceSet.Get(XATTR_FILLTRANSPARENCE, bSearchInParents)).GetValue());
16056b35d86SArmin Le Grand     const SfxPoolItem* pGradientItem = 0;
16156b35d86SArmin Le Grand 
16256b35d86SArmin Le Grand     if(SFX_ITEM_SET == rSourceSet.GetItemState(XATTR_FILLFLOATTRANSPARENCE, bSearchInParents, &pGradientItem)
16356b35d86SArmin Le Grand         && static_cast< const XFillFloatTransparenceItem* >(pGradientItem)->IsEnabled())
16456b35d86SArmin Le Grand     {
16556b35d86SArmin Le Grand         const XGradient& rGradient = static_cast< const XFillFloatTransparenceItem* >(pGradientItem)->GetGradientValue();
16656b35d86SArmin Le Grand         const sal_uInt16 nStartLuminance(rGradient.GetStartColor().GetLuminance());
16756b35d86SArmin Le Grand         const sal_uInt16 nEndLuminance(rGradient.GetEndColor().GetLuminance());
16856b35d86SArmin Le Grand 
16956b35d86SArmin Le Grand         // luminance is [0..255], transparence needs to be in [0..100].Maximum is 51200, thus sal_uInt16 is okay to use
17056b35d86SArmin Le Grand         nFillTransparence = static_cast< sal_uInt16 >(((nStartLuminance + nEndLuminance) * 100) / 512);
17156b35d86SArmin Le Grand     }
17256b35d86SArmin Le Grand 
17356b35d86SArmin Le Grand     return nFillTransparence;
17456b35d86SArmin Le Grand }
17556b35d86SArmin Le Grand 
17656b35d86SArmin Le Grand //UUUU
getSvxBrushItemForSolid(const SfxItemSet & rSourceSet,sal_Bool bSearchInParents,sal_uInt16 nBackgroundID)17756b35d86SArmin Le Grand SvxBrushItem getSvxBrushItemForSolid(const SfxItemSet& rSourceSet, sal_Bool bSearchInParents, sal_uInt16 nBackgroundID)
17856b35d86SArmin Le Grand {
17956b35d86SArmin Le Grand     Color aFillColor(static_cast< const XFillColorItem& >(rSourceSet.Get(XATTR_FILLCOLOR, bSearchInParents)).GetColorValue());
18056b35d86SArmin Le Grand 
18156b35d86SArmin Le Grand     // get evtl. mixed transparence
18256b35d86SArmin Le Grand     const sal_uInt16 nFillTransparence(getTransparenceForSvxBrushItem(rSourceSet, bSearchInParents));
18356b35d86SArmin Le Grand 
18456b35d86SArmin Le Grand     if(0 != nFillTransparence)
18556b35d86SArmin Le Grand     {
186*09ef3841SArmin Le Grand         // #i125189# nFillTransparence is in range [0..100] and needs to be in [0..254] unsigned
187*09ef3841SArmin Le Grand         // It is necessary to use the maximum of 0xfe for transparence for the SvxBrushItem
188*09ef3841SArmin Le Grand         // since the oxff value is used for special purposes (like no fill and derive from parent)
189*09ef3841SArmin Le Grand         const sal_uInt8 aTargetTrans(std::min(sal_uInt8(0xfe), static_cast< sal_uInt8 >((nFillTransparence * 254) / 100)));
190*09ef3841SArmin Le Grand 
191*09ef3841SArmin Le Grand         aFillColor.SetTransparency(aTargetTrans);
19256b35d86SArmin Le Grand     }
19356b35d86SArmin Le Grand 
19456b35d86SArmin Le Grand     return SvxBrushItem(aFillColor, nBackgroundID);
19556b35d86SArmin Le Grand }
19656b35d86SArmin Le Grand 
19756b35d86SArmin Le Grand //UUUU
getSvxBrushItemFromSourceSet(const SfxItemSet & rSourceSet,sal_uInt16 nBackgroundID,sal_Bool bSearchInParents)19856b35d86SArmin Le Grand SvxBrushItem getSvxBrushItemFromSourceSet(const SfxItemSet& rSourceSet, sal_uInt16 nBackgroundID, sal_Bool bSearchInParents)
19956b35d86SArmin Le Grand {
20056b35d86SArmin Le Grand     const XFillStyleItem* pXFillStyleItem(static_cast< const XFillStyleItem*  >(rSourceSet.GetItem(XATTR_FILLSTYLE, bSearchInParents)));
20156b35d86SArmin Le Grand 
20256b35d86SArmin Le Grand     if(!pXFillStyleItem || XFILL_NONE == pXFillStyleItem->GetValue())
20356b35d86SArmin Le Grand     {
20456b35d86SArmin Le Grand         // no fill, still need to rescue the evtl. set RGB color, but use as transparent color (we have XFILL_NONE)
20556b35d86SArmin Le Grand         Color aFillColor(static_cast< const XFillColorItem& >(rSourceSet.Get(XATTR_FILLCOLOR, bSearchInParents)).GetColorValue());
20656b35d86SArmin Le Grand         aFillColor.SetTransparency(0xff);
20756b35d86SArmin Le Grand 
20856b35d86SArmin Le Grand         return SvxBrushItem(aFillColor, nBackgroundID);
20956b35d86SArmin Le Grand     }
21056b35d86SArmin Le Grand 
21156b35d86SArmin Le Grand     SvxBrushItem aRetval(nBackgroundID);
21256b35d86SArmin Le Grand 
21356b35d86SArmin Le Grand     switch(pXFillStyleItem->GetValue())
21456b35d86SArmin Le Grand     {
21556b35d86SArmin Le Grand         case XFILL_NONE:
21656b35d86SArmin Le Grand         {
21756b35d86SArmin Le Grand             // already handled above, can not happen again
21856b35d86SArmin Le Grand             break;
21956b35d86SArmin Le Grand         }
22056b35d86SArmin Le Grand         case XFILL_SOLID:
22156b35d86SArmin Le Grand         {
22256b35d86SArmin Le Grand             // create SvxBrushItem with fill color
22356b35d86SArmin Le Grand             aRetval = getSvxBrushItemForSolid(rSourceSet, bSearchInParents, nBackgroundID);
22456b35d86SArmin Le Grand             break;
22556b35d86SArmin Le Grand         }
22656b35d86SArmin Le Grand         case XFILL_GRADIENT:
22756b35d86SArmin Le Grand         {
22856b35d86SArmin Le Grand             // cannot be directly supported, but do the best possible
22956b35d86SArmin Le Grand             const XGradient aXGradient(static_cast< const XFillGradientItem& >(rSourceSet.Get(XATTR_FILLGRADIENT)).GetGradientValue());
23056b35d86SArmin Le Grand             const basegfx::BColor aStartColor(aXGradient.GetStartColor().getBColor() * (aXGradient.GetStartIntens() * 0.01));
23156b35d86SArmin Le Grand             const basegfx::BColor aEndColor(aXGradient.GetEndColor().getBColor() * (aXGradient.GetEndIntens() * 0.01));
23256b35d86SArmin Le Grand 
23356b35d86SArmin Le Grand             // use half/half mixed color from gradient start and end
23456b35d86SArmin Le Grand             Color aMixedColor((aStartColor + aEndColor) * 0.5);
23556b35d86SArmin Le Grand 
23656b35d86SArmin Le Grand             // get evtl. mixed transparence
23756b35d86SArmin Le Grand             const sal_uInt16 nFillTransparence(getTransparenceForSvxBrushItem(rSourceSet, bSearchInParents));
23856b35d86SArmin Le Grand 
23956b35d86SArmin Le Grand             if(0 != nFillTransparence)
24056b35d86SArmin Le Grand             {
241*09ef3841SArmin Le Grand                 // #i125189# nFillTransparence is in range [0..100] and needs to be in [0..254] unsigned
242*09ef3841SArmin Le Grand                 // It is necessary to use the maximum of 0xfe for transparence for the SvxBrushItem
243*09ef3841SArmin Le Grand                 // since the oxff value is used for special purposes (like no fill and derive from parent)
244*09ef3841SArmin Le Grand                 const sal_uInt8 aTargetTrans(std::min(sal_uInt8(0xfe), static_cast< sal_uInt8 >((nFillTransparence * 254) / 100)));
245*09ef3841SArmin Le Grand 
246*09ef3841SArmin Le Grand                 aMixedColor.SetTransparency(aTargetTrans);
24756b35d86SArmin Le Grand             }
24856b35d86SArmin Le Grand 
24956b35d86SArmin Le Grand             aRetval = SvxBrushItem(aMixedColor, nBackgroundID);
25056b35d86SArmin Le Grand             break;
25156b35d86SArmin Le Grand         }
25256b35d86SArmin Le Grand         case XFILL_HATCH:
25356b35d86SArmin Le Grand         {
25456b35d86SArmin Le Grand             // cannot be directly supported, but do the best possible
25556b35d86SArmin Le Grand             const XHatch& rHatch(static_cast< const XFillHatchItem& >(rSourceSet.Get(XATTR_FILLHATCH)).GetHatchValue());
25656b35d86SArmin Le Grand             const bool bFillBackground(static_cast< const XFillBackgroundItem& >(rSourceSet.Get(XATTR_FILLBACKGROUND)).GetValue());
25756b35d86SArmin Le Grand 
25856b35d86SArmin Le Grand             if(bFillBackground)
25956b35d86SArmin Le Grand             {
26056b35d86SArmin Le Grand                 // hatch is background-filled, use FillColor as if XFILL_SOLID
26156b35d86SArmin Le Grand                 aRetval = getSvxBrushItemForSolid(rSourceSet, bSearchInParents, nBackgroundID);
26256b35d86SArmin Le Grand             }
26356b35d86SArmin Le Grand             else
26456b35d86SArmin Le Grand             {
26556b35d86SArmin Le Grand                 // hatch is not background-filled and using hatch color would be too dark; compensate
26656b35d86SArmin Le Grand                 // somewhat by making it more transparent
26756b35d86SArmin Le Grand                 Color aHatchColor(rHatch.GetColor());
26856b35d86SArmin Le Grand 
26956b35d86SArmin Le Grand                 // get evtl. mixed transparence
27056b35d86SArmin Le Grand                 sal_uInt16 nFillTransparence(getTransparenceForSvxBrushItem(rSourceSet, bSearchInParents));
27156b35d86SArmin Le Grand 
27256b35d86SArmin Le Grand                 // take half orig transparence, add half transparent, clamp result
27356b35d86SArmin Le Grand                 nFillTransparence = basegfx::clamp((sal_uInt16)((nFillTransparence / 2) + 50), (sal_uInt16)0, (sal_uInt16)255);
27456b35d86SArmin Le Grand 
275*09ef3841SArmin Le Grand                 // #i125189# nFillTransparence is in range [0..100] and needs to be in [0..254] unsigned
276*09ef3841SArmin Le Grand                 // It is necessary to use the maximum of 0xfe for transparence for the SvxBrushItem
277*09ef3841SArmin Le Grand                 // since the oxff value is used for special purposes (like no fill and derive from parent)
278*09ef3841SArmin Le Grand                 const sal_uInt8 aTargetTrans(std::min(sal_uInt8(0xfe), static_cast< sal_uInt8 >((nFillTransparence * 254) / 100)));
27956b35d86SArmin Le Grand 
280*09ef3841SArmin Le Grand                 aHatchColor.SetTransparency(aTargetTrans);
28156b35d86SArmin Le Grand                 aRetval = SvxBrushItem(aHatchColor, nBackgroundID);
28256b35d86SArmin Le Grand             }
28356b35d86SArmin Le Grand 
28456b35d86SArmin Le Grand             break;
28556b35d86SArmin Le Grand         }
28656b35d86SArmin Le Grand         case XFILL_BITMAP:
28756b35d86SArmin Le Grand         {
28856b35d86SArmin Le Grand             // create SvxBrushItem with bitmap info and flags
28956b35d86SArmin Le Grand             const XFillBitmapItem& rBmpItm = static_cast< const XFillBitmapItem& >(rSourceSet.Get(XATTR_FILLBITMAP, bSearchInParents));
29056b35d86SArmin Le Grand             const Graphic aGraphic(rBmpItm.GetGraphicObject().GetGraphic());
29156b35d86SArmin Le Grand 
29256b35d86SArmin Le Grand             // continue idependent of evtl. GRAPHIC_NONE as aGraphic.GetType(), we still need to rescue positions
29356b35d86SArmin Le Grand             SvxGraphicPosition aSvxGraphicPosition(GPOS_NONE);
29456b35d86SArmin Le Grand             const XFillBmpStretchItem& rStretchItem = static_cast< const XFillBmpStretchItem& >(rSourceSet.Get(XATTR_FILLBMP_STRETCH, bSearchInParents));
29556b35d86SArmin Le Grand             const XFillBmpTileItem& rTileItem = static_cast< const XFillBmpTileItem& >(rSourceSet.Get(XATTR_FILLBMP_TILE, bSearchInParents));
29656b35d86SArmin Le Grand 
29756b35d86SArmin Le Grand             if(rTileItem.GetValue())
29856b35d86SArmin Le Grand             {
29956b35d86SArmin Le Grand                 aSvxGraphicPosition = GPOS_TILED;
30056b35d86SArmin Le Grand             }
30156b35d86SArmin Le Grand             else if(rStretchItem.GetValue())
30256b35d86SArmin Le Grand             {
30356b35d86SArmin Le Grand                 aSvxGraphicPosition = GPOS_AREA;
30456b35d86SArmin Le Grand             }
30556b35d86SArmin Le Grand             else
30656b35d86SArmin Le Grand             {
30756b35d86SArmin Le Grand                 const XFillBmpPosItem& rPosItem = static_cast< const XFillBmpPosItem& >(rSourceSet.Get(XATTR_FILLBMP_POS, bSearchInParents));
30856b35d86SArmin Le Grand 
30956b35d86SArmin Le Grand                 switch(rPosItem.GetValue())
31056b35d86SArmin Le Grand                 {
31156b35d86SArmin Le Grand                     case RP_LT: aSvxGraphicPosition = GPOS_LT; break;
31256b35d86SArmin Le Grand                     case RP_MT: aSvxGraphicPosition = GPOS_MT; break;
31356b35d86SArmin Le Grand                     case RP_RT: aSvxGraphicPosition = GPOS_RT; break;
31456b35d86SArmin Le Grand                     case RP_LM: aSvxGraphicPosition = GPOS_LM; break;
31556b35d86SArmin Le Grand                     case RP_MM: aSvxGraphicPosition = GPOS_MM; break;
31656b35d86SArmin Le Grand                     case RP_RM: aSvxGraphicPosition = GPOS_RM; break;
31756b35d86SArmin Le Grand                     case RP_LB: aSvxGraphicPosition = GPOS_LB; break;
31856b35d86SArmin Le Grand                     case RP_MB: aSvxGraphicPosition = GPOS_MB; break;
31956b35d86SArmin Le Grand                     case RP_RB: aSvxGraphicPosition = GPOS_RB; break;
32056b35d86SArmin Le Grand                 }
32156b35d86SArmin Le Grand             }
32256b35d86SArmin Le Grand 
32356b35d86SArmin Le Grand             // create with given graphic and position
32456b35d86SArmin Le Grand             aRetval = SvxBrushItem(aGraphic, aSvxGraphicPosition, nBackgroundID);
32556b35d86SArmin Le Grand 
32656b35d86SArmin Le Grand             // get evtl. mixed transparence
32756b35d86SArmin Le Grand             const sal_uInt16 nFillTransparence(getTransparenceForSvxBrushItem(rSourceSet, bSearchInParents));
32856b35d86SArmin Le Grand 
32956b35d86SArmin Le Grand             if(0 != nFillTransparence)
33056b35d86SArmin Le Grand             {
331*09ef3841SArmin Le Grand                 // #i125189# nFillTransparence is in range [0..100] and needs to be in [0..100] signed
33256b35d86SArmin Le Grand                 aRetval.setGraphicTransparency(static_cast< sal_Int8 >(nFillTransparence));
33356b35d86SArmin Le Grand             }
33456b35d86SArmin Le Grand 
33556b35d86SArmin Le Grand             break;
33656b35d86SArmin Le Grand         }
33756b35d86SArmin Le Grand     }
33856b35d86SArmin Le Grand 
33956b35d86SArmin Le Grand     return aRetval;
34056b35d86SArmin Le Grand }
34156b35d86SArmin Le Grand 
34256b35d86SArmin Le Grand //eof
343