Compare commits

..

6 Commits

Author SHA1 Message Date
1bec6aacad Merge pull request #961 from ONLYOFFICE/fix/v7.2.0-fix-bugs2
fix vba read and other
2022-06-20 18:07:28 +03:00
ac64868d4c fix vba read and other 2022-06-20 18:06:19 +03:00
23283244e9 Create fonts directory, if font files cannot be created 2022-06-20 17:49:51 +03:00
c4e6dea3a3 Fix constants for ligatures in docx 2022-06-20 16:25:34 +03:00
ffd60188c2 Fix typo 2022-06-20 15:52:59 +03:00
0da5552fdf Fix allfonts path 2022-06-20 15:50:10 +03:00
10 changed files with 93 additions and 33 deletions

View File

@ -591,8 +591,10 @@ int Binary_rPrReader::ReadContent(BYTE type, long length, void* poResult)
}break;
case c_oSerProp_rPrType::HighLightTyped:
{
BYTE byteHighLightTyped = m_oBufferedStream.GetUChar();
pRPr->m_oHighlight.Init(); pRPr->m_oHighlight->m_oVal.Init();
pRPr->m_oHighlight->m_oVal->SetValueFromByte(m_oBufferedStream.GetUChar());
pRPr->m_oHighlight->m_oVal->SetValue(SimpleTypes::highlightcolorNone);
}break;
case c_oSerProp_rPrType::Shd:
{
@ -9309,7 +9311,7 @@ int Binary_DocumentTableReader::ReadSdtPr(BYTE type, long length, void* poResult
else if (c_oSerSdt::RPr == type)
{
pSdtWraper->m_oRPr.Init();
res = oBinary_rPrReader.Read(length, &pSdtWraper->m_oRPr);
res = oBinary_rPrReader.Read(length, pSdtWraper->m_oRPr.GetPointer());
}
else if (c_oSerSdt::ShowingPlcHdr == type)
{

View File

@ -435,7 +435,7 @@ namespace VBA
virtual void load(CVbaFileStreamPtr stream);
_UINT32 TextOffset;
_UINT32 TextOffset = 0xffffffff;
};
typedef boost::shared_ptr<MODULEOFFSET> MODULEOFFSETPtr;
//-----------------------------------------------------------------------------

View File

@ -132,6 +132,11 @@ CVbaFileStream::CVbaFileStream(POLE::Stream* stream, _UINT32 offset)
return;
}
dataSize -= 1;
if (offset > dataSize)
{
return; //error;
}
stream->seek(stream->tell() + offset);
dataSize -= offset;
@ -140,23 +145,24 @@ CVbaFileStream::CVbaFileStream(POLE::Stream* stream, _UINT32 offset)
stream->read(data, dataSize);
unsigned char *dataCur = data;
size_t dataPos = 0;
while (dataPos + 2 < dataSize)
while (dataCur - data < dataSize - 2)
{
std::vector<unsigned char> arrChunk;
_UINT16 header = *((_UINT32*)dataCur); dataCur += 2;
bool bCompressed = ((header & CHUNK_COMPRESSED) != 0);
_UINT16 chunkSize = (header & CHUNK_LENMASK);
_UINT16 chunkSize = (header & CHUNK_LENMASK) + 1;
bool bUnknown = false;
if ((header & CHUNK_SIGMASK) != CHUNK_SIG)
{
bCompressed = true;
chunkSize = 4094; //по факту
bUnknown = true;
}
POLE::uint64 target = (dataCur - data) + chunkSize;
unsigned char *dataNext = dataCur + chunkSize;
if (bCompressed)
{
unsigned char nBitCount = 4;
@ -203,8 +209,7 @@ CVbaFileStream::CVbaFileStream(POLE::Stream* stream, _UINT32 offset)
}
else
{
arrChunk.emplace_back();
arrChunk.back() = *dataCur; dataCur++;
arrChunk.push_back(*dataCur); dataCur++;
++chunkPos;
}
}
@ -215,7 +220,8 @@ CVbaFileStream::CVbaFileStream(POLE::Stream* stream, _UINT32 offset)
arrChunk.resize(chunkSize);
memcpy(arrChunk.data(), dataCur, chunkSize); dataCur += chunkSize;
}
dataPos = target;
dataCur = dataNext;
arrChunks.insert(arrChunks.end(), arrChunk.begin(), arrChunk.end());
}
}

View File

@ -103,6 +103,9 @@ const std::wstring CVbaReader::convert()
{
for (size_t i = 0; i < DirStreamObject->ModulesRecord->modules.size(); ++i)
{
if (!DirStreamObject->ModulesRecord->modules[i])
continue;
CP_XML_NODE(L"Module")
{
if (DirStreamObject->ModulesRecord->modules[i]->StreamNameRecord)
@ -121,7 +124,10 @@ const std::wstring CVbaReader::convert()
DirStreamObject->ModulesRecord->modules[i]->StreamNameRecord->StreamNameUnicode.value);
_UINT32 offset = DirStreamObject->ModulesRecord->modules[i]->OffsetRecord ?
DirStreamObject->ModulesRecord->modules[i]->OffsetRecord->TextOffset : 0;//skip cache
DirStreamObject->ModulesRecord->modules[i]->OffsetRecord->TextOffset : 0xffffffff;//skip cache
if (offset == 0xffffffff)
continue; // error record
CVbaFileStreamPtr strmModule = vbaProject_file_->getNamedStream(streamName, offset);
strmModule->CodePage = code_page_;

View File

@ -7051,25 +7051,33 @@ namespace SimpleTypes
SimpleType_FromString (EDirVal)
SimpleType_Operator_Equal (CDirVal)
};
enum ELigaturesFlags
{
ligaturesFlagStandard = (1 << 0),
ligaturesFlagContextual = (1 << 1),
ligaturesFlagHistorical = (1 << 2),
ligaturesFlagDiscretional = (1 << 3)
};
enum ELigatures
{
ligatureNone = 0,
ligatureStandard = 1,
ligatureContextual = 2,
ligatureHistorical = 3,
ligatureDiscretional = 4,
ligatureStandardContextual = 5,
ligatureStandardHistorical = 6,
ligatureContextualHistorical = 7,
ligatureStandardDiscretional = 8,
ligatureContextualDiscretional = 9,
ligatureHistoricalDiscretional = 10,
ligatureStandardContextualHistorical = 11,
ligatureStandardContextualDiscretional = 12,
ligatureStandardHistoricalDiscretional = 13,
ligatureContextualHistoricalDiscretional = 14,
ligatureAll = 15
ligatureNone = 0,
ligatureStandard = ligaturesFlagStandard,
ligatureContextual = ligaturesFlagContextual,
ligatureHistorical = ligaturesFlagHistorical,
ligatureDiscretional = ligaturesFlagDiscretional,
ligatureStandardContextual = ligaturesFlagStandard | ligaturesFlagContextual,
ligatureStandardHistorical = ligaturesFlagStandard | ligaturesFlagHistorical,
ligatureContextualHistorical = ligaturesFlagContextual | ligaturesFlagHistorical,
ligatureStandardDiscretional = ligaturesFlagStandard | ligaturesFlagDiscretional,
ligatureContextualDiscretional = ligaturesFlagContextual | ligaturesFlagDiscretional,
ligatureHistoricalDiscretional = ligaturesFlagHistorical | ligaturesFlagDiscretional,
ligatureStandardContextualHistorical = ligaturesFlagStandard | ligaturesFlagContextual | ligaturesFlagHistorical,
ligatureStandardContextualDiscretional = ligaturesFlagStandard | ligaturesFlagContextual | ligaturesFlagDiscretional,
ligatureStandardHistoricalDiscretional = ligaturesFlagStandard | ligaturesFlagHistorical | ligaturesFlagDiscretional,
ligatureContextualHistoricalDiscretional = ligaturesFlagContextual | ligaturesFlagHistorical | ligaturesFlagDiscretional,
ligatureAll = ligaturesFlagStandard | ligaturesFlagContextual | ligaturesFlagHistorical | ligaturesFlagDiscretional
};
template<ELigatures eDefValue = ligatureStandard>

View File

@ -172,6 +172,11 @@ core_windows {
QMAKE_CXXFLAGS -= -Zc:strictStrings
QMAKE_CXXFLAGS += /MP
MSVC_VERSION_DETECT = $$(VisualStudioVersion)
greaterThan(MSVC_VERSION_DETECT, 15.0) {
CONFIG += vs2019
}
vs2019 {
QMAKE_CXXFLAGS_RELEASE -= -permissive-
QMAKE_CXXFLAGS -= -permissive-

View File

@ -35,6 +35,7 @@
#include "../xml/include/xmlutils.h"
#include "../common/File.h"
#include "../common/Directory.h"
#include "../common/SystemUtils.h"
namespace NSDoctRenderer
{
@ -82,6 +83,12 @@ namespace NSDoctRenderer
public:
void SetAllFontsExternal(const std::wstring& sFilePath)
{
m_strAllFonts = private_GetFile(NSFile::GetProcessDirectory() + L"/", sFilePath);
m_bIsNotUseConfigAllFontsDir = true;
}
void Parse(const std::wstring& sWorkDir)
{
m_arrFiles.clear();
@ -112,7 +119,34 @@ namespace NSDoctRenderer
std::wstring sAllFontsPath = oNode.ReadNodeText(L"allfonts");
if (!sAllFontsPath.empty())
{
m_strAllFonts = sAllFontsPath;
m_strAllFonts = private_GetFile(sConfigDir, sAllFontsPath);
#ifndef _WIN32
// на папку может не быть прав
if (!NSFile::CFileBinary::Exists(m_strAllFonts))
{
FILE* pFileNative = NSFile::CFileBinary::OpenFileNative(m_strAllFonts, L"wb");
if (!pFileNative)
{
std::wstring sHomeDir = NSSystemUtils::GetEnvVariable(L"HOME");
if (!sHomeDir.empty())
{
if (NSDirectory::Exists(sHomeDir + L"/.local/share"))
sHomeDir = sHomeDir + L"/.local/share";
else if (NSDirectory::Exists(sHomeDir + L"/.local"))
sHomeDir = sHomeDir + L"/.local";
if (NSDirectory::CreateDirectory(sHomeDir + L"/.docbuilder"))
m_strAllFonts = sHomeDir + L"/.docbuilder/AllFonts.js";
}
}
else
{
fclose(pFileNative);
}
}
#endif
}
}
m_arrFiles.push_back(private_GetFile(sConfigDir, m_strAllFonts));

View File

@ -680,8 +680,7 @@ namespace NSDoctRenderer
}
else if (sParam == "--all-fonts-path")
{
m_pInternal->m_strAllFonts = std::wstring(value);
m_pInternal->m_bIsNotUseConfigAllFontsDir = true;
m_pInternal->SetAllFontsExternal(std::wstring(value));
}
else if (sParam == "--argument")
{

View File

@ -256,8 +256,7 @@ namespace NSDoctRenderer
{
if (!sAllFontsPath.empty())
{
m_strAllFonts = sAllFontsPath;
m_bIsNotUseConfigAllFontsDir = true;
SetAllFontsExternal(sAllFontsPath);
}
CDoctRendererConfig::Parse(sConfigDir);

View File

@ -32,6 +32,7 @@ doct_renderer_empty {
SOURCES += doctrenderer_empty.cpp
} else {
HEADERS += \
config.h \
doctrenderer.h \
docbuilder.h