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