diff options
author | Armin Le Grand <alg@apache.org> | 2012-05-10 09:29:55 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-03-15 15:24:52 +0000 |
commit | c97aec0d2276901c20634abe53867f739f420f50 (patch) | |
tree | db775ba307edfffaa990a5d01361ae5c53c43f28 /cui | |
parent | d2cccde341af33b72378f3e7b0e8dd9ff1cd5e65 (diff) |
Related: #i119125# change XFillBitmapItem to work with GraphicObject
Completely changed XFillBitmapItem to work with GraphicObject, removed XOBitmap
class, adapted all usages (also the pretty old 8x8 pixel editor).
All Bitmap fill styles will now accept transparent bitmaps as fillings in all
variations (tiled, etc.). LoadSave is no problem, ODF defines graphic as
content for fill. Backward means that OOs before this change will use a white
background of fill with transparent, same as the fallback all the time when
using a transparent fill.
This is also a preparation to e.g. offer SVG or Metafiles as fill style.
Conflicts:
cui/source/tabpages/backgrnd.cxx
cui/source/tabpages/tparea.cxx
cui/source/tabpages/tpbitmap.cxx
filter/source/msfilter/msdffimp.cxx
filter/source/msfilter/svdfppt.cxx
sc/source/filter/excel/xiescher.cxx
sd/source/ui/func/fupage.cxx
svx/inc/svx/dlgctrl.hxx
svx/inc/svx/xbitmap.hxx
svx/inc/svx/xbtmpit.hxx
svx/inc/svx/xtable.hxx
svx/source/customshapes/EnhancedCustomShape2d.cxx
svx/source/dialog/dlgctrl.cxx
svx/source/svdraw/svdograf.cxx
svx/source/tbxctrls/fillctrl.cxx
svx/source/unodraw/XPropertyTable.cxx
svx/source/xoutdev/xattrbmp.cxx
svx/source/xoutdev/xtabbtmp.cxx
Change-Id: Id838bfbacc863695d078fb3cf379d1c0cd951680
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/tabpages/backgrnd.cxx | 2 | ||||
-rw-r--r-- | cui/source/tabpages/tparea.cxx | 16 | ||||
-rw-r--r-- | cui/source/tabpages/tpbitmap.cxx | 237 | ||||
-rw-r--r-- | cui/source/tabpages/tpline.cxx | 1 |
4 files changed, 80 insertions, 176 deletions
diff --git a/cui/source/tabpages/backgrnd.cxx b/cui/source/tabpages/backgrnd.cxx index d84cf85117b3..930073fad779 100644 --- a/cui/source/tabpages/backgrnd.cxx +++ b/cui/source/tabpages/backgrnd.cxx @@ -53,6 +53,8 @@ #include <svx/xflgrit.hxx> #include <svl/intitem.hxx> #include <sfx2/request.hxx> +#include <svtools/grfmgr.hxx> + using namespace ::com::sun::star; // static ---------------------------------------------------------------- diff --git a/cui/source/tabpages/tparea.cxx b/cui/source/tabpages/tparea.cxx index 952d6121bd2c..c6716c1798e6 100644 --- a/cui/source/tabpages/tparea.cxx +++ b/cui/source/tabpages/tparea.cxx @@ -1142,9 +1142,9 @@ sal_Bool SvxAreaTabPage::FillItemSet( SfxItemSet& rAttrs ) if( nPos != LISTBOX_ENTRY_NOTFOUND && nPos != aLbBitmap.GetSavedValue() ) { - XOBitmap aXOBitmap = pBitmapList->GetBitmap( nPos )->GetXBitmap(); - String aString = aLbBitmap.GetSelectEntry(); - XFillBitmapItem aFillBitmapItem( aString, aXOBitmap ); + const XBitmapEntry* pXBitmapEntry = pBitmapList->GetBitmap(nPos); + const String aString(aLbBitmap.GetSelectEntry()); + const XFillBitmapItem aFillBitmapItem(aString, pXBitmapEntry->GetGraphicObject()); pOld = GetOldItem( rAttrs, XATTR_FILLBITMAP ); if ( !pOld || !( *(const XFillBitmapItem*)pOld == aFillBitmapItem ) ) { @@ -2225,15 +2225,15 @@ IMPL_LINK_NOARG(SvxAreaTabPage, ModifyBitmapHdl_Impl) if( _nPos != LISTBOX_ENTRY_NOTFOUND ) { // fill ItemSet and pass it on to aCtlXRectPreview - XBitmapEntry* pEntry = pBitmapList->GetBitmap( _nPos ); + const XBitmapEntry* pEntry = pBitmapList->GetBitmap(_nPos); - rXFSet.Put( XFillStyleItem( XFILL_BITMAP ) ); - rXFSet.Put( XFillBitmapItem( String(), pEntry->GetXBitmap() ) ); + rXFSet.Put(XFillStyleItem(XFILL_BITMAP)); + rXFSet.Put(XFillBitmapItem(String(), pEntry->GetGraphicObject())); } else if( SFX_ITEM_SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLBITMAP ), sal_True, &pPoolItem ) ) { - rXFSet.Put( XFillStyleItem( XFILL_BITMAP ) ); - rXFSet.Put( XFillBitmapItem( String(), ( ( const XFillBitmapItem* ) pPoolItem )->GetBitmapValue() ) ); + rXFSet.Put(XFillStyleItem(XFILL_BITMAP)); + rXFSet.Put(XFillBitmapItem(String(), ((const XFillBitmapItem*)pPoolItem)->GetGraphicObject())); } else rXFSet.Put( XFillStyleItem( XFILL_NONE ) ); diff --git a/cui/source/tabpages/tpbitmap.cxx b/cui/source/tabpages/tpbitmap.cxx index 6a4b74b139f0..3ed60c3366a2 100644 --- a/cui/source/tabpages/tpbitmap.cxx +++ b/cui/source/tabpages/tpbitmap.cxx @@ -89,7 +89,7 @@ SvxBitmapTabPage::SvxBitmapTabPage pXPool ( (XOutdevItemPool*) rInAttrs.GetPool() ), aXFStyleItem ( XFILL_BITMAP ), - aXBitmapItem ( String(), XOBitmap() ), + aXBitmapItem ( String(), Graphic() ), aXFillAttr ( pXPool ), rXFSet ( aXFillAttr.GetItemSet() ) { @@ -237,32 +237,26 @@ sal_Bool SvxBitmapTabPage::FillItemSet( SfxItemSet& _rOutAttrs ) { if( *pDlgType == 0 && *pbAreaTP == sal_False ) // area dialog { - if( *pPageType == PT_BITMAP ) + if(PT_BITMAP == *pPageType) { - // CheckChanges_Impl(); <-- duplicate inquiry? - - XOBitmap aXOBitmap; - String aString; + _rOutAttrs.Put(XFillStyleItem(XFILL_BITMAP)); sal_uInt16 nPos = aLbBitmaps.GetSelectEntryPos(); - if( nPos != LISTBOX_ENTRY_NOTFOUND ) + if(LISTBOX_ENTRY_NOTFOUND != nPos) { - aXOBitmap = pBitmapList->GetBitmap( nPos )->GetXBitmap(); - aString = aLbBitmaps.GetSelectEntry(); + const XBitmapEntry* pXBitmapEntry = pBitmapList->GetBitmap(nPos); + const String aString(aLbBitmaps.GetSelectEntry()); + _rOutAttrs.Put(XFillBitmapItem(aString, pXBitmapEntry->GetGraphicObject())); } else { - aXOBitmap = aBitmapCtl.GetXBitmap(); - - // #85339# if it's an array, force conversion to bitmap before using it. - if(aXOBitmap.GetBitmapType() == XBITMAP_8X8) - aXOBitmap.GetBitmap(); + const BitmapEx aBitmapEx(aBitmapCtl.GetBitmapEx()); + _rOutAttrs.Put(XFillBitmapItem(String(), Graphic(aBitmapEx))); } - _rOutAttrs.Put( XFillStyleItem( XFILL_BITMAP ) ); - _rOutAttrs.Put( XFillBitmapItem( aString, aXOBitmap ) ); } } + return sal_True; } @@ -278,7 +272,7 @@ void SvxBitmapTabPage::Reset( const SfxItemSet& ) aBitmapCtl.SetBmpArray( aCtlPixel.GetBitmapPixelPtr() ); // get bitmap and display it - XFillBitmapItem aBmpItem( (const String &) String(), aBitmapCtl.GetXBitmap() ); + const XFillBitmapItem aBmpItem(OUString(), Graphic(aBitmapCtl.GetBitmapEx())); rXFSet.Put( aBmpItem ); aCtlPreview.SetAttributes( aXFillAttr.GetItemSet() ); aCtlPreview.Invalidate(); @@ -313,145 +307,49 @@ SfxTabPage* SvxBitmapTabPage::Create( Window* pWindow, IMPL_LINK_NOARG(SvxBitmapTabPage, ChangeBitmapHdl_Impl) { - XOBitmap* pXOBitmap = NULL; - int nPos = aLbBitmaps.GetSelectEntryPos(); + GraphicObject* pGraphicObject = 0; + int nPos(aLbBitmaps.GetSelectEntryPos()); - if( nPos != LISTBOX_ENTRY_NOTFOUND ) - pXOBitmap = new XOBitmap( ( (XBitmapEntry*) pBitmapList->GetBitmap( nPos ) )->GetXBitmap() ); + if(LISTBOX_ENTRY_NOTFOUND != nPos) + { + pGraphicObject = new GraphicObject(pBitmapList->GetBitmap(nPos)->GetGraphicObject()); + } else { - const SfxPoolItem* pPoolItem = NULL; - if( SFX_ITEM_SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLSTYLE ), sal_True, &pPoolItem ) ) + const SfxPoolItem* pPoolItem = 0; + + if(SFX_ITEM_SET == rOutAttrs.GetItemState(GetWhich(XATTR_FILLSTYLE), true, &pPoolItem)) { - XFillStyle eXFS = (XFillStyle) ( ( const XFillStyleItem* ) pPoolItem )->GetValue(); - if( ( XFILL_BITMAP == eXFS ) && - ( SFX_ITEM_SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLBITMAP ), sal_True, &pPoolItem ) ) ) + const XFillStyle eXFS((XFillStyle)((const XFillStyleItem*)pPoolItem)->GetValue()); + + if((XFILL_BITMAP == eXFS) && (SFX_ITEM_SET == rOutAttrs.GetItemState(GetWhich(XATTR_FILLBITMAP), true, &pPoolItem))) { - pXOBitmap = new XOBitmap( ( ( const XFillBitmapItem* ) pPoolItem )->GetBitmapValue() ); + pGraphicObject = new GraphicObject(((const XFillBitmapItem*)pPoolItem)->GetGraphicObject()); } } - if( !pXOBitmap ) + + if(!pGraphicObject) { - aLbBitmaps.SelectEntryPos( 0 ); + aLbBitmaps.SelectEntryPos(0); nPos = aLbBitmaps.GetSelectEntryPos(); - if( nPos != LISTBOX_ENTRY_NOTFOUND ) - pXOBitmap = new XOBitmap( ( (XBitmapEntry*) pBitmapList->GetBitmap( nPos ) )->GetXBitmap() ); - } - } - if( pXOBitmap ) - { - // #85339# try to convert bitmapped item to array item. - if(pXOBitmap->GetBitmapType() == XBITMAP_IMPORT) - { - Bitmap aBitmap(pXOBitmap->GetBitmap()); - Size aSizePixel(aBitmap.GetSizePixel()); - if(8 == aSizePixel.Width() && 8 == aSizePixel.Height()) + if(LISTBOX_ENTRY_NOTFOUND != nPos) { - sal_uInt16* pPixelArray = new sal_uInt16[64]; - sal_uInt32 nCol1(0xffffffff); // background - sal_uInt32 nCol2(0xffffffff); // pixel - BitmapReadAccess* pAccess = aBitmap.AcquireReadAccess(); - sal_Bool bValid(sal_True); - - if(pAccess) - { - for(sal_uInt32 a(0); bValid && a < 64; a++) - { - const BitmapColor aBmCol = pAccess->GetColor(a>>3, a%8); - Color aRgbCol(aBmCol.GetRed(), aBmCol.GetGreen(), aBmCol.GetBlue()); - sal_uInt32 nColVal = aRgbCol.GetRGBColor(); - - // test with nCol1 - if(nCol1 != nColVal) - { - if(0xffffffff == nCol1) - { - // nCol1 is used first time - nCol1 = nColVal; - pPixelArray[a] = 0; - } - else - { - // test with nCol2 - if(nCol2 != nColVal) - { - if(0xffffffff == nCol2) - { - // nCol2 used first time - nCol2 = nColVal; - pPixelArray[a] = 1; - } - else - { - // Third color detected - bValid = sal_False; - } - } - else - { - // color is pixel color - pPixelArray[a] = 1; - } - } - } - else - { - // color is background color - pPixelArray[a] = 0; - } - } - - // release ReadAccess - aBitmap.ReleaseAccess(pAccess); - } - else - { - // no access -> no success - bValid = sal_False; - } - - if(bValid) - { - Color aCol1(nCol1); - Color aCol2(nCol2); - - // no pixel color found? Use opposite od background color. - if(0xffffffff == nCol2) - { - aCol2 = Color( - 0xff - aCol1.GetRed(), - 0xff - aCol1.GetGreen(), - 0xff - aCol1.GetBlue()); - } - - // transformation did work, create a new Item - delete pXOBitmap; - pXOBitmap = new XOBitmap(pPixelArray, aCol2, aCol1); - } - - // cleanup - delete[] pPixelArray; + pGraphicObject = new GraphicObject(pBitmapList->GetBitmap(nPos)->GetGraphicObject()); } } + } + + if(pGraphicObject) + { + BitmapColor aBack; + BitmapColor aFront; + bool bIs8x8(isHistorical8x8(pGraphicObject->GetGraphic().GetBitmap(), aBack, aFront)); aLbColor.SetNoSelection(); aLbBackgroundColor.SetNoSelection(); - if( pXOBitmap->GetBitmapType() == XBITMAP_IMPORT ) - { - aCtlPixel.Reset(); - aCtlPixel.SetPaintable( sal_False ); - aCtlPixel.Disable(); - aFtPixelEdit.Disable(); - aFtColor.Disable(); - aLbColor.Disable(); - aFtBackgroundColor.Disable(); - aLbBackgroundColor.Disable(); - aBtnModify.Disable(); - aBtnAdd.Disable(); - } - else if( pXOBitmap->GetBitmapType() == XBITMAP_8X8 ) + if(bIs8x8) { aCtlPixel.SetPaintable( sal_True ); aCtlPixel.Enable(); @@ -464,10 +362,10 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ChangeBitmapHdl_Impl) aBtnAdd.Enable(); // setting the pixel control - aCtlPixel.SetXBitmap( *pXOBitmap ); + aCtlPixel.SetXBitmap(pGraphicObject->GetGraphic().GetBitmapEx()); - Color aPixelColor = pXOBitmap->GetPixelColor(); - Color aBackColor = pXOBitmap->GetBackgroundColor(); + Color aPixelColor = aFront; + Color aBackColor = aBack; aBitmapCtl.SetPixelColor( aPixelColor ); aBitmapCtl.SetBackgroundColor( aBackColor ); @@ -493,19 +391,34 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ChangeBitmapHdl_Impl) aLbBackgroundColor.SelectEntry( aBackColor ); } } + else + { + aCtlPixel.Reset(); + aCtlPixel.SetPaintable( sal_False ); + aCtlPixel.Disable(); + aFtPixelEdit.Disable(); + aFtColor.Disable(); + aLbColor.Disable(); + aFtBackgroundColor.Disable(); + aLbBackgroundColor.Disable(); + aBtnModify.Disable(); + aBtnAdd.Disable(); + } + aCtlPixel.Invalidate(); // display bitmap - XFillBitmapItem aXBmpItem( (const String &) String(), *pXOBitmap ); + const XFillBitmapItem aXBmpItem(String(), *pGraphicObject); rXFSet.Put( aXBmpItem ); aCtlPreview.SetAttributes( aXFillAttr.GetItemSet() ); aCtlPreview.Invalidate(); bBmpChanged = sal_False; - delete pXOBitmap; + delete pGraphicObject; } - return 0L; + + return 0; } // ----------------------------------------------------------------------- @@ -624,21 +537,17 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ClickAddHdl_Impl) XBitmapEntry* pEntry = 0; if( aCtlPixel.IsEnabled() ) { - XOBitmap aXOBitmap = aBitmapCtl.GetXBitmap(); + const BitmapEx aBitmapEx(aBitmapCtl.GetBitmapEx()); - // #85339# if it's an array, force conversion to bitmap before using it. - if(aXOBitmap.GetBitmapType() == XBITMAP_8X8) - aXOBitmap.GetBitmap(); - - pEntry = new XBitmapEntry( aXOBitmap, aName ); + pEntry = new XBitmapEntry(Graphic(aBitmapEx), aName); } else // it must be a not existing imported bitmap { - const SfxPoolItem* pPoolItem = NULL; - if( SFX_ITEM_SET == rOutAttrs.GetItemState( XATTR_FILLBITMAP, sal_True, &pPoolItem ) ) + const SfxPoolItem* pPoolItem = 0; + + if(SFX_ITEM_SET == rOutAttrs.GetItemState(XATTR_FILLBITMAP, true, &pPoolItem)) { - XOBitmap aXOBitmap( ( ( const XFillBitmapItem* ) pPoolItem )->GetBitmapValue() ); - pEntry = new XBitmapEntry( aXOBitmap, aName ); + pEntry = new XBitmapEntry(dynamic_cast< const XFillBitmapItem* >(pPoolItem)->GetGraphicObject(), aName); } } @@ -746,9 +655,7 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ClickImportHdl_Impl) if( !nError ) { - Bitmap aBmp( aGraphic.GetBitmap() ); - XBitmapEntry* pEntry = - new XBitmapEntry( XOBitmap( aBmp ), aName ); + XBitmapEntry* pEntry = new XBitmapEntry( aGraphic, aName ); pBitmapList->Insert( pEntry ); aLbBitmaps.Append( pEntry ); @@ -819,13 +726,9 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ClickModifyHdl_Impl) pEntry->SetName( aName ); - XOBitmap aXOBitmap = aBitmapCtl.GetXBitmap(); - - // #85339# if it's an array, force conversion to bitmap before using it. - if(aXOBitmap.GetBitmapType() == XBITMAP_8X8) - aXOBitmap.GetBitmap(); + const BitmapEx aBitmapEx(aBitmapCtl.GetBitmapEx()); - pEntry->SetXBitmap( aXOBitmap ); + pEntry->SetGraphicObject(Graphic(aBitmapEx)); aLbBitmaps.Modify( pEntry, nPos ); aLbBitmaps.SelectEntryPos( nPos ); @@ -1043,7 +946,7 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ChangePixelColorHdl_Impl) aBitmapCtl.SetPixelColor( aLbColor.GetSelectEntryColor() ); // get bitmap and display it - rXFSet.Put( XFillBitmapItem( String(), aBitmapCtl.GetXBitmap() ) ); + rXFSet.Put(XFillBitmapItem(String(), Graphic(aBitmapCtl.GetBitmapEx()))); aCtlPreview.SetAttributes( aXFillAttr.GetItemSet() ); aCtlPreview.Invalidate(); @@ -1062,7 +965,7 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ChangeBackgrndColorHdl_Impl) aBitmapCtl.SetBackgroundColor( aLbBackgroundColor.GetSelectEntryColor() ); // get bitmap and display it - rXFSet.Put( XFillBitmapItem( String(), aBitmapCtl.GetXBitmap() ) ); + rXFSet.Put(XFillBitmapItem(String(), Graphic(aBitmapCtl.GetBitmapEx()))); aCtlPreview.SetAttributes( aXFillAttr.GetItemSet() ); aCtlPreview.Invalidate(); @@ -1080,7 +983,7 @@ void SvxBitmapTabPage::PointChanged( Window* pWindow, RECT_POINT ) aBitmapCtl.SetBmpArray( aCtlPixel.GetBitmapPixelPtr() ); // get bitmap and display it - rXFSet.Put( XFillBitmapItem( String(), aBitmapCtl.GetXBitmap() ) ); + rXFSet.Put(XFillBitmapItem(String(), Graphic(aBitmapCtl.GetBitmapEx()))); aCtlPreview.SetAttributes( aXFillAttr.GetItemSet() ); aCtlPreview.Invalidate(); diff --git a/cui/source/tabpages/tpline.cxx b/cui/source/tabpages/tpline.cxx index 77a9a005a329..303647465959 100644 --- a/cui/source/tabpages/tpline.cxx +++ b/cui/source/tabpages/tpline.cxx @@ -48,7 +48,6 @@ #include <sfx2/objsh.hxx> #include <editeng/brushitem.hxx> #include <svx/gallery.hxx> -#include <svx/xbitmap.hxx> #include <unotools/localfilehelper.hxx> #include "paragrph.hrc" #include "sfx2/opengrf.hxx" |