From 6fe92e1725b0ede2b0f7554c8470b6be7b0d0097 Mon Sep 17 00:00:00 2001 From: Kamil Kerimov Date: Fri, 20 Dec 2024 17:58:52 +0500 Subject: [PATCH 01/21] Fix table header columns conversion --- OdfFile/Writer/Format/table.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/OdfFile/Writer/Format/table.cpp b/OdfFile/Writer/Format/table.cpp index 381dd1f93e..7b29f2bc3a 100644 --- a/OdfFile/Writer/Format/table.cpp +++ b/OdfFile/Writer/Format/table.cpp @@ -468,18 +468,17 @@ void table_columns_no_group::add_child_element( const office_element_ptr & child } void table_columns_no_group::serialize(std::wostream & _Wostream) { - // CP_XML_WRITER(_Wostream) - // { - //CP_XML_NODE_SIMPLE() - // { - table_columns_1_.serialize(_Wostream); + CP_XML_WRITER(_Wostream) + { + table_columns_1_.serialize(_Wostream); - if (table_table_header_columns_) - table_table_header_columns_->serialize(_Wostream); - - table_columns_2_.serialize(_Wostream); - // } - //} + if (table_table_header_columns_) + table_table_header_columns_->serialize(_Wostream); + else + CP_XML_NODE(L"table:table-header-columns"); + + table_columns_2_.serialize(_Wostream); + } } _CP_PTR(table_columns_no_group) table_columns_no_group::create(odf_conversion_context * Context) { From 896427db83d57438812c21f99422336b8db7cd86 Mon Sep 17 00:00:00 2001 From: "Oleg.Korshul" Date: Sat, 8 Feb 2025 21:59:52 +0300 Subject: [PATCH 02/21] For bug 72964 --- .../doctrenderer/embed/GraphicsEmbed.cpp | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/DesktopEditor/doctrenderer/embed/GraphicsEmbed.cpp b/DesktopEditor/doctrenderer/embed/GraphicsEmbed.cpp index b2677c4b85..15bbc60574 100644 --- a/DesktopEditor/doctrenderer/embed/GraphicsEmbed.cpp +++ b/DesktopEditor/doctrenderer/embed/GraphicsEmbed.cpp @@ -160,16 +160,30 @@ void CGraphicsEmbed::SetAppImage(CGraphicsAppImage* appImage) JSSmart CGraphicsEmbed::create(JSSmart Native, JSSmart width_px, JSSmart height_px, JSSmart width_mm, JSSmart height_mm) { - NSNativeControl::CNativeControl* pControl = NULL; if (!Native->isNull()) { - pControl = (NSNativeControl::CNativeControl*)Native->toObject()->getNative()->getObject(); + JSSmart pNativeObject = Native->toObject(); + CJSEmbedObject* pNativeEmbedObject = pNativeObject->getNative(); if (m_pInternal->m_pAppImage) delete m_pInternal->m_pAppImage; m_pInternal->m_pAppImage = new CGraphicsAppImage(); - m_pInternal->m_pAppImage->SetFontsDirectory(pControl->m_strFontsDirectory); - m_pInternal->m_pAppImage->SetImagesDirectory(pControl->m_strImagesDirectory); + + if (pNativeEmbedObject) + { + NSNativeControl::CNativeControl* pControl = (NSNativeControl::CNativeControl*)pNativeEmbedObject->getObject(); + m_pInternal->m_pAppImage->SetFontsDirectory(pControl->m_strFontsDirectory); + m_pInternal->m_pAppImage->SetImagesDirectory(pControl->m_strImagesDirectory); + } + else + { + JSSmart checkResources = pNativeObject->get("isResourcesObject"); + if (checkResources->isBool() && true == checkResources->toBool()) + { + m_pInternal->m_pAppImage->SetFontsDirectory(pNativeObject->get("fontsDirectory")->toStringW()); + m_pInternal->m_pAppImage->SetImagesDirectory(pNativeObject->get("imagesDirectory")->toStringW()); + } + } } m_pInternal->init(width_px->toDouble(), height_px->toDouble(), width_mm->toDouble(), height_mm->toDouble()); From beb8574dfd1c263bec39eb8e5a2d3bac9d128768 Mon Sep 17 00:00:00 2001 From: Green Date: Mon, 3 Feb 2025 04:46:08 +0300 Subject: [PATCH 03/21] Fix bug #72962 --- .../raster/Metafile/Common/MetaFileRenderer.h | 80 ++++++++++++------- 1 file changed, 50 insertions(+), 30 deletions(-) diff --git a/DesktopEditor/raster/Metafile/Common/MetaFileRenderer.h b/DesktopEditor/raster/Metafile/Common/MetaFileRenderer.h index 507ee0082f..fe042dc3bf 100644 --- a/DesktopEditor/raster/Metafile/Common/MetaFileRenderer.h +++ b/DesktopEditor/raster/Metafile/Common/MetaFileRenderer.h @@ -1218,30 +1218,56 @@ namespace MetaFile else if (PS_JOIN_MITER == ulPenJoin) nJoinStyle = Aggplus::LineJoinMiter; - const double dWidth = pPen->GetWidth() * m_dScaleX; - const double dMiterLimit = (0 != pPen->GetMiterLimit()) ? pPen->GetMiterLimit() : m_pFile->GetMiterLimit() * m_dScaleX; + double dWidth = pPen->GetWidth(); - BYTE nDashStyle = Aggplus::DashStyleSolid; + // Повторение кода из Graphics для вычисления минимальной ширины пера + double dM11, dM12, dM21, dM22, dDx, dDy; + m_pRenderer->GetTransform(&dM11, &dM12, &dM21, &dM22, &dDx, &dDy); + + Aggplus::CMatrix oMatrix; + + oMatrix.SetElements(dM11, dM12, dM21, dM22, dDx, dDy); + oMatrix.Scale(1. / m_dScaleX, 1. / m_dScaleY); double *pDataDash; unsigned int unSizeDash; pPen->GetDashData(pDataDash, unSizeDash); + // Вычисление минимально возможной ширины пера + // # Код явялется дублированным из Graphics + const double dSqrtDet = sqrt(abs(oMatrix.Determinant())); + const double dWidthMinSize = (dSqrtDet != 0) ? (1.0 / dSqrtDet) : dWidth; + + if (0 == pPen->GetWidth()) + { + double dX = 0.72, dY = 0.72; + + oMatrix.Invert(); + oMatrix.TransformPoint(dX, dY); + dX -= oMatrix.OffsetX(); + dY -= oMatrix.OffsetY(); + dWidth = std::min(abs(dX), abs(dY)); + } + //------------------------ + else + dWidth *= m_dScaleX; + + if (dWidth < dWidthMinSize) + dWidth = dWidthMinSize; + + const double dMiterLimit = (0 != pPen->GetMiterLimit()) ? pPen->GetMiterLimit() : m_pFile->GetMiterLimit() * m_dScaleX; + + BYTE nDashStyle = Aggplus::DashStyleSolid; + if (NULL != pDataDash && 0 != unSizeDash) { m_pRenderer->put_PenDashOffset(pPen->GetDashOffset()); - double dM11, dTemp; - m_pRenderer->GetTransform(&dM11, &dTemp, &dTemp, &dTemp, &dTemp, &dTemp); - double dDpi; - m_pRenderer->get_DpiX(&dDpi); - const double dNewWidth{dWidth * dM11 * dDpi / 25.4}; - std::vector arDashes(unSizeDash); for (unsigned int unIndex = 0; unIndex < unSizeDash; ++unIndex) - arDashes[unIndex] = pDataDash[unIndex] * dNewWidth; + arDashes[unIndex] = pDataDash[unIndex] * dWidth; m_pRenderer->PenDashPattern(arDashes.data(), unSizeDash); @@ -1251,45 +1277,39 @@ namespace MetaFile { std::vector arDashPattern; - double dM11, dTemp; - m_pRenderer->GetTransform(&dM11, &dTemp, &dTemp, &dTemp, &dTemp, &dTemp); - double dDpi; - m_pRenderer->get_DpiX(&dDpi); - const double dNewWidth{dWidth * dM11 * dDpi / 25.4}; - switch (ulPenStyle) { case PS_DASH: { - arDashPattern.push_back(9 * dNewWidth); - arDashPattern.push_back(3 * dNewWidth); + arDashPattern.push_back(9 * dWidth); + arDashPattern.push_back(3 * dWidth); break; } case PS_DOT: { - arDashPattern.push_back(3 * dNewWidth); - arDashPattern.push_back(3 * dNewWidth); + arDashPattern.push_back(3 * dWidth); + arDashPattern.push_back(3 * dWidth); break; } case PS_DASHDOT: { - arDashPattern.push_back(9 * dNewWidth); - arDashPattern.push_back(3 * dNewWidth); - arDashPattern.push_back(3 * dNewWidth); - arDashPattern.push_back(3 * dNewWidth); + arDashPattern.push_back(9 * dWidth); + arDashPattern.push_back(6 * dWidth); + arDashPattern.push_back(3 * dWidth); + arDashPattern.push_back(6 * dWidth); break; } case PS_DASHDOTDOT: { - arDashPattern.push_back(9 * dNewWidth); - arDashPattern.push_back(3 * dNewWidth); - arDashPattern.push_back(3 * dNewWidth); - arDashPattern.push_back(3 * dNewWidth); - arDashPattern.push_back(3 * dNewWidth); - arDashPattern.push_back(3 * dNewWidth); + arDashPattern.push_back(9 * dWidth); + arDashPattern.push_back(6 * dWidth); + arDashPattern.push_back(3 * dWidth); + arDashPattern.push_back(6 * dWidth); + arDashPattern.push_back(3 * dWidth); + arDashPattern.push_back(6 * dWidth); break; } From b7d346460924746698f70e3127af95ca6d1ffb87 Mon Sep 17 00:00:00 2001 From: Green Date: Thu, 6 Feb 2025 13:41:28 +0300 Subject: [PATCH 04/21] Edited default mode ShapeRendering for metafile to svg conversion --- DesktopEditor/raster/Metafile/Emf/EmfParser/CEmfParserBase.cpp | 2 +- DesktopEditor/raster/Metafile/Wmf/WmfParser/CWmfParserBase.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DesktopEditor/raster/Metafile/Emf/EmfParser/CEmfParserBase.cpp b/DesktopEditor/raster/Metafile/Emf/EmfParser/CEmfParserBase.cpp index cffcbabb82..b69bafd5d3 100644 --- a/DesktopEditor/raster/Metafile/Emf/EmfParser/CEmfParserBase.cpp +++ b/DesktopEditor/raster/Metafile/Emf/EmfParser/CEmfParserBase.cpp @@ -763,7 +763,7 @@ namespace MetaFile if (InterpretatorType::Svg == oInterpretatorType) { CEmfInterpretatorSvg *pEmfInterpretatorSvg = new CEmfInterpretatorSvg(this, dWidth, dHeight); - pEmfInterpretatorSvg->SetShapeRendering(EShapeRendering::CrispEdges); + pEmfInterpretatorSvg->SetShapeRendering(EShapeRendering::OptimizeSpeed); m_pInterpretator = pEmfInterpretatorSvg; } } diff --git a/DesktopEditor/raster/Metafile/Wmf/WmfParser/CWmfParserBase.cpp b/DesktopEditor/raster/Metafile/Wmf/WmfParser/CWmfParserBase.cpp index b8d03f538e..c0d82821f1 100644 --- a/DesktopEditor/raster/Metafile/Wmf/WmfParser/CWmfParserBase.cpp +++ b/DesktopEditor/raster/Metafile/Wmf/WmfParser/CWmfParserBase.cpp @@ -196,7 +196,7 @@ namespace MetaFile if (InterpretatorType::Svg == oInterpretatorType) { CWmfInterpretatorSvg *pWmfInterpretatorSvg = new CWmfInterpretatorSvg(this, unWidth, unHeight); - pWmfInterpretatorSvg->SetShapeRendering(EShapeRendering::CrispEdges); + pWmfInterpretatorSvg->SetShapeRendering(EShapeRendering::OptimizeSpeed); m_pInterpretator = pWmfInterpretatorSvg; } } From 2a0c84513b93f7b6be5b614b42f3d3520faf5c94 Mon Sep 17 00:00:00 2001 From: Green Date: Thu, 6 Feb 2025 15:34:29 +0300 Subject: [PATCH 05/21] For bug #72962 --- .../raster/Metafile/Common/MetaFileRenderer.h | 140 ++++++++++-------- 1 file changed, 78 insertions(+), 62 deletions(-) diff --git a/DesktopEditor/raster/Metafile/Common/MetaFileRenderer.h b/DesktopEditor/raster/Metafile/Common/MetaFileRenderer.h index fe042dc3bf..bc2351eab7 100644 --- a/DesktopEditor/raster/Metafile/Common/MetaFileRenderer.h +++ b/DesktopEditor/raster/Metafile/Common/MetaFileRenderer.h @@ -100,8 +100,6 @@ namespace MetaFile m_bStartedPath = false; m_bUpdatedClip = true; - m_pRenderer->CommandLong(c_nPenWidth0As1px, 1); - //int alpha = 0xff; //m_pRenderer->put_BrushAlpha1(alpha); //m_pRenderer->put_BrushType(c_BrushTypeSolid); @@ -1229,11 +1227,6 @@ namespace MetaFile oMatrix.SetElements(dM11, dM12, dM21, dM22, dDx, dDy); oMatrix.Scale(1. / m_dScaleX, 1. / m_dScaleY); - double *pDataDash; - unsigned int unSizeDash; - - pPen->GetDashData(pDataDash, unSizeDash); - // Вычисление минимально возможной ширины пера // # Код явялется дублированным из Graphics const double dSqrtDet = sqrt(abs(oMatrix.Determinant())); @@ -1251,76 +1244,99 @@ namespace MetaFile } //------------------------ else + { dWidth *= m_dScaleX; - if (dWidth < dWidthMinSize) - dWidth = dWidthMinSize; + if (dWidth < dWidthMinSize) + dWidth = dWidthMinSize; + } const double dMiterLimit = (0 != pPen->GetMiterLimit()) ? pPen->GetMiterLimit() : m_pFile->GetMiterLimit() * m_dScaleX; BYTE nDashStyle = Aggplus::DashStyleSolid; - if (NULL != pDataDash && 0 != unSizeDash) + double *pDataDash; + unsigned int unSizeDash; + + pPen->GetDashData(pDataDash, unSizeDash); + + if ((NULL != pDataDash && 0 != unSizeDash) || PS_SOLID != ulPenStyle) { - m_pRenderer->put_PenDashOffset(pPen->GetDashOffset()); + // Дублированный код из Graphics + // Без этого используется оригинальный код в Graphics, который отрисовывает уже неверно + double dDashWidth{dWidth}; - std::vector arDashes(unSizeDash); - - for (unsigned int unIndex = 0; unIndex < unSizeDash; ++unIndex) - arDashes[unIndex] = pDataDash[unIndex] * dWidth; - - m_pRenderer->PenDashPattern(arDashes.data(), unSizeDash); - - nDashStyle = Aggplus::DashStyleCustom; - } - else if (PS_SOLID != ulPenStyle) - { - std::vector arDashPattern; - - switch (ulPenStyle) + if (!Equals(dWidthMinSize, dWidth)) { - case PS_DASH: - { - arDashPattern.push_back(9 * dWidth); - arDashPattern.push_back(3 * dWidth); + double dDet = oMatrix.Determinant(); - break; - } - case PS_DOT: - { - arDashPattern.push_back(3 * dWidth); - arDashPattern.push_back(3 * dWidth); - - break; - } - case PS_DASHDOT: - { - arDashPattern.push_back(9 * dWidth); - arDashPattern.push_back(6 * dWidth); - arDashPattern.push_back(3 * dWidth); - arDashPattern.push_back(6 * dWidth); - - break; - } - case PS_DASHDOTDOT: - { - arDashPattern.push_back(9 * dWidth); - arDashPattern.push_back(6 * dWidth); - arDashPattern.push_back(3 * dWidth); - arDashPattern.push_back(6 * dWidth); - arDashPattern.push_back(3 * dWidth); - arDashPattern.push_back(6 * dWidth); - - break; - } + if (fabs(dDet) < 0.0001) + dDashWidth *= dSqrtDet; } + // ----------------------------- - if (!arDashPattern.empty()) + if (NULL != pDataDash && 0 != unSizeDash) { - m_pRenderer->PenDashPattern(arDashPattern.data(), arDashPattern.size()); + m_pRenderer->put_PenDashOffset(pPen->GetDashOffset()); + + std::vector arDashes(unSizeDash); + + for (unsigned int unIndex = 0; unIndex < unSizeDash; ++unIndex) + arDashes[unIndex] = pDataDash[unIndex] * dDashWidth; + + m_pRenderer->PenDashPattern(arDashes.data(), unSizeDash); + nDashStyle = Aggplus::DashStyleCustom; - nStartCapStyle = nEndCapStyle = Aggplus::LineCapFlat; - nJoinStyle = Aggplus::LineJoinMiter; + } + else + { + std::vector arDashPattern; + + switch (ulPenStyle) + { + case PS_DASH: + { + arDashPattern.push_back(9 * dDashWidth); + arDashPattern.push_back(3 * dDashWidth); + + break; + } + case PS_DOT: + { + arDashPattern.push_back(3 * dDashWidth); + arDashPattern.push_back(3 * dDashWidth); + + break; + } + case PS_DASHDOT: + { + arDashPattern.push_back(9 * dDashWidth); + arDashPattern.push_back(6 * dDashWidth); + arDashPattern.push_back(3 * dDashWidth); + arDashPattern.push_back(6 * dDashWidth); + + break; + } + case PS_DASHDOTDOT: + { + arDashPattern.push_back(9 * dDashWidth); + arDashPattern.push_back(6 * dDashWidth); + arDashPattern.push_back(3 * dDashWidth); + arDashPattern.push_back(6 * dDashWidth); + arDashPattern.push_back(3 * dDashWidth); + arDashPattern.push_back(6 * dDashWidth); + + break; + } + } + + if (!arDashPattern.empty()) + { + m_pRenderer->PenDashPattern(arDashPattern.data(), arDashPattern.size()); + nDashStyle = Aggplus::DashStyleCustom; + nStartCapStyle = nEndCapStyle = Aggplus::LineCapFlat; + nJoinStyle = Aggplus::LineJoinMiter; + } } } From 612142f0ae4ec7c7a11332dedd30d4c73d64f59a Mon Sep 17 00:00:00 2001 From: Green Date: Thu, 6 Feb 2025 16:27:14 +0300 Subject: [PATCH 06/21] Refactoring --- .../raster/Metafile/Common/MetaFileTypes.cpp | 16 ++++- .../raster/Metafile/Common/MetaFileTypes.h | 2 + .../raster/Metafile/Common/MetaFileUtils.cpp | 38 ++++-------- .../raster/Metafile/Emf/EmfObjects.cpp | 1 - .../Metafile/Emf/EmfParser/CEmfParser.cpp | 10 ++++ .../Metafile/Emf/EmfParser/CEmfParserBase.h | 4 -- .../Metafile/Emf/EmfParser/CEmfPlusParser.cpp | 60 ++++++++----------- .../Metafile/Emf/EmfParser/CEmfPlusParser.h | 2 - .../raster/Metafile/Emf/EmfPlusTypes.h | 10 ++++ .../raster/Metafile/StarView/SvmFile.cpp | 2 + .../WmfInterpretator/CWmfInterpretatorSvg.cpp | 8 ++- .../Metafile/Wmf/WmfParser/CWmfParser.cpp | 2 +- .../Metafile/Wmf/WmfParser/CWmfParserBase.cpp | 38 +++++++----- .../Metafile/Wmf/WmfParser/CWmfParserBase.h | 1 + 14 files changed, 108 insertions(+), 86 deletions(-) diff --git a/DesktopEditor/raster/Metafile/Common/MetaFileTypes.cpp b/DesktopEditor/raster/Metafile/Common/MetaFileTypes.cpp index b6293a91ce..697c9440ff 100644 --- a/DesktopEditor/raster/Metafile/Common/MetaFileTypes.cpp +++ b/DesktopEditor/raster/Metafile/Common/MetaFileTypes.cpp @@ -44,7 +44,8 @@ namespace MetaFile : r(_r), g(_g), b(_b), a(_a) {} - TRGBA::TRGBA(int nValue) : r((nValue >> 0) & 0xFF), g((nValue >> 8) & 0xFF), b((nValue >> 16) & 0xFF), a((nValue >> 24) & 0xFF) + TRGBA::TRGBA(int nValue) + : r((nValue >> 0) & 0xFF), g((nValue >> 8) & 0xFF), b((nValue >> 16) & 0xFF), a((nValue >> 24) & 0xFF) {} void TRGBA::Set(unsigned char _r, unsigned char _g, unsigned char _b, unsigned char _a) @@ -94,7 +95,18 @@ namespace MetaFile return a; } - TXForm::TXForm() : M11(1), M12(0), M21(0), M22(1), Dx(0), Dy(0) + TRGBA& TRGBA::operator=(const TRGBA& oRGBA) + { + r = oRGBA.r; + g = oRGBA.g; + b = oRGBA.b; + a = oRGBA.a; + + return *this; + } + + TXForm::TXForm() + : M11(1), M12(0), M21(0), M22(1), Dx(0), Dy(0) {} TXForm::TXForm(const TXForm &oXForm) diff --git a/DesktopEditor/raster/Metafile/Common/MetaFileTypes.h b/DesktopEditor/raster/Metafile/Common/MetaFileTypes.h index 4bd9ff3da7..09ff44864a 100644 --- a/DesktopEditor/raster/Metafile/Common/MetaFileTypes.h +++ b/DesktopEditor/raster/Metafile/Common/MetaFileTypes.h @@ -558,6 +558,8 @@ namespace MetaFile unsigned char GetGreen() const; unsigned char GetBlue() const; unsigned char GetAlpha() const; + + TRGBA& operator=(const TRGBA& oRGBA); }; struct TXForm diff --git a/DesktopEditor/raster/Metafile/Common/MetaFileUtils.cpp b/DesktopEditor/raster/Metafile/Common/MetaFileUtils.cpp index 29ab635fda..ed46d2c551 100644 --- a/DesktopEditor/raster/Metafile/Common/MetaFileUtils.cpp +++ b/DesktopEditor/raster/Metafile/Common/MetaFileUtils.cpp @@ -237,7 +237,9 @@ namespace MetaFile } for (int nAddIndex = 0; nAddIndex < nAdditBytes; nAddIndex++) { - int nByte = *pBuffer; pBuffer++; lBufLen--; + // int nByte = *pBuffer; + ++pBuffer; + --lBufLen; } } } @@ -271,7 +273,9 @@ namespace MetaFile } for (int nAddIndex = 0; nAddIndex < nAdditBytes; nAddIndex++) { - int nByte = *pBuffer; pBuffer++; lBufLen--; + // int nByte = *pBuffer; + ++pBuffer; + --lBufLen; } } } @@ -490,7 +494,12 @@ namespace MetaFile } if (lBufLen < (nWidth + nAdd) * abs(nHeight)) + { + if (pUncompressedBuffer) + delete[] pUncompressedBuffer; + return false; + } pBgraBuffer = new BYTE[nWidth * abs(nHeight) * 4 * sizeof(BYTE)]; if (NULL == pBgraBuffer) @@ -643,7 +652,7 @@ namespace MetaFile *pulWidth = ulWidth; *pulHeight = ulHeight; - return false; + return true; } else if (BI_BITCOUNT_5 == ushBitCount) { @@ -990,29 +999,6 @@ namespace MetaFile } } - std::wstring ascii_to_unicode(const char *src) - { - size_t nSize = mbstowcs(0, src, 0); - wchar_t* pBuffer = new wchar_t[nSize]; - nSize = mbstowcs(pBuffer, src, nSize); - std::wstring sRes; - if (nSize != (size_t)-1) - sRes = std::wstring(pBuffer, nSize); - delete[] pBuffer; - return sRes; - } - std::string unicode_to_ascii(const wchar_t *src) - { - size_t nSize = wcstombs(0, src, 0); - char* pBuffer = new char[nSize]; - nSize = wcstombs(pBuffer, src, nSize); - std::string sRes; - if (nSize != (size_t)-1) - sRes = std::string(pBuffer, nSize); - delete[] pBuffer; - return sRes; - } - std::wstring GetTempFilename(const std::wstring& sFolder) { std::wstring sTmpFile = NSFile::CFileBinary::CreateTempFileWithUniqueName(sFolder.empty() ? NSFile::CFileBinary::GetTempPath() : sFolder, L"wmf"); diff --git a/DesktopEditor/raster/Metafile/Emf/EmfObjects.cpp b/DesktopEditor/raster/Metafile/Emf/EmfObjects.cpp index 09f8874ced..cd1518e567 100644 --- a/DesktopEditor/raster/Metafile/Emf/EmfObjects.cpp +++ b/DesktopEditor/raster/Metafile/Emf/EmfObjects.cpp @@ -30,7 +30,6 @@ * */ #include "../../../raster/ImageFileFormatChecker.h" -#include "../../../graphics/Image.h" #include "../Common/MetaFileUtils.h" diff --git a/DesktopEditor/raster/Metafile/Emf/EmfParser/CEmfParser.cpp b/DesktopEditor/raster/Metafile/Emf/EmfParser/CEmfParser.cpp index 6f4bdc8e00..62360a3586 100644 --- a/DesktopEditor/raster/Metafile/Emf/EmfParser/CEmfParser.cpp +++ b/DesktopEditor/raster/Metafile/Emf/EmfParser/CEmfParser.cpp @@ -593,6 +593,8 @@ namespace MetaFile if (!BanEMFProcesses()) HANDLE_EMR_CREATEBRUSHINDIRECT(ulBrushIndex, pBrush); + else + delete pBrush; } void CEmfParser::Read_EMR_SETTEXTCOLOR() @@ -630,6 +632,8 @@ namespace MetaFile if (!BanEMFProcesses()) HANDLE_EMR_EXTCREATEFONTINDIRECTW(ulIndex, pFont); + else + delete pFont; } void CEmfParser::Read_EMR_SETTEXTALIGN() @@ -722,6 +726,8 @@ namespace MetaFile if (!BanEMFProcesses()) HANDLE_EMR_EXTCREATEPEN(ulPenIndex, pPen, arUnused); + else + delete pPen; } void CEmfParser::Read_EMR_CREATEPEN() @@ -744,6 +750,8 @@ namespace MetaFile if (!BanEMFProcesses()) HANDLE_EMR_CREATEPEN(ulPenIndex, widthX, pPen); + else + delete pPen; } void CEmfParser::Read_EMR_SETPOLYFILLMODE() @@ -1011,6 +1019,8 @@ namespace MetaFile if (!BanEMFProcesses()) HANDLE_EMR_CREATEPALETTE(ulPaletteIndex, pPalette); + else + delete pPalette; } void CEmfParser::Read_EMR_SELECTPALETTE() diff --git a/DesktopEditor/raster/Metafile/Emf/EmfParser/CEmfParserBase.h b/DesktopEditor/raster/Metafile/Emf/EmfParser/CEmfParserBase.h index 20a460aa48..d52dfd9434 100644 --- a/DesktopEditor/raster/Metafile/Emf/EmfParser/CEmfParserBase.h +++ b/DesktopEditor/raster/Metafile/Emf/EmfParser/CEmfParserBase.h @@ -1,10 +1,6 @@ #ifndef CEMFPARSERBASE_H #define CEMFPARSERBASE_H -//#include "../EmfTypes.h" -//#include "../EmfObjects.h" -//#include "../../Common/MetaFileUtils.h" - #include "../EmfPlayer.h" #include "../../Common/MetaFile.h" diff --git a/DesktopEditor/raster/Metafile/Emf/EmfParser/CEmfPlusParser.cpp b/DesktopEditor/raster/Metafile/Emf/EmfParser/CEmfPlusParser.cpp index 713cb4c95d..5ae466d3c1 100644 --- a/DesktopEditor/raster/Metafile/Emf/EmfParser/CEmfPlusParser.cpp +++ b/DesktopEditor/raster/Metafile/Emf/EmfParser/CEmfPlusParser.cpp @@ -67,15 +67,11 @@ #define EMFPLUS_TRANSLATEWORLDTRANSFORM 0x402D #include -#include #include "CEmfParser.h" -#include "../../Wmf/WmfFile.h" -#include "../../Wmf/WmfInterpretator/CWmfInterpretatorSvg.h" #include "../EmfInterpretator/CEmfInterpretator.h" #include "../EmfInterpretator/CEmfInterpretatorSvg.h" -#include "../EmfInterpretator/CEmfInterpretatorArray.h" #include "../EmfInterpretator/CEmfInterpretatorRender.h" #ifdef METAFILE_SUPPORT_WMF_EMF_XML @@ -665,8 +661,8 @@ namespace MetaFile for (unsigned int unIndex = 0; unIndex < unPositionCount; ++unIndex) m_oStream >> pEmfPlusBrush->arGradientColors[unIndex].first; - pEmfPlusBrush->oColor = pEmfPlusBrush->arGradientColors[unPositionCount - 1].first; - pEmfPlusBrush->oColorBack = pEmfPlusBrush->arGradientColors[0].first; + pEmfPlusBrush->oColor = pEmfPlusBrush->arGradientColors.back() .first; + pEmfPlusBrush->oColorBack = pEmfPlusBrush->arGradientColors.front().first; } } @@ -775,7 +771,7 @@ namespace MetaFile switch (nEndCap) { - case 0: pEmfPlusPen->unStyle |= PS_ENDCAP_MASK & PS_ENDCAP_FLAT; break; + case 0: pEmfPlusPen->unStyle |= PS_ENDCAP_MASK & PS_ENDCAP_FLAT; break; case 1: pEmfPlusPen->unStyle |= PS_ENDCAP_MASK & PS_ENDCAP_SQUARE; break; case 2: pEmfPlusPen->unStyle |= PS_ENDCAP_MASK & PS_ENDCAP_ROUND; break; } @@ -788,7 +784,7 @@ namespace MetaFile switch (nJoin) { - case 0: pEmfPlusPen->unStyle |= PS_JOIN_MASK & PS_JOIN_MITER; break; + case 0: pEmfPlusPen->unStyle |= PS_JOIN_MASK & PS_JOIN_MITER; break; case 1: pEmfPlusPen->unStyle |= PS_JOIN_MASK & PS_JOIN_BEVEL; break; case 2: pEmfPlusPen->unStyle |= PS_JOIN_MASK & PS_ENDCAP_ROUND; break; } @@ -874,7 +870,7 @@ namespace MetaFile m_oStream >> *pLineCapData; if (CustomLineCapDataFillPath == pLineCapData->unCustomLineCapDataFlags || - CustomLineCapDataLinePath == pLineCapData->unCustomLineCapDataFlags) + CustomLineCapDataLinePath == pLineCapData->unCustomLineCapDataFlags) { m_oStream.Skip(4); // FillPathLength or LinePathLength pLineCapData->pPath = ReadPath(); @@ -1346,7 +1342,7 @@ namespace MetaFile if (oImageAttributes.eWrapMode == WrapModeClamp) { if (oRectangle.dX < 0 || oRectangle.dX < 0 || - oRectangle.dX >= oRectangle.dWidth || oRectangle.dY >= oRectangle.dHeight) + oRectangle.dX >= oRectangle.dWidth || oRectangle.dY >= oRectangle.dHeight) return oImageAttributes.oClampColor; } @@ -1544,14 +1540,10 @@ namespace MetaFile case MetafileDataTypeEmf: case MetafileDataTypeEmfPlusOnly: case MetafileDataTypeEmfPlusDual: - { return DrawMetafile(pBuffer, unSizeBuffer, oSrcRect, arPoints); - } case MetafileDataTypeWmf: case MetafileDataTypeWmfPlaceable: - { return DrawMetafile(pBuffer, unSizeBuffer, oSrcRect, arPoints); - } } } } @@ -1664,7 +1656,7 @@ namespace MetaFile BYTE* pNewBuffer = GetClipedImage(pPixels, nWidth, nHeight, oClipRect, nW, nH); m_pInterpretator->DrawBitmap(arPoints[0].X, arPoints[0].Y, arPoints[1].X - arPoints[0].X - m_pDC->GetPixelWidth(), arPoints[2].Y - arPoints[0].Y - m_pDC->GetPixelHeight(), - (NULL != pNewBuffer) ? pNewBuffer : pPixels, nW, nH); + (NULL != pNewBuffer) ? pNewBuffer : pPixels, nW, nH); RELEASEINTERFACE(pGrRenderer); RELEASEARRAYOBJECTS(pNewBuffer); @@ -1743,7 +1735,7 @@ namespace MetaFile BYTE* pNewBuffer = GetClipedImage(pBytes, unWidth, unHeight, oClipRect, nW, nH); m_pInterpretator->DrawBitmap(arPoints[0].X, arPoints[0].Y, arPoints[1].X - arPoints[0].X, arPoints[2].Y - arPoints[0].Y, - (NULL != pNewBuffer) ? pNewBuffer : pBytes, nW, nH); + (NULL != pNewBuffer) ? pNewBuffer : pBytes, nW, nH); if (!bExternalBuffer) RELEASEARRAYOBJECTS(pBytes); @@ -1806,17 +1798,15 @@ namespace MetaFile m_pDC->SetPen(pPen); if (AD_COUNTERCLOCKWISE != m_pDC->GetArcDirection()) - { dSweepAngle = dSweepAngle - 360; - } TEmfPlusRectF oConvertedRect = GetConvertedRectangle(oRect); MoveTo(oConvertedRect.dX, oConvertedRect.dY); ArcTo(oConvertedRect.dX, oConvertedRect.dY, - oConvertedRect.dX + oConvertedRect.dWidth, - oConvertedRect.dY + oConvertedRect.dHeight, - dStartAngle, dSweepAngle); + oConvertedRect.dX + oConvertedRect.dWidth, + oConvertedRect.dY + oConvertedRect.dHeight, + dStartAngle, dSweepAngle); DrawPath(true, false); if (NULL != m_pInterpretator) @@ -2293,13 +2283,13 @@ namespace MetaFile if (NULL != m_pInterpretator) { - CPathConverter oPathConverter; - CPath oNewPath, oLineCapPath; - - oPathConverter.GetUpdatedPath(oNewPath, oLineCapPath, *pPath, *pEmfPlusPen); - if (InterpretatorType::Render == m_pInterpretator->GetType()) { + CPathConverter oPathConverter; + CPath oNewPath, oLineCapPath; + + oPathConverter.GetUpdatedPath(oNewPath, oLineCapPath, *pPath, *pEmfPlusPen); + oNewPath.DrawOn(m_pInterpretator, true, false); oLineCapPath.DrawOn(m_pInterpretator, false, true); } @@ -2836,7 +2826,7 @@ namespace MetaFile void CEmfPlusParser::Read_EMFPLUS_FILLREGION(unsigned short unShFlags) { - short shOgjectIndex = ExpressValue(unShFlags, 0, 7); + // short shOgjectIndex = ExpressValue(unShFlags, 0, 7); unsigned int unBrushId; m_oStream >> unBrushId; @@ -2995,34 +2985,34 @@ namespace MetaFile void CEmfPlusParser::Read_EMFPLUS_SETANTIALIASMODE(unsigned short unShFlags) { - short shSmoothingMode = ExpressValue(unShFlags, 1, 7); + // short shSmoothingMode = ExpressValue(unShFlags, 1, 7); //TODO: реализовать } void CEmfPlusParser::Read_EMFPLUS_SETCOMPOSITINGMODE(unsigned short unShFlags) { - short shCompositingMode = ExpressValue(unShFlags, 0, 7); + // short shCompositingMode = ExpressValue(unShFlags, 0, 7); //TODO: реализовать } void CEmfPlusParser::Read_EMFPLUS_SETCOMPOSITINGQUALITY(unsigned short unShFlags) { - short shCompositingQuality = ExpressValue(unShFlags, 0, 7); + // short shCompositingQuality = ExpressValue(unShFlags, 0, 7); //TODO: реализовать } void CEmfPlusParser::Read_EMFPLUS_SETINTERPOLATIONMODE(unsigned short unShFlags) { - short shInterpolationMode = ExpressValue(unShFlags, 0, 7); + // short shInterpolationMode = ExpressValue(unShFlags, 0, 7); //TODO: реализовать } void CEmfPlusParser::Read_EMFPLUS_SETPIXELOFFSETMODE(unsigned short unShFlags) { - short shPixelOffsetMode = ExpressValue(unShFlags, 0, 7); + // short shPixelOffsetMode = ExpressValue(unShFlags, 0, 7); //TODO: реализовать } @@ -3039,20 +3029,20 @@ namespace MetaFile void CEmfPlusParser::Read_EMFPLUS_SETTEXTCONTRAST(unsigned short unShFlags) { - short shTextContrast = ExpressValue(unShFlags, 0, 11); + // short shTextContrast = ExpressValue(unShFlags, 0, 11); //TODO: реализовать } void CEmfPlusParser::Read_EMRPLUS_SETTEXTRENDERINGHINT(unsigned short unShFlags) { - short shTextRenderingHint = ExpressValue(unShFlags, 0, 7); + // short shTextRenderingHint = ExpressValue(unShFlags, 0, 7); //TODO: реализовать } void CEmfPlusParser::Read_EMFPLUS_BEGINCONTAINER(unsigned short unShFlags) { - short shPageUnit = ExpressValue(unShFlags, 8, 15); + // short shPageUnit = ExpressValue(unShFlags, 8, 15); TEmfPlusRectF oDestRect, oSrcRect; unsigned int unStackIndex; diff --git a/DesktopEditor/raster/Metafile/Emf/EmfParser/CEmfPlusParser.h b/DesktopEditor/raster/Metafile/Emf/EmfParser/CEmfPlusParser.h index d78d497131..a1930b6e7e 100644 --- a/DesktopEditor/raster/Metafile/Emf/EmfParser/CEmfPlusParser.h +++ b/DesktopEditor/raster/Metafile/Emf/EmfParser/CEmfPlusParser.h @@ -1,8 +1,6 @@ #ifndef CEMFPLUSPARSER_H #define CEMFPLUSPARSER_H -//#include "../../Common/MetaFileUtils.h" -//#include "../../Common/MetaFile.h" #include "../EmfPlusObjects.h" #include "CEmfParserBase.h" #include "../EmfPlusTypes.h" diff --git a/DesktopEditor/raster/Metafile/Emf/EmfPlusTypes.h b/DesktopEditor/raster/Metafile/Emf/EmfPlusTypes.h index 0e49ce3500..421ee792b7 100644 --- a/DesktopEditor/raster/Metafile/Emf/EmfPlusTypes.h +++ b/DesktopEditor/raster/Metafile/Emf/EmfPlusTypes.h @@ -106,6 +106,16 @@ namespace MetaFile chRed = oARGB.chRed; chAlpha = oARGB.chAlpha; } + + TEmfPlusARGB& operator=(const TEmfPlusARGB& oARGB) + { + chBlue = oARGB.chBlue; + chGreen = oARGB.chGreen; + chRed = oARGB.chRed; + chAlpha = oARGB.chAlpha; + + return *this; + } }; struct TGUID diff --git a/DesktopEditor/raster/Metafile/StarView/SvmFile.cpp b/DesktopEditor/raster/Metafile/StarView/SvmFile.cpp index 1a95477427..05f1ffe372 100644 --- a/DesktopEditor/raster/Metafile/StarView/SvmFile.cpp +++ b/DesktopEditor/raster/Metafile/StarView/SvmFile.cpp @@ -266,6 +266,7 @@ void CSvmFile::Read_META_LINE() { case LINE_SOLID: last_pen->PenStyle = PS_SOLID ; break; case LINE_DASH: last_pen->PenStyle = PS_DASH ; break; + default: break; } } } @@ -323,6 +324,7 @@ void CSvmFile::Read_META_POLYLINE() { case LINE_SOLID: last_pen->PenStyle = PS_SOLID ; break; case LINE_DASH: last_pen->PenStyle = PS_DASH ; break; + default: break; } if (last_pen->Width < 1) diff --git a/DesktopEditor/raster/Metafile/Wmf/WmfInterpretator/CWmfInterpretatorSvg.cpp b/DesktopEditor/raster/Metafile/Wmf/WmfInterpretator/CWmfInterpretatorSvg.cpp index 0201d9d9dd..c15aed926b 100644 --- a/DesktopEditor/raster/Metafile/Wmf/WmfInterpretator/CWmfInterpretatorSvg.cpp +++ b/DesktopEditor/raster/Metafile/Wmf/WmfInterpretator/CWmfInterpretatorSvg.cpp @@ -153,7 +153,13 @@ namespace MetaFile const std::wstring wsText{ConvertToUnicode(pString, (long)shStringLength, (NULL != pFont) ? pFont->GetCharSet() : DEFAULT_CHARSET)}; - TPointD oScale((m_pParser->IsWindowFlippedX()) ? -1 : 1, (m_pParser->IsWindowFlippedY()) ? -1 : 1); + TPointD oScale(1, 1); + + if (NULL != m_pParser) + { + oScale.X = m_pParser->IsWindowFlippedX() ? -1 : 1; + oScale.Y = m_pParser->IsWindowFlippedY() ? -1 : 1; + } std::vector arDx(0); diff --git a/DesktopEditor/raster/Metafile/Wmf/WmfParser/CWmfParser.cpp b/DesktopEditor/raster/Metafile/Wmf/WmfParser/CWmfParser.cpp index 214b314d83..cada341c75 100644 --- a/DesktopEditor/raster/Metafile/Wmf/WmfParser/CWmfParser.cpp +++ b/DesktopEditor/raster/Metafile/Wmf/WmfParser/CWmfParser.cpp @@ -298,7 +298,7 @@ namespace MetaFile m_oStream >> oBitmap; unsigned int unRecordSizeDWORD = m_unRecordSize >> 1; - unsigned int unValue = (META_STRETCHBLT >> 8) + 3; + // unsigned int unValue = (META_STRETCHBLT >> 8) + 3; if (unRecordSizeDWORD == ((META_STRETCHBLT >> 8) + 3)) { diff --git a/DesktopEditor/raster/Metafile/Wmf/WmfParser/CWmfParserBase.cpp b/DesktopEditor/raster/Metafile/Wmf/WmfParser/CWmfParserBase.cpp index c0d82821f1..5dd8d104a7 100644 --- a/DesktopEditor/raster/Metafile/Wmf/WmfParser/CWmfParserBase.cpp +++ b/DesktopEditor/raster/Metafile/Wmf/WmfParser/CWmfParserBase.cpp @@ -241,10 +241,10 @@ namespace MetaFile { const double dKoef = 96. / (double)m_oPlaceable.ushInch; - m_oDCRect.Left = std::round(m_oDCRect.Left * dKoef); - m_oDCRect.Top = std::round(m_oDCRect.Top * dKoef); - m_oDCRect.Right = std::round(m_oDCRect.Right * dKoef); - m_oDCRect.Bottom = std::round(m_oDCRect.Bottom * dKoef); + m_oDCRect.Left = static_cast(std::round(m_oDCRect.Left * dKoef)); + m_oDCRect.Top = static_cast(std::round(m_oDCRect.Top * dKoef)); + m_oDCRect.Right = static_cast(std::round(m_oDCRect.Right * dKoef)); + m_oDCRect.Bottom = static_cast(std::round(m_oDCRect.Bottom * dKoef)); } // Иногда m_oPlaceable.BoundingBox задается нулевой ширины и высоты @@ -292,6 +292,16 @@ namespace MetaFile m_pDC->SetCurPos(shX, shY); } + void CWmfParserBase::MoveToD(double dX, double dY) + { + if (NULL != m_pInterpretator) + m_pInterpretator->MoveTo(dX, dY); + else + RegisterPoint(static_cast(dX), static_cast(dY)); + + m_pDC->SetCurPos(static_cast(dX), static_cast(dY)); + } + void CWmfParserBase::LineTo(short shX, short shY) { if (NULL != m_pInterpretator) @@ -396,7 +406,7 @@ namespace MetaFile NSFonts::IFontManager* pFontManager = GetFontManager(); if (pFontManager) { - int lLogicalFontHeight = pFont->GetHeight(); + int lLogicalFontHeight = static_cast(pFont->GetHeight()); if (lLogicalFontHeight < 0) lLogicalFontHeight = -lLogicalFontHeight; if (lLogicalFontHeight < 0.01) @@ -444,8 +454,8 @@ namespace MetaFile { pFontManager->LoadString1(wsText, 0, 0); TBBox oBox = pFontManager->MeasureString2(); - fL = (float)(oBox.fMinX); - fW = (float)(oBox.fMaxX - oBox.fMinX); + fL = static_cast(oBox.fMinX); + fW = static_cast(oBox.fMaxX - oBox.fMinX); } pFontManager->LoadString1(wsText, 0, 0); @@ -520,7 +530,7 @@ namespace MetaFile } else { - int lLogicalFontHeight = pFont->GetHeight(); + int lLogicalFontHeight = static_cast(pFont->GetHeight()); if (lLogicalFontHeight < 0) lLogicalFontHeight = -lLogicalFontHeight; if (lLogicalFontHeight < 0.01) @@ -548,7 +558,7 @@ namespace MetaFile fW = (float)(dFontHeight * wsText.length()); } - fH = dFontHeight * 1.2; + fH = (float)dFontHeight * 1.2f; double dTheta = -((((double)pFont->GetEscapement()) / 10) * 3.14159265358979323846 / 180); double dCosTheta = (float)cos(dTheta); @@ -724,17 +734,17 @@ namespace MetaFile oNewRect.Top < 0 || oNewRect.Bottom < 0) return NULL; - if (unHeight < (oNewRect.Bottom - oNewRect.Top)) - oNewRect.Bottom = oNewRect.Top + unWidth; + if (unHeight < static_cast(std::abs(oNewRect.Bottom - oNewRect.Top))) + oNewRect.Bottom = oNewRect.Top + unHeight; - if (unWidth < (oNewRect.Right - oNewRect.Left)) + if (unWidth < static_cast(std::abs(oNewRect.Right - oNewRect.Left))) oNewRect.Right = oNewRect.Left + unWidth; if (unHeight == (oNewRect.Bottom - oNewRect.Top) && unWidth == (oNewRect.Right - oNewRect.Left)) return NULL; - int nBeginX, nBeginY, nEndX, nEndY; + ULONG nBeginX, nBeginY, nEndX, nEndY; nBeginX = (std::min)(oNewRect.Left, oNewRect.Right); nBeginY = (std::min)(oNewRect.Top, oNewRect.Bottom); @@ -924,7 +934,7 @@ namespace MetaFile double dSweepAngle = GetSweepAngle(dStartAngle, dEndAngle); - MoveTo(dX1, dY1); + MoveToD(dX1, dY1); ArcTo(shLeft, shTop, shRight, shBottom, dStartAngle, dSweepAngle); DrawPath(true, false); } diff --git a/DesktopEditor/raster/Metafile/Wmf/WmfParser/CWmfParserBase.h b/DesktopEditor/raster/Metafile/Wmf/WmfParser/CWmfParserBase.h index 5716462b35..b1d7f8f58b 100644 --- a/DesktopEditor/raster/Metafile/Wmf/WmfParser/CWmfParserBase.h +++ b/DesktopEditor/raster/Metafile/Wmf/WmfParser/CWmfParserBase.h @@ -188,6 +188,7 @@ namespace MetaFile inline double GetSweepAngle(const double& dStartAngle, const double& dEndAngle) const; void MoveTo(short shX, short shY); + void MoveToD(double dX, double dY); void LineTo(short shX, short shY); void ArcTo(short shL, short shT, short shR, short shB, double dStart, double dSweep); void ClosePath(); From f145378002d5aa43630afac9353f52f520147b25 Mon Sep 17 00:00:00 2001 From: ElenaSubbotina Date: Wed, 12 Feb 2025 15:35:26 +0300 Subject: [PATCH 07/21] fix additional sdtPr --- OOXML/Binary/Document/BinReader/Readers.cpp | 19 +++- OOXML/Binary/Document/BinReader/Readers.h | 2 +- .../Binary/Document/BinWriter/BinWriters.cpp | 18 ++- OOXML/Common/ComplexTypes.cpp | 17 ++- OOXML/Common/ComplexTypes.h | 5 +- OOXML/Common/SimpleTypes_Word.cpp | 105 +++++++----------- OOXML/Common/SimpleTypes_Word.h | 10 +- OOXML/DocxFormat/Logic/Sdt.cpp | 4 +- OOXML/DocxFormat/WritingElement.h | 10 +- 9 files changed, 105 insertions(+), 85 deletions(-) diff --git a/OOXML/Binary/Document/BinReader/Readers.cpp b/OOXML/Binary/Document/BinReader/Readers.cpp index b647412ef3..e1210e711d 100644 --- a/OOXML/Binary/Document/BinReader/Readers.cpp +++ b/OOXML/Binary/Document/BinReader/Readers.cpp @@ -260,15 +260,21 @@ docRGB Binary_CommonReader2::ReadColor() oRGB.B = m_oBufferedStream.GetUChar(); return oRGB; } -void Binary_CommonReader2::ReadHexColor(SimpleTypes::CHexColor *pColor) +void Binary_CommonReader2::ReadHexColor(SimpleTypes::CHexColor *pColor, long length) { if (!pColor) { - m_oBufferedStream.Skip(3); + m_oBufferedStream.Skip(length); return; } - pColor->SetValue(SimpleTypes::hexcolorRGB); + + if (length == 4) + { + pColor->SetValue(SimpleTypes::hexcolorARGB); + + pColor->Set_A(m_oBufferedStream.GetUChar()); + } pColor->Set_R(m_oBufferedStream.GetUChar()); pColor->Set_G(m_oBufferedStream.GetUChar()); @@ -341,7 +347,7 @@ int Binary_CommonReader2::ReadShdComplexType(BYTE type, long length, void* poRes case c_oSerShdType::Color: { pShd->m_oColor.Init(); - ReadHexColor(pShd->m_oColor.GetPointer()); + ReadHexColor(pShd->m_oColor.GetPointer(), length); }break; case c_oSerShdType::ColorTheme: { @@ -352,7 +358,7 @@ int Binary_CommonReader2::ReadShdComplexType(BYTE type, long length, void* poRes case c_oSerShdType::Fill: { pShd->m_oFill.Init(); - ReadHexColor(pShd->m_oFill.GetPointer()); + ReadHexColor(pShd->m_oFill.GetPointer(), length); }break; case c_oSerShdType::FillTheme: { @@ -1339,7 +1345,8 @@ int Binary_pPrReader::ReadBorder(BYTE type, long length, void* poResult) { pBorder->m_oColor.Init(); pBorder->m_oColor->SetValue(SimpleTypes::hexcolorRGB); - oBinary_CommonReader2.ReadHexColor(pBorder->m_oColor.GetPointer()); + + oBinary_CommonReader2.ReadHexColor(pBorder->m_oColor.GetPointer(), length); } else if ( c_oSerBorderType::Space == type ) { diff --git a/OOXML/Binary/Document/BinReader/Readers.h b/OOXML/Binary/Document/BinReader/Readers.h index a396a04931..1f48e6d4ac 100644 --- a/OOXML/Binary/Document/BinReader/Readers.h +++ b/OOXML/Binary/Document/BinReader/Readers.h @@ -57,7 +57,7 @@ class Binary_CommonReader2 : public Binary_CommonReader public: Binary_CommonReader2(NSBinPptxRW::CBinaryFileReader& poBufferedStream); docRGB ReadColor(); - void ReadHexColor(SimpleTypes::CHexColor *pColor); + void ReadHexColor(SimpleTypes::CHexColor *pColor, long length); void ReadThemeColor(int length, CThemeColor& oCThemeColor); int ReadThemeColorContent(BYTE type, long length, void* poResult); template int ReadTrackRevision(long length, T* poResult); diff --git a/OOXML/Binary/Document/BinWriter/BinWriters.cpp b/OOXML/Binary/Document/BinWriter/BinWriters.cpp index bbba33bc4c..3a2210edf8 100644 --- a/OOXML/Binary/Document/BinWriter/BinWriters.cpp +++ b/OOXML/Binary/Document/BinWriter/BinWriters.cpp @@ -153,11 +153,12 @@ void BinaryCommonWriter::WriteBorder(const BYTE & type, const ComplexTypes::Word } void BinaryCommonWriter::WriteBorder(const ComplexTypes::Word::CBorder& border) {//todooo сделать все типы бордера - if (border.m_oVal.IsInit()) - { - if (border.m_oColor.IsInit()) - WriteColor(c_oSerBorderType::Color, border.m_oColor.get()); + if (border.m_oColor.IsInit()) + WriteColor(c_oSerBorderType::Color, border.m_oColor.get()); + + if (border.m_oVal.IsInit()) + { WriteThemeColor(c_oSerBorderType::ColorTheme, border.m_oColor, border.m_oThemeColor, border.m_oThemeTint, border.m_oThemeShade); if (border.m_oSpace.IsInit()) @@ -295,6 +296,15 @@ void BinaryCommonWriter::WriteColor(BYTE type, const SimpleTypes::CHexColor& col m_oStream.WriteBYTE(color.Get_G()); m_oStream.WriteBYTE(color.Get_B()); } + else if (SimpleTypes::hexcolorARGB == color.GetValue()) + { + m_oStream.WriteBYTE(type); + m_oStream.WriteBYTE(c_oSerPropLenType::Long); + m_oStream.WriteBYTE(color.Get_A()); + m_oStream.WriteBYTE(color.Get_R()); + m_oStream.WriteBYTE(color.Get_G()); + m_oStream.WriteBYTE(color.Get_B()); + } } void BinaryCommonWriter::WriteThemeColor(BYTE type, const nullable& oHexColor, const nullable& oThemeColor, const nullable& oThemeTint, const nullable& oThemeShade) diff --git a/OOXML/Common/ComplexTypes.cpp b/OOXML/Common/ComplexTypes.cpp index e31d7ad1b1..a909bb481b 100644 --- a/OOXML/Common/ComplexTypes.cpp +++ b/OOXML/Common/ComplexTypes.cpp @@ -115,6 +115,10 @@ namespace Word oReader.ReadTillEnd(); } std::wstring CBorder::ToString() const + { + return ToString(true); + } + std::wstring CBorder::ToString(bool noAlpha) const { std::wstring sResult; @@ -127,7 +131,7 @@ namespace Word if ( m_oColor.IsInit() ) { sResult += L"w:color=\""; - sResult += m_oColor->ToStringNoAlpha(); + sResult += noAlpha ? m_oColor->ToStringNoAlpha() : m_oColor->ToString(); sResult += L"\" "; } if (m_oThemeColor.IsInit()) @@ -437,6 +441,10 @@ namespace Word oReader.ReadTillEnd(); } std::wstring CShading::ToString() const + { + return ToString(true); + } + std::wstring CShading::ToString(bool noAlpha) const { std::wstring sResult; @@ -446,13 +454,13 @@ namespace Word sResult += m_oVal->ToString(); sResult += L"\" "; } - if ( m_oColor.IsInit() ) + if (m_oColor.IsInit()) { sResult += L"w:color=\""; - sResult += m_oColor->ToStringNoAlpha(); + sResult += noAlpha ? m_oColor->ToStringNoAlpha() : m_oColor->ToString(); sResult += L"\" "; } - if ( m_oThemeColor.IsInit() ) + if (m_oThemeColor.IsInit()) { sResult += L"w:themeColor=\""; sResult += m_oThemeColor->ToString(); @@ -496,7 +504,6 @@ namespace Word } return sResult; } - void CShading::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) { WritingElement_ReadAttributes_Start( oReader ) diff --git a/OOXML/Common/ComplexTypes.h b/OOXML/Common/ComplexTypes.h index b8e3b5dd2f..ea14aa1fc3 100644 --- a/OOXML/Common/ComplexTypes.h +++ b/OOXML/Common/ComplexTypes.h @@ -140,7 +140,8 @@ namespace ComplexTypes virtual void FromXML(XmlUtils::CXmlNode& oNode); virtual void FromXML(XmlUtils::CXmlLiteReader& oReader); virtual std::wstring ToString() const; - + + std::wstring ToString(bool noAlpha) const; private: void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); @@ -245,6 +246,8 @@ namespace ComplexTypes virtual void FromXML(XmlUtils::CXmlNode& oNode); virtual void FromXML(XmlUtils::CXmlLiteReader& oReader); virtual std::wstring ToString() const; + + std::wstring ToString(bool noAlpha) const; private: void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); diff --git a/OOXML/Common/SimpleTypes_Word.cpp b/OOXML/Common/SimpleTypes_Word.cpp index 2233a9926f..2b546cd0bf 100644 --- a/OOXML/Common/SimpleTypes_Word.cpp +++ b/OOXML/Common/SimpleTypes_Word.cpp @@ -1757,9 +1757,11 @@ namespace SimpleTypes /// - CHexColor::CHexColor(unsigned char r, unsigned char g, unsigned char b) + CHexColor::CHexColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a) { this->m_eValue = hexcolorRGB; + + m_unA = a; m_unR = r; m_unG = g; m_unB = b; @@ -1779,9 +1781,19 @@ namespace SimpleTypes if ( m_sValue.length() < 6 ) return; - m_unR = HexToInt( (int)m_sValue[1] ) + (unsigned char)(HexToInt( (int)m_sValue[0] ) << 4); - m_unG = HexToInt( (int)m_sValue[3] ) + (unsigned char)(HexToInt( (int)m_sValue[2] ) << 4); - m_unB = HexToInt( (int)m_sValue[5] ) + (unsigned char)(HexToInt( (int)m_sValue[4] ) << 4); + if (m_sValue.length() > 6) + { + m_unA = HexToInt((int)m_sValue[1]) + (unsigned char)(HexToInt((int)m_sValue[0]) << 4); + m_unR = HexToInt((int)m_sValue[3]) + (unsigned char)(HexToInt((int)m_sValue[2]) << 4); + m_unG = HexToInt((int)m_sValue[5]) + (unsigned char)(HexToInt((int)m_sValue[4]) << 4); + m_unB = HexToInt((int)m_sValue[7]) + (unsigned char)(HexToInt((int)m_sValue[6]) << 4); + } + else + { + m_unR = HexToInt((int)m_sValue[1]) + (unsigned char)(HexToInt((int)m_sValue[0]) << 4); + m_unG = HexToInt((int)m_sValue[3]) + (unsigned char)(HexToInt((int)m_sValue[2]) << 4); + m_unB = HexToInt((int)m_sValue[5]) + (unsigned char)(HexToInt((int)m_sValue[4]) << 4); + } } void CHexColor::Parse3() @@ -1823,8 +1835,8 @@ namespace SimpleTypes } else if (8 <= sValue.length()) { - this->m_eValue = hexcolorRGB; - m_sValue = sValue.substr(2, 6); + this->m_eValue = hexcolorARGB; + m_sValue = sValue.substr(0, 8); Parse(); } else if ( 6 <= sValue.length() ) @@ -1842,52 +1854,20 @@ namespace SimpleTypes else this->m_eValue = EHexColor::hexcolorAuto;//eDefValue; } - return this->m_eValue; } - /* - template<> - EHexColor CHexColor::FromString(const std::wstring &sValue) - { - if ( _T("auto") == sValue || _T("none") == sValue ) - this->m_eValue = hexcolorAuto; - else - { - //В документации не написано, что цвет может приходить строкой, но в реальных докуентах встречается и word это разруливает. - //CHighlightColor oHighlightColor(sValue); - CPresetColorVal<> oPresetColorVal; - if(oPresetColorVal.FromStringIgnoreCase(sValue)) - { - this->m_eValue = hexcolorRGB; - m_unR = oPresetColorVal.Get_R(); - m_unG = oPresetColorVal.Get_G(); - m_unB = oPresetColorVal.Get_B(); - } - else if ( 6 <= sValue.length() ) - { - this->m_eValue = hexcolorRGB; - m_sValue = sValue.substr( 0, 6 ); - Parse(); - } - else if ( 3 == sValue.length() )// a la #339 (Compo 3AP.docx) - { - this->m_eValue = hexcolorRGB; - m_sValue = sValue; - Parse3(); - } - else this->m_eValue = EHexColor::hexcolorAuto;//eDefValue; - - } - - return this->m_eValue; - } - */ - - std::wstring CHexColor::ToString () const + std::wstring CHexColor::ToString () const { switch(this->m_eValue) { + case hexcolorARGB: + { + std::wstringstream sstream; + sstream << boost::wformat(L"%02x%02x%02x%02x") % m_unA % m_unR % m_unG % m_unB; + + return sstream.str(); + } case hexcolorRGB : { std::wstringstream sstream; @@ -1901,42 +1881,43 @@ namespace SimpleTypes } } - std::wstring CHexColor::ToStringNoAlpha () const + std::wstring CHexColor::ToStringNoAlpha () const { - switch(this->m_eValue) + switch (this->m_eValue) { - case hexcolorRGB : - { - std::wstringstream sstream; - sstream << boost::wformat( L"%02x%02x%02x" ) % m_unR % m_unG % m_unB; + case hexcolorARGB: + case hexcolorRGB: + { + std::wstringstream sstream; + sstream << boost::wformat(L"%02x%02x%02x") % m_unR % m_unG % m_unB; - return sstream.str(); + return sstream.str(); + } + case hexcolorAuto: + default: + return (L"auto"); } - case hexcolorAuto : - default : - return (L"auto"); } } - + void CHexColor::Set_A(unsigned char A) + { + m_unA = A; + } void CHexColor::Set_R(unsigned char R) { m_unR = R; } - void CHexColor::Set_G(unsigned char G) { m_unG = G; } - void CHexColor::Set_B(unsigned char B) { m_unB = B; } - unsigned char CHexColor::Get_R() const { return m_unR; } - unsigned char CHexColor::Get_G() const { return m_unG; @@ -1949,7 +1930,7 @@ namespace SimpleTypes unsigned char CHexColor::Get_A() const { - return 255; + return m_unA; } //-------------------------------------------------------------------------------- diff --git a/OOXML/Common/SimpleTypes_Word.h b/OOXML/Common/SimpleTypes_Word.h index e882f73610..cc5ce6b646 100644 --- a/OOXML/Common/SimpleTypes_Word.h +++ b/OOXML/Common/SimpleTypes_Word.h @@ -847,7 +847,9 @@ namespace SimpleTypes enum EHexColor { hexcolorAuto = 0, - hexcolorRGB = 1 + hexcolorRGB = 1, + hexcolorARGB = 2 + }; //-------------------------------------------------------------------------------- @@ -877,10 +879,11 @@ namespace SimpleTypes DEFINE_SIMPLE_TYPE_START(CHexColor, EHexColor, hexcolorAuto) public: - CHexColor(unsigned char r, unsigned char g, unsigned char b); + CHexColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a = 255); - std::wstring ToStringNoAlpha () const; + std::wstring ToStringNoAlpha () const; + void Set_A(unsigned char R); void Set_R(unsigned char R); void Set_G(unsigned char G); void Set_B(unsigned char B); @@ -896,6 +899,7 @@ namespace SimpleTypes std::wstring m_sValue; + unsigned char m_unA = 255; unsigned char m_unR = 0; unsigned char m_unG = 0; unsigned char m_unB = 0; diff --git a/OOXML/DocxFormat/Logic/Sdt.cpp b/OOXML/DocxFormat/Logic/Sdt.cpp index fdc8a97069..7537129921 100644 --- a/OOXML/DocxFormat/Logic/Sdt.cpp +++ b/OOXML/DocxFormat/Logic/Sdt.cpp @@ -1635,8 +1635,8 @@ namespace OOX WritingElement_WriteNode_2(m_oFormPr); WritingElement_WriteNode_2(m_oTextFormPr); WritingElement_WriteNode_2(m_oComplexFormPr); - WritingElement_WriteNode_1(L"toXML(); - //----------------------------------------------------------------------------------------------- + +#define WritingElement_WriteNode_3( sStartNodeString, oValue ) \ + if ( oValue.IsInit() )\ + {\ + sResult += sStartNodeString;\ + sResult += oValue->ToString(false);\ + sResult += _T("/>");\ +} +//----------------------------------------------------------------------------------------------- #define WritingElement_ReadAttributes_ReadSingle2(Reader, AttrName, Value) \ if ( Reader.GetAttributesCount() > 0 ){\ if ( Reader.MoveToFirstAttribute() ){\ From a93db0e01273403649bdeb55cbcedd65d6065029 Mon Sep 17 00:00:00 2001 From: ElenaSubbotina Date: Wed, 12 Feb 2025 18:15:00 +0300 Subject: [PATCH 08/21] . --- OOXML/Common/SimpleTypes_Word.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/OOXML/Common/SimpleTypes_Word.cpp b/OOXML/Common/SimpleTypes_Word.cpp index 2b546cd0bf..c8184b6fb5 100644 --- a/OOXML/Common/SimpleTypes_Word.cpp +++ b/OOXML/Common/SimpleTypes_Word.cpp @@ -1783,10 +1783,10 @@ namespace SimpleTypes if (m_sValue.length() > 6) { - m_unA = HexToInt((int)m_sValue[1]) + (unsigned char)(HexToInt((int)m_sValue[0]) << 4); - m_unR = HexToInt((int)m_sValue[3]) + (unsigned char)(HexToInt((int)m_sValue[2]) << 4); - m_unG = HexToInt((int)m_sValue[5]) + (unsigned char)(HexToInt((int)m_sValue[4]) << 4); - m_unB = HexToInt((int)m_sValue[7]) + (unsigned char)(HexToInt((int)m_sValue[6]) << 4); + m_unR = HexToInt((int)m_sValue[1]) + (unsigned char)(HexToInt((int)m_sValue[0]) << 4); + m_unG = HexToInt((int)m_sValue[3]) + (unsigned char)(HexToInt((int)m_sValue[2]) << 4); + m_unB = HexToInt((int)m_sValue[5]) + (unsigned char)(HexToInt((int)m_sValue[4]) << 4); + m_unA = HexToInt((int)m_sValue[7]) + (unsigned char)(HexToInt((int)m_sValue[6]) << 4); } else { @@ -1864,7 +1864,7 @@ namespace SimpleTypes case hexcolorARGB: { std::wstringstream sstream; - sstream << boost::wformat(L"%02x%02x%02x%02x") % m_unA % m_unR % m_unG % m_unB; + sstream << boost::wformat(L"%02x%02x%02x%02x") % m_unR % m_unG % m_unB % m_unA; return sstream.str(); } From 5bc1c8d8609e7dac5935ea4d00f1e4ff8ea86f3e Mon Sep 17 00:00:00 2001 From: ElenaSubbotina Date: Thu, 13 Feb 2025 15:12:58 +0300 Subject: [PATCH 09/21] fix bug #73215 --- OdfFile/Writer/Converter/MathConverter.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/OdfFile/Writer/Converter/MathConverter.cpp b/OdfFile/Writer/Converter/MathConverter.cpp index afb155f1f2..293d47479e 100644 --- a/OdfFile/Writer/Converter/MathConverter.cpp +++ b/OdfFile/Writer/Converter/MathConverter.cpp @@ -177,7 +177,7 @@ namespace Oox2Odf int base_font_size = current_font_size.empty() ? 12 : current_font_size.back(); std::wstring base_font_color; - if (odf_context()->is_child_text_context()) + if (odf_context()->is_child_text_context() && odf_context()->drawing_context()) { if (odf_context()->drawing_context()->get_text_properties()) { @@ -187,6 +187,16 @@ namespace Oox2Odf } } } + else + { + if (odf_context()->text_context()->get_text_properties()) + { + if (odf_context()->text_context()->get_text_properties()->fo_color_) + { + base_font_color = odf_context()->drawing_context()->get_text_properties()->fo_color_->get_hex_value(); + } + } + } bool bStart = odf_context()->start_math(base_font_size, base_font_color); for (size_t i = 0; i < oox_math->m_arrItems.size(); ++i) From e484db496b3a9fcb950001a4b5690ec0a5a4e0b7 Mon Sep 17 00:00:00 2001 From: ElenaSubbotina Date: Thu, 13 Feb 2025 15:14:51 +0300 Subject: [PATCH 10/21] . --- OdfFile/Writer/Converter/MathConverter.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/OdfFile/Writer/Converter/MathConverter.cpp b/OdfFile/Writer/Converter/MathConverter.cpp index 293d47479e..c29992fc87 100644 --- a/OdfFile/Writer/Converter/MathConverter.cpp +++ b/OdfFile/Writer/Converter/MathConverter.cpp @@ -264,7 +264,7 @@ namespace Oox2Odf int base_font_size = current_font_size.empty() ? 12 : current_font_size.back(); std::wstring base_font_color; - if (odf_context()->is_child_text_context()) + if (odf_context()->is_child_text_context() && odf_context()->drawing_context()) { if (odf_context()->drawing_context()->get_text_properties()) { @@ -274,7 +274,16 @@ namespace Oox2Odf } } } - + else + { + if (odf_context()->text_context()->get_text_properties()) + { + if (odf_context()->text_context()->get_text_properties()->fo_color_) + { + base_font_color = odf_context()->drawing_context()->get_text_properties()->fo_color_->get_hex_value(); + } + } + } bool bStart = odf_context()->start_math(base_font_size, base_font_color); for (size_t i = 0; i < oox_math_para->m_arrItems.size(); ++i) From 1f86b0265acfcb466a65e59378309e18d736cdf1 Mon Sep 17 00:00:00 2001 From: Kamil Kerimov Date: Thu, 13 Feb 2025 18:20:31 +0500 Subject: [PATCH 11/21] Fix bug #72871 --- OdfFile/Reader/Format/note.cpp | 8 ++++---- OdfFile/Reader/Format/paragraph_elements.cpp | 8 +++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/OdfFile/Reader/Format/note.cpp b/OdfFile/Reader/Format/note.cpp index 98b369c891..c57ae3aee3 100644 --- a/OdfFile/Reader/Format/note.cpp +++ b/OdfFile/Reader/Format/note.cpp @@ -79,10 +79,10 @@ void note_citation::add_space(const std::wstring & Text) } void note_citation::docx_convert(oox::docx_conversion_context & Context) { - for (size_t i = 0; i < content_.size(); i++) - { - content_[i]->docx_convert(Context); - } + //for (size_t i = 0; i < content_.size(); i++) + // { + // content_[i]->docx_convert(Context); + // } } // text:note-body diff --git a/OdfFile/Reader/Format/paragraph_elements.cpp b/OdfFile/Reader/Format/paragraph_elements.cpp index 0eb0d42d99..a146a0dd44 100644 --- a/OdfFile/Reader/Format/paragraph_elements.cpp +++ b/OdfFile/Reader/Format/paragraph_elements.cpp @@ -999,11 +999,17 @@ void note::docx_convert(oox::docx_conversion_context & Context) if (text_note_class_.get_type() == noteclass::Footnote) { - Context.output_stream() << ""; + Context.output_stream() << L""; + Context.output_stream() << L""; + Context.output_stream() << L""; + + Context.output_stream() << ""; + Context.add_new_run(); } else { Context.output_stream() << ""; + Context.add_new_run(); } if (text_note_citation_) From ddd7628bbe46d60d25bc82a7a3a80e1aa39156e7 Mon Sep 17 00:00:00 2001 From: ElenaSubbotina Date: Thu, 13 Feb 2025 17:48:33 +0300 Subject: [PATCH 12/21] fix bug #73097 --- OdfFile/Reader/Format/calcs_styles.cpp | 8 ++++---- OdfFile/Reader/Format/calcs_styles.h | 4 ++-- OdfFile/Reader/Format/draw_frame.cpp | 2 +- OdfFile/Reader/Format/draw_frame_pptx.cpp | 5 +++-- OdfFile/Reader/Format/style_graphic_properties.cpp | 2 ++ OdfFile/Reader/Format/style_graphic_properties.h | 2 ++ 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/OdfFile/Reader/Format/calcs_styles.cpp b/OdfFile/Reader/Format/calcs_styles.cpp index f0b300f6dc..ae607cbe86 100644 --- a/OdfFile/Reader/Format/calcs_styles.cpp +++ b/OdfFile/Reader/Format/calcs_styles.cpp @@ -105,7 +105,7 @@ graphic_format_properties_ptr calc_graphic_properties_content(const std::vector< return result; } -graphic_format_properties_ptr calc_graphic_properties_content(const style_instance * styleInstance) +graphic_format_properties_ptr calc_graphic_properties_content(const style_instance * styleInstance, bool noParents) { if (!styleInstance) return graphic_format_properties_ptr(); @@ -118,12 +118,12 @@ graphic_format_properties_ptr calc_graphic_properties_content(const style_instan graphicProps.insert(graphicProps.begin(), graphicProp); } - styleInstance = styleInstance->parent(); + styleInstance = noParents ? NULL : styleInstance->parent(); } return calc_graphic_properties_content(graphicProps); } -graphic_format_properties_ptr calc_graphic_properties_content(const std::vector & styleInstances) +graphic_format_properties_ptr calc_graphic_properties_content(const std::vector & styleInstances, bool noParents) { if (styleInstances.empty()) return graphic_format_properties_ptr(); @@ -131,7 +131,7 @@ graphic_format_properties_ptr calc_graphic_properties_content(const std::vector< for (size_t i = 0; i < styleInstances.size(); i++) { - graphic_format_properties_ptr f = calc_graphic_properties_content(styleInstances[i]); + graphic_format_properties_ptr f = calc_graphic_properties_content(styleInstances[i], noParents); result->apply_from(f.get()); } return result; diff --git a/OdfFile/Reader/Format/calcs_styles.h b/OdfFile/Reader/Format/calcs_styles.h index 0ff9b5ddcd..a6171f42f0 100644 --- a/OdfFile/Reader/Format/calcs_styles.h +++ b/OdfFile/Reader/Format/calcs_styles.h @@ -48,8 +48,8 @@ namespace cpdoccore } namespace odf_reader { - graphic_format_properties_ptr calc_graphic_properties_content(const style_instance * styleInstance); - graphic_format_properties_ptr calc_graphic_properties_content(const std::vector & styleInstances); + graphic_format_properties_ptr calc_graphic_properties_content(const style_instance* styleInstance, bool noParents = false); + graphic_format_properties_ptr calc_graphic_properties_content(const std::vector & styleInstances, bool noParents = false); text_format_properties_ptr calc_text_properties_content(const style_instance * styleInstance); text_format_properties_ptr calc_text_properties_content(const std::vector & styleInstances); diff --git a/OdfFile/Reader/Format/draw_frame.cpp b/OdfFile/Reader/Format/draw_frame.cpp index ea19a7edbb..8ccaecf2bb 100644 --- a/OdfFile/Reader/Format/draw_frame.cpp +++ b/OdfFile/Reader/Format/draw_frame.cpp @@ -268,7 +268,7 @@ void draw_frame::add_attributes( const xml::attributes_wc_ptr & Attributes ) void draw_frame::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name) { if (CP_CHECK_NAME(L"draw", L"text-box") || - CP_CHECK_NAME(L"draw", L"image") ||//копия объекта в виде картинки ну.. или просто картинка + CP_CHECK_NAME(L"draw", L"image") || CP_CHECK_NAME(L"table", L"table") || CP_CHECK_NAME(L"draw", L"object-ole")|| CP_CHECK_NAME(L"draw", L"applet") || diff --git a/OdfFile/Reader/Format/draw_frame_pptx.cpp b/OdfFile/Reader/Format/draw_frame_pptx.cpp index 179d3ab8f3..7f65e5600c 100644 --- a/OdfFile/Reader/Format/draw_frame_pptx.cpp +++ b/OdfFile/Reader/Format/draw_frame_pptx.cpp @@ -172,12 +172,13 @@ void draw_frame::pptx_convert(oox::pptx_conversion_context & Context) } oox::_oox_fill fill; - graphic_format_properties_ptr properties = calc_graphic_properties_content(instances); + graphic_format_properties_ptr properties = calc_graphic_properties_content(instances, is_object_); if (properties) { properties->apply_to(Context.get_slide_context().get_properties()); Compute_GraphicFill(properties->common_draw_fill_attlist_, properties->style_background_image_, Context.root(), fill); + if (properties->fo_clip_) { std::wstring strRectClip = properties->fo_clip_.get(); @@ -403,7 +404,7 @@ void draw_text_box::pptx_convert(oox::pptx_conversion_context & Context) } void draw_object::pptx_convert(oox::pptx_conversion_context & Context) { - if (draw_frame_ptr) + if (draw_frame_ptr) { draw_frame *frame = dynamic_cast(draw_frame_ptr.get()); if (frame) diff --git a/OdfFile/Reader/Format/style_graphic_properties.cpp b/OdfFile/Reader/Format/style_graphic_properties.cpp index 485c2b29d2..d4f50c12d9 100644 --- a/OdfFile/Reader/Format/style_graphic_properties.cpp +++ b/OdfFile/Reader/Format/style_graphic_properties.cpp @@ -55,6 +55,7 @@ void graphic_format_properties::add_attributes( const xml::attributes_wc_ptr & A CP_APPLY_ATTR(L"draw:fit-to-contour", draw_fit_to_contour_); CP_APPLY_ATTR(L"style:shrink-to-fit", style_shrink_to_fit_); CP_APPLY_ATTR(L"draw:fit-to-size", draw_fit_to_size_str_); + CP_APPLY_ATTR(L"draw:ole-draw-aspect", draw_ole_draw_aspect_); CP_APPLY_ATTR(L"draw:stroke", draw_stroke_); CP_APPLY_ATTR(L"draw:stroke-dash", draw_stroke_dash_); @@ -205,6 +206,7 @@ void graphic_format_properties::apply_from(const graphic_format_properties * Oth _CP_APPLY_PROP3(draw_fit_to_size_); _CP_APPLY_PROP3(draw_fit_to_contour_); _CP_APPLY_PROP3(style_shrink_to_fit_); + _CP_APPLY_PROP3(draw_ole_draw_aspect_); _CP_APPLY_PROP3(svg_stroke_color_); _CP_APPLY_PROP3(svg_stroke_width_); diff --git a/OdfFile/Reader/Format/style_graphic_properties.h b/OdfFile/Reader/Format/style_graphic_properties.h index 5c23a51553..7a42aa58fe 100644 --- a/OdfFile/Reader/Format/style_graphic_properties.h +++ b/OdfFile/Reader/Format/style_graphic_properties.h @@ -96,6 +96,8 @@ public: _CP_OPT(bool) draw_fit_to_contour_; _CP_OPT(std::wstring) draw_wrap_influence_on_position_; + _CP_OPT(unsigned int) draw_ole_draw_aspect_; + odf_types::common_draw_rel_size_attlist common_draw_rel_size_attlist_; odf_types::common_draw_fill_attlist common_draw_fill_attlist_; odf_types::common_horizontal_margin_attlist common_horizontal_margin_attlist_; From 447ade207fc709856a3c7ddb8a2a07a3298983e2 Mon Sep 17 00:00:00 2001 From: Kamil Kerimov Date: Fri, 14 Feb 2025 13:56:53 +0500 Subject: [PATCH 13/21] Fix bug #73222 --- OdfFile/Reader/Converter/docx_conversion_context.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OdfFile/Reader/Converter/docx_conversion_context.cpp b/OdfFile/Reader/Converter/docx_conversion_context.cpp index 2f248b996e..92f31714c0 100644 --- a/OdfFile/Reader/Converter/docx_conversion_context.cpp +++ b/OdfFile/Reader/Converter/docx_conversion_context.cpp @@ -2192,7 +2192,7 @@ int docx_conversion_context::process_paragraph_attr(odf_reader::text::paragraph_ { odf_reader::list_style_container & list_styles = root()->odf_context().listStyleContainer(); - if (!list_style_stack_.empty() && list_styles.outline_style()) + if (list_style_stack_.empty() && list_styles.outline_style() && !get_table_context().in_table()) { output_stream() << L""; output_stream() << L""; From 67cb29652d50b3a799f90ab94ba04018ec9d494c Mon Sep 17 00:00:00 2001 From: Kamil Kerimov Date: Sat, 15 Feb 2025 17:41:26 +0500 Subject: [PATCH 14/21] Fix bug #73238 --- OdfFile/Reader/Format/text_elements.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OdfFile/Reader/Format/text_elements.cpp b/OdfFile/Reader/Format/text_elements.cpp index 0dbb2c3f8f..62a5f7d5ca 100644 --- a/OdfFile/Reader/Format/text_elements.cpp +++ b/OdfFile/Reader/Format/text_elements.cpp @@ -279,7 +279,7 @@ void paragraph::process_list_bullet_style(oox::docx_conversion_context& Context) style_instance* paragraph_style = Context.root()->odf_context().styleContainer().style_by_name(attrs_.text_style_name_, style_family::Paragraph, false); if (paragraph_style && paragraph_style->content()) { - paragraph_style->content()->get_style_text_properties(true)->content_.fo_color_ = text_props->content_.fo_color_; + paragraph_style->content()->get_style_text_properties(true)->content_.apply_from(text_props->content_); } } } From 6b3c3952201a6b17f2aa02d35d47394ec17ea2c5 Mon Sep 17 00:00:00 2001 From: Svetlana Kulikova Date: Mon, 17 Feb 2025 13:44:01 +0300 Subject: [PATCH 15/21] Fix bug 73220 --- .../graphics/pro/js/qt/nativegraphics.pro | 2 ++ PdfFile/PdfFile.cpp | 4 +--- PdfFile/lib/xpdf/Gfx.cc | 23 ++++++++++++++----- PdfFile/lib/xpdf/Gfx.h | 1 + 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/DesktopEditor/graphics/pro/js/qt/nativegraphics.pro b/DesktopEditor/graphics/pro/js/qt/nativegraphics.pro index 3b3710f95f..8f532e4fa5 100644 --- a/DesktopEditor/graphics/pro/js/qt/nativegraphics.pro +++ b/DesktopEditor/graphics/pro/js/qt/nativegraphics.pro @@ -682,6 +682,7 @@ HEADERS += \ $$DOCX_RENDERER_ROOT_DIR/src/logic/elements/DropCap.h \ $$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/Table.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 \ @@ -706,6 +707,7 @@ SOURCES += \ $$DOCX_RENDERER_ROOT_DIR/src/logic/elements/ContText.cpp \ $$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Paragraph.cpp \ $$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Shape.cpp \ + $$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Table.cpp \ $$DOCX_RENDERER_ROOT_DIR/src/logic/elements/TextLine.cpp \ $$DOCX_RENDERER_ROOT_DIR/src/logic/managers/FontManager.cpp \ $$DOCX_RENDERER_ROOT_DIR/src/logic/managers/FontStyleManager.cpp \ diff --git a/PdfFile/PdfFile.cpp b/PdfFile/PdfFile.cpp index 7f76a7b9c2..ec96d91007 100644 --- a/PdfFile/PdfFile.cpp +++ b/PdfFile/PdfFile.cpp @@ -36,14 +36,12 @@ #include "../DesktopEditor/common/File.h" #include "../DesktopEditor/graphics/commands/DocInfo.h" #include "lib/xpdf/PDFDoc.h" +#include "Resources/BaseFonts.h" #ifndef BUILDING_WASM_MODULE #include "PdfEditor.h" #include "OnlineOfficeBinToPdf.h" - #include "SrcWriter/Document.h" -#include "Resources/BaseFonts.h" - #else class CPdfEditor { diff --git a/PdfFile/lib/xpdf/Gfx.cc b/PdfFile/lib/xpdf/Gfx.cc index abb942b676..5baf41c4f2 100644 --- a/PdfFile/lib/xpdf/Gfx.cc +++ b/PdfFile/lib/xpdf/Gfx.cc @@ -5037,6 +5037,20 @@ void Gfx::opEndIgnoreUndef(Object args[], int numArgs) { // marked content operators //------------------------------------------------------------------------ +void Gfx::SkipBDC() +{ + Object obj; + getContentObj(&obj); + while (!obj.isEOF()) { + if (obj.isCmd("BMC") || obj.isCmd("BDC")) + SkipBDC(); + else if (obj.isCmd("EMC")) + break; + obj.free(); + getContentObj(&obj); + } + obj.free(); +} void Gfx::opBeginMarkedContent(Object args[], int numArgs) { GfxMarkedContent *mc; Object obj; @@ -5074,16 +5088,13 @@ void Gfx::opBeginMarkedContent(Object args[], int numArgs) { oIDF.getString()->cmp(oIDF2.getString()) == 0 && oMetaOForm.dictLookup("ID", &oID)->isString() && xref->getTrailerDict()->dictLookup("ID", &oTID)->isArray() && oTID.arrayGet(1, &oID2)->isString() && oID2.getString()->cmp(oID.getString()) == 0 && args[1].dictLookup("MCID", &oMCID)->isInt() && oMetaOForm.dictLookup("Metadata", &oMetadata)->isArray() && oMetadata.arrayGet(oMCID.getInt(), &oMetadataCur)->isString()) { - oID.free(); oTID.free(); oID2.free(); oIDF.free(); oIDF2.free(); oMCID.free(); oMetadata.free(); obj.free(); + oID.free(); oTID.free(); oID2.free(); oIDF.free(); oIDF2.free(); oMetadata.free(); obj.free(); Object oImRef, oArrImage; if (!oMetaOForm.dictLookup("Image", &oArrImage)->isArray() || !oArrImage.arrayGetNF(oMCID.getInt(), &oImRef)->isRef()) oImRef.free(); + oMCID.free(); if (out->beginMCOShapes(state, oMetadataCur.getString(), &oImRef)) { - getContentObj(&obj); - while (!obj.isEOF() && !obj.isCmd("EMC")) { - obj.free(); - getContentObj(&obj); - } + SkipBDC(); out->endMarkedContent(state); oImRef.free(); oArrImage.free(); oMetaOForm.free(); oMetadataCur.free(); obj.free(); diff --git a/PdfFile/lib/xpdf/Gfx.h b/PdfFile/lib/xpdf/Gfx.h index bdc03da311..06968c4672 100644 --- a/PdfFile/lib/xpdf/Gfx.h +++ b/PdfFile/lib/xpdf/Gfx.h @@ -355,6 +355,7 @@ private: void opBeginMarkedContent(Object args[], int numArgs); void opEndMarkedContent(Object args[], int numArgs); void opMarkPoint(Object args[], int numArgs); + void SkipBDC(); GfxState *saveStateStack(); void restoreStateStack(GfxState *oldState); From f5088f43d86066ab5b684e22b263bdf92982277b Mon Sep 17 00:00:00 2001 From: Svetlana Kulikova Date: Mon, 17 Feb 2025 14:10:38 +0300 Subject: [PATCH 16/21] Fix bug 73178 --- PdfFile/SrcReader/RendererOutputDev.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PdfFile/SrcReader/RendererOutputDev.cpp b/PdfFile/SrcReader/RendererOutputDev.cpp index 44fed8e90f..4109ae0b24 100644 --- a/PdfFile/SrcReader/RendererOutputDev.cpp +++ b/PdfFile/SrcReader/RendererOutputDev.cpp @@ -2890,9 +2890,10 @@ namespace PdfReader Aggplus::CImage oImage; StreamKind nSK = pStream->getKind(); int nComponentsCount = pColorMap->getNumPixelComps(); + BYTE unAlpha = std::min(255, std::max(0, int(pGState->getFillOpacity() * 255))); // Чтение jpeg через cximage происходит быстрее чем через xpdf на ~40% - if (pMaskColors || (nSK != strDCT || nComponentsCount != 3 || !ReadImage(&oImage, pRef, pStream))) + if (pMaskColors || unAlpha != 255 || (nSK != strDCT || nComponentsCount != 3 || !ReadImage(&oImage, pRef, pStream))) { int nBufferSize = 4 * nWidth * nHeight; if (nBufferSize < 1) @@ -2906,7 +2907,6 @@ namespace PdfReader ImageStream* pImageStream = new ImageStream(pStream, nWidth, nComponentsCount, pColorMap->getBits()); pImageStream->reset(); - BYTE unAlpha = std::min(255, std::max(0, int(pGState->getFillOpacity() * 255))); int nComps = pImageStream->getComps(); int nCheckWidth = std::min(nWidth, pImageStream->getVals() / nComps); GfxRenderingIntent intent = pGState->getRenderingIntent(); From efd047be749055c21fdaeaa6d57126b57235e14b Mon Sep 17 00:00:00 2001 From: Kamil Kerimov Date: Mon, 17 Feb 2025 18:27:48 +0500 Subject: [PATCH 17/21] Fix bug #71975 --- OdfFile/Writer/Converter/DocxConverter.cpp | 42 ++++++++-------------- OdfFile/Writer/Format/odf_text_context.cpp | 2 +- 2 files changed, 16 insertions(+), 28 deletions(-) diff --git a/OdfFile/Writer/Converter/DocxConverter.cpp b/OdfFile/Writer/Converter/DocxConverter.cpp index a8394c214d..6a61b455a8 100644 --- a/OdfFile/Writer/Converter/DocxConverter.cpp +++ b/OdfFile/Writer/Converter/DocxConverter.cpp @@ -3287,7 +3287,7 @@ void DocxConverter::convert(OOX::Drawing::CAnchor* oox_anchor) if (oox_anchor->m_oPositionV.IsInit() && oox_anchor->m_oPositionV->m_oRelativeFrom.IsInit()) { - int vert_rel = oox_anchor->m_oPositionV->m_oRelativeFrom->GetValue(); + SimpleTypes::ERelFromV vert_rel = oox_anchor->m_oPositionV->m_oRelativeFrom->GetValue(); odt_context->drawing_context()->set_vertical_rel(vert_rel); @@ -3296,20 +3296,12 @@ void DocxConverter::convert(OOX::Drawing::CAnchor* oox_anchor) else if (oox_anchor->m_oPositionV->m_oPosOffset.IsInit()) { - // relfromvBottomMargin = 0, - // relfromvInsideMargin = 1, - // relfromvLine = 2, - // relfromvMargin = 3, - // relfromvOutsideMargin = 4, - // relfromvPage = 5, - // relfromvParagraph = 6, - // relfromvTopMargin = 7 switch (vert_rel) { - case 2: anchor_type_x = anchor_type::Char; break; - case 5: anchor_type_y = anchor_type::Page; break; - case 3: - case 6: anchor_type_y = anchor_type::Paragraph; break; + case SimpleTypes::relfromvLine: anchor_type_x = anchor_type::Char; break; + case SimpleTypes::relfromvPage: anchor_type_y = anchor_type::Page; break; + case SimpleTypes::relfromvMargin: + case SimpleTypes::relfromvParagraph: anchor_type_y = anchor_type::Paragraph; break; } odt_context->drawing_context()->set_vertical_pos(oox_anchor->m_oPositionV->m_oPosOffset->ToPoints()); } @@ -3318,7 +3310,7 @@ void DocxConverter::convert(OOX::Drawing::CAnchor* oox_anchor) } if (oox_anchor->m_oPositionH.IsInit() && oox_anchor->m_oPositionH->m_oRelativeFrom.IsInit()) { - int horiz_rel = oox_anchor->m_oPositionH->m_oRelativeFrom->GetValue(); + SimpleTypes::ERelFromH horiz_rel = oox_anchor->m_oPositionH->m_oRelativeFrom->GetValue(); odt_context->drawing_context()->set_horizontal_rel(horiz_rel); if (oox_anchor->m_oPositionH->m_oAlign.IsInit()) @@ -3327,21 +3319,14 @@ void DocxConverter::convert(OOX::Drawing::CAnchor* oox_anchor) else if (oox_anchor->m_oPositionH->m_oPosOffset.IsInit()) { odt_context->drawing_context()->set_horizontal_pos(oox_anchor->m_oPositionH->m_oPosOffset->ToPoints()); - // relfromhCharacter = 0, - // relfromhColumn = 1, - // relfromhInsideMargin = 2, - // relfromhLeftMargin = 3, - // relfromhMargin = 4, - // relfromhOutsideMargin = 5, - // relfromhPage = 6, - // relfromhRightMargin = 7 + switch (horiz_rel) { - case 0: anchor_type_x = anchor_type::Char; break; - case 1: anchor_type_x = anchor_type::Frame; break; - case 4: - case 2: anchor_type_x = anchor_type::Paragraph; break; - case 6: anchor_type_x = anchor_type::Page; break; + case SimpleTypes::relfromhCharacter: anchor_type_x = anchor_type::Char; break; + case SimpleTypes::relfromhColumn: anchor_type_x = anchor_type::Frame; break; + case SimpleTypes::relfromhMargin: + case SimpleTypes::relfromhInsideMargin: anchor_type_x = anchor_type::Paragraph; break; + case SimpleTypes::relfromhPage: anchor_type_x = anchor_type::Page; break; } } else @@ -3350,6 +3335,9 @@ void DocxConverter::convert(OOX::Drawing::CAnchor* oox_anchor) if (anchor_type_x && anchor_type_y) { + if (*anchor_type_x == anchor_type::Paragraph || *anchor_type_y == anchor_type::Paragraph) + *anchor_type_x = *anchor_type_y = anchor_type::Paragraph; + if (*anchor_type_x == *anchor_type_y) odt_context->drawing_context()->set_anchor(*anchor_type_x); else if (*anchor_type_x == anchor_type::Frame && *anchor_type_y == anchor_type::Paragraph) diff --git a/OdfFile/Writer/Format/odf_text_context.cpp b/OdfFile/Writer/Format/odf_text_context.cpp index 286ca3c708..195bd3e02b 100644 --- a/OdfFile/Writer/Format/odf_text_context.cpp +++ b/OdfFile/Writer/Format/odf_text_context.cpp @@ -773,7 +773,7 @@ bool odf_text_context::set_type_break(int type, int clear)//todooo clear ??? end_element(); need_break_ = fo_break(fo_break::Page); - need_restart = true; + need_restart = clear != 0; // brclearAll = 0, } else //brtypeTextWrapping { From 6adf65d3a8e772ee020e162509e87042d85a3cce Mon Sep 17 00:00:00 2001 From: ElenaSubbotina Date: Tue, 18 Feb 2025 09:51:43 +0300 Subject: [PATCH 18/21] fix bug #73221 --- OdfFile/Reader/Converter/oox_drawing_fills.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/OdfFile/Reader/Converter/oox_drawing_fills.cpp b/OdfFile/Reader/Converter/oox_drawing_fills.cpp index 37729857f4..54912299ef 100644 --- a/OdfFile/Reader/Converter/oox_drawing_fills.cpp +++ b/OdfFile/Reader/Converter/oox_drawing_fills.cpp @@ -183,12 +183,11 @@ void oox_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val, cons else CP_XML_ATTR(L"r:link", val.bitmap->rId ); - _CP_OPT(double) opacity = val.image_opacity ? val.image_opacity : val.opacity; - if (opacity) + if (val.image_opacity) { CP_XML_NODE(ns + L":alphaModFix") { - CP_XML_ATTR2(ns_att + L"amt", (int)(*opacity * 1000)); + CP_XML_ATTR2(ns_att + L"amt", (int)(*val.image_opacity * 1000)); } } if (val.bitmap->bGrayscale) From 1d31e5836bcdff46cc1ba585ce4cfff0f0fe02f3 Mon Sep 17 00:00:00 2001 From: ElenaSubbotina Date: Tue, 18 Feb 2025 20:23:49 +0300 Subject: [PATCH 19/21] fix fileFormatChecker --- Common/OfficeFileFormatChecker.h | 2 + Common/OfficeFileFormatChecker2.cpp | 78 +++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) diff --git a/Common/OfficeFileFormatChecker.h b/Common/OfficeFileFormatChecker.h index d8a9fe0755..83cc47271a 100644 --- a/Common/OfficeFileFormatChecker.h +++ b/Common/OfficeFileFormatChecker.h @@ -68,6 +68,7 @@ public: bool isOOXFormatFile(const std::wstring& fileName, bool unpacked = false); bool isOpenOfficeFormatFile(const std::wstring& fileName, std::wstring& documentID); bool isOnlyOfficeFormatFile(const std::wstring& fileName); + bool isMacFormatFile(const std::wstring& fileName); bool isDocFormatFile(const std::wstring& fileName); bool isXlsFormatFile(const std::wstring& fileName); @@ -80,6 +81,7 @@ public: bool isMS_MITCRYPTOFormatFile(POLE::Storage* storage, std::wstring& documentID); bool isVbaProjectFile(POLE::Storage* storage); bool isMS_OFFCRYPTOFormatFile(const std::wstring& fileName, std::wstring& documentID); + bool isHwpFile(POLE::Storage* storage); bool iXmlFile(const std::wstring& fileName); diff --git a/Common/OfficeFileFormatChecker2.cpp b/Common/OfficeFileFormatChecker2.cpp index d2887d78fd..e1ea7b2d88 100644 --- a/Common/OfficeFileFormatChecker2.cpp +++ b/Common/OfficeFileFormatChecker2.cpp @@ -451,6 +451,20 @@ bool COfficeFileFormatChecker::isVbaProjectFile(POLE::Storage *storage) } return true; } +bool COfficeFileFormatChecker::isHwpFile(POLE::Storage* storage) +{ + if (storage == NULL) + return false; + + unsigned char buffer[10]; + + POLE::Stream stream(storage, L"BodyText/Section0"); + if (stream.read(buffer, 10) < 1) + { + return false; + } + return true; +} bool COfficeFileFormatChecker::isXlsFormatFile(POLE::Storage *storage) { if (storage == NULL) @@ -721,6 +735,11 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName) nFileType = AVS_OFFICESTUDIO_FILE_OTHER_MS_VBAPROJECT; return true; } + else if (isHwpFile(&storage)) + { + nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_HWP; + return true; + } } NSFile::CFileBinary file; if (!file.OpenFile(fileName)) @@ -767,6 +786,13 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName) bufferDetect = NULL; return true; } + else if (isMacFormatFile(fileName)) + { + if (bufferDetect) + delete[] bufferDetect; + bufferDetect = NULL; + return true; + } } //----------------------------------------------------------------------------------------------- @@ -1133,6 +1159,58 @@ bool COfficeFileFormatChecker::isOnlyOfficeFormatFile(const std::wstring &fileNa } return false; } +bool COfficeFileFormatChecker::isMacFormatFile(const std::wstring& fileName) +{ + COfficeUtils OfficeUtils(NULL); + + ULONG nBufferSize = 0; + BYTE* pBuffer = NULL; + + HRESULT hresult = OfficeUtils.LoadFileFromArchive(fileName, L"Index/Document.iwa", &pBuffer, nBufferSize); + if (hresult == S_OK && pBuffer != NULL) + { + nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES; + + delete[] pBuffer; + pBuffer = NULL; + + hresult = OfficeUtils.LoadFileFromArchive(fileName, L"Index/Slide.iwa", &pBuffer, nBufferSize); + if (hresult == S_OK && pBuffer != NULL) + { + delete[] pBuffer; + pBuffer = NULL; + + nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_KEY; + return true; + } + hresult = OfficeUtils.LoadFileFromArchive(fileName, L"Index/Tables/DataList.iwa", &pBuffer, nBufferSize); + if (hresult == S_OK && pBuffer != NULL) + { + delete[] pBuffer; + pBuffer = NULL; + + nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS; + return true; + } + std::wstring::size_type nExtPos = fileName.rfind(L'.'); + std::wstring sExt = L"unknown"; + + if (nExtPos != std::wstring::npos) + sExt = fileName.substr(nExtPos); + + std::transform(sExt.begin(), sExt.end(), sExt.begin(), tolower); + + if (0 == sExt.compare(L".pages")) + nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES; + else if (0 == sExt.compare(L".numbers")) + nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS; + else if (0 == sExt.compare(L".key")) + nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_KEY; + + return true; + } + return false; +} bool COfficeFileFormatChecker::isOpenOfficeFormatFile(const std::wstring &fileName, std::wstring &documentID) { documentID.clear(); From 2c27cfc72064625ec77e733ca085239ab56372f4 Mon Sep 17 00:00:00 2001 From: ElenaSubbotina Date: Wed, 19 Feb 2025 15:32:12 +0300 Subject: [PATCH 20/21] . --- OdfFile/Writer/Format/odf_settings_context.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OdfFile/Writer/Format/odf_settings_context.cpp b/OdfFile/Writer/Format/odf_settings_context.cpp index 3e1c91fd9c..a2bd15f696 100644 --- a/OdfFile/Writer/Format/odf_settings_context.cpp +++ b/OdfFile/Writer/Format/odf_settings_context.cpp @@ -93,6 +93,9 @@ void odf_settings_context::end_table() } void odf_settings_context::set_modify_info(const std::wstring& crypt, const std::wstring& algorithm, const std::wstring& solt, const std::wstring& hash, int iteration_count) { + if (algorithm.empty() && solt.empty() && hash.empty()) + return; + office_element_ptr elm_item_set; create_element(L"config", L"config-item-set", elm_item_set, odf_context_); config_content_.push_back(elm_item_set); From b14fa1c2a173c35ee13def9e0fc3cb0951480b42 Mon Sep 17 00:00:00 2001 From: ElenaSubbotina Date: Wed, 19 Feb 2025 15:35:55 +0300 Subject: [PATCH 21/21] fix bug #73248 --- .../Binary/Document/BinWriter/BinWriters.cpp | 252 ++++++---- OOXML/DocxFormat/Logic/RunContent.h | 127 ++--- OOXML/DocxFormat/Math/oMathContent.cpp | 434 ++++++++---------- OOXML/DocxFormat/Math/oMathContent.h | 48 +- .../Converter/StarMath2OOXML/cooxml2odf.cpp | 27 +- OdfFile/Reader/Format/odf_document_impl.cpp | 2 +- OdfFile/Writer/Converter/MathConverter.cpp | 100 ++-- RtfFile/Format/DestinationCommand.cpp | 4 +- RtfFile/Format/RtfProperty.cpp | 22 +- RtfFile/Format/RtfProperty.h | 2 +- RtfFile/Format/RtfReader.cpp | 6 + RtfFile/OOXml/Reader/OOXMathReader.cpp | 36 +- 12 files changed, 536 insertions(+), 524 deletions(-) diff --git a/OOXML/Binary/Document/BinWriter/BinWriters.cpp b/OOXML/Binary/Document/BinWriter/BinWriters.cpp index 3a2210edf8..85aeee134f 100644 --- a/OOXML/Binary/Document/BinWriter/BinWriters.cpp +++ b/OOXML/Binary/Document/BinWriter/BinWriters.cpp @@ -5070,8 +5070,10 @@ void BinaryDocumentTableWriter::WriteMathArgNodes(const std::vectorm_oMRPr.IsInit() ) + if (pMRun->m_oMRPr.IsInit()) + { WriteMathMRPr(pMRun->m_oMRPr.get()); + } if ( pMRun->m_oRPr.IsInit() ) { int nCurPos2 = m_oBcw.WriteItemStart(c_oSer_OMathContentType::RPr); @@ -5084,102 +5086,182 @@ void BinaryDocumentTableWriter::WriteMathRunContent(OOX::Logic::CMRun* pMRun) m_oBcw.m_oStream.WriteRecord2(0, pMRun->m_oARPr); m_oBcw.WriteItemEnd(nCurPos2); } - if ( pMRun->m_oMText.IsInit() ) - WriteMathText(pMRun->m_oMText.get()); - - if ( pMRun->m_oBr.IsInit() ) - { - int nBreakType = -1; - switch(pMRun->m_oBr->m_oType.GetValue()) - { - case SimpleTypes::brtypeColumn: nBreakType = c_oSer_OMathContentType::columnbreak;break; - case SimpleTypes::brtypePage: nBreakType = c_oSer_OMathContentType::pagebreak;break; - case SimpleTypes::brtypeTextWrapping: nBreakType = c_oSer_OMathContentType::linebreak;break; - } - if (-1 != nBreakType) - { - m_oBcw.m_oStream.WriteBYTE(nBreakType); - m_oBcw.m_oStream.WriteLONG(c_oSerPropLenType::Null); - } - } - if ( pMRun->m_oDel.IsInit() ) + if (pMRun->m_oDel.IsInit()) { int nCurPos2 = m_oBcw.WriteItemStart(c_oSer_OMathContentType::Del); WriteMathDel(pMRun->m_oDel.get()); m_oBcw.WriteItemEnd(nCurPos2); } - if ( pMRun->m_oIns.IsInit() ) + if (pMRun->m_oIns.IsInit()) { int nCurPos2 = m_oBcw.WriteItemStart(c_oSer_OMathContentType::Ins); WriteMathIns(pMRun->m_oIns.get()); m_oBcw.WriteItemEnd(nCurPos2); } - if (pMRun->m_oNoBreakHyphen.IsInit()) - { - m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathContentType::NoBreakHyphen); - m_oBcw.m_oStream.WriteLONG(c_oSerPropLenType::Null); - } - if (pMRun->m_oSoftHyphen.IsInit()) - { - m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathContentType::SoftHyphen); - m_oBcw.m_oStream.WriteLONG(c_oSerPropLenType::Null); - } - if (pMRun->m_oTab.IsInit()) - { - m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathContentType::Tab); - m_oBcw.m_oStream.WriteLONG(c_oSerPropLenType::Null); - } - if (pMRun->m_oSym.IsInit()) - { - wchar_t ch = 0x0FFF & pMRun->m_oSym->m_oChar->GetValue(); - std::wstring sText(&ch, 1); - int nCurPos2 = m_oBcw.WriteItemStart(c_oSer_OMathContentType::Sym); - m_oBcw.m_oStream.WriteStringW(sText); - m_oBcw.WriteItemEnd(nCurPos2); - } - if (pMRun->m_oAnnotationRef.IsInit()) + for (size_t i = 0; i < pMRun->m_arrItems.size(); ++i) { - m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathContentType::AnnotationRef); - m_oBcw.m_oStream.WriteLONG(c_oSerPropLenType::Null); - } - if (pMRun->m_oCommentReference.IsInit()) - { - int nCurPos2 = m_oBcw.WriteItemStart(c_oSer_OMathContentType::CommentReference); - WriteComment(OOX::et_w_commentReference, pMRun->m_oCommentReference->m_oId); - m_oBcw.WriteItemEnd(nCurPos2); - } - if (pMRun->m_oCr.IsInit()) - { - m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathContentType::Cr); - m_oBcw.m_oStream.WriteLONG(c_oSerPropLenType::Null); - } - if (pMRun->m_oEndnoteRef.IsInit()) - { - m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathContentType::EndnoteRef); - m_oBcw.m_oStream.WriteLONG(c_oSerPropLenType::Null); - } - if (pMRun->m_oEndnoteReference.IsInit()) - { - int nCurPos2 = m_oBcw.WriteItemStart(c_oSer_OMathContentType::EndnoteReference); - WriteNoteRef(pMRun->m_oEndnoteReference->m_oCustomMarkFollows, pMRun->m_oEndnoteReference->m_oId); - m_oBcw.WriteItemEnd(nCurPos2); - } - if (pMRun->m_oFootnoteRef.IsInit()) - { - m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathContentType::FootnoteRef); - m_oBcw.m_oStream.WriteLONG(c_oSerPropLenType::Null); - } - if (pMRun->m_oFootnoteReference.IsInit()) - { - int nCurPos2 = m_oBcw.WriteItemStart(c_oSer_OMathContentType::FootnoteReference); - WriteNoteRef(pMRun->m_oFootnoteReference->m_oCustomMarkFollows, pMRun->m_oFootnoteReference->m_oId); - m_oBcw.WriteItemEnd(nCurPos2); - } - if (pMRun->m_oLastRenderedPageBreak.IsInit()) - { - m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathContentType::LastRenderedPageBreak); - m_oBcw.m_oStream.WriteLONG(c_oSerPropLenType::Null); + OOX::WritingElement* item = pMRun->m_arrItems[i]; + switch (item->getType()) + { + case OOX::et_w_br: + { + OOX::Logic::CBr* pBr = static_cast(item); + int nBreakType = -1; + switch (pBr->m_oType.GetValue()) + { + case SimpleTypes::brtypeColumn: nBreakType = c_oSerRunType::columnbreak; break; + case SimpleTypes::brtypePage: nBreakType = c_oSerRunType::pagebreak; break; + case SimpleTypes::brtypeTextWrapping: + { + switch (pBr->m_oClear.GetValue()) + { + case SimpleTypes::brclearAll: nBreakType = c_oSerRunType::linebreakClearAll; break; + case SimpleTypes::brclearLeft: nBreakType = c_oSerRunType::linebreakClearLeft; break; + case SimpleTypes::brclearRight: nBreakType = c_oSerRunType::linebreakClearRight; break; + default: nBreakType = c_oSerRunType::linebreak; break; + } + + }break; + default: + break; + } + if (-1 != nBreakType) + { + m_oBcw.m_oStream.WriteBYTE(nBreakType); + m_oBcw.m_oStream.WriteLONG(c_oSerPropLenType::Null); + } + }break; + case OOX::et_w_cr: + { + m_oBcw.m_oStream.WriteBYTE(c_oSerRunType::cr); + m_oBcw.m_oStream.WriteLONG(c_oSerPropLenType::Null); + break; + } + case OOX::et_mc_alternateContent: + case OOX::et_w_pict: + case OOX::et_w_drawing: + { + WriteDrawingPptx(item); + }break; + case OOX::et_w_fldChar: + { + OOX::Logic::CFldChar* pFldChar = static_cast(item); + int nCurPos = m_oBcw.WriteItemStart(c_oSerRunType::fldChar); + WriteFldChar(pFldChar); + m_oBcw.WriteItemEnd(nCurPos); + }break; + case OOX::et_w_delInstrText: + { + OOX::Logic::CDelInstrText* pInstrText = static_cast(item); + WriteText(pInstrText->m_sText, c_oSerRunType::delInstrText); + }break; + case OOX::et_w_instrText: + { + OOX::Logic::CInstrText* pInstrText = static_cast(item); + WriteText(pInstrText->m_sText, c_oSerRunType::instrText); + } + break; + case OOX::et_w_nonBreakHyphen: + { + m_oBcw.m_oStream.WriteBYTE(c_oSerRunType::noBreakHyphen); + m_oBcw.m_oStream.WriteLONG(c_oSerPropLenType::Null); + }break; + case OOX::et_w_pgNum: + { + m_oBcw.m_oStream.WriteBYTE(c_oSerRunType::pagenum); + m_oBcw.m_oStream.WriteLONG(c_oSerPropLenType::Null); + }break; + case OOX::et_w_ptab: + break; + case OOX::et_w_softHyphen: + { + m_oBcw.m_oStream.WriteBYTE(c_oSerRunType::softHyphen); + m_oBcw.m_oStream.WriteLONG(c_oSerPropLenType::Null); + }break; + case OOX::et_w_sym: + { + OOX::Logic::CSym* oSym = static_cast(item); + wchar_t ch = 0x0FFF & oSym->m_oChar->GetValue(); + std::wstring sText(&ch, 1); + WriteText(sText, c_oSerRunType::run); // todooo определить что писать c_oSerRunType::run или c_oSerRunType::delText - 66333 + + }break; + case OOX::et_w_delText: + { + std::wstring& sText = static_cast(item)->m_sText; + WriteText(sText, c_oSerRunType::delText); + }break; + case OOX::et_w_t: + { + std::wstring& sText = static_cast(item)->m_sText; + WriteText(sText, c_oSerRunType::run); + }break; + case OOX::et_w_tab: + { + m_oBcw.m_oStream.WriteBYTE(c_oSerRunType::tab); + m_oBcw.m_oStream.WriteLONG(c_oSerPropLenType::Null); + }break; + case OOX::et_w_separator: + { + m_oBcw.m_oStream.WriteBYTE(c_oSerRunType::separator); + m_oBcw.m_oStream.WriteLONG(c_oSerPropLenType::Null); + }break; + case OOX::et_w_continuationSeparator: + { + m_oBcw.m_oStream.WriteBYTE(c_oSerRunType::continuationSeparator); + m_oBcw.m_oStream.WriteLONG(c_oSerPropLenType::Null); + }break; + case OOX::et_w_commentReference: + { + OOX::Logic::CCommentReference* pCommentReference = static_cast(item); + WriteComment(OOX::et_w_commentReference, pCommentReference->m_oId); + }break; + case OOX::et_w_object: + { + int nPosObject = m_oBcw.WriteItemStart(c_oSerRunType::object); + + OOX::Logic::CObject* pObject = static_cast(item); + std::wstring* pXml = pObject ? pObject->m_sXml.GetPointer() : NULL; + + int nPosImageCache = m_oBcw.WriteItemStart(c_oSerRunType::pptxDrawing); + WriteDrawing(pXml, NULL, NULL); + m_oBcw.WriteItemEnd(nPosImageCache); + + m_oBcw.WriteItemEnd(nPosObject); + }break; + case OOX::et_w_footnoteRef: + { + m_oBcw.m_oStream.WriteBYTE(c_oSerRunType::footnoteRef); + m_oBcw.m_oStream.WriteLONG(c_oSerPropLenType::Null); + }break; + case OOX::et_w_endnoteRef: + { + m_oBcw.m_oStream.WriteBYTE(c_oSerRunType::endnoteRef); + m_oBcw.m_oStream.WriteLONG(c_oSerPropLenType::Null); + }break; + case OOX::et_w_footnoteReference: + { + OOX::Logic::CFootnoteReference* pFootnoteReference = static_cast(item); + int nCurPos = m_oBcw.WriteItemStart(c_oSerRunType::footnoteReference); + WriteNoteRef(pFootnoteReference->m_oCustomMarkFollows, pFootnoteReference->m_oId); + m_oBcw.WriteItemEnd(nCurPos); + }break; + case OOX::et_w_endnoteReference: + { + OOX::Logic::CEndnoteReference* pEndnoteReference = static_cast(item); + int nCurPos = m_oBcw.WriteItemStart(c_oSerRunType::endnoteReference); + WriteNoteRef(pEndnoteReference->m_oCustomMarkFollows, pEndnoteReference->m_oId); + m_oBcw.WriteItemEnd(nCurPos); + }break; + case OOX::et_m_t: + { + WriteMathText(*static_cast(item)); + } + break; + default: + break; + } } } void BinaryDocumentTableWriter::WriteMathAccPr(const OOX::Logic::CAccPr &pAccPr) diff --git a/OOXML/DocxFormat/Logic/RunContent.h b/OOXML/DocxFormat/Logic/RunContent.h index efcb3c220f..a83211adb0 100644 --- a/OOXML/DocxFormat/Logic/RunContent.h +++ b/OOXML/DocxFormat/Logic/RunContent.h @@ -71,10 +71,8 @@ namespace OOX virtual std::wstring toXML() const; virtual EElementType getType() const; - private: void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - public: SimpleTypes::CBrClear m_oClear; @@ -97,14 +95,12 @@ namespace OOX virtual std::wstring toXML() const; virtual EElementType getType() const; - private: void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - public: - std::wstring m_namespace; - nullable m_oXfrm; - //nullable m_oNvContentPartPr; + std::wstring m_namespace; + nullable m_oXfrm; + //nullable m_oNvContentPartPr; nullable m_oId; }; @@ -173,18 +169,14 @@ namespace OOX virtual void fromXML(XmlUtils::CXmlNode& oNode); virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - virtual std::wstring toXML() const; + virtual std::wstring toXML() const; virtual EElementType getType() const; - private: void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - public: - // Attributes nullable m_oSpace; - // Value - std::wstring m_sText; + std::wstring m_sText; }; @@ -283,19 +275,17 @@ namespace OOX CPTab(OOX::Document *pMain = NULL); virtual ~CPTab(); - public: - virtual void fromXML(XmlUtils::CXmlNode& oNode); - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& oNode); + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - virtual std::wstring toXML() const; + virtual std::wstring toXML() const; virtual EElementType getType() const; - private: void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); public: - nullable m_oAlignment; - nullable m_oLeader; + nullable m_oAlignment; + nullable m_oLeader; nullable m_oRelativeTo; }; @@ -310,11 +300,10 @@ namespace OOX CRuby(OOX::Document *pMain = NULL); virtual ~CRuby(); - public: - virtual void fromXML(XmlUtils::CXmlNode& oNode); - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& oNode); + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - virtual std::wstring toXML() const; + virtual std::wstring toXML() const; virtual EElementType getType() const; }; @@ -327,12 +316,11 @@ namespace OOX WritingElement_AdditionMethods(CSoftHyphen) CSoftHyphen(OOX::Document *pMain = NULL); virtual ~CSoftHyphen(); - - public: - virtual void fromXML(XmlUtils::CXmlNode& oNode); - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - virtual std::wstring toXML() const; + virtual void fromXML(XmlUtils::CXmlNode& oNode); + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + + virtual std::wstring toXML() const; virtual EElementType getType() const; }; @@ -346,19 +334,16 @@ namespace OOX CSym(OOX::Document *pMain = NULL); virtual ~CSym(); - public: - virtual void fromXML(XmlUtils::CXmlNode& oNode); - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& oNode); + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - virtual std::wstring toXML() const; + virtual std::wstring toXML() const; virtual EElementType getType() const; - private: void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - public: - nullable m_oChar; - nullable m_oFont; + nullable m_oChar; + nullable m_oFont; }; @@ -379,16 +364,11 @@ namespace OOX virtual EElementType getType() const; static void ReadAttributes(XmlUtils::CXmlLiteReader& oReader, nullable& oSpace); - private: void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - public: - // Attributes nullable m_oSpace; - - // Value - std::wstring m_sText; + std::wstring m_sText; }; //-------------------------------------------------------------------------------- @@ -401,11 +381,10 @@ namespace OOX CTab(OOX::Document *pMain = NULL); virtual ~CTab(); - public: - virtual void fromXML(XmlUtils::CXmlNode& oNode); - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& oNode); + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - virtual std::wstring toXML() const; + virtual std::wstring toXML() const; virtual EElementType getType() const; }; @@ -419,11 +398,10 @@ namespace OOX CYearLong(OOX::Document *pMain = NULL); virtual ~CYearLong(); - public: - virtual void fromXML(XmlUtils::CXmlNode& oNode); - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& oNode); + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - virtual std::wstring toXML() const; + virtual std::wstring toXML() const; virtual EElementType getType() const; }; @@ -437,11 +415,10 @@ namespace OOX CYearShort(OOX::Document *pMain = NULL); virtual ~CYearShort(); - public: - virtual void fromXML(XmlUtils::CXmlNode& oNode); - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual void fromXML(XmlUtils::CXmlNode& oNode); + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - virtual std::wstring toXML() const; + virtual std::wstring toXML() const; virtual EElementType getType() const; }; @@ -458,7 +435,7 @@ namespace OOX virtual void fromXML(XmlUtils::CXmlNode& oNode); virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - virtual std::wstring toXML() const; + virtual std::wstring toXML() const; virtual EElementType getType() const; }; @@ -475,9 +452,8 @@ namespace OOX virtual void fromXML(XmlUtils::CXmlNode& oNode); virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - virtual std::wstring toXML() const; + virtual std::wstring toXML() const; virtual EElementType getType() const; - private: void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); @@ -498,7 +474,7 @@ namespace OOX virtual void fromXML(XmlUtils::CXmlNode& oNode); virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - virtual std::wstring toXML() const; + virtual std::wstring toXML() const; virtual EElementType getType() const; }; @@ -515,18 +491,16 @@ namespace OOX virtual void fromXML(XmlUtils::CXmlNode& oNode); virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - virtual std::wstring toXML() const; + virtual std::wstring toXML() const; virtual EElementType getType() const; private: void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); public: - // Attributes nullable m_oSpace; - // Value - std::wstring m_sText; + std::wstring m_sText; }; @@ -543,7 +517,7 @@ namespace OOX virtual void fromXML(XmlUtils::CXmlNode& oNode); virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - virtual std::wstring toXML() const; + virtual std::wstring toXML() const; virtual EElementType getType() const; }; @@ -562,13 +536,11 @@ namespace OOX virtual std::wstring toXML() const; virtual EElementType getType() const; - private: void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - public: - nullable m_oCustomMarkFollows; - nullable m_oId; + nullable m_oCustomMarkFollows; + nullable m_oId; }; @@ -585,7 +557,7 @@ namespace OOX virtual void fromXML(XmlUtils::CXmlNode& oNode); virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - virtual std::wstring toXML() const; + virtual std::wstring toXML() const; virtual EElementType getType() const; }; @@ -602,15 +574,15 @@ namespace OOX virtual void fromXML(XmlUtils::CXmlNode& oNode); virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - virtual std::wstring toXML() const; + virtual std::wstring toXML() const; virtual EElementType getType() const; private: void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); public: - nullable m_oCustomMarkFollows; - nullable m_oId; + nullable m_oCustomMarkFollows; + nullable m_oId; }; //-------------------------------------------------------------------------------- @@ -626,18 +598,13 @@ namespace OOX virtual void fromXML(XmlUtils::CXmlNode& oNode); virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - virtual std::wstring toXML() const; + virtual std::wstring toXML() const; virtual EElementType getType() const; - private: void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - public: - // Attributes nullable m_oSpace; - - // Value - std::wstring m_sText; + std::wstring m_sText; }; @@ -654,7 +621,7 @@ namespace OOX virtual void fromXML(XmlUtils::CXmlNode& oNode); virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - virtual std::wstring toXML() const; + virtual std::wstring toXML() const; virtual EElementType getType() const; }; diff --git a/OOXML/DocxFormat/Math/oMathContent.cpp b/OOXML/DocxFormat/Math/oMathContent.cpp index 7d648fe820..551abbdbbd 100644 --- a/OOXML/DocxFormat/Math/oMathContent.cpp +++ b/OOXML/DocxFormat/Math/oMathContent.cpp @@ -499,8 +499,8 @@ namespace OOX void CBrk::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) { WritingElement_ReadAttributes_Start( oReader ) - WritingElement_ReadAttributes_ReadSingle( oReader, _T("m:alnAt"), m_alnAt ) - WritingElement_ReadAttributes_End( oReader ) + WritingElement_ReadAttributes_ReadSingle( oReader, _T("m:alnAt"), m_alnAt ) + WritingElement_ReadAttributes_End( oReader ) } //-------------------------------------------------------------------------------- @@ -2289,11 +2289,22 @@ namespace OOX // CMRun 22.1.2.87 (Math Run) //-------------------------------------------------------------------------------- - CMRun::CMRun(OOX::Document *pMain) : WritingElement(pMain) + CMRun::CMRun(OOX::Document *pMain) : WritingElementWithChilds<>(pMain) { } CMRun::~CMRun() { + ClearItems(); + } + void CMRun::ClearItems() + { + m_oARPr.reset(); + m_oMRPr.reset(); + m_oRPr.reset(); + m_oDel.reset(); + m_oIns.reset(); + + WritingElementWithChilds<>::ClearItems(); } void CMRun::fromXML(XmlUtils::CXmlNode& oNode) { @@ -2306,83 +2317,89 @@ namespace OOX if ( oItem.IsValid( ) ) { std::wstring sName = oItem.GetName(); + WritingElement* pItem = NULL; - if ( _T("w:annotationRef") == sName ) - m_oAnnotationRef = oItem; - else if ( _T("w:br") == sName ) - m_oBr = oItem; - else if ( _T("w:commentReference") == sName ) - m_oCommentReference = oItem; - else if ( _T("w:contentPart") == sName ) - m_oContentPart = oItem; - else if ( _T("w:continuationSeparator") == sName ) - m_oContinuationSeparator = oItem; - else if ( _T("w:cr") == sName ) - m_oCr = oItem; - else if ( _T("w:dayLong") == sName ) - m_oDayLong = oItem; - else if ( _T("w:dayShort") == sName ) - m_oDayShort = oItem; - else if ( _T("w:del") == sName ) + if (L"w:annotationRef" == sName) + AssignPtrXmlContent(pItem, CAnnotationRef, oItem) + else if (L"w:br" == sName) + AssignPtrXmlContent(pItem, CBr, oItem) + else if (L"w:commentReference" == sName) + AssignPtrXmlContent(pItem, CCommentReference, oItem) + else if (L"w:contentPart" == sName) + AssignPtrXmlContent(pItem, CContentPart, oItem) + else if (L"w:continuationSeparator" == sName) + AssignPtrXmlContent(pItem, CContinuationSeparator, oItem) + else if (L"w:cr" == sName) + AssignPtrXmlContent(pItem, CCr, oItem) + else if (L"w:dayLong" == sName) + AssignPtrXmlContent(pItem, CDayLong, oItem) + else if (L"w:dayShort" == sName) + AssignPtrXmlContent(pItem, CDayShort, oItem) + else if (L"w:delInstrText" == sName) + AssignPtrXmlContent(pItem, CDelInstrText, oItem) + else if (L"w:delText" == sName) + AssignPtrXmlContent(pItem, CDelText, oItem) + else if (L"w:drawing" == sName) + AssignPtrXmlContent(pItem, CDrawing, oItem) + else if (L"w:endnoteRef" == sName) + AssignPtrXmlContent(pItem, CEndnoteRef, oItem) + else if (L"w:endnoteReference" == sName) + AssignPtrXmlContent(pItem, CEndnoteReference, oItem) + else if (L"w:fldChar" == sName) + AssignPtrXmlContent(pItem, CFldChar, oItem) + else if (L"w:footnoteRef" == sName) + AssignPtrXmlContent(pItem, CFootnoteRef, oItem) + else if (L"w:footnoteReference" == sName) + AssignPtrXmlContent(pItem, CFootnoteReference, oItem) + else if (L"w:instrText" == sName) + AssignPtrXmlContent(pItem, CInstrText, oItem) + else if (L"w:lastRenderedPageBreak" == sName) + AssignPtrXmlContent(pItem, CLastRenderedPageBreak, oItem) + else if (L"w:monthLong" == sName) + AssignPtrXmlContent(pItem, CMonthLong, oItem) + else if (L"w:monthShort" == sName) + AssignPtrXmlContent(pItem, CMonthShort, oItem) + else if (L"w:noBreakHyphen" == sName) + AssignPtrXmlContent(pItem, CNoBreakHyphen, oItem) + else if (L"w:object" == sName) + AssignPtrXmlContent(pItem, CObject, oItem) + else if (L"w:pgNum" == sName) + AssignPtrXmlContent(pItem, CPgNum, oItem) + else if (L"w:pict" == sName) + AssignPtrXmlContent(pItem, CPicture, oItem) + else if (L"w:ptab" == sName) + AssignPtrXmlContent(pItem, CPTab, oItem) + else if (L"w:ruby" == sName) + AssignPtrXmlContent(pItem, CRuby, oItem) + else if (L"w:separator" == sName) + AssignPtrXmlContent(pItem, CSeparator, oItem) + else if (L"w:softHyphen" == sName) + AssignPtrXmlContent(pItem, CSoftHyphen, oItem) + else if (L"w:sym" == sName) + AssignPtrXmlContent(pItem, CSym, oItem) + else if (L"m:t" == sName) + AssignPtrXmlContent(pItem, CMText, oItem) + else if (L"w:t" == sName) + AssignPtrXmlContent(pItem, CText, oItem) + else if (L"w:tab" == sName) + AssignPtrXmlContent(pItem, CTab, oItem) + else if (L"w:yearLong" == sName) + AssignPtrXmlContent(pItem, CYearLong, oItem) + else if (L"w:yearShort" == sName) + AssignPtrXmlContent(pItem, CYearShort, oItem) + else if ( L"w:del" == sName ) m_oDel = oItem; - else if ( _T("w:delInstrText") == sName ) - m_oDelInstrText = oItem; - else if ( _T("w:delText") == sName ) - m_oDelText = oItem; - else if ( _T("w:drawing") == sName ) - m_oDrawing = oItem; - else if ( _T("w:endnoteRef") == sName ) - m_oEndnoteRef = oItem; - else if ( _T("w:endnoteReference") == sName ) - m_oEndnoteReference = oItem; - else if ( _T("w:fldChar") == sName ) - m_oFldChar = oItem; - else if ( _T("w:footnoteRef") == sName ) - m_oFootnoteRef = oItem; - else if ( _T("w:footnoteReference") == sName ) - m_oFootnoteReference = oItem; - else if ( _T("w:ins") == sName ) + else if ( L"w:ins" == sName ) m_oIns = oItem; - else if ( _T("w:instrText") == sName ) - m_oInstrText = oItem; - else if ( _T("w:lastRenderedPageBreak") == sName ) - m_oLastRenderedPageBreak = oItem; - else if ( _T("w:monthLong") == sName ) - m_oMonthLong = oItem; - else if ( _T("w:monthShort") == sName ) - m_oMonthShort = oItem; - else if ( _T("w:noBreakHyphen") == sName ) - m_oNoBreakHyphen = oItem; - else if ( _T("w:object") == sName ) - m_oObject = oItem; - else if ( _T("w:pgNum") == sName ) - m_oPgNum = oItem; - else if ( _T("w:ptab") == sName ) - m_oPtab = oItem; - else if ( _T("m:rPr") == sName ) + else if ( L"m:rPr" == sName ) m_oMRPr = oItem ; - else if ( _T("w:rPr") == sName ) + else if ( L"w:rPr" == sName ) m_oRPr = oItem; - else if ( _T("a:rPr") == sName ) + else if ( L"a:rPr" == sName ) m_oARPr = oItem; - else if ( _T("w:ruby") == sName ) - m_oRuby = oItem; - else if ( _T("w:separator") == sName ) - m_oSeparator = oItem; - else if ( _T("w:softHyphen") == sName ) - m_oSoftHyphen = oItem; - else if ( _T("w:sym") == sName ) - m_oSym = oItem; - else if ( _T("m:t") == sName ) - m_oMText = oItem ; - else if ( _T("w:t") == sName ) - m_oText = oItem; - else if ( _T("w:tab") == sName ) - m_oTab = oItem; - else if ( _T("w:yearLong") == sName ) - m_oYearLong = oItem; - else if ( _T("w:yearShort") == sName ) - m_oYearShort = oItem; + + if (pItem) + m_arrItems.push_back(pItem); } } } @@ -2395,63 +2412,83 @@ namespace OOX while( oReader.ReadNextSiblingNode( nParentDepth ) ) { std::wstring sName = oReader.GetName(); - if ( _T("w:annotationRef") == sName ) - m_oAnnotationRef = oReader; - else if ( _T("w:br") == sName ) - m_oBr = oReader; - else if ( _T("w:commentReference") == sName ) - m_oCommentReference = oReader; - else if ( _T("w:contentPart") == sName ) - m_oContentPart = oReader; - else if ( _T("w:continuationSeparator") == sName ) - m_oContinuationSeparator = oReader; - else if ( _T("w:cr") == sName ) - m_oCr = oReader; - else if ( _T("w:dayLong") == sName ) - m_oDayLong = oReader; - else if ( _T("w:dayShort") == sName ) - m_oDayShort = oReader; - else if ( _T("w:del") == sName ) + WritingElement* pItem = NULL; + + if (L"w:annotationRef" == sName) + pItem = new CAnnotationRef(); + else if (L"w:br" == sName) + pItem = new CBr(); + else if (L"w:commentReference" == sName) + pItem = new CCommentReference(); + else if (L"w:contentPart" == sName) + pItem = new CContentPart(); + else if (L"w:continuationSeparator" == sName) + pItem = new CContinuationSeparator(); + else if (L"w:cr" == sName) + pItem = new CCr(); + else if (L"w:dayLong" == sName) + pItem = new CDayLong(); + else if (L"w:dayShort" == sName) + pItem = new CDayShort(); + else if (L"w:delInstrText" == sName) + pItem = new CDelInstrText(); + else if (L"w:delText" == sName) + pItem = new CDelText(); + else if (L"w:drawing" == sName) + pItem = new CDrawing(); + else if (L"w:endnoteRef" == sName) + pItem = new CEndnoteRef(); + else if (L"w:endnoteReference" == sName) + pItem = new CEndnoteReference(); + else if (L"w:fldChar" == sName) + pItem = new CFldChar(); + else if (L"w:footnoteRef" == sName) + pItem = new CFootnoteRef(); + else if (L"w:footnoteReference" == sName) + pItem = new CFootnoteReference(); + else if (L"w:instrText" == sName) + pItem = new CInstrText(); + else if (L"w:lastRenderedPageBreak" == sName) + pItem = new CLastRenderedPageBreak(); + else if (L"w:monthLong" == sName) + pItem = new CMonthLong(); + else if (L"w:monthShort" == sName) + pItem = new CMonthShort(); + else if (L"w:noBreakHyphen" == sName) + pItem = new CNoBreakHyphen(); + else if (L"w:object" == sName) + pItem = new CObject(); + else if (L"w:pgNum" == sName) + pItem = new CPgNum(); + else if (L"w:pict" == sName) + pItem = new CPicture(); + else if (L"w:ptab" == sName) + pItem = new CPTab(); + else if (L"w:ruby" == sName) + pItem = new CRuby(); + else if (L"w:separator" == sName) + pItem = new CSeparator(); + else if (L"w:softHyphen" == sName) + pItem = new CSoftHyphen(); + else if (L"w:sym" == sName) + pItem = new CSym(); + else if (L"w:t" == sName) + pItem = new CText(); + else if (L"w:tab" == sName) + pItem = new CTab(); + else if (L"w:yearLong" == sName) + pItem = new CYearLong(); + else if (L"m:t" == sName) + pItem = new CMText(); + else if (L"w:del" == sName) m_oDel = oReader; - else if ( _T("w:delInstrText") == sName ) - m_oDelInstrText = oReader; - else if ( _T("w:delText") == sName ) - m_oDelText = oReader; - else if ( _T("w:drawing") == sName ) - m_oDrawing = oReader; - else if ( _T("w:endnoteRef") == sName ) - m_oEndnoteRef = oReader; - else if ( _T("w:endnoteReference") == sName ) - m_oEndnoteReference = oReader; - else if ( _T("w:fldChar") == sName ) - m_oFldChar = oReader; - else if ( _T("w:footnoteRef") == sName ) - m_oFootnoteRef = oReader; - else if ( _T("w:footnoteReference") == sName ) - m_oFootnoteReference = oReader; - else if ( _T("w:ins") == sName ) + else if (L"w:ins" == sName) m_oIns = oReader; - else if ( _T("w:instrText") == sName ) - m_oInstrText = oReader; - else if ( _T("w:lastRenderedPageBreak") == sName ) - m_oLastRenderedPageBreak = oReader; - else if ( _T("w:monthLong") == sName ) - m_oMonthLong = oReader; - else if ( _T("w:monthShort") == sName ) - m_oMonthShort = oReader; - else if ( _T("w:noBreakHyphen") == sName ) - m_oNoBreakHyphen = oReader; - else if ( _T("w:object") == sName ) - m_oObject = oReader; - else if ( _T("w:pgNum") == sName ) - m_oPgNum = oReader; - else if ( _T("w:ptab") == sName ) - m_oPtab = oReader; - else if ( _T("m:rPr") == sName ) - m_oMRPr = oReader ; - else if ( _T("w:rPr") == sName ) + else if (L"m:rPr" == sName) + m_oMRPr = oReader; + else if (L"w:rPr" == sName) m_oRPr = oReader; - else if ( _T("a:rPr") == sName ) + else if (L"a:rPr" == sName) { std::wstring sXml = oReader.GetOuterXml(); XmlUtils::CXmlNode node; @@ -2459,24 +2496,11 @@ namespace OOX m_oARPr = node; } - else if ( _T("w:ruby") == sName ) - m_oRuby = oReader; - else if ( _T("w:separator") == sName ) - m_oSeparator = oReader; - else if ( _T("w:softHyphen") == sName ) - m_oSoftHyphen = oReader; - else if ( _T("w:sym") == sName ) - m_oSym = oReader; - else if ( _T("m:t") == sName ) - m_oMText = oReader ; - else if ( _T("w:t") == sName ) - m_oText = oReader; - else if ( _T("w:tab") == sName ) - m_oTab = oReader; - else if ( _T("w:yearLong") == sName ) - m_oYearLong = oReader; - else if ( _T("w:yearShort") == sName ) - m_oYearShort = oReader; + if (pItem) + { + pItem->fromXML(oReader); + m_arrItems.push_back(pItem); + } } } EElementType CMRun::getType() const @@ -4216,7 +4240,7 @@ namespace OOX return sResult; } - std::wstring CMc::toXML() const + std::wstring CMc::toXML() const { std::wstring sResult = L""; @@ -4228,7 +4252,7 @@ namespace OOX return sResult; } - std::wstring CNary::toXML() const + std::wstring CNary::toXML() const { std::wstring sResult = L""; @@ -4249,7 +4273,7 @@ namespace OOX return sResult; } - std::wstring CPhant::toXML() const + std::wstring CPhant::toXML() const { std::wstring sResult = L""; @@ -4264,7 +4288,7 @@ namespace OOX return sResult; } - std::wstring CMRun::toXML() const + std::wstring CMRun::toXML() const { std::wstring sResult = L""; @@ -4274,81 +4298,15 @@ namespace OOX return sResult; } - std::wstring CMRun::toXMLInner() const + std::wstring CMRun::toXMLInner() const { std::wstring sResult; - if ( m_oAnnotationRef.IsInit() ) - sResult += m_oAnnotationRef->toXML(); + if (m_oIns.IsInit() ) + sResult += m_oIns->toXML(); - if ( m_oBr.IsInit() ) - sResult += m_oBr->toXML(); - - if ( m_oCommentReference.IsInit() ) - sResult += m_oCommentReference->toXML(); - - if ( m_oContentPart.IsInit() ) - sResult += m_oContentPart->toXML(); - - if ( m_oContinuationSeparator.IsInit() ) - sResult += m_oContinuationSeparator->toXML(); - - if ( m_oCr.IsInit() ) - sResult += m_oCr->toXML(); - - if ( m_oDayLong.IsInit() ) - sResult += m_oDayLong->toXML(); - - if ( m_oDayShort.IsInit() ) - sResult += m_oDayShort->toXML(); - - if ( m_oDelInstrText.IsInit() ) - sResult += m_oDelInstrText->toXML(); - - if ( m_oDelText.IsInit() ) - sResult += m_oDelText->toXML(); - - if ( m_oDrawing.IsInit() ) - sResult += m_oDrawing->toXML(); - - if ( m_oEndnoteRef.IsInit() ) - sResult += m_oEndnoteRef->toXML(); - - if ( m_oEndnoteReference.IsInit() ) - sResult += m_oEndnoteReference->toXML(); - - if ( m_oFldChar.IsInit() ) - sResult += m_oFldChar->toXML(); - - if ( m_oFootnoteRef.IsInit() ) - sResult += m_oFootnoteRef->toXML(); - - if ( m_oFootnoteReference.IsInit() ) - sResult += m_oFootnoteReference->toXML(); - - if ( m_oInstrText.IsInit() ) - sResult += m_oInstrText->toXML(); - - if ( m_oLastRenderedPageBreak.IsInit() ) - sResult += m_oLastRenderedPageBreak->toXML(); - - if ( m_oMonthLong.IsInit() ) - sResult += m_oMonthLong->toXML(); - - if ( m_oMonthShort.IsInit() ) - sResult += m_oMonthShort->toXML(); - - if ( m_oNoBreakHyphen.IsInit() ) - sResult += m_oNoBreakHyphen->toXML(); - - if ( m_oObject.IsInit() ) - sResult += m_oObject->toXML(); - - if ( m_oPgNum.IsInit() ) - sResult += m_oPgNum->toXML(); - - if ( m_oPtab.IsInit() ) - sResult += m_oPtab->toXML(); + if ( m_oDel.IsInit() ) + sResult += m_oDel->toXML(); if ( m_oMRPr.IsInit() ) sResult += m_oMRPr->toXML(); @@ -4359,33 +4317,13 @@ namespace OOX if ( m_oRPr.IsInit() ) sResult += m_oRPr->toXML(); - if ( m_oRuby.IsInit() ) - sResult += m_oRuby->toXML(); - - if ( m_oSeparator.IsInit() ) - sResult += m_oSeparator->toXML(); - - if ( m_oSoftHyphen.IsInit() ) - sResult += m_oSoftHyphen->toXML(); - - if ( m_oSym.IsInit() ) - sResult += m_oSym->toXML(); - - if ( m_oMText.IsInit() ) - sResult += m_oMText->toXML(); - - if ( m_oText.IsInit() ) - sResult += m_oText->toXML(); - - if ( m_oTab.IsInit() ) - sResult += m_oTab->toXML(); - - if ( m_oYearLong.IsInit() ) - sResult += m_oYearLong->toXML(); - - if ( m_oYearShort.IsInit() ) - sResult += m_oYearShort->toXML(); - + for (size_t i = 0; i < m_arrItems.size(); ++i) + { + if (m_arrItems[i]) + { + sResult += m_arrItems[i]->toXML(); + } + } return sResult; } } diff --git a/OOXML/DocxFormat/Math/oMathContent.h b/OOXML/DocxFormat/Math/oMathContent.h index c207902a73..f0cdf2ef6c 100644 --- a/OOXML/DocxFormat/Math/oMathContent.h +++ b/OOXML/DocxFormat/Math/oMathContent.h @@ -937,13 +937,15 @@ namespace OOX //-------------------------------------------------------------------------------- // CMRun 22.1.2.87 (Math Run) //-------------------------------------------------------------------------------- - class CMRun : public WritingElement + class CMRun : public WritingElementWithChilds<> { public: WritingElement_AdditionMethods(CMRun) CMRun(OOX::Document *pMain = NULL); virtual ~CMRun(); + virtual void ClearItems(); + virtual void fromXML(XmlUtils::CXmlNode& oNode); virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); @@ -952,45 +954,11 @@ namespace OOX virtual EElementType getType() const; - // Childs - nullable m_oAnnotationRef; - nullable m_oBr; - nullable m_oCommentReference; - nullable m_oContentPart; - nullable m_oContinuationSeparator; - nullable m_oCr; - nullable m_oDayLong; - nullable m_oDayShort; - nullable m_oDel; - nullable m_oDelInstrText; - nullable m_oDelText; - nullable m_oDrawing; - nullable m_oEndnoteRef; - nullable m_oEndnoteReference; - nullable m_oFldChar; - nullable m_oFootnoteRef; - nullable m_oFootnoteReference; - nullable m_oIns; - nullable m_oInstrText; - nullable m_oLastRenderedPageBreak; - nullable m_oMonthLong; - nullable m_oMonthShort; - nullable m_oNoBreakHyphen; - nullable m_oObject; - nullable m_oPgNum; - nullable m_oPtab; - nullable m_oRPr; - nullable m_oMRPr; - nullable m_oARPr; - nullable m_oRuby; - nullable m_oSeparator; - nullable m_oSoftHyphen; - nullable m_oSym; - nullable m_oMText; - nullable m_oText; - nullable m_oTab; - nullable m_oYearLong; - nullable m_oYearShort; + nullable m_oARPr; + nullable m_oRPr; + nullable m_oMRPr; + nullable m_oDel; + nullablem_oIns; }; class CMDel : public WritingElement diff --git a/OdfFile/Reader/Converter/StarMath2OOXML/cooxml2odf.cpp b/OdfFile/Reader/Converter/StarMath2OOXML/cooxml2odf.cpp index 9f96c40f9b..9fdd78b7c6 100644 --- a/OdfFile/Reader/Converter/StarMath2OOXML/cooxml2odf.cpp +++ b/OdfFile/Reader/Converter/StarMath2OOXML/cooxml2odf.cpp @@ -542,17 +542,34 @@ namespace StarMath } std::vector COOXml2Odf::ConversionMRun(OOX::Logic::CMRun *pMRun) { - StValuePr* stRpr(nullptr); std::vector arLine; if(pMRun == nullptr) return arLine; + + StValuePr* stRpr(nullptr); if(pMRun->m_oRPr.GetPointer() != nullptr) stRpr = ConversionRunProperties(pMRun->m_oRPr.GetPointer()); else if (pMRun->m_oARPr.GetPointer() != nullptr) ConversionARpr(pMRun->m_oARPr.GetPointer(),stRpr); + if(pMRun->m_oMRPr.GetPointer() != nullptr) ConversionMRunProperties(pMRun->m_oMRPr.GetPointer(),stRpr); - if(pMRun->m_oMText.GetPointer() != nullptr) - arLine = ConversionMT(pMRun->m_oMText.GetPointer(),stRpr,pMRun->m_oMRPr.GetPointer()); + + for (size_t i = 0; i < pMRun->m_arrItems.size(); ++i) + { + switch (pMRun->m_arrItems[i]->getType()) + { + case OOX::et_m_t: + { + std::vector arLine_run; + arLine_run = ConversionMT(dynamic_cast(pMRun->m_arrItems[i]), stRpr, pMRun->m_oMRPr.GetPointer()); + arLine.insert(arLine.end(), arLine_run.begin(), arLine_run.end()); + arLine_run.clear(); + }break; + default: + break; + } + } + CreateAttribute(stRpr); if(stRpr != nullptr && !arLine.empty()) { @@ -564,8 +581,8 @@ namespace StarMath { if(i != 0 ) { - arLine[i]->SetAttribute(stRpr); - stRpr->AddRef(); + arLine[i]->SetAttribute(stRpr); + stRpr->AddRef(); } else if(i == 0 ) arLine[i]->SetAttribute(stRpr); diff --git a/OdfFile/Reader/Format/odf_document_impl.cpp b/OdfFile/Reader/Format/odf_document_impl.cpp index 934edc118f..8ae5b40ae5 100644 --- a/OdfFile/Reader/Format/odf_document_impl.cpp +++ b/OdfFile/Reader/Format/odf_document_impl.cpp @@ -637,7 +637,7 @@ void odf_document::Impl::parse_settings(office_element *element) for (auto info_elm = conf_item_set->content_.begin(); info_elm != conf_item_set->content_.end(); ++info_elm) { settings_config_item* info = dynamic_cast(info_elm->get()); - if (info) + if (info && !info->content_.empty()) { context_->Settings().add(L"modify:" + info->config_name_, info->content_); } diff --git a/OdfFile/Writer/Converter/MathConverter.cpp b/OdfFile/Writer/Converter/MathConverter.cpp index c29992fc87..5cd2841a19 100644 --- a/OdfFile/Writer/Converter/MathConverter.cpp +++ b/OdfFile/Writer/Converter/MathConverter.cpp @@ -1252,46 +1252,72 @@ namespace Oox2Odf { if (!oox_mrun) return; - convert(oox_mrun->m_oAnnotationRef.GetPointer()); - convert(oox_mrun->m_oARPr.GetPointer()); - convert(oox_mrun->m_oBr.GetPointer()); - convert(oox_mrun->m_oCommentReference.GetPointer()); - convert(oox_mrun->m_oContentPart.GetPointer()); - convert(oox_mrun->m_oContinuationSeparator.GetPointer()); - convert(oox_mrun->m_oCr.GetPointer()); - convert(oox_mrun->m_oDayLong.GetPointer()); - convert(oox_mrun->m_oDayShort.GetPointer()); convert(oox_mrun->m_oDel.GetPointer()); - convert(oox_mrun->m_oDelInstrText.GetPointer()); - convert(oox_mrun->m_oDelText.GetPointer()); - convert(oox_mrun->m_oDrawing.GetPointer()); - convert(oox_mrun->m_oEndnoteRef.GetPointer()); - convert(oox_mrun->m_oEndnoteReference.GetPointer()); - convert(oox_mrun->m_oEndnoteReference.GetPointer()); - convert(oox_mrun->m_oFldChar.GetPointer()); - convert(oox_mrun->m_oFootnoteRef.GetPointer()); - convert(oox_mrun->m_oFootnoteReference.GetPointer()); convert(oox_mrun->m_oIns.GetPointer()); - convert(oox_mrun->m_oInstrText.GetPointer()); - convert(oox_mrun->m_oLastRenderedPageBreak.GetPointer()); - convert(oox_mrun->m_oMonthLong.GetPointer()); - convert(oox_mrun->m_oMonthShort.GetPointer()); - //convert(oox_mrun->m_oMRPr.GetPointer()); + + convert(oox_mrun->m_oARPr.GetPointer()); bool clrFlag = convert(oox_mrun->m_oRPr.GetPointer()); - convert(oox_mrun->m_oMText.GetPointer()); - convert(oox_mrun->m_oNoBreakHyphen.GetPointer()); - convert(oox_mrun->m_oObject.GetPointer()); - convert(oox_mrun->m_oPgNum.GetPointer()); - convert(oox_mrun->m_oPtab.GetPointer()); - convert(oox_mrun->m_oRuby.GetPointer()); - convert(oox_mrun->m_oSeparator.GetPointer()); - convert(oox_mrun->m_oSoftHyphen.GetPointer()); - convert(oox_mrun->m_oSym.GetPointer()); - convert(oox_mrun->m_oTab.GetPointer()); - convert(oox_mrun->m_oText.GetPointer()); - convert(oox_mrun->m_oYearLong.GetPointer()); - convert(oox_mrun->m_oYearShort.GetPointer()); - + //convert(oox_mrun->m_oMRPr.GetPointer()); + + for (size_t i = 0; i < oox_mrun->m_arrItems.size(); ++i) + { + switch (oox_mrun->m_arrItems[i]->getType()) + { + case OOX::et_w_fldChar: + { + OOX::Logic::CFldChar* pFldChar = dynamic_cast(oox_mrun->m_arrItems[i]); + convert(pFldChar); + }break; + case OOX::et_w_instrText: + { + OOX::Logic::CInstrText* pInstrText = dynamic_cast(oox_mrun->m_arrItems[i]); + convert(pInstrText); + }break; + case OOX::et_w_delText: + { + OOX::Logic::CDelText* pDelText = dynamic_cast(oox_mrun->m_arrItems[i]); + convert(pDelText); + }break; + case OOX::et_w_lastRenderedPageBreak: // не информативное .. может быть неверно записано + { + }break; + case OOX::et_w_t: + { + OOX::Logic::CText* pText = dynamic_cast(oox_mrun->m_arrItems[i]); + convert(pText); + }break; + case OOX::et_m_t: + { + OOX::Logic::CMText* pMText = dynamic_cast(oox_mrun->m_arrItems[i]); + convert(pMText); + }break; + case OOX::et_w_sym: + { + OOX::Logic::CSym* pSym = dynamic_cast(oox_mrun->m_arrItems[i]); + convert(pSym); + }break; + case OOX::et_w_tab: + { + OOX::Logic::CTab* pTab = dynamic_cast(oox_mrun->m_arrItems[i]); + }break; + + case OOX::et_w_separator: + case OOX::et_w_continuationSeparator: + { + }break; + //contentPart + //cr + //dayLong, dayShort, monthLong, monthShort, yearLong, yearShort + //noBreakHyphen + //pgNum + //ruby + //softHyphen + //delInstrText + default: + convert(oox_mrun->m_arrItems[i]); + } + } + if (clrFlag) { CLOSE_MATH_TAG; diff --git a/RtfFile/Format/DestinationCommand.cpp b/RtfFile/Format/DestinationCommand.cpp index c3f2f6fd1c..d283b381d2 100644 --- a/RtfFile/Format/DestinationCommand.cpp +++ b/RtfFile/Format/DestinationCommand.cpp @@ -5355,8 +5355,8 @@ bool RtfListTableReader::ListReader::ListLevelReader::ExecuteCommand(RtfDocument } else if( "leveltext" == sCommand ) { - TextReader oLevelTextReader( m_oListLevelProp.m_sText ); - oLevelTextReader.m_bUseGlobalCodepage = true; + TextReader oLevelTextReader( m_oListLevelProp.m_sLevelText); + oLevelTextReader.m_bUseGlobalCodepage = true; // font Symbol return StartSubReader( oLevelTextReader, oDocument, oReader ); } else if( "levelnumbers" == sCommand ) diff --git a/RtfFile/Format/RtfProperty.cpp b/RtfFile/Format/RtfProperty.cpp index 10561fa694..c960a78e1a 100644 --- a/RtfFile/Format/RtfProperty.cpp +++ b/RtfFile/Format/RtfProperty.cpp @@ -1886,7 +1886,7 @@ bool RtfListLevelProperty::IsValid() { //return -1 != m_nFollow && -1 != m_nStart && -1 != m_nNumberType && -1 != m_nJustification && // false == m_sText.empty() && false == m_sNumber.empty(); - return PROP_DEF != m_nNumberType && false == m_sText.empty(); + return PROP_DEF != m_nNumberType && false == m_sLevelText.empty(); } std::wstring RtfListLevelProperty::GenerateListText() {//заменяем на булеты @@ -1918,7 +1918,7 @@ void RtfListLevelProperty::SetDefault() DEFAULT_PROPERTY ( m_nJustification ) DEFAULT_PROPERTY ( m_nFollow ) DEFAULT_PROPERTY ( m_nStart ) - DEFAULT_PROPERTY_DEF( m_sText, L"" ) + DEFAULT_PROPERTY_DEF(m_sLevelText, L"" ) DEFAULT_PROPERTY_DEF( m_sNumber, L"" ) DEFAULT_PROPERTY ( m_nNoRestart ) DEFAULT_PROPERTY ( m_nLegal ) @@ -1940,8 +1940,8 @@ void RtfListLevelProperty::Merge(RtfListLevelProperty& oListLevel) MERGE_PROPERTY( m_nFollow, oListLevel) MERGE_PROPERTY( m_nStart, oListLevel) - if (!oListLevel.m_sText.empty()) - m_sText = oListLevel.m_sText; + if (!oListLevel.m_sLevelText.empty()) + m_sLevelText = oListLevel.m_sLevelText; if (!oListLevel.m_sNumber.empty()) m_sNumber = oListLevel.m_sNumber; @@ -2119,7 +2119,7 @@ std::wstring RtfListLevelProperty::RenderToRtf(RenderParameter oRenderParameter) //чтобы при последующем чтении из rtf не потерялась информация о шрифте sResult += m_oCharProp.RenderToRtf( oRenderParameter ); - sResult += L"{\\leveltext" + m_sText + L";}"; + sResult += L"{\\leveltext" + m_sLevelText + L";}"; sResult += L"{\\levelnumbers" + m_sNumber + L";}"; RENDER_RTF_INT( m_nFirstIndent, sResult, L"fi" ) @@ -2138,7 +2138,7 @@ std::wstring RtfListLevelProperty::RenderToRtf(RenderParameter oRenderParameter) } std::wstring RtfListLevelProperty::GetLevelTextOOX() { - std::wstring sResult = m_sText; + std::wstring sResult = m_sLevelText; if ( sResult.length() > 0 ) { size_t nLevelTextLength = sResult[0]; @@ -2174,8 +2174,8 @@ std::wstring RtfListLevelProperty::GetLevelTextOOX() void RtfListLevelProperty::SetLevelTextOOX(const std::wstring& sText) { - m_sText = L""; - m_sNumber = L""; + m_sLevelText.clear(); + m_sNumber.clear(); int nLevelOffsets = 0; int nText = 0; @@ -2186,7 +2186,7 @@ void RtfListLevelProperty::SetLevelTextOOX(const std::wstring& sText) { int nLevel = RtfUtility::ToByte( sText[ i + 1 ] ); - m_sText += L"\\'" + XmlUtils::ToString(nLevel - 1, L"%02x"); + m_sLevelText += L"\\'" + XmlUtils::ToString(nLevel - 1, L"%02x"); m_sNumber += L"\\'" + XmlUtils::ToString(nLevelOffsets + 1, L"%02x"); i++; //т.к. следующий симовл уже учли @@ -2195,12 +2195,12 @@ void RtfListLevelProperty::SetLevelTextOOX(const std::wstring& sText) else { std::wstring s (sText.c_str() + i, 1); - m_sText += RtfChar::renderRtfText(s); + m_sLevelText += RtfChar::renderRtfText(s); nText++; } nLevelOffsets++; } - m_sText = L"\\'" + XmlUtils::ToString(nText, L"%02x") + m_sText; + m_sLevelText = L"\\'" + XmlUtils::ToString(nText, L"%02x") + m_sLevelText; } std::wstring RtfListLevelProperty::RenderToOOX(RenderParameter oRenderParameter) { diff --git a/RtfFile/Format/RtfProperty.h b/RtfFile/Format/RtfProperty.h index fe464e8a4f..e8aa7f2fba 100644 --- a/RtfFile/Format/RtfProperty.h +++ b/RtfFile/Format/RtfProperty.h @@ -503,7 +503,7 @@ public: _INT32 m_nJustification; //leveljcN \leveljcnN 0 Left justified 1 Center justified 2 Right justified _INT32 m_nFollow; //levelfollowN _INT32 m_nStart; //levelstartatN N specifies the start-at value for the level. - std::wstring m_sText; //как в rtf текст, но сдвинут от нуля на 1 // \'03\'00.\'01 -> ("%d%d%d",4,1,2) + std::wstring m_sLevelText; //как в rtf текст, но сдвинут от нуля на 1 // \'03\'00.\'01 -> ("%d%d%d",4,1,2) std::wstring m_sNumber; _INT32 m_nNoRestart; //levelnorestartN 1 if this level does not restart its count each time a super ordinate level is incremented; 0 if this level does restart its count each time a super ordinate level is incremented. _INT32 m_nLegal; //levellegalN 1 if any list numbers from previous levels should be converted to Arabic numbers; 0 if they should be left with the format specified by their own level’s definition. diff --git a/RtfFile/Format/RtfReader.cpp b/RtfFile/Format/RtfReader.cpp index 6fb9f74e6a..db7a3a4440 100644 --- a/RtfFile/Format/RtfReader.cpp +++ b/RtfFile/Format/RtfReader.cpp @@ -258,7 +258,13 @@ std::wstring RtfAbstractReader::ExecuteTextInternal(RtfDocument& oDocument, RtfR if ("u" == sKey) { if (true == bHasPar) + { + if (m_bUseGlobalCodepage && sizeof(wchar_t) != 2) + { + nPar = nPar & 0x0FFF; + } sResult += wchar_t(nPar); + } } else { diff --git a/RtfFile/OOXml/Reader/OOXMathReader.cpp b/RtfFile/OOXml/Reader/OOXMathReader.cpp index a36ca28fa8..84d2c8b7b1 100644 --- a/RtfFile/OOXml/Reader/OOXMathReader.cpp +++ b/RtfFile/OOXml/Reader/OOXMathReader.cpp @@ -105,23 +105,31 @@ bool OOXMathReader::ParseElement(ReaderParameter oParam , OOX::WritingElement * OOXrPrReader orPrReader(ooxRPr); orPrReader.Parse( oParam, m_oCharProperty); - //----------------------------------------------------------------------------------- - OOX::Logic::CMText *ooxTextMath = dynamic_cast(ooxRunMath->m_oMText.GetPointer()); - if (ooxTextMath) + bool result = false; + for (size_t i = 0; i < ooxRunMath->m_arrItems.size(); ++i) { - RtfCharPtr oChar(new RtfChar); - - oChar->m_oProperty = m_oCharProperty; - oChar->setText( ooxTextMath->m_sText ); - rtfMath->m_oVal.AddItem( oChar ); - } - else - { - bool res = false; - if (!res) res = ParseElement(oParam, ooxRunMath->m_oIns.GetPointer(), rtfMath); - if (!res) res = ParseElement(oParam, ooxRunMath->m_oDel.GetPointer(), rtfMath); + switch (ooxRunMath->m_arrItems[i]->getType()) + { + case OOX::et_m_t: + { + OOX::Logic::CMText* ooxTextMath = dynamic_cast(ooxRunMath->m_arrItems[i]); + if (ooxTextMath) + { + RtfCharPtr oChar(new RtfChar); + oChar->m_oProperty = m_oCharProperty; + oChar->setText(ooxTextMath->m_sText); + rtfMath->m_oVal.AddItem(oChar); + + result = true; + } + }break; + default: + break; + } } + if (!result) result = ParseElement(oParam, ooxRunMath->m_oIns.GetPointer(), rtfMath); + if (!result) result = ParseElement(oParam, ooxRunMath->m_oDel.GetPointer(), rtfMath); m_oCharProperty = oCurrentProp; }break; case OOX::et_m_t: