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