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