mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-07-20 03:55:47 +08:00
added dependens(base.pri) for cfcpp library
This commit is contained in:
@ -9,6 +9,12 @@ CONFIG += c++11
|
||||
# In order to do so, uncomment the following line.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include(../base.pri)
|
||||
|
||||
ADD_DEPENDENCY(UnicodeConverter, kernel)
|
||||
|
||||
SOURCES += \
|
||||
RBTree/rbtree.cpp \
|
||||
cfitem.cpp \
|
||||
@ -44,9 +50,3 @@ HEADERS += \
|
||||
streamrw.h \
|
||||
streamview.h \
|
||||
svector.h
|
||||
|
||||
# Default rules for deployment.
|
||||
unix {
|
||||
target.path = $$[QT_INSTALL_PLUGINS]/generic
|
||||
}
|
||||
!isEmpty(target.path): INSTALLS += target
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#include "../../DesktopEditor/common/File.h"
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include "sector.h"
|
||||
|
||||
|
||||
using namespace CFCPP;
|
||||
@ -863,7 +864,8 @@ void CompoundFile::FreeMiniChain(SVector<Sector> §orChain, int nth_sector_to
|
||||
int currentId = sectorChain[i]->id;
|
||||
|
||||
miniFATView.Seek(currentId * 4, std::ios::beg);
|
||||
miniFATView.Write(reinterpret_cast<const char*>(&Sector::FREESECT), 0, 4);
|
||||
const int freesec = Sector::FREESECT;
|
||||
miniFATView.Write(reinterpret_cast<const char*>(&freesec), 0, 4);
|
||||
}
|
||||
|
||||
// Write End of Chain in MiniFAT ---------------------------------------
|
||||
@ -874,7 +876,8 @@ void CompoundFile::FreeMiniChain(SVector<Sector> §orChain, int nth_sector_to
|
||||
if (nth_sector_to_remove > 0 && sectorChain.size() > 0)
|
||||
{
|
||||
miniFATView.Seek(sectorChain[nth_sector_to_remove - 1]->id * 4, std::ios::beg);
|
||||
miniFATView.Write(reinterpret_cast<const char*>(&Sector::ENDOFCHAIN), 0, 4);
|
||||
const int endofchain = Sector::ENDOFCHAIN;
|
||||
miniFATView.Write(reinterpret_cast<const char*>(&endofchain), 0, 4);
|
||||
}
|
||||
|
||||
// Update sector chains ---------------------------------------
|
||||
@ -916,14 +919,16 @@ void CompoundFile::FreeChain(SVector<Sector> §orChain, int nth_sector_to_rem
|
||||
int currentId = sectorChain[i]->id;
|
||||
|
||||
FATView.Seek(currentId * 4, std::ios::beg);
|
||||
FATView.Write(reinterpret_cast<const char*>(&Sector::FREESECT), 0, 4);
|
||||
const int freesec = Sector::FREESECT;
|
||||
FATView.Write(reinterpret_cast<const char*>(&freesec), 0, 4);
|
||||
}
|
||||
|
||||
// Write new end of chain if partial free ----------
|
||||
if (nth_sector_to_remove > 0 && sectorChain.size() > 0)
|
||||
{
|
||||
FATView.Seek(sectorChain[nth_sector_to_remove - 1]->id * 4, std::ios::beg);
|
||||
FATView.Write(reinterpret_cast<const char*>(&Sector::ENDOFCHAIN), 0, 4);
|
||||
const int endofchain = Sector::ENDOFCHAIN;
|
||||
FATView.Write(reinterpret_cast<const char*>(&endofchain), 0, 4);
|
||||
}
|
||||
}
|
||||
|
||||
@ -973,7 +978,8 @@ void CompoundFile::AllocateFATSectorChain(SVector<Sector> §orChain)
|
||||
}
|
||||
|
||||
fatStream.Seek(sectorChain[sectorChain.size() - 1]->id * 4, std::ios::beg);
|
||||
fatStream.Write(reinterpret_cast<const char*>(&Sector::ENDOFCHAIN), 0, 4);
|
||||
const int endofchain = Sector::ENDOFCHAIN;
|
||||
fatStream.Write(reinterpret_cast<const char*>(&endofchain), 0, 4);
|
||||
|
||||
// Merge chain to CFS
|
||||
AllocateDIFATSectorChain(fatStream.BaseSectorChain());
|
||||
@ -1109,13 +1115,15 @@ void CompoundFile::AllocateDIFATSectorChain(SVector<Sector> &FATsectorChain)
|
||||
for (int i = 0; i < (int)header->difatSectorsNumber; i++)
|
||||
{
|
||||
fatSv.Seek(difatStream.BaseSectorChain()[i]->id * 4, std::ios::beg);
|
||||
fatSv.Write(reinterpret_cast<const char*>(&Sector::DIFSECT), 0, 4);
|
||||
const int difsect = Sector::DIFSECT;
|
||||
fatSv.Write(reinterpret_cast<const char*>(&difsect), 0, 4);
|
||||
}
|
||||
|
||||
for (int i = 0; i < header->fatSectorsNumber; i++)
|
||||
{
|
||||
fatSv.Seek(fatSv.BaseSectorChain()[i]->id * 4, std::ios::beg);
|
||||
fatSv.Write(reinterpret_cast<const char*>(&Sector::FATSECT), 0, 4);
|
||||
const int fatsect = Sector::FATSECT;
|
||||
fatSv.Write(reinterpret_cast<const char*>(&fatsect), 0, 4);
|
||||
}
|
||||
|
||||
//fatSv.Seek(fatSv.BaseSectorChain[fatSv.BaseSectorChain.Count - 1].Id * 4, SeekOrigin.Begin);
|
||||
@ -1181,7 +1189,8 @@ void CompoundFile::AllocateMiniSectorChain(SVector<Sector> §orChain)
|
||||
|
||||
// Write End of Chain in MiniFAT
|
||||
miniFATView.Seek(sectorChain[sectorChain.size() - 1]->id * SIZE_OF_SID, std::ios::beg);
|
||||
miniFATView.Write(reinterpret_cast<const char*>(&Sector::ENDOFCHAIN), 0, 4);
|
||||
const int endofchain = Sector::ENDOFCHAIN;
|
||||
miniFATView.Write(reinterpret_cast<const char*>(&endofchain), 0, 4);
|
||||
|
||||
// Update sector chains
|
||||
AllocateSectorChain(miniStreamView.BaseSectorChain());
|
||||
@ -1854,7 +1863,8 @@ void CompoundFile::CheckForLockSector()
|
||||
StreamView fatStream(GetFatSectorChain(), GetSectorSize(), sourceStream);
|
||||
|
||||
fatStream.Seek(_lockSectorId * 4, std::ios::beg);
|
||||
fatStream.Write(reinterpret_cast<const char*>(&Sector::ENDOFCHAIN), 0, 4);
|
||||
const int endofchain = Sector::ENDOFCHAIN;
|
||||
fatStream.Write(reinterpret_cast<const char*>(&endofchain), 0, 4);
|
||||
|
||||
_transactionLockAllocated = true;
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
|
||||
#include "sector.h"
|
||||
#include <array>
|
||||
|
||||
namespace CFCPP
|
||||
{
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "stream.h"
|
||||
#include <memory>
|
||||
#include "../../DesktopEditor/common/Types.h"
|
||||
#include <vector>
|
||||
#include <mutex>
|
||||
#include "stream.h"
|
||||
#include "../../DesktopEditor/common/Types.h"
|
||||
|
||||
namespace CFCPP
|
||||
{
|
||||
|
||||
0
Common/cppcf/test/data/ex.ppt
Normal file
0
Common/cppcf/test/data/ex.ppt
Normal file
@ -1,6 +1,7 @@
|
||||
#include "tst_streamrw.h"
|
||||
#include "tst_header.h"
|
||||
#include "tst_directoryentry.h"
|
||||
#include "tst_compondfile.h"
|
||||
|
||||
using namespace CFCPP;
|
||||
using namespace std;
|
||||
|
||||
@ -1,15 +1,22 @@
|
||||
include(gtest_dependency.pri)
|
||||
|
||||
TARGET = test
|
||||
TEMPLATE = app
|
||||
CONFIG += console c++11
|
||||
CONFIG -= app_bundle
|
||||
CONFIG += thread
|
||||
CONFIG -= qt
|
||||
|
||||
LIBS += -L$$PWD/../../../build/lib/linux_64/debug -lcfcpp
|
||||
CORE_ROOT_DIR = $$PWD/../../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include(../../base.pri)
|
||||
|
||||
ADD_DEPENDENCY(UnicodeConverter, kernel, cfcpp)
|
||||
|
||||
INCLUDEPATH += $$PWD/../
|
||||
|
||||
HEADERS += \
|
||||
tst_compondfile.h \
|
||||
tst_directoryentry.h \
|
||||
tst_header.h \
|
||||
tst_streamrw.h
|
||||
|
||||
26
Common/cppcf/test/tst_compondfile.h
Normal file
26
Common/cppcf/test/tst_compondfile.h
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <gmock/gmock-matchers.h>
|
||||
#include "compoundfile.h"
|
||||
|
||||
using namespace testing;
|
||||
using namespace std;
|
||||
using namespace CFCPP;
|
||||
|
||||
|
||||
struct CompoundFileTest : testing::Test
|
||||
{
|
||||
wstring filename = L"../../../data/ex.ppt";
|
||||
CompoundFile cf;
|
||||
|
||||
CompoundFileTest() : cf(filename)
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(CompoundFileTest, test_compoundfile_read)
|
||||
{
|
||||
EXPECT_TRUE(cf.HasSourceStream());
|
||||
}
|
||||
@ -12,7 +12,7 @@ using namespace CFCPP;
|
||||
struct DirEntryTest : testing::Test
|
||||
{
|
||||
Stream stream;
|
||||
string filename = "../data/ex.ppt";
|
||||
string filename = "../../../data/ex.ppt";
|
||||
|
||||
DirEntryTest()
|
||||
{
|
||||
@ -61,7 +61,7 @@ TEST_F(DirEntryTest, test_directoryentry_write)
|
||||
stream->seekg(0x400, std::ios::beg);
|
||||
de.Read(stream);
|
||||
|
||||
std::string other_filename("../data/types/direntry.bin");
|
||||
std::string other_filename("../../../data/types/direntry.bin");
|
||||
stream.reset(new std::fstream(other_filename, ios::app | ios::in | ios::out | ios::binary));
|
||||
de.Write(stream);
|
||||
EXPECT_EQ(stream->tellg(), 0x80);
|
||||
|
||||
@ -13,7 +13,7 @@ struct HeaderTest : testing::Test
|
||||
{
|
||||
Stream stream;
|
||||
Header hd;
|
||||
string filename = "../data/ex.ppt";
|
||||
string filename = "../../../data/ex.ppt";
|
||||
|
||||
HeaderTest()
|
||||
{
|
||||
@ -54,7 +54,7 @@ TEST_F(HeaderTest, test_header_write)
|
||||
{
|
||||
hd.Read(stream);
|
||||
|
||||
std::string other_filename("../data/types/header.bin");
|
||||
std::string other_filename("../../../data/types/header.bin");
|
||||
stream.reset(new std::fstream(other_filename, ios::app | ios::in | ios::out | ios::binary));
|
||||
hd.Write(stream);
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ struct StreamRWTest : testing::Test
|
||||
{
|
||||
Stream stream;
|
||||
shared_ptr<StreamRW> rw;
|
||||
string filename = "../data/types/types.bin";
|
||||
string filename = "../../../data/types/types.bin";
|
||||
const char symbol = 'a';
|
||||
const int integer = 13;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user