Compare commits

..

13 Commits

20 changed files with 503 additions and 39 deletions

View File

@ -1,6 +1,7 @@
#include "BooleanOperations.h"
#include "boolean_operations_math.h"
#include <algorithm>
#include <iterator>
namespace Aggplus {
Segment::Segment() noexcept
@ -1116,7 +1117,7 @@ void CBooleanOperations::PreparePath(const CGraphicsPath& path, int id,
curves.push_back(Curve(segments[i], i == (length - 1) ? segments[0] : segments[i + 1]));
}
void CBooleanOperations::InsertSegment(const Segment& segment, const Segment& handles, bool updateHandles)
void CBooleanOperations::InsertSegment(Segment& segment, const Segment& handles, bool updateHandles)
{
if (segment.Id == 1)
{
@ -1124,6 +1125,7 @@ void CBooleanOperations::InsertSegment(const Segment& segment, const Segment& ha
index = segment.Index == length ? 0 : segment.Index;
if (getDistance(segment.P, Segments1[index].P) <= GEOMETRIC_EPSILON)
{
segment.Index = index;
Segments1[index] = segment;
return;
}
@ -1147,6 +1149,7 @@ void CBooleanOperations::InsertSegment(const Segment& segment, const Segment& ha
index = segment.Index == length ? 0 : segment.Index;
if (getDistance(segment.P, Segments2[index].P) <= GEOMETRIC_EPSILON)
{
segment.Index = index;
Segments2[index] = segment;
return;
}
@ -1261,7 +1264,8 @@ std::vector<std::vector<int>> CBooleanOperations::FindBoundsCollisions()
std::vector<std::vector<double>> allBounds(bounds1);
if (!self)
std::copy(bounds2.begin(), bounds2.end(), std::back_inserter(allBounds));
for (auto it = bounds2.begin(); it != bounds2.end(); ++it) // std::copy(bounds2.begin(), bounds2.end(), std::back_inserter(allBounds));
allBounds.push_back(*it);
int allLength = static_cast<int>(allBounds.size()),
length1 = static_cast<int>(bounds1.size());

View File

@ -120,7 +120,7 @@ namespace Aggplus
// Path
void PreparePath(const CGraphicsPath& path, int id, std::vector<Segment>& segments,
std::vector<Curve>& curves, bool reverse = false);
void InsertSegment(const Segment& segment, const Segment& handles, bool updateHandles);
void InsertSegment(Segment& segment, const Segment& handles, bool updateHandles);
Curve GetCurve(const Segment& segment) const noexcept;
Curve GetPreviousCurve(const Curve& curve) const noexcept;
Curve GetNextCurve(const Curve& curve) const noexcept;

View File

@ -221,6 +221,7 @@ BYTE* CAnnotFieldInfo::GetRender(LONG& nLen)
}
const std::wstring& CAnnotFieldInfo::GetNM() { return m_wsNM; }
const std::wstring& CAnnotFieldInfo::GetLM() { return m_wsLM; }
const std::wstring& CAnnotFieldInfo::GetOUserID() { return m_wsOUserID; }
const std::wstring& CAnnotFieldInfo::GetContents() { return m_wsContents; }
const std::vector<double>& CAnnotFieldInfo::GetC() { return m_arrC; }
@ -348,6 +349,8 @@ bool CAnnotFieldInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMeta
m_pRender = pReader->GetCurrentBuffer();
pReader->Skip(m_nRenderLen);
}
if (nFlags & (1 << 7))
m_wsOUserID = pReader->ReadString();
if (IsMarkup())
{

View File

@ -414,6 +414,7 @@ public:
BYTE* GetRender(LONG& nLen);
const std::wstring& GetNM();
const std::wstring& GetLM();
const std::wstring& GetOUserID();
const std::wstring& GetContents();
const std::vector<double>& GetC();
@ -466,6 +467,7 @@ private:
int m_nPage;
std::wstring m_wsNM;
std::wstring m_wsLM;
std::wstring m_wsOUserID;
std::wstring m_wsContents;
std::pair<BYTE, double> m_pBE;
std::vector<double> m_arrC;

View File

@ -53,6 +53,8 @@ HEADERS += \
../../../Matrix.h \
../../../Matrix_private.h \
../../../GraphicsPath.h \
../../../BooleanOperations.h \
../../../boolean_operations_math.h \
../../../GraphicsPath_private.h \
../../../AlphaMask.h \
\
@ -105,6 +107,7 @@ HEADERS += \
SOURCES += \
../../../Matrix.cpp \
../../../GraphicsPath.cpp \
../../../BooleanOperations.cpp \
../../../AlphaMask.cpp \
../../../../raster/BgraFrame.cpp \
../../../../raster/ImageFileFormatChecker.cpp \
@ -680,6 +683,7 @@ HEADERS += \
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Paragraph.h \
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Shape.h \
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/TextLine.h \
$$DOCX_RENDERER_ROOT_DIR/src/logic/managers/ExternalImageStorage.h \
$$DOCX_RENDERER_ROOT_DIR/src/logic/managers/FontStyleManager.h \
$$DOCX_RENDERER_ROOT_DIR/src/logic/managers/ImageManager.h \
$$DOCX_RENDERER_ROOT_DIR/src/logic/managers/FontManager.h \

View File

@ -488,7 +488,11 @@ function readAnnot(reader, rec)
// Date of last change - M
if (flags & (1 << 5))
rec["LastModified"] = reader.readString();
// AP
rec["AP"]["have"] = (flags >> 6) & 1;
// User ID
if (flags & (1 << 7))
rec["OUserID"] = reader.readString();
}
function readAnnotAP(reader, AP)
{
@ -1435,6 +1439,43 @@ function fontToMemory(file, isCheck)
Module["_free"](idPointer);
}
// FONTS
CFile.prototype["addPage"] = function(pageIndex, pageObj)
{
this.pages.splice(pageIndex, 0, pageObj);
if (this.fontStreams)
{
for (let i in this.fontStreams)
{
let pages = this.fontStreams[i].pages;
for (let j = 0; j < pages.length; j++)
{
if (pages[j] >= pageIndex)
pages[j] += 1;
}
}
}
};
CFile.prototype["removePage"] = function(pageIndex)
{
let result = this.pages.splice(pageIndex, 1);
if (this.fontStreams)
{
for (let i in this.fontStreams)
{
let pages = this.fontStreams[i].pages;
for (let j = 0; j < pages.length; j++)
{
if (pages[j] > pageIndex)
pages[j] -= 1;
else if (pages[j] == pageIndex)
pages.splice(j, 1);
}
}
}
return result;
};
// ONLY WEB
self["AscViewer"]["Free"] = function(pointer)
{

View File

@ -267,6 +267,13 @@ void ReadAnnot(BYTE* pWidgets, int& i)
std::cout << "YES AP, ";
else
std::cout << "NO AP, ";
if (nFlags & (1 << 7))
{
nPathLength = READ_INT(pWidgets + i);
i += 4;
std::cout << "User ID " << std::string((char*)(pWidgets + i), nPathLength) << ", ";
i += nPathLength;
}
}
void ReadInteractiveForms(BYTE* pWidgets, int& i)
@ -1801,6 +1808,13 @@ int main(int argc, char* argv[])
free(pAnnotAP);
}
if (true)
{
BYTE* pScan = ScanPage(pGrFile, nTestPage, 1);
if (pScan)
free(pScan);
}
Close(pGrFile);
RELEASEARRAYOBJECTS(pFileData);
RELEASEARRAYOBJECTS(pCMapData);

View File

@ -5,7 +5,7 @@
#include "managers/ImageManager.h"
#include "managers/FontStyleManager.h"
#include "managers/ParagraphStyleManager.h"
#include "convert_params.h"
#include "../../convert_params.h"
namespace NSDocxRenderer
{

View File

@ -12,10 +12,6 @@
namespace NSDocxRenderer
{
CVectorGraphics::CVectorGraphics() noexcept
: m_dLeftDefault(std::numeric_limits<double>().max()),
m_dRightDefault(std::numeric_limits<double>().min()),
m_dTopDefault(std::numeric_limits<double>().max()),
m_dBottomDefault(std::numeric_limits<double>().min())
{
ResetBorders();
}
@ -131,10 +127,10 @@ namespace NSDocxRenderer
void CVectorGraphics::ResetBorders() noexcept
{
m_dLeft = m_dLeftDefault;
m_dTop = m_dTopDefault;
m_dRight = m_dRightDefault;
m_dBottom = m_dBottomDefault;
m_dLeft = std::numeric_limits<double>().max();
m_dTop = std::numeric_limits<double>().max();
m_dRight = std::numeric_limits<double>().min();
m_dBottom = std::numeric_limits<double>().min();
}
double CVectorGraphics::GetLeft() const noexcept

View File

@ -90,11 +90,6 @@ namespace NSDocxRenderer
double m_dRight;
double m_dBottom;
const double m_dLeftDefault;
const double m_dTopDefault;
const double m_dRightDefault;
const double m_dBottomDefault;
void ResetBorders() noexcept;
Aggplus::CGraphicsPath GetGraphicsPath() const noexcept;

View File

@ -2040,10 +2040,9 @@ namespace OOX
{
public:
nullable_string m_name;
nullableUintVal m_fmtId;
nullableIntVal m_fmtId;
nullable<OOX::Drawing::COfficeArtExtensionList> m_extLst;
CT_PivotSource();
~CT_PivotSource();

View File

@ -55,14 +55,32 @@ namespace StarMath
if(!pReader->EmptyString())
{
if(pReader->GetLocalType() == TypeElement::newline)
{
m_arEquation.push_back(new CElementSpecialSymbol(pReader->GetLocalType(),pReader->GetTypeConversion()));
{ m_arEquation.push_back(new CElementSpecialSymbol(pReader->GetLocalType(),pReader->GetTypeConversion()));
pReader->ClearReader();
}
CElement* pTempElement = ParseElement(pReader);
if(nullptr != pTempElement)
m_arEquation.push_back(pTempElement);
}
TFormulaSize tSize;
for(CElement* pElement:m_arEquation)
{
if(pElement->GetBaseType() == TypeElement::SpecialSymbol)
{
CElementSpecialSymbol* pSpecial = dynamic_cast<CElementSpecialSymbol*>(pElement);
if(pSpecial->GetType() == TypeElement::newline)
{
m_qSize.push(tSize);
tSize.Zeroing();
}
else
ComparisonByHeight(tSize,pElement->GetSize());
}
else
ComparisonByHeight(tSize,pElement->GetSize());
}
if(tSize.m_iHeight != 0 && tSize.m_iWidth != 0)
m_qSize.push(tSize);
return m_arEquation;
}
@ -275,6 +293,24 @@ namespace StarMath
CElement* pTempElement = ParseElement(pReader);
AddingAnElementToAnArray(arElements,pTempElement,pReader);
}
std::queue<TFormulaSize> CParserStarMathString::GetFormulaSize()
{
return m_qSize;
}
void CParserStarMathString::ComparisonByHeight(TFormulaSize &tLeftSize, const TFormulaSize &tRightSize)
{
if(tLeftSize.m_iHeight < tRightSize.m_iHeight)
tLeftSize.m_iHeight = tRightSize.m_iHeight;
if(tRightSize.m_iWidth != 0)
tLeftSize.m_iWidth += tRightSize.m_iWidth;
}
void CParserStarMathString::ComparisonByWidth(TFormulaSize &tLeftSize, const TFormulaSize &tRightSize)
{
if(tRightSize.m_iHeight != 0)
tLeftSize.m_iHeight += tRightSize.m_iHeight;
if(tLeftSize.m_iWidth < tRightSize.m_iWidth)
tLeftSize.m_iWidth = tRightSize.m_iWidth;
}
//class methods CAttribute
CAttribute::CAttribute(): m_bBold(false),m_bItal(false),m_bPhantom(false),m_bStrike(false),m_bParent(false),m_iSize(0),m_iAlignment(0),m_unCount(0)
{
@ -878,6 +914,16 @@ namespace StarMath
{
SetBaseAttribute(pAttribute);
}
TFormulaSize CElementString::GetSize()
{
TFormulaSize tSize;
if(!m_wsString.empty())
{
tSize.m_iHeight = 1;
tSize.m_iWidth = m_wsString.size();
}
return tSize;
}
//class methods CElementBinOperator
CElementBinOperator::CElementBinOperator(const TypeElement& enType,const TypeConversion &enTypeConversion)
:CElement(TypeElement::BinOperator,enTypeConversion),m_pLeftArgument(nullptr) , m_pRightArgument(nullptr),m_enTypeBinOp(enType)
@ -1114,6 +1160,29 @@ namespace StarMath
{
return m_enTypeBinOp;
}
TFormulaSize CElementBinOperator::GetSize()
{
TFormulaSize tSize;
if(m_pLeftArgument != nullptr)
tSize = m_pLeftArgument->GetSize();
switch(m_enTypeBinOp)
{
case TypeElement::over:
case TypeElement::wideslash:
case TypeElement::frac:
{
if(m_pRightArgument!= nullptr)
CParserStarMathString::ComparisonByWidth(tSize,m_pRightArgument->GetSize());
tSize.m_iHeight += 1;
return tSize;
}
default:
if(m_pRightArgument != nullptr)
CParserStarMathString::ComparisonByHeight(tSize,m_pRightArgument->GetSize());
tSize.m_iWidth+= 1;
return tSize;
}
}
//class methods CElementBracket
CElementBracket::CElementBracket(const TypeElement& enType,const TypeConversion &enTypeConversion,const bool& bScalability)
:CElement(TypeElement::Bracket,enTypeConversion),m_enTypeBracket(enType),m_bScalability(bScalability)
@ -1327,6 +1396,94 @@ namespace StarMath
return L"";
}
}
TFormulaSize CElementBracket::GetSize()
{
TFormulaSize tSize;
std::vector<TFormulaSize> arSizeLine;
std::vector<TFormulaSize> arSizeColumn;
for(CElement* pElement:m_arBrecketValue)
{
if(pElement != nullptr)
{
if(pElement->GetBaseType() == TypeElement::SpecialSymbol)
{
CElementSpecialSymbol* pSpecial = dynamic_cast<CElementSpecialSymbol*>(pElement);
if(pSpecial->GetType() == TypeElement::grid)
{
arSizeLine.push_back(tSize);
tSize.Zeroing();
}
else if(pSpecial->GetType() == TypeElement::transition)
{
arSizeLine.push_back(tSize);
tSize.Zeroing();
for(TFormulaSize tTempSize:arSizeLine)
CParserStarMathString::ComparisonByHeight(tSize,tTempSize);
tSize.m_iWidth += 0.5;
arSizeColumn.push_back(tSize);
arSizeLine.clear();
tSize.Zeroing();
}
else
CParserStarMathString::ComparisonByHeight(tSize,pElement->GetSize());
}
else
CParserStarMathString::ComparisonByHeight(tSize,pElement->GetSize());
}
}
if(tSize.m_iHeight != 0 && tSize.m_iWidth != 0 )
{
if(!arSizeLine.empty())
{
arSizeLine.push_back(tSize);
tSize.Zeroing();
if(!arSizeColumn.empty())
{
for(int i = 0 ; i < arSizeLine.size();i++)
{
CParserStarMathString::ComparisonByHeight(tSize,arSizeLine[i]);
if(i != 0)
tSize.m_iWidth += 1;
}
arSizeLine.clear();
arSizeColumn.push_back(tSize);
tSize.Zeroing();
for(int i = 0;i < arSizeColumn.size();i++)
{
CParserStarMathString::ComparisonByWidth(tSize,arSizeColumn[i]);
if(i != 0)
tSize.m_iHeight += 0.5;
}
arSizeColumn.clear();
}
else
{
for(int i = 0;i < arSizeLine.size();i++)
{
CParserStarMathString::ComparisonByWidth(tSize,arSizeLine[i]);
if(i != 0)
tSize.m_iHeight += 0.5;
}
arSizeLine.clear();
}
}
else if(!arSizeColumn.empty())
{
arSizeColumn.push_back(tSize);
tSize.Zeroing();
for(int i = 0; i < arSizeColumn.size();i++)
{
CParserStarMathString::ComparisonByWidth(tSize,arSizeColumn[i]);
if(i != 0)
tSize.m_iHeight += 0.5;
}
arSizeColumn.clear();
}
}
if(m_enTypeBracket != TypeElement::brace)
tSize.m_iWidth += 1;
return tSize;
}
//class methods CElementSpecialSymbol
CElementSpecialSymbol::CElementSpecialSymbol(const TypeElement &enType,const TypeConversion &enTypeConversion)
:CElement(TypeElement::SpecialSymbol,enTypeConversion),m_pValue(nullptr),m_enTypeSpecial(enType),m_wsType(L"")
@ -1835,6 +1992,34 @@ namespace StarMath
break;
}
}
TFormulaSize CElementSpecialSymbol::GetSize()
{
TFormulaSize tSize;
if(TypeElement::fact == m_enTypeSpecial || TypeElement::abs == m_enTypeSpecial)
{
if(m_pValue!= nullptr)
{
tSize = m_pValue->GetSize();
tSize.m_iWidth += 1;
}
else
{
tSize.m_iHeight = 1;
tSize.m_iWidth = 1;
}
}
else if(TypeElement::emptiness == m_enTypeSpecial)
{
tSize.m_iHeight = 1;
tSize.m_iWidth = 4;
}
else if(TypeElement::newline != m_enTypeSpecial && TypeElement::grid != m_enTypeSpecial && TypeElement::mline != m_enTypeSpecial)
{
tSize.m_iHeight = 1;
tSize.m_iWidth = 1;
}
return tSize;
}
//class methods CElementSetOperations
CElementSetOperations::CElementSetOperations(const TypeElement &enType,const TypeConversion &enTypeConversion)
:CElement(TypeElement::SetOperations,enTypeConversion),m_pLeftArgument(nullptr), m_pRightArgument(nullptr),m_enTypeSet(enType)
@ -1962,6 +2147,16 @@ namespace StarMath
{
return m_enTypeSet;
}
TFormulaSize CElementSetOperations::GetSize()
{
TFormulaSize tSize;
if(m_pLeftArgument != nullptr)
tSize = m_pLeftArgument->GetSize();
if(m_pRightArgument != nullptr)
CParserStarMathString::ComparisonByHeight(tSize,m_pRightArgument->GetSize());
tSize.m_iWidth += 1;
return tSize;
}
//class methods CElementConnection
CElementConnection::CElementConnection(const TypeElement& enType,const TypeConversion &enTypeConversion)
:CElement(TypeElement::Connection,enTypeConversion),m_pLeftArgument(nullptr), m_pRightArgument(nullptr),m_enTypeCon(enType)
@ -2166,6 +2361,16 @@ namespace StarMath
{
return m_enTypeCon;
}
TFormulaSize CElementConnection::GetSize()
{
TFormulaSize tSize;
if(m_pLeftArgument != nullptr)
tSize = m_pLeftArgument->GetSize();
if(m_pRightArgument != nullptr)
CParserStarMathString::ComparisonByHeight(tSize,m_pRightArgument->GetSize());
tSize.m_iWidth += 1;
return tSize;
}
//class methods CIndex
CElementIndex::CElementIndex(const TypeElement& enType,const TypeConversion &enTypeConversion)
: CElement(TypeElement::Index,enTypeConversion),m_pValueIndex(nullptr),m_pUpperIndex(nullptr),m_pLowerIndex(nullptr),m_pLsubIndex(nullptr),m_pLsupIndex(nullptr),m_pCsubIndex(nullptr),m_pCsupIndex(nullptr),m_pLeftArg(nullptr),m_enTypeIndex(enType)
@ -2453,6 +2658,29 @@ namespace StarMath
{
return m_enTypeIndex;
}
TFormulaSize CElementIndex::GetSize()
{
TFormulaSize tSizeIndex,tLeftArgSize;
if(m_pLeftArg!= nullptr)
tLeftArgSize = m_pLeftArg->GetSize();
if(m_pCsubIndex != nullptr)
CParserStarMathString::ComparisonByHeight(tSizeIndex,m_pCsubIndex->GetSize());
else if(m_pCsupIndex != nullptr)
CParserStarMathString::ComparisonByHeight(tSizeIndex,m_pCsupIndex->GetSize());
else if(m_pLowerIndex != nullptr)
CParserStarMathString::ComparisonByHeight(tSizeIndex,m_pLowerIndex->GetSize());
else if(m_pUpperIndex != nullptr)
CParserStarMathString::ComparisonByHeight(tSizeIndex,m_pUpperIndex->GetSize());
else if(m_pLsubIndex != nullptr)
CParserStarMathString::ComparisonByHeight(tSizeIndex,m_pLsubIndex->GetSize());
else if(m_pLsupIndex != nullptr)
CParserStarMathString::ComparisonByHeight(tSizeIndex,m_pLsupIndex->GetSize());
else if(m_pValueIndex != nullptr)
CParserStarMathString::ComparisonByHeight(tSizeIndex,m_pValueIndex->GetSize());
tSizeIndex.m_iHeight += tLeftArgSize.m_iHeight;
tSizeIndex.m_iWidth += tLeftArgSize.m_iWidth;
return tSizeIndex;
}
//class methods CElementFunction
CElementFunction::CElementFunction(const TypeElement &enType, const TypeConversion &enTypeConversion ,const std::wstring &wsNameFunc)
:CElement(TypeElement::Function,enTypeConversion), m_pValue(nullptr),m_pIndex(nullptr),m_enTypeFunction(enType)
@ -2637,6 +2865,17 @@ namespace StarMath
if(m_pValue != nullptr)
m_pValue->SetAttribute(pAttribute);
}
TFormulaSize CElementFunction::GetSize()
{
TFormulaSize tSize;
if(m_pValue != nullptr)
tSize = m_pValue->GetSize();
if(m_pIndex != nullptr)
CParserStarMathString::ComparisonByHeight(tSize,m_pIndex->GetSize());
if(!m_wsNameFunc.empty())
tSize.m_iWidth += m_wsNameFunc.size();
return tSize;
}
//class methods CElementOperation
CElementOperator::CElementOperator(const TypeElement &enType, const TypeConversion &enTypeConversion,const std::wstring& wsNameOp)
:CElement(TypeElement::Operator,enTypeConversion), m_pValueFrom(nullptr), m_pValueTo(nullptr), m_pValueOperator(nullptr),m_pUpperIndex(nullptr),m_pLowerIndex(nullptr),m_enTypeOperator(enType),m_wsName(wsNameOp)
@ -2821,6 +3060,33 @@ namespace StarMath
if(m_pUpperIndex!=nullptr)
m_pUpperIndex->SetAttribute(pAttribute);
}
TFormulaSize CElementOperator::GetSize()
{
TFormulaSize tSizeTo,tSizeFrom;
if(m_pValueTo != nullptr && m_pUpperIndex != nullptr)
{
tSizeTo = m_pValueTo->GetSize();
CParserStarMathString::ComparisonByHeight(tSizeTo,m_pUpperIndex->GetSize());
}
else if(m_pUpperIndex != nullptr)
tSizeTo = m_pUpperIndex->GetSize();
else if(m_pValueTo != nullptr)
tSizeTo = m_pValueTo->GetSize();
if(m_pValueFrom != nullptr && m_pLowerIndex != nullptr)
{
tSizeFrom = m_pValueFrom->GetSize();
CParserStarMathString::ComparisonByHeight(tSizeFrom,m_pLowerIndex->GetSize());
}
else if(m_pLowerIndex != nullptr)
tSizeFrom = m_pLowerIndex->GetSize();
else if(m_pValueFrom != nullptr)
tSizeFrom = m_pValueFrom->GetSize();
CParserStarMathString::ComparisonByWidth(tSizeTo,tSizeFrom);
tSizeTo.m_iHeight += 1;
if(m_pValueOperator != nullptr)
CParserStarMathString::ComparisonByHeight(tSizeTo,m_pValueOperator->GetSize());
return tSizeTo;
}
// class methods CStarMathReader
CStarMathReader::CStarMathReader(std::wstring::iterator& itStart, std::wstring::iterator& itEnd,const TypeConversion &enTypeConversion)
: m_enGlobalType(TypeElement::Empty),m_enUnderType(TypeElement::Empty),m_pAttribute(nullptr),m_bMarkForUnar(true),m_enTypeCon(enTypeConversion)
@ -3322,6 +3588,16 @@ namespace StarMath
{
return m_enTypeBracketWithIndex;
}
TFormulaSize CElementBracketWithIndex::GetSize()
{
TFormulaSize tSize,tSizeFrom;
if(m_pLeftArg != nullptr)
tSize = m_pLeftArg->GetSize();
if(m_pValue != nullptr)
tSizeFrom = m_pValue->GetSize();
CParserStarMathString::ComparisonByWidth(tSize,tSizeFrom);
return tSize;
}
//class methods CElementGrade
CElementGrade::CElementGrade(const TypeConversion &enTypeConversion)
:CElement(TypeElement::Grade,enTypeConversion),m_pValueGrade(nullptr), m_pValueFrom(nullptr), m_pValueTo(nullptr)
@ -3419,6 +3695,19 @@ namespace StarMath
if(m_pValueTo!=nullptr)
m_pValueTo->SetAttribute(pAttribute);
}
TFormulaSize CElementGrade::GetSize()
{
TFormulaSize tSizeTo,tSizeFrom;
if(m_pValueFrom != nullptr)
tSizeFrom = m_pValueFrom->GetSize();
if(m_pValueTo != nullptr)
tSizeTo = m_pValueTo->GetSize();
CParserStarMathString::ComparisonByWidth(tSizeTo,tSizeFrom);
tSizeTo.m_iHeight += 1;
if(m_pValueGrade != nullptr)
CParserStarMathString::ComparisonByHeight(tSizeTo,m_pValueGrade->GetSize());
return tSizeTo;
}
//class methods CElementMatrix
CElementMatrix::CElementMatrix(const TypeElement &enType,const TypeConversion &enTypeConversion)
:CElement(TypeElement::Matrix,enTypeConversion), m_pFirstArgument(nullptr), m_pSecondArgument(nullptr), m_enTypeMatrix(enType)
@ -3556,6 +3845,20 @@ namespace StarMath
if(m_pSecondArgument != nullptr)
m_pSecondArgument->SetAttribute(pAttribute);
}
TFormulaSize CElementMatrix::GetSize()
{
TFormulaSize tSize;
if(m_pFirstArgument!= nullptr)
tSize = m_pFirstArgument->GetSize();
if(m_pSecondArgument != nullptr)
CParserStarMathString::ComparisonByWidth(tSize,m_pSecondArgument->GetSize());
else if(m_pFirstArgument!= nullptr && m_pFirstArgument->GetBaseType() != TypeElement::Bracket)
{
tSize.m_iHeight += 1.5;
tSize.m_iWidth += 2;
}
return tSize;
}
//class CElementDiacriticalMark
CElementDiacriticalMark::CElementDiacriticalMark(const TypeElement& enType,const TypeConversion &enTypeConversion)
:CElement(TypeElement::Mark,enTypeConversion),m_pValueMark(nullptr),m_enTypeMark(enType)
@ -3684,6 +3987,13 @@ namespace StarMath
if(m_pValueMark != nullptr)
m_pValueMark->SetAttribute(pAttribute);
}
TFormulaSize CElementDiacriticalMark::GetSize()
{
TFormulaSize tSize;
tSize = m_pValueMark->GetSize();
tSize.m_iHeight += 1;
return tSize;
}
}

