Salome HOME
Merge with PAL/SALOME 2.1.0d
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_StudyBuilder_i.cxx
1 //  SALOME SALOMEDS : data structure of SALOME and sources of Salome data server 
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SALOMEDS_StudyBuilder_i.cxx
25 //  Author : Yves FRICAUD
26 //  Module : SALOME
27 //  $Header$
28
29 #include "utilities.h"
30 #include "SALOMEDS_Study_i.hxx"
31 //#include "SALOMEDS_StudyBuilder_i.hxx"
32 #include "SALOMEDS_SObject_i.hxx"
33 #include "SALOMEDS_SComponent_i.hxx"
34
35 #include "SALOMEDS_IORAttribute.hxx"
36 #include "SALOMEDS_PersRefAttribute.hxx"
37 #include "SALOMEDS_TargetAttribute.hxx"
38 #include "SALOMEDS_StudyPropertiesAttribute.hxx"
39 #include "SALOMEDS_PythonObjectAttribute.hxx"
40 #include "SALOMEDS_ExternalFileDef.hxx"
41 #include "SALOMEDS_FileType.hxx"
42 #include <TDF_ChildIterator.hxx>
43 #include <TDF_Label.hxx>
44 #include <TDataStd_Name.hxx>
45 #include <TDataStd_Comment.hxx>
46 #include <TDataStd_UAttribute.hxx>
47 #include <TDataStd_Real.hxx>
48 #include <TDF_Tool.hxx>
49 #include <TDF_Reference.hxx>
50 #include <TDF_Data.hxx>
51 #include <TDataStd_ChildNodeIterator.hxx>
52 #include <TDF_ListIteratorOfAttributeList.hxx>
53 #include "SALOMEDS_AttributePersistentRef_i.hxx"
54 #include "SALOMEDS_AttributeIOR_i.hxx"
55 #include "SALOMEDS_AttributeExternalFileDef_i.hxx"
56 #include "SALOMEDS_AttributeFileType_i.hxx"
57 #include "SALOMEDS_AttributeComment_i.hxx"
58 #include "SALOMEDS_AttributeName_i.hxx"
59 #include "SALOMEDS_AttributeSequenceOfInteger_i.hxx"
60 #include "SALOMEDS_AttributeSequenceOfReal_i.hxx"
61 #include "SALOMEDS_AttributeTableOfInteger_i.hxx"
62 #include "SALOMEDS_AttributeTableOfReal_i.hxx"
63 #include "SALOMEDS_AttributeTableOfString_i.hxx"
64 #include "SALOMEDS_AttributeInteger_i.hxx"
65 #include "SALOMEDS_AttributeReal_i.hxx"
66 #include "SALOMEDS_AttributeDrawable_i.hxx"
67 #include "SALOMEDS_AttributeSelectable_i.hxx"
68 #include "SALOMEDS_AttributeExpandable_i.hxx"
69 #include "SALOMEDS_AttributeOpened_i.hxx"
70 #include "SALOMEDS_AttributeFlags_i.hxx"
71 #include "SALOMEDS_AttributeGraphic_i.hxx"
72 #include "SALOMEDS_AttributeTextColor_i.hxx"
73 #include "SALOMEDS_AttributeTextHighlightColor_i.hxx"
74 #include "SALOMEDS_AttributePixMap_i.hxx"
75 #include "SALOMEDS_AttributeTreeNode_i.hxx"
76 #include "SALOMEDS_AttributeTarget_i.hxx"
77 #include "SALOMEDS_AttributeLocalID_i.hxx"
78 #include "SALOMEDS_AttributeUserID_i.hxx"
79 #include "SALOMEDS_AttributeStudyProperties_i.hxx"
80 #include "SALOMEDS_AttributePythonObject_i.hxx"
81 #include "SALOMEDS_Tool.hxx"
82 #include "Utils_CorbaException.hxx"
83 #include "Utils_ExceptHandlers.hxx"
84
85 #include <HDFOI.hxx>
86 #include <stdlib.h> 
87
88 using namespace std;
89
90 #define USE_CASE_LABEL_TAG            2
91 #define DIRECTORYID 16661
92 #define FILELOCALID 26662 
93
94 UNEXPECT_CATCH(SBSalomeException, SALOME::SALOME_Exception);
95 UNEXPECT_CATCH(SBLockProtection, SALOMEDS::StudyBuilder::LockProtection);
96 //============================================================================
97 /*! Function : constructor
98  *  Purpose  :
99  */
100 //============================================================================
101 SALOMEDS_StudyBuilder_i::SALOMEDS_StudyBuilder_i(const Handle(TDocStd_Document) doc, 
102                                                  CORBA::ORB_ptr orb) : _doc(doc)
103 {
104   _orb = CORBA::ORB::_duplicate(orb);
105 }
106
107 //============================================================================
108 /*! Function : destructor
109  *  Purpose  :
110  */
111 //============================================================================
112 SALOMEDS_StudyBuilder_i::~SALOMEDS_StudyBuilder_i()
113 {
114 }
115
116 //============================================================================
117 /*! Function : NewComponent
118  *  Purpose  : Create a new component (Scomponent)
119  */
120 //============================================================================
121 SALOMEDS::SComponent_ptr 
122 SALOMEDS_StudyBuilder_i::NewComponent(const char* DataType)
123 {
124   CheckLocked();
125   //Always create component under main label.
126   TDF_Label L  = _doc->Main();
127
128   // YFR DEBUG : 13/02/2002 TDF_Label NL = L.NewChild();
129   
130   Standard_Integer imax = 0;
131   for (TDF_ChildIterator it(L); it.More(); it.Next()) {
132     if (it.Value().Tag() > imax)
133       imax = it.Value().Tag();
134   }
135   imax++;
136   TDF_Label NL = L.FindChild(imax);
137
138    TDataStd_Comment::Set(NL,Standard_CString(DataType));
139    //  TDataStd_Comment::Set(NL,Standard_CString(CORBA::string_dup(DataType)));
140
141   SALOMEDS_SComponent_i *  so_servant = new SALOMEDS_SComponent_i (NL,_orb);
142   SALOMEDS::SComponent_var so;
143   so= SALOMEDS::SComponent::_narrow(so_servant->SComponent::_this()); 
144
145   if(!CORBA::is_nil(_callbackOnAdd)) _callbackOnAdd->OnAddSObject(so);
146
147   return so;
148 }
149
150 //============================================================================
151 /*! Function : DefineComponentInstance
152  *  Purpose  : Add IOR attribute of a Scomponent
153  */
154 //============================================================================
155 void SALOMEDS_StudyBuilder_i::DefineComponentInstance(SALOMEDS::SComponent_ptr aComponent,
156                                                  CORBA::Object_ptr IOR)
157 {
158   CheckLocked();
159   //Find label
160   TDF_Label Lab;
161   ASSERT(!CORBA::is_nil(aComponent));
162   CORBA::String_var compid = aComponent->GetID();
163   TDF_Tool::Label(_doc->GetData(),compid,Lab);
164
165   //add IOR definition 
166   ASSERT(!CORBA::is_nil(IOR));
167   CORBA::String_var iorstr = _orb->object_to_string(IOR);
168   SALOMEDS_IORAttribute::Set(Lab,(char*)iorstr,_orb);
169   
170 }
171
172 //============================================================================
173 /*! Function : RemoveComponent
174  *  Purpose  : Delete a Scomponent
175  */
176 //============================================================================
177 void 
178 SALOMEDS_StudyBuilder_i::RemoveComponent(SALOMEDS::SComponent_ptr aComponent)
179 {
180   CheckLocked();
181   ASSERT(!CORBA::is_nil(aComponent));
182   RemoveObject(aComponent);
183 }
184
185 //============================================================================
186 /*! Function : NewObject
187  *  Purpose  : Create a new SObject
188  */
189 //============================================================================
190 SALOMEDS::SObject_ptr 
191 SALOMEDS_StudyBuilder_i::NewObject(SALOMEDS::SObject_ptr theFatherObject)
192 {
193   CheckLocked();
194   TCollection_AsciiString anEntry;
195  
196   //Find label of father
197   TDF_Label Lab;
198   
199   ASSERT(!CORBA::is_nil(theFatherObject));
200   CORBA::String_var fatherid = theFatherObject->GetID();
201   TDF_Tool::Label(_doc->GetData(),fatherid,Lab);
202
203   //Create a new label
204   //YFR DEBUG : 13/02/2002  TDF_Label NewLab = Lab.NewChild();
205   Standard_Integer imax = 0;
206   for (TDF_ChildIterator it(Lab); it.More(); it.Next()) {
207     if (it.Value().Tag() > imax)
208       imax = it.Value().Tag();
209   }
210   imax++;
211   TDF_Label NewLab = Lab.FindChild(imax);
212   
213   SALOMEDS_SObject_i *  so_servant = new SALOMEDS_SObject_i (NewLab,_orb);
214   SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); 
215
216   if(!CORBA::is_nil(_callbackOnAdd)) _callbackOnAdd->OnAddSObject(so);
217
218   return so;
219 }
220
221 //============================================================================
222 /*! Function : NewObjectToTag
223  *  Purpose  :
224  */
225 //============================================================================
226 SALOMEDS::SObject_ptr 
227 SALOMEDS_StudyBuilder_i::NewObjectToTag(SALOMEDS::SObject_ptr theFatherObject,
228                                         CORBA::Long atag)
229 {
230   CheckLocked();
231   //Find label of father
232   TDF_Label Lab;
233
234   ASSERT(!CORBA::is_nil(theFatherObject));
235   CORBA::String_var fatherid = theFatherObject->GetID();
236   TDF_Tool::Label(_doc->GetData(),fatherid,Lab);
237   //Create or find label
238   TDF_Label NewLab = Lab.FindChild(atag,1);
239
240   SALOMEDS_SObject_i *  so_servant = new SALOMEDS_SObject_i (NewLab,_orb);
241   SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); 
242
243   if(!CORBA::is_nil(_callbackOnAdd)) _callbackOnAdd->OnAddSObject(so);
244
245   return so;
246 }
247
248 //============================================================================
249 /*! Function : RemoveObject
250  *  Purpose  :
251  */
252 //============================================================================
253 void SALOMEDS_StudyBuilder_i::RemoveObject(SALOMEDS::SObject_ptr anObject)
254 {
255   CheckLocked();
256   if(!CORBA::is_nil(_callbackOnRemove)) _callbackOnRemove->OnRemoveSObject(anObject);
257
258   TDF_Label Lab;
259   ASSERT(!CORBA::is_nil(anObject));
260   TDF_Tool::Label(_doc->GetData(),anObject->GetID(),Lab);
261
262   Handle(TDF_Reference) aReference;
263   if (Lab.FindAttribute(TDF_Reference::GetID(), aReference)) {
264     Handle(SALOMEDS_TargetAttribute) aTarget;
265     if (aReference->Get().FindAttribute(SALOMEDS_TargetAttribute::GetID(),aTarget))
266       aTarget->Remove(Lab);
267   }
268
269   Handle(SALOMEDS_IORAttribute) anAttr; // postponed removing of CORBA objects
270   if (Lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr))
271     SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString());
272
273   Lab.ForgetAllAttributes();
274 }
275
276 //============================================================================
277 /*! Function : RemoveObjectWithChildren
278  *  Purpose  :
279  */
280 //============================================================================
281 void SALOMEDS_StudyBuilder_i::RemoveObjectWithChildren(SALOMEDS::SObject_ptr anObject)
282 {
283   CheckLocked();
284   if(!CORBA::is_nil(_callbackOnRemove)) _callbackOnRemove->OnRemoveSObject(anObject);
285
286   TDF_Label Lab;
287   ASSERT(!CORBA::is_nil(anObject));
288   TDF_Tool::Label(_doc->GetData(),anObject->GetID(),Lab);
289
290   Handle(TDF_Reference) aReference;
291   if (Lab.FindAttribute(TDF_Reference::GetID(), aReference)) {
292     Handle(SALOMEDS_TargetAttribute) aTarget;
293     if (aReference->Get().FindAttribute(SALOMEDS_TargetAttribute::GetID(),aTarget))
294       aTarget->Remove(Lab);
295   }
296   Handle(SALOMEDS_IORAttribute) anAttr; // postponed removing of CORBA objects
297   if (Lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr))
298     SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString());
299
300   TDF_ChildIterator it(Lab, Standard_True);
301   for(;it.More();it.Next()) {
302     TDF_Label aLabel = it.Value();
303     if (aLabel.FindAttribute(TDF_Reference::GetID(), aReference)) {
304       Handle(SALOMEDS_TargetAttribute) aTarget;
305       if (aReference->Get().FindAttribute(SALOMEDS_TargetAttribute::GetID(),aTarget))
306         aTarget->Remove(aLabel);
307     }
308     Handle(SALOMEDS_IORAttribute) anAttr; // postponed removing of CORBA objects
309     if (aLabel.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr))
310       SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString());
311   }
312
313   Lab.ForgetAllAttributes(Standard_True);
314 }
315
316 //============================================================================
317 /*! Function : Translate_persistentID_to_IOR
318  *  Purpose  :
319  */
320 //============================================================================
321 static void  Translate_persistentID_to_IOR(TDF_Label                  Lab,
322                                            SALOMEDS::Driver_ptr       driver,
323                                            CORBA::ORB_ptr             orb,
324                                            CORBA::Boolean             isMultiFile,
325                                            CORBA::Boolean             isASCII)
326 {
327   TDF_ChildIterator  itchild (Lab);
328   
329   for (; itchild.More(); itchild.Next()) {
330     TDF_Label current = itchild.Value();
331     Handle(TDF_Attribute) Att;
332     if (current.FindAttribute(SALOMEDS_PersRefAttribute::GetID(),Att)) {  
333
334       Handle(SALOMEDS_LocalIDAttribute) anID;
335       if (current.FindAttribute(SALOMEDS_LocalIDAttribute::GetID(), anID)) 
336         if (anID->Get() == FILELOCALID) continue;        //SRN: This attribute store a file name, skip it 
337
338       TCollection_ExtendedString res;   
339       res = Handle(TDataStd_Comment)::DownCast(Att)->Get();
340       TCollection_AsciiString ch(res);
341       
342       CORBA::String_var persistent_string = CORBA::string_dup(ch.ToCString());
343       ASSERT(! CORBA::is_nil(driver));
344       SALOMEDS_SObject_i *  so_servant = new SALOMEDS_SObject_i (current,orb);
345       SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); 
346
347       CORBA::String_var ior_string = driver->LocalPersistentIDToIOR(so, persistent_string, isMultiFile, isASCII);
348
349       TCollection_ExtendedString value(ior_string); 
350       SALOMEDS_IORAttribute::Set (current,value,orb); 
351       
352       //TCollection_AsciiString anEntry;TDF_Tool::Entry (current,anEntry); //SRN: No use here
353       //delete persistent_string;
354       //delete ior_string;
355     }
356     Translate_persistentID_to_IOR (current,driver,orb,isMultiFile, isASCII);
357   }
358 }
359
360 //============================================================================
361 /*! Function : LoadWith
362  *  Purpose  : 
363  */
364 //============================================================================
365
366 //============================================================================
367 void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr anSCO, 
368                                        SALOMEDS::Driver_ptr aDriver) throw(SALOME::SALOME_Exception)
369 {
370   Unexpect aCatch(SBSalomeException);
371   TDF_Label Lab;
372   ASSERT(!CORBA::is_nil(anSCO));
373   CORBA::String_var scoid = anSCO->GetID();
374   TDF_Tool::Label(_doc->GetData(),scoid,Lab);
375   Handle(TDF_Attribute) Att;
376   
377   //Find the current Url of the study  
378   if (_doc->Main().FindAttribute(SALOMEDS_PersRefAttribute::GetID(),Att)) {
379     int aLocked = anSCO->GetStudy()->GetProperties()->IsLocked();
380     if (aLocked) anSCO->GetStudy()->GetProperties()->SetLocked(false);
381     
382     TCollection_ExtendedString Res = Handle(TDataStd_Comment)::DownCast(Att)->Get();
383     
384     Handle(TDataStd_Comment) type;
385     TCollection_ExtendedString DataType;
386     if (Lab.FindAttribute(TDataStd_Comment::GetID(),type))
387       DataType = type->Get();
388     else 
389       MESSAGE("No Data Type");
390     
391     // associate the driver to the SComponent
392     ASSERT(!CORBA::is_nil(aDriver));
393     // mpv 06.03.2003: SAL1927 - if component data if already loaded, it is not necessary to do it again
394     if (Lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), Att)) {
395       if (aLocked) anSCO->GetStudy()->GetProperties()->SetLocked(true);
396       return;
397     }
398     DefineComponentInstance (anSCO, aDriver);
399     
400     TCollection_AsciiString aHDFPath(Res);
401     
402     char* aHDFUrl;
403     bool isASCII = false;
404     if (HDFascii::isASCII(aHDFPath.ToCString())) {
405       isASCII = true;
406       char* aResultPath = HDFascii::ConvertFromASCIIToHDF(aHDFPath.ToCString());
407       aHDFUrl = new char[strlen(aResultPath) + 19];
408       sprintf(aHDFUrl, "%shdf_from_ascii.hdf", aResultPath);
409       delete(aResultPath);
410     } else {
411       aHDFUrl = CORBA::string_dup(aHDFPath.ToCString());
412     }
413
414     //Open the Study HDF file 
415     HDFfile *hdf_file = new HDFfile(aHDFUrl); 
416     
417     char aMultifileState[2];
418     char ASCIIfileState[2];
419     try {
420       CORBA::String_var scoid = anSCO->GetID();
421       hdf_file->OpenOnDisk(HDF_RDONLY);
422       HDFgroup *hdf_group = new HDFgroup("DATACOMPONENT",hdf_file);
423       hdf_group->OpenOnDisk();
424       HDFgroup *hdf_sco_group = new HDFgroup(scoid, hdf_group);
425       hdf_sco_group->OpenOnDisk();
426         
427       SALOMEDS::TMPFile_var aStreamFile;
428       if (hdf_sco_group->ExistInternalObject("FILE_STREAM")) {
429         HDFdataset *hdf_dataset = new HDFdataset("FILE_STREAM", hdf_sco_group);
430         hdf_dataset->OpenOnDisk();
431         int aStreamSize = hdf_dataset->GetSize();
432         unsigned char* aBuffer = new unsigned char[aStreamSize];
433         if(aBuffer == NULL) throw HDFexception("Unable to open dataset FILE_STREAM");
434         hdf_dataset->ReadFromDisk(aBuffer);
435         aStreamFile = new SALOMEDS::TMPFile(aStreamSize, aStreamSize, aBuffer, 1);
436         hdf_dataset->CloseOnDisk();
437         hdf_dataset = 0;
438       } else aStreamFile = new SALOMEDS::TMPFile(0);
439       
440       HDFdataset *multifile_hdf_dataset = new HDFdataset("MULTIFILE_STATE", hdf_sco_group);
441       multifile_hdf_dataset->OpenOnDisk();
442       multifile_hdf_dataset->ReadFromDisk(aMultifileState);
443       
444       HDFdataset *ascii_hdf_dataset = new HDFdataset("ASCII_STATE", hdf_sco_group);
445       ascii_hdf_dataset->OpenOnDisk();
446       ascii_hdf_dataset->ReadFromDisk(ASCIIfileState);
447       
448       // set path without file name from URL 
449       int aFileNameSize = Res.Length();
450       char* aDir = new char[aFileNameSize];
451       memcpy(aDir, TCollection_AsciiString(Res).ToCString(), aFileNameSize);
452       for(int aCounter = aFileNameSize-1; aCounter>=0; aCounter--)
453         if (aDir[aCounter] == '/') {
454           aDir[aCounter+1] = 0;
455           break;
456         }
457       
458       CORBA::Boolean aResult = (ASCIIfileState[0]=='A')?
459         aDriver->LoadASCII(anSCO, aStreamFile.in(), aDir, aMultifileState[0]=='M'):
460           aDriver->Load(anSCO, aStreamFile.in(), aDir, aMultifileState[0]=='M');
461       if(!aResult) {
462         RemoveAttribute( anSCO, "AttributeIOR" );
463
464         MESSAGE("Can't load component");
465         //THROW_SALOME_CORBA_EXCEPTION("Unable to load component data",SALOME::BAD_PARAM);
466         throw HDFexception("Unable to load component");
467       }
468       
469       delete(aDir);
470
471       multifile_hdf_dataset->CloseOnDisk();
472       multifile_hdf_dataset = 0;
473       ascii_hdf_dataset->CloseOnDisk();
474       ascii_hdf_dataset = 0;
475       hdf_sco_group->CloseOnDisk();
476       hdf_sco_group = 0;
477       hdf_group->CloseOnDisk();
478       hdf_group = 0;
479       hdf_file->CloseOnDisk();
480       delete hdf_file;
481       
482       if (isASCII) {
483         SALOMEDS::ListOfFileNames_var aFilesToRemove = new SALOMEDS::ListOfFileNames;
484         aFilesToRemove->length(1);
485         aFilesToRemove[0] = CORBA::string_dup(&(aHDFUrl[strlen(SALOMEDS_Tool::GetDirFromPath(aHDFUrl).c_str())]));
486         SALOMEDS_Tool::RemoveTemporaryFiles(SALOMEDS_Tool::GetDirFromPath(aHDFUrl).c_str(), aFilesToRemove, true);
487       }
488       delete aHDFUrl;
489     }
490     catch (HDFexception) {
491       INFOS("No persistent file Name");
492       delete hdf_file;
493       if (isASCII) {
494         SALOMEDS::ListOfFileNames_var aFilesToRemove = new SALOMEDS::ListOfFileNames;
495         aFilesToRemove->length(1);
496         aFilesToRemove[0] = CORBA::string_dup(&(aHDFUrl[strlen(SALOMEDS_Tool::GetDirFromPath(aHDFUrl).c_str())]));
497         SALOMEDS_Tool::RemoveTemporaryFiles(SALOMEDS_Tool::GetDirFromPath(aHDFUrl).c_str(), aFilesToRemove, true);
498       }
499       delete aHDFUrl;
500       if (aLocked) anSCO->GetStudy()->GetProperties()->SetLocked(true);
501       THROW_SALOME_CORBA_EXCEPTION("No persistent file Name found",SALOME::BAD_PARAM);   
502     }
503     
504     try {
505       Translate_persistentID_to_IOR (Lab,aDriver,_orb, aMultifileState[0]=='M', ASCIIfileState[0] == 'A');
506     } catch (SALOME::SALOME_Exception) {
507       INFOS("Can't translate PersRef to IOR");
508       if (aLocked) anSCO->GetStudy()->GetProperties()->SetLocked(true);
509       THROW_SALOME_CORBA_EXCEPTION("Unable to convert component persistent data to the transient",SALOME::BAD_PARAM);
510       //        throw HDFexception("Unable to load component data");
511     }
512     if (aLocked) anSCO->GetStudy()->GetProperties()->SetLocked(true);
513   } else
514     MESSAGE("No persistent file Name");
515 }
516
517
518 //============================================================================
519 /*! Function : Load
520  *  Purpose  : 
521  */
522 //============================================================================
523 void SALOMEDS_StudyBuilder_i::Load(SALOMEDS::SObject_ptr sco)
524 {
525   MESSAGE ( "This function is not yet implemented");
526 }
527
528 //============================================================================
529 /*! Function : FindOrCreateAttribute
530  *  Purpose  : Add attribute of given type to SObject, if there is attribute of such type, returns
531  *  existing one
532  */
533 //============================================================================
534 SALOMEDS::GenericAttribute_ptr SALOMEDS_StudyBuilder_i::FindOrCreateAttribute(SALOMEDS::SObject_ptr anObject, 
535                                                                               const char* aTypeOfAttribute)
536 {
537   TDF_Label Lab;
538   ASSERT(!CORBA::is_nil(anObject));
539   CORBA::String_var anobid = anObject->GetID();
540   TDF_Tool::Label(_doc->GetData(),anobid,Lab);
541
542   __FindOrCreateAttributeLocked(TDataStd_Real, AttributeReal)
543   __FindOrCreateAttributeLocked(TDataStd_Integer, AttributeInteger)
544   __FindOrCreateAttributeLocked(SALOMEDS_SequenceOfRealAttribute, AttributeSequenceOfReal)
545   __FindOrCreateAttributeLocked(SALOMEDS_SequenceOfIntegerAttribute, AttributeSequenceOfInteger)
546   __FindOrCreateAttributeLocked(TDataStd_Name, AttributeName)
547   __FindOrCreateAttributeLocked(TDataStd_Comment, AttributeComment)
548   __FindOrCreateAttributeLocked(SALOMEDS_IORAttribute, AttributeIOR)
549   __FindOrCreateAttributeLocked(SALOMEDS_PixMapAttribute, AttributePixMap)
550   __FindOrCreateAttributeLocked(SALOMEDS_LocalIDAttribute, AttributeLocalID)
551   __FindOrCreateAttributeLocked(SALOMEDS_TableOfIntegerAttribute, AttributeTableOfInteger)
552   __FindOrCreateAttributeLocked(SALOMEDS_TableOfRealAttribute, AttributeTableOfReal)
553   __FindOrCreateAttributeLocked(SALOMEDS_TableOfStringAttribute, AttributeTableOfString)
554   __FindOrCreateAttributeLocked(SALOMEDS_PythonObjectAttribute, AttributePythonObject)
555
556   __FindOrCreateAttribute(SALOMEDS_PersRefAttribute, AttributePersistentRef)
557   __FindOrCreateAttribute(SALOMEDS_DrawableAttribute, AttributeDrawable)
558   __FindOrCreateAttribute(SALOMEDS_SelectableAttribute, AttributeSelectable)
559   __FindOrCreateAttribute(SALOMEDS_ExpandableAttribute, AttributeExpandable)
560   __FindOrCreateAttribute(SALOMEDS_OpenedAttribute, AttributeOpened)
561   __FindOrCreateAttribute(SALOMEDS_TextColorAttribute, AttributeTextColor)
562   __FindOrCreateAttribute(SALOMEDS_TextHighlightColorAttribute, AttributeTextHighlightColor)
563   __FindOrCreateAttribute(SALOMEDS_TargetAttribute, AttributeTarget)
564   __FindOrCreateAttribute(SALOMEDS_StudyPropertiesAttribute, AttributeStudyProperties)
565   __FindOrCreateAttribute(SALOMEDS_ExternalFileDef, AttributeExternalFileDef)
566   __FindOrCreateAttribute(SALOMEDS_FileType, AttributeFileType)
567   __FindOrCreateAttribute(SALOMEDS_FlagsAttribute, AttributeFlags)
568   __FindOrCreateAttribute(SALOMEDS_GraphicAttribute, AttributeGraphic)    
569
570   if (strncmp(aTypeOfAttribute, "AttributeTreeNode",17) == 0 ) {
571     Standard_GUID aTreeNodeGUID;
572     if (strcmp(aTypeOfAttribute, "AttributeTreeNode") == 0) {
573       aTreeNodeGUID = TDataStd_TreeNode::GetDefaultTreeID();
574     } else {
575       char* aGUIDString = new char[40];
576       sprintf(aGUIDString, &(aTypeOfAttribute[21]));
577       aTreeNodeGUID = Standard_GUID(aGUIDString); // create tree node GUID by name
578       delete(aGUIDString);
579     }
580     Handle(TDataStd_TreeNode) anAttr;
581     if (!Lab.FindAttribute(aTreeNodeGUID, anAttr)) {
582       CheckLocked();
583       anAttr = TDataStd_TreeNode::Set(Lab, aTreeNodeGUID);
584     }
585     SALOMEDS_AttributeTreeNode_i* aTreeNodeAttr = new SALOMEDS_AttributeTreeNode_i(anAttr, _orb);
586     return aTreeNodeAttr->AttributeTreeNode::_this();
587   }
588
589   if (strncmp(aTypeOfAttribute, "AttributeUserID",15) == 0 ) {
590     Handle(TDataStd_UAttribute) anAttr;
591     if (!Lab.FindAttribute(SALOMEDS_AttributeUserID_i::DefaultID(), anAttr)) {
592       CheckLocked();
593       anAttr = TDataStd_UAttribute::Set(Lab, SALOMEDS_AttributeUserID_i::DefaultID());
594     }
595     SALOMEDS_AttributeUserID_i* aUAttr = new SALOMEDS_AttributeUserID_i(anAttr, _orb);
596     return aUAttr->AttributeUserID::_this();
597   }
598   return SALOMEDS::GenericAttribute::_nil();
599 }
600
601 //============================================================================
602 /*! Function : FindAttribute
603  *  Purpose  : Find attribute of given type assigned SObject, returns Standard_True if it is found
604  */
605 //============================================================================
606
607 CORBA::Boolean SALOMEDS_StudyBuilder_i::FindAttribute(SALOMEDS::SObject_ptr anObject, 
608                                                              SALOMEDS::GenericAttribute_out anAttribute, 
609                                                              const char* aTypeOfAttribute)
610 {
611   TDF_Label Lab;
612   ASSERT(!CORBA::is_nil(anObject));
613   CORBA::String_var anobid = anObject->GetID();
614   TDF_Tool::Label(_doc->GetData(),anobid,Lab);
615   Handle(TDF_Attribute) anAttr;
616   if (Lab.FindAttribute(SALOMEDS_GenericAttribute_i::GetGUID(aTypeOfAttribute), anAttr)) {
617     anAttribute = SALOMEDS::GenericAttribute::_duplicate(SALOMEDS_GenericAttribute_i::CreateAttribute(_orb, anAttr));
618     return Standard_True;
619   }
620   return Standard_False;
621 }
622
623 //============================================================================
624 /*! Function : RemoveAttribute
625  *  Purpose  : Remove attribute of given type assigned SObject
626  */
627 //============================================================================
628
629 void SALOMEDS_StudyBuilder_i::RemoveAttribute(SALOMEDS::SObject_ptr anObject, 
630                                               const char* aTypeOfAttribute)
631 {
632   CheckLocked();
633   TDF_Label Lab;
634   ASSERT(!CORBA::is_nil(anObject));
635   CORBA::String_var anobid = anObject->GetID();
636   TDF_Tool::Label(_doc->GetData(),anobid,Lab);
637   
638   if (strcmp(aTypeOfAttribute, "AttributeIOR") == 0) { // postponed removing of CORBA objects
639     Handle(SALOMEDS_IORAttribute) anAttr;
640     if (Lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr))
641       SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString());
642     else return;
643   }
644
645   Lab.ForgetAttribute (SALOMEDS_GenericAttribute_i::GetGUID(aTypeOfAttribute));
646 }
647
648 //============================================================================
649 /*! Function : Addreference
650  *  Purpose  : 
651  */
652 //============================================================================
653 void 
654 SALOMEDS_StudyBuilder_i::Addreference(SALOMEDS::SObject_ptr me, 
655                                       SALOMEDS::SObject_ptr theReferencedObject)
656 {
657   CheckLocked();
658   TDF_Label Lab;
659   ASSERT(!CORBA::is_nil(me));
660   CORBA::String_var meid = me->GetID();
661   TDF_Tool::Label(_doc->GetData(),meid,Lab);  
662   TDF_Label RefLab;
663   ASSERT(!CORBA::is_nil(theReferencedObject));
664   CORBA::String_var roid = theReferencedObject->GetID();
665   TDF_Tool::Label(_doc->GetData(),roid,RefLab);
666   TDF_Reference::Set(Lab,RefLab);
667
668   SALOMEDS_TargetAttribute::Set(RefLab)->Append(Lab);
669
670   if(!CORBA::is_nil(_callbackOnRemove) && Lab.IsDescendant(_doc->Main())) _callbackOnRemove->OnRemoveSObject(me);
671 }
672
673 //============================================================================
674 /*! Function : RemoveReference
675  *  Purpose  : 
676  */
677 //============================================================================
678 void SALOMEDS_StudyBuilder_i::RemoveReference(SALOMEDS::SObject_ptr me)
679 {
680   SALOMEDS::SObject_var theReferencedObject;
681   if(!me->ReferencedObject(theReferencedObject)) return;  //No reference is found
682
683   CheckLocked();
684   TDF_Label Lab;
685   ASSERT(!CORBA::is_nil(me));
686   CORBA::String_var meid = me->GetID();
687   TDF_Tool::Label(_doc->GetData(),meid,Lab);  
688
689   Lab.ForgetAttribute(TDF_Reference::GetID());  
690
691   //SRN: 30 Aug, 2004 : fix from Ecole l'ete version 
692
693   TDF_Label RefLab;
694   ASSERT(!CORBA::is_nil(theReferencedObject));
695   CORBA::String_var roid = theReferencedObject->GetID();
696   TDF_Tool::Label(_doc->GetData(),roid,RefLab);
697        
698   Handle(SALOMEDS_TargetAttribute) aTarget;
699   if(RefLab.FindAttribute(SALOMEDS_TargetAttribute::GetID(), aTarget)) aTarget->Remove(Lab);
700 }
701
702
703
704 //============================================================================
705 /*! Function : AddDirectory
706  *  Purpose  : adds a new directory with a path = thePath
707  */
708 //============================================================================
709 void SALOMEDS_StudyBuilder_i::AddDirectory(const char* thePath) 
710 {
711   CheckLocked();
712   if(thePath == NULL || strlen(thePath) == 0) throw SALOMEDS::Study::StudyInvalidDirectory();
713
714   TCollection_AsciiString aPath(CORBA::string_dup(thePath)), aContext(""), aFatherPath;
715   TDF_ChildIterator anIterator(_doc->Main());
716   Handle(TDataStd_Name) aName;
717   TDF_Label aLabel;
718   SALOMEDS_SObject_i* so_servant = new SALOMEDS_SObject_i (_doc->Main(), _orb);
719   SALOMEDS::SObject_var anObject = SALOMEDS::SObject::_narrow(so_servant->_this()); 
720   SALOMEDS::Study_var aStudy = anObject->GetStudy();
721
722   try { 
723     anObject = aStudy->FindObjectByPath(thePath); //Check if the directory already exists
724   }
725   catch(...) { }
726
727   if(!anObject->_is_nil()) throw SALOMEDS::Study::StudyNameAlreadyUsed(); 
728
729   if(aPath.Value(1) != '/') { //Relative path 
730     aPath.Prepend('/');
731     aPath = TCollection_AsciiString(aStudy->GetContext()) + aPath;
732   }
733
734   TCollection_AsciiString aToken = aPath.Token("/", 1);
735   if(aToken.Length() == 0) aFatherPath = "/";
736
737   int i = 1;  
738   while(aToken.Length() != 0) {
739     if(aPath.Token("/", i+1).Length() > 0) {
740       aFatherPath += "/";
741       aFatherPath += aToken;
742     }
743     aToken = aPath.Token("/", ++i);
744   }
745
746   anObject = SALOMEDS::SObject::_nil();
747   try { 
748     anObject = aStudy->FindObjectByPath(aFatherPath.ToCString()); //Check if the father directory exists
749   }
750   catch(...) { ; }
751   if(anObject->_is_nil()) throw SALOMEDS::Study::StudyInvalidDirectory(); 
752
753   SALOMEDS::SObject_var aNewObject = NewObject(anObject);
754   TDF_Tool::Label(_doc->GetData(), aNewObject->GetID(), aLabel);
755   if(aLabel.IsNull()) {
756     MESSAGE("### NULL label");
757     throw SALOMEDS::Study::StudyInvalidComponent();      
758   }
759
760   TDataStd_Name::Set(aLabel, aPath.Token("/", i-1));
761
762   //Set LocalID attribute to identify the directory object
763   SALOMEDS::GenericAttribute_var anAttr = FindOrCreateAttribute(aNewObject, "AttributeLocalID");
764   SALOMEDS::AttributeLocalID_var aPersRef = SALOMEDS::AttributeLocalID::_narrow(anAttr);
765   if(aPersRef->_is_nil()) throw SALOMEDS::Study::StudyInvalidDirectory();
766
767   aPersRef->SetValue(DIRECTORYID);
768 }
769
770
771 //============================================================================
772 /*! Function : SetGUID
773  *  Purpose  : 
774  */
775 //============================================================================
776 void SALOMEDS_StudyBuilder_i::SetGUID(SALOMEDS::SObject_ptr anObject, const char* theGUID)
777 {
778   CheckLocked();
779   TDF_Label aLabel;
780   ASSERT(!CORBA::is_nil(anObject));
781   CORBA::String_var anEntry = anObject->GetID();
782   TDF_Tool::Label(_doc->GetData(), anEntry, aLabel);
783   TDataStd_UAttribute::Set(aLabel, (char*)theGUID);
784 }
785
786 //============================================================================
787 /*! Function : IsGUID
788  *  Purpose  : 
789  */
790 //============================================================================
791 bool SALOMEDS_StudyBuilder_i::IsGUID(SALOMEDS::SObject_ptr anObject, const char* theGUID)
792 {
793   TDF_Label aLabel;
794   ASSERT(!CORBA::is_nil(anObject));
795   CORBA::String_var anEntry = anObject->GetID();
796   TDF_Tool::Label(_doc->GetData(), anEntry, aLabel);
797   return aLabel.IsAttribute((char*)theGUID);
798 }
799
800
801 //============================================================================
802 /*! Function : NewCommand
803  *  Purpose  : 
804  */
805 //============================================================================
806 void SALOMEDS_StudyBuilder_i::NewCommand()
807 {
808   // mpv: for SAL2114 - unset "lock changed" flag at the operation start
809   Handle(SALOMEDS_StudyPropertiesAttribute) anAttr;
810   if (!_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) {
811     anAttr = new SALOMEDS_StudyPropertiesAttribute;
812     _doc->Main().AddAttribute(anAttr);
813   }
814   anAttr->IsLockChanged(true);
815   
816   _doc->NewCommand();
817 }
818
819 //============================================================================
820 /*! Function : CommitCommand
821  *  Purpose  : 
822  */
823 //============================================================================
824 void SALOMEDS_StudyBuilder_i::CommitCommand() throw (SALOMEDS::StudyBuilder::LockProtection)
825 {
826   Unexpect aCatch(SBLockProtection);
827   Handle(SALOMEDS_StudyPropertiesAttribute) anAttr;
828   if (!_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) {
829     anAttr = new SALOMEDS_StudyPropertiesAttribute;
830     _doc->Main().AddAttribute(anAttr);
831   }
832   if (anAttr->IsLocked() && !anAttr->IsLockChanged(true)) {
833     MESSAGE("Locked document modification !!!");
834     AbortCommand();
835     throw SALOMEDS::StudyBuilder::LockProtection();
836   } else {
837     SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->RemovePostponed(_doc->GetUndoLimit());
838
839     int aModif = anAttr->GetModified();
840     if (aModif < 0) aModif = 1000; // if user make undo and then - new transaction "modify" will never be zero
841     anAttr->SetModified(aModif+1);
842     _doc->CommitCommand();
843   }
844 }
845
846 //============================================================================
847 /*! Function : HasOpenCommand
848  *  Purpose  : 
849  */
850 //============================================================================
851 CORBA::Boolean SALOMEDS_StudyBuilder_i::HasOpenCommand()
852 {
853   return _doc->HasOpenCommand();
854 }
855
856 //============================================================================
857 /*! Function : AbortCommand
858  *  Purpose  : 
859  */
860 //============================================================================
861 void SALOMEDS_StudyBuilder_i::AbortCommand()
862 {
863   SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->UndoPostponed(0);
864   
865   _doc->AbortCommand();
866 }
867
868 //============================================================================
869 /*! Function : Undo
870  *  Purpose  : 
871  */
872 //============================================================================
873 void SALOMEDS_StudyBuilder_i::Undo() throw (SALOMEDS::StudyBuilder::LockProtection)
874 {
875   Unexpect aCatch(SBLockProtection);
876   Handle(SALOMEDS_StudyPropertiesAttribute) anAttr;
877   if (!_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) {
878     anAttr = new SALOMEDS_StudyPropertiesAttribute;
879     _doc->Main().AddAttribute(anAttr);
880     }
881   if (anAttr->IsLocked()) {
882     MESSAGE("Locked document modification !!!");
883     throw SALOMEDS::StudyBuilder::LockProtection();
884   } else {
885     SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->UndoPostponed(1);
886     _doc->Undo();
887     anAttr->SetModified(anAttr->GetModified()-1);
888   }
889 }
890
891 //============================================================================
892 /*! Function : Redo
893  *  Purpose  : 
894  */
895 //============================================================================
896 void SALOMEDS_StudyBuilder_i::Redo() throw (SALOMEDS::StudyBuilder::LockProtection)
897 {
898   Unexpect aCatch(SBLockProtection);
899   Handle(SALOMEDS_StudyPropertiesAttribute) anAttr;
900   if (!_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) {
901     anAttr = new SALOMEDS_StudyPropertiesAttribute;
902     _doc->Main().AddAttribute(anAttr);
903   }
904   
905   if (anAttr->IsLocked()) {
906     MESSAGE("Locked document modification !!!");
907     throw SALOMEDS::StudyBuilder::LockProtection();
908   } else {
909     _doc->Redo();
910     SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->UndoPostponed(-1);
911     anAttr->SetModified(anAttr->GetModified()+1);
912   }
913  }
914
915 //============================================================================
916 /*! Function : GetAvailableUndos
917  *  Purpose  : 
918  */
919 //============================================================================
920 CORBA::Boolean SALOMEDS_StudyBuilder_i::GetAvailableUndos()
921 {
922   return _doc->GetAvailableUndos();
923 }
924
925 //============================================================================
926 /*! Function : GetAvailableRedos
927  *  Purpose  : 
928  */
929 //============================================================================
930 CORBA::Boolean  SALOMEDS_StudyBuilder_i::GetAvailableRedos()
931 {
932   return _doc->GetAvailableRedos();
933 }
934
935 //============================================================================
936 /*! Function : UndoLimit
937  *  Purpose  : 
938  */
939 //============================================================================
940 CORBA::Long  SALOMEDS_StudyBuilder_i::UndoLimit()
941 {
942   return _doc->GetUndoLimit();
943 }
944
945 //============================================================================
946 /*! Function : UndoLimit
947  *  Purpose  : 
948  */
949 //============================================================================
950 void  SALOMEDS_StudyBuilder_i::UndoLimit(CORBA::Long n)
951 {
952   CheckLocked();
953   _doc->SetUndoLimit (n);
954 }
955
956 //============================================================================
957 /*! Function : SetOnAddSObject
958  *  Purpose  : 
959  */
960 //============================================================================
961 SALOMEDS::Callback_ptr SALOMEDS_StudyBuilder_i::SetOnAddSObject(SALOMEDS::Callback_ptr theCallback)
962 {
963   SALOMEDS::Callback_ptr aRet = (CORBA::is_nil(_callbackOnAdd))?NULL:_callbackOnAdd._retn();
964   _callbackOnAdd = SALOMEDS::Callback::_duplicate(theCallback);
965   return aRet;
966 }
967
968 //============================================================================
969 /*! Function : SetOnNewSObject
970  *  Purpose  : 
971  */
972 //============================================================================
973 SALOMEDS::Callback_ptr SALOMEDS_StudyBuilder_i::SetOnRemoveSObject(SALOMEDS::Callback_ptr theCallback)
974 {
975   SALOMEDS::Callback_ptr aRet = (CORBA::is_nil(_callbackOnRemove))?NULL:_callbackOnRemove._retn();
976   _callbackOnRemove = SALOMEDS::Callback::_duplicate(theCallback);
977   return aRet;
978 }
979
980 //============================================================================
981 /*! Function : CheckLocked
982  *  Purpose  : 
983  */
984 //============================================================================
985 void SALOMEDS_StudyBuilder_i::CheckLocked() throw (SALOMEDS::StudyBuilder::LockProtection) {
986   Unexpect aCatch(SBLockProtection);
987   if (_doc->HasOpenCommand()) return;
988   Handle(SALOMEDS_StudyPropertiesAttribute) anAttr;
989   if (!_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) {
990     anAttr = new SALOMEDS_StudyPropertiesAttribute;
991     _doc->Main().AddAttribute(anAttr);
992     }
993   if (anAttr->IsLocked()) throw SALOMEDS::StudyBuilder::LockProtection();
994 }
995
996 //============================================================================
997 /*! Function : SetName
998  *  Purpose  : 
999  */
1000 //============================================================================
1001 void SALOMEDS_StudyBuilder_i::SetName(SALOMEDS::SObject_ptr theSO, const char* theValue)
1002      throw(SALOMEDS::StudyBuilder::LockProtection)
1003 {
1004   Unexpect aCatch(SBLockProtection);
1005   CheckLocked();
1006   //Find label
1007   TDF_Label aLabel;
1008   ASSERT(!CORBA::is_nil(theSO));
1009   CORBA::String_var aSOID = theSO->GetID();
1010   TDF_Tool::Label(_doc->GetData(), aSOID, aLabel);
1011   TDataStd_Name::Set(aLabel, (char*)theValue);
1012 }
1013
1014 //============================================================================
1015 /*! Function : SetComment
1016  *  Purpose  : 
1017  */
1018 //============================================================================
1019 void SALOMEDS_StudyBuilder_i::SetComment(SALOMEDS::SObject_ptr theSO, const char* theValue)
1020  throw(SALOMEDS::StudyBuilder::LockProtection)
1021 {
1022   Unexpect aCatch(SBLockProtection);
1023   CheckLocked();
1024    //Find label
1025   TDF_Label aLabel;
1026   ASSERT(!CORBA::is_nil(theSO));
1027   CORBA::String_var aSOID = theSO->GetID();
1028   TDF_Tool::Label(_doc->GetData(), aSOID, aLabel);
1029   TDataStd_Comment::Set(aLabel, (char*)theValue);
1030 }
1031
1032 //============================================================================
1033 /*! Function : SetIOR
1034  *  Purpose  : 
1035  */
1036 //============================================================================
1037 void SALOMEDS_StudyBuilder_i::SetIOR(SALOMEDS::SObject_ptr theSO, const char* theValue)
1038  throw(SALOMEDS::StudyBuilder::LockProtection)
1039 {
1040   Unexpect aCatch(SBLockProtection);
1041   CheckLocked();
1042   //Find label
1043   TDF_Label aLabel;
1044   ASSERT(!CORBA::is_nil(theSO));
1045   CORBA::String_var aSOID = theSO->GetID();
1046   TDF_Tool::Label(_doc->GetData(), aSOID, aLabel);
1047   SALOMEDS_IORAttribute::Set(aLabel, TCollection_ExtendedString((char*)theValue), _orb);
1048 }