GME
13
|
00001 // GMEOLEActiveModel.cpp : implementation file 00002 // 00003 00004 #include "stdafx.h" 00005 #include "gme.h" 00006 #include "GMEOLEIt.h" 00007 #include "GMEOLEAspect.h" 00008 #include "GMEOLEError.h" 00009 #include "GMEOLEColl.h" 00010 #include "GMEDoc.h" 00011 #include "MainFrm.h" 00012 #include "GMEEventLogger.h" 00013 #include "CommonStl.h" 00014 00015 #ifdef _DEBUG 00016 #define new DEBUG_NEW 00017 #undef THIS_FILE 00018 static char THIS_FILE[] = __FILE__; 00019 #endif 00020 00021 #define CATCHALL_AND_CALL_END \ 00022 catch( const wchar_t * p) \ 00023 { \ 00024 end(); \ 00025 SHOW_ERROR( p ); \ 00026 } \ 00027 catch(...) \ 00028 { \ 00029 end(); \ 00030 SHOW_ERROR( L"Unhandled error occurred" ); \ 00031 } \ 00032 end(); 00033 00035 // CGMEOLEIt 00036 00037 IMPLEMENT_DYNCREATE(CGMEOLEIt, CCmdTarget) 00038 00039 CGMEOLEIt::CGMEOLEIt() 00040 : m_theView(0) 00041 , m_theMgaModel(0) 00042 , m_isInUserInitiatedTransaction( false) 00043 { 00044 EnableAutomation(); 00045 } 00046 00047 CGMEOLEIt::~CGMEOLEIt() 00048 { 00049 } 00050 00051 00052 void CGMEOLEIt::OnFinalRelease() 00053 { 00054 // When the last reference for an automation object is released 00055 // OnFinalRelease is called. The base class will automatically 00056 // deletes the object. Add additional cleanup required for your 00057 // object before calling the base class. 00058 00059 CCmdTarget::OnFinalRelease(); 00060 } 00061 00062 00063 bool CGMEOLEIt::AmIValid() 00064 { 00065 m_theView = 0; 00066 m_theMgaModel = 0; 00067 CMDIChildWnd *pChild = CMainFrame::theInstance->MDIGetActive(); 00068 00069 if (pChild) 00070 { 00071 CGMEView *view = (CGMEView*)pChild->GetActiveView(); 00072 if (view) 00073 { 00074 CComPtr<IMgaModel> mm = view->GetCurrentModel(); //CComPtr<IMgaModel> & 00075 if( mm ) 00076 { 00077 m_theView = view; 00078 m_theMgaModel = mm; 00079 return true; 00080 } 00081 } 00082 } 00083 return false; 00084 } 00085 00086 bool CGMEOLEIt::beginTrans() 00087 { 00088 CComObjPtr<IMgaTerritory> territory; 00089 00090 COMTHROW( theApp.mgaProject->CreateTerritory(NULL, PutOut(territory), NULL) ); 00091 COMTHROW( theApp.mgaProject->BeginTransaction(territory, TRANSACTION_GENERAL) ); 00092 00093 return true; 00094 } 00095 00096 bool CGMEOLEIt::commitTrans() 00097 { 00098 try 00099 { 00100 CComPtr<IMgaTerritory> act_terr; 00101 COMTHROW( theApp.mgaProject->get_ActiveTerritory( &act_terr)); 00102 if( act_terr) act_terr->Flush(); 00103 COMTHROW( theApp.mgaProject->CommitTransaction()); 00104 //act_terr = 0; 00105 } 00106 catch( ... ) 00107 { 00108 COMTHROW( theApp.mgaProject->AbortTransaction()); 00109 } 00110 00111 return true; 00112 } 00113 00114 bool CGMEOLEIt::abortTrans() 00115 { 00116 try 00117 { 00118 CComPtr<IMgaTerritory> act_terr; 00119 COMTHROW( theApp.mgaProject->get_ActiveTerritory( &act_terr)); 00120 if( act_terr) act_terr->Flush(); 00121 00122 COMTHROW( theApp.mgaProject->AbortTransaction()); 00123 } 00124 catch( ... ) 00125 { 00126 } 00127 00128 return true; 00129 } 00130 00131 CComPtr<IMgaFCO> CGMEOLEIt::putInTerr( const CComPtr<IMgaFCO>& p_oneFCO) 00132 { 00133 CComPtr<IMgaTerritory> act_terr; 00134 COMTHROW( theApp.mgaProject->get_ActiveTerritory( &act_terr)); 00135 00136 if( !act_terr && !m_isInUserInitiatedTransaction && !m_initedByMe) return 0; 00137 if( !p_oneFCO) return 0; 00138 00139 CComPtr<IMgaFCO> out_fco; 00140 COMTHROW(act_terr->OpenFCO( p_oneFCO, &out_fco)); 00141 00142 return out_fco.Detach(); 00143 00144 } 00145 00146 LPDISPATCH CGMEOLEIt::putInTerr( LPDISPATCH p_oneObj) 00147 { 00148 return putInTerr( CComQIPtr<IMgaFCO>( p_oneObj)).Detach(); 00149 } 00150 00151 // if invoked, this method assures that either a user transaction, or a freshly created transaction is open 00152 bool CGMEOLEIt::start() 00153 { 00154 // a transaction may be started like: project.BeginTransaction() also 00155 // not only through the this.BeginTransaction() (this = CGMEOLEIt) 00156 // that is why we prepare for that as well 00157 00158 // m_isInUserInitiatedTransaction <==> it has been started with this.BeginTransaction() 00159 // m_initedByMe <==> there was no active transaction, so we start one in order to function correctly 00160 // and we have to commit it when the method exits 00161 // 00162 00163 CComObjPtr<IMgaTerritory> territory; 00164 COMTHROW( theApp.mgaProject->get_ActiveTerritory( PutOut( territory))); 00165 00166 m_initedByMe = false; 00167 if( !m_isInUserInitiatedTransaction && !territory) // if 0 then no trasaction is going on 00168 { 00169 this->beginTrans(); 00170 m_initedByMe = true; 00171 } 00172 00173 return true; 00174 } 00175 00176 // closes the transaction if it was created automatically ( not by the user ) 00177 bool CGMEOLEIt::end() 00178 { 00179 if( m_initedByMe) 00180 { 00181 this->commitTrans(); 00182 } 00183 00184 return true; 00185 } 00186 00187 //static 00188 void CGMEOLEIt::rename( CComPtr<IMgaFCO> pFco, LPCTSTR pName) 00189 { 00190 CComBSTR _name( pName); 00191 if( pFco) 00192 COMTHROW( pFco->put_Name( _name)); 00193 } 00194 00195 //static 00196 CComPtr<IMgaFCO> CGMEOLEIt::getChildInByName( CComPtr<IMgaModel> model, LPCTSTR name ) 00197 { 00198 return fcoByPath( model, name); 00199 #if(0) 00200 CComPtr<IMgaFCO> ch; 00201 CComBSTR nm( (LPCTSTR) name); 00202 if( model) COMTHROW( model->get_ChildFCO( nm, &ch)); 00203 if( ch) 00204 { 00205 return ch; 00206 } 00207 return 0; 00208 #endif 00209 } 00210 00211 //static 00212 bool CGMEOLEIt::isValidChildIn( CComPtr<IMgaModel> model, CComPtr<IMgaFCO> fco) // is valid child (aspect related information( hidden, shown is disregarded now) 00213 { 00214 CComBSTR nm; 00215 if( fco) COMTHROW( fco->get_Name( &nm )); 00216 00217 CComPtr<IMgaFCO> ch; 00218 if( model) COMTHROW( model->get_ChildFCO( nm, &ch)); 00219 if( ch && ch == fco) 00220 { 00221 return true; 00222 } 00223 return false; 00224 } 00225 00226 // gives back the metarole ptr based on a part's name 00227 //static 00228 CComPtr<IMgaMetaRole> CGMEOLEIt::metaRolePtrInByName( CComPtr<IMgaModel> p_model, CComBSTR p_part ) 00229 { 00230 CComObjPtr<IMgaMetaFCO> fco_meta; 00231 if( p_model) COMTHROW( p_model->get_Meta( PutOut( fco_meta))); 00232 00233 CComObjPtr<IMgaMetaModel> model_meta; 00234 COMTHROW( fco_meta.QueryInterface( model_meta)); 00235 THROW_IF_NULL( model_meta, _T("Invalid Meta object")); 00236 00237 CComPtr<IMgaMetaRole> metarole; 00238 // COMTHROW not used since it is common to pass in wrong names: 00239 model_meta->get_RoleByName( p_part, &metarole); // may throw if bad kind is asked 00240 THROW_IF_NULL( metarole, _T("No such metarole found")); 00241 00242 return metarole; 00243 } 00244 00245 // gives back the meta rolename 00246 //static 00247 CComBSTR CGMEOLEIt::roleNameOf( CComPtr<IMgaFCO> one_fco ) 00248 { 00249 CComObjPtr<IMgaMetaFCO> fco_meta; 00250 if( one_fco) COMTHROW( one_fco->get_Meta( PutOut( fco_meta))); 00251 00252 CComBSTR mrn; 00253 if( fco_meta) COMTHROW( fco_meta->get_Name( &mrn)); 00254 00255 return mrn; 00256 } 00257 00258 // gives back a connection metarole ptr based on src and dst and container 00259 //static 00260 CComPtr<IMgaMetaRole> CGMEOLEIt::connMetaRolePtrInBetween( CComPtr<IMgaModel> p_model, CComPtr<IMgaFCO> p_src, CComPtr<IMgaFCO> p_dst ) 00261 { 00262 CComBSTR to_connect_as_src = roleNameOf( p_src); 00263 CComBSTR to_connect_as_dst = roleNameOf( p_dst); 00264 00265 return connMetaRolePtrInBetween( p_model, to_connect_as_src, to_connect_as_dst); 00266 } 00267 00268 //static 00269 CComPtr<IMgaMetaRole> CGMEOLEIt::connMetaRolePtrInBetween( CComPtr<IMgaModel> p_model, CComPtr<IMgaFCO> p_srcRole1, CComPtr<IMgaFCO> p_srcRole2, CComPtr<IMgaFCO> p_dstRole1, CComPtr<IMgaFCO> p_dstRole2) 00270 { 00271 CComBSTR to_connect_as_src = roleNameOf( p_srcRole1); 00272 CComBSTR to_connect_as_dst = roleNameOf( p_dstRole1); 00273 00274 COMTHROW(to_connect_as_src.Append(_T(" "))); 00275 COMTHROW(to_connect_as_src.AppendBSTR( roleNameOf( p_srcRole2))); // now we have a path like: "model port" composed of roles 00276 COMTHROW(to_connect_as_dst.Append(_T(" "))); 00277 COMTHROW(to_connect_as_dst.AppendBSTR( roleNameOf( p_dstRole2))); 00278 00279 return connMetaRolePtrInBetween( p_model, to_connect_as_src, to_connect_as_dst); 00280 } 00281 00282 //static 00283 CComPtr<IMgaMetaRole> CGMEOLEIt::connMetaRolePtrInBetween( CComPtr<IMgaModel> p_model, const CComBSTR& src_localpath, const CComBSTR& dst_localpath) 00284 { 00285 CComBSTR src_nm( L"src"); 00286 CComBSTR dst_nm( L"dst"); 00287 00288 // check for connection allowed in p_model between p_src and p_dst 00289 00290 CComObjPtr<IMgaMetaFCO> fco_meta; 00291 if( p_model) COMTHROW( p_model->get_Meta( PutOut( fco_meta))); 00292 00293 CComObjPtr<IMgaMetaModel> model_meta; 00294 COMTHROW( fco_meta.QueryInterface( model_meta)); 00295 00296 // the model can contain these connections 00297 CComObjPtrVector<IMgaMetaRole> conn_metaroles; 00298 if( model_meta) COMTHROW( model_meta->LegalConnectionRoles( 0, PutOut( conn_metaroles ))); 00299 00300 // will store the possible connection meta roles 00301 CComObjPtrVector<IMgaMetaRole> valid_conn_metaroles; 00302 00303 CComObjPtrVector<IMgaMetaRole>::iterator coll_it = conn_metaroles.begin(); 00304 CComObjPtrVector<IMgaMetaRole>::iterator coll_end = conn_metaroles.end(); 00305 for( ; coll_it != coll_end; ++coll_it) 00306 { 00307 bool src_found = false; 00308 bool dst_found = false; 00309 00310 CComObjPtr<IMgaMetaFCO> fco_meta; 00311 COMTHROW( (*coll_it)->get_Kind( PutOut( fco_meta))); 00312 00313 CComObjPtr<IMgaMetaConnection> conn_meta; 00314 COMTHROW( fco_meta.QueryInterface( conn_meta )); 00315 00316 // joints the connection may have 00317 CComObjPtrVector<IMgaMetaConnJoint> jnts; 00318 if( conn_meta) COMTHROW( conn_meta->get_Joints( PutOut( jnts ))); 00319 00320 CComObjPtrVector<IMgaMetaConnJoint>::iterator jnt_it = jnts.begin(); 00321 CComObjPtrVector<IMgaMetaConnJoint>::iterator jnt_end = jnts.end(); 00322 for( ; jnt_it != jnt_end; ++jnt_it) 00323 { 00324 CComObjPtrVector<IMgaMetaPointerSpec> pntspecs; 00325 COMTHROW( (*jnt_it)->get_PointerSpecs( PutOut( pntspecs))); 00326 00327 00328 CComObjPtrVector<IMgaMetaPointerSpec>::iterator pntspec_it = pntspecs.begin(); 00329 CComObjPtrVector<IMgaMetaPointerSpec>::iterator pntspec_end = pntspecs.end(); 00330 for( ; pntspec_it != pntspec_end; ++pntspec_it) 00331 { 00332 CComBSTR nm; // "src" or "dst" for connections 00333 COMTHROW( (*pntspec_it)->get_Name( &nm)); 00334 00335 CComObjPtrVector<IMgaMetaPointerItem> pntitems; 00336 COMTHROW( (*pntspec_it)->get_Items( PutOut( pntitems))); 00337 00338 CComObjPtrVector<IMgaMetaPointerItem>::iterator item_it = pntitems.begin(); 00339 CComObjPtrVector<IMgaMetaPointerItem>::iterator item_end = pntitems.end(); 00340 for( ; item_it != item_end; ++item_it) 00341 { 00342 CComBSTR ds; // "role1 role2" or "role" most tipically (see local path defined in meta.idl) 00343 COMTHROW( (*item_it)->get_Desc( &ds )); 00344 00345 if( nm == _T("src") && ds == src_localpath) 00346 src_found = true; 00347 if( nm == _T("dst") && ds == dst_localpath) 00348 dst_found = true; 00349 } 00350 } 00351 } 00352 if( src_found && dst_found) 00353 { 00354 valid_conn_metaroles.push_back( *coll_it); 00355 } 00356 } 00357 00358 if( valid_conn_metaroles.empty()) 00359 return 0; 00360 if( valid_conn_metaroles.size() > 1 ) 00361 return 0; 00362 00363 return CComPtr<IMgaMetaRole>( valid_conn_metaroles[0].p); 00364 } 00365 00366 //static 00367 objtype_enum CGMEOLEIt::myTypeIs( CComPtr<IMgaFCO> fco) 00368 { 00369 CComPtr<IMgaMetaRole> mrole; 00370 if( fco) COMTHROW( fco->get_MetaRole( &mrole )); 00371 00372 CComPtr<IMgaMetaFCO> mfco; 00373 if( mrole) COMTHROW( mrole->get_Kind( &mfco)); 00374 00375 objtype_enum type_info; 00376 if( mfco) COMTHROW( mfco->get_ObjType( &type_info)); 00377 00378 return type_info; 00379 } 00380 00381 //indicates if the two collections contain the same set of fcos (the order is important) 00382 //static 00383 bool CGMEOLEIt::areCollectionsEqual( const CComPtr<IMgaFCOs>& op1, const CComPtr<IMgaFCOs>& op2) 00384 { 00385 bool res = false; 00386 long sz1(0), sz2(0); 00387 if( op1) COMTHROW( op1->get_Count( &sz1)); 00388 if( op2) COMTHROW( op2->get_Count( &sz2)); 00389 if( sz1 == sz2) 00390 { 00391 bool conti = true; 00392 for( long i = 1; conti && i <= sz1; ++i) 00393 { 00394 conti = false; 00395 CComPtr<IMgaFCO> it1, it2; 00396 COMTHROW( op1->get_Item( i, &it1)); 00397 COMTHROW( op2->get_Item( i, &it2)); 00398 if( it1 == it2) 00399 conti = true; 00400 } 00401 res = conti; 00402 } 00403 return res; 00404 } 00405 00406 // finds a port with p_portRole name 00407 // -or inside a model referred by p_ref 00408 // -or inside a model referred by a reference referred by p_ref 00409 // -or inside a model (referred by a reference)* referred by p_ref 00410 // and builds the reference collection 00411 // returns: the fcoptr of the port 00412 // the reference collection 00413 // 00414 //static 00415 void CGMEOLEIt::refPortFinderAndChainBuilder( LPCTSTR p_portRole, CComPtr<IMgaFCO> p_ref, CComPtr<IMgaFCO>& p_portResult, CComPtr<IMgaFCOs>& p_refChainResult ) 00416 { 00417 CComQIPtr<IMgaReference> ref( p_ref ); 00418 00419 bool go_on = true; 00420 while( go_on && ref) 00421 { 00422 CComPtr<IMgaFCO> referd; 00423 if( ref) COMTHROW( ref->get_Referred( &referd)); 00424 00425 CComQIPtr<IMgaModel> model( referd); 00426 if( model) // the reference points to a model truly 00427 { 00428 p_portResult = getChildInByName( model, p_portRole); 00429 00430 if( !p_refChainResult) 00431 COMTHROW(p_refChainResult.CoCreateInstance( L"Mga.MgaFCOs")); 00432 00433 COMTHROW( p_refChainResult->Append( ref )); 00434 00435 go_on = false; 00436 } 00437 else 00438 { 00439 CComQIPtr<IMgaReference> ref2( referd); // the reference (ref) may point 00440 // to another reference (ref2) 00441 // which may point to a model containing the port we are looking for 00442 00443 if( ref2) //yes it seems 00444 { 00445 if( !p_refChainResult) 00446 COMTHROW(p_refChainResult.CoCreateInstance( L"Mga.MgaFCOs")); 00447 00448 COMTHROW( p_refChainResult->Append( ref )); 00449 ref = ref2; 00450 } 00451 else 00452 { 00453 // no more trouble, the loop ends with the conclusion that the 00454 // original reference is the connection target and not the model 00455 // it is referring to, but then raises the question why did the 00456 // user call the ''ConnectThruPort method at all? 00457 } 00458 } 00459 } 00460 } 00461 00462 // verifies if p_port 00463 // -is inside a model referred by p_ref 00464 // -or inside a model referred by a reference referred by p_ref 00465 // -or inside a model (referred by a reference)* referred by p_ref 00466 // and builds the reference collection (chain) 00467 // 00468 // returns: success or failure 00469 // the reference collection 00470 // 00471 // used by ConnectThruPortFCO 00472 //static 00473 bool CGMEOLEIt::refChainBuilder2( CComPtr<IMgaFCO> p_ref, CComPtr<IMgaFCO> p_port, CComPtr<IMgaFCOs>& coll) 00474 { 00475 CComQIPtr<IMgaReference> ref( p_ref); 00476 CComPtr<IMgaFCO> tgt; 00477 if( !coll) 00478 COMTHROW(coll.CoCreateInstance( L"Mga.MgaFCOs")); 00479 VERIFY( coll); 00480 00481 bool valid = ref != 0; 00482 while( ref && valid) 00483 { 00484 COMTHROW( coll->Append( ref)); 00485 COMTHROW( ref->get_Referred( &tgt)); 00486 CComQIPtr<IMgaModel> tgt_model( tgt); 00487 CComQIPtr<IMgaReference> tgt_isRef( tgt); 00488 if( tgt_model) 00489 { 00490 ref = CComPtr<IMgaReference>(0); 00491 valid = isValidChildIn( tgt_model.p, p_port.p); 00492 } 00493 else 00494 { 00495 ref = tgt_isRef; 00496 valid = ref != 0; 00497 } 00498 } 00499 00500 return valid; 00501 } 00502 00503 // static 00504 bool CGMEOLEIt::createObjs( CComPtr<IMgaModel>& p_parent, LPCTSTR p_partToCreate, LPCTSTR p_givenName, IMgaFCO** p_pNewObj ) 00505 { 00506 if( !p_parent) return false; 00507 00508 CComObjPtr<IMgaMetaFCO> fco_meta; 00509 COMTHROW( p_parent->get_Meta( PutOut( fco_meta))); 00510 00511 CComObjPtr<IMgaMetaModel> model_meta; 00512 COMTHROW( fco_meta.QueryInterface( model_meta)); 00513 00514 CComObjPtr<IMgaMetaRole> metarole; 00515 00516 // COMTHROW not used since it is common to pass in wrong names: 00517 model_meta->get_RoleByName( CComBSTR( p_partToCreate), PutOut( metarole)); 00518 THROW_IF_NULL( metarole, _T("No such metarole found")); 00519 00520 CComObjPtr<IMgaFCO> newfco; 00521 COMTHROW( p_parent->CreateChildObject( metarole, PutOut( newfco))); 00522 THROW_IF_NULL( newfco, _T("Invalid new object pointer")); 00523 00524 CComBSTR new_name(L"New"); new_name.Append( p_partToCreate); 00525 CComBSTR b_given_name( p_givenName); 00526 00527 if( newfco) 00528 COMTHROW( newfco->put_Name( b_given_name == _T("")? new_name : b_given_name )); 00529 00530 ASSERT( p_pNewObj); 00531 *p_pNewObj = newfco.Detach(); 00532 00533 return true; 00534 } 00535 00536 //static 00537 bool CGMEOLEIt::cloneObjs( CComPtr<IMgaModel>& p_parent, IMgaFCO* p_existingFcoPtr, LPCTSTR p_existingFcoName, LPCTSTR p_givenName, IMgaFCO** p_pNewObj ) 00538 { 00539 if( !p_parent) return false; 00540 00541 CComObjPtr<IMgaMetaFCO> fco_meta; 00542 COMTHROW( p_parent->get_Meta( PutOut( fco_meta))); 00543 00544 CComObjPtr<IMgaMetaModel> model_meta; 00545 COMTHROW( fco_meta.QueryInterface( model_meta)); 00546 00547 CComObjPtr<IMgaFCO> existing_fco; 00548 00549 if( p_existingFcoPtr) // if ptr provided it is assumed is in the territory 00550 { 00551 existing_fco = p_existingFcoPtr; 00552 } 00553 else // else use p_part parameter to determine the kind 00554 { 00555 COMTHROW( p_parent->get_ChildFCO( CComBSTR( p_existingFcoName), PutOut( existing_fco))); 00556 } 00557 00558 if( !existing_fco) return false; 00559 00560 CComPtr<IMgaFCOs> coll; 00561 COMTHROW( coll.CoCreateInstance( L"Mga.MgaFCOs" )); 00562 COMTHROW( coll->Append( existing_fco)); 00563 00564 CComObjPtr<IMgaMetaRole> ex_metarole; 00565 COMTHROW( existing_fco->get_MetaRole( PutOut( ex_metarole))); 00566 00567 CComPtr<IMgaMetaRoles> col2; 00568 COMTHROW( col2.CoCreateInstance( L"Mga.MgaMetaRoles")); 00569 COMTHROW( col2->Append( ex_metarole)); 00570 00571 CComObjPtr<IMgaFCOs> col3; 00572 COMTHROW( p_parent->CopyFCOs( coll, col2, PutOut( col3 ))); 00573 00574 long l = 0; 00575 if( col3) 00576 COMTHROW( col3->get_Count(&l)); 00577 00578 if( l == 1) 00579 { 00580 CComPtr<IMgaFCO> newfco; 00581 COMTHROW( coll->get_Item( 1, &newfco)); 00582 00583 CComBSTR new_name(L"Cloned"); new_name.Append(p_existingFcoName); 00584 CComBSTR given_name( p_givenName); 00585 00586 if( newfco) 00587 COMTHROW( newfco->put_Name( given_name == _T("") ? new_name : given_name)); 00588 00589 ASSERT( p_pNewObj); 00590 *p_pNewObj = newfco.Detach(); 00591 } 00592 else 00593 { 00594 ASSERT( 0 ); 00595 return false; 00596 } 00597 00598 return true; 00599 } 00600 00601 00602 BEGIN_MESSAGE_MAP(CGMEOLEIt, CCmdTarget) 00603 //{{AFX_MSG_MAP(CGMEOLEIt) 00604 // NOTE - the ClassWizard will add and remove mapping macros here. 00605 //}}AFX_MSG_MAP 00606 END_MESSAGE_MAP() 00607 00608 00609 BEGIN_DISPATCH_MAP(CGMEOLEIt, CCmdTarget) 00610 //{{AFX_DISPATCH_MAP(CGMEOLEIt) 00611 DISP_PROPERTY_EX(CGMEOLEIt, "Valid", GetValid, SetValid, VT_BOOL) 00612 DISP_PROPERTY_EX(CGMEOLEIt, "Aspects", GetAspects, SetAspects, VT_DISPATCH) 00613 DISP_PROPERTY_EX(CGMEOLEIt, "MgaModel", GetMgaModel, SetMgaModel, VT_DISPATCH) 00614 00615 DISP_FUNCTION(CGMEOLEIt, "Print", Print, VT_EMPTY, VTS_NONE) 00616 DISP_FUNCTION(CGMEOLEIt, "PrintDialog", PrintDialog, VT_EMPTY, VTS_NONE) 00617 DISP_FUNCTION(CGMEOLEIt, "DumpWindowsMetaFile", DumpWindowsMetaFile, VT_EMPTY, VTS_BSTR) 00618 DISP_FUNCTION(CGMEOLEIt, "CheckConstraints", CheckConstraints, VT_EMPTY, VTS_NONE) 00619 DISP_FUNCTION(CGMEOLEIt, "RunComponent", RunComponent, VT_EMPTY, VTS_BSTR) 00620 DISP_FUNCTION(CGMEOLEIt, "RunComponentDialog", RunComponentDialog, VT_EMPTY, VTS_NONE) 00621 DISP_FUNCTION(CGMEOLEIt, "Close", Close, VT_EMPTY, VTS_NONE) 00622 DISP_FUNCTION(CGMEOLEIt, "GrayOutFCO", GrayOutFCO, VT_EMPTY, VTS_BOOL VTS_BOOL VTS_DISPATCH) 00623 DISP_FUNCTION(CGMEOLEIt, "GrayOutHide", GrayOutHide, VT_EMPTY, VTS_NONE) 00624 DISP_FUNCTION(CGMEOLEIt, "ShowSetMembers", ShowSetMembers, VT_EMPTY, VTS_DISPATCH) 00625 DISP_FUNCTION(CGMEOLEIt, "HideSetMembers", HideSetMembers, VT_EMPTY, VTS_NONE) 00626 DISP_FUNCTION(CGMEOLEIt, "Zoom", Zoom, VT_EMPTY, VTS_I4) 00627 DISP_FUNCTION(CGMEOLEIt, "ZoomTo", ZoomTo, VT_EMPTY, VTS_DISPATCH) 00628 DISP_FUNCTION(CGMEOLEIt, "Scroll", Scroll, VT_EMPTY, VTS_I2 VTS_I2) 00629 DISP_FUNCTION(CGMEOLEIt, "DumpModelGeometryXML", DumpModelGeometryXML, VT_EMPTY, VTS_BSTR) 00630 00631 00632 DISP_FUNCTION(CGMEOLEIt, "ShowFCO", ShowFCO, VT_EMPTY, VTS_BSTR VTS_BOOL) 00633 DISP_FUNCTION(CGMEOLEIt, "ShowFCOPtr", ShowFCOPtr, VT_EMPTY, VTS_DISPATCH VTS_BOOL) 00634 DISP_FUNCTION(CGMEOLEIt, "Child", Child, VT_DISPATCH, VTS_BSTR) 00635 DISP_FUNCTION(CGMEOLEIt, "Create", Create, VT_DISPATCH, VTS_BSTR VTS_BSTR) 00636 DISP_FUNCTION(CGMEOLEIt, "CreateInChild", CreateInChild, VT_DISPATCH, VTS_BSTR VTS_BSTR VTS_BSTR) 00637 DISP_FUNCTION(CGMEOLEIt, "CreateInChildFCO", CreateInChildFCO, VT_DISPATCH, VTS_DISPATCH VTS_BSTR VTS_BSTR) 00638 DISP_FUNCTION(CGMEOLEIt, "Duplicate", Duplicate, VT_DISPATCH, VTS_BSTR VTS_BSTR) 00639 DISP_FUNCTION(CGMEOLEIt, "DuplicateFCO", DuplicateFCO, VT_DISPATCH, VTS_DISPATCH VTS_BSTR) 00640 DISP_FUNCTION(CGMEOLEIt, "Rename", Rename, VT_EMPTY, VTS_BSTR VTS_BSTR) 00641 DISP_FUNCTION(CGMEOLEIt, "SetName", SetName, VT_EMPTY, VTS_DISPATCH VTS_BSTR) 00642 DISP_FUNCTION(CGMEOLEIt, "Include", Include, VT_EMPTY, VTS_BSTR VTS_BSTR) 00643 DISP_FUNCTION(CGMEOLEIt, "IncludeFCO", IncludeFCO, VT_EMPTY, VTS_DISPATCH VTS_DISPATCH) 00644 DISP_FUNCTION(CGMEOLEIt, "Exclude", Exclude, VT_EMPTY, VTS_BSTR VTS_BSTR) 00645 DISP_FUNCTION(CGMEOLEIt, "ExcludeFCO", ExcludeFCO, VT_EMPTY, VTS_DISPATCH VTS_DISPATCH) 00646 DISP_FUNCTION(CGMEOLEIt, "Connect", Connect, VT_DISPATCH, VTS_BSTR VTS_BSTR VTS_BSTR) 00647 DISP_FUNCTION(CGMEOLEIt, "Disconnect", Disconnect, VT_EMPTY, VTS_BSTR VTS_BSTR VTS_BSTR) 00648 DISP_FUNCTION(CGMEOLEIt, "ConnectThruPort", ConnectThruPort, VT_DISPATCH, VTS_BSTR VTS_BSTR VTS_BSTR VTS_BSTR VTS_BSTR) 00649 DISP_FUNCTION(CGMEOLEIt, "ConnectThruPortFCO", ConnectThruPortFCO, VT_DISPATCH, VTS_DISPATCH VTS_DISPATCH VTS_DISPATCH VTS_DISPATCH VTS_BSTR) 00650 DISP_FUNCTION(CGMEOLEIt, "DisconnectThruPort", DisconnectThruPort, VT_EMPTY, VTS_BSTR VTS_BSTR VTS_BSTR VTS_BSTR VTS_BSTR) 00651 DISP_FUNCTION(CGMEOLEIt, "ConnectFCOs", ConnectFCOs, VT_DISPATCH, VTS_DISPATCH VTS_DISPATCH VTS_BSTR) 00652 DISP_FUNCTION(CGMEOLEIt, "DisconnectFCOs", DisconnectFCOs, VT_EMPTY, VTS_DISPATCH VTS_DISPATCH VTS_BSTR) 00653 DISP_FUNCTION(CGMEOLEIt, "Refer", Refer, VT_EMPTY, VTS_BSTR VTS_BSTR) 00654 DISP_FUNCTION(CGMEOLEIt, "ClearRef", ClearRef, VT_EMPTY, VTS_BSTR) 00655 DISP_FUNCTION(CGMEOLEIt, "FollowRef", FollowRef, VT_EMPTY, VTS_BSTR) 00656 DISP_FUNCTION(CGMEOLEIt, "ReferFCO", ReferFCO, VT_EMPTY, VTS_DISPATCH VTS_DISPATCH) 00657 DISP_FUNCTION(CGMEOLEIt, "ClearRefFCO", ClearRefFCO, VT_EMPTY, VTS_DISPATCH) 00658 DISP_FUNCTION(CGMEOLEIt, "FollowRefFCO", FollowRefFCO, VT_EMPTY, VTS_DISPATCH) 00659 DISP_FUNCTION(CGMEOLEIt, "NullFCO", NullFCO, VT_DISPATCH, VTS_NONE) 00660 00661 DISP_FUNCTION(CGMEOLEIt, "SetAttribute", SetAttribute, VT_EMPTY, VTS_BSTR VTS_BSTR VTS_VARIANT) 00662 DISP_FUNCTION(CGMEOLEIt, "GetAttribute", GetAttribute, VT_VARIANT, VTS_BSTR VTS_BSTR) 00663 00664 DISP_FUNCTION(CGMEOLEIt, "SetAttributeFCO", SetAttributeFCO, VT_EMPTY, VTS_DISPATCH VTS_BSTR VTS_VARIANT) 00665 DISP_FUNCTION(CGMEOLEIt, "GetAttributeFCO", GetAttributeFCO, VT_VARIANT, VTS_DISPATCH VTS_BSTR) 00666 00667 DISP_FUNCTION(CGMEOLEIt, "SubType", SubType, VT_DISPATCH, VTS_BSTR VTS_BSTR) 00668 DISP_FUNCTION(CGMEOLEIt, "Instantiate", Instantiate, VT_DISPATCH, VTS_BSTR VTS_BSTR) 00669 00670 DISP_FUNCTION(CGMEOLEIt, "SubTypeFCO", SubTypeFCO, VT_DISPATCH, VTS_DISPATCH VTS_BSTR) 00671 DISP_FUNCTION(CGMEOLEIt, "InstantiateFCO", InstantiateFCO, VT_DISPATCH, VTS_DISPATCH VTS_BSTR) 00672 00673 DISP_FUNCTION(CGMEOLEIt, "BeginTransaction", BeginTransaction, VT_EMPTY, VTS_NONE) 00674 DISP_FUNCTION(CGMEOLEIt, "CommitTransaction", CommitTransaction, VT_EMPTY, VTS_NONE) 00675 DISP_FUNCTION(CGMEOLEIt, "AbortTransaction", AbortTransaction, VT_EMPTY, VTS_NONE) 00676 DISP_FUNCTION(CGMEOLEIt, "IsInTransaction", IsInTransaction, VT_BOOL, VTS_NONE) 00677 DISP_FUNCTION(CGMEOLEIt, "PutInTerritory", PutInTerritory, VT_DISPATCH, VTS_DISPATCH) 00678 00679 DISP_FUNCTION(CGMEOLEIt, "Help", Help, VT_EMPTY, VTS_NONE ) 00680 00681 DISP_FUNCTION(CGMEOLEIt, "SetSelected", SetSelected, VT_EMPTY, VTS_BSTR) 00682 DISP_FUNCTION(CGMEOLEIt, "GetSelected", GetSelected, VT_BSTR, VTS_NONE) 00683 DISP_FUNCTION(CGMEOLEIt, "SetSelectedFCOs", SetSelectedFCOs, VT_EMPTY, VTS_DISPATCH) 00684 DISP_FUNCTION(CGMEOLEIt, "GetSelectedFCOs", GetSelectedFCOs, VT_DISPATCH, VTS_NONE) 00685 00686 DISP_FUNCTION(CGMEOLEIt, "GetCurrentAspect", GetCurrentAspect, VT_HRESULT, VTS_BSTR) 00687 DISP_FUNCTION(CGMEOLEIt, "SetCurrentAspect", SetCurrentAspect, VT_HRESULT, VTS_BSTR) 00688 DISP_FUNCTION(CGMEOLEIt, "NextAspect", NextAspect, VT_EMPTY, VTS_NONE) 00689 DISP_FUNCTION(CGMEOLEIt, "PrevAspect", PrevAspect, VT_EMPTY, VTS_NONE) 00690 DISP_FUNCTION(CGMEOLEIt, "Next", Next, VT_EMPTY, VTS_NONE) 00691 DISP_FUNCTION(CGMEOLEIt, "Prev", Prev, VT_EMPTY, VTS_NONE) 00692 DISP_FUNCTION(CGMEOLEIt, "Position", Position, VT_EMPTY, VTS_BSTR VTS_BSTR VTS_I4 VTS_I4) 00693 DISP_FUNCTION(CGMEOLEIt, "PositionFCO", PositionFCO, VT_EMPTY, VTS_DISPATCH VTS_BSTR VTS_I4 VTS_I4) 00694 00695 00696 //}}AFX_DISPATCH_MAP 00697 END_DISPATCH_MAP() 00698 00699 00700 BEGIN_INTERFACE_MAP(CGMEOLEIt, CCmdTarget) 00701 INTERFACE_PART(CGMEOLEIt, __uuidof(IGMEOLEIt), Dual) 00702 DUAL_ERRORINFO_PART(CGMEOLEIt) 00703 END_INTERFACE_MAP() 00704 00706 // CGMEOLEIt message handlers 00707 00708 00709 BOOL CGMEOLEIt::GetValid() 00710 { 00711 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::GetValid()\r\n")); 00712 00713 return AmIValid() ? TRUE : FALSE; 00714 } 00715 00716 void CGMEOLEIt::SetValid(BOOL) 00717 { 00718 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::SetValid()\r\n")); 00719 00720 SetNotSupported(); 00721 } 00722 00723 LPDISPATCH CGMEOLEIt::GetMgaModel() 00724 { 00725 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::GetMgaModel()\r\n")); 00726 00727 PRECONDITION_VALID_MODEL // calls AmIValid 00728 00729 ASSERT( m_theView); 00730 ASSERT( m_theMgaModel); 00731 00732 CComObjPtr<IMgaTerritory> territory; 00733 COMTHROW( theApp.mgaProject->get_ActiveTerritory( PutOut( territory))); 00734 00735 if( territory) 00736 { 00737 // if transaction is going on, then put the pointer 00738 // into its territory 00739 CComObjPtr<IMgaObject> obj; 00740 COMTHROW(territory->OpenObj( m_theMgaModel, PutOut(obj))); 00741 CComObjPtr<IMgaModel> model; 00742 COMTHROW(obj.QueryInterface( model)); 00743 00744 return model.Detach(); 00745 } 00746 else 00747 { 00748 CComObjPtr<IMgaModel> model( m_theMgaModel); 00749 return model.Detach(); 00750 } 00751 } 00752 00753 void CGMEOLEIt::SetMgaModel(LPDISPATCH) 00754 { 00755 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::SetMgaModel()\r\n")); 00756 00757 SetNotSupported(); 00758 } 00759 00760 void CGMEOLEIt::Print() 00761 { 00762 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::Print()\r\n")); 00763 00764 PRECONDITION_VALID_MODEL 00765 00766 m_theView->SendMessage(WM_COMMAND, ID_FILE_PRINT_DIRECT); 00767 } 00768 00769 void CGMEOLEIt::PrintDialog() 00770 { 00771 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::PrintDialog()\r\n")); 00772 00773 PRECONDITION_VALID_MODEL 00774 00775 m_theView->SendMessage(WM_COMMAND, ID_FILE_PRINT); 00776 00777 } 00778 00779 void CGMEOLEIt::DumpWindowsMetaFile(LPCTSTR filePath) 00780 { 00781 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::DumpWindowsMetaFile()\r\n")); 00782 00783 PRECONDITION_VALID_MODEL 00784 00785 CMetaFileDC cDC; 00786 BOOL ret = cDC.CreateEnhanced(m_theView->GetDC(),filePath,NULL,_T("GME Model")); 00787 if (ret == FALSE) { 00788 AfxMessageBox(_T("Unable to create metafile."), MB_OK | MB_ICONSTOP); 00789 return; 00790 } 00791 00792 cDC.m_bPrinting = TRUE; // HACK by Peter (c) 00793 m_theView->OnDraw(&cDC); 00794 00795 HENHMETAFILE hEmf = cDC.CloseEnhanced(); 00796 if ( hEmf ) { 00797 DeleteEnhMetaFile(hEmf); 00798 } 00799 } 00800 00801 void CGMEOLEIt::CheckConstraints() 00802 { 00803 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::CheckConstraints()\r\n")); 00804 00805 PRECONDITION_VALID_MODEL 00806 PRECONDITION_ACTIVE_CONSTMGR 00807 00808 m_theView->OnFileCheck(); 00809 } 00810 00811 void CGMEOLEIt::RunComponent(LPCTSTR appID) 00812 { 00813 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::RunComponent()\r\n")); 00814 00815 PRECONDITION_VALID_MODEL 00816 00817 m_theView->RunComponent(appID); 00818 } 00819 00820 void CGMEOLEIt::RunComponentDialog() 00821 { 00822 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::RunComponentDialog()\r\n")); 00823 00824 PRECONDITION_VALID_MODEL 00825 00826 m_theView->RunComponent(_T("")); 00827 } 00828 00829 LPDISPATCH CGMEOLEIt::GetAspects() 00830 { 00831 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::GetAspects()\r\n")); 00832 00833 PRECONDITION_VALID_MODEL 00834 00835 CGMEOLEColl* coll = new CGMEOLEColl(); 00836 00837 POSITION pos = m_theView->guiMeta->aspects.GetHeadPosition(); 00838 while (pos) { 00839 CGuiMetaAspect* guiaspect = (CGuiMetaAspect*)(m_theView->guiMeta->aspects.GetNext(pos)); 00840 ASSERT(guiaspect); 00841 CGMEOLEAspect* aspect = new CGMEOLEAspect(); 00842 aspect->SetGuiParams(m_theView, guiaspect); 00843 coll->Add(aspect->GetIDispatch(FALSE)); 00844 aspect->GetIDispatch(FALSE)->Release(); // We do not hold reference, hopefully the collection will hold one 00845 } 00846 00847 return coll->GetIDispatch(FALSE); 00848 } 00849 00850 void CGMEOLEIt::SetAspects(LPDISPATCH) 00851 { 00852 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::SetAspects()\r\n")); 00853 00854 SetNotSupported(); 00855 } 00856 00857 void CGMEOLEIt::Close() 00858 { 00859 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::Close()\r\n")); 00860 00861 PRECONDITION_VALID_MODEL; 00862 00863 m_theView->GetParentFrame()->DestroyWindow(); 00864 } 00865 00866 void CGMEOLEIt::GrayOutFCO(BOOL bGray, BOOL bNeighbours, LPDISPATCH mgaFCOs) 00867 { 00868 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::GrayOutFCO()\r\n")); 00869 00870 PRECONDITION_VALID_MODEL; 00871 00872 if (CGMEDoc::theInstance) 00873 CGMEDoc::theInstance->SetMode(5); 00874 00875 CComPtr<IDispatch> alienFCOs(mgaFCOs); 00876 CComPtr<IMgaFCOs> mFCOColl; 00877 if (!SUCCEEDED(alienFCOs.QueryInterface(&mFCOColl))) { 00878 return; 00879 } 00880 00881 long l = 0; 00882 COMTHROW( mFCOColl->get_Count( &l )); 00883 00884 for( long i = 1; i <= l; ++i) 00885 { 00886 CComPtr<IMgaFCO> item; 00887 COMTHROW( mFCOColl->get_Item( i, &item)); 00888 00889 // collection is coming from an unknown territory, do not use it as-is. (except for this search) 00890 CGuiObject *gObj = CGuiObject::FindObject(item, m_theView->children); 00891 CGuiConnection *gConn = CGuiConnection::FindConnection(item, m_theView->connections); 00892 00893 if (gObj) { 00894 gObj->GrayOut(bGray == TRUE); 00895 if (bNeighbours == TRUE) { 00896 gObj->GrayOutNeighbors(); 00897 } 00898 CGuiFco::GrayOutNonInternalConnections(m_theView->connections); 00899 } 00900 else if (gConn) { 00901 gConn->GrayOut(bGray == TRUE); 00902 gConn->GrayOutEndPoints(); 00903 if (bNeighbours == TRUE) { 00904 CGuiFco::GrayOutNonInternalConnections(m_theView->connections); 00905 } 00906 } 00907 } 00908 00909 m_theView->Invalidate(); 00910 } 00911 00912 void CGMEOLEIt::GrayOutHide() 00913 { 00914 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::GrayOutHide()\r\n")); 00915 00916 PRECONDITION_VALID_MODEL; 00917 00918 if (CGMEDoc::theInstance) 00919 CGMEDoc::theInstance->SetMode(5); 00920 00921 CGuiFco::GrayOutFcos(m_theView->children, TRUE); 00922 CGuiFco::GrayOutFcos(m_theView->connections, TRUE); 00923 m_theView->Invalidate(); 00924 } 00925 00926 void CGMEOLEIt::ShowSetMembers(LPDISPATCH mgaFCO) 00927 { 00928 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::ShowSetMembers()\r\n")); 00929 00930 PRECONDITION_VALID_MODEL; 00931 00932 if (CGMEDoc::theInstance) 00933 CGMEDoc::theInstance->SetMode(3); 00934 00935 CGuiFco::GrayOutFcos(m_theView->children, TRUE); 00936 00937 CComPtr<IDispatch> alienFCO(mgaFCO); 00938 CComPtr<IMgaFCO> mFCO; 00939 if (!SUCCEEDED(alienFCO.QueryInterface(&mFCO))) 00940 return; 00941 00942 // mgaFCO is comming from an unknown territory, do not use it as-is. (except for this search) 00943 CGuiObject *gObj = CGuiObject::FindObject(mFCO, m_theView->children); 00944 if (gObj) 00945 { 00946 gObj->GrayOut(false); 00947 00948 // members of the set too 00949 CComPtr<IMgaSet> mSet; 00950 if (!SUCCEEDED(mFCO.QueryInterface(&mSet))) 00951 return; 00952 m_theView->BeginTransaction(); 00953 00954 try 00955 { 00956 CComPtr<IMgaFCOs> mSetMembers = NULL; 00957 COMTHROW(mSet->get_Members(&mSetMembers)); 00958 00959 long num = 0; 00960 COMTHROW(mSetMembers->get_Count(&num)); 00961 for (int i=1; i<=num; i++) 00962 { 00963 CComPtr<IMgaFCO> memb = NULL; 00964 COMTHROW(mSetMembers->get_Item(i, &memb)); 00965 CGuiObject *gObj = CGuiObject::FindObject(memb, m_theView->children); 00966 if (gObj) 00967 gObj->GrayOut(false); 00968 } 00969 m_theView->CommitTransaction(); 00970 } 00971 catch(hresult_exception &e) 00972 { 00973 m_theView->AbortTransaction(e.hr); 00974 } 00975 } 00976 00977 m_theView->Invalidate(); 00978 } 00979 00980 void CGMEOLEIt::HideSetMembers() 00981 { 00982 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::HideSetMembers()\r\n")); 00983 00984 PRECONDITION_VALID_MODEL; 00985 00986 if (CGMEDoc::theInstance) 00987 CGMEDoc::theInstance->SetMode(3); 00988 00989 CGuiFco::GrayOutFcos(m_theView->children, TRUE); 00990 m_theView->Invalidate(); 00991 } 00992 00993 void CGMEOLEIt::Zoom(long percent) 00994 { 00995 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::Zoom()\r\n")); 00996 00997 PRECONDITION_VALID_MODEL; 00998 00999 m_theView->ZoomPercent(percent); 01000 m_theView->Invalidate(); 01001 } 01002 01003 void CGMEOLEIt::ZoomTo(LPDISPATCH mgaFCOs) 01004 { 01005 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::ZoomTo()\r\n")); 01006 01007 PRECONDITION_VALID_MODEL; 01008 01009 if (CGMEDoc::theInstance) 01010 CGMEDoc::theInstance->SetMode(4); 01011 01012 CComPtr<IDispatch> disp(mgaFCOs); 01013 CComPtr<IMgaFCOs> fcos; 01014 if (!SUCCEEDED(disp.QueryInterface(&fcos))) 01015 return; 01016 01017 // calculate the total size of them 01018 CRect totalr(0,0,0,0); 01019 m_theView->BeginTransaction(); 01020 try 01021 { 01022 long num = 0; 01023 COMTHROW(fcos->get_Count(&num)); 01024 for (int i=1; i<=num; i++) 01025 { 01026 CComPtr<IMgaFCO> memb = NULL; 01027 COMTHROW(fcos->get_Item(i, &memb)); 01028 // size ?? 01029 CGuiObject *gObj = CGuiObject::FindObject(memb, m_theView->children); 01030 if (gObj) 01031 { 01032 CRect rec = gObj->GetLocation(); 01033 totalr.UnionRect(totalr, rec); 01034 } 01035 } 01036 m_theView->CommitTransaction(); 01037 } 01038 catch(hresult_exception &e) 01039 { 01040 m_theView->AbortTransaction(e.hr); 01041 } 01042 01043 m_theView->ZoomToFCOs(totalr); 01044 m_theView->Invalidate(); 01045 01046 } 01047 01048 void CGMEOLEIt::Scroll(long bar, long scroll) 01049 { 01050 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::Scroll()\r\n")); 01051 01052 PRECONDITION_VALID_MODEL; 01053 01054 UINT code = SB_LINEDOWN; 01055 switch (scroll) 01056 { 01057 case 0: 01058 code = SB_LINEUP; 01059 break; 01060 case 1: 01061 code = SB_LINEDOWN; 01062 break; 01063 case 2: 01064 code = SB_PAGEUP; 01065 break; 01066 case 3: 01067 code = SB_PAGEDOWN; 01068 break; 01069 case 4: 01070 code = SB_TOP; 01071 break; 01072 case 5: 01073 code = SB_BOTTOM; 01074 break; 01075 } 01076 01077 if (bar == 0) 01078 m_theView->OnHScroll(code, 1, NULL); 01079 else 01080 m_theView->OnVScroll(code, 1, NULL); 01081 01082 m_theView->Invalidate(); 01083 } 01084 01085 void CGMEOLEIt::DumpModelGeometryXML(LPCTSTR filePath) 01086 { 01087 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::DumpModelGeometryXML()\r\n")); 01088 01089 PRECONDITION_VALID_MODEL 01090 01091 HRESULT hr = m_theView->DumpModelGeometryXML(filePath); 01092 if (FAILED(hr)) 01093 { 01094 _bstr_t err; 01095 GetErrorInfo(err.GetAddress()); 01096 if (err.length()) 01097 AfxThrowOleDispatchException(201, err); 01098 } 01099 } 01100 01101 //static 01102 CComPtr<IMgaObject> CGMEOLEIt::myParent( const CComPtr<IMgaObject>& obj) 01103 { 01104 if( !obj) return 0; 01105 01106 CComPtr<IMgaModel> parent_m; 01107 CComPtr<IMgaFolder> parent_f; 01108 01109 CComQIPtr<IMgaFCO> fco( obj); 01110 if( fco) 01111 { 01112 COMTHROW( fco->get_ParentModel( &parent_m)); 01113 if ( !parent_m) 01114 COMTHROW( fco->get_ParentFolder( &parent_f)); 01115 }else 01116 { 01117 CComQIPtr<IMgaFolder> fol( obj); 01118 if( !fol) 01119 return 0; 01120 COMTHROW( fol->get_ParentFolder( &parent_f)); 01121 } 01122 01123 return parent_m ? CComPtr<IMgaObject>(parent_m) : CComPtr<IMgaObject>(parent_f); 01124 } 01125 01126 //static 01127 CComPtr<IMgaFCO> CGMEOLEIt::fcoByPath( const CComPtr<IMgaModel>& mod, LPCTSTR p_objPath) 01128 { 01129 // can handle absolute paths: those which start with '/' ie.> '/MainModel1' 01130 // can handle actual model reference with './' ie.> './sybling' 01131 // can step up one step in hierarchy with '..' ie.> '../../fco1' 01132 CComPtr<IMgaObject> newparent = mod; 01133 01134 LPCTSTR path_ptr = p_objPath; 01135 if( *path_ptr == '/') // absolute path used, starting from rootfolder 01136 { 01137 ++path_ptr; 01138 CComPtr<IMgaObject> t_par; // to store the last valid value 01139 while( newparent) // go up in the hierarchy until rootfolder 01140 { 01141 t_par = newparent; 01142 newparent = myParent( newparent); 01143 } 01144 newparent = t_par; // the last non null value is the rootfolder 01145 } 01146 01147 01148 std::wstring path( path_ptr); 01149 if( path.compare( _T("./")) == 0) return CComPtr<IMgaFCO>( mod); 01150 01151 bool went_up = false; 01152 bool null_ptr_found = newparent == 0; 01153 while( !null_ptr_found && !path.empty() && 01154 ( path.compare(_T("..")) == 0 01155 || path.substr(0, 3).compare( _T("../")) == 0)) 01156 { 01157 newparent = myParent( newparent); 01158 null_ptr_found = newparent == 0; 01159 went_up = true; 01160 01161 if( path.length() > 2) path = path.substr( 3); // passing one directory : '../' 01162 else path = _T(""); 01163 } 01164 01165 if( null_ptr_found) // rootfolder reached => invalid path 01166 return 0; 01167 01168 if( path.empty() && went_up ) // thus allow '../../' as input, but if did not go up, then interpret the '' as empty child name 01169 return CComQIPtr<IMgaFCO>( newparent); 01170 01171 CComBSTR b_path( path.c_str()); 01172 CComPtr<IMgaObject> obj_ptr; 01173 newparent->get_ObjectByPath( b_path, &obj_ptr); 01174 01175 return CComQIPtr<IMgaFCO>( obj_ptr); 01176 } 01177 01178 void CGMEOLEIt::ShowFCO( LPCTSTR p_objName, BOOL p_inParent) 01179 { 01180 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::ShowFCO\r\n")); 01181 01182 PRECONDITION_VALID_MODEL // calls AmIValid 01183 01184 ASSERT( m_theView); 01185 ASSERT( m_theMgaModel); 01186 01187 CComPtr<IMgaFCO> obj_ptr; 01188 start(); 01189 try 01190 { 01191 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 01192 THROW_IF_NULL( model, _T("Invalid parent model")); 01193 01194 obj_ptr = fcoByPath( model, p_objName); 01195 } 01196 CATCHALL_AND_CALL_END; 01197 01198 if( obj_ptr && CMainFrame::theInstance != NULL ) 01199 { 01200 CMainFrame::theInstance->mGmeOleApp->ShowFCO( obj_ptr, p_inParent); 01201 } 01202 } 01203 01204 void CGMEOLEIt::ShowFCOPtr( LPDISPATCH p_obj, BOOL p_inParent) 01205 { 01206 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::ShowFCOPtr\r\n")); 01207 01208 PRECONDITION_VALID_MODEL // calls AmIValid 01209 01210 ASSERT( m_theView); 01211 ASSERT( m_theMgaModel); 01212 01213 CComQIPtr<IMgaFCO> obj_ptr( p_obj); 01214 01215 if( obj_ptr && CMainFrame::theInstance != NULL ) 01216 { 01217 CMainFrame::theInstance->mGmeOleApp->ShowFCO( obj_ptr, p_inParent); 01218 } 01219 } 01220 01221 LPDISPATCH CGMEOLEIt::Child( LPCTSTR p_objName) 01222 { 01223 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::Child\r\n")); 01224 01225 PRECONDITION_VALID_MODEL // calls AmIValid 01226 01227 ASSERT( m_theView); 01228 ASSERT( m_theMgaModel); 01229 01230 CComPtr<IMgaFCO> obj_ptr; 01231 start(); 01232 try 01233 { 01234 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 01235 THROW_IF_NULL( model, _T("Invalid parent model")); 01236 obj_ptr = getChildInByName( model, p_objName); 01237 } 01238 CATCHALL_AND_CALL_END; 01239 return obj_ptr.Detach(); 01240 } 01241 01242 01243 LPDISPATCH CGMEOLEIt::Create( LPCTSTR p_partName, LPCTSTR p_objname) 01244 { 01245 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::Create\r\n")); 01246 01247 PRECONDITION_VALID_MODEL // calls AmIValid 01248 01249 ASSERT( m_theView); 01250 ASSERT( m_theMgaModel); 01251 01252 CComPtr<IMgaFCO> obj_ptr; 01253 start(); 01254 try 01255 { 01256 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 01257 THROW_IF_NULL( model, _T("Invalid parent model")); 01258 createObjs( model, p_partName, p_objname, &obj_ptr); 01259 } 01260 CATCHALL_AND_CALL_END; 01261 return obj_ptr.Detach(); 01262 } 01263 01264 LPDISPATCH CGMEOLEIt::CreateInChild( LPCTSTR p_childAsParent, LPCTSTR p_part, LPCTSTR p_objname) 01265 { 01266 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::CreateInChild\r\n")); 01267 01268 PRECONDITION_VALID_MODEL // calls AmIValid 01269 01270 ASSERT( m_theView); 01271 ASSERT( m_theMgaModel); 01272 01273 CComPtr<IMgaFCO> obj_ptr; 01274 start(); 01275 try 01276 { 01277 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 01278 THROW_IF_NULL( model, _T("Invalid parent model")); 01279 01280 CComQIPtr<IMgaModel> child( getChildInByName( model, p_childAsParent)); 01281 THROW_IF_NULL( child, _T("Invalid child model specified")); 01282 01283 createObjs( child, p_part, p_objname, &obj_ptr); 01284 } 01285 CATCHALL_AND_CALL_END; 01286 return obj_ptr.Detach(); 01287 } 01288 01289 LPDISPATCH CGMEOLEIt::CreateInChildFCO( LPDISPATCH p_childAsParent, LPCTSTR p_part, LPCTSTR p_objname) 01290 { 01291 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::Create\r\n")); 01292 01293 PRECONDITION_VALID_MODEL // calls AmIValid 01294 01295 ASSERT( m_theView); 01296 ASSERT( m_theMgaModel); 01297 01298 CComPtr<IMgaFCO> obj_ptr; 01299 start(); 01300 try 01301 { 01302 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 01303 THROW_IF_NULL( model, _T("Invalid parent model")); 01304 01305 CComQIPtr<IMgaModel> child( putInTerr( p_childAsParent)); 01306 if( !child || !isValidChildIn( model.p, child.p)) 01307 THROW_IF_NULL( 0, _T("Invalid child model specified")); 01308 01309 createObjs( child, p_part, p_objname, &obj_ptr); 01310 } 01311 CATCHALL_AND_CALL_END; 01312 return obj_ptr.Detach(); 01313 } 01314 01315 01316 LPDISPATCH CGMEOLEIt::Duplicate( LPCTSTR p_existingObjName, LPCTSTR p_objName) 01317 { 01318 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::Duplicate\r\n")); 01319 01320 PRECONDITION_VALID_MODEL // calls AmIValid 01321 01322 ASSERT( m_theView); 01323 ASSERT( m_theMgaModel); 01324 01325 CComPtr<IMgaFCO> obj_ptr; 01326 start(); 01327 try 01328 { 01329 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 01330 THROW_IF_NULL( model, _T("Invalid parent model")); 01331 CComPtr<IMgaFCO> exist_obj( getChildInByName( model, p_existingObjName)); 01332 THROW_IF_NULL( exist_obj, _T("Duplicable object not found")); 01333 cloneObjs( model, exist_obj, _T("") , p_objName, &obj_ptr); 01334 } 01335 CATCHALL_AND_CALL_END; 01336 return obj_ptr.Detach(); 01337 } 01338 01339 LPDISPATCH CGMEOLEIt::DuplicateFCO( LPDISPATCH p_existingFCO, LPCTSTR p_objName) 01340 { 01341 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::DuplicateFCO\r\n")); 01342 01343 PRECONDITION_VALID_MODEL // calls AmIValid 01344 01345 ASSERT( m_theView); 01346 ASSERT( m_theMgaModel); 01347 01348 CComPtr<IMgaFCO> obj_ptr; 01349 start(); 01350 try 01351 { 01352 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 01353 THROW_IF_NULL( model, _T("Invalid parent model")); 01354 CComQIPtr<IMgaFCO> exist_fco( putInTerr( p_existingFCO)); 01355 THROW_IF_NULL( exist_fco, _T("Invalid object pointer")); 01356 01357 cloneObjs( model, exist_fco, _T(""), p_objName, &obj_ptr); 01358 } 01359 CATCHALL_AND_CALL_END; 01360 01361 return obj_ptr.Detach(); 01362 } 01363 01364 void CGMEOLEIt::Rename( LPCTSTR p_oldName, LPCTSTR p_newName) 01365 { 01366 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::Rename\r\n")); 01367 01368 PRECONDITION_VALID_MODEL // calls AmIValid 01369 01370 ASSERT( m_theView); 01371 ASSERT( m_theMgaModel); 01372 01373 start(); 01374 try 01375 { 01376 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 01377 THROW_IF_NULL( model, _T("Invalid parent model")); 01378 CComPtr<IMgaFCO> child( getChildInByName( model, p_oldName)); 01379 THROW_IF_NULL( child, _T("Object not found")); 01380 01381 rename( child, p_newName); 01382 } 01383 CATCHALL_AND_CALL_END; 01384 } 01385 01386 void CGMEOLEIt::SetName( LPDISPATCH p_lpDisp, LPCTSTR p_name) 01387 { 01388 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::SetName\r\n")); 01389 01390 PRECONDITION_VALID_MODEL // calls AmIValid 01391 01392 ASSERT( m_theView); 01393 ASSERT( m_theMgaModel); 01394 01395 start(); 01396 try 01397 { 01398 CComQIPtr<IMgaFCO> child( putInTerr( p_lpDisp)); 01399 THROW_IF_NULL( child, _T("Invalid object pointer")); 01400 01401 rename( child, p_name); 01402 } 01403 CATCHALL_AND_CALL_END; 01404 } 01405 01406 void CGMEOLEIt::Include( LPCTSTR psetnm, LPCTSTR pfconm) 01407 { 01408 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::Include\r\n")); 01409 01410 PRECONDITION_VALID_MODEL // calls AmIValid 01411 01412 ASSERT( m_theView); 01413 ASSERT( m_theMgaModel); 01414 01415 start(); 01416 try 01417 { 01418 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 01419 THROW_IF_NULL( model, _T("Invalid parent model")); 01420 CComQIPtr<IMgaSet> set( getChildInByName( model, psetnm)); 01421 THROW_IF_NULL( set, _T("Set not found")); 01422 CComPtr<IMgaFCO> fco( getChildInByName( model, pfconm)); 01423 THROW_IF_NULL( fco, _T("Member Fco not found")); 01424 01425 COMTHROW( set->AddMember( fco )); 01426 } 01427 CATCHALL_AND_CALL_END; 01428 } 01429 01430 void CGMEOLEIt::IncludeFCO( LPDISPATCH pset, LPDISPATCH pfco) 01431 { 01432 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::IncludeFCO\r\n")); 01433 01434 PRECONDITION_VALID_MODEL // calls AmIValid 01435 01436 ASSERT( m_theView); 01437 ASSERT( m_theMgaModel); 01438 01439 start(); 01440 try 01441 { 01442 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 01443 THROW_IF_NULL( model, _T("Invalid parent model")); 01444 CComQIPtr<IMgaSet> set( putInTerr( pset)); 01445 THROW_IF_NULL( set, _T("Invalid set pointer")); 01446 CComQIPtr<IMgaFCO> fco( putInTerr( pfco)); 01447 THROW_IF_NULL( fco, _T("Invalid Member Fco pointer")); 01448 01449 // in case of sets we require that the set and fco must be in the same model: 01450 if( isValidChildIn( model.p, set.p) && isValidChildIn( model.p, fco.p)) 01451 COMTHROW( set->AddMember( fco )); 01452 } 01453 CATCHALL_AND_CALL_END; 01454 } 01455 void CGMEOLEIt::Exclude( LPCTSTR psetnm, LPCTSTR pfconm) 01456 { 01457 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::Exclude\r\n")); 01458 01459 PRECONDITION_VALID_MODEL // calls AmIValid 01460 01461 ASSERT( m_theView); 01462 ASSERT( m_theMgaModel); 01463 01464 start(); 01465 try 01466 { 01467 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 01468 THROW_IF_NULL( model, _T("Invalid parent model")); 01469 01470 CComQIPtr<IMgaSet> set( getChildInByName( model, psetnm)); 01471 THROW_IF_NULL( set, _T("Set not found")); 01472 CComPtr<IMgaFCO> fco( getChildInByName( model, pfconm)); 01473 THROW_IF_NULL( fco, _T("Member Fco not found")); 01474 01475 COMTHROW( set->RemoveMember( fco )); 01476 } 01477 CATCHALL_AND_CALL_END; 01478 } 01479 void CGMEOLEIt::ExcludeFCO( LPDISPATCH pset, LPDISPATCH pfco) 01480 { 01481 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::ExcludeFCO\r\n")); 01482 01483 PRECONDITION_VALID_MODEL // calls AmIValid 01484 01485 ASSERT( m_theView); 01486 ASSERT( m_theMgaModel); 01487 01488 start(); 01489 try 01490 { 01491 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 01492 THROW_IF_NULL( model, _T("Invalid parent model")); 01493 01494 CComQIPtr<IMgaSet> set( putInTerr( pset)); 01495 THROW_IF_NULL( set, _T("Invalid Set pointer")); 01496 CComQIPtr<IMgaFCO> fco( putInTerr( pfco)); 01497 THROW_IF_NULL( fco, _T("Invalid Member Fco pointer")); 01498 01499 // in case of sets we require that the set and fco must be in the same model: 01500 if( isValidChildIn( model.p, set.p) && isValidChildIn( model.p, fco.p)) 01501 COMTHROW( set->RemoveMember( fco )); 01502 } 01503 CATCHALL_AND_CALL_END; 01504 } 01505 01506 LPDISPATCH CGMEOLEIt::Connect( LPCTSTR p_srcName, LPCTSTR p_dstName, LPCTSTR p_connName) 01507 { 01508 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::Connect\r\n")); 01509 01510 PRECONDITION_VALID_MODEL // calls AmIValid 01511 01512 ASSERT( m_theView); 01513 ASSERT( m_theMgaModel); 01514 01515 CComPtr<IMgaFCO> new_conn; 01516 start(); 01517 try 01518 { 01519 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 01520 THROW_IF_NULL( model, _T("Invalid parent model")); 01521 CComPtr<IMgaFCO> end1( getChildInByName( model, p_srcName)); 01522 THROW_IF_NULL( end1, _T("Source object not found")); 01523 CComPtr<IMgaFCO> end2( getChildInByName( model, p_dstName)); 01524 THROW_IF_NULL( end2, _T("Destination object not found")); 01525 01526 CComPtr<IMgaMetaRole> metarole; 01527 CComBSTR conn_name( p_connName); 01528 try 01529 { 01530 if( conn_name != _T("")) 01531 metarole = metaRolePtrInByName( model, conn_name); 01532 }catch(...) 01533 { 01534 THROW_IF_BOOL( true, _T("No such connection role found")); 01535 } 01536 01537 if( !metarole) 01538 metarole = connMetaRolePtrInBetween( model, end1, end2 ); // create the only possible connection if 1 exists 01539 01540 THROW_IF_NULL( metarole, _T("No possible connection found")); 01541 COMTHROW( model->CreateSimpleConn( metarole, end1, end2, 0, 0, &new_conn)); 01542 } 01543 CATCHALL_AND_CALL_END; 01544 01545 return new_conn.Detach(); 01546 } 01547 01548 void CGMEOLEIt::Disconnect( LPCTSTR p_srcName, LPCTSTR p_dstName, LPCTSTR p_connName) 01549 { 01550 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::Disconnect\r\n")); 01551 01552 PRECONDITION_VALID_MODEL // calls AmIValid 01553 01554 ASSERT( m_theView); 01555 ASSERT( m_theMgaModel); 01556 01557 bool found_any = false; 01558 start(); 01559 try 01560 { 01561 CComBSTR src_role( L"src"); 01562 CComBSTR dst_role( L"dst"); 01563 01564 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 01565 THROW_IF_NULL( model, _T("Invalid parent model")); 01566 01567 CComPtr<IMgaFCO> end1( getChildInByName( model, p_srcName)); 01568 THROW_IF_NULL( end1, _T("Source object not found")); 01569 CComPtr<IMgaFCO> end2( getChildInByName( model, p_dstName)); 01570 THROW_IF_NULL( end2, _T("Destination object not found")); 01571 // will look for a connection between end1 and end2 01572 01573 CComObjPtrVector<IMgaFCO> children; 01574 COMTHROW( model->get_ChildFCOs( PutOut( children ))); 01575 01576 CComObjPtrVector<IMgaFCO>::iterator ch_it = children.begin(); 01577 CComObjPtrVector<IMgaFCO>::iterator ch_end = children.end(); 01578 for( ; ch_it != ch_end; ++ch_it) 01579 { 01580 if( myTypeIs( CComPtr<IMgaFCO>( (*ch_it).p)) == OBJTYPE_CONNECTION ) 01581 { 01582 CComQIPtr<IMgaConnection> conn( *ch_it); 01583 CComObjPtrVector<IMgaConnPoint> cps; 01584 COMTHROW( conn->get_ConnPoints( PutOut( cps))); 01585 01586 bool src_found = false; 01587 bool dst_found = false; 01588 01589 CComObjPtrVector<IMgaConnPoint>::iterator cp_it = cps.begin(); 01590 CComObjPtrVector<IMgaConnPoint>::iterator cp_end = cps.end(); 01591 for( ; cp_it != cp_end; ++cp_it) 01592 { 01593 CComPtr<IMgaFCO> tg; 01594 COMTHROW( (*cp_it)->get_Target( &tg)); 01595 01596 CComBSTR connrole; 01597 COMTHROW( (*cp_it)->get_ConnRole( &connrole)); 01598 01599 if( connrole == src_role && tg == end1) 01600 { 01601 src_found = true; 01602 } 01603 else if( connrole == dst_role && tg == end2) 01604 { 01605 dst_found = true; 01606 } 01607 } 01608 bool name_checked = true; // name or kind could be checked. The Disconnect uses: NAME 01609 CComBSTR conn_name( p_connName); 01610 if( conn_name != _T("")) // if name provided 01611 { 01612 name_checked = false; 01613 01614 CComBSTR nm; 01615 COMTHROW( conn->get_Name( &nm)); 01616 01617 if( nm == conn_name) 01618 name_checked = true; 01619 01620 } 01621 01622 if( src_found && dst_found && name_checked) // regarding src and dst it is ok 01623 { 01624 COMTHROW( (*ch_it)->DestroyObject()); 01625 found_any = true; 01626 } 01627 } 01628 } 01629 } 01630 CATCHALL_AND_CALL_END; 01631 01632 if( !found_any) 01633 SHOW_ERROR( _T("No connection found")); 01634 } 01635 01636 LPDISPATCH CGMEOLEIt::ConnectThruPort( LPCTSTR p_srcRole1, LPCTSTR p_srcRole2, LPCTSTR p_dstRole1, LPCTSTR p_dstRole2, LPCTSTR p_connName) 01637 { 01638 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::ConnectThruPort\r\n")); 01639 01640 PRECONDITION_VALID_MODEL // calls AmIValid 01641 01642 ASSERT( m_theView); 01643 ASSERT( m_theMgaModel); 01644 01645 CComPtr<IMgaFCO> new_conn; 01646 start(); 01647 try 01648 { 01649 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 01650 THROW_IF_NULL( model, _T("Invalid parent model")); 01651 01652 CComPtr<IMgaFCO> src1( getChildInByName( model, p_srcRole1)); 01653 THROW_IF_NULL( src1, _T("SourceRole1 object not found")); 01654 CComPtr<IMgaFCO> dst1( getChildInByName( model, p_dstRole1)); 01655 THROW_IF_NULL( dst1, _T("DestinationRole1 object not found")); 01656 CComPtr<IMgaFCO> sport; 01657 CComPtr<IMgaFCO> dport; 01658 CComPtr<IMgaFCOs> srefs; 01659 CComPtr<IMgaFCOs> drefs; 01660 01661 objtype_enum type1_info = myTypeIs( src1); 01662 objtype_enum type2_info = myTypeIs( dst1); 01663 01664 if( type1_info == OBJTYPE_MODEL && CComBSTR( p_srcRole2) != _T("")) 01665 { 01666 // for models only: 01667 sport = getChildInByName( CComQIPtr<IMgaModel>(src1), p_srcRole2); 01668 } 01669 else if( type1_info == OBJTYPE_REFERENCE && CComBSTR( p_srcRole2) != _T("")) 01670 { 01671 refPortFinderAndChainBuilder( p_srcRole2, src1, sport, srefs ); 01672 } 01673 01674 if( type2_info == OBJTYPE_MODEL && CComBSTR( p_dstRole2) != _T("")) 01675 { 01676 dport = getChildInByName( CComQIPtr<IMgaModel>(dst1), p_dstRole2); 01677 } 01678 else if( type2_info == OBJTYPE_REFERENCE && CComBSTR( p_dstRole2) != _T("")) 01679 { 01680 refPortFinderAndChainBuilder( p_dstRole2, dst1, dport, drefs); 01681 } 01682 01683 bool error; 01684 error = CComBSTR( p_srcRole2) != _T("") && !sport; // if sport == NULL and the p_srcRole2 != NULL then error state 01685 THROW_IF_BOOL( error, _T("SourceRole2 object not found")); 01686 error = CComBSTR( p_dstRole2) != _T("") && !dport; // if dport == NULL and the p_dstRole2 != NULL then error state 01687 THROW_IF_BOOL( error, _T("DestinationRole2 object not found")); 01688 01689 CComPtr<IMgaMetaRole> metarole; 01690 CComBSTR conn_name( p_connName); 01691 try 01692 { 01693 if( conn_name != _T("")) 01694 metarole = metaRolePtrInByName( model, conn_name); 01695 }catch(...) 01696 { 01697 THROW_IF_BOOL( true, _T("No such connection role found")); 01698 } 01699 01700 if( !metarole) 01701 metarole = connMetaRolePtrInBetween( model, src1, sport, dst1, dport ); // create the only possible connection if 1 exists 01702 01703 THROW_IF_NULL( metarole, _T("No possible connection found")); 01704 01705 // will create a connection inside the model 01706 // between 01707 // src1 sport - dst1 dport 01708 // src1 sport - dst1 01709 // src1 - dst1 dport 01710 // src1 - dst1 01711 // 01712 01713 if( sport && dport) 01714 COMTHROW( model->CreateSimpleConn( metarole, sport, dport, srefs, drefs, &new_conn)); 01715 else if( sport && dst1) 01716 COMTHROW( model->CreateSimpleConn( metarole, sport, dst1, srefs, drefs, &new_conn)); 01717 else if( dport && src1) 01718 COMTHROW( model->CreateSimpleConn( metarole, src1, dport, srefs, drefs, &new_conn)); 01719 else if( src1 && dst1 ) 01720 COMTHROW( model->CreateSimpleConn( metarole, src1, dst1, srefs, drefs, &new_conn)); 01721 else 01722 THROW_IF_BOOL( true, _T("Unexpected case")); 01723 } 01724 CATCHALL_AND_CALL_END; 01725 01726 return new_conn.Detach(); 01727 } 01728 01729 LPDISPATCH CGMEOLEIt::ConnectThruPortFCO( LPDISPATCH p_src1, LPDISPATCH p_src2Port, LPDISPATCH p_dst1, LPDISPATCH p_dst2Port, LPCTSTR p_connName) 01730 { 01731 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::ConnectThruPortFCO\r\n")); 01732 01733 PRECONDITION_VALID_MODEL // calls AmIValid 01734 01735 ASSERT( m_theView); 01736 ASSERT( m_theMgaModel); 01737 01738 CComPtr<IMgaFCO> new_conn; 01739 start(); 01740 try 01741 { 01742 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 01743 THROW_IF_NULL( model, _T("Invalid parent model")); 01744 01745 //CComPtr<IMgaFCO> src1( getChildInByName( model, p_srcRole1)); 01746 CComQIPtr<IMgaFCO> src1( putInTerr( p_src1)); 01747 THROW_IF_NULL( src1, _T("SourceRole1 object not found")); 01748 //CComPtr<IMgaFCO> dst1( getChildInByName( model, p_dstRole1)); 01749 CComQIPtr<IMgaFCO> dst1( putInTerr( p_dst1)); 01750 THROW_IF_NULL( dst1, _T("DestinationRole1 object not found")); 01751 01752 if( !isValidChildIn( model.p, src1.p)) 01753 THROW_IF_NULL( 0, _T("SourceRole1 object not found in active model")); 01754 if( !isValidChildIn( model.p, dst1.p)) 01755 THROW_IF_NULL( 0, _T("DestinationRole1 object not found in active model")); 01756 01757 objtype_enum type1_info = myTypeIs( src1); 01758 objtype_enum type2_info = myTypeIs( dst1); 01759 01760 CComPtr<IMgaFCOs> srefs; 01761 CComPtr<IMgaFCOs> drefs; 01762 01763 CComQIPtr<IMgaFCO> sport( putInTerr( p_src2Port)); 01764 CComQIPtr<IMgaFCO> dport( putInTerr( p_dst2Port)); 01765 if( sport) // non-zero means really port is needed to be connected 01766 { 01767 if( type1_info == OBJTYPE_MODEL) 01768 { 01769 CComQIPtr<IMgaModel> s_m( src1); 01770 bool valid = s_m && isValidChildIn( s_m.p, sport.p); 01771 THROW_IF_NULL( valid, _T("Source port object not found in source model specified")); 01772 } 01773 else if( type1_info == OBJTYPE_REFERENCE) 01774 { 01775 bool succ = refChainBuilder2( src1, sport.p, srefs); 01776 THROW_IF_NULL( succ, _T("Source port object not found inside the target of the specified reference")); 01777 } 01778 } 01779 01780 if( dport) // non-zero means really port is needed to be connected 01781 { 01782 if( type2_info == OBJTYPE_MODEL) 01783 { 01784 CComQIPtr<IMgaModel> d_m( dst1); 01785 bool valid = d_m && isValidChildIn( d_m.p, dport.p); 01786 THROW_IF_NULL( valid, _T("Destination port object not found in destination model specified")); 01787 } 01788 else if( type2_info == OBJTYPE_REFERENCE) 01789 { 01790 bool succ = refChainBuilder2( dst1.p, dport.p, drefs); 01791 THROW_IF_NULL( succ, _T("Destination port object not found inside the target of the specified reference")); 01792 } 01793 } 01794 01795 bool error; 01796 error = p_src2Port && !sport; // if sport == NULL and the p_src2Port != NULL then error state 01797 THROW_IF_BOOL( error, _T("SourceRole2 object not found")); 01798 error = p_dst2Port && !dport; // if dport == NULL and the p_dst2Port != NULL then error state 01799 THROW_IF_BOOL( error, _T("DestinationRole2 object not found")); 01800 01801 CComPtr<IMgaMetaRole> metarole; 01802 CComBSTR conn_name( p_connName); 01803 try 01804 { 01805 if( conn_name != _T("")) 01806 metarole = metaRolePtrInByName( model, conn_name); 01807 }catch(...) 01808 { 01809 THROW_IF_BOOL( true, _T("No such connection role found")); 01810 } 01811 01812 if( !metarole) 01813 metarole = connMetaRolePtrInBetween( model, src1, sport, dst1, dport ); // create the only possible connection if 1 exists 01814 01815 THROW_IF_NULL( metarole, _T("No possible connection found")); 01816 01817 // will create a connection inside the model 01818 // between 01819 // src1 sport - dst1 dport 01820 // src1 sport - dst1 01821 // src1 - dst1 dport 01822 // src1 - dst1 01823 // 01824 01825 if( sport && dport) 01826 COMTHROW( model->CreateSimpleConn( metarole, sport, dport, srefs, drefs, &new_conn)); 01827 else if( sport && dst1) 01828 COMTHROW( model->CreateSimpleConn( metarole, sport, dst1, srefs, drefs, &new_conn)); 01829 else if( dport && src1) 01830 COMTHROW( model->CreateSimpleConn( metarole, src1, dport, srefs, drefs, &new_conn)); 01831 else if( src1 && dst1 ) 01832 COMTHROW( model->CreateSimpleConn( metarole, src1, dst1, srefs, drefs, &new_conn)); 01833 else 01834 THROW_IF_BOOL( true, _T("Unexpected case")); 01835 } 01836 CATCHALL_AND_CALL_END; 01837 01838 return new_conn.Detach(); 01839 } 01840 01841 void CGMEOLEIt::DisconnectThruPort( LPCTSTR p_srcRole1, LPCTSTR p_srcRole2, LPCTSTR p_dstRole1, LPCTSTR p_dstRole2, LPCTSTR p_connName) 01842 { 01843 CGMEEventLogger::LogGMEEvent("CGMEOLEIt::DisconnectThruPort\r\n"); 01844 01845 PRECONDITION_VALID_MODEL // calls AmIValid 01846 01847 ASSERT( m_theView); 01848 ASSERT( m_theMgaModel); 01849 01850 bool found_any = false; 01851 start(); 01852 try 01853 { 01854 CComBSTR src_role( L"src"); 01855 CComBSTR dst_role( L"dst"); 01856 01857 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 01858 THROW_IF_NULL( model, _T("Invalid parent model")); 01859 01860 CComPtr<IMgaFCO> src1( getChildInByName( model, p_srcRole1)); 01861 THROW_IF_NULL( src1, _T("SourceRole1 object not found")); 01862 CComPtr<IMgaFCO> dst1( getChildInByName( model, p_dstRole1)); 01863 THROW_IF_NULL( dst1, _T("DestinationRole1 object not found")); 01864 CComPtr<IMgaFCO> sport; 01865 CComPtr<IMgaFCO> dport; 01866 CComPtr<IMgaFCOs> srefs; 01867 CComPtr<IMgaFCOs> drefs; 01868 01869 objtype_enum type1_info = myTypeIs( src1); 01870 objtype_enum type2_info = myTypeIs( dst1); 01871 01872 if( type1_info == OBJTYPE_MODEL) 01873 { 01874 // for models only: sport is the port inside with the given name 01875 sport = getChildInByName( CComQIPtr<IMgaModel>(src1), p_srcRole2); 01876 } 01877 else if( type1_info == OBJTYPE_REFERENCE) 01878 { 01879 refPortFinderAndChainBuilder( p_srcRole2, src1, sport, srefs );//sport will be filled if found 01880 } 01881 01882 if( type2_info == OBJTYPE_MODEL) 01883 { 01884 dport = getChildInByName( CComQIPtr<IMgaModel>(dst1), p_dstRole2); 01885 } 01886 else if( type2_info == OBJTYPE_REFERENCE) 01887 { 01888 refPortFinderAndChainBuilder( p_dstRole2, dst1, dport, drefs); 01889 } 01890 01891 bool error; 01892 error = CComBSTR( p_srcRole2) != _T("") && !sport; 01893 THROW_IF_BOOL( error, _T("SourceRole2 object not found")); 01894 error = CComBSTR( p_dstRole2) != _T("") && !dport; 01895 THROW_IF_BOOL( error, _T("DestinationRole2 object not found")); 01896 // will look for a connection inside model 01897 // between 01898 // src1 sport - dst1 dport 01899 // src1 sport - dst1 01900 // src1 - dst1 dport 01901 // src1 - dst1 01902 // 01903 01904 CComObjPtrVector<IMgaFCO> children; 01905 COMTHROW( model->get_ChildFCOs( PutOut( children ))); 01906 01907 CComObjPtrVector<IMgaFCO>::iterator ch_it = children.begin(); 01908 CComObjPtrVector<IMgaFCO>::iterator ch_end = children.end(); 01909 for( ; ch_it != ch_end; ++ch_it) 01910 { 01911 if( myTypeIs( CComPtr<IMgaFCO>((*ch_it).p)) == OBJTYPE_CONNECTION ) 01912 { 01913 CComQIPtr<IMgaConnection> conn( *ch_it); 01914 CComObjPtrVector<IMgaConnPoint> cps; 01915 COMTHROW( conn->get_ConnPoints( PutOut( cps))); 01916 01917 bool src_found = false; 01918 bool dst_found = false; 01919 01920 CComObjPtrVector<IMgaConnPoint>::iterator cp_it = cps.begin(); 01921 CComObjPtrVector<IMgaConnPoint>::iterator cp_end = cps.end(); 01922 for( ; cp_it != cp_end; ++cp_it) 01923 { 01924 CComPtr<IMgaFCO> tg; 01925 COMTHROW( (*cp_it)->get_Target( &tg)); 01926 01927 CComBSTR connrole; 01928 COMTHROW( (*cp_it)->get_ConnRole( &connrole)); 01929 01930 CComPtr<IMgaFCOs> refchain; 01931 COMTHROW( (*cp_it)->get_References( &refchain)); 01932 01933 if( connrole == src_role) 01934 { 01935 if( sport && tg == sport && areCollectionsEqual( refchain, srefs)) 01936 src_found = true; 01937 else if( src1 && tg == src1) 01938 src_found = true; 01939 } 01940 else if( connrole == dst_role) 01941 { 01942 if( dport && tg == dport && areCollectionsEqual( refchain, drefs)) 01943 dst_found = true; 01944 else if( dst1 && tg == dst1) 01945 dst_found = true; 01946 } 01947 } 01948 bool name_checked = true; 01949 CComBSTR conn_name( p_connName); 01950 if( conn_name != _T("")) // if name provided 01951 { 01952 name_checked = false; 01953 01954 CComBSTR nm; 01955 COMTHROW( conn->get_Name( &nm)); 01956 01957 if( nm == conn_name) 01958 name_checked = true; 01959 01960 } 01961 01962 if( src_found && dst_found && name_checked) // regarding src and dst it is ok 01963 { 01964 COMTHROW( (*ch_it)->DestroyObject()); 01965 found_any = true; 01966 } 01967 } 01968 } 01969 } 01970 CATCHALL_AND_CALL_END; 01971 01972 if( !found_any) 01973 SHOW_ERROR( _T("No connection found")); 01974 } 01975 01976 LPDISPATCH CGMEOLEIt::ConnectFCOs( LPDISPATCH p_src, LPDISPATCH p_dst, LPCTSTR p_connName) 01977 { 01978 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::ConnectFCOs\r\n")); 01979 01980 PRECONDITION_VALID_MODEL // calls AmIValid 01981 01982 ASSERT( m_theView); 01983 ASSERT( m_theMgaModel); 01984 01985 CComPtr<IMgaFCO> new_conn; 01986 start(); 01987 try 01988 { 01989 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 01990 THROW_IF_NULL( model, _T("Invalid parent model")); 01991 01992 CComQIPtr<IMgaFCO> end1( putInTerr( p_src)); 01993 THROW_IF_NULL( end1, _T("Invalid Source pointer")); 01994 CComQIPtr<IMgaFCO> end2( putInTerr( p_dst)); 01995 THROW_IF_NULL( end2, _T("Invalid Destination pointer")); 01996 01997 CComPtr<IMgaMetaRole> metarole; 01998 CComBSTR conn_name( p_connName); 01999 02000 try 02001 { 02002 if( conn_name != _T("")) 02003 metarole = metaRolePtrInByName( model, conn_name); 02004 }catch(...) 02005 { 02006 THROW_IF_BOOL( true, _T("No such connection role found")); 02007 } 02008 if( !metarole) 02009 metarole = connMetaRolePtrInBetween( model, end1, end2 ); // create the only possible connection if 1 exists 02010 02011 THROW_IF_NULL( metarole, _T("No possible connection found")); 02012 COMTHROW( model->CreateSimpleConn( metarole, end1, end2, 0, 0, &new_conn)); 02013 } 02014 CATCHALL_AND_CALL_END; 02015 02016 return new_conn.Detach(); 02017 } 02018 02019 void CGMEOLEIt::DisconnectFCOs( LPDISPATCH p_src, LPDISPATCH p_dst, LPCTSTR p_connName) 02020 { 02021 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::DisconnectFCOs\r\n")); 02022 02023 PRECONDITION_VALID_MODEL // calls AmIValid 02024 02025 ASSERT( m_theView); 02026 ASSERT( m_theMgaModel); 02027 02028 bool found_any = false; 02029 start(); 02030 try 02031 { 02032 CComBSTR src_role( L"src"); 02033 CComBSTR dst_role( L"dst"); 02034 02035 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 02036 THROW_IF_NULL( model, _T("Invalid parent model")); 02037 02038 CComQIPtr<IMgaFCO> end1( putInTerr( p_src)); 02039 THROW_IF_NULL( end1, _T("Invalid Source pointer")); 02040 CComQIPtr<IMgaFCO> end2( putInTerr( p_dst)); 02041 THROW_IF_NULL( end2, _T("Invalid Destination pointer")); 02042 // will look for a connection between end1 and end2 02043 02044 CComObjPtrVector<IMgaFCO> children; 02045 COMTHROW( model->get_ChildFCOs( PutOut( children ))); 02046 02047 CComObjPtrVector<IMgaFCO>::iterator ch_it = children.begin(); 02048 CComObjPtrVector<IMgaFCO>::iterator ch_end = children.end(); 02049 for( ; ch_it != ch_end; ++ch_it) 02050 { 02051 if( myTypeIs( CComPtr<IMgaFCO>( (*ch_it).p)) == OBJTYPE_CONNECTION ) 02052 { 02053 CComQIPtr<IMgaConnection> conn( *ch_it); 02054 CComObjPtrVector<IMgaConnPoint> cps; 02055 COMTHROW( conn->get_ConnPoints( PutOut( cps))); 02056 02057 bool src_found = false; 02058 bool dst_found = false; 02059 02060 CComObjPtrVector<IMgaConnPoint>::iterator cp_it = cps.begin(); 02061 CComObjPtrVector<IMgaConnPoint>::iterator cp_end = cps.end(); 02062 for( ; cp_it != cp_end; ++cp_it) 02063 { 02064 CComPtr<IMgaFCO> tg; 02065 COMTHROW( (*cp_it)->get_Target( &tg)); 02066 02067 CComBSTR connrole; 02068 COMTHROW( (*cp_it)->get_ConnRole( &connrole)); 02069 02070 if( connrole == src_role && tg == end1) 02071 { 02072 src_found = true; 02073 } 02074 else if( connrole == dst_role && tg == end2) 02075 { 02076 dst_found = true; 02077 } 02078 } 02079 bool name_checked = true; // name or kind could be checked. DisconnectFCO uses: NAME 02080 CComBSTR conn_name( p_connName); 02081 if( conn_name != _T("")) // if name provided 02082 { 02083 name_checked = false; 02084 02085 CComBSTR nm; 02086 COMTHROW( conn->get_Name( &nm)); 02087 02088 if( nm == conn_name) 02089 name_checked = true; 02090 02091 } 02092 02093 if( src_found && dst_found && name_checked) // regarding src and dst it is ok 02094 { 02095 COMTHROW( (*ch_it)->DestroyObject()); 02096 found_any = true; 02097 } 02098 } 02099 } 02100 } 02101 CATCHALL_AND_CALL_END; 02102 02103 if( !found_any) 02104 SHOW_ERROR( _T("No connection found")); 02105 } 02106 02107 void CGMEOLEIt::Refer( LPCTSTR prefnm, LPCTSTR pfconm) 02108 { 02109 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::Refer\r\n")); 02110 02111 PRECONDITION_VALID_MODEL // calls AmIValid 02112 02113 ASSERT( m_theView); 02114 ASSERT( m_theMgaModel); 02115 02116 start(); 02117 try 02118 { 02119 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 02120 THROW_IF_NULL( model, _T("Invalid parent model")); 02121 02122 CComQIPtr<IMgaReference> ref( getChildInByName( model, prefnm)); 02123 THROW_IF_NULL( ref, _T("Reference object not found")); 02124 CComPtr<IMgaFCO> fco( getChildInByName( model, pfconm)); 02125 THROW_IF_NULL( fco, _T("To-Be-Referred object not found")); 02126 02127 COMTHROW( ref->put_Referred( fco )); 02128 } 02129 CATCHALL_AND_CALL_END; 02130 } 02131 02132 void CGMEOLEIt::ReferFCO( LPDISPATCH pref, LPDISPATCH pfco) 02133 { 02134 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::ReferFCO\r\n")); 02135 02136 PRECONDITION_VALID_MODEL // calls AmIValid 02137 02138 ASSERT( m_theView); 02139 ASSERT( m_theMgaModel); 02140 02141 start(); 02142 try 02143 { 02144 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 02145 THROW_IF_NULL( model, _T("Invalid parent model")); 02146 02147 CComQIPtr<IMgaReference> ref( putInTerr( pref)); 02148 THROW_IF_NULL( ref, _T("Invalid Reference pointer")); 02149 CComQIPtr<IMgaFCO> fco( putInTerr( pfco)); 02150 THROW_IF_NULL( fco, _T("Invalid To-Be-Referred Fco pointer")); 02151 02152 // we require that the reference is inside the model, but not the fco ptr 02153 if( isValidChildIn( model.p, ref.p)) 02154 COMTHROW( ref->put_Referred(fco) ); 02155 } 02156 CATCHALL_AND_CALL_END; 02157 } 02158 02159 void CGMEOLEIt::ClearRef( LPCTSTR prefnm) 02160 { 02161 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::ClearRef\r\n")); 02162 02163 PRECONDITION_VALID_MODEL // calls AmIValid 02164 02165 ASSERT( m_theView); 02166 ASSERT( m_theMgaModel); 02167 02168 start(); 02169 try 02170 { 02171 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 02172 THROW_IF_NULL( model, _T("Invalid parent model")); 02173 02174 CComQIPtr<IMgaReference> ref( getChildInByName( model, prefnm)); 02175 THROW_IF_NULL( ref, _T("Reference object not found")); 02176 CComPtr<IMgaFCO> emptyfco; 02177 COMTHROW( ref->put_Referred( emptyfco )); 02178 } 02179 CATCHALL_AND_CALL_END; 02180 } 02181 02182 void CGMEOLEIt::ClearRefFCO( LPDISPATCH pref) 02183 { 02184 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::ClearRefFCO\r\n")); 02185 02186 PRECONDITION_VALID_MODEL // calls AmIValid 02187 02188 ASSERT( m_theView); 02189 ASSERT( m_theMgaModel); 02190 02191 start(); 02192 try 02193 { 02194 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 02195 THROW_IF_NULL( model, _T("Invalid parent model")); 02196 02197 CComQIPtr<IMgaReference> ref( putInTerr( pref)); 02198 THROW_IF_NULL( ref, _T("Invalid Reference pointer")); 02199 CComQIPtr<IMgaFCO> emptyfco; 02200 02201 // we require that the reference is inside the model, but not the fco ptr 02202 if( isValidChildIn( model.p, ref.p)) 02203 COMTHROW( ref->put_Referred( emptyfco) ); 02204 } 02205 CATCHALL_AND_CALL_END; 02206 } 02207 02208 void CGMEOLEIt::FollowRef( LPCTSTR prefnm) 02209 { 02210 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::FollowRef\r\n")); 02211 02212 PRECONDITION_VALID_MODEL // calls AmIValid 02213 02214 ASSERT( m_theView); 02215 ASSERT( m_theMgaModel); 02216 02217 CComPtr<IMgaFCO> tgt; 02218 start(); 02219 try 02220 { 02221 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 02222 THROW_IF_NULL( model, _T("Invalid parent model")); 02223 02224 CComQIPtr<IMgaReference> ref( getChildInByName( model, prefnm)); 02225 THROW_IF_NULL( ref, _T("Reference object not found")); 02226 02227 COMTHROW( ref->get_Referred( &tgt )); 02228 02229 } 02230 CATCHALL_AND_CALL_END; 02231 02232 if( tgt) ShowFCOPtr( tgt, 1); 02233 } 02234 02235 void CGMEOLEIt::FollowRefFCO( LPDISPATCH pref) 02236 { 02237 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::FollowRefFCO\r\n")); 02238 02239 PRECONDITION_VALID_MODEL // calls AmIValid 02240 02241 ASSERT( m_theView); 02242 ASSERT( m_theMgaModel); 02243 02244 CComQIPtr<IMgaFCO> tgt; 02245 start(); 02246 try 02247 { 02248 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 02249 THROW_IF_NULL( model, _T("Invalid parent model")); 02250 02251 CComQIPtr<IMgaReference> ref( putInTerr( pref)); 02252 THROW_IF_NULL( ref, _T("Invalid Reference pointer")); 02253 02254 COMTHROW( ref->get_Referred( &tgt) ); 02255 } 02256 CATCHALL_AND_CALL_END; 02257 02258 if( tgt) ShowFCOPtr( tgt, 1); 02259 } 02260 02261 LPDISPATCH CGMEOLEIt::NullFCO() 02262 { 02263 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::NullFCO\r\n")); 02264 CComPtr<IMgaFCO> nullobj; 02265 return nullobj.Detach(); 02266 } 02267 02268 void CGMEOLEIt::SetAttribute( LPCTSTR p_partName, LPCTSTR p_attrName, VARIANT& p_attrValue) 02269 { 02270 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::SetAttribute\r\n")); 02271 02272 PRECONDITION_VALID_MODEL // calls AmIValid 02273 02274 ASSERT( m_theView); 02275 ASSERT( m_theMgaModel); 02276 02277 start(); 02278 try 02279 { 02280 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 02281 THROW_IF_NULL( model, _T("Invalid parent model")); 02282 02283 CComPtr<IMgaFCO> fco( getChildInByName( model, p_partName)); 02284 THROW_IF_NULL( fco, _T("Fco object not found")); 02285 02286 CComBSTR attr_name( p_attrName); 02287 CComVariant attr_value( p_attrValue); 02288 02289 COMTHROW( fco->put_AttributeByName( attr_name, attr_value)); 02290 } 02291 CATCHALL_AND_CALL_END; 02292 } 02293 02294 02295 VARIANT CGMEOLEIt::GetAttribute( LPCTSTR p_partName, LPCTSTR p_attrName) 02296 { 02297 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::GetAttribute\r\n")); 02298 02299 PRECONDITION_VALID_MODEL // calls AmIValid 02300 02301 ASSERT( m_theView); 02302 ASSERT( m_theMgaModel); 02303 02304 CComVariant attr_value; 02305 start(); 02306 try 02307 { 02308 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 02309 THROW_IF_NULL( model, _T("Invalid parent model")); 02310 02311 CComPtr<IMgaFCO> fco( getChildInByName( model, p_partName)); 02312 THROW_IF_NULL( fco, _T("Fco object not found")); 02313 02314 CComBSTR attr_name( p_attrName); 02315 02316 COMTHROW( fco->get_AttributeByName( attr_name, &attr_value)); 02317 } 02318 CATCHALL_AND_CALL_END; 02319 02320 return attr_value; 02321 } 02322 02323 void CGMEOLEIt::SetAttributeFCO( LPDISPATCH p_fco, LPCTSTR p_attrName, VARIANT& p_attrValue) 02324 { 02325 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::SetAttributeFCO\r\n")); 02326 02327 PRECONDITION_VALID_MODEL // calls AmIValid 02328 02329 ASSERT( m_theView); 02330 ASSERT( m_theMgaModel); 02331 02332 start(); 02333 try 02334 { 02335 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 02336 THROW_IF_NULL( model, _T("Invalid parent model")); 02337 02338 CComQIPtr<IMgaFCO> fco( putInTerr( p_fco)); 02339 THROW_IF_NULL( fco, _T("Invalid Fco pointer")); 02340 02341 CComBSTR attr_name( p_attrName); 02342 CComVariant attr_value( p_attrValue); 02343 02344 if( isValidChildIn( CComPtr<IMgaModel>(model.p), fco)) // valid child of model (could be aspect aware) 02345 { 02346 COMTHROW( fco->put_AttributeByName( attr_name, attr_value)); 02347 } 02348 } 02349 CATCHALL_AND_CALL_END; 02350 } 02351 02352 VARIANT CGMEOLEIt::GetAttributeFCO( LPDISPATCH p_fco, LPCTSTR p_attrName) 02353 { 02354 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::GetAttributeFCO\r\n")); 02355 02356 PRECONDITION_VALID_MODEL // calls AmIValid 02357 02358 ASSERT( m_theView); 02359 ASSERT( m_theMgaModel); 02360 02361 CComVariant attr_value; 02362 start(); 02363 try 02364 { 02365 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 02366 THROW_IF_NULL( model, _T("Invalid parent model")); 02367 02368 CComQIPtr<IMgaFCO> fco( putInTerr( p_fco)); 02369 THROW_IF_NULL( fco, _T("Invalid Fco pointer")); 02370 02371 CComBSTR attr_name( p_attrName); 02372 02373 if( isValidChildIn( CComPtr<IMgaModel>( model.p), fco )) // valid child of model (could be aspect aware) 02374 { 02375 COMTHROW( fco->get_AttributeByName( attr_name, &attr_value)); 02376 } 02377 } 02378 CATCHALL_AND_CALL_END; 02379 02380 return attr_value; 02381 } 02382 02383 LPDISPATCH CGMEOLEIt::SubType( LPCTSTR p_baseName, LPCTSTR p_subtypeName) 02384 { 02385 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::Subtype\r\n")); 02386 02387 PRECONDITION_VALID_MODEL // calls AmIValid 02388 02389 ASSERT( m_theView); 02390 ASSERT( m_theMgaModel); 02391 02392 CComPtr<IMgaFCO> newobj; 02393 start(); 02394 try 02395 { 02396 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 02397 THROW_IF_NULL( model, _T("Invalid parent model")); 02398 02399 CComPtr<IMgaFCO> base( getChildInByName( model, p_baseName)); 02400 THROW_IF_NULL( base, _T("Base object not found")); 02401 02402 CComPtr<IMgaMetaRole> metarole; 02403 COMTHROW( base->get_MetaRole( &metarole)); 02404 02405 COMTHROW( model->DeriveChildObject( base, metarole, VARIANT_FALSE, &newobj)); 02406 02407 THROW_IF_NULL( newobj, _T("Invalid new object pointer")); 02408 rename( newobj, p_subtypeName); 02409 } 02410 CATCHALL_AND_CALL_END; 02411 02412 return newobj.Detach(); 02413 } 02414 02415 LPDISPATCH CGMEOLEIt::Instantiate( LPCTSTR p_baseName, LPCTSTR p_instanceName) 02416 { 02417 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::Instantiate\r\n")); 02418 02419 PRECONDITION_VALID_MODEL // calls AmIValid 02420 02421 ASSERT( m_theView); 02422 ASSERT( m_theMgaModel); 02423 02424 CComPtr<IMgaFCO> newobj; 02425 start(); 02426 try 02427 { 02428 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 02429 THROW_IF_NULL( model, _T("Invalid parent model")); 02430 02431 CComPtr<IMgaFCO> base( getChildInByName( model, p_baseName)); 02432 THROW_IF_NULL( base, _T("Base object not found")); 02433 02434 CComPtr<IMgaMetaRole> metarole; 02435 COMTHROW( base->get_MetaRole( &metarole)); 02436 02437 COMTHROW( model->DeriveChildObject( base, metarole, VARIANT_TRUE, &newobj)); 02438 02439 THROW_IF_NULL( newobj, _T("Invalid new object pointer")); 02440 rename( newobj, p_instanceName); 02441 } 02442 CATCHALL_AND_CALL_END; 02443 02444 return newobj.Detach(); 02445 } 02446 02447 LPDISPATCH CGMEOLEIt::SubTypeFCO( LPDISPATCH p_base, LPCTSTR p_subtypeName) 02448 { 02449 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::SubTypeFCO\r\n")); 02450 02451 PRECONDITION_VALID_MODEL // calls AmIValid 02452 02453 ASSERT( m_theView); 02454 ASSERT( m_theMgaModel); 02455 02456 CComPtr<IMgaFCO> newobj; 02457 start(); 02458 try 02459 { 02460 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 02461 THROW_IF_NULL( model, _T("Invalid parent model")); 02462 02463 CComQIPtr<IMgaFCO> base( putInTerr( p_base)); 02464 THROW_IF_NULL( base, _T("Invalid Base pointer")); 02465 02466 //if( isValidChildIn( CComPtr<IMgaModel>( model.p), fco ) // valid child of model (could be aspect aware) 02467 // it should not be forced to be the child of the model 02468 CComPtr<IMgaMetaRole> metarole; 02469 COMTHROW( base->get_MetaRole( &metarole)); 02470 02471 COMTHROW( model->DeriveChildObject( base, metarole, VARIANT_FALSE, &newobj)); 02472 02473 THROW_IF_NULL( newobj, _T("Invalid new object pointer")); 02474 rename( newobj, p_subtypeName); 02475 } 02476 CATCHALL_AND_CALL_END; 02477 02478 return newobj.Detach(); 02479 } 02480 02481 LPDISPATCH CGMEOLEIt::InstantiateFCO( LPDISPATCH p_base, LPCTSTR p_instanceName) 02482 { 02483 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::InstantiateFCO\r\n")); 02484 02485 PRECONDITION_VALID_MODEL // calls AmIValid 02486 02487 ASSERT( m_theView); 02488 ASSERT( m_theMgaModel); 02489 02490 CComPtr<IMgaFCO> newobj; 02491 start(); 02492 try 02493 { 02494 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 02495 THROW_IF_NULL( model, _T("Invalid parent model")); 02496 02497 CComQIPtr<IMgaFCO> base( putInTerr( p_base)); 02498 THROW_IF_NULL( base, _T("Invalid Base pointer")); 02499 02500 //if( isValidChildIn( CComPtr<IMgaModel>( model.p), base ) 02501 // it should not be forced to be the child of the model 02502 CComPtr<IMgaMetaRole> metarole; 02503 COMTHROW( base->get_MetaRole( &metarole)); 02504 02505 COMTHROW( model->DeriveChildObject( base, metarole, VARIANT_TRUE, &newobj)); 02506 02507 THROW_IF_NULL( newobj, _T("Invalid new object pointer")); 02508 rename( newobj, p_instanceName); 02509 } 02510 CATCHALL_AND_CALL_END; 02511 02512 return newobj.Detach(); 02513 } 02514 02515 02516 void CGMEOLEIt::BeginTransaction( ) 02517 { 02518 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::BeginTransaction\r\n")); 02519 02520 beginTrans(); 02521 m_isInUserInitiatedTransaction = true; 02522 02523 } 02524 02525 void CGMEOLEIt::CommitTransaction( ) 02526 { 02527 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::CommitTransaction\r\n")); 02528 02529 commitTrans(); 02530 m_isInUserInitiatedTransaction = false; 02531 } 02532 02533 void CGMEOLEIt::AbortTransaction( ) 02534 { 02535 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::AbortTransaction\r\n")); 02536 02537 abortTrans(); 02538 m_isInUserInitiatedTransaction = false; 02539 } 02540 02541 VARIANT_BOOL CGMEOLEIt::IsInTransaction( ) 02542 { 02543 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::IsInTransaction\r\n")); 02544 02545 CComPtr<IMgaTerritory> act_terr; 02546 COMTHROW( theApp.mgaProject->get_ActiveTerritory( &act_terr)); 02547 02548 return (act_terr || m_isInUserInitiatedTransaction)? VARIANT_TRUE : VARIANT_FALSE; 02549 } 02550 02551 LPDISPATCH CGMEOLEIt::PutInTerritory( LPDISPATCH one_obj) 02552 { 02553 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::PutInTerritory\r\n")); 02554 02555 return putInTerr( one_obj); 02556 } 02557 02558 02559 void CGMEOLEIt::Help( ) 02560 { 02561 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::Help\r\n")); 02562 02563 static const wchar_t * htmlhelp = 02564 L"Scripting HELP<br>\ 02565 Predefined variables available in this scripting environment: "gme", "project" and "it".<br>\ 02566 <b>gme</b> implements the IGMEOLEApp interface. i.e.: gme.OpenProject('MGA=c:\myproj.mga') <br>\ 02567 <b>project</b> implements the IMgaProject interface. i.e.: myrootfolder = project.RootFolder<br>\ 02568 <b>it</b> implements the IGMEOLEIt interface and represents the currently opened model window.<br>\ 02569 It can be used for speeding up repetitive tasks, like creating several fcos:<br>\ 02570 e.g.(in Python): for i in range(0,5): it.Create('CompoundParts', 'NewlyCreatedCompound' + str(i)).<br>\ 02571 The methods of 'it' can be used either inside, or outside GME transactions."; 02572 02573 if( CMainFrame::theInstance != NULL ) 02574 { 02575 CMainFrame::theInstance->m_console.Message(htmlhelp, 1 ); 02576 } 02577 } 02578 02579 void CGMEOLEIt::SetSelected( LPCTSTR list) 02580 { 02581 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::SetSelected()\r\n")); 02582 02583 PRECONDITION_VALID_MODEL // calls AmIValid 02584 02585 ASSERT( m_theView); 02586 ASSERT( m_theMgaModel); 02587 02588 CGuiObjectList new_selection; // will store the selected objects 02589 start(); 02590 try 02591 { 02592 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 02593 02594 CComPtr<IMgaFCOs> coll; 02595 COMTHROW(coll.CoCreateInstance( L"Mga.MgaFCOs")); 02596 02597 CString tok,m = list; 02598 int i = 0; 02599 tok = m.Tokenize( _T(" "), i); 02600 while( tok != _T("")) 02601 { 02602 CComPtr<IMgaFCO> ch; 02603 CComBSTR nm( (LPCTSTR) tok); 02604 COMTHROW( model->get_ChildFCO( nm, &ch)); 02605 if( ch) 02606 { 02607 COMTHROW( coll->Append( ch )); 02608 } 02609 tok = m.Tokenize( _T(" "), i); 02610 } 02611 02612 long l = 0; 02613 COMTHROW( coll->get_Count( &l )); 02614 02615 for( long i = 1; i <= l; ++i) 02616 { 02617 CComPtr<IMgaFCO> local_item; 02618 COMTHROW( coll->get_Item( i, &local_item)); 02619 02620 // search for local_item among children and build up the "new_selection" 02621 bool found = false; 02622 POSITION pos = m_theView->children.GetHeadPosition(); 02623 while ( pos && !found) 02624 { 02625 CGuiFco* gui_fco = m_theView->children.GetNext( pos); 02626 if( gui_fco->IsVisible()) // aspect aware 02627 { 02628 CComQIPtr<IMgaFCO> mga_fco( putInTerr( gui_fco->mgaFco)); 02629 02630 if( mga_fco && local_item == mga_fco) // must not be null 02631 { 02632 found = true; 02633 CGuiObject* gui_obj = NULL; 02634 if (gui_fco) 02635 gui_obj = gui_fco->dynamic_cast_CGuiObject(); 02636 if( gui_obj) new_selection.AddTail( gui_obj); 02637 } 02638 } 02639 } 02640 } 02641 } 02642 CATCHALL_AND_CALL_END; 02643 02644 if( m_theView)// && ! m_theView->selected.IsEmpty()) 02645 { 02646 m_theView->selected.RemoveAll(); 02647 m_theView->selected.AddTail( &new_selection); 02648 m_theView->Invalidate(); 02649 } 02650 } 02651 02652 BSTR CGMEOLEIt::GetSelected( ) 02653 { 02654 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::GetSelected()\r\n")); 02655 02656 PRECONDITION_VALID_MODEL // calls AmIValid 02657 02658 ASSERT( m_theView); 02659 ASSERT( m_theMgaModel); 02660 02661 CComBSTR string_res; 02662 start(); 02663 try 02664 { 02665 CComPtr<IMgaFCOs> coll, col2; 02666 COMTHROW(col2.CoCreateInstance(OLESTR("Mga.MgaFCOs"))); 02667 POSITION pos = m_theView->selected.GetHeadPosition(); 02668 while(pos) { 02669 COMTHROW(col2->Append(m_theView->selected.GetNext(pos)->mgaFco)); 02670 } 02671 02672 //COMTHROW(m_theView->currentModel->AddInternalConnections(col2,&coll)); // copy from coll to coll 02673 CComQIPtr<IMgaModel> curmodel( putInTerr( m_theView->GetCurrentModel())); 02674 if( curmodel) COMTHROW( curmodel->AddInternalConnections( col2, &coll)); 02675 02676 long sz; 02677 COMTHROW( coll->get_Count( &sz)); 02678 if( sz > 0 ) 02679 { 02680 for( long i = 1; i <= sz; ++i) 02681 { 02682 CComPtr<IMgaFCO> fco; 02683 COMTHROW( coll->get_Item( i, &fco)); 02684 02685 CComQIPtr<IMgaFCO> tfco( putInTerr( fco)); 02686 CComBSTR nm; 02687 COMTHROW( tfco->get_Name( &nm)); 02688 TRACE( _T("setselectedFCO input collection: %s"), nm); 02689 if (!string_res.Length() == 0) 02690 COMTHROW(string_res.Append(_T(" "))); 02691 COMTHROW(string_res.AppendBSTR( nm)); 02692 } 02693 } 02694 } 02695 CATCHALL_AND_CALL_END; 02696 02697 return string_res.Detach(); 02698 } 02699 02700 void CGMEOLEIt::SetSelectedFCOs( LPDISPATCH p_dispColl) 02701 { 02702 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::SetSelectedFCOs()\r\n")); 02703 02704 PRECONDITION_VALID_MODEL // calls AmIValid 02705 02706 ASSERT( m_theView); 02707 ASSERT( m_theMgaModel); 02708 02709 CGuiObjectList new_selection; // will store the selected objects 02710 start(); 02711 try 02712 { 02713 CComPtr<IMgaFCOs> coll; 02714 p_dispColl->QueryInterface(__uuidof(IMgaFCOs), (LPVOID*)&coll); 02715 02716 long l = 0; 02717 COMTHROW( coll->get_Count( &l )); 02718 02719 for( long i = 1; i <= l; ++i) 02720 { 02721 CComPtr<IMgaFCO> item; 02722 COMTHROW( coll->get_Item( i, &item)); 02723 CComQIPtr<IMgaFCO> local_item( putInTerr( item )); 02724 02725 // search for local_item among children and build up the "new_selection" 02726 bool found = false; 02727 POSITION pos = m_theView->children.GetHeadPosition(); 02728 while ( pos && !found) 02729 { 02730 CGuiFco* gui_fco = m_theView->children.GetNext( pos); 02731 CComQIPtr<IMgaFCO> mga_fco( putInTerr( gui_fco->mgaFco)); 02732 02733 if( gui_fco->IsVisible()) // aspect aware 02734 { 02735 if( mga_fco && local_item == mga_fco) // test non-null 02736 { 02737 found = true; 02738 CGuiObject* gui_obj = NULL; 02739 if (gui_fco) 02740 gui_obj = gui_fco->dynamic_cast_CGuiObject(); 02741 if( gui_obj) new_selection.AddTail( gui_obj); 02742 } 02743 } 02744 } 02745 } 02746 } 02747 CATCHALL_AND_CALL_END; 02748 02749 if( m_theView) 02750 { 02751 m_theView->selected.RemoveAll(); 02752 m_theView->selected.AddTail( &new_selection); 02753 m_theView->Invalidate(); 02754 } 02755 } 02756 02757 02758 LPDISPATCH CGMEOLEIt::GetSelectedFCOs( ) 02759 { 02760 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::GetSelectedFCOs()\r\n")); 02761 02762 PRECONDITION_VALID_MODEL // calls AmIValid 02763 02764 ASSERT( m_theView); 02765 ASSERT( m_theMgaModel); 02766 02767 CComPtr<IMgaFCOs> coll; 02768 start(); 02769 try 02770 { 02771 CComPtr<IMgaFCOs> col2; 02772 COMTHROW(col2.CoCreateInstance(OLESTR("Mga.MgaFCOs"))); 02773 POSITION pos = m_theView->selected.GetHeadPosition(); 02774 while(pos) { 02775 COMTHROW(col2->Append(m_theView->selected.GetNext(pos)->mgaFco)); 02776 } 02777 02778 //COMTHROW(m_theView->currentModel->AddInternalConnections(col2,&coll)); // copy from coll to coll 02779 CComQIPtr<IMgaModel> curmodel( putInTerr( m_theView->GetCurrentModel())); 02780 if( curmodel) COMTHROW( curmodel->AddInternalConnections( col2, &coll)); 02781 } 02782 CATCHALL_AND_CALL_END; 02783 02784 return coll.Detach(); 02785 } 02786 02787 void CGMEOLEIt::moveAspect( int dir) 02788 { 02789 CGuiMetaAspect* guiaspect = (CGuiMetaAspect*)m_theView->guiMeta->FindAspect(m_theView->currentAspect->name); 02790 int ca = guiaspect->index; 02791 ca += dir; 02792 02793 if( ca < 0) 02794 ca = m_theView->guiMeta->NumberOfAspects() - 1; 02795 02796 if( ca >= m_theView->guiMeta->NumberOfAspects()) 02797 ca = 0; 02798 02799 m_theView->ChangeAspect( ca); 02800 02801 } 02802 02803 CString CGMEOLEIt::GetCurrentAspect(void) 02804 { 02805 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::GetCurrentAspect()\r\n")); 02806 02807 PRECONDITION_VALID_MODEL 02808 02809 return m_theView->GetCurrentAspectName(); 02810 } 02811 02812 void CGMEOLEIt::SetCurrentAspect(const CString& aspectName) 02813 { 02814 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::SetCurrentAspect()\r\n")); 02815 02816 PRECONDITION_VALID_MODEL 02817 02818 m_theView->ChangeAspect(aspectName); 02819 } 02820 02821 void CGMEOLEIt::NextAspect( ) 02822 { 02823 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::NextAspect()\r\n")); 02824 02825 PRECONDITION_VALID_MODEL // calls AmIValid 02826 02827 ASSERT( m_theView); 02828 ASSERT( m_theMgaModel); 02829 02830 moveAspect( 1 ); 02831 } 02832 02833 void CGMEOLEIt::PrevAspect( ) 02834 { 02835 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::PrevAspect()\r\n")); 02836 02837 PRECONDITION_VALID_MODEL // calls AmIValid 02838 02839 ASSERT( m_theView); 02840 ASSERT( m_theMgaModel); 02841 02842 moveAspect( -1 ); 02843 } 02844 02845 void CGMEOLEIt::moveView( int dir ) 02846 { 02847 POSITION pos = CGMEDoc::theInstance->GetFirstViewPosition(); 02848 POSITION pos_1st = pos; 02849 02850 CGMEView* first_view = (CGMEView *)CGMEDoc::theInstance->GetNextView(pos_1st); 02851 CGMEView* new_view = 0; 02852 CGMEView* prev_view = 0; 02853 CGMEView* it_view = 0; 02854 02855 while (pos != NULL && !new_view) 02856 { 02857 prev_view = it_view; 02858 it_view = (CGMEView *)CGMEDoc::theInstance->GetNextView(pos); 02859 02860 if( it_view == m_theView) 02861 { 02862 if( dir == 1) // next 02863 { 02864 if( pos != NULL) // if not the last 02865 { 02866 new_view = (CGMEView *)CGMEDoc::theInstance->GetNextView(pos); 02867 } 02868 else // if last use the first 02869 { 02870 new_view = first_view; 02871 } 02872 } 02873 else if( dir == -1) // previous 02874 { 02875 if( prev_view) // if not first use the previous 02876 { 02877 new_view = prev_view; 02878 } 02879 else 02880 { 02881 new_view = it_view; 02882 while (pos != NULL) 02883 new_view = (CGMEView *)CGMEDoc::theInstance->GetNextView(pos); 02884 // new_view now is the last one 02885 } 02886 } 02887 } 02888 } 02889 ASSERT( new_view); 02890 if( new_view) 02891 { 02892 CMainFrame::theInstance->ActivateView(new_view);//MDIActivate( new_view); 02893 } 02894 } 02895 void CGMEOLEIt::Next( ) 02896 { 02897 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::Next()\r\n")); 02898 02899 PRECONDITION_VALID_MODEL // calls AmIValid 02900 02901 ASSERT( m_theView); 02902 ASSERT( m_theMgaModel); 02903 02904 moveView( 1 ); 02905 } 02906 02907 void CGMEOLEIt::Prev( ) 02908 { 02909 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::Prev()\r\n")); 02910 02911 PRECONDITION_VALID_MODEL // calls AmIValid 02912 02913 ASSERT( m_theView); 02914 ASSERT( m_theMgaModel); 02915 02916 moveView( -1 ); 02917 } 02918 02919 void CGMEOLEIt::setObjPos( CComPtr<IMgaFCO> pChild, LPCTSTR pAspectName, long parX, long parY) 02920 { 02921 ASSERT( pChild); 02922 if( !pChild) return; 02923 02924 CString path; 02925 path.Format( _T("PartRegs/%s/Position"), pAspectName); 02926 CString valu; 02927 valu.Format( _T("%u,%u"), parX, parY); 02928 COMTHROW( pChild->put_RegistryValue( PutInBstr(path), PutInBstr(valu))); 02929 } 02930 02931 void CGMEOLEIt::Position( LPCTSTR pObjName, LPCTSTR pAspectName, long parX, long parY) 02932 { 02933 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::Position()\r\n")); 02934 02935 PRECONDITION_VALID_MODEL // calls AmIValid 02936 02937 ASSERT( m_theView); 02938 ASSERT( m_theMgaModel); 02939 02940 start(); 02941 try 02942 { 02943 CComQIPtr<IMgaModel> model( putInTerr( m_theMgaModel)); 02944 THROW_IF_NULL( model, _T("Invalid parent model")); 02945 02946 CComPtr<IMgaFCO> child( getChildInByName( model, pObjName)); 02947 THROW_IF_NULL( child, _T("Child object not found")); 02948 02949 setObjPos( child, pAspectName, parX, parY); 02950 } 02951 CATCHALL_AND_CALL_END; 02952 } 02953 02954 void CGMEOLEIt::PositionFCO( LPDISPATCH pObjPtr, LPCTSTR pAspectName, long parX, long parY) 02955 { 02956 CGMEEventLogger::LogGMEEvent(_T("CGMEOLEIt::PositionFCO()\r\n")); 02957 02958 PRECONDITION_VALID_MODEL // calls AmIValid 02959 02960 ASSERT( m_theView); 02961 ASSERT( m_theMgaModel); 02962 02963 start(); 02964 try 02965 { 02966 CComQIPtr<IMgaFCO> child( putInTerr( pObjPtr)); 02967 setObjPos( child, pAspectName, parX, parY); 02968 } 02969 CATCHALL_AND_CALL_END; 02970 } 02971 02972 DELEGATE_DUAL_INTERFACE(CGMEOLEIt, Dual) 02973 02974 // Implement ISupportErrorInfo to indicate we support the 02975 // OLE Automation error handler. 02976 IMPLEMENT_DUAL_ERRORINFO(CGMEOLEIt, __uuidof(IGMEOLEIt)) 02977 02978 02979 STDMETHODIMP CGMEOLEIt::XDual::get_Aspects(IGMEOLEColl** coll) 02980 { 02981 METHOD_PROLOGUE(CGMEOLEIt, Dual) 02982 02983 TRY_DUAL(__uuidof(IGMEOLEIt)) 02984 { 02985 LPDISPATCH lpDisp = pThis->GetAspects(); 02986 lpDisp->QueryInterface(__uuidof(IGMEOLEColl), (LPVOID*)coll); 02987 return NOERROR; 02988 } 02989 CATCH_ALL_DUAL 02990 } 02991 02992 STDMETHODIMP CGMEOLEIt::XDual::Print() 02993 { 02994 METHOD_PROLOGUE(CGMEOLEIt, Dual) 02995 02996 TRY_DUAL(__uuidof(IGMEOLEIt)) 02997 { 02998 pThis->Print(); 02999 return NOERROR; 03000 } 03001 CATCH_ALL_DUAL 03002 } 03003 03004 STDMETHODIMP CGMEOLEIt::XDual::PrintDialog() 03005 { 03006 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03007 03008 TRY_DUAL(__uuidof(IGMEOLEIt)) 03009 { 03010 pThis->PrintDialog(); 03011 return NOERROR; 03012 } 03013 CATCH_ALL_DUAL 03014 } 03015 03016 03017 STDMETHODIMP CGMEOLEIt::XDual::DumpWindowsMetaFile(BSTR filePath) 03018 { 03019 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03020 03021 TRY_DUAL(__uuidof(IGMEOLEIt)) 03022 { 03023 pThis->DumpWindowsMetaFile(CString(filePath)); 03024 return NOERROR; 03025 } 03026 CATCH_ALL_DUAL 03027 } 03028 03029 03030 STDMETHODIMP CGMEOLEIt::XDual::CheckConstraints() 03031 { 03032 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03033 03034 TRY_DUAL(__uuidof(IGMEOLEIt)) 03035 { 03036 pThis->CheckConstraints(); 03037 return NOERROR; 03038 } 03039 CATCH_ALL_DUAL 03040 } 03041 03042 03043 STDMETHODIMP CGMEOLEIt::XDual::RunComponent(BSTR appID) 03044 { 03045 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03046 03047 TRY_DUAL(__uuidof(IGMEOLEIt)) 03048 { 03049 pThis->RunComponent(CString(appID)); 03050 return NOERROR; 03051 } 03052 CATCH_ALL_DUAL 03053 } 03054 03055 03056 STDMETHODIMP CGMEOLEIt::XDual::RunComponentDialog() 03057 { 03058 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03059 03060 TRY_DUAL(__uuidof(IGMEOLEIt)) 03061 { 03062 pThis->RunComponentDialog(); 03063 return NOERROR; 03064 } 03065 CATCH_ALL_DUAL 03066 } 03067 03068 03069 STDMETHODIMP CGMEOLEIt::XDual::Close() 03070 { 03071 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03072 03073 TRY_DUAL(__uuidof(IGMEOLEIt)) 03074 { 03075 pThis->Close(); 03076 return NOERROR; 03077 } 03078 CATCH_ALL_DUAL 03079 } 03080 03081 03082 STDMETHODIMP CGMEOLEIt::XDual::GrayOutFCO(VARIANT_BOOL bGray, VARIANT_BOOL bNeighbours, IMgaFCOs* mgaFCO) 03083 { 03084 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03085 03086 TRY_DUAL(__uuidof(IGMEOLEIt)) 03087 { 03088 LPDISPATCH lpDisp = NULL; 03089 mgaFCO->QueryInterface(IID_IDispatch, (LPVOID*)&lpDisp); 03090 pThis->GrayOutFCO(bGray, bNeighbours, lpDisp); 03091 lpDisp->Release(); 03092 return NOERROR; 03093 } 03094 CATCH_ALL_DUAL 03095 } 03096 03097 03098 STDMETHODIMP CGMEOLEIt::XDual::GrayOutHide() 03099 { 03100 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03101 03102 TRY_DUAL(__uuidof(IGMEOLEIt)) 03103 { 03104 pThis->GrayOutHide(); 03105 return NOERROR; 03106 } 03107 CATCH_ALL_DUAL 03108 } 03109 03110 STDMETHODIMP CGMEOLEIt::XDual::ShowSetMembers(IMgaFCO* mgaFCO) 03111 { 03112 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03113 03114 TRY_DUAL(__uuidof(IGMEOLEIt)) 03115 { 03116 LPDISPATCH lpDisp = NULL; 03117 mgaFCO->QueryInterface(IID_IDispatch, (LPVOID*)&lpDisp); 03118 pThis->ShowSetMembers(lpDisp); 03119 lpDisp->Release(); 03120 return NOERROR; 03121 } 03122 CATCH_ALL_DUAL 03123 } 03124 03125 03126 STDMETHODIMP CGMEOLEIt::XDual::HideSetMembers() 03127 { 03128 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03129 03130 TRY_DUAL(__uuidof(IGMEOLEIt)) 03131 { 03132 pThis->HideSetMembers(); 03133 return NOERROR; 03134 } 03135 CATCH_ALL_DUAL 03136 } 03137 03138 STDMETHODIMP CGMEOLEIt::XDual::Zoom(DWORD percent) 03139 { 03140 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03141 03142 TRY_DUAL(__uuidof(IGMEOLEIt)) 03143 { 03144 pThis->Zoom(percent); 03145 return NOERROR; 03146 } 03147 CATCH_ALL_DUAL 03148 } 03149 03150 STDMETHODIMP CGMEOLEIt::XDual::ZoomTo(IMgaFCOs* mgaFCOs) 03151 { 03152 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03153 03154 TRY_DUAL(__uuidof(IGMEOLEIt)) 03155 { 03156 pThis->ZoomTo(mgaFCOs); 03157 return NOERROR; 03158 } 03159 CATCH_ALL_DUAL 03160 } 03161 03162 STDMETHODIMP CGMEOLEIt::XDual::Scroll(bar_enum bar, scroll_enum scroll) 03163 { 03164 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03165 03166 TRY_DUAL(__uuidof(IGMEOLEIt)) 03167 { 03168 pThis->Scroll(bar, scroll); 03169 return NOERROR; 03170 } 03171 CATCH_ALL_DUAL 03172 } 03173 03174 03175 STDMETHODIMP CGMEOLEIt::XDual::DumpModelGeometryXML(BSTR filePath) 03176 { 03177 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03178 03179 TRY_DUAL(__uuidof(IGMEOLEIt)) 03180 { 03181 pThis->DumpModelGeometryXML(CString(filePath)); 03182 return NOERROR; 03183 } 03184 CATCH_ALL_DUAL 03185 } 03186 03187 03188 STDMETHODIMP CGMEOLEIt::XDual::get_Valid(VARIANT_BOOL* p_isActive) 03189 { 03190 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03191 03192 TRY_DUAL(__uuidof(IGMEOLEIt)) 03193 { 03194 *p_isActive = (pThis->GetValid() == FALSE) ? VARIANT_FALSE : VARIANT_TRUE; 03195 return NOERROR; 03196 } 03197 CATCH_ALL_DUAL 03198 } 03199 03200 STDMETHODIMP CGMEOLEIt::XDual::get_MgaModel(IMgaModel** p_pModel) 03201 { 03202 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03203 03204 TRY_DUAL(__uuidof(IGMEOLEIt)) 03205 { 03206 LPDISPATCH lpDisp = pThis->GetMgaModel(); 03207 lpDisp->QueryInterface(__uuidof(IMgaModel), (LPVOID*)p_pModel); 03208 return NOERROR; 03209 } 03210 CATCH_ALL_DUAL 03211 } 03212 03213 STDMETHODIMP CGMEOLEIt::XDual::ShowFCO( BSTR directory, VARIANT_BOOL inParent) 03214 { 03215 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03216 03217 TRY_DUAL(__uuidof(IGMEOLEIt)) 03218 { 03219 pThis->ShowFCO( (LPCTSTR) directory, inParent); 03220 return NOERROR; 03221 } 03222 CATCH_ALL_DUAL 03223 } 03224 03225 STDMETHODIMP CGMEOLEIt::XDual::ShowFCOPtr( IMgaFCO* child, VARIANT_BOOL inParent) 03226 { 03227 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03228 03229 TRY_DUAL(__uuidof(IGMEOLEIt)) 03230 { 03231 pThis->ShowFCOPtr( child, inParent); 03232 return NOERROR; 03233 } 03234 CATCH_ALL_DUAL 03235 } 03236 03237 STDMETHODIMP CGMEOLEIt::XDual::Child( BSTR child_name, IMgaFCO** new_fco) 03238 { 03239 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03240 03241 TRY_DUAL(__uuidof(IGMEOLEIt)) 03242 { 03243 LPDISPATCH lpDisp = pThis->Child( (LPCTSTR) child_name); 03244 lpDisp->QueryInterface(__uuidof(IMgaFCO), (LPVOID*) new_fco); 03245 return NOERROR; 03246 } 03247 CATCH_ALL_DUAL 03248 } 03249 03250 STDMETHODIMP CGMEOLEIt::XDual::Create( BSTR part, BSTR name, IMgaFCO** new_fco) 03251 { 03252 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03253 03254 TRY_DUAL(__uuidof(IGMEOLEIt)) 03255 { 03256 LPDISPATCH lpDisp = pThis->Create( (LPCTSTR)part, (LPCTSTR)name); 03257 lpDisp->QueryInterface(__uuidof(IMgaFCO), (LPVOID*) new_fco); 03258 return NOERROR; 03259 } 03260 CATCH_ALL_DUAL 03261 } 03262 03263 STDMETHODIMP CGMEOLEIt::XDual::CreateInChild( BSTR child_as_parent, BSTR part, BSTR name, IMgaFCO** new_fco) 03264 { 03265 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03266 03267 TRY_DUAL(__uuidof(IGMEOLEIt)) 03268 { 03269 LPDISPATCH lpDisp = pThis->CreateInChild( (LPCTSTR) child_as_parent, (LPCTSTR) part, (LPCTSTR) name); 03270 lpDisp->QueryInterface(__uuidof(IMgaFCO), (LPVOID*) new_fco); 03271 return NOERROR; 03272 } 03273 CATCH_ALL_DUAL 03274 } 03275 03276 STDMETHODIMP CGMEOLEIt::XDual::CreateInChildFCO( IMgaFCO* child_as_parent, BSTR part, BSTR name, IMgaFCO** new_fco) 03277 { 03278 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03279 03280 TRY_DUAL(__uuidof(IGMEOLEIt)) 03281 { 03282 LPDISPATCH lpDisp = pThis->CreateInChildFCO( child_as_parent, (LPCTSTR) part, (LPCTSTR) name); 03283 lpDisp->QueryInterface(__uuidof(IMgaFCO), (LPVOID*) new_fco); 03284 return NOERROR; 03285 } 03286 CATCH_ALL_DUAL 03287 } 03288 03289 STDMETHODIMP CGMEOLEIt::XDual::Duplicate(THIS_ BSTR existing_fco_name, BSTR new_fco_name, IMgaFCO** new_fco) 03290 { 03291 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03292 03293 TRY_DUAL(__uuidof(IGMEOLEIt)) 03294 { 03295 LPDISPATCH lpDisp = pThis->Duplicate( (LPCTSTR)existing_fco_name, (LPCTSTR)new_fco_name); 03296 lpDisp->QueryInterface(__uuidof(IMgaFCO), (LPVOID*) new_fco); 03297 return NOERROR; 03298 } 03299 CATCH_ALL_DUAL 03300 } 03301 03302 STDMETHODIMP CGMEOLEIt::XDual::DuplicateFCO(THIS_ IMgaFCO* existing_fco, BSTR new_fco_name, IMgaFCO** new_fco) 03303 { 03304 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03305 03306 TRY_DUAL(__uuidof(IGMEOLEIt)) 03307 { 03308 LPDISPATCH lpDisp = pThis->DuplicateFCO( existing_fco, (LPCTSTR)new_fco_name); 03309 lpDisp->QueryInterface(__uuidof(IMgaFCO), (LPVOID*) new_fco); 03310 return NOERROR; 03311 } 03312 CATCH_ALL_DUAL 03313 } 03314 03315 STDMETHODIMP CGMEOLEIt::XDual::Rename(THIS_ BSTR oldname, BSTR newname) 03316 { 03317 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03318 03319 TRY_DUAL(__uuidof(IGMEOLEIt)) 03320 { 03321 pThis->Rename( (LPCTSTR)oldname, (LPCTSTR)newname); 03322 } 03323 CATCH_ALL_DUAL 03324 } 03325 03326 STDMETHODIMP CGMEOLEIt::XDual::SetName(THIS_ IMgaFCO* fco, BSTR name) 03327 { 03328 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03329 03330 TRY_DUAL(__uuidof(IGMEOLEIt)) 03331 { 03332 pThis->SetName( fco, (LPCTSTR)name); 03333 } 03334 CATCH_ALL_DUAL 03335 } 03336 03337 STDMETHODIMP CGMEOLEIt::XDual::Include(THIS_ BSTR setname, BSTR fconame) 03338 { 03339 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03340 03341 TRY_DUAL(__uuidof(IGMEOLEIt)) 03342 { 03343 pThis->Include( (LPCTSTR) setname, (LPCTSTR) fconame ); 03344 } 03345 CATCH_ALL_DUAL 03346 } 03347 03348 STDMETHODIMP CGMEOLEIt::XDual::IncludeFCO(THIS_ IMgaSet* set, IMgaFCO* fco) 03349 { 03350 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03351 03352 TRY_DUAL(__uuidof(IGMEOLEIt)) 03353 { 03354 pThis->IncludeFCO( set, fco ); 03355 } 03356 CATCH_ALL_DUAL 03357 } 03358 03359 STDMETHODIMP CGMEOLEIt::XDual::Exclude(THIS_ BSTR setname, BSTR fconame) 03360 { 03361 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03362 03363 TRY_DUAL(__uuidof(IGMEOLEIt)) 03364 { 03365 pThis->Exclude( (LPCTSTR) setname, (LPCTSTR) fconame ); 03366 } 03367 CATCH_ALL_DUAL 03368 } 03369 03370 STDMETHODIMP CGMEOLEIt::XDual::ExcludeFCO(THIS_ IMgaSet* set, IMgaFCO* fco) 03371 { 03372 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03373 03374 TRY_DUAL(__uuidof(IGMEOLEIt)) 03375 { 03376 pThis->ExcludeFCO( set, fco ); 03377 } 03378 CATCH_ALL_DUAL 03379 } 03380 03381 STDMETHODIMP CGMEOLEIt::XDual::Connect(THIS_ BSTR name1, BSTR name2, BSTR connection, IMgaConnection** conn ) 03382 { 03383 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03384 03385 TRY_DUAL(__uuidof(IGMEOLEIt)) 03386 { 03387 LPDISPATCH lpDisp = pThis->Connect( (LPCTSTR) name1, (LPCTSTR) name2, (LPCTSTR) connection ); 03388 lpDisp->QueryInterface(__uuidof(IMgaConnection), (LPVOID*) conn); 03389 03390 } 03391 CATCH_ALL_DUAL 03392 } 03393 03394 STDMETHODIMP CGMEOLEIt::XDual::Disconnect(THIS_ BSTR part1, BSTR part2, BSTR connection) 03395 { 03396 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03397 03398 TRY_DUAL(__uuidof(IGMEOLEIt)) 03399 { 03400 pThis->Disconnect( (LPCTSTR) part1, (LPCTSTR) part2, (LPCTSTR) connection ); 03401 } 03402 CATCH_ALL_DUAL 03403 } 03404 03405 STDMETHODIMP CGMEOLEIt::XDual::ConnectThruPort(THIS_ BSTR part1, BSTR port1, BSTR part2, BSTR port2, BSTR connection, IMgaConnection ** conn ) 03406 { 03407 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03408 03409 TRY_DUAL(__uuidof(IGMEOLEIt)) 03410 { 03411 LPDISPATCH lpDisp = pThis->ConnectThruPort( (LPCTSTR) part1, (LPCTSTR) port1, (LPCTSTR) part2, (LPCTSTR) port2, (LPCTSTR) connection); 03412 lpDisp->QueryInterface(__uuidof(IMgaConnection), (LPVOID*) conn); 03413 } 03414 CATCH_ALL_DUAL 03415 } 03416 03417 STDMETHODIMP CGMEOLEIt::XDual::ConnectThruPortFCO(THIS_ IMgaFCO* src_part, IMgaFCO* src_ref, IMgaFCO* dst_part, IMgaFCO* dst_ref, BSTR connection_role, IMgaConnection ** conn) 03418 { 03419 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03420 03421 TRY_DUAL(__uuidof(IGMEOLEIt)) 03422 { 03423 LPDISPATCH lpDisp = pThis->ConnectThruPortFCO( src_part, src_ref, dst_part, dst_ref, (LPCTSTR) connection_role); 03424 lpDisp->QueryInterface(__uuidof(IMgaConnection), (LPVOID*) conn); 03425 } 03426 CATCH_ALL_DUAL 03427 } 03428 03429 STDMETHODIMP CGMEOLEIt::XDual::DisconnectThruPort(THIS_ BSTR part1, BSTR port1, BSTR part2, BSTR port2, BSTR connection) 03430 { 03431 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03432 03433 TRY_DUAL(__uuidof(IGMEOLEIt)) 03434 { 03435 pThis->DisconnectThruPort( (LPCTSTR) part1, (LPCTSTR) port1, (LPCTSTR) part2, (LPCTSTR) port2, (LPCTSTR) connection ); 03436 } 03437 CATCH_ALL_DUAL 03438 } 03439 03440 STDMETHODIMP CGMEOLEIt::XDual::ConnectFCOs(THIS_ IMgaFCO* part1, IMgaFCO* part2, BSTR connection, IMgaConnection ** conn ) 03441 { 03442 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03443 03444 TRY_DUAL(__uuidof(IGMEOLEIt)) 03445 { 03446 LPDISPATCH lpDisp = pThis->ConnectFCOs( part1, part2, (LPCTSTR) connection ); 03447 lpDisp->QueryInterface(__uuidof(IMgaConnection), (LPVOID*) conn); 03448 } 03449 CATCH_ALL_DUAL 03450 } 03451 03452 STDMETHODIMP CGMEOLEIt::XDual::DisconnectFCOs(THIS_ IMgaFCO* part1, IMgaFCO* part2, BSTR connection) 03453 { 03454 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03455 03456 TRY_DUAL(__uuidof(IGMEOLEIt)) 03457 { 03458 pThis->DisconnectFCOs( part1, part2, (LPCTSTR) connection ); 03459 } 03460 CATCH_ALL_DUAL 03461 } 03462 03463 STDMETHODIMP CGMEOLEIt::XDual::Refer(THIS_ BSTR reference, BSTR referred) 03464 { 03465 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03466 03467 TRY_DUAL(__uuidof(IGMEOLEIt)) 03468 { 03469 pThis->Refer( (LPCTSTR) reference, (LPCTSTR) referred ); 03470 } 03471 CATCH_ALL_DUAL 03472 } 03473 03474 STDMETHODIMP CGMEOLEIt::XDual::ReferFCO(THIS_ IMgaReference* reference, IMgaFCO* referred) 03475 { 03476 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03477 03478 TRY_DUAL(__uuidof(IGMEOLEIt)) 03479 { 03480 pThis->ReferFCO( reference, referred ); 03481 } 03482 CATCH_ALL_DUAL 03483 } 03484 03485 STDMETHODIMP CGMEOLEIt::XDual::ClearRef(THIS_ BSTR reference) 03486 { 03487 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03488 03489 TRY_DUAL(__uuidof(IGMEOLEIt)) 03490 { 03491 pThis->ClearRef( (LPCTSTR) reference); 03492 } 03493 CATCH_ALL_DUAL 03494 } 03495 03496 STDMETHODIMP CGMEOLEIt::XDual::ClearRefFCO(THIS_ IMgaReference* reference) 03497 { 03498 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03499 03500 TRY_DUAL(__uuidof(IGMEOLEIt)) 03501 { 03502 pThis->ClearRefFCO( reference); 03503 } 03504 CATCH_ALL_DUAL 03505 } 03506 03507 STDMETHODIMP CGMEOLEIt::XDual::FollowRef(THIS_ BSTR reference) 03508 { 03509 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03510 03511 TRY_DUAL(__uuidof(IGMEOLEIt)) 03512 { 03513 pThis->FollowRef( (LPCTSTR) reference); 03514 } 03515 CATCH_ALL_DUAL 03516 } 03517 03518 STDMETHODIMP CGMEOLEIt::XDual::FollowRefFCO(THIS_ IMgaReference* reference) 03519 { 03520 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03521 03522 TRY_DUAL(__uuidof(IGMEOLEIt)) 03523 { 03524 pThis->FollowRefFCO( reference); 03525 } 03526 CATCH_ALL_DUAL 03527 } 03528 03529 STDMETHODIMP CGMEOLEIt::XDual::NullFCO(THIS_ IMgaFCO** nullobj) 03530 { 03531 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03532 03533 TRY_DUAL(__uuidof(IGMEOLEIt)) 03534 { 03535 LPDISPATCH lpDisp = pThis->NullFCO(); 03536 lpDisp->QueryInterface(__uuidof(IMgaFCO), (LPVOID*) nullobj); 03537 } 03538 CATCH_ALL_DUAL 03539 } 03540 03541 STDMETHODIMP CGMEOLEIt::XDual::SetAttribute(THIS_ BSTR name, BSTR attr_name, VARIANT value) 03542 { 03543 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03544 03545 TRY_DUAL(__uuidof(IGMEOLEIt)) 03546 { 03547 pThis->SetAttribute( (LPCTSTR) name, (LPCTSTR) attr_name, value ); 03548 } 03549 CATCH_ALL_DUAL 03550 } 03551 03552 STDMETHODIMP CGMEOLEIt::XDual::GetAttribute(THIS_ BSTR name, BSTR attr_name, VARIANT* value) 03553 { 03554 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03555 03556 TRY_DUAL(__uuidof(IGMEOLEIt)) 03557 { 03558 CComVariant p = pThis->GetAttribute( (LPCTSTR) name, (LPCTSTR) attr_name ); 03559 *value = p; 03560 } 03561 CATCH_ALL_DUAL 03562 } 03563 03564 STDMETHODIMP CGMEOLEIt::XDual::SetAttributeFCO(THIS_ IMgaFCO* fco, BSTR attr_name, VARIANT value) 03565 { 03566 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03567 03568 TRY_DUAL(__uuidof(IGMEOLEIt)) 03569 { 03570 pThis->SetAttributeFCO( fco, (LPCTSTR) attr_name, value); 03571 } 03572 CATCH_ALL_DUAL 03573 } 03574 03575 STDMETHODIMP CGMEOLEIt::XDual::GetAttributeFCO(THIS_ IMgaFCO* fco, BSTR attr_name, VARIANT* value) 03576 { 03577 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03578 03579 TRY_DUAL(__uuidof(IGMEOLEIt)) 03580 { 03581 CComVariant p = pThis->GetAttributeFCO( fco, (LPCTSTR) attr_name ); 03582 *value = p; 03583 } 03584 CATCH_ALL_DUAL 03585 } 03586 03587 STDMETHODIMP CGMEOLEIt::XDual::SubType(THIS_ BSTR base, BSTR name_of_subtype, IMgaFCO** subtype) 03588 { 03589 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03590 03591 TRY_DUAL(__uuidof(IGMEOLEIt)) 03592 { 03593 LPDISPATCH lpDisp = pThis->SubType( (LPCTSTR) base, (LPCTSTR) name_of_subtype); 03594 lpDisp->QueryInterface(__uuidof(IMgaFCO), (LPVOID*) subtype); 03595 } 03596 CATCH_ALL_DUAL 03597 } 03598 03599 STDMETHODIMP CGMEOLEIt::XDual::Instantiate(THIS_ BSTR base, BSTR name_of_instance, IMgaFCO** instance) 03600 { 03601 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03602 03603 TRY_DUAL(__uuidof(IGMEOLEIt)) 03604 { 03605 LPDISPATCH lpDisp = pThis->Instantiate( (LPCTSTR) base, (LPCTSTR) name_of_instance); 03606 lpDisp->QueryInterface(__uuidof(IMgaFCO), (LPVOID*) instance); 03607 } 03608 CATCH_ALL_DUAL 03609 } 03610 03611 STDMETHODIMP CGMEOLEIt::XDual::SubTypeFCO(THIS_ IMgaFCO* base_ptr, BSTR name_of_subtype, IMgaFCO** subtype) 03612 { 03613 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03614 03615 TRY_DUAL(__uuidof(IGMEOLEIt)) 03616 { 03617 LPDISPATCH lpDisp = pThis->SubTypeFCO( base_ptr, (LPCTSTR) name_of_subtype); 03618 lpDisp->QueryInterface(__uuidof(IMgaFCO), (LPVOID*) subtype); 03619 } 03620 CATCH_ALL_DUAL 03621 } 03622 03623 STDMETHODIMP CGMEOLEIt::XDual::InstantiateFCO(THIS_ IMgaFCO* base_ptr, BSTR name_of_instance, IMgaFCO** instance) 03624 { 03625 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03626 03627 TRY_DUAL(__uuidof(IGMEOLEIt)) 03628 { 03629 LPDISPATCH lpDisp = pThis->InstantiateFCO( base_ptr, (LPCTSTR) name_of_instance); 03630 lpDisp->QueryInterface(__uuidof(IMgaFCO), (LPVOID*) instance); 03631 } 03632 CATCH_ALL_DUAL 03633 } 03634 03635 STDMETHODIMP CGMEOLEIt::XDual::BeginTransaction() 03636 { 03637 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03638 03639 TRY_DUAL(__uuidof(IGMEOLEIt)) 03640 { 03641 pThis->BeginTransaction(); 03642 } 03643 CATCH_ALL_DUAL 03644 } 03645 03646 STDMETHODIMP CGMEOLEIt::XDual::CommitTransaction() 03647 { 03648 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03649 03650 TRY_DUAL(__uuidof(IGMEOLEIt)) 03651 { 03652 pThis->CommitTransaction(); 03653 } 03654 CATCH_ALL_DUAL 03655 } 03656 03657 STDMETHODIMP CGMEOLEIt::XDual::AbortTransaction() 03658 { 03659 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03660 03661 TRY_DUAL(__uuidof(IGMEOLEIt)) 03662 { 03663 pThis->AbortTransaction(); 03664 } 03665 CATCH_ALL_DUAL 03666 } 03667 03668 STDMETHODIMP CGMEOLEIt::XDual::IsInTransaction(THIS_ VARIANT_BOOL* intrans) 03669 { 03670 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03671 03672 TRY_DUAL(__uuidof(IGMEOLEIt)) 03673 { 03674 *intrans = pThis->IsInTransaction(); 03675 } 03676 CATCH_ALL_DUAL 03677 } 03678 03679 STDMETHODIMP CGMEOLEIt::XDual::PutInTerritory(THIS_ IMgaFCO* fco, IMgaFCO** newfco) 03680 { 03681 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03682 03683 TRY_DUAL(__uuidof(IGMEOLEIt)) 03684 { 03685 LPDISPATCH lpDisp = pThis->PutInTerritory( fco); 03686 lpDisp->QueryInterface(__uuidof(IMgaFCO), (LPVOID*) newfco); 03687 return NOERROR; 03688 } 03689 CATCH_ALL_DUAL 03690 } 03691 03692 STDMETHODIMP CGMEOLEIt::XDual::Help(THIS) 03693 { 03694 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03695 03696 TRY_DUAL(__uuidof(IGMEOLEIt)) 03697 { 03698 pThis->Help(); 03699 return NOERROR; 03700 } 03701 CATCH_ALL_DUAL 03702 } 03703 03704 STDMETHODIMP CGMEOLEIt::XDual::SetSelected(THIS_ BSTR space_delimited_string ) 03705 { 03706 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03707 03708 TRY_DUAL(__uuidof(IGMEOLEIt)) 03709 { 03710 pThis->SetSelected( (LPCTSTR) space_delimited_string); 03711 return NOERROR; 03712 } 03713 CATCH_ALL_DUAL 03714 } 03715 03716 STDMETHODIMP CGMEOLEIt::XDual::GetSelected(THIS_ BSTR * space_delimited_string ) 03717 { 03718 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03719 03720 TRY_DUAL(__uuidof(IGMEOLEIt)) 03721 { 03722 CComBSTR p = pThis->GetSelected(); 03723 *space_delimited_string = p.Detach(); 03724 return NOERROR; 03725 } 03726 CATCH_ALL_DUAL 03727 } 03728 03729 STDMETHODIMP CGMEOLEIt::XDual::SetSelectedFCOs(THIS_ IMgaFCOs* fcos_to_select) 03730 { 03731 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03732 03733 TRY_DUAL(__uuidof(IGMEOLEIt)) 03734 { 03735 TRACE( _T("XDual::SetSelectedFCOs")); 03736 pThis->SetSelectedFCOs( fcos_to_select); 03737 return NOERROR; 03738 } 03739 CATCH_ALL_DUAL 03740 } 03741 03742 STDMETHODIMP CGMEOLEIt::XDual::GetSelectedFCOs(THIS_ IMgaFCOs** selected_fcos) 03743 { 03744 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03745 03746 TRY_DUAL(__uuidof(IGMEOLEIt)) 03747 { 03748 TRACE( _T("XDual::GetSelectedFCOs")); 03749 LPDISPATCH lpDisp = pThis->GetSelectedFCOs(); 03750 lpDisp->QueryInterface(__uuidof(IMgaFCOs), (LPVOID*)selected_fcos); 03751 03752 return NOERROR; 03753 } 03754 CATCH_ALL_DUAL 03755 } 03756 03757 STDMETHODIMP CGMEOLEIt::XDual::GetCurrentAspect(THIS_ BSTR* aspectName) 03758 { 03759 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03760 03761 TRY_DUAL(__uuidof(IGMEOLEIt)) 03762 { 03763 CComBSTR string_asp = pThis->GetCurrentAspect(); 03764 *aspectName = string_asp.Detach(); 03765 return NOERROR; 03766 } 03767 CATCH_ALL_DUAL 03768 } 03769 03770 STDMETHODIMP CGMEOLEIt::XDual::SetCurrentAspect(THIS_ BSTR aspectName) 03771 { 03772 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03773 03774 TRY_DUAL(__uuidof(IGMEOLEIt)) 03775 { 03776 pThis->SetCurrentAspect(CString(aspectName)); 03777 return S_OK; 03778 } 03779 CATCH_ALL_DUAL 03780 } 03781 03782 STDMETHODIMP CGMEOLEIt::XDual::NextAspect(THIS) 03783 { 03784 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03785 03786 TRY_DUAL(__uuidof(IGMEOLEIt)) 03787 { 03788 pThis->NextAspect(); 03789 return NOERROR; 03790 } 03791 CATCH_ALL_DUAL 03792 } 03793 03794 STDMETHODIMP CGMEOLEIt::XDual::PrevAspect(THIS) 03795 { 03796 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03797 03798 TRY_DUAL(__uuidof(IGMEOLEIt)) 03799 { 03800 pThis->PrevAspect(); 03801 return NOERROR; 03802 } 03803 CATCH_ALL_DUAL 03804 } 03805 03806 STDMETHODIMP CGMEOLEIt::XDual::Next(THIS) 03807 { 03808 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03809 03810 TRY_DUAL(__uuidof(IGMEOLEIt)) 03811 { 03812 pThis->Next(); 03813 return NOERROR; 03814 } 03815 CATCH_ALL_DUAL 03816 } 03817 03818 STDMETHODIMP CGMEOLEIt::XDual::Prev(THIS) 03819 { 03820 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03821 03822 TRY_DUAL(__uuidof(IGMEOLEIt)) 03823 { 03824 pThis->Prev(); 03825 return NOERROR; 03826 } 03827 CATCH_ALL_DUAL 03828 } 03829 03830 STDMETHODIMP CGMEOLEIt::XDual::Position(THIS_ BSTR pChildName, BSTR pAspectName, long parX, long parY) 03831 { 03832 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03833 03834 TRY_DUAL(__uuidof(IGMEOLEIt)) 03835 { 03836 pThis->Position( (LPCTSTR) pChildName, (LPCTSTR) pAspectName, parX, parY); 03837 return NOERROR; 03838 } 03839 CATCH_ALL_DUAL 03840 } 03841 03842 STDMETHODIMP CGMEOLEIt::XDual::PositionFCO(THIS_ IMgaFCO* pChildPtr, BSTR pAspectName, long parX, long parY) 03843 { 03844 METHOD_PROLOGUE(CGMEOLEIt, Dual) 03845 03846 TRY_DUAL(__uuidof(IGMEOLEIt)) 03847 { 03848 pThis->PositionFCO( pChildPtr, (LPCTSTR) pAspectName, parX, parY); 03849 return NOERROR; 03850 } 03851 CATCH_ALL_DUAL 03852 }