View File

@ -57,7 +57,19 @@ namespace StarMath
bool base_font_bold;
bool base_font_italic;
};
struct TFormulaSize
{
TFormulaSize():m_iHeight(0),m_iWidth(0) {};
TFormulaSize(const unsigned int& iHeight,const unsigned int& iwidth):m_iHeight(iHeight),m_iWidth(iwidth) {};
float m_iHeight;
float m_iWidth;
void Zeroing()
{
this->m_iHeight = 0;
this->m_iWidth = 0;
}
};
class CAttribute
{
public:
@ -165,6 +177,7 @@ namespace StarMath
static CElement* CreateElement(CStarMathReader* pReader);
virtual void ConversionToOOXML(XmlUtils::CXmlWriter* pXmlWrite) = 0;
virtual void SetAttribute(CAttribute* pAttribute) = 0;
virtual TFormulaSize GetSize() = 0;
void SetBaseAttribute(CAttribute* pAttribute);
void SetBaseType(const TypeElement& enType);
CAttribute* GetAttribute();
@ -194,6 +207,7 @@ namespace StarMath
void SetAttribute(CAttribute* pAttribute) override;
void Parse(CStarMathReader* pReader) override;
void ConversionToOOXML(XmlUtils::CXmlWriter* pXmlWrite) override;
TFormulaSize GetSize() override;
void ConversionOfIndicesToValue(XmlUtils::CXmlWriter* pXmlWrite);
void ConversionOfIndicesAfterValue(XmlUtils::CXmlWriter* pXmlWrite);
CElement* m_pValueIndex;
@ -220,6 +234,7 @@ namespace StarMath
private:
void Parse(CStarMathReader* pReader) override;
void ConversionToOOXML(XmlUtils::CXmlWriter* pXmlWrite) override;
TFormulaSize GetSize() override;
std::wstring m_wsString;
};
@ -243,6 +258,7 @@ namespace StarMath
bool IsBinOperatorLowPrior();
void Parse(CStarMathReader* pReader) override;
void ConversionToOOXML(XmlUtils::CXmlWriter* oXmlWrite) override;
TFormulaSize GetSize() override;
CElement* m_pLeftArgument;
CElement* m_pRightArgument;
TypeElement m_enTypeBinOp;
@ -267,6 +283,7 @@ namespace StarMath
void SetAttribute(CAttribute* pAttribute);
void Parse(CStarMathReader* pReader) override;
void ConversionToOOXML(XmlUtils::CXmlWriter* oXmlWrite) override;
TFormulaSize GetSize() override;
CElement* m_pValueOperator;
CElement* m_pValueFrom;
CElement* m_pValueTo;
@ -289,6 +306,7 @@ namespace StarMath
void SetAttribute(CAttribute* pAttribute) override;
void Parse(CStarMathReader* pReader) override;
void ConversionToOOXML(XmlUtils::CXmlWriter* pXmlWrite) override;
TFormulaSize GetSize() override;
CElement* m_pValueGrade;
CElement* m_pValueFrom;
CElement* m_pValueTo;
@ -307,6 +325,7 @@ namespace StarMath
void SetAttribute(CAttribute* pAttribute) override;
void Parse(CStarMathReader* pReader) override;
void ConversionToOOXML(XmlUtils::CXmlWriter* pXmlWrite) override;
TFormulaSize GetSize() override;
bool CheckMline(CElement* pElement);
std::wstring DefiningBracket(const TypeElement& enTypeBracket);
TypeElement m_enTypeBracket,m_enLeftBracket,m_enRightBracket;
@ -328,6 +347,7 @@ namespace StarMath
void SetAttribute(CAttribute* pAttribute) override;
void Parse(CStarMathReader* pReader) override;
void ConversionToOOXML(XmlUtils::CXmlWriter* pXmlWrite) override;
TFormulaSize GetSize() override;
CElement* m_pLeftArg;
CElement* m_pValue;
TypeElement m_enTypeBracketWithIndex;
@ -348,6 +368,7 @@ namespace StarMath
void SetAttribute(CAttribute* pAttribute) override;
void Parse(CStarMathReader* pReader) override;
void ConversionToOOXML(XmlUtils::CXmlWriter* pXmlWrite) override;
TFormulaSize GetSize() override;
CElement* m_pLeftArgument;
CElement* m_pRightArgument;
TypeElement m_enTypeSet;
@ -368,6 +389,7 @@ namespace StarMath
void SetAttribute(CAttribute* pAttribute) override;
void Parse(CStarMathReader* pReader) override;
void ConversionToOOXML(XmlUtils::CXmlWriter* pXmlWrite) override;
TFormulaSize GetSize() override;
CElement* m_pLeftArgument;
CElement* m_pRightArgument;
TypeElement m_enTypeCon;
@ -387,6 +409,7 @@ namespace StarMath
void SetAttribute(CAttribute* pAttribute) override;
void Parse(CStarMathReader* pReader) override;
void ConversionToOOXML(XmlUtils::CXmlWriter* pXmlWrite) override;
TFormulaSize GetSize() override;
CElement* m_pValue;
CElement* m_pIndex;
std::wstring m_wsNameFunc;
@ -406,6 +429,7 @@ namespace StarMath
void SetAttribute(CAttribute* pAttribute) override;
void Parse(CStarMathReader* pReader) override;
void ConversionToOOXML(XmlUtils::CXmlWriter* pXmlWrite) override;
TFormulaSize GetSize() override;
CElement* m_pValue;
TypeElement m_enTypeSpecial;
std::wstring m_wsType;
@ -423,6 +447,7 @@ namespace StarMath
void SetAttribute(CAttribute* pAttribute) override;
void Parse(CStarMathReader *pReader) override;
void ConversionToOOXML(XmlUtils::CXmlWriter* pXmlWrite) override;
TFormulaSize GetSize() override;
CElement* m_pFirstArgument;
CElement* m_pSecondArgument;
TypeElement m_enTypeMatrix;
@ -439,6 +464,7 @@ namespace StarMath
void SetAttribute(CAttribute* pAttribute) override;
void Parse(CStarMathReader* pReader) override;
void ConversionToOOXML(XmlUtils::CXmlWriter* pXmlWrite) override;
TFormulaSize GetSize() override;
CElement* m_pValueMark;
TypeElement m_enTypeMark;
};
@ -470,11 +496,15 @@ namespace StarMath
void SetBaseAlignment(const unsigned int& iAlignment);
void SetBaseItalic(const bool& bItal);
void SetBaseBold(const bool& bBold);
std::queue<TFormulaSize> GetFormulaSize();
static void ComparisonByHeight(TFormulaSize& tLeftSize,const TFormulaSize& tRightSize);
static void ComparisonByWidth(TFormulaSize& tLeftSize, const TFormulaSize& tRightSize);
static std::wstring ConvertToLowerCase(const std::wstring& wsToken);
private:
TBaseAttribute m_stBaseAttribute;
std::vector<CElement*> m_arEquation;
unsigned int m_iAlignment;
std::queue<TFormulaSize> m_qSize;
};
}

