694 lines
16 KiB
C++
694 lines
16 KiB
C++
#include "StdAfx.h"
|
|
#include "OpeningLabelData.h"
|
|
|
|
|
|
#define OPENING_LABEL_INI _T("OpeningLabel.ini")
|
|
|
|
enum {eSort = 0, eRule, eHyphen, eSize, eNum, eHasHyphen, eNoHyphen, eSplit0, eRound, eIsRound, eNoRound, eCalWidth, eInboard, eMiddle, eOutboard, eKeyAll};
|
|
|
|
// 关键字
|
|
static CString s_sKey[eKeyAll] =
|
|
{
|
|
_T("Sort"),
|
|
_T("Rule"),
|
|
_T("Hyphen"),
|
|
_T("Size"),
|
|
_T("number"),
|
|
_T("1"),
|
|
_T("0"),
|
|
_T("="),
|
|
_T("Round"),
|
|
_T("1"),
|
|
_T("0"),
|
|
_T("CalWidth"),
|
|
_T("Inboard"),
|
|
_T("Middle"),
|
|
_T("Outboard")
|
|
};
|
|
|
|
// 门窗数据
|
|
// 标签, 大类型, 默认“用途”, 默认“编号”;
|
|
// 针对配置文件可能会被删除,或者错误的修改,此处保留默认数据,当配置文件不可用时,从此处获得数据,一保证程序的运行、
|
|
static CString s_sDoorDatas[] =
|
|
{
|
|
_T("Door"), _T("门"), _T("普通门"), _T("FM"),
|
|
_T("DoorWin"), _T("门连窗"), _T("门连窗"), _T("MLC"),
|
|
_T("TwoDoor"), _T("子母门"), _T("子母门"), _T("ZM"),
|
|
_T("GroupOpening"), _T("组合门窗"), _T("组合门窗"), _T("ZM"),
|
|
_T("Window"), _T("窗"), _T("普通窗"), _T("C"),
|
|
_T("ArcWin"), _T("弧窗"), _T("弧窗"), _T("HC"),
|
|
_T("BayWin"), _T("凸窗"), _T("凸窗"), _T("TC"),
|
|
_T("CornerWin"), _T("转角窗"), _T("转角窗"), _T("ZJC"),
|
|
_T("BandWin"), _T("带形窗"), _T("带形窗"), _T("DC"),
|
|
_T("Dormer"), _T("老虎窗"), _T("老虎窗"), _T("LHC"),
|
|
_T("Hole"), _T("洞口"), _T("洞口"), _T("DK")
|
|
};
|
|
|
|
// 门窗类型列表框的索引类型
|
|
static bool s_bDoorGirdStyle[] =
|
|
{
|
|
1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0
|
|
};
|
|
|
|
enum {
|
|
eDoor = 0,
|
|
eDoorWin,
|
|
eTwoDoor,
|
|
eGroupOpening,
|
|
eWindow,
|
|
eArcWin,
|
|
eBayWin,
|
|
eCornerWin,
|
|
eBandWin,
|
|
eDormer,
|
|
eHole,
|
|
eDoorTypeNum,
|
|
};
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
BOOL TLabelSetDataTable::Split(const CString &sOri, CString &sLeft, CString &sRight)
|
|
{
|
|
sLeft = _T("");
|
|
sRight = _T("");
|
|
|
|
int nFind = sOri.Find(s_sKey[eSplit0]);
|
|
|
|
if (nFind == -1)
|
|
{
|
|
sLeft = sOri;
|
|
}
|
|
else
|
|
{
|
|
if (nFind > 0)
|
|
{
|
|
sLeft = sOri.Mid(0, nFind);
|
|
sLeft.TrimLeft();
|
|
sLeft.TrimRight();
|
|
}
|
|
|
|
if (nFind < sOri.GetLength() - 1)
|
|
{
|
|
sRight = sOri.Mid(nFind+1, sOri.GetLength());
|
|
sRight.TrimLeft();
|
|
sRight.TrimRight();
|
|
}
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void TLabelSetDataTable::AddLabel(SOpeningLabelGroup *pLabel)
|
|
{
|
|
if (pLabel == NULL)
|
|
{
|
|
return;
|
|
}
|
|
|
|
m_arLabelData.Add(pLabel);
|
|
}
|
|
|
|
BOOL TLabelSetDataTable::SetSerialRule(const CString &sRule)
|
|
{
|
|
if (s_sKey[eSize].CompareNoCase(sRule) == 0)
|
|
{
|
|
m_eSerialRule = eAccordSize;
|
|
}
|
|
else if (s_sKey[eNum].CompareNoCase(sRule) == 0)
|
|
{
|
|
m_eSerialRule = eAccordNum;
|
|
}
|
|
else
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL TLabelSetDataTable::SetCalWidthRule(const CString &sRule)
|
|
{
|
|
if (s_sKey[eInboard].CompareNoCase(sRule) == 0)
|
|
{
|
|
m_eCalWidthRule = eWallInboard;
|
|
}
|
|
else if (s_sKey[eMiddle].CompareNoCase(sRule) == 0)
|
|
{
|
|
m_eCalWidthRule = eWallMiddle;
|
|
}
|
|
else if (s_sKey[eOutboard].CompareNoCase(sRule) == 0)
|
|
{
|
|
m_eCalWidthRule = eWallOutboard;
|
|
}
|
|
else
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL TLabelSetDataTable::SetHyphenRule(const CString &sHyphen)
|
|
{
|
|
if (s_sKey[eHasHyphen].CompareNoCase(sHyphen) == 0)
|
|
{
|
|
m_bHyphen = TRUE;
|
|
}
|
|
else if (s_sKey[eNoHyphen].CompareNoCase(sHyphen) == 0)
|
|
{
|
|
m_bHyphen = FALSE;
|
|
}
|
|
else
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL TLabelSetDataTable::SetRoundRule(const CString &sRound)
|
|
{
|
|
if (s_sKey[eIsRound].CompareNoCase(sRound) == 0)
|
|
{
|
|
m_bTgRound = TRUE;
|
|
}
|
|
else if (s_sKey[eNoRound].CompareNoCase(sRound) == 0)
|
|
{
|
|
m_bTgRound = FALSE;
|
|
}
|
|
else
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void TLabelSetDataTable::Clear()
|
|
{
|
|
for (int i = 0; i < (int)m_arLabelData.GetSize(); i++)
|
|
{
|
|
delete (m_arLabelData[i]);
|
|
m_arLabelData[i] = NULL;
|
|
}
|
|
|
|
m_arLabelData.RemoveAll();
|
|
m_bReaded = FALSE;
|
|
}
|
|
|
|
// label=>SOpeningLabelGroup
|
|
SOpeningLabelGroup* TLabelSetDataTable::GetLabelContent(const CString &sLabel) const
|
|
{
|
|
for (int i = 0; i < (int)m_arLabelData.GetSize(); i++)
|
|
{
|
|
if ((m_arLabelData[i])->sLabel.CompareNoCase(sLabel) == 0)
|
|
{
|
|
return m_arLabelData[i];
|
|
}
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
void TLabelSetDataTable::CopyFrom(const TLabelSetDataTable& dataTable)
|
|
{
|
|
m_bReaded = TRUE;
|
|
|
|
m_arLabelData.RemoveAll();
|
|
for (int i = 0; i < (int)dataTable.m_arLabelData.GetSize(); i++)
|
|
{
|
|
SOpeningLabelGroup *pGroup = dataTable.m_arLabelData[i];
|
|
SOpeningLabelGroup *pThisGroup = new SOpeningLabelGroup;
|
|
pThisGroup->sLabel = pGroup->sLabel;
|
|
pThisGroup->arLabelPair.RemoveAll();
|
|
pThisGroup->arLabelPair.Append(pGroup->arLabelPair);
|
|
m_arLabelData.Add(pThisGroup);
|
|
}
|
|
|
|
m_eSerialRule = dataTable.m_eSerialRule;
|
|
m_bHyphen = dataTable.m_bHyphen;
|
|
m_bTgRound = dataTable.m_bTgRound;
|
|
m_eCalWidthRule = dataTable.m_eCalWidthRule;
|
|
}
|
|
|
|
// 覆盖label中对应的数据
|
|
void TLabelSetDataTable::CoverLabelData(const CString &sLabel, const ArLabelPair &arLabelPair)
|
|
{
|
|
SOpeningLabelGroup *pGroup = GetLabelContent(sLabel);
|
|
if (pGroup != NULL)
|
|
{
|
|
pGroup->arLabelPair.RemoveAll();
|
|
pGroup->arLabelPair.Append(arLabelPair);
|
|
}
|
|
}
|
|
|
|
void TLabelSetDataTable::GetLabelData(const CString &sLabel, ArLabelPair &arLabelPair) const
|
|
{
|
|
ASSERT(arLabelPair.GetSize() == 0);
|
|
|
|
SOpeningLabelGroup *pGroup = GetLabelContent(sLabel);
|
|
if (pGroup != NULL)
|
|
{
|
|
arLabelPair.RemoveAll();
|
|
arLabelPair.Append(pGroup->arLabelPair);
|
|
}
|
|
}
|
|
|
|
int TLabelSetDataTable::Read(const CString &sFileName)
|
|
{
|
|
int iRet = 0; // 0正常,1表示文件不存在,2表示文件格式出错。
|
|
this->Clear();
|
|
const int VALUE_STRING_LEN = 100;
|
|
m_bReaded = TRUE;
|
|
|
|
// 读取类型,
|
|
for (int i = 0; i < eDoorTypeNum; i++)
|
|
{
|
|
CString csSection = s_sDoorDatas[i*4]; // sectionName;
|
|
|
|
const int SECTION_MAX_LEN = 0x07FF;
|
|
TCHAR sSectionString[SECTION_MAX_LEN];
|
|
TCHAR sOneSection[SECTION_MAX_LEN];// 一个section ** = **;;
|
|
memset(sOneSection, 0, sizeof(TCHAR)*SECTION_MAX_LEN); // 初始化
|
|
|
|
DWORD dw = GetPrivateProfileSection(csSection, sSectionString, SECTION_MAX_LEN, sFileName);
|
|
CStringArray arKeys;
|
|
|
|
int index = 0;
|
|
int nStart = 0, nEnd = 0;
|
|
for (index = 0; index < (int)dw; index++)
|
|
{
|
|
sOneSection[index - nStart] = sSectionString[index];
|
|
if (sSectionString[index] == 0)
|
|
{
|
|
if (index > nStart)
|
|
{
|
|
CString sKey, sValue;
|
|
TLabelSetDataTable::Split(CString(sOneSection), sKey, sValue);
|
|
if (!sKey.IsEmpty())
|
|
arKeys.Add(sKey);
|
|
|
|
memset(sOneSection, 0, sizeof(TCHAR)*SECTION_MAX_LEN);
|
|
|
|
nStart = index + 1;
|
|
}
|
|
}
|
|
}
|
|
|
|
CStringArray arValues;
|
|
for (index = 0; index < (int)arKeys.GetSize(); index++)
|
|
{
|
|
CString sValue;
|
|
GetPrivateProfileString(csSection, arKeys[index], _T(""), sValue.GetBuffer(VALUE_STRING_LEN), VALUE_STRING_LEN, sFileName);
|
|
arValues.Add(sValue);
|
|
sValue.ReleaseBuffer(VALUE_STRING_LEN);
|
|
}
|
|
|
|
|
|
if (arKeys.GetSize() == 0)
|
|
{ // 空的,设置默认值
|
|
arKeys.Add(s_sDoorDatas[i*4+2]);
|
|
arValues.Add(s_sDoorDatas[i*4+3]); // 设置默认值
|
|
|
|
iRet = 2;
|
|
}
|
|
|
|
ASSERT(GetLabelContent(csSection) == NULL);
|
|
SOpeningLabelGroup *pGroup = new SOpeningLabelGroup;
|
|
pGroup->sLabel = csSection;
|
|
AddLabel(pGroup);
|
|
|
|
for (index = 0; index < (int)arKeys.GetSize(); index++)
|
|
{
|
|
SOpeningLabelPair ss((arKeys[index]), (arValues[index]));
|
|
pGroup->arLabelPair.Add(ss);
|
|
}
|
|
}
|
|
|
|
// 读取sort:
|
|
LPCTSTR szSection = s_sKey[eSort];
|
|
CString sValue;
|
|
|
|
GetPrivateProfileString(szSection, s_sKey[eRound], s_sKey[eIsRound],
|
|
sValue.GetBuffer(VALUE_STRING_LEN), VALUE_STRING_LEN, sFileName);
|
|
SetRoundRule(sValue);
|
|
sValue.ReleaseBuffer(VALUE_STRING_LEN);
|
|
|
|
GetPrivateProfileString(szSection, s_sKey[eHyphen], s_sKey[eNoHyphen],
|
|
sValue.GetBuffer(VALUE_STRING_LEN), VALUE_STRING_LEN, sFileName);
|
|
SetHyphenRule(sValue);
|
|
sValue.ReleaseBuffer(VALUE_STRING_LEN);
|
|
|
|
GetPrivateProfileString(szSection, s_sKey[eRule], s_sKey[eSize],
|
|
sValue.GetBuffer(VALUE_STRING_LEN), VALUE_STRING_LEN, sFileName);
|
|
SetSerialRule(sValue);
|
|
sValue.ReleaseBuffer(VALUE_STRING_LEN);
|
|
|
|
GetPrivateProfileString(szSection, s_sKey[eCalWidth], s_sKey[eMiddle],
|
|
sValue.GetBuffer(VALUE_STRING_LEN), VALUE_STRING_LEN, sFileName);
|
|
SetCalWidthRule(sValue);
|
|
sValue.ReleaseBuffer(VALUE_STRING_LEN);
|
|
return iRet;
|
|
}
|
|
|
|
void TLabelSetDataTable::Write(const CString &sFileName) const
|
|
{
|
|
// 清空原文档
|
|
CStdioFile txtFile;
|
|
if (txtFile.Open(sFileName, CFile::modeCreate | CFile::modeWrite))
|
|
{
|
|
txtFile.Close();
|
|
}
|
|
|
|
CString szValue = GetSerialRule() == TLabelSetDataTable::eAccordNum ? s_sKey[eNum] : s_sKey[eSize];
|
|
WritePrivateProfileString(s_sKey[eSort], s_sKey[eRule], szValue, sFileName);
|
|
|
|
if (GetCalWidthRule() == TLabelSetDataTable::eWallInboard)
|
|
szValue = s_sKey[eInboard];
|
|
else if (GetCalWidthRule() == TLabelSetDataTable::eWallOutboard)
|
|
szValue = s_sKey[eOutboard];
|
|
else
|
|
szValue = s_sKey[eMiddle];
|
|
WritePrivateProfileString(s_sKey[eSort], s_sKey[eCalWidth], szValue, sFileName);
|
|
|
|
szValue = GetHyphenRule() ? s_sKey[eHasHyphen] : s_sKey[eNoHyphen];
|
|
WritePrivateProfileString(s_sKey[eSort], s_sKey[eHyphen], szValue, sFileName);
|
|
|
|
szValue = GetRoundRule() ? s_sKey[eIsRound] : s_sKey[eNoRound];
|
|
WritePrivateProfileString(s_sKey[eSort], s_sKey[eRound], szValue, sFileName);
|
|
|
|
for (int i = 0; i < (int)m_arLabelData.GetSize(); i++)
|
|
{
|
|
SOpeningLabelGroup *pGroup = m_arLabelData[i];
|
|
for (int i = 0; i < (int)pGroup->arLabelPair.GetSize(); i++)
|
|
{
|
|
WritePrivateProfileString(pGroup->sLabel,
|
|
pGroup->arLabelPair[i].sPurpose,
|
|
pGroup->arLabelPair[i].sSerialNum,
|
|
sFileName);
|
|
}
|
|
}
|
|
|
|
return ;
|
|
}
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
TOpeningLabelData::TOpeningLabelData()
|
|
{
|
|
// 提示语置空
|
|
m_csPrompt = _T("");
|
|
|
|
// 获取文件路径
|
|
CString csSysPath = g_sDwbPath;
|
|
csSysPath = csSysPath.Left(csSysPath.GetLength() - 5) + _T("\\sys\\");
|
|
m_sFileName = csSysPath + OPENING_LABEL_INI;
|
|
|
|
// 检查文件是否存在
|
|
CFileStatus cStatus;
|
|
if (!CFile::GetStatus(m_sFileName, cStatus))
|
|
{
|
|
m_csPrompt.Format(_T("%s文件不存在!"), m_sFileName);
|
|
}
|
|
|
|
m_allDatas.m_bReaded = FALSE;
|
|
Read(m_allDatas);
|
|
}
|
|
|
|
TOpeningLabelData::~TOpeningLabelData()
|
|
{
|
|
}
|
|
|
|
BOOL TOpeningLabelData::Read(TLabelSetDataTable &dataTable)
|
|
{
|
|
int iRet = 0;
|
|
if (!m_allDatas.m_bReaded)
|
|
iRet = m_allDatas.Read(m_sFileName);
|
|
|
|
if (&dataTable != &m_allDatas)
|
|
dataTable.CopyFrom(m_allDatas);
|
|
|
|
if (iRet == 1)
|
|
{
|
|
m_csPrompt.Format(_T("%s文件不存在!"), m_sFileName);
|
|
return FALSE;
|
|
}
|
|
else if (iRet == 2)
|
|
{
|
|
m_csPrompt.Format(_T("%s文件格式发生错误!"), m_sFileName);
|
|
return FALSE;
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL TOpeningLabelData::Write(const TLabelSetDataTable &dataTable) const
|
|
{
|
|
if (!m_allDatas.m_bReaded)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
dataTable.Write(m_sFileName);
|
|
return TRUE;
|
|
}
|
|
|
|
// 系统要求提供接口
|
|
// 获得所有标签名称(不包括Sort)
|
|
bool TOpeningLabelData::GetLabelArray(CStringArray &arLabel) const
|
|
{
|
|
if (!m_allDatas.m_bReaded)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (arLabel.GetSize() != 0)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
arLabel.SetSize(eDoorTypeNum);
|
|
for (int i = 0; i < eDoorTypeNum; i++)
|
|
{
|
|
arLabel[i] = s_sDoorDatas[i*4];
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
// 根据给出的标签名称,获得子类型(即:用途) ==>> [***]-->用途数组
|
|
bool TOpeningLabelData::GetSubType(const CString &csKind, CStringArray &arSubType) const
|
|
{
|
|
if (!m_allDatas.m_bReaded)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (arSubType.GetSize() != 0)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
SOpeningLabelGroup *pGroup = m_allDatas.GetLabelContent(csKind);
|
|
if (pGroup == NULL)
|
|
return false;
|
|
|
|
ASSERT(pGroup->arLabelPair.GetSize() != 0);
|
|
for (int i = 0; i < (int)pGroup->arLabelPair.GetSize(); i++)
|
|
{
|
|
arSubType.Add(pGroup->arLabelPair[i].sPurpose);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
// 根据给出的标签名称,获得子类型的编号 ==>>[***]-->标号数组
|
|
bool TOpeningLabelData::GetSubLabelPrefix(const CString &csKind, CStringArray &arLabelPrefix) const
|
|
{
|
|
if (!m_allDatas.m_bReaded)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (arLabelPrefix.GetSize() != 0)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
SOpeningLabelGroup *pGroup = m_allDatas.GetLabelContent(csKind);
|
|
if (pGroup == NULL)
|
|
return false;
|
|
|
|
ASSERT(pGroup->arLabelPair.GetSize() != 0);
|
|
for (int i = 0; i < (int)pGroup->arLabelPair.GetSize(); i++)
|
|
{
|
|
arLabelPrefix.Add(pGroup->arLabelPair[i].sSerialNum);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
// 获得是否添加连字符
|
|
bool TOpeningLabelData::HasHypen() const
|
|
{
|
|
if (!m_allDatas.m_bReaded)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return m_allDatas.GetHyphenRule() ? true : false;
|
|
}
|
|
|
|
// 获得是否四舍五入
|
|
bool TOpeningLabelData::IsRound() const
|
|
{
|
|
if (!m_allDatas.m_bReaded)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return m_allDatas.GetRoundRule() ? true : false;
|
|
}
|
|
|
|
// 获得窗宽计算位置的原则
|
|
TOpeningLabelData::ECalWidthRule TOpeningLabelData::GetCalWidthRule()
|
|
{
|
|
if (!m_allDatas.m_bReaded)
|
|
{
|
|
return TOpeningLabelData::kMiddle;
|
|
}
|
|
|
|
int nNum = (int)m_allDatas.GetCalWidthRule();
|
|
return (TOpeningLabelData::ECalWidthRule)nNum;
|
|
}
|
|
|
|
|
|
// 获得编号原则,按尺寸或者按数序
|
|
TOpeningLabelData::ESerialRule TOpeningLabelData::GetNumRule()
|
|
{
|
|
if (!m_allDatas.m_bReaded)
|
|
{
|
|
return TOpeningLabelData::kSize;
|
|
}
|
|
|
|
int nNum = (int)m_allDatas.GetSerialRule();
|
|
return (TOpeningLabelData::ESerialRule)nNum;
|
|
}
|
|
|
|
// 根据编号,获得大类型(即:标签)和子类型(即:用途)
|
|
void TOpeningLabelData::GetTypeByLabel(const CString &csPrefix, CStringArray &arCsLabel, CStringArray &ArCsSubType)
|
|
{
|
|
if (!m_allDatas.m_bReaded)
|
|
{
|
|
return;
|
|
}
|
|
|
|
for (int i = 0; i < (int)m_allDatas.m_arLabelData.GetSize(); i++)
|
|
{
|
|
SOpeningLabelGroup *pGroup = m_allDatas.m_arLabelData[i];
|
|
|
|
for (int i = 0;i < (int)pGroup->arLabelPair.GetSize(); i++)
|
|
{
|
|
if (pGroup->arLabelPair[i].sSerialNum.CompareNoCase(csPrefix) == 0)
|
|
{
|
|
arCsLabel.Add(pGroup->sLabel); // 大类型
|
|
ArCsSubType.Add(pGroup->arLabelPair[i].sPurpose); // 小类型
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
CString TOpeningLabelData::TypeToLabel(const CString &sType)
|
|
{
|
|
for (int i = 0; i < eDoorTypeNum; i++)
|
|
{
|
|
if (s_sDoorDatas[i*4 + 1].CompareNoCase(sType) == 0)
|
|
{
|
|
return s_sDoorDatas[i*4];
|
|
}
|
|
}
|
|
|
|
return _T("");
|
|
}
|
|
|
|
int TOpeningLabelData::GetLabelIndex(const CString &sLabel)
|
|
{
|
|
for (int i = 0; i < eDoorTypeNum; i++)
|
|
{
|
|
if (s_sDoorDatas[i*4].CompareNoCase(sLabel) == 0)
|
|
{
|
|
return i;
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
// 获得一个具体的标注值
|
|
bool TOpeningLabelData::GetOpeningLabel(const CString &csKind, const CString &csSubKind, CString &csLabel)
|
|
{
|
|
CString sValue = _T("");
|
|
GetPrivateProfileString(csKind, csSubKind, _T(""), sValue.GetBuffer(MAX_PATH), MAX_PATH, m_sFileName);
|
|
sValue.ReleaseBuffer();
|
|
if (!sValue.IsEmpty())
|
|
{
|
|
csLabel = sValue;
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
// 获得所有类型,按顺序输出
|
|
bool TOpeningLabelData::GetAllOpeningType(CStringArray &aryAllSubType)
|
|
{
|
|
// 首先获得所有标签名
|
|
CStringArray arSectionName, arTempLabels;
|
|
if (!GetLabelArray(arSectionName))
|
|
return false;
|
|
|
|
CString csSection, csType;
|
|
int nSize = (int)arSectionName.GetSize(),
|
|
nLabelSize(0), nAllSize(0), i(0), j(0), k(0), nFind(-1);
|
|
for (i=0; i<nSize; i++)
|
|
{
|
|
csSection = arSectionName[i];
|
|
GetSubType(csSection, arTempLabels); // 获得标签名下的所有类型
|
|
|
|
nLabelSize = (int)arTempLabels.GetSize();
|
|
while(nLabelSize)
|
|
{
|
|
csType = arTempLabels[0];
|
|
|
|
nFind = -1;
|
|
nAllSize = (int)aryAllSubType.GetSize();
|
|
for (k=0; k<nAllSize; k++)
|
|
{
|
|
csSection = aryAllSubType[k];
|
|
if (_tcscmp(csSection, csType) == 0)
|
|
{
|
|
nFind = k;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (nFind == -1) // 找不到,再添加
|
|
{
|
|
aryAllSubType.Add(csType);
|
|
}
|
|
|
|
arTempLabels.RemoveAt(0); // 相当于同时清空arTempLabels,准备获得下一个循环
|
|
nLabelSize--;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|