4554 lines
125 KiB
C++
4554 lines
125 KiB
C++
#include "stdafx.h"
|
||
#include "AcGiUtil.h"
|
||
|
||
#include "dbobjptr.h"
|
||
|
||
static int CompareRange(const TGridRange *p1, const void *p2)
|
||
{
|
||
return (p1!=p2);
|
||
}
|
||
|
||
#define LSF_DEFAULT 0.4
|
||
|
||
Acad::ErrorStatus CalInsertParameters(const AcDbBlockReference *pBlkSrc, XPoint &ptNewBase, double *nRotation,
|
||
double *nSx, double *nSy, double *nSz,TBlockGeomInfo info)
|
||
{
|
||
|
||
ads_matrix matRotOld, matMove, matScale, matRotNew, matTransform;
|
||
double nSizeX, nSizeY, nSizeZ, nRot;
|
||
XPoint ptBase, ptCen, ptNewCen;
|
||
VERIFY(GetBlockRefSizeInfo(pBlkSrc, ptBase, &nRot, ptCen, &nSizeX, &nSizeY, &nSizeZ)==RTNORM);
|
||
ptNewCen = info.m_ptCen;
|
||
ptNewCen.z += info.m_nSizeZ/2.0;
|
||
|
||
// 绕旧中心旋转-nRotOld -> 绕旧中心Scale -> 平移到新中心 -> 旋转 RotNew
|
||
// or
|
||
// 绕旧中心旋转-nRotOld -> 绕旧中心Scale -> 旋转 RotNew -> 平移到新中心 (Current Method)
|
||
AcGeScale3d bScale = pBlkSrc->scaleFactors();
|
||
double sx=1, sy=1, sz=1;
|
||
if(fabs(nSizeX)>1.0E-6) bScale[0] *= (sx = info.m_nSizeX/nSizeX);
|
||
if(fabs(nSizeY)>1.0E-6) bScale[1] *= (sy = info.m_nSizeY/nSizeY);
|
||
if(fabs(nSizeZ)>1.0E-6) bScale[2] *= (sz = info.m_nSizeZ/nSizeZ);
|
||
|
||
ptCen.GetRotationMatrix(-nRot, matRotOld);
|
||
ptCen.GetScaleMatrix(sx, sy, sz, matScale);
|
||
ptCen.GetRotationMatrix(info.m_nRotation, matRotNew);
|
||
ptCen.GetMoveMatrix(ptNewCen, matMove);
|
||
|
||
MatrixMultiply(matTransform, matMove, matRotNew, matScale, matRotOld, NULL);
|
||
ptNewBase = ptBase.TransformAs(matTransform); //换算新的基点位置
|
||
*nRotation = info.m_nRotation;
|
||
*nSx = bScale[0];
|
||
*nSy = bScale[1];
|
||
*nSz = bScale[2];
|
||
|
||
return Acad::eOk;
|
||
}
|
||
void UpdateInsert(AcDbBlockReference *pInsert,TBlockGeomInfo info,BOOL bUniScale)
|
||
{
|
||
XPoint ptNewBase;
|
||
double nNewRot;
|
||
AcGeScale3d scale;
|
||
if(CalInsertParameters(pInsert, ptNewBase, &nNewRot, &scale[0], &scale[1], &scale[2],info)!=Acad::eOk)
|
||
return;
|
||
pInsert->setPosition(ptNewBase);
|
||
pInsert->setRotation(nNewRot);
|
||
|
||
if(bUniScale)
|
||
{
|
||
double dScale = min(scale[0], scale[1]);
|
||
pInsert->setScaleFactors(AcGeScale3d(dScale,dScale,dScale));
|
||
}
|
||
else
|
||
{
|
||
pInsert->setScaleFactors(scale);
|
||
}
|
||
}
|
||
|
||
////////////////////////////////////////////
|
||
// 方格的样式
|
||
//TArch5\6,1;TArch7,2
|
||
const Adesk::UInt8 TGridStyle::g_nVersion=2;
|
||
TGridStyle::TGridStyle()
|
||
{
|
||
m_nOverride=0; //override parent's style (none)
|
||
m_nHorMode = AcDb::kTextLeft; // Specifies the horizontal text alignment
|
||
m_nVerMode = AcDb::kTextBase;
|
||
// AcDbHardPointerId m_idTextStyle; // Font
|
||
m_nTextColor=0; //Controls the foreground(Text) color
|
||
m_bTextWrap=true; // Word wraps cell text when true
|
||
m_nLineSpaceFactor=LSF_DEFAULT; //自动换行时的行距系数(行距=系数*字高)
|
||
m_nTextHeight=3.0;
|
||
|
||
m_nTextDirection=kRight;
|
||
}
|
||
|
||
TGridStyle::TGridStyle(const TGridStyle &src)
|
||
{
|
||
*this = src;
|
||
}
|
||
|
||
TGridStyle &
|
||
TGridStyle::operator = (const TGridStyle &src)
|
||
{
|
||
CopyObject(src, *this);
|
||
return *this;
|
||
}
|
||
|
||
|
||
Acad::ErrorStatus TGridStyle::dwgInFields (AcDbDwgFiler* pFiler)
|
||
{
|
||
Adesk::UInt8 nVer=0;
|
||
pFiler->readItem(&nVer);
|
||
if(nVer>g_nVersion) // Version is too new
|
||
return Acad::eMakeMeProxy;
|
||
|
||
pFiler->readItem(&m_nOverride);
|
||
if(m_nOverride&OF_HORMODE) {
|
||
Adesk::UInt8 align;
|
||
pFiler->readItem(&align);
|
||
m_nHorMode=(AcDb::TextHorzMode)align;
|
||
}
|
||
if(m_nOverride&OF_VERMODE) {
|
||
Adesk::UInt8 align;
|
||
pFiler->readItem(&align);
|
||
m_nVerMode=(AcDb::TextVertMode)align;
|
||
}
|
||
if(m_nOverride&OF_TEXTSTYLE) {
|
||
pFiler->readItem(&m_idTextStyle);
|
||
}
|
||
if(m_nOverride&OF_TEXTCOLOR) {
|
||
pFiler->readItem(&m_nTextColor);
|
||
}
|
||
if(m_nOverride&OF_TEXTWRAP) {
|
||
pFiler->readItem(&m_bTextWrap);
|
||
}
|
||
if(m_nOverride&OF_LINESPACE) {
|
||
pFiler->readItem(&m_nLineSpaceFactor);
|
||
}
|
||
if(m_nOverride&OF_TEXTHEIGHT) {
|
||
pFiler->readItem(&m_nTextHeight);
|
||
}
|
||
|
||
if(nVer>1)
|
||
{
|
||
Adesk::UInt8 nDirection;
|
||
pFiler->readItem(&nDirection);
|
||
m_nTextDirection=(TextDirection)nDirection;
|
||
}
|
||
return pFiler->filerStatus();
|
||
}
|
||
|
||
Acad::ErrorStatus TGridStyle::dwgOutFields(AcDbDwgFiler* pFiler) const
|
||
{
|
||
if(g_nSaveTArchVer<7)
|
||
pFiler->writeItem((Adesk::UInt8)1);
|
||
else
|
||
pFiler->writeItem(g_nVersion);
|
||
|
||
pFiler->writeItem(m_nOverride);
|
||
if(m_nOverride&OF_HORMODE)
|
||
pFiler->writeItem((Adesk::UInt8)m_nHorMode);
|
||
if(m_nOverride&OF_VERMODE)
|
||
pFiler->writeItem((Adesk::UInt8)m_nVerMode);
|
||
if(m_nOverride&OF_TEXTSTYLE)
|
||
pFiler->writeItem(m_idTextStyle);
|
||
if(m_nOverride&OF_TEXTCOLOR)
|
||
pFiler->writeItem(m_nTextColor);
|
||
if(m_nOverride&OF_TEXTWRAP)
|
||
pFiler->writeItem(m_bTextWrap);
|
||
if(m_nOverride&OF_LINESPACE)
|
||
pFiler->writeItem(m_nLineSpaceFactor);
|
||
if(m_nOverride&OF_TEXTHEIGHT)
|
||
pFiler->writeItem(m_nTextHeight);
|
||
|
||
if(g_nSaveTArchVer>6)
|
||
pFiler->writeItem((Adesk::UInt8)m_nTextDirection);
|
||
|
||
return pFiler->filerStatus();
|
||
}
|
||
|
||
void TGridStyle::SetOverrideAll(BOOL bTrue)
|
||
{
|
||
if(bTrue) m_nOverride=(OF_HORMODE|OF_VERMODE|OF_TEXTSTYLE|OF_TEXTCOLOR|
|
||
OF_TEXTWRAP|OF_LINESPACE|OF_TEXTHEIGHT);
|
||
else m_nOverride=0;
|
||
}
|
||
|
||
void TGridStyle::SetFlagBit(int nFlag, BOOL bSet)
|
||
{
|
||
if(bSet) {
|
||
m_nOverride |= nFlag;
|
||
} else {
|
||
m_nOverride &= ~nFlag;
|
||
}
|
||
}
|
||
|
||
void TGridStyle::SetTextStyleId(AcDbObjectId id)
|
||
{
|
||
m_idTextStyle=id;
|
||
}
|
||
|
||
void TGridStyle::SetTextColor(Adesk::UInt16 nColor)
|
||
{
|
||
m_nTextColor=nColor;
|
||
}
|
||
|
||
void TGridStyle::SetTextWrap(BOOL bTrue)
|
||
{
|
||
m_bTextWrap=bTrue;
|
||
}
|
||
|
||
void TGridStyle::SetLineSpaceFactor(double nFactor)
|
||
{
|
||
m_nLineSpaceFactor=nFactor;
|
||
}
|
||
|
||
void TGridStyle::SetTextHeight(double h)
|
||
{
|
||
m_nTextHeight=h;
|
||
}
|
||
|
||
|
||
BOOL TGridStyle::TestFlagBit(int nFlag) const
|
||
{
|
||
return ((m_nOverride&nFlag)!=0);
|
||
}
|
||
|
||
AcDbObjectId TGridStyle::GetTextStyleId() const
|
||
{
|
||
return m_idTextStyle;
|
||
}
|
||
|
||
Adesk::UInt16 TGridStyle::GetTextColor() const
|
||
{
|
||
return m_nTextColor;
|
||
}
|
||
|
||
BOOL TGridStyle::IsTextWrap() const
|
||
{
|
||
return m_bTextWrap;
|
||
}
|
||
|
||
double TGridStyle::GetLineSpaceFactor() const
|
||
{
|
||
return m_nLineSpaceFactor;
|
||
}
|
||
|
||
double TGridStyle::GetTextHeight() const
|
||
{
|
||
return m_nTextHeight;
|
||
}
|
||
|
||
void TGridStyle::SetVerMode(AcDb::TextVertMode nVerMode)
|
||
{
|
||
m_nVerMode=nVerMode;
|
||
}
|
||
|
||
void TGridStyle::SetHorMode(AcDb::TextHorzMode nHorMode)
|
||
{
|
||
m_nHorMode=nHorMode;
|
||
}
|
||
|
||
AcDb::TextHorzMode
|
||
TGridStyle::GetHorMode() const
|
||
{
|
||
return m_nHorMode;
|
||
}
|
||
|
||
AcDb::TextVertMode
|
||
TGridStyle::GetVerMode() const
|
||
{
|
||
return m_nVerMode;
|
||
}
|
||
|
||
|
||
/////////////////////////////////////
|
||
// 分割线样式
|
||
const Adesk::UInt8 TDividerStyle::g_nVersion=1;
|
||
TDividerStyle::TDividerStyle()
|
||
{
|
||
m_nFlag=kParent;
|
||
m_nColor=0;
|
||
//AcDbHardPointerId m_idLineType; //线型
|
||
m_nLineWidth=0.0; //线宽
|
||
}
|
||
|
||
TDividerStyle::TDividerStyle(const TDividerStyle &src)
|
||
{
|
||
*this = src;
|
||
}
|
||
|
||
TDividerStyle &
|
||
TDividerStyle::operator= (const TDividerStyle &src)
|
||
{
|
||
CopyObject(src, *this);
|
||
return *this;
|
||
}
|
||
|
||
|
||
Acad::ErrorStatus TDividerStyle::dwgInFields (AcDbDwgFiler* pFiler)
|
||
{
|
||
Adesk::UInt8 nVer=0;
|
||
pFiler->readItem(&nVer);
|
||
if(nVer>g_nVersion) // Version is too new
|
||
return Acad::eMakeMeProxy;
|
||
Adesk::UInt8 nTemp;
|
||
pFiler->readItem(&nTemp);
|
||
m_nFlag=(TDividerFlag)nTemp;
|
||
if(m_nFlag==TDividerStyle::kLocal) {
|
||
pFiler->readItem(&m_nColor);
|
||
pFiler->readItem(&m_idLineType);
|
||
pFiler->readItem(&m_nLineWidth);
|
||
}
|
||
return pFiler->filerStatus();
|
||
}
|
||
|
||
Acad::ErrorStatus TDividerStyle::dwgOutFields(AcDbDwgFiler* pFiler) const
|
||
{
|
||
pFiler->writeItem(g_nVersion);
|
||
|
||
pFiler->writeItem((Adesk::UInt8 )m_nFlag);
|
||
if(m_nFlag==TDividerStyle::kLocal) {
|
||
pFiler->writeItem(m_nColor);
|
||
pFiler->writeItem(m_idLineType);
|
||
pFiler->writeItem(m_nLineWidth);
|
||
}
|
||
return pFiler->filerStatus();
|
||
}
|
||
|
||
|
||
TDividerStyle::TDividerFlag
|
||
TDividerStyle::GetDividerFlag() const
|
||
{
|
||
return m_nFlag;
|
||
}
|
||
|
||
double
|
||
TDividerStyle::GetLineWidth() const
|
||
{
|
||
return m_nLineWidth;
|
||
}
|
||
|
||
AcDbObjectId
|
||
TDividerStyle::GetLineTypeId() const
|
||
{
|
||
return m_idLineType;
|
||
}
|
||
|
||
Adesk::UInt16
|
||
TDividerStyle::GetColor() const
|
||
{
|
||
return m_nColor;
|
||
}
|
||
|
||
void
|
||
TDividerStyle::SetDividerFlag(TDividerFlag flag)
|
||
{
|
||
m_nFlag=flag;
|
||
}
|
||
|
||
void
|
||
TDividerStyle::SetLineWidth(double nWidth)
|
||
{
|
||
m_nLineWidth=nWidth;
|
||
}
|
||
|
||
void
|
||
TDividerStyle::SetLineTypeId(AcDbObjectId id)
|
||
{
|
||
m_idLineType=id;
|
||
}
|
||
|
||
void
|
||
TDividerStyle::SetColor(Adesk::UInt16 nColor)
|
||
{
|
||
m_nColor=nColor;
|
||
}
|
||
|
||
|
||
////////////////////////////////
|
||
// 列定义
|
||
const Adesk::UInt8 TSheetColumn::g_nVersion=1;
|
||
TSheetColumn::TSheetColumn()
|
||
{
|
||
//m_gridStyle.m_nOverride = 0;
|
||
m_divider.m_nFlag=TDividerStyle::kParent; // Divider style for right column border
|
||
m_bAllowSizing=true; // Enables interactive resizing for a column
|
||
m_nWidth=0.0; //in Paper Unit
|
||
}
|
||
|
||
TSheetColumn::TSheetColumn(const TSheetColumn &src)
|
||
{
|
||
*this=src;
|
||
}
|
||
|
||
TSheetColumn &
|
||
TSheetColumn::operator= (const TSheetColumn &src)
|
||
{
|
||
CopyObject(src, *this);
|
||
return *this;
|
||
}
|
||
|
||
BOOL TSheetColumn::IsValid() const
|
||
{
|
||
return (m_nWidth>0.0);
|
||
}
|
||
|
||
Acad::ErrorStatus TSheetColumn::dwgInFields (AcDbDwgFiler* pFiler)
|
||
{
|
||
Adesk::UInt8 nVer=0;
|
||
pFiler->readItem(&nVer);
|
||
if(nVer>g_nVersion) // Version is too new
|
||
return Acad::eMakeMeProxy;
|
||
|
||
Acad::ErrorStatus es=m_gridStyle.dwgInFields(pFiler);
|
||
if(es!=Acad::eOk)
|
||
return es;
|
||
es=m_divider.dwgInFields(pFiler);
|
||
if(es!=Acad::eOk)
|
||
return es;
|
||
pFiler->readItem(&m_bAllowSizing);
|
||
pFiler->readItem(&m_nWidth);
|
||
return pFiler->filerStatus();
|
||
}
|
||
|
||
Acad::ErrorStatus TSheetColumn::dwgOutFields(AcDbDwgFiler* pFiler) const
|
||
{
|
||
pFiler->writeItem(g_nVersion);
|
||
|
||
VERIFY(m_gridStyle.dwgOutFields(pFiler)==Acad::eOk);
|
||
VERIFY(m_divider.dwgOutFields(pFiler)==Acad::eOk);
|
||
pFiler->writeItem(m_bAllowSizing);
|
||
pFiler->writeItem(m_nWidth);
|
||
return pFiler->filerStatus();
|
||
}
|
||
|
||
//图纸单位
|
||
double TSheetColumn::GetWidth() const
|
||
{
|
||
return m_nWidth;
|
||
}
|
||
|
||
//图纸单位
|
||
void TSheetColumn::SetWidth(double w)
|
||
{
|
||
m_nWidth=w;
|
||
}
|
||
|
||
const TDividerStyle &
|
||
TSheetColumn::GetDividerStyle() const
|
||
{
|
||
return m_divider;
|
||
}
|
||
|
||
TDividerStyle &
|
||
TSheetColumn::GetDividerStyle()
|
||
{
|
||
return m_divider;
|
||
}
|
||
|
||
const TGridStyle &
|
||
TSheetColumn::GetGridStyle() const
|
||
{
|
||
return m_gridStyle;
|
||
}
|
||
|
||
TGridStyle &
|
||
TSheetColumn::GetGridStyle()
|
||
{
|
||
return m_gridStyle;
|
||
}
|
||
|
||
BOOL
|
||
TSheetColumn::AllowSizing() const
|
||
{
|
||
return m_bAllowSizing;
|
||
}
|
||
|
||
void
|
||
TSheetColumn::SetAllowSizing(BOOL bTrue)
|
||
{
|
||
m_bAllowSizing=bTrue;
|
||
}
|
||
|
||
void
|
||
TSheetColumn::SetDividerStyle(const TDividerStyle &style)
|
||
{
|
||
CopyObject(style, m_divider);
|
||
}
|
||
|
||
void TSheetColumn::SetGridStyle(const TGridStyle &style)
|
||
{
|
||
CopyObject(style, m_gridStyle);
|
||
}
|
||
|
||
|
||
///////////////////////////////
|
||
// 行定义
|
||
const Adesk::UInt8 TSheetRow::g_nVersion=1;
|
||
TSheetRow::TSheetRow()
|
||
{
|
||
m_divider.m_nFlag=TDividerStyle::kParent; // Divider style for right column border
|
||
m_nHeightFlag=TSheetRow::kParent; // Disable interactive resizing for row
|
||
m_nHeight=0.0; //in Paper Unit
|
||
m_nVerMode=AcDb::kTextBase;
|
||
}
|
||
|
||
TSheetRow::TSheetRow(const TSheetRow &src)
|
||
{
|
||
*this = src;
|
||
}
|
||
|
||
TSheetRow &
|
||
TSheetRow::operator= (const TSheetRow &src)
|
||
{
|
||
CopyObject(src, *this);
|
||
return *this;
|
||
}
|
||
|
||
double TSheetRow::GetHeight() const
|
||
{
|
||
return m_nHeight;
|
||
}
|
||
|
||
void TSheetRow::SetHeight(double h)
|
||
{
|
||
m_nHeight = h;
|
||
}
|
||
|
||
TSheetRow::TRowHeightStyle TSheetRow::GetRowHeightStyle() const
|
||
{
|
||
return m_nHeightFlag;
|
||
}
|
||
|
||
void TSheetRow::SetRowHeightStyle(TSheetRow::TRowHeightStyle st)
|
||
{
|
||
m_nHeightFlag=st;
|
||
}
|
||
|
||
const TDividerStyle &
|
||
TSheetRow::GetDividerStyle() const
|
||
{
|
||
return m_divider;
|
||
}
|
||
|
||
TDividerStyle &
|
||
TSheetRow::GetDividerStyle()
|
||
{
|
||
return m_divider;
|
||
}
|
||
|
||
void TSheetRow::SetDividerStyle(const TDividerStyle &src)
|
||
{
|
||
CopyObject(src, m_divider);
|
||
}
|
||
|
||
Acad::ErrorStatus TSheetRow::dwgInFields (AcDbDwgFiler* pFiler)
|
||
{
|
||
Adesk::UInt8 nVer=0;
|
||
pFiler->readItem(&nVer);
|
||
if(nVer>g_nVersion) // Version is too new
|
||
return Acad::eMakeMeProxy;
|
||
|
||
Acad::ErrorStatus es=m_divider.dwgInFields(pFiler);
|
||
if(es!=Acad::eOk)
|
||
return es;
|
||
Adesk::UInt8 nTemp;
|
||
pFiler->readItem(&nTemp);
|
||
m_nHeightFlag=(TRowHeightStyle)nTemp;
|
||
pFiler->readItem(&m_nHeight);
|
||
pFiler->readItem(&nTemp);
|
||
m_nVerMode=(AcDb::TextVertMode)nTemp;
|
||
return pFiler->filerStatus();
|
||
}
|
||
|
||
Acad::ErrorStatus TSheetRow::dwgOutFields(AcDbDwgFiler* pFiler) const
|
||
{
|
||
pFiler->writeItem(g_nVersion);
|
||
|
||
VERIFY(m_divider.dwgOutFields(pFiler)==Acad::eOk);
|
||
pFiler->writeItem((Adesk::UInt8)m_nHeightFlag);
|
||
pFiler->writeItem(m_nHeight);
|
||
pFiler->writeItem((Adesk::UInt8)m_nVerMode);
|
||
return pFiler->filerStatus();
|
||
}
|
||
|
||
AcDb::TextVertMode
|
||
TSheetRow::GetVerMode() const
|
||
{
|
||
return m_nVerMode;
|
||
}
|
||
|
||
void
|
||
TSheetRow::SetVerMode(AcDb::TextVertMode nVerMode)
|
||
{
|
||
m_nVerMode=nVerMode;
|
||
}
|
||
|
||
|
||
///////////////////////////////////
|
||
// 单元格的定义
|
||
//TArch6:1,TArch7:2
|
||
const Adesk::UInt8 TGridCell::g_nVersion=2;
|
||
TGridCell::TGridCell()
|
||
{
|
||
//m_gridStyle.m_nOverride=0;
|
||
m_pRange=NULL;
|
||
//m_sText;
|
||
}
|
||
|
||
TGridCell::TGridCell(const TGridCell &src)
|
||
{
|
||
*this = src;
|
||
}
|
||
|
||
TGridCell &
|
||
TGridCell::operator = (const TGridCell &src)
|
||
{
|
||
CopyObject(src.m_gridStyle, m_gridStyle);
|
||
m_sText=src.m_sText;
|
||
m_idBlock=src.m_idBlock;
|
||
m_pRange=src.m_pRange;
|
||
return *this;
|
||
}
|
||
|
||
Acad::ErrorStatus TGridCell::dwgInFields (AcDbDwgFiler* pFiler, const DList<TGridRange> *ranges)
|
||
{
|
||
Adesk::UInt8 nVer=0;
|
||
pFiler->readItem(&nVer);
|
||
if(nVer>g_nVersion) // Version is too new
|
||
return Acad::eMakeMeProxy;
|
||
|
||
Adesk::UInt16 nRange=0;
|
||
pFiler->readItem(&nRange);
|
||
if(nRange==0 || !ranges)
|
||
{
|
||
m_pRange=NULL;
|
||
Acad::ErrorStatus es=m_gridStyle.dwgInFields(pFiler);
|
||
if(es!=Acad::eOk)
|
||
return es;
|
||
ReadString(pFiler, m_sText);
|
||
}
|
||
else
|
||
{
|
||
DList<TGridRange> *pRangeList=(DList<TGridRange> *)ranges;
|
||
m_pRange=(*pRangeList)[nRange-1];
|
||
}
|
||
|
||
if(nVer>1)
|
||
pFiler->readItem(&m_idBlock);
|
||
|
||
return pFiler->filerStatus();
|
||
}
|
||
|
||
Acad::ErrorStatus TGridCell::dwgOutFields(AcDbDwgFiler* pFiler, const DList<TGridRange> *ranges) const
|
||
{
|
||
if(g_nSaveTArchVer<7)
|
||
pFiler->writeItem((Adesk::UInt8)1);
|
||
else
|
||
pFiler->writeItem(g_nVersion);
|
||
|
||
Adesk::UInt16 nRange=0;
|
||
if(m_pRange && ranges) {
|
||
DList<TGridRange> *pRangeList=(DList<TGridRange> *)ranges;
|
||
if(pRangeList->FindNode(m_pRange, CompareRange)) {
|
||
nRange = pRangeList->CurPosition()+1;
|
||
}
|
||
}
|
||
pFiler->writeItem(nRange);
|
||
if(nRange==0) {
|
||
VERIFY(m_gridStyle.dwgOutFields(pFiler)==Acad::eOk);
|
||
pFiler->writeString(m_sText);
|
||
}
|
||
|
||
if(g_nSaveTArchVer>6)
|
||
pFiler->writeItem(m_idBlock);
|
||
|
||
return pFiler->filerStatus();
|
||
}
|
||
|
||
BOOL TGridCell::IsRange() const
|
||
{
|
||
return (m_pRange!=NULL);
|
||
}
|
||
|
||
|
||
const TGridStyle &
|
||
TGridCell::GetGridStyle() const
|
||
{
|
||
if(m_pRange)
|
||
return m_pRange->GetGridStyle();
|
||
return m_gridStyle;
|
||
}
|
||
|
||
TGridStyle &
|
||
TGridCell::GetGridStyle()
|
||
{
|
||
if(m_pRange)
|
||
return m_pRange->GetGridStyle();
|
||
return m_gridStyle;
|
||
}
|
||
|
||
const TCHAR *TGridCell::GetText() const
|
||
{
|
||
if(m_pRange)
|
||
return m_pRange->GetText();
|
||
return (const TCHAR *)m_sText;
|
||
}
|
||
|
||
void TGridCell::SetText(const TCHAR *szText)
|
||
{
|
||
if(m_pRange)
|
||
m_pRange->SetText(szText);
|
||
m_sText=szText;
|
||
|
||
TCellBlockInsert insert;
|
||
if(insert.ParserDesc(m_sText))
|
||
m_idBlock=InitBlock(insert.m_sBlockName);
|
||
else
|
||
m_idBlock=AcDbObjectId::kNull;
|
||
}
|
||
|
||
const TGridRange *
|
||
TGridCell::GetRange() const
|
||
{
|
||
return m_pRange;
|
||
}
|
||
|
||
void TGridCell::SetGridStyle(const TGridStyle &style)
|
||
{
|
||
if(m_pRange)
|
||
m_pRange->SetGridStyle(style);
|
||
CopyObject(style, m_gridStyle);
|
||
}
|
||
|
||
void TGridCell::SetRange(TGridRange *pRange)
|
||
{
|
||
m_pRange=pRange;
|
||
}
|
||
|
||
|
||
|
||
///////////////////////////////////
|
||
// 合并单元格的定义
|
||
// Modify on 2003/6/24,8位整数上升到16位整数
|
||
const Adesk::UInt8 TGridRange::g_nVersion=2;
|
||
TGridRange::TGridRange()
|
||
{
|
||
//m_gridStyle.m_nOverride=0;
|
||
m_nRow = m_nColumn = -1;
|
||
m_nRowMax = m_nColumnMax = -1;
|
||
//m_sText;
|
||
}
|
||
|
||
TGridRange::TGridRange(const TGridRange &src)
|
||
{
|
||
*this = src;
|
||
}
|
||
|
||
TGridRange &
|
||
TGridRange::operator = (const TGridRange &src)
|
||
{
|
||
CopyObject(src, *this);
|
||
SetRange((TGridRange *)src.GetRange());
|
||
return *this;
|
||
}
|
||
|
||
BOOL TGridRange::IsValid() const
|
||
{
|
||
BOOL bRet=(m_nRow>=0 && m_nColumn>=0);
|
||
bRet = (bRet && (m_nRowMax>=m_nRow && m_nColumnMax>=m_nColumn));
|
||
return bRet;
|
||
}
|
||
|
||
BOOL TGridRange::IsCellar() const
|
||
{
|
||
return (m_nRow==m_nRowMax && m_nColumn==m_nColumnMax);
|
||
}
|
||
|
||
Acad::ErrorStatus TGridRange::dwgInFields (AcDbDwgFiler* pFiler)
|
||
{
|
||
Acad::ErrorStatus es=TGridCell::dwgInFields(pFiler);
|
||
if(es!=Acad::eOk)
|
||
return es;
|
||
Adesk::UInt8 nVer=0;
|
||
pFiler->readItem(&nVer);
|
||
if(nVer>g_nVersion) // Version is too new
|
||
return Acad::eMakeMeProxy;
|
||
|
||
//Acad::ErrorStatus es=m_gridStyle.dwgInFields(pFiler);
|
||
//if(es!=Acad::eOk)
|
||
// return es;
|
||
//ReadString(pFiler, m_sText);
|
||
if(nVer<2) {
|
||
Adesk::UInt8 a1=0, a2=0, a3=0, a4=0;
|
||
pFiler->readItem(&a1);
|
||
pFiler->readItem(&a2);
|
||
pFiler->readItem(&a3);
|
||
pFiler->readItem(&a4);
|
||
m_nRow=a1;
|
||
m_nColumn=a2;
|
||
m_nRowMax=a3;
|
||
m_nColumnMax=a4;
|
||
} else {
|
||
pFiler->readItem(&m_nRow);
|
||
pFiler->readItem(&m_nColumn);
|
||
pFiler->readItem(&m_nRowMax);
|
||
pFiler->readItem(&m_nColumnMax);
|
||
}
|
||
return pFiler->filerStatus();
|
||
}
|
||
|
||
Acad::ErrorStatus TGridRange::dwgOutFields(AcDbDwgFiler* pFiler) const
|
||
{
|
||
VERIFY(TGridCell::dwgOutFields(pFiler)==Acad::eOk);
|
||
|
||
//VERIFY(m_gridStyle.dwgOutFields(pFiler)==Acad::eOk);
|
||
//pFiler->writeString(m_sText);
|
||
if(g_nSaveTArchVer==5) {
|
||
ASSERT(m_nRowMax<=256 && m_nColumnMax<=256);
|
||
pFiler->writeItem((Adesk::UInt8)1);
|
||
pFiler->writeItem((Adesk::UInt8)m_nRow);
|
||
pFiler->writeItem((Adesk::UInt8)m_nColumn);
|
||
pFiler->writeItem((Adesk::UInt8)m_nRowMax);
|
||
pFiler->writeItem((Adesk::UInt8)m_nColumnMax);
|
||
} else {
|
||
pFiler->writeItem(g_nVersion);
|
||
pFiler->writeItem(m_nRow);
|
||
pFiler->writeItem(m_nColumn);
|
||
pFiler->writeItem(m_nRowMax);
|
||
pFiler->writeItem(m_nColumnMax);
|
||
}
|
||
return pFiler->filerStatus();
|
||
}
|
||
|
||
/*
|
||
const TCHAR *TGridRange::GetText() const
|
||
{
|
||
return (const TCHAR *)m_sText;
|
||
}
|
||
*/
|
||
int TGridRange::GetCoord(BOOL bIsRow) const
|
||
{
|
||
return (bIsRow? m_nRow : m_nColumn);
|
||
}
|
||
|
||
int TGridRange::GetCoordMax(BOOL bIsRow) const
|
||
{
|
||
return (bIsRow? m_nRowMax : m_nColumnMax);
|
||
}
|
||
/*
|
||
void TGridRange::SetText(const TCHAR *szText)
|
||
{
|
||
m_sText=szText;
|
||
}
|
||
*/
|
||
void TGridRange::SetCoord(int nRow, int nCol)
|
||
{
|
||
m_nRow=nRow;
|
||
m_nColumn=nCol;
|
||
}
|
||
|
||
void TGridRange::SetCoordMax(int nRow, int nCol)
|
||
{
|
||
m_nRowMax=nRow;
|
||
m_nColumnMax=nCol;
|
||
}
|
||
|
||
|
||
BOOL TGridRange::Include(int nRow, int nCol) const
|
||
{
|
||
BOOL bRet=(nRow>=m_nRow && nRow<=m_nRowMax &&
|
||
nCol>=m_nColumn && nCol<=m_nColumnMax);
|
||
return bRet;
|
||
}
|
||
|
||
////////////////////////////////////
|
||
// 标题的定义
|
||
const Adesk::UInt8 TSheetTitle::g_nVersion=1;
|
||
TSheetTitle::TSheetTitle()
|
||
{
|
||
//XString m_sText;
|
||
m_gridStyle.SetFlagBit(OF_HORMODE|OF_TEXTHEIGHT, TRUE);
|
||
m_gridStyle.SetHorMode(AcDb::kTextCenter);
|
||
SetVerMode(AcDb::kTextVertMid);
|
||
m_bVisibility=TRUE;
|
||
//m_gridStyle.m_nOverride=0;
|
||
}
|
||
|
||
TSheetTitle::TSheetTitle(const TSheetTitle &src)
|
||
{
|
||
*this = src;
|
||
}
|
||
|
||
TSheetTitle &
|
||
TSheetTitle::operator = (const TSheetTitle &src)
|
||
{
|
||
CopyObject(src, *this);
|
||
return *this;
|
||
}
|
||
|
||
BOOL TSheetTitle::IsVisible() const
|
||
{
|
||
return (m_bVisibility!=0);
|
||
}
|
||
|
||
void TSheetTitle::SetVisible(BOOL bTrue)
|
||
{
|
||
m_bVisibility=bTrue;
|
||
}
|
||
|
||
|
||
Acad::ErrorStatus TSheetTitle::dwgInFields (AcDbDwgFiler* pFiler)
|
||
{
|
||
Acad::ErrorStatus es=TSheetRow::dwgInFields(pFiler);
|
||
if(es!=Acad::eOk)
|
||
return es;
|
||
es=TGridCell::dwgInFields(pFiler);
|
||
if(es!=Acad::eOk)
|
||
return es;
|
||
|
||
Adesk::UInt8 nVer=0;
|
||
pFiler->readItem(&nVer);
|
||
if(nVer>g_nVersion) // Version is too new
|
||
return Acad::eMakeMeProxy;
|
||
|
||
//VERIFY(m_gridStyle.dwgInFields(pFiler)==Acad::eOk);
|
||
//ReadString(pFiler, m_sText);
|
||
pFiler->readItem(&m_bVisibility);
|
||
return pFiler->filerStatus();
|
||
}
|
||
|
||
Acad::ErrorStatus TSheetTitle::dwgOutFields(AcDbDwgFiler* pFiler) const
|
||
{
|
||
VERIFY(TSheetRow::dwgOutFields(pFiler)==Acad::eOk);
|
||
VERIFY(TGridCell::dwgOutFields(pFiler)==Acad::eOk);
|
||
|
||
pFiler->writeItem(g_nVersion);
|
||
|
||
//VERIFY(m_gridStyle.dwgOutFields(pFiler)==Acad::eOk);
|
||
//pFiler->writeString(m_sText);
|
||
pFiler->writeItem(m_bVisibility);
|
||
return pFiler->filerStatus();
|
||
}
|
||
|
||
/////////////////////////////////////////////////////////////
|
||
// 表格对象类
|
||
/////////////////////////////////////////////////////////////
|
||
// TArch5, T6Bet2:ver=2;T6B3:nVer=3, nVer=4
|
||
const Adesk::UInt8 TDbSheet::g_nVersion = 4;
|
||
|
||
|
||
ACRX_DXF_DEFINE_MEMBERS(ATSSheet, ATSEntity, AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
|
||
1, ATS_SHEET, "ATS_SHEET图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com");
|
||
|
||
IMPLEMENT_TENTBASE(TDbSheet);
|
||
|
||
|
||
TDbSheet::TDbSheet()
|
||
{
|
||
m_rowHeightStyle=TSheetRow::kFixed;
|
||
m_gridStyle.SetOverrideAll(TRUE); //标准方格样式
|
||
m_border.m_nFlag=TDividerStyle::kLocal; //表格外框的分割线样式
|
||
m_rowDivider.m_nFlag=TDividerStyle::kLocal; //表格内部分割线样式
|
||
m_colDivider.m_nFlag=TDividerStyle::kLocal;
|
||
|
||
//TSheetTitle m_title; //标题
|
||
//DList<TSheetColumn> m_columns; //列
|
||
//DList<TSheetRow> m_rows; //行
|
||
//DList<TGridCell> m_ranges; //单元格
|
||
m_pCells=NULL;
|
||
|
||
m_nRowHeight=0.0; //标准行高
|
||
//表格本身的定位方式, 左上, 右上, 左下, 右下, 中间
|
||
m_nAlignment=XExplodeDraw::kTopLeft;
|
||
//XPoint m_ptLocation; //定位点
|
||
m_nRotation=0.0;
|
||
}
|
||
|
||
|
||
TDbSheet::~TDbSheet()
|
||
{
|
||
if(m_pCells)
|
||
delete [] m_pCells;
|
||
}
|
||
|
||
|
||
|
||
void TDbSheet::InitSheet(int nRow, int nCol, double nRowHeight, double nColWidth)
|
||
{
|
||
ASSERT(nRow>0 && nCol>0);
|
||
if(m_pCells)
|
||
delete [] m_pCells;
|
||
|
||
m_pCells = new TGridCell[nRow*nCol];
|
||
m_columns.Reset();
|
||
m_rows.Reset();
|
||
m_ranges.Reset();
|
||
|
||
m_nRowHeight=nRowHeight;
|
||
|
||
for(int i=0; i<nCol; i++) {
|
||
TSheetColumn *pCol=new TSheetColumn;
|
||
pCol->SetWidth(nColWidth);
|
||
pCol->SetGridStyle(m_gridStyle);
|
||
//pCol->SetDividerStyle(m_colDivider);
|
||
m_columns.Append(pCol);
|
||
}
|
||
for(i=0; i<nRow; i++) {
|
||
TSheetRow *pRow=new TSheetRow;
|
||
pRow->SetHeight(nRowHeight);
|
||
pRow->SetVerMode(m_gridStyle.GetVerMode());
|
||
//pRow->SetDividerStyle(m_rowDivider);
|
||
m_rows.Append(pRow);
|
||
}
|
||
}
|
||
|
||
BOOL TDbSheet::IsValid() const
|
||
{
|
||
BOOL bRet=TDbEntity::IsValid();
|
||
if(!bRet)
|
||
return bRet;
|
||
bRet=(m_nRowHeight>0.0 && m_rows.Length() && m_columns.Length());
|
||
return bRet;
|
||
}
|
||
|
||
// 提供对格式刷的支持
|
||
void TDbSheet::CopyPropertiesFrom(AcDbEntity *pSrcEntity, unsigned gMatchFlag)
|
||
{
|
||
assertWriteEnabled();
|
||
TDbEntity::CopyPropertiesFrom(pSrcEntity, gMatchFlag);
|
||
TDbSheet *pSrc=TDbSheet::cast(pSrcEntity);
|
||
if(pSrc) {
|
||
m_gridStyle=pSrc->m_gridStyle; //标准方格样式
|
||
m_border=pSrc->m_border; //表格外框的分割线样式
|
||
m_rowDivider=pSrc->m_rowDivider; //行分割线样式
|
||
m_colDivider=pSrc->m_colDivider; //列分割线样式
|
||
|
||
m_nRowHeight=pSrc->m_nRowHeight; //标准行高
|
||
//表格本身的定位方式, 左上, 右上, 左下, 右下, 中间
|
||
m_nAlignment=pSrc->m_nAlignment;
|
||
|
||
// TArch6
|
||
m_rowHeightStyle=pSrc->m_rowHeightStyle;
|
||
}
|
||
}
|
||
|
||
|
||
Acad::ErrorStatus
|
||
TDbSheet::DownGradeSave(int nDrawMode, AcDbVoidPtrArray &entSet, BOOL *bErase)
|
||
{
|
||
//add by whl on 060223
|
||
if(g_nSaveTArchVer<7)//7.0开始才有圆圈文字
|
||
{
|
||
BOOL bHasCircle=FALSE;
|
||
long num=GetSubTextNum();
|
||
for(long i=0;i<num;i++)
|
||
{
|
||
TSubText* pSubText=GetSubText(i);
|
||
if(pSubText!=NULL)
|
||
{
|
||
CString sText=pSubText->GetText();
|
||
delete pSubText;
|
||
|
||
if(sText.Find(_T("^C"))!=-1)
|
||
{
|
||
bHasCircle=TRUE;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
if(bHasCircle)
|
||
{
|
||
Acad::ErrorStatus es=Acad::eOk;
|
||
XPushMemVar<BOOL> vTemp(XExplodeStream::m_bFullExplode, TRUE);//完全分解
|
||
|
||
XExplodeStream dc(entSet);
|
||
if(!OnExplodeOrDraw(dc))
|
||
return es;
|
||
|
||
dc.SetPropertiesFrom(this);
|
||
if(nDrawMode==DRAW_2D)
|
||
es=ExplodeOrDraw2d(dc);
|
||
else
|
||
es=ExplodeOrDraw3d(dc);
|
||
if(bErase)
|
||
*bErase=TRUE;
|
||
|
||
return es;
|
||
}
|
||
}
|
||
|
||
if(g_nSaveTArchVer==5)
|
||
{
|
||
if(GetRowNum()>256 || GetColumnNum()>256)
|
||
{
|
||
XExplodeStream dc(entSet);
|
||
if(!OnExplodeOrDraw(dc))
|
||
return Acad::eOk;
|
||
|
||
dc.SetPropertiesFrom(this);//add by whl on 060404
|
||
Acad::ErrorStatus es=ExplodeOrDraw2d(dc);
|
||
if(bErase) *bErase=TRUE;
|
||
return es;
|
||
}
|
||
}
|
||
|
||
return TDbEntity::DownGradeSave(nDrawMode,entSet,bErase);
|
||
}
|
||
|
||
|
||
Acad::ErrorStatus
|
||
TDbSheet::subGetClassID(CLSID* pClsid) const
|
||
{
|
||
return Acad::eOk;
|
||
}
|
||
|
||
// 从DWG读入数据:
|
||
Acad::ErrorStatus TDbSheet::dwgInFields (AcDbDwgFiler* pFiler)
|
||
{
|
||
assertWriteEnabled();
|
||
|
||
Acad::ErrorStatus es = TDbEntity::dwgInFields(pFiler);
|
||
if(es != Acad::eOk) return es;
|
||
Adesk::UInt8 nVer;
|
||
pFiler->readItem(&nVer);
|
||
if(nVer>g_nVersion) {// Version is too new
|
||
return Acad::eMakeMeProxy;
|
||
}
|
||
|
||
es=m_gridStyle.dwgInFields(pFiler);
|
||
if(es!=Acad::eOk) return es;
|
||
es=m_border.dwgInFields(pFiler);
|
||
if(es!=Acad::eOk) return es;
|
||
es=m_rowDivider.dwgInFields(pFiler);
|
||
if(es!=Acad::eOk) return es;
|
||
if(nVer>1) {
|
||
es=m_colDivider.dwgInFields(pFiler);
|
||
if(es!=Acad::eOk) return es;
|
||
}
|
||
es=m_title.dwgInFields(pFiler);
|
||
if(es!=Acad::eOk) return es;
|
||
|
||
Adesk::UInt16 nColNum=0;
|
||
m_columns.Reset();
|
||
if(nVer>2) {
|
||
pFiler->readItem(&nColNum);
|
||
} else {
|
||
Adesk::UInt8 nTemp=0;
|
||
pFiler->readItem(&nTemp);
|
||
nColNum=nTemp;
|
||
}
|
||
for(Adesk::UInt16 iCol=0; iCol<nColNum; iCol++) {
|
||
TSheetColumn *pCol=new TSheetColumn;
|
||
es=pCol->dwgInFields(pFiler);
|
||
if(es!=Acad::eOk) {
|
||
delete pCol;
|
||
return es;
|
||
}
|
||
m_columns.Append(pCol);
|
||
}
|
||
|
||
m_rows.Reset();
|
||
Adesk::UInt16 nRowNum=0;
|
||
if(nVer>2) {
|
||
pFiler->readItem(&nRowNum);
|
||
} else {
|
||
Adesk::UInt8 nTemp=0;
|
||
pFiler->readItem(&nTemp);
|
||
nRowNum = nTemp;
|
||
}
|
||
for(Adesk::UInt16 iRow=0; iRow<nRowNum; iRow++) {
|
||
TSheetRow *pRow=new TSheetRow;
|
||
es=pRow->dwgInFields(pFiler);
|
||
if(es!=Acad::eOk) {
|
||
delete pRow;
|
||
return es;
|
||
}
|
||
m_rows.Append(pRow);
|
||
}
|
||
|
||
// 合并格
|
||
m_ranges.Reset();
|
||
Adesk::UInt16 nRangeNum;
|
||
pFiler->readItem(&nRangeNum);
|
||
for(Adesk::UInt16 iRange=0; iRange<nRangeNum; iRange++) {
|
||
TGridRange *pRange=new TGridRange;
|
||
es=pRange->dwgInFields(pFiler);
|
||
if(es!=Acad::eOk) {
|
||
delete pRange;
|
||
return es;
|
||
}
|
||
m_ranges.Append(pRange);
|
||
}
|
||
|
||
|
||
//单元格
|
||
if(m_pCells)
|
||
delete [] m_pCells;
|
||
ASSERT(nRowNum>0 && nColNum>0);
|
||
Adesk::UInt16 nCellNum=nRowNum*nColNum;
|
||
m_pCells=new TGridCell[nCellNum];
|
||
for(Adesk::UInt16 iCell=0; iCell<nCellNum; iCell++) {
|
||
es=m_pCells[iCell].dwgInFields(pFiler, &m_ranges);
|
||
if(es!=Acad::eOk)
|
||
return es;
|
||
}
|
||
|
||
|
||
pFiler->readItem(&m_nRowHeight);
|
||
Adesk::UInt8 nAlign;
|
||
pFiler->readItem(&nAlign);
|
||
m_nAlignment=(XExplodeDraw::TextAlignment)nAlign;
|
||
|
||
pFiler->readItem((AcGePoint3d *)&m_ptLocation);
|
||
m_ptLocation.z=0;
|
||
pFiler->readItem(&m_nRotation);
|
||
|
||
if(nVer>=4) {
|
||
Adesk::UInt8 nTemp;
|
||
pFiler->readItem(&nTemp);
|
||
m_rowHeightStyle=(TSheetRow::TRowHeightStyle)nTemp;
|
||
}
|
||
return pFiler->filerStatus();
|
||
}
|
||
|
||
Acad::ErrorStatus TDbSheet::dwgOutFields(AcDbDwgFiler* pFiler) const
|
||
{
|
||
assertReadEnabled();
|
||
Acad::ErrorStatus es = TDbEntity::dwgOutFields(pFiler);
|
||
if(es != Acad::eOk) return es;
|
||
|
||
if(g_nSaveTArchVer==5)
|
||
pFiler->writeItem((Adesk::UInt8)2);
|
||
else
|
||
pFiler->writeItem(g_nVersion);
|
||
|
||
VERIFY(m_gridStyle.dwgOutFields(pFiler)==Acad::eOk);
|
||
VERIFY(m_border.dwgOutFields(pFiler)==Acad::eOk);
|
||
VERIFY(m_rowDivider.dwgOutFields(pFiler)==Acad::eOk);
|
||
VERIFY(m_colDivider.dwgOutFields(pFiler)==Acad::eOk);
|
||
VERIFY(m_title.dwgOutFields(pFiler)==Acad::eOk);
|
||
|
||
Adesk::UInt16 nColNum=m_columns.Length();
|
||
if(g_nSaveTArchVer==5) {
|
||
ASSERT(nColNum<=256);
|
||
pFiler->writeItem((Adesk::UInt8)nColNum);
|
||
} else
|
||
pFiler->writeItem(nColNum);
|
||
for(Adesk::UInt16 iCol=0; iCol<nColNum; iCol++) {
|
||
VERIFY(m_columns[iCol].dwgOutFields(pFiler)==Acad::eOk);
|
||
}
|
||
|
||
Adesk::UInt16 nRowNum=m_rows.Length();
|
||
if(g_nSaveTArchVer==5) {
|
||
ASSERT(nRowNum<=256);
|
||
pFiler->writeItem((Adesk::UInt8)nRowNum);
|
||
} else
|
||
pFiler->writeItem(nRowNum);
|
||
for(Adesk::UInt16 iRow=0; iRow<nRowNum; iRow++) {
|
||
VERIFY(m_rows[iRow].dwgOutFields(pFiler)==Acad::eOk);
|
||
}
|
||
|
||
Adesk::UInt16 nRangeNum=m_ranges.Length();
|
||
pFiler->writeItem(nRangeNum);
|
||
for(Adesk::UInt16 iRange=0; iRange<nRangeNum; iRange++) {
|
||
VERIFY(m_ranges[iRange].dwgOutFields(pFiler)==Acad::eOk);
|
||
}
|
||
|
||
Adesk::UInt16 nCellNum=nRowNum*nColNum;
|
||
for(Adesk::UInt16 iCell=0; iCell<nCellNum; iCell++) {
|
||
VERIFY(m_pCells[iCell].dwgOutFields(pFiler, &m_ranges)==Acad::eOk);
|
||
}
|
||
|
||
|
||
pFiler->writeItem(m_nRowHeight);
|
||
pFiler->writeItem((Adesk::UInt8)m_nAlignment);
|
||
|
||
pFiler->writeItem((const AcGePoint3d &)m_ptLocation);
|
||
pFiler->writeItem(m_nRotation);
|
||
if(g_nSaveTArchVer!=5) {
|
||
pFiler->writeItem((Adesk::UInt8)m_rowHeightStyle);
|
||
}
|
||
return pFiler->filerStatus();
|
||
}
|
||
|
||
Acad::ErrorStatus TDbSheet::dxfInFields (AcDbDxfFiler* pFiler)
|
||
{
|
||
assertWriteEnabled();
|
||
|
||
Acad::ErrorStatus es = TDbEntity::dxfInFields(pFiler);
|
||
if(es!=Acad::eOk)
|
||
return es;
|
||
|
||
if (!pFiler->atSubclassData(_T("TDbSheet"))) {
|
||
return Acad::eBadDxfSequence;
|
||
}
|
||
|
||
pFiler->writePoint2d(AcDb::kDxfXCoord, m_ptLocation.AsAcGePoint2d());
|
||
pFiler->writeString(AcDb::kDxfText, (const TCHAR *)GetTitleText());
|
||
pFiler->writeDouble(AcDb::kDxfReal, m_nRowHeight);
|
||
pFiler->writeDouble(AcDb::kDxfAngle, m_nRotation);
|
||
pFiler->writeInt16(AcDb::kDxfInt16, (Adesk::Int16)GetRowNum());
|
||
pFiler->writeInt16(AcDb::kDxfInt16+1, (Adesk::Int16)GetColumnNum());
|
||
pFiler->writeInt16(AcDb::kDxfInt16+2, (Adesk::Int16)m_nAlignment);
|
||
|
||
int fieldsFlags=0;
|
||
XPoint pt;
|
||
XString sText;
|
||
double nHeight, nRot;
|
||
int nAlign;
|
||
resbuf rb;
|
||
while ((es == Acad::eOk)
|
||
&& ((es = pFiler->readResBuf(&rb)) == Acad::eOk)) {
|
||
switch (rb.restype) {
|
||
case AcDb::kDxfXCoord:
|
||
pt=rb.resval.rpoint;
|
||
fieldsFlags |= 0x01;
|
||
break;
|
||
case AcDb::kDxfText:
|
||
sText=rb.resval.rstring;
|
||
fieldsFlags |= 0x02;
|
||
break;
|
||
case AcDb::kDxfReal:
|
||
nHeight=rb.resval.rreal;
|
||
fieldsFlags |= 0x04;
|
||
break;
|
||
case AcDb::kDxfAngle:
|
||
nRot=rb.resval.rreal;
|
||
fieldsFlags |= 0x08;
|
||
break;
|
||
case AcDb::kDxfInt16:
|
||
fieldsFlags |= 0x10;
|
||
break;
|
||
case AcDb::kDxfInt16+1:
|
||
fieldsFlags |= 0x20;
|
||
break;
|
||
case AcDb::kDxfInt16+2:
|
||
fieldsFlags |= 0x40;
|
||
nAlign = rb.resval.rint;
|
||
break;
|
||
//fall through intentional
|
||
default:
|
||
// An unrecognized group. Push it back so that
|
||
// the subclass can read it again.
|
||
pFiler->pushBackItem();
|
||
es = Acad::eEndOfFile;
|
||
break;
|
||
}
|
||
}
|
||
if (es != Acad::eEndOfFile)
|
||
return Acad::eInvalidResBuf;
|
||
if(fieldsFlags&0x01)
|
||
m_ptLocation=pt;
|
||
if(fieldsFlags&0x02)
|
||
SetTitleText(sText);
|
||
if(fieldsFlags&0x04)
|
||
m_nRowHeight=nHeight;
|
||
if(fieldsFlags&0x08)
|
||
m_nRotation=nRot;
|
||
if(fieldsFlags&0x40)
|
||
m_nAlignment=(XExplodeDraw::TextAlignment)nAlign;
|
||
|
||
return pFiler->filerStatus();
|
||
}
|
||
|
||
Acad::ErrorStatus TDbSheet::dxfOutFields(AcDbDxfFiler* pFiler) const
|
||
{
|
||
assertReadEnabled();
|
||
Acad::ErrorStatus es=TDbEntity::dxfOutFields(pFiler);
|
||
assert(es == Acad::eOk);
|
||
|
||
es = pFiler->writeItem(AcDb::kDxfSubclass,_T("TDbSheet"));
|
||
assert(es == Acad::eOk);
|
||
pFiler->writePoint2d(AcDb::kDxfXCoord, m_ptLocation.AsAcGePoint2d());
|
||
pFiler->writeString(AcDb::kDxfText, (const TCHAR *)GetTitleText());
|
||
pFiler->writeDouble(AcDb::kDxfReal, m_nRowHeight);
|
||
pFiler->writeDouble(AcDb::kDxfAngle, m_nRotation);
|
||
pFiler->writeInt16(AcDb::kDxfInt16, (Adesk::Int16)GetRowNum());
|
||
pFiler->writeInt16(AcDb::kDxfInt16+1, (Adesk::Int16)GetColumnNum());
|
||
pFiler->writeInt16(AcDb::kDxfInt16+2, (Adesk::Int16)m_nAlignment);
|
||
|
||
return es;
|
||
}
|
||
|
||
|
||
|
||
// -----------------------------------------------------------------------
|
||
|
||
|
||
// Overriden functions for edit
|
||
// to do:
|
||
// 允许通过夹点改变边界
|
||
Acad::ErrorStatus TDbSheet::subGetGripPoints(AcGePoint3dArray& gripPoints,
|
||
AcDbIntArray& osnapModes,
|
||
AcDbIntArray& geomIds) const
|
||
{
|
||
assertReadEnabled();
|
||
gripPoints.append(m_ptLocation); //0
|
||
XPoint ptTopLeft=GetTopLeft(FALSE);
|
||
XPoint ext=GetExtents(FALSE, FALSE);
|
||
XPoint ptBotRight;
|
||
double nRotWcs=Layout2Wcs(m_nRotation);
|
||
ads_polar(ptTopLeft, nRotWcs-PI/2, ext.y, ptBotRight);
|
||
ads_polar(XPoint(ptBotRight), nRotWcs, ext.x, ptBotRight);
|
||
gripPoints.append(ptBotRight); //1
|
||
|
||
int nColNum=GetColumnNum();
|
||
for(int iCol=0; iCol<nColNum; iCol++) {
|
||
const TSheetColumn &column=m_columns[iCol];
|
||
if(column.AllowSizing()) {
|
||
double nWidth=GetColumnsWidth(0, iCol, FALSE);
|
||
XPoint pt;
|
||
ads_polar(ptTopLeft, nRotWcs, nWidth, pt);
|
||
gripPoints.append(pt);
|
||
}
|
||
}
|
||
int nRowNum=GetRowNum();
|
||
for(int iRow=0; iRow<nRowNum; iRow++) {
|
||
const TSheetRow &row=m_rows[iRow];
|
||
if(row.GetRowHeightStyle()==TSheetRow::kFree ||
|
||
row.GetRowHeightStyle()==TSheetRow::kAtLeast ||
|
||
(row.GetRowHeightStyle()==TSheetRow::kParent &&
|
||
(m_rowHeightStyle==TSheetRow::kFree || m_rowHeightStyle==TSheetRow::kAtLeast))
|
||
) {
|
||
double nHeight=GetRowsHeight(0, iRow, FALSE);
|
||
XPoint pt;
|
||
ads_polar(ptTopLeft, nRotWcs-PI/2, nHeight, pt);
|
||
gripPoints.append(pt);
|
||
}
|
||
}
|
||
return Acad::eOk;
|
||
}
|
||
|
||
// stretch points is diffrent from grep points, with no midpoint included
|
||
Acad::ErrorStatus TDbSheet::subGetStretchPoints(AcGePoint3dArray & stretchPoints) const
|
||
{
|
||
assertReadEnabled();
|
||
AcDbIntArray osnapModes;
|
||
AcDbIntArray geomIds;
|
||
return subGetGripPoints(stretchPoints, osnapModes, geomIds);
|
||
}
|
||
|
||
|
||
|
||
// Active when being rotated, scaled, moved, etc.
|
||
// Scale is disabled here
|
||
Acad::ErrorStatus TDbSheet::subTransformBy(const AcGeMatrix3d& xform)
|
||
{
|
||
assertWriteEnabled();
|
||
TDbEntity::subTransformBy(xform);
|
||
ads_matrix mat;
|
||
AsAdsMatrix(xform, mat);
|
||
if(!g_bLayoutRotate) {
|
||
AcGeVector3d vt(cos(m_nRotation), sin(m_nRotation), 0.0);
|
||
vt.transformBy(xform);
|
||
m_nRotation=ads_angle(XPoint(), XPoint(vt[0], vt[1]));
|
||
}
|
||
m_ptLocation.TransformBy(mat);
|
||
|
||
return Acad::eOk;
|
||
}
|
||
|
||
|
||
|
||
// 功能: 夹点操作
|
||
Acad::ErrorStatus TDbSheet::subMoveGripPointsAt(
|
||
const AcDbIntArray& indices,
|
||
const AcGeVector3d& offset)
|
||
{
|
||
assertWriteEnabled();
|
||
XPoint vtOffset(offset[0], offset[1]);
|
||
if(indices.length()>1) {
|
||
m_ptLocation += vtOffset;
|
||
return Acad::eOk;
|
||
}
|
||
|
||
double nRotWcs=Layout2Wcs(m_nRotation);
|
||
int idx = indices[0];
|
||
if(idx==0) {
|
||
m_ptLocation += vtOffset;
|
||
} else if(idx==1) {
|
||
XVector3D vtRight(cos(nRotWcs), sin(nRotWcs));
|
||
XVector3D vtBot(cos(nRotWcs-PI/2), sin(nRotWcs-PI/2));
|
||
double nWidthInc=(vtRight&vtOffset);
|
||
double nHeightInc=(vtBot&vtOffset);
|
||
BOOL bIncTitle=m_title.IsVisible();
|
||
XPoint ptTopLeft=GetTopLeft(bIncTitle);
|
||
XPoint ext=GetExtents(bIncTitle, FALSE);
|
||
double xRatio = nWidthInc/ext.x + 1.0;
|
||
double yRatio = nHeightInc/ext.y + 1.0;
|
||
|
||
int nColNum=GetColumnNum();
|
||
for(int iCol=0; iCol<nColNum; iCol++) {
|
||
TSheetColumn &column=*m_columns[iCol];
|
||
column.m_nWidth *= xRatio;
|
||
column.m_gridStyle.m_nTextHeight *= yRatio;
|
||
}
|
||
m_gridStyle.m_nTextHeight *= yRatio;
|
||
int nRowNum=GetRowNum();
|
||
for(int iRow=0; iRow<nRowNum; iRow++) {
|
||
TSheetRow &row=*m_rows[iRow];
|
||
row.m_nHeight *= yRatio;
|
||
for(iCol=0; iCol<nColNum; iCol++) {
|
||
TGridCell *pCell=(*this)(iRow, iCol);
|
||
//TGridStyle gridStyle;
|
||
//CopyObject(pCell->GetGridStyle(), gridStyle);
|
||
pCell->m_gridStyle.m_nTextHeight *= yRatio;
|
||
//pCell->SetGridStyle(gridStyle);
|
||
}
|
||
}
|
||
for(int n=0; n<m_ranges.Length(); n++)
|
||
m_ranges[n]->m_gridStyle.m_nTextHeight *= yRatio;
|
||
m_nRowHeight *= yRatio;
|
||
m_title.m_nHeight *= yRatio;
|
||
m_title.m_gridStyle.m_nTextHeight *= yRatio;
|
||
} else {
|
||
XVector3D vt(cos(nRotWcs), sin(nRotWcs));
|
||
double nWidth = (vt&vtOffset);
|
||
int nColNum=GetColumnNum();
|
||
int iVert=1;
|
||
for(int iCol=0; iCol<nColNum; iCol++) {
|
||
TSheetColumn &column=*m_columns[iCol];
|
||
if(column.AllowSizing()) {
|
||
iVert++;
|
||
if(idx==iVert) {
|
||
if(column.GetWidth()*GetPScale()+nWidth<_DIST_SNAP) { //Delete column
|
||
RemoveColumn(iCol);
|
||
} else {
|
||
column.SetWidth(column.GetWidth()+nWidth/GetPScale());
|
||
CalculateRowHeight(0, GetRowNum()-1);
|
||
}
|
||
return Acad::eOk;
|
||
}
|
||
}
|
||
}
|
||
|
||
XVector3D vt1(cos(nRotWcs-PI/2), sin(nRotWcs-PI/2));
|
||
double nHeight = (vt1&vtOffset);
|
||
int nRowNum=GetRowNum();
|
||
for(int iRow=0; iRow<nRowNum; iRow++) {
|
||
TSheetRow &row=*m_rows[iRow];
|
||
if(row.GetRowHeightStyle()==TSheetRow::kFree ||
|
||
row.GetRowHeightStyle()==TSheetRow::kAtLeast ||
|
||
(row.GetRowHeightStyle()==TSheetRow::kParent &&
|
||
(m_rowHeightStyle==TSheetRow::kFree || m_rowHeightStyle==TSheetRow::kAtLeast))
|
||
) {
|
||
iVert++;
|
||
if(idx==iVert) {
|
||
if(row.GetHeight()*GetPScale()+nHeight<_DIST_SNAP)
|
||
RemoveRow(iRow);
|
||
else {
|
||
double h=row.GetHeight()+nHeight/GetPScale();
|
||
if(row.GetRowHeightStyle()==TSheetRow::kAtLeast ||
|
||
(row.GetRowHeightStyle()==TSheetRow::kParent &&
|
||
m_rowHeightStyle==TSheetRow::kAtLeast)
|
||
) {
|
||
if(h>GetRowHeight(TRUE))
|
||
row.SetHeight(h);
|
||
else
|
||
row.SetHeight(GetRowHeight(TRUE));
|
||
} else
|
||
row.SetHeight(h);
|
||
}
|
||
return Acad::eOk;
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
return Acad::eOk;
|
||
}
|
||
|
||
|
||
// 功能: 夹点操作
|
||
Acad::ErrorStatus TDbSheet::subMoveStretchPointsAt(
|
||
const AcDbIntArray& indices,
|
||
const AcGeVector3d& offset)
|
||
{
|
||
return subMoveGripPointsAt(indices, offset);
|
||
}
|
||
|
||
// 取得夹点说明
|
||
Acad::ErrorStatus TDbSheet::GetGripText(int i, CString &cs) const
|
||
{
|
||
Acad::ErrorStatus es=Acad::eOk;
|
||
if(i==0) {
|
||
cs=_T("移动表格");
|
||
} else if(i==1) {
|
||
cs=_T("角点缩放");
|
||
} else {
|
||
int nColNum=GetColumnNum();
|
||
int iVert=1;
|
||
for(int iCol=0; iCol<nColNum; iCol++) {
|
||
const TSheetColumn &column=m_columns[iCol];
|
||
if(column.AllowSizing()) {
|
||
iVert++;
|
||
if(i==iVert) {
|
||
cs.Format(_T("移动第%d列"), iCol+1);
|
||
return Acad::eOk;
|
||
}
|
||
}
|
||
}
|
||
|
||
int nRowNum=GetRowNum();
|
||
for(int iRow=0; iRow<nRowNum; iRow++) {
|
||
const TSheetRow &row=m_rows[iRow];
|
||
if(row.GetRowHeightStyle()==TSheetRow::kFree ||
|
||
row.GetRowHeightStyle()==TSheetRow::kAtLeast ||
|
||
(row.GetRowHeightStyle()==TSheetRow::kParent &&
|
||
(m_rowHeightStyle==TSheetRow::kFree || m_rowHeightStyle==TSheetRow::kAtLeast))
|
||
) {
|
||
iVert++;
|
||
if(i==iVert) {
|
||
cs.Format(_T("移动第%d行"), iRow+1);
|
||
if(row.GetRowHeightStyle()==TSheetRow::kFree ||
|
||
(row.GetRowHeightStyle()==TSheetRow::kParent &&
|
||
m_rowHeightStyle==TSheetRow::kFree)
|
||
)
|
||
cs += _T("(自由移动)");
|
||
else
|
||
cs += _T("(不小于表格行高)");
|
||
return Acad::eOk;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return es;
|
||
}
|
||
|
||
TEntityBase::DrawType
|
||
TDbSheet::GetDrawType() const
|
||
{
|
||
return TEntityBase::k2DOnly;
|
||
}
|
||
|
||
|
||
int TDbSheet::ConvertText(TConvertTextPtr ptr, void *pData)
|
||
{
|
||
assertWriteEnabled();
|
||
int nRow=GetRowNum();
|
||
int nCol=GetColumnNum();
|
||
int nCode=RTNONE;
|
||
XString sText;
|
||
nCode=ptr(m_title.m_sText, sText, pData);
|
||
if(nCode==RTNORM)
|
||
m_title.m_sText=sText;
|
||
for(int iRow=0; iRow<nRow; iRow++) {
|
||
for(int iCol=0; iCol<nCol; iCol++) {
|
||
TGridCell &cell=m_pCells[iRow*nCol+iCol];
|
||
int nRet=ptr(cell.m_sText, sText, pData);
|
||
if(nRet==RTERROR)
|
||
nCode=nRet;
|
||
else if(nRet==RTNORM)
|
||
cell.m_sText=sText;
|
||
}
|
||
}
|
||
for(int i=0; i<m_ranges.Length(); i++) {
|
||
TGridRange *cell=m_ranges[i];
|
||
int nRet=ptr(cell->m_sText, sText, pData);
|
||
if(nRet==RTERROR)
|
||
nCode=nRet;
|
||
else if(nRet==RTNORM)
|
||
cell->m_sText=sText;
|
||
}
|
||
return nCode;
|
||
}
|
||
|
||
|
||
// 返回发现的位置,同时posStart往前移动(以便继续找下一个使用),
|
||
TTextPosition
|
||
TDbSheet::FindSubText(const TCHAR *sSubText, TTextPosition &posStart, TTextRange *pRange) const
|
||
{
|
||
TTextPosition pos;
|
||
if(!sSubText || !sSubText[0])
|
||
return pos;
|
||
|
||
TTextPosition posNext=posStart;
|
||
while(1) {
|
||
if((int)posNext.m_nCookies>=(GetRowNum()*GetColumnNum()+m_ranges.Length()+1))
|
||
break;
|
||
|
||
TDbText *pText=GetText(posNext.m_nCookies);
|
||
TTextPosition posFind;
|
||
if(pText) {
|
||
posFind=pText->FindSubText(sSubText, posNext, pRange);
|
||
delete pText;
|
||
}
|
||
if(!posFind) {
|
||
posNext.m_nCookies++;
|
||
posNext.m_nTextPos=0;
|
||
} else {
|
||
posStart=posNext;
|
||
if(!posStart) {
|
||
posStart.m_nCookies++;
|
||
posStart.m_nTextPos=0;
|
||
}
|
||
posFind.m_nCookies=posNext.m_nCookies;
|
||
pos=posFind;
|
||
break;
|
||
}
|
||
}
|
||
return pos;
|
||
}
|
||
|
||
// 返回下一次查找的开始位置
|
||
TTextPosition
|
||
TDbSheet::ReplaceSubText(const TTextPosition &posRep, const TCHAR *sRepText, TTextRange *pRange)
|
||
{
|
||
assertWriteEnabled();
|
||
TTextPosition posNext;
|
||
TDbText *pText=GetText(posRep.m_nCookies);
|
||
if(!pText)
|
||
return posNext;
|
||
posNext=pText->ReplaceSubText(posRep, sRepText, pRange);
|
||
|
||
int cookies=posRep.m_nCookies;
|
||
if(cookies==0) {
|
||
SetTitleText(pText->GetText());
|
||
} else {
|
||
cookies--;
|
||
int nRowNum=GetRowNum();
|
||
int nColNum=GetColumnNum();
|
||
if(cookies<nRowNum*nColNum) {
|
||
int nRow=cookies/nColNum;
|
||
int nCol=cookies-nRow*nColNum;
|
||
TGridCell *cell=(*this)(nRow, nCol);
|
||
cell->SetText(pText->GetText());
|
||
} else {
|
||
cookies -= nRowNum*nColNum;
|
||
if(cookies<m_ranges.Length())
|
||
m_ranges[cookies]->SetText(pText->GetText());
|
||
}
|
||
}
|
||
delete pText;
|
||
if(!posNext) {
|
||
posNext.m_nCookies=posRep.m_nCookies+1;
|
||
posNext.m_nTextPos=0;
|
||
}
|
||
return posNext;
|
||
}
|
||
|
||
|
||
/* * * * * * * * * * 取 动 态 属 性 显 示 数 据 的 函 数 * * * * * * * * * */
|
||
void TDbSheet::GetTips(DList<TObjInfoUnit> &lstInfo) const
|
||
{
|
||
lstInfo.Append(new TObjInfoUnit(_T("对象类型"), _T("表格")));
|
||
const TCHAR *pszTitle=m_title.IsVisible()? _T("标题") : _T("标题(隐藏)");
|
||
lstInfo.Append(new TObjInfoUnit(pszTitle, m_title.GetText()));
|
||
XPoint ext=GetExtents(m_title.IsVisible() && m_title.GetDividerStyle().GetDividerFlag()!=TDividerStyle::kNone);
|
||
XString sHeight, sWidth, sRowHeight;
|
||
ftoa(ext.x, 1, sWidth);
|
||
ftoa(ext.y, 1, sHeight);
|
||
ftoa(GetRowHeight(),1, sRowHeight);
|
||
sHeight << _T("P");
|
||
sWidth << _T("P");
|
||
sRowHeight << _T("P");
|
||
lstInfo.Append(new TObjInfoUnit(_T("标准行高"), sRowHeight));
|
||
lstInfo.Append(new TObjInfoUnit(_T("表格宽度"), sWidth));
|
||
lstInfo.Append(new TObjInfoUnit(_T("表格高度"), sHeight));
|
||
lstInfo.Append(new TObjInfoUnit(_T("行数"), XString(_T("%d"),GetRowNum())));
|
||
lstInfo.Append(new TObjInfoUnit(_T("列数"), XString(_T("%d"), GetColumnNum())));
|
||
}
|
||
|
||
Acad::ErrorStatus
|
||
TDbSheet::ExplodeOrDraw2d(XExplodeDraw &dc) const
|
||
{
|
||
//TPushProperty vProp(this, dc);
|
||
//add on 20161017 图层关闭,不进行相关绘制,解决表格对象内有图块,当表格图层关闭,打印显示图块的问题。
|
||
AcDbLayerTableRecordPointer player(this->layerId(), AcDb::kForRead);
|
||
if (player.openStatus() == Acad::eOk && player->isOff())//对图层为空时,进行保护
|
||
{
|
||
return Acad::eOk;
|
||
}
|
||
//end add
|
||
assertReadEnabled();
|
||
int nGsMarker=1;
|
||
if(!objectId() && _tcsicmp(dc.Desc(), XAcGiViewDraw::Descriptor())==0) nGsMarker=0;
|
||
DrawBorder(dc, nGsMarker);
|
||
DrawTitle(dc, nGsMarker);
|
||
XPoint ptBase=GetTopLeft(FALSE);
|
||
DrawRowDivider(ptBase, dc, nGsMarker);
|
||
DrawColumnDivider(ptBase, dc, nGsMarker);
|
||
if(!!objectId())
|
||
DrawCellText(ptBase, dc, nGsMarker);
|
||
return Acad::eOk;
|
||
}
|
||
|
||
////////////////////////////////////////////////////////////////////
|
||
// 绘制表格的方法
|
||
|
||
// 绘制表格的外框
|
||
void TDbSheet::DrawBorder(XExplodeDraw &dc, int &nGsMarker) const
|
||
{
|
||
AcDbPolyline pline;
|
||
XPoly2D polyBorder(1);
|
||
GetBorder(polyBorder);
|
||
PolyConvert(polyBorder, pline);
|
||
pline.setPropertiesFrom(this);
|
||
|
||
if(nGsMarker) {
|
||
dc.SetSelectionMarker(nGsMarker);
|
||
nGsMarker ++ ;
|
||
|
||
//捕捉加速
|
||
INT_PTR nQuickMarker=GetQuickMarker();
|
||
if(nQuickMarker && nQuickMarker<(nGsMarker-4) || nQuickMarker>=nGsMarker) //用于捕捉时加速
|
||
return;
|
||
|
||
}
|
||
int nOldColor=dc.GetColor();
|
||
switch(m_border.m_nFlag) {
|
||
case TDividerStyle::kLocal:
|
||
if(!!m_border.m_idLineType)
|
||
pline.setLinetype(m_border.m_idLineType);
|
||
if(m_border.m_nLineWidth>0.0 && !!objectId())
|
||
pline.setConstantWidth(m_border.m_nLineWidth*GetPScale());
|
||
if(m_border.m_nColor>0) {
|
||
dc.SetColor(m_border.GetColor());
|
||
pline.setColorIndex(m_border.GetColor());
|
||
}
|
||
dc.Polyline(pline);
|
||
break;
|
||
case TDividerStyle::kParent:
|
||
dc.Polyline(pline);
|
||
break;
|
||
case TDividerStyle::kNone:
|
||
default:
|
||
break;
|
||
}
|
||
dc.SetColor(nOldColor);
|
||
}
|
||
|
||
// 当Wrap和一行容纳不下时采用MText
|
||
void
|
||
TDbSheet::InitTextInBox(TDbText &text, XPoint ptTopLeft, double nBoxWidth, double nBoxHeight,
|
||
double nOffset, AcDb::TextHorzMode nHorMode, AcDb::TextVertMode nVerMode) const
|
||
{
|
||
BOOL bMText=text.isKindOf(TDbMText::desc());
|
||
XPoint ptAlign=ptTopLeft;
|
||
if(!bMText) {
|
||
XExplodeDraw::TextAlignment align=XExplodeDraw::GetTextAlignment(nHorMode, nVerMode);
|
||
switch(nHorMode) {
|
||
case AcDb::kTextLeft:
|
||
ptAlign.x += nOffset;
|
||
break;
|
||
case AcDb::kTextCenter:
|
||
case AcDb::kTextMid:
|
||
ptAlign.x += nBoxWidth/2;
|
||
break;
|
||
case AcDb::kTextRight:
|
||
ptAlign.x += nBoxWidth;
|
||
ptAlign.x -= nOffset;
|
||
break;
|
||
default:
|
||
ptAlign.x += nOffset;
|
||
break;
|
||
}
|
||
switch(nVerMode) {
|
||
case AcDb::kTextBase:
|
||
case AcDb::kTextBottom:
|
||
ptAlign.y -= nBoxHeight;
|
||
ptAlign.y += nOffset;
|
||
if(align==XExplodeDraw::kTextFit || align==XExplodeDraw::kUnknown)
|
||
align=XExplodeDraw::kLeft;
|
||
break;
|
||
case AcDb::kTextVertMid:
|
||
ptAlign.y -= nBoxHeight/2;
|
||
if(align==XExplodeDraw::kTextFit || align==XExplodeDraw::kUnknown)
|
||
align=XExplodeDraw::kMiddleLeft;
|
||
break;
|
||
case AcDb::kTextTop:
|
||
ptAlign.y -= nOffset;
|
||
if(align==XExplodeDraw::kTextFit || align==XExplodeDraw::kUnknown)
|
||
align=XExplodeDraw::kTopLeft;
|
||
break;
|
||
default:
|
||
ASSERT(0);
|
||
}
|
||
|
||
text.SetAlignment(align);
|
||
text.SetLocation(ptAlign);
|
||
} else {
|
||
XExplodeDraw::TextAlignment align;
|
||
ptAlign.x += nOffset;
|
||
switch(nHorMode) {
|
||
case AcDb::kTextLeft:
|
||
align = XExplodeDraw::kLeft;
|
||
break;
|
||
case AcDb::kTextCenter:
|
||
case AcDb::kTextMid:
|
||
align = XExplodeDraw::kCenter;
|
||
break;
|
||
case AcDb::kTextRight:
|
||
align = XExplodeDraw::kRight;
|
||
break;
|
||
case AcDb::kTextFit:
|
||
align = XExplodeDraw::kTextFit;
|
||
break;
|
||
default:
|
||
ASSERT(0);
|
||
}
|
||
text.SetAlignment(align);
|
||
XPoint ext=text.GetExtents();
|
||
switch(nVerMode) {
|
||
case AcDb::kTextBase:
|
||
case AcDb::kTextBottom:
|
||
ptAlign.y -= nBoxHeight;
|
||
ptAlign.y += nOffset+ext.y;
|
||
break;
|
||
case AcDb::kTextVertMid:
|
||
ptAlign.y -= nBoxHeight/2;
|
||
ptAlign.y += ext.y/2;
|
||
break;
|
||
case AcDb::kTextTop:
|
||
ptAlign.y -= nOffset;
|
||
break;
|
||
default:
|
||
ASSERT(0);
|
||
}
|
||
text.SetLocation(ptAlign);
|
||
}
|
||
}
|
||
|
||
// 绘制标题, 包括文字和横线
|
||
// ptBase -- 标题上(IN)下(OUT)的第一左上角
|
||
void
|
||
TDbSheet::DrawTitle(XExplodeDraw &dc, int &nGsMarker) const
|
||
{
|
||
if(!m_title.IsVisible())
|
||
return;
|
||
BOOL bIncludeTitle=(m_title.m_divider.m_nFlag!=TDividerStyle::kNone);
|
||
double nTitleHeight = GetTitleHeight(FALSE);
|
||
double nTitleWidth = GetSheetWidth(FALSE);
|
||
|
||
double nRotWcs=Layout2Wcs(m_nRotation);
|
||
//左上角为ptBase
|
||
XPoint ptBase=GetTopLeft(bIncludeTitle);
|
||
if(!bIncludeTitle)
|
||
ads_polar(XPoint(ptBase), nRotWcs+PI/2, nTitleHeight, ptBase);
|
||
|
||
INT_PTR nQuickMarker=GetQuickMarker();
|
||
BOOL bDrawText=TRUE;
|
||
if(nGsMarker) {
|
||
dc.SetSelectionMarker(nGsMarker);
|
||
nGsMarker++;
|
||
|
||
//捕捉时加速
|
||
if(nQuickMarker && (nGsMarker-1)!=nQuickMarker)
|
||
bDrawText=FALSE;
|
||
else
|
||
bDrawText=TRUE;
|
||
} else {
|
||
bDrawText=FALSE;
|
||
}
|
||
|
||
ads_matrix mat;
|
||
ptBase.GetRotationMatrix(nRotWcs, mat);
|
||
if(bDrawText && !!m_title.m_sText) { //绘制文字
|
||
double nOffset=GetTitleLineSpace(FALSE);
|
||
double nTextHeight=GetTitleTextHeight(TRUE);
|
||
AcDbObjectId idTextStyle=GetTitleTextStyle();
|
||
|
||
TDbText textLine;
|
||
textLine.setPropertiesFrom(this);
|
||
textLine.SetHeight(nTextHeight);
|
||
textLine.SetStyleId(idTextStyle);
|
||
textLine.SetText(m_title.m_sText);
|
||
const TCHAR *bHardMText=_tcschr(m_title.GetText(), _T('\n'));
|
||
TDbText *pDbText=NULL;
|
||
if(bHardMText ||
|
||
(textLine.GetExtents().x + nOffset*2 > nTitleWidth && IsTitleWrapEnabled())
|
||
) {
|
||
TDbMText *pTextSeg=new TDbMText;
|
||
pDbText=pTextSeg;
|
||
pDbText->setPropertiesFrom(this);
|
||
TDbMText &textSeg=*pTextSeg;
|
||
textSeg.SetLineSpace(nOffset, FALSE);
|
||
textSeg.SetPageWidth(nTitleWidth-2*nOffset, FALSE);
|
||
} else {
|
||
pDbText=new TDbText;
|
||
pDbText->setPropertiesFrom(this);
|
||
}
|
||
|
||
Adesk::UInt16 nColor=GetTitleTextColor();
|
||
int nOldColor=dc.GetColor();
|
||
if(nColor>0) {
|
||
pDbText->setColorIndex(nColor);
|
||
dc.SetColor(nColor);
|
||
}
|
||
|
||
pDbText->SetHeight(nTextHeight);
|
||
pDbText->SetStyleId(idTextStyle);
|
||
pDbText->SetText(m_title.m_sText);
|
||
InitTextInBox(*pDbText, ptBase, nTitleWidth, nTitleHeight, nOffset,
|
||
GetTitleHorMode(), GetTitleVerMode());
|
||
XPoint ptLoc=pDbText->GetLocation();
|
||
ptLoc.TransformBy(mat);
|
||
pDbText->SetLocation(ptLoc);
|
||
pDbText->SetRotation(m_nRotation);
|
||
if(dc.IsFullExplode())
|
||
pDbText->ExplodeOrDraw2d(dc);
|
||
else
|
||
dc.DrawEntity(*pDbText);
|
||
delete pDbText;
|
||
if(nColor>0)
|
||
dc.SetColor(nOldColor);
|
||
}
|
||
|
||
ads_polar(XPoint(ptBase), nRotWcs-PI/2, nTitleHeight, ptBase);
|
||
XPoint ptRight;
|
||
ads_polar(ptBase, nRotWcs, nTitleWidth, ptRight);
|
||
if(nGsMarker) {
|
||
dc.SetSelectionMarker(nGsMarker);
|
||
nGsMarker++;
|
||
//捕捉加速
|
||
if(nQuickMarker && (nGsMarker-1)!=nQuickMarker)
|
||
return;
|
||
}
|
||
|
||
int nOldColor=dc.GetColor();
|
||
AcDbPolyline pline;
|
||
pline.addVertexAt(0, ptBase);
|
||
pline.addVertexAt(1, ptRight);
|
||
pline.setPropertiesFrom(this);
|
||
const TDividerStyle ÷r=m_title.m_divider;
|
||
switch(divider.m_nFlag) {
|
||
case TDividerStyle::kLocal:
|
||
case TDividerStyle::kParent:
|
||
if(!!m_title.m_divider.m_idLineType)
|
||
pline.setLinetype(m_title.m_divider.m_idLineType);
|
||
if(m_title.m_divider.m_nLineWidth>0.0 && !!objectId())
|
||
pline.setConstantWidth(m_title.m_divider.m_nLineWidth*GetPScale());
|
||
if(m_title.m_divider.m_nColor>0) {
|
||
dc.SetColor(m_title.m_divider.m_nColor);
|
||
pline.setColorIndex(m_title.m_divider.m_nColor);
|
||
}
|
||
dc.Polyline(pline);
|
||
break;
|
||
case TDividerStyle::kNone:
|
||
default:
|
||
break;
|
||
}
|
||
dc.SetColor(nOldColor);
|
||
}
|
||
|
||
|
||
// 绘制表格的行分割线
|
||
void
|
||
TDbSheet::DrawRowDivider(int nRow, XPoint ptLeft, XExplodeDraw &dc) const
|
||
{
|
||
AcDbPolyline pline;
|
||
if(!InitRowDivider(pline, nRow))
|
||
return;
|
||
|
||
DList<XLine> lstSegments;
|
||
int nColNum=m_columns.Length();
|
||
double nScale=GetPScale();
|
||
XLine lnSeg;
|
||
XPoint ptFrom=ptLeft;
|
||
XPoint ptStart;
|
||
BOOL bStartValid=FALSE;
|
||
double nRotWcs=Layout2Wcs(m_nRotation);
|
||
for(int nCol=0; nCol<nColNum; nCol++) {
|
||
const TSheetColumn &column=m_columns[nCol];
|
||
double nColWidth=column.m_nWidth*nScale;
|
||
XPoint ptTo;
|
||
ads_polar(ptFrom, nRotWcs, nColWidth, ptTo);
|
||
if(HasRowDivider(nRow, nCol)) {
|
||
if(!bStartValid) {
|
||
bStartValid=TRUE;
|
||
ptStart=ptFrom;
|
||
}
|
||
if(nCol==nColNum-1) {
|
||
lstSegments.Append(new XLine(ptStart, ptTo));
|
||
}
|
||
} else if(bStartValid) {
|
||
lstSegments.Append(new XLine(ptStart, ptFrom));
|
||
bStartValid=FALSE;
|
||
}
|
||
ptFrom=ptTo;
|
||
}
|
||
|
||
for(int i=0; i<lstSegments.Length(); i++) {
|
||
XLine *pLine=lstSegments[i];
|
||
if(i==0) {
|
||
pline.addVertexAt(0, pLine->StartPoint());
|
||
pline.addVertexAt(1, pLine->EndPoint());
|
||
} else {
|
||
pline.setPointAt(0, pLine->StartPoint());
|
||
pline.setPointAt(1, pLine->EndPoint());
|
||
}
|
||
dc.Polyline(pline);
|
||
}
|
||
}
|
||
|
||
|
||
// 绘制行分割线
|
||
void
|
||
TDbSheet::DrawRowDivider(XPoint ptBase, XExplodeDraw &dc, int &nGsMarker) const
|
||
{
|
||
int nRowNum=m_rows.Length();
|
||
XPoint ptLeft=ptBase;
|
||
INT_PTR nQuickMarker=GetQuickMarker();
|
||
double nRotWcs=Layout2Wcs(m_nRotation);
|
||
for(int n=0; n<nRowNum-1; n++) {
|
||
ads_polar(XPoint(ptLeft), nRotWcs-PI/2, GetRowHeight(n, FALSE), ptLeft);
|
||
if(nGsMarker) {
|
||
dc.SetSelectionMarker(nGsMarker);
|
||
nGsMarker++;
|
||
//捕捉加速
|
||
if(nQuickMarker && (nGsMarker-1)!=nQuickMarker)
|
||
continue;//用于捕捉时加速
|
||
|
||
}
|
||
DrawRowDivider(n, ptLeft, dc);
|
||
};
|
||
}
|
||
|
||
// 绘制表格列分割线
|
||
void
|
||
TDbSheet::DrawColumnDivider(int nCol, XPoint ptTop, XExplodeDraw &dc) const
|
||
{
|
||
AcDbPolyline pline;
|
||
if(!InitColumnDivider(pline, nCol))
|
||
return;
|
||
|
||
double nRotWcs=Layout2Wcs(m_nRotation);
|
||
DList<XLine> lstSegments;
|
||
int nRowNum=m_rows.Length();
|
||
double nScale=GetPScale();
|
||
XLine lnSeg;
|
||
XPoint ptFrom=ptTop;
|
||
XPoint ptStart;
|
||
BOOL bStartValid=FALSE;
|
||
for(int nRow=0; nRow<nRowNum; nRow++) {
|
||
double nRowHeight=GetRowHeight(nRow, FALSE);
|
||
XPoint ptTo;
|
||
ads_polar(ptFrom, nRotWcs-PI/2.0, nRowHeight, ptTo);
|
||
if(HasColumnDivider(nRow, nCol)) {
|
||
if(!bStartValid) {
|
||
bStartValid=TRUE;
|
||
ptStart=ptFrom;
|
||
}
|
||
if(nRow==nRowNum-1) {
|
||
lstSegments.Append(new XLine(ptStart, ptTo));
|
||
}
|
||
} else if(bStartValid) {
|
||
lstSegments.Append(new XLine(ptStart, ptFrom));
|
||
bStartValid=FALSE;
|
||
}
|
||
ptFrom=ptTo;
|
||
}
|
||
|
||
for(int i=0; i<lstSegments.Length(); i++) {
|
||
XLine *pLine=lstSegments[i];
|
||
if(i==0) {
|
||
pline.addVertexAt(0, pLine->StartPoint());
|
||
pline.addVertexAt(1, pLine->EndPoint());
|
||
} else {
|
||
pline.setPointAt(0, pLine->StartPoint());
|
||
pline.setPointAt(1, pLine->EndPoint());
|
||
}
|
||
dc.Polyline(pline);
|
||
}
|
||
}
|
||
|
||
// 绘制表格列分割线
|
||
void
|
||
TDbSheet::DrawColumnDivider(XPoint ptBase, XExplodeDraw &dc, int &nGsMarker) const
|
||
{
|
||
double nRotWcs=Layout2Wcs(m_nRotation);
|
||
int nColNum=m_columns.Length();
|
||
XPoint ptTop=ptBase;
|
||
INT_PTR nQuickMarker=GetQuickMarker();
|
||
for(int n=0; n<nColNum-1; n++) {
|
||
ads_polar(XPoint(ptTop), nRotWcs, GetColumnWidth(n, FALSE), ptTop);
|
||
if(nGsMarker) {
|
||
dc.SetSelectionMarker(nGsMarker);
|
||
nGsMarker++;
|
||
//捕捉加速
|
||
if(nQuickMarker && (nGsMarker-1)!=nQuickMarker)
|
||
continue;//用于捕捉时加速
|
||
|
||
}
|
||
DrawColumnDivider(n, ptTop, dc);
|
||
};
|
||
}
|
||
|
||
// 绘制单元格的文本
|
||
void
|
||
TDbSheet::DrawRangeText(const TGridRange &range, XPoint ptTopLeft, XExplodeDraw &dc)const
|
||
{
|
||
BOOL bValid=(range.m_nRow>=0 && range.m_nRow<=range.m_nRowMax &&
|
||
range.m_nColumn>=0 && range.m_nColumn<=range.m_nColumnMax &&
|
||
range.m_nRowMax<GetRowNum() &&
|
||
range.m_nColumnMax<GetColumnNum());
|
||
if(!bValid)
|
||
return;
|
||
|
||
double x=GetColumnsWidth(0, range.m_nColumn-1, FALSE);
|
||
double y=GetRowsHeight(0, range.m_nRow-1, FALSE);
|
||
double w, h;
|
||
w=GetColumnsWidth(range.m_nColumn, range.m_nColumnMax, FALSE);
|
||
h=GetRowsHeight(range.m_nRow, range.m_nRowMax, FALSE);
|
||
double nRotWcs=Layout2Wcs(m_nRotation);
|
||
|
||
//左上角为ptBase
|
||
XPoint ptBase;
|
||
ads_polar(ptTopLeft, nRotWcs, x, ptBase);
|
||
ads_polar(XPoint(ptBase), nRotWcs-PI/2, y, ptBase);
|
||
DrawCellText(range.GetText(), w, h, range.m_nRow, range.m_nColumn, ptBase, dc);
|
||
}
|
||
|
||
void
|
||
TDbSheet::DrawCellText(int nRow, int nCol, XPoint ptTopLeft, XExplodeDraw &dc) const
|
||
{
|
||
const TGridCell &cell=*(*this)(nRow, nCol);
|
||
if(cell.IsRange())
|
||
return;
|
||
|
||
double x=GetColumnsWidth(0, nCol-1, FALSE);
|
||
double y=GetRowsHeight(0, nRow-1, FALSE);
|
||
double w, h;
|
||
w=GetColumnWidth(nCol, FALSE);
|
||
h=GetRowHeight(nRow, FALSE);
|
||
double nRotWcs=Layout2Wcs(m_nRotation);
|
||
//左上角为ptBase
|
||
XPoint ptBase;
|
||
ads_polar(ptTopLeft, nRotWcs, x, ptBase);
|
||
ads_polar(XPoint(ptBase), nRotWcs-PI/2, y, ptBase);
|
||
DrawCellText(cell.GetText(), w, h, nRow, nCol, ptBase, dc);
|
||
}
|
||
|
||
// sg add 101116,支持统一标高
|
||
bool TDbSheet::UnifyElevation(double dElevation)
|
||
{
|
||
assertWriteEnabled();
|
||
m_ptLocation.z = dElevation;
|
||
return true;
|
||
}
|
||
|
||
int TAttribValue::FindByName(const TAttribValue *p1, const void *p2)
|
||
{
|
||
return _tcsicmp(p1->m_sName, (const TCHAR *)p2);
|
||
}
|
||
|
||
|
||
BOOL TCellBlockInsert::OutputDesc(XString &sDescOut) const
|
||
{
|
||
if(!m_sBlockName)
|
||
return FALSE;
|
||
XString sDesc(2048);
|
||
sDesc << _T("^B{");
|
||
sDesc << _T("BLOCK=") << m_sBlockName << _T(";");
|
||
sDesc << _T("FLAG=") << m_nControlFlag << _T(";");
|
||
if(!(m_nControlFlag&CBF_AUTOSIZE)) {
|
||
sDesc << _T("X=") << m_xValue << _T(";")
|
||
<< _T("Y=") << m_yValue << _T(";")
|
||
<< _T("Z=") << m_zValue << _T(";");
|
||
}
|
||
sDesc << _T("}");
|
||
if(m_nControlFlag&CBF_SHOW_ATTR) {
|
||
sDesc << _T("{");
|
||
for(int i=0; i<m_lstAttribs.Length(); i++) {
|
||
const TAttribValue &attr=m_lstAttribs[i];
|
||
sDesc << attr.m_sName << _T("=") << attr.m_sValue << _T(";");
|
||
}
|
||
sDesc << _T("}");
|
||
}
|
||
sDescOut = sDesc;
|
||
return TRUE;
|
||
}
|
||
|
||
BOOL TCellBlockInsert::ParserDesc(const TCHAR *pszText)
|
||
{
|
||
if(!pszText)
|
||
return FALSE;
|
||
size_t nCharNum=_tcslen(pszText);
|
||
if(nCharNum>4 && nCharNum<2048) ;
|
||
else
|
||
return FALSE;
|
||
if(pszText[0]==_T('^') && pszText[1]==_T('B') && pszText[2]==_T('{')) ;
|
||
else
|
||
return FALSE;
|
||
|
||
const TCHAR *pEndBlock=_tcschr(pszText, _T('}'));
|
||
if(!pEndBlock)
|
||
return FALSE;
|
||
XString sBlockInfo(2048);
|
||
StrCpy(sBlockInfo, &pszText[3], pEndBlock); //取图块描述
|
||
|
||
// 分析图块描述
|
||
TCHAR *pBegStat=sBlockInfo;
|
||
while(pBegStat && *pBegStat) {
|
||
XString sStatement(2048);
|
||
TCHAR *pEndStat=_tcschr(pBegStat, _T(';'));
|
||
if(!pEndStat)
|
||
break;
|
||
StrCpy(sStatement, pBegStat, pEndStat);
|
||
|
||
TCHAR *pEqual=_tcschr(sStatement, _T('='));
|
||
if(!pEqual)
|
||
return FALSE;
|
||
XString sLeftValue(2048), sRightValue(2048);
|
||
StrCpy(sLeftValue, sStatement, pEqual);
|
||
StrCpy(sRightValue, pEqual+1, NULL);
|
||
if(_tcsicmp(sLeftValue, _T("BLOCK"))==0)
|
||
m_sBlockName=sRightValue;
|
||
else if(_tcsicmp(sLeftValue, _T("FLAG"))==0)
|
||
m_nControlFlag=_ttoi(sRightValue);
|
||
else if(_tcsicmp(sLeftValue, _T("X"))==0)
|
||
m_xValue = _tstof(sRightValue);
|
||
else if(_tcsicmp(sLeftValue, _T("Y"))==0)
|
||
m_yValue = _tstof(sRightValue);
|
||
else if(_tcsicmp(sLeftValue, _T("Z"))==0)
|
||
m_zValue = _tstof(sRightValue);
|
||
|
||
pBegStat=pEndStat+1;
|
||
}
|
||
|
||
m_lstAttribs.Reset();
|
||
const TCHAR *pBegAttr=_tcschr(pEndBlock, _T('{'));
|
||
if(!pBegAttr)
|
||
return TRUE;
|
||
const TCHAR *pEndAttr=_tcschr(pBegAttr, _T('}'));
|
||
if(!pEndAttr)
|
||
return FALSE;
|
||
XString sAttrInfo(2048);
|
||
StrCpy(sAttrInfo, pBegAttr+1, pEndAttr);
|
||
|
||
|
||
pBegStat=sAttrInfo;
|
||
while(pBegStat && *pBegStat) {
|
||
XString sStatement(2048);
|
||
TCHAR *pEndStat=_tcschr(pBegStat, _T(';'));
|
||
if(!pEndStat)
|
||
break;
|
||
StrCpy(sStatement, pBegStat, pEndStat);
|
||
|
||
TCHAR *pEqual=_tcschr(sStatement, _T('='));
|
||
if(!pEqual)
|
||
return FALSE;
|
||
XString sLeftValue(2048), sRightValue(2048);
|
||
StrCpy(sLeftValue, sStatement, pEqual);
|
||
StrCpy(sRightValue, pEqual+1, NULL);
|
||
m_lstAttribs.Append(new TAttribValue(sLeftValue, sRightValue));
|
||
pBegStat=pEndStat+1;
|
||
}
|
||
return TRUE;
|
||
}
|
||
/*
|
||
static BOOL IsBlockInsert(const TCHAR *pszText, AcDbObjectId &idBlock, XPoint &sizeBlock)
|
||
{
|
||
if(!pszText)
|
||
return FALSE;
|
||
int nCharNum=strlen(pszText);
|
||
if(nCharNum>2 && nCharNum<256) {
|
||
if(pszText[0]==_T('^') && pszText[1]==_T('B')) {
|
||
TCHAR szBlockInfo[256]=_T("");
|
||
_tcscpy(szBlockInfo, &pszText[2]);
|
||
TCHAR *pSep=_tcschr(szBlockInfo, _T(':'));
|
||
TCHAR szBlockName[256]=_T(""), szSizeX[256]=_T(""), szSizeY[256]=_T("");
|
||
if(pSep) {
|
||
StrCpy(szBlockName, szBlockInfo, pSep);
|
||
pSep++;
|
||
TCHAR *pSep1=_tcschr(pSep, _T(':'));
|
||
if(pSep1) {
|
||
StrCpy(szSizeX, pSep, pSep1);
|
||
StrCpy(szSizeY, pSep1+1, NULL);
|
||
}
|
||
}
|
||
double nSizeX=_tstof(szSizeX), nSizeY=_tstof(szSizeY);
|
||
if(nSizeX<_DIST_SNAP || nSizeY<_DIST_SNAP)
|
||
return FALSE;
|
||
idBlock=InitBlock(szBlockName);
|
||
if(!idBlock)
|
||
return FALSE;
|
||
sizeBlock.x=nSizeX;
|
||
sizeBlock.y=nSizeY;
|
||
return TRUE;
|
||
}
|
||
}
|
||
return FALSE;
|
||
}
|
||
*/
|
||
|
||
|
||
// Modify on 2003/2/28
|
||
// 增加图块的插入
|
||
void TDbSheet::DrawCellText(const TCHAR *pszText, double w, double h, int nRow, int nCol, XPoint ptBase,
|
||
XExplodeDraw &dc) const
|
||
{
|
||
//if(!pszText && pszText[0])//modified by whl on 070206
|
||
if(pszText==NULL||_tcslen(pszText)==0)
|
||
return;
|
||
|
||
ads_matrix mat;
|
||
double nRotWcs=Layout2Wcs(m_nRotation);
|
||
ptBase.GetRotationMatrix(nRotWcs, mat);
|
||
|
||
AcDbObjectId idBlock;
|
||
//XPoint sizeBlock;
|
||
TCellBlockInsert insert;
|
||
if(insert.ParserDesc(pszText))
|
||
idBlock=InitBlock(insert.m_sBlockName,database());
|
||
if(idBlock.isValid()) {
|
||
XPoint ptAlign=ptBase;
|
||
double nOffset=GetCellLineSpace(nRow, nCol, FALSE);
|
||
AcDb::TextHorzMode nHorMode=GetCellHorMode(nRow, nCol);
|
||
AcDb::TextVertMode nVerMode=GetCellVerMode(nRow, nCol);
|
||
XExplodeDraw::TextAlignment align=XExplodeDraw::GetTextAlignment(
|
||
nHorMode, nVerMode);
|
||
switch(nHorMode) {
|
||
case AcDb::kTextLeft:
|
||
ptAlign.x += nOffset;
|
||
break;
|
||
case AcDb::kTextCenter:
|
||
case AcDb::kTextMid:
|
||
ptAlign.x += w/2;
|
||
break;
|
||
case AcDb::kTextRight:
|
||
ptAlign.x += w;
|
||
ptAlign.x -= nOffset;
|
||
break;
|
||
default:
|
||
ptAlign.x += w/2;
|
||
break;
|
||
}
|
||
switch(nVerMode) {
|
||
case AcDb::kTextBase:
|
||
case AcDb::kTextBottom:
|
||
ptAlign.y -= h;
|
||
ptAlign.y += nOffset;
|
||
break;
|
||
case AcDb::kTextVertMid:
|
||
ptAlign.y -= h/2;
|
||
break;
|
||
case AcDb::kTextTop:
|
||
ptAlign.y -= h;
|
||
break;
|
||
default:
|
||
ptAlign.y -= h/2;
|
||
}
|
||
|
||
// ptInsert-单元格中心点
|
||
XPoint ptInsert=ptAlign;
|
||
ptInsert.TransformBy(mat);
|
||
ads_polar(ptBase, nRotWcs, w/2.0, ptInsert);
|
||
ads_polar(XPoint(ptInsert), nRotWcs-PI/2, h/2.0, ptInsert);
|
||
AcDbBlockReference blkInsert(ptInsert, idBlock);
|
||
TBlockGeomInfo info;
|
||
if(insert.m_nControlFlag&CBF_AUTOSIZE) {
|
||
info.m_nSizeX=max(w-2*nOffset, nOffset);
|
||
info.m_nSizeY=max(h-2*nOffset, nOffset);
|
||
if(insert.m_nControlFlag&CBF_EQUAL_SIDE)
|
||
info.m_nSizeX=info.m_nSizeY=min(info.m_nSizeX, info.m_nSizeY);
|
||
} else if(insert.m_nControlFlag&CBF_INPUT_SCALE) {
|
||
info.SetFromInsert(&blkInsert);
|
||
info.m_nSizeX *= insert.m_xValue;
|
||
info.m_nSizeY *= insert.m_yValue;
|
||
info.m_nSizeZ *= insert.m_zValue;
|
||
} else {
|
||
info.m_nSizeX=insert.m_xValue;
|
||
info.m_nSizeY=insert.m_yValue;
|
||
info.m_nSizeZ=insert.m_zValue;
|
||
}
|
||
info.m_ptCen=ptInsert;
|
||
info.m_nRotation=nRotWcs;
|
||
blkInsert.setPropertiesFrom(this);
|
||
|
||
//modify by xlc on 071101
|
||
//info.UpdateInsert(&blkInsert);
|
||
UpdateInsert(&blkInsert,info,insert.m_nControlFlag&CBF_UNISCALE);
|
||
|
||
|
||
if(insert.m_nControlFlag&CBF_UNISCALE) {
|
||
//del by xlc on 071101
|
||
//AcGeScale3d factors=blkInsert.scaleFactors();
|
||
//double nScale=min(factors[0], factors[1]);
|
||
//factors[0]=factors[1]=factors[2]=nScale;
|
||
//blkInsert.setScaleFactors(factors);
|
||
info.SetFromInsert(&blkInsert);
|
||
info.m_ptCen=ptInsert;
|
||
info.UpdateInsert(&blkInsert);
|
||
}
|
||
|
||
|
||
Adesk::UInt16 nColor=GetCellTextColor(nRow, nCol);
|
||
blkInsert.setColorIndex(nColor);
|
||
//blkInsert.setScaleFactors(scales);
|
||
BOOL bAcGi=false;
|
||
if(g_nAcadVer>15.0001)
|
||
bAcGi=(_tcscmp(dc.Desc(), XAcGiViewDraw::Descriptor())==0);
|
||
if(bAcGi) {
|
||
OPENOBJ_BEGIN(idBlock, AcDb::kForRead, AcDbBlockTableRecord, pBlock);
|
||
if(pBlock) {
|
||
AcGiSubEntityTraits &traits=((XAcGiViewDraw &)dc).GetCommonDraw()->subEntityTraits();
|
||
AcDbObjectId idLayer = traits.layerId();
|
||
Adesk::UInt16 nColorOld = traits.color();
|
||
AcDbObjectId idLineType = traits.lineTypeId();
|
||
AcGeMatrix3d matTrans=BlockTransform(&blkInsert);
|
||
if(nColor>0 && nColor<256)
|
||
traits.setColor(nColor);
|
||
AcGiGeometry *geom=((XAcGiViewDraw &)dc).GetCommonDraw()->rawGeometry();
|
||
geom->pushModelTransform(matTrans);
|
||
geom->draw(pBlock);
|
||
geom->popModelTransform();
|
||
traits.setLayer(idLayer);
|
||
traits.setColor(nColorOld);
|
||
traits.setLineType(idLineType);
|
||
}
|
||
OPENOBJ_END();
|
||
} else {
|
||
int nOldColor=dc.GetColor();
|
||
dc.SetColor(nColor);
|
||
dc.DrawEntity(blkInsert);
|
||
dc.SetColor(nOldColor);
|
||
}
|
||
|
||
// 输出属性
|
||
AcGeMatrix3d matBlock=BlockTransform(&blkInsert);
|
||
OPENOBJ_BEGIN(idBlock, AcDb::kForRead, AcDbBlockTableRecord, pBlock);
|
||
if(pBlock) {
|
||
AcDbBlockTableRecordIterator *pIter=NULL;
|
||
if(pBlock->newIterator(pIter)==Acad::eOk && pIter) {
|
||
for(pIter->start(); !pIter->done(); pIter->step()) {
|
||
AcDbObjectId idAtt;
|
||
pIter->getEntityId(idAtt);
|
||
OPENOBJ_BEGIN(idAtt, AcDb::kForRead, AcDbAttributeDefinition, pAttr);
|
||
if(pAttr) {
|
||
TCHAR *pTag=pAttr->tag();
|
||
if(pTag) {
|
||
TAttribValue *pFind=insert.m_lstAttribs.FindNode(pTag, TAttribValue::FindByName);
|
||
if(pFind) {
|
||
TDbText text;
|
||
text.setPropertiesFrom(this);
|
||
text.ConvertFrom(pAttr);
|
||
text.SetText(pFind->m_sValue);
|
||
text.setColorIndex(nColor);
|
||
XPoint ptLoc=text.GetLocation();
|
||
XPoint ptHeight;
|
||
ads_polar(ptLoc, nRotWcs+PI/2, text.GetHeight(FALSE), ptHeight);
|
||
ptHeight.TransformBy(matBlock);
|
||
ptLoc.TransformBy(matBlock);
|
||
text.SetLocation(ptLoc);
|
||
text.SetHeight(ptLoc.Distance2d(ptHeight), FALSE);
|
||
text.ExplodeOrDraw2d(dc);
|
||
}
|
||
delete [] pTag;
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
delete pIter;
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
} else { //绘制文字
|
||
double nOffset=GetCellLineSpace(nRow, nCol, FALSE);
|
||
double nTextHeight=GetCellTextHeight(nRow, nCol, TRUE);
|
||
AcDbObjectId idTextStyle=GetCellTextStyle(nRow, nCol);
|
||
|
||
TDbText textLine;
|
||
textLine.setPropertiesFrom(this); //Add this line on 2002/11/18
|
||
textLine.SetHeight(nTextHeight);
|
||
textLine.SetStyleId(idTextStyle);
|
||
textLine.SetText(pszText);
|
||
TDbText *pCellText=NULL;
|
||
const TCHAR *bHardMText=_tcschr(pszText, _T('\n'));
|
||
XPoint ptMyExt=textLine.GetExtents();
|
||
BOOL bOverWidth= (ptMyExt.x + nOffset*2.0 > w);
|
||
BOOL bWrapEnabled=IsCellWrapEnabled(nRow, nCol);
|
||
if(bHardMText || (bOverWidth && bWrapEnabled)) {
|
||
pCellText=new TDbMText;
|
||
pCellText->setPropertiesFrom(this);
|
||
TDbMText &textSeg=*(TDbMText *)pCellText;
|
||
textSeg.SetLineSpace(nOffset, FALSE);
|
||
textSeg.SetPageWidth(w-2*nOffset, FALSE);
|
||
} else {
|
||
pCellText=new TDbText;
|
||
pCellText->setPropertiesFrom(this);
|
||
}
|
||
|
||
Adesk::UInt16 nColor=GetCellTextColor(nRow, nCol);
|
||
int nOldColor=dc.GetColor();
|
||
if(nColor>0) {
|
||
pCellText->setColorIndex(nColor);
|
||
dc.SetColor(nColor);
|
||
}
|
||
pCellText->SetHeight(nTextHeight);
|
||
pCellText->SetStyleId(idTextStyle);
|
||
pCellText->SetText(pszText);
|
||
InitTextInBox(*pCellText, ptBase, w, h, nOffset,
|
||
GetCellHorMode(nRow, nCol), GetCellVerMode(nRow, nCol));
|
||
XPoint ptLoc=pCellText->GetLocation();
|
||
ptLoc.TransformBy(mat);
|
||
pCellText->SetLocation(ptLoc);
|
||
pCellText->SetRotation(m_nRotation);
|
||
if(dc.IsFullExplode())
|
||
pCellText->ExplodeOrDraw2d(dc);
|
||
else
|
||
dc.DrawEntity(*pCellText);
|
||
if(nColor>0)
|
||
dc.SetColor(nOldColor);
|
||
delete pCellText;
|
||
}
|
||
}
|
||
|
||
// 绘制单元格文本
|
||
void
|
||
TDbSheet::DrawCellText(XPoint ptTopLeft, XExplodeDraw &dc, int &nGsMarker) const
|
||
{
|
||
int nRowNum=GetRowNum();
|
||
int nColNum=GetColumnNum();
|
||
INT_PTR nQuickMarker=GetQuickMarker();
|
||
for(int iRow=0; iRow<nRowNum; iRow++) {
|
||
for(int iCol=0; iCol<nColNum; iCol++) {
|
||
if(nGsMarker) {
|
||
dc.SetSelectionMarker(nGsMarker);
|
||
nGsMarker++;
|
||
//捕捉加速
|
||
if(nQuickMarker && (nGsMarker-1)!=nQuickMarker)
|
||
continue;//用于捕捉时加速
|
||
}
|
||
DrawCellText(iRow, iCol, ptTopLeft, dc);
|
||
}
|
||
}
|
||
|
||
int nLen=m_ranges.Length();
|
||
for(int i=0; i<nLen; i++) {
|
||
if(nGsMarker) {
|
||
dc.SetSelectionMarker(nGsMarker);
|
||
nGsMarker++;
|
||
//捕捉加速
|
||
if(nQuickMarker && (nGsMarker-1)!=nQuickMarker)
|
||
continue;//用于捕捉时加速
|
||
}
|
||
DrawRangeText(m_ranges[i], ptTopLeft, dc);
|
||
}
|
||
}
|
||
TSubText* TDbSheet::HitTestText(XPoint pt)const
|
||
{
|
||
long row=HitTestOnRow(pt),col=HitTestOnColumn(pt);
|
||
if(row==-1&&col>=0&&col<GetColumnNum())
|
||
return GetSubText(0);
|
||
else if(row>=0&&row<GetRowNum()&&col>=0&&col<GetColumnNum())
|
||
{
|
||
const TGridCell* pCell=(*this)(row,col);
|
||
if(pCell->IsRange())
|
||
{
|
||
((DList<TGridRange>&)m_ranges).FindNode(pCell->GetRange(), CompareRange);
|
||
return GetSubText(GetRowNum()*GetColumnNum()+1+m_ranges.CurPosition());
|
||
}
|
||
else
|
||
return GetSubText(row*GetColumnNum()+col+1);
|
||
}
|
||
return NULL;
|
||
}
|
||
TSubText* TDbSheet::GetSubText(long iText)const
|
||
{
|
||
extern BOOL g_bExplodeSubText;
|
||
XPushMemVar<BOOL> vTemp(TchGeLib::g_bExplodeSubText,TRUE);
|
||
|
||
TDbText* pText=GetText(iText);
|
||
if(pText==NULL)
|
||
return NULL;
|
||
TSubText*pSubText= new TSubText(objectId(),pText,iText);
|
||
pSubText->SetMultiLine(true);
|
||
if(iText!=0)//cell
|
||
pSubText->SetMenuType(5);
|
||
return pSubText;
|
||
}
|
||
void TDbSheet::SetSubText(long i,CString sText)
|
||
{
|
||
if(i==0)
|
||
SetTitleText(sText);
|
||
else
|
||
{
|
||
i--;
|
||
assertWriteEnabled();
|
||
if(i<GetRowNum()*GetColumnNum())
|
||
{
|
||
long row=i/GetColumnNum(),col=i%GetColumnNum();
|
||
(*this)(row,col)->SetText(sText);
|
||
}
|
||
else
|
||
{
|
||
i-=GetRowNum()*GetColumnNum();
|
||
m_ranges[i]->SetText(sText);
|
||
}
|
||
}
|
||
}
|
||
long TDbSheet::GetNextSubTextIndex(long i,bool bVert,bool bPre)const
|
||
{
|
||
if(GetRowNum()==0||GetColumnNum()==0)
|
||
return i;
|
||
|
||
long trueRowNum=GetRowNum()+m_title.IsVisible();
|
||
long curRow,curCol,curRowMax,curColMax;
|
||
long nextRow,nextCol;
|
||
if(i==0)
|
||
{
|
||
curRow=curRowMax=0;
|
||
curCol=curColMax=0;
|
||
}
|
||
else
|
||
{
|
||
i--;
|
||
if(i<GetRowNum()*GetColumnNum())
|
||
{
|
||
curRow=curRowMax=i/GetColumnNum()+m_title.IsVisible();
|
||
curCol=curColMax=i%GetColumnNum();
|
||
}
|
||
else
|
||
{
|
||
i-=GetRowNum()*GetColumnNum();
|
||
const TGridRange*pRange=&m_ranges[i];
|
||
curRow=pRange->GetCoord(TRUE)+m_title.IsVisible();
|
||
curCol=pRange->GetCoord(FALSE);
|
||
curRowMax=pRange->GetCoordMax(TRUE)+m_title.IsVisible();
|
||
curColMax=pRange->GetCoordMax(FALSE);
|
||
}
|
||
}
|
||
|
||
if(bVert)
|
||
{
|
||
if(bPre)
|
||
nextRow=(curRow-1+trueRowNum)%trueRowNum;
|
||
else
|
||
nextRow=(curRowMax+1)%trueRowNum;
|
||
nextCol=curCol;
|
||
}
|
||
else
|
||
{
|
||
if(bPre)
|
||
nextCol=(curCol-1+GetColumnNum())%GetColumnNum();
|
||
else
|
||
nextCol=(curColMax+1)%GetColumnNum();
|
||
nextRow=curRow;
|
||
}
|
||
|
||
if(m_title.IsVisible())
|
||
{
|
||
if(nextRow==0)
|
||
return 0;
|
||
else
|
||
nextRow--;
|
||
}
|
||
|
||
const TGridCell* pCell=(*this)(nextRow,nextCol);
|
||
if(pCell->IsRange())
|
||
{
|
||
((DList<TGridRange>&)m_ranges).FindNode(pCell->GetRange(), CompareRange);
|
||
return GetRowNum()*GetColumnNum()+1+m_ranges.CurPosition();
|
||
}
|
||
else
|
||
return nextRow*GetColumnNum()+nextCol+1;
|
||
}
|
||
// cookies--0,标题
|
||
// 接着是正常的单元格
|
||
// 然后是合并单元格
|
||
TDbText * TDbSheet::GetText(Adesk::UInt32 cookies) const
|
||
{
|
||
TDbText *pDbText=NULL;
|
||
if(cookies==0) //title
|
||
{
|
||
if(!m_title.m_sText&&!g_bExplodeSubText)
|
||
return NULL;
|
||
BOOL bIncludeTitle=(m_title.m_divider.m_nFlag!=TDividerStyle::kNone);
|
||
double nTitleHeight = GetTitleHeight(FALSE);
|
||
double nTitleWidth = GetSheetWidth(FALSE);
|
||
|
||
//左上角为ptBase
|
||
XPoint ptBase=GetTopLeft(bIncludeTitle);
|
||
if(!bIncludeTitle)
|
||
ads_polar(XPoint(ptBase), Layout2Wcs(m_nRotation)+PI/2, nTitleHeight, ptBase);
|
||
ads_matrix mat;
|
||
ptBase.GetRotationMatrix(Layout2Wcs(m_nRotation), mat);
|
||
|
||
double nOffset=GetTitleLineSpace(FALSE);
|
||
double nTextHeight=GetTitleTextHeight(TRUE);
|
||
AcDbObjectId idTextStyle=GetTitleTextStyle();
|
||
|
||
TDbText textLine;
|
||
textLine.setPropertiesFrom(this);
|
||
textLine.SetHeight(nTextHeight);
|
||
textLine.SetStyleId(idTextStyle);
|
||
textLine.SetText(m_title.m_sText);
|
||
TCHAR *bHardMText=(TCHAR*)_tcschr(m_title.GetText(), _T('\n'));
|
||
|
||
if(bHardMText ||
|
||
(textLine.GetExtents().x + nOffset*2 > nTitleWidth && IsTitleWrapEnabled())
|
||
)
|
||
{
|
||
TDbMText *pTextSeg=new TDbMText;
|
||
pDbText=pTextSeg;
|
||
pDbText->setPropertiesFrom(this);
|
||
TDbMText &textSeg=*pTextSeg;
|
||
textSeg.SetLineSpace(nOffset, FALSE);
|
||
textSeg.SetPageWidth(nTitleWidth-2*nOffset, FALSE);
|
||
}
|
||
else
|
||
{
|
||
pDbText=new TDbText;
|
||
pDbText->setPropertiesFrom(this);
|
||
}
|
||
|
||
Adesk::UInt16 nColor=GetTitleTextColor();
|
||
if(nColor>0)
|
||
pDbText->setColorIndex(nColor);
|
||
|
||
pDbText->SetHeight(nTextHeight);
|
||
pDbText->SetStyleId(idTextStyle);
|
||
pDbText->SetText(m_title.m_sText);
|
||
InitTextInBox(*pDbText, ptBase, nTitleWidth, nTitleHeight, nOffset,
|
||
GetTitleHorMode(), GetTitleVerMode());
|
||
XPoint ptLoc=pDbText->GetLocation();
|
||
ptLoc.TransformBy(mat);
|
||
pDbText->SetLocation(ptLoc);
|
||
pDbText->SetRotation(m_nRotation);
|
||
}
|
||
else
|
||
{
|
||
cookies--;
|
||
int nRowNum=GetRowNum();
|
||
int nColNum=GetColumnNum();
|
||
XPoint ptTopLeft=GetTopLeft(FALSE);
|
||
if((int)cookies<nRowNum*nColNum) //cells array
|
||
{
|
||
int nRow=cookies/nColNum;
|
||
int nCol=cookies-(nRow*nColNum);
|
||
|
||
const TGridCell &cell=*(*this)(nRow, nCol);
|
||
if(cell.IsRange())
|
||
return NULL;
|
||
double x=GetColumnsWidth(0, nCol-1, FALSE);
|
||
double y=GetRowsHeight(0, nRow-1, FALSE);
|
||
double w, h;
|
||
w=GetColumnWidth(nCol, FALSE);
|
||
h=GetRowHeight(nRow, FALSE);
|
||
|
||
//左上角为ptBase
|
||
XPoint ptBase;
|
||
ads_polar(ptTopLeft, Layout2Wcs(m_nRotation), x, ptBase);
|
||
ads_polar(XPoint(ptBase), Layout2Wcs(m_nRotation)-PI/2, y, ptBase);
|
||
const TCHAR *pszText=cell.GetText();
|
||
if(!pszText[0]&&!g_bExplodeSubText)
|
||
return NULL;
|
||
ads_matrix mat;
|
||
ptBase.GetRotationMatrix(Layout2Wcs(m_nRotation), mat);
|
||
|
||
|
||
double nOffset=GetCellLineSpace(nRow, nCol, FALSE);
|
||
double nTextHeight=GetCellTextHeight(nRow, nCol, TRUE);
|
||
AcDbObjectId idTextStyle=GetCellTextStyle(nRow, nCol);
|
||
|
||
TDbText textLine;
|
||
textLine.setPropertiesFrom(this);
|
||
textLine.SetHeight(nTextHeight);
|
||
textLine.SetStyleId(idTextStyle);
|
||
textLine.SetText(pszText);
|
||
|
||
TCHAR *bHardMText=(TCHAR*)_tcschr(pszText, _T('\n'));
|
||
if(bHardMText || (textLine.GetExtents().x + nOffset*2.0 > w && IsCellWrapEnabled(nRow, nCol)))
|
||
{
|
||
pDbText=new TDbMText;
|
||
pDbText->setPropertiesFrom(this);
|
||
TDbMText &textSeg=*(TDbMText *)pDbText;
|
||
textSeg.SetLineSpace(nOffset, FALSE);
|
||
textSeg.SetPageWidth(w-2*nOffset, FALSE);
|
||
}
|
||
else
|
||
{
|
||
pDbText=new TDbText;
|
||
pDbText->setPropertiesFrom(this);
|
||
}
|
||
|
||
Adesk::UInt16 nColor=GetCellTextColor(nRow, nCol);
|
||
if(nColor>0)
|
||
pDbText->setColorIndex(nColor);
|
||
pDbText->SetHeight(nTextHeight);
|
||
pDbText->SetStyleId(idTextStyle);
|
||
pDbText->SetText(pszText);
|
||
InitTextInBox(*pDbText, ptBase, w, h, nOffset,
|
||
GetCellHorMode(nRow, nCol), GetCellVerMode(nRow, nCol));
|
||
XPoint ptLoc=pDbText->GetLocation();
|
||
ptLoc.TransformBy(mat);
|
||
pDbText->SetLocation(ptLoc);
|
||
pDbText->SetRotation(m_nRotation);
|
||
}
|
||
else //ranges
|
||
{
|
||
cookies -= nRowNum*nColNum;
|
||
if((int)cookies>=m_ranges.Length())
|
||
return NULL;
|
||
|
||
const TGridRange &range=m_ranges[cookies];
|
||
const TCHAR *pszText=range.GetText();
|
||
if(!pszText[0]&&!g_bExplodeSubText)
|
||
return NULL;
|
||
|
||
double x=GetColumnsWidth(0, range.m_nColumn-1, FALSE);
|
||
double y=GetRowsHeight(0, range.m_nRow-1, FALSE);
|
||
double w, h;
|
||
w=GetColumnsWidth(range.m_nColumn, range.m_nColumnMax, FALSE);
|
||
h=GetRowsHeight(range.m_nRow, range.m_nRowMax, FALSE);
|
||
|
||
//左上角为ptBase
|
||
XPoint ptBase;
|
||
ads_polar(ptTopLeft, Layout2Wcs(m_nRotation), x, ptBase);
|
||
ads_polar(XPoint(ptBase), Layout2Wcs(m_nRotation)-PI/2, y, ptBase);
|
||
ads_matrix mat;
|
||
ptBase.GetRotationMatrix(Layout2Wcs(m_nRotation), mat);
|
||
|
||
int nRow=range.m_nRow;
|
||
int nCol=range.m_nColumn;
|
||
|
||
// 与正常单元格一样的处理方法
|
||
double nOffset=GetCellLineSpace(nRow, nCol, FALSE);
|
||
double nTextHeight=GetCellTextHeight(nRow, nCol, TRUE);
|
||
AcDbObjectId idTextStyle=GetCellTextStyle(nRow, nCol);
|
||
|
||
TDbText textLine;
|
||
textLine.setPropertiesFrom(this);
|
||
textLine.SetHeight(nTextHeight);
|
||
textLine.SetStyleId(idTextStyle);
|
||
textLine.SetText(pszText);
|
||
|
||
TCHAR *bHardMText=(TCHAR*)_tcschr(pszText, _T('\n'));
|
||
if(bHardMText || (textLine.GetExtents().x + nOffset*2.0 > w && IsCellWrapEnabled(nRow, nCol)))
|
||
{
|
||
pDbText=new TDbMText;
|
||
pDbText->setPropertiesFrom(this);
|
||
TDbMText &textSeg=*(TDbMText *)pDbText;
|
||
textSeg.SetLineSpace(nOffset, FALSE);
|
||
textSeg.SetPageWidth(w-2*nOffset, FALSE);
|
||
}
|
||
else
|
||
{
|
||
pDbText=new TDbText;
|
||
pDbText->setPropertiesFrom(this);
|
||
}
|
||
|
||
Adesk::UInt16 nColor=GetCellTextColor(nRow, nCol);
|
||
if(nColor>0)
|
||
pDbText->setColorIndex(nColor);
|
||
pDbText->SetHeight(nTextHeight);
|
||
pDbText->SetStyleId(idTextStyle);
|
||
pDbText->SetText(pszText);
|
||
InitTextInBox(*pDbText, ptBase, w, h, nOffset,
|
||
GetCellHorMode(nRow, nCol), GetCellVerMode(nRow, nCol));
|
||
XPoint ptLoc=pDbText->GetLocation();
|
||
ptLoc.TransformBy(mat);
|
||
pDbText->SetLocation(ptLoc);
|
||
pDbText->SetRotation(m_nRotation);
|
||
}
|
||
}
|
||
return pDbText;
|
||
}
|
||
// 对某一行初始化分割线的属性, 如果没有分割线则返回FALSE
|
||
BOOL TDbSheet::InitRowDivider(AcDbPolyline &pline, int nRow) const
|
||
{
|
||
const TSheetRow &row=m_rows[nRow];
|
||
if(row.m_divider.m_nFlag==TDividerStyle::kNone)
|
||
return FALSE;
|
||
const TDividerStyle ÷r=row.m_divider.m_nFlag==TDividerStyle::kLocal ?
|
||
row.m_divider : m_rowDivider;
|
||
|
||
BOOL bRet=TRUE;
|
||
pline.setPropertiesFrom(this);
|
||
switch(divider.m_nFlag) {
|
||
case TDividerStyle::kLocal:
|
||
if(!!divider.m_idLineType)
|
||
pline.setLinetype(divider.m_idLineType);
|
||
if(divider.m_nLineWidth>0.0 && !!objectId())
|
||
pline.setConstantWidth(divider.m_nLineWidth*GetPScale());
|
||
if(divider.m_nColor>0)
|
||
pline.setColorIndex(divider.m_nColor);
|
||
break;
|
||
case TDividerStyle::kParent:
|
||
break;
|
||
case TDividerStyle::kNone:
|
||
default:
|
||
bRet=FALSE;
|
||
break;
|
||
}
|
||
return bRet;
|
||
}
|
||
|
||
|
||
// 对某一列初始化分割线的属性, 如果没有分割线则返回FALSE
|
||
BOOL TDbSheet::InitColumnDivider(AcDbPolyline &pline, int nCol) const
|
||
{
|
||
const TSheetColumn &column=m_columns[nCol];
|
||
if(column.m_divider.m_nFlag==TDividerStyle::kNone)
|
||
return FALSE;
|
||
const TDividerStyle ÷r=column.m_divider.m_nFlag==TDividerStyle::kLocal ?
|
||
column.m_divider : m_colDivider;
|
||
|
||
BOOL bRet=TRUE;
|
||
pline.setPropertiesFrom(this);
|
||
switch(divider.m_nFlag) {
|
||
case TDividerStyle::kLocal:
|
||
if(!!divider.m_idLineType)
|
||
pline.setLinetype(divider.m_idLineType);
|
||
if(divider.m_nLineWidth>0.0 && !!objectId())
|
||
pline.setConstantWidth(divider.m_nLineWidth*GetPScale());
|
||
if(divider.m_nColor>0)
|
||
pline.setColorIndex(divider.m_nColor);
|
||
break;
|
||
case TDividerStyle::kParent:
|
||
break;
|
||
case TDividerStyle::kNone:
|
||
default:
|
||
bRet=FALSE;
|
||
break;
|
||
}
|
||
return bRet;
|
||
}
|
||
|
||
|
||
|
||
///////////////////////////////////////////////
|
||
// Helper Method
|
||
|
||
// 强制下级继承上级属性
|
||
void TDbSheet::DescInheritGridStyle()
|
||
{
|
||
assertWriteEnabled();
|
||
int nRowNum=GetRowNum();
|
||
int nColNum=GetColumnNum();
|
||
for(int iRow=0; iRow<nRowNum; iRow++) {
|
||
TSheetRow *pRow=m_rows[iRow];
|
||
pRow->m_nVerMode=AcDb::kTextBase;
|
||
}
|
||
for(int iCol=0; iCol<nColNum; iCol++) {
|
||
TSheetColumn *pCol=m_columns[iCol];
|
||
pCol->m_gridStyle.SetOverrideAll(FALSE);
|
||
}
|
||
for(iRow=0; iRow<nRowNum; iRow++) {
|
||
for(iCol=0; iCol<nColNum; iCol++) {
|
||
TGridCell *pCell=(*this)(iRow, iCol);
|
||
TGridStyle &grid=pCell->GetGridStyle();
|
||
grid.SetOverrideAll(FALSE);
|
||
}
|
||
}
|
||
}
|
||
|
||
// 下属行继承特性
|
||
void TDbSheet::DescInheritRowDivider(bool bIncludeRowHeight)
|
||
{
|
||
assertWriteEnabled();
|
||
int nRowNum=GetRowNum();
|
||
for(int iRow=0; iRow<nRowNum; iRow++) {
|
||
TSheetRow *pRow=m_rows[iRow];
|
||
pRow->m_divider.SetDividerFlag(TDividerStyle::kParent);
|
||
if(bIncludeRowHeight) {
|
||
pRow->SetHeight(m_nRowHeight);
|
||
pRow->SetRowHeightStyle(TSheetRow::kParent);
|
||
}
|
||
}
|
||
}
|
||
|
||
void TDbSheet::DescInheritColDivider()
|
||
{
|
||
assertWriteEnabled();
|
||
int nColNum=GetColumnNum();
|
||
for(int iCol=0; iCol<nColNum; iCol++) {
|
||
m_columns[iCol]->m_divider.SetDividerFlag(TDividerStyle::kParent);
|
||
}
|
||
}
|
||
|
||
void TDbSheet::DescInheritColGridStyle(int iCol)
|
||
{
|
||
assertWriteEnabled();
|
||
int nRowNum=GetRowNum();
|
||
for(int iRow=0; iRow<nRowNum; iRow++) {
|
||
TGridCell *pCell=(*this)(iRow, iCol);
|
||
TGridStyle &grid=pCell->GetGridStyle();
|
||
BOOL bOver=grid.TestFlagBit(OF_VERMODE);
|
||
grid.SetOverrideAll(FALSE);
|
||
if(bOver) {
|
||
grid.SetFlagBit(OF_VERMODE, TRUE);
|
||
}
|
||
}
|
||
}
|
||
|
||
void TDbSheet::DescInheritRowGridStyle(int iRow)
|
||
{
|
||
assertWriteEnabled();
|
||
int nColNum=GetColumnNum();
|
||
for(int iCol=0; iCol<nColNum; iCol++) {
|
||
TGridCell *pCell=(*this)(iRow, iCol);
|
||
TGridStyle &grid=pCell->GetGridStyle();
|
||
grid.SetFlagBit(OF_VERMODE, FALSE);
|
||
}
|
||
}
|
||
|
||
|
||
XPoint TDbSheet::Align2Base(XPoint ptAlign, XPoint ext) const
|
||
{
|
||
XPoint ptBase=XExplodeDraw::Align2Base(m_nAlignment, ptAlign, ext);
|
||
ads_matrix mat;
|
||
ptAlign.GetRotationMatrix(Layout2Wcs(m_nRotation), mat);
|
||
ptBase.TransformBy(mat);
|
||
return ptBase;
|
||
}
|
||
|
||
XPoint TDbSheet::Base2Align(XPoint ptBase, XPoint ext) const
|
||
{
|
||
XPoint ptAlign=XExplodeDraw::Base2Align(m_nAlignment, ptBase, ext);
|
||
ads_matrix mat;
|
||
ptBase.GetRotationMatrix(Layout2Wcs(m_nRotation), mat);
|
||
ptAlign.TransformBy(mat);
|
||
return ptAlign;
|
||
}
|
||
|
||
// 按行列取得单元格
|
||
TGridCell * TDbSheet::operator () (int nRow, int nCol)
|
||
{
|
||
return &m_pCells[nRow*GetColumnNum()+nCol];
|
||
}
|
||
// 按行列取得单元格
|
||
const TGridCell * TDbSheet::operator () (int nRow, int nCol) const
|
||
{
|
||
TDbSheet *pThis=(TDbSheet *)this;
|
||
return (*pThis)(nRow, nCol);
|
||
}
|
||
|
||
int TDbSheet::HitTestOnColumn(XPoint pt) const
|
||
{
|
||
pt.z=0;
|
||
int nColNum=m_columns.Length();
|
||
XPoint ptTopLeft=GetTopLeft(FALSE);
|
||
double nColWidth=0.0;
|
||
double nRotWcs=Layout2Wcs(m_nRotation);
|
||
for(int n=0; n<nColNum; n++) {
|
||
XLine lnLeft(ptTopLeft, nRotWcs+PI/2);
|
||
nColWidth=GetColumnWidth(n, FALSE);
|
||
ads_polar(XPoint(ptTopLeft), nRotWcs, nColWidth, ptTopLeft);
|
||
XLine lnRight(ptTopLeft, nRotWcs+PI/2);
|
||
int nSide1=lnLeft.OnWhichSide(pt);
|
||
int nSide2=lnRight.OnWhichSide(pt);
|
||
if(nSide1==OFFSET_LEFT && n==0)
|
||
return COL_PREVFIRST;
|
||
if(nSide1==OFFSET_RIGHT && nSide2==OFFSET_LEFT)
|
||
{
|
||
double d1=pt.Distance(&lnLeft),d2=pt.Distance(&lnRight);
|
||
double distPre=(d1+d2)/20.0;
|
||
if(d1<distPre||d2<distPre)
|
||
return COL_NEXTLAST;
|
||
return n;
|
||
}
|
||
}
|
||
return COL_NEXTLAST;
|
||
}
|
||
|
||
int TDbSheet::HitTestOnRow(XPoint pt) const
|
||
{
|
||
pt.z=0;
|
||
int nRowNum=m_rows.Length();
|
||
XPoint ptTopLeft=GetTopLeft(FALSE);
|
||
double nRotWcs=Layout2Wcs(m_nRotation);
|
||
for(int n=0; n<nRowNum; n++) {
|
||
XLine lnUp(ptTopLeft, nRotWcs);
|
||
double nRowHeight=GetRowHeight(n, FALSE);
|
||
ads_polar(XPoint(ptTopLeft), nRotWcs-PI/2, nRowHeight, ptTopLeft);
|
||
XLine lnDown(ptTopLeft, nRotWcs);
|
||
int nSide1=lnUp.OnWhichSide(pt);
|
||
int nSide2=lnDown.OnWhichSide(pt);
|
||
if(nSide1==OFFSET_LEFT && n==0)
|
||
{
|
||
double d=GetTitleHeight(FALSE);
|
||
double d1=pt.Distance(&lnUp);
|
||
double d2=d-d1;
|
||
double distPre=(d1+d2)/20.0;
|
||
|
||
if(d1<distPre||d2<distPre)
|
||
return COL_NEXTLAST;
|
||
|
||
return ROW_PREVFIRST;
|
||
}
|
||
if(nSide1==OFFSET_RIGHT && nSide2==OFFSET_LEFT)
|
||
{
|
||
double d1=pt.Distance(&lnUp),d2=pt.Distance(&lnDown);
|
||
double distPre=(d1+d2)/20.0;
|
||
if(d1<distPre||d2<distPre)
|
||
return COL_NEXTLAST;
|
||
return n;
|
||
}
|
||
}
|
||
return ROW_NEXTLAST;
|
||
}
|
||
|
||
const TGridCell *
|
||
TDbSheet::HitTestOnCell(XPoint pt, int *pRow, int *pCol) const
|
||
{
|
||
pt.z=0;
|
||
int nRowNum=GetRowNum();
|
||
int nColNum=GetColumnNum();
|
||
double nRotWcs=Layout2Wcs(m_nRotation);
|
||
for(int iRow=0; iRow<nRowNum; iRow++) {
|
||
for(int iCol=0; iCol<nColNum; iCol++) {
|
||
XPoint ptTopLeft = GetCellPoint(iRow, iCol);
|
||
XPoint szCell = GetCellSize(iRow, iCol, FALSE);
|
||
XPoint ptBotLeft, ptBotRight, ptTopRight;
|
||
ads_polar(ptTopLeft, nRotWcs, szCell.x, ptTopRight);
|
||
ads_polar(ptTopLeft, nRotWcs-PI/2, szCell.y, ptBotLeft);
|
||
ads_polar(ptTopRight, nRotWcs-PI/2, szCell.y, ptBotRight);
|
||
|
||
XPoly2D poly(1);
|
||
poly.AppendNode(ptTopLeft);
|
||
poly.AppendNode(ptBotLeft);
|
||
poly.AppendNode(ptBotRight);
|
||
poly.AppendNode(ptTopRight);
|
||
poly.SetElevation(0.0);
|
||
if((pt&poly)==PR_INSIDE) {
|
||
if(pRow) *pRow=iRow;
|
||
if(pCol) *pCol=iCol;
|
||
return (*this)(iRow, iCol);
|
||
}
|
||
}
|
||
}
|
||
return NULL;
|
||
}
|
||
|
||
// 单元分解
|
||
BOOL TDbSheet::ExplodeCell(int nRow, int nCol)
|
||
{
|
||
assertWriteEnabled();
|
||
TGridCell *pCell=(*this)(nRow, nCol);
|
||
if(!pCell || !pCell->GetRange())
|
||
return FALSE;
|
||
const TGridRange *pRange=pCell->GetRange();
|
||
for(int iRow=pRange->GetCoord(TRUE); iRow<=pRange->GetCoordMax(TRUE); iRow++) {
|
||
for(int iCol=pRange->GetCoord(FALSE); iCol<=pRange->GetCoordMax(FALSE); iCol++) {
|
||
TGridCell *pCell0=(*this)(iRow, iCol);
|
||
if(pCell0) {
|
||
CopyObject(*(TGridCell *)pRange, *pCell0);
|
||
pCell0->SetRange(NULL);
|
||
}
|
||
}
|
||
}
|
||
int nRanNum=m_ranges.Length();
|
||
for(int i=0; i<nRanNum; i++) {
|
||
if(m_ranges[i]==pRange) {
|
||
m_ranges.Remove();
|
||
break;
|
||
}
|
||
}
|
||
return TRUE;
|
||
}
|
||
|
||
// 合并单元格
|
||
void
|
||
TDbSheet::MergeCells(int nRowFrom, int nColFrom, int nRowTo, int nColTo)
|
||
{
|
||
assertWriteEnabled();
|
||
if(nRowTo<nRowFrom || nColTo<nColFrom)
|
||
return;
|
||
if(nRowFrom==nRowTo && nColFrom==nColTo)
|
||
return;
|
||
|
||
TGridRange *pRange=NULL;
|
||
TGridCell *pMaster=(*this)(nRowFrom, nColFrom); //左上角
|
||
if(pMaster->IsRange()) {
|
||
pRange=(TGridRange *)pMaster->GetRange();
|
||
ASSERT(pRange->GetCoord(TRUE)==nRowFrom &&
|
||
pRange->GetCoord(FALSE)==nColFrom);
|
||
ASSERT(pRange->GetCoordMax(TRUE)<=nRowTo);
|
||
ASSERT(pRange->GetCoordMax(FALSE)<=nColTo);
|
||
pRange->SetCoord(nRowFrom, nColFrom);
|
||
pRange->SetCoordMax(nRowTo, nColTo);
|
||
} else {
|
||
pRange=new TGridRange;
|
||
CopyObject(pMaster->m_gridStyle, pRange->m_gridStyle);
|
||
pRange->m_gridStyle.SetFlagBit(OF_HORMODE);
|
||
pRange->m_gridStyle.SetFlagBit(OF_VERMODE);
|
||
pRange->m_gridStyle.SetHorMode(AcDb::kTextCenter);
|
||
pRange->m_gridStyle.SetVerMode(AcDb::kTextVertMid);
|
||
pRange->SetText(pMaster->GetText());
|
||
pRange->SetCoord(nRowFrom, nColFrom);
|
||
pRange->SetCoordMax(nRowTo, nColTo);
|
||
m_ranges.Append(pRange);
|
||
}
|
||
|
||
for(int iRow=nRowFrom; iRow<=nRowTo; iRow++) {
|
||
for(int iCol=nColFrom; iCol<=nColTo; iCol++) {
|
||
TGridCell *pSlaver=(*this)(iRow, iCol);
|
||
if(pSlaver->IsRange()) { //其他的合并单元格,则予以删除
|
||
const TGridRange *pSlaverRange=pSlaver->GetRange();
|
||
if(pSlaverRange!=pRange) {
|
||
if(m_ranges.FindNode(pSlaverRange, CompareRange))
|
||
m_ranges.Remove();
|
||
}
|
||
}
|
||
pSlaver->SetRange(pRange);
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
void
|
||
TDbSheet::CalculateRowHeight(int nRowFrom, int nRowTo)
|
||
{
|
||
assertWriteEnabled();
|
||
for(int i=nRowFrom; i<=nRowTo; i++)
|
||
CalculateRowHeight(i);
|
||
}
|
||
|
||
//当行的文字改变时, 重新计算行高
|
||
void
|
||
TDbSheet::CalculateRowHeight(int nRow)
|
||
{
|
||
assertWriteEnabled();
|
||
TSheetRow *row=m_rows[nRow];
|
||
if(row->GetRowHeightStyle()==TSheetRow::kAutomatic) {
|
||
int nColNum=GetColumnNum();
|
||
XPoint ptTopLeft=GetTopLeft(FALSE);
|
||
double nSizeHeight=0.0; //row->GetHeight()*GetPScale();
|
||
for(int iCol=0; iCol<nColNum; iCol++) {
|
||
double nOffset=GetCellLineSpace(nRow, iCol, FALSE);
|
||
const TCHAR *szText=(*this)(nRow, iCol)->GetText();
|
||
/*
|
||
AcDbObjectId idBlock;
|
||
XPoint sizeBlock;
|
||
if(IsBlockInsert(szText, idBlock, sizeBlock)) {
|
||
if(nSizeHeight<1.0E-3)
|
||
nSizeHeight= sizeBlock.y+nOffset*2.0;
|
||
else
|
||
nSizeHeight = max(nSizeHeight, sizeBlock.y+nOffset*2.0);
|
||
continue;
|
||
}*/
|
||
AcDbVoidPtrArray entSet;
|
||
XExplodeStream dc(entSet);
|
||
DrawCellText(nRow, iCol, ptTopLeft, dc);
|
||
|
||
int nCount=entSet.length();
|
||
if(nCount>0) {
|
||
AcDbEntity *pEnt=(AcDbEntity *)entSet[0];
|
||
if(pEnt->isKindOf(TDbText::desc())) {
|
||
TDbText *pText=(TDbText *)pEnt;
|
||
XPoint ext=pText->GetExtents();
|
||
if(nSizeHeight<1.0E-3)
|
||
nSizeHeight= ext.y+nOffset*2.0;
|
||
else
|
||
nSizeHeight = max(nSizeHeight, ext.y+nOffset*2.0);
|
||
} /*else if(pEnt->isKindOf(AcDbBlockReference::desc())) {
|
||
TBlockGeomInfo info;
|
||
info.SetFromInsert(AcDbBlockReference::cast(pEnt));
|
||
double nOffset=GetCellLineSpace(nRow, iCol, FALSE);
|
||
if(nSizeHeight<1.0E-3)
|
||
nSizeHeight= info.GetSizeY()+nOffset*2.0;
|
||
else
|
||
nSizeHeight = max(nSizeHeight, info.GetSizeY()+nOffset*2.0);
|
||
}*/
|
||
}
|
||
}
|
||
if(nSizeHeight>1.0E-3)
|
||
row->SetHeight(nSizeHeight/GetPScale());
|
||
}
|
||
}
|
||
|
||
// 复制行内容和属性(包括单元格)
|
||
BOOL TDbSheet::CopyRow(int nSrc, int nDest)
|
||
{
|
||
//add by whl on 060223
|
||
if(nSrc<0||nSrc>=GetRowNum()||
|
||
nDest<0||nDest>=GetRowNum())
|
||
return FALSE;
|
||
|
||
assertWriteEnabled();
|
||
|
||
TSheetRow *rowSrc=m_rows[nSrc];
|
||
TSheetRow *rowDest=m_rows[nDest];
|
||
CopyObject(*rowSrc, *rowDest);
|
||
int nColNum=GetColumnNum();
|
||
|
||
//add by xlc on 071224
|
||
Array<int> nPosArray; //记录合并单元格的位置数组
|
||
|
||
for(int i=0; i<nColNum; i++) {
|
||
TGridCell *cellSrc=(*this)(nSrc, i);
|
||
TGridCell *cellDest=(*this)(nDest, i);
|
||
const TGridRange *pRange=cellDest->GetRange();
|
||
const TGridRange *pRangeSrc=cellSrc->GetRange();
|
||
const TGridCell *pSrc=pRangeSrc? (const TGridCell *)pRangeSrc : (const TGridCell *)cellSrc;
|
||
|
||
if(pRange)
|
||
CopyObject(*pSrc, *(TGridCell *)pRange);
|
||
else CopyObject(*pSrc, *cellDest);
|
||
|
||
//add by xlc on 071224
|
||
if(pRangeSrc)
|
||
{
|
||
TGridRange *pRange1=(TGridRange *)pRangeSrc;
|
||
int colIndexMin=pRange1->GetCoord(FALSE);
|
||
int colIndexMax=pRange1->GetCoordMax(FALSE);
|
||
|
||
int nNum=nPosArray.GetLength();
|
||
if(nNum < 1 || colIndexMin > nPosArray[nNum-1])
|
||
{
|
||
nPosArray.AddTail(colIndexMin);
|
||
nPosArray.AddTail(colIndexMax);
|
||
}
|
||
}
|
||
}
|
||
|
||
//add by xlc on 071224
|
||
//合并单元格
|
||
for(i=0;i<nPosArray.GetLength()-1;)
|
||
{
|
||
MergeCells(nDest,nPosArray[i],nDest,nPosArray[i+1]);
|
||
i=i+2;
|
||
}
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
// 交换列
|
||
BOOL TDbSheet::SwapColumn(int nSrc, int nDest)
|
||
{
|
||
assertWriteEnabled();
|
||
TSheetColumn *colSrc=m_columns[nSrc];
|
||
TSheetColumn *colDest=m_columns[nDest];
|
||
TchPrivate::Exchange(*colSrc, *colDest);
|
||
int nRowNum=GetRowNum();
|
||
for(int i=nRowNum-1; i>=0; i--) {
|
||
TGridCell *cellSrc=(*this)(i, nSrc);
|
||
TGridCell *cellDest=(*this)(i, nDest);
|
||
const TGridRange *pRangeSrc=cellSrc->GetRange();
|
||
const TGridRange *pRangeDest=cellDest->GetRange();
|
||
TGridCell cellTemp;
|
||
if(pRangeSrc) {
|
||
CopyObject(*(const TGridCell *)pRangeSrc, cellTemp);
|
||
if(pRangeDest) {
|
||
if(i==pRangeSrc->GetCoord(TRUE))
|
||
CopyObject(*(const TGridCell*)pRangeDest, *(TGridCell *)pRangeSrc);
|
||
if(i==pRangeDest->GetCoord(TRUE))
|
||
CopyObject(cellTemp, *(TGridCell *)pRangeDest);
|
||
} else {
|
||
if(i==pRangeSrc->GetCoord(TRUE))
|
||
CopyObject(*cellDest, *(TGridCell *)pRangeSrc);
|
||
CopyObject(cellTemp, *cellDest);
|
||
}
|
||
} else {
|
||
CopyObject(*cellSrc, cellTemp);
|
||
if(pRangeDest) {
|
||
CopyObject(*(const TGridCell*)pRangeDest, *cellSrc);
|
||
if(i==pRangeDest->GetCoord(TRUE))
|
||
CopyObject(cellTemp, *(TGridCell *)pRangeDest);
|
||
} else {
|
||
CopyObject(*cellDest, *cellSrc);
|
||
CopyObject(cellTemp, *cellDest);
|
||
}
|
||
}
|
||
|
||
cellSrc->SetRange((TGridRange *)pRangeSrc);
|
||
cellDest->SetRange((TGridRange *)pRangeDest);
|
||
}
|
||
return TRUE;
|
||
}
|
||
|
||
|
||
// 交换行
|
||
BOOL TDbSheet::SwapRow(int nSrc, int nDest)
|
||
{
|
||
assertWriteEnabled();
|
||
TSheetRow *rowSrc=m_rows[nSrc];
|
||
TSheetRow *rowDest=m_rows[nDest];
|
||
TchPrivate::Exchange(*rowSrc, *rowDest);
|
||
int nColNum=GetColumnNum();
|
||
for(int i=nColNum-1; i>=0; i--) {
|
||
TGridCell *cellSrc=(*this)(nSrc, i);
|
||
TGridCell *cellDest=(*this)(nDest, i);
|
||
const TGridRange *pRangeSrc=cellSrc->GetRange();
|
||
const TGridRange *pRangeDest=cellDest->GetRange();
|
||
TGridCell cellTemp;
|
||
if(pRangeSrc) {
|
||
CopyObject(*(const TGridCell *)pRangeSrc, cellTemp);
|
||
if(pRangeDest) {
|
||
if(i==pRangeSrc->GetCoord(FALSE))
|
||
CopyObject(*(const TGridCell*)pRangeDest, *(TGridCell *)pRangeSrc);
|
||
if(i==pRangeDest->GetCoord(FALSE))
|
||
CopyObject(cellTemp, *(TGridCell *)pRangeDest);
|
||
} else {
|
||
if(i==pRangeSrc->GetCoord(FALSE))
|
||
CopyObject(*cellDest, *(TGridCell *)pRangeSrc);
|
||
CopyObject(cellTemp, *cellDest);
|
||
}
|
||
} else {
|
||
CopyObject(*cellSrc, cellTemp);
|
||
if(pRangeDest) {
|
||
CopyObject(*(const TGridCell*)pRangeDest, *cellSrc);
|
||
if(i==pRangeDest->GetCoord(FALSE))
|
||
CopyObject(cellTemp, *(TGridCell *)pRangeDest);
|
||
} else {
|
||
CopyObject(*cellDest, *cellSrc);
|
||
CopyObject(cellTemp, *cellDest);
|
||
}
|
||
}
|
||
|
||
cellSrc->SetRange((TGridRange *)pRangeSrc);
|
||
cellDest->SetRange((TGridRange *)pRangeDest);
|
||
}
|
||
return TRUE;
|
||
}
|
||
|
||
|
||
// 排序
|
||
//-1代表最后一列
|
||
void TDbSheet::SortByColumn(int nKeyCol, BOOL bSortAscend, int nRowFrom, int nRowTo)
|
||
{
|
||
if(nRowTo<0)
|
||
nRowTo=GetRowNum()-1;
|
||
for(int i=nRowFrom; i<=nRowTo; i++) {
|
||
for(int j=nRowFrom; j<nRowTo; j++) {
|
||
TGridCell *pCell1=(*this)(i, nKeyCol);
|
||
TGridCell *pCell2=(*this)(j, nKeyCol);
|
||
int nCmp=_tcscmp(pCell1->GetText(), pCell2->GetText());
|
||
if((bSortAscend && nCmp>0) || (!bSortAscend && nCmp<0))
|
||
SwapRow(i, j);
|
||
}
|
||
}
|
||
}
|
||
|
||
//-1代表最后一列
|
||
void TDbSheet::SortByColumns(const DList<int> &lstKeyCol, BOOL bSortAscend, int nRowFrom, int nRowTo)
|
||
{
|
||
if(nRowTo<0)
|
||
nRowTo=GetRowNum()-1;
|
||
int nColNum=lstKeyCol.Length();
|
||
for(int i=nRowFrom; i<=nRowTo; i++) {
|
||
for(int j=nRowFrom; j<nRowTo; j++) {
|
||
int nCmp=0;
|
||
for(int n=0; n<nColNum; n++) {
|
||
int nKeyCol=lstKeyCol[n];
|
||
TGridCell *pCell1=(*this)(i, nKeyCol);
|
||
TGridCell *pCell2=(*this)(j, nKeyCol);
|
||
int nCmp1=_tcscmp(pCell1->GetText(), pCell2->GetText());
|
||
if(nCmp1!=0) {
|
||
nCmp=nCmp1;
|
||
break;
|
||
}
|
||
}
|
||
if((bSortAscend && nCmp>0) || (!bSortAscend && nCmp<0))
|
||
SwapRow(i, j);
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
// 删除列
|
||
void TDbSheet::RemoveColumn(int nCol)
|
||
{
|
||
assertWriteEnabled();
|
||
ASSERT(m_pCells);
|
||
int nRowNum=GetRowNum();
|
||
int nColNum=GetColumnNum();
|
||
if(nColNum<=1)
|
||
return;
|
||
TGridCell *pCellArray=new TGridCell[nRowNum*(nColNum-1)];
|
||
for(int iCol=0; iCol<nCol; iCol++) {
|
||
for(int iRow=0; iRow<nRowNum; iRow++) {
|
||
pCellArray[iRow*(nColNum-1)+iCol]=m_pCells[iRow*nColNum+iCol];
|
||
}
|
||
}
|
||
for(iCol=nCol+1; iCol<nColNum; iCol++) {
|
||
for(int iRow=0; iRow<nRowNum; iRow++) {
|
||
pCellArray[iRow*(nColNum-1)+iCol-1]=m_pCells[iRow*nColNum+iCol];
|
||
}
|
||
}
|
||
delete []m_pCells;
|
||
m_pCells = pCellArray;
|
||
|
||
m_columns.Remove(nCol);
|
||
int nRanNum=m_ranges.Length();
|
||
for(int iRan=0; iRan<nRanNum; iRan++) {
|
||
TGridRange *pRange=m_ranges[iRan];
|
||
if(pRange->GetCoord(FALSE)==pRange->GetCoordMax(FALSE) &&
|
||
pRange->GetCoord(FALSE)==nCol) { //整个单元格在列内
|
||
m_ranges.Remove();
|
||
nRanNum--;
|
||
iRan--;
|
||
} else if(pRange->GetCoord(FALSE)>nCol) { //单元格在右边
|
||
ASSERT(pRange->GetCoordMax(FALSE)>nCol);
|
||
pRange->SetCoord(pRange->GetCoord(TRUE), pRange->GetCoord(FALSE)-1);
|
||
pRange->SetCoordMax(pRange->GetCoordMax(TRUE), pRange->GetCoordMax(FALSE)-1);
|
||
} else if(pRange->GetCoord(FALSE)<=nCol && pRange->GetCoordMax(FALSE)>=nCol) {
|
||
// 跨越列
|
||
pRange->SetCoordMax(pRange->GetCoordMax(TRUE), pRange->GetCoordMax(FALSE)-1);
|
||
if(pRange->IsCellar()) {
|
||
// 合并单元格退化为单元格
|
||
(*this)(pRange->GetCoord(TRUE), pRange->GetCoord(FALSE))->SetRange(NULL);
|
||
|
||
//add by whl on 040902,解决bug:删除列时原先的合并单元退化时丢文字
|
||
(*this)(pRange->GetCoord(TRUE), pRange->GetCoord(FALSE))->SetText(pRange->GetText());
|
||
m_ranges.Remove();
|
||
nRanNum--;
|
||
iRan--;
|
||
}
|
||
} else {
|
||
ASSERT(pRange->GetCoordMax(FALSE)<nCol); //单元格在左边
|
||
ASSERT(pRange->GetCoord(FALSE)<nCol);
|
||
// 不发生任何改动
|
||
}
|
||
}
|
||
|
||
// 重新计算行高度
|
||
CalculateRowHeight(0, GetRowNum()-1);
|
||
}
|
||
|
||
// 删除行
|
||
void TDbSheet::RemoveRow(int nRow)
|
||
{
|
||
assertWriteEnabled();
|
||
ASSERT(m_pCells);
|
||
int nRowNum=GetRowNum();
|
||
int nColNum=GetColumnNum();
|
||
if(nColNum<1||nRow<0||nRow>=nRowNum)
|
||
return;
|
||
TGridCell *pCellArray=new TGridCell[(nRowNum-1)*nColNum];
|
||
for(int iRow=0; iRow<nRow; iRow++) {
|
||
for(int iCol=0; iCol<nColNum; iCol++) {
|
||
pCellArray[iRow*nColNum+iCol]=m_pCells[iRow*nColNum+iCol];
|
||
}
|
||
}
|
||
for(iRow=nRow+1; iRow<nRowNum; iRow++) {
|
||
for(int iCol=0; iCol<nColNum; iCol++) {
|
||
pCellArray[(iRow-1)*nColNum+iCol]=m_pCells[iRow*nColNum+iCol];
|
||
}
|
||
}
|
||
delete []m_pCells;
|
||
m_pCells = pCellArray;
|
||
|
||
m_rows.Remove(nRow);
|
||
int nRanNum=m_ranges.Length();
|
||
for(int iRan=0; iRan<nRanNum; iRan++) {
|
||
TGridRange *pRange=m_ranges[iRan];
|
||
if(pRange->GetCoord(TRUE)==pRange->GetCoordMax(TRUE) &&
|
||
pRange->GetCoord(TRUE)==nRow) { //单元范围在此行内
|
||
m_ranges.Remove();
|
||
nRanNum--;
|
||
iRan--;
|
||
} else if(pRange->GetCoord(TRUE)>nRow) { //单元格在下边
|
||
ASSERT(pRange->GetCoordMax(TRUE)>nRow);
|
||
pRange->SetCoord(pRange->GetCoord(TRUE)-1, pRange->GetCoord(FALSE));
|
||
pRange->SetCoordMax(pRange->GetCoordMax(TRUE)-1, pRange->GetCoordMax(FALSE));
|
||
} else if(pRange->GetCoord(TRUE)<=nRow && pRange->GetCoordMax(TRUE)>=nRow) {
|
||
// 跨越列
|
||
pRange->SetCoordMax(pRange->GetCoordMax(TRUE)-1, pRange->GetCoordMax(FALSE));
|
||
if(pRange->IsCellar()) {
|
||
// 合并单元格退化为单元格
|
||
(*this)(pRange->GetCoord(TRUE), pRange->GetCoord(FALSE))->SetRange(NULL);
|
||
|
||
//add by whl on 040902,解决bug:删除行时原先的合并单元退化时丢文字
|
||
(*this)(pRange->GetCoord(TRUE), pRange->GetCoord(FALSE))->SetText(pRange->GetText());
|
||
|
||
m_ranges.Remove();
|
||
nRanNum--;
|
||
iRan--;
|
||
}
|
||
} else {
|
||
ASSERT(pRange->GetCoordMax(TRUE)<nRow); //单元格在左边
|
||
ASSERT(pRange->GetCoord(TRUE)<nRow);
|
||
// 不发生任何改动
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
BOOL TDbSheet::AddRowAt(int i)
|
||
{
|
||
TSheetRow row;
|
||
if(i>=0 && i<GetRowNum()) {
|
||
CopyObject(*GetRow(i), row);
|
||
} else {
|
||
row.SetHeight(m_nRowHeight);
|
||
row.SetRowHeightStyle(TSheetRow::kParent);
|
||
row.SetVerMode(m_gridStyle.GetVerMode());
|
||
row.SetDividerStyle(m_rowDivider);
|
||
}
|
||
return AddRowAt(i, row);
|
||
}
|
||
|
||
// 增加第i行
|
||
BOOL TDbSheet::AddRowAt(int i, const TSheetRow &row)
|
||
{
|
||
assertWriteEnabled();
|
||
ASSERT(i>=0);
|
||
|
||
int nRowNum=GetRowNum();
|
||
int nColNum=GetColumnNum();
|
||
if(nColNum<1)
|
||
return FALSE;
|
||
|
||
TSheetRow *pRow=new TSheetRow;
|
||
VERIFY(CopyObject(row, *pRow));
|
||
if(i<m_rows.Length()) {
|
||
m_rows[i];
|
||
m_rows.Insert(pRow);
|
||
} else {
|
||
m_rows.Append(pRow);
|
||
}
|
||
|
||
TGridCell *pCellArray=new TGridCell[(nRowNum+1)*nColNum];
|
||
for(int iRow=0; iRow<i; iRow++) {
|
||
for(int iCol=0; iCol<nColNum; iCol++) {
|
||
pCellArray[iRow*nColNum+iCol]=m_pCells[iRow*nColNum+iCol];
|
||
}
|
||
}
|
||
for(iRow=i; iRow<nRowNum; iRow++) {
|
||
for(int iCol=0; iCol<nColNum; iCol++) {
|
||
pCellArray[(iRow+1)*nColNum+iCol]=m_pCells[iRow*nColNum+iCol];
|
||
}
|
||
}
|
||
if(m_pCells)
|
||
delete []m_pCells;
|
||
m_pCells = pCellArray;
|
||
|
||
int nRanNum=m_ranges.Length();
|
||
for(int iRan=0; iRan<nRanNum; iRan++) {
|
||
TGridRange *pRange=m_ranges[iRan];
|
||
if(pRange->GetCoord(TRUE)>=i) { //在新增行后面
|
||
//if(pRange->GetCoord(TRUE)>i)
|
||
pRange->SetCoord(pRange->GetCoord(TRUE)+1, pRange->GetCoord(FALSE));
|
||
pRange->SetCoordMax(pRange->GetCoordMax(TRUE)+1, pRange->GetCoordMax(FALSE));
|
||
} else if(pRange->GetCoordMax(TRUE)>=i) { //跨越新增的行
|
||
pRange->SetCoordMax(pRange->GetCoordMax(TRUE)+1, pRange->GetCoordMax(FALSE));
|
||
for(int idx=pRange->GetCoord(FALSE); idx<=pRange->GetCoordMax(FALSE); idx++) {
|
||
(*this)(i, idx)->SetRange(pRange);
|
||
}
|
||
}
|
||
}
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
|
||
// 增加第i列
|
||
BOOL TDbSheet::AddColumnAt(int i)
|
||
{
|
||
TSheetColumn col;
|
||
int nColNum=GetColumnNum();
|
||
if(i>=0 && i<nColNum) {
|
||
CopyObject(*GetColumn(i), col);
|
||
} else if(i==nColNum) {
|
||
CopyObject(*GetColumn(nColNum-1), col);
|
||
} else {
|
||
ASSERT(0);
|
||
/*
|
||
col.SetWidth(24.0);
|
||
col.SetGridStyle(m_gridStyle);
|
||
col.SetDividerStyle(m_colDivider);
|
||
*/
|
||
return FALSE;
|
||
}
|
||
return AddColumnAt(i, col);
|
||
}
|
||
|
||
BOOL TDbSheet::AddColumnAt(int i, const TSheetColumn &column)
|
||
{
|
||
assertWriteEnabled();
|
||
ASSERT(i>=0);
|
||
|
||
int nRowNum=GetRowNum();
|
||
int nColNum=GetColumnNum();
|
||
if(nRowNum<=1)
|
||
return FALSE;
|
||
|
||
TSheetColumn *pCol=new TSheetColumn;
|
||
VERIFY(CopyObject(column, *pCol));
|
||
if(i<m_columns.Length()) {
|
||
m_columns[i];
|
||
m_columns.Insert(pCol);
|
||
} else {
|
||
m_columns.Append(pCol);
|
||
}
|
||
|
||
// 复制已有的列
|
||
TGridCell *pCellArray=new TGridCell[nRowNum*(nColNum+1)];
|
||
|
||
for(int iRow=0; iRow<nRowNum; iRow++) {
|
||
for(int iCol=0; iCol<i; iCol++) {
|
||
pCellArray[iRow*(nColNum+1)+iCol]=m_pCells[iRow*nColNum+iCol];
|
||
}
|
||
for(iCol=i; iCol<nColNum; iCol++) {
|
||
pCellArray[iRow*(nColNum+1)+iCol+1]=m_pCells[iRow*nColNum+iCol];
|
||
}
|
||
}
|
||
|
||
if(m_pCells)
|
||
delete []m_pCells;
|
||
m_pCells = pCellArray;
|
||
|
||
//
|
||
int nRanNum=m_ranges.Length();
|
||
for(int iRan=0; iRan<nRanNum; iRan++) {
|
||
TGridRange *pRange=m_ranges[iRan];
|
||
if(pRange->GetCoord(FALSE)>=i) { //单元格在新增列后面
|
||
pRange->SetCoord(pRange->GetCoord(TRUE), pRange->GetCoord(FALSE)+1);
|
||
pRange->SetCoordMax(pRange->GetCoordMax(TRUE), pRange->GetCoordMax(FALSE)+1);
|
||
} else if(pRange->GetCoordMax(FALSE)>=i) { //单元格跨越新增的列
|
||
pRange->SetCoordMax(pRange->GetCoordMax(TRUE), pRange->GetCoordMax(FALSE)+1);
|
||
for(int idx=pRange->GetCoord(TRUE); idx<=pRange->GetCoordMax(TRUE); idx++) {
|
||
(*this)(idx, i)->SetRange(pRange);
|
||
}
|
||
}
|
||
}
|
||
|
||
return TRUE;
|
||
}
|
||
//add by whl on 040903
|
||
void TDbSheet::Merge(TDbSheet*pSheet,bool bRowMerge)
|
||
{
|
||
assertWriteEnabled();
|
||
|
||
TDbSheet*pSheet1=(TDbSheet*)(pSheet->clone());
|
||
DList<TSheetColumn> &m_columns1=pSheet1->m_columns;
|
||
DList<TSheetRow> &m_rows1=pSheet1->m_rows;
|
||
DList<TGridRange> &m_ranges1=pSheet1->m_ranges;
|
||
TGridCell *m_pCells1=pSheet1->m_pCells;
|
||
|
||
if(bRowMerge)
|
||
{
|
||
long newRowNum=GetRowNum()+pSheet->GetRowNum(),newColNum=max(GetColumnNum(),pSheet->GetColumnNum());
|
||
//复制单元格
|
||
TGridCell *pNewCells=new TGridCell[newRowNum*newColNum];
|
||
for(long i=0;i<GetRowNum();i++)
|
||
for(long j=0;j<GetColumnNum();j++)
|
||
pNewCells[i*newColNum+j]=m_pCells[i*GetColumnNum()+j];
|
||
for(i=0;i<pSheet->GetRowNum();i++)
|
||
for(long j=0;j<pSheet->GetColumnNum();j++)
|
||
pNewCells[(i+GetRowNum())*newColNum+j]=m_pCells1[i*pSheet->GetColumnNum()+j];
|
||
delete[] m_pCells;
|
||
m_pCells=pNewCells;
|
||
//加列
|
||
for(i=GetColumnNum();i<newColNum;i++)
|
||
m_columns.Append(new TSheetColumn(*m_columns1[i]));
|
||
//调整并入合并单元记录
|
||
for(i=0;i<m_ranges1.Length();i++)
|
||
{
|
||
TGridRange *pRange=m_ranges1[i];
|
||
pRange->SetCoord(pRange->GetCoord(TRUE)+GetRowNum(),pRange->GetCoord(FALSE));
|
||
pRange->SetCoordMax(pRange->GetCoordMax(TRUE)+GetRowNum(),pRange->GetCoordMax(FALSE));
|
||
}
|
||
m_ranges<<m_ranges1;
|
||
//加行
|
||
m_rows<<m_rows1;
|
||
}
|
||
else
|
||
{
|
||
long newRowNum=max(GetRowNum(),pSheet->GetRowNum()),newColNum=GetColumnNum()+pSheet->GetColumnNum();
|
||
//复制单元格
|
||
TGridCell *pNewCells=new TGridCell[newRowNum*newColNum];
|
||
for(long i=0;i<GetRowNum();i++)
|
||
for(long j=0;j<GetColumnNum();j++)
|
||
pNewCells[i*newColNum+j]=m_pCells[i*GetColumnNum()+j];
|
||
for(i=0;i<pSheet->GetRowNum();i++)
|
||
for(long j=0;j<pSheet->GetColumnNum();j++)
|
||
pNewCells[i*newColNum+j+GetColumnNum()]=m_pCells1[i*pSheet->GetColumnNum()+j];
|
||
delete[] m_pCells;
|
||
m_pCells=pNewCells;
|
||
//加行
|
||
for(i=GetRowNum();i<newRowNum;i++)
|
||
m_rows.Append(new TSheetRow(*m_rows1[i]));
|
||
//调整并入合并单元记录
|
||
for(i=0;i<m_ranges1.Length();i++)
|
||
{
|
||
TGridRange *pRange=m_ranges1[i];
|
||
pRange->SetCoord(pRange->GetCoord(TRUE),pRange->GetCoord(FALSE)+GetColumnNum());
|
||
|
||
//modify by xlc on 071220
|
||
//pRange->SetCoordMax(pRange->GetCoordMax(TRUE)+GetRowNum(),pRange->GetCoordMax(FALSE)+GetColumnNum());
|
||
pRange->SetCoordMax(pRange->GetCoordMax(TRUE),pRange->GetCoordMax(FALSE)+GetColumnNum());
|
||
}
|
||
m_ranges<<m_ranges1;
|
||
//加行
|
||
m_columns<<m_columns1;
|
||
}
|
||
CalculateRowHeight(0,GetRowNum()-1);
|
||
delete pSheet1;
|
||
}
|
||
/////////////////////////////////////////////////////////////////
|
||
// Properties
|
||
|
||
const TDividerStyle&
|
||
TDbSheet::GetRowDivider() const
|
||
{
|
||
return m_rowDivider;
|
||
}
|
||
|
||
const TDividerStyle&
|
||
TDbSheet::GetColDivider() const
|
||
{
|
||
return m_colDivider;
|
||
}
|
||
|
||
TGridStyle &
|
||
TDbSheet::GetGridStyle()
|
||
{
|
||
return m_gridStyle;
|
||
}
|
||
|
||
TDividerStyle &
|
||
TDbSheet::GetRowDivider()
|
||
{
|
||
return m_rowDivider;
|
||
}
|
||
|
||
TDividerStyle &
|
||
TDbSheet::GetColDivider()
|
||
{
|
||
return m_colDivider;
|
||
}
|
||
|
||
TDividerStyle &
|
||
TDbSheet::GetBorderStyle()
|
||
{
|
||
return m_border;
|
||
}
|
||
|
||
const TDividerStyle &
|
||
TDbSheet::GetBorderStyle() const
|
||
{
|
||
return m_border;
|
||
}
|
||
|
||
|
||
int TDbSheet::GetRowNum() const
|
||
{
|
||
return m_rows.Length();
|
||
}
|
||
|
||
int TDbSheet::GetColumnNum() const
|
||
{
|
||
return m_columns.Length();
|
||
}
|
||
|
||
const TSheetRow *
|
||
TDbSheet::GetRow(int nRow) const
|
||
{
|
||
return &m_rows[nRow];
|
||
}
|
||
|
||
const TSheetColumn *
|
||
TDbSheet::GetColumn(int nCol) const
|
||
{
|
||
return &m_columns[nCol];
|
||
}
|
||
|
||
TSheetRow *
|
||
TDbSheet::GetRow(int nRow)
|
||
{
|
||
return m_rows[nRow];
|
||
}
|
||
|
||
TSheetColumn *
|
||
TDbSheet::GetColumn(int nCol)
|
||
{
|
||
return m_columns[nCol];
|
||
}
|
||
|
||
const TGridStyle &
|
||
TDbSheet::GetGridStyle() const
|
||
{
|
||
return m_gridStyle;
|
||
}
|
||
|
||
void
|
||
TDbSheet::SetBorderStyle(const TDividerStyle& src)
|
||
{
|
||
assertWriteEnabled();
|
||
CopyObject(src, m_border);
|
||
}
|
||
|
||
void
|
||
TDbSheet::SetRowDivider(const TDividerStyle& src)
|
||
{
|
||
assertWriteEnabled();
|
||
CopyObject(src, m_rowDivider);
|
||
}
|
||
|
||
void
|
||
TDbSheet::SetColDivider(const TDividerStyle& src)
|
||
{
|
||
assertWriteEnabled();
|
||
CopyObject(src, m_colDivider);
|
||
}
|
||
|
||
void TDbSheet::SetGridStyle(const TGridStyle &src)
|
||
{
|
||
assertWriteEnabled();
|
||
CopyObject(src, m_gridStyle);
|
||
}
|
||
|
||
// 增加第i列
|
||
// 没有检查列的数目
|
||
BOOL TDbSheet::SetColumnAt(int i, const TSheetColumn &column)
|
||
{
|
||
assertWriteEnabled();
|
||
ASSERT(i>=0);
|
||
TSheetColumn *pCol=m_columns[i];
|
||
VERIFY(CopyObject(column, *pCol));
|
||
return TRUE;
|
||
}
|
||
|
||
|
||
// 增加地i行
|
||
BOOL TDbSheet::SetRowAt(int i, const TSheetRow &row)
|
||
{
|
||
assertWriteEnabled();
|
||
ASSERT(i>=0);
|
||
TSheetRow *pRow=m_rows[i];
|
||
VERIFY(CopyObject(row, *pRow));
|
||
return TRUE;
|
||
}
|
||
|
||
|
||
void TDbSheet::GetBorder(XPoly2D &polyBorder) const
|
||
{
|
||
double nRotWcs=Layout2Wcs(m_nRotation);
|
||
BOOL bIncludeTitle=(m_title.IsVisible() &&
|
||
m_title.GetDividerStyle().GetDividerFlag()!=TDividerStyle::kNone);
|
||
XPoint ptUpLeft=GetTopLeft(bIncludeTitle);
|
||
XPoint ext=GetExtents(bIncludeTitle, FALSE);
|
||
XPoint ptLowRight, ptUpRight, ptLowLeft;
|
||
ads_polar(ptUpLeft, nRotWcs-PI/2, ext.y, ptLowLeft);
|
||
ads_polar(ptLowLeft, nRotWcs, ext.x, ptLowRight);
|
||
ads_polar(ptLowRight, nRotWcs+PI/2, ext.y, ptUpRight);
|
||
polyBorder.Reset();
|
||
polyBorder.AppendNode(ptLowLeft);
|
||
polyBorder.AppendNode(ptLowRight);
|
||
polyBorder.AppendNode(ptUpRight);
|
||
polyBorder.AppendNode(ptUpLeft);
|
||
polyBorder.SetFlag(1);
|
||
//polyBorder.SetElevation(0.0);
|
||
}
|
||
|
||
// 取得表格大小
|
||
XPoint TDbSheet::GetExtents(BOOL bIncludeTitle, BOOL bAsPaperUnit) const
|
||
{
|
||
double nWidth=GetSheetWidth(bAsPaperUnit);
|
||
double nHeight=GetSheetHeight(bIncludeTitle, bAsPaperUnit);
|
||
return XPoint(nWidth, nHeight);
|
||
}
|
||
|
||
// 取得表格的高度
|
||
double TDbSheet::GetSheetHeight(BOOL bIncludeTitle, BOOL bAsPaperUnit) const
|
||
{
|
||
int nRowNum=m_rows.Length();
|
||
double nHeight=GetRowsHeight(0, nRowNum-1, TRUE);
|
||
|
||
if(bIncludeTitle) nHeight += m_title.GetHeight();
|
||
if(!bAsPaperUnit) {
|
||
double nScale=GetPScale();
|
||
nHeight *= nScale;
|
||
}
|
||
return nHeight;
|
||
}
|
||
|
||
// 取得表格的宽度
|
||
double TDbSheet::GetSheetWidth(BOOL bAsPaperUnit) const
|
||
{
|
||
double nWidth=0.0;
|
||
int nColNum=m_columns.Length();
|
||
for(int i=0; i<nColNum; i++) {
|
||
const TSheetColumn &column=m_columns[i];
|
||
nWidth += column.m_nWidth;
|
||
}
|
||
if(!bAsPaperUnit) {
|
||
double nScale=GetPScale();
|
||
nWidth *= nScale;
|
||
}
|
||
return nWidth;
|
||
}
|
||
|
||
// 取得连续几行的行高
|
||
double TDbSheet::GetRowsHeight(int nRowFrom, int nRowTo, BOOL bAsPaperUnit) const
|
||
{
|
||
double nHeight=0.0;
|
||
for(int i=nRowFrom; i<=nRowTo; i++) {
|
||
nHeight += GetRowHeight(i, bAsPaperUnit);
|
||
}
|
||
return nHeight;
|
||
}
|
||
|
||
//取得连续几列的列宽
|
||
double TDbSheet::GetColumnsWidth(int nColFrom, int nColTo, BOOL bAsPaperUnit) const
|
||
{
|
||
double nWidth=0.0;
|
||
for(int i=nColFrom; i<=nColTo; i++) {
|
||
nWidth += GetColumnWidth(i, bAsPaperUnit);
|
||
}
|
||
return nWidth;
|
||
}
|
||
|
||
|
||
// 得到某一行的高度
|
||
double TDbSheet::GetRowHeight(int nRow, BOOL bAsPaperUnit) const
|
||
{
|
||
ASSERT(nRow<m_rows.Length());
|
||
if(nRow>=m_rows.Length())
|
||
return 0.0;
|
||
const TSheetRow &row=m_rows[nRow];
|
||
double nHeight=0.0;
|
||
if(row.m_nHeightFlag==TSheetRow::kParent &&
|
||
m_rowHeightStyle==TSheetRow::kFixed)
|
||
nHeight=m_nRowHeight;
|
||
else
|
||
nHeight=row.m_nHeight;
|
||
if(!bAsPaperUnit)
|
||
nHeight *= GetPScale();
|
||
return nHeight;
|
||
}
|
||
|
||
// 取得某列的宽度
|
||
double TDbSheet::GetColumnWidth(int nCol, BOOL bAsPaperUnit) const
|
||
{
|
||
ASSERT(nCol<m_columns.Length());
|
||
const TSheetColumn &column=m_columns[nCol];
|
||
double nWidth=column.m_nWidth;
|
||
if(!bAsPaperUnit)
|
||
nWidth *= GetPScale();
|
||
return nWidth;
|
||
}
|
||
|
||
// 取得某列的左上角点
|
||
XPoint TDbSheet::GetColumnPoint(int nCol) const
|
||
{
|
||
XPoint ptTopLeft=GetTopLeft(FALSE);
|
||
double nWidth=GetColumnsWidth(0, nCol-1, FALSE);
|
||
ads_polar(XPoint(ptTopLeft), Layout2Wcs(m_nRotation), nWidth, ptTopLeft);
|
||
return ptTopLeft;
|
||
}
|
||
|
||
// 取得某行的左上角点
|
||
XPoint TDbSheet::GetRowPoint(int nRow) const
|
||
{
|
||
XPoint ptTopLeft=GetTopLeft(FALSE);
|
||
double nHeight=GetRowsHeight(0, nRow-1, FALSE);
|
||
ads_polar(XPoint(ptTopLeft), Layout2Wcs(m_nRotation)-PI/2, nHeight, ptTopLeft);
|
||
return ptTopLeft;
|
||
}
|
||
|
||
//取的表格的左上角点
|
||
XPoint TDbSheet::GetTopLeft(BOOL bIncludeTitle) const
|
||
{
|
||
XPoint ext=GetExtents(bIncludeTitle, FALSE);
|
||
XPoint ptLowLeft=Align2Base(GetLocation(), GetExtents(m_title.IsVisible(), FALSE));
|
||
XPoint ptTopLeft;
|
||
ads_polar(ptLowLeft, Layout2Wcs(m_nRotation)+PI/2, ext.y, ptTopLeft);
|
||
return ptTopLeft;
|
||
}
|
||
|
||
// 取得表格位置
|
||
XPoint TDbSheet::GetLocation() const
|
||
{
|
||
return m_ptLocation;
|
||
}
|
||
|
||
// 取表格旋转角度
|
||
double TDbSheet::GetRotation() const
|
||
{
|
||
return m_nRotation;
|
||
}
|
||
|
||
// 取表格定位方式
|
||
XExplodeDraw::TextAlignment
|
||
TDbSheet::GetAlignment() const
|
||
{
|
||
return m_nAlignment;
|
||
}
|
||
|
||
//取缺省的行高
|
||
double TDbSheet::GetRowHeight(BOOL bAsPaperUnit) const
|
||
{
|
||
double h=m_nRowHeight;
|
||
if(!bAsPaperUnit)
|
||
h *= GetPScale();
|
||
return h;
|
||
}
|
||
|
||
// 设置表格位置
|
||
void TDbSheet::SetLocation(XPoint pt)
|
||
{
|
||
assertWriteEnabled();
|
||
m_ptLocation=pt;
|
||
m_ptLocation.z=0;
|
||
}
|
||
|
||
// 设置表格转角
|
||
void TDbSheet::SetRotation(double nRot)
|
||
{
|
||
assertWriteEnabled();
|
||
m_nRotation=nRot;
|
||
}
|
||
|
||
// 设置表格的定位对齐方式
|
||
void TDbSheet::SetAlignment(XExplodeDraw::TextAlignment nAlign)
|
||
{
|
||
assertWriteEnabled();
|
||
m_nAlignment=nAlign;
|
||
}
|
||
|
||
//设置缺省的行高
|
||
void TDbSheet::SetRowHeight(double h, BOOL bAsPaperUnit)
|
||
{
|
||
assertWriteEnabled();
|
||
m_nRowHeight=h;
|
||
if(!bAsPaperUnit)
|
||
m_nRowHeight /= GetPScale();
|
||
}
|
||
|
||
//////////////////////////////////////////////////////////////////
|
||
// 单元格属性
|
||
|
||
XPoint
|
||
TDbSheet::GetCellSize(int nRow, int nCol, BOOL bAsPaperUnit) const
|
||
{
|
||
const TGridCell &cell=*(*this)(nRow, nCol);
|
||
double w, h;
|
||
if(cell.IsRange()) {
|
||
const TGridRange &range=*cell.GetRange();
|
||
w=GetColumnsWidth(range.m_nColumn, range.m_nColumnMax, bAsPaperUnit);
|
||
h=GetRowsHeight(range.m_nRow, range.m_nRowMax, bAsPaperUnit);
|
||
} else {
|
||
w=GetColumnWidth(nCol, bAsPaperUnit);
|
||
h=GetRowHeight(nRow, bAsPaperUnit);
|
||
}
|
||
return XPoint(w, h);
|
||
}
|
||
|
||
XPoint
|
||
TDbSheet::GetCellPoint(int nRow, int nCol) const
|
||
{
|
||
const TGridCell *pCell=(*this)(nRow, nCol);
|
||
if(pCell->IsRange()) {
|
||
nRow=pCell->GetRange()->GetCoord(TRUE);
|
||
nCol=pCell->GetRange()->GetCoord(FALSE);
|
||
}
|
||
|
||
double x=GetColumnsWidth(0, nCol-1, FALSE);
|
||
double y=GetRowsHeight(0, nRow-1, FALSE);
|
||
XPoint ptTopLeft=GetTopLeft(FALSE);
|
||
XPoint ptDest;
|
||
ads_polar(ptTopLeft, Layout2Wcs(m_nRotation), x, ptDest);
|
||
ads_polar(XPoint(ptDest), Layout2Wcs(m_nRotation)-PI/2, y, ptDest);
|
||
return ptDest;
|
||
}
|
||
|
||
// 判断某单元格是否有底线
|
||
BOOL TDbSheet::HasRowDivider(int nRow, int nCol) const
|
||
{
|
||
const TGridCell *pCell=(*this)(nRow, nCol);
|
||
if(!pCell)
|
||
return TRUE; //没有内容的单元格, 作为空的单元格, 有底线
|
||
BOOL bRet=TRUE;
|
||
if(pCell->IsRange() && nRow<pCell->GetRange()->m_nRowMax)
|
||
bRet=FALSE;
|
||
return bRet;
|
||
}
|
||
|
||
// 判断某单元格是否有右线
|
||
BOOL TDbSheet::HasColumnDivider(int nRow, int nCol) const
|
||
{
|
||
const TGridCell *pCell=(*this)(nRow, nCol);
|
||
if(!pCell) //没有内容的单元格, 作为空的单元格, 有边线
|
||
return TRUE;
|
||
BOOL bRet=TRUE;
|
||
if(pCell->IsRange() && nCol<pCell->GetRange()->m_nColumnMax)
|
||
bRet=FALSE;
|
||
return bRet;
|
||
}
|
||
|
||
|
||
// 求单元格最终有效的属性样式
|
||
const TGridStyle *
|
||
TDbSheet::GetCellGridStyle(int nRow, int nCol, int nOverFlag, BOOL *bLocal) const
|
||
{
|
||
const TGridCell &cell=*(*this)(nRow, nCol);
|
||
const TGridStyle &rStyle=cell.IsRange()?
|
||
cell.GetRange()->m_gridStyle : cell.m_gridStyle;
|
||
return GetCellGridStyle(rStyle, nCol, nOverFlag, bLocal);
|
||
}
|
||
|
||
// 取得单元格最终的有效样式
|
||
const TGridStyle *
|
||
TDbSheet::GetCellGridStyle(const TGridStyle &rStyle, int nCol, int nOverFlag, BOOL*bLocal) const
|
||
{
|
||
const TGridStyle *pGridStyle=NULL;
|
||
if(rStyle.m_nOverride&nOverFlag) {
|
||
pGridStyle=&rStyle;
|
||
if(bLocal) *bLocal=TRUE;
|
||
} else {
|
||
if(bLocal) *bLocal=FALSE;
|
||
const TSheetColumn &column=m_columns[nCol];
|
||
if(column.m_gridStyle.m_nOverride&nOverFlag)
|
||
pGridStyle=&column.m_gridStyle;
|
||
else if(m_gridStyle.m_nOverride&nOverFlag)
|
||
pGridStyle=&m_gridStyle;
|
||
}
|
||
return pGridStyle;
|
||
}
|
||
|
||
|
||
// 取得单元格的水平对齐方式
|
||
AcDb::TextHorzMode
|
||
TDbSheet::GetCellHorMode(int nRow, int nCol, BOOL *bLocal) const
|
||
{
|
||
const TGridStyle *style=GetCellGridStyle(nRow, nCol, OF_HORMODE, bLocal);
|
||
ASSERT(style);
|
||
return style->m_nHorMode;
|
||
}
|
||
|
||
// 取得单元格的垂直对齐方式, 继承方式不同于其它
|
||
AcDb::TextVertMode
|
||
TDbSheet::GetCellVerMode(int nRow, int nCol, BOOL *bLocal) const
|
||
{
|
||
const TGridCell &cell=*(*this)(nRow, nCol);
|
||
const TGridStyle &rStyle=cell.IsRange()?
|
||
cell.GetRange()->m_gridStyle : cell.m_gridStyle;
|
||
|
||
AcDb::TextVertMode nVerMode;
|
||
if(rStyle.m_nOverride&OF_VERMODE) {
|
||
nVerMode=rStyle.m_nVerMode;
|
||
if(bLocal) *bLocal=TRUE;
|
||
} else {
|
||
nVerMode=m_rows[nRow].m_nVerMode;
|
||
if(nVerMode==AcDb::kTextBase) { //继承
|
||
nVerMode=m_gridStyle.GetVerMode();
|
||
}
|
||
if(bLocal) *bLocal=FALSE;
|
||
}
|
||
return nVerMode;
|
||
}
|
||
|
||
//取得单元格的文本行间距
|
||
double
|
||
TDbSheet::GetCellLineSpace(int nRow, int nCol, BOOL bAsPaperUnit) const
|
||
{
|
||
const TGridStyle *style1=GetCellGridStyle(nRow, nCol, OF_LINESPACE);
|
||
const TGridStyle *style2=GetCellGridStyle(nRow, nCol, OF_TEXTHEIGHT);
|
||
ASSERT(style1 && style2);
|
||
double nVal=style1->m_nLineSpaceFactor * style2->m_nTextHeight;
|
||
if(!bAsPaperUnit)
|
||
nVal *= GetPScale();
|
||
return nVal;
|
||
}
|
||
|
||
//取得单元格的文本行间距
|
||
double
|
||
TDbSheet::GetCellLineSpaceFactor(int nRow, int nCol, BOOL *bLocal) const
|
||
{
|
||
const TGridStyle *style=GetCellGridStyle(nRow, nCol, OF_LINESPACE, bLocal);
|
||
ASSERT(style);
|
||
double nLineSpaceFactor=style->m_nLineSpaceFactor;
|
||
return nLineSpaceFactor;
|
||
}
|
||
|
||
|
||
// 取得单元格的文本高度
|
||
double
|
||
TDbSheet::GetCellTextHeight(int nRow, int nCol, BOOL bAsPaperUnit, BOOL *bLocal) const
|
||
{
|
||
const TGridStyle *style=GetCellGridStyle(nRow, nCol, OF_TEXTHEIGHT, bLocal);
|
||
ASSERT(style);
|
||
double nHeight=style->m_nTextHeight;
|
||
if(!bAsPaperUnit)
|
||
nHeight *= GetPScale();
|
||
return nHeight;
|
||
}
|
||
|
||
// 取得单元格的文字样式
|
||
AcDbObjectId
|
||
TDbSheet::GetCellTextStyle(int nRow, int nCol, BOOL *bLocal) const
|
||
{
|
||
const TGridStyle *style=GetCellGridStyle(nRow, nCol, OF_TEXTSTYLE, bLocal);
|
||
ASSERT(style);
|
||
AcDbObjectId idStyle=style->m_idTextStyle;
|
||
if(!idStyle)
|
||
idStyle=m_gridStyle.GetTextStyleId();
|
||
return idStyle;
|
||
}
|
||
|
||
// 取得单元格的文字颜色
|
||
Adesk::UInt16
|
||
TDbSheet::GetCellTextColor(int nRow, int nCol, BOOL *bLocal) const
|
||
{
|
||
const TGridStyle *style=GetCellGridStyle(nRow, nCol, OF_TEXTCOLOR, bLocal);
|
||
ASSERT(style);
|
||
return style->m_nTextColor;
|
||
}
|
||
|
||
|
||
// 单元格文字是否自动换行
|
||
BOOL TDbSheet::IsCellWrapEnabled(int nRow, int nCol, BOOL *bLocal) const
|
||
{
|
||
const TGridStyle *style=GetCellGridStyle(nRow, nCol, OF_TEXTWRAP, bLocal);
|
||
ASSERT(style);
|
||
return style->m_bTextWrap;
|
||
}
|
||
|
||
//////////////////////////////////////////////////////////////////
|
||
// 标题的属性
|
||
// 标题的属性为局部, 不继承
|
||
// 求标题最终有效的属性样式
|
||
const TGridStyle *
|
||
TDbSheet::GetTitleGridStyle(int nOverFlag, BOOL *bLocal) const
|
||
{
|
||
const TGridStyle *pGridStyle=NULL;
|
||
pGridStyle=&m_title.m_gridStyle;
|
||
if(bLocal) *bLocal=TRUE;
|
||
/*
|
||
if(m_title.m_gridStyle.m_nOverride&nOverFlag) {
|
||
pGridStyle=&m_title.m_gridStyle;
|
||
if(bLocal) *bLocal=TRUE;
|
||
} else if(m_gridStyle.m_nOverride&nOverFlag) {
|
||
pGridStyle=&m_gridStyle;
|
||
if(bLocal) *bLocal=FALSE;
|
||
}*/
|
||
return pGridStyle;
|
||
}
|
||
|
||
// 标题的高度
|
||
double TDbSheet::GetTitleHeight(BOOL bAsPaperUnit) const
|
||
{
|
||
double nHeight=m_title.m_nHeight;
|
||
if(!bAsPaperUnit)
|
||
nHeight *= GetPScale();
|
||
return nHeight;
|
||
}
|
||
|
||
// 标题文字的水平对齐方式
|
||
AcDb::TextHorzMode
|
||
TDbSheet::GetTitleHorMode( BOOL *bLocal) const
|
||
{
|
||
const TGridStyle *style=GetTitleGridStyle(OF_HORMODE, bLocal);
|
||
ASSERT(style);
|
||
return style->m_nHorMode;
|
||
}
|
||
|
||
// 取得单元格的垂直对齐方式
|
||
AcDb::TextVertMode
|
||
TDbSheet::GetTitleVerMode( BOOL *bLocal) const
|
||
{
|
||
const TGridStyle *style=GetTitleGridStyle(OF_VERMODE, bLocal);
|
||
ASSERT(style);
|
||
return style->GetVerMode();
|
||
}
|
||
|
||
// 标题的文字行间距
|
||
double TDbSheet::GetTitleLineSpace(BOOL bAsPaperUnit) const
|
||
{
|
||
double nTextHeight=GetTitleTextHeight(bAsPaperUnit);
|
||
const TGridStyle *style=GetTitleGridStyle(OF_LINESPACE);
|
||
double nLineSpaceFactor=(style? style->m_nLineSpaceFactor : LSF_DEFAULT);
|
||
return (nTextHeight*nLineSpaceFactor);
|
||
}
|
||
|
||
// 标题的文字行间距
|
||
double TDbSheet::GetTitleLineSpaceFactor(BOOL *bLocal) const
|
||
{
|
||
const TGridStyle *style=GetTitleGridStyle(OF_LINESPACE, bLocal);
|
||
double nLineSpaceFactor=(style? style->m_nLineSpaceFactor : LSF_DEFAULT);
|
||
return nLineSpaceFactor;
|
||
}
|
||
|
||
|
||
// 标题的文字高度
|
||
double TDbSheet::GetTitleTextHeight(BOOL bAsPaperUnit, BOOL *bLocal) const
|
||
{
|
||
const TGridStyle *style=GetTitleGridStyle(OF_TEXTHEIGHT, bLocal);
|
||
ASSERT(style);
|
||
double nHeight=style->m_nTextHeight;
|
||
if(!bAsPaperUnit)
|
||
nHeight *= GetPScale();
|
||
return nHeight;
|
||
}
|
||
|
||
// 标题的文字样式
|
||
AcDbObjectId TDbSheet::GetTitleTextStyle(BOOL *bLocal) const
|
||
{
|
||
const TGridStyle *style=GetTitleGridStyle(OF_TEXTSTYLE, bLocal);
|
||
ASSERT(style);
|
||
AcDbObjectId idStyle=style->m_idTextStyle;
|
||
if(!idStyle)
|
||
idStyle=m_gridStyle.GetTextStyleId();
|
||
return idStyle;
|
||
}
|
||
|
||
Adesk::UInt16 TDbSheet::GetTitleTextColor(BOOL *bLocal) const
|
||
{
|
||
const TGridStyle *style=GetTitleGridStyle(OF_TEXTCOLOR, bLocal);
|
||
ASSERT(style);
|
||
return style->GetTextColor();
|
||
}
|
||
|
||
|
||
// 标题文字是否自动换行
|
||
BOOL TDbSheet::IsTitleWrapEnabled(BOOL *bLocal) const
|
||
{
|
||
const TGridStyle *style=GetTitleGridStyle(OF_TEXTWRAP, bLocal);
|
||
ASSERT(style);
|
||
return style->m_bTextWrap;
|
||
}
|
||
|
||
// 取得标题文本
|
||
const TCHAR *TDbSheet::GetTitleText() const
|
||
{
|
||
return (const TCHAR *)m_title.m_sText;
|
||
}
|
||
|
||
// 设置标题文本
|
||
void TDbSheet::SetTitleText(const TCHAR *szText)
|
||
{
|
||
assertWriteEnabled();
|
||
m_title.m_sText = szText;
|
||
}
|
||
|
||
void TDbSheet::SetTitleHeight(double h, BOOL bAsPaperUnit)
|
||
{
|
||
assertWriteEnabled();
|
||
if(!bAsPaperUnit)
|
||
h /= GetPScale();
|
||
m_title.SetHeight(h);
|
||
}
|
||
|
||
void TDbSheet::SetTitleGridStyle(const TGridStyle &gridStyle)
|
||
{
|
||
assertWriteEnabled();
|
||
m_title.SetGridStyle(gridStyle);
|
||
}
|
||
|
||
const TSheetTitle &
|
||
TDbSheet::GetTitle() const
|
||
{
|
||
return m_title;
|
||
}
|
||
|
||
TSheetTitle&
|
||
TDbSheet::GetTitle()
|
||
{
|
||
return m_title;
|
||
}
|
||
const TCHAR* TDbSheet::GetDefaultLayer()const
|
||
{
|
||
return LAY_SHEET;
|
||
}
|
||
|
||
void InitDbSheet(BOOL bTrue)
|
||
{
|
||
if(bTrue) {
|
||
TDbSheet::rxInit();
|
||
acrxBuildClassHierarchy();
|
||
TDbSheet::InitMatchProtocol(TRUE);
|
||
} else {
|
||
TDbSheet::InitMatchProtocol(FALSE);
|
||
deleteAcRxClass(TDbSheet::desc());
|
||
}
|
||
}
|
||
|