1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 29 #include <stdio.h> 30 #include <tools/stream.hxx> 31 #include <tools/debug.hxx> 32 #include <vcl/msgbox.hxx> 33 #include <svtools/prgsbar.hxx> 34 35 #include <soldep/depper.hxx> 36 #include <soldep/objwin.hxx> 37 38 #include "math.h" 39 #include "time.h" 40 #include "stdlib.h" 41 #include "dtsodcmp.hrc" 42 43 #include <vcl/svapp.hxx> 44 45 #define MIN(a,b) (a)<(b)?(a):(b) 46 #define MAX(a,b) (a)>(b)?(a):(b) 47 48 ByteString sDelimiterLine("#=========================================================================="); 49 50 51 52 53 Depper::Depper( Window* pBaseWindow ): 54 Window( pBaseWindow ), 55 mbIsPrjView(sal_False), 56 maDefPos( 50, 50 ), 57 maDefSize( 60, 25 ), 58 mnViewMask( 1 ), 59 pSubBar( NULL ), 60 pMainBar( NULL ), 61 pSubText( NULL ), 62 pMainText( NULL ), 63 maArrangeDlg( pBaseWindow ), 64 mpPrjIdMapper( NULL ), 65 maToolBox( pBaseWindow, DtSodResId(TID_SOLDEP_MAIN) ), 66 maTaskBarFrame( pBaseWindow, 0) 67 { 68 maArrangeDlg.Hide(); 69 70 mpProcessWin = pBaseWindow; 71 mpGraphWin = new GraphWin( mpProcessWin, this ); 72 mpGraphPrjWin = new GraphWin( mpProcessWin, this ); 73 //mpBaseWin paints into virtual OutputDevice 74 mpBaseWin = new DepWin( mpGraphWin->GetBufferWindow(), WB_NOBORDER | WB_SIZEABLE | WB_AUTOSIZE ); 75 mpBasePrjWin = new DepWin( mpGraphPrjWin->GetBufferWindow(), WB_NOBORDER | WB_SIZEABLE | WB_AUTOSIZE ); 76 77 mpGraphWin->SetBackground( Wallpaper( Color( COL_RED ))); 78 mpGraphPrjWin->SetBackground( Wallpaper( Color( COL_BLUE ))); 79 mpGraphPrjWin->Hide(); 80 mpBaseWin->SetBackground( Wallpaper( Color( COL_WHITE ))); 81 mpBasePrjWin->SetBackground( Wallpaper( Color( COL_LIGHTGRAY ))); 82 /* 83 mpGraphWin->SetZOrder( NULL, WINDOW_ZORDER_FIRST ); 84 mpGraphPrjWin->SetZOrder( NULL, WINDOW_ZORDER_FIRST ); 85 mpBaseWin->SetZOrder( NULL, WINDOW_ZORDER_FIRST ); 86 */ 87 mpGraphWin->EnableClipSiblings(); 88 mpGraphPrjWin->EnableClipSiblings(); 89 90 mpParentProcessWin = mpProcessWin->GetParent(); 91 mpBaseWin->Show(); 92 nZoomed = 0; 93 94 mpBaseWin->SetPopupHdl( this ); 95 mpBasePrjWin->SetPopupHdl( this ); 96 97 mpObjectList = new ObjectList(); //ObjectList unbekannt 98 mpObjectPrjList = new ObjectList(); 99 } 100 101 Depper::~Depper() 102 { 103 // delete mpObjectList; 104 delete mpBaseWin; 105 delete mpGraphWin; 106 } 107 108 sal_Bool Depper::TogglePrjViewStatus() 109 { 110 GetDepWin()->Hide(); //Hide old content window 111 GetGraphWin()->Hide(); 112 mbIsPrjView = !mbIsPrjView; //switch now 113 GetDepWin()->Invalidate(); 114 GetGraphWin()->Show(); 115 GetDepWin()->Show(); //Show new content window 116 return mbIsPrjView; 117 } 118 119 void Depper::HideObjectsAndConnections( ObjectList* pObjLst ) 120 { 121 for ( sal_uIntPtr i = 0; i < pObjLst->Count(); i ++ ) { 122 ObjectWin *pWin = pObjLst->GetObject( i ); 123 pWin->Hide(); 124 } 125 mpGraphWin->Hide(); 126 mpBaseWin->Hide(); 127 mpGraphPrjWin->Show(); 128 mpBasePrjWin->Show(); 129 } 130 131 void Depper::ShowObjectsAndConnections( ObjectList* pObjLst ) 132 { 133 for ( sal_uIntPtr i = 0; i < pObjLst->Count(); i ++ ) { 134 ObjectWin *pWin = pObjLst->GetObject( i ); 135 pWin->Show(); 136 } 137 mpBasePrjWin->Hide(); 138 mpGraphPrjWin->Hide(); 139 mpGraphWin->Show(); 140 mpBaseWin->Show(); 141 } 142 143 144 void Depper::RemoveAllObjects( ObjectList* pObjLst ) 145 { 146 sal_uIntPtr i; 147 148 for ( i = pObjLst->Count(); i > 0; i-- ) 149 delete pObjLst->GetObject( i - 1 ); 150 pObjLst->Clear(); 151 } 152 153 sal_uInt16 Depper::Save( const ByteString& rFileName ) 154 { 155 DBG_ASSERT( sal_False , "you are dead!" ); 156 SvFileStream aOutFile( String( rFileName, RTL_TEXTENCODING_UTF8 ), STREAM_WRITE ); 157 depper_head dh; 158 sal_uInt16 i; 159 sal_uIntPtr nObjCount = mpObjectList->Count(); 160 161 ConnectorList* pConList = GetDepWin()->GetConnectorList(); 162 sal_uIntPtr nCnctrCount = pConList->Count(); 163 164 dh.nID = DEPPER_ID; 165 dh.nObjectCount = nObjCount; 166 dh.nCnctrCount = nCnctrCount; 167 168 aOutFile.Write( &dh, sizeof( dh )); 169 170 for ( i=0; i < nObjCount ; i++ ) 171 { 172 mpObjectList->GetObject( i )->Save( aOutFile ); 173 } 174 175 for ( i=0; i < nCnctrCount ; i++ ) 176 { 177 pConList->GetObject( i )->Save( aOutFile ); 178 } 179 180 return 0; 181 } 182 183 184 sal_uInt16 Depper::WriteSource() 185 { 186 DBG_ASSERT( sal_False , "overload it!" ); 187 return 0; 188 }; 189 190 sal_uInt16 Depper::ReadSource( sal_Bool bUpdater ) 191 { 192 DBG_ASSERT( sal_False , "overload it!" ); 193 return 0; 194 }; 195 196 sal_uInt16 Depper::OpenSource() 197 { 198 DBG_ASSERT( sal_False , "overload it!" ); 199 return 0; 200 }; 201 202 ObjectWin* Depper::ObjIdToPtr( ObjectList* pObjLst, sal_uIntPtr nId ) 203 { 204 sal_uIntPtr nObjCount = pObjLst->Count(); 205 sal_uIntPtr i = 0; 206 ObjectWin* pWin; 207 sal_uIntPtr nWinId = 0; 208 209 do 210 { 211 pWin = pObjLst->GetObject( i ); 212 nWinId = pWin->GetId(); 213 i++; 214 } 215 while( i < nObjCount && pWin->GetId() != nId ); 216 if ( pWin->GetId() == nId ) 217 return pWin; 218 else 219 return NULL; 220 } 221 222 void Depper::SetMainProgressBar( sal_uInt16 i) 223 { 224 if ( pMainBar ) { 225 pMainBar->SetValue( 100 ); 226 pMainBar->Update(); 227 } 228 } 229 230 void Depper::UpdateMainProgressBar(sal_uInt16 i, sal_uInt16 nScaleVal, sal_uInt16 &nStep, sal_Bool bCountingDown ) 231 { 232 sal_uIntPtr val = 0; 233 if ( pMainBar ) { 234 // val = i * 50 / nScaleVal + 1; 235 val = bCountingDown ? 50 + ( nScaleVal - i ) * 50 / nScaleVal : i * 50 / nScaleVal; 236 237 pMainBar->SetValue( val ); 238 pMainBar->Update(); 239 String sText( String::CreateFromAscii( "Optimize step " )); 240 sText += String::CreateFromInt32( ++nStep ); 241 pSubText->SetText( sText ); 242 } 243 } 244 245 void Depper::UpdateSubProgrssBar(sal_uIntPtr i) 246 { 247 if ( pSubBar ) 248 { 249 pSubBar->SetValue( i ); 250 pSubBar->Update(); 251 GetpApp()->Reschedule(); 252 } 253 } 254 255 256 sal_uInt16 Depper::AutoArrangeDlgStart() 257 { 258 pSubBar = maArrangeDlg.GetSubBar(); 259 pMainBar = maArrangeDlg.GetMainBar(); 260 pSubText = maArrangeDlg.GetSubText(); 261 pMainText = maArrangeDlg.GetMainText(); 262 pMainText->SetText( String::CreateFromAscii( "Overall status" )); 263 maArrangeDlg.Show(); 264 GetDepWin()->Enable( sal_False ); 265 GetDepWin()->Hide(); 266 return 0; 267 } 268 269 sal_uInt16 Depper::AutoArrangeDlgStop() 270 { 271 maArrangeDlg.Hide(); 272 GetDepWin()->Enable( sal_True ); 273 GetDepWin()->Show(); 274 pSubBar = NULL; 275 pMainBar = NULL; 276 pSubText = NULL; 277 pMainText = NULL; 278 return 0; 279 } 280 281 282 283 sal_uInt16 Depper::Zoom( MapMode& rMapMode ) 284 { 285 sal_uIntPtr i; 286 ObjectWin* pWin; 287 Point aPos; 288 Size aSize; 289 ObjectList* pObjList; 290 pObjList = GetObjectList(); 291 // aSize = mpBaseWin->GetSizePixel(); 292 // mpGraphWin->SetTotalSize( aSize ); 293 // mpGraphWin->EndScroll( 0, 0 ); 294 295 for ( i = pObjList->Count(); i > 0; i-- ) 296 { 297 pWin = pObjList->GetObject( i - 1 ); 298 aPos = pWin->PixelToLogic( pWin->GetPosPixel()); 299 aSize = pWin->PixelToLogic( pWin->GetSizePixel()); 300 pWin->SetMapMode( rMapMode ); 301 aPos = pWin->LogicToPixel( aPos ); 302 aSize = pWin->LogicToPixel( aSize ); 303 pWin->SetPosSizePixel( aPos, aSize ); 304 } 305 GetDepWin()->Invalidate(); 306 return 0; 307 } 308 309 sal_uIntPtr Depper::AddObjectToList( DepWin* pParentWin, ObjectList* pObjLst, sal_uIntPtr &LastID, sal_uIntPtr &WinCount, ByteString& rBodyText, sal_Bool bInteract ) 310 { 311 Point aPos; 312 Size aSize = GetDefSize(); 313 314 aPos = GetDepWin()->LogicToPixel( aPos ); 315 aSize = GetDepWin()->LogicToPixel( aSize ); 316 return AddObjectToList( pParentWin, pObjLst, LastID, WinCount, rBodyText, aPos, aSize ); 317 } 318 319 sal_uIntPtr Depper::AddObjectToList( DepWin* pParentWin, ObjectList* pObjLst, sal_uIntPtr &LastID, sal_uIntPtr &WinCount, ByteString& rBodyText, Point& rPos, Size& rSize ) 320 { 321 ObjectWin* pWin = new ObjectWin( pParentWin, WB_BORDER ); 322 //pWin->mpDepperDontuseme = this; 323 pWin->SetGlobalViewMask(mnViewMask); // Set ViewMask for all ObjectWin and Connector objects 324 325 Size aNewSize; 326 aNewSize.Width() = pWin->GetTextWidth( String( rBodyText, RTL_TEXTENCODING_UTF8 )); 327 aNewSize.Height() = pWin->GetTextHeight(); 328 if ( aNewSize.Width() > rSize.Width() - 8 ) 329 { 330 aNewSize.Width() = aNewSize.Width() + 8; 331 aNewSize.Height() = rSize.Height(); 332 } 333 else 334 aNewSize = rSize; 335 pWin->SetPosSizePixel( rPos,aNewSize); 336 337 MapMode aMapMode = mpBaseWin->GetMapMode(); 338 pWin->SetMapMode( aMapMode ); 339 340 pObjLst->Insert( pWin, LIST_APPEND ); 341 pWin->SetId( LastID ); 342 LastID++; 343 WinCount++; 344 pWin->SetBodyText( rBodyText ); 345 // pWin->Show(); 346 return pWin->GetId(); 347 } 348 349 /*void Depper::DrawOutput( OutputDevice* pDevice ) 350 { 351 GetDepWin()->DrawOutput( pDevice ); 352 ObjectList* pObjList = GetObjectList(); 353 for ( sal_uInt16 i = pObjList->Count(); i > 0; i-- ) 354 { 355 ObjectWin* pWin = pObjList->GetObject( i - 1 ); 356 pWin->DrawOutput( pDevice ); 357 } 358 }*/ 359 360 ObjectWin* Depper::RemoveObjectFromList( ObjectList* pObjLst, sal_uIntPtr &WinCount, sal_uInt16 nId, sal_Bool bDelete ) 361 { 362 ObjectWin* pWin = ObjIdToPtr( pObjLst, nId ); 363 364 if ( pWin ) 365 { 366 pObjLst->Remove( pWin ); 367 WinCount--; 368 if( bDelete ) 369 delete pWin; 370 return pWin; 371 } 372 else 373 return NULL; 374 } 375 sal_uInt16 Depper::AddConnectorToObjects( ObjectList* pObjLst, sal_uIntPtr nStartId, sal_uIntPtr nEndId ) 376 { 377 ObjectWin* pStartWin = ObjIdToPtr( pObjLst, nStartId ); 378 379 if ( !pStartWin ) 380 return DEP_STARTID_NOT_FOUND; 381 382 ObjectWin* pEndWin = ObjIdToPtr( pObjLst, nEndId ); 383 384 if ( !pEndWin ) 385 return DEP_STARTID_NOT_FOUND; 386 387 return AddConnectorToObjects( pStartWin, pEndWin ); 388 } 389 390 sal_uInt16 Depper::RemoveConnectorFromObjects( ObjectList* pObjLst, sal_uIntPtr nStartId, sal_uIntPtr nEndId ) 391 { 392 // DBG_ASSERT( FALSE , "noch nicht" ); 393 ObjectWin* pStartWin = ObjIdToPtr( pObjLst, nStartId ); 394 395 if ( !pStartWin ) 396 return DEP_STARTID_NOT_FOUND; 397 398 ObjectWin* pEndWin = ObjIdToPtr( pObjLst, nEndId ); 399 400 if ( !pEndWin ) 401 return DEP_STARTID_NOT_FOUND; 402 403 return RemoveConnectorFromObjects( pStartWin, pEndWin ); 404 } 405 406 sal_uInt16 Depper::AddConnectorToObjects( ObjectWin* pStartWin, ObjectWin* pEndWin ) 407 { 408 if ( pStartWin->ConnectionExistsInAnyDirection( pEndWin )) 409 return 0; 410 411 Connector* pCon = new Connector( GetDepWin(), WB_NOBORDER ); 412 // pCon->Initialize( pStartWin, pEndWin ); 413 if (pStartWin->IsNullObject()) //null_project 414 pCon->Initialize( pStartWin, pEndWin, sal_False ); 415 else 416 pCon->Initialize( pStartWin, pEndWin, sal_True ); 417 return 0; 418 } 419 420 sal_uInt16 Depper::RemoveConnectorFromObjects( ObjectWin* pStartWin, ObjectWin* pEndWin ) 421 { 422 Connector* pCon = pStartWin->GetConnector( pStartWin->GetId(), pEndWin->GetId() ); 423 424 if ( !pCon ) 425 return DEP_CONNECTOR_NOT_FOUND; 426 else 427 { 428 delete pCon; 429 return DEP_OK; 430 } 431 } 432 433 sal_uIntPtr Depper::HandleNewPrjDialog( ByteString &rBodyText ) 434 { 435 SolNewProjectDlg aNewProjectDlg( GetDepWin(), DtSodResId( RID_SD_DIALOG_NEWPROJECT )); 436 if ( aNewProjectDlg.Execute() ) 437 { 438 rBodyText = ByteString( aNewProjectDlg.maEName.GetText(), RTL_TEXTENCODING_UTF8); 439 //hashtable auf stand halten 440 MyHashObject* pHObject; 441 sal_uIntPtr nObjectId = AddObjectToList( mpBaseWin, mpObjectList, mnSolLastId, mnSolWinCount, rBodyText, sal_False ); 442 pHObject = new MyHashObject( nObjectId, ObjIdToPtr( mpObjectList, nObjectId )); 443 mpSolIdMapper->Insert( rBodyText, pHObject ); 444 445 ByteString sTokenLine( aNewProjectDlg.maEShort.GetText(), RTL_TEXTENCODING_UTF8 ); 446 sTokenLine += '\t'; 447 sTokenLine += ByteString( aNewProjectDlg.maEName.GetText(), RTL_TEXTENCODING_UTF8 ); 448 sTokenLine += "\t:\t"; 449 450 ByteString sDeps = ByteString( aNewProjectDlg.maEDeps.GetText(), RTL_TEXTENCODING_UTF8 ); 451 452 if ( sDeps != "" ) 453 { 454 sal_uInt16 i; 455 ByteString sDepName; 456 sal_uInt16 nToken = sDeps.GetTokenCount(' '); 457 for ( i = 0 ; i < nToken ; i++) 458 { 459 sDepName = sDeps.GetToken( i, ' ' ); 460 sTokenLine += sDepName; 461 sTokenLine +='\t'; 462 } 463 } 464 sTokenLine +="NULL"; 465 466 mpStarWriter->InsertTokenLine( sTokenLine ); 467 mpStarWriter->InsertTokenLine( sDelimiterLine ); 468 469 if ( sDeps != "" ) 470 { 471 sal_uInt16 i; 472 ByteString sDepName; 473 sal_uIntPtr nObjectId_l, nHashedId; 474 MyHashObject* pHObject_l; 475 sal_uInt16 nToken = sDeps.GetTokenCount(' '); 476 for ( i = 0 ; i < nToken ; i++) 477 { 478 sDepName = sDeps.GetToken( i, ' ' ); 479 480 pHObject_l = mpSolIdMapper->Find( sDepName ); 481 if ( !pHObject_l ) 482 { 483 String sMessage; 484 sMessage += String::CreateFromAscii("can't find "); 485 sMessage += String( sDepName, RTL_TEXTENCODING_UTF8 ); 486 sMessage += String::CreateFromAscii(".\ndependency ignored"); 487 WarningBox aBox( GetDepWin(), WB_OK, sMessage); 488 aBox.Execute(); 489 } 490 else 491 { 492 nHashedId = pHObject_l->GetId(); 493 pHObject_l = mpSolIdMapper->Find( rBodyText ); 494 nObjectId_l = pHObject_l->GetId(); 495 AddConnectorToObjects( mpObjectList, nHashedId, nObjectId_l ); 496 } 497 } 498 } 499 return nObjectId; 500 } 501 return 0; 502 } 503 504 sal_uIntPtr Depper::HandleNewDirectoryDialog(ByteString &rBodyText) 505 { 506 SolNewDirectoryDlg aNewDirectoryDlg( GetDepWin(), DtSodResId( RID_SD_DIALOG_NEWDIRECTORY )); 507 //todo: set defaults 508 if ( aNewDirectoryDlg.Execute() ) 509 { 510 rBodyText = ByteString( aNewDirectoryDlg.maEFlag.GetText(), RTL_TEXTENCODING_UTF8 ); 511 //hashtable auf stand halten 512 MyHashObject* pHObject; 513 sal_uIntPtr nObjectId = AddObjectToList( GetDepWin(), mpObjectPrjList, mnSolLastId, mnSolWinCount, rBodyText ); 514 pHObject = new MyHashObject( nObjectId, ObjIdToPtr( mpObjectPrjList, nObjectId )); 515 mpPrjIdMapper->Insert( rBodyText, pHObject ); // mpPrjIdMapper 516 517 String sTokenLine; 518 sTokenLine = String( mpPrj->GetPreFix(), RTL_TEXTENCODING_UTF8 ); 519 sTokenLine += '\t'; 520 String sNameConvert = aNewDirectoryDlg.maEName.GetText(); 521 sNameConvert.SearchAndReplaceAll( '/', '\\' ); 522 if ( sNameConvert.GetToken( 0, 0x5c ) != String( mpPrj->GetProjectName(), RTL_TEXTENCODING_UTF8 )) 523 { 524 sTokenLine += String( mpPrj->GetProjectName(), RTL_TEXTENCODING_UTF8 ); 525 sTokenLine += String("\\", RTL_TEXTENCODING_UTF8 ); 526 sTokenLine += sNameConvert; 527 } 528 else 529 sTokenLine += sNameConvert; 530 sTokenLine += '\t'; 531 sTokenLine += aNewDirectoryDlg.maEAction.GetText(); 532 sTokenLine += String( "\t-\t", RTL_TEXTENCODING_UTF8 ); 533 sTokenLine += aNewDirectoryDlg.maEEnv.GetText(); 534 sTokenLine += '\t'; 535 sTokenLine += aNewDirectoryDlg.maEFlag.GetText(); 536 sTokenLine += '\t'; 537 538 sTokenLine += String( "NULL", RTL_TEXTENCODING_UTF8 ); 539 540 ByteString bsTokenLine = ByteString( sTokenLine, RTL_TEXTENCODING_UTF8 ); 541 mpStarWriter->InsertTokenLine( bsTokenLine ); 542 543 if ( aNewDirectoryDlg.maEDeps.GetText() != String( "", RTL_TEXTENCODING_UTF8 )) 544 { 545 sal_uInt16 i; 546 ByteString sDeps = ByteString( aNewDirectoryDlg.maEDeps.GetText(), RTL_TEXTENCODING_UTF8 ); 547 ByteString sDepName; 548 sal_uIntPtr nObjectId_l, nHashedId; 549 MyHashObject* pHObject_l; 550 sal_uInt16 nToken = sDeps.GetTokenCount(' '); 551 for ( i = 0 ; i < nToken ; i++) 552 { 553 sDepName = sDeps.GetToken( i, ' ' ); 554 555 pHObject_l = mpPrjIdMapper->Find( sDepName ); // mpPrjIdMapper 556 if ( !pHObject_l ) 557 { 558 String sMessage; 559 sMessage += String::CreateFromAscii("can't find "); 560 sMessage += String( sDepName, RTL_TEXTENCODING_UTF8 ); 561 sMessage += String::CreateFromAscii(".\ndependency ignored"); 562 WarningBox aBox( mpBaseWin, WB_OK, sMessage); 563 aBox.Execute(); 564 } 565 else 566 { 567 sTokenLine += String( sDepName, RTL_TEXTENCODING_UTF8 ); 568 sTokenLine +='\t'; 569 nHashedId = pHObject_l->GetId(); 570 pHObject_l = mpPrjIdMapper->Find( rBodyText ); // mpPrjIdMapper 571 nObjectId_l = pHObject_l->GetId(); 572 AddConnectorToObjects( mpObjectPrjList, nHashedId, nObjectId_l ); 573 } 574 } 575 } 576 577 if ( mpPrj->Count() > 1 ) 578 { 579 CommandData* pData = mpPrj->GetObject( mpPrj->Count() - 1 ); 580 pData = mpPrj->Replace( pData, mpPrj->Count() - 2 ); 581 mpPrj->Replace( pData, mpPrj->Count() - 1 ); 582 } 583 584 return nObjectId; 585 } 586 return 0; 587 } 588 589 // Context-Menue 590 IMPL_LINK( Depper, PopupSelected, PopupMenu*, mpPopup ) 591 { 592 sal_uInt16 nItemId = mpPopup->GetCurItemId(); 593 594 switch( nItemId ) 595 { 596 case DEPPOPUP_NEW : 597 { 598 ByteString sNewItem = ByteString("new"); 599 //AddObject( mpObjectList, sNewItem , sal_True ); 600 } 601 break; 602 case DEPPOPUP_AUTOARRANGE : 603 //AutoArrange( mpObjectList, mpObjectList, GetStart(), 0 ); 604 break; 605 case DEPPOPUP_LOAD : 606 //Load( ByteString("test.dep")); 607 break; 608 case DEPPOPUP_SAVE : 609 Save( ByteString("test.dep")); 610 break; 611 case DEPPOPUP_WRITE_SOURCE : 612 WriteSource(); 613 break; 614 case DEPPOPUP_READ_SOURCE : 615 ReadSource(sal_True); 616 break; 617 case DEPPOPUP_OPEN_SOURCE : 618 OpenSource(); 619 break; 620 case DEPPOPUP_ZOOMIN : 621 { 622 // DBG_ASSERT( FALSE,"zoomin"); 623 MapMode aMapMode = GetDepWin()->GetMapMode(); 624 aMapMode.SetScaleX( aMapMode.GetScaleX() * Fraction( 1.25 )); 625 aMapMode.SetScaleY( aMapMode.GetScaleY() * Fraction( 1.25 )); 626 GetDepWin()->SetMapMode( aMapMode ); 627 628 if ( nZoomed < 1 ) 629 { 630 Size aZoomInSize( GetDepWin()->GetSizePixel()); 631 aZoomInSize.Width() *= 1.25; 632 aZoomInSize.Height() *= 1.25; 633 GetDepWin()->SetSizePixel( aZoomInSize ); 634 } 635 nZoomed--; 636 637 Zoom( aMapMode ); 638 }; 639 break; 640 case DEPPOPUP_ZOOMOUT : 641 { 642 // DBG_ASSERT( FALSE,"zoomout"); 643 MapMode aMapMode = GetDepWin()->GetMapMode(); 644 if ( aMapMode.GetScaleX() > Fraction( 0.25 )) 645 { 646 aMapMode.SetScaleX( aMapMode.GetScaleX() * Fraction( 0.8 )); 647 aMapMode.SetScaleY( aMapMode.GetScaleY() * Fraction( 0.8 )); 648 GetDepWin()->SetMapMode( aMapMode ); 649 650 if ( nZoomed < 0 ) 651 { 652 Size aZoomOutSize( mpBaseWin->GetSizePixel()); 653 aZoomOutSize.Width() *= 0.8; 654 aZoomOutSize.Height() *= 0.8; 655 GetDepWin()->SetSizePixel( aZoomOutSize ); 656 } 657 nZoomed++; 658 659 Zoom( aMapMode ); 660 } 661 }; 662 break; 663 case DEPPOPUP_CLEAR : 664 // DBG_ASSERT( FALSE,"clear"); 665 // RemoveAllObjects( mpObjectList ); 666 break; 667 case DEPPOPUP_CLOSE : 668 // DBG_ASSERT( FALSE,"close"); 669 CloseWindow(); 670 break; 671 case DEPPOPUP_HELP : 672 // DBG_ASSERT( FALSE,"help"); 673 ShowHelp(); 674 break; 675 case DEPPOPUP_TEST : 676 // DBG_ASSERT( FALSE,"TEST!"); 677 // test(); 678 break; 679 case DEPPOPUP_SHOW_TOOLBOX: 680 maToolBox.Show(); 681 break; 682 default : 683 DBG_ASSERT( sal_False, "default" ); 684 break; 685 } 686 return 0; 687 } 688