xref: /aoo41x/main/svx/source/xoutdev/xattrbmp.cxx (revision 035a2f44)
1f6e50924SAndrew Rist /**************************************************************
2f6e50924SAndrew Rist  *
3f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f6e50924SAndrew Rist  * distributed with this work for additional information
6f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10f6e50924SAndrew Rist  *
11f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17f6e50924SAndrew Rist  * specific language governing permissions and limitations
18f6e50924SAndrew Rist  * under the License.
19f6e50924SAndrew Rist  *
20f6e50924SAndrew Rist  *************************************************************/
21f6e50924SAndrew Rist 
22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
23cdf0e10cSrcweir #include "precompiled_svx.hxx"
2470d3707aSArmin Le Grand 
25cdf0e10cSrcweir #include <com/sun/star/awt/XBitmap.hpp>
26cdf0e10cSrcweir #include <com/sun/star/graphic/XGraphic.hpp>
27cdf0e10cSrcweir #include <tools/stream.hxx>
28cdf0e10cSrcweir #include <vcl/window.hxx>
29cdf0e10cSrcweir #include <vcl/virdev.hxx>
30cdf0e10cSrcweir #include <vcl/bitmapex.hxx>
31cdf0e10cSrcweir #include <toolkit/unohlp.hxx>
32cdf0e10cSrcweir #include <svl/style.hxx>
33cdf0e10cSrcweir #include <editeng/memberids.hrc>
34cdf0e10cSrcweir #include <svx/dialogs.hrc>
35cdf0e10cSrcweir #include "svx/xattr.hxx"
36cdf0e10cSrcweir #include <svx/xtable.hxx>
37cdf0e10cSrcweir #include <svx/xdef.hxx>
38cdf0e10cSrcweir #include <svx/unomid.hxx>
39cdf0e10cSrcweir #include <editeng/unoprnms.hxx>
4070d3707aSArmin Le Grand #include <svx/unoapi.hxx>
41cdf0e10cSrcweir #include <svx/svdmodel.hxx>
42cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
4370d3707aSArmin Le Grand #include <vcl/salbtype.hxx>
4470d3707aSArmin Le Grand #include <vcl/bmpacc.hxx>
45cdf0e10cSrcweir 
46cdf0e10cSrcweir using namespace ::com::sun::star;
47cdf0e10cSrcweir 
4870d3707aSArmin Le Grand // -----------------------
4970d3707aSArmin Le Grand // class XFillBitmapItem
5070d3707aSArmin Le Grand // -----------------------
5170d3707aSArmin Le Grand TYPEINIT1_AUTOFACTORY(XFillBitmapItem, NameOrIndex);
52cdf0e10cSrcweir 
5370d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
54cdf0e10cSrcweir 
5570d3707aSArmin Le Grand XFillBitmapItem::XFillBitmapItem(long nIndex, const GraphicObject& rGraphicObject)
5670d3707aSArmin Le Grand :   NameOrIndex(XATTR_FILLBITMAP, nIndex),
5770d3707aSArmin Le Grand 	maGraphicObject(rGraphicObject)
58cdf0e10cSrcweir {
59cdf0e10cSrcweir }
60cdf0e10cSrcweir 
6170d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
62cdf0e10cSrcweir 
6370d3707aSArmin Le Grand XFillBitmapItem::XFillBitmapItem(const XubString& rName, const GraphicObject& rGraphicObject)
6470d3707aSArmin Le Grand :   NameOrIndex(XATTR_FILLBITMAP, rName),
6570d3707aSArmin Le Grand 	maGraphicObject(rGraphicObject)
66cdf0e10cSrcweir {
67cdf0e10cSrcweir }
68cdf0e10cSrcweir 
6970d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
70cdf0e10cSrcweir 
7170d3707aSArmin Le Grand XFillBitmapItem::XFillBitmapItem(const XFillBitmapItem& rItem)
7270d3707aSArmin Le Grand :   NameOrIndex(rItem),
7370d3707aSArmin Le Grand 	maGraphicObject(rItem.maGraphicObject)
74cdf0e10cSrcweir {
75cdf0e10cSrcweir }
76cdf0e10cSrcweir 
7770d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
78cdf0e10cSrcweir 
7970d3707aSArmin Le Grand Bitmap createHistorical8x8FromArray(const sal_uInt16* pArray, Color aColorPix, Color aColorBack)
80cdf0e10cSrcweir {
8170d3707aSArmin Le Grand     BitmapPalette aPalette(2);
82cdf0e10cSrcweir 
8370d3707aSArmin Le Grand     aPalette[0] = BitmapColor(aColorBack);
8470d3707aSArmin Le Grand     aPalette[1] = BitmapColor(aColorPix);
85cdf0e10cSrcweir 
8670d3707aSArmin Le Grand     Bitmap aBitmap(Size(8, 8), 1, &aPalette);
8770d3707aSArmin Le Grand 	BitmapWriteAccess* pContent = aBitmap.AcquireWriteAccess();
88cdf0e10cSrcweir 
8970d3707aSArmin Le Grand     if(pContent)
9070d3707aSArmin Le Grand     {
9170d3707aSArmin Le Grand         for(sal_uInt16 a(0); a < 8; a++)
9270d3707aSArmin Le Grand         {
9370d3707aSArmin Le Grand             for(sal_uInt16 b(0); b < 8; b++)
9470d3707aSArmin Le Grand             {
9570d3707aSArmin Le Grand                 if(pArray[(a * 8) + b])
9670d3707aSArmin Le Grand                 {
9770d3707aSArmin Le Grand                     pContent->SetPixel(b, a, sal_uInt8(1));
9870d3707aSArmin Le Grand                 }
9970d3707aSArmin Le Grand                 else
10070d3707aSArmin Le Grand                 {
10170d3707aSArmin Le Grand                     pContent->SetPixel(b, a, sal_uInt8(0));
10270d3707aSArmin Le Grand                 }
10370d3707aSArmin Le Grand             }
10470d3707aSArmin Le Grand         }
105cdf0e10cSrcweir 
10670d3707aSArmin Le Grand         aBitmap.ReleaseAccess(pContent);
10770d3707aSArmin Le Grand     }
108cdf0e10cSrcweir 
10970d3707aSArmin Le Grand     return aBitmap;
110cdf0e10cSrcweir }
111cdf0e10cSrcweir 
11270d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
113cdf0e10cSrcweir 
11470d3707aSArmin Le Grand bool SVX_DLLPUBLIC isHistorical8x8(const BitmapEx& rBitmapEx, BitmapColor& o_rBack, BitmapColor& o_rFront)
115cdf0e10cSrcweir {
11670d3707aSArmin Le Grand     if(!rBitmapEx.IsTransparent())
11770d3707aSArmin Le Grand     {
11870d3707aSArmin Le Grand         Bitmap aBitmap(rBitmapEx.GetBitmap());
119cdf0e10cSrcweir 
12070d3707aSArmin Le Grand         if(8 == aBitmap.GetSizePixel().Width() && 8 == aBitmap.GetSizePixel().Height())
12170d3707aSArmin Le Grand         {
12270d3707aSArmin Le Grand             if(2 == aBitmap.GetColorCount())
12370d3707aSArmin Le Grand             {
12470d3707aSArmin Le Grand                 BitmapReadAccess* pRead = aBitmap.AcquireReadAccess();
12570d3707aSArmin Le Grand 
12670d3707aSArmin Le Grand                 if(pRead)
12770d3707aSArmin Le Grand                 {
12870d3707aSArmin Le Grand                     if(pRead->HasPalette() && 2 == pRead->GetPaletteEntryCount())
12970d3707aSArmin Le Grand                     {
13070d3707aSArmin Le Grand                         const BitmapPalette& rPalette = pRead->GetPalette();
13170d3707aSArmin Le Grand 
13270d3707aSArmin Le Grand                         o_rBack = rPalette[1];
13370d3707aSArmin Le Grand                         o_rFront = rPalette[0];
13470d3707aSArmin Le Grand 
13570d3707aSArmin Le Grand                         return true;
13670d3707aSArmin Le Grand                     }
13770d3707aSArmin Le Grand                 }
13870d3707aSArmin Le Grand             }
13970d3707aSArmin Le Grand         }
14070d3707aSArmin Le Grand     }
141cdf0e10cSrcweir 
14270d3707aSArmin Le Grand     return false;
143cdf0e10cSrcweir }
144cdf0e10cSrcweir 
14570d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
146cdf0e10cSrcweir 
14770d3707aSArmin Le Grand XFillBitmapItem::XFillBitmapItem(SvStream& rIn, sal_uInt16 nVer)
14870d3707aSArmin Le Grand :   NameOrIndex(XATTR_FILLBITMAP, rIn)
149cdf0e10cSrcweir {
15070d3707aSArmin Le Grand 	if (!IsIndex())
151cdf0e10cSrcweir 	{
15270d3707aSArmin Le Grand 	    if(0 == nVer)
15370d3707aSArmin Le Grand 	    {
15470d3707aSArmin Le Grand 		    // Behandlung der alten Bitmaps
15570d3707aSArmin Le Grand 		    Bitmap aBmp;
15670d3707aSArmin Le Grand 
15770d3707aSArmin Le Grand 		    rIn >> aBmp;
15870d3707aSArmin Le Grand             maGraphicObject = Graphic(aBmp);
15970d3707aSArmin Le Grand 	    }
16070d3707aSArmin Le Grand 	    else if(1 == nVer)
16170d3707aSArmin Le Grand 	    {
16270d3707aSArmin Le Grand             enum XBitmapType
16370d3707aSArmin Le Grand             {
16470d3707aSArmin Le Grand                 XBITMAP_IMPORT,
16570d3707aSArmin Le Grand                 XBITMAP_8X8
16670d3707aSArmin Le Grand             };
16770d3707aSArmin Le Grand 
16870d3707aSArmin Le Grand             sal_Int16 iTmp;
16970d3707aSArmin Le Grand 
17070d3707aSArmin Le Grand             rIn >> iTmp; // former XBitmapStyle
17170d3707aSArmin Le Grand 		    rIn >> iTmp; // former XBitmapType
17270d3707aSArmin Le Grand 
17370d3707aSArmin Le Grand 		    if(XBITMAP_IMPORT == iTmp)
17470d3707aSArmin Le Grand 		    {
17570d3707aSArmin Le Grand 			    Bitmap aBmp;
17670d3707aSArmin Le Grand 
17770d3707aSArmin Le Grand                 rIn >> aBmp;
17870d3707aSArmin Le Grand                 maGraphicObject = Graphic(aBmp);
17970d3707aSArmin Le Grand 		    }
18070d3707aSArmin Le Grand 		    else if(XBITMAP_8X8 == iTmp)
18170d3707aSArmin Le Grand 		    {
18270d3707aSArmin Le Grand                 sal_uInt16 aArray[64];
18370d3707aSArmin Le Grand 
18470d3707aSArmin Le Grand 			    for(sal_uInt16 i(0); i < 64; i++)
18570d3707aSArmin Le Grand                 {
18670d3707aSArmin Le Grand 				    rIn >> aArray[i];
18770d3707aSArmin Le Grand                 }
18870d3707aSArmin Le Grand 
18970d3707aSArmin Le Grand 			    Color aColorPix;
19070d3707aSArmin Le Grand 			    Color aColorBack;
19170d3707aSArmin Le Grand 
19270d3707aSArmin Le Grand                 rIn >> aColorPix;
19370d3707aSArmin Le Grand 			    rIn >> aColorBack;
19470d3707aSArmin Le Grand 
19570d3707aSArmin Le Grand                 const Bitmap aBitmap(createHistorical8x8FromArray(aArray, aColorPix, aColorBack));
19670d3707aSArmin Le Grand 
19770d3707aSArmin Le Grand                 maGraphicObject = Graphic(aBitmap);
19870d3707aSArmin Le Grand             }
19970d3707aSArmin Le Grand 	    }
20070d3707aSArmin Le Grand         else if(2 == nVer)
20170d3707aSArmin Le Grand         {
20270d3707aSArmin Le Grand 		    BitmapEx aBmpEx;
203cdf0e10cSrcweir 
20470d3707aSArmin Le Grand 		    rIn >> aBmpEx;
20570d3707aSArmin Le Grand             maGraphicObject = Graphic(aBmpEx);
20670d3707aSArmin Le Grand         }
20770d3707aSArmin Le Grand     }
208cdf0e10cSrcweir }
209cdf0e10cSrcweir 
21070d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
211cdf0e10cSrcweir 
21270d3707aSArmin Le Grand XFillBitmapItem::XFillBitmapItem(SfxItemPool* /*pPool*/, const GraphicObject& rGraphicObject)
21370d3707aSArmin Le Grand : 	NameOrIndex( XATTR_FILLBITMAP, -1),
21470d3707aSArmin Le Grand 	maGraphicObject(rGraphicObject)
215cdf0e10cSrcweir {
216cdf0e10cSrcweir }
217cdf0e10cSrcweir 
21870d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
219cdf0e10cSrcweir 
22070d3707aSArmin Le Grand XFillBitmapItem::XFillBitmapItem(SfxItemPool* /*pPool*/)
22170d3707aSArmin Le Grand :   NameOrIndex(XATTR_FILLBITMAP, -1),
22270d3707aSArmin Le Grand     maGraphicObject()
223cdf0e10cSrcweir {
224cdf0e10cSrcweir }
225cdf0e10cSrcweir 
22670d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
227cdf0e10cSrcweir 
228cdf0e10cSrcweir SfxPoolItem* XFillBitmapItem::Clone(SfxItemPool* /*pPool*/) const
229cdf0e10cSrcweir {
230cdf0e10cSrcweir 	return new XFillBitmapItem(*this);
231cdf0e10cSrcweir }
232cdf0e10cSrcweir 
23370d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
234cdf0e10cSrcweir 
235cdf0e10cSrcweir int XFillBitmapItem::operator==(const SfxPoolItem& rItem) const
236cdf0e10cSrcweir {
23770d3707aSArmin Le Grand 	return (NameOrIndex::operator==(rItem)
23870d3707aSArmin Le Grand         && maGraphicObject == ((const XFillBitmapItem&)rItem).maGraphicObject);
239cdf0e10cSrcweir }
240cdf0e10cSrcweir 
24170d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
242cdf0e10cSrcweir 
243cdf0e10cSrcweir SfxPoolItem* XFillBitmapItem::Create(SvStream& rIn, sal_uInt16 nVer) const
244cdf0e10cSrcweir {
245cdf0e10cSrcweir 	return new XFillBitmapItem( rIn, nVer );
246cdf0e10cSrcweir }
247cdf0e10cSrcweir 
24870d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
249cdf0e10cSrcweir 
250cdf0e10cSrcweir SvStream& XFillBitmapItem::Store( SvStream& rOut, sal_uInt16 nItemVersion ) const
251cdf0e10cSrcweir {
25270d3707aSArmin Le Grand 	NameOrIndex::Store(rOut, nItemVersion);
253cdf0e10cSrcweir 
25470d3707aSArmin Le Grand 	if(!IsIndex())
255cdf0e10cSrcweir 	{
25670d3707aSArmin Le Grand         rOut << maGraphicObject.GetGraphic().GetBitmapEx();
257cdf0e10cSrcweir 	}
258cdf0e10cSrcweir 
259cdf0e10cSrcweir 	return rOut;
260cdf0e10cSrcweir }
261cdf0e10cSrcweir 
26270d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
26370d3707aSArmin Le Grand 
26470d3707aSArmin Le Grand const GraphicObject& XFillBitmapItem::GetGraphicObject() const
265cdf0e10cSrcweir {
26670d3707aSArmin Le Grand     return maGraphicObject;
267cdf0e10cSrcweir }
268cdf0e10cSrcweir 
26970d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
27070d3707aSArmin Le Grand 
27170d3707aSArmin Le Grand void XFillBitmapItem::SetGraphicObject(const GraphicObject& rGraphicObject)
27270d3707aSArmin Le Grand {
27370d3707aSArmin Le Grand     maGraphicObject = rGraphicObject;
27470d3707aSArmin Le Grand }
275cdf0e10cSrcweir 
27670d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
277cdf0e10cSrcweir 
27870d3707aSArmin Le Grand sal_uInt16 XFillBitmapItem::GetVersion(sal_uInt16 /*nFileFormatVersion*/) const
279cdf0e10cSrcweir {
28070d3707aSArmin Le Grand 	// version three
28170d3707aSArmin Le Grand 	return(2);
282cdf0e10cSrcweir }
283cdf0e10cSrcweir 
28470d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
285cdf0e10cSrcweir 
28670d3707aSArmin Le Grand SfxItemPresentation XFillBitmapItem::GetPresentation(
287cdf0e10cSrcweir 	SfxItemPresentation ePres,
28870d3707aSArmin Le Grand 	SfxMapUnit /*eCoreUnit*/,
28970d3707aSArmin Le Grand 	SfxMapUnit /*ePresUnit*/,
29070d3707aSArmin Le Grand     XubString& rText,
29170d3707aSArmin Le Grand     const IntlWrapper*) const
292cdf0e10cSrcweir {
29370d3707aSArmin Le Grand 	switch (ePres)
294cdf0e10cSrcweir 	{
295cdf0e10cSrcweir 		case SFX_ITEM_PRESENTATION_NONE:
296cdf0e10cSrcweir 			rText.Erase();
297cdf0e10cSrcweir 			return ePres;
298cdf0e10cSrcweir 		case SFX_ITEM_PRESENTATION_NAMELESS:
299cdf0e10cSrcweir 		case SFX_ITEM_PRESENTATION_COMPLETE:
300cdf0e10cSrcweir 			rText += GetName();
301cdf0e10cSrcweir 			return ePres;
302cdf0e10cSrcweir 		default:
303cdf0e10cSrcweir 			return SFX_ITEM_PRESENTATION_NONE;
304cdf0e10cSrcweir 	}
305cdf0e10cSrcweir }
306cdf0e10cSrcweir 
30770d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
308cdf0e10cSrcweir 
30970d3707aSArmin Le Grand sal_Bool XFillBitmapItem::QueryValue(::com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId) const
310cdf0e10cSrcweir {
311cdf0e10cSrcweir     nMemberId &= ~CONVERT_TWIPS;
312cdf0e10cSrcweir 
313cdf0e10cSrcweir     // needed for MID_NAME
314cdf0e10cSrcweir     ::rtl::OUString aApiName;
315cdf0e10cSrcweir     // needed for complete item (MID 0)
316cdf0e10cSrcweir     ::rtl::OUString aInternalName;
317cdf0e10cSrcweir 
318cdf0e10cSrcweir     ::rtl::OUString aURL;
319cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap > xBmp;
320cdf0e10cSrcweir 
321cdf0e10cSrcweir 	if( nMemberId == MID_NAME )
322cdf0e10cSrcweir 	{
323cdf0e10cSrcweir  		SvxUnogetApiNameForItem( Which(), GetName(), aApiName );
324cdf0e10cSrcweir 	}
325cdf0e10cSrcweir     else if( nMemberId == 0  )
326cdf0e10cSrcweir     {
327cdf0e10cSrcweir         aInternalName = GetName();
328cdf0e10cSrcweir     }
329cdf0e10cSrcweir 
330cdf0e10cSrcweir     if( nMemberId == MID_GRAFURL ||
331cdf0e10cSrcweir         nMemberId == 0 )
332cdf0e10cSrcweir 	{
33370d3707aSArmin Le Grand         aURL = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX));
33470d3707aSArmin Le Grand 		aURL += ::rtl::OUString::createFromAscii(GetGraphicObject().GetUniqueID().GetBuffer() );
335cdf0e10cSrcweir 	}
336cdf0e10cSrcweir     if( nMemberId == MID_BITMAP ||
337cdf0e10cSrcweir         nMemberId == 0  )
338cdf0e10cSrcweir 	{
33970d3707aSArmin Le Grand 		xBmp.set(VCLUnoHelper::CreateBitmap(GetGraphicObject().GetGraphic().GetBitmapEx()));
340cdf0e10cSrcweir 	}
341cdf0e10cSrcweir 
342cdf0e10cSrcweir     if( nMemberId == MID_NAME )
343cdf0e10cSrcweir 		rVal <<= aApiName;
344cdf0e10cSrcweir 	else if( nMemberId == MID_GRAFURL )
345cdf0e10cSrcweir 		rVal <<= aURL;
346cdf0e10cSrcweir 	else if( nMemberId == MID_BITMAP )
347cdf0e10cSrcweir 		rVal <<= xBmp;
348cdf0e10cSrcweir     else
349cdf0e10cSrcweir     {
350cdf0e10cSrcweir         // member-id 0 => complete item (e.g. for toolbars)
351cdf0e10cSrcweir         DBG_ASSERT( nMemberId == 0, "invalid member-id" );
352cdf0e10cSrcweir         uno::Sequence< beans::PropertyValue > aPropSeq( 3 );
353cdf0e10cSrcweir 
354cdf0e10cSrcweir         aPropSeq[0].Name  = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ));
355cdf0e10cSrcweir         aPropSeq[0].Value = uno::makeAny( aInternalName );
356cdf0e10cSrcweir         aPropSeq[1].Name  = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillBitmapURL" ));
357cdf0e10cSrcweir         aPropSeq[1].Value = uno::makeAny( aURL );
358cdf0e10cSrcweir         aPropSeq[2].Name  = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Bitmap" ));
359cdf0e10cSrcweir         aPropSeq[2].Value = uno::makeAny( xBmp );
360cdf0e10cSrcweir 
361cdf0e10cSrcweir         rVal <<= aPropSeq;
362cdf0e10cSrcweir     }
363cdf0e10cSrcweir 
364cdf0e10cSrcweir 	return sal_True;
365cdf0e10cSrcweir }
366cdf0e10cSrcweir 
36770d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
368cdf0e10cSrcweir 
369cdf0e10cSrcweir sal_Bool XFillBitmapItem::PutValue( const ::com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId )
370cdf0e10cSrcweir {
371cdf0e10cSrcweir     nMemberId &= ~CONVERT_TWIPS;
372cdf0e10cSrcweir 
373cdf0e10cSrcweir     ::rtl::OUString aName;
374cdf0e10cSrcweir     ::rtl::OUString aURL;
375cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap > xBmp;
376cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > xGraphic;
377cdf0e10cSrcweir 
378cdf0e10cSrcweir     bool bSetName   = false;
379cdf0e10cSrcweir     bool bSetURL    = false;
380cdf0e10cSrcweir     bool bSetBitmap = false;
381cdf0e10cSrcweir 
382cdf0e10cSrcweir     if( nMemberId == MID_NAME )
383cdf0e10cSrcweir 		bSetName = (rVal >>= aName);
384cdf0e10cSrcweir     else if( nMemberId == MID_GRAFURL )
385cdf0e10cSrcweir 		bSetURL = (rVal >>= aURL);
386cdf0e10cSrcweir 	else if( nMemberId == MID_BITMAP )
387cdf0e10cSrcweir 	{
388cdf0e10cSrcweir         bSetBitmap = (rVal >>= xBmp);
389cdf0e10cSrcweir 		if ( !bSetBitmap )
390cdf0e10cSrcweir 			bSetBitmap = (rVal >>= xGraphic );
391cdf0e10cSrcweir 	}
392cdf0e10cSrcweir     else
393cdf0e10cSrcweir     {
394cdf0e10cSrcweir         DBG_ASSERT( nMemberId == 0, "invalid member-id" );
395cdf0e10cSrcweir         uno::Sequence< beans::PropertyValue >   aPropSeq;
396cdf0e10cSrcweir         if( rVal >>= aPropSeq )
397cdf0e10cSrcweir         {
398cdf0e10cSrcweir             for ( sal_Int32 n = 0; n < aPropSeq.getLength(); n++ )
399cdf0e10cSrcweir             {
400cdf0e10cSrcweir                 if( aPropSeq[n].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Name" )))
401cdf0e10cSrcweir                     bSetName = (aPropSeq[n].Value >>= aName);
402cdf0e10cSrcweir                 else if( aPropSeq[n].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "FillBitmapURL" )))
403cdf0e10cSrcweir                     bSetURL = (aPropSeq[n].Value >>= aURL);
404cdf0e10cSrcweir                 else if( aPropSeq[n].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Bitmap" )))
405cdf0e10cSrcweir                     bSetBitmap = (aPropSeq[n].Value >>= xBmp);
406cdf0e10cSrcweir             }
407cdf0e10cSrcweir         }
408cdf0e10cSrcweir     }
409cdf0e10cSrcweir 
410cdf0e10cSrcweir     if( bSetName )
411cdf0e10cSrcweir     {
412cdf0e10cSrcweir         SetName( aName );
413cdf0e10cSrcweir     }
414cdf0e10cSrcweir     if( bSetURL )
415cdf0e10cSrcweir     {
41670d3707aSArmin Le Grand         maGraphicObject  = GraphicObject::CreateGraphicObjectFromURL(aURL);
417*035a2f44SArmin Le Grand 
418*035a2f44SArmin Le Grand         // #121194# Prefer GraphicObject over bitmap object if both are provided
419*035a2f44SArmin Le Grand         if(bSetBitmap && GRAPHIC_NONE != maGraphicObject.GetType())
420*035a2f44SArmin Le Grand         {
421*035a2f44SArmin Le Grand             bSetBitmap = false;
422*035a2f44SArmin Le Grand         }
423cdf0e10cSrcweir     }
424cdf0e10cSrcweir     if( bSetBitmap )
425cdf0e10cSrcweir     {
42670d3707aSArmin Le Grand 		if(xBmp.is())
427cdf0e10cSrcweir 		{
42870d3707aSArmin Le Grand             maGraphicObject = Graphic(VCLUnoHelper::GetBitmap(xBmp));
429cdf0e10cSrcweir 		}
43070d3707aSArmin Le Grand 		else if(xGraphic.is())
431cdf0e10cSrcweir 		{
43270d3707aSArmin Le Grand 			maGraphicObject = Graphic(xGraphic);
433cdf0e10cSrcweir 		}
434cdf0e10cSrcweir     }
435cdf0e10cSrcweir 
436cdf0e10cSrcweir 	return (bSetName || bSetURL || bSetBitmap);
437cdf0e10cSrcweir }
438cdf0e10cSrcweir 
43970d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
44070d3707aSArmin Le Grand 
441cdf0e10cSrcweir sal_Bool XFillBitmapItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 )
442cdf0e10cSrcweir {
44370d3707aSArmin Le Grand     const GraphicObject& aGraphicObjectA(((XFillBitmapItem*)p1)->GetGraphicObject());
44470d3707aSArmin Le Grand     const GraphicObject& aGraphicObjectB(((XFillBitmapItem*)p2)->GetGraphicObject());
44570d3707aSArmin Le Grand 
44670d3707aSArmin Le Grand 	return aGraphicObjectA == aGraphicObjectB;
447cdf0e10cSrcweir }
448cdf0e10cSrcweir 
44970d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
45070d3707aSArmin Le Grand 
451cdf0e10cSrcweir XFillBitmapItem* XFillBitmapItem::checkForUniqueItem( SdrModel* pModel ) const
452cdf0e10cSrcweir {
453cdf0e10cSrcweir 	if( pModel )
454cdf0e10cSrcweir 	{
455cdf0e10cSrcweir 		const String aUniqueName = NameOrIndex::CheckNamedItem(	this,
456cdf0e10cSrcweir 																XATTR_FILLBITMAP,
457cdf0e10cSrcweir 																&pModel->GetItemPool(),
458cdf0e10cSrcweir 																pModel->GetStyleSheetPool() ? &pModel->GetStyleSheetPool()->GetPool() : NULL,
459cdf0e10cSrcweir 																XFillBitmapItem::CompareValueFunc,
460cdf0e10cSrcweir 																RID_SVXSTR_BMP21,
461cdf0e10cSrcweir 																pModel->GetBitmapList() );
462cdf0e10cSrcweir 
463cdf0e10cSrcweir 		// if the given name is not valid, replace it!
464cdf0e10cSrcweir 		if( aUniqueName != GetName() )
465cdf0e10cSrcweir 		{
46670d3707aSArmin Le Grand 			return new XFillBitmapItem(aUniqueName, maGraphicObject);
467cdf0e10cSrcweir 		}
468cdf0e10cSrcweir 	}
469cdf0e10cSrcweir 
470cdf0e10cSrcweir 	return (XFillBitmapItem*)this;
471cdf0e10cSrcweir }
47270d3707aSArmin Le Grand 
47370d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
47470d3707aSArmin Le Grand // eof
475