1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 // INCLUDE ---------------------------------------------------------------
31 #include <comphelper/string.hxx>
33 #include <svl/style.hxx>
35 #include <sfx2/newstyle.hxx>
37 #include "newstyle.hrc"
38 #include "sfx2/sfxresid.hxx"
40 // PRIVATE METHODES ------------------------------------------------------
42 IMPL_LINK( SfxNewStyleDlg
, OKHdl
, Control
*, pControl
)
44 (void)pControl
; //unused
45 const String
aName( aColBox
.GetText() );
46 SfxStyleSheetBase
* pStyle
= rPool
.Find( aName
, rPool
.GetSearchFamily(), SFXSTYLEBIT_ALL
);
49 if ( !pStyle
->IsUserDefined() )
51 InfoBox( this, SfxResId( MSG_POOL_STYLE_NAME
) ).Execute();
55 if ( RET_YES
== aQueryOverwriteBox
.Execute() )
64 // -----------------------------------------------------------------------
66 IMPL_LINK_INLINE_START( SfxNewStyleDlg
, ModifyHdl
, ComboBox
*, pBox
)
68 aOKBtn
.Enable( !comphelper::string::remove(pBox
->GetText(), ' ').isEmpty() );
71 IMPL_LINK_INLINE_END( SfxNewStyleDlg
, ModifyHdl
, ComboBox
*, pBox
)
73 // CTOR / DTOR -----------------------------------------------------------
75 SfxNewStyleDlg::SfxNewStyleDlg( Window
* pParent
, SfxStyleSheetBasePool
& rInPool
) :
77 ModalDialog( pParent
, SfxResId( DLG_NEW_STYLE_BY_EXAMPLE
) ),
79 aColFL ( this, SfxResId( FL_COL
) ),
80 aColBox ( this, SfxResId( LB_COL
) ),
81 aOKBtn ( this, SfxResId( BT_OK
) ),
82 aCancelBtn ( this, SfxResId( BT_CANCEL
) ),
83 aQueryOverwriteBox ( this, SfxResId( MSG_OVERWRITE
) ),
90 aOKBtn
.SetClickHdl(LINK(this, SfxNewStyleDlg
, OKHdl
));
91 aColBox
.SetModifyHdl(LINK(this, SfxNewStyleDlg
, ModifyHdl
));
92 aColBox
.SetDoubleClickHdl(LINK(this, SfxNewStyleDlg
, OKHdl
));
93 aColBox
.SetAccessibleName(SfxResId(FL_COL
));
95 SfxStyleSheetBase
*pStyle
= rPool
.First();
98 aColBox
.InsertEntry(pStyle
->GetName());
99 pStyle
= rPool
.Next();
103 // -----------------------------------------------------------------------
105 SfxNewStyleDlg::~SfxNewStyleDlg()
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */