LCOV - code coverage report
Current view: top level - libreoffice/cui/source/tabpages - tpbitmap.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 536 0.2 %
Date: 2012-12-17 Functions: 2 30 6.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <vcl/wrkwin.hxx>
      21             : #include <tools/shl.hxx>
      22             : #include <vcl/msgbox.hxx>
      23             : #include <tools/urlobj.hxx>
      24             : #include <unotools/ucbstreamhelper.hxx>
      25             : #include <unotools/pathoptions.hxx>
      26             : #include <sfx2/app.hxx>
      27             : #include <sfx2/filedlghelper.hxx>
      28             : #include <unotools/localfilehelper.hxx>
      29             : #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
      30             : #include <svx/dialmgr.hxx>
      31             : #include <vcl/bmpacc.hxx>
      32             : #include <svx/dialogs.hrc>
      33             : 
      34             : #define _SVX_TPBITMAP_CXX
      35             : 
      36             : #include <cuires.hrc>
      37             : #include "helpid.hrc"
      38             : #include "svx/xattr.hxx"
      39             : #include <svx/xpool.hxx>
      40             : #include <svx/xtable.hxx>
      41             : #include "svx/xoutbmp.hxx"
      42             : #include "svx/drawitem.hxx"
      43             : #include "cuitabarea.hxx"
      44             : #include "tabarea.hrc"
      45             : #include "defdlgname.hxx"
      46             : #include <svx/svxdlg.hxx>
      47             : #include <dialmgr.hxx>
      48             : #include "sfx2/opengrf.hxx"
      49             : #include "paragrph.hrc"
      50             : 
      51           0 : SvxBitmapTabPage::SvxBitmapTabPage
      52             : (
      53             :     Window* pParent,
      54             :     const SfxItemSet& rInAttrs
      55             : ) :
      56             : 
      57           0 :     SvxTabPage          ( pParent, CUI_RES( RID_SVXPAGE_BITMAP ), rInAttrs ),
      58             : 
      59           0 :     aCtlPixel           ( this, CUI_RES( CTL_PIXEL ) ),
      60           0 :     aFtPixelEdit        ( this, CUI_RES( FT_PIXEL_EDIT ) ),
      61           0 :     aFtColor            ( this, CUI_RES( FT_COLOR ) ),
      62           0 :     aLbColor            ( this, CUI_RES( LB_COLOR ) ),
      63           0 :     aFtBackgroundColor  ( this, CUI_RES( FT_BACKGROUND_COLOR ) ),
      64           0 :     aLbBackgroundColor  ( this, CUI_RES( LB_BACKGROUND_COLOR ) ),
      65             :     // This fix text is used only to provide the name for the following
      66             :     // bitmap list box.  The fixed text is not displayed.
      67           0 :     aLbBitmapsHidden    ( this, CUI_RES( FT_BITMAPS_HIDDEN ) ),
      68           0 :     aLbBitmaps          ( this, CUI_RES( LB_BITMAPS ) ),
      69           0 :     aFlProp             ( this, CUI_RES( FL_PROP ) ),
      70           0 :     aCtlPreview         ( this, CUI_RES( CTL_PREVIEW ) ),
      71           0 :     aBtnAdd             ( this, CUI_RES( BTN_ADD ) ),
      72           0 :     aBtnModify          ( this, CUI_RES( BTN_MODIFY ) ),
      73           0 :     aBtnImport          ( this, CUI_RES( BTN_IMPORT ) ),
      74           0 :     aBtnDelete          ( this, CUI_RES( BTN_DELETE ) ),
      75           0 :     aBtnLoad            ( this, CUI_RES( BTN_LOAD ) ),
      76           0 :     aBtnSave            ( this, CUI_RES( BTN_SAVE ) ),
      77             : 
      78           0 :     aBitmapCtl          ( this, aCtlPreview.GetSizePixel() ),
      79             :     rOutAttrs           ( rInAttrs ),
      80             : 
      81           0 :     pXPool              ( (XOutdevItemPool*) rInAttrs.GetPool() ),
      82             :     aXFStyleItem        ( XFILL_BITMAP ),
      83             :     aXBitmapItem        ( String(), XOBitmap() ),
      84             :     aXFillAttr          ( pXPool ),
      85           0 :     rXFSet              ( aXFillAttr.GetItemSet() )
      86             : {
      87           0 :     FreeResource();
      88             : 
      89             :     // this page needs ExchangeSupport
      90           0 :     SetExchangeSupport();
      91             : 
      92             :     // setting the output device
      93           0 :     rXFSet.Put( aXFStyleItem );
      94           0 :     rXFSet.Put( aXBitmapItem );
      95             : 
      96           0 :     aBtnAdd.SetClickHdl( LINK( this, SvxBitmapTabPage, ClickAddHdl_Impl ) );
      97             :     aBtnImport.SetClickHdl(
      98           0 :         LINK( this, SvxBitmapTabPage, ClickImportHdl_Impl ) );
      99             :     aBtnModify.SetClickHdl(
     100           0 :         LINK( this, SvxBitmapTabPage, ClickModifyHdl_Impl ) );
     101             :     aBtnDelete.SetClickHdl(
     102           0 :         LINK( this, SvxBitmapTabPage, ClickDeleteHdl_Impl ) );
     103           0 :     aBtnLoad.SetClickHdl( LINK( this, SvxBitmapTabPage, ClickLoadHdl_Impl ) );
     104           0 :     aBtnSave.SetClickHdl( LINK( this, SvxBitmapTabPage, ClickSaveHdl_Impl ) );
     105             : 
     106             :     aLbBitmaps.SetSelectHdl(
     107           0 :         LINK( this, SvxBitmapTabPage, ChangeBitmapHdl_Impl ) );
     108             :     aLbColor.SetSelectHdl(
     109           0 :         LINK( this, SvxBitmapTabPage, ChangePixelColorHdl_Impl ) );
     110             :     aLbBackgroundColor.SetSelectHdl(
     111           0 :         LINK( this, SvxBitmapTabPage, ChangeBackgrndColorHdl_Impl ) );
     112             : 
     113           0 :     String accName = String(CUI_RES(STR_EXAMPLE));
     114           0 :     aCtlPreview.SetAccessibleName(accName);
     115           0 :     aCtlPixel.SetAccessibleRelationMemberOf( &aFlProp );
     116           0 :     aCtlPixel.SetAccessibleRelationLabeledBy( &aFtPixelEdit );
     117           0 :     aLbBitmaps.SetAccessibleRelationLabeledBy(&aLbBitmaps);
     118           0 :     aBtnAdd.SetAccessibleRelationMemberOf( &aFlProp );
     119           0 :     aBtnModify.SetAccessibleRelationMemberOf( &aFlProp );
     120           0 :     aBtnImport.SetAccessibleRelationMemberOf( &aFlProp );
     121           0 :     aBtnDelete.SetAccessibleRelationMemberOf( &aFlProp );
     122             : 
     123           0 : }
     124             : 
     125             : // -----------------------------------------------------------------------
     126             : 
     127           0 : void SvxBitmapTabPage::Construct()
     128             : {
     129           0 :     aLbColor.Fill( pColorList );
     130           0 :     aLbBackgroundColor.CopyEntries( aLbColor );
     131             : 
     132           0 :     aLbBitmaps.Fill( pBitmapList );
     133           0 : }
     134             : 
     135             : // -----------------------------------------------------------------------
     136             : 
     137           0 : void SvxBitmapTabPage::ActivatePage( const SfxItemSet&  )
     138             : {
     139             :     sal_uInt16 nPos;
     140             :     sal_uInt16 nCount;
     141             : 
     142           0 :     if( *pDlgType == 0 ) // area dialog
     143             :     {
     144           0 :         *pbAreaTP = sal_False;
     145             : 
     146           0 :         if( pColorList.is() )
     147             :         {
     148             :             // ColorList
     149           0 :             if( *pnColorListState & CT_CHANGED ||
     150             :                 *pnColorListState & CT_MODIFIED )
     151             :             {
     152           0 :                 if( *pnColorListState & CT_CHANGED )
     153           0 :                     pColorList = ( (SvxAreaTabDialog*) GetParentDialog() )->GetNewColorList();
     154             : 
     155             :                 // LbColor
     156           0 :                 nPos = aLbColor.GetSelectEntryPos();
     157           0 :                 aLbColor.Clear();
     158           0 :                 aLbColor.Fill( pColorList );
     159           0 :                 nCount = aLbColor.GetEntryCount();
     160           0 :                 if( nCount == 0 )
     161             :                     ; // this case should not occur
     162           0 :                 else if( nCount <= nPos )
     163           0 :                     aLbColor.SelectEntryPos( 0 );
     164             :                 else
     165           0 :                     aLbColor.SelectEntryPos( nPos );
     166             : 
     167             :                 // LbColorBackground
     168           0 :                 nPos = aLbBackgroundColor.GetSelectEntryPos();
     169           0 :                 aLbBackgroundColor.Clear();
     170           0 :                 aLbBackgroundColor.CopyEntries( aLbColor );
     171           0 :                 nCount = aLbBackgroundColor.GetEntryCount();
     172           0 :                 if( nCount == 0 )
     173             :                     ; // this case should not occur
     174           0 :                 else if( nCount <= nPos )
     175           0 :                     aLbBackgroundColor.SelectEntryPos( 0 );
     176             :                 else
     177           0 :                     aLbBackgroundColor.SelectEntryPos( nPos );
     178             : 
     179           0 :                 ChangePixelColorHdl_Impl( this );
     180           0 :                 ChangeBackgrndColorHdl_Impl( this );
     181             :             }
     182             : 
     183             :             // determining (possibly cutting) the name and
     184             :             // displaying it in the GroupBox
     185           0 :             String          aString( CUI_RES( RID_SVXSTR_TABLE ) ); aString.AppendAscii( ": " );
     186           0 :             INetURLObject   aURL( pBitmapList->GetPath() );
     187             : 
     188           0 :             aURL.Append( pBitmapList->GetName() );
     189             :             DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
     190             : 
     191           0 :             if( aURL.getBase().getLength() > 18 )
     192             :             {
     193           0 :                 aString += String(aURL.getBase()).Copy( 0, 15 );
     194           0 :                 aString.AppendAscii( "..." );
     195             :             }
     196             :             else
     197           0 :                 aString += String(aURL.getBase());
     198             : 
     199           0 :             if( *pPageType == PT_BITMAP && *pPos != LISTBOX_ENTRY_NOTFOUND )
     200             :             {
     201           0 :                 aLbBitmaps.SelectEntryPos( *pPos );
     202             :             }
     203             :             // colors could have been deleted
     204           0 :             ChangeBitmapHdl_Impl( this );
     205             : 
     206           0 :             *pPageType = PT_BITMAP;
     207           0 :             *pPos = LISTBOX_ENTRY_NOTFOUND;
     208             :         }
     209             :     }
     210           0 : }
     211             : 
     212             : // -----------------------------------------------------------------------
     213             : 
     214           0 : int SvxBitmapTabPage::DeactivatePage( SfxItemSet* _pSet)
     215             : {
     216           0 :     if ( CheckChanges_Impl() == -1L )
     217           0 :         return KEEP_PAGE;
     218             : 
     219           0 :     if( _pSet )
     220           0 :         FillItemSet( *_pSet );
     221             : 
     222           0 :     return LEAVE_PAGE;
     223             : }
     224             : 
     225             : // -----------------------------------------------------------------------
     226             : 
     227           0 : sal_Bool SvxBitmapTabPage::FillItemSet( SfxItemSet& _rOutAttrs )
     228             : {
     229           0 :     if( *pDlgType == 0 && *pbAreaTP == sal_False ) // area dialog
     230             :     {
     231           0 :         if( *pPageType == PT_BITMAP )
     232             :         {
     233             :             // CheckChanges_Impl(); <-- duplicate inquiry?
     234             : 
     235           0 :             XOBitmap aXOBitmap;
     236           0 :             String aString;
     237           0 :             sal_uInt16 nPos = aLbBitmaps.GetSelectEntryPos();
     238           0 :             if( nPos != LISTBOX_ENTRY_NOTFOUND )
     239             :             {
     240           0 :                 aXOBitmap = pBitmapList->GetBitmap( nPos )->GetXBitmap();
     241           0 :                 aString = aLbBitmaps.GetSelectEntry();
     242             : 
     243             :             }
     244             :             else
     245             :             {
     246           0 :                 aXOBitmap = aBitmapCtl.GetXBitmap();
     247             : 
     248             :                 // #85339# if it's an array, force conversion to bitmap before using it.
     249           0 :                 if(aXOBitmap.GetBitmapType() == XBITMAP_8X8)
     250           0 :                     aXOBitmap.GetBitmap();
     251             : 
     252             :             }
     253           0 :             _rOutAttrs.Put( XFillStyleItem( XFILL_BITMAP ) );
     254           0 :             _rOutAttrs.Put( XFillBitmapItem( aString, aXOBitmap ) );
     255             :         }
     256             :     }
     257           0 :     return sal_True;
     258             : }
     259             : 
     260             : // -----------------------------------------------------------------------
     261             : 
     262           0 : void SvxBitmapTabPage::Reset( const SfxItemSet&  )
     263             : {
     264             :     // aLbBitmaps.SelectEntryPos( 0 );
     265             : 
     266           0 :     aBitmapCtl.SetLines( aCtlPixel.GetLineCount() );
     267           0 :     aBitmapCtl.SetPixelColor( aLbColor.GetSelectEntryColor() );
     268           0 :     aBitmapCtl.SetBackgroundColor( aLbBackgroundColor.GetSelectEntryColor() );
     269           0 :     aBitmapCtl.SetBmpArray( aCtlPixel.GetBitmapPixelPtr() );
     270             : 
     271             :     // get bitmap and display it
     272           0 :     XFillBitmapItem aBmpItem( (const String &) String(), aBitmapCtl.GetXBitmap() );
     273           0 :     rXFSet.Put( aBmpItem );
     274           0 :     aCtlPreview.SetAttributes( aXFillAttr.GetItemSet() );
     275           0 :     aCtlPreview.Invalidate();
     276             : 
     277           0 :     ChangeBitmapHdl_Impl( this );
     278             : 
     279             :     // determine button state
     280           0 :     if( pBitmapList->Count() )
     281             :     {
     282           0 :         aBtnAdd.Enable();
     283           0 :         aBtnModify.Enable();
     284           0 :         aBtnDelete.Enable();
     285           0 :         aBtnSave.Enable();
     286             :     }
     287             :     else
     288             :     {
     289           0 :         aBtnModify.Disable();
     290           0 :         aBtnDelete.Disable();
     291           0 :         aBtnSave.Disable();
     292           0 :     }
     293           0 : }
     294             : 
     295             : // -----------------------------------------------------------------------
     296             : 
     297           0 : SfxTabPage* SvxBitmapTabPage::Create( Window* pWindow,
     298             :                 const SfxItemSet& rSet )
     299             : {
     300           0 :     return new SvxBitmapTabPage( pWindow, rSet );
     301             : }
     302             : 
     303             : //------------------------------------------------------------------------
     304             : 
     305           0 : IMPL_LINK_NOARG(SvxBitmapTabPage, ChangeBitmapHdl_Impl)
     306             : {
     307           0 :     XOBitmap* pXOBitmap = NULL;
     308           0 :     int nPos = aLbBitmaps.GetSelectEntryPos();
     309             : 
     310           0 :     if( nPos != LISTBOX_ENTRY_NOTFOUND )
     311           0 :         pXOBitmap = new XOBitmap( ( (XBitmapEntry*) pBitmapList->GetBitmap( nPos ) )->GetXBitmap() );
     312             :     else
     313             :     {
     314           0 :         const SfxPoolItem* pPoolItem = NULL;
     315           0 :         if( SFX_ITEM_SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLSTYLE ), sal_True, &pPoolItem ) )
     316             :         {
     317           0 :             XFillStyle eXFS = (XFillStyle) ( ( const XFillStyleItem* ) pPoolItem )->GetValue();
     318           0 :             if( ( XFILL_BITMAP == eXFS ) &&
     319           0 :                 ( SFX_ITEM_SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLBITMAP ), sal_True, &pPoolItem ) ) )
     320             :             {
     321           0 :                 pXOBitmap = new XOBitmap( ( ( const XFillBitmapItem* ) pPoolItem )->GetBitmapValue() );
     322             :             }
     323             :         }
     324           0 :         if( !pXOBitmap )
     325             :         {
     326           0 :             aLbBitmaps.SelectEntryPos( 0 );
     327           0 :             nPos = aLbBitmaps.GetSelectEntryPos();
     328           0 :             if( nPos != LISTBOX_ENTRY_NOTFOUND )
     329           0 :                 pXOBitmap = new XOBitmap( ( (XBitmapEntry*) pBitmapList->GetBitmap( nPos ) )->GetXBitmap() );
     330             :         }
     331             :     }
     332           0 :     if( pXOBitmap )
     333             :     {
     334             :         // #85339# try to convert bitmapped item to array item.
     335           0 :         if(pXOBitmap->GetBitmapType() == XBITMAP_IMPORT)
     336             :         {
     337           0 :             Bitmap aBitmap(pXOBitmap->GetBitmap());
     338           0 :             Size aSizePixel(aBitmap.GetSizePixel());
     339             : 
     340           0 :             if(8 == aSizePixel.Width() && 8 == aSizePixel.Height())
     341             :             {
     342           0 :                 sal_uInt16* pPixelArray = new sal_uInt16[64];
     343           0 :                 sal_uInt32 nCol1(0xffffffff); // background
     344           0 :                 sal_uInt32 nCol2(0xffffffff); // pixel
     345           0 :                 BitmapReadAccess* pAccess = aBitmap.AcquireReadAccess();
     346           0 :                 sal_Bool bValid(sal_True);
     347             : 
     348           0 :                 if(pAccess)
     349             :                 {
     350           0 :                     for(sal_uInt32 a(0); bValid && a < 64; a++)
     351             :                     {
     352           0 :                         const BitmapColor aBmCol = pAccess->GetColor(a>>3, a%8);
     353           0 :                         Color aRgbCol(aBmCol.GetRed(), aBmCol.GetGreen(), aBmCol.GetBlue());
     354           0 :                         sal_uInt32 nColVal = aRgbCol.GetRGBColor();
     355             : 
     356             :                         // test with nCol1
     357           0 :                         if(nCol1 != nColVal)
     358             :                         {
     359           0 :                             if(0xffffffff == nCol1)
     360             :                             {
     361             :                                 // nCol1 is used first time
     362           0 :                                 nCol1 = nColVal;
     363           0 :                                 pPixelArray[a] = 0;
     364             :                             }
     365             :                             else
     366             :                             {
     367             :                                 // test with nCol2
     368           0 :                                 if(nCol2 != nColVal)
     369             :                                 {
     370           0 :                                     if(0xffffffff == nCol2)
     371             :                                     {
     372             :                                         // nCol2 used first time
     373           0 :                                         nCol2 = nColVal;
     374           0 :                                         pPixelArray[a] = 1;
     375             :                                     }
     376             :                                     else
     377             :                                     {
     378             :                                         // Third color detected
     379           0 :                                         bValid = sal_False;
     380             :                                     }
     381             :                                 }
     382             :                                 else
     383             :                                 {
     384             :                                     // color is pixel color
     385           0 :                                     pPixelArray[a] = 1;
     386             :                                 }
     387             :                             }
     388             :                         }
     389             :                         else
     390             :                         {
     391             :                             // color is background color
     392           0 :                             pPixelArray[a] = 0;
     393             :                         }
     394           0 :                     }
     395             : 
     396             :                     // release ReadAccess
     397           0 :                     aBitmap.ReleaseAccess(pAccess);
     398             :                 }
     399             :                 else
     400             :                 {
     401             :                     // no access -> no success
     402           0 :                     bValid = sal_False;
     403             :                 }
     404             : 
     405           0 :                 if(bValid)
     406             :                 {
     407           0 :                     Color aCol1(nCol1);
     408           0 :                     Color aCol2(nCol2);
     409             : 
     410             :                     // no pixel color found? Use opposite od background color.
     411           0 :                     if(0xffffffff == nCol2)
     412             :                     {
     413             :                         aCol2 = Color(
     414           0 :                             0xff - aCol1.GetRed(),
     415           0 :                             0xff - aCol1.GetGreen(),
     416           0 :                             0xff - aCol1.GetBlue());
     417             :                     }
     418             : 
     419             :                     // transformation did work, create a new Item
     420           0 :                     delete pXOBitmap;
     421           0 :                     pXOBitmap = new XOBitmap(pPixelArray, aCol2, aCol1);
     422             :                 }
     423             : 
     424             :                 // cleanup
     425           0 :                 delete[] pPixelArray;
     426           0 :             }
     427             :         }
     428             : 
     429           0 :         aLbColor.SetNoSelection();
     430           0 :         aLbBackgroundColor.SetNoSelection();
     431             : 
     432           0 :         if( pXOBitmap->GetBitmapType() == XBITMAP_IMPORT )
     433             :         {
     434           0 :             aCtlPixel.Reset();
     435           0 :             aCtlPixel.SetPaintable( sal_False );
     436           0 :             aCtlPixel.Disable();
     437           0 :             aFtPixelEdit.Disable();
     438           0 :             aFtColor.Disable();
     439           0 :             aLbColor.Disable();
     440           0 :             aFtBackgroundColor.Disable();
     441           0 :             aLbBackgroundColor.Disable();
     442           0 :             aBtnModify.Disable();
     443           0 :             aBtnAdd.Disable();
     444             :         }
     445           0 :         else if( pXOBitmap->GetBitmapType() == XBITMAP_8X8 )
     446             :         {
     447           0 :             aCtlPixel.SetPaintable( sal_True );
     448           0 :             aCtlPixel.Enable();
     449           0 :             aFtPixelEdit.Enable();
     450           0 :             aFtColor.Enable();
     451           0 :             aLbColor.Enable();
     452           0 :             aFtBackgroundColor.Enable();
     453           0 :             aLbBackgroundColor.Enable();
     454           0 :             aBtnModify.Enable();
     455           0 :             aBtnAdd.Enable();
     456             : 
     457             :             // setting the pixel control
     458           0 :             aCtlPixel.SetXBitmap( *pXOBitmap );
     459             : 
     460           0 :             Color aPixelColor = pXOBitmap->GetPixelColor();
     461           0 :             Color aBackColor  = pXOBitmap->GetBackgroundColor();
     462             : 
     463           0 :             aBitmapCtl.SetPixelColor( aPixelColor );
     464           0 :             aBitmapCtl.SetBackgroundColor( aBackColor );
     465             : 
     466             :             // if the entry is not in the listbox,
     467             :             // the color is added temporarily
     468           0 :             if( 0 == aLbBitmaps.GetSelectEntryPos() )
     469             :             {
     470           0 :                 aLbColor.SelectEntry( Color( COL_BLACK ) );
     471           0 :                 ChangePixelColorHdl_Impl( this );
     472             :             }
     473             :             else
     474           0 :                 aLbColor.SelectEntry( aPixelColor );
     475           0 :             if( aLbColor.GetSelectEntryCount() == 0 )
     476             :             {
     477           0 :                 aLbColor.InsertEntry( aPixelColor, String() );
     478           0 :                 aLbColor.SelectEntry( aPixelColor );
     479             :             }
     480           0 :             aLbBackgroundColor.SelectEntry( aBackColor );
     481           0 :             if( aLbBackgroundColor.GetSelectEntryCount() == 0 )
     482             :             {
     483           0 :                 aLbBackgroundColor.InsertEntry( aBackColor, String() );
     484           0 :                 aLbBackgroundColor.SelectEntry( aBackColor );
     485             :             }
     486             :         }
     487           0 :         aCtlPixel.Invalidate();
     488             : 
     489             :         // display bitmap
     490           0 :         XFillBitmapItem aXBmpItem( (const String &) String(), *pXOBitmap );
     491           0 :         rXFSet.Put( aXBmpItem );
     492             : 
     493           0 :         aCtlPreview.SetAttributes( aXFillAttr.GetItemSet() );
     494           0 :         aCtlPreview.Invalidate();
     495             : 
     496           0 :         bBmpChanged = sal_False;
     497           0 :         delete pXOBitmap;
     498             :     }
     499           0 :     return 0L;
     500             : }
     501             : 
     502             : // -----------------------------------------------------------------------
     503             : 
     504           0 : long SvxBitmapTabPage::CheckChanges_Impl()
     505             : {
     506           0 :     sal_uInt16 nPos = aLbBitmaps.GetSelectEntryPos();
     507           0 :     if( nPos != LISTBOX_ENTRY_NOTFOUND )
     508             :     {
     509           0 :         String aString = aLbBitmaps.GetSelectEntry();
     510             : 
     511           0 :         if( bBmpChanged )
     512             :         {
     513           0 :             ResMgr& rMgr = CUI_MGR();
     514           0 :             Image aWarningBoxImage = WarningBox::GetStandardImage();
     515           0 :             SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     516             :             DBG_ASSERT(pFact, "Dialogdiet fail!");
     517           0 :             AbstractSvxMessDialog* aMessDlg = pFact->CreateSvxMessDialog( GetParentDialog(), RID_SVXDLG_MESSBOX,
     518           0 :                                                         String( SVX_RES( RID_SVXSTR_BITMAP ) ),
     519           0 :                                                         String( CUI_RES( RID_SVXSTR_ASK_CHANGE_BITMAP ) ),
     520           0 :                                                         &aWarningBoxImage  );
     521             :             DBG_ASSERT(aMessDlg, "Dialogdiet fail!");
     522             :             aMessDlg->SetButtonText( MESS_BTN_1,
     523           0 :                                     String( ResId( RID_SVXSTR_CHANGE, rMgr ) ) );
     524             :             aMessDlg->SetButtonText( MESS_BTN_2,
     525           0 :                                     String( ResId( RID_SVXSTR_ADD, rMgr ) ) );
     526             : 
     527           0 :             short nRet = aMessDlg->Execute();
     528             : 
     529           0 :             switch( nRet )
     530             :             {
     531             :                 case RET_BTN_1:
     532             :                 {
     533           0 :                     ClickModifyHdl_Impl( this );
     534             :                 }
     535           0 :                 break;
     536             : 
     537             :                 case RET_BTN_2:
     538             :                 {
     539           0 :                     ClickAddHdl_Impl( this );
     540           0 :                     nPos = aLbBitmaps.GetSelectEntryPos();
     541             :                 }
     542           0 :                 break;
     543             : 
     544             :                 case RET_CANCEL:
     545           0 :                 break;
     546             :             }
     547           0 :             delete aMessDlg;
     548           0 :         }
     549             :     }
     550           0 :     nPos = aLbBitmaps.GetSelectEntryPos();
     551           0 :     if( nPos != LISTBOX_ENTRY_NOTFOUND )
     552           0 :         *pPos = nPos;
     553           0 :     return 0L;
     554             : }
     555             : 
     556             : //------------------------------------------------------------------------
     557             : 
     558           0 : IMPL_LINK_NOARG(SvxBitmapTabPage, ClickAddHdl_Impl)
     559             : {
     560           0 :     ResMgr& rMgr = CUI_MGR();
     561           0 :     String aNewName( SVX_RES( RID_SVXSTR_BITMAP ) );
     562           0 :     String aDesc( CUI_RES( RID_SVXSTR_DESC_NEW_BITMAP ) );
     563           0 :     String aName;
     564             : 
     565           0 :     long nCount = pBitmapList->Count();
     566           0 :     long j = 1;
     567           0 :     sal_Bool bDifferent = sal_False;
     568             : 
     569           0 :     while( !bDifferent )
     570             :     {
     571           0 :         aName  = aNewName;
     572           0 :         aName += sal_Unicode(' ');
     573           0 :         aName += OUString::valueOf( j++ );
     574           0 :         bDifferent = sal_True;
     575             : 
     576           0 :         for( long i = 0; i < nCount && bDifferent; i++ )
     577           0 :             if( aName == pBitmapList->GetBitmap( i )->GetName() )
     578           0 :                 bDifferent = sal_False;
     579             :     }
     580             : 
     581           0 :     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     582             :     DBG_ASSERT(pFact, "Dialogdiet fail!");
     583           0 :     AbstractSvxNameDialog* pDlg = pFact->CreateSvxNameDialog( GetParentDialog(), aName, aDesc );
     584             :     DBG_ASSERT(pDlg, "Dialogdiet fail!");
     585           0 :     WarningBox*    pWarnBox = NULL;
     586           0 :     sal_uInt16         nError   = RID_SVXSTR_WARN_NAME_DUPLICATE;
     587             : 
     588           0 :     while( pDlg->Execute() == RET_OK )
     589             :     {
     590           0 :         pDlg->GetName( aName );
     591             : 
     592           0 :         bDifferent = sal_True;
     593             : 
     594           0 :         for( long i = 0; i < nCount && bDifferent; i++ )
     595           0 :             if( aName == pBitmapList->GetBitmap( i )->GetName() )
     596           0 :                 bDifferent = sal_False;
     597             : 
     598           0 :         if( bDifferent ) {
     599           0 :             nError = 0;
     600           0 :             break;
     601             :         }
     602             : 
     603           0 :         if( !pWarnBox )
     604             :         {
     605           0 :             pWarnBox = new WarningBox( GetParentDialog(),
     606             :                                        WinBits( WB_OK_CANCEL ),
     607           0 :                                        String( ResId( nError, rMgr ) ) );
     608           0 :             pWarnBox->SetHelpId( HID_WARN_NAME_DUPLICATE );
     609             :         }
     610             : 
     611           0 :         if( pWarnBox->Execute() != RET_OK )
     612           0 :             break;
     613             :     }
     614           0 :     delete pDlg;
     615           0 :     delete pWarnBox;
     616             : 
     617           0 :     if( !nError )
     618             :     {
     619           0 :         XBitmapEntry* pEntry = 0;
     620           0 :         if( aCtlPixel.IsEnabled() )
     621             :         {
     622           0 :             XOBitmap aXOBitmap = aBitmapCtl.GetXBitmap();
     623             : 
     624             :             // #85339# if it's an array, force conversion to bitmap before using it.
     625           0 :             if(aXOBitmap.GetBitmapType() == XBITMAP_8X8)
     626           0 :                 aXOBitmap.GetBitmap();
     627             : 
     628           0 :             pEntry = new XBitmapEntry( aXOBitmap, aName );
     629             :         }
     630             :         else // it must be a not existing imported bitmap
     631             :         {
     632           0 :             const SfxPoolItem* pPoolItem = NULL;
     633           0 :             if( SFX_ITEM_SET == rOutAttrs.GetItemState( XATTR_FILLBITMAP, sal_True, &pPoolItem ) )
     634             :             {
     635           0 :                 XOBitmap aXOBitmap( ( ( const XFillBitmapItem* ) pPoolItem )->GetBitmapValue() );
     636           0 :                 pEntry = new XBitmapEntry( aXOBitmap, aName );
     637             :             }
     638             :         }
     639             : 
     640             :         DBG_ASSERT( pEntry, "SvxBitmapTabPage::ClickAddHdl_Impl(), pEntry == 0 ?" );
     641             : 
     642           0 :         if( pEntry )
     643             :         {
     644           0 :             pBitmapList->Insert( pEntry );
     645             : 
     646           0 :             aLbBitmaps.Append( pEntry );
     647           0 :             aLbBitmaps.SelectEntryPos( aLbBitmaps.GetEntryCount() - 1 );
     648             : 
     649             : #ifdef WNT
     650             :             // hack: #31355# W.P.
     651             :             Rectangle aRect( aLbBitmaps.GetPosPixel(), aLbBitmaps.GetSizePixel() );
     652             :             if( sal_True ) {                // ??? overlapped with pDlg
     653             :                                         // and srolling
     654             :                 Invalidate( aRect );
     655             :                 //aLbBitmaps.Invalidate();
     656             :             }
     657             : #endif
     658             : 
     659           0 :             *pnBitmapListState |= CT_MODIFIED;
     660             : 
     661           0 :             ChangeBitmapHdl_Impl( this );
     662             :         }
     663             :     }
     664             : 
     665             :     // determine button state
     666           0 :     if( pBitmapList->Count() )
     667             :     {
     668           0 :         aBtnModify.Enable();
     669           0 :         aBtnDelete.Enable();
     670           0 :         aBtnSave.Enable();
     671             :     }
     672           0 :     return 0L;
     673             : }
     674             : 
     675             : 
     676             : /******************************************************************************/
     677             : /******************************************************************************/
     678             : 
     679             : 
     680             : //------------------------------------------------------------------------
     681             : 
     682             : #ifdef _MSC_VER
     683             : #pragma optimize ( "", off )
     684             : #endif
     685             : 
     686           0 : IMPL_LINK_NOARG(SvxBitmapTabPage, ClickImportHdl_Impl)
     687             : {
     688           0 :     ResMgr& rMgr = CUI_MGR();
     689           0 :     SvxOpenGraphicDialog aDlg( OUString("Import") );
     690           0 :     aDlg.EnableLink(sal_False);
     691             : 
     692           0 :     if( !aDlg.Execute() )
     693             :     {
     694           0 :         Graphic         aGraphic;
     695           0 :         int             nError = 1;
     696             : 
     697           0 :         EnterWait();
     698           0 :         nError = aDlg.GetGraphic( aGraphic );
     699           0 :         LeaveWait();
     700             : 
     701           0 :         if( !nError )
     702             :         {
     703           0 :             String aDesc( ResId(RID_SVXSTR_DESC_EXT_BITMAP, rMgr) );
     704           0 :             WarningBox*    pWarnBox = NULL;
     705             : 
     706             :             // convert file URL to UI name
     707           0 :             String          aName;
     708           0 :             INetURLObject   aURL( aDlg.GetPath() );
     709           0 :             SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     710             :             DBG_ASSERT(pFact, "Dialogdiet fail!");
     711           0 :             AbstractSvxNameDialog* pDlg = pFact->CreateSvxNameDialog( GetParentDialog(), String(aURL.GetName()).GetToken( 0, '.' ), aDesc );
     712             :             DBG_ASSERT(pDlg, "Dialogdiet fail!");
     713           0 :             nError = RID_SVXSTR_WARN_NAME_DUPLICATE;
     714             : 
     715           0 :             while( pDlg->Execute() == RET_OK )
     716             :             {
     717           0 :                 pDlg->GetName( aName );
     718             : 
     719           0 :                 sal_Bool bDifferent = sal_True;
     720           0 :                 long nCount     = pBitmapList->Count();
     721             : 
     722           0 :                 for( long i = 0; i < nCount && bDifferent; i++ )
     723           0 :                     if( aName == pBitmapList->GetBitmap( i )->GetName() )
     724           0 :                         bDifferent = sal_False;
     725             : 
     726           0 :                 if( bDifferent ) {
     727           0 :                     nError = 0;
     728           0 :                     break;
     729             :                 }
     730             : 
     731           0 :                 if( !pWarnBox )
     732             :                 {
     733           0 :                     pWarnBox = new WarningBox( GetParentDialog(),
     734             :                                                WinBits( WB_OK_CANCEL ),
     735           0 :                                                String( ResId( nError, rMgr ) ) );
     736           0 :                     pWarnBox->SetHelpId( HID_WARN_NAME_DUPLICATE );
     737             :                 }
     738             : 
     739             : 
     740           0 :                 if( pWarnBox->Execute() != RET_OK )
     741           0 :                     break;
     742             :             }
     743           0 :             delete pDlg;
     744           0 :             delete pWarnBox;
     745             : 
     746           0 :             if( !nError )
     747             :             {
     748           0 :                 Bitmap aBmp( aGraphic.GetBitmap() );
     749             :                 XBitmapEntry* pEntry =
     750           0 :                     new XBitmapEntry( XOBitmap( aBmp ), aName );
     751           0 :                 pBitmapList->Insert( pEntry );
     752             : 
     753           0 :                 aLbBitmaps.Append( pEntry );
     754           0 :                 aLbBitmaps.SelectEntryPos( aLbBitmaps.GetEntryCount() - 1 );
     755             : 
     756             : #ifdef WNT
     757             :                 // hack: #31355# W.P.
     758             :                 Rectangle aRect( aLbBitmaps.GetPosPixel(), aLbBitmaps.GetSizePixel() );
     759             :                 if( sal_True ) {                // ??? overlapped with pDlg
     760             :                                             // and srolling
     761             :                     Invalidate( aRect );
     762             :                 }
     763             : #endif
     764             : 
     765           0 :                 *pnBitmapListState |= CT_MODIFIED;
     766             : 
     767           0 :                 ChangeBitmapHdl_Impl( this );
     768           0 :             }
     769             :         }
     770             :         else
     771             :             // graphic couldn't be loaded
     772           0 :             ErrorBox( GetParentDialog(),
     773             :                       WinBits( WB_OK ),
     774           0 :                       String( ResId( RID_SVXSTR_READ_DATA_ERROR, rMgr ) ) ).Execute();
     775             :     }
     776             : 
     777           0 :     return 0L;
     778             : }
     779             : 
     780             : #ifdef _MSC_VER
     781             : #pragma optimize ( "", on )
     782             : #endif
     783             : 
     784             : //------------------------------------------------------------------------
     785             : 
     786           0 : IMPL_LINK_NOARG(SvxBitmapTabPage, ClickModifyHdl_Impl)
     787             : {
     788           0 :     sal_uInt16 nPos = aLbBitmaps.GetSelectEntryPos();
     789             : 
     790           0 :     if ( nPos != LISTBOX_ENTRY_NOTFOUND )
     791             :     {
     792           0 :         ResMgr& rMgr = CUI_MGR();
     793           0 :         String aNewName( SVX_RES( RID_SVXSTR_BITMAP ) );
     794           0 :         String aDesc( ResId( RID_SVXSTR_DESC_NEW_BITMAP, rMgr ) );
     795           0 :         String aName( pBitmapList->GetBitmap( nPos )->GetName() );
     796           0 :         String aOldName = aName;
     797             : 
     798           0 :         SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     799             :         DBG_ASSERT(pFact, "Dialogdiet fail!");
     800           0 :         AbstractSvxNameDialog* pDlg = pFact->CreateSvxNameDialog( GetParentDialog(), aName, aDesc );
     801             :         DBG_ASSERT(pDlg, "Dialogdiet fail!");
     802             : 
     803           0 :         long nCount = pBitmapList->Count();
     804           0 :         sal_Bool bDifferent = sal_False;
     805           0 :         sal_Bool bLoop = sal_True;
     806             : 
     807           0 :         while( bLoop && pDlg->Execute() == RET_OK )
     808             :         {
     809           0 :             pDlg->GetName( aName );
     810           0 :             bDifferent = sal_True;
     811             : 
     812           0 :             for( long i = 0; i < nCount && bDifferent; i++ )
     813             :             {
     814           0 :                 if( aName == pBitmapList->GetBitmap( i )->GetName() &&
     815           0 :                     aName != aOldName )
     816           0 :                     bDifferent = sal_False;
     817             :             }
     818             : 
     819           0 :             if( bDifferent )
     820             :             {
     821           0 :                 bLoop = sal_False;
     822           0 :                 XBitmapEntry* pEntry = pBitmapList->GetBitmap( nPos );
     823             : 
     824           0 :                 pEntry->SetName( aName );
     825             : 
     826           0 :                 XOBitmap aXOBitmap = aBitmapCtl.GetXBitmap();
     827             : 
     828             :                 // #85339# if it's an array, force conversion to bitmap before using it.
     829           0 :                 if(aXOBitmap.GetBitmapType() == XBITMAP_8X8)
     830           0 :                     aXOBitmap.GetBitmap();
     831             : 
     832           0 :                 pEntry->SetXBitmap( aXOBitmap );
     833             : 
     834           0 :                 aLbBitmaps.Modify( pEntry, nPos );
     835           0 :                 aLbBitmaps.SelectEntryPos( nPos );
     836             : 
     837           0 :                 *pnBitmapListState |= CT_MODIFIED;
     838             : 
     839           0 :                 bBmpChanged = sal_False;
     840             :             }
     841             :             else
     842             :             {
     843           0 :                 WarningBox aBox( GetParentDialog(), WinBits( WB_OK ), String( ResId( RID_SVXSTR_WARN_NAME_DUPLICATE, rMgr ) ) );
     844           0 :                 aBox.SetHelpId( HID_WARN_NAME_DUPLICATE );
     845           0 :                 aBox.Execute();
     846             :             }
     847             :         }
     848           0 :         delete pDlg;
     849             :     }
     850           0 :     return 0L;
     851             : }
     852             : 
     853             : //------------------------------------------------------------------------
     854             : 
     855           0 : IMPL_LINK_NOARG(SvxBitmapTabPage, ClickDeleteHdl_Impl)
     856             : {
     857           0 :     sal_uInt16 nPos = aLbBitmaps.GetSelectEntryPos();
     858             : 
     859           0 :     if( nPos != LISTBOX_ENTRY_NOTFOUND )
     860             :     {
     861           0 :         QueryBox aQueryBox( GetParentDialog(), WinBits( WB_YES_NO | WB_DEF_NO ),
     862           0 :             String( CUI_RES( RID_SVXSTR_ASK_DEL_BITMAP ) ) );
     863             : 
     864           0 :         if( aQueryBox.Execute() == RET_YES )
     865             :         {
     866           0 :             delete pBitmapList->Remove( nPos );
     867           0 :             aLbBitmaps.RemoveEntry( nPos );
     868           0 :             aLbBitmaps.SelectEntryPos( 0 );
     869             : 
     870           0 :             aCtlPreview.Invalidate();
     871           0 :             aCtlPixel.Invalidate();
     872             : 
     873           0 :             ChangeBitmapHdl_Impl( this );
     874             : 
     875           0 :             *pnBitmapListState |= CT_MODIFIED;
     876           0 :         }
     877             :     }
     878             :     // determine button state
     879           0 :     if( !pBitmapList->Count() )
     880             :     {
     881           0 :         aBtnModify.Disable();
     882           0 :         aBtnDelete.Disable();
     883           0 :         aBtnSave.Disable();
     884             :     }
     885           0 :     return 0L;
     886             : }
     887             : 
     888             : // -----------------------------------------------------------------------
     889             : 
     890           0 : IMPL_LINK_NOARG(SvxBitmapTabPage, ClickLoadHdl_Impl)
     891             : {
     892           0 :     sal_uInt16 nReturn = RET_YES;
     893           0 :     ResMgr& rMgr = CUI_MGR();
     894             : 
     895           0 :     if ( *pnBitmapListState & CT_MODIFIED )
     896             :     {
     897           0 :         nReturn = WarningBox( GetParentDialog(), WinBits( WB_YES_NO_CANCEL ),
     898           0 :             String( ResId( RID_SVXSTR_WARN_TABLE_OVERWRITE, rMgr ) ) ).Execute();
     899             : 
     900           0 :         if ( nReturn == RET_YES )
     901           0 :             pBitmapList->Save();
     902             :     }
     903             : 
     904           0 :     if ( nReturn != RET_CANCEL )
     905             :     {
     906             :         ::sfx2::FileDialogHelper aDlg(
     907             :             com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
     908           0 :             0 );
     909           0 :         String aStrFilterType( "*.sob" );
     910           0 :         aDlg.AddFilter( aStrFilterType, aStrFilterType );
     911           0 :         INetURLObject aFile( SvtPathOptions().GetPalettePath() );
     912           0 :         aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) );
     913             : 
     914           0 :         if ( aDlg.Execute() == ERRCODE_NONE )
     915             :         {
     916           0 :             EnterWait();
     917           0 :             INetURLObject aURL( aDlg.GetPath() );
     918           0 :             INetURLObject aPathURL( aURL );
     919             : 
     920           0 :             aPathURL.removeSegment();
     921           0 :             aPathURL.removeFinalSlash();
     922             : 
     923             :             // save table
     924             :             XBitmapListRef pBmpList = XPropertyList::CreatePropertyList(
     925           0 :                 XBITMAP_LIST, aPathURL.GetMainURL( INetURLObject::NO_DECODE ), pXPool )->AsBitmapList();
     926           0 :             pBmpList->SetName( aURL.getName() );
     927           0 :             if( pBmpList->Load() )
     928             :             {
     929           0 :                 pBitmapList = pBmpList;
     930           0 :                 ( (SvxAreaTabDialog*) GetParentDialog() )->SetNewBitmapList( pBitmapList );
     931             : 
     932           0 :                 aLbBitmaps.Clear();
     933           0 :                 aLbBitmaps.Fill( pBitmapList );
     934           0 :                 Reset( rOutAttrs );
     935             : 
     936           0 :                 pBitmapList->SetName( aURL.getName() );
     937             : 
     938             :                 // determining (possibly cutting) the name
     939             :                 // displaying it in the GroupBox
     940           0 :                 String aString( ResId( RID_SVXSTR_TABLE, rMgr ) );
     941           0 :                 aString.AppendAscii( ": " );
     942             : 
     943           0 :                 if ( aURL.getBase().getLength() > 18 )
     944             :                 {
     945           0 :                     aString += String(aURL.getBase()).Copy( 0, 15 );
     946           0 :                     aString.AppendAscii( "..." );
     947             :                 }
     948             :                 else
     949           0 :                     aString += String(aURL.getBase());
     950             : 
     951           0 :                 *pnBitmapListState |= CT_CHANGED;
     952           0 :                 *pnBitmapListState &= ~CT_MODIFIED;
     953           0 :                 LeaveWait();
     954             :             }
     955             :             else
     956             :             {
     957           0 :                 LeaveWait();
     958           0 :                 ErrorBox( GetParentDialog(), WinBits( WB_OK ),
     959           0 :                     String( ResId( RID_SVXSTR_READ_DATA_ERROR, rMgr ) ) ).Execute();
     960           0 :             }
     961           0 :         }
     962             :     }
     963             : 
     964             :     // determine button state
     965           0 :     if( pBitmapList->Count() )
     966             :     {
     967           0 :         aBtnModify.Enable();
     968           0 :         aBtnDelete.Enable();
     969           0 :         aBtnSave.Enable();
     970             :     }
     971             :     else
     972             :     {
     973           0 :         aBtnModify.Disable();
     974           0 :         aBtnDelete.Disable();
     975           0 :         aBtnSave.Disable();
     976             :     }
     977           0 :     return 0L;
     978             : }
     979             : 
     980             : // -----------------------------------------------------------------------
     981             : 
     982           0 : IMPL_LINK_NOARG(SvxBitmapTabPage, ClickSaveHdl_Impl)
     983             : {
     984             :        ::sfx2::FileDialogHelper aDlg(
     985           0 :         com::sun::star::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE, 0 );
     986           0 :     String aStrFilterType( "*.sob" );
     987           0 :     aDlg.AddFilter( aStrFilterType, aStrFilterType );
     988             : 
     989           0 :     INetURLObject aFile( SvtPathOptions().GetPalettePath() );
     990             :     DBG_ASSERT( aFile.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
     991             : 
     992           0 :     if( pBitmapList->GetName().Len() )
     993             :     {
     994           0 :         aFile.Append( pBitmapList->GetName() );
     995             : 
     996           0 :         if( aFile.getExtension().isEmpty() )
     997           0 :             aFile.SetExtension( OUString("sob") );
     998             :     }
     999             : 
    1000           0 :     aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) );
    1001           0 :     if ( aDlg.Execute() == ERRCODE_NONE )
    1002             :     {
    1003           0 :         INetURLObject   aURL( aDlg.GetPath() );
    1004           0 :         INetURLObject   aPathURL( aURL );
    1005             : 
    1006           0 :         aPathURL.removeSegment();
    1007           0 :         aPathURL.removeFinalSlash();
    1008             : 
    1009           0 :         pBitmapList->SetName( aURL.getName() );
    1010           0 :         pBitmapList->SetPath( aPathURL.GetMainURL( INetURLObject::NO_DECODE ) );
    1011             : 
    1012           0 :         if( pBitmapList->Save() )
    1013             :         {
    1014             :             // determining (possibly cutting) the name
    1015             :             // displaying it in the GroupBox
    1016           0 :             String aString( CUI_RES( RID_SVXSTR_TABLE ) );
    1017           0 :             aString.AppendAscii( ": " );
    1018             : 
    1019           0 :             if ( aURL.getBase().getLength() > 18 )
    1020             :             {
    1021           0 :                 aString += String(aURL.getBase()).Copy( 0, 15 );
    1022           0 :                 aString.AppendAscii( "..." );
    1023             :             }
    1024             :             else
    1025           0 :                 aString += String(aURL.getBase());
    1026             : 
    1027           0 :             *pnBitmapListState |= CT_SAVED;
    1028           0 :             *pnBitmapListState &= ~CT_MODIFIED;
    1029             :         }
    1030             :         else
    1031             :         {
    1032           0 :             ErrorBox( GetParentDialog(), WinBits( WB_OK ),
    1033           0 :                 String( CUI_RES( RID_SVXSTR_WRITE_DATA_ERROR ) ) ).Execute();
    1034           0 :         }
    1035             :     }
    1036             : 
    1037           0 :     return 0L;
    1038             : }
    1039             : 
    1040             : //------------------------------------------------------------------------
    1041             : 
    1042           0 : IMPL_LINK_NOARG(SvxBitmapTabPage, ChangePixelColorHdl_Impl)
    1043             : {
    1044           0 :     aCtlPixel.SetPixelColor( aLbColor.GetSelectEntryColor() );
    1045           0 :     aCtlPixel.Invalidate();
    1046             : 
    1047           0 :     aBitmapCtl.SetPixelColor( aLbColor.GetSelectEntryColor() );
    1048             : 
    1049             :     // get bitmap and display it
    1050           0 :     rXFSet.Put( XFillBitmapItem( String(), aBitmapCtl.GetXBitmap() ) );
    1051           0 :     aCtlPreview.SetAttributes( aXFillAttr.GetItemSet() );
    1052           0 :     aCtlPreview.Invalidate();
    1053             : 
    1054           0 :     bBmpChanged = sal_True;
    1055             : 
    1056           0 :     return 0L;
    1057             : }
    1058             : 
    1059             : //------------------------------------------------------------------------
    1060             : 
    1061           0 : IMPL_LINK_NOARG(SvxBitmapTabPage, ChangeBackgrndColorHdl_Impl)
    1062             : {
    1063           0 :     aCtlPixel.SetBackgroundColor( aLbBackgroundColor.GetSelectEntryColor() );
    1064           0 :     aCtlPixel.Invalidate();
    1065             : 
    1066           0 :     aBitmapCtl.SetBackgroundColor( aLbBackgroundColor.GetSelectEntryColor() );
    1067             : 
    1068             :     // get bitmap and display it
    1069           0 :     rXFSet.Put( XFillBitmapItem( String(), aBitmapCtl.GetXBitmap() ) );
    1070           0 :     aCtlPreview.SetAttributes( aXFillAttr.GetItemSet() );
    1071           0 :     aCtlPreview.Invalidate();
    1072             : 
    1073           0 :     bBmpChanged = sal_True;
    1074             : 
    1075           0 :     return 0L;
    1076             : }
    1077             : 
    1078             : //------------------------------------------------------------------------
    1079             : 
    1080           0 : void SvxBitmapTabPage::PointChanged( Window* pWindow, RECT_POINT )
    1081             : {
    1082           0 :     if( pWindow == &aCtlPixel )
    1083             :     {
    1084           0 :         aBitmapCtl.SetBmpArray( aCtlPixel.GetBitmapPixelPtr() );
    1085             : 
    1086             :         // get bitmap and display it
    1087           0 :         rXFSet.Put( XFillBitmapItem( String(), aBitmapCtl.GetXBitmap() ) );
    1088           0 :         aCtlPreview.SetAttributes( aXFillAttr.GetItemSet() );
    1089           0 :         aCtlPreview.Invalidate();
    1090             : 
    1091           0 :         bBmpChanged = sal_True;
    1092             :     }
    1093           0 : }
    1094             : 
    1095             : 
    1096             : 
    1097             : 
    1098           0 : Window* SvxBitmapTabPage::GetParentLabeledBy( const Window* pLabeled ) const
    1099             : {
    1100           0 :     if (pLabeled == &aLbBitmaps)
    1101           0 :         return const_cast<FixedText*>(&aLbBitmapsHidden);
    1102             :     else
    1103           0 :         return SvxTabPage::GetParentLabeledBy (pLabeled);
    1104           6 : }
    1105             : 
    1106             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10