1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sc.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #undef SC_DLLIMPLEMENTATION 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir //------------------------------------------------------------------ 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #include "scitems.hxx" 38*cdf0e10cSrcweir #include <svx/algitem.hxx> 39*cdf0e10cSrcweir #include <editeng/boxitem.hxx> 40*cdf0e10cSrcweir #include <editeng/brshitem.hxx> 41*cdf0e10cSrcweir #include <editeng/cntritem.hxx> 42*cdf0e10cSrcweir #include <editeng/colritem.hxx> 43*cdf0e10cSrcweir #include <editeng/crsditem.hxx> 44*cdf0e10cSrcweir #include <editeng/fontitem.hxx> 45*cdf0e10cSrcweir #include <editeng/postitem.hxx> 46*cdf0e10cSrcweir #include <editeng/shdditem.hxx> 47*cdf0e10cSrcweir #include <editeng/udlnitem.hxx> 48*cdf0e10cSrcweir #include <editeng/wghtitem.hxx> 49*cdf0e10cSrcweir #include <svl/zforlist.hxx> 50*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 51*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 52*cdf0e10cSrcweir #include <sfx2/sfxresid.hxx> 53*cdf0e10cSrcweir #include "sc.hrc" 54*cdf0e10cSrcweir #include "scmod.hxx" 55*cdf0e10cSrcweir #include "attrib.hxx" 56*cdf0e10cSrcweir #include "zforauto.hxx" 57*cdf0e10cSrcweir #include "scitems.hxx" 58*cdf0e10cSrcweir #include "global.hxx" 59*cdf0e10cSrcweir #include "globstr.hrc" 60*cdf0e10cSrcweir #include "autoform.hxx" 61*cdf0e10cSrcweir #include "strindlg.hxx" 62*cdf0e10cSrcweir #include "miscdlgs.hrc" 63*cdf0e10cSrcweir #include "scuiautofmt.hxx" 64*cdf0e10cSrcweir #include "scresid.hxx" 65*cdf0e10cSrcweir #include "document.hxx" 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir //======================================================================== 68*cdf0e10cSrcweir // AutoFormat-Dialog: 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir ScAutoFormatDlg::ScAutoFormatDlg( Window* pParent, 71*cdf0e10cSrcweir ScAutoFormat* pAutoFormat, 72*cdf0e10cSrcweir const ScAutoFormatData* pSelFormatData, 73*cdf0e10cSrcweir ScDocument* pDoc ) : 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir ModalDialog ( pParent, ScResId( RID_SCDLG_AUTOFORMAT ) ), 76*cdf0e10cSrcweir // 77*cdf0e10cSrcweir aFlFormat ( this, ScResId( FL_FORMAT ) ), 78*cdf0e10cSrcweir aLbFormat ( this, ScResId( LB_FORMAT ) ), 79*cdf0e10cSrcweir pWndPreview ( new ScAutoFmtPreview( this, ScResId( WND_PREVIEW ), pDoc ) ), 80*cdf0e10cSrcweir aBtnOk ( this, ScResId( BTN_OK ) ), 81*cdf0e10cSrcweir aBtnCancel ( this, ScResId( BTN_CANCEL ) ), 82*cdf0e10cSrcweir aBtnHelp ( this, ScResId( BTN_HELP ) ), 83*cdf0e10cSrcweir aBtnAdd ( this, ScResId( BTN_ADD ) ), 84*cdf0e10cSrcweir aBtnRemove ( this, ScResId( BTN_REMOVE ) ), 85*cdf0e10cSrcweir aBtnMore ( this, ScResId( BTN_MORE ) ), 86*cdf0e10cSrcweir aFlFormatting ( this, ScResId( FL_FORMATTING ) ), 87*cdf0e10cSrcweir aBtnNumFormat ( this, ScResId( BTN_NUMFORMAT ) ), 88*cdf0e10cSrcweir aBtnBorder ( this, ScResId( BTN_BORDER ) ), 89*cdf0e10cSrcweir aBtnFont ( this, ScResId( BTN_FONT ) ), 90*cdf0e10cSrcweir aBtnPattern ( this, ScResId( BTN_PATTERN ) ), 91*cdf0e10cSrcweir aBtnAlignment ( this, ScResId( BTN_ALIGNMENT ) ), 92*cdf0e10cSrcweir aBtnAdjust ( this, ScResId( BTN_ADJUST ) ), 93*cdf0e10cSrcweir aBtnRename ( this, ScResId( BTN_RENAME ) ), 94*cdf0e10cSrcweir aStrTitle ( ScResId( STR_ADD_TITLE ) ), 95*cdf0e10cSrcweir aStrLabel ( ScResId( STR_ADD_LABEL ) ), 96*cdf0e10cSrcweir aStrClose ( ScResId( STR_BTN_CLOSE ) ), 97*cdf0e10cSrcweir aStrDelTitle ( ScResId( STR_DEL_TITLE ) ), 98*cdf0e10cSrcweir aStrDelMsg ( ScResId( STR_DEL_MSG ) ) , 99*cdf0e10cSrcweir aStrRename ( ScResId( STR_RENAME_TITLE ) ), 100*cdf0e10cSrcweir // 101*cdf0e10cSrcweir pFormat ( pAutoFormat ), 102*cdf0e10cSrcweir pSelFmtData ( pSelFormatData ), 103*cdf0e10cSrcweir nIndex ( 0 ), 104*cdf0e10cSrcweir bCoreDataChanged( sal_False ), 105*cdf0e10cSrcweir bFmtInserted ( sal_False ) 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir Init(); 108*cdf0e10cSrcweir pWndPreview->NotifyChange( (*pFormat)[0] ); 109*cdf0e10cSrcweir FreeResource(); 110*cdf0e10cSrcweir } 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir //------------------------------------------------------------------------ 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir __EXPORT ScAutoFormatDlg::~ScAutoFormatDlg() 115*cdf0e10cSrcweir { 116*cdf0e10cSrcweir delete pWndPreview; 117*cdf0e10cSrcweir } 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir //------------------------------------------------------------------------ 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir void ScAutoFormatDlg::Init() 122*cdf0e10cSrcweir { 123*cdf0e10cSrcweir sal_uInt16 nCount; 124*cdf0e10cSrcweir String aEntry; 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir aLbFormat .SetSelectHdl( LINK( this, ScAutoFormatDlg, SelFmtHdl ) ); 127*cdf0e10cSrcweir aBtnNumFormat.SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) ); 128*cdf0e10cSrcweir aBtnBorder .SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) ); 129*cdf0e10cSrcweir aBtnFont .SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) ); 130*cdf0e10cSrcweir aBtnPattern .SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) ); 131*cdf0e10cSrcweir aBtnAlignment.SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) ); 132*cdf0e10cSrcweir aBtnAdjust .SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) ); 133*cdf0e10cSrcweir aBtnAdd .SetClickHdl ( LINK( this, ScAutoFormatDlg, AddHdl ) ); 134*cdf0e10cSrcweir aBtnRemove .SetClickHdl ( LINK( this, ScAutoFormatDlg, RemoveHdl ) ); 135*cdf0e10cSrcweir aBtnOk .SetClickHdl ( LINK( this, ScAutoFormatDlg, CloseHdl ) ); 136*cdf0e10cSrcweir aBtnCancel .SetClickHdl ( LINK( this, ScAutoFormatDlg, CloseHdl ) ); 137*cdf0e10cSrcweir aBtnRename .SetClickHdl ( LINK( this, ScAutoFormatDlg, RenameHdl ) ); 138*cdf0e10cSrcweir aLbFormat .SetDoubleClickHdl( LINK( this, ScAutoFormatDlg, DblClkHdl ) ); 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir aBtnMore.AddWindow( &aBtnRename ); 141*cdf0e10cSrcweir aBtnMore.AddWindow( &aBtnNumFormat ); 142*cdf0e10cSrcweir aBtnMore.AddWindow( &aBtnBorder ); 143*cdf0e10cSrcweir aBtnMore.AddWindow( &aBtnFont ); 144*cdf0e10cSrcweir aBtnMore.AddWindow( &aBtnPattern ); 145*cdf0e10cSrcweir aBtnMore.AddWindow( &aBtnAlignment ); 146*cdf0e10cSrcweir aBtnMore.AddWindow( &aBtnAdjust ); 147*cdf0e10cSrcweir aBtnMore.AddWindow( &aFlFormatting ); 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir nCount = pFormat->GetCount(); 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < nCount; i++ ) 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir ((*pFormat)[i])->GetName( aEntry ); 154*cdf0e10cSrcweir aLbFormat.InsertEntry( aEntry ); 155*cdf0e10cSrcweir } 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir if ( nCount == 1 ) 158*cdf0e10cSrcweir aBtnRemove.Disable(); 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir aLbFormat.SelectEntryPos( 0 ); 161*cdf0e10cSrcweir aBtnRename.Disable(); 162*cdf0e10cSrcweir aBtnRemove.Disable(); 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir nIndex = 0; 165*cdf0e10cSrcweir UpdateChecks(); 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir if ( !pSelFmtData ) 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir aBtnAdd.Disable(); 170*cdf0e10cSrcweir aBtnRemove.Disable(); 171*cdf0e10cSrcweir bFmtInserted = sal_True; 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir } 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir //------------------------------------------------------------------------ 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir void ScAutoFormatDlg::UpdateChecks() 178*cdf0e10cSrcweir { 179*cdf0e10cSrcweir ScAutoFormatData* pData = (*pFormat)[nIndex]; 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir aBtnNumFormat.Check( pData->GetIncludeValueFormat() ); 182*cdf0e10cSrcweir aBtnBorder .Check( pData->GetIncludeFrame() ); 183*cdf0e10cSrcweir aBtnFont .Check( pData->GetIncludeFont() ); 184*cdf0e10cSrcweir aBtnPattern .Check( pData->GetIncludeBackground() ); 185*cdf0e10cSrcweir aBtnAlignment.Check( pData->GetIncludeJustify() ); 186*cdf0e10cSrcweir aBtnAdjust .Check( pData->GetIncludeWidthHeight() ); 187*cdf0e10cSrcweir } 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir //------------------------------------------------------------------------ 190*cdf0e10cSrcweir // Handler: 191*cdf0e10cSrcweir //--------- 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir IMPL_LINK( ScAutoFormatDlg, CloseHdl, PushButton *, pBtn ) 194*cdf0e10cSrcweir { 195*cdf0e10cSrcweir if ( pBtn == &aBtnOk || pBtn == &aBtnCancel ) 196*cdf0e10cSrcweir { 197*cdf0e10cSrcweir if ( bCoreDataChanged ) 198*cdf0e10cSrcweir ScGlobal::GetAutoFormat()->Save(); 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir EndDialog( (pBtn == &aBtnOk) ? RET_OK : RET_CANCEL ); 201*cdf0e10cSrcweir } 202*cdf0e10cSrcweir return 0; 203*cdf0e10cSrcweir } 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir //------------------------------------------------------------------------ 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir IMPL_LINK_INLINE_START( ScAutoFormatDlg, DblClkHdl, void *, EMPTYARG ) 208*cdf0e10cSrcweir { 209*cdf0e10cSrcweir if ( bCoreDataChanged ) 210*cdf0e10cSrcweir ScGlobal::GetAutoFormat()->Save(); 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir EndDialog( RET_OK ); 213*cdf0e10cSrcweir return 0; 214*cdf0e10cSrcweir } 215*cdf0e10cSrcweir IMPL_LINK_INLINE_END( ScAutoFormatDlg, DblClkHdl, void *, EMPTYARG ) 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir //------------------------------------------------------------------------ 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir IMPL_LINK( ScAutoFormatDlg, CheckHdl, Button *, pBtn ) 220*cdf0e10cSrcweir { 221*cdf0e10cSrcweir ScAutoFormatData* pData = (*pFormat)[nIndex]; 222*cdf0e10cSrcweir sal_Bool bCheck = ((CheckBox*)pBtn)->IsChecked(); 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir if ( pBtn == &aBtnNumFormat ) 225*cdf0e10cSrcweir pData->SetIncludeValueFormat( bCheck ); 226*cdf0e10cSrcweir else if ( pBtn == &aBtnBorder ) 227*cdf0e10cSrcweir pData->SetIncludeFrame( bCheck ); 228*cdf0e10cSrcweir else if ( pBtn == &aBtnFont ) 229*cdf0e10cSrcweir pData->SetIncludeFont( bCheck ); 230*cdf0e10cSrcweir else if ( pBtn == &aBtnPattern ) 231*cdf0e10cSrcweir pData->SetIncludeBackground( bCheck ); 232*cdf0e10cSrcweir else if ( pBtn == &aBtnAlignment ) 233*cdf0e10cSrcweir pData->SetIncludeJustify( bCheck ); 234*cdf0e10cSrcweir else if ( pBtn == &aBtnAdjust ) 235*cdf0e10cSrcweir pData->SetIncludeWidthHeight( bCheck ); 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir if ( !bCoreDataChanged ) 238*cdf0e10cSrcweir { 239*cdf0e10cSrcweir aBtnCancel.SetText( aStrClose ); 240*cdf0e10cSrcweir bCoreDataChanged = sal_True; 241*cdf0e10cSrcweir } 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir pWndPreview->NotifyChange( pData ); 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir return 0; 246*cdf0e10cSrcweir } 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir //------------------------------------------------------------------------ 249*cdf0e10cSrcweir 250*cdf0e10cSrcweir IMPL_LINK( ScAutoFormatDlg, AddHdl, void *, EMPTYARG ) 251*cdf0e10cSrcweir { 252*cdf0e10cSrcweir if ( !bFmtInserted && pSelFmtData ) 253*cdf0e10cSrcweir { 254*cdf0e10cSrcweir String aStrStandard( SfxResId(STR_STANDARD) ); 255*cdf0e10cSrcweir String aFormatName; 256*cdf0e10cSrcweir ScStringInputDlg* pDlg; 257*cdf0e10cSrcweir sal_Bool bOk = sal_False; 258*cdf0e10cSrcweir 259*cdf0e10cSrcweir while ( !bOk ) 260*cdf0e10cSrcweir { 261*cdf0e10cSrcweir pDlg = new ScStringInputDlg( this, 262*cdf0e10cSrcweir aStrTitle, 263*cdf0e10cSrcweir aStrLabel, 264*cdf0e10cSrcweir aFormatName, 265*cdf0e10cSrcweir HID_SC_ADD_AUTOFMT, HID_SC_AUTOFMT_NAME ); 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir if ( pDlg->Execute() == RET_OK ) 268*cdf0e10cSrcweir { 269*cdf0e10cSrcweir pDlg->GetInputString( aFormatName ); 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir if ( (aFormatName.Len() > 0) && (aFormatName != aStrStandard) ) 272*cdf0e10cSrcweir { 273*cdf0e10cSrcweir ScAutoFormatData* pNewData 274*cdf0e10cSrcweir = new ScAutoFormatData( *pSelFmtData ); 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir pNewData->SetName( aFormatName ); 277*cdf0e10cSrcweir bFmtInserted = pFormat->Insert( pNewData ); 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir if ( bFmtInserted ) 280*cdf0e10cSrcweir { 281*cdf0e10cSrcweir sal_uInt16 nAt = pFormat->IndexOf( pNewData ); 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir aLbFormat.InsertEntry( aFormatName, nAt ); 284*cdf0e10cSrcweir aLbFormat.SelectEntry( aFormatName ); 285*cdf0e10cSrcweir aBtnAdd.Disable(); 286*cdf0e10cSrcweir 287*cdf0e10cSrcweir if ( !bCoreDataChanged ) 288*cdf0e10cSrcweir { 289*cdf0e10cSrcweir aBtnCancel.SetText( aStrClose ); 290*cdf0e10cSrcweir bCoreDataChanged = sal_True; 291*cdf0e10cSrcweir } 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir SelFmtHdl( 0 ); 294*cdf0e10cSrcweir bOk = sal_True; 295*cdf0e10cSrcweir } 296*cdf0e10cSrcweir else 297*cdf0e10cSrcweir delete pNewData; 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir } 300*cdf0e10cSrcweir 301*cdf0e10cSrcweir if ( !bFmtInserted ) 302*cdf0e10cSrcweir { 303*cdf0e10cSrcweir sal_uInt16 nRet = ErrorBox( this, 304*cdf0e10cSrcweir WinBits( WB_OK_CANCEL | WB_DEF_OK), 305*cdf0e10cSrcweir ScGlobal::GetRscString(STR_INVALID_AFNAME) 306*cdf0e10cSrcweir ).Execute(); 307*cdf0e10cSrcweir 308*cdf0e10cSrcweir bOk = ( nRet == RET_CANCEL ); 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir } 311*cdf0e10cSrcweir else 312*cdf0e10cSrcweir bOk = sal_True; 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir delete pDlg; 315*cdf0e10cSrcweir } 316*cdf0e10cSrcweir } 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir return 0; 319*cdf0e10cSrcweir } 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir //------------------------------------------------------------------------ 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir IMPL_LINK( ScAutoFormatDlg, RemoveHdl, void *, EMPTYARG ) 324*cdf0e10cSrcweir { 325*cdf0e10cSrcweir if ( (nIndex > 0) && (aLbFormat.GetEntryCount() > 0) ) 326*cdf0e10cSrcweir { 327*cdf0e10cSrcweir String aMsg( aStrDelMsg.GetToken( 0, '#' ) ); 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir aMsg += aLbFormat.GetSelectEntry(); 330*cdf0e10cSrcweir aMsg += aStrDelMsg.GetToken( 1, '#' ); 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir if ( RET_YES == 333*cdf0e10cSrcweir QueryBox( this, WinBits( WB_YES_NO | WB_DEF_YES ), aMsg ).Execute() ) 334*cdf0e10cSrcweir { 335*cdf0e10cSrcweir aLbFormat.RemoveEntry( nIndex ); 336*cdf0e10cSrcweir aLbFormat.SelectEntryPos( nIndex-1 ); 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir if ( nIndex-1 == 0 ) 339*cdf0e10cSrcweir aBtnRemove.Disable(); 340*cdf0e10cSrcweir 341*cdf0e10cSrcweir if ( !bCoreDataChanged ) 342*cdf0e10cSrcweir { 343*cdf0e10cSrcweir aBtnCancel.SetText( aStrClose ); 344*cdf0e10cSrcweir bCoreDataChanged = sal_True; 345*cdf0e10cSrcweir } 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir pFormat->AtFree( nIndex ); // in der Core loeschen 348*cdf0e10cSrcweir nIndex--; 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir SelFmtHdl( 0 ); 351*cdf0e10cSrcweir } 352*cdf0e10cSrcweir } 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir SelFmtHdl( 0 ); 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir return 0; 357*cdf0e10cSrcweir } 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir IMPL_LINK( ScAutoFormatDlg, RenameHdl, void *, EMPTYARG ) 360*cdf0e10cSrcweir { 361*cdf0e10cSrcweir sal_Bool bOk = sal_False; 362*cdf0e10cSrcweir while( !bOk ) 363*cdf0e10cSrcweir { 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir String aFormatName=aLbFormat.GetSelectEntry(); 366*cdf0e10cSrcweir String aEntry; 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir ScStringInputDlg* pDlg = new ScStringInputDlg( this, 369*cdf0e10cSrcweir aStrRename, 370*cdf0e10cSrcweir aStrLabel, 371*cdf0e10cSrcweir aFormatName, 372*cdf0e10cSrcweir HID_SC_REN_AFMT_DLG, HID_SC_REN_AFMT_NAME ); 373*cdf0e10cSrcweir if( pDlg->Execute() == RET_OK ) 374*cdf0e10cSrcweir { 375*cdf0e10cSrcweir sal_Bool bFmtRenamed = sal_False; 376*cdf0e10cSrcweir pDlg->GetInputString( aFormatName ); 377*cdf0e10cSrcweir sal_uInt16 n; 378*cdf0e10cSrcweir 379*cdf0e10cSrcweir if ( aFormatName.Len() > 0 ) 380*cdf0e10cSrcweir { 381*cdf0e10cSrcweir for( n = 0; n < pFormat->GetCount(); ++n ) 382*cdf0e10cSrcweir { 383*cdf0e10cSrcweir (*pFormat)[n]->GetName(aEntry); 384*cdf0e10cSrcweir if ( aEntry== aFormatName) 385*cdf0e10cSrcweir break; 386*cdf0e10cSrcweir } 387*cdf0e10cSrcweir if( n >= pFormat->GetCount() ) 388*cdf0e10cSrcweir { 389*cdf0e10cSrcweir // Format mit dem Namen noch nicht vorhanden, also 390*cdf0e10cSrcweir // umbenennen 391*cdf0e10cSrcweir 392*cdf0e10cSrcweir aLbFormat.RemoveEntry(nIndex ); 393*cdf0e10cSrcweir ScAutoFormatData* p=(*pFormat)[ nIndex ]; 394*cdf0e10cSrcweir ScAutoFormatData* pNewData 395*cdf0e10cSrcweir = new ScAutoFormatData(*p); 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir pFormat->AtFree( nIndex ); 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir pNewData->SetName( aFormatName ); 400*cdf0e10cSrcweir 401*cdf0e10cSrcweir pFormat->Insert( pNewData); 402*cdf0e10cSrcweir 403*cdf0e10cSrcweir sal_uInt16 nCount = pFormat->GetCount(); 404*cdf0e10cSrcweir 405*cdf0e10cSrcweir aLbFormat.SetUpdateMode(sal_False); 406*cdf0e10cSrcweir aLbFormat.Clear(); 407*cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < nCount; i++ ) 408*cdf0e10cSrcweir { 409*cdf0e10cSrcweir ((*pFormat)[i])->GetName( aEntry ); 410*cdf0e10cSrcweir aLbFormat.InsertEntry( aEntry ); 411*cdf0e10cSrcweir } 412*cdf0e10cSrcweir 413*cdf0e10cSrcweir aLbFormat.SetUpdateMode( sal_True); 414*cdf0e10cSrcweir aLbFormat.SelectEntry( aFormatName); 415*cdf0e10cSrcweir 416*cdf0e10cSrcweir if ( !bCoreDataChanged ) 417*cdf0e10cSrcweir { 418*cdf0e10cSrcweir aBtnCancel.SetText( aStrClose ); 419*cdf0e10cSrcweir bCoreDataChanged = sal_True; 420*cdf0e10cSrcweir } 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir 423*cdf0e10cSrcweir SelFmtHdl( 0 ); 424*cdf0e10cSrcweir bOk = sal_True; 425*cdf0e10cSrcweir bFmtRenamed = sal_True; 426*cdf0e10cSrcweir } 427*cdf0e10cSrcweir } 428*cdf0e10cSrcweir if( !bFmtRenamed ) 429*cdf0e10cSrcweir { 430*cdf0e10cSrcweir bOk = RET_CANCEL == ErrorBox( this, 431*cdf0e10cSrcweir WinBits( WB_OK_CANCEL | WB_DEF_OK), 432*cdf0e10cSrcweir ScGlobal::GetRscString(STR_INVALID_AFNAME) 433*cdf0e10cSrcweir ).Execute(); 434*cdf0e10cSrcweir } 435*cdf0e10cSrcweir } 436*cdf0e10cSrcweir else 437*cdf0e10cSrcweir bOk = sal_True; 438*cdf0e10cSrcweir delete pDlg; 439*cdf0e10cSrcweir } 440*cdf0e10cSrcweir 441*cdf0e10cSrcweir return 0; 442*cdf0e10cSrcweir } 443*cdf0e10cSrcweir 444*cdf0e10cSrcweir //------------------------------------------------------------------------ 445*cdf0e10cSrcweir 446*cdf0e10cSrcweir IMPL_LINK( ScAutoFormatDlg, SelFmtHdl, void *, EMPTYARG ) 447*cdf0e10cSrcweir { 448*cdf0e10cSrcweir nIndex = aLbFormat.GetSelectEntryPos(); 449*cdf0e10cSrcweir UpdateChecks(); 450*cdf0e10cSrcweir 451*cdf0e10cSrcweir if ( nIndex == 0 ) 452*cdf0e10cSrcweir { 453*cdf0e10cSrcweir aBtnRename.Disable(); 454*cdf0e10cSrcweir aBtnRemove.Disable(); 455*cdf0e10cSrcweir } 456*cdf0e10cSrcweir else 457*cdf0e10cSrcweir { 458*cdf0e10cSrcweir aBtnRename.Enable(); 459*cdf0e10cSrcweir aBtnRemove.Enable(); 460*cdf0e10cSrcweir } 461*cdf0e10cSrcweir 462*cdf0e10cSrcweir pWndPreview->NotifyChange( (*pFormat)[nIndex] ); 463*cdf0e10cSrcweir 464*cdf0e10cSrcweir return 0; 465*cdf0e10cSrcweir } 466*cdf0e10cSrcweir 467*cdf0e10cSrcweir //------------------------------------------------------------------------ 468*cdf0e10cSrcweir 469*cdf0e10cSrcweir String __EXPORT ScAutoFormatDlg::GetCurrFormatName() 470*cdf0e10cSrcweir { 471*cdf0e10cSrcweir String aResult; 472*cdf0e10cSrcweir 473*cdf0e10cSrcweir ((*pFormat)[nIndex])->GetName( aResult ); 474*cdf0e10cSrcweir 475*cdf0e10cSrcweir return aResult; 476*cdf0e10cSrcweir } 477