mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
Merge remote-tracking branch 'origin/hotfix/v8.1.1' into develop
This commit is contained in:
@ -109,7 +109,7 @@ FT_Error FT_Load_Glyph_Wrapper( FT_Face face,
|
||||
FT_Err_Invalid_Reference = 0x86;
|
||||
*/
|
||||
|
||||
if ((bHintsSupport == TRUE) && (nErr > 0x10 && nErr < 0x28 || nErr == 0x83 || nErr == 0x86))
|
||||
if ((bHintsSupport == TRUE) && ((nErr > 0x10 && nErr < 0x28) || nErr == 0x83 || nErr == 0x86))
|
||||
{
|
||||
int nErr2 = FT_Load_Glyph(face, glyph_index, 40970);
|
||||
|
||||
|
||||
@ -152,6 +152,7 @@ public:
|
||||
ShapeEnd = 8,
|
||||
PageClear = 9,
|
||||
PageRotate = 10,
|
||||
Headings = 11,
|
||||
|
||||
Undefined = 255
|
||||
};
|
||||
|
||||
@ -929,6 +929,7 @@ namespace NSOnlineOfficeBinToPdf
|
||||
case ctShapeEnd:
|
||||
case ctPageClear:
|
||||
case ctPageRotate:
|
||||
case ctHeadings:
|
||||
{
|
||||
IAdvancedCommand::AdvancedCommandType eAdvancedCommandType = IAdvancedCommand::AdvancedCommandType::Undefined;
|
||||
switch (eCommand)
|
||||
@ -941,6 +942,7 @@ namespace NSOnlineOfficeBinToPdf
|
||||
case ctShapeEnd: eAdvancedCommandType = IAdvancedCommand::AdvancedCommandType::ShapeEnd; break;
|
||||
case ctPageClear: eAdvancedCommandType = IAdvancedCommand::AdvancedCommandType::PageClear; break;
|
||||
case ctPageRotate: eAdvancedCommandType = IAdvancedCommand::AdvancedCommandType::PageRotate; break;
|
||||
case ctHeadings: eAdvancedCommandType = IAdvancedCommand::AdvancedCommandType::Headings; break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -1264,6 +1266,7 @@ namespace NSOnlineOfficeBinToPdf
|
||||
case ctShapeStart:
|
||||
case ctShapeEnd:
|
||||
case ctPageRotate:
|
||||
case ctHeadings:
|
||||
default:
|
||||
{
|
||||
BYTE* cur = oReader.GetCurrentBuffer();
|
||||
|
||||
@ -185,6 +185,7 @@ namespace NSOnlineOfficeBinToPdf
|
||||
ctWidgetsInfo = 166,
|
||||
ctShapeStart = 167,
|
||||
ctShapeEnd = 168,
|
||||
ctHeadings = 169,
|
||||
|
||||
ctPageWidth = 200,
|
||||
ctPageHeight = 201,
|
||||
|
||||
@ -62,6 +62,7 @@ namespace NSOnlineOfficeBinToPdf
|
||||
case ctShapeEnd: return new CEmptyComand(IAdvancedCommand::AdvancedCommandType::ShapeEnd);
|
||||
case ctPageClear: return new CEmptyComand(IAdvancedCommand::AdvancedCommandType::PageClear);
|
||||
case ctPageRotate: return Read_Command<CPageRotate> (this, pCorrector);
|
||||
case ctHeadings: return Read_Command<CHeadings> (this, pCorrector);
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
||||
@ -164,3 +164,24 @@ bool CPageRotate::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafile
|
||||
return true;
|
||||
}
|
||||
|
||||
CHeadings::CHeadings() : IAdvancedCommand(AdvancedCommandType::Headings) {}
|
||||
const std::vector<CHeadings::CHeading>& CHeadings::GetHeading() { return m_arrHeading; }
|
||||
bool CHeadings::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector)
|
||||
{
|
||||
int nHeadings = pReader->ReadInt();
|
||||
for (int i = 0; i < nHeadings; ++i)
|
||||
m_arrHeading.push_back(ReadHeading(pReader));
|
||||
return true;
|
||||
}
|
||||
CHeadings::CHeading CHeadings::ReadHeading(NSOnlineOfficeBinToPdf::CBufferReader* pReader)
|
||||
{
|
||||
CHeading oHeading;
|
||||
oHeading.wsTitle = pReader->ReadString();
|
||||
oHeading.nPage = pReader->ReadInt();
|
||||
oHeading.dX = pReader->ReadDouble();
|
||||
oHeading.dY = pReader->ReadDouble();
|
||||
int nHeadings = pReader->ReadInt();
|
||||
for (int i = 0; i < nHeadings; ++i)
|
||||
oHeading.arrHeading.push_back(ReadHeading(pReader));
|
||||
return oHeading;
|
||||
}
|
||||
|
||||
@ -170,5 +170,29 @@ private:
|
||||
int m_nPageRotate;
|
||||
};
|
||||
|
||||
class GRAPHICS_DECL CHeadings : public IAdvancedCommand
|
||||
{
|
||||
public:
|
||||
struct CHeading
|
||||
{
|
||||
std::wstring wsTitle;
|
||||
int nPage;
|
||||
double dX;
|
||||
double dY;
|
||||
std::vector<CHeading> arrHeading;
|
||||
};
|
||||
|
||||
CHeadings();
|
||||
|
||||
bool Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector);
|
||||
|
||||
const std::vector<CHeading>& GetHeading();
|
||||
|
||||
private:
|
||||
std::vector<CHeading> m_arrHeading;
|
||||
|
||||
CHeading ReadHeading(NSOnlineOfficeBinToPdf::CBufferReader* pReader);
|
||||
};
|
||||
|
||||
|
||||
#endif // _BUILD_DOCINFO_H_
|
||||
|
||||
@ -149,6 +149,7 @@ HRESULT CPdfWriter::EditWidgetParents(NSFonts::IApplicationFonts* pAppFonts, CWi
|
||||
PdfWriter::CDocument* CPdfWriter::GetDocument() { return NULL; }
|
||||
PdfWriter::CPage* CPdfWriter::GetPage() { return NULL; }
|
||||
void CPdfWriter::AddFont(const std::wstring& wsFontName, const bool& bBold, const bool& bItalic, const std::wstring& wsFontPath, const LONG& lFaceIndex) {}
|
||||
void CPdfWriter::SetHeadings(CHeadings* pCommand) {}
|
||||
PdfWriter::CImageDict* CPdfWriter::LoadImage(Aggplus::CImage* pImage, BYTE nAlpha) { return NULL; }
|
||||
PdfWriter::CImageDict* CPdfWriter::DrawImage(Aggplus::CImage* pImage, const double& dX, const double& dY, const double& dW, const double& dH, const BYTE& nAlpha) { return NULL; }
|
||||
bool CPdfWriter::DrawText(unsigned char* pCodes, const unsigned int& unLen, const double& dX, const double& dY) { return false; }
|
||||
|
||||
@ -207,12 +207,14 @@ int FDB::serialize(std::wostream & strm, bool bSql, bool bDBB)
|
||||
if (m_SXVDTEx)
|
||||
{
|
||||
SXVDTEx *olap_info = dynamic_cast<SXVDTEx*>(m_SXVDTEx.get());
|
||||
if ((olap_info) && (olap_info->isxth >= 0))
|
||||
if ((olap_info) && (olap_info->isxth >= 0) && (olap_info->isxth < m_arPIVOTTH.size()))
|
||||
{
|
||||
PIVOTTH* ht = dynamic_cast<PIVOTTH*>(m_arPIVOTTH[olap_info->isxth].get());
|
||||
SXTH* sxTH = dynamic_cast<SXTH*>(ht->m_SXTH.get());
|
||||
|
||||
CP_XML_ATTR(L"caption", sxTH->stDisplay.value());
|
||||
SXTH* sxTH = ht ? dynamic_cast<SXTH*>(ht->m_SXTH.get()) : NULL;
|
||||
if (sxTH)
|
||||
{
|
||||
CP_XML_ATTR(L"caption", sxTH->stDisplay.value());
|
||||
}
|
||||
|
||||
CP_XML_ATTR(L"hierarchy", olap_info->isxth);
|
||||
CP_XML_ATTR(L"level", olap_info->isxtl);
|
||||
@ -333,7 +335,8 @@ int FDB::serialize(std::wostream & strm, bool bSql, bool bDBB)
|
||||
|
||||
for (size_t i = 0; i < m_arSRCSXOPER.size(); i++)
|
||||
{
|
||||
m_arSRCSXOPER[i]->serialize(CP_XML_STREAM());
|
||||
if (m_arSRCSXOPER[i])
|
||||
m_arSRCSXOPER[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -352,12 +355,16 @@ int FDB::serialize(std::wostream & strm, bool bSql, bool bDBB)
|
||||
|
||||
if (m_SXRANGE)
|
||||
m_SXRANGE->serialize(CP_XML_STREAM());
|
||||
|
||||
CP_XML_NODE(L"groupItems")
|
||||
{
|
||||
CP_XML_ATTR(L"count", m_arGRPSXOPER.size());
|
||||
for (size_t i = 0; i < m_arGRPSXOPER.size(); i++)
|
||||
{
|
||||
m_arGRPSXOPER[i]->serialize(CP_XML_STREAM());
|
||||
if (m_arGRPSXOPER[i])
|
||||
{
|
||||
m_arGRPSXOPER[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -382,6 +389,8 @@ int FDB::serialize_record(std::wostream & strm)
|
||||
for (size_t i = 0; i < m_arSRCSXOPER.size(); i++)
|
||||
{
|
||||
SXOPER* oper = dynamic_cast<SXOPER*>(m_arSRCSXOPER[i].get());
|
||||
if (!oper) continue;
|
||||
|
||||
oper->serialize_record(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
|
||||
@ -423,19 +423,20 @@ void odf_number_styles_context::create_number_style(number_format_state & state,
|
||||
create_numbers(state, elm, root_elm);
|
||||
}
|
||||
}
|
||||
void odf_number_styles_context::create_numbers(number_format_state & state, office_element_ptr & elm, office_element_ptr & root_elm)
|
||||
void odf_number_styles_context::create_numbers(number_format_state& state, office_element_ptr& elm, office_element_ptr& root_elm)
|
||||
{
|
||||
_CP_OPT(int) min_digit, min_decimal;
|
||||
_CP_OPT(int) separate;
|
||||
|
||||
switch(state.ods_type)
|
||||
switch (state.ods_type)
|
||||
{
|
||||
case office_value_type::Currency:
|
||||
case office_value_type::Percentage:
|
||||
case office_value_type::Float: create_element(L"number", L"number", elm, odf_context_); break;
|
||||
case office_value_type::Scientific: create_element(L"number", L"scientific-number", elm, odf_context_); break;
|
||||
case office_value_type::Fraction: create_element(L"number", L"fraction", elm, odf_context_); break;
|
||||
case office_value_type::Currency:
|
||||
case office_value_type::Percentage:
|
||||
case office_value_type::Float: create_element(L"number", L"number", elm, odf_context_); break;
|
||||
case office_value_type::Scientific: create_element(L"number", L"scientific-number", elm, odf_context_); break;
|
||||
case office_value_type::Fraction: create_element(L"number", L"fraction", elm, odf_context_); break;
|
||||
}
|
||||
|
||||
|
||||
office_element_ptr elm_text;
|
||||
|
||||
bool bText = false;
|
||||
@ -473,74 +474,90 @@ void odf_number_styles_context::create_numbers(number_format_state & state, offi
|
||||
if (indNumber < 0)
|
||||
indNumber = 0;
|
||||
|
||||
std::wstring str1,str2;
|
||||
boost::wregex re1(L"([^0-9.,]+)");
|
||||
boost::wsmatch result;
|
||||
boost::wregex re2(L"([^#.,]+)");
|
||||
|
||||
// split by space, find #0 - use it ... ????
|
||||
std::wstring str1;
|
||||
boost::wregex re1(L"([^#0.,]+)");
|
||||
|
||||
str1 = boost::regex_replace(splits[indNumber], re1, L"", boost::match_default | boost::format_all);
|
||||
str2 = boost::regex_replace(splits[indNumber], re2, L"", boost::match_default | boost::format_all);
|
||||
|
||||
if (str1.length() < str2.length()) str1 = str2;
|
||||
size_t pos_separate_1000 = str1.find(L",");
|
||||
size_t pos_separate_decimal = str1.find(L".");
|
||||
|
||||
std::vector<std::wstring> numbers;
|
||||
boost::algorithm::split(numbers, str1, boost::algorithm::is_any_of(L".,"), boost::algorithm::token_compress_on);
|
||||
|
||||
int ind = 1;//
|
||||
for (size_t i = 0; i < numbers.size(); i++)
|
||||
if (pos_separate_decimal != std::wstring::npos)
|
||||
{
|
||||
if (numbers[i].empty())continue;
|
||||
std::wstring str2;
|
||||
boost::wregex re2(L"([^0]+)");
|
||||
|
||||
if (ind == 1) min_digit = numbers[i].length();
|
||||
if (ind == 2) min_decimal = numbers[i].length();
|
||||
ind++;
|
||||
str2 = boost::regex_replace(str1.substr(pos_separate_decimal), re2, L"", boost::match_default | boost::format_all);
|
||||
|
||||
if (false == str2.empty())
|
||||
min_decimal = str2.length();
|
||||
|
||||
str1 = str1.substr(0, pos_separate_decimal);
|
||||
}
|
||||
else
|
||||
{
|
||||
min_decimal = 0;
|
||||
}
|
||||
{
|
||||
std::wstring str2;
|
||||
boost::wregex re2(L"([^0]+)");
|
||||
|
||||
str2 = boost::regex_replace(str1, re2, L"", boost::match_default | boost::format_all);
|
||||
|
||||
if (false == str2.empty())
|
||||
min_digit = str2.length();
|
||||
}
|
||||
if (pos_separate_1000 != std::wstring::npos)
|
||||
{
|
||||
separate = str1.length() - pos_separate_1000 - 1;
|
||||
}
|
||||
|
||||
if (bText && root_elm)
|
||||
{
|
||||
int res1 = (int) splits[indText].find(L"\"");
|
||||
int res2 = (int) splits[indText].find(L"\"", res1 + 1);
|
||||
int res1 = (int)splits[indText].find(L"\"");
|
||||
int res2 = (int)splits[indText].find(L"\"", res1 + 1);
|
||||
|
||||
if (res2 > 0)
|
||||
{
|
||||
std::wstring text = splits[indText].substr(res1 + 1, res2 - res1 - 1);
|
||||
|
||||
if (!text.empty())
|
||||
{
|
||||
{
|
||||
if (indText < indNumber) text = text + L" ";
|
||||
else text = L" " + text;
|
||||
|
||||
create_element(L"number", L"text", elm_text, odf_context_);
|
||||
number_text* number_text_ = dynamic_cast<number_text*>(elm_text.get());
|
||||
|
||||
|
||||
if (number_text_)
|
||||
number_text_->add_text(text);
|
||||
number_text_->add_text(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
number_number* number_ = dynamic_cast<number_number*>(elm.get());
|
||||
if (number_)
|
||||
{
|
||||
number_->number_min_integer_digits_ = min_digit;
|
||||
number_->number_decimal_places_ = min_digit ? min_decimal.get_value_or(0) : min_decimal;
|
||||
number_->number_min_integer_digits_ = min_digit;
|
||||
number_->number_decimal_places_ = min_decimal.get_value_or(0);
|
||||
|
||||
if (root_elm && bText)
|
||||
if (separate)
|
||||
number_->number_grouping_ = true;
|
||||
}
|
||||
number_scientific_number* scientific_ = dynamic_cast<number_scientific_number*>(elm.get());
|
||||
if (scientific_)
|
||||
{
|
||||
scientific_->number_min_integer_digits_ = min_digit;
|
||||
scientific_->number_decimal_places_ = min_decimal;
|
||||
scientific_->number_min_exponent_digits_= min_digit;
|
||||
scientific_->number_min_decimal_places_ = min_decimal;
|
||||
scientific_->number_min_integer_digits_ = min_digit;
|
||||
scientific_->number_decimal_places_ = min_decimal;
|
||||
scientific_->number_min_exponent_digits_ = min_digit;
|
||||
scientific_->number_min_decimal_places_ = min_decimal;
|
||||
scientific_->number_forced_exponent_sign_ = true;
|
||||
|
||||
if (root_elm && bText)
|
||||
|
||||
if (separate)
|
||||
scientific_->number_grouping_ = true;
|
||||
}
|
||||
}
|
||||
number_fraction* fraction_ = dynamic_cast<number_fraction*>(elm.get());
|
||||
if (fraction_)
|
||||
{
|
||||
@ -548,7 +565,7 @@ void odf_number_styles_context::create_numbers(number_format_state & state, offi
|
||||
fraction_->number_min_numerator_digits_ = min_digit;
|
||||
fraction_->number_min_denominator_digits_ = min_digit;
|
||||
|
||||
if (root_elm && bText)
|
||||
if (separate)
|
||||
fraction_->number_grouping_ = true;
|
||||
}
|
||||
if (root_elm)
|
||||
|
||||
@ -1182,6 +1182,7 @@ HRESULT CPdfFile::IsSupportAdvancedCommand(const IAdvancedCommand::AdvancedComma
|
||||
case IAdvancedCommand::AdvancedCommandType::ShapeEnd:
|
||||
case IAdvancedCommand::AdvancedCommandType::PageClear:
|
||||
case IAdvancedCommand::AdvancedCommandType::PageRotate:
|
||||
case IAdvancedCommand::AdvancedCommandType::Headings:
|
||||
return S_OK;
|
||||
default:
|
||||
break;
|
||||
@ -1273,6 +1274,11 @@ HRESULT CPdfFile::AdvancedCommand(IAdvancedCommand* command)
|
||||
m_pInternal->pWriter->PageRotate(pCommand->GetPageRotate());
|
||||
return S_OK;
|
||||
}
|
||||
case IAdvancedCommand::AdvancedCommandType::Headings:
|
||||
{
|
||||
m_pInternal->pWriter->SetHeadings((CHeadings*)command);
|
||||
return S_OK;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@ -43,6 +43,7 @@
|
||||
#include "SrcWriter/Font14.h"
|
||||
#include "SrcWriter/Destination.h"
|
||||
#include "SrcWriter/Field.h"
|
||||
#include "SrcWriter/Outline.h"
|
||||
|
||||
#include "../DesktopEditor/graphics/Image.h"
|
||||
#include "../DesktopEditor/graphics/structures.h"
|
||||
@ -2443,6 +2444,29 @@ HRESULT CPdfWriter::AddMetaData(const std::wstring& sMetaName, BYTE* pMetaData,
|
||||
{
|
||||
return m_pDocument->AddMetaData(sMetaName, pMetaData, nMetaLength) ? S_OK : S_FALSE;
|
||||
}
|
||||
void CreateOutlines(PdfWriter::CDocument* m_pDocument, const std::vector<CHeadings::CHeading>& arrHeadings, PdfWriter::COutline* pParent)
|
||||
{
|
||||
for (int i = 0; i < arrHeadings.size(); ++i)
|
||||
{
|
||||
std::string sTitle = U_TO_UTF8(arrHeadings[i].wsTitle);
|
||||
PdfWriter::COutline* pOutline = m_pDocument->CreateOutline(pParent, sTitle.c_str());
|
||||
PdfWriter::CPage* pPageD = m_pDocument->GetPage(arrHeadings[i].nPage);
|
||||
PdfWriter::CDestination* pDest = m_pDocument->CreateDestination(pPageD);
|
||||
if (pDest)
|
||||
{
|
||||
pOutline->SetDestination(pDest);
|
||||
pDest->SetXYZ(arrHeadings[i].dX, arrHeadings[i].dY, 0);
|
||||
}
|
||||
CreateOutlines(m_pDocument, arrHeadings[i].arrHeading, pOutline);
|
||||
}
|
||||
}
|
||||
void CPdfWriter::SetHeadings(CHeadings* pCommand)
|
||||
{
|
||||
if (!m_pDocument || !pCommand)
|
||||
return;
|
||||
|
||||
CreateOutlines(m_pDocument, pCommand->GetHeading(), NULL);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------
|
||||
// Дополнительные функции Pdf рендерера
|
||||
//----------------------------------------------------------------------------------------
|
||||
@ -2796,6 +2820,7 @@ PdfWriter::CImageDict* CPdfWriter::LoadImage(Aggplus::CImage* pImage, BYTE nAlph
|
||||
bool bAlpha = false;
|
||||
|
||||
CBgraFrame oFrame;
|
||||
/*
|
||||
if (m_pDocument->IsPDFA())
|
||||
{
|
||||
BYTE* pCopyImage = new BYTE[4 * nImageW * nImageH];
|
||||
@ -2822,6 +2847,7 @@ PdfWriter::CImageDict* CPdfWriter::LoadImage(Aggplus::CImage* pImage, BYTE nAlph
|
||||
oFrame.put_Stride(-4* nImageW);
|
||||
}
|
||||
else
|
||||
*/
|
||||
{
|
||||
BYTE* pDataMem = pData;
|
||||
for (int nIndex = 0, nSize = nImageW * nImageH; nIndex < nSize; nIndex++)
|
||||
|
||||
@ -40,6 +40,7 @@
|
||||
#include "../../DesktopEditor/graphics/pro/Fonts.h"
|
||||
#include "../../DesktopEditor/graphics/pro/Image.h"
|
||||
#include "../../DesktopEditor/graphics/commands/FormField.h"
|
||||
#include "../../DesktopEditor/graphics/commands/DocInfo.h"
|
||||
#include "../../DesktopEditor/graphics/commands/AnnotField.h"
|
||||
#include "../../DesktopEditor/xmlsec/src/include/Certificate.h"
|
||||
#include "SrcWriter/States.h"
|
||||
@ -217,6 +218,7 @@ public:
|
||||
PdfWriter::CDocument* GetDocument();
|
||||
PdfWriter::CPage* GetPage();
|
||||
void AddFont(const std::wstring& wsFontName, const bool& bBold, const bool& bItalic, const std::wstring& wsFontPath, const LONG& lFaceIndex);
|
||||
void SetHeadings(CHeadings* pCommand);
|
||||
|
||||
private:
|
||||
PdfWriter::CImageDict* LoadImage(Aggplus::CImage* pImage, BYTE nAlpha);
|
||||
|
||||
@ -289,9 +289,6 @@ namespace PdfWriter
|
||||
}
|
||||
void CImageDict::LoadSMask(const BYTE* pBgra, unsigned int unWidth, unsigned int unHeight, unsigned char unAlpha, bool bVerFlip)
|
||||
{
|
||||
if (m_pDocument->IsPDFA())
|
||||
return;
|
||||
|
||||
CMemoryStream* pStream = new CMemoryStream(unWidth * unHeight);
|
||||
if (!pStream)
|
||||
return;
|
||||
|
||||
@ -48,7 +48,7 @@ namespace PdfWriter
|
||||
pOpenFlag->SetHidden();
|
||||
|
||||
Add("_OPENED", pOpenFlag);
|
||||
Add("Type", "Outline");
|
||||
Add("Type", "Outlines");
|
||||
}
|
||||
COutline::COutline(COutline* pParent, const char* sTitle, CXref* pXref)
|
||||
{
|
||||
@ -172,4 +172,4 @@ namespace PdfWriter
|
||||
else
|
||||
pNumber->Set(bOpened ? OUTLINE_OPENED : OUTLINE_CLOSED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user