新版本读取老版本文件崩溃BUG
读取文件匹配代码
BOOL CWBPage::LoadFromFile(CFile *pFile, LONGLONG& lOff, ULONGLONG lFileLength)
{
if (pFile == NULL)
{
return FALSE;
} LONGLONG lPageOff = lOff; //页偏移量
//读取页长度
ULONGLONG lPageLength; //页内容长度 pFile->Seek(lPageOff, CFile::begin);
pFile->Read((char *)&lPageLength, sizeof(ULONGLONG));
if ((lPageOff + lPageLength) > lFileLength)
{
return FALSE;
}
lPageOff += sizeof(ULONGLONG);//偏移量增加 if (lPageLength <= ) //如果是空页
{
lOff = lPageOff;
return TRUE;
} //读取所有对象
//int nlayerIndex = 1; //对象图层号
while ((ULONGLONG)(lPageOff - lOff) < lPageLength)
{
//读取对象类型
char chObjType;
pFile->Seek(lPageOff, CFile::begin);
pFile->Read(&chObjType, );
int nObjType = (int)chObjType; switch (nObjType)
{
case WB_OBJ_LINE: //直线
{
CWBLine *pLine = new CWBLine();
if (NULL == pLine)
{
return FALSE;
}
if (!pLine->LoadFromFile(pFile, lPageOff, lFileLength))
{
delete pLine;
return FALSE;
}
//pLine->SetLayerIndex(nlayerIndex); //设置对象图层号 //m_pWBObjList->AddTail(pLine);
AddWBObject(pLine, pLine->GetLayerType());
}
break;
case WB_OBJ_CURVE: //曲线
{
CWBCurve *pCurve = new CWBCurve();
if (NULL == pCurve)
{
return FALSE;
}
if (!pCurve->LoadFromFile(pFile, lPageOff, lFileLength))
{
delete pCurve;
return FALSE;
}
//pCurve->SetLayerIndex(nlayerIndex); //设置对象图层号 //m_pWBObjList->AddTail(pCurve);
AddWBObject(pCurve, pCurve->GetLayerType());
}
break;
case WB_OBJ_ICOCURVE: //图标曲线
{
CWBIcoCurve *pIcoCurve = new CWBIcoCurve();
if (NULL == pIcoCurve)
{
return FALSE;
}
if (!pIcoCurve->LoadFromFile(pFile, lPageOff, lFileLength))
{
delete pIcoCurve;
return FALSE;
} AddWBObject(pIcoCurve, pIcoCurve->GetLayerType());
}
break;
case WB_OBJ_POLYGON: //多边形
{
CWBPolygon *pPolygon = new CWBPolygon();
if (NULL ==pPolygon)
{
return FALSE;
}
if (!pPolygon->LoadFromFile(pFile, lPageOff, lFileLength))
{
delete pPolygon;
return FALSE;
}
//pPolygon->SetLayerIndex(nlayerIndex); //m_pWBObjList->AddTail(pPolygon);
AddWBObject(pPolygon, pPolygon->GetLayerType());
}
break;
case WB_OBJ_RECT: //矩形
{
CWBRectangle *pRect = new CWBRectangle();
if (NULL == pRect)
{
return FALSE;
}
if (!pRect->LoadFromFile(pFile, lPageOff, lFileLength))
{
delete pRect;
return FALSE;
}
//pRect->SetLayerIndex(nlayerIndex);
//m_pWBObjList->AddTail(pRect);
AddWBObject(pRect, pRect->GetLayerType());
}
break;
case WB_OBJ_TEXT: //文本
{
CWBText *pText = new CWBText();
if (NULL == pText)
{
return FALSE;
}
if(!pText->LoadFromFile(pFile, lPageOff, lFileLength))
{
delete pText;
return FALSE;
}
//pText->SetLayerIndex(nlayerIndex); //m_pWBObjList->AddTail(pText);
AddWBObject(pText, pText->GetLayerType());
}
break;
case WB_OBJ_PICTURE: //图片
{
CWBPicture *pPicture = new CWBPicture();
if (NULL == pPicture)
{
return FALSE;
}
if (!pPicture->LoadFromFile(pFile, lPageOff, lFileLength))
{
delete pPicture;
return FALSE;
}
//pPicture->SetLayerIndex(nlayerIndex); //m_pWBObjList->AddTail(pPicture);
AddWBObject(pPicture, pPicture->GetLayerType());
}
break;
case WB_OBJ_DXF: //dxf
{
CWBDxf *pDxf = new CWBDxf();
if (NULL == pDxf)
{
return FALSE;
}
if (!pDxf->LoadFromFile(pFile, lPageOff, lFileLength))
{
delete pDxf;
return FALSE;
}
AddWBObject(pDxf, pDxf->GetLayerType());
}
break;
case WB_OBJ_FLASH: //flash
{
CWBFlash *pFlash = new CWBFlash();
if (NULL == pFlash)
{
return FALSE;
}
if (!pFlash->LoadFromFile(pFile, lPageOff, lFileLength))
{
delete pFlash;
return FALSE;
}
//pFlash->SetLayerIndex(nlayerIndex); //m_pWBObjList->AddTail(pFlash);
AddWBObject(pFlash, pFlash->GetLayerType());
}
break; case WB_OBJ_ELLIPSE: //椭圆
{
CWBEllipse *pEllipse = new CWBEllipse();
if (NULL == pEllipse)
{
return FALSE;
}
if(!pEllipse->LoadFromFile(pFile, lPageOff, lFileLength))
{
delete pEllipse;
return FALSE;
}
//pEllipse->SetLayerIndex(nlayerIndex);
//m_pWBObjList->AddTail(pEllipse);
AddWBObject(pEllipse, pEllipse->GetLayerType());
}
break;
case WB_OBJ_TRIANGLE: //三角形
{
CWBTriangle *pTriangle = new CWBTriangle();
if ( NULL == pTriangle)
{
return FALSE;
}
if (!pTriangle->LoadFromFile(pFile, lPageOff, lFileLength))
{
delete pTriangle;
return FALSE;
}
//pTriangle->SetLayerIndex(nlayerIndex); //m_pWBObjList->AddTail(pTriangle);
AddWBObject(pTriangle, pTriangle->GetLayerType());
}
break;
case WB_OBJ_RHOMBUS: //菱形
{
CWBRhombus *pRhombus = new CWBRhombus();
if (NULL == pRhombus)
{
return FALSE;
}
if (!pRhombus->LoadFromFile(pFile, lPageOff, lFileLength))
{
delete pRhombus;
return FALSE;
}
//pRhombus->SetLayerIndex(nlayerIndex); //m_pWBObjList->AddTail(pRhombus);
AddWBObject(pRhombus, pRhombus->GetLayerType());
}
break;
case WB_OBJ_PENTAGON: //五边形
{
CWBPentagon *pPentagon = new CWBPentagon();
if (NULL == pPentagon)
{
return FALSE;
}
if (!pPentagon->LoadFromFile(pFile, lPageOff, lFileLength))
{
delete pPentagon;
return FALSE;
}
//pPentagon->SetLayerIndex(nlayerIndex); //m_pWBObjList->AddTail(pPentagon);
AddWBObject(pPentagon, pPentagon->GetLayerType());
}
break;
case WB_OBJ_HEXAGON: //六边形
{
CWBHexagon *pHexagon = new CWBHexagon();
if (NULL == pHexagon)
{
return FALSE;
}
if (!pHexagon->LoadFromFile(pFile, lPageOff, lFileLength))
{
delete pHexagon;
return FALSE;
}
//pHexagon->SetLayerIndex(nlayerIndex); //m_pWBObjList->AddTail(pHexagon);
AddWBObject(pHexagon, pHexagon->GetLayerType());
}
break;
case WB_OBJ_FIVEPOINTSTART: //五角星
{
CWBFivepointstart *pFivepointstart = new CWBFivepointstart();
if (NULL == pFivepointstart)
{
return FALSE;
}
if (!pFivepointstart->LoadFromFile(pFile, lPageOff, lFileLength))
{
delete pFivepointstart;
return FALSE;
}
//pFivepointstart->SetLayerIndex(nlayerIndex); //m_pWBObjList->AddTail(pFivepointstart);
AddWBObject(pFivepointstart, pFivepointstart->GetLayerType());
}
break;
case WB_OBJ_TRAPEZIUM: //梯形
{
CWBTrapezium *pTrapezium = new CWBTrapezium();
if (NULL == pTrapezium)
{
return FALSE;
}
if (!pTrapezium->LoadFromFile(pFile, lPageOff, lFileLength))
{
delete pTrapezium;
return FALSE;
}
//pTrapezium->SetLayerIndex(nlayerIndex); //m_pWBObjList->AddTail(pTrapezium);
AddWBObject(pTrapezium, pTrapezium->GetLayerType());
}
break;
case WB_OBJ_MEDIA:
{
//加载新视频
CWBMedia* pMedia = new CWBMedia(NULL);
if (NULL == pMedia)
{
return FALSE;
}
if (!pMedia->LoadFromFile(pFile, lPageOff, lFileLength))
{
delete pMedia;
pMedia = NULL;
return FALSE;
}
//将新视频的显示状态全部设置为隐藏,否则会在第一页显示出所有的视频
if (g_pWhiteBoardView->m_bIsCombin)//主要组合和正常打开有点区别问题wangxiaobin
{
if (g_PageCount >= )
{
pMedia->HideAndPauseMedia();
}
}
else
{
if (g_PageCount > )
{
pMedia->HideAndPauseMedia();
}
} AddWBObject(pMedia, pMedia->GetLayerType());
}
break;
case WB_OBJ_DOCUMENT:
{
CWBDocument *pDoc = new CWBDocument();
if (NULL == pDoc)
{
return FALSE;
}
pDoc->SetPageIndex(g_PageCount);
if (!pDoc->LoadFromFile(pFile, lPageOff, lFileLength))
{
delete pDoc;
return FALSE;
}
//pDoc->SetLayerIndex(nlayerIndex); //m_pWBObjList->AddTail(pDoc);
AddWBObject(pDoc, pDoc->GetLayerType());
}
break;
case WB_OBJ_COMBINE:
{
CWBCombine *pCombine = new CWBCombine();
if (NULL == pCombine)
{
return FALSE;
}
if (!pCombine->LoadFromFile(pFile, lPageOff, lFileLength))
{
delete pCombine;
return FALSE;
}
//pCombine->SetLayerIndex(nlayerIndex); //m_pWBObjList->AddTail(pCombine);
m_nWBMaxLayerId = pCombine->GetPageLayerIndex();
AddWBObject(pCombine, pCombine->GetLayerType());
}
break;
case WB_OBJ_ANNOTATIONS:
{
CWBAnnotations *pAnnotations = new CWBAnnotations();
if (NULL == pAnnotations)
{
return FALSE;
}
if (!pAnnotations->LoadFromFile(pFile, lPageOff, lFileLength))
{
delete pAnnotations;
return FALSE;
}
//pAnnotations->SetLayerIndex(nlayerIndex); //m_pWBObjList->AddTail(pAnnotations);
AddWBObject(pAnnotations, pAnnotations->GetLayerType());
}
break;
case WB_OBJ_BAFFLE:
{
CWBBafflePlate *pBafflePlate = new CWBBafflePlate();
if (NULL == pBafflePlate)
{
return FALSE;
}
if (!pBafflePlate->LoadFromFile(pFile, lPageOff, lFileLength))
{
delete pBafflePlate;
return FALSE;
}
//pBafflePlate->SetLayerIndex(nlayerIndex); //m_pWBObjList->AddTail(pBafflePlate);
AddWBObject(pBafflePlate, pBafflePlate->GetLayerType());
}
break;
default:
return FALSE;
}
} //m_dwCurObjLayerIndex = nlayerIndex - 1; //设置当前图层号
lOff = lPageOff;
return TRUE;
}
老版本对象枚举类型代码
enum WB_OBJ_TYPE
{
WB_OBJ_NORMAL = ,
WB_OBJ_LINE, //直线
WB_OBJ_CURVE, //曲线
WB_OBJ_ICOCURVE,//图标曲线
WB_OBJ_POLYGON, //多边形
WB_OBJ_RECT, //矩形
WB_OBJ_SELECTRECT, //选择框
WB_OBJ_PICTURE, //图片
WB_OBJ_MOVIE, //视频
WB_OBJ_MEDIA, //新视频
WB_OBJ_FLASH, //FLASH
WB_OBJ_DOCUMENT, //文档
WB_OBJ_TEXT, //文字
WB_OBJ_ELLIPSE, //椭圆
WB_OBJ_TRIANGLE, //三角形
WB_OBJ_RHOMBUS, //菱形
WB_OBJ_BAFFLE, //挡板
WB_OBJ_COMBINE, //组合
WB_OBJ_MAQN, //放大镜
WB_OBJ_SPOTLIGHT, //聚光灯
WB_OBJ_ANNOTATIONS, //标注
WB_OBJ_CAMERA, //摄像头
WB_OBJ_DUSTBIN, //垃圾箱
WB_OBJ_RULER,//直尺
WB_OBJ_PROTRACTOR,//量角器
WB_OBJ_ANGLE, //生成刻度
WB_OBJ_SETSQUARE,//三角板
WB_OBJ_COMPASS, //圆规
WB_OBJ_ARC, //圆弧
WB_OBJ_SECTOR, //扇形
WB_OBJ_ARBITRARYTRIANGLE, //任意三角形
WB_OBJ_PALLELOGAM, //平行四边形
WB_OBJ_PENTAGON, //五边形
WB_OBJ_HEXAGON, //六边形
WB_OBJ_FIVEPOINTSTART, //五角星
WB_OBJ_TRAPEZIUM, //梯形
WB_OBJ_DXF //DXF
};
新版本对象枚举类型代码
enum WB_OBJ_TYPE
{
WB_OBJ_NORMAL = ,
WB_OBJ_TRAPEZIUM, //梯形
WB_OBJ_LINE, //直线
WB_OBJ_CURVE, //曲线
WB_OBJ_ICOCURVE,//图标曲线
WB_OBJ_POLYGON, //多边形
WB_OBJ_RECT, //矩形
WB_OBJ_SELECTRECT, //选择框
WB_OBJ_PICTURE, //图片
WB_OBJ_MOVIE, //视频
WB_OBJ_MEDIA, //新视频
WB_OBJ_FLASH, //FLASH
WB_OBJ_DOCUMENT, //文档
WB_OBJ_TEXT, //文字
WB_OBJ_ELLIPSE, //椭圆
WB_OBJ_TRIANGLE, //三角形
WB_OBJ_RHOMBUS, //菱形
WB_OBJ_BAFFLE, //挡板
WB_OBJ_COMBINE, //组合
WB_OBJ_MAQN, //放大镜
WB_OBJ_SPOTLIGHT, //聚光灯
WB_OBJ_ANNOTATIONS, //标注
WB_OBJ_CAMERA, //摄像头
WB_OBJ_DUSTBIN, //垃圾箱
WB_OBJ_RULER,//直尺
WB_OBJ_PROTRACTOR,//量角器
WB_OBJ_ANGLE, //生成刻度
WB_OBJ_SETSQUARE,//三角板
WB_OBJ_COMPASS, //圆规
WB_OBJ_ARC, //圆弧
WB_OBJ_SECTOR, //扇形
WB_OBJ_ARBITRARYTRIANGLE, //任意三角形
WB_OBJ_PALLELOGAM, //平行四边形
WB_OBJ_PENTAGON, //五边形
WB_OBJ_HEXAGON, //六边形
WB_OBJ_FIVEPOINTSTART, //五角星
WB_OBJ_DXF //DXF
};
在新版本中由于有人把WB_OBJ_TRAPEZIUM, //梯形
放在了第二行,原来第二行是WB_OBJ_LINE, //直线
保存老版本的时候1代表的是WB_OBJ_LINE, //直线
新版本中1代表的是WB_OBJ_TRAPEZIUM, //梯形
char chObjType;
pFile->Seek(lPageOff, CFile::begin);
pFile->Read(&chObjType, 1);
int nObjType = (int)chObjType;
由于Read()中nOjbType得到的是枚举类型中的对应的整形数,因此在读取老版本中保存的直线时候,匹配到的对象是新版本中的梯形,会去梯形类中读取,导致读取文件失败。
新版本读取老版本文件崩溃BUG的更多相关文章
- 安装VS2010后,如何设置老版本的项目文件不是默认用VS2010打开
1.系统先后安装了VS2008和VS2010,在打开用VS2008创建的项目文件时总是会默认用VS2010打开,选择打开方式都不行,很不方便,差点要把VS2010卸载了. 其实只需要简单设置V ...
- 一种解决新版本API完全兼容老版本API的方法
原文:http://android.eoe.cn/topic/android_sdk 这节课程我们讨论如何创建一个实现类,即能对应新版本的API,又能够保持对老版本API的支持. * 寻找一个替代的解 ...
- [C#]读取不同版本的excel文件的方法
--------------------------------2007及以上的版本-------------------------------- 测试如下: //DataInterface.Met ...
- 使用 Microsoft.UI.Xaml 解决 UWP 控件和对老版本 Windows 10 的兼容性问题
原文 使用 Microsoft.UI.Xaml 解决 UWP 控件和对老版本 Windows 10 的兼容性问题 虽然微软宣称 Windows 10 将是最后一个 Windows 版本,但由于年代跨越 ...
- cento升级openssl依旧显示老版本
不久前拿到了一季度的服务器漏洞扫描报告,还是一些老生常谈的软件.按照报告上的漏洞一个个处理,开始升级openssl的时候一切都很顺利,上传源码包,解压,编译,安装,全部都没有报错.opessl --v ...
- Atitit.播放系统规划新版本 and 最近版本回顾 v3 pbf.doc 1 版本11 (ing)41.1 规划h5本地缓存系列 41.2 Android版本app41.3 双类别系统,
Atitit.播放系统规划新版本 and 最近版本回顾 v3 pbf.doc 1 版本11 (ing)4 1.1 规划h5本地缓存系列 4 1.2 Android版本app4 1.3 双类别系统, ...
- Atitit.播放系统规划新版本 and 最近版本回顾 v3 pbf.doc
Atitit.播放系统规划新版本 and 最近版本回顾 v3 pbf.doc 1 版本11 (ing)4 1.1 规划h5本地缓存系列 4 1.2 Android版本app4 1.3 双类别系统, ...
- vue-cli脚手架工具新老版本安装对比
1.老版本 Shift+鼠标右键 选择打开命令窗口 1.创建项目之前,需先确保本机已经安装node 在命令窗口中执行node -v npm -v 2.一般情况下用npm安装东西比较慢,可以使用淘宝 ...
- 如何给不支持新特性的浏览器打补丁(让老版本IE兼容新特性)
一个非常棒的 JavaScript 框架叫做 Modernizr(http://www.modernizr. com),用于向缺少 HTML5/CSS3特性支持的浏览器打补丁.由 Alexander ...
随机推荐
- 【WPF】ListBox无法滚动
问题:ListBox显示多个条目时,无法滚动,也不显示滚动条. 办法: 给ListBox控件加上ScrollViewer.VerticalScrollBarVisibility和ScrollViewe ...
- 数据库——SQL中EXISTS怎么用1(转)
EXISTS用于检查子查询是否至少会返回一行数据,该子查询实际上并不返回任何数据,而是返回值True或False 方法/步骤 EXISTS用于检查子查询是否至少会返回一行数据,该子查询实际上并不返 ...
- datagrid中reoload提交时如何批量提交表单中的查询条件
看标题描述有点复杂,看下图: 直接将手工添加的一个个字段直接用一句代码完成. $('#dg_sub').datagrid("reload",$('#searchForm').ser ...
- javascript 图片滚动
<div style="width:9999px;"> <ul id="marquePic1_1"> <li> <dl ...
- jsp页面的el表达式取数据
在jsp页面去Id时候要照上面的方式取,不能照下面的方式取:
- dvi 中的内容居中
text-align:right; 文本居中 line-height:35px;*垂直居中*
- JS中的数字比较
if(parseInt(current_index)!=parseInt(uls)){
- SQL SERVER 2005快捷键
一.SQL SERVER 2005快捷键 快捷键 功能 CTRL + SHIFT + B生成解决方案 CTRL + F7 生成编译 CTRL + O 打开文件 CTRL + SHIFT + O打开项目 ...
- Android ArryaList 笔记
Arraylist相当于动态数组,可以动态的添加或者删除其中的元素. 参考链接 http://beginnersbook.com/2013/12/java-arraylist/ package com ...
- unity3D绘画手册-----地形及术语解释
Unity3D教程:设置地形(Terrain) Posted on 2013年04月18日 by U3d / Unity3D 基础教程 /被围观 1,901 次 新建地形: 在菜单中新建一个地形. U ...