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