xref: /AOO41X/main/svx/source/xoutdev/xattrbmp.cxx (revision 70d3707ac8de2c13f15b54a698b22c6ac9b73267)
1f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
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
10cdf0e10cSrcweir  *
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.
19cdf0e10cSrcweir  *
20f6e50924SAndrew Rist  *************************************************************/
21f6e50924SAndrew Rist 
22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
23cdf0e10cSrcweir #include "precompiled_svx.hxx"
24*70d3707aSArmin 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>
40*70d3707aSArmin Le Grand #include <svx/unoapi.hxx>
41cdf0e10cSrcweir #include <svx/svdmodel.hxx>
42cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
43*70d3707aSArmin Le Grand #include <vcl/salbtype.hxx>
44*70d3707aSArmin Le Grand #include <vcl/bmpacc.hxx>
45cdf0e10cSrcweir 
46cdf0e10cSrcweir using namespace ::com::sun::star;
47cdf0e10cSrcweir 
48cdf0e10cSrcweir // -----------------------
49cdf0e10cSrcweir // class XFillBitmapItem
50cdf0e10cSrcweir // -----------------------
51cdf0e10cSrcweir TYPEINIT1_AUTOFACTORY(XFillBitmapItem, NameOrIndex);
52cdf0e10cSrcweir 
53*70d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
54cdf0e10cSrcweir 
55*70d3707aSArmin Le Grand XFillBitmapItem::XFillBitmapItem(long nIndex, const GraphicObject& rGraphicObject)
56*70d3707aSArmin Le Grand :   NameOrIndex(XATTR_FILLBITMAP, nIndex),
57*70d3707aSArmin Le Grand 	maGraphicObject(rGraphicObject)
58cdf0e10cSrcweir {
59cdf0e10cSrcweir }
60cdf0e10cSrcweir 
61*70d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
62cdf0e10cSrcweir 
63*70d3707aSArmin Le Grand XFillBitmapItem::XFillBitmapItem(const XubString& rName, const GraphicObject& rGraphicObject)
64*70d3707aSArmin Le Grand :   NameOrIndex(XATTR_FILLBITMAP, rName),
65*70d3707aSArmin Le Grand 	maGraphicObject(rGraphicObject)
66cdf0e10cSrcweir {
67cdf0e10cSrcweir }
68cdf0e10cSrcweir 
69*70d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
70cdf0e10cSrcweir 
71*70d3707aSArmin Le Grand XFillBitmapItem::XFillBitmapItem(const XFillBitmapItem& rItem)
72*70d3707aSArmin Le Grand :   NameOrIndex(rItem),
73*70d3707aSArmin Le Grand 	maGraphicObject(rItem.maGraphicObject)
74cdf0e10cSrcweir {
75cdf0e10cSrcweir }
76cdf0e10cSrcweir 
77*70d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
78cdf0e10cSrcweir 
79*70d3707aSArmin Le Grand Bitmap createHistorical8x8FromArray(const sal_uInt16* pArray, Color aColorPix, Color aColorBack)
80cdf0e10cSrcweir {
81*70d3707aSArmin Le Grand     BitmapPalette aPalette(2);
82*70d3707aSArmin Le Grand 
83*70d3707aSArmin Le Grand     aPalette[0] = BitmapColor(aColorBack);
84*70d3707aSArmin Le Grand     aPalette[1] = BitmapColor(aColorPix);
85*70d3707aSArmin Le Grand 
86*70d3707aSArmin Le Grand     Bitmap aBitmap(Size(8, 8), 1, &aPalette);
87*70d3707aSArmin Le Grand 	BitmapWriteAccess* pContent = aBitmap.AcquireWriteAccess();
88*70d3707aSArmin Le Grand 
89*70d3707aSArmin Le Grand     if(pContent)
90*70d3707aSArmin Le Grand     {
91*70d3707aSArmin Le Grand         for(sal_uInt16 a(0); a < 8; a++)
92*70d3707aSArmin Le Grand         {
93*70d3707aSArmin Le Grand             for(sal_uInt16 b(0); b < 8; b++)
94*70d3707aSArmin Le Grand             {
95*70d3707aSArmin Le Grand                 if(pArray[(a * 8) + b])
96*70d3707aSArmin Le Grand                 {
97*70d3707aSArmin Le Grand                     pContent->SetPixel(b, a, sal_uInt8(1));
98*70d3707aSArmin Le Grand                 }
99*70d3707aSArmin Le Grand                 else
100*70d3707aSArmin Le Grand                 {
101*70d3707aSArmin Le Grand                     pContent->SetPixel(b, a, sal_uInt8(0));
102*70d3707aSArmin Le Grand                 }
103*70d3707aSArmin Le Grand             }
104*70d3707aSArmin Le Grand         }
105*70d3707aSArmin Le Grand 
106*70d3707aSArmin Le Grand         aBitmap.ReleaseAccess(pContent);
107*70d3707aSArmin Le Grand     }
108*70d3707aSArmin Le Grand 
109*70d3707aSArmin Le Grand     return aBitmap;
110*70d3707aSArmin Le Grand }
111*70d3707aSArmin Le Grand 
112*70d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
113*70d3707aSArmin Le Grand 
114*70d3707aSArmin Le Grand bool SVX_DLLPUBLIC isHistorical8x8(const BitmapEx& rBitmapEx, BitmapColor& o_rBack, BitmapColor& o_rFront)
115*70d3707aSArmin Le Grand {
116*70d3707aSArmin Le Grand     if(!rBitmapEx.IsTransparent())
117*70d3707aSArmin Le Grand     {
118*70d3707aSArmin Le Grand         Bitmap aBitmap(rBitmapEx.GetBitmap());
119*70d3707aSArmin Le Grand 
120*70d3707aSArmin Le Grand         if(8 == aBitmap.GetSizePixel().Width() && 8 == aBitmap.GetSizePixel().Height())
121*70d3707aSArmin Le Grand         {
122*70d3707aSArmin Le Grand             if(2 == aBitmap.GetColorCount())
123*70d3707aSArmin Le Grand             {
124*70d3707aSArmin Le Grand                 BitmapReadAccess* pRead = aBitmap.AcquireReadAccess();
125*70d3707aSArmin Le Grand 
126*70d3707aSArmin Le Grand                 if(pRead)
127*70d3707aSArmin Le Grand                 {
128*70d3707aSArmin Le Grand                     if(pRead->HasPalette() && 2 == pRead->GetPaletteEntryCount())
129*70d3707aSArmin Le Grand                     {
130*70d3707aSArmin Le Grand                         const BitmapPalette& rPalette = pRead->GetPalette();
131*70d3707aSArmin Le Grand 
132*70d3707aSArmin Le Grand                         o_rBack = rPalette[1];
133*70d3707aSArmin Le Grand                         o_rFront = rPalette[0];
134*70d3707aSArmin Le Grand 
135*70d3707aSArmin Le Grand                         return true;
136*70d3707aSArmin Le Grand                     }
137*70d3707aSArmin Le Grand                 }
138*70d3707aSArmin Le Grand             }
139*70d3707aSArmin Le Grand         }
140*70d3707aSArmin Le Grand     }
141*70d3707aSArmin Le Grand 
142*70d3707aSArmin Le Grand     return false;
143*70d3707aSArmin Le Grand }
144*70d3707aSArmin Le Grand 
145*70d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
146*70d3707aSArmin Le Grand 
147*70d3707aSArmin Le Grand XFillBitmapItem::XFillBitmapItem(SvStream& rIn, sal_uInt16 nVer)
148*70d3707aSArmin Le Grand :   NameOrIndex(XATTR_FILLBITMAP, rIn)
149cdf0e10cSrcweir {
150cdf0e10cSrcweir 	if (!IsIndex())
151cdf0e10cSrcweir 	{
152*70d3707aSArmin Le Grand 	    if(0 == nVer)
153*70d3707aSArmin Le Grand 	    {
154cdf0e10cSrcweir 		    // Behandlung der alten Bitmaps
155cdf0e10cSrcweir 		    Bitmap aBmp;
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 		    rIn >> aBmp;
158*70d3707aSArmin Le Grand             maGraphicObject = Graphic(aBmp);
159*70d3707aSArmin Le Grand 	    }
160*70d3707aSArmin Le Grand 	    else if(1 == nVer)
161*70d3707aSArmin Le Grand 	    {
162*70d3707aSArmin Le Grand             enum XBitmapType
163*70d3707aSArmin Le Grand             {
164*70d3707aSArmin Le Grand                 XBITMAP_IMPORT,
165*70d3707aSArmin Le Grand                 XBITMAP_8X8
166*70d3707aSArmin Le Grand             };
167cdf0e10cSrcweir 
168cdf0e10cSrcweir             sal_Int16 iTmp;
169cdf0e10cSrcweir 
170*70d3707aSArmin Le Grand             rIn >> iTmp; // former XBitmapStyle
171*70d3707aSArmin Le Grand 		    rIn >> iTmp; // former XBitmapType
172*70d3707aSArmin Le Grand 
173*70d3707aSArmin Le Grand 		    if(XBITMAP_IMPORT == iTmp)
174cdf0e10cSrcweir 		    {
175cdf0e10cSrcweir 			    Bitmap aBmp;
176*70d3707aSArmin Le Grand 
177cdf0e10cSrcweir                 rIn >> aBmp;
178*70d3707aSArmin Le Grand                 maGraphicObject = Graphic(aBmp);
179cdf0e10cSrcweir 		    }
180*70d3707aSArmin Le Grand 		    else if(XBITMAP_8X8 == iTmp)
181cdf0e10cSrcweir 		    {
182*70d3707aSArmin Le Grand                 sal_uInt16 aArray[64];
183cdf0e10cSrcweir 
184*70d3707aSArmin Le Grand 			    for(sal_uInt16 i(0); i < 64; i++)
185*70d3707aSArmin Le Grand                 {
186*70d3707aSArmin Le Grand 				    rIn >> aArray[i];
187*70d3707aSArmin Le Grand                 }
188cdf0e10cSrcweir 
189*70d3707aSArmin Le Grand 			    Color aColorPix;
190*70d3707aSArmin Le Grand 			    Color aColorBack;
191cdf0e10cSrcweir 
192*70d3707aSArmin Le Grand                 rIn >> aColorPix;
193*70d3707aSArmin Le Grand 			    rIn >> aColorBack;
194*70d3707aSArmin Le Grand 
195*70d3707aSArmin Le Grand                 const Bitmap aBitmap(createHistorical8x8FromArray(aArray, aColorPix, aColorBack));
196*70d3707aSArmin Le Grand 
197*70d3707aSArmin Le Grand                 maGraphicObject = Graphic(aBitmap);
198*70d3707aSArmin Le Grand             }
199*70d3707aSArmin Le Grand 	    }
200*70d3707aSArmin Le Grand         else if(2 == nVer)
201*70d3707aSArmin Le Grand         {
202*70d3707aSArmin Le Grand 		    BitmapEx aBmpEx;
203*70d3707aSArmin Le Grand 
204*70d3707aSArmin Le Grand 		    rIn >> aBmpEx;
205*70d3707aSArmin Le Grand             maGraphicObject = Graphic(aBmpEx);
206cdf0e10cSrcweir         }
207cdf0e10cSrcweir     }
208cdf0e10cSrcweir }
209cdf0e10cSrcweir 
210*70d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
211cdf0e10cSrcweir 
212*70d3707aSArmin Le Grand XFillBitmapItem::XFillBitmapItem(SfxItemPool* /*pPool*/, const GraphicObject& rGraphicObject)
213cdf0e10cSrcweir : 	NameOrIndex( XATTR_FILLBITMAP, -1),
214*70d3707aSArmin Le Grand 	maGraphicObject(rGraphicObject)
215cdf0e10cSrcweir {
216cdf0e10cSrcweir }
217cdf0e10cSrcweir 
218*70d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
219cdf0e10cSrcweir 
220cdf0e10cSrcweir XFillBitmapItem::XFillBitmapItem(SfxItemPool* /*pPool*/)
221*70d3707aSArmin Le Grand :   NameOrIndex(XATTR_FILLBITMAP, -1),
222*70d3707aSArmin Le Grand     maGraphicObject()
223cdf0e10cSrcweir {
224cdf0e10cSrcweir }
225cdf0e10cSrcweir 
226*70d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
227cdf0e10cSrcweir 
228cdf0e10cSrcweir SfxPoolItem* XFillBitmapItem::Clone(SfxItemPool* /*pPool*/) const
229cdf0e10cSrcweir {
230cdf0e10cSrcweir 	return new XFillBitmapItem(*this);
231cdf0e10cSrcweir }
232cdf0e10cSrcweir 
233*70d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
234cdf0e10cSrcweir 
235cdf0e10cSrcweir int XFillBitmapItem::operator==(const SfxPoolItem& rItem) const
236cdf0e10cSrcweir {
237*70d3707aSArmin Le Grand 	return (NameOrIndex::operator==(rItem)
238*70d3707aSArmin Le Grand         && maGraphicObject == ((const XFillBitmapItem&)rItem).maGraphicObject);
239cdf0e10cSrcweir }
240cdf0e10cSrcweir 
241*70d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
242cdf0e10cSrcweir 
243cdf0e10cSrcweir SfxPoolItem* XFillBitmapItem::Create(SvStream& rIn, sal_uInt16 nVer) const
244cdf0e10cSrcweir {
245cdf0e10cSrcweir 	return new XFillBitmapItem( rIn, nVer );
246cdf0e10cSrcweir }
247cdf0e10cSrcweir 
248*70d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
249cdf0e10cSrcweir 
250cdf0e10cSrcweir SvStream& XFillBitmapItem::Store( SvStream& rOut, sal_uInt16 nItemVersion ) const
251cdf0e10cSrcweir {
252cdf0e10cSrcweir 	NameOrIndex::Store(rOut, nItemVersion);
253cdf0e10cSrcweir 
254cdf0e10cSrcweir 	if(!IsIndex())
255cdf0e10cSrcweir 	{
256*70d3707aSArmin Le Grand         rOut << maGraphicObject.GetGraphic().GetBitmapEx();
257cdf0e10cSrcweir 	}
258cdf0e10cSrcweir 
259cdf0e10cSrcweir 	return rOut;
260cdf0e10cSrcweir }
261cdf0e10cSrcweir 
262*70d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
263cdf0e10cSrcweir 
264*70d3707aSArmin Le Grand const GraphicObject& XFillBitmapItem::GetGraphicObject() const
265cdf0e10cSrcweir {
266*70d3707aSArmin Le Grand     return maGraphicObject;
267cdf0e10cSrcweir }
268cdf0e10cSrcweir 
269*70d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
270cdf0e10cSrcweir 
271*70d3707aSArmin Le Grand void XFillBitmapItem::SetGraphicObject(const GraphicObject& rGraphicObject)
272*70d3707aSArmin Le Grand {
273*70d3707aSArmin Le Grand     maGraphicObject = rGraphicObject;
274*70d3707aSArmin Le Grand }
275*70d3707aSArmin Le Grand 
276*70d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
277cdf0e10cSrcweir 
278cdf0e10cSrcweir sal_uInt16 XFillBitmapItem::GetVersion(sal_uInt16 /*nFileFormatVersion*/) const
279cdf0e10cSrcweir {
280*70d3707aSArmin Le Grand 	// version three
281*70d3707aSArmin Le Grand 	return(2);
282cdf0e10cSrcweir }
283cdf0e10cSrcweir 
284*70d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
285cdf0e10cSrcweir 
286*70d3707aSArmin Le Grand SfxItemPresentation XFillBitmapItem::GetPresentation(
287cdf0e10cSrcweir 	SfxItemPresentation ePres,
288cdf0e10cSrcweir 	SfxMapUnit /*eCoreUnit*/,
289cdf0e10cSrcweir 	SfxMapUnit /*ePresUnit*/,
290*70d3707aSArmin Le Grand     XubString& rText,
291*70d3707aSArmin Le Grand     const IntlWrapper*) const
292cdf0e10cSrcweir {
293cdf0e10cSrcweir 	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 
307*70d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
308cdf0e10cSrcweir 
309cdf0e10cSrcweir 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 	{
333cdf0e10cSrcweir         aURL = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX));
334*70d3707aSArmin Le Grand 		aURL += ::rtl::OUString::createFromAscii(GetGraphicObject().GetUniqueID().GetBuffer() );
335cdf0e10cSrcweir 	}
336cdf0e10cSrcweir     if( nMemberId == MID_BITMAP ||
337cdf0e10cSrcweir         nMemberId == 0  )
338cdf0e10cSrcweir 	{
339*70d3707aSArmin 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 
367*70d3707aSArmin 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     {
416*70d3707aSArmin Le Grand         maGraphicObject  = GraphicObject::CreateGraphicObjectFromURL(aURL);
417cdf0e10cSrcweir     }
418cdf0e10cSrcweir     if( bSetBitmap )
419cdf0e10cSrcweir     {
420cdf0e10cSrcweir 		if(xBmp.is())
421cdf0e10cSrcweir 		{
422*70d3707aSArmin Le Grand             maGraphicObject = Graphic(VCLUnoHelper::GetBitmap(xBmp));
423cdf0e10cSrcweir 		}
424cdf0e10cSrcweir 		else if(xGraphic.is())
425cdf0e10cSrcweir 		{
426*70d3707aSArmin Le Grand 			maGraphicObject = Graphic(xGraphic);
427cdf0e10cSrcweir 		}
428cdf0e10cSrcweir     }
429cdf0e10cSrcweir 
430cdf0e10cSrcweir 	return (bSetName || bSetURL || bSetBitmap);
431cdf0e10cSrcweir }
432cdf0e10cSrcweir 
433*70d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
434*70d3707aSArmin Le Grand 
435cdf0e10cSrcweir sal_Bool XFillBitmapItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 )
436cdf0e10cSrcweir {
437*70d3707aSArmin Le Grand     const GraphicObject& aGraphicObjectA(((XFillBitmapItem*)p1)->GetGraphicObject());
438*70d3707aSArmin Le Grand     const GraphicObject& aGraphicObjectB(((XFillBitmapItem*)p2)->GetGraphicObject());
439*70d3707aSArmin Le Grand 
440*70d3707aSArmin Le Grand 	return aGraphicObjectA == aGraphicObjectB;
441cdf0e10cSrcweir }
442cdf0e10cSrcweir 
443*70d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
444*70d3707aSArmin Le Grand 
445cdf0e10cSrcweir XFillBitmapItem* XFillBitmapItem::checkForUniqueItem( SdrModel* pModel ) const
446cdf0e10cSrcweir {
447cdf0e10cSrcweir 	if( pModel )
448cdf0e10cSrcweir 	{
449cdf0e10cSrcweir 		const String aUniqueName = NameOrIndex::CheckNamedItem(	this,
450cdf0e10cSrcweir 																XATTR_FILLBITMAP,
451cdf0e10cSrcweir 																&pModel->GetItemPool(),
452cdf0e10cSrcweir 																pModel->GetStyleSheetPool() ? &pModel->GetStyleSheetPool()->GetPool() : NULL,
453cdf0e10cSrcweir 																XFillBitmapItem::CompareValueFunc,
454cdf0e10cSrcweir 																RID_SVXSTR_BMP21,
455cdf0e10cSrcweir 																pModel->GetBitmapList() );
456cdf0e10cSrcweir 
457cdf0e10cSrcweir 		// if the given name is not valid, replace it!
458cdf0e10cSrcweir 		if( aUniqueName != GetName() )
459cdf0e10cSrcweir 		{
460*70d3707aSArmin Le Grand 			return new XFillBitmapItem(aUniqueName, maGraphicObject);
461cdf0e10cSrcweir 		}
462cdf0e10cSrcweir 	}
463cdf0e10cSrcweir 
464cdf0e10cSrcweir 	return (XFillBitmapItem*)this;
465cdf0e10cSrcweir }
466*70d3707aSArmin Le Grand 
467*70d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
468*70d3707aSArmin Le Grand // eof
469