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