ExtendInfoIdentify.cpp
上传用户:hell82222
上传日期:2013-12-19
资源大小:1872k
文件大小:38k
- // ExtendInfoIdentify.cpp: implementation of the CExtendInfoIdentify class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "fileswitch.h"
- #include "ExtendInfoIdentify.h"
- #include "CShow.h"
- #include "DataBase.h"
- #include "KmEntity.h"
- #include "block.h"
- #include "KmText.h"
- #include "KmSText.h"
- #include "KmObject.h"
- #include "KmShare.h"
- #include "MXManager.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CExtendInfoIdentify::CExtendInfoIdentify(KmBuffer* pExtendInfoSource)
- {
- ASSERT(pExtendInfoSource);
- m_pExtendInfoSource=pExtendInfoSource;
- }
- CExtendInfoIdentify::~CExtendInfoIdentify()
- {
- ASSERT(m_pExtendInfoSource);
- if(m_pExtendInfoSource)
- {
- m_pExtendInfoSource->ClearKmBuffer();
- delete m_pExtendInfoSource;
- m_pExtendInfoSource=NULL;
- }
- }
- //从数据库创建扩展信息分析源集合的函数
- KmBuffer* CExtendInfoIdentify::CreateExtendInfoSourceBuffer(CKmDataManager* pDataManager,BOOL& bRected,KmRect &rectOutSide)
- {
- bRected=FALSE;
- ASSERT(pDataManager);
- if(pDataManager)
- {
- KmBuffer* pBuffer=new KmBuffer;
- CKmDataManager* pBack=::GetActiveDataManager();
- ::SetActiveDataManager(pDataManager);
- {//处理当前活动数据库,内部禁止处理当前活动数据库。
- CShow* pShow = new CGDIShow((CWnd*)NULL);
- {//遍历数据库生成扩展信息集合
- DICTIONARY_ITEM dic;
- KmObject* pObj;
- for(UINT i=0;i<::GetEntDicSize();i++)
- {
- dic=::GetEntDicAt((int)i);
- if(dic==NULL)
- {
- continue;
- }
- if(dic->IsDerivedFrom(RUNTIME_CLASS(KmBlockRef)))
- {
- KmIteratorPtr pIterator(pDataManager->CreateIterator(dic));
- for(pIterator->First();!pIterator->IsDone();pIterator->Next())
- {
- pObj=pIterator->CurrentItem();
-
- if(pObj==NULL)
- {
- continue;
- }
- if(!pObj->IsVisual())
- {
- continue;
- }
- KmObject* pTemp=NULL;
- KmBlockRef* pRef=(KmBlockRef*)pObj;
- for(UINT j=0;j<pRef->GetObjectNum(TRUE);j++)
- {
- pRef->GetObjectAt(j,pTemp,TRUE);
- if(pTemp==NULL)
- {
- continue;
- }
- if(!pTemp->IsKindOf(RUNTIME_CLASS(KmCurve)))
- {
- if(!pTemp->IsKindOf(RUNTIME_CLASS(KmText)))
- {
- if(!pTemp->IsKindOf(RUNTIME_CLASS(KmSText)))
- {
- continue;//只处理曲线和文字
- }
- }
- }
- pTemp->Draw(pShow,RGB(0,0,0),DRAWPRESENT,pBuffer);
- }
- }
- continue;//块引用分析完了
- }
- if(!dic->IsDerivedFrom(RUNTIME_CLASS(KmCurve)))
- {
- if(!dic->IsDerivedFrom(RUNTIME_CLASS(KmText)))
- {
- if(!dic->IsDerivedFrom(RUNTIME_CLASS(KmSText)))
- {
- continue;
- }
- }
- }
- KmIteratorPtr pIterator(pDataManager->CreateIterator(dic));
- for(pIterator->First();!pIterator->IsDone();pIterator->Next())
- {
- pObj=pIterator->CurrentItem();
-
- if(pObj==NULL)
- {
- continue;
- }
- if(!pObj->IsVisual())
- {
- continue;
- }
- pObj->Draw(pShow,RGB(0,0,0),DRAWPRESENT,pBuffer);
- }
- //分析仅针对块引用、直线和文字而言。
- }
- }
- pShow->UnInitial();
- delete pShow;
- pShow=NULL;
- }
- ::SetActiveDataManager(pBack);
- CArray<S_LINE_BUFFER*,S_LINE_BUFFER*>* paLines=pBuffer->GetLineBuffer();
- S_LINE_BUFFER* pLine=NULL;
- for(int index=0;index<paLines->GetSize();index++)
- {
- pLine=paLines->GetAt(index);
- if(pLine!=NULL)
- {
- if(pLine->LineType==SOLID_LINE)
- {
- if(pLine->P1!=pLine->P2)
- {
- if(fabs(pLine->P1.x-pLine->P2.x)<0.01)
- {
- continue;
- }
- if(fabs(pLine->P1.y-pLine->P2.y)<0.01)
- {
- continue;
- }
- }
- }
- }
- delete paLines->GetAt(index);
- paLines->RemoveAt(index);
- index--;
- }
- CArray<S_TEXT*,S_TEXT*>* paTexts=pBuffer->GetTextBuffer();
- S_TEXT* pText=NULL;
- for(index=0;index<paTexts->GetSize();index++)
- {
- pText=paTexts->GetAt(index);
- if(pText!=NULL)
- {
- if(fabs(pText->m_nEscapement)<0.01)
- {
- calculate_text_boundary(pText);
- continue;
- }
- }
- delete paTexts->GetAt(index);
- paTexts->RemoveAt(index);
- index--;
- }
- return pBuffer;
- }
- return NULL;
- }
- //识别图框
- BOOL CExtendInfoIdentify::IdentifyLegend(KmLegend* &pLegend,double& dShowScale,KmPoint& ptRightBottom)
- {
- try
- {
- /*xlf:识别假设
- 只有一个图框
- 图框的线是连续的。
- //xlf*/
- ASSERT(pLegend);
- ASSERT(m_pExtendInfoSource);
- int up_line_in =-1, down_line_in =-1, right_line_in =-1, left_line_in =-1,
- up_line_out=-1, down_line_out=-1, right_line_out=-1, left_line_out=-1;
- double h_length=0.0, v_length=0.0;
- double xmin =1.0e8, ymin =1.0e8;
- double v_len1=0.0, v_len2=0.0;
- BOOL out_boundary_ok =TRUE,in_boundary_ok =TRUE;
- //找到外图框
- for(int i=0; i<m_pExtendInfoSource->GetLineBuffSize(); i++)
- {
- // if(m_pExtendInfoSource->GetLineEnt(i)->LineType!=SOLID_LINE)
- // {
- // continue;
- // }
- if(fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.x-m_pExtendInfoSource->GetLineEnt(i)->P2.x) < PRECISION) //竖直
- {
- if(m_pExtendInfoSource->GetLineEnt(i)->P1.x < xmin)
- {
- xmin=m_pExtendInfoSource->GetLineEnt(i)->P1.x;
- }
- if(left_line_out==-1)
- {
- left_line_out=i;
- }
- if(right_line_out==-1)
- {
- right_line_out=i;
- }
- double minx, maxx;
- if(fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.y-m_pExtendInfoSource->GetLineEnt(i)->P2.y) >= v_length*0.85)
- {
- if(fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.y-m_pExtendInfoSource->GetLineEnt(i)->P2.y) > v_length)
- {
- v_length =fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.y-m_pExtendInfoSource->GetLineEnt(i)->P2.y);
- }
- minx =m_pExtendInfoSource->GetLineEnt(left_line_out)->P1.x;
- maxx =m_pExtendInfoSource->GetLineEnt(right_line_out)->P1.x;
- if(fabs(minx)<=PRECISION)
- {
- minx =0;
- }
- if(m_pExtendInfoSource->GetLineEnt(i)->P1.x < minx+PRECISION)
- {
- left_line_out =i;
- }
- if(m_pExtendInfoSource->GetLineEnt(i)->P1.x > maxx-PRECISION)
- {
- right_line_out =i;
- }
- else if(fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.y-m_pExtendInfoSource->GetLineEnt(i)->P2.y) > v_length*1.05)
- {
- if( fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.x-m_pExtendInfoSource->GetLineEnt(left_line_out)->P1.x)
- < fabs(m_pExtendInfoSource->GetLineEnt(right_line_out)->P1.x-m_pExtendInfoSource->GetLineEnt(i)->P1.x))
- {
- left_line_out = i;
- }
- else
- {
- right_line_out = i;
- }
- }
- }
- else
- {
- continue;
- }
- }
- else if(fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.y-m_pExtendInfoSource->GetLineEnt(i)->P2.y) < PRECISION)
- {
- if(m_pExtendInfoSource->GetLineEnt(i)->P1.y<ymin)
- {
- ymin =m_pExtendInfoSource->GetLineEnt(i)->P1.y;
- }
- if(up_line_out == -1)
- {
- up_line_out =i;
- }
- if(down_line_out == -1)
- {
- down_line_out =i;
- }
- if(fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.x-m_pExtendInfoSource->GetLineEnt(i)->P2.x) >= h_length*0.85)
- {
- if(fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.x-m_pExtendInfoSource->GetLineEnt(i)->P2.x) > h_length)
- {
- h_length =fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.x-m_pExtendInfoSource->GetLineEnt(i)->P2.x);
- }
- if(m_pExtendInfoSource->GetLineEnt(i)->P1.y < m_pExtendInfoSource->GetLineEnt(down_line_out)->P1.y+PRECISION)
- {
- down_line_out = i;
- }
- else if(m_pExtendInfoSource->GetLineEnt(i)->P1.y > m_pExtendInfoSource->GetLineEnt(up_line_out)->P1.y-PRECISION)
- {
- up_line_out = i;
- }
- else if(fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.x-m_pExtendInfoSource->GetLineEnt(i)->P2.x) > h_length*1.05)
- {
- if( fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.y-m_pExtendInfoSource->GetLineEnt(down_line_out)->P1.y)
- < fabs(m_pExtendInfoSource->GetLineEnt(up_line_out)->P1.y-m_pExtendInfoSource->GetLineEnt(i)->P1.y))
- {
- down_line_out = i;
- }
- else
- {
- up_line_out = i;
- }
- }
- }
- else
- {
- continue;
- }
- }
- }
- if(up_line_out == -1 || down_line_out == -1 || right_line_out == -1 || left_line_out == -1)
- {
- out_boundary_ok = FALSE;
- }
- if(out_boundary_ok)
- {
- out_boundary_ok =calculate_check_boundary(up_line_out, down_line_out, right_line_out ,left_line_out);//检查是否围成矩形框
- }
- if(out_boundary_ok)
- {
- double dleft=m_pExtendInfoSource->GetLineEnt(left_line_out)->P1.x;
- double dright=m_pExtendInfoSource->GetLineEnt(right_line_out)->P1.x;
- double dtop=m_pExtendInfoSource->GetLineEnt(up_line_out)->P1.y;
- double dbottom=m_pExtendInfoSource->GetLineEnt(down_line_out)->P1.y;
- double dtemp;
- if(dleft>dright)
- {
- dtemp=dright;
- dright=dleft;
- dleft=dtemp;
- }
- if(dbottom>dtop)
- {
- dtemp=dtop;
- dtop=dbottom;
- dbottom=dtemp;
- }
- {
- double temp=fabs(dleft-dright)*PRECISION;
- dleft+=temp;
- dright-=temp;
- temp=fabs(dtop-dbottom)*PRECISION;
- dtop-=temp;
- dbottom+=temp;
- }
- h_length /= 2.0;//外框
- v_length /= 2.0;
- for(int rate=0;rate<4;rate++)
- {
- double dratesmall=1.0;
- double dratelarge=1.0;
- switch(rate)
- {
- case 0:
- dratesmall=0.85;
- dratelarge=1.05;
- break;
- case 1:
- dratesmall=0.90;
- dratelarge=1.0375;
- break;
- case 2:
- dratesmall=0.95;
- dratelarge=1.025;
- break;
- case 3:
- dratesmall=0.99;
- dratelarge=1.01;
- break;
- default:
- ASSERT(FALSE);
- break;
- }
- double h_length_2=h_length, v_length_2=v_length;
- {
- //找内图框
- for(i=0; i<m_pExtendInfoSource->GetLineBuffSize(); i++)
- {
- if(i == left_line_out)
- {
- continue;
- }
- if(i == right_line_out)
- {
- continue;
- }
- if(i == up_line_out)
- {
- continue;
- }
- if(i == down_line_out)
- {
- continue;
- }
- /// if(m_pExtendInfoSource->GetLineEnt(i)->LineType!=SOLID_LINE)
- // {
- // continue;
- // }
- //竖直的线
- if(fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.x - m_pExtendInfoSource->GetLineEnt(i)->P2.x) < PRECISION && m_pExtendInfoSource->GetLineEnt(i)->P1.x >dleft && m_pExtendInfoSource->GetLineEnt(i)->P1.x <dright) //竖直
- {
- if(fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.y-m_pExtendInfoSource->GetLineEnt(i)->P2.y) >= v_length_2*dratesmall)
- {
- if(left_line_in == -1)
- {
- left_line_in =i;
- }
- if(right_line_in == -1)
- {
- right_line_in =i;
- }
- if(fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.y-m_pExtendInfoSource->GetLineEnt(i)->P2.y) > v_length_2)
- {
- v_length_2 =fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.y-m_pExtendInfoSource->GetLineEnt(i)->P2.y);
- }
- if( (m_pExtendInfoSource->GetLineEnt(i)->P1.x < m_pExtendInfoSource->GetLineEnt(left_line_in)->P1.x+PRECISION)
- && (m_pExtendInfoSource->GetLineEnt(i)->P1.x > m_pExtendInfoSource->GetLineEnt(left_line_out)->P1.x-PRECISION))
- {
- left_line_in = i;
- }
- if((m_pExtendInfoSource->GetLineEnt(i)->P1.x > m_pExtendInfoSource->GetLineEnt(right_line_in)->P1.x-PRECISION)
- && (m_pExtendInfoSource->GetLineEnt(i)->P1.x < m_pExtendInfoSource->GetLineEnt(right_line_out)->P1.x+PRECISION))
- {
- right_line_in = i;
- }
- else if(fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.y-m_pExtendInfoSource->GetLineEnt(i)->P2.y) > v_length_2*dratesmall)
- {
- if( fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.x-m_pExtendInfoSource->GetLineEnt(left_line_in)->P1.x)
- < fabs(m_pExtendInfoSource->GetLineEnt(right_line_in)->P1.x-m_pExtendInfoSource->GetLineEnt(i)->P1.x))
- {
- left_line_in =i;
- }
- else
- {
- right_line_in =i;
- }
- }
- }
- else
- {
- continue;
- }
- }
- //水平的线
- else if(fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.y-m_pExtendInfoSource->GetLineEnt(i)->P2.y) < PRECISION&& m_pExtendInfoSource->GetLineEnt(i)->P1.y >dbottom&& m_pExtendInfoSource->GetLineEnt(i)->P1.y <dtop)
- {
- if(fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.x-m_pExtendInfoSource->GetLineEnt(i)->P2.x) >= h_length_2*dratesmall)
- {
- if(up_line_in == -1)
- {
- up_line_in =i;
- }
- if(down_line_in == -1)
- {
- down_line_in =i;
- }
- if(fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.x-m_pExtendInfoSource->GetLineEnt(i)->P2.x) > h_length_2)
- {
- h_length_2 =fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.x-m_pExtendInfoSource->GetLineEnt(i)->P2.x);
- }
- if((m_pExtendInfoSource->GetLineEnt(i)->P1.y < m_pExtendInfoSource->GetLineEnt(down_line_in)->P1.y)+PRECISION
- && (m_pExtendInfoSource->GetLineEnt(i)->P1.y > m_pExtendInfoSource->GetLineEnt(down_line_out)->P1.y-PRECISION))
- {
- down_line_in = i;
- }
- else if((m_pExtendInfoSource->GetLineEnt(i)->P1.y > m_pExtendInfoSource->GetLineEnt(up_line_in)->P1.y)-PRECISION
- && (m_pExtendInfoSource->GetLineEnt(i)->P1.y < m_pExtendInfoSource->GetLineEnt(up_line_out)->P1.y+PRECISION))
- {
- up_line_in = i;
- }
- else if(fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.x-m_pExtendInfoSource->GetLineEnt(i)->P2.x) > h_length_2*dratesmall)
- {
- if(fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.y-m_pExtendInfoSource->GetLineEnt(down_line_in)->P1.y)
- < fabs(m_pExtendInfoSource->GetLineEnt(up_line_in)->P1.y-m_pExtendInfoSource->GetLineEnt(i)->P1.y))
- {
- down_line_in = i;
- }
- else
- {
- up_line_in = i;
- }
- }
- }
- else
- {
- continue;
- }
- }
- }
- }
- if(up_line_in == -1 || down_line_in == -1 || right_line_in == -1 || left_line_in == -1)
- {
- in_boundary_ok = FALSE;
- }
- if(in_boundary_ok)
- {
- in_boundary_ok =calculate_check_boundary(up_line_in, down_line_in, right_line_in,left_line_in);//检查是否围成矩形框
- if(in_boundary_ok )
- {
- break;
- }
- }
- {
- if(!in_boundary_ok)
- {//使用第二种算法寻找
- in_boundary_ok=TRUE;
- up_line_in =-1, down_line_in =-1, right_line_in =-1, left_line_in =-1,
- xmin =1.0e8, ymin =1.0e8;
- v_len1=0.0, v_len2=0.0;
- //找到外图框
- for(int i=0; i<m_pExtendInfoSource->GetLineBuffSize(); i++)
- {
- // if(m_pExtendInfoSource->GetLineEnt(i)->LineType!=SOLID_LINE)
- // {
- // continue;
- // }
- if(i == left_line_out)
- {
- continue;
- }
- if(i == right_line_out)
- {
- continue;
- }
- if(i == up_line_out)
- {
- continue;
- }
- if(i == down_line_out)
- {
- continue;
- }
- if(fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.x-m_pExtendInfoSource->GetLineEnt(i)->P2.x) < PRECISION&& m_pExtendInfoSource->GetLineEnt(i)->P1.x >dleft && m_pExtendInfoSource->GetLineEnt(i)->P1.x <dright) //竖直
- {
- if(m_pExtendInfoSource->GetLineEnt(i)->P1.x < xmin)
- {
- xmin=m_pExtendInfoSource->GetLineEnt(i)->P1.x;
- }
- if(left_line_in==-1)
- {
- left_line_in=i;
- }
- if(right_line_in==-1)
- {
- right_line_in=i;
- }
- double minx, maxx;
- if(fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.y-m_pExtendInfoSource->GetLineEnt(i)->P2.y) >= v_length_2*dratesmall)
- {
- if(fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.y-m_pExtendInfoSource->GetLineEnt(i)->P2.y) > v_length_2)
- {
- v_length_2 =fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.y-m_pExtendInfoSource->GetLineEnt(i)->P2.y);
- }
- minx =m_pExtendInfoSource->GetLineEnt(left_line_in)->P1.x;
- maxx =m_pExtendInfoSource->GetLineEnt(right_line_in)->P1.x;
- if(fabs(minx)<=PRECISION)
- {
- minx =0;
- }
- if(m_pExtendInfoSource->GetLineEnt(i)->P1.x < minx+PRECISION)
- {
- left_line_in =i;
- }
- if(m_pExtendInfoSource->GetLineEnt(i)->P1.x > maxx-PRECISION)
- {
- right_line_in =i;
- }
- else if(fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.y-m_pExtendInfoSource->GetLineEnt(i)->P2.y) > v_length_2*dratesmall)
- {
- if( fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.x-m_pExtendInfoSource->GetLineEnt(left_line_in)->P1.x)
- < fabs(m_pExtendInfoSource->GetLineEnt(right_line_in)->P1.x-m_pExtendInfoSource->GetLineEnt(i)->P1.x))
- {
- left_line_in = i;
- }
- else
- {
- right_line_in = i;
- }
- }
- }
- else
- {
- continue;
- }
- }
- else if(fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.y-m_pExtendInfoSource->GetLineEnt(i)->P2.y) < PRECISION&& m_pExtendInfoSource->GetLineEnt(i)->P1.y >dbottom&& m_pExtendInfoSource->GetLineEnt(i)->P1.y <dtop)
- {
- if(m_pExtendInfoSource->GetLineEnt(i)->P1.y<ymin)
- {
- ymin =m_pExtendInfoSource->GetLineEnt(i)->P1.y;
- }
- if(up_line_in == -1)
- {
- up_line_in =i;
- }
- if(down_line_in == -1)
- {
- down_line_in =i;
- }
- if(fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.x-m_pExtendInfoSource->GetLineEnt(i)->P2.x) >= h_length_2*dratesmall)
- {
- if(fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.x-m_pExtendInfoSource->GetLineEnt(i)->P2.x) > h_length_2)
- {
- h_length_2 =fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.x-m_pExtendInfoSource->GetLineEnt(i)->P2.x);
- }
- if(m_pExtendInfoSource->GetLineEnt(i)->P1.y < m_pExtendInfoSource->GetLineEnt(down_line_in)->P1.y+PRECISION)
- {
- down_line_in = i;
- }
- else if(m_pExtendInfoSource->GetLineEnt(i)->P1.y > m_pExtendInfoSource->GetLineEnt(up_line_in)->P1.y-PRECISION)
- {
- up_line_in = i;
- }
- else if(fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.x-m_pExtendInfoSource->GetLineEnt(i)->P2.x) > h_length_2*dratesmall)
- {
- if( fabs(m_pExtendInfoSource->GetLineEnt(i)->P1.y-m_pExtendInfoSource->GetLineEnt(down_line_in)->P1.y)
- < fabs(m_pExtendInfoSource->GetLineEnt(up_line_in)->P1.y-m_pExtendInfoSource->GetLineEnt(i)->P1.y))
- {
- down_line_in = i;
- }
- else
- {
- up_line_in = i;
- }
- }
- }
- else
- {
- continue;
- }
- }
- }
- if(up_line_in == -1 || down_line_in == -1 || right_line_in == -1 || left_line_in == -1)
- {
- in_boundary_ok = FALSE;
- }
- if(in_boundary_ok)
- {
- in_boundary_ok =calculate_check_boundary(up_line_in, down_line_in, right_line_in,left_line_in);//检查是否围成矩形框
- if(in_boundary_ok)
- {
- break;
- }
- }
- }
- }
- }
- }
- if(out_boundary_ok) //图框找对
- {
- double dleft=m_pExtendInfoSource->GetLineEnt(left_line_out)->P1.x;
- double dright=m_pExtendInfoSource->GetLineEnt(right_line_out)->P1.x;
- double dtop=m_pExtendInfoSource->GetLineEnt(up_line_out)->P1.y;
- double dbottom=m_pExtendInfoSource->GetLineEnt(down_line_out)->P1.y;
- if(in_boundary_ok)
- {
- double dleftin=m_pExtendInfoSource->GetLineEnt(left_line_in)->P1.x;
- double drightin=m_pExtendInfoSource->GetLineEnt(right_line_in)->P1.x;
- double dtopin=m_pExtendInfoSource->GetLineEnt(up_line_in)->P1.y;
- double dbottomin=m_pExtendInfoSource->GetLineEnt(down_line_in)->P1.y;
- ptRightBottom.x=drightin;
- ptRightBottom.y=dbottomin;
- if(pLegend->SetRect(dleft,dright,dtop,dbottom,dleftin,drightin,dtopin,dbottomin,TRUE,dShowScale))
- {
- return TRUE;
- }
- }
- else
- {
- ptRightBottom.x=dright;
- ptRightBottom.y=dbottom;
- if(pLegend->SetRect(dleft,dright,dtop,dbottom,0.0,0.0,0.0,0.0,FALSE,dShowScale))
- {
- return TRUE;
- }
- }
- }
- else
- {
- dShowScale=-1;
- return FALSE;
- }
- }
- catch(...)
- {
- dShowScale=-1;
- return FALSE;
- }
- dShowScale=-1;
- return FALSE;
- }
- void CExtendInfoIdentify::calculate_text_boundary(S_TEXT* &pText)
- {
- int nSize=strlen(pText->m_czText);
- int nSpecChars=nSize-1;
- for(int i=0; i<nSize; i++)
- {
- if(IsDBCSLeadByte(pText->m_czText[i]))///判断是否为双字节
- {
- i++;
- nSpecChars--;
- }
- }
- //角度已知为0
- pText->m_nWidth=nSize*pText->m_nWidth*0.5+pText->m_dSpace*nSpecChars;
- pText->m_Offset.x+=pText->m_nWidth*0.5;
- pText->m_Offset.y-=pText->m_nHeight*0.5;
- pText->m_nWidth*=0.9;//缩小百分之十
- pText->m_nHeight*=0.9;//缩小百分之十
- }
- //检查是否围成矩形框
- //up_line 上框线
- //down_line 下框线
- //right_line 右框线
- //left_line 左框线
- BOOL CExtendInfoIdentify::calculate_check_boundary(int up_line, int down_line,int right_line, int left_line )
- {
- BOOL flag = TRUE;
- double temp;
- double up_line_xb,up_line_yb,up_line_xe,up_line_ye;
- double down_line_xb,down_line_yb,down_line_xe,down_line_ye;
- double left_line_xb,left_line_yb,left_line_xe,left_line_ye;
- double right_line_xb,right_line_yb,right_line_xe,right_line_ye;
-
- up_line_xb=m_pExtendInfoSource->GetLineEnt(up_line)->P1.x;
- up_line_yb=m_pExtendInfoSource->GetLineEnt(up_line)->P1.y;
- up_line_xe=m_pExtendInfoSource->GetLineEnt(up_line)->P2.x;
- up_line_ye=m_pExtendInfoSource->GetLineEnt(up_line)->P2.y;
- down_line_xb=m_pExtendInfoSource->GetLineEnt(down_line)->P1.x;
- down_line_yb=m_pExtendInfoSource->GetLineEnt(down_line)->P1.y;
- down_line_xe=m_pExtendInfoSource->GetLineEnt(down_line)->P2.x;
- down_line_ye=m_pExtendInfoSource->GetLineEnt(down_line)->P2.y;
- left_line_xb=m_pExtendInfoSource->GetLineEnt(left_line)->P1.x;
- left_line_yb=m_pExtendInfoSource->GetLineEnt(left_line)->P1.y;
- left_line_xe=m_pExtendInfoSource->GetLineEnt(left_line)->P2.x;
- left_line_ye=m_pExtendInfoSource->GetLineEnt(left_line)->P2.y;
- right_line_xb=m_pExtendInfoSource->GetLineEnt(right_line)->P1.x;
- right_line_yb=m_pExtendInfoSource->GetLineEnt(right_line)->P1.y;
- right_line_xe=m_pExtendInfoSource->GetLineEnt(right_line)->P2.x;
- right_line_ye=m_pExtendInfoSource->GetLineEnt(right_line)->P2.y;
- if( up_line_xb > up_line_xe )
- {
- temp = up_line_xb;
- up_line_xb = up_line_xe;
- up_line_xe = temp;
- }
-
- if( down_line_xb > down_line_xe )
- {
- temp = down_line_xb;
- down_line_xb = down_line_xe;
- down_line_xe = temp;
- }
-
- if( left_line_yb > left_line_ye )
- {
- temp = left_line_yb;
- left_line_yb = left_line_ye;
- left_line_ye = temp;
- }
-
- if( right_line_yb > right_line_ye )
- {
- temp = right_line_yb;
- right_line_yb = right_line_ye;
- right_line_ye = temp;
- }
-
- if( fabs(up_line_xb - down_line_xb) > 2 ||
- fabs(up_line_xe - down_line_xe) > 2 )
- {
- flag = FALSE;
- return flag;
- }
-
- if( fabs(left_line_yb - right_line_yb) > 2 ||
- fabs(left_line_ye - right_line_ye) > 2 )
- {
- flag = FALSE;
- return flag;
- }
-
- if( fabs( (up_line_yb - down_line_yb) - (right_line_ye - right_line_yb) ) > 4 )
- {
- flag = FALSE;
- return flag;
- }
-
- if( fabs( (right_line_xb - left_line_xb) - (up_line_xe - up_line_xb) ) > 4 )
- {
- flag = FALSE;
- return flag;
- }
-
- return flag;
- }
- CCellInfo::CCellInfo()
- {
- m_strCellInfo="";
- m_strCellData="";
- }
- CCellInfo::CCellInfo(CCellInfo& cCellInfo)
- {
- m_strCellInfo=cCellInfo.m_strCellInfo;
- m_strCellData=cCellInfo.m_strCellData;
- m_cRect=cCellInfo.m_cRect;
- }
- CCellInfo::~CCellInfo()
- {
- }
- void CCellInfo::Zoom(double dScale)
- {
- m_cRect.left=m_cRect.left*dScale;
- m_cRect.right=m_cRect.right*dScale;
- m_cRect.bottom=m_cRect.bottom*dScale;
- m_cRect.top=m_cRect.top*dScale;
- }
- void CCellInfo::Move(KmPoint ptOffset)
- {
- m_cRect.left+=ptOffset.x;
- m_cRect.right+=ptOffset.x;
- m_cRect.bottom+=ptOffset.y;
- m_cRect.top+=ptOffset.y;
- }
- BOOL CCellInfo::IsSurround(KmBuffer* pData)
- {
- double dWidthPrec=m_cRect.Width()*0.1;//精度为宽度得十分之一
- double dHeightPrec=m_cRect.Height()*0.1;
- double dleft=m_cRect.left+dWidthPrec;
- double dright=m_cRect.right-dWidthPrec;
- double dbottom=m_cRect.bottom+dHeightPrec;
- double dtop=m_cRect.top-dHeightPrec;
- double dTemp;
- BOOL bleft=FALSE;
- BOOL bright=FALSE;
- BOOL bbottom=FALSE;
- BOOL btop=FALSE;
- ASSERT(pData);
- S_LINE_BUFFER* pLine=NULL;
- for(int i=0;i<pData->GetLineBuffSize();i++)
- {
- pLine=pData->GetLineEnt(i);
- if(fabs(pLine->P1.x-pLine->P2.x)<0.01)
- {
- if(pLine->P1.y>pLine->P2.y)
- {
- dTemp=pLine->P1.y;
- pLine->P1.y=pLine->P2.y;
- pLine->P2.y=dTemp;
- }
- //p1.y <= p2.y
- if(!bleft)
- {
- if(fabs(pLine->P1.x-m_cRect.left)<dWidthPrec)
- {
- if(dbottom>pLine->P1.y&&dtop<pLine->P2.y)
- {
- bleft=TRUE;
- if(bleft&&bright&&bbottom&&btop)
- {
- return TRUE;
- }
- }
- }
- }
- if(!bright)
- {
- if(fabs(pLine->P1.x-m_cRect.right)<dWidthPrec)
- {
- if(dbottom>pLine->P1.y&&dtop<pLine->P2.y)
- {
- bright=TRUE;
- if(bleft&&bright&&bbottom&&btop)
- {
- return TRUE;
- }
- }
- }
- }
- }
- if(fabs(pLine->P1.y-pLine->P2.y)<0.01)
- {
- if(pLine->P1.x>pLine->P2.x)
- {
- dTemp=pLine->P1.x;
- pLine->P1.x=pLine->P2.x;
- pLine->P2.x=dTemp;
- }
- //p1.x <= p2.x
- if(!bbottom)
- {
- if(fabs(pLine->P1.y-m_cRect.bottom)<dHeightPrec)
- {
- if(dleft>pLine->P1.x&&dright<pLine->P2.x)
- {
- bbottom=TRUE;
- if(bleft&&bright&&bbottom&&btop)
- {
- return TRUE;
- }
- }
- }
- }
- if(!btop)
- {
- if(fabs(pLine->P1.y-m_cRect.top)<dHeightPrec)
- {
- if(dleft>pLine->P1.x&&dright<pLine->P2.x)
- {
- btop=TRUE;
- if(bleft&&bright&&bbottom&&btop)
- {
- return TRUE;
- }
- }
- }
- }
- }
- }
- return FALSE;
- }
- void CCellInfo::SetData(KmBuffer* pData,BOOL &bWordStyle,CWordStyle& ws)
- {
- double dWidth=m_cRect.Width();
- double dHeight=m_cRect.Height();
- m_strCellData.Empty();
- S_TEXT* pText=NULL;
- CArray<S_TEXT*,S_TEXT*>aTexts;
- CArray<S_TEXT*,S_TEXT*>* paTexts=pData->GetTextBuffer();
- for(int i=0;i<paTexts->GetSize();i++)
- {
- pText=paTexts->GetAt(i);
- if(pText)
- {
- if(m_cRect.PtInRect(pText->m_Offset))
- {
- //1.中心点在矩形内.
- if(dWidth>pText->m_nWidth&&dHeight>pText->m_nHeight)
- {
- if(bWordStyle)
- {
- ws.SetFontName(pText->m_lpszFacename);
- ws.SetHeight(pText->m_nHeight);
- try
- {
- ws.SetWFactor(pText->m_nWidth/pText->m_nHeight);
- }
- catch (...) {
- }
- bWordStyle=FALSE;
- }
- paTexts->RemoveAt(i);
- i--;
- aTexts.Add(pText);
- }
- }
- }
- }
- if(aTexts.GetSize())
- {
- if(aTexts.GetSize()==1)
- {
- m_strCellData=aTexts[0]->m_czText;
- }
- else
- {
- int j=0;
- S_TEXT* pTemp=NULL;
- for(i=aTexts.GetSize()-1;i>=0;i--)
- {
- for(j=0;j<i;j++)
- {
- //按Y从大到小 如果Y相同 X从小到大排序。
- if(fabs(aTexts[i]->m_Offset.y-aTexts[j]->m_Offset.y)<(aTexts[i]->m_nHeight*0.4))
- {
- if(aTexts[i]->m_Offset.x<aTexts[j]->m_Offset.x)
- {
- pTemp=aTexts[i];
- aTexts[i]=aTexts[j];
- aTexts[j]=pTemp;
- }
- }
- else if(aTexts[i]->m_Offset.y>aTexts[j]->m_Offset.y)
- {
- pTemp=aTexts[i];
- aTexts[i]=aTexts[j];
- aTexts[j]=pTemp;
- }
- }
- }
- for(i=0;i<aTexts.GetSize();i++)
- {
- m_strCellData+=aTexts[i]->m_czText;
- }
- }
- for(i=0;i<aTexts.GetSize();i++)
- {
- delete aTexts[i];
- }
- aTexts.RemoveAll();
- }
- }
- CProductInfo::CProductInfo()
- {
- m_bHaveBiaoTi=TRUE;
- }
- CProductInfo::~CProductInfo()
- {
- }
- void CProductInfo::SetBaseInfo(KmPoint ptRightBottom,double dShowScale)
- {
- m_ptRightBottom=ptRightBottom; //右下角
- m_dBiaoTiHight*=dShowScale; //标题栏高度
- m_dBiaoTiWidth*=dShowScale; //标题栏宽度
- m_dMingXiBottomHight*=dShowScale;//明细底栏高度
- m_dMingXiHight*=dShowScale; //明细栏高度
- m_dMingXiWidth*=dShowScale; //明细栏宽度
- for(int i=0;i<m_aBiaoTi.GetSize();i++)
- {
- m_aBiaoTi[i].Zoom(dShowScale);
- m_aBiaoTi[i].Move(ptRightBottom);
- }//标题栏CELL
- // for(i=0;i<m_aMingXiBottom.GetSize();i++)
- // {
- // m_aMingXiBottom[i].Zoom(dShowScale);
- // m_aMingXiBottom[i].Move(ptRightBottom);
- // }//明细底栏CELL
- for(i=0;i<m_aMingXi.GetSize();i++)
- {
- m_aMingXi[i].Zoom(dShowScale);
- m_aMingXi[i].Move(ptRightBottom);
- }//明细栏CELL
- }
- BOOL CProductInfo::LoadFromFile(CString strFileName)
- {
- try
- {
- CString strTemp;
- CStdioFile file;
- if(!file.Open(strFileName, CFile::modeRead))
- {
- return FALSE;
- }
- while(file.ReadString(strTemp))
- {
- if(strTemp=="@@标题栏@@")
- {
- if(!file.ReadString(strTemp))
- {
- return FALSE;
- }
- int iCount=0;
- if(::sscanf(strTemp,"%d,%lf,%lf",&iCount,&m_dBiaoTiWidth,&m_dBiaoTiHight)!=3)
- {
- if(::sscanf(strTemp,"%lf,%lf",&m_dBiaoTiWidth,&m_dBiaoTiHight)!=2)
- {//兼容模式读取。
- return FALSE;
- }
- }
- for(int i=0;i<iCount;i++)
- {
- CCellInfo cCellInfo;
- if(!file.ReadString(strTemp))
- {
- return FALSE;
- }
- int index;
- int iPos=-1;
- iPos=strTemp.Find(',');
- if(iPos==-1)
- {
- return FALSE;
- }
- cCellInfo.m_strCellInfo=strTemp.Right(strTemp.GetLength()-1-iPos);
- strTemp=strTemp.Left(iPos);
- index=::atoi(strTemp);
- if(!file.ReadString(strTemp))
- {
- return FALSE;
- }
- if(::sscanf(strTemp,"%lf,%lf,%lf,%lf",&cCellInfo.m_cRect.left,&cCellInfo.m_cRect.bottom,&cCellInfo.m_cRect.right,&cCellInfo.m_cRect.top)!=4)
- {
- return FALSE;
- }
- cCellInfo.m_cRect.right=cCellInfo.m_cRect.left+cCellInfo.m_cRect.right;
- cCellInfo.m_cRect.top=cCellInfo.m_cRect.bottom+cCellInfo.m_cRect.top;
- m_aBiaoTi.Add(cCellInfo);
- }
- }
- else if(strTemp=="@@明细栏@@")
- {
- if(!file.ReadString(strTemp))
- {
- return FALSE;
- }
- int iCount=0;
- double dTemp1,dTemp2,dTemp3;
- int iTemp;
- //明细栏排列方式(暂固定为1),明细栏列数,明细栏宽,明细底栏高,明细栏数据栏高,
- if(::sscanf(strTemp,"%d,%d,%lf,%lf,%lf,%d,%d,%d",&iTemp,&iCount,&m_dMingXiWidth,&m_dMingXiBottomHight,&m_dMingXiHight,&dTemp1,&dTemp2,&dTemp3)!=8)
- {
- return FALSE;
- }
- for(int i=0;i<iCount;i++)
- {
- CCellInfo cCellInfo;
- if(!file.ReadString(strTemp))
- {
- return FALSE;
- }
- int index;
- int iPos=-1;
- iPos=strTemp.Find(',');
- if(iPos==-1)
- {
- return FALSE;
- }
- cCellInfo.m_strCellInfo=strTemp.Right(strTemp.GetLength()-1-iPos);
- strTemp=strTemp.Left(iPos);
- index=::atoi(strTemp);
- if(!file.ReadString(strTemp))
- {
- return FALSE;
- }
- if(index!=i+1)
- {
- i--;
- continue;
- }
- iPos=strTemp.Find(',');
- if(iPos==-1)
- {
- return FALSE;
- }
- cCellInfo.m_cRect.left=::atof(strTemp.Left(iPos));
- strTemp=strTemp.Right(strTemp.GetLength()-1-iPos);
- iPos=strTemp.Find(',');
- if(iPos==-1)
- {
- return FALSE;
- }
- cCellInfo.m_cRect.right=::atof(strTemp.Left(iPos));
- strTemp=strTemp.Right(strTemp.GetLength()-1-iPos);//对齐方式
- {
- cCellInfo.m_cRect.right=cCellInfo.m_cRect.left+cCellInfo.m_cRect.right;
- cCellInfo.m_cRect.left-=m_dMingXiWidth;
- cCellInfo.m_cRect.right-=m_dMingXiWidth;
- }
- cCellInfo.m_cRect.bottom=0.0;
- cCellInfo.m_cRect.top=m_dMingXiBottomHight;
- m_aMingXiBottom.Add(cCellInfo);
- cCellInfo.m_cRect.top=m_dMingXiHight;
- m_aMingXi.Add(cCellInfo);
- }
- }
- }
- }
- catch(...)
- {
- return FALSE;
- }
- return TRUE;
- }
- void CProductInfo::SetHaveBiaoTi(BOOL bHaveBiaoTi)
- {
- m_bHaveBiaoTi=bHaveBiaoTi;
- }
- void CProductInfo::SetMingXiBottom()
- {
- // if(m_bHaveBiaoTi)
- // {
- // KmPoint ptOffset;
- // ptOffset.x=0.0;
- // ptOffset.y=m_dBiaoTiHight;
- // for(int i=0;i<m_aMingXiBottom.GetSize();i++)
- // {
- // m_aMingXiBottom[i].Move(ptOffset);
- // }//明细底栏CELL
- // }
- }
- void CProductInfo::SetMingXi(int ix,int iy)
- {
- KmPoint ptOffset;
- if(m_bHaveBiaoTi)
- {
- if(ix<1)
- {//第一列
- ptOffset.x=-1*m_dMingXiWidth*ix;
- ptOffset.y=m_dBiaoTiHight+m_dMingXiBottomHight+m_dMingXiHight*iy;
- }
- else
- {//第二列以上
- ptOffset.x=-1*m_dBiaoTiWidth-1*m_dMingXiWidth*(ix-1);
- ptOffset.y=m_dMingXiBottomHight+m_dMingXiHight*iy;
- }
- }
- else
- {
- if(ix<1)
- {//第一列
- ptOffset.x=-1*m_dMingXiWidth*ix;
- ptOffset.y=m_dBiaoTiHight+m_dMingXiBottomHight+m_dMingXiHight*iy;
- }
- else
- {//第二列以上
- ptOffset.x=-1*m_dMingXiWidth*ix;
- ptOffset.y=m_dMingXiBottomHight+m_dMingXiHight*iy;
- }
- }
- m_aMingXiTemp.RemoveAll();
- int j=0;
- for(int i=0;i<m_aMingXi.GetSize();i++)
- {
- j=m_aMingXiTemp.Add(m_aMingXi[i]);
- m_aMingXiTemp[j].Move(ptOffset);
- }
- }
- BOOL CExtendInfoIdentify::IdentifyProductInfo(double dShowScale,KmPoint ptRightBottom,CKmDataManager* pDataMgr)
- {
- BOOL bWordStyle;
- CWordStyle ws;
- if(!pDataMgr)
- {
- return FALSE;
- }
- char szFileName[MAX_PATH+100];
- ::GetModuleFileName(NULL,szFileName,MAX_PATH);
- (*::strrchr(szFileName, '\' ))=' ';
- ::strcat(szFileName, "\support\minxiconv.con");
- CProductInfo cProductInfo;
- if(!cProductInfo.LoadFromFile(szFileName))
- {
- ::GetModuleFileName(NULL,szFileName,MAX_PATH);
- (*::strrchr(szFileName, '\' ))=' ';
- ::strcat(szFileName, "\support\mingxiconv.con");
- if(!cProductInfo.LoadFromFile(szFileName))
- {
- return FALSE;
- }
- }
- cProductInfo.SetBaseInfo(ptRightBottom,1/dShowScale);
- BOOL bHaveBiaoTi=TRUE;
- if(!pDataMgr->GetPicInfoPtr())
- {
- bHaveBiaoTi=FALSE;
- }
- else
- {
- for(int i=0;i<cProductInfo.m_aBiaoTi.GetSize();i++)
- {
- if(!cProductInfo.m_aBiaoTi[i].IsSurround(m_pExtendInfoSource))
- {
- bHaveBiaoTi=FALSE;
- break;
- }
- }
- }
- if(bHaveBiaoTi&&pDataMgr->GetPicInfoPtr())
- {
- PICINFO cInfo;
- cInfo=pDataMgr->GetPicInfoPtr()->GetPicInfo();
- cInfo.Flag=0x330000;
- for(int i=0;i<cInfo.ValueField.GetSize();i++)
- {
- cInfo.ValueField[i].Empty();
- }
- bWordStyle=FALSE;
- //识别标题栏
- for(i=0;i<cProductInfo.m_aBiaoTi.GetSize();i++)
- {
- cProductInfo.m_aBiaoTi[i].SetData(m_pExtendInfoSource,bWordStyle,ws);
- for(int j=0;j<cInfo.AttribField.GetSize();j++)
- {
- if(cProductInfo.m_aBiaoTi[i].m_strCellInfo==cInfo.AttribField[j])
- {
- cInfo.ValueField[j]=cProductInfo.m_aBiaoTi[i].m_strCellData;
- break;
- }
- }
- //不匹配不予处理
- // if(!bFind)
- // {
- // cInfo.AttribField.Add(cProductInfo.m_aBiaoTi[i].m_strCellInfo);
- // cInfo.ValueField.Add(cProductInfo.m_aBiaoTi[i].m_strCellData);
- // }
- }
- pDataMgr->GetPicInfoPtr()->SetPicInfo(cInfo);
- // KmMxManager mxmgr;
- // mxmgr.GenerateBiaotiTable();
- }
- cProductInfo.SetHaveBiaoTi(bHaveBiaoTi);
- BOOL bHaveMingXi=TRUE;
- //由于配置文件中没有明细底栏分两行时底高度信息,故不判断
- // cProductInfo.SetMingXiBottom();
- // for(int i=0;i<cProductInfo.m_aMingXiBottom.GetSize();i++)
- // {
- // if(!cProductInfo.m_aMingXiBottom[i].IsSurround(m_pExtendInfoSource))
- // {
- // bHaveMingXi=FALSE;
- // break;
- // }
- // }
- int utMingXiText=-1;
- if(bHaveMingXi)
- {
- //设置明细配置项数组
- KmMxConfig* pMxConfig=pDataMgr->GetMxConfig();
- if(pMxConfig)
- {
- pMxConfig->m_BomHeight=cProductInfo.m_dMingXiBottomHight*dShowScale;
- pMxConfig->m_OtherHeight=cProductInfo.m_dMingXiHight*dShowScale;
- KmMxContent* pMxContent=pDataMgr->GetMxContent();
- if(pMxConfig&&pMxContent)
- {
- //首先清空明细记录。
- KmMxRec* pOld=NULL;
- while(pMxContent->RemoveMxRecAt(0,pOld))
- {
- delete pOld;
- pOld=NULL;
- }
- //然后清空明细配置
- CArray<MxConfigItem,MxConfigItem>* pMxConfigItems=pMxConfig->GetConfigItems();
- ASSERT(pMxConfigItems);
- pMxConfigItems->RemoveAll();
- //再添加明细配置
- MxConfigItem cMxConfigItem;
- for(int i=0;i<cProductInfo.m_aMingXiBottom.GetSize();i++)
- {
- cMxConfigItem.m_uIndex=(UINT)(i+1);//从1开始
- cMxConfigItem.m_strName=cProductInfo.m_aMingXiBottom[i].m_strCellInfo;
- cMxConfigItem.m_fColWidth=cProductInfo.m_aMingXiBottom[i].m_cRect.Width();
- cMxConfigItem.m_uAlignMode=KT_ALIGN_CENTER|KT_ALIGN_LEFT;
- pMxConfigItems->Add(cMxConfigItem);
- }
- KmMxRec cKmMxRec;
- int index=0;
- int ix=0;
- do
- {
- int iy=0;
- do
- {
- {//doing
- cProductInfo.SetMingXi(ix,iy);
- BOOL bRight=TRUE;
- for(int i=0;i<cProductInfo.m_aMingXiTemp.GetSize();i++)
- {
- if(!cProductInfo.m_aMingXiTemp[i].IsSurround(m_pExtendInfoSource))
- {
- bRight=FALSE;
- break;
- }
- }
- if(!bRight)
- {
- ix=10000;
- iy=10000;
- break;
- }
- //读出一条明细内容。
- cKmMxRec.m_uFlag=OTHER_MX;
- cKmMxRec.m_aContent.RemoveAll();
-
- for(i=0;i<cProductInfo.m_aMingXiTemp.GetSize();i++)
- {
- if(utMingXiText<=0)
- {
- bWordStyle=TRUE;
- cProductInfo.m_aMingXiTemp[i].SetData(m_pExtendInfoSource,bWordStyle,ws);
- if(!bWordStyle)
- {
- ws.SetHeight(ws.GetHeight()*dShowScale);
- utMingXiText=pDataMgr->AddWordStyle(ws);
- }
- }
- else
- {
- bWordStyle=FALSE;
- cProductInfo.m_aMingXiTemp[i].SetData(m_pExtendInfoSource,bWordStyle,ws);
- ws.SetHeight(ws.GetHeight()*dShowScale);
- }
- cKmMxRec.m_aContent.Add(cProductInfo.m_aMingXiTemp[i].m_strCellData);
- }
- //写到东方CAD中去。
- pMxContent->AddMxRec(cKmMxRec);
- }
- iy++;
- }
- while(iy<200);//最多200列
- ix++;
- }
- while(ix<10);//最多十行
- }
- for(int m=0;m<pMxContent->GetMxRecNum();m++)
- pMxContent->GetMxRecAt(m).Release();
- pMxContent->SetBaseWSID(utMingXiText);
- CKmDataManager* pBack=::GetActiveDataManager();
- ::SetActiveDataManager(pDataMgr);
- KmMxManager mxmgr;
- mxmgr.GenerateMxTable(TRUE);
- mxmgr.HideMx(TRUE,NULL);
- ::SetActiveDataManager(pBack);
- }
- }
- return TRUE;
- }