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