1*5b190011SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*5b190011SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*5b190011SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*5b190011SAndrew Rist * distributed with this work for additional information 6*5b190011SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*5b190011SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*5b190011SAndrew Rist * "License"); you may not use this file except in compliance 9*5b190011SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*5b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*5b190011SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*5b190011SAndrew Rist * software distributed under the License is distributed on an 15*5b190011SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*5b190011SAndrew Rist * KIND, either express or implied. See the License for the 17*5b190011SAndrew Rist * specific language governing permissions and limitations 18*5b190011SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*5b190011SAndrew Rist *************************************************************/ 21*5b190011SAndrew Rist 22*5b190011SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sd.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #ifdef SD_DLLIMPLEMENTATION 28cdf0e10cSrcweir #undef SD_DLLIMPLEMENTATION 29cdf0e10cSrcweir #endif 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include "custsdlg.hxx" 32cdf0e10cSrcweir #include "custsdlg.hrc" 33cdf0e10cSrcweir 34cdf0e10cSrcweir #include "strings.hrc" 35cdf0e10cSrcweir #include "sdresid.hxx" 36cdf0e10cSrcweir 37cdf0e10cSrcweir #include "drawdoc.hxx" 38cdf0e10cSrcweir #include "sdpage.hxx" 39cdf0e10cSrcweir #include "cusshow.hxx" 40cdf0e10cSrcweir #include "app.hxx" 41cdf0e10cSrcweir #include <vcl/msgbox.hxx> 42cdf0e10cSrcweir 43cdf0e10cSrcweir 44cdf0e10cSrcweir ///////////////////// 45cdf0e10cSrcweir // SdCustomShowDlg // 46cdf0e10cSrcweir ///////////////////// 47cdf0e10cSrcweir 48cdf0e10cSrcweir 49cdf0e10cSrcweir /************************************************************************* 50cdf0e10cSrcweir |* Konstruktor 51cdf0e10cSrcweir \************************************************************************/ 52cdf0e10cSrcweir SdCustomShowDlg::SdCustomShowDlg( Window* pWindow, 53cdf0e10cSrcweir SdDrawDocument& rDrawDoc ) : 54cdf0e10cSrcweir ModalDialog ( pWindow, SdResId( DLG_CUSTOMSHOW ) ), 55cdf0e10cSrcweir 56cdf0e10cSrcweir aLbCustomShows ( this, SdResId( LB_CUSTOMSHOWS ) ), 57cdf0e10cSrcweir aCbxUseCustomShow( this, SdResId( CBX_USE_CUSTOMSHOW ) ), 58cdf0e10cSrcweir aBtnNew ( this, SdResId( BTN_NEW ) ), 59cdf0e10cSrcweir aBtnEdit ( this, SdResId( BTN_EDIT ) ), 60cdf0e10cSrcweir aBtnRemove ( this, SdResId( BTN_REMOVE ) ), 61cdf0e10cSrcweir aBtnCopy ( this, SdResId( BTN_COPY ) ), 62cdf0e10cSrcweir aBtnHelp ( this, SdResId( BTN_HELP ) ), 63cdf0e10cSrcweir aBtnStartShow ( this, SdResId( BTN_STARTSHOW ) ), 64cdf0e10cSrcweir aBtnOK ( this, SdResId( BTN_OK ) ), 65cdf0e10cSrcweir 66cdf0e10cSrcweir rDoc ( rDrawDoc ), 67cdf0e10cSrcweir pCustomShowList ( NULL ), 68cdf0e10cSrcweir pCustomShow ( NULL ), 69cdf0e10cSrcweir bModified ( sal_False ) 70cdf0e10cSrcweir { 71cdf0e10cSrcweir FreeResource(); 72cdf0e10cSrcweir 73cdf0e10cSrcweir Link aLink( LINK( this, SdCustomShowDlg, ClickButtonHdl ) ); 74cdf0e10cSrcweir aBtnNew.SetClickHdl( aLink ); 75cdf0e10cSrcweir aBtnEdit.SetClickHdl( aLink ); 76cdf0e10cSrcweir aBtnRemove.SetClickHdl( aLink ); 77cdf0e10cSrcweir aBtnCopy.SetClickHdl( aLink ); 78cdf0e10cSrcweir aCbxUseCustomShow.SetClickHdl( aLink ); 79cdf0e10cSrcweir aLbCustomShows.SetSelectHdl( aLink ); 80cdf0e10cSrcweir 81cdf0e10cSrcweir aBtnStartShow.SetClickHdl( LINK( this, SdCustomShowDlg, StartShowHdl ) ); // Testweise 82cdf0e10cSrcweir 83cdf0e10cSrcweir // CustomShow-Liste des Docs abrufen 84cdf0e10cSrcweir pCustomShowList = rDoc.GetCustomShowList(); 85cdf0e10cSrcweir if( pCustomShowList ) 86cdf0e10cSrcweir { 87cdf0e10cSrcweir long nPosToSelect = pCustomShowList->GetCurPos(); 88cdf0e10cSrcweir // ListBox mit CustomShows fuellen 89cdf0e10cSrcweir for( pCustomShow = (SdCustomShow*) pCustomShowList->First(); 90cdf0e10cSrcweir pCustomShow != NULL; 91cdf0e10cSrcweir pCustomShow = (SdCustomShow*) pCustomShowList->Next() ) 92cdf0e10cSrcweir { 93cdf0e10cSrcweir aLbCustomShows.InsertEntry( pCustomShow->GetName() ); 94cdf0e10cSrcweir } 95cdf0e10cSrcweir aLbCustomShows.SelectEntryPos( (sal_uInt16)nPosToSelect ); 96cdf0e10cSrcweir pCustomShowList->Seek( nPosToSelect ); 97cdf0e10cSrcweir } 98cdf0e10cSrcweir 99cdf0e10cSrcweir aCbxUseCustomShow.Check( pCustomShowList && rDoc.getPresentationSettings().mbCustomShow ); 100cdf0e10cSrcweir 101cdf0e10cSrcweir CheckState(); 102cdf0e10cSrcweir } 103cdf0e10cSrcweir 104cdf0e10cSrcweir /************************************************************************* 105cdf0e10cSrcweir |* Dtor 106cdf0e10cSrcweir \************************************************************************/ 107cdf0e10cSrcweir SdCustomShowDlg::~SdCustomShowDlg() 108cdf0e10cSrcweir { 109cdf0e10cSrcweir } 110cdf0e10cSrcweir 111cdf0e10cSrcweir /************************************************************************* 112cdf0e10cSrcweir |* CheckState 113cdf0e10cSrcweir \************************************************************************/ 114cdf0e10cSrcweir void SdCustomShowDlg::CheckState() 115cdf0e10cSrcweir { 116cdf0e10cSrcweir sal_uInt16 nPos = aLbCustomShows.GetSelectEntryPos(); 117cdf0e10cSrcweir 118cdf0e10cSrcweir sal_Bool bEnable = nPos != LISTBOX_ENTRY_NOTFOUND; 119cdf0e10cSrcweir aBtnEdit.Enable( bEnable ); 120cdf0e10cSrcweir aBtnRemove.Enable( bEnable ); 121cdf0e10cSrcweir aBtnCopy.Enable( bEnable ); 122cdf0e10cSrcweir aCbxUseCustomShow.Enable( bEnable ); 123cdf0e10cSrcweir aBtnStartShow.Enable( true ); 124cdf0e10cSrcweir 125cdf0e10cSrcweir if( bEnable ) 126cdf0e10cSrcweir pCustomShowList->Seek( nPos ); 127cdf0e10cSrcweir } 128cdf0e10cSrcweir 129cdf0e10cSrcweir /************************************************************************* 130cdf0e10cSrcweir |* ButtonHdl() 131cdf0e10cSrcweir \************************************************************************/ 132cdf0e10cSrcweir IMPL_LINK( SdCustomShowDlg, ClickButtonHdl, void *, p ) 133cdf0e10cSrcweir { 134cdf0e10cSrcweir // Neue CustomShow 135cdf0e10cSrcweir if( p == &aBtnNew ) 136cdf0e10cSrcweir { 137cdf0e10cSrcweir pCustomShow = NULL; 138cdf0e10cSrcweir SdDefineCustomShowDlg aDlg( this, rDoc, pCustomShow ); 139cdf0e10cSrcweir if( aDlg.Execute() == RET_OK ) 140cdf0e10cSrcweir { 141cdf0e10cSrcweir if( pCustomShow ) 142cdf0e10cSrcweir { 143cdf0e10cSrcweir if( !pCustomShowList ) 144cdf0e10cSrcweir pCustomShowList = rDoc.GetCustomShowList( sal_True ); 145cdf0e10cSrcweir 146cdf0e10cSrcweir pCustomShowList->Insert( pCustomShow, LIST_APPEND ); 147cdf0e10cSrcweir pCustomShowList->Last(); 148cdf0e10cSrcweir aLbCustomShows.InsertEntry( pCustomShow->GetName() ); 149cdf0e10cSrcweir aLbCustomShows.SelectEntry( pCustomShow->GetName() ); 150cdf0e10cSrcweir } 151cdf0e10cSrcweir 152cdf0e10cSrcweir if( aDlg.IsModified() ) 153cdf0e10cSrcweir bModified = sal_True; 154cdf0e10cSrcweir } 155cdf0e10cSrcweir else if( pCustomShow ) 156cdf0e10cSrcweir DELETEZ( pCustomShow ); 157cdf0e10cSrcweir } 158cdf0e10cSrcweir // CustomShow bearbeiten 159cdf0e10cSrcweir else if( p == &aBtnEdit ) 160cdf0e10cSrcweir { 161cdf0e10cSrcweir sal_uInt16 nPos = aLbCustomShows.GetSelectEntryPos(); 162cdf0e10cSrcweir if( nPos != LISTBOX_ENTRY_NOTFOUND ) 163cdf0e10cSrcweir { 164cdf0e10cSrcweir DBG_ASSERT( pCustomShowList, "pCustomShowList existiert nicht" ); 165cdf0e10cSrcweir pCustomShow = (SdCustomShow*) pCustomShowList->GetObject( nPos ); 166cdf0e10cSrcweir SdDefineCustomShowDlg aDlg( this, rDoc, pCustomShow ); 167cdf0e10cSrcweir 168cdf0e10cSrcweir if( aDlg.Execute() == RET_OK ) 169cdf0e10cSrcweir { 170cdf0e10cSrcweir if( pCustomShow ) 171cdf0e10cSrcweir { 172cdf0e10cSrcweir pCustomShowList->Replace( pCustomShow, nPos ); 173cdf0e10cSrcweir pCustomShowList->Seek( nPos ); 174cdf0e10cSrcweir aLbCustomShows.RemoveEntry( nPos ); 175cdf0e10cSrcweir aLbCustomShows.InsertEntry( pCustomShow->GetName(), nPos ); 176cdf0e10cSrcweir aLbCustomShows.SelectEntryPos( nPos ); 177cdf0e10cSrcweir } 178cdf0e10cSrcweir if( aDlg.IsModified() ) 179cdf0e10cSrcweir bModified = sal_True; 180cdf0e10cSrcweir } 181cdf0e10cSrcweir } 182cdf0e10cSrcweir } 183cdf0e10cSrcweir // CustomShow loeschen 184cdf0e10cSrcweir else if( p == &aBtnRemove ) 185cdf0e10cSrcweir { 186cdf0e10cSrcweir sal_uInt16 nPos = aLbCustomShows.GetSelectEntryPos(); 187cdf0e10cSrcweir if( nPos != LISTBOX_ENTRY_NOTFOUND ) 188cdf0e10cSrcweir { 189cdf0e10cSrcweir delete (SdCustomShow*) pCustomShowList->Remove( nPos ); 190cdf0e10cSrcweir aLbCustomShows.RemoveEntry( nPos ); 191cdf0e10cSrcweir aLbCustomShows.SelectEntryPos( nPos == 0 ? nPos : nPos - 1 ); 192cdf0e10cSrcweir bModified = sal_True; 193cdf0e10cSrcweir } 194cdf0e10cSrcweir } 195cdf0e10cSrcweir // CustomShow kopieren 196cdf0e10cSrcweir else if( p == &aBtnCopy ) 197cdf0e10cSrcweir { 198cdf0e10cSrcweir sal_uInt16 nPos = aLbCustomShows.GetSelectEntryPos(); 199cdf0e10cSrcweir if( nPos != LISTBOX_ENTRY_NOTFOUND ) 200cdf0e10cSrcweir { 201cdf0e10cSrcweir SdCustomShow* pShow = new SdCustomShow( *(SdCustomShow*) pCustomShowList->GetObject( nPos ) ); 202cdf0e10cSrcweir String aStr( pShow->GetName() ); 203cdf0e10cSrcweir String aStrCopy( SdResId( STR_COPY_CUSTOMSHOW ) ); 204cdf0e10cSrcweir 205cdf0e10cSrcweir sal_uInt16 nStrPos = aStr.Search( aStrCopy ); 206cdf0e10cSrcweir sal_uInt16 nNum = 1; 207cdf0e10cSrcweir if( nStrPos == STRING_NOTFOUND ) 208cdf0e10cSrcweir { 209cdf0e10cSrcweir aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " (" ) ); 210cdf0e10cSrcweir aStr.Append( aStrCopy ); 211cdf0e10cSrcweir aStr.Append( UniString::CreateFromInt32( nNum ) ); 212cdf0e10cSrcweir aStr.Append( sal_Unicode(')') ); 213cdf0e10cSrcweir nStrPos = aStr.Search( aStrCopy ); 214cdf0e10cSrcweir } 215cdf0e10cSrcweir nStrPos = nStrPos + (sal_uInt16)aStrCopy.Len(); 216cdf0e10cSrcweir // Um nicht ins Nirvana zu greifen (--> Endlosschleife) 217cdf0e10cSrcweir if( nStrPos >= aStr.Len() ) 218cdf0e10cSrcweir { 219cdf0e10cSrcweir aStr.Append( sal_Unicode(' ') ); 220cdf0e10cSrcweir aStr.Append( UniString::CreateFromInt32( nNum ) ); 221cdf0e10cSrcweir } 222cdf0e10cSrcweir 223cdf0e10cSrcweir // Name ueberpruefen... 224cdf0e10cSrcweir sal_Bool bDifferent = sal_False; 225cdf0e10cSrcweir //long nPosToSelect = pCustomShowList->GetCurPos(); 226cdf0e10cSrcweir while( !bDifferent ) 227cdf0e10cSrcweir { 228cdf0e10cSrcweir bDifferent = sal_True; 229cdf0e10cSrcweir for( pCustomShow = (SdCustomShow*) pCustomShowList->First(); 230cdf0e10cSrcweir pCustomShow != NULL && bDifferent; 231cdf0e10cSrcweir pCustomShow = (SdCustomShow*) pCustomShowList->Next() ) 232cdf0e10cSrcweir { 233cdf0e10cSrcweir if( aStr == pCustomShow->GetName() ) 234cdf0e10cSrcweir bDifferent = sal_False; 235cdf0e10cSrcweir } 236cdf0e10cSrcweir if( !bDifferent ) 237cdf0e10cSrcweir { 238cdf0e10cSrcweir // Nummer entfernen und durch um 1 erhoehte ersetzen 239cdf0e10cSrcweir 240cdf0e10cSrcweir const CharClass* pCharClass = rDoc.GetCharClass(); 241cdf0e10cSrcweir while( pCharClass->isDigit( aStr, nStrPos ) ) 242cdf0e10cSrcweir aStr.Erase( nStrPos, 1 ); 243cdf0e10cSrcweir aStr.Insert( UniString::CreateFromInt32( ++nNum ), nStrPos); 244cdf0e10cSrcweir } 245cdf0e10cSrcweir 246cdf0e10cSrcweir } 247cdf0e10cSrcweir //pCustomShowList->Seek( nPosToSelect ); 248cdf0e10cSrcweir pShow->SetName( aStr ); 249cdf0e10cSrcweir 250cdf0e10cSrcweir pCustomShowList->Insert( pShow, LIST_APPEND ); 251cdf0e10cSrcweir pCustomShowList->Last(); 252cdf0e10cSrcweir aLbCustomShows.InsertEntry( pShow->GetName() ); 253cdf0e10cSrcweir aLbCustomShows.SelectEntry( pShow->GetName() ); 254cdf0e10cSrcweir 255cdf0e10cSrcweir 256cdf0e10cSrcweir bModified = sal_True; 257cdf0e10cSrcweir } 258cdf0e10cSrcweir } 259cdf0e10cSrcweir else if( p == &aLbCustomShows ) 260cdf0e10cSrcweir { 261cdf0e10cSrcweir sal_uInt16 nPos = aLbCustomShows.GetSelectEntryPos(); 262cdf0e10cSrcweir if( nPos != LISTBOX_ENTRY_NOTFOUND ) 263cdf0e10cSrcweir pCustomShowList->Seek( nPos ); 264cdf0e10cSrcweir 265cdf0e10cSrcweir bModified = sal_True; 266cdf0e10cSrcweir } 267cdf0e10cSrcweir else if( p == &aCbxUseCustomShow ) 268cdf0e10cSrcweir { 269cdf0e10cSrcweir bModified = sal_True; 270cdf0e10cSrcweir } 271cdf0e10cSrcweir 272cdf0e10cSrcweir CheckState(); 273cdf0e10cSrcweir 274cdf0e10cSrcweir return( 0L ); 275cdf0e10cSrcweir } 276cdf0e10cSrcweir 277cdf0e10cSrcweir /************************************************************************* 278cdf0e10cSrcweir |* StartShow-Hdl 279cdf0e10cSrcweir \************************************************************************/ 280cdf0e10cSrcweir IMPL_LINK( SdCustomShowDlg, StartShowHdl, Button *, EMPTYARG ) 281cdf0e10cSrcweir { 282cdf0e10cSrcweir EndDialog( RET_YES ); 283cdf0e10cSrcweir 284cdf0e10cSrcweir return 0; 285cdf0e10cSrcweir } 286cdf0e10cSrcweir 287cdf0e10cSrcweir /************************************************************************* 288cdf0e10cSrcweir |* CheckState 289cdf0e10cSrcweir \************************************************************************/ 290cdf0e10cSrcweir sal_Bool SdCustomShowDlg::IsCustomShow() const 291cdf0e10cSrcweir { 292cdf0e10cSrcweir return( aCbxUseCustomShow.IsEnabled() && aCbxUseCustomShow.IsChecked() ); 293cdf0e10cSrcweir } 294cdf0e10cSrcweir 295cdf0e10cSrcweir 296cdf0e10cSrcweir 297cdf0e10cSrcweir /////////////////////////// 298cdf0e10cSrcweir // SdDefineCustomShowDlg // 299cdf0e10cSrcweir /////////////////////////// 300cdf0e10cSrcweir 301cdf0e10cSrcweir 302cdf0e10cSrcweir /************************************************************************* 303cdf0e10cSrcweir |* 304cdf0e10cSrcweir |* Konstruktor 305cdf0e10cSrcweir |* 306cdf0e10cSrcweir \************************************************************************/ 307cdf0e10cSrcweir SdDefineCustomShowDlg::SdDefineCustomShowDlg( Window* pWindow, 308cdf0e10cSrcweir SdDrawDocument& rDrawDoc, SdCustomShow*& rpCS ) : 309cdf0e10cSrcweir ModalDialog ( pWindow, SdResId( DLG_DEFINE_CUSTOMSHOW ) ), 310cdf0e10cSrcweir 311cdf0e10cSrcweir aFtName ( this, SdResId( FT_NAME ) ), 312cdf0e10cSrcweir aEdtName ( this, SdResId( EDT_NAME ) ), 313cdf0e10cSrcweir aFtPages ( this, SdResId( FT_PAGES ) ), 314cdf0e10cSrcweir aLbPages ( this, SdResId( LB_PAGES ) ), 315cdf0e10cSrcweir aBtnAdd ( this, SdResId( BTN_ADD ) ), 316cdf0e10cSrcweir aBtnRemove ( this, SdResId( BTN_REMOVE ) ), 317cdf0e10cSrcweir aFtCustomPages ( this, SdResId( FT_CUSTOM_PAGES ) ), 318cdf0e10cSrcweir aLbCustomPages ( this, SdResId( LB_CUSTOM_PAGES ) ), 319cdf0e10cSrcweir aBtnOK ( this, SdResId( BTN_OK ) ), 320cdf0e10cSrcweir aBtnCancel ( this, SdResId( BTN_CANCEL ) ), 321cdf0e10cSrcweir aBtnHelp ( this, SdResId( BTN_HELP ) ), 322cdf0e10cSrcweir 323cdf0e10cSrcweir rDoc ( rDrawDoc ), 324cdf0e10cSrcweir rpCustomShow ( rpCS ), 325cdf0e10cSrcweir bModified ( sal_False ) 326cdf0e10cSrcweir { 327cdf0e10cSrcweir FreeResource(); 328cdf0e10cSrcweir 329cdf0e10cSrcweir Link aLink = LINK( this, SdDefineCustomShowDlg, ClickButtonHdl ); 330cdf0e10cSrcweir aBtnAdd.SetClickHdl( aLink ); 331cdf0e10cSrcweir aBtnRemove.SetClickHdl( aLink ); 332cdf0e10cSrcweir aEdtName.SetModifyHdl( aLink ); 333cdf0e10cSrcweir aLbPages.SetSelectHdl( aLink ); // wegen Status 334cdf0e10cSrcweir aLbCustomPages.SetSelectHdl( aLink ); // wegen Status 335cdf0e10cSrcweir 336cdf0e10cSrcweir aBtnOK.SetClickHdl( LINK( this, SdDefineCustomShowDlg, OKHdl ) ); 337cdf0e10cSrcweir 338cdf0e10cSrcweir SdPage* pPage; 339cdf0e10cSrcweir // Listbox mit Seitennamen des Docs fuellen 340cdf0e10cSrcweir for( long nPage = 0L; 341cdf0e10cSrcweir nPage < rDoc.GetSdPageCount( PK_STANDARD ); 342cdf0e10cSrcweir nPage++ ) 343cdf0e10cSrcweir { 344cdf0e10cSrcweir pPage = rDoc.GetSdPage( (sal_uInt16) nPage, PK_STANDARD ); 345cdf0e10cSrcweir String aStr( pPage->GetName() ); 346cdf0e10cSrcweir aLbPages.InsertEntry( aStr ); 347cdf0e10cSrcweir } 348cdf0e10cSrcweir //aLbPages.SelectEntryPos( 0 ); 349cdf0e10cSrcweir 350cdf0e10cSrcweir if( rpCustomShow ) 351cdf0e10cSrcweir { 352cdf0e10cSrcweir aOldName = rpCustomShow->GetName(); 353cdf0e10cSrcweir aEdtName.SetText( aOldName ); 354cdf0e10cSrcweir 355cdf0e10cSrcweir // ListBox mit CustomShow-Seiten fuellen 356cdf0e10cSrcweir for( pPage = (SdPage*) rpCustomShow->First(); 357cdf0e10cSrcweir pPage != NULL; 358cdf0e10cSrcweir pPage = (SdPage*) rpCustomShow->Next() ) 359cdf0e10cSrcweir { 360cdf0e10cSrcweir SvLBoxEntry* pEntry = aLbCustomPages.InsertEntry( pPage->GetName() ); 361cdf0e10cSrcweir pEntry->SetUserData( pPage ); 362cdf0e10cSrcweir } 363cdf0e10cSrcweir } 364cdf0e10cSrcweir else 365cdf0e10cSrcweir { 366cdf0e10cSrcweir rpCustomShow = new SdCustomShow( &rDoc ); 367cdf0e10cSrcweir aEdtName.SetText( String( SdResId( STR_NEW_CUSTOMSHOW ) ) ); 368cdf0e10cSrcweir aEdtName.SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) ); 369cdf0e10cSrcweir rpCustomShow->SetName( aEdtName.GetText() ); 370cdf0e10cSrcweir } 371cdf0e10cSrcweir 372cdf0e10cSrcweir aLbCustomPages.SetDragDropMode( SV_DRAGDROP_CTRL_MOVE ); 373cdf0e10cSrcweir aLbCustomPages.SetHighlightRange(); 374cdf0e10cSrcweir 375cdf0e10cSrcweir aBtnOK.Enable( sal_False ); 376cdf0e10cSrcweir CheckState(); 377cdf0e10cSrcweir } 378cdf0e10cSrcweir 379cdf0e10cSrcweir /************************************************************************* 380cdf0e10cSrcweir |* 381cdf0e10cSrcweir |* Dtor 382cdf0e10cSrcweir |* 383cdf0e10cSrcweir \************************************************************************/ 384cdf0e10cSrcweir SdDefineCustomShowDlg::~SdDefineCustomShowDlg() 385cdf0e10cSrcweir { 386cdf0e10cSrcweir } 387cdf0e10cSrcweir 388cdf0e10cSrcweir /************************************************************************* 389cdf0e10cSrcweir |* CheckState 390cdf0e10cSrcweir \************************************************************************/ 391cdf0e10cSrcweir void SdDefineCustomShowDlg::CheckState() 392cdf0e10cSrcweir { 393cdf0e10cSrcweir sal_Bool bPages = aLbPages.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND; 394cdf0e10cSrcweir //sal_Bool bCSPages = aLbCustomPages.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND; 395cdf0e10cSrcweir sal_Bool bCSPages = aLbCustomPages.FirstSelected() != NULL; 396cdf0e10cSrcweir sal_Bool bCount = aLbCustomPages.GetEntryCount() > 0; 397cdf0e10cSrcweir 398cdf0e10cSrcweir aBtnOK.Enable( bCount ); 399cdf0e10cSrcweir aBtnAdd.Enable( bPages ); 400cdf0e10cSrcweir aBtnRemove.Enable( bCSPages ); 401cdf0e10cSrcweir } 402cdf0e10cSrcweir 403cdf0e10cSrcweir /************************************************************************* 404cdf0e10cSrcweir |* ButtonHdl() 405cdf0e10cSrcweir \************************************************************************/ 406cdf0e10cSrcweir IMPL_LINK( SdDefineCustomShowDlg, ClickButtonHdl, void *, p ) 407cdf0e10cSrcweir { 408cdf0e10cSrcweir if( p == &aBtnAdd ) 409cdf0e10cSrcweir { 410cdf0e10cSrcweir sal_uInt16 nCount = aLbPages.GetSelectEntryCount(); 411cdf0e10cSrcweir if( nCount > 0 ) 412cdf0e10cSrcweir { 413cdf0e10cSrcweir sal_uLong nPosCP = LIST_APPEND; 414cdf0e10cSrcweir SvLBoxEntry* pEntry = aLbCustomPages.FirstSelected(); 415cdf0e10cSrcweir if( pEntry ) 416cdf0e10cSrcweir nPosCP = aLbCustomPages.GetModel()->GetAbsPos( pEntry ) + 1L; 417cdf0e10cSrcweir 418cdf0e10cSrcweir for( sal_uInt16 i = 0; i < nCount; i++ ) 419cdf0e10cSrcweir { 420cdf0e10cSrcweir String aStr = aLbPages.GetSelectEntry( i ); 421cdf0e10cSrcweir pEntry = aLbCustomPages.InsertEntry( aStr, 422cdf0e10cSrcweir 0, sal_False, nPosCP ); 423cdf0e10cSrcweir 424cdf0e10cSrcweir aLbCustomPages.Select( pEntry ); 425cdf0e10cSrcweir SdPage* pPage = rDoc.GetSdPage( (sal_uInt16) aLbPages. 426cdf0e10cSrcweir GetSelectEntryPos( i ), PK_STANDARD ); 427cdf0e10cSrcweir pEntry->SetUserData( pPage ); 428cdf0e10cSrcweir 429cdf0e10cSrcweir if( nPosCP != LIST_APPEND ) 430cdf0e10cSrcweir nPosCP++; 431cdf0e10cSrcweir } 432cdf0e10cSrcweir bModified = sal_True; 433cdf0e10cSrcweir } 434cdf0e10cSrcweir } 435cdf0e10cSrcweir else if( p == &aBtnRemove ) 436cdf0e10cSrcweir { 437cdf0e10cSrcweir //sal_uInt16 nPos = aLbCustomPages.GetSelectEntryPos(); 438cdf0e10cSrcweir SvLBoxEntry* pEntry = aLbCustomPages.FirstSelected(); 439cdf0e10cSrcweir if( pEntry ) 440cdf0e10cSrcweir { 441cdf0e10cSrcweir sal_uLong nPos = aLbCustomPages.GetModel()->GetAbsPos( pEntry ); 442cdf0e10cSrcweir //rpCustomShow->Remove( nPos ); 443cdf0e10cSrcweir //aLbCustomPages.RemoveEntry( nPos ); 444cdf0e10cSrcweir aLbCustomPages.GetModel()->Remove( aLbCustomPages.GetModel()->GetEntryAtAbsPos( nPos ) ); 445cdf0e10cSrcweir 446cdf0e10cSrcweir bModified = sal_True; 447cdf0e10cSrcweir } 448cdf0e10cSrcweir } 449cdf0e10cSrcweir else if( p == &aEdtName ) 450cdf0e10cSrcweir { 451cdf0e10cSrcweir //rpCustomShow->SetName( aEdtName.GetText() ); 452cdf0e10cSrcweir 453cdf0e10cSrcweir bModified = sal_True; 454cdf0e10cSrcweir } 455cdf0e10cSrcweir 456cdf0e10cSrcweir CheckState(); 457cdf0e10cSrcweir 458cdf0e10cSrcweir return( 0L ); 459cdf0e10cSrcweir } 460cdf0e10cSrcweir 461cdf0e10cSrcweir /************************************************************************* 462cdf0e10cSrcweir |* CheckCustomShow(): 463cdf0e10cSrcweir |* Ueberprueft die Page-Pointer der Show, da die Eintraege ueber die 464cdf0e10cSrcweir |* TreeLB verschoben und kopiert werden k�nnen 465cdf0e10cSrcweir \************************************************************************/ 466cdf0e10cSrcweir void SdDefineCustomShowDlg::CheckCustomShow() 467cdf0e10cSrcweir { 468cdf0e10cSrcweir sal_Bool bDifferent = sal_False; 469cdf0e10cSrcweir SdPage* pPage = NULL; 470cdf0e10cSrcweir SvLBoxEntry* pEntry = NULL; 471cdf0e10cSrcweir 472cdf0e10cSrcweir // Anzahl vergleichen 473cdf0e10cSrcweir if( rpCustomShow->Count() != aLbCustomPages.GetEntryCount() ) 474cdf0e10cSrcweir { 475cdf0e10cSrcweir rpCustomShow->Clear(); 476cdf0e10cSrcweir bDifferent = sal_True; 477cdf0e10cSrcweir } 478cdf0e10cSrcweir 479cdf0e10cSrcweir // Seiten-Pointer vergleichen 480cdf0e10cSrcweir if( !bDifferent ) 481cdf0e10cSrcweir { 482cdf0e10cSrcweir for( pPage = (SdPage*) rpCustomShow->First(), pEntry = aLbCustomPages.First(); 483cdf0e10cSrcweir pPage != NULL && pEntry != NULL && !bDifferent; 484cdf0e10cSrcweir pPage = (SdPage*) rpCustomShow->Next(), pEntry = aLbCustomPages.Next( pEntry ) ) 485cdf0e10cSrcweir { 486cdf0e10cSrcweir if( pPage != pEntry->GetUserData() ) 487cdf0e10cSrcweir { 488cdf0e10cSrcweir rpCustomShow->Clear(); 489cdf0e10cSrcweir bDifferent = sal_True; 490cdf0e10cSrcweir } 491cdf0e10cSrcweir } 492cdf0e10cSrcweir } 493cdf0e10cSrcweir 494cdf0e10cSrcweir // Seiten-Pointer neu setzen 495cdf0e10cSrcweir if( bDifferent ) 496cdf0e10cSrcweir { 497cdf0e10cSrcweir for( pEntry = aLbCustomPages.First(); 498cdf0e10cSrcweir pEntry != NULL; 499cdf0e10cSrcweir pEntry = aLbCustomPages.Next( pEntry ) ) 500cdf0e10cSrcweir { 501cdf0e10cSrcweir pPage = (SdPage*) pEntry->GetUserData(); 502cdf0e10cSrcweir rpCustomShow->Insert( pPage, LIST_APPEND ); 503cdf0e10cSrcweir } 504cdf0e10cSrcweir bModified = sal_True; 505cdf0e10cSrcweir } 506cdf0e10cSrcweir 507cdf0e10cSrcweir // Name vergleichen und ggfs. setzen 508cdf0e10cSrcweir String aStr( aEdtName.GetText() ); 509cdf0e10cSrcweir if( rpCustomShow->GetName() != aStr ) 510cdf0e10cSrcweir { 511cdf0e10cSrcweir rpCustomShow->SetName( aStr ); 512cdf0e10cSrcweir bModified = sal_True; 513cdf0e10cSrcweir } 514cdf0e10cSrcweir } 515cdf0e10cSrcweir 516cdf0e10cSrcweir /************************************************************************* 517cdf0e10cSrcweir |* OK-Hdl 518cdf0e10cSrcweir \************************************************************************/ 519cdf0e10cSrcweir IMPL_LINK( SdDefineCustomShowDlg, OKHdl, Button *, EMPTYARG ) 520cdf0e10cSrcweir { 521cdf0e10cSrcweir // Name ueberpruefen... 522cdf0e10cSrcweir sal_Bool bDifferent = sal_True; 523cdf0e10cSrcweir List* pCustomShowList = rDoc.GetCustomShowList(); 524cdf0e10cSrcweir if( pCustomShowList ) 525cdf0e10cSrcweir { 526cdf0e10cSrcweir String aName( aEdtName.GetText() ); 527cdf0e10cSrcweir SdCustomShow* pCustomShow; 528cdf0e10cSrcweir 529cdf0e10cSrcweir long nPosToSelect = pCustomShowList->GetCurPos(); 530cdf0e10cSrcweir for( pCustomShow = (SdCustomShow*) pCustomShowList->First(); 531cdf0e10cSrcweir pCustomShow != NULL; 532cdf0e10cSrcweir pCustomShow = (SdCustomShow*) pCustomShowList->Next() ) 533cdf0e10cSrcweir { 534cdf0e10cSrcweir if( aName == pCustomShow->GetName() && aName != aOldName ) 535cdf0e10cSrcweir bDifferent = sal_False; 536cdf0e10cSrcweir } 537cdf0e10cSrcweir pCustomShowList->Seek( nPosToSelect ); 538cdf0e10cSrcweir } 539cdf0e10cSrcweir 540cdf0e10cSrcweir if( bDifferent ) 541cdf0e10cSrcweir { 542cdf0e10cSrcweir CheckCustomShow(); 543cdf0e10cSrcweir 544cdf0e10cSrcweir EndDialog( RET_OK ); 545cdf0e10cSrcweir } 546cdf0e10cSrcweir else 547cdf0e10cSrcweir { 548cdf0e10cSrcweir WarningBox( this, WinBits( WB_OK ), 549cdf0e10cSrcweir String( SdResId( STR_WARN_NAME_DUPLICATE ) ) ).Execute(); 550cdf0e10cSrcweir 551cdf0e10cSrcweir aEdtName.GrabFocus(); 552cdf0e10cSrcweir } 553cdf0e10cSrcweir 554cdf0e10cSrcweir return 0; 555cdf0e10cSrcweir } 556cdf0e10cSrcweir 557