xref: /AOO41X/main/cui/source/tabpages/tpbitmap.cxx (revision 3e407bd8bfbcadcc775d35b65ff2369f9097ff80)
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
10cdf0e10cSrcweir  *
112ee96f1cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
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.
19cdf0e10cSrcweir  *
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 
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 
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 
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 
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     {
26870d3707aSArmin Le Grand         if(PT_BITMAP == *pPageType)
269cdf0e10cSrcweir         {
27070d3707aSArmin Le Grand             const sal_uInt16 nPos(aLbBitmaps.GetSelectEntryPos());
271cdf0e10cSrcweir 
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());
278cdf0e10cSrcweir 
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)));
28670d3707aSArmin Le Grand             }
28770d3707aSArmin Le Grand         }
28870d3707aSArmin Le Grand     }
289cdf0e10cSrcweir 
290cdf0e10cSrcweir     return sal_True;
291cdf0e10cSrcweir }
292cdf0e10cSrcweir 
293cdf0e10cSrcweir // -----------------------------------------------------------------------
294cdf0e10cSrcweir 
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 
330cdf0e10cSrcweir SfxTabPage* SvxBitmapTabPage::Create( Window* pWindow,
331cdf0e10cSrcweir                 const SfxItemSet& rSet )
332cdf0e10cSrcweir {
333cdf0e10cSrcweir     return new SvxBitmapTabPage( pWindow, rSet );
334cdf0e10cSrcweir }
335cdf0e10cSrcweir 
336cdf0e10cSrcweir //------------------------------------------------------------------------
337cdf0e10cSrcweir 
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         {
363cdf0e10cSrcweir             aLbBitmaps.SelectEntryPos(0);
364cdf0e10cSrcweir             nPos = aLbBitmaps.GetSelectEntryPos();
365cdf0e10cSrcweir 
36670d3707aSArmin Le Grand             if(LISTBOX_ENTRY_NOTFOUND != nPos)
367cdf0e10cSrcweir             {
368c7be74b1SArmin Le Grand                 pGraphicObject = new GraphicObject(maBitmapList->GetBitmap(nPos)->GetGraphicObject());
369cdf0e10cSrcweir             }
370cdf0e10cSrcweir         }
371cdf0e10cSrcweir     }
372cdf0e10cSrcweir 
37370d3707aSArmin Le Grand     if(pGraphicObject)
374cdf0e10cSrcweir     {
37570d3707aSArmin Le Grand         BitmapColor aBack;
37670d3707aSArmin Le Grand         BitmapColor aFront;
37770d3707aSArmin Le Grand         bool bIs8x8(isHistorical8x8(pGraphicObject->GetGraphic().GetBitmap(), aBack, aFront));
378cdf0e10cSrcweir 
379cdf0e10cSrcweir         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 
400cdf0e10cSrcweir             aBitmapCtl.SetPixelColor( aPixelColor );
401cdf0e10cSrcweir             aBitmapCtl.SetBackgroundColor( aBackColor );
402cdf0e10cSrcweir 
403cdf0e10cSrcweir             // Wenn der Eintrag nicht in der Listbox ist, wird die Farbe
404cdf0e10cSrcweir             // temporaer hinzugenommen
405cdf0e10cSrcweir             if( 0 == aLbBitmaps.GetSelectEntryPos() )
406cdf0e10cSrcweir             {
407cdf0e10cSrcweir                 aLbColor.SelectEntry( Color( COL_BLACK ) );
408cdf0e10cSrcweir                 ChangePixelColorHdl_Impl( this );
409cdf0e10cSrcweir             }
410cdf0e10cSrcweir             else
411cdf0e10cSrcweir                 aLbColor.SelectEntry( aPixelColor );
412cdf0e10cSrcweir             if( aLbColor.GetSelectEntryCount() == 0 )
413cdf0e10cSrcweir             {
414cdf0e10cSrcweir                 aLbColor.InsertEntry( aPixelColor, String() );
415cdf0e10cSrcweir                 aLbColor.SelectEntry( aPixelColor );
416cdf0e10cSrcweir             }
417cdf0e10cSrcweir             aLbBackgroundColor.SelectEntry( aBackColor );
418cdf0e10cSrcweir             if( aLbBackgroundColor.GetSelectEntryCount() == 0 )
419cdf0e10cSrcweir             {
420cdf0e10cSrcweir                 aLbBackgroundColor.InsertEntry( aBackColor, String() );
421cdf0e10cSrcweir                 aLbBackgroundColor.SelectEntry( aBackColor );
422cdf0e10cSrcweir             }
423cdf0e10cSrcweir         }
42470d3707aSArmin Le Grand         else
42570d3707aSArmin Le Grand         {
42670d3707aSArmin Le Grand             aCtlPixel.Reset();
42770d3707aSArmin Le Grand             aCtlPixel.SetPaintable( sal_False );
42870d3707aSArmin Le Grand             aCtlPixel.Disable();
42970d3707aSArmin Le Grand             aFtPixelEdit.Disable();
43070d3707aSArmin Le Grand             aFtColor.Disable();
43170d3707aSArmin Le Grand             aLbColor.Disable();
43270d3707aSArmin Le Grand             aFtBackgroundColor.Disable();
43370d3707aSArmin Le Grand             aLbBackgroundColor.Disable();
43470d3707aSArmin Le Grand             aBtnModify.Disable();
43570d3707aSArmin Le Grand             aBtnAdd.Disable();
43670d3707aSArmin Le Grand         }
43770d3707aSArmin Le Grand 
438cdf0e10cSrcweir         aCtlPixel.Invalidate();
439cdf0e10cSrcweir 
440cdf0e10cSrcweir         // Bitmap darstellen
44170d3707aSArmin Le Grand         const XFillBitmapItem aXBmpItem(String(), *pGraphicObject);
442cdf0e10cSrcweir         rXFSet.Put( aXBmpItem );
443cdf0e10cSrcweir 
444cdf0e10cSrcweir         aCtlPreview.SetAttributes( aXFillAttr.GetItemSet() );
445cdf0e10cSrcweir         aCtlPreview.Invalidate();
446cdf0e10cSrcweir 
447cdf0e10cSrcweir         bBmpChanged = sal_False;
44870d3707aSArmin Le Grand         delete pGraphicObject;
449cdf0e10cSrcweir     }
45070d3707aSArmin Le Grand 
45170d3707aSArmin Le Grand     return 0;
452cdf0e10cSrcweir }
453cdf0e10cSrcweir 
454cdf0e10cSrcweir // -----------------------------------------------------------------------
455cdf0e10cSrcweir 
456cdf0e10cSrcweir long SvxBitmapTabPage::CheckChanges_Impl()
457cdf0e10cSrcweir {
458cdf0e10cSrcweir     sal_uInt16 nPos = aLbBitmaps.GetSelectEntryPos();
459cdf0e10cSrcweir     if( nPos != LISTBOX_ENTRY_NOTFOUND )
460cdf0e10cSrcweir     {
461cdf0e10cSrcweir         String aString = aLbBitmaps.GetSelectEntry();
462cdf0e10cSrcweir 
463cdf0e10cSrcweir         if( bBmpChanged )
464cdf0e10cSrcweir         {
465cdf0e10cSrcweir             ResMgr& rMgr = CUI_MGR();
466cdf0e10cSrcweir             Image aWarningBoxImage = WarningBox::GetStandardImage();
467cdf0e10cSrcweir             SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
468cdf0e10cSrcweir             DBG_ASSERT(pFact, "Dialogdiet fail!");//CHINA001
469cdf0e10cSrcweir             AbstractSvxMessDialog* aMessDlg = pFact->CreateSvxMessDialog( DLGWIN, RID_SVXDLG_MESSBOX,
470cdf0e10cSrcweir                                                         String( SVX_RES( RID_SVXSTR_BITMAP ) ),
471cdf0e10cSrcweir                                                         String( CUI_RES( RID_SVXSTR_ASK_CHANGE_BITMAP ) ),
472cdf0e10cSrcweir                                                         &aWarningBoxImage  );
473cdf0e10cSrcweir             DBG_ASSERT(aMessDlg, "Dialogdiet fail!");//CHINA001
474cdf0e10cSrcweir             aMessDlg->SetButtonText( MESS_BTN_1, //CHINA001 aMessDlg.SetButtonText( MESS_BTN_1,
475cdf0e10cSrcweir                                     String( ResId( RID_SVXSTR_CHANGE, rMgr ) ) );
476cdf0e10cSrcweir             aMessDlg->SetButtonText( MESS_BTN_2, //CHINA001 aMessDlg.SetButtonText( MESS_BTN_2,
477cdf0e10cSrcweir                                     String( ResId( RID_SVXSTR_ADD, rMgr ) ) );
478cdf0e10cSrcweir 
479cdf0e10cSrcweir             short nRet = aMessDlg->Execute(); //CHINA001 short nRet = aMessDlg.Execute();
480cdf0e10cSrcweir 
481cdf0e10cSrcweir             switch( nRet )
482cdf0e10cSrcweir             {
483cdf0e10cSrcweir                 case RET_BTN_1: // Aendern
484cdf0e10cSrcweir                 {
485cdf0e10cSrcweir                     ClickModifyHdl_Impl( this );
486cdf0e10cSrcweir                 }
487cdf0e10cSrcweir                 break;
488cdf0e10cSrcweir 
489cdf0e10cSrcweir                 case RET_BTN_2: // Hinzufuegen
490cdf0e10cSrcweir                 {
491cdf0e10cSrcweir                     ClickAddHdl_Impl( this );
492cdf0e10cSrcweir                     nPos = aLbBitmaps.GetSelectEntryPos();
493cdf0e10cSrcweir                 }
494cdf0e10cSrcweir                 break;
495cdf0e10cSrcweir 
496cdf0e10cSrcweir                 case RET_CANCEL:
497cdf0e10cSrcweir                     // return( -1L );
498cdf0e10cSrcweir                 break;
499cdf0e10cSrcweir                 // return( sal_True ); // Abbruch
500cdf0e10cSrcweir             }
501cdf0e10cSrcweir             delete aMessDlg; //add by CHINA001
502cdf0e10cSrcweir         }
503cdf0e10cSrcweir     }
504cdf0e10cSrcweir     nPos = aLbBitmaps.GetSelectEntryPos();
505cdf0e10cSrcweir     if( nPos != LISTBOX_ENTRY_NOTFOUND )
506cdf0e10cSrcweir         *pPos = nPos;
507cdf0e10cSrcweir     return 0L;
508cdf0e10cSrcweir }
509cdf0e10cSrcweir 
510cdf0e10cSrcweir //------------------------------------------------------------------------
511cdf0e10cSrcweir 
512cdf0e10cSrcweir IMPL_LINK( SvxBitmapTabPage, ClickAddHdl_Impl, void *, EMPTYARG )
513cdf0e10cSrcweir {
514cdf0e10cSrcweir     ResMgr& rMgr = CUI_MGR();
515cdf0e10cSrcweir     String aNewName( SVX_RES( RID_SVXSTR_BITMAP ) );
516cdf0e10cSrcweir     String aDesc( CUI_RES( RID_SVXSTR_DESC_NEW_BITMAP ) );
517cdf0e10cSrcweir     String aName;
518cdf0e10cSrcweir 
519c7be74b1SArmin Le Grand     long nCount = maBitmapList.get() ? maBitmapList->Count() : 0;
520cdf0e10cSrcweir     long j = 1;
521cdf0e10cSrcweir     sal_Bool bDifferent = sal_False;
522cdf0e10cSrcweir 
523cdf0e10cSrcweir     while( !bDifferent )
524cdf0e10cSrcweir     {
525cdf0e10cSrcweir         aName  = aNewName;
526cdf0e10cSrcweir         aName += sal_Unicode(' ');
527cdf0e10cSrcweir         aName += UniString::CreateFromInt32( j++ );
528cdf0e10cSrcweir         bDifferent = sal_True;
529cdf0e10cSrcweir 
530cdf0e10cSrcweir         for( long i = 0; i < nCount && bDifferent; i++ )
531c7be74b1SArmin Le Grand             if( aName == maBitmapList->GetBitmap( i )->GetName() )
532cdf0e10cSrcweir                 bDifferent = sal_False;
533cdf0e10cSrcweir     }
534cdf0e10cSrcweir 
535cdf0e10cSrcweir     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
536cdf0e10cSrcweir     DBG_ASSERT(pFact, "Dialogdiet fail!");//CHINA001
537cdf0e10cSrcweir     AbstractSvxNameDialog* pDlg = pFact->CreateSvxNameDialog( DLGWIN, aName, aDesc );
538cdf0e10cSrcweir     DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
539cdf0e10cSrcweir     WarningBox*    pWarnBox = NULL;
540cdf0e10cSrcweir     sal_uInt16         nError   = RID_SVXSTR_WARN_NAME_DUPLICATE;
541cdf0e10cSrcweir 
542cdf0e10cSrcweir     while( pDlg->Execute() == RET_OK )
543cdf0e10cSrcweir     {
544cdf0e10cSrcweir         pDlg->GetName( aName );
545cdf0e10cSrcweir 
546cdf0e10cSrcweir         bDifferent = sal_True;
547cdf0e10cSrcweir 
548cdf0e10cSrcweir         for( long i = 0; i < nCount && bDifferent; i++ )
549c7be74b1SArmin Le Grand             if( aName == maBitmapList->GetBitmap( i )->GetName() )
550cdf0e10cSrcweir                 bDifferent = sal_False;
551cdf0e10cSrcweir 
552cdf0e10cSrcweir         if( bDifferent ) {
553cdf0e10cSrcweir             nError = 0;
554cdf0e10cSrcweir             break;
555cdf0e10cSrcweir         }
556cdf0e10cSrcweir 
557cdf0e10cSrcweir         if( !pWarnBox )
558cdf0e10cSrcweir         {
559cdf0e10cSrcweir             pWarnBox = new WarningBox( DLGWIN,
560cdf0e10cSrcweir                                        WinBits( WB_OK_CANCEL ),
561cdf0e10cSrcweir                                        String( ResId( nError, rMgr ) ) );
562cdf0e10cSrcweir             pWarnBox->SetHelpId( HID_WARN_NAME_DUPLICATE );
563cdf0e10cSrcweir         }
564cdf0e10cSrcweir 
565cdf0e10cSrcweir         if( pWarnBox->Execute() != RET_OK )
566cdf0e10cSrcweir             break;
567cdf0e10cSrcweir     }
568*3e407bd8SArmin Le Grand 
569cdf0e10cSrcweir     delete pDlg;
570cdf0e10cSrcweir     delete pWarnBox;
571cdf0e10cSrcweir 
572cdf0e10cSrcweir     if( !nError )
573cdf0e10cSrcweir     {
574cdf0e10cSrcweir         XBitmapEntry* pEntry = 0;
575cdf0e10cSrcweir         if( aCtlPixel.IsEnabled() )
576cdf0e10cSrcweir         {
57770d3707aSArmin Le Grand             const BitmapEx aBitmapEx(aBitmapCtl.GetBitmapEx());
578cdf0e10cSrcweir 
57970d3707aSArmin Le Grand             pEntry = new XBitmapEntry(Graphic(aBitmapEx), aName);
580cdf0e10cSrcweir         }
581cdf0e10cSrcweir         else // Es muss sich um eine nicht vorhandene importierte Bitmap handeln
582cdf0e10cSrcweir         {
58370d3707aSArmin Le Grand             const SfxPoolItem* pPoolItem = 0;
58470d3707aSArmin Le Grand 
58570d3707aSArmin Le Grand             if(SFX_ITEM_SET == rOutAttrs.GetItemState(XATTR_FILLBITMAP, true, &pPoolItem))
586cdf0e10cSrcweir             {
58770d3707aSArmin Le Grand                 pEntry = new XBitmapEntry(dynamic_cast< const XFillBitmapItem* >(pPoolItem)->GetGraphicObject(), aName);
588cdf0e10cSrcweir             }
589cdf0e10cSrcweir         }
590cdf0e10cSrcweir 
591cdf0e10cSrcweir         DBG_ASSERT( pEntry, "SvxBitmapTabPage::ClickAddHdl_Impl(), pEntry == 0 ?" );
592cdf0e10cSrcweir 
593cdf0e10cSrcweir         if( pEntry )
594cdf0e10cSrcweir         {
595c7be74b1SArmin Le Grand             maBitmapList->Insert( pEntry );
596a68b38dfSArmin Le Grand             const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
597a68b38dfSArmin Le Grand             aLbBitmaps.Append(rStyleSettings.GetListBoxPreviewDefaultPixelSize(), *pEntry );
598cdf0e10cSrcweir             aLbBitmaps.SelectEntryPos( aLbBitmaps.GetEntryCount() - 1 );
599cdf0e10cSrcweir 
600cdf0e10cSrcweir             // Flag fuer modifiziert setzen
601cdf0e10cSrcweir             *pnBitmapListState |= CT_MODIFIED;
602cdf0e10cSrcweir 
603cdf0e10cSrcweir             ChangeBitmapHdl_Impl( this );
604cdf0e10cSrcweir         }
605cdf0e10cSrcweir     }
606cdf0e10cSrcweir 
607cdf0e10cSrcweir     // Status der Buttons ermitteln
608c7be74b1SArmin Le Grand     if( maBitmapList.get() && maBitmapList->Count() )
609cdf0e10cSrcweir     {
610cdf0e10cSrcweir         aBtnModify.Enable();
611cdf0e10cSrcweir         aBtnDelete.Enable();
612cdf0e10cSrcweir         aBtnSave.Enable();
613cdf0e10cSrcweir     }
614cdf0e10cSrcweir     return 0L;
615cdf0e10cSrcweir }
616cdf0e10cSrcweir 
617cdf0e10cSrcweir 
618cdf0e10cSrcweir /******************************************************************************/
619cdf0e10cSrcweir /******************************************************************************/
620cdf0e10cSrcweir 
621cdf0e10cSrcweir 
622cdf0e10cSrcweir //------------------------------------------------------------------------
623cdf0e10cSrcweir 
624cdf0e10cSrcweir #ifdef _MSC_VER
625cdf0e10cSrcweir #pragma optimize ( "", off )
626cdf0e10cSrcweir #endif
627cdf0e10cSrcweir 
628cdf0e10cSrcweir IMPL_LINK( SvxBitmapTabPage, ClickImportHdl_Impl, void *, EMPTYARG )
629cdf0e10cSrcweir {
630cdf0e10cSrcweir     ResMgr& rMgr = CUI_MGR();
631cdf0e10cSrcweir     SvxOpenGraphicDialog aDlg( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "Import" ) ) );
632cdf0e10cSrcweir     aDlg.EnableLink(sal_False);
633cdf0e10cSrcweir 
634cdf0e10cSrcweir     if( !aDlg.Execute() )
635cdf0e10cSrcweir     {
636cdf0e10cSrcweir         Graphic         aGraphic;
637cdf0e10cSrcweir         int             nError = 1;
638cdf0e10cSrcweir 
639cdf0e10cSrcweir         EnterWait();
640cdf0e10cSrcweir         nError = aDlg.GetGraphic( aGraphic );
641cdf0e10cSrcweir         LeaveWait();
642cdf0e10cSrcweir 
643cdf0e10cSrcweir         if( !nError )
644cdf0e10cSrcweir         {
645cdf0e10cSrcweir             String aDesc( ResId(RID_SVXSTR_DESC_EXT_BITMAP, rMgr) );
646cdf0e10cSrcweir             WarningBox*    pWarnBox = NULL;
647cdf0e10cSrcweir 
648cdf0e10cSrcweir             // convert file URL to UI name
649cdf0e10cSrcweir             String          aName;
650cdf0e10cSrcweir             INetURLObject   aURL( aDlg.GetPath() );
651cdf0e10cSrcweir             SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
652cdf0e10cSrcweir             DBG_ASSERT(pFact, "Dialogdiet fail!");//CHINA001
653cdf0e10cSrcweir             AbstractSvxNameDialog* pDlg = pFact->CreateSvxNameDialog( DLGWIN, String(aURL.GetName()).GetToken( 0, '.' ), aDesc );
654cdf0e10cSrcweir             DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
655cdf0e10cSrcweir             nError = RID_SVXSTR_WARN_NAME_DUPLICATE;
656cdf0e10cSrcweir 
657cdf0e10cSrcweir             while( pDlg->Execute() == RET_OK )
658cdf0e10cSrcweir             {
659cdf0e10cSrcweir                 pDlg->GetName( aName );
660cdf0e10cSrcweir 
661cdf0e10cSrcweir                 sal_Bool bDifferent = sal_True;
662c7be74b1SArmin Le Grand                 long nCount     = maBitmapList->Count();
663cdf0e10cSrcweir 
664cdf0e10cSrcweir                 for( long i = 0; i < nCount && bDifferent; i++ )
665c7be74b1SArmin Le Grand                     if( aName == maBitmapList->GetBitmap( i )->GetName() )
666cdf0e10cSrcweir                         bDifferent = sal_False;
667cdf0e10cSrcweir 
668cdf0e10cSrcweir                 if( bDifferent ) {
669cdf0e10cSrcweir                     nError = 0;
670cdf0e10cSrcweir                     break;
671cdf0e10cSrcweir                 }
672cdf0e10cSrcweir 
673cdf0e10cSrcweir                 if( !pWarnBox )
674cdf0e10cSrcweir                 {
675cdf0e10cSrcweir                     pWarnBox = new WarningBox( DLGWIN,
676cdf0e10cSrcweir                                                WinBits( WB_OK_CANCEL ),
677cdf0e10cSrcweir                                                String( ResId( nError, rMgr ) ) );
678cdf0e10cSrcweir                     pWarnBox->SetHelpId( HID_WARN_NAME_DUPLICATE );
679cdf0e10cSrcweir                 }
680cdf0e10cSrcweir 
681cdf0e10cSrcweir 
682cdf0e10cSrcweir                 if( pWarnBox->Execute() != RET_OK )
683cdf0e10cSrcweir                     break;
684cdf0e10cSrcweir             }
685*3e407bd8SArmin Le Grand 
686cdf0e10cSrcweir             delete pDlg;
687cdf0e10cSrcweir             delete pWarnBox;
688cdf0e10cSrcweir 
689cdf0e10cSrcweir             if( !nError )
690cdf0e10cSrcweir             {
69170d3707aSArmin Le Grand                 XBitmapEntry* pEntry = new XBitmapEntry( aGraphic, aName );
692c7be74b1SArmin Le Grand                 maBitmapList->Insert( pEntry );
693cdf0e10cSrcweir 
694a68b38dfSArmin Le Grand                 const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
695a68b38dfSArmin Le Grand                 aLbBitmaps.Append(rStyleSettings.GetListBoxPreviewDefaultPixelSize(), *pEntry );
696cdf0e10cSrcweir                 aLbBitmaps.SelectEntryPos( aLbBitmaps.GetEntryCount() - 1 );
697cdf0e10cSrcweir 
698cdf0e10cSrcweir                 // Flag fuer modifiziert setzen
699cdf0e10cSrcweir                 *pnBitmapListState |= CT_MODIFIED;
700cdf0e10cSrcweir 
701cdf0e10cSrcweir                 ChangeBitmapHdl_Impl( this );
702cdf0e10cSrcweir             }
703cdf0e10cSrcweir         }
704cdf0e10cSrcweir         else
705cdf0e10cSrcweir             // Graphik konnte nicht geladen werden
706cdf0e10cSrcweir             ErrorBox( DLGWIN,
707cdf0e10cSrcweir                       WinBits( WB_OK ),
708cdf0e10cSrcweir                       String( ResId( RID_SVXSTR_READ_DATA_ERROR, rMgr ) ) ).Execute();
709cdf0e10cSrcweir     }
710cdf0e10cSrcweir 
711cdf0e10cSrcweir     return 0L;
712cdf0e10cSrcweir }
713cdf0e10cSrcweir 
714cdf0e10cSrcweir #ifdef _MSC_VER
715cdf0e10cSrcweir #pragma optimize ( "", on )
716cdf0e10cSrcweir #endif
717cdf0e10cSrcweir 
718cdf0e10cSrcweir //------------------------------------------------------------------------
719cdf0e10cSrcweir 
720cdf0e10cSrcweir IMPL_LINK( SvxBitmapTabPage, ClickModifyHdl_Impl, void *, EMPTYARG )
721cdf0e10cSrcweir {
722cdf0e10cSrcweir     sal_uInt16 nPos = aLbBitmaps.GetSelectEntryPos();
723cdf0e10cSrcweir 
724cdf0e10cSrcweir     if ( nPos != LISTBOX_ENTRY_NOTFOUND )
725cdf0e10cSrcweir     {
726cdf0e10cSrcweir         ResMgr& rMgr = CUI_MGR();
727cdf0e10cSrcweir         String aNewName( SVX_RES( RID_SVXSTR_BITMAP ) );
728cdf0e10cSrcweir         String aDesc( ResId( RID_SVXSTR_DESC_NEW_BITMAP, rMgr ) );
729c7be74b1SArmin Le Grand         String aName( maBitmapList->GetBitmap( nPos )->GetName() );
730cdf0e10cSrcweir         String aOldName = aName;
731cdf0e10cSrcweir 
732cdf0e10cSrcweir         SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
733cdf0e10cSrcweir         DBG_ASSERT(pFact, "Dialogdiet fail!");//CHINA001
734cdf0e10cSrcweir         AbstractSvxNameDialog* pDlg = pFact->CreateSvxNameDialog( DLGWIN, aName, aDesc );
735cdf0e10cSrcweir         DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
736cdf0e10cSrcweir 
737c7be74b1SArmin Le Grand         long nCount = maBitmapList.get() ? maBitmapList->Count() : 0;
738cdf0e10cSrcweir         sal_Bool bDifferent = sal_False;
739cdf0e10cSrcweir         sal_Bool bLoop = sal_True;
740a68b38dfSArmin Le Grand         const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
741cdf0e10cSrcweir 
742cdf0e10cSrcweir         while( bLoop && pDlg->Execute() == RET_OK )
743cdf0e10cSrcweir         {
744cdf0e10cSrcweir             pDlg->GetName( aName );
745cdf0e10cSrcweir             bDifferent = sal_True;
746cdf0e10cSrcweir 
747cdf0e10cSrcweir             for( long i = 0; i < nCount && bDifferent; i++ )
748cdf0e10cSrcweir             {
749c7be74b1SArmin Le Grand                 if( aName == maBitmapList->GetBitmap( i )->GetName() &&
750cdf0e10cSrcweir                     aName != aOldName )
751cdf0e10cSrcweir                     bDifferent = sal_False;
752cdf0e10cSrcweir             }
753cdf0e10cSrcweir 
754cdf0e10cSrcweir             if( bDifferent )
755cdf0e10cSrcweir             {
756cdf0e10cSrcweir                 bLoop = sal_False;
757cdf0e10cSrcweir 
75870d3707aSArmin Le Grand                 const BitmapEx aBitmapEx(aBitmapCtl.GetBitmapEx());
759*3e407bd8SArmin Le Grand                 const XBitmapEntry aEntry(Graphic(aBitmapEx), aName);
760cdf0e10cSrcweir 
761*3e407bd8SArmin Le Grand                 aLbBitmaps.Modify( rStyleSettings.GetListBoxPreviewDefaultPixelSize(), aEntry, nPos );
762cdf0e10cSrcweir                 aLbBitmaps.SelectEntryPos( nPos );
763cdf0e10cSrcweir 
764cdf0e10cSrcweir                 // Flag fuer modifiziert setzen
765cdf0e10cSrcweir                 *pnBitmapListState |= CT_MODIFIED;
766cdf0e10cSrcweir 
767cdf0e10cSrcweir                 bBmpChanged = sal_False;
768cdf0e10cSrcweir             }
769cdf0e10cSrcweir             else
770cdf0e10cSrcweir             {
771cdf0e10cSrcweir                 WarningBox aBox( DLGWIN, WinBits( WB_OK ), String( ResId( RID_SVXSTR_WARN_NAME_DUPLICATE, rMgr ) ) );
772cdf0e10cSrcweir                 aBox.SetHelpId( HID_WARN_NAME_DUPLICATE );
773cdf0e10cSrcweir                 aBox.Execute();
774cdf0e10cSrcweir             }
775cdf0e10cSrcweir         }
776cdf0e10cSrcweir         delete pDlg;
777cdf0e10cSrcweir     }
778cdf0e10cSrcweir     return 0L;
779cdf0e10cSrcweir }
780cdf0e10cSrcweir 
781cdf0e10cSrcweir //------------------------------------------------------------------------
782cdf0e10cSrcweir 
783cdf0e10cSrcweir IMPL_LINK( SvxBitmapTabPage, ClickDeleteHdl_Impl, void *, EMPTYARG )
784cdf0e10cSrcweir {
785cdf0e10cSrcweir     sal_uInt16 nPos = aLbBitmaps.GetSelectEntryPos();
786cdf0e10cSrcweir 
787cdf0e10cSrcweir     if( nPos != LISTBOX_ENTRY_NOTFOUND )
788cdf0e10cSrcweir     {
789cdf0e10cSrcweir         QueryBox aQueryBox( DLGWIN, WinBits( WB_YES_NO | WB_DEF_NO ),
790cdf0e10cSrcweir             String( CUI_RES( RID_SVXSTR_ASK_DEL_BITMAP ) ) );
791cdf0e10cSrcweir 
792cdf0e10cSrcweir         if( aQueryBox.Execute() == RET_YES )
793cdf0e10cSrcweir         {
794c7be74b1SArmin Le Grand             delete maBitmapList->Remove( nPos );
795cdf0e10cSrcweir             aLbBitmaps.RemoveEntry( nPos );
796cdf0e10cSrcweir             aLbBitmaps.SelectEntryPos( 0 );
797cdf0e10cSrcweir 
798cdf0e10cSrcweir             aCtlPreview.Invalidate();
799cdf0e10cSrcweir             aCtlPixel.Invalidate();
800cdf0e10cSrcweir 
801cdf0e10cSrcweir             ChangeBitmapHdl_Impl( this );
802cdf0e10cSrcweir 
803cdf0e10cSrcweir             // Flag fuer modifiziert setzen
804cdf0e10cSrcweir             *pnBitmapListState |= CT_MODIFIED;
805cdf0e10cSrcweir         }
806cdf0e10cSrcweir     }
807cdf0e10cSrcweir     // Status der Buttons ermitteln
808c7be74b1SArmin Le Grand     if( !maBitmapList.get() || !maBitmapList->Count() )
809cdf0e10cSrcweir     {
810cdf0e10cSrcweir         aBtnModify.Disable();
811cdf0e10cSrcweir         aBtnDelete.Disable();
812cdf0e10cSrcweir         aBtnSave.Disable();
813cdf0e10cSrcweir     }
814cdf0e10cSrcweir     return 0L;
815cdf0e10cSrcweir }
816cdf0e10cSrcweir 
817cdf0e10cSrcweir // -----------------------------------------------------------------------
818cdf0e10cSrcweir 
819cdf0e10cSrcweir IMPL_LINK( SvxBitmapTabPage, ClickLoadHdl_Impl, void *, EMPTYARG )
820cdf0e10cSrcweir {
821cdf0e10cSrcweir     sal_uInt16 nReturn = RET_YES;
822cdf0e10cSrcweir     ResMgr& rMgr = CUI_MGR();
823cdf0e10cSrcweir 
824cdf0e10cSrcweir     if ( *pnBitmapListState & CT_MODIFIED )
825cdf0e10cSrcweir     {
826cdf0e10cSrcweir         nReturn = WarningBox( DLGWIN, WinBits( WB_YES_NO_CANCEL ),
827cdf0e10cSrcweir             String( ResId( RID_SVXSTR_WARN_TABLE_OVERWRITE, rMgr ) ) ).Execute();
828cdf0e10cSrcweir 
829cdf0e10cSrcweir         if ( nReturn == RET_YES )
830c7be74b1SArmin Le Grand             maBitmapList->Save();
831cdf0e10cSrcweir     }
832cdf0e10cSrcweir 
833cdf0e10cSrcweir     if ( nReturn != RET_CANCEL )
834cdf0e10cSrcweir     {
835cdf0e10cSrcweir         ::sfx2::FileDialogHelper aDlg(
836cdf0e10cSrcweir             com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
837cdf0e10cSrcweir             0 );
838cdf0e10cSrcweir         String aStrFilterType( RTL_CONSTASCII_USTRINGPARAM( "*.sob" ) );
839cdf0e10cSrcweir         aDlg.AddFilter( aStrFilterType, aStrFilterType );
840cdf0e10cSrcweir         INetURLObject aFile( SvtPathOptions().GetPalettePath() );
841cdf0e10cSrcweir         aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) );
842cdf0e10cSrcweir 
843cdf0e10cSrcweir         if ( aDlg.Execute() == ERRCODE_NONE )
844cdf0e10cSrcweir         {
845cdf0e10cSrcweir             EnterWait();
846cdf0e10cSrcweir             INetURLObject aURL( aDlg.GetPath() );
847cdf0e10cSrcweir             INetURLObject aPathURL( aURL );
848cdf0e10cSrcweir 
849cdf0e10cSrcweir             aPathURL.removeSegment();
850cdf0e10cSrcweir             aPathURL.removeFinalSlash();
851cdf0e10cSrcweir 
852cdf0e10cSrcweir             // Tabelle speichern
853c7be74b1SArmin Le Grand             XBitmapListSharedPtr aBmpList(XPropertyListFactory::CreateSharedXBitmapList(aPathURL.GetMainURL(INetURLObject::NO_DECODE)));
854c7be74b1SArmin Le Grand             aBmpList->SetName( aURL.getName() );
855c7be74b1SArmin Le Grand             if( aBmpList->Load() )
856cdf0e10cSrcweir             {
857c7be74b1SArmin Le Grand                 if( aBmpList.get() )
858cdf0e10cSrcweir                 {
859c7be74b1SArmin Le Grand                     maBitmapList = aBmpList;
860c7be74b1SArmin Le Grand                     ( (SvxAreaTabDialog*) DLGWIN )->SetNewBitmapList( maBitmapList );
861cdf0e10cSrcweir 
862cdf0e10cSrcweir                     aLbBitmaps.Clear();
863c7be74b1SArmin Le Grand                     aLbBitmaps.Fill( maBitmapList );
864cdf0e10cSrcweir                     Reset( rOutAttrs );
865cdf0e10cSrcweir 
866c7be74b1SArmin Le Grand                     maBitmapList->SetName( aURL.getName() );
867cdf0e10cSrcweir 
868cdf0e10cSrcweir                     // Ermitteln (evtl. abschneiden) des Namens und in
869cdf0e10cSrcweir                     // der GroupBox darstellen
870cdf0e10cSrcweir                     String aString( ResId( RID_SVXSTR_TABLE, rMgr ) );
871cdf0e10cSrcweir                     aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
872cdf0e10cSrcweir 
873cdf0e10cSrcweir                     if ( aURL.getBase().getLength() > 18 )
874cdf0e10cSrcweir                     {
875cdf0e10cSrcweir                         aString += String(aURL.getBase()).Copy( 0, 15 );
876cdf0e10cSrcweir                         aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) );
877cdf0e10cSrcweir                     }
878cdf0e10cSrcweir                     else
879cdf0e10cSrcweir                         aString += String(aURL.getBase());
880cdf0e10cSrcweir 
881cdf0e10cSrcweir                     // Flag fuer gewechselt setzen
882cdf0e10cSrcweir                     *pnBitmapListState |= CT_CHANGED;
883cdf0e10cSrcweir                     // Flag fuer modifiziert entfernen
884cdf0e10cSrcweir                     *pnBitmapListState &= ~CT_MODIFIED;
885cdf0e10cSrcweir                 }
886cdf0e10cSrcweir                 LeaveWait();
887cdf0e10cSrcweir             }
888cdf0e10cSrcweir             else
889cdf0e10cSrcweir             {
890cdf0e10cSrcweir                 LeaveWait();
891cdf0e10cSrcweir                 ErrorBox( DLGWIN, WinBits( WB_OK ),
892cdf0e10cSrcweir                     String( ResId( RID_SVXSTR_READ_DATA_ERROR, rMgr ) ) ).Execute();
893cdf0e10cSrcweir             }
894cdf0e10cSrcweir         }
895cdf0e10cSrcweir     }
896cdf0e10cSrcweir 
897cdf0e10cSrcweir     // Status der Buttons ermitteln
898c7be74b1SArmin Le Grand     if( maBitmapList.get() && maBitmapList->Count() )
899cdf0e10cSrcweir     {
900cdf0e10cSrcweir         aBtnModify.Enable();
901cdf0e10cSrcweir         aBtnDelete.Enable();
902cdf0e10cSrcweir         aBtnSave.Enable();
903cdf0e10cSrcweir     }
904cdf0e10cSrcweir     else
905cdf0e10cSrcweir     {
906cdf0e10cSrcweir         aBtnModify.Disable();
907cdf0e10cSrcweir         aBtnDelete.Disable();
908cdf0e10cSrcweir         aBtnSave.Disable();
909cdf0e10cSrcweir     }
910cdf0e10cSrcweir     return 0L;
911cdf0e10cSrcweir }
912cdf0e10cSrcweir 
913cdf0e10cSrcweir // -----------------------------------------------------------------------
914cdf0e10cSrcweir 
915cdf0e10cSrcweir IMPL_LINK( SvxBitmapTabPage, ClickSaveHdl_Impl, void *, EMPTYARG )
916cdf0e10cSrcweir {
917cdf0e10cSrcweir     ::sfx2::FileDialogHelper aDlg(
918cdf0e10cSrcweir         com::sun::star::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE, 0 );
919cdf0e10cSrcweir     String aStrFilterType( RTL_CONSTASCII_USTRINGPARAM( "*.sob" ) );
920cdf0e10cSrcweir     aDlg.AddFilter( aStrFilterType, aStrFilterType );
921cdf0e10cSrcweir 
922cdf0e10cSrcweir     INetURLObject aFile( SvtPathOptions().GetPalettePath() );
923cdf0e10cSrcweir     DBG_ASSERT( aFile.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
924cdf0e10cSrcweir 
925c7be74b1SArmin Le Grand     if( maBitmapList->GetName().Len() )
926cdf0e10cSrcweir     {
927c7be74b1SArmin Le Grand         aFile.Append( maBitmapList->GetName() );
928cdf0e10cSrcweir 
929cdf0e10cSrcweir         if( !aFile.getExtension().getLength() )
930cdf0e10cSrcweir             aFile.SetExtension( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "sob" ) ) );
931cdf0e10cSrcweir     }
932cdf0e10cSrcweir 
933cdf0e10cSrcweir     aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) );
934cdf0e10cSrcweir     if ( aDlg.Execute() == ERRCODE_NONE )
935cdf0e10cSrcweir     {
936cdf0e10cSrcweir         INetURLObject   aURL( aDlg.GetPath() );
937cdf0e10cSrcweir         INetURLObject   aPathURL( aURL );
938cdf0e10cSrcweir 
939cdf0e10cSrcweir         aPathURL.removeSegment();
940cdf0e10cSrcweir         aPathURL.removeFinalSlash();
941cdf0e10cSrcweir 
942c7be74b1SArmin Le Grand         maBitmapList->SetName( aURL.getName() );
943c7be74b1SArmin Le Grand         maBitmapList->SetPath( aPathURL.GetMainURL( INetURLObject::NO_DECODE ) );
944cdf0e10cSrcweir 
945c7be74b1SArmin Le Grand         if( maBitmapList->Save() )
946cdf0e10cSrcweir         {
947cdf0e10cSrcweir             // Ermitteln (evtl. abschneiden) des Namens und in
948cdf0e10cSrcweir             // der GroupBox darstellen
949cdf0e10cSrcweir             String aString( CUI_RES( RID_SVXSTR_TABLE ) );
950cdf0e10cSrcweir             aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
951cdf0e10cSrcweir 
952cdf0e10cSrcweir             if ( aURL.getBase().getLength() > 18 )
953cdf0e10cSrcweir             {
954cdf0e10cSrcweir                 aString += String(aURL.getBase()).Copy( 0, 15 );
955cdf0e10cSrcweir                 aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "..." ) );
956cdf0e10cSrcweir             }
957cdf0e10cSrcweir             else
958cdf0e10cSrcweir                 aString += String(aURL.getBase());
959cdf0e10cSrcweir 
960cdf0e10cSrcweir             // Flag fuer gespeichert setzen
961cdf0e10cSrcweir             *pnBitmapListState |= CT_SAVED;
962cdf0e10cSrcweir             // Flag fuer modifiziert entfernen
963cdf0e10cSrcweir             *pnBitmapListState &= ~CT_MODIFIED;
964cdf0e10cSrcweir         }
965cdf0e10cSrcweir         else
966cdf0e10cSrcweir         {
967cdf0e10cSrcweir             ErrorBox( DLGWIN, WinBits( WB_OK ),
968cdf0e10cSrcweir                 String( CUI_RES( RID_SVXSTR_WRITE_DATA_ERROR ) ) ).Execute();
969cdf0e10cSrcweir         }
970cdf0e10cSrcweir     }
971cdf0e10cSrcweir 
972cdf0e10cSrcweir     return 0L;
973cdf0e10cSrcweir }
974cdf0e10cSrcweir 
975cdf0e10cSrcweir //------------------------------------------------------------------------
976cdf0e10cSrcweir 
977cdf0e10cSrcweir IMPL_LINK( SvxBitmapTabPage, ChangePixelColorHdl_Impl, void *, EMPTYARG )
978cdf0e10cSrcweir {
979cdf0e10cSrcweir     aCtlPixel.SetPixelColor( aLbColor.GetSelectEntryColor() );
980cdf0e10cSrcweir     aCtlPixel.Invalidate();
981cdf0e10cSrcweir 
982cdf0e10cSrcweir     aBitmapCtl.SetPixelColor( aLbColor.GetSelectEntryColor() );
983cdf0e10cSrcweir 
984cdf0e10cSrcweir     // Bitmap holen und darstellen
98570d3707aSArmin Le Grand     rXFSet.Put(XFillBitmapItem(String(), Graphic(aBitmapCtl.GetBitmapEx())));
986cdf0e10cSrcweir     aCtlPreview.SetAttributes( aXFillAttr.GetItemSet() );
987cdf0e10cSrcweir     aCtlPreview.Invalidate();
988cdf0e10cSrcweir 
989cdf0e10cSrcweir     bBmpChanged = sal_True;
990cdf0e10cSrcweir 
991cdf0e10cSrcweir     return 0L;
992cdf0e10cSrcweir }
993cdf0e10cSrcweir 
994cdf0e10cSrcweir //------------------------------------------------------------------------
995cdf0e10cSrcweir 
996cdf0e10cSrcweir IMPL_LINK( SvxBitmapTabPage, ChangeBackgrndColorHdl_Impl, void *, EMPTYARG )
997cdf0e10cSrcweir {
998cdf0e10cSrcweir     aCtlPixel.SetBackgroundColor( aLbBackgroundColor.GetSelectEntryColor() );
999cdf0e10cSrcweir     aCtlPixel.Invalidate();
1000cdf0e10cSrcweir 
1001cdf0e10cSrcweir     aBitmapCtl.SetBackgroundColor( aLbBackgroundColor.GetSelectEntryColor() );
1002cdf0e10cSrcweir 
1003cdf0e10cSrcweir     // Bitmap holen und darstellen
100470d3707aSArmin Le Grand     rXFSet.Put(XFillBitmapItem(String(), Graphic(aBitmapCtl.GetBitmapEx())));
1005cdf0e10cSrcweir     aCtlPreview.SetAttributes( aXFillAttr.GetItemSet() );
1006cdf0e10cSrcweir     aCtlPreview.Invalidate();
1007cdf0e10cSrcweir 
1008cdf0e10cSrcweir     bBmpChanged = sal_True;
1009cdf0e10cSrcweir 
1010cdf0e10cSrcweir     return 0L;
1011cdf0e10cSrcweir }
1012cdf0e10cSrcweir 
1013cdf0e10cSrcweir //------------------------------------------------------------------------
1014cdf0e10cSrcweir 
1015cdf0e10cSrcweir void SvxBitmapTabPage::PointChanged( Window* pWindow, RECT_POINT )
1016cdf0e10cSrcweir {
1017cdf0e10cSrcweir     if( pWindow == &aCtlPixel )
1018cdf0e10cSrcweir     {
1019cdf0e10cSrcweir         aBitmapCtl.SetBmpArray( aCtlPixel.GetBitmapPixelPtr() );
1020cdf0e10cSrcweir 
1021cdf0e10cSrcweir         // Bitmap holen und darstellen
102270d3707aSArmin Le Grand         rXFSet.Put(XFillBitmapItem(String(), Graphic(aBitmapCtl.GetBitmapEx())));
1023cdf0e10cSrcweir         aCtlPreview.SetAttributes( aXFillAttr.GetItemSet() );
1024cdf0e10cSrcweir         aCtlPreview.Invalidate();
1025cdf0e10cSrcweir 
1026cdf0e10cSrcweir         bBmpChanged = sal_True;
1027cdf0e10cSrcweir     }
1028cdf0e10cSrcweir }
1029cdf0e10cSrcweir 
1030cdf0e10cSrcweir 
1031cdf0e10cSrcweir 
1032cdf0e10cSrcweir 
1033cdf0e10cSrcweir Window* SvxBitmapTabPage::GetParentLabeledBy( const Window* pLabeled ) const
1034cdf0e10cSrcweir {
1035cdf0e10cSrcweir     if (pLabeled == &aLbBitmaps)
1036cdf0e10cSrcweir         return const_cast<FixedText*>(&aLbBitmapsHidden);
1037cdf0e10cSrcweir     else
1038cdf0e10cSrcweir         return SvxTabPage::GetParentLabeledBy (pLabeled);
1039cdf0e10cSrcweir }
1040