update dev300-m58
[ooovba.git] / svx / source / cui / dlgname.cxx
blob73582471017cbcbcd3476494945f685f51c292bd
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: dlgname.cxx,v $
10 * $Revision: 1.13 $
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_svx.hxx"
34 #ifdef SVX_DLLIMPLEMENTATION
35 #undef SVX_DLLIMPLEMENTATION
36 #endif
38 #include <tools/ref.hxx>
39 #include <tools/list.hxx>
40 #include <tools/shl.hxx>
41 #include <tools/debug.hxx>
42 #include <vcl/msgbox.hxx>
44 #include <svx/dialogs.hrc>
46 #include "dlgname.hxx"
47 #include "defdlgname.hxx" //CHINA001
48 #include "dlgname.hrc"
49 #include <svx/dialmgr.hxx>
51 #define MAX_DESCRIPTION_LINES ((long)5)
53 /*************************************************************************
55 |* Dialog zum Editieren eines Namens
57 \************************************************************************/
59 SvxNameDialog::SvxNameDialog( Window* pWindow, const String& rName, const String& rDesc ) :
60 ModalDialog ( pWindow, SVX_RES( RID_SVXDLG_NAME ) ),
61 aFtDescription ( this, SVX_RES( FT_DESCRIPTION ) ),
62 aEdtName ( this, SVX_RES( EDT_STRING ) ),
63 aBtnOK ( this, SVX_RES( BTN_OK ) ),
64 aBtnCancel ( this, SVX_RES( BTN_CANCEL ) ),
65 aBtnHelp ( this, SVX_RES( BTN_HELP ) )
67 FreeResource();
69 aFtDescription.SetText( rDesc );
70 aEdtName.SetText( rName );
71 aEdtName.SetSelection(Selection(SELECTION_MIN, SELECTION_MAX));
72 ModifyHdl(&aEdtName);
73 aEdtName.SetModifyHdl(LINK(this, SvxNameDialog, ModifyHdl));
75 // dynamic height of the description field
76 Size aSize = aFtDescription.GetSizePixel();
77 long nTxtWidth = aFtDescription.GetCtrlTextWidth( rDesc );
78 if ( nTxtWidth > aSize.Width() )
80 long nLines = Min( ( nTxtWidth / aSize.Width() + 1 ), MAX_DESCRIPTION_LINES );
81 long nHeight = aSize.Height();
82 aSize.Height() = nHeight * nLines;
83 aFtDescription.SetSizePixel( aSize );
84 Point aPnt = aEdtName.GetPosPixel();
85 aPnt.Y() += ( aSize.Height() - nHeight );
86 aEdtName.SetPosPixel( aPnt );
90 /* -----------------------------27.02.2002 15:22------------------------------
92 ---------------------------------------------------------------------------*/
93 IMPL_LINK(SvxNameDialog, ModifyHdl, Edit*, EMPTYARG)
95 if(aCheckNameHdl.IsSet())
96 aBtnOK.Enable(aCheckNameHdl.Call(this) > 0);
97 return 0;
100 ///////////////////////////////////////////////////////////////////////////////////////////////
101 // #i68101#
102 // Dialog for editing Object Name
103 // plus uniqueness-callback-linkHandler
105 SvxObjectNameDialog::SvxObjectNameDialog(
106 Window* pWindow,
107 const String& rName)
108 : ModalDialog(pWindow, SVX_RES(RID_SVXDLG_OBJECT_NAME)),
109 aFtName(this, SVX_RES(NTD_FT_NAME)),
110 aEdtName(this, SVX_RES(NTD_EDT_NAME)),
111 aFlSeparator(this, SVX_RES(FL_SEPARATOR_A)),
112 aBtnHelp(this, SVX_RES(BTN_HELP)),
113 aBtnOK(this, SVX_RES(BTN_OK)),
114 aBtnCancel(this, SVX_RES(BTN_CANCEL))
116 FreeResource();
118 // set name
119 aEdtName.SetText(rName);
121 // activate name
122 aEdtName.SetSelection(Selection(SELECTION_MIN, SELECTION_MAX));
123 ModifyHdl(&aEdtName);
124 aEdtName.SetModifyHdl(LINK(this, SvxObjectNameDialog, ModifyHdl));
127 IMPL_LINK(SvxObjectNameDialog, ModifyHdl, Edit*, EMPTYARG)
129 if(aCheckNameHdl.IsSet())
131 aBtnOK.Enable(aCheckNameHdl.Call(this) > 0);
134 return 0;
137 ///////////////////////////////////////////////////////////////////////////////////////////////
138 // #i68101#
139 // Dialog for editing Object Title and Description
141 SvxObjectTitleDescDialog::SvxObjectTitleDescDialog(
142 Window* pWindow,
143 const String& rTitle,
144 const String& rDescription)
145 : ModalDialog(pWindow, SVX_RES(RID_SVXDLG_OBJECT_TITLE_DESC)),
146 aFtTitle(this, SVX_RES(NTD_FT_TITLE)),
147 aEdtTitle(this, SVX_RES(NTD_EDT_TITLE)),
148 aFtDescription(this, SVX_RES(NTD_FT_DESC)),
149 aEdtDescription(this, SVX_RES(NTD_EDT_DESC)),
150 aFlSeparator(this, SVX_RES(FL_SEPARATOR_B)),
151 aBtnHelp(this, SVX_RES(BTN_HELP)),
152 aBtnOK(this, SVX_RES(BTN_OK)),
153 aBtnCancel(this, SVX_RES(BTN_CANCEL))
155 FreeResource();
157 // set title & desc
158 aEdtTitle.SetText(rTitle);
159 aEdtDescription.SetText(rDescription);
161 // activate title
162 aEdtTitle.SetSelection(Selection(SELECTION_MIN, SELECTION_MAX));
165 ///////////////////////////////////////////////////////////////////////////////////////////////
167 /*************************************************************************
169 |* Dialog zum Abbrechen, Speichern oder Hinzufuegen
171 \************************************************************************/
173 SvxMessDialog::SvxMessDialog( Window* pWindow, const String& rText, const String& rDesc, Image* pImg ) :
174 ModalDialog ( pWindow, SVX_RES( RID_SVXDLG_MESSBOX ) ),
175 aFtDescription ( this, SVX_RES( FT_DESCRIPTION ) ),
176 aBtn1 ( this, SVX_RES( BTN_1 ) ),
177 aBtn2 ( this, SVX_RES( BTN_2 ) ),
178 aBtnCancel ( this, SVX_RES( BTN_CANCEL ) ),
179 aFtImage ( this )
181 FreeResource();
183 if( pImg )
185 pImage = new Image( *pImg );
186 aFtImage.SetImage( *pImage );
187 aFtImage.SetStyle( ( aFtImage.GetStyle()/* | WB_NOTABSTOP */) & ~WB_3DLOOK );
188 aFtImage.SetPosSizePixel( LogicToPixel( Point( 3, 6 ), MAP_APPFONT ),
189 aFtImage.GetImage().GetSizePixel() );
190 aFtImage.Show();
193 SetText( rText );
194 aFtDescription.SetText( rDesc );
196 aBtn1.SetClickHdl( LINK( this, SvxMessDialog, Button1Hdl ) );
197 aBtn2.SetClickHdl( LINK( this, SvxMessDialog, Button2Hdl ) );
200 SvxMessDialog::~SvxMessDialog()
202 if( pImage )
203 delete pImage;
206 /*************************************************************************/
208 IMPL_LINK_INLINE_START( SvxMessDialog, Button1Hdl, Button *, EMPTYARG )
210 EndDialog( RET_BTN_1 );
211 return 0;
213 IMPL_LINK_INLINE_END( SvxMessDialog, Button1Hdl, Button *, EMPTYARG )
215 /*************************************************************************/
217 IMPL_LINK_INLINE_START( SvxMessDialog, Button2Hdl, Button *, EMPTYARG )
219 EndDialog( RET_BTN_2 );
220 return 0;
222 IMPL_LINK_INLINE_END( SvxMessDialog, Button2Hdl, Button *, EMPTYARG )
224 /*************************************************************************/
226 void SvxMessDialog::SetButtonText( USHORT nBtnId, const String& rNewTxt )
228 switch ( nBtnId )
230 case MESS_BTN_1:
231 aBtn1.SetText( rNewTxt );
232 break;
234 case MESS_BTN_2:
235 aBtn2.SetText( rNewTxt );
236 break;
238 default:
239 DBG_ERROR( "Falsche Button-Nummer!!!" );