Example #1
0
TEST(json, DISABLED_fetch_write_fail)
{
	std::string string4("");
	std::stringstream stream4(string4, std::ios_base::in);
	json_upgrade_test object4;
	auto error4(rai::fetch_object(object4, stream4));
	ASSERT_TRUE(error4);
}
bool COfficeFileFormatChecker::isXlsFormatFile	(POLE::Storage * storage)
{
	if (storage == NULL) return false;

    unsigned char buffer[10];

    POLE::Stream stream(storage, L"Workbook");
	
	if (stream.read(buffer,10) < 1)
	{
		POLE::Stream stream2(storage, L"Book");

		if (stream2.read(buffer,10) < 1)
		{
			POLE::Stream stream3(storage, L"WORKBOOK");

			if (stream3.read(buffer,10) < 1)
			{
				POLE::Stream stream4(storage, L"BOOK");

				if (stream4.read(buffer,10) < 1)
				{
					POLE::Stream stream5(storage, L"book");

					if (stream5.read(buffer,10) < 1)
						return false;
				}
			}
		}
	}
	if (storage->isDirectory(L"_VBA_PROJECT_CUR"))
	{
		bMacroEnabled = true;
	}
	return true;
}
Example #3
0
/// TODO:名称和路径需要联系起来
// 不能使用QHash ,会出现string相同的情况,那用什么方法呢
// QMultiMap??
void QJDMainWindow::setHomeDir(QString homePath)
{
    areaWidget->clear();

    /// 第一层 -- 工区
    QDir dir1;

    // 这个需要能设置,程序需要有settings.ini
    dir1.setPath(homePath);
    QStringList dirLev1;
    dirLev1<<dir1.entryList(QDir::NoDotAndDotDot|QDir::Dirs);
    //    qDebug()<<dir1.count(); // 包含./..

    /// 第二层 -- 线, 目前要向里面加入data文件夹,data文件夹与flow并列并且继续有往下的选择,可以不用descname
    QStringList areaStringList;
    QStringList areaPathList;
    QStringList lineStringList;
    QStringList linePathList;

    QVector<QStringList> flowStringList;
    QVector<QStringList> flowPathList;

    QVector<QVector<QStringList> > dataStringList;
    QVector<QVector<QStringList> >  dataPathList;
    for(int i=0; i<dirLev1.count(); i++)
    {
        // 遍历
        QDir dir2;
        QString dir2path=dir1.path()+"/"+dirLev1.at(i);
        dir2.setPath(dir2path);
        QStringList dirLev2;
        dirLev2=dir2.entryList(QDir::NoDotAndDotDot|QDir::Dirs);

        // 解析 DescName -- 工区名称
        QFile file2;
        file2.setFileName(dir2path+"/DescName");
        if(!file2.exists())
        {
            continue;
        }
        areaPathList<<dir2path;

        file2.open(QFile::ReadOnly);
        QTextStream stream2(&file2);
        QString areatmp=stream2.readAll();
        areatmp.chop(1);
        areaStringList<<areatmp;   // 路径就是dir2path
        //        qDebug()<<dir2path;
        file2.close();

        /// 第三层 -- 流程/Data, 同一层的data文件夹需要特殊处理
        for(int j=0; j<dirLev2.count(); j++)
        {
            QDir dir3;
            QString dir3path=dir2.path()+"/"+dirLev2.at(j);
            dir3.setPath(dir3path);
            QStringList dirLev3;
            dirLev3=dir3.entryList(QDir::NoDotAndDotDot|QDir::Dirs);  // 线名

            // 解析 DescName -- 线名称
            QFile file3;
            file3.setFileName(dir3path+"/DescName");
            if(!file3.exists())
            {
                continue;
            }
            linePathList<<dir3path;
            file3.open(QFile::ReadOnly);
            QTextStream stream3(&file3);
            QString linetmp=stream3.readAll();
            linetmp.chop(1);
            lineStringList<<linetmp;
            file3.close();
            //            qDebug()<<"line::"<<lineStringList;

            /// 第四层 -- 具体流程
            flowStringList.resize(dirLev2.count());
            flowPathList.resize(dirLev2.count());
            dataStringList.resize(dirLev2.count());
            dataPathList.resize(dirLev2.count());
            for(int k=0; k<dirLev3.count(); k++)
            {
                // 应当没有文件夹了,只剩下文件了
                QDir dir4;
                QString dir4path=dir3.path()+"/"+dirLev3.at(k);
                dir4.setPath(dir4path);
                QStringList dirLev4;
                dirLev4=dir4.entryList(QDir::NoDotAndDotDot|QDir::Files);  // 文件名列表了
                flowPathList[j]<<dir4path;
                /// 底下应当有个记录流程xml文件

                // 解析 DescName -- 线名称
                QFile file4;
                file4.setFileName(dir4path+"/DescName");
                if(!file4.exists())
                {
                    continue;
                }
                file4.open(QFile::ReadOnly);
                QTextStream stream4(&file4);
                QString flowtmp=stream4.readAll();
                flowtmp.chop(1);
                flowStringList[j]<<flowtmp;  // 只有在流程里才会有,其他的文件夹内不会有这个
                file4.close();
                //                qDebug()<<"flow::"<<flowStringList;

                /// 第五层 -- 数据存放,不应当再像前面一样完全扫描了.需要列出文件类型目录即可
                //! !! 如何准确放到某条线下面去,每条线都有,目前还是没有解决这个问题
                // 也就是说需要二维数组来确定
                if(flowtmp=="Data")
                {
                    dataStringList[j].resize(dirLev3.count());
                    dataPathList[j].resize(dirLev3.count());
                    for(int l=0; l<dirLev4.count(); l++)
                    {
                        // 应当没有文件夹了,只剩下文件了
                        QDir dir5;
                        dir5.setPath(dir4.path());
                        QStringList dirLev5;
                        dirLev5=dir5.entryList(QDir::NoDotAndDotDot|QDir::AllDirs);  // 文件名列表了
                        //                        qDebug()<<dir4.path()<<"dirLev5::"<<dirLev5;  // 怎么是空的??
                        dataStringList[j][k].append(dirLev5);
                        /// 底下应当有个记录流程xml文件

                        for(int m=0; m<dirLev5.size(); m++)
                        {
                            QString dataPath=dir4.path()+"/"+dirLev5.at(m);
                            dataPathList[j][k].append(dataPath);
                        }
                    }
                    // dataString为空 path为data descName的path
                    //                    qDebug()<<"!!!!!!!!!!!!!!!!!!!!!!!!!!"<<dirLev4.count()<<dataStringList;
                }
            }
        }
        //        qDebug()<<"\nstart set:::"<<areaStringList.at(i)<<lineStringList<<flowStringList;
        //        qDebug()<<"Data:::"<<dataStringList;

        setAreaWidget(areaStringList.at(i),areaPathList.at(i),lineStringList,
                      linePathList,flowStringList,flowPathList,dataStringList,dataPathList);

        /// 清理
        flowStringList.clear();
        flowPathList.clear();
        lineStringList.clear();
        linePathList.clear();
        dataStringList.clear();
        dataPathList.clear();
    }

    if(!areaStringList.isEmpty())
    {
        //        qDebug()<<areaWidget->topLevelItem(0)->text(0);
        areaWidget->setCurrentItem(areaWidget->topLevelItem(0));
        areaWidget->returnPath(areaWidget->currentItem(),areaWidget->currentColumn());
    }
}