CDocument* CReportManager::OpenForm(CString csName,BOOL bVisible) { if(!AfxGetMainWnd()) return 0; POSITION pos=GetFirstDocTemplatePosition(); CString csFind=mUpper(csName); CDocTemplate* pTemplate=NULL; BOOL bFind=FALSE; for(int i=0;i<aDescription.GetSize();i++) { pTemplate=GetNextDocTemplate(pos); CString csCurName=aDescription[i].csName; if(csFind==mUpper(csCurName)) { bFind=TRUE; break; } } if(bFind) { if(pTemplate) { CDocument* pDoc=pTemplate->OpenDocumentFile(NULL,bVisible); ((CEnterpriseApp*)AfxGetApp())->DeleteConfigName(); return pDoc; } } return NULL; }
//получение метаобъекта (если такой метаобъект еще не загружен из файла, то он загружается) CMetaObject *CMetadata::GetMetaObject2(CString csFileName,CString csObjName,int bReadOnly) { if(!OpenZip(OPEN_LOAD)) return 0; if(afxAppRunMode==ENTERPRISE_MODE || bIsLibrary) bReadOnly=1; CMetaObject *pObject=(CMetaObject *)ListObjects[mUpper(csFileName)]; if(pObject) { if(!csObjName.IsEmpty()&&pObject->csOldName!=pObject->csName) { //было изменено имя - переписываем указатель ListObjects[mUpper(pObject->csName)]=pObject; pObject=0; } else { if(pObject->IsDeleted) {//объект был удален - значит больше его не грузим pObject=new CMetaObject(); ListObjects[mUpper(csFileName)]=pObject; } if(!bReadOnly)//если объекта берется для изменения, то разрешаем его последующую запись pObject->bCanSave=1; return pObject; } } if(bReadOnly)//проверяем физическое наличие в файле метаданных { int n1=m_zip.FindFile(csFileName); if(n1<0) n1=m_zip.FindFile(csFileName+".inf"); if(n1<0) n1=m_zip.FindFile(csFileName+".2c"); if(n1<0) { return 0; } } pObject=new CMetaObject(); if(bReadOnly)//объект еще не загружался + режим взятия только для чтения - помечаем его как незаписываемый (для уменьшения трафика) pObject->bCanSave=0; ListObjects[mUpper(csFileName)]=pObject; pObject->Load(m_zip,csFileName,csObjName); // OpenZip(CLOSE_FILE); //временное закрытие return pObject; }
void AddUniqueList(CMapStringToPtr &HashList, CArray <CString,CString&> &ListDest, CArray <CString,CString&> &ListSource) { for(int i=0;i<ListSource.GetSize();i++) { CString csName=ListSource[i]; if(!HashList[mUpper(csName)]) { HashList[mUpper(csName)]=(void*)1; ListDest.Add(csName); } } }
void CMetadata::AddLibrary(CString csFileName) { CMetadata *pLib=new CMetadata(); pLib->bIsLibrary=1; pLib->vMeta=vMeta; if(pLib->Load(csFileName)) { vMeta=pLib->vMeta; AddUniqueList(ListModuleAdd, ListModuleName,pLib->ListModuleName); AddUniqueList(ListFormAdd, ListFormName,pLib->ListFormName); AddUniqueList(ListMaketAdd, ListMaketName,pLib->ListMaketName); AddUniqueList(ListObjectAdd, ListObjectName,pLib->ListObjectName); //описание объектов POSITION pos; CString csKey; ObjectDescription *p2; for( pos = pLib->OList.GetStartPosition(); pos != NULL; ) { pLib->OList.GetNextAssoc( pos, csKey, (void*&)p2 ); if(p2) { OList[mUpper(csKey)]=p2; } } aLibList.Add(pLib); } else { delete pLib; } }
//Авторские права - VTOOLS.RU ([email protected]) // ReportManager.cpp: implementation of the CReportManager class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "ReportManager.h" #include "Compiler\ChooseValue.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CReportManager::CReportManager() { csTitle="Выбор"; bSmall=FALSE; } CReportManager::~CReportManager() { } void CReportManager::OnFileNew() { CChooseValue dlg; CArray <CDocTemplate*,CDocTemplate*> listTemlate; POSITION pos=GetFirstDocTemplatePosition(); for(int i=0;i<aDescription.GetSize();i++) { CDocTemplate* pTemplate=GetNextDocTemplate(pos); if(aDescription[i].bCanVisible) { dlg.List.Add(aDescription[i].csDescription); dlg.ListImage.Add(aDescription[i].nImage); listTemlate.Add(pTemplate); } } dlg.nStart=0; dlg.csTitle=csTitle; dlg.nMode=0; if(bSmall) dlg.Small(); int nResponse = IDOK; int nIndex=0; if(dlg.List.GetSize()>1) { nResponse = dlg.DoModal(); nIndex=dlg.nRes; } if (nResponse == IDOK) { if(listTemlate.GetSize()>0) if(listTemlate[nIndex]) listTemlate[nIndex]->OpenDocumentFile(NULL); } } void CReportManager::AddDocTemplate(CMultiDocTemplate *p,CString csName,CString csDescription,bool bCanView,int nImage) { CDocManager::AddDocTemplate(p); csName.TrimLeft(); csName.TrimRight(); CReportElement data; data.csName=csName; data.csDescription=csDescription; data.bCanVisible=bCanView; data.nImage=nImage; aDescription.Add(data); } CDocument* CReportManager::OpenForm(CString csName,BOOL bVisible) { if(!AfxGetMainWnd()) return 0; POSITION pos=GetFirstDocTemplatePosition(); CString csFind=mUpper(csName); CDocTemplate* pTemplate=NULL; BOOL bFind=FALSE; for(int i=0;i<aDescription.GetSize();i++) { pTemplate=GetNextDocTemplate(pos); CString csCurName=aDescription[i].csName; if(csFind==mUpper(csCurName)) { bFind=TRUE; break; } } if(bFind) { if(pTemplate) { CDocument* pDoc=pTemplate->OpenDocumentFile(NULL,bVisible); ((CEnterpriseApp*)AfxGetApp())->DeleteConfigName(); return pDoc; } } return NULL; } void AFXAPI _AfxAppendFilterSuffix(CString& filter, OPENFILENAME& ofn, CDocTemplate* pTemplate, CString* pstrDefaultExt) { ASSERT_VALID(pTemplate); ASSERT_KINDOF(CDocTemplate, pTemplate); CString strFilterExt, strFilterName; if (pTemplate->GetDocString(strFilterExt, CDocTemplate::filterExt) && !strFilterExt.IsEmpty() && pTemplate->GetDocString(strFilterName, CDocTemplate::filterName) && !strFilterName.IsEmpty()) { // a file based document template - add to filter list ASSERT(strFilterExt[0] == '.'); if (pstrDefaultExt != NULL) { // set the default extension *pstrDefaultExt = ((LPCTSTR)strFilterExt) + 1; // skip the '.' ofn.lpstrDefExt = (LPTSTR)(LPCTSTR)(*pstrDefaultExt); ofn.nFilterIndex = ofn.nMaxCustFilter + 1; // 1 based number } // add to filter filter += strFilterName; ASSERT(!filter.IsEmpty()); // must have a file type name filter += (TCHAR)'\0'; // next string please filter += (TCHAR)'*'; filter += strFilterExt; filter += (TCHAR)'\0'; // next string please ofn.nMaxCustFilter++; } } //*/ BOOL CReportManager::DoPromptFileName(CString& fileName, UINT nIDSTitle, DWORD lFlags, BOOL bOpenFileDialog, CDocTemplate* pTemplate) { CFileDialog dlgFile(bOpenFileDialog); CString title; VERIFY(title.LoadString(nIDSTitle)); dlgFile.m_ofn.Flags |= lFlags; CString strFilter; CString strDefault; if (pTemplate != NULL) { ASSERT_VALID(pTemplate); _AfxAppendFilterSuffix(strFilter, dlgFile.m_ofn, pTemplate, &strDefault); } else { // do for all doc template POSITION pos = m_templateList.GetHeadPosition(); BOOL bFirst = TRUE; while (pos != NULL) { CDocTemplate* pTemplate = (CDocTemplate*)m_templateList.GetNext(pos); _AfxAppendFilterSuffix(strFilter, dlgFile.m_ofn, pTemplate, bFirst ? &strDefault : NULL); bFirst = FALSE; } } CString allFilter; // append the "*.html" files filter if(mUpper(strDefault)=="2C") { allFilter="Файлы HTML (*.htm)"; strFilter += allFilter; strFilter += (TCHAR)'\0'; // next string please strFilter += _T("*.htm"); strFilter += (TCHAR)'\0'; // last string dlgFile.m_ofn.nMaxCustFilter++; } // append the "*.*" all files filter VERIFY(allFilter.LoadString(AFX_IDS_ALLFILTER)); strFilter += allFilter; strFilter += (TCHAR)'\0'; // next string please strFilter += _T("*.*"); strFilter += (TCHAR)'\0'; // last string dlgFile.m_ofn.nMaxCustFilter++; dlgFile.m_ofn.lpstrFilter = strFilter; dlgFile.m_ofn.lpstrTitle = title; dlgFile.m_ofn.lpstrFile = fileName.GetBuffer(_MAX_PATH); int nResult = dlgFile.DoModal(); fileName.ReleaseBuffer(); return nResult == IDOK; }
bool StateVectorLimiter<StateType>::testState(const StateVector<StateType> &_stateVec) const { bool result = true; if((_stateVec.size() != mUpper.size()) |(_stateVec.size() != mLower.size())) { std::cout << "incompatible dimensions. can't evaluate state limits\n"; return false; } for(unsigned i=0; i < _stateVec.size(); i++) { bool valid = ((mLower(i) <= _stateVec[i]) & (mUpper(i) >= _stateVec[i])); result &= valid; std::string msg = valid ? "ok" : "error"; std::cout << i << ". value=" << _stateVec[i] << "[" << mLower(i) << " ; " << mUpper(i) << msg << "\n"; } return result; }
BOOL ObjectDescription::Add(CArray <CString,CString&> &aListName,CMapStringToPtr &aListFind, CString csName0) { CString csNAME=mUpper(csName0); if(!csNAME.IsEmpty()) if(!aListFind[csNAME]) { aListName.Add(csName0); aListFind[csNAME]=(void*)1; return TRUE; } return FALSE; }
void CMetadata::Clear() { ListModuleName.RemoveAll(); ListFormName.RemoveAll(); ListMaketName.RemoveAll(); ListObjectName.RemoveAll(); ListModuleAdd.RemoveAll(); ListFormAdd.RemoveAll(); ListMaketAdd.RemoveAll(); ListObjectAdd.RemoveAll(); ListModuleAdd[INITMODULENAME]=(void*)1; ListModuleAdd[mUpper(INITMODULENAME)]=(void*)1; // ListMetadataName.RemoveAll(); CMetaObject *p; POSITION pos; CString csKey; if(!bIsLibrary) for( pos = ListObjects.GetStartPosition(); pos != NULL; ) { ListObjects.GetNextAssoc( pos, csKey, (void*&)p ); if(p) delete p; } ListObjects.RemoveAll(); ObjectDescription *p2; if(!bIsLibrary) for( pos = OList.GetStartPosition(); pos != NULL; ) { OList.GetNextAssoc( pos, csKey, (void*&)p2 ); if(p2) delete p2; } OList.RemoveAll(); //ListDelObjects.RemoveAll(); vMeta.Reset(); for(int i=0;i<aLibList.GetSize();i++) delete aLibList[i]; aLibList.RemoveAll(); }
void CMetadata::AddToMeta(CString Str) { CValue *pCurPos=&vMeta; int nPoint=Str.ReverseFind('.'); CString csType; if(nPoint>0) { csType=mUpper(Str.Mid(nPoint)); Str=Str.Left(nPoint); } CString csName; int nIndex1=0; int nIndex2=Str.Find("\\",nIndex1); while(nIndex2>0) { csName=Str.Mid(nIndex1,nIndex2-nIndex1); if(pCurPos->GetType()!=TYPE_ARRAY) pCurPos->CreateObject("Структура"); pCurPos=&pCurPos->GetAt(csName); nIndex1=nIndex2+1; nIndex2=Str.Find("\\",nIndex1); } csName=Str.Mid(nIndex1); if(pCurPos->GetType()!=TYPE_ARRAY) pCurPos->CreateObject("Структура"); if(csType!=".ATR")//&&csType!=".INF") { if(pCurPos->GetAt(csName).GetType()!=TYPE_ARRAY) pCurPos->SetAt(csName,CValue()); } else if(csType==".ATR") { CMetaObject *pObj=GetMetaObject(Str,csName,1); if(pObj) { CValue Val; Val.LoadFromString(pObj->csAttr); Val.SetAt(String("#"),1);//признак атрибута pCurPos->SetAt(csName,Val); Val.SetAt("Идентификатор",String(csName)); Val.SetAt("Синоним",String(pObj->csAlias)); Val.SetAt("Комментарий",String(pObj->csComment)); } } }
int CValueContext::FindMethod(CString csName) { if(!pRun) return -1; CString csMethName=mUpper(csName); if(csMethName=="ПЕРЕМ"||csMethName=="VAR")//доступ к массиву переменных return EXT_ATTRIBUTE_CALL; int n=pRun->FindFunction(csMethName); return n; }
///////////////////////////////////////////////////////////////////////////// //загрузка системной библиотеки объектов void CMetadata::LoadSystemLibrary() { CString StartPath=csCurrentExeDir; StartPath.TrimRight('\\'); StartPath+="\\SYSTEM\\"; SetCurrentDirectory(csIBDir); WIN32_FIND_DATA fdata; HANDLE hfind=FindFirstFile(StartPath+"*.md2",&fdata); if(NULL==hfind || INVALID_HANDLE_VALUE==hfind) return; CArray <CString,CString&> aLibName; do { CString csName=StartPath + fdata.cFileName; if(mUpper(csName)!=mUpper(m_csConfigPath)) aLibName.Add(csName); } while(FindNextFile(hfind,&fdata)); FindClose(hfind); // m_zip.Open(m_csConfigPath, CZipArchive::create,0);//Новый архив // m_zip.Close(); //сортировка SortList(aLibName); for(int i=0;i<aLibName.GetSize();i++) { CString csName=mUpper(aLibName[i]); if(csName.Right(4)==".MD2") //AfxMessageBox(aLibName[i]); AddLibrary(aLibName[i]); } }
int CValueContext::FindAttribute(CString csName) { if(pRun) { int iName=(int)pRun->pByteCode->VarList[mUpper(csName)]-1; //Message(CValue(csName+" "+CValue(iName))); if(iName==-1) { int iSize=aContVarList.GetSizeArray(); for (int iIndex=1;iIndex<=iSize;iIndex++) if(mUpper(aContVarList.GetAt(iIndex).GetString())==csName) { return (int)LOCAL_ATTRIBUTE+iIndex; } aContVarList.SetAt(iSize+1,CValue(csName)); aContValueList.SetAt(iSize+1,CValue()); return (int)LOCAL_ATTRIBUTE+iSize+1; } return iName; } else return -1; }
CString GetFullMetaPath(CString csPathObject,CString Str) { Str.Replace("/","\\"); if(mUpper(Str.Left(3))=="MD:") { if(Str.Mid(3,1)=="\\") return Str.Mid(4); else return Str.Mid(3); } else { return METADATANAME+"\\"+csPathObject+Str; } }
//Заполнение списка метаданных BOOL CMetadata::Load(CString csFileName) { m_csConfigPath=csFileName; Clear(); if(!bIsLibrary) LoadSystemLibrary(); if(!OpenZip(OPEN_LOAD)) return 0; int nEntries=m_zip.GetNoEntries(); for (WORD i = 0; i < nEntries; i++) { CZipFileHeader fhInfo; m_zip.GetFileInfo(fhInfo, i); CString Str=fhInfo.GetFileName()+"\\"; if(!m_zip.IsFileDirectory(i)) AddToMeta(fhInfo.GetFileName()); int nPoint=Str.ReverseFind('.'); CString csExt; if(nPoint>0) { csExt=mUpper(Str.Mid(nPoint)); csExt.TrimRight('\\'); } if(csExt==".INF") Str=Str.Left(nPoint)+"\\"; int nIndex1=Str.Find("\\"); if(nIndex1>0) { int nIndex2=Str.Find("\\",nIndex1+1); if(nIndex2>0) { CString Str2=Str.Left(nIndex2); int n=Str2.ReverseFind('\\'); CString csName=Str2.Mid(n+1); CString csType=mUpper(Str2.Left(n)); if(csType==mUpper(OBJECTSNAME)) { csName.TrimRight(); if(csName.IsEmpty()) continue; if(!ListObjectAdd[mUpper(csName)]) { ListObjectAdd[mUpper(csName)]=(void*)1; ListObjectName.Add(csName); } //Объекты\Документ\Модули\Модуль среды исполнения.2c int nIndex3=Str.Find("\\",nIndex2+1); int nIndex4=Str.ReverseFind('.'); int nPoint=nIndex4; if(nIndex4<=0) nIndex4=Str.Find("\\",nIndex3+1); if(nIndex3>0&&nIndex4>0) { CString csGroup=mUpper(Str.Mid(nIndex2+1,nIndex3-nIndex2-1)); CString csModule=Str.Mid(nIndex3+1,nIndex4-nIndex3-1); csModule.TrimRight(); if(csModule.IsEmpty()) continue; ObjectDescription *pObject; pObject=(ObjectDescription *)OList[mUpper(csName)]; if(!pObject) pObject=new ObjectDescription(); pObject->bReadOnly=bIsLibrary; OList[mUpper(csName)]=pObject; if(csGroup==mUpper(OBJFORM)) { if(csExt==".FRM") pObject->Add(pObject->aForms,pObject->ListFormAdd,csModule); //pObject->aForms.Add(csModule); } else if(csGroup==mUpper(OBJMODULE)) { //if(csExt==".2C"&&mUpper(csModule)!=mUpper(CONFIGMODULENAME)&&mUpper(csModule)!=mUpper(ENTERPRISEMODULENAME)) if(csExt!=".INF") if(mUpper(csModule)!=mUpper(CONFIGMODULENAME)&&mUpper(csModule)!=mUpper(ENTERPRISEMODULENAME)) pObject->Add(pObject->aModule,pObject->ListModuleAdd,csModule); //pObject->aModule.Add(csModule); } else if(csGroup==mUpper(OBJMAKET)) { pObject->Add(pObject->aMakets,pObject->ListMaketAdd,csModule); //pObject->aMakets.Add(csModule); } else if(csGroup==mUpper(OBJCONST)) { if(pObject->Add(pObject->aConst,pObject->ListConstAdd,csModule)) if(!aHashKeywordList[mUpper(csModule)]) { aGlVariables.Add(csModule); aHashKeywordList[mUpper(csModule)]=(void*)1; } /* if(!mUpper(csModule).IsEmpty()) if(!aHashKeywordList[mUpper(csModule)]) { aGlVariables.Add(csModule); aHashKeywordList[mUpper(csModule)]=(void*)1; } pObject->aConst.Add(csModule);*/ } } } /* else if(csType==mUpper(METADATANAME)) { if(csExt==".ATR") { ObjectDescription *pObject; pObject=(ObjectDescription *)OList[mUpper(csName)]; if(!pObject) pObject=new ObjectDescription(); OList[mUpper(csName)]=pObject; pObject->aAttrList.Add(csModule); } } */ else if(csType==mUpper(MODULESNAME)) { CString csFileType=mUpper(Str2.Right(3)); if(csFileType!=".INF") { if(csFileType==".2C") csName=csName.Left(csName.GetLength()-3); csName.TrimRight(); if(csName.IsEmpty()) continue; if(!ListModuleAdd[mUpper(csName)]) { ListModuleAdd[mUpper(csName)]=(void*)1; ListModuleName.Add(csName); } } } else if(csType==mUpper(FORMSNAME)) { CString csFileType=mUpper(Str2.Right(4)); if(csFileType==".FRM") { csName=csName.Left(csName.GetLength()-4); csName.TrimRight(); if(csName.IsEmpty()) continue; if(!ListFormAdd[mUpper(csName)]) { ListFormAdd[mUpper(csName)]=(void*)1; ListFormName.Add(csName); } } } else if(csType==mUpper(MAKETSNAME)) { csName.TrimRight(); if(csName.IsEmpty()) continue; if(!ListMaketAdd[mUpper(csName)]) { ListMaketAdd[mUpper(csName)]=(void*)1; ListMaketName.Add(csName); } } } } } SortList(ListFormName); SortList(ListMaketName); SortList(ListModuleName); SortList(ListObjectName); // SortList(ListMetadataName); OpenZip(CLOSE_FILE); //временное закрытие return TRUE; }