1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <vcl/wrkwin.hxx>
21 #include <vcl/msgbox.hxx>
22 #include <tools/urlobj.hxx>
23 #include <unotools/ucbstreamhelper.hxx>
24 #include <unotools/pathoptions.hxx>
25 #include <sfx2/app.hxx>
26 #include <sfx2/dialoghelper.hxx>
27 #include <sfx2/filedlghelper.hxx>
28 #include <unotools/localfilehelper.hxx>
29 #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
30 #include <svx/dialmgr.hxx>
31 #include <vcl/bmpacc.hxx>
32 #include <vcl/settings.hxx>
33 #include <svx/dialogs.hrc>
37 #include "svx/xattr.hxx"
38 #include <svx/xpool.hxx>
39 #include <svx/xtable.hxx>
40 #include "svx/xoutbmp.hxx"
41 #include "svx/drawitem.hxx"
42 #include "cuitabarea.hxx"
43 #include "defdlgname.hxx"
44 #include "dlgname.hxx"
45 #include <svx/svxdlg.hxx>
46 #include <dialmgr.hxx>
47 #include "sfx2/opengrf.hxx"
48 #include "paragrph.hrc"
49 #include <boost/scoped_ptr.hpp>
51 using namespace com::sun::star
;
53 SvxBitmapTabPage::SvxBitmapTabPage( vcl::Window
* pParent
, const SfxItemSet
& rInAttrs
) :
57 "cui/ui/bitmaptabpage.ui",
59 rOutAttrs ( rInAttrs
),
61 pnBitmapListState ( 0 ),
62 pnColorListState ( 0 ),
68 bBmpChanged ( false ),
70 pXPool ( static_cast<XOutdevItemPool
*>( rInAttrs
.GetPool() )),
71 aXFStyleItem ( drawing::FillStyle_BITMAP
),
72 aXBitmapItem ( OUString(), Graphic() ),
73 aXFillAttr ( pXPool
),
74 rXFSet ( aXFillAttr
.GetItemSet() )
76 get(m_pBxPixelEditor
,"maingrid");
77 get(m_pCtlPixel
,"CTL_PIXEL");
78 get(m_pLbColor
,"LB_COLOR");
79 get(m_pLbBackgroundColor
,"LB_BACKGROUND_COLOR");
80 get(m_pCtlPreview
,"CTL_PREVIEW");
81 get(m_pLbBitmaps
,"LB_BITMAPS");
82 get(m_pLbBitmapsHidden
,"FT_BITMAPS_HIDDEN");
83 get(m_pBtnAdd
,"BTN_ADD");
84 get(m_pBtnModify
,"BTN_MODIFY");
85 get(m_pBtnImport
,"BTN_IMPORT");
86 get(m_pBtnDelete
,"BTN_DELETE");
87 get(m_pBtnLoad
,"BTN_LOAD");
88 get(m_pBtnSave
,"BTN_SAVE");
90 // size of the bitmap listbox
91 Size aSize
= getDrawListBoxOptimalSize(this);
92 m_pLbBitmaps
->set_width_request(aSize
.Width());
93 m_pLbBitmaps
->set_height_request(aSize
.Height());
95 // size of the bitmap display
96 Size aSize2
= getDrawPreviewOptimalSize(this);
97 m_pCtlPreview
->set_width_request(aSize2
.Width());
98 m_pCtlPreview
->set_height_request(aSize2
.Height());
100 m_pBitmapCtl
= new SvxBitmapCtl(this, aSize2
);
102 // this page needs ExchangeSupport
103 SetExchangeSupport();
105 // setting the output device
106 rXFSet
.Put( aXFStyleItem
);
107 rXFSet
.Put( aXBitmapItem
);
109 m_pBtnAdd
->SetClickHdl( LINK( this, SvxBitmapTabPage
, ClickAddHdl_Impl
) );
110 m_pBtnImport
->SetClickHdl( LINK( this, SvxBitmapTabPage
, ClickImportHdl_Impl
) );
111 m_pBtnModify
->SetClickHdl( LINK( this, SvxBitmapTabPage
, ClickModifyHdl_Impl
) );
112 m_pBtnDelete
->SetClickHdl( LINK( this, SvxBitmapTabPage
, ClickDeleteHdl_Impl
) );
113 m_pBtnLoad
->SetClickHdl( LINK( this, SvxBitmapTabPage
, ClickLoadHdl_Impl
) );
114 m_pBtnSave
->SetClickHdl( LINK( this, SvxBitmapTabPage
, ClickSaveHdl_Impl
) );
116 m_pLbBitmaps
->SetSelectHdl( LINK( this, SvxBitmapTabPage
, ChangeBitmapHdl_Impl
) );
117 m_pLbColor
->SetSelectHdl( LINK( this, SvxBitmapTabPage
, ChangePixelColorHdl_Impl
) );
118 m_pLbBackgroundColor
->SetSelectHdl( LINK( this, SvxBitmapTabPage
, ChangeBackgrndColorHdl_Impl
) );
120 setPreviewsToSamePlace(pParent
, this);
123 SvxBitmapTabPage::~SvxBitmapTabPage()
128 void SvxBitmapTabPage::dispose()
132 m_pBxPixelEditor
.clear();
135 m_pLbBackgroundColor
.clear();
136 m_pLbBitmapsHidden
.clear();
137 m_pLbBitmaps
.clear();
138 m_pCtlPreview
.clear();
140 m_pBtnModify
.clear();
141 m_pBtnImport
.clear();
142 m_pBtnDelete
.clear();
145 SvxTabPage::dispose();
148 void SvxBitmapTabPage::Construct()
150 m_pLbColor
->Fill( pColorList
);
151 m_pLbBackgroundColor
->CopyEntries( *m_pLbColor
);
153 m_pLbBitmaps
->Fill( pBitmapList
);
158 void SvxBitmapTabPage::ActivatePage( const SfxItemSet
& )
163 if( nDlgType
== 0 ) // area dialog
167 if( pColorList
.is() )
170 if( *pnColorListState
& ChangeType::CHANGED
||
171 *pnColorListState
& ChangeType::MODIFIED
)
173 if( *pnColorListState
& ChangeType::CHANGED
)
174 pColorList
= static_cast<SvxAreaTabDialog
*>( GetParentDialog() )->GetNewColorList();
177 nPos
= m_pLbColor
->GetSelectEntryPos();
179 m_pLbColor
->Fill( pColorList
);
180 nCount
= m_pLbColor
->GetEntryCount();
182 ; // this case should not occur
183 else if( nCount
<= nPos
)
184 m_pLbColor
->SelectEntryPos( 0 );
186 m_pLbColor
->SelectEntryPos( nPos
);
189 nPos
= m_pLbBackgroundColor
->GetSelectEntryPos();
190 m_pLbBackgroundColor
->Clear();
191 m_pLbBackgroundColor
->CopyEntries( *m_pLbColor
);
192 nCount
= m_pLbBackgroundColor
->GetEntryCount();
194 ; // this case should not occur
195 else if( nCount
<= nPos
)
196 m_pLbBackgroundColor
->SelectEntryPos( 0 );
198 m_pLbBackgroundColor
->SelectEntryPos( nPos
);
200 ChangePixelColorHdl_Impl( this );
201 ChangeBackgrndColorHdl_Impl( this );
204 // determining (possibly cutting) the name and
205 // displaying it in the GroupBox
206 OUString
aString( CUI_RES( RID_SVXSTR_TABLE
) );
208 INetURLObject
aURL( pBitmapList
->GetPath() );
210 aURL
.Append( pBitmapList
->GetName() );
211 DBG_ASSERT( aURL
.GetProtocol() != INetProtocol::NotValid
, "invalid URL" );
213 if( aURL
.getBase().getLength() > 18 )
215 aString
+= aURL
.getBase().copy( 0, 15 );
219 aString
+= aURL
.getBase();
221 if( *pPageType
== PT_BITMAP
&& *pPos
!= LISTBOX_ENTRY_NOTFOUND
)
223 m_pLbBitmaps
->SelectEntryPos( *pPos
);
225 // colors could have been deleted
226 ChangeBitmapHdl_Impl( this );
228 *pPageType
= PT_BITMAP
;
229 *pPos
= LISTBOX_ENTRY_NOTFOUND
;
236 SfxTabPage::sfxpg
SvxBitmapTabPage::DeactivatePage( SfxItemSet
* _pSet
)
238 if ( CheckChanges_Impl() == -1L )
242 FillItemSet( _pSet
);
249 bool SvxBitmapTabPage::FillItemSet( SfxItemSet
* _rOutAttrs
)
251 if( nDlgType
== 0 && !*pbAreaTP
) // area dialog
253 if(PT_BITMAP
== *pPageType
)
255 _rOutAttrs
->Put(XFillStyleItem(drawing::FillStyle_BITMAP
));
256 sal_Int32 nPos
= m_pLbBitmaps
->GetSelectEntryPos();
257 if(LISTBOX_ENTRY_NOTFOUND
!= nPos
)
259 const XBitmapEntry
* pXBitmapEntry
= pBitmapList
->GetBitmap(nPos
);
260 const OUString
aString(m_pLbBitmaps
->GetSelectEntry());
262 _rOutAttrs
->Put(XFillBitmapItem(aString
, pXBitmapEntry
->GetGraphicObject()));
266 const BitmapEx
aBitmapEx(m_pBitmapCtl
->GetBitmapEx());
268 _rOutAttrs
->Put(XFillBitmapItem(OUString(), Graphic(aBitmapEx
)));
278 void SvxBitmapTabPage::Reset( const SfxItemSet
* )
280 // aLbBitmaps.SelectEntryPos( 0 );
282 m_pBitmapCtl
->SetLines( m_pCtlPixel
->GetLineCount() );
283 m_pBitmapCtl
->SetPixelColor( m_pLbColor
->GetSelectEntryColor() );
284 m_pBitmapCtl
->SetBackgroundColor( m_pLbBackgroundColor
->GetSelectEntryColor() );
285 m_pBitmapCtl
->SetBmpArray( m_pCtlPixel
->GetBitmapPixelPtr() );
287 // get bitmap and display it
288 const XFillBitmapItem
aBmpItem(OUString(), Graphic(m_pBitmapCtl
->GetBitmapEx()));
289 rXFSet
.Put( aBmpItem
);
290 m_pCtlPreview
->SetAttributes( aXFillAttr
.GetItemSet() );
291 m_pCtlPreview
->Invalidate();
293 ChangeBitmapHdl_Impl( this );
295 // determine button state
296 if( pBitmapList
.is() && pBitmapList
->Count() )
299 m_pBtnModify
->Enable();
300 m_pBtnDelete
->Enable();
301 m_pBtnSave
->Enable();
305 m_pBtnModify
->Disable();
306 m_pBtnDelete
->Disable();
307 m_pBtnSave
->Disable();
313 VclPtr
<SfxTabPage
> SvxBitmapTabPage::Create( vcl::Window
* pWindow
,
314 const SfxItemSet
* rSet
)
316 return VclPtr
<SvxBitmapTabPage
>::Create( pWindow
, *rSet
);
321 IMPL_LINK_NOARG(SvxBitmapTabPage
, ChangeBitmapHdl_Impl
)
323 boost::scoped_ptr
<GraphicObject
> pGraphicObject
;
324 int nPos(m_pLbBitmaps
->GetSelectEntryPos());
326 if(LISTBOX_ENTRY_NOTFOUND
!= nPos
)
328 pGraphicObject
.reset(new GraphicObject(pBitmapList
->GetBitmap(nPos
)->GetGraphicObject()));
332 const SfxPoolItem
* pPoolItem
= 0;
334 if(SfxItemState::SET
== rOutAttrs
.GetItemState(GetWhich(XATTR_FILLSTYLE
), true, &pPoolItem
))
336 const drawing::FillStyle
eXFS((drawing::FillStyle
)static_cast<const XFillStyleItem
*>(pPoolItem
)->GetValue());
338 if((drawing::FillStyle_BITMAP
== eXFS
) && (SfxItemState::SET
== rOutAttrs
.GetItemState(GetWhich(XATTR_FILLBITMAP
), true, &pPoolItem
)))
340 pGraphicObject
.reset(new GraphicObject(static_cast<const XFillBitmapItem
*>(pPoolItem
)->GetGraphicObject()));
346 m_pLbBitmaps
->SelectEntryPos(0);
347 nPos
= m_pLbBitmaps
->GetSelectEntryPos();
349 if(LISTBOX_ENTRY_NOTFOUND
!= nPos
)
351 pGraphicObject
.reset(new GraphicObject(pBitmapList
->GetBitmap(nPos
)->GetGraphicObject()));
360 bool bIs8x8(isHistorical8x8(pGraphicObject
->GetGraphic().GetBitmap(), aBack
, aFront
));
362 m_pLbColor
->SetNoSelection();
363 m_pLbBackgroundColor
->SetNoSelection();
367 m_pCtlPixel
->SetPaintable( true );
368 m_pBxPixelEditor
->Enable();
369 m_pBtnModify
->Enable();
372 // setting the pixel control
374 m_pCtlPixel
->SetXBitmap(pGraphicObject
->GetGraphic().GetBitmapEx());
376 Color aPixelColor
= aFront
;
377 Color aBackColor
= aBack
;
379 // #i123564# This causes the wrong color to be selected
380 // as foreground color when the 1st bitmap in the bitmap
381 // list is selected. I see no reason why this is done,
382 // thus I will take it out
384 //if( 0 == m_pLbBitmaps->GetSelectEntryPos() )
386 // m_pLbColor->SelectEntry( Color( COL_BLACK ) );
387 // ChangePixelColorHdl_Impl( this );
391 m_pLbColor
->SelectEntry( aPixelColor
);
393 if( m_pLbColor
->GetSelectEntryCount() == 0 )
395 m_pLbColor
->InsertEntry( aPixelColor
, OUString() );
396 m_pLbColor
->SelectEntry( aPixelColor
);
399 m_pLbBackgroundColor
->SelectEntry( aBackColor
);
401 if( m_pLbBackgroundColor
->GetSelectEntryCount() == 0 )
403 m_pLbBackgroundColor
->InsertEntry( aBackColor
, OUString() );
404 m_pLbBackgroundColor
->SelectEntry( aBackColor
);
407 // update m_pBitmapCtl, rXFSet and m_pCtlPreview
408 m_pBitmapCtl
->SetPixelColor( aPixelColor
);
409 m_pBitmapCtl
->SetBackgroundColor( aBackColor
);
410 rXFSet
.Put(XFillBitmapItem(OUString(), Graphic(m_pBitmapCtl
->GetBitmapEx())));
411 m_pCtlPreview
->SetAttributes( aXFillAttr
.GetItemSet() );
412 m_pCtlPreview
->Invalidate();
416 m_pCtlPixel
->Reset();
417 m_pCtlPixel
->SetPaintable( false );
418 m_pBxPixelEditor
->Disable();
419 m_pBtnModify
->Disable();
420 m_pBtnAdd
->Disable();
423 m_pCtlPixel
->Invalidate();
426 const XFillBitmapItem
aXBmpItem(OUString(), *pGraphicObject
);
427 rXFSet
.Put( aXBmpItem
);
429 m_pCtlPreview
->SetAttributes( aXFillAttr
.GetItemSet() );
430 m_pCtlPreview
->Invalidate();
440 long SvxBitmapTabPage::CheckChanges_Impl()
442 sal_Int32 nPos
= m_pLbBitmaps
->GetSelectEntryPos();
443 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
447 ResMgr
& rMgr
= CUI_MGR();
448 Image aWarningBoxImage
= WarningBox::GetStandardImage();
449 ScopedVclPtrInstance
<SvxMessDialog
> aMessDlg( GetParentDialog(),
450 SVX_RES( RID_SVXSTR_BITMAP
),
451 CUI_RES( RID_SVXSTR_ASK_CHANGE_BITMAP
),
453 DBG_ASSERT(aMessDlg
, "Dialog creation failed!");
454 aMessDlg
->SetButtonText( MESS_BTN_1
, ResId( RID_SVXSTR_CHANGE
, rMgr
) );
455 aMessDlg
->SetButtonText( MESS_BTN_2
, ResId( RID_SVXSTR_ADD
, rMgr
) );
457 short nRet
= aMessDlg
->Execute();
463 ClickModifyHdl_Impl( this );
469 ClickAddHdl_Impl( this );
478 nPos
= m_pLbBitmaps
->GetSelectEntryPos();
479 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
486 IMPL_LINK_NOARG(SvxBitmapTabPage
, ClickAddHdl_Impl
)
489 OUString
aNewName( SVX_RES( RID_SVXSTR_BITMAP
) );
490 OUString
aDesc( CUI_RES( RID_SVXSTR_DESC_NEW_BITMAP
) );
493 long nCount
= pBitmapList
->Count();
495 bool bDifferent
= false;
501 aName
+= OUString::number( j
++ );
504 for( long i
= 0; i
< nCount
&& bDifferent
; i
++ )
505 if( aName
== pBitmapList
->GetBitmap( i
)->GetName() )
509 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
510 DBG_ASSERT(pFact
, "Dialog creation failed!");
511 boost::scoped_ptr
<AbstractSvxNameDialog
> pDlg(pFact
->CreateSvxNameDialog( GetParentDialog(), aName
, aDesc
));
512 DBG_ASSERT(pDlg
, "Dialog creation failed!");
513 ScopedVclPtr
<MessageDialog
> pWarnBox
;
514 sal_uInt16
nError(1);
516 while( pDlg
->Execute() == RET_OK
)
518 pDlg
->GetName( aName
);
522 for( long i
= 0; i
< nCount
&& bDifferent
; i
++ )
523 if( aName
== pBitmapList
->GetBitmap( i
)->GetName() )
533 pWarnBox
.reset(VclPtr
<MessageDialog
>::Create( GetParentDialog()
534 ,"DuplicateNameDialog"
535 ,"cui/ui/queryduplicatedialog.ui"));
538 if( pWarnBox
->Execute() != RET_OK
)
547 XBitmapEntry
* pEntry
= 0;
548 if( m_pCtlPixel
->IsEnabled() )
550 const BitmapEx
aBitmapEx(m_pBitmapCtl
->GetBitmapEx());
552 pEntry
= new XBitmapEntry(Graphic(aBitmapEx
), aName
);
554 else // it must be a not existing imported bitmap
556 const SfxPoolItem
* pPoolItem
= 0;
558 if(SfxItemState::SET
== rOutAttrs
.GetItemState(XATTR_FILLBITMAP
, true, &pPoolItem
))
560 pEntry
= new XBitmapEntry(dynamic_cast< const XFillBitmapItem
* >(pPoolItem
)->GetGraphicObject(), aName
);
564 DBG_ASSERT( pEntry
, "SvxBitmapTabPage::ClickAddHdl_Impl(), pEntry == 0 ?" );
568 pBitmapList
->Insert( pEntry
);
569 const StyleSettings
& rStyleSettings
= Application::GetSettings().GetStyleSettings();
570 m_pLbBitmaps
->Append(rStyleSettings
.GetListBoxPreviewDefaultPixelSize(), *pEntry
);
571 m_pLbBitmaps
->SelectEntryPos( m_pLbBitmaps
->GetEntryCount() - 1 );
573 *pnBitmapListState
|= ChangeType::MODIFIED
;
575 ChangeBitmapHdl_Impl( this );
579 // determine button state
580 if( pBitmapList
->Count() )
582 m_pBtnModify
->Enable();
583 m_pBtnDelete
->Enable();
584 m_pBtnSave
->Enable();
590 /******************************************************************************/
591 /******************************************************************************/
596 IMPL_LINK_NOARG(SvxBitmapTabPage
, ClickImportHdl_Impl
)
598 ResMgr
& rMgr
= CUI_MGR();
599 SvxOpenGraphicDialog
aDlg( OUString("Import") );
600 aDlg
.EnableLink(false);
602 if( !aDlg
.Execute() )
607 int nError
= aDlg
.GetGraphic( aGraphic
);
612 OUString
aDesc( ResId(RID_SVXSTR_DESC_EXT_BITMAP
, rMgr
) );
613 ScopedVclPtr
<MessageDialog
> pWarnBox
;
615 // convert file URL to UI name
617 INetURLObject
aURL( aDlg
.GetPath() );
618 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
619 DBG_ASSERT(pFact
, "Dialog creation failed!");
620 boost::scoped_ptr
<AbstractSvxNameDialog
> pDlg(pFact
->CreateSvxNameDialog( GetParentDialog(), aURL
.GetName().getToken( 0, '.' ), aDesc
));
621 DBG_ASSERT(pDlg
, "Dialog creation failed!");
624 while( pDlg
->Execute() == RET_OK
)
626 pDlg
->GetName( aName
);
628 bool bDifferent
= true;
629 long nCount
= pBitmapList
->Count();
631 for( long i
= 0; i
< nCount
&& bDifferent
; i
++ )
632 if( aName
== pBitmapList
->GetBitmap( i
)->GetName() )
642 pWarnBox
.reset(VclPtr
<MessageDialog
>::Create( GetParentDialog()
643 ,"DuplicateNameDialog"
644 ,"cui/ui/queryduplicatedialog.ui"));
647 if( pWarnBox
->Execute() != RET_OK
)
656 XBitmapEntry
* pEntry
= new XBitmapEntry( aGraphic
, aName
);
657 pBitmapList
->Insert( pEntry
);
659 const StyleSettings
& rStyleSettings
= Application::GetSettings().GetStyleSettings();
660 m_pLbBitmaps
->Append(rStyleSettings
.GetListBoxPreviewDefaultPixelSize(), *pEntry
);
661 m_pLbBitmaps
->SelectEntryPos( m_pLbBitmaps
->GetEntryCount() - 1 );
663 *pnBitmapListState
|= ChangeType::MODIFIED
;
665 ChangeBitmapHdl_Impl( this );
669 // graphic couldn't be loaded
670 ScopedVclPtrInstance
<MessageDialog
>::Create( GetParentDialog()
671 ,"NoLoadedFileDialog"
672 ,"cui/ui/querynoloadedfiledialog.ui")->Execute();
680 IMPL_LINK_NOARG(SvxBitmapTabPage
, ClickModifyHdl_Impl
)
682 sal_Int32 nPos
= m_pLbBitmaps
->GetSelectEntryPos();
684 if ( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
686 ResMgr
& rMgr
= CUI_MGR();
687 OUString
aDesc( ResId( RID_SVXSTR_DESC_NEW_BITMAP
, rMgr
) );
688 OUString
aName( pBitmapList
->GetBitmap( nPos
)->GetName() );
689 OUString aOldName
= aName
;
691 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
692 DBG_ASSERT(pFact
, "Dialog creation failed!");
693 boost::scoped_ptr
<AbstractSvxNameDialog
> pDlg(pFact
->CreateSvxNameDialog( GetParentDialog(), aName
, aDesc
));
694 DBG_ASSERT(pDlg
, "Dialog creation failed!");
696 long nCount
= pBitmapList
->Count();
698 const StyleSettings
& rStyleSettings
= Application::GetSettings().GetStyleSettings();
700 while( bLoop
&& pDlg
->Execute() == RET_OK
)
702 pDlg
->GetName( aName
);
703 bool bDifferent
= true;
705 for( long i
= 0; i
< nCount
&& bDifferent
; i
++ )
707 if( aName
== pBitmapList
->GetBitmap( i
)->GetName() &&
716 const BitmapEx
aBitmapEx(m_pBitmapCtl
->GetBitmapEx());
718 // #i123497# Need to replace the existing entry with a new one (old returned needs to be deleted)
719 XBitmapEntry
* pEntry
= new XBitmapEntry(Graphic(aBitmapEx
), aName
);
720 delete pBitmapList
->Replace(pEntry
, nPos
);
722 m_pLbBitmaps
->Modify( rStyleSettings
.GetListBoxPreviewDefaultPixelSize(), *pEntry
, nPos
);
723 m_pLbBitmaps
->SelectEntryPos( nPos
);
725 *pnBitmapListState
|= ChangeType::MODIFIED
;
731 ScopedVclPtrInstance
<MessageDialog
> aBox(
733 ,"DuplicateNameDialog"
734 ,"cui/ui/queryduplicatedialog.ui");
744 IMPL_LINK_NOARG(SvxBitmapTabPage
, ClickDeleteHdl_Impl
)
746 sal_Int32 nPos
= m_pLbBitmaps
->GetSelectEntryPos();
748 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
750 ScopedVclPtrInstance
< MessageDialog
> aQueryBox( GetParentDialog(),"AskDelBitmapDialog","cui/ui/querydeletebitmapdialog.ui" );
752 if( aQueryBox
->Execute() == RET_YES
)
754 delete pBitmapList
->Remove( nPos
);
755 m_pLbBitmaps
->RemoveEntry( nPos
);
756 m_pLbBitmaps
->SelectEntryPos( 0 );
758 m_pCtlPreview
->Invalidate();
759 m_pCtlPixel
->Invalidate();
761 ChangeBitmapHdl_Impl( this );
763 *pnBitmapListState
|= ChangeType::MODIFIED
;
766 // determine button state
767 if( !pBitmapList
->Count() )
769 m_pBtnModify
->Disable();
770 m_pBtnDelete
->Disable();
771 m_pBtnSave
->Disable();
778 IMPL_LINK_NOARG(SvxBitmapTabPage
, ClickLoadHdl_Impl
)
780 sal_uInt16 nReturn
= RET_YES
;
781 ResMgr
& rMgr
= CUI_MGR();
783 if ( *pnBitmapListState
& ChangeType::MODIFIED
)
785 nReturn
= ScopedVclPtrInstance
<MessageDialog
>::Create( GetParentDialog()
787 ,"cui/ui/querysavelistdialog.ui")->Execute();
789 if ( nReturn
== RET_YES
)
793 if ( nReturn
!= RET_CANCEL
)
795 ::sfx2::FileDialogHelper
aDlg( com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE
, 0 );
796 OUString
aStrFilterType( "*.sob" );
797 aDlg
.AddFilter( aStrFilterType
, aStrFilterType
);
798 INetURLObject
aFile( SvtPathOptions().GetPalettePath() );
799 aDlg
.SetDisplayDirectory( aFile
.GetMainURL( INetURLObject::NO_DECODE
) );
801 if ( aDlg
.Execute() == ERRCODE_NONE
)
804 INetURLObject
aURL( aDlg
.GetPath() );
805 INetURLObject
aPathURL( aURL
);
807 aPathURL
.removeSegment();
808 aPathURL
.removeFinalSlash();
811 XBitmapListRef pBmpList
= XPropertyList::AsBitmapList(
812 XPropertyList::CreatePropertyList(
813 XBITMAP_LIST
, aPathURL
.GetMainURL(INetURLObject::NO_DECODE
),
815 pBmpList
->SetName( aURL
.getName() );
816 if( pBmpList
->Load() )
818 pBitmapList
= pBmpList
;
819 static_cast<SvxAreaTabDialog
*>( GetParentDialog() )->SetNewBitmapList( pBitmapList
);
821 m_pLbBitmaps
->Clear();
822 m_pLbBitmaps
->Fill( pBitmapList
);
825 pBitmapList
->SetName( aURL
.getName() );
827 // determining (possibly cutting) the name
828 // displaying it in the GroupBox
829 OUString
aString( ResId( RID_SVXSTR_TABLE
, rMgr
) );
832 if ( aURL
.getBase().getLength() > 18 )
834 aString
+= aURL
.getBase().copy( 0, 15 );
838 aString
+= aURL
.getBase();
840 *pnBitmapListState
|= ChangeType::CHANGED
;
841 *pnBitmapListState
&= ~ChangeType::MODIFIED
;
847 ScopedVclPtrInstance
<MessageDialog
>::Create( GetParentDialog()
848 ,"NoLoadedFileDialog"
849 ,"cui/ui/querynoloadedfiledialog.ui")->Execute();
854 // determine button state
855 if( pBitmapList
->Count() )
857 m_pBtnModify
->Enable();
858 m_pBtnDelete
->Enable();
859 m_pBtnSave
->Enable();
863 m_pBtnModify
->Disable();
864 m_pBtnDelete
->Disable();
865 m_pBtnSave
->Disable();
872 IMPL_LINK_NOARG(SvxBitmapTabPage
, ClickSaveHdl_Impl
)
874 ::sfx2::FileDialogHelper
aDlg( com::sun::star::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE
, 0 );
875 OUString
aStrFilterType( "*.sob" );
876 aDlg
.AddFilter( aStrFilterType
, aStrFilterType
);
878 INetURLObject
aFile( SvtPathOptions().GetPalettePath() );
879 DBG_ASSERT( aFile
.GetProtocol() != INetProtocol::NotValid
, "invalid URL" );
881 if( !pBitmapList
->GetName().isEmpty() )
883 aFile
.Append( pBitmapList
->GetName() );
885 if( aFile
.getExtension().isEmpty() )
886 aFile
.SetExtension( OUString("sob") );
889 aDlg
.SetDisplayDirectory( aFile
.GetMainURL( INetURLObject::NO_DECODE
) );
890 if ( aDlg
.Execute() == ERRCODE_NONE
)
892 INetURLObject
aURL( aDlg
.GetPath() );
893 INetURLObject
aPathURL( aURL
);
895 aPathURL
.removeSegment();
896 aPathURL
.removeFinalSlash();
898 pBitmapList
->SetName( aURL
.getName() );
899 pBitmapList
->SetPath( aPathURL
.GetMainURL( INetURLObject::NO_DECODE
) );
901 if( pBitmapList
->Save() )
903 // determining (possibly cutting) the name
904 // displaying it in the GroupBox
905 OUString
aString( CUI_RES( RID_SVXSTR_TABLE
) );
908 if ( aURL
.getBase().getLength() > 18 )
910 aString
+= aURL
.getBase().copy( 0, 15 );
914 aString
+= aURL
.getBase();
916 *pnBitmapListState
|= ChangeType::SAVED
;
917 *pnBitmapListState
&= ~ChangeType::MODIFIED
;
921 ScopedVclPtrInstance
<MessageDialog
>::Create( GetParentDialog()
923 ,"cui/ui/querynosavefiledialog.ui")->Execute();
932 IMPL_LINK_NOARG(SvxBitmapTabPage
, ChangePixelColorHdl_Impl
)
934 m_pCtlPixel
->SetPixelColor( m_pLbColor
->GetSelectEntryColor() );
935 m_pCtlPixel
->Invalidate();
937 m_pBitmapCtl
->SetPixelColor( m_pLbColor
->GetSelectEntryColor() );
939 // get bitmap and display it
940 rXFSet
.Put(XFillBitmapItem(OUString(), Graphic(m_pBitmapCtl
->GetBitmapEx())));
941 m_pCtlPreview
->SetAttributes( aXFillAttr
.GetItemSet() );
942 m_pCtlPreview
->Invalidate();
951 IMPL_LINK_NOARG(SvxBitmapTabPage
, ChangeBackgrndColorHdl_Impl
)
953 m_pCtlPixel
->SetBackgroundColor( m_pLbBackgroundColor
->GetSelectEntryColor() );
954 m_pCtlPixel
->Invalidate();
956 m_pBitmapCtl
->SetBackgroundColor( m_pLbBackgroundColor
->GetSelectEntryColor() );
958 // get bitmap and display it
959 rXFSet
.Put(XFillBitmapItem(OUString(), Graphic(m_pBitmapCtl
->GetBitmapEx())));
960 m_pCtlPreview
->SetAttributes( aXFillAttr
.GetItemSet() );
961 m_pCtlPreview
->Invalidate();
970 void SvxBitmapTabPage::PointChanged( vcl::Window
* pWindow
, RECT_POINT
)
972 if( pWindow
== m_pCtlPixel
)
974 m_pBitmapCtl
->SetBmpArray( m_pCtlPixel
->GetBitmapPixelPtr() );
976 // get bitmap and display it
977 rXFSet
.Put(XFillBitmapItem(OUString(), Graphic(m_pBitmapCtl
->GetBitmapEx())));
978 m_pCtlPreview
->SetAttributes( aXFillAttr
.GetItemSet() );
979 m_pCtlPreview
->Invalidate();
988 vcl::Window
* SvxBitmapTabPage::GetParentLabeledBy( const vcl::Window
* pLabeled
) const
990 if (pLabeled
== m_pLbBitmaps
)
991 return m_pLbBitmapsHidden
.get();
993 return SvxTabPage::GetParentLabeledBy (pLabeled
);
996 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */