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 //TBD: ToolBox handling prjview/back 28 29 #include <osl/file.hxx> 30 #include <rtl/ustring.hxx> 31 #include <tools/debug.hxx> 32 #include <soldep/sstring.hxx> 33 #include <svtools/filedlg.hxx> 34 #include <tools/iparser.hxx> 35 #include <tools/geninfo.hxx> 36 #include <vcl/gdimtf.hxx> 37 #include <vcl/bitmap.hxx> 38 #include <soldep/appdef.hxx> 39 #include "time.h" 40 #include <soldep/depper.hxx> 41 #include <soldep/soldep.hxx> 42 #include <soldep/soldlg.hxx> 43 #include "dtsodcmp.hrc" 44 45 IMPLEMENT_HASHTABLE_OWNER( SolIdMapper, ByteString, sal_uIntPtr* ); 46 //IMPLEMENT_HASHTABLE_OWNER( PrjIdMapper, ByteString, sal_uIntPtr* ); 47 #define EVENT_RESIZE 0x00000001 48 #define MIN(a,b) (a)<(b)?(a):(b) 49 #define MAX(a,b) (a)>(b)?(a):(b) 50 51 52 //ByteString sDelimiterLine("#=========================================================================="); 53 54 55 // 56 // class SolDep 57 // 58 59 /*****************************************************************************/ 60 SolDep::SolDep( Window* pBaseWindow ) 61 /*****************************************************************************/ 62 : Depper( pBaseWindow ), 63 mbBServer(sal_False), 64 mpTravellerList( NULL ), 65 mbIsHide( sal_False ) 66 { 67 mnSolWinCount = 0; 68 mnSolLastId = 0; 69 // mpPrjIdMapper = new SolIdMapper( 63997 ); 70 maTaskBarFrame.EnableAlwaysOnTop(); 71 maTaskBarFrame.Show(); 72 maToolBox.SetPosSizePixel( Point( 0,0 ), Size( 1100,35 )); 73 maToolBox.SetSelectHdl( LINK ( this, SolDep, ToolSelect )); 74 maToolBox.Show(); 75 76 mpBaseWin->AddChildEventListener( LINK( this, SolDep, ChildWindowEventListener )); 77 78 // Kontext-Menue (geh�rt zu soldep.cxx) 79 InitContextMenueMainWnd(); 80 InitContextMenuePrjViewWnd( mpBasePrjWin ); 81 } 82 83 /*****************************************************************************/ 84 SolDep::~SolDep() 85 /*****************************************************************************/ 86 { 87 mpBaseWin->RemoveChildEventListener( LINK( this, SolDep, ChildWindowEventListener ) ); 88 delete mpSolIdMapper; 89 delete mpStarWriter; 90 delete mpStandLst; 91 } 92 93 /*****************************************************************************/ 94 void SolDep::Init() 95 /*****************************************************************************/ 96 { 97 InformationParser aParser; 98 String sStandLst( GetDefStandList(), RTL_TEXTENCODING_ASCII_US ); 99 mpStandLst = aParser.Execute( sStandLst ); 100 ByteString aUpdater( getenv("UPDATER") ); 101 if ( mpStandLst && (aUpdater == "YES") ) { 102 if ( GetVersion() ) 103 ReadSource( sal_True ); 104 } else 105 { 106 ReadSource(); // if stand.lst isn't available 107 } 108 } 109 110 /*****************************************************************************/ 111 void SolDep::Init( ByteString &rVersion, GenericInformationList *pVersionList ) 112 /*****************************************************************************/ 113 { 114 // Interface for bs 115 mbBServer=sal_True; 116 if ( pVersionList ) 117 mpStandLst = new GenericInformationList( *pVersionList ); 118 else { 119 InformationParser aParser; 120 String sStandLst( GetDefStandList(), RTL_TEXTENCODING_ASCII_US ); 121 mpStandLst = aParser.Execute( sStandLst ); 122 } 123 if ( mpStandLst ) { 124 msVersionMajor = ByteString( rVersion ); 125 ReadSource(sal_True); //call from build server set UPDATER to TRUE 126 } 127 } 128 129 /*****************************************************************************/ 130 IMPL_LINK( SolDep, ChildWindowEventListener, VclSimpleEvent*, pEvent ) 131 /*****************************************************************************/ 132 { 133 if ( pEvent && pEvent->ISA( VclWindowEvent ) ) 134 { 135 ProcessChildWindowEvent( *static_cast< VclWindowEvent* >( pEvent ) ); 136 } 137 return 0; 138 } 139 140 141 /*****************************************************************************/ 142 void SolDep::ProcessChildWindowEvent( const VclWindowEvent& _rVclWindowEvent ) 143 /*****************************************************************************/ 144 { 145 Window* pChildWin = _rVclWindowEvent.GetWindow(); 146 // Window* pParentWin = pChildWin->GetParent(); 147 //Resize(); 148 if ( isAlive() ) 149 { 150 sal_uIntPtr id = _rVclWindowEvent.GetId(); 151 switch ( id ) 152 { 153 case VCLEVENT_USER_MOUSEBUTTON_DOWN: 154 { 155 ObjectWin* pObjWin = dynamic_cast<ObjectWin*>(pChildWin); 156 if( pObjWin ) 157 { 158 // handle mouse click on ObjectWin object 159 ObjectWin* pWin = (ObjectWin*) pChildWin; 160 //GetObjectList()->ResetSelectedObject(); 161 if (IsHideMode()) // simple mouse click left 162 { 163 pWin->CaptureMouse(); 164 pWin->SetMarkMode( MARKMODE_SELECTED ); 165 pWin->MarkNeeded(); 166 pWin->MarkDepending(); 167 pWin->Invalidate(); 168 } else 169 { 170 pWin->LoseFocus(); 171 pWin->SetMarkMode( MARKMODE_SELECTED ); 172 pWin->UnsetMarkMode( MARKMODE_ACTIVATED ); 173 pWin->MarkNeeded( sal_True ); 174 pWin->MarkDepending( sal_True ); 175 } 176 177 } 178 } 179 break; 180 case VCLEVENT_USER_MOUSEBUTTON_DOWN_ALT: 181 { 182 ObjectWin* pObjWin = dynamic_cast<ObjectWin*>(pChildWin); 183 if( pObjWin ) 184 { 185 ObjectWin* pWin = (ObjectWin*) pChildWin; 186 MarkObjects( pWin ); 187 } 188 } 189 break; 190 case VCLEVENT_USER_MOUSEBUTTON_DOWN_DBLCLICK: 191 { 192 ObjectWin* pObjWin = dynamic_cast<ObjectWin*>(pChildWin); 193 if( pObjWin ) 194 { 195 if (IsHideMode()) ToggleHideDependency(); 196 ByteString text = ((ObjectWin*) pChildWin)->GetBodyText(); 197 ViewContent(text); 198 } 199 } 200 break; 201 case VCLEVENT_USER_MOUSEBUTTON_UP_SHFT: 202 { 203 ObjectWin* pObjWin = dynamic_cast<ObjectWin*>(pChildWin); 204 if( pObjWin ) 205 { 206 ObjectWin* pWin = (ObjectWin*) pChildWin; 207 GetDepWin()->NewConnector( pWin ); 208 } 209 } 210 break; 211 case VCLEVENT_USER_MOUSEBUTTON_UP: 212 { 213 ObjectWin* pObjWin = dynamic_cast<ObjectWin*>(pChildWin); 214 if( pObjWin ) 215 { 216 ObjectWin* pWin = (ObjectWin*) pChildWin; 217 pWin->ReleaseMouse(); 218 pWin->SetMarkMode(MARKMODE_SELECTED); 219 GetDepWin()->Invalidate(); 220 } 221 } 222 break; 223 } // switch 224 } // if isAlive 225 //fprintf(stdout,"BLA::Resize: %d\n",pChildWin); 226 } 227 228 /*****************************************************************************/ 229 IMPL_LINK( SolDep, ToolSelect, SoldepToolBox* , pBox) 230 /*****************************************************************************/ 231 { 232 sal_uInt16 nItemId = pBox->GetCurItemId(); 233 switch ( nItemId ) 234 { 235 case TID_SOLDEP_FIND: 236 FindProject(); 237 break; 238 case TID_SOLDEP_CREATEMETA : 239 { 240 VirtualDevice aVDev; 241 aVDev.SetMapMode( MAP_100TH_MM ); 242 GDIMetaFile aMtf; 243 aVDev.EnableOutput( sal_False ); 244 aMtf.Record( &aVDev ); 245 246 aVDev.SetLineColor( Color( COL_BLACK ) ); 247 aVDev.SetTextAlign( ALIGN_TOP ); 248 249 Size aSize( GetDepWin()->GetOutputSizePixel() ); 250 long nXMin = aSize.Width(); 251 long nXMax = 0; 252 long nYMax = 0; 253 long nYMin = aSize.Height(); 254 255 for ( sal_uInt16 i=0; i<mpObjectList->Count(); i++ ) 256 { 257 Point aPoint = mpObjectList->GetObject(i)->GetPosPixel(); 258 Size aSize = mpObjectList->GetObject(i)->GetSizePixel(); 259 nXMin = MIN( aPoint.X(), nXMin ); 260 nXMax = MAX( aPoint.X() + aSize.Width(), nXMax ); 261 nYMin = MIN( aPoint.Y(), nYMin ); 262 nYMax = MAX( aPoint.Y() + aSize.Height(), nYMax ); 263 } 264 265 Point aOffset( nXMin, nYMin ); 266 aOffset = aVDev.PixelToLogic( aOffset ); 267 268 GetDepWin()->DrawOutput( &aVDev, aOffset ); 269 for ( sal_uInt16 i=0; i<mpObjectList->Count(); i++ ) 270 if ( mpObjectList->GetObject(i)->IsVisible() ) 271 mpObjectList->GetObject(i)->DrawOutput( &aVDev, aOffset ); 272 273 aMtf.Stop(); 274 aMtf.WindStart(); 275 aMtf.SetPrefMapMode( aVDev.GetMapMode() ); 276 Size aDevSize( nXMax-nXMin + 10, nYMax-nYMin + 10); 277 aDevSize = aVDev.PixelToLogic( aDevSize ); 278 aMtf.SetPrefSize( aDevSize ); 279 SvFileStream aStream( String::CreateFromAscii("d:\\out.svm"), STREAM_STD_READWRITE ); 280 aMtf.Write( aStream ); 281 break; 282 } 283 case TID_SOLDEP_HIDE_INDEPENDEND: 284 { 285 ToggleHideDependency(); 286 for ( sal_uInt16 i=0; i<mpObjectList->Count(); i++ ) 287 mpObjectList->GetObject(i)->SetViewMask(!mbIsHide); 288 289 maToolBox.CheckItem(TID_SOLDEP_HIDE_INDEPENDEND, IsHideMode()); 290 GetDepWin()->Invalidate(); //repaint Main-View 291 } 292 break; 293 case TID_SOLDEP_SELECT_WORKSPACE: 294 if (mpStandLst) 295 { 296 if (GetVersion()) // Version dialog box 297 { 298 delete mpSolIdMapper; 299 delete mpStarWriter; 300 mpObjectList->ClearAndDelete(); 301 ReadSource(sal_True); 302 } 303 } 304 break; 305 case TID_SOLDEP_BACK: 306 maToolBox.HideItem(TID_SOLDEP_BACK); 307 maToolBox.ShowItem(TID_SOLDEP_SELECT_WORKSPACE); //disabled for prj view (doubleclick ObjWin) 308 maToolBox.ShowItem(TID_SOLDEP_HIDE_INDEPENDEND); //disabled for prj view (doubleclick ObjWin) 309 maToolBox.ShowItem(TID_SOLDEP_FIND); //disabled for prj view (doubleclick ObjWin) 310 maToolBox.Resize(); 311 TogglePrjViewStatus(); 312 break; 313 } 314 return 0; 315 } 316 317 /*****************************************************************************/ 318 void SolDep::ToggleHideDependency() 319 /*****************************************************************************/ 320 { 321 mbIsHide = !mbIsHide; 322 maToolBox.CheckItem(TID_SOLDEP_HIDE_INDEPENDEND, IsHideMode()); 323 ObjectWin* pWin = GetObjectList()->GetObject( 0 ); 324 pWin->ToggleHideMode(); 325 }; 326 327 /*****************************************************************************/ 328 sal_Bool SolDep::GetVersion() 329 /*****************************************************************************/ 330 { 331 SolSelectVersionDlg aVersionDlg( GetDepWin(), mpStandLst ); 332 if ( aVersionDlg.Execute() == RET_OK ) { 333 msVersionMajor = aVersionDlg.GetVersionMajor(); 334 msVersionMinor = aVersionDlg.GetVersionMinor(); 335 return sal_True; 336 } 337 return sal_False; 338 } 339 340 void SolDep::InitContextMenueMainWnd() 341 { 342 InitContextMenuePrjViewWnd( mpBaseWin ); 343 return; // Disable not actually supported items 344 345 mpBaseWin->mpPopup->InsertItem( DEPPOPUP_AUTOARRANGE, String::CreateFromAscii("Autoarrange")) ; 346 mpBaseWin->mpPopup->InsertSeparator(); 347 mpBaseWin->mpPopup->InsertItem( DEPPOPUP_READ_SOURCE, String::CreateFromAscii("Revert all changes") ); 348 mpBaseWin->mpPopup->InsertSeparator(); 349 mpBaseWin->mpPopup->InsertItem( DEPPOPUP_OPEN_SOURCE, String::CreateFromAscii("Open") ); 350 mpBaseWin->mpPopup->InsertItem( DEPPOPUP_WRITE_SOURCE, String::CreateFromAscii("Save") ); 351 } 352 353 void SolDep::InitContextMenuePrjViewWnd(DepWin* pBaseWin ) 354 { 355 // temp. disabled pBaseWin->mpPopup->InsertItem( DEPPOPUP_NEW, String::CreateFromAscii("New object") ); 356 pBaseWin->mpPopup->InsertItem( DEPPOPUP_ZOOMIN, String::CreateFromAscii("Zoom in") ); 357 pBaseWin->mpPopup->InsertItem( DEPPOPUP_ZOOMOUT, String::CreateFromAscii("Zoom out") ); 358 pBaseWin->mpPopup->InsertSeparator(); 359 // temp disabled pBaseWin->mpPopup->InsertItem( DEPPOPUP_CLEAR, String::CreateFromAscii("Clear") ); 360 pBaseWin->mpPopup->InsertItem( DEPPOPUP_SHOW_TOOLBOX, String::CreateFromAscii("Show Toolbox") ); 361 } 362 363 /*****************************************************************************/ 364 ObjectWin *SolDep::RemoveObject( sal_uInt16 nId, sal_Bool bDelete ) 365 /*****************************************************************************/ 366 { 367 Prj* pPrj; 368 369 //hshtable auf stand halten 370 ObjectWin* pWin = RemoveObjectFromList( mpObjectList, mnSolWinCount, nId, sal_False ); 371 if ( pWin ) 372 { 373 ByteString aBodyText( pWin->GetBodyText() ); 374 if( (pPrj = mpStarWriter->GetPrj( aBodyText )) ) 375 { 376 mpStarWriter->Remove( pPrj ); 377 //cleanup ist teuer... 378 mpStarWriter->CleanUp(); 379 delete pPrj; 380 } 381 else 382 DBG_ASSERT( sal_False, "project not found - write" ); 383 384 mpSolIdMapper->Delete( aBodyText ); 385 if ( bDelete ) 386 delete pWin; 387 return pWin; 388 } 389 else 390 return NULL; 391 } 392 393 /*****************************************************************************/ 394 sal_uIntPtr SolDep::AddObject( ByteString& rBodyText, sal_Bool bInteract ) 395 /*****************************************************************************/ 396 { 397 sal_uIntPtr nObjectId; 398 if ( bInteract ) 399 { 400 nObjectId = HandleNewPrjDialog( rBodyText ); 401 } 402 else 403 { 404 //hashtable auf stand halten 405 MyHashObject* pHObject; 406 nObjectId = AddObjectToList( mpBaseWin, mpObjectList, mnSolLastId, mnSolWinCount, rBodyText, sal_False ); 407 pHObject = new MyHashObject( nObjectId, ObjIdToPtr(mpObjectList, nObjectId )); 408 mpSolIdMapper->Insert( rBodyText, pHObject ); 409 } 410 return nObjectId; 411 } 412 413 /*****************************************************************************/ 414 sal_uIntPtr SolDep::AddPrjObject( ByteString& rBodyText, sal_Bool bInteract ) 415 /*****************************************************************************/ 416 { 417 sal_uIntPtr nObjectId; 418 if ( bInteract ) 419 { 420 nObjectId = HandleNewDirectoryDialog( rBodyText ); 421 } 422 else 423 { 424 //hshtable auf stand halten 425 MyHashObject* pHObject; 426 nObjectId = AddObjectToList( mpBasePrjWin, mpObjectPrjList, mnPrjLastId, mnPrjWinCount, rBodyText ); 427 pHObject = new MyHashObject( nObjectId, ObjIdToPtr( mpObjectPrjList, nObjectId )); 428 mpPrjIdMapper->Insert( rBodyText, pHObject ); // mpPrjIdMapper 429 } 430 return nObjectId; 431 } 432 433 /*****************************************************************************/ 434 sal_uInt16 SolDep::AddConnector( ObjectWin* pStartWin, ObjectWin* pEndWin ) 435 /*****************************************************************************/ 436 { 437 // DBG_ASSERT( FALSE , "not yet" ); 438 ByteString sEndName = pEndWin->GetBodyText(); 439 ByteString sStartName = pStartWin->GetBodyText(); 440 441 Prj* pPrj = mpStarWriter->GetPrj( sEndName ); 442 if ( pPrj ) 443 { 444 pPrj->AddDependencies( sStartName ); 445 return AddConnectorToObjects( pStartWin, pEndWin ); 446 } 447 else 448 { 449 DBG_ASSERT( sal_False , "non existing Project" ); 450 return 1; 451 } 452 } 453 454 /*****************************************************************************/ 455 sal_uInt16 SolDep::RemoveConnector( ObjectWin* pStartWin, ObjectWin* pEndWin ) 456 /*****************************************************************************/ 457 { 458 SByteStringList* pPrjDeps = NULL; 459 ByteString sEndName = pEndWin->GetBodyText(); 460 ByteString sStartName = pStartWin->GetBodyText(); 461 462 Prj* pPrj = mpStarWriter->GetPrj( sEndName ); 463 pPrjDeps = pPrj->GetDependencies( sal_False ); 464 if ( pPrjDeps ) 465 { 466 ByteString* pString; 467 sal_uIntPtr nPrjDepsCount = pPrjDeps->Count(); 468 for ( sal_uIntPtr j = nPrjDepsCount; j > 0; j-- ) 469 { 470 pString = pPrjDeps->GetObject( j - 1 ); 471 if ( pString->GetToken( 0, '.') == sStartName ) 472 pPrjDeps->Remove( pString ); 473 } 474 } 475 476 return RemoveConnectorFromObjects( pStartWin, pEndWin ); 477 } 478 479 /*****************************************************************************/ 480 void SolDep::RemoveAllObjects( ObjectList* pObjLst ) 481 /*****************************************************************************/ 482 { 483 484 Depper::RemoveAllObjects( pObjLst ); 485 486 if ( mpSolIdMapper ) 487 { 488 delete mpSolIdMapper; 489 mpSolIdMapper = NULL; 490 } 491 if ( mpStarWriter ) 492 { 493 delete mpStarWriter; 494 mpStarWriter = NULL; 495 } 496 } 497 498 /*****************************************************************************/ 499 sal_uIntPtr SolDep::GetStart(SolIdMapper* pIdMapper, ObjectList* pObjList) 500 /*****************************************************************************/ 501 { 502 // DBG_ASSERT( FALSE , "soldep" ); 503 MyHashObject* pHObject = pIdMapper->Find( "null" );//null_project 504 505 if ( !pHObject ) { 506 ByteString sNullPrj = "null";//null_project 507 sal_uIntPtr nObjectId = AddObject( sNullPrj, sal_False ); 508 ObjIdToPtr( pObjList, nObjectId )->SetViewMask( 1 ); 509 return nObjectId; 510 } 511 512 return pHObject->GetId(); 513 } 514 515 /*****************************************************************************/ 516 sal_uIntPtr SolDep::GetStartPrj(SolIdMapper* , ObjectList* ) 517 /*****************************************************************************/ 518 { 519 // DBG_ASSERT( FALSE , "prjdep" ); 520 MyHashObject* pHObject = mpPrjIdMapper->Find( ByteString( "null" ) ); //null_dir 521 if ( !pHObject ) 522 { 523 ByteString bsNull("null"); 524 sal_uIntPtr nObjectId = AddPrjObject( bsNull, sal_False); //null_dir 525 return nObjectId; 526 } 527 else 528 return pHObject->GetId(); 529 } 530 531 /*****************************************************************************/ 532 sal_uInt16 SolDep::OpenSource() 533 /*****************************************************************************/ 534 { 535 if ( mpStandLst ) { 536 if ( GetVersion()) 537 return ReadSource(); 538 } 539 return 0; 540 } 541 542 /*****************************************************************************/ 543 sal_uInt16 SolDep::ReadSource(sal_Bool bUpdater) 544 /*****************************************************************************/ 545 { 546 mpBaseWin->EnablePaint( sal_False ); 547 mpBaseWin->Hide(); 548 sal_uIntPtr nObjectId, nHashedId; 549 sal_uIntPtr i; 550 MyHashObject* pHObject; 551 ByteString* pStr; 552 ObjectWin *pStartWin, *pEndWin; 553 554 mpSolIdMapper = new SolIdMapper( 63997 ); 555 if (mpStandLst && bUpdater) 556 { 557 mpStarWriter = new StarWriter( mpStandLst, msVersionMajor, msVersionMinor, sal_True ); 558 } else 559 { 560 SolarFileList* pSolarFileList; 561 pSolarFileList = GetPrjListFromDir(); 562 mpStarWriter = new StarWriter( pSolarFileList, sal_True ); 563 } 564 ByteString sTitle( SOLDEPL_NAME ); 565 if ( mpStarWriter->GetMode() == STAR_MODE_SINGLE_PARSE ) { 566 sTitle += ByteString( " - mode: single file [" ); 567 sTitle += (ByteString) mpStarWriter->GetName(); 568 sTitle += ByteString( "]" ); 569 } 570 else if ( mpStarWriter->GetMode() == STAR_MODE_MULTIPLE_PARSE ) { 571 sTitle += ByteString( " - mode: multiple files [" ); 572 sTitle += ByteString( "]" ); 573 } 574 SetTitle( String( sTitle, RTL_TEXTENCODING_UTF8) ); 575 576 sal_uIntPtr nCount = mpStarWriter->Count(); 577 for ( i=0; i<nCount; i++ ) 578 { 579 Prj *pPrj = mpStarWriter->GetObject(i); 580 ByteString sPrjName = pPrj->GetProjectName(); 581 nObjectId = AddObject( sPrjName, sal_False ); 582 ObjIdToPtr( mpObjectList, nObjectId )->SetViewMask( 1 ); 583 } 584 for ( i=0; i<nCount; i++ ) 585 { 586 Prj *pPrj = mpStarWriter->GetObject(i); 587 SByteStringList *pLst = pPrj->GetDependencies( sal_False ); 588 if ( pLst ) 589 { 590 sal_uIntPtr nDepCount = pLst->Count(); 591 for ( sal_uIntPtr m=0; m<nDepCount; m++) 592 { 593 pStr = pLst->GetObject(m); 594 pHObject = mpSolIdMapper->Find( *pStr ); 595 /*if ( !pHObject ) 596 { 597 // create new prj 598 Prj *pNewPrj = new Prj( *pStr ); 599 ByteString sPrjName = pNewPrj->GetProjectName(); 600 nObjectId = AddObject( sPrjName, sal_False ); 601 pHObject = mpSolIdMapper->Find( *pStr ); 602 ObjIdToPtr( mpObjectList, nObjectId )->SetViewMask( 2 ); 603 }*/ 604 605 if ( pHObject ) 606 { 607 nHashedId = pHObject->GetId(); 608 ByteString sF_Os2 = pPrj->GetProjectName(); 609 pStr = &sF_Os2; 610 pHObject = mpSolIdMapper->Find( *pStr ); 611 nObjectId = pHObject->GetId(); 612 pStartWin = ObjIdToPtr( mpObjectList, nHashedId ); 613 pEndWin = ObjIdToPtr( mpObjectList, nObjectId ); 614 AddConnectorToObjects( pStartWin, pEndWin ); 615 } 616 } 617 } 618 } 619 if (!IsPrjView()) 620 { 621 AutoArrange( mpSolIdMapper, mpObjectList, GetStart(mpSolIdMapper,mpObjectList), 0, GetStart(mpSolIdMapper,mpObjectList) ); 622 GetDepWin()->EnablePaint( sal_True ); 623 } 624 return 0; 625 } 626 627 SolarFileList* SolDep::GetPrjListFromDir() 628 { 629 SolarFileList* pSolarFileList = new SolarFileList(); 630 String sPrjDir( String::CreateFromAscii( "prj" )); 631 String sBuildLst( String::CreateFromAscii( "build.lst" )); 632 DirEntry aCurrent( getenv( SOURCEROOT ) ); 633 634 aCurrent.ToAbs(); 635 Dir aDir( aCurrent, FSYS_KIND_DIR ); 636 637 sal_uInt16 nEntries = aDir.Count(); 638 if( nEntries ) 639 { 640 UniStringList aSortDirList; 641 for ( sal_uInt16 n = 0; n < nEntries; n++ ) 642 { 643 DirEntry& rEntry = aDir[n]; 644 UniString aName( rEntry.GetName() ); 645 if( aName.Len() && ( aName.GetChar(0) != '.' ) && rEntry.Exists() ) 646 { 647 rEntry += DirEntry( sPrjDir ); 648 rEntry += DirEntry( sBuildLst ); 649 if (rEntry.Exists()) 650 { 651 pSolarFileList->Insert( new String( rEntry.GetFull() ), LIST_APPEND ); 652 ByteString aName_dbg(rEntry.GetFull(),RTL_TEXTENCODING_UTF8); 653 fprintf(stdout, "bla:%s\n", aName_dbg.GetBuffer()); 654 } 655 } 656 } 657 } 658 if ( !pSolarFileList->Count() ) 659 { 660 //is empty!! TBD 661 delete pSolarFileList; 662 return NULL; 663 } 664 return pSolarFileList; 665 } 666 667 /*****************************************************************************/ 668 sal_uInt16 SolDep::WriteSource() 669 /*****************************************************************************/ 670 { 671 /* zur Sicherheit deaktiviert 672 sal_uInt16 nMode = mpStarWriter->GetMode(); 673 if ( nMode == STAR_MODE_SINGLE_PARSE ) { 674 ByteString sFileName = mpStarWriter->GetName(); 675 if ( sFileName.Len()) { 676 mpStarWriter->Write( String( sFileName, RTL_TEXTENCODING_UTF8) ); 677 mpStarWriter->RemoveProject( ByteString( "null")); //null_project 678 } 679 } 680 else if ( nMode == STAR_MODE_MULTIPLE_PARSE ) { 681 // *OBO* 682 //String sRoot = mpStarWriter->GetSourceRoot(); 683 //nicht mehr unterst�tzt mpStarWriter->GetSourceRoot() 684 ByteString sFileName = mpStarWriter->GetName(); 685 DirEntry aEntry( sFileName ); 686 aEntry.ToAbs(); 687 aEntry = aEntry.GetPath().GetPath().GetPath(); 688 String sRoot = aEntry.GetFull(); 689 690 if ( sRoot.Len()) { 691 mpStarWriter->RemoveProject( ByteString( "null")); //null_project 692 mpStarWriter->WriteMultiple( sRoot ); 693 } 694 } 695 */ 696 return 1; 697 } 698 699 sal_uInt16 SolDep::Load( const ByteString& rFileName ) 700 { 701 // moved from depper class 702 DBG_ASSERT( sal_False , "you are dead!" ); 703 SvFileStream aInFile( String( rFileName, RTL_TEXTENCODING_UTF8 ), STREAM_READ ); 704 depper_head dh; 705 sal_uIntPtr i; 706 sal_uIntPtr nLoadOffs = mnSolLastId; //or Prj?? 707 ObjectWin* pNewWin; 708 aInFile.Read( &dh, sizeof( dh )); 709 710 sal_uIntPtr nObjCount = dh.nObjectCount; 711 sal_uIntPtr nCnctrCount = dh.nCnctrCount; 712 713 for ( i=0; i < nObjCount ; i++ ) 714 { 715 ObjectWin* pWin = new ObjectWin( mpBaseWin, WB_BORDER ); 716 pWin->Load( aInFile ); 717 pNewWin = ObjIdToPtr( mpObjectList, AddObjectToList( mpBaseWin, mpObjectList, mnSolLastId, mnSolWinCount, pWin->GetBodyText(), sal_False )); 718 pNewWin->SetId( nLoadOffs + pWin->GetId()); 719 pNewWin->SetPosPixel( pWin->GetPosPixel()); 720 pNewWin->SetSizePixel( pWin->GetSizePixel()); 721 } 722 723 sal_uIntPtr nStartId; 724 sal_uIntPtr nEndId; 725 // ueber addconnector fuehren! 726 for ( i=0; i < nCnctrCount ; i++ ) 727 { 728 Connector* pCon = new Connector( mpBaseWin, WB_NOBORDER ); 729 pCon->Load( aInFile ); 730 731 nStartId = nLoadOffs + pCon->GetStartId(); 732 nEndId = nLoadOffs + pCon->GetEndId(); 733 734 ObjectWin* pStartWin = ObjIdToPtr( mpObjectList, nStartId ); 735 ObjectWin* pEndWin = ObjIdToPtr( mpObjectList, nEndId ); 736 737 pCon->Initialize( pStartWin, pEndWin ); 738 } 739 740 741 return 0; 742 } 743 744 /*****************************************************************************/ 745 sal_Bool SolDep::ViewContent( ByteString& rObjectName ) 746 /*****************************************************************************/ 747 { 748 mpFocusWin = NULL; 749 SetPrjViewStatus(sal_True); 750 751 for ( sal_uIntPtr i = 0; i < mpObjectList->Count() && !mpFocusWin; i++ ) 752 if ( mpObjectList->GetObject( i )->HasFocus()) 753 mpFocusWin = mpObjectList->GetObject( i ); 754 //HideObjectsAndConnections( mpObjectList ); 755 mpProcessWin->Resize(); 756 GetDepWin()->Show(); 757 return InitPrj( rObjectName ); 758 } 759 760 /*****************************************************************************/ 761 sal_Bool SolDep::InitPrj( ByteString& rListName ) 762 /*****************************************************************************/ 763 { 764 sal_uIntPtr nObjectId, nHashedId; 765 sal_uIntPtr i, j; 766 MyHashObject* pHObject; 767 ByteString *pDepName; 768 ByteString *pFlagName; 769 Prj* pPrj; 770 ObjectWin *pStartWin, *pEndWin; 771 maToolBox.HideItem(TID_SOLDEP_SELECT_WORKSPACE); 772 maToolBox.HideItem(TID_SOLDEP_HIDE_INDEPENDEND); 773 maToolBox.HideItem(TID_SOLDEP_FIND); 774 maToolBox.ShowItem(TID_SOLDEP_BACK); 775 maToolBox.Invalidate(); 776 777 //clean up 778 mpObjectPrjList->ClearAndDelete(); 779 GetDepWin()->ClearConnectorList(); 780 if (mpPrjIdMapper) delete mpPrjIdMapper; 781 mpPrjIdMapper = new SolIdMapper( 63997 ); //generate clean mapper 782 mnPrjWinCount = 0; 783 mnPrjLastId = 0; 784 785 sal_uIntPtr nCount = mpStarWriter->Count(); 786 GetDepWin()->EnablePaint( sal_False ); 787 Point aPnt = GetGraphWin()->GetPosPixel(); 788 Size aSize = GetGraphWin()->GetSizePixel(); 789 790 GetGraphWin()->SetPosSizePixel( aPnt, aSize ); // Hier wird das Window gesetzt 791 792 sal_Bool bReturn = sal_False; 793 794 for ( i=0; i<nCount; i++ ) 795 { 796 // pPrj->GetProjectName() returns the name of 797 // the project e.g. svtools 798 pPrj = mpStarWriter->GetObject(i); 799 ByteString sPrjName = pPrj->GetProjectName(); 800 if ( sPrjName == rListName ) 801 { 802 bReturn = sal_True; 803 804 mpPrj = mpStarWriter->GetObject(i); 805 sal_uIntPtr nDirCount = mpPrj->Count(); 806 for ( j=0; j<nDirCount; j++ ) 807 { 808 CommandData *pData = mpPrj->GetObject(j); 809 fprintf( stdout, "\tProjectDir : %s\n", 810 pData->GetLogFile().GetBuffer()); 811 // pData->GetLogFile() contains internal project IDs 812 // e.g. st_mkout etc. 813 if ( pData->GetLogFile() != "" ) 814 { 815 ByteString sItem = pData->GetLogFile(); 816 nObjectId = AddPrjObject( sItem, sal_False); 817 // there may be faster ways...... 818 ObjectWin *pWin = ObjIdToPtr( mpObjectPrjList, nObjectId ); 819 pWin->SetViewMask( 0x0001 ); 820 // pData->GetPath() contains internal project directories 821 // e.g. svtools/inc etc. 822 ByteString sPath = pData->GetPath(); 823 pWin->SetTipText( sPath ); 824 } 825 } 826 827 // set connectors for dependencies here 828 for ( j=0; j<nDirCount; j++ ) 829 { 830 CommandData *pData = mpPrj->GetObject(j); 831 SByteStringList *pDeps = pData->GetDependencies(); 832 if ( pDeps ) 833 { 834 ByteString sFlagName = pData->GetLogFile(); 835 pFlagName = &sFlagName; 836 //pHObject = mpPrjIdMapper->Find( (*pFlagName).GetToken( 0, '.'));//mpSolIdMapper see ReadSource() 837 pHObject = mpPrjIdMapper->Find( sFlagName.GetToken( 0, '.')); 838 if (pHObject) 839 { 840 841 nObjectId = pHObject->GetId(); 842 843 sal_uIntPtr nDepCount = pDeps->Count(); 844 for ( sal_uIntPtr k=0; k<nDepCount; k++ ) 845 { 846 pDepName = pDeps->GetObject(k); 847 pHObject = mpPrjIdMapper->Find( (*pDepName).GetToken( 0, '.')); 848 if (pHObject ) 849 { 850 nHashedId = pHObject->GetId(); 851 pStartWin = ObjIdToPtr( mpObjectPrjList, nHashedId ); 852 pEndWin = ObjIdToPtr( mpObjectPrjList, nObjectId ); 853 854 AddConnectorToObjects( pStartWin, pEndWin ); 855 } 856 else 857 { 858 String sMessage; 859 sMessage += String::CreateFromAscii("can't find "); 860 sMessage += String( *pDepName, RTL_TEXTENCODING_UTF8 ); 861 sMessage += String::CreateFromAscii(".\ndependency ignored"); 862 WarningBox aBox( GetDepWin(), WB_OK, sMessage); 863 aBox.Execute(); 864 } 865 } 866 } 867 } 868 869 } 870 871 break; 872 } 873 } 874 ByteString sNullDir = "null"; 875 nObjectId = AddPrjObject( sNullDir, sal_False); 876 ObjectWin *pWin = ObjIdToPtr( mpObjectPrjList, nObjectId ); 877 pWin->SetViewMask( 0x0001 ); 878 mpGraphPrjWin->EnablePaint( sal_True ); 879 //debug 880 // int test_l = GetStartPrj(mpPrjIdMapper, mpObjectPrjList); 881 // ObjectWin *pTestWin = ObjIdToPtr( mpObjectPrjList, test_l ); 882 AutoArrange( mpPrjIdMapper, mpObjectPrjList, GetStartPrj(mpPrjIdMapper, mpObjectPrjList), 0, GetStartPrj(mpPrjIdMapper, mpObjectPrjList) ); 883 mpGraphWin->Hide(); 884 mpGraphPrjWin->Show(); 885 mpGraphPrjWin->Invalidate(); 886 887 return bReturn; 888 } 889 890 /*****************************************************************************/ 891 sal_uInt16 SolDep::CloseWindow() 892 /*****************************************************************************/ 893 { 894 895 ((SystemWindow*)mpProcessWin)->Close(); 896 return 0; 897 } 898 899 /*****************************************************************************/ 900 void SolDep::ShowHelp() 901 /*****************************************************************************/ 902 { 903 SvFileStream aHelpFile( String::CreateFromAscii( "g:\\soldep.hlp" ), STREAM_READ ); 904 String aHelpText; 905 ByteString aGetStr; 906 907 if ( aHelpFile.IsOpen() ) 908 { 909 while ( aHelpFile.ReadLine( aGetStr ) ) 910 { 911 aHelpText += String (aGetStr, RTL_TEXTENCODING_UTF8); 912 aHelpText += String::CreateFromAscii("\n"); 913 } 914 } 915 else 916 aHelpText = String::CreateFromAscii("No Helpfile found."); 917 918 SolHelpDlg aHelpDlg( mpBaseWin, DtSodResId( RID_SD_DIALOG_HELP )); 919 aHelpDlg.maMLEHelp.SetText( aHelpText ); 920 aHelpDlg.maMLEHelp.SetReadOnly(); 921 aHelpDlg.maMLEHelp.EnableFocusSelectionHide( sal_True ); 922 aHelpDlg.Execute(); 923 } 924 925 /*****************************************************************************/ 926 sal_Bool SolDep::FindProject() 927 /*****************************************************************************/ 928 { 929 SolFindProjectDlg aFindProjectDlg( GetDepWin(), GetObjectList() ); 930 ObjectWin* pObjectWin = NULL; 931 mpObjectList->ResetSelectedObject(); 932 if (IsHideMode()) 933 { 934 GetDepWin()->Invalidate(); 935 } 936 937 mpFocusWin=NULL; 938 939 if ( aFindProjectDlg.Execute() == RET_OK ) { 940 msProject = aFindProjectDlg.GetProject(); 941 //now we have a project string 942 943 pObjectWin = mpObjectList->GetPtrByName( msProject ); 944 if (pObjectWin) 945 { 946 mpObjectList->ResetSelectedObject(); 947 MarkObjects( pObjectWin ); 948 } 949 else 950 { 951 mpObjectList->ResetSelectedObject(); 952 for ( sal_uInt16 i=0; i<mpObjectList->Count(); i++ ) 953 { 954 ObjectWin* pObjectWin = mpObjectList->GetObject( i ); 955 if ( !pObjectWin->IsTop() ) 956 pObjectWin->SetViewMask(sal_False); 957 } 958 } 959 } 960 return sal_False; 961 } 962 963 sal_Bool SolDep::MarkObjects( ObjectWin* pObjectWin ) 964 { 965 if (pObjectWin) 966 { 967 if (!(pObjectWin->IsNullObject())) 968 { 969 pObjectWin->SetMarkMode( MARKMODE_SELECTED ); 970 pObjectWin->MarkNeeded(); 971 pObjectWin->MarkDepending(); 972 if (IsHideMode()) 973 { 974 GetDepWin()->Invalidate(); 975 } 976 } else 977 { 978 fprintf(stdout,"null\n"); 979 } 980 } 981 return sal_True; 982 } 983 984 void SolDep::Resize() 985 { 986 //funzt! mu� aber von der applikation aufgerufen werden. 987 Point aOutPos = Point( 0, 0 ); 988 Size aOutSize = mpProcessWin->GetOutputSizePixel(); 989 // calculate output size 990 sal_uIntPtr nTaskHeight = maToolBox.CalcWindowSizePixel().Height(); 991 sal_uIntPtr nTaskWidth = maToolBox.CalcWindowSizePixel().Width(); 992 Size aSize( aOutSize.Width(), nTaskHeight ); 993 994 // sal_uIntPtr nMenuHeight = 0; 995 Point aGraphWinPos = Point(0,0); 996 Size aGraphWinSize = Size(0,0); 997 998 //wei� nicht wie: nMenuHeight = aMenuBar.GetWindow()->GetSizePixel().Height(); //H�he des Menues 999 1000 //aInRect = pTBManager->Resize( Rectangle( aOutPos, aOutSize ); 1001 // Set Docking-Rectangle for ToolBar 1002 Rectangle aInRect; 1003 1004 if (( !maToolBox.IsFloatingMode() ) && ( maToolBox.GetAlign() == WINDOWALIGN_TOP )) 1005 { 1006 // waagerechte Toolbar oben 1007 maToolBox.SetPosSizePixel( aOutPos, Size( aOutSize.Width(), maToolBox.CalcWindowSizePixel().Height())); 1008 if( maToolBox.IsVisible()) 1009 { 1010 Point aOutPosTmp; 1011 Size aOutSizeTmp; 1012 aOutPosTmp = Point( aOutPos.X(), aOutPos.Y() + maToolBox.CalcWindowSizePixel().Height()); 1013 aOutSizeTmp = Size( aOutSize.Width(), aOutSize.Height() - maToolBox.CalcWindowSizePixel().Height()); 1014 aInRect = Rectangle( aOutPosTmp, aOutSizeTmp ); 1015 aGraphWinPos = Point( 0, nTaskHeight ); 1016 aGraphWinSize = Size( aOutSize.Width(), aOutSize.Height() - nTaskHeight); 1017 } 1018 } 1019 if (( !maToolBox.IsFloatingMode() ) && ( maToolBox.GetAlign() == WINDOWALIGN_BOTTOM )) 1020 { 1021 // waagerechte Toolbar unten 1022 Point aTbPos = Point( aOutPos.X(), aOutPos.Y() + aOutSize.Height() - maToolBox.CalcWindowSizePixel().Height()); 1023 Size aTbSize = Size( aOutSize.Width(), maToolBox.CalcWindowSizePixel().Height()); 1024 maToolBox.SetPosSizePixel( aTbPos, aTbSize ); 1025 if( maToolBox.IsVisible()) 1026 { 1027 Point aOutPosTmp; 1028 Size aOutSizeTmp; 1029 aOutPosTmp = Point( aOutPos.X(), aOutPos.Y() + maToolBox.CalcWindowSizePixel().Height()); 1030 aOutSizeTmp = Size( aOutSize.Width(), aOutSize.Height() - maToolBox.CalcWindowSizePixel().Height()); 1031 aInRect = Rectangle( aOutPosTmp, aOutSizeTmp ); 1032 aGraphWinPos = Point( 0, 0 ); 1033 aGraphWinSize = Size( aOutSize.Width(), aOutSize.Height() - nTaskHeight); 1034 } 1035 } 1036 if (( !maToolBox.IsFloatingMode() ) && ( maToolBox.GetAlign() == WINDOWALIGN_LEFT )) 1037 { 1038 // senkrechte ToolBar links 1039 maToolBox.SetPosSizePixel( aOutPos, Size( maToolBox.CalcWindowSizePixel().Width(), aOutSize.Height())); 1040 if( maToolBox.IsVisible()) 1041 { 1042 Point aOutPosTmp; 1043 Size aOutSizeTmp; 1044 aOutPosTmp = Point( aOutPos.X() + maToolBox.CalcWindowSizePixel().Width(), aOutPos.Y()); 1045 aOutSizeTmp = Size( aOutSize.Width()- maToolBox.CalcWindowSizePixel().Width(), aOutSize.Height()); 1046 aInRect = Rectangle( aOutPosTmp, aOutSizeTmp ); 1047 aGraphWinPos = Point( nTaskWidth, 0 ); 1048 aGraphWinSize = Size( aOutSize.Width() - nTaskWidth, aOutSize.Height()); 1049 } 1050 } 1051 if (( !maToolBox.IsFloatingMode() ) && ( maToolBox.GetAlign() == WINDOWALIGN_RIGHT )) 1052 { 1053 // senkrechte ToolBar rechts 1054 Point aTbPos = Point( aOutPos.X() + aOutSize.Width() - maToolBox.CalcWindowSizePixel().Width(), aOutPos.Y()); 1055 Size aTbSize= Size( maToolBox.CalcWindowSizePixel().Width(), aOutSize.Height()); 1056 maToolBox.SetPosSizePixel( aTbPos, aTbSize); 1057 if( maToolBox.IsVisible()) 1058 { 1059 Point aOutPosTmp; 1060 Size aOutSizeTmp; 1061 aOutPosTmp = Point( aOutPos.X() + maToolBox.CalcWindowSizePixel().Width(), aOutPos.Y()); 1062 aOutSizeTmp = Size( aOutSize.Width()- maToolBox.CalcWindowSizePixel().Width(), aOutSize.Height()); 1063 aInRect = Rectangle( aOutPosTmp, aOutSizeTmp ); 1064 aGraphWinPos = Point( 0, 0 ); 1065 aGraphWinSize = Size( aOutSize.Width() - nTaskWidth, aOutSize.Height()); 1066 } 1067 } 1068 1069 Rectangle rout = Rectangle( Point( 0,0 ), aOutSize ); //OutputToScreenPixel( aOutPos ) 1070 Rectangle rin = Rectangle( Point( 0,0 ),//OutputToScreenPixel( Point( aOutPos.X() - 20, aInRect.Top()) 1071 Size( aOutSize.Width(), aOutSize.Height())); 1072 /* 1073 Rectangle rout = mpProcessWin->OutputToScreenPixel( aOutPos ); 1074 Rectangle rin = Rectangle( Point( 0,0 ),//OutputToScreenPixel( Point( aOutPos.X() - 20, aInRect.Top()) 1075 Size( aOutSize.Width(), aOutSize.Height())); 1076 */ 1077 maToolBox.SetDockingRects( rout, rin ); 1078 1079 sal_Bool bFloating = maToolBox.IsFloatingMode(); 1080 1081 if ( bFloating ) 1082 { 1083 GetGraphWin()->SetPosSizePixel(Point(0,0),aOutSize); 1084 //if (IsPrjView() && (mpPrjDep)) mpPrjDep->Resize(); 1085 if (maToolBox.IsVisible()) maToolBox.Show(); 1086 } else 1087 { 1088 GetGraphWin()->SetPosSizePixel( aGraphWinPos, aGraphWinSize ); 1089 } 1090 if (maToolBox.IsVisible()) maToolBox.Show(); 1091 } 1092 1093 sal_uInt16 SolDep::AddConnectorPrjView( ObjectWin* pStartWin, ObjectWin* pEndWin ) 1094 { 1095 // DBG_ASSERT( FALSE , "not yet" ); 1096 ByteString sEndName = pEndWin->GetBodyText(); 1097 ByteString sStartName = pStartWin->GetBodyText(); 1098 if ( sStartName != ByteString("null")) 1099 { 1100 CommandData* pEndData = mpPrj->GetDirectoryData( sEndName ); 1101 SByteStringList* pDeps = pEndData->GetDependencies(); 1102 if ( pDeps ) 1103 pDeps->PutString( &sStartName ); 1104 else 1105 { 1106 pDeps = new SByteStringList(); 1107 pEndData->SetDependencies( pDeps ); 1108 pDeps->PutString( &sStartName ); 1109 pEndData->GetDependencies(); 1110 } 1111 } 1112 return AddConnectorToObjects( pStartWin, pEndWin ); 1113 } 1114 1115 sal_uInt16 SolDep::RemoveConnectorPrjView( ObjectWin* pStartWin, ObjectWin* pEndWin ) 1116 { 1117 ByteString sEndName = pEndWin->GetBodyText(); 1118 ByteString sStartName = pStartWin->GetBodyText(); 1119 CommandData* pEndData = mpPrj->GetDirectoryData( sEndName ); 1120 SByteStringList* pDeps = pEndData->GetDependencies(); 1121 if ( pDeps ) 1122 { 1123 ByteString* pString; 1124 sal_uIntPtr nDepsCount = pDeps->Count(); 1125 for ( sal_uIntPtr j = nDepsCount; j > 0; j-- ) 1126 { 1127 pString = pDeps->GetObject( j - 1 ); 1128 if ( pString->GetToken( 0, '.') == sStartName ) 1129 pDeps->Remove( pString ); 1130 } 1131 } 1132 return RemoveConnectorFromObjects( pStartWin, pEndWin ); 1133 } 1134 1135 sal_uInt16 SolDep::AutoArrange( SolIdMapper* pIdMapper, ObjectList* pObjLst, sal_uIntPtr nTopId, sal_uIntPtr nBottmId, sal_uIntPtr aObjID ) 1136 { 1137 AutoArrangeDlgStart(); 1138 OptimizePos(pIdMapper, pObjLst, nTopId, nBottmId, aObjID ); 1139 AutoArrangeDlgStop(); 1140 return 0; 1141 } 1142 1143 Point SolDep::CalcPos( sal_uInt16 nSet, sal_uInt16 nIndex ) 1144 { 1145 int nRowIndex = nIndex / DEPPER_MAX_WIDTH; 1146 sal_uIntPtr nPosX = mnXOffset + nRowIndex % 3 * GetDefSize().Width() / 3 + ( nIndex - ( DEPPER_MAX_WIDTH * nRowIndex )) * (GetDefSize().Width() + OBJWIN_X_SPACING ); 1147 1148 sal_uIntPtr nPosY = ( nSet + mnLevelOffset + nRowIndex ) * ( GetDefSize().Height() + OBJWIN_Y_SPACING ) + OBJWIN_Y_SPACING; 1149 Point aPos( nPosX, nPosY ); 1150 return aPos; 1151 } 1152 1153 sal_uIntPtr SolDep::CalcXOffset( sal_uIntPtr nObjectsToFit ) 1154 { 1155 long nDynXOffs; 1156 long nXMiddle; 1157 sal_uIntPtr nTrigger; 1158 1159 nXMiddle = GetDepWin()->PixelToLogic( GetDepWin()->GetSizePixel()).Width() / 2; 1160 if ( nObjectsToFit > DEPPER_MAX_WIDTH ) 1161 nObjectsToFit = DEPPER_MAX_WIDTH - 1 + DEPPER_MAX_WIDTH % 2; 1162 nTrigger = ( nObjectsToFit - 1 ) / 2; 1163 nDynXOffs = ( GetDefSize().Width() + OBJWIN_X_SPACING ) * nTrigger; 1164 sal_uIntPtr nXOffs = nXMiddle - nDynXOffs; 1165 1166 if ( sal_uIntPtr(nXMiddle - nDynXOffs) < mnMinDynXOffs ) 1167 mnMinDynXOffs = nXMiddle - nDynXOffs; 1168 1169 return nXOffs; 1170 1171 } 1172 1173 double SolDep::CalcDistSum( ObjWinList* pObjList, DistType eDistType ) 1174 { 1175 ObjectWin* pWin; 1176 Connector* pCon; 1177 sal_uIntPtr nObjCount = pObjList->Count(); 1178 double dRetVal = 0; 1179 double dWinVal; 1180 sal_uInt16 i, j; 1181 sal_Bool bIsStart; 1182 1183 for ( i = 0; i < nObjCount; i++ ) 1184 { 1185 pWin = pObjList->GetObject( i ); 1186 1187 if ( pWin && pWin->IsVisible()) 1188 { 1189 j = 0; 1190 dWinVal = 0; 1191 while ( (pCon = pWin->GetConnector( j )) ) 1192 { 1193 if ( pCon->IsVisible()) { 1194 bIsStart = pCon->IsStart( pWin ); 1195 if ( eDistType != BOTH ) 1196 if ( eDistType == TOPDOWN ) 1197 { 1198 if ( bIsStart ) 1199 { 1200 pCon->UpdatePosition( pWin, sal_False ); 1201 dWinVal += pCon->GetLen() * pWin->mnHeadDist; 1202 } 1203 } 1204 else 1205 { 1206 if ( !bIsStart ) 1207 { 1208 pCon->UpdatePosition( pWin, sal_False ); 1209 dWinVal += pCon->GetLen() * pWin->mnRootDist; 1210 } 1211 1212 } 1213 else 1214 { 1215 pCon->UpdatePosition( pWin, sal_False ); 1216 if ( !bIsStart ) 1217 dWinVal += pCon->GetLen() * ( pWin->mnHeadDist + 1 ); 1218 else 1219 dWinVal += pCon->GetLen() * pWin->mnRootDist; 1220 } 1221 } 1222 j++; 1223 } 1224 // if ( j != 0 ) 1225 // dWinVal /= j; 1226 dRetVal += dWinVal; 1227 } 1228 } 1229 1230 return dRetVal; 1231 } 1232 1233 sal_uInt16 SolDep::Impl_Traveller( ObjectWin* pWin, sal_uInt16 nDepth ) 1234 { 1235 sal_uInt16 i = 0; 1236 ObjectWin* pNewWin; 1237 Connector* pCon; 1238 1239 nDepth++; 1240 1241 sal_uInt16 nMaxDepth = nDepth; 1242 1243 pWin->mbVisited = sal_True; 1244 pWin->mnRootDist = Max ( nDepth, pWin-> mnRootDist ); 1245 if ( nDepth > DEPPER_MAX_DEPTH ) 1246 { 1247 DBG_ASSERT( nDepth != DEPPER_MAX_DEPTH + 1, "Ringabh�ngigkeit!" ); 1248 nDepth++; 1249 return DEP_ENDLES_RECURSION_FOUND; 1250 } 1251 1252 while ( (pCon = pWin->GetConnector( i )) ) 1253 { 1254 if ( pCon->IsStart( pWin )&& pCon->IsVisible() ) //removed: don't show null_project 1255 { 1256 pNewWin = pCon->GetOtherWin( pWin ); 1257 nMaxDepth = Max( Impl_Traveller( pNewWin, nDepth ), nMaxDepth ); 1258 if( nMaxDepth == DEP_ENDLES_RECURSION_FOUND ) 1259 { 1260 mpTravellerList->Insert( pWin, LIST_APPEND ); 1261 return DEP_ENDLES_RECURSION_FOUND; 1262 } 1263 } 1264 i++; 1265 } 1266 pWin->mnHeadDist = MAX( pWin->mnHeadDist, nMaxDepth - nDepth ); 1267 return nMaxDepth; 1268 } 1269 1270 1271 double SolDep::Impl_PermuteMin( ObjWinList& rObjList, Point* pPosArray, ObjWinList& rResultList, double dMinDist, sal_uIntPtr nStart, sal_uIntPtr nSize, DistType eDistType ) 1272 { 1273 1274 sal_uIntPtr i, j, l; 1275 sal_uIntPtr nEnd = nStart + nSize; 1276 ObjectWin* pSwapWin; 1277 sal_uIntPtr nLevelObjCount = rObjList.Count(); 1278 1279 //dont use full recusion for more than 6 objects 1280 if ( nLevelObjCount > 6 ) 1281 { 1282 srand(( unsigned ) time( NULL )); 1283 1284 sal_uIntPtr nIdx1, nIdx2; 1285 for ( i = 0; i < 101; i++ ) 1286 { 1287 UpdateSubProgrssBar(i); 1288 for ( j = 0; j < 100; j++ ) 1289 { 1290 nIdx1 = (sal_uIntPtr) ( double( rand() ) / RAND_MAX * nLevelObjCount ); 1291 while ( rObjList.GetObject( nIdx1 ) == NULL ) 1292 nIdx1 = (sal_uIntPtr) ( double( rand() ) / RAND_MAX * nLevelObjCount ); 1293 nIdx2 = (sal_uIntPtr) ( double( rand() ) / RAND_MAX * nLevelObjCount ); 1294 while ( nIdx1 == nIdx2 || nIdx2 == nLevelObjCount ) 1295 nIdx2 = (sal_uIntPtr) ( double( rand() ) / RAND_MAX * nLevelObjCount ); 1296 1297 pSwapWin = rObjList.GetObject( nIdx1 ); 1298 if ( pSwapWin ) 1299 pSwapWin->SetCalcPosPixel( pPosArray[ nIdx2 ] ); 1300 pSwapWin = rObjList.Replace( pSwapWin, nIdx2 ); 1301 if ( pSwapWin ) 1302 pSwapWin->SetCalcPosPixel( pPosArray[ nIdx1 ] ); 1303 rObjList.Replace( pSwapWin, nIdx1 ); 1304 1305 double dCurDist = CalcDistSum( &rObjList, eDistType ); 1306 1307 if ( dCurDist < dMinDist ) 1308 { 1309 dMinDist = dCurDist; 1310 rResultList.Clear(); 1311 for ( l = 0; l < nLevelObjCount; l++ ) 1312 { 1313 pSwapWin = rObjList.GetObject( l ); 1314 rResultList.Insert( pSwapWin, LIST_APPEND); 1315 } 1316 } 1317 // if ( dCurDist > dMinDist * 1.5 ) 1318 if ( dCurDist > dMinDist * 15 ) 1319 { 1320 pSwapWin = rObjList.GetObject( nIdx1 ); 1321 if ( pSwapWin ) 1322 pSwapWin->SetCalcPosPixel( pPosArray[ nIdx2 ] ); 1323 pSwapWin = rObjList.Replace( pSwapWin, nIdx2 ); 1324 if ( pSwapWin ) 1325 pSwapWin->SetCalcPosPixel( pPosArray[ nIdx1 ] ); 1326 rObjList.Replace( pSwapWin, nIdx1 ); 1327 } 1328 } 1329 } 1330 } 1331 else 1332 { 1333 for ( i = nStart ; i < nEnd; i++) 1334 { 1335 if ( nSize > 1 ) 1336 { 1337 pSwapWin = rObjList.GetObject( i ); 1338 pSwapWin = rObjList.Replace( pSwapWin, nStart ); 1339 rObjList.Replace( pSwapWin, i ); 1340 double dPermuteDist = Impl_PermuteMin( rObjList, pPosArray, rResultList, dMinDist, nStart + 1, nSize - 1, eDistType ); 1341 dMinDist = MIN( dMinDist, dPermuteDist); 1342 pSwapWin = rObjList.GetObject( i ); 1343 pSwapWin = rObjList.Replace( pSwapWin, nStart ); 1344 rObjList.Replace( pSwapWin, i ); 1345 1346 } 1347 else 1348 { 1349 for ( l = 0; l < nLevelObjCount; l++ ) 1350 { 1351 pSwapWin = rObjList.GetObject( l ); 1352 if ( pSwapWin ) 1353 pSwapWin->SetCalcPosPixel( pPosArray[ l ] ); 1354 } 1355 1356 double dCurDist = CalcDistSum( &rObjList, eDistType ); 1357 1358 if ( dCurDist < dMinDist ) 1359 { 1360 dMinDist = dCurDist; 1361 rResultList.Clear(); 1362 for ( l = 0; l < nLevelObjCount; l++ ) 1363 { 1364 pSwapWin = rObjList.GetObject( l ); 1365 rResultList.Insert( pSwapWin, LIST_APPEND); 1366 } 1367 } 1368 1369 } 1370 } 1371 } 1372 1373 return dMinDist; 1374 } 1375 1376 1377 sal_uInt16 SolDep::OptimizePos(SolIdMapper* pIdMapper, ObjectList* pObjLst, sal_uIntPtr nTopId, sal_uIntPtr nBottmId, sal_uIntPtr aObjID ) 1378 { 1379 ObjWinList aWorkList; 1380 ObjectWin* pWin; 1381 Connector* pCon; 1382 sal_uInt16 nRootDist = (sal_uInt16) -1; 1383 sal_uInt16 i, j, k, l, nRetVal; 1384 sal_uInt16 LevelUse[ DEPPER_MAX_DEPTH ]; 1385 sal_uInt16 LevelSecUse[ DEPPER_MAX_DEPTH ]; 1386 ObjWinList* LevelList[ DEPPER_MAX_DEPTH ]; 1387 ObjWinList* LevelSecList[ DEPPER_MAX_DEPTH ]; 1388 Point aPosArray[ DEPPER_MAX_LEVEL_WIDTH * DEPPER_MAX_WIDTH ]; 1389 1390 mnMinDynXOffs = 0xffff; 1391 1392 for ( i = 0; i < DEPPER_MAX_DEPTH; i++ ) 1393 { 1394 LevelUse[ i ] = 0; 1395 LevelList[ i ] = NULL; 1396 LevelSecUse[ i ] = 0; 1397 LevelSecList[ i ] = NULL; 1398 } 1399 1400 GetDepWin()->EnablePaint( sal_False ); 1401 1402 sal_uIntPtr nObjCount = pObjLst->Count(); 1403 for ( i = 0; i < nObjCount; i++ ) 1404 { 1405 pWin = pObjLst->GetObject( i ); 1406 if ( pWin->IsVisible()) { 1407 pWin->mbVisited = sal_False; 1408 pWin->mnHeadDist = 0; 1409 pWin->mnRootDist = 0; 1410 1411 // find initial objects which need to be connected with 1412 // root object 1413 j = 0; 1414 sal_uInt16 nStartCount = 0; 1415 sal_uInt16 nEndCount = 0; 1416 while ( (pCon = pWin->GetConnector( j )) ) 1417 { 1418 if ( pCon->IsVisible()) { //null_project 1419 if( pCon->IsStart( pWin )) 1420 nStartCount++; 1421 else 1422 { 1423 nEndCount = 1; 1424 break; 1425 } 1426 } 1427 j++; 1428 } 1429 1430 if ( nStartCount > 0 && nEndCount == 0 ) 1431 if ( nTopId != pWin->GetId()) 1432 AddConnectorToObjects( pObjLst, nTopId, pWin->GetId()); 1433 1434 } 1435 } 1436 1437 pWin = ObjIdToPtr( pObjLst, nTopId ); 1438 1439 if ( mpTravellerList ) 1440 { 1441 mpTravellerList->Clear(); 1442 delete mpTravellerList; 1443 } 1444 mpTravellerList = new ObjWinList(); 1445 // set root and top distance 1446 nRetVal = Impl_Traveller( pWin, nRootDist ); 1447 1448 DBG_ASSERT( nRetVal < DEPPER_MAX_DEPTH , "zu tief" ); 1449 if ( nRetVal == DEP_ENDLES_RECURSION_FOUND ) 1450 { 1451 WriteToErrorFile(); 1452 return nRetVal; 1453 } 1454 1455 sal_uIntPtr nUnvisited = 0; 1456 sal_uIntPtr nUnvisYOffs = 0; 1457 1458 // seperate mainstream, secondary and unconnected 1459 for ( i = 0; i < nObjCount; i++ ) 1460 { 1461 pWin = pObjLst->GetObject( i ); 1462 if ( pWin->IsVisible()) { 1463 if (( pWin->mnHeadDist + pWin->mnRootDist ) == nRetVal ) 1464 { 1465 if ( !LevelList[ pWin->mnHeadDist ] ) 1466 LevelList[ pWin->mnHeadDist ] = new ObjWinList; 1467 LevelList[ pWin->mnHeadDist ]->Insert( pWin ); 1468 LevelUse[ pWin->mnHeadDist ]++; 1469 } 1470 else 1471 if ( pWin->mbVisited ) 1472 { 1473 if ( !LevelSecList[ nRetVal - pWin->mnRootDist ] ) 1474 LevelSecList[ nRetVal - pWin->mnRootDist ] = new ObjWinList; 1475 LevelSecList[ nRetVal - pWin->mnRootDist ]->Insert( pWin ); 1476 LevelSecUse[ nRetVal - pWin->mnRootDist ]++; 1477 } 1478 else 1479 { 1480 // need to be arranged more intelligent... 1481 Point aPos( 5, nUnvisYOffs ); 1482 pWin->SetCalcPosPixel( aPos ); 1483 1484 Point aTmpPos = pWin->GetCalcPosPixel(); 1485 pWin->SetPosPixel( mpBaseWin->LogicToPixel( aTmpPos )); 1486 1487 nUnvisYOffs += pWin->PixelToLogic( pWin->GetSizePixel()).Height(); 1488 nUnvisited++; 1489 } 1490 } 1491 } 1492 1493 mnLevelOffset = 0; 1494 1495 sal_uInt16 nScaleVal; 1496 1497 if ( nRetVal == 0 ) 1498 nScaleVal = 1; 1499 else 1500 nScaleVal = nRetVal; 1501 1502 i = 0; 1503 1504 sal_uInt16 nStep = 0; 1505 1506 while ( LevelList[ i ] ) 1507 { 1508 UpdateMainProgressBar(i, nScaleVal, nStep); 1509 DBG_ASSERT( LevelUse[ i ] == LevelList[ i ]->Count() , "level index im a..." ); 1510 ObjectWin* pSwapWin; 1511 sal_uIntPtr nLevelObjCount = LevelList[ i ]->Count(); 1512 1513 if ( nLevelObjCount % 2 == 0 ) 1514 { 1515 LevelList[ i ]->Insert( NULL, LIST_APPEND ); 1516 nLevelObjCount++; 1517 // LevelUse bleibt orginal... 1518 // LevelUse[ i ]++; 1519 } 1520 1521 // catch too big lists 1522 DBG_ASSERT( nLevelObjCount < DEPPER_MAX_LEVEL_WIDTH * DEPPER_MAX_WIDTH , "graph zu breit! dat geiht nich gut. breaking" ); 1523 if ( nLevelObjCount >= DEPPER_MAX_LEVEL_WIDTH * DEPPER_MAX_WIDTH ) 1524 { 1525 WarningBox aWBox( mpBaseWin, WB_OK, String::CreateFromAscii("graph zu breit! dat geiht nich gut. breaking")); 1526 aWBox.Execute(); 1527 break; 1528 } 1529 mnXOffset = CalcXOffset( nLevelObjCount ); 1530 aWorkList.Clear(); 1531 1532 // initial positioning for mainstream 1533 for ( j = 0; j < nLevelObjCount; j++ ) 1534 { 1535 pSwapWin = LevelList[ i ]->GetObject( j ); 1536 aWorkList.Insert( pSwapWin, LIST_APPEND); 1537 Point aPos = CalcPos( i, j ); 1538 aPosArray[ j ] = aPos; 1539 if ( pSwapWin ) 1540 pSwapWin->SetCalcPosPixel( aPosArray[ j ] ); 1541 } 1542 1543 double dMinDist = CalcDistSum( LevelList[ i ] ); 1544 1545 // optimize mainstream order and return best matching list in "aWorkList" 1546 dMinDist = MIN( dMinDist, Impl_PermuteMin( *(LevelList[ i ]), aPosArray, aWorkList, dMinDist, 0, nLevelObjCount )); 1547 1548 // set optimized positions - may still be wrong from later tries 1549 for ( j = 0; j < nLevelObjCount; j++ ) 1550 { 1551 pSwapWin = aWorkList.GetObject( j ); 1552 if ( pSwapWin ) 1553 pSwapWin->SetCalcPosPixel( aPosArray[ j ] ); 1554 } 1555 1556 if ( LevelSecList[ i ] != NULL ) 1557 { 1558 sal_uIntPtr nLevelSecObjCount = LevelSecList[ i ]->Count(); 1559 // expand list for better positioning 1560 while ( nLevelSecObjCount + LevelUse[ i ] < DEPPER_MAX_WIDTH - 1 ) 1561 { 1562 LevelSecList[ i ]->Insert( NULL, LIST_APPEND ); 1563 nLevelSecObjCount++; 1564 } 1565 if ( ( nLevelSecObjCount + LevelUse[ i ])% 2 == 0 ) 1566 { 1567 LevelSecList[ i ]->Insert( NULL, LIST_APPEND ); 1568 nLevelSecObjCount++; 1569 } 1570 1571 DBG_ASSERT( nLevelSecObjCount < DEPPER_MAX_LEVEL_WIDTH * DEPPER_MAX_WIDTH , "graph zu breit! dat geiht nich gut. breaking" ); 1572 if ( nLevelObjCount >= DEPPER_MAX_LEVEL_WIDTH * DEPPER_MAX_WIDTH ) 1573 { 1574 WarningBox aWBox( mpBaseWin, WB_OK, String::CreateFromAscii("graph zu breit! dat geiht nich gut. breaking")); 1575 aWBox.Execute(); 1576 break; 1577 } 1578 mnXOffset = CalcXOffset( LevelUse[ i ] + nLevelSecObjCount ); 1579 aWorkList.Clear(); 1580 1581 l = 0; 1582 sal_Bool bUsedPos; 1583 1584 // find free positions for secondary objects 1585 for ( j = 0; j < ( LevelUse[ i ] + nLevelSecObjCount ) ; j++ ) 1586 { 1587 Point aPos = CalcPos( i, j ); 1588 bUsedPos = sal_False; 1589 // is already occupied? 1590 for ( k = 0; k < nLevelObjCount; k++ ) 1591 { 1592 if ( LevelList[ i ]->GetObject( k ) ) 1593 if ( aPos == LevelList[ i ]->GetObject( k )->GetCalcPosPixel() ) 1594 bUsedPos = sal_True; 1595 } 1596 // if its free, add to pool 1597 if ( !bUsedPos ) 1598 { 1599 aPosArray[ l ] = aPos; 1600 l++; 1601 } 1602 } 1603 1604 // initial positioning for secodaries 1605 for ( j = 0 ; j < nLevelSecObjCount ; j++ ) 1606 { 1607 pSwapWin = LevelSecList[ i ]->GetObject( j ); 1608 aWorkList.Insert( pSwapWin, LIST_APPEND); 1609 if ( pSwapWin ) 1610 pSwapWin->SetCalcPosPixel( aPosArray[ j ] ); 1611 } 1612 dMinDist = CalcDistSum( LevelSecList[ i ] ); 1613 1614 dMinDist = MIN( dMinDist, Impl_PermuteMin( *(LevelSecList[ i ]), aPosArray, aWorkList, dMinDist, 0, nLevelSecObjCount )); 1615 1616 // set optimized positions - may still be wrong from later tries 1617 for ( j = 0; j < nLevelSecObjCount; j++ ) 1618 { 1619 pSwapWin = aWorkList.GetObject( j ); 1620 if ( pSwapWin ) 1621 pSwapWin->SetCalcPosPixel( aPosArray[ j ] ); 1622 } 1623 if ( LevelUse[ i ] + LevelSecUse[ i ] > DEPPER_MAX_WIDTH ) 1624 mnLevelOffset++; 1625 } 1626 if ( LevelUse[ i ] + LevelSecUse[ i ] > DEPPER_MAX_WIDTH ) 1627 mnLevelOffset+= ( LevelUse[ i ] + LevelSecUse[ i ] ) / DEPPER_MAX_WIDTH ; 1628 i++; 1629 } 1630 1631 mnMinDynXOffs = 0xffff; 1632 1633 // and back again... 1634 // get better results form already preoptimized upper and lower rows 1635 1636 do 1637 { 1638 i--; 1639 UpdateMainProgressBar(i, nScaleVal, nStep, sal_True); // sal_True ~ counting down 1640 if ( LevelUse[ i ] + LevelSecUse[ i ] > DEPPER_MAX_WIDTH ) 1641 mnLevelOffset-= ( LevelUse[ i ] + LevelSecUse[ i ] ) / DEPPER_MAX_WIDTH ; 1642 ObjectWin* pSwapWin; 1643 sal_uIntPtr nLevelObjCount = LevelList[ i ]->Count(); 1644 mnXOffset = CalcXOffset( nLevelObjCount ); 1645 aWorkList.Clear(); 1646 1647 for ( j = 0; j < nLevelObjCount; j++ ) 1648 { 1649 pSwapWin = LevelList[ i ]->GetObject( j ); 1650 aWorkList.Insert( pSwapWin, LIST_APPEND); 1651 Point aPos = CalcPos( i, j ); 1652 aPosArray[ j ] = aPos; 1653 //no need to do this stuff....... ????? 1654 if ( pSwapWin ) 1655 pSwapWin->SetCalcPosPixel( aPosArray[ j ] ); 1656 } 1657 1658 double dMinDist = CalcDistSum( LevelList[ i ], BOTH ); 1659 1660 dMinDist = MIN( dMinDist, Impl_PermuteMin( *(LevelList[ i ]), aPosArray, aWorkList, dMinDist, 0, nLevelObjCount, BOTH )); 1661 // wrong position for remaping - keep old positions for comparing 1662 for ( j = 0; j < nLevelObjCount; j++ ) 1663 { 1664 pSwapWin = aWorkList.GetObject( j ); 1665 if ( pSwapWin ) 1666 // pSwapWin->SetCalcPosPixel( mpBaseWin->LogicToPixel( aPosArray[ j ] )); 1667 pSwapWin->SetCalcPosPixel( aPosArray[ j ] ); 1668 } 1669 1670 if ( LevelSecList[ i ] != NULL ) 1671 { 1672 sal_uIntPtr nLevelSecObjCount = LevelSecList[ i ]->Count(); 1673 mnXOffset = CalcXOffset( LevelUse[ i ] + nLevelSecObjCount ); 1674 aWorkList.Clear(); 1675 1676 l = 0; 1677 sal_Bool bUsedPos; 1678 1679 for ( j = 0; j < ( LevelUse[ i ] + nLevelSecObjCount ) ; j++ ) 1680 { 1681 Point aPos = CalcPos( i, j ); 1682 bUsedPos = sal_False; 1683 // could be faster 1684 for ( k = 0; k < nLevelObjCount; k++ ) 1685 { 1686 if ( LevelList[ i ]->GetObject( k ) ) 1687 if ( aPos == LevelList[ i ]->GetObject( k )->GetCalcPosPixel() ) 1688 bUsedPos = sal_True; 1689 } 1690 if ( !bUsedPos ) 1691 { 1692 aPosArray[ l ] = aPos; 1693 l++; 1694 } 1695 } 1696 1697 for ( j = 0 ; j < nLevelSecObjCount ; j++ ) 1698 { 1699 pSwapWin = LevelSecList[ i ]->GetObject( j ); 1700 aWorkList.Insert( pSwapWin, LIST_APPEND); 1701 if ( pSwapWin ) 1702 pSwapWin->SetCalcPosPixel( aPosArray[ j ] ); 1703 } 1704 dMinDist = CalcDistSum( LevelSecList[ i ], BOTH ); 1705 1706 dMinDist = MIN( dMinDist, Impl_PermuteMin( *(LevelSecList[ i ]), aPosArray, aWorkList, dMinDist, 0, nLevelSecObjCount, BOTH )); 1707 // wrong position for remaping - keep old positions for comparing 1708 for ( j = 0; j < nLevelSecObjCount; j++ ) 1709 { 1710 pSwapWin = aWorkList.GetObject( j ); 1711 if ( pSwapWin ) 1712 pSwapWin->SetCalcPosPixel( aPosArray[ j ] ); 1713 } 1714 } 1715 // i--; 1716 } while ( i != 0 ); 1717 SetMainProgressBar( 100 ); 1718 1719 sal_uIntPtr nNewXSize = ( DEPPER_MAX_WIDTH + 1 ) * ( OBJWIN_X_SPACING + GetDefSize().Width() ); 1720 1721 // sal_uIntPtr aObjID = GetStart(pIdMapper, pObjLst) //hier mu� man switchen GetStart/GetPrjStart oder so 1722 1723 ObjectWin* pObjWin = ObjIdToPtr( pObjLst, aObjID); 1724 1725 sal_uIntPtr nNewYSize = pObjWin->GetCalcPosPixel().Y() + GetDefSize().Height() + 2 * OBJWIN_Y_SPACING; 1726 if (( nUnvisYOffs + GetDefSize().Height()) > nNewYSize ) 1727 nNewYSize = nUnvisYOffs + GetDefSize().Height(); 1728 1729 MapMode aMapMode = GetDepWin()->GetMapMode(); 1730 Size aTmpSize( (sal_uIntPtr) (double(nNewXSize) * double( aMapMode.GetScaleX())), (sal_uIntPtr) (double( nNewYSize) * double( aMapMode.GetScaleY()))); 1731 1732 Size aNowSize( GetGraphWin()->GetSizePixel()); 1733 1734 if ( GetDepWin()->LogicToPixel( aNowSize ).Width() > aTmpSize.Width() ) 1735 aTmpSize.Width() = GetDepWin()->LogicToPixel( aNowSize ).Width() ; 1736 1737 if ( GetDepWin()->LogicToPixel( aNowSize ).Height() > aTmpSize.Height() ) 1738 aTmpSize.Height() = GetDepWin()->LogicToPixel( aNowSize ).Height() ; 1739 1740 // if ( nZoomed <= 0 ) 1741 // { 1742 // mpBaseWin->SetSizePixel( aTmpSize ); 1743 // mpGraphWin->SetTotalSize( aTmpSize ); 1744 // mpGraphWin->EndScroll( 0, 0 ); 1745 // } 1746 1747 // now remap all objects 1748 sal_uIntPtr nAllObjCount = pObjLst->Count(); 1749 Point aTmpPos; 1750 for ( j = 0; j < nAllObjCount; j++ ) 1751 { 1752 pWin = pObjLst->GetObject( j ); 1753 if ( pWin->IsVisible()) { 1754 aTmpPos = pWin->GetCalcPosPixel(); 1755 if ( pWin->mbVisited ) 1756 { 1757 // reserve space for unconnected 1758 aTmpPos.X() -= mnMinDynXOffs; 1759 aTmpPos.X() += GetDefSize().Width() + OBJWIN_X_SPACING; 1760 // center window 1761 aTmpPos.X() += GetDefSize().Width() / 2; 1762 aTmpPos.X() -= pWin->PixelToLogic( pWin->GetSizePixel()).Width() / 2 ; 1763 } 1764 pWin->SetPosPixel( GetDepWin()->LogicToPixel( aTmpPos )); 1765 } 1766 } 1767 aWorkList.Clear(); 1768 GetDepWin()->EnablePaint( sal_True ); 1769 GetDepWin()->Invalidate(); 1770 //LevelListen loeschen H�? Welche Levellisten? 1771 1772 //Update all Connectors 1773 // --> To be done: Don't call twice Object1-Connector-Object2 1774 ObjectWin* pObject1; 1775 for ( i = 0 ; i < nObjCount ; i++) 1776 { 1777 pObject1 = pObjLst->GetObject( i ); 1778 if ( pObject1->IsVisible()) 1779 pObject1->UpdateConnectors(); 1780 }; 1781 return 0; 1782 } 1783 1784 void SolDep::WriteToErrorFile() 1785 { 1786 //Needs some improvement 1787 ObjectWin* pWin; 1788 WarningBox aWBox( mpBaseWin, WB_OK, String::CreateFromAscii("graph too deep! dat geiht nich gut.\nlook at depper.err in your Tmp-directory\nfor list of objects")); 1789 aWBox.Execute(); 1790 char *tmpdir = getenv("TMP"); 1791 char *errfilebasename = "depper.err"; 1792 char *ErrFileName = (char*) malloc( strlen( tmpdir ) + strlen( errfilebasename) + 3 ); 1793 *ErrFileName = '\0'; 1794 strcat( ErrFileName, tmpdir ); 1795 strcat( ErrFileName, "\\" ); 1796 strcat( ErrFileName, errfilebasename ); 1797 FILE* pErrFile = fopen( "depper.err", "w+" ); 1798 if ( pErrFile ) 1799 { 1800 for ( sal_uInt16 i = 0; i < mpTravellerList->Count(); i++ ) 1801 { 1802 pWin = mpTravellerList->GetObject( i ); 1803 fprintf( pErrFile, " %s -> \n", (pWin->GetBodyText()).GetBuffer()); 1804 } 1805 fclose( pErrFile ); 1806 } 1807 } 1808