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