コード例 #1
0
ファイル: fpdf_text.cpp プロジェクト: 151706061/PDFium
void CTextBaseLine::WriteOutput(CFX_WideString& str, FX_FLOAT leftx, FX_FLOAT pagewidth,
                                int iTextWidth)
{
    int lastpos = -1;
    for (int i = 0; i < m_TextList.GetSize(); i ++) {
        CTextBox* pText = (CTextBox*)m_TextList.GetAt(i);
        int xpos;
        if (pText->m_pColumn) {
            xpos = (int)((pText->m_pColumn->m_AvgPos - leftx) * iTextWidth / pagewidth + 0.5);
            xpos -= pText->m_Text.GetLength();
        } else {
            xpos = (int)((pText->m_Left - leftx) * iTextWidth / pagewidth + 0.5);
        }
        if (xpos <= lastpos) {
            xpos = lastpos + 1;
        }
        for (int j = lastpos + 1; j < xpos; j ++) {
            str += ' ';
        }
        CFX_WideString sSrc(pText->m_Text);
        NormalizeString(sSrc);
        str += sSrc;
        str += ' ';
        lastpos = xpos + pText->m_Text.GetLength();
    }
}
コード例 #2
0
ファイル: SString.cpp プロジェクト: wolfspelz/Apollo
char* String::strncpy(char* dest, const char* src, size_t bufSize)
{
  if (strlen(src) < bufSize) { // < because of trailing \0
    return ::strcpy(dest, src);
  } else {
    String sSrc(src);
    return strcpy(dest, (const char*) sSrc.subString(0, bufSize - 1));
  }
};
コード例 #3
0
void EDetailManager::UpdateSlotBBox(int sx, int sz, DetailSlot& slot)
{
	Fbox bbox;
    Frect rect;
    GetSlotRect			(rect,sx,sz);
    bbox.min.set		(rect.x1, m_BBox.min.y, rect.y1);
    bbox.max.set		(rect.x2, m_BBox.max.y, rect.y2);

    SBoxPickInfoVec pinf;
    ETOOLS::box_options(0);
    if (Scene->BoxPickObjects(bbox,pinf,&m_SnapObjects)){
		bbox.grow		(EPS_L_VAR);
    	Fplane			frustum_planes[4];
		frustum_planes[0].build(bbox.min,left_vec);
		frustum_planes[1].build(bbox.min,back_vec);
		frustum_planes[2].build(bbox.max,right_vec);
		frustum_planes[3].build(bbox.max,fwd_vec);

        CFrustum frustum;
        frustum.CreateFromPlanes(frustum_planes,4);

        float y_min		= flt_max;
        float y_max		= flt_min;
		for (SBoxPickInfoIt it=pinf.begin(); it!=pinf.end(); it++){
        	for (int k=0; k<(int)it->inf.size(); k++){
                float range;
                Fvector verts[3];
                it->e_obj->GetFaceWorld(it->s_obj->_Transform(),it->e_mesh,it->inf[k].id,verts);
                sPoly sSrc	(verts,3);
                sPoly sDest;
                sPoly* sRes = frustum.ClipPoly(sSrc, sDest);
                if (sRes){
                    for (u32 k=0; k<sRes->size(); k++){
                        float H = (*sRes)[k].y;
                        if (H>y_max) y_max = H+0.03f;
                        if (H<y_min) y_min = H-0.03f;
                    }
                    slot.w_y	(y_min,y_max-y_min);
                    slot.w_id(0,DetailSlot::ID_Empty);
                    slot.w_id(1,DetailSlot::ID_Empty);
                    slot.w_id(2,DetailSlot::ID_Empty);
                    slot.w_id(3,DetailSlot::ID_Empty);
                }
            }
	    }
    }else{
    	ZeroMemory(&slot,sizeof(DetailSlot));
    	slot.w_id(0,DetailSlot::ID_Empty);
    	slot.w_id(1,DetailSlot::ID_Empty);
    	slot.w_id(2,DetailSlot::ID_Empty);
    	slot.w_id(3,DetailSlot::ID_Empty);
    }
}
コード例 #4
0
ファイル: COPYBLK.CPP プロジェクト: abcweizhuo/Test3
int CCopyBlock::CopyTagBlocks()
  {
  CWaitCursor Wait;
//  ASSERT(eSrc!=CB_List); //this src type not allowed
//  ASSERT(eDst!=CB_Tag); //this dst type not allowed
  ASSERT(pEO);
  CProfINIFile SrcPF(bSrcDatalib ? CfgFiles() : PrjFiles(), (char*)CopyBlkFileName);
  CheckCopyBlockVer(SrcPF);
  CProfINIFile DstPF(bDstDatalib ? CfgFiles() : PrjFiles(), (char*)CopyBlkFileName);
  if (!CheckCopyBlockVer(DstPF, true))
    return 0;
  int Cnt = 0;
  //gs_pTheSFELib->FE_SetHoldGlobalLinks(true);
  //gs_Exec.SetHoldValidateData(true, true, true);
  gs_Exec.BeginBulkChange();

  Strng Section;
  if (eSrc==CB_SelectedTag)
    Section = TempBlockName;
  else
    Section.Set("%s(%s)", sSrc(), sModelClass());
  char Buff[16384];
  DWORD dw = SrcPF.RdSection(Section(), Buff, sizeof(Buff));
  ASSERT(dw<sizeof(Buff)-2); //section too large!!!
  if (eDst==CB_Block)
    {
    Strng DstSection;
    DstSection.Set("%s(%s)", sDst(), sModelClass());
    DstPF.WrSection(DstSection(), Buff);
    }
  else
    {
    Strng_List sStrList;
    CXM_Route Route;
    CXM_ObjectData ObjData;
    char* p = Buff;
    while (p[0])
      {
      int len = strlen(p);
      char* Nextp = p;
      Nextp += (len + 1);
      char* pp = strchr(p, '=');
      if (pp)
        {
        pp[0] = 0;
        char* pValue = &pp[1];
        char* ppp = strchr(p, '.');
        Strng PartTag;
        PartTag = (ppp==NULL ? p : ppp);
        for (int i=0; i<TagList.GetSize(); i++)
          {
          Strng WrkTag(TagList[i]());
          WrkTag += PartTag;
          //CXM_ObjectTag ObjTag(WrkTag(), 0);
          //need to use TABOpt_AllInfoOnce because of tags that contain a strList!
          CXM_ObjectTag ObjTag(WrkTag(), TABOpt_AllInfoOnce);//0);//TABOpt_Exists);//TABOpt_Parms);//TABOpt_ValCnvsOnce);
          Route.Clear();
          if (pEO->XReadTaggedItem(ObjTag, ObjData, Route))
            {
            CPkDataItem * pItem = ObjData.FirstItem();
            byte cType = pItem->Type();
            PkDataUnion DU;
            if (IsStrng(cType))
              DU.SetTypeString(cType, pValue);
            else if (IsFloatData(cType))
              DU.SetTypeDouble(cType, SafeAtoF(pValue));
            else if (IsIntData(cType) && pItem->Contains(PDI_StrList))
              {
              pItem->GetStrList(sStrList);
              pStrng pS = sStrList.Find(pValue);
              //const int Indx = (pS==NULL ? 0 : sStrList.Index(pS));
              const int Indx = (pS==NULL ? 0 : pS->Index());
              DU.SetTypeLong(cType, Indx);
              }
            else
              DU.SetTypeLong(cType, SafeAtoL(pValue));
            CXM_ObjectData OD(0, 0, WrkTag(), 0, DU);
            if (pEO->XWriteTaggedItem(OD, Route)==TOData_NotFound)
              LogWarning(WrkTag(), 0, "Write tag failed");
            else
              Cnt++;
            //if (pEO->XWriteTaggedItem(OD, Route)!=TOData_OK)
            //  LogWarning(WrkTag(), 0, "Write tag failed (possibly invalid data)");
            }
          else
            LogWarning(WrkTag(), 0, "Unable to read tag");
          }
        }
      p = Nextp;
      }
    }
  
  //TaggedObject::SetHoldValidateData(false);
  //gs_Exec.SetHoldValidateData(false, true, true);
  //gs_pTheSFELib->FE_SetHoldGlobalLinks(false);
  gs_Exec.EndBulkChange();


  //TaggedObject::SetXWritesBusy(false);
  return Cnt;
  }