Files
envi-code/SourceCode/Code2026/tg_shs/shs_annotate/CellPropDlg.cpp
T
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

222 lines
6.8 KiB
C++

// CellPropDlg.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "CellPropDlg.h"
//extern TARCH_IMPEXP XString GetSymbolName(AcDbObjectId idSymbolRec);
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCellPropDlg dialog
CCellPropDlg::CCellPropDlg(CWnd* pParent /*=NULL*/)
: CGridStyleDialog(CCellPropDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CCellPropDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
CCellPropDlg::CCellPropDlg(UINT id, CWnd* pParent /*=NULL*/)
: CGridStyleDialog(id, pParent)
{
//{{AFX_DATA_INIT(CCellPropDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CCellPropDlg::DoDataExchange(CDataExchange* pDX)
{
CGridStyleDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCellPropDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCellPropDlg, CGridStyleDialog)
//{{AFX_MSG_MAP(CCellPropDlg)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCellPropDlg message handlers
void
CCellPropDlg::Obj2Dlg(const TDbSheet *pSheet, int nRow, int nCol)
{
ASSERT(pSheet);
TGridStyle gridStyle;
gridStyle.SetOverrideAll(FALSE);
BOOL bLocal=TRUE;
//水平对齐
AcDb::TextHorzMode nHorMode=pSheet->GetCellHorMode(nRow, nCol, &bLocal);
m_nHorMode=HorMode2Index(nHorMode);
if(!bLocal)
m_nHorMode=0;
XString sHorMode;
int nParentHorMode=HorMode2Index(pSheet->GetCellGridStyle(gridStyle, nCol, OF_HORMODE)->GetHorMode());
sHorMode << g_szHorModes[nParentHorMode] << _T("(") << g_szHorModes[0] << _T(")");
*m_lstHorModes[0]=sHorMode;
//垂直对齐
AcDb::TextVertMode nVerMode=pSheet->GetCellVerMode(nRow, nCol, &bLocal);
m_nVerMode=VerMode2Index(nVerMode);
if(!bLocal)
m_nVerMode=0;
int nParentVerMode=VerMode2Index(pSheet->GetRow(nRow)->GetVerMode());
XString sVerMode;
sVerMode << g_szVerModes[nParentVerMode] << _T("(") << g_szVerModes[0] << _T(")");
*m_lstVerModes[0]=sVerMode;
// 行距系数
double nFactor=pSheet->GetCellLineSpaceFactor(nRow, nCol, &bLocal);
XString sFactor, sFactorParent;
ftoa(nFactor, 1, sFactor);
if(!bLocal) {
sFactor << _T("(") << g_szFactors[0] << _T(")");
}
ftoa(pSheet->GetCellGridStyle(gridStyle, nCol, OF_LINESPACE)->GetLineSpaceFactor(),
1, sFactorParent);
*m_lstFactors[0]=XString(_T("%s(继承)"), (const TCHAR *)sFactorParent);
m_csLineSpaceFactor=sFactor;
//文字高度
double nTextSize=pSheet->GetCellTextHeight(nRow, nCol, TRUE, &bLocal);
XString sTextSize, sTextSizeParent;
ftoa(nTextSize, 1, sTextSize);
if(!bLocal) {
sTextSize << _T("(") << g_szTextSizes[0] << _T(")");
}
ftoa(pSheet->GetCellGridStyle(gridStyle, nCol, OF_TEXTHEIGHT)->GetTextHeight(), 1, sTextSizeParent);
*m_lstTextSizes[0]=XString(_T("%s(继承)"), (const TCHAR *)sTextSizeParent);
m_csTextSize=sTextSize;
//文字样式
AcDbObjectId idStyle=pSheet->GetCellTextStyle(nRow, nCol, &bLocal);
ASSERT(!!idStyle);
XString szStyle=GetSymbolName(idStyle);
XString sStyle;
sStyle << GetSymbolName(pSheet->GetCellGridStyle(gridStyle, nCol, OF_TEXTSTYLE)->GetTextStyleId()) << _T("(继承)");
*m_lstTextStyles[0]=sStyle;
if(!bLocal) {
m_nTextStyle=0;
} else {
for(int i=1; i<m_lstTextStyles.Length(); i++) {
if(_tcsicmp(*m_lstTextStyles[i], szStyle)==0) {
m_nTextStyle=i;
break;
}
}
}
//换行属性
m_bTextWrap=pSheet->IsCellWrapEnabled(nRow, nCol, &bLocal);
m_bParentTextWrap=pSheet->GetCellGridStyle(gridStyle, nCol, OF_TEXTWRAP)->IsTextWrap();
m_bInheritWrapText=!bLocal;
if(m_bInheritWrapText)
m_bTextWrap=m_bParentTextWrap;
//颜色
m_nTextColor = pSheet->GetCellTextColor(nRow, nCol, &bLocal);
int nParentColor=pSheet->GetCellGridStyle(gridStyle, nCol, OF_TEXTCOLOR)->GetTextColor();
if(nParentColor==0)
nParentColor=pSheet->colorIndex();
if(!bLocal) { //继承为Byblock
m_nTextColor=0;
}
if(nParentColor)
m_colorComboBox.SetBlockColorIndex(nParentColor);
}
void
CCellPropDlg::Dlg2Obj(TDbSheet *pSheet, int nRow, int nCol) const
{
ASSERT(pSheet);
TGridCell *pCell=(*pSheet)(nRow, nCol);;
pSheet->assertWriteEnabled();
TGridStyle *pGridStyle=NULL;
if(pCell->IsRange()) {
TGridRange *pRange=(TGridRange *)pCell->GetRange();
pGridStyle=&(pRange->m_gridStyle);
} else {
pGridStyle=&(pCell->m_gridStyle);
}
TGridStyle &gridStyle=*pGridStyle;
BOOL bLocal=TRUE;
//水平对齐
if(m_nHorMode==0) {
gridStyle.SetFlagBit(OF_HORMODE, FALSE);
} else if(m_nHorMode>0) {
gridStyle.SetFlagBit(OF_HORMODE, TRUE);
gridStyle.SetHorMode(Index2HorMode(m_nHorMode));
}
//垂直对齐
if(m_nVerMode==0) {
gridStyle.SetFlagBit(OF_VERMODE, FALSE);
} else if(m_nVerMode) {
gridStyle.SetFlagBit(OF_VERMODE, TRUE);
gridStyle.SetVerMode(Index2VerMode(m_nVerMode));
}
// 行距系数
if(_tcscmp(m_csLineSpaceFactor, m_lstFactors[0])==0) {
gridStyle.SetFlagBit(OF_LINESPACE, FALSE);
} else if(!m_csLineSpaceFactor.IsEmpty()) {
double nLineSpaceFactor=_tstof(m_csLineSpaceFactor);
if(nLineSpaceFactor>-1.0E-3) {
gridStyle.SetFlagBit(OF_LINESPACE, TRUE);
gridStyle.SetLineSpaceFactor(nLineSpaceFactor);
}
}
//文字高度
if(_tcscmp(m_csTextSize, m_lstTextSizes[0])==0) {
gridStyle.SetFlagBit(OF_TEXTHEIGHT, FALSE);
} else if(!m_csTextSize.IsEmpty()) {
double nTextSize=_tstof(m_csTextSize);
if(nTextSize>1.0E-3) {
gridStyle.SetFlagBit(OF_TEXTHEIGHT, TRUE);
gridStyle.SetTextHeight(nTextSize);
}
}
//文字样式
if(m_nTextStyle==0) {
gridStyle.SetFlagBit(OF_TEXTSTYLE, FALSE);
} else if(m_nTextStyle>0) {
gridStyle.SetFlagBit(OF_TEXTSTYLE, TRUE);
gridStyle.SetTextStyleId(GetTextStyleId(m_lstTextStyles[m_nTextStyle]));
}
//换行属性
if(m_bInheritWrapText) {
gridStyle.SetFlagBit(OF_TEXTWRAP, FALSE);
} else {
gridStyle.SetFlagBit(OF_TEXTWRAP, TRUE);
gridStyle.SetTextWrap(m_bTextWrap);
}
//颜色
if(m_nTextColor==0) {
gridStyle.SetFlagBit(OF_TEXTCOLOR, FALSE);
} else if(m_nTextColor>0) {
gridStyle.SetFlagBit(OF_TEXTCOLOR, TRUE);
gridStyle.SetTextColor(m_nTextColor);
}
}