12ee96f1cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
32ee96f1cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
42ee96f1cSAndrew Rist * or more contributor license agreements. See the NOTICE file
52ee96f1cSAndrew Rist * distributed with this work for additional information
62ee96f1cSAndrew Rist * regarding copyright ownership. The ASF licenses this file
72ee96f1cSAndrew Rist * to you under the Apache License, Version 2.0 (the
82ee96f1cSAndrew Rist * "License"); you may not use this file except in compliance
92ee96f1cSAndrew Rist * with the License. You may obtain a copy of the License at
102ee96f1cSAndrew Rist *
112ee96f1cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
122ee96f1cSAndrew Rist *
132ee96f1cSAndrew Rist * Unless required by applicable law or agreed to in writing,
142ee96f1cSAndrew Rist * software distributed under the License is distributed on an
152ee96f1cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
162ee96f1cSAndrew Rist * KIND, either express or implied. See the License for the
172ee96f1cSAndrew Rist * specific language governing permissions and limitations
182ee96f1cSAndrew Rist * under the License.
192ee96f1cSAndrew Rist *
202ee96f1cSAndrew Rist *************************************************************/
212ee96f1cSAndrew Rist
222ee96f1cSAndrew 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
SvxBitmapTabPage(Window * pParent,const SfxItemSet & rInAttrs)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
110c7be74b1SArmin Le Grand maColorTab(),
111c7be74b1SArmin Le Grand maBitmapList(),
112cdf0e10cSrcweir
113cdf0e10cSrcweir pXPool ( (XOutdevItemPool*) rInAttrs.GetPool() ),
114cdf0e10cSrcweir aXFStyleItem ( XFILL_BITMAP ),
11570d3707aSArmin Le Grand aXBitmapItem ( String(), Graphic() ),
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
Construct()162cdf0e10cSrcweir void SvxBitmapTabPage::Construct()
163cdf0e10cSrcweir {
164cdf0e10cSrcweir // Farbtabellen
165c7be74b1SArmin Le Grand aLbColor.Fill( maColorTab );
166cdf0e10cSrcweir aLbBackgroundColor.CopyEntries( aLbColor );
167cdf0e10cSrcweir
168cdf0e10cSrcweir // Bitmaptabelle
169c7be74b1SArmin Le Grand aLbBitmaps.Fill( maBitmapList );
170cdf0e10cSrcweir }
171cdf0e10cSrcweir
172cdf0e10cSrcweir // -----------------------------------------------------------------------
173cdf0e10cSrcweir
ActivatePage(const SfxItemSet &)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
183c7be74b1SArmin Le Grand if( maColorTab.get() )
184cdf0e10cSrcweir {
185cdf0e10cSrcweir // ColorTable
186cdf0e10cSrcweir if( *pnColorTableState & CT_CHANGED ||
187cdf0e10cSrcweir *pnColorTableState & CT_MODIFIED )
188cdf0e10cSrcweir {
189cdf0e10cSrcweir if( *pnColorTableState & CT_CHANGED )
190c7be74b1SArmin Le Grand maColorTab = ( (SvxAreaTabDialog*) DLGWIN )->GetNewColorTable();
191cdf0e10cSrcweir
192cdf0e10cSrcweir // LbColor
193cdf0e10cSrcweir nPos = aLbColor.GetSelectEntryPos();
194cdf0e10cSrcweir aLbColor.Clear();
195c7be74b1SArmin Le Grand aLbColor.Fill( maColorTab );
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( ": " ) );
223c7be74b1SArmin Le Grand INetURLObject aURL( maBitmapList->GetPath() );
224cdf0e10cSrcweir
225c7be74b1SArmin Le Grand aURL.Append( maBitmapList->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
DeactivatePage(SfxItemSet * _pSet)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
FillItemSet(SfxItemSet & _rOutAttrs)264cdf0e10cSrcweir sal_Bool SvxBitmapTabPage::FillItemSet( SfxItemSet& _rOutAttrs )
265cdf0e10cSrcweir {
266cdf0e10cSrcweir if( *pDlgType == 0 && *pbAreaTP == sal_False ) // Flaechen-Dialog
267cdf0e10cSrcweir {
26870d3707aSArmin Le Grand if(PT_BITMAP == *pPageType)
269cdf0e10cSrcweir {
27070d3707aSArmin Le Grand const sal_uInt16 nPos(aLbBitmaps.GetSelectEntryPos());
27170d3707aSArmin Le Grand
27270d3707aSArmin Le Grand _rOutAttrs.Put(XFillStyleItem(XFILL_BITMAP));
27370d3707aSArmin Le Grand
27470d3707aSArmin Le Grand if(LISTBOX_ENTRY_NOTFOUND != nPos)
275cdf0e10cSrcweir {
276c7be74b1SArmin Le Grand const XBitmapEntry* pXBitmapEntry = maBitmapList->GetBitmap(nPos);
27770d3707aSArmin Le Grand const String aString(aLbBitmaps.GetSelectEntry());
27870d3707aSArmin Le Grand
27970d3707aSArmin Le Grand _rOutAttrs.Put(XFillBitmapItem(aString, pXBitmapEntry->GetGraphicObject()));
280cdf0e10cSrcweir }
281cdf0e10cSrcweir else
282cdf0e10cSrcweir {
28370d3707aSArmin Le Grand const BitmapEx aBitmapEx(aBitmapCtl.GetBitmapEx());
284cdf0e10cSrcweir
28570d3707aSArmin Le Grand _rOutAttrs.Put(XFillBitmapItem(String(), Graphic(aBitmapEx)));
286cdf0e10cSrcweir }
287cdf0e10cSrcweir }
288cdf0e10cSrcweir }
28970d3707aSArmin Le Grand
29070d3707aSArmin Le Grand return sal_True;
291cdf0e10cSrcweir }
292cdf0e10cSrcweir
293cdf0e10cSrcweir // -----------------------------------------------------------------------
294cdf0e10cSrcweir
Reset(const SfxItemSet &)295cdf0e10cSrcweir void SvxBitmapTabPage::Reset( const SfxItemSet& )
296cdf0e10cSrcweir {
297cdf0e10cSrcweir // aLbBitmaps.SelectEntryPos( 0 );
298cdf0e10cSrcweir
299cdf0e10cSrcweir aBitmapCtl.SetLines( aCtlPixel.GetLineCount() );
300cdf0e10cSrcweir aBitmapCtl.SetPixelColor( aLbColor.GetSelectEntryColor() );
301cdf0e10cSrcweir aBitmapCtl.SetBackgroundColor( aLbBackgroundColor.GetSelectEntryColor() );
302cdf0e10cSrcweir aBitmapCtl.SetBmpArray( aCtlPixel.GetBitmapPixelPtr() );
303cdf0e10cSrcweir
304cdf0e10cSrcweir // Bitmap holen und darstellen
30570d3707aSArmin Le Grand const XFillBitmapItem aBmpItem(String(), Graphic(aBitmapCtl.GetBitmapEx()));
306cdf0e10cSrcweir rXFSet.Put( aBmpItem );
307cdf0e10cSrcweir aCtlPreview.SetAttributes( aXFillAttr.GetItemSet() );
308cdf0e10cSrcweir aCtlPreview.Invalidate();
309cdf0e10cSrcweir
310cdf0e10cSrcweir ChangeBitmapHdl_Impl( this );
311cdf0e10cSrcweir
312cdf0e10cSrcweir // Status der Buttons ermitteln
313c7be74b1SArmin Le Grand if( maBitmapList.get() && maBitmapList->Count() )
314cdf0e10cSrcweir {
315cdf0e10cSrcweir aBtnAdd.Enable();
316cdf0e10cSrcweir aBtnModify.Enable();
317cdf0e10cSrcweir aBtnDelete.Enable();
318cdf0e10cSrcweir aBtnSave.Enable();
319cdf0e10cSrcweir }
320cdf0e10cSrcweir else
321cdf0e10cSrcweir {
322cdf0e10cSrcweir aBtnModify.Disable();
323cdf0e10cSrcweir aBtnDelete.Disable();
324cdf0e10cSrcweir aBtnSave.Disable();
325cdf0e10cSrcweir }
326cdf0e10cSrcweir }
327cdf0e10cSrcweir
328cdf0e10cSrcweir // -----------------------------------------------------------------------
329cdf0e10cSrcweir
Create(Window * pWindow,const SfxItemSet & rSet)330cdf0e10cSrcweir SfxTabPage* SvxBitmapTabPage::Create( Window* pWindow,
331cdf0e10cSrcweir const SfxItemSet& rSet )
332cdf0e10cSrcweir {
333cdf0e10cSrcweir return new SvxBitmapTabPage( pWindow, rSet );
334cdf0e10cSrcweir }
335cdf0e10cSrcweir
336cdf0e10cSrcweir //------------------------------------------------------------------------
337cdf0e10cSrcweir
IMPL_LINK(SvxBitmapTabPage,ChangeBitmapHdl_Impl,void *,EMPTYARG)338cdf0e10cSrcweir IMPL_LINK( SvxBitmapTabPage, ChangeBitmapHdl_Impl, void *, EMPTYARG )
339cdf0e10cSrcweir {
34070d3707aSArmin Le Grand GraphicObject* pGraphicObject = 0;
34170d3707aSArmin Le Grand int nPos(aLbBitmaps.GetSelectEntryPos());
342cdf0e10cSrcweir
34370d3707aSArmin Le Grand if(LISTBOX_ENTRY_NOTFOUND != nPos)
34470d3707aSArmin Le Grand {
345c7be74b1SArmin Le Grand pGraphicObject = new GraphicObject(maBitmapList->GetBitmap(nPos)->GetGraphicObject());
34670d3707aSArmin Le Grand }
347cdf0e10cSrcweir else
348cdf0e10cSrcweir {
34970d3707aSArmin Le Grand const SfxPoolItem* pPoolItem = 0;
35070d3707aSArmin Le Grand
35170d3707aSArmin Le Grand if(SFX_ITEM_SET == rOutAttrs.GetItemState(GetWhich(XATTR_FILLSTYLE), true, &pPoolItem))
352cdf0e10cSrcweir {
35370d3707aSArmin Le Grand const XFillStyle eXFS((XFillStyle)((const XFillStyleItem*)pPoolItem)->GetValue());
35470d3707aSArmin Le Grand
35570d3707aSArmin Le Grand if((XFILL_BITMAP == eXFS) && (SFX_ITEM_SET == rOutAttrs.GetItemState(GetWhich(XATTR_FILLBITMAP), true, &pPoolItem)))
356cdf0e10cSrcweir {
35770d3707aSArmin Le Grand pGraphicObject = new GraphicObject(((const XFillBitmapItem*)pPoolItem)->GetGraphicObject());
358cdf0e10cSrcweir }
359cdf0e10cSrcweir }
36070d3707aSArmin Le Grand
36170d3707aSArmin Le Grand if(!pGraphicObject)
362cdf0e10cSrcweir {
36370d3707aSArmin Le Grand aLbBitmaps.SelectEntryPos(0);
364cdf0e10cSrcweir nPos = aLbBitmaps.GetSelectEntryPos();
36570d3707aSArmin Le Grand
36670d3707aSArmin Le Grand if(LISTBOX_ENTRY_NOTFOUND != nPos)
36770d3707aSArmin Le Grand {
368c7be74b1SArmin Le Grand pGraphicObject = new GraphicObject(maBitmapList->GetBitmap(nPos)->GetGraphicObject());
36970d3707aSArmin Le Grand }
370cdf0e10cSrcweir }
371cdf0e10cSrcweir }
372cdf0e10cSrcweir
37370d3707aSArmin Le Grand if(pGraphicObject)
37470d3707aSArmin Le Grand {
37570d3707aSArmin Le Grand BitmapColor aBack;
37670d3707aSArmin Le Grand BitmapColor aFront;
37770d3707aSArmin Le Grand bool bIs8x8(isHistorical8x8(pGraphicObject->GetGraphic().GetBitmap(), aBack, aFront));
378cdf0e10cSrcweir
37970d3707aSArmin Le Grand aLbColor.SetNoSelection();
380cdf0e10cSrcweir aLbBackgroundColor.SetNoSelection();
381cdf0e10cSrcweir
38270d3707aSArmin Le Grand if(bIs8x8)
383cdf0e10cSrcweir {
384cdf0e10cSrcweir aCtlPixel.SetPaintable( sal_True );
385cdf0e10cSrcweir aCtlPixel.Enable();
386cdf0e10cSrcweir aFtPixelEdit.Enable();
387cdf0e10cSrcweir aFtColor.Enable();
388cdf0e10cSrcweir aLbColor.Enable();
389cdf0e10cSrcweir aFtBackgroundColor.Enable();
390cdf0e10cSrcweir aLbBackgroundColor.Enable();
391cdf0e10cSrcweir aBtnModify.Enable();
392cdf0e10cSrcweir aBtnAdd.Enable();
393cdf0e10cSrcweir
394cdf0e10cSrcweir // Setzen des PixelControls
39570d3707aSArmin Le Grand aCtlPixel.SetXBitmap(pGraphicObject->GetGraphic().GetBitmapEx());
396cdf0e10cSrcweir
39770d3707aSArmin Le Grand Color aPixelColor = aFront;
39870d3707aSArmin Le Grand Color aBackColor = aBack;
399cdf0e10cSrcweir
400*1f69a0e2SArmin Le Grand // #123564# This causes the wrong color to be selected
401*1f69a0e2SArmin Le Grand // as foreground color when the 1st bitmap in the bitmap
402*1f69a0e2SArmin Le Grand // list is selected. I see no reason why this is done,
403*1f69a0e2SArmin Le Grand // thus I will take it out
404*1f69a0e2SArmin Le Grand //
405*1f69a0e2SArmin Le Grand //if( 0 == aLbBitmaps.GetSelectEntryPos() )
406*1f69a0e2SArmin Le Grand //{
407*1f69a0e2SArmin Le Grand // aLbColor.SelectEntry( Color( COL_BLACK ) );
408*1f69a0e2SArmin Le Grand // ChangePixelColorHdl_Impl( this );
409*1f69a0e2SArmin Le Grand //}
410*1f69a0e2SArmin Le Grand //else
411*1f69a0e2SArmin Le Grand
412*1f69a0e2SArmin Le Grand aLbColor.SelectEntry( aPixelColor );
413*1f69a0e2SArmin Le Grand
414*1f69a0e2SArmin Le Grand if( aLbColor.GetSelectEntryCount() == 0 )
415*1f69a0e2SArmin Le Grand {
416*1f69a0e2SArmin Le Grand aLbColor.InsertEntry( aPixelColor, String() );
417*1f69a0e2SArmin Le Grand aLbColor.SelectEntry( aPixelColor );
418*1f69a0e2SArmin Le Grand }
419cdf0e10cSrcweir
420*1f69a0e2SArmin Le Grand aLbBackgroundColor.SelectEntry( aBackColor );
421*1f69a0e2SArmin Le Grand
422*1f69a0e2SArmin Le Grand if( aLbBackgroundColor.GetSelectEntryCount() == 0 )
423*1f69a0e2SArmin Le Grand {
424*1f69a0e2SArmin Le Grand aLbBackgroundColor.InsertEntry( aBackColor, String() );
425*1f69a0e2SArmin Le Grand aLbBackgroundColor.SelectEntry( aBackColor );
426*1f69a0e2SArmin Le Grand }
427*1f69a0e2SArmin Le Grand
428*1f69a0e2SArmin Le Grand // update aBitmapCtl, rXFSet and aCtlPreview
429*1f69a0e2SArmin Le Grand aBitmapCtl.SetPixelColor( aPixelColor );
430*1f69a0e2SArmin Le Grand aBitmapCtl.SetBackgroundColor( aBackColor );
431*1f69a0e2SArmin Le Grand rXFSet.Put(XFillBitmapItem(String(), Graphic(aBitmapCtl.GetBitmapEx())));
432*1f69a0e2SArmin Le Grand aCtlPreview.SetAttributes( aXFillAttr.GetItemSet() );
433*1f69a0e2SArmin Le Grand aCtlPreview.Invalidate();
434*1f69a0e2SArmin Le Grand }
43570d3707aSArmin Le Grand else
43670d3707aSArmin Le Grand {
43770d3707aSArmin Le Grand aCtlPixel.Reset();
43870d3707aSArmin Le Grand aCtlPixel.SetPaintable( sal_False );
43970d3707aSArmin Le Grand aCtlPixel.Disable();
44070d3707aSArmin Le Grand aFtPixelEdit.Disable();
44170d3707aSArmin Le Grand aFtColor.Disable();
44270d3707aSArmin Le Grand aLbColor.Disable();
44370d3707aSArmin Le Grand aFtBackgroundColor.Disable();
44470d3707aSArmin Le Grand aLbBackgroundColor.Disable();
44570d3707aSArmin Le Grand aBtnModify.Disable();
44670d3707aSArmin Le Grand aBtnAdd.Disable();
44770d3707aSArmin Le Grand }
44870d3707aSArmin Le Grand
44970d3707aSArmin Le Grand aCtlPixel.Invalidate();
450cdf0e10cSrcweir
451cdf0e10cSrcweir // Bitmap darstellen
45270d3707aSArmin Le Grand const XFillBitmapItem aXBmpItem(String(), *pGraphicObject);
453cdf0e10cSrcweir rXFSet.Put( aXBmpItem );
454cdf0e10cSrcweir
455cdf0e10cSrcweir aCtlPreview.SetAttributes( aXFillAttr.GetItemSet() );
456cdf0e10cSrcweir aCtlPreview.Invalidate();
457cdf0e10cSrcweir
458cdf0e10cSrcweir bBmpChanged = sal_False;
45970d3707aSArmin Le Grand delete pGraphicObject;
460cdf0e10cSrcweir }
46170d3707aSArmin Le Grand
46270d3707aSArmin Le Grand return 0;
463cdf0e10cSrcweir }
464cdf0e10cSrcweir
465cdf0e10cSrcweir // -----------------------------------------------------------------------
466cdf0e10cSrcweir
CheckChanges_Impl()467cdf0e10cSrcweir long SvxBitmapTabPage::CheckChanges_Impl()
468cdf0e10cSrcweir {
469cdf0e10cSrcweir sal_uInt16 nPos = aLbBitmaps.GetSelectEntryPos();
470cdf0e10cSrcweir if( nPos != LISTBOX_ENTRY_NOTFOUND )
471cdf0e10cSrcweir {
472cdf0e10cSrcweir String aString = aLbBitmaps.GetSelectEntry();
473cdf0e10cSrcweir
474cdf0e10cSrcweir if( bBmpChanged )
475cdf0e10cSrcweir {
476cdf0e10cSrcweir ResMgr& rMgr = CUI_MGR();
477cdf0e10cSrcweir Image aWarningBoxImage = WarningBox::GetStandardImage();
478cdf0e10cSrcweir SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
479cdf0e10cSrcweir DBG_ASSERT(pFact, "Dialogdiet fail!");//CHINA001
480cdf0e10cSrcweir AbstractSvxMessDialog* aMessDlg = pFact->CreateSvxMessDialog( DLGWIN, RID_SVXDLG_MESSBOX,
481cdf0e10cSrcweir String( SVX_RES( RID_SVXSTR_BITMAP ) ),
482cdf0e10cSrcweir String( CUI_RES( RID_SVXSTR_ASK_CHANGE_BITMAP ) ),
483cdf0e10cSrcweir &aWarningBoxImage );
484cdf0e10cSrcweir DBG_ASSERT(aMessDlg, "Dialogdiet fail!");//CHINA001
485cdf0e10cSrcweir aMessDlg->SetButtonText( MESS_BTN_1, //CHINA001 aMessDlg.SetButtonText( MESS_BTN_1,
486cdf0e10cSrcweir String( ResId( RID_SVXSTR_CHANGE, rMgr ) ) );
487cdf0e10cSrcweir aMessDlg->SetButtonText( MESS_BTN_2, //CHINA001 aMessDlg.SetButtonText( MESS_BTN_2,
488cdf0e10cSrcweir String( ResId( RID_SVXSTR_ADD, rMgr ) ) );
489cdf0e10cSrcweir
490cdf0e10cSrcweir short nRet = aMessDlg->Execute(); //CHINA001 short nRet = aMessDlg.Execute();
491cdf0e10cSrcweir
492cdf0e10cSrcweir switch( nRet )
493cdf0e10cSrcweir {
494cdf0e10cSrcweir case RET_BTN_1: // Aendern
495cdf0e10cSrcweir {
496cdf0e10cSrcweir ClickModifyHdl_Impl( this );
497cdf0e10cSrcweir }
498cdf0e10cSrcweir break;
499cdf0e10cSrcweir
500cdf0e10cSrcweir case RET_BTN_2: // Hinzufuegen
501cdf0e10cSrcweir {
502cdf0e10cSrcweir ClickAddHdl_Impl( this );
503cdf0e10cSrcweir nPos = aLbBitmaps.GetSelectEntryPos();
504cdf0e10cSrcweir }
505cdf0e10cSrcweir break;
506cdf0e10cSrcweir
507cdf0e10cSrcweir case RET_CANCEL:
508cdf0e10cSrcweir // return( -1L );
509cdf0e10cSrcweir break;
510cdf0e10cSrcweir // return( sal_True ); // Abbruch
511cdf0e10cSrcweir }
512cdf0e10cSrcweir delete aMessDlg; //add by CHINA001
513cdf0e10cSrcweir }
514cdf0e10cSrcweir }
515cdf0e10cSrcweir nPos = aLbBitmaps.GetSelectEntryPos();
516cdf0e10cSrcweir if( nPos != LISTBOX_ENTRY_NOTFOUND )
517cdf0e10cSrcweir *pPos = nPos;
518cdf0e10cSrcweir return 0L;
519cdf0e10cSrcweir }
520cdf0e10cSrcweir
521cdf0e10cSrcweir //------------------------------------------------------------------------
522cdf0e10cSrcweir
IMPL_LINK(SvxBitmapTabPage,ClickAddHdl_Impl,void *,EMPTYARG)523cdf0e10cSrcweir IMPL_LINK( SvxBitmapTabPage, ClickAddHdl_Impl, void *, EMPTYARG )
524cdf0e10cSrcweir {
525cdf0e10cSrcweir ResMgr& rMgr = CUI_MGR();
526cdf0e10cSrcweir String aNewName( SVX_RES( RID_SVXSTR_BITMAP ) );
527cdf0e10cSrcweir String aDesc( CUI_RES( RID_SVXSTR_DESC_NEW_BITMAP ) );
528cdf0e10cSrcweir String aName;
529cdf0e10cSrcweir
530c7be74b1SArmin Le Grand long nCount = maBitmapList.get() ? maBitmapList->Count() : 0;
531cdf0e10cSrcweir long j = 1;
532cdf0e10cSrcweir sal_Bool bDifferent = sal_False;
533cdf0e10cSrcweir
534cdf0e10cSrcweir while( !bDifferent )
535cdf0e10cSrcweir {
536cdf0e10cSrcweir aName = aNewName;
537cdf0e10cSrcweir aName += sal_Unicode(' ');
538cdf0e10cSrcweir aName += UniString::CreateFromInt32( j++ );
539cdf0e10cSrcweir bDifferent = sal_True;
540cdf0e10cSrcweir
541cdf0e10cSrcweir for( long i = 0; i < nCount && bDifferent; i++ )
542c7be74b1SArmin Le Grand if( aName == maBitmapList->GetBitmap( i )->GetName() )
543cdf0e10cSrcweir bDifferent = sal_False;
544cdf0e10cSrcweir }
545cdf0e10cSrcweir
546cdf0e10cSrcweir SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
547cdf0e10cSrcweir DBG_ASSERT(pFact, "Dialogdiet fail!");//CHINA001
548cdf0e10cSrcweir AbstractSvxNameDialog* pDlg = pFact->CreateSvxNameDialog( DLGWIN, aName, aDesc );
549cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
550cdf0e10cSrcweir WarningBox* pWarnBox = NULL;
551cdf0e10cSrcweir sal_uInt16 nError = RID_SVXSTR_WARN_NAME_DUPLICATE;
552cdf0e10cSrcweir
553cdf0e10cSrcweir while( pDlg->Execute() == RET_OK )
554cdf0e10cSrcweir {
555cdf0e10cSrcweir pDlg->GetName( aName );
556cdf0e10cSrcweir
557cdf0e10cSrcweir bDifferent = sal_True;
558cdf0e10cSrcweir
559cdf0e10cSrcweir for( long i = 0; i < nCount && bDifferent; i++ )
560c7be74b1SArmin Le Grand if( aName == maBitmapList->GetBitmap( i )->GetName() )
561cdf0e10cSrcweir bDifferent = sal_False;
562cdf0e10cSrcweir
563cdf0e10cSrcweir if( bDifferent ) {
564cdf0e10cSrcweir nError = 0;
565cdf0e10cSrcweir break;
566cdf0e10cSrcweir }
567cdf0e10cSrcweir
568cdf0e10cSrcweir if( !pWarnBox )
569cdf0e10cSrcweir {
570cdf0e10cSrcweir pWarnBox = new WarningBox( DLGWIN,
571cdf0e10cSrcweir WinBits( WB_OK_CANCEL ),
572cdf0e10cSrcweir String( ResId( nError, rMgr ) ) );
573cdf0e10cSrcweir pWarnBox->SetHelpId( HID_WARN_NAME_DUPLICATE );
574cdf0e10cSrcweir }
575cdf0e10cSrcweir
576cdf0e10cSrcweir if( pWarnBox->Execute() != RET_OK )
577cdf0e10cSrcweir break;
578cdf0e10cSrcweir }
5793e407bd8SArmin Le Grand
5803e407bd8SArmin Le Grand delete pDlg;
581cdf0e10cSrcweir delete pWarnBox;
582cdf0e10cSrcweir
583cdf0e10cSrcweir if( !nError )
584cdf0e10cSrcweir {
585cdf0e10cSrcweir XBitmapEntry* pEntry = 0;
586cdf0e10cSrcweir if( aCtlPixel.IsEnabled() )
587cdf0e10cSrcweir {
58870d3707aSArmin Le Grand const BitmapEx aBitmapEx(aBitmapCtl.GetBitmapEx());
589cdf0e10cSrcweir
59070d3707aSArmin Le Grand pEntry = new XBitmapEntry(Graphic(aBitmapEx), aName);
591cdf0e10cSrcweir }
592cdf0e10cSrcweir else // Es muss sich um eine nicht vorhandene importierte Bitmap handeln
593cdf0e10cSrcweir {
59470d3707aSArmin Le Grand const SfxPoolItem* pPoolItem = 0;
59570d3707aSArmin Le Grand
59670d3707aSArmin Le Grand if(SFX_ITEM_SET == rOutAttrs.GetItemState(XATTR_FILLBITMAP, true, &pPoolItem))
597cdf0e10cSrcweir {
59870d3707aSArmin Le Grand pEntry = new XBitmapEntry(dynamic_cast< const XFillBitmapItem* >(pPoolItem)->GetGraphicObject(), aName);
599cdf0e10cSrcweir }
600cdf0e10cSrcweir }
601cdf0e10cSrcweir
602cdf0e10cSrcweir DBG_ASSERT( pEntry, "SvxBitmapTabPage::ClickAddHdl_Impl(), pEntry == 0 ?" );
603cdf0e10cSrcweir
604cdf0e10cSrcweir if( pEntry )
605cdf0e10cSrcweir {
606c7be74b1SArmin Le Grand maBitmapList->Insert( pEntry );
607a68b38dfSArmin Le Grand const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
608a68b38dfSArmin Le Grand aLbBitmaps.Append(rStyleSettings.GetListBoxPreviewDefaultPixelSize(), *pEntry );
609cdf0e10cSrcweir aLbBitmaps.SelectEntryPos( aLbBitmaps.GetEntryCount() - 1 );
610cdf0e10cSrcweir
611cdf0e10cSrcweir // Flag fuer modifiziert setzen
612cdf0e10cSrcweir *pnBitmapListState |= CT_MODIFIED;
613cdf0e10cSrcweir
614cdf0e10cSrcweir ChangeBitmapHdl_Impl( this );
615cdf0e10cSrcweir }
616cdf0e10cSrcweir }
617cdf0e10cSrcweir
618cdf0e10cSrcweir // Status der Buttons ermitteln
619c7be74b1SArmin Le Grand if( maBitmapList.get() && maBitmapList->Count() )
620cdf0e10cSrcweir {
621cdf0e10cSrcweir aBtnModify.Enable();
622cdf0e10cSrcweir aBtnDelete.Enable();
623cdf0e10cSrcweir aBtnSave.Enable();
624cdf0e10cSrcweir }
625cdf0e10cSrcweir return 0L;
626cdf0e10cSrcweir }
627cdf0e10cSrcweir
628cdf0e10cSrcweir
629cdf0e10cSrcweir /******************************************************************************/
630cdf0e10cSrcweir /******************************************************************************/
631cdf0e10cSrcweir
632cdf0e10cSrcweir
633cdf0e10cSrcweir //------------------------------------------------------------------------
634cdf0e10cSrcweir
635cdf0e10cSrcweir #ifdef _MSC_VER
636cdf0e10cSrcweir #pragma optimize ( "", off )
637cdf0e10cSrcweir #endif
638cdf0e10cSrcweir
IMPL_LINK(SvxBitmapTabPage,ClickImportHdl_Impl,void *,EMPTYARG)639cdf0e10cSrcweir IMPL_LINK( SvxBitmapTabPage, ClickImportHdl_Impl, void *, EMPTYARG )
640cdf0e10cSrcweir {
641cdf0e10cSrcweir ResMgr& rMgr = CUI_MGR();
642cdf0e10cSrcweir SvxOpenGraphicDialog aDlg( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "Import" ) ) );
643cdf0e10cSrcweir aDlg.EnableLink(sal_False);
644cdf0e10cSrcweir
645cdf0e10cSrcweir if( !aDlg.Execute() )
646cdf0e10cSrcweir {
647cdf0e10cSrcweir Graphic aGraphic;
648cdf0e10cSrcweir int nError = 1;
649cdf0e10cSrcweir
650cdf0e10cSrcweir EnterWait();
651cdf0e10cSrcweir nError = aDlg.GetGraphic( aGraphic );
652cdf0e10cSrcweir LeaveWait();
653cdf0e10cSrcweir
654cdf0e10cSrcweir if( !nError )
655cdf0e10cSrcweir {
656cdf0e10cSrcweir String aDesc( ResId(RID_SVXSTR_DESC_EXT_BITMAP, rMgr) );
657cdf0e10cSrcweir WarningBox* pWarnBox = NULL;
658cdf0e10cSrcweir
659cdf0e10cSrcweir // convert file URL to UI name
660cdf0e10cSrcweir String aName;
661cdf0e10cSrcweir INetURLObject aURL( aDlg.GetPath() );
662cdf0e10cSrcweir SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
663cdf0e10cSrcweir DBG_ASSERT(pFact, "Dialogdiet fail!");//CHINA001
664cdf0e10cSrcweir AbstractSvxNameDialog* pDlg = pFact->CreateSvxNameDialog( DLGWIN, String(aURL.GetName()).GetToken( 0, '.' ), aDesc );
665cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
666cdf0e10cSrcweir nError = RID_SVXSTR_WARN_NAME_DUPLICATE;
667cdf0e10cSrcweir
668cdf0e10cSrcweir while( pDlg->Execute() == RET_OK )
669cdf0e10cSrcweir {
670cdf0e10cSrcweir pDlg->GetName( aName );
671cdf0e10cSrcweir
672cdf0e10cSrcweir sal_Bool bDifferent = sal_True;
673c7be74b1SArmin Le Grand long nCount = maBitmapList->Count();
674cdf0e10cSrcweir
675cdf0e10cSrcweir for( long i = 0; i < nCount && bDifferent; i++ )
676c7be74b1SArmin Le Grand if( aName == maBitmapList->GetBitmap( i )->GetName() )
677cdf0e10cSrcweir bDifferent = sal_False;
678cdf0e10cSrcweir
679cdf0e10cSrcweir if( bDifferent ) {
680cdf0e10cSrcweir nError = 0;
681cdf0e10cSrcweir break;
682cdf0e10cSrcweir }
683cdf0e10cSrcweir
684cdf0e10cSrcweir if( !pWarnBox )
685cdf0e10cSrcweir {
686cdf0e10cSrcweir pWarnBox = new WarningBox( DLGWIN,
687cdf0e10cSrcweir WinBits( WB_OK_CANCEL ),
688cdf0e10cSrcweir String( ResId( nError, rMgr ) ) );
689cdf0e10cSrcweir pWarnBox->SetHelpId( HID_WARN_NAME_DUPLICATE );
690cdf0e10cSrcweir }
691cdf0e10cSrcweir
692cdf0e10cSrcweir
693cdf0e10cSrcweir if( pWarnBox->Execute() != RET_OK )
694cdf0e10cSrcweir break;
695cdf0e10cSrcweir }
6963e407bd8SArmin Le Grand
6973e407bd8SArmin Le Grand delete pDlg;
698cdf0e10cSrcweir delete pWarnBox;
699cdf0e10cSrcweir
700cdf0e10cSrcweir if( !nError )
701cdf0e10cSrcweir {
70270d3707aSArmin Le Grand XBitmapEntry* pEntry = new XBitmapEntry( aGraphic, aName );
703c7be74b1SArmin Le Grand maBitmapList->Insert( pEntry );
704cdf0e10cSrcweir
705a68b38dfSArmin Le Grand const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
706a68b38dfSArmin Le Grand aLbBitmaps.Append(rStyleSettings.GetListBoxPreviewDefaultPixelSize(), *pEntry );
707cdf0e10cSrcweir aLbBitmaps.SelectEntryPos( aLbBitmaps.GetEntryCount() - 1 );
708cdf0e10cSrcweir
709cdf0e10cSrcweir // Flag fuer modifiziert setzen
710cdf0e10cSrcweir *pnBitmapListState |= CT_MODIFIED;
711cdf0e10cSrcweir
712cdf0e10cSrcweir ChangeBitmapHdl_Impl( this );
713cdf0e10cSrcweir }
714cdf0e10cSrcweir }
715cdf0e10cSrcweir else
716cdf0e10cSrcweir // Graphik konnte nicht geladen werden
717cdf0e10cSrcweir ErrorBox( DLGWIN,
718cdf0e10cSrcweir WinBits( WB_OK ),
719cdf0e10cSrcweir String( ResId( RID_SVXSTR_READ_DATA_ERROR, rMgr ) ) ).Execute();
720cdf0e10cSrcweir }
721cdf0e10cSrcweir
722cdf0e10cSrcweir return 0L;
723cdf0e10cSrcweir }
724cdf0e10cSrcweir
725cdf0e10cSrcweir #ifdef _MSC_VER
726cdf0e10cSrcweir #pragma optimize ( "", on )
727cdf0e10cSrcweir #endif
728cdf0e10cSrcweir
729cdf0e10cSrcweir //------------------------------------------------------------------------
730cdf0e10cSrcweir
IMPL_LINK(SvxBitmapTabPage,ClickModifyHdl_Impl,void *,EMPTYARG)731cdf0e10cSrcweir IMPL_LINK( SvxBitmapTabPage, ClickModifyHdl_Impl, void *, EMPTYARG )
732cdf0e10cSrcweir {
733cdf0e10cSrcweir sal_uInt16 nPos = aLbBitmaps.GetSelectEntryPos();
734cdf0e10cSrcweir
735cdf0e10cSrcweir if ( nPos != LISTBOX_ENTRY_NOTFOUND )
736cdf0e10cSrcweir {
737cdf0e10cSrcweir ResMgr& rMgr = CUI_MGR();
738cdf0e10cSrcweir String aNewName( SVX_RES( RID_SVXSTR_BITMAP ) );
739cdf0e10cSrcweir String aDesc( ResId( RID_SVXSTR_DESC_NEW_BITMAP, rMgr ) );
740c7be74b1SArmin Le Grand String aName( maBitmapList->GetBitmap( nPos )->GetName() );
741cdf0e10cSrcweir String aOldName = aName;
742cdf0e10cSrcweir
743cdf0e10cSrcweir SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
744cdf0e10cSrcweir DBG_ASSERT(pFact, "Dialogdiet fail!");//CHINA001
745cdf0e10cSrcweir AbstractSvxNameDialog* pDlg = pFact->CreateSvxNameDialog( DLGWIN, aName, aDesc );
746cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
747cdf0e10cSrcweir
748c7be74b1SArmin Le Grand long nCount = maBitmapList.get() ? maBitmapList->Count() : 0;
749cdf0e10cSrcweir sal_Bool bDifferent = sal_False;
750cdf0e10cSrcweir sal_Bool bLoop = sal_True;
751a68b38dfSArmin Le Grand const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
752cdf0e10cSrcweir
753cdf0e10cSrcweir while( bLoop && pDlg->Execute() == RET_OK )
754cdf0e10cSrcweir {
755cdf0e10cSrcweir pDlg->GetName( aName );
756cdf0e10cSrcweir bDifferent = sal_True;
757cdf0e10cSrcweir
758cdf0e10cSrcweir for( long i = 0; i < nCount && bDifferent; i++ )
759cdf0e10cSrcweir {
760c7be74b1SArmin Le Grand if( aName == maBitmapList->GetBitmap( i )->GetName() &&
761cdf0e10cSrcweir aName != aOldName )
762cdf0e10cSrcweir bDifferent = sal_False;
763cdf0e10cSrcweir }
764cdf0e10cSrcweir
765cdf0e10cSrcweir if( bDifferent )
766cdf0e10cSrcweir {
767cdf0e10cSrcweir bLoop = sal_False;
768cdf0e10cSrcweir
76970d3707aSArmin Le Grand const BitmapEx aBitmapEx(aBitmapCtl.GetBitmapEx());
770cdf0e10cSrcweir
771aa64976bSArmin Le Grand // #123497# Need to replace the existing entry with a new one (old returned needs to be deleted)
772aa64976bSArmin Le Grand XBitmapEntry* pEntry = new XBitmapEntry(Graphic(aBitmapEx), aName);
773aa64976bSArmin Le Grand delete maBitmapList->Replace(pEntry, nPos);
774aa64976bSArmin Le Grand
775aa64976bSArmin Le Grand aLbBitmaps.Modify( rStyleSettings.GetListBoxPreviewDefaultPixelSize(), *pEntry, nPos );
776cdf0e10cSrcweir aLbBitmaps.SelectEntryPos( nPos );
777cdf0e10cSrcweir
778cdf0e10cSrcweir // Flag fuer modifiziert setzen
779cdf0e10cSrcweir *pnBitmapListState |= CT_MODIFIED;
780cdf0e10cSrcweir
781cdf0e10cSrcweir bBmpChanged = sal_False;
782cdf0e10cSrcweir }
783cdf0e10cSrcweir else
784cdf0e10cSrcweir {
785cdf0e10cSrcweir WarningBox aBox( DLGWIN, WinBits( WB_OK ), String( ResId( RID_SVXSTR_WARN_NAME_DUPLICATE, rMgr ) ) );
786cdf0e10cSrcweir aBox.SetHelpId( HID_WARN_NAME_DUPLICATE );
787cdf0e10cSrcweir aBox.Execute();
788cdf0e10cSrcweir }
789cdf0e10cSrcweir }
790cdf0e10cSrcweir delete pDlg;
791cdf0e10cSrcweir }
792cdf0e10cSrcweir return 0L;
793cdf0e10cSrcweir }
794cdf0e10cSrcweir
795cdf0e10cSrcweir //------------------------------------------------------------------------
796cdf0e10cSrcweir
IMPL_LINK(SvxBitmapTabPage,ClickDeleteHdl_Impl,void *,EMPTYARG)797cdf0e10cSrcweir IMPL_LINK( SvxBitmapTabPage, ClickDeleteHdl_Impl, void *, EMPTYARG )
798cdf0e10cSrcweir {
799cdf0e10cSrcweir sal_uInt16 nPos = aLbBitmaps.GetSelectEntryPos();
800cdf0e10cSrcweir
801cdf0e10cSrcweir if( nPos != LISTBOX_ENTRY_NOTFOUND )
802cdf0e10cSrcweir {
803cdf0e10cSrcweir QueryBox aQueryBox( DLGWIN, WinBits( WB_YES_NO | WB_DEF_NO ),
804cdf0e10cSrcweir String( CUI_RES( RID_SVXSTR_ASK_DEL_BITMAP ) ) );
805cdf0e10cSrcweir
806cdf0e10cSrcweir if( aQueryBox.Execute() == RET_YES )
807cdf0e10cSrcweir {
808c7be74b1SArmin Le Grand delete maBitmapList->Remove( nPos );
809cdf0e10cSrcweir aLbBitmaps.RemoveEntry( nPos );
810cdf0e10cSrcweir aLbBitmaps.SelectEntryPos( 0 );
811cdf0e10cSrcweir
812cdf0e10cSrcweir aCtlPreview.Invalidate();
813cdf0e10cSrcweir aCtlPixel.Invalidate();
814cdf0e10cSrcweir
815cdf0e10cSrcweir ChangeBitmapHdl_Impl( this );
816cdf0e10cSrcweir
817cdf0e10cSrcweir // Flag fuer modifiziert setzen
818cdf0e10cSrcweir *pnBitmapListState |= CT_MODIFIED;
819cdf0e10cSrcweir }
820cdf0e10cSrcweir }
821cdf0e10cSrcweir // Status der Buttons ermitteln
822c7be74b1SArmin Le Grand if( !maBitmapList.get() || !maBitmapList->Count() )
823cdf0e10cSrcweir {
824cdf0e10cSrcweir aBtnModify.Disable();
825cdf0e10cSrcweir aBtnDelete.Disable();
826cdf0e10cSrcweir aBtnSave.Disable();
827cdf0e10cSrcweir }
828cdf0e10cSrcweir return 0L;
829cdf0e10cSrcweir }
830cdf0e10cSrcweir
831cdf0e10cSrcweir // -----------------------------------------------------------------------
832cdf0e10cSrcweir
IMPL_LINK(SvxBitmapTabPage,ClickLoadHdl_Impl,void *,EMPTYARG)833cdf0e10cSrcweir IMPL_LINK( SvxBitmapTabPage, ClickLoadHdl_Impl, void *, EMPTYARG )
834cdf0e10cSrcweir {
835cdf0e10cSrcweir sal_uInt16 nReturn = RET_YES;
836cdf0e10cSrcweir ResMgr& rMgr = CUI_MGR();
837cdf0e10cSrcweir
838cdf0e10cSrcweir if ( *pnBitmapListState & CT_MODIFIED )
839cdf0e10cSrcweir {
840cdf0e10cSrcweir nReturn = WarningBox( DLGWIN, WinBits( WB_YES_NO_CANCEL ),
841cdf0e10cSrcweir String( ResId( RID_SVXSTR_WARN_TABLE_OVERWRITE, rMgr ) ) ).Execute();
842cdf0e10cSrcweir
843cdf0e10cSrcweir if ( nReturn == RET_YES )
844c7be74b1SArmin Le Grand maBitmapList->Save();
845cdf0e10cSrcweir }
846cdf0e10cSrcweir
847cdf0e10cSrcweir if ( nReturn != RET_CANCEL )
848cdf0e10cSrcweir {
849cdf0e10cSrcweir ::sfx2::FileDialogHelper aDlg(
850cdf0e10cSrcweir com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
851cdf0e10cSrcweir 0 );
852cdf0e10cSrcweir String aStrFilterType( RTL_CONSTASCII_USTRINGPARAM( "*.sob" ) );
853cdf0e10cSrcweir aDlg.AddFilter( aStrFilterType, aStrFilterType );
854cdf0e10cSrcweir INetURLObject aFile( SvtPathOptions().GetPalettePath() );
855cdf0e10cSrcweir aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) );
856cdf0e10cSrcweir
857cdf0e10cSrcweir if ( aDlg.Execute() == ERRCODE_NONE )
858cdf0e10cSrcweir {
859cdf0e10cSrcweir EnterWait();
860cdf0e10cSrcweir INetURLObject aURL( aDlg.GetPath() );
861cdf0e10cSrcweir INetURLObject aPathURL( aURL );
862cdf0e10cSrcweir
863cdf0e10cSrcweir aPathURL.removeSegment();
864cdf0e10cSrcweir aPathURL.removeFinalSlash();
865cdf0e10cSrcweir
866cdf0e10cSrcweir // Tabelle speichern
867c7be74b1SArmin Le Grand XBitmapListSharedPtr aBmpList(XPropertyListFactory::CreateSharedXBitmapList(aPathURL.GetMainURL(INetURLObject::NO_DECODE)));
868c7be74b1SArmin Le Grand aBmpList->SetName( aURL.getName() );
869c7be74b1SArmin Le Grand if( aBmpList->Load() )
870cdf0e10cSrcweir {
871c7be74b1SArmin Le Grand if( aBmpList.get() )
872cdf0e10cSrcweir {
873c7be74b1SArmin Le Grand maBitmapList = aBmpList;
874c7be74b1SArmin Le Grand ( (SvxAreaTabDialog*) DLGWIN )->SetNewBitmapList( maBitmapList );
875cdf0e10cSrcweir
876cdf0e10cSrcweir aLbBitmaps.Clear();
877c7be74b1SArmin Le Grand aLbBitmaps.Fill( maBitmapList );
878cdf0e10cSrcweir Reset( rOutAttrs );
879cdf0e10cSrcweir
880c7be74b1SArmin Le Grand maBitmapList->SetName( aURL.getName() );
881cdf0e10cSrcweir
882cdf0e10cSrcweir // Ermitteln (evtl. abschneiden) des Namens und in
883cdf0e10cSrcweir // der GroupBox darstellen
884cdf0e10cSrcweir String aString( ResId( RID_SVXSTR_TABLE, rMgr ) );
885cdf0e10cSrcweir aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
886cdf0e10cSrcweir
887cdf0e10cSrcweir if ( aURL.getBase().getLength() > 18 )
888cdf0e10cSrcweir {
889cdf0e10cSrcweir aString += String(aURL.getBase()).Copy( 0, 15 );
890cdf0e10cSrcweir aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) );
891cdf0e10cSrcweir }
892cdf0e10cSrcweir else
893cdf0e10cSrcweir aString += String(aURL.getBase());
894cdf0e10cSrcweir
895cdf0e10cSrcweir // Flag fuer gewechselt setzen
896cdf0e10cSrcweir *pnBitmapListState |= CT_CHANGED;
897cdf0e10cSrcweir // Flag fuer modifiziert entfernen
898cdf0e10cSrcweir *pnBitmapListState &= ~CT_MODIFIED;
899cdf0e10cSrcweir }
900cdf0e10cSrcweir LeaveWait();
901cdf0e10cSrcweir }
902cdf0e10cSrcweir else
903cdf0e10cSrcweir {
904cdf0e10cSrcweir LeaveWait();
905cdf0e10cSrcweir ErrorBox( DLGWIN, WinBits( WB_OK ),
906cdf0e10cSrcweir String( ResId( RID_SVXSTR_READ_DATA_ERROR, rMgr ) ) ).Execute();
907cdf0e10cSrcweir }
908cdf0e10cSrcweir }
909cdf0e10cSrcweir }
910cdf0e10cSrcweir
911cdf0e10cSrcweir // Status der Buttons ermitteln
912c7be74b1SArmin Le Grand if( maBitmapList.get() && maBitmapList->Count() )
913cdf0e10cSrcweir {
914cdf0e10cSrcweir aBtnModify.Enable();
915cdf0e10cSrcweir aBtnDelete.Enable();
916cdf0e10cSrcweir aBtnSave.Enable();
917cdf0e10cSrcweir }
918cdf0e10cSrcweir else
919cdf0e10cSrcweir {
920cdf0e10cSrcweir aBtnModify.Disable();
921cdf0e10cSrcweir aBtnDelete.Disable();
922cdf0e10cSrcweir aBtnSave.Disable();
923cdf0e10cSrcweir }
924cdf0e10cSrcweir return 0L;
925cdf0e10cSrcweir }
926cdf0e10cSrcweir
927cdf0e10cSrcweir // -----------------------------------------------------------------------
928cdf0e10cSrcweir
IMPL_LINK(SvxBitmapTabPage,ClickSaveHdl_Impl,void *,EMPTYARG)929cdf0e10cSrcweir IMPL_LINK( SvxBitmapTabPage, ClickSaveHdl_Impl, void *, EMPTYARG )
930cdf0e10cSrcweir {
931cdf0e10cSrcweir ::sfx2::FileDialogHelper aDlg(
932cdf0e10cSrcweir com::sun::star::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE, 0 );
933cdf0e10cSrcweir String aStrFilterType( RTL_CONSTASCII_USTRINGPARAM( "*.sob" ) );
934cdf0e10cSrcweir aDlg.AddFilter( aStrFilterType, aStrFilterType );
935cdf0e10cSrcweir
936cdf0e10cSrcweir INetURLObject aFile( SvtPathOptions().GetPalettePath() );
937cdf0e10cSrcweir DBG_ASSERT( aFile.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
938cdf0e10cSrcweir
939c7be74b1SArmin Le Grand if( maBitmapList->GetName().Len() )
940cdf0e10cSrcweir {
941c7be74b1SArmin Le Grand aFile.Append( maBitmapList->GetName() );
942cdf0e10cSrcweir
943cdf0e10cSrcweir if( !aFile.getExtension().getLength() )
944cdf0e10cSrcweir aFile.SetExtension( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "sob" ) ) );
945cdf0e10cSrcweir }
946cdf0e10cSrcweir
947cdf0e10cSrcweir aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) );
948cdf0e10cSrcweir if ( aDlg.Execute() == ERRCODE_NONE )
949cdf0e10cSrcweir {
950cdf0e10cSrcweir INetURLObject aURL( aDlg.GetPath() );
951cdf0e10cSrcweir INetURLObject aPathURL( aURL );
952cdf0e10cSrcweir
953cdf0e10cSrcweir aPathURL.removeSegment();
954cdf0e10cSrcweir aPathURL.removeFinalSlash();
955cdf0e10cSrcweir
956c7be74b1SArmin Le Grand maBitmapList->SetName( aURL.getName() );
957c7be74b1SArmin Le Grand maBitmapList->SetPath( aPathURL.GetMainURL( INetURLObject::NO_DECODE ) );
958cdf0e10cSrcweir
959c7be74b1SArmin Le Grand if( maBitmapList->Save() )
960cdf0e10cSrcweir {
961cdf0e10cSrcweir // Ermitteln (evtl. abschneiden) des Namens und in
962cdf0e10cSrcweir // der GroupBox darstellen
963cdf0e10cSrcweir String aString( CUI_RES( RID_SVXSTR_TABLE ) );
964cdf0e10cSrcweir aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
965cdf0e10cSrcweir
966cdf0e10cSrcweir if ( aURL.getBase().getLength() > 18 )
967cdf0e10cSrcweir {
968cdf0e10cSrcweir aString += String(aURL.getBase()).Copy( 0, 15 );
969cdf0e10cSrcweir aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) );
970cdf0e10cSrcweir }
971cdf0e10cSrcweir else
972cdf0e10cSrcweir aString += String(aURL.getBase());
973cdf0e10cSrcweir
974cdf0e10cSrcweir // Flag fuer gespeichert setzen
975cdf0e10cSrcweir *pnBitmapListState |= CT_SAVED;
976cdf0e10cSrcweir // Flag fuer modifiziert entfernen
977cdf0e10cSrcweir *pnBitmapListState &= ~CT_MODIFIED;
978cdf0e10cSrcweir }
979cdf0e10cSrcweir else
980cdf0e10cSrcweir {
981cdf0e10cSrcweir ErrorBox( DLGWIN, WinBits( WB_OK ),
982cdf0e10cSrcweir String( CUI_RES( RID_SVXSTR_WRITE_DATA_ERROR ) ) ).Execute();
983cdf0e10cSrcweir }
984cdf0e10cSrcweir }
985cdf0e10cSrcweir
986cdf0e10cSrcweir return 0L;
987cdf0e10cSrcweir }
988cdf0e10cSrcweir
989cdf0e10cSrcweir //------------------------------------------------------------------------
990cdf0e10cSrcweir
IMPL_LINK(SvxBitmapTabPage,ChangePixelColorHdl_Impl,void *,EMPTYARG)991cdf0e10cSrcweir IMPL_LINK( SvxBitmapTabPage, ChangePixelColorHdl_Impl, void *, EMPTYARG )
992cdf0e10cSrcweir {
993cdf0e10cSrcweir aCtlPixel.SetPixelColor( aLbColor.GetSelectEntryColor() );
994cdf0e10cSrcweir aCtlPixel.Invalidate();
995cdf0e10cSrcweir
996cdf0e10cSrcweir aBitmapCtl.SetPixelColor( aLbColor.GetSelectEntryColor() );
997cdf0e10cSrcweir
998cdf0e10cSrcweir // Bitmap holen und darstellen
99970d3707aSArmin Le Grand rXFSet.Put(XFillBitmapItem(String(), Graphic(aBitmapCtl.GetBitmapEx())));
1000cdf0e10cSrcweir aCtlPreview.SetAttributes( aXFillAttr.GetItemSet() );
1001cdf0e10cSrcweir aCtlPreview.Invalidate();
1002cdf0e10cSrcweir
1003cdf0e10cSrcweir bBmpChanged = sal_True;
1004cdf0e10cSrcweir
1005cdf0e10cSrcweir return 0L;
1006cdf0e10cSrcweir }
1007cdf0e10cSrcweir
1008cdf0e10cSrcweir //------------------------------------------------------------------------
1009cdf0e10cSrcweir
IMPL_LINK(SvxBitmapTabPage,ChangeBackgrndColorHdl_Impl,void *,EMPTYARG)1010cdf0e10cSrcweir IMPL_LINK( SvxBitmapTabPage, ChangeBackgrndColorHdl_Impl, void *, EMPTYARG )
1011cdf0e10cSrcweir {
1012cdf0e10cSrcweir aCtlPixel.SetBackgroundColor( aLbBackgroundColor.GetSelectEntryColor() );
1013cdf0e10cSrcweir aCtlPixel.Invalidate();
1014cdf0e10cSrcweir
1015cdf0e10cSrcweir aBitmapCtl.SetBackgroundColor( aLbBackgroundColor.GetSelectEntryColor() );
1016cdf0e10cSrcweir
1017cdf0e10cSrcweir // Bitmap holen und darstellen
101870d3707aSArmin Le Grand rXFSet.Put(XFillBitmapItem(String(), Graphic(aBitmapCtl.GetBitmapEx())));
1019cdf0e10cSrcweir aCtlPreview.SetAttributes( aXFillAttr.GetItemSet() );
1020cdf0e10cSrcweir aCtlPreview.Invalidate();
1021cdf0e10cSrcweir
1022cdf0e10cSrcweir bBmpChanged = sal_True;
1023cdf0e10cSrcweir
1024cdf0e10cSrcweir return 0L;
1025cdf0e10cSrcweir }
1026cdf0e10cSrcweir
1027cdf0e10cSrcweir //------------------------------------------------------------------------
1028cdf0e10cSrcweir
PointChanged(Window * pWindow,RECT_POINT)1029cdf0e10cSrcweir void SvxBitmapTabPage::PointChanged( Window* pWindow, RECT_POINT )
1030cdf0e10cSrcweir {
1031cdf0e10cSrcweir if( pWindow == &aCtlPixel )
1032cdf0e10cSrcweir {
1033cdf0e10cSrcweir aBitmapCtl.SetBmpArray( aCtlPixel.GetBitmapPixelPtr() );
1034cdf0e10cSrcweir
1035cdf0e10cSrcweir // Bitmap holen und darstellen
103670d3707aSArmin Le Grand rXFSet.Put(XFillBitmapItem(String(), Graphic(aBitmapCtl.GetBitmapEx())));
1037cdf0e10cSrcweir aCtlPreview.SetAttributes( aXFillAttr.GetItemSet() );
1038cdf0e10cSrcweir aCtlPreview.Invalidate();
1039cdf0e10cSrcweir
1040cdf0e10cSrcweir bBmpChanged = sal_True;
1041cdf0e10cSrcweir }
1042cdf0e10cSrcweir }
1043cdf0e10cSrcweir
1044cdf0e10cSrcweir
1045cdf0e10cSrcweir
1046cdf0e10cSrcweir
GetParentLabeledBy(const Window * pLabeled) const1047cdf0e10cSrcweir Window* SvxBitmapTabPage::GetParentLabeledBy( const Window* pLabeled ) const
1048cdf0e10cSrcweir {
1049cdf0e10cSrcweir if (pLabeled == &aLbBitmaps)
1050cdf0e10cSrcweir return const_cast<FixedText*>(&aLbBitmapsHidden);
1051cdf0e10cSrcweir else
1052cdf0e10cSrcweir return SvxTabPage::GetParentLabeledBy (pLabeled);
1053cdf0e10cSrcweir }
1054