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>
4545fd3b9aSArmin Le Grand #include <vcl/dibtools.hxx>
46cdf0e10cSrcweir
47cdf0e10cSrcweir using namespace ::com::sun::star;
48cdf0e10cSrcweir
4970d3707aSArmin Le Grand // -----------------------
5070d3707aSArmin Le Grand // class XFillBitmapItem
5170d3707aSArmin Le Grand // -----------------------
5270d3707aSArmin Le Grand TYPEINIT1_AUTOFACTORY(XFillBitmapItem, NameOrIndex);
53cdf0e10cSrcweir
5470d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
55cdf0e10cSrcweir
XFillBitmapItem(long nIndex,const GraphicObject & rGraphicObject)5670d3707aSArmin Le Grand XFillBitmapItem::XFillBitmapItem(long nIndex, const GraphicObject& rGraphicObject)
5770d3707aSArmin Le Grand : NameOrIndex(XATTR_FILLBITMAP, nIndex),
5870d3707aSArmin Le Grand maGraphicObject(rGraphicObject)
59cdf0e10cSrcweir {
60cdf0e10cSrcweir }
61cdf0e10cSrcweir
6270d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
63cdf0e10cSrcweir
XFillBitmapItem(const XubString & rName,const GraphicObject & rGraphicObject)6470d3707aSArmin Le Grand XFillBitmapItem::XFillBitmapItem(const XubString& rName, const GraphicObject& rGraphicObject)
6570d3707aSArmin Le Grand : NameOrIndex(XATTR_FILLBITMAP, rName),
6670d3707aSArmin Le Grand maGraphicObject(rGraphicObject)
67cdf0e10cSrcweir {
68cdf0e10cSrcweir }
69cdf0e10cSrcweir
7070d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
71cdf0e10cSrcweir
XFillBitmapItem(const XFillBitmapItem & rItem)7270d3707aSArmin Le Grand XFillBitmapItem::XFillBitmapItem(const XFillBitmapItem& rItem)
7370d3707aSArmin Le Grand : NameOrIndex(rItem),
7470d3707aSArmin Le Grand maGraphicObject(rItem.maGraphicObject)
75cdf0e10cSrcweir {
76cdf0e10cSrcweir }
77cdf0e10cSrcweir
7870d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
79cdf0e10cSrcweir
createHistorical8x8FromArray(const sal_uInt16 * pArray,Color aColorPix,Color aColorBack)8070d3707aSArmin Le Grand Bitmap createHistorical8x8FromArray(const sal_uInt16* pArray, Color aColorPix, Color aColorBack)
81cdf0e10cSrcweir {
8270d3707aSArmin Le Grand BitmapPalette aPalette(2);
83cdf0e10cSrcweir
8470d3707aSArmin Le Grand aPalette[0] = BitmapColor(aColorBack);
8570d3707aSArmin Le Grand aPalette[1] = BitmapColor(aColorPix);
86cdf0e10cSrcweir
8770d3707aSArmin Le Grand Bitmap aBitmap(Size(8, 8), 1, &aPalette);
8870d3707aSArmin Le Grand BitmapWriteAccess* pContent = aBitmap.AcquireWriteAccess();
89cdf0e10cSrcweir
9070d3707aSArmin Le Grand if(pContent)
9170d3707aSArmin Le Grand {
9270d3707aSArmin Le Grand for(sal_uInt16 a(0); a < 8; a++)
9370d3707aSArmin Le Grand {
9470d3707aSArmin Le Grand for(sal_uInt16 b(0); b < 8; b++)
9570d3707aSArmin Le Grand {
9670d3707aSArmin Le Grand if(pArray[(a * 8) + b])
9770d3707aSArmin Le Grand {
983e407bd8SArmin Le Grand pContent->SetPixelIndex(a, b, 1);
9970d3707aSArmin Le Grand }
10070d3707aSArmin Le Grand else
10170d3707aSArmin Le Grand {
1023e407bd8SArmin Le Grand pContent->SetPixelIndex(a, b, 0);
10370d3707aSArmin Le Grand }
10470d3707aSArmin Le Grand }
10570d3707aSArmin Le Grand }
106cdf0e10cSrcweir
10770d3707aSArmin Le Grand aBitmap.ReleaseAccess(pContent);
10870d3707aSArmin Le Grand }
109cdf0e10cSrcweir
11070d3707aSArmin Le Grand return aBitmap;
111cdf0e10cSrcweir }
112cdf0e10cSrcweir
11370d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
114cdf0e10cSrcweir
isHistorical8x8(const BitmapEx & rBitmapEx,BitmapColor & o_rBack,BitmapColor & o_rFront)11570d3707aSArmin Le Grand bool SVX_DLLPUBLIC isHistorical8x8(const BitmapEx& rBitmapEx, BitmapColor& o_rBack, BitmapColor& o_rFront)
116cdf0e10cSrcweir {
11770d3707aSArmin Le Grand if(!rBitmapEx.IsTransparent())
11870d3707aSArmin Le Grand {
11970d3707aSArmin Le Grand Bitmap aBitmap(rBitmapEx.GetBitmap());
120cdf0e10cSrcweir
12170d3707aSArmin Le Grand if(8 == aBitmap.GetSizePixel().Width() && 8 == aBitmap.GetSizePixel().Height())
12270d3707aSArmin Le Grand {
12370d3707aSArmin Le Grand if(2 == aBitmap.GetColorCount())
12470d3707aSArmin Le Grand {
12570d3707aSArmin Le Grand BitmapReadAccess* pRead = aBitmap.AcquireReadAccess();
12670d3707aSArmin Le Grand
12770d3707aSArmin Le Grand if(pRead)
12870d3707aSArmin Le Grand {
12970d3707aSArmin Le Grand if(pRead->HasPalette() && 2 == pRead->GetPaletteEntryCount())
13070d3707aSArmin Le Grand {
13170d3707aSArmin Le Grand const BitmapPalette& rPalette = pRead->GetPalette();
132*1f69a0e2SArmin Le Grand
133*1f69a0e2SArmin Le Grand // #123564# bachground and foregrund were exchanged; of course
134*1f69a0e2SArmin Le Grand // rPalette[0] is the background color
135*1f69a0e2SArmin Le Grand o_rFront = rPalette[1];
136*1f69a0e2SArmin Le Grand o_rBack = rPalette[0];
137*1f69a0e2SArmin Le Grand
13870d3707aSArmin Le Grand return true;
13970d3707aSArmin Le Grand }
14070d3707aSArmin Le Grand }
14170d3707aSArmin Le Grand }
14270d3707aSArmin Le Grand }
14370d3707aSArmin Le Grand }
144cdf0e10cSrcweir
14570d3707aSArmin Le Grand return false;
146cdf0e10cSrcweir }
147cdf0e10cSrcweir
14870d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
149cdf0e10cSrcweir
XFillBitmapItem(SvStream & rIn,sal_uInt16 nVer)15070d3707aSArmin Le Grand XFillBitmapItem::XFillBitmapItem(SvStream& rIn, sal_uInt16 nVer)
15170d3707aSArmin Le Grand : NameOrIndex(XATTR_FILLBITMAP, rIn)
152cdf0e10cSrcweir {
15370d3707aSArmin Le Grand if (!IsIndex())
154cdf0e10cSrcweir {
15570d3707aSArmin Le Grand if(0 == nVer)
15670d3707aSArmin Le Grand {
15770d3707aSArmin Le Grand // Behandlung der alten Bitmaps
15870d3707aSArmin Le Grand Bitmap aBmp;
15970d3707aSArmin Le Grand
16045fd3b9aSArmin Le Grand ReadDIB(aBmp, rIn, true);
16170d3707aSArmin Le Grand maGraphicObject = Graphic(aBmp);
16270d3707aSArmin Le Grand }
16370d3707aSArmin Le Grand else if(1 == nVer)
16470d3707aSArmin Le Grand {
16570d3707aSArmin Le Grand enum XBitmapType
16670d3707aSArmin Le Grand {
16770d3707aSArmin Le Grand XBITMAP_IMPORT,
16870d3707aSArmin Le Grand XBITMAP_8X8
16970d3707aSArmin Le Grand };
17070d3707aSArmin Le Grand
17170d3707aSArmin Le Grand sal_Int16 iTmp;
17270d3707aSArmin Le Grand
17370d3707aSArmin Le Grand rIn >> iTmp; // former XBitmapStyle
17470d3707aSArmin Le Grand rIn >> iTmp; // former XBitmapType
17570d3707aSArmin Le Grand
17670d3707aSArmin Le Grand if(XBITMAP_IMPORT == iTmp)
17770d3707aSArmin Le Grand {
17870d3707aSArmin Le Grand Bitmap aBmp;
17970d3707aSArmin Le Grand
18045fd3b9aSArmin Le Grand ReadDIB(aBmp, rIn, true);
18170d3707aSArmin Le Grand maGraphicObject = Graphic(aBmp);
18270d3707aSArmin Le Grand }
18370d3707aSArmin Le Grand else if(XBITMAP_8X8 == iTmp)
18470d3707aSArmin Le Grand {
18570d3707aSArmin Le Grand sal_uInt16 aArray[64];
18670d3707aSArmin Le Grand
18770d3707aSArmin Le Grand for(sal_uInt16 i(0); i < 64; i++)
18870d3707aSArmin Le Grand {
18970d3707aSArmin Le Grand rIn >> aArray[i];
19070d3707aSArmin Le Grand }
19170d3707aSArmin Le Grand
19270d3707aSArmin Le Grand Color aColorPix;
19370d3707aSArmin Le Grand Color aColorBack;
19470d3707aSArmin Le Grand
19570d3707aSArmin Le Grand rIn >> aColorPix;
19670d3707aSArmin Le Grand rIn >> aColorBack;
19770d3707aSArmin Le Grand
19870d3707aSArmin Le Grand const Bitmap aBitmap(createHistorical8x8FromArray(aArray, aColorPix, aColorBack));
19970d3707aSArmin Le Grand
20070d3707aSArmin Le Grand maGraphicObject = Graphic(aBitmap);
20170d3707aSArmin Le Grand }
20270d3707aSArmin Le Grand }
20370d3707aSArmin Le Grand else if(2 == nVer)
20470d3707aSArmin Le Grand {
20570d3707aSArmin Le Grand BitmapEx aBmpEx;
206cdf0e10cSrcweir
20745fd3b9aSArmin Le Grand ReadDIBBitmapEx(aBmpEx, rIn);
20870d3707aSArmin Le Grand maGraphicObject = Graphic(aBmpEx);
20970d3707aSArmin Le Grand }
21070d3707aSArmin Le Grand }
211cdf0e10cSrcweir }
212cdf0e10cSrcweir
21370d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
214cdf0e10cSrcweir
XFillBitmapItem(SfxItemPool *,const GraphicObject & rGraphicObject)21570d3707aSArmin Le Grand XFillBitmapItem::XFillBitmapItem(SfxItemPool* /*pPool*/, const GraphicObject& rGraphicObject)
21670d3707aSArmin Le Grand : NameOrIndex( XATTR_FILLBITMAP, -1),
21770d3707aSArmin Le Grand maGraphicObject(rGraphicObject)
218cdf0e10cSrcweir {
219cdf0e10cSrcweir }
220cdf0e10cSrcweir
22170d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
222cdf0e10cSrcweir
XFillBitmapItem(SfxItemPool *)22370d3707aSArmin Le Grand XFillBitmapItem::XFillBitmapItem(SfxItemPool* /*pPool*/)
22470d3707aSArmin Le Grand : NameOrIndex(XATTR_FILLBITMAP, -1),
22570d3707aSArmin Le Grand maGraphicObject()
226cdf0e10cSrcweir {
227cdf0e10cSrcweir }
228cdf0e10cSrcweir
22970d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
230cdf0e10cSrcweir
Clone(SfxItemPool *) const231cdf0e10cSrcweir SfxPoolItem* XFillBitmapItem::Clone(SfxItemPool* /*pPool*/) const
232cdf0e10cSrcweir {
233cdf0e10cSrcweir return new XFillBitmapItem(*this);
234cdf0e10cSrcweir }
235cdf0e10cSrcweir
23670d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
237cdf0e10cSrcweir
operator ==(const SfxPoolItem & rItem) const238cdf0e10cSrcweir int XFillBitmapItem::operator==(const SfxPoolItem& rItem) const
239cdf0e10cSrcweir {
24070d3707aSArmin Le Grand return (NameOrIndex::operator==(rItem)
24170d3707aSArmin Le Grand && maGraphicObject == ((const XFillBitmapItem&)rItem).maGraphicObject);
242cdf0e10cSrcweir }
243cdf0e10cSrcweir
24470d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
245cdf0e10cSrcweir
Create(SvStream & rIn,sal_uInt16 nVer) const246cdf0e10cSrcweir SfxPoolItem* XFillBitmapItem::Create(SvStream& rIn, sal_uInt16 nVer) const
247cdf0e10cSrcweir {
248cdf0e10cSrcweir return new XFillBitmapItem( rIn, nVer );
249cdf0e10cSrcweir }
250cdf0e10cSrcweir
25170d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
252cdf0e10cSrcweir
Store(SvStream & rOut,sal_uInt16 nItemVersion) const253cdf0e10cSrcweir SvStream& XFillBitmapItem::Store( SvStream& rOut, sal_uInt16 nItemVersion ) const
254cdf0e10cSrcweir {
25570d3707aSArmin Le Grand NameOrIndex::Store(rOut, nItemVersion);
256cdf0e10cSrcweir
25770d3707aSArmin Le Grand if(!IsIndex())
258cdf0e10cSrcweir {
25945fd3b9aSArmin Le Grand WriteDIBBitmapEx(maGraphicObject.GetGraphic().GetBitmapEx(), rOut);
260cdf0e10cSrcweir }
261cdf0e10cSrcweir
262cdf0e10cSrcweir return rOut;
263cdf0e10cSrcweir }
264cdf0e10cSrcweir
26570d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
26670d3707aSArmin Le Grand
GetGraphicObject() const26770d3707aSArmin Le Grand const GraphicObject& XFillBitmapItem::GetGraphicObject() const
268cdf0e10cSrcweir {
26970d3707aSArmin Le Grand return maGraphicObject;
270cdf0e10cSrcweir }
271cdf0e10cSrcweir
27270d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
27370d3707aSArmin Le Grand
SetGraphicObject(const GraphicObject & rGraphicObject)27470d3707aSArmin Le Grand void XFillBitmapItem::SetGraphicObject(const GraphicObject& rGraphicObject)
27570d3707aSArmin Le Grand {
27670d3707aSArmin Le Grand maGraphicObject = rGraphicObject;
27770d3707aSArmin Le Grand }
278cdf0e10cSrcweir
27970d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
280cdf0e10cSrcweir
GetVersion(sal_uInt16) const28170d3707aSArmin Le Grand sal_uInt16 XFillBitmapItem::GetVersion(sal_uInt16 /*nFileFormatVersion*/) const
282cdf0e10cSrcweir {
28370d3707aSArmin Le Grand // version three
28470d3707aSArmin Le Grand return(2);
285cdf0e10cSrcweir }
286cdf0e10cSrcweir
28770d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
288cdf0e10cSrcweir
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const28970d3707aSArmin Le Grand SfxItemPresentation XFillBitmapItem::GetPresentation(
290cdf0e10cSrcweir SfxItemPresentation ePres,
29170d3707aSArmin Le Grand SfxMapUnit /*eCoreUnit*/,
29270d3707aSArmin Le Grand SfxMapUnit /*ePresUnit*/,
29370d3707aSArmin Le Grand XubString& rText,
29470d3707aSArmin Le Grand const IntlWrapper*) const
295cdf0e10cSrcweir {
29670d3707aSArmin Le Grand switch (ePres)
297cdf0e10cSrcweir {
298cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NONE:
299cdf0e10cSrcweir rText.Erase();
300cdf0e10cSrcweir return ePres;
301cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NAMELESS:
302cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_COMPLETE:
303cdf0e10cSrcweir rText += GetName();
304cdf0e10cSrcweir return ePres;
305cdf0e10cSrcweir default:
306cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NONE;
307cdf0e10cSrcweir }
308cdf0e10cSrcweir }
309cdf0e10cSrcweir
31070d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
311cdf0e10cSrcweir
QueryValue(::com::sun::star::uno::Any & rVal,sal_uInt8 nMemberId) const31270d3707aSArmin Le Grand sal_Bool XFillBitmapItem::QueryValue(::com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId) const
313cdf0e10cSrcweir {
314cdf0e10cSrcweir nMemberId &= ~CONVERT_TWIPS;
315cdf0e10cSrcweir
316cdf0e10cSrcweir // needed for MID_NAME
317cdf0e10cSrcweir ::rtl::OUString aApiName;
318cdf0e10cSrcweir // needed for complete item (MID 0)
319cdf0e10cSrcweir ::rtl::OUString aInternalName;
320cdf0e10cSrcweir
321cdf0e10cSrcweir ::rtl::OUString aURL;
322cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap > xBmp;
323cdf0e10cSrcweir
324cdf0e10cSrcweir if( nMemberId == MID_NAME )
325cdf0e10cSrcweir {
326cdf0e10cSrcweir SvxUnogetApiNameForItem( Which(), GetName(), aApiName );
327cdf0e10cSrcweir }
328cdf0e10cSrcweir else if( nMemberId == 0 )
329cdf0e10cSrcweir {
330cdf0e10cSrcweir aInternalName = GetName();
331cdf0e10cSrcweir }
332cdf0e10cSrcweir
333cdf0e10cSrcweir if( nMemberId == MID_GRAFURL ||
334cdf0e10cSrcweir nMemberId == 0 )
335cdf0e10cSrcweir {
33670d3707aSArmin Le Grand aURL = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX));
33770d3707aSArmin Le Grand aURL += ::rtl::OUString::createFromAscii(GetGraphicObject().GetUniqueID().GetBuffer() );
338cdf0e10cSrcweir }
339cdf0e10cSrcweir if( nMemberId == MID_BITMAP ||
340cdf0e10cSrcweir nMemberId == 0 )
341cdf0e10cSrcweir {
34270d3707aSArmin Le Grand xBmp.set(VCLUnoHelper::CreateBitmap(GetGraphicObject().GetGraphic().GetBitmapEx()));
343cdf0e10cSrcweir }
344cdf0e10cSrcweir
345cdf0e10cSrcweir if( nMemberId == MID_NAME )
346cdf0e10cSrcweir rVal <<= aApiName;
347cdf0e10cSrcweir else if( nMemberId == MID_GRAFURL )
348cdf0e10cSrcweir rVal <<= aURL;
349cdf0e10cSrcweir else if( nMemberId == MID_BITMAP )
350cdf0e10cSrcweir rVal <<= xBmp;
351cdf0e10cSrcweir else
352cdf0e10cSrcweir {
353cdf0e10cSrcweir // member-id 0 => complete item (e.g. for toolbars)
354cdf0e10cSrcweir DBG_ASSERT( nMemberId == 0, "invalid member-id" );
355cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aPropSeq( 3 );
356cdf0e10cSrcweir
357cdf0e10cSrcweir aPropSeq[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ));
358cdf0e10cSrcweir aPropSeq[0].Value = uno::makeAny( aInternalName );
359cdf0e10cSrcweir aPropSeq[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillBitmapURL" ));
360cdf0e10cSrcweir aPropSeq[1].Value = uno::makeAny( aURL );
361cdf0e10cSrcweir aPropSeq[2].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Bitmap" ));
362cdf0e10cSrcweir aPropSeq[2].Value = uno::makeAny( xBmp );
363cdf0e10cSrcweir
364cdf0e10cSrcweir rVal <<= aPropSeq;
365cdf0e10cSrcweir }
366cdf0e10cSrcweir
367cdf0e10cSrcweir return sal_True;
368cdf0e10cSrcweir }
369cdf0e10cSrcweir
37070d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
371cdf0e10cSrcweir
PutValue(const::com::sun::star::uno::Any & rVal,sal_uInt8 nMemberId)372cdf0e10cSrcweir sal_Bool XFillBitmapItem::PutValue( const ::com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId )
373cdf0e10cSrcweir {
374cdf0e10cSrcweir nMemberId &= ~CONVERT_TWIPS;
375cdf0e10cSrcweir
376cdf0e10cSrcweir ::rtl::OUString aName;
377cdf0e10cSrcweir ::rtl::OUString aURL;
378cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap > xBmp;
379cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > xGraphic;
380cdf0e10cSrcweir
381cdf0e10cSrcweir bool bSetName = false;
382cdf0e10cSrcweir bool bSetURL = false;
383cdf0e10cSrcweir bool bSetBitmap = false;
384cdf0e10cSrcweir
385cdf0e10cSrcweir if( nMemberId == MID_NAME )
386cdf0e10cSrcweir bSetName = (rVal >>= aName);
387cdf0e10cSrcweir else if( nMemberId == MID_GRAFURL )
388cdf0e10cSrcweir bSetURL = (rVal >>= aURL);
389cdf0e10cSrcweir else if( nMemberId == MID_BITMAP )
390cdf0e10cSrcweir {
391cdf0e10cSrcweir bSetBitmap = (rVal >>= xBmp);
392cdf0e10cSrcweir if ( !bSetBitmap )
393cdf0e10cSrcweir bSetBitmap = (rVal >>= xGraphic );
394cdf0e10cSrcweir }
395cdf0e10cSrcweir else
396cdf0e10cSrcweir {
397cdf0e10cSrcweir DBG_ASSERT( nMemberId == 0, "invalid member-id" );
398cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aPropSeq;
399cdf0e10cSrcweir if( rVal >>= aPropSeq )
400cdf0e10cSrcweir {
401cdf0e10cSrcweir for ( sal_Int32 n = 0; n < aPropSeq.getLength(); n++ )
402cdf0e10cSrcweir {
403cdf0e10cSrcweir if( aPropSeq[n].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Name" )))
404cdf0e10cSrcweir bSetName = (aPropSeq[n].Value >>= aName);
405cdf0e10cSrcweir else if( aPropSeq[n].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "FillBitmapURL" )))
406cdf0e10cSrcweir bSetURL = (aPropSeq[n].Value >>= aURL);
407cdf0e10cSrcweir else if( aPropSeq[n].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Bitmap" )))
408cdf0e10cSrcweir bSetBitmap = (aPropSeq[n].Value >>= xBmp);
409cdf0e10cSrcweir }
410cdf0e10cSrcweir }
411cdf0e10cSrcweir }
412cdf0e10cSrcweir
413cdf0e10cSrcweir if( bSetName )
414cdf0e10cSrcweir {
415cdf0e10cSrcweir SetName( aName );
416cdf0e10cSrcweir }
417cdf0e10cSrcweir if( bSetURL )
418cdf0e10cSrcweir {
41970d3707aSArmin Le Grand maGraphicObject = GraphicObject::CreateGraphicObjectFromURL(aURL);
420035a2f44SArmin Le Grand
421035a2f44SArmin Le Grand // #121194# Prefer GraphicObject over bitmap object if both are provided
422035a2f44SArmin Le Grand if(bSetBitmap && GRAPHIC_NONE != maGraphicObject.GetType())
423035a2f44SArmin Le Grand {
424035a2f44SArmin Le Grand bSetBitmap = false;
425035a2f44SArmin Le Grand }
426cdf0e10cSrcweir }
427cdf0e10cSrcweir if( bSetBitmap )
428cdf0e10cSrcweir {
42970d3707aSArmin Le Grand if(xBmp.is())
430cdf0e10cSrcweir {
43170d3707aSArmin Le Grand maGraphicObject = Graphic(VCLUnoHelper::GetBitmap(xBmp));
432cdf0e10cSrcweir }
43370d3707aSArmin Le Grand else if(xGraphic.is())
434cdf0e10cSrcweir {
43570d3707aSArmin Le Grand maGraphicObject = Graphic(xGraphic);
436cdf0e10cSrcweir }
437cdf0e10cSrcweir }
438cdf0e10cSrcweir
439cdf0e10cSrcweir return (bSetName || bSetURL || bSetBitmap);
440cdf0e10cSrcweir }
441cdf0e10cSrcweir
44270d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
44370d3707aSArmin Le Grand
CompareValueFunc(const NameOrIndex * p1,const NameOrIndex * p2)444cdf0e10cSrcweir sal_Bool XFillBitmapItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 )
445cdf0e10cSrcweir {
44670d3707aSArmin Le Grand const GraphicObject& aGraphicObjectA(((XFillBitmapItem*)p1)->GetGraphicObject());
44770d3707aSArmin Le Grand const GraphicObject& aGraphicObjectB(((XFillBitmapItem*)p2)->GetGraphicObject());
44870d3707aSArmin Le Grand
44970d3707aSArmin Le Grand return aGraphicObjectA == aGraphicObjectB;
450cdf0e10cSrcweir }
451cdf0e10cSrcweir
45270d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
45370d3707aSArmin Le Grand
checkForUniqueItem(SdrModel * pModel) const454cdf0e10cSrcweir XFillBitmapItem* XFillBitmapItem::checkForUniqueItem( SdrModel* pModel ) const
455cdf0e10cSrcweir {
456cdf0e10cSrcweir if( pModel )
457cdf0e10cSrcweir {
458cdf0e10cSrcweir const String aUniqueName = NameOrIndex::CheckNamedItem( this,
459cdf0e10cSrcweir XATTR_FILLBITMAP,
460cdf0e10cSrcweir &pModel->GetItemPool(),
461cdf0e10cSrcweir pModel->GetStyleSheetPool() ? &pModel->GetStyleSheetPool()->GetPool() : NULL,
462cdf0e10cSrcweir XFillBitmapItem::CompareValueFunc,
463cdf0e10cSrcweir RID_SVXSTR_BMP21,
464c7be74b1SArmin Le Grand pModel->GetBitmapListFromSdrModel().get() );
465cdf0e10cSrcweir
466cdf0e10cSrcweir // if the given name is not valid, replace it!
467cdf0e10cSrcweir if( aUniqueName != GetName() )
468cdf0e10cSrcweir {
46970d3707aSArmin Le Grand return new XFillBitmapItem(aUniqueName, maGraphicObject);
470cdf0e10cSrcweir }
471cdf0e10cSrcweir }
472cdf0e10cSrcweir
473cdf0e10cSrcweir return (XFillBitmapItem*)this;
474cdf0e10cSrcweir }
47570d3707aSArmin Le Grand
47670d3707aSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
47770d3707aSArmin Le Grand // eof
478