1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_svx.hxx" 30*cdf0e10cSrcweir #include <com/sun/star/awt/XBitmap.hpp> 31*cdf0e10cSrcweir #include <com/sun/star/graphic/XGraphic.hpp> 32*cdf0e10cSrcweir #include <tools/stream.hxx> 33*cdf0e10cSrcweir #include <vcl/window.hxx> 34*cdf0e10cSrcweir #include <vcl/virdev.hxx> 35*cdf0e10cSrcweir #include <vcl/bitmapex.hxx> 36*cdf0e10cSrcweir #include <toolkit/unohlp.hxx> 37*cdf0e10cSrcweir #include <svl/style.hxx> 38*cdf0e10cSrcweir #include <editeng/memberids.hrc> 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir #include <svx/dialogs.hrc> 41*cdf0e10cSrcweir #include "svx/xattr.hxx" 42*cdf0e10cSrcweir #include <svx/xtable.hxx> 43*cdf0e10cSrcweir #include <svx/xdef.hxx> 44*cdf0e10cSrcweir #include <svx/unomid.hxx> 45*cdf0e10cSrcweir #include <editeng/unoprnms.hxx> 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir #include "svx/unoapi.hxx" 48*cdf0e10cSrcweir #include <svx/svdmodel.hxx> 49*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir #define GLOBALOVERFLOW 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir using namespace ::com::sun::star; 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir // --------------- 56*cdf0e10cSrcweir // class XOBitmap 57*cdf0e10cSrcweir // --------------- 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir /************************************************************************* 60*cdf0e10cSrcweir |* 61*cdf0e10cSrcweir |* XOBitmap::XOBitmap() 62*cdf0e10cSrcweir |* 63*cdf0e10cSrcweir |* Beschreibung 64*cdf0e10cSrcweir |* Ersterstellung 27.07.95 65*cdf0e10cSrcweir |* Letzte Aenderung 27.07.95 66*cdf0e10cSrcweir |* 67*cdf0e10cSrcweir *************************************************************************/ 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir XOBitmap::XOBitmap() : 70*cdf0e10cSrcweir eType ( XBITMAP_NONE ), 71*cdf0e10cSrcweir eStyle ( XBITMAP_STRETCH ), 72*cdf0e10cSrcweir pPixelArray ( NULL ), 73*cdf0e10cSrcweir bGraphicDirty ( sal_False ) 74*cdf0e10cSrcweir { 75*cdf0e10cSrcweir } 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir /************************************************************************* 78*cdf0e10cSrcweir |* 79*cdf0e10cSrcweir |* XOBitmap::XOBitmap( Bitmap aBitmap, XBitmapStyle eStyle = XBITMAP_TILE ) 80*cdf0e10cSrcweir |* 81*cdf0e10cSrcweir |* Beschreibung 82*cdf0e10cSrcweir |* Ersterstellung 26.07.95 83*cdf0e10cSrcweir |* Letzte Aenderung 26.07.95 84*cdf0e10cSrcweir |* 85*cdf0e10cSrcweir *************************************************************************/ 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir XOBitmap::XOBitmap( const Bitmap& rBmp, XBitmapStyle eInStyle ) : 88*cdf0e10cSrcweir eType ( XBITMAP_IMPORT ), 89*cdf0e10cSrcweir eStyle ( eInStyle ), 90*cdf0e10cSrcweir aGraphicObject ( rBmp ), 91*cdf0e10cSrcweir pPixelArray ( NULL ), 92*cdf0e10cSrcweir bGraphicDirty ( sal_False ) 93*cdf0e10cSrcweir { 94*cdf0e10cSrcweir } 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir /************************************************************************* 97*cdf0e10cSrcweir |* 98*cdf0e10cSrcweir |* XOBitmap::XOBitmap( Bitmap aBitmap, XBitmapStyle eStyle = XBITMAP_TILE ) 99*cdf0e10cSrcweir |* 100*cdf0e10cSrcweir |* Beschreibung 101*cdf0e10cSrcweir |* Ersterstellung 26.07.95 102*cdf0e10cSrcweir |* Letzte Aenderung 26.07.95 103*cdf0e10cSrcweir |* 104*cdf0e10cSrcweir *************************************************************************/ 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir XOBitmap::XOBitmap( const GraphicObject& rGraphicObject, XBitmapStyle eInStyle ) : 107*cdf0e10cSrcweir eType ( XBITMAP_IMPORT ), 108*cdf0e10cSrcweir eStyle ( eInStyle ), 109*cdf0e10cSrcweir aGraphicObject ( rGraphicObject ), 110*cdf0e10cSrcweir pPixelArray ( NULL ), 111*cdf0e10cSrcweir bGraphicDirty ( sal_False ) 112*cdf0e10cSrcweir { 113*cdf0e10cSrcweir } 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir /************************************************************************* 116*cdf0e10cSrcweir |* 117*cdf0e10cSrcweir |* XOBitmap::XOBitmap( sal_uInt16* pArray, const Color& aPixelColor, 118*cdf0e10cSrcweir |* const Color& aBckgrColor, const Size& rSize = Size( 8, 8 ), 119*cdf0e10cSrcweir |* XBitmapStyle eStyle = XBITMAP_TILE ) 120*cdf0e10cSrcweir |* 121*cdf0e10cSrcweir |* Beschreibung 122*cdf0e10cSrcweir |* Ersterstellung 26.07.95 123*cdf0e10cSrcweir |* Letzte Aenderung 26.07.95 124*cdf0e10cSrcweir |* 125*cdf0e10cSrcweir *************************************************************************/ 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir XOBitmap::XOBitmap( const sal_uInt16* pArray, const Color& rPixelColor, 128*cdf0e10cSrcweir const Color& rBckgrColor, const Size& rSize, 129*cdf0e10cSrcweir XBitmapStyle eInStyle ) : 130*cdf0e10cSrcweir eStyle ( eInStyle ), 131*cdf0e10cSrcweir pPixelArray ( NULL ), 132*cdf0e10cSrcweir aArraySize ( rSize ), 133*cdf0e10cSrcweir aPixelColor ( rPixelColor ), 134*cdf0e10cSrcweir aBckgrColor ( rBckgrColor ), 135*cdf0e10cSrcweir bGraphicDirty ( sal_True ) 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir if( aArraySize.Width() == 8 && aArraySize.Height() == 8 ) 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir eType = XBITMAP_8X8; 141*cdf0e10cSrcweir pPixelArray = new sal_uInt16[ 64 ]; 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir for( sal_uInt16 i = 0; i < 64; i++ ) 144*cdf0e10cSrcweir *( pPixelArray + i ) = *( pArray + i ); 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir else 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir DBG_ASSERT( 0, "Nicht unterstuetzte Bitmapgroesse" ); 149*cdf0e10cSrcweir } 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir /************************************************************************* 153*cdf0e10cSrcweir |* 154*cdf0e10cSrcweir |* XOBitmap::XOBitmap( const XOBitmap& rXBmp ) 155*cdf0e10cSrcweir |* 156*cdf0e10cSrcweir |* Beschreibung 157*cdf0e10cSrcweir |* Ersterstellung 27.07.95 158*cdf0e10cSrcweir |* Letzte Aenderung 27.07.95 159*cdf0e10cSrcweir |* 160*cdf0e10cSrcweir *************************************************************************/ 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir XOBitmap::XOBitmap( const XOBitmap& rXBmp ) : 163*cdf0e10cSrcweir pPixelArray ( NULL ) 164*cdf0e10cSrcweir { 165*cdf0e10cSrcweir eType = rXBmp.eType; 166*cdf0e10cSrcweir eStyle = rXBmp.eStyle; 167*cdf0e10cSrcweir aGraphicObject = rXBmp.aGraphicObject; 168*cdf0e10cSrcweir aArraySize = rXBmp.aArraySize; 169*cdf0e10cSrcweir aPixelColor = rXBmp.aPixelColor; 170*cdf0e10cSrcweir aBckgrColor = rXBmp.aBckgrColor; 171*cdf0e10cSrcweir bGraphicDirty = rXBmp.bGraphicDirty; 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir if( rXBmp.pPixelArray ) 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir if( eType == XBITMAP_8X8 ) 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir pPixelArray = new sal_uInt16[ 64 ]; 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir for( sal_uInt16 i = 0; i < 64; i++ ) 180*cdf0e10cSrcweir *( pPixelArray + i ) = *( rXBmp.pPixelArray + i ); 181*cdf0e10cSrcweir } 182*cdf0e10cSrcweir } 183*cdf0e10cSrcweir } 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir /************************************************************************* 186*cdf0e10cSrcweir |* 187*cdf0e10cSrcweir |* XOBitmap::XOBitmap( Bitmap aBitmap, XBitmapStyle eStyle = XBITMAP_TILE ) 188*cdf0e10cSrcweir |* 189*cdf0e10cSrcweir |* Beschreibung 190*cdf0e10cSrcweir |* Ersterstellung 26.07.95 191*cdf0e10cSrcweir |* Letzte Aenderung 26.07.95 192*cdf0e10cSrcweir |* 193*cdf0e10cSrcweir *************************************************************************/ 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir XOBitmap::~XOBitmap() 196*cdf0e10cSrcweir { 197*cdf0e10cSrcweir if( pPixelArray ) 198*cdf0e10cSrcweir delete []pPixelArray; 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir /************************************************************************* 202*cdf0e10cSrcweir |* 203*cdf0e10cSrcweir |* XOBitmap& XOBitmap::operator=( const XOBitmap& rXBmp ) 204*cdf0e10cSrcweir |* 205*cdf0e10cSrcweir |* Beschreibung 206*cdf0e10cSrcweir |* Ersterstellung 27.07.95 207*cdf0e10cSrcweir |* Letzte Aenderung 27.07.95 208*cdf0e10cSrcweir |* 209*cdf0e10cSrcweir *************************************************************************/ 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir XOBitmap& XOBitmap::operator=( const XOBitmap& rXBmp ) 212*cdf0e10cSrcweir { 213*cdf0e10cSrcweir eType = rXBmp.eType; 214*cdf0e10cSrcweir eStyle = rXBmp.eStyle; 215*cdf0e10cSrcweir aGraphicObject = rXBmp.aGraphicObject; 216*cdf0e10cSrcweir aArraySize = rXBmp.aArraySize; 217*cdf0e10cSrcweir aPixelColor = rXBmp.aPixelColor; 218*cdf0e10cSrcweir aBckgrColor = rXBmp.aBckgrColor; 219*cdf0e10cSrcweir bGraphicDirty = rXBmp.bGraphicDirty; 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir if( rXBmp.pPixelArray ) 222*cdf0e10cSrcweir { 223*cdf0e10cSrcweir if( eType == XBITMAP_8X8 ) 224*cdf0e10cSrcweir { 225*cdf0e10cSrcweir pPixelArray = new sal_uInt16[ 64 ]; 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir for( sal_uInt16 i = 0; i < 64; i++ ) 228*cdf0e10cSrcweir *( pPixelArray + i ) = *( rXBmp.pPixelArray + i ); 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir } 231*cdf0e10cSrcweir return( *this ); 232*cdf0e10cSrcweir } 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir /************************************************************************* 235*cdf0e10cSrcweir |* 236*cdf0e10cSrcweir |* int XOBitmap::operator==( const XOBitmap& rXOBitmap ) const 237*cdf0e10cSrcweir |* 238*cdf0e10cSrcweir |* Beschreibung 239*cdf0e10cSrcweir |* Ersterstellung 26.07.95 240*cdf0e10cSrcweir |* Letzte Aenderung 26.07.95 241*cdf0e10cSrcweir |* 242*cdf0e10cSrcweir *************************************************************************/ 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir int XOBitmap::operator==( const XOBitmap& rXOBitmap ) const 245*cdf0e10cSrcweir { 246*cdf0e10cSrcweir if( eType != rXOBitmap.eType || 247*cdf0e10cSrcweir eStyle != rXOBitmap.eStyle || 248*cdf0e10cSrcweir aGraphicObject != rXOBitmap.aGraphicObject || 249*cdf0e10cSrcweir aArraySize != rXOBitmap.aArraySize || 250*cdf0e10cSrcweir aPixelColor != rXOBitmap.aPixelColor || 251*cdf0e10cSrcweir aBckgrColor != rXOBitmap.aBckgrColor || 252*cdf0e10cSrcweir bGraphicDirty != rXOBitmap.bGraphicDirty ) 253*cdf0e10cSrcweir { 254*cdf0e10cSrcweir return( sal_False ); 255*cdf0e10cSrcweir } 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir if( pPixelArray && rXOBitmap.pPixelArray ) 258*cdf0e10cSrcweir { 259*cdf0e10cSrcweir sal_uInt16 nCount = (sal_uInt16) ( aArraySize.Width() * aArraySize.Height() ); 260*cdf0e10cSrcweir for( sal_uInt16 i = 0; i < nCount; i++ ) 261*cdf0e10cSrcweir { 262*cdf0e10cSrcweir if( *( pPixelArray + i ) != *( rXOBitmap.pPixelArray + i ) ) 263*cdf0e10cSrcweir return( sal_False ); 264*cdf0e10cSrcweir } 265*cdf0e10cSrcweir } 266*cdf0e10cSrcweir return( sal_True ); 267*cdf0e10cSrcweir } 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir /************************************************************************* 270*cdf0e10cSrcweir |* 271*cdf0e10cSrcweir |* void SetPixelArray( const sal_uInt16* pArray ) 272*cdf0e10cSrcweir |* 273*cdf0e10cSrcweir |* Beschreibung 274*cdf0e10cSrcweir |* Ersterstellung 27.07.95 275*cdf0e10cSrcweir |* Letzte Aenderung 27.07.95 276*cdf0e10cSrcweir |* 277*cdf0e10cSrcweir *************************************************************************/ 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir void XOBitmap::SetPixelArray( const sal_uInt16* pArray ) 280*cdf0e10cSrcweir { 281*cdf0e10cSrcweir if( eType == XBITMAP_8X8 ) 282*cdf0e10cSrcweir { 283*cdf0e10cSrcweir if( pPixelArray ) 284*cdf0e10cSrcweir delete []pPixelArray; 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir pPixelArray = new sal_uInt16[ 64 ]; 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir for( sal_uInt16 i = 0; i < 64; i++ ) 289*cdf0e10cSrcweir *( pPixelArray + i ) = *( pArray + i ); 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir bGraphicDirty = sal_True; 292*cdf0e10cSrcweir } 293*cdf0e10cSrcweir else 294*cdf0e10cSrcweir { 295*cdf0e10cSrcweir DBG_ASSERT( 0, "Nicht unterstuetzter Bitmaptyp" ); 296*cdf0e10cSrcweir } 297*cdf0e10cSrcweir } 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir /************************************************************************* 300*cdf0e10cSrcweir |* 301*cdf0e10cSrcweir |* Bitmap XOBitmap::GetBitmap() 302*cdf0e10cSrcweir |* 303*cdf0e10cSrcweir |* Beschreibung 304*cdf0e10cSrcweir |* Ersterstellung 26.07.95 305*cdf0e10cSrcweir |* Letzte Aenderung 26.07.95 306*cdf0e10cSrcweir |* 307*cdf0e10cSrcweir *************************************************************************/ 308*cdf0e10cSrcweir 309*cdf0e10cSrcweir Bitmap XOBitmap::GetBitmap() const 310*cdf0e10cSrcweir { 311*cdf0e10cSrcweir return GetGraphicObject().GetGraphic().GetBitmap(); 312*cdf0e10cSrcweir } 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir /************************************************************************* 315*cdf0e10cSrcweir |* 316*cdf0e10cSrcweir |* Bitmap XOBitmap::GetGraphicObject() 317*cdf0e10cSrcweir |* 318*cdf0e10cSrcweir |* Beschreibung 319*cdf0e10cSrcweir |* Ersterstellung 320*cdf0e10cSrcweir |* Letzte Aenderung 321*cdf0e10cSrcweir |* 322*cdf0e10cSrcweir *************************************************************************/ 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir const GraphicObject& XOBitmap::GetGraphicObject() const 325*cdf0e10cSrcweir { 326*cdf0e10cSrcweir if( bGraphicDirty ) 327*cdf0e10cSrcweir ( (XOBitmap*) this )->Array2Bitmap(); 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir return aGraphicObject; 330*cdf0e10cSrcweir } 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir /************************************************************************* 333*cdf0e10cSrcweir |* 334*cdf0e10cSrcweir |* void XOBitmap::Bitmap2Array() 335*cdf0e10cSrcweir |* 336*cdf0e10cSrcweir |* Beschreibung Umwandlung der Bitmap in Array, Hinter- u. 337*cdf0e10cSrcweir |* Vordergrundfarbe 338*cdf0e10cSrcweir |* Ersterstellung 27.07.95 339*cdf0e10cSrcweir |* Letzte Aenderung 27.07.95 340*cdf0e10cSrcweir |* 341*cdf0e10cSrcweir *************************************************************************/ 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir void XOBitmap::Bitmap2Array() 344*cdf0e10cSrcweir { 345*cdf0e10cSrcweir VirtualDevice aVD; 346*cdf0e10cSrcweir sal_Bool bPixelColor = sal_False; 347*cdf0e10cSrcweir const Bitmap aBitmap( GetBitmap() ); 348*cdf0e10cSrcweir const sal_uInt16 nLines = 8; // von Type abhaengig 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir if( !pPixelArray ) 351*cdf0e10cSrcweir pPixelArray = new sal_uInt16[ nLines * nLines ]; 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir aVD.SetOutputSizePixel( aBitmap.GetSizePixel() ); 354*cdf0e10cSrcweir aVD.DrawBitmap( Point(), aBitmap ); 355*cdf0e10cSrcweir aPixelColor = aBckgrColor = aVD.GetPixel( Point() ); 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir // Aufbau des Arrays und Ermittlung der Vorder-, bzw. 358*cdf0e10cSrcweir // Hintergrundfarbe 359*cdf0e10cSrcweir for( sal_uInt16 i = 0; i < nLines; i++ ) 360*cdf0e10cSrcweir { 361*cdf0e10cSrcweir for( sal_uInt16 j = 0; j < nLines; j++ ) 362*cdf0e10cSrcweir { 363*cdf0e10cSrcweir if ( aVD.GetPixel( Point( j, i ) ) == aBckgrColor ) 364*cdf0e10cSrcweir *( pPixelArray + j + i * nLines ) = 0; 365*cdf0e10cSrcweir else 366*cdf0e10cSrcweir { 367*cdf0e10cSrcweir *( pPixelArray + j + i * nLines ) = 1; 368*cdf0e10cSrcweir if( !bPixelColor ) 369*cdf0e10cSrcweir { 370*cdf0e10cSrcweir aPixelColor = aVD.GetPixel( Point( j, i ) ); 371*cdf0e10cSrcweir bPixelColor = sal_True; 372*cdf0e10cSrcweir } 373*cdf0e10cSrcweir } 374*cdf0e10cSrcweir } 375*cdf0e10cSrcweir } 376*cdf0e10cSrcweir } 377*cdf0e10cSrcweir 378*cdf0e10cSrcweir /************************************************************************* 379*cdf0e10cSrcweir |* 380*cdf0e10cSrcweir |* void XOBitmap::Array2Bitmap() 381*cdf0e10cSrcweir |* 382*cdf0e10cSrcweir |* Beschreibung Umwandlung des Arrays, Hinter- u. 383*cdf0e10cSrcweir |* Vordergrundfarbe in eine Bitmap 384*cdf0e10cSrcweir |* Ersterstellung 27.07.95 385*cdf0e10cSrcweir |* Letzte Aenderung 27.07.95 386*cdf0e10cSrcweir |* 387*cdf0e10cSrcweir *************************************************************************/ 388*cdf0e10cSrcweir 389*cdf0e10cSrcweir void XOBitmap::Array2Bitmap() 390*cdf0e10cSrcweir { 391*cdf0e10cSrcweir VirtualDevice aVD; 392*cdf0e10cSrcweir sal_uInt16 nLines = 8; // von Type abhaengig 393*cdf0e10cSrcweir 394*cdf0e10cSrcweir if( !pPixelArray ) 395*cdf0e10cSrcweir return; 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir aVD.SetOutputSizePixel( Size( nLines, nLines ) ); 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir // Aufbau der Bitmap 400*cdf0e10cSrcweir for( sal_uInt16 i = 0; i < nLines; i++ ) 401*cdf0e10cSrcweir { 402*cdf0e10cSrcweir for( sal_uInt16 j = 0; j < nLines; j++ ) 403*cdf0e10cSrcweir { 404*cdf0e10cSrcweir if( *( pPixelArray + j + i * nLines ) == 0 ) 405*cdf0e10cSrcweir aVD.DrawPixel( Point( j, i ), aBckgrColor ); 406*cdf0e10cSrcweir else 407*cdf0e10cSrcweir aVD.DrawPixel( Point( j, i ), aPixelColor ); 408*cdf0e10cSrcweir } 409*cdf0e10cSrcweir } 410*cdf0e10cSrcweir 411*cdf0e10cSrcweir aGraphicObject = GraphicObject( aVD.GetBitmap( Point(), Size( nLines, nLines ) ) ); 412*cdf0e10cSrcweir bGraphicDirty = sal_False; 413*cdf0e10cSrcweir } 414*cdf0e10cSrcweir 415*cdf0e10cSrcweir // ----------------------- 416*cdf0e10cSrcweir // class XFillBitmapItem 417*cdf0e10cSrcweir // ----------------------- 418*cdf0e10cSrcweir TYPEINIT1_AUTOFACTORY(XFillBitmapItem, NameOrIndex); 419*cdf0e10cSrcweir 420*cdf0e10cSrcweir /************************************************************************* 421*cdf0e10cSrcweir |* 422*cdf0e10cSrcweir |* XFillBitmapItem::XFillBitmapItem(long nIndex, 423*cdf0e10cSrcweir |* const Bitmap& rTheBitmap) 424*cdf0e10cSrcweir |* 425*cdf0e10cSrcweir |* Beschreibung 426*cdf0e10cSrcweir |* Ersterstellung 17.11.94 427*cdf0e10cSrcweir |* Letzte Aenderung 17.11.94 428*cdf0e10cSrcweir |* 429*cdf0e10cSrcweir *************************************************************************/ 430*cdf0e10cSrcweir 431*cdf0e10cSrcweir XFillBitmapItem::XFillBitmapItem(long nIndex, 432*cdf0e10cSrcweir const XOBitmap& rTheBitmap) : 433*cdf0e10cSrcweir NameOrIndex( XATTR_FILLBITMAP, nIndex ), 434*cdf0e10cSrcweir aXOBitmap( rTheBitmap ) 435*cdf0e10cSrcweir { 436*cdf0e10cSrcweir } 437*cdf0e10cSrcweir 438*cdf0e10cSrcweir /************************************************************************* 439*cdf0e10cSrcweir |* 440*cdf0e10cSrcweir |* XFillBitmapItem::XFillBitmapItem(const XubString& rName, 441*cdf0e10cSrcweir |* const Bitmap& rTheBitmap) 442*cdf0e10cSrcweir |* 443*cdf0e10cSrcweir |* Beschreibung 444*cdf0e10cSrcweir |* Ersterstellung 17.11.94 445*cdf0e10cSrcweir |* Letzte Aenderung 17.11.94 446*cdf0e10cSrcweir |* 447*cdf0e10cSrcweir *************************************************************************/ 448*cdf0e10cSrcweir 449*cdf0e10cSrcweir XFillBitmapItem::XFillBitmapItem(const XubString& rName, 450*cdf0e10cSrcweir const XOBitmap& rTheBitmap) : 451*cdf0e10cSrcweir NameOrIndex( XATTR_FILLBITMAP, rName ), 452*cdf0e10cSrcweir aXOBitmap( rTheBitmap ) 453*cdf0e10cSrcweir { 454*cdf0e10cSrcweir } 455*cdf0e10cSrcweir 456*cdf0e10cSrcweir /************************************************************************* 457*cdf0e10cSrcweir |* 458*cdf0e10cSrcweir |* XFillBitmapItem::XFillBitmapItem(const XFillBitmapItem& rItem) 459*cdf0e10cSrcweir |* 460*cdf0e10cSrcweir |* Beschreibung 461*cdf0e10cSrcweir |* Ersterstellung 17.11.94 462*cdf0e10cSrcweir |* Letzte Aenderung 17.11.94 463*cdf0e10cSrcweir |* 464*cdf0e10cSrcweir *************************************************************************/ 465*cdf0e10cSrcweir 466*cdf0e10cSrcweir XFillBitmapItem::XFillBitmapItem(const XFillBitmapItem& rItem) : 467*cdf0e10cSrcweir NameOrIndex( rItem ), 468*cdf0e10cSrcweir aXOBitmap( rItem.aXOBitmap ) 469*cdf0e10cSrcweir { 470*cdf0e10cSrcweir } 471*cdf0e10cSrcweir 472*cdf0e10cSrcweir /************************************************************************* 473*cdf0e10cSrcweir |* 474*cdf0e10cSrcweir |* XFillBitmapItem::XFillBitmapItem(SvStream& rIn) 475*cdf0e10cSrcweir |* 476*cdf0e10cSrcweir |* Beschreibung 477*cdf0e10cSrcweir |* Ersterstellung 17.11.94 478*cdf0e10cSrcweir |* Letzte Aenderung 26.07.94 479*cdf0e10cSrcweir |* 480*cdf0e10cSrcweir *************************************************************************/ 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir XFillBitmapItem::XFillBitmapItem( SvStream& rIn, sal_uInt16 nVer ) : 483*cdf0e10cSrcweir NameOrIndex( XATTR_FILLBITMAP, rIn ) 484*cdf0e10cSrcweir { 485*cdf0e10cSrcweir if( nVer == 0 ) 486*cdf0e10cSrcweir { 487*cdf0e10cSrcweir if (!IsIndex()) 488*cdf0e10cSrcweir { 489*cdf0e10cSrcweir // Behandlung der alten Bitmaps 490*cdf0e10cSrcweir Bitmap aBmp; 491*cdf0e10cSrcweir 492*cdf0e10cSrcweir rIn >> aBmp; 493*cdf0e10cSrcweir 494*cdf0e10cSrcweir aXOBitmap.SetBitmap( aBmp ); 495*cdf0e10cSrcweir aXOBitmap.SetBitmapStyle( XBITMAP_TILE ); 496*cdf0e10cSrcweir 497*cdf0e10cSrcweir if( aBmp.GetSizePixel().Width() == 8 && 498*cdf0e10cSrcweir aBmp.GetSizePixel().Height() == 8 ) 499*cdf0e10cSrcweir { 500*cdf0e10cSrcweir aXOBitmap.SetBitmapType( XBITMAP_8X8 ); 501*cdf0e10cSrcweir aXOBitmap.Bitmap2Array(); 502*cdf0e10cSrcweir } 503*cdf0e10cSrcweir else 504*cdf0e10cSrcweir aXOBitmap.SetBitmapType( XBITMAP_IMPORT ); 505*cdf0e10cSrcweir } 506*cdf0e10cSrcweir } 507*cdf0e10cSrcweir else if( nVer == 1 ) 508*cdf0e10cSrcweir { 509*cdf0e10cSrcweir if (!IsIndex()) 510*cdf0e10cSrcweir { 511*cdf0e10cSrcweir sal_Int16 iTmp; 512*cdf0e10cSrcweir rIn >> iTmp; 513*cdf0e10cSrcweir aXOBitmap.SetBitmapStyle( (XBitmapStyle) iTmp ); 514*cdf0e10cSrcweir rIn >> iTmp; 515*cdf0e10cSrcweir aXOBitmap.SetBitmapType( (XBitmapType) iTmp ); 516*cdf0e10cSrcweir 517*cdf0e10cSrcweir if( aXOBitmap.GetBitmapType() == XBITMAP_IMPORT ) 518*cdf0e10cSrcweir { 519*cdf0e10cSrcweir Bitmap aBmp; 520*cdf0e10cSrcweir rIn >> aBmp; 521*cdf0e10cSrcweir aXOBitmap.SetBitmap( aBmp ); 522*cdf0e10cSrcweir } 523*cdf0e10cSrcweir else if( aXOBitmap.GetBitmapType() == XBITMAP_8X8 ) 524*cdf0e10cSrcweir { 525*cdf0e10cSrcweir sal_uInt16* pArray = new sal_uInt16[ 64 ]; 526*cdf0e10cSrcweir Color aColor; 527*cdf0e10cSrcweir 528*cdf0e10cSrcweir for( sal_uInt16 i = 0; i < 64; i++ ) 529*cdf0e10cSrcweir rIn >> *( pArray + i ); 530*cdf0e10cSrcweir aXOBitmap.SetPixelArray( pArray ); 531*cdf0e10cSrcweir 532*cdf0e10cSrcweir rIn >> aColor; 533*cdf0e10cSrcweir aXOBitmap.SetPixelColor( aColor ); 534*cdf0e10cSrcweir rIn >> aColor; 535*cdf0e10cSrcweir aXOBitmap.SetBackgroundColor( aColor ); 536*cdf0e10cSrcweir 537*cdf0e10cSrcweir delete []pArray; 538*cdf0e10cSrcweir } 539*cdf0e10cSrcweir } 540*cdf0e10cSrcweir } 541*cdf0e10cSrcweir 542*cdf0e10cSrcweir // #81908# force bitmap to exist 543*cdf0e10cSrcweir aXOBitmap.GetBitmap(); 544*cdf0e10cSrcweir } 545*cdf0e10cSrcweir 546*cdf0e10cSrcweir //************************************************************************* 547*cdf0e10cSrcweir 548*cdf0e10cSrcweir XFillBitmapItem::XFillBitmapItem( SfxItemPool* /*pPool*/, const XOBitmap& rTheBitmap ) 549*cdf0e10cSrcweir : NameOrIndex( XATTR_FILLBITMAP, -1 ), 550*cdf0e10cSrcweir aXOBitmap( rTheBitmap ) 551*cdf0e10cSrcweir { 552*cdf0e10cSrcweir } 553*cdf0e10cSrcweir 554*cdf0e10cSrcweir //************************************************************************* 555*cdf0e10cSrcweir 556*cdf0e10cSrcweir XFillBitmapItem::XFillBitmapItem( SfxItemPool* /*pPool*/) 557*cdf0e10cSrcweir : NameOrIndex(XATTR_FILLBITMAP, -1 ) 558*cdf0e10cSrcweir { 559*cdf0e10cSrcweir } 560*cdf0e10cSrcweir 561*cdf0e10cSrcweir /************************************************************************* 562*cdf0e10cSrcweir |* 563*cdf0e10cSrcweir |* XFillBitmapItem::Clone(SfxItemPool* pPool) const 564*cdf0e10cSrcweir |* 565*cdf0e10cSrcweir |* Beschreibung 566*cdf0e10cSrcweir |* Ersterstellung 17.11.94 567*cdf0e10cSrcweir |* Letzte Aenderung 17.11.94 568*cdf0e10cSrcweir |* 569*cdf0e10cSrcweir *************************************************************************/ 570*cdf0e10cSrcweir 571*cdf0e10cSrcweir SfxPoolItem* XFillBitmapItem::Clone(SfxItemPool* /*pPool*/) const 572*cdf0e10cSrcweir { 573*cdf0e10cSrcweir return new XFillBitmapItem(*this); 574*cdf0e10cSrcweir } 575*cdf0e10cSrcweir 576*cdf0e10cSrcweir /************************************************************************* 577*cdf0e10cSrcweir |* 578*cdf0e10cSrcweir |* int XFillBitmapItem::operator==(const SfxPoolItem& rItem) const 579*cdf0e10cSrcweir |* 580*cdf0e10cSrcweir |* Beschreibung 581*cdf0e10cSrcweir |* Ersterstellung 17.11.94 582*cdf0e10cSrcweir |* Letzte Aenderung 26.07.95 583*cdf0e10cSrcweir |* 584*cdf0e10cSrcweir *************************************************************************/ 585*cdf0e10cSrcweir 586*cdf0e10cSrcweir int XFillBitmapItem::operator==(const SfxPoolItem& rItem) const 587*cdf0e10cSrcweir { 588*cdf0e10cSrcweir return ( NameOrIndex::operator==(rItem) && 589*cdf0e10cSrcweir aXOBitmap == ((const XFillBitmapItem&) rItem).aXOBitmap ); 590*cdf0e10cSrcweir } 591*cdf0e10cSrcweir 592*cdf0e10cSrcweir /************************************************************************* 593*cdf0e10cSrcweir |* 594*cdf0e10cSrcweir |* SfxPoolItem* XFillBitmapItem::Create(SvStream& rIn, sal_uInt16 nVer) const 595*cdf0e10cSrcweir |* 596*cdf0e10cSrcweir |* Beschreibung 597*cdf0e10cSrcweir |* Ersterstellung 17.11.94 598*cdf0e10cSrcweir |* Letzte Aenderung 17.11.94 599*cdf0e10cSrcweir |* 600*cdf0e10cSrcweir *************************************************************************/ 601*cdf0e10cSrcweir 602*cdf0e10cSrcweir SfxPoolItem* XFillBitmapItem::Create(SvStream& rIn, sal_uInt16 nVer) const 603*cdf0e10cSrcweir { 604*cdf0e10cSrcweir return new XFillBitmapItem( rIn, nVer ); 605*cdf0e10cSrcweir } 606*cdf0e10cSrcweir 607*cdf0e10cSrcweir /************************************************************************* 608*cdf0e10cSrcweir |* 609*cdf0e10cSrcweir |* SfxPoolItem* XFillBitmapItem::Store(SvStream& rOut) const 610*cdf0e10cSrcweir |* 611*cdf0e10cSrcweir |* Beschreibung 612*cdf0e10cSrcweir |* Ersterstellung 17.11.94 613*cdf0e10cSrcweir |* Letzte Aenderung 26.07.94 614*cdf0e10cSrcweir |* 615*cdf0e10cSrcweir *************************************************************************/ 616*cdf0e10cSrcweir 617*cdf0e10cSrcweir SvStream& XFillBitmapItem::Store( SvStream& rOut, sal_uInt16 nItemVersion ) const 618*cdf0e10cSrcweir { 619*cdf0e10cSrcweir NameOrIndex::Store( rOut, nItemVersion ); 620*cdf0e10cSrcweir 621*cdf0e10cSrcweir if (!IsIndex()) 622*cdf0e10cSrcweir { 623*cdf0e10cSrcweir rOut << (sal_Int16) aXOBitmap.GetBitmapStyle(); 624*cdf0e10cSrcweir if( !aXOBitmap.GetBitmap() ) 625*cdf0e10cSrcweir rOut << (sal_Int16) XBITMAP_NONE; 626*cdf0e10cSrcweir else 627*cdf0e10cSrcweir { 628*cdf0e10cSrcweir rOut << (sal_Int16) aXOBitmap.GetBitmapType(); 629*cdf0e10cSrcweir if( aXOBitmap.GetBitmapType() == XBITMAP_IMPORT ) 630*cdf0e10cSrcweir { 631*cdf0e10cSrcweir const sal_uInt16 nOldComprMode = rOut.GetCompressMode(); 632*cdf0e10cSrcweir sal_uInt16 nNewComprMode = nOldComprMode; 633*cdf0e10cSrcweir 634*cdf0e10cSrcweir if( rOut.GetVersion() >= SOFFICE_FILEFORMAT_50 ) 635*cdf0e10cSrcweir nNewComprMode |= COMPRESSMODE_ZBITMAP; 636*cdf0e10cSrcweir else 637*cdf0e10cSrcweir nNewComprMode &= ~COMPRESSMODE_ZBITMAP; 638*cdf0e10cSrcweir 639*cdf0e10cSrcweir rOut.SetCompressMode( nNewComprMode ); 640*cdf0e10cSrcweir rOut << aXOBitmap.GetBitmap(); 641*cdf0e10cSrcweir rOut.SetCompressMode( nOldComprMode ); 642*cdf0e10cSrcweir } 643*cdf0e10cSrcweir else if( aXOBitmap.GetBitmapType() == XBITMAP_8X8 ) 644*cdf0e10cSrcweir { 645*cdf0e10cSrcweir sal_uInt16* pArray = aXOBitmap.GetPixelArray(); 646*cdf0e10cSrcweir for( sal_uInt16 i = 0; i < 64; i++ ) 647*cdf0e10cSrcweir rOut << (sal_uInt16) *( pArray + i ); 648*cdf0e10cSrcweir 649*cdf0e10cSrcweir rOut << aXOBitmap.GetPixelColor(); 650*cdf0e10cSrcweir rOut << aXOBitmap.GetBackgroundColor(); 651*cdf0e10cSrcweir } 652*cdf0e10cSrcweir } 653*cdf0e10cSrcweir } 654*cdf0e10cSrcweir 655*cdf0e10cSrcweir return rOut; 656*cdf0e10cSrcweir } 657*cdf0e10cSrcweir 658*cdf0e10cSrcweir /************************************************************************* 659*cdf0e10cSrcweir |* 660*cdf0e10cSrcweir |* const Bitmap& XFillBitmapItem::GetValue(const XBitmapTable* pTable) const 661*cdf0e10cSrcweir |* 662*cdf0e10cSrcweir |* Beschreibung 663*cdf0e10cSrcweir |* Ersterstellung 15.11.94 664*cdf0e10cSrcweir |* Letzte Aenderung 26.07.94 665*cdf0e10cSrcweir |* 666*cdf0e10cSrcweir *************************************************************************/ 667*cdf0e10cSrcweir 668*cdf0e10cSrcweir const XOBitmap& XFillBitmapItem::GetBitmapValue(const XBitmapTable* pTable) const // GetValue -> GetBitmapValue 669*cdf0e10cSrcweir { 670*cdf0e10cSrcweir if (!IsIndex()) 671*cdf0e10cSrcweir return aXOBitmap; 672*cdf0e10cSrcweir else 673*cdf0e10cSrcweir return pTable->GetBitmap(GetIndex())->GetXBitmap(); 674*cdf0e10cSrcweir } 675*cdf0e10cSrcweir 676*cdf0e10cSrcweir 677*cdf0e10cSrcweir /************************************************************************* 678*cdf0e10cSrcweir |* 679*cdf0e10cSrcweir |* sal_uInt16 XFillBitmapItem::GetVersion() const 680*cdf0e10cSrcweir |* 681*cdf0e10cSrcweir |* Beschreibung 682*cdf0e10cSrcweir |* Ersterstellung 26.07.95 683*cdf0e10cSrcweir |* Letzte Aenderung 26.07.95 684*cdf0e10cSrcweir |* 685*cdf0e10cSrcweir *************************************************************************/ 686*cdf0e10cSrcweir 687*cdf0e10cSrcweir sal_uInt16 XFillBitmapItem::GetVersion( sal_uInt16 /*nFileFormatVersion*/) const 688*cdf0e10cSrcweir { 689*cdf0e10cSrcweir // 2. Version 690*cdf0e10cSrcweir return( 1 ); 691*cdf0e10cSrcweir } 692*cdf0e10cSrcweir 693*cdf0e10cSrcweir //------------------------------------------------------------------------ 694*cdf0e10cSrcweir 695*cdf0e10cSrcweir SfxItemPresentation XFillBitmapItem::GetPresentation 696*cdf0e10cSrcweir ( 697*cdf0e10cSrcweir SfxItemPresentation ePres, 698*cdf0e10cSrcweir SfxMapUnit /*eCoreUnit*/, 699*cdf0e10cSrcweir SfxMapUnit /*ePresUnit*/, 700*cdf0e10cSrcweir XubString& rText, const IntlWrapper * 701*cdf0e10cSrcweir ) const 702*cdf0e10cSrcweir { 703*cdf0e10cSrcweir switch ( ePres ) 704*cdf0e10cSrcweir { 705*cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NONE: 706*cdf0e10cSrcweir rText.Erase(); 707*cdf0e10cSrcweir return ePres; 708*cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NAMELESS: 709*cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_COMPLETE: 710*cdf0e10cSrcweir rText += GetName(); 711*cdf0e10cSrcweir return ePres; 712*cdf0e10cSrcweir default: 713*cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NONE; 714*cdf0e10cSrcweir } 715*cdf0e10cSrcweir } 716*cdf0e10cSrcweir 717*cdf0e10cSrcweir //------------------------------------------------------------------------ 718*cdf0e10cSrcweir 719*cdf0e10cSrcweir sal_Bool XFillBitmapItem::QueryValue( ::com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId ) const 720*cdf0e10cSrcweir { 721*cdf0e10cSrcweir // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); 722*cdf0e10cSrcweir nMemberId &= ~CONVERT_TWIPS; 723*cdf0e10cSrcweir 724*cdf0e10cSrcweir // needed for MID_NAME 725*cdf0e10cSrcweir ::rtl::OUString aApiName; 726*cdf0e10cSrcweir // needed for complete item (MID 0) 727*cdf0e10cSrcweir ::rtl::OUString aInternalName; 728*cdf0e10cSrcweir 729*cdf0e10cSrcweir ::rtl::OUString aURL; 730*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap > xBmp; 731*cdf0e10cSrcweir 732*cdf0e10cSrcweir if( nMemberId == MID_NAME ) 733*cdf0e10cSrcweir { 734*cdf0e10cSrcweir SvxUnogetApiNameForItem( Which(), GetName(), aApiName ); 735*cdf0e10cSrcweir } 736*cdf0e10cSrcweir else if( nMemberId == 0 ) 737*cdf0e10cSrcweir { 738*cdf0e10cSrcweir aInternalName = GetName(); 739*cdf0e10cSrcweir } 740*cdf0e10cSrcweir 741*cdf0e10cSrcweir if( nMemberId == MID_GRAFURL || 742*cdf0e10cSrcweir nMemberId == 0 ) 743*cdf0e10cSrcweir { 744*cdf0e10cSrcweir XOBitmap aLocalXOBitmap( GetBitmapValue() ); 745*cdf0e10cSrcweir aURL = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX)); 746*cdf0e10cSrcweir aURL += ::rtl::OUString::createFromAscii( aLocalXOBitmap.GetGraphicObject().GetUniqueID().GetBuffer() ); 747*cdf0e10cSrcweir } 748*cdf0e10cSrcweir if( nMemberId == MID_BITMAP || 749*cdf0e10cSrcweir nMemberId == 0 ) 750*cdf0e10cSrcweir { 751*cdf0e10cSrcweir XOBitmap aLocalXOBitmap( GetBitmapValue() ); 752*cdf0e10cSrcweir Bitmap aBmp( aLocalXOBitmap.GetBitmap() ); 753*cdf0e10cSrcweir BitmapEx aBmpEx( aBmp ); 754*cdf0e10cSrcweir 755*cdf0e10cSrcweir xBmp.set( VCLUnoHelper::CreateBitmap( aBmpEx ) ); 756*cdf0e10cSrcweir } 757*cdf0e10cSrcweir 758*cdf0e10cSrcweir if( nMemberId == MID_NAME ) 759*cdf0e10cSrcweir rVal <<= aApiName; 760*cdf0e10cSrcweir else if( nMemberId == MID_GRAFURL ) 761*cdf0e10cSrcweir rVal <<= aURL; 762*cdf0e10cSrcweir else if( nMemberId == MID_BITMAP ) 763*cdf0e10cSrcweir rVal <<= xBmp; 764*cdf0e10cSrcweir else 765*cdf0e10cSrcweir { 766*cdf0e10cSrcweir // member-id 0 => complete item (e.g. for toolbars) 767*cdf0e10cSrcweir DBG_ASSERT( nMemberId == 0, "invalid member-id" ); 768*cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aPropSeq( 3 ); 769*cdf0e10cSrcweir 770*cdf0e10cSrcweir aPropSeq[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" )); 771*cdf0e10cSrcweir aPropSeq[0].Value = uno::makeAny( aInternalName ); 772*cdf0e10cSrcweir aPropSeq[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillBitmapURL" )); 773*cdf0e10cSrcweir aPropSeq[1].Value = uno::makeAny( aURL ); 774*cdf0e10cSrcweir aPropSeq[2].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Bitmap" )); 775*cdf0e10cSrcweir aPropSeq[2].Value = uno::makeAny( xBmp ); 776*cdf0e10cSrcweir 777*cdf0e10cSrcweir rVal <<= aPropSeq; 778*cdf0e10cSrcweir } 779*cdf0e10cSrcweir 780*cdf0e10cSrcweir return sal_True; 781*cdf0e10cSrcweir } 782*cdf0e10cSrcweir 783*cdf0e10cSrcweir //------------------------------------------------------------------------ 784*cdf0e10cSrcweir 785*cdf0e10cSrcweir sal_Bool XFillBitmapItem::PutValue( const ::com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId ) 786*cdf0e10cSrcweir { 787*cdf0e10cSrcweir // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); 788*cdf0e10cSrcweir nMemberId &= ~CONVERT_TWIPS; 789*cdf0e10cSrcweir 790*cdf0e10cSrcweir ::rtl::OUString aName; 791*cdf0e10cSrcweir ::rtl::OUString aURL; 792*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap > xBmp; 793*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > xGraphic; 794*cdf0e10cSrcweir 795*cdf0e10cSrcweir bool bSetName = false; 796*cdf0e10cSrcweir bool bSetURL = false; 797*cdf0e10cSrcweir bool bSetBitmap = false; 798*cdf0e10cSrcweir 799*cdf0e10cSrcweir if( nMemberId == MID_NAME ) 800*cdf0e10cSrcweir bSetName = (rVal >>= aName); 801*cdf0e10cSrcweir else if( nMemberId == MID_GRAFURL ) 802*cdf0e10cSrcweir bSetURL = (rVal >>= aURL); 803*cdf0e10cSrcweir else if( nMemberId == MID_BITMAP ) 804*cdf0e10cSrcweir { 805*cdf0e10cSrcweir bSetBitmap = (rVal >>= xBmp); 806*cdf0e10cSrcweir if ( !bSetBitmap ) 807*cdf0e10cSrcweir bSetBitmap = (rVal >>= xGraphic ); 808*cdf0e10cSrcweir } 809*cdf0e10cSrcweir else 810*cdf0e10cSrcweir { 811*cdf0e10cSrcweir DBG_ASSERT( nMemberId == 0, "invalid member-id" ); 812*cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aPropSeq; 813*cdf0e10cSrcweir if( rVal >>= aPropSeq ) 814*cdf0e10cSrcweir { 815*cdf0e10cSrcweir for ( sal_Int32 n = 0; n < aPropSeq.getLength(); n++ ) 816*cdf0e10cSrcweir { 817*cdf0e10cSrcweir if( aPropSeq[n].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Name" ))) 818*cdf0e10cSrcweir bSetName = (aPropSeq[n].Value >>= aName); 819*cdf0e10cSrcweir else if( aPropSeq[n].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "FillBitmapURL" ))) 820*cdf0e10cSrcweir bSetURL = (aPropSeq[n].Value >>= aURL); 821*cdf0e10cSrcweir else if( aPropSeq[n].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Bitmap" ))) 822*cdf0e10cSrcweir bSetBitmap = (aPropSeq[n].Value >>= xBmp); 823*cdf0e10cSrcweir } 824*cdf0e10cSrcweir } 825*cdf0e10cSrcweir } 826*cdf0e10cSrcweir 827*cdf0e10cSrcweir if( bSetName ) 828*cdf0e10cSrcweir { 829*cdf0e10cSrcweir SetName( aName ); 830*cdf0e10cSrcweir } 831*cdf0e10cSrcweir if( bSetURL ) 832*cdf0e10cSrcweir { 833*cdf0e10cSrcweir GraphicObject aGrafObj( GraphicObject::CreateGraphicObjectFromURL( aURL ) ); 834*cdf0e10cSrcweir XOBitmap aBMP( aGrafObj ); 835*cdf0e10cSrcweir SetBitmapValue( aBMP ); 836*cdf0e10cSrcweir } 837*cdf0e10cSrcweir if( bSetBitmap ) 838*cdf0e10cSrcweir { 839*cdf0e10cSrcweir Bitmap aInput; 840*cdf0e10cSrcweir if ( xBmp.is() ) 841*cdf0e10cSrcweir { 842*cdf0e10cSrcweir BitmapEx aInputEx( VCLUnoHelper::GetBitmap( xBmp ) ); 843*cdf0e10cSrcweir aInput = aInputEx.GetBitmap(); 844*cdf0e10cSrcweir } 845*cdf0e10cSrcweir else if ( xGraphic.is() ) 846*cdf0e10cSrcweir { 847*cdf0e10cSrcweir Graphic aGraphic( xGraphic ); 848*cdf0e10cSrcweir aInput = aGraphic.GetBitmap(); 849*cdf0e10cSrcweir } 850*cdf0e10cSrcweir 851*cdf0e10cSrcweir // note: aXOBitmap is the member bitmap 852*cdf0e10cSrcweir aXOBitmap.SetBitmap( aInput ); 853*cdf0e10cSrcweir aXOBitmap.SetBitmapType(XBITMAP_IMPORT); 854*cdf0e10cSrcweir 855*cdf0e10cSrcweir if(aInput.GetSizePixel().Width() == 8 856*cdf0e10cSrcweir && aInput.GetSizePixel().Height() == 8 857*cdf0e10cSrcweir && aInput.GetColorCount() == 2) 858*cdf0e10cSrcweir { 859*cdf0e10cSrcweir aXOBitmap.Bitmap2Array(); 860*cdf0e10cSrcweir aXOBitmap.SetBitmapType(XBITMAP_8X8); 861*cdf0e10cSrcweir aXOBitmap.SetPixelSize(aInput.GetSizePixel()); 862*cdf0e10cSrcweir } 863*cdf0e10cSrcweir } 864*cdf0e10cSrcweir 865*cdf0e10cSrcweir return (bSetName || bSetURL || bSetBitmap); 866*cdf0e10cSrcweir } 867*cdf0e10cSrcweir 868*cdf0e10cSrcweir sal_Bool XFillBitmapItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 ) 869*cdf0e10cSrcweir { 870*cdf0e10cSrcweir return ((XFillBitmapItem*)p1)->GetBitmapValue().GetGraphicObject().GetUniqueID() == 871*cdf0e10cSrcweir ((XFillBitmapItem*)p2)->GetBitmapValue().GetGraphicObject().GetUniqueID(); 872*cdf0e10cSrcweir } 873*cdf0e10cSrcweir 874*cdf0e10cSrcweir XFillBitmapItem* XFillBitmapItem::checkForUniqueItem( SdrModel* pModel ) const 875*cdf0e10cSrcweir { 876*cdf0e10cSrcweir if( pModel ) 877*cdf0e10cSrcweir { 878*cdf0e10cSrcweir const String aUniqueName = NameOrIndex::CheckNamedItem( this, 879*cdf0e10cSrcweir XATTR_FILLBITMAP, 880*cdf0e10cSrcweir &pModel->GetItemPool(), 881*cdf0e10cSrcweir pModel->GetStyleSheetPool() ? &pModel->GetStyleSheetPool()->GetPool() : NULL, 882*cdf0e10cSrcweir XFillBitmapItem::CompareValueFunc, 883*cdf0e10cSrcweir RID_SVXSTR_BMP21, 884*cdf0e10cSrcweir pModel->GetBitmapList() ); 885*cdf0e10cSrcweir 886*cdf0e10cSrcweir // if the given name is not valid, replace it! 887*cdf0e10cSrcweir if( aUniqueName != GetName() ) 888*cdf0e10cSrcweir { 889*cdf0e10cSrcweir return new XFillBitmapItem( aUniqueName, aXOBitmap ); 890*cdf0e10cSrcweir } 891*cdf0e10cSrcweir } 892*cdf0e10cSrcweir 893*cdf0e10cSrcweir return (XFillBitmapItem*)this; 894*cdf0e10cSrcweir } 895