merge the formfield patch from ooo-build
[ooovba.git] / sfx2 / source / dialog / newstyle.cxx
blob192f5917f3cac0533cc43b110956a41f765d3d15
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: newstyle.cxx,v $
10 * $Revision: 1.9 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sfx2.hxx"
34 // INCLUDE ---------------------------------------------------------------
35 #include <svtools/style.hxx>
36 #ifndef GCC
37 #endif
39 #include <sfx2/newstyle.hxx>
40 #include "dialog.hrc"
41 #include "newstyle.hrc"
42 #include "sfxresid.hxx"
44 // PRIVATE METHODES ------------------------------------------------------
46 IMPL_LINK( SfxNewStyleDlg, OKHdl, Control *, pControl )
48 (void)pControl; //unused
49 const String aName( aColBox.GetText() );
50 SfxStyleSheetBase* pStyle = rPool.Find( aName, rPool.GetSearchFamily(), SFXSTYLEBIT_ALL );
51 if ( pStyle )
53 if ( !pStyle->IsUserDefined() )
55 InfoBox( this, SfxResId( MSG_POOL_STYLE_NAME ) ).Execute();
56 return 0;
59 if ( RET_YES == aQueryOverwriteBox.Execute() )
60 EndDialog( RET_OK );
62 else
63 EndDialog( RET_OK );
65 return 0;
68 // -----------------------------------------------------------------------
70 IMPL_LINK_INLINE_START( SfxNewStyleDlg, ModifyHdl, ComboBox *, pBox )
72 aOKBtn.Enable( pBox->GetText().EraseAllChars().Len() > 0 );
73 return 0;
75 IMPL_LINK_INLINE_END( SfxNewStyleDlg, ModifyHdl, ComboBox *, pBox )
77 // CTOR / DTOR -----------------------------------------------------------
79 SfxNewStyleDlg::SfxNewStyleDlg( Window* pParent, SfxStyleSheetBasePool& rInPool ) :
81 ModalDialog( pParent, SfxResId( DLG_NEW_STYLE_BY_EXAMPLE ) ),
83 aColFL ( this, SfxResId( FL_COL ) ),
84 aColBox ( this, SfxResId( LB_COL ) ),
85 aOKBtn ( this, SfxResId( BT_OK ) ),
86 aCancelBtn ( this, SfxResId( BT_CANCEL ) ),
87 aQueryOverwriteBox ( this, SfxResId( MSG_OVERWRITE ) ),
89 rPool( rInPool )
92 FreeResource();
94 aOKBtn.SetClickHdl(LINK(this, SfxNewStyleDlg, OKHdl));
95 aColBox.SetModifyHdl(LINK(this, SfxNewStyleDlg, ModifyHdl));
96 aColBox.SetDoubleClickHdl(LINK(this, SfxNewStyleDlg, OKHdl));
98 SfxStyleSheetBase *pStyle = rPool.First();
99 while ( pStyle )
101 aColBox.InsertEntry(pStyle->GetName());
102 pStyle = rPool.Next();
106 // -----------------------------------------------------------------------
108 __EXPORT SfxNewStyleDlg::~SfxNewStyleDlg()