1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sfx2.hxx" 30 31 // INCLUDE --------------------------------------------------------------- 32 #include <svl/style.hxx> 33 #ifndef GCC 34 #endif 35 36 #include <sfx2/newstyle.hxx> 37 #include "dialog.hrc" 38 #include "newstyle.hrc" 39 #include "sfx2/sfxresid.hxx" 40 41 // PRIVATE METHODES ------------------------------------------------------ 42 43 IMPL_LINK( SfxNewStyleDlg, OKHdl, Control *, pControl ) 44 { 45 (void)pControl; //unused 46 const String aName( aColBox.GetText() ); 47 SfxStyleSheetBase* pStyle = rPool.Find( aName, rPool.GetSearchFamily(), SFXSTYLEBIT_ALL ); 48 if ( pStyle ) 49 { 50 if ( !pStyle->IsUserDefined() ) 51 { 52 InfoBox( this, SfxResId( MSG_POOL_STYLE_NAME ) ).Execute(); 53 return 0; 54 } 55 56 if ( RET_YES == aQueryOverwriteBox.Execute() ) 57 EndDialog( RET_OK ); 58 } 59 else 60 EndDialog( RET_OK ); 61 62 return 0; 63 } 64 65 // ----------------------------------------------------------------------- 66 67 IMPL_LINK_INLINE_START( SfxNewStyleDlg, ModifyHdl, ComboBox *, pBox ) 68 { 69 aOKBtn.Enable( pBox->GetText().EraseAllChars().Len() > 0 ); 70 return 0; 71 } 72 IMPL_LINK_INLINE_END( SfxNewStyleDlg, ModifyHdl, ComboBox *, pBox ) 73 74 // CTOR / DTOR ----------------------------------------------------------- 75 76 SfxNewStyleDlg::SfxNewStyleDlg( Window* pParent, SfxStyleSheetBasePool& rInPool ) : 77 78 ModalDialog( pParent, SfxResId( DLG_NEW_STYLE_BY_EXAMPLE ) ), 79 80 aColFL ( this, SfxResId( FL_COL ) ), 81 aColBox ( this, SfxResId( LB_COL ) ), 82 aOKBtn ( this, SfxResId( BT_OK ) ), 83 aCancelBtn ( this, SfxResId( BT_CANCEL ) ), 84 aQueryOverwriteBox ( this, SfxResId( MSG_OVERWRITE ) ), 85 86 rPool( rInPool ) 87 88 { 89 FreeResource(); 90 91 aOKBtn.SetClickHdl(LINK(this, SfxNewStyleDlg, OKHdl)); 92 aColBox.SetModifyHdl(LINK(this, SfxNewStyleDlg, ModifyHdl)); 93 aColBox.SetDoubleClickHdl(LINK(this, SfxNewStyleDlg, OKHdl)); 94 // aColBox.SetAccessibleName(SfxResId(FL_COL)); 95 96 SfxStyleSheetBase *pStyle = rPool.First(); 97 while ( pStyle ) 98 { 99 aColBox.InsertEntry(pStyle->GetName()); 100 pStyle = rPool.Next(); 101 } 102 } 103 104 // ----------------------------------------------------------------------- 105 106 __EXPORT SfxNewStyleDlg::~SfxNewStyleDlg() 107 { 108 } 109 110