SeeNote.cpp 2.24 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
#include "stdafx.h"
#include "SeeNote.h"


CSeeNote::CSeeNote(std::vector<CShareFolder*> list,int index)
{
	m_list = list;
	m_index = index;
}


CSeeNote::~CSeeNote(void)
{
}

void CSeeNote::SplitString2Float(CString sourceStr,float ratio_x,float ratio_y,CString& newStr)
{
	sourceStr.Replace(_T(";"),_T(""));
	std::string temp1=CT2A(sourceStr.GetBuffer());
	std::vector<CString> list;
	int pos=sourceStr.Find(_T(","));
	while(pos>0)
	{
		CString temp=sourceStr.Mid(0,pos);
		int size=list.size();
		std::string temp1=CT2A(temp.GetBuffer());
		temp.ReleaseBuffer();
		CString f_temp=FloatStr2Floar(temp1,ratio_x,ratio_y,size);
		list.push_back(f_temp);
		sourceStr=sourceStr.Mid(pos+1,sourceStr.GetLength()-pos-1);
		pos=sourceStr.Find(_T(","));
		if(pos<0)
		{
			size=list.size();
			std::string temp11=CT2A(sourceStr.GetBuffer());
			CString f1_temp=FloatStr2Floar(temp11,ratio_x,ratio_y,size);
			sourceStr.ReleaseBuffer();
			list.push_back(f1_temp);
		}
	}
	for(int i=0;i<list.size();i++)
	{
		int size = newStr.GetLength();
		if(size>0)
		{
			newStr=newStr+_T(",")+list.at(i);
		}
		else
			newStr=list.at(i);
	}
}

int CSeeNote::CoordChange( CPDFNoteInfo* info)
{
	int iRet=-1;
	if (info->pageWidth>10 && info->pageHeight>10)
	{
		iRet=0;
		double width;
		double height;
		PDF_GetPageSize(info->pageIndex,width,height);
		float ratio_x=(float)info->pageWidth/(float)width;
		float ratio_y=(float)info->pageHeight/(float)height;
		if(info->pdfNoteType==NoteFreedom)
		{
			for(int i=0;i<info->m_free_pen_line.size();i++)
			{
				FREE_PEN_INFO* freePen=info->m_free_pen_line.at(i);
				CString StrCoord=freePen->coord;
				freePen->coord=_T("");
				SplitString2Float(StrCoord,ratio_x,ratio_y,freePen->coord);
			}
		}
		else
		{

			CString new_coord;
			SplitString2Float(info->coord,ratio_x,ratio_y,new_coord);
			info->coord=new_coord;

		}
	}
	else
	{
		iRet =-1;
	}
	return iRet;
}
CString CSeeNote::FloatStr2Floar(std::string str,float ratio_x,float ratio_y,int size)
{
	if(ratio_x==0.0||ratio_y==0.0)
	{
		ratio_x =1.0;
		ratio_y =1.0;
	}


	float f_temp=atof(str.c_str());
	if(size==0 || size%2==0)
		f_temp*=ratio_x;
	else
		f_temp*=ratio_y;
	CString temp;
	temp.Format(_T("%.2f"),f_temp);
	//f_temp = ( (float)( (int)( (f_temp + 0.005) * 100 ) ) ) / 100;
	return temp;
}