xref: /trunk/main/sfx2/source/dialog/newstyle.cxx (revision 0deba7fb)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sfx2.hxx"
26 
27 // INCLUDE ---------------------------------------------------------------
28 #include <svl/style.hxx>
29 #ifndef GCC
30 #endif
31 
32 #include <sfx2/newstyle.hxx>
33 #include "dialog.hrc"
34 #include "newstyle.hrc"
35 #include "sfx2/sfxresid.hxx"
36 
37 // PRIVATE METHODES ------------------------------------------------------
38 
IMPL_LINK(SfxNewStyleDlg,OKHdl,Control *,pControl)39 IMPL_LINK( SfxNewStyleDlg, OKHdl, Control *, pControl )
40 {
41     (void)pControl; //unused
42     const String aName( aColBox.GetText() );
43 	SfxStyleSheetBase* pStyle = rPool.Find( aName, rPool.GetSearchFamily(), SFXSTYLEBIT_ALL );
44 	if ( pStyle )
45 	{
46 		if ( !pStyle->IsUserDefined() )
47 		{
48 			InfoBox( this, SfxResId( MSG_POOL_STYLE_NAME ) ).Execute();
49 			return 0;
50 		}
51 
52 		if ( RET_YES == aQueryOverwriteBox.Execute() )
53 			EndDialog( RET_OK );
54 	}
55 	else
56 		EndDialog( RET_OK );
57 
58 	return 0;
59 }
60 
61 // -----------------------------------------------------------------------
62 
IMPL_LINK_INLINE_START(SfxNewStyleDlg,ModifyHdl,ComboBox *,pBox)63 IMPL_LINK_INLINE_START( SfxNewStyleDlg, ModifyHdl, ComboBox *, pBox )
64 {
65 	aOKBtn.Enable( pBox->GetText().EraseAllChars().Len() > 0 );
66 	return 0;
67 }
IMPL_LINK_INLINE_END(SfxNewStyleDlg,ModifyHdl,ComboBox *,pBox)68 IMPL_LINK_INLINE_END( SfxNewStyleDlg, ModifyHdl, ComboBox *, pBox )
69 
70 // CTOR / DTOR -----------------------------------------------------------
71 
72 SfxNewStyleDlg::SfxNewStyleDlg( Window* pParent, SfxStyleSheetBasePool& rInPool ) :
73 
74 	ModalDialog( pParent, SfxResId( DLG_NEW_STYLE_BY_EXAMPLE ) ),
75 
76 	aColFL				( this, SfxResId( FL_COL ) ),
77 	aColBox				( this, SfxResId( LB_COL ) ),
78 	aOKBtn				( this, SfxResId( BT_OK ) ),
79 	aCancelBtn			( this, SfxResId( BT_CANCEL ) ),
80 	aQueryOverwriteBox	( this, SfxResId( MSG_OVERWRITE ) ),
81 
82 	rPool( rInPool )
83 
84 {
85 	FreeResource();
86 
87 	aOKBtn.SetClickHdl(LINK(this, SfxNewStyleDlg, OKHdl));
88 	aColBox.SetModifyHdl(LINK(this, SfxNewStyleDlg, ModifyHdl));
89 	aColBox.SetDoubleClickHdl(LINK(this, SfxNewStyleDlg, OKHdl));
90 	aColBox.SetAccessibleName(SfxResId(FL_COL));
91 
92 	SfxStyleSheetBase *pStyle = rPool.First();
93 	while ( pStyle )
94 	{
95 		aColBox.InsertEntry(pStyle->GetName());
96 		pStyle = rPool.Next();
97 	}
98 }
99 
100 // -----------------------------------------------------------------------
101 
~SfxNewStyleDlg()102 __EXPORT SfxNewStyleDlg::~SfxNewStyleDlg()
103 {
104 }
105 
106