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 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 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 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 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 { 98*3e407bd8SArmin Le Grand pContent->SetPixelIndex(a, b, 1); 9970d3707aSArmin Le Grand } 10070d3707aSArmin Le Grand else 10170d3707aSArmin Le Grand { 102*3e407bd8SArmin 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 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(); 13270d3707aSArmin Le Grand 13370d3707aSArmin Le Grand o_rBack = rPalette[1]; 13470d3707aSArmin Le Grand o_rFront = rPalette[0]; 13570d3707aSArmin Le Grand 13670d3707aSArmin Le Grand return true; 13770d3707aSArmin Le Grand } 13870d3707aSArmin Le Grand } 13970d3707aSArmin Le Grand } 14070d3707aSArmin Le Grand } 14170d3707aSArmin Le Grand } 142cdf0e10cSrcweir 14370d3707aSArmin Le Grand return false; 144cdf0e10cSrcweir } 145cdf0e10cSrcweir 14670d3707aSArmin Le Grand ////////////////////////////////////////////////////////////////////////////// 147cdf0e10cSrcweir 14870d3707aSArmin Le Grand XFillBitmapItem::XFillBitmapItem(SvStream& rIn, sal_uInt16 nVer) 14970d3707aSArmin Le Grand : NameOrIndex(XATTR_FILLBITMAP, rIn) 150cdf0e10cSrcweir { 15170d3707aSArmin Le Grand if (!IsIndex()) 152cdf0e10cSrcweir { 15370d3707aSArmin Le Grand if(0 == nVer) 15470d3707aSArmin Le Grand { 15570d3707aSArmin Le Grand // Behandlung der alten Bitmaps 15670d3707aSArmin Le Grand Bitmap aBmp; 15770d3707aSArmin Le Grand 15845fd3b9aSArmin Le Grand ReadDIB(aBmp, rIn, true); 15970d3707aSArmin Le Grand maGraphicObject = Graphic(aBmp); 16070d3707aSArmin Le Grand } 16170d3707aSArmin Le Grand else if(1 == nVer) 16270d3707aSArmin Le Grand { 16370d3707aSArmin Le Grand enum XBitmapType 16470d3707aSArmin Le Grand { 16570d3707aSArmin Le Grand XBITMAP_IMPORT, 16670d3707aSArmin Le Grand XBITMAP_8X8 16770d3707aSArmin Le Grand }; 16870d3707aSArmin Le Grand 16970d3707aSArmin Le Grand sal_Int16 iTmp; 17070d3707aSArmin Le Grand 17170d3707aSArmin Le Grand rIn >> iTmp; // former XBitmapStyle 17270d3707aSArmin Le Grand rIn >> iTmp; // former XBitmapType 17370d3707aSArmin Le Grand 17470d3707aSArmin Le Grand if(XBITMAP_IMPORT == iTmp) 17570d3707aSArmin Le Grand { 17670d3707aSArmin Le Grand Bitmap aBmp; 17770d3707aSArmin Le Grand 17845fd3b9aSArmin Le Grand ReadDIB(aBmp, rIn, true); 17970d3707aSArmin Le Grand maGraphicObject = Graphic(aBmp); 18070d3707aSArmin Le Grand } 18170d3707aSArmin Le Grand else if(XBITMAP_8X8 == iTmp) 18270d3707aSArmin Le Grand { 18370d3707aSArmin Le Grand sal_uInt16 aArray[64]; 18470d3707aSArmin Le Grand 18570d3707aSArmin Le Grand for(sal_uInt16 i(0); i < 64; i++) 18670d3707aSArmin Le Grand { 18770d3707aSArmin Le Grand rIn >> aArray[i]; 18870d3707aSArmin Le Grand } 18970d3707aSArmin Le Grand 19070d3707aSArmin Le Grand Color aColorPix; 19170d3707aSArmin Le Grand Color aColorBack; 19270d3707aSArmin Le Grand 19370d3707aSArmin Le Grand rIn >> aColorPix; 19470d3707aSArmin Le Grand rIn >> aColorBack; 19570d3707aSArmin Le Grand 19670d3707aSArmin Le Grand const Bitmap aBitmap(createHistorical8x8FromArray(aArray, aColorPix, aColorBack)); 19770d3707aSArmin Le Grand 19870d3707aSArmin Le Grand maGraphicObject = Graphic(aBitmap); 19970d3707aSArmin Le Grand } 20070d3707aSArmin Le Grand } 20170d3707aSArmin Le Grand else if(2 == nVer) 20270d3707aSArmin Le Grand { 20370d3707aSArmin Le Grand BitmapEx aBmpEx; 204cdf0e10cSrcweir 20545fd3b9aSArmin Le Grand ReadDIBBitmapEx(aBmpEx, rIn); 20670d3707aSArmin Le Grand maGraphicObject = Graphic(aBmpEx); 20770d3707aSArmin Le Grand } 20870d3707aSArmin Le Grand } 209cdf0e10cSrcweir } 210cdf0e10cSrcweir 21170d3707aSArmin Le Grand ////////////////////////////////////////////////////////////////////////////// 212cdf0e10cSrcweir 21370d3707aSArmin Le Grand XFillBitmapItem::XFillBitmapItem(SfxItemPool* /*pPool*/, const GraphicObject& rGraphicObject) 21470d3707aSArmin Le Grand : NameOrIndex( XATTR_FILLBITMAP, -1), 21570d3707aSArmin Le Grand maGraphicObject(rGraphicObject) 216cdf0e10cSrcweir { 217cdf0e10cSrcweir } 218cdf0e10cSrcweir 21970d3707aSArmin Le Grand ////////////////////////////////////////////////////////////////////////////// 220cdf0e10cSrcweir 22170d3707aSArmin Le Grand XFillBitmapItem::XFillBitmapItem(SfxItemPool* /*pPool*/) 22270d3707aSArmin Le Grand : NameOrIndex(XATTR_FILLBITMAP, -1), 22370d3707aSArmin Le Grand maGraphicObject() 224cdf0e10cSrcweir { 225cdf0e10cSrcweir } 226cdf0e10cSrcweir 22770d3707aSArmin Le Grand ////////////////////////////////////////////////////////////////////////////// 228cdf0e10cSrcweir 229cdf0e10cSrcweir SfxPoolItem* XFillBitmapItem::Clone(SfxItemPool* /*pPool*/) const 230cdf0e10cSrcweir { 231cdf0e10cSrcweir return new XFillBitmapItem(*this); 232cdf0e10cSrcweir } 233cdf0e10cSrcweir 23470d3707aSArmin Le Grand ////////////////////////////////////////////////////////////////////////////// 235cdf0e10cSrcweir 236cdf0e10cSrcweir int XFillBitmapItem::operator==(const SfxPoolItem& rItem) const 237cdf0e10cSrcweir { 23870d3707aSArmin Le Grand return (NameOrIndex::operator==(rItem) 23970d3707aSArmin Le Grand && maGraphicObject == ((const XFillBitmapItem&)rItem).maGraphicObject); 240cdf0e10cSrcweir } 241cdf0e10cSrcweir 24270d3707aSArmin Le Grand ////////////////////////////////////////////////////////////////////////////// 243cdf0e10cSrcweir 244cdf0e10cSrcweir SfxPoolItem* XFillBitmapItem::Create(SvStream& rIn, sal_uInt16 nVer) const 245cdf0e10cSrcweir { 246cdf0e10cSrcweir return new XFillBitmapItem( rIn, nVer ); 247cdf0e10cSrcweir } 248cdf0e10cSrcweir 24970d3707aSArmin Le Grand ////////////////////////////////////////////////////////////////////////////// 250cdf0e10cSrcweir 251cdf0e10cSrcweir SvStream& XFillBitmapItem::Store( SvStream& rOut, sal_uInt16 nItemVersion ) const 252cdf0e10cSrcweir { 25370d3707aSArmin Le Grand NameOrIndex::Store(rOut, nItemVersion); 254cdf0e10cSrcweir 25570d3707aSArmin Le Grand if(!IsIndex()) 256cdf0e10cSrcweir { 25745fd3b9aSArmin Le Grand WriteDIBBitmapEx(maGraphicObject.GetGraphic().GetBitmapEx(), rOut); 258cdf0e10cSrcweir } 259cdf0e10cSrcweir 260cdf0e10cSrcweir return rOut; 261cdf0e10cSrcweir } 262cdf0e10cSrcweir 26370d3707aSArmin Le Grand ////////////////////////////////////////////////////////////////////////////// 26470d3707aSArmin Le Grand 26570d3707aSArmin Le Grand const GraphicObject& XFillBitmapItem::GetGraphicObject() const 266cdf0e10cSrcweir { 26770d3707aSArmin Le Grand return maGraphicObject; 268cdf0e10cSrcweir } 269cdf0e10cSrcweir 27070d3707aSArmin Le Grand ////////////////////////////////////////////////////////////////////////////// 27170d3707aSArmin Le Grand 27270d3707aSArmin Le Grand void XFillBitmapItem::SetGraphicObject(const GraphicObject& rGraphicObject) 27370d3707aSArmin Le Grand { 27470d3707aSArmin Le Grand maGraphicObject = rGraphicObject; 27570d3707aSArmin Le Grand } 276cdf0e10cSrcweir 27770d3707aSArmin Le Grand ////////////////////////////////////////////////////////////////////////////// 278cdf0e10cSrcweir 27970d3707aSArmin Le Grand sal_uInt16 XFillBitmapItem::GetVersion(sal_uInt16 /*nFileFormatVersion*/) const 280cdf0e10cSrcweir { 28170d3707aSArmin Le Grand // version three 28270d3707aSArmin Le Grand return(2); 283cdf0e10cSrcweir } 284cdf0e10cSrcweir 28570d3707aSArmin Le Grand ////////////////////////////////////////////////////////////////////////////// 286cdf0e10cSrcweir 28770d3707aSArmin Le Grand SfxItemPresentation XFillBitmapItem::GetPresentation( 288cdf0e10cSrcweir SfxItemPresentation ePres, 28970d3707aSArmin Le Grand SfxMapUnit /*eCoreUnit*/, 29070d3707aSArmin Le Grand SfxMapUnit /*ePresUnit*/, 29170d3707aSArmin Le Grand XubString& rText, 29270d3707aSArmin Le Grand const IntlWrapper*) const 293cdf0e10cSrcweir { 29470d3707aSArmin Le Grand switch (ePres) 295cdf0e10cSrcweir { 296cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NONE: 297cdf0e10cSrcweir rText.Erase(); 298cdf0e10cSrcweir return ePres; 299cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NAMELESS: 300cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_COMPLETE: 301cdf0e10cSrcweir rText += GetName(); 302cdf0e10cSrcweir return ePres; 303cdf0e10cSrcweir default: 304cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NONE; 305cdf0e10cSrcweir } 306cdf0e10cSrcweir } 307cdf0e10cSrcweir 30870d3707aSArmin Le Grand ////////////////////////////////////////////////////////////////////////////// 309cdf0e10cSrcweir 31070d3707aSArmin Le Grand sal_Bool XFillBitmapItem::QueryValue(::com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId) const 311cdf0e10cSrcweir { 312cdf0e10cSrcweir nMemberId &= ~CONVERT_TWIPS; 313cdf0e10cSrcweir 314cdf0e10cSrcweir // needed for MID_NAME 315cdf0e10cSrcweir ::rtl::OUString aApiName; 316cdf0e10cSrcweir // needed for complete item (MID 0) 317cdf0e10cSrcweir ::rtl::OUString aInternalName; 318cdf0e10cSrcweir 319cdf0e10cSrcweir ::rtl::OUString aURL; 320cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap > xBmp; 321cdf0e10cSrcweir 322cdf0e10cSrcweir if( nMemberId == MID_NAME ) 323cdf0e10cSrcweir { 324cdf0e10cSrcweir SvxUnogetApiNameForItem( Which(), GetName(), aApiName ); 325cdf0e10cSrcweir } 326cdf0e10cSrcweir else if( nMemberId == 0 ) 327cdf0e10cSrcweir { 328cdf0e10cSrcweir aInternalName = GetName(); 329cdf0e10cSrcweir } 330cdf0e10cSrcweir 331cdf0e10cSrcweir if( nMemberId == MID_GRAFURL || 332cdf0e10cSrcweir nMemberId == 0 ) 333cdf0e10cSrcweir { 33470d3707aSArmin Le Grand aURL = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX)); 33570d3707aSArmin Le Grand aURL += ::rtl::OUString::createFromAscii(GetGraphicObject().GetUniqueID().GetBuffer() ); 336cdf0e10cSrcweir } 337cdf0e10cSrcweir if( nMemberId == MID_BITMAP || 338cdf0e10cSrcweir nMemberId == 0 ) 339cdf0e10cSrcweir { 34070d3707aSArmin Le Grand xBmp.set(VCLUnoHelper::CreateBitmap(GetGraphicObject().GetGraphic().GetBitmapEx())); 341cdf0e10cSrcweir } 342cdf0e10cSrcweir 343cdf0e10cSrcweir if( nMemberId == MID_NAME ) 344cdf0e10cSrcweir rVal <<= aApiName; 345cdf0e10cSrcweir else if( nMemberId == MID_GRAFURL ) 346cdf0e10cSrcweir rVal <<= aURL; 347cdf0e10cSrcweir else if( nMemberId == MID_BITMAP ) 348cdf0e10cSrcweir rVal <<= xBmp; 349cdf0e10cSrcweir else 350cdf0e10cSrcweir { 351cdf0e10cSrcweir // member-id 0 => complete item (e.g. for toolbars) 352cdf0e10cSrcweir DBG_ASSERT( nMemberId == 0, "invalid member-id" ); 353cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aPropSeq( 3 ); 354cdf0e10cSrcweir 355cdf0e10cSrcweir aPropSeq[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" )); 356cdf0e10cSrcweir aPropSeq[0].Value = uno::makeAny( aInternalName ); 357cdf0e10cSrcweir aPropSeq[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillBitmapURL" )); 358cdf0e10cSrcweir aPropSeq[1].Value = uno::makeAny( aURL ); 359cdf0e10cSrcweir aPropSeq[2].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Bitmap" )); 360cdf0e10cSrcweir aPropSeq[2].Value = uno::makeAny( xBmp ); 361cdf0e10cSrcweir 362cdf0e10cSrcweir rVal <<= aPropSeq; 363cdf0e10cSrcweir } 364cdf0e10cSrcweir 365cdf0e10cSrcweir return sal_True; 366cdf0e10cSrcweir } 367cdf0e10cSrcweir 36870d3707aSArmin Le Grand ////////////////////////////////////////////////////////////////////////////// 369cdf0e10cSrcweir 370cdf0e10cSrcweir sal_Bool XFillBitmapItem::PutValue( const ::com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId ) 371cdf0e10cSrcweir { 372cdf0e10cSrcweir nMemberId &= ~CONVERT_TWIPS; 373cdf0e10cSrcweir 374cdf0e10cSrcweir ::rtl::OUString aName; 375cdf0e10cSrcweir ::rtl::OUString aURL; 376cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap > xBmp; 377cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > xGraphic; 378cdf0e10cSrcweir 379cdf0e10cSrcweir bool bSetName = false; 380cdf0e10cSrcweir bool bSetURL = false; 381cdf0e10cSrcweir bool bSetBitmap = false; 382cdf0e10cSrcweir 383cdf0e10cSrcweir if( nMemberId == MID_NAME ) 384cdf0e10cSrcweir bSetName = (rVal >>= aName); 385cdf0e10cSrcweir else if( nMemberId == MID_GRAFURL ) 386cdf0e10cSrcweir bSetURL = (rVal >>= aURL); 387cdf0e10cSrcweir else if( nMemberId == MID_BITMAP ) 388cdf0e10cSrcweir { 389cdf0e10cSrcweir bSetBitmap = (rVal >>= xBmp); 390cdf0e10cSrcweir if ( !bSetBitmap ) 391cdf0e10cSrcweir bSetBitmap = (rVal >>= xGraphic ); 392cdf0e10cSrcweir } 393cdf0e10cSrcweir else 394cdf0e10cSrcweir { 395cdf0e10cSrcweir DBG_ASSERT( nMemberId == 0, "invalid member-id" ); 396cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aPropSeq; 397cdf0e10cSrcweir if( rVal >>= aPropSeq ) 398cdf0e10cSrcweir { 399cdf0e10cSrcweir for ( sal_Int32 n = 0; n < aPropSeq.getLength(); n++ ) 400cdf0e10cSrcweir { 401cdf0e10cSrcweir if( aPropSeq[n].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Name" ))) 402cdf0e10cSrcweir bSetName = (aPropSeq[n].Value >>= aName); 403cdf0e10cSrcweir else if( aPropSeq[n].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "FillBitmapURL" ))) 404cdf0e10cSrcweir bSetURL = (aPropSeq[n].Value >>= aURL); 405cdf0e10cSrcweir else if( aPropSeq[n].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Bitmap" ))) 406cdf0e10cSrcweir bSetBitmap = (aPropSeq[n].Value >>= xBmp); 407cdf0e10cSrcweir } 408cdf0e10cSrcweir } 409cdf0e10cSrcweir } 410cdf0e10cSrcweir 411cdf0e10cSrcweir if( bSetName ) 412cdf0e10cSrcweir { 413cdf0e10cSrcweir SetName( aName ); 414cdf0e10cSrcweir } 415cdf0e10cSrcweir if( bSetURL ) 416cdf0e10cSrcweir { 41770d3707aSArmin Le Grand maGraphicObject = GraphicObject::CreateGraphicObjectFromURL(aURL); 418035a2f44SArmin Le Grand 419035a2f44SArmin Le Grand // #121194# Prefer GraphicObject over bitmap object if both are provided 420035a2f44SArmin Le Grand if(bSetBitmap && GRAPHIC_NONE != maGraphicObject.GetType()) 421035a2f44SArmin Le Grand { 422035a2f44SArmin Le Grand bSetBitmap = false; 423035a2f44SArmin Le Grand } 424cdf0e10cSrcweir } 425cdf0e10cSrcweir if( bSetBitmap ) 426cdf0e10cSrcweir { 42770d3707aSArmin Le Grand if(xBmp.is()) 428cdf0e10cSrcweir { 42970d3707aSArmin Le Grand maGraphicObject = Graphic(VCLUnoHelper::GetBitmap(xBmp)); 430cdf0e10cSrcweir } 43170d3707aSArmin Le Grand else if(xGraphic.is()) 432cdf0e10cSrcweir { 43370d3707aSArmin Le Grand maGraphicObject = Graphic(xGraphic); 434cdf0e10cSrcweir } 435cdf0e10cSrcweir } 436cdf0e10cSrcweir 437cdf0e10cSrcweir return (bSetName || bSetURL || bSetBitmap); 438cdf0e10cSrcweir } 439cdf0e10cSrcweir 44070d3707aSArmin Le Grand ////////////////////////////////////////////////////////////////////////////// 44170d3707aSArmin Le Grand 442cdf0e10cSrcweir sal_Bool XFillBitmapItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 ) 443cdf0e10cSrcweir { 44470d3707aSArmin Le Grand const GraphicObject& aGraphicObjectA(((XFillBitmapItem*)p1)->GetGraphicObject()); 44570d3707aSArmin Le Grand const GraphicObject& aGraphicObjectB(((XFillBitmapItem*)p2)->GetGraphicObject()); 44670d3707aSArmin Le Grand 44770d3707aSArmin Le Grand return aGraphicObjectA == aGraphicObjectB; 448cdf0e10cSrcweir } 449cdf0e10cSrcweir 45070d3707aSArmin Le Grand ////////////////////////////////////////////////////////////////////////////// 45170d3707aSArmin Le Grand 452cdf0e10cSrcweir XFillBitmapItem* XFillBitmapItem::checkForUniqueItem( SdrModel* pModel ) const 453cdf0e10cSrcweir { 454cdf0e10cSrcweir if( pModel ) 455cdf0e10cSrcweir { 456cdf0e10cSrcweir const String aUniqueName = NameOrIndex::CheckNamedItem( this, 457cdf0e10cSrcweir XATTR_FILLBITMAP, 458cdf0e10cSrcweir &pModel->GetItemPool(), 459cdf0e10cSrcweir pModel->GetStyleSheetPool() ? &pModel->GetStyleSheetPool()->GetPool() : NULL, 460cdf0e10cSrcweir XFillBitmapItem::CompareValueFunc, 461cdf0e10cSrcweir RID_SVXSTR_BMP21, 462c7be74b1SArmin Le Grand pModel->GetBitmapListFromSdrModel().get() ); 463cdf0e10cSrcweir 464cdf0e10cSrcweir // if the given name is not valid, replace it! 465cdf0e10cSrcweir if( aUniqueName != GetName() ) 466cdf0e10cSrcweir { 46770d3707aSArmin Le Grand return new XFillBitmapItem(aUniqueName, maGraphicObject); 468cdf0e10cSrcweir } 469cdf0e10cSrcweir } 470cdf0e10cSrcweir 471cdf0e10cSrcweir return (XFillBitmapItem*)this; 472cdf0e10cSrcweir } 47370d3707aSArmin Le Grand 47470d3707aSArmin Le Grand ////////////////////////////////////////////////////////////////////////////// 47570d3707aSArmin Le Grand // eof 476