View File

@ -1792,6 +1792,8 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF
if (nFlags & (1 << 5))
pAnnot->SetLM(oInfo.GetLM());
bool bRender = (nFlags >> 6) & 1;
if (nFlags & (1 << 7))
pAnnot->SetOUserID(oInfo.GetOUserID());
if (oInfo.IsMarkup())
{

View File

@ -581,6 +581,17 @@ std::map<std::wstring, std::wstring> CAnnotFonts::GetAllFonts(PDFDoc* pdfDoc, NS
Object oObj;
if (!oAnnot.dictLookup("RC", &oObj)->isString())
{
oObj.free();
if (oAnnot.dictLookup("AP", &oObj)->isNull() && oAnnot.dictLookup("Contents", &oObj)->isString())
{
const unsigned char* pData14 = NULL;
unsigned int nSize14 = 0;
std::wstring wsFontName = L"Helvetica";
NSFonts::IFontsMemoryStorage* pMemoryStorage = NSFonts::NSApplicationFontStream::GetGlobalMemoryStorage();
if (pMemoryStorage && !pMemoryStorage->Get(wsFontName) && GetBaseFont(wsFontName, pData14, nSize14))
pMemoryStorage->Add(wsFontName, (BYTE*)pData14, nSize14, false);
mFonts[L"Helvetica"] = L"Helvetica";
}
oAnnot.free(); oObj.free();
continue;
}
@ -2098,6 +2109,26 @@ CAnnotFreeText::CAnnotFreeText(PDFDoc* pdfDoc, Object* oAnnotRef, int nPageIndex
}
oObj.free();
if (oAnnot.dictLookup("AP", &oObj)->isNull() && oAnnot.dictLookup("RC", &oObj2)->isNull() && oAnnot.dictLookup("Contents", &oObj)->isString())
{
NSStringUtils::CStringBuilder oRC;
oRC += L"<?xml version=\"1.0\"?><body xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:xfa=\"http://www.xfa.org/schema/xfa-data/1.0/\" xfa:APIVersion=\"Acrobat:23.8.0\" xfa:spec=\"2.0.2\"><p dir=\"ltr\"><span style=\"font-size:14.0pt;font-family:Helvetica;text-align:left;color:#000000\">";
TextString* s = new TextString(oObj.getString());
std::wstring wsContents = NSStringExt::CConverter::GetUnicodeFromUTF32(s->getUnicode(), s->getLength());
delete s;
oRC.WriteEncodeXmlString(wsContents);
oRC += L"</span></p></body>";
std::wstring wsRC = oRC.GetData();
m_arrRC = CAnnotMarkup::ReadRC(U_TO_UTF8(wsRC));
if (m_arrRC.empty())
m_unFlags &= ~(1 << 3);
else
m_unFlags |= (1 << 3);
}
oObj.free(); oObj2.free();
oAnnot.free();
}
@ -2816,6 +2847,16 @@ CAnnot::CAnnot(PDFDoc* pdfDoc, AcroFormField* pField)
if (pField->fieldLookup("AP", &oObj)->isDict() && oObj.dictGetLength())
m_unAFlags |= (1 << 6);
oObj.free();
// 7 - User ID
if (pField->fieldLookup("OUserID", &oObj)->isString())
{
m_unAFlags |= (1 << 7);
TextString* s = new TextString(oObj.getString());
m_sOUserID = NSStringExt::CConverter::GetUtf8FromUTF32(s->getUnicode(), s->getLength());
delete s;
}
oObj.free();
}
CAnnot::CAnnot(PDFDoc* pdfDoc, Object* oAnnotRef, int nPageIndex)
{
@ -2932,6 +2973,16 @@ CAnnot::CAnnot(PDFDoc* pdfDoc, Object* oAnnotRef, int nPageIndex)
m_unAFlags |= (1 << 6);
oObj.free();
// 7 - User ID
if (oAnnot.dictLookup("OUserID", &oObj)->isString())
{
m_unAFlags |= (1 << 7);
TextString* s = new TextString(oObj.getString());
m_sOUserID = NSStringExt::CConverter::GetUtf8FromUTF32(s->getUnicode(), s->getLength());
delete s;
}
oObj.free();
oAnnot.free();
}
CAnnot::~CAnnot()
@ -3386,6 +3437,8 @@ void CAnnot::ToWASM(NSWasm::CData& oRes)
m_pBorder->ToWASM(oRes);
if (m_unAFlags & (1 << 5))
oRes.WriteString(m_sM);
if (m_unAFlags & (1 << 7))
oRes.WriteString(m_sOUserID);
}
void CAnnot::CBorderType::ToWASM(NSWasm::CData& oRes)
{

View File

@ -202,6 +202,7 @@ private:
std::string m_sContents; // Отображаемый текст
std::string m_sNM; // Уникальное имя
std::string m_sM; // Дата последнего изменения
std::string m_sOUserID; // OO User ID
std::vector<double> m_arrC; // Специальный цвет
CBorderType* m_pBorder; // Граница
};
@ -350,6 +351,8 @@ protected:
virtual void ToWASM(NSWasm::CData& oRes) override;
std::vector<CFontData*> m_arrRC; // Форматированный текст
private:
BYTE m_nRT; // Тип аннотации-ответа
unsigned int m_unRefNumPopup; // Номер ссылки на всплывающую аннотацию
@ -358,7 +361,6 @@ private:
std::string m_sT; // Текстовая метка, пользователь добавивший аннотацию
std::string m_sCreationDate; // Дата создания
std::string m_sSubj; // Краткое описание
std::vector<CFontData*> m_arrRC; // Форматированный текст
};
//------------------------------------------------------------------------

View File

@ -1677,14 +1677,12 @@ namespace PdfReader
oImage->Create(pBgraData, nWidth, nHeight, 4 * nWidth);
double xMin, yMin, xMax, yMax;
Transform(pMatrix, pBBox[0], pBBox[1], &xMin, &yMin);
Transform(pMatrix, pBBox[2], pBBox[3], &xMax, &yMax);
double dW = xMax - xMin;
double dH = yMax - yMin;
xMin += (double)nX0 * dW;
xMax += (double)nX1 * dW;
yMin += (double)nY0 * dH;
yMax += (double)nY1 * dH;
xMin = nX0 * dXStep;
yMin = nY0 * dYStep;
xMax = nX1 * dXStep;
yMax = nY1 * dYStep;
Transform(pMatrix, xMin, yMin, &xMin, &yMin);
Transform(pMatrix, xMax, yMax, &xMax, &yMax);
pGState->moveTo(xMin, yMin);
pGState->lineTo(xMax, yMin);
pGState->lineTo(xMax, yMax);

View File

@ -275,6 +275,11 @@ namespace PdfWriter
std::string sValue = U_TO_UTF8(wsLM);
Add("M", new CStringObject(sValue.c_str()));
}
void CAnnotation::SetOUserID(const std::wstring& wsLM)
{
std::string sValue = U_TO_UTF8(wsLM);
Add("OUserID", new CStringObject(sValue.c_str()));
}
void CAnnotation::SetC(const std::vector<double>& arrC)
{
AddToVectorD(this, "C", arrC);

View File

@ -180,6 +180,7 @@ namespace PdfWriter
void SetContents(const std::wstring& wsText);
void SetNM(const std::wstring& wsNM);
void SetLM(const std::wstring& wsLM);
void SetOUserID(const std::wstring& wsOUserID);
void SetC(const std::vector<double>& arrC);
void APFromFakePage(CPage* pFakePage);

View File

@ -358,8 +358,10 @@ void Annot::generateLineAppearance() {
obj1.free();
//----- set line style, colors
setLineStyle(borderStyle, &w);
setStrokeColor(borderStyle->getColor(), borderStyle->getNumColorComps());
if (borderStyle) {
setLineStyle(borderStyle, &w);
setStrokeColor(borderStyle->getColor(), borderStyle->getNumColorComps());
}
fill = gFalse;
if (annotObj.dictLookup("IC", &obj1)->isArray()) {
if (setFillColor(&obj1)) {
@ -486,7 +488,7 @@ void Annot::generateLineAppearance() {
appearBuf->append("S\n");
//----- draw the arrows
if (borderStyle->getType() == annotBorderDashed) {
if (borderStyle && borderStyle->getType() == annotBorderDashed) {
appearBuf->append("[] 0 d\n");
}
drawLineArrow(lineEnd1, lx1, ly1, dx, dy, w, fill);
@ -544,8 +546,10 @@ void Annot::generatePolyLineAppearance() {
obj1.free();
//----- set line style, colors
setLineStyle(borderStyle, &w);
setStrokeColor(borderStyle->getColor(), borderStyle->getNumColorComps());
if (borderStyle) {
setLineStyle(borderStyle, &w);
setStrokeColor(borderStyle->getColor(), borderStyle->getNumColorComps());
}
// fill = gFalse;
// if (annotObj.dictLookup("IC", &obj1)->isArray()) {
// if (setFillColor(&obj1)) {
@ -761,7 +765,7 @@ void Annot::generateFreeTextAppearance() {
delete da;
//----- draw the border
if (borderStyle->getWidth() != 0) {
if (borderStyle && borderStyle->getWidth() != 0) {
setLineStyle(borderStyle, &lineWidth);
appearBuf->appendf("{0:.4f} {1:.4f} {2:.4f} {3:.4f} re s\n",
0.5 * lineWidth, 0.5 * lineWidth,
@ -809,13 +813,14 @@ void Annot::setLineStyle(AnnotBorderStyle *bs, double *lineWidth) {
double w;
int dashLength, i;
if ((w = borderStyle->getWidth()) <= 0) {
w = 0.1;
if (borderStyle && (w = borderStyle->getWidth()) <= 0) {
w = 0.1;
}
*lineWidth = w;
appearBuf->appendf("{0:.4f} w\n", w);
// this treats beveled/inset/underline as solid
if (borderStyle->getType() == annotBorderDashed) {
if (borderStyle && borderStyle->getType() == annotBorderDashed) {
borderStyle->getDash(&dash, &dashLength);
appearBuf->append("[");
for (i = 0; i < dashLength; ++i) {