mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Compare commits
18 Commits
v5.3.0.113
...
v5.3.0.171
| Author | SHA1 | Date | |
|---|---|---|---|
| f4df80ebf3 | |||
| 230c51689d | |||
| 826be463f5 | |||
| 29bb606d04 | |||
| 942767eb79 | |||
| 17c68ae414 | |||
| 32193b8a04 | |||
| 97531fe80f | |||
| 84755143fa | |||
| 37ab11c58a | |||
| 22cdeaf821 | |||
| ee4d2079dc | |||
| 68606f4cb0 | |||
| dbb11a480e | |||
| eb157610d3 | |||
| ef7331d803 | |||
| 287059a891 | |||
| d8f8720d05 |
@ -769,18 +769,15 @@ namespace DocFileFormat
|
||||
|
||||
return bytes;
|
||||
}
|
||||
#if !defined(_WIN32) && !defined(_WIN64)
|
||||
static inline std::wstring IntToWideString(unsigned int value)
|
||||
{
|
||||
return (std::to_wstring(value));
|
||||
}
|
||||
|
||||
static inline std::wstring IntToWideString(int value)
|
||||
{
|
||||
return (std::to_wstring(value));
|
||||
}
|
||||
#endif
|
||||
static inline std::wstring IntToWideString(size_t value)
|
||||
}
|
||||
static inline std::wstring SizeTToWideString(size_t value)
|
||||
{
|
||||
return (std::to_wstring((unsigned int)value));
|
||||
}
|
||||
|
||||
@ -94,11 +94,11 @@ namespace DocFileFormat
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:comment", TRUE );
|
||||
if (atrdPre10->m_BookmarkId < 0)//-1 - easy ref (not start/end comment ref)
|
||||
{
|
||||
m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString( index + 1 + count + 1024 ));
|
||||
m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::SizeTToWideString( index + 1 + count + 1024 ));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString( index + 1 ));
|
||||
m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::SizeTToWideString( index + 1 ));
|
||||
}
|
||||
if (atrdPost10)
|
||||
{
|
||||
|
||||
@ -92,7 +92,7 @@ namespace DocFileFormat
|
||||
{
|
||||
//start abstractNum
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:abstractNum", TRUE );
|
||||
m_pXmlWriter->WriteAttribute( L"w:abstractNumId", FormatUtils::IntToWideString( i /*+ 1 */));
|
||||
m_pXmlWriter->WriteAttribute( L"w:abstractNumId", FormatUtils::SizeTToWideString( i /*+ 1 */));
|
||||
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
|
||||
|
||||
//nsid
|
||||
@ -140,7 +140,7 @@ namespace DocFileFormat
|
||||
{
|
||||
//start abstractNum
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:abstractNum", TRUE );
|
||||
m_pXmlWriter->WriteAttribute( L"w:abstractNumId", FormatUtils::IntToWideString( rglst->listNumbering[i]->id ));
|
||||
m_pXmlWriter->WriteAttribute( L"w:abstractNumId", FormatUtils::SizeTToWideString( rglst->listNumbering[i]->id ));
|
||||
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
|
||||
|
||||
////nsid
|
||||
@ -169,7 +169,7 @@ namespace DocFileFormat
|
||||
|
||||
//start num
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:num", TRUE );
|
||||
m_pXmlWriter->WriteAttribute( L"w:numId", FormatUtils::IntToWideString(i + 1));
|
||||
m_pXmlWriter->WriteAttribute( L"w:numId", FormatUtils::SizeTToWideString(i + 1));
|
||||
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
|
||||
|
||||
int index = FindIndexbyId( rglst->listData, lfo->lsid );
|
||||
@ -205,12 +205,12 @@ namespace DocFileFormat
|
||||
for (size_t i = 0; i < rglst->listNumbering.size(); ++i)
|
||||
{
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:num", TRUE );
|
||||
m_pXmlWriter->WriteAttribute( L"w:numId", FormatUtils::IntToWideString(rglst->listNumbering[i]->id));
|
||||
m_pXmlWriter->WriteAttribute( L"w:numId", FormatUtils::SizeTToWideString(rglst->listNumbering[i]->id));
|
||||
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
|
||||
|
||||
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:abstractNumId", TRUE );
|
||||
m_pXmlWriter->WriteAttribute( L"w:val", FormatUtils::IntToWideString( rglst->listNumbering[i]->id ));
|
||||
m_pXmlWriter->WriteAttribute( L"w:val", FormatUtils::SizeTToWideString( rglst->listNumbering[i]->id ));
|
||||
m_pXmlWriter->WriteNodeEnd( L"", TRUE );
|
||||
|
||||
m_pXmlWriter->WriteNodeEnd(L"w:num");
|
||||
@ -285,7 +285,7 @@ namespace DocFileFormat
|
||||
newResult = find_if((result + 1), lvl->xst.end(), &NumberingMapping::IsPlaceholder);
|
||||
|
||||
ret += L"%";
|
||||
ret += FormatUtils::IntToWideString(*result + 1);
|
||||
ret += FormatUtils::SizeTToWideString(*result + 1);
|
||||
ret += std::wstring((result + 1), newResult);
|
||||
result = newResult;
|
||||
}
|
||||
|
||||
@ -85,19 +85,19 @@ namespace DocFileFormat
|
||||
|
||||
struct ImageFileStructure
|
||||
{
|
||||
ImageFileStructure()
|
||||
ImageFileStructure(const std::wstring& _ext, boost::shared_array<unsigned char> _data, unsigned int _size, Global::BlipType _blipType = Global::msoblipUNKNOWN) : ext(_ext), data(_data), size(_size), blipType(_blipType)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ImageFileStructure(const std::wstring& _ext, const std::vector<unsigned char>& _data, Global::BlipType _blipType = Global::msoblipUNKNOWN) : ext(_ext), data(_data), blipType(_blipType)
|
||||
ImageFileStructure(const std::wstring& _ext, unsigned char* _data, unsigned int _size, Global::BlipType _blipType = Global::msoblipUNKNOWN) : ext(_ext), size(_size), blipType(_blipType)
|
||||
{
|
||||
|
||||
data = boost::shared_array<unsigned char>(new unsigned char[size]);
|
||||
memcpy(data.get(), _data, size);
|
||||
}
|
||||
|
||||
std::wstring ext;
|
||||
std::vector<unsigned char> data;
|
||||
Global::BlipType blipType;
|
||||
std::wstring ext;
|
||||
boost::shared_array<unsigned char> data;
|
||||
unsigned int size;
|
||||
Global::BlipType blipType;
|
||||
};
|
||||
|
||||
struct OleObjectFileStructure
|
||||
|
||||
@ -33,6 +33,8 @@
|
||||
#include "PictureDescriptor.h"
|
||||
#include "OfficeDrawing/MetafilePictBlip.h"
|
||||
|
||||
#include "../../DesktopEditor/raster/BgraFrame.h"
|
||||
|
||||
#ifndef MM_ISOTROPIC
|
||||
#define MM_ISOTROPIC 7
|
||||
#endif
|
||||
@ -41,6 +43,111 @@
|
||||
#define MM_ANISOTROPIC 8
|
||||
#endif
|
||||
|
||||
namespace ImageHelper
|
||||
{
|
||||
Global::_BlipType SaveImageToFileFromDIB(unsigned char* data, int size, const std::wstring& file_name)//without ext
|
||||
{
|
||||
Global::_BlipType result = Global::msoblipERROR;
|
||||
|
||||
CBgraFrame oFrame;
|
||||
int offset = 0, biSizeImage = 0;
|
||||
|
||||
__BITMAPINFOHEADER * header = (__BITMAPINFOHEADER*)data;
|
||||
if (!header) return result;
|
||||
|
||||
result = Global::msoblipDIB;
|
||||
|
||||
if (header->biWidth > 100000 || header->biHeight > 100000 || header->biSize != 40)
|
||||
{
|
||||
__BITMAPCOREHEADER * header_core = (__BITMAPCOREHEADER *)data;
|
||||
if (header_core->bcSize != 12)
|
||||
{
|
||||
result = Global::msoblipWMF;
|
||||
}
|
||||
else
|
||||
{
|
||||
offset = 12; //sizeof(BITMAPCOREHEADER)
|
||||
|
||||
oFrame.put_Height (header_core->bcHeight );
|
||||
oFrame.put_Width (header_core->bcWidth );
|
||||
|
||||
int sz_bitmap = header_core->bcHeight * header_core->bcWidth * header_core->bcBitCount/ 8;
|
||||
|
||||
//if (header_core->bcWidth % 2 != 0 && sz_bitmap < size - offset)
|
||||
// header_core->bcWidth++;
|
||||
///???? todooo непонятно .. в biff5 нужно флипать картинку, в biff8 не ясно ( -
|
||||
|
||||
int stride = -(size - offset) / header_core->bcHeight;
|
||||
oFrame.put_Stride (stride/*header_core->bcBitCount * header_core->bcWidth /8 */);
|
||||
|
||||
biSizeImage = size - offset;
|
||||
|
||||
if (-stride >= header_core->bcWidth && header_core->bcBitCount >=24 )
|
||||
{
|
||||
result = Global::msoblipPNG;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
offset = 40; //sizeof(BITMAPINFOHEADER)
|
||||
|
||||
oFrame.put_Height (header->biHeight );
|
||||
oFrame.put_Width (header->biWidth );
|
||||
|
||||
int sz_bitmap = header->biHeight * header->biWidth * header->biBitCount/ 8;
|
||||
|
||||
//if (header->biWidth % 2 != 0 && sz_bitmap < size -offset)
|
||||
// header->biWidth++;
|
||||
|
||||
int stride = -(size - offset) / header->biHeight;
|
||||
|
||||
if (-stride >= header->biWidth && header->biBitCount >= 24)
|
||||
{
|
||||
result = Global::msoblipPNG;
|
||||
}
|
||||
oFrame.put_Stride (stride/*header->biBitCount * header->biWidth /8*/);
|
||||
|
||||
biSizeImage = header->biSizeImage > 0 ? header->biSizeImage : (size - offset);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
||||
if (result == Global::msoblipPNG)
|
||||
{
|
||||
oFrame.put_Data((unsigned char*)data + offset);
|
||||
|
||||
if (!oFrame.SaveFile(file_name + L".png", 4/*CXIMAGE_FORMAT_PNG*/))
|
||||
result = Global::msoblipERROR;
|
||||
|
||||
oFrame.put_Data(NULL);
|
||||
}
|
||||
else if (result == Global::msoblipWMF)
|
||||
{
|
||||
NSFile::CFileBinary file;
|
||||
if (file.CreateFileW(file_name + L".wmf"))
|
||||
{
|
||||
file.WriteFile((BYTE*)data, size);
|
||||
file.CloseFile();
|
||||
}
|
||||
}
|
||||
else if (biSizeImage > 0)
|
||||
{
|
||||
NSFile::CFileBinary file;
|
||||
if (file.CreateFileW(file_name + L".bmp"))
|
||||
{
|
||||
_UINT16 vtType = 0x4D42; file.WriteFile((BYTE*)&vtType, 2);
|
||||
_UINT32 dwLen = biSizeImage; file.WriteFile((BYTE*)&dwLen, 4);
|
||||
_UINT32 dwRes = 0; file.WriteFile((BYTE*)&dwRes, 4);
|
||||
_UINT32 dwOffset = 2; file.WriteFile((BYTE*)&dwOffset, 4);
|
||||
|
||||
file.WriteFile((BYTE*)data, size);
|
||||
file.CloseFile();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
namespace DocFileFormat
|
||||
{
|
||||
/// Parses the CHPX for a fcPic an loads the PictureDescriptor at this offset
|
||||
|
||||
@ -134,3 +134,34 @@ namespace DocFileFormat
|
||||
int embeddedDataSize;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
namespace ImageHelper
|
||||
{
|
||||
struct __BITMAPINFOHEADER
|
||||
{
|
||||
_UINT32 biSize;
|
||||
_INT32 biWidth;
|
||||
_INT32 biHeight;
|
||||
_UINT16 biPlanes;
|
||||
_UINT16 biBitCount;
|
||||
_UINT32 biCompression;
|
||||
_UINT32 biSizeImage;
|
||||
_INT32 biXPelsPerMeter;
|
||||
_INT32 biYPelsPerMeter;
|
||||
_UINT32 biClrUsed;
|
||||
_UINT32 biClrImportant;
|
||||
};
|
||||
|
||||
struct __BITMAPCOREHEADER
|
||||
{
|
||||
_UINT32 bcSize; /* used to get to color table */
|
||||
_UINT16 bcWidth;
|
||||
_UINT16 bcHeight;
|
||||
_UINT16 bcPlanes;
|
||||
_UINT16 bcBitCount;
|
||||
};
|
||||
|
||||
Global::_BlipType SaveImageToFileFromDIB(unsigned char* data, int size, const std::wstring& file_name);
|
||||
}
|
||||
|
||||
|
||||
@ -67,7 +67,7 @@ namespace DocFileFormat
|
||||
XMLTools::XMLAttribute layoutType ( L"w:type", L"fixed");
|
||||
bool bLayoutFixed = true;
|
||||
|
||||
short tblIndent = 0;
|
||||
_CP_OPT(short) tblIndent;
|
||||
short gabHalf = 0;
|
||||
short marginLeft = 0;
|
||||
short marginRight = 0;
|
||||
@ -98,8 +98,7 @@ namespace DocFileFormat
|
||||
//For this cases we can calculate the indent of the table by getting the
|
||||
//first boundary of the TDef and adding the padding of the cells
|
||||
|
||||
tblIndent = FormatUtils::BytesToInt16( iter->Arguments, 1, iter->argumentsSize );
|
||||
tblIndent += gabHalf;
|
||||
tblIndent = gabHalf + FormatUtils::BytesToInt16( iter->Arguments, 1, iter->argumentsSize );
|
||||
//If there follows a real sprmTWidthIndent, this value will be overwritten
|
||||
|
||||
//tblIndent = (std::max)((int)tblIndent,0); //cerere.doc
|
||||
@ -404,11 +403,11 @@ namespace DocFileFormat
|
||||
}
|
||||
|
||||
//indent
|
||||
if ( tblIndent != 0 )
|
||||
if ( tblIndent )
|
||||
{
|
||||
XMLTools::XMLElement tblInd( L"w:tblInd");
|
||||
|
||||
XMLTools::XMLAttribute tblIndW( L"w:w", FormatUtils::IntToWideString( tblIndent ) );
|
||||
XMLTools::XMLAttribute tblIndW( L"w:w", FormatUtils::IntToWideString( *tblIndent ) );
|
||||
tblInd.AppendAttribute( tblIndW );
|
||||
|
||||
XMLTools::XMLAttribute tblIndType( L"w:type", L"dxa");
|
||||
|
||||
@ -557,10 +557,10 @@ namespace DocFileFormat
|
||||
pict->embeddedDataSize += lLenHeader;
|
||||
delete []pict->embeddedData;
|
||||
pict->embeddedData = newData;
|
||||
|
||||
}
|
||||
|
||||
m_context->_docx->ImagesList.push_back(ImageFileStructure(GetTargetExt(Global::msoblipDIB),
|
||||
std::vector<unsigned char>(pict->embeddedData, (pict->embeddedData + pict->embeddedDataSize)), Global::msoblipDIB));
|
||||
pict->embeddedData, pict->embeddedDataSize, Global::msoblipDIB));
|
||||
|
||||
m_nImageId = m_context->_docx->RegisterImage(m_caller, btWin32);
|
||||
result = true;
|
||||
@ -577,26 +577,44 @@ namespace DocFileFormat
|
||||
if (metaBlip)
|
||||
{//decompress inside MetafilePictBlip
|
||||
unsigned char *newData = NULL;
|
||||
int newDataSize = metaBlip->oMetaFile.ToBuffer(newData);
|
||||
|
||||
m_context->_docx->ImagesList.push_back(ImageFileStructure(GetTargetExt(oBlipEntry->btWin32), std::vector<unsigned char>(newData, (newData + newDataSize))));
|
||||
|
||||
RELEASEARRAYOBJECTS(newData);
|
||||
}
|
||||
}
|
||||
break;
|
||||
unsigned int newDataSize = metaBlip->oMetaFile.ToBuffer(newData);
|
||||
|
||||
boost::shared_array<unsigned char> arData(newData);
|
||||
m_context->_docx->ImagesList.push_back(ImageFileStructure(GetTargetExt(oBlipEntry->btWin32), arData, newDataSize));
|
||||
}
|
||||
}break;
|
||||
case Global::msoblipDIB:
|
||||
{//user_manual_v52.doc
|
||||
|
||||
BitmapBlip* bitBlip = static_cast<BitmapBlip*>(oBlipEntry->Blip);
|
||||
if (bitBlip)
|
||||
{
|
||||
std::wstring file_name = m_context->_doc->m_sTempFolder + L"tmp_image";
|
||||
oBlipEntry->btWin32 = ImageHelper::SaveImageToFileFromDIB(bitBlip->m_pvBits, bitBlip->pvBitsSize, file_name);
|
||||
|
||||
if (oBlipEntry->btWin32 == Global::msoblipPNG)
|
||||
{
|
||||
unsigned char* pData = NULL;
|
||||
DWORD nData = 0;
|
||||
if (NSFile::CFileBinary::ReadAllBytes(file_name, &pData, nData))
|
||||
{
|
||||
m_context->_docx->ImagesList.push_back(ImageFileStructure(GetTargetExt(Global::msoblipPNG),
|
||||
boost::shared_array<unsigned char>(pData), nData, Global::msoblipPNG));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}//в случае ошибки конвертации -храним оригинальный dib
|
||||
case Global::msoblipJPEG:
|
||||
case Global::msoblipCMYKJPEG:
|
||||
case Global::msoblipPNG:
|
||||
case Global::msoblipTIFF:
|
||||
case Global::msoblipDIB:
|
||||
{
|
||||
BitmapBlip* bitBlip = static_cast<BitmapBlip*>(oBlipEntry->Blip);
|
||||
if (bitBlip)
|
||||
{
|
||||
m_context->_docx->ImagesList.push_back(ImageFileStructure(GetTargetExt(oBlipEntry->btWin32),
|
||||
std::vector<unsigned char>(bitBlip->m_pvBits, (bitBlip->m_pvBits + bitBlip->pvBitsSize)), oBlipEntry->btWin32));
|
||||
bitBlip->m_pvBits, bitBlip->pvBitsSize, oBlipEntry->btWin32));
|
||||
}
|
||||
}break;
|
||||
|
||||
|
||||
@ -1293,7 +1293,7 @@ namespace DocFileFormat
|
||||
|
||||
/// Copies the picture from the binary stream to the zip archive
|
||||
/// and creates the relationships for the image.
|
||||
bool VMLShapeMapping::copyPicture(const BlipStoreEntry* oBlip)
|
||||
bool VMLShapeMapping::copyPicture(BlipStoreEntry* oBlip)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
@ -1304,9 +1304,9 @@ namespace DocFileFormat
|
||||
|
||||
switch (oBlip->btWin32)
|
||||
{
|
||||
case Global::msoblipEMF:
|
||||
case Global::msoblipWMF:
|
||||
case Global::msoblipPICT:
|
||||
case Global::msoblipEMF:
|
||||
case Global::msoblipWMF:
|
||||
case Global::msoblipPICT:
|
||||
{
|
||||
//it's a meta image
|
||||
MetafilePictBlip* metaBlip = static_cast<MetafilePictBlip*>(RecordFactory::ReadRecord(&reader, 0));
|
||||
@ -1314,38 +1314,53 @@ namespace DocFileFormat
|
||||
{
|
||||
//meta images can be compressed
|
||||
unsigned char* decompressed = NULL;
|
||||
int decompressedSize = 0;
|
||||
unsigned int decompressedSize = 0;
|
||||
|
||||
decompressedSize = metaBlip->Decompress(&decompressed);
|
||||
|
||||
if (0 != decompressedSize && NULL != decompressed)
|
||||
{
|
||||
m_context->_docx->ImagesList.push_back(ImageFileStructure(GetTargetExt(oBlip->btWin32), std::vector<unsigned char>(decompressed, (decompressed + decompressedSize))));
|
||||
RELEASEARRAYOBJECTS(decompressed);
|
||||
boost::shared_array<unsigned char> arDecompressed(decompressed);
|
||||
m_context->_docx->ImagesList.push_back(ImageFileStructure(GetTargetExt(oBlip->btWin32), arDecompressed, decompressedSize));
|
||||
}
|
||||
|
||||
RELEASEOBJECT(metaBlip);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Global::msoblipJPEG:
|
||||
case Global::msoblipCMYKJPEG:
|
||||
case Global::msoblipPNG:
|
||||
case Global::msoblipTIFF:
|
||||
case Global::msoblipDIB:
|
||||
{
|
||||
//it's a bitmap image
|
||||
case Global::msoblipJPEG:
|
||||
case Global::msoblipCMYKJPEG:
|
||||
case Global::msoblipPNG:
|
||||
case Global::msoblipTIFF:
|
||||
case Global::msoblipDIB:
|
||||
{//it's a bitmap image
|
||||
BitmapBlip* bitBlip = static_cast<BitmapBlip*>(RecordFactory::ReadRecord(&reader, 0));
|
||||
if ((bitBlip) && (bitBlip->m_pvBits))
|
||||
{
|
||||
if (oBlip->btWin32 == Global::msoblipDIB)
|
||||
{
|
||||
std::wstring file_name = m_context->_doc->m_sTempFolder + L"tmp_image";
|
||||
|
||||
if (Global::msoblipPNG == ImageHelper::SaveImageToFileFromDIB(bitBlip->m_pvBits, bitBlip->pvBitsSize, file_name))
|
||||
{
|
||||
oBlip->btWin32 = Global::msoblipPNG;
|
||||
|
||||
unsigned char* pData = NULL;
|
||||
DWORD nData = 0;
|
||||
if (NSFile::CFileBinary::ReadAllBytes(file_name, &pData, nData))
|
||||
{
|
||||
m_context->_docx->ImagesList.push_back(ImageFileStructure(GetTargetExt(Global::msoblipPNG),
|
||||
boost::shared_array<unsigned char>(pData), nData, Global::msoblipPNG));
|
||||
break;
|
||||
}
|
||||
}//в случае ошибки конвертации -храним оригинальный dib
|
||||
}
|
||||
m_context->_docx->ImagesList.push_back(ImageFileStructure(GetTargetExt(oBlip->btWin32),
|
||||
std::vector<unsigned char>(bitBlip->m_pvBits, (bitBlip->m_pvBits + bitBlip->pvBitsSize)), oBlip->btWin32));
|
||||
bitBlip->m_pvBits, bitBlip->pvBitsSize, oBlip->btWin32));
|
||||
RELEASEOBJECT (bitBlip);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
}break;
|
||||
default:
|
||||
{
|
||||
result = false;
|
||||
return result;
|
||||
|
||||
@ -80,7 +80,7 @@ namespace DocFileFormat
|
||||
void WriteShape (const ShapeContainer* pContainer);
|
||||
|
||||
std::wstring GenShapeId(const Shape* pShape) const;
|
||||
bool copyPicture( const BlipStoreEntry* bse );
|
||||
bool copyPicture( BlipStoreEntry* bse );
|
||||
std::wstring GetTargetExt( Global::BlipType _type ) const;
|
||||
|
||||
void AppendDimensionToStyle ( std::wstring& style, const PictureDescriptor* pict, bool twistDimensions ) const;
|
||||
|
||||
@ -32,7 +32,6 @@
|
||||
|
||||
#include "WordprocessingDocument.h"
|
||||
|
||||
#include "../../DesktopEditor/raster/BgraFrame.h"
|
||||
#include "../../DesktopEditor/common/Directory.h"
|
||||
#include "../../DesktopEditor/common/SystemUtils.h"
|
||||
|
||||
@ -40,136 +39,6 @@
|
||||
#include "../../Common/DocxFormat/Source/DocxFormat/Core.h"
|
||||
#include "../../Common/DocxFormat/Source/DocxFormat/ContentTypes.h"
|
||||
|
||||
namespace ImageHelper
|
||||
{
|
||||
struct __BITMAPINFOHEADER
|
||||
{
|
||||
_UINT32 biSize;
|
||||
_INT32 biWidth;
|
||||
_INT32 biHeight;
|
||||
_UINT16 biPlanes;
|
||||
_UINT16 biBitCount;
|
||||
_UINT32 biCompression;
|
||||
_UINT32 biSizeImage;
|
||||
_INT32 biXPelsPerMeter;
|
||||
_INT32 biYPelsPerMeter;
|
||||
_UINT32 biClrUsed;
|
||||
_UINT32 biClrImportant;
|
||||
};
|
||||
|
||||
struct __BITMAPCOREHEADER
|
||||
{
|
||||
_UINT32 bcSize; /* used to get to color table */
|
||||
_UINT16 bcWidth;
|
||||
_UINT16 bcHeight;
|
||||
_UINT16 bcPlanes;
|
||||
_UINT16 bcBitCount;
|
||||
};
|
||||
|
||||
inline Global::_BlipType SaveImageToFileFromDIB(unsigned char* data, int size, const std::wstring& file_name)//without ext
|
||||
{
|
||||
Global::_BlipType result = Global::msoblipERROR;
|
||||
|
||||
CBgraFrame oFrame;
|
||||
int offset = 0, biSizeImage = 0;
|
||||
|
||||
__BITMAPINFOHEADER * header = (__BITMAPINFOHEADER*)data;
|
||||
if (!header) return result;
|
||||
|
||||
result = Global::msoblipDIB;
|
||||
|
||||
if (header->biWidth > 100000 || header->biHeight > 100000 || header->biSize != 40)
|
||||
{
|
||||
__BITMAPCOREHEADER * header_core = (__BITMAPCOREHEADER *)data;
|
||||
if (header_core->bcSize != 12)
|
||||
{
|
||||
result = Global::msoblipWMF;
|
||||
}
|
||||
else
|
||||
{
|
||||
offset = 12; //sizeof(BITMAPCOREHEADER)
|
||||
|
||||
oFrame.put_Height (header_core->bcHeight );
|
||||
oFrame.put_Width (header_core->bcWidth );
|
||||
|
||||
int sz_bitmap = header_core->bcHeight * header_core->bcWidth * header_core->bcBitCount/ 8;
|
||||
|
||||
//if (header_core->bcWidth % 2 != 0 && sz_bitmap < size - offset)
|
||||
// header_core->bcWidth++;
|
||||
///???? todooo непонятно .. в biff5 нужно флипать картинку, в biff8 не ясно ( -
|
||||
|
||||
int stride = -(size - offset) / header_core->bcHeight;
|
||||
oFrame.put_Stride (stride/*header_core->bcBitCount * header_core->bcWidth /8 */);
|
||||
|
||||
biSizeImage = size - offset;
|
||||
|
||||
if (-stride >= header_core->bcWidth && header_core->bcBitCount >=24 )
|
||||
{
|
||||
result = Global::msoblipPNG;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
offset = 40; //sizeof(BITMAPINFOHEADER)
|
||||
|
||||
oFrame.put_Height (header->biHeight );
|
||||
oFrame.put_Width (header->biWidth );
|
||||
|
||||
int sz_bitmap = header->biHeight * header->biWidth * header->biBitCount/ 8;
|
||||
|
||||
//if (header->biWidth % 2 != 0 && sz_bitmap < size -offset)
|
||||
// header->biWidth++;
|
||||
|
||||
int stride = -(size - offset) / header->biHeight;
|
||||
|
||||
if (-stride >= header->biWidth && header->biBitCount >= 24)
|
||||
{
|
||||
result = Global::msoblipPNG;
|
||||
}
|
||||
oFrame.put_Stride (stride/*header->biBitCount * header->biWidth /8*/);
|
||||
|
||||
biSizeImage = header->biSizeImage > 0 ? header->biSizeImage : (size - offset);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
||||
if (result == Global::msoblipPNG)
|
||||
{
|
||||
oFrame.put_Data((unsigned char*)data + offset);
|
||||
|
||||
if (!oFrame.SaveFile(file_name + L".png", 4/*CXIMAGE_FORMAT_PNG*/))
|
||||
result = Global::msoblipERROR;
|
||||
|
||||
oFrame.put_Data(NULL);
|
||||
}
|
||||
else if (result == Global::msoblipWMF)
|
||||
{
|
||||
NSFile::CFileBinary file;
|
||||
if (file.CreateFileW(file_name + L".wmf"))
|
||||
{
|
||||
file.WriteFile((BYTE*)data, size);
|
||||
file.CloseFile();
|
||||
}
|
||||
}
|
||||
else if (biSizeImage > 0)
|
||||
{
|
||||
NSFile::CFileBinary file;
|
||||
if (file.CreateFileW(file_name + L".bmp"))
|
||||
{
|
||||
_UINT16 vtType = 0x4D42; file.WriteFile((BYTE*)&vtType, 2);
|
||||
_UINT32 dwLen = biSizeImage; file.WriteFile((BYTE*)&dwLen, 4);
|
||||
_UINT32 dwRes = 0; file.WriteFile((BYTE*)&dwRes, 4);
|
||||
_UINT32 dwOffset = 2; file.WriteFile((BYTE*)&dwOffset, 4);
|
||||
|
||||
file.WriteFile((BYTE*)data, size);
|
||||
file.CloseFile();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
namespace DocFileFormat
|
||||
{
|
||||
WordprocessingDocument::WordprocessingDocument(const std::wstring & _pathOutput, const WordDocument* _docFile) :
|
||||
@ -275,24 +144,7 @@ namespace DocFileFormat
|
||||
|
||||
for (std::list<ImageFileStructure>::iterator iter = ImagesList.begin(); iter != ImagesList.end(); ++iter)
|
||||
{
|
||||
unsigned char* bytes = NULL;
|
||||
bytes = new unsigned char[iter->data.size()];
|
||||
if (bytes)
|
||||
{
|
||||
copy(iter->data.begin(), iter->data.end(), bytes);
|
||||
|
||||
if (Global::msoblipDIB == iter->blipType)
|
||||
{//user_manual_v52.doc
|
||||
std::wstring file_name = pathMedia + FILE_SEPARATOR_STR + L"image" + FormatUtils::IntToWideString(i++);
|
||||
iter->blipType = ImageHelper::SaveImageToFileFromDIB(bytes, iter->data.size(), file_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
SaveToFile(pathMedia, std::wstring(L"image" ) + FormatUtils::IntToWideString(i++) + iter->ext, (void*)bytes, (unsigned int)iter->data.size());
|
||||
}
|
||||
|
||||
RELEASEARRAYOBJECTS(bytes);
|
||||
}
|
||||
SaveToFile(pathMedia, std::wstring(L"image" ) + FormatUtils::IntToWideString(i++) + iter->ext, (void*)iter->data.get(), iter->size);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -4080,6 +4080,30 @@ int Binary_DocumentTableReader::ReadDocumentContent(BYTE type, long length, void
|
||||
READ1_DEF(length, res, this->ReadBookmarkEnd, &oBookmarkEnd);
|
||||
m_oDocumentWriter.m_oContent.WriteString(oBookmarkEnd.toXML());
|
||||
}
|
||||
else if ( c_oSerParType::MoveFromRangeStart == type )
|
||||
{
|
||||
OOX::Logic::CMoveFromRangeStart oMoveFromRangeStart;
|
||||
READ1_DEF(length, res, this->ReadMoveFromRangeStart, &oMoveFromRangeStart);
|
||||
m_oDocumentWriter.m_oContent.WriteString(oMoveFromRangeStart.toXML());
|
||||
}
|
||||
else if ( c_oSerParType::MoveFromRangeEnd == type )
|
||||
{
|
||||
OOX::Logic::CMoveFromRangeEnd oMoveToRangeEnd;
|
||||
READ1_DEF(length, res, this->ReadMoveFromRangeEnd, &oMoveToRangeEnd);
|
||||
m_oDocumentWriter.m_oContent.WriteString(oMoveToRangeEnd.toXML());
|
||||
}
|
||||
else if ( c_oSerParType::MoveToRangeStart == type )
|
||||
{
|
||||
OOX::Logic::CMoveToRangeStart oMoveToRangeStart;
|
||||
READ1_DEF(length, res, this->ReadMoveToRangeStart, &oMoveToRangeStart);
|
||||
m_oDocumentWriter.m_oContent.WriteString(oMoveToRangeStart.toXML());
|
||||
}
|
||||
else if ( c_oSerParType::MoveToRangeEnd == type )
|
||||
{
|
||||
OOX::Logic::CMoveToRangeEnd oMoveToRangeEnd;
|
||||
READ1_DEF(length, res, this->ReadMoveToRangeEnd, &oMoveToRangeEnd);
|
||||
m_oDocumentWriter.m_oContent.WriteString(oMoveToRangeEnd.toXML());
|
||||
}
|
||||
else if(c_oSerParType::JsaProject == type)
|
||||
{
|
||||
BYTE* pData = m_oBufferedStream.GetPointer(length);
|
||||
@ -4922,6 +4946,30 @@ int Binary_DocumentTableReader::ReadMathArg(BYTE type, long length, void* poResu
|
||||
READ1_DEF(length, res, this->ReadBookmarkEnd, &oBookmarkEnd);
|
||||
GetRunStringWriter().WriteString(oBookmarkEnd.toXML());
|
||||
}
|
||||
else if ( c_oSer_OMathContentType::MoveFromRangeStart == type )
|
||||
{
|
||||
OOX::Logic::CMoveFromRangeStart oMoveFromRangeStart;
|
||||
READ1_DEF(length, res, this->ReadMoveFromRangeStart, &oMoveFromRangeStart);
|
||||
GetRunStringWriter().WriteString(oMoveFromRangeStart.toXML());
|
||||
}
|
||||
else if ( c_oSer_OMathContentType::MoveFromRangeEnd == type )
|
||||
{
|
||||
OOX::Logic::CMoveFromRangeEnd oMoveToRangeEnd;
|
||||
READ1_DEF(length, res, this->ReadMoveFromRangeEnd, &oMoveToRangeEnd);
|
||||
GetRunStringWriter().WriteString(oMoveToRangeEnd.toXML());
|
||||
}
|
||||
else if ( c_oSer_OMathContentType::MoveToRangeStart == type )
|
||||
{
|
||||
OOX::Logic::CMoveToRangeStart oMoveToRangeStart;
|
||||
READ1_DEF(length, res, this->ReadMoveToRangeStart, &oMoveToRangeStart);
|
||||
GetRunStringWriter().WriteString(oMoveToRangeStart.toXML());
|
||||
}
|
||||
else if ( c_oSer_OMathContentType::MoveToRangeEnd == type )
|
||||
{
|
||||
OOX::Logic::CMoveToRangeEnd oMoveToRangeEnd;
|
||||
READ1_DEF(length, res, this->ReadMoveToRangeEnd, &oMoveToRangeEnd);
|
||||
GetRunStringWriter().WriteString(oMoveToRangeEnd.toXML());
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
@ -7161,7 +7209,7 @@ int Binary_DocumentTableReader::ReadRunContent(BYTE type, long length, void* poR
|
||||
if(NULL != m_pComments)
|
||||
{
|
||||
CComment* pComment = m_pComments->get(nId);
|
||||
if(NULL != pComment && pComment->bIdFormat)
|
||||
if(NULL != pComment) // могут быть и без start/end
|
||||
{
|
||||
GetRunStringWriter().WriteString(pComment->writeRef(std::wstring(_T("")), std::wstring(_T("w:commentReference")), std::wstring(_T(""))));
|
||||
}
|
||||
@ -7407,6 +7455,30 @@ int Binary_DocumentTableReader::Read_TableContent(BYTE type, long length, void*
|
||||
READ1_DEF(length, res, this->ReadBookmarkEnd, &oBookmarkEnd);
|
||||
pCStringWriter->WriteString(oBookmarkEnd.toXML());
|
||||
}
|
||||
else if ( c_oSerDocTableType::MoveFromRangeStart == type )
|
||||
{
|
||||
OOX::Logic::CMoveFromRangeStart oMoveFromRangeStart;
|
||||
READ1_DEF(length, res, this->ReadMoveFromRangeStart, &oMoveFromRangeStart);
|
||||
pCStringWriter->WriteString(oMoveFromRangeStart.toXML());
|
||||
}
|
||||
else if ( c_oSerDocTableType::MoveFromRangeEnd == type )
|
||||
{
|
||||
OOX::Logic::CMoveFromRangeEnd oMoveToRangeEnd;
|
||||
READ1_DEF(length, res, this->ReadMoveFromRangeEnd, &oMoveToRangeEnd);
|
||||
pCStringWriter->WriteString(oMoveToRangeEnd.toXML());
|
||||
}
|
||||
else if ( c_oSerDocTableType::MoveToRangeStart == type )
|
||||
{
|
||||
OOX::Logic::CMoveToRangeStart oMoveToRangeStart;
|
||||
READ1_DEF(length, res, this->ReadMoveToRangeStart, &oMoveToRangeStart);
|
||||
pCStringWriter->WriteString(oMoveToRangeStart.toXML());
|
||||
}
|
||||
else if ( c_oSerDocTableType::MoveToRangeEnd == type )
|
||||
{
|
||||
OOX::Logic::CMoveToRangeEnd oMoveToRangeEnd;
|
||||
READ1_DEF(length, res, this->ReadMoveToRangeEnd, &oMoveToRangeEnd);
|
||||
pCStringWriter->WriteString(oMoveToRangeEnd.toXML());
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
@ -7456,6 +7528,30 @@ int Binary_DocumentTableReader::ReadRowContent(BYTE type, long length, void* poR
|
||||
READ1_DEF(length, res, this->ReadBookmarkEnd, &oBookmarkEnd);
|
||||
pCStringWriter->WriteString(oBookmarkEnd.toXML());
|
||||
}
|
||||
else if ( c_oSerDocTableType::MoveFromRangeStart == type )
|
||||
{
|
||||
OOX::Logic::CMoveFromRangeStart oMoveFromRangeStart;
|
||||
READ1_DEF(length, res, this->ReadMoveFromRangeStart, &oMoveFromRangeStart);
|
||||
pCStringWriter->WriteString(oMoveFromRangeStart.toXML());
|
||||
}
|
||||
else if ( c_oSerDocTableType::MoveFromRangeEnd == type )
|
||||
{
|
||||
OOX::Logic::CMoveFromRangeEnd oMoveToRangeEnd;
|
||||
READ1_DEF(length, res, this->ReadMoveFromRangeEnd, &oMoveToRangeEnd);
|
||||
pCStringWriter->WriteString(oMoveToRangeEnd.toXML());
|
||||
}
|
||||
else if ( c_oSerDocTableType::MoveToRangeStart == type )
|
||||
{
|
||||
OOX::Logic::CMoveToRangeStart oMoveToRangeStart;
|
||||
READ1_DEF(length, res, this->ReadMoveToRangeStart, &oMoveToRangeStart);
|
||||
pCStringWriter->WriteString(oMoveToRangeStart.toXML());
|
||||
}
|
||||
else if ( c_oSerDocTableType::MoveToRangeEnd == type )
|
||||
{
|
||||
OOX::Logic::CMoveToRangeEnd oMoveToRangeEnd;
|
||||
READ1_DEF(length, res, this->ReadMoveToRangeEnd, &oMoveToRangeEnd);
|
||||
pCStringWriter->WriteString(oMoveToRangeEnd.toXML());
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
|
||||
@ -524,7 +524,11 @@ extern int g_nCurFormatVersion;
|
||||
Sdt = 10,
|
||||
BookmarkStart = 11,
|
||||
BookmarkEnd = 12,
|
||||
tblGrid_ItemTwips = 13
|
||||
tblGrid_ItemTwips = 13,
|
||||
MoveFromRangeStart = 14,
|
||||
MoveFromRangeEnd = 15,
|
||||
MoveToRangeStart = 16,
|
||||
MoveToRangeEnd = 17
|
||||
};}
|
||||
namespace c_oSerRunType{enum c_oSerRunType
|
||||
{
|
||||
@ -979,7 +983,11 @@ extern int g_nCurFormatVersion;
|
||||
columnbreak = 64,
|
||||
ARPr = 65,
|
||||
BookmarkStart = 66,
|
||||
BookmarkEnd = 67
|
||||
BookmarkEnd = 67,
|
||||
MoveFromRangeStart = 68,
|
||||
MoveFromRangeEnd = 69,
|
||||
MoveToRangeStart = 70,
|
||||
MoveToRangeEnd = 71
|
||||
};}
|
||||
namespace c_oSer_FramePrType{ enum c_oSer_FramePrType
|
||||
{
|
||||
|
||||
@ -3082,6 +3082,34 @@ void BinaryDocumentTableWriter::WriteDocumentContent(const std::vector<OOX::Writ
|
||||
WriteBookmarkEnd(*pBookmarkEnd);
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}break;
|
||||
case OOX::et_w_moveFromRangeStart:
|
||||
{
|
||||
OOX::Logic::CMoveFromRangeStart* pMoveFromRangeStart = static_cast<OOX::Logic::CMoveFromRangeStart*>(item);
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerParType::MoveFromRangeStart);
|
||||
WriteMoveRangeStart(*pMoveFromRangeStart);
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
}break;
|
||||
case OOX::et_w_moveFromRangeEnd:
|
||||
{
|
||||
OOX::Logic::CMoveFromRangeEnd* pMoveFromRangeEnd = static_cast<OOX::Logic::CMoveFromRangeEnd*>(item);
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerParType::MoveFromRangeEnd);
|
||||
WriteMoveRangeEnd(*pMoveFromRangeEnd);
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
}break;
|
||||
case OOX::et_w_moveToRangeStart:
|
||||
{
|
||||
OOX::Logic::CMoveToRangeStart* pMoveToRangeStart = static_cast<OOX::Logic::CMoveToRangeStart*>(item);
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerParType::MoveToRangeStart);
|
||||
WriteMoveRangeStart(*pMoveToRangeStart);
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
}break;
|
||||
case OOX::et_w_moveToRangeEnd:
|
||||
{
|
||||
OOX::Logic::CMoveToRangeEnd* pMoveToRangeEnd = static_cast<OOX::Logic::CMoveToRangeEnd*>(item);
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerParType::MoveToRangeEnd);
|
||||
WriteMoveRangeEnd(*pMoveToRangeEnd);
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
}break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -3285,39 +3313,38 @@ void BinaryDocumentTableWriter::WriteParagraphContent(const std::vector<OOX::Wri
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
break;
|
||||
}
|
||||
//todo moveRange on all levels(body, p ...)
|
||||
// case OOX::et_w_moveFromRangeStart:
|
||||
// {
|
||||
// OOX::Logic::CMoveFromRangeStart* pMoveFromRangeStart = static_cast<OOX::Logic::CMoveFromRangeStart*>(item);
|
||||
// nCurPos = m_oBcw.WriteItemStart(c_oSerParType::MoveFromRangeStart);
|
||||
// WriteMoveRangeStart(*pMoveFromRangeStart);
|
||||
// m_oBcw.WriteItemEnd(nCurPos);
|
||||
// break;
|
||||
// }
|
||||
// case OOX::et_w_moveFromRangeEnd:
|
||||
// {
|
||||
// OOX::Logic::CMoveFromRangeEnd* pMoveFromRangeEnd = static_cast<OOX::Logic::CMoveFromRangeEnd*>(item);
|
||||
// nCurPos = m_oBcw.WriteItemStart(c_oSerParType::MoveFromRangeEnd);
|
||||
// WriteMoveRangeEnd(*pMoveFromRangeEnd);
|
||||
// m_oBcw.WriteItemEnd(nCurPos);
|
||||
// break;
|
||||
// }
|
||||
// case OOX::et_w_moveToRangeStart:
|
||||
// {
|
||||
// OOX::Logic::CMoveToRangeStart* pMoveToRangeStart = static_cast<OOX::Logic::CMoveToRangeStart*>(item);
|
||||
// nCurPos = m_oBcw.WriteItemStart(c_oSerParType::MoveToRangeStart);
|
||||
// WriteMoveRangeStart(*pMoveToRangeStart);
|
||||
// m_oBcw.WriteItemEnd(nCurPos);
|
||||
// break;
|
||||
// }
|
||||
// case OOX::et_w_moveToRangeEnd:
|
||||
// {
|
||||
// OOX::Logic::CMoveToRangeEnd* pMoveToRangeEnd = static_cast<OOX::Logic::CMoveToRangeEnd*>(item);
|
||||
// nCurPos = m_oBcw.WriteItemStart(c_oSerParType::MoveToRangeEnd);
|
||||
// WriteMoveRangeEnd(*pMoveToRangeEnd);
|
||||
// m_oBcw.WriteItemEnd(nCurPos);
|
||||
// break;
|
||||
// }
|
||||
case OOX::et_w_moveFromRangeStart:
|
||||
{
|
||||
OOX::Logic::CMoveFromRangeStart* pMoveFromRangeStart = static_cast<OOX::Logic::CMoveFromRangeStart*>(item);
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerParType::MoveFromRangeStart);
|
||||
WriteMoveRangeStart(*pMoveFromRangeStart);
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
break;
|
||||
}
|
||||
case OOX::et_w_moveFromRangeEnd:
|
||||
{
|
||||
OOX::Logic::CMoveFromRangeEnd* pMoveFromRangeEnd = static_cast<OOX::Logic::CMoveFromRangeEnd*>(item);
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerParType::MoveFromRangeEnd);
|
||||
WriteMoveRangeEnd(*pMoveFromRangeEnd);
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
break;
|
||||
}
|
||||
case OOX::et_w_moveToRangeStart:
|
||||
{
|
||||
OOX::Logic::CMoveToRangeStart* pMoveToRangeStart = static_cast<OOX::Logic::CMoveToRangeStart*>(item);
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerParType::MoveToRangeStart);
|
||||
WriteMoveRangeStart(*pMoveToRangeStart);
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
break;
|
||||
}
|
||||
case OOX::et_w_moveToRangeEnd:
|
||||
{
|
||||
OOX::Logic::CMoveToRangeEnd* pMoveToRangeEnd = static_cast<OOX::Logic::CMoveToRangeEnd*>(item);
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerParType::MoveToRangeEnd);
|
||||
WriteMoveRangeEnd(*pMoveToRangeEnd);
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
break;
|
||||
}
|
||||
case OOX::et_m_oMathPara:
|
||||
{
|
||||
OOX::Logic::COMathPara* pOMathPara = static_cast<OOX::Logic::COMathPara*>(item);
|
||||
@ -4222,6 +4249,38 @@ void BinaryDocumentTableWriter::WriteMathArgNodes(const std::vector<OOX::Writing
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
break;
|
||||
}
|
||||
case OOX::et_w_moveFromRangeStart:
|
||||
{
|
||||
OOX::Logic::CMoveFromRangeStart* pMoveFromRangeStart = static_cast<OOX::Logic::CMoveFromRangeStart*>(item);
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_OMathContentType::MoveFromRangeStart);
|
||||
WriteMoveRangeStart(*pMoveFromRangeStart);
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
break;
|
||||
}
|
||||
case OOX::et_w_moveFromRangeEnd:
|
||||
{
|
||||
OOX::Logic::CMoveFromRangeEnd* pMoveFromRangeEnd = static_cast<OOX::Logic::CMoveFromRangeEnd*>(item);
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_OMathContentType::MoveFromRangeEnd);
|
||||
WriteMoveRangeEnd(*pMoveFromRangeEnd);
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
break;
|
||||
}
|
||||
case OOX::et_w_moveToRangeStart:
|
||||
{
|
||||
OOX::Logic::CMoveToRangeStart* pMoveToRangeStart = static_cast<OOX::Logic::CMoveToRangeStart*>(item);
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_OMathContentType::MoveToRangeStart);
|
||||
WriteMoveRangeStart(*pMoveToRangeStart);
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
break;
|
||||
}
|
||||
case OOX::et_w_moveToRangeEnd:
|
||||
{
|
||||
OOX::Logic::CMoveToRangeEnd* pMoveToRangeEnd = static_cast<OOX::Logic::CMoveToRangeEnd*>(item);
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_OMathContentType::MoveToRangeEnd);
|
||||
WriteMoveRangeEnd(*pMoveToRangeEnd);
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -6806,6 +6865,34 @@ void BinaryDocumentTableWriter::WriteTableContent(std::vector<OOX::WritingElemen
|
||||
WriteBookmarkEnd(*pBookmarkEnd);
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
else if(OOX::et_w_moveFromRangeStart == item->getType())
|
||||
{
|
||||
OOX::Logic::CMoveFromRangeStart* pMoveFromRangeStart = static_cast<OOX::Logic::CMoveFromRangeStart*>(item);
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerDocTableType::MoveFromRangeStart);
|
||||
WriteMoveRangeStart(*pMoveFromRangeStart);
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
}
|
||||
else if(OOX::et_w_moveFromRangeEnd == item->getType())
|
||||
{
|
||||
OOX::Logic::CMoveFromRangeEnd* pMoveFromRangeEnd = static_cast<OOX::Logic::CMoveFromRangeEnd*>(item);
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerDocTableType::MoveFromRangeEnd);
|
||||
WriteMoveRangeEnd(*pMoveFromRangeEnd);
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
}
|
||||
else if(OOX::et_w_moveToRangeStart == item->getType())
|
||||
{
|
||||
OOX::Logic::CMoveToRangeStart* pMoveToRangeStart = static_cast<OOX::Logic::CMoveToRangeStart*>(item);
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerDocTableType::MoveToRangeStart);
|
||||
WriteMoveRangeStart(*pMoveToRangeStart);
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
}
|
||||
else if(OOX::et_w_moveToRangeEnd == item->getType())
|
||||
{
|
||||
OOX::Logic::CMoveToRangeEnd* pMoveToRangeEnd = static_cast<OOX::Logic::CMoveToRangeEnd*>(item);
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerDocTableType::MoveToRangeEnd);
|
||||
WriteMoveRangeEnd(*pMoveToRangeEnd);
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
void BinaryDocumentTableWriter::WriteRow(const OOX::Logic::CTr& Row, OOX::Logic::CTableProperty* pTblPr, int nCurRowIndex, int nRows, int nCols)
|
||||
@ -6880,6 +6967,34 @@ void BinaryDocumentTableWriter::WriteRowContent(const std::vector<OOX::WritingEl
|
||||
WriteBookmarkEnd(*pBookmarkEnd);
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
else if(OOX::et_w_moveFromRangeStart == item->getType())
|
||||
{
|
||||
OOX::Logic::CMoveFromRangeStart* pMoveFromRangeStart = static_cast<OOX::Logic::CMoveFromRangeStart*>(item);
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerDocTableType::MoveFromRangeStart);
|
||||
WriteMoveRangeStart(*pMoveFromRangeStart);
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
}
|
||||
else if(OOX::et_w_moveFromRangeEnd == item->getType())
|
||||
{
|
||||
OOX::Logic::CMoveFromRangeEnd* pMoveFromRangeEnd = static_cast<OOX::Logic::CMoveFromRangeEnd*>(item);
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerDocTableType::MoveFromRangeEnd);
|
||||
WriteMoveRangeEnd(*pMoveFromRangeEnd);
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
}
|
||||
else if(OOX::et_w_moveToRangeStart == item->getType())
|
||||
{
|
||||
OOX::Logic::CMoveToRangeStart* pMoveToRangeStart = static_cast<OOX::Logic::CMoveToRangeStart*>(item);
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerDocTableType::MoveToRangeStart);
|
||||
WriteMoveRangeStart(*pMoveToRangeStart);
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
}
|
||||
else if(OOX::et_w_moveToRangeEnd == item->getType())
|
||||
{
|
||||
OOX::Logic::CMoveToRangeEnd* pMoveToRangeEnd = static_cast<OOX::Logic::CMoveToRangeEnd*>(item);
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerDocTableType::MoveToRangeEnd);
|
||||
WriteMoveRangeEnd(*pMoveToRangeEnd);
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
void BinaryDocumentTableWriter::WriteCell(OOX::Logic::CTc& tc, OOX::Logic::CTableProperty* pTblPr, int nCurRowIndex, int nCurColIndex, int nRows, int nCols)
|
||||
|
||||
@ -143,7 +143,7 @@ docx_conversion_context::docx_conversion_context(odf_reader::odf_document * OdfD
|
||||
text_tracked_context_ (*this),
|
||||
table_context_ (*this),
|
||||
output_document_ (NULL),
|
||||
process_note_ (noNote),
|
||||
current_process_note_ (noNote),
|
||||
new_list_style_number_ (0),
|
||||
current_margin_left_ (0),
|
||||
current_outline_level_ (-1),
|
||||
@ -151,7 +151,7 @@ docx_conversion_context::docx_conversion_context(odf_reader::odf_document * OdfD
|
||||
is_delete_text_ (false),
|
||||
delayed_converting_ (false),
|
||||
process_headers_footers_ (false),
|
||||
process_comment_ (false),
|
||||
current_process_comment_ (false),
|
||||
mediaitems_ (OdfDocument->get_folder() ),
|
||||
math_context_ (OdfDocument->odf_context().fontContainer(), false),
|
||||
odf_document_ (OdfDocument)
|
||||
@ -619,9 +619,9 @@ std::wstring docx_conversion_context::add_hyperlink(const std::wstring & href, b
|
||||
{
|
||||
hyperlinks::_type_place type = hyperlinks::document_place;
|
||||
|
||||
if (process_comment_ == true) type = hyperlinks::comment_place;
|
||||
else if (process_note_ == footNote || process_note_ == footNoteRefSet) type = hyperlinks::footnote_place;
|
||||
else if (process_note_ == endNote || process_note_ == endNoteRefSet ) type = hyperlinks::endnote_place;
|
||||
if (current_process_comment_ == true) type = hyperlinks::comment_place;
|
||||
else if (current_process_note_ == footNote || current_process_note_ == footNoteRefSet) type = hyperlinks::footnote_place;
|
||||
else if (current_process_note_ == endNote || current_process_note_ == endNoteRefSet ) type = hyperlinks::endnote_place;
|
||||
|
||||
std::wstring href_correct = xml::utils::replace_text_to_xml(href);
|
||||
XmlUtils::replace_all( href_correct, L" .", L".");//1 (130).odt
|
||||
@ -1464,7 +1464,7 @@ void docx_conversion_context::end_text_list_style()
|
||||
text_list_style_name_ = L"";
|
||||
}
|
||||
|
||||
const std::wstring & docx_conversion_context::get_text_list_style_name()
|
||||
std::wstring docx_conversion_context::get_text_list_style_name()
|
||||
{
|
||||
return text_list_style_name_;
|
||||
}
|
||||
@ -1490,9 +1490,9 @@ void docx_conversion_context::end_list()
|
||||
list_style_stack_.pop_back();
|
||||
}
|
||||
|
||||
const std::wstring docx_conversion_context::current_list_style() const
|
||||
std::wstring docx_conversion_context::current_list_style()
|
||||
{
|
||||
if (!list_style_stack_.empty())
|
||||
if (false == list_style_stack_.empty())
|
||||
return list_style_stack_.back();
|
||||
else
|
||||
return L"";
|
||||
@ -1545,6 +1545,93 @@ int docx_conversion_context::process_text_attr(odf_reader::text::paragraph_attrs
|
||||
push_text_properties(styleContent->get_style_text_properties());
|
||||
return 1;
|
||||
}
|
||||
int docx_conversion_context::process_paragraph_style(const std::wstring & style_name)
|
||||
{
|
||||
if (style_name.empty()) return 0;
|
||||
|
||||
if (odf_reader::style_instance * styleInst =
|
||||
root()->odf_context().styleContainer().style_by_name(style_name, odf_types::style_family::Paragraph, process_headers_footers_))
|
||||
{
|
||||
double font_size = odf_reader::text_format_properties_content::process_font_size_impl(odf_types::font_size(odf_types::percent(100.0)), styleInst);
|
||||
if (font_size > 0) current_fontSize.push_back(font_size);
|
||||
|
||||
process_page_break_after(styleInst);
|
||||
|
||||
if (styleInst->is_automatic())
|
||||
{
|
||||
if (odf_reader::style_content * styleContent = styleInst->content())
|
||||
{
|
||||
std::wstring id;
|
||||
//office_element_ptr parent_tab_stops_;
|
||||
if (const odf_reader::style_instance * parentStyleContent = styleInst->parent())
|
||||
{
|
||||
std::wstring parent_name = parentStyleContent->name();
|
||||
id = styles_map_.get( parent_name, parentStyleContent->type() );
|
||||
|
||||
if (in_table_content_ && table_content_context_.empty_current_table_content_level_index())
|
||||
{
|
||||
table_content_context_.set_current_level(parent_name);
|
||||
}
|
||||
}
|
||||
|
||||
start_automatic_style(id);
|
||||
|
||||
calc_tab_stops(styleInst, get_tabs_context());
|
||||
|
||||
//вытаскивает rtl c цепочки стилей !! - просто прописать в наследуемом НЕЛЬЗЯ !!
|
||||
odf_reader::paragraph_format_properties properties = odf_reader::calc_paragraph_properties_content(styleInst);
|
||||
if (properties.style_writing_mode_)
|
||||
{
|
||||
odf_types::writing_mode::type type = properties.style_writing_mode_->get_type();
|
||||
switch(type)
|
||||
{
|
||||
case odf_types::writing_mode::RlTb:
|
||||
case odf_types::writing_mode::TbRl:
|
||||
case odf_types::writing_mode::Rl:
|
||||
set_rtl(true);
|
||||
break;
|
||||
default:
|
||||
set_rtl(false);
|
||||
}
|
||||
}
|
||||
set_margin_left(properties.fo_margin_left_? 20.0 * properties.fo_margin_left_->get_length().get_value_unit(odf_types::length::pt) : 0);
|
||||
|
||||
styleContent->docx_convert(*this);
|
||||
|
||||
end_automatic_style();
|
||||
|
||||
//push_text_properties(styleContent->get_style_text_properties());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const std::wstring id = styles_map_.get( styleInst->name(), styleInst->type() );
|
||||
output_stream() << L"<w:pPr>";
|
||||
|
||||
output_stream() << L"<w:pStyle w:val=\"" << id << L"\" />";
|
||||
|
||||
if (!get_text_tracked_context().dumpPPr_.empty())
|
||||
{
|
||||
output_stream() << get_text_tracked_context().dumpPPr_;
|
||||
get_text_tracked_context().dumpPPr_.clear();
|
||||
}
|
||||
|
||||
serialize_list_properties(output_stream());
|
||||
|
||||
if (!get_text_tracked_context().dumpRPrInsDel_.empty())
|
||||
{
|
||||
output_stream() << L"<w:rPr>";
|
||||
output_stream() << get_text_tracked_context().dumpRPrInsDel_;
|
||||
get_text_tracked_context().dumpRPrInsDel_.clear();
|
||||
output_stream() << L"</w:rPr>";
|
||||
}
|
||||
output_stream() << L"</w:pPr>";
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int docx_conversion_context::process_paragraph_attr(odf_reader::text::paragraph_attrs *Attr)
|
||||
{
|
||||
if (!Attr) return 0;
|
||||
@ -1565,19 +1652,22 @@ int docx_conversion_context::process_paragraph_attr(odf_reader::text::paragraph_
|
||||
if (odf_reader::style_instance * styleInst =
|
||||
root()->odf_context().styleContainer().style_by_name(Attr->text_style_name_, odf_types::style_family::Paragraph, process_headers_footers_)
|
||||
)
|
||||
{
|
||||
process_page_break_after(styleInst);
|
||||
{
|
||||
double font_size = odf_reader::text_format_properties_content::process_font_size_impl(odf_types::font_size(odf_types::percent(100.0)), styleInst);
|
||||
if (font_size > 0) current_fontSize.push_back(font_size);
|
||||
|
||||
process_page_break_after(styleInst);
|
||||
|
||||
if (styleInst->is_automatic())
|
||||
{
|
||||
if (odf_reader::style_content * styleContent = styleInst->content())
|
||||
{
|
||||
std::wstring id;
|
||||
{
|
||||
if (odf_reader::style_content * styleContent = styleInst->content())
|
||||
{
|
||||
std::wstring id;
|
||||
//office_element_ptr parent_tab_stops_;
|
||||
if (const odf_reader::style_instance * parentStyleContent = styleInst->parent())
|
||||
if (const odf_reader::style_instance * parentStyleContent = styleInst->parent())
|
||||
{
|
||||
std::wstring parent_name = parentStyleContent->name();
|
||||
id = styles_map_.get( parent_name, parentStyleContent->type() );
|
||||
id = styles_map_.get( parent_name, parentStyleContent->type() );
|
||||
|
||||
if (in_table_content_ && table_content_context_.empty_current_table_content_level_index())
|
||||
{
|
||||
@ -1585,7 +1675,7 @@ int docx_conversion_context::process_paragraph_attr(odf_reader::text::paragraph_
|
||||
}
|
||||
}
|
||||
|
||||
start_automatic_style(id);
|
||||
start_automatic_style(id);
|
||||
|
||||
calc_tab_stops(styleInst, get_tabs_context());
|
||||
|
||||
@ -1611,10 +1701,10 @@ int docx_conversion_context::process_paragraph_attr(odf_reader::text::paragraph_
|
||||
set_outline_level(*Attr->outline_level_ - 1);
|
||||
}
|
||||
styleContent->docx_convert(*this);
|
||||
|
||||
|
||||
end_automatic_style();
|
||||
|
||||
push_text_properties(styleContent->get_style_text_properties());
|
||||
push_text_properties(styleContent->get_style_text_properties());
|
||||
|
||||
if (!get_section_context().dump_.empty()
|
||||
&& !get_table_context().in_table()
|
||||
@ -1630,6 +1720,8 @@ int docx_conversion_context::process_paragraph_attr(odf_reader::text::paragraph_
|
||||
output_stream() << L"</w:pPr>";
|
||||
finish_paragraph();
|
||||
start_paragraph();
|
||||
//process_paragraph_style(Context.get_current_paragraph_style()); ??
|
||||
|
||||
if ((Attr->outline_level_) && (*Attr->outline_level_ > 0))
|
||||
{
|
||||
output_stream() << L"<w:pPr>";
|
||||
@ -1649,58 +1741,58 @@ int docx_conversion_context::process_paragraph_attr(odf_reader::text::paragraph_
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const std::wstring id = styles_map_.get( styleInst->name(), styleInst->type() );
|
||||
output_stream() << L"<w:pPr>";
|
||||
//todooo причесать
|
||||
if (!get_section_context().dump_.empty()
|
||||
&& !get_table_context().in_table()
|
||||
&& (get_process_note() == oox::docx_conversion_context::noNote)
|
||||
&& !in_drawing)
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const std::wstring id = styles_map_.get( styleInst->name(), styleInst->type() );
|
||||
output_stream() << L"<w:pPr>";
|
||||
//todooo причесать
|
||||
if (!get_section_context().dump_.empty()
|
||||
&& !get_table_context().in_table()
|
||||
&& (get_process_note() == oox::docx_conversion_context::noNote)
|
||||
&& !in_drawing)
|
||||
{
|
||||
if (is_paragraph_header() )
|
||||
{
|
||||
if (is_paragraph_header() )
|
||||
{
|
||||
output_stream() << get_section_context().dump_;
|
||||
get_section_context().dump_.clear();
|
||||
output_stream() << get_section_context().dump_;
|
||||
get_section_context().dump_.clear();
|
||||
|
||||
output_stream() << L"</w:pPr>";
|
||||
finish_paragraph();
|
||||
start_paragraph();
|
||||
output_stream() << L"<w:pPr>";
|
||||
}
|
||||
else
|
||||
{
|
||||
output_stream() << get_section_context().dump_;
|
||||
get_section_context().dump_.clear();
|
||||
}
|
||||
output_stream() << L"</w:pPr>";
|
||||
finish_paragraph();
|
||||
start_paragraph();
|
||||
output_stream() << L"<w:pPr>";
|
||||
}
|
||||
|
||||
output_stream() << L"<w:pStyle w:val=\"" << id << L"\" />";
|
||||
|
||||
if (!get_text_tracked_context().dumpPPr_.empty())
|
||||
else
|
||||
{
|
||||
output_stream() << get_text_tracked_context().dumpPPr_;
|
||||
get_text_tracked_context().dumpPPr_.clear();
|
||||
output_stream() << get_section_context().dump_;
|
||||
get_section_context().dump_.clear();
|
||||
}
|
||||
}
|
||||
|
||||
serialize_list_properties(output_stream());
|
||||
|
||||
if ((Attr->outline_level_) && (*Attr->outline_level_ > 0))
|
||||
{
|
||||
output_stream() << L"<w:outlineLvl w:val=\"" << *Attr->outline_level_ - 1 << L"\" />";
|
||||
}
|
||||
output_stream() << L"<w:pStyle w:val=\"" << id << L"\" />";
|
||||
|
||||
if (!get_text_tracked_context().dumpRPrInsDel_.empty())
|
||||
{
|
||||
output_stream() << L"<w:rPr>";
|
||||
output_stream() << get_text_tracked_context().dumpRPrInsDel_;
|
||||
get_text_tracked_context().dumpRPrInsDel_.clear();
|
||||
output_stream() << L"</w:rPr>";
|
||||
}
|
||||
output_stream() << L"</w:pPr>";
|
||||
if (!get_text_tracked_context().dumpPPr_.empty())
|
||||
{
|
||||
output_stream() << get_text_tracked_context().dumpPPr_;
|
||||
get_text_tracked_context().dumpPPr_.clear();
|
||||
}
|
||||
|
||||
serialize_list_properties(output_stream());
|
||||
|
||||
if ((Attr->outline_level_) && (*Attr->outline_level_ > 0))
|
||||
{
|
||||
output_stream() << L"<w:outlineLvl w:val=\"" << *Attr->outline_level_ - 1 << L"\" />";
|
||||
}
|
||||
|
||||
if (!get_text_tracked_context().dumpRPrInsDel_.empty())
|
||||
{
|
||||
output_stream() << L"<w:rPr>";
|
||||
output_stream() << get_text_tracked_context().dumpRPrInsDel_;
|
||||
get_text_tracked_context().dumpRPrInsDel_.clear();
|
||||
output_stream() << L"</w:rPr>";
|
||||
}
|
||||
output_stream() << L"</w:pPr>";
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
@ -1751,28 +1843,27 @@ void docx_conversion_context::process_page_break_after(const odf_reader::style_i
|
||||
}
|
||||
void docx_conversion_context::serialize_list_properties(std::wostream & strm)
|
||||
{
|
||||
if (!list_style_stack_.empty())
|
||||
if (list_style_stack_.empty()) return;
|
||||
|
||||
if (first_element_list_item_)
|
||||
{
|
||||
if (first_element_list_item_)
|
||||
{
|
||||
const int id = root()->odf_context().listStyleContainer().id_by_name( current_list_style() );
|
||||
const int id = root()->odf_context().listStyleContainer().id_by_name( current_list_style() );
|
||||
|
||||
CP_XML_WRITER(strm)
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE(L"w:numPr")
|
||||
{
|
||||
CP_XML_NODE(L"w:numPr")
|
||||
CP_XML_NODE(L"w:ilvl")
|
||||
{
|
||||
CP_XML_NODE(L"w:ilvl")
|
||||
{
|
||||
CP_XML_ATTR(L"w:val", (list_style_stack_.size() - 1));
|
||||
}
|
||||
CP_XML_NODE(L"w:numId")
|
||||
{
|
||||
CP_XML_ATTR(L"w:val", id );
|
||||
}
|
||||
CP_XML_ATTR(L"w:val", (list_style_stack_.size() - 1));
|
||||
}
|
||||
CP_XML_NODE(L"w:numId")
|
||||
{
|
||||
CP_XML_ATTR(L"w:val", id );
|
||||
}
|
||||
}
|
||||
first_element_list_item_ = false;
|
||||
}
|
||||
}
|
||||
first_element_list_item_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1938,12 +2029,12 @@ void notes_context::dump_rels(rels & Rels) const
|
||||
|
||||
void docx_conversion_context::add_note_reference ()
|
||||
{
|
||||
if (process_note_ == footNote || process_note_ == endNote)
|
||||
if (current_process_note_ == footNote || current_process_note_ == endNote)
|
||||
{
|
||||
add_element_to_run(_T(""));
|
||||
output_stream() << ((process_note_ == footNote) ? L"<w:footnoteRef />" : L"<w:endnoteRef />");
|
||||
output_stream() << ((current_process_note_ == footNote) ? L"<w:footnoteRef />" : L"<w:endnoteRef />");
|
||||
finish_run();
|
||||
process_note_ = (NoteType) (process_note_ + 1); //add ref set
|
||||
current_process_note_ = (NoteType) (current_process_note_ + 1); //add ref set
|
||||
}
|
||||
}
|
||||
|
||||
@ -1992,7 +2083,7 @@ void docx_conversion_context::start_text_changes (const std::wstring &id)
|
||||
void docx_conversion_context::start_changes()
|
||||
{
|
||||
if (map_current_changes_.empty()) return;
|
||||
if (process_comment_) return;
|
||||
if (current_process_comment_) return;
|
||||
|
||||
text_tracked_context_.dumpPPr_.clear();
|
||||
text_tracked_context_.dumpRPr_.clear();
|
||||
@ -2091,7 +2182,7 @@ void docx_conversion_context::start_changes()
|
||||
|
||||
void docx_conversion_context::end_changes()
|
||||
{
|
||||
if (process_comment_) return;
|
||||
if (current_process_comment_) return;
|
||||
|
||||
for (map_changes_iterator it = map_current_changes_.begin(); it != map_current_changes_.end(); ++it)
|
||||
{
|
||||
|
||||
@ -829,6 +829,7 @@ public:
|
||||
bool process_page_properties(std::wostream & strm);
|
||||
void process_section (std::wostream & strm, odf_reader::style_columns * columns = NULL);
|
||||
|
||||
int process_paragraph_style (const std::wstring & style_name);
|
||||
int process_paragraph_attr (odf_reader::text::paragraph_attrs *attr);
|
||||
int process_text_attr (odf_reader::text::paragraph_attrs *Attr);
|
||||
void process_page_break_after(const odf_reader::style_instance *styleInst);
|
||||
@ -872,8 +873,8 @@ public:
|
||||
void start_text_list_style (const std::wstring & StyleName);
|
||||
void end_text_list_style ();
|
||||
|
||||
const std::wstring & get_text_list_style_name();
|
||||
const std::wstring current_list_style () const;
|
||||
std::wstring get_text_list_style_name();
|
||||
std::wstring current_list_style();
|
||||
|
||||
void start_list (const std::wstring & StyleName, bool Continue = false);
|
||||
void end_list ();
|
||||
@ -910,26 +911,32 @@ public:
|
||||
StreamsManPtr get_stream_man() const { return streams_man_; }
|
||||
void set_stream_man(StreamsManPtr Sm) { streams_man_ = Sm; }
|
||||
|
||||
void set_rtl(bool val) { is_rtl_ = val; }
|
||||
bool get_rtl() const {return is_rtl_;}
|
||||
void set_rtl(bool val) { is_rtl_ = val; }
|
||||
bool get_rtl() const {return is_rtl_;}
|
||||
|
||||
double get_current_fontSize() {return current_fontSize.empty() ? 0 : current_fontSize.back();}
|
||||
void pop_current_fontSize() {if (!current_fontSize.empty()) current_fontSize.pop_back();}
|
||||
|
||||
void set_margin_left(int val) {current_margin_left_ = val;}
|
||||
int get_margin_left() {return current_margin_left_;}
|
||||
|
||||
void set_outline_level(int val) {current_outline_level_ = val;}
|
||||
int get_outline_level() {return current_outline_level_;}
|
||||
|
||||
void set_process_note (NoteType Val) { process_note_ = Val; }
|
||||
NoteType get_process_note () const { return process_note_; }
|
||||
void set_process_note (NoteType Val) { current_process_note_ = Val; }
|
||||
NoteType get_process_note () const { return current_process_note_; }
|
||||
void add_note_reference ();
|
||||
|
||||
void start_paragraph_style(const std::wstring& style_name) {paragraph_style_stack_.push_back(style_name);}
|
||||
void end_paragraph_style() { if (!paragraph_style_stack_.empty()) paragraph_style_stack_.pop_back();}
|
||||
std::wstring get_current_paragraph_style() {return paragraph_style_stack_.empty() ? L"" : paragraph_style_stack_.back();}
|
||||
|
||||
oox_chart_context & current_chart();
|
||||
void start_chart(std::wstring name);
|
||||
void end_chart ();
|
||||
|
||||
void start_comment () {process_comment_ = true;}
|
||||
void end_comment () {process_comment_ = false;}
|
||||
bool process_comment_;
|
||||
void start_comment () {current_process_comment_ = true;}
|
||||
void end_comment () {current_process_comment_ = false;}
|
||||
|
||||
void start_math_formula ();
|
||||
void end_math_formula ();
|
||||
@ -948,7 +955,7 @@ public:
|
||||
|
||||
headers_footers & get_headers_footers() { return headers_footers_; }
|
||||
header_footer_context & get_header_footer_context() { return header_footer_context_; }
|
||||
drop_cap_context & get_drop_cap_context() {return drop_cap_context_;}
|
||||
drop_cap_context & get_drop_cap_context() { return drop_cap_context_; }
|
||||
|
||||
styles_map styles_map_;
|
||||
bool process_headers_footers_;
|
||||
@ -959,6 +966,7 @@ public:
|
||||
void end_changes();
|
||||
|
||||
void add_jsaProject(const std::string &content);
|
||||
|
||||
private:
|
||||
|
||||
struct _context_state
|
||||
@ -1011,14 +1019,14 @@ private:
|
||||
std::vector<oox_chart_context_ptr> charts_;
|
||||
headers_footers headers_footers_;
|
||||
|
||||
std::wstring automatic_parent_style_;
|
||||
std::wstring current_master_page_name_;
|
||||
std::wstring text_list_style_name_;
|
||||
|
||||
std::vector<std::wstring> list_style_stack_;
|
||||
std::vector<std::wstring> fields_names_stack_;
|
||||
std::wstring automatic_parent_style_;
|
||||
std::wstring current_master_page_name_;
|
||||
std::wstring text_list_style_name_;
|
||||
std::vector<std::wstring> paragraph_style_stack_;
|
||||
std::vector<std::wstring> list_style_stack_;
|
||||
std::vector<std::wstring> fields_names_stack_;
|
||||
|
||||
bool first_element_list_item_;
|
||||
bool first_element_list_item_;
|
||||
|
||||
bool page_break_after_;
|
||||
bool page_break_before_;
|
||||
@ -1032,11 +1040,13 @@ private:
|
||||
bool is_delete_text_;
|
||||
bool is_rtl_; // right-to-left
|
||||
|
||||
std::wstring current_alphabetic_index_;
|
||||
int current_margin_left_;
|
||||
int current_outline_level_;
|
||||
int new_list_style_number_; // счетчик для нумерации имен созданных в процессе конвертации стилей
|
||||
NoteType process_note_;
|
||||
NoteType current_process_note_;
|
||||
bool current_process_comment_;
|
||||
std::vector<double> current_fontSize;
|
||||
std::wstring current_alphabetic_index_;
|
||||
int current_margin_left_;
|
||||
int current_outline_level_;
|
||||
int new_list_style_number_; // счетчик для нумерации имен созданных в процессе конвертации стилей
|
||||
|
||||
std::vector<odf_reader::office_element*> delayed_elements_;
|
||||
|
||||
|
||||
@ -193,7 +193,14 @@ std::wstring mediaitems::detectImageFileExtension(const std::wstring &fileName)
|
||||
CImageFileFormatChecker image_checker;
|
||||
sExt = image_checker.DetectFormatByData(buffer, buffer_size);
|
||||
|
||||
if (!sExt.empty()) sExt = std::wstring(L".") + sExt;
|
||||
if (sExt.empty())
|
||||
{
|
||||
size_t n = fileName.rfind(L".");
|
||||
if (n != std::wstring::npos)
|
||||
sExt = XmlUtils::GetLower(fileName.substr(n));
|
||||
|
||||
}
|
||||
else sExt = std::wstring(L".") + sExt;
|
||||
}
|
||||
return XmlUtils::GetLower(sExt);
|
||||
}
|
||||
|
||||
@ -493,6 +493,10 @@ void pptx_slide_context::set_image(const std::wstring & path)
|
||||
impl_->object_description_.type_ = typeImage;
|
||||
impl_->object_description_.xlink_href_ = path;
|
||||
}
|
||||
else if (impl_->object_description_.type_ == typeImage && impl_->object_description_.xlink_href_.rfind(L".svg") != std::wstring::npos)
|
||||
{
|
||||
impl_->object_description_.xlink_href_ = path;
|
||||
}
|
||||
else if (impl_->use_image_replacement_)
|
||||
{
|
||||
impl_->object_description_.fill_.type = 2;
|
||||
|
||||
@ -307,7 +307,7 @@ void line_break::docx_convert(oox::docx_conversion_context & Context)
|
||||
Context.finish_run();
|
||||
Context.finish_paragraph();
|
||||
Context.start_paragraph();
|
||||
|
||||
Context.process_paragraph_style(Context.get_current_paragraph_style());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -1204,7 +1204,10 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context &
|
||||
double fontSizeVal = (fo_font_size_) ? process_font_size_impl(fo_font_size_, Context.get_styles_context().get_current_processed_style()) :
|
||||
process_font_size_impl(font_size(percent(100.0)), Context.get_styles_context().get_current_processed_style());
|
||||
|
||||
if (style_text_position_->get_type() == text_position::Percent)
|
||||
if (fontSizeVal <= 0)
|
||||
fontSizeVal = Context.get_current_fontSize();
|
||||
|
||||
if (style_text_position_->get_type() == text_position::Percent)
|
||||
{
|
||||
const double mul = style_text_position_->get_position().get_value() / 100.0;
|
||||
if (fontSizeVal > 0)
|
||||
|
||||
@ -90,11 +90,9 @@ public:
|
||||
|
||||
int process_font_size (const _CP_OPT(odf_types::font_size) & FontSize, const style_instance * currnetStyle, bool Complex = false, double Mul = 1.0);
|
||||
|
||||
private:
|
||||
static double process_font_size_impl (const _CP_OPT(odf_types::font_size) & FontSize, const style_instance * currnetStyle, bool Complex = false, double Mul = 1.0);
|
||||
static int process_font_weight (const _CP_OPT(odf_types::font_weight) & FontWeight);
|
||||
static int process_font_style (const _CP_OPT(odf_types::font_style) & FontStyle);
|
||||
public:
|
||||
|
||||
_CP_OPT(std::wstring) r_style_;
|
||||
_CP_OPT(odf_types::font_variant) fo_font_variant_;
|
||||
|
||||
@ -330,8 +330,10 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
|
||||
|
||||
Context.get_drop_cap_context().state(1);//after
|
||||
Context.start_paragraph();
|
||||
Context.process_paragraph_style(Context.get_current_paragraph_style());
|
||||
|
||||
}
|
||||
Context.start_paragraph_style(styleName);
|
||||
|
||||
int textStyle = Context.process_paragraph_attr(&attrs_);
|
||||
|
||||
@ -370,7 +372,9 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
|
||||
if (textStyle > 0)
|
||||
{
|
||||
is_empty = false;
|
||||
if (textStyle==1) Context.pop_text_properties();
|
||||
if (textStyle == 1) Context.pop_text_properties();
|
||||
|
||||
Context.pop_current_fontSize();
|
||||
}
|
||||
|
||||
Context.finish_run();
|
||||
@ -394,6 +398,7 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
|
||||
if (is_empty)
|
||||
Context.output_stream() << emptyParagraphContent;
|
||||
|
||||
Context.end_paragraph_style();
|
||||
Context.finish_paragraph();
|
||||
}
|
||||
|
||||
|
||||
@ -885,7 +885,8 @@ bool odf_drawing_context::change_text_box_2_wordart()
|
||||
draw_base* draw_old = dynamic_cast<draw_base*>(impl_->current_level_[sz - 1].get());
|
||||
if (draw_old)
|
||||
{
|
||||
draw_old->content_[draw_old->content_.size() - 1] = draw_elm;
|
||||
if (draw_old->content_.size() > 1)
|
||||
draw_old->content_[draw_old->content_.size() - 1] = draw_elm;
|
||||
}
|
||||
}
|
||||
//----------------------------------------------
|
||||
@ -958,11 +959,15 @@ void odf_drawing_context::end_shape()
|
||||
{
|
||||
double angle = *rotate;//impl_->current_drawing_state_.rotateAngle_ ? *impl_->current_drawing_state_.rotateAngle_ : 0;
|
||||
|
||||
line->draw_line_attlist_.svg_x1_ = *line->draw_line_attlist_.svg_x1_ / 2 - (*line->draw_line_attlist_.svg_x1_ / 2 * cos(-angle) - *line->draw_line_attlist_.svg_y1_ / 2 * sin(-angle) );
|
||||
line->draw_line_attlist_.svg_y1_ = *line->draw_line_attlist_.svg_y1_ / 2 - (*line->draw_line_attlist_.svg_x1_ / 2 * sin(-angle) + *line->draw_line_attlist_.svg_y1_ / 2 * cos(-angle) );
|
||||
if (line->draw_line_attlist_.svg_x1_)
|
||||
line->draw_line_attlist_.svg_x1_ = *line->draw_line_attlist_.svg_x1_ / 2 - (*line->draw_line_attlist_.svg_x1_ / 2 * cos(-angle) - *line->draw_line_attlist_.svg_y1_ / 2 * sin(-angle) );
|
||||
if (line->draw_line_attlist_.svg_y1_)
|
||||
line->draw_line_attlist_.svg_y1_ = *line->draw_line_attlist_.svg_y1_ / 2 - (*line->draw_line_attlist_.svg_x1_ / 2 * sin(-angle) + *line->draw_line_attlist_.svg_y1_ / 2 * cos(-angle) );
|
||||
|
||||
line->draw_line_attlist_.svg_x2_ = *line->draw_line_attlist_.svg_x2_ / 2 - (*line->draw_line_attlist_.svg_x2_ / 2 * cos(-angle) - *line->draw_line_attlist_.svg_y2_ / 2 * sin(-angle) );
|
||||
line->draw_line_attlist_.svg_y2_ = *line->draw_line_attlist_.svg_y2_ / 2 - (*line->draw_line_attlist_.svg_x2_ / 2 * sin(-angle) + *line->draw_line_attlist_.svg_y2_ / 2 * cos(-angle) );
|
||||
if (line->draw_line_attlist_.svg_x2_)
|
||||
line->draw_line_attlist_.svg_x2_ = *line->draw_line_attlist_.svg_x2_ / 2 - (*line->draw_line_attlist_.svg_x2_ / 2 * cos(-angle) - *line->draw_line_attlist_.svg_y2_ / 2 * sin(-angle) );
|
||||
if (line->draw_line_attlist_.svg_y2_)
|
||||
line->draw_line_attlist_.svg_y2_ = *line->draw_line_attlist_.svg_y2_ / 2 - (*line->draw_line_attlist_.svg_x2_ / 2 * sin(-angle) + *line->draw_line_attlist_.svg_y2_ / 2 * cos(-angle) );
|
||||
|
||||
line->common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_transform_= L"";
|
||||
|
||||
|
||||
@ -874,8 +874,10 @@ void ods_table_state::set_cell_formula(std::wstring & formula)
|
||||
{
|
||||
if (formula.empty())return;
|
||||
|
||||
ods_conversion_context* ods_context = dynamic_cast<ods_conversion_context*>(context_);
|
||||
|
||||
//test external link
|
||||
bool bExternal = true;
|
||||
bool bExternal = !ods_context->externals_.empty();
|
||||
boost::wregex re(L"([\[]\\d+[\]])+");
|
||||
|
||||
while(bExternal)
|
||||
@ -884,11 +886,12 @@ void ods_table_state::set_cell_formula(std::wstring & formula)
|
||||
bExternal = boost::regex_search(formula, result, re);
|
||||
if (!bExternal) break;
|
||||
|
||||
ods_conversion_context* ods_context = dynamic_cast<ods_conversion_context*>(context_);
|
||||
|
||||
std::wstring refExternal = result[1].str();
|
||||
int idExternal = XmlUtils::GetInteger(refExternal.substr(1, refExternal.length() - 1)) - 1;
|
||||
|
||||
bExternal = idExternal >= 0 && idExternal < ods_context->externals_.size();
|
||||
|
||||
while(idExternal >= 0 && idExternal < ods_context->externals_.size())
|
||||
{
|
||||
size_t pos = formula.find(refExternal);
|
||||
|
||||
@ -3009,7 +3009,7 @@ void CDrawingConverter::doc_LoadShape(PPTX::Logic::SpTreeElem *elem, XmlUtils::C
|
||||
|
||||
if (bStroked)
|
||||
{
|
||||
CheckPenShape(elem, oNodeShape, pPPTShape);
|
||||
CheckPenShape(elem, oNodeShape, pPPTShape);
|
||||
}
|
||||
|
||||
CheckBrushShape(elem, oNodeShape, pPPTShape);
|
||||
@ -4104,18 +4104,21 @@ void CDrawingConverter::CheckBorderShape(PPTX::Logic::SpTreeElem* oElem, XmlUtil
|
||||
|
||||
if (oNodeBorder.IsValid())
|
||||
{
|
||||
pSpPr->ln.Init();
|
||||
nullable_int nWidthBorder;
|
||||
XmlMacroReadAttributeBase(oNode, L"width", nWidthBorder);
|
||||
|
||||
nullable_string sTypeBorder;
|
||||
XmlMacroReadAttributeBase(oNode, L"type", sTypeBorder);
|
||||
|
||||
XmlMacroReadAttributeBase(oNodeBorder, L"type", sTypeBorder);
|
||||
|
||||
SimpleTypes::CBorderType<> borderType;
|
||||
if (sTypeBorder.IsInit())
|
||||
{
|
||||
SimpleTypes::CBorderType<> borderType;
|
||||
borderType.FromString(sTypeBorder.get());
|
||||
}
|
||||
if (borderType.GetValue() != SimpleTypes::bordertypeNone)
|
||||
{
|
||||
pSpPr->ln.Init();
|
||||
|
||||
nullable_int nWidthBorder;
|
||||
XmlMacroReadAttributeBase(oNodeBorder, L"width", nWidthBorder);
|
||||
|
||||
if (borderType.GetValue() > 0 &&
|
||||
borderType.GetValue() < 6)
|
||||
{
|
||||
@ -4131,30 +4134,29 @@ void CDrawingConverter::CheckBorderShape(PPTX::Logic::SpTreeElem* oElem, XmlUtil
|
||||
case SimpleTypes::bordertypeDotDash: pSpPr->ln->prstDash->val->SetBYTECode(1); break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (nWidthBorder.IsInit())
|
||||
{
|
||||
pSpPr->ln->w = (int)(*nWidthBorder * g_emu_koef);//pt to emu
|
||||
}
|
||||
if (sColorBorder.IsInit())
|
||||
{
|
||||
PPTX::Logic::SolidFill* pSolid = new PPTX::Logic::SolidFill();
|
||||
pSolid->m_namespace = L"a";
|
||||
pSolid->Color.Color = new PPTX::Logic::SrgbClr();
|
||||
|
||||
if (std::wstring::npos != sColorBorder->find(L"#"))
|
||||
if (nWidthBorder.IsInit())
|
||||
{
|
||||
pSolid->Color.Color->SetHexString(sColorBorder->substr(1));
|
||||
pSpPr->ln->w = (int)(*nWidthBorder * g_emu_koef);//pt to emu
|
||||
}
|
||||
else
|
||||
if (sColorBorder.IsInit())
|
||||
{
|
||||
//"red", L"black" , .. to color
|
||||
PPTX::Logic::SolidFill* pSolid = new PPTX::Logic::SolidFill();
|
||||
pSolid->m_namespace = L"a";
|
||||
pSolid->Color.Color = new PPTX::Logic::SrgbClr();
|
||||
|
||||
if (std::wstring::npos != sColorBorder->find(L"#"))
|
||||
{
|
||||
pSolid->Color.Color->SetHexString(sColorBorder->substr(1));
|
||||
}
|
||||
else
|
||||
{
|
||||
//"red", L"black" , .. to color
|
||||
}
|
||||
|
||||
pSpPr->ln->Fill.m_type = PPTX::Logic::UniFill::solidFill;
|
||||
pSpPr->ln->Fill.Fill = pSolid;
|
||||
|
||||
}
|
||||
|
||||
pSpPr->ln->Fill.m_type = PPTX::Logic::UniFill::solidFill;
|
||||
pSpPr->ln->Fill.Fill = pSolid;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -410,7 +410,6 @@ HEADERS += pptxformatlib.h \
|
||||
../../../PPTXFormat/Logic/TextListStyle.h \
|
||||
../../../PPTXFormat/Logic/TextParagraphPr.h \
|
||||
../../../PPTXFormat/Logic/TextSpacing.h \
|
||||
../../../PPTXFormat/Logic/Timing.h \
|
||||
../../../PPTXFormat/Logic/TxBody.h \
|
||||
../../../PPTXFormat/Logic/TxStyles.h \
|
||||
../../../PPTXFormat/Logic/UniColor.h \
|
||||
|
||||
84
DesktopEditor/doctrenderer/app_builder/common.h
Normal file
84
DesktopEditor/doctrenderer/app_builder/common.h
Normal file
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2019
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _BUILDER_COMMON_H
|
||||
#define _BUILDER_COMMON_H
|
||||
|
||||
#ifndef Q_DECL_EXPORT
|
||||
|
||||
#define Q_BUILDCUSTOM_VISIBILITY_AVAILABLE
|
||||
|
||||
#ifndef Q_BUILDCUSTOM_VISIBILITY_AVAILABLE
|
||||
#ifdef QT_VISIBILITY_AVAILABLE
|
||||
#define Q_BUILDCUSTOM_VISIBILITY_AVAILABLE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
#define Q_DECL_EXPORT __declspec(dllexport)
|
||||
#define Q_DECL_IMPORT __declspec(dllimport)
|
||||
#elif defined(Q_BUILDCUSTOM_VISIBILITY_AVAILABLE)
|
||||
#define Q_DECL_EXPORT __attribute__((visibility("default")))
|
||||
#define Q_DECL_IMPORT __attribute__((visibility("default")))
|
||||
#endif
|
||||
|
||||
#ifndef Q_DECL_EXPORT
|
||||
#define Q_DECL_EXPORT
|
||||
#endif
|
||||
#ifndef Q_DECL_IMPORT
|
||||
#define Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#define OFFICESTUDIO_FILE_DOCUMENT 0x0040
|
||||
#define OFFICESTUDIO_FILE_DOCUMENT_DOCX OFFICESTUDIO_FILE_DOCUMENT + 0x0001
|
||||
#define OFFICESTUDIO_FILE_DOCUMENT_ODT OFFICESTUDIO_FILE_DOCUMENT + 0x0003
|
||||
#define OFFICESTUDIO_FILE_DOCUMENT_RTF OFFICESTUDIO_FILE_DOCUMENT + 0x0004
|
||||
#define OFFICESTUDIO_FILE_DOCUMENT_TXT OFFICESTUDIO_FILE_DOCUMENT + 0x0005
|
||||
|
||||
#define OFFICESTUDIO_FILE_PRESENTATION 0x0080
|
||||
#define OFFICESTUDIO_FILE_PRESENTATION_PPTX OFFICESTUDIO_FILE_PRESENTATION + 0x0001
|
||||
|
||||
#define OFFICESTUDIO_FILE_SPREADSHEET 0x0100
|
||||
#define OFFICESTUDIO_FILE_SPREADSHEET_XLSX OFFICESTUDIO_FILE_SPREADSHEET + 0x0001
|
||||
#define OFFICESTUDIO_FILE_SPREADSHEET_ODS OFFICESTUDIO_FILE_SPREADSHEET + 0x0003
|
||||
#define OFFICESTUDIO_FILE_SPREADSHEET_CSV OFFICESTUDIO_FILE_SPREADSHEET + 0x0004
|
||||
|
||||
#define OFFICESTUDIO_FILE_CROSSPLATFORM 0x0200
|
||||
#define OFFICESTUDIO_FILE_CROSSPLATFORM_PDF OFFICESTUDIO_FILE_CROSSPLATFORM + 0x0001
|
||||
|
||||
#define OFFICESTUDIO_FILE_IMAGE 0x0400
|
||||
#define OFFICESTUDIO_FILE_IMAGE_JPG OFFICESTUDIO_FILE_IMAGE + 0x0001
|
||||
#define OFFICESTUDIO_FILE_IMAGE_PNG OFFICESTUDIO_FILE_IMAGE + 0x0005
|
||||
|
||||
#endif // _BUILDER_COMMON_H
|
||||
54
DesktopEditor/doctrenderer/app_builder/docbuilder.pro
Normal file
54
DesktopEditor/doctrenderer/app_builder/docbuilder.pro
Normal file
@ -0,0 +1,54 @@
|
||||
QT -= core
|
||||
QT -= gui
|
||||
|
||||
TARGET = docbuilder
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
PRODUCT_VERSION=$$(PRODUCT_VERSION)
|
||||
BUILD_NUMBER=$$(BUILD_NUMBER)
|
||||
|
||||
isEmpty(PRODUCT_VERSION) {
|
||||
BINARYVERSION = 0.0.0.0
|
||||
}
|
||||
else {
|
||||
BINARYVERSION = $$(PRODUCT_VERSION).$$(BUILD_NUMBER)
|
||||
}
|
||||
|
||||
DEFINES += INTVER=$$BINARYVERSION
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
CONFIG += core_static_link_libstd
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../../../core
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
include($$CORE_ROOT_DIR/Common/3dParty/icu/icu.pri)
|
||||
|
||||
core_linux {
|
||||
QMAKE_LFLAGS += -Wl,--rpath=./:./system
|
||||
}
|
||||
|
||||
core_win_64 {
|
||||
QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:CONSOLE,5.02
|
||||
}
|
||||
core_win_32 {
|
||||
QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:CONSOLE,5.01
|
||||
}
|
||||
|
||||
core_windows {
|
||||
RC_FILE = version.rc
|
||||
}
|
||||
|
||||
############### destination path ###############
|
||||
DESTDIR = $$CORE_ROOT_DIR/build/bin/$$CORE_BUILDS_PLATFORM_PREFIX
|
||||
################################################
|
||||
|
||||
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -ldoctrenderer -lkernel -lgraphics -lUnicodeConverter
|
||||
|
||||
core_linux {
|
||||
LIBS += -ldl
|
||||
}
|
||||
|
||||
SOURCES += main.cpp
|
||||
BIN
DesktopEditor/doctrenderer/app_builder/icons.ico
Normal file
BIN
DesktopEditor/doctrenderer/app_builder/icons.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 279 KiB |
146
DesktopEditor/doctrenderer/app_builder/main.cpp
Normal file
146
DesktopEditor/doctrenderer/app_builder/main.cpp
Normal file
@ -0,0 +1,146 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2019
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
#include "./common.h"
|
||||
#include "../docbuilder.h"
|
||||
#include "../../common/File.h"
|
||||
|
||||
#ifdef LINUX
|
||||
#include "../../../DesktopEditor/common/File.h"
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <string>
|
||||
#define VALUE_TO_STRING(x) #x
|
||||
#define VALUE(x) VALUE_TO_STRING(x)
|
||||
|
||||
#ifdef WIN32
|
||||
int wmain(int argc, wchar_t *argv[])
|
||||
#else
|
||||
int main(int argc, char *argv[])
|
||||
#endif
|
||||
{
|
||||
if (argc <= 0)
|
||||
return 0;
|
||||
|
||||
bool bIsHelp = false;
|
||||
for (int i = 0; i < argc; ++i)
|
||||
{
|
||||
#ifdef WIN32
|
||||
std::wstring sW(argv[i]);
|
||||
std::string sParam(sW.begin(), sW.end());
|
||||
#else
|
||||
std::string sParam(argv[i]);
|
||||
#endif
|
||||
if (sParam == "-v" ||
|
||||
sParam == "-version")
|
||||
{
|
||||
std::cout << "v" VALUE(INTVER) << std::endl;
|
||||
NSDoctRenderer::CDocBuilder oBuilder;
|
||||
oBuilder.ExecuteCommand(L"checkL");
|
||||
|
||||
char* sSdkVer = oBuilder.GetVersion();
|
||||
if (NULL != sSdkVer)
|
||||
{
|
||||
std::string sSdkVerStd(sSdkVer);
|
||||
std::cout << "sdk version: " << sSdkVerStd << std::endl;
|
||||
delete [] sSdkVer;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
if (sParam == "-h" ||
|
||||
sParam == "-help")
|
||||
{
|
||||
bIsHelp = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (argc < 2 || bIsHelp)
|
||||
{
|
||||
std::cout << "USAGE: documentbuilder \"path_to_script_file\"" << std::endl;
|
||||
NSDoctRenderer::CDocBuilder oBuilder;
|
||||
oBuilder.ExecuteCommand(L"checkL");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
std::wstring sBuildFile(argv[argc - 1]);
|
||||
#else
|
||||
std::string sBuildFileA(argv[argc - 1]);
|
||||
std::wstring sBuildFile = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sBuildFileA.c_str(), (LONG)sBuildFileA.length());
|
||||
#endif
|
||||
|
||||
NSDoctRenderer::CDocBuilder::Initialize();
|
||||
|
||||
if (true)
|
||||
{
|
||||
NSDoctRenderer::CDocBuilder oBuilder;
|
||||
oBuilder.SetProperty("--check-fonts", L"");
|
||||
//oBuilder.SetProperty("--use-doctrenderer-scheme", L"");
|
||||
//oBuilder.SetProperty("--work-directory", L"builder");
|
||||
|
||||
for (int i = 0; i < (argc - 1); ++i)
|
||||
{
|
||||
#ifdef WIN32
|
||||
std::wstring sW(argv[i]);
|
||||
std::string sParam = U_TO_UTF8(sW);
|
||||
#else
|
||||
std::string sParam(argv[i]);
|
||||
#endif
|
||||
|
||||
if (sParam.find("--") == 0)
|
||||
{
|
||||
std::string::size_type _pos = sParam.find('=');
|
||||
if (std::string::npos == _pos)
|
||||
oBuilder.SetProperty(sParam.c_str(), L"");
|
||||
else
|
||||
{
|
||||
std::string sName = sParam.substr(0, _pos);
|
||||
std::string sValue = sParam.substr(_pos + 1);
|
||||
|
||||
std::wstring sValueW = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sValue.c_str(), (LONG)sValue.length());
|
||||
oBuilder.SetProperty(sName.c_str(), sValueW.c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
continue;
|
||||
}
|
||||
|
||||
oBuilder.Run(sBuildFile.c_str());
|
||||
}
|
||||
|
||||
NSDoctRenderer::CDocBuilder::Dispose();
|
||||
|
||||
return 0;
|
||||
}
|
||||
30
DesktopEditor/doctrenderer/app_builder/version.h
Normal file
30
DesktopEditor/doctrenderer/app_builder/version.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef VERSION_H
|
||||
#define VERSION_H
|
||||
|
||||
#define VER_FILEVERSION 1,0,0,2
|
||||
#define VER_FILEVERSION_STR "1.0.0.2\0"
|
||||
|
||||
#define VER_PRODUCTVERSION VER_FILEVERSION
|
||||
#define VER_PRODUCTVERSION_STR "1.0\0"
|
||||
|
||||
#ifdef ONLY_RU
|
||||
#define VER_COMPANYNAME_STR "Novie kommunikacionnie tehnologii CJSC\0"
|
||||
#define VER_LEGALCOPYRIGHT_STR "Novie kommunikacionnie tehnologii CJSC, 2016\0"
|
||||
#define VER_COMPANYDOMAIN_STR "www.onlyoffice.ru\0"
|
||||
#define ABOUT_COPYRIGHT_STR "1999-2016 ЗАО 'НКТ'\0"
|
||||
#else
|
||||
#define VER_COMPANYNAME_STR "Ascensio System SIA\0"
|
||||
#define VER_LEGALCOPYRIGHT_STR "Ascensio System SIA 2016\0"
|
||||
#define VER_COMPANYDOMAIN_STR "www.onlyoffice.com\0"
|
||||
#define ABOUT_COPYRIGHT_STR VER_LEGALCOPYRIGHT_STR
|
||||
#endif
|
||||
|
||||
#define VER_FILEDESCRIPTION_STR "ONLYOFFICE Document Builder\0"
|
||||
#define VER_INTERNALNAME_STR "Document Builder\0"
|
||||
#define VER_LEGALTRADEMARKS1_STR "All Rights Reserved\0"
|
||||
#define VER_LEGALTRADEMARKS2_STR VER_LEGALTRADEMARKS1_STR
|
||||
#define VER_ORIGINALFILENAME_STR "docbuilder.exe\0"
|
||||
#define VER_PRODUCTNAME_STR "ONLYOFFICE Document Builder\0"
|
||||
|
||||
#endif
|
||||
|
||||
32
DesktopEditor/doctrenderer/app_builder/version.rc
Normal file
32
DesktopEditor/doctrenderer/app_builder/version.rc
Normal file
@ -0,0 +1,32 @@
|
||||
MAINICON ICON DISCARDABLE "./icons.ico"
|
||||
|
||||
#include <windows.h>
|
||||
#include "./version.h"
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION VER_FILEVERSION
|
||||
PRODUCTVERSION VER_PRODUCTVERSION
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904E4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", VER_COMPANYNAME_STR
|
||||
VALUE "FileDescription", VER_FILEDESCRIPTION_STR
|
||||
VALUE "FileVersion", VER_FILEVERSION_STR
|
||||
VALUE "InternalName", VER_INTERNALNAME_STR
|
||||
VALUE "LegalCopyright", VER_LEGALCOPYRIGHT_STR
|
||||
VALUE "LegalTrademarks1", VER_LEGALTRADEMARKS1_STR
|
||||
VALUE "LegalTrademarks2", VER_LEGALTRADEMARKS2_STR
|
||||
VALUE "OriginalFilename", VER_ORIGINALFILENAME_STR
|
||||
VALUE "ProductName", VER_PRODUCTNAME_STR
|
||||
VALUE "ProductVersion", VER_PRODUCTVERSION_STR
|
||||
END
|
||||
END
|
||||
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
END
|
||||
END
|
||||
|
||||
@ -322,7 +322,21 @@ bool CImageFileFormatChecker::isSvmFile(BYTE* pBuffer,DWORD dwBytes)
|
||||
|
||||
return false;
|
||||
}
|
||||
bool CImageFileFormatChecker::isSvgFile(BYTE* pBuffer,DWORD dwBytes)
|
||||
{
|
||||
if (eFileType)return false;
|
||||
|
||||
if ( (6 <= dwBytes) &&(0x3C == pBuffer[0] && 0x3F == pBuffer[1] && 0x78 == pBuffer[2] && 0x6D == pBuffer[3]
|
||||
&& 0x6C == pBuffer[4] && 0x20 == pBuffer[5]))
|
||||
{
|
||||
std::string sXml_part = std::string((char*)pBuffer, dwBytes);
|
||||
if (sXml_part.find(std::string("svg")) != std::string::npos)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CImageFileFormatChecker::isJ2kFile(BYTE* pBuffer,DWORD dwBytes)
|
||||
{
|
||||
@ -602,6 +616,7 @@ std::wstring CImageFileFormatChecker::DetectFormatByData(BYTE *Data, int DataSiz
|
||||
else if (isTiffFile(Data,DataSize))return L"tif";
|
||||
else if (isWmfFile(Data,DataSize)) return L"wmf";
|
||||
else if (isSvmFile(Data,DataSize)) return L"svm";
|
||||
else if (isSvgFile(Data,DataSize)) return L"svg";
|
||||
|
||||
return L"jpg";
|
||||
return L"";
|
||||
}
|
||||
|
||||
@ -103,6 +103,7 @@ public:
|
||||
bool isMj2File(BYTE* pBuffer,DWORD dwBytes);
|
||||
bool isIpodFile(BYTE* pBuffer,DWORD dwBytes);
|
||||
bool isPgxFile(BYTE* pBuffer,DWORD dwBytes);
|
||||
bool isSvgFile(BYTE* pBuffer,DWORD dwBytes);
|
||||
|
||||
std::wstring DetectFormatByData(BYTE *Data, int DataSize);
|
||||
|
||||
|
||||
7
Makefile
7
Makefile
@ -104,7 +104,7 @@ TARGETS += $(VIDEOPLAYERLIB)
|
||||
X2T_PRO := $(abspath X2tConverter/build/Qt/X2tSLN.pro)
|
||||
HTMLFILEINTERNAL_PRO := $(abspath ../desktop-sdk/HtmlFile/Internal/Internal.pro)
|
||||
ALLFONTSGEN_PRO := $(abspath DesktopEditor/AllFontsGen/AllFontsGen.pro)
|
||||
DOCBUILDER_PRO := $(abspath ../core-ext/docbuilder/test_builder/docbuilder.pro)
|
||||
DOCBUILDER_PRO := $(abspath DesktopEditor/doctrenderer/app_builder/docbuilder.pro)
|
||||
PDFWRITER_PRO := $(abspath PdfWriter/PdfWriter.pro)
|
||||
GRAPHICS_PRO := $(abspath DesktopEditor/graphics/pro/graphics.pro)
|
||||
DOCTRENDERER_PRO := $(abspath DesktopEditor/doctrenderer/doctrenderer.pro)
|
||||
@ -120,7 +120,8 @@ OOXMLSIGNATURE_PRO := $(abspath DesktopEditor/xmlsec/src/ooxmlsignature.pro)
|
||||
HUNSPELL_PRO := $(abspath DesktopEditor/hunspell-1.3.3/src/qt/hunspell.pro)
|
||||
KERNEL_PRO := $(abspath Common/kernel.pro)
|
||||
CRYPTOPP_PRO := $(abspath Common/3dParty/cryptopp/project/cryptopp.pro)
|
||||
VIDEOPLAYERLIB_PRO := $(abspath ../core-ext/multimedia/videoplayer/lib/VideoPlayerLib.pro)
|
||||
#VIDEOPLAYERLIB_PRO := $(abspath ../core-ext/multimedia/videoplayer/lib/VideoPlayerLib.pro)
|
||||
VIDEOPLAYERLIB_PRO := $(abspath ../desktop-sdk/ChromiumBasedEditors/videoplayerlib/videoplayerlib.pro)
|
||||
|
||||
# PROS += $(basename $(X2T_PRO)).build
|
||||
# PROS += ALLFONTSGEN_PRO
|
||||
@ -270,7 +271,7 @@ all: $(CORE_TARGET)
|
||||
|
||||
ext: $(EXT_TARGET)
|
||||
|
||||
desktop: $(ASCDOCUMENTSCORE)
|
||||
desktop: $(ASCDOCUMENTSCORE) $(VIDEOPLAYERLIB)
|
||||
|
||||
video: $(VIDEOPLAYERLIB)
|
||||
|
||||
|
||||
@ -1546,14 +1546,16 @@ PdfWriter::CImageDict* CPdfRenderer::LoadImage(Aggplus::CImage* pImage, const BY
|
||||
|
||||
::memcpy(pCopyImage, pData, 4 * nImageW * nImageH);
|
||||
|
||||
BYTE* pDataMem = pCopyImage;
|
||||
for (int nIndex = 0, nSize = nImageW * nImageH; nIndex < nSize; nIndex++)
|
||||
{
|
||||
if (pCopyImage[4 * nIndex + 3] < 32)
|
||||
if (pDataMem[3] < 32)
|
||||
{
|
||||
pCopyImage[4 * nIndex + 0] = 255;
|
||||
pCopyImage[4 * nIndex + 1] = 255;
|
||||
pCopyImage[4 * nIndex + 2] = 255;
|
||||
pDataMem[0] = 255;
|
||||
pDataMem[1] = 255;
|
||||
pDataMem[2] = 255;
|
||||
}
|
||||
pDataMem += 4;
|
||||
}
|
||||
|
||||
oFrame.put_Width(nImageW);
|
||||
@ -1563,13 +1565,23 @@ PdfWriter::CImageDict* CPdfRenderer::LoadImage(Aggplus::CImage* pImage, const BY
|
||||
}
|
||||
else
|
||||
{
|
||||
BYTE* pDataMem = pData;
|
||||
for (int nIndex = 0, nSize = nImageW * nImageH; nIndex < nSize; nIndex++)
|
||||
{
|
||||
if (pData[4 * nIndex + 3] < 255)
|
||||
// making full-transparent pixels white
|
||||
if (pDataMem[3] == 0)
|
||||
{
|
||||
pDataMem[0] = 255;
|
||||
pDataMem[1] = 255;
|
||||
pDataMem[2] = 255;
|
||||
}
|
||||
|
||||
if (!bAlpha && (pDataMem[3] < 255))
|
||||
{
|
||||
bAlpha = true;
|
||||
break;
|
||||
bAlpha = true;
|
||||
}
|
||||
|
||||
pDataMem += 4;
|
||||
}
|
||||
oFrame.FromImage(pImage);
|
||||
}
|
||||
|
||||
@ -2998,7 +2998,7 @@ void BinaryWorksheetTableWriter::WriteCell(const OOX::Spreadsheet::CCell& oCell)
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
}
|
||||
//Value
|
||||
if(oCell.m_oValue.IsInit())
|
||||
if(oCell.m_oValue.IsInit() && !oCell.m_oValue->ToString().empty())
|
||||
{
|
||||
|
||||
double dValue = 0;
|
||||
|
||||
Reference in New Issue
Block a user