From 65ceacc5acc0b783045c62a8cb598e2f84a63d11 Mon Sep 17 00:00:00 2001 From: Ivan M Date: Sun, 30 May 2021 21:48:47 +0300 Subject: [PATCH 01/84] add some things for recognizing table --- .../PPTFormatLib/PPTXWriter/Converter.cpp | 9 +- .../Records/Drawing/ShapeContainer.cpp | 3647 +++++++++-------- ASCOfficePPTXFile/Editor/Drawing/Element.h | 5 +- ASCOfficePPTXFile/Editor/Drawing/Elements.h | 74 +- 4 files changed, 1889 insertions(+), 1846 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp index 7154b394fb..3ee052074c 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp @@ -934,8 +934,10 @@ void PPT_FORMAT::CPPTXWriter::WriteGroup(CStringWriter& oWriter, CRelsGenerator& } void PPT_FORMAT::CPPTXWriter::WriteTable(CStringWriter& oWriter, CRelsGenerator& oRels, CElementPtr pElement, CLayout* pLayout) { - CGroupElement *pGroupElement = dynamic_cast(pElement.get()); + CTableElement *pTableElement = dynamic_cast(pElement.get()); + if (!pTableElement) + return; m_pShapeWriter->SetElement(pElement); oWriter.WriteString(m_pShapeWriter->ConvertTable()); @@ -951,9 +953,12 @@ void PPT_FORMAT::CPPTXWriter::WriteElement(CStringWriter& oWriter, CRelsGenerato if (!pElement) return; CGroupElement *pGroupElement = dynamic_cast(pElement.get()); + CTableElement *pTableElement = dynamic_cast(pElement.get()); - if (pGroupElement && pGroupElement->m_sName.find(L"Table") != -1) + if (pTableElement) + { return WriteTable(oWriter, oRels, pElement, pLayout); + } if (pGroupElement) { return WriteGroup(oWriter, oRels, pElement, pLayout); diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp index cd572d0686..c3add9ed70 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp @@ -47,82 +47,82 @@ bool CPPTElement::ChangeBlack2ColorImage(std::wstring image_path, int rgbColor1, int rgbColor2) { - CBgraFrame bgraFrame; + CBgraFrame bgraFrame; - if (bgraFrame.OpenFile(image_path)) - { - int smpl = abs(bgraFrame.get_Stride() / bgraFrame.get_Width()); + if (bgraFrame.OpenFile(image_path)) + { + int smpl = abs(bgraFrame.get_Stride() / bgraFrame.get_Width()); - BYTE * rgb = bgraFrame.get_Data(); - - BYTE R1 = (BYTE)(rgbColor1); - BYTE G1 = (BYTE)(rgbColor1 >> 8); - BYTE B1 = (BYTE)(rgbColor1 >> 16); + BYTE * rgb = bgraFrame.get_Data(); - BYTE R2 = (BYTE)(rgbColor2); - BYTE G2 = (BYTE)(rgbColor2 >> 8); - BYTE B2 = (BYTE)(rgbColor2 >> 16); + BYTE R1 = (BYTE)(rgbColor1); + BYTE G1 = (BYTE)(rgbColor1 >> 8); + BYTE B1 = (BYTE)(rgbColor1 >> 16); - for (int i = 0 ; i < bgraFrame.get_Width() * bgraFrame.get_Height(); i++) - { - if (rgb[i * smpl + 0 ] == 0x00 && rgb[i * smpl + 1 ] == 0x00 && rgb[i * smpl + 2 ] == 0x00) - { - rgb[i * smpl + 0 ] = R1; - rgb[i * smpl + 1 ] = G1; - rgb[i * smpl + 2 ] = B1; - } - else - { - rgb[i * smpl + 0 ] = R2; - rgb[i * smpl + 1 ] = G2; - rgb[i * smpl + 2 ] = B2; - } - } - bgraFrame.SaveFile(image_path, 1); - return true; - } - return false; + BYTE R2 = (BYTE)(rgbColor2); + BYTE G2 = (BYTE)(rgbColor2 >> 8); + BYTE B2 = (BYTE)(rgbColor2 >> 16); + + for (int i = 0 ; i < bgraFrame.get_Width() * bgraFrame.get_Height(); i++) + { + if (rgb[i * smpl + 0 ] == 0x00 && rgb[i * smpl + 1 ] == 0x00 && rgb[i * smpl + 2 ] == 0x00) + { + rgb[i * smpl + 0 ] = R1; + rgb[i * smpl + 1 ] = G1; + rgb[i * smpl + 2 ] = B1; + } + else + { + rgb[i * smpl + 0 ] = R2; + rgb[i * smpl + 1 ] = G2; + rgb[i * smpl + 2 ] = B2; + } + } + bgraFrame.SaveFile(image_path, 1); + return true; + } + return false; } CColor CPPTElement::CorrectSysColor(int nColorCode, CElementPtr pElement, CTheme* pTheme) { - if (!pElement) return CColor(); + if (!pElement) return CColor(); - CColor color; + CColor color; - unsigned short nParameter = (unsigned short)(( nColorCode >> 16 ) & 0x00ff); // the HiByte of nParameter is not zero, an exclusive AND is helping :o - unsigned short nFunctionBits = (unsigned short)(( nColorCode & 0x00000f00 ) >> 8 ); - unsigned short nAdditionalFlags = (unsigned short)(( nColorCode & 0x0000f000) >> 8 ); - unsigned short nColorIndex = (unsigned short) ( nColorCode & 0x00ff); - unsigned short nPropColor = 0; + unsigned short nParameter = (unsigned short)(( nColorCode >> 16 ) & 0x00ff); // the HiByte of nParameter is not zero, an exclusive AND is helping :o + unsigned short nFunctionBits = (unsigned short)(( nColorCode & 0x00000f00 ) >> 8 ); + unsigned short nAdditionalFlags = (unsigned short)(( nColorCode & 0x0000f000) >> 8 ); + unsigned short nColorIndex = (unsigned short) ( nColorCode & 0x00ff); + unsigned short nPropColor = 0; - switch (nColorIndex) - { - case 0xF0: color = pElement->m_oBrush.Color1; break; - case 0xF1: - { - if (pElement->m_bLine) color = pElement->m_oPen.Color; - else color = pElement->m_oBrush.Color1; - }break; - case 0xF2: color = pElement->m_oPen.Color; break; - case 0xF3: color = pElement->m_oShadow.Color; break; - case 0xF4: break; ///this - case 0xF5: color = pElement->m_oBrush.Color2; break; - case 0xF6: break; //lineBackColor - case 0xF7: //FillThenLine - case 0xF8: //colorIndexMask - color = pElement->m_oBrush.Color1; break; - default: - //from table - break; - } + switch (nColorIndex) + { + case 0xF0: color = pElement->m_oBrush.Color1; break; + case 0xF1: + { + if (pElement->m_bLine) color = pElement->m_oPen.Color; + else color = pElement->m_oBrush.Color1; + }break; + case 0xF2: color = pElement->m_oPen.Color; break; + case 0xF3: color = pElement->m_oShadow.Color; break; + case 0xF4: break; ///this + case 0xF5: color = pElement->m_oBrush.Color2; break; + case 0xF6: break; //lineBackColor + case 0xF7: //FillThenLine + case 0xF8: //colorIndexMask + color = pElement->m_oBrush.Color1; break; + default: + //from table + break; + } if (color.m_lSchemeIndex != -1 && (int)pTheme->m_arColorScheme.size() > color.m_lSchemeIndex) - { - //вытащить цвет ( + { + //вытащить цвет ( - color = pTheme->m_arColorScheme[color.m_lSchemeIndex]; - } + color = pTheme->m_arColorScheme[color.m_lSchemeIndex]; + } //if ( nCProp && ( nPropColor & 0x10000000 ) == 0 ) // beware of looping recursive // color = CorrectSysColor( nPropColor, pElement); @@ -130,66 +130,66 @@ CColor CPPTElement::CorrectSysColor(int nColorCode, CElementPtr pElement, CTheme if( nAdditionalFlags & 0x80 ) // make color gray { BYTE nZwi = 0x7f;//= aColor.GetLuminance(); - color.SetRGB(nZwi, nZwi, nZwi); + color.SetRGB(nZwi, nZwi, nZwi); } switch( nFunctionBits ) { - case 0x01 : // darken color by parameter - { - color.SetR ( static_cast ( ( nParameter * color.GetR() ) >> 8 ) ); - color.SetG ( static_cast ( ( nParameter * color.GetG() ) >> 8 ) ); - color.SetB ( static_cast ( ( nParameter * color.GetB() ) >> 8 ) ); - } + case 0x01 : // darken color by parameter + { + color.SetR ( static_cast ( ( nParameter * color.GetR() ) >> 8 ) ); + color.SetG ( static_cast ( ( nParameter * color.GetG() ) >> 8 ) ); + color.SetB ( static_cast ( ( nParameter * color.GetB() ) >> 8 ) ); + } break; - case 0x02 : // lighten color by parameter - { - unsigned short nInvParameter = ( 0x00ff - nParameter ) * 0xff; - color.SetR( static_cast( ( nInvParameter + ( nParameter * color.GetR() ) ) >> 8 ) ); - color.SetG( static_cast( ( nInvParameter + ( nParameter * color.GetG() ) ) >> 8 ) ); - color.SetB( static_cast( ( nInvParameter + ( nParameter * color.GetB() ) ) >> 8 ) ); - } + case 0x02 : // lighten color by parameter + { + unsigned short nInvParameter = ( 0x00ff - nParameter ) * 0xff; + color.SetR( static_cast( ( nInvParameter + ( nParameter * color.GetR() ) ) >> 8 ) ); + color.SetG( static_cast( ( nInvParameter + ( nParameter * color.GetG() ) ) >> 8 ) ); + color.SetB( static_cast( ( nInvParameter + ( nParameter * color.GetB() ) ) >> 8 ) ); + } break; - case 0x03 : // add grey level RGB(p,p,p) - { - short nR = (short)color.GetR() + (short)nParameter; - short nG = (short)color.GetG() + (short)nParameter; - short nB = (short)color.GetB() + (short)nParameter; + case 0x03 : // add grey level RGB(p,p,p) + { + short nR = (short)color.GetR() + (short)nParameter; + short nG = (short)color.GetG() + (short)nParameter; + short nB = (short)color.GetB() + (short)nParameter; - if ( nR > 0x00ff ) nR = 0x00ff; - if ( nG > 0x00ff ) nG = 0x00ff; - if ( nB > 0x00ff ) nB = 0x00ff; + if ( nR > 0x00ff ) nR = 0x00ff; + if ( nG > 0x00ff ) nG = 0x00ff; + if ( nB > 0x00ff ) nB = 0x00ff; - color.SetRGB( (BYTE)nR, (BYTE)nG, (BYTE)nB ); - } + color.SetRGB( (BYTE)nR, (BYTE)nG, (BYTE)nB ); + } break; - case 0x04 : // substract grey level RGB(p,p,p) - { - short nR = (short)color.GetR() - (short)nParameter; - short nG = (short)color.GetG() - (short)nParameter; - short nB = (short)color.GetB() - (short)nParameter; - if ( nR < 0 ) nR = 0; - if ( nG < 0 ) nG = 0; - if ( nB < 0 ) nB = 0; - color.SetRGB( (BYTE)nR, (BYTE)nG, (BYTE)nB ); - } + case 0x04 : // substract grey level RGB(p,p,p) + { + short nR = (short)color.GetR() - (short)nParameter; + short nG = (short)color.GetG() - (short)nParameter; + short nB = (short)color.GetB() - (short)nParameter; + if ( nR < 0 ) nR = 0; + if ( nG < 0 ) nG = 0; + if ( nB < 0 ) nB = 0; + color.SetRGB( (BYTE)nR, (BYTE)nG, (BYTE)nB ); + } break; - case 0x05 : // substract from gray level RGB(p,p,p) - { - short nR = (short)nParameter - (short)color.GetR(); - short nG = (short)nParameter - (short)color.GetG(); - short nB = (short)nParameter - (short)color.GetB(); - if ( nR < 0 ) nR = 0; - if ( nG < 0 ) nG = 0; - if ( nB < 0 ) nB = 0; - color.SetRGB( (BYTE)nR, (BYTE)nG, (BYTE)nB ); - } + case 0x05 : // substract from gray level RGB(p,p,p) + { + short nR = (short)nParameter - (short)color.GetR(); + short nG = (short)nParameter - (short)color.GetG(); + short nB = (short)nParameter - (short)color.GetB(); + if ( nR < 0 ) nR = 0; + if ( nG < 0 ) nG = 0; + if ( nB < 0 ) nB = 0; + color.SetRGB( (BYTE)nR, (BYTE)nG, (BYTE)nB ); + } break; - case 0x06 : // per component: black if < p, white if >= p - { - color.SetR( color.GetR() < nParameter ? 0x00 : 0xff ); - color.SetG( color.GetG() < nParameter ? 0x00 : 0xff ); - color.SetB( color.GetB() < nParameter ? 0x00 : 0xff ); - } + case 0x06 : // per component: black if < p, white if >= p + { + color.SetR( color.GetR() < nParameter ? 0x00 : 0xff ); + color.SetG( color.GetG() < nParameter ? 0x00 : 0xff ); + color.SetB( color.GetB() < nParameter ? 0x00 : 0xff ); + } break; } if ( nAdditionalFlags & 0x40 ) // top-bit invert @@ -198,1294 +198,1300 @@ CColor CPPTElement::CorrectSysColor(int nColorCode, CElementPtr pElement, CTheme if ( nAdditionalFlags & 0x20 ) // invert color color.SetRGB(0xff - color.GetR(), 0xff - color.GetG(), 0xff - color.GetB()); - return color; + return color; } void CPPTElement::SetUpProperties(CElementPtr pElement, CTheme* pTheme, CSlideInfo* pWrapper, CSlide* pSlide, CProperties* pProperties, bool reset_default) { - size_t lCount = pProperties->m_lCount; - switch (pElement->m_etType) - { - case PPT_FORMAT::etVideo: - { - if (reset_default) - { - pElement->m_bLine = false; - } - for (size_t i = 0; i < lCount; ++i) - { - SetUpPropertyVideo(pElement, pTheme, pWrapper, pSlide, &pProperties->m_arProperties[i]); - } - break; - } - case PPT_FORMAT::etPicture: - { - if (reset_default) - { - pElement->m_oBrush.Type = c_BrushTypeTexture; - pElement->m_bLine = false; - } - for (size_t i = 0; i < lCount; ++i) - { - SetUpPropertyImage(pElement, pTheme, pWrapper, pSlide, &pProperties->m_arProperties[i]); - } - break; - } - case PPT_FORMAT::etAudio: - { - if (reset_default) - { - pElement->m_bLine = false; - } - for (size_t i = 0; i < lCount; ++i) - { - SetUpPropertyAudio(pElement, pTheme, pWrapper, pSlide, &pProperties->m_arProperties[i]); - } - break; - } - case PPT_FORMAT::etGroup: - { - if (reset_default) - { - pElement->m_bLine = false; - pElement->m_bIsFilled = false; - } - for (size_t i = 0; i < lCount; ++i) - { - SetUpProperty(pElement, pTheme, pWrapper, pSlide, &pProperties->m_arProperties[i]); - } - }break; - case PPT_FORMAT::etShape: - { - CShapeElement* pShapeElem = dynamic_cast(pElement.get()); - CPPTShape* pPPTShape = dynamic_cast(pShapeElem->m_pShape->getBaseShape().get()); + size_t lCount = pProperties->m_lCount; + switch (pElement->m_etType) + { + case PPT_FORMAT::etVideo: + { + if (reset_default) + { + pElement->m_bLine = false; + } + for (size_t i = 0; i < lCount; ++i) + { + SetUpPropertyVideo(pElement, pTheme, pWrapper, pSlide, &pProperties->m_arProperties[i]); + } + break; + } + case PPT_FORMAT::etPicture: + { + if (reset_default) + { + pElement->m_oBrush.Type = c_BrushTypeTexture; + pElement->m_bLine = false; + } + for (size_t i = 0; i < lCount; ++i) + { + SetUpPropertyImage(pElement, pTheme, pWrapper, pSlide, &pProperties->m_arProperties[i]); + } + break; + } + case PPT_FORMAT::etAudio: + { + if (reset_default) + { + pElement->m_bLine = false; + } + for (size_t i = 0; i < lCount; ++i) + { + SetUpPropertyAudio(pElement, pTheme, pWrapper, pSlide, &pProperties->m_arProperties[i]); + } + break; + } + case PPT_FORMAT::etGroup: + { + if (reset_default) + { + pElement->m_bLine = false; + pElement->m_bIsFilled = false; + } + for (size_t i = 0; i < lCount; ++i) + { + SetUpProperty(pElement, pTheme, pWrapper, pSlide, &pProperties->m_arProperties[i]); + } + }break; + case PPT_FORMAT::etShape: + { + CShapeElement* pShapeElem = dynamic_cast(pElement.get()); + CPPTShape* pPPTShape = dynamic_cast(pShapeElem->m_pShape->getBaseShape().get()); - if (NULL != pPPTShape) - { - pPPTShape->m_oCustomVML.SetAdjusts(&pPPTShape->m_arAdjustments); - } + if (NULL != pPPTShape) + { + pPPTShape->m_oCustomVML.SetAdjusts(&pPPTShape->m_arAdjustments); + } - for (size_t i = 0; i < lCount; ++i) - { - SetUpPropertyShape(pElement, pTheme, pWrapper, pSlide, &pProperties->m_arProperties[i]); - } + for (size_t i = 0; i < lCount; ++i) + { + SetUpPropertyShape(pElement, pTheme, pWrapper, pSlide, &pProperties->m_arProperties[i]); + } - if (false == pElement->m_bIsFilled) - { - pElement->m_oBrush.Type = c_BrushTypeNoFill; - } - else if (pElement->m_oBrush.Type == c_BrushTypeNotSet && - (pElement->m_lPlaceholderType == 0 && pElement->m_lPlaceholderID < 0 )) - { - pElement->m_oBrush.Type = c_BrushTypeSolid; - } + if (false == pElement->m_bIsFilled) + { + pElement->m_oBrush.Type = c_BrushTypeNoFill; + } + else if (pElement->m_oBrush.Type == c_BrushTypeNotSet && + (pElement->m_lPlaceholderType == 0 && pElement->m_lPlaceholderID < 0 )) + { + pElement->m_oBrush.Type = c_BrushTypeSolid; + } - if (NULL != pPPTShape) - { - pPPTShape->m_oCustomVML.ToCustomShape(pPPTShape, pPPTShape->m_oManager); - pPPTShape->ReCalculate(); - } - break; - } - default: - break; - } + if (NULL != pPPTShape) + { + pPPTShape->m_oCustomVML.ToCustomShape(pPPTShape, pPPTShape->m_oManager); + pPPTShape->ReCalculate(); + } + break; + } + default: + break; + } } void CPPTElement::SetUpProperty(CElementPtr pElement, CTheme* pTheme, CSlideInfo* pInfo, CSlide* pSlide, CProperty* pProperty) { - switch (pProperty->m_ePID) - { - case wzName: - { - pElement->m_sName = NSFile::CUtf8Converter::GetWStringFromUTF16((unsigned short*)pProperty->m_pOptions, pProperty->m_lValue /2 - 1); - }break; - case wzDescription: - { - pElement->m_sDescription = NSFile::CUtf8Converter::GetWStringFromUTF16((unsigned short*)pProperty->m_pOptions, pProperty->m_lValue /2 - 1); - }break; - case hspMaster: - { - pElement->m_lLayoutID = (LONG)pProperty->m_lValue; - }break; - case ePropertyId_rotation: - { - pElement->m_dRotate = FixedPointToDouble(pProperty->m_lValue); - }break; - case ePropertyId_fFlipH: - { - BYTE flag1 = (BYTE)pProperty->m_lValue; - BYTE flag3 = (BYTE)(pProperty->m_lValue >> 16); + switch (pProperty->m_ePID) + { + case wzName: + { + pElement->m_sName = NSFile::CUtf8Converter::GetWStringFromUTF16((unsigned short*)pProperty->m_pOptions, pProperty->m_lValue /2 - 1); + }break; + case wzDescription: + { + pElement->m_sDescription = NSFile::CUtf8Converter::GetWStringFromUTF16((unsigned short*)pProperty->m_pOptions, pProperty->m_lValue /2 - 1); + }break; + case hspMaster: + { + pElement->m_lLayoutID = (LONG)pProperty->m_lValue; + }break; + case ePropertyId_rotation: + { + pElement->m_dRotate = FixedPointToDouble(pProperty->m_lValue); + }break; + case ePropertyId_fFlipH: + { + BYTE flag1 = (BYTE)pProperty->m_lValue; + BYTE flag3 = (BYTE)(pProperty->m_lValue >> 16); - bool bFlipH = (0x01 == (0x01 & flag1)); - bool bFlipV = (0x02 == (0x02 & flag1)); + bool bFlipH = (0x01 == (0x01 & flag1)); + bool bFlipV = (0x02 == (0x02 & flag1)); - bool bUseFlipH = (0x01 == (0x01 & flag3)); - bool bUseFlipV = (0x02 == (0x02 & flag3)); + bool bUseFlipH = (0x01 == (0x01 & flag3)); + bool bUseFlipV = (0x02 == (0x02 & flag3)); - if (bUseFlipH) - pElement->m_bFlipH = bFlipH; + if (bUseFlipH) + pElement->m_bFlipH = bFlipH; - if (bUseFlipV) - pElement->m_bFlipV = bFlipV; - }break; - case fillType: - { - _UINT32 dwType = pProperty->m_lValue; - switch(dwType) - { - case ODRAW::fillPattern: - { - pElement->m_oBrush.Type = c_BrushTypePattern; - //texture + change black to color2, white to color1 - }break; - case ODRAW::fillTexture : - case ODRAW::fillPicture : - { - pElement->m_oBrush.Type = c_BrushTypeTexture; - pElement->m_oBrush.TextureMode = (ODRAW::fillPicture == dwType) ? c_BrushTextureModeStretch : c_BrushTextureModeTile; - }break; - case ODRAW::fillShadeCenter://1 color - case ODRAW::fillShadeShape: - { - pElement->m_oBrush.Type = c_BrushTypeCenter; - }break;// - case ODRAW::fillShadeTitle://2 colors and more - case ODRAW::fillShade : - case ODRAW::fillShadeScale: - { - pElement->m_oBrush.Type = c_BrushTypePathGradient1; - }break; - case ODRAW::fillBackground: - { - pElement->m_oBrush.Type = c_BrushTypeNoFill; - }break; - } - }break; - case fillBlip: - { - int dwOffset = 0 ; - - if (pProperty->m_bComplex) - { - //inline - dwOffset = -1; - } - else - { - dwOffset = pInfo->GetIndexPicture(pProperty->m_lValue); - } - int nLen = pElement->m_oBrush.TexturePath.length() - 1; - int nIndex = pElement->m_oBrush.TexturePath.rfind(FILE_SEPARATOR_CHAR); - if (nLen != nIndex) - { - pElement->m_oBrush.TexturePath.erase(nIndex + 1, nLen - nIndex); - } - - pElement->m_oBrush.TexturePath = pElement->m_oBrush.TexturePath + pInfo->GetFileNamePicture(dwOffset); - if (pElement->m_oBrush.Type == c_BrushTypePattern) - { - int rgbColor1 = 0xFFFFFF; - int rgbColor2 = 0; + if (bUseFlipV) + pElement->m_bFlipV = bFlipV; + }break; + case fillType: + { + _UINT32 dwType = pProperty->m_lValue; + switch(dwType) + { + case ODRAW::fillPattern: + { + pElement->m_oBrush.Type = c_BrushTypePattern; + //texture + change black to color2, white to color1 + }break; + case ODRAW::fillTexture : + case ODRAW::fillPicture : + { + pElement->m_oBrush.Type = c_BrushTypeTexture; + pElement->m_oBrush.TextureMode = (ODRAW::fillPicture == dwType) ? c_BrushTextureModeStretch : c_BrushTextureModeTile; + }break; + case ODRAW::fillShadeCenter://1 color + case ODRAW::fillShadeShape: + { + pElement->m_oBrush.Type = c_BrushTypeCenter; + }break;// + case ODRAW::fillShadeTitle://2 colors and more + case ODRAW::fillShade : + case ODRAW::fillShadeScale: + { + pElement->m_oBrush.Type = c_BrushTypePathGradient1; + }break; + case ODRAW::fillBackground: + { + pElement->m_oBrush.Type = c_BrushTypeNoFill; + }break; + } + }break; + case fillBlip: + { + int dwOffset = 0 ; - if (pElement->m_oBrush.Color1.m_lSchemeIndex == -1) - { - rgbColor1 = pElement->m_oBrush.Color1.GetLONG_RGB(); - } - else - { - if ((pSlide) && (pSlide->m_arColorScheme.size() > 0)) - { - rgbColor1 = pSlide->m_arColorScheme[pElement->m_oBrush.Color1.m_lSchemeIndex].GetLONG_RGB(); - } - else if ((pTheme) && (pTheme->m_arColorScheme.size() > 0)) - { - rgbColor1 = pTheme->m_arColorScheme[pElement->m_oBrush.Color1.m_lSchemeIndex].GetLONG_RGB(); - } - } - if (pElement->m_oBrush.Color2.m_lSchemeIndex == -1) - { - rgbColor2 = pElement->m_oBrush.Color2.GetLONG_RGB(); - } - else - { - if ((pSlide) && (pSlide->m_arColorScheme.size() > 0)) - { - rgbColor2 = pSlide->m_arColorScheme[pElement->m_oBrush.Color2.m_lSchemeIndex].GetLONG_RGB(); - } - else if ((pTheme) && (pTheme->m_arColorScheme.size() > 0)) - { - rgbColor2 = pTheme->m_arColorScheme[pElement->m_oBrush.Color2.m_lSchemeIndex].GetLONG_RGB(); - } - } - ChangeBlack2ColorImage(pElement->m_oBrush.TexturePath, rgbColor2, rgbColor1); - - pElement->m_oBrush.Type = c_BrushTypeTexture; - pElement->m_oBrush.TextureMode = c_BrushTextureModeTile; - } - }break; - case fillColor: - { - SColorAtom oAtom; - oAtom.FromValue(pProperty->m_lValue); + if (pProperty->m_bComplex) + { + //inline + dwOffset = -1; + } + else + { + dwOffset = pInfo->GetIndexPicture(pProperty->m_lValue); + } + int nLen = pElement->m_oBrush.TexturePath.length() - 1; + int nIndex = pElement->m_oBrush.TexturePath.rfind(FILE_SEPARATOR_CHAR); + if (nLen != nIndex) + { + pElement->m_oBrush.TexturePath.erase(nIndex + 1, nLen - nIndex); + } - if(oAtom.bSysIndex) - pElement->m_oBrush.Color1 = CorrectSysColor(pProperty->m_lValue, pElement, pTheme); - else - oAtom.ToColor(&pElement->m_oBrush.Color1); + pElement->m_oBrush.TexturePath = pElement->m_oBrush.TexturePath + pInfo->GetFileNamePicture(dwOffset); + if (pElement->m_oBrush.Type == c_BrushTypePattern) + { + int rgbColor1 = 0xFFFFFF; + int rgbColor2 = 0; - if (pElement->m_oBrush.Type == c_BrushTypeNotSet ) - pElement->m_oBrush.Type = c_BrushTypeSolid; - - }break; - case fillBackColor: - { - SColorAtom oAtom; - oAtom.FromValue(pProperty->m_lValue); + if (pElement->m_oBrush.Color1.m_lSchemeIndex == -1) + { + rgbColor1 = pElement->m_oBrush.Color1.GetLONG_RGB(); + } + else + { + if ((pSlide) && (pSlide->m_arColorScheme.size() > 0)) + { + rgbColor1 = pSlide->m_arColorScheme[pElement->m_oBrush.Color1.m_lSchemeIndex].GetLONG_RGB(); + } + else if ((pTheme) && (pTheme->m_arColorScheme.size() > 0)) + { + rgbColor1 = pTheme->m_arColorScheme[pElement->m_oBrush.Color1.m_lSchemeIndex].GetLONG_RGB(); + } + } + if (pElement->m_oBrush.Color2.m_lSchemeIndex == -1) + { + rgbColor2 = pElement->m_oBrush.Color2.GetLONG_RGB(); + } + else + { + if ((pSlide) && (pSlide->m_arColorScheme.size() > 0)) + { + rgbColor2 = pSlide->m_arColorScheme[pElement->m_oBrush.Color2.m_lSchemeIndex].GetLONG_RGB(); + } + else if ((pTheme) && (pTheme->m_arColorScheme.size() > 0)) + { + rgbColor2 = pTheme->m_arColorScheme[pElement->m_oBrush.Color2.m_lSchemeIndex].GetLONG_RGB(); + } + } + ChangeBlack2ColorImage(pElement->m_oBrush.TexturePath, rgbColor2, rgbColor1); - if(oAtom.bSysIndex) - pElement->m_oBrush.Color2 = CorrectSysColor(pProperty->m_lValue, pElement, pTheme); - else - oAtom.ToColor(&pElement->m_oBrush.Color2); - - if (pElement->m_bIsBackground && pElement->m_oBrush.Type == c_BrushTypeNotSet ) - { - pElement->m_oBrush.Type = c_BrushTypeSolid; - } - }break; - case fillOpacity: - { - pElement->m_oBrush.Alpha1 = (BYTE)(std::min)(255, (int)CDirectory::NormFixedPoint(pProperty->m_lValue, 255)); - }break; - case fillBackOpacity: - { - pElement->m_oBrush.Alpha2 = (BYTE)(std::min)(255, (int)CDirectory::NormFixedPoint(pProperty->m_lValue, 255)); - }break; - case fillAngle: - { - pElement->m_oBrush.LinearAngle = FixedPointToDouble(pProperty->m_lValue); - }break; - case fillRectLeft: - { - pElement->m_oBrush.Rect.X = pProperty->m_lValue; - pElement->m_oBrush.Rectable = true; - }break; - case fillRectRight: - { - pElement->m_oBrush.Rect.Width = pProperty->m_lValue - pElement->m_oBrush.Rect.X; - pElement->m_oBrush.Rectable = true; - }break; - case fillRectTop: - { - pElement->m_oBrush.Rect.Y = pProperty->m_lValue; - pElement->m_oBrush.Rectable = true; - }break; - case fillRectBottom: - { - pElement->m_oBrush.Rect.Height = pProperty->m_lValue - pElement->m_oBrush.Rect.Y; - pElement->m_oBrush.Rectable = true; - }break; - case fillBackground: - { - }break; - case fillShadeType: - { - bool bShadeNone = GETBIT(pProperty->m_lValue, 31); - bool bShadeGamma = GETBIT(pProperty->m_lValue, 30); - bool bShadeSigma = GETBIT(pProperty->m_lValue, 29); - bool bShadeBand = GETBIT(pProperty->m_lValue, 28); - bool bShadeOneColor = GETBIT(pProperty->m_lValue, 27); + pElement->m_oBrush.Type = c_BrushTypeTexture; + pElement->m_oBrush.TextureMode = c_BrushTextureModeTile; + } + }break; + case fillColor: + { + SColorAtom oAtom; + oAtom.FromValue(pProperty->m_lValue); - }break; - case fillFocus://relative position of the last color in the shaded fill - { - }break; - case fillShadePreset: - {//value (int) from 0x00000088 through 0x0000009F or complex - }break; - case fillShadeColors: - { - unsigned short nElems = pProperty->m_lValue/8; - _INT32* pCompl = (_INT32*)pProperty->m_pOptions; - - while(nElems--) - { - CColor color; - SColorAtom oAtom; - oAtom.FromValue(*pCompl); pCompl++; - oAtom.ToColor(&color); - - _UINT32 dwPosition = *pCompl; pCompl++; - pElement->m_oBrush.ColorsPosition.push_back(std::pair(color, 100. * FIXED_POINT_unsigned(dwPosition))); - } - }break; - case fillStyleBooleanProperties: - { - BYTE flag1 = (BYTE)(pProperty->m_lValue); - BYTE flag2 = (BYTE)(pProperty->m_lValue >> 16); + if(oAtom.bSysIndex) + pElement->m_oBrush.Color1 = CorrectSysColor(pProperty->m_lValue, pElement, pTheme); + else + oAtom.ToColor(&pElement->m_oBrush.Color1); - bool bNoFillHitTest = (0x01 == (0x01 & flag1)); - bool bFillUseRect = (0x02 == (0x02 & flag1)); - bool bFillShape = (0x04 == (0x04 & flag1)); - bool bHitTestFill = (0x08 == (0x08 & flag1)); - bool bFilled = (0x10 == (0x10 & flag1)); - bool bUseShapeAnchor = (0x20 == (0x20 & flag1)); - bool bRecolorFillAsPictures = (0x40 == (0x40 & flag1)); + if (pElement->m_oBrush.Type == c_BrushTypeNotSet ) + pElement->m_oBrush.Type = c_BrushTypeSolid; - bool bUsebNoFillHitTest = (0x01 == (0x01 & flag2)); - bool bUsebFillUseRect = (0x02 == (0x02 & flag2)); - bool bUsebFillShape = (0x04 == (0x04 & flag2)); - bool bUsebHitTestFill = (0x08 == (0x08 & flag2)); - bool bUsebFilled = (0x10 == (0x10 & flag2)); - bool bUsebUseShapeAnchor = (0x20 == (0x20 & flag2)); - bool bUsebRecolorFillAsPictures = (0x40 == (0x40 & flag2)); + }break; + case fillBackColor: + { + SColorAtom oAtom; + oAtom.FromValue(pProperty->m_lValue); - if (bUsebFilled) - pElement->m_bIsFilled = bFilled; + if(oAtom.bSysIndex) + pElement->m_oBrush.Color2 = CorrectSysColor(pProperty->m_lValue, pElement, pTheme); + else + oAtom.ToColor(&pElement->m_oBrush.Color2); - break; - } - case ODRAW::geometryBooleanProperties: - { - BYTE flag1 = (BYTE)(pProperty->m_lValue); - BYTE flag2 = (BYTE)(pProperty->m_lValue >> 8); - BYTE flag3 = (BYTE)(pProperty->m_lValue >> 16); - BYTE flag4 = (BYTE)(pProperty->m_lValue >> 24); + if (pElement->m_bIsBackground && pElement->m_oBrush.Type == c_BrushTypeNotSet ) + { + pElement->m_oBrush.Type = c_BrushTypeSolid; + } + }break; + case fillOpacity: + { + pElement->m_oBrush.Alpha1 = (BYTE)(std::min)(255, (int)CDirectory::NormFixedPoint(pProperty->m_lValue, 255)); + }break; + case fillBackOpacity: + { + pElement->m_oBrush.Alpha2 = (BYTE)(std::min)(255, (int)CDirectory::NormFixedPoint(pProperty->m_lValue, 255)); + }break; + case fillAngle: + { + pElement->m_oBrush.LinearAngle = FixedPointToDouble(pProperty->m_lValue); + }break; + case fillRectLeft: + { + pElement->m_oBrush.Rect.X = pProperty->m_lValue; + pElement->m_oBrush.Rectable = true; + }break; + case fillRectRight: + { + pElement->m_oBrush.Rect.Width = pProperty->m_lValue - pElement->m_oBrush.Rect.X; + pElement->m_oBrush.Rectable = true; + }break; + case fillRectTop: + { + pElement->m_oBrush.Rect.Y = pProperty->m_lValue; + pElement->m_oBrush.Rectable = true; + }break; + case fillRectBottom: + { + pElement->m_oBrush.Rect.Height = pProperty->m_lValue - pElement->m_oBrush.Rect.Y; + pElement->m_oBrush.Rectable = true; + }break; + case fillBackground: + { + }break; + case fillShadeType: + { + bool bShadeNone = GETBIT(pProperty->m_lValue, 31); + bool bShadeGamma = GETBIT(pProperty->m_lValue, 30); + bool bShadeSigma = GETBIT(pProperty->m_lValue, 29); + bool bShadeBand = GETBIT(pProperty->m_lValue, 28); + bool bShadeOneColor = GETBIT(pProperty->m_lValue, 27); - bool bFillOk = (0x01 == (0x01 & flag1)); - bool bFillShadeShapeOk = (0x02 == (0x02 & flag1)); - bool bGTextOk = (0x04 == (0x04 & flag1)); - bool bLineOk = (0x08 == (0x08 & flag1)); - bool b3DOk = (0x10 == (0x10 & flag1)); - bool bShadowOk = (0x20 == (0x20 & flag1)); + }break; + case fillFocus://relative position of the last color in the shaded fill + { + }break; + case fillShadePreset: + {//value (int) from 0x00000088 through 0x0000009F or complex + }break; + case fillShadeColors: + { + unsigned short nElems = pProperty->m_lValue/8; + _INT32* pCompl = (_INT32*)pProperty->m_pOptions; - bool bUseFillOk = (0x01 == (0x01 & flag3)); - bool bUseFillShadeShapeOk = (0x02 == (0x02 & flag3)); - bool bUseGTextOk = (0x04 == (0x04 & flag3)); - bool bUseLineOk = (0x08 == (0x08 & flag3)); - bool bUse3DOk = (0x10 == (0x10 & flag3)); - bool bUseShadowOk = (0x20 == (0x20 & flag3)); + while(nElems--) + { + CColor color; + SColorAtom oAtom; + oAtom.FromValue(*pCompl); pCompl++; + oAtom.ToColor(&color); - //if (bUseLineOk) - // pElement->m_bLine = bLineOk;//?? todooo проверить - не сраюатывает ! 1 (82).ppt + _UINT32 dwPosition = *pCompl; pCompl++; + pElement->m_oBrush.ColorsPosition.push_back(std::pair(color, 100. * FIXED_POINT_unsigned(dwPosition))); + } + }break; + case fillStyleBooleanProperties: + { + BYTE flag1 = (BYTE)(pProperty->m_lValue); + BYTE flag2 = (BYTE)(pProperty->m_lValue >> 16); - if (bUseFillOk) - pElement->m_bIsFilled = bFillOk; + bool bNoFillHitTest = (0x01 == (0x01 & flag1)); + bool bFillUseRect = (0x02 == (0x02 & flag1)); + bool bFillShape = (0x04 == (0x04 & flag1)); + bool bHitTestFill = (0x08 == (0x08 & flag1)); + bool bFilled = (0x10 == (0x10 & flag1)); + bool bUseShapeAnchor = (0x20 == (0x20 & flag1)); + bool bRecolorFillAsPictures = (0x40 == (0x40 & flag1)); - break; - } -// line -------------------------------------------------------- - case lineStyleBooleanProperties: //Line Style Boolean Properties - { - bool bUsefLineOpaqueBackColor = GETBIT(pProperty->m_lValue, 25); - bool bUsefInsetPen = GETBIT(pProperty->m_lValue, 22); - bool bUsefInsetPenOK = GETBIT(pProperty->m_lValue, 21); - bool bUsefArrowheadsOK = GETBIT(pProperty->m_lValue, 20); - bool bUsefLine = GETBIT(pProperty->m_lValue, 19); - bool bUsefHitTestLine = GETBIT(pProperty->m_lValue, 18); - bool bUsefLineFillShape = GETBIT(pProperty->m_lValue, 17); - bool bUsefNoLineDrawDash = GETBIT(pProperty->m_lValue, 16); + bool bUsebNoFillHitTest = (0x01 == (0x01 & flag2)); + bool bUsebFillUseRect = (0x02 == (0x02 & flag2)); + bool bUsebFillShape = (0x04 == (0x04 & flag2)); + bool bUsebHitTestFill = (0x08 == (0x08 & flag2)); + bool bUsebFilled = (0x10 == (0x10 & flag2)); + bool bUsebUseShapeAnchor = (0x20 == (0x20 & flag2)); + bool bUsebRecolorFillAsPictures = (0x40 == (0x40 & flag2)); - bool bLineOpaqueBackColor = GETBIT(pProperty->m_lValue, 9); - bool bInsetPen = GETBIT(pProperty->m_lValue, 6); - bool bInsetPenOK = GETBIT(pProperty->m_lValue, 5); - bool bArrowheadsOK = GETBIT(pProperty->m_lValue, 4); - bool bLine = GETBIT(pProperty->m_lValue, 3); - bool bHitTestLine = GETBIT(pProperty->m_lValue, 2); - bool bLineFillShape = GETBIT(pProperty->m_lValue, 1); - bool bNoLineDrawDash = GETBIT(pProperty->m_lValue, 0); + if (bUsebFilled) + pElement->m_bIsFilled = bFilled; - if (bUsefLine) - pElement->m_bLine = bLine; - }break; - case lineDashStyle://from Complex - { - pElement->m_bLine = true; - }break; - case lineColor: - { - pElement->m_bLine = true; - - SColorAtom oAtom; - oAtom.FromValue(pProperty->m_lValue); - - if (oAtom.bSysIndex) - pElement->m_oPen.Color = CorrectSysColor(pProperty->m_lValue, pElement, pTheme); - else - oAtom.ToColor(&pElement->m_oPen.Color); - }break; - case lineOpacity: - { - pElement->m_oPen.Alpha = (BYTE)(std::min)(255, (int)CDirectory::NormFixedPoint(pProperty->m_lValue, 255)); - }break; - case lineBackColor: - { - SColorAtom oAtom; - oAtom.FromValue(pProperty->m_lValue); - - if (oAtom.bSysIndex) - pElement->m_oPen.Color2 = CorrectSysColor(pProperty->m_lValue, pElement, pTheme); - else - oAtom.ToColor(&pElement->m_oPen.Color2); + break; + } + case ODRAW::geometryBooleanProperties: + { + BYTE flag1 = (BYTE)(pProperty->m_lValue); + BYTE flag2 = (BYTE)(pProperty->m_lValue >> 8); + BYTE flag3 = (BYTE)(pProperty->m_lValue >> 16); + BYTE flag4 = (BYTE)(pProperty->m_lValue >> 24); - }break; - case lineWidth: - { - pElement->m_oPen.Size = pProperty->m_lValue; - pElement->m_bLine = true; - }break; - case lineStyle: - { - pElement->m_bLine = true; - pElement->m_oPen.LineStyle = pProperty->m_lValue; - }break; - case lineDashing: - { - pElement->m_bLine = true; - pElement->m_oPen.DashStyle = pProperty->m_lValue; - }break; - case lineJoinStyle: - { - pElement->m_oPen.LineJoin = pProperty->m_lValue; - }break; - case lineStartArrowLength: - { - pElement->m_oPen.LineStartLength = pProperty->m_lValue; - }break; - case lineEndArrowLength: - { - pElement->m_oPen.LineEndLength = pProperty->m_lValue; - }break; - case lineStartArrowWidth: - { - pElement->m_oPen.LineStartWidth = pProperty->m_lValue; - }break; - case lineEndArrowWidth: - { - pElement->m_oPen.LineEndWidth = pProperty->m_lValue; - }break; - case lineStartArrowhead: - { - pElement->m_oPen.LineStartCap = pProperty->m_lValue; - }break; - case lineEndArrowhead: - { - pElement->m_oPen.LineEndCap = pProperty->m_lValue; - }break; - case shadowType: - { - pElement->m_oShadow.Type = pProperty->m_lValue; - }break; - case shadowOriginX://in emu, relative from center shape - { - pElement->m_oShadow.OriginX = FixedPointToDouble(pProperty->m_lValue); - }break; - case shadowOriginY: - { - pElement->m_oShadow.OriginY = FixedPointToDouble(pProperty->m_lValue); - }break; - case shadowColor: - { - SColorAtom oAtom; - oAtom.FromValue(pProperty->m_lValue); + bool bFillOk = (0x01 == (0x01 & flag1)); + bool bFillShadeShapeOk = (0x02 == (0x02 & flag1)); + bool bGTextOk = (0x04 == (0x04 & flag1)); + bool bLineOk = (0x08 == (0x08 & flag1)); + bool b3DOk = (0x10 == (0x10 & flag1)); + bool bShadowOk = (0x20 == (0x20 & flag1)); - if (oAtom.bSysIndex) - pElement->m_oShadow.Color = CorrectSysColor(pProperty->m_lValue, pElement, pTheme); - else - oAtom.ToColor(&pElement->m_oShadow.Color); + bool bUseFillOk = (0x01 == (0x01 & flag3)); + bool bUseFillShadeShapeOk = (0x02 == (0x02 & flag3)); + bool bUseGTextOk = (0x04 == (0x04 & flag3)); + bool bUseLineOk = (0x08 == (0x08 & flag3)); + bool bUse3DOk = (0x10 == (0x10 & flag3)); + bool bUseShadowOk = (0x20 == (0x20 & flag3)); - }break; - case shadowWeight: - { - }break; - case shadowOpacity: - { + //if (bUseLineOk) + // pElement->m_bLine = bLineOk;//?? todooo проверить - не сраюатывает ! 1 (82).ppt + + if (bUseFillOk) + pElement->m_bIsFilled = bFillOk; + + break; + } + // line -------------------------------------------------------- + case lineStyleBooleanProperties: //Line Style Boolean Properties + { + bool bUsefLineOpaqueBackColor = GETBIT(pProperty->m_lValue, 25); + bool bUsefInsetPen = GETBIT(pProperty->m_lValue, 22); + bool bUsefInsetPenOK = GETBIT(pProperty->m_lValue, 21); + bool bUsefArrowheadsOK = GETBIT(pProperty->m_lValue, 20); + bool bUsefLine = GETBIT(pProperty->m_lValue, 19); + bool bUsefHitTestLine = GETBIT(pProperty->m_lValue, 18); + bool bUsefLineFillShape = GETBIT(pProperty->m_lValue, 17); + bool bUsefNoLineDrawDash = GETBIT(pProperty->m_lValue, 16); + + bool bLineOpaqueBackColor = GETBIT(pProperty->m_lValue, 9); + bool bInsetPen = GETBIT(pProperty->m_lValue, 6); + bool bInsetPenOK = GETBIT(pProperty->m_lValue, 5); + bool bArrowheadsOK = GETBIT(pProperty->m_lValue, 4); + bool bLine = GETBIT(pProperty->m_lValue, 3); + bool bHitTestLine = GETBIT(pProperty->m_lValue, 2); + bool bLineFillShape = GETBIT(pProperty->m_lValue, 1); + bool bNoLineDrawDash = GETBIT(pProperty->m_lValue, 0); + + if (bUsefLine) + pElement->m_bLine = bLine; + }break; + case lineDashStyle://from Complex + { + pElement->m_bLine = true; + }break; + case lineColor: + { + pElement->m_bLine = true; + + SColorAtom oAtom; + oAtom.FromValue(pProperty->m_lValue); + + if (oAtom.bSysIndex) + pElement->m_oPen.Color = CorrectSysColor(pProperty->m_lValue, pElement, pTheme); + else + oAtom.ToColor(&pElement->m_oPen.Color); + }break; + case lineOpacity: + { + pElement->m_oPen.Alpha = (BYTE)(std::min)(255, (int)CDirectory::NormFixedPoint(pProperty->m_lValue, 255)); + }break; + case lineBackColor: + { + SColorAtom oAtom; + oAtom.FromValue(pProperty->m_lValue); + + if (oAtom.bSysIndex) + pElement->m_oPen.Color2 = CorrectSysColor(pProperty->m_lValue, pElement, pTheme); + else + oAtom.ToColor(&pElement->m_oPen.Color2); + + }break; + case lineWidth: + { + pElement->m_oPen.Size = pProperty->m_lValue; + pElement->m_bLine = true; + }break; + case lineStyle: + { + pElement->m_bLine = true; + pElement->m_oPen.LineStyle = pProperty->m_lValue; + }break; + case lineDashing: + { + pElement->m_bLine = true; + pElement->m_oPen.DashStyle = pProperty->m_lValue; + }break; + case lineJoinStyle: + { + pElement->m_oPen.LineJoin = pProperty->m_lValue; + }break; + case lineStartArrowLength: + { + pElement->m_oPen.LineStartLength = pProperty->m_lValue; + }break; + case lineEndArrowLength: + { + pElement->m_oPen.LineEndLength = pProperty->m_lValue; + }break; + case lineStartArrowWidth: + { + pElement->m_oPen.LineStartWidth = pProperty->m_lValue; + }break; + case lineEndArrowWidth: + { + pElement->m_oPen.LineEndWidth = pProperty->m_lValue; + }break; + case lineStartArrowhead: + { + pElement->m_oPen.LineStartCap = pProperty->m_lValue; + }break; + case lineEndArrowhead: + { + pElement->m_oPen.LineEndCap = pProperty->m_lValue; + }break; + case shadowType: + { + pElement->m_oShadow.Type = pProperty->m_lValue; + }break; + case shadowOriginX://in emu, relative from center shape + { + pElement->m_oShadow.OriginX = FixedPointToDouble(pProperty->m_lValue); + }break; + case shadowOriginY: + { + pElement->m_oShadow.OriginY = FixedPointToDouble(pProperty->m_lValue); + }break; + case shadowColor: + { + SColorAtom oAtom; + oAtom.FromValue(pProperty->m_lValue); + + if (oAtom.bSysIndex) + pElement->m_oShadow.Color = CorrectSysColor(pProperty->m_lValue, pElement, pTheme); + else + oAtom.ToColor(&pElement->m_oShadow.Color); + + }break; + case shadowWeight: + { + }break; + case shadowOpacity: + { pElement->m_oShadow.Alpha = (BYTE)(std::min)(255, (int)CDirectory::NormFixedPoint(pProperty->m_lValue, 255)); - }break; - case shadowHighlight: - { - //оттенок двойной тени - }break; - case shadowOffsetX: - {//signed - pElement->m_oShadow.DistanceX = (_INT32)pProperty->m_lValue; - }break; - case shadowOffsetY: - {//signed - pElement->m_oShadow.DistanceY = (_INT32)pProperty->m_lValue; - }break; - case shadowScaleXToX: - { - pElement->m_oShadow.ScaleXToX = FixedPointToDouble(pProperty->m_lValue); - }break; - case shadowScaleYToX: - { - pElement->m_oShadow.ScaleYToX = FixedPointToDouble(pProperty->m_lValue); - }break; - case shadowScaleXToY: - { - pElement->m_oShadow.ScaleXToY = FixedPointToDouble(pProperty->m_lValue); - }break; - case shadowScaleYToY: - { - pElement->m_oShadow.ScaleYToY = FixedPointToDouble(pProperty->m_lValue); - }break; - case shadowPerspectiveX: - { - pElement->m_oShadow.PerspectiveX = pProperty->m_lValue; - }break; - case shadowPerspectiveY: - { - pElement->m_oShadow.PerspectiveY = pProperty->m_lValue; - }break; - case shadowStyleBooleanProperties: - { - bool fshadowObscured = GETBIT(pProperty->m_lValue, 0); - bool fShadow = GETBIT(pProperty->m_lValue, 1); - bool fUsefshadowObscured = GETBIT(pProperty->m_lValue, 16); - bool fUsefShadow = GETBIT(pProperty->m_lValue, 17); + }break; + case shadowHighlight: + { + //оттенок двойной тени + }break; + case shadowOffsetX: + {//signed + pElement->m_oShadow.DistanceX = (_INT32)pProperty->m_lValue; + }break; + case shadowOffsetY: + {//signed + pElement->m_oShadow.DistanceY = (_INT32)pProperty->m_lValue; + }break; + case shadowScaleXToX: + { + pElement->m_oShadow.ScaleXToX = FixedPointToDouble(pProperty->m_lValue); + }break; + case shadowScaleYToX: + { + pElement->m_oShadow.ScaleYToX = FixedPointToDouble(pProperty->m_lValue); + }break; + case shadowScaleXToY: + { + pElement->m_oShadow.ScaleXToY = FixedPointToDouble(pProperty->m_lValue); + }break; + case shadowScaleYToY: + { + pElement->m_oShadow.ScaleYToY = FixedPointToDouble(pProperty->m_lValue); + }break; + case shadowPerspectiveX: + { + pElement->m_oShadow.PerspectiveX = pProperty->m_lValue; + }break; + case shadowPerspectiveY: + { + pElement->m_oShadow.PerspectiveY = pProperty->m_lValue; + }break; + case shadowStyleBooleanProperties: + { + bool fshadowObscured = GETBIT(pProperty->m_lValue, 0); + bool fShadow = GETBIT(pProperty->m_lValue, 1); + bool fUsefshadowObscured = GETBIT(pProperty->m_lValue, 16); + bool fUsefShadow = GETBIT(pProperty->m_lValue, 17); - if (fUsefShadow) - pElement->m_oShadow.Visible = fShadow; - - if (!fUsefShadow && fUsefshadowObscured) - { - //контурная - pElement->m_oShadow.Visible = fshadowObscured; - } - }break; - case shapeBoolean: - { - bool fUsefPolicyLabel = GETBIT(pProperty->m_lValue, 25); - bool fUsefPolicyBarcode = GETBIT(pProperty->m_lValue, 24); - bool fUsefFlipHOverride = GETBIT(pProperty->m_lValue, 23); - bool fUsefFlipVOverride = GETBIT(pProperty->m_lValue, 22); - bool fUsefOleIcon = GETBIT(pProperty->m_lValue, 21); - bool fUsefPreferRelativeResize = GETBIT(pProperty->m_lValue, 20); - bool fUsefLockShapeType = GETBIT(pProperty->m_lValue, 19); - bool fUsefInitiator = GETBIT(pProperty->m_lValue, 18); - bool fUsefBackground = GETBIT(pProperty->m_lValue, 16); - - bool fPolicyLabel = fUsefPolicyLabel ? GETBIT(pProperty->m_lValue, 9) : false; - bool fPolicyBarcode = fUsefPolicyBarcode ? GETBIT(pProperty->m_lValue, 8) : false; - bool fFlipHOverride = fUsefFlipHOverride ? GETBIT(pProperty->m_lValue, 7) : false; - bool fFlipVOverride = fUsefFlipVOverride ? GETBIT(pProperty->m_lValue, 6) : false; - bool fOleIcon = fUsefOleIcon ? GETBIT(pProperty->m_lValue, 5) : false; - bool fPreferRelativeResize = fUsefPreferRelativeResize ? GETBIT(pProperty->m_lValue, 4) : false; - bool fLockShapeType = fUsefLockShapeType ? GETBIT(pProperty->m_lValue, 3) : false; - bool fInitiator = fUsefInitiator ? GETBIT(pProperty->m_lValue, 2) : false; - bool fBackground = fUsefBackground ? GETBIT(pProperty->m_lValue, 0) : false; - }break; - case groupShapeBooleanProperties: - { - bool fUsefLayoutInCell = GETBIT(pProperty->m_lValue, 31); - bool fUsefIsBullet = GETBIT(pProperty->m_lValue, 30); - bool fUsefStandardHR = GETBIT(pProperty->m_lValue, 29); - bool fUsefNoshadeHR = GETBIT(pProperty->m_lValue, 28); - bool fUsefHorizRule = GETBIT(pProperty->m_lValue, 27); - bool fUsefUserDrawn = GETBIT(pProperty->m_lValue, 26); - bool fUsefAllowOverlap = GETBIT(pProperty->m_lValue, 25); - bool fUsefReallyHidden = GETBIT(pProperty->m_lValue, 24); - bool fUsefScriptAnchor = GETBIT(pProperty->m_lValue, 23); - bool fUsefEditedWrap = GETBIT(pProperty->m_lValue, 22); - bool fUsefBehindDocument = GETBIT(pProperty->m_lValue, 21); - bool fUsefOnDblClickNotify = GETBIT(pProperty->m_lValue, 20); - bool fUsefIsButton = GETBIT(pProperty->m_lValue, 19); - bool fUsefOneD = GETBIT(pProperty->m_lValue, 18); - bool fUsefHidden = GETBIT(pProperty->m_lValue, 17); - bool fUsefPrint = GETBIT(pProperty->m_lValue, 16); - - bool fLayoutInCell = fUsefLayoutInCell ? GETBIT(pProperty->m_lValue, 15) : true; - bool fIsBullet = fUsefIsBullet ? GETBIT(pProperty->m_lValue, 14) : false; - bool fStandardHR = fUsefStandardHR ? GETBIT(pProperty->m_lValue, 13) : false; - bool fNoshadeHR = fUsefNoshadeHR ? GETBIT(pProperty->m_lValue, 12) : false; - bool fHorizRule = fUsefHorizRule ? GETBIT(pProperty->m_lValue, 11) : false; - bool fUserDrawn = fUsefUserDrawn ? GETBIT(pProperty->m_lValue, 10) : false; - bool fAllowOverlap = fUsefAllowOverlap ? GETBIT(pProperty->m_lValue, 9) : true; - bool fReallyHidden = fUsefReallyHidden ? GETBIT(pProperty->m_lValue, 8) : false; - bool fScriptAnchor = fUsefScriptAnchor ? GETBIT(pProperty->m_lValue, 7) : false; - bool fEditedWrap = fUsefEditedWrap ? GETBIT(pProperty->m_lValue, 6) : false; - bool fBehindDocument = fUsefBehindDocument ? GETBIT(pProperty->m_lValue, 5) : false; - bool fOnDblClickNotify = fUsefOnDblClickNotify ? GETBIT(pProperty->m_lValue, 4) : false; - bool fIsButton = fUsefIsButton ? GETBIT(pProperty->m_lValue, 3) : false; - bool fOneD = fUsefOneD ? GETBIT(pProperty->m_lValue, 2) : false; - bool fHidden = fUsefHidden ? GETBIT(pProperty->m_lValue, 1) : false; - bool fPrint = fUsefPrint ? GETBIT(pProperty->m_lValue, 0) : true; + if (fUsefShadow) + pElement->m_oShadow.Visible = fShadow; - pElement->m_bHidden = fHidden || fIsBullet; - //presentation_ticio_20100610.ppt - }break; - default: - break; - } + if (!fUsefShadow && fUsefshadowObscured) + { + //контурная + pElement->m_oShadow.Visible = fshadowObscured; + } + }break; + case shapeBoolean: + { + bool fUsefPolicyLabel = GETBIT(pProperty->m_lValue, 25); + bool fUsefPolicyBarcode = GETBIT(pProperty->m_lValue, 24); + bool fUsefFlipHOverride = GETBIT(pProperty->m_lValue, 23); + bool fUsefFlipVOverride = GETBIT(pProperty->m_lValue, 22); + bool fUsefOleIcon = GETBIT(pProperty->m_lValue, 21); + bool fUsefPreferRelativeResize = GETBIT(pProperty->m_lValue, 20); + bool fUsefLockShapeType = GETBIT(pProperty->m_lValue, 19); + bool fUsefInitiator = GETBIT(pProperty->m_lValue, 18); + bool fUsefBackground = GETBIT(pProperty->m_lValue, 16); + + bool fPolicyLabel = fUsefPolicyLabel ? GETBIT(pProperty->m_lValue, 9) : false; + bool fPolicyBarcode = fUsefPolicyBarcode ? GETBIT(pProperty->m_lValue, 8) : false; + bool fFlipHOverride = fUsefFlipHOverride ? GETBIT(pProperty->m_lValue, 7) : false; + bool fFlipVOverride = fUsefFlipVOverride ? GETBIT(pProperty->m_lValue, 6) : false; + bool fOleIcon = fUsefOleIcon ? GETBIT(pProperty->m_lValue, 5) : false; + bool fPreferRelativeResize = fUsefPreferRelativeResize ? GETBIT(pProperty->m_lValue, 4) : false; + bool fLockShapeType = fUsefLockShapeType ? GETBIT(pProperty->m_lValue, 3) : false; + bool fInitiator = fUsefInitiator ? GETBIT(pProperty->m_lValue, 2) : false; + bool fBackground = fUsefBackground ? GETBIT(pProperty->m_lValue, 0) : false; + }break; + case groupShapeBooleanProperties: + { + bool fUsefLayoutInCell = GETBIT(pProperty->m_lValue, 31); + bool fUsefIsBullet = GETBIT(pProperty->m_lValue, 30); + bool fUsefStandardHR = GETBIT(pProperty->m_lValue, 29); + bool fUsefNoshadeHR = GETBIT(pProperty->m_lValue, 28); + bool fUsefHorizRule = GETBIT(pProperty->m_lValue, 27); + bool fUsefUserDrawn = GETBIT(pProperty->m_lValue, 26); + bool fUsefAllowOverlap = GETBIT(pProperty->m_lValue, 25); + bool fUsefReallyHidden = GETBIT(pProperty->m_lValue, 24); + bool fUsefScriptAnchor = GETBIT(pProperty->m_lValue, 23); + bool fUsefEditedWrap = GETBIT(pProperty->m_lValue, 22); + bool fUsefBehindDocument = GETBIT(pProperty->m_lValue, 21); + bool fUsefOnDblClickNotify = GETBIT(pProperty->m_lValue, 20); + bool fUsefIsButton = GETBIT(pProperty->m_lValue, 19); + bool fUsefOneD = GETBIT(pProperty->m_lValue, 18); + bool fUsefHidden = GETBIT(pProperty->m_lValue, 17); + bool fUsefPrint = GETBIT(pProperty->m_lValue, 16); + + bool fLayoutInCell = fUsefLayoutInCell ? GETBIT(pProperty->m_lValue, 15) : true; + bool fIsBullet = fUsefIsBullet ? GETBIT(pProperty->m_lValue, 14) : false; + bool fStandardHR = fUsefStandardHR ? GETBIT(pProperty->m_lValue, 13) : false; + bool fNoshadeHR = fUsefNoshadeHR ? GETBIT(pProperty->m_lValue, 12) : false; + bool fHorizRule = fUsefHorizRule ? GETBIT(pProperty->m_lValue, 11) : false; + bool fUserDrawn = fUsefUserDrawn ? GETBIT(pProperty->m_lValue, 10) : false; + bool fAllowOverlap = fUsefAllowOverlap ? GETBIT(pProperty->m_lValue, 9) : true; + bool fReallyHidden = fUsefReallyHidden ? GETBIT(pProperty->m_lValue, 8) : false; + bool fScriptAnchor = fUsefScriptAnchor ? GETBIT(pProperty->m_lValue, 7) : false; + bool fEditedWrap = fUsefEditedWrap ? GETBIT(pProperty->m_lValue, 6) : false; + bool fBehindDocument = fUsefBehindDocument ? GETBIT(pProperty->m_lValue, 5) : false; + bool fOnDblClickNotify = fUsefOnDblClickNotify ? GETBIT(pProperty->m_lValue, 4) : false; + bool fIsButton = fUsefIsButton ? GETBIT(pProperty->m_lValue, 3) : false; + bool fOneD = fUsefOneD ? GETBIT(pProperty->m_lValue, 2) : false; + bool fHidden = fUsefHidden ? GETBIT(pProperty->m_lValue, 1) : false; + bool fPrint = fUsefPrint ? GETBIT(pProperty->m_lValue, 0) : true; + + pElement->m_bHidden = fHidden || fIsBullet; + //presentation_ticio_20100610.ppt + }break; + case tableProperties: + case tableRowProperties: + { + pElement->m_etType = etTable; + break; + } + default: + break; + } } void CPPTElement::SetUpPropertyVideo(CElementPtr pElement, CTheme* pTheme, CSlideInfo* pInfo, CSlide* pSlide, CProperty* pProperty) { - SetUpPropertyImage(pElement, pTheme, pInfo, pSlide, pProperty); + SetUpPropertyImage(pElement, pTheme, pInfo, pSlide, pProperty); } void CPPTElement::SetUpPropertyAudio(CElementPtr pElement, CTheme* pTheme, CSlideInfo* pInfo, CSlide* pSlide, CProperty* pProperty) { - SetUpPropertyImage(pElement, pTheme, pInfo, pSlide, pProperty); + SetUpPropertyImage(pElement, pTheme, pInfo, pSlide, pProperty); } void CPPTElement::SetUpPropertyImage(CElementPtr pElement, CTheme* pTheme, CSlideInfo* pInfo, CSlide* pSlide, CProperty* pProperty) { - SetUpProperty(pElement, pTheme, pInfo, pSlide, pProperty); + SetUpProperty(pElement, pTheme, pInfo, pSlide, pProperty); - CImageElement* image_element = dynamic_cast(pElement.get()); + CImageElement* image_element = dynamic_cast(pElement.get()); - switch(pProperty->m_ePID) - { - case pib: - { - int dwOffset = pInfo->GetIndexPicture(pProperty->m_lValue); - if (dwOffset >=0) - { - image_element->m_strImageFileName += pInfo->GetFileNamePicture(dwOffset); - image_element->m_bImagePresent = true; - } - }break; - case pictureId://OLE identifier of the picture. - { - image_element->m_bOLE = true; - }break; - case pibName: - { - image_element->m_sImageName = NSFile::CUtf8Converter::GetWStringFromUTF16((unsigned short*)pProperty->m_pOptions, pProperty->m_lValue /2-1); - // TextMining05.ppt, слайд 20 - некорректное имя ( - todooo потом подчистить его - }break; - case cropFromTop: - { - image_element->m_lcropFromTop = (_INT32)pProperty->m_lValue; - image_element->m_bCropEnabled = true; - }break; - case cropFromBottom: - { - image_element->m_lcropFromBottom = (_INT32)pProperty->m_lValue; - image_element->m_bCropEnabled = true; - }break; - case cropFromLeft: - { - image_element->m_lcropFromLeft = (_INT32)pProperty->m_lValue; - image_element->m_bCropEnabled = true; - }break; - case cropFromRight: - { - image_element->m_lcropFromRight = (_INT32)pProperty->m_lValue; - image_element->m_bCropEnabled = true; - }break; - case pibFlags: - { - }break; - } + switch(pProperty->m_ePID) + { + case pib: + { + int dwOffset = pInfo->GetIndexPicture(pProperty->m_lValue); + if (dwOffset >=0) + { + image_element->m_strImageFileName += pInfo->GetFileNamePicture(dwOffset); + image_element->m_bImagePresent = true; + } + }break; + case pictureId://OLE identifier of the picture. + { + image_element->m_bOLE = true; + }break; + case pibName: + { + image_element->m_sImageName = NSFile::CUtf8Converter::GetWStringFromUTF16((unsigned short*)pProperty->m_pOptions, pProperty->m_lValue /2-1); + // TextMining05.ppt, слайд 20 - некорректное имя ( - todooo потом подчистить его + }break; + case cropFromTop: + { + image_element->m_lcropFromTop = (_INT32)pProperty->m_lValue; + image_element->m_bCropEnabled = true; + }break; + case cropFromBottom: + { + image_element->m_lcropFromBottom = (_INT32)pProperty->m_lValue; + image_element->m_bCropEnabled = true; + }break; + case cropFromLeft: + { + image_element->m_lcropFromLeft = (_INT32)pProperty->m_lValue; + image_element->m_bCropEnabled = true; + }break; + case cropFromRight: + { + image_element->m_lcropFromRight = (_INT32)pProperty->m_lValue; + image_element->m_bCropEnabled = true; + }break; + case pibFlags: + { + }break; + } } void CPPTElement::SetUpPropertyShape(CElementPtr pElement, CTheme* pTheme, CSlideInfo* pInfo, CSlide* pSlide, CProperty* pProperty) { - SetUpProperty(pElement, pTheme, pInfo, pSlide, pProperty); + SetUpProperty(pElement, pTheme, pInfo, pSlide, pProperty); - CShapeElement* shape_element = dynamic_cast(pElement.get()); + CShapeElement* shape_element = dynamic_cast(pElement.get()); - CShapePtr pParentShape = shape_element->m_pShape; - if (NULL == pParentShape) - return; + CShapePtr pParentShape = shape_element->m_pShape; + if (NULL == pParentShape) + return; - CPPTShape* pShape = dynamic_cast(pParentShape->getBaseShape().get()); + CPPTShape* pShape = dynamic_cast(pParentShape->getBaseShape().get()); - if (NULL == pShape) - return; + if (NULL == pShape) + return; - switch (pProperty->m_ePID) - { - case ODRAW::metroBlob: - { - NSFile::CFileBinary file; + switch (pProperty->m_ePID) + { + case ODRAW::metroBlob: + { + NSFile::CFileBinary file; std::wstring temp = NSDirectory::GetTempPath(); - std::wstring tempFileName = temp + FILE_SEPARATOR_STR + L"tempMetroBlob.zip"; + std::wstring tempFileName = temp + FILE_SEPARATOR_STR + L"tempMetroBlob.zip"; - if (file.CreateFileW(tempFileName)) - { - file.WriteFile(pProperty->m_pOptions, pProperty->m_lValue); - file.CloseFile(); - } - COfficeUtils officeUtils(NULL); + if (file.CreateFileW(tempFileName)) + { + file.WriteFile(pProperty->m_pOptions, pProperty->m_lValue); + file.CloseFile(); + } + COfficeUtils officeUtils(NULL); - BYTE *utf8Data = NULL; - ULONG utf8DataSize = 0; - if (S_OK != officeUtils.LoadFileFromArchive(tempFileName, L"drs/shapexml.xml", &utf8Data, utf8DataSize)) - { - officeUtils.LoadFileFromArchive(tempFileName, L"drs/diagrams/drawing1.xml", &utf8Data, utf8DataSize); - } + BYTE *utf8Data = NULL; + ULONG utf8DataSize = 0; + if (S_OK != officeUtils.LoadFileFromArchive(tempFileName, L"drs/shapexml.xml", &utf8Data, utf8DataSize)) + { + officeUtils.LoadFileFromArchive(tempFileName, L"drs/diagrams/drawing1.xml", &utf8Data, utf8DataSize); + } - if (utf8Data && utf8DataSize > 0) - { - pParentShape->m_strXmlString = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8(utf8Data, utf8DataSize); + if (utf8Data && utf8DataSize > 0) + { + pParentShape->m_strXmlString = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8(utf8Data, utf8DataSize); - delete []utf8Data; - } - NSFile::CFileBinary::Remove(tempFileName); - }break; - case ODRAW::geoRight: - { - if (0 < pProperty->m_lValue) - pParentShape->m_dWidthLogic = (double)(pProperty->m_lValue); - }break; - case ODRAW::geoBottom: - { - if (0 < pProperty->m_lValue) - pParentShape->m_dHeightLogic = (double)(pProperty->m_lValue); - }break; - case ODRAW::shapePath: - { - pShape->m_oCustomVML.SetPath((RulesType)pProperty->m_lValue); - pShape->m_bCustomShape = true; - }break; - case ODRAW::pSegmentInfo: - { - if (pProperty->m_bComplex) - { - pShape->m_oCustomVML.LoadSegments(pProperty); - pShape->m_bCustomShape = true; - } - }break; - case ODRAW::pVertices: - { - if (pProperty->m_bComplex) - { - pShape->m_oCustomVML.LoadVertices(pProperty); - pShape->m_bCustomShape = true; - } - }break; - case ODRAW::pConnectionSites: - { - if (pProperty->m_bComplex) - { - pShape->m_oCustomVML.LoadConnectionSites(pProperty); - } - }break; - case ODRAW::pConnectionSitesDir: - { - if (pProperty->m_bComplex) - { - pShape->m_oCustomVML.LoadConnectionSitesDir(pProperty); - } - }break; - case ODRAW::pGuides: - { - if (pProperty->m_bComplex/* && pShape->m_eType != sptNotchedCircularArrow*/) - {//Тікбұрышты үшбұрыштарды.ppt - slide 25 - pShape->m_oCustomVML.LoadGuides(pProperty); - } - }break; - case ODRAW::pInscribe: - { - if (pProperty->m_bComplex) - { - pShape->m_oCustomVML.LoadInscribe(pProperty); - } - }break; - case ODRAW::pAdjustHandles: - { - if (pProperty->m_bComplex) - { - pShape->m_oCustomVML.LoadAHs(pProperty); - } - }break; - case ODRAW::adjustValue: - case ODRAW::adjust2Value: - case ODRAW::adjust3Value: - case ODRAW::adjust4Value: - case ODRAW::adjust5Value: - case ODRAW::adjust6Value: - case ODRAW::adjust7Value: - case ODRAW::adjust8Value: - case ODRAW::adjust9Value: - case ODRAW::adjust10Value: - { - LONG lIndexAdj = pProperty->m_ePID - ODRAW::adjustValue; - if (lIndexAdj >= 0 && lIndexAdj < (LONG)pShape->m_arAdjustments.size()) - { - pShape->m_oCustomVML.LoadAdjusts(lIndexAdj, (LONG)pProperty->m_lValue); - } - else - { - pShape->m_oCustomVML.LoadAdjusts(lIndexAdj, (LONG)pProperty->m_lValue); - } - }break; -//-------------------------------------------------------------------------------------------------------------------- - case lTxid: - { - }break; - case ODRAW::dxTextLeft: - { - pParentShape->m_dTextMarginX = pProperty->m_lValue; - }break; - case ODRAW::dxTextRight: - { - pParentShape->m_dTextMarginRight = pProperty->m_lValue; - }break; - case ODRAW::dyTextTop: - { - pParentShape->m_dTextMarginY = pProperty->m_lValue; - }break; - case ODRAW::dyTextBottom: - { - pParentShape->m_dTextMarginBottom = pProperty->m_lValue; - }break; - case ODRAW::WrapText: - { - pParentShape->m_oText.m_lWrapMode = (LONG)pProperty->m_lValue; - }break; - case ODRAW::gtextUNICODE://word art text - { - if (pProperty->m_bComplex && 0 < pProperty->m_lValue) - { - std::wstring str = NSFile::CUtf8Converter::GetWStringFromUTF16((unsigned short*)pProperty->m_pOptions, pProperty->m_lValue/2-1); + delete []utf8Data; + } + NSFile::CFileBinary::Remove(tempFileName); + }break; + case ODRAW::geoRight: + { + if (0 < pProperty->m_lValue) + pParentShape->m_dWidthLogic = (double)(pProperty->m_lValue); + }break; + case ODRAW::geoBottom: + { + if (0 < pProperty->m_lValue) + pParentShape->m_dHeightLogic = (double)(pProperty->m_lValue); + }break; + case ODRAW::shapePath: + { + pShape->m_oCustomVML.SetPath((RulesType)pProperty->m_lValue); + pShape->m_bCustomShape = true; + }break; + case ODRAW::pSegmentInfo: + { + if (pProperty->m_bComplex) + { + pShape->m_oCustomVML.LoadSegments(pProperty); + pShape->m_bCustomShape = true; + } + }break; + case ODRAW::pVertices: + { + if (pProperty->m_bComplex) + { + pShape->m_oCustomVML.LoadVertices(pProperty); + pShape->m_bCustomShape = true; + } + }break; + case ODRAW::pConnectionSites: + { + if (pProperty->m_bComplex) + { + pShape->m_oCustomVML.LoadConnectionSites(pProperty); + } + }break; + case ODRAW::pConnectionSitesDir: + { + if (pProperty->m_bComplex) + { + pShape->m_oCustomVML.LoadConnectionSitesDir(pProperty); + } + }break; + case ODRAW::pGuides: + { + if (pProperty->m_bComplex/* && pShape->m_eType != sptNotchedCircularArrow*/) + {//Тікбұрышты үшбұрыштарды.ppt - slide 25 + pShape->m_oCustomVML.LoadGuides(pProperty); + } + }break; + case ODRAW::pInscribe: + { + if (pProperty->m_bComplex) + { + pShape->m_oCustomVML.LoadInscribe(pProperty); + } + }break; + case ODRAW::pAdjustHandles: + { + if (pProperty->m_bComplex) + { + pShape->m_oCustomVML.LoadAHs(pProperty); + } + }break; + case ODRAW::adjustValue: + case ODRAW::adjust2Value: + case ODRAW::adjust3Value: + case ODRAW::adjust4Value: + case ODRAW::adjust5Value: + case ODRAW::adjust6Value: + case ODRAW::adjust7Value: + case ODRAW::adjust8Value: + case ODRAW::adjust9Value: + case ODRAW::adjust10Value: + { + LONG lIndexAdj = pProperty->m_ePID - ODRAW::adjustValue; + if (lIndexAdj >= 0 && lIndexAdj < (LONG)pShape->m_arAdjustments.size()) + { + pShape->m_oCustomVML.LoadAdjusts(lIndexAdj, (LONG)pProperty->m_lValue); + } + else + { + pShape->m_oCustomVML.LoadAdjusts(lIndexAdj, (LONG)pProperty->m_lValue); + } + }break; + //-------------------------------------------------------------------------------------------------------------------- + case lTxid: + { + }break; + case ODRAW::dxTextLeft: + { + pParentShape->m_dTextMarginX = pProperty->m_lValue; + }break; + case ODRAW::dxTextRight: + { + pParentShape->m_dTextMarginRight = pProperty->m_lValue; + }break; + case ODRAW::dyTextTop: + { + pParentShape->m_dTextMarginY = pProperty->m_lValue; + }break; + case ODRAW::dyTextBottom: + { + pParentShape->m_dTextMarginBottom = pProperty->m_lValue; + }break; + case ODRAW::WrapText: + { + pParentShape->m_oText.m_lWrapMode = (LONG)pProperty->m_lValue; + }break; + case ODRAW::gtextUNICODE://word art text + { + if (pProperty->m_bComplex && 0 < pProperty->m_lValue) + { + std::wstring str = NSFile::CUtf8Converter::GetWStringFromUTF16((unsigned short*)pProperty->m_pOptions, pProperty->m_lValue/2-1); - if (!str.empty() && pParentShape->m_oText.m_arParagraphs.empty()) - { - int length = str.length(); + if (!str.empty() && pParentShape->m_oText.m_arParagraphs.empty()) + { + int length = str.length(); - for (int i = length-1; i>=0; i--) - { - if (str.at(i) > 13 ) break; - length--; - } - PPT_FORMAT::CParagraph p; - PPT_FORMAT::CSpan s; - s.m_strText = str.substr(0,length); - p.m_arSpans.push_back(s); - pParentShape->m_oText.m_arParagraphs.push_back(p); - } - } - }break; - case ODRAW::gtextFont: - { - if (pProperty->m_bComplex && 0 < pProperty->m_lValue) - { - std::wstring str = NSFile::CUtf8Converter::GetWStringFromUTF16((unsigned short*)pProperty->m_pOptions, pProperty->m_lValue/2-1); - pParentShape->m_oText.m_oAttributes.m_oFont.Name = str; - } - }break; - case ODRAW::gtextSize: - { - pParentShape->m_oText.m_oAttributes.m_oFont.Size = (INT)((pProperty->m_lValue >> 16) & 0x0000FFFF); - break; - } - case ODRAW::anchorText: - { - switch (pProperty->m_lValue) - { - case ODRAW::anchorTop: - case ODRAW::anchorTopBaseline: - { - pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = 0; - break; - } - case ODRAW::anchorMiddle: - { - pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = 1; - break; - } - case ODRAW::anchorBottom: - case ODRAW::anchorBottomBaseline: - { - pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 0; - pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = 2; - break; - } - case ODRAW::anchorTopCentered: - case ODRAW::anchorTopCenteredBaseline: - { - pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 1; - pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = 0; - break; - } - case ODRAW::anchorMiddleCentered: - { - pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 1; - pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = 1; - break; - } - case ODRAW::anchorBottomCentered: - case ODRAW::anchorBottomCenteredBaseline: - { - pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 1; - pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = 2; - break; - } - default: - { - pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 1; - pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = -1; // not set - break; - } - }; - break; - } - case ODRAW::gtextAlign: - { - switch (pProperty->m_lValue) - { - case ODRAW::alignTextLeft: - { - pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 0; - }break; - case ODRAW::alignTextCenter: - { - pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 1; - }break; - case ODRAW::alignTextRight: - { - pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 2; - }break; - default: - { - pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 1; - }break; - }; - break; - } - case ODRAW::geometryTextBooleanProperties: - { - // вот здесь - нужно единицы перевести в пикселы - BYTE flag1 = (BYTE)(pProperty->m_lValue); - BYTE flag2 = (BYTE)(pProperty->m_lValue >> 8); - BYTE flag3 = (BYTE)(pProperty->m_lValue >> 16); - BYTE flag4 = (BYTE)(pProperty->m_lValue >> 24); + for (int i = length-1; i>=0; i--) + { + if (str.at(i) > 13 ) break; + length--; + } + PPT_FORMAT::CParagraph p; + PPT_FORMAT::CSpan s; + s.m_strText = str.substr(0,length); + p.m_arSpans.push_back(s); + pParentShape->m_oText.m_arParagraphs.push_back(p); + } + } + }break; + case ODRAW::gtextFont: + { + if (pProperty->m_bComplex && 0 < pProperty->m_lValue) + { + std::wstring str = NSFile::CUtf8Converter::GetWStringFromUTF16((unsigned short*)pProperty->m_pOptions, pProperty->m_lValue/2-1); + pParentShape->m_oText.m_oAttributes.m_oFont.Name = str; + } + }break; + case ODRAW::gtextSize: + { + pParentShape->m_oText.m_oAttributes.m_oFont.Size = (INT)((pProperty->m_lValue >> 16) & 0x0000FFFF); + break; + } + case ODRAW::anchorText: + { + switch (pProperty->m_lValue) + { + case ODRAW::anchorTop: + case ODRAW::anchorTopBaseline: + { + pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = 0; + break; + } + case ODRAW::anchorMiddle: + { + pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = 1; + break; + } + case ODRAW::anchorBottom: + case ODRAW::anchorBottomBaseline: + { + pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 0; + pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = 2; + break; + } + case ODRAW::anchorTopCentered: + case ODRAW::anchorTopCenteredBaseline: + { + pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 1; + pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = 0; + break; + } + case ODRAW::anchorMiddleCentered: + { + pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 1; + pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = 1; + break; + } + case ODRAW::anchorBottomCentered: + case ODRAW::anchorBottomCenteredBaseline: + { + pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 1; + pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = 2; + break; + } + default: + { + pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 1; + pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = -1; // not set + break; + } + }; + break; + } + case ODRAW::gtextAlign: + { + switch (pProperty->m_lValue) + { + case ODRAW::alignTextLeft: + { + pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 0; + }break; + case ODRAW::alignTextCenter: + { + pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 1; + }break; + case ODRAW::alignTextRight: + { + pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 2; + }break; + default: + { + pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 1; + }break; + }; + break; + } + case ODRAW::geometryTextBooleanProperties: + { + // вот здесь - нужно единицы перевести в пикселы + BYTE flag1 = (BYTE)(pProperty->m_lValue); + BYTE flag2 = (BYTE)(pProperty->m_lValue >> 8); + BYTE flag3 = (BYTE)(pProperty->m_lValue >> 16); + BYTE flag4 = (BYTE)(pProperty->m_lValue >> 24); - bool bStrikethrought = (0x01 == (0x01 & flag1)); - bool bSmallCaps = (0x02 == (0x02 & flag1)); - bool bShadow = (0x04 == (0x04 & flag1)); - bool bUnderline = (0x08 == (0x08 & flag1)); - bool bItalic = (0x10 == (0x10 & flag1)); - bool bBold = (0x20 == (0x20 & flag1)); + bool bStrikethrought = (0x01 == (0x01 & flag1)); + bool bSmallCaps = (0x02 == (0x02 & flag1)); + bool bShadow = (0x04 == (0x04 & flag1)); + bool bUnderline = (0x08 == (0x08 & flag1)); + bool bItalic = (0x10 == (0x10 & flag1)); + bool bBold = (0x20 == (0x20 & flag1)); - bool bUseStrikethrought = (0x01 == (0x01 & flag3)); - bool bUseSmallCaps = (0x02 == (0x02 & flag3)); - bool bUseShadow = (0x04 == (0x04 & flag3)); - bool bUseUnderline = (0x08 == (0x08 & flag3)); - bool bUseItalic = (0x10 == (0x10 & flag3)); - bool bUseBold = (0x20 == (0x20 & flag3)); + bool bUseStrikethrought = (0x01 == (0x01 & flag3)); + bool bUseSmallCaps = (0x02 == (0x02 & flag3)); + bool bUseShadow = (0x04 == (0x04 & flag3)); + bool bUseUnderline = (0x08 == (0x08 & flag3)); + bool bUseItalic = (0x10 == (0x10 & flag3)); + bool bUseBold = (0x20 == (0x20 & flag3)); - bool bVertical = (0x20 == (0x20 & flag2)); - bool bUseVertical = (0x20 == (0x20 & flag4)); + bool bVertical = (0x20 == (0x20 & flag2)); + bool bUseVertical = (0x20 == (0x20 & flag4)); - if (bUseStrikethrought) - { - pParentShape->m_oText.m_oAttributes.m_oFont.Strikeout = (BYTE)bStrikethrought; - } - if (bUseShadow) - { - pParentShape->m_oText.m_oAttributes.m_oTextShadow.Visible = true; - } - if (bUseUnderline) - { - pParentShape->m_oText.m_oAttributes.m_oFont.Underline = (BYTE)bUnderline; - } - if (bUseItalic) - { - pParentShape->m_oText.m_oAttributes.m_oFont.Italic = bItalic; - } - if (bUseBold) - { - pParentShape->m_oText.m_oAttributes.m_oFont.Bold = bBold; - } - if (bUseVertical) - { - pParentShape->m_oText.m_bVertical = (true == bVertical) ? true : false; - } - }break; - case ODRAW::cdirFont: - { - switch (pProperty->m_lValue) - { - case 1: - pParentShape->m_oText.m_bVertical = true; - break; - case 2: - pParentShape->m_oText.m_oAttributes.m_dTextRotate = 180; - break; - case 3: - pParentShape->m_oText.m_bVertical = true; - pParentShape->m_oText.m_oAttributes.m_dTextRotate = 180; - break; - } - }break; - case ODRAW::txflTextFlow: - { - pParentShape->m_oText.m_nTextFlow = pProperty->m_lValue; - }break; - case ODRAW::textBooleanProperties: - { - BYTE flag1 = (BYTE)(pProperty->m_lValue); - BYTE flag2 = (BYTE)(pProperty->m_lValue >> 8); - BYTE flag3 = (BYTE)(pProperty->m_lValue >> 16); - BYTE flag4 = (BYTE)(pProperty->m_lValue >> 24); + if (bUseStrikethrought) + { + pParentShape->m_oText.m_oAttributes.m_oFont.Strikeout = (BYTE)bStrikethrought; + } + if (bUseShadow) + { + pParentShape->m_oText.m_oAttributes.m_oTextShadow.Visible = true; + } + if (bUseUnderline) + { + pParentShape->m_oText.m_oAttributes.m_oFont.Underline = (BYTE)bUnderline; + } + if (bUseItalic) + { + pParentShape->m_oText.m_oAttributes.m_oFont.Italic = bItalic; + } + if (bUseBold) + { + pParentShape->m_oText.m_oAttributes.m_oFont.Bold = bBold; + } + if (bUseVertical) + { + pParentShape->m_oText.m_bVertical = (true == bVertical) ? true : false; + } + }break; + case ODRAW::cdirFont: + { + switch (pProperty->m_lValue) + { + case 1: + pParentShape->m_oText.m_bVertical = true; + break; + case 2: + pParentShape->m_oText.m_oAttributes.m_dTextRotate = 180; + break; + case 3: + pParentShape->m_oText.m_bVertical = true; + pParentShape->m_oText.m_oAttributes.m_dTextRotate = 180; + break; + } + }break; + case ODRAW::txflTextFlow: + { + pParentShape->m_oText.m_nTextFlow = pProperty->m_lValue; + }break; + case ODRAW::textBooleanProperties: + { + BYTE flag1 = (BYTE)(pProperty->m_lValue); + BYTE flag2 = (BYTE)(pProperty->m_lValue >> 8); + BYTE flag3 = (BYTE)(pProperty->m_lValue >> 16); + BYTE flag4 = (BYTE)(pProperty->m_lValue >> 24); - bool bFitShapeToText = (0x02 == (0x02 & flag1)); - bool bAutoTextMargin = (0x08 == (0x08 & flag1)); - bool bSelectText = (0x10 == (0x10 & flag1)); + bool bFitShapeToText = (0x02 == (0x02 & flag1)); + bool bAutoTextMargin = (0x08 == (0x08 & flag1)); + bool bSelectText = (0x10 == (0x10 & flag1)); - bool bUseFitShapeToText = (0x02 == (0x02 & flag3)); - bool bUseAutoTextMargin = (0x08 == (0x08 & flag3)); - bool bUseSelectText = (0x10 == (0x10 & flag3)); + bool bUseFitShapeToText = (0x02 == (0x02 & flag3)); + bool bUseAutoTextMargin = (0x08 == (0x08 & flag3)); + bool bUseSelectText = (0x10 == (0x10 & flag3)); - if (bUseAutoTextMargin) - { - if (bAutoTextMargin) - { - pParentShape->m_dTextMarginX = 2.54; - pParentShape->m_dTextMarginRight = 1.27; - pParentShape->m_dTextMarginY = 2.54; - pParentShape->m_dTextMarginBottom = 1.27; - } - } - if (bUseFitShapeToText) - pParentShape->m_oText.m_bAutoFit = bFitShapeToText; + if (bUseAutoTextMargin) + { + if (bAutoTextMargin) + { + pParentShape->m_dTextMarginX = 2.54; + pParentShape->m_dTextMarginRight = 1.27; + pParentShape->m_dTextMarginY = 2.54; + pParentShape->m_dTextMarginBottom = 1.27; + } + } + if (bUseFitShapeToText) + pParentShape->m_oText.m_bAutoFit = bFitShapeToText; - }break; - case ODRAW::c3DSpecularAmt: - { - pShape->m_o3dOptions.dSpecularAmt = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DDiffuseAmt: - { - pShape->m_o3dOptions.dDiffuseAmt = FixedPointToDouble(pProperty->m_lValue); - }break; + }break; + case ODRAW::c3DSpecularAmt: + { + pShape->m_o3dOptions.dSpecularAmt = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DDiffuseAmt: + { + pShape->m_o3dOptions.dDiffuseAmt = FixedPointToDouble(pProperty->m_lValue); + }break; case ODRAW::c3DShininess: - { - pShape->m_o3dOptions.dShininess = FixedPointToDouble(pProperty->m_lValue); - }break; + { + pShape->m_o3dOptions.dShininess = FixedPointToDouble(pProperty->m_lValue); + }break; case ODRAW::c3DEdgeThickness: - { - pShape->m_o3dOptions.nEdgeThickness = pProperty->m_lValue; - }break; - case ODRAW::C3DExtrudeForward: - { - pShape->m_o3dOptions.nExtrudeForward = pProperty->m_lValue; - }break; - case ODRAW::c3DExtrudeBackward: - { - pShape->m_o3dOptions.nExtrudeBackward = pProperty->m_lValue; - }break; - case ODRAW::c3DExtrudePlane: - { - //ExtrudePlane = 0; - }break; - case ODRAW::c3DExtrusionColor: - { - SColorAtom oAtom; - oAtom.FromValue(pProperty->m_lValue); + { + pShape->m_o3dOptions.nEdgeThickness = pProperty->m_lValue; + }break; + case ODRAW::C3DExtrudeForward: + { + pShape->m_o3dOptions.nExtrudeForward = pProperty->m_lValue; + }break; + case ODRAW::c3DExtrudeBackward: + { + pShape->m_o3dOptions.nExtrudeBackward = pProperty->m_lValue; + }break; + case ODRAW::c3DExtrudePlane: + { + //ExtrudePlane = 0; + }break; + case ODRAW::c3DExtrusionColor: + { + SColorAtom oAtom; + oAtom.FromValue(pProperty->m_lValue); - CColor tmp; - if(oAtom.bSysIndex) tmp = CorrectSysColor(pProperty->m_lValue, pElement, pTheme); - else oAtom.ToColor(&tmp); + CColor tmp; + if(oAtom.bSysIndex) tmp = CorrectSysColor(pProperty->m_lValue, pElement, pTheme); + else oAtom.ToColor(&tmp); - pShape->m_o3dOptions.oExtrusionColor = tmp; - }break; - case ODRAW::c3DCrMod: - { - SColorAtom oAtom; - oAtom.FromValue(pProperty->m_lValue); + pShape->m_o3dOptions.oExtrusionColor = tmp; + }break; + case ODRAW::c3DCrMod: + { + SColorAtom oAtom; + oAtom.FromValue(pProperty->m_lValue); - CColor tmp; - if(oAtom.bSysIndex) tmp = CorrectSysColor(pProperty->m_lValue, pElement, pTheme); - else oAtom.ToColor(&tmp); - - pShape->m_o3dOptions.oCrMod = tmp; - }break; - case ODRAW::c3DExtrusionColorExt: - { - SColorAtom oAtom; - oAtom.FromValue(pProperty->m_lValue); + CColor tmp; + if(oAtom.bSysIndex) tmp = CorrectSysColor(pProperty->m_lValue, pElement, pTheme); + else oAtom.ToColor(&tmp); - CColor tmp; - if(oAtom.bSysIndex) tmp = CorrectSysColor(pProperty->m_lValue, pElement, pTheme); - else oAtom.ToColor(&tmp); - pShape->m_o3dOptions.oExtrusionColorExt = tmp; - }break; - case ODRAW::c3DExtrusionColorExtMod: - { - pShape->m_o3dOptions.nTypeExtrusionColorExt = (pProperty->m_lValue & 0x00000300) >> 8; - }break; - case ODRAW::c3DBottomBevelWidth: - { - pShape->m_o3dOptions.dBottomBevelWidth = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DBottomBevelHeight: - { - pShape->m_o3dOptions.dBottomBevelHeight = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DBottomBevelType: - { - pShape->m_o3dOptions.nBottomBevelType = pProperty->m_lValue; - }break; - case ODRAW::c3DTopBevelWidth: - { - pShape->m_o3dOptions.dTopBevelWidth = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DTopBevelHeight: - { - pShape->m_o3dOptions.dTopBevelHeight = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DTopBevelType: - { - pShape->m_o3dOptions.nTopBevelType = pProperty->m_lValue; - }break; - case ODRAW::threeDObjectBooleanProperties: - { - bool fUsef3D = GETBIT(pProperty->m_lValue, 19); - bool fUsefc3DMetallic = GETBIT(pProperty->m_lValue, 18); - bool fUsefc3DUseExtrusionColor = GETBIT(pProperty->m_lValue, 17); - bool fUsefc3DLightFace = GETBIT(pProperty->m_lValue, 16); - - pShape->m_o3dOptions.bEnabled = fUsef3D ? GETBIT(pProperty->m_lValue, 3) : false; - pShape->m_o3dOptions.bMetallic = fUsefc3DMetallic ? GETBIT(pProperty->m_lValue, 2) : false; - pShape->m_o3dOptions.bExtrusionColor= fUsefc3DUseExtrusionColor ? GETBIT(pProperty->m_lValue, 1) : false; - pShape->m_o3dOptions.bLightFace = fUsefc3DLightFace ? GETBIT(pProperty->m_lValue, 0) : true; + pShape->m_o3dOptions.oCrMod = tmp; + }break; + case ODRAW::c3DExtrusionColorExt: + { + SColorAtom oAtom; + oAtom.FromValue(pProperty->m_lValue); - }break; - case ODRAW::c3DYRotationAngle: - { - double val = FixedPointToDouble(pProperty->m_lValue); - if (val < 0) val += 360; - pShape->m_o3dOptions.dYRotationAngle = val; - }break; - case ODRAW::c3DXRotationAngle: - { - double val = FixedPointToDouble(pProperty->m_lValue); - if (val < 0) val += 360; - pShape->m_o3dOptions.dXRotationAngle = val; - }break; - case ODRAW::c3DRotationAxisX: - { - pShape->m_o3dOptions.dRotationAxisX = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DRotationAxisY: - { - pShape->m_o3dOptions.dRotationAxisY = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DRotationAxisZ: - { - pShape->m_o3dOptions.dRotationAxisZ = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DRotationAngle: - { - pShape->m_o3dOptions.dRotationAngle = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DRotationCenterX: - { - pShape->m_o3dOptions.dRotationCenterX = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DRotationCenterY: - { - pShape->m_o3dOptions.dRotationCenterY = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DRotationCenterZ: - { - pShape->m_o3dOptions.dRotationCenterZ = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DRenderMode: - { - pShape->m_o3dOptions.nRenderMode = pProperty->m_lValue; - }break; - case ODRAW::c3DTolerance: - { - pShape->m_o3dOptions.dTolerance = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DXViewpoint: - { - pShape->m_o3dOptions.dXViewpoint = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DYViewpoint: - { - pShape->m_o3dOptions.dYViewpoint = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DZViewpoint: - { - pShape->m_o3dOptions.dZViewpoint = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DOriginX: - { - pShape->m_o3dOptions.dOriginX = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DOriginY: - { - pShape->m_o3dOptions.dOriginY = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DSkewAngle: - { - double val = FixedPointToDouble(pProperty->m_lValue); - if (val <= 0) val += 360; - pShape->m_o3dOptions.dSkewAngle = val; - }break; - case ODRAW::c3DSkewAmount: - { - pShape->m_o3dOptions.nSkewAmount = pProperty->m_lValue; - }break; - case ODRAW::c3DAmbientIntensity: - { - pShape->m_o3dOptions.dAmbientIntensity = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DKeyX: - { - pShape->m_o3dOptions.dKeyX = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DKeyY: - { - pShape->m_o3dOptions.dKeyY = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DKeyZ: - { - pShape->m_o3dOptions.dKeyZ = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DKeyIntensity: - { - pShape->m_o3dOptions.dKeyIntensity = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DFillX: - { - pShape->m_o3dOptions.dFillX = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DFillY: - { - pShape->m_o3dOptions.dFillY = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DFillZ: - { - pShape->m_o3dOptions.dFillZ = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DFillIntensity: - { - pShape->m_o3dOptions.dFillIntensity = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::threeDStyleBooleanProperties: - { - bool fUsefc3DConstrainRotation = GETBIT(pProperty->m_lValue, 20); - bool fUsefc3DRotationCenterAuto = GETBIT(pProperty->m_lValue, 19); - bool fUsefc3DParallel = GETBIT(pProperty->m_lValue, 18); - bool fUsefc3DKeyHarsh = GETBIT(pProperty->m_lValue, 17); - bool fUsefc3DFillHarsh = GETBIT(pProperty->m_lValue, 16); - - pShape->m_o3dOptions.bConstrainRotation = fUsefc3DConstrainRotation ? GETBIT(pProperty->m_lValue, 4) : true; - pShape->m_o3dOptions.bRotationCenterAuto= fUsefc3DRotationCenterAuto? GETBIT(pProperty->m_lValue, 3) : false; - pShape->m_o3dOptions.bParallel = fUsefc3DParallel ? GETBIT(pProperty->m_lValue, 2) : true; - pShape->m_o3dOptions.bKeyHarsh = fUsefc3DKeyHarsh ? GETBIT(pProperty->m_lValue, 1) : true; - pShape->m_o3dOptions.bFillHarsh = fUsefc3DFillHarsh ? GETBIT(pProperty->m_lValue, 0) : true; - }break; - default: - { - int unknown_value = pProperty->m_lValue; - unknown_value = unknown_value; - }break; - } + CColor tmp; + if(oAtom.bSysIndex) tmp = CorrectSysColor(pProperty->m_lValue, pElement, pTheme); + else oAtom.ToColor(&tmp); + pShape->m_o3dOptions.oExtrusionColorExt = tmp; + }break; + case ODRAW::c3DExtrusionColorExtMod: + { + pShape->m_o3dOptions.nTypeExtrusionColorExt = (pProperty->m_lValue & 0x00000300) >> 8; + }break; + case ODRAW::c3DBottomBevelWidth: + { + pShape->m_o3dOptions.dBottomBevelWidth = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DBottomBevelHeight: + { + pShape->m_o3dOptions.dBottomBevelHeight = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DBottomBevelType: + { + pShape->m_o3dOptions.nBottomBevelType = pProperty->m_lValue; + }break; + case ODRAW::c3DTopBevelWidth: + { + pShape->m_o3dOptions.dTopBevelWidth = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DTopBevelHeight: + { + pShape->m_o3dOptions.dTopBevelHeight = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DTopBevelType: + { + pShape->m_o3dOptions.nTopBevelType = pProperty->m_lValue; + }break; + case ODRAW::threeDObjectBooleanProperties: + { + bool fUsef3D = GETBIT(pProperty->m_lValue, 19); + bool fUsefc3DMetallic = GETBIT(pProperty->m_lValue, 18); + bool fUsefc3DUseExtrusionColor = GETBIT(pProperty->m_lValue, 17); + bool fUsefc3DLightFace = GETBIT(pProperty->m_lValue, 16); + + pShape->m_o3dOptions.bEnabled = fUsef3D ? GETBIT(pProperty->m_lValue, 3) : false; + pShape->m_o3dOptions.bMetallic = fUsefc3DMetallic ? GETBIT(pProperty->m_lValue, 2) : false; + pShape->m_o3dOptions.bExtrusionColor= fUsefc3DUseExtrusionColor ? GETBIT(pProperty->m_lValue, 1) : false; + pShape->m_o3dOptions.bLightFace = fUsefc3DLightFace ? GETBIT(pProperty->m_lValue, 0) : true; + + }break; + case ODRAW::c3DYRotationAngle: + { + double val = FixedPointToDouble(pProperty->m_lValue); + if (val < 0) val += 360; + pShape->m_o3dOptions.dYRotationAngle = val; + }break; + case ODRAW::c3DXRotationAngle: + { + double val = FixedPointToDouble(pProperty->m_lValue); + if (val < 0) val += 360; + pShape->m_o3dOptions.dXRotationAngle = val; + }break; + case ODRAW::c3DRotationAxisX: + { + pShape->m_o3dOptions.dRotationAxisX = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DRotationAxisY: + { + pShape->m_o3dOptions.dRotationAxisY = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DRotationAxisZ: + { + pShape->m_o3dOptions.dRotationAxisZ = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DRotationAngle: + { + pShape->m_o3dOptions.dRotationAngle = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DRotationCenterX: + { + pShape->m_o3dOptions.dRotationCenterX = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DRotationCenterY: + { + pShape->m_o3dOptions.dRotationCenterY = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DRotationCenterZ: + { + pShape->m_o3dOptions.dRotationCenterZ = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DRenderMode: + { + pShape->m_o3dOptions.nRenderMode = pProperty->m_lValue; + }break; + case ODRAW::c3DTolerance: + { + pShape->m_o3dOptions.dTolerance = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DXViewpoint: + { + pShape->m_o3dOptions.dXViewpoint = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DYViewpoint: + { + pShape->m_o3dOptions.dYViewpoint = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DZViewpoint: + { + pShape->m_o3dOptions.dZViewpoint = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DOriginX: + { + pShape->m_o3dOptions.dOriginX = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DOriginY: + { + pShape->m_o3dOptions.dOriginY = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DSkewAngle: + { + double val = FixedPointToDouble(pProperty->m_lValue); + if (val <= 0) val += 360; + pShape->m_o3dOptions.dSkewAngle = val; + }break; + case ODRAW::c3DSkewAmount: + { + pShape->m_o3dOptions.nSkewAmount = pProperty->m_lValue; + }break; + case ODRAW::c3DAmbientIntensity: + { + pShape->m_o3dOptions.dAmbientIntensity = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DKeyX: + { + pShape->m_o3dOptions.dKeyX = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DKeyY: + { + pShape->m_o3dOptions.dKeyY = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DKeyZ: + { + pShape->m_o3dOptions.dKeyZ = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DKeyIntensity: + { + pShape->m_o3dOptions.dKeyIntensity = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DFillX: + { + pShape->m_o3dOptions.dFillX = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DFillY: + { + pShape->m_o3dOptions.dFillY = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DFillZ: + { + pShape->m_o3dOptions.dFillZ = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DFillIntensity: + { + pShape->m_o3dOptions.dFillIntensity = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::threeDStyleBooleanProperties: + { + bool fUsefc3DConstrainRotation = GETBIT(pProperty->m_lValue, 20); + bool fUsefc3DRotationCenterAuto = GETBIT(pProperty->m_lValue, 19); + bool fUsefc3DParallel = GETBIT(pProperty->m_lValue, 18); + bool fUsefc3DKeyHarsh = GETBIT(pProperty->m_lValue, 17); + bool fUsefc3DFillHarsh = GETBIT(pProperty->m_lValue, 16); + + pShape->m_o3dOptions.bConstrainRotation = fUsefc3DConstrainRotation ? GETBIT(pProperty->m_lValue, 4) : true; + pShape->m_o3dOptions.bRotationCenterAuto= fUsefc3DRotationCenterAuto? GETBIT(pProperty->m_lValue, 3) : false; + pShape->m_o3dOptions.bParallel = fUsefc3DParallel ? GETBIT(pProperty->m_lValue, 2) : true; + pShape->m_o3dOptions.bKeyHarsh = fUsefc3DKeyHarsh ? GETBIT(pProperty->m_lValue, 1) : true; + pShape->m_o3dOptions.bFillHarsh = fUsefc3DFillHarsh ? GETBIT(pProperty->m_lValue, 0) : true; + }break; + default: + { + int unknown_value = pProperty->m_lValue; + unknown_value = unknown_value; + }break; + } } CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, - CTheme* pTheme, CLayout* pLayout, - CSlideInfo* pThemeWrapper, CSlideInfo* pSlideWrapper, CSlide* pSlide) + CTheme* pTheme, CLayout* pLayout, + CSlideInfo* pThemeWrapper, CSlideInfo* pSlideWrapper, CSlide* pSlide) { CElementPtr pElement; @@ -1530,8 +1536,8 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, for (size_t nIndex = 0; nIndex < nIndexMem; ++nIndex) { if ((placeholder_type == pLayout->m_arElements[nIndex]->m_lPlaceholderType ) && - ( placeholder_id < 0 || pLayout->m_arElements[nIndex]->m_lPlaceholderID < 0 || - placeholder_id == pLayout->m_arElements[nIndex]->m_lPlaceholderID)) + ( placeholder_id < 0 || pLayout->m_arElements[nIndex]->m_lPlaceholderID < 0 || + placeholder_id == pLayout->m_arElements[nIndex]->m_lPlaceholderID)) { if (pLayout->m_arElements[nIndex]->m_bPlaceholderSet == false) { @@ -1568,93 +1574,98 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, case sptNil: break; case sptPictureFrame: - { - std::vector oArrayEx; - GetRecordsByType(&oArrayEx, true, true); + { + std::vector oArrayEx; + GetRecordsByType(&oArrayEx, true, true); - CExFilesInfo oInfo; - CExFilesInfo oInfoDefault; - // по умолчанию картинка (или оле объект) - CExFilesInfo::ExFilesType exType = CExFilesInfo::eftNone; - CExFilesInfo* pInfo = pMapIDs->Lock(0xFFFFFFFF, exType); + CExFilesInfo oInfo; + CExFilesInfo oInfoDefault; + // по умолчанию картинка (или оле объект) + CExFilesInfo::ExFilesType exType = CExFilesInfo::eftNone; + CExFilesInfo* pInfo = pMapIDs->Lock(0xFFFFFFFF, exType); + if (NULL != pInfo) + { + oInfo = *pInfo; + oInfoDefault = oInfo; + } + + if (0 != oArrayEx.size()) + { + pInfo = pMapIDs->Lock(oArrayEx[0]->m_nExObjID, exType); if (NULL != pInfo) { - oInfo = *pInfo; - oInfoDefault = oInfo; + oInfo = *pInfo; } + } - if (0 != oArrayEx.size()) - { - pInfo = pMapIDs->Lock(oArrayEx[0]->m_nExObjID, exType); - if (NULL != pInfo) - { - oInfo = *pInfo; - } - } - - if (CExFilesInfo::eftVideo == exType) - { - CVideoElement* pVideoElem = new CVideoElement(); - - pVideoElem->m_strVideoFileName = oInfo.m_strFilePath ; - pVideoElem->m_strImageFileName = oInfoDefault.m_strFilePath + FILE_SEPARATOR_STR; - - pElement = CElementPtr(pVideoElem); - } - else if (CExFilesInfo::eftAudio == exType) - { - CAudioElement* pAudioElem = new CAudioElement(); - pElement = CElementPtr(pAudioElem); - - pAudioElem->m_strAudioFileName = oInfo.m_strFilePath; - pAudioElem->m_strImageFileName = oInfoDefault.m_strFilePath + FILE_SEPARATOR_STR; - - pAudioElem->m_dClipStartTime = oInfo.m_dStartTime; - pAudioElem->m_dClipEndTime = oInfo.m_dEndTime; - - pAudioElem->m_bLoop = oInfo.m_bLoop; - - if (NULL != pSlide) - { - pAudioElem->m_dStartTime = pSlide->m_dStartTime; - pAudioElem->m_dEndTime = pSlide->m_dEndTime; - - } - else - { - if (pLayout) - pLayout->m_arElements.push_back(pElement); - } - - } - else - { - CImageElement* pImageElem = new CImageElement(); - pImageElem->m_strImageFileName = oInfo.m_strFilePath + FILE_SEPARATOR_STR; - - pElement = CElementPtr(pImageElem); - } - }break; - default: + if (CExFilesInfo::eftVideo == exType) { - if (bGroupShape) + CVideoElement* pVideoElem = new CVideoElement(); + + pVideoElem->m_strVideoFileName = oInfo.m_strFilePath ; + pVideoElem->m_strImageFileName = oInfoDefault.m_strFilePath + FILE_SEPARATOR_STR; + + pElement = CElementPtr(pVideoElem); + } + else if (CExFilesInfo::eftAudio == exType) + { + CAudioElement* pAudioElem = new CAudioElement(); + pElement = CElementPtr(pAudioElem); + + pAudioElem->m_strAudioFileName = oInfo.m_strFilePath; + pAudioElem->m_strImageFileName = oInfoDefault.m_strFilePath + FILE_SEPARATOR_STR; + + pAudioElem->m_dClipStartTime = oInfo.m_dStartTime; + pAudioElem->m_dClipEndTime = oInfo.m_dEndTime; + + pAudioElem->m_bLoop = oInfo.m_bLoop; + + if (NULL != pSlide) { - CGroupElement* pGroupElem = new CGroupElement(); - pElement = CElementPtr(pGroupElem); + pAudioElem->m_dStartTime = pSlide->m_dStartTime; + pAudioElem->m_dEndTime = pSlide->m_dEndTime; + } else { - // shape - CShapeElement* pShape = new CShapeElement(NSBaseShape::ppt, eType); - CPPTShape *ppt_shape = dynamic_cast(pShape->m_pShape->getBaseShape().get()); - - if ( (ppt_shape) && (OOXMLShapes::sptCustom == ppt_shape->m_eType)) - { - pShape->m_bShapePreset = true; - } - pElement = CElementPtr(pShape); + if (pLayout) + pLayout->m_arElements.push_back(pElement); } - }break; + + } + else + { + CImageElement* pImageElem = new CImageElement(); + pImageElem->m_strImageFileName = oInfo.m_strFilePath + FILE_SEPARATOR_STR; + + pElement = CElementPtr(pImageElem); + } + }break; + default: + { + if (bGroupShape && 0) + { + CTableElement* pTableElem = new CTableElement(); + pElement = CElementPtr(pTableElem); + } + else if (bGroupShape) + { + CGroupElement* pGroupElem = new CGroupElement(); + pElement = CElementPtr(pGroupElem); + } + else + { + // shape + CShapeElement* pShape = new CShapeElement(NSBaseShape::ppt, eType); + CPPTShape *ppt_shape = dynamic_cast(pShape->m_pShape->getBaseShape().get()); + + if ( (ppt_shape) && (OOXMLShapes::sptCustom == ppt_shape->m_eType)) + { + pShape->m_bShapePreset = true; + } + pElement = CElementPtr(pShape); + } + }break; } } @@ -1664,7 +1675,7 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, pElement->m_lID = oArrayShape[0]->m_nID; pElement->m_lLayoutID = lMasterID; -//---------внешние ссылки + //---------внешние ссылки { CExFilesInfo::ExFilesType exType = CExFilesInfo::eftNone; CExFilesInfo * pTextureInfo = pMapIDs->Lock(0xFFFFFFFF, exType); @@ -1687,7 +1698,7 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, } } std::wstring strShapeText; -//------------------------------------------------------------------------------------------------ + //------------------------------------------------------------------------------------------------ // placeholders if (0 < oArrayPlaceHolder.size()) { @@ -1751,7 +1762,7 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, pElement->m_nFormatDate = 2; } } -//------------- привязки --------------------------------------------------------------------------------- + //------------- привязки --------------------------------------------------------------------------------- std::vector oArrayGroupShape; this->GetRecordsByType(&oArrayGroupShape, true, true); @@ -1805,7 +1816,7 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, pElementLayout->m_bAnchorEnabled = pElement->m_bAnchorEnabled; pElementLayout->m_bChildAnchorEnabled = pElement->m_bChildAnchorEnabled; } -//--------- наличие текста -------------------------------------------------------------------------- + //--------- наличие текста -------------------------------------------------------------------------- CShapeElement* pShapeElem = dynamic_cast(pElement.get()); if (NULL != pShapeElem) { @@ -1864,7 +1875,7 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, if (pos < 0) pElement->m_lPlaceholderType = PT_MasterFooter; ///???? 1-(33).ppt } -//------ shape properties ---------------------------------------------------------------------------------------- + //------ shape properties ---------------------------------------------------------------------------------------- CPPTElement oElement; for (size_t nIndexProp = 0; nIndexProp < oArrayOptions.size(); ++nIndexProp) { @@ -2015,7 +2026,7 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, pElement->m_lLayoutID = lMasterID; } -//---------------------------------------------------------------------------------------------------- + //---------------------------------------------------------------------------------------------------- if (NULL != pSlide) { pElement->m_dStartTime = pSlide->m_dStartTime; @@ -2032,54 +2043,54 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, void CRecordShapeContainer::ApplyThemeStyle(CElementPtr pElem, CTheme* pTheme, CRecordMasterTextPropAtom* master_levels) { - CShapeElement* pShape = dynamic_cast(pElem.get()); - if (NULL == pShape) - return; - - CTextAttributesEx* pText = &(pShape->m_pShape->m_oText); + CShapeElement* pShape = dynamic_cast(pElem.get()); + if (NULL == pShape) + return; - - if (master_levels) - { - for (size_t i = 0; i < pText->m_arParagraphs.size(); i++) - { - if (i >= master_levels->m_arrProps.size()) break; - - pText->m_arParagraphs[i].m_lTextLevel = master_levels->m_arrProps[i].lIndentLevel; - pText->m_arParagraphs[i].m_oPFRun.leftMargin.reset(); - pText->m_arParagraphs[i].m_oPFRun.indent.reset(); - } - } + CTextAttributesEx* pText = &(pShape->m_pShape->m_oText); - pText->ApplyThemeStyle(pTheme); + + if (master_levels) + { + for (size_t i = 0; i < pText->m_arParagraphs.size(); i++) + { + if (i >= master_levels->m_arrProps.size()) break; + + pText->m_arParagraphs[i].m_lTextLevel = master_levels->m_arrProps[i].lIndentLevel; + pText->m_arParagraphs[i].m_oPFRun.leftMargin.reset(); + pText->m_arParagraphs[i].m_oPFRun.indent.reset(); + } + } + + pText->ApplyThemeStyle(pTheme); } void CRecordShapeContainer::SetUpTextStyle(std::wstring& strText, CTheme* pTheme, CLayout* pLayout, CElementPtr pElem, CSlideInfo* pThemeWrapper, CSlideInfo* pSlideWrapper, CSlide* pSlide, CRecordMasterTextPropAtom* master_levels) { - // сначала проверяем на shape - // затем применяем все настройки по-очереди - // 1) master + TextMasterStyles - // 2) persist + TextMasterStyles - // 3) свои настройки + TextMasterStyles - // причем "свои настройки" - это чисто "продвинутые настройки" - // потому что все общие ( через проперти ) - уже установлены + // сначала проверяем на shape + // затем применяем все настройки по-очереди + // 1) master + TextMasterStyles + // 2) persist + TextMasterStyles + // 3) свои настройки + TextMasterStyles + // причем "свои настройки" - это чисто "продвинутые настройки" + // потому что все общие ( через проперти ) - уже установлены - if (NULL == pElem) - return; + if (NULL == pElem) + return; - if (etShape != pElem->m_etType) - return; + if (etShape != pElem->m_etType) + return; - CShapeElement* pShape = dynamic_cast(pElem.get()); - if (NULL == pShape) - return; + CShapeElement* pShape = dynamic_cast(pElem.get()); + if (NULL == pShape) + return; - CTextAttributesEx* pTextSettings = &(pShape->m_pShape->m_oText); + CTextAttributesEx* pTextSettings = &(pShape->m_pShape->m_oText); - // сначала применим ссылки на masterstyle (для шаблонного элемента) - // как узнать - просто есть ли массивы (т.к. они могли появиться пока только оттуда) - // - теперь этого делать не нужно - т.к. в мастере тоже вызывается эта функция - - // и там все это должно уже примениться + // сначала применим ссылки на masterstyle (для шаблонного элемента) + // как узнать - просто есть ли массивы (т.к. они могли появиться пока только оттуда) + // - теперь этого делать не нужно - т.к. в мастере тоже вызывается эта функция - + // и там все это должно уже примениться bool bIsPersistPresentSettings = false; bool bIsOwnPresentSettings = false; @@ -2087,15 +2098,15 @@ void CRecordShapeContainer::SetUpTextStyle(std::wstring& strText, CTheme* pTheme TextTypeEnum eTypePersist = NoPresent; TextTypeEnum eTypeOwn = (TextTypeEnum)pTextSettings->m_lTextType; - CShapeElement* pElementLayoutPH = NULL; + CShapeElement* pElementLayoutPH = NULL; - // выставим тип мастера - if (NULL != pSlide) - { - int ph_type = pShape->m_lPlaceholderType; - int ph_pos = pShape->m_lPlaceholderID; + // выставим тип мастера + if (NULL != pSlide) + { + int ph_type = pShape->m_lPlaceholderType; + int ph_pos = pShape->m_lPlaceholderID; - pTextSettings->m_lPlaceholderType = pShape->m_lPlaceholderType; + pTextSettings->m_lPlaceholderType = pShape->m_lPlaceholderType; size_t lElemsCount = 0; @@ -2112,444 +2123,444 @@ void CRecordShapeContainer::SetUpTextStyle(std::wstring& strText, CTheme* pTheme } } } - } - else - { + } + else + { eTypeMaster = (TextTypeEnum)pTextSettings->m_lTextMasterType; - } + } - // ------------------------------------------------------------------------------ - CElementInfo oElemInfo; - std::map::iterator pPair = pSlideWrapper->m_mapElements.find(pShape->m_lID); - if (pSlideWrapper->m_mapElements.end() != pPair) - oElemInfo = pPair->second; + // ------------------------------------------------------------------------------ + CElementInfo oElemInfo; + std::map::iterator pPair = pSlideWrapper->m_mapElements.find(pShape->m_lID); + if (pSlideWrapper->m_mapElements.end() != pPair) + oElemInfo = pPair->second; - // persist ---------------------------------------------------------------------- - std::vector* pArrayPlaceHolders = &pSlideWrapper->m_arTextPlaceHolders; - int lCountPersistObjects = pArrayPlaceHolders->size(); - int lPersistIndex = oElemInfo.m_lPersistIndex; + // persist ---------------------------------------------------------------------- + std::vector* pArrayPlaceHolders = &pSlideWrapper->m_arTextPlaceHolders; + int lCountPersistObjects = pArrayPlaceHolders->size(); + int lPersistIndex = oElemInfo.m_lPersistIndex; - if ((lPersistIndex >= 0) && (lPersistIndex < lCountPersistObjects)) - { - CTextFullSettings* pSettings = &pArrayPlaceHolders->at(lPersistIndex); + if ((lPersistIndex >= 0) && (lPersistIndex < lCountPersistObjects)) + { + CTextFullSettings* pSettings = &pArrayPlaceHolders->at(lPersistIndex); eTypePersist = (TextTypeEnum)pSettings->m_nTextType; - strText = pSettings->ApplyProperties(pTextSettings); + strText = pSettings->ApplyProperties(pTextSettings); - if ((0 != pSettings->m_arRanges.size()) && (0 == pShape->m_oTextActions.m_arRanges.size())) - { - pShape->m_oTextActions.m_bPresent = true; - - pShape->m_oTextActions.m_arRanges = pSettings->m_arRanges; - } + if ((0 != pSettings->m_arRanges.size()) && (0 == pShape->m_oTextActions.m_arRanges.size())) + { + pShape->m_oTextActions.m_bPresent = true; - bIsPersistPresentSettings = ((NULL != pSettings->m_pTextStyleProp) && (0 < pSettings->m_pTextStyleProp->m_lCount)); - } - // ------------------------------------------------------------------------------ + pShape->m_oTextActions.m_arRanges = pSettings->m_arRanges; + } - if (NULL != oElemInfo.m_pStream && -1 != oElemInfo.m_lOffsetTextStyle) - { - // теперь нужно загрузить стили текста из стрима. - LONG lPosition = 0; StreamUtils::StreamPosition(lPosition, oElemInfo.m_pStream); + bIsPersistPresentSettings = ((NULL != pSettings->m_pTextStyleProp) && (0 < pSettings->m_pTextStyleProp->m_lCount)); + } + // ------------------------------------------------------------------------------ - StreamUtils::StreamSeek(oElemInfo.m_lOffsetTextStyle - 8, oElemInfo.m_pStream); + if (NULL != oElemInfo.m_pStream && -1 != oElemInfo.m_lOffsetTextStyle) + { + // теперь нужно загрузить стили текста из стрима. + LONG lPosition = 0; StreamUtils::StreamPosition(lPosition, oElemInfo.m_pStream); - SRecordHeader oHeader; - oHeader.ReadFromStream(oElemInfo.m_pStream) ; + StreamUtils::StreamSeek(oElemInfo.m_lOffsetTextStyle - 8, oElemInfo.m_pStream); + + SRecordHeader oHeader; + oHeader.ReadFromStream(oElemInfo.m_pStream) ; if (RT_StyleTextPropAtom == oHeader.RecType) - { - CRecordStyleTextPropAtom* pStyle = new CRecordStyleTextPropAtom(); - pStyle->m_lCount = strText.length(); + { + CRecordStyleTextPropAtom* pStyle = new CRecordStyleTextPropAtom(); + pStyle->m_lCount = strText.length(); - pStyle->ReadFromStream(oHeader, oElemInfo.m_pStream); + pStyle->ReadFromStream(oHeader, oElemInfo.m_pStream); - PPT_FORMAT::ConvertPPTTextToEditorStructure(pStyle->m_arrPFs, pStyle->m_arrCFs, strText, pShape->m_pShape->m_oText); + PPT_FORMAT::ConvertPPTTextToEditorStructure(pStyle->m_arrPFs, pStyle->m_arrCFs, strText, pShape->m_pShape->m_oText); - bIsOwnPresentSettings = (0 < pStyle->m_lCount); + bIsOwnPresentSettings = (0 < pStyle->m_lCount); - RELEASEOBJECT(pStyle); - } - StreamUtils::StreamSeek(lPosition, oElemInfo.m_pStream); - } + RELEASEOBJECT(pStyle); + } + StreamUtils::StreamSeek(lPosition, oElemInfo.m_pStream); + } - // ------------------------------------------------------------------------------ + // ------------------------------------------------------------------------------ - // теперь выставляем все настройки текста (стили) - if (NULL == pSlide) - { - int nTextMasterType = (int)eTypeMaster; - if (-1 != pShape->m_lPlaceholderType) - { - switch (oElemInfo.m_lMasterPlaceholderType) - { - case PT_Title: - case PT_MasterTitle: - case PT_VerticalTitle: - { - pTextSettings->m_lStyleThemeIndex = 1; + // теперь выставляем все настройки текста (стили) + if (NULL == pSlide) + { + int nTextMasterType = (int)eTypeMaster; + if (-1 != pShape->m_lPlaceholderType) + { + switch (oElemInfo.m_lMasterPlaceholderType) + { + case PT_Title: + case PT_MasterTitle: + case PT_VerticalTitle: + { + pTextSettings->m_lStyleThemeIndex = 1; - if (Tx_TYPE_TITLE != eTypeMaster) - { - if (0 <= nTextMasterType && nTextMasterType < 9) - { - if (pThemeWrapper->m_pStyles[nTextMasterType].is_init()) - pTextSettings->m_oStyles = pThemeWrapper->m_pStyles[nTextMasterType].get(); - } - } - break; - } - case PT_CenterTitle: - case PT_MasterCenterTitle: - { - pTextSettings->m_lStyleThemeIndex = 1; + if (Tx_TYPE_TITLE != eTypeMaster) + { + if (0 <= nTextMasterType && nTextMasterType < 9) + { + if (pThemeWrapper->m_pStyles[nTextMasterType].is_init()) + pTextSettings->m_oStyles = pThemeWrapper->m_pStyles[nTextMasterType].get(); + } + } + break; + } + case PT_CenterTitle: + case PT_MasterCenterTitle: + { + pTextSettings->m_lStyleThemeIndex = 1; - if (Tx_TYPE_TITLE != eTypeMaster) - { - if (0 <= nTextMasterType && nTextMasterType < 9) - { - if (pThemeWrapper->m_pStyles[nTextMasterType].is_init()) - pTextSettings->m_oStyles = pThemeWrapper->m_pStyles[nTextMasterType].get(); - } - } - break; - } - case PT_Body: - case PT_MasterBody: - case PT_NotesBody: - case PT_MasterNotesBody: - case PT_VerticalBody: - case PT_MasterSubTitle: - case PT_SubTitle: - { - pTextSettings->m_lStyleThemeIndex = 2; + if (Tx_TYPE_TITLE != eTypeMaster) + { + if (0 <= nTextMasterType && nTextMasterType < 9) + { + if (pThemeWrapper->m_pStyles[nTextMasterType].is_init()) + pTextSettings->m_oStyles = pThemeWrapper->m_pStyles[nTextMasterType].get(); + } + } + break; + } + case PT_Body: + case PT_MasterBody: + case PT_NotesBody: + case PT_MasterNotesBody: + case PT_VerticalBody: + case PT_MasterSubTitle: + case PT_SubTitle: + { + pTextSettings->m_lStyleThemeIndex = 2; - if ((Tx_TYPE_BODY != eTypeMaster) || !pLayout) - { - if (0 <= nTextMasterType && nTextMasterType < 9) - { - if (pThemeWrapper->m_pStyles[nTextMasterType].is_init()) - pTextSettings->m_oStyles = pThemeWrapper->m_pStyles[nTextMasterType].get(); - } - } - break; - } - default: - { - pTextSettings->m_lStyleThemeIndex = 3; + if ((Tx_TYPE_BODY != eTypeMaster) || !pLayout) + { + if (0 <= nTextMasterType && nTextMasterType < 9) + { + if (pThemeWrapper->m_pStyles[nTextMasterType].is_init()) + pTextSettings->m_oStyles = pThemeWrapper->m_pStyles[nTextMasterType].get(); + } + } + break; + } + default: + { + pTextSettings->m_lStyleThemeIndex = 3; - if ((Tx_TYPE_OTHER != eTypeMaster) || !pLayout) - { - if (0 <= nTextMasterType && nTextMasterType < 9) - { - if (pThemeWrapper->m_pStyles[nTextMasterType].is_init()) - { - pTextSettings->m_oStyles = pThemeWrapper->m_pStyles[nTextMasterType].get(); - } - } - } - break; - } - } - } - else - { - //pTextSettings->m_lTextType = 0; + if ((Tx_TYPE_OTHER != eTypeMaster) || !pLayout) + { + if (0 <= nTextMasterType && nTextMasterType < 9) + { + if (pThemeWrapper->m_pStyles[nTextMasterType].is_init()) + { + pTextSettings->m_oStyles = pThemeWrapper->m_pStyles[nTextMasterType].get(); + } + } + } + break; + } + } + } + else + { + //pTextSettings->m_lTextType = 0; - //if (Other != eTypeMaster) - //{ - // if (0 <= nTextMasterType && nTextMasterType < 9) - // { - // if (pThemeWrapper->m_pStyles[nTextMasterType].is_init()) - // pTextSettings->m_oStyles = pThemeWrapper->m_pStyles[nTextMasterType].get(); - // } - //} - } + //if (Other != eTypeMaster) + //{ + // if (0 <= nTextMasterType && nTextMasterType < 9) + // { + // if (pThemeWrapper->m_pStyles[nTextMasterType].is_init()) + // pTextSettings->m_oStyles = pThemeWrapper->m_pStyles[nTextMasterType].get(); + // } + //} + } - // теперь смотрим все остальные стили (persist и own) - просто применяем их к m_oStyles - if (eTypePersist != NoPresent && eTypePersist != eTypeMaster) - { - int nIndexType = (int)eTypePersist; - if (0 <= nIndexType && nIndexType < 9) - { - if (pThemeWrapper->m_pStyles[nIndexType].is_init()) - pTextSettings->m_oStyles.ApplyAfter(pThemeWrapper->m_pStyles[nIndexType].get()); - } - } - if (eTypeOwn != NoPresent && eTypeOwn != eTypePersist && eTypeOwn != eTypeMaster) - { - int nIndexType = (int)eTypeOwn; - if (0 <= nIndexType && nIndexType < 9) - { - if (pThemeWrapper->m_pStyles[nIndexType].is_init()) - pTextSettings->m_oStyles.ApplyAfter(pThemeWrapper->m_pStyles[nIndexType].get()); - } - } - } - else - { - if (-1 != pShape->m_lPlaceholderType) - { - if (NULL != pElementLayoutPH) - { - pTextSettings->m_oLayoutStyles = pElementLayoutPH->m_pShape->m_oText.m_oStyles; - pTextSettings->m_lTextType = pElementLayoutPH->m_pShape->m_oText.m_lTextType; - pTextSettings->m_lStyleThemeIndex = pElementLayoutPH->m_pShape->m_oText.m_lStyleThemeIndex; - } - else - { - switch (oElemInfo.m_lMasterPlaceholderType) - { - case PT_Title: - case PT_MasterTitle: - case PT_VerticalTitle: - { - pTextSettings->m_lStyleThemeIndex = 1; - break; - } - case PT_CenterTitle: - case PT_MasterCenterTitle: - { - pTextSettings->m_lStyleThemeIndex = 1; - break; - } - case PT_Body: - case PT_MasterBody: - case PT_NotesBody: - case PT_MasterNotesBody: - case PT_VerticalBody: - { - pTextSettings->m_lStyleThemeIndex = 2; - break; - } - default: - { - pTextSettings->m_lStyleThemeIndex = 3; - break; - } - } - } - } - else - { - pTextSettings->m_lStyleThemeIndex = -1; - } + // теперь смотрим все остальные стили (persist и own) - просто применяем их к m_oStyles + if (eTypePersist != NoPresent && eTypePersist != eTypeMaster) + { + int nIndexType = (int)eTypePersist; + if (0 <= nIndexType && nIndexType < 9) + { + if (pThemeWrapper->m_pStyles[nIndexType].is_init()) + pTextSettings->m_oStyles.ApplyAfter(pThemeWrapper->m_pStyles[nIndexType].get()); + } + } + if (eTypeOwn != NoPresent && eTypeOwn != eTypePersist && eTypeOwn != eTypeMaster) + { + int nIndexType = (int)eTypeOwn; + if (0 <= nIndexType && nIndexType < 9) + { + if (pThemeWrapper->m_pStyles[nIndexType].is_init()) + pTextSettings->m_oStyles.ApplyAfter(pThemeWrapper->m_pStyles[nIndexType].get()); + } + } + } + else + { + if (-1 != pShape->m_lPlaceholderType) + { + if (NULL != pElementLayoutPH) + { + pTextSettings->m_oLayoutStyles = pElementLayoutPH->m_pShape->m_oText.m_oStyles; + pTextSettings->m_lTextType = pElementLayoutPH->m_pShape->m_oText.m_lTextType; + pTextSettings->m_lStyleThemeIndex = pElementLayoutPH->m_pShape->m_oText.m_lStyleThemeIndex; + } + else + { + switch (oElemInfo.m_lMasterPlaceholderType) + { + case PT_Title: + case PT_MasterTitle: + case PT_VerticalTitle: + { + pTextSettings->m_lStyleThemeIndex = 1; + break; + } + case PT_CenterTitle: + case PT_MasterCenterTitle: + { + pTextSettings->m_lStyleThemeIndex = 1; + break; + } + case PT_Body: + case PT_MasterBody: + case PT_NotesBody: + case PT_MasterNotesBody: + case PT_VerticalBody: + { + pTextSettings->m_lStyleThemeIndex = 2; + break; + } + default: + { + pTextSettings->m_lStyleThemeIndex = 3; + break; + } + } + } + } + else + { + pTextSettings->m_lStyleThemeIndex = -1; + } - // теперь смотрим все остальные стили (persist и own) - просто применяем их к m_oStyles - if (eTypePersist != NoPresent && eTypePersist != eTypeMaster) - { - int nIndexType = (int)eTypePersist; - if (0 <= nIndexType && nIndexType < 9) - { - if (pThemeWrapper->m_pStyles[nIndexType].is_init()) - pTextSettings->m_oStyles.ApplyAfter(pThemeWrapper->m_pStyles[nIndexType].get()); - } - } - if (eTypeOwn != NoPresent && eTypeOwn != Tx_TYPE_OTHER && eTypeOwn != eTypePersist && eTypeOwn != eTypeMaster) - {//齐孟尧-2015年度职工考核报告.ppt - int nIndexType = (int)eTypeOwn; - - if (0 <= nIndexType && nIndexType < 9 && pLayout) - { - if (eTypeOwn == Tx_TYPE_HALFBODY || eTypeOwn == Tx_TYPE_QUARTERBODY) - { - if (pThemeWrapper->m_pStyles[1].IsInit())//body -> (560).ppt - { - pTextSettings->m_oStyles.ApplyAfter(pThemeWrapper->m_pStyles[1].get()); - } - } - if (pThemeWrapper->m_pStyles[nIndexType].IsInit()) - { - pTextSettings->m_oStyles.ApplyAfter(pThemeWrapper->m_pStyles[nIndexType].get()); - } - } - } - } + // теперь смотрим все остальные стили (persist и own) - просто применяем их к m_oStyles + if (eTypePersist != NoPresent && eTypePersist != eTypeMaster) + { + int nIndexType = (int)eTypePersist; + if (0 <= nIndexType && nIndexType < 9) + { + if (pThemeWrapper->m_pStyles[nIndexType].is_init()) + pTextSettings->m_oStyles.ApplyAfter(pThemeWrapper->m_pStyles[nIndexType].get()); + } + } + if (eTypeOwn != NoPresent && eTypeOwn != Tx_TYPE_OTHER && eTypeOwn != eTypePersist && eTypeOwn != eTypeMaster) + {//齐孟尧-2015年度职工考核报告.ppt + int nIndexType = (int)eTypeOwn; - if ((_T("") != strText) && 0 == pTextSettings->m_arParagraphs.size()) - { - // значит никаких своих настроек нету. Значит просто пустые свои настройки - std::vector oArrayPF; - - CTextPFRunRecord elm; - - elm.m_lCount = strText.length(); - elm.m_lLevel = 0; - - oArrayPF.push_back(elm); + if (0 <= nIndexType && nIndexType < 9 && pLayout) + { + if (eTypeOwn == Tx_TYPE_HALFBODY || eTypeOwn == Tx_TYPE_QUARTERBODY) + { + if (pThemeWrapper->m_pStyles[1].IsInit())//body -> (560).ppt + { + pTextSettings->m_oStyles.ApplyAfter(pThemeWrapper->m_pStyles[1].get()); + } + } + if (pThemeWrapper->m_pStyles[nIndexType].IsInit()) + { + pTextSettings->m_oStyles.ApplyAfter(pThemeWrapper->m_pStyles[nIndexType].get()); + } + } + } + } - std::vector oArrayCF; - - CTextCFRunRecord elm1; - elm1.m_lCount = elm.m_lCount; - - oArrayCF.push_back(elm1); - - PPT_FORMAT::ConvertPPTTextToEditorStructure(oArrayPF, oArrayCF, strText, *pTextSettings); - } + if ((_T("") != strText) && 0 == pTextSettings->m_arParagraphs.size()) + { + // значит никаких своих настроек нету. Значит просто пустые свои настройки + std::vector oArrayPF; - if (NULL != oElemInfo.m_pStream && -1 != oElemInfo.m_lOffsetTextProp) - { - //языковые настройки текта - LONG lPosition = 0; StreamUtils::StreamPosition(lPosition, oElemInfo.m_pStream); + CTextPFRunRecord elm; - StreamUtils::StreamSeek(oElemInfo.m_lOffsetTextProp - 8, oElemInfo.m_pStream); + elm.m_lCount = strText.length(); + elm.m_lLevel = 0; - SRecordHeader oHeader; - oHeader.ReadFromStream(oElemInfo.m_pStream) ; + oArrayPF.push_back(elm); + + std::vector oArrayCF; + + CTextCFRunRecord elm1; + elm1.m_lCount = elm.m_lCount; + + oArrayCF.push_back(elm1); + + PPT_FORMAT::ConvertPPTTextToEditorStructure(oArrayPF, oArrayCF, strText, *pTextSettings); + } + + if (NULL != oElemInfo.m_pStream && -1 != oElemInfo.m_lOffsetTextProp) + { + //языковые настройки текта + LONG lPosition = 0; StreamUtils::StreamPosition(lPosition, oElemInfo.m_pStream); + + StreamUtils::StreamSeek(oElemInfo.m_lOffsetTextProp - 8, oElemInfo.m_pStream); + + SRecordHeader oHeader; + oHeader.ReadFromStream(oElemInfo.m_pStream) ; if (RT_TextSpecialInfoAtom == oHeader.RecType) - { - CRecordTextSpecInfoAtom* pSpecInfo = new CRecordTextSpecInfoAtom(); - pSpecInfo->m_lCount = -1; + { + CRecordTextSpecInfoAtom* pSpecInfo = new CRecordTextSpecInfoAtom(); + pSpecInfo->m_lCount = -1; - pSpecInfo->ReadFromStream(oHeader, oElemInfo.m_pStream); - pSpecInfo->ApplyProperties(&(pShape->m_pShape->m_oText)); + pSpecInfo->ReadFromStream(oHeader, oElemInfo.m_pStream); + pSpecInfo->ApplyProperties(&(pShape->m_pShape->m_oText)); - RELEASEOBJECT(pSpecInfo); - } - StreamUtils::StreamSeek(lPosition, oElemInfo.m_pStream); - } - pShape->m_pShape->m_oText.RecalcParagraphsPPT(); - - ApplyThemeStyle(pElem, pTheme, master_levels); + RELEASEOBJECT(pSpecInfo); + } + StreamUtils::StreamSeek(lPosition, oElemInfo.m_pStream); + } + pShape->m_pShape->m_oText.RecalcParagraphsPPT(); - if (pShape->m_oTextActions.m_bPresent) - { - //todooo разобраться нужно ли менять цвет на гиперлинк - 1-(34).ppt - ODRAW::CColor oColor; - if ((NULL != pSlide) && !pSlide->m_bUseLayoutColorScheme) oColor = pSlide->GetColor(11); - else if ((NULL != pLayout) && (!pLayout->m_bUseThemeColorScheme)) oColor = pLayout->GetColor(11); - else if (NULL != pTheme) oColor = pTheme->GetColor(11); - oColor.m_lSchemeIndex = 11; + ApplyThemeStyle(pElem, pTheme, master_levels); - ApplyHyperlink(pShape, oColor); - } + if (pShape->m_oTextActions.m_bPresent) + { + //todooo разобраться нужно ли менять цвет на гиперлинк - 1-(34).ppt + ODRAW::CColor oColor; + if ((NULL != pSlide) && !pSlide->m_bUseLayoutColorScheme) oColor = pSlide->GetColor(11); + else if ((NULL != pLayout) && (!pLayout->m_bUseThemeColorScheme)) oColor = pLayout->GetColor(11); + else if (NULL != pTheme) oColor = pTheme->GetColor(11); + oColor.m_lSchemeIndex = 11; - CPPTShape* pPPTShape = dynamic_cast(pShape->m_pShape->getBaseShape().get()); + ApplyHyperlink(pShape, oColor); + } - if (NULL != pPPTShape) // проверка на wordart - { - switch (pPPTShape->m_eType) - { - case sptTextPlainText: - case sptTextStop: - case sptTextTriangle: - case sptTextTriangleInverted: - case sptTextChevron: - case sptTextChevronInverted: - case sptTextRingInside: - case sptTextRingOutside: - case sptTextArchUpCurve: - case sptTextArchDownCurve: - case sptTextCircleCurve: - case sptTextButtonCurve: - case sptTextArchUpPour: - case sptTextArchDownPour: - case sptTextCirclePour: - case sptTextButtonPour: - case sptTextCurveUp: - case sptTextCurveDown: - case sptTextCascadeUp: - case sptTextCascadeDown: - case sptTextWave1: - case sptTextWave2: - case sptTextWave3: - case sptTextWave4: - case sptTextInflate: - case sptTextDeflate: - case sptTextInflateBottom: - case sptTextDeflateBottom: - case sptTextInflateTop: - case sptTextDeflateTop: - case sptTextDeflateInflate: - case sptTextDeflateInflateDeflate: - case sptTextFadeRight: - case sptTextFadeLeft: - case sptTextFadeUp: - case sptTextFadeDown: - case sptTextSlantUp: - case sptTextSlantDown: - case sptTextCanUp: - case sptTextCanDown: - { - pShape->m_pShape->m_oText.m_oAttributes.m_oTextBrush = pShape->m_oBrush; + CPPTShape* pPPTShape = dynamic_cast(pShape->m_pShape->getBaseShape().get()); - pShape->m_pShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 1; - pShape->m_pShape->m_oText.m_oAttributes.m_nTextAlignVertical = 1; + if (NULL != pPPTShape) // проверка на wordart + { + switch (pPPTShape->m_eType) + { + case sptTextPlainText: + case sptTextStop: + case sptTextTriangle: + case sptTextTriangleInverted: + case sptTextChevron: + case sptTextChevronInverted: + case sptTextRingInside: + case sptTextRingOutside: + case sptTextArchUpCurve: + case sptTextArchDownCurve: + case sptTextCircleCurve: + case sptTextButtonCurve: + case sptTextArchUpPour: + case sptTextArchDownPour: + case sptTextCirclePour: + case sptTextButtonPour: + case sptTextCurveUp: + case sptTextCurveDown: + case sptTextCascadeUp: + case sptTextCascadeDown: + case sptTextWave1: + case sptTextWave2: + case sptTextWave3: + case sptTextWave4: + case sptTextInflate: + case sptTextDeflate: + case sptTextInflateBottom: + case sptTextDeflateBottom: + case sptTextInflateTop: + case sptTextDeflateTop: + case sptTextDeflateInflate: + case sptTextDeflateInflateDeflate: + case sptTextFadeRight: + case sptTextFadeLeft: + case sptTextFadeUp: + case sptTextFadeDown: + case sptTextSlantUp: + case sptTextSlantDown: + case sptTextCanUp: + case sptTextCanDown: + { + pShape->m_pShape->m_oText.m_oAttributes.m_oTextBrush = pShape->m_oBrush; - pShape->m_pShape->m_lDrawType = c_ShapeDrawType_Text; - break; - } - default: - break; - }; - } + pShape->m_pShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 1; + pShape->m_pShape->m_oText.m_oAttributes.m_nTextAlignVertical = 1; + + pShape->m_pShape->m_lDrawType = c_ShapeDrawType_Text; + break; + } + default: + break; + }; + } } void CRecordShapeContainer::ApplyHyperlink(CShapeElement* pShape, CColor& oColor) { - std::vector* pRanges = &pShape->m_oTextActions.m_arRanges; - CTextAttributesEx* pTextAttributes = &pShape->m_pShape->m_oText; + std::vector* pRanges = &pShape->m_oTextActions.m_arRanges; + CTextAttributesEx* pTextAttributes = &pShape->m_pShape->m_oText; - int lCountHyper = pRanges->size(); + int lCountHyper = pRanges->size(); - if (0 == lCountHyper) - return; + if (0 == lCountHyper) + return; - size_t nCountPars = pTextAttributes->m_arParagraphs.size(); - for (int nIndexRange = 0; nIndexRange < lCountHyper; ++nIndexRange) - { - int lStart = (*pRanges)[nIndexRange].m_lStart; - int lEnd = (*pRanges)[nIndexRange].m_lEnd; + size_t nCountPars = pTextAttributes->m_arParagraphs.size(); + for (int nIndexRange = 0; nIndexRange < lCountHyper; ++nIndexRange) + { + int lStart = (*pRanges)[nIndexRange].m_lStart; + int lEnd = (*pRanges)[nIndexRange].m_lEnd; - int lCurrentStart = 0; - for (size_t nIndexPar = 0; nIndexPar < nCountPars; ++nIndexPar) - { - CParagraph* pParagraph = &pTextAttributes->m_arParagraphs[nIndexPar]; + int lCurrentStart = 0; + for (size_t nIndexPar = 0; nIndexPar < nCountPars; ++nIndexPar) + { + CParagraph* pParagraph = &pTextAttributes->m_arParagraphs[nIndexPar]; - for (size_t nIndexSpan = 0; nIndexSpan < pParagraph->m_arSpans.size(); ++nIndexSpan) - { - int lCurrentEnd = lCurrentStart + pParagraph->m_arSpans[nIndexSpan].m_strText.length() - 1; + for (size_t nIndexSpan = 0; nIndexSpan < pParagraph->m_arSpans.size(); ++nIndexSpan) + { + int lCurrentEnd = lCurrentStart + pParagraph->m_arSpans[nIndexSpan].m_strText.length() - 1; - if (lCurrentStart > lEnd || lCurrentEnd < lStart) - { - lCurrentStart = lCurrentEnd + 1; - continue; - } + if (lCurrentStart > lEnd || lCurrentEnd < lStart) + { + lCurrentStart = lCurrentEnd + 1; + continue; + } int lStart_ = (std::max)(lStart, lCurrentStart); int lEnd_ = (std::min)(lEnd, lCurrentEnd); - CSpan oRunProp = pParagraph->m_arSpans[nIndexSpan]; + CSpan oRunProp = pParagraph->m_arSpans[nIndexSpan]; - std::wstring strText = pParagraph->m_arSpans[nIndexSpan].m_strText; - if (lStart_ > lCurrentStart) - { - pParagraph->m_arSpans.insert(pParagraph->m_arSpans.begin() + nIndexSpan, oRunProp); - pParagraph->m_arSpans[nIndexSpan].m_strText = strText.substr(0, lStart_ - lCurrentStart); + std::wstring strText = pParagraph->m_arSpans[nIndexSpan].m_strText; + if (lStart_ > lCurrentStart) + { + pParagraph->m_arSpans.insert(pParagraph->m_arSpans.begin() + nIndexSpan, oRunProp); + pParagraph->m_arSpans[nIndexSpan].m_strText = strText.substr(0, lStart_ - lCurrentStart); - ++nIndexSpan; - } - pParagraph->m_arSpans[nIndexSpan].m_oRun.Color = oColor; + ++nIndexSpan; + } + pParagraph->m_arSpans[nIndexSpan].m_oRun.Color = oColor; pParagraph->m_arSpans[nIndexSpan].m_oRun.FontUnderline = (bool)true; - pParagraph->m_arSpans[nIndexSpan].m_strText = strText.substr(lStart_ - lCurrentStart, lEnd_ - lStart_ + 1); - if (lEnd_ < lCurrentEnd) - { - pParagraph->m_arSpans.insert(pParagraph->m_arSpans.begin() + nIndexSpan + 1, oRunProp); - ++nIndexSpan; + pParagraph->m_arSpans[nIndexSpan].m_strText = strText.substr(lStart_ - lCurrentStart, lEnd_ - lStart_ + 1); + if (lEnd_ < lCurrentEnd) + { + pParagraph->m_arSpans.insert(pParagraph->m_arSpans.begin() + nIndexSpan + 1, oRunProp); + ++nIndexSpan; - pParagraph->m_arSpans[nIndexSpan].m_strText = strText.substr(lEnd_ - lCurrentStart + 1, lCurrentEnd - lEnd_); - } + pParagraph->m_arSpans[nIndexSpan].m_strText = strText.substr(lEnd_ - lCurrentStart + 1, lCurrentEnd - lEnd_); + } - lCurrentStart = lCurrentEnd + 1; - } - } - } + lCurrentStart = lCurrentEnd + 1; + } + } + } } void CRecordGroupShapeContainer::ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream) { - CRecordsContainer::ReadFromStream(oHeader, pStream); + CRecordsContainer::ReadFromStream(oHeader, pStream); } diff --git a/ASCOfficePPTXFile/Editor/Drawing/Element.h b/ASCOfficePPTXFile/Editor/Drawing/Element.h index 4d2b62a02c..a3eb135f7d 100644 --- a/ASCOfficePPTXFile/Editor/Drawing/Element.h +++ b/ASCOfficePPTXFile/Editor/Drawing/Element.h @@ -45,7 +45,8 @@ namespace PPT_FORMAT etAudio = 2, etPicture = 3, etShape = 4, - etText = 5 + etText = 5, + etTable = 6 }; class CTheme; @@ -72,7 +73,7 @@ namespace PPT_FORMAT double m_dEndTime; CTextInteractiveInfo m_oTextActions; - std::vector m_arrActions; + std::vector m_arrActions; CAnimationInfo m_oAnimations; CEffects m_oEffects; diff --git a/ASCOfficePPTXFile/Editor/Drawing/Elements.h b/ASCOfficePPTXFile/Editor/Drawing/Elements.h index 6b41f8b0a9..0891ab26e4 100644 --- a/ASCOfficePPTXFile/Editor/Drawing/Elements.h +++ b/ASCOfficePPTXFile/Editor/Drawing/Elements.h @@ -731,7 +731,8 @@ namespace PPT_FORMAT return pElement; } }; - class CVideoElement : public CImageElement + + class CVideoElement : public CImageElement { public: std::wstring m_strVideoFileName; @@ -780,33 +781,58 @@ namespace PPT_FORMAT } }; - class CGroupElement : public CElement - { - public: - CGroupElement() : CElement() - { - m_etType = etGroup; - } - virtual ~CGroupElement() - { - } - virtual CElementPtr CreateDublicate() - { - CGroupElement* pGroupElement = new CGroupElement(); + class CGroupElement : public CElement + { + public: + CGroupElement() : CElement() + { + m_etType = etGroup; + } + virtual ~CGroupElement() + { + } + virtual CElementPtr CreateDublicate() + { + CGroupElement* pGroupElement = new CGroupElement(); - CElementPtr pElement = CElementPtr( pGroupElement ); - - SetProperiesToDublicate(pElement); + CElementPtr pElement = CElementPtr( pGroupElement ); - return pElement; - } - AVSINLINE std::wstring ConvertPPTShapeToPPTX(bool bIsNamespace = false) - { + SetProperiesToDublicate(pElement); - return L""; - } - }; + return pElement; + } + AVSINLINE std::wstring ConvertPPTShapeToPPTX(bool bIsNamespace = false) + { + return L""; + } + }; + class CTableElement : public CElement + { + public: + CTableElement() : CElement() + { + m_etType = etTable; + } + virtual ~CTableElement() + { + } + virtual CElementPtr CreateDublicate() + { + CTableElement* pTableElement = new CTableElement(); + + CElementPtr pElement = CElementPtr( pTableElement ); + + SetProperiesToDublicate(pElement); + + return pElement; + } + AVSINLINE std::wstring ConvertPPTShapeToPPTX(bool bIsNamespace = false) + { + + return L""; + } + }; } From d377bef3a10a3373695c6783d847381208d82c23 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Mon, 31 May 2021 14:38:18 +0300 Subject: [PATCH 02/84] catch table --- .../PPTFormatLib/PPTXWriter/Converter.cpp | 1 + .../PPTFormatLib/Reader/Records.h | 2 +- .../Records/Drawing/ShapeContainer.cpp | 20 ++++++++++++++++++- .../Records/Drawing/ShapeContainer.h | 2 ++ X2tConverter/build/Qt/X2tConverter.pri | 2 +- 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp index 3ee052074c..bbc2475d88 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp @@ -939,6 +939,7 @@ void PPT_FORMAT::CPPTXWriter::WriteTable(CStringWriter& oWriter, CRelsGenerator& if (!pTableElement) return; m_pShapeWriter->SetElement(pElement); +// PPTX::Logic::GraphicFrame oWriter.WriteString(m_pShapeWriter->ConvertTable()); oWriter.WriteString(m_pShapeWriter->ConvertTableCells()); diff --git a/ASCOfficePPTFile/PPTFormatLib/Reader/Records.h b/ASCOfficePPTFile/PPTFormatLib/Reader/Records.h index e4dbba8ad8..728d75dc86 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Reader/Records.h +++ b/ASCOfficePPTFile/PPTFormatLib/Reader/Records.h @@ -225,7 +225,7 @@ public: virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream); template - void GetRecordsByType(std::vector* pArray, bool bIsChild, bool bOnlyFirst = false) + void GetRecordsByType(std::vector* pArray, bool bIsChild, bool bOnlyFirst = false) const { if (NULL == pArray) return; diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp index c3add9ed70..2c4c78e6f4 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp @@ -1643,7 +1643,7 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, }break; default: { - if (bGroupShape && 0) + if (isTable()) { CTableElement* pTableElem = new CTableElement(); pElement = CElementPtr(pTableElem); @@ -2041,6 +2041,24 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, return pElement; } +bool CRecordShapeContainer::isTable() const +{ + std::vector oArrayOptions; + GetRecordsByType(&oArrayOptions, true, false); + + for (const auto* option : oArrayOptions) + { + for (const auto& prop : option->m_oProperties.m_arProperties) + { + if ((prop.m_ePID == tableProperties || + prop.m_ePID == tableRowProperties) && + bGroupShape) + return true; + } + } + return false; +} + void CRecordShapeContainer::ApplyThemeStyle(CElementPtr pElem, CTheme* pTheme, CRecordMasterTextPropAtom* master_levels) { CShapeElement* pShape = dynamic_cast(pElem.get()); diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h index a737f0eaf0..054b02f5bd 100755 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h @@ -140,7 +140,9 @@ public: protected: + bool isTable()const; void ApplyThemeStyle(CElementPtr pElem, CTheme* pTheme, CRecordMasterTextPropAtom* master_levels); void SetUpTextStyle(std::wstring& strText, CTheme* pTheme, CLayout* pLayout, CElementPtr pElem, CSlideInfo* pThemeWrapper, CSlideInfo* pSlideWrapper, CSlide* pSlide, CRecordMasterTextPropAtom* master_levels); void ApplyHyperlink(CShapeElement* pShape, CColor& oColor); }; + diff --git a/X2tConverter/build/Qt/X2tConverter.pri b/X2tConverter/build/Qt/X2tConverter.pri index 1f38285f30..ccf6b6fd68 100755 --- a/X2tConverter/build/Qt/X2tConverter.pri +++ b/X2tConverter/build/Qt/X2tConverter.pri @@ -91,7 +91,7 @@ LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lDocxFormatLib LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lCryptoPPLib #All dynamic libs -ADD_DEPENDENCY(graphics, kernel, UnicodeConverter, PdfWriter, PdfReader, HtmlFile2, EpubFile, XpsFile, DjVuFile, HtmlRenderer, doctrenderer, Fb2File) +ADD_DEPENDENCY(graphics, kernel, UnicodeConverter, Fb2File, PdfWriter, PdfReader, HtmlFile2, EpubFile, XpsFile, DjVuFile, HtmlRenderer, doctrenderer) ##################################################### # внешнее подключение сторонних библиотек From 190f1ffc109f615017eb7f49d58c0449106dcb4b Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Mon, 31 May 2021 18:36:27 +0300 Subject: [PATCH 03/84] add table class --- .../PPTFormatLib/Linux/PPTFormatLib.pro | 2 + .../PPTFormatLib/PPTXWriter/Converter.cpp | 13 ++--- .../PPTFormatLib/PPTXWriter/TableWriter.cpp | 50 +++++++++++++++++ .../PPTFormatLib/PPTXWriter/TableWriter.h | 54 +++++++++++++++++++ .../Records/Drawing/ShapeContainer.cpp | 2 + 5 files changed, 112 insertions(+), 9 deletions(-) create mode 100644 ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp create mode 100644 ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h diff --git a/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro b/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro index 54359fa016..f66778cfbf 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro +++ b/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro @@ -360,6 +360,7 @@ HEADERS += \ ../Enums/enums.h \ ../PPTFormatLib.h \ ../PPTXWriter/Animation.h \ + ../PPTXWriter/TableWriter.h \ ../Reader/ClassesAtom.h \ ../Reader/CommonZLib.h \ ../Reader/PPTDocumentInfo.h \ @@ -651,5 +652,6 @@ SOURCES += \ ../../../ASCOfficePPTXFile/Editor/Drawing/TextAttributesEx.cpp \ ../../../Common/3dParty/pole/pole.cpp \ ../PPTXWriter/Animation.cpp \ + ../PPTXWriter/TableWriter.cpp \ ../Records/Animations/TimeVariant.cpp diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp index bbc2475d88..613fb1852b 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp @@ -40,6 +40,7 @@ #include "../../../ASCOfficeXlsFile2/source/Common/simple_xml_writer.h" #include "../../../DesktopEditor/common/Directory.h" #include "../../../DesktopEditor/common/SystemUtils.h" +#include "TableWriter.h" #include "../Reader/PPTDocumentInfo.h" @@ -938,16 +939,10 @@ void PPT_FORMAT::CPPTXWriter::WriteTable(CStringWriter& oWriter, CRelsGenerator& if (!pTableElement) return; - m_pShapeWriter->SetElement(pElement); -// PPTX::Logic::GraphicFrame - oWriter.WriteString(m_pShapeWriter->ConvertTable()); - oWriter.WriteString(m_pShapeWriter->ConvertTableCells()); -// for (size_t i = 0; i < pGroupElement->m_pChildElements.size(); i++) -// { -// WriteElement(oWriter, oRels, pGroupElement->m_pChildElements[i], pLayout); -// } - oWriter.WriteString(L""); + PPTX::Logic::GraphicFrame gf; + TableWriter(pTableElement).Convert(gf); + oWriter.WriteString(gf.toXML()); } void PPT_FORMAT::CPPTXWriter::WriteElement(CStringWriter& oWriter, CRelsGenerator& oRels, CElementPtr pElement, CLayout* pLayout) { diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp new file mode 100644 index 0000000000..783d668a13 --- /dev/null +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp @@ -0,0 +1,50 @@ +#include "TableWriter.h" + +TableWriter::TableWriter(CTableElement *pTableElement) : + m_pTableElement(pTableElement) +{ + +} + +void TableWriter::Convert(PPTX::Logic::GraphicFrame &oGraphicFrame) +{ + if (!m_pTableElement) + return; + + oGraphicFrame.nvGraphicFramePr = new PPTX::Logic::NvGraphicFramePr; + FillNvGraphicFramePr(oGraphicFrame.nvGraphicFramePr.get2()); + + oGraphicFrame.xfrm = new PPTX::Logic::Xfrm; + FillXfrm(oGraphicFrame.xfrm.get2()); + + oGraphicFrame.table = new PPTX::Logic::Table; + FillTable(oGraphicFrame.table.get2()); +} + +void TableWriter::FillNvGraphicFramePr(PPTX::Logic::NvGraphicFramePr& oNvGFPr) +{ + oNvGFPr.cNvPr.id = m_pTableElement->m_lID; + oNvGFPr.cNvPr.name = m_pTableElement->m_sName; + + // not works in full + // graphicFrameLocks + + PPTX::Logic::Ext ext; + ext.uri = L"{D42A27DB-BD31-4B8C-83A1-F6EECF244321}"; + oNvGFPr.nvPr.extLst.push_back(ext); +} + +void TableWriter::FillXfrm(PPTX::Logic::Xfrm &oXFRM) +{ + oXFRM.offX = int(m_pTableElement->m_rcAnchor.left * 1588); + oXFRM.offY = int(m_pTableElement->m_rcAnchor.top * 1588); + + oXFRM.extX = int(m_pTableElement->m_rcAnchor.right * 983); + oXFRM.extY = int(m_pTableElement->m_rcAnchor.bottom * 1398); + +} + +void TableWriter::FillTable(PPTX::Logic::Table &oTable) +{ + +} diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h new file mode 100644 index 0000000000..53f0bd5651 --- /dev/null +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h @@ -0,0 +1,54 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ +#pragma once + +#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/GraphicFrame.h" +#include "../../../ASCOfficePPTXFile/Editor/Drawing/Elements.h" + +namespace PPT_FORMAT +{ +class TableWriter +{ +public: + TableWriter(CTableElement *pTableElement); + + void Convert(PPTX::Logic::GraphicFrame& oGraphicFrame); + +private: + void FillNvGraphicFramePr(PPTX::Logic::NvGraphicFramePr& oNvGFPr); + void FillXfrm(PPTX::Logic::Xfrm& oXFRM); + void FillTable(PPTX::Logic::Table &oTable); + +private: + CTableElement *m_pTableElement; +}; +} diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp index 2c4c78e6f4..fa8bc81d68 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp @@ -1646,7 +1646,9 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, if (isTable()) { CTableElement* pTableElem = new CTableElement(); + pTableElem->m_etType = etGroup; pElement = CElementPtr(pTableElem); + } else if (bGroupShape) { From 389472e2fb4ea1fd2ee316741065772400ad17df Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Thu, 3 Jun 2021 18:40:47 +0300 Subject: [PATCH 04/84] add some methods for tables --- .../PPTFormatLib/PPTXWriter/TableWriter.cpp | 18 +++++++++++++++++- .../PPTFormatLib/PPTXWriter/TableWriter.h | 9 +++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp index 783d668a13..d871a0226c 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp @@ -41,10 +41,26 @@ void TableWriter::FillXfrm(PPTX::Logic::Xfrm &oXFRM) oXFRM.extX = int(m_pTableElement->m_rcAnchor.right * 983); oXFRM.extY = int(m_pTableElement->m_rcAnchor.bottom * 1398); - } void TableWriter::FillTable(PPTX::Logic::Table &oTable) { } + +void TableWriter::prepareShapes(std::vector &arrCells, std::vector &arrSpliters) +{ + for (const auto& ptrShape : m_pTableElement->m_pChildElements) + { + auto pShapeEl = dynamic_cast(ptrShape.get()); + switch (pShapeEl->m_lShapeType) + { + case 1: + arrCells.push_back(pShapeEl); + break; + case 20: + arrSpliters.push_back(pShapeEl); + break; + } + } +} diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h index 53f0bd5651..cc5e6544af 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h @@ -48,6 +48,15 @@ private: void FillXfrm(PPTX::Logic::Xfrm& oXFRM); void FillTable(PPTX::Logic::Table &oTable); + void FillTblPr(PPTX::Logic::TableProperties& oTblPr); + void FillTblGrid(std::vector& tblGrid); + void prepareShapes(std::vector &arrCells, + std::vector& arrSpliters); + std::vector< std::list > + prepareRows(std::vector &arrCells); + + void FillRows(std::vector& TableRows); + private: CTableElement *m_pTableElement; }; From f5fa11dde5705d3923edb972631f3738d21650a5 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Thu, 3 Jun 2021 18:40:47 +0300 Subject: [PATCH 05/84] add some methods for tables --- .../PPTFormatLib/PPTXWriter/TableWriter.cpp | 34 ++++++++++++++++++- .../PPTFormatLib/PPTXWriter/TableWriter.h | 12 +++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp index 783d668a13..1d0cda57a6 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp @@ -41,10 +41,42 @@ void TableWriter::FillXfrm(PPTX::Logic::Xfrm &oXFRM) oXFRM.extX = int(m_pTableElement->m_rcAnchor.right * 983); oXFRM.extY = int(m_pTableElement->m_rcAnchor.bottom * 1398); - } void TableWriter::FillTable(PPTX::Logic::Table &oTable) { + std::vector arrCells, arrSpliters; + prepareShapes(arrCells, arrSpliters); + auto height = getHeight(arrCells); +} + +std::vector TableWriter::getHeight(std::vector &arrCells) +{ + std::vector height; + int currentHeight = 0; + for (auto* cell : arrCells) + { + auto pShapeEl = dynamic_cast(cell); +// if (pShapeEl->) + } + + return height; +} + +void TableWriter::prepareShapes(std::vector &arrCells, std::vector &arrSpliters) +{ + for (const auto& ptrShape : m_pTableElement->m_pChildElements) + { + auto pShapeEl = dynamic_cast(ptrShape.get()); + switch (pShapeEl->m_lShapeType) + { + case 1: + arrCells.push_back(pShapeEl); + break; + case 20: + arrSpliters.push_back(pShapeEl); + break; + } + } } diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h index 53f0bd5651..a20b6877fb 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h @@ -48,6 +48,18 @@ private: void FillXfrm(PPTX::Logic::Xfrm& oXFRM); void FillTable(PPTX::Logic::Table &oTable); + std::vector getWidth(); + std::vector getHeight(std::vector &arrCells); + + void FillTblPr(PPTX::Logic::TableProperties& oTblPr); + void FillTblGrid(std::vector& tblGrid); + void prepareShapes(std::vector &arrCells, + std::vector& arrSpliters); + std::vector< std::list > + prepareRows(std::vector &arrCells); + + void FillRows(std::vector& TableRows); + private: CTableElement *m_pTableElement; }; From 04374ade42f1498a8f604fa26efade09f2ba74a6 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Fri, 4 Jun 2021 17:22:04 +0300 Subject: [PATCH 06/84] add spliter for old table shapes --- .../PPTFormatLib/PPTXWriter/TableWriter.cpp | 108 +++++++++++++++++- .../PPTFormatLib/PPTXWriter/TableWriter.h | 14 ++- 2 files changed, 113 insertions(+), 9 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp index d871a0226c..1d9d0ec741 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp @@ -36,19 +36,110 @@ void TableWriter::FillNvGraphicFramePr(PPTX::Logic::NvGraphicFramePr& oNvGFPr) void TableWriter::FillXfrm(PPTX::Logic::Xfrm &oXFRM) { - oXFRM.offX = int(m_pTableElement->m_rcAnchor.left * 1588); - oXFRM.offY = int(m_pTableElement->m_rcAnchor.top * 1588); + double multip1 = m_pTableElement->m_bAnchorEnabled ? 1587.6 : 1; + double multip2 = m_pTableElement->m_bAnchorEnabled ? 1273.0 : 1; + oXFRM.offX = int(m_pTableElement->m_rcAnchor.left * multip1); + oXFRM.offY = int(m_pTableElement->m_rcAnchor.top * multip1); - oXFRM.extX = int(m_pTableElement->m_rcAnchor.right * 983); - oXFRM.extY = int(m_pTableElement->m_rcAnchor.bottom * 1398); + oXFRM.extX = int(m_pTableElement->m_rcAnchor.right * multip2); + oXFRM.extY = int(m_pTableElement->m_rcAnchor.bottom * multip2); } void TableWriter::FillTable(PPTX::Logic::Table &oTable) { + oTable.tableProperties = new PPTX::Logic::TableProperties; + FillTblPr(oTable.tableProperties.get2()); + std::vector arrCells, arrSpliters; + prepareShapes(arrCells, arrSpliters); + FillTblGrid(oTable.TableCols , arrCells); + + auto arrRows = getRows(arrCells); + for (auto row : arrRows) + { + PPTX::Logic::TableRow tr; + FillRow(tr, row); + oTable.TableRows.push_back(tr); + } } -void TableWriter::prepareShapes(std::vector &arrCells, std::vector &arrSpliters) +std::vector TableWriter::getWidth(std::vector& arrCells) +{ + std::map mapLeftWidth; + for (const auto* pCell : arrCells) + { + if (!pCell) continue; + double left = pCell->m_rcChildAnchor.left; + double width = pCell->m_rcChildAnchor.right - left; + + // Here we search uniq left to answer: is it new colum? + auto iter = mapLeftWidth.find(left); + if (iter == mapLeftWidth.end()) + { + mapLeftWidth.insert(std::make_pair(left, width)); + } + // Here we check qestion: was it merged cell and now is it true width of colum? + else if (iter->second > width) + { + mapLeftWidth.erase(iter); + mapLeftWidth.insert(std::make_pair(left, width)); + } + } + + std::vector gridWidth; + for (const auto& w : mapLeftWidth) + gridWidth.push_back(int(w.second * 1587.6)); + + return gridWidth; +} + +std::vector > TableWriter::getRows(std::vector &arrCells) +{ + std::vector > arrRows; + int rowTop = -1; + for (auto* pCell : arrCells) + { + if (!pCell) continue; + + double multip = m_pTableElement->m_bAnchorEnabled ? 1587.6 : 1; + int top = int(pCell->m_rcChildAnchor.top * multip); + if (top != rowTop) + { + rowTop = top; + arrRows.push_back(std::vector()); + } + arrRows.back().push_back(pCell); + } + + return arrRows; +} + +int TableWriter::getCellHeight(const CShapeElement *pCell) const +{ + double multip = m_pTableElement->m_bAnchorEnabled ? 1587.6 : 1; + double height = pCell->m_rcChildAnchor.bottom - pCell->m_rcChildAnchor.top; + return int(height * multip); +} + +void TableWriter::FillTblPr(PPTX::Logic::TableProperties &oTblPr) +{ + oTblPr.TableStyleId = L"{F5AB1C69-6EDB-4FF4-983F-18BD219EF322}"; + oTblPr.FirstRow = true; + oTblPr.BandRow = true; +} + +void TableWriter::FillTblGrid(std::vector &tblGrid, std::vector& arrCells) +{ + auto grid = getWidth(arrCells); + for (const auto& w : grid) + { + PPTX::Logic::TableCol tc; + tc.Width = w; + tblGrid.push_back(tc); + } +} + +void TableWriter::prepareShapes(std::vector &arrCells, std::vector &arrSpliters) { for (const auto& ptrShape : m_pTableElement->m_pChildElements) { @@ -64,3 +155,10 @@ void TableWriter::prepareShapes(std::vector &arrCells, std::vector& arrCells) +{ + if (arrCells.empty()) return; + + oRow.Height = getCellHeight(arrCells.front()); +} diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h index cc5e6544af..daa4206269 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h @@ -47,15 +47,21 @@ private: void FillNvGraphicFramePr(PPTX::Logic::NvGraphicFramePr& oNvGFPr); void FillXfrm(PPTX::Logic::Xfrm& oXFRM); void FillTable(PPTX::Logic::Table &oTable); + + std::vector getWidth(std::vector &arrCells); + std::vector > + getRows(std::vector &arrCells); + int getCellHeight(const CShapeElement * pCell)const; void FillTblPr(PPTX::Logic::TableProperties& oTblPr); - void FillTblGrid(std::vector& tblGrid); - void prepareShapes(std::vector &arrCells, - std::vector& arrSpliters); + void FillTblGrid(std::vector& tblGrid, + std::vector &arrCells); + void prepareShapes(std::vector &arrCells, + std::vector& arrSpliters); std::vector< std::list > prepareRows(std::vector &arrCells); - void FillRows(std::vector& TableRows); + void FillRow(PPTX::Logic::TableRow& oRow, std::vector& arrCells); private: CTableElement *m_pTableElement; From 46d0acb10678adbc17278a42f2cf7de87acf0b26 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Fri, 4 Jun 2021 18:53:50 +0300 Subject: [PATCH 07/84] add getProtoTable method --- .../PPTFormatLib/PPTXWriter/TableWriter.cpp | 20 +++++++++++++++++++ .../PPTFormatLib/PPTXWriter/TableWriter.h | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp index 1d9d0ec741..bd031e290f 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp @@ -156,6 +156,26 @@ void TableWriter::prepareShapes(std::vector &arrCells, std::vec } } +std::vector > TableWriter::createProtoTable(std::vector &arrCells) +{ + auto gridWidth = getWidth(arrCells); + auto arrRows = getRows(arrCells); + const unsigned countRows = arrRows.size(); + const unsigned countCols = gridWidth.size(); + + std::vector > protoTable(countRows); + for (unsigned cRow = 0; cRow < countRows; cRow++) + { + std::vector row(countCols); + int top = arrRows[cRow].front()->m_rcChildAnchor.top; + for (unsigned cCol = 0; cCol < countCols; cCol++) + { + + } + protoTable.push_back(row); + } +} + void TableWriter::FillRow(PPTX::Logic::TableRow &oRow, std::vector& arrCells) { if (arrCells.empty()) return; diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h index daa4206269..fe0bcc0a8b 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h @@ -58,8 +58,8 @@ private: std::vector &arrCells); void prepareShapes(std::vector &arrCells, std::vector& arrSpliters); - std::vector< std::list > - prepareRows(std::vector &arrCells); + std::vector > + createProtoTable(std::vector &arrCells); void FillRow(PPTX::Logic::TableRow& oRow, std::vector& arrCells); From 7c9444e086ad9472d2d81c7b7cdbb90b990ebb8a Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Mon, 7 Jun 2021 18:05:32 +0300 Subject: [PATCH 08/84] add not work protoTable --- .../PPTFormatLib/PPTXWriter/TableWriter.cpp | 157 ++++++++++++++++-- .../PPTFormatLib/PPTXWriter/TableWriter.h | 53 +++++- 2 files changed, 186 insertions(+), 24 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp index bd031e290f..961b2da1ad 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp @@ -54,8 +54,8 @@ void TableWriter::FillTable(PPTX::Logic::Table &oTable) prepareShapes(arrCells, arrSpliters); FillTblGrid(oTable.TableCols , arrCells); - auto arrRows = getRows(arrCells); - for (auto row : arrRows) + auto arrRows = createProtoTable(arrCells); + for (auto& row : *arrRows) { PPTX::Logic::TableRow tr; FillRow(tr, row); @@ -63,7 +63,7 @@ void TableWriter::FillTable(PPTX::Logic::Table &oTable) } } -std::vector TableWriter::getWidth(std::vector& arrCells) +std::vector TableWriter::getWidth(std::vector& arrCells, bool isWidth) { std::map mapLeftWidth; for (const auto* pCell : arrCells) @@ -87,8 +87,12 @@ std::vector TableWriter::getWidth(std::vector& arrCells) } std::vector gridWidth; + double multip = isWidth ? 1587.6 : 1.0; for (const auto& w : mapLeftWidth) - gridWidth.push_back(int(w.second * 1587.6)); + { + double value = isWidth ? w.second : w.first; + gridWidth.push_back(int(value * multip)); + } return gridWidth; } @@ -114,13 +118,6 @@ std::vector > TableWriter::getRows(std::vectorm_bAnchorEnabled ? 1587.6 : 1; - double height = pCell->m_rcChildAnchor.bottom - pCell->m_rcChildAnchor.top; - return int(height * multip); -} - void TableWriter::FillTblPr(PPTX::Logic::TableProperties &oTblPr) { oTblPr.TableStyleId = L"{F5AB1C69-6EDB-4FF4-983F-18BD219EF322}"; @@ -156,29 +153,153 @@ void TableWriter::prepareShapes(std::vector &arrCells, std::vec } } -std::vector > TableWriter::createProtoTable(std::vector &arrCells) +ptrProtoTable TableWriter::createProtoTable(std::vector &arrCells) { - auto gridWidth = getWidth(arrCells); + auto gridWidth = getWidth(arrCells, false); auto arrRows = getRows(arrCells); + auto cellIter = arrCells.begin(); + const unsigned countRows = arrRows.size(); const unsigned countCols = gridWidth.size(); - std::vector > protoTable(countRows); + ptrProtoTable pProtoTable(new ProtoTable); for (unsigned cRow = 0; cRow < countRows; cRow++) { - std::vector row(countCols); + pProtoTable->push_back(std::vector()); + std::vector& row = pProtoTable->back(); + int top = arrRows[cRow].front()->m_rcChildAnchor.top; for (unsigned cCol = 0; cCol < countCols; cCol++) { + int left = gridWidth[cCol]; + + CShapeElement* current = (*cellIter); + if (current && + current->m_rcChildAnchor.top == top && + current->m_rcChildAnchor.left == left) + { + row.push_back(TCell(current, cRow, cCol)); + cellIter++; + } else + { + TCell* pParent = FindCellParent(pProtoTable, cRow, cCol); + row.push_back(TCell(nullptr, cRow, cCol, pParent)); + } } - protoTable.push_back(row); } + + return pProtoTable; } -void TableWriter::FillRow(PPTX::Logic::TableRow &oRow, std::vector& arrCells) +TCell *TableWriter::FindCellParent(ptrProtoTable pPT, int row, int col) +{ + if (!pPT || pPT->empty() || row < 0 || col < 1) + return nullptr; + + TCell::eMergeDirection curDir = row > 0 ? + (*pPT)[--row][col].parentDirection() : (*pPT)[row][--col].parentDirection(); + + // go up + while (curDir == TCell::vert && row >= 0) + { + if (curDir == TCell::none) + return &(*pPT)[row][col]; + curDir = (*pPT)[--row][col].parentDirection(); + } + + // go up and left + while (curDir == TCell::hove && row >= 0 && col >= 0) + { + if (curDir == TCell::none) + return &(*pPT)[row][col]; + curDir = (*pPT)[--row][--col].parentDirection(); + } + + // go left + while (curDir == TCell::horz && col >= 0) + { + if (curDir == TCell::none) + return &(*pPT)[row][col]; + curDir = (*pPT)[row][--col].parentDirection(); + } + + return &(*pPT)[(row >= 0 ? row : 0)][(col >= 0 ? col : 0)]; +} + +int TableWriter::getTRHeight(const ProtoTableRow& row) +{ + const TCell* pCell = nullptr; + for (const auto& cell : row) + if (cell.parentDirection() == TCell::none) + { + pCell = &cell; + break; + } + + return pCell ? pCell->getHeight() : 0; +} + +void TableWriter::FillRow(PPTX::Logic::TableRow &oRow, ProtoTableRow& arrCells) { if (arrCells.empty()) return; - oRow.Height = getCellHeight(arrCells.front()); + oRow.Height = getTRHeight(arrCells); + for (auto& protoCell : arrCells) + { + PPTX::Logic::TableCell cell; + protoCell.FillTc(cell); + oRow.Cells.push_back(cell); + } } + +TCell::TCell(CShapeElement *pShape, int row, int col, TCell *pParent) : + m_pShape(pShape), m_row(row), m_col(col), m_pParent(pParent), m_parentDirection(none) +{ + if (m_pParent) + { + if (m_pParent->m_col == m_col && m_pParent->m_row != m_row) + m_parentDirection = vert; + else if (m_pParent->m_col != m_col && m_pParent->m_row == m_row) + m_parentDirection = horz; + else + m_parentDirection = hove; + } +} + +void TCell::setArrBorders(const std::vector &arrBorders) +{ + m_arrBorders = arrBorders; +} + +void TCell::FillTc(PPTX::Logic::TableCell &oTc) +{ + if (m_pParent) + { + FillMergeDirection(oTc); + return; + } + +} + +TCell::eMergeDirection TCell::parentDirection() const +{ + return m_parentDirection; +} + +int TCell::getHeight() const +{ + auto pShape = m_pParent ? m_pParent->m_pShape : m_pShape; + double multip = pShape->m_bAnchorEnabled ? 1587.6 : 1; + double height = pShape->m_rcChildAnchor.bottom - pShape->m_rcChildAnchor.top; + + return int(height * multip); +} + +void TCell::FillMergeDirection(PPTX::Logic::TableCell &oTc) +{ + oTc.HMerge = parentDirection() & horz; + oTc.VMerge = parentDirection() & vert; +} + + diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h index fe0bcc0a8b..f45622bf3a 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h @@ -36,6 +36,47 @@ namespace PPT_FORMAT { +class TCell +{ +public: + TCell(CShapeElement *pShape, int row, int col, TCell* pParent = nullptr); + void setArrBorders(const std::vector &arrBorders); + + void FillTc(PPTX::Logic::TableCell &oTc); + + enum eMergeDirection { + none = 0b00, + vert = 0b01, + horz = 0b10, + hove = (horz | vert) + }; + + eMergeDirection parentDirection() const; + int getHeight()const; + +private: + void FillMergeDirection(PPTX::Logic::TableCell& oTc); + +private: + CShapeElement* m_pShape; + + // 0 - left, 1 - top, 2 - right, 3 - bottom, + // 4 - lnTlToBr, 5 - lnBlToTr + std::vector m_arrBorders; + + // Proto table's coord + int m_row, m_col; + + // Parent + TCell* m_pParent; + eMergeDirection m_parentDirection; +}; + + +typedef std::vector ProtoTableRow; +typedef std::vector ProtoTable; +typedef boost::shared_ptr ptrProtoTable; + class TableWriter { public: @@ -48,20 +89,20 @@ private: void FillXfrm(PPTX::Logic::Xfrm& oXFRM); void FillTable(PPTX::Logic::Table &oTable); - std::vector getWidth(std::vector &arrCells); + std::vector getWidth(std::vector &arrCells, bool isWidth = true); std::vector > - getRows(std::vector &arrCells); - int getCellHeight(const CShapeElement * pCell)const; + getRows(std::vector &arrCells); void FillTblPr(PPTX::Logic::TableProperties& oTblPr); void FillTblGrid(std::vector& tblGrid, std::vector &arrCells); void prepareShapes(std::vector &arrCells, std::vector& arrSpliters); - std::vector > - createProtoTable(std::vector &arrCells); + ptrProtoTable createProtoTable(std::vector &arrCells); + TCell* FindCellParent(ptrProtoTable pPT, int row, int col); + int getTRHeight(const ProtoTableRow& row); - void FillRow(PPTX::Logic::TableRow& oRow, std::vector& arrCells); + void FillRow(PPTX::Logic::TableRow& oRow, ProtoTableRow &arrCells); private: CTableElement *m_pTableElement; From 22bae397cf63a60171684a330426d8d57e47fc10 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Mon, 7 Jun 2021 18:43:23 +0300 Subject: [PATCH 09/84] start to rewrite proto table --- .../PPTFormatLib/PPTXWriter/TableWriter.cpp | 121 +++++++----------- .../PPTFormatLib/PPTXWriter/TableWriter.h | 28 ++-- 2 files changed, 68 insertions(+), 81 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp index 961b2da1ad..786f311ac2 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp @@ -63,7 +63,7 @@ void TableWriter::FillTable(PPTX::Logic::Table &oTable) } } -std::vector TableWriter::getWidth(std::vector& arrCells, bool isWidth) +std::vector ProtoTable::getWidth(std::vector& arrCells, bool isWidth) { std::map mapLeftWidth; for (const auto* pCell : arrCells) @@ -97,7 +97,15 @@ std::vector TableWriter::getWidth(std::vector& arrCells, bo return gridWidth; } -std::vector > TableWriter::getRows(std::vector &arrCells) +std::vector ProtoTable::getHeight(std::vector > &oRows, bool isTop) +{ + for (auto& row : oRows) + { + + } +} + +std::vector > ProtoTable::getRows(std::vector &arrCells) { std::vector > arrRows; int rowTop = -1; @@ -105,8 +113,7 @@ std::vector > TableWriter::getRows(std::vectorm_bAnchorEnabled ? 1587.6 : 1; - int top = int(pCell->m_rcChildAnchor.top * multip); + int top = int(pCell->m_rcChildAnchor.top); if (top != rowTop) { rowTop = top; @@ -155,78 +162,10 @@ void TableWriter::prepareShapes(std::vector &arrCells, std::vec ptrProtoTable TableWriter::createProtoTable(std::vector &arrCells) { - auto gridWidth = getWidth(arrCells, false); - auto arrRows = getRows(arrCells); - auto cellIter = arrCells.begin(); - - const unsigned countRows = arrRows.size(); - const unsigned countCols = gridWidth.size(); - - ptrProtoTable pProtoTable(new ProtoTable); - for (unsigned cRow = 0; cRow < countRows; cRow++) - { - pProtoTable->push_back(std::vector()); - std::vector& row = pProtoTable->back(); - - int top = arrRows[cRow].front()->m_rcChildAnchor.top; - for (unsigned cCol = 0; cCol < countCols; cCol++) - { - int left = gridWidth[cCol]; - - CShapeElement* current = (*cellIter); - if (current && - current->m_rcChildAnchor.top == top && - current->m_rcChildAnchor.left == left) - { - row.push_back(TCell(current, cRow, cCol)); - cellIter++; - } else - { - TCell* pParent = FindCellParent(pProtoTable, cRow, cCol); - row.push_back(TCell(nullptr, cRow, cCol, pParent)); - } - - } - } return pProtoTable; } -TCell *TableWriter::FindCellParent(ptrProtoTable pPT, int row, int col) -{ - if (!pPT || pPT->empty() || row < 0 || col < 1) - return nullptr; - - TCell::eMergeDirection curDir = row > 0 ? - (*pPT)[--row][col].parentDirection() : (*pPT)[row][--col].parentDirection(); - - // go up - while (curDir == TCell::vert && row >= 0) - { - if (curDir == TCell::none) - return &(*pPT)[row][col]; - curDir = (*pPT)[--row][col].parentDirection(); - } - - // go up and left - while (curDir == TCell::hove && row >= 0 && col >= 0) - { - if (curDir == TCell::none) - return &(*pPT)[row][col]; - curDir = (*pPT)[--row][--col].parentDirection(); - } - - // go left - while (curDir == TCell::horz && col >= 0) - { - if (curDir == TCell::none) - return &(*pPT)[row][col]; - curDir = (*pPT)[row][--col].parentDirection(); - } - - return &(*pPT)[(row >= 0 ? row : 0)][(col >= 0 ? col : 0)]; -} - int TableWriter::getTRHeight(const ProtoTableRow& row) { const TCell* pCell = nullptr; @@ -303,3 +242,41 @@ void TCell::FillMergeDirection(PPTX::Logic::TableCell &oTc) } + +ProtoTable::ProtoTable(std::vector &arrCells) +{ + auto arrRows = getRows(arrCells); + m_arrLeft = getWidth(arrCells, false); + m_arrTop + auto cellIter = arrCells.begin(); + + const unsigned countRows = arrRows.size(); + const unsigned countCols = gridWidth.size(); + + for (unsigned cRow = 0; cRow < countRows; cRow++) + { + m_table.push_back(std::vector()); + std::vector& row = m_table.back(); + + int top = arrRows[cRow].front()->m_rcChildAnchor.top; + for (unsigned cCol = 0; cCol < countCols; cCol++) + { + int left = gridWidth[cCol]; + + CShapeElement* current = (*cellIter); + if (current && + current->m_rcChildAnchor.top == top && + current->m_rcChildAnchor.left == left) + { + row.push_back(TCell(current, cRow, cCol)); + cellIter++; + } else + { + TCell* pParent = FindCellParent(pProtoTable, cRow, cCol); + row.push_back(TCell(nullptr, cRow, cCol, pParent)); + } + + } + } + +} diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h index f45622bf3a..39e19d88c9 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h @@ -74,8 +74,25 @@ private: typedef std::vector ProtoTableRow; -typedef std::vector ProtoTable; -typedef boost::shared_ptr ptrProtoTable; + +class ProtoTable +{ +public: + ProtoTable(std::vector &arrCells); + static int getRowHight(ProtoTableRow& oTR); + + std::vector m_table; + +private: + std::vector getWidth(std::vector &arrCells, bool isWidth = true); + std::vector getHeight(std::vector >& oRows, bool isTop = true); + std::vector > + getRows(std::vector &arrCells); + +private: + std::vector m_arrLeft; + std::vector m_arrTop; +}; class TableWriter { @@ -88,19 +105,12 @@ private: void FillNvGraphicFramePr(PPTX::Logic::NvGraphicFramePr& oNvGFPr); void FillXfrm(PPTX::Logic::Xfrm& oXFRM); void FillTable(PPTX::Logic::Table &oTable); - - std::vector getWidth(std::vector &arrCells, bool isWidth = true); - std::vector > - getRows(std::vector &arrCells); void FillTblPr(PPTX::Logic::TableProperties& oTblPr); void FillTblGrid(std::vector& tblGrid, std::vector &arrCells); void prepareShapes(std::vector &arrCells, std::vector& arrSpliters); - ptrProtoTable createProtoTable(std::vector &arrCells); - TCell* FindCellParent(ptrProtoTable pPT, int row, int col); - int getTRHeight(const ProtoTableRow& row); void FillRow(PPTX::Logic::TableRow& oRow, ProtoTableRow &arrCells); From 810e01e7e99ae71209bcc87a747d9a7fdda9da77 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Wed, 9 Jun 2021 14:10:13 +0300 Subject: [PATCH 10/84] add class ProtoTable --- .../PPTFormatLib/PPTXWriter/TableWriter.cpp | 266 +++++++++++++----- .../PPTFormatLib/PPTXWriter/TableWriter.h | 26 +- 2 files changed, 208 insertions(+), 84 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp index 786f311ac2..d8a628ffdd 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp @@ -52,15 +52,16 @@ void TableWriter::FillTable(PPTX::Logic::Table &oTable) std::vector arrCells, arrSpliters; prepareShapes(arrCells, arrSpliters); + m_nPTable = new ProtoTable(arrCells, arrSpliters); FillTblGrid(oTable.TableCols , arrCells); - auto arrRows = createProtoTable(arrCells); - for (auto& row : *arrRows) - { - PPTX::Logic::TableRow tr; - FillRow(tr, row); - oTable.TableRows.push_back(tr); - } + // auto arrRows = createProtoTable(arrCells); + // for (auto& row : *arrRows) + // { + // PPTX::Logic::TableRow tr; + // FillRow(tr, row); + // oTable.TableRows.push_back(tr); + // } } std::vector ProtoTable::getWidth(std::vector& arrCells, bool isWidth) @@ -97,12 +98,101 @@ std::vector ProtoTable::getWidth(std::vector& arrCells, boo return gridWidth; } -std::vector ProtoTable::getHeight(std::vector > &oRows, bool isTop) +std::vector ProtoTable::getHeight(std::vector& arrCells, bool isHeight) { - for (auto& row : oRows) + std::map mapTopHeight; + for (auto* pCell : arrCells) { + if (!pCell) continue; + double top = pCell->m_rcChildAnchor.top; + double height = pCell->m_rcChildAnchor.bottom - top; + + // Here we search uniq top to answer: is it new row? + auto iter = mapTopHeight.find(top); + if (iter == mapTopHeight.end()) + { + mapTopHeight.insert(std::make_pair(top, height)); + } + // Here we check qestion: was it merged cell and now is it true height of row? + else if (iter->second > height) + { + mapTopHeight.erase(iter); + mapTopHeight.insert(std::make_pair(top, height)); + } } + + std::vector gridHeight; + double multip = isHeight ? 1587.6 : 1.0; + for (const auto& h : mapTopHeight) + { + double value = isHeight ? h.second : h.first; + gridHeight.push_back(int(value * multip)); + } + + return gridHeight; +} + +void ProtoTable::initProtoTable() +{ + const UINT countRow = m_arrTop.size(); + const UINT countCol = m_arrLeft.size(); + + m_table.clear(); + for (UINT cRow = 0; cRow < countRow; cRow++) + { + ProtoTableRow protoRow; + for (UINT cCol = 0; cCol < countCol; cCol++) + protoRow.push_back(TCell(nullptr, cRow, cCol, nullptr)); + + m_table.push_back(protoRow); + } +} + +bool ProtoTable::fillProtoTable(std::vector &arrCells, + std::vector& arrSpliters) +{ + if (m_table.empty() || m_arrTop.empty() || m_arrLeft.empty()) + return false; + + bool wasCellsFilled = fillCells(arrCells); + + return wasCellsFilled; +} + +bool ProtoTable::fillCells(std::vector &arrCells) +{ + const UINT countRow = m_arrTop.size(); + const UINT countCol = m_arrLeft.size(); + + for (auto* pCell : arrCells) + { + int left = pCell->m_rcChildAnchor.left; + int top = pCell->m_rcChildAnchor.top; + int right = pCell->m_rcChildAnchor.right; + int bottom = pCell->m_rcChildAnchor.bottom; + + UINT posRow = 0, posCol = 0; + for (; posRow < countRow; posRow++) + if (top == m_arrTop[posRow]) break; + for (; posCol < countCol; posCol++) + if (left == m_arrLeft[posCol]) break; + TCell* pParent = &m_table[posRow][posCol]; + + UINT posRightCol = 0, posBottomRow = 0; + for (; posBottomRow < countRow; posBottomRow++) + if (bottom == m_arrTop[posBottomRow]) break; + for (; posRightCol < countCol; posRightCol++) + if (right == m_arrLeft[posRightCol]) break; + + for (UINT cRow = posRow; cRow < posBottomRow; cRow++) + for (UINT cCol = posCol; cCol < posRightCol; cCol++) + m_table[cRow][cCol].setPParent(pParent); + pParent->setPParent(nullptr); + pParent->setPShape(pCell); + } + + return true; } std::vector > ProtoTable::getRows(std::vector &arrCells) @@ -125,6 +215,11 @@ std::vector > ProtoTable::getRows(std::vector &tblGrid, std::vector& arrCells) { - auto grid = getWidth(arrCells); - for (const auto& w : grid) - { - PPTX::Logic::TableCol tc; - tc.Width = w; - tblGrid.push_back(tc); - } + // auto grid = getWidth(arrCells); + // for (const auto& w : grid) + // { + // PPTX::Logic::TableCol tc; + // tc.Width = w; + // tblGrid.push_back(tc); + // } } void TableWriter::prepareShapes(std::vector &arrCells, std::vector &arrSpliters) @@ -160,50 +255,36 @@ void TableWriter::prepareShapes(std::vector &arrCells, std::vec } } -ptrProtoTable TableWriter::createProtoTable(std::vector &arrCells) -{ +//int TableWriter::getTRHeight(const ProtoTableRow& row) +//{ +// const TCell* pCell = nullptr; +// for (const auto& cell : row) +// if (cell.parentDirection() == TCell::none) +// { +// pCell = &cell; +// break; +// } - return pProtoTable; -} - -int TableWriter::getTRHeight(const ProtoTableRow& row) -{ - const TCell* pCell = nullptr; - for (const auto& cell : row) - if (cell.parentDirection() == TCell::none) - { - pCell = &cell; - break; - } - - return pCell ? pCell->getHeight() : 0; -} +// return pCell ? pCell->getHeight() : 0; +//} void TableWriter::FillRow(PPTX::Logic::TableRow &oRow, ProtoTableRow& arrCells) { if (arrCells.empty()) return; - oRow.Height = getTRHeight(arrCells); - for (auto& protoCell : arrCells) - { - PPTX::Logic::TableCell cell; - protoCell.FillTc(cell); - oRow.Cells.push_back(cell); - } + // oRow.Height = getTRHeight(arrCells); + // for (auto& protoCell : arrCells) + // { + // PPTX::Logic::TableCell cell; + // protoCell.FillTc(cell); + // oRow.Cells.push_back(cell); + // } } TCell::TCell(CShapeElement *pShape, int row, int col, TCell *pParent) : m_pShape(pShape), m_row(row), m_col(col), m_pParent(pParent), m_parentDirection(none) { - if (m_pParent) - { - if (m_pParent->m_col == m_col && m_pParent->m_row != m_row) - m_parentDirection = vert; - else if (m_pParent->m_col != m_col && m_pParent->m_row == m_row) - m_parentDirection = horz; - else - m_parentDirection = hove; - } + setParentDirection(); } void TCell::setArrBorders(const std::vector &arrBorders) @@ -235,48 +316,77 @@ int TCell::getHeight() const return int(height * multip); } +void TCell::setPParent(TCell *pParent) +{ + m_pParent = pParent; + setParentDirection(); +} + void TCell::FillMergeDirection(PPTX::Logic::TableCell &oTc) { oTc.HMerge = parentDirection() & horz; oTc.VMerge = parentDirection() & vert; } - - -ProtoTable::ProtoTable(std::vector &arrCells) +void TCell::setParentDirection() +{ + if (m_pParent) + { + // Todo rewrite it + if (m_pParent->m_col == m_col && m_pParent->m_row != m_row) + m_parentDirection = vert; + else if (m_pParent->m_col != m_col && m_pParent->m_row == m_row) + m_parentDirection = horz; + else + m_parentDirection = hove; + } +} + +void TCell::setPShape(CShapeElement *pShape) +{ + m_pShape = pShape; + m_parentDirection = none; +} + + + +ProtoTable::ProtoTable(std::vector &arrCells, + std::vector& arrSpliters) { - auto arrRows = getRows(arrCells); m_arrLeft = getWidth(arrCells, false); - m_arrTop + m_arrTop = getHeight(arrCells, false); + initProtoTable(); + fillProtoTable(arrCells, arrSpliters); + auto cellIter = arrCells.begin(); - const unsigned countRows = arrRows.size(); - const unsigned countCols = gridWidth.size(); + // const unsigned countRows = arrRows.size(); + // const unsigned countCols = gridWidth.size(); - for (unsigned cRow = 0; cRow < countRows; cRow++) - { - m_table.push_back(std::vector()); - std::vector& row = m_table.back(); + // for (unsigned cRow = 0; cRow < countRows; cRow++) + // { + // m_table.push_back(std::vector()); + // std::vector& row = m_table.back(); - int top = arrRows[cRow].front()->m_rcChildAnchor.top; - for (unsigned cCol = 0; cCol < countCols; cCol++) - { - int left = gridWidth[cCol]; + // int top = arrRows[cRow].front()->m_rcChildAnchor.top; + // for (unsigned cCol = 0; cCol < countCols; cCol++) + // { + // int left = gridWidth[cCol]; - CShapeElement* current = (*cellIter); - if (current && - current->m_rcChildAnchor.top == top && - current->m_rcChildAnchor.left == left) - { - row.push_back(TCell(current, cRow, cCol)); - cellIter++; - } else - { - TCell* pParent = FindCellParent(pProtoTable, cRow, cCol); - row.push_back(TCell(nullptr, cRow, cCol, pParent)); - } + // CShapeElement* current = (*cellIter); + // if (current && + // current->m_rcChildAnchor.top == top && + // current->m_rcChildAnchor.left == left) + // { + // row.push_back(TCell(current, cRow, cCol)); + // cellIter++; + // } else + // { + // TCell* pParent = FindCellParent(pProtoTable, cRow, cCol); + // row.push_back(TCell(nullptr, cRow, cCol, pParent)); + // } - } - } + // } + // } } diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h index 39e19d88c9..4660ba5697 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h @@ -54,8 +54,12 @@ public: eMergeDirection parentDirection() const; int getHeight()const; + void setPParent(TCell *pParent); + void setPShape(CShapeElement *pShape); + private: void FillMergeDirection(PPTX::Logic::TableCell& oTc); + void setParentDirection(); private: CShapeElement* m_pShape; @@ -74,24 +78,33 @@ private: typedef std::vector ProtoTableRow; +typedef std::vector MProtoTable; + class ProtoTable { public: - ProtoTable(std::vector &arrCells); - static int getRowHight(ProtoTableRow& oTR); + ProtoTable(std::vector &arrCells, + std::vector& arrSpliters); - std::vector m_table; + + static int getRowHight(ProtoTableRow& oTR); + static std::vector getWidth(std::vector &arrCells, bool isWidth = true); + static std::vector getHeight(std::vector &arrCells, bool isHeight = true); + MProtoTable getTable() const; private: - std::vector getWidth(std::vector &arrCells, bool isWidth = true); - std::vector getHeight(std::vector >& oRows, bool isTop = true); + void initProtoTable(); + bool fillProtoTable(std::vector &arrCells, std::vector &arrSpliters); + bool fillCells(std::vector &arrCells); + void fillBorders(std::vector &arrSpliters); std::vector > - getRows(std::vector &arrCells); + getRows(std::vector &arrCells); private: std::vector m_arrLeft; std::vector m_arrTop; + MProtoTable m_table; }; class TableWriter @@ -116,5 +129,6 @@ private: private: CTableElement *m_pTableElement; + nullable m_nPTable; }; } From 1e5819f9f9f958b5eafcaa0d17fb0f7953c397a1 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Wed, 9 Jun 2021 16:26:41 +0300 Subject: [PATCH 11/84] add merging --- .../PPTFormatLib/PPTXWriter/TableWriter.cpp | 128 ++++++++---------- .../PPTFormatLib/PPTXWriter/TableWriter.h | 9 +- 2 files changed, 64 insertions(+), 73 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp index d8a628ffdd..cde16b7044 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp @@ -55,13 +55,16 @@ void TableWriter::FillTable(PPTX::Logic::Table &oTable) m_nPTable = new ProtoTable(arrCells, arrSpliters); FillTblGrid(oTable.TableCols , arrCells); - // auto arrRows = createProtoTable(arrCells); - // for (auto& row : *arrRows) - // { - // PPTX::Logic::TableRow tr; - // FillRow(tr, row); - // oTable.TableRows.push_back(tr); - // } + + auto protoTable = m_nPTable->getTable(); + auto arrHeight = ProtoTable::getHeight(arrCells); + for (UINT cRow = 0; cRow < protoTable.size(); cRow++) + { + PPTX::Logic::TableRow tr; + FillRow(tr, protoTable[cRow]); + tr.Height = arrHeight[cRow]; + oTable.TableRows.push_back(tr); + } } std::vector ProtoTable::getWidth(std::vector& arrCells, bool isWidth) @@ -187,9 +190,21 @@ bool ProtoTable::fillCells(std::vector &arrCells) for (UINT cRow = posRow; cRow < posBottomRow; cRow++) for (UINT cCol = posCol; cCol < posRightCol; cCol++) - m_table[cRow][cCol].setPParent(pParent); + { + auto& tCell = m_table[cRow][cCol]; + tCell.setPParent(pParent); + + if (posCol == cCol) + tCell.setGridSpan(posRightCol - cCol); + + if (posRow == cRow) + tCell.setRowSpan(posBottomRow - cRow); + } pParent->setPParent(nullptr); pParent->setPShape(pCell); + +// pParent->setGridSpan(posRightCol - posCol); +// pParent->setRowSpan(posBottomRow - posRow); } return true; @@ -229,13 +244,13 @@ void TableWriter::FillTblPr(PPTX::Logic::TableProperties &oTblPr) void TableWriter::FillTblGrid(std::vector &tblGrid, std::vector& arrCells) { - // auto grid = getWidth(arrCells); - // for (const auto& w : grid) - // { - // PPTX::Logic::TableCol tc; - // tc.Width = w; - // tblGrid.push_back(tc); - // } + auto grid = ProtoTable::getWidth(arrCells); + for (const auto& w : grid) + { + PPTX::Logic::TableCol tc; + tc.Width = w; + tblGrid.push_back(tc); + } } void TableWriter::prepareShapes(std::vector &arrCells, std::vector &arrSpliters) @@ -255,34 +270,21 @@ void TableWriter::prepareShapes(std::vector &arrCells, std::vec } } -//int TableWriter::getTRHeight(const ProtoTableRow& row) -//{ -// const TCell* pCell = nullptr; -// for (const auto& cell : row) -// if (cell.parentDirection() == TCell::none) -// { -// pCell = &cell; -// break; -// } - -// return pCell ? pCell->getHeight() : 0; -//} - void TableWriter::FillRow(PPTX::Logic::TableRow &oRow, ProtoTableRow& arrCells) { if (arrCells.empty()) return; - // oRow.Height = getTRHeight(arrCells); - // for (auto& protoCell : arrCells) - // { - // PPTX::Logic::TableCell cell; - // protoCell.FillTc(cell); - // oRow.Cells.push_back(cell); - // } + for (auto& protoCell : arrCells) + { + PPTX::Logic::TableCell cell; + protoCell.FillTc(cell); + oRow.Cells.push_back(cell); + } } TCell::TCell(CShapeElement *pShape, int row, int col, TCell *pParent) : - m_pShape(pShape), m_row(row), m_col(col), m_pParent(pParent), m_parentDirection(none) + m_pShape(pShape), m_row(row), m_col(col), m_rowSpan(1), m_gridSpan(1), + m_pParent(pParent), m_parentDirection(none) { setParentDirection(); } @@ -294,12 +296,16 @@ void TCell::setArrBorders(const std::vector &arrBorders) void TCell::FillTc(PPTX::Logic::TableCell &oTc) { + if (m_gridSpan > 1) + oTc.GridSpan = m_gridSpan; + if (m_rowSpan > 1) + oTc.RowSpan = m_rowSpan; + if (m_pParent) { FillMergeDirection(oTc); return; } - } TCell::eMergeDirection TCell::parentDirection() const @@ -324,8 +330,10 @@ void TCell::setPParent(TCell *pParent) void TCell::FillMergeDirection(PPTX::Logic::TableCell &oTc) { - oTc.HMerge = parentDirection() & horz; - oTc.VMerge = parentDirection() & vert; + if (parentDirection() & horz) + oTc.HMerge = true; + if (parentDirection() & vert) + oTc.VMerge = true; } void TCell::setParentDirection() @@ -342,6 +350,16 @@ void TCell::setParentDirection() } } +void TCell::setGridSpan(int gridSpan) +{ + m_gridSpan = gridSpan; +} + +void TCell::setRowSpan(int rowSpan) +{ + m_rowSpan = rowSpan; +} + void TCell::setPShape(CShapeElement *pShape) { m_pShape = pShape; @@ -357,36 +375,4 @@ ProtoTable::ProtoTable(std::vector &arrCells, m_arrTop = getHeight(arrCells, false); initProtoTable(); fillProtoTable(arrCells, arrSpliters); - - auto cellIter = arrCells.begin(); - - // const unsigned countRows = arrRows.size(); - // const unsigned countCols = gridWidth.size(); - - // for (unsigned cRow = 0; cRow < countRows; cRow++) - // { - // m_table.push_back(std::vector()); - // std::vector& row = m_table.back(); - - // int top = arrRows[cRow].front()->m_rcChildAnchor.top; - // for (unsigned cCol = 0; cCol < countCols; cCol++) - // { - // int left = gridWidth[cCol]; - - // CShapeElement* current = (*cellIter); - // if (current && - // current->m_rcChildAnchor.top == top && - // current->m_rcChildAnchor.left == left) - // { - // row.push_back(TCell(current, cRow, cCol)); - // cellIter++; - // } else - // { - // TCell* pParent = FindCellParent(pProtoTable, cRow, cCol); - // row.push_back(TCell(nullptr, cRow, cCol, pParent)); - // } - - // } - // } - } diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h index 4660ba5697..350b25bf0c 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h @@ -57,6 +57,10 @@ public: void setPParent(TCell *pParent); void setPShape(CShapeElement *pShape); + void setRowSpan(int rowSpan); + + void setGridSpan(int gridSpan); + private: void FillMergeDirection(PPTX::Logic::TableCell& oTc); void setParentDirection(); @@ -71,6 +75,9 @@ private: // Proto table's coord int m_row, m_col; + int m_rowSpan; + int m_gridSpan; + // Parent TCell* m_pParent; eMergeDirection m_parentDirection; @@ -87,8 +94,6 @@ public: ProtoTable(std::vector &arrCells, std::vector& arrSpliters); - - static int getRowHight(ProtoTableRow& oTR); static std::vector getWidth(std::vector &arrCells, bool isWidth = true); static std::vector getHeight(std::vector &arrCells, bool isHeight = true); MProtoTable getTable() const; From 12789ab7f6ac8ce3a6f38d20f3b6632d0ff4e0c8 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Wed, 9 Jun 2021 17:19:09 +0300 Subject: [PATCH 12/84] empty table was converted --- .../PPTFormatLib/PPTXWriter/TableWriter.cpp | 23 +++++++++++++++++-- .../PPTFormatLib/PPTXWriter/TableWriter.h | 2 ++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp index cde16b7044..7b8c9ae1c4 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp @@ -27,15 +27,16 @@ void TableWriter::FillNvGraphicFramePr(PPTX::Logic::NvGraphicFramePr& oNvGFPr) oNvGFPr.cNvPr.name = m_pTableElement->m_sName; // not works in full - // graphicFrameLocks + oNvGFPr.cNvGraphicFramePr.noGrp = true; PPTX::Logic::Ext ext; - ext.uri = L"{D42A27DB-BD31-4B8C-83A1-F6EECF244321}"; + ext.uri = L"{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}"; oNvGFPr.nvPr.extLst.push_back(ext); } void TableWriter::FillXfrm(PPTX::Logic::Xfrm &oXFRM) { + oXFRM.m_ns = L"p"; double multip1 = m_pTableElement->m_bAnchorEnabled ? 1587.6 : 1; double multip2 = m_pTableElement->m_bAnchorEnabled ? 1273.0 : 1; oXFRM.offX = int(m_pTableElement->m_rcAnchor.left * multip1); @@ -301,6 +302,9 @@ void TCell::FillTc(PPTX::Logic::TableCell &oTc) if (m_rowSpan > 1) oTc.RowSpan = m_rowSpan; + oTc.txBody = new PPTX::Logic::TxBody(L"a:txBody"); + FillTxBody(oTc.txBody.get2()); + if (m_pParent) { FillMergeDirection(oTc); @@ -355,6 +359,21 @@ void TCell::setGridSpan(int gridSpan) m_gridSpan = gridSpan; } +void TCell::FillTxBody(PPTX::Logic::TxBody &oTxBody) +{ + oTxBody.bodyPr = new PPTX::Logic::BodyPr; + oTxBody.lstStyle = new PPTX::Logic::TextListStyle; +// if (m_pShape == nullptr) +// { + PPTX::Logic::Paragraph p; + p.endParaRPr = new PPTX::Logic::RunProperties; + p.endParaRPr->m_name = L"a:endParaRPr"; + p.endParaRPr->lang = L"en-US"; + + oTxBody.Paragrs.push_back(p); +// } +} + void TCell::setRowSpan(int rowSpan) { m_rowSpan = rowSpan; diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h index 350b25bf0c..463db42d1e 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h @@ -62,6 +62,8 @@ public: void setGridSpan(int gridSpan); private: + void FillTxBody(PPTX::Logic::TxBody &oTxBody); + void FillMergeDirection(PPTX::Logic::TableCell& oTc); void setParentDirection(); From 89bbbb0aac07c5a38f88294c955bde6b1b8a1eaf Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Wed, 9 Jun 2021 18:38:15 +0300 Subject: [PATCH 13/84] start new class for table text --- .../PPTFormatLib/Linux/PPTFormatLib.pro | 2 + .../PPTFormatLib/PPTXWriter/TableWriter.cpp | 16 ++--- .../PPTXWriter/TxBodyConverter.cpp | 41 +++++++++++++ .../PPTFormatLib/PPTXWriter/TxBodyConverter.h | 58 +++++++++++++++++++ 4 files changed, 106 insertions(+), 11 deletions(-) create mode 100644 ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp create mode 100644 ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h diff --git a/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro b/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro index f66778cfbf..e7bafc26a6 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro +++ b/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro @@ -361,6 +361,7 @@ HEADERS += \ ../PPTFormatLib.h \ ../PPTXWriter/Animation.h \ ../PPTXWriter/TableWriter.h \ + ../PPTXWriter/TxBodyConverter.h \ ../Reader/ClassesAtom.h \ ../Reader/CommonZLib.h \ ../Reader/PPTDocumentInfo.h \ @@ -653,5 +654,6 @@ SOURCES += \ ../../../Common/3dParty/pole/pole.cpp \ ../PPTXWriter/Animation.cpp \ ../PPTXWriter/TableWriter.cpp \ + ../PPTXWriter/TxBodyConverter.cpp \ ../Records/Animations/TimeVariant.cpp diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp index 7b8c9ae1c4..e40e7b1eab 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp @@ -1,4 +1,5 @@ #include "TableWriter.h" +#include "TxBodyConverter.h" TableWriter::TableWriter(CTableElement *pTableElement) : m_pTableElement(pTableElement) @@ -304,6 +305,8 @@ void TCell::FillTc(PPTX::Logic::TableCell &oTc) oTc.txBody = new PPTX::Logic::TxBody(L"a:txBody"); FillTxBody(oTc.txBody.get2()); + oTc.CellProperties = new PPTX::Logic::TableCellProperties; + // ToDo FillTableCellProperties(oTc.CellProperties.get2()) if (m_pParent) { @@ -361,17 +364,8 @@ void TCell::setGridSpan(int gridSpan) void TCell::FillTxBody(PPTX::Logic::TxBody &oTxBody) { - oTxBody.bodyPr = new PPTX::Logic::BodyPr; - oTxBody.lstStyle = new PPTX::Logic::TextListStyle; -// if (m_pShape == nullptr) -// { - PPTX::Logic::Paragraph p; - p.endParaRPr = new PPTX::Logic::RunProperties; - p.endParaRPr->m_name = L"a:endParaRPr"; - p.endParaRPr->lang = L"en-US"; - - oTxBody.Paragrs.push_back(p); -// } + TxBodyConverter txBodyConverter(&m_pShape->m_pShape->m_oText, TxBodyConverter::table); + txBodyConverter.FillTxBody(oTxBody); } void TCell::setRowSpan(int rowSpan) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp new file mode 100644 index 0000000000..c5693b96b4 --- /dev/null +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp @@ -0,0 +1,41 @@ +#include "TxBodyConverter.h" + +using namespace PPT_FORMAT; + +TxBodyConverter::TxBodyConverter(CTextAttributesEx *pText, TxBodyConverter::eTxType txType) : + m_pText(pText), m_txType(txType) +{ + +} + +void TxBodyConverter::FillTxBody(PPTX::Logic::TxBody &oTxBody) +{ + if (m_pText == nullptr) + return; + switch (m_txType) + { + case shape: ConvertShapeTxBody(oTxBody); break; + case table: ConvertTableTxBody(oTxBody); break; + } + +} + +void TxBodyConverter::ConvertTableTxBody(PPTX::Logic::TxBody &oTxBody) +{ + oTxBody.bodyPr = new PPTX::Logic::BodyPr; + oTxBody.lstStyle = new PPTX::Logic::TextListStyle; +// if (m_pShape == nullptr) +// { + PPTX::Logic::Paragraph p; + p.endParaRPr = new PPTX::Logic::RunProperties; + p.endParaRPr->m_name = L"a:endParaRPr"; + p.endParaRPr->lang = L"en-US"; + + oTxBody.Paragrs.push_back(p); +// } +} + +void TxBodyConverter::ConvertShapeTxBody(PPTX::Logic::TxBody &oTxBody) +{ + +} diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h new file mode 100644 index 0000000000..d23da8a39e --- /dev/null +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h @@ -0,0 +1,58 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ +#pragma once + +#include "../../../ASCOfficePPTXFile/Editor/Drawing/TextAttributesEx.h" +#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/TxBody.h" + +namespace PPT_FORMAT +{ +class TxBodyConverter +{ +public: + enum eTxType + { + shape, + table + }; + TxBodyConverter(CTextAttributesEx* pText, eTxType txType); + + void FillTxBody(PPTX::Logic::TxBody& oTxBody); +private: + void ConvertTableTxBody(PPTX::Logic::TxBody& oTxBody); + void ConvertShapeTxBody(PPTX::Logic::TxBody& oTxBody); + +private: + CTextAttributesEx* m_pText; + eTxType m_txType; +}; +} From 5a10bb897e59e4a0d13358d35acd58f8bad11ac6 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Thu, 10 Jun 2021 18:32:25 +0300 Subject: [PATCH 14/84] convert text but sometimes it's uncorrect --- .../PPTFormatLib/PPTXWriter/TableWriter.cpp | 5 +- .../PPTXWriter/TxBodyConverter.cpp | 179 +++++++++++++++++- .../PPTFormatLib/PPTXWriter/TxBodyConverter.h | 8 + 3 files changed, 183 insertions(+), 9 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp index e40e7b1eab..18980e32bf 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp @@ -239,7 +239,7 @@ MProtoTable ProtoTable::getTable() const void TableWriter::FillTblPr(PPTX::Logic::TableProperties &oTblPr) { - oTblPr.TableStyleId = L"{F5AB1C69-6EDB-4FF4-983F-18BD219EF322}"; + oTblPr.TableStyleId = L"{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}"; oTblPr.FirstRow = true; oTblPr.BandRow = true; } @@ -364,6 +364,9 @@ void TCell::setGridSpan(int gridSpan) void TCell::FillTxBody(PPTX::Logic::TxBody &oTxBody) { + if (m_pShape == nullptr) + return; + TxBodyConverter txBodyConverter(&m_pShape->m_pShape->m_oText, TxBodyConverter::table); txBodyConverter.FillTxBody(oTxBody); } diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp index c5693b96b4..cb52378262 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp @@ -1,4 +1,5 @@ #include "TxBodyConverter.h" +#include "../../../Common/MS-LCID.h" using namespace PPT_FORMAT; @@ -24,18 +25,180 @@ void TxBodyConverter::ConvertTableTxBody(PPTX::Logic::TxBody &oTxBody) { oTxBody.bodyPr = new PPTX::Logic::BodyPr; oTxBody.lstStyle = new PPTX::Logic::TextListStyle; -// if (m_pShape == nullptr) -// { - PPTX::Logic::Paragraph p; - p.endParaRPr = new PPTX::Logic::RunProperties; - p.endParaRPr->m_name = L"a:endParaRPr"; - p.endParaRPr->lang = L"en-US"; + oTxBody.m_name = L"a:txBody"; + + FillParagraphs(oTxBody.Paragrs, m_pText->m_arParagraphs); - oTxBody.Paragrs.push_back(p); -// } } void TxBodyConverter::ConvertShapeTxBody(PPTX::Logic::TxBody &oTxBody) { } + +void TxBodyConverter::FillParagraphs(std::vector &arrP, std::vector &arrParagraphs) +{ + if (m_pText == nullptr) + { + PPTX::Logic::Paragraph p; + p.endParaRPr = new PPTX::Logic::RunProperties; + p.endParaRPr->m_name = L"a:endParaRPr"; + p.endParaRPr->lang = L"en-US"; + + arrP.push_back(p); + return; + } + + for (auto& paragraph : arrParagraphs) + { + PPTX::Logic::Paragraph p; + FillParagraph(p, paragraph); + arrP.push_back(p); + } +} + +void TxBodyConverter::FillParagraph(PPTX::Logic::Paragraph &p, CParagraph ¶graph) +{ + for (auto& span : paragraph.m_arSpans) + { + PPTX::Logic::RunElem runElem; + auto pRun = new PPTX::Logic::Run(); + FillRun(*pRun, span); + runElem.InitRun(pRun); + + p.RunElems.push_back(runElem); + } + + p.pPr = new PPTX::Logic::TextParagraphPr; + FillPPr(p.pPr.get2(), paragraph.m_oPFRun); + + p.endParaRPr = new PPTX::Logic::RunProperties; + FillEndParaRPr(p.endParaRPr.get2(), paragraph.m_oPFRun); +} + +void TxBodyConverter::FillRun(PPTX::Logic::Run &oRun, CSpan& oSpan) +{ + oRun.SetText(oSpan.m_strText); + + oRun.rPr = new PPTX::Logic::RunProperties; + FillRPr(oRun.rPr.get2(), oSpan.m_oRun); +} + +void TxBodyConverter::FillEndParaRPr(PPTX::Logic::RunProperties &oEndPr, CTextPFRun &oPFRun) +{ + oEndPr.m_name = L"a:endParaRPr"; + oEndPr.lang = L"en-US"; + oEndPr.dirty = true; + +// if ((oPFRun.Size.is_init()) && (oPFRun.Size.get() > 0) && (oCFRun.Size.get() < 4001)) +// { +// oEndPr.sz = int(100 * oPFRun.Size.get()); +// } else +// { +// oEndPr.sz = 18; +// } +// if (oCFRun.BaseLineOffset.is_init()) +// { +// oEndPr.baseline = int(1000 * oCFRun.BaseLineOffset.get()); +// } +// if (oCFRun.FontBold.is_init()) +// { +// oEndPr.b = oCFRun.FontBold.get(); +// } +// if (oCFRun.FontItalic.is_init()) +// { +// oEndPr.i = oCFRun.FontItalic.get(); +// } +// if (oCFRun.FontUnderline.is_init()) +// { +// oEndPr.u = new PPTX::Limit::TextUnderline; +// oEndPr.u->set(oCFRun.FontUnderline.get() ? L"sng" : L"none"); +// } +// if (oCFRun.Language.is_init()) +// { +// std::wstring str_lang = msLCID2wstring(oCFRun.Language.get()); + +// if (str_lang.length() > 0) +// oEndPr.lang = msLCID2wstring(oCFRun.Language.get()); + // } +} + +void TxBodyConverter::FillPPr(PPTX::Logic::TextParagraphPr &oPPr, CTextPFRun &oPFRun) +{ + int leftMargin = 0; + if (oPFRun.leftMargin.is_init()) + { + leftMargin = oPFRun.leftMargin.get(); + oPPr.marL = leftMargin; + oPPr.indent = -leftMargin; + } + + if (oPFRun.indent.is_init()) + oPPr.indent = oPFRun.indent.get() - leftMargin; + + if (oPFRun.bulletFontProperties.is_init()) + { + auto pBuFont = new PPTX::Logic::TextFont; + pBuFont->typeface = oPFRun.bulletFontProperties->Name; + + if ( oPFRun.bulletFontProperties->PitchFamily > 0) + { + pBuFont->pitchFamily = std::to_wstring(oPFRun.bulletFontProperties->PitchFamily); + } + if ( oPFRun.bulletFontProperties->Charset > 0) + { + pBuFont->charset = std::to_wstring((char)oPFRun.bulletFontProperties->Charset); + } + oPPr.buTypeface.SetParentPointer(pBuFont); + } + + + if (oPFRun.bulletAutoNum.is_init()) + { + auto pBuAutoNum = new PPTX::Logic::BuAutoNum; + oPPr.ParagraphBullet.m_Bullet.reset(pBuAutoNum); + if (oPFRun.bulletAutoNum->startAt.is_init() && oPFRun.bulletAutoNum->startAt.get() != 1) + pBuAutoNum->startAt = oPFRun.bulletAutoNum->startAt.get(); + if (oPFRun.bulletAutoNum->type.is_init()) + pBuAutoNum->type = oPFRun.bulletAutoNum->type.get(); + } +} + +void TxBodyConverter::FillRPr(PPTX::Logic::RunProperties &oRPr, CTextCFRun &oCFRun) +{ + if ((oCFRun.Size.is_init()) && (oCFRun.Size.get() > 0) && (oCFRun.Size.get() < 4001)) + { + oRPr.sz = int(100 * oCFRun.Size.get()); + } else + { + oRPr.sz = 1800; + } + if (oCFRun.BaseLineOffset.is_init()) + { + oRPr.baseline = int(1000 * oCFRun.BaseLineOffset.get()); + } + if (oCFRun.FontBold.is_init()) + { + oRPr.b = oCFRun.FontBold.get(); + } + else + { + oRPr.b = false; + } + if (oCFRun.FontItalic.is_init()) + { + oRPr.i = oCFRun.FontItalic.get(); + } + if (oCFRun.FontUnderline.is_init()) + { + oRPr.u = new PPTX::Limit::TextUnderline; + oRPr.u->set(oCFRun.FontUnderline.get() ? L"sng" : L"none"); + } + if (oCFRun.Language.is_init()) + { + std::wstring str_lang = msLCID2wstring(oCFRun.Language.get()); + + if (str_lang.length() > 0) + oRPr.lang = msLCID2wstring(oCFRun.Language.get()); + } +} diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h index d23da8a39e..3aeb779265 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h @@ -51,6 +51,14 @@ private: void ConvertTableTxBody(PPTX::Logic::TxBody& oTxBody); void ConvertShapeTxBody(PPTX::Logic::TxBody& oTxBody); +private: + void FillParagraphs(std::vector& arrP, std::vector& arrParagraphs); + void FillParagraph(PPTX::Logic::Paragraph& p, CParagraph& paragraph); + void FillRun(PPTX::Logic::Run& oRun, CSpan &oSpan); + void FillEndParaRPr(PPTX::Logic::RunProperties& oEndPr, CTextPFRun& oPFRun); + void FillPPr(PPTX::Logic::TextParagraphPr& oPPr, CTextPFRun& oPFRun); + void FillRPr(PPTX::Logic::RunProperties& oRPr, CTextCFRun& oCFRun); + private: CTextAttributesEx* m_pText; eTxType m_txType; From b2cd5f0211fe4f802093fcf01cd4e8979132d700 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Fri, 11 Jun 2021 16:07:06 +0300 Subject: [PATCH 15/84] add base styles fot text --- .../PPTXWriter/TxBodyConverter.cpp | 106 +++++++++++++----- .../PPTFormatLib/PPTXWriter/TxBodyConverter.h | 5 +- .../PPTXFormat/WrapperWritingElement.h | 3 +- 3 files changed, 83 insertions(+), 31 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp index cb52378262..60d55c77db 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp @@ -90,36 +90,36 @@ void TxBodyConverter::FillEndParaRPr(PPTX::Logic::RunProperties &oEndPr, CTextPF oEndPr.lang = L"en-US"; oEndPr.dirty = true; -// if ((oPFRun.Size.is_init()) && (oPFRun.Size.get() > 0) && (oCFRun.Size.get() < 4001)) -// { -// oEndPr.sz = int(100 * oPFRun.Size.get()); -// } else -// { -// oEndPr.sz = 18; -// } -// if (oCFRun.BaseLineOffset.is_init()) -// { -// oEndPr.baseline = int(1000 * oCFRun.BaseLineOffset.get()); -// } -// if (oCFRun.FontBold.is_init()) -// { -// oEndPr.b = oCFRun.FontBold.get(); -// } -// if (oCFRun.FontItalic.is_init()) -// { -// oEndPr.i = oCFRun.FontItalic.get(); -// } -// if (oCFRun.FontUnderline.is_init()) -// { -// oEndPr.u = new PPTX::Limit::TextUnderline; -// oEndPr.u->set(oCFRun.FontUnderline.get() ? L"sng" : L"none"); -// } -// if (oCFRun.Language.is_init()) -// { -// std::wstring str_lang = msLCID2wstring(oCFRun.Language.get()); + // if ((oPFRun.Size.is_init()) && (oPFRun.Size.get() > 0) && (oCFRun.Size.get() < 4001)) + // { + // oEndPr.sz = int(100 * oPFRun.Size.get()); + // } else + // { + // oEndPr.sz = 18; + // } + // if (oCFRun.BaseLineOffset.is_init()) + // { + // oEndPr.baseline = int(1000 * oCFRun.BaseLineOffset.get()); + // } + // if (oCFRun.FontBold.is_init()) + // { + // oEndPr.b = oCFRun.FontBold.get(); + // } + // if (oCFRun.FontItalic.is_init()) + // { + // oEndPr.i = oCFRun.FontItalic.get(); + // } + // if (oCFRun.FontUnderline.is_init()) + // { + // oEndPr.u = new PPTX::Limit::TextUnderline; + // oEndPr.u->set(oCFRun.FontUnderline.get() ? L"sng" : L"none"); + // } + // if (oCFRun.Language.is_init()) + // { + // std::wstring str_lang = msLCID2wstring(oCFRun.Language.get()); -// if (str_lang.length() > 0) -// oEndPr.lang = msLCID2wstring(oCFRun.Language.get()); + // if (str_lang.length() > 0) + // oEndPr.lang = msLCID2wstring(oCFRun.Language.get()); // } } @@ -201,4 +201,52 @@ void TxBodyConverter::FillRPr(PPTX::Logic::RunProperties &oRPr, CTextCFRun &oCFR if (str_lang.length() > 0) oRPr.lang = msLCID2wstring(oCFRun.Language.get()); } + + FillEffectLst(oRPr.EffectList, oCFRun); + if (oCFRun.Color.is_init()) + FillSolidFill(oRPr.Fill, oCFRun.Color.get()); + + + if (oCFRun.font.font.is_init()) + { + oRPr.latin = new PPTX::Logic::TextFont; + FillLatin(oRPr.latin.get2(), oCFRun.font.font.get()); + } +} + +void TxBodyConverter::FillLatin(PPTX::Logic::TextFont &oLatin, CFontProperty &font) +{ + oLatin.typeface = font.Name; + oLatin.charset = std::to_wstring(font.Charset); + oLatin.pitchFamily = std::to_wstring(font.PitchFamily); + oLatin.m_name = L"a:latin"; +} + +void TxBodyConverter::FillCS(PPTX::Logic::TextFont &oCs, CFontProperties &font) +{ + // FillLatin(oCs, font); + oCs.m_name = L"a:cs"; +} + +void TxBodyConverter::FillEffectLst(PPTX::Logic::EffectProperties &oEList, CTextCFRun &oCFRun) +{ + if (oCFRun.FontShadow.is_init() && oCFRun.FontShadow.get()) + { + auto pELst = new PPTX::Logic::EffectLst; + pELst->outerShdw = new PPTX::Logic::OuterShdw; + pELst->outerShdw->blurRad = 38100; + pELst->outerShdw->dist = 38100; + pELst->outerShdw->dir = 2700000; + pELst->outerShdw->algn = new PPTX::Limit::RectAlign; + pELst->outerShdw->algn->set(L"tl"); + pELst->outerShdw->Color.SetRGBColor(0, 0, 0); + oEList.List.reset(pELst); + } +} + +void TxBodyConverter::FillSolidFill(PPTX::Logic::UniFill &oUF, CColor &oColor) +{ + auto pSolidFill = new PPTX::Logic::SolidFill; + pSolidFill->Color.SetRGBColor(oColor.GetR(), oColor.GetG(), oColor.GetB()); + oUF.Fill.reset(pSolidFill); } diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h index 3aeb779265..e34483d1e8 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h @@ -58,7 +58,10 @@ private: void FillEndParaRPr(PPTX::Logic::RunProperties& oEndPr, CTextPFRun& oPFRun); void FillPPr(PPTX::Logic::TextParagraphPr& oPPr, CTextPFRun& oPFRun); void FillRPr(PPTX::Logic::RunProperties& oRPr, CTextCFRun& oCFRun); - + void FillLatin(PPTX::Logic::TextFont& oLatin, CFontProperty &font); + void FillCS(PPTX::Logic::TextFont& oCs, CFontProperties& font); + void FillEffectLst(PPTX::Logic::EffectProperties &oEList, CTextCFRun& oCFRun); + void FillSolidFill(PPTX::Logic::UniFill& oUF, CColor& oColor); private: CTextAttributesEx* m_pText; eTxType m_txType; diff --git a/ASCOfficePPTXFile/PPTXFormat/WrapperWritingElement.h b/ASCOfficePPTXFile/PPTXFormat/WrapperWritingElement.h index 3c04772320..b06f516a57 100644 --- a/ASCOfficePPTXFile/PPTXFormat/WrapperWritingElement.h +++ b/ASCOfficePPTXFile/PPTXFormat/WrapperWritingElement.h @@ -78,7 +78,8 @@ namespace PPTX virtual void FillParentPointersForChilds(){} public: - virtual void SetParentPointer(const WrapperWritingElement* pParent) + virtual void + SetParentPointer(const WrapperWritingElement* pParent) { parentElement = pParent; parentFile = parentElement->parentFile; From 5dbc4b4d49d20e010816bb6d8f6798b560cd2084 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Fri, 11 Jun 2021 17:42:28 +0300 Subject: [PATCH 16/84] add cell's color --- .../PPTFormatLib/PPTXWriter/TableWriter.cpp | 14 ++++++++++++-- .../PPTFormatLib/PPTXWriter/TableWriter.h | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp index 18980e32bf..6d864a545d 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp @@ -305,14 +305,15 @@ void TCell::FillTc(PPTX::Logic::TableCell &oTc) oTc.txBody = new PPTX::Logic::TxBody(L"a:txBody"); FillTxBody(oTc.txBody.get2()); - oTc.CellProperties = new PPTX::Logic::TableCellProperties; - // ToDo FillTableCellProperties(oTc.CellProperties.get2()) if (m_pParent) { FillMergeDirection(oTc); return; } + + oTc.CellProperties = new PPTX::Logic::TableCellProperties; + FillTcPr(oTc.CellProperties.get2()); } TCell::eMergeDirection TCell::parentDirection() const @@ -371,6 +372,15 @@ void TCell::FillTxBody(PPTX::Logic::TxBody &oTxBody) txBodyConverter.FillTxBody(oTxBody); } +void TCell::FillTcPr(PPTX::Logic::TableCellProperties &oTcPr) +{ + auto pSolidFill = new PPTX::Logic::SolidFill; + auto& clr = m_pShape->m_oBrush.Color1; + + pSolidFill->Color.SetRGBColor(clr.GetR(), clr.GetG(), clr.GetB()); + oTcPr.Fill.Fill.reset(pSolidFill); +} + void TCell::setRowSpan(int rowSpan) { m_rowSpan = rowSpan; diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h index 463db42d1e..eff51ff60b 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h @@ -63,6 +63,7 @@ public: private: void FillTxBody(PPTX::Logic::TxBody &oTxBody); + void FillTcPr(PPTX::Logic::TableCellProperties& oTcPr); void FillMergeDirection(PPTX::Logic::TableCell& oTc); void setParentDirection(); From 0594d9decd46937d0d0c43c77d69ab623d3c8dda Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Wed, 16 Jun 2021 12:46:05 +0300 Subject: [PATCH 17/84] add border setter --- .../PPTFormatLib/PPTXWriter/TableWriter.cpp | 105 +++++++++++++++++- .../PPTFormatLib/PPTXWriter/TableWriter.h | 22 +++- 2 files changed, 117 insertions(+), 10 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp index 6d864a545d..a0af1c9c91 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp @@ -160,7 +160,8 @@ bool ProtoTable::fillProtoTable(std::vector &arrCells, if (m_table.empty() || m_arrTop.empty() || m_arrLeft.empty()) return false; - bool wasCellsFilled = fillCells(arrCells); + bool wasCellsFilled = fillCells(arrCells); + fillBorders(arrSpliters); return wasCellsFilled; } @@ -212,6 +213,95 @@ bool ProtoTable::fillCells(std::vector &arrCells) return true; } +void ProtoTable::fillBorders(std::vector &arrSpliters) +{ + for (auto* pBorder : arrSpliters) + { + int left = pBorder->m_rcChildAnchor.left; + int top = pBorder->m_rcChildAnchor.top; + int right = pBorder->m_rcChildAnchor.right; + int bottom = pBorder->m_rcChildAnchor.bottom; + + UINT posFirstTop, posFirstLeft; + UINT posLastTop, posLastLeft; + + findCellPos(top, left, posFirstTop, posFirstLeft); + findCellPos(bottom, right, posLastTop, posLastLeft); + if (!isDefaultBoard(pBorder)) + { + setBorders(posFirstTop, posFirstLeft, posLastTop, posLastLeft, pBorder); + } + } +} + +bool ProtoTable::findCellPos(const int top, const int left, UINT &posRow, UINT &posCol) +{ + const UINT countRow = m_arrTop.size(); + const UINT countCol = m_arrLeft.size(); + + for (posRow = 0; posRow < countRow; posRow++) + if (top == m_arrTop[posRow]) break; + for (posCol = 0; posCol < countCol; posCol++) + if (left == m_arrLeft[posCol]) break; + + return !(posRow == countRow || posCol == countCol); +} + +void ProtoTable::setBorders(const UINT posFRow, const UINT posFCol, const UINT posLRow, const UINT posLCol, CShapeElement* pBorder) +{ + + const UINT countRow = m_arrTop.size(); + const UINT countCol = m_arrLeft.size(); + + // lnTlToBr or lnBlToTr + if ((posFRow != posLRow) && (posFCol != posLCol)) + { + auto borPos = posFRow > posLRow ? TCell::lnTlToBr : TCell::lnBlToTr; + m_table[posFRow][posFCol].setBorder(borPos, pBorder); + return; + } + + // lnT or(and) lnB + if (posFCol != posLCol) + { + for (UINT i = posFCol; i < posLCol; i++) + { + if (posFRow < countRow) + m_table[posFRow][i].setBorder(TCell::lnT, pBorder); + if (posFRow > 0) + m_table[posFRow-1][i].setBorder(TCell::lnB, pBorder); + } + + return; + } + + // lnL or(and) lnR + if (posFRow != posLRow) + { + for (UINT i = posFRow; i < posLRow; i++) + { + if (posFCol < countCol) + m_table[i][posFCol].setBorder(TCell::lnL, pBorder); + if (posFCol > 0) + m_table[i][posFCol-1].setBorder(TCell::lnR, pBorder); + } + + return; + } + + return; +} + +bool ProtoTable::isDefaultBoard(const CShapeElement *pBorder) +{ + if (pBorder == nullptr) + return false; + + auto& color = pBorder->m_oPen.Color; + + return color.m_lSchemeIndex == 13; +} + std::vector > ProtoTable::getRows(std::vector &arrCells) { std::vector > arrRows; @@ -291,11 +381,6 @@ TCell::TCell(CShapeElement *pShape, int row, int col, TCell *pParent) : setParentDirection(); } -void TCell::setArrBorders(const std::vector &arrBorders) -{ - m_arrBorders = arrBorders; -} - void TCell::FillTc(PPTX::Logic::TableCell &oTc) { if (m_gridSpan > 1) @@ -316,6 +401,14 @@ void TCell::FillTc(PPTX::Logic::TableCell &oTc) FillTcPr(oTc.CellProperties.get2()); } +void TCell::setBorder(TCell::eBorderPossition borderPos, CShapeElement *pBorder) +{ + if (m_pShape) + m_mapBorders[borderPos] = pBorder; + else if (m_pParent) + m_pParent->setBorder(borderPos, pBorder); +} + TCell::eMergeDirection TCell::parentDirection() const { return m_parentDirection; diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h index eff51ff60b..f933716225 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h @@ -40,7 +40,6 @@ class TCell { public: TCell(CShapeElement *pShape, int row, int col, TCell* pParent = nullptr); - void setArrBorders(const std::vector &arrBorders); void FillTc(PPTX::Logic::TableCell &oTc); @@ -51,6 +50,17 @@ public: hove = (horz | vert) }; + enum eBorderPossition + { + lnL, + lnR, + lnT, + lnB, + lnTlToBr, + lnBlToTr + }; + void setBorder(eBorderPossition borderPos, CShapeElement *pBorder); + eMergeDirection parentDirection() const; int getHeight()const; @@ -71,9 +81,7 @@ private: private: CShapeElement* m_pShape; - // 0 - left, 1 - top, 2 - right, 3 - bottom, - // 4 - lnTlToBr, 5 - lnBlToTr - std::vector m_arrBorders; + std::map m_mapBorders; // Proto table's coord int m_row, m_col; @@ -106,6 +114,12 @@ private: bool fillProtoTable(std::vector &arrCells, std::vector &arrSpliters); bool fillCells(std::vector &arrCells); void fillBorders(std::vector &arrSpliters); + bool findCellPos(const int top, const int left, UINT& posRow, UINT& posCol); + std::list getParentCellFromTable(const UINT posFRow, const UINT posFCol, const UINT posLRow, const UINT posLCol); + void setBorders(const UINT posFRow, const UINT posFCol, const UINT posLRow, const UINT posLCol, CShapeElement *pBorder); + + bool isDefaultBoard(const CShapeElement *pBorder); + std::vector > getRows(std::vector &arrCells); From c2d4d4f9bdbe759dbe4f87315dc6ef8d90e967ef Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Wed, 16 Jun 2021 18:41:44 +0300 Subject: [PATCH 18/84] add border writer, but it format is broken --- .../PPTFormatLib/PPTXWriter/TableWriter.cpp | 79 ++++++++++++++++++- .../PPTFormatLib/PPTXWriter/TableWriter.h | 3 +- 2 files changed, 79 insertions(+), 3 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp index a0af1c9c91..b066358b9f 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp @@ -288,8 +288,6 @@ void ProtoTable::setBorders(const UINT posFRow, const UINT posFCol, const UINT p return; } - - return; } bool ProtoTable::isDefaultBoard(const CShapeElement *pBorder) @@ -459,7 +457,18 @@ void TCell::setGridSpan(int gridSpan) void TCell::FillTxBody(PPTX::Logic::TxBody &oTxBody) { if (m_pShape == nullptr) + { + PPTX::Logic::Paragraph p; + auto RPr = new PPTX::Logic::RunProperties; + RPr->lang = L"en-US"; + RPr->sz = 1800; + RPr->dirty = false; + RPr->m_name = L"a:endParaRPr"; + p.endParaRPr = RPr; + oTxBody.Paragrs.push_back(p); + return; + } TxBodyConverter txBodyConverter(&m_pShape->m_pShape->m_oText, TxBodyConverter::table); txBodyConverter.FillTxBody(oTxBody); @@ -472,6 +481,72 @@ void TCell::FillTcPr(PPTX::Logic::TableCellProperties &oTcPr) pSolidFill->Color.SetRGBColor(clr.GetR(), clr.GetG(), clr.GetB()); oTcPr.Fill.Fill.reset(pSolidFill); + + for (auto IterBorder : m_mapBorders) + { + auto pLn = new PPTX::Logic::Ln; + FillLn(*pLn, IterBorder.first, IterBorder.second); + switch (IterBorder.first) + { + case lnL: oTcPr.LnL = pLn; break; + case lnR: oTcPr.LnR = pLn; break; + case lnT: oTcPr.LnT = pLn; break; + case lnB: oTcPr.LnB = pLn; break; + case lnBlToTr: oTcPr.LnBlToTr = pLn; break; + case lnTlToBr: oTcPr.LnTlToBr = pLn; break; + } + } +} + +void TCell::FillLn(PPTX::Logic::Ln &Ln, TCell::eBorderPossition eBP, CShapeElement *pBorder) +{ + if (pBorder == nullptr) + return; + switch (eBP) + { + case lnL: Ln.m_name = L"lnL"; break; + case lnR: Ln.m_name = L"lnR"; break; + case lnT: Ln.m_name = L"lnT"; break; + case lnB: Ln.m_name = L"lnB"; break; + case lnBlToTr: Ln.m_name = L"lnBlToTr"; break; + case lnTlToBr: Ln.m_name = L"lnTlToBr"; break; + } + + auto& pen = pBorder->m_oPen; + Ln.w = pen.Size; + + auto pSolidFill = new PPTX::Logic::SolidFill; + auto& clr = pen.Color; + pSolidFill->Color.SetRGBColor(clr.GetR(), clr.GetG(), clr.GetB()); + pSolidFill->Color.Color->alpha = (unsigned char)pen.Alpha; + Ln.Fill.Fill.reset(pSolidFill); + + Ln.prstDash = new PPTX::Logic::PrstDash; + Ln.prstDash->val = new PPTX::Limit::PrstDashVal; + BYTE dash[] = {6,7,10,1,3,4,5}; + if (sizeof (dash) > pen.DashStyle) + Ln.prstDash->val->SetBYTECode(dash[pen.DashStyle]); + + // TODO? + Ln.cap = new PPTX::Limit::LineCap; + Ln.cmpd = new PPTX::Limit::CompoundLine; + Ln.algn = new PPTX::Limit::PenAlign; + + auto* pLineEnd = new PPTX::Logic::LineEnd; + pLineEnd->m_name = L"a:headEnd"; + pLineEnd->type = new PPTX::Limit::LineEndType; + pLineEnd->w = new PPTX::Limit::LineEndSize; + pLineEnd->len = new PPTX::Limit::LineEndSize; + Ln.headEnd = pLineEnd; + + pLineEnd = new PPTX::Logic::LineEnd; + pLineEnd->m_name = L"a:tailEnd"; + pLineEnd->type = new PPTX::Limit::LineEndType; + pLineEnd->w = new PPTX::Limit::LineEndSize; + pLineEnd->len = new PPTX::Limit::LineEndSize; + Ln.tailEnd = pLineEnd; + + Ln.Join.type = PPTX::Logic::eJoin::JoinRound; } void TCell::setRowSpan(int rowSpan) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h index f933716225..eb23d34c19 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h @@ -74,6 +74,7 @@ public: private: void FillTxBody(PPTX::Logic::TxBody &oTxBody); void FillTcPr(PPTX::Logic::TableCellProperties& oTcPr); + void FillLn(PPTX::Logic::Ln& Ln, eBorderPossition eBP, CShapeElement* pBorder); void FillMergeDirection(PPTX::Logic::TableCell& oTc); void setParentDirection(); @@ -81,7 +82,7 @@ private: private: CShapeElement* m_pShape; - std::map m_mapBorders; + std::map m_mapBorders; // Proto table's coord int m_row, m_col; From 30ab4a55d1b25f7bb06533ad8dfb44f95e7ed1aa Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Thu, 17 Jun 2021 17:06:15 +0300 Subject: [PATCH 19/84] add border writer --- .../PPTFormatLib/PPTXWriter/TableWriter.cpp | 37 ++++++++----------- .../PPTXWriter/TxBodyConverter.cpp | 8 ++-- .../PPTFormatLib/PPTXWriter/TxBodyConverter.h | 1 + 3 files changed, 20 insertions(+), 26 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp index b066358b9f..1bbb2af27e 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp @@ -458,20 +458,14 @@ void TCell::FillTxBody(PPTX::Logic::TxBody &oTxBody) { if (m_pShape == nullptr) { - PPTX::Logic::Paragraph p; - auto RPr = new PPTX::Logic::RunProperties; - RPr->lang = L"en-US"; - RPr->sz = 1800; - RPr->dirty = false; - RPr->m_name = L"a:endParaRPr"; - p.endParaRPr = RPr; - oTxBody.Paragrs.push_back(p); - - return; + TxBodyConverter txBodyConverter(nullptr, TxBodyConverter::table); + txBodyConverter.FillTxBody(oTxBody); + } else + { + TxBodyConverter txBodyConverter(&m_pShape->m_pShape->m_oText, TxBodyConverter::table); + txBodyConverter.FillTxBody(oTxBody); } - TxBodyConverter txBodyConverter(&m_pShape->m_pShape->m_oText, TxBodyConverter::table); - txBodyConverter.FillTxBody(oTxBody); } void TCell::FillTcPr(PPTX::Logic::TableCellProperties &oTcPr) @@ -504,12 +498,12 @@ void TCell::FillLn(PPTX::Logic::Ln &Ln, TCell::eBorderPossition eBP, CShapeEleme return; switch (eBP) { - case lnL: Ln.m_name = L"lnL"; break; - case lnR: Ln.m_name = L"lnR"; break; - case lnT: Ln.m_name = L"lnT"; break; - case lnB: Ln.m_name = L"lnB"; break; - case lnBlToTr: Ln.m_name = L"lnBlToTr"; break; - case lnTlToBr: Ln.m_name = L"lnTlToBr"; break; + case lnL: Ln.m_name = L"a:lnL"; break; + case lnR: Ln.m_name = L"a:lnR"; break; + case lnT: Ln.m_name = L"a:lnT"; break; + case lnB: Ln.m_name = L"a:lnB"; break; + case lnBlToTr: Ln.m_name = L"a:lnBlToTr"; break; + case lnTlToBr: Ln.m_name = L"a:lnTlToBr"; break; } auto& pen = pBorder->m_oPen; @@ -523,9 +517,10 @@ void TCell::FillLn(PPTX::Logic::Ln &Ln, TCell::eBorderPossition eBP, CShapeEleme Ln.prstDash = new PPTX::Logic::PrstDash; Ln.prstDash->val = new PPTX::Limit::PrstDashVal; - BYTE dash[] = {6,7,10,1,3,4,5}; - if (sizeof (dash) > pen.DashStyle) - Ln.prstDash->val->SetBYTECode(dash[pen.DashStyle]); + auto oldDash = pen.DashStyle; + BYTE dash[] = {6,7,10,8,9,2,0,3,1,4}; + if (sizeof (dash) > oldDash) + Ln.prstDash->val->SetBYTECode(dash[oldDash]); // TODO? Ln.cap = new PPTX::Limit::LineCap; diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp index 60d55c77db..dc4b4a9ae3 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp @@ -11,14 +11,11 @@ TxBodyConverter::TxBodyConverter(CTextAttributesEx *pText, TxBodyConverter::eTxT void TxBodyConverter::FillTxBody(PPTX::Logic::TxBody &oTxBody) { - if (m_pText == nullptr) - return; switch (m_txType) { case shape: ConvertShapeTxBody(oTxBody); break; case table: ConvertTableTxBody(oTxBody); break; } - } void TxBodyConverter::ConvertTableTxBody(PPTX::Logic::TxBody &oTxBody) @@ -28,7 +25,6 @@ void TxBodyConverter::ConvertTableTxBody(PPTX::Logic::TxBody &oTxBody) oTxBody.m_name = L"a:txBody"; FillParagraphs(oTxBody.Paragrs, m_pText->m_arParagraphs); - } void TxBodyConverter::ConvertShapeTxBody(PPTX::Logic::TxBody &oTxBody) @@ -38,12 +34,14 @@ void TxBodyConverter::ConvertShapeTxBody(PPTX::Logic::TxBody &oTxBody) void TxBodyConverter::FillParagraphs(std::vector &arrP, std::vector &arrParagraphs) { - if (m_pText == nullptr) + if (m_pText == nullptr || m_pText->m_arParagraphs.empty()) { PPTX::Logic::Paragraph p; p.endParaRPr = new PPTX::Logic::RunProperties; p.endParaRPr->m_name = L"a:endParaRPr"; p.endParaRPr->lang = L"en-US"; + p.endParaRPr->sz = 1800; + p.endParaRPr->dirty = false; arrP.push_back(p); return; diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h index e34483d1e8..96096f63c4 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h @@ -62,6 +62,7 @@ private: void FillCS(PPTX::Logic::TextFont& oCs, CFontProperties& font); void FillEffectLst(PPTX::Logic::EffectProperties &oEList, CTextCFRun& oCFRun); void FillSolidFill(PPTX::Logic::UniFill& oUF, CColor& oColor); + private: CTextAttributesEx* m_pText; eTxType m_txType; From 90fd93de9acfb533fa013b17c73b89f249407ab0 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Thu, 17 Jun 2021 17:56:28 +0300 Subject: [PATCH 20/84] correct alpha and diagonal borders --- .../PPTFormatLib/PPTXWriter/TableWriter.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp index 1bbb2af27e..023a95bfe8 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp @@ -256,7 +256,7 @@ void ProtoTable::setBorders(const UINT posFRow, const UINT posFCol, const UINT p // lnTlToBr or lnBlToTr if ((posFRow != posLRow) && (posFCol != posLCol)) { - auto borPos = posFRow > posLRow ? TCell::lnTlToBr : TCell::lnBlToTr; + auto borPos = posFRow > posLRow ? TCell::lnBlToTr : TCell::lnTlToBr; m_table[posFRow][posFCol].setBorder(borPos, pBorder); return; } @@ -512,7 +512,13 @@ void TCell::FillLn(PPTX::Logic::Ln &Ln, TCell::eBorderPossition eBP, CShapeEleme auto pSolidFill = new PPTX::Logic::SolidFill; auto& clr = pen.Color; pSolidFill->Color.SetRGBColor(clr.GetR(), clr.GetG(), clr.GetB()); - pSolidFill->Color.Color->alpha = (unsigned char)pen.Alpha; + if (pen.Alpha) + { + PPTX::Logic::ColorModifier alpha; + alpha.name = L"a:alpha"; + alpha.val = pen.Alpha * 394; + pSolidFill->Color.Color->Modifiers.push_back(alpha); + } Ln.Fill.Fill.reset(pSolidFill); Ln.prstDash = new PPTX::Logic::PrstDash; From 59c0abbee919f195ce24ad0a4943aa6b0287955b Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Fri, 18 Jun 2021 14:54:24 +0300 Subject: [PATCH 21/84] add horz align --- .../PPTFormatLib/PPTXWriter/TxBodyConverter.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp index dc4b4a9ae3..dd13c7754c 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp @@ -160,6 +160,17 @@ void TxBodyConverter::FillPPr(PPTX::Logic::TextParagraphPr &oPPr, CTextPFRun &oP if (oPFRun.bulletAutoNum->type.is_init()) pBuAutoNum->type = oPFRun.bulletAutoNum->type.get(); } + + if (oPFRun.textAlignment.is_init()) + { + auto pAlgn = new PPTX::Limit::TextAlign; + auto old_algn = *(oPFRun.textAlignment); + BYTE algn[] = {4,0,5,2}; + if (sizeof (algn) > old_algn) + pAlgn->SetBYTECode(algn[old_algn]); + + oPPr.algn = pAlgn; + } } void TxBodyConverter::FillRPr(PPTX::Logic::RunProperties &oRPr, CTextCFRun &oCFRun) From a2a65579c1fc6219d2edb52cb8f4d50e8d76103e Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Fri, 18 Jun 2021 16:01:44 +0300 Subject: [PATCH 22/84] add common anchor --- .../PPTFormatLib/PPTXWriter/TableWriter.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp index 023a95bfe8..168d7a45c5 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp @@ -470,6 +470,23 @@ void TCell::FillTxBody(PPTX::Logic::TxBody &oTxBody) void TCell::FillTcPr(PPTX::Logic::TableCellProperties &oTcPr) { + //anchor + auto& attr = m_pShape->m_pShape->m_oText.m_oAttributes; + if (attr.m_nTextAlignVertical != -1) + { + auto pAnchor = new PPTX::Limit::TextAnchor; + BYTE anchor[] = {4,1,0}; + if (sizeof (anchor) > (UINT)attr.m_nTextAlignVertical) + pAnchor->SetBYTECode(anchor[attr.m_nTextAlignVertical]); + + oTcPr.Anchor = pAnchor; + } + if (attr.m_nTextAlignHorizontal == 1) + { + oTcPr.AnchorCtr = true; + } + + auto pSolidFill = new PPTX::Logic::SolidFill; auto& clr = m_pShape->m_oBrush.Color1; From cb5530028613c1aecaebf81d6213fc0444ddbc7b Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Fri, 18 Jun 2021 17:12:12 +0300 Subject: [PATCH 23/84] add line spacing --- .../PPTXWriter/TxBodyConverter.cpp | 18 ++++++++++++++++-- .../PPTFormatLib/PPTXWriter/TxBodyConverter.h | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp index dd13c7754c..e6074cb260 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp @@ -68,7 +68,7 @@ void TxBodyConverter::FillParagraph(PPTX::Logic::Paragraph &p, CParagraph ¶g } p.pPr = new PPTX::Logic::TextParagraphPr; - FillPPr(p.pPr.get2(), paragraph.m_oPFRun); + FillPPr(p.pPr.get2(), paragraph); p.endParaRPr = new PPTX::Logic::RunProperties; FillEndParaRPr(p.endParaRPr.get2(), paragraph.m_oPFRun); @@ -121,8 +121,9 @@ void TxBodyConverter::FillEndParaRPr(PPTX::Logic::RunProperties &oEndPr, CTextPF // } } -void TxBodyConverter::FillPPr(PPTX::Logic::TextParagraphPr &oPPr, CTextPFRun &oPFRun) +void TxBodyConverter::FillPPr(PPTX::Logic::TextParagraphPr &oPPr, CParagraph ¶graph) { + CTextPFRun &oPFRun = paragraph.m_oPFRun; int leftMargin = 0; if (oPFRun.leftMargin.is_init()) { @@ -171,6 +172,19 @@ void TxBodyConverter::FillPPr(PPTX::Logic::TextParagraphPr &oPPr, CTextPFRun &oP oPPr.algn = pAlgn; } + + if (paragraph.m_lTextLevel != 0) + { + oPPr.lvl = paragraph.m_lTextLevel; + } + + if (oPFRun.lineSpacing.is_init()) + { + auto pLnSpc = new PPTX::Logic::TextSpacing; + pLnSpc->m_name = L"a:lnSpc"; + pLnSpc->spcPct = *(oPFRun.lineSpacing) * -1000; + oPPr.lnSpc = pLnSpc; + } } void TxBodyConverter::FillRPr(PPTX::Logic::RunProperties &oRPr, CTextCFRun &oCFRun) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h index 96096f63c4..97ff3ec910 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h @@ -56,7 +56,7 @@ private: void FillParagraph(PPTX::Logic::Paragraph& p, CParagraph& paragraph); void FillRun(PPTX::Logic::Run& oRun, CSpan &oSpan); void FillEndParaRPr(PPTX::Logic::RunProperties& oEndPr, CTextPFRun& oPFRun); - void FillPPr(PPTX::Logic::TextParagraphPr& oPPr, CTextPFRun& oPFRun); + void FillPPr(PPTX::Logic::TextParagraphPr& oPPr, CParagraph ¶graph); void FillRPr(PPTX::Logic::RunProperties& oRPr, CTextCFRun& oCFRun); void FillLatin(PPTX::Logic::TextFont& oLatin, CFontProperty &font); void FillCS(PPTX::Logic::TextFont& oCs, CFontProperties& font); From 06fb3f02031c5506bdc674e150b4ed4af80fbb48 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Fri, 18 Jun 2021 18:07:39 +0300 Subject: [PATCH 24/84] add pt spacing --- .../PPTXWriter/TxBodyConverter.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp index e6074cb260..a6437345fd 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp @@ -166,7 +166,7 @@ void TxBodyConverter::FillPPr(PPTX::Logic::TextParagraphPr &oPPr, CParagraph &pa { auto pAlgn = new PPTX::Limit::TextAlign; auto old_algn = *(oPFRun.textAlignment); - BYTE algn[] = {4,0,5,2}; + BYTE algn[] = {4,0,5,2,1}; if (sizeof (algn) > old_algn) pAlgn->SetBYTECode(algn[old_algn]); @@ -185,6 +185,23 @@ void TxBodyConverter::FillPPr(PPTX::Logic::TextParagraphPr &oPPr, CParagraph &pa pLnSpc->spcPct = *(oPFRun.lineSpacing) * -1000; oPPr.lnSpc = pLnSpc; } + + if (oPFRun.spaceAfter.is_init()) + { + auto pSpcAft = new PPTX::Logic::TextSpacing; + pSpcAft->m_name = L"a:spcAft"; + pSpcAft->spcPts = (int)(12.5 * oPFRun.spaceAfter.get()); + + oPPr.spcAft = pSpcAft; + } + if (oPFRun.spaceBefore.is_init()) + { + auto pSpcBef = new PPTX::Logic::TextSpacing; + pSpcBef->m_name = L"a:spcBef"; + pSpcBef->spcPts = (int)(12.5 * oPFRun.spaceBefore.get()); + + oPPr.spcBef = pSpcBef; + } } void TxBodyConverter::FillRPr(PPTX::Logic::RunProperties &oRPr, CTextCFRun &oCFRun) From e5e0949f39506e4ec0bed523bbe0ee5591b09e8e Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Wed, 23 Jun 2021 19:46:41 +0300 Subject: [PATCH 25/84] add bullets for text in table --- .../PPTXWriter/TxBodyConverter.cpp | 65 +++++++++++++++---- .../PPTFormatLib/PPTXWriter/TxBodyConverter.h | 2 + .../PPTXFormat/Logic/Bullets/BulletTypeface.h | 6 +- 3 files changed, 59 insertions(+), 14 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp index a6437345fd..743bff3250 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp @@ -151,17 +151,6 @@ void TxBodyConverter::FillPPr(PPTX::Logic::TextParagraphPr &oPPr, CParagraph &pa oPPr.buTypeface.SetParentPointer(pBuFont); } - - if (oPFRun.bulletAutoNum.is_init()) - { - auto pBuAutoNum = new PPTX::Logic::BuAutoNum; - oPPr.ParagraphBullet.m_Bullet.reset(pBuAutoNum); - if (oPFRun.bulletAutoNum->startAt.is_init() && oPFRun.bulletAutoNum->startAt.get() != 1) - pBuAutoNum->startAt = oPFRun.bulletAutoNum->startAt.get(); - if (oPFRun.bulletAutoNum->type.is_init()) - pBuAutoNum->type = oPFRun.bulletAutoNum->type.get(); - } - if (oPFRun.textAlignment.is_init()) { auto pAlgn = new PPTX::Limit::TextAlign; @@ -202,6 +191,45 @@ void TxBodyConverter::FillPPr(PPTX::Logic::TextParagraphPr &oPPr, CParagraph &pa oPPr.spcBef = pSpcBef; } + + if (oPFRun.bulletColor.is_init()) + { + FillBuClr(oPPr.buColor, oPFRun.bulletColor.get()); + } + + if (oPFRun.hasBullet.is_init() && *(oPFRun.hasBullet) == true) + { + if (oPFRun.bulletChar.is_init()) + { + FillBuChar(oPPr.ParagraphBullet, oPFRun.bulletChar.get()); + } else + { + FillBuChar(oPPr.ParagraphBullet, L'•'); + } + } + + if (oPFRun.bulletFontProperties.is_init()) + { + auto pTypeface = new PPTX::Logic::BulletTypeface(); + auto pFont = new PPTX::Logic::TextFont(); + pFont->m_name = _T("a:buFont"); + pFont->typeface = oPFRun.bulletFontProperties->Name; + pFont->pitchFamily = std::to_wstring(oPFRun.bulletFontProperties->PitchFamily); + pFont->charset = std::to_wstring(oPFRun.bulletFontProperties->PitchFamily); + + pTypeface->m_Typeface.reset(pFont); + oPPr.buTypeface.m_Typeface.reset(pTypeface); + } + + if (oPFRun.bulletAutoNum.is_init() && oPFRun.bulletFontProperties.is_init() && oPFRun.bulletFontProperties->Charset == 0) + { + auto pBuAutoNum = new PPTX::Logic::BuAutoNum; + oPPr.ParagraphBullet.m_Bullet.reset(pBuAutoNum); + if (oPFRun.bulletAutoNum->startAt.is_init() && oPFRun.bulletAutoNum->startAt.get() != 1) + pBuAutoNum->startAt = oPFRun.bulletAutoNum->startAt.get(); + if (oPFRun.bulletAutoNum->type.is_init()) + pBuAutoNum->type = oPFRun.bulletAutoNum->type.get(); + } } void TxBodyConverter::FillRPr(PPTX::Logic::RunProperties &oRPr, CTextCFRun &oCFRun) @@ -290,3 +318,18 @@ void TxBodyConverter::FillSolidFill(PPTX::Logic::UniFill &oUF, CColor &oColor) pSolidFill->Color.SetRGBColor(oColor.GetR(), oColor.GetG(), oColor.GetB()); oUF.Fill.reset(pSolidFill); } + +void TxBodyConverter::FillBuClr(PPTX::Logic::BulletColor &oBuClr, CColor &oColor) +{ + auto pBuClr = new PPTX::Logic::BuClr; + pBuClr->Color.SetRGBColor(oColor.GetR(), oColor.GetG(), oColor.GetB()); + oBuClr.m_Color.reset(pBuClr); +} + +void TxBodyConverter::FillBuChar(PPTX::Logic::Bullet &oBullet, WCHAR symbol) +{ + auto pBuChar = new PPTX::Logic::BuChar; + pBuChar->Char.clear(); + pBuChar->Char.push_back(symbol); + oBullet.m_Bullet.reset(pBuChar); +} diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h index 97ff3ec910..caafe55f30 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h @@ -62,6 +62,8 @@ private: void FillCS(PPTX::Logic::TextFont& oCs, CFontProperties& font); void FillEffectLst(PPTX::Logic::EffectProperties &oEList, CTextCFRun& oCFRun); void FillSolidFill(PPTX::Logic::UniFill& oUF, CColor& oColor); + void FillBuClr(PPTX::Logic::BulletColor& oBuClr, CColor& oColor); + void FillBuChar(PPTX::Logic::Bullet& oBullet, WCHAR symbol); private: CTextAttributesEx* m_pText; diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/Bullets/BulletTypeface.h b/ASCOfficePPTXFile/PPTXFormat/Logic/Bullets/BulletTypeface.h index 989312ef74..a9f21b583c 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/Bullets/BulletTypeface.h +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/Bullets/BulletTypeface.h @@ -153,8 +153,8 @@ namespace PPTX pReader->Seek(_end_rec); } - //public: - private: + public: +// private: smart_ptr m_Typeface; protected: virtual void FillParentPointersForChilds(){}; @@ -168,4 +168,4 @@ namespace PPTX } // namespace Logic } // namespace PPTX -#endif // PPTX_LOGIC_BULLETTYPEFACE_INCLUDE_H \ No newline at end of file +#endif // PPTX_LOGIC_BULLETTYPEFACE_INCLUDE_H From 01ee6766147fd8c18e884736e7055295d68dc0f0 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Fri, 25 Jun 2021 12:16:54 +0300 Subject: [PATCH 26/84] add records: metafile, RoundTripOArtTextStyles12Atom --- .../PPTFormatLib/Linux/PPTFormatLib.pro | 1 + .../PPTFormatLib/Reader/Records.cpp | 6 +- .../PPTFormatLib/Records/MetafileBlob.h | 17 ++++- .../PPTFormatLib/Records/RecordsIncluder.h | 3 + .../Records/RoundTripOArtTextStyles12Atom.h | 68 +++++++++++++++++++ 5 files changed, 90 insertions(+), 5 deletions(-) create mode 100644 ASCOfficePPTFile/PPTFormatLib/Records/RoundTripOArtTextStyles12Atom.h diff --git a/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro b/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro index e7bafc26a6..a2ecd29f5f 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro +++ b/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro @@ -444,6 +444,7 @@ HEADERS += \ ../Records/DocProgTagsContainer.h \ ../Records/OfficeArtClientData.h \ ../Records/PlaceHolderAtom.h \ + ../Records/RoundTripOArtTextStyles12Atom.h \ ../Records/ShapeProgBinaryTagSubContainerOrAtom.h \ ../Records/CFMasks.h \ ../Records/ColorSchemeAtom.h \ diff --git a/ASCOfficePPTFile/PPTFormatLib/Reader/Records.cpp b/ASCOfficePPTFile/PPTFormatLib/Reader/Records.cpp index 654a700b85..ed466ec410 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Reader/Records.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Reader/Records.cpp @@ -528,7 +528,8 @@ IRecord* CreateByType(SRecordHeader oHeader) //CREATE_BY_TYPE(RECORD_TYPE_ROUNDTRIPSHAPEID12 , CRecordRoundTripShapeId12Atom) CREATE_BY_TYPE(RT_RoundTripHFPlaceholder12Atom , CRecordRoundTripHFPlaceholder12Atom) //CREATE_BY_TYPE(RECORD_TYPE_ROUNDTRIPCONTENTMASTERID , CRecordRoundTripContentMasterId12Atom) - //CREATE_BY_TYPE(RECORD_TYPE_ROUNDTRIPOARTTEXTSTYLES12 , CRecordRoundTripOArtTextStyles12Atom) + + CREATE_BY_TYPE(RT_RoundTripOArtTextStyles12Atom , CRecordRoundTripOArtTextStyles12Atom) CREATE_BY_TYPE(RT_RoundTripHeaderFooterDefaults12Atom , CRecordRoundTripHeaderFooterDefaults12Atom) CREATE_BY_TYPE(RT_RoundTripNotesMasterTextStyles12Atom , CRecordRoundTripNotesMasterTextStyles12Atom) //CREATE_BY_TYPE(RECORD_TYPE_ROUNDTRIPDOCFLAGS12 , CRecordRoundTripDocFlags12Atom) @@ -632,10 +633,11 @@ IRecord* CreateByType(SRecordHeader oHeader) CREATE_BY_TYPE(RT_Sound , CRecordSoundContainer) CREATE_BY_TYPE(RT_SoundDataBlob , CRecordSoundDataBlob) - + CREATE_BY_TYPE(RT_MetaFile , CRecordMetafileBlob) default: { + std::cout << GetRecordName(oHeader.RecType) << ": " << oHeader.RecLen << "\n"; }break; }; diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/MetafileBlob.h b/ASCOfficePPTFile/PPTFormatLib/Records/MetafileBlob.h index 548e47acb1..4f0db277f6 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/MetafileBlob.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/MetafileBlob.h @@ -31,6 +31,8 @@ */ #pragma once #include "../Reader/Records.h" +#include + class CRecordMetafileBlob : public CUnknownRecord { @@ -40,17 +42,26 @@ public: SHORT m_nExtY; BYTE* m_pData; - CRecordMetafileBlob() + CRecordMetafileBlob() : + m_nMM(-1), m_nExtX(-1), m_nExtY(-1), m_pData(nullptr) { + } ~CRecordMetafileBlob() { + RELEASEOBJECT (m_pData) } virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream) { - return CUnknownRecord::ReadFromStream(oHeader, pStream); + m_oHeader = oHeader; + + m_nMM = StreamUtils::ReadSHORT(pStream); + m_nExtX = StreamUtils::ReadSHORT(pStream); + m_nExtY = StreamUtils::ReadSHORT(pStream); + pStream->read(m_pData, m_oHeader.RecLen - 6); + std::cout << m_pData << "\n\n"; } -}; \ No newline at end of file +}; diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/RecordsIncluder.h b/ASCOfficePPTFile/PPTFormatLib/Records/RecordsIncluder.h index 0e72ead75a..34a05321d1 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/RecordsIncluder.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/RecordsIncluder.h @@ -141,3 +141,6 @@ #include "RoundTripOriginalMainMasterId12Atom.h" #include "RoundTripCompositeMainMasterId12Atom.h" + +// Meta data +#include "RoundTripOArtTextStyles12Atom.h" diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/RoundTripOArtTextStyles12Atom.h b/ASCOfficePPTFile/PPTFormatLib/Records/RoundTripOArtTextStyles12Atom.h new file mode 100644 index 0000000000..a0994ed8ad --- /dev/null +++ b/ASCOfficePPTFile/PPTFormatLib/Records/RoundTripOArtTextStyles12Atom.h @@ -0,0 +1,68 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ +#pragma once +#include "../Reader/Records.h" +#include + +class CRecordRoundTripOArtTextStyles12Atom : public CUnknownRecord +{ + BYTE* m_pData; + +public: + + CRecordRoundTripOArtTextStyles12Atom() + { + m_pData = NULL; + } + + ~CRecordRoundTripOArtTextStyles12Atom() + { + ReleaseData(); + } + + virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream) + { + m_oHeader = oHeader; + unsigned lSize = m_oHeader.RecLen; + + if (0 < lSize) + { + m_pData = new BYTE[lSize]; + pStream->read(m_pData, lSize); + } + } + + void ReleaseData() + { + RELEASEARRAYOBJECTS(m_pData); + } +}; From 66e103fd94ef49e7c885a971282a61d8c0953afb Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Tue, 29 Jun 2021 15:52:21 +0300 Subject: [PATCH 27/84] I can exctract tableStyles.xml, but it's not perfect solition --- .../PPTFormatLib/Linux/PPTFormatLib.pro | 364 +- .../PPTFormatLib/PPTXWriter/Converter.cpp | 2980 +++++++++-------- OfficeUtils/src/ZipUtilsCP.h | 2 + 3 files changed, 1500 insertions(+), 1846 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro b/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro index e7bafc26a6..1166511ad8 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro +++ b/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro @@ -27,334 +27,6 @@ DEFINES += UNICODE \ #DISABLE_FILE_DOWNLOADER HEADERS += \ -# ../../../ASCOfficePPTXFile/Editor/Drawing/Animations.h \ -# ../../../ASCOfficePPTXFile/Editor/Drawing/Attributes.h \ -# ../../../ASCOfficePPTXFile/Editor/Drawing/AudioOverlay.h \ -# ../../../ASCOfficePPTXFile/Editor/Drawing/Document.h \ -# ../../../ASCOfficePPTXFile/Editor/Drawing/Effects.h \ -# ../../../ASCOfficePPTXFile/Editor/Drawing/Interactive.h \ -# ../../../ASCOfficePPTXFile/Editor/Drawing/Metric.h \ -# ../../../ASCOfficePPTXFile/Editor/Drawing/SlideShow.h \ -# ../../../ASCOfficePPTXFile/Editor/Drawing/Structures.h \ -# ../../../ASCOfficePPTXFile/Editor/Drawing/XmlStringWriter.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/AlbumLayout.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/AnimationDgmBuild.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/BWMode.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/BaseLimit.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/BevelType.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/BlendMode.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/BlipCompression.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/CameraType.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/ChartBuild.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/ChartBuildType.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/ColorSchemeIndex.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/CompoundLine.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/Conformance.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/ContentStatus.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/CornerDirectionVal.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/DgmBuild.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/DgmBuildType.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/EffectContainerType.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/EightDirectionVal.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/FillPath.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/Flip.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/FontAlign.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/FontStyleIndex.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/FrameShape.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/HorzOverflow.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/InOutDirectionVal.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/IterateType.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/LastView.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/LightRigType.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/LineCap.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/LineEndSize.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/LineEndType.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/Material.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/OnOff.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/Orient.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/ParaBuildType.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/PathFillMode.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/PattFillVal.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/PenAlign.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/PlaceholderSize.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/PlaceholderType.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/PresetShadowVal.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/PrstClrVal.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/PrstDashVal.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/RectAlign.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/SchemeClrVal.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/ShapeType.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/SideDirectionVal.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/SlideLayoutType.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/SlideSize.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/SplitterBarState.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/SysClrVal.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/TLAccumulate.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/TLAdditive.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/TLCalcMode.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/TLChartSubElement.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/TLColorDirection.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/TLColorSpace.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/TLCommandType.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/TLMasterRelation.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/TLNextAc.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/TLNodeFillType.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/TLNodeType.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/TLOrigin.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/TLOverride.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/TLPathEditMode.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/TLPresetClass.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/TLPrevAc.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/TLRestart.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/TLRuntimeTrigger.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/TLSyncBehavior.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/TLTransform.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/TLTransition.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/TLTriggerEvent.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/TLValueType.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/TextAlign.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/TextAnchor.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/TextAutonumberScheme.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/TextCaps.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/TextShapeType.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/TextStrike.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/TextTabAlignType.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/TextUnderline.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/TextVerticalType.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/TextWrap.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/TransitionSpeed.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/VariantType.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Limit/VertOverflow.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Ah.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/AhBase.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/AhPolar.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/AhXY.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Backdrop.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Bevel.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Bg.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/BgPr.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/BodyPr.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Bullets/BuAutoNum.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Bullets/BuBlip.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Bullets/BuChar.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Bullets/BuClr.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Bullets/BuClrTx.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Bullets/BuFontTx.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Bullets/BuNone.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Bullets/BuSzPct.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Bullets/BuSzPts.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Bullets/BuSzTx.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Bullets/Bullet.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Bullets/BulletColor.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Bullets/BulletSize.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Bullets/BulletTypeface.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/CNvCxnSpPr.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/CNvGraphicFramePr.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/CNvGrpSpPr.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/CNvPicPr.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/CNvPr.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/CNvSpPr.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/CSld.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Camera.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Cell3D.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/ClrMap.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/ClrMapOvr.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Colors/ColorBase.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Colors/ColorModifier.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Colors/PrstClr.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SchemeClr.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SrgbClr.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SysClr.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/ContentPart.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Controls.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/CustGeom.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Cxn.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/CxnSp.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/DefaultShapeDefinition.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/EffectDag.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/EffectLst.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/EffectProperties.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/EffectStyle.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Effects/AlphaBiLevel.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Effects/AlphaCeiling.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Effects/AlphaFloor.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Effects/AlphaInv.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Effects/AlphaMod.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Effects/AlphaModFix.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Effects/AlphaOutset.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Effects/AlphaRepl.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Effects/BiLevel.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Effects/Blend.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Effects/Blur.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Effects/ClrChange.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Effects/ClrRepl.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Effects/Duotone.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Effects/EffectElement.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Effects/FillEffect.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Effects/FillOverlay.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Effects/Glow.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Effects/Grayscl.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Effects/HslEffect.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Effects/InnerShdw.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Effects/LumEffect.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Effects/OuterShdw.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Effects/PrstShdw.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Effects/Reflection.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Effects/RelOff.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Effects/SoftEdge.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Effects/TintEffect.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Effects/XfrmEffect.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/ExtP.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/FillStyle.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Fills/Blip.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Fills/BlipFill.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Fills/GradFill.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Fills/NoFill.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Fills/PattFill.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Fills/SolidFill.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Fills/Stretch.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Fills/Tile.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/FontCollection.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/FontRef.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Gd.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Geometry.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/GraphicFrame.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/GrpSpPr.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Gs.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/HeadingVariant.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Hf.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Hyperlink.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/LightRig.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Lin.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/LineEnd.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/LineJoin.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/LineStyle.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Ln.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Media/AudioCD.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Media/MediaFile.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Media/WavAudioFile.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/NvCxnSpPr.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/NvGraphicFramePr.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/NvGrpSpPr.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/NvPicPr.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/NvPr.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/NvSpPr.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Paragraph.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/PartTitle.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Path.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Path2D.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Path2D/ArcTo.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Path2D/Close.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Path2D/CubicBezTo.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Path2D/LineTo.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Path2D/MoveTo.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Path2D/PathBase.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Path2D/QuadBezTo.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Ph.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Pic.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/PrstDash.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/PrstGeom.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/PrstTxWarp.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Rect.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Rot.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/RunElem.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/RunProperties.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Runs/Br.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Runs/Fld.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Runs/MathParaWrapper.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Runs/Run.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Runs/RunBase.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Scene3d.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Shape.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/ShapeStyle.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/SmartArt.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Sp3d.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/SpPr.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/SpTree.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/SpTreeElem.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/StyleRef.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/SupplementalFont.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Tab.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Table/Table.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Table/TableCell.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Table/TableCellProperties.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Table/TableCol.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Table/TableProperties.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Table/TableRow.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/TableBgStyle.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/TablePartStyle.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/TableStyle.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/TcBdr.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/TcStyle.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/TcTxStyle.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/TextFit.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/TextFont.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/TextListStyle.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/TextParagraphPr.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/TextSpacing.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Anim.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimClr.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimEffect.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimMotion.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimRot.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimScale.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimVariant.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AttrName.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AttrNameLst.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Audio.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/BldDgm.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/BldGraphic.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/BldLst.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/BldOleChart.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/BldP.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/BldSub.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/BuildNodeBase.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/CBhvr.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/CMediaNode.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/CTn.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/ChildTnLst.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Cmd.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Cond.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/CondLst.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Excl.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/GraphicEl.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Iterate.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Par.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Seq.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Set.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/SpTgt.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Tav.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/TavLst.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/TgtEl.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/TimeNodeBase.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Timing.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Tmpl.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/TmplLst.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/TnLst.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/TxEl.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Video.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/CornerDirectionTransition.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/EightDirectionTransition.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/EmptyTransition.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/OptionalBlackTransition.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/OrientationTransition.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/SideDirectionTransition.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/SndAc.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/SplitTransition.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/StSnd.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/Transition.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/TransitionBase.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/WheelTransition.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/ZoomTransition.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/TxBody.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/TxStyles.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/UniColor.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/UniEffect.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/UniFill.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/UniMedia.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/UniPath2D.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Xfrm.h \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/XmlId.h \ ../Enums/RecordType.h \ ../Enums/_includer.h \ ../Enums/enums.h \ @@ -444,6 +116,7 @@ HEADERS += \ ../Records/DocProgTagsContainer.h \ ../Records/OfficeArtClientData.h \ ../Records/PlaceHolderAtom.h \ + ../Records/RoundTripOArtTextStyles12Atom.h \ ../Records/ShapeProgBinaryTagSubContainerOrAtom.h \ ../Records/CFMasks.h \ ../Records/ColorSchemeAtom.h \ @@ -613,40 +286,6 @@ SOURCES += \ } SOURCES += \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Bg.cpp \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/CNvGrpSpPr.cpp \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SchemeClr.cpp \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/ContentPart.cpp \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Controls.cpp \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/CxnSp.cpp \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/EffectDag.cpp \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/EffectLst.cpp \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/EffectProperties.cpp \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/EffectStyle.cpp \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Fills/Blip.cpp \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Fills/BlipFill.cpp \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Geometry.cpp \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/GraphicFrame.cpp \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/GrpSpPr.cpp \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Hyperlink.cpp \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Media/WavAudioFile.cpp \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/NvGraphicFramePr.cpp \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/NvGrpSpPr.cpp \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Pic.cpp \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Runs/MathParaWrapper.cpp \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Shape.cpp \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/SmartArt.cpp \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/SpPr.cpp \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/SpTree.cpp \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/SpTreeElem.cpp \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Table/TableCell.cpp \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/BuildNodeBase.cpp \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/TimeNodeBase.cpp \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/TransitionBase.cpp \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/TxBody.cpp \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/UniColor.cpp \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/UniEffect.cpp \ -# ../../../ASCOfficePPTXFile/PPTXFormat/Logic/UniFill.cpp \ ../Enums/RecordType.cpp \ ../PPTFormatLib.cpp \ ../../../ASCOfficePPTXFile/Editor/Drawing/Elements.cpp \ @@ -656,4 +295,3 @@ SOURCES += \ ../PPTXWriter/TableWriter.cpp \ ../PPTXWriter/TxBodyConverter.cpp \ ../Records/Animations/TimeVariant.cpp - diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp index 613fb1852b..53843518e5 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp @@ -1,1483 +1,1497 @@ -/* - * (c) Copyright Ascensio System SIA 2010-2019 - * - * This program is a free software product. You can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License (AGPL) - * version 3 as published by the Free Software Foundation. In accordance with - * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement - * of any third-party rights. - * - * This program is distributed WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For - * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html - * - * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha - * street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions - * of the Program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product - * logo when distributing the program. Pursuant to Section 7(e) we decline to - * grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as - * well as technical writing content are licensed under the terms of the - * Creative Commons Attribution-ShareAlike 4.0 International. See the License - * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - * - */ -#pragma once - -#include "../../../ASCOfficePPTXFile/Editor/Drawing/Document.h" - -#include "../../../ASCOfficePPTXFile/Editor/DefaultNotesMaster.h" -#include "../../../ASCOfficePPTXFile/Editor/DefaultNotesTheme.h" - -#include "../../../Common/DocxFormat/Source/SystemUtility/SystemUtility.h" -#include "../../../ASCOfficeXlsFile2/source/Common/simple_xml_writer.h" -#include "../../../DesktopEditor/common/Directory.h" -#include "../../../DesktopEditor/common/SystemUtils.h" -#include "TableWriter.h" - -#include "../Reader/PPTDocumentInfo.h" - -#include "ShapeWriter.h" -#include "StylesWriter.h" - -#include "Converter.h" -#include "Animation.h" - -namespace PPT_FORMAT -{ - namespace NSPPTXWriterConst - { - static std::wstring g_string_rels_presentation = _T("\ -\ -\ -\ -\ -"); - - static std::wstring g_string_core = _T("\ -\ -Slide 1\ -1\ -"); - } -} - - -PPT_FORMAT::CPPTXWriter::CPPTXWriter() -{ - m_strTempDirectory = NSDirectory::GetTempPath() + FILE_SEPARATOR_STR + _T("TempPPTX"); - m_strDstFileName = NSDirectory::GetTempPath() + FILE_SEPARATOR_STR + _T("Test.pptx"); - - m_pDocument = NULL; - m_pUserInfo = NULL; - - m_pShapeWriter = new CShapeWriter(); -} - -PPT_FORMAT::CPPTXWriter::~CPPTXWriter() -{ - RELEASEOBJECT(m_pShapeWriter); -} - -void PPT_FORMAT::CPPTXWriter::CreateFile(CPPTUserInfo* pUserInfo ) -{ - m_pUserInfo = pUserInfo; - - m_pDocument = dynamic_cast(pUserInfo); - - m_oManager.Clear(); - m_oManager.SetDstMedia(m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("media") + FILE_SEPARATOR_STR); - - m_pShapeWriter->InitNextId(); - - NSDirectory::CreateDirectory(m_strTempDirectory); - CFile oFile; - std::wstring strMemory = _T(""); - - // _rels - NSDirectory::CreateDirectory(m_strTempDirectory + FILE_SEPARATOR_STR + _T("_rels")); - - oFile.CreateFile(m_strTempDirectory + FILE_SEPARATOR_STR + _T("_rels") + FILE_SEPARATOR_STR + _T(".rels")); - strMemory = NSPPTXWriterConst::g_string_rels_presentation; - oFile.WriteStringUTF8(strMemory); - oFile.CloseFile(); - - // docProps - NSDirectory::CreateDirectory(m_strTempDirectory + FILE_SEPARATOR_STR + _T("docProps")); - - // core - oFile.CreateFile(m_strTempDirectory + FILE_SEPARATOR_STR + _T("docProps") + FILE_SEPARATOR_STR + _T("core.xml")); - strMemory = NSPPTXWriterConst::g_string_core; - oFile.WriteStringUTF8(strMemory); - oFile.CloseFile(); - - // app - oFile.CreateFile(m_strTempDirectory + FILE_SEPARATOR_STR + _T("docProps") + FILE_SEPARATOR_STR + _T("app.xml")); - WriteApp(oFile); - oFile.CloseFile(); - - // content types - WriteContentTypes(); - - // ppt - NSDirectory::CreateDirectory(m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt")); - WritePresInfo(); - - WriteAll(); -} - -void PPT_FORMAT::CPPTXWriter::CreateFile(CDocument* pDocument) -{ - m_pDocument = pDocument; - m_oManager.Clear(); - m_oManager.SetDstMedia(m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("media") + FILE_SEPARATOR_STR); - - m_pShapeWriter->InitNextId(); - - NSDirectory::CreateDirectory(m_strTempDirectory); - CFile oFile; - std::wstring strMemory = _T(""); - - // _rels - NSDirectory::CreateDirectory(m_strTempDirectory + FILE_SEPARATOR_STR + _T("_rels")); - - oFile.CreateFile(m_strTempDirectory + FILE_SEPARATOR_STR + _T("_rels") + FILE_SEPARATOR_STR + _T(".rels")); - strMemory = NSPPTXWriterConst::g_string_rels_presentation; - oFile.WriteStringUTF8(strMemory); - oFile.CloseFile(); - - // docProps - NSDirectory::CreateDirectory(m_strTempDirectory + FILE_SEPARATOR_STR + _T("docProps")); - - // core - oFile.CreateFile(m_strTempDirectory + FILE_SEPARATOR_STR + _T("docProps") + FILE_SEPARATOR_STR + _T("core.xml")); - strMemory = NSPPTXWriterConst::g_string_core; - oFile.WriteStringUTF8(strMemory); - oFile.CloseFile(); - - // app - oFile.CreateFile(m_strTempDirectory + FILE_SEPARATOR_STR + _T("docProps") + FILE_SEPARATOR_STR + _T("app.xml")); - WriteApp(oFile); - oFile.CloseFile(); - - // content types - WriteContentTypes(); - - // ppt - NSDirectory::CreateDirectory(m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt")); - WritePresInfo(); - - WriteAll(); -} - -void PPT_FORMAT::CPPTXWriter::CloseFile() -{ - m_oManager.Clear(); -} - - -void PPT_FORMAT::CPPTXWriter::WriteContentTypes() -{ - std::wstring strContentTypes = L"\ -\ -\ -\ -\ -\ -\ -\ -\ -\ -\ -\ -\ -\ -\ -\ -\ -\ -\ -\ -\ -\ -"; - - if (m_pDocument->m_bMacros) - { - strContentTypes += L"\ -"; - } - else - { - strContentTypes += L""; - } - strContentTypes += L"\ -\ -\ -\ -"; - - int nIndexLayout = 1, nIndexTheme = 1; - - for (size_t nT = 0; nT < m_pDocument->m_arThemes.size(); nT++, nIndexTheme++) - { - strContentTypes += L""; - - strContentTypes += L""; - - - for (size_t nL = 0; nL < m_pDocument->m_arThemes[nT]->m_arLayouts.size(); nL++, nIndexLayout++) - { - strContentTypes += L""; - } - } - - if (m_pDocument->m_pNotesMaster) - { - strContentTypes += L""; - strContentTypes += L""; - } - if (m_pDocument->m_pHandoutMaster) - { - strContentTypes += L""; - strContentTypes += L""; - } - - for (size_t nS = 0; nS < m_pDocument->m_arSlides.size(); ++nS) - { - strContentTypes += L""; - } - - for (size_t nS = 0; nS < m_pDocument->m_arNotes.size(); ++nS) - { - strContentTypes += L""; - } - strContentTypes += _T(""); - - CFile oFile; - oFile.CreateFile(m_strTempDirectory + FILE_SEPARATOR_STR + _T("[Content_Types].xml")); - oFile.WriteStringUTF8(strContentTypes); - oFile.CloseFile(); -} - - -void PPT_FORMAT::CPPTXWriter::WriteApp(CFile& oFile) -{ - std::wstringstream strm; - - CP_XML_WRITER(strm) - { - CP_XML_NODE(L"Properties") - { - CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"); - CP_XML_ATTR(L"xmlns:vt", L"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"); - - CP_XML_NODE(L"TotalTime") - { - CP_XML_STREAM() << 0; - } - CP_XML_NODE(L"Words") - { - CP_XML_STREAM() << 0; - } - std::wstring sApplication = NSSystemUtils::GetEnvVariable(NSSystemUtils::gc_EnvApplicationName); - if (sApplication.empty()) - sApplication = NSSystemUtils::gc_EnvApplicationNameDefault; - #if defined(INTVER) - std::string s = VALUE2STR(INTVER); - sApplication += L"/" + std::wstring(s.begin(), s.end()); - #endif - CP_XML_NODE(L"Application") - { - CP_XML_STREAM() << sApplication; - } - //CP_XML_NODE(L"AppVersion") - //{ - // CP_XML_STREAM() << L"1.0"; - //} - CP_XML_NODE(L"Paragraphs") - { - CP_XML_STREAM() << 0; - } - CP_XML_NODE(L"PresentationFormat") - { - CP_XML_STREAM() << L"On-screen Show (4:3)"; - } - CP_XML_NODE(L"Slides") - { - CP_XML_STREAM() << m_pDocument->m_arSlides.size(); - } - CP_XML_NODE(L"Notes") - { - CP_XML_STREAM() << m_pDocument->m_arNotes.size(); - } - CP_XML_NODE(L"HiddenSlides") - { - CP_XML_STREAM() << 0; - } - CP_XML_NODE(L"MMClips") - { - CP_XML_STREAM() << 0; - } - CP_XML_NODE(L"ScaleCrop") - { - CP_XML_STREAM() << L"false"; - } - CP_XML_NODE(L"HeadingPairs") - { - CP_XML_NODE(L"vt:vector") - { - CP_XML_ATTR(L"size", 4); - CP_XML_ATTR(L"baseType", L"variant"); - - CP_XML_NODE(L"vt:variant") - { - CP_XML_NODE(L"vt:lpstr") - { - CP_XML_STREAM() << L"Theme"; - } - } - CP_XML_NODE(L"vt:variant") - { - CP_XML_NODE(L"vt:i4") - { - CP_XML_STREAM() << m_pDocument->m_arThemes.size(); - } - } - CP_XML_NODE(L"vt:variant") - { - CP_XML_NODE(L"vt:lpstr") - { - CP_XML_STREAM() << L"Slide Titles"; - } - } - CP_XML_NODE(L"vt:variant") - { - CP_XML_NODE(L"vt:i4") - CP_XML_STREAM() << m_pDocument->m_arSlides.size(); - } - } - } - CP_XML_NODE(L"TitlesOfParts") - { - CP_XML_NODE(L"vt:vector") - { - CP_XML_ATTR(L"size", m_pDocument->m_arSlides.size() + m_pDocument->m_arThemes.size()); - CP_XML_ATTR(L"baseType", L"lpstr"); - - for (size_t i = 1; i <= m_pDocument->m_arThemes.size(); ++i) - { - CP_XML_NODE(L"vt:lpstr") - { - CP_XML_STREAM() << L"Theme " << i; - } - } - for (size_t i = 1; i <= m_pDocument->m_arSlides.size(); ++i) - { - CP_XML_NODE(L"vt:lpstr") - { - CP_XML_STREAM() << L"Slide " << i; - } - } - } - } - - //CP_XML_NODE(L"Company"); - CP_XML_NODE(L"LinksUpToDate") - { - CP_XML_STREAM() << L"false"; - } - CP_XML_NODE(L"SharedDoc") - { - CP_XML_STREAM() << L"false"; - } - CP_XML_NODE(L"HyperlinksChanged") - { - CP_XML_STREAM() << L"false"; - } - } - } - oFile.WriteStringUTF8(L""); - oFile.WriteStringUTF8(strm.str()); -} - -void PPT_FORMAT::CPPTXWriter::WritePresInfo() -{ - CFile oFile; - -// tableStyles.xml - oFile.CreateFile(m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("tableStyles.xml")); - - oFile.WriteStringUTF8(L"\ - "); - oFile.CloseFile(); - -// presProps.xml - oFile.CreateFile(m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("presProps.xml")); - oFile.WriteStringUTF8(L"\ - \ - \ - \ - \ - \ - "); - oFile.CloseFile(); - -// viewProps.xml - oFile.CreateFile(m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("viewProps.xml")); - oFile.WriteStringUTF8(L"\ - \ - \ - \ - \ - "); - oFile.CloseFile(); - - // presentation.xml + _rels/presentation.xml.rels - std::wstring strPresRels; - - std::wstring strPresMasters; - std::wstring strPresSlides; - std::wstring strNotesIDs; - std::wstring strHandoutIDs; - - size_t nCountLayouts = 0; - - for (size_t nIndexTheme = 0; nIndexTheme < m_pDocument->m_arThemes.size(); ++nIndexTheme) - { - strPresRels += L""; - - strPresRels += L""; - - strPresMasters += L""; - - nCountLayouts += m_pDocument->m_arThemes[nIndexTheme]->m_arLayouts.size(); - nCountLayouts += 1; - } - - int nCurrentRels = (int)(2 * m_pDocument->m_arThemes.size() + 1); - - if (m_pDocument->m_pNotesMaster) - { - strNotesIDs = L""; - strPresRels += L""; - ++nCurrentRels; - } - if (m_pDocument->m_pHandoutMaster) - { - strHandoutIDs = L""; - strPresRels += L""; - ++nCurrentRels; - } - for (size_t nIndexSlide = 0; nIndexSlide < m_pDocument->m_arSlides.size(); ++nIndexSlide, ++nCurrentRels) - { - strPresRels += L""; - - strPresSlides += L""; - } - - strPresRels += L""; - strPresRels += L""; - strPresRels += L""; - - if (m_pDocument->m_bMacros) - { - std::wstring strVbaProject = m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("vbaProject.bin"); - - if (CDirectory::CopyFile(m_pDocument->m_sVbaProjectFile, strVbaProject)) - { - strPresRels += L""; - } - } - strPresRels = L"" - + strPresRels + L""; - - std::wstring strPptRels = m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("_rels"); - - NSDirectory::CreateDirectory(strPptRels); - oFile.CreateFile(strPptRels + FILE_SEPARATOR_STR + _T("presentation.xml.rels")); - oFile.WriteStringUTF8(strPresRels); - oFile.CloseFile(); - - std::wstring strSizePres = L"m_lSlideWidth) + - L"\" cy=\"" + std::to_wstring(m_pDocument->m_lSlideHeight) + - L"\" type=\"screen4x3\" />m_lNotesWidth) + - L"\" cy=\"" + std::to_wstring(m_pDocument->m_lNotesHeight) + L"\"/>"; - - std::wstring strDefaultTextStyle = _T(""); - - if (false == m_pDocument->m_arThemes.empty()) - { - CStylesWriter styleWriter(m_pDocument->m_arThemes[0].get()); - strDefaultTextStyle += styleWriter.ConvertStyles(m_pDocument->m_arThemes[0]->m_pStyles[0], 9); - } - strDefaultTextStyle += _T(""); - - std::wstring strPres = _T(""); - strPres += _T("m_bRtl)) - { - strPres += _T(" rtl=\"1\""); - } - strPres += _T(">"); - strPres += _T("") + strPresMasters + _T(""); - strPres += strNotesIDs ; - strPres += strHandoutIDs ; - strPres +=_T("") + strPresSlides + _T(""); - strPres += strSizePres; - strPres += strDefaultTextStyle; - strPres +=_T(""); - - oFile.CreateFile(m_strTempDirectory+ FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("presentation.xml")); - oFile.WriteStringUTF8(strPres); - oFile.CloseFile(); -} - -void PPT_FORMAT::CPPTXWriter::WriteAll() -{ - std::wstring strPptDirectory = m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR ; - - NSDirectory::CreateDirectory(strPptDirectory + _T("media")); - NSDirectory::CreateDirectory(strPptDirectory + _T("theme")); - NSDirectory::CreateDirectory(strPptDirectory + _T("slideMasters")); - NSDirectory::CreateDirectory(strPptDirectory + _T("slideMasters") + FILE_SEPARATOR_STR + _T("_rels")); - NSDirectory::CreateDirectory(strPptDirectory + _T("slideLayouts")); - NSDirectory::CreateDirectory(strPptDirectory + _T("slideLayouts") + FILE_SEPARATOR_STR + _T("_rels")); - NSDirectory::CreateDirectory(strPptDirectory + _T("slides")); - NSDirectory::CreateDirectory(strPptDirectory + _T("slides") + FILE_SEPARATOR_STR + _T("_rels")); - - if (m_pDocument->m_pHandoutMaster) - { - NSDirectory::CreateDirectory(strPptDirectory + _T("handoutMasters")); - NSDirectory::CreateDirectory(strPptDirectory + _T("handoutMasters") + FILE_SEPARATOR_STR + _T("_rels")); - } - if (m_pDocument->m_pNotesMaster) - { - NSDirectory::CreateDirectory(strPptDirectory + _T("notesMasters")); - NSDirectory::CreateDirectory(strPptDirectory + _T("notesMasters") + FILE_SEPARATOR_STR + _T("_rels")); - } - if (!m_pDocument->m_arNotes.empty()) - { - NSDirectory::CreateDirectory(strPptDirectory + _T("notesSlides")); - NSDirectory::CreateDirectory(strPptDirectory + _T("notesSlides") + FILE_SEPARATOR_STR + _T("_rels")); - } - WriteThemes(); - - WriteSlides(); - WriteNotes(); -} - -void PPT_FORMAT::CPPTXWriter::WriteThemes() -{ - int nStartLayout = 0, nIndexTheme = 0; - - for (size_t i = 0; i < m_pDocument->m_arThemes.size(); i++) - { - m_pShapeWriter->m_pTheme = m_pDocument->m_arThemes[i].get(); - WriteTheme(m_pDocument->m_arThemes[i], nIndexTheme, nStartLayout); - m_pShapeWriter->m_pTheme = NULL; - } - - WriteTheme(m_pDocument->m_pNotesMaster, nIndexTheme, nStartLayout); - WriteTheme(m_pDocument->m_pHandoutMaster, nIndexTheme, nStartLayout); -} - -void PPT_FORMAT::CPPTXWriter::WriteTheme(CThemePtr pTheme, int & nIndexTheme, int & nStartLayout) -{ - if (!pTheme) return; - - std::wstring strPptDirectory = m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR ; - - std::wstring strThemeFile = L"theme" + std::to_wstring(nIndexTheme + 1) + L".xml"; - strThemeFile = strPptDirectory + _T("theme") + FILE_SEPARATOR_STR + strThemeFile; - - CFile oFile; - oFile.CreateFile(strThemeFile); - - PPT_FORMAT::CStringWriter oStringWriter; - - oStringWriter.WriteString(std::wstring(L"m_sThemeName); - oStringWriter.WriteString(std::wstring(L"\">")); - - WriteColorScheme(oStringWriter, L"Default", pTheme->m_arColorScheme); - - oStringWriter.WriteString(std::wstring(L"m_arFonts[0].Name); - oStringWriter.WriteString(std::wstring(L"\"/>")); - - oStringWriter.WriteString(std::wstring(L"m_arFonts.size() > 1 ) oStringWriter.WriteString (pTheme->m_arFonts[1].Name); - else oStringWriter.WriteStringXML(pTheme->m_arFonts[0].Name); - - oStringWriter.WriteString(std::wstring(L"\"/>")); - oStringWriter.WriteString(std::wstring(L"")); - - oStringWriter.WriteString(std::wstring(L"\ -\ -\ -\ -\ -\ -\ -\ -\ -\ -\ -\ -\ -\ -\ -\ -\ -\ -\ -\ -\ -\ -\ -\ -\ -")); - - oStringWriter.WriteString(std::wstring(L"")); - oStringWriter.WriteString(std::wstring(L"")); - - for (size_t i = 0 ; i < pTheme->m_arExtraColorScheme.size(); i++) - { - std::wstring str = L" " + std::to_wstring(i + 1); - WriteColorScheme(oStringWriter, pTheme->m_sThemeName + str, pTheme->m_arExtraColorScheme[i], true); //extra - } - - oStringWriter.WriteString(std::wstring(L"")); - oStringWriter.WriteString(std::wstring(L"")); - - oFile.WriteStringUTF8(oStringWriter.GetData()); - oFile.CloseFile(); - - CRelsGenerator oRels(&m_oManager); - int nCountLayouts = (int)pTheme->m_arLayouts.size(); - oRels.StartMaster(nIndexTheme, nStartLayout, nCountLayouts); - - CStringWriter oWriter; - oWriter.WriteString(L""); - - if (pTheme->m_eType == typeMaster) - { - oWriter.WriteString(L""); - } - else if (pTheme->m_eType == typeNotesMaster) - { - oWriter.WriteString(L""); - } - else if (pTheme->m_eType == typeHandoutMaster) - { - oWriter.WriteString(L""); - } - oWriter.WriteString(L""); - - if (pTheme->m_bIsBackground) - { - WriteBackground(oWriter, oRels, pTheme->m_oBackground); - } - oWriter.WriteString(L"\ -"); - - CGroupElement *pGroupElement = !pTheme->m_arElements.empty() ? dynamic_cast(pTheme->m_arElements[0].get()) : NULL; - - size_t start_index = 0; - if (pGroupElement) - { - for (size_t i = 0; i < pGroupElement->m_pChildElements.size(); ++i) - { - if (isBodyPlaceholder(pGroupElement->m_pChildElements[i]->m_lPlaceholderType)) - pGroupElement->m_pChildElements[i]->m_lPlaceholderType = 100; //body тип прописывать !! - - //if (pGroupElement->m_pChildElements[i]->m_bAnchorEnabled == false && - // pGroupElement->m_pChildElements[i]->m_bChildAnchorEnabled == false) - // continue; - - //if (pTheme->m_eType == typeNotesMaster) - //{ - // pGroupElement->m_pChildElements[i]->m_lPlaceholderID = -1; - //} - //else if (pTheme->m_eType == typeHandoutMaster) - //{ - // pGroupElement->m_pChildElements[i]->m_lPlaceholderID = -1; - // pGroupElement->m_pChildElements[i]->m_lPlaceholderSizePreset = -1; - //} - WriteElement(oWriter, oRels, pGroupElement->m_pChildElements[i]); - } - - start_index = 1; - } - - for (size_t i = start_index; i < pTheme->m_arElements.size(); ++i) - { - if (isBodyPlaceholder(pTheme->m_arElements[i]->m_lPlaceholderType)) - pTheme->m_arElements[i]->m_lPlaceholderType = 100; //body тип прописывать !! - - //if (pTheme->m_arElements[i]->m_bAnchorEnabled == false && - // pTheme->m_arElements[i]->m_bChildAnchorEnabled == false) - // continue; - - //if (pTheme->m_eType == typeNotesMaster) - //{ - // pTheme->m_arElements[i]->m_lPlaceholderID = -1; - //} - //else if (pTheme->m_eType == typeHandoutMaster) - //{ - // pTheme->m_arElements[i]->m_lPlaceholderID = -1; - // pTheme->m_arElements[i]->m_lPlaceholderSizePreset = -1; - //} - - WriteElement(oWriter, oRels, pTheme->m_arElements[i]); - } - - oWriter.WriteString(std::wstring(L"")); - - std::wstring strOverrideColorScheme = _T(""); - oWriter.WriteString(strOverrideColorScheme); - - if (pTheme->m_eType == typeMaster) - { - oWriter.WriteString(std::wstring(L"")); - - size_t __nCountLayouts = 0; - for (int nIndexLayout = 0; nIndexLayout < nCountLayouts; ++nIndexLayout) - { - oWriter.WriteString(L""); - - WriteLayout(pTheme->m_arLayouts[nIndexLayout], nIndexLayout, nStartLayout, nIndexTheme); - } - - oWriter.WriteString(std::wstring(L"")); - } - - if (pTheme->m_bHasDate || pTheme->m_bHasFooter || pTheme->m_bHasSlideNumber) - { - oWriter.WriteString(std::wstring(L"m_bHasDate) oWriter.WriteString(std::wstring(L" dt=\"0\"")); - if (!pTheme->m_bHasSlideNumber) oWriter.WriteString(std::wstring(L" sldNum=\"0\"")); - oWriter.WriteString(std::wstring(L" hdr=\"0\"")); - if (!pTheme->m_bHasFooter) oWriter.WriteString(std::wstring(L" ftr=\"0\"")); - oWriter.WriteString(std::wstring(L"/>")); - } - CStylesWriter styleWriter; - styleWriter.m_pTheme = pTheme.get(); - - if (pTheme->m_eType == typeMaster) - { - oWriter.WriteString(std::wstring(L"")); - - oWriter.WriteString(std::wstring(L"")); - styleWriter.ConvertStyles(pTheme->m_pStyles[1], oWriter, 9); - oWriter.WriteString(std::wstring(L"")); - - oWriter.WriteString(std::wstring(L"")); - styleWriter.ConvertStyles(pTheme->m_pStyles[2], oWriter, 9); - oWriter.WriteString(std::wstring(L"")); - - oWriter.WriteString(std::wstring(L"")); - styleWriter.ConvertStyles(pTheme->m_pStyles[3], oWriter, 9); - oWriter.WriteString(std::wstring(L"")); - - oWriter.WriteString(std::wstring(L"")); - } - else if (pTheme->m_eType == typeNotesMaster) - { - oWriter.WriteString(std::wstring(L"")); - styleWriter.ConvertStyles(pTheme->m_pStyles[1], oWriter, 9); - oWriter.WriteString(std::wstring(L"")); - } - - std::wstring strSlideMasterFile; - std::wstring strSlideMasterRelsFile; - if (pTheme->m_eType == typeMaster) - { - oWriter.WriteString(std::wstring(L"")); - - strSlideMasterFile = L"slideMaster" + std::to_wstring(nIndexTheme + 1) + L".xml"; - strSlideMasterFile = strPptDirectory + _T("slideMasters") + FILE_SEPARATOR_STR + strSlideMasterFile; - - strSlideMasterRelsFile = L"slideMaster" + std::to_wstring(nIndexTheme + 1) + L".xml.rels"; - strSlideMasterRelsFile = strPptDirectory + _T("slideMasters") + FILE_SEPARATOR_STR + _T("_rels") + FILE_SEPARATOR_STR + strSlideMasterRelsFile; - } - else if (pTheme->m_eType == typeNotesMaster) - { - oWriter.WriteString(std::wstring(L"")); - - strSlideMasterFile = L"notesMaster1.xml"; - strSlideMasterFile = strPptDirectory + _T("notesMasters") + FILE_SEPARATOR_STR + strSlideMasterFile; - - strSlideMasterRelsFile = L"notesMaster1.xml.rels"; - strSlideMasterRelsFile = strPptDirectory + _T("notesMasters") + FILE_SEPARATOR_STR + _T("_rels") + FILE_SEPARATOR_STR + strSlideMasterRelsFile; - } - else if (pTheme->m_eType == typeHandoutMaster) - { - oWriter.WriteString(std::wstring(L"")); - - strSlideMasterFile = L"handoutMaster1.xml"; - strSlideMasterFile = strPptDirectory + _T("handoutMasters") + FILE_SEPARATOR_STR + strSlideMasterFile; - - strSlideMasterRelsFile = L"handoutMaster1.xml.rels"; - strSlideMasterRelsFile = strPptDirectory + _T("handoutMasters") + FILE_SEPARATOR_STR + _T("_rels") + FILE_SEPARATOR_STR + strSlideMasterRelsFile; - } - oFile.CreateFile(strSlideMasterFile); - std::wstring strMaster = oWriter.GetData(); - oFile.WriteStringUTF8(strMaster); - oFile.CloseFile(); - - oRels.CloseRels(); - oRels.SaveRels(strSlideMasterRelsFile); - - nStartLayout += nCountLayouts; - nIndexTheme++; -} - -void PPT_FORMAT::CPPTXWriter::WriteColorScheme(CStringWriter& oStringWriter, const std::wstring & name, const std::vector & colors, bool extra) -{ - if (colors.size() < 1) - { - oStringWriter.WriteString(L"\ - \ - \ - \ - \ - "); - return; - } - - if (extra) - oStringWriter.WriteString(L""); - - oStringWriter.WriteString(L""); - - oStringWriter.WriteString(L""); - - oStringWriter.WriteString(L""); - - oStringWriter.WriteString(L""); - - oStringWriter.WriteString(L""); - - oStringWriter.WriteString(L""); - - oStringWriter.WriteString(L""); - - oStringWriter.WriteString(L""); - - oStringWriter.WriteString(L""); - - oStringWriter.WriteString(L""); - - oStringWriter.WriteString(L""); - - oStringWriter.WriteString(L""); - - oStringWriter.WriteString(L""); - - oStringWriter.WriteString(L""); - if (extra) - { - oStringWriter.WriteString(L""); - oStringWriter.WriteString(L""); - } -} - -void PPT_FORMAT::CPPTXWriter::WriteBackground(CStringWriter& oWriter, CRelsGenerator& oRels, CBrush& oBackground) -{ - oWriter.WriteString(std::wstring(L"")); - - m_pShapeWriter->SetRelsGenerator(&oRels); - { - oWriter.WriteString(m_pShapeWriter->ConvertBrush(oBackground)); - } - oWriter.WriteString(std::wstring(L"")); -} -void PPT_FORMAT::CPPTXWriter::WriteGroup(CStringWriter& oWriter, CRelsGenerator& oRels, CElementPtr pElement, CLayout* pLayout) -{ - CGroupElement *pGroupElement = dynamic_cast(pElement.get()); - - m_pShapeWriter->SetElement(pElement); - oWriter.WriteString(m_pShapeWriter->ConvertGroup()); - - for (size_t i = 0; i < pGroupElement->m_pChildElements.size(); i++) - { - WriteElement(oWriter, oRels, pGroupElement->m_pChildElements[i], pLayout); - } - oWriter.WriteString(L""); -} -void PPT_FORMAT::CPPTXWriter::WriteTable(CStringWriter& oWriter, CRelsGenerator& oRels, CElementPtr pElement, CLayout* pLayout) -{ - CTableElement *pTableElement = dynamic_cast(pElement.get()); - - if (!pTableElement) - return; - - PPTX::Logic::GraphicFrame gf; - TableWriter(pTableElement).Convert(gf); - oWriter.WriteString(gf.toXML()); -} -void PPT_FORMAT::CPPTXWriter::WriteElement(CStringWriter& oWriter, CRelsGenerator& oRels, CElementPtr pElement, CLayout* pLayout) -{ - if (!pElement) return; - - CGroupElement *pGroupElement = dynamic_cast(pElement.get()); - CTableElement *pTableElement = dynamic_cast(pElement.get()); - - if (pTableElement) - { - return WriteTable(oWriter, oRels, pElement, pLayout); - } - if (pGroupElement) - { - return WriteGroup(oWriter, oRels, pElement, pLayout); - } - - bool bObject = m_pShapeWriter->SetElement(pElement); - - if (bObject) - { - m_pShapeWriter->SetRelsGenerator(&oRels); - - if (NULL != pLayout) - { - if (-1 != pElement->m_lPlaceholderType) - { - size_t nCountElements = pLayout->m_arElements.size(); - for (size_t nIndex = 0; nIndex < nCountElements; ++nIndex) - { - if ((pElement->m_lPlaceholderType == pLayout->m_arElements[nIndex]->m_lPlaceholderType) && - (pElement->m_lPlaceholderID == pLayout->m_arElements[nIndex]->m_lPlaceholderID)) - { - CElementPtr pElLayout = pLayout->m_arElements[nIndex]; - - bool bIsEqualTransform = ((pElement->m_dRotate == pElLayout->m_dRotate) - && (pElement->m_bFlipH == pElLayout->m_bFlipH) && (pElement->m_bFlipV == pElLayout->m_bFlipV)); - - if (bIsEqualTransform) - { - if (pElement->m_bAnchorEnabled == pElLayout->m_bAnchorEnabled && pElLayout->m_bAnchorEnabled == true) - { - if (pElement->m_rcAnchor.IsEqual(pElLayout->m_rcAnchor, 0.5)) - pElement->m_bAnchorEnabled = false; - } - if (pElement->m_bChildAnchorEnabled == pElLayout->m_bChildAnchorEnabled && pElLayout->m_bChildAnchorEnabled == true) - { - if (pElement->m_rcChildAnchor.IsEqual(pElLayout->m_rcChildAnchor, 0.5)) - pElement->m_bChildAnchorEnabled = false; - } - } - - break; - } - } - } - } - oWriter.WriteString(m_pShapeWriter->ConvertShape()); - } -} - -void PPT_FORMAT::CPPTXWriter::WriteLayout(CLayoutPtr pLayout, int nIndexLayout, int nStartLayout, int nIndexTheme) -{ - if (!pLayout) return; - - CStringWriter oWriter; - - CRelsGenerator oRels(&m_oManager); - oRels.StartLayout(nIndexTheme); - - oWriter.WriteString(std::wstring(L"")); - - oWriter.WriteString(std::wstring(L"m_strLayoutType + _T("\"")); - oWriter.WriteString(std::wstring(L" showMasterSp=\"") + (pLayout->m_bShowMasterShapes ? _T("1") : _T("0"))); - oWriter.WriteString(std::wstring(L"\" preserve=\"1\">m_sName.empty() == false) - oWriter.WriteString(std::wstring(L" name=\"") + pLayout->m_sName + std::wstring(L"\"")); - oWriter.WriteString(std::wstring(L">")); - - if (pLayout->m_bIsBackground) - { - WriteBackground(oWriter, oRels, pLayout->m_oBackground); - } - - std::wstring strElems = _T("\ -"); - oWriter.WriteString(strElems); - - size_t start_index = 0; - - if (pLayout->m_bIsTitleMaster) - { - CGroupElement *pGroupElement = (!pLayout->m_arElements.empty()) ? dynamic_cast(pLayout->m_arElements[0].get()) : NULL; - - if (pGroupElement) - { - for (size_t i = 0; i < pGroupElement->m_pChildElements.size(); ++i) - { - WriteElement(oWriter, oRels, pGroupElement->m_pChildElements[i]); - } - - start_index = 1; - } - } - - for (size_t i = start_index; i < pLayout->m_arElements.size(); ++i) - { - WriteElement(oWriter, oRels, pLayout->m_arElements[i]); - } - oWriter.WriteString(std::wstring(L"")); - - oWriter.WriteString(std::wstring(L"")); - oWriter.WriteString(std::wstring(L"")); - - oRels.CloseRels(); - - std::wstring strXml = oWriter.GetData(); - std::wstring strFile = L"slideLayout" + std::to_wstring(nIndexLayout + nStartLayout + 1) + L".xml"; - - CFile oFile; - std::wstring strFileLayoutPath= m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("slideLayouts") + FILE_SEPARATOR_STR; - oFile.CreateFile(strFileLayoutPath + strFile); - oFile.WriteStringUTF8(strXml); - oFile.CloseFile(); - - strFile = L"slideLayout" + std::to_wstring(nIndexLayout + nStartLayout + 1) + L".xml.rels"; - oRels.SaveRels(strFileLayoutPath + _T("_rels") + FILE_SEPARATOR_STR + strFile); -} -void PPT_FORMAT::CPPTXWriter::WriteSlide(int nIndexSlide) -{ - CStringWriter oWriter; - CRelsGenerator oRels(&m_oManager); - - CSlide* pSlide = m_pDocument->m_arSlides[nIndexSlide]; - - if (0 == pSlide->m_lThemeID) - oRels.StartSlide(pSlide->m_lLayoutID, pSlide->m_lNotesID); - else - { - int nLayout = pSlide->m_lLayoutID; - for (int i = 0; i < pSlide->m_lThemeID; ++i) - { - nLayout += (int)m_pDocument->m_arThemes[i]->m_arLayouts.size(); - } - - oRels.StartSlide(nLayout, pSlide->m_lNotesID); - } - - oWriter.WriteString(std::wstring(L"")); - oWriter.WriteString(std::wstring(L"m_bShowMasterShapes) - oWriter.WriteString(std::wstring(L" showMasterSp=\"0\"")); - oWriter.WriteString(std::wstring(L">")); - - oWriter.WriteString(std::wstring(L"m_sName.empty() == false) - oWriter.WriteString(std::wstring(L" name=\"") + pSlide->m_sName + std::wstring(L"\"")); - - oWriter.WriteString(std::wstring(L">")); - - if (pSlide->m_bIsBackground) - { - WriteBackground(oWriter, oRels, pSlide->m_oBackground); - } - - oWriter.WriteString(std::wstring(L"\ -")); - - CGroupElement *pGroupElement = !pSlide->m_arElements.empty() ? dynamic_cast(pSlide->m_arElements[0].get()) : NULL; - - size_t start_index = 0; - - if (pGroupElement) - { - for (size_t i = 0; i < pGroupElement->m_pChildElements.size(); ++i) - { - WriteElement(oWriter, oRels, pGroupElement->m_pChildElements[i]); - } - - start_index = 1; - } - - for (size_t i = start_index; i < pSlide->m_arElements.size(); ++i) - { - WriteElement(oWriter, oRels, pSlide->m_arElements[i]); - } - - oWriter.WriteString(std::wstring(L"")); - - oWriter.WriteString(std::wstring(L"")); - - WriteTransition(oWriter, pSlide->m_oSlideShow); - - // TODO write new method and class for timing - WriteTiming(oWriter, oRels, nIndexSlide); - - - oWriter.WriteString(std::wstring(L"")); - - - - - oRels.CloseRels(); - - std::wstring strXml = oWriter.GetData(); - std::wstring strFile = L"slide" + std::to_wstring(nIndexSlide + 1) + L".xml"; - std::wstring strFileSlidePath= m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("slides") + FILE_SEPARATOR_STR; - - CFile oFile; - oFile.CreateFile(strFileSlidePath + strFile); - oFile.WriteStringUTF8(strXml); - oFile.CloseFile(); - - strFile = L"slide" + std::to_wstring(nIndexSlide + 1) + L".xml.rels"; - oRels.SaveRels(strFileSlidePath + _T("_rels") + FILE_SEPARATOR_STR + strFile); -} - -void PPT_FORMAT::CPPTXWriter::WriteTransition(CStringWriter& oWriter, CSlideShowInfo &oSSInfo) -{ - CTransition& transition = oSSInfo.m_oTransition; - - if (transition.m_nEffectType == 0xFF) return; - - std::wstring type; - - std::wstring param_name, param_value; - std::wstring param_name2, param_value2; - - switch(transition.m_nEffectType) - { - case 0: - { - type = L"p:cut"; - param_name = L"thruBlk"; - param_value = transition.m_nEffectDirection ? L"true" : L"false"; - }break; - case 1: - { - type = L"p:random"; - }break; - case 2: - { - type = L"p:blinds"; - param_name = L"dir"; - param_value = transition.m_nEffectDirection ? L"vert" : L"horz"; - }break; - case 3: - { - type = L"p:checker"; - param_name = L"dir"; - param_value = transition.m_nEffectDirection ? L"vert" : L"horz"; - }break; - case 5: - { - type = L"p:dissolve"; - param_name = L"thruBlk"; - param_value = transition.m_nEffectDirection ? L"true" : L"false"; - }break; - case 6: - { - type = L"p:fade"; - param_name = L"thruBlk"; - param_value = transition.m_nEffectDirection ? L"true" : L"false"; - }break; - case 4: - case 7: - { - if (transition.m_nEffectType == 4) type = L"p:cover"; - if (transition.m_nEffectType == 7) type = L"p:pull"; - param_name = L"dir"; - switch(transition.m_nEffectDirection) - { - case 0: param_value = L"r"; break; - case 1: param_value = L"b"; break; - case 2: param_value = L"l"; break; - case 3: param_value = L"t"; break; - case 4: param_value = L"br"; break; - case 5: param_value = L"bl"; break; - case 6: param_value = L"tr"; break; - case 7: param_value = L"tl"; break; - } - }break; - case 8: - { - type = L"p:randomBars"; - param_name = L"dir"; - param_value = transition.m_nEffectDirection ? L"vert" : L"horz"; - }break; - case 9: - { - type = L"p:strips"; - param_name = L"dir"; - switch(transition.m_nEffectDirection) - { - case 0: param_value = L"ru"; break; - case 1: param_value = L"lu"; break; - case 2: param_value = L"rd"; break; - case 3: param_value = L"ld"; break; - } - }break; - case 10: - case 20: - { - if (transition.m_nEffectType == 10) type = L"p:wipe"; - if (transition.m_nEffectType == 20) type = L"p:push"; - - param_name = L"dir"; - switch(transition.m_nEffectDirection) - { - case 0: param_value = L"l"; break; - case 1: param_value = L"u"; break; - case 2: param_value = L"r"; break; - case 3: param_value = L"d"; break; - } - }break; - case 11: - { - type = L"p:zoom"; - param_name = L"dir"; - param_value = transition.m_nEffectDirection ? L"in" : L"out"; - }break; - case 13: - { - type = L"p:split"; - param_name = L"dir"; - param_name2 = L"orient"; - switch(transition.m_nEffectDirection) - { - case 0: param_value2 = L"horz"; param_value = L"out"; break; - case 1: param_value2 = L"horz"; param_value = L"in"; break; - case 2: param_value2 = L"vert"; param_value = L"out"; break; - case 3: param_value2 = L"vert"; param_value = L"in"; break; - } - }break; - case 17: - { - type = L"p:diamond"; - }break; - case 18: - { - type = L"p:plus"; - }break; - case 19: - { - type = L"p:wedge"; - }break; - - case 21: - { - type = L"p:comb"; - param_name = L"dir"; - param_value = transition.m_nEffectDirection ? L"vert" : L"horz"; - }break; - case 22: - { - type = L"p:newsflash"; - }break; - case 23: - { - type = L"p:fade"; - // p:alphaFade - }break; - case 26: - { - type = L"p:wheel"; - param_name = L"spokes"; - param_value = std::to_wstring(transition.m_nEffectDirection); - }break; - case 27: - { - type = L"p:circle"; - }break; - default: - break; - } - - if (type.empty()) return; - oWriter.WriteString(std::wstring(L""); - oWriter.WriteString(L"<" + type); - if (!param_name.empty() && !param_value.empty()) - { - oWriter.WriteString(L" " + param_name + L"=\"" + param_value + L"\""); - } - if (!param_name2.empty() && !param_value2.empty()) - { - oWriter.WriteString(L" " + param_name2 + L"=\"" + param_value2 + L"\""); - } - oWriter.WriteString(L"/>"); - if (transition.m_bAudioPresent) - { - bool bExternal = false; - std::wstring rId = m_pShapeWriter->m_pRels->WriteAudio(transition.m_oAudio.m_strAudioFileName, bExternal); - oWriter.WriteString(std::wstring(L"")); - oWriter.WriteString(L""); - oWriter.WriteString(std::wstring(L"")); - } - oWriter.WriteString(std::wstring(L"")); -} - -void PPT_FORMAT::CPPTXWriter::WriteNotes(int nIndexNotes) -{ - CStringWriter oWriter; - CRelsGenerator oRels(&m_oManager); - - CSlide* pNotes = m_pDocument->m_arNotes[nIndexNotes]; - - oRels.StartNotes(pNotes->m_lSlideID, m_pDocument->m_pNotesMaster != NULL); - - oWriter.WriteString(std::wstring(L"")); - oWriter.WriteString(std::wstring(L"m_bShowMasterShapes) - oWriter.WriteString(std::wstring(L" showMasterSp=\"0\"")); - oWriter.WriteString(std::wstring(L">")); - - oWriter.WriteString(std::wstring(L"")); - - if (pNotes->m_bIsBackground) - { - WriteBackground(oWriter, oRels, pNotes->m_oBackground); - } - - oWriter.WriteString(std::wstring(L"\ -")); - - CGroupElement *pGroupElement = !pNotes->m_arElements.empty() ? dynamic_cast(pNotes->m_arElements[0].get()) : NULL; - - size_t start_index = 0; - - if (pGroupElement) - { - for (size_t i = 0; i < pGroupElement->m_pChildElements.size(); ++i) - { - WriteElement(oWriter, oRels, pGroupElement->m_pChildElements[i]); - } - - start_index = 1; - } - - for (size_t i = start_index; i < pNotes->m_arElements.size(); ++i) - { - WriteElement(oWriter, oRels, pNotes->m_arElements[i]); - } - - oWriter.WriteString(std::wstring(L"")); - - oWriter.WriteString(std::wstring(L"")); - oWriter.WriteString(std::wstring(L"")); - - oRels.CloseRels(); - - std::wstring strXml = oWriter.GetData(); - std::wstring strFile = L"notesSlide" + std::to_wstring(nIndexNotes + 1) + L".xml"; - std::wstring strFileSlidePath = m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("notesSlides") + FILE_SEPARATOR_STR; - - CFile oFile; - oFile.CreateFile(strFileSlidePath + strFile); - oFile.WriteStringUTF8(strXml); - oFile.CloseFile(); - - strFile = L"notesSlide" + std::to_wstring(nIndexNotes + 1) + L".xml.rels"; - oRels.SaveRels(strFileSlidePath + _T("_rels") + FILE_SEPARATOR_STR + strFile); -} - -void PPT_FORMAT::CPPTXWriter::WriteSlides() -{ - m_oManager.WriteAudioCollection(m_pUserInfo->m_oExMedia.m_arAudioCollection); - for (size_t nIndexS = 0; nIndexS < m_pDocument->m_arSlides.size(); ++nIndexS) - { - WriteSlide((int)nIndexS); - } -} -void PPT_FORMAT::CPPTXWriter::WriteNotes() -{ - for (size_t nIndexS = 0; nIndexS < m_pDocument->m_arNotes.size(); ++nIndexS) - { - WriteNotes((int)nIndexS); - } -} - - -void PPT_FORMAT::CPPTXWriter::WriteTiming(CStringWriter& oWriter, CRelsGenerator &oRels, int nIndexSlide) -{ - PPTX::Logic::Timing oTiming; - - auto slide_iter = m_pUserInfo->m_mapSlides.find(m_pUserInfo->m_arrSlidesOrder[nIndexSlide]); - // This part for new animation - CRecordSlideProgTagsContainer* progTag = slide_iter->second->m_pSlideProgTagsContainer; - CRecordPP10SlideBinaryTagExtension* pPP10SlideBinaryTag = progTag ? progTag->getPP10SlideBinaryTagExtension() : NULL; - // This part for old animation - std::vector arrShapeCont; - slide_iter->second->GetRecordsByType(&arrShapeCont, true); - std::vector arrOldAnim; - for (auto ShapeCont : arrShapeCont) - { - SOldAnimation oldAnim; - std::vector shape; - ShapeCont->GetRecordsByType(&shape, true); - std::vector anim; - ShapeCont->GetRecordsByType(&anim, true); - if (!anim.empty() && !shape.empty()) - { - oldAnim.shapeId = shape[0]->m_nID; - oldAnim.anim = anim[0]; - arrOldAnim.push_back(oldAnim); - } - } - - if (!pPP10SlideBinaryTag && arrOldAnim.empty()) - return; - - Animation animation(pPP10SlideBinaryTag, arrOldAnim, &(m_pUserInfo->m_oExMedia), &oRels); - - animation.Convert(oTiming); - oWriter.WriteString(oTiming.toXML()); - //oWriter.WriteString(std::wstring(L"")); - -} +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ +#pragma once + +#include "../../../ASCOfficePPTXFile/Editor/Drawing/Document.h" + +#include "../../../ASCOfficePPTXFile/Editor/DefaultNotesMaster.h" +#include "../../../ASCOfficePPTXFile/Editor/DefaultNotesTheme.h" + +#include "../../../Common/DocxFormat/Source/SystemUtility/SystemUtility.h" +#include "../../../ASCOfficeXlsFile2/source/Common/simple_xml_writer.h" +#include "../../../DesktopEditor/common/Directory.h" +#include "../../../DesktopEditor/common/SystemUtils.h" +#include "../../../OfficeUtils/src/OfficeUtils.h" +#include "boost/smart_ptr.hpp" +#include +#include "TableWriter.h" + +#include "../Reader/PPTDocumentInfo.h" + +#include "ShapeWriter.h" +#include "StylesWriter.h" + +#include "Converter.h" +#include "Animation.h" + +namespace PPT_FORMAT +{ + namespace NSPPTXWriterConst + { + static std::wstring g_string_rels_presentation = _T("\ +\ +\ +\ +\ +"); + + static std::wstring g_string_core = _T("\ +\ +Slide 1\ +1\ +"); + } +} + + +PPT_FORMAT::CPPTXWriter::CPPTXWriter() +{ + m_strTempDirectory = NSDirectory::GetTempPath() + FILE_SEPARATOR_STR + _T("TempPPTX"); + m_strDstFileName = NSDirectory::GetTempPath() + FILE_SEPARATOR_STR + _T("Test.pptx"); + + m_pDocument = NULL; + m_pUserInfo = NULL; + + m_pShapeWriter = new CShapeWriter(); +} + +PPT_FORMAT::CPPTXWriter::~CPPTXWriter() +{ + RELEASEOBJECT(m_pShapeWriter); +} + +void PPT_FORMAT::CPPTXWriter::CreateFile(CPPTUserInfo* pUserInfo ) +{ + m_pUserInfo = pUserInfo; + + m_pDocument = dynamic_cast(pUserInfo); + + m_oManager.Clear(); + m_oManager.SetDstMedia(m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("media") + FILE_SEPARATOR_STR); + + m_pShapeWriter->InitNextId(); + + NSDirectory::CreateDirectory(m_strTempDirectory); + CFile oFile; + std::wstring strMemory = _T(""); + + // _rels + NSDirectory::CreateDirectory(m_strTempDirectory + FILE_SEPARATOR_STR + _T("_rels")); + + oFile.CreateFile(m_strTempDirectory + FILE_SEPARATOR_STR + _T("_rels") + FILE_SEPARATOR_STR + _T(".rels")); + strMemory = NSPPTXWriterConst::g_string_rels_presentation; + oFile.WriteStringUTF8(strMemory); + oFile.CloseFile(); + + // docProps + NSDirectory::CreateDirectory(m_strTempDirectory + FILE_SEPARATOR_STR + _T("docProps")); + + // core + oFile.CreateFile(m_strTempDirectory + FILE_SEPARATOR_STR + _T("docProps") + FILE_SEPARATOR_STR + _T("core.xml")); + strMemory = NSPPTXWriterConst::g_string_core; + oFile.WriteStringUTF8(strMemory); + oFile.CloseFile(); + + // app + oFile.CreateFile(m_strTempDirectory + FILE_SEPARATOR_STR + _T("docProps") + FILE_SEPARATOR_STR + _T("app.xml")); + WriteApp(oFile); + oFile.CloseFile(); + + // content types + WriteContentTypes(); + + // ppt + NSDirectory::CreateDirectory(m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt")); + WritePresInfo(); + + WriteAll(); +} + +void PPT_FORMAT::CPPTXWriter::CreateFile(CDocument* pDocument) +{ + m_pDocument = pDocument; + m_oManager.Clear(); + m_oManager.SetDstMedia(m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("media") + FILE_SEPARATOR_STR); + + m_pShapeWriter->InitNextId(); + + NSDirectory::CreateDirectory(m_strTempDirectory); + CFile oFile; + std::wstring strMemory = _T(""); + + // _rels + NSDirectory::CreateDirectory(m_strTempDirectory + FILE_SEPARATOR_STR + _T("_rels")); + + oFile.CreateFile(m_strTempDirectory + FILE_SEPARATOR_STR + _T("_rels") + FILE_SEPARATOR_STR + _T(".rels")); + strMemory = NSPPTXWriterConst::g_string_rels_presentation; + oFile.WriteStringUTF8(strMemory); + oFile.CloseFile(); + + // docProps + NSDirectory::CreateDirectory(m_strTempDirectory + FILE_SEPARATOR_STR + _T("docProps")); + + // core + oFile.CreateFile(m_strTempDirectory + FILE_SEPARATOR_STR + _T("docProps") + FILE_SEPARATOR_STR + _T("core.xml")); + strMemory = NSPPTXWriterConst::g_string_core; + oFile.WriteStringUTF8(strMemory); + oFile.CloseFile(); + + // app + oFile.CreateFile(m_strTempDirectory + FILE_SEPARATOR_STR + _T("docProps") + FILE_SEPARATOR_STR + _T("app.xml")); + WriteApp(oFile); + oFile.CloseFile(); + + // content types + WriteContentTypes(); + + // ppt + NSDirectory::CreateDirectory(m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt")); + WritePresInfo(); + + WriteAll(); +} + +void PPT_FORMAT::CPPTXWriter::CloseFile() +{ + m_oManager.Clear(); +} + + +void PPT_FORMAT::CPPTXWriter::WriteContentTypes() +{ + std::wstring strContentTypes = L"\ +\ +\ +\ +\ +\ +\ +\ +\ +\ +\ +\ +\ +\ +\ +\ +\ +\ +\ +\ +\ +\ +"; + + if (m_pDocument->m_bMacros) + { + strContentTypes += L"\ +"; + } + else + { + strContentTypes += L""; + } + strContentTypes += L"\ +\ +\ +\ +"; + + int nIndexLayout = 1, nIndexTheme = 1; + + for (size_t nT = 0; nT < m_pDocument->m_arThemes.size(); nT++, nIndexTheme++) + { + strContentTypes += L""; + + strContentTypes += L""; + + + for (size_t nL = 0; nL < m_pDocument->m_arThemes[nT]->m_arLayouts.size(); nL++, nIndexLayout++) + { + strContentTypes += L""; + } + } + + if (m_pDocument->m_pNotesMaster) + { + strContentTypes += L""; + strContentTypes += L""; + } + if (m_pDocument->m_pHandoutMaster) + { + strContentTypes += L""; + strContentTypes += L""; + } + + for (size_t nS = 0; nS < m_pDocument->m_arSlides.size(); ++nS) + { + strContentTypes += L""; + } + + for (size_t nS = 0; nS < m_pDocument->m_arNotes.size(); ++nS) + { + strContentTypes += L""; + } + strContentTypes += _T(""); + + CFile oFile; + oFile.CreateFile(m_strTempDirectory + FILE_SEPARATOR_STR + _T("[Content_Types].xml")); + oFile.WriteStringUTF8(strContentTypes); + oFile.CloseFile(); +} + + +void PPT_FORMAT::CPPTXWriter::WriteApp(CFile& oFile) +{ + std::wstringstream strm; + + CP_XML_WRITER(strm) + { + CP_XML_NODE(L"Properties") + { + CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"); + CP_XML_ATTR(L"xmlns:vt", L"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"); + + CP_XML_NODE(L"TotalTime") + { + CP_XML_STREAM() << 0; + } + CP_XML_NODE(L"Words") + { + CP_XML_STREAM() << 0; + } + std::wstring sApplication = NSSystemUtils::GetEnvVariable(NSSystemUtils::gc_EnvApplicationName); + if (sApplication.empty()) + sApplication = NSSystemUtils::gc_EnvApplicationNameDefault; + #if defined(INTVER) + std::string s = VALUE2STR(INTVER); + sApplication += L"/" + std::wstring(s.begin(), s.end()); + #endif + CP_XML_NODE(L"Application") + { + CP_XML_STREAM() << sApplication; + } + //CP_XML_NODE(L"AppVersion") + //{ + // CP_XML_STREAM() << L"1.0"; + //} + CP_XML_NODE(L"Paragraphs") + { + CP_XML_STREAM() << 0; + } + CP_XML_NODE(L"PresentationFormat") + { + CP_XML_STREAM() << L"On-screen Show (4:3)"; + } + CP_XML_NODE(L"Slides") + { + CP_XML_STREAM() << m_pDocument->m_arSlides.size(); + } + CP_XML_NODE(L"Notes") + { + CP_XML_STREAM() << m_pDocument->m_arNotes.size(); + } + CP_XML_NODE(L"HiddenSlides") + { + CP_XML_STREAM() << 0; + } + CP_XML_NODE(L"MMClips") + { + CP_XML_STREAM() << 0; + } + CP_XML_NODE(L"ScaleCrop") + { + CP_XML_STREAM() << L"false"; + } + CP_XML_NODE(L"HeadingPairs") + { + CP_XML_NODE(L"vt:vector") + { + CP_XML_ATTR(L"size", 4); + CP_XML_ATTR(L"baseType", L"variant"); + + CP_XML_NODE(L"vt:variant") + { + CP_XML_NODE(L"vt:lpstr") + { + CP_XML_STREAM() << L"Theme"; + } + } + CP_XML_NODE(L"vt:variant") + { + CP_XML_NODE(L"vt:i4") + { + CP_XML_STREAM() << m_pDocument->m_arThemes.size(); + } + } + CP_XML_NODE(L"vt:variant") + { + CP_XML_NODE(L"vt:lpstr") + { + CP_XML_STREAM() << L"Slide Titles"; + } + } + CP_XML_NODE(L"vt:variant") + { + CP_XML_NODE(L"vt:i4") + CP_XML_STREAM() << m_pDocument->m_arSlides.size(); + } + } + } + CP_XML_NODE(L"TitlesOfParts") + { + CP_XML_NODE(L"vt:vector") + { + CP_XML_ATTR(L"size", m_pDocument->m_arSlides.size() + m_pDocument->m_arThemes.size()); + CP_XML_ATTR(L"baseType", L"lpstr"); + + for (size_t i = 1; i <= m_pDocument->m_arThemes.size(); ++i) + { + CP_XML_NODE(L"vt:lpstr") + { + CP_XML_STREAM() << L"Theme " << i; + } + } + for (size_t i = 1; i <= m_pDocument->m_arSlides.size(); ++i) + { + CP_XML_NODE(L"vt:lpstr") + { + CP_XML_STREAM() << L"Slide " << i; + } + } + } + } + + //CP_XML_NODE(L"Company"); + CP_XML_NODE(L"LinksUpToDate") + { + CP_XML_STREAM() << L"false"; + } + CP_XML_NODE(L"SharedDoc") + { + CP_XML_STREAM() << L"false"; + } + CP_XML_NODE(L"HyperlinksChanged") + { + CP_XML_STREAM() << L"false"; + } + } + } + oFile.WriteStringUTF8(L""); + oFile.WriteStringUTF8(strm.str()); +} + +void PPT_FORMAT::CPPTXWriter::WritePresInfo() +{ + CFile oFile; + +// tableStyles.xml + std::wstring zipPath = m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("tableStyles.zip"); + oFile.CreateFile(zipPath); + + std::vector vecTableStyles; + ((CPPTUserInfo*)(m_pDocument))->m_oDocument.GetRecordsByType(&vecTableStyles, false); + // Source + BYTE* tableStylesData = vecTableStyles[0]->data.first.get(); + ULONG tableStylesLen = vecTableStyles[0]->data.second; + oFile.WriteFile(tableStylesData, tableStylesLen); + oFile.CloseFile(); + + COfficeUtils officeUtils; + officeUtils.ExtractToDirectory(zipPath, m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt"), NULL, 1); + + + + +// presProps.xml + oFile.CreateFile(m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("presProps.xml")); + oFile.WriteStringUTF8(L"\ + \ + \ + \ + \ + \ + "); + oFile.CloseFile(); + +// viewProps.xml + oFile.CreateFile(m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("viewProps.xml")); + oFile.WriteStringUTF8(L"\ + \ + \ + \ + \ + "); + oFile.CloseFile(); + + // presentation.xml + _rels/presentation.xml.rels + std::wstring strPresRels; + + std::wstring strPresMasters; + std::wstring strPresSlides; + std::wstring strNotesIDs; + std::wstring strHandoutIDs; + + size_t nCountLayouts = 0; + + for (size_t nIndexTheme = 0; nIndexTheme < m_pDocument->m_arThemes.size(); ++nIndexTheme) + { + strPresRels += L""; + + strPresRels += L""; + + strPresMasters += L""; + + nCountLayouts += m_pDocument->m_arThemes[nIndexTheme]->m_arLayouts.size(); + nCountLayouts += 1; + } + + int nCurrentRels = (int)(2 * m_pDocument->m_arThemes.size() + 1); + + if (m_pDocument->m_pNotesMaster) + { + strNotesIDs = L""; + strPresRels += L""; + ++nCurrentRels; + } + if (m_pDocument->m_pHandoutMaster) + { + strHandoutIDs = L""; + strPresRels += L""; + ++nCurrentRels; + } + for (size_t nIndexSlide = 0; nIndexSlide < m_pDocument->m_arSlides.size(); ++nIndexSlide, ++nCurrentRels) + { + strPresRels += L""; + + strPresSlides += L""; + } + + strPresRels += L""; + strPresRels += L""; + strPresRels += L""; + + if (m_pDocument->m_bMacros) + { + std::wstring strVbaProject = m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("vbaProject.bin"); + + if (CDirectory::CopyFile(m_pDocument->m_sVbaProjectFile, strVbaProject)) + { + strPresRels += L""; + } + } + strPresRels = L"" + + strPresRels + L""; + + std::wstring strPptRels = m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("_rels"); + + NSDirectory::CreateDirectory(strPptRels); + oFile.CreateFile(strPptRels + FILE_SEPARATOR_STR + _T("presentation.xml.rels")); + oFile.WriteStringUTF8(strPresRels); + oFile.CloseFile(); + + std::wstring strSizePres = L"m_lSlideWidth) + + L"\" cy=\"" + std::to_wstring(m_pDocument->m_lSlideHeight) + + L"\" type=\"screen4x3\" />m_lNotesWidth) + + L"\" cy=\"" + std::to_wstring(m_pDocument->m_lNotesHeight) + L"\"/>"; + + std::wstring strDefaultTextStyle = _T(""); + + if (false == m_pDocument->m_arThemes.empty()) + { + CStylesWriter styleWriter(m_pDocument->m_arThemes[0].get()); + strDefaultTextStyle += styleWriter.ConvertStyles(m_pDocument->m_arThemes[0]->m_pStyles[0], 9); + } + strDefaultTextStyle += _T(""); + + std::wstring strPres = _T(""); + strPres += _T("m_bRtl)) + { + strPres += _T(" rtl=\"1\""); + } + strPres += _T(">"); + strPres += _T("") + strPresMasters + _T(""); + strPres += strNotesIDs ; + strPres += strHandoutIDs ; + strPres +=_T("") + strPresSlides + _T(""); + strPres += strSizePres; + strPres += strDefaultTextStyle; + strPres +=_T(""); + + oFile.CreateFile(m_strTempDirectory+ FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("presentation.xml")); + oFile.WriteStringUTF8(strPres); + oFile.CloseFile(); +} + +void PPT_FORMAT::CPPTXWriter::WriteAll() +{ + std::wstring strPptDirectory = m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR ; + + NSDirectory::CreateDirectory(strPptDirectory + _T("media")); + NSDirectory::CreateDirectory(strPptDirectory + _T("theme")); + NSDirectory::CreateDirectory(strPptDirectory + _T("slideMasters")); + NSDirectory::CreateDirectory(strPptDirectory + _T("slideMasters") + FILE_SEPARATOR_STR + _T("_rels")); + NSDirectory::CreateDirectory(strPptDirectory + _T("slideLayouts")); + NSDirectory::CreateDirectory(strPptDirectory + _T("slideLayouts") + FILE_SEPARATOR_STR + _T("_rels")); + NSDirectory::CreateDirectory(strPptDirectory + _T("slides")); + NSDirectory::CreateDirectory(strPptDirectory + _T("slides") + FILE_SEPARATOR_STR + _T("_rels")); + + if (m_pDocument->m_pHandoutMaster) + { + NSDirectory::CreateDirectory(strPptDirectory + _T("handoutMasters")); + NSDirectory::CreateDirectory(strPptDirectory + _T("handoutMasters") + FILE_SEPARATOR_STR + _T("_rels")); + } + if (m_pDocument->m_pNotesMaster) + { + NSDirectory::CreateDirectory(strPptDirectory + _T("notesMasters")); + NSDirectory::CreateDirectory(strPptDirectory + _T("notesMasters") + FILE_SEPARATOR_STR + _T("_rels")); + } + if (!m_pDocument->m_arNotes.empty()) + { + NSDirectory::CreateDirectory(strPptDirectory + _T("notesSlides")); + NSDirectory::CreateDirectory(strPptDirectory + _T("notesSlides") + FILE_SEPARATOR_STR + _T("_rels")); + } + WriteThemes(); + + WriteSlides(); + WriteNotes(); +} + +void PPT_FORMAT::CPPTXWriter::WriteThemes() +{ + int nStartLayout = 0, nIndexTheme = 0; + + for (size_t i = 0; i < m_pDocument->m_arThemes.size(); i++) + { + m_pShapeWriter->m_pTheme = m_pDocument->m_arThemes[i].get(); + WriteTheme(m_pDocument->m_arThemes[i], nIndexTheme, nStartLayout); + m_pShapeWriter->m_pTheme = NULL; + } + + WriteTheme(m_pDocument->m_pNotesMaster, nIndexTheme, nStartLayout); + WriteTheme(m_pDocument->m_pHandoutMaster, nIndexTheme, nStartLayout); +} + +void PPT_FORMAT::CPPTXWriter::WriteTheme(CThemePtr pTheme, int & nIndexTheme, int & nStartLayout) +{ + if (!pTheme) return; + + std::wstring strPptDirectory = m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR ; + + std::wstring strThemeFile = L"theme" + std::to_wstring(nIndexTheme + 1) + L".xml"; + strThemeFile = strPptDirectory + _T("theme") + FILE_SEPARATOR_STR + strThemeFile; + + CFile oFile; + oFile.CreateFile(strThemeFile); + + PPT_FORMAT::CStringWriter oStringWriter; + + oStringWriter.WriteString(std::wstring(L"m_sThemeName); + oStringWriter.WriteString(std::wstring(L"\">")); + + WriteColorScheme(oStringWriter, L"Default", pTheme->m_arColorScheme); + + oStringWriter.WriteString(std::wstring(L"m_arFonts[0].Name); + oStringWriter.WriteString(std::wstring(L"\"/>")); + + oStringWriter.WriteString(std::wstring(L"m_arFonts.size() > 1 ) oStringWriter.WriteString (pTheme->m_arFonts[1].Name); + else oStringWriter.WriteStringXML(pTheme->m_arFonts[0].Name); + + oStringWriter.WriteString(std::wstring(L"\"/>")); + oStringWriter.WriteString(std::wstring(L"")); + + oStringWriter.WriteString(std::wstring(L"\ +\ +\ +\ +\ +\ +\ +\ +\ +\ +\ +\ +\ +\ +\ +\ +\ +\ +\ +\ +\ +\ +\ +\ +\ +")); + + oStringWriter.WriteString(std::wstring(L"")); + oStringWriter.WriteString(std::wstring(L"")); + + for (size_t i = 0 ; i < pTheme->m_arExtraColorScheme.size(); i++) + { + std::wstring str = L" " + std::to_wstring(i + 1); + WriteColorScheme(oStringWriter, pTheme->m_sThemeName + str, pTheme->m_arExtraColorScheme[i], true); //extra + } + + oStringWriter.WriteString(std::wstring(L"")); + oStringWriter.WriteString(std::wstring(L"")); + + oFile.WriteStringUTF8(oStringWriter.GetData()); + oFile.CloseFile(); + + CRelsGenerator oRels(&m_oManager); + int nCountLayouts = (int)pTheme->m_arLayouts.size(); + oRels.StartMaster(nIndexTheme, nStartLayout, nCountLayouts); + + CStringWriter oWriter; + oWriter.WriteString(L""); + + if (pTheme->m_eType == typeMaster) + { + oWriter.WriteString(L""); + } + else if (pTheme->m_eType == typeNotesMaster) + { + oWriter.WriteString(L""); + } + else if (pTheme->m_eType == typeHandoutMaster) + { + oWriter.WriteString(L""); + } + oWriter.WriteString(L""); + + if (pTheme->m_bIsBackground) + { + WriteBackground(oWriter, oRels, pTheme->m_oBackground); + } + oWriter.WriteString(L"\ +"); + + CGroupElement *pGroupElement = !pTheme->m_arElements.empty() ? dynamic_cast(pTheme->m_arElements[0].get()) : NULL; + + size_t start_index = 0; + if (pGroupElement) + { + for (size_t i = 0; i < pGroupElement->m_pChildElements.size(); ++i) + { + if (isBodyPlaceholder(pGroupElement->m_pChildElements[i]->m_lPlaceholderType)) + pGroupElement->m_pChildElements[i]->m_lPlaceholderType = 100; //body тип прописывать !! + + //if (pGroupElement->m_pChildElements[i]->m_bAnchorEnabled == false && + // pGroupElement->m_pChildElements[i]->m_bChildAnchorEnabled == false) + // continue; + + //if (pTheme->m_eType == typeNotesMaster) + //{ + // pGroupElement->m_pChildElements[i]->m_lPlaceholderID = -1; + //} + //else if (pTheme->m_eType == typeHandoutMaster) + //{ + // pGroupElement->m_pChildElements[i]->m_lPlaceholderID = -1; + // pGroupElement->m_pChildElements[i]->m_lPlaceholderSizePreset = -1; + //} + WriteElement(oWriter, oRels, pGroupElement->m_pChildElements[i]); + } + + start_index = 1; + } + + for (size_t i = start_index; i < pTheme->m_arElements.size(); ++i) + { + if (isBodyPlaceholder(pTheme->m_arElements[i]->m_lPlaceholderType)) + pTheme->m_arElements[i]->m_lPlaceholderType = 100; //body тип прописывать !! + + //if (pTheme->m_arElements[i]->m_bAnchorEnabled == false && + // pTheme->m_arElements[i]->m_bChildAnchorEnabled == false) + // continue; + + //if (pTheme->m_eType == typeNotesMaster) + //{ + // pTheme->m_arElements[i]->m_lPlaceholderID = -1; + //} + //else if (pTheme->m_eType == typeHandoutMaster) + //{ + // pTheme->m_arElements[i]->m_lPlaceholderID = -1; + // pTheme->m_arElements[i]->m_lPlaceholderSizePreset = -1; + //} + + WriteElement(oWriter, oRels, pTheme->m_arElements[i]); + } + + oWriter.WriteString(std::wstring(L"")); + + std::wstring strOverrideColorScheme = _T(""); + oWriter.WriteString(strOverrideColorScheme); + + if (pTheme->m_eType == typeMaster) + { + oWriter.WriteString(std::wstring(L"")); + + size_t __nCountLayouts = 0; + for (int nIndexLayout = 0; nIndexLayout < nCountLayouts; ++nIndexLayout) + { + oWriter.WriteString(L""); + + WriteLayout(pTheme->m_arLayouts[nIndexLayout], nIndexLayout, nStartLayout, nIndexTheme); + } + + oWriter.WriteString(std::wstring(L"")); + } + + if (pTheme->m_bHasDate || pTheme->m_bHasFooter || pTheme->m_bHasSlideNumber) + { + oWriter.WriteString(std::wstring(L"m_bHasDate) oWriter.WriteString(std::wstring(L" dt=\"0\"")); + if (!pTheme->m_bHasSlideNumber) oWriter.WriteString(std::wstring(L" sldNum=\"0\"")); + oWriter.WriteString(std::wstring(L" hdr=\"0\"")); + if (!pTheme->m_bHasFooter) oWriter.WriteString(std::wstring(L" ftr=\"0\"")); + oWriter.WriteString(std::wstring(L"/>")); + } + CStylesWriter styleWriter; + styleWriter.m_pTheme = pTheme.get(); + + if (pTheme->m_eType == typeMaster) + { + oWriter.WriteString(std::wstring(L"")); + + oWriter.WriteString(std::wstring(L"")); + styleWriter.ConvertStyles(pTheme->m_pStyles[1], oWriter, 9); + oWriter.WriteString(std::wstring(L"")); + + oWriter.WriteString(std::wstring(L"")); + styleWriter.ConvertStyles(pTheme->m_pStyles[2], oWriter, 9); + oWriter.WriteString(std::wstring(L"")); + + oWriter.WriteString(std::wstring(L"")); + styleWriter.ConvertStyles(pTheme->m_pStyles[3], oWriter, 9); + oWriter.WriteString(std::wstring(L"")); + + oWriter.WriteString(std::wstring(L"")); + } + else if (pTheme->m_eType == typeNotesMaster) + { + oWriter.WriteString(std::wstring(L"")); + styleWriter.ConvertStyles(pTheme->m_pStyles[1], oWriter, 9); + oWriter.WriteString(std::wstring(L"")); + } + + std::wstring strSlideMasterFile; + std::wstring strSlideMasterRelsFile; + if (pTheme->m_eType == typeMaster) + { + oWriter.WriteString(std::wstring(L"")); + + strSlideMasterFile = L"slideMaster" + std::to_wstring(nIndexTheme + 1) + L".xml"; + strSlideMasterFile = strPptDirectory + _T("slideMasters") + FILE_SEPARATOR_STR + strSlideMasterFile; + + strSlideMasterRelsFile = L"slideMaster" + std::to_wstring(nIndexTheme + 1) + L".xml.rels"; + strSlideMasterRelsFile = strPptDirectory + _T("slideMasters") + FILE_SEPARATOR_STR + _T("_rels") + FILE_SEPARATOR_STR + strSlideMasterRelsFile; + } + else if (pTheme->m_eType == typeNotesMaster) + { + oWriter.WriteString(std::wstring(L"")); + + strSlideMasterFile = L"notesMaster1.xml"; + strSlideMasterFile = strPptDirectory + _T("notesMasters") + FILE_SEPARATOR_STR + strSlideMasterFile; + + strSlideMasterRelsFile = L"notesMaster1.xml.rels"; + strSlideMasterRelsFile = strPptDirectory + _T("notesMasters") + FILE_SEPARATOR_STR + _T("_rels") + FILE_SEPARATOR_STR + strSlideMasterRelsFile; + } + else if (pTheme->m_eType == typeHandoutMaster) + { + oWriter.WriteString(std::wstring(L"")); + + strSlideMasterFile = L"handoutMaster1.xml"; + strSlideMasterFile = strPptDirectory + _T("handoutMasters") + FILE_SEPARATOR_STR + strSlideMasterFile; + + strSlideMasterRelsFile = L"handoutMaster1.xml.rels"; + strSlideMasterRelsFile = strPptDirectory + _T("handoutMasters") + FILE_SEPARATOR_STR + _T("_rels") + FILE_SEPARATOR_STR + strSlideMasterRelsFile; + } + oFile.CreateFile(strSlideMasterFile); + std::wstring strMaster = oWriter.GetData(); + oFile.WriteStringUTF8(strMaster); + oFile.CloseFile(); + + oRels.CloseRels(); + oRels.SaveRels(strSlideMasterRelsFile); + + nStartLayout += nCountLayouts; + nIndexTheme++; +} + +void PPT_FORMAT::CPPTXWriter::WriteColorScheme(CStringWriter& oStringWriter, const std::wstring & name, const std::vector & colors, bool extra) +{ + if (colors.size() < 1) + { + oStringWriter.WriteString(L"\ + \ + \ + \ + \ + "); + return; + } + + if (extra) + oStringWriter.WriteString(L""); + + oStringWriter.WriteString(L""); + + oStringWriter.WriteString(L""); + + oStringWriter.WriteString(L""); + + oStringWriter.WriteString(L""); + + oStringWriter.WriteString(L""); + + oStringWriter.WriteString(L""); + + oStringWriter.WriteString(L""); + + oStringWriter.WriteString(L""); + + oStringWriter.WriteString(L""); + + oStringWriter.WriteString(L""); + + oStringWriter.WriteString(L""); + + oStringWriter.WriteString(L""); + + oStringWriter.WriteString(L""); + + oStringWriter.WriteString(L""); + if (extra) + { + oStringWriter.WriteString(L""); + oStringWriter.WriteString(L""); + } +} + +void PPT_FORMAT::CPPTXWriter::WriteBackground(CStringWriter& oWriter, CRelsGenerator& oRels, CBrush& oBackground) +{ + oWriter.WriteString(std::wstring(L"")); + + m_pShapeWriter->SetRelsGenerator(&oRels); + { + oWriter.WriteString(m_pShapeWriter->ConvertBrush(oBackground)); + } + oWriter.WriteString(std::wstring(L"")); +} +void PPT_FORMAT::CPPTXWriter::WriteGroup(CStringWriter& oWriter, CRelsGenerator& oRels, CElementPtr pElement, CLayout* pLayout) +{ + CGroupElement *pGroupElement = dynamic_cast(pElement.get()); + + m_pShapeWriter->SetElement(pElement); + oWriter.WriteString(m_pShapeWriter->ConvertGroup()); + + for (size_t i = 0; i < pGroupElement->m_pChildElements.size(); i++) + { + WriteElement(oWriter, oRels, pGroupElement->m_pChildElements[i], pLayout); + } + oWriter.WriteString(L""); +} +void PPT_FORMAT::CPPTXWriter::WriteTable(CStringWriter& oWriter, CRelsGenerator& oRels, CElementPtr pElement, CLayout* pLayout) +{ + CTableElement *pTableElement = dynamic_cast(pElement.get()); + + if (!pTableElement) + return; + + PPTX::Logic::GraphicFrame gf; + TableWriter(pTableElement).Convert(gf); + oWriter.WriteString(gf.toXML()); +} +void PPT_FORMAT::CPPTXWriter::WriteElement(CStringWriter& oWriter, CRelsGenerator& oRels, CElementPtr pElement, CLayout* pLayout) +{ + if (!pElement) return; + + CGroupElement *pGroupElement = dynamic_cast(pElement.get()); + CTableElement *pTableElement = dynamic_cast(pElement.get()); + + if (pTableElement) + { + return WriteTable(oWriter, oRels, pElement, pLayout); + } + if (pGroupElement) + { + return WriteGroup(oWriter, oRels, pElement, pLayout); + } + + bool bObject = m_pShapeWriter->SetElement(pElement); + + if (bObject) + { + m_pShapeWriter->SetRelsGenerator(&oRels); + + if (NULL != pLayout) + { + if (-1 != pElement->m_lPlaceholderType) + { + size_t nCountElements = pLayout->m_arElements.size(); + for (size_t nIndex = 0; nIndex < nCountElements; ++nIndex) + { + if ((pElement->m_lPlaceholderType == pLayout->m_arElements[nIndex]->m_lPlaceholderType) && + (pElement->m_lPlaceholderID == pLayout->m_arElements[nIndex]->m_lPlaceholderID)) + { + CElementPtr pElLayout = pLayout->m_arElements[nIndex]; + + bool bIsEqualTransform = ((pElement->m_dRotate == pElLayout->m_dRotate) + && (pElement->m_bFlipH == pElLayout->m_bFlipH) && (pElement->m_bFlipV == pElLayout->m_bFlipV)); + + if (bIsEqualTransform) + { + if (pElement->m_bAnchorEnabled == pElLayout->m_bAnchorEnabled && pElLayout->m_bAnchorEnabled == true) + { + if (pElement->m_rcAnchor.IsEqual(pElLayout->m_rcAnchor, 0.5)) + pElement->m_bAnchorEnabled = false; + } + if (pElement->m_bChildAnchorEnabled == pElLayout->m_bChildAnchorEnabled && pElLayout->m_bChildAnchorEnabled == true) + { + if (pElement->m_rcChildAnchor.IsEqual(pElLayout->m_rcChildAnchor, 0.5)) + pElement->m_bChildAnchorEnabled = false; + } + } + + break; + } + } + } + } + oWriter.WriteString(m_pShapeWriter->ConvertShape()); + } +} + +void PPT_FORMAT::CPPTXWriter::WriteLayout(CLayoutPtr pLayout, int nIndexLayout, int nStartLayout, int nIndexTheme) +{ + if (!pLayout) return; + + CStringWriter oWriter; + + CRelsGenerator oRels(&m_oManager); + oRels.StartLayout(nIndexTheme); + + oWriter.WriteString(std::wstring(L"")); + + oWriter.WriteString(std::wstring(L"m_strLayoutType + _T("\"")); + oWriter.WriteString(std::wstring(L" showMasterSp=\"") + (pLayout->m_bShowMasterShapes ? _T("1") : _T("0"))); + oWriter.WriteString(std::wstring(L"\" preserve=\"1\">m_sName.empty() == false) + oWriter.WriteString(std::wstring(L" name=\"") + pLayout->m_sName + std::wstring(L"\"")); + oWriter.WriteString(std::wstring(L">")); + + if (pLayout->m_bIsBackground) + { + WriteBackground(oWriter, oRels, pLayout->m_oBackground); + } + + std::wstring strElems = _T("\ +"); + oWriter.WriteString(strElems); + + size_t start_index = 0; + + if (pLayout->m_bIsTitleMaster) + { + CGroupElement *pGroupElement = (!pLayout->m_arElements.empty()) ? dynamic_cast(pLayout->m_arElements[0].get()) : NULL; + + if (pGroupElement) + { + for (size_t i = 0; i < pGroupElement->m_pChildElements.size(); ++i) + { + WriteElement(oWriter, oRels, pGroupElement->m_pChildElements[i]); + } + + start_index = 1; + } + } + + for (size_t i = start_index; i < pLayout->m_arElements.size(); ++i) + { + WriteElement(oWriter, oRels, pLayout->m_arElements[i]); + } + oWriter.WriteString(std::wstring(L"")); + + oWriter.WriteString(std::wstring(L"")); + oWriter.WriteString(std::wstring(L"")); + + oRels.CloseRels(); + + std::wstring strXml = oWriter.GetData(); + std::wstring strFile = L"slideLayout" + std::to_wstring(nIndexLayout + nStartLayout + 1) + L".xml"; + + CFile oFile; + std::wstring strFileLayoutPath= m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("slideLayouts") + FILE_SEPARATOR_STR; + oFile.CreateFile(strFileLayoutPath + strFile); + oFile.WriteStringUTF8(strXml); + oFile.CloseFile(); + + strFile = L"slideLayout" + std::to_wstring(nIndexLayout + nStartLayout + 1) + L".xml.rels"; + oRels.SaveRels(strFileLayoutPath + _T("_rels") + FILE_SEPARATOR_STR + strFile); +} +void PPT_FORMAT::CPPTXWriter::WriteSlide(int nIndexSlide) +{ + CStringWriter oWriter; + CRelsGenerator oRels(&m_oManager); + + CSlide* pSlide = m_pDocument->m_arSlides[nIndexSlide]; + + if (0 == pSlide->m_lThemeID) + oRels.StartSlide(pSlide->m_lLayoutID, pSlide->m_lNotesID); + else + { + int nLayout = pSlide->m_lLayoutID; + for (int i = 0; i < pSlide->m_lThemeID; ++i) + { + nLayout += (int)m_pDocument->m_arThemes[i]->m_arLayouts.size(); + } + + oRels.StartSlide(nLayout, pSlide->m_lNotesID); + } + + oWriter.WriteString(std::wstring(L"")); + oWriter.WriteString(std::wstring(L"m_bShowMasterShapes) + oWriter.WriteString(std::wstring(L" showMasterSp=\"0\"")); + oWriter.WriteString(std::wstring(L">")); + + oWriter.WriteString(std::wstring(L"m_sName.empty() == false) + oWriter.WriteString(std::wstring(L" name=\"") + pSlide->m_sName + std::wstring(L"\"")); + + oWriter.WriteString(std::wstring(L">")); + + if (pSlide->m_bIsBackground) + { + WriteBackground(oWriter, oRels, pSlide->m_oBackground); + } + + oWriter.WriteString(std::wstring(L"\ +")); + + CGroupElement *pGroupElement = !pSlide->m_arElements.empty() ? dynamic_cast(pSlide->m_arElements[0].get()) : NULL; + + size_t start_index = 0; + + if (pGroupElement) + { + for (size_t i = 0; i < pGroupElement->m_pChildElements.size(); ++i) + { + WriteElement(oWriter, oRels, pGroupElement->m_pChildElements[i]); + } + + start_index = 1; + } + + for (size_t i = start_index; i < pSlide->m_arElements.size(); ++i) + { + WriteElement(oWriter, oRels, pSlide->m_arElements[i]); + } + + oWriter.WriteString(std::wstring(L"")); + + oWriter.WriteString(std::wstring(L"")); + + WriteTransition(oWriter, pSlide->m_oSlideShow); + + // TODO write new method and class for timing + WriteTiming(oWriter, oRels, nIndexSlide); + + + oWriter.WriteString(std::wstring(L"")); + + + + + oRels.CloseRels(); + + std::wstring strXml = oWriter.GetData(); + std::wstring strFile = L"slide" + std::to_wstring(nIndexSlide + 1) + L".xml"; + std::wstring strFileSlidePath= m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("slides") + FILE_SEPARATOR_STR; + + CFile oFile; + oFile.CreateFile(strFileSlidePath + strFile); + oFile.WriteStringUTF8(strXml); + oFile.CloseFile(); + + strFile = L"slide" + std::to_wstring(nIndexSlide + 1) + L".xml.rels"; + oRels.SaveRels(strFileSlidePath + _T("_rels") + FILE_SEPARATOR_STR + strFile); +} + +void PPT_FORMAT::CPPTXWriter::WriteTransition(CStringWriter& oWriter, CSlideShowInfo &oSSInfo) +{ + CTransition& transition = oSSInfo.m_oTransition; + + if (transition.m_nEffectType == 0xFF) return; + + std::wstring type; + + std::wstring param_name, param_value; + std::wstring param_name2, param_value2; + + switch(transition.m_nEffectType) + { + case 0: + { + type = L"p:cut"; + param_name = L"thruBlk"; + param_value = transition.m_nEffectDirection ? L"true" : L"false"; + }break; + case 1: + { + type = L"p:random"; + }break; + case 2: + { + type = L"p:blinds"; + param_name = L"dir"; + param_value = transition.m_nEffectDirection ? L"vert" : L"horz"; + }break; + case 3: + { + type = L"p:checker"; + param_name = L"dir"; + param_value = transition.m_nEffectDirection ? L"vert" : L"horz"; + }break; + case 5: + { + type = L"p:dissolve"; + param_name = L"thruBlk"; + param_value = transition.m_nEffectDirection ? L"true" : L"false"; + }break; + case 6: + { + type = L"p:fade"; + param_name = L"thruBlk"; + param_value = transition.m_nEffectDirection ? L"true" : L"false"; + }break; + case 4: + case 7: + { + if (transition.m_nEffectType == 4) type = L"p:cover"; + if (transition.m_nEffectType == 7) type = L"p:pull"; + param_name = L"dir"; + switch(transition.m_nEffectDirection) + { + case 0: param_value = L"r"; break; + case 1: param_value = L"b"; break; + case 2: param_value = L"l"; break; + case 3: param_value = L"t"; break; + case 4: param_value = L"br"; break; + case 5: param_value = L"bl"; break; + case 6: param_value = L"tr"; break; + case 7: param_value = L"tl"; break; + } + }break; + case 8: + { + type = L"p:randomBars"; + param_name = L"dir"; + param_value = transition.m_nEffectDirection ? L"vert" : L"horz"; + }break; + case 9: + { + type = L"p:strips"; + param_name = L"dir"; + switch(transition.m_nEffectDirection) + { + case 0: param_value = L"ru"; break; + case 1: param_value = L"lu"; break; + case 2: param_value = L"rd"; break; + case 3: param_value = L"ld"; break; + } + }break; + case 10: + case 20: + { + if (transition.m_nEffectType == 10) type = L"p:wipe"; + if (transition.m_nEffectType == 20) type = L"p:push"; + + param_name = L"dir"; + switch(transition.m_nEffectDirection) + { + case 0: param_value = L"l"; break; + case 1: param_value = L"u"; break; + case 2: param_value = L"r"; break; + case 3: param_value = L"d"; break; + } + }break; + case 11: + { + type = L"p:zoom"; + param_name = L"dir"; + param_value = transition.m_nEffectDirection ? L"in" : L"out"; + }break; + case 13: + { + type = L"p:split"; + param_name = L"dir"; + param_name2 = L"orient"; + switch(transition.m_nEffectDirection) + { + case 0: param_value2 = L"horz"; param_value = L"out"; break; + case 1: param_value2 = L"horz"; param_value = L"in"; break; + case 2: param_value2 = L"vert"; param_value = L"out"; break; + case 3: param_value2 = L"vert"; param_value = L"in"; break; + } + }break; + case 17: + { + type = L"p:diamond"; + }break; + case 18: + { + type = L"p:plus"; + }break; + case 19: + { + type = L"p:wedge"; + }break; + + case 21: + { + type = L"p:comb"; + param_name = L"dir"; + param_value = transition.m_nEffectDirection ? L"vert" : L"horz"; + }break; + case 22: + { + type = L"p:newsflash"; + }break; + case 23: + { + type = L"p:fade"; + // p:alphaFade + }break; + case 26: + { + type = L"p:wheel"; + param_name = L"spokes"; + param_value = std::to_wstring(transition.m_nEffectDirection); + }break; + case 27: + { + type = L"p:circle"; + }break; + default: + break; + } + + if (type.empty()) return; + oWriter.WriteString(std::wstring(L""); + oWriter.WriteString(L"<" + type); + if (!param_name.empty() && !param_value.empty()) + { + oWriter.WriteString(L" " + param_name + L"=\"" + param_value + L"\""); + } + if (!param_name2.empty() && !param_value2.empty()) + { + oWriter.WriteString(L" " + param_name2 + L"=\"" + param_value2 + L"\""); + } + oWriter.WriteString(L"/>"); + if (transition.m_bAudioPresent) + { + bool bExternal = false; + std::wstring rId = m_pShapeWriter->m_pRels->WriteAudio(transition.m_oAudio.m_strAudioFileName, bExternal); + oWriter.WriteString(std::wstring(L"")); + oWriter.WriteString(L""); + oWriter.WriteString(std::wstring(L"")); + } + oWriter.WriteString(std::wstring(L"")); +} + +void PPT_FORMAT::CPPTXWriter::WriteNotes(int nIndexNotes) +{ + CStringWriter oWriter; + CRelsGenerator oRels(&m_oManager); + + CSlide* pNotes = m_pDocument->m_arNotes[nIndexNotes]; + + oRels.StartNotes(pNotes->m_lSlideID, m_pDocument->m_pNotesMaster != NULL); + + oWriter.WriteString(std::wstring(L"")); + oWriter.WriteString(std::wstring(L"m_bShowMasterShapes) + oWriter.WriteString(std::wstring(L" showMasterSp=\"0\"")); + oWriter.WriteString(std::wstring(L">")); + + oWriter.WriteString(std::wstring(L"")); + + if (pNotes->m_bIsBackground) + { + WriteBackground(oWriter, oRels, pNotes->m_oBackground); + } + + oWriter.WriteString(std::wstring(L"\ +")); + + CGroupElement *pGroupElement = !pNotes->m_arElements.empty() ? dynamic_cast(pNotes->m_arElements[0].get()) : NULL; + + size_t start_index = 0; + + if (pGroupElement) + { + for (size_t i = 0; i < pGroupElement->m_pChildElements.size(); ++i) + { + WriteElement(oWriter, oRels, pGroupElement->m_pChildElements[i]); + } + + start_index = 1; + } + + for (size_t i = start_index; i < pNotes->m_arElements.size(); ++i) + { + WriteElement(oWriter, oRels, pNotes->m_arElements[i]); + } + + oWriter.WriteString(std::wstring(L"")); + + oWriter.WriteString(std::wstring(L"")); + oWriter.WriteString(std::wstring(L"")); + + oRels.CloseRels(); + + std::wstring strXml = oWriter.GetData(); + std::wstring strFile = L"notesSlide" + std::to_wstring(nIndexNotes + 1) + L".xml"; + std::wstring strFileSlidePath = m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("notesSlides") + FILE_SEPARATOR_STR; + + CFile oFile; + oFile.CreateFile(strFileSlidePath + strFile); + oFile.WriteStringUTF8(strXml); + oFile.CloseFile(); + + strFile = L"notesSlide" + std::to_wstring(nIndexNotes + 1) + L".xml.rels"; + oRels.SaveRels(strFileSlidePath + _T("_rels") + FILE_SEPARATOR_STR + strFile); +} + +void PPT_FORMAT::CPPTXWriter::WriteSlides() +{ + m_oManager.WriteAudioCollection(m_pUserInfo->m_oExMedia.m_arAudioCollection); + for (size_t nIndexS = 0; nIndexS < m_pDocument->m_arSlides.size(); ++nIndexS) + { + WriteSlide((int)nIndexS); + } +} +void PPT_FORMAT::CPPTXWriter::WriteNotes() +{ + for (size_t nIndexS = 0; nIndexS < m_pDocument->m_arNotes.size(); ++nIndexS) + { + WriteNotes((int)nIndexS); + } +} + + +void PPT_FORMAT::CPPTXWriter::WriteTiming(CStringWriter& oWriter, CRelsGenerator &oRels, int nIndexSlide) +{ + PPTX::Logic::Timing oTiming; + + auto slide_iter = m_pUserInfo->m_mapSlides.find(m_pUserInfo->m_arrSlidesOrder[nIndexSlide]); + // This part for new animation + CRecordSlideProgTagsContainer* progTag = slide_iter->second->m_pSlideProgTagsContainer; + CRecordPP10SlideBinaryTagExtension* pPP10SlideBinaryTag = progTag ? progTag->getPP10SlideBinaryTagExtension() : NULL; + // This part for old animation + std::vector arrShapeCont; + slide_iter->second->GetRecordsByType(&arrShapeCont, true); + std::vector arrOldAnim; + for (auto ShapeCont : arrShapeCont) + { + SOldAnimation oldAnim; + std::vector shape; + ShapeCont->GetRecordsByType(&shape, true); + std::vector anim; + ShapeCont->GetRecordsByType(&anim, true); + if (!anim.empty() && !shape.empty()) + { + oldAnim.shapeId = shape[0]->m_nID; + oldAnim.anim = anim[0]; + arrOldAnim.push_back(oldAnim); + } + } + + if (!pPP10SlideBinaryTag && arrOldAnim.empty()) + return; + + Animation animation(pPP10SlideBinaryTag, arrOldAnim, &(m_pUserInfo->m_oExMedia), &oRels); + + animation.Convert(oTiming); + oWriter.WriteString(oTiming.toXML()); + //oWriter.WriteString(std::wstring(L"")); + +} diff --git a/OfficeUtils/src/ZipUtilsCP.h b/OfficeUtils/src/ZipUtilsCP.h index 5202d1f873..ff3b9becc2 100644 --- a/OfficeUtils/src/ZipUtilsCP.h +++ b/OfficeUtils/src/ZipUtilsCP.h @@ -52,6 +52,8 @@ using namespace std; #if defined(_WIN32) || defined (_WIN64) #include "zlib-1.2.11/contrib/minizip/iowin32.h" #endif +// for debian to solve use +// # apt install zlib1g-dev #include namespace ZLibZipUtils From e98b542eaeda9f4bec0d8c29f22966e327ecd32c Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Wed, 30 Jun 2021 09:19:23 +0300 Subject: [PATCH 28/84] Correct some class for xml tables. Last home's changes. --- .../PPTFormatLib/PPTXWriter/Converter.cpp | 17 ++++++++++------- .../PPTFormatLib/Reader/Records.cpp | 4 +--- .../Records/Drawing/ShapeContainer.cpp | 17 ++++++++++++++--- ASCOfficePPTXFile/Editor/Drawing/Elements.h | 3 ++- Common/DocxFormat/Source/SystemUtility/File.h | 16 ++++++++++++++++ OfficeUtils/src/ZipUtilsCP.h | 2 -- 6 files changed, 43 insertions(+), 16 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp index 53843518e5..391758c9ef 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp @@ -429,14 +429,17 @@ void PPT_FORMAT::CPPTXWriter::WritePresInfo() std::vector vecTableStyles; ((CPPTUserInfo*)(m_pDocument))->m_oDocument.GetRecordsByType(&vecTableStyles, false); // Source - BYTE* tableStylesData = vecTableStyles[0]->data.first.get(); - ULONG tableStylesLen = vecTableStyles[0]->data.second; - oFile.WriteFile(tableStylesData, tableStylesLen); - oFile.CloseFile(); - - COfficeUtils officeUtils; - officeUtils.ExtractToDirectory(zipPath, m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt"), NULL, 1); + if (vecTableStyles.size()) + { + BYTE* tableStylesData = vecTableStyles[0]->data.first.get(); + ULONG tableStylesLen = vecTableStyles[0]->data.second; + oFile.WriteFile(tableStylesData, tableStylesLen); + oFile.CloseFile(); + COfficeUtils officeUtils; + officeUtils.ExtractToDirectory(zipPath, m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt"), NULL, 1); + oFile.RemoveFile(zipPath); + } diff --git a/ASCOfficePPTFile/PPTFormatLib/Reader/Records.cpp b/ASCOfficePPTFile/PPTFormatLib/Reader/Records.cpp index ed466ec410..5c2214a195 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Reader/Records.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Reader/Records.cpp @@ -637,12 +637,10 @@ IRecord* CreateByType(SRecordHeader oHeader) default: { - std::cout << GetRecordName(oHeader.RecType) << ": " << oHeader.RecLen << "\n"; +// std::cout << GetRecordName(oHeader.RecType) << ": " << oHeader.RecLen << "\n"; }break; }; -// std::cout << GetRecordName(oHeader.RecType) << ": " << oHeader.RecLen << "\n"; - if (NULL == pRecord) { diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp index fa8bc81d68..49394fba89 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp @@ -41,8 +41,6 @@ #include "../../../../OfficeUtils/src/OfficeUtils.h" #include "../../Enums/_includer.h" - - #define FIXED_POINT_unsigned(val) (double)((WORD)(val >> 16) + ((WORD)(val) / 65536.0)) bool CPPTElement::ChangeBlack2ColorImage(std::wstring image_path, int rgbColor1, int rgbColor2) @@ -929,6 +927,20 @@ void CPPTElement::SetUpPropertyShape(CElementPtr pElement, CTheme* pTheme, CSlid delete []utf8Data; } + + utf8Data = NULL; + utf8DataSize = 0; + if (S_OK != officeUtils.LoadFileFromArchive(tempFileName, L"drs/e2oDoc.xml", &utf8Data, utf8DataSize)) + { + officeUtils.LoadFileFromArchive(tempFileName, L"drs/diagrams/drawing1.xml", &utf8Data, utf8DataSize); + } + + if (utf8Data && utf8DataSize > 0) + { + std::wstring tableXmlStr = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8(utf8Data, utf8DataSize); + + delete []utf8Data; + } NSFile::CFileBinary::Remove(tempFileName); }break; case ODRAW::geoRight: @@ -1648,7 +1660,6 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, CTableElement* pTableElem = new CTableElement(); pTableElem->m_etType = etGroup; pElement = CElementPtr(pTableElem); - } else if (bGroupShape) { diff --git a/ASCOfficePPTXFile/Editor/Drawing/Elements.h b/ASCOfficePPTXFile/Editor/Drawing/Elements.h index 0891ab26e4..bcb534f2b4 100644 --- a/ASCOfficePPTXFile/Editor/Drawing/Elements.h +++ b/ASCOfficePPTXFile/Editor/Drawing/Elements.h @@ -32,7 +32,6 @@ #pragma once #include "Theme.h" #include "Shapes/Shape.h" - #include "Shapes/BaseShape/PPTShape/Ppt2PptxShapeConverter.h" namespace PPTX2EditorAdvanced @@ -783,6 +782,8 @@ namespace PPT_FORMAT class CGroupElement : public CElement { + public: + public: CGroupElement() : CElement() { diff --git a/Common/DocxFormat/Source/SystemUtility/File.h b/Common/DocxFormat/Source/SystemUtility/File.h index 9fead48763..c4038866b0 100644 --- a/Common/DocxFormat/Source/SystemUtility/File.h +++ b/Common/DocxFormat/Source/SystemUtility/File.h @@ -111,6 +111,18 @@ private: return hRes; } + + // Todo for windows =) + HRESULT _Remove(const std::wstring& strFileName) + { + BYTE* pUtf8 = NULL; + LONG lLen = 0; + NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strFileName.c_str(), strFileName.length(), pUtf8, lLen, false); + auto err = remove((char*)pUtf8); + + return S_OK; + } + public: CFile() { @@ -198,6 +210,10 @@ public: { return _Open(strFileName, false, true, true); } + HRESULT RemoveFile(const std::wstring& strFileName) + { + return _Remove(strFileName); + } HRESULT SetPosition( ULONG nPos ) { if (m_pFile && nPos <= (ULONG)m_lFileSize) diff --git a/OfficeUtils/src/ZipUtilsCP.h b/OfficeUtils/src/ZipUtilsCP.h index ff3b9becc2..5202d1f873 100644 --- a/OfficeUtils/src/ZipUtilsCP.h +++ b/OfficeUtils/src/ZipUtilsCP.h @@ -52,8 +52,6 @@ using namespace std; #if defined(_WIN32) || defined (_WIN64) #include "zlib-1.2.11/contrib/minizip/iowin32.h" #endif -// for debian to solve use -// # apt install zlib1g-dev #include namespace ZLibZipUtils From 83230fb3eccc965d57feac805fb769c1cfa642b7 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Wed, 30 Jun 2021 18:51:50 +0300 Subject: [PATCH 29/84] xml table. It has some problem with color --- .../PPTFormatLib/PPTXWriter/Converter.cpp | 30 +++++++--- .../PPTFormatLib/PPTXWriter/TableWriter.cpp | 33 +++++++++-- .../PPTFormatLib/PPTXWriter/TableWriter.h | 3 + .../Records/Drawing/ShapeContainer.cpp | 55 ++++++++++++++----- .../Records/Drawing/ShapeContainer.h | 1 + ASCOfficePPTXFile/Editor/Drawing/Elements.h | 2 + 6 files changed, 96 insertions(+), 28 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp index 391758c9ef..05c03b5e9e 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp @@ -423,23 +423,37 @@ void PPT_FORMAT::CPPTXWriter::WritePresInfo() CFile oFile; // tableStyles.xml - std::wstring zipPath = m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("tableStyles.zip"); - oFile.CreateFile(zipPath); + std::wstring tableStylesPath = m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("tableStyles.xml"); + oFile.CreateFile(tableStylesPath); std::vector vecTableStyles; ((CPPTUserInfo*)(m_pDocument))->m_oDocument.GetRecordsByType(&vecTableStyles, false); - // Source + if (vecTableStyles.size()) { BYTE* tableStylesData = vecTableStyles[0]->data.first.get(); ULONG tableStylesLen = vecTableStyles[0]->data.second; - oFile.WriteFile(tableStylesData, tableStylesLen); - oFile.CloseFile(); + NSFile::CFileBinary binFile; - COfficeUtils officeUtils; - officeUtils.ExtractToDirectory(zipPath, m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt"), NULL, 1); - oFile.RemoveFile(zipPath); + std::wstring temp = NSDirectory::GetTempPath(); + + std::wstring tempFileName = temp + FILE_SEPARATOR_STR + L"tempTableStyles.zip"; + if (binFile.CreateFileW(tempFileName)) + { + binFile.WriteFile(tableStylesData, tableStylesLen); + binFile.CloseFile(); + } + + COfficeUtils officeUtils(NULL); + BYTE *utf8Data = NULL; + ULONG utf8DataSize = 0; + if(S_OK == officeUtils.LoadFileFromArchive(tempFileName, L"tableStyles.xml", &utf8Data, utf8DataSize)) + oFile.WriteFile(utf8Data, utf8DataSize); + + NSFile::CFileBinary::Remove(tempFileName); + delete [] utf8Data; } + oFile.CloseFile(); diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp index 168d7a45c5..b17986d9d7 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp @@ -1,5 +1,6 @@ #include "TableWriter.h" #include "TxBodyConverter.h" +#include TableWriter::TableWriter(CTableElement *pTableElement) : m_pTableElement(pTableElement) @@ -12,14 +13,21 @@ void TableWriter::Convert(PPTX::Logic::GraphicFrame &oGraphicFrame) if (!m_pTableElement) return; - oGraphicFrame.nvGraphicFramePr = new PPTX::Logic::NvGraphicFramePr; - FillNvGraphicFramePr(oGraphicFrame.nvGraphicFramePr.get2()); + if (m_pTableElement->m_xmlRawData.empty()) + { + oGraphicFrame.nvGraphicFramePr = new PPTX::Logic::NvGraphicFramePr; + FillNvGraphicFramePr(oGraphicFrame.nvGraphicFramePr.get2()); - oGraphicFrame.xfrm = new PPTX::Logic::Xfrm; - FillXfrm(oGraphicFrame.xfrm.get2()); + oGraphicFrame.xfrm = new PPTX::Logic::Xfrm; + FillXfrm(oGraphicFrame.xfrm.get2()); - oGraphicFrame.table = new PPTX::Logic::Table; - FillTable(oGraphicFrame.table.get2()); + oGraphicFrame.table = new PPTX::Logic::Table; + FillTable(oGraphicFrame.table.get2()); + } + else + { + oGraphicFrame.fromXMLString(getXmlForGraphicFrame()); + } } void TableWriter::FillNvGraphicFramePr(PPTX::Logic::NvGraphicFramePr& oNvGFPr) @@ -372,6 +380,19 @@ void TableWriter::FillRow(PPTX::Logic::TableRow &oRow, ProtoTableRow& arrCells) } } +std::wstring TableWriter::getXmlForGraphicFrame() const +{ + auto& rXml = m_pTableElement->m_xmlRawData; + + auto startIter = rXml.find(L""); + auto endIter = rXml.find(L""); + std::wstring xml = L""; + xml += std::wstring(rXml.begin() + startIter, rXml.begin() + endIter); + xml += L""; + + return xml; +} + TCell::TCell(CShapeElement *pShape, int row, int col, TCell *pParent) : m_pShape(pShape), m_row(row), m_col(col), m_rowSpan(1), m_gridSpan(1), m_pParent(pParent), m_parentDirection(none) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h index eb23d34c19..2c4fe78cee 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h @@ -150,6 +150,9 @@ private: void FillRow(PPTX::Logic::TableRow& oRow, ProtoTableRow &arrCells); +private: + std::wstring getXmlForGraphicFrame()const; + private: CTableElement *m_pTableElement; nullable m_nPTable; diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp index 49394fba89..4889441b43 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp @@ -39,10 +39,13 @@ #include "../../../../Common/DocxFormat/Source/Base/Types_32.h" #include "../../../../OfficeUtils/src/OfficeUtils.h" +#include #include "../../Enums/_includer.h" #define FIXED_POINT_unsigned(val) (double)((WORD)(val >> 16) + ((WORD)(val) / 65536.0)) +ULONG xmlName = 1; + bool CPPTElement::ChangeBlack2ColorImage(std::wstring image_path, int rgbColor1, int rgbColor2) { CBgraFrame bgraFrame; @@ -927,20 +930,6 @@ void CPPTElement::SetUpPropertyShape(CElementPtr pElement, CTheme* pTheme, CSlid delete []utf8Data; } - - utf8Data = NULL; - utf8DataSize = 0; - if (S_OK != officeUtils.LoadFileFromArchive(tempFileName, L"drs/e2oDoc.xml", &utf8Data, utf8DataSize)) - { - officeUtils.LoadFileFromArchive(tempFileName, L"drs/diagrams/drawing1.xml", &utf8Data, utf8DataSize); - } - - if (utf8Data && utf8DataSize > 0) - { - std::wstring tableXmlStr = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8(utf8Data, utf8DataSize); - - delete []utf8Data; - } NSFile::CFileBinary::Remove(tempFileName); }break; case ODRAW::geoRight: @@ -1658,6 +1647,7 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, if (isTable()) { CTableElement* pTableElem = new CTableElement(); + pTableElem->m_xmlRawData = getTableXmlStr(); pTableElem->m_etType = etGroup; pElement = CElementPtr(pTableElem); } @@ -2072,6 +2062,43 @@ bool CRecordShapeContainer::isTable() const return false; } +std::wstring CRecordShapeContainer::getTableXmlStr() const +{ + std::vector oArrayOptions; + GetRecordsByType(&oArrayOptions, true, false); + std::wstring xmlStr = L""; + + if (oArrayOptions.size() >= 2 && + oArrayOptions[1]->m_oProperties.m_arProperties.size() >= 3) + { + COfficeUtils officeUtils(NULL); + BYTE *utf8Data = NULL; + ULONG utf8DataSize = 0; + auto& xmlProp = oArrayOptions[1]->m_oProperties.m_arProperties[2]; + NSFile::CFileBinary file; + + std::wstring temp = NSDirectory::GetTempPath(); + + std::wstring tempFileName = temp + FILE_SEPARATOR_STR + L"tempMetroBlob.zip"; + + if (file.CreateFileW(tempFileName)) + { + file.WriteFile(xmlProp.m_pOptions, xmlProp.m_lValue); + file.CloseFile(); + } + + if (S_OK == officeUtils.LoadFileFromArchive(tempFileName, L"drs/e2oDoc.xml", &utf8Data, utf8DataSize)) + { + xmlStr = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8(utf8Data, utf8DataSize); + } + + delete [] utf8Data; + NSFile::CFileBinary::Remove(tempFileName); + } + + return xmlStr; +} + void CRecordShapeContainer::ApplyThemeStyle(CElementPtr pElem, CTheme* pTheme, CRecordMasterTextPropAtom* master_levels) { CShapeElement* pShape = dynamic_cast(pElem.get()); diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h index 054b02f5bd..5de4534d3a 100755 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h @@ -141,6 +141,7 @@ public: protected: bool isTable()const; + std::wstring getTableXmlStr()const; void ApplyThemeStyle(CElementPtr pElem, CTheme* pTheme, CRecordMasterTextPropAtom* master_levels); void SetUpTextStyle(std::wstring& strText, CTheme* pTheme, CLayout* pLayout, CElementPtr pElem, CSlideInfo* pThemeWrapper, CSlideInfo* pSlideWrapper, CSlide* pSlide, CRecordMasterTextPropAtom* master_levels); void ApplyHyperlink(CShapeElement* pShape, CColor& oColor); diff --git a/ASCOfficePPTXFile/Editor/Drawing/Elements.h b/ASCOfficePPTXFile/Editor/Drawing/Elements.h index bcb534f2b4..5d05eda330 100644 --- a/ASCOfficePPTXFile/Editor/Drawing/Elements.h +++ b/ASCOfficePPTXFile/Editor/Drawing/Elements.h @@ -811,6 +811,8 @@ namespace PPT_FORMAT class CTableElement : public CElement { + public: + std::wstring m_xmlRawData; public: CTableElement() : CElement() { From 5bf3e4d7ab8d571e16082d453a1cd73014b28461 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Thu, 1 Jul 2021 16:41:39 +0300 Subject: [PATCH 30/84] add xml correct. Not works as I wanted --- .../PPTFormatLib/PPTXWriter/TableWriter.cpp | 14 ++++++++++++++ .../PPTFormatLib/PPTXWriter/TableWriter.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp index b17986d9d7..344d443a46 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp @@ -27,6 +27,7 @@ void TableWriter::Convert(PPTX::Logic::GraphicFrame &oGraphicFrame) else { oGraphicFrame.fromXMLString(getXmlForGraphicFrame()); + CorrectGraphicFrame(oGraphicFrame); } } @@ -393,6 +394,19 @@ std::wstring TableWriter::getXmlForGraphicFrame() const return xml; } +void TableWriter::CorrectGraphicFrame(PPTX::Logic::GraphicFrame &oGraphicFrame) +{ + FillnvPr(oGraphicFrame.nvGraphicFramePr->nvPr); +} + +void TableWriter::FillnvPr(PPTX::Logic::NvPr &oNvPr) +{ + PPTX::Logic::Ext ext; + ext.uri = L"{D42A27DB-BD31-4B8C-83A1-F6EECF244321}"; + + oNvPr.extLst.push_back(ext); +} + TCell::TCell(CShapeElement *pShape, int row, int col, TCell *pParent) : m_pShape(pShape), m_row(row), m_col(col), m_rowSpan(1), m_gridSpan(1), m_pParent(pParent), m_parentDirection(none) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h index 2c4fe78cee..05421c57fe 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h @@ -152,6 +152,8 @@ private: private: std::wstring getXmlForGraphicFrame()const; + void CorrectGraphicFrame(PPTX::Logic::GraphicFrame& oGraphicFrame); + void FillnvPr(PPTX::Logic::NvPr& oNvPr); private: CTableElement *m_pTableElement; From 09d3f946e71fec24cbbc8bc60150add1fc737120 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Fri, 2 Jul 2021 17:45:30 +0300 Subject: [PATCH 31/84] add theme*.xml from CRecordRoundTripThemeAtom --- .../PPTFormatLib/PPTXWriter/Converter.cpp | 77 ++++++++++++++++--- .../PPTFormatLib/PPTXWriter/Converter.h | 3 +- .../PPTFormatLib/Records/RoundTripThemeAtom.h | 26 ++++--- 3 files changed, 82 insertions(+), 24 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp index 05c03b5e9e..c6b11c6ba0 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp @@ -622,15 +622,31 @@ void PPT_FORMAT::CPPTXWriter::WriteThemes() { int nStartLayout = 0, nIndexTheme = 0; - for (size_t i = 0; i < m_pDocument->m_arThemes.size(); i++) - { - m_pShapeWriter->m_pTheme = m_pDocument->m_arThemes[i].get(); - WriteTheme(m_pDocument->m_arThemes[i], nIndexTheme, nStartLayout); - m_pShapeWriter->m_pTheme = NULL; - } + std::vector arrThemes; + for (auto& oMaster : m_pUserInfo->m_mapMasters) + oMaster.second->GetRecordsByType(&arrThemes, false); + for (auto& oNoteMaster : m_pUserInfo->m_mapNotesMasters) + oNoteMaster.second->GetRecordsByType(&arrThemes, false); + for (auto& oHandoutMaster : m_pUserInfo->m_mapHandoutMasters) + oHandoutMaster.second->GetRecordsByType(&arrThemes, false); - WriteTheme(m_pDocument->m_pNotesMaster, nIndexTheme, nStartLayout); - WriteTheme(m_pDocument->m_pHandoutMaster, nIndexTheme, nStartLayout); + if (arrThemes.size()) + { + for (auto* pTheme : arrThemes) + WriteTheme(pTheme, nIndexTheme); + } + else + { + for (size_t i = 0; i < m_pDocument->m_arThemes.size(); i++) + { + m_pShapeWriter->m_pTheme = m_pDocument->m_arThemes[i].get(); + WriteTheme(m_pDocument->m_arThemes[i], nIndexTheme, nStartLayout); + m_pShapeWriter->m_pTheme = NULL; + } + + WriteTheme(m_pDocument->m_pNotesMaster, nIndexTheme, nStartLayout); + WriteTheme(m_pDocument->m_pHandoutMaster, nIndexTheme, nStartLayout); + } } void PPT_FORMAT::CPPTXWriter::WriteTheme(CThemePtr pTheme, int & nIndexTheme, int & nStartLayout) @@ -887,6 +903,44 @@ void PPT_FORMAT::CPPTXWriter::WriteTheme(CThemePtr pTheme, int & nIndexTheme, in nIndexTheme++; } +// there maybe not only one theme in zip data +void CPPTXWriter::WriteTheme(CRecordRoundTripThemeAtom* pTheme, int & nIndexTheme) +{ + nIndexTheme++; + if (!pTheme) + return; + + CFile oFile; + // ppt/theme/theme1.xml + std::wstring tableStylesPath = m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("theme") + + FILE_SEPARATOR_STR + _T("theme") + std::to_wstring(nIndexTheme) + _T(".xml"); + oFile.CreateFile(tableStylesPath); + + BYTE* themeData = pTheme->data.first.get(); + ULONG themeLen = pTheme->data.second; + NSFile::CFileBinary binFile; + + std::wstring temp = NSDirectory::GetTempPath(); + + std::wstring tempFileName = temp + FILE_SEPARATOR_STR + L"tempTheme.zip"; + if (binFile.CreateFileW(tempFileName)) + { + binFile.WriteFile(themeData, themeLen); + binFile.CloseFile(); + } + + COfficeUtils officeUtils(NULL); + BYTE *utf8Data = NULL; + ULONG utf8DataSize = 0; + // here need to check second theme and etc + if(S_OK == officeUtils.LoadFileFromArchive(tempFileName, L"theme/theme/theme1.xml", &utf8Data, utf8DataSize)) + oFile.WriteFile(utf8Data, utf8DataSize); + + NSFile::CFileBinary::Remove(tempFileName); + delete [] utf8Data; + oFile.CloseFile(); +} + void PPT_FORMAT::CPPTXWriter::WriteColorScheme(CStringWriter& oStringWriter, const std::wstring & name, const std::vector & colors, bool extra) { if (colors.size() < 1) @@ -968,8 +1022,6 @@ void PPT_FORMAT::CPPTXWriter::WriteTable(CStringWriter& oWriter, CRelsGenerator& { CTableElement *pTableElement = dynamic_cast(pElement.get()); - if (!pTableElement) - return; PPTX::Logic::GraphicFrame gf; TableWriter(pTableElement).Convert(gf); @@ -979,13 +1031,14 @@ void PPT_FORMAT::CPPTXWriter::WriteElement(CStringWriter& oWriter, CRelsGenerato { if (!pElement) return; - CGroupElement *pGroupElement = dynamic_cast(pElement.get()); - CTableElement *pTableElement = dynamic_cast(pElement.get()); + CTableElement *pTableElement = dynamic_cast(pElement.get()); if (pTableElement) { return WriteTable(oWriter, oRels, pElement, pLayout); } + + CGroupElement *pGroupElement = dynamic_cast(pElement.get()); if (pGroupElement) { return WriteGroup(oWriter, oRels, pElement, pLayout); diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.h index 9152546f58..a908185bbb 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.h @@ -76,7 +76,8 @@ namespace PPT_FORMAT void WriteAll (); void WriteThemes (); void WriteTheme (CThemePtr pTheme, int & nIndexTheme, int & nStartLayout); - void WriteSlides (); + void WriteTheme (CRecordRoundTripThemeAtom *pTheme, int &nIndexTheme); + void WriteSlides (); void WriteNotes (); void WriteLayout (CLayoutPtr pLayout, int nIndexLayout, int nStartLayout, int nIndexTheme); void WriteSlide (int nIndexSlide); diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/RoundTripThemeAtom.h b/ASCOfficePPTFile/PPTFormatLib/Records/RoundTripThemeAtom.h index 34abab6fea..9134d872a0 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/RoundTripThemeAtom.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/RoundTripThemeAtom.h @@ -32,19 +32,23 @@ #pragma once #include "../Reader/Records.h" +#include + +//ULONG ThemeCounter = 1; + class CRecordRoundTripThemeAtom : public CUnknownRecord { public: - std::pair, _INT32> data; - - CRecordRoundTripThemeAtom(){} - ~CRecordRoundTripThemeAtom(){} + std::pair, _INT32> data; - virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream) - { - m_oHeader = oHeader; - - data = std::make_pair(boost::shared_array(new unsigned char[m_oHeader.RecLen]), m_oHeader.RecLen); - pStream->read(data.first.get(), data.second); - } + CRecordRoundTripThemeAtom(){} + ~CRecordRoundTripThemeAtom(){} + + virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream) + { + m_oHeader = oHeader; + + data = std::make_pair(boost::shared_array(new unsigned char[m_oHeader.RecLen]), m_oHeader.RecLen); + pStream->read(data.first.get(), data.second); + } }; From 7f6d04eb343cda0904b0d6e934c43c8f14489f39 Mon Sep 17 00:00:00 2001 From: Ivan Date: Mon, 5 Jul 2021 11:36:28 +0300 Subject: [PATCH 32/84] add round trip theme. Now it works fine. --- .../PPTFormatLib/PPTXWriter/Converter.cpp | 460 +++++++++--------- .../Reader/PPTDocumentInfoOneUser.cpp | 8 + ASCOfficePPTXFile/Editor/Drawing/Theme.h | 4 + 3 files changed, 249 insertions(+), 223 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp index c6b11c6ba0..c0cfc44b2f 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp @@ -55,9 +55,9 @@ namespace PPT_FORMAT { - namespace NSPPTXWriterConst - { - static std::wstring g_string_rels_presentation = _T("\ +namespace NSPPTXWriterConst +{ +static std::wstring g_string_rels_presentation = _T("\ \ \ \ @@ -67,8 +67,8 @@ namespace PPT_FORMAT static std::wstring g_string_core = _T("\ \ Slide 1\ -1\ -"); + 1\ + "); } } @@ -241,7 +241,7 @@ void PPT_FORMAT::CPPTXWriter::WriteContentTypes() for (size_t nL = 0; nL < m_pDocument->m_arThemes[nT]->m_arLayouts.size(); nL++, nIndexLayout++) { strContentTypes += L""; + L".xml\" ContentType=\"application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml\"/>"; } } @@ -267,7 +267,7 @@ void PPT_FORMAT::CPPTXWriter::WriteContentTypes() for (size_t nS = 0; nS < m_pDocument->m_arNotes.size(); ++nS) { strContentTypes += L""; + + L".xml\" ContentType=\"application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml\"/>"; } strContentTypes += _T(""); @@ -300,10 +300,10 @@ void PPT_FORMAT::CPPTXWriter::WriteApp(CFile& oFile) std::wstring sApplication = NSSystemUtils::GetEnvVariable(NSSystemUtils::gc_EnvApplicationName); if (sApplication.empty()) sApplication = NSSystemUtils::gc_EnvApplicationNameDefault; - #if defined(INTVER) +#if defined(INTVER) std::string s = VALUE2STR(INTVER); sApplication += L"/" + std::wstring(s.begin(), s.end()); - #endif +#endif CP_XML_NODE(L"Application") { CP_XML_STREAM() << sApplication; @@ -371,7 +371,7 @@ void PPT_FORMAT::CPPTXWriter::WriteApp(CFile& oFile) CP_XML_NODE(L"vt:variant") { CP_XML_NODE(L"vt:i4") - CP_XML_STREAM() << m_pDocument->m_arSlides.size(); + CP_XML_STREAM() << m_pDocument->m_arSlides.size(); } } } @@ -422,7 +422,7 @@ void PPT_FORMAT::CPPTXWriter::WritePresInfo() { CFile oFile; -// tableStyles.xml + // tableStyles.xml std::wstring tableStylesPath = m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("tableStyles.xml"); oFile.CreateFile(tableStylesPath); @@ -457,7 +457,7 @@ void PPT_FORMAT::CPPTXWriter::WritePresInfo() -// presProps.xml + // presProps.xml oFile.CreateFile(m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("presProps.xml")); oFile.WriteStringUTF8(L"\ \ @@ -468,8 +468,8 @@ void PPT_FORMAT::CPPTXWriter::WritePresInfo() "); oFile.CloseFile(); -// viewProps.xml - oFile.CreateFile(m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("viewProps.xml")); + // viewProps.xml + oFile.CreateFile(m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("viewProps.xml")); oFile.WriteStringUTF8(L"\ \ \ @@ -521,8 +521,8 @@ void PPT_FORMAT::CPPTXWriter::WritePresInfo() for (size_t nIndexSlide = 0; nIndexSlide < m_pDocument->m_arSlides.size(); ++nIndexSlide, ++nCurrentRels) { strPresRels += L""; + L"\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide\" Target=\"slides/slide" + + std::to_wstring(nIndexSlide + 1) + L".xml\" />"; strPresSlides += L""; } @@ -551,7 +551,7 @@ void PPT_FORMAT::CPPTXWriter::WritePresInfo() oFile.CloseFile(); std::wstring strSizePres = L"m_lSlideWidth) + - L"\" cy=\"" + std::to_wstring(m_pDocument->m_lSlideHeight) + + L"\" cy=\"" + std::to_wstring(m_pDocument->m_lSlideHeight) + L"\" type=\"screen4x3\" />m_lNotesWidth) + L"\" cy=\"" + std::to_wstring(m_pDocument->m_lNotesHeight) + L"\"/>"; @@ -566,17 +566,17 @@ void PPT_FORMAT::CPPTXWriter::WritePresInfo() std::wstring strPres = _T(""); strPres += _T("m_bRtl)) - { - strPres += _T(" rtl=\"1\""); - } - strPres += _T(">"); - strPres += _T("") + strPresMasters + _T(""); - strPres += strNotesIDs ; - strPres += strHandoutIDs ; - strPres +=_T("") + strPresSlides + _T(""); - strPres += strSizePres; - strPres += strDefaultTextStyle; + if ((m_pUserInfo) && (m_pUserInfo->m_bRtl)) + { + strPres += _T(" rtl=\"1\""); + } + strPres += _T(">"); + strPres += _T("") + strPresMasters + _T(""); + strPres += strNotesIDs ; + strPres += strHandoutIDs ; + strPres +=_T("") + strPresSlides + _T(""); + strPres += strSizePres; + strPres += strDefaultTextStyle; strPres +=_T(""); oFile.CreateFile(m_strTempDirectory+ FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("presentation.xml")); @@ -622,37 +622,22 @@ void PPT_FORMAT::CPPTXWriter::WriteThemes() { int nStartLayout = 0, nIndexTheme = 0; - std::vector arrThemes; - for (auto& oMaster : m_pUserInfo->m_mapMasters) - oMaster.second->GetRecordsByType(&arrThemes, false); - for (auto& oNoteMaster : m_pUserInfo->m_mapNotesMasters) - oNoteMaster.second->GetRecordsByType(&arrThemes, false); - for (auto& oHandoutMaster : m_pUserInfo->m_mapHandoutMasters) - oHandoutMaster.second->GetRecordsByType(&arrThemes, false); - if (arrThemes.size()) + for (size_t i = 0; i < m_pDocument->m_arThemes.size(); i++) { - for (auto* pTheme : arrThemes) - WriteTheme(pTheme, nIndexTheme); + m_pShapeWriter->m_pTheme = m_pDocument->m_arThemes[i].get(); + WriteTheme(m_pDocument->m_arThemes[i], nIndexTheme, nStartLayout); + m_pShapeWriter->m_pTheme = NULL; } - else - { - for (size_t i = 0; i < m_pDocument->m_arThemes.size(); i++) - { - m_pShapeWriter->m_pTheme = m_pDocument->m_arThemes[i].get(); - WriteTheme(m_pDocument->m_arThemes[i], nIndexTheme, nStartLayout); - m_pShapeWriter->m_pTheme = NULL; - } - WriteTheme(m_pDocument->m_pNotesMaster, nIndexTheme, nStartLayout); - WriteTheme(m_pDocument->m_pHandoutMaster, nIndexTheme, nStartLayout); - } + WriteTheme(m_pDocument->m_pNotesMaster, nIndexTheme, nStartLayout); + WriteTheme(m_pDocument->m_pHandoutMaster, nIndexTheme, nStartLayout); + } void PPT_FORMAT::CPPTXWriter::WriteTheme(CThemePtr pTheme, int & nIndexTheme, int & nStartLayout) { if (!pTheme) return; - std::wstring strPptDirectory = m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR ; std::wstring strThemeFile = L"theme" + std::to_wstring(nIndexTheme + 1) + L".xml"; @@ -661,25 +646,54 @@ void PPT_FORMAT::CPPTXWriter::WriteTheme(CThemePtr pTheme, int & nIndexTheme, in CFile oFile; oFile.CreateFile(strThemeFile); - PPT_FORMAT::CStringWriter oStringWriter; + if (pTheme->m_arrZipXml.size() == 1 && pTheme->m_arrZipXml[0] != nullptr) + { + auto& zipData = *(pTheme->m_arrZipXml[0]); + BYTE* themeData = zipData.data.first.get(); + ULONG themeLen = zipData.data.second; + NSFile::CFileBinary binFile; - oStringWriter.WriteString(std::wstring(L"m_sThemeName); - oStringWriter.WriteString(std::wstring(L"\">")); + std::wstring temp = NSDirectory::GetTempPath(); - WriteColorScheme(oStringWriter, L"Default", pTheme->m_arColorScheme); + std::wstring tempFileName = temp + FILE_SEPARATOR_STR + L"tempTheme.zip"; + if (binFile.CreateFileW(tempFileName)) + { + binFile.WriteFile(themeData, themeLen); + binFile.CloseFile(); + } - oStringWriter.WriteString(std::wstring(L"m_arFonts[0].Name); - oStringWriter.WriteString(std::wstring(L"\"/>")); + COfficeUtils officeUtils(NULL); + BYTE *utf8Data = NULL; + ULONG utf8DataSize = 0; + // here need to check second theme and etc + if(S_OK == officeUtils.LoadFileFromArchive(tempFileName, L"theme/theme/theme1.xml", &utf8Data, utf8DataSize)) + oFile.WriteFile(utf8Data, utf8DataSize); - oStringWriter.WriteString(std::wstring(L"m_arFonts.size() > 1 ) oStringWriter.WriteString (pTheme->m_arFonts[1].Name); - else oStringWriter.WriteStringXML(pTheme->m_arFonts[0].Name); + oStringWriter.WriteString(std::wstring(L"m_sThemeName); + oStringWriter.WriteString(std::wstring(L"\">")); - oStringWriter.WriteString(std::wstring(L"\"/>")); - oStringWriter.WriteString(std::wstring(L"")); + WriteColorScheme(oStringWriter, L"Default", pTheme->m_arColorScheme); + + oStringWriter.WriteString(std::wstring(L"m_arFonts[0].Name); + oStringWriter.WriteString(std::wstring(L"\"/>")); + + oStringWriter.WriteString(std::wstring(L"m_arFonts.size() > 1 ) oStringWriter.WriteString (pTheme->m_arFonts[1].Name); + else oStringWriter.WriteStringXML(pTheme->m_arFonts[0].Name); + + oStringWriter.WriteString(std::wstring(L"\"/>")); + oStringWriter.WriteString(std::wstring(L"")); oStringWriter.WriteString(std::wstring(L"\ \ @@ -708,21 +722,21 @@ void PPT_FORMAT::CPPTXWriter::WriteTheme(CThemePtr pTheme, int & nIndexTheme, in \ ")); - oStringWriter.WriteString(std::wstring(L"")); - oStringWriter.WriteString(std::wstring(L"")); + oStringWriter.WriteString(std::wstring(L"")); + oStringWriter.WriteString(std::wstring(L"")); - for (size_t i = 0 ; i < pTheme->m_arExtraColorScheme.size(); i++) - { - std::wstring str = L" " + std::to_wstring(i + 1); - WriteColorScheme(oStringWriter, pTheme->m_sThemeName + str, pTheme->m_arExtraColorScheme[i], true); //extra + for (size_t i = 0 ; i < pTheme->m_arExtraColorScheme.size(); i++) + { + std::wstring str = L" " + std::to_wstring(i + 1); + WriteColorScheme(oStringWriter, pTheme->m_sThemeName + str, pTheme->m_arExtraColorScheme[i], true); //extra + } + + oStringWriter.WriteString(std::wstring(L"")); + oStringWriter.WriteString(std::wstring(L"")); + + oFile.WriteStringUTF8(oStringWriter.GetData()); + oFile.CloseFile(); } - - oStringWriter.WriteString(std::wstring(L"")); - oStringWriter.WriteString(std::wstring(L"")); - - oFile.WriteStringUTF8(oStringWriter.GetData()); - oFile.CloseFile(); - CRelsGenerator oRels(&m_oManager); int nCountLayouts = (int)pTheme->m_arLayouts.size(); oRels.StartMaster(nIndexTheme, nStartLayout, nCountLayouts); @@ -827,7 +841,7 @@ void PPT_FORMAT::CPPTXWriter::WriteTheme(CThemePtr pTheme, int & nIndexTheme, in oWriter.WriteString(std::wstring(L"m_bHasDate) oWriter.WriteString(std::wstring(L" dt=\"0\"")); if (!pTheme->m_bHasSlideNumber) oWriter.WriteString(std::wstring(L" sldNum=\"0\"")); - oWriter.WriteString(std::wstring(L" hdr=\"0\"")); + oWriter.WriteString(std::wstring(L" hdr=\"0\"")); if (!pTheme->m_bHasFooter) oWriter.WriteString(std::wstring(L" ftr=\"0\"")); oWriter.WriteString(std::wstring(L"/>")); } @@ -892,8 +906,8 @@ void PPT_FORMAT::CPPTXWriter::WriteTheme(CThemePtr pTheme, int & nIndexTheme, in strSlideMasterRelsFile = strPptDirectory + _T("handoutMasters") + FILE_SEPARATOR_STR + _T("_rels") + FILE_SEPARATOR_STR + strSlideMasterRelsFile; } oFile.CreateFile(strSlideMasterFile); - std::wstring strMaster = oWriter.GetData(); - oFile.WriteStringUTF8(strMaster); + std::wstring strMaster = oWriter.GetData(); + oFile.WriteStringUTF8(strMaster); oFile.CloseFile(); oRels.CloseRels(); @@ -1058,12 +1072,12 @@ void PPT_FORMAT::CPPTXWriter::WriteElement(CStringWriter& oWriter, CRelsGenerato for (size_t nIndex = 0; nIndex < nCountElements; ++nIndex) { if ((pElement->m_lPlaceholderType == pLayout->m_arElements[nIndex]->m_lPlaceholderType) && - (pElement->m_lPlaceholderID == pLayout->m_arElements[nIndex]->m_lPlaceholderID)) + (pElement->m_lPlaceholderID == pLayout->m_arElements[nIndex]->m_lPlaceholderID)) { CElementPtr pElLayout = pLayout->m_arElements[nIndex]; bool bIsEqualTransform = ((pElement->m_dRotate == pElLayout->m_dRotate) - && (pElement->m_bFlipH == pElLayout->m_bFlipH) && (pElement->m_bFlipV == pElLayout->m_bFlipV)); + && (pElement->m_bFlipH == pElLayout->m_bFlipH) && (pElement->m_bFlipV == pElLayout->m_bFlipV)); if (bIsEqualTransform) { @@ -1106,7 +1120,7 @@ void PPT_FORMAT::CPPTXWriter::WriteLayout(CLayoutPtr pLayout, int nIndexLayout, if ( pLayout->m_sName.empty() == false) oWriter.WriteString(std::wstring(L" name=\"") + pLayout->m_sName + std::wstring(L"\"")); - oWriter.WriteString(std::wstring(L">")); + oWriter.WriteString(std::wstring(L">")); if (pLayout->m_bIsBackground) { @@ -1224,7 +1238,7 @@ void PPT_FORMAT::CPPTXWriter::WriteSlide(int nIndexSlide) WriteTransition(oWriter, pSlide->m_oSlideShow); // TODO write new method and class for timing - WriteTiming(oWriter, oRels, nIndexSlide); + WriteTiming(oWriter, oRels, nIndexSlide); oWriter.WriteString(std::wstring(L"")); @@ -1261,180 +1275,180 @@ void PPT_FORMAT::CPPTXWriter::WriteTransition(CStringWriter& oWriter, CSlideShow switch(transition.m_nEffectType) { case 0: - { - type = L"p:cut"; - param_name = L"thruBlk"; - param_value = transition.m_nEffectDirection ? L"true" : L"false"; - }break; + { + type = L"p:cut"; + param_name = L"thruBlk"; + param_value = transition.m_nEffectDirection ? L"true" : L"false"; + }break; case 1: - { - type = L"p:random"; - }break; + { + type = L"p:random"; + }break; case 2: - { - type = L"p:blinds"; - param_name = L"dir"; - param_value = transition.m_nEffectDirection ? L"vert" : L"horz"; - }break; + { + type = L"p:blinds"; + param_name = L"dir"; + param_value = transition.m_nEffectDirection ? L"vert" : L"horz"; + }break; case 3: - { - type = L"p:checker"; - param_name = L"dir"; - param_value = transition.m_nEffectDirection ? L"vert" : L"horz"; - }break; + { + type = L"p:checker"; + param_name = L"dir"; + param_value = transition.m_nEffectDirection ? L"vert" : L"horz"; + }break; case 5: - { - type = L"p:dissolve"; - param_name = L"thruBlk"; - param_value = transition.m_nEffectDirection ? L"true" : L"false"; - }break; + { + type = L"p:dissolve"; + param_name = L"thruBlk"; + param_value = transition.m_nEffectDirection ? L"true" : L"false"; + }break; case 6: - { - type = L"p:fade"; - param_name = L"thruBlk"; - param_value = transition.m_nEffectDirection ? L"true" : L"false"; - }break; + { + type = L"p:fade"; + param_name = L"thruBlk"; + param_value = transition.m_nEffectDirection ? L"true" : L"false"; + }break; case 4: case 7: + { + if (transition.m_nEffectType == 4) type = L"p:cover"; + if (transition.m_nEffectType == 7) type = L"p:pull"; + param_name = L"dir"; + switch(transition.m_nEffectDirection) { - if (transition.m_nEffectType == 4) type = L"p:cover"; - if (transition.m_nEffectType == 7) type = L"p:pull"; - param_name = L"dir"; - switch(transition.m_nEffectDirection) - { - case 0: param_value = L"r"; break; - case 1: param_value = L"b"; break; - case 2: param_value = L"l"; break; - case 3: param_value = L"t"; break; - case 4: param_value = L"br"; break; - case 5: param_value = L"bl"; break; - case 6: param_value = L"tr"; break; - case 7: param_value = L"tl"; break; - } - }break; + case 0: param_value = L"r"; break; + case 1: param_value = L"b"; break; + case 2: param_value = L"l"; break; + case 3: param_value = L"t"; break; + case 4: param_value = L"br"; break; + case 5: param_value = L"bl"; break; + case 6: param_value = L"tr"; break; + case 7: param_value = L"tl"; break; + } + }break; case 8: - { - type = L"p:randomBars"; - param_name = L"dir"; - param_value = transition.m_nEffectDirection ? L"vert" : L"horz"; - }break; + { + type = L"p:randomBars"; + param_name = L"dir"; + param_value = transition.m_nEffectDirection ? L"vert" : L"horz"; + }break; case 9: + { + type = L"p:strips"; + param_name = L"dir"; + switch(transition.m_nEffectDirection) { - type = L"p:strips"; - param_name = L"dir"; - switch(transition.m_nEffectDirection) - { - case 0: param_value = L"ru"; break; - case 1: param_value = L"lu"; break; - case 2: param_value = L"rd"; break; - case 3: param_value = L"ld"; break; - } - }break; + case 0: param_value = L"ru"; break; + case 1: param_value = L"lu"; break; + case 2: param_value = L"rd"; break; + case 3: param_value = L"ld"; break; + } + }break; case 10: case 20: - { - if (transition.m_nEffectType == 10) type = L"p:wipe"; - if (transition.m_nEffectType == 20) type = L"p:push"; + { + if (transition.m_nEffectType == 10) type = L"p:wipe"; + if (transition.m_nEffectType == 20) type = L"p:push"; - param_name = L"dir"; - switch(transition.m_nEffectDirection) - { - case 0: param_value = L"l"; break; - case 1: param_value = L"u"; break; - case 2: param_value = L"r"; break; - case 3: param_value = L"d"; break; - } - }break; + param_name = L"dir"; + switch(transition.m_nEffectDirection) + { + case 0: param_value = L"l"; break; + case 1: param_value = L"u"; break; + case 2: param_value = L"r"; break; + case 3: param_value = L"d"; break; + } + }break; case 11: - { - type = L"p:zoom"; - param_name = L"dir"; - param_value = transition.m_nEffectDirection ? L"in" : L"out"; - }break; + { + type = L"p:zoom"; + param_name = L"dir"; + param_value = transition.m_nEffectDirection ? L"in" : L"out"; + }break; case 13: + { + type = L"p:split"; + param_name = L"dir"; + param_name2 = L"orient"; + switch(transition.m_nEffectDirection) { - type = L"p:split"; - param_name = L"dir"; - param_name2 = L"orient"; - switch(transition.m_nEffectDirection) - { - case 0: param_value2 = L"horz"; param_value = L"out"; break; - case 1: param_value2 = L"horz"; param_value = L"in"; break; - case 2: param_value2 = L"vert"; param_value = L"out"; break; - case 3: param_value2 = L"vert"; param_value = L"in"; break; - } - }break; + case 0: param_value2 = L"horz"; param_value = L"out"; break; + case 1: param_value2 = L"horz"; param_value = L"in"; break; + case 2: param_value2 = L"vert"; param_value = L"out"; break; + case 3: param_value2 = L"vert"; param_value = L"in"; break; + } + }break; case 17: - { - type = L"p:diamond"; - }break; + { + type = L"p:diamond"; + }break; case 18: - { - type = L"p:plus"; - }break; + { + type = L"p:plus"; + }break; case 19: - { - type = L"p:wedge"; - }break; + { + type = L"p:wedge"; + }break; case 21: - { - type = L"p:comb"; - param_name = L"dir"; - param_value = transition.m_nEffectDirection ? L"vert" : L"horz"; - }break; + { + type = L"p:comb"; + param_name = L"dir"; + param_value = transition.m_nEffectDirection ? L"vert" : L"horz"; + }break; case 22: - { - type = L"p:newsflash"; - }break; + { + type = L"p:newsflash"; + }break; case 23: - { - type = L"p:fade"; - // p:alphaFade - }break; + { + type = L"p:fade"; + // p:alphaFade + }break; case 26: - { - type = L"p:wheel"; - param_name = L"spokes"; - param_value = std::to_wstring(transition.m_nEffectDirection); - }break; + { + type = L"p:wheel"; + param_name = L"spokes"; + param_value = std::to_wstring(transition.m_nEffectDirection); + }break; case 27: - { - type = L"p:circle"; - }break; + { + type = L"p:circle"; + }break; default: break; } if (type.empty()) return; oWriter.WriteString(std::wstring(L""); oWriter.WriteString(L"<" + type); - if (!param_name.empty() && !param_value.empty()) - { - oWriter.WriteString(L" " + param_name + L"=\"" + param_value + L"\""); - } - if (!param_name2.empty() && !param_value2.empty()) - { - oWriter.WriteString(L" " + param_name2 + L"=\"" + param_value2 + L"\""); - } + if (!param_name.empty() && !param_value.empty()) + { + oWriter.WriteString(L" " + param_name + L"=\"" + param_value + L"\""); + } + if (!param_name2.empty() && !param_value2.empty()) + { + oWriter.WriteString(L" " + param_name2 + L"=\"" + param_value2 + L"\""); + } oWriter.WriteString(L"/>"); if (transition.m_bAudioPresent) { diff --git a/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp b/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp index 0b92702091..ad05cdb7bf 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp @@ -1628,6 +1628,14 @@ void CPPTUserInfo::LoadMainMaster(_UINT32 dwMasterID) } int lLayoutID = AddNewLayout(pTheme, pMaster, false, true); + + for (auto& oMaster : m_mapMasters) + oMaster.second->GetRecordsByType(&pTheme->m_arrZipXml, false); +// for (auto& oNoteMaster : m_mapNotesMasters) +// oNoteMaster.second->GetRecordsByType(&pTheme->m_arrZipXml, false); +// for (auto& oHandoutMaster : m_mapHandoutMasters) +// oHandoutMaster.second->GetRecordsByType(&pTheme->m_arrZipXml, false); + if (lLayoutID >= 0 && false == pTheme->m_arLayouts.empty()) { CLayout *pLayout_ = pTheme->m_arLayouts.back().get(); diff --git a/ASCOfficePPTXFile/Editor/Drawing/Theme.h b/ASCOfficePPTXFile/Editor/Drawing/Theme.h index 1d5d331250..4e0cf044f4 100644 --- a/ASCOfficePPTXFile/Editor/Drawing/Theme.h +++ b/ASCOfficePPTXFile/Editor/Drawing/Theme.h @@ -30,6 +30,7 @@ * */ #pragma once +#include "../../../ASCOfficePPTFile/PPTFormatLib/Records/RoundTripThemeAtom.h" #include "Structures.h" #include "Layout.h" @@ -75,6 +76,8 @@ namespace PPT_FORMAT std::wstring m_sThemeName; std::vector>m_arExtraColorScheme; + + std::vector m_arrZipXml; bool m_bHasDate; bool m_bHasSlideNumber; @@ -101,6 +104,7 @@ namespace PPT_FORMAT m_mapTitleLayout.clear(); m_mapGeomToLayout.clear(); m_mapPlaceholders.clear(); + m_arrZipXml.clear(); m_sThemeName = L"Default"; From ef3e4c2cfa14050056682d464a3c7d66b28f0609 Mon Sep 17 00:00:00 2001 From: Ivan Date: Mon, 5 Jul 2021 18:49:33 +0300 Subject: [PATCH 33/84] add invizible table cells --- .../PPTFormatLib/PPTXWriter/TableWriter.cpp | 20 +++++++++++++++++-- .../Records/Drawing/ShapeContainer.cpp | 2 ++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp index 344d443a46..a63b8d2331 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp @@ -523,9 +523,25 @@ void TCell::FillTcPr(PPTX::Logic::TableCellProperties &oTcPr) auto pSolidFill = new PPTX::Logic::SolidFill; - auto& clr = m_pShape->m_oBrush.Color1; + auto& brush = m_pShape->m_oBrush; + auto& clr = brush.Color1; pSolidFill->Color.SetRGBColor(clr.GetR(), clr.GetG(), clr.GetB()); + if (brush.Alpha1 != 255) + { + PPTX::Logic::ColorModifier alpha; + alpha.name = L"a:alpha"; + alpha.val = brush.Alpha1 * 392; + pSolidFill->Color.Color->Modifiers.push_back(alpha); + } + if (brush.Type == 5000) + { + PPTX::Logic::ColorModifier alpha; + alpha.name = L"a:alpha"; + alpha.val = 0; + pSolidFill->Color.Color->Modifiers.push_back(alpha); + } + oTcPr.Fill.Fill.reset(pSolidFill); for (auto IterBorder : m_mapBorders) @@ -568,7 +584,7 @@ void TCell::FillLn(PPTX::Logic::Ln &Ln, TCell::eBorderPossition eBP, CShapeEleme { PPTX::Logic::ColorModifier alpha; alpha.name = L"a:alpha"; - alpha.val = pen.Alpha * 394; + alpha.val = pen.Alpha * 392; pSolidFill->Color.Color->Modifiers.push_back(alpha); } Ln.Fill.Fill.reset(pSolidFill); diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp index 4889441b43..552d29036b 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp @@ -2056,7 +2056,9 @@ bool CRecordShapeContainer::isTable() const if ((prop.m_ePID == tableProperties || prop.m_ePID == tableRowProperties) && bGroupShape) + { return true; + } } } return false; From 63cfded90c6ba8c490bca57d42bd818f2e3517ce Mon Sep 17 00:00:00 2001 From: Ivan Date: Tue, 6 Jul 2021 16:36:41 +0300 Subject: [PATCH 34/84] add zero height for proto table --- .../PPTFormatLib/PPTXWriter/TableWriter.cpp | 31 +++++++++++++++---- .../PPTFormatLib/PPTXWriter/TableWriter.h | 3 ++ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp index a63b8d2331..502d86ec37 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp @@ -13,7 +13,7 @@ void TableWriter::Convert(PPTX::Logic::GraphicFrame &oGraphicFrame) if (!m_pTableElement) return; - if (m_pTableElement->m_xmlRawData.empty()) + if (m_pTableElement->m_xmlRawData.empty()/* || true*/) { oGraphicFrame.nvGraphicFramePr = new PPTX::Logic::NvGraphicFramePr; FillNvGraphicFramePr(oGraphicFrame.nvGraphicFramePr.get2()); @@ -48,12 +48,13 @@ void TableWriter::FillXfrm(PPTX::Logic::Xfrm &oXFRM) { oXFRM.m_ns = L"p"; double multip1 = m_pTableElement->m_bAnchorEnabled ? 1587.6 : 1; - double multip2 = m_pTableElement->m_bAnchorEnabled ? 1273.0 : 1; + double multip2 = m_pTableElement->m_bAnchorEnabled ? 1575.864 : 1; + double multip3 = m_pTableElement->m_bAnchorEnabled ? 1232.137 : 1; oXFRM.offX = int(m_pTableElement->m_rcAnchor.left * multip1); oXFRM.offY = int(m_pTableElement->m_rcAnchor.top * multip1); oXFRM.extX = int(m_pTableElement->m_rcAnchor.right * multip2); - oXFRM.extY = int(m_pTableElement->m_rcAnchor.bottom * multip2); + oXFRM.extY = int(m_pTableElement->m_rcAnchor.bottom * multip3); } void TableWriter::FillTable(PPTX::Logic::Table &oTable) @@ -73,7 +74,7 @@ void TableWriter::FillTable(PPTX::Logic::Table &oTable) { PPTX::Logic::TableRow tr; FillRow(tr, protoTable[cRow]); - tr.Height = arrHeight[cRow]; + tr.Height = ProtoTable::checkRowForZeroHeight(protoTable[cRow]) ? 0 : arrHeight[cRow]; oTable.TableRows.push_back(tr); } } @@ -137,16 +138,27 @@ std::vector ProtoTable::getHeight(std::vector& arrCells, bo } std::vector gridHeight; - double multip = isHeight ? 1587.6 : 1.0; + double multip = isHeight ? 1587.5 : 1.0; for (const auto& h : mapTopHeight) { double value = isHeight ? h.second : h.first; - gridHeight.push_back(int(value * multip)); + gridHeight.push_back(round(value * multip)); } return gridHeight; } +bool ProtoTable::checkRowForZeroHeight(const ProtoTableRow &oRow) +{ + for (const auto& cell : oRow) + { + if (cell.isRealCell()) + return false; + } + + return true; +} + void ProtoTable::initProtoTable() { const UINT countRow = m_arrTop.size(); @@ -489,6 +501,13 @@ void TCell::setGridSpan(int gridSpan) m_gridSpan = gridSpan; } +bool TCell::isRealCell() const +{ + if (m_rowSpan > 1 || m_gridSpan > 1 || m_parentDirection != TCell::none) + return false; + return true; +} + void TCell::FillTxBody(PPTX::Logic::TxBody &oTxBody) { if (m_pShape == nullptr) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h index 05421c57fe..d6416521d6 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h @@ -71,6 +71,8 @@ public: void setGridSpan(int gridSpan); + bool isRealCell()const; + private: void FillTxBody(PPTX::Logic::TxBody &oTxBody); void FillTcPr(PPTX::Logic::TableCellProperties& oTcPr); @@ -108,6 +110,7 @@ public: static std::vector getWidth(std::vector &arrCells, bool isWidth = true); static std::vector getHeight(std::vector &arrCells, bool isHeight = true); + static bool checkRowForZeroHeight(const ProtoTableRow& oRow); MProtoTable getTable() const; private: From eb032af4579aa1897c735fc002a3019fca535d84 Mon Sep 17 00:00:00 2001 From: Ivan Date: Tue, 6 Jul 2021 18:36:08 +0300 Subject: [PATCH 35/84] correct some table properties --- .../PPTFormatLib/PPTXWriter/TableWriter.cpp | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp index 502d86ec37..189e7caf0e 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp @@ -47,14 +47,13 @@ void TableWriter::FillNvGraphicFramePr(PPTX::Logic::NvGraphicFramePr& oNvGFPr) void TableWriter::FillXfrm(PPTX::Logic::Xfrm &oXFRM) { oXFRM.m_ns = L"p"; - double multip1 = m_pTableElement->m_bAnchorEnabled ? 1587.6 : 1; - double multip2 = m_pTableElement->m_bAnchorEnabled ? 1575.864 : 1; - double multip3 = m_pTableElement->m_bAnchorEnabled ? 1232.137 : 1; - oXFRM.offX = int(m_pTableElement->m_rcAnchor.left * multip1); - oXFRM.offY = int(m_pTableElement->m_rcAnchor.top * multip1); + double multip1 = m_pTableElement->m_bAnchorEnabled ? 1587.5 : 1; - oXFRM.extX = int(m_pTableElement->m_rcAnchor.right * multip2); - oXFRM.extY = int(m_pTableElement->m_rcAnchor.bottom * multip3); + oXFRM.offX = round(m_pTableElement->m_rcAnchor.left * multip1); + oXFRM.offY = round(m_pTableElement->m_rcAnchor.top * multip1); + + oXFRM.extX = round(m_pTableElement->m_rcAnchor.GetWidth() * multip1); + oXFRM.extY = round(m_pTableElement->m_rcAnchor.GetHeight() * multip1); } void TableWriter::FillTable(PPTX::Logic::Table &oTable) @@ -103,11 +102,11 @@ std::vector ProtoTable::getWidth(std::vector& arrCells, boo } std::vector gridWidth; - double multip = isWidth ? 1587.6 : 1.0; + double multip = isWidth ? 1587.5 : 1.0; for (const auto& w : mapLeftWidth) { double value = isWidth ? w.second : w.first; - gridWidth.push_back(int(value * multip)); + gridWidth.push_back(round(value * multip)); } return gridWidth; @@ -348,9 +347,9 @@ MProtoTable ProtoTable::getTable() const void TableWriter::FillTblPr(PPTX::Logic::TableProperties &oTblPr) { - oTblPr.TableStyleId = L"{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}"; - oTblPr.FirstRow = true; - oTblPr.BandRow = true; +// oTblPr.TableStyleId = L"{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}"; +// oTblPr.FirstRow = true; +// oTblPr.BandRow = true; } void TableWriter::FillTblGrid(std::vector &tblGrid, std::vector& arrCells) @@ -462,10 +461,10 @@ TCell::eMergeDirection TCell::parentDirection() const int TCell::getHeight() const { auto pShape = m_pParent ? m_pParent->m_pShape : m_pShape; - double multip = pShape->m_bAnchorEnabled ? 1587.6 : 1; + double multip = pShape->m_bAnchorEnabled ? 1587.5 : 1; double height = pShape->m_rcChildAnchor.bottom - pShape->m_rcChildAnchor.top; - return int(height * multip); + return round(height * multip); } void TCell::setPParent(TCell *pParent) @@ -503,7 +502,7 @@ void TCell::setGridSpan(int gridSpan) bool TCell::isRealCell() const { - if (m_rowSpan > 1 || m_gridSpan > 1 || m_parentDirection != TCell::none) + if (m_rowSpan == 2 || m_gridSpan == 2 || m_parentDirection != TCell::none) return false; return true; } From 53accfc084f2b7a4a4094e94e28fbd2bbeafa216 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Wed, 7 Jul 2021 18:34:24 +0300 Subject: [PATCH 36/84] add styles for tables (not all) --- .../PPTFormatLib/PPTXWriter/TableWriter.cpp | 2 +- .../PPTXWriter/TxBodyConverter.cpp | 154 +++++++++++++++++- .../PPTFormatLib/PPTXWriter/TxBodyConverter.h | 4 + 3 files changed, 158 insertions(+), 2 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp index 189e7caf0e..349a4e9eb1 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp @@ -13,7 +13,7 @@ void TableWriter::Convert(PPTX::Logic::GraphicFrame &oGraphicFrame) if (!m_pTableElement) return; - if (m_pTableElement->m_xmlRawData.empty()/* || true*/) + if (m_pTableElement->m_xmlRawData.empty() /*|| true*/) { oGraphicFrame.nvGraphicFramePr = new PPTX::Logic::NvGraphicFramePr; FillNvGraphicFramePr(oGraphicFrame.nvGraphicFramePr.get2()); diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp index 743bff3250..bbe830b654 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp @@ -1,5 +1,6 @@ #include "TxBodyConverter.h" #include "../../../Common/MS-LCID.h" +#include "StylesWriter.h" using namespace PPT_FORMAT; @@ -22,8 +23,10 @@ void TxBodyConverter::ConvertTableTxBody(PPTX::Logic::TxBody &oTxBody) { oTxBody.bodyPr = new PPTX::Logic::BodyPr; oTxBody.lstStyle = new PPTX::Logic::TextListStyle; + oTxBody.m_name = L"a:txBody"; + FillLstStyles(oTxBody.lstStyle.get2(), m_pText->m_oStyles); FillParagraphs(oTxBody.Paragrs, m_pText->m_arParagraphs); } @@ -74,6 +77,33 @@ void TxBodyConverter::FillParagraph(PPTX::Logic::Paragraph &p, CParagraph ¶g FillEndParaRPr(p.endParaRPr.get2(), paragraph.m_oPFRun); } +void TxBodyConverter::FillLstStyles(PPTX::Logic::TextListStyle &oTLS, CTextStyles &oStyles) +{ + auto* pLevels = oStyles.m_pLevels; + for (int i = 0; i < 10; i++) + { + if (pLevels[i].is_init()) + { + PPTX::Logic::TextParagraphPr level; + ConvertStyleLevel(level, pLevels[i].get(), i); + oTLS.levels[i] = std::move(level); + } + } + +} + +void TxBodyConverter::ConvertStyleLevel(PPTX::Logic::TextParagraphPr &oLevel, CTextStyleLevel& oOldLevel, const int &nLevel) +{ + if (nLevel == 9) + oLevel.m_name = _T("a:defPPr"); + else + { + oLevel.m_name = L"a:lvl" + std::to_wstring(nLevel + 1) + L"pPr"; + } + + ConverpPFRun(oLevel, &oOldLevel.m_oPFRun); +} + void TxBodyConverter::FillRun(PPTX::Logic::Run &oRun, CSpan& oSpan) { oRun.SetText(oSpan.m_strText); @@ -187,7 +217,7 @@ void TxBodyConverter::FillPPr(PPTX::Logic::TextParagraphPr &oPPr, CParagraph &pa { auto pSpcBef = new PPTX::Logic::TextSpacing; pSpcBef->m_name = L"a:spcBef"; - pSpcBef->spcPts = (int)(12.5 * oPFRun.spaceBefore.get()); + pSpcBef->spcPts = round(12.5 * oPFRun.spaceBefore.get()); oPPr.spcBef = pSpcBef; } @@ -333,3 +363,125 @@ void TxBodyConverter::FillBuChar(PPTX::Logic::Bullet &oBullet, WCHAR symbol) pBuChar->Char.push_back(symbol); oBullet.m_Bullet.reset(pBuChar); } + +void TxBodyConverter::ConverpPFRun(PPTX::Logic::TextParagraphPr &oLevel, CTextPFRun *pPF) +{ + if (pPF->textDirection.is_init()) + { + if (pPF->textDirection.get() == 1) oLevel.rtl = true; + else oLevel.rtl = false; + } + if (pPF->fontAlign.is_init()) + { + oLevel.fontAlgn = new PPTX::Limit::FontAlign; + oLevel.fontAlgn->set(CStylesWriter::GetFontAlign(pPF->fontAlign.get())); + } + + int leftMargin = 0; + if (pPF->leftMargin.is_init()) + { + leftMargin = pPF->leftMargin.get(); + oLevel.marL = leftMargin; + } + if (pPF->indent.is_init()) + { + oLevel.indent = pPF->indent.get() - leftMargin; + } + if (pPF->textAlignment.is_init()) + { + oLevel.algn = new PPTX::Limit::TextAlign; + oLevel.algn->set(CStylesWriter::GetTextAlign(pPF->textAlignment.get())); + } + if (pPF->defaultTabSize.is_init()) + { + oLevel.defTabSz = pPF->defaultTabSize.get(); + } + + ConvertTabStops(oLevel.tabLst, pPF->tabStops); + + if (pPF->lineSpacing.is_init()) + { + auto pLnSpc = new PPTX::Logic::TextSpacing; + pLnSpc->m_name = L"a:lnSpc"; + pLnSpc->spcPct = *(pPF->lineSpacing) * -1000; + oLevel.lnSpc = pLnSpc; + } + + if (pPF->spaceAfter.is_init()) + { + auto pSpcAft = new PPTX::Logic::TextSpacing; + pSpcAft->m_name = L"a:spcAft"; + pSpcAft->spcPts = (int)(12.5 * pPF->spaceAfter.get()); + + oLevel.spcAft = pSpcAft; + } + if (pPF->spaceBefore.is_init()) + { + auto pSpcBef = new PPTX::Logic::TextSpacing; + pSpcBef->m_name = L"a:spcBef"; + pSpcBef->spcPts = round(12.5 * pPF->spaceBefore.get()); + + oLevel.spcBef = pSpcBef; + } + + if (pPF->bulletColor.is_init()) + { + FillBuClr(oLevel.buColor, pPF->bulletColor.get()); + } + + if (pPF->hasBullet.is_init() && *(pPF->hasBullet) == true) + { + if (pPF->bulletChar.is_init()) + { + FillBuChar(oLevel.ParagraphBullet, pPF->bulletChar.get()); + } else + { + FillBuChar(oLevel.ParagraphBullet, L'•'); + } + } + + if (pPF->bulletFontProperties.is_init()) + { + auto pTypeface = new PPTX::Logic::BulletTypeface(); + auto pFont = new PPTX::Logic::TextFont(); + pFont->m_name = _T("a:buFont"); + pFont->typeface = pPF->bulletFontProperties->Name; + pFont->pitchFamily = std::to_wstring(pPF->bulletFontProperties->PitchFamily); + pFont->charset = std::to_wstring(pPF->bulletFontProperties->PitchFamily); + + pTypeface->m_Typeface.reset(pFont); + oLevel.buTypeface.m_Typeface.reset(pTypeface); + } + + if (pPF->bulletAutoNum.is_init() && pPF->bulletFontProperties.is_init() && pPF->bulletFontProperties->Charset == 0) + { + auto pBuAutoNum = new PPTX::Logic::BuAutoNum; + oLevel.ParagraphBullet.m_Bullet.reset(pBuAutoNum); + if (pPF->bulletAutoNum->startAt.is_init() && pPF->bulletAutoNum->startAt.get() != 1) + pBuAutoNum->startAt = pPF->bulletAutoNum->startAt.get(); + if (pPF->bulletAutoNum->type.is_init()) + pBuAutoNum->type = pPF->bulletAutoNum->type.get(); + } + +} + +void TxBodyConverter::ConvertTabStops(std::vector &arrTabs, std::vector > &arrTabStops) +{ + for (size_t t = 0 ; t < arrTabStops.size(); t++) + { + PPTX::Logic::Tab tab; + tab.pos = arrTabStops[t].first; + auto pAlgn = new PPTX::Limit::TextTabAlignType; + + switch (arrTabStops[t].second) + { + case 1: pAlgn->set(L"ctr"); break; + case 2: pAlgn->set(L"r"); break; + case 3: pAlgn->set(L"dec"); break; + default: pAlgn->set(L"l"); + } + tab.algn = pAlgn; + + arrTabs.push_back(tab); + } +} diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h index caafe55f30..aa43c7eb85 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h @@ -54,6 +54,10 @@ private: private: void FillParagraphs(std::vector& arrP, std::vector& arrParagraphs); void FillParagraph(PPTX::Logic::Paragraph& p, CParagraph& paragraph); + void FillLstStyles(PPTX::Logic::TextListStyle& oTLS, CTextStyles& oStyles); + void ConvertStyleLevel(PPTX::Logic::TextParagraphPr &oLevel, CTextStyleLevel& oOldLevel, const int& nLevel); + void ConverpPFRun(PPTX::Logic::TextParagraphPr &oLevel, PPT_FORMAT::CTextPFRun* pPF); + void ConvertTabStops(std::vector& arrTabs, std::vector>& arrTabStops); void FillRun(PPTX::Logic::Run& oRun, CSpan &oSpan); void FillEndParaRPr(PPTX::Logic::RunProperties& oEndPr, CTextPFRun& oPFRun); void FillPPr(PPTX::Logic::TextParagraphPr& oPPr, CParagraph ¶graph); From 9d357572455ff0a7a797d3c5dfa9fd2fae9aed27 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Thu, 8 Jul 2021 16:44:20 +0300 Subject: [PATCH 37/84] add margins for top and down, but it fail with text. Some conditions were disable! --- .../PPTFormatLib/PPTXWriter/TableWriter.cpp | 9 ++++++- .../PPTXWriter/TxBodyConverter.cpp | 27 +++++++++++-------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp index 349a4e9eb1..8bff567b49 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp @@ -13,7 +13,7 @@ void TableWriter::Convert(PPTX::Logic::GraphicFrame &oGraphicFrame) if (!m_pTableElement) return; - if (m_pTableElement->m_xmlRawData.empty() /*|| true*/) + if (m_pTableElement->m_xmlRawData.empty() || true) { oGraphicFrame.nvGraphicFramePr = new PPTX::Logic::NvGraphicFramePr; FillNvGraphicFramePr(oGraphicFrame.nvGraphicFramePr.get2()); @@ -539,6 +539,13 @@ void TCell::FillTcPr(PPTX::Logic::TableCellProperties &oTcPr) oTcPr.AnchorCtr = true; } + oTcPr.MarB = round(m_pShape->m_pShape->m_dTextMarginBottom); // 0 + oTcPr.MarT = round(m_pShape->m_pShape->m_dTextMarginY); // 12512 + oTcPr.MarL = round(m_pShape->m_pShape->m_dTextMarginX); + oTcPr.MarR = round(m_pShape->m_pShape->m_dTextMarginRight); + + oTcPr.HorzOverflow = new PPTX::Limit::HorzOverflow; + oTcPr.HorzOverflow->set(L"overflow"); auto pSolidFill = new PPTX::Logic::SolidFill; auto& brush = m_pShape->m_oBrush; diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp index bbe830b654..c55efeb5e0 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp @@ -26,8 +26,11 @@ void TxBodyConverter::ConvertTableTxBody(PPTX::Logic::TxBody &oTxBody) oTxBody.m_name = L"a:txBody"; - FillLstStyles(oTxBody.lstStyle.get2(), m_pText->m_oStyles); - FillParagraphs(oTxBody.Paragrs, m_pText->m_arParagraphs); + if (m_pText) + { + FillLstStyles(oTxBody.lstStyle.get2(), m_pText->m_oStyles); + FillParagraphs(oTxBody.Paragrs, m_pText->m_arParagraphs); + } } void TxBodyConverter::ConvertShapeTxBody(PPTX::Logic::TxBody &oTxBody) @@ -82,7 +85,7 @@ void TxBodyConverter::FillLstStyles(PPTX::Logic::TextListStyle &oTLS, CTextStyle auto* pLevels = oStyles.m_pLevels; for (int i = 0; i < 10; i++) { - if (pLevels[i].is_init()) + if (pLevels[i].is_init() && false) { PPTX::Logic::TextParagraphPr level; ConvertStyleLevel(level, pLevels[i].get(), i); @@ -116,7 +119,7 @@ void TxBodyConverter::FillEndParaRPr(PPTX::Logic::RunProperties &oEndPr, CTextPF { oEndPr.m_name = L"a:endParaRPr"; oEndPr.lang = L"en-US"; - oEndPr.dirty = true; +// oEndPr.dirty = true; // if ((oPFRun.Size.is_init()) && (oPFRun.Size.get() > 0) && (oCFRun.Size.get() < 4001)) // { @@ -209,7 +212,7 @@ void TxBodyConverter::FillPPr(PPTX::Logic::TextParagraphPr &oPPr, CParagraph &pa { auto pSpcAft = new PPTX::Logic::TextSpacing; pSpcAft->m_name = L"a:spcAft"; - pSpcAft->spcPts = (int)(12.5 * oPFRun.spaceAfter.get()); + pSpcAft->spcPts = round(12.5 * oPFRun.spaceAfter.get()); oPPr.spcAft = pSpcAft; } @@ -377,15 +380,17 @@ void TxBodyConverter::ConverpPFRun(PPTX::Logic::TextParagraphPr &oLevel, CTextPF oLevel.fontAlgn->set(CStylesWriter::GetFontAlign(pPF->fontAlign.get())); } + int indent = 0; int leftMargin = 0; + if (pPF->indent.is_init()) + { + indent = pPF->indent.get(); +// oLevel.indent = pPF->indent.get() - leftMargin; + } if (pPF->leftMargin.is_init()) { leftMargin = pPF->leftMargin.get(); - oLevel.marL = leftMargin; - } - if (pPF->indent.is_init()) - { - oLevel.indent = pPF->indent.get() - leftMargin; + oLevel.marL = leftMargin - indent; } if (pPF->textAlignment.is_init()) { @@ -411,7 +416,7 @@ void TxBodyConverter::ConverpPFRun(PPTX::Logic::TextParagraphPr &oLevel, CTextPF { auto pSpcAft = new PPTX::Logic::TextSpacing; pSpcAft->m_name = L"a:spcAft"; - pSpcAft->spcPts = (int)(12.5 * pPF->spaceAfter.get()); + pSpcAft->spcPts = round(12.5 * pPF->spaceAfter.get()); oLevel.spcAft = pSpcAft; } From b85d11cc05aea814bd4558c8419818186ed69d8c Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Thu, 8 Jul 2021 18:44:11 +0300 Subject: [PATCH 38/84] start to rewrite table text --- .../PPTXWriter/TxBodyConverter.cpp | 537 ++++-------------- .../PPTFormatLib/PPTXWriter/TxBodyConverter.h | 12 +- 2 files changed, 104 insertions(+), 445 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp index c55efeb5e0..8a84f7647a 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp @@ -1,17 +1,20 @@ #include "TxBodyConverter.h" #include "../../../Common/MS-LCID.h" +#include "../../../ASCOfficeXlsFile2/source/XlsXlsxConverter/ShapeType.h" #include "StylesWriter.h" using namespace PPT_FORMAT; -TxBodyConverter::TxBodyConverter(CTextAttributesEx *pText, TxBodyConverter::eTxType txType) : - m_pText(pText), m_txType(txType) +TxBodyConverter::TxBodyConverter(CShapeElement *pShapeElement, TxBodyConverter::eTxType txType) : + m_pShapeElement(pShapeElement), oText(pShapeElement->m_pShape->m_oText), m_txType(txType) { - } void TxBodyConverter::FillTxBody(PPTX::Logic::TxBody &oTxBody) { + if (m_pShapeElement == nullptr) + return; + switch (m_txType) { case shape: ConvertShapeTxBody(oTxBody); break; @@ -21,16 +24,35 @@ void TxBodyConverter::FillTxBody(PPTX::Logic::TxBody &oTxBody) void TxBodyConverter::ConvertTableTxBody(PPTX::Logic::TxBody &oTxBody) { - oTxBody.bodyPr = new PPTX::Logic::BodyPr; - oTxBody.lstStyle = new PPTX::Logic::TextListStyle; - oTxBody.m_name = L"a:txBody"; - if (m_pText) + + oTxBody.bodyPr = new PPTX::Logic::BodyPr; + FillBodyPr(oTxBody.bodyPr.get2()); + + + size_t nCount = oText.m_arParagraphs.size(); + if (nCount == 0) { - FillLstStyles(oTxBody.lstStyle.get2(), m_pText->m_oStyles); - FillParagraphs(oTxBody.Paragrs, m_pText->m_arParagraphs); + oTxBody.lstStyle = new PPTX::Logic::TextListStyle; + PPTX::Logic::Paragraph paragraph; + auto pEndParaRPr = new PPTX::Logic::RunProperties; + pEndParaRPr->m_name = L"a:endParaRPr"; + pEndParaRPr->dirty = false; + paragraph.endParaRPr = pEndParaRPr; + oTxBody.Paragrs.push_back(paragraph); + + return; } + + oTxBody.lstStyle = new PPTX::Logic::TextListStyle; + + +// if (m_pText) +// { +// FillLstStyles(oTxBody.lstStyle.get2(), m_pText->m_oStyles); +// FillParagraphs(oTxBody.Paragrs, m_pText->m_arParagraphs); +// } } void TxBodyConverter::ConvertShapeTxBody(PPTX::Logic::TxBody &oTxBody) @@ -38,455 +60,86 @@ void TxBodyConverter::ConvertShapeTxBody(PPTX::Logic::TxBody &oTxBody) } -void TxBodyConverter::FillParagraphs(std::vector &arrP, std::vector &arrParagraphs) +void TxBodyConverter::FillBodyPr(PPTX::Logic::BodyPr &oBodyPr) { - if (m_pText == nullptr || m_pText->m_arParagraphs.empty()) - { - PPTX::Logic::Paragraph p; - p.endParaRPr = new PPTX::Logic::RunProperties; - p.endParaRPr->m_name = L"a:endParaRPr"; - p.endParaRPr->lang = L"en-US"; - p.endParaRPr->sz = 1800; - p.endParaRPr->dirty = false; + CDoubleRect oTextRect; + m_pShapeElement->m_pShape->GetTextRect(oTextRect); - arrP.push_back(p); - return; + oBodyPr.lIns = oTextRect.left; + oBodyPr.rIns = oTextRect.right; + oBodyPr.tIns = oTextRect.top; + oBodyPr.bIns = oTextRect.bottom; + + + auto pAnchor = new PPTX::Limit::TextAnchor; + switch (oText.m_oAttributes.m_nTextAlignVertical) + { + case 0: pAnchor->set(L"t"); break; + case 2: pAnchor->set(L"b"); break; + default: + pAnchor->set(L"ctr"); + oBodyPr.anchorCtr = false; } + oBodyPr.anchor = pAnchor; - for (auto& paragraph : arrParagraphs) + + if (m_pShapeElement->m_pShape->m_oText.m_bAutoFit) + oBodyPr.Fit.type = PPTX::Logic::TextFit::FitSpAuto; + + + if (oText.m_oAttributes.m_dTextRotate > 0) + oBodyPr.rot = round(oText.m_oAttributes.m_dTextRotate * 60000); + + + if (oText.m_nTextFlow >= 0) { - PPTX::Logic::Paragraph p; - FillParagraph(p, paragraph); - arrP.push_back(p); - } -} - -void TxBodyConverter::FillParagraph(PPTX::Logic::Paragraph &p, CParagraph ¶graph) -{ - for (auto& span : paragraph.m_arSpans) - { - PPTX::Logic::RunElem runElem; - auto pRun = new PPTX::Logic::Run(); - FillRun(*pRun, span); - runElem.InitRun(pRun); - - p.RunElems.push_back(runElem); - } - - p.pPr = new PPTX::Logic::TextParagraphPr; - FillPPr(p.pPr.get2(), paragraph); - - p.endParaRPr = new PPTX::Logic::RunProperties; - FillEndParaRPr(p.endParaRPr.get2(), paragraph.m_oPFRun); -} - -void TxBodyConverter::FillLstStyles(PPTX::Logic::TextListStyle &oTLS, CTextStyles &oStyles) -{ - auto* pLevels = oStyles.m_pLevels; - for (int i = 0; i < 10; i++) - { - if (pLevels[i].is_init() && false) + auto *pVert = new PPTX::Limit::TextVerticalType; + switch(oText.m_nTextFlow) { - PPTX::Logic::TextParagraphPr level; - ConvertStyleLevel(level, pLevels[i].get(), i); - oTLS.levels[i] = std::move(level); + case 1: + case 3: pVert->set(L"vert"); break; + case 2: pVert->set(L"vert270"); break; + case 5: pVert->set(L"wordArtVert"); break; } + oBodyPr.vert = pVert; + } + else if (oText.m_bVertical) + { + auto *pVert = new PPTX::Limit::TextVerticalType; + pVert->set(L"eaVert"); + oBodyPr.vert = pVert; } -} -void TxBodyConverter::ConvertStyleLevel(PPTX::Logic::TextParagraphPr &oLevel, CTextStyleLevel& oOldLevel, const int &nLevel) -{ - if (nLevel == 9) - oLevel.m_name = _T("a:defPPr"); - else + std::wstring prstGeom = oox::Spt2ShapeType_mini((oox::MSOSPT)m_pShapeElement->m_lShapeType); + std::wstring prstTxWarp = oox::Spt2WordArtShapeType((oox::MSOSPT)m_pShapeElement->m_lShapeType); + if (prstGeom.size() && prstTxWarp.size()) { - oLevel.m_name = L"a:lvl" + std::to_wstring(nLevel + 1) + L"pPr"; - } + auto pPrstTxWarp = new PPTX::Logic::PrstTxWarp; + pPrstTxWarp->prst.set(prstTxWarp); - ConverpPFRun(oLevel, &oOldLevel.m_oPFRun); -} -void TxBodyConverter::FillRun(PPTX::Logic::Run &oRun, CSpan& oSpan) -{ - oRun.SetText(oSpan.m_strText); + CPPTShape *pPPTShape = dynamic_cast(m_pShapeElement->m_pShape->getBaseShape().get()); + std::wstring strVal; - oRun.rPr = new PPTX::Logic::RunProperties; - FillRPr(oRun.rPr.get2(), oSpan.m_oRun); -} - -void TxBodyConverter::FillEndParaRPr(PPTX::Logic::RunProperties &oEndPr, CTextPFRun &oPFRun) -{ - oEndPr.m_name = L"a:endParaRPr"; - oEndPr.lang = L"en-US"; -// oEndPr.dirty = true; - - // if ((oPFRun.Size.is_init()) && (oPFRun.Size.get() > 0) && (oCFRun.Size.get() < 4001)) - // { - // oEndPr.sz = int(100 * oPFRun.Size.get()); - // } else - // { - // oEndPr.sz = 18; - // } - // if (oCFRun.BaseLineOffset.is_init()) - // { - // oEndPr.baseline = int(1000 * oCFRun.BaseLineOffset.get()); - // } - // if (oCFRun.FontBold.is_init()) - // { - // oEndPr.b = oCFRun.FontBold.get(); - // } - // if (oCFRun.FontItalic.is_init()) - // { - // oEndPr.i = oCFRun.FontItalic.get(); - // } - // if (oCFRun.FontUnderline.is_init()) - // { - // oEndPr.u = new PPTX::Limit::TextUnderline; - // oEndPr.u->set(oCFRun.FontUnderline.get() ? L"sng" : L"none"); - // } - // if (oCFRun.Language.is_init()) - // { - // std::wstring str_lang = msLCID2wstring(oCFRun.Language.get()); - - // if (str_lang.length() > 0) - // oEndPr.lang = msLCID2wstring(oCFRun.Language.get()); - // } -} - -void TxBodyConverter::FillPPr(PPTX::Logic::TextParagraphPr &oPPr, CParagraph ¶graph) -{ - CTextPFRun &oPFRun = paragraph.m_oPFRun; - int leftMargin = 0; - if (oPFRun.leftMargin.is_init()) - { - leftMargin = oPFRun.leftMargin.get(); - oPPr.marL = leftMargin; - oPPr.indent = -leftMargin; - } - - if (oPFRun.indent.is_init()) - oPPr.indent = oPFRun.indent.get() - leftMargin; - - if (oPFRun.bulletFontProperties.is_init()) - { - auto pBuFont = new PPTX::Logic::TextFont; - pBuFont->typeface = oPFRun.bulletFontProperties->Name; - - if ( oPFRun.bulletFontProperties->PitchFamily > 0) + for (size_t i = 0 ; (pPPTShape) && (i < pPPTShape->m_arAdjustments.size()); i++) { - pBuFont->pitchFamily = std::to_wstring(oPFRun.bulletFontProperties->PitchFamily); + PPTX::Logic::Gd gd; + switch(m_pShapeElement->m_lShapeType) + { + case oox::msosptTextFadeUp: + { + double kf = 4.63; //"волшебный" + std::wstring strVal = std::to_wstring((int)(kf * pPPTShape->m_arAdjustments[i])); + + gd.fmla = L"val"; + gd.name = L"adj"; + pPrstTxWarp->avLst.push_back(std::move(gd)); + }break; + } + } - if ( oPFRun.bulletFontProperties->Charset > 0) - { - pBuFont->charset = std::to_wstring((char)oPFRun.bulletFontProperties->Charset); - } - oPPr.buTypeface.SetParentPointer(pBuFont); - } - if (oPFRun.textAlignment.is_init()) - { - auto pAlgn = new PPTX::Limit::TextAlign; - auto old_algn = *(oPFRun.textAlignment); - BYTE algn[] = {4,0,5,2,1}; - if (sizeof (algn) > old_algn) - pAlgn->SetBYTECode(algn[old_algn]); - - oPPr.algn = pAlgn; - } - - if (paragraph.m_lTextLevel != 0) - { - oPPr.lvl = paragraph.m_lTextLevel; - } - - if (oPFRun.lineSpacing.is_init()) - { - auto pLnSpc = new PPTX::Logic::TextSpacing; - pLnSpc->m_name = L"a:lnSpc"; - pLnSpc->spcPct = *(oPFRun.lineSpacing) * -1000; - oPPr.lnSpc = pLnSpc; - } - - if (oPFRun.spaceAfter.is_init()) - { - auto pSpcAft = new PPTX::Logic::TextSpacing; - pSpcAft->m_name = L"a:spcAft"; - pSpcAft->spcPts = round(12.5 * oPFRun.spaceAfter.get()); - - oPPr.spcAft = pSpcAft; - } - if (oPFRun.spaceBefore.is_init()) - { - auto pSpcBef = new PPTX::Logic::TextSpacing; - pSpcBef->m_name = L"a:spcBef"; - pSpcBef->spcPts = round(12.5 * oPFRun.spaceBefore.get()); - - oPPr.spcBef = pSpcBef; - } - - if (oPFRun.bulletColor.is_init()) - { - FillBuClr(oPPr.buColor, oPFRun.bulletColor.get()); - } - - if (oPFRun.hasBullet.is_init() && *(oPFRun.hasBullet) == true) - { - if (oPFRun.bulletChar.is_init()) - { - FillBuChar(oPPr.ParagraphBullet, oPFRun.bulletChar.get()); - } else - { - FillBuChar(oPPr.ParagraphBullet, L'•'); - } - } - - if (oPFRun.bulletFontProperties.is_init()) - { - auto pTypeface = new PPTX::Logic::BulletTypeface(); - auto pFont = new PPTX::Logic::TextFont(); - pFont->m_name = _T("a:buFont"); - pFont->typeface = oPFRun.bulletFontProperties->Name; - pFont->pitchFamily = std::to_wstring(oPFRun.bulletFontProperties->PitchFamily); - pFont->charset = std::to_wstring(oPFRun.bulletFontProperties->PitchFamily); - - pTypeface->m_Typeface.reset(pFont); - oPPr.buTypeface.m_Typeface.reset(pTypeface); - } - - if (oPFRun.bulletAutoNum.is_init() && oPFRun.bulletFontProperties.is_init() && oPFRun.bulletFontProperties->Charset == 0) - { - auto pBuAutoNum = new PPTX::Logic::BuAutoNum; - oPPr.ParagraphBullet.m_Bullet.reset(pBuAutoNum); - if (oPFRun.bulletAutoNum->startAt.is_init() && oPFRun.bulletAutoNum->startAt.get() != 1) - pBuAutoNum->startAt = oPFRun.bulletAutoNum->startAt.get(); - if (oPFRun.bulletAutoNum->type.is_init()) - pBuAutoNum->type = oPFRun.bulletAutoNum->type.get(); - } -} - -void TxBodyConverter::FillRPr(PPTX::Logic::RunProperties &oRPr, CTextCFRun &oCFRun) -{ - if ((oCFRun.Size.is_init()) && (oCFRun.Size.get() > 0) && (oCFRun.Size.get() < 4001)) - { - oRPr.sz = int(100 * oCFRun.Size.get()); - } else - { - oRPr.sz = 1800; - } - if (oCFRun.BaseLineOffset.is_init()) - { - oRPr.baseline = int(1000 * oCFRun.BaseLineOffset.get()); - } - if (oCFRun.FontBold.is_init()) - { - oRPr.b = oCFRun.FontBold.get(); - } - else - { - oRPr.b = false; - } - if (oCFRun.FontItalic.is_init()) - { - oRPr.i = oCFRun.FontItalic.get(); - } - if (oCFRun.FontUnderline.is_init()) - { - oRPr.u = new PPTX::Limit::TextUnderline; - oRPr.u->set(oCFRun.FontUnderline.get() ? L"sng" : L"none"); - } - if (oCFRun.Language.is_init()) - { - std::wstring str_lang = msLCID2wstring(oCFRun.Language.get()); - - if (str_lang.length() > 0) - oRPr.lang = msLCID2wstring(oCFRun.Language.get()); - } - - FillEffectLst(oRPr.EffectList, oCFRun); - if (oCFRun.Color.is_init()) - FillSolidFill(oRPr.Fill, oCFRun.Color.get()); - - - if (oCFRun.font.font.is_init()) - { - oRPr.latin = new PPTX::Logic::TextFont; - FillLatin(oRPr.latin.get2(), oCFRun.font.font.get()); - } -} - -void TxBodyConverter::FillLatin(PPTX::Logic::TextFont &oLatin, CFontProperty &font) -{ - oLatin.typeface = font.Name; - oLatin.charset = std::to_wstring(font.Charset); - oLatin.pitchFamily = std::to_wstring(font.PitchFamily); - oLatin.m_name = L"a:latin"; -} - -void TxBodyConverter::FillCS(PPTX::Logic::TextFont &oCs, CFontProperties &font) -{ - // FillLatin(oCs, font); - oCs.m_name = L"a:cs"; -} - -void TxBodyConverter::FillEffectLst(PPTX::Logic::EffectProperties &oEList, CTextCFRun &oCFRun) -{ - if (oCFRun.FontShadow.is_init() && oCFRun.FontShadow.get()) - { - auto pELst = new PPTX::Logic::EffectLst; - pELst->outerShdw = new PPTX::Logic::OuterShdw; - pELst->outerShdw->blurRad = 38100; - pELst->outerShdw->dist = 38100; - pELst->outerShdw->dir = 2700000; - pELst->outerShdw->algn = new PPTX::Limit::RectAlign; - pELst->outerShdw->algn->set(L"tl"); - pELst->outerShdw->Color.SetRGBColor(0, 0, 0); - oEList.List.reset(pELst); - } -} - -void TxBodyConverter::FillSolidFill(PPTX::Logic::UniFill &oUF, CColor &oColor) -{ - auto pSolidFill = new PPTX::Logic::SolidFill; - pSolidFill->Color.SetRGBColor(oColor.GetR(), oColor.GetG(), oColor.GetB()); - oUF.Fill.reset(pSolidFill); -} - -void TxBodyConverter::FillBuClr(PPTX::Logic::BulletColor &oBuClr, CColor &oColor) -{ - auto pBuClr = new PPTX::Logic::BuClr; - pBuClr->Color.SetRGBColor(oColor.GetR(), oColor.GetG(), oColor.GetB()); - oBuClr.m_Color.reset(pBuClr); -} - -void TxBodyConverter::FillBuChar(PPTX::Logic::Bullet &oBullet, WCHAR symbol) -{ - auto pBuChar = new PPTX::Logic::BuChar; - pBuChar->Char.clear(); - pBuChar->Char.push_back(symbol); - oBullet.m_Bullet.reset(pBuChar); -} - -void TxBodyConverter::ConverpPFRun(PPTX::Logic::TextParagraphPr &oLevel, CTextPFRun *pPF) -{ - if (pPF->textDirection.is_init()) - { - if (pPF->textDirection.get() == 1) oLevel.rtl = true; - else oLevel.rtl = false; - } - if (pPF->fontAlign.is_init()) - { - oLevel.fontAlgn = new PPTX::Limit::FontAlign; - oLevel.fontAlgn->set(CStylesWriter::GetFontAlign(pPF->fontAlign.get())); - } - - int indent = 0; - int leftMargin = 0; - if (pPF->indent.is_init()) - { - indent = pPF->indent.get(); -// oLevel.indent = pPF->indent.get() - leftMargin; - } - if (pPF->leftMargin.is_init()) - { - leftMargin = pPF->leftMargin.get(); - oLevel.marL = leftMargin - indent; - } - if (pPF->textAlignment.is_init()) - { - oLevel.algn = new PPTX::Limit::TextAlign; - oLevel.algn->set(CStylesWriter::GetTextAlign(pPF->textAlignment.get())); - } - if (pPF->defaultTabSize.is_init()) - { - oLevel.defTabSz = pPF->defaultTabSize.get(); - } - - ConvertTabStops(oLevel.tabLst, pPF->tabStops); - - if (pPF->lineSpacing.is_init()) - { - auto pLnSpc = new PPTX::Logic::TextSpacing; - pLnSpc->m_name = L"a:lnSpc"; - pLnSpc->spcPct = *(pPF->lineSpacing) * -1000; - oLevel.lnSpc = pLnSpc; - } - - if (pPF->spaceAfter.is_init()) - { - auto pSpcAft = new PPTX::Logic::TextSpacing; - pSpcAft->m_name = L"a:spcAft"; - pSpcAft->spcPts = round(12.5 * pPF->spaceAfter.get()); - - oLevel.spcAft = pSpcAft; - } - if (pPF->spaceBefore.is_init()) - { - auto pSpcBef = new PPTX::Logic::TextSpacing; - pSpcBef->m_name = L"a:spcBef"; - pSpcBef->spcPts = round(12.5 * pPF->spaceBefore.get()); - - oLevel.spcBef = pSpcBef; - } - - if (pPF->bulletColor.is_init()) - { - FillBuClr(oLevel.buColor, pPF->bulletColor.get()); - } - - if (pPF->hasBullet.is_init() && *(pPF->hasBullet) == true) - { - if (pPF->bulletChar.is_init()) - { - FillBuChar(oLevel.ParagraphBullet, pPF->bulletChar.get()); - } else - { - FillBuChar(oLevel.ParagraphBullet, L'•'); - } - } - - if (pPF->bulletFontProperties.is_init()) - { - auto pTypeface = new PPTX::Logic::BulletTypeface(); - auto pFont = new PPTX::Logic::TextFont(); - pFont->m_name = _T("a:buFont"); - pFont->typeface = pPF->bulletFontProperties->Name; - pFont->pitchFamily = std::to_wstring(pPF->bulletFontProperties->PitchFamily); - pFont->charset = std::to_wstring(pPF->bulletFontProperties->PitchFamily); - - pTypeface->m_Typeface.reset(pFont); - oLevel.buTypeface.m_Typeface.reset(pTypeface); - } - - if (pPF->bulletAutoNum.is_init() && pPF->bulletFontProperties.is_init() && pPF->bulletFontProperties->Charset == 0) - { - auto pBuAutoNum = new PPTX::Logic::BuAutoNum; - oLevel.ParagraphBullet.m_Bullet.reset(pBuAutoNum); - if (pPF->bulletAutoNum->startAt.is_init() && pPF->bulletAutoNum->startAt.get() != 1) - pBuAutoNum->startAt = pPF->bulletAutoNum->startAt.get(); - if (pPF->bulletAutoNum->type.is_init()) - pBuAutoNum->type = pPF->bulletAutoNum->type.get(); - } - -} - -void TxBodyConverter::ConvertTabStops(std::vector &arrTabs, std::vector > &arrTabStops) -{ - for (size_t t = 0 ; t < arrTabStops.size(); t++) - { - PPTX::Logic::Tab tab; - tab.pos = arrTabStops[t].first; - auto pAlgn = new PPTX::Limit::TextTabAlignType; - - switch (arrTabStops[t].second) - { - case 1: pAlgn->set(L"ctr"); break; - case 2: pAlgn->set(L"r"); break; - case 3: pAlgn->set(L"dec"); break; - default: pAlgn->set(L"l"); - } - tab.algn = pAlgn; - - arrTabs.push_back(tab); + oBodyPr.prstTxWarp = pPrstTxWarp; } } diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h index aa43c7eb85..279e18f701 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h @@ -31,7 +31,7 @@ */ #pragma once -#include "../../../ASCOfficePPTXFile/Editor/Drawing/TextAttributesEx.h" +#include "../../../ASCOfficePPTXFile/Editor/Drawing/Elements.h" #include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/TxBody.h" namespace PPT_FORMAT @@ -44,7 +44,7 @@ public: shape, table }; - TxBodyConverter(CTextAttributesEx* pText, eTxType txType); + TxBodyConverter(CShapeElement* pShapeElement, eTxType txType); void FillTxBody(PPTX::Logic::TxBody& oTxBody); private: @@ -52,6 +52,10 @@ private: void ConvertShapeTxBody(PPTX::Logic::TxBody& oTxBody); private: + void FillBodyPr(PPTX::Logic::BodyPr& oBodyPr); + + + void FillParagraphs(std::vector& arrP, std::vector& arrParagraphs); void FillParagraph(PPTX::Logic::Paragraph& p, CParagraph& paragraph); void FillLstStyles(PPTX::Logic::TextListStyle& oTLS, CTextStyles& oStyles); @@ -70,7 +74,9 @@ private: void FillBuChar(PPTX::Logic::Bullet& oBullet, WCHAR symbol); private: - CTextAttributesEx* m_pText; + CShapeElement* m_pShapeElement; + CTextAttributesEx& oText; + eTxType m_txType; }; } From 436b268e49da9a7e9a08f6fe9687e95b6226064d Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Fri, 9 Jul 2021 18:43:11 +0300 Subject: [PATCH 39/84] continue to rewrite table text --- .../PPTFormatLib/PPTXWriter/TableWriter.cpp | 4 +- .../PPTFormatLib/PPTXWriter/TableWriter.h | 6 +- .../PPTXWriter/TxBodyConverter.cpp | 514 +++++++++++++++++- .../PPTFormatLib/PPTXWriter/TxBodyConverter.h | 30 +- 4 files changed, 520 insertions(+), 34 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp index 8bff567b49..665f532264 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp @@ -2,8 +2,8 @@ #include "TxBodyConverter.h" #include -TableWriter::TableWriter(CTableElement *pTableElement) : - m_pTableElement(pTableElement) +TableWriter::TableWriter(CTableElement *pTableElement, CRelsGenerator* pRels) : + m_pTableElement(pTableElement), m_pRels(pRels) { } diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h index d6416521d6..5fb553daff 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h @@ -33,6 +33,7 @@ #include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/GraphicFrame.h" #include "../../../ASCOfficePPTXFile/Editor/Drawing/Elements.h" +#include "ImageManager.h" namespace PPT_FORMAT { @@ -136,7 +137,7 @@ private: class TableWriter { public: - TableWriter(CTableElement *pTableElement); + TableWriter(CTableElement *pTableElement, CRelsGenerator* pRels); void Convert(PPTX::Logic::GraphicFrame& oGraphicFrame); @@ -159,7 +160,8 @@ private: void FillnvPr(PPTX::Logic::NvPr& oNvPr); private: - CTableElement *m_pTableElement; + CTableElement* m_pTableElement; + CRelsGenerator* m_pRels; nullable m_nPTable; }; } diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp index 8a84f7647a..2e75770766 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp @@ -5,8 +5,9 @@ using namespace PPT_FORMAT; -TxBodyConverter::TxBodyConverter(CShapeElement *pShapeElement, TxBodyConverter::eTxType txType) : - m_pShapeElement(pShapeElement), oText(pShapeElement->m_pShape->m_oText), m_txType(txType) +TxBodyConverter::TxBodyConverter(CShapeElement *pShapeElement, CRelsGenerator* pRels, TxBodyConverter::eTxType txType) : + m_pShapeElement(pShapeElement), m_pRels(pRels), oText(pShapeElement->m_pShape->m_oText), m_txType(txType), + m_bWordArt(false) { } @@ -36,23 +37,30 @@ void TxBodyConverter::ConvertTableTxBody(PPTX::Logic::TxBody &oTxBody) { oTxBody.lstStyle = new PPTX::Logic::TextListStyle; PPTX::Logic::Paragraph paragraph; - auto pEndParaRPr = new PPTX::Logic::RunProperties; - pEndParaRPr->m_name = L"a:endParaRPr"; - pEndParaRPr->dirty = false; - paragraph.endParaRPr = pEndParaRPr; + + paragraph.endParaRPr = getNewEndParaRPr(false); oTxBody.Paragrs.push_back(paragraph); return; } + // todo oTxBody.lstStyle = new PPTX::Logic::TextListStyle; + if (!m_bWordArt) + FillLstStyles(oTxBody.lstStyle.get2(), oText.m_oStyles); -// if (m_pText) -// { -// FillLstStyles(oTxBody.lstStyle.get2(), m_pText->m_oStyles); -// FillParagraphs(oTxBody.Paragrs, m_pText->m_arParagraphs); -// } + for (size_t nIndexPar = 0; nIndexPar < nCount; ++nIndexPar) + { + PPTX::Logic::Paragraph p; + FillParagraph(p,oText.m_arParagraphs[nIndexPar]); + oTxBody.Paragrs.push_back(std::move(p)); + } + // if (m_pText) + // { + // FillLstStyles(oTxBody.lstStyle.get2(), m_pText->m_oStyles); + // FillParagraphs(oTxBody.Paragrs, m_pText->m_arParagraphs); + // } } void TxBodyConverter::ConvertShapeTxBody(PPTX::Logic::TxBody &oTxBody) @@ -115,6 +123,9 @@ void TxBodyConverter::FillBodyPr(PPTX::Logic::BodyPr &oBodyPr) std::wstring prstTxWarp = oox::Spt2WordArtShapeType((oox::MSOSPT)m_pShapeElement->m_lShapeType); if (prstGeom.size() && prstTxWarp.size()) { + m_bWordArt = true; + + auto pPrstTxWarp = new PPTX::Logic::PrstTxWarp; pPrstTxWarp->prst.set(prstTxWarp); @@ -127,15 +138,15 @@ void TxBodyConverter::FillBodyPr(PPTX::Logic::BodyPr &oBodyPr) PPTX::Logic::Gd gd; switch(m_pShapeElement->m_lShapeType) { - case oox::msosptTextFadeUp: - { - double kf = 4.63; //"волшебный" - std::wstring strVal = std::to_wstring((int)(kf * pPPTShape->m_arAdjustments[i])); + case oox::msosptTextFadeUp: + { + double kf = 4.63; //"волшебный" + std::wstring strVal = std::to_wstring(round(kf * pPPTShape->m_arAdjustments[i])); - gd.fmla = L"val"; - gd.name = L"adj"; - pPrstTxWarp->avLst.push_back(std::move(gd)); - }break; + gd.fmla = L"val"; + gd.name = L"adj"; + pPrstTxWarp->avLst.push_back(std::move(gd)); + }break; } } @@ -143,3 +154,468 @@ void TxBodyConverter::FillBodyPr(PPTX::Logic::BodyPr &oBodyPr) oBodyPr.prstTxWarp = pPrstTxWarp; } } + +void TxBodyConverter::FillLstStyles(PPTX::Logic::TextListStyle &oTLS, CTextStyles &oStyles) +{ + +} + +void TxBodyConverter::FillParagraph(PPTX::Logic::Paragraph &p, CParagraph ¶graph) +{ + p.pPr = new PPTX::Logic::TextParagraphPr; + FillPPr(p.pPr.get2(), paragraph); + + size_t nCountSpans = paragraph.m_arSpans.size(); + for (size_t nSpan = 0; nSpan < nCountSpans; ++nSpan) + { + if ((nSpan == (nCountSpans - 1)) && (_T("\n") == paragraph.m_arSpans[nSpan].m_strText || paragraph.m_arSpans[nSpan].m_strText.empty()) ) + { + PPT_FORMAT::CTextCFRun* pCF = ¶graph.m_arSpans[nSpan].m_oRun; + if ((pCF->Size.is_init()) && (pCF->Size.get() > 0) && (pCF->Size.get() < 4001)) + p.endParaRPr = getNewEndParaRPr(-1, (100 * pCF->Size.get()), L"en-US"); + else + p.endParaRPr = getNewEndParaRPr(-1, -1, L"en-US"); + + continue; + } + + + int span_sz = paragraph.m_arSpans[nSpan].m_strText.length() ; + if ((span_sz==1 && ( paragraph.m_arSpans[nSpan].m_strText[0] == (wchar_t)13 )) || + ((span_sz==2 && ( paragraph.m_arSpans[nSpan].m_strText[0] == (wchar_t)13 ) && + ( paragraph.m_arSpans[nSpan].m_strText[1] == (wchar_t)13 )))) + continue; + + + PPTX::Logic::RunElem runElem; + if (paragraph.m_arSpans[nSpan].m_bBreak) + { + auto pBr = new PPTX::Logic::Br; + FillRPr(pBr->rPr.get2(), paragraph.m_arSpans[nSpan].m_oRun, true); + runElem.InitRun(pBr); + } else + { + auto pRun = new PPTX::Logic::Run(); + FillRun(*pRun, paragraph.m_arSpans[nSpan]); + runElem.InitRun(pRun); + + auto pFld = new PPTX::Logic::Fld; + if (m_pShapeElement->m_lPlaceholderType == PT_MasterSlideNumber/* && paragraph.m_arSpans[nSpan].m_bField*/) + { + pFld->id = L"{D038279B-FC19-497E-A7D1-5ADD9CAF016F}"; + pFld->type = L"slidenum"; + } else if (m_pShapeElement->m_lPlaceholderType == PT_MasterDate && m_pShapeElement->m_nFormatDate == 1/* && pParagraph->m_arSpans[nSpan].m_bField*/) + { + pFld->id = L"{D7E01130-044F-4930-9A27-C729C70D8524}"; + pFld->type = L"datetime1"; + } else { + delete pFld; + pFld = nullptr; + } + if (pFld) + { + PPTX::Logic::RunElem runElemFld; + runElemFld.InitRun(pFld); + p.RunElems.push_back(std::move(runElemFld)); + } + } + p.RunElems.push_back(std::move(runElem)); + } +} + +void TxBodyConverter::FillPPr(PPTX::Logic::TextParagraphPr &oPPr, CParagraph ¶graph) +{ + oPPr.lvl = paragraph.m_lTextLevel; + + + auto* pPF = &(paragraph.m_oPFRun); + if (pPF) + ConvertPFRun(oPPr, pPF); + +} + +void TxBodyConverter::ConvertPFRun(PPTX::Logic::TextParagraphPr &oPPr, CTextPFRun *pPF) +{ + if (pPF->textDirection.is_init()) + { + if (pPF->textDirection.get() == 1) oPPr.rtl = true; + else oPPr.rtl = false; + } + if (pPF->fontAlign.is_init()) + { + oPPr.fontAlgn = new PPTX::Limit::FontAlign; + oPPr.fontAlgn->set(CStylesWriter::GetFontAlign(pPF->fontAlign.get())); + } + + int leftMargin = 0; + if (pPF->leftMargin.is_init()) + { + leftMargin = pPF->leftMargin.get(); + oPPr.marL = leftMargin; + } + if (pPF->indent.is_init()) + { + oPPr.indent = pPF->indent.get() - leftMargin; + } + if (pPF->textAlignment.is_init()) + { + oPPr.algn = new PPTX::Limit::TextAlign; + oPPr.algn->set(CStylesWriter::GetTextAlign(pPF->textAlignment.get())); + } + if (pPF->defaultTabSize.is_init()) + { + oPPr.defTabSz = pPF->defaultTabSize.get(); + } + + ConvertTabStops(oPPr.tabLst, pPF->tabStops); + + if (pPF->lineSpacing.is_init()) + { + LONG val = pPF->lineSpacing.get(); + auto pLnSpc = new PPTX::Logic::TextSpacing; + pLnSpc->m_name = L"a:lnSpc"; + + if (val > 0) + pLnSpc->spcPct = val * 12.5; + else if (val < 0 && val > -13200) + pLnSpc->spcPct = val * -1000; + + oPPr.lnSpc = pLnSpc; + } + + if (pPF->spaceAfter.is_init()) + { + LONG val = pPF->spaceAfter.get(); + auto pSpcAft = new PPTX::Logic::TextSpacing; + pSpcAft->m_name = L"a:spcAft"; + if (val > 0) + pSpcAft->spcPts = round(12.5 * pPF->spaceAfter.get()); + else if (val < 0 && val > -13200) + pSpcAft->spcPts = val * -1000; + + oPPr.spcAft = pSpcAft; + } + if (pPF->spaceBefore.is_init()) + { + LONG val = pPF->spaceBefore.get(); + auto pSpcBef = new PPTX::Logic::TextSpacing; + pSpcBef->m_name = L"a:spcBef"; + if (val > 0) + pSpcBef->spcPts = round(12.5 * pPF->spaceBefore.get()); + else if (val < 0 && val > -13200) + pSpcBef->spcPts = val * -1000; + + oPPr.spcBef = pSpcBef; + } + + ConvertAllBullets(oPPr, pPF); +} + +void TxBodyConverter::ConvertTabStops(std::vector &arrTabs, std::vector > &arrTabStops) +{ + for (size_t t = 0 ; t < arrTabStops.size(); t++) + { + PPTX::Logic::Tab tab; + tab.pos = arrTabStops[t].first; + auto pAlgn = new PPTX::Limit::TextTabAlignType; + + switch (arrTabStops[t].second) + { + case 1: pAlgn->set(L"ctr"); break; + case 2: pAlgn->set(L"r"); break; + case 3: pAlgn->set(L"dec"); break; + default: pAlgn->set(L"l"); + } + tab.algn = pAlgn; + + arrTabs.push_back(tab); + } +} + +void TxBodyConverter::FillBuChar(PPTX::Logic::Bullet &oBullet, WCHAR symbol) +{ + auto pBuChar = new PPTX::Logic::BuChar; + pBuChar->Char.clear(); + pBuChar->Char.push_back(symbol); + oBullet.m_Bullet.reset(pBuChar); +} + +void TxBodyConverter::ConvertAllBullets(PPTX::Logic::TextParagraphPr &oPPr, CTextPFRun *pPF) +{ + + if (pPF->hasBullet.is_init()) + { + if (pPF->hasBullet.get()) + { + if (pPF->bulletColor.is_init()) + { + FillBuClr(oPPr.buColor, pPF->bulletColor.get()); + } + if (pPF->bulletSize.is_init()) + { + PPTX::WrapperWritingElement* pBuSize; + if (pPF->bulletSize.get() > 24 && pPF->bulletSize.get() < 401) + { + pBuSize = new PPTX::Logic::BuSzPct; + static_cast(pBuSize)->val = pPF->bulletSize.get() * 1000 ; + } + if (pPF->bulletSize.get() < 0 && pPF->bulletSize.get() > -4001) + { + pBuSize = new PPTX::Logic::BuSzPts; + static_cast(pBuSize)->val = - (pPF->bulletSize.get()); + } + oPPr.buSize.m_Size = pBuSize; + } + if (pPF->bulletFontProperties.is_init()) + { + auto pBuFont = new PPTX::Logic::TextFont; + pBuFont->m_name = L"a:buFont"; + pBuFont->typeface = pPF->bulletFontProperties->Name; + + if ( pPF->bulletFontProperties->PitchFamily > 0) + pBuFont->pitchFamily = std::to_wstring(pPF->bulletFontProperties->PitchFamily); + if ( pPF->bulletFontProperties->Charset > 0) + pBuFont->charset = std::to_wstring(pPF->bulletFontProperties->Charset); + + oPPr.buTypeface.m_Typeface.reset(pBuFont); + } + if (pPF->bulletAutoNum.is_init()) + { + auto pBuAutoNum = new PPTX::Logic::BuAutoNum; + oPPr.ParagraphBullet.m_Bullet.reset(pBuAutoNum); + if (pPF->bulletAutoNum->startAt.is_init() && pPF->bulletAutoNum->startAt.get() != 1) + pBuAutoNum->startAt = pPF->bulletAutoNum->startAt.get(); + if (pPF->bulletAutoNum->type.is_init()) + pBuAutoNum->type = pPF->bulletAutoNum->type.get(); + } + + bool set = true; + if (pPF->bulletFontProperties.is_init() == false && pPF->bulletSize.is_init() == false) + { + auto pBuFont = new PPTX::Logic::BuFontTx; + oPPr.buTypeface.m_Typeface.reset(pBuFont); + if (pPF->bulletColor.is_init() == false) + set = false; + } + + if (pPF->bulletChar.is_init()) + { + FillBuChar(oPPr.ParagraphBullet, pPF->bulletChar.get()); + } else if (set) + { + FillBuChar(oPPr.ParagraphBullet, L'•'); + } + if (pPF->bulletColor.is_init()) + { + FillBuClr(oPPr.buColor, pPF->bulletColor.get()); + } + } + else + { + oPPr.buTypeface.m_Typeface.reset(new PPTX::Logic::BuNone); + } + } + +} + +void TxBodyConverter::FillBuClr(PPTX::Logic::BulletColor &oBuClr, CColor &oColor) +{ + auto pBuClr = new PPTX::Logic::BuClr; + pBuClr->Color.SetRGBColor(oColor.GetR(), oColor.GetG(), oColor.GetB()); + oBuClr.m_Color.reset(pBuClr); +} + +void TxBodyConverter::FillRun(PPTX::Logic::Run &oRun, CSpan &oSpan) +{ + oRun.SetText(oSpan.m_strText); + + FillRPr(oRun.rPr.get2(), oSpan.m_oRun); +} + +PPTX::Logic::RunProperties *TxBodyConverter::getNewEndParaRPr(const int dirty, const int sz , const std::wstring& lang) +{ + auto pEndParaRPr = new PPTX::Logic::RunProperties; + pEndParaRPr->m_name = L"a:endParaRPr"; + + if (dirty == 0 || dirty == 1) + pEndParaRPr->dirty = (bool)dirty; + if (sz > 0) + pEndParaRPr->sz = sz; + if (lang.size()) + pEndParaRPr->lang = lang; + + return pEndParaRPr; +} + +void TxBodyConverter::FillRPr(PPTX::Logic::RunProperties &oRPr, CTextCFRun &oCFRun) +{ + if ((oCFRun.Size.is_init()) && (oCFRun.Size.get() > 0) && (oCFRun.Size.get() < 4001)) + { + oRPr.sz = int(100 * oCFRun.Size.get()); + } else + { + oRPr.sz = 1800; + } + if (oCFRun.BaseLineOffset.is_init()) + { + oRPr.baseline = int(1000 * oCFRun.BaseLineOffset.get()); + } + if (oCFRun.FontBold.is_init()) + { + oRPr.b = oCFRun.FontBold.get(); + } + else + { + oRPr.b = false; + } + if (oCFRun.FontItalic.is_init()) + { + oRPr.i = oCFRun.FontItalic.get(); + } + if (oCFRun.FontUnderline.is_init()) + { + oRPr.u = new PPTX::Limit::TextUnderline; + oRPr.u->set(oCFRun.FontUnderline.get() ? L"sng" : L"none"); + } + if (oCFRun.Language.is_init()) + { + std::wstring str_lang = msLCID2wstring(oCFRun.Language.get()); + + if (str_lang.length() > 0) + oRPr.lang = msLCID2wstring(oCFRun.Language.get()); + } + + + if (m_bWordArt) + {//порядок важен - линия, заливка, тень !!! + if (m_pShapeElement->m_bLine) + { + oRPr.ln = new PPTX::Logic::Ln; + ConvertLine(oRPr.ln.get2()); + } + m_oWriter.WriteString(ConvertBrush(pShapeElement->m_oBrush)); + m_oWriter.WriteString(ConvertShadow(pShapeElement->m_oShadow)); + } + else + { + if (pCF->Color.is_init()) + { + if (pCF->Color->m_lSchemeIndex != -1) + { + std::wstring strProp = _T(""); + m_oWriter.WriteString(strProp); + } + else + { + std::wstring strColor = XmlUtils::IntToString(pCF->Color->GetLONG_RGB(), L"%06x"); + + m_oWriter.WriteString(L""); + } + } + } + + FillEffectLst(oRPr.EffectList, oCFRun); + if (oCFRun.Color.is_init()) + FillSolidFill(oRPr.Fill, oCFRun.Color.get()); + + + if (oCFRun.font.font.is_init()) + { + oRPr.latin = new PPTX::Logic::TextFont; + FillLatin(oRPr.latin.get2(), oCFRun.font.font.get()); + } +} + +void TxBodyConverter::ConvertLine(PPTX::Logic::Ln &oLn) +{ + auto& oPen = m_pShapeElement->m_oPen; + oLn.cmpd = new PPTX::Limit::CompoundLine; + switch(oPen.LineStyle) + { + case 1: oLn.cmpd->set(L"dbl"); break; + case 2: oLn.cmpd->set(L"thickThin"); break; + case 3: oLn.cmpd->set(L"thinThick"); break; + case 4: oLn.cmpd->set(L"tri"); break; + } + + + oLn.w = oPen.Size; + FillSolidFill(oLn.Fill, oPen.Color); + + if (oPen.DashStyle > 0 && oPen.DashStyle < 11) + { + oLn.prstDash = new PPTX::Logic::PrstDash; + oLn.prstDash.get2().val = new PPTX::Limit::PrstDashVal; + auto& val = oLn.prstDash.get2().val; + switch(oPen.DashStyle) + { + case 1: val->set(L"sysDash"); break; + case 2: val->set(L"sysDot"); break; + case 3: val->set(L"sysDashDot"); break; + case 4: val->set(L"sysDashDotDot"); break; + case 5: val->set(L"dot"); break; + case 6: val->set(L"dash"); break; + case 7: val->set(L"lgDash"); break; + case 8: val->set(L"dashDot"); break; + case 9: val->set(L"lgDashDot"); break; + case 10: val->set(L"lgDashDotDot"); break; + } + } + + switch(oPen.LineJoin) + { + case 0: oLn.Join.type = PPTX::Logic::eJoin::JoinBevel; break; + case 1: oLn.Join.type = PPTX::Logic::eJoin::JoinMiter; break; + case 2: oLn.Join.type = PPTX::Logic::eJoin::JoinRound; break; + } + + oLn.headEnd = new PPTX::Logic::LineEnd; + oLn.tailEnd = new PPTX::Logic::LineEnd; + + ConvertLineEnd(oLn.headEnd.get2(), oPen.LineStartCap, oPen.LineStartLength, oPen.LineStartWidth, true); + ConvertLineEnd(oLn.tailEnd.get2(), oPen.LineEndCap, oPen.LineEndLength, oPen.LineEndWidth, false); +} + +void TxBodyConverter::ConvertLineEnd(PPTX::Logic::LineEnd &oLine, unsigned char cap, unsigned char length, unsigned char width, bool isHead) +{ + if (cap < 1) + return; + + if (isHead) + oLine.m_name = L"a:headEnd"; + else + oLine.m_name = L"a:tailEnd"; + + oLine.type = new PPTX::Limit::LineEndType; + switch(cap) + { + case 1: oLine.type->set(L"triangle"); break; + case 2: oLine.type->set(L"stealth"); break; + case 3: oLine.type->set(L"diamond"); break; + case 4: oLine.type->set(L"oval"); break; + case 5: oLine.type->set(L"arrow"); break; + } + + oLine.len = new PPTX::Limit::LineEndSize; + switch(length) + { + case 0: oLine.len->set(L"sm"); break; + case 1: oLine.len->set(L"med"); break; + case 2: oLine.len->set(L"lg"); break; + } + + oLine.w = new PPTX::Limit::LineEndSize; + switch(width) + { + case 0: oLine.w->set(L"sm"); break; + case 1: oLine.w->set(L"med"); break; + case 2: oLine.w->set(L"lg"); break; + } +} + +void TxBodyConverter::FillSolidFill(PPTX::Logic::UniFill &oUF, CColor &oColor) +{ + auto pSolidFill = new PPTX::Logic::SolidFill; + pSolidFill->Color.SetRGBColor(oColor.GetR(), oColor.GetG(), oColor.GetB()); + oUF.Fill.reset(pSolidFill); +} diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h index 279e18f701..d801044341 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h @@ -33,6 +33,7 @@ #include "../../../ASCOfficePPTXFile/Editor/Drawing/Elements.h" #include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/TxBody.h" +#include "ImageManager.h" namespace PPT_FORMAT { @@ -44,7 +45,7 @@ public: shape, table }; - TxBodyConverter(CShapeElement* pShapeElement, eTxType txType); + TxBodyConverter(CShapeElement* pShapeElement, CRelsGenerator* pRels, eTxType txType); void FillTxBody(PPTX::Logic::TxBody& oTxBody); private: @@ -53,30 +54,37 @@ private: private: void FillBodyPr(PPTX::Logic::BodyPr& oBodyPr); + void FillLstStyles(PPTX::Logic::TextListStyle& oTLS, CTextStyles& oStyles); + void FillParagraph(PPTX::Logic::Paragraph& p, CParagraph& paragraph); + void FillPPr(PPTX::Logic::TextParagraphPr& oPPr, CParagraph ¶graph); + void ConvertPFRun(PPTX::Logic::TextParagraphPr &oPPr, PPT_FORMAT::CTextPFRun* pPF); + void ConvertTabStops(std::vector& arrTabs, std::vector>& arrTabStops); + void FillBuChar(PPTX::Logic::Bullet& oBullet, WCHAR symbol); + void ConvertAllBullets(PPTX::Logic::TextParagraphPr &oPPr, CTextPFRun *pPF); + void FillBuClr(PPTX::Logic::BulletColor& oBuClr, CColor& oColor); + void FillRun(PPTX::Logic::Run& oRun, CSpan &oSpan); + PPTX::Logic::RunProperties* getNewEndParaRPr(const int dirty = -1, const int sz = -1, const std::wstring& lang = L""); + void FillRPr(PPTX::Logic::RunProperties& oRPr, CTextCFRun& oCFRun); + void ConvertLine(PPTX::Logic::Ln& oLn); + void ConvertLineEnd(PPTX::Logic::LineEnd& oLine, unsigned char cap, unsigned char length, unsigned char width, bool isHead); + void ConvertBrush(PPTX::Logic::RunProperties& oRPr); + void FillSolidFill(PPTX::Logic::UniFill& oUF, CColor& oColor); void FillParagraphs(std::vector& arrP, std::vector& arrParagraphs); - void FillParagraph(PPTX::Logic::Paragraph& p, CParagraph& paragraph); - void FillLstStyles(PPTX::Logic::TextListStyle& oTLS, CTextStyles& oStyles); void ConvertStyleLevel(PPTX::Logic::TextParagraphPr &oLevel, CTextStyleLevel& oOldLevel, const int& nLevel); - void ConverpPFRun(PPTX::Logic::TextParagraphPr &oLevel, PPT_FORMAT::CTextPFRun* pPF); - void ConvertTabStops(std::vector& arrTabs, std::vector>& arrTabStops); - void FillRun(PPTX::Logic::Run& oRun, CSpan &oSpan); void FillEndParaRPr(PPTX::Logic::RunProperties& oEndPr, CTextPFRun& oPFRun); - void FillPPr(PPTX::Logic::TextParagraphPr& oPPr, CParagraph ¶graph); - void FillRPr(PPTX::Logic::RunProperties& oRPr, CTextCFRun& oCFRun); void FillLatin(PPTX::Logic::TextFont& oLatin, CFontProperty &font); void FillCS(PPTX::Logic::TextFont& oCs, CFontProperties& font); void FillEffectLst(PPTX::Logic::EffectProperties &oEList, CTextCFRun& oCFRun); - void FillSolidFill(PPTX::Logic::UniFill& oUF, CColor& oColor); - void FillBuClr(PPTX::Logic::BulletColor& oBuClr, CColor& oColor); - void FillBuChar(PPTX::Logic::Bullet& oBullet, WCHAR symbol); private: CShapeElement* m_pShapeElement; + CRelsGenerator* m_pRels; CTextAttributesEx& oText; eTxType m_txType; + bool m_bWordArt; }; } From 2559e97f48b448e8bb774d2c373f69a4eefc4329 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Mon, 12 Jul 2021 17:52:37 +0300 Subject: [PATCH 40/84] finish to rewrite table text. Can merge with develop --- .../PPTFormatLib/PPTXWriter/Converter.cpp | 2 +- .../PPTFormatLib/PPTXWriter/TableWriter.cpp | 38 +++--- .../PPTFormatLib/PPTXWriter/TableWriter.h | 9 +- .../PPTXWriter/TxBodyConverter.cpp | 122 ++++++++++++++---- .../PPTFormatLib/PPTXWriter/TxBodyConverter.h | 7 +- 5 files changed, 131 insertions(+), 47 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp index c0cfc44b2f..0e3f720ab2 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp @@ -1038,7 +1038,7 @@ void PPT_FORMAT::CPPTXWriter::WriteTable(CStringWriter& oWriter, CRelsGenerator& PPTX::Logic::GraphicFrame gf; - TableWriter(pTableElement).Convert(gf); + TableWriter(pTableElement, &oRels).Convert(gf); oWriter.WriteString(gf.toXML()); } void PPT_FORMAT::CPPTXWriter::WriteElement(CStringWriter& oWriter, CRelsGenerator& oRels, CElementPtr pElement, CLayout* pLayout) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp index 665f532264..cf19fc11e6 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.cpp @@ -13,7 +13,7 @@ void TableWriter::Convert(PPTX::Logic::GraphicFrame &oGraphicFrame) if (!m_pTableElement) return; - if (m_pTableElement->m_xmlRawData.empty() || true) + if (m_pTableElement->m_xmlRawData.empty()/* || true*/) { oGraphicFrame.nvGraphicFramePr = new PPTX::Logic::NvGraphicFramePr; FillNvGraphicFramePr(oGraphicFrame.nvGraphicFramePr.get2()); @@ -27,7 +27,7 @@ void TableWriter::Convert(PPTX::Logic::GraphicFrame &oGraphicFrame) else { oGraphicFrame.fromXMLString(getXmlForGraphicFrame()); - CorrectGraphicFrame(oGraphicFrame); +// CorrectGraphicFrame(oGraphicFrame); } } @@ -63,7 +63,7 @@ void TableWriter::FillTable(PPTX::Logic::Table &oTable) std::vector arrCells, arrSpliters; prepareShapes(arrCells, arrSpliters); - m_nPTable = new ProtoTable(arrCells, arrSpliters); + m_nPTable = new ProtoTable(arrCells, arrSpliters, m_pRels); FillTblGrid(oTable.TableCols , arrCells); @@ -168,7 +168,7 @@ void ProtoTable::initProtoTable() { ProtoTableRow protoRow; for (UINT cCol = 0; cCol < countCol; cCol++) - protoRow.push_back(TCell(nullptr, cRow, cCol, nullptr)); + protoRow.push_back(TCell(nullptr, cRow, cCol, m_pRels, nullptr)); m_table.push_back(protoRow); } @@ -226,8 +226,8 @@ bool ProtoTable::fillCells(std::vector &arrCells) pParent->setPParent(nullptr); pParent->setPShape(pCell); -// pParent->setGridSpan(posRightCol - posCol); -// pParent->setRowSpan(posBottomRow - posRow); + // pParent->setGridSpan(posRightCol - posCol); + // pParent->setRowSpan(posBottomRow - posRow); } return true; @@ -347,9 +347,9 @@ MProtoTable ProtoTable::getTable() const void TableWriter::FillTblPr(PPTX::Logic::TableProperties &oTblPr) { -// oTblPr.TableStyleId = L"{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}"; -// oTblPr.FirstRow = true; -// oTblPr.BandRow = true; + // oTblPr.TableStyleId = L"{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}"; + // oTblPr.FirstRow = true; + // oTblPr.BandRow = true; } void TableWriter::FillTblGrid(std::vector &tblGrid, std::vector& arrCells) @@ -418,9 +418,9 @@ void TableWriter::FillnvPr(PPTX::Logic::NvPr &oNvPr) oNvPr.extLst.push_back(ext); } -TCell::TCell(CShapeElement *pShape, int row, int col, TCell *pParent) : +TCell::TCell(CShapeElement *pShape, int row, int col, CRelsGenerator* pRels, TCell *pParent) : m_pShape(pShape), m_row(row), m_col(col), m_rowSpan(1), m_gridSpan(1), - m_pParent(pParent), m_parentDirection(none) + m_pParent(pParent), m_parentDirection(none), m_pRels(pRels) { setParentDirection(); } @@ -511,11 +511,11 @@ void TCell::FillTxBody(PPTX::Logic::TxBody &oTxBody) { if (m_pShape == nullptr) { - TxBodyConverter txBodyConverter(nullptr, TxBodyConverter::table); + TxBodyConverter txBodyConverter(nullptr, m_pRels, TxBodyConverter::table); txBodyConverter.FillTxBody(oTxBody); } else { - TxBodyConverter txBodyConverter(&m_pShape->m_pShape->m_oText, TxBodyConverter::table); + TxBodyConverter txBodyConverter(m_pShape, m_pRels, TxBodyConverter::table); txBodyConverter.FillTxBody(oTxBody); } @@ -544,8 +544,11 @@ void TCell::FillTcPr(PPTX::Logic::TableCellProperties &oTcPr) oTcPr.MarL = round(m_pShape->m_pShape->m_dTextMarginX); oTcPr.MarR = round(m_pShape->m_pShape->m_dTextMarginRight); - oTcPr.HorzOverflow = new PPTX::Limit::HorzOverflow; - oTcPr.HorzOverflow->set(L"overflow"); + if (true) + { + oTcPr.HorzOverflow = new PPTX::Limit::HorzOverflow; + oTcPr.HorzOverflow->set(L"overflow"); + } auto pSolidFill = new PPTX::Logic::SolidFill; auto& brush = m_pShape->m_oBrush; @@ -605,7 +608,7 @@ void TCell::FillLn(PPTX::Logic::Ln &Ln, TCell::eBorderPossition eBP, CShapeEleme auto pSolidFill = new PPTX::Logic::SolidFill; auto& clr = pen.Color; pSolidFill->Color.SetRGBColor(clr.GetR(), clr.GetG(), clr.GetB()); - if (pen.Alpha) + if (pen.Alpha && pen.Alpha != 255) { PPTX::Logic::ColorModifier alpha; alpha.name = L"a:alpha"; @@ -657,7 +660,8 @@ void TCell::setPShape(CShapeElement *pShape) ProtoTable::ProtoTable(std::vector &arrCells, - std::vector& arrSpliters) + std::vector& arrSpliters, + CRelsGenerator *pRels) : m_pRels(pRels) { m_arrLeft = getWidth(arrCells, false); m_arrTop = getHeight(arrCells, false); diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h index 5fb553daff..78239491f7 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TableWriter.h @@ -40,7 +40,7 @@ namespace PPT_FORMAT class TCell { public: - TCell(CShapeElement *pShape, int row, int col, TCell* pParent = nullptr); + TCell(CShapeElement *pShape, int row, int col, CRelsGenerator* pRels, TCell* pParent = nullptr); void FillTc(PPTX::Logic::TableCell &oTc); @@ -96,6 +96,9 @@ private: // Parent TCell* m_pParent; eMergeDirection m_parentDirection; + + // Common + CRelsGenerator* m_pRels; }; @@ -107,7 +110,8 @@ class ProtoTable { public: ProtoTable(std::vector &arrCells, - std::vector& arrSpliters); + std::vector& arrSpliters, + CRelsGenerator* pRels); static std::vector getWidth(std::vector &arrCells, bool isWidth = true); static std::vector getHeight(std::vector &arrCells, bool isHeight = true); @@ -132,6 +136,7 @@ private: std::vector m_arrLeft; std::vector m_arrTop; MProtoTable m_table; + CRelsGenerator* m_pRels; }; class TableWriter diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp index 2e75770766..ca4a195f46 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.cpp @@ -1,20 +1,28 @@ #include "TxBodyConverter.h" #include "../../../Common/MS-LCID.h" #include "../../../ASCOfficeXlsFile2/source/XlsXlsxConverter/ShapeType.h" +#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SchemeClr.h" #include "StylesWriter.h" using namespace PPT_FORMAT; TxBodyConverter::TxBodyConverter(CShapeElement *pShapeElement, CRelsGenerator* pRels, TxBodyConverter::eTxType txType) : - m_pShapeElement(pShapeElement), m_pRels(pRels), oText(pShapeElement->m_pShape->m_oText), m_txType(txType), + m_pShapeElement(pShapeElement), m_pRels(pRels), m_txType(txType), m_bWordArt(false) { + if (pShapeElement && pShapeElement->m_pShape) + pText = &pShapeElement->m_pShape->m_oText; + else + pText = nullptr; } void TxBodyConverter::FillTxBody(PPTX::Logic::TxBody &oTxBody) { if (m_pShapeElement == nullptr) + { + FillMergedTxBody(oTxBody); return; + } switch (m_txType) { @@ -32,28 +40,33 @@ void TxBodyConverter::ConvertTableTxBody(PPTX::Logic::TxBody &oTxBody) FillBodyPr(oTxBody.bodyPr.get2()); - size_t nCount = oText.m_arParagraphs.size(); + size_t nCount = pText->m_arParagraphs.size(); if (nCount == 0) { oTxBody.lstStyle = new PPTX::Logic::TextListStyle; PPTX::Logic::Paragraph paragraph; - - paragraph.endParaRPr = getNewEndParaRPr(false); + unsigned sz = m_pShapeElement->m_rcChildAnchor.GetHeight() * 10; + paragraph.endParaRPr = getNewEndParaRPr(false, sz > 2000 ? 2000 : sz); oTxBody.Paragrs.push_back(paragraph); return; } + + if (pText == nullptr) + return; + + // todo oTxBody.lstStyle = new PPTX::Logic::TextListStyle; if (!m_bWordArt) - FillLstStyles(oTxBody.lstStyle.get2(), oText.m_oStyles); + FillLstStyles(oTxBody.lstStyle.get2(), pText->m_oStyles); for (size_t nIndexPar = 0; nIndexPar < nCount; ++nIndexPar) { PPTX::Logic::Paragraph p; - FillParagraph(p,oText.m_arParagraphs[nIndexPar]); + FillParagraph(p,pText->m_arParagraphs[nIndexPar]); oTxBody.Paragrs.push_back(std::move(p)); } // if (m_pText) @@ -68,6 +81,17 @@ void TxBodyConverter::ConvertShapeTxBody(PPTX::Logic::TxBody &oTxBody) } +void TxBodyConverter::FillMergedTxBody(PPTX::Logic::TxBody &oTxBody) +{ + oTxBody.lstStyle = new PPTX::Logic::TextListStyle; + oTxBody.bodyPr = new PPTX::Logic::BodyPr; + oTxBody.lstStyle = new PPTX::Logic::TextListStyle; + + PPTX::Logic::Paragraph paragraph; + paragraph.endParaRPr = getNewEndParaRPr(); + oTxBody.Paragrs.push_back(paragraph); +} + void TxBodyConverter::FillBodyPr(PPTX::Logic::BodyPr &oBodyPr) { CDoubleRect oTextRect; @@ -80,7 +104,7 @@ void TxBodyConverter::FillBodyPr(PPTX::Logic::BodyPr &oBodyPr) auto pAnchor = new PPTX::Limit::TextAnchor; - switch (oText.m_oAttributes.m_nTextAlignVertical) + switch (pText->m_oAttributes.m_nTextAlignVertical) { case 0: pAnchor->set(L"t"); break; case 2: pAnchor->set(L"b"); break; @@ -95,14 +119,14 @@ void TxBodyConverter::FillBodyPr(PPTX::Logic::BodyPr &oBodyPr) oBodyPr.Fit.type = PPTX::Logic::TextFit::FitSpAuto; - if (oText.m_oAttributes.m_dTextRotate > 0) - oBodyPr.rot = round(oText.m_oAttributes.m_dTextRotate * 60000); + if (pText->m_oAttributes.m_dTextRotate > 0) + oBodyPr.rot = round(pText->m_oAttributes.m_dTextRotate * 60000); - if (oText.m_nTextFlow >= 0) + if (pText->m_nTextFlow >= 0) { auto *pVert = new PPTX::Limit::TextVerticalType; - switch(oText.m_nTextFlow) + switch(pText->m_nTextFlow) { case 1: case 3: pVert->set(L"vert"); break; @@ -111,7 +135,7 @@ void TxBodyConverter::FillBodyPr(PPTX::Logic::BodyPr &oBodyPr) } oBodyPr.vert = pVert; } - else if (oText.m_bVertical) + else if (pText->m_bVertical) { auto *pVert = new PPTX::Limit::TextVerticalType; pVert->set(L"eaVert"); @@ -191,7 +215,8 @@ void TxBodyConverter::FillParagraph(PPTX::Logic::Paragraph &p, CParagraph ¶g if (paragraph.m_arSpans[nSpan].m_bBreak) { auto pBr = new PPTX::Logic::Br; - FillRPr(pBr->rPr.get2(), paragraph.m_arSpans[nSpan].m_oRun, true); + pBr->rPr = new PPTX::Logic::RunProperties; + FillRPr(pBr->rPr.get2(), paragraph.m_arSpans[nSpan].m_oRun); runElem.InitRun(pBr); } else { @@ -379,6 +404,7 @@ void TxBodyConverter::ConvertAllBullets(PPTX::Logic::TextParagraphPr &oPPr, CTex oPPr.buTypeface.m_Typeface.reset(pBuFont); } + bool set = true; if (pPF->bulletAutoNum.is_init()) { auto pBuAutoNum = new PPTX::Logic::BuAutoNum; @@ -387,9 +413,9 @@ void TxBodyConverter::ConvertAllBullets(PPTX::Logic::TextParagraphPr &oPPr, CTex pBuAutoNum->startAt = pPF->bulletAutoNum->startAt.get(); if (pPF->bulletAutoNum->type.is_init()) pBuAutoNum->type = pPF->bulletAutoNum->type.get(); + set = false; } - bool set = true; if (pPF->bulletFontProperties.is_init() == false && pPF->bulletSize.is_init() == false) { auto pBuFont = new PPTX::Logic::BuFontTx; @@ -429,6 +455,7 @@ void TxBodyConverter::FillRun(PPTX::Logic::Run &oRun, CSpan &oSpan) { oRun.SetText(oSpan.m_strText); + oRun.rPr = new PPTX::Logic::RunProperties; FillRPr(oRun.rPr.get2(), oSpan.m_oRun); } @@ -449,6 +476,7 @@ PPTX::Logic::RunProperties *TxBodyConverter::getNewEndParaRPr(const int dirty, c void TxBodyConverter::FillRPr(PPTX::Logic::RunProperties &oRPr, CTextCFRun &oCFRun) { + oRPr.normalizeH = false; if ((oCFRun.Size.is_init()) && (oCFRun.Size.get() > 0) && (oCFRun.Size.get() < 4001)) { oRPr.sz = int(100 * oCFRun.Size.get()); @@ -493,23 +521,21 @@ void TxBodyConverter::FillRPr(PPTX::Logic::RunProperties &oRPr, CTextCFRun &oCFR oRPr.ln = new PPTX::Logic::Ln; ConvertLine(oRPr.ln.get2()); } - m_oWriter.WriteString(ConvertBrush(pShapeElement->m_oBrush)); - m_oWriter.WriteString(ConvertShadow(pShapeElement->m_oShadow)); + // I don't know todo or not +// m_oWriter.WriteString(ConvertBrush(pShapeElement->m_oBrush)); +// m_oWriter.WriteString(ConvertShadow(pShapeElement->m_oShadow)); } else { - if (pCF->Color.is_init()) + if (oCFRun.Color.is_init()) { - if (pCF->Color->m_lSchemeIndex != -1) + if (oCFRun.Color->m_lSchemeIndex != -1) { - std::wstring strProp = _T(""); - m_oWriter.WriteString(strProp); + FillSchemeClr(oRPr.Fill, oCFRun.Color.get()); } else { - std::wstring strColor = XmlUtils::IntToString(pCF->Color->GetLONG_RGB(), L"%06x"); - - m_oWriter.WriteString(L""); + FillSolidFill(oRPr.Fill, oCFRun.Color.get()); } } } @@ -522,7 +548,25 @@ void TxBodyConverter::FillRPr(PPTX::Logic::RunProperties &oRPr, CTextCFRun &oCFR if (oCFRun.font.font.is_init()) { oRPr.latin = new PPTX::Logic::TextFont; - FillLatin(oRPr.latin.get2(), oCFRun.font.font.get()); + oRPr.latin->m_name = L"a:latin"; + oRPr.latin->typeface = oCFRun.font.font->Name; + oRPr.latin->charset = std::to_wstring(oCFRun.font.font->Charset); + oRPr.latin->pitchFamily = std::to_wstring(oCFRun.font.font->PitchFamily + 2); + } // todo else for fontRef.is_init() // it's theme + + if (oCFRun.font.ea.is_init()) + { + oRPr.ea = new PPTX::Logic::TextFont; + oRPr.ea->m_name = L"a:ea"; + oRPr.ea->typeface = oCFRun.font.ea->Name; + oRPr.ea->charset = std::to_wstring(oCFRun.font.ea->Charset); + } + if (oCFRun.font.sym.is_init()) + { + oRPr.sym = new PPTX::Logic::TextFont; + oRPr.sym->m_name = L"a:sym"; + oRPr.sym->typeface = oCFRun.font.sym->Name; + oRPr.sym->charset = std::to_wstring(oCFRun.font.sym->Charset); } } @@ -613,9 +657,39 @@ void TxBodyConverter::ConvertLineEnd(PPTX::Logic::LineEnd &oLine, unsigned char } } +void TxBodyConverter::ConvertBrush(PPTX::Logic::RunProperties &oRPr) +{ + CBrush& brush = m_pShapeElement->m_oBrush; +} + void TxBodyConverter::FillSolidFill(PPTX::Logic::UniFill &oUF, CColor &oColor) { auto pSolidFill = new PPTX::Logic::SolidFill; pSolidFill->Color.SetRGBColor(oColor.GetR(), oColor.GetG(), oColor.GetB()); oUF.Fill.reset(pSolidFill); } + +void TxBodyConverter::FillSchemeClr(PPTX::Logic::UniFill &oUF, CColor &oColor) +{ + auto pSolidFill = new PPTX::Logic::SolidFill; + auto pScheme = new PPTX::Logic::SchemeClr; + pScheme->val.set(CStylesWriter::GetColorInScheme(oColor.m_lSchemeIndex)); + pSolidFill->Color.Color.reset(pScheme); + oUF.Fill.reset(pSolidFill); +} + +void TxBodyConverter::FillEffectLst(PPTX::Logic::EffectProperties &oEList, CTextCFRun &oCFRun) +{ + auto pELst = new PPTX::Logic::EffectLst; + if (oCFRun.FontShadow.is_init() && oCFRun.FontShadow.get()) + { + pELst->outerShdw = new PPTX::Logic::OuterShdw; + pELst->outerShdw->blurRad = 38100; + pELst->outerShdw->dist = 38100; + pELst->outerShdw->dir = 2700000; + pELst->outerShdw->algn = new PPTX::Limit::RectAlign; + pELst->outerShdw->algn->set(L"tl"); + pELst->outerShdw->Color.SetRGBColor(0, 0, 0); + } + oEList.List.reset(pELst); +} diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h index d801044341..f670e6bd00 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/TxBodyConverter.h @@ -51,6 +51,7 @@ public: private: void ConvertTableTxBody(PPTX::Logic::TxBody& oTxBody); void ConvertShapeTxBody(PPTX::Logic::TxBody& oTxBody); + void FillMergedTxBody(PPTX::Logic::TxBody& oTxBody); private: void FillBodyPr(PPTX::Logic::BodyPr& oBodyPr); @@ -69,20 +70,20 @@ private: void ConvertLineEnd(PPTX::Logic::LineEnd& oLine, unsigned char cap, unsigned char length, unsigned char width, bool isHead); void ConvertBrush(PPTX::Logic::RunProperties& oRPr); void FillSolidFill(PPTX::Logic::UniFill& oUF, CColor& oColor); + void FillSchemeClr(PPTX::Logic::UniFill& oUF, CColor& oColor); + void FillEffectLst(PPTX::Logic::EffectProperties &oEList, CTextCFRun& oCFRun); void FillParagraphs(std::vector& arrP, std::vector& arrParagraphs); void ConvertStyleLevel(PPTX::Logic::TextParagraphPr &oLevel, CTextStyleLevel& oOldLevel, const int& nLevel); void FillEndParaRPr(PPTX::Logic::RunProperties& oEndPr, CTextPFRun& oPFRun); - void FillLatin(PPTX::Logic::TextFont& oLatin, CFontProperty &font); void FillCS(PPTX::Logic::TextFont& oCs, CFontProperties& font); - void FillEffectLst(PPTX::Logic::EffectProperties &oEList, CTextCFRun& oCFRun); private: CShapeElement* m_pShapeElement; CRelsGenerator* m_pRels; - CTextAttributesEx& oText; + CTextAttributesEx* pText; eTxType m_txType; bool m_bWordArt; From 38c31f25e1b411a4dbac48c93f2e32511e6d9282 Mon Sep 17 00:00:00 2001 From: Ivan Date: Fri, 16 Jul 2021 19:11:01 +0300 Subject: [PATCH 41/84] trying to fix 51028. Change slide number recognizer --- .../PPTFormatLib/PPTXWriter/ImageManager.h | 7 +- .../PPTFormatLib/PPTXWriter/ShapeWriter.cpp | 4 + .../Reader/PPTDocumentInfoOneUser.cpp | 5 +- ASCOfficePPTXFile/Editor/Drawing/Attributes.h | 1972 +++++++++-------- 4 files changed, 1007 insertions(+), 981 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ImageManager.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ImageManager.h index 738be05c0b..a39b4256a7 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ImageManager.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ImageManager.h @@ -361,11 +361,10 @@ namespace PPT_FORMAT } std::wstring WriteSlideRef(const std::wstring& strLocation) { + int sldNum = CExFilesInfo::GetSlideNumber(strLocation); + std::wstring strSlide(L"slide"); - std::vector strs; - boost::split(strs, strLocation, boost::is_any_of(L",")); - if (strs.size() == 3) - strSlide += strs[1]; + strSlide += std::to_wstring(sldNum); strSlide += L".xml"; return WriteHyperlinkMedia(strSlide, false, false, L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide"); } diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp index 0cfdaf0e83..b8535b05d1 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp @@ -1772,6 +1772,10 @@ void PPT_FORMAT::CShapeWriter::WriteButton(int paragraphNum) else hlink.action = L"ppaction://noaction"; break; + }case 8: + { + hlink.action = L"ppaction://noaction"; + break; } default: hlink.action = L"ppaction://noaction"; diff --git a/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp b/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp index ecb1677e69..79f655decc 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp @@ -2391,14 +2391,17 @@ void CPPTUserInfo::LoadExternal(CRecordExObjListContainer* pExObjects) if (oArrayCString[i]->m_oHeader.RecInstance == 1) oInfo.m_strFilePath = oArrayCString[i]->m_strText; // Location atom. It's for slides or other local pp objects. - if (oArrayCString[i]->m_oHeader.RecInstance == 3) + if (oArrayCString[i]->m_oHeader.RecInstance == 3 && oInfo.GetSlideNumber(oArrayCString[i]->m_strText) != -1) oInfo.m_strLocation = oArrayCString[i]->m_strText; } m_oExMedia.m_arHyperlinks.push_back(oInfo); + } } } + + void CPPTUserInfo::LoadExVideo(CRecordsContainer* pExObject) { std::vector oArrayExMedia; diff --git a/ASCOfficePPTXFile/Editor/Drawing/Attributes.h b/ASCOfficePPTXFile/Editor/Drawing/Attributes.h index 3f439dacc3..b31239c2c4 100644 --- a/ASCOfficePPTXFile/Editor/Drawing/Attributes.h +++ b/ASCOfficePPTXFile/Editor/Drawing/Attributes.h @@ -66,1094 +66,1114 @@ static void CorrectXmlString(std::wstring & strText) } static inline std::wstring BoolToString(bool bValue) { - return bValue ? L"1" : L"0"; + return bValue ? L"1" : L"0"; } namespace PPT_FORMAT { - class CExFilesInfo +class CExFilesInfo +{ +public: + enum ExFilesType { - public: - enum ExFilesType - { - eftNone = 0, - eftVideo = 1, - eftAudio = 2, - eftHyperlink= 3, - eftObject = 4, - eftSlide // Not used yet - }; - _UINT32 m_dwID; - std::wstring m_strFilePath; - std::wstring m_strLocation; - std::wstring m_name; - - // clip - double m_dStartTime; - double m_dEndTime; - - // loop - bool m_bLoop; - - CExFilesInfo() - { - m_dwID = 0; - m_strFilePath = _T(""); - m_strLocation = _T(""); - - m_dStartTime = 0.0; - m_dEndTime = -1.0; - - m_bLoop = false; - } - CExFilesInfo(const CExFilesInfo& oSrc) - { - *this = oSrc; - } - CExFilesInfo& operator=(const CExFilesInfo& oSrc) - { - m_dwID = oSrc.m_dwID; - m_strFilePath = oSrc.m_strFilePath; - m_strLocation = oSrc.m_strLocation; - m_name = oSrc.m_name; - - m_dStartTime = oSrc.m_dStartTime; - m_dEndTime = oSrc.m_dEndTime; - - m_bLoop = oSrc.m_bLoop; - - return *this; - } + eftNone = 0, + eftVideo = 1, + eftAudio = 2, + eftHyperlink= 3, + eftObject = 4, + eftSlide // Not used yet }; + _UINT32 m_dwID; + std::wstring m_strFilePath; + std::wstring m_strLocation; + std::wstring m_name; - class CExMedia + // clip + double m_dStartTime; + double m_dEndTime; + + // loop + bool m_bLoop; + + CExFilesInfo() { - public: - std::wstring m_strPresentationDirectory; + m_dwID = 0; + m_strFilePath = _T(""); + m_strLocation = _T(""); - std::vector m_arVideos; - std::vector m_arImages; - std::vector m_arAudios; - std::vector m_arHyperlinks; + m_dStartTime = 0.0; + m_dEndTime = -1.0; - std::vector m_arAudioCollection; + m_bLoop = false; + } + CExFilesInfo(const CExFilesInfo& oSrc) + { + *this = oSrc; + } + CExFilesInfo& operator=(const CExFilesInfo& oSrc) + { + m_dwID = oSrc.m_dwID; + m_strFilePath = oSrc.m_strFilePath; + m_strLocation = oSrc.m_strLocation; + m_name = oSrc.m_name; - void Clear() + m_dStartTime = oSrc.m_dStartTime; + m_dEndTime = oSrc.m_dEndTime; + + m_bLoop = oSrc.m_bLoop; + + return *this; + } + + static int GetSlideNumber(const std::wstring &str) + { + std::wstring sldHeader = L"Slide "; + int strIter = str.find(sldHeader); + if (strIter != -1) { - m_arVideos.clear(); - m_arImages.clear(); - m_arAudios.clear(); - m_arAudioCollection.clear(); - } + std::wstring sNum(str.begin() + sldHeader.size() + strIter, str.end()); + int num = -1; + try { + num = std::stoi(sNum); + if (num > 0 && num < 256) + return num; + } catch (...) { - CExMedia() : m_arVideos(), m_arImages(), m_arAudios() - { - } - - CExMedia(const CExMedia& oSrc) - { - *this = oSrc; - } - - CExMedia& operator=(const CExMedia& oSrc) - { - m_strPresentationDirectory = oSrc.m_strPresentationDirectory; - - for (size_t i=0; i < oSrc.m_arVideos.size(); i++) - m_arVideos.push_back(oSrc.m_arVideos[i]); - for (size_t i=0; i < oSrc.m_arVideos.size(); i++) - m_arImages.push_back(oSrc.m_arImages[i]); - for (size_t i=0; i < oSrc.m_arVideos.size(); i++) - m_arAudios.push_back(oSrc.m_arAudios[i]); - - return *this; - } - CExFilesInfo* LockHyperlink(_UINT32 dwID) - { - size_t nCount = m_arHyperlinks.size(); - for (size_t i = 0; i < nCount; ++i) - { - if (dwID == m_arHyperlinks[i].m_dwID) - { - return &m_arHyperlinks[i]; - } } - - return NULL; } - CExFilesInfo* LockVideo(_UINT32 dwID) + + return -1; + } +}; + +class CExMedia +{ +public: + std::wstring m_strPresentationDirectory; + + std::vector m_arVideos; + std::vector m_arImages; + std::vector m_arAudios; + std::vector m_arHyperlinks; + + std::vector m_arAudioCollection; + + void Clear() + { + m_arVideos.clear(); + m_arImages.clear(); + m_arAudios.clear(); + m_arAudioCollection.clear(); + } + + CExMedia() : m_arVideos(), m_arImages(), m_arAudios() + { + } + + CExMedia(const CExMedia& oSrc) + { + *this = oSrc; + } + + CExMedia& operator=(const CExMedia& oSrc) + { + m_strPresentationDirectory = oSrc.m_strPresentationDirectory; + + for (size_t i=0; i < oSrc.m_arVideos.size(); i++) + m_arVideos.push_back(oSrc.m_arVideos[i]); + for (size_t i=0; i < oSrc.m_arVideos.size(); i++) + m_arImages.push_back(oSrc.m_arImages[i]); + for (size_t i=0; i < oSrc.m_arVideos.size(); i++) + m_arAudios.push_back(oSrc.m_arAudios[i]); + + return *this; + } + CExFilesInfo* LockHyperlink(_UINT32 dwID) + { + size_t nCount = m_arHyperlinks.size(); + for (size_t i = 0; i < nCount; ++i) { - size_t nCount = m_arVideos.size(); - for (size_t i = 0; i < nCount; ++i) + if (dwID == m_arHyperlinks[i].m_dwID) { - if (dwID == m_arVideos[i].m_dwID) - { - return &m_arVideos[i]; - } + return &m_arHyperlinks[i]; } - - return NULL; } - CExFilesInfo* LockImage(_UINT32 dwID) + + return NULL; + } + CExFilesInfo* LockVideo(_UINT32 dwID) + { + size_t nCount = m_arVideos.size(); + for (size_t i = 0; i < nCount; ++i) { - size_t nCount = m_arImages.size(); - for (size_t i = 0; i < nCount; ++i) + if (dwID == m_arVideos[i].m_dwID) { - if (dwID == m_arImages[i].m_dwID) - { - return &m_arImages[i]; - } + return &m_arVideos[i]; } - - return NULL; } - CExFilesInfo* LockAudio(_UINT32 dwID) + + return NULL; + } + CExFilesInfo* LockImage(_UINT32 dwID) + { + size_t nCount = m_arImages.size(); + for (size_t i = 0; i < nCount; ++i) { - size_t nCount = m_arAudios.size(); - for (size_t i = 0; i < nCount; ++i) + if (dwID == m_arImages[i].m_dwID) { - if (dwID == m_arAudios[i].m_dwID) - { - return &m_arAudios[i]; - } + return &m_arImages[i]; } - - return NULL; } - CExFilesInfo* LockAudioFromCollection(_UINT32 dwID) + + return NULL; + } + CExFilesInfo* LockAudio(_UINT32 dwID) + { + size_t nCount = m_arAudios.size(); + for (size_t i = 0; i < nCount; ++i) { - size_t nCount = m_arAudioCollection.size(); - for (size_t i = 0; i < nCount; ++i) + if (dwID == m_arAudios[i].m_dwID) { - if (dwID == m_arAudioCollection[i].m_dwID) - { - return &m_arAudioCollection[i]; - } + return &m_arAudios[i]; } - - return NULL; } - CExFilesInfo* Lock(_UINT32 dwID, CExFilesInfo::ExFilesType& eType) + return NULL; + } + CExFilesInfo* LockAudioFromCollection(_UINT32 dwID) + { + size_t nCount = m_arAudioCollection.size(); + for (size_t i = 0; i < nCount; ++i) { - CExFilesInfo* pInfo = NULL; - - pInfo = LockHyperlink(dwID); - if (NULL != pInfo) + if (dwID == m_arAudioCollection[i].m_dwID) { - eType = CExFilesInfo::eftHyperlink; - return pInfo; + return &m_arAudioCollection[i]; } - pInfo = LockVideo(dwID); - if (NULL != pInfo) - { - eType = CExFilesInfo::eftVideo; - return pInfo; - } - pInfo = LockAudio(dwID); - if (NULL != pInfo) - { - eType = CExFilesInfo::eftAudio; - return pInfo; - } - eType = CExFilesInfo::eftNone; - return LockImage(dwID); } - }; + + return NULL; + } + + CExFilesInfo* Lock(_UINT32 dwID, CExFilesInfo::ExFilesType& eType) + { + CExFilesInfo* pInfo = NULL; + + pInfo = LockHyperlink(dwID); + if (NULL != pInfo) + { + eType = CExFilesInfo::eftHyperlink; + return pInfo; + } + pInfo = LockVideo(dwID); + if (NULL != pInfo) + { + eType = CExFilesInfo::eftVideo; + return pInfo; + } + pInfo = LockAudio(dwID); + if (NULL != pInfo) + { + eType = CExFilesInfo::eftAudio; + return pInfo; + } + eType = CExFilesInfo::eftNone; + return LockImage(dwID); + } +}; } namespace ODRAW { - class CColor +class CColor +{ +public: + BYTE R; + BYTE G; + BYTE B; + BYTE A; + + LONG m_lSchemeIndex; + + CColor() { - public: - BYTE R; - BYTE G; - BYTE B; - BYTE A; + R = 0; + G = 0; + B = 0; + A = 255; - LONG m_lSchemeIndex; + m_lSchemeIndex = -1; + } + CColor(_UINT32 rgb) + { + (*this) = CreateColor(rgb); + } + CColor& operator =(const CColor& oSrc) + { + R = oSrc.R; + G = oSrc.G; + B = oSrc.B; + A = oSrc.A; - CColor() + m_lSchemeIndex = oSrc.m_lSchemeIndex; + return (*this); + } + inline bool IsEqual(const CColor& oSrc) + { + return ((R == oSrc.R) && (G == oSrc.G) && (B == oSrc.B) && (m_lSchemeIndex == oSrc.m_lSchemeIndex)); + } + static CColor CreateColor(_UINT32 dwColor) + { + CColor oColor; + oColor.R = (BYTE)(dwColor >> 16); + oColor.G = (BYTE)(dwColor >> 8); + oColor.B = (BYTE)(dwColor); + oColor.A = 0xFF; + + oColor.m_lSchemeIndex = -1; + return oColor; + } + + CColor& operator =(const _UINT32& oSrc) + { + R = (BYTE)(oSrc >> 8); + G = (BYTE)(oSrc >> 16); + B = (BYTE)(oSrc >> 24); + A = (BYTE)oSrc; + + m_lSchemeIndex = -1; + return (*this); + } + void SetSBGR(const _UINT32& lBGR) + { + R = (BYTE)(lBGR); + G = (BYTE)(lBGR >> 8); + B = (BYTE)(lBGR >> 16); + + if (lBGR & 0xFF000000) + m_lSchemeIndex = R; + } + void SetBGR(const LONG& lBGR) + { + R = (BYTE)(lBGR); + G = (BYTE)(lBGR >> 8); + B = (BYTE)(lBGR >> 16); + + m_lSchemeIndex = -1; + } + void SetRGB(BYTE r, BYTE g, BYTE b) + { + R = r; + G = g; + B = b; + + m_lSchemeIndex = -1; + } + void SetR(BYTE r){ R = r; } + void SetG(BYTE g){ G = g; } + void SetB(BYTE b){ B = b; } + + BYTE GetR(){ return R; } + BYTE GetG(){ return G; } + BYTE GetB(){ return B; } + + friend bool operator==(const CColor& color1, const CColor& color2) + { + return ((color1.R == color2.R) && (color1.G == color2.G) && (color1.B == color2.B)); + } + + LONG GetLONG() const + { + LONG dwColor = 0; + dwColor |= R; + dwColor |= (G << 8); + dwColor |= (B << 16); + + return dwColor; + } + LONG GetLONG_RGB() const + { + LONG dwColor = 0; + dwColor |= B; + dwColor |= (G << 8); + dwColor |= (R << 16); + + return dwColor; + } + + std::wstring ToString() + { + _UINT32 dwColor = 0; + dwColor |= R; + dwColor |= (G << 8); + dwColor |= (B << 16); + return std::to_wstring((int)dwColor); + } + + void FromString(std::wstring str) + { + int lColor; + if (str.find(_T("#")) == 0) { - R = 0; - G = 0; - B = 0; + lColor = XmlUtils::GetColorBGR(str.substr(1, 6)); + R = (BYTE)(lColor); + G = (BYTE)(lColor >> 8); + B = (BYTE)(lColor >> 16); A = 255; + } + else + { + size_t nLen = str.length(); + wchar_t* pBuffer = (wchar_t*)str.c_str(); + wchar_t* pBuffer1 = pBuffer; + wchar_t* pBuffer2 = pBuffer; + wchar_t* pBufferEnd = pBuffer + nLen; + + while ((pBuffer1 < pBufferEnd) && !XmlUtils::IsDigit(*pBuffer1)) + ++pBuffer1; + pBuffer2 = pBuffer1; + while ((pBuffer2 < pBufferEnd) && XmlUtils::IsDigit(*pBuffer2)) + ++pBuffer2; + R = _GetColor(pBuffer1, pBuffer2); + + pBuffer1 = pBuffer2; + while ((pBuffer1 < pBufferEnd) && !XmlUtils::IsDigit(*pBuffer1)) + ++pBuffer1; + pBuffer2 = pBuffer1; + while ((pBuffer2 < pBufferEnd) && XmlUtils::IsDigit(*pBuffer2)) + ++pBuffer2; + G = _GetColor(pBuffer1, pBuffer2); + + pBuffer1 = pBuffer2; + while ((pBuffer1 < pBufferEnd) && !XmlUtils::IsDigit(*pBuffer1)) + ++pBuffer1; + pBuffer2 = pBuffer1; + while ((pBuffer2 < pBufferEnd) && XmlUtils::IsDigit(*pBuffer2)) + ++pBuffer2; + B = _GetColor(pBuffer1, pBuffer2); + + A = 0xFF; m_lSchemeIndex = -1; } - CColor(_UINT32 rgb) - { - (*this) = CreateColor(rgb); - } - CColor& operator =(const CColor& oSrc) - { - R = oSrc.R; - G = oSrc.G; - B = oSrc.B; - A = oSrc.A; - - m_lSchemeIndex = oSrc.m_lSchemeIndex; - return (*this); - } - inline bool IsEqual(const CColor& oSrc) - { - return ((R == oSrc.R) && (G == oSrc.G) && (B == oSrc.B) && (m_lSchemeIndex == oSrc.m_lSchemeIndex)); - } - static CColor CreateColor(_UINT32 dwColor) - { - CColor oColor; - oColor.R = (BYTE)(dwColor >> 16); - oColor.G = (BYTE)(dwColor >> 8); - oColor.B = (BYTE)(dwColor); - oColor.A = 0xFF; - - oColor.m_lSchemeIndex = -1; - return oColor; - } - - CColor& operator =(const _UINT32& oSrc) - { - R = (BYTE)(oSrc >> 8); - G = (BYTE)(oSrc >> 16); - B = (BYTE)(oSrc >> 24); - A = (BYTE)oSrc; - - m_lSchemeIndex = -1; - return (*this); - } - void SetSBGR(const _UINT32& lBGR) - { - R = (BYTE)(lBGR); - G = (BYTE)(lBGR >> 8); - B = (BYTE)(lBGR >> 16); - - if (lBGR & 0xFF000000) - m_lSchemeIndex = R; - } - void SetBGR(const LONG& lBGR) - { - R = (BYTE)(lBGR); - G = (BYTE)(lBGR >> 8); - B = (BYTE)(lBGR >> 16); - - m_lSchemeIndex = -1; - } - void SetRGB(BYTE r, BYTE g, BYTE b) - { - R = r; - G = g; - B = b; - - m_lSchemeIndex = -1; - } - void SetR(BYTE r){ R = r; } - void SetG(BYTE g){ G = g; } - void SetB(BYTE b){ B = b; } - - BYTE GetR(){ return R; } - BYTE GetG(){ return G; } - BYTE GetB(){ return B; } - - friend bool operator==(const CColor& color1, const CColor& color2) - { - return ((color1.R == color2.R) && (color1.G == color2.G) && (color1.B == color2.B)); - } - - LONG GetLONG() const - { - LONG dwColor = 0; - dwColor |= R; - dwColor |= (G << 8); - dwColor |= (B << 16); - - return dwColor; - } - LONG GetLONG_RGB() const - { - LONG dwColor = 0; - dwColor |= B; - dwColor |= (G << 8); - dwColor |= (R << 16); - - return dwColor; - } - - std::wstring ToString() - { - _UINT32 dwColor = 0; - dwColor |= R; - dwColor |= (G << 8); - dwColor |= (B << 16); - return std::to_wstring((int)dwColor); - } - - void FromString(std::wstring str) - { - int lColor; - if (str.find(_T("#")) == 0) - { - lColor = XmlUtils::GetColorBGR(str.substr(1, 6)); - R = (BYTE)(lColor); - G = (BYTE)(lColor >> 8); - B = (BYTE)(lColor >> 16); - A = 255; - } - else - { - size_t nLen = str.length(); - - wchar_t* pBuffer = (wchar_t*)str.c_str(); - wchar_t* pBuffer1 = pBuffer; - wchar_t* pBuffer2 = pBuffer; - wchar_t* pBufferEnd = pBuffer + nLen; - - while ((pBuffer1 < pBufferEnd) && !XmlUtils::IsDigit(*pBuffer1)) - ++pBuffer1; - pBuffer2 = pBuffer1; - while ((pBuffer2 < pBufferEnd) && XmlUtils::IsDigit(*pBuffer2)) - ++pBuffer2; - R = _GetColor(pBuffer1, pBuffer2); - - pBuffer1 = pBuffer2; - while ((pBuffer1 < pBufferEnd) && !XmlUtils::IsDigit(*pBuffer1)) - ++pBuffer1; - pBuffer2 = pBuffer1; - while ((pBuffer2 < pBufferEnd) && XmlUtils::IsDigit(*pBuffer2)) - ++pBuffer2; - G = _GetColor(pBuffer1, pBuffer2); - - pBuffer1 = pBuffer2; - while ((pBuffer1 < pBufferEnd) && !XmlUtils::IsDigit(*pBuffer1)) - ++pBuffer1; - pBuffer2 = pBuffer1; - while ((pBuffer2 < pBufferEnd) && XmlUtils::IsDigit(*pBuffer2)) - ++pBuffer2; - B = _GetColor(pBuffer1, pBuffer2); - - A = 0xFF; - m_lSchemeIndex = -1; - } - } - void From_UINT32(_UINT32 dwVal) - { - - } - - private: - BYTE _GetColor(wchar_t* pChar1, wchar_t* pChar2) - { - if (pChar1 == pChar2) - return 0; - std::wstring s(pChar1, (int)(pChar2 - pChar1)); - return (BYTE)XmlUtils::GetInteger(s); - } - }; - - class CPen + } + void From_UINT32(_UINT32 dwVal) { - public: - CColor Color; - long Alpha; - long Size; - unsigned char DashStyle; - unsigned char LineStyle; - unsigned char LineJoin; - - unsigned char LineEndCap; - unsigned char LineEndLength; - unsigned char LineEndWidth; + } - unsigned char LineStartCap; - unsigned char LineStartLength; - unsigned char LineStartWidth; +private: + BYTE _GetColor(wchar_t* pChar1, wchar_t* pChar2) + { + if (pChar1 == pChar2) + return 0; + std::wstring s(pChar1, (int)(pChar2 - pChar1)); + return (BYTE)XmlUtils::GetInteger(s); + } +}; - double* DashPattern; - long Count; +class CPen +{ +public: + CColor Color; + long Alpha; + long Size; - double DashOffset; + unsigned char DashStyle; + unsigned char LineStyle; + unsigned char LineJoin; - LONG Align; - double MiterLimit; + unsigned char LineEndCap; + unsigned char LineEndLength; + unsigned char LineEndWidth; - CColor Color2; //backLine + unsigned char LineStartCap; + unsigned char LineStartLength; + unsigned char LineStartWidth; - void GetDashPattern(double* arrDashPattern, long& nCount) const + double* DashPattern; + long Count; + + double DashOffset; + + LONG Align; + double MiterLimit; + + CColor Color2; //backLine + + void GetDashPattern(double* arrDashPattern, long& nCount) const + { + if (nCount == Count) { - if (nCount == Count) + for (int i = 0; i < Count; ++i) { - for (int i = 0; i < Count; ++i) - { - arrDashPattern[i] = DashPattern[i]; - } + arrDashPattern[i] = DashPattern[i]; } } - void SetDashPattern(double* arrDashPattern, long nCount) + } + void SetDashPattern(double* arrDashPattern, long nCount) + { + if ((arrDashPattern == NULL) || (nCount == 0)) { - if ((arrDashPattern == NULL) || (nCount == 0)) + Count = 0; + RELEASEARRAYOBJECTS(DashPattern); + } + else + { + if (Count != nCount) { - Count = 0; + Count = nCount; RELEASEARRAYOBJECTS(DashPattern); - } - else - { - if (Count != nCount) - { - Count = nCount; - RELEASEARRAYOBJECTS(DashPattern); - DashPattern = new double[Count]; - } - - for (int i = 0; i < Count; ++i) - { - DashPattern[i] = arrDashPattern[i]; - } - } - } - - void ScaleAlpha( double dScale ) - { - long dNewAlpha = long(Alpha * dScale + 0.5); - - if( dNewAlpha > 255 ) dNewAlpha = 255; - else if( dNewAlpha < 0 ) dNewAlpha = 0; - - Alpha = dNewAlpha; - } - - bool IsEqual(CPen* pPen) - { - if (NULL == pPen) - return false; - - return ((Color == pPen->Color) && (Alpha == pPen->Alpha) && (Size == pPen->Size) && - (DashStyle == pPen->DashStyle) && (LineStartCap == pPen->LineStartCap) && - (LineEndCap == pPen->LineEndCap) && (LineJoin == pPen->LineJoin)); - } - void SetToRenderer(IRenderer *pRenderer) - { - if (-1 == Color.m_lSchemeIndex) - pRenderer->put_PenColor(Color.GetLONG()); - else - { - LONG lColor = Color.GetLONG(); - lColor |= (0xFF000000 & ((Color.m_lSchemeIndex + 1 + 100) << 24)); - pRenderer->put_PenColor(lColor); - } - pRenderer->put_PenAlpha(Alpha); - pRenderer->put_PenSize(Size); - pRenderer->put_PenDashStyle(DashStyle); - pRenderer->put_PenLineStartCap(LineStartCap); - pRenderer->put_PenLineEndCap(LineEndCap); - pRenderer->put_PenLineJoin(LineJoin); - pRenderer->put_PenAlign(Align); - - if (DashStyle != Gdiplus::DashStyleSolid) - { - - - pRenderer->PenDashPattern(DashPattern, Count); - - - pRenderer->put_PenDashOffset(DashOffset); - } - } - void SetDefaultParams() - { - Alpha = 255; - Size = 9524; - - LineStyle = 0; //single(Simple) - DashStyle = 0; //Solid - LineJoin = 2; //round - - LineStartCap = 0; - LineEndCap = 0; - LineEndLength = 1; //med - LineStartLength = 1; - LineEndWidth = 1; - LineStartWidth = 1; - - DashPattern = NULL; - Count = 0; - - Color.SetRGB (0x00, 0x00, 0x00); - Color2.SetRGB (0xff, 0xff, 0xff); - - DashOffset = 0; - Align = Gdiplus::PenAlignmentCenter; - MiterLimit = 0.5; - } - - CPen() - { - SetDefaultParams(); - } - CPen( const CPen& other ) - { - *this = other; - } - CPen& operator=(const CPen& other) - { - Color = other.Color; - Color2 = other.Color2; - Alpha = other.Alpha; - Size = other.Size; - - DashStyle = other.DashStyle; - LineStartCap = other.LineStartCap; - LineEndCap = other.LineEndCap; - LineJoin = other.LineJoin; - - RELEASEARRAYOBJECTS(DashPattern); - Count = other.Count; - if (Count != 0) - { DashPattern = new double[Count]; - for (int i = 0; i < Count; ++i) - { - DashPattern[i] = other.DashPattern[i]; - } } - DashOffset = other.DashOffset; - Align = other.Align; - MiterLimit = other.MiterLimit; - - return *this; - } - virtual ~CPen() - { - RELEASEARRAYOBJECTS(DashPattern); + for (int i = 0; i < Count; ++i) + { + DashPattern[i] = arrDashPattern[i]; + } } + } - }; - - class CBrush + void ScaleAlpha( double dScale ) { - public: - long Type; + long dNewAlpha = long(Alpha * dScale + 0.5); - CColor Color1; - CColor Color2; + if( dNewAlpha > 255 ) dNewAlpha = 255; + else if( dNewAlpha < 0 ) dNewAlpha = 0; - long Alpha1; - long Alpha2; + Alpha = dNewAlpha; + } - std::wstring TexturePath; - long TextureAlpha; - long TextureMode; + bool IsEqual(CPen* pPen) + { + if (NULL == pPen) + return false; - bool Rectable; - Gdiplus::RectF Rect; - - double LinearAngle; - - std::vector> ColorsPosition; - - inline LONG ConstantCompatible(LONG nConstant) + return ((Color == pPen->Color) && (Alpha == pPen->Alpha) && (Size == pPen->Size) && + (DashStyle == pPen->DashStyle) && (LineStartCap == pPen->LineStartCap) && + (LineEndCap == pPen->LineEndCap) && (LineJoin == pPen->LineJoin)); + } + void SetToRenderer(IRenderer *pRenderer) + { + if (-1 == Color.m_lSchemeIndex) + pRenderer->put_PenColor(Color.GetLONG()); + else { - if( c_BrushTypeDiagonal1_ == nConstant ) - nConstant = c_BrushTypeDiagonal2_; - else if( c_BrushTypeDiagonal2_ == nConstant ) - nConstant = c_BrushTypeDiagonal1_; + LONG lColor = Color.GetLONG(); + lColor |= (0xFF000000 & ((Color.m_lSchemeIndex + 1 + 100) << 24)); + pRenderer->put_PenColor(lColor); + } + pRenderer->put_PenAlpha(Alpha); + pRenderer->put_PenSize(Size); + pRenderer->put_PenDashStyle(DashStyle); + pRenderer->put_PenLineStartCap(LineStartCap); + pRenderer->put_PenLineEndCap(LineEndCap); + pRenderer->put_PenLineJoin(LineJoin); + pRenderer->put_PenAlign(Align); - if (1000 <= nConstant) - return nConstant; - if (c_BrushTypeSolid_ == nConstant) - return nConstant + 1000; - if (c_BrushTypeHorizontal_ <= nConstant && c_BrushTypePathGradient2_ >= nConstant) - return nConstant + 2000; - if (c_BrushTypeTexture_ == nConstant) - return nConstant + 3000; - if (c_BrushTypeHatch1_ <= nConstant && c_BrushTypeHatch53_ >= nConstant) - return nConstant + 4000; - if (c_BrushTypeGradient1_ <= nConstant && c_BrushTypeGradient6_ >= nConstant) - return nConstant + 2000 - 61; + if (DashStyle != Gdiplus::DashStyleSolid) + { - return 1000; + + pRenderer->PenDashPattern(DashPattern, Count); + + + pRenderer->put_PenDashOffset(DashOffset); + } + } + void SetDefaultParams() + { + Alpha = 255; + Size = 9524; + + LineStyle = 0; //single(Simple) + DashStyle = 0; //Solid + LineJoin = 2; //round + + LineStartCap = 0; + LineEndCap = 0; + LineEndLength = 1; //med + LineStartLength = 1; + LineEndWidth = 1; + LineStartWidth = 1; + + DashPattern = NULL; + Count = 0; + + Color.SetRGB (0x00, 0x00, 0x00); + Color2.SetRGB (0xff, 0xff, 0xff); + + DashOffset = 0; + Align = Gdiplus::PenAlignmentCenter; + MiterLimit = 0.5; + } + + CPen() + { + SetDefaultParams(); + } + CPen( const CPen& other ) + { + *this = other; + } + CPen& operator=(const CPen& other) + { + Color = other.Color; + Color2 = other.Color2; + Alpha = other.Alpha; + Size = other.Size; + + DashStyle = other.DashStyle; + LineStartCap = other.LineStartCap; + LineEndCap = other.LineEndCap; + LineJoin = other.LineJoin; + + RELEASEARRAYOBJECTS(DashPattern); + Count = other.Count; + if (Count != 0) + { + DashPattern = new double[Count]; + for (int i = 0; i < Count; ++i) + { + DashPattern[i] = other.DashPattern[i]; + } } - void ScaleAlpha1( double dScale ) - { - long dNewAlpha = long(Alpha1 * dScale + 0.5); + DashOffset = other.DashOffset; + Align = other.Align; + MiterLimit = other.MiterLimit; - if( dNewAlpha > 255 ) dNewAlpha = 255; - else if( dNewAlpha < 0 ) dNewAlpha = 0; + return *this; + } + virtual ~CPen() + { + RELEASEARRAYOBJECTS(DashPattern); + } - Alpha1 = dNewAlpha; - } - void ScaleAlpha2( double dScale ) - { - long dNewAlpha = long(Alpha2 * dScale + 0.5); +}; - if( dNewAlpha > 255 ) dNewAlpha = 255; - else if( dNewAlpha < 0 ) dNewAlpha = 0; +class CBrush +{ +public: + long Type; - Alpha2 = dNewAlpha; - } + CColor Color1; + CColor Color2; - void ScaleTextureAlpha( double dScale ) - { - long dNewAlpha = long(TextureAlpha * dScale + 0.5); + long Alpha1; + long Alpha2; - if( dNewAlpha > 255 ) dNewAlpha = 255; - else if( dNewAlpha < 0 ) dNewAlpha = 0; + std::wstring TexturePath; + long TextureAlpha; + long TextureMode; - TextureAlpha = dNewAlpha; - } + bool Rectable; + Gdiplus::RectF Rect; + + double LinearAngle; + + std::vector> ColorsPosition; + + inline LONG ConstantCompatible(LONG nConstant) + { + if( c_BrushTypeDiagonal1_ == nConstant ) + nConstant = c_BrushTypeDiagonal2_; + else if( c_BrushTypeDiagonal2_ == nConstant ) + nConstant = c_BrushTypeDiagonal1_; + + if (1000 <= nConstant) + return nConstant; + if (c_BrushTypeSolid_ == nConstant) + return nConstant + 1000; + if (c_BrushTypeHorizontal_ <= nConstant && c_BrushTypePathGradient2_ >= nConstant) + return nConstant + 2000; + if (c_BrushTypeTexture_ == nConstant) + return nConstant + 3000; + if (c_BrushTypeHatch1_ <= nConstant && c_BrushTypeHatch53_ >= nConstant) + return nConstant + 4000; + if (c_BrushTypeGradient1_ <= nConstant && c_BrushTypeGradient6_ >= nConstant) + return nConstant + 2000 - 61; + + return 1000; + } + + void ScaleAlpha1( double dScale ) + { + long dNewAlpha = long(Alpha1 * dScale + 0.5); + + if( dNewAlpha > 255 ) dNewAlpha = 255; + else if( dNewAlpha < 0 ) dNewAlpha = 0; + + Alpha1 = dNewAlpha; + } + void ScaleAlpha2( double dScale ) + { + long dNewAlpha = long(Alpha2 * dScale + 0.5); + + if( dNewAlpha > 255 ) dNewAlpha = 255; + else if( dNewAlpha < 0 ) dNewAlpha = 0; + + Alpha2 = dNewAlpha; + } + + void ScaleTextureAlpha( double dScale ) + { + long dNewAlpha = long(TextureAlpha * dScale + 0.5); + + if( dNewAlpha > 255 ) dNewAlpha = 255; + else if( dNewAlpha < 0 ) dNewAlpha = 0; + + TextureAlpha = dNewAlpha; + } - bool IsEqual(CBrush* pBrush) - { - if (NULL == pBrush) - return false; + bool IsEqual(CBrush* pBrush) + { + if (NULL == pBrush) + return false; - /*return ((Type == pBrush->Type) && + /*return ((Type == pBrush->Type) && (Color1 == pBrush->Color1) && (Color2 == pBrush->Color2) && (Alpha1 == pBrush->Alpha1) && (Alpha2 == pBrush->Alpha2));*/ - return ((Type == pBrush->Type) && - (Color1 == pBrush->Color1) && (Color2 == pBrush->Color2) && - (Alpha1 == pBrush->Alpha1) && (Alpha2 == pBrush->Alpha2) && (LinearAngle == pBrush->LinearAngle) && - (TexturePath == pBrush->TexturePath) && (TextureAlpha == pBrush->TextureAlpha) && (TextureMode == pBrush->TextureMode) && - (Rectable == pBrush->Rectable) && (Rect.Equals(pBrush->Rect))); - } + return ((Type == pBrush->Type) && + (Color1 == pBrush->Color1) && (Color2 == pBrush->Color2) && + (Alpha1 == pBrush->Alpha1) && (Alpha2 == pBrush->Alpha2) && (LinearAngle == pBrush->LinearAngle) && + (TexturePath == pBrush->TexturePath) && (TextureAlpha == pBrush->TextureAlpha) && (TextureMode == pBrush->TextureMode) && + (Rectable == pBrush->Rectable) && (Rect.Equals(pBrush->Rect))); + } - void SetDefaultParams() + void SetDefaultParams() + { + Type = c_BrushTypeNotSet; + + Color1 = 0xFFFFFFFF; + Alpha1 = 255; + Color2 = 0xFFFFFFFF; + Alpha2 = 255; + + TextureAlpha = 255; + TextureMode = c_BrushTextureModeStretch; + + LinearAngle = 0; + + TexturePath = _T(""); + + Rectable = false; + + Rect.X = 0.0F; + Rect.Y = 0.0F; + Rect.Width = 0.0F; + Rect.Height = 0.0F; + + ColorsPosition.clear(); + } + + CBrush() + { + SetDefaultParams(); + } + CBrush( const CBrush& other ) + { + Type = other.Type; + + Color1 = other.Color1; + Alpha1 = other.Alpha1; + Color2 = other.Color2; + Alpha2 = other.Alpha2; + + TexturePath = other.TexturePath; + TextureAlpha = other.TextureAlpha; + TextureMode = other.TextureMode; + + Rectable = other.Rectable; + Rect = other.Rect; + + LinearAngle = other.LinearAngle; + + ColorsPosition = other.ColorsPosition; + } + CBrush& operator=(const CBrush& other) + { + Type = other.Type; + + Color1 = other.Color1; + Alpha1 = other.Alpha1; + Color2 = other.Color2; + Alpha2 = other.Alpha2; + + TexturePath = other.TexturePath; + TextureAlpha = other.TextureAlpha; + TextureMode = other.TextureMode; + + Rectable = other.Rectable; + Rect = other.Rect; + + LinearAngle = other.LinearAngle; + + ColorsPosition = other.ColorsPosition; + return *this; + } + virtual ~CBrush() + { + } + + bool IsTexture() + { + return (c_BrushTypeTexture == Type); + } + bool IsOneColor() + { + return (c_BrushTypeSolid == Type); + } + bool IsTwoColor() + { + return ((c_BrushTypeHorizontal <= Type && c_BrushTypeCylinderVer >= Type) || + (c_BrushTypeHatch1 <= Type && c_BrushTypeHatch53 >= Type)); + } + + void SetToRenderer(IRenderer *pRenderer) + { + Type = ConstantCompatible(Type); + pRenderer->put_BrushType(Type); + if (IsOneColor()) { - Type = c_BrushTypeNotSet; + //pRenderer->put_BrushColor1(Color1.GetLONG()); - Color1 = 0xFFFFFFFF; - Alpha1 = 255; - Color2 = 0xFFFFFFFF; - Alpha2 = 255; - - TextureAlpha = 255; - TextureMode = c_BrushTextureModeStretch; - - LinearAngle = 0; - - TexturePath = _T(""); - - Rectable = false; - - Rect.X = 0.0F; - Rect.Y = 0.0F; - Rect.Width = 0.0F; - Rect.Height = 0.0F; - - ColorsPosition.clear(); - } - - CBrush() - { - SetDefaultParams(); - } - CBrush( const CBrush& other ) - { - Type = other.Type; - - Color1 = other.Color1; - Alpha1 = other.Alpha1; - Color2 = other.Color2; - Alpha2 = other.Alpha2; - - TexturePath = other.TexturePath; - TextureAlpha = other.TextureAlpha; - TextureMode = other.TextureMode; - - Rectable = other.Rectable; - Rect = other.Rect; - - LinearAngle = other.LinearAngle; - - ColorsPosition = other.ColorsPosition; - } - CBrush& operator=(const CBrush& other) - { - Type = other.Type; - - Color1 = other.Color1; - Alpha1 = other.Alpha1; - Color2 = other.Color2; - Alpha2 = other.Alpha2; - - TexturePath = other.TexturePath; - TextureAlpha = other.TextureAlpha; - TextureMode = other.TextureMode; - - Rectable = other.Rectable; - Rect = other.Rect; - - LinearAngle = other.LinearAngle; - - ColorsPosition = other.ColorsPosition; - return *this; - } - virtual ~CBrush() - { - } - - bool IsTexture() - { - return (c_BrushTypeTexture == Type); - } - bool IsOneColor() - { - return (c_BrushTypeSolid == Type); - } - bool IsTwoColor() - { - return ((c_BrushTypeHorizontal <= Type && c_BrushTypeCylinderVer >= Type) || - (c_BrushTypeHatch1 <= Type && c_BrushTypeHatch53 >= Type)); - } - - void SetToRenderer(IRenderer *pRenderer) - { - Type = ConstantCompatible(Type); - pRenderer->put_BrushType(Type); - if (IsOneColor()) + if (-1 == Color1.m_lSchemeIndex) + pRenderer->put_BrushColor1(Color1.GetLONG()); + else { - //pRenderer->put_BrushColor1(Color1.GetLONG()); - - if (-1 == Color1.m_lSchemeIndex) - pRenderer->put_BrushColor1(Color1.GetLONG()); - else - { - LONG lColor = Color1.GetLONG(); - lColor |= (0xFF000000 & ((Color1.m_lSchemeIndex + 1 + 100) << 24)); - pRenderer->put_BrushColor1(lColor); - } - - pRenderer->put_BrushAlpha1(Alpha1); + LONG lColor = Color1.GetLONG(); + lColor |= (0xFF000000 & ((Color1.m_lSchemeIndex + 1 + 100) << 24)); + pRenderer->put_BrushColor1(lColor); } - else if (IsTexture()) + + pRenderer->put_BrushAlpha1(Alpha1); + } + else if (IsTexture()) + { + //BSTR bstrTexturePath = TexturePath.AllocSysString(); + pRenderer->put_BrushTexturePath(TexturePath); + //SysFreeString(bstrTexturePath); + pRenderer->put_BrushTextureMode(TextureMode); + pRenderer->put_BrushTextureAlpha(TextureAlpha); + pRenderer->BrushRect(Rectable, Rect.X, Rect.Y, Rect.Width, Rect.Height); + } + else if (IsTwoColor()) + { + //pRenderer->put_BrushColor1(Color1.GetLONG()); + + if (-1 == Color1.m_lSchemeIndex) + pRenderer->put_BrushColor1(Color1.GetLONG()); + else { - //BSTR bstrTexturePath = TexturePath.AllocSysString(); - pRenderer->put_BrushTexturePath(TexturePath); - //SysFreeString(bstrTexturePath); - pRenderer->put_BrushTextureMode(TextureMode); - pRenderer->put_BrushTextureAlpha(TextureAlpha); - pRenderer->BrushRect(Rectable, Rect.X, Rect.Y, Rect.Width, Rect.Height); + LONG lColor = Color1.GetLONG(); + lColor |= (0xFF000000 & ((Color1.m_lSchemeIndex + 1 + 100) << 24)); + pRenderer->put_BrushColor1(lColor); } - else if (IsTwoColor()) - { - //pRenderer->put_BrushColor1(Color1.GetLONG()); - if (-1 == Color1.m_lSchemeIndex) - pRenderer->put_BrushColor1(Color1.GetLONG()); - else - { - LONG lColor = Color1.GetLONG(); - lColor |= (0xFF000000 & ((Color1.m_lSchemeIndex + 1 + 100) << 24)); - pRenderer->put_BrushColor1(lColor); - } - - pRenderer->put_BrushAlpha1(Alpha1); - pRenderer->put_BrushColor2(Color2.GetLONG()); - pRenderer->put_BrushAlpha2(Alpha2); - } + pRenderer->put_BrushAlpha1(Alpha1); + pRenderer->put_BrushColor2(Color2.GetLONG()); + pRenderer->put_BrushAlpha2(Alpha2); } - }; + } +}; - class CFont +class CFont +{ +public: + std::wstring Path; + std::wstring Name; + double Size; + bool Bold; + bool Italic; + BYTE Underline; + BYTE Strikeout; + + bool StringGID; + double CharSpace; + + BYTE PitchFamily; + BYTE Charset; + bool Monospace; + + bool IsEqual(CFont* pFont) { - public: - std::wstring Path; - std::wstring Name; - double Size; - bool Bold; - bool Italic; - BYTE Underline; - BYTE Strikeout; + if (NULL == pFont) + return false; - bool StringGID; - double CharSpace; - - BYTE PitchFamily; - BYTE Charset; - bool Monospace; - - bool IsEqual(CFont* pFont) - { - if (NULL == pFont) - return false; - - return ((Name == pFont->Name) && (Path == pFont->Path) && (StringGID == pFont->StringGID) && (Size == pFont->Size) && - (Bold == pFont->Bold) && (Italic == pFont->Italic) && - (Underline == pFont->Underline) && (Strikeout == pFont->Strikeout)); - } - bool IsEqual2(CFont* pFont) - { - if (NULL == pFont) - return false; - - return ((Name == pFont->Name) && (Path == pFont->Path) && (StringGID == pFont->StringGID) && (Size == pFont->Size) && - (Bold == pFont->Bold) && (Italic == pFont->Italic)); - } - - LONG GetStyle() const - { - LONG lStyle = 0; - if (Bold) - lStyle |= 0x01; - if (Italic) - lStyle |= 0x02; - lStyle |= Underline << 2; - lStyle |= Strikeout << 7; - return lStyle; - } - void SetStyle(LONG const& lStyle) - { - Bold = (0x01 == (0x01 & lStyle)); - Italic = (0x02 == (0x02 & lStyle)); - Underline = (BYTE)(0x7C & lStyle) >> 2; - Strikeout = (BYTE)(0x0180 & lStyle) >> 7; - } - void SetToRenderer(IRenderer *pRenderer) - { - pRenderer->put_FontName(Name); - pRenderer->put_FontPath(Path); - - - pRenderer->put_FontSize(Size); - pRenderer->put_FontStyle(GetStyle()); - pRenderer->put_FontStringGID(StringGID); - pRenderer->put_FontCharSpace(CharSpace); - } - void SetDefaultParams() - { - Name = _T("Arial"); - Path = _T(""); - - Size = 0; - Bold = false; - Italic = false; - Underline = 0; - Strikeout = 0; - - StringGID = false; - CharSpace = 0.0; - - PitchFamily = 0; - Charset = 0; - Monospace = false; - } - - CFont() - { - SetDefaultParams(); - } - CFont( const CFont& other ) - { - *this = other; - } - CFont& operator=(const CFont& other) - { - Name = other.Name; - Path = other.Path; - Size = other.Size; - Bold = other.Bold; - Italic = other.Italic; - Underline = other.Underline; - Strikeout = other.Strikeout; - - StringGID = other.StringGID; - CharSpace = other.CharSpace; - - PitchFamily = other.PitchFamily; - Charset = other.Charset; - Monospace = other.Monospace; - - return *this; - } - virtual ~CFont() - { - } - }; - - class CShadow + return ((Name == pFont->Name) && (Path == pFont->Path) && (StringGID == pFont->StringGID) && (Size == pFont->Size) && + (Bold == pFont->Bold) && (Italic == pFont->Italic) && + (Underline == pFont->Underline) && (Strikeout == pFont->Strikeout)); + } + bool IsEqual2(CFont* pFont) { - public: + if (NULL == pFont) + return false; - bool Visible; + return ((Name == pFont->Name) && (Path == pFont->Path) && (StringGID == pFont->StringGID) && (Size == pFont->Size) && + (Bold == pFont->Bold) && (Italic == pFont->Italic)); + } - double DistanceX; - double DistanceY; - - double OriginX; - double OriginY; - - double BlurSize; - CColor Color; - long Alpha; - - int Type; - - double ScaleXToX; - double ScaleXToY; - double ScaleYToX; - double ScaleYToY; - - int PerspectiveX; - int PerspectiveY; - - void SetDefaultParams() - { - Visible = false; - DistanceX = 25400; - DistanceY = 25400; - BlurSize = 0; - Alpha = 255; - - OriginX = 0; - OriginY = 0; - - Type = -1; - - ScaleXToX = 1.; - ScaleXToY = 1.; - ScaleYToX = 1.; - ScaleYToY = 1.; - - PerspectiveX = 0; - PerspectiveY = 0; - - Color.SetRGB(0x80, 0x80, 0x80); - } - - CShadow() - { - SetDefaultParams(); - } - CShadow( const CShadow& other ) - { - Visible = other.Visible; - DistanceX = other.DistanceX; - DistanceY = other.DistanceY; - OriginX = other.OriginX; - OriginY = other.OriginY; - BlurSize = other.BlurSize; - Color = other.Color; - Alpha = other.Alpha; - - Type = other.Type; - - ScaleXToX = other.ScaleXToX; - ScaleXToY = other.ScaleXToY; - ScaleYToX = other.ScaleYToX; - ScaleYToY = other.ScaleYToY; - - PerspectiveX= other.PerspectiveX; - PerspectiveY= other.PerspectiveY; - } - CShadow& operator=(const CShadow& other) - { - Visible = other.Visible; - DistanceX = other.DistanceX; - DistanceY = other.DistanceY; - OriginX = other.OriginX; - OriginY = other.OriginY; - BlurSize = other.BlurSize; - Color = other.Color; - Alpha = other.Alpha; - Type = other.Type; - - PerspectiveX= other.PerspectiveX; - PerspectiveY= other.PerspectiveY; - - ScaleXToX = other.ScaleXToX; - ScaleXToY = other.ScaleXToY; - ScaleYToX = other.ScaleYToX; - ScaleYToY = other.ScaleYToY; - - return *this; - } - virtual ~CShadow() - { - } - }; - - class CEdgeText + LONG GetStyle() const { - public: - - long Visible; - double Dist; - CColor Color; - long Alpha; - - void SetDefaultParams() - { - Visible = 0; - Dist = 5; - Color = 0; - Alpha = 255; - } - - CEdgeText() - { - SetDefaultParams(); - } - CEdgeText( const CEdgeText& other ) - { - Visible = other.Visible; - Dist = other.Dist; - Color = other.Color; - Alpha = other.Alpha; - } - CEdgeText& operator=(const CEdgeText& other) - { - Visible = other.Visible; - Dist = other.Dist; - Color = other.Color; - Alpha = other.Alpha; - - return *this; - } - virtual ~CEdgeText() - { - } - }; - - class CTextAttributes + LONG lStyle = 0; + if (Bold) + lStyle |= 0x01; + if (Italic) + lStyle |= 0x02; + lStyle |= Underline << 2; + lStyle |= Strikeout << 7; + return lStyle; + } + void SetStyle(LONG const& lStyle) { - public: - CFont m_oFont; - CBrush m_oTextBrush; - CShadow m_oTextShadow; - CEdgeText m_oTextEdge; + Bold = (0x01 == (0x01 & lStyle)); + Italic = (0x02 == (0x02 & lStyle)); + Underline = (BYTE)(0x7C & lStyle) >> 2; + Strikeout = (BYTE)(0x0180 & lStyle) >> 7; + } + void SetToRenderer(IRenderer *pRenderer) + { + pRenderer->put_FontName(Name); + pRenderer->put_FontPath(Path); - int m_nTextAlignHorizontal; - int m_nTextAlignVertical; - double m_dTextRotate; - CTextAttributes() : m_oFont(), m_oTextBrush(), m_oTextShadow(), m_oTextEdge() - { - m_oFont.Size = 36; - m_oTextBrush.Color1 = 0xFF; + pRenderer->put_FontSize(Size); + pRenderer->put_FontStyle(GetStyle()); + pRenderer->put_FontStringGID(StringGID); + pRenderer->put_FontCharSpace(CharSpace); + } + void SetDefaultParams() + { + Name = _T("Arial"); + Path = _T(""); - m_nTextAlignHorizontal = 0; - m_nTextAlignVertical = -1; //not set - m_dTextRotate = 0; - } - CTextAttributes& operator =(const CTextAttributes& oSrc) - { - m_oFont = oSrc.m_oFont; - m_oTextBrush = oSrc.m_oTextBrush; - m_oTextShadow = oSrc.m_oTextShadow; - m_oTextEdge = oSrc.m_oTextEdge; + Size = 0; + Bold = false; + Italic = false; + Underline = 0; + Strikeout = 0; - m_nTextAlignHorizontal = oSrc.m_nTextAlignHorizontal; - m_nTextAlignVertical = oSrc.m_nTextAlignVertical; - m_dTextRotate = oSrc.m_dTextRotate; + StringGID = false; + CharSpace = 0.0; + + PitchFamily = 0; + Charset = 0; + Monospace = false; + } + + CFont() + { + SetDefaultParams(); + } + CFont( const CFont& other ) + { + *this = other; + } + CFont& operator=(const CFont& other) + { + Name = other.Name; + Path = other.Path; + Size = other.Size; + Bold = other.Bold; + Italic = other.Italic; + Underline = other.Underline; + Strikeout = other.Strikeout; + + StringGID = other.StringGID; + CharSpace = other.CharSpace; + + PitchFamily = other.PitchFamily; + Charset = other.Charset; + Monospace = other.Monospace; + + return *this; + } + virtual ~CFont() + { + } +}; + +class CShadow +{ +public: + + bool Visible; + + double DistanceX; + double DistanceY; + + double OriginX; + double OriginY; + + double BlurSize; + CColor Color; + long Alpha; + + int Type; + + double ScaleXToX; + double ScaleXToY; + double ScaleYToX; + double ScaleYToY; + + int PerspectiveX; + int PerspectiveY; + + void SetDefaultParams() + { + Visible = false; + DistanceX = 25400; + DistanceY = 25400; + BlurSize = 0; + Alpha = 255; + + OriginX = 0; + OriginY = 0; + + Type = -1; + + ScaleXToX = 1.; + ScaleXToY = 1.; + ScaleYToX = 1.; + ScaleYToY = 1.; + + PerspectiveX = 0; + PerspectiveY = 0; + + Color.SetRGB(0x80, 0x80, 0x80); + } + + CShadow() + { + SetDefaultParams(); + } + CShadow( const CShadow& other ) + { + Visible = other.Visible; + DistanceX = other.DistanceX; + DistanceY = other.DistanceY; + OriginX = other.OriginX; + OriginY = other.OriginY; + BlurSize = other.BlurSize; + Color = other.Color; + Alpha = other.Alpha; + + Type = other.Type; + + ScaleXToX = other.ScaleXToX; + ScaleXToY = other.ScaleXToY; + ScaleYToX = other.ScaleYToX; + ScaleYToY = other.ScaleYToY; + + PerspectiveX= other.PerspectiveX; + PerspectiveY= other.PerspectiveY; + } + CShadow& operator=(const CShadow& other) + { + Visible = other.Visible; + DistanceX = other.DistanceX; + DistanceY = other.DistanceY; + OriginX = other.OriginX; + OriginY = other.OriginY; + BlurSize = other.BlurSize; + Color = other.Color; + Alpha = other.Alpha; + Type = other.Type; + + PerspectiveX= other.PerspectiveX; + PerspectiveY= other.PerspectiveY; + + ScaleXToX = other.ScaleXToX; + ScaleXToY = other.ScaleXToY; + ScaleYToX = other.ScaleYToX; + ScaleYToY = other.ScaleYToY; + + return *this; + } + virtual ~CShadow() + { + } +}; + +class CEdgeText +{ +public: + + long Visible; + double Dist; + CColor Color; + long Alpha; + + void SetDefaultParams() + { + Visible = 0; + Dist = 5; + Color = 0; + Alpha = 255; + } + + CEdgeText() + { + SetDefaultParams(); + } + CEdgeText( const CEdgeText& other ) + { + Visible = other.Visible; + Dist = other.Dist; + Color = other.Color; + Alpha = other.Alpha; + } + CEdgeText& operator=(const CEdgeText& other) + { + Visible = other.Visible; + Dist = other.Dist; + Color = other.Color; + Alpha = other.Alpha; + + return *this; + } + virtual ~CEdgeText() + { + } +}; + +class CTextAttributes +{ +public: + CFont m_oFont; + CBrush m_oTextBrush; + CShadow m_oTextShadow; + CEdgeText m_oTextEdge; + + int m_nTextAlignHorizontal; + int m_nTextAlignVertical; + double m_dTextRotate; + + CTextAttributes() : m_oFont(), m_oTextBrush(), m_oTextShadow(), m_oTextEdge() + { + m_oFont.Size = 36; + m_oTextBrush.Color1 = 0xFF; + + m_nTextAlignHorizontal = 0; + m_nTextAlignVertical = -1; //not set + m_dTextRotate = 0; + } + CTextAttributes& operator =(const CTextAttributes& oSrc) + { + m_oFont = oSrc.m_oFont; + m_oTextBrush = oSrc.m_oTextBrush; + m_oTextShadow = oSrc.m_oTextShadow; + m_oTextEdge = oSrc.m_oTextEdge; + + m_nTextAlignHorizontal = oSrc.m_nTextAlignHorizontal; + m_nTextAlignVertical = oSrc.m_nTextAlignVertical; + m_dTextRotate = oSrc.m_dTextRotate; + + return (*this); + } +}; - return (*this); - } - }; - } From a8e537220bcac77eb4d5cc78aaec0f565ba4eb80 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Mon, 19 Jul 2021 18:43:38 +0300 Subject: [PATCH 42/84] start to rewrite Rels in buttons --- .../PPTFormatLib/PPTXWriter/ShapeWriter.cpp | 3975 +++++++++-------- .../Reader/PPTDocumentInfoOneUser.cpp | 34 +- .../Records/Drawing/ShapeContainer.cpp | 14 +- .../Records/InteractiveInfoAtom.h | 70 +- ASCOfficePPTXFile/Editor/Drawing/Attributes.h | 63 +- .../Editor/Drawing/Interactive.h | 2 + 6 files changed, 2113 insertions(+), 2045 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp index b8535b05d1..69db41b8b9 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp @@ -48,766 +48,766 @@ CStylesWriter::CStylesWriter(PPT_FORMAT::CTheme* pTheme) : m_pTheme(pTheme) {} void CStylesWriter::ConvertStyleLevel(PPT_FORMAT::CTextStyleLevel& oLevel, PPT_FORMAT::CStringWriter& oWriter, const int& nLevel) {//дублирование CTextPFRun и CTextCFRun с ShapeWriter - todooo - вынести отдельно std::wstring str1; - if (nLevel == 9) - str1 = _T("textDirection.is_init()) - { - if (pPF->textDirection.get() == 1) oWriter.WriteString(L" rtl=\"1\""); - else oWriter.WriteString(L" rtl=\"0\""); - } - if (pPF->fontAlign.is_init()) - { - std::wstring strProp = GetFontAlign(pPF->fontAlign.get()); - oWriter.WriteString(L" fontAlgn=\"" + strProp + L"\""); - } + if (pPF->textDirection.is_init()) + { + if (pPF->textDirection.get() == 1) oWriter.WriteString(L" rtl=\"1\""); + else oWriter.WriteString(L" rtl=\"0\""); + } + if (pPF->fontAlign.is_init()) + { + std::wstring strProp = GetFontAlign(pPF->fontAlign.get()); + oWriter.WriteString(L" fontAlgn=\"" + strProp + L"\""); + } - int leftMargin = 0; - if (pPF->leftMargin.is_init()) - { - leftMargin = pPF->leftMargin.get(); - std::wstring strProp = std::to_wstring(leftMargin); - oWriter.WriteString(L" marL=\"" + strProp + L"\""); - } - if (pPF->indent.is_init()) - { - std::wstring strProp = std::to_wstring(pPF->indent.get() - leftMargin); - oWriter.WriteString(L" indent=\"" + strProp + L"\""); - } - if (pPF->textAlignment.is_init()) - { - std::wstring strProp = GetTextAlign(pPF->textAlignment.get()); - oWriter.WriteString(L" algn=\"" + strProp + L"\""); - } - if (pPF->defaultTabSize.is_init()) - { + int leftMargin = 0; + if (pPF->leftMargin.is_init()) + { + leftMargin = pPF->leftMargin.get(); + std::wstring strProp = std::to_wstring(leftMargin); + oWriter.WriteString(L" marL=\"" + strProp + L"\""); + } + if (pPF->indent.is_init()) + { + std::wstring strProp = std::to_wstring(pPF->indent.get() - leftMargin); + oWriter.WriteString(L" indent=\"" + strProp + L"\""); + } + if (pPF->textAlignment.is_init()) + { + std::wstring strProp = GetTextAlign(pPF->textAlignment.get()); + oWriter.WriteString(L" algn=\"" + strProp + L"\""); + } + if (pPF->defaultTabSize.is_init()) + { std::wstring strProp = std::to_wstring(pPF->defaultTabSize.get()); - oWriter.WriteString(L" defTabSz=\"" + strProp + L"\""); - } - oWriter.WriteString(L">"); + oWriter.WriteString(L" defTabSz=\"" + strProp + L"\""); + } + oWriter.WriteString(L">"); - if (pPF->tabStops.size() > 0) - { - oWriter.WriteString(L""); - for (size_t t = 0 ; t < pPF->tabStops.size(); t++) - { - std::wstring strTabPos = std::to_wstring(pPF->tabStops[t].first); - oWriter.WriteString(L"tabStops.size() > 0) + { + oWriter.WriteString(L""); + for (size_t t = 0 ; t < pPF->tabStops.size(); t++) + { + std::wstring strTabPos = std::to_wstring(pPF->tabStops[t].first); + oWriter.WriteString(L"tabStops[t].second == 1) oWriter.WriteString(L" algn=\"ctr\"/>"); - else if (pPF->tabStops[t].second == 2) oWriter.WriteString(L" algn=\"r\"/>"); - else if (pPF->tabStops[t].second == 3) oWriter.WriteString(L" algn=\"dec\"/>"); - else oWriter.WriteString(L" algn=\"l\"/>"); - } - oWriter.WriteString(L""); - } + if (pPF->tabStops[t].second == 1) oWriter.WriteString(L" algn=\"ctr\"/>"); + else if (pPF->tabStops[t].second == 2) oWriter.WriteString(L" algn=\"r\"/>"); + else if (pPF->tabStops[t].second == 3) oWriter.WriteString(L" algn=\"dec\"/>"); + else oWriter.WriteString(L" algn=\"l\"/>"); + } + oWriter.WriteString(L""); + } - if (pPF->hasBullet.is_init()) - { - if (pPF->hasBullet.get()) - { - if (pPF->bulletColor.is_init()) - { - oWriter.WriteString(L""); - oWriter.WriteString(PPT_FORMAT::CShapeWriter::ConvertColor(pPF->bulletColor.get(), 255)); - oWriter.WriteString(L""); - } - if (pPF->bulletSize.is_init()) - { - if (pPF->bulletSize.get() > 24 && pPF->bulletSize.get() < 401) - { - std::wstring strProp = std::to_wstring(pPF->bulletSize.get() * 1000 ); - oWriter.WriteString(L""); - } - if (pPF->bulletSize.get() < 0 && pPF->bulletSize.get() > -4001) - { - std::wstring strProp = std::to_wstring(- pPF->bulletSize.get() ); - oWriter.WriteString(L""); - } - } - if (pPF->bulletFontProperties.is_init()) - { - oWriter.WriteString(L"bulletFontProperties->Name + L"\""); + if (pPF->hasBullet.is_init()) + { + if (pPF->hasBullet.get()) + { + if (pPF->bulletColor.is_init()) + { + oWriter.WriteString(L""); + oWriter.WriteString(PPT_FORMAT::CShapeWriter::ConvertColor(pPF->bulletColor.get(), 255)); + oWriter.WriteString(L""); + } + if (pPF->bulletSize.is_init()) + { + if (pPF->bulletSize.get() > 24 && pPF->bulletSize.get() < 401) + { + std::wstring strProp = std::to_wstring(pPF->bulletSize.get() * 1000 ); + oWriter.WriteString(L""); + } + if (pPF->bulletSize.get() < 0 && pPF->bulletSize.get() > -4001) + { + std::wstring strProp = std::to_wstring(- pPF->bulletSize.get() ); + oWriter.WriteString(L""); + } + } + if (pPF->bulletFontProperties.is_init()) + { + oWriter.WriteString(L"bulletFontProperties->Name + L"\""); - if ( pPF->bulletFontProperties->PitchFamily > 0) - { - oWriter.WriteString(std::wstring(L" pitchFamily=\"") + std::to_wstring(pPF->bulletFontProperties->PitchFamily) + L"\""); - } - if ( pPF->bulletFontProperties->Charset > 0) - { - oWriter.WriteString(std::wstring(L" charset=\"") + std::to_wstring((char)pPF->bulletFontProperties->Charset) + L"\""); - } - oWriter.WriteString(std::wstring(L"/>")); + if ( pPF->bulletFontProperties->PitchFamily > 0) + { + oWriter.WriteString(std::wstring(L" pitchFamily=\"") + std::to_wstring(pPF->bulletFontProperties->PitchFamily) + L"\""); + } + if ( pPF->bulletFontProperties->Charset > 0) + { + oWriter.WriteString(std::wstring(L" charset=\"") + std::to_wstring((char)pPF->bulletFontProperties->Charset) + L"\""); + } + oWriter.WriteString(std::wstring(L"/>")); - } - if (pPF->bulletChar.is_init()) - { - wchar_t bu = pPF->bulletChar.get(); - - oWriter.WriteString(L""); - } -// if (!pPF->bulletAutoNum.is_init()) -// { -// oWriter.WriteString(L""); -// } - } - else - { - oWriter.WriteString(L""); - } - } + } + if (pPF->bulletChar.is_init()) + { + wchar_t bu = pPF->bulletChar.get(); - double dKoef1 = 3.52777778; - if (pPF->lineSpacing.is_init()) - { + oWriter.WriteString(L""); + } + // if (!pPF->bulletAutoNum.is_init()) + // { + // oWriter.WriteString(L""); + // } + } + else + { + oWriter.WriteString(L""); + } + } + + double dKoef1 = 3.52777778; + if (pPF->lineSpacing.is_init()) + { LONG val = pPF->lineSpacing.get(); - if (val > 0) - { - std::wstring str = std::to_wstring( (int)(val * 0.125 * 100/*/ dKoef1*/)); - oWriter.WriteString(L""); - } - else if (val < 0 && val > -13200) - { - std::wstring str = std::to_wstring(-val * 1000); - oWriter.WriteString(L""); - } - } - if (pPF->spaceAfter.is_init()) - { + if (val > 0) + { + std::wstring str = std::to_wstring( (int)(val * 0.125 * 100/*/ dKoef1*/)); + oWriter.WriteString(L""); + } + else if (val < 0 && val > -13200) + { + std::wstring str = std::to_wstring(-val * 1000); + oWriter.WriteString(L""); + } + } + if (pPF->spaceAfter.is_init()) + { LONG val = pPF->spaceAfter.get(); - if (val > 0) - { - std::wstring str = std::to_wstring((int)(val * 0.125 * 100/*/ dKoef1*/)); - oWriter.WriteString(L""); - } - else if (val < 0 && val > -13200) - { - std::wstring str = std::to_wstring(-val * 1000); - oWriter.WriteString(L""); - } - } - if (pPF->spaceBefore.is_init()) - { + if (val > 0) + { + std::wstring str = std::to_wstring((int)(val * 0.125 * 100/*/ dKoef1*/)); + oWriter.WriteString(L""); + } + else if (val < 0 && val > -13200) + { + std::wstring str = std::to_wstring(-val * 1000); + oWriter.WriteString(L""); + } + } + if (pPF->spaceBefore.is_init()) + { LONG val = pPF->spaceBefore.get(); - if (val > 0) - { - std::wstring str = std::to_wstring((int)(val * 0.125 * 100/*/ dKoef1*/)); - oWriter.WriteString(L""); - } - else if (val < 0 && val > -13200) - { - std::wstring str = std::to_wstring(-val * 1000); - oWriter.WriteString(L""); - } - } + if (val > 0) + { + std::wstring str = std::to_wstring((int)(val * 0.125 * 100/*/ dKoef1*/)); + oWriter.WriteString(L""); + } + else if (val < 0 && val > -13200) + { + std::wstring str = std::to_wstring(-val * 1000); + oWriter.WriteString(L""); + } + } - oWriter.WriteString(L"Size.is_init()) - { - std::wstring str = std::to_wstring((int)(100 * pCF->Size.get())); - oWriter.WriteString(L" sz=\"" + str + L"\""); - } - if (pCF->FontBold.is_init()) - { - if (pCF->FontBold.get()) - oWriter.WriteString(L" b=\"1\""); - else - oWriter.WriteString(L" b=\"0\""); - } - if (pCF->FontItalic.is_init()) - { - if (pCF->FontItalic.get()) - oWriter.WriteString(std::wstring(L" i=\"1\"")); - else - oWriter.WriteString(std::wstring(L" i=\"0\"")); - } - if (pCF->Language.is_init()) - { - std::wstring str_lang = msLCID2wstring(pCF->Language.get()); + PPT_FORMAT::CTextCFRun* pCF = &oLevel.m_oCFRun; - if (str_lang.length() > 0) - oWriter.WriteString(std::wstring(L" lang=\"") + str_lang + _T("\"")); - } - oWriter.WriteString(std::wstring(L">")); + if (pCF->Size.is_init()) + { + std::wstring str = std::to_wstring((int)(100 * pCF->Size.get())); + oWriter.WriteString(L" sz=\"" + str + L"\""); + } + if (pCF->FontBold.is_init()) + { + if (pCF->FontBold.get()) + oWriter.WriteString(L" b=\"1\""); + else + oWriter.WriteString(L" b=\"0\""); + } + if (pCF->FontItalic.is_init()) + { + if (pCF->FontItalic.get()) + oWriter.WriteString(std::wstring(L" i=\"1\"")); + else + oWriter.WriteString(std::wstring(L" i=\"0\"")); + } + if (pCF->Language.is_init()) + { + std::wstring str_lang = msLCID2wstring(pCF->Language.get()); - if (pCF->Color.is_init()) - { - if (pCF->Color->m_lSchemeIndex != -1) - { - oWriter.WriteString(L"Color->m_lSchemeIndex) + L"\"/>"); - } - else - { + if (str_lang.length() > 0) + oWriter.WriteString(std::wstring(L" lang=\"") + str_lang + _T("\"")); + } + oWriter.WriteString(std::wstring(L">")); + + if (pCF->Color.is_init()) + { + if (pCF->Color->m_lSchemeIndex != -1) + { + oWriter.WriteString(L"Color->m_lSchemeIndex) + L"\"/>"); + } + else + { std::wstring strColor = XmlUtils::IntToString(pCF->Color->GetLONG_RGB(), L"%06x"); - oWriter.WriteString(L""); - } - } - if ((pCF->font.ansi.is_init()) && (!pCF->font.ansi->Name.empty())) - { - oWriter.WriteString(L"font.ansi->Name + L"\"/>"); - } - else if (pCF->fontRef.is_init()) - { - if ((m_pTheme) && (pCF->fontRef.get() < m_pTheme->m_arFonts.size())) - { - oWriter.WriteString(L"m_arFonts[pCF->fontRef.get()].Name + L"\"/>"); - } - else - { - if (0 == pCF->fontRef.get()) - { - oWriter.WriteString(L""); - } - else - { - oWriter.WriteString(L""); - } - } - } - if (pCF->font.ea.is_init()) - { - oWriter.WriteString(L"font.ea->Name + L"\"/>"); - } - if (pCF->font.sym.is_init()) - { - oWriter.WriteString(L"font.sym->Name + L"\"/>"); - } - oWriter.WriteString(L""); + oWriter.WriteString(L""); + } + } + if ((pCF->font.ansi.is_init()) && (!pCF->font.ansi->Name.empty())) + { + oWriter.WriteString(L"font.ansi->Name + L"\"/>"); + } + else if (pCF->fontRef.is_init()) + { + if ((m_pTheme) && (pCF->fontRef.get() < m_pTheme->m_arFonts.size())) + { + oWriter.WriteString(L"m_arFonts[pCF->fontRef.get()].Name + L"\"/>"); + } + else + { + if (0 == pCF->fontRef.get()) + { + oWriter.WriteString(L""); + } + else + { + oWriter.WriteString(L""); + } + } + } + if (pCF->font.ea.is_init()) + { + oWriter.WriteString(L"font.ea->Name + L"\"/>"); + } + if (pCF->font.sym.is_init()) + { + oWriter.WriteString(L"font.sym->Name + L"\"/>"); + } + oWriter.WriteString(L""); std::wstring str3; - if (nLevel == 9) - str3 = L""; - else - str3 = L""; + if (nLevel == 9) + str3 = L""; + else + str3 = L""; - oWriter.WriteString(str3); + oWriter.WriteString(str3); } PPT_FORMAT::CShapeWriter::CShapeWriter() { - m_pTheme = NULL; - m_pRels = NULL; - m_lNextShapeID = 1000; + m_pTheme = NULL; + m_pRels = NULL; + m_lNextShapeID = 1000; - m_bWordArt = false; - m_bTextBox = false; - -////////////////////////////////////////////////////////////////////// - m_dDpiX = 96.0; - m_dDpiY = 96.0; + m_bWordArt = false; + m_bTextBox = false; - m_lClipMode = c_nClipRegionTypeWinding; + ////////////////////////////////////////////////////////////////////// + m_dDpiX = 96.0; + m_dDpiY = 96.0; - m_pSimpleGraphicsConverter = new Aggplus::CGraphicsPathSimpleConverter(); - //m_pSimpleGraphicsConverter->SetRenderer(this); + m_lClipMode = c_nClipRegionTypeWinding; - m_dTransformAngle = 0.0; + m_pSimpleGraphicsConverter = new Aggplus::CGraphicsPathSimpleConverter(); + //m_pSimpleGraphicsConverter->SetRenderer(this); - m_pFontManager = NULL; + m_dTransformAngle = 0.0; + + m_pFontManager = NULL; } bool PPT_FORMAT::CShapeWriter::SetElement(CElementPtr pElem) { - m_pElement = pElem; - - m_pSimpleGraphicsConverter->PathCommandEnd(); + m_pElement = pElem; - m_bWordArt = false; - m_bTextBox = false; + m_pSimpleGraphicsConverter->PathCommandEnd(); - m_xmlGeomAlternative.clear(); - m_xmlTxBodyAlternative.clear(); - m_xmlAlternative.clear(); + m_bWordArt = false; + m_bTextBox = false; - m_oWriter.ClearNoAttack(); - m_oWriterPath.ClearNoAttack(); - m_oWriterVML.ClearNoAttack(); + m_xmlGeomAlternative.clear(); + m_xmlTxBodyAlternative.clear(); + m_xmlAlternative.clear(); - return (m_pElement != NULL); + m_oWriter.ClearNoAttack(); + m_oWriterPath.ClearNoAttack(); + m_oWriterVML.ClearNoAttack(); + + return (m_pElement != NULL); } std::wstring PPT_FORMAT::CShapeWriter::ConvertLine(CPen & pen) { - PPT_FORMAT::CStringWriter line_writer; + PPT_FORMAT::CStringWriter line_writer; - std::wstring strL; - switch(pen.LineStyle) - { - case 1: strL = L" cmpd=\"dbl\""; break; - case 2: strL = L" cmpd=\"thickThin\""; break; - case 3: strL = L" cmpd=\"thinThick\""; break; - case 4: strL = L" cmpd=\"tri\""; break; - } - line_writer.WriteString(L""); + std::wstring strL; + switch(pen.LineStyle) + { + case 1: strL = L" cmpd=\"dbl\""; break; + case 2: strL = L" cmpd=\"thickThin\""; break; + case 3: strL = L" cmpd=\"thinThick\""; break; + case 4: strL = L" cmpd=\"tri\""; break; + } + line_writer.WriteString(L""); - line_writer.WriteString(L""); - line_writer.WriteString(ConvertColor(pen.Color, pen.Alpha)); - line_writer.WriteString(L""); + line_writer.WriteString(L""); + line_writer.WriteString(ConvertColor(pen.Color, pen.Alpha)); + line_writer.WriteString(L""); - switch(pen.DashStyle) - { - case 1: line_writer.WriteString(L""); break; - case 2: line_writer.WriteString(L""); break; - case 3: line_writer.WriteString(L""); break; - case 4: line_writer.WriteString(L""); break; - case 5: line_writer.WriteString(L""); break; - case 6: line_writer.WriteString(L""); break; - case 7: line_writer.WriteString(L""); break; - case 8: line_writer.WriteString(L""); break; - case 9: line_writer.WriteString(L""); break; - case 10:line_writer.WriteString(L""); break; - } - switch(pen.LineJoin) - { - case 0: line_writer.WriteString(L""); break; - case 1: line_writer.WriteString(L""); break; - case 2: line_writer.WriteString(L""); break; - } + switch(pen.DashStyle) + { + case 1: line_writer.WriteString(L""); break; + case 2: line_writer.WriteString(L""); break; + case 3: line_writer.WriteString(L""); break; + case 4: line_writer.WriteString(L""); break; + case 5: line_writer.WriteString(L""); break; + case 6: line_writer.WriteString(L""); break; + case 7: line_writer.WriteString(L""); break; + case 8: line_writer.WriteString(L""); break; + case 9: line_writer.WriteString(L""); break; + case 10:line_writer.WriteString(L""); break; + } + switch(pen.LineJoin) + { + case 0: line_writer.WriteString(L""); break; + case 1: line_writer.WriteString(L""); break; + case 2: line_writer.WriteString(L""); break; + } - line_writer.WriteString(L""); - line_writer.WriteString(L""); - - line_writer.WriteString(L""); + line_writer.WriteString(L""); + line_writer.WriteString(L""); - return line_writer.GetData(); + line_writer.WriteString(L""); + + return line_writer.GetData(); } std::wstring PPT_FORMAT::CShapeWriter::ConvertLineEnd(unsigned char cap, unsigned char length, unsigned char width) { - if (cap < 1) return L""; + if (cap < 1) return L""; - std::wstring sResult; + std::wstring sResult; - switch(cap) - { - case 1: sResult += L" type=\"triangle\""; break; - case 2: sResult += L" type=\"stealth\""; break; - case 3: sResult += L" type=\"diamond\""; break; - case 4: sResult += L" type=\"oval\""; break; - case 5: sResult += L" type=\"arrow\""; break; - } - switch(length) - { - case 0: sResult += L" len=\"sm\""; break; - case 1: sResult += L" len=\"med\""; break; - case 2: sResult += L" len=\"lg\""; break; - } - switch(width) - { - case 0: sResult += L" w=\"sm\""; break; - case 1: sResult += L" w=\"med\""; break; - case 2: sResult += L" w=\"lg\""; break; - } - return sResult; + switch(cap) + { + case 1: sResult += L" type=\"triangle\""; break; + case 2: sResult += L" type=\"stealth\""; break; + case 3: sResult += L" type=\"diamond\""; break; + case 4: sResult += L" type=\"oval\""; break; + case 5: sResult += L" type=\"arrow\""; break; + } + switch(length) + { + case 0: sResult += L" len=\"sm\""; break; + case 1: sResult += L" len=\"med\""; break; + case 2: sResult += L" len=\"lg\""; break; + } + switch(width) + { + case 0: sResult += L" w=\"sm\""; break; + case 1: sResult += L" w=\"med\""; break; + case 2: sResult += L" w=\"lg\""; break; + } + return sResult; } std::wstring PPT_FORMAT::CShapeWriter::ConvertBrush(CBrush & brush) { - PPT_FORMAT::CStringWriter brush_writer; - - if (brush.Type == c_BrushTypeTexture) - { - if (m_pElement && ( m_pElement->m_etType == etPicture || - m_pElement->m_etType == etAudio || - m_pElement->m_etType == etVideo)) //фон для картинки с празрачностью - { - brush_writer.WriteString(L""); - } - else - { - std::wstring strRid = m_pRels->WriteImage(brush.TexturePath); + PPT_FORMAT::CStringWriter brush_writer; - brush_writer.WriteString(L""); - - if ( brush.TextureMode == c_BrushTextureModeTile) - brush_writer.WriteString(L""); - else - brush_writer.WriteString(L""); + if (brush.Type == c_BrushTypeTexture) + { + if (m_pElement && ( m_pElement->m_etType == etPicture || + m_pElement->m_etType == etAudio || + m_pElement->m_etType == etVideo)) //фон для картинки с празрачностью + { + brush_writer.WriteString(L""); + } + else + { + std::wstring strRid = m_pRels->WriteImage(brush.TexturePath); - brush_writer.WriteString(L""); - } - } - else if ( brush.Type == c_BrushTypeNoFill ) - { - brush_writer.WriteString(L""); - } - else if ( brush.Type == c_BrushTypePathGradient1 || - brush.Type == c_BrushTypePathGradient2 || - brush.Type == c_BrushTypeCenter || - brush.Type == c_BrushTypeHorizontal || - brush.Type == c_BrushTypeVertical ) - { - brush_writer.WriteString(L""); - if (brush.ColorsPosition.empty() == false) - { - for (size_t i = 0; i < brush.ColorsPosition.size(); i++) - { - std::wstring str = std::to_wstring( (int)(brush.ColorsPosition[i].second * 1000)); - - brush_writer.WriteString(L""); - brush_writer.WriteString(ConvertColor(brush.ColorsPosition[i].first, 255)); - brush_writer.WriteString(L""); - } - } - else - { - brush_writer.WriteString(L""); - brush_writer.WriteString(ConvertColor(brush.Color1, brush.Alpha1)); - brush_writer.WriteString(L""); - - brush_writer.WriteString(L""); - brush_writer.WriteString(ConvertColor(brush.Color2, brush.Alpha2)); - brush_writer.WriteString(L""); - } - brush_writer.WriteString(L""); - brush_writer.WriteString(L" 180) brush.LinearAngle -= 180; + brush_writer.WriteString(L""); - double val = (90 - brush.LinearAngle) ; - if (val < 0) val = 0; - if (val > 360) val -= 360; - - std::wstring str = std::to_wstring((int)(val * 60000)); - brush_writer.WriteString(str); - } - brush_writer.WriteString(L"\" scaled=\"1\"/>"); - brush_writer.WriteString(L""); - } - else if(brush.Type == c_BrushTypePattern) - {//типов нету в ппт - вместо них шаблон-картинка - brush_writer.WriteString(L""); - brush_writer.WriteString(L""); - brush_writer.WriteString(ConvertColor(brush.Color1, brush.Alpha1)); - brush_writer.WriteString(L""); - brush_writer.WriteString(L""); - brush_writer.WriteString(ConvertColor(brush.Color2, brush.Alpha2)); - brush_writer.WriteString(L""); - brush_writer.WriteString(L""); - } - else if (brush.Type != c_BrushTypeNotSet) - { - brush_writer.WriteString(std::wstring(L"")); - brush_writer.WriteString(ConvertColor(brush.Color1, brush.Alpha1)); - brush_writer.WriteString(std::wstring(L"")); - } - return brush_writer.GetData(); + if ( brush.TextureMode == c_BrushTextureModeTile) + brush_writer.WriteString(L""); + else + brush_writer.WriteString(L""); + + brush_writer.WriteString(L""); + } + } + else if ( brush.Type == c_BrushTypeNoFill ) + { + brush_writer.WriteString(L""); + } + else if ( brush.Type == c_BrushTypePathGradient1 || + brush.Type == c_BrushTypePathGradient2 || + brush.Type == c_BrushTypeCenter || + brush.Type == c_BrushTypeHorizontal || + brush.Type == c_BrushTypeVertical ) + { + brush_writer.WriteString(L""); + if (brush.ColorsPosition.empty() == false) + { + for (size_t i = 0; i < brush.ColorsPosition.size(); i++) + { + std::wstring str = std::to_wstring( (int)(brush.ColorsPosition[i].second * 1000)); + + brush_writer.WriteString(L""); + brush_writer.WriteString(ConvertColor(brush.ColorsPosition[i].first, 255)); + brush_writer.WriteString(L""); + } + } + else + { + brush_writer.WriteString(L""); + brush_writer.WriteString(ConvertColor(brush.Color1, brush.Alpha1)); + brush_writer.WriteString(L""); + + brush_writer.WriteString(L""); + brush_writer.WriteString(ConvertColor(brush.Color2, brush.Alpha2)); + brush_writer.WriteString(L""); + } + brush_writer.WriteString(L""); + brush_writer.WriteString(L" 180) brush.LinearAngle -= 180; + + double val = (90 - brush.LinearAngle) ; + if (val < 0) val = 0; + if (val > 360) val -= 360; + + std::wstring str = std::to_wstring((int)(val * 60000)); + brush_writer.WriteString(str); + } + brush_writer.WriteString(L"\" scaled=\"1\"/>"); + brush_writer.WriteString(L""); + } + else if(brush.Type == c_BrushTypePattern) + {//типов нету в ппт - вместо них шаблон-картинка + brush_writer.WriteString(L""); + brush_writer.WriteString(L""); + brush_writer.WriteString(ConvertColor(brush.Color1, brush.Alpha1)); + brush_writer.WriteString(L""); + brush_writer.WriteString(L""); + brush_writer.WriteString(ConvertColor(brush.Color2, brush.Alpha2)); + brush_writer.WriteString(L""); + brush_writer.WriteString(L""); + } + else if (brush.Type != c_BrushTypeNotSet) + { + brush_writer.WriteString(std::wstring(L"")); + brush_writer.WriteString(ConvertColor(brush.Color1, brush.Alpha1)); + brush_writer.WriteString(std::wstring(L"")); + } + return brush_writer.GetData(); } std::wstring PPT_FORMAT::CShapeWriter::ConvertShadow(CShadow & shadow) { - std::wstring Preset; - bool Inner = false; + std::wstring Preset; + bool Inner = false; - if (shadow.Visible == false) return _T(""); + if (shadow.Visible == false) return _T(""); - double dist = sqrt(shadow.DistanceY * shadow.DistanceY + shadow.DistanceX * shadow.DistanceX); - double dir = 0; - - if (fabs(shadow.DistanceY) > 0) - { - dir = 180 * atan(shadow.DistanceX / shadow.DistanceY) / 3.1415926; + double dist = sqrt(shadow.DistanceY * shadow.DistanceY + shadow.DistanceX * shadow.DistanceX); + double dir = 0; - if (dir < 0) dir += 180; + if (fabs(shadow.DistanceY) > 0) + { + dir = 180 * atan(shadow.DistanceX / shadow.DistanceY) / 3.1415926; - if (shadow.DistanceX < 0 && shadow.DistanceY < 0) dir *= 10; - } + if (dir < 0) dir += 180; - if (shadow.Type == 1) Preset = L"shdw13"; + if (shadow.DistanceX < 0 && shadow.DistanceY < 0) dir *= 10; + } - if (shadow.Type == 5) - { - if (shadow.DistanceX < 0 && shadow.DistanceY < 0) Preset = L"shdw18"; - else Preset = L"shdw17"; - } - if (shadow.Type == 2 && shadow.OriginX < 0) - { - if (shadow.OriginX < -1.4) - { - if (shadow.ScaleYToY < 0) Preset = L"shdw15"; - else Preset = L"shdw11"; - } - else - { - if (shadow.ScaleYToY < 0) Preset = L"shdw16"; - else Preset = L"shdw12"; - } - } + if (shadow.Type == 1) Preset = L"shdw13"; - std::wstring strDir; - std::wstring strDist; + if (shadow.Type == 5) + { + if (shadow.DistanceX < 0 && shadow.DistanceY < 0) Preset = L"shdw18"; + else Preset = L"shdw17"; + } + if (shadow.Type == 2 && shadow.OriginX < 0) + { + if (shadow.OriginX < -1.4) + { + if (shadow.ScaleYToY < 0) Preset = L"shdw15"; + else Preset = L"shdw11"; + } + else + { + if (shadow.ScaleYToY < 0) Preset = L"shdw16"; + else Preset = L"shdw12"; + } + } - if (shadow.DistanceY != 0 && shadow.DistanceX != 0) - { - if (shadow.DistanceY < 0 && shadow.DistanceX < 0) dir /=2; + std::wstring strDir; + std::wstring strDist; - strDir = L" dir=\"" + std::to_wstring((int)(dir * 60000)) + L"\""; - strDist = L" dist=\"" + std::to_wstring((int)dist) + L"\""; - } + if (shadow.DistanceY != 0 && shadow.DistanceX != 0) + { + if (shadow.DistanceY < 0 && shadow.DistanceX < 0) dir /=2; - std::wstring strSY; - if (shadow.ScaleYToY < 1 || shadow.ScaleYToY > 1) - { - if (shadow.ScaleYToX < 1)shadow.ScaleYToY = -shadow.ScaleYToY; + strDir = L" dir=\"" + std::to_wstring((int)(dir * 60000)) + L"\""; + strDist = L" dist=\"" + std::to_wstring((int)dist) + L"\""; + } - strSY = L" sy=\"" + std::to_wstring((int)(shadow.ScaleYToY * 100000)) + L"\""; - } - std::wstring strSX; - if (shadow.ScaleYToX < 1 || shadow.ScaleYToX > 1) - { - strSX = L" kx=\"" + std::to_wstring((int)((shadow.ScaleYToX + 0.5) * 360000)) + L"\""; - } - PPT_FORMAT::CStringWriter shadow_writer; - - shadow_writer.WriteString(L""); + std::wstring strSY; + if (shadow.ScaleYToY < 1 || shadow.ScaleYToY > 1) + { + if (shadow.ScaleYToX < 1)shadow.ScaleYToY = -shadow.ScaleYToY; - if (!Preset.empty()) - { - shadow_writer.WriteString(L""); + strSY = L" sy=\"" + std::to_wstring((int)(shadow.ScaleYToY * 100000)) + L"\""; + } + std::wstring strSX; + if (shadow.ScaleYToX < 1 || shadow.ScaleYToX > 1) + { + strSX = L" kx=\"" + std::to_wstring((int)((shadow.ScaleYToX + 0.5) * 360000)) + L"\""; + } + PPT_FORMAT::CStringWriter shadow_writer; - shadow_writer.WriteString(ConvertColor(shadow.Color,shadow.Alpha)); - shadow_writer.WriteString(L""); - } - else if (Inner) - { - shadow_writer.WriteString(L""); + shadow_writer.WriteString(L""); - shadow_writer.WriteString(ConvertColor(shadow.Color,shadow.Alpha)); - shadow_writer.WriteString(L""); - } - else - { - shadow_writer.WriteString(L""); + if (!Preset.empty()) + { + shadow_writer.WriteString(L""); - shadow_writer.WriteString(ConvertColor(shadow.Color,shadow.Alpha)); - shadow_writer.WriteString(L""); - } - shadow_writer.WriteString(L""); - return shadow_writer.GetData(); + shadow_writer.WriteString(ConvertColor(shadow.Color,shadow.Alpha)); + shadow_writer.WriteString(L""); + } + else if (Inner) + { + shadow_writer.WriteString(L""); + + shadow_writer.WriteString(ConvertColor(shadow.Color,shadow.Alpha)); + shadow_writer.WriteString(L""); + } + else + { + shadow_writer.WriteString(L""); + + shadow_writer.WriteString(ConvertColor(shadow.Color,shadow.Alpha)); + shadow_writer.WriteString(L""); + } + shadow_writer.WriteString(L""); + return shadow_writer.GetData(); } std::wstring PPT_FORMAT::CShapeWriter::ConvertColor(CColor & color, long alpha) { - PPT_FORMAT::CStringWriter color_writer; - if (color.m_lSchemeIndex == -1) + PPT_FORMAT::CStringWriter color_writer; + if (color.m_lSchemeIndex == -1) { - if (255 == alpha) - { + if (255 == alpha) + { color_writer.WriteString(L""); - } - else - { + } + else + { color_writer.WriteString(L"" + L""); - } - } - else - { - if (255 == alpha) - { - color_writer.WriteString(L""); - } - else - { - std::wstring strAlpha = std::to_wstring((int)(alpha * 100000 / 255)); - color_writer.WriteString(L""); - } - } - return color_writer.GetData(); + } + } + else + { + if (255 == alpha) + { + color_writer.WriteString(L""); + } + else + { + std::wstring strAlpha = std::to_wstring((int)(alpha * 100000 / 255)); + color_writer.WriteString(L""); + } + } + return color_writer.GetData(); } void PPT_FORMAT::CShapeWriter::WriteImageInfo() { CImageElement* pImageElement = dynamic_cast(m_pElement.get()); - if (!pImageElement) return; - - CAudioElement* pAudioElement = dynamic_cast(pImageElement); + if (!pImageElement) return; + + CAudioElement* pAudioElement = dynamic_cast(pImageElement); CVideoElement* pVideoElement = dynamic_cast(pImageElement); - - m_oWriter.WriteString(std::wstring(L"")); - if (pImageElement->m_lID < 0) - pImageElement->m_lID = m_lNextShapeID; + m_oWriter.WriteString(std::wstring(L"")); - std::wstring strShapeID = std::to_wstring(pImageElement->m_lID); - - m_oWriter.WriteString(std::wstring(L"m_sName.empty()) - { - if (pAudioElement) pImageElement->m_sName = std::wstring(L"Audio ") + strShapeID; - else if (pVideoElement) pImageElement->m_sName = std::wstring(L"Video ") + strShapeID; - else pImageElement->m_sName = std::wstring(L"Image ") + strShapeID; - } - - if (pImageElement->m_bHidden) m_oWriter.WriteString(std::wstring(L" hidden=\"1\"")); + if (pImageElement->m_lID < 0) + pImageElement->m_lID = m_lNextShapeID; - m_oWriter.WriteString(std::wstring(L" name=\"")); - m_oWriter.WriteStringXML(pImageElement->m_sName); - m_oWriter.WriteString(std::wstring(L"\"")); - - if (!pImageElement->m_sDescription.empty()) - {//бывает всякая разная бяка сохранена - m_oWriter.WriteString(std::wstring(L" descr=\"")); - m_oWriter.WriteString(XmlUtils::EncodeXmlStringExtend(pImageElement->m_sDescription, true)); - m_oWriter.WriteString(std::wstring(L"\"")); - } - m_oWriter.WriteString(std::wstring(L">")); + std::wstring strShapeID = std::to_wstring(pImageElement->m_lID); + + m_oWriter.WriteString(std::wstring(L"m_sName.empty()) + { + if (pAudioElement) pImageElement->m_sName = std::wstring(L"Audio ") + strShapeID; + else if (pVideoElement) pImageElement->m_sName = std::wstring(L"Video ") + strShapeID; + else pImageElement->m_sName = std::wstring(L"Image ") + strShapeID; + } + + if (pImageElement->m_bHidden) m_oWriter.WriteString(std::wstring(L" hidden=\"1\"")); + + m_oWriter.WriteString(std::wstring(L" name=\"")); + m_oWriter.WriteStringXML(pImageElement->m_sName); + m_oWriter.WriteString(std::wstring(L"\"")); + + if (!pImageElement->m_sDescription.empty()) + {//бывает всякая разная бяка сохранена + m_oWriter.WriteString(std::wstring(L" descr=\"")); + m_oWriter.WriteString(XmlUtils::EncodeXmlStringExtend(pImageElement->m_sDescription, true)); + m_oWriter.WriteString(std::wstring(L"\"")); + } + m_oWriter.WriteString(std::wstring(L">")); - if (pVideoElement || pAudioElement) - { - m_oWriter.WriteString(std::wstring(L"")); - } + if (pVideoElement || pAudioElement) + { + m_oWriter.WriteString(std::wstring(L"")); + } - m_oWriter.WriteString(std::wstring(L"m_bChildAnchorEnabled) - { - m_oWriter.WriteString(std::wstring(L" noGrp=\"1\"")); - } - m_oWriter.WriteString(std::wstring(L" noChangeAspect=\"1\"/>")); + m_oWriter.WriteString(std::wstring(L"m_bChildAnchorEnabled) + { + m_oWriter.WriteString(std::wstring(L" noGrp=\"1\"")); + } + m_oWriter.WriteString(std::wstring(L" noChangeAspect=\"1\"/>")); - m_oWriter.WriteString(std::wstring(L"")); - - if (-1 != pImageElement->m_lPlaceholderType) - { - m_oWriter.WriteString(std::wstring(L"m_lPlaceholderType > 0 && pImageElement->m_lPlaceholderType != PT_Body_Empty) - m_oWriter.WriteString(std::wstring(L" type=\"") + GetPhType(pImageElement->m_lPlaceholderType) + L"\""); - - if (-1 != pImageElement->m_lPlaceholderID) - { - std::wstring strIdx = std::to_wstring(pImageElement->m_lPlaceholderID ); - m_oWriter.WriteString(std::wstring(L" idx=\"") + strIdx + L"\""); + ++m_lNextShapeID; - } - m_oWriter.WriteString(std::wstring(L"/>")); - } + m_oWriter.WriteString(std::wstring(L"")); - std::wstring sMediaFile; - - if ((pVideoElement) && (!pVideoElement->m_strVideoFileName.empty())) - { - bool bExternal = false; - std::wstring strRid = m_pRels->WriteVideo(pVideoElement->m_strVideoFileName, bExternal); - - m_oWriter.WriteString(L""); + if (-1 != pImageElement->m_lPlaceholderType) + { + m_oWriter.WriteString(std::wstring(L"m_strVideoFileName; - } + if (pImageElement->m_lPlaceholderType > 0 && pImageElement->m_lPlaceholderType != PT_Body_Empty) + m_oWriter.WriteString(std::wstring(L" type=\"") + GetPhType(pImageElement->m_lPlaceholderType) + L"\""); - if ((pAudioElement) && (!pAudioElement->m_strAudioFileName.empty())) - { - bool bExternal = false; - std::wstring strRid = m_pRels->WriteAudio(pAudioElement->m_strAudioFileName, bExternal); + if (-1 != pImageElement->m_lPlaceholderID) + { + std::wstring strIdx = std::to_wstring(pImageElement->m_lPlaceholderID ); + m_oWriter.WriteString(std::wstring(L" idx=\"") + strIdx + L"\""); - m_oWriter.WriteString(L""); - - sMediaFile = bExternal ? L"" : pAudioElement->m_strAudioFileName; - } - if (sMediaFile.empty() == false) - { - std::wstring strRid = m_pRels->WriteMedia(sMediaFile); - if (!strRid.empty()) - { - m_oWriter.WriteString(L"\ -"); - } - } + } + m_oWriter.WriteString(std::wstring(L"/>")); + } + + std::wstring sMediaFile; + + if ((pVideoElement) && (!pVideoElement->m_strVideoFileName.empty())) + { + bool bExternal = false; + std::wstring strRid = m_pRels->WriteVideo(pVideoElement->m_strVideoFileName, bExternal); + + m_oWriter.WriteString(L""); + + sMediaFile = bExternal ? L"" : pVideoElement->m_strVideoFileName; + } + + if ((pAudioElement) && (!pAudioElement->m_strAudioFileName.empty())) + { + bool bExternal = false; + std::wstring strRid = m_pRels->WriteAudio(pAudioElement->m_strAudioFileName, bExternal); + + m_oWriter.WriteString(L""); + + sMediaFile = bExternal ? L"" : pAudioElement->m_strAudioFileName; + } + if (sMediaFile.empty() == false) + { + std::wstring strRid = m_pRels->WriteMedia(sMediaFile); + if (!strRid.empty()) + { + m_oWriter.WriteString(L"\ + "); + } + } + + m_oWriter.WriteString(std::wstring(L"")); - m_oWriter.WriteString(std::wstring(L"")); - std::wstring str2 = _T(""); - m_oWriter.WriteString(str2); + m_oWriter.WriteString(str2); } void PPT_FORMAT::CShapeWriter::WriteGroupInfo() { - CGroupElement* pGroupElement = dynamic_cast(m_pElement.get()); - if (!pGroupElement) return; + CGroupElement* pGroupElement = dynamic_cast(m_pElement.get()); + if (!pGroupElement) return; - m_oWriter.WriteString(std::wstring(L"")); + m_oWriter.WriteString(std::wstring(L"")); - if (pGroupElement->m_lID < 0) - pGroupElement->m_lID = m_lNextShapeID; + if (pGroupElement->m_lID < 0) + pGroupElement->m_lID = m_lNextShapeID; - std::wstring strShapeID = std::to_wstring(pGroupElement->m_lID); + std::wstring strShapeID = std::to_wstring(pGroupElement->m_lID); - m_oWriter.WriteString(std::wstring(L"m_sName.empty()) pGroupElement->m_sName = std::wstring(L"Group ") + strShapeID; + if (pGroupElement->m_sName.empty()) pGroupElement->m_sName = std::wstring(L"Group ") + strShapeID; - if (pGroupElement->m_bHidden) m_oWriter.WriteString(std::wstring(L" hidden=\"1\"")); - - m_oWriter.WriteString(std::wstring(L" name=\"")); - m_oWriter.WriteStringXML(pGroupElement->m_sName); - m_oWriter.WriteString(std::wstring(L"\"")); + if (pGroupElement->m_bHidden) m_oWriter.WriteString(std::wstring(L" hidden=\"1\"")); - if (!pGroupElement->m_sDescription.empty()) - { - m_oWriter.WriteString(std::wstring(L" descr=\"")); - m_oWriter.WriteStringXML(pGroupElement->m_sDescription); - m_oWriter.WriteString(std::wstring(L"\"")); - } - m_oWriter.WriteString(std::wstring(L">")); - if (!pGroupElement->m_sHyperlink.empty()) - { + m_oWriter.WriteString(std::wstring(L" name=\"")); + m_oWriter.WriteStringXML(pGroupElement->m_sName); + m_oWriter.WriteString(std::wstring(L"\"")); + + if (!pGroupElement->m_sDescription.empty()) + { + m_oWriter.WriteString(std::wstring(L" descr=\"")); + m_oWriter.WriteStringXML(pGroupElement->m_sDescription); + m_oWriter.WriteString(std::wstring(L"\"")); + } + m_oWriter.WriteString(std::wstring(L">")); + if (!pGroupElement->m_sHyperlink.empty()) + { std::wstring rId = m_pRels->WriteHyperlink(pGroupElement->m_sHyperlink); - m_oWriter.WriteString(std::wstring(L"")); - } - m_oWriter.WriteString(std::wstring(L"")); - - m_oWriter.WriteString(std::wstring(L"")); + m_oWriter.WriteString(std::wstring(L"")); + } + m_oWriter.WriteString(std::wstring(L"")); - ++m_lNextShapeID; + m_oWriter.WriteString(std::wstring(L"")); + + ++m_lNextShapeID; + + m_oWriter.WriteString(std::wstring(L"")); - m_oWriter.WriteString(std::wstring(L"")); - std::wstring str2 = _T(""); - m_oWriter.WriteString(str2); + m_oWriter.WriteString(str2); } void PPT_FORMAT::CShapeWriter::WriteTableInfo() @@ -829,13 +829,13 @@ void PPT_FORMAT::CShapeWriter::WriteTableInfo() if (pGroupElement->m_bHidden) m_oWriter.WriteString(std::wstring(L" hidden=\"1\"")); m_oWriter.WriteString(std::wstring(L" name=\"")); - m_oWriter.WriteStringXML(pGroupElement->m_sName); + m_oWriter.WriteStringXML(pGroupElement->m_sName); m_oWriter.WriteString(std::wstring(L"\"")); if (!pGroupElement->m_sDescription.empty()) { m_oWriter.WriteString(std::wstring(L" descr=\"")); - m_oWriter.WriteStringXML(pGroupElement->m_sDescription); + m_oWriter.WriteStringXML(pGroupElement->m_sDescription); m_oWriter.WriteString(std::wstring(L"\"")); } m_oWriter.WriteString(std::wstring(L">")); @@ -844,8 +844,8 @@ void PPT_FORMAT::CShapeWriter::WriteTableInfo() std::wstring rId = m_pRels->WriteHyperlink(pGroupElement->m_sHyperlink); m_oWriter.WriteString(std::wstring(L"")); } m_oWriter.WriteString(std::wstring(L"")); @@ -862,539 +862,539 @@ void PPT_FORMAT::CShapeWriter::WriteTableInfo() void PPT_FORMAT::CShapeWriter::WriteShapeInfo() { - CShapeElement* pShapeElement = dynamic_cast(m_pElement.get()); - if (!pShapeElement) return; + CShapeElement* pShapeElement = dynamic_cast(m_pElement.get()); + if (!pShapeElement) return; - m_oWriter.WriteString(std::wstring(L"")); + m_oWriter.WriteString(std::wstring(L"")); - if (pShapeElement->m_lID < 0) - pShapeElement->m_lID = m_lNextShapeID; + if (pShapeElement->m_lID < 0) + pShapeElement->m_lID = m_lNextShapeID; - std::wstring strShapeID = std::to_wstring(pShapeElement->m_lID); + std::wstring strShapeID = std::to_wstring(pShapeElement->m_lID); - m_oWriter.WriteString(std::wstring(L"m_sName.empty()) pShapeElement->m_sName = std::wstring(L"Shape ") + strShapeID; + if (pShapeElement->m_sName.empty()) pShapeElement->m_sName = std::wstring(L"Shape ") + strShapeID; - if (pShapeElement->m_bHidden) m_oWriter.WriteString(std::wstring(L" hidden=\"1\"")); - - m_oWriter.WriteString(std::wstring(L" name=\"")); - m_oWriter.WriteStringXML(pShapeElement->m_sName); - m_oWriter.WriteString(std::wstring(L"\"")); + if (pShapeElement->m_bHidden) m_oWriter.WriteString(std::wstring(L" hidden=\"1\"")); - if (!pShapeElement->m_sDescription.empty()) - { - m_oWriter.WriteString(std::wstring(L" descr=\"")); - m_oWriter.WriteStringXML(pShapeElement->m_sDescription); - m_oWriter.WriteString(std::wstring(L"\"")); - } - m_oWriter.WriteString(std::wstring(L">")); + m_oWriter.WriteString(std::wstring(L" name=\"")); + m_oWriter.WriteStringXML(pShapeElement->m_sName); + m_oWriter.WriteString(std::wstring(L"\"")); + + if (!pShapeElement->m_sDescription.empty()) + { + m_oWriter.WriteString(std::wstring(L" descr=\"")); + m_oWriter.WriteStringXML(pShapeElement->m_sDescription); + m_oWriter.WriteString(std::wstring(L"\"")); + } + m_oWriter.WriteString(std::wstring(L">")); WriteButton(); - if (!pShapeElement->m_sHyperlink.empty()) - { + if (!pShapeElement->m_sHyperlink.empty()) + { std::wstring rId = m_pRels->WriteHyperlink(pShapeElement->m_sHyperlink); - m_oWriter.WriteString(std::wstring(L"")); - } - m_oWriter.WriteString(std::wstring(L"")); - - m_oWriter.WriteString(std::wstring(L"m_bChildAnchorEnabled) - { - m_oWriter.WriteString(std::wstring(L" noGrp=\"1\"")); - } - m_oWriter.WriteString(std::wstring(L" noChangeShapeType=\"1\"/>")); + m_oWriter.WriteString(std::wstring(L"")); + } + m_oWriter.WriteString(std::wstring(L"")); - m_oWriter.WriteString(std::wstring(L"")); + m_oWriter.WriteString(std::wstring(L"m_bChildAnchorEnabled) + { + m_oWriter.WriteString(std::wstring(L" noGrp=\"1\"")); + } + m_oWriter.WriteString(std::wstring(L" noChangeShapeType=\"1\"/>")); + + m_oWriter.WriteString(std::wstring(L"")); + + ++m_lNextShapeID; + + if (-1 != pShapeElement->m_lPlaceholderType) + { + m_oWriter.WriteString(std::wstring(L"m_lPlaceholderType > 0 && pShapeElement->m_lPlaceholderType != PT_Body_Empty) + m_oWriter.WriteString(std::wstring(L" type=\"") + GetPhType(pShapeElement->m_lPlaceholderType) + _T("\"")); + + if ( pShapeElement->m_lPlaceholderID != -1) + { + std::wstring strIdx = std::to_wstring( pShapeElement->m_lPlaceholderID ); + m_oWriter.WriteString(std::wstring(L" idx=\"") + strIdx + L"\""); + } + + if (pShapeElement->m_lPlaceholderSizePreset > 1 && !isTitlePlaceholder(pShapeElement->m_lPlaceholderType)) + { + if (pShapeElement->m_lPlaceholderSizePreset == 1) + m_oWriter.WriteString(std::wstring(L" size=\"half\"")); + else if (pShapeElement->m_lPlaceholderSizePreset == 2) + m_oWriter.WriteString(std::wstring(L" size=\"quarter\"")); + else if (pShapeElement->m_lPlaceholderSizePreset == 3) + { + if (isBodyPlaceholder(pShapeElement->m_lPlaceholderType)) + m_oWriter.WriteString(std::wstring(L" size=\"half\"")); + else + m_oWriter.WriteString(std::wstring(L" size=\"quarter\"")); + } + } + m_oWriter.WriteString(std::wstring(L"/>")); + } + else + { + m_oWriter.WriteString(std::wstring(L"")); + } - if (-1 != pShapeElement->m_lPlaceholderType) - { - m_oWriter.WriteString(std::wstring(L"m_lPlaceholderType > 0 && pShapeElement->m_lPlaceholderType != PT_Body_Empty) - m_oWriter.WriteString(std::wstring(L" type=\"") + GetPhType(pShapeElement->m_lPlaceholderType) + _T("\"")); - - if ( pShapeElement->m_lPlaceholderID != -1) - { - std::wstring strIdx = std::to_wstring( pShapeElement->m_lPlaceholderID ); - m_oWriter.WriteString(std::wstring(L" idx=\"") + strIdx + L"\""); - } - - if (pShapeElement->m_lPlaceholderSizePreset > 1 && !isTitlePlaceholder(pShapeElement->m_lPlaceholderType)) - { - if (pShapeElement->m_lPlaceholderSizePreset == 1) - m_oWriter.WriteString(std::wstring(L" size=\"half\"")); - else if (pShapeElement->m_lPlaceholderSizePreset == 2) - m_oWriter.WriteString(std::wstring(L" size=\"quarter\"")); - else if (pShapeElement->m_lPlaceholderSizePreset == 3) - { - if (isBodyPlaceholder(pShapeElement->m_lPlaceholderType)) - m_oWriter.WriteString(std::wstring(L" size=\"half\"")); - else - m_oWriter.WriteString(std::wstring(L" size=\"quarter\"")); - } - } - m_oWriter.WriteString(std::wstring(L"/>")); - } - else - { - m_oWriter.WriteString(std::wstring(L"")); - } - std::wstring str2 = _T(""); - m_oWriter.WriteString(str2); + m_oWriter.WriteString(str2); } void PPT_FORMAT::CShapeWriter::Write3dShape() { - CShapeElement* pShapeElement = dynamic_cast(m_pElement.get()); - if (!pShapeElement) return; + CShapeElement* pShapeElement = dynamic_cast(m_pElement.get()); + if (!pShapeElement) return; - CPPTShape *pPPTShape = dynamic_cast(pShapeElement->m_pShape->getBaseShape().get()); - if (!pPPTShape) return; + CPPTShape *pPPTShape = dynamic_cast(pShapeElement->m_pShape->getBaseShape().get()); + if (!pPPTShape) return; - if (!pPPTShape->m_o3dOptions.bEnabled) return; + if (!pPPTShape->m_o3dOptions.bEnabled) return; - //{ - // std::cout << "........................................................................\n"; - // std::wcout << pShapeElement->m_sName << L"\n"; - // if (pPPTShape->m_o3dOptions.dSpecularAmt) - // { - // std::cout << "SpecularAmt\t" << (*pPPTShape->m_o3dOptions.dSpecularAmt) << "\n"; - // } - // if (pPPTShape->m_o3dOptions.dDiffuseAmt) - // { - // std::cout << "iffuseAmt\t" << (*pPPTShape->m_o3dOptions.dDiffuseAmt) << "\n"; - // } - // if (pPPTShape->m_o3dOptions.dShininess) - // { - // std::cout << "Shininess\t" << (*pPPTShape->m_o3dOptions.dShininess) << "\n"; - // } - // if (pPPTShape->m_o3dOptions.dXRotationAngle) - // { - // std::cout << "XRotationAngle\t" << (*pPPTShape->m_o3dOptions.dXRotationAngle) << "\n"; - // } - // if (pPPTShape->m_o3dOptions.dYRotationAngle) - // { - // std::cout << "YRotationAngle\t" << (*pPPTShape->m_o3dOptions.dYRotationAngle) << "\n"; - // } - // if (pPPTShape->m_o3dOptions.dRotationAxisX) - // { - // std::cout << "RotationAxisX\t" << (*pPPTShape->m_o3dOptions.dRotationAxisX) << "\n"; - // } - // if (pPPTShape->m_o3dOptions.dRotationAxisY) - // { - // std::cout << "RotationAxisY\t" << (*pPPTShape->m_o3dOptions.dRotationAxisY) << "\n"; - // } - // if (pPPTShape->m_o3dOptions.dRotationAxisZ) - // { - // std::cout << "RotationAxisZ\t" << (*pPPTShape->m_o3dOptions.dRotationAxisZ) << "\n"; - // } - // if (pPPTShape->m_o3dOptions.dRotationAngle) - // { - // std::cout << "RotationAngle\t" << (*pPPTShape->m_o3dOptions.dRotationAngle) << "\n"; - // } - // if (pPPTShape->m_o3dOptions.dRotationCenterX) - // { - // std::cout << "RotationCenterX\t" << (*pPPTShape->m_o3dOptions.dRotationCenterX) << "\n"; - // } - // if (pPPTShape->m_o3dOptions.dRotationCenterY) - // { - // std::cout << "RotationCenterY\t" << (*pPPTShape->m_o3dOptions.dRotationCenterY) << "\n"; - // } - // if (pPPTShape->m_o3dOptions.dRotationCenterZ) - // { - // std::cout << "RotationCenterZ\t" << (*pPPTShape->m_o3dOptions.dRotationCenterZ) << "\n"; - // } - // if (pPPTShape->m_o3dOptions.dTolerance) - // { - // std::cout << "Tolerance\t" << (*pPPTShape->m_o3dOptions.dTolerance) << "\n"; - // } - // std::cout << "XViewpoint\t" << (pPPTShape->m_o3dOptions.dXViewpoint) << "\n"; - // std::cout << "YViewpoint\t" << (pPPTShape->m_o3dOptions.dYViewpoint) << "\n"; - // if (pPPTShape->m_o3dOptions.dZViewpoint) - // { - // std::cout << "ZViewpoint\t" << (*pPPTShape->m_o3dOptions.dZViewpoint) << "\n"; - // } - // std::cout << "OriginX\t" << (pPPTShape->m_o3dOptions.dOriginX) << "\n"; - // std::cout << "OriginY\t" << (pPPTShape->m_o3dOptions.dOriginY) << "\n"; - // std::cout << "SkewAngle\t" << (pPPTShape->m_o3dOptions.dSkewAngle) << "\n"; - // std::cout << "SkewAmount\t" << (pPPTShape->m_o3dOptions.nSkewAmount) << "\n"; + //{ + // std::cout << "........................................................................\n"; + // std::wcout << pShapeElement->m_sName << L"\n"; + // if (pPPTShape->m_o3dOptions.dSpecularAmt) + // { + // std::cout << "SpecularAmt\t" << (*pPPTShape->m_o3dOptions.dSpecularAmt) << "\n"; + // } + // if (pPPTShape->m_o3dOptions.dDiffuseAmt) + // { + // std::cout << "iffuseAmt\t" << (*pPPTShape->m_o3dOptions.dDiffuseAmt) << "\n"; + // } + // if (pPPTShape->m_o3dOptions.dShininess) + // { + // std::cout << "Shininess\t" << (*pPPTShape->m_o3dOptions.dShininess) << "\n"; + // } + // if (pPPTShape->m_o3dOptions.dXRotationAngle) + // { + // std::cout << "XRotationAngle\t" << (*pPPTShape->m_o3dOptions.dXRotationAngle) << "\n"; + // } + // if (pPPTShape->m_o3dOptions.dYRotationAngle) + // { + // std::cout << "YRotationAngle\t" << (*pPPTShape->m_o3dOptions.dYRotationAngle) << "\n"; + // } + // if (pPPTShape->m_o3dOptions.dRotationAxisX) + // { + // std::cout << "RotationAxisX\t" << (*pPPTShape->m_o3dOptions.dRotationAxisX) << "\n"; + // } + // if (pPPTShape->m_o3dOptions.dRotationAxisY) + // { + // std::cout << "RotationAxisY\t" << (*pPPTShape->m_o3dOptions.dRotationAxisY) << "\n"; + // } + // if (pPPTShape->m_o3dOptions.dRotationAxisZ) + // { + // std::cout << "RotationAxisZ\t" << (*pPPTShape->m_o3dOptions.dRotationAxisZ) << "\n"; + // } + // if (pPPTShape->m_o3dOptions.dRotationAngle) + // { + // std::cout << "RotationAngle\t" << (*pPPTShape->m_o3dOptions.dRotationAngle) << "\n"; + // } + // if (pPPTShape->m_o3dOptions.dRotationCenterX) + // { + // std::cout << "RotationCenterX\t" << (*pPPTShape->m_o3dOptions.dRotationCenterX) << "\n"; + // } + // if (pPPTShape->m_o3dOptions.dRotationCenterY) + // { + // std::cout << "RotationCenterY\t" << (*pPPTShape->m_o3dOptions.dRotationCenterY) << "\n"; + // } + // if (pPPTShape->m_o3dOptions.dRotationCenterZ) + // { + // std::cout << "RotationCenterZ\t" << (*pPPTShape->m_o3dOptions.dRotationCenterZ) << "\n"; + // } + // if (pPPTShape->m_o3dOptions.dTolerance) + // { + // std::cout << "Tolerance\t" << (*pPPTShape->m_o3dOptions.dTolerance) << "\n"; + // } + // std::cout << "XViewpoint\t" << (pPPTShape->m_o3dOptions.dXViewpoint) << "\n"; + // std::cout << "YViewpoint\t" << (pPPTShape->m_o3dOptions.dYViewpoint) << "\n"; + // if (pPPTShape->m_o3dOptions.dZViewpoint) + // { + // std::cout << "ZViewpoint\t" << (*pPPTShape->m_o3dOptions.dZViewpoint) << "\n"; + // } + // std::cout << "OriginX\t" << (pPPTShape->m_o3dOptions.dOriginX) << "\n"; + // std::cout << "OriginY\t" << (pPPTShape->m_o3dOptions.dOriginY) << "\n"; + // std::cout << "SkewAngle\t" << (pPPTShape->m_o3dOptions.dSkewAngle) << "\n"; + // std::cout << "SkewAmount\t" << (pPPTShape->m_o3dOptions.nSkewAmount) << "\n"; - // if (pPPTShape->m_o3dOptions.dAmbientIntensity) - // { - // std::cout << "AmbientIntensity\t" << (*pPPTShape->m_o3dOptions.dAmbientIntensity) << "\n"; - // } - // if (pPPTShape->m_o3dOptions.dKeyIntensity) - // { - // std::cout << "KeyIntensity\t" << (*pPPTShape->m_o3dOptions.dKeyIntensity) << "\n"; - // } - // std::cout << "KeyX\t" << (pPPTShape->m_o3dOptions.dKeyX) << "\n"; - // std::cout << "KeyY\t" << (pPPTShape->m_o3dOptions.dKeyY) << "\n"; - // if (pPPTShape->m_o3dOptions.dKeyZ) - // { - // std::cout << "KeyZ\t" << (*pPPTShape->m_o3dOptions.dKeyZ) << "\n"; - // } - // std::cout << "FillIntensity\t" << (pPPTShape->m_o3dOptions.dFillIntensity) << "\n"; - // std::cout << "FillX\t" << (pPPTShape->m_o3dOptions.dFillX) << "\n"; - // std::cout << "FillY\t" << (pPPTShape->m_o3dOptions.dFillY) << "\n"; - // if (pPPTShape->m_o3dOptions.dFillZ) - // { - // std::cout << "FillZ\t" << (*pPPTShape->m_o3dOptions.dFillZ) << "\n"; - // } - // std::cout << "........................................................................\n"; - //} + // if (pPPTShape->m_o3dOptions.dAmbientIntensity) + // { + // std::cout << "AmbientIntensity\t" << (*pPPTShape->m_o3dOptions.dAmbientIntensity) << "\n"; + // } + // if (pPPTShape->m_o3dOptions.dKeyIntensity) + // { + // std::cout << "KeyIntensity\t" << (*pPPTShape->m_o3dOptions.dKeyIntensity) << "\n"; + // } + // std::cout << "KeyX\t" << (pPPTShape->m_o3dOptions.dKeyX) << "\n"; + // std::cout << "KeyY\t" << (pPPTShape->m_o3dOptions.dKeyY) << "\n"; + // if (pPPTShape->m_o3dOptions.dKeyZ) + // { + // std::cout << "KeyZ\t" << (*pPPTShape->m_o3dOptions.dKeyZ) << "\n"; + // } + // std::cout << "FillIntensity\t" << (pPPTShape->m_o3dOptions.dFillIntensity) << "\n"; + // std::cout << "FillX\t" << (pPPTShape->m_o3dOptions.dFillX) << "\n"; + // std::cout << "FillY\t" << (pPPTShape->m_o3dOptions.dFillY) << "\n"; + // if (pPPTShape->m_o3dOptions.dFillZ) + // { + // std::cout << "FillZ\t" << (*pPPTShape->m_o3dOptions.dFillZ) << "\n"; + // } + // std::cout << "........................................................................\n"; + //} - m_oWriter.WriteString(std::wstring(L"")); - m_oWriter.WriteString(std::wstring(L"m_o3dOptions.dSkewAngle < 10) sAngle = L"Left"; - else if (pPPTShape->m_o3dOptions.dSkewAngle >= 10 && pPPTShape->m_o3dOptions.dSkewAngle < 80) sAngle = L"BottomLeft"; - else if (pPPTShape->m_o3dOptions.dSkewAngle >= 80 && pPPTShape->m_o3dOptions.dSkewAngle < 100) sAngle = L"Bottom"; - else if (pPPTShape->m_o3dOptions.dSkewAngle >= 100 && pPPTShape->m_o3dOptions.dSkewAngle < 145) sAngle = L"BottomRight"; - else if (pPPTShape->m_o3dOptions.dSkewAngle >= 145 && pPPTShape->m_o3dOptions.dSkewAngle < 190) sAngle = L"Right"; - else if (pPPTShape->m_o3dOptions.dSkewAngle >= 190 && pPPTShape->m_o3dOptions.dSkewAngle < 235) sAngle = L"TopRight"; - else if (pPPTShape->m_o3dOptions.dSkewAngle >= 235 && pPPTShape->m_o3dOptions.dSkewAngle < 280) sAngle = L"Top"; - else if (pPPTShape->m_o3dOptions.dSkewAngle >= 280 && pPPTShape->m_o3dOptions.dSkewAngle < 325) sAngle = L"TopLeft"; - else sAngle = L"Front"; + m_oWriter.WriteString(std::wstring(L"")); + m_oWriter.WriteString(std::wstring(L"m_o3dOptions.bParallel) - m_oWriter.WriteString(std::wstring(L" prst=\"legacyOblique" + sAngle + L"\"")); - else - m_oWriter.WriteString(std::wstring(L" prst=\"legacyPerspective" + sAngle + L"\"")); - m_oWriter.WriteString(std::wstring(L">")); - if (pPPTShape->m_o3dOptions.bConstrainRotation) - { - m_oWriter.WriteString(std::wstring(L"m_o3dOptions.dXRotationAngle.get_value_or(0))) + L"\"")); - m_oWriter.WriteString(std::wstring(L" lon=\"" + std::to_wstring((int)(60000 * pPPTShape->m_o3dOptions.dYRotationAngle.get_value_or(0))) + L"\"")); - m_oWriter.WriteString(std::wstring(L" rev=\"" + std::to_wstring((int)(60000 * pPPTShape->m_o3dOptions.dRotationAngle.get_value_or(0))) + L"\"")); - m_oWriter.WriteString(std::wstring(L"/>")); - } - m_oWriter.WriteString(std::wstring(L"")); + std::wstring sAngle; + if (pPPTShape->m_o3dOptions.dSkewAngle < 10) sAngle = L"Left"; + else if (pPPTShape->m_o3dOptions.dSkewAngle >= 10 && pPPTShape->m_o3dOptions.dSkewAngle < 80) sAngle = L"BottomLeft"; + else if (pPPTShape->m_o3dOptions.dSkewAngle >= 80 && pPPTShape->m_o3dOptions.dSkewAngle < 100) sAngle = L"Bottom"; + else if (pPPTShape->m_o3dOptions.dSkewAngle >= 100 && pPPTShape->m_o3dOptions.dSkewAngle < 145) sAngle = L"BottomRight"; + else if (pPPTShape->m_o3dOptions.dSkewAngle >= 145 && pPPTShape->m_o3dOptions.dSkewAngle < 190) sAngle = L"Right"; + else if (pPPTShape->m_o3dOptions.dSkewAngle >= 190 && pPPTShape->m_o3dOptions.dSkewAngle < 235) sAngle = L"TopRight"; + else if (pPPTShape->m_o3dOptions.dSkewAngle >= 235 && pPPTShape->m_o3dOptions.dSkewAngle < 280) sAngle = L"Top"; + else if (pPPTShape->m_o3dOptions.dSkewAngle >= 280 && pPPTShape->m_o3dOptions.dSkewAngle < 325) sAngle = L"TopLeft"; + else sAngle = L"Front"; - m_oWriter.WriteString(std::wstring(L"m_o3dOptions.dFillIntensity < 0.3) - m_oWriter.WriteString(std::wstring(L" rig=\"legacyHarsh3\"")); - else if (pPPTShape->m_o3dOptions.dFillIntensity < 0.4) - m_oWriter.WriteString(std::wstring(L" rig=\"legacyFlat4\"")); - else if (pPPTShape->m_o3dOptions.dFillIntensity > 0.6 || - (pPPTShape->m_o3dOptions.dKeyX < 0.1 && pPPTShape->m_o3dOptions.dFillX < 0.1 && - pPPTShape->m_o3dOptions.dKeyY < 0.1 && pPPTShape->m_o3dOptions.dFillY < 0.1)) - m_oWriter.WriteString(std::wstring(L" rig=\"legacyFlat1\"")); - else - m_oWriter.WriteString(std::wstring(L" rig=\"legacyFlat3\"")); + if (pPPTShape->m_o3dOptions.bParallel) + m_oWriter.WriteString(std::wstring(L" prst=\"legacyOblique" + sAngle + L"\"")); + else + m_oWriter.WriteString(std::wstring(L" prst=\"legacyPerspective" + sAngle + L"\"")); + m_oWriter.WriteString(std::wstring(L">")); + if (pPPTShape->m_o3dOptions.bConstrainRotation) + { + m_oWriter.WriteString(std::wstring(L"m_o3dOptions.dXRotationAngle.get_value_or(0))) + L"\"")); + m_oWriter.WriteString(std::wstring(L" lon=\"" + std::to_wstring((int)(60000 * pPPTShape->m_o3dOptions.dYRotationAngle.get_value_or(0))) + L"\"")); + m_oWriter.WriteString(std::wstring(L" rev=\"" + std::to_wstring((int)(60000 * pPPTShape->m_o3dOptions.dRotationAngle.get_value_or(0))) + L"\"")); + m_oWriter.WriteString(std::wstring(L"/>")); + } + m_oWriter.WriteString(std::wstring(L"")); - if (pPPTShape->m_o3dOptions.dKeyX < 0.1 && pPPTShape->m_o3dOptions.dFillX < 0.1) - { - if (pPPTShape->m_o3dOptions.dKeyY < 0.1 && pPPTShape->m_o3dOptions.dFillY < 0.1) - m_oWriter.WriteString(std::wstring(L" dir=\"t\"")); - else if (pPPTShape->m_o3dOptions.dKeyY < 0) m_oWriter.WriteString(std::wstring(L" dir=\"r\"")); - else m_oWriter.WriteString(std::wstring(L" dir=\"l\"")); - } - else - { - if (pPPTShape->m_o3dOptions.dKeyX < 0) m_oWriter.WriteString(std::wstring(L" dir=\"t\"")); - else m_oWriter.WriteString(std::wstring(L" dir=\"b\"")); - } - m_oWriter.WriteString(std::wstring(L"/>")); - m_oWriter.WriteString(std::wstring(L"")); - - m_oWriter.WriteString(std::wstring(L"m_o3dOptions.nExtrudeBackward) + L"\"")); + m_oWriter.WriteString(std::wstring(L"m_o3dOptions.dFillIntensity < 0.3) + m_oWriter.WriteString(std::wstring(L" rig=\"legacyHarsh3\"")); + else if (pPPTShape->m_o3dOptions.dFillIntensity < 0.4) + m_oWriter.WriteString(std::wstring(L" rig=\"legacyFlat4\"")); + else if (pPPTShape->m_o3dOptions.dFillIntensity > 0.6 || + (pPPTShape->m_o3dOptions.dKeyX < 0.1 && pPPTShape->m_o3dOptions.dFillX < 0.1 && + pPPTShape->m_o3dOptions.dKeyY < 0.1 && pPPTShape->m_o3dOptions.dFillY < 0.1)) + m_oWriter.WriteString(std::wstring(L" rig=\"legacyFlat1\"")); + else + m_oWriter.WriteString(std::wstring(L" rig=\"legacyFlat3\"")); - switch(pPPTShape->m_o3dOptions.nRenderMode) - { - case 0x00000000://solid - { - if (pPPTShape->m_o3dOptions.bMetallic) - m_oWriter.WriteString(std::wstring(L" prstMaterial=\"legacyMetal\"")); - else - m_oWriter.WriteString(std::wstring(L" prstMaterial=\"legacyMatte\"")); - }break; - case 0x00000001: m_oWriter.WriteString(std::wstring(L" prstMaterial=\"legacyWireframe\"")); break; //wireframe - case 0x00000002: m_oWriter.WriteString(std::wstring(L" prstMaterial=\"legacyWireframe\"")); break; //bounding cube ???? - } + if (pPPTShape->m_o3dOptions.dKeyX < 0.1 && pPPTShape->m_o3dOptions.dFillX < 0.1) + { + if (pPPTShape->m_o3dOptions.dKeyY < 0.1 && pPPTShape->m_o3dOptions.dFillY < 0.1) + m_oWriter.WriteString(std::wstring(L" dir=\"t\"")); + else if (pPPTShape->m_o3dOptions.dKeyY < 0) m_oWriter.WriteString(std::wstring(L" dir=\"r\"")); + else m_oWriter.WriteString(std::wstring(L" dir=\"l\"")); + } + else + { + if (pPPTShape->m_o3dOptions.dKeyX < 0) m_oWriter.WriteString(std::wstring(L" dir=\"t\"")); + else m_oWriter.WriteString(std::wstring(L" dir=\"b\"")); + } + m_oWriter.WriteString(std::wstring(L"/>")); + m_oWriter.WriteString(std::wstring(L"")); - m_oWriter.WriteString(std::wstring(L">")); + m_oWriter.WriteString(std::wstring(L"m_o3dOptions.nExtrudeBackward) + L"\"")); - m_oWriter.WriteString(std::wstring(L"")); - m_oWriter.WriteString(std::wstring(L"")); + switch(pPPTShape->m_o3dOptions.nRenderMode) + { + case 0x00000000://solid + { + if (pPPTShape->m_o3dOptions.bMetallic) + m_oWriter.WriteString(std::wstring(L" prstMaterial=\"legacyMetal\"")); + else + m_oWriter.WriteString(std::wstring(L" prstMaterial=\"legacyMatte\"")); + }break; + case 0x00000001: m_oWriter.WriteString(std::wstring(L" prstMaterial=\"legacyWireframe\"")); break; //wireframe + case 0x00000002: m_oWriter.WriteString(std::wstring(L" prstMaterial=\"legacyWireframe\"")); break; //bounding cube ???? + } - std::wstring strExtrusionClr; - if (pPPTShape->m_o3dOptions.oExtrusionColor) - { - strExtrusionClr = ConvertColor(*pPPTShape->m_o3dOptions.oExtrusionColor); - } - else - { - if (pShapeElement->m_oBrush.Type != c_BrushTypeNoFill) - { - strExtrusionClr = ConvertColor(pShapeElement->m_oBrush.Color1, pShapeElement->m_oBrush.Alpha1); - } - else - { - strExtrusionClr = ConvertColor(pShapeElement->m_oPen.Color, pShapeElement->m_oPen.Alpha); - } - } - m_oWriter.WriteString(std::wstring(L"")); - m_oWriter.WriteString(strExtrusionClr); - m_oWriter.WriteString(std::wstring(L"")); - m_oWriter.WriteString(std::wstring(L"")); - m_oWriter.WriteString(strExtrusionClr); - m_oWriter.WriteString(std::wstring(L"")); + m_oWriter.WriteString(std::wstring(L">")); - m_oWriter.WriteString(std::wstring(L"")); + m_oWriter.WriteString(std::wstring(L"")); + m_oWriter.WriteString(std::wstring(L"")); + + std::wstring strExtrusionClr; + if (pPPTShape->m_o3dOptions.oExtrusionColor) + { + strExtrusionClr = ConvertColor(*pPPTShape->m_o3dOptions.oExtrusionColor); + } + else + { + if (pShapeElement->m_oBrush.Type != c_BrushTypeNoFill) + { + strExtrusionClr = ConvertColor(pShapeElement->m_oBrush.Color1, pShapeElement->m_oBrush.Alpha1); + } + else + { + strExtrusionClr = ConvertColor(pShapeElement->m_oPen.Color, pShapeElement->m_oPen.Alpha); + } + } + m_oWriter.WriteString(std::wstring(L"")); + m_oWriter.WriteString(strExtrusionClr); + m_oWriter.WriteString(std::wstring(L"")); + m_oWriter.WriteString(std::wstring(L"")); + m_oWriter.WriteString(strExtrusionClr); + m_oWriter.WriteString(std::wstring(L"")); + + m_oWriter.WriteString(std::wstring(L"")); } void PPT_FORMAT::CShapeWriter::WriteTextInfo() { - //if (false == m_xmlTxBodyAlternative.empty()) - //{ - // m_oWriter.WriteString(m_xmlTxBodyAlternative); + //if (false == m_xmlTxBodyAlternative.empty()) + //{ + // m_oWriter.WriteString(m_xmlTxBodyAlternative); - // return; - //} - CShapeElement* pShapeElement = dynamic_cast(m_pElement.get()); - if (!pShapeElement) return; + // return; + //} + CShapeElement* pShapeElement = dynamic_cast(m_pElement.get()); + if (!pShapeElement) return; - CDoubleRect oTextRect; + CDoubleRect oTextRect; - size_t nCount = pShapeElement->m_pShape->m_oText.m_arParagraphs.size(); + size_t nCount = pShapeElement->m_pShape->m_oText.m_arParagraphs.size(); - m_oWriter.WriteString(std::wstring(L"")); + m_oWriter.WriteString(std::wstring(L"")); - m_oWriter.WriteString(std::wstring(L"m_pShape->GetTextRect(oTextRect); + pShapeElement->m_pShape->GetTextRect(oTextRect); std::wstring str = L" lIns=\"" + std::to_wstring((int)oTextRect.left) + L"\" tIns=\"" + std::to_wstring((int)oTextRect.top) + - L"\" rIns=\"" + std::to_wstring((int)oTextRect.right) + L"\" bIns=\"" + std::to_wstring((int)oTextRect.bottom) + L"\""; - - m_oWriter.WriteString(str); - -// m_oWriter.WriteString(std::wstring(L" lIns=\"0\" tIns=\"0\" rIns=\"0\" bIns=\"0\"")); + L"\" rIns=\"" + std::to_wstring((int)oTextRect.right) + L"\" bIns=\"" + std::to_wstring((int)oTextRect.bottom) + L"\""; - if (pShapeElement->m_pShape->m_oText.m_oAttributes.m_nTextAlignVertical == 0 ) - m_oWriter.WriteString(L" anchor=\"t\""); - else if (pShapeElement->m_pShape->m_oText.m_oAttributes.m_nTextAlignVertical == 2 ) - m_oWriter.WriteString(L" anchor=\"b\""); - else if (pShapeElement->m_pShape->m_oText.m_oAttributes.m_nTextAlignVertical == 1 ) - { - m_oWriter.WriteString(L" anchor=\"ctr\""); - m_oWriter.WriteString(L" anchorCtr=\"0\""); - } - if (pShapeElement->m_pShape->m_oText.m_oAttributes.m_dTextRotate > 0) - { - std::wstring strProp = std::to_wstring((int)(pShapeElement->m_pShape->m_oText.m_oAttributes.m_dTextRotate * 60000)); - m_oWriter.WriteString(L" rot=\"" + strProp + L"\""); - } - if (pShapeElement->m_pShape->m_oText.m_nTextFlow >= 0) - { - switch(pShapeElement->m_pShape->m_oText.m_nTextFlow) - { - case 1: - case 3: m_oWriter.WriteString(L" vert=\"vert\""); break; - case 2: m_oWriter.WriteString(L" vert=\"vert270\""); break; - case 5: m_oWriter.WriteString(L" vert=\"wordArtVert\""); break; - } - } - else if (pShapeElement->m_pShape->m_oText.m_bVertical) - { - m_oWriter.WriteString(L" vert=\"eaVert\""); - } - m_oWriter.WriteString(L">"); + m_oWriter.WriteString(str); - if (m_bWordArt) - { - std::wstring prstTxWarp = oox::Spt2WordArtShapeType((oox::MSOSPT)pShapeElement->m_lShapeType); - m_oWriter.WriteString(std::wstring(L"")); - m_oWriter.WriteString(std::wstring(L""));//модификаторы + // m_oWriter.WriteString(std::wstring(L" lIns=\"0\" tIns=\"0\" rIns=\"0\" bIns=\"0\"")); - CPPTShape *pPPTShape = dynamic_cast(pShapeElement->m_pShape->getBaseShape().get()); - std::wstring strVal; + if (pShapeElement->m_pShape->m_oText.m_oAttributes.m_nTextAlignVertical == 0 ) + m_oWriter.WriteString(L" anchor=\"t\""); + else if (pShapeElement->m_pShape->m_oText.m_oAttributes.m_nTextAlignVertical == 2 ) + m_oWriter.WriteString(L" anchor=\"b\""); + else if (pShapeElement->m_pShape->m_oText.m_oAttributes.m_nTextAlignVertical == 1 ) + { + m_oWriter.WriteString(L" anchor=\"ctr\""); + m_oWriter.WriteString(L" anchorCtr=\"0\""); + } + if (pShapeElement->m_pShape->m_oText.m_oAttributes.m_dTextRotate > 0) + { + std::wstring strProp = std::to_wstring((int)(pShapeElement->m_pShape->m_oText.m_oAttributes.m_dTextRotate * 60000)); + m_oWriter.WriteString(L" rot=\"" + strProp + L"\""); + } + if (pShapeElement->m_pShape->m_oText.m_nTextFlow >= 0) + { + switch(pShapeElement->m_pShape->m_oText.m_nTextFlow) + { + case 1: + case 3: m_oWriter.WriteString(L" vert=\"vert\""); break; + case 2: m_oWriter.WriteString(L" vert=\"vert270\""); break; + case 5: m_oWriter.WriteString(L" vert=\"wordArtVert\""); break; + } + } + else if (pShapeElement->m_pShape->m_oText.m_bVertical) + { + m_oWriter.WriteString(L" vert=\"eaVert\""); + } + m_oWriter.WriteString(L">"); - for (size_t i = 0 ; (pPPTShape) && (i < pPPTShape->m_arAdjustments.size()); i++) - { - switch(pShapeElement->m_lShapeType) - { - case oox::msosptTextFadeUp: - { - double kf = 4.63; //"волшебный" - std::wstring strVal = std::to_wstring((int)(kf * pPPTShape->m_arAdjustments[i])); - - m_oWriter.WriteString(L""); - }break; - } - - } + if (m_bWordArt) + { + std::wstring prstTxWarp = oox::Spt2WordArtShapeType((oox::MSOSPT)pShapeElement->m_lShapeType); + m_oWriter.WriteString(std::wstring(L"")); + m_oWriter.WriteString(std::wstring(L""));//модификаторы + + CPPTShape *pPPTShape = dynamic_cast(pShapeElement->m_pShape->getBaseShape().get()); + std::wstring strVal; + + for (size_t i = 0 ; (pPPTShape) && (i < pPPTShape->m_arAdjustments.size()); i++) + { + switch(pShapeElement->m_lShapeType) + { + case oox::msosptTextFadeUp: + { + double kf = 4.63; //"волшебный" + std::wstring strVal = std::to_wstring((int)(kf * pPPTShape->m_arAdjustments[i])); + + m_oWriter.WriteString(L""); + }break; + } + + } + + m_oWriter.WriteString(L""); + m_oWriter.WriteString(L""); + } + if (pShapeElement->m_pShape->m_oText.m_bAutoFit) + { + m_oWriter.WriteString(L""); + } + m_oWriter.WriteString(L""); - m_oWriter.WriteString(L""); - m_oWriter.WriteString(L""); - } - if (pShapeElement->m_pShape->m_oText.m_bAutoFit) - { - m_oWriter.WriteString(L""); - } - m_oWriter.WriteString(L""); - if (0 == nCount) - { - m_oWriter.WriteString(L""); - return; - } - m_oWriter.WriteString(L""); + { + m_oWriter.WriteString(L""); + return; + } + m_oWriter.WriteString(L""); if (!m_bWordArt) - { - CStylesWriter styleWriter(m_pTheme); - styleWriter.ConvertStyles(pShapeElement->m_pShape->m_oText.m_oStyles, m_oWriter); - } + { + CStylesWriter styleWriter(m_pTheme); + styleWriter.ConvertStyles(pShapeElement->m_pShape->m_oText.m_oStyles, m_oWriter); + } - m_oWriter.WriteString(std::wstring(L"")); + m_oWriter.WriteString(std::wstring(L"")); - for (size_t nIndexPar = 0; nIndexPar < nCount; ++nIndexPar) - { - PPT_FORMAT::CParagraph* pParagraph = &pShapeElement->m_pShape->m_oText.m_arParagraphs[nIndexPar]; + for (size_t nIndexPar = 0; nIndexPar < nCount; ++nIndexPar) + { + PPT_FORMAT::CParagraph* pParagraph = &pShapeElement->m_pShape->m_oText.m_arParagraphs[nIndexPar]; - //if (m_bWordArt && nIndexPar == nCount-1) - //{ - // if (pParagraph->m_arSpans.size() < 1) break; - // if (pParagraph->m_arSpans.size() == 1 && pParagraph->m_arSpans[0].m_strText.empty()) break; - //} + //if (m_bWordArt && nIndexPar == nCount-1) + //{ + // if (pParagraph->m_arSpans.size() < 1) break; + // if (pParagraph->m_arSpans.size() == 1 && pParagraph->m_arSpans[0].m_strText.empty()) break; + //} - std::wstring _str1 = std::to_wstring(pParagraph->m_lTextLevel); - m_oWriter.WriteString(L"m_lTextLevel); + m_oWriter.WriteString(L"m_oPFRun; + PPT_FORMAT::CTextPFRun* pPF = &pParagraph->m_oPFRun; - if (pPF->textDirection.is_init()) - { - if (pPF->textDirection.get() == 1) m_oWriter.WriteString(std::wstring(L" rtl=\"1\"")); - else m_oWriter.WriteString(std::wstring(L" rtl=\"0\"")); - } - if (pPF->fontAlign.is_init()) - { - std::wstring strProp = CStylesWriter::GetFontAlign(pPF->fontAlign.get()); - m_oWriter.WriteString(std::wstring(L" fontAlgn=\"") + strProp + L"\""); - } - int leftMargin = 0; - if (pPF->leftMargin.is_init()) - { - leftMargin = pPF->leftMargin.get(); + if (pPF->textDirection.is_init()) + { + if (pPF->textDirection.get() == 1) m_oWriter.WriteString(std::wstring(L" rtl=\"1\"")); + else m_oWriter.WriteString(std::wstring(L" rtl=\"0\"")); + } + if (pPF->fontAlign.is_init()) + { + std::wstring strProp = CStylesWriter::GetFontAlign(pPF->fontAlign.get()); + m_oWriter.WriteString(std::wstring(L" fontAlgn=\"") + strProp + L"\""); + } + int leftMargin = 0; + if (pPF->leftMargin.is_init()) + { + leftMargin = pPF->leftMargin.get(); std::wstring strProp = std::to_wstring( leftMargin ); - m_oWriter.WriteString(L" marL=\"" + strProp + L"\""); - } - if (pPF->indent.is_init()) - { - std::wstring strProp = std::to_wstring(pPF->indent.get() - leftMargin); - m_oWriter.WriteString(L" indent=\"" + strProp + L"\""); - } - if (pPF->textAlignment.is_init()) - { + m_oWriter.WriteString(L" marL=\"" + strProp + L"\""); + } + if (pPF->indent.is_init()) + { + std::wstring strProp = std::to_wstring(pPF->indent.get() - leftMargin); + m_oWriter.WriteString(L" indent=\"" + strProp + L"\""); + } + if (pPF->textAlignment.is_init()) + { std::wstring strProp = CStylesWriter::GetTextAlign(pPF->textAlignment.get()); - m_oWriter.WriteString(L" algn=\"" + strProp + L"\""); - } - if (pPF->defaultTabSize.is_init()) - { - std::wstring strProp= std::to_wstring( pPF->defaultTabSize.get()); - m_oWriter.WriteString(L" defTabSz=\"" + strProp + L"\""); - } - m_oWriter.WriteString(L">"); + m_oWriter.WriteString(L" algn=\"" + strProp + L"\""); + } + if (pPF->defaultTabSize.is_init()) + { + std::wstring strProp= std::to_wstring( pPF->defaultTabSize.get()); + m_oWriter.WriteString(L" defTabSz=\"" + strProp + L"\""); + } + m_oWriter.WriteString(L">"); - double dKoef1 = 3.52777778; // :-) чё это не понятно ... - if (pPF->lineSpacing.is_init()) - { - LONG val = pPF->lineSpacing.get(); - //1/1024 master unit or 1/589824 inch. - //1 inch = 576 master unit -> 1 master unit = 0.125 pt - if (val > 0)//The absolute value specifies spacing in master units. - { - std::wstring strProp = std::to_wstring( (int)(val* 0.125 * 100/*/ dKoef1*/)); - m_oWriter.WriteString(L""); - } - else if (val < 0 && val > -13200) - {//0 to 13200, inclusive - The value specifies spacing as a percentage of the text line height. - std::wstring strProp = std::to_wstring( -val * 1000); - m_oWriter.WriteString(L""); - } - } - if (pPF->spaceAfter.is_init()) - { - LONG val = pPF->spaceAfter.get(); - if (val > 0) - { - std::wstring strProp = std::to_wstring((int)(val * 0.125 * 100/*/ dKoef1*/)); - m_oWriter.WriteString(L""); - } - else if (val < 0 && val > -13200) - { - std::wstring strProp = std::to_wstring(-val * 1000); - m_oWriter.WriteString(L""); - } - } - if (pPF->spaceBefore.is_init()) - { - LONG val = pPF->spaceBefore.get(); - if (val > 0) - { - std::wstring strProp = std::to_wstring((int)(val * 0.125 * 100/*/ dKoef1*/)); - m_oWriter.WriteString(L""); - } - else if (val < 0 && val > -13200) - { - std::wstring strProp = std::to_wstring(-val * 1000); - m_oWriter.WriteString(L""); - } - } + double dKoef1 = 3.52777778; // :-) чё это не понятно ... + if (pPF->lineSpacing.is_init()) + { + LONG val = pPF->lineSpacing.get(); + //1/1024 master unit or 1/589824 inch. + //1 inch = 576 master unit -> 1 master unit = 0.125 pt + if (val > 0)//The absolute value specifies spacing in master units. + { + std::wstring strProp = std::to_wstring( (int)(val* 0.125 * 100/*/ dKoef1*/)); + m_oWriter.WriteString(L""); + } + else if (val < 0 && val > -13200) + {//0 to 13200, inclusive - The value specifies spacing as a percentage of the text line height. + std::wstring strProp = std::to_wstring( -val * 1000); + m_oWriter.WriteString(L""); + } + } + if (pPF->spaceAfter.is_init()) + { + LONG val = pPF->spaceAfter.get(); + if (val > 0) + { + std::wstring strProp = std::to_wstring((int)(val * 0.125 * 100/*/ dKoef1*/)); + m_oWriter.WriteString(L""); + } + else if (val < 0 && val > -13200) + { + std::wstring strProp = std::to_wstring(-val * 1000); + m_oWriter.WriteString(L""); + } + } + if (pPF->spaceBefore.is_init()) + { + LONG val = pPF->spaceBefore.get(); + if (val > 0) + { + std::wstring strProp = std::to_wstring((int)(val * 0.125 * 100/*/ dKoef1*/)); + m_oWriter.WriteString(L""); + } + else if (val < 0 && val > -13200) + { + std::wstring strProp = std::to_wstring(-val * 1000); + m_oWriter.WriteString(L""); + } + } - if (pPF->hasBullet.is_init()) - { - if (pPF->hasBullet.get()) - { - if (pPF->bulletColor.is_init()) - { - m_oWriter.WriteString(std::wstring(L"")); - m_oWriter.WriteString(ConvertColor(pPF->bulletColor.get(), 255)); - m_oWriter.WriteString(std::wstring(L"")); - } - if (pPF->bulletSize.is_init()) - { - if (pPF->bulletSize.get() > 24 && pPF->bulletSize.get() < 401) - { - std::wstring strProp = std::to_wstring(pPF->bulletSize.get() * 1000 ); - m_oWriter.WriteString(L""); - } - if (pPF->bulletSize.get() < 0 && pPF->bulletSize.get() > -4001) - { - std::wstring strProp = std::to_wstring(- pPF->bulletSize.get() ); - m_oWriter.WriteString(L""); - } - } - if (pPF->bulletFontProperties.is_init()) - { - m_oWriter.WriteString(std::wstring(L"bulletFontProperties->Name + L"\""); + if (pPF->hasBullet.is_init()) + { + if (pPF->hasBullet.get()) + { + if (pPF->bulletColor.is_init()) + { + m_oWriter.WriteString(std::wstring(L"")); + m_oWriter.WriteString(ConvertColor(pPF->bulletColor.get(), 255)); + m_oWriter.WriteString(std::wstring(L"")); + } + if (pPF->bulletSize.is_init()) + { + if (pPF->bulletSize.get() > 24 && pPF->bulletSize.get() < 401) + { + std::wstring strProp = std::to_wstring(pPF->bulletSize.get() * 1000 ); + m_oWriter.WriteString(L""); + } + if (pPF->bulletSize.get() < 0 && pPF->bulletSize.get() > -4001) + { + std::wstring strProp = std::to_wstring(- pPF->bulletSize.get() ); + m_oWriter.WriteString(L""); + } + } + if (pPF->bulletFontProperties.is_init()) + { + m_oWriter.WriteString(std::wstring(L"bulletFontProperties->Name + L"\""); - if ( pPF->bulletFontProperties->PitchFamily > 0) - { - m_oWriter.WriteString(std::wstring(L" pitchFamily=\"") + std::to_wstring(pPF->bulletFontProperties->PitchFamily) + L"\""); - } - if ( pPF->bulletFontProperties->Charset > 0) - { - m_oWriter.WriteString(std::wstring(L" charset=\"") + std::to_wstring((char)pPF->bulletFontProperties->Charset) + L"\""); - } - m_oWriter.WriteString(std::wstring(L"/>")); - } + if ( pPF->bulletFontProperties->PitchFamily > 0) + { + m_oWriter.WriteString(std::wstring(L" pitchFamily=\"") + std::to_wstring(pPF->bulletFontProperties->PitchFamily) + L"\""); + } + if ( pPF->bulletFontProperties->Charset > 0) + { + m_oWriter.WriteString(std::wstring(L" charset=\"") + std::to_wstring((char)pPF->bulletFontProperties->Charset) + L"\""); + } + m_oWriter.WriteString(std::wstring(L"/>")); + } if (pPF->bulletAutoNum.is_init()) // TODO Numbering { m_oWriter.WriteString(L""); } - bool set = true; - if (pPF->bulletFontProperties.is_init() == false && pPF->bulletSize.is_init() == false) - { - m_oWriter.WriteString(std::wstring(L"")); - if (pPF->bulletColor.is_init() == false) - set = false; - } + bool set = true; + if (pPF->bulletFontProperties.is_init() == false && pPF->bulletSize.is_init() == false) + { + m_oWriter.WriteString(std::wstring(L"")); + if (pPF->bulletColor.is_init() == false) + set = false; + } - if (pPF->bulletChar.is_init()) - { - wchar_t bu = pPF->bulletChar.get(); - m_oWriter.WriteString(std::wstring(L"")); - set = true; - } - - if (!set) - { - wchar_t bu = 0x2022; - m_oWriter.WriteString(std::wstring(L"")); - } - } - else - { - m_oWriter.WriteString(std::wstring(L"")); - } - } + if (pPF->bulletChar.is_init()) + { + wchar_t bu = pPF->bulletChar.get(); + m_oWriter.WriteString(std::wstring(L"")); + set = true; + } - m_oWriter.WriteString(std::wstring(L"")); + if (!set) + { + wchar_t bu = 0x2022; + m_oWriter.WriteString(std::wstring(L"")); + } + } + else + { + m_oWriter.WriteString(std::wstring(L"")); + } + } - std::wstring typeRun = L"a:r"; + m_oWriter.WriteString(std::wstring(L"")); - size_t nCountSpans = pParagraph->m_arSpans.size(); - for (size_t nSpan = 0; nSpan < nCountSpans; ++nSpan) - { - if (true) - { - if ((nSpan == (nCountSpans - 1)) && (_T("\n") == pParagraph->m_arSpans[nSpan].m_strText || pParagraph->m_arSpans[nSpan].m_strText.empty()) ) - { - PPT_FORMAT::CTextCFRun* pCF = &pParagraph->m_arSpans[nSpan].m_oRun; - if ((pCF->Size.is_init()) && (pCF->Size.get() > 0) && (pCF->Size.get() < 4001)) - { + std::wstring typeRun = L"a:r"; + + size_t nCountSpans = pParagraph->m_arSpans.size(); + for (size_t nSpan = 0; nSpan < nCountSpans; ++nSpan) + { + if (true) + { + if ((nSpan == (nCountSpans - 1)) && (_T("\n") == pParagraph->m_arSpans[nSpan].m_strText || pParagraph->m_arSpans[nSpan].m_strText.empty()) ) + { + PPT_FORMAT::CTextCFRun* pCF = &pParagraph->m_arSpans[nSpan].m_oRun; + if ((pCF->Size.is_init()) && (pCF->Size.get() > 0) && (pCF->Size.get() < 4001)) + { m_oWriter.WriteString(L"Size.get())) + L"\"/>"); - } - else - { - m_oWriter.WriteString(std::wstring(L"")); - } - continue; - } - } + } + else + { + m_oWriter.WriteString(std::wstring(L"")); + } + continue; + } + } - PPT_FORMAT::CTextCFRun* pCF = &pParagraph->m_arSpans[nSpan].m_oRun; - int span_sz = pParagraph->m_arSpans[nSpan].m_strText.length() ; + PPT_FORMAT::CTextCFRun* pCF = &pParagraph->m_arSpans[nSpan].m_oRun; + int span_sz = pParagraph->m_arSpans[nSpan].m_strText.length() ; if ((span_sz==1 && ( pParagraph->m_arSpans[nSpan].m_strText[0] == (wchar_t)13 )) || - ((span_sz==2 && ( pParagraph->m_arSpans[nSpan].m_strText[0] == (wchar_t)13 ) && ( pParagraph->m_arSpans[nSpan].m_strText[1] == (wchar_t)13 )))) - { - continue; - } + ((span_sz==2 && ( pParagraph->m_arSpans[nSpan].m_strText[0] == (wchar_t)13 ) && ( pParagraph->m_arSpans[nSpan].m_strText[1] == (wchar_t)13 )))) + { + continue; + } - if (pParagraph->m_arSpans[nSpan].m_strText.empty() && !pParagraph->m_arSpans[nSpan].m_bBreak) continue; - - if (pParagraph->m_arSpans[nSpan].m_bBreak) - { - m_oWriter.WriteString(std::wstring(L"m_lPlaceholderType == PT_MasterSlideNumber/* && pParagraph->m_arSpans[nSpan].m_bField*/) - { - m_oWriter.WriteString(std::wstring(L"m_lPlaceholderType == PT_MasterDate && pShapeElement->m_nFormatDate == 1/* && pParagraph->m_arSpans[nSpan].m_bField*/) - { - m_oWriter.WriteString(std::wstring(L"Size.is_init()) && (pCF->Size.get() > 0) && (pCF->Size.get() < 4001)) - { - m_oWriter.WriteString(L" sz=\"" + std::to_wstring((int)(100 * pCF->Size.get())) + L"\""); - } - if (pCF->BaseLineOffset.is_init()) - { - m_oWriter.WriteString(L" baseline=\"" + std::to_wstring((int)(1000 * pCF->BaseLineOffset.get())) + L"\""); - } - if (pCF->FontBold.is_init()) - { - if (pCF->FontBold.get()) - m_oWriter.WriteString(std::wstring(L" b=\"1\"")); - else - m_oWriter.WriteString(std::wstring(L" b=\"0\"")); - } - if (pCF->FontItalic.is_init()) - { - if (pCF->FontItalic.get()) - m_oWriter.WriteString(std::wstring(L" i=\"1\"")); - else - m_oWriter.WriteString(std::wstring(L" i=\"0\"")); - } + if (pParagraph->m_arSpans[nSpan].m_strText.empty() && !pParagraph->m_arSpans[nSpan].m_bBreak) continue; - if (pCF->FontUnderline.is_init()) - { - if (pCF->FontUnderline.get()) - m_oWriter.WriteString(std::wstring(L" u=\"sng\"")); - else - m_oWriter.WriteString(std::wstring(L" u=\"none\"")); - } - if (pCF->Language.is_init()) - { - std::wstring str_lang = msLCID2wstring(pCF->Language.get()); - - if (str_lang.length() > 0) - m_oWriter.WriteString(std::wstring(L" lang=\"") + str_lang + _T("\"")); - } - m_oWriter.WriteString(std::wstring(L">")); - - if (m_bWordArt) - {//порядок важен - линия, заливка, тень !!! - if (pShapeElement->m_bLine) - { - m_oWriter.WriteString(ConvertLine(pShapeElement->m_oPen)); - } - m_oWriter.WriteString(ConvertBrush(pShapeElement->m_oBrush)); - m_oWriter.WriteString(ConvertShadow(pShapeElement->m_oShadow)); - } + if (pParagraph->m_arSpans[nSpan].m_bBreak) + { + m_oWriter.WriteString(std::wstring(L"Color.is_init()) - { - if (pCF->Color->m_lSchemeIndex != -1) - { + { + if (pShapeElement->m_lPlaceholderType == PT_MasterSlideNumber/* && pParagraph->m_arSpans[nSpan].m_bField*/) + { + m_oWriter.WriteString(std::wstring(L"m_lPlaceholderType == PT_MasterDate && pShapeElement->m_nFormatDate == 1/* && pParagraph->m_arSpans[nSpan].m_bField*/) + { + m_oWriter.WriteString(std::wstring(L"Size.is_init()) && (pCF->Size.get() > 0) && (pCF->Size.get() < 4001)) + { + m_oWriter.WriteString(L" sz=\"" + std::to_wstring((int)(100 * pCF->Size.get())) + L"\""); + } + if (pCF->BaseLineOffset.is_init()) + { + m_oWriter.WriteString(L" baseline=\"" + std::to_wstring((int)(1000 * pCF->BaseLineOffset.get())) + L"\""); + } + if (pCF->FontBold.is_init()) + { + if (pCF->FontBold.get()) + m_oWriter.WriteString(std::wstring(L" b=\"1\"")); + else + m_oWriter.WriteString(std::wstring(L" b=\"0\"")); + } + if (pCF->FontItalic.is_init()) + { + if (pCF->FontItalic.get()) + m_oWriter.WriteString(std::wstring(L" i=\"1\"")); + else + m_oWriter.WriteString(std::wstring(L" i=\"0\"")); + } + + if (pCF->FontUnderline.is_init()) + { + if (pCF->FontUnderline.get()) + m_oWriter.WriteString(std::wstring(L" u=\"sng\"")); + else + m_oWriter.WriteString(std::wstring(L" u=\"none\"")); + } + if (pCF->Language.is_init()) + { + std::wstring str_lang = msLCID2wstring(pCF->Language.get()); + + if (str_lang.length() > 0) + m_oWriter.WriteString(std::wstring(L" lang=\"") + str_lang + _T("\"")); + } + m_oWriter.WriteString(std::wstring(L">")); + + if (m_bWordArt) + {//порядок важен - линия, заливка, тень !!! + if (pShapeElement->m_bLine) + { + m_oWriter.WriteString(ConvertLine(pShapeElement->m_oPen)); + } + m_oWriter.WriteString(ConvertBrush(pShapeElement->m_oBrush)); + m_oWriter.WriteString(ConvertShadow(pShapeElement->m_oShadow)); + } + else + { + if (pCF->Color.is_init()) + { + if (pCF->Color->m_lSchemeIndex != -1) + { std::wstring strProp = _T("Color->m_lSchemeIndex) + _T("\"/>"); - m_oWriter.WriteString(strProp); - } - else - { + m_oWriter.WriteString(strProp); + } + else + { std::wstring strColor = XmlUtils::IntToString(pCF->Color->GetLONG_RGB(), L"%06x"); m_oWriter.WriteString(L""); - } - } - } + } + } + } - if (pCF->font.font.is_init()) - { - m_oWriter.WriteString(std::wstring(L"font.font->Name + _T("\"/>")); - } - else if (pCF->fontRef.is_init()) - { - if ((m_pTheme) && (pCF->fontRef.get() < m_pTheme->m_arFonts.size())) - { - m_oWriter.WriteString(L"m_arFonts[pCF->fontRef.get()].Name + L"\"/>"); - } - else - { - if (0 == pCF->fontRef.get()) - { - m_oWriter.WriteString(L""); - } - else - { - m_oWriter.WriteString(L""); - } - } - } + if (pCF->font.font.is_init()) + { + m_oWriter.WriteString(std::wstring(L"font.font->Name + _T("\"/>")); + } + else if (pCF->fontRef.is_init()) + { + if ((m_pTheme) && (pCF->fontRef.get() < m_pTheme->m_arFonts.size())) + { + m_oWriter.WriteString(L"m_arFonts[pCF->fontRef.get()].Name + L"\"/>"); + } + else + { + if (0 == pCF->fontRef.get()) + { + m_oWriter.WriteString(L""); + } + else + { + m_oWriter.WriteString(L""); + } + } + } - if (pCF->font.ea.is_init()) - { - m_oWriter.WriteString(std::wstring(L"font.ea->Name + L"\"/>"); - } - if (pCF->font.sym.is_init()) - { - m_oWriter.WriteString(std::wstring(L"font.sym->Name + _T("\"/>")); - } + if (pCF->font.ea.is_init()) + { + m_oWriter.WriteString(std::wstring(L"font.ea->Name + L"\"/>"); + } + if (pCF->font.sym.is_init()) + { + m_oWriter.WriteString(std::wstring(L"font.sym->Name + _T("\"/>")); + } WriteButton(nIndexPar); m_oWriter.WriteString(std::wstring(L"")); - if (pParagraph->m_arSpans[nSpan].m_bBreak) - { - m_oWriter.WriteString(std::wstring(L"")); - } - else - { + if (pParagraph->m_arSpans[nSpan].m_bBreak) + { + m_oWriter.WriteString(std::wstring(L"")); + } + else + { std::wstring strT1 = _T(""); - m_oWriter.WriteString(strT1); + m_oWriter.WriteString(strT1); - std::wstring strT = pParagraph->m_arSpans[nSpan].m_strText; - CorrectXmlString(strT); - m_oWriter.WriteString(strT); + std::wstring strT = pParagraph->m_arSpans[nSpan].m_strText; + CorrectXmlString(strT); + m_oWriter.WriteString(strT); std::wstring strT2 = _T(""); - m_oWriter.WriteString(strT2); - - if ((pShapeElement->m_lPlaceholderType == PT_MasterSlideNumber || - (pShapeElement->m_lPlaceholderType == PT_MasterDate && pShapeElement->m_nFormatDate == 1))/* && pParagraph->m_arSpans[nSpan].m_bField*/) - { - m_oWriter.WriteString(std::wstring(L"")); - } - else - m_oWriter.WriteString(std::wstring(L"")); - } - } + m_oWriter.WriteString(strT2); + + if ((pShapeElement->m_lPlaceholderType == PT_MasterSlideNumber || + (pShapeElement->m_lPlaceholderType == PT_MasterDate && pShapeElement->m_nFormatDate == 1))/* && pParagraph->m_arSpans[nSpan].m_bField*/) + { + m_oWriter.WriteString(std::wstring(L"")); + } + else + m_oWriter.WriteString(std::wstring(L"")); + } + } std::wstring strEndPar = _T(""); - m_oWriter.WriteString(strEndPar); - } + m_oWriter.WriteString(strEndPar); + } std::wstring str5 = _T(""); - m_oWriter.WriteString(str5); + m_oWriter.WriteString(str5); } std::wstring PPT_FORMAT::CShapeWriter::ConvertGroup() { - CGroupElement* pGroupElement = dynamic_cast(m_pElement.get()); - if (!pGroupElement) return L""; + CGroupElement* pGroupElement = dynamic_cast(m_pElement.get()); + if (!pGroupElement) return L""; - m_oWriter.WriteString(std::wstring(L"")); + m_oWriter.WriteString(std::wstring(L"")); - WriteGroupInfo(); - - m_pElement->NormalizeCoordsByMetric(); + WriteGroupInfo(); - m_oWriter.WriteString(std::wstring(L"")); + m_pElement->NormalizeCoordsByMetric(); - if (pGroupElement->m_bChildAnchorEnabled || pGroupElement->m_bAnchorEnabled) - { + m_oWriter.WriteString(std::wstring(L"")); + + if (pGroupElement->m_bChildAnchorEnabled || pGroupElement->m_bAnchorEnabled) + { std::wstring str; - - m_oWriter.WriteString(std::wstring(L"m_dRotate) - { - if (pGroupElement->m_bFlipH && pGroupElement->m_dRotate < 180) - pGroupElement->m_dRotate += 180; //Тікбұрышты үшбұрыштарды.ppt slide-7 - m_oWriter.WriteString(L" rot=\"" + std::to_wstring((int)(pGroupElement->m_dRotate * 60000)) + L"\""); - } - if (pGroupElement->m_bFlipH) - { - m_oWriter.WriteString(std::wstring(L" flipH=\"1\"")); - } - if (pGroupElement->m_bFlipV) - { - m_oWriter.WriteString(std::wstring(L" flipV=\"1\"")); - } - m_oWriter.WriteString(std::wstring(L">")); + m_oWriter.WriteString(std::wstring(L"m_dRotate) + { + if (pGroupElement->m_bFlipH && pGroupElement->m_dRotate < 180) + pGroupElement->m_dRotate += 180; //Тікбұрышты үшбұрыштарды.ppt slide-7 - m_oWriter.WriteString(L"m_bChildAnchorEnabled ? (int)pGroupElement->m_rcChildAnchor.left : (int)pGroupElement->m_rcAnchor.left) - + L"\" y=\"" + - std::to_wstring(pGroupElement->m_bChildAnchorEnabled ? (int)pGroupElement->m_rcChildAnchor.top : (int)pGroupElement->m_rcAnchor.top) + - L"\"/>"); + m_oWriter.WriteString(L" rot=\"" + std::to_wstring((int)(pGroupElement->m_dRotate * 60000)) + L"\""); + } + if (pGroupElement->m_bFlipH) + { + m_oWriter.WriteString(std::wstring(L" flipH=\"1\"")); + } + if (pGroupElement->m_bFlipV) + { + m_oWriter.WriteString(std::wstring(L" flipV=\"1\"")); + } + m_oWriter.WriteString(std::wstring(L">")); - double width = pGroupElement->m_bChildAnchorEnabled ? pGroupElement->m_rcChildAnchor.GetWidth() : pGroupElement->m_rcAnchor.GetWidth(); - double height = pGroupElement->m_bChildAnchorEnabled ? pGroupElement->m_rcChildAnchor.GetHeight() : pGroupElement->m_rcAnchor.GetHeight(); + m_oWriter.WriteString(L"m_bChildAnchorEnabled ? (int)pGroupElement->m_rcChildAnchor.left : (int)pGroupElement->m_rcAnchor.left) + + L"\" y=\"" + + std::to_wstring(pGroupElement->m_bChildAnchorEnabled ? (int)pGroupElement->m_rcChildAnchor.top : (int)pGroupElement->m_rcAnchor.top) + + L"\"/>"); - if ( width > 0 || height > 0 ) - { + double width = pGroupElement->m_bChildAnchorEnabled ? pGroupElement->m_rcChildAnchor.GetWidth() : pGroupElement->m_rcAnchor.GetWidth(); + double height = pGroupElement->m_bChildAnchorEnabled ? pGroupElement->m_rcChildAnchor.GetHeight() : pGroupElement->m_rcAnchor.GetHeight(); + + if ( width > 0 || height > 0 ) + { m_oWriter.WriteString(L""); - } + } - m_oWriter.WriteString(L"m_rcGroupAnchor.left) + - L"\" y=\"" + std::to_wstring((int)pGroupElement->m_rcGroupAnchor.top) + L"\"/>"); - m_oWriter.WriteString(L"m_rcGroupAnchor.GetWidth()) + - L"\" cy=\"" + std::to_wstring((int)pGroupElement->m_rcGroupAnchor.GetHeight()) + L"\"/>"); + m_oWriter.WriteString(L"m_rcGroupAnchor.left) + + L"\" y=\"" + std::to_wstring((int)pGroupElement->m_rcGroupAnchor.top) + L"\"/>"); + m_oWriter.WriteString(L"m_rcGroupAnchor.GetWidth()) + + L"\" cy=\"" + std::to_wstring((int)pGroupElement->m_rcGroupAnchor.GetHeight()) + L"\"/>"); - m_oWriter.WriteString(std::wstring(L"")); - } + m_oWriter.WriteString(std::wstring(L"")); + } - m_oWriter.WriteString(std::wstring(L"")); + m_oWriter.WriteString(std::wstring(L"")); - pGroupElement = NULL; + pGroupElement = NULL; - return m_oWriter.GetData(); + return m_oWriter.GetData(); } void PPT_FORMAT::CShapeWriter::WriteButton(int paragraphNum) @@ -1725,6 +1725,15 @@ void PPT_FORMAT::CShapeWriter::WriteButton(int paragraphNum) hlink.action = L"ppaction://noaction"; break; } + case II_MacroAction: + { + if (actions[i].m_macro.size()) + hlink.action = L"ppaction://macro?name=" + actions[i].m_macro; + else + hlink.action = L"ppaction://noaction"; + + break; + } case II_JumpAction: { std::wstring strJump(L"ppaction://hlinkshowjump?jump="); @@ -1767,19 +1776,27 @@ void PPT_FORMAT::CShapeWriter::WriteButton(int paragraphNum) } case II_HyperlinkAction: { - if (hlink.id.is_init()) - hlink.action = L"ppaction://hlinksldjump"; - else + if (actions[i].m_lHyperlinkType == 7) + { + if (hlink.id.is_init()) + hlink.action = L"ppaction://hlinksldjump"; + } + else if (actions[i].m_lHyperlinkType == 8) + hlink.action = L""; + + if (!hlink.action.is_init() || hlink.action->empty()) hlink.action = L"ppaction://noaction"; break; - }case 8: + } + case II_MediaAction: { - hlink.action = L"ppaction://noaction"; + + hlink.action = L"ppaction://media"; break; } default: hlink.action = L"ppaction://noaction"; - } + } m_oWriter.WriteString(hlink.toXML()); } @@ -1840,28 +1857,28 @@ std::wstring PPT_FORMAT::CShapeWriter::ConvertTable () std::wstring str; m_oWriter.WriteString(std::wstring(L"m_dRotate) - { - if (pGroupElement->m_bFlipH && pGroupElement->m_dRotate < 180) - pGroupElement->m_dRotate += 180; //Тікбұрышты үшбұрыштарды.ppt slide-7 + if (0 != pGroupElement->m_dRotate) + { + if (pGroupElement->m_bFlipH && pGroupElement->m_dRotate < 180) + pGroupElement->m_dRotate += 180; //Тікбұрышты үшбұрыштарды.ppt slide-7 - m_oWriter.WriteString(L" rot=\"" + std::to_wstring((int)(pGroupElement->m_dRotate * 60000)) + L"\""); - } - if (pGroupElement->m_bFlipH) - { - m_oWriter.WriteString(std::wstring(L" flipH=\"1\"")); - } - if (pGroupElement->m_bFlipV) - { - m_oWriter.WriteString(std::wstring(L" flipV=\"1\"")); - } + m_oWriter.WriteString(L" rot=\"" + std::to_wstring((int)(pGroupElement->m_dRotate * 60000)) + L"\""); + } + if (pGroupElement->m_bFlipH) + { + m_oWriter.WriteString(std::wstring(L" flipH=\"1\"")); + } + if (pGroupElement->m_bFlipV) + { + m_oWriter.WriteString(std::wstring(L" flipV=\"1\"")); + } m_oWriter.WriteString(std::wstring(L">")); m_oWriter.WriteString(L"m_bChildAnchorEnabled ? (int)pGroupElement->m_rcChildAnchor.left : (int)pGroupElement->m_rcAnchor.left) - + L"\" y=\"" + - std::to_wstring(pGroupElement->m_bChildAnchorEnabled ? (int)pGroupElement->m_rcChildAnchor.top : (int)pGroupElement->m_rcAnchor.top) + - L"\"/>"); + std::to_wstring(pGroupElement->m_bChildAnchorEnabled ? (int)pGroupElement->m_rcChildAnchor.left : (int)pGroupElement->m_rcAnchor.left) + + L"\" y=\"" + + std::to_wstring(pGroupElement->m_bChildAnchorEnabled ? (int)pGroupElement->m_rcChildAnchor.top : (int)pGroupElement->m_rcAnchor.top) + + L"\"/>"); double width = pGroupElement->m_bChildAnchorEnabled ? pGroupElement->m_rcChildAnchor.GetWidth() : pGroupElement->m_rcAnchor.GetWidth(); double height = pGroupElement->m_bChildAnchorEnabled ? pGroupElement->m_rcChildAnchor.GetHeight() : pGroupElement->m_rcAnchor.GetHeight(); @@ -1894,1102 +1911,1102 @@ std::wstring PPT_FORMAT::CShapeWriter::ConvertTableCells() std::wstring PPT_FORMAT::CShapeWriter::ConvertShape() { - CImageElement* pImageElement = dynamic_cast(m_pElement.get()); - CGroupElement* pGroupElement = dynamic_cast(m_pElement.get()); - CShapeElement* pShapeElement = dynamic_cast(m_pElement.get()); + CImageElement* pImageElement = dynamic_cast(m_pElement.get()); + CGroupElement* pGroupElement = dynamic_cast(m_pElement.get()); + CShapeElement* pShapeElement = dynamic_cast(m_pElement.get()); - if (pImageElement) return ConvertImage(); - if (pGroupElement) return ConvertGroup(); + if (pImageElement) return ConvertImage(); + if (pGroupElement) return ConvertGroup(); - if (pShapeElement == NULL) return _T(""); + if (pShapeElement == NULL) return _T(""); - std::wstring prstTxWarp; - std::wstring prstGeom = oox::Spt2ShapeType_mini((oox::MSOSPT)pShapeElement->m_lShapeType); -//rect, ellipse, line + std::wstring prstTxWarp; + std::wstring prstGeom = oox::Spt2ShapeType_mini((oox::MSOSPT)pShapeElement->m_lShapeType); + //rect, ellipse, line - if (prstGeom.empty()) - { - prstTxWarp = oox::Spt2WordArtShapeType((oox::MSOSPT)pShapeElement->m_lShapeType); - if (prstTxWarp.empty() == false) - { - m_bWordArt = true; - m_bTextBox = true; - prstGeom = L"rect"; - m_oBrush.Type = c_BrushTypeNoFill; - } - } - else - { - if (oox::msosptTextBox == (oox::MSOSPT)pShapeElement->m_lShapeType) - m_bTextBox = true; - if (oox::msosptLine == (oox::MSOSPT)pShapeElement->m_lShapeType) - pShapeElement->m_bLine = true; - } + if (prstGeom.empty()) + { + prstTxWarp = oox::Spt2WordArtShapeType((oox::MSOSPT)pShapeElement->m_lShapeType); + if (prstTxWarp.empty() == false) + { + m_bWordArt = true; + m_bTextBox = true; + prstGeom = L"rect"; + m_oBrush.Type = c_BrushTypeNoFill; + } + } + else + { + if (oox::msosptTextBox == (oox::MSOSPT)pShapeElement->m_lShapeType) + m_bTextBox = true; + if (oox::msosptLine == (oox::MSOSPT)pShapeElement->m_lShapeType) + pShapeElement->m_bLine = true; + } - if (pShapeElement->m_pShape && !pShapeElement->m_pShape->m_strXmlString.empty()) - { - ParseXmlAlternative(pShapeElement->m_pShape->m_strXmlString); - } + if (pShapeElement->m_pShape && !pShapeElement->m_pShape->m_strXmlString.empty()) + { + ParseXmlAlternative(pShapeElement->m_pShape->m_strXmlString); + } - m_oWriter.WriteString(std::wstring(L"")); + m_oWriter.WriteString(std::wstring(L"")); - WriteShapeInfo(); + WriteShapeInfo(); - CGeomShapeInfo oInfo; + CGeomShapeInfo oInfo; - oInfo.m_lOriginalWidth = m_pElement->m_bChildAnchorEnabled ? (LONG)m_pElement->m_rcChildAnchor.GetWidth() : (LONG)m_pElement->m_rcAnchor.GetWidth(); + oInfo.m_lOriginalWidth = m_pElement->m_bChildAnchorEnabled ? (LONG)m_pElement->m_rcChildAnchor.GetWidth() : (LONG)m_pElement->m_rcAnchor.GetWidth(); oInfo.m_lOriginalHeight = m_pElement->m_bChildAnchorEnabled ? (LONG)m_pElement->m_rcChildAnchor.GetHeight() : (LONG)m_pElement->m_rcAnchor.GetHeight(); - m_pElement->NormalizeCoordsByMetric(); - oInfo.SetBounds(m_pElement->m_bChildAnchorEnabled ? m_pElement->m_rcChildAnchor : m_pElement->m_rcAnchor); - - oInfo.m_dRotate = pShapeElement->m_dRotate; - oInfo.m_bFlipH = pShapeElement->m_bFlipH; - oInfo.m_bFlipV = pShapeElement->m_bFlipV; + m_pElement->NormalizeCoordsByMetric(); + oInfo.SetBounds(m_pElement->m_bChildAnchorEnabled ? m_pElement->m_rcChildAnchor : m_pElement->m_rcAnchor); - m_oWriter.WriteString(std::wstring(L"")); + oInfo.m_dRotate = pShapeElement->m_dRotate; + oInfo.m_bFlipH = pShapeElement->m_bFlipH; + oInfo.m_bFlipV = pShapeElement->m_bFlipV; - if (pShapeElement->m_bChildAnchorEnabled || pShapeElement->m_bAnchorEnabled) - { + m_oWriter.WriteString(std::wstring(L"")); + + if (pShapeElement->m_bChildAnchorEnabled || pShapeElement->m_bAnchorEnabled) + { std::wstring str; - - m_oWriter.WriteString(std::wstring(L"m_dRotate) - { - if (pShapeElement->m_bFlipH && pShapeElement->m_dRotate < 180) - pShapeElement->m_dRotate += 180; //Тікбұрышты үшбұрыштарды.ppt slide-7 - m_oWriter.WriteString(L" rot=\"" + std::to_wstring((int)(pShapeElement->m_dRotate * 60000)) + L"\""); - } - if (pShapeElement->m_bFlipH) - { - m_oWriter.WriteString(std::wstring(L" flipH=\"1\"")); - } - if (pShapeElement->m_bFlipV) - { - m_oWriter.WriteString(std::wstring(L" flipV=\"1\"")); - } - m_oWriter.WriteString(std::wstring(L">")); + m_oWriter.WriteString(std::wstring(L"m_dRotate) + { + if (pShapeElement->m_bFlipH && pShapeElement->m_dRotate < 180) + pShapeElement->m_dRotate += 180; //Тікбұрышты үшбұрыштарды.ppt slide-7 - m_oWriter.WriteString(L"m_bChildAnchorEnabled ? (int)pShapeElement->m_rcChildAnchor.left : (int)pShapeElement->m_rcAnchor.left) - + L"\" y=\"" + - std::to_wstring(pShapeElement->m_bChildAnchorEnabled ? (int)pShapeElement->m_rcChildAnchor.top : (int)pShapeElement->m_rcAnchor.top) + - L"\"/>"); + m_oWriter.WriteString(L" rot=\"" + std::to_wstring((int)(pShapeElement->m_dRotate * 60000)) + L"\""); + } + if (pShapeElement->m_bFlipH) + { + m_oWriter.WriteString(std::wstring(L" flipH=\"1\"")); + } + if (pShapeElement->m_bFlipV) + { + m_oWriter.WriteString(std::wstring(L" flipV=\"1\"")); + } + m_oWriter.WriteString(std::wstring(L">")); - double width = pShapeElement->m_bChildAnchorEnabled ? pShapeElement->m_rcChildAnchor.GetWidth() : pShapeElement->m_rcAnchor.GetWidth(); - double height = pShapeElement->m_bChildAnchorEnabled ? pShapeElement->m_rcChildAnchor.GetHeight() : pShapeElement->m_rcAnchor.GetHeight(); + m_oWriter.WriteString(L"m_bChildAnchorEnabled ? (int)pShapeElement->m_rcChildAnchor.left : (int)pShapeElement->m_rcAnchor.left) + + L"\" y=\"" + + std::to_wstring(pShapeElement->m_bChildAnchorEnabled ? (int)pShapeElement->m_rcChildAnchor.top : (int)pShapeElement->m_rcAnchor.top) + + L"\"/>"); - if ( width > 0 || height > 0 ) - { + double width = pShapeElement->m_bChildAnchorEnabled ? pShapeElement->m_rcChildAnchor.GetWidth() : pShapeElement->m_rcAnchor.GetWidth(); + double height = pShapeElement->m_bChildAnchorEnabled ? pShapeElement->m_rcChildAnchor.GetHeight() : pShapeElement->m_rcAnchor.GetHeight(); + + if ( width > 0 || height > 0 ) + { m_oWriter.WriteString(L""); - } - m_oWriter.WriteString(std::wstring(L"")); - } + } + m_oWriter.WriteString(std::wstring(L"")); + } CBaseShapePtr shape = pShapeElement->m_pShape->getBaseShape(); - if (pShapeElement->m_pShape->m_lDrawType & c_ShapeDrawType_Graphic || shape->m_bCustomShape) - { - pShapeElement->m_pShape->ToRenderer(dynamic_cast(this), oInfo, 0.0, 1.0); - } + if (pShapeElement->m_pShape->m_lDrawType & c_ShapeDrawType_Graphic || shape->m_bCustomShape) + { + pShapeElement->m_pShape->ToRenderer(dynamic_cast(this), oInfo, 0.0, 1.0); + } - if (!m_xmlGeomAlternative.empty()) - { - m_oWriter.WriteString(m_xmlGeomAlternative); - } - else - { - if ((prstGeom.empty() == false || pShapeElement->m_bShapePreset) && prstTxWarp.empty() && !shape->m_bCustomShape) - { - if (prstGeom.empty()) prstGeom = L"rect"; - m_oWriter.WriteString(std::wstring(L"")); - if (!m_bWordArt) - { - m_oWriter.WriteString(std::wstring(L"")); - } - } - m_oWriter.WriteString(std::wstring(L"")); - } - else if (prstTxWarp.empty()) - { - m_oWriter.WriteString(pShapeElement->ConvertPPTShapeToPPTX()); - } - else - { - //word art - m_oWriter.WriteString(std::wstring(L"")); - } - } + if (!m_xmlGeomAlternative.empty()) + { + m_oWriter.WriteString(m_xmlGeomAlternative); + } + else + { + if ((prstGeom.empty() == false || pShapeElement->m_bShapePreset) && prstTxWarp.empty() && !shape->m_bCustomShape) + { + if (prstGeom.empty()) prstGeom = L"rect"; + m_oWriter.WriteString(std::wstring(L"")); + if (!m_bWordArt) + { + m_oWriter.WriteString(std::wstring(L"")); + } + } + m_oWriter.WriteString(std::wstring(L"")); + } + else if (prstTxWarp.empty()) + { + m_oWriter.WriteString(pShapeElement->ConvertPPTShapeToPPTX()); + } + else + { + //word art + m_oWriter.WriteString(std::wstring(L"")); + } + } - if (!m_bWordArt) - { - m_oWriter.WriteString(ConvertBrush(pShapeElement->m_oBrush)); - if (pShapeElement->m_bLine) - { - m_oWriter.WriteString(ConvertLine(pShapeElement->m_oPen)); - } - m_oWriter.WriteString(ConvertShadow(pShapeElement->m_oShadow)); - } - Write3dShape(); + if (!m_bWordArt) + { + m_oWriter.WriteString(ConvertBrush(pShapeElement->m_oBrush)); + if (pShapeElement->m_bLine) + { + m_oWriter.WriteString(ConvertLine(pShapeElement->m_oPen)); + } + m_oWriter.WriteString(ConvertShadow(pShapeElement->m_oShadow)); + } + Write3dShape(); - m_oWriter.WriteString(std::wstring(L"")); + m_oWriter.WriteString(std::wstring(L"")); - WriteTextInfo(); - m_oWriter.WriteString(std::wstring(L"")); + WriteTextInfo(); + m_oWriter.WriteString(std::wstring(L"")); - pShapeElement = NULL; + pShapeElement = NULL; - return m_oWriter.GetData(); + return m_oWriter.GetData(); } void PPT_FORMAT::CShapeWriter::ParseXmlAlternative(const std::wstring & xml) { - XmlUtils::CXmlLiteReader oReader; + XmlUtils::CXmlLiteReader oReader; - if ( !oReader.FromString( xml ) ) - return; - if ( !oReader.ReadNextNode() ) - return; + if ( !oReader.FromString( xml ) ) + return; + if ( !oReader.ReadNextNode() ) + return; - std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName()); + std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName()); - nullable oElement; + nullable oElement; - if ( L"graphicFrame" == sName || L"pic" == sName || L"sp" == sName || L"grpSp" == sName || L"cxnSp" == sName || L"AlternateContent" == sName - || L"spTree" ) - { - oElement = oReader; - } + if ( L"graphicFrame" == sName || L"pic" == sName || L"sp" == sName || L"grpSp" == sName || L"cxnSp" == sName || L"AlternateContent" == sName + || L"spTree" ) + { + oElement = oReader; + } - if (oElement.IsInit()) - { - smart_ptr shape = oElement->GetElem().smart_dynamic_cast(); - if (shape.IsInit()) - { - NSBinPptxRW::CXmlWriter writer(XMLWRITER_DOC_TYPE_PPTX); - shape->spPr.Geometry.toXmlWriter(&writer); + if (oElement.IsInit()) + { + smart_ptr shape = oElement->GetElem().smart_dynamic_cast(); + if (shape.IsInit()) + { + NSBinPptxRW::CXmlWriter writer(XMLWRITER_DOC_TYPE_PPTX); + shape->spPr.Geometry.toXmlWriter(&writer); - if (shape->spPr.scene3d.IsInit()) - shape->spPr.scene3d->toXmlWriter(&writer); - - if (shape->spPr.sp3d.IsInit()) - shape->spPr.sp3d->toXmlWriter(&writer); + if (shape->spPr.scene3d.IsInit()) + shape->spPr.scene3d->toXmlWriter(&writer); - m_xmlGeomAlternative = writer.GetXmlString(); + if (shape->spPr.sp3d.IsInit()) + shape->spPr.sp3d->toXmlWriter(&writer); - writer.ClearNoAttack(); - if ((shape->txBody.IsInit()) && (shape->txBody->bodyPr.IsInit()) && (shape->txBody->bodyPr->prstTxWarp.IsInit())) - {//только WordArt - shape->txBody->toXmlWriter(&writer); - m_xmlTxBodyAlternative = writer.GetXmlString(); - } - } - smart_ptr groupShape = oElement->GetElem().smart_dynamic_cast(); - if (groupShape.IsInit()) - {//smartArt - NSBinPptxRW::CXmlWriter writer(XMLWRITER_DOC_TYPE_PPTX); - groupShape->toXmlWriter(&writer); + m_xmlGeomAlternative = writer.GetXmlString(); - m_xmlAlternative = writer.GetXmlString(); - } - } + writer.ClearNoAttack(); + if ((shape->txBody.IsInit()) && (shape->txBody->bodyPr.IsInit()) && (shape->txBody->bodyPr->prstTxWarp.IsInit())) + {//только WordArt + shape->txBody->toXmlWriter(&writer); + m_xmlTxBodyAlternative = writer.GetXmlString(); + } + } + smart_ptr groupShape = oElement->GetElem().smart_dynamic_cast(); + if (groupShape.IsInit()) + {//smartArt + NSBinPptxRW::CXmlWriter writer(XMLWRITER_DOC_TYPE_PPTX); + groupShape->toXmlWriter(&writer); + + m_xmlAlternative = writer.GetXmlString(); + } + } } std::wstring PPT_FORMAT::CShapeWriter::ConvertImage() { - CImageElement* pImageElement = dynamic_cast(m_pElement.get()); - if (!pImageElement) return L""; + CImageElement* pImageElement = dynamic_cast(m_pElement.get()); + if (!pImageElement) return L""; - if (pImageElement->m_bImagePresent == false) - { - if (pImageElement->m_sName.empty()) return _T(""); - //ppt_presentation.ppt - ссылка на файл на диске + if (pImageElement->m_bImagePresent == false) + { + if (pImageElement->m_sName.empty()) return _T(""); + //ppt_presentation.ppt - ссылка на файл на диске - pImageElement->m_strImageFileName.clear(); - pImageElement->m_bImagePresent = true; - } + pImageElement->m_strImageFileName.clear(); + pImageElement->m_bImagePresent = true; + } std::wstring strRid; - if (!pImageElement->m_strImageFileName.empty()) - { - strRid = m_pRels->WriteImage(pImageElement->m_strImageFileName); - } - else if (!pImageElement->m_sImageName.empty()) - { - strRid = m_pRels->WriteHyperlinkImage(CorrectXmlString3(pImageElement->m_sImageName)); - } - - if (strRid.empty()) return _T(""); + if (!pImageElement->m_strImageFileName.empty()) + { + strRid = m_pRels->WriteImage(pImageElement->m_strImageFileName); + } + else if (!pImageElement->m_sImageName.empty()) + { + strRid = m_pRels->WriteHyperlinkImage(CorrectXmlString3(pImageElement->m_sImageName)); + } - m_oWriter.WriteString(std::wstring(L"")); + if (strRid.empty()) return _T(""); - WriteImageInfo(); + m_oWriter.WriteString(std::wstring(L"")); - CGeomShapeInfo oInfo; + WriteImageInfo(); - oInfo.m_lOriginalWidth = m_pElement->m_bChildAnchorEnabled ? (LONG)m_pElement->m_rcChildAnchor.GetWidth() : (LONG)m_pElement->m_rcAnchor.GetWidth(); + CGeomShapeInfo oInfo; + + oInfo.m_lOriginalWidth = m_pElement->m_bChildAnchorEnabled ? (LONG)m_pElement->m_rcChildAnchor.GetWidth() : (LONG)m_pElement->m_rcAnchor.GetWidth(); oInfo.m_lOriginalHeight = m_pElement->m_bChildAnchorEnabled ? (LONG)m_pElement->m_rcChildAnchor.GetHeight() : (LONG)m_pElement->m_rcAnchor.GetHeight(); - m_pElement->NormalizeCoordsByMetric(); - oInfo.SetBounds(m_pElement->m_bChildAnchorEnabled ? m_pElement->m_rcChildAnchor : m_pElement->m_rcAnchor); - - oInfo.m_dRotate = pImageElement->m_dRotate; - oInfo.m_bFlipH = pImageElement->m_bFlipH; - oInfo.m_bFlipV = pImageElement->m_bFlipV; + m_pElement->NormalizeCoordsByMetric(); + oInfo.SetBounds(m_pElement->m_bChildAnchorEnabled ? m_pElement->m_rcChildAnchor : m_pElement->m_rcAnchor); - m_oWriter.WriteString(std::wstring(L"")); - - std::wstring strWrite = _T(""); - m_oWriter.WriteString(strWrite); + oInfo.m_dRotate = pImageElement->m_dRotate; + oInfo.m_bFlipH = pImageElement->m_bFlipH; + oInfo.m_bFlipV = pImageElement->m_bFlipV; - m_oWriter.WriteString(std::wstring(L"m_bCropEnabled) - {//124-125 Q3 V2 Win File 3.ppt - m_oWriter.WriteString(L" l=\"" + std::to_wstring((_INT64)(pImageElement->m_lcropFromLeft *1.5)) + L"\""); - m_oWriter.WriteString(L" t=\"" + std::to_wstring((_INT64)(pImageElement->m_lcropFromTop *1.5)) + L"\""); - m_oWriter.WriteString(L" r=\"" + std::to_wstring((_INT64)(pImageElement->m_lcropFromRight *1.5)) + L"\""); - m_oWriter.WriteString(L" b=\"" + std::to_wstring((_INT64)(pImageElement->m_lcropFromBottom*1.5)) + L"\""); - } - m_oWriter.WriteString(std::wstring(L"/>")); - - if (pImageElement->m_bTile) - { - m_oWriter.WriteString(std::wstring(L"")); - } - else if (pImageElement->m_bStretch) - { - m_oWriter.WriteString(std::wstring(L"")); - } + m_oWriter.WriteString(std::wstring(L"")); - m_oWriter.WriteString(std::wstring(L"")); + std::wstring strWrite = _T(""); + m_oWriter.WriteString(strWrite); - m_oWriter.WriteString(std::wstring(L"")); + m_oWriter.WriteString(std::wstring(L"m_bCropEnabled) + {//124-125 Q3 V2 Win File 3.ppt + m_oWriter.WriteString(L" l=\"" + std::to_wstring((_INT64)(pImageElement->m_lcropFromLeft *1.5)) + L"\""); + m_oWriter.WriteString(L" t=\"" + std::to_wstring((_INT64)(pImageElement->m_lcropFromTop *1.5)) + L"\""); + m_oWriter.WriteString(L" r=\"" + std::to_wstring((_INT64)(pImageElement->m_lcropFromRight *1.5)) + L"\""); + m_oWriter.WriteString(L" b=\"" + std::to_wstring((_INT64)(pImageElement->m_lcropFromBottom*1.5)) + L"\""); + } + m_oWriter.WriteString(std::wstring(L"/>")); - if (pImageElement->m_bChildAnchorEnabled || pImageElement->m_bAnchorEnabled) - { + if (pImageElement->m_bTile) + { + m_oWriter.WriteString(std::wstring(L"")); + } + else if (pImageElement->m_bStretch) + { + m_oWriter.WriteString(std::wstring(L"")); + } + + m_oWriter.WriteString(std::wstring(L"")); + + m_oWriter.WriteString(std::wstring(L"")); + + if (pImageElement->m_bChildAnchorEnabled || pImageElement->m_bAnchorEnabled) + { std::wstring str; - - m_oWriter.WriteString(std::wstring(L"m_dRotate) - { - m_oWriter.WriteString(L" rot=\"" + std::to_wstring((int)(pImageElement->m_dRotate * 60000)) + L"\""); - } - if (pImageElement->m_bFlipH) - { - m_oWriter.WriteString(std::wstring(L" flipH=\"1\"")); - } - if (pImageElement->m_bFlipV) - { - m_oWriter.WriteString(std::wstring(L" flipV=\"1\"")); - } - m_oWriter.WriteString(std::wstring(L">")); - m_oWriter.WriteString(L"m_bChildAnchorEnabled ? (int)pImageElement->m_rcChildAnchor.left : (int)pImageElement->m_rcAnchor.left) - + L"\" y=\"" + - std::to_wstring(pImageElement->m_bChildAnchorEnabled ? (int)pImageElement->m_rcChildAnchor.top : (int)pImageElement->m_rcAnchor.top) + - L"\"/>"); + m_oWriter.WriteString(std::wstring(L"m_dRotate) + { + m_oWriter.WriteString(L" rot=\"" + std::to_wstring((int)(pImageElement->m_dRotate * 60000)) + L"\""); + } + if (pImageElement->m_bFlipH) + { + m_oWriter.WriteString(std::wstring(L" flipH=\"1\"")); + } + if (pImageElement->m_bFlipV) + { + m_oWriter.WriteString(std::wstring(L" flipV=\"1\"")); + } + m_oWriter.WriteString(std::wstring(L">")); - double width = pImageElement->m_bChildAnchorEnabled ? pImageElement->m_rcChildAnchor.GetWidth() : pImageElement->m_rcAnchor.GetWidth(); - double height = pImageElement->m_bChildAnchorEnabled ? pImageElement->m_rcChildAnchor.GetHeight() : pImageElement->m_rcAnchor.GetHeight(); - - if ( width > 0 || height > 0 ) - { + m_oWriter.WriteString(L"m_bChildAnchorEnabled ? (int)pImageElement->m_rcChildAnchor.left : (int)pImageElement->m_rcAnchor.left) + + L"\" y=\"" + + std::to_wstring(pImageElement->m_bChildAnchorEnabled ? (int)pImageElement->m_rcChildAnchor.top : (int)pImageElement->m_rcAnchor.top) + + L"\"/>"); + + double width = pImageElement->m_bChildAnchorEnabled ? pImageElement->m_rcChildAnchor.GetWidth() : pImageElement->m_rcAnchor.GetWidth(); + double height = pImageElement->m_bChildAnchorEnabled ? pImageElement->m_rcChildAnchor.GetHeight() : pImageElement->m_rcAnchor.GetHeight(); + + if ( width > 0 || height > 0 ) + { m_oWriter.WriteString(L""); - } - m_oWriter.WriteString(std::wstring(L"")); - } - m_oWriter.WriteString(std::wstring(L"")); + } + m_oWriter.WriteString(std::wstring(L"")); + } + m_oWriter.WriteString(std::wstring(L"")); - m_oWriter.WriteString(ConvertBrush(pImageElement->m_oBrush)); + m_oWriter.WriteString(ConvertBrush(pImageElement->m_oBrush)); - if (pImageElement->m_bLine) - { - m_oWriter.WriteString(ConvertLine(pImageElement->m_oPen)); - } + if (pImageElement->m_bLine) + { + m_oWriter.WriteString(ConvertLine(pImageElement->m_oPen)); + } - m_oWriter.WriteString(std::wstring(L"")); + m_oWriter.WriteString(std::wstring(L"")); - m_oWriter.WriteString(std::wstring(L"")); - - pImageElement = NULL; - return m_oWriter.GetData(); + m_oWriter.WriteString(std::wstring(L"")); + + pImageElement = NULL; + return m_oWriter.GetData(); } HRESULT PPT_FORMAT::CShapeWriter::get_Type(LONG* lType) { - if (NULL == lType) + if (NULL == lType) return S_FALSE; - *lType = c_nSVGConverter; - return S_OK; + *lType = c_nSVGConverter; + return S_OK; } //-------- Функции для работы со страницей -------------------------------------------------- HRESULT PPT_FORMAT::CShapeWriter::NewPage() { - return S_OK; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_Height(double* dHeight) { - return S_OK; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_Height(const double& dHeight) { - return S_OK; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_Width(double* dWidth) { - return S_OK; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_Width(const double& dWidth) { - return S_OK; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_DpiX(double* dDpiX) { - return S_OK; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_DpiY(double* dDpiY) { - return S_OK; + return S_OK; } // pen -------------------------------------------------------------------------------------- HRESULT PPT_FORMAT::CShapeWriter::SetPen(std::wstring bsXML) { //m_oPen.FromXmlString((std::wstring)bsXML); - return S_OK; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_PenColor(LONG* lColor) { - *lColor = m_oPen.Color.GetLONG(); - return S_OK; + *lColor = m_oPen.Color.GetLONG(); + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_PenColor(const LONG& lColor) { - BYTE lScheme = ((_UINT32)(lColor)) >> 24; + BYTE lScheme = ((_UINT32)(lColor)) >> 24; - if (0xFF != lScheme) - m_oPen.Color.SetBGR(lColor); - return S_OK; + if (0xFF != lScheme) + m_oPen.Color.SetBGR(lColor); + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_PenAlpha(LONG* lAlpha) { - *lAlpha = m_oPen.Alpha; - return S_OK; + *lAlpha = m_oPen.Alpha; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_PenAlpha(const LONG& lAlpha) { - m_oPen.Alpha = lAlpha; - return S_OK; + m_oPen.Alpha = lAlpha; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_PenSize(double* dSize) { - *dSize = m_oPen.Size; - return S_OK; + *dSize = m_oPen.Size; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_PenSize(const double& dSize) { - m_oPen.Size = (long)(dSize * 25.4 / 96.0); - return S_OK; + m_oPen.Size = (long)(dSize * 25.4 / 96.0); + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_PenDashStyle(BYTE* val) { - *val = m_oPen.DashStyle; - return S_OK; + *val = m_oPen.DashStyle; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_PenDashStyle(const BYTE& val) { - m_oPen.DashStyle = val; - return S_OK; + m_oPen.DashStyle = val; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_PenLineStartCap(BYTE* val) { - *val = m_oPen.LineStartCap; - return S_OK; + *val = m_oPen.LineStartCap; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_PenLineStartCap(const BYTE& val) { - m_oPen.LineStartCap = val; - return S_OK; + m_oPen.LineStartCap = val; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_PenLineEndCap(BYTE* val) { - *val = m_oPen.LineEndCap; - return S_OK; + *val = m_oPen.LineEndCap; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_PenLineEndCap(const BYTE& val) { - m_oPen.LineEndCap = val; - return S_OK; + m_oPen.LineEndCap = val; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_PenLineJoin(BYTE* val) { - *val = m_oPen.LineJoin; - return S_OK; + *val = m_oPen.LineJoin; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_PenLineJoin(const BYTE& val) { - m_oPen.LineJoin = val; - return S_OK; + m_oPen.LineJoin = val; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_PenDashOffset(double* val) { - *val = m_oPen.DashOffset; - return S_OK; + *val = m_oPen.DashOffset; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_PenDashOffset(const double& val) { - m_oPen.DashOffset = val; - return S_OK; + m_oPen.DashOffset = val; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_PenAlign(LONG* val) { - *val = m_oPen.Align; - return S_OK; + *val = m_oPen.Align; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_PenAlign(const LONG& val) { - m_oPen.Align = val; - return S_OK; + m_oPen.Align = val; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_PenMiterLimit(double* val) { - *val = m_oPen.MiterLimit; - return S_OK; + *val = m_oPen.MiterLimit; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_PenMiterLimit(const double& val) { - m_oPen.MiterLimit = val; - return S_OK; + m_oPen.MiterLimit = val; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::PenDashPattern(double* pPattern, LONG lCount) { - if (NULL != pPattern) - { - m_oPen.SetDashPattern(pPattern, lCount); - } + if (NULL != pPattern) + { + m_oPen.SetDashPattern(pPattern, lCount); + } - return S_OK; + return S_OK; } // brush ------------------------------------------------------------------------------------ HRESULT PPT_FORMAT::CShapeWriter::SetBrush(std::wstring bsXML) { //m_oBrush.FromXmlString((std::wstring)bsXML); - return S_OK; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_BrushType(LONG* lType) { - *lType = m_oBrush.Type; - return S_OK; + *lType = m_oBrush.Type; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_BrushType(const LONG& lType) { - m_oBrush.Type = lType; - return S_OK; + m_oBrush.Type = lType; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_BrushColor1(LONG* lColor) { - *lColor = m_oBrush.Color1.GetLONG(); - return S_OK; + *lColor = m_oBrush.Color1.GetLONG(); + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_BrushColor1(const LONG& lColor) { - BYTE lScheme = ((_UINT32)(lColor)) >> 24; + BYTE lScheme = ((_UINT32)(lColor)) >> 24; - if (0xFF != lScheme) - m_oBrush.Color1.SetBGR(lColor); - return S_OK; + if (0xFF != lScheme) + m_oBrush.Color1.SetBGR(lColor); + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_BrushAlpha1(LONG* lAlpha) { - *lAlpha = m_oBrush.Alpha1; - return S_OK; + *lAlpha = m_oBrush.Alpha1; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_BrushAlpha1(const LONG& lAlpha) { - m_oBrush.Alpha1 = lAlpha; - return S_OK; + m_oBrush.Alpha1 = lAlpha; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_BrushColor2(LONG* lColor) { - *lColor = m_oBrush.Color2.GetLONG(); - return S_OK; + *lColor = m_oBrush.Color2.GetLONG(); + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_BrushColor2(const LONG& lColor) { - m_oBrush.Color2.SetBGR(lColor); - return S_OK; + m_oBrush.Color2.SetBGR(lColor); + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_BrushAlpha2(LONG* lAlpha) { - *lAlpha = m_oBrush.Alpha2; - return S_OK; + *lAlpha = m_oBrush.Alpha2; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_BrushAlpha2(const LONG& lAlpha) { - m_oBrush.Alpha2 = lAlpha; - return S_OK; + m_oBrush.Alpha2 = lAlpha; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_BrushTexturePath(std::wstring* bsPath) { - if (bsPath == NULL) return S_OK; - *bsPath = m_oBrush.TexturePath; - return S_OK; + if (bsPath == NULL) return S_OK; + *bsPath = m_oBrush.TexturePath; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_BrushTexturePath(const std::wstring& bsPath) { - m_oBrush.TexturePath = bsPath; - return S_OK; + m_oBrush.TexturePath = bsPath; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_BrushTextureMode(LONG* lMode) { - *lMode = m_oBrush.TextureMode; - return S_OK; + *lMode = m_oBrush.TextureMode; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_BrushTextureMode(const LONG& lMode) { - m_oBrush.TextureMode = lMode; - return S_OK; + m_oBrush.TextureMode = lMode; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_BrushTextureAlpha(LONG* lTxAlpha) { - *lTxAlpha = m_oBrush.TextureAlpha; - return S_OK; + *lTxAlpha = m_oBrush.TextureAlpha; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_BrushTextureAlpha(const LONG& lTxAlpha) { - m_oBrush.TextureAlpha = lTxAlpha; - return S_OK; + m_oBrush.TextureAlpha = lTxAlpha; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_BrushLinearAngle(double* dAngle) { - *dAngle = m_oBrush.LinearAngle; - return S_OK; + *dAngle = m_oBrush.LinearAngle; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_BrushLinearAngle(const double& dAngle) { - m_oBrush.LinearAngle = dAngle; - return S_OK; + m_oBrush.LinearAngle = dAngle; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::BrushRect(const INT& val, const double& left, const double& top, const double& width, const double& height) { - m_oBrush.Rectable = val; - m_oBrush.Rect.X = (float)left; - m_oBrush.Rect.Y = (float)top; - m_oBrush.Rect.Width = (float)width; - m_oBrush.Rect.Height = (float)height; + m_oBrush.Rectable = val; + m_oBrush.Rect.X = (float)left; + m_oBrush.Rect.Y = (float)top; + m_oBrush.Rect.Width = (float)width; + m_oBrush.Rect.Height = (float)height; - return S_OK; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::BrushBounds(const double& left, const double& top, const double& width, const double& height) { - return S_OK; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_BrushGradientColors(LONG* lColors, double* pPositions, LONG nCount) { - return S_OK; + return S_OK; } // font ------------------------------------------------------------------------------------- HRESULT PPT_FORMAT::CShapeWriter::SetFont(std::wstring bsXML) { //m_oFont.FromXmlString((std::wstring)bsXML); - return S_OK; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_FontName(std::wstring* bsName) { - if (bsName == NULL) return S_OK; - *bsName = m_oFont.Name; - return S_OK; + if (bsName == NULL) return S_OK; + *bsName = m_oFont.Name; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_FontName(const std::wstring& bsName) { - m_oFont.Name = bsName; - return S_OK; + m_oFont.Name = bsName; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_FontPath(std::wstring* bsName) { - if (bsName == NULL) return S_OK; - *bsName = m_oFont.Path; - return S_OK; + if (bsName == NULL) return S_OK; + *bsName = m_oFont.Path; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_FontPath(const std::wstring& bsName) { - m_oFont.Path = bsName; - return S_OK; + m_oFont.Path = bsName; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_FontSize(double* dSize) { - *dSize = m_oFont.Size; - return S_OK; + *dSize = m_oFont.Size; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_FontSize(const double& dSize) { - m_oFont.Size = dSize; - return S_OK; + m_oFont.Size = dSize; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_FontStyle(LONG* lStyle) { - *lStyle = m_oFont.GetStyle(); - return S_OK; + *lStyle = m_oFont.GetStyle(); + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_FontStyle(const LONG& lStyle) { - m_oFont.SetStyle(lStyle); - return S_OK; + m_oFont.SetStyle(lStyle); + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_FontStringGID(INT* bGID) { - *bGID = m_oFont.StringGID; - return S_OK; + *bGID = m_oFont.StringGID; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_FontStringGID(const INT& bGID) { - m_oFont.StringGID = bGID; - m_pFontManager->SetStringGID(bGID); - return S_OK; + m_oFont.StringGID = bGID; + m_pFontManager->SetStringGID(bGID); + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_FontCharSpace(double* dSpace) { - *dSpace = m_oFont.CharSpace; - return S_OK; + *dSpace = m_oFont.CharSpace; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_FontCharSpace(const double& dSpace) { - m_oFont.CharSpace = dSpace; - return S_OK; + m_oFont.CharSpace = dSpace; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_FontFaceIndex(int* lFaceIndex) { - return S_OK; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_FontFaceIndex(const int& lFaceIndex) { - return S_OK; + return S_OK; } // shadow ----------------------------------------------------------------------------------- HRESULT PPT_FORMAT::CShapeWriter::SetShadow(std::wstring bsXML) { //m_oShadow.FromXmlString((std::wstring)bsXML); - return S_OK; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_ShadowDistanceX(double* val) { - *val = m_oShadow.DistanceX; - return S_OK; + *val = m_oShadow.DistanceX; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_ShadowDistanceX(double val) { - m_oShadow.DistanceX = val; - return S_OK; + m_oShadow.DistanceX = val; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_ShadowDistanceY(double* val) { - *val = m_oShadow.DistanceY; - return S_OK; + *val = m_oShadow.DistanceY; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_ShadowDistanceY(double val) { - m_oShadow.DistanceY = val; - return S_OK; + m_oShadow.DistanceY = val; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_ShadowBlurSize(double* val) { - *val = m_oShadow.BlurSize; - return S_OK; + *val = m_oShadow.BlurSize; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_ShadowBlurSize(double val) { - m_oShadow.BlurSize = val; - return S_OK; + m_oShadow.BlurSize = val; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_ShadowColor(LONG* val) { - *val = m_oShadow.Color.GetLONG(); - return S_OK; + *val = m_oShadow.Color.GetLONG(); + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_ShadowColor(LONG val) { - m_oShadow.Color.SetBGR(val); - return S_OK; + m_oShadow.Color.SetBGR(val); + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_ShadowAlpha(LONG* val) { - *val = m_oShadow.Alpha; - return S_OK; + *val = m_oShadow.Alpha; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_ShadowAlpha(LONG val) { - m_oShadow.Alpha = val; - return S_OK; + m_oShadow.Alpha = val; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_ShadowVisible(bool* val) { - *val = m_oShadow.Visible; - return S_OK; + *val = m_oShadow.Visible; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_ShadowVisible(bool val) { - m_oShadow.Visible = val; - return S_OK; + m_oShadow.Visible = val; + return S_OK; } // edge ------------------------------------------------------------------------------------- HRESULT PPT_FORMAT::CShapeWriter::SetEdgeText(std::wstring bsXML) { //m_oEdge.FromXmlString((std::wstring)bsXML); - return S_OK; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_EdgeVisible(LONG* val) { - *val = m_oEdge.Visible; - return S_OK; + *val = m_oEdge.Visible; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_EdgeVisible(LONG val) { - m_oEdge.Visible = val; - return S_OK; + m_oEdge.Visible = val; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_EdgeColor(LONG* val) { - *val = m_oEdge.Color.GetLONG(); - return S_OK; + *val = m_oEdge.Color.GetLONG(); + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_EdgeColor(LONG val) { - m_oEdge.Color.SetBGR(val); - return S_OK; + m_oEdge.Color.SetBGR(val); + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_EdgeAlpha(LONG* val) { - *val = m_oEdge.Alpha; - return S_OK; + *val = m_oEdge.Alpha; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_EdgeAlpha(LONG val) { - m_oEdge.Alpha = val; - return S_OK; + m_oEdge.Alpha = val; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::get_EdgeDist(double* val) { - *val = m_oEdge.Dist; - return S_OK; + *val = m_oEdge.Dist; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_EdgeDist(double val) { - m_oEdge.Dist = val; - return S_OK; + m_oEdge.Dist = val; + return S_OK; } //-------- Функции для вывода текста -------------------------------------------------------- HRESULT PPT_FORMAT::CShapeWriter::CommandDrawText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h) { - if (c_nHyperlinkType == m_lCurrentCommandType) - return S_OK; + if (c_nHyperlinkType == m_lCurrentCommandType) + return S_OK; if (true) - { - PathCommandEnd(); - BeginCommand(c_nPathType); - PathCommandText(bsText, x, y, w, h); - DrawPath(c_nWindingFillMode); - EndCommand(c_nPathType); - PathCommandEnd(); - return S_OK; - } + { + PathCommandEnd(); + BeginCommand(c_nPathType); + PathCommandText(bsText, x, y, w, h); + DrawPath(c_nWindingFillMode); + EndCommand(c_nPathType); + PathCommandEnd(); + return S_OK; + } - return S_OK; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::CommandDrawTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h) { - return S_OK; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::CommandDrawTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h) { - return S_OK; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::PathCommandTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h) { - return S_OK; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::PathCommandTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h) { - return S_OK; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::CommandLong(const LONG& lType, const LONG& lCommand) { - return S_OK; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::CommandDouble(const LONG& lType, const double& dCommand) { - return S_OK; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::CommandString(const LONG& lType, const std::wstring& sCommand) { - return S_OK; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::CommandDrawTextEx(const std::wstring& bsUnicodeText, const unsigned int* pGids, const unsigned int nGidsCount, const double& x, const double& y, const double& w, const double& h) { if (true) - { - PathCommandEnd(); - BeginCommand(c_nPathType); - PathCommandTextEx(bsUnicodeText, pGids, nGidsCount ,x, y, w, h); - DrawPath(c_nWindingFillMode); - EndCommand(c_nPathType); - PathCommandEnd(); - return S_OK; - } - return S_OK; + { + PathCommandEnd(); + BeginCommand(c_nPathType); + PathCommandTextEx(bsUnicodeText, pGids, nGidsCount ,x, y, w, h); + DrawPath(c_nWindingFillMode); + EndCommand(c_nPathType); + PathCommandEnd(); + return S_OK; + } + return S_OK; } //-------- Маркеры для команд --------------------------------------------------------------- HRESULT PPT_FORMAT::CShapeWriter::BeginCommand(const _UINT32& lType) { - if (c_nPathType == lType) - { - m_pSimpleGraphicsConverter->PathCommandEnd(); - } + if (c_nPathType == lType) + { + m_pSimpleGraphicsConverter->PathCommandEnd(); + } - m_lCurrentCommandType = lType; + m_lCurrentCommandType = lType; - return S_OK; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::EndCommand(const _UINT32& lType) { - m_lCurrentCommandType = -1; - return S_OK; + m_lCurrentCommandType = -1; + return S_OK; } //-------- Функции для работы с Graphics Path ----------------------------------------------- HRESULT PPT_FORMAT::CShapeWriter::PathCommandMoveTo(const double& x, const double& y) { - if (c_nSimpleGraphicType == m_lCurrentCommandType) - { - MoveTo(x, y); - } - else - { - m_pSimpleGraphicsConverter->PathCommandMoveTo(x, y); - } + if (c_nSimpleGraphicType == m_lCurrentCommandType) + { + MoveTo(x, y); + } + else + { + m_pSimpleGraphicsConverter->PathCommandMoveTo(x, y); + } - return S_OK; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::PathCommandLineTo(const double& x, const double& y) { - if (c_nSimpleGraphicType == m_lCurrentCommandType) - { - LineTo(x, y); - } - else - { - m_pSimpleGraphicsConverter->PathCommandLineTo(x, y); - } + if (c_nSimpleGraphicType == m_lCurrentCommandType) + { + LineTo(x, y); + } + else + { + m_pSimpleGraphicsConverter->PathCommandLineTo(x, y); + } - return S_OK; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::PathCommandLinesTo(double* points, const int& count) { - m_pSimpleGraphicsConverter->PathCommandLinesTo(points, count); - return S_OK; + m_pSimpleGraphicsConverter->PathCommandLinesTo(points, count); + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::PathCommandCurveTo(const double& x1, const double& y1, const double& x2, const double& y2, const double& x3, const double& y3) { - if (c_nSimpleGraphicType == m_lCurrentCommandType) - { - CurveTo(x1, y1, x2, y2, x3, y3); - } - else - { - m_pSimpleGraphicsConverter->PathCommandCurveTo(x1, y1, x2, y2, x3, y3); - } + if (c_nSimpleGraphicType == m_lCurrentCommandType) + { + CurveTo(x1, y1, x2, y2, x3, y3); + } + else + { + m_pSimpleGraphicsConverter->PathCommandCurveTo(x1, y1, x2, y2, x3, y3); + } - return S_OK; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::PathCommandCurvesTo(double* points, const int& count) { - m_pSimpleGraphicsConverter->PathCommandCurvesTo(points, count); - return S_OK; + m_pSimpleGraphicsConverter->PathCommandCurvesTo(points, count); + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::PathCommandArcTo(const double& x, const double& y, const double& w, const double& h, const double& startAngle, const double& sweepAngle) { - m_pSimpleGraphicsConverter->PathCommandArcTo(x, y, w, h, startAngle, sweepAngle); - return S_OK; + m_pSimpleGraphicsConverter->PathCommandArcTo(x, y, w, h, startAngle, sweepAngle); + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::PathCommandClose() { - if (c_nSimpleGraphicType == m_lCurrentCommandType) - { - Close(); - } - else - { - m_pSimpleGraphicsConverter->PathCommandClose(); - } + if (c_nSimpleGraphicType == m_lCurrentCommandType) + { + Close(); + } + else + { + m_pSimpleGraphicsConverter->PathCommandClose(); + } - return S_OK; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::PathCommandEnd() { - if (c_nSimpleGraphicType == m_lCurrentCommandType) - { - End(); - } - else - { - m_pSimpleGraphicsConverter->PathCommandEnd(); - } + if (c_nSimpleGraphicType == m_lCurrentCommandType) + { + End(); + } + else + { + m_pSimpleGraphicsConverter->PathCommandEnd(); + } - return S_OK; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::DrawPath(const LONG& nType) { - bool bIsStroke = ((0x01 == (nType & 0x01)) && (0 != m_oPen.Alpha)); - bool bIsFill = ((0xFF < nType) && (0 != m_oBrush.Alpha1)); + bool bIsStroke = ((0x01 == (nType & 0x01)) && (0 != m_oPen.Alpha)); + bool bIsFill = ((0xFF < nType) && (0 != m_oBrush.Alpha1)); - if (bIsStroke && bIsFill) - { + if (bIsStroke && bIsFill) + { m_oWriterVML.WriteString(L""); - m_oWriterVML.Write(m_oWriterPath); - m_oWriterVML.WriteString(std::wstring(L"")); - } - else if (bIsStroke) - { + m_oWriterVML.Write(m_oWriterPath); + m_oWriterVML.WriteString(std::wstring(L"")); + } + else if (bIsStroke) + { m_oWriterVML.WriteString(L""); - m_oWriterVML.Write(m_oWriterPath); - m_oWriterVML.WriteString(std::wstring(L"")); - } - else if (bIsFill) - { + m_oWriterVML.Write(m_oWriterPath); + m_oWriterVML.WriteString(std::wstring(L"")); + } + else if (bIsFill) + { m_oWriterVML.WriteString(L""); - m_oWriterVML.Write(m_oWriterPath); - m_oWriterVML.WriteString(std::wstring(L"")); - } + m_oWriterVML.Write(m_oWriterPath); + m_oWriterVML.WriteString(std::wstring(L"")); + } - return S_OK; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::PathCommandStart() { - if (c_nSimpleGraphicType == m_lCurrentCommandType) - { - Start(); - } - else - { - m_pSimpleGraphicsConverter->PathCommandEnd(); - m_pSimpleGraphicsConverter->PathCommandStart(); - } + if (c_nSimpleGraphicType == m_lCurrentCommandType) + { + Start(); + } + else + { + m_pSimpleGraphicsConverter->PathCommandEnd(); + m_pSimpleGraphicsConverter->PathCommandStart(); + } - return S_OK; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::PathCommandGetCurrentPoint(double* fX, double* fY) { - m_pSimpleGraphicsConverter->PathCommandGetCurrentPoint(fX, fY); - return S_OK; + m_pSimpleGraphicsConverter->PathCommandGetCurrentPoint(fX, fY); + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::PathCommandText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h) { - _SetFont(); - m_pSimpleGraphicsConverter->PathCommandText(bsText, m_pFontManager, x, y, w, h, 0); - return S_OK; + _SetFont(); + m_pSimpleGraphicsConverter->PathCommandText(bsText, m_pFontManager, x, y, w, h, 0); + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::PathCommandTextEx(const std::wstring& bsUnicodeText, const unsigned int* pGids, const unsigned int nGidsCount, const double& x, const double& y, const double& w, const double& h) { bool bGid = m_oFont.StringGID; - //TODOO - //if (NULL != bsGidText) - //{ - // m_oFont.StringGID = true; - // PathCommandText(bsUnicodeText, x, y, w, h, baselineOffset); - //} - - m_oFont.StringGID = false; - PathCommandText(bsUnicodeText, x, y, w, h); + //TODOO + //if (NULL != bsGidText) + //{ + // m_oFont.StringGID = true; + // PathCommandText(bsUnicodeText, x, y, w, h, baselineOffset); + //} - m_oFont.StringGID = bGid; - return S_OK; + m_oFont.StringGID = false; + PathCommandText(bsUnicodeText, x, y, w, h); + + m_oFont.StringGID = bGid; + return S_OK; } //-------- Функции для вывода изображений --------------------------------------------------- HRESULT PPT_FORMAT::CShapeWriter::DrawImage(IGrObject* pImage, const double& x, const double& y, const double& w, const double& h) { - return S_OK; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::DrawImageFromFile(const std::wstring&, const double& x, const double& y, const double& w, const double& h, const BYTE& lAlpha) { - return S_OK; + return S_OK; } // transform -------------------------------------------------------------------------------- HRESULT PPT_FORMAT::CShapeWriter::GetCommandParams(double* dAngle, double* dLeft, double* dTop, double* dWidth, double* dHeight, _UINT32* lFlags) { - return S_OK; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::SetCommandParams(double dAngle, double dLeft, double dTop, double dWidth, double dHeight, _UINT32 lFlags) { - if ((dWidth <= 1) || (dHeight <= 1)) - lFlags = 0; + if ((dWidth <= 1) || (dHeight <= 1)) + lFlags = 0; bool bFlipX = (0 != (c_nParamFlipX & lFlags)); bool bFlipY = (0 != (c_nParamFlipY & lFlags)); - - double m11 = bFlipX ? -1.0 : 1.0; - double m22 = bFlipY ? -1.0 : 1.0; - - Aggplus::CMatrix oMatrix(1, 0, 0, 1, 0, 0); - if ((0 != dAngle) || (0 != lFlags)) - { - double dCentreX = (dLeft + dWidth / 2.0); - double dCentreY = (dTop + dHeight / 2.0); - - oMatrix.Translate(-dCentreX, -dCentreY , Aggplus::MatrixOrderAppend); - - oMatrix.Rotate(dAngle , Aggplus::MatrixOrderAppend); - oMatrix.Scale(m11, m22 , Aggplus::MatrixOrderAppend); - - oMatrix.Translate(dCentreX, dCentreY , Aggplus::MatrixOrderAppend); - } + double m11 = bFlipX ? -1.0 : 1.0; + double m22 = bFlipY ? -1.0 : 1.0; - m_oTransform = oMatrix; - CalculateFullTransform(); + Aggplus::CMatrix oMatrix(1, 0, 0, 1, 0, 0); - return S_OK; + if ((0 != dAngle) || (0 != lFlags)) + { + double dCentreX = (dLeft + dWidth / 2.0); + double dCentreY = (dTop + dHeight / 2.0); + + oMatrix.Translate(-dCentreX, -dCentreY , Aggplus::MatrixOrderAppend); + + oMatrix.Rotate(dAngle , Aggplus::MatrixOrderAppend); + oMatrix.Scale(m11, m22 , Aggplus::MatrixOrderAppend); + + oMatrix.Translate(dCentreX, dCentreY , Aggplus::MatrixOrderAppend); + } + + m_oTransform = oMatrix; + CalculateFullTransform(); + + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::SetTransform(const double& m1, const double& m2, const double& m3, const double& m4, const double& m5, const double& m6) { - Aggplus::CMatrix oTrans(m1, m2, m3, m4, m5, m6); - m_oTransform = oTrans; + Aggplus::CMatrix oTrans(m1, m2, m3, m4, m5, m6); + m_oTransform = oTrans; - CalculateFullTransform(); + CalculateFullTransform(); - return S_OK; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::GetTransform(double *pdA, double *pdB, double *pdC, double *pdD, double *pdE, double *pdF) { - return S_OK; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::ResetTransform(void) { - m_oTransform.Reset(); - CalculateFullTransform(); - return S_OK; + m_oTransform.Reset(); + CalculateFullTransform(); + return S_OK; } // ----------------------------------------------------------------------------------------- HRESULT PPT_FORMAT::CShapeWriter::get_ClipMode(LONG* plMode) { - *plMode = m_lClipMode; - return S_OK; + *plMode = m_lClipMode; + return S_OK; } HRESULT PPT_FORMAT::CShapeWriter::put_ClipMode(const LONG& lMode) { - m_lClipMode = lMode; - return S_OK; + m_lClipMode = lMode; + return S_OK; } diff --git a/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp b/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp index 79f655decc..6b6ca23a97 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp @@ -2387,14 +2387,38 @@ void CPPTUserInfo::LoadExternal(CRecordExObjListContainer* pExObjects) oInfo.m_dwID = oArrayHyperlink[0]->m_nHyperlinkID; for (size_t i = 0 ; i < oArrayCString.size(); i++) { + const auto& recStr = oArrayCString[i]->m_strText; + const auto recInst = oArrayCString[i]->m_oHeader.RecInstance; // Target atom. It's for eigher local and external files. - if (oArrayCString[i]->m_oHeader.RecInstance == 1) - oInfo.m_strFilePath = oArrayCString[i]->m_strText; + if (recInst == 1) + { + oInfo.m_strFilePath = recStr; + oInfo.m_type = oInfo.isHTTPLink(recStr) ? CExFilesInfo::ExFilesType::eftHyperlink : + CExFilesInfo::ExFilesType::eftAudio; + } // Location atom. It's for slides or other local pp objects. - if (oArrayCString[i]->m_oHeader.RecInstance == 3 && oInfo.GetSlideNumber(oArrayCString[i]->m_strText) != -1) - oInfo.m_strLocation = oArrayCString[i]->m_strText; + else if (recInst == 3 && oInfo.GetSlideNumber(recStr) != -1) + { + oInfo.m_strFilePath = recStr; + oInfo.m_type = CExFilesInfo::ExFilesType::eftSlide; + } + else + continue; + } + switch (oInfo.m_type) + { + case CExFilesInfo::ExFilesType::eftHyperlink: + m_oExMedia.m_arHyperlinks.push_back(oInfo); + break; + case CExFilesInfo::ExFilesType::eftAudio: + m_oExMedia.m_arAudioCollection.push_back(oInfo); + break; + case CExFilesInfo::ExFilesType::eftSlide: + m_oExMedia.m_arSlides.push_back(oInfo); + break; + default: + m_oExMedia.m_arHyperlinks.push_back(oInfo); } - m_oExMedia.m_arHyperlinks.push_back(oInfo); } } diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp index cd572d0686..af3ee3a340 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp @@ -1896,6 +1896,9 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, std::vector oArrayInteractive; GetRecordsByType(&oArrayInteractive, true, false); + std::vector oArrayMacro; + GetRecordsByType(&oArrayMacro, true, false); + if (oArrayInteractive.size() == 2) oArrayInteractive[1]->m_oHeader.RecInstance = 1; @@ -1913,12 +1916,19 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, interactiveInfo.m_strAudioFileName = pInfo1->m_strFilePath; interactiveInfo.m_strAudioName = pInfo1->m_name; } - CExFilesInfo* pInfo2 = pMapIDs->LockHyperlink(interactiveAtom->m_nExHyperlinkIdRef); + CExFilesInfo* pInfo2 = pMapIDs->LockSlide(interactiveAtom->m_nExHyperlinkIdRef); if (NULL != pInfo2) { - interactiveInfo.m_strHyperlink = pInfo2->m_strLocation; + interactiveInfo.m_strHyperlink = pInfo2->m_strFilePath; + } + pInfo2 = pMapIDs->LockHyperlink(interactiveAtom->m_nExHyperlinkIdRef); + if (NULL != pInfo2) + { + interactiveInfo.m_strHyperlink = pInfo2->m_strFilePath; } } + if (oArrayMacro.size()) + interactiveInfo.m_macro = oArrayMacro[0]->m_strText; interactiveInfo.m_lType = interactiveAtom->m_nAction; interactiveInfo.m_lOleVerb = interactiveAtom->m_nOleVerb; diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/InteractiveInfoAtom.h b/ASCOfficePPTFile/PPTFormatLib/Records/InteractiveInfoAtom.h index 6762f6f828..02bdc53276 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/InteractiveInfoAtom.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/InteractiveInfoAtom.h @@ -32,47 +32,49 @@ #pragma once #include "../Reader/Records.h" +using namespace std; + class CRecordInteractiveInfoAtom : public CUnknownRecord { public: - UINT m_nSoundIdRef; - UINT m_nExHyperlinkIdRef; - BYTE m_nAction; - BYTE m_nOleVerb; - BYTE m_nJump; - BYTE m_nHyperlinkType; + UINT m_nSoundIdRef; + UINT m_nExHyperlinkIdRef; + BYTE m_nAction; + BYTE m_nOleVerb; + BYTE m_nJump; + BYTE m_nHyperlinkType; - bool m_bAnimated; - bool m_bStopSound; - bool m_bCustomShowReturn; - bool m_bVisited; - - CRecordInteractiveInfoAtom() - { - } + bool m_bAnimated; + bool m_bStopSound; + bool m_bCustomShowReturn; + bool m_bVisited; - ~CRecordInteractiveInfoAtom() - { - } + CRecordInteractiveInfoAtom() + { + } - virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream) - { - m_oHeader = oHeader; + ~CRecordInteractiveInfoAtom() + { + } - m_nSoundIdRef = StreamUtils::ReadDWORD(pStream); - m_nExHyperlinkIdRef = StreamUtils::ReadDWORD(pStream); - m_nAction = StreamUtils::ReadBYTE(pStream); - m_nOleVerb = StreamUtils::ReadBYTE(pStream); - m_nJump = StreamUtils::ReadBYTE(pStream); + virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream) + { + m_oHeader = oHeader; - BYTE nFlag = StreamUtils::ReadBYTE(pStream); + m_nSoundIdRef = StreamUtils::ReadDWORD(pStream); + m_nExHyperlinkIdRef = StreamUtils::ReadDWORD(pStream); + m_nAction = StreamUtils::ReadBYTE(pStream); + m_nOleVerb = StreamUtils::ReadBYTE(pStream); + m_nJump = StreamUtils::ReadBYTE(pStream); - m_bAnimated = ((nFlag & 0x01) == 0x01); - m_bStopSound = ((nFlag & 0x02) == 0x02); - m_bCustomShowReturn = ((nFlag & 0x04) == 0x04); - m_bVisited = ((nFlag & 0x08) == 0x08); + BYTE nFlag = StreamUtils::ReadBYTE(pStream); - m_nHyperlinkType = StreamUtils::ReadBYTE(pStream); - StreamUtils::StreamSkip(3, pStream); - } -}; \ No newline at end of file + m_bAnimated = ((nFlag & 0x01) == 0x01); + m_bStopSound = ((nFlag & 0x02) == 0x02); + m_bCustomShowReturn = ((nFlag & 0x04) == 0x04); + m_bVisited = ((nFlag & 0x08) == 0x08); + + m_nHyperlinkType = StreamUtils::ReadBYTE(pStream); + StreamUtils::StreamSkip(3, pStream); + } +}; diff --git a/ASCOfficePPTXFile/Editor/Drawing/Attributes.h b/ASCOfficePPTXFile/Editor/Drawing/Attributes.h index b31239c2c4..47f80b4369 100644 --- a/ASCOfficePPTXFile/Editor/Drawing/Attributes.h +++ b/ASCOfficePPTXFile/Editor/Drawing/Attributes.h @@ -79,13 +79,14 @@ public: eftNone = 0, eftVideo = 1, eftAudio = 2, - eftHyperlink= 3, + eftHyperlink = 3, eftObject = 4, - eftSlide // Not used yet + eftSlide }; - _UINT32 m_dwID; - std::wstring m_strFilePath; - std::wstring m_strLocation; + + ExFilesType m_type; + _UINT32 m_dwID; + std::wstring m_strFilePath; std::wstring m_name; // clip @@ -97,33 +98,19 @@ public: CExFilesInfo() { - m_dwID = 0; - m_strFilePath = _T(""); - m_strLocation = _T(""); + m_type = eftNone; + m_dwID = 0; + m_strFilePath = _T(""); - m_dStartTime = 0.0; - m_dEndTime = -1.0; + m_dStartTime = 0.0; + m_dEndTime = -1.0; - m_bLoop = false; + m_bLoop = false; } CExFilesInfo(const CExFilesInfo& oSrc) { *this = oSrc; } - CExFilesInfo& operator=(const CExFilesInfo& oSrc) - { - m_dwID = oSrc.m_dwID; - m_strFilePath = oSrc.m_strFilePath; - m_strLocation = oSrc.m_strLocation; - m_name = oSrc.m_name; - - m_dStartTime = oSrc.m_dStartTime; - m_dEndTime = oSrc.m_dEndTime; - - m_bLoop = oSrc.m_bLoop; - - return *this; - } static int GetSlideNumber(const std::wstring &str) { @@ -144,6 +131,12 @@ public: return -1; } + static bool isHTTPLink(const std::wstring &str) + { + int iter1 = str.find(L"http://"); + int iter2 = str.find(L"https://"); + return iter1 != -1 || iter2 != -1; + } }; class CExMedia @@ -155,6 +148,7 @@ public: std::vector m_arImages; std::vector m_arAudios; std::vector m_arHyperlinks; + std::vector m_arSlides; std::vector m_arAudioCollection; @@ -201,6 +195,19 @@ public: return NULL; } + CExFilesInfo* LockSlide(_UINT32 dwID) + { + size_t nCount = m_arSlides.size(); + for (size_t i = 0; i < nCount; ++i) + { + if (dwID == m_arSlides[i].m_dwID) + { + return &m_arSlides[i]; + } + } + + return NULL; + } CExFilesInfo* LockVideo(_UINT32 dwID) { size_t nCount = m_arVideos.size(); @@ -276,6 +283,12 @@ public: eType = CExFilesInfo::eftAudio; return pInfo; } + pInfo = LockSlide(dwID); + if (NULL != pInfo) + { + eType = CExFilesInfo::eftSlide; + return pInfo; + } eType = CExFilesInfo::eftNone; return LockImage(dwID); } diff --git a/ASCOfficePPTXFile/Editor/Drawing/Interactive.h b/ASCOfficePPTXFile/Editor/Drawing/Interactive.h index e02b26e442..e0f5cf953c 100644 --- a/ASCOfficePPTXFile/Editor/Drawing/Interactive.h +++ b/ASCOfficePPTXFile/Editor/Drawing/Interactive.h @@ -90,6 +90,7 @@ namespace PPT_FORMAT m_strHyperlink = oSrc.m_strHyperlink; m_strAudioName = oSrc.m_strAudioName; m_eActivation = oSrc.m_eActivation; + m_macro = oSrc.m_macro; return *this; } CInteractiveInfo(const CInteractiveInfo& oSrc) @@ -112,6 +113,7 @@ namespace PPT_FORMAT std::wstring m_strAudioFileName; std::wstring m_strHyperlink; std::wstring m_strAudioName; + std::wstring m_macro; }; class CTextInteractiveInfo { From 0586cabee58a960c853b1999c63e200803aae50b Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Tue, 20 Jul 2021 18:43:51 +0300 Subject: [PATCH 43/84] add image hyperlinks, change text hyperlinks, but last one works uncorrect --- .../PPTFormatLib/PPTXWriter/ShapeWriter.cpp | 20 +- .../Records/Drawing/ShapeContainer.cpp | 3735 +++++++++-------- 2 files changed, 1876 insertions(+), 1879 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp index 69db41b8b9..2ad6d42696 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp @@ -691,10 +691,7 @@ void PPT_FORMAT::CShapeWriter::WriteImageInfo() m_oWriter.WriteString(std::wstring(L">")); - if (pVideoElement || pAudioElement) - { - m_oWriter.WriteString(std::wstring(L"")); - } + WriteButton(); m_oWriter.WriteString(std::wstring(L"font.sym->Name + _T("\"/>")); } - WriteButton(nIndexPar); +// WriteButton(nIndexPar); m_oWriter.WriteString(std::wstring(L"")); @@ -1781,11 +1778,11 @@ void PPT_FORMAT::CShapeWriter::WriteButton(int paragraphNum) if (hlink.id.is_init()) hlink.action = L"ppaction://hlinksldjump"; } - else if (actions[i].m_lHyperlinkType == 8) - hlink.action = L""; +// else if (actions[i].m_lHyperlinkType == 8) +// hlink.action = L""; - if (!hlink.action.is_init() || hlink.action->empty()) - hlink.action = L"ppaction://noaction"; +// if (!hlink.action.is_init() || hlink.action->empty()) +// hlink.action = L"ppaction://noaction"; break; } case II_MediaAction: @@ -1804,10 +1801,7 @@ void PPT_FORMAT::CShapeWriter::WriteButton(int paragraphNum) std::vector CShapeWriter::getActionsByNum(const int num) { - CShapeElement* pShapeElement = dynamic_cast(m_pElement.get()); - if (!pShapeElement) return {}; - - auto& actions = pShapeElement->m_arrActions; + auto& actions = m_pElement->m_arrActions; // Need to check paragraph or button if (num == -1 && actions.size() > 2) // paragraph inside shape diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp index af3ee3a340..ac01b90410 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp @@ -47,82 +47,82 @@ bool CPPTElement::ChangeBlack2ColorImage(std::wstring image_path, int rgbColor1, int rgbColor2) { - CBgraFrame bgraFrame; + CBgraFrame bgraFrame; - if (bgraFrame.OpenFile(image_path)) - { - int smpl = abs(bgraFrame.get_Stride() / bgraFrame.get_Width()); + if (bgraFrame.OpenFile(image_path)) + { + int smpl = abs(bgraFrame.get_Stride() / bgraFrame.get_Width()); - BYTE * rgb = bgraFrame.get_Data(); - - BYTE R1 = (BYTE)(rgbColor1); - BYTE G1 = (BYTE)(rgbColor1 >> 8); - BYTE B1 = (BYTE)(rgbColor1 >> 16); + BYTE * rgb = bgraFrame.get_Data(); - BYTE R2 = (BYTE)(rgbColor2); - BYTE G2 = (BYTE)(rgbColor2 >> 8); - BYTE B2 = (BYTE)(rgbColor2 >> 16); + BYTE R1 = (BYTE)(rgbColor1); + BYTE G1 = (BYTE)(rgbColor1 >> 8); + BYTE B1 = (BYTE)(rgbColor1 >> 16); - for (int i = 0 ; i < bgraFrame.get_Width() * bgraFrame.get_Height(); i++) - { - if (rgb[i * smpl + 0 ] == 0x00 && rgb[i * smpl + 1 ] == 0x00 && rgb[i * smpl + 2 ] == 0x00) - { - rgb[i * smpl + 0 ] = R1; - rgb[i * smpl + 1 ] = G1; - rgb[i * smpl + 2 ] = B1; - } - else - { - rgb[i * smpl + 0 ] = R2; - rgb[i * smpl + 1 ] = G2; - rgb[i * smpl + 2 ] = B2; - } - } - bgraFrame.SaveFile(image_path, 1); - return true; - } - return false; + BYTE R2 = (BYTE)(rgbColor2); + BYTE G2 = (BYTE)(rgbColor2 >> 8); + BYTE B2 = (BYTE)(rgbColor2 >> 16); + + for (int i = 0 ; i < bgraFrame.get_Width() * bgraFrame.get_Height(); i++) + { + if (rgb[i * smpl + 0 ] == 0x00 && rgb[i * smpl + 1 ] == 0x00 && rgb[i * smpl + 2 ] == 0x00) + { + rgb[i * smpl + 0 ] = R1; + rgb[i * smpl + 1 ] = G1; + rgb[i * smpl + 2 ] = B1; + } + else + { + rgb[i * smpl + 0 ] = R2; + rgb[i * smpl + 1 ] = G2; + rgb[i * smpl + 2 ] = B2; + } + } + bgraFrame.SaveFile(image_path, 1); + return true; + } + return false; } CColor CPPTElement::CorrectSysColor(int nColorCode, CElementPtr pElement, CTheme* pTheme) { - if (!pElement) return CColor(); + if (!pElement) return CColor(); - CColor color; + CColor color; - unsigned short nParameter = (unsigned short)(( nColorCode >> 16 ) & 0x00ff); // the HiByte of nParameter is not zero, an exclusive AND is helping :o - unsigned short nFunctionBits = (unsigned short)(( nColorCode & 0x00000f00 ) >> 8 ); - unsigned short nAdditionalFlags = (unsigned short)(( nColorCode & 0x0000f000) >> 8 ); - unsigned short nColorIndex = (unsigned short) ( nColorCode & 0x00ff); - unsigned short nPropColor = 0; + unsigned short nParameter = (unsigned short)(( nColorCode >> 16 ) & 0x00ff); // the HiByte of nParameter is not zero, an exclusive AND is helping :o + unsigned short nFunctionBits = (unsigned short)(( nColorCode & 0x00000f00 ) >> 8 ); + unsigned short nAdditionalFlags = (unsigned short)(( nColorCode & 0x0000f000) >> 8 ); + unsigned short nColorIndex = (unsigned short) ( nColorCode & 0x00ff); + unsigned short nPropColor = 0; - switch (nColorIndex) - { - case 0xF0: color = pElement->m_oBrush.Color1; break; - case 0xF1: - { - if (pElement->m_bLine) color = pElement->m_oPen.Color; - else color = pElement->m_oBrush.Color1; - }break; - case 0xF2: color = pElement->m_oPen.Color; break; - case 0xF3: color = pElement->m_oShadow.Color; break; - case 0xF4: break; ///this - case 0xF5: color = pElement->m_oBrush.Color2; break; - case 0xF6: break; //lineBackColor - case 0xF7: //FillThenLine - case 0xF8: //colorIndexMask - color = pElement->m_oBrush.Color1; break; - default: - //from table - break; - } + switch (nColorIndex) + { + case 0xF0: color = pElement->m_oBrush.Color1; break; + case 0xF1: + { + if (pElement->m_bLine) color = pElement->m_oPen.Color; + else color = pElement->m_oBrush.Color1; + }break; + case 0xF2: color = pElement->m_oPen.Color; break; + case 0xF3: color = pElement->m_oShadow.Color; break; + case 0xF4: break; ///this + case 0xF5: color = pElement->m_oBrush.Color2; break; + case 0xF6: break; //lineBackColor + case 0xF7: //FillThenLine + case 0xF8: //colorIndexMask + color = pElement->m_oBrush.Color1; break; + default: + //from table + break; + } if (color.m_lSchemeIndex != -1 && (int)pTheme->m_arColorScheme.size() > color.m_lSchemeIndex) - { - //вытащить цвет ( + { + //вытащить цвет ( - color = pTheme->m_arColorScheme[color.m_lSchemeIndex]; - } + color = pTheme->m_arColorScheme[color.m_lSchemeIndex]; + } //if ( nCProp && ( nPropColor & 0x10000000 ) == 0 ) // beware of looping recursive // color = CorrectSysColor( nPropColor, pElement); @@ -130,66 +130,66 @@ CColor CPPTElement::CorrectSysColor(int nColorCode, CElementPtr pElement, CTheme if( nAdditionalFlags & 0x80 ) // make color gray { BYTE nZwi = 0x7f;//= aColor.GetLuminance(); - color.SetRGB(nZwi, nZwi, nZwi); + color.SetRGB(nZwi, nZwi, nZwi); } switch( nFunctionBits ) { - case 0x01 : // darken color by parameter - { - color.SetR ( static_cast ( ( nParameter * color.GetR() ) >> 8 ) ); - color.SetG ( static_cast ( ( nParameter * color.GetG() ) >> 8 ) ); - color.SetB ( static_cast ( ( nParameter * color.GetB() ) >> 8 ) ); - } + case 0x01 : // darken color by parameter + { + color.SetR ( static_cast ( ( nParameter * color.GetR() ) >> 8 ) ); + color.SetG ( static_cast ( ( nParameter * color.GetG() ) >> 8 ) ); + color.SetB ( static_cast ( ( nParameter * color.GetB() ) >> 8 ) ); + } break; - case 0x02 : // lighten color by parameter - { - unsigned short nInvParameter = ( 0x00ff - nParameter ) * 0xff; - color.SetR( static_cast( ( nInvParameter + ( nParameter * color.GetR() ) ) >> 8 ) ); - color.SetG( static_cast( ( nInvParameter + ( nParameter * color.GetG() ) ) >> 8 ) ); - color.SetB( static_cast( ( nInvParameter + ( nParameter * color.GetB() ) ) >> 8 ) ); - } + case 0x02 : // lighten color by parameter + { + unsigned short nInvParameter = ( 0x00ff - nParameter ) * 0xff; + color.SetR( static_cast( ( nInvParameter + ( nParameter * color.GetR() ) ) >> 8 ) ); + color.SetG( static_cast( ( nInvParameter + ( nParameter * color.GetG() ) ) >> 8 ) ); + color.SetB( static_cast( ( nInvParameter + ( nParameter * color.GetB() ) ) >> 8 ) ); + } break; - case 0x03 : // add grey level RGB(p,p,p) - { - short nR = (short)color.GetR() + (short)nParameter; - short nG = (short)color.GetG() + (short)nParameter; - short nB = (short)color.GetB() + (short)nParameter; + case 0x03 : // add grey level RGB(p,p,p) + { + short nR = (short)color.GetR() + (short)nParameter; + short nG = (short)color.GetG() + (short)nParameter; + short nB = (short)color.GetB() + (short)nParameter; - if ( nR > 0x00ff ) nR = 0x00ff; - if ( nG > 0x00ff ) nG = 0x00ff; - if ( nB > 0x00ff ) nB = 0x00ff; + if ( nR > 0x00ff ) nR = 0x00ff; + if ( nG > 0x00ff ) nG = 0x00ff; + if ( nB > 0x00ff ) nB = 0x00ff; - color.SetRGB( (BYTE)nR, (BYTE)nG, (BYTE)nB ); - } + color.SetRGB( (BYTE)nR, (BYTE)nG, (BYTE)nB ); + } break; - case 0x04 : // substract grey level RGB(p,p,p) - { - short nR = (short)color.GetR() - (short)nParameter; - short nG = (short)color.GetG() - (short)nParameter; - short nB = (short)color.GetB() - (short)nParameter; - if ( nR < 0 ) nR = 0; - if ( nG < 0 ) nG = 0; - if ( nB < 0 ) nB = 0; - color.SetRGB( (BYTE)nR, (BYTE)nG, (BYTE)nB ); - } + case 0x04 : // substract grey level RGB(p,p,p) + { + short nR = (short)color.GetR() - (short)nParameter; + short nG = (short)color.GetG() - (short)nParameter; + short nB = (short)color.GetB() - (short)nParameter; + if ( nR < 0 ) nR = 0; + if ( nG < 0 ) nG = 0; + if ( nB < 0 ) nB = 0; + color.SetRGB( (BYTE)nR, (BYTE)nG, (BYTE)nB ); + } break; - case 0x05 : // substract from gray level RGB(p,p,p) - { - short nR = (short)nParameter - (short)color.GetR(); - short nG = (short)nParameter - (short)color.GetG(); - short nB = (short)nParameter - (short)color.GetB(); - if ( nR < 0 ) nR = 0; - if ( nG < 0 ) nG = 0; - if ( nB < 0 ) nB = 0; - color.SetRGB( (BYTE)nR, (BYTE)nG, (BYTE)nB ); - } + case 0x05 : // substract from gray level RGB(p,p,p) + { + short nR = (short)nParameter - (short)color.GetR(); + short nG = (short)nParameter - (short)color.GetG(); + short nB = (short)nParameter - (short)color.GetB(); + if ( nR < 0 ) nR = 0; + if ( nG < 0 ) nG = 0; + if ( nB < 0 ) nB = 0; + color.SetRGB( (BYTE)nR, (BYTE)nG, (BYTE)nB ); + } break; - case 0x06 : // per component: black if < p, white if >= p - { - color.SetR( color.GetR() < nParameter ? 0x00 : 0xff ); - color.SetG( color.GetG() < nParameter ? 0x00 : 0xff ); - color.SetB( color.GetB() < nParameter ? 0x00 : 0xff ); - } + case 0x06 : // per component: black if < p, white if >= p + { + color.SetR( color.GetR() < nParameter ? 0x00 : 0xff ); + color.SetG( color.GetG() < nParameter ? 0x00 : 0xff ); + color.SetB( color.GetB() < nParameter ? 0x00 : 0xff ); + } break; } if ( nAdditionalFlags & 0x40 ) // top-bit invert @@ -198,1294 +198,1294 @@ CColor CPPTElement::CorrectSysColor(int nColorCode, CElementPtr pElement, CTheme if ( nAdditionalFlags & 0x20 ) // invert color color.SetRGB(0xff - color.GetR(), 0xff - color.GetG(), 0xff - color.GetB()); - return color; + return color; } void CPPTElement::SetUpProperties(CElementPtr pElement, CTheme* pTheme, CSlideInfo* pWrapper, CSlide* pSlide, CProperties* pProperties, bool reset_default) { - size_t lCount = pProperties->m_lCount; - switch (pElement->m_etType) - { - case PPT_FORMAT::etVideo: - { - if (reset_default) - { - pElement->m_bLine = false; - } - for (size_t i = 0; i < lCount; ++i) - { - SetUpPropertyVideo(pElement, pTheme, pWrapper, pSlide, &pProperties->m_arProperties[i]); - } - break; - } - case PPT_FORMAT::etPicture: - { - if (reset_default) - { - pElement->m_oBrush.Type = c_BrushTypeTexture; - pElement->m_bLine = false; - } - for (size_t i = 0; i < lCount; ++i) - { - SetUpPropertyImage(pElement, pTheme, pWrapper, pSlide, &pProperties->m_arProperties[i]); - } - break; - } - case PPT_FORMAT::etAudio: - { - if (reset_default) - { - pElement->m_bLine = false; - } - for (size_t i = 0; i < lCount; ++i) - { - SetUpPropertyAudio(pElement, pTheme, pWrapper, pSlide, &pProperties->m_arProperties[i]); - } - break; - } - case PPT_FORMAT::etGroup: - { - if (reset_default) - { - pElement->m_bLine = false; - pElement->m_bIsFilled = false; - } - for (size_t i = 0; i < lCount; ++i) - { - SetUpProperty(pElement, pTheme, pWrapper, pSlide, &pProperties->m_arProperties[i]); - } - }break; - case PPT_FORMAT::etShape: - { - CShapeElement* pShapeElem = dynamic_cast(pElement.get()); - CPPTShape* pPPTShape = dynamic_cast(pShapeElem->m_pShape->getBaseShape().get()); + size_t lCount = pProperties->m_lCount; + switch (pElement->m_etType) + { + case PPT_FORMAT::etVideo: + { + if (reset_default) + { + pElement->m_bLine = false; + } + for (size_t i = 0; i < lCount; ++i) + { + SetUpPropertyVideo(pElement, pTheme, pWrapper, pSlide, &pProperties->m_arProperties[i]); + } + break; + } + case PPT_FORMAT::etPicture: + { + if (reset_default) + { + pElement->m_oBrush.Type = c_BrushTypeTexture; + pElement->m_bLine = false; + } + for (size_t i = 0; i < lCount; ++i) + { + SetUpPropertyImage(pElement, pTheme, pWrapper, pSlide, &pProperties->m_arProperties[i]); + } + break; + } + case PPT_FORMAT::etAudio: + { + if (reset_default) + { + pElement->m_bLine = false; + } + for (size_t i = 0; i < lCount; ++i) + { + SetUpPropertyAudio(pElement, pTheme, pWrapper, pSlide, &pProperties->m_arProperties[i]); + } + break; + } + case PPT_FORMAT::etGroup: + { + if (reset_default) + { + pElement->m_bLine = false; + pElement->m_bIsFilled = false; + } + for (size_t i = 0; i < lCount; ++i) + { + SetUpProperty(pElement, pTheme, pWrapper, pSlide, &pProperties->m_arProperties[i]); + } + }break; + case PPT_FORMAT::etShape: + { + CShapeElement* pShapeElem = dynamic_cast(pElement.get()); + CPPTShape* pPPTShape = dynamic_cast(pShapeElem->m_pShape->getBaseShape().get()); - if (NULL != pPPTShape) - { - pPPTShape->m_oCustomVML.SetAdjusts(&pPPTShape->m_arAdjustments); - } + if (NULL != pPPTShape) + { + pPPTShape->m_oCustomVML.SetAdjusts(&pPPTShape->m_arAdjustments); + } - for (size_t i = 0; i < lCount; ++i) - { - SetUpPropertyShape(pElement, pTheme, pWrapper, pSlide, &pProperties->m_arProperties[i]); - } + for (size_t i = 0; i < lCount; ++i) + { + SetUpPropertyShape(pElement, pTheme, pWrapper, pSlide, &pProperties->m_arProperties[i]); + } - if (false == pElement->m_bIsFilled) - { - pElement->m_oBrush.Type = c_BrushTypeNoFill; - } - else if (pElement->m_oBrush.Type == c_BrushTypeNotSet && - (pElement->m_lPlaceholderType == 0 && pElement->m_lPlaceholderID < 0 )) - { - pElement->m_oBrush.Type = c_BrushTypeSolid; - } + if (false == pElement->m_bIsFilled) + { + pElement->m_oBrush.Type = c_BrushTypeNoFill; + } + else if (pElement->m_oBrush.Type == c_BrushTypeNotSet && + (pElement->m_lPlaceholderType == 0 && pElement->m_lPlaceholderID < 0 )) + { + pElement->m_oBrush.Type = c_BrushTypeSolid; + } - if (NULL != pPPTShape) - { - pPPTShape->m_oCustomVML.ToCustomShape(pPPTShape, pPPTShape->m_oManager); - pPPTShape->ReCalculate(); - } - break; - } - default: - break; - } + if (NULL != pPPTShape) + { + pPPTShape->m_oCustomVML.ToCustomShape(pPPTShape, pPPTShape->m_oManager); + pPPTShape->ReCalculate(); + } + break; + } + default: + break; + } } void CPPTElement::SetUpProperty(CElementPtr pElement, CTheme* pTheme, CSlideInfo* pInfo, CSlide* pSlide, CProperty* pProperty) { - switch (pProperty->m_ePID) - { - case wzName: - { - pElement->m_sName = NSFile::CUtf8Converter::GetWStringFromUTF16((unsigned short*)pProperty->m_pOptions, pProperty->m_lValue /2 - 1); - }break; - case wzDescription: - { - pElement->m_sDescription = NSFile::CUtf8Converter::GetWStringFromUTF16((unsigned short*)pProperty->m_pOptions, pProperty->m_lValue /2 - 1); - }break; - case hspMaster: - { - pElement->m_lLayoutID = (LONG)pProperty->m_lValue; - }break; - case ePropertyId_rotation: - { - pElement->m_dRotate = FixedPointToDouble(pProperty->m_lValue); - }break; - case ePropertyId_fFlipH: - { - BYTE flag1 = (BYTE)pProperty->m_lValue; - BYTE flag3 = (BYTE)(pProperty->m_lValue >> 16); + switch (pProperty->m_ePID) + { + case wzName: + { + pElement->m_sName = NSFile::CUtf8Converter::GetWStringFromUTF16((unsigned short*)pProperty->m_pOptions, pProperty->m_lValue /2 - 1); + }break; + case wzDescription: + { + pElement->m_sDescription = NSFile::CUtf8Converter::GetWStringFromUTF16((unsigned short*)pProperty->m_pOptions, pProperty->m_lValue /2 - 1); + }break; + case hspMaster: + { + pElement->m_lLayoutID = (LONG)pProperty->m_lValue; + }break; + case ePropertyId_rotation: + { + pElement->m_dRotate = FixedPointToDouble(pProperty->m_lValue); + }break; + case ePropertyId_fFlipH: + { + BYTE flag1 = (BYTE)pProperty->m_lValue; + BYTE flag3 = (BYTE)(pProperty->m_lValue >> 16); - bool bFlipH = (0x01 == (0x01 & flag1)); - bool bFlipV = (0x02 == (0x02 & flag1)); + bool bFlipH = (0x01 == (0x01 & flag1)); + bool bFlipV = (0x02 == (0x02 & flag1)); - bool bUseFlipH = (0x01 == (0x01 & flag3)); - bool bUseFlipV = (0x02 == (0x02 & flag3)); + bool bUseFlipH = (0x01 == (0x01 & flag3)); + bool bUseFlipV = (0x02 == (0x02 & flag3)); - if (bUseFlipH) - pElement->m_bFlipH = bFlipH; + if (bUseFlipH) + pElement->m_bFlipH = bFlipH; - if (bUseFlipV) - pElement->m_bFlipV = bFlipV; - }break; - case fillType: - { - _UINT32 dwType = pProperty->m_lValue; - switch(dwType) - { - case ODRAW::fillPattern: - { - pElement->m_oBrush.Type = c_BrushTypePattern; - //texture + change black to color2, white to color1 - }break; - case ODRAW::fillTexture : - case ODRAW::fillPicture : - { - pElement->m_oBrush.Type = c_BrushTypeTexture; - pElement->m_oBrush.TextureMode = (ODRAW::fillPicture == dwType) ? c_BrushTextureModeStretch : c_BrushTextureModeTile; - }break; - case ODRAW::fillShadeCenter://1 color - case ODRAW::fillShadeShape: - { - pElement->m_oBrush.Type = c_BrushTypeCenter; - }break;// - case ODRAW::fillShadeTitle://2 colors and more - case ODRAW::fillShade : - case ODRAW::fillShadeScale: - { - pElement->m_oBrush.Type = c_BrushTypePathGradient1; - }break; - case ODRAW::fillBackground: - { - pElement->m_oBrush.Type = c_BrushTypeNoFill; - }break; - } - }break; - case fillBlip: - { - int dwOffset = 0 ; - - if (pProperty->m_bComplex) - { - //inline - dwOffset = -1; - } - else - { - dwOffset = pInfo->GetIndexPicture(pProperty->m_lValue); - } - int nLen = pElement->m_oBrush.TexturePath.length() - 1; - int nIndex = pElement->m_oBrush.TexturePath.rfind(FILE_SEPARATOR_CHAR); - if (nLen != nIndex) - { - pElement->m_oBrush.TexturePath.erase(nIndex + 1, nLen - nIndex); - } - - pElement->m_oBrush.TexturePath = pElement->m_oBrush.TexturePath + pInfo->GetFileNamePicture(dwOffset); - if (pElement->m_oBrush.Type == c_BrushTypePattern) - { - int rgbColor1 = 0xFFFFFF; - int rgbColor2 = 0; + if (bUseFlipV) + pElement->m_bFlipV = bFlipV; + }break; + case fillType: + { + _UINT32 dwType = pProperty->m_lValue; + switch(dwType) + { + case ODRAW::fillPattern: + { + pElement->m_oBrush.Type = c_BrushTypePattern; + //texture + change black to color2, white to color1 + }break; + case ODRAW::fillTexture : + case ODRAW::fillPicture : + { + pElement->m_oBrush.Type = c_BrushTypeTexture; + pElement->m_oBrush.TextureMode = (ODRAW::fillPicture == dwType) ? c_BrushTextureModeStretch : c_BrushTextureModeTile; + }break; + case ODRAW::fillShadeCenter://1 color + case ODRAW::fillShadeShape: + { + pElement->m_oBrush.Type = c_BrushTypeCenter; + }break;// + case ODRAW::fillShadeTitle://2 colors and more + case ODRAW::fillShade : + case ODRAW::fillShadeScale: + { + pElement->m_oBrush.Type = c_BrushTypePathGradient1; + }break; + case ODRAW::fillBackground: + { + pElement->m_oBrush.Type = c_BrushTypeNoFill; + }break; + } + }break; + case fillBlip: + { + int dwOffset = 0 ; - if (pElement->m_oBrush.Color1.m_lSchemeIndex == -1) - { - rgbColor1 = pElement->m_oBrush.Color1.GetLONG_RGB(); - } - else - { - if ((pSlide) && (pSlide->m_arColorScheme.size() > 0)) - { - rgbColor1 = pSlide->m_arColorScheme[pElement->m_oBrush.Color1.m_lSchemeIndex].GetLONG_RGB(); - } - else if ((pTheme) && (pTheme->m_arColorScheme.size() > 0)) - { - rgbColor1 = pTheme->m_arColorScheme[pElement->m_oBrush.Color1.m_lSchemeIndex].GetLONG_RGB(); - } - } - if (pElement->m_oBrush.Color2.m_lSchemeIndex == -1) - { - rgbColor2 = pElement->m_oBrush.Color2.GetLONG_RGB(); - } - else - { - if ((pSlide) && (pSlide->m_arColorScheme.size() > 0)) - { - rgbColor2 = pSlide->m_arColorScheme[pElement->m_oBrush.Color2.m_lSchemeIndex].GetLONG_RGB(); - } - else if ((pTheme) && (pTheme->m_arColorScheme.size() > 0)) - { - rgbColor2 = pTheme->m_arColorScheme[pElement->m_oBrush.Color2.m_lSchemeIndex].GetLONG_RGB(); - } - } - ChangeBlack2ColorImage(pElement->m_oBrush.TexturePath, rgbColor2, rgbColor1); - - pElement->m_oBrush.Type = c_BrushTypeTexture; - pElement->m_oBrush.TextureMode = c_BrushTextureModeTile; - } - }break; - case fillColor: - { - SColorAtom oAtom; - oAtom.FromValue(pProperty->m_lValue); + if (pProperty->m_bComplex) + { + //inline + dwOffset = -1; + } + else + { + dwOffset = pInfo->GetIndexPicture(pProperty->m_lValue); + } + int nLen = pElement->m_oBrush.TexturePath.length() - 1; + int nIndex = pElement->m_oBrush.TexturePath.rfind(FILE_SEPARATOR_CHAR); + if (nLen != nIndex) + { + pElement->m_oBrush.TexturePath.erase(nIndex + 1, nLen - nIndex); + } - if(oAtom.bSysIndex) - pElement->m_oBrush.Color1 = CorrectSysColor(pProperty->m_lValue, pElement, pTheme); - else - oAtom.ToColor(&pElement->m_oBrush.Color1); + pElement->m_oBrush.TexturePath = pElement->m_oBrush.TexturePath + pInfo->GetFileNamePicture(dwOffset); + if (pElement->m_oBrush.Type == c_BrushTypePattern) + { + int rgbColor1 = 0xFFFFFF; + int rgbColor2 = 0; - if (pElement->m_oBrush.Type == c_BrushTypeNotSet ) - pElement->m_oBrush.Type = c_BrushTypeSolid; - - }break; - case fillBackColor: - { - SColorAtom oAtom; - oAtom.FromValue(pProperty->m_lValue); + if (pElement->m_oBrush.Color1.m_lSchemeIndex == -1) + { + rgbColor1 = pElement->m_oBrush.Color1.GetLONG_RGB(); + } + else + { + if ((pSlide) && (pSlide->m_arColorScheme.size() > 0)) + { + rgbColor1 = pSlide->m_arColorScheme[pElement->m_oBrush.Color1.m_lSchemeIndex].GetLONG_RGB(); + } + else if ((pTheme) && (pTheme->m_arColorScheme.size() > 0)) + { + rgbColor1 = pTheme->m_arColorScheme[pElement->m_oBrush.Color1.m_lSchemeIndex].GetLONG_RGB(); + } + } + if (pElement->m_oBrush.Color2.m_lSchemeIndex == -1) + { + rgbColor2 = pElement->m_oBrush.Color2.GetLONG_RGB(); + } + else + { + if ((pSlide) && (pSlide->m_arColorScheme.size() > 0)) + { + rgbColor2 = pSlide->m_arColorScheme[pElement->m_oBrush.Color2.m_lSchemeIndex].GetLONG_RGB(); + } + else if ((pTheme) && (pTheme->m_arColorScheme.size() > 0)) + { + rgbColor2 = pTheme->m_arColorScheme[pElement->m_oBrush.Color2.m_lSchemeIndex].GetLONG_RGB(); + } + } + ChangeBlack2ColorImage(pElement->m_oBrush.TexturePath, rgbColor2, rgbColor1); - if(oAtom.bSysIndex) - pElement->m_oBrush.Color2 = CorrectSysColor(pProperty->m_lValue, pElement, pTheme); - else - oAtom.ToColor(&pElement->m_oBrush.Color2); - - if (pElement->m_bIsBackground && pElement->m_oBrush.Type == c_BrushTypeNotSet ) - { - pElement->m_oBrush.Type = c_BrushTypeSolid; - } - }break; - case fillOpacity: - { - pElement->m_oBrush.Alpha1 = (BYTE)(std::min)(255, (int)CDirectory::NormFixedPoint(pProperty->m_lValue, 255)); - }break; - case fillBackOpacity: - { - pElement->m_oBrush.Alpha2 = (BYTE)(std::min)(255, (int)CDirectory::NormFixedPoint(pProperty->m_lValue, 255)); - }break; - case fillAngle: - { - pElement->m_oBrush.LinearAngle = FixedPointToDouble(pProperty->m_lValue); - }break; - case fillRectLeft: - { - pElement->m_oBrush.Rect.X = pProperty->m_lValue; - pElement->m_oBrush.Rectable = true; - }break; - case fillRectRight: - { - pElement->m_oBrush.Rect.Width = pProperty->m_lValue - pElement->m_oBrush.Rect.X; - pElement->m_oBrush.Rectable = true; - }break; - case fillRectTop: - { - pElement->m_oBrush.Rect.Y = pProperty->m_lValue; - pElement->m_oBrush.Rectable = true; - }break; - case fillRectBottom: - { - pElement->m_oBrush.Rect.Height = pProperty->m_lValue - pElement->m_oBrush.Rect.Y; - pElement->m_oBrush.Rectable = true; - }break; - case fillBackground: - { - }break; - case fillShadeType: - { - bool bShadeNone = GETBIT(pProperty->m_lValue, 31); - bool bShadeGamma = GETBIT(pProperty->m_lValue, 30); - bool bShadeSigma = GETBIT(pProperty->m_lValue, 29); - bool bShadeBand = GETBIT(pProperty->m_lValue, 28); - bool bShadeOneColor = GETBIT(pProperty->m_lValue, 27); + pElement->m_oBrush.Type = c_BrushTypeTexture; + pElement->m_oBrush.TextureMode = c_BrushTextureModeTile; + } + }break; + case fillColor: + { + SColorAtom oAtom; + oAtom.FromValue(pProperty->m_lValue); - }break; - case fillFocus://relative position of the last color in the shaded fill - { - }break; - case fillShadePreset: - {//value (int) from 0x00000088 through 0x0000009F or complex - }break; - case fillShadeColors: - { - unsigned short nElems = pProperty->m_lValue/8; - _INT32* pCompl = (_INT32*)pProperty->m_pOptions; - - while(nElems--) - { - CColor color; - SColorAtom oAtom; - oAtom.FromValue(*pCompl); pCompl++; - oAtom.ToColor(&color); - - _UINT32 dwPosition = *pCompl; pCompl++; - pElement->m_oBrush.ColorsPosition.push_back(std::pair(color, 100. * FIXED_POINT_unsigned(dwPosition))); - } - }break; - case fillStyleBooleanProperties: - { - BYTE flag1 = (BYTE)(pProperty->m_lValue); - BYTE flag2 = (BYTE)(pProperty->m_lValue >> 16); + if(oAtom.bSysIndex) + pElement->m_oBrush.Color1 = CorrectSysColor(pProperty->m_lValue, pElement, pTheme); + else + oAtom.ToColor(&pElement->m_oBrush.Color1); - bool bNoFillHitTest = (0x01 == (0x01 & flag1)); - bool bFillUseRect = (0x02 == (0x02 & flag1)); - bool bFillShape = (0x04 == (0x04 & flag1)); - bool bHitTestFill = (0x08 == (0x08 & flag1)); - bool bFilled = (0x10 == (0x10 & flag1)); - bool bUseShapeAnchor = (0x20 == (0x20 & flag1)); - bool bRecolorFillAsPictures = (0x40 == (0x40 & flag1)); + if (pElement->m_oBrush.Type == c_BrushTypeNotSet ) + pElement->m_oBrush.Type = c_BrushTypeSolid; - bool bUsebNoFillHitTest = (0x01 == (0x01 & flag2)); - bool bUsebFillUseRect = (0x02 == (0x02 & flag2)); - bool bUsebFillShape = (0x04 == (0x04 & flag2)); - bool bUsebHitTestFill = (0x08 == (0x08 & flag2)); - bool bUsebFilled = (0x10 == (0x10 & flag2)); - bool bUsebUseShapeAnchor = (0x20 == (0x20 & flag2)); - bool bUsebRecolorFillAsPictures = (0x40 == (0x40 & flag2)); + }break; + case fillBackColor: + { + SColorAtom oAtom; + oAtom.FromValue(pProperty->m_lValue); - if (bUsebFilled) - pElement->m_bIsFilled = bFilled; + if(oAtom.bSysIndex) + pElement->m_oBrush.Color2 = CorrectSysColor(pProperty->m_lValue, pElement, pTheme); + else + oAtom.ToColor(&pElement->m_oBrush.Color2); - break; - } - case ODRAW::geometryBooleanProperties: - { - BYTE flag1 = (BYTE)(pProperty->m_lValue); - BYTE flag2 = (BYTE)(pProperty->m_lValue >> 8); - BYTE flag3 = (BYTE)(pProperty->m_lValue >> 16); - BYTE flag4 = (BYTE)(pProperty->m_lValue >> 24); + if (pElement->m_bIsBackground && pElement->m_oBrush.Type == c_BrushTypeNotSet ) + { + pElement->m_oBrush.Type = c_BrushTypeSolid; + } + }break; + case fillOpacity: + { + pElement->m_oBrush.Alpha1 = (BYTE)(std::min)(255, (int)CDirectory::NormFixedPoint(pProperty->m_lValue, 255)); + }break; + case fillBackOpacity: + { + pElement->m_oBrush.Alpha2 = (BYTE)(std::min)(255, (int)CDirectory::NormFixedPoint(pProperty->m_lValue, 255)); + }break; + case fillAngle: + { + pElement->m_oBrush.LinearAngle = FixedPointToDouble(pProperty->m_lValue); + }break; + case fillRectLeft: + { + pElement->m_oBrush.Rect.X = pProperty->m_lValue; + pElement->m_oBrush.Rectable = true; + }break; + case fillRectRight: + { + pElement->m_oBrush.Rect.Width = pProperty->m_lValue - pElement->m_oBrush.Rect.X; + pElement->m_oBrush.Rectable = true; + }break; + case fillRectTop: + { + pElement->m_oBrush.Rect.Y = pProperty->m_lValue; + pElement->m_oBrush.Rectable = true; + }break; + case fillRectBottom: + { + pElement->m_oBrush.Rect.Height = pProperty->m_lValue - pElement->m_oBrush.Rect.Y; + pElement->m_oBrush.Rectable = true; + }break; + case fillBackground: + { + }break; + case fillShadeType: + { + bool bShadeNone = GETBIT(pProperty->m_lValue, 31); + bool bShadeGamma = GETBIT(pProperty->m_lValue, 30); + bool bShadeSigma = GETBIT(pProperty->m_lValue, 29); + bool bShadeBand = GETBIT(pProperty->m_lValue, 28); + bool bShadeOneColor = GETBIT(pProperty->m_lValue, 27); - bool bFillOk = (0x01 == (0x01 & flag1)); - bool bFillShadeShapeOk = (0x02 == (0x02 & flag1)); - bool bGTextOk = (0x04 == (0x04 & flag1)); - bool bLineOk = (0x08 == (0x08 & flag1)); - bool b3DOk = (0x10 == (0x10 & flag1)); - bool bShadowOk = (0x20 == (0x20 & flag1)); + }break; + case fillFocus://relative position of the last color in the shaded fill + { + }break; + case fillShadePreset: + {//value (int) from 0x00000088 through 0x0000009F or complex + }break; + case fillShadeColors: + { + unsigned short nElems = pProperty->m_lValue/8; + _INT32* pCompl = (_INT32*)pProperty->m_pOptions; - bool bUseFillOk = (0x01 == (0x01 & flag3)); - bool bUseFillShadeShapeOk = (0x02 == (0x02 & flag3)); - bool bUseGTextOk = (0x04 == (0x04 & flag3)); - bool bUseLineOk = (0x08 == (0x08 & flag3)); - bool bUse3DOk = (0x10 == (0x10 & flag3)); - bool bUseShadowOk = (0x20 == (0x20 & flag3)); + while(nElems--) + { + CColor color; + SColorAtom oAtom; + oAtom.FromValue(*pCompl); pCompl++; + oAtom.ToColor(&color); - //if (bUseLineOk) - // pElement->m_bLine = bLineOk;//?? todooo проверить - не сраюатывает ! 1 (82).ppt + _UINT32 dwPosition = *pCompl; pCompl++; + pElement->m_oBrush.ColorsPosition.push_back(std::pair(color, 100. * FIXED_POINT_unsigned(dwPosition))); + } + }break; + case fillStyleBooleanProperties: + { + BYTE flag1 = (BYTE)(pProperty->m_lValue); + BYTE flag2 = (BYTE)(pProperty->m_lValue >> 16); - if (bUseFillOk) - pElement->m_bIsFilled = bFillOk; + bool bNoFillHitTest = (0x01 == (0x01 & flag1)); + bool bFillUseRect = (0x02 == (0x02 & flag1)); + bool bFillShape = (0x04 == (0x04 & flag1)); + bool bHitTestFill = (0x08 == (0x08 & flag1)); + bool bFilled = (0x10 == (0x10 & flag1)); + bool bUseShapeAnchor = (0x20 == (0x20 & flag1)); + bool bRecolorFillAsPictures = (0x40 == (0x40 & flag1)); - break; - } -// line -------------------------------------------------------- - case lineStyleBooleanProperties: //Line Style Boolean Properties - { - bool bUsefLineOpaqueBackColor = GETBIT(pProperty->m_lValue, 25); - bool bUsefInsetPen = GETBIT(pProperty->m_lValue, 22); - bool bUsefInsetPenOK = GETBIT(pProperty->m_lValue, 21); - bool bUsefArrowheadsOK = GETBIT(pProperty->m_lValue, 20); - bool bUsefLine = GETBIT(pProperty->m_lValue, 19); - bool bUsefHitTestLine = GETBIT(pProperty->m_lValue, 18); - bool bUsefLineFillShape = GETBIT(pProperty->m_lValue, 17); - bool bUsefNoLineDrawDash = GETBIT(pProperty->m_lValue, 16); + bool bUsebNoFillHitTest = (0x01 == (0x01 & flag2)); + bool bUsebFillUseRect = (0x02 == (0x02 & flag2)); + bool bUsebFillShape = (0x04 == (0x04 & flag2)); + bool bUsebHitTestFill = (0x08 == (0x08 & flag2)); + bool bUsebFilled = (0x10 == (0x10 & flag2)); + bool bUsebUseShapeAnchor = (0x20 == (0x20 & flag2)); + bool bUsebRecolorFillAsPictures = (0x40 == (0x40 & flag2)); - bool bLineOpaqueBackColor = GETBIT(pProperty->m_lValue, 9); - bool bInsetPen = GETBIT(pProperty->m_lValue, 6); - bool bInsetPenOK = GETBIT(pProperty->m_lValue, 5); - bool bArrowheadsOK = GETBIT(pProperty->m_lValue, 4); - bool bLine = GETBIT(pProperty->m_lValue, 3); - bool bHitTestLine = GETBIT(pProperty->m_lValue, 2); - bool bLineFillShape = GETBIT(pProperty->m_lValue, 1); - bool bNoLineDrawDash = GETBIT(pProperty->m_lValue, 0); + if (bUsebFilled) + pElement->m_bIsFilled = bFilled; - if (bUsefLine) - pElement->m_bLine = bLine; - }break; - case lineDashStyle://from Complex - { - pElement->m_bLine = true; - }break; - case lineColor: - { - pElement->m_bLine = true; - - SColorAtom oAtom; - oAtom.FromValue(pProperty->m_lValue); - - if (oAtom.bSysIndex) - pElement->m_oPen.Color = CorrectSysColor(pProperty->m_lValue, pElement, pTheme); - else - oAtom.ToColor(&pElement->m_oPen.Color); - }break; - case lineOpacity: - { - pElement->m_oPen.Alpha = (BYTE)(std::min)(255, (int)CDirectory::NormFixedPoint(pProperty->m_lValue, 255)); - }break; - case lineBackColor: - { - SColorAtom oAtom; - oAtom.FromValue(pProperty->m_lValue); - - if (oAtom.bSysIndex) - pElement->m_oPen.Color2 = CorrectSysColor(pProperty->m_lValue, pElement, pTheme); - else - oAtom.ToColor(&pElement->m_oPen.Color2); + break; + } + case ODRAW::geometryBooleanProperties: + { + BYTE flag1 = (BYTE)(pProperty->m_lValue); + BYTE flag2 = (BYTE)(pProperty->m_lValue >> 8); + BYTE flag3 = (BYTE)(pProperty->m_lValue >> 16); + BYTE flag4 = (BYTE)(pProperty->m_lValue >> 24); - }break; - case lineWidth: - { - pElement->m_oPen.Size = pProperty->m_lValue; - pElement->m_bLine = true; - }break; - case lineStyle: - { - pElement->m_bLine = true; - pElement->m_oPen.LineStyle = pProperty->m_lValue; - }break; - case lineDashing: - { - pElement->m_bLine = true; - pElement->m_oPen.DashStyle = pProperty->m_lValue; - }break; - case lineJoinStyle: - { - pElement->m_oPen.LineJoin = pProperty->m_lValue; - }break; - case lineStartArrowLength: - { - pElement->m_oPen.LineStartLength = pProperty->m_lValue; - }break; - case lineEndArrowLength: - { - pElement->m_oPen.LineEndLength = pProperty->m_lValue; - }break; - case lineStartArrowWidth: - { - pElement->m_oPen.LineStartWidth = pProperty->m_lValue; - }break; - case lineEndArrowWidth: - { - pElement->m_oPen.LineEndWidth = pProperty->m_lValue; - }break; - case lineStartArrowhead: - { - pElement->m_oPen.LineStartCap = pProperty->m_lValue; - }break; - case lineEndArrowhead: - { - pElement->m_oPen.LineEndCap = pProperty->m_lValue; - }break; - case shadowType: - { - pElement->m_oShadow.Type = pProperty->m_lValue; - }break; - case shadowOriginX://in emu, relative from center shape - { - pElement->m_oShadow.OriginX = FixedPointToDouble(pProperty->m_lValue); - }break; - case shadowOriginY: - { - pElement->m_oShadow.OriginY = FixedPointToDouble(pProperty->m_lValue); - }break; - case shadowColor: - { - SColorAtom oAtom; - oAtom.FromValue(pProperty->m_lValue); + bool bFillOk = (0x01 == (0x01 & flag1)); + bool bFillShadeShapeOk = (0x02 == (0x02 & flag1)); + bool bGTextOk = (0x04 == (0x04 & flag1)); + bool bLineOk = (0x08 == (0x08 & flag1)); + bool b3DOk = (0x10 == (0x10 & flag1)); + bool bShadowOk = (0x20 == (0x20 & flag1)); - if (oAtom.bSysIndex) - pElement->m_oShadow.Color = CorrectSysColor(pProperty->m_lValue, pElement, pTheme); - else - oAtom.ToColor(&pElement->m_oShadow.Color); + bool bUseFillOk = (0x01 == (0x01 & flag3)); + bool bUseFillShadeShapeOk = (0x02 == (0x02 & flag3)); + bool bUseGTextOk = (0x04 == (0x04 & flag3)); + bool bUseLineOk = (0x08 == (0x08 & flag3)); + bool bUse3DOk = (0x10 == (0x10 & flag3)); + bool bUseShadowOk = (0x20 == (0x20 & flag3)); - }break; - case shadowWeight: - { - }break; - case shadowOpacity: - { + //if (bUseLineOk) + // pElement->m_bLine = bLineOk;//?? todooo проверить - не сраюатывает ! 1 (82).ppt + + if (bUseFillOk) + pElement->m_bIsFilled = bFillOk; + + break; + } + // line -------------------------------------------------------- + case lineStyleBooleanProperties: //Line Style Boolean Properties + { + bool bUsefLineOpaqueBackColor = GETBIT(pProperty->m_lValue, 25); + bool bUsefInsetPen = GETBIT(pProperty->m_lValue, 22); + bool bUsefInsetPenOK = GETBIT(pProperty->m_lValue, 21); + bool bUsefArrowheadsOK = GETBIT(pProperty->m_lValue, 20); + bool bUsefLine = GETBIT(pProperty->m_lValue, 19); + bool bUsefHitTestLine = GETBIT(pProperty->m_lValue, 18); + bool bUsefLineFillShape = GETBIT(pProperty->m_lValue, 17); + bool bUsefNoLineDrawDash = GETBIT(pProperty->m_lValue, 16); + + bool bLineOpaqueBackColor = GETBIT(pProperty->m_lValue, 9); + bool bInsetPen = GETBIT(pProperty->m_lValue, 6); + bool bInsetPenOK = GETBIT(pProperty->m_lValue, 5); + bool bArrowheadsOK = GETBIT(pProperty->m_lValue, 4); + bool bLine = GETBIT(pProperty->m_lValue, 3); + bool bHitTestLine = GETBIT(pProperty->m_lValue, 2); + bool bLineFillShape = GETBIT(pProperty->m_lValue, 1); + bool bNoLineDrawDash = GETBIT(pProperty->m_lValue, 0); + + if (bUsefLine) + pElement->m_bLine = bLine; + }break; + case lineDashStyle://from Complex + { + pElement->m_bLine = true; + }break; + case lineColor: + { + pElement->m_bLine = true; + + SColorAtom oAtom; + oAtom.FromValue(pProperty->m_lValue); + + if (oAtom.bSysIndex) + pElement->m_oPen.Color = CorrectSysColor(pProperty->m_lValue, pElement, pTheme); + else + oAtom.ToColor(&pElement->m_oPen.Color); + }break; + case lineOpacity: + { + pElement->m_oPen.Alpha = (BYTE)(std::min)(255, (int)CDirectory::NormFixedPoint(pProperty->m_lValue, 255)); + }break; + case lineBackColor: + { + SColorAtom oAtom; + oAtom.FromValue(pProperty->m_lValue); + + if (oAtom.bSysIndex) + pElement->m_oPen.Color2 = CorrectSysColor(pProperty->m_lValue, pElement, pTheme); + else + oAtom.ToColor(&pElement->m_oPen.Color2); + + }break; + case lineWidth: + { + pElement->m_oPen.Size = pProperty->m_lValue; + pElement->m_bLine = true; + }break; + case lineStyle: + { + pElement->m_bLine = true; + pElement->m_oPen.LineStyle = pProperty->m_lValue; + }break; + case lineDashing: + { + pElement->m_bLine = true; + pElement->m_oPen.DashStyle = pProperty->m_lValue; + }break; + case lineJoinStyle: + { + pElement->m_oPen.LineJoin = pProperty->m_lValue; + }break; + case lineStartArrowLength: + { + pElement->m_oPen.LineStartLength = pProperty->m_lValue; + }break; + case lineEndArrowLength: + { + pElement->m_oPen.LineEndLength = pProperty->m_lValue; + }break; + case lineStartArrowWidth: + { + pElement->m_oPen.LineStartWidth = pProperty->m_lValue; + }break; + case lineEndArrowWidth: + { + pElement->m_oPen.LineEndWidth = pProperty->m_lValue; + }break; + case lineStartArrowhead: + { + pElement->m_oPen.LineStartCap = pProperty->m_lValue; + }break; + case lineEndArrowhead: + { + pElement->m_oPen.LineEndCap = pProperty->m_lValue; + }break; + case shadowType: + { + pElement->m_oShadow.Type = pProperty->m_lValue; + }break; + case shadowOriginX://in emu, relative from center shape + { + pElement->m_oShadow.OriginX = FixedPointToDouble(pProperty->m_lValue); + }break; + case shadowOriginY: + { + pElement->m_oShadow.OriginY = FixedPointToDouble(pProperty->m_lValue); + }break; + case shadowColor: + { + SColorAtom oAtom; + oAtom.FromValue(pProperty->m_lValue); + + if (oAtom.bSysIndex) + pElement->m_oShadow.Color = CorrectSysColor(pProperty->m_lValue, pElement, pTheme); + else + oAtom.ToColor(&pElement->m_oShadow.Color); + + }break; + case shadowWeight: + { + }break; + case shadowOpacity: + { pElement->m_oShadow.Alpha = (BYTE)(std::min)(255, (int)CDirectory::NormFixedPoint(pProperty->m_lValue, 255)); - }break; - case shadowHighlight: - { - //оттенок двойной тени - }break; - case shadowOffsetX: - {//signed - pElement->m_oShadow.DistanceX = (_INT32)pProperty->m_lValue; - }break; - case shadowOffsetY: - {//signed - pElement->m_oShadow.DistanceY = (_INT32)pProperty->m_lValue; - }break; - case shadowScaleXToX: - { - pElement->m_oShadow.ScaleXToX = FixedPointToDouble(pProperty->m_lValue); - }break; - case shadowScaleYToX: - { - pElement->m_oShadow.ScaleYToX = FixedPointToDouble(pProperty->m_lValue); - }break; - case shadowScaleXToY: - { - pElement->m_oShadow.ScaleXToY = FixedPointToDouble(pProperty->m_lValue); - }break; - case shadowScaleYToY: - { - pElement->m_oShadow.ScaleYToY = FixedPointToDouble(pProperty->m_lValue); - }break; - case shadowPerspectiveX: - { - pElement->m_oShadow.PerspectiveX = pProperty->m_lValue; - }break; - case shadowPerspectiveY: - { - pElement->m_oShadow.PerspectiveY = pProperty->m_lValue; - }break; - case shadowStyleBooleanProperties: - { - bool fshadowObscured = GETBIT(pProperty->m_lValue, 0); - bool fShadow = GETBIT(pProperty->m_lValue, 1); - bool fUsefshadowObscured = GETBIT(pProperty->m_lValue, 16); - bool fUsefShadow = GETBIT(pProperty->m_lValue, 17); + }break; + case shadowHighlight: + { + //оттенок двойной тени + }break; + case shadowOffsetX: + {//signed + pElement->m_oShadow.DistanceX = (_INT32)pProperty->m_lValue; + }break; + case shadowOffsetY: + {//signed + pElement->m_oShadow.DistanceY = (_INT32)pProperty->m_lValue; + }break; + case shadowScaleXToX: + { + pElement->m_oShadow.ScaleXToX = FixedPointToDouble(pProperty->m_lValue); + }break; + case shadowScaleYToX: + { + pElement->m_oShadow.ScaleYToX = FixedPointToDouble(pProperty->m_lValue); + }break; + case shadowScaleXToY: + { + pElement->m_oShadow.ScaleXToY = FixedPointToDouble(pProperty->m_lValue); + }break; + case shadowScaleYToY: + { + pElement->m_oShadow.ScaleYToY = FixedPointToDouble(pProperty->m_lValue); + }break; + case shadowPerspectiveX: + { + pElement->m_oShadow.PerspectiveX = pProperty->m_lValue; + }break; + case shadowPerspectiveY: + { + pElement->m_oShadow.PerspectiveY = pProperty->m_lValue; + }break; + case shadowStyleBooleanProperties: + { + bool fshadowObscured = GETBIT(pProperty->m_lValue, 0); + bool fShadow = GETBIT(pProperty->m_lValue, 1); + bool fUsefshadowObscured = GETBIT(pProperty->m_lValue, 16); + bool fUsefShadow = GETBIT(pProperty->m_lValue, 17); - if (fUsefShadow) - pElement->m_oShadow.Visible = fShadow; - - if (!fUsefShadow && fUsefshadowObscured) - { - //контурная - pElement->m_oShadow.Visible = fshadowObscured; - } - }break; - case shapeBoolean: - { - bool fUsefPolicyLabel = GETBIT(pProperty->m_lValue, 25); - bool fUsefPolicyBarcode = GETBIT(pProperty->m_lValue, 24); - bool fUsefFlipHOverride = GETBIT(pProperty->m_lValue, 23); - bool fUsefFlipVOverride = GETBIT(pProperty->m_lValue, 22); - bool fUsefOleIcon = GETBIT(pProperty->m_lValue, 21); - bool fUsefPreferRelativeResize = GETBIT(pProperty->m_lValue, 20); - bool fUsefLockShapeType = GETBIT(pProperty->m_lValue, 19); - bool fUsefInitiator = GETBIT(pProperty->m_lValue, 18); - bool fUsefBackground = GETBIT(pProperty->m_lValue, 16); - - bool fPolicyLabel = fUsefPolicyLabel ? GETBIT(pProperty->m_lValue, 9) : false; - bool fPolicyBarcode = fUsefPolicyBarcode ? GETBIT(pProperty->m_lValue, 8) : false; - bool fFlipHOverride = fUsefFlipHOverride ? GETBIT(pProperty->m_lValue, 7) : false; - bool fFlipVOverride = fUsefFlipVOverride ? GETBIT(pProperty->m_lValue, 6) : false; - bool fOleIcon = fUsefOleIcon ? GETBIT(pProperty->m_lValue, 5) : false; - bool fPreferRelativeResize = fUsefPreferRelativeResize ? GETBIT(pProperty->m_lValue, 4) : false; - bool fLockShapeType = fUsefLockShapeType ? GETBIT(pProperty->m_lValue, 3) : false; - bool fInitiator = fUsefInitiator ? GETBIT(pProperty->m_lValue, 2) : false; - bool fBackground = fUsefBackground ? GETBIT(pProperty->m_lValue, 0) : false; - }break; - case groupShapeBooleanProperties: - { - bool fUsefLayoutInCell = GETBIT(pProperty->m_lValue, 31); - bool fUsefIsBullet = GETBIT(pProperty->m_lValue, 30); - bool fUsefStandardHR = GETBIT(pProperty->m_lValue, 29); - bool fUsefNoshadeHR = GETBIT(pProperty->m_lValue, 28); - bool fUsefHorizRule = GETBIT(pProperty->m_lValue, 27); - bool fUsefUserDrawn = GETBIT(pProperty->m_lValue, 26); - bool fUsefAllowOverlap = GETBIT(pProperty->m_lValue, 25); - bool fUsefReallyHidden = GETBIT(pProperty->m_lValue, 24); - bool fUsefScriptAnchor = GETBIT(pProperty->m_lValue, 23); - bool fUsefEditedWrap = GETBIT(pProperty->m_lValue, 22); - bool fUsefBehindDocument = GETBIT(pProperty->m_lValue, 21); - bool fUsefOnDblClickNotify = GETBIT(pProperty->m_lValue, 20); - bool fUsefIsButton = GETBIT(pProperty->m_lValue, 19); - bool fUsefOneD = GETBIT(pProperty->m_lValue, 18); - bool fUsefHidden = GETBIT(pProperty->m_lValue, 17); - bool fUsefPrint = GETBIT(pProperty->m_lValue, 16); - - bool fLayoutInCell = fUsefLayoutInCell ? GETBIT(pProperty->m_lValue, 15) : true; - bool fIsBullet = fUsefIsBullet ? GETBIT(pProperty->m_lValue, 14) : false; - bool fStandardHR = fUsefStandardHR ? GETBIT(pProperty->m_lValue, 13) : false; - bool fNoshadeHR = fUsefNoshadeHR ? GETBIT(pProperty->m_lValue, 12) : false; - bool fHorizRule = fUsefHorizRule ? GETBIT(pProperty->m_lValue, 11) : false; - bool fUserDrawn = fUsefUserDrawn ? GETBIT(pProperty->m_lValue, 10) : false; - bool fAllowOverlap = fUsefAllowOverlap ? GETBIT(pProperty->m_lValue, 9) : true; - bool fReallyHidden = fUsefReallyHidden ? GETBIT(pProperty->m_lValue, 8) : false; - bool fScriptAnchor = fUsefScriptAnchor ? GETBIT(pProperty->m_lValue, 7) : false; - bool fEditedWrap = fUsefEditedWrap ? GETBIT(pProperty->m_lValue, 6) : false; - bool fBehindDocument = fUsefBehindDocument ? GETBIT(pProperty->m_lValue, 5) : false; - bool fOnDblClickNotify = fUsefOnDblClickNotify ? GETBIT(pProperty->m_lValue, 4) : false; - bool fIsButton = fUsefIsButton ? GETBIT(pProperty->m_lValue, 3) : false; - bool fOneD = fUsefOneD ? GETBIT(pProperty->m_lValue, 2) : false; - bool fHidden = fUsefHidden ? GETBIT(pProperty->m_lValue, 1) : false; - bool fPrint = fUsefPrint ? GETBIT(pProperty->m_lValue, 0) : true; + if (fUsefShadow) + pElement->m_oShadow.Visible = fShadow; - pElement->m_bHidden = fHidden || fIsBullet; - //presentation_ticio_20100610.ppt - }break; - default: - break; - } + if (!fUsefShadow && fUsefshadowObscured) + { + //контурная + pElement->m_oShadow.Visible = fshadowObscured; + } + }break; + case shapeBoolean: + { + bool fUsefPolicyLabel = GETBIT(pProperty->m_lValue, 25); + bool fUsefPolicyBarcode = GETBIT(pProperty->m_lValue, 24); + bool fUsefFlipHOverride = GETBIT(pProperty->m_lValue, 23); + bool fUsefFlipVOverride = GETBIT(pProperty->m_lValue, 22); + bool fUsefOleIcon = GETBIT(pProperty->m_lValue, 21); + bool fUsefPreferRelativeResize = GETBIT(pProperty->m_lValue, 20); + bool fUsefLockShapeType = GETBIT(pProperty->m_lValue, 19); + bool fUsefInitiator = GETBIT(pProperty->m_lValue, 18); + bool fUsefBackground = GETBIT(pProperty->m_lValue, 16); + + bool fPolicyLabel = fUsefPolicyLabel ? GETBIT(pProperty->m_lValue, 9) : false; + bool fPolicyBarcode = fUsefPolicyBarcode ? GETBIT(pProperty->m_lValue, 8) : false; + bool fFlipHOverride = fUsefFlipHOverride ? GETBIT(pProperty->m_lValue, 7) : false; + bool fFlipVOverride = fUsefFlipVOverride ? GETBIT(pProperty->m_lValue, 6) : false; + bool fOleIcon = fUsefOleIcon ? GETBIT(pProperty->m_lValue, 5) : false; + bool fPreferRelativeResize = fUsefPreferRelativeResize ? GETBIT(pProperty->m_lValue, 4) : false; + bool fLockShapeType = fUsefLockShapeType ? GETBIT(pProperty->m_lValue, 3) : false; + bool fInitiator = fUsefInitiator ? GETBIT(pProperty->m_lValue, 2) : false; + bool fBackground = fUsefBackground ? GETBIT(pProperty->m_lValue, 0) : false; + }break; + case groupShapeBooleanProperties: + { + bool fUsefLayoutInCell = GETBIT(pProperty->m_lValue, 31); + bool fUsefIsBullet = GETBIT(pProperty->m_lValue, 30); + bool fUsefStandardHR = GETBIT(pProperty->m_lValue, 29); + bool fUsefNoshadeHR = GETBIT(pProperty->m_lValue, 28); + bool fUsefHorizRule = GETBIT(pProperty->m_lValue, 27); + bool fUsefUserDrawn = GETBIT(pProperty->m_lValue, 26); + bool fUsefAllowOverlap = GETBIT(pProperty->m_lValue, 25); + bool fUsefReallyHidden = GETBIT(pProperty->m_lValue, 24); + bool fUsefScriptAnchor = GETBIT(pProperty->m_lValue, 23); + bool fUsefEditedWrap = GETBIT(pProperty->m_lValue, 22); + bool fUsefBehindDocument = GETBIT(pProperty->m_lValue, 21); + bool fUsefOnDblClickNotify = GETBIT(pProperty->m_lValue, 20); + bool fUsefIsButton = GETBIT(pProperty->m_lValue, 19); + bool fUsefOneD = GETBIT(pProperty->m_lValue, 18); + bool fUsefHidden = GETBIT(pProperty->m_lValue, 17); + bool fUsefPrint = GETBIT(pProperty->m_lValue, 16); + + bool fLayoutInCell = fUsefLayoutInCell ? GETBIT(pProperty->m_lValue, 15) : true; + bool fIsBullet = fUsefIsBullet ? GETBIT(pProperty->m_lValue, 14) : false; + bool fStandardHR = fUsefStandardHR ? GETBIT(pProperty->m_lValue, 13) : false; + bool fNoshadeHR = fUsefNoshadeHR ? GETBIT(pProperty->m_lValue, 12) : false; + bool fHorizRule = fUsefHorizRule ? GETBIT(pProperty->m_lValue, 11) : false; + bool fUserDrawn = fUsefUserDrawn ? GETBIT(pProperty->m_lValue, 10) : false; + bool fAllowOverlap = fUsefAllowOverlap ? GETBIT(pProperty->m_lValue, 9) : true; + bool fReallyHidden = fUsefReallyHidden ? GETBIT(pProperty->m_lValue, 8) : false; + bool fScriptAnchor = fUsefScriptAnchor ? GETBIT(pProperty->m_lValue, 7) : false; + bool fEditedWrap = fUsefEditedWrap ? GETBIT(pProperty->m_lValue, 6) : false; + bool fBehindDocument = fUsefBehindDocument ? GETBIT(pProperty->m_lValue, 5) : false; + bool fOnDblClickNotify = fUsefOnDblClickNotify ? GETBIT(pProperty->m_lValue, 4) : false; + bool fIsButton = fUsefIsButton ? GETBIT(pProperty->m_lValue, 3) : false; + bool fOneD = fUsefOneD ? GETBIT(pProperty->m_lValue, 2) : false; + bool fHidden = fUsefHidden ? GETBIT(pProperty->m_lValue, 1) : false; + bool fPrint = fUsefPrint ? GETBIT(pProperty->m_lValue, 0) : true; + + pElement->m_bHidden = fHidden || fIsBullet; + //presentation_ticio_20100610.ppt + }break; + default: + break; + } } void CPPTElement::SetUpPropertyVideo(CElementPtr pElement, CTheme* pTheme, CSlideInfo* pInfo, CSlide* pSlide, CProperty* pProperty) { - SetUpPropertyImage(pElement, pTheme, pInfo, pSlide, pProperty); + SetUpPropertyImage(pElement, pTheme, pInfo, pSlide, pProperty); } void CPPTElement::SetUpPropertyAudio(CElementPtr pElement, CTheme* pTheme, CSlideInfo* pInfo, CSlide* pSlide, CProperty* pProperty) { - SetUpPropertyImage(pElement, pTheme, pInfo, pSlide, pProperty); + SetUpPropertyImage(pElement, pTheme, pInfo, pSlide, pProperty); } void CPPTElement::SetUpPropertyImage(CElementPtr pElement, CTheme* pTheme, CSlideInfo* pInfo, CSlide* pSlide, CProperty* pProperty) { - SetUpProperty(pElement, pTheme, pInfo, pSlide, pProperty); + SetUpProperty(pElement, pTheme, pInfo, pSlide, pProperty); - CImageElement* image_element = dynamic_cast(pElement.get()); + CImageElement* image_element = dynamic_cast(pElement.get()); - switch(pProperty->m_ePID) - { - case pib: - { - int dwOffset = pInfo->GetIndexPicture(pProperty->m_lValue); - if (dwOffset >=0) - { - image_element->m_strImageFileName += pInfo->GetFileNamePicture(dwOffset); - image_element->m_bImagePresent = true; - } - }break; - case pictureId://OLE identifier of the picture. - { - image_element->m_bOLE = true; - }break; - case pibName: - { - image_element->m_sImageName = NSFile::CUtf8Converter::GetWStringFromUTF16((unsigned short*)pProperty->m_pOptions, pProperty->m_lValue /2-1); - // TextMining05.ppt, слайд 20 - некорректное имя ( - todooo потом подчистить его - }break; - case cropFromTop: - { - image_element->m_lcropFromTop = (_INT32)pProperty->m_lValue; - image_element->m_bCropEnabled = true; - }break; - case cropFromBottom: - { - image_element->m_lcropFromBottom = (_INT32)pProperty->m_lValue; - image_element->m_bCropEnabled = true; - }break; - case cropFromLeft: - { - image_element->m_lcropFromLeft = (_INT32)pProperty->m_lValue; - image_element->m_bCropEnabled = true; - }break; - case cropFromRight: - { - image_element->m_lcropFromRight = (_INT32)pProperty->m_lValue; - image_element->m_bCropEnabled = true; - }break; - case pibFlags: - { - }break; - } + switch(pProperty->m_ePID) + { + case pib: + { + int dwOffset = pInfo->GetIndexPicture(pProperty->m_lValue); + if (dwOffset >=0) + { + image_element->m_strImageFileName += pInfo->GetFileNamePicture(dwOffset); + image_element->m_bImagePresent = true; + } + }break; + case pictureId://OLE identifier of the picture. + { + image_element->m_bOLE = true; + }break; + case pibName: + { + image_element->m_sImageName = NSFile::CUtf8Converter::GetWStringFromUTF16((unsigned short*)pProperty->m_pOptions, pProperty->m_lValue /2-1); + // TextMining05.ppt, слайд 20 - некорректное имя ( - todooo потом подчистить его + }break; + case cropFromTop: + { + image_element->m_lcropFromTop = (_INT32)pProperty->m_lValue; + image_element->m_bCropEnabled = true; + }break; + case cropFromBottom: + { + image_element->m_lcropFromBottom = (_INT32)pProperty->m_lValue; + image_element->m_bCropEnabled = true; + }break; + case cropFromLeft: + { + image_element->m_lcropFromLeft = (_INT32)pProperty->m_lValue; + image_element->m_bCropEnabled = true; + }break; + case cropFromRight: + { + image_element->m_lcropFromRight = (_INT32)pProperty->m_lValue; + image_element->m_bCropEnabled = true; + }break; + case pibFlags: + { + }break; + } } void CPPTElement::SetUpPropertyShape(CElementPtr pElement, CTheme* pTheme, CSlideInfo* pInfo, CSlide* pSlide, CProperty* pProperty) { - SetUpProperty(pElement, pTheme, pInfo, pSlide, pProperty); + SetUpProperty(pElement, pTheme, pInfo, pSlide, pProperty); - CShapeElement* shape_element = dynamic_cast(pElement.get()); + CShapeElement* shape_element = dynamic_cast(pElement.get()); - CShapePtr pParentShape = shape_element->m_pShape; - if (NULL == pParentShape) - return; + CShapePtr pParentShape = shape_element->m_pShape; + if (NULL == pParentShape) + return; - CPPTShape* pShape = dynamic_cast(pParentShape->getBaseShape().get()); + CPPTShape* pShape = dynamic_cast(pParentShape->getBaseShape().get()); - if (NULL == pShape) - return; + if (NULL == pShape) + return; - switch (pProperty->m_ePID) - { - case ODRAW::metroBlob: - { - NSFile::CFileBinary file; + switch (pProperty->m_ePID) + { + case ODRAW::metroBlob: + { + NSFile::CFileBinary file; std::wstring temp = NSDirectory::GetTempPath(); - std::wstring tempFileName = temp + FILE_SEPARATOR_STR + L"tempMetroBlob.zip"; + std::wstring tempFileName = temp + FILE_SEPARATOR_STR + L"tempMetroBlob.zip"; - if (file.CreateFileW(tempFileName)) - { - file.WriteFile(pProperty->m_pOptions, pProperty->m_lValue); - file.CloseFile(); - } - COfficeUtils officeUtils(NULL); + if (file.CreateFileW(tempFileName)) + { + file.WriteFile(pProperty->m_pOptions, pProperty->m_lValue); + file.CloseFile(); + } + COfficeUtils officeUtils(NULL); - BYTE *utf8Data = NULL; - ULONG utf8DataSize = 0; - if (S_OK != officeUtils.LoadFileFromArchive(tempFileName, L"drs/shapexml.xml", &utf8Data, utf8DataSize)) - { - officeUtils.LoadFileFromArchive(tempFileName, L"drs/diagrams/drawing1.xml", &utf8Data, utf8DataSize); - } + BYTE *utf8Data = NULL; + ULONG utf8DataSize = 0; + if (S_OK != officeUtils.LoadFileFromArchive(tempFileName, L"drs/shapexml.xml", &utf8Data, utf8DataSize)) + { + officeUtils.LoadFileFromArchive(tempFileName, L"drs/diagrams/drawing1.xml", &utf8Data, utf8DataSize); + } - if (utf8Data && utf8DataSize > 0) - { - pParentShape->m_strXmlString = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8(utf8Data, utf8DataSize); + if (utf8Data && utf8DataSize > 0) + { + pParentShape->m_strXmlString = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8(utf8Data, utf8DataSize); - delete []utf8Data; - } - NSFile::CFileBinary::Remove(tempFileName); - }break; - case ODRAW::geoRight: - { - if (0 < pProperty->m_lValue) - pParentShape->m_dWidthLogic = (double)(pProperty->m_lValue); - }break; - case ODRAW::geoBottom: - { - if (0 < pProperty->m_lValue) - pParentShape->m_dHeightLogic = (double)(pProperty->m_lValue); - }break; - case ODRAW::shapePath: - { - pShape->m_oCustomVML.SetPath((RulesType)pProperty->m_lValue); - pShape->m_bCustomShape = true; - }break; - case ODRAW::pSegmentInfo: - { - if (pProperty->m_bComplex) - { - pShape->m_oCustomVML.LoadSegments(pProperty); - pShape->m_bCustomShape = true; - } - }break; - case ODRAW::pVertices: - { - if (pProperty->m_bComplex) - { - pShape->m_oCustomVML.LoadVertices(pProperty); - pShape->m_bCustomShape = true; - } - }break; - case ODRAW::pConnectionSites: - { - if (pProperty->m_bComplex) - { - pShape->m_oCustomVML.LoadConnectionSites(pProperty); - } - }break; - case ODRAW::pConnectionSitesDir: - { - if (pProperty->m_bComplex) - { - pShape->m_oCustomVML.LoadConnectionSitesDir(pProperty); - } - }break; - case ODRAW::pGuides: - { - if (pProperty->m_bComplex/* && pShape->m_eType != sptNotchedCircularArrow*/) - {//Тікбұрышты үшбұрыштарды.ppt - slide 25 - pShape->m_oCustomVML.LoadGuides(pProperty); - } - }break; - case ODRAW::pInscribe: - { - if (pProperty->m_bComplex) - { - pShape->m_oCustomVML.LoadInscribe(pProperty); - } - }break; - case ODRAW::pAdjustHandles: - { - if (pProperty->m_bComplex) - { - pShape->m_oCustomVML.LoadAHs(pProperty); - } - }break; - case ODRAW::adjustValue: - case ODRAW::adjust2Value: - case ODRAW::adjust3Value: - case ODRAW::adjust4Value: - case ODRAW::adjust5Value: - case ODRAW::adjust6Value: - case ODRAW::adjust7Value: - case ODRAW::adjust8Value: - case ODRAW::adjust9Value: - case ODRAW::adjust10Value: - { - LONG lIndexAdj = pProperty->m_ePID - ODRAW::adjustValue; - if (lIndexAdj >= 0 && lIndexAdj < (LONG)pShape->m_arAdjustments.size()) - { - pShape->m_oCustomVML.LoadAdjusts(lIndexAdj, (LONG)pProperty->m_lValue); - } - else - { - pShape->m_oCustomVML.LoadAdjusts(lIndexAdj, (LONG)pProperty->m_lValue); - } - }break; -//-------------------------------------------------------------------------------------------------------------------- - case lTxid: - { - }break; - case ODRAW::dxTextLeft: - { - pParentShape->m_dTextMarginX = pProperty->m_lValue; - }break; - case ODRAW::dxTextRight: - { - pParentShape->m_dTextMarginRight = pProperty->m_lValue; - }break; - case ODRAW::dyTextTop: - { - pParentShape->m_dTextMarginY = pProperty->m_lValue; - }break; - case ODRAW::dyTextBottom: - { - pParentShape->m_dTextMarginBottom = pProperty->m_lValue; - }break; - case ODRAW::WrapText: - { - pParentShape->m_oText.m_lWrapMode = (LONG)pProperty->m_lValue; - }break; - case ODRAW::gtextUNICODE://word art text - { - if (pProperty->m_bComplex && 0 < pProperty->m_lValue) - { - std::wstring str = NSFile::CUtf8Converter::GetWStringFromUTF16((unsigned short*)pProperty->m_pOptions, pProperty->m_lValue/2-1); + delete []utf8Data; + } + NSFile::CFileBinary::Remove(tempFileName); + }break; + case ODRAW::geoRight: + { + if (0 < pProperty->m_lValue) + pParentShape->m_dWidthLogic = (double)(pProperty->m_lValue); + }break; + case ODRAW::geoBottom: + { + if (0 < pProperty->m_lValue) + pParentShape->m_dHeightLogic = (double)(pProperty->m_lValue); + }break; + case ODRAW::shapePath: + { + pShape->m_oCustomVML.SetPath((RulesType)pProperty->m_lValue); + pShape->m_bCustomShape = true; + }break; + case ODRAW::pSegmentInfo: + { + if (pProperty->m_bComplex) + { + pShape->m_oCustomVML.LoadSegments(pProperty); + pShape->m_bCustomShape = true; + } + }break; + case ODRAW::pVertices: + { + if (pProperty->m_bComplex) + { + pShape->m_oCustomVML.LoadVertices(pProperty); + pShape->m_bCustomShape = true; + } + }break; + case ODRAW::pConnectionSites: + { + if (pProperty->m_bComplex) + { + pShape->m_oCustomVML.LoadConnectionSites(pProperty); + } + }break; + case ODRAW::pConnectionSitesDir: + { + if (pProperty->m_bComplex) + { + pShape->m_oCustomVML.LoadConnectionSitesDir(pProperty); + } + }break; + case ODRAW::pGuides: + { + if (pProperty->m_bComplex/* && pShape->m_eType != sptNotchedCircularArrow*/) + {//Тікбұрышты үшбұрыштарды.ppt - slide 25 + pShape->m_oCustomVML.LoadGuides(pProperty); + } + }break; + case ODRAW::pInscribe: + { + if (pProperty->m_bComplex) + { + pShape->m_oCustomVML.LoadInscribe(pProperty); + } + }break; + case ODRAW::pAdjustHandles: + { + if (pProperty->m_bComplex) + { + pShape->m_oCustomVML.LoadAHs(pProperty); + } + }break; + case ODRAW::adjustValue: + case ODRAW::adjust2Value: + case ODRAW::adjust3Value: + case ODRAW::adjust4Value: + case ODRAW::adjust5Value: + case ODRAW::adjust6Value: + case ODRAW::adjust7Value: + case ODRAW::adjust8Value: + case ODRAW::adjust9Value: + case ODRAW::adjust10Value: + { + LONG lIndexAdj = pProperty->m_ePID - ODRAW::adjustValue; + if (lIndexAdj >= 0 && lIndexAdj < (LONG)pShape->m_arAdjustments.size()) + { + pShape->m_oCustomVML.LoadAdjusts(lIndexAdj, (LONG)pProperty->m_lValue); + } + else + { + pShape->m_oCustomVML.LoadAdjusts(lIndexAdj, (LONG)pProperty->m_lValue); + } + }break; + //-------------------------------------------------------------------------------------------------------------------- + case lTxid: + { + }break; + case ODRAW::dxTextLeft: + { + pParentShape->m_dTextMarginX = pProperty->m_lValue; + }break; + case ODRAW::dxTextRight: + { + pParentShape->m_dTextMarginRight = pProperty->m_lValue; + }break; + case ODRAW::dyTextTop: + { + pParentShape->m_dTextMarginY = pProperty->m_lValue; + }break; + case ODRAW::dyTextBottom: + { + pParentShape->m_dTextMarginBottom = pProperty->m_lValue; + }break; + case ODRAW::WrapText: + { + pParentShape->m_oText.m_lWrapMode = (LONG)pProperty->m_lValue; + }break; + case ODRAW::gtextUNICODE://word art text + { + if (pProperty->m_bComplex && 0 < pProperty->m_lValue) + { + std::wstring str = NSFile::CUtf8Converter::GetWStringFromUTF16((unsigned short*)pProperty->m_pOptions, pProperty->m_lValue/2-1); - if (!str.empty() && pParentShape->m_oText.m_arParagraphs.empty()) - { - int length = str.length(); + if (!str.empty() && pParentShape->m_oText.m_arParagraphs.empty()) + { + int length = str.length(); - for (int i = length-1; i>=0; i--) - { - if (str.at(i) > 13 ) break; - length--; - } - PPT_FORMAT::CParagraph p; - PPT_FORMAT::CSpan s; - s.m_strText = str.substr(0,length); - p.m_arSpans.push_back(s); - pParentShape->m_oText.m_arParagraphs.push_back(p); - } - } - }break; - case ODRAW::gtextFont: - { - if (pProperty->m_bComplex && 0 < pProperty->m_lValue) - { - std::wstring str = NSFile::CUtf8Converter::GetWStringFromUTF16((unsigned short*)pProperty->m_pOptions, pProperty->m_lValue/2-1); - pParentShape->m_oText.m_oAttributes.m_oFont.Name = str; - } - }break; - case ODRAW::gtextSize: - { - pParentShape->m_oText.m_oAttributes.m_oFont.Size = (INT)((pProperty->m_lValue >> 16) & 0x0000FFFF); - break; - } - case ODRAW::anchorText: - { - switch (pProperty->m_lValue) - { - case ODRAW::anchorTop: - case ODRAW::anchorTopBaseline: - { - pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = 0; - break; - } - case ODRAW::anchorMiddle: - { - pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = 1; - break; - } - case ODRAW::anchorBottom: - case ODRAW::anchorBottomBaseline: - { - pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 0; - pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = 2; - break; - } - case ODRAW::anchorTopCentered: - case ODRAW::anchorTopCenteredBaseline: - { - pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 1; - pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = 0; - break; - } - case ODRAW::anchorMiddleCentered: - { - pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 1; - pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = 1; - break; - } - case ODRAW::anchorBottomCentered: - case ODRAW::anchorBottomCenteredBaseline: - { - pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 1; - pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = 2; - break; - } - default: - { - pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 1; - pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = -1; // not set - break; - } - }; - break; - } - case ODRAW::gtextAlign: - { - switch (pProperty->m_lValue) - { - case ODRAW::alignTextLeft: - { - pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 0; - }break; - case ODRAW::alignTextCenter: - { - pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 1; - }break; - case ODRAW::alignTextRight: - { - pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 2; - }break; - default: - { - pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 1; - }break; - }; - break; - } - case ODRAW::geometryTextBooleanProperties: - { - // вот здесь - нужно единицы перевести в пикселы - BYTE flag1 = (BYTE)(pProperty->m_lValue); - BYTE flag2 = (BYTE)(pProperty->m_lValue >> 8); - BYTE flag3 = (BYTE)(pProperty->m_lValue >> 16); - BYTE flag4 = (BYTE)(pProperty->m_lValue >> 24); + for (int i = length-1; i>=0; i--) + { + if (str.at(i) > 13 ) break; + length--; + } + PPT_FORMAT::CParagraph p; + PPT_FORMAT::CSpan s; + s.m_strText = str.substr(0,length); + p.m_arSpans.push_back(s); + pParentShape->m_oText.m_arParagraphs.push_back(p); + } + } + }break; + case ODRAW::gtextFont: + { + if (pProperty->m_bComplex && 0 < pProperty->m_lValue) + { + std::wstring str = NSFile::CUtf8Converter::GetWStringFromUTF16((unsigned short*)pProperty->m_pOptions, pProperty->m_lValue/2-1); + pParentShape->m_oText.m_oAttributes.m_oFont.Name = str; + } + }break; + case ODRAW::gtextSize: + { + pParentShape->m_oText.m_oAttributes.m_oFont.Size = (INT)((pProperty->m_lValue >> 16) & 0x0000FFFF); + break; + } + case ODRAW::anchorText: + { + switch (pProperty->m_lValue) + { + case ODRAW::anchorTop: + case ODRAW::anchorTopBaseline: + { + pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = 0; + break; + } + case ODRAW::anchorMiddle: + { + pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = 1; + break; + } + case ODRAW::anchorBottom: + case ODRAW::anchorBottomBaseline: + { + pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 0; + pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = 2; + break; + } + case ODRAW::anchorTopCentered: + case ODRAW::anchorTopCenteredBaseline: + { + pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 1; + pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = 0; + break; + } + case ODRAW::anchorMiddleCentered: + { + pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 1; + pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = 1; + break; + } + case ODRAW::anchorBottomCentered: + case ODRAW::anchorBottomCenteredBaseline: + { + pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 1; + pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = 2; + break; + } + default: + { + pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 1; + pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = -1; // not set + break; + } + }; + break; + } + case ODRAW::gtextAlign: + { + switch (pProperty->m_lValue) + { + case ODRAW::alignTextLeft: + { + pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 0; + }break; + case ODRAW::alignTextCenter: + { + pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 1; + }break; + case ODRAW::alignTextRight: + { + pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 2; + }break; + default: + { + pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 1; + }break; + }; + break; + } + case ODRAW::geometryTextBooleanProperties: + { + // вот здесь - нужно единицы перевести в пикселы + BYTE flag1 = (BYTE)(pProperty->m_lValue); + BYTE flag2 = (BYTE)(pProperty->m_lValue >> 8); + BYTE flag3 = (BYTE)(pProperty->m_lValue >> 16); + BYTE flag4 = (BYTE)(pProperty->m_lValue >> 24); - bool bStrikethrought = (0x01 == (0x01 & flag1)); - bool bSmallCaps = (0x02 == (0x02 & flag1)); - bool bShadow = (0x04 == (0x04 & flag1)); - bool bUnderline = (0x08 == (0x08 & flag1)); - bool bItalic = (0x10 == (0x10 & flag1)); - bool bBold = (0x20 == (0x20 & flag1)); + bool bStrikethrought = (0x01 == (0x01 & flag1)); + bool bSmallCaps = (0x02 == (0x02 & flag1)); + bool bShadow = (0x04 == (0x04 & flag1)); + bool bUnderline = (0x08 == (0x08 & flag1)); + bool bItalic = (0x10 == (0x10 & flag1)); + bool bBold = (0x20 == (0x20 & flag1)); - bool bUseStrikethrought = (0x01 == (0x01 & flag3)); - bool bUseSmallCaps = (0x02 == (0x02 & flag3)); - bool bUseShadow = (0x04 == (0x04 & flag3)); - bool bUseUnderline = (0x08 == (0x08 & flag3)); - bool bUseItalic = (0x10 == (0x10 & flag3)); - bool bUseBold = (0x20 == (0x20 & flag3)); + bool bUseStrikethrought = (0x01 == (0x01 & flag3)); + bool bUseSmallCaps = (0x02 == (0x02 & flag3)); + bool bUseShadow = (0x04 == (0x04 & flag3)); + bool bUseUnderline = (0x08 == (0x08 & flag3)); + bool bUseItalic = (0x10 == (0x10 & flag3)); + bool bUseBold = (0x20 == (0x20 & flag3)); - bool bVertical = (0x20 == (0x20 & flag2)); - bool bUseVertical = (0x20 == (0x20 & flag4)); + bool bVertical = (0x20 == (0x20 & flag2)); + bool bUseVertical = (0x20 == (0x20 & flag4)); - if (bUseStrikethrought) - { - pParentShape->m_oText.m_oAttributes.m_oFont.Strikeout = (BYTE)bStrikethrought; - } - if (bUseShadow) - { - pParentShape->m_oText.m_oAttributes.m_oTextShadow.Visible = true; - } - if (bUseUnderline) - { - pParentShape->m_oText.m_oAttributes.m_oFont.Underline = (BYTE)bUnderline; - } - if (bUseItalic) - { - pParentShape->m_oText.m_oAttributes.m_oFont.Italic = bItalic; - } - if (bUseBold) - { - pParentShape->m_oText.m_oAttributes.m_oFont.Bold = bBold; - } - if (bUseVertical) - { - pParentShape->m_oText.m_bVertical = (true == bVertical) ? true : false; - } - }break; - case ODRAW::cdirFont: - { - switch (pProperty->m_lValue) - { - case 1: - pParentShape->m_oText.m_bVertical = true; - break; - case 2: - pParentShape->m_oText.m_oAttributes.m_dTextRotate = 180; - break; - case 3: - pParentShape->m_oText.m_bVertical = true; - pParentShape->m_oText.m_oAttributes.m_dTextRotate = 180; - break; - } - }break; - case ODRAW::txflTextFlow: - { - pParentShape->m_oText.m_nTextFlow = pProperty->m_lValue; - }break; - case ODRAW::textBooleanProperties: - { - BYTE flag1 = (BYTE)(pProperty->m_lValue); - BYTE flag2 = (BYTE)(pProperty->m_lValue >> 8); - BYTE flag3 = (BYTE)(pProperty->m_lValue >> 16); - BYTE flag4 = (BYTE)(pProperty->m_lValue >> 24); + if (bUseStrikethrought) + { + pParentShape->m_oText.m_oAttributes.m_oFont.Strikeout = (BYTE)bStrikethrought; + } + if (bUseShadow) + { + pParentShape->m_oText.m_oAttributes.m_oTextShadow.Visible = true; + } + if (bUseUnderline) + { + pParentShape->m_oText.m_oAttributes.m_oFont.Underline = (BYTE)bUnderline; + } + if (bUseItalic) + { + pParentShape->m_oText.m_oAttributes.m_oFont.Italic = bItalic; + } + if (bUseBold) + { + pParentShape->m_oText.m_oAttributes.m_oFont.Bold = bBold; + } + if (bUseVertical) + { + pParentShape->m_oText.m_bVertical = (true == bVertical) ? true : false; + } + }break; + case ODRAW::cdirFont: + { + switch (pProperty->m_lValue) + { + case 1: + pParentShape->m_oText.m_bVertical = true; + break; + case 2: + pParentShape->m_oText.m_oAttributes.m_dTextRotate = 180; + break; + case 3: + pParentShape->m_oText.m_bVertical = true; + pParentShape->m_oText.m_oAttributes.m_dTextRotate = 180; + break; + } + }break; + case ODRAW::txflTextFlow: + { + pParentShape->m_oText.m_nTextFlow = pProperty->m_lValue; + }break; + case ODRAW::textBooleanProperties: + { + BYTE flag1 = (BYTE)(pProperty->m_lValue); + BYTE flag2 = (BYTE)(pProperty->m_lValue >> 8); + BYTE flag3 = (BYTE)(pProperty->m_lValue >> 16); + BYTE flag4 = (BYTE)(pProperty->m_lValue >> 24); - bool bFitShapeToText = (0x02 == (0x02 & flag1)); - bool bAutoTextMargin = (0x08 == (0x08 & flag1)); - bool bSelectText = (0x10 == (0x10 & flag1)); + bool bFitShapeToText = (0x02 == (0x02 & flag1)); + bool bAutoTextMargin = (0x08 == (0x08 & flag1)); + bool bSelectText = (0x10 == (0x10 & flag1)); - bool bUseFitShapeToText = (0x02 == (0x02 & flag3)); - bool bUseAutoTextMargin = (0x08 == (0x08 & flag3)); - bool bUseSelectText = (0x10 == (0x10 & flag3)); + bool bUseFitShapeToText = (0x02 == (0x02 & flag3)); + bool bUseAutoTextMargin = (0x08 == (0x08 & flag3)); + bool bUseSelectText = (0x10 == (0x10 & flag3)); - if (bUseAutoTextMargin) - { - if (bAutoTextMargin) - { - pParentShape->m_dTextMarginX = 2.54; - pParentShape->m_dTextMarginRight = 1.27; - pParentShape->m_dTextMarginY = 2.54; - pParentShape->m_dTextMarginBottom = 1.27; - } - } - if (bUseFitShapeToText) - pParentShape->m_oText.m_bAutoFit = bFitShapeToText; + if (bUseAutoTextMargin) + { + if (bAutoTextMargin) + { + pParentShape->m_dTextMarginX = 2.54; + pParentShape->m_dTextMarginRight = 1.27; + pParentShape->m_dTextMarginY = 2.54; + pParentShape->m_dTextMarginBottom = 1.27; + } + } + if (bUseFitShapeToText) + pParentShape->m_oText.m_bAutoFit = bFitShapeToText; - }break; - case ODRAW::c3DSpecularAmt: - { - pShape->m_o3dOptions.dSpecularAmt = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DDiffuseAmt: - { - pShape->m_o3dOptions.dDiffuseAmt = FixedPointToDouble(pProperty->m_lValue); - }break; + }break; + case ODRAW::c3DSpecularAmt: + { + pShape->m_o3dOptions.dSpecularAmt = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DDiffuseAmt: + { + pShape->m_o3dOptions.dDiffuseAmt = FixedPointToDouble(pProperty->m_lValue); + }break; case ODRAW::c3DShininess: - { - pShape->m_o3dOptions.dShininess = FixedPointToDouble(pProperty->m_lValue); - }break; + { + pShape->m_o3dOptions.dShininess = FixedPointToDouble(pProperty->m_lValue); + }break; case ODRAW::c3DEdgeThickness: - { - pShape->m_o3dOptions.nEdgeThickness = pProperty->m_lValue; - }break; - case ODRAW::C3DExtrudeForward: - { - pShape->m_o3dOptions.nExtrudeForward = pProperty->m_lValue; - }break; - case ODRAW::c3DExtrudeBackward: - { - pShape->m_o3dOptions.nExtrudeBackward = pProperty->m_lValue; - }break; - case ODRAW::c3DExtrudePlane: - { - //ExtrudePlane = 0; - }break; - case ODRAW::c3DExtrusionColor: - { - SColorAtom oAtom; - oAtom.FromValue(pProperty->m_lValue); + { + pShape->m_o3dOptions.nEdgeThickness = pProperty->m_lValue; + }break; + case ODRAW::C3DExtrudeForward: + { + pShape->m_o3dOptions.nExtrudeForward = pProperty->m_lValue; + }break; + case ODRAW::c3DExtrudeBackward: + { + pShape->m_o3dOptions.nExtrudeBackward = pProperty->m_lValue; + }break; + case ODRAW::c3DExtrudePlane: + { + //ExtrudePlane = 0; + }break; + case ODRAW::c3DExtrusionColor: + { + SColorAtom oAtom; + oAtom.FromValue(pProperty->m_lValue); - CColor tmp; - if(oAtom.bSysIndex) tmp = CorrectSysColor(pProperty->m_lValue, pElement, pTheme); - else oAtom.ToColor(&tmp); + CColor tmp; + if(oAtom.bSysIndex) tmp = CorrectSysColor(pProperty->m_lValue, pElement, pTheme); + else oAtom.ToColor(&tmp); - pShape->m_o3dOptions.oExtrusionColor = tmp; - }break; - case ODRAW::c3DCrMod: - { - SColorAtom oAtom; - oAtom.FromValue(pProperty->m_lValue); + pShape->m_o3dOptions.oExtrusionColor = tmp; + }break; + case ODRAW::c3DCrMod: + { + SColorAtom oAtom; + oAtom.FromValue(pProperty->m_lValue); - CColor tmp; - if(oAtom.bSysIndex) tmp = CorrectSysColor(pProperty->m_lValue, pElement, pTheme); - else oAtom.ToColor(&tmp); - - pShape->m_o3dOptions.oCrMod = tmp; - }break; - case ODRAW::c3DExtrusionColorExt: - { - SColorAtom oAtom; - oAtom.FromValue(pProperty->m_lValue); + CColor tmp; + if(oAtom.bSysIndex) tmp = CorrectSysColor(pProperty->m_lValue, pElement, pTheme); + else oAtom.ToColor(&tmp); - CColor tmp; - if(oAtom.bSysIndex) tmp = CorrectSysColor(pProperty->m_lValue, pElement, pTheme); - else oAtom.ToColor(&tmp); - pShape->m_o3dOptions.oExtrusionColorExt = tmp; - }break; - case ODRAW::c3DExtrusionColorExtMod: - { - pShape->m_o3dOptions.nTypeExtrusionColorExt = (pProperty->m_lValue & 0x00000300) >> 8; - }break; - case ODRAW::c3DBottomBevelWidth: - { - pShape->m_o3dOptions.dBottomBevelWidth = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DBottomBevelHeight: - { - pShape->m_o3dOptions.dBottomBevelHeight = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DBottomBevelType: - { - pShape->m_o3dOptions.nBottomBevelType = pProperty->m_lValue; - }break; - case ODRAW::c3DTopBevelWidth: - { - pShape->m_o3dOptions.dTopBevelWidth = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DTopBevelHeight: - { - pShape->m_o3dOptions.dTopBevelHeight = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DTopBevelType: - { - pShape->m_o3dOptions.nTopBevelType = pProperty->m_lValue; - }break; - case ODRAW::threeDObjectBooleanProperties: - { - bool fUsef3D = GETBIT(pProperty->m_lValue, 19); - bool fUsefc3DMetallic = GETBIT(pProperty->m_lValue, 18); - bool fUsefc3DUseExtrusionColor = GETBIT(pProperty->m_lValue, 17); - bool fUsefc3DLightFace = GETBIT(pProperty->m_lValue, 16); - - pShape->m_o3dOptions.bEnabled = fUsef3D ? GETBIT(pProperty->m_lValue, 3) : false; - pShape->m_o3dOptions.bMetallic = fUsefc3DMetallic ? GETBIT(pProperty->m_lValue, 2) : false; - pShape->m_o3dOptions.bExtrusionColor= fUsefc3DUseExtrusionColor ? GETBIT(pProperty->m_lValue, 1) : false; - pShape->m_o3dOptions.bLightFace = fUsefc3DLightFace ? GETBIT(pProperty->m_lValue, 0) : true; + pShape->m_o3dOptions.oCrMod = tmp; + }break; + case ODRAW::c3DExtrusionColorExt: + { + SColorAtom oAtom; + oAtom.FromValue(pProperty->m_lValue); - }break; - case ODRAW::c3DYRotationAngle: - { - double val = FixedPointToDouble(pProperty->m_lValue); - if (val < 0) val += 360; - pShape->m_o3dOptions.dYRotationAngle = val; - }break; - case ODRAW::c3DXRotationAngle: - { - double val = FixedPointToDouble(pProperty->m_lValue); - if (val < 0) val += 360; - pShape->m_o3dOptions.dXRotationAngle = val; - }break; - case ODRAW::c3DRotationAxisX: - { - pShape->m_o3dOptions.dRotationAxisX = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DRotationAxisY: - { - pShape->m_o3dOptions.dRotationAxisY = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DRotationAxisZ: - { - pShape->m_o3dOptions.dRotationAxisZ = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DRotationAngle: - { - pShape->m_o3dOptions.dRotationAngle = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DRotationCenterX: - { - pShape->m_o3dOptions.dRotationCenterX = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DRotationCenterY: - { - pShape->m_o3dOptions.dRotationCenterY = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DRotationCenterZ: - { - pShape->m_o3dOptions.dRotationCenterZ = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DRenderMode: - { - pShape->m_o3dOptions.nRenderMode = pProperty->m_lValue; - }break; - case ODRAW::c3DTolerance: - { - pShape->m_o3dOptions.dTolerance = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DXViewpoint: - { - pShape->m_o3dOptions.dXViewpoint = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DYViewpoint: - { - pShape->m_o3dOptions.dYViewpoint = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DZViewpoint: - { - pShape->m_o3dOptions.dZViewpoint = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DOriginX: - { - pShape->m_o3dOptions.dOriginX = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DOriginY: - { - pShape->m_o3dOptions.dOriginY = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DSkewAngle: - { - double val = FixedPointToDouble(pProperty->m_lValue); - if (val <= 0) val += 360; - pShape->m_o3dOptions.dSkewAngle = val; - }break; - case ODRAW::c3DSkewAmount: - { - pShape->m_o3dOptions.nSkewAmount = pProperty->m_lValue; - }break; - case ODRAW::c3DAmbientIntensity: - { - pShape->m_o3dOptions.dAmbientIntensity = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DKeyX: - { - pShape->m_o3dOptions.dKeyX = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DKeyY: - { - pShape->m_o3dOptions.dKeyY = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DKeyZ: - { - pShape->m_o3dOptions.dKeyZ = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DKeyIntensity: - { - pShape->m_o3dOptions.dKeyIntensity = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DFillX: - { - pShape->m_o3dOptions.dFillX = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DFillY: - { - pShape->m_o3dOptions.dFillY = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DFillZ: - { - pShape->m_o3dOptions.dFillZ = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::c3DFillIntensity: - { - pShape->m_o3dOptions.dFillIntensity = FixedPointToDouble(pProperty->m_lValue); - }break; - case ODRAW::threeDStyleBooleanProperties: - { - bool fUsefc3DConstrainRotation = GETBIT(pProperty->m_lValue, 20); - bool fUsefc3DRotationCenterAuto = GETBIT(pProperty->m_lValue, 19); - bool fUsefc3DParallel = GETBIT(pProperty->m_lValue, 18); - bool fUsefc3DKeyHarsh = GETBIT(pProperty->m_lValue, 17); - bool fUsefc3DFillHarsh = GETBIT(pProperty->m_lValue, 16); - - pShape->m_o3dOptions.bConstrainRotation = fUsefc3DConstrainRotation ? GETBIT(pProperty->m_lValue, 4) : true; - pShape->m_o3dOptions.bRotationCenterAuto= fUsefc3DRotationCenterAuto? GETBIT(pProperty->m_lValue, 3) : false; - pShape->m_o3dOptions.bParallel = fUsefc3DParallel ? GETBIT(pProperty->m_lValue, 2) : true; - pShape->m_o3dOptions.bKeyHarsh = fUsefc3DKeyHarsh ? GETBIT(pProperty->m_lValue, 1) : true; - pShape->m_o3dOptions.bFillHarsh = fUsefc3DFillHarsh ? GETBIT(pProperty->m_lValue, 0) : true; - }break; - default: - { - int unknown_value = pProperty->m_lValue; - unknown_value = unknown_value; - }break; - } + CColor tmp; + if(oAtom.bSysIndex) tmp = CorrectSysColor(pProperty->m_lValue, pElement, pTheme); + else oAtom.ToColor(&tmp); + pShape->m_o3dOptions.oExtrusionColorExt = tmp; + }break; + case ODRAW::c3DExtrusionColorExtMod: + { + pShape->m_o3dOptions.nTypeExtrusionColorExt = (pProperty->m_lValue & 0x00000300) >> 8; + }break; + case ODRAW::c3DBottomBevelWidth: + { + pShape->m_o3dOptions.dBottomBevelWidth = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DBottomBevelHeight: + { + pShape->m_o3dOptions.dBottomBevelHeight = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DBottomBevelType: + { + pShape->m_o3dOptions.nBottomBevelType = pProperty->m_lValue; + }break; + case ODRAW::c3DTopBevelWidth: + { + pShape->m_o3dOptions.dTopBevelWidth = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DTopBevelHeight: + { + pShape->m_o3dOptions.dTopBevelHeight = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DTopBevelType: + { + pShape->m_o3dOptions.nTopBevelType = pProperty->m_lValue; + }break; + case ODRAW::threeDObjectBooleanProperties: + { + bool fUsef3D = GETBIT(pProperty->m_lValue, 19); + bool fUsefc3DMetallic = GETBIT(pProperty->m_lValue, 18); + bool fUsefc3DUseExtrusionColor = GETBIT(pProperty->m_lValue, 17); + bool fUsefc3DLightFace = GETBIT(pProperty->m_lValue, 16); + + pShape->m_o3dOptions.bEnabled = fUsef3D ? GETBIT(pProperty->m_lValue, 3) : false; + pShape->m_o3dOptions.bMetallic = fUsefc3DMetallic ? GETBIT(pProperty->m_lValue, 2) : false; + pShape->m_o3dOptions.bExtrusionColor= fUsefc3DUseExtrusionColor ? GETBIT(pProperty->m_lValue, 1) : false; + pShape->m_o3dOptions.bLightFace = fUsefc3DLightFace ? GETBIT(pProperty->m_lValue, 0) : true; + + }break; + case ODRAW::c3DYRotationAngle: + { + double val = FixedPointToDouble(pProperty->m_lValue); + if (val < 0) val += 360; + pShape->m_o3dOptions.dYRotationAngle = val; + }break; + case ODRAW::c3DXRotationAngle: + { + double val = FixedPointToDouble(pProperty->m_lValue); + if (val < 0) val += 360; + pShape->m_o3dOptions.dXRotationAngle = val; + }break; + case ODRAW::c3DRotationAxisX: + { + pShape->m_o3dOptions.dRotationAxisX = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DRotationAxisY: + { + pShape->m_o3dOptions.dRotationAxisY = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DRotationAxisZ: + { + pShape->m_o3dOptions.dRotationAxisZ = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DRotationAngle: + { + pShape->m_o3dOptions.dRotationAngle = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DRotationCenterX: + { + pShape->m_o3dOptions.dRotationCenterX = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DRotationCenterY: + { + pShape->m_o3dOptions.dRotationCenterY = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DRotationCenterZ: + { + pShape->m_o3dOptions.dRotationCenterZ = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DRenderMode: + { + pShape->m_o3dOptions.nRenderMode = pProperty->m_lValue; + }break; + case ODRAW::c3DTolerance: + { + pShape->m_o3dOptions.dTolerance = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DXViewpoint: + { + pShape->m_o3dOptions.dXViewpoint = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DYViewpoint: + { + pShape->m_o3dOptions.dYViewpoint = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DZViewpoint: + { + pShape->m_o3dOptions.dZViewpoint = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DOriginX: + { + pShape->m_o3dOptions.dOriginX = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DOriginY: + { + pShape->m_o3dOptions.dOriginY = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DSkewAngle: + { + double val = FixedPointToDouble(pProperty->m_lValue); + if (val <= 0) val += 360; + pShape->m_o3dOptions.dSkewAngle = val; + }break; + case ODRAW::c3DSkewAmount: + { + pShape->m_o3dOptions.nSkewAmount = pProperty->m_lValue; + }break; + case ODRAW::c3DAmbientIntensity: + { + pShape->m_o3dOptions.dAmbientIntensity = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DKeyX: + { + pShape->m_o3dOptions.dKeyX = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DKeyY: + { + pShape->m_o3dOptions.dKeyY = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DKeyZ: + { + pShape->m_o3dOptions.dKeyZ = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DKeyIntensity: + { + pShape->m_o3dOptions.dKeyIntensity = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DFillX: + { + pShape->m_o3dOptions.dFillX = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DFillY: + { + pShape->m_o3dOptions.dFillY = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DFillZ: + { + pShape->m_o3dOptions.dFillZ = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::c3DFillIntensity: + { + pShape->m_o3dOptions.dFillIntensity = FixedPointToDouble(pProperty->m_lValue); + }break; + case ODRAW::threeDStyleBooleanProperties: + { + bool fUsefc3DConstrainRotation = GETBIT(pProperty->m_lValue, 20); + bool fUsefc3DRotationCenterAuto = GETBIT(pProperty->m_lValue, 19); + bool fUsefc3DParallel = GETBIT(pProperty->m_lValue, 18); + bool fUsefc3DKeyHarsh = GETBIT(pProperty->m_lValue, 17); + bool fUsefc3DFillHarsh = GETBIT(pProperty->m_lValue, 16); + + pShape->m_o3dOptions.bConstrainRotation = fUsefc3DConstrainRotation ? GETBIT(pProperty->m_lValue, 4) : true; + pShape->m_o3dOptions.bRotationCenterAuto= fUsefc3DRotationCenterAuto? GETBIT(pProperty->m_lValue, 3) : false; + pShape->m_o3dOptions.bParallel = fUsefc3DParallel ? GETBIT(pProperty->m_lValue, 2) : true; + pShape->m_o3dOptions.bKeyHarsh = fUsefc3DKeyHarsh ? GETBIT(pProperty->m_lValue, 1) : true; + pShape->m_o3dOptions.bFillHarsh = fUsefc3DFillHarsh ? GETBIT(pProperty->m_lValue, 0) : true; + }break; + default: + { + int unknown_value = pProperty->m_lValue; + unknown_value = unknown_value; + }break; + } } CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, - CTheme* pTheme, CLayout* pLayout, - CSlideInfo* pThemeWrapper, CSlideInfo* pSlideWrapper, CSlide* pSlide) + CTheme* pTheme, CLayout* pLayout, + CSlideInfo* pThemeWrapper, CSlideInfo* pSlideWrapper, CSlide* pSlide) { CElementPtr pElement; @@ -1530,8 +1530,8 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, for (size_t nIndex = 0; nIndex < nIndexMem; ++nIndex) { if ((placeholder_type == pLayout->m_arElements[nIndex]->m_lPlaceholderType ) && - ( placeholder_id < 0 || pLayout->m_arElements[nIndex]->m_lPlaceholderID < 0 || - placeholder_id == pLayout->m_arElements[nIndex]->m_lPlaceholderID)) + ( placeholder_id < 0 || pLayout->m_arElements[nIndex]->m_lPlaceholderID < 0 || + placeholder_id == pLayout->m_arElements[nIndex]->m_lPlaceholderID)) { if (pLayout->m_arElements[nIndex]->m_bPlaceholderSet == false) { @@ -1568,93 +1568,93 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, case sptNil: break; case sptPictureFrame: - { - std::vector oArrayEx; - GetRecordsByType(&oArrayEx, true, true); + { + std::vector oArrayEx; + GetRecordsByType(&oArrayEx, true, true); - CExFilesInfo oInfo; - CExFilesInfo oInfoDefault; - // по умолчанию картинка (или оле объект) - CExFilesInfo::ExFilesType exType = CExFilesInfo::eftNone; - CExFilesInfo* pInfo = pMapIDs->Lock(0xFFFFFFFF, exType); + CExFilesInfo oInfo; + CExFilesInfo oInfoDefault; + // по умолчанию картинка (или оле объект) + CExFilesInfo::ExFilesType exType = CExFilesInfo::eftNone; + CExFilesInfo* pInfo = pMapIDs->Lock(0xFFFFFFFF, exType); + if (NULL != pInfo) + { + oInfo = *pInfo; + oInfoDefault = oInfo; + } + + if (0 != oArrayEx.size()) + { + pInfo = pMapIDs->Lock(oArrayEx[0]->m_nExObjID, exType); if (NULL != pInfo) { - oInfo = *pInfo; - oInfoDefault = oInfo; + oInfo = *pInfo; } + } - if (0 != oArrayEx.size()) - { - pInfo = pMapIDs->Lock(oArrayEx[0]->m_nExObjID, exType); - if (NULL != pInfo) - { - oInfo = *pInfo; - } - } - - if (CExFilesInfo::eftVideo == exType) - { - CVideoElement* pVideoElem = new CVideoElement(); - - pVideoElem->m_strVideoFileName = oInfo.m_strFilePath ; - pVideoElem->m_strImageFileName = oInfoDefault.m_strFilePath + FILE_SEPARATOR_STR; - - pElement = CElementPtr(pVideoElem); - } - else if (CExFilesInfo::eftAudio == exType) - { - CAudioElement* pAudioElem = new CAudioElement(); - pElement = CElementPtr(pAudioElem); - - pAudioElem->m_strAudioFileName = oInfo.m_strFilePath; - pAudioElem->m_strImageFileName = oInfoDefault.m_strFilePath + FILE_SEPARATOR_STR; - - pAudioElem->m_dClipStartTime = oInfo.m_dStartTime; - pAudioElem->m_dClipEndTime = oInfo.m_dEndTime; - - pAudioElem->m_bLoop = oInfo.m_bLoop; - - if (NULL != pSlide) - { - pAudioElem->m_dStartTime = pSlide->m_dStartTime; - pAudioElem->m_dEndTime = pSlide->m_dEndTime; - - } - else - { - if (pLayout) - pLayout->m_arElements.push_back(pElement); - } - - } - else - { - CImageElement* pImageElem = new CImageElement(); - pImageElem->m_strImageFileName = oInfo.m_strFilePath + FILE_SEPARATOR_STR; - - pElement = CElementPtr(pImageElem); - } - }break; - default: + if (CExFilesInfo::eftVideo == exType) { - if (bGroupShape) + CVideoElement* pVideoElem = new CVideoElement(); + + pVideoElem->m_strVideoFileName = oInfo.m_strFilePath ; + pVideoElem->m_strImageFileName = oInfoDefault.m_strFilePath + FILE_SEPARATOR_STR; + + pElement = CElementPtr(pVideoElem); + } + else if (CExFilesInfo::eftAudio == exType) + { + CAudioElement* pAudioElem = new CAudioElement(); + pElement = CElementPtr(pAudioElem); + + pAudioElem->m_strAudioFileName = oInfo.m_strFilePath; + pAudioElem->m_strImageFileName = oInfoDefault.m_strFilePath + FILE_SEPARATOR_STR; + + pAudioElem->m_dClipStartTime = oInfo.m_dStartTime; + pAudioElem->m_dClipEndTime = oInfo.m_dEndTime; + + pAudioElem->m_bLoop = oInfo.m_bLoop; + + if (NULL != pSlide) { - CGroupElement* pGroupElem = new CGroupElement(); - pElement = CElementPtr(pGroupElem); + pAudioElem->m_dStartTime = pSlide->m_dStartTime; + pAudioElem->m_dEndTime = pSlide->m_dEndTime; + } else { - // shape - CShapeElement* pShape = new CShapeElement(NSBaseShape::ppt, eType); - CPPTShape *ppt_shape = dynamic_cast(pShape->m_pShape->getBaseShape().get()); - - if ( (ppt_shape) && (OOXMLShapes::sptCustom == ppt_shape->m_eType)) - { - pShape->m_bShapePreset = true; - } - pElement = CElementPtr(pShape); + if (pLayout) + pLayout->m_arElements.push_back(pElement); } - }break; + + } + else + { + CImageElement* pImageElem = new CImageElement(); + pImageElem->m_strImageFileName = oInfo.m_strFilePath + FILE_SEPARATOR_STR; + + pElement = CElementPtr(pImageElem); + } + }break; + default: + { + if (bGroupShape) + { + CGroupElement* pGroupElem = new CGroupElement(); + pElement = CElementPtr(pGroupElem); + } + else + { + // shape + CShapeElement* pShape = new CShapeElement(NSBaseShape::ppt, eType); + CPPTShape *ppt_shape = dynamic_cast(pShape->m_pShape->getBaseShape().get()); + + if ( (ppt_shape) && (OOXMLShapes::sptCustom == ppt_shape->m_eType)) + { + pShape->m_bShapePreset = true; + } + pElement = CElementPtr(pShape); + } + }break; } } @@ -1664,7 +1664,7 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, pElement->m_lID = oArrayShape[0]->m_nID; pElement->m_lLayoutID = lMasterID; -//---------внешние ссылки + //---------внешние ссылки { CExFilesInfo::ExFilesType exType = CExFilesInfo::eftNone; CExFilesInfo * pTextureInfo = pMapIDs->Lock(0xFFFFFFFF, exType); @@ -1687,7 +1687,7 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, } } std::wstring strShapeText; -//------------------------------------------------------------------------------------------------ + //------------------------------------------------------------------------------------------------ // placeholders if (0 < oArrayPlaceHolder.size()) { @@ -1751,7 +1751,7 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, pElement->m_nFormatDate = 2; } } -//------------- привязки --------------------------------------------------------------------------------- + //------------- привязки --------------------------------------------------------------------------------- std::vector oArrayGroupShape; this->GetRecordsByType(&oArrayGroupShape, true, true); @@ -1805,7 +1805,58 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, pElementLayout->m_bAnchorEnabled = pElement->m_bAnchorEnabled; pElementLayout->m_bChildAnchorEnabled = pElement->m_bChildAnchorEnabled; } -//--------- наличие текста -------------------------------------------------------------------------- + + std::vector oArrayInteractive; + GetRecordsByType(&oArrayInteractive, true, false); + std::vector oArrayMacro; + GetRecordsByType(&oArrayMacro, true, false); + + if (oArrayInteractive.size() == 2) + oArrayInteractive[1]->m_oHeader.RecInstance = 1; + + for (auto const* interactiveAtom : oArrayInteractive) + { + CInteractiveInfo interactiveInfo; + interactiveInfo.m_bPresent = true; + interactiveInfo.m_eActivation = (bool)interactiveAtom->m_oHeader.RecInstance; + + if (pMapIDs) + { + CExFilesInfo* pInfo1 = pMapIDs->LockAudioFromCollection(interactiveAtom->m_nSoundIdRef); + if (NULL != pInfo1) + { + interactiveInfo.m_strAudioFileName = pInfo1->m_strFilePath; + interactiveInfo.m_strAudioName = pInfo1->m_name; + } + CExFilesInfo* pInfo2 = pMapIDs->LockSlide(interactiveAtom->m_nExHyperlinkIdRef); + if (NULL != pInfo2) + { + interactiveInfo.m_strHyperlink = pInfo2->m_strFilePath; + } + pInfo2 = pMapIDs->LockHyperlink(interactiveAtom->m_nExHyperlinkIdRef); + if (NULL != pInfo2) + { + interactiveInfo.m_strHyperlink = pInfo2->m_strFilePath; + } + } + if (oArrayMacro.size()) + interactiveInfo.m_macro = oArrayMacro[0]->m_strText; + + interactiveInfo.m_lType = interactiveAtom->m_nAction; + interactiveInfo.m_lOleVerb = interactiveAtom->m_nOleVerb; + interactiveInfo.m_lJump = interactiveAtom->m_nJump; + interactiveInfo.m_lHyperlinkType = interactiveAtom->m_nHyperlinkType; + + interactiveInfo.m_bAnimated = interactiveAtom->m_bAnimated; + interactiveInfo.m_bStopSound = interactiveAtom->m_bStopSound; + interactiveInfo.m_bCustomShowReturn = interactiveAtom->m_bCustomShowReturn; + interactiveInfo.m_bVisited = interactiveAtom->m_bVisited; + + pElement->m_arrActions.push_back(interactiveInfo); + } + + + //--------- наличие текста -------------------------------------------------------------------------- CShapeElement* pShapeElem = dynamic_cast(pElement.get()); if (NULL != pShapeElem) { @@ -1864,7 +1915,7 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, if (pos < 0) pElement->m_lPlaceholderType = PT_MasterFooter; ///???? 1-(33).ppt } -//------ shape properties ---------------------------------------------------------------------------------------- + //------ shape properties ---------------------------------------------------------------------------------------- CPPTElement oElement; for (size_t nIndexProp = 0; nIndexProp < oArrayOptions.size(); ++nIndexProp) { @@ -1894,54 +1945,6 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, pShapeElem->m_pShape->m_oText.m_oRuler = oArrayTextRuler[0]->m_oTextRuler; } - std::vector oArrayInteractive; - GetRecordsByType(&oArrayInteractive, true, false); - std::vector oArrayMacro; - GetRecordsByType(&oArrayMacro, true, false); - - if (oArrayInteractive.size() == 2) - oArrayInteractive[1]->m_oHeader.RecInstance = 1; - - for (auto const* interactiveAtom : oArrayInteractive) - { - CInteractiveInfo interactiveInfo; - interactiveInfo.m_bPresent = true; - interactiveInfo.m_eActivation = (bool)interactiveAtom->m_oHeader.RecInstance; - - if (pMapIDs) - { - CExFilesInfo* pInfo1 = pMapIDs->LockAudioFromCollection(interactiveAtom->m_nSoundIdRef); - if (NULL != pInfo1) - { - interactiveInfo.m_strAudioFileName = pInfo1->m_strFilePath; - interactiveInfo.m_strAudioName = pInfo1->m_name; - } - CExFilesInfo* pInfo2 = pMapIDs->LockSlide(interactiveAtom->m_nExHyperlinkIdRef); - if (NULL != pInfo2) - { - interactiveInfo.m_strHyperlink = pInfo2->m_strFilePath; - } - pInfo2 = pMapIDs->LockHyperlink(interactiveAtom->m_nExHyperlinkIdRef); - if (NULL != pInfo2) - { - interactiveInfo.m_strHyperlink = pInfo2->m_strFilePath; - } - } - if (oArrayMacro.size()) - interactiveInfo.m_macro = oArrayMacro[0]->m_strText; - - interactiveInfo.m_lType = interactiveAtom->m_nAction; - interactiveInfo.m_lOleVerb = interactiveAtom->m_nOleVerb; - interactiveInfo.m_lJump = interactiveAtom->m_nJump; - interactiveInfo.m_lHyperlinkType = interactiveAtom->m_nHyperlinkType; - - interactiveInfo.m_bAnimated = interactiveAtom->m_bAnimated; - interactiveInfo.m_bStopSound = interactiveAtom->m_bStopSound; - interactiveInfo.m_bCustomShowReturn = interactiveAtom->m_bCustomShowReturn; - interactiveInfo.m_bVisited = interactiveAtom->m_bVisited; - - pShapeElem->m_arrActions.push_back(interactiveInfo); - } std::vector oArrayTextInteractive; this->GetRecordsByType(&oArrayTextInteractive, true); @@ -2025,7 +2028,7 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, pElement->m_lLayoutID = lMasterID; } -//---------------------------------------------------------------------------------------------------- + //---------------------------------------------------------------------------------------------------- if (NULL != pSlide) { pElement->m_dStartTime = pSlide->m_dStartTime; @@ -2042,54 +2045,54 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, void CRecordShapeContainer::ApplyThemeStyle(CElementPtr pElem, CTheme* pTheme, CRecordMasterTextPropAtom* master_levels) { - CShapeElement* pShape = dynamic_cast(pElem.get()); - if (NULL == pShape) - return; - - CTextAttributesEx* pText = &(pShape->m_pShape->m_oText); + CShapeElement* pShape = dynamic_cast(pElem.get()); + if (NULL == pShape) + return; - - if (master_levels) - { - for (size_t i = 0; i < pText->m_arParagraphs.size(); i++) - { - if (i >= master_levels->m_arrProps.size()) break; - - pText->m_arParagraphs[i].m_lTextLevel = master_levels->m_arrProps[i].lIndentLevel; - pText->m_arParagraphs[i].m_oPFRun.leftMargin.reset(); - pText->m_arParagraphs[i].m_oPFRun.indent.reset(); - } - } + CTextAttributesEx* pText = &(pShape->m_pShape->m_oText); - pText->ApplyThemeStyle(pTheme); + + if (master_levels) + { + for (size_t i = 0; i < pText->m_arParagraphs.size(); i++) + { + if (i >= master_levels->m_arrProps.size()) break; + + pText->m_arParagraphs[i].m_lTextLevel = master_levels->m_arrProps[i].lIndentLevel; + pText->m_arParagraphs[i].m_oPFRun.leftMargin.reset(); + pText->m_arParagraphs[i].m_oPFRun.indent.reset(); + } + } + + pText->ApplyThemeStyle(pTheme); } void CRecordShapeContainer::SetUpTextStyle(std::wstring& strText, CTheme* pTheme, CLayout* pLayout, CElementPtr pElem, CSlideInfo* pThemeWrapper, CSlideInfo* pSlideWrapper, CSlide* pSlide, CRecordMasterTextPropAtom* master_levels) { - // сначала проверяем на shape - // затем применяем все настройки по-очереди - // 1) master + TextMasterStyles - // 2) persist + TextMasterStyles - // 3) свои настройки + TextMasterStyles - // причем "свои настройки" - это чисто "продвинутые настройки" - // потому что все общие ( через проперти ) - уже установлены + // сначала проверяем на shape + // затем применяем все настройки по-очереди + // 1) master + TextMasterStyles + // 2) persist + TextMasterStyles + // 3) свои настройки + TextMasterStyles + // причем "свои настройки" - это чисто "продвинутые настройки" + // потому что все общие ( через проперти ) - уже установлены - if (NULL == pElem) - return; + if (NULL == pElem) + return; - if (etShape != pElem->m_etType) - return; + if (etShape != pElem->m_etType) + return; - CShapeElement* pShape = dynamic_cast(pElem.get()); - if (NULL == pShape) - return; + CShapeElement* pShape = dynamic_cast(pElem.get()); + if (NULL == pShape) + return; - CTextAttributesEx* pTextSettings = &(pShape->m_pShape->m_oText); + CTextAttributesEx* pTextSettings = &(pShape->m_pShape->m_oText); - // сначала применим ссылки на masterstyle (для шаблонного элемента) - // как узнать - просто есть ли массивы (т.к. они могли появиться пока только оттуда) - // - теперь этого делать не нужно - т.к. в мастере тоже вызывается эта функция - - // и там все это должно уже примениться + // сначала применим ссылки на masterstyle (для шаблонного элемента) + // как узнать - просто есть ли массивы (т.к. они могли появиться пока только оттуда) + // - теперь этого делать не нужно - т.к. в мастере тоже вызывается эта функция - + // и там все это должно уже примениться bool bIsPersistPresentSettings = false; bool bIsOwnPresentSettings = false; @@ -2097,15 +2100,15 @@ void CRecordShapeContainer::SetUpTextStyle(std::wstring& strText, CTheme* pTheme TextTypeEnum eTypePersist = NoPresent; TextTypeEnum eTypeOwn = (TextTypeEnum)pTextSettings->m_lTextType; - CShapeElement* pElementLayoutPH = NULL; + CShapeElement* pElementLayoutPH = NULL; - // выставим тип мастера - if (NULL != pSlide) - { - int ph_type = pShape->m_lPlaceholderType; - int ph_pos = pShape->m_lPlaceholderID; + // выставим тип мастера + if (NULL != pSlide) + { + int ph_type = pShape->m_lPlaceholderType; + int ph_pos = pShape->m_lPlaceholderID; - pTextSettings->m_lPlaceholderType = pShape->m_lPlaceholderType; + pTextSettings->m_lPlaceholderType = pShape->m_lPlaceholderType; size_t lElemsCount = 0; @@ -2122,444 +2125,444 @@ void CRecordShapeContainer::SetUpTextStyle(std::wstring& strText, CTheme* pTheme } } } - } - else - { + } + else + { eTypeMaster = (TextTypeEnum)pTextSettings->m_lTextMasterType; - } + } - // ------------------------------------------------------------------------------ - CElementInfo oElemInfo; - std::map::iterator pPair = pSlideWrapper->m_mapElements.find(pShape->m_lID); - if (pSlideWrapper->m_mapElements.end() != pPair) - oElemInfo = pPair->second; + // ------------------------------------------------------------------------------ + CElementInfo oElemInfo; + std::map::iterator pPair = pSlideWrapper->m_mapElements.find(pShape->m_lID); + if (pSlideWrapper->m_mapElements.end() != pPair) + oElemInfo = pPair->second; - // persist ---------------------------------------------------------------------- - std::vector* pArrayPlaceHolders = &pSlideWrapper->m_arTextPlaceHolders; - int lCountPersistObjects = pArrayPlaceHolders->size(); - int lPersistIndex = oElemInfo.m_lPersistIndex; + // persist ---------------------------------------------------------------------- + std::vector* pArrayPlaceHolders = &pSlideWrapper->m_arTextPlaceHolders; + int lCountPersistObjects = pArrayPlaceHolders->size(); + int lPersistIndex = oElemInfo.m_lPersistIndex; - if ((lPersistIndex >= 0) && (lPersistIndex < lCountPersistObjects)) - { - CTextFullSettings* pSettings = &pArrayPlaceHolders->at(lPersistIndex); + if ((lPersistIndex >= 0) && (lPersistIndex < lCountPersistObjects)) + { + CTextFullSettings* pSettings = &pArrayPlaceHolders->at(lPersistIndex); eTypePersist = (TextTypeEnum)pSettings->m_nTextType; - strText = pSettings->ApplyProperties(pTextSettings); + strText = pSettings->ApplyProperties(pTextSettings); - if ((0 != pSettings->m_arRanges.size()) && (0 == pShape->m_oTextActions.m_arRanges.size())) - { - pShape->m_oTextActions.m_bPresent = true; - - pShape->m_oTextActions.m_arRanges = pSettings->m_arRanges; - } + if ((0 != pSettings->m_arRanges.size()) && (0 == pShape->m_oTextActions.m_arRanges.size())) + { + pShape->m_oTextActions.m_bPresent = true; - bIsPersistPresentSettings = ((NULL != pSettings->m_pTextStyleProp) && (0 < pSettings->m_pTextStyleProp->m_lCount)); - } - // ------------------------------------------------------------------------------ + pShape->m_oTextActions.m_arRanges = pSettings->m_arRanges; + } - if (NULL != oElemInfo.m_pStream && -1 != oElemInfo.m_lOffsetTextStyle) - { - // теперь нужно загрузить стили текста из стрима. - LONG lPosition = 0; StreamUtils::StreamPosition(lPosition, oElemInfo.m_pStream); + bIsPersistPresentSettings = ((NULL != pSettings->m_pTextStyleProp) && (0 < pSettings->m_pTextStyleProp->m_lCount)); + } + // ------------------------------------------------------------------------------ - StreamUtils::StreamSeek(oElemInfo.m_lOffsetTextStyle - 8, oElemInfo.m_pStream); + if (NULL != oElemInfo.m_pStream && -1 != oElemInfo.m_lOffsetTextStyle) + { + // теперь нужно загрузить стили текста из стрима. + LONG lPosition = 0; StreamUtils::StreamPosition(lPosition, oElemInfo.m_pStream); - SRecordHeader oHeader; - oHeader.ReadFromStream(oElemInfo.m_pStream) ; + StreamUtils::StreamSeek(oElemInfo.m_lOffsetTextStyle - 8, oElemInfo.m_pStream); + + SRecordHeader oHeader; + oHeader.ReadFromStream(oElemInfo.m_pStream) ; if (RT_StyleTextPropAtom == oHeader.RecType) - { - CRecordStyleTextPropAtom* pStyle = new CRecordStyleTextPropAtom(); - pStyle->m_lCount = strText.length(); + { + CRecordStyleTextPropAtom* pStyle = new CRecordStyleTextPropAtom(); + pStyle->m_lCount = strText.length(); - pStyle->ReadFromStream(oHeader, oElemInfo.m_pStream); + pStyle->ReadFromStream(oHeader, oElemInfo.m_pStream); - PPT_FORMAT::ConvertPPTTextToEditorStructure(pStyle->m_arrPFs, pStyle->m_arrCFs, strText, pShape->m_pShape->m_oText); + PPT_FORMAT::ConvertPPTTextToEditorStructure(pStyle->m_arrPFs, pStyle->m_arrCFs, strText, pShape->m_pShape->m_oText); - bIsOwnPresentSettings = (0 < pStyle->m_lCount); + bIsOwnPresentSettings = (0 < pStyle->m_lCount); - RELEASEOBJECT(pStyle); - } - StreamUtils::StreamSeek(lPosition, oElemInfo.m_pStream); - } + RELEASEOBJECT(pStyle); + } + StreamUtils::StreamSeek(lPosition, oElemInfo.m_pStream); + } - // ------------------------------------------------------------------------------ + // ------------------------------------------------------------------------------ - // теперь выставляем все настройки текста (стили) - if (NULL == pSlide) - { - int nTextMasterType = (int)eTypeMaster; - if (-1 != pShape->m_lPlaceholderType) - { - switch (oElemInfo.m_lMasterPlaceholderType) - { - case PT_Title: - case PT_MasterTitle: - case PT_VerticalTitle: - { - pTextSettings->m_lStyleThemeIndex = 1; + // теперь выставляем все настройки текста (стили) + if (NULL == pSlide) + { + int nTextMasterType = (int)eTypeMaster; + if (-1 != pShape->m_lPlaceholderType) + { + switch (oElemInfo.m_lMasterPlaceholderType) + { + case PT_Title: + case PT_MasterTitle: + case PT_VerticalTitle: + { + pTextSettings->m_lStyleThemeIndex = 1; - if (Tx_TYPE_TITLE != eTypeMaster) - { - if (0 <= nTextMasterType && nTextMasterType < 9) - { - if (pThemeWrapper->m_pStyles[nTextMasterType].is_init()) - pTextSettings->m_oStyles = pThemeWrapper->m_pStyles[nTextMasterType].get(); - } - } - break; - } - case PT_CenterTitle: - case PT_MasterCenterTitle: - { - pTextSettings->m_lStyleThemeIndex = 1; + if (Tx_TYPE_TITLE != eTypeMaster) + { + if (0 <= nTextMasterType && nTextMasterType < 9) + { + if (pThemeWrapper->m_pStyles[nTextMasterType].is_init()) + pTextSettings->m_oStyles = pThemeWrapper->m_pStyles[nTextMasterType].get(); + } + } + break; + } + case PT_CenterTitle: + case PT_MasterCenterTitle: + { + pTextSettings->m_lStyleThemeIndex = 1; - if (Tx_TYPE_TITLE != eTypeMaster) - { - if (0 <= nTextMasterType && nTextMasterType < 9) - { - if (pThemeWrapper->m_pStyles[nTextMasterType].is_init()) - pTextSettings->m_oStyles = pThemeWrapper->m_pStyles[nTextMasterType].get(); - } - } - break; - } - case PT_Body: - case PT_MasterBody: - case PT_NotesBody: - case PT_MasterNotesBody: - case PT_VerticalBody: - case PT_MasterSubTitle: - case PT_SubTitle: - { - pTextSettings->m_lStyleThemeIndex = 2; + if (Tx_TYPE_TITLE != eTypeMaster) + { + if (0 <= nTextMasterType && nTextMasterType < 9) + { + if (pThemeWrapper->m_pStyles[nTextMasterType].is_init()) + pTextSettings->m_oStyles = pThemeWrapper->m_pStyles[nTextMasterType].get(); + } + } + break; + } + case PT_Body: + case PT_MasterBody: + case PT_NotesBody: + case PT_MasterNotesBody: + case PT_VerticalBody: + case PT_MasterSubTitle: + case PT_SubTitle: + { + pTextSettings->m_lStyleThemeIndex = 2; - if ((Tx_TYPE_BODY != eTypeMaster) || !pLayout) - { - if (0 <= nTextMasterType && nTextMasterType < 9) - { - if (pThemeWrapper->m_pStyles[nTextMasterType].is_init()) - pTextSettings->m_oStyles = pThemeWrapper->m_pStyles[nTextMasterType].get(); - } - } - break; - } - default: - { - pTextSettings->m_lStyleThemeIndex = 3; + if ((Tx_TYPE_BODY != eTypeMaster) || !pLayout) + { + if (0 <= nTextMasterType && nTextMasterType < 9) + { + if (pThemeWrapper->m_pStyles[nTextMasterType].is_init()) + pTextSettings->m_oStyles = pThemeWrapper->m_pStyles[nTextMasterType].get(); + } + } + break; + } + default: + { + pTextSettings->m_lStyleThemeIndex = 3; - if ((Tx_TYPE_OTHER != eTypeMaster) || !pLayout) - { - if (0 <= nTextMasterType && nTextMasterType < 9) - { - if (pThemeWrapper->m_pStyles[nTextMasterType].is_init()) - { - pTextSettings->m_oStyles = pThemeWrapper->m_pStyles[nTextMasterType].get(); - } - } - } - break; - } - } - } - else - { - //pTextSettings->m_lTextType = 0; + if ((Tx_TYPE_OTHER != eTypeMaster) || !pLayout) + { + if (0 <= nTextMasterType && nTextMasterType < 9) + { + if (pThemeWrapper->m_pStyles[nTextMasterType].is_init()) + { + pTextSettings->m_oStyles = pThemeWrapper->m_pStyles[nTextMasterType].get(); + } + } + } + break; + } + } + } + else + { + //pTextSettings->m_lTextType = 0; - //if (Other != eTypeMaster) - //{ - // if (0 <= nTextMasterType && nTextMasterType < 9) - // { - // if (pThemeWrapper->m_pStyles[nTextMasterType].is_init()) - // pTextSettings->m_oStyles = pThemeWrapper->m_pStyles[nTextMasterType].get(); - // } - //} - } + //if (Other != eTypeMaster) + //{ + // if (0 <= nTextMasterType && nTextMasterType < 9) + // { + // if (pThemeWrapper->m_pStyles[nTextMasterType].is_init()) + // pTextSettings->m_oStyles = pThemeWrapper->m_pStyles[nTextMasterType].get(); + // } + //} + } - // теперь смотрим все остальные стили (persist и own) - просто применяем их к m_oStyles - if (eTypePersist != NoPresent && eTypePersist != eTypeMaster) - { - int nIndexType = (int)eTypePersist; - if (0 <= nIndexType && nIndexType < 9) - { - if (pThemeWrapper->m_pStyles[nIndexType].is_init()) - pTextSettings->m_oStyles.ApplyAfter(pThemeWrapper->m_pStyles[nIndexType].get()); - } - } - if (eTypeOwn != NoPresent && eTypeOwn != eTypePersist && eTypeOwn != eTypeMaster) - { - int nIndexType = (int)eTypeOwn; - if (0 <= nIndexType && nIndexType < 9) - { - if (pThemeWrapper->m_pStyles[nIndexType].is_init()) - pTextSettings->m_oStyles.ApplyAfter(pThemeWrapper->m_pStyles[nIndexType].get()); - } - } - } - else - { - if (-1 != pShape->m_lPlaceholderType) - { - if (NULL != pElementLayoutPH) - { - pTextSettings->m_oLayoutStyles = pElementLayoutPH->m_pShape->m_oText.m_oStyles; - pTextSettings->m_lTextType = pElementLayoutPH->m_pShape->m_oText.m_lTextType; - pTextSettings->m_lStyleThemeIndex = pElementLayoutPH->m_pShape->m_oText.m_lStyleThemeIndex; - } - else - { - switch (oElemInfo.m_lMasterPlaceholderType) - { - case PT_Title: - case PT_MasterTitle: - case PT_VerticalTitle: - { - pTextSettings->m_lStyleThemeIndex = 1; - break; - } - case PT_CenterTitle: - case PT_MasterCenterTitle: - { - pTextSettings->m_lStyleThemeIndex = 1; - break; - } - case PT_Body: - case PT_MasterBody: - case PT_NotesBody: - case PT_MasterNotesBody: - case PT_VerticalBody: - { - pTextSettings->m_lStyleThemeIndex = 2; - break; - } - default: - { - pTextSettings->m_lStyleThemeIndex = 3; - break; - } - } - } - } - else - { - pTextSettings->m_lStyleThemeIndex = -1; - } + // теперь смотрим все остальные стили (persist и own) - просто применяем их к m_oStyles + if (eTypePersist != NoPresent && eTypePersist != eTypeMaster) + { + int nIndexType = (int)eTypePersist; + if (0 <= nIndexType && nIndexType < 9) + { + if (pThemeWrapper->m_pStyles[nIndexType].is_init()) + pTextSettings->m_oStyles.ApplyAfter(pThemeWrapper->m_pStyles[nIndexType].get()); + } + } + if (eTypeOwn != NoPresent && eTypeOwn != eTypePersist && eTypeOwn != eTypeMaster) + { + int nIndexType = (int)eTypeOwn; + if (0 <= nIndexType && nIndexType < 9) + { + if (pThemeWrapper->m_pStyles[nIndexType].is_init()) + pTextSettings->m_oStyles.ApplyAfter(pThemeWrapper->m_pStyles[nIndexType].get()); + } + } + } + else + { + if (-1 != pShape->m_lPlaceholderType) + { + if (NULL != pElementLayoutPH) + { + pTextSettings->m_oLayoutStyles = pElementLayoutPH->m_pShape->m_oText.m_oStyles; + pTextSettings->m_lTextType = pElementLayoutPH->m_pShape->m_oText.m_lTextType; + pTextSettings->m_lStyleThemeIndex = pElementLayoutPH->m_pShape->m_oText.m_lStyleThemeIndex; + } + else + { + switch (oElemInfo.m_lMasterPlaceholderType) + { + case PT_Title: + case PT_MasterTitle: + case PT_VerticalTitle: + { + pTextSettings->m_lStyleThemeIndex = 1; + break; + } + case PT_CenterTitle: + case PT_MasterCenterTitle: + { + pTextSettings->m_lStyleThemeIndex = 1; + break; + } + case PT_Body: + case PT_MasterBody: + case PT_NotesBody: + case PT_MasterNotesBody: + case PT_VerticalBody: + { + pTextSettings->m_lStyleThemeIndex = 2; + break; + } + default: + { + pTextSettings->m_lStyleThemeIndex = 3; + break; + } + } + } + } + else + { + pTextSettings->m_lStyleThemeIndex = -1; + } - // теперь смотрим все остальные стили (persist и own) - просто применяем их к m_oStyles - if (eTypePersist != NoPresent && eTypePersist != eTypeMaster) - { - int nIndexType = (int)eTypePersist; - if (0 <= nIndexType && nIndexType < 9) - { - if (pThemeWrapper->m_pStyles[nIndexType].is_init()) - pTextSettings->m_oStyles.ApplyAfter(pThemeWrapper->m_pStyles[nIndexType].get()); - } - } - if (eTypeOwn != NoPresent && eTypeOwn != Tx_TYPE_OTHER && eTypeOwn != eTypePersist && eTypeOwn != eTypeMaster) - {//齐孟尧-2015年度职工考核报告.ppt - int nIndexType = (int)eTypeOwn; - - if (0 <= nIndexType && nIndexType < 9 && pLayout) - { - if (eTypeOwn == Tx_TYPE_HALFBODY || eTypeOwn == Tx_TYPE_QUARTERBODY) - { - if (pThemeWrapper->m_pStyles[1].IsInit())//body -> (560).ppt - { - pTextSettings->m_oStyles.ApplyAfter(pThemeWrapper->m_pStyles[1].get()); - } - } - if (pThemeWrapper->m_pStyles[nIndexType].IsInit()) - { - pTextSettings->m_oStyles.ApplyAfter(pThemeWrapper->m_pStyles[nIndexType].get()); - } - } - } - } + // теперь смотрим все остальные стили (persist и own) - просто применяем их к m_oStyles + if (eTypePersist != NoPresent && eTypePersist != eTypeMaster) + { + int nIndexType = (int)eTypePersist; + if (0 <= nIndexType && nIndexType < 9) + { + if (pThemeWrapper->m_pStyles[nIndexType].is_init()) + pTextSettings->m_oStyles.ApplyAfter(pThemeWrapper->m_pStyles[nIndexType].get()); + } + } + if (eTypeOwn != NoPresent && eTypeOwn != Tx_TYPE_OTHER && eTypeOwn != eTypePersist && eTypeOwn != eTypeMaster) + {//齐孟尧-2015年度职工考核报告.ppt + int nIndexType = (int)eTypeOwn; - if ((_T("") != strText) && 0 == pTextSettings->m_arParagraphs.size()) - { - // значит никаких своих настроек нету. Значит просто пустые свои настройки - std::vector oArrayPF; - - CTextPFRunRecord elm; - - elm.m_lCount = strText.length(); - elm.m_lLevel = 0; - - oArrayPF.push_back(elm); + if (0 <= nIndexType && nIndexType < 9 && pLayout) + { + if (eTypeOwn == Tx_TYPE_HALFBODY || eTypeOwn == Tx_TYPE_QUARTERBODY) + { + if (pThemeWrapper->m_pStyles[1].IsInit())//body -> (560).ppt + { + pTextSettings->m_oStyles.ApplyAfter(pThemeWrapper->m_pStyles[1].get()); + } + } + if (pThemeWrapper->m_pStyles[nIndexType].IsInit()) + { + pTextSettings->m_oStyles.ApplyAfter(pThemeWrapper->m_pStyles[nIndexType].get()); + } + } + } + } - std::vector oArrayCF; - - CTextCFRunRecord elm1; - elm1.m_lCount = elm.m_lCount; - - oArrayCF.push_back(elm1); - - PPT_FORMAT::ConvertPPTTextToEditorStructure(oArrayPF, oArrayCF, strText, *pTextSettings); - } + if ((_T("") != strText) && 0 == pTextSettings->m_arParagraphs.size()) + { + // значит никаких своих настроек нету. Значит просто пустые свои настройки + std::vector oArrayPF; - if (NULL != oElemInfo.m_pStream && -1 != oElemInfo.m_lOffsetTextProp) - { - //языковые настройки текта - LONG lPosition = 0; StreamUtils::StreamPosition(lPosition, oElemInfo.m_pStream); + CTextPFRunRecord elm; - StreamUtils::StreamSeek(oElemInfo.m_lOffsetTextProp - 8, oElemInfo.m_pStream); + elm.m_lCount = strText.length(); + elm.m_lLevel = 0; - SRecordHeader oHeader; - oHeader.ReadFromStream(oElemInfo.m_pStream) ; + oArrayPF.push_back(elm); + + std::vector oArrayCF; + + CTextCFRunRecord elm1; + elm1.m_lCount = elm.m_lCount; + + oArrayCF.push_back(elm1); + + PPT_FORMAT::ConvertPPTTextToEditorStructure(oArrayPF, oArrayCF, strText, *pTextSettings); + } + + if (NULL != oElemInfo.m_pStream && -1 != oElemInfo.m_lOffsetTextProp) + { + //языковые настройки текта + LONG lPosition = 0; StreamUtils::StreamPosition(lPosition, oElemInfo.m_pStream); + + StreamUtils::StreamSeek(oElemInfo.m_lOffsetTextProp - 8, oElemInfo.m_pStream); + + SRecordHeader oHeader; + oHeader.ReadFromStream(oElemInfo.m_pStream) ; if (RT_TextSpecialInfoAtom == oHeader.RecType) - { - CRecordTextSpecInfoAtom* pSpecInfo = new CRecordTextSpecInfoAtom(); - pSpecInfo->m_lCount = -1; + { + CRecordTextSpecInfoAtom* pSpecInfo = new CRecordTextSpecInfoAtom(); + pSpecInfo->m_lCount = -1; - pSpecInfo->ReadFromStream(oHeader, oElemInfo.m_pStream); - pSpecInfo->ApplyProperties(&(pShape->m_pShape->m_oText)); + pSpecInfo->ReadFromStream(oHeader, oElemInfo.m_pStream); + pSpecInfo->ApplyProperties(&(pShape->m_pShape->m_oText)); - RELEASEOBJECT(pSpecInfo); - } - StreamUtils::StreamSeek(lPosition, oElemInfo.m_pStream); - } - pShape->m_pShape->m_oText.RecalcParagraphsPPT(); - - ApplyThemeStyle(pElem, pTheme, master_levels); + RELEASEOBJECT(pSpecInfo); + } + StreamUtils::StreamSeek(lPosition, oElemInfo.m_pStream); + } + pShape->m_pShape->m_oText.RecalcParagraphsPPT(); - if (pShape->m_oTextActions.m_bPresent) - { - //todooo разобраться нужно ли менять цвет на гиперлинк - 1-(34).ppt - ODRAW::CColor oColor; - if ((NULL != pSlide) && !pSlide->m_bUseLayoutColorScheme) oColor = pSlide->GetColor(11); - else if ((NULL != pLayout) && (!pLayout->m_bUseThemeColorScheme)) oColor = pLayout->GetColor(11); - else if (NULL != pTheme) oColor = pTheme->GetColor(11); - oColor.m_lSchemeIndex = 11; + ApplyThemeStyle(pElem, pTheme, master_levels); - ApplyHyperlink(pShape, oColor); - } + if (pShape->m_oTextActions.m_bPresent) + { + //todooo разобраться нужно ли менять цвет на гиперлинк - 1-(34).ppt + ODRAW::CColor oColor; + if ((NULL != pSlide) && !pSlide->m_bUseLayoutColorScheme) oColor = pSlide->GetColor(11); + else if ((NULL != pLayout) && (!pLayout->m_bUseThemeColorScheme)) oColor = pLayout->GetColor(11); + else if (NULL != pTheme) oColor = pTheme->GetColor(11); + oColor.m_lSchemeIndex = 11; - CPPTShape* pPPTShape = dynamic_cast(pShape->m_pShape->getBaseShape().get()); + ApplyHyperlink(pShape, oColor); + } - if (NULL != pPPTShape) // проверка на wordart - { - switch (pPPTShape->m_eType) - { - case sptTextPlainText: - case sptTextStop: - case sptTextTriangle: - case sptTextTriangleInverted: - case sptTextChevron: - case sptTextChevronInverted: - case sptTextRingInside: - case sptTextRingOutside: - case sptTextArchUpCurve: - case sptTextArchDownCurve: - case sptTextCircleCurve: - case sptTextButtonCurve: - case sptTextArchUpPour: - case sptTextArchDownPour: - case sptTextCirclePour: - case sptTextButtonPour: - case sptTextCurveUp: - case sptTextCurveDown: - case sptTextCascadeUp: - case sptTextCascadeDown: - case sptTextWave1: - case sptTextWave2: - case sptTextWave3: - case sptTextWave4: - case sptTextInflate: - case sptTextDeflate: - case sptTextInflateBottom: - case sptTextDeflateBottom: - case sptTextInflateTop: - case sptTextDeflateTop: - case sptTextDeflateInflate: - case sptTextDeflateInflateDeflate: - case sptTextFadeRight: - case sptTextFadeLeft: - case sptTextFadeUp: - case sptTextFadeDown: - case sptTextSlantUp: - case sptTextSlantDown: - case sptTextCanUp: - case sptTextCanDown: - { - pShape->m_pShape->m_oText.m_oAttributes.m_oTextBrush = pShape->m_oBrush; + CPPTShape* pPPTShape = dynamic_cast(pShape->m_pShape->getBaseShape().get()); - pShape->m_pShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 1; - pShape->m_pShape->m_oText.m_oAttributes.m_nTextAlignVertical = 1; + if (NULL != pPPTShape) // проверка на wordart + { + switch (pPPTShape->m_eType) + { + case sptTextPlainText: + case sptTextStop: + case sptTextTriangle: + case sptTextTriangleInverted: + case sptTextChevron: + case sptTextChevronInverted: + case sptTextRingInside: + case sptTextRingOutside: + case sptTextArchUpCurve: + case sptTextArchDownCurve: + case sptTextCircleCurve: + case sptTextButtonCurve: + case sptTextArchUpPour: + case sptTextArchDownPour: + case sptTextCirclePour: + case sptTextButtonPour: + case sptTextCurveUp: + case sptTextCurveDown: + case sptTextCascadeUp: + case sptTextCascadeDown: + case sptTextWave1: + case sptTextWave2: + case sptTextWave3: + case sptTextWave4: + case sptTextInflate: + case sptTextDeflate: + case sptTextInflateBottom: + case sptTextDeflateBottom: + case sptTextInflateTop: + case sptTextDeflateTop: + case sptTextDeflateInflate: + case sptTextDeflateInflateDeflate: + case sptTextFadeRight: + case sptTextFadeLeft: + case sptTextFadeUp: + case sptTextFadeDown: + case sptTextSlantUp: + case sptTextSlantDown: + case sptTextCanUp: + case sptTextCanDown: + { + pShape->m_pShape->m_oText.m_oAttributes.m_oTextBrush = pShape->m_oBrush; - pShape->m_pShape->m_lDrawType = c_ShapeDrawType_Text; - break; - } - default: - break; - }; - } + pShape->m_pShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 1; + pShape->m_pShape->m_oText.m_oAttributes.m_nTextAlignVertical = 1; + + pShape->m_pShape->m_lDrawType = c_ShapeDrawType_Text; + break; + } + default: + break; + }; + } } void CRecordShapeContainer::ApplyHyperlink(CShapeElement* pShape, CColor& oColor) { - std::vector* pRanges = &pShape->m_oTextActions.m_arRanges; - CTextAttributesEx* pTextAttributes = &pShape->m_pShape->m_oText; + std::vector* pRanges = &pShape->m_oTextActions.m_arRanges; + CTextAttributesEx* pTextAttributes = &pShape->m_pShape->m_oText; - int lCountHyper = pRanges->size(); + int lCountHyper = pRanges->size(); - if (0 == lCountHyper) - return; + if (0 == lCountHyper) + return; - size_t nCountPars = pTextAttributes->m_arParagraphs.size(); - for (int nIndexRange = 0; nIndexRange < lCountHyper; ++nIndexRange) - { - int lStart = (*pRanges)[nIndexRange].m_lStart; - int lEnd = (*pRanges)[nIndexRange].m_lEnd; + size_t nCountPars = pTextAttributes->m_arParagraphs.size(); + for (int nIndexRange = 0; nIndexRange < lCountHyper; ++nIndexRange) + { + int lStart = (*pRanges)[nIndexRange].m_lStart; + int lEnd = (*pRanges)[nIndexRange].m_lEnd; - int lCurrentStart = 0; - for (size_t nIndexPar = 0; nIndexPar < nCountPars; ++nIndexPar) - { - CParagraph* pParagraph = &pTextAttributes->m_arParagraphs[nIndexPar]; + int lCurrentStart = 0; + for (size_t nIndexPar = 0; nIndexPar < nCountPars; ++nIndexPar) + { + CParagraph* pParagraph = &pTextAttributes->m_arParagraphs[nIndexPar]; - for (size_t nIndexSpan = 0; nIndexSpan < pParagraph->m_arSpans.size(); ++nIndexSpan) - { - int lCurrentEnd = lCurrentStart + pParagraph->m_arSpans[nIndexSpan].m_strText.length() - 1; + for (size_t nIndexSpan = 0; nIndexSpan < pParagraph->m_arSpans.size(); ++nIndexSpan) + { + int lCurrentEnd = lCurrentStart + pParagraph->m_arSpans[nIndexSpan].m_strText.length() - 1; - if (lCurrentStart > lEnd || lCurrentEnd < lStart) - { - lCurrentStart = lCurrentEnd + 1; - continue; - } + if (lCurrentStart > lEnd || lCurrentEnd < lStart) + { + lCurrentStart = lCurrentEnd + 1; + continue; + } int lStart_ = (std::max)(lStart, lCurrentStart); int lEnd_ = (std::min)(lEnd, lCurrentEnd); - CSpan oRunProp = pParagraph->m_arSpans[nIndexSpan]; + CSpan oRunProp = pParagraph->m_arSpans[nIndexSpan]; - std::wstring strText = pParagraph->m_arSpans[nIndexSpan].m_strText; - if (lStart_ > lCurrentStart) - { - pParagraph->m_arSpans.insert(pParagraph->m_arSpans.begin() + nIndexSpan, oRunProp); - pParagraph->m_arSpans[nIndexSpan].m_strText = strText.substr(0, lStart_ - lCurrentStart); + std::wstring strText = pParagraph->m_arSpans[nIndexSpan].m_strText; + if (lStart_ > lCurrentStart) + { + pParagraph->m_arSpans.insert(pParagraph->m_arSpans.begin() + nIndexSpan, oRunProp); + pParagraph->m_arSpans[nIndexSpan].m_strText = strText.substr(0, lStart_ - lCurrentStart); - ++nIndexSpan; - } - pParagraph->m_arSpans[nIndexSpan].m_oRun.Color = oColor; + ++nIndexSpan; + } + pParagraph->m_arSpans[nIndexSpan].m_oRun.Color = oColor; pParagraph->m_arSpans[nIndexSpan].m_oRun.FontUnderline = (bool)true; - pParagraph->m_arSpans[nIndexSpan].m_strText = strText.substr(lStart_ - lCurrentStart, lEnd_ - lStart_ + 1); - if (lEnd_ < lCurrentEnd) - { - pParagraph->m_arSpans.insert(pParagraph->m_arSpans.begin() + nIndexSpan + 1, oRunProp); - ++nIndexSpan; + pParagraph->m_arSpans[nIndexSpan].m_strText = strText.substr(lStart_ - lCurrentStart, lEnd_ - lStart_ + 1); + if (lEnd_ < lCurrentEnd) + { + pParagraph->m_arSpans.insert(pParagraph->m_arSpans.begin() + nIndexSpan + 1, oRunProp); + ++nIndexSpan; - pParagraph->m_arSpans[nIndexSpan].m_strText = strText.substr(lEnd_ - lCurrentStart + 1, lCurrentEnd - lEnd_); - } + pParagraph->m_arSpans[nIndexSpan].m_strText = strText.substr(lEnd_ - lCurrentStart + 1, lCurrentEnd - lEnd_); + } - lCurrentStart = lCurrentEnd + 1; - } - } - } + lCurrentStart = lCurrentEnd + 1; + } + } + } } void CRecordGroupShapeContainer::ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream) { - CRecordsContainer::ReadFromStream(oHeader, pStream); + CRecordsContainer::ReadFromStream(oHeader, pStream); } From 110cee404a4651ab399b8b4a78def2979ea3a921 Mon Sep 17 00:00:00 2001 From: KirillovIlya Date: Tue, 20 Jul 2021 19:05:35 +0300 Subject: [PATCH 44/84] Fix bug #50743 Improve rendering of bold text when there is no bold font --- PdfWriter/PdfRenderer.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/PdfWriter/PdfRenderer.cpp b/PdfWriter/PdfRenderer.cpp index 485e82de02..77bbd9313b 100644 --- a/PdfWriter/PdfRenderer.cpp +++ b/PdfWriter/PdfRenderer.cpp @@ -416,9 +416,14 @@ void CPdfRenderer::CCommandManager::Flush() isNeedDoBold = pText->IsNeedDoBold(); if (isNeedDoBold && eMode == textrenderingmode_Fill) + { + pPage->SetLineWidth(dTextSize / 12 * 0.343); pPage->SetTextRenderingMode(textrenderingmode_FillThenStroke); + } else + { pPage->SetTextRenderingMode(eMode); + } } if (fabs(dHorScaling - pText->GetHorScaling()) > 0.001) From 14c517eaf564a83e3ce6215c6ea88d23d07d83ca Mon Sep 17 00:00:00 2001 From: Oleg Korshul Date: Tue, 20 Jul 2021 20:36:09 +0300 Subject: [PATCH 45/84] Add flag for disable all warnings --- Common/base.pri | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Common/base.pri b/Common/base.pri index c1cae56ff6..c20502723f 100644 --- a/Common/base.pri +++ b/Common/base.pri @@ -322,6 +322,10 @@ plugin { } } +core_disable_all_warnings { + CONFIG += warn_off +} + # BUILD_PATHS # MUST BE DEFINED CORE_ROOT_DIR !core_no_dst { From 3a97757b86487cf89ad5eb5edb0a5739a67e3baa Mon Sep 17 00:00:00 2001 From: KirillovIlya Date: Tue, 20 Jul 2021 21:56:36 +0300 Subject: [PATCH 46/84] Fix bug #50874 Fix the problem with escaping text strings --- PdfWriter/PdfRenderer.cpp | 11 +++++++++-- PdfWriter/Src/Utils.h | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/PdfWriter/PdfRenderer.cpp b/PdfWriter/PdfRenderer.cpp index 77bbd9313b..28b327bc96 100644 --- a/PdfWriter/PdfRenderer.cpp +++ b/PdfWriter/PdfRenderer.cpp @@ -365,6 +365,7 @@ void CPdfRenderer::CCommandManager::Flush() ETextRenderingMode eMode = textrenderingmode_Fill; bool isNeedDoBold = false; bool isNeedDoItalic = false; + double dLineWidth = -1; double dPrevX = -1000; double dPrevY = -1000; @@ -417,7 +418,13 @@ void CPdfRenderer::CCommandManager::Flush() if (isNeedDoBold && eMode == textrenderingmode_Fill) { - pPage->SetLineWidth(dTextSize / 12 * 0.343); + double dNewLineWidth = dTextSize / 12 * 0.343; + if (fabs(dLineWidth - dNewLineWidth) > 0.001) + { + dLineWidth = dNewLineWidth; + pPage->SetLineWidth(dLineWidth); + } + pPage->SetTextRenderingMode(textrenderingmode_FillThenStroke); } else @@ -462,8 +469,8 @@ void CPdfRenderer::CCommandManager::Flush() } } } - oTextLine.Flush(pPage); + oTextLine.Flush(pPage); pPage->EndText(); } diff --git a/PdfWriter/Src/Utils.h b/PdfWriter/Src/Utils.h index 65974e12ae..4e564976c6 100644 --- a/PdfWriter/Src/Utils.h +++ b/PdfWriter/Src/Utils.h @@ -34,12 +34,12 @@ #include "Types.h" -#define NEEDS_ESCAPE(c) (c < 0x20 || \ +#define NEEDS_ESCAPE(c) (c < 0x21 || \ c > 0x7e || \ c == '\\' || \ c == '%' || \ c == '#' || \ - /*c == '/' || */\ + c == '/' || \ c == '(' || \ c == ')' || \ c == '<' || \ From bbcd181d9dbb368fb49081dfe7f2b176dbcfea48 Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Wed, 21 Jul 2021 16:27:12 +0300 Subject: [PATCH 47/84] fix bug #51387; fix macro save --- ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.cpp | 6 +++--- ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.h | 2 +- .../source/Oox2OdfConverter/XlsxConverter.cpp | 9 ++++++--- ASCOfficePPTXFile/PPTXFormat/Logic/Shape.cpp | 1 + 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.cpp b/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.cpp index 24fc6319e5..883df8640d 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.cpp @@ -1630,9 +1630,9 @@ void ods_table_state::end_conditional_format() { current_level_.pop_back(); } -void ods_table_state::start_conditional_rule(int rule_type) +void ods_table_state::start_conditional_rule(int rule_type, _CP_OPT(unsigned int) rank) { - office_element_ptr elm; + office_element_ptr elm; if (rule_type == 3) create_element(L"calcext", L"color-scale", elm, context_); else if (rule_type == 7)create_element(L"calcext", L"data-bar", elm ,context_); @@ -1680,7 +1680,7 @@ void ods_table_state::start_conditional_rule(int rule_type) case 11: condition->attr_.calcext_value_ = L"not-contains-text()"; break; case 12: condition->attr_.calcext_value_ = L"is-no-error"; break; case 13: condition->attr_.calcext_value_ = L"not-contains-text()"; break; - case 15: condition->attr_.calcext_value_ = L"top-elements()"; break;//bottom-elements ??? + case 15: condition->attr_.calcext_value_ = L"top-elements(" + std::to_wstring(rank.get_value_or(10)) + L")"; break;//bottom-elements ??? case 16: condition->attr_.calcext_value_ = L"unique"; break; case 2: /*cellIs*/ default: break; diff --git a/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.h b/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.h index e2f7304464..1290edaeb1 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.h +++ b/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.h @@ -375,7 +375,7 @@ public: void start_conditional_formats(); void start_conditional_format(std::wstring ref); - void start_conditional_rule(int rule_type); + void start_conditional_rule(int rule_type, _CP_OPT(unsigned int) rank); void set_conditional_formula(std::wstring formula); void set_conditional_value(int type, std::wstring value ); void set_conditional_iconset(int type_iconset); diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp index a39a56138e..7f2258454b 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp @@ -3229,8 +3229,11 @@ void XlsxConverter::convert(OOX::Spreadsheet::CConditionalFormattingRule *oox_co if (!oox_cond_rule)return; if (false == oox_cond_rule->m_oType.IsInit()) return; + + _CP_OPT(unsigned int) rank; + if (oox_cond_rule->m_oRank.IsInit()) rank = oox_cond_rule->m_oRank->GetValue(); - ods_context->current_table()->start_conditional_rule(oox_cond_rule->m_oType->GetValue()); + ods_context->current_table()->start_conditional_rule(oox_cond_rule->m_oType->GetValue(), rank); { if (oox_cond_rule->m_oDxfId.IsInit()) { @@ -3249,7 +3252,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CConditionalFormattingRule *oox_co ods_context->current_table()->set_conditional_operator(oox_cond_rule->m_oOperator->GetValue()); if (oox_cond_rule->m_oText.IsInit()) - ods_context->current_table()->set_conditional_text(oox_cond_rule->m_oText.get2()); + ods_context->current_table()->set_conditional_text(*oox_cond_rule->m_oText); convert(oox_cond_rule->m_oIconSet.GetPointer()); convert(oox_cond_rule->m_oColorScale.GetPointer()); @@ -3315,7 +3318,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CConditionalFormatValueObject *oox if (oox_cond_value->m_oType.IsInit()) type = oox_cond_value->m_oType->GetValue(); if (oox_cond_value->m_oFormula.IsInit()) val = oox_cond_value->m_oFormula->m_sText; - else if (oox_cond_value->m_oVal.IsInit()) val = oox_cond_value->m_oVal.get2(); + else if (oox_cond_value->m_oVal.IsInit()) val = *oox_cond_value->m_oVal; ods_context->current_table()->set_conditional_value(type, val); } diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/Shape.cpp b/ASCOfficePPTXFile/PPTXFormat/Logic/Shape.cpp index af36df4a73..f4b3a0b24c 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/Shape.cpp +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/Shape.cpp @@ -435,6 +435,7 @@ namespace PPTX pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); pWriter->WriteBool2(0, attrUseBgFill); + pWriter->WriteString2(1, attrMacro); pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); pWriter->WriteRecord1(0, nvSpPr); From a009d4d918e42d02d81ec8e27a28406c8d0d2350 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Wed, 21 Jul 2021 18:30:53 +0300 Subject: [PATCH 48/84] remove text hyperlinking. Need to rewrite it --- .../PPTFormatLib/PPTXWriter/ShapeWriter.cpp | 10 +++++----- .../PPTFormatLib/PPTXWriter/ShapeWriter.h | 2 +- .../Records/Drawing/ShapeContainer.cpp | 14 ++++++++++++-- ASCOfficePPTXFile/Editor/Drawing/TextStructures.h | 4 +++- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp index 2ad6d42696..b228283d8d 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp @@ -691,7 +691,7 @@ void PPT_FORMAT::CShapeWriter::WriteImageInfo() m_oWriter.WriteString(std::wstring(L">")); - WriteButton(); + WriteHyperlink(m_pElement->m_arrActions); m_oWriter.WriteString(std::wstring(L"")); - WriteButton(); + WriteHyperlink(m_pElement->m_arrActions); if (!pShapeElement->m_sHyperlink.empty()) { std::wstring rId = m_pRels->WriteHyperlink(pShapeElement->m_sHyperlink); @@ -1482,6 +1482,7 @@ void PPT_FORMAT::CShapeWriter::WriteTextInfo() else { m_oWriter.WriteString(std::wstring(L"oArrayInteractive); } } @@ -1583,7 +1584,7 @@ void PPT_FORMAT::CShapeWriter::WriteTextInfo() m_oWriter.WriteString(std::wstring(L"font.sym->Name + _T("\"/>")); } -// WriteButton(nIndexPar); +// WriteHyperlink(nIndexPar); m_oWriter.WriteString(std::wstring(L"")); @@ -1684,9 +1685,8 @@ std::wstring PPT_FORMAT::CShapeWriter::ConvertGroup() return m_oWriter.GetData(); } -void PPT_FORMAT::CShapeWriter::WriteButton(int paragraphNum) +void PPT_FORMAT::CShapeWriter::WriteHyperlink(const std::vector& actions) { - auto actions = getActionsByNum(paragraphNum); for (unsigned i = 0; i < actions.size(); i++) { if (actions[i].m_lType == CInteractiveInfo::over diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.h index 756bcb5d6d..431595605a 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.h @@ -448,7 +448,7 @@ namespace PPT_FORMAT void WriteGroupInfo(); void WriteTableInfo(); - void WriteButton(int paragraphNum = -1); + void WriteHyperlink(const std::vector &actions); std::vector getActionsByNum(const int num); std::wstring ConvertTableCells(); std::wstring ConvertTableRow(); diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp index ac01b90410..42674f622e 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp @@ -1806,10 +1806,20 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, pElementLayout->m_bChildAnchorEnabled = pElement->m_bChildAnchorEnabled; } + std::vector oArrayArtClient; + GetRecordsByType(&oArrayArtClient, false, true); std::vector oArrayInteractive; - GetRecordsByType(&oArrayInteractive, true, false); std::vector oArrayMacro; - GetRecordsByType(&oArrayMacro, true, false); +// GetRecordsByType(&oArrayMacro, true, false); + + if (oArrayArtClient.size()) + oArrayArtClient[0]->GetRecordsByType(&oArrayInteractive, true, false); + else + { + GetRecordsByType(&oArrayInteractive, true, false); + if (oArrayInteractive.size()) + oArrayInteractive.clear(); + } if (oArrayInteractive.size() == 2) oArrayInteractive[1]->m_oHeader.RecInstance = 1; diff --git a/ASCOfficePPTXFile/Editor/Drawing/TextStructures.h b/ASCOfficePPTXFile/Editor/Drawing/TextStructures.h index 1a9469345a..c30bfc8251 100644 --- a/ASCOfficePPTXFile/Editor/Drawing/TextStructures.h +++ b/ASCOfficePPTXFile/Editor/Drawing/TextStructures.h @@ -33,6 +33,7 @@ #include "Structures.h" #include "../../../ASCOfficePPTFile/PPTFormatLib/Enums/enums.h" #include "../../../Common/DocxFormat/Source/Base/Nullable.h" +#include "../../../ASCOfficePPTXFile/Editor/Drawing/Interactive.h" using namespace ODRAW; @@ -163,7 +164,8 @@ namespace PPT_FORMAT NSCommon::nullable_base Cap; // 0 - none, 1 - TEXT, 2 - text NSCommon::nullable_base Language; - CFontProperties font; + CFontProperties font; + std::vector oArrayInteractive; CTextCFRun() { From 208bf7800392e263c70c75bb426370286d584d0d Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Thu, 22 Jul 2021 15:05:12 +0300 Subject: [PATCH 49/84] fix bug #51328 --- .../src/docx/docx_conversion_context.cpp | 15 +++++++++++++-- ASCOfficeOdfFile/src/odf/odf_document_impl.cpp | 2 +- .../src/odf/style_paragraph_properties_docx.cpp | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ASCOfficeOdfFile/src/docx/docx_conversion_context.cpp b/ASCOfficeOdfFile/src/docx/docx_conversion_context.cpp index 8eb4562902..4abc361a27 100644 --- a/ASCOfficeOdfFile/src/docx/docx_conversion_context.cpp +++ b/ASCOfficeOdfFile/src/docx/docx_conversion_context.cpp @@ -1119,6 +1119,8 @@ void docx_conversion_context::process_styles() } _Wostream << L""; + std::wstring default_style; + for (size_t i = 0; i < arStyles.size(); i++) { if (false == arStyles[i]->is_automatic() && @@ -1134,6 +1136,11 @@ void docx_conversion_context::process_styles() if (bDefault) // style { _Wostream << L" w:default=\"1\""; + + if (arStyles[i]->type() == odf_types::style_family::Paragraph) + { + default_style = id; + } } else if (!arStyles[i]->is_default()) // default-style { @@ -1150,6 +1157,10 @@ void docx_conversion_context::process_styles() const std::wstring basedOnId = styles_map_.get(baseOn->name(), baseOn->type()); _Wostream << L""; } + else if (!bDefault && !default_style.empty()) + { + _Wostream << L""; + } // else if (false == bDefault && false == arStyles[i]->is_default() && styles_map_.check(L"", arStyles[i]->type())) // { //bDisplayed = false; @@ -1809,7 +1820,7 @@ int docx_conversion_context::process_paragraph_attr(odf_reader::text::paragraph_ //process_paragraph_style(Context.get_current_paragraph_style()); ?? //if ((Attr->outline_level_) && (*Attr->outline_level_ > 0)) - if (outline_level) + if ((outline_level) && (*outline_level < 10)) { output_stream() << L""; output_stream() << L""; @@ -1821,7 +1832,7 @@ int docx_conversion_context::process_paragraph_attr(odf_reader::text::paragraph_ output_stream() << get_section_context().dump_; get_section_context().dump_.clear(); //if ((Attr->outline_level_) && (*Attr->outline_level_ > 0)) - if (outline_level) + if ((outline_level) && (*outline_level < 10)) { output_stream() << L""; } diff --git a/ASCOfficeOdfFile/src/odf/odf_document_impl.cpp b/ASCOfficeOdfFile/src/odf/odf_document_impl.cpp index 1ec3f9fc00..91ca4d5cea 100644 --- a/ASCOfficeOdfFile/src/odf/odf_document_impl.cpp +++ b/ASCOfficeOdfFile/src/odf/odf_document_impl.cpp @@ -854,7 +854,7 @@ void odf_document::Impl::parse_styles(office_element *element) L"", L"", L"", - L""); + L"default"); } for (size_t i = 0; i < docStyles->style_presentation_page_layout_.size(); i++) { diff --git a/ASCOfficeOdfFile/src/odf/style_paragraph_properties_docx.cpp b/ASCOfficeOdfFile/src/odf/style_paragraph_properties_docx.cpp index 5cff1ea5f7..6ecf8462ce 100644 --- a/ASCOfficeOdfFile/src/odf/style_paragraph_properties_docx.cpp +++ b/ASCOfficeOdfFile/src/odf/style_paragraph_properties_docx.cpp @@ -181,7 +181,7 @@ void paragraph_format_properties::docx_convert(oox::docx_conversion_context & Co } } - if (level >= 0) + if (level >= 0 && level < 10) { if (list_styles.outline_style()) { From 90565663d5d8426e24e34171ac5adf8cd8a371ad Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Thu, 22 Jul 2021 15:06:42 +0300 Subject: [PATCH 50/84] fix bug #51445 --- .../DocxFormat/Projects/DocxFormatLib.vcxproj | 1 + .../Projects/DocxFormatLib.vcxproj.filters | 33 ++++++++++--------- .../Source/XlsxFormat/Worksheets/Sparkline.h | 4 +-- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/Common/DocxFormat/Projects/DocxFormatLib.vcxproj b/Common/DocxFormat/Projects/DocxFormatLib.vcxproj index 12a3b3799e..90c23b0a01 100644 --- a/Common/DocxFormat/Projects/DocxFormatLib.vcxproj +++ b/Common/DocxFormat/Projects/DocxFormatLib.vcxproj @@ -403,6 +403,7 @@ + diff --git a/Common/DocxFormat/Projects/DocxFormatLib.vcxproj.filters b/Common/DocxFormat/Projects/DocxFormatLib.vcxproj.filters index 39851d321c..6281864915 100644 --- a/Common/DocxFormat/Projects/DocxFormatLib.vcxproj.filters +++ b/Common/DocxFormat/Projects/DocxFormatLib.vcxproj.filters @@ -121,9 +121,6 @@ {1be492b6-dbf2-436f-be99-b8ce8cd99269} - - {ebf55a86-a27b-4d5d-a95b-1f9cbc890855} - {c6fe581a-01db-4119-9bbc-1dfdc7e376ed} @@ -163,6 +160,9 @@ {744df142-08f4-4564-9383-0594368c1eb2} + + {ebf55a86-a27b-4d5d-a95b-1f9cbc890855} + @@ -484,37 +484,37 @@ XlsxFormat\SharedStrings - XlsxFormat\Styles + XlsxFormat\Slicer\Styles - XlsxFormat\Styles + XlsxFormat\Slicer\Styles - XlsxFormat\Styles + XlsxFormat\Slicer\Styles - XlsxFormat\Styles + XlsxFormat\Slicer\Styles - XlsxFormat\Styles + XlsxFormat\Slicer\Styles - XlsxFormat\Styles + XlsxFormat\Slicer\Styles - XlsxFormat\Styles + XlsxFormat\Slicer\Styles - XlsxFormat\Styles + XlsxFormat\Slicer\Styles - XlsxFormat\Styles + XlsxFormat\Slicer\Styles - XlsxFormat\Styles + XlsxFormat\Slicer\Styles - XlsxFormat\Styles + XlsxFormat\Slicer\Styles XlsxFormat\Table @@ -697,6 +697,9 @@ XlsxFormat\Chart + + XlsxFormat\Worksheets + @@ -814,7 +817,7 @@ XlsxFormat\SharedStrings - XlsxFormat\Styles + XlsxFormat\Slicer\Styles XlsxFormat\Table diff --git a/Common/DocxFormat/Source/XlsxFormat/Worksheets/Sparkline.h b/Common/DocxFormat/Source/XlsxFormat/Worksheets/Sparkline.h index 8e1011a9de..41b392d4e5 100644 --- a/Common/DocxFormat/Source/XlsxFormat/Worksheets/Sparkline.h +++ b/Common/DocxFormat/Source/XlsxFormat/Worksheets/Sparkline.h @@ -65,13 +65,13 @@ namespace OOX if(m_oRef.IsInit()) { writer.WriteString(_T("")); - writer.WriteString(m_oRef.get()); + writer.WriteEncodeXmlString(m_oRef.get()); writer.WriteString(_T("")); } if(m_oSqRef.IsInit()) { writer.WriteString(_T("")); - writer.WriteString(m_oSqRef.get()); + writer.WriteEncodeXmlString(m_oSqRef.get()); writer.WriteString(_T("")); } writer.WriteString(_T("")); From bbc0f1231db6c85af190c126198fd2139e28077b Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Thu, 22 Jul 2021 15:23:34 +0300 Subject: [PATCH 51/84] fix issue 1321 --- ASCOfficeOdfFile/src/odf/table_xlsx.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ASCOfficeOdfFile/src/odf/table_xlsx.cpp b/ASCOfficeOdfFile/src/odf/table_xlsx.cpp index f4238f3199..f8bd0fc7fa 100644 --- a/ASCOfficeOdfFile/src/odf/table_xlsx.cpp +++ b/ASCOfficeOdfFile/src/odf/table_xlsx.cpp @@ -904,7 +904,10 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context) if (number_val.empty() && !bool_val) { - sharedStringId = content_.xlsx_convert(Context, textFormatProperties); + if (!formula.empty()) + xlsx_value_type = oox::XlsxCellType::str; + else + sharedStringId = content_.xlsx_convert(Context, textFormatProperties); } //--------------------------------------------------------------------------------------------------------- From 974b9bcc1b3360c65a4cda93876707f7d33cb56b Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Thu, 22 Jul 2021 17:50:10 +0300 Subject: [PATCH 52/84] add CRecordMouseInteractiveInfoContainer --- .../PPTFormatLib/Linux/PPTFormatLib.pro | 1 + .../PPTFormatLib/Reader/Records.cpp | 2 +- .../Records/Drawing/ShapeContainer.cpp | 44 ++-- .../Records/InteractiveInfoAtom.h | 2 - .../Records/MouseInteractiveInfoContainer.h | 68 ++++++ .../PPTFormatLib/Records/RecordsIncluder.h | 1 + .../Editor/Drawing/Interactive.h | 202 +++++++++--------- 7 files changed, 189 insertions(+), 131 deletions(-) create mode 100644 ASCOfficePPTFile/PPTFormatLib/Records/MouseInteractiveInfoContainer.h diff --git a/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro b/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro index 54359fa016..0cffd9e663 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro +++ b/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro @@ -440,6 +440,7 @@ HEADERS += \ ../Records/BuildAtom.h \ ../Records/DocInfoListContainer.h \ ../Records/DocProgTagsContainer.h \ + ../Records/MouseInteractiveInfoContainer.h \ ../Records/OfficeArtClientData.h \ ../Records/PlaceHolderAtom.h \ ../Records/ShapeProgBinaryTagSubContainerOrAtom.h \ diff --git a/ASCOfficePPTFile/PPTFormatLib/Reader/Records.cpp b/ASCOfficePPTFile/PPTFormatLib/Reader/Records.cpp index 654a700b85..ab8b80f51d 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Reader/Records.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Reader/Records.cpp @@ -624,6 +624,7 @@ IRecord* CreateByType(SRecordHeader oHeader) // интерактив CREATE_BY_TYPE(RT_InteractiveInfoAtom , CRecordInteractiveInfoAtom) CREATE_BY_TYPE(RT_TextInteractiveInfoAtom , CRecordTextInteractiveInfoAtom) + CREATE_BY_TYPE(RT_InteractiveInfo , CRecordMouseInteractiveInfoContainer) // читаем для анимации @@ -633,7 +634,6 @@ IRecord* CreateByType(SRecordHeader oHeader) CREATE_BY_TYPE(RT_Sound , CRecordSoundContainer) CREATE_BY_TYPE(RT_SoundDataBlob , CRecordSoundDataBlob) - default: { }break; diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp index 42674f622e..bef6bf4531 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp @@ -1808,59 +1808,49 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, std::vector oArrayArtClient; GetRecordsByType(&oArrayArtClient, false, true); - std::vector oArrayInteractive; - std::vector oArrayMacro; -// GetRecordsByType(&oArrayMacro, true, false); + std::vector oArrayInteractive; if (oArrayArtClient.size()) oArrayArtClient[0]->GetRecordsByType(&oArrayInteractive, true, false); - else - { - GetRecordsByType(&oArrayInteractive, true, false); - if (oArrayInteractive.size()) - oArrayInteractive.clear(); - } - if (oArrayInteractive.size() == 2) - oArrayInteractive[1]->m_oHeader.RecInstance = 1; - - for (auto const* interactiveAtom : oArrayInteractive) + for (auto const* interactiveCont : oArrayInteractive) { + auto& interactiveAtom = interactiveCont->interactiveInfoAtom; CInteractiveInfo interactiveInfo; interactiveInfo.m_bPresent = true; - interactiveInfo.m_eActivation = (bool)interactiveAtom->m_oHeader.RecInstance; + interactiveInfo.m_eActivation = interactiveCont->isOver; if (pMapIDs) { - CExFilesInfo* pInfo1 = pMapIDs->LockAudioFromCollection(interactiveAtom->m_nSoundIdRef); + CExFilesInfo* pInfo1 = pMapIDs->LockAudioFromCollection(interactiveAtom.m_nSoundIdRef); if (NULL != pInfo1) { interactiveInfo.m_strAudioFileName = pInfo1->m_strFilePath; interactiveInfo.m_strAudioName = pInfo1->m_name; } - CExFilesInfo* pInfo2 = pMapIDs->LockSlide(interactiveAtom->m_nExHyperlinkIdRef); + CExFilesInfo* pInfo2 = pMapIDs->LockSlide(interactiveAtom.m_nExHyperlinkIdRef); if (NULL != pInfo2) { interactiveInfo.m_strHyperlink = pInfo2->m_strFilePath; } - pInfo2 = pMapIDs->LockHyperlink(interactiveAtom->m_nExHyperlinkIdRef); + pInfo2 = pMapIDs->LockHyperlink(interactiveAtom.m_nExHyperlinkIdRef); if (NULL != pInfo2) { interactiveInfo.m_strHyperlink = pInfo2->m_strFilePath; } } - if (oArrayMacro.size()) - interactiveInfo.m_macro = oArrayMacro[0]->m_strText; + if (interactiveCont->macroNameAtom.is_init()) + interactiveInfo.m_macro = interactiveCont->macroNameAtom->m_strText; - interactiveInfo.m_lType = interactiveAtom->m_nAction; - interactiveInfo.m_lOleVerb = interactiveAtom->m_nOleVerb; - interactiveInfo.m_lJump = interactiveAtom->m_nJump; - interactiveInfo.m_lHyperlinkType = interactiveAtom->m_nHyperlinkType; + interactiveInfo.m_lType = interactiveAtom.m_nAction; + interactiveInfo.m_lOleVerb = interactiveAtom.m_nOleVerb; + interactiveInfo.m_lJump = interactiveAtom.m_nJump; + interactiveInfo.m_lHyperlinkType = interactiveAtom.m_nHyperlinkType; - interactiveInfo.m_bAnimated = interactiveAtom->m_bAnimated; - interactiveInfo.m_bStopSound = interactiveAtom->m_bStopSound; - interactiveInfo.m_bCustomShowReturn = interactiveAtom->m_bCustomShowReturn; - interactiveInfo.m_bVisited = interactiveAtom->m_bVisited; + interactiveInfo.m_bAnimated = interactiveAtom.m_bAnimated; + interactiveInfo.m_bStopSound = interactiveAtom.m_bStopSound; + interactiveInfo.m_bCustomShowReturn = interactiveAtom.m_bCustomShowReturn; + interactiveInfo.m_bVisited = interactiveAtom.m_bVisited; pElement->m_arrActions.push_back(interactiveInfo); } diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/InteractiveInfoAtom.h b/ASCOfficePPTFile/PPTFormatLib/Records/InteractiveInfoAtom.h index 02bdc53276..d0542489ce 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/InteractiveInfoAtom.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/InteractiveInfoAtom.h @@ -32,8 +32,6 @@ #pragma once #include "../Reader/Records.h" -using namespace std; - class CRecordInteractiveInfoAtom : public CUnknownRecord { public: diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/MouseInteractiveInfoContainer.h b/ASCOfficePPTFile/PPTFormatLib/Records/MouseInteractiveInfoContainer.h new file mode 100644 index 0000000000..c20fd2d88b --- /dev/null +++ b/ASCOfficePPTFile/PPTFormatLib/Records/MouseInteractiveInfoContainer.h @@ -0,0 +1,68 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ +#pragma once +#include "InteractiveInfoAtom.h" +#include "CString.h" + +class CRecordMouseInteractiveInfoContainer : public CUnknownRecord +{ +public: + CRecordInteractiveInfoAtom interactiveInfoAtom; + nullable macroNameAtom; + bool isOver; // click = 0, over = 1 + + CRecordMouseInteractiveInfoContainer() : + isOver(false) + { + } + + ~CRecordMouseInteractiveInfoContainer() + { + } + + virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream) + { + m_oHeader = oHeader; + isOver = oHeader.RecInstance; + + SRecordHeader header; + header.ReadFromStream(pStream); + interactiveInfoAtom.ReadFromStream(header, pStream); + + if (m_oHeader.RecLen > 24) + { + header.ReadFromStream(pStream); + macroNameAtom.reset(new CRecordCString); + macroNameAtom->ReadFromStream(header, pStream); + } + } +}; diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/RecordsIncluder.h b/ASCOfficePPTFile/PPTFormatLib/Records/RecordsIncluder.h index 0e72ead75a..9327770388 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/RecordsIncluder.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/RecordsIncluder.h @@ -128,6 +128,7 @@ #include "Animations/_includer.h" #include "InteractiveInfoAtom.h" #include "TextInteractiveInfoAtom.h" +#include "MouseInteractiveInfoContainer.h" //sound #include "ExMIDIAudioContainer.h" diff --git a/ASCOfficePPTXFile/Editor/Drawing/Interactive.h b/ASCOfficePPTXFile/Editor/Drawing/Interactive.h index e0f5cf953c..ecbfb37ccb 100644 --- a/ASCOfficePPTXFile/Editor/Drawing/Interactive.h +++ b/ASCOfficePPTXFile/Editor/Drawing/Interactive.h @@ -36,118 +36,118 @@ namespace PPT_FORMAT { - class CTextRange - { - public: - int m_lStart; - int m_lEnd; - - public: - CTextRange() - { - m_lStart = 0; - m_lEnd = 0; - } - CTextRange& operator=(const CTextRange& oSrc) - { - m_lStart = oSrc.m_lStart; - m_lEnd = oSrc.m_lEnd; +class CTextRange +{ +public: + int m_lStart; + int m_lEnd; - return *this; - } - CTextRange(const CTextRange& oSrc) - { - *this = oSrc; - } - }; - class CInteractiveInfo - { - public: - enum : bool - { - click, - over - }; - CInteractiveInfo() - { - m_bPresent = false; - } +public: + CTextRange() + { + m_lStart = 0; + m_lEnd = 0; + } + CTextRange& operator=(const CTextRange& oSrc) + { + m_lStart = oSrc.m_lStart; + m_lEnd = oSrc.m_lEnd; - CInteractiveInfo& operator=(const CInteractiveInfo& oSrc) - { - m_bPresent = oSrc.m_bPresent; - m_lType = oSrc.m_lType; + return *this; + } + CTextRange(const CTextRange& oSrc) + { + *this = oSrc; + } +}; +class CInteractiveInfo +{ +public: + enum : bool + { + click, + over + }; + CInteractiveInfo() + { + m_bPresent = false; + } - m_lOleVerb = oSrc.m_lOleVerb; - m_lJump = oSrc.m_lJump; - m_lHyperlinkType = oSrc.m_lHyperlinkType; - m_bAnimated = oSrc.m_bAnimated; - m_bStopSound = oSrc.m_bStopSound; - m_bCustomShowReturn = oSrc.m_bCustomShowReturn; - m_bVisited = oSrc.m_bVisited; + CInteractiveInfo& operator=(const CInteractiveInfo& oSrc) + { + m_bPresent = oSrc.m_bPresent; + m_lType = oSrc.m_lType; - m_strAudioFileName = oSrc.m_strAudioFileName; - m_strHyperlink = oSrc.m_strHyperlink; - m_strAudioName = oSrc.m_strAudioName; - m_eActivation = oSrc.m_eActivation; - m_macro = oSrc.m_macro; - return *this; - } - CInteractiveInfo(const CInteractiveInfo& oSrc) - { - *this = oSrc; - } + m_lOleVerb = oSrc.m_lOleVerb; + m_lJump = oSrc.m_lJump; + m_lHyperlinkType = oSrc.m_lHyperlinkType; + m_bAnimated = oSrc.m_bAnimated; + m_bStopSound = oSrc.m_bStopSound; + m_bCustomShowReturn = oSrc.m_bCustomShowReturn; + m_bVisited = oSrc.m_bVisited; - bool m_bPresent; + m_strAudioFileName = oSrc.m_strAudioFileName; + m_strHyperlink = oSrc.m_strHyperlink; + m_strAudioName = oSrc.m_strAudioName; + m_eActivation = oSrc.m_eActivation; + m_macro = oSrc.m_macro; + return *this; + } + CInteractiveInfo(const CInteractiveInfo& oSrc) + { + *this = oSrc; + } - int m_lType; - int m_lOleVerb; - int m_lJump; - int m_lHyperlinkType; - bool m_bAnimated; - bool m_bStopSound; - bool m_bCustomShowReturn; - bool m_bVisited; - bool m_eActivation; // Click or over + bool m_bPresent; - std::wstring m_strAudioFileName; - std::wstring m_strHyperlink; - std::wstring m_strAudioName; - std::wstring m_macro; - }; - class CTextInteractiveInfo - { - private: - long m_lType; - ASC_VARIANT m_varParameter; - - public: - bool m_bPresent; + int m_lType; + int m_lOleVerb; + int m_lJump; + int m_lHyperlinkType; + bool m_bAnimated; + bool m_bStopSound; + bool m_bCustomShowReturn; + bool m_bVisited; + bool m_eActivation; // Click or over - std::vector m_arRanges; + std::wstring m_strAudioFileName; + std::wstring m_strHyperlink; + std::wstring m_strAudioName; + std::wstring m_macro; +}; +class CTextInteractiveInfo +{ +private: + long m_lType; + ASC_VARIANT m_varParameter; - CTextInteractiveInfo() - { - m_bPresent = false; - } - ~CTextInteractiveInfo() - { - } +public: + bool m_bPresent; - CTextInteractiveInfo& operator=(const CTextInteractiveInfo& oSrc) - { - m_lType = oSrc.m_lType; - m_varParameter = oSrc.m_varParameter; + std::vector m_arRanges; - m_bPresent = oSrc.m_bPresent; + CTextInteractiveInfo() + { + m_bPresent = false; + } + ~CTextInteractiveInfo() + { + } - m_arRanges.insert(m_arRanges.end(), oSrc.m_arRanges.begin(), oSrc.m_arRanges.end()); + CTextInteractiveInfo& operator=(const CTextInteractiveInfo& oSrc) + { + m_lType = oSrc.m_lType; + m_varParameter = oSrc.m_varParameter; - return *this; - } - CTextInteractiveInfo(const CTextInteractiveInfo& oSrc) - { - *this = oSrc; - } - }; + m_bPresent = oSrc.m_bPresent; + + m_arRanges.insert(m_arRanges.end(), oSrc.m_arRanges.begin(), oSrc.m_arRanges.end()); + + return *this; + } + CTextInteractiveInfo(const CTextInteractiveInfo& oSrc) + { + *this = oSrc; + } +}; } From 383bae3750854643b2dace96088076485f5fb51f Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Thu, 22 Jul 2021 18:23:20 +0300 Subject: [PATCH 53/84] fix bug #51327 --- .../src/odf/odf_document_impl.cpp | 17 ++-- .../src/odf/style_text_properties.cpp | 10 ++- ASCOfficeOdfFile/src/odf/styles_list.cpp | 87 ++++++++++--------- ASCOfficeOdfFile/src/odf/styles_list.h | 8 +- 4 files changed, 61 insertions(+), 61 deletions(-) diff --git a/ASCOfficeOdfFile/src/odf/odf_document_impl.cpp b/ASCOfficeOdfFile/src/odf/odf_document_impl.cpp index 91ca4d5cea..12245558cc 100644 --- a/ASCOfficeOdfFile/src/odf/odf_document_impl.cpp +++ b/ASCOfficeOdfFile/src/odf/odf_document_impl.cpp @@ -518,26 +518,19 @@ void odf_document::Impl::parse_fonts(office_element *element) std::wstring altName = fontNames.size() >= 2 ? fontNames[1] : L""; const std::wstring charset = fontFace->style_font_charset_.get_value_or(L"") == L"x-symbol" ? L"02" : L"00"; - const std::wstring fontFamily + + std::wstring fontFamily = fontFace->style_font_family_generic_.get_value_or( font_family_generic(font_family_generic::System) ).get_type() == font_family_generic::System ? L"auto" : boost::lexical_cast(*fontFace->style_font_family_generic_); - const std::wstring fontPitch = fontFace->style_font_pitch_ ? boost::lexical_cast(*fontFace->style_font_pitch_) : L""; + + const std::wstring fontPitch = fontFace->style_font_pitch_ ? boost::lexical_cast(*fontFace->style_font_pitch_) : L""; boost::algorithm::trim_if(fontName, boost::algorithm::is_any_of("'")); - + font_instance_ptr fontInstance( new font_instance (styleName, fontName, charset, fontFamily, fontPitch, altName) ); context_->fontContainer().add_font( fontInstance ); - /*if (!context_.fontContainer().font_by_name(fontStyleName)) - { - // два раза не добавляем? - - } - else - { - _CP_LOG << L"[warning] duplicate font name (" << fontName << L")\n"; - }*/ } } while (0); diff --git a/ASCOfficeOdfFile/src/odf/style_text_properties.cpp b/ASCOfficeOdfFile/src/odf/style_text_properties.cpp index 08a8de36ae..4985badc3c 100644 --- a/ASCOfficeOdfFile/src/odf/style_text_properties.cpp +++ b/ASCOfficeOdfFile/src/odf/style_text_properties.cpp @@ -1407,8 +1407,16 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context & if (style_font_name_) { font_instance * font = fonts.font_by_style_name(*style_font_name_); - if (font) + if (font) + { w_ascii = w_hAnsi = font->name(); + + if (font->charset() == L"02") + { + if (w_cs.empty()) w_cs = font->name(); + if (w_eastAsia.empty()) w_eastAsia = font->name(); + } + } } _rPr << L"get_text_list_tab_stop_position() ? labelAlignment->get_text_list_tab_stop_position()->get_value_unit(length::pt) : 0; + double position = labelAlignment->text_list_tab_stop_position_ ? labelAlignment->text_list_tab_stop_position_->get_value_unit(length::pt) : 0; CP_XML_WRITER(strm) { - if (position >0) + if (position > 0 && bTabs) { CP_XML_NODE(L"w:tabs") { @@ -293,8 +293,8 @@ void docx_serialize_label_alignment_props(std::wostream & strm, style_list_level } } } - int w_hanging = (int)( 0.5 - 20.0 * labelAlignment->get_fo_text_indent().get_value_or( length(0, length::pt) ).get_value_unit(length::pt) ); - int w_left = (int)( 0.5 + 20.0 * labelAlignment->get_fo_margin_left().get_value_or( length(0, length::pt) ).get_value_unit(length::pt) ); + int w_hanging = (int)( 0.5 - 20.0 * labelAlignment->fo_text_indent_.get_value_or( length(0, length::pt) ).get_value_unit(length::pt) ); + int w_left = (int)( 0.5 + 20.0 * labelAlignment->fo_margin_left_.get_value_or( length(0, length::pt) ).get_value_unit(length::pt) ); CP_XML_NODE(L"w:ind") { @@ -567,25 +567,31 @@ void text_list_level_style_number::pptx_convert(oox::pptx_conversion_context & C namespace { -wchar_t convert_bullet_char(wchar_t c) +std::wstring convert_bullet_char(std::wstring c) { //return c; - wchar_t res = c; - switch(c) - { - case L'\xE00C': res = L'\xF075';/*L'\xF0A8'*/; break; - case L'\xE00A': res = L'\xF0A7'; break; - case L'\x2611': res = L'\xF0FE'; break; - case L'\x2022': res = L'\x2022'; break; - case L'\x25CF': res = L'\xF0B7'; break; - case L'\x27A2': res = L'\xF0D8'; break; - case L'\x2714': res = L'\xF0FC'; break; - /*case L'\x25A0': res = L'\xF0A7'; break; */ - case L'\x25CB': res = L'\x006F'; break; - case L'\x2794': res = L'\xF0DA'; break; - case L'\x2717': res = L'\xF04F'; break; - case L'\x2013': res = L'\x2013'; break; - default:break; + std::wstring res; + + for(size_t i = 0; i < c.size(); ++i) + { + switch (c[i]) + { + case L'\xE00C': res += L'\xF075';/*L'\xF0A8'*/; break; + case L'\xE00A': res += L'\xF0A7'; break; + case L'\x2611': res += L'\xF0FE'; break; + case L'\x2022': res += L'\x2022'; res += L'\x20'; break; + case L'\x25CF': res += L'\xF0B7'; break; + case L'\x27A2': res += L'\xF0D8'; break; + case L'\x2714': res += L'\xF0FC'; break; + /*case L'\x25A0': res = L'\xF0A7'; break; */ + case L'\x25CB': res += L'\x006F'; break; + case L'\x2794': res += L'\xF0DA'; break; + case L'\x2717': res += L'\xF04F'; break; + case L'\x2013': res += L'\x2013'; break; + default: + res += c[i]; + break; + } } return res; } @@ -610,20 +616,19 @@ void text_list_level_style_bullet::docx_convert(oox::docx_conversion_context & C CP_XML_ATTR(L"w:ilvl",(text_list_level_style_attr_.get_text_level() - 1)); CP_XML_NODE(L"w:numFmt"){CP_XML_ATTR(L"w:val",L"bullet");} - CP_XML_NODE(L"w:suff") - { - if ((labelAlignment) && (labelAlignment->text_label_followed_by_)) + if ((labelAlignment) && (labelAlignment->text_label_followed_by_)) + { + CP_XML_NODE(L"w:suff") { - CP_XML_ATTR(L"w:val",labelAlignment->text_label_followed_by_.get() ); + CP_XML_ATTR(L"w:val", labelAlignment->text_label_followed_by_.get()); } - else - CP_XML_ATTR(L"w:val", L"tab"); } - const wchar_t bullet = text_list_level_style_bullet_attr_.text_bullet_char_.get_value_or(L'\x2022'); + std::wstring bullet = text_list_level_style_bullet_attr_.text_bullet_char_.get_value_or(L"\x2022"); CP_XML_NODE(L"w:lvlText") { - CP_XML_ATTR(L"w:val",convert_bullet_char(bullet)); + std::wstring out = convert_bullet_char(bullet); + CP_XML_ATTR(L"w:val", out); } docx_serialize_level_justification(CP_XML_STREAM(), listLevelProperties); @@ -648,7 +653,7 @@ void text_list_level_style_bullet::docx_convert(oox::docx_conversion_context & C if (labelAlignment) { - docx_serialize_label_alignment_props(CP_XML_STREAM(), labelAlignment); + docx_serialize_label_alignment_props(CP_XML_STREAM(), labelAlignment, false); } else { @@ -708,7 +713,7 @@ void text_list_level_style_bullet::pptx_convert(oox::pptx_conversion_context & C CP_XML_WRITER(strm) { style_text_properties * textProperties = dynamic_cast(style_text_properties_.get()); - wchar_t bullet = text_list_level_style_bullet_attr_.text_bullet_char_.get_value_or(L'\x2022'); + std::wstring bullet = text_list_level_style_bullet_attr_.text_bullet_char_.get_value_or(L"\x2022"); if (textProperties)///эти свойства относятся // к отрисовки значков !!! а не самого текста @@ -723,7 +728,7 @@ void text_list_level_style_bullet::pptx_convert(oox::pptx_conversion_context & C //{ // if (textProperties->content().style_font_charset_.get() == L"x-xsymbol")bullet = bullet + 0xf000; //} - CP_XML_ATTR(L"char",bullet/*convert_bullet_char(bullet)*/); + CP_XML_ATTR(L"char", bullet/*convert_bullet_char(bullet)*/); } } } @@ -747,21 +752,19 @@ void text_list_level_style_image::docx_convert(oox::docx_conversion_context & Co { CP_XML_ATTR(L"w:ilvl",(text_list_level_style_attr_.get_text_level() - 1)); CP_XML_NODE(L"w:numFmt"){CP_XML_ATTR(L"w:val",L"bullet");} - - CP_XML_NODE(L"w:suff") - { - if ((labelAlignment) && (labelAlignment->text_label_followed_by_)) + + if ((labelAlignment) && (labelAlignment->text_label_followed_by_)) + { + CP_XML_NODE(L"w:suff") { CP_XML_ATTR(L"w:val",labelAlignment->text_label_followed_by_.get() ); } - else - CP_XML_ATTR(L"w:val", L"tab"); } - const wchar_t bullet = L'\x2022'; + std::wstring bullet = L"\x2022"; CP_XML_NODE(L"w:lvlText") { - CP_XML_ATTR(L"w:val",convert_bullet_char(bullet)); + CP_XML_ATTR(L"w:val", bullet/*convert_bullet_char(bullet)*/); } docx_serialize_level_justification(CP_XML_STREAM(), listLevelProperties); @@ -786,7 +789,7 @@ void text_list_level_style_image::docx_convert(oox::docx_conversion_context & Co if (labelAlignment) { - docx_serialize_label_alignment_props(CP_XML_STREAM(), labelAlignment); + docx_serialize_label_alignment_props(CP_XML_STREAM(), labelAlignment, false); } else { diff --git a/ASCOfficeOdfFile/src/odf/styles_list.h b/ASCOfficeOdfFile/src/odf/styles_list.h index 428ae4aae9..c0f595a28a 100644 --- a/ASCOfficeOdfFile/src/odf/styles_list.h +++ b/ASCOfficeOdfFile/src/odf/styles_list.h @@ -162,12 +162,8 @@ private: virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name); public: - const _CP_OPT(odf_types::length) & get_fo_text_indent() const { return fo_text_indent_; } - const _CP_OPT(odf_types::length) & get_fo_margin_left() const { return fo_margin_left_; } - const _CP_OPT(odf_types::length) & get_text_list_tab_stop_position() const { return text_list_tab_stop_position_; } + _CP_OPT(std::wstring) text_label_followed_by_; - _CP_OPT(std::wstring) text_label_followed_by_; -private: _CP_OPT(odf_types::length) text_list_tab_stop_position_; _CP_OPT(odf_types::length) fo_text_indent_; _CP_OPT(odf_types::length) fo_margin_left_; @@ -210,7 +206,7 @@ public: private: _CP_OPT(std::wstring) text_style_name_; - _CP_OPT(wchar_t) text_bullet_char_; + _CP_OPT(std::wstring) text_bullet_char_; odf_types::common_num_format_prefix_suffix_attlist common_num_format_prefix_suffix_attlist_; _CP_OPT(odf_types::percent) text_bullet_relative_size_; From 6973cec1a16005819b5791664b265f2d3db121ed Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Thu, 22 Jul 2021 18:37:37 +0300 Subject: [PATCH 54/84] add client text box record for hyperlinks --- .../PPTFormatLib/Linux/PPTFormatLib.pro | 1 + .../PPTFormatLib/Reader/Records.cpp | 2 + .../Records/Drawing/ShapeContainer.cpp | 80 ++++++++++--------- .../Records/Drawing/ShapeContainer.h | 4 +- .../PPTFormatLib/Records/RecordsIncluder.h | 1 + .../Editor/Drawing/Interactive.h | 1 + 6 files changed, 52 insertions(+), 37 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro b/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro index 0cffd9e663..29af477834 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro +++ b/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro @@ -442,6 +442,7 @@ HEADERS += \ ../Records/DocProgTagsContainer.h \ ../Records/MouseInteractiveInfoContainer.h \ ../Records/OfficeArtClientData.h \ + ../Records/OfficeArtClientTextbox.h \ ../Records/PlaceHolderAtom.h \ ../Records/ShapeProgBinaryTagSubContainerOrAtom.h \ ../Records/CFMasks.h \ diff --git a/ASCOfficePPTFile/PPTFormatLib/Reader/Records.cpp b/ASCOfficePPTFile/PPTFormatLib/Reader/Records.cpp index ab8b80f51d..ecada86130 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Reader/Records.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Reader/Records.cpp @@ -613,6 +613,8 @@ IRecord* CreateByType(SRecordHeader oHeader) CREATE_BY_TYPE(RTE_SPLITMENUCOLORS , CRecordSplitMenuColorRecord) CREATE_BY_TYPE(RTE_COLORMRU , CRecordMostRecentlyUserColors) CREATE_BY_TYPE(RTE_CLIENTDATA , CRecordOfficeArtClientData) + CREATE_BY_TYPE(RTE_CLIENTTEXTBOX , CRecordOfficeArtClientTextbox) + CREATE_BY_TYPE(RT_ExternalCdAudio , CRecordExCDAudioContainer) CREATE_BY_TYPE(RT_ExternalWavAudioLink , CRecordWAVAudioLinkContainer) diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp index bef6bf4531..54be446944 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp @@ -40,6 +40,7 @@ #include "../../../../OfficeUtils/src/OfficeUtils.h" #include "../../Enums/_includer.h" +#include "iostream" @@ -1815,42 +1816,8 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, for (auto const* interactiveCont : oArrayInteractive) { - auto& interactiveAtom = interactiveCont->interactiveInfoAtom; CInteractiveInfo interactiveInfo; - interactiveInfo.m_bPresent = true; - interactiveInfo.m_eActivation = interactiveCont->isOver; - - if (pMapIDs) - { - CExFilesInfo* pInfo1 = pMapIDs->LockAudioFromCollection(interactiveAtom.m_nSoundIdRef); - if (NULL != pInfo1) - { - interactiveInfo.m_strAudioFileName = pInfo1->m_strFilePath; - interactiveInfo.m_strAudioName = pInfo1->m_name; - } - CExFilesInfo* pInfo2 = pMapIDs->LockSlide(interactiveAtom.m_nExHyperlinkIdRef); - if (NULL != pInfo2) - { - interactiveInfo.m_strHyperlink = pInfo2->m_strFilePath; - } - pInfo2 = pMapIDs->LockHyperlink(interactiveAtom.m_nExHyperlinkIdRef); - if (NULL != pInfo2) - { - interactiveInfo.m_strHyperlink = pInfo2->m_strFilePath; - } - } - if (interactiveCont->macroNameAtom.is_init()) - interactiveInfo.m_macro = interactiveCont->macroNameAtom->m_strText; - - interactiveInfo.m_lType = interactiveAtom.m_nAction; - interactiveInfo.m_lOleVerb = interactiveAtom.m_nOleVerb; - interactiveInfo.m_lJump = interactiveAtom.m_nJump; - interactiveInfo.m_lHyperlinkType = interactiveAtom.m_nHyperlinkType; - - interactiveInfo.m_bAnimated = interactiveAtom.m_bAnimated; - interactiveInfo.m_bStopSound = interactiveAtom.m_bStopSound; - interactiveInfo.m_bCustomShowReturn = interactiveAtom.m_bCustomShowReturn; - interactiveInfo.m_bVisited = interactiveAtom.m_bVisited; + ConvertInteractiveInfo(interactiveInfo, interactiveCont, pMapIDs); pElement->m_arrActions.push_back(interactiveInfo); } @@ -2559,7 +2526,48 @@ void CRecordShapeContainer::ApplyHyperlink(CShapeElement* pShape, CColor& oColor } } } -} +} + +void CRecordShapeContainer::ConvertInteractiveInfo(CInteractiveInfo &interactiveInfo, const CRecordMouseInteractiveInfoContainer *interactiveCont, CExMedia *pMapIDs) +{ + + auto& interactiveAtom = interactiveCont->interactiveInfoAtom; + interactiveInfo.m_bPresent = true; + interactiveInfo.m_eActivation = interactiveCont->isOver; + + if (pMapIDs) + { + CExFilesInfo* pInfo1 = pMapIDs->LockAudioFromCollection(interactiveAtom.m_nSoundIdRef); + if (NULL != pInfo1) + { + interactiveInfo.m_strAudioFileName = pInfo1->m_strFilePath; + interactiveInfo.m_strAudioName = pInfo1->m_name; + } + CExFilesInfo* pInfo2 = pMapIDs->LockSlide(interactiveAtom.m_nExHyperlinkIdRef); + if (NULL != pInfo2) + { + interactiveInfo.m_strHyperlink = pInfo2->m_strFilePath; + } + pInfo2 = pMapIDs->LockHyperlink(interactiveAtom.m_nExHyperlinkIdRef); + if (NULL != pInfo2) + { + interactiveInfo.m_strHyperlink = pInfo2->m_strFilePath; + } + } + if (interactiveCont->macroNameAtom.is_init()) + interactiveInfo.m_macro = interactiveCont->macroNameAtom->m_strText; + + interactiveInfo.m_lType = interactiveAtom.m_nAction; + interactiveInfo.m_lOleVerb = interactiveAtom.m_nOleVerb; + interactiveInfo.m_lJump = interactiveAtom.m_nJump; + interactiveInfo.m_lHyperlinkType = interactiveAtom.m_nHyperlinkType; + + interactiveInfo.m_bAnimated = interactiveAtom.m_bAnimated; + interactiveInfo.m_bStopSound = interactiveAtom.m_bStopSound; + interactiveInfo.m_bCustomShowReturn = interactiveAtom.m_bCustomShowReturn; + interactiveInfo.m_bVisited = interactiveAtom.m_bVisited; + +} void CRecordGroupShapeContainer::ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream) { diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h index a737f0eaf0..b14b440435 100755 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h @@ -41,7 +41,7 @@ #include "../PlaceHolderAtom.h" #include "../StyleTextPropAtom.h" #include "../OutlineTextRefAtom.h" -#include "../InteractiveInfoAtom.h" +#include "../MouseInteractiveInfoContainer.h" #include "../TextInteractiveInfoAtom.h" #include "../MasterTextPropAtom.h" #include "../HeadersFootersAtom.h" @@ -143,4 +143,6 @@ protected: void ApplyThemeStyle(CElementPtr pElem, CTheme* pTheme, CRecordMasterTextPropAtom* master_levels); void SetUpTextStyle(std::wstring& strText, CTheme* pTheme, CLayout* pLayout, CElementPtr pElem, CSlideInfo* pThemeWrapper, CSlideInfo* pSlideWrapper, CSlide* pSlide, CRecordMasterTextPropAtom* master_levels); void ApplyHyperlink(CShapeElement* pShape, CColor& oColor); + static void ConvertInteractiveInfo(CInteractiveInfo& interactiveInfo, const CRecordMouseInteractiveInfoContainer* interactiveCont, CExMedia* pMapIDs); + }; diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/RecordsIncluder.h b/ASCOfficePPTFile/PPTFormatLib/Records/RecordsIncluder.h index 9327770388..d826857edd 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/RecordsIncluder.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/RecordsIncluder.h @@ -57,6 +57,7 @@ #include "Drawing/DrawingContainer.h" #include "OfficeArtClientData.h" +#include "OfficeArtClientTextbox.h" // others diff --git a/ASCOfficePPTXFile/Editor/Drawing/Interactive.h b/ASCOfficePPTXFile/Editor/Drawing/Interactive.h index ecbfb37ccb..c3d314e6cf 100644 --- a/ASCOfficePPTXFile/Editor/Drawing/Interactive.h +++ b/ASCOfficePPTXFile/Editor/Drawing/Interactive.h @@ -114,6 +114,7 @@ public: std::wstring m_strHyperlink; std::wstring m_strAudioName; std::wstring m_macro; + }; class CTextInteractiveInfo { From a26264775bbf79369015c5e9a1908e12477f1314 Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Fri, 23 Jul 2021 12:24:51 +0300 Subject: [PATCH 55/84] change read/write macro in/to binary --- .../Editor/BinReaderWriterDefines.h | 2 ++ ASCOfficePPTXFile/PPTXFormat/Logic/CxnSp.h | 33 ++++++------------ .../PPTXFormat/Logic/GraphicFrame.cpp | 17 ++++++---- ASCOfficePPTXFile/PPTXFormat/Logic/Pic.cpp | 32 ++++++----------- ASCOfficePPTXFile/PPTXFormat/Logic/Shape.cpp | 34 +++++++++++-------- ASCOfficePPTXFile/PPTXFormat/Logic/Shape.h | 7 ++-- ASCOfficePPTXFile/PPTXFormat/Logic/Sp3d.h | 15 ++++++-- 7 files changed, 69 insertions(+), 71 deletions(-) diff --git a/ASCOfficePPTXFile/Editor/BinReaderWriterDefines.h b/ASCOfficePPTXFile/Editor/BinReaderWriterDefines.h index d48b654733..df4abbdcf7 100644 --- a/ASCOfficePPTXFile/Editor/BinReaderWriterDefines.h +++ b/ASCOfficePPTXFile/Editor/BinReaderWriterDefines.h @@ -194,6 +194,8 @@ namespace NSBinPptxRW #define SPTREE_TYPE_AUDIO 8 #define SPTREE_TYPE_LOCKED_CANVAS 9 +#define SPTREE_TYPE_MACRO 0xA1 + static BYTE SchemeClr_GetBYTECode(const std::wstring& sValue) { if ((L"accent1") == sValue) diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/CxnSp.h b/ASCOfficePPTXFile/PPTXFormat/Logic/CxnSp.h index b372d11c6e..6b0178a2d8 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/CxnSp.h +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/CxnSp.h @@ -76,14 +76,16 @@ namespace PPTX { pWriter->StartRecord(SPTREE_TYPE_CXNSP); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteString2(0, macro); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - pWriter->WriteRecord1(0, nvCxnSpPr); pWriter->WriteRecord1(1, spPr); pWriter->WriteRecord2(2, style); + if (macro.IsInit()) + { + pWriter->StartRecord(SPTREE_TYPE_MACRO); + pWriter->WriteString1(0, *macro); + pWriter->EndRecord(); + } pWriter->EndRecord(); } void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) @@ -126,24 +128,6 @@ namespace PPTX { LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - switch (_at) - { - case 0: - { - macro = pReader->GetString2(); - }break; - default: - break; - } - } while (pReader->GetPos() < _end_rec) { BYTE _at = pReader->GetUChar(); @@ -165,6 +149,11 @@ namespace PPTX style->fromPPTY(pReader); break; } + case SPTREE_TYPE_MACRO: + { + pReader->Skip(1); // type + macro = pReader->GetString2(); + }break; default: { break; diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/GraphicFrame.cpp b/ASCOfficePPTXFile/PPTXFormat/Logic/GraphicFrame.cpp index 92e9817e22..dea47c0e00 100755 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/GraphicFrame.cpp +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/GraphicFrame.cpp @@ -576,7 +576,6 @@ namespace PPTX pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); pWriter->WriteString2(0, vmlSpid); - pWriter->WriteString2(1, macro); pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); pWriter->WriteRecord2(0, nvGraphicFramePr); @@ -613,7 +612,12 @@ namespace PPTX { //???? } - + if (macro.IsInit()) + { + pWriter->StartRecord(SPTREE_TYPE_MACRO); + pWriter->WriteString1(0, *macro); + pWriter->EndRecord(); + } pWriter->EndRecord(); } @@ -634,10 +638,6 @@ namespace PPTX { vmlSpid = pReader->GetString2(); }break; - case 1: - { - macro = pReader->GetString2(); - }break; default: break; } @@ -689,6 +689,11 @@ namespace PPTX chartRec->m_bChartEx = true; chartRec->fromPPTY(pReader); }break; + case SPTREE_TYPE_MACRO: + { + pReader->Skip(1); // type + macro = pReader->GetString2(); + }break; default: pReader->SkipRecord(); break; diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/Pic.cpp b/ASCOfficePPTXFile/PPTXFormat/Logic/Pic.cpp index ce9d44257a..575ea5a9a2 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/Pic.cpp +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/Pic.cpp @@ -727,9 +727,6 @@ namespace PPTX { pWriter->StartRecord(SPTREE_TYPE_PIC); } - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteString2(0, macro); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); if (blipFill.additionalFile.is()) { @@ -756,6 +753,12 @@ namespace PPTX pWriter->WriteRecord1(2, spPr); pWriter->WriteRecord2(3, style); + if (macro.IsInit()) + { + pWriter->StartRecord(SPTREE_TYPE_MACRO); + pWriter->WriteString1(0, *macro); + pWriter->EndRecord(); + } pWriter->EndRecord(); } @@ -850,24 +853,6 @@ namespace PPTX LONG _end_rec = pReader->GetPos() + pReader->GetRecordSize() + 4; nvPicPr.cNvPr.id = -1; - pReader->Skip(1); // start attributes - - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - - switch (_at) - { - case 0: - { - macro = pReader->GetString2(); - }break; - default: - break; - } - } while (pReader->GetPos() < _end_rec) { @@ -954,6 +939,11 @@ namespace PPTX } pReader->Seek(_end_rec1); } + case SPTREE_TYPE_MACRO: + { + pReader->Skip(1); // type + macro = pReader->GetString2(); + }break; default: { break; diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/Shape.cpp b/ASCOfficePPTXFile/PPTXFormat/Logic/Shape.cpp index f4b3a0b24c..321269a276 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/Shape.cpp +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/Shape.cpp @@ -149,8 +149,8 @@ namespace PPTX { m_name = node.GetName(); - XmlMacroReadAttributeBase(node,L"useBgFill", attrUseBgFill); - XmlMacroReadAttributeBase(node, L"macro", attrMacro); + XmlMacroReadAttributeBase(node,L"useBgFill", useBgFill); + XmlMacroReadAttributeBase(node, L"macro", macro); XmlUtils::CXmlNodes oNodes; if (node.GetNodes(L"*", oNodes)) @@ -191,8 +191,8 @@ namespace PPTX std::wstring Shape::toXML() const { XmlUtils::CAttribute oAttr; - oAttr.Write(L"useBgFill", attrUseBgFill); - oAttr.Write(L"macro", attrMacro); + oAttr.Write(L"useBgFill", useBgFill); + oAttr.Write(L"macro", macro); XmlUtils::CNodeValue oValue; oValue.Write(nvSpPr); @@ -216,8 +216,8 @@ namespace PPTX pWriter->StartNode(name_); pWriter->StartAttributes(); - pWriter->WriteAttribute(L"macro", attrMacro); - pWriter->WriteAttribute(L"useBgFill", attrUseBgFill); + pWriter->WriteAttribute(L"macro", macro); + pWriter->WriteAttribute(L"useBgFill", useBgFill); pWriter->EndAttributes(); if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || @@ -322,11 +322,7 @@ namespace PPTX { case 0: { - attrUseBgFill = pReader->GetBool(); - }break; - case 1: - { - attrMacro = pReader->GetString2(); + useBgFill = pReader->GetBool(); }break; default: break; @@ -405,6 +401,11 @@ namespace PPTX signatureLine->fromPPTY(pReader); break; } + case SPTREE_TYPE_MACRO: + { + pReader->Skip(1); // type + macro = pReader->GetString2(); + }break; default: { pReader->SkipRecord(); @@ -416,8 +417,6 @@ namespace PPTX pReader->Seek(_end_rec); } - - void Shape::FillParentPointersForChilds() { nvSpPr.SetParentPointer(this); @@ -434,8 +433,7 @@ namespace PPTX pWriter->StartRecord(SPTREE_TYPE_SHAPE); pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteBool2(0, attrUseBgFill); - pWriter->WriteString2(1, attrMacro); + pWriter->WriteBool2(0, useBgFill); pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); pWriter->WriteRecord1(0, nvSpPr); @@ -502,6 +500,12 @@ namespace PPTX pWriter->WriteRecord2(6, txXfrm); pWriter->WriteRecord2(7, signatureLine); + if (macro.IsInit()) + { + pWriter->StartRecord(SPTREE_TYPE_MACRO); + pWriter->WriteString1(0, *macro); + pWriter->EndRecord(); + } pWriter->EndRecord(); } diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/Shape.h b/ASCOfficePPTXFile/PPTXFormat/Logic/Shape.h index f20e8b1718..e69a5e08e4 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/Shape.h +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/Shape.h @@ -296,8 +296,7 @@ namespace PPTX void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) { WritingElement_ReadAttributes_Start( oReader ) - WritingElement_ReadAttributes_Read_if( oReader, _T("useBgFill"), attrUseBgFill) - WritingElement_ReadAttributes_Read_else_if(oReader, _T("macro"), attrMacro) + WritingElement_ReadAttributes_Read_if( oReader, _T("useBgFill"), useBgFill) WritingElement_ReadAttributes_End( oReader ) } std::wstring GetText()const{if(txBody.IsInit()) return txBody->GetText(); return _T(""); }; @@ -331,8 +330,8 @@ namespace PPTX nullable oTextBoxShape; nullable oTextBoxBodyPr; - nullable_bool attrUseBgFill; - nullable_string attrMacro; + nullable_bool useBgFill; + nullable_string macro; //------------------------------------------------------------------------------------------------- nullable signatureLine; std::wstring m_sClientDataXml; diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/Sp3d.h b/ASCOfficePPTXFile/PPTXFormat/Logic/Sp3d.h index 9afa01e511..4f3fd9e1db 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/Sp3d.h +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/Sp3d.h @@ -183,13 +183,19 @@ namespace PPTX pWriter->WriteInt2(1, extrusionH); pWriter->WriteLimit2(2, prstMaterial); pWriter->WriteInt2(3, z); - pWriter->WriteString2(4, macro); pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); pWriter->WriteRecord2(0, bevelT); pWriter->WriteRecord2(1, bevelB); pWriter->WriteRecord1(2, extrusionClr); pWriter->WriteRecord1(3, contourClr); + + if (macro.IsInit()) + { + pWriter->StartRecord(SPTREE_TYPE_MACRO); + pWriter->WriteString1(0, *macro); + pWriter->EndRecord(); + } } virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) { @@ -207,7 +213,6 @@ namespace PPTX else if (1 == _at) extrusionH = pReader->GetLong(); else if (2 == _at) prstMaterial = pReader->GetUChar(); else if (3 == _at) z = pReader->GetLong(); - else if (4 == _at) macro = pReader->GetString2(); else break; } @@ -239,11 +244,15 @@ namespace PPTX contourClr.fromPPTY(pReader); break; } + case SPTREE_TYPE_MACRO: + { + pReader->Skip(1); // type + macro = pReader->GetString2(); + }break; default: break; } } - pReader->Seek(_end_rec); } From 9df5a2616c738cd3fd0130f10a2cbd2deb33598a Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Fri, 23 Jul 2021 13:19:02 +0300 Subject: [PATCH 56/84] . --- ASCOfficePPTXFile/PPTXFormat/Logic/CxnSp.h | 2 +- ASCOfficePPTXFile/PPTXFormat/Logic/GraphicFrame.cpp | 2 +- ASCOfficePPTXFile/PPTXFormat/Logic/Pic.cpp | 2 +- ASCOfficePPTXFile/PPTXFormat/Logic/Shape.cpp | 2 +- ASCOfficePPTXFile/PPTXFormat/Logic/Sp3d.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/CxnSp.h b/ASCOfficePPTXFile/PPTXFormat/Logic/CxnSp.h index 6b0178a2d8..1c72b3ee72 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/CxnSp.h +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/CxnSp.h @@ -151,7 +151,7 @@ namespace PPTX } case SPTREE_TYPE_MACRO: { - pReader->Skip(1); // type + pReader->Skip(5); // type + size macro = pReader->GetString2(); }break; default: diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/GraphicFrame.cpp b/ASCOfficePPTXFile/PPTXFormat/Logic/GraphicFrame.cpp index dea47c0e00..6e81b6d41d 100755 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/GraphicFrame.cpp +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/GraphicFrame.cpp @@ -691,7 +691,7 @@ namespace PPTX }break; case SPTREE_TYPE_MACRO: { - pReader->Skip(1); // type + pReader->Skip(5); // type + size macro = pReader->GetString2(); }break; default: diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/Pic.cpp b/ASCOfficePPTXFile/PPTXFormat/Logic/Pic.cpp index 575ea5a9a2..5ff3d413d8 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/Pic.cpp +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/Pic.cpp @@ -941,7 +941,7 @@ namespace PPTX } case SPTREE_TYPE_MACRO: { - pReader->Skip(1); // type + pReader->Skip(5); // type + size macro = pReader->GetString2(); }break; default: diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/Shape.cpp b/ASCOfficePPTXFile/PPTXFormat/Logic/Shape.cpp index 321269a276..5ca5e08f70 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/Shape.cpp +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/Shape.cpp @@ -403,7 +403,7 @@ namespace PPTX } case SPTREE_TYPE_MACRO: { - pReader->Skip(1); // type + pReader->Skip(5); // type + size macro = pReader->GetString2(); }break; default: diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/Sp3d.h b/ASCOfficePPTXFile/PPTXFormat/Logic/Sp3d.h index 4f3fd9e1db..c02828a464 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/Sp3d.h +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/Sp3d.h @@ -246,7 +246,7 @@ namespace PPTX } case SPTREE_TYPE_MACRO: { - pReader->Skip(1); // type + pReader->Skip(5); // type + size macro = pReader->GetString2(); }break; default: From 06c8c0e0755eae8476b80383566f31ca8213b4b8 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Fri, 23 Jul 2021 15:58:01 +0300 Subject: [PATCH 57/84] add text hyperlinks. But it has bugs --- .../PPTFormatLib/PPTXWriter/ShapeWriter.cpp | 2 +- .../Records/Drawing/ShapeContainer.cpp | 21 ++++++++++++++++++- ASCOfficePPTXFile/Editor/Drawing/Element.h | 1 + .../Editor/Drawing/TextStructures.h | 6 +++--- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp index b228283d8d..f3b564883d 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp @@ -1482,7 +1482,6 @@ void PPT_FORMAT::CShapeWriter::WriteTextInfo() else { m_oWriter.WriteString(std::wstring(L"oArrayInteractive); } } @@ -1524,6 +1523,7 @@ void PPT_FORMAT::CShapeWriter::WriteTextInfo() m_oWriter.WriteString(std::wstring(L" lang=\"") + str_lang + _T("\"")); } m_oWriter.WriteString(std::wstring(L">")); + WriteHyperlink(pCF->arrInteractive); if (m_bWordArt) {//порядок важен - линия, заливка, тень !!! diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp index 54be446944..0b4e8a86d1 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp @@ -1913,8 +1913,24 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, } + std::vector oArrayTextBox; + std::vector oArrayInteractiveCont; std::vector oArrayTextInteractive; - this->GetRecordsByType(&oArrayTextInteractive, true); + this->GetRecordsByType(&oArrayTextBox, false); + + if (oArrayTextBox.size()) + { + oArrayTextBox[0]->GetRecordsByType(&oArrayTextInteractive, false); + + oArrayTextBox[0]->GetRecordsByType(&oArrayInteractiveCont, false); + } + + for (const auto* pInerAtom : oArrayInteractiveCont) + { + CInteractiveInfo interactive; + ConvertInteractiveInfo(interactive, pInerAtom, pMapIDs); + pShapeElem->m_textHyperlinks.push_back(interactive); + } if (!oArrayTextInteractive.empty()) { @@ -2471,6 +2487,7 @@ void CRecordShapeContainer::ApplyHyperlink(CShapeElement* pShape, CColor& oColor { std::vector* pRanges = &pShape->m_oTextActions.m_arRanges; CTextAttributesEx* pTextAttributes = &pShape->m_pShape->m_oText; + auto& arrInteractive = pShape->m_textHyperlinks; int lCountHyper = pRanges->size(); @@ -2516,6 +2533,8 @@ void CRecordShapeContainer::ApplyHyperlink(CShapeElement* pShape, CColor& oColor pParagraph->m_arSpans[nIndexSpan].m_strText = strText.substr(lStart_ - lCurrentStart, lEnd_ - lStart_ + 1); if (lEnd_ < lCurrentEnd) { + pParagraph->m_arSpans[nIndexSpan].m_oRun.arrInteractive.push_back(arrInteractive.front()); + arrInteractive.erase(arrInteractive.begin()); pParagraph->m_arSpans.insert(pParagraph->m_arSpans.begin() + nIndexSpan + 1, oRunProp); ++nIndexSpan; diff --git a/ASCOfficePPTXFile/Editor/Drawing/Element.h b/ASCOfficePPTXFile/Editor/Drawing/Element.h index 4d2b62a02c..93aa721f6a 100644 --- a/ASCOfficePPTXFile/Editor/Drawing/Element.h +++ b/ASCOfficePPTXFile/Editor/Drawing/Element.h @@ -73,6 +73,7 @@ namespace PPT_FORMAT CTextInteractiveInfo m_oTextActions; std::vector m_arrActions; + std::vector m_textHyperlinks; CAnimationInfo m_oAnimations; CEffects m_oEffects; diff --git a/ASCOfficePPTXFile/Editor/Drawing/TextStructures.h b/ASCOfficePPTXFile/Editor/Drawing/TextStructures.h index c30bfc8251..f07b713283 100644 --- a/ASCOfficePPTXFile/Editor/Drawing/TextStructures.h +++ b/ASCOfficePPTXFile/Editor/Drawing/TextStructures.h @@ -164,8 +164,8 @@ namespace PPT_FORMAT NSCommon::nullable_base Cap; // 0 - none, 1 - TEXT, 2 - text NSCommon::nullable_base Language; - CFontProperties font; - std::vector oArrayInteractive; + CFontProperties font; + std::vector arrInteractive; CTextCFRun() { @@ -200,7 +200,7 @@ namespace PPT_FORMAT Cap = oSrc.Cap; Language = oSrc.Language; - + arrInteractive = oSrc.arrInteractive; return *this; } ~CTextCFRun() From ee19ab476f8713ca2c79d85e0e237ed2403d36f3 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Fri, 23 Jul 2021 18:31:23 +0300 Subject: [PATCH 58/84] trying to correct hyperlinks --- .../PPTFormatLib/Reader/ReadStructures.cpp | 2 +- .../PPTFormatLib/Reader/ReadStructures.h | 4 ++-- .../Records/Drawing/ShapeContainer.cpp | 16 ++++++++++++++-- .../Records/Drawing/ShapeContainer.h | 2 ++ 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.cpp b/ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.cpp index 04894510a2..eceda1a52d 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.cpp @@ -517,7 +517,7 @@ void CTextCFRunRecord::LoadFromStream(POLE::Stream* pStream, bool bIsIndentation namespace PPT_FORMAT { void ConvertPPTTextToEditorStructure(std::vector& oArrayPF, std::vector& oArrayCF, - std::wstring& strText, PPT_FORMAT::CTextAttributesEx& oAttributes) + std::wstring& strText, PPT_FORMAT::CTextAttributesEx& oAttributes, std::vector arrRange) { int nCountPFs = (int)oArrayPF.size(); int nCountCFs = (int)oArrayCF.size(); diff --git a/ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.h b/ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.h index 358418307b..c34478cf9c 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.h +++ b/ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.h @@ -342,6 +342,6 @@ public: namespace PPT_FORMAT { - void ConvertPPTTextToEditorStructure(std::vector& oArrayPF, std::vector& oArrayCF, - std::wstring& strText, PPT_FORMAT::CTextAttributesEx& oAttributes); + void ConvertPPTTextToEditorStructure(std::vector& oArrayPF, std::vector& oArrayCF, + std::wstring& strText, PPT_FORMAT::CTextAttributesEx& oAttributes, std::vector arrRange); } diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp index 0b4e8a86d1..52f55602b4 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp @@ -2381,7 +2381,7 @@ void CRecordShapeContainer::SetUpTextStyle(std::wstring& strText, CTheme* pTheme oArrayCF.push_back(elm1); - PPT_FORMAT::ConvertPPTTextToEditorStructure(oArrayPF, oArrayCF, strText, *pTextSettings); + PPT_FORMAT::ConvertPPTTextToEditorStructure(oArrayPF, oArrayCF, strText, *pTextSettings, pShape->m_oTextActions.m_arRanges); } if (NULL != oElemInfo.m_pStream && -1 != oElemInfo.m_lOffsetTextProp) @@ -2530,7 +2530,7 @@ void CRecordShapeContainer::ApplyHyperlink(CShapeElement* pShape, CColor& oColor } pParagraph->m_arSpans[nIndexSpan].m_oRun.Color = oColor; pParagraph->m_arSpans[nIndexSpan].m_oRun.FontUnderline = (bool)true; - pParagraph->m_arSpans[nIndexSpan].m_strText = strText.substr(lStart_ - lCurrentStart, lEnd_ - lStart_ + 1); + pParagraph->m_arSpans[nIndexSpan].m_strText = strText.substr(lStart_ - lCurrentStart, lEnd_ - lStart_); if (lEnd_ < lCurrentEnd) { pParagraph->m_arSpans[nIndexSpan].m_oRun.arrInteractive.push_back(arrInteractive.front()); @@ -2547,6 +2547,18 @@ void CRecordShapeContainer::ApplyHyperlink(CShapeElement* pShape, CColor& oColor } } +void CRecordShapeContainer::addHyperlinkToSpan(CSpan &oSpan, CInteractiveInfo &oInteractive, CColor &oColor) +{ + oSpan.m_oRun.Color = oColor; + oSpan.m_oRun.FontUnderline = (bool)true; + oSpan.m_oRun.arrInteractive.push_back(oInteractive); +} + +void CRecordShapeContainer::splitSpans(std::vector &oParagraps, std::vector &oRanges) +{ + +} + void CRecordShapeContainer::ConvertInteractiveInfo(CInteractiveInfo &interactiveInfo, const CRecordMouseInteractiveInfoContainer *interactiveCont, CExMedia *pMapIDs) { diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h index b14b440435..117dc8e231 100755 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h @@ -143,6 +143,8 @@ protected: void ApplyThemeStyle(CElementPtr pElem, CTheme* pTheme, CRecordMasterTextPropAtom* master_levels); void SetUpTextStyle(std::wstring& strText, CTheme* pTheme, CLayout* pLayout, CElementPtr pElem, CSlideInfo* pThemeWrapper, CSlideInfo* pSlideWrapper, CSlide* pSlide, CRecordMasterTextPropAtom* master_levels); void ApplyHyperlink(CShapeElement* pShape, CColor& oColor); + static void addHyperlinkToSpan(CSpan& oSpan, CInteractiveInfo &oInteractive, CColor& oColor); + static void splitSpans(std::vector& oParagraps, std::vector &oRanges); static void ConvertInteractiveInfo(CInteractiveInfo& interactiveInfo, const CRecordMouseInteractiveInfoContainer* interactiveCont, CExMedia* pMapIDs); }; From ef277b465626dd8b3dd6b308fbd37912f4947246 Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Sat, 24 Jul 2021 13:20:27 +0300 Subject: [PATCH 59/84] fix bug #51489 --- .../src/docx/xlsx_conditionalFormatting.cpp | 21 ++++++++++++++++--- .../source/OdfFormat/ods_table_state.cpp | 10 +++++++-- .../source/OdfFormat/ods_table_state.h | 2 +- .../source/Oox2OdfConverter/XlsxConverter.cpp | 7 +++++-- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/ASCOfficeOdfFile/src/docx/xlsx_conditionalFormatting.cpp b/ASCOfficeOdfFile/src/docx/xlsx_conditionalFormatting.cpp index 74e4b46930..d0fa542d42 100644 --- a/ASCOfficeOdfFile/src/docx/xlsx_conditionalFormatting.cpp +++ b/ASCOfficeOdfFile/src/docx/xlsx_conditionalFormatting.cpp @@ -89,6 +89,7 @@ namespace oox { _CP_OPT(std::wstring) text; _CP_OPT(std::wstring) formula2; _CP_OPT(int) rank; + _CP_OPT(bool) bottom; //color scale icon set data_bar std::vector<_cfvo> cfvo; //color scale data_bar(1 element) @@ -144,9 +145,8 @@ public: if (c.rules[j].stopIfTrue) CP_XML_ATTR(L"stopIfTrue", *c.rules[j].stopIfTrue); if (c.rules[j].text) CP_XML_ATTR(L"text", *c.rules[j].text); if (c.rules[j].rank) CP_XML_ATTR(L"rank", *c.rules[j].rank); - - //CP_XML_ATTR(L"bottom" , 0); - //CP_XML_ATTR(L"equalAverage" , 0); + if (c.rules[j].bottom) CP_XML_ATTR(L"bottom", *c.rules[j].bottom); + //CP_XML_ATTR(L"equalAverage" , 0); //CP_XML_ATTR(L"aboveAverage" , 0); if (c.rules[j].type == 1) { @@ -362,6 +362,21 @@ void xlsx_conditionalFormatting_context::set_formula(std::wstring f) impl_->conditionalFormattings_.back().rules.back().rank = boost::lexical_cast(val); } } + else if (0 <= (pos = f.find(L"bottom"))) + { + impl_->conditionalFormattings_.back().rules.back().formula_type = L"top10"; + impl_->conditionalFormattings_.back().rules.back().bottom = true; + if (0 < (pos = f.find(L"percent"))) + { + impl_->conditionalFormattings_.back().rules.back().percent = true; + } + if (0 <= (pos = f.find(L"("))) + { + val = f.substr(pos + 1, f.length() - pos - 2); + if (!val.empty()) + impl_->conditionalFormattings_.back().rules.back().rank = boost::lexical_cast(val); + } + } else { impl_->conditionalFormattings_.back().rules.back().formula_type = L"cellIs"; diff --git a/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.cpp b/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.cpp index 883df8640d..69eb722565 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.cpp @@ -1630,7 +1630,7 @@ void ods_table_state::end_conditional_format() { current_level_.pop_back(); } -void ods_table_state::start_conditional_rule(int rule_type, _CP_OPT(unsigned int) rank) +void ods_table_state::start_conditional_rule(int rule_type, _CP_OPT(unsigned int) rank, _CP_OPT(bool) bottom) { office_element_ptr elm; @@ -1680,7 +1680,13 @@ void ods_table_state::start_conditional_rule(int rule_type, _CP_OPT(unsigned int case 11: condition->attr_.calcext_value_ = L"not-contains-text()"; break; case 12: condition->attr_.calcext_value_ = L"is-no-error"; break; case 13: condition->attr_.calcext_value_ = L"not-contains-text()"; break; - case 15: condition->attr_.calcext_value_ = L"top-elements(" + std::to_wstring(rank.get_value_or(10)) + L")"; break;//bottom-elements ??? + case 15: + { + if ((bottom) && (*bottom)) + condition->attr_.calcext_value_ = L"bottom-elements(" + std::to_wstring(rank.get_value_or(10)) + L")"; + else + condition->attr_.calcext_value_ = L"top-elements(" + std::to_wstring(rank.get_value_or(10)) + L")"; + }break; case 16: condition->attr_.calcext_value_ = L"unique"; break; case 2: /*cellIs*/ default: break; diff --git a/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.h b/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.h index 1290edaeb1..697ae696b1 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.h +++ b/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.h @@ -375,7 +375,7 @@ public: void start_conditional_formats(); void start_conditional_format(std::wstring ref); - void start_conditional_rule(int rule_type, _CP_OPT(unsigned int) rank); + void start_conditional_rule(int rule_type, _CP_OPT(unsigned int) rank, _CP_OPT(bool) bottom); void set_conditional_formula(std::wstring formula); void set_conditional_value(int type, std::wstring value ); void set_conditional_iconset(int type_iconset); diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp index 7f2258454b..9463ceac16 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp @@ -3231,9 +3231,12 @@ void XlsxConverter::convert(OOX::Spreadsheet::CConditionalFormattingRule *oox_co if (false == oox_cond_rule->m_oType.IsInit()) return; _CP_OPT(unsigned int) rank; - if (oox_cond_rule->m_oRank.IsInit()) rank = oox_cond_rule->m_oRank->GetValue(); + _CP_OPT(bool) bottom; - ods_context->current_table()->start_conditional_rule(oox_cond_rule->m_oType->GetValue(), rank); + if (oox_cond_rule->m_oRank.IsInit()) rank = oox_cond_rule->m_oRank->GetValue(); + if (oox_cond_rule->m_oBottom.IsInit()) bottom = oox_cond_rule->m_oBottom->ToBool(); + + ods_context->current_table()->start_conditional_rule(oox_cond_rule->m_oType->GetValue(), rank, bottom); { if (oox_cond_rule->m_oDxfId.IsInit()) { From f591bcbd45c7e413cdf76235a8e150ce509be600 Mon Sep 17 00:00:00 2001 From: Ivan Date: Sun, 25 Jul 2021 18:03:53 +0300 Subject: [PATCH 60/84] trying to correct text hyperlinks for hard cases. Problems with text after hyperlink --- .../PPTFormatLib/PPTXWriter/ShapeWriter.cpp | 2 +- .../PPTFormatLib/Reader/ReadStructures.cpp | 2 +- .../PPTFormatLib/Reader/ReadStructures.h | 2 +- .../Records/Drawing/ShapeContainer.cpp | 138 +++++++++++------- .../Records/Drawing/ShapeContainer.h | 3 +- .../Editor/Drawing/TextAttributesEx.h | 1 + .../Editor/Drawing/TextStructures.h | 7 +- 7 files changed, 96 insertions(+), 59 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp index f3b564883d..bab1932e6a 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp @@ -1523,7 +1523,7 @@ void PPT_FORMAT::CShapeWriter::WriteTextInfo() m_oWriter.WriteString(std::wstring(L" lang=\"") + str_lang + _T("\"")); } m_oWriter.WriteString(std::wstring(L">")); - WriteHyperlink(pCF->arrInteractive); + WriteHyperlink(pParagraph->m_arSpans[nSpan].m_arrInteractive); if (m_bWordArt) {//порядок важен - линия, заливка, тень !!! diff --git a/ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.cpp b/ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.cpp index eceda1a52d..75cd2e568b 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.cpp @@ -517,7 +517,7 @@ void CTextCFRunRecord::LoadFromStream(POLE::Stream* pStream, bool bIsIndentation namespace PPT_FORMAT { void ConvertPPTTextToEditorStructure(std::vector& oArrayPF, std::vector& oArrayCF, - std::wstring& strText, PPT_FORMAT::CTextAttributesEx& oAttributes, std::vector arrRange) + std::wstring& strText, PPT_FORMAT::CTextAttributesEx& oAttributes) { int nCountPFs = (int)oArrayPF.size(); int nCountCFs = (int)oArrayCF.size(); diff --git a/ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.h b/ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.h index c34478cf9c..5b61b55547 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.h +++ b/ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.h @@ -343,5 +343,5 @@ public: namespace PPT_FORMAT { void ConvertPPTTextToEditorStructure(std::vector& oArrayPF, std::vector& oArrayCF, - std::wstring& strText, PPT_FORMAT::CTextAttributesEx& oAttributes, std::vector arrRange); + std::wstring& strText, PPT_FORMAT::CTextAttributesEx& oAttributes); } diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp index 52f55602b4..14b87b0905 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp @@ -40,8 +40,6 @@ #include "../../../../OfficeUtils/src/OfficeUtils.h" #include "../../Enums/_includer.h" -#include "iostream" - #define FIXED_POINT_unsigned(val) (double)((WORD)(val >> 16) + ((WORD)(val) / 65536.0)) @@ -1866,6 +1864,7 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, if (0 < oArrayTextBytes.size() && strShapeText.empty()) { strShapeText = oArrayTextBytes[0]->m_strText; + pShapeElem->m_pShape->m_oText.m_originalText = strShapeText; } std::vector oArrayTextChars; @@ -2381,7 +2380,7 @@ void CRecordShapeContainer::SetUpTextStyle(std::wstring& strText, CTheme* pTheme oArrayCF.push_back(elm1); - PPT_FORMAT::ConvertPPTTextToEditorStructure(oArrayPF, oArrayCF, strText, *pTextSettings, pShape->m_oTextActions.m_arRanges); + PPT_FORMAT::ConvertPPTTextToEditorStructure(oArrayPF, oArrayCF, strText, *pTextSettings); } if (NULL != oElemInfo.m_pStream && -1 != oElemInfo.m_lOffsetTextProp) @@ -2485,78 +2484,113 @@ void CRecordShapeContainer::SetUpTextStyle(std::wstring& strText, CTheme* pTheme void CRecordShapeContainer::ApplyHyperlink(CShapeElement* pShape, CColor& oColor) { - std::vector* pRanges = &pShape->m_oTextActions.m_arRanges; - CTextAttributesEx* pTextAttributes = &pShape->m_pShape->m_oText; - auto& arrInteractive = pShape->m_textHyperlinks; + auto& oTextAttributes = pShape->m_pShape->m_oText; + const auto& originalText = oTextAttributes.m_originalText; - int lCountHyper = pRanges->size(); + // lenght these ones shoud be equal + const auto& arrRanges = pShape->m_oTextActions.m_arRanges; + const auto arrSplitedInteractive = splitInteractive(pShape->m_textHyperlinks); + const auto lCountHyper = arrRanges.size(); if (0 == lCountHyper) return; - size_t nCountPars = pTextAttributes->m_arParagraphs.size(); - for (int nIndexRange = 0; nIndexRange < lCountHyper; ++nIndexRange) + // Ranges + // Paragraphs + //Spans + + const auto nCountPars = oTextAttributes.m_arParagraphs.size(); + size_t iterRange = 0; + int iterTextPos = 0; + for (size_t iterPar = 0; iterPar < nCountPars; ++iterPar) { - int lStart = (*pRanges)[nIndexRange].m_lStart; - int lEnd = (*pRanges)[nIndexRange].m_lEnd; + auto& oParagraph = oTextAttributes.m_arParagraphs[iterPar]; - int lCurrentStart = 0; - for (size_t nIndexPar = 0; nIndexPar < nCountPars; ++nIndexPar) + for (size_t iterSpan = 0; iterSpan < oParagraph.m_arSpans.size(); ++iterSpan) { - CParagraph* pParagraph = &pTextAttributes->m_arParagraphs[nIndexPar]; + const auto rangeStart = arrRanges[iterRange].m_lStart; + const auto rangeEnd = arrRanges[iterRange].m_lEnd; - for (size_t nIndexSpan = 0; nIndexSpan < pParagraph->m_arSpans.size(); ++nIndexSpan) + const int currentSpanEndPos = iterTextPos + oParagraph.m_arSpans[iterSpan].m_strText.length(); + + // If hyperlink is outside current span + if (iterTextPos > rangeEnd || currentSpanEndPos < rangeStart) { - int lCurrentEnd = lCurrentStart + pParagraph->m_arSpans[nIndexSpan].m_strText.length() - 1; - - if (lCurrentStart > lEnd || lCurrentEnd < lStart) - { - lCurrentStart = lCurrentEnd + 1; - continue; - } - - int lStart_ = (std::max)(lStart, lCurrentStart); - int lEnd_ = (std::min)(lEnd, lCurrentEnd); - - CSpan oRunProp = pParagraph->m_arSpans[nIndexSpan]; - - std::wstring strText = pParagraph->m_arSpans[nIndexSpan].m_strText; - if (lStart_ > lCurrentStart) - { - pParagraph->m_arSpans.insert(pParagraph->m_arSpans.begin() + nIndexSpan, oRunProp); - pParagraph->m_arSpans[nIndexSpan].m_strText = strText.substr(0, lStart_ - lCurrentStart); - - ++nIndexSpan; - } - pParagraph->m_arSpans[nIndexSpan].m_oRun.Color = oColor; - pParagraph->m_arSpans[nIndexSpan].m_oRun.FontUnderline = (bool)true; - pParagraph->m_arSpans[nIndexSpan].m_strText = strText.substr(lStart_ - lCurrentStart, lEnd_ - lStart_); - if (lEnd_ < lCurrentEnd) - { - pParagraph->m_arSpans[nIndexSpan].m_oRun.arrInteractive.push_back(arrInteractive.front()); - arrInteractive.erase(arrInteractive.begin()); - pParagraph->m_arSpans.insert(pParagraph->m_arSpans.begin() + nIndexSpan + 1, oRunProp); - ++nIndexSpan; - - pParagraph->m_arSpans[nIndexSpan].m_strText = strText.substr(lEnd_ - lCurrentStart + 1, lCurrentEnd - lEnd_); - } - - lCurrentStart = lCurrentEnd + 1; + // go to next span. +1 - skipping '\r' + iterTextPos = originalText[currentSpanEndPos] == '\r' ? + currentSpanEndPos + 1 : currentSpanEndPos; + continue; } +// if (oParagraph.m_arSpans[iterSpan].m_oRun.arrInteractive.size()) +// continue; + + // find possitions for hyperlink inside current span + const int hyperStart = (std::max)(rangeStart, iterTextPos); + const int hyperEnd = (std::min)(rangeEnd, currentSpanEndPos); + + // property for copy to new span + CSpan& oRunProp = oParagraph.m_arSpans[iterSpan]; + + // text HYPERLINK + if (hyperStart > iterTextPos) + { + // text without hyperlink + // push current front new span with prop and sub string + oParagraph.m_arSpans.insert(oParagraph.m_arSpans.begin() + iterSpan, oRunProp); + oParagraph.m_arSpans[iterSpan].m_strText = originalText.substr(iterTextPos, hyperStart - iterTextPos); + + ++iterSpan; + } + + // HYPERLINK + oParagraph.m_arSpans[iterSpan].m_oRun.Color = oColor; + oParagraph.m_arSpans[iterSpan].m_oRun.FontUnderline = (bool)true; + oParagraph.m_arSpans[iterSpan].m_strText = originalText.substr(hyperStart, hyperEnd - hyperStart); + oParagraph.m_arSpans[iterSpan].m_arrInteractive = arrSplitedInteractive[iterRange]; + if (hyperEnd == currentSpanEndPos) + iterRange++; + + // HYPERLINK text + // In case: "HYPERLINK1 HYPERLINK2" it'll be temporarily written such as simple text + // and will be rewritted to the next iteration of span or paragraph + if (hyperEnd < currentSpanEndPos) + { + // text without hyperlink + // push current back new span with prop and sub string + ++iterSpan; + oParagraph.m_arSpans.insert(oParagraph.m_arSpans.begin() + iterSpan, oRunProp); + oParagraph.m_arSpans[iterSpan].m_strText = originalText.substr(hyperEnd, currentSpanEndPos - hyperEnd); + } + + // go to next span. +1 - skipping '\r' + iterTextPos = originalText[currentSpanEndPos] == '\r' ? + currentSpanEndPos + 1 : currentSpanEndPos; } } + } void CRecordShapeContainer::addHyperlinkToSpan(CSpan &oSpan, CInteractiveInfo &oInteractive, CColor &oColor) { oSpan.m_oRun.Color = oColor; oSpan.m_oRun.FontUnderline = (bool)true; - oSpan.m_oRun.arrInteractive.push_back(oInteractive); + oSpan.m_arrInteractive.push_back(oInteractive); } -void CRecordShapeContainer::splitSpans(std::vector &oParagraps, std::vector &oRanges) +std::vector > CRecordShapeContainer::splitInteractive(const std::vector &arrInteractive) { + std::vector > splited; + std::vector inserting; + for (const auto& interactive : arrInteractive) + { + if (interactive.m_eActivation == interactive.click && !inserting.empty()) + splited.push_back(std::move(inserting)); + inserting.push_back(interactive); + } + if (!inserting.empty()) + splited.push_back(std::move(inserting)); + return splited; } void CRecordShapeContainer::ConvertInteractiveInfo(CInteractiveInfo &interactiveInfo, const CRecordMouseInteractiveInfoContainer *interactiveCont, CExMedia *pMapIDs) diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h index 117dc8e231..7d5497b03d 100755 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h @@ -55,6 +55,7 @@ #include "../../../../DesktopEditor/raster/BgraFrame.h" #include "../../../../Common/DocxFormat/Source/Base/Types_32.h" + #define FIXED_POINT_unsigned(val) (double)((WORD)(val >> 16) + ((WORD)(val) / 65536.0)) using namespace ODRAW; @@ -144,7 +145,7 @@ protected: void SetUpTextStyle(std::wstring& strText, CTheme* pTheme, CLayout* pLayout, CElementPtr pElem, CSlideInfo* pThemeWrapper, CSlideInfo* pSlideWrapper, CSlide* pSlide, CRecordMasterTextPropAtom* master_levels); void ApplyHyperlink(CShapeElement* pShape, CColor& oColor); static void addHyperlinkToSpan(CSpan& oSpan, CInteractiveInfo &oInteractive, CColor& oColor); - static void splitSpans(std::vector& oParagraps, std::vector &oRanges); + static std::vector > splitInteractive(const std::vector& arrInteractive); static void ConvertInteractiveInfo(CInteractiveInfo& interactiveInfo, const CRecordMouseInteractiveInfoContainer* interactiveCont, CExMedia* pMapIDs); }; diff --git a/ASCOfficePPTXFile/Editor/Drawing/TextAttributesEx.h b/ASCOfficePPTXFile/Editor/Drawing/TextAttributesEx.h index 8c5da3724a..9892db3e6b 100644 --- a/ASCOfficePPTXFile/Editor/Drawing/TextAttributesEx.h +++ b/ASCOfficePPTXFile/Editor/Drawing/TextAttributesEx.h @@ -63,6 +63,7 @@ namespace PPT_FORMAT // настройки по-умолчанию CTextAttributes m_oAttributes; std::vector m_arParagraphs; + std::wstring m_originalText; bool m_bVertical; bool m_bAutoFit; diff --git a/ASCOfficePPTXFile/Editor/Drawing/TextStructures.h b/ASCOfficePPTXFile/Editor/Drawing/TextStructures.h index f07b713283..8d7f0f96d5 100644 --- a/ASCOfficePPTXFile/Editor/Drawing/TextStructures.h +++ b/ASCOfficePPTXFile/Editor/Drawing/TextStructures.h @@ -165,7 +165,6 @@ namespace PPT_FORMAT NSCommon::nullable_base Language; CFontProperties font; - std::vector arrInteractive; CTextCFRun() { @@ -199,8 +198,7 @@ namespace PPT_FORMAT Cap = oSrc.Cap; - Language = oSrc.Language; - arrInteractive = oSrc.arrInteractive; + Language = oSrc.Language; return *this; } ~CTextCFRun() @@ -639,6 +637,8 @@ namespace PPT_FORMAT bool m_bField; bool m_bBreak; + std::vector m_arrInteractive; + CSpan() : m_bField(false), m_bBreak(false) { } @@ -652,6 +652,7 @@ namespace PPT_FORMAT m_strText = oSrc.m_strText; m_bField = oSrc.m_bField; m_bBreak = oSrc.m_bBreak; + m_arrInteractive = oSrc.m_arrInteractive; return *this; } From bf0b1e8d97e84f6816f43b8249869c0bc49429c1 Mon Sep 17 00:00:00 2001 From: Ivan Date: Sun, 25 Jul 2021 22:49:10 +0300 Subject: [PATCH 61/84] trying to correct text hyperlinks --- .../Records/Drawing/ShapeContainer.cpp | 68 +++++++++---------- .../Editor/Drawing/Interactive.h | 4 ++ 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp index 14b87b0905..1bae1eef12 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp @@ -2508,64 +2508,60 @@ void CRecordShapeContainer::ApplyHyperlink(CShapeElement* pShape, CColor& oColor for (size_t iterSpan = 0; iterSpan < oParagraph.m_arSpans.size(); ++iterSpan) { - const auto rangeStart = arrRanges[iterRange].m_lStart; - const auto rangeEnd = arrRanges[iterRange].m_lEnd; + const auto& hyperRange = arrRanges[iterRange]; + const auto hyperStart = std::max(hyperRange.m_lStart, iterTextPos); + const auto hyperEnd = hyperRange.m_lEnd; + auto nextHyperStart = -1; + if (arrRanges.size() > iterRange + 1) + nextHyperStart = arrRanges[iterRange + 1].m_lStart; const int currentSpanEndPos = iterTextPos + oParagraph.m_arSpans[iterSpan].m_strText.length(); // If hyperlink is outside current span - if (iterTextPos > rangeEnd || currentSpanEndPos < rangeStart) + if (iterTextPos > hyperEnd || currentSpanEndPos < hyperStart) { - // go to next span. +1 - skipping '\r' - iterTextPos = originalText[currentSpanEndPos] == '\r' ? - currentSpanEndPos + 1 : currentSpanEndPos; + // go to next span. + iterTextPos = currentSpanEndPos; continue; } -// if (oParagraph.m_arSpans[iterSpan].m_oRun.arrInteractive.size()) -// continue; // find possitions for hyperlink inside current span - const int hyperStart = (std::max)(rangeStart, iterTextPos); - const int hyperEnd = (std::min)(rangeEnd, currentSpanEndPos); + int blockEnd = (std::min)(hyperEnd, currentSpanEndPos); + if (nextHyperStart != -1) + blockEnd = std::min(blockEnd, nextHyperStart); // property for copy to new span CSpan& oRunProp = oParagraph.m_arSpans[iterSpan]; - // text HYPERLINK - if (hyperStart > iterTextPos) + + // text + if (iterTextPos < hyperStart || iterTextPos >= hyperEnd) { // text without hyperlink - // push current front new span with prop and sub string - oParagraph.m_arSpans.insert(oParagraph.m_arSpans.begin() + iterSpan, oRunProp); - oParagraph.m_arSpans[iterSpan].m_strText = originalText.substr(iterTextPos, hyperStart - iterTextPos); + // push current new span with prop and sub string + const bool afterHyperlink = hyperStart < iterTextPos; + oParagraph.m_arSpans.insert(oParagraph.m_arSpans.begin() + iterSpan + afterHyperlink, oRunProp); + const auto textLen = (afterHyperlink ? blockEnd : hyperStart) - iterTextPos; + oParagraph.m_arSpans[iterSpan].m_strText = originalText.substr(iterTextPos, textLen); - ++iterSpan; + iterTextPos += textLen; } // HYPERLINK - oParagraph.m_arSpans[iterSpan].m_oRun.Color = oColor; - oParagraph.m_arSpans[iterSpan].m_oRun.FontUnderline = (bool)true; - oParagraph.m_arSpans[iterSpan].m_strText = originalText.substr(hyperStart, hyperEnd - hyperStart); - oParagraph.m_arSpans[iterSpan].m_arrInteractive = arrSplitedInteractive[iterRange]; - if (hyperEnd == currentSpanEndPos) - iterRange++; - - // HYPERLINK text - // In case: "HYPERLINK1 HYPERLINK2" it'll be temporarily written such as simple text - // and will be rewritted to the next iteration of span or paragraph - if (hyperEnd < currentSpanEndPos) + else if (hyperStart == iterTextPos && iterTextPos < currentSpanEndPos) { - // text without hyperlink - // push current back new span with prop and sub string - ++iterSpan; - oParagraph.m_arSpans.insert(oParagraph.m_arSpans.begin() + iterSpan, oRunProp); - oParagraph.m_arSpans[iterSpan].m_strText = originalText.substr(hyperEnd, currentSpanEndPos - hyperEnd); + oParagraph.m_arSpans[iterSpan].m_oRun.Color = oColor; + oParagraph.m_arSpans[iterSpan].m_oRun.FontUnderline = (bool)true; + const auto hyperLen = blockEnd - hyperStart; + oParagraph.m_arSpans[iterSpan].m_strText = originalText.substr(iterTextPos, hyperLen); + oParagraph.m_arSpans[iterSpan].m_arrInteractive = arrSplitedInteractive[iterRange]; + iterTextPos += hyperLen; + if (hyperEnd == iterTextPos) + iterRange++; } - - // go to next span. +1 - skipping '\r' - iterTextPos = originalText[currentSpanEndPos] == '\r' ? - currentSpanEndPos + 1 : currentSpanEndPos; } + // skipping '\r' + iterTextPos++; } } diff --git a/ASCOfficePPTXFile/Editor/Drawing/Interactive.h b/ASCOfficePPTXFile/Editor/Drawing/Interactive.h index c3d314e6cf..324687c568 100644 --- a/ASCOfficePPTXFile/Editor/Drawing/Interactive.h +++ b/ASCOfficePPTXFile/Editor/Drawing/Interactive.h @@ -59,6 +59,10 @@ public: { *this = oSrc; } + bool inRange(const int pos)const + { + return (pos >= m_lStart && pos < m_lEnd); + } }; class CInteractiveInfo { From ac865d292f314c2af4c7bac83b01749433c57bfe Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Mon, 26 Jul 2021 14:59:42 +0300 Subject: [PATCH 62/84] text hyperlinks were corrected! Now it has problem with some visible hyperlink, but it goesn't work --- .../Records/Drawing/ShapeContainer.cpp | 130 ++++++++++-------- .../Records/Drawing/ShapeContainer.h | 2 +- 2 files changed, 71 insertions(+), 61 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp index 1bae1eef12..1613c63b40 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp @@ -2490,87 +2490,97 @@ void CRecordShapeContainer::ApplyHyperlink(CShapeElement* pShape, CColor& oColor // lenght these ones shoud be equal const auto& arrRanges = pShape->m_oTextActions.m_arRanges; const auto arrSplitedInteractive = splitInteractive(pShape->m_textHyperlinks); - const auto lCountHyper = arrRanges.size(); - if (0 == lCountHyper) + // It cannot be changed + if (arrRanges.empty() || arrSplitedInteractive.empty()) return; - // Ranges - // Paragraphs - //Spans - - const auto nCountPars = oTextAttributes.m_arParagraphs.size(); - size_t iterRange = 0; - int iterTextPos = 0; - for (size_t iterPar = 0; iterPar < nCountPars; ++iterPar) + size_t posOrigText(0); + auto iterRange = arrRanges.begin(); + auto iterInteractive = arrSplitedInteractive.begin(); + for (auto& paragraph : oTextAttributes.m_arParagraphs) { - auto& oParagraph = oTextAttributes.m_arParagraphs[iterPar]; - - for (size_t iterSpan = 0; iterSpan < oParagraph.m_arSpans.size(); ++iterSpan) + auto& arrSpans = paragraph.m_arSpans; + for (auto iterSpan = arrSpans.begin(); iterSpan != arrSpans.end(); iterSpan++) { - const auto& hyperRange = arrRanges[iterRange]; - const auto hyperStart = std::max(hyperRange.m_lStart, iterTextPos); - const auto hyperEnd = hyperRange.m_lEnd; - auto nextHyperStart = -1; - if (arrRanges.size() > iterRange + 1) - nextHyperStart = arrRanges[iterRange + 1].m_lStart; - - const int currentSpanEndPos = iterTextPos + oParagraph.m_arSpans[iterSpan].m_strText.length(); - - // If hyperlink is outside current span - if (iterTextPos > hyperEnd || currentSpanEndPos < hyperStart) + // if there isn't needed changes in next spans & paragraps + if (iterRange == arrRanges.end()) + { + return; + } + + const bool isHyperlink = iterRange->inRange(posOrigText); + + const int posBlockStart = posOrigText; + const int posOrigSpanEnd = posBlockStart + iterSpan->m_strText.length(); + const int posBlockEnd = isHyperlink ? + std::min(posOrigSpanEnd, iterRange->m_lEnd) : + std::min(posOrigSpanEnd, iterRange->m_lStart); + const size_t blockLen = posBlockEnd - posBlockStart; + + const bool isNeedToSplit = posBlockEnd < posOrigSpanEnd && isHyperlink; + + posOrigText += blockLen; + // Skipping span + if (iterRange->m_lStart > posBlockEnd) { - // go to next span. - iterTextPos = currentSpanEndPos; continue; } - // find possitions for hyperlink inside current span - int blockEnd = (std::min)(hyperEnd, currentSpanEndPos); - if (nextHyperStart != -1) - blockEnd = std::min(blockEnd, nextHyperStart); - - // property for copy to new span - CSpan& oRunProp = oParagraph.m_arSpans[iterSpan]; - - - // text - if (iterTextPos < hyperStart || iterTextPos >= hyperEnd) - { - // text without hyperlink - // push current new span with prop and sub string - const bool afterHyperlink = hyperStart < iterTextPos; - oParagraph.m_arSpans.insert(oParagraph.m_arSpans.begin() + iterSpan + afterHyperlink, oRunProp); - const auto textLen = (afterHyperlink ? blockEnd : hyperStart) - iterTextPos; - oParagraph.m_arSpans[iterSpan].m_strText = originalText.substr(iterTextPos, textLen); - - iterTextPos += textLen; - } - // HYPERLINK - else if (hyperStart == iterTextPos && iterTextPos < currentSpanEndPos) + if (isHyperlink) { - oParagraph.m_arSpans[iterSpan].m_oRun.Color = oColor; - oParagraph.m_arSpans[iterSpan].m_oRun.FontUnderline = (bool)true; - const auto hyperLen = blockEnd - hyperStart; - oParagraph.m_arSpans[iterSpan].m_strText = originalText.substr(iterTextPos, hyperLen); - oParagraph.m_arSpans[iterSpan].m_arrInteractive = arrSplitedInteractive[iterRange]; - iterTextPos += hyperLen; - if (hyperEnd == iterTextPos) + // case: HYPERLINK & text(or next HYPERLINK inside original span) + if (isNeedToSplit) + { + // HYPERLINK + iterSpan->m_strText = originalText.substr(posBlockStart, blockLen); + + const size_t nextBlockLen = posOrigSpanEnd - posBlockEnd; + iterSpan = arrSpans.insert(iterSpan, *iterSpan); + // Go to next new span and correct text + iterSpan++; + iterSpan->m_strText = originalText.substr(posBlockEnd, nextBlockLen); + iterSpan->m_arrInteractive.clear(); + // Return to current span + iterSpan--; + } + + addHyperlinkToSpan(*iterSpan, *iterInteractive, oColor); + + if (posBlockEnd == iterRange->m_lEnd) + { iterRange++; + iterInteractive++; + } + } + // Hyperlink will be written in the next iteration + // case: text & HYPERLINK + else + { + iterSpan = arrSpans.insert(iterSpan, *iterSpan); + iterSpan->m_strText = originalText.substr(posBlockStart, blockLen); + iterSpan->m_arrInteractive.clear(); + + // Go to next new span and correct text + iterSpan++; + const size_t nextBlockLen = posOrigSpanEnd - posBlockEnd; + iterSpan->m_strText = originalText.substr(posBlockEnd, nextBlockLen); + iterSpan->m_arrInteractive.clear(); + // Return to current span + iterSpan--; } } // skipping '\r' - iterTextPos++; + posOrigText++; } - } -void CRecordShapeContainer::addHyperlinkToSpan(CSpan &oSpan, CInteractiveInfo &oInteractive, CColor &oColor) +void CRecordShapeContainer::addHyperlinkToSpan(CSpan &oSpan, const std::vector &arrInteractive, const CColor &oColor) { oSpan.m_oRun.Color = oColor; oSpan.m_oRun.FontUnderline = (bool)true; - oSpan.m_arrInteractive.push_back(oInteractive); + oSpan.m_arrInteractive = arrInteractive; } std::vector > CRecordShapeContainer::splitInteractive(const std::vector &arrInteractive) diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h index 7d5497b03d..a8b9abb407 100755 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h @@ -144,7 +144,7 @@ protected: void ApplyThemeStyle(CElementPtr pElem, CTheme* pTheme, CRecordMasterTextPropAtom* master_levels); void SetUpTextStyle(std::wstring& strText, CTheme* pTheme, CLayout* pLayout, CElementPtr pElem, CSlideInfo* pThemeWrapper, CSlideInfo* pSlideWrapper, CSlide* pSlide, CRecordMasterTextPropAtom* master_levels); void ApplyHyperlink(CShapeElement* pShape, CColor& oColor); - static void addHyperlinkToSpan(CSpan& oSpan, CInteractiveInfo &oInteractive, CColor& oColor); + static void addHyperlinkToSpan(CSpan& oSpan, const std::vector &arrInteractive, const CColor& oColor); static std::vector > splitInteractive(const std::vector& arrInteractive); static void ConvertInteractiveInfo(CInteractiveInfo& interactiveInfo, const CRecordMouseInteractiveInfoContainer* interactiveCont, CExMedia* pMapIDs); From fb9d4d0460f0217270199f599878b37708c8999c Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Mon, 26 Jul 2021 17:48:03 +0300 Subject: [PATCH 63/84] add Other Presentation hyperlinks --- .../PPTFormatLib/PPTXWriter/ImageManager.h | 46 ++++++++++++++----- .../PPTFormatLib/PPTXWriter/ShapeWriter.cpp | 42 +++++++++++++---- .../Reader/PPTDocumentInfoOneUser.cpp | 8 +++- ASCOfficePPTXFile/Editor/Drawing/Attributes.h | 11 ++++- 4 files changed, 85 insertions(+), 22 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ImageManager.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ImageManager.h index a39b4256a7..47bc349efa 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ImageManager.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ImageManager.h @@ -281,30 +281,54 @@ namespace PPT_FORMAT std::wstring strMem = m_oWriter.GetData(); oFile.WriteStringUTF8(strMem); oFile.CloseFile(); - } + } inline std::wstring WriteHyperlink(const std::wstring& strHyperlink) - { - std::map::iterator pPair = m_mapHyperlinks.find(strHyperlink); + { + std::map::iterator pPair = m_mapHyperlinks.find(strHyperlink); - if (m_mapHyperlinks.end() != pPair) - { + if (m_mapHyperlinks.end() != pPair) + { std::wstring strRid = L"rId" + pPair->second; - return strRid; - } - m_mapHyperlinks[strHyperlink] = m_lNextRelsID; + return strRid; + } + m_mapHyperlinks[strHyperlink] = m_lNextRelsID; std::wstring strRid = L"rId" + std::to_wstring( m_lNextRelsID++); - std::wstring strRels = L""; - m_oWriter.WriteString(strRels); - + m_oWriter.WriteString(strRels); + return strRid; } + inline std::wstring WriteFile(const std::wstring& strPath) + { + std::map::iterator pPair = m_mapHyperlinks.find(strPath); + + if (m_mapHyperlinks.end() != pPair) + { + std::wstring strRid = L"rId" + pPair->second; + return strRid; + } + m_mapHyperlinks[strPath] = m_lNextRelsID; + + std::wstring strRid = L"rId" + std::to_wstring( m_lNextRelsID++); + + std::wstring strRels = L""; + + m_oWriter.WriteString(strRels); + + return strRid; + } + + inline std::wstring WriteHyperlinkMedia(const std::wstring& strMedia, bool bExternal = true, bool newRIdAlways = false, std::wstring strRelsType = L"http://schemas.microsoft.com/office/2007/relationships/media") { if (!newRIdAlways) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp index bab1932e6a..9b7aa9ab18 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp @@ -1697,8 +1697,16 @@ void PPT_FORMAT::CShapeWriter::WriteHyperlink(const std::vectorWriteSlideRef(actions[i].m_strHyperlink); - hlink.id = id; + std::wstring id; + switch (actions[i].m_lHyperlinkType) + { + case LT_SlideNumber: id = m_pRels->WriteSlideRef(actions[i].m_strHyperlink); break; + case LT_Url: id = m_pRels->WriteHyperlink(actions[i].m_strHyperlink); break; + case LT_OtherPresentation: id = m_pRels->WriteFile(actions[i].m_strHyperlink); break; + case LT_OtherFile: id = m_pRels->WriteFile(actions[i].m_strHyperlink); break; + } + if (!id.empty()) + hlink.id = id; } if (actions[i].m_strAudioFileName.size() && m_pRels) @@ -1712,7 +1720,8 @@ void PPT_FORMAT::CShapeWriter::WriteHyperlink(const std::vectorempty()) -// hlink.action = L"ppaction://noaction"; + if (!hlink.action.is_init() || hlink.action->empty()) + hlink.action = L"ppaction://noaction"; break; } case II_MediaAction: diff --git a/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp b/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp index 6b6ca23a97..3ca74e722e 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp @@ -2393,8 +2393,12 @@ void CPPTUserInfo::LoadExternal(CRecordExObjListContainer* pExObjects) if (recInst == 1) { oInfo.m_strFilePath = recStr; - oInfo.m_type = oInfo.isHTTPLink(recStr) ? CExFilesInfo::ExFilesType::eftHyperlink : - CExFilesInfo::ExFilesType::eftAudio; + if (oInfo.isAudioLink(recStr)) + oInfo.m_type = CExFilesInfo::ExFilesType::eftAudio; + else if (oInfo.isHTTPLink(recStr)) + oInfo.m_type = CExFilesInfo::ExFilesType::eftHyperlink; + else + oInfo.m_type = CExFilesInfo::ExFilesType::eftHyperlink; } // Location atom. It's for slides or other local pp objects. else if (recInst == 3 && oInfo.GetSlideNumber(recStr) != -1) diff --git a/ASCOfficePPTXFile/Editor/Drawing/Attributes.h b/ASCOfficePPTXFile/Editor/Drawing/Attributes.h index 47f80b4369..e1462c2e06 100644 --- a/ASCOfficePPTXFile/Editor/Drawing/Attributes.h +++ b/ASCOfficePPTXFile/Editor/Drawing/Attributes.h @@ -81,7 +81,8 @@ public: eftAudio = 2, eftHyperlink = 3, eftObject = 4, - eftSlide + eftSlide = 5/*, + eftFile = 6*/ }; ExFilesType m_type; @@ -137,6 +138,13 @@ public: int iter2 = str.find(L"https://"); return iter1 != -1 || iter2 != -1; } + static bool isAudioLink(const std::wstring &str) + { + int iter1 = str.find(L".mp3"); + int iter2 = str.find(L".wav"); + int iter3 = str.find(L".waw"); + return iter1 != -1 || iter2 != -1 || iter3 != -1; + } }; class CExMedia @@ -149,6 +157,7 @@ public: std::vector m_arAudios; std::vector m_arHyperlinks; std::vector m_arSlides; + std::vector m_arFiles; std::vector m_arAudioCollection; From f8f307aa2943392ac1cb06fd0f89d54e3776355a Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Mon, 26 Jul 2021 18:06:40 +0300 Subject: [PATCH 64/84] add Other Files and http(s) hyperlinks --- .../PPTFormatLib/PPTXWriter/ImageManager.h | 5 +++-- .../PPTFormatLib/PPTXWriter/ShapeWriter.cpp | 10 ++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ImageManager.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ImageManager.h index 47bc349efa..516a227965 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ImageManager.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ImageManager.h @@ -282,7 +282,7 @@ namespace PPT_FORMAT oFile.WriteStringUTF8(strMem); oFile.CloseFile(); } - inline std::wstring WriteHyperlink(const std::wstring& strHyperlink) + inline std::wstring WriteHyperlink(const std::wstring& strHyperlink, bool isExternal = false) { std::map::iterator pPair = m_mapHyperlinks.find(strHyperlink); @@ -298,7 +298,8 @@ namespace PPT_FORMAT std::wstring strRels = L""; + strRels += strHyperlink; + strRels += (isExternal ? L"\" TargetMode=\"External\" />" : L"\"/>"); m_oWriter.WriteString(strRels); diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp index 9b7aa9ab18..db83b6a71d 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp @@ -1700,10 +1700,10 @@ void PPT_FORMAT::CShapeWriter::WriteHyperlink(const std::vectorWriteSlideRef(actions[i].m_strHyperlink); break; - case LT_Url: id = m_pRels->WriteHyperlink(actions[i].m_strHyperlink); break; - case LT_OtherPresentation: id = m_pRels->WriteFile(actions[i].m_strHyperlink); break; - case LT_OtherFile: id = m_pRels->WriteFile(actions[i].m_strHyperlink); break; + case LT_SlideNumber: id = m_pRels->WriteSlideRef(actions[i].m_strHyperlink); break; + case LT_Url: id = m_pRels->WriteHyperlink(actions[i].m_strHyperlink, true); break; + case LT_OtherPresentation: id = m_pRels->WriteFile(actions[i].m_strHyperlink); break; + case LT_OtherFile: id = m_pRels->WriteFile(actions[i].m_strHyperlink); break; } if (!id.empty()) hlink.id = id; @@ -1807,8 +1807,6 @@ void PPT_FORMAT::CShapeWriter::WriteHyperlink(const std::vectorempty()) - hlink.action = L"ppaction://noaction"; break; } case II_MediaAction: From 82105951789a56c85afdaa920ea0db2116c71ebc Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Mon, 26 Jul 2021 21:58:41 +0300 Subject: [PATCH 65/84] fix bug #51522 --- ASCOfficeDocxFile2/DocWrapper/DocxSerializer.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ASCOfficeDocxFile2/DocWrapper/DocxSerializer.cpp b/ASCOfficeDocxFile2/DocWrapper/DocxSerializer.cpp index 2205635cd6..68b99446af 100644 --- a/ASCOfficeDocxFile2/DocWrapper/DocxSerializer.cpp +++ b/ASCOfficeDocxFile2/DocWrapper/DocxSerializer.cpp @@ -122,6 +122,9 @@ namespace BinDocxRW if (L"pkg:xmlData" == sName) { std::wstring data = oReader.GetInnerXml(); + XmlUtils::replace_all(data, L" ", L""); + XmlUtils::replace_all(data, L" ", L""); + //todooo убрать "красивую" разметку xml WriteXmlFile(*name, data); } if (L"pkg:binaryData" == sName) @@ -142,6 +145,7 @@ namespace BinDocxRW NSFile::CFileBinary file; if (file.CreateFileW(path.GetPath())) { + file.WriteStringUTF8(L"\r\n"); file.WriteStringUTF8(data); file.CloseFile(); } From 476ebe6e95af1edcf277446da257ddc844467f4c Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Tue, 27 Jul 2021 15:58:58 +0300 Subject: [PATCH 66/84] fix bug #51541 --- ASCOfficeOdfFile/src/docx/xlsxconversioncontext.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ASCOfficeOdfFile/src/docx/xlsxconversioncontext.cpp b/ASCOfficeOdfFile/src/docx/xlsxconversioncontext.cpp index 828ab0180e..7b9e45eeaf 100644 --- a/ASCOfficeOdfFile/src/docx/xlsxconversioncontext.cpp +++ b/ASCOfficeOdfFile/src/docx/xlsxconversioncontext.cpp @@ -139,6 +139,13 @@ void xlsx_conversion_context::end_document() { std::wstringstream workbook_content; + if (sheets_.empty()) + { // owncloud new document ... oO + start_table(L"Sheet1", L""); + current_sheet().cols() << L""; + end_table(); + } + for (size_t i = 0; i < sheets_.size(); i++) { xlsx_xml_worksheet_ptr& sheet = sheets_[i]; From 4ff7be8245ad2075be09c6bfb58c68c5527683f2 Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Tue, 27 Jul 2021 16:51:19 +0300 Subject: [PATCH 67/84] fix bug #51543 --- Common/OfficeFileFormatChecker2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/OfficeFileFormatChecker2.cpp b/Common/OfficeFileFormatChecker2.cpp index fd01191fc1..38bfae484c 100644 --- a/Common/OfficeFileFormatChecker2.cpp +++ b/Common/OfficeFileFormatChecker2.cpp @@ -483,7 +483,7 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring & _fileName) if (0 == sExt.compare(L".mht")) nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_MHT; - else if (0 == sExt.compare(L".csv")) + else if (0 == sExt.compare(L".csv") || 0 == sExt.compare(L".xlsx") || 0 == sExt.compare(L".xls")) nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV; else if (0 == sExt.compare(L".html") || 0 == sExt.compare(L".htm")) nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML; From b0363dad58a2625194b70439a99259e11455c763 Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Tue, 27 Jul 2021 17:08:01 +0300 Subject: [PATCH 68/84] for bug #51543 --- X2tConverter/src/ASCConverters.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/X2tConverter/src/ASCConverters.cpp b/X2tConverter/src/ASCConverters.cpp index f323a8a056..000b9a7ba4 100644 --- a/X2tConverter/src/ASCConverters.cpp +++ b/X2tConverter/src/ASCConverters.cpp @@ -1229,7 +1229,11 @@ namespace NExtractTools m_oCXlsxSerializer.setIsNoBase64(params.getIsNoBase64()); m_oCXlsxSerializer.setFontDir(params.getFontPath()); - _UINT32 nRes = m_oCXlsxSerializer.saveToFile (sResultXlstFileEditor, sCSV, params.getXmlOptions()); + if (!params.m_nFormatFrom) params.m_nFormatFrom = new int(AVS_OFFICESTUDIO_FILE_UNKNOWN); + if (AVS_OFFICESTUDIO_FILE_UNKNOWN == *params.m_nFormatFrom) + *params.m_nFormatFrom = AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV; + + _UINT32 nRes = m_oCXlsxSerializer.saveToFile (sResultXlstFileEditor, sCSV, params.getXmlOptions()); if (SUCCEEDED_X2T(nRes)) { From 558cfb80484b11511445234040f4e7a3a7c731dd Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Tue, 27 Jul 2021 17:21:25 +0300 Subject: [PATCH 69/84] refactoring ExHyperlinkContainer --- .../PPTFormatLib/PPTXWriter/ShapeWriter.cpp | 4 +- .../Reader/PPTDocumentInfoOneUser.cpp | 117 +++++++++--------- .../PPTFormatLib/Records/ExHyperlinkAtom.h | 92 +++++++++----- 3 files changed, 126 insertions(+), 87 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp index db83b6a71d..b5e791349f 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp @@ -1721,8 +1721,8 @@ void PPT_FORMAT::CShapeWriter::WriteHyperlink(const std::vectorm_oHeadersFootersAtom) { m_bHasDate = oArrayHeadersFootersInfo[0]->m_oHeadersFootersAtom->m_bHasDate/* || - oArrayHeadersFootersInfo[0]->m_oHeadersFootersAtom->m_bHasTodayDate || - oArrayHeadersFootersInfo[0]->m_oHeadersFootersAtom->m_bHasUserDate*/; + oArrayHeadersFootersInfo[0]->m_oHeadersFootersAtom->m_bHasTodayDate || + oArrayHeadersFootersInfo[0]->m_oHeadersFootersAtom->m_bHasUserDate*/; m_bHasFooter = oArrayHeadersFootersInfo[0]->m_oHeadersFootersAtom->m_bHasFooter; m_bHasSlideNumber = oArrayHeadersFootersInfo[0]->m_oHeadersFootersAtom->m_bHasSlideNumber; @@ -731,8 +731,8 @@ void CPPTUserInfo::LoadNotes(_UINT32 dwNoteID, CSlide* pNotes) if (oArrayHeadersFootersInfo[0]->m_oHeadersFootersAtom) { bHasDate = oArrayHeadersFootersInfo[0]->m_oHeadersFootersAtom->m_bHasDate/* || - oArrayHeadersFootersInfo[0]->m_oHeadersFootersAtom->m_bHasTodayDate || - oArrayHeadersFootersInfo[0]->m_oHeadersFootersAtom->m_bHasUserDate*/; + oArrayHeadersFootersInfo[0]->m_oHeadersFootersAtom->m_bHasTodayDate || + oArrayHeadersFootersInfo[0]->m_oHeadersFootersAtom->m_bHasUserDate*/; bHasFooter = oArrayHeadersFootersInfo[0]->m_oHeadersFootersAtom->m_bHasFooter; bHasSlideNumber = oArrayHeadersFootersInfo[0]->m_oHeadersFootersAtom->m_bHasSlideNumber; @@ -963,8 +963,8 @@ void CPPTUserInfo::LoadSlide(_UINT32 dwSlideID, CSlide* pSlide) if (oArrayHeadersFootersInfo[0]->m_oHeadersFootersAtom) { bHasDate = oArrayHeadersFootersInfo[0]->m_oHeadersFootersAtom->m_bHasDate/* || - oArrayHeadersFootersInfo[0]->m_oHeadersFootersAtom->m_bHasTodayDate || - oArrayHeadersFootersInfo[0]->m_oHeadersFootersAtom->m_bHasUserDate*/; + oArrayHeadersFootersInfo[0]->m_oHeadersFootersAtom->m_bHasTodayDate || + oArrayHeadersFootersInfo[0]->m_oHeadersFootersAtom->m_bHasUserDate*/; bHasFooter = oArrayHeadersFootersInfo[0]->m_oHeadersFootersAtom->m_bHasFooter; bHasSlideNumber = oArrayHeadersFootersInfo[0]->m_oHeadersFootersAtom->m_bHasSlideNumber; @@ -2369,62 +2369,67 @@ void CPPTUserInfo::LoadExternal(CRecordExObjListContainer* pExObjects) //-------------------------------------------------------------------- std::vector oArrayHyperlinkContainer; - pExObjects->GetRecordsByType(&oArrayHyperlinkContainer , true); - for (size_t nIndex = 0; nIndex < oArrayHyperlinkContainer.size(); ++nIndex) + for (const auto* pExHyperlink : oArrayHyperlinkContainer) { - std::vector oArrayHyperlink; - std::vector oArrayCString; + if (!pExHyperlink || !pExHyperlink->hasCString()) + continue; - oArrayHyperlinkContainer[nIndex]->GetRecordsByType (&oArrayHyperlink, false); - oArrayHyperlinkContainer[nIndex]->GetRecordsByType (&oArrayCString, false); + PPT_FORMAT::CExFilesInfo oInfo; + oInfo.m_dwID = pExHyperlink->m_exHyperlinkAtom.m_nHyperlinkID; - if (oArrayCString.size() > 0 && oArrayHyperlink.size() > 0) + bool wasSlide = false; +// bool wasLink = false; + + // it isn't normal that here we should catch slide number. + if (pExHyperlink->m_friendlyNameAtom.IsInit()) { - PPT_FORMAT::CExFilesInfo oInfo; - - oInfo.m_dwID = oArrayHyperlink[0]->m_nHyperlinkID; - for (size_t i = 0 ; i < oArrayCString.size(); i++) - { - const auto& recStr = oArrayCString[i]->m_strText; - const auto recInst = oArrayCString[i]->m_oHeader.RecInstance; - // Target atom. It's for eigher local and external files. - if (recInst == 1) - { - oInfo.m_strFilePath = recStr; - if (oInfo.isAudioLink(recStr)) - oInfo.m_type = CExFilesInfo::ExFilesType::eftAudio; - else if (oInfo.isHTTPLink(recStr)) - oInfo.m_type = CExFilesInfo::ExFilesType::eftHyperlink; - else - oInfo.m_type = CExFilesInfo::ExFilesType::eftHyperlink; - } - // Location atom. It's for slides or other local pp objects. - else if (recInst == 3 && oInfo.GetSlideNumber(recStr) != -1) - { - oInfo.m_strFilePath = recStr; - oInfo.m_type = CExFilesInfo::ExFilesType::eftSlide; - } - else - continue; - } - switch (oInfo.m_type) - { - case CExFilesInfo::ExFilesType::eftHyperlink: - m_oExMedia.m_arHyperlinks.push_back(oInfo); - break; - case CExFilesInfo::ExFilesType::eftAudio: - m_oExMedia.m_arAudioCollection.push_back(oInfo); - break; - case CExFilesInfo::ExFilesType::eftSlide: - m_oExMedia.m_arSlides.push_back(oInfo); - break; - default: - m_oExMedia.m_arHyperlinks.push_back(oInfo); - } - + std::wstring& recStr =pExHyperlink->m_friendlyNameAtom->m_strText; +// int slideNum = oInfo.GetSlideNumber(recStr); +// if (slideNum != -1) +// { +// oInfo.m_strFilePath = recStr; +// oInfo.m_type = CExFilesInfo::ExFilesType::eftSlide; +// m_oExMedia.m_arSlides.push_back(oInfo); +// wasSlide = true; +// } } + + if (pExHyperlink->m_targetAtom.IsInit()) + { + std::wstring& recStr =pExHyperlink->m_targetAtom->m_strText; + oInfo.m_strFilePath = recStr; + if (oInfo.isAudioLink(recStr)) + { + oInfo.m_type = CExFilesInfo::ExFilesType::eftAudio; + m_oExMedia.m_arAudioCollection.push_back(oInfo); + }else if (oInfo.isHTTPLink(recStr)) + { + oInfo.m_type = CExFilesInfo::ExFilesType::eftHyperlink; + m_oExMedia.m_arHyperlinks.push_back(oInfo); + }else{ + oInfo.m_type = CExFilesInfo::ExFilesType::eftHyperlink; + m_oExMedia.m_arHyperlinks.push_back(oInfo); + } + } + + if (pExHyperlink->m_locationAtom.IsInit()) + { + // Here we need to write some records like file's path and slides + std::wstring& recStr = pExHyperlink->m_locationAtom->m_strText; + oInfo.m_strFilePath = recStr; + if (!wasSlide) + { + oInfo.m_type = CExFilesInfo::ExFilesType::eftSlide; + m_oExMedia.m_arSlides.push_back(oInfo); + } else if (!m_oExMedia.m_arSlides.empty()) + { + oInfo.m_type = CExFilesInfo::ExFilesType::eftSlide; + m_oExMedia.m_arSlides.back().m_strFilePath = recStr; + } + } + } } @@ -2536,7 +2541,7 @@ void CPPTUserInfo::AddAudioTransition (_UINT32 refID, CTransition* pTransition, std::wstring audioName = strRecord->m_strText; ; -// audioName.erase(audioName.find(L"."), audioName.end()); todo + // audioName.erase(audioName.find(L"."), audioName.end()); todo if (strRecord) pTransition->m_oAudio.m_sImageName = audioName; diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/ExHyperlinkAtom.h b/ASCOfficePPTFile/PPTFormatLib/Records/ExHyperlinkAtom.h index 1eed696c3f..6405f84681 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/ExHyperlinkAtom.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/ExHyperlinkAtom.h @@ -31,41 +31,75 @@ */ #pragma once #include "../Reader/Records.h" +#include "CString.h" -class CRecordExHyperlinkContainer : public CRecordsContainer -{ -public: - CRecordExHyperlinkContainer() - { - } - ~CRecordExHyperlinkContainer() - { - } - - virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream) - { - CRecordsContainer::ReadFromStream(oHeader, pStream); - } -}; class CRecordExHyperlinkAtom : public CUnknownRecord { public: - UINT m_nHyperlinkID; - - CRecordExHyperlinkAtom() - { - } + UINT m_nHyperlinkID; - ~CRecordExHyperlinkAtom() - { - } + CRecordExHyperlinkAtom() + { + } - virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream) - { - m_oHeader = oHeader; + ~CRecordExHyperlinkAtom() + { + } - m_nHyperlinkID = StreamUtils::ReadDWORD(pStream); - } -}; \ No newline at end of file + virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream) + { + m_oHeader = oHeader; + + m_nHyperlinkID = StreamUtils::ReadDWORD(pStream); + } +}; + +class CRecordExHyperlinkContainer : public CRecordsContainer +{ +public: + CRecordExHyperlinkAtom m_exHyperlinkAtom; + nullable m_friendlyNameAtom; + nullable m_targetAtom; + nullable m_locationAtom; + + CRecordExHyperlinkContainer() + { + } + + ~CRecordExHyperlinkContainer() + { + } + + bool hasCString()const + { + return m_friendlyNameAtom.IsInit() || m_targetAtom.IsInit() || m_locationAtom.IsInit(); + } + + virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream) + { + m_oHeader = oHeader; + + SRecordHeader header; + + header.ReadFromStream(pStream); + m_exHyperlinkAtom.ReadFromStream(header, pStream); + + unsigned currentLen = 12; // 12(atom) + while (currentLen < m_oHeader.RecLen) + { + header.ReadFromStream(pStream); + auto* pCString = new CRecordCString; + pCString->ReadFromStream(header, pStream); + switch (header.RecInstance) + { + case 0: m_friendlyNameAtom = pCString; break; + case 1: m_targetAtom = pCString; break; + case 3: m_locationAtom = pCString; break; + default: delete pCString; + } + currentLen += 8 + header.RecLen; // headerLen + CStringLen + } + } +}; From 95bba9d44a2854f04ec40a26346e6c189c8216b6 Mon Sep 17 00:00:00 2001 From: Kirill Poljakov Date: Wed, 28 Jul 2021 18:12:34 +0300 Subject: [PATCH 70/84] Fixed missing text when converting an EMF file --- DesktopEditor/raster/Metafile/Common/MetaFileRenderer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DesktopEditor/raster/Metafile/Common/MetaFileRenderer.h b/DesktopEditor/raster/Metafile/Common/MetaFileRenderer.h index 61516b09fb..460a2ba337 100644 --- a/DesktopEditor/raster/Metafile/Common/MetaFileRenderer.h +++ b/DesktopEditor/raster/Metafile/Common/MetaFileRenderer.h @@ -192,8 +192,8 @@ namespace MetaFile if (!pFont) return; - UpdateClip(); UpdateTransform(iGraphicsMode); + UpdateClip(); int lLogicalFontHeight = pFont->GetHeight(); if (lLogicalFontHeight < 0) From 2a8e8995bd3cf17a97244b4f6449df2f9e983de4 Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Thu, 29 Jul 2021 15:46:10 +0300 Subject: [PATCH 71/84] add checker for empty fix macro --- ASCOfficePPTXFile/PPTXFormat/Logic/Shape.h | 7 ++++--- Common/OfficeFileFormatChecker2.cpp | 18 +++++++++++++++--- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/Shape.h b/ASCOfficePPTXFile/PPTXFormat/Logic/Shape.h index e69a5e08e4..b0dfdeaed6 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/Shape.h +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/Shape.h @@ -296,10 +296,11 @@ namespace PPTX void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) { WritingElement_ReadAttributes_Start( oReader ) - WritingElement_ReadAttributes_Read_if( oReader, _T("useBgFill"), useBgFill) - WritingElement_ReadAttributes_End( oReader ) + WritingElement_ReadAttributes_Read_if( oReader, L"useBgFill", useBgFill) + WritingElement_ReadAttributes_Read_if(oReader, L"macro", macro) + WritingElement_ReadAttributes_End( oReader ) } - std::wstring GetText()const{if(txBody.IsInit()) return txBody->GetText(); return _T(""); }; + std::wstring GetText()const{if(txBody.IsInit()) return txBody->GetText(); return L""; }; void FillLevelUp(); void Merge(Shape& shape, bool bIsSlidePlaceholder = false); diff --git a/Common/OfficeFileFormatChecker2.cpp b/Common/OfficeFileFormatChecker2.cpp index 38bfae484c..c6e4496a18 100644 --- a/Common/OfficeFileFormatChecker2.cpp +++ b/Common/OfficeFileFormatChecker2.cpp @@ -396,6 +396,8 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring & _fileName) } //----------------------------------------------------------------------------------------------- // others + + bool bEmptyFile = false; { NSFile::CFileBinary file; if (!file.OpenFile(fileName)) @@ -408,6 +410,8 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring & _fileName) file.ReadFile(buffer, MIN_SIZE_BUFFER, dwReadBytes); int sizeRead = (int)dwReadBytes; + bEmptyFile = (dwReadBytes < 1); + if ( isOOXFlatFormatFile(buffer,sizeRead) ) { //nFileType; @@ -469,7 +473,7 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring & _fileName) if (buffer)delete []buffer; buffer = NULL; } - if (nFileType != AVS_OFFICESTUDIO_FILE_UNKNOWN)return true; + if (nFileType != AVS_OFFICESTUDIO_FILE_UNKNOWN) return true; //------------------------------------------------------------------------------------------------ //// by Extension @@ -480,8 +484,16 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring & _fileName) sExt = fileName.substr(nExtPos); std::transform(sExt.begin(), sExt.end(), sExt.begin(), tolower); - - if (0 == sExt.compare(L".mht")) + + if (nFileType != AVS_OFFICESTUDIO_FILE_UNKNOWN) return true; + + if (bEmptyFile && 0 == sExt.compare(L".xlsx")) + nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX; + else if (bEmptyFile && 0 == sExt.compare(L".docx")) + nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX; + if (bEmptyFile && 0 == sExt.compare(L".pptx")) + nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX; + else if (0 == sExt.compare(L".mht")) nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_MHT; else if (0 == sExt.compare(L".csv") || 0 == sExt.compare(L".xlsx") || 0 == sExt.compare(L".xls")) nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV; From f43a38bdc9e509773b0644549f92882d4c867601 Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Thu, 29 Jul 2021 16:52:03 +0300 Subject: [PATCH 72/84] convert empty files --- Common/OfficeFileFormatChecker2.cpp | 22 ++++-- X2tConverter/src/ASCConverters.cpp | 104 +++++++++++++++++++++------- 2 files changed, 95 insertions(+), 31 deletions(-) diff --git a/Common/OfficeFileFormatChecker2.cpp b/Common/OfficeFileFormatChecker2.cpp index c6e4496a18..eebc8544a3 100644 --- a/Common/OfficeFileFormatChecker2.cpp +++ b/Common/OfficeFileFormatChecker2.cpp @@ -487,12 +487,22 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring & _fileName) if (nFileType != AVS_OFFICESTUDIO_FILE_UNKNOWN) return true; - if (bEmptyFile && 0 == sExt.compare(L".xlsx")) - nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX; - else if (bEmptyFile && 0 == sExt.compare(L".docx")) - nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX; - if (bEmptyFile && 0 == sExt.compare(L".pptx")) - nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX; + if (bEmptyFile) + { + if (0 == sExt.compare(L".xlsx")) + nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX; + else if ( 0 == sExt.compare(L".docx")) + nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX; + else if (0 == sExt.compare(L".pptx")) + nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX; + + else if (0 == sExt.compare(L".ods")) + nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS; + else if (0 == sExt.compare(L".odt")) + nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT; + else if (0 == sExt.compare(L".odp")) + nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP; + } else if (0 == sExt.compare(L".mht")) nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_MHT; else if (0 == sExt.compare(L".csv") || 0 == sExt.compare(L".xlsx") || 0 == sExt.compare(L".xls")) diff --git a/X2tConverter/src/ASCConverters.cpp b/X2tConverter/src/ASCConverters.cpp index 000b9a7ba4..744b5ed19f 100644 --- a/X2tConverter/src/ASCConverters.cpp +++ b/X2tConverter/src/ASCConverters.cpp @@ -99,6 +99,31 @@ namespace NExtractTools } return sExt; } + bool create_if_empty(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &signature) + { + bool res = false; + NSFile::CFileBinary file; + if (file.OpenFile(sFrom)) + { + long file_size = file.GetFileSize(); + file.CloseFile(); + + if (file_size == 0) + { + file.CreateFileW(sTo); + + if (false == signature.empty()) + { + file.WriteStringUTF8(signature); + } + file.CloseFile(); + + res = true; + } + } + return res; + } + _UINT32 replaceContentType(const std::wstring &sDir, const std::wstring &sCTFrom, const std::wstring &sCTTo) { _UINT32 nRes = 0; @@ -231,7 +256,6 @@ namespace NExtractTools // docx -> bin _UINT32 docx2doct_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) { - // Extract docx to temp directory std::wstring sTempUnpackedDOCX = sTemp + FILE_SEPARATOR_STR + _T("docx_unpacked"); NSDirectory::CreateDirectory(sTempUnpackedDOCX); @@ -246,11 +270,14 @@ namespace NExtractTools if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_OTHER_MS_OFFCRYPTO) return mscrypt2oot_bin(sFrom, sTo, sTemp, params); else - return AVS_FILEUTILS_ERROR_CONVERT; + { + if (create_if_empty(sFrom, sTo, L"DOCY;v10;0;")) + return 0; + } + return AVS_FILEUTILS_ERROR_CONVERT; } else return AVS_FILEUTILS_ERROR_CONVERT; } - return docx_dir2doct_bin(sTempUnpackedDOCX, sTo, sTemp, params); } _UINT32 docx_dir2doct_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) @@ -660,6 +687,8 @@ namespace NExtractTools } else { + if (create_if_empty(sFrom, sTo, L"XLSY;v10;0;")) + return 0; return AVS_FILEUTILS_ERROR_CONVERT; } } @@ -1060,7 +1089,11 @@ namespace NExtractTools if (OfficeFileFormatChecker.nFileType == AVS_OFFICESTUDIO_FILE_OTHER_MS_OFFCRYPTO) return mscrypt2oot_bin(sFrom, sTo, sTemp, params); else + { + if (create_if_empty(sFrom, sTo, L"PPTY;v10;0;")) + return 0; return AVS_FILEUTILS_ERROR_CONVERT; + } } else return AVS_FILEUTILS_ERROR_CONVERT; } @@ -2646,21 +2679,30 @@ namespace NExtractTools NSDirectory::CreateDirectory(sTempUnpackedOdf); - COfficeUtils oCOfficeUtils(NULL); - if (S_OK != oCOfficeUtils.ExtractToDirectory(sFrom, sTempUnpackedOdf, NULL, 0)) - return -3; + _UINT32 nRes = 0; - NSDirectory::CreateDirectory(sTempUnpackedOox); - - _UINT32 nRes = ConvertODF2OOXml(sTempUnpackedOdf, sTempUnpackedOox, params.getFontPath(), sTemp, params.getPassword(), NULL); - nRes = processEncryptionError(nRes, sFrom, params); - if(SUCCEEDED_X2T(nRes)) + COfficeUtils oCOfficeUtils(NULL); + if (S_OK == oCOfficeUtils.ExtractToDirectory(sFrom, sTempUnpackedOdf, NULL, 0)) { - BinDocxRW::CDocxSerializer m_oCDocxSerializer; + NSDirectory::CreateDirectory(sTempUnpackedOox); - m_oCDocxSerializer.setFontDir(params.getFontPath()); + nRes = ConvertODF2OOXml(sTempUnpackedOdf, sTempUnpackedOox, params.getFontPath(), sTemp, params.getPassword(), NULL); + nRes = processEncryptionError(nRes, sFrom, params); + if (SUCCEEDED_X2T(nRes)) + { + //???? todooo - xlsx, pptx + BinDocxRW::CDocxSerializer m_oCDocxSerializer; - nRes = m_oCDocxSerializer.saveToFile (sTo, sTempUnpackedOox, params.getXmlOptions(), sTemp) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; + m_oCDocxSerializer.setFontDir(params.getFontPath()); + + nRes = m_oCDocxSerializer.saveToFile(sTo, sTempUnpackedOox, params.getXmlOptions(), sTemp) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; + } + } + else + { + nRes = AVS_FILEUTILS_ERROR_CONVERT; + if (create_if_empty(sFrom, sTo, L"DOCY;v10;0;")) + nRes = 0; } return nRes; } @@ -2671,7 +2713,7 @@ namespace NExtractTools COfficeUtils oCOfficeUtils(NULL); if (S_OK != oCOfficeUtils.ExtractToDirectory(sFrom, sTempUnpackedOdf, NULL, 0)) - return AVS_FILEUTILS_ERROR_CONVERT;; + return AVS_FILEUTILS_ERROR_CONVERT; _UINT32 nRes = ConvertOTF2ODF(sTempUnpackedOdf); if(SUCCEEDED_X2T(nRes)) @@ -2681,32 +2723,44 @@ namespace NExtractTools } return nRes; } - _UINT32 odf2oox(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params) { std::wstring sTempUnpackedOox = sTemp + FILE_SEPARATOR_STR + _T("oox_unpacked"); NSDirectory::CreateDirectory(sTempUnpackedOox); - _UINT32 nRes = odf2oox_dir(sFrom, sTempUnpackedOox, sTemp, params); - if(SUCCEEDED_X2T(nRes)) - { + _UINT32 nRes = odf2oox_dir(sFrom, sTempUnpackedOox, sTemp, params); + + if (SUCCEEDED_X2T(nRes)) + { COfficeUtils oCOfficeUtils(NULL); nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory(sTempUnpackedOox, sTo, true)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT; } + else + { + nRes = AVS_FILEUTILS_ERROR_CONVERT; + if (create_if_empty(sFrom, sTo, L"")) + nRes = 0; + } return nRes; } _UINT32 odf2oox_dir(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params) { + _UINT32 nRes = 0; + std::wstring sTempUnpackedOdf = sTemp + FILE_SEPARATOR_STR + _T("odf_unpacked"); NSDirectory::CreateDirectory(sTempUnpackedOdf); COfficeUtils oCOfficeUtils(NULL); - if (S_OK != oCOfficeUtils.ExtractToDirectory(sFrom, sTempUnpackedOdf, NULL, 0)) - return AVS_FILEUTILS_ERROR_CONVERT;; - - _UINT32 nRes = ConvertODF2OOXml(sTempUnpackedOdf, sTo, params.getFontPath(), sTemp, params.getPassword(), NULL); - nRes = processEncryptionError(nRes, sFrom, params); - return nRes; + if (S_OK == oCOfficeUtils.ExtractToDirectory(sFrom, sTempUnpackedOdf, NULL, 0)) + { + nRes = ConvertODF2OOXml(sTempUnpackedOdf, sTo, params.getFontPath(), sTemp, params.getPassword(), NULL); + nRes = processEncryptionError(nRes, sFrom, params); + } + else + { + nRes = AVS_FILEUTILS_ERROR_CONVERT; + } + return nRes; } //odf flat _UINT32 odf_flat2oot(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params) From 6c28c529e3706ce70b50d452cddafafaf946428b Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Thu, 29 Jul 2021 20:04:07 +0300 Subject: [PATCH 73/84] fix bug #51584 --- .../source/OdfFormat/ods_table_state.cpp | 13 ++++++++----- .../source/OdfFormat/ods_table_state.h | 2 +- .../source/Oox2OdfConverter/XlsxConverter.cpp | 5 +++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.cpp b/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.cpp index 69eb722565..07977a191c 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.cpp @@ -1630,7 +1630,7 @@ void ods_table_state::end_conditional_format() { current_level_.pop_back(); } -void ods_table_state::start_conditional_rule(int rule_type, _CP_OPT(unsigned int) rank, _CP_OPT(bool) bottom) +void ods_table_state::start_conditional_rule(int rule_type, _CP_OPT(unsigned int) rank, _CP_OPT(bool) bottom, _CP_OPT(bool) percent) { office_element_ptr elm; @@ -1682,10 +1682,13 @@ void ods_table_state::start_conditional_rule(int rule_type, _CP_OPT(unsigned int case 13: condition->attr_.calcext_value_ = L"not-contains-text()"; break; case 15: { - if ((bottom) && (*bottom)) - condition->attr_.calcext_value_ = L"bottom-elements(" + std::to_wstring(rank.get_value_or(10)) + L")"; - else - condition->attr_.calcext_value_ = L"top-elements(" + std::to_wstring(rank.get_value_or(10)) + L")"; + if ((bottom) && (*bottom)) condition->attr_.calcext_value_ = L"bottom"; + else condition->attr_.calcext_value_ = L"top"; + + if (percent && (*percent)) *condition->attr_.calcext_value_ += L"-percent("; + else *condition->attr_.calcext_value_ += L"-elements("; + + *condition->attr_.calcext_value_ += std::to_wstring(rank.get_value_or(10)) + L")"; }break; case 16: condition->attr_.calcext_value_ = L"unique"; break; case 2: /*cellIs*/ diff --git a/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.h b/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.h index 697ae696b1..23e39e9747 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.h +++ b/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.h @@ -375,7 +375,7 @@ public: void start_conditional_formats(); void start_conditional_format(std::wstring ref); - void start_conditional_rule(int rule_type, _CP_OPT(unsigned int) rank, _CP_OPT(bool) bottom); + void start_conditional_rule(int rule_type, _CP_OPT(unsigned int) rank, _CP_OPT(bool) bottom, _CP_OPT(bool) percent); void set_conditional_formula(std::wstring formula); void set_conditional_value(int type, std::wstring value ); void set_conditional_iconset(int type_iconset); diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp index 9463ceac16..42d977dc93 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp @@ -3231,12 +3231,13 @@ void XlsxConverter::convert(OOX::Spreadsheet::CConditionalFormattingRule *oox_co if (false == oox_cond_rule->m_oType.IsInit()) return; _CP_OPT(unsigned int) rank; - _CP_OPT(bool) bottom; + _CP_OPT(bool) bottom, percent; if (oox_cond_rule->m_oRank.IsInit()) rank = oox_cond_rule->m_oRank->GetValue(); if (oox_cond_rule->m_oBottom.IsInit()) bottom = oox_cond_rule->m_oBottom->ToBool(); + if (oox_cond_rule->m_oPercent.IsInit()) percent = oox_cond_rule->m_oPercent->ToBool(); - ods_context->current_table()->start_conditional_rule(oox_cond_rule->m_oType->GetValue(), rank, bottom); + ods_context->current_table()->start_conditional_rule(oox_cond_rule->m_oType->GetValue(), rank, bottom, percent); { if (oox_cond_rule->m_oDxfId.IsInit()) { From ef365fc08e3a42b5fc4c93e2adf286c5c0aaa7f1 Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Thu, 29 Jul 2021 20:49:59 +0300 Subject: [PATCH 74/84] form. border & shd --- ASCOfficeDocxFile2/BinReader/Readers.cpp | 13 +- .../BinWriter/BinReaderWriterDefines.h | 6 +- ASCOfficeDocxFile2/BinWriter/BinWriters.cpp | 14 +- ASCOfficeDocxFile2/BinWriter/BinWriters.h | 2 +- .../Source/DocxFormat/Logic/Sdt.cpp | 142 +++++++++++------- .../DocxFormat/Source/DocxFormat/Logic/Sdt.h | 54 +++---- .../Source/DocxFormat/WritingElement.h | 1 + 7 files changed, 143 insertions(+), 89 deletions(-) diff --git a/ASCOfficeDocxFile2/BinReader/Readers.cpp b/ASCOfficeDocxFile2/BinReader/Readers.cpp index afb02a9400..4a60c8aac5 100644 --- a/ASCOfficeDocxFile2/BinReader/Readers.cpp +++ b/ASCOfficeDocxFile2/BinReader/Readers.cpp @@ -9359,7 +9359,8 @@ int Binary_DocumentTableReader::ReadSdtPicture(BYTE type, long length, void* poR int Binary_DocumentTableReader::ReadSdtFormPr(BYTE type, long length, void* poResult) { int res = 0; - ComplexTypes::Word::CFormPr* pFormPr = static_cast(poResult); + OOX::Logic::CFormPr* pFormPr = static_cast(poResult); + if (c_oSerSdt::FormPrKey == type) { pFormPr->m_oKey = m_oBufferedStream.GetString3(length); @@ -9376,6 +9377,16 @@ int Binary_DocumentTableReader::ReadSdtFormPr(BYTE type, long length, void* poRe { pFormPr->m_oRequired = m_oBufferedStream.GetBool(); } + else if (c_oSerSdt::FormPrBorder == type) + { + pFormPr->m_oBorder.Init(); + READ2_DEF(length, res, oBinary_pPrReader.ReadBorder2, pFormPr->m_oBorder.GetPointer()); + } + else if (c_oSerSdt::FormPrShd == type) + { + pFormPr->m_oShd.Init(); + READ2_DEF(length, res, oBinary_CommonReader2.ReadShd, pFormPr->m_oShd.GetPointer()); + } else res = c_oSerConstants::ReadUnknown; return res; diff --git a/ASCOfficeDocxFile2/BinWriter/BinReaderWriterDefines.h b/ASCOfficeDocxFile2/BinWriter/BinReaderWriterDefines.h index 3ff2104565..8206c5e006 100644 --- a/ASCOfficeDocxFile2/BinWriter/BinReaderWriterDefines.h +++ b/ASCOfficeDocxFile2/BinWriter/BinReaderWriterDefines.h @@ -110,7 +110,7 @@ const double g_dKoef_mm_to_hps = 2 * g_dKoef_mm_to_pt; const static wchar_t* g_sFormatSignature = L"DOCY"; const int g_nFormatVersion = 5; -const int g_nFormatVersionNoBase64 = 10; +const int g_nFormatVersionNoBase64 = 10; extern int g_nCurFormatVersion; namespace c_oAscWrapStyle{enum c_oSerFormat { @@ -1241,7 +1241,9 @@ extern int g_nCurFormatVersion; PictureFormPrLockProportions = 62, PictureFormPrRespectBorders = 63, PictureFormPrShiftX = 64, - PictureFormPrShiftY = 65 + PictureFormPrShiftY = 65, + FormPrBorder = 70, + FormPrShd = 71 };} namespace c_oSerFFData{enum c_oSerFFData { diff --git a/ASCOfficeDocxFile2/BinWriter/BinWriters.cpp b/ASCOfficeDocxFile2/BinWriter/BinWriters.cpp index b7b05ec94c..d8b2bc20af 100644 --- a/ASCOfficeDocxFile2/BinWriter/BinWriters.cpp +++ b/ASCOfficeDocxFile2/BinWriter/BinWriters.cpp @@ -7843,7 +7843,7 @@ void BinaryDocumentTableWriter::WriteDropDownList(const OOX::Logic::CSdtDropDown m_oBcw.WriteItemEnd(nCurPos); } } -void BinaryDocumentTableWriter::WriteSdtFormPr(const ComplexTypes::Word::CFormPr& oFormPr) +void BinaryDocumentTableWriter::WriteSdtFormPr(const OOX::Logic::CFormPr& oFormPr) { int nCurPos = 0; if(oFormPr.m_oKey.IsInit()) @@ -7870,6 +7870,18 @@ void BinaryDocumentTableWriter::WriteSdtFormPr(const ComplexTypes::Word::CFormPr m_oBcw.m_oStream.WriteBOOL(oFormPr.m_oRequired.get()); m_oBcw.WriteItemEnd(nCurPos); } + if (oFormPr.m_oBorder.IsInit()) + { + nCurPos = m_oBcw.WriteItemStart(c_oSerSdt::TextFormPrCombBorder); + m_oBcw.WriteBorder(oFormPr.m_oBorder.get()); + m_oBcw.WriteItemEnd(nCurPos); + } + if (oFormPr.m_oShd.IsInit()) + { + nCurPos = m_oBcw.WriteItemStart(c_oSerSdt::TextFormPrCombBorder); + m_oBcw.WriteShd(oFormPr.m_oShd.get()); + m_oBcw.WriteItemEnd(nCurPos); + } } void BinaryDocumentTableWriter::WriteSdtTextFormPr(const OOX::Logic::CTextFormPr& oTextFormPr) { diff --git a/ASCOfficeDocxFile2/BinWriter/BinWriters.h b/ASCOfficeDocxFile2/BinWriter/BinWriters.h index dc66a8bb88..5797f5a5ac 100644 --- a/ASCOfficeDocxFile2/BinWriter/BinWriters.h +++ b/ASCOfficeDocxFile2/BinWriter/BinWriters.h @@ -498,7 +498,7 @@ namespace BinDocxRW void WriteSdtPrDate(const OOX::Logic::CDate& oDate); void WriteDocPartList(const OOX::Logic::CSdtDocPart& oSdtDocPart); void WriteDropDownList(const OOX::Logic::CSdtDropDownList& oDropDownList); - void WriteSdtFormPr(const ComplexTypes::Word::CFormPr& oFormPr); + void WriteSdtFormPr(const OOX::Logic::CFormPr& oFormPr); void WriteSdtTextFormPr(const OOX::Logic::CTextFormPr& oTextFormPr); void WriteSdtTextFormPrComb(const ComplexTypes::Word::CComb& oComb); void WriteSdtPicture(const OOX::Logic::CSdtPicture& oSdtPicture); diff --git a/Common/DocxFormat/Source/DocxFormat/Logic/Sdt.cpp b/Common/DocxFormat/Source/DocxFormat/Logic/Sdt.cpp index 73492449ce..5952f15697 100644 --- a/Common/DocxFormat/Source/DocxFormat/Logic/Sdt.cpp +++ b/Common/DocxFormat/Source/DocxFormat/Logic/Sdt.cpp @@ -55,59 +55,6 @@ namespace ComplexTypes { namespace Word { - void CFormPr::FromXML(XmlUtils::CXmlNode& oNode) - { - XmlMacroReadAttributeBase( oNode, L"w:key", m_oKey ); - XmlMacroReadAttributeBase( oNode, L"w:label", m_oLabel ); - XmlMacroReadAttributeBase( oNode, L"w:helpText", m_oHelpText ); - XmlMacroReadAttributeBase( oNode, L"w:required", m_oRequired ); - } - void CFormPr::FromXML(XmlUtils::CXmlLiteReader& oReader) - { - ReadAttributes(oReader); - - if ( !oReader.IsEmptyNode() ) - oReader.ReadTillEnd(); - } - std::wstring CFormPr::ToString() const - { - std::wstring sResult; - if(m_oKey.IsInit()) - { - sResult += L"w:key=\"" + XmlUtils::EncodeXmlString(m_oKey.get()) + L"\" "; - } - if(m_oLabel.IsInit()) - { - sResult += L"w:label=\"" + XmlUtils::EncodeXmlString(m_oLabel.get()) + L"\" "; - } - if(m_oHelpText.IsInit()) - { - sResult += L"w:helpText=\"" + XmlUtils::EncodeXmlString(m_oHelpText.get()) + L"\" "; - } - if(m_oRequired.IsInit()) - { - if(*m_oRequired) - { - sResult += L"w:required=\"1\" "; - } - else - { - sResult += L"w:required=\"0\" "; - } - - } - - return sResult; - } - void CFormPr::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start_No_NS( oReader ) - WritingElement_ReadAttributes_Read_if( oReader, L"key", m_oKey ) - WritingElement_ReadAttributes_Read_else_if( oReader, L"label", m_oLabel ) - WritingElement_ReadAttributes_Read_else_if( oReader, L"helpText", m_oHelpText ) - WritingElement_ReadAttributes_Read_else_if( oReader, L"required", m_oRequired ) - WritingElement_ReadAttributes_End_No_NS( oReader ) - } void CComb::FromXML(XmlUtils::CXmlNode& oNode) { XmlMacroReadAttributeBase( oNode, L"w:width", m_oWidth ); @@ -154,9 +101,9 @@ namespace OOX { namespace Logic { - //-------------------------------------------------------------------------------- - // CSdtContent - //-------------------------------------------------------------------------------- +//-------------------------------------------------------------------------------- +// CSdtContent +//-------------------------------------------------------------------------------- void CSdtContent::fromXML(XmlUtils::CXmlNode& oNode) { ClearItems(); @@ -364,6 +311,87 @@ namespace OOX return sResult; } +//-------------------------------------------------------------------------------- + EElementType CFormPr::getType() const + { + return et_w_formPr; + } + void CFormPr::fromXML(XmlUtils::CXmlNode& oNode) + { + XmlUtils::CXmlNode oChild; + + XmlMacroReadAttributeBase(oNode, L"w:key", m_oKey); + XmlMacroReadAttributeBase(oNode, L"w:label", m_oLabel); + XmlMacroReadAttributeBase(oNode, L"w:helpText", m_oHelpText); + XmlMacroReadAttributeBase(oNode, L"w:required", m_oRequired); + + WritingElement_ReadNode(oNode, oChild, L"w:border", m_oBorder); + WritingElement_ReadNode(oNode, oChild, L"w:shd", m_oShd); + } + void CFormPr::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + ReadAttributes(oReader); + + if (oReader.IsEmptyNode()) + return; + + int nParentDepth = oReader.GetDepth(); + while (oReader.ReadNextSiblingNode(nParentDepth)) + { + std::wstring sName = oReader.GetName(); + if (L"w:shd" == sName) + m_oShd = oReader; + else if (L"w:border" == sName) + m_oBorder = oReader; + } + } + std::wstring CFormPr::toXML() const + { + std::wstring sResult = L""; + WritingElement_WriteNode_1(L""; + + return sResult; + + return sResult; + } + void CFormPr::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start_No_NS(oReader) + WritingElement_ReadAttributes_Read_if(oReader, L"key", m_oKey) + WritingElement_ReadAttributes_Read_else_if(oReader, L"label", m_oLabel) + WritingElement_ReadAttributes_Read_else_if(oReader, L"helpText", m_oHelpText) + WritingElement_ReadAttributes_Read_else_if(oReader, L"required", m_oRequired) + WritingElement_ReadAttributes_End_No_NS(oReader) + } //----------------------------------------------------------------------------------------------------------------------------- void CTextFormPr::fromXML(XmlUtils::CXmlNode& oNode) { @@ -739,7 +767,7 @@ namespace OOX break; } } - WritingElement_WriteNode_1(L"> m_oVal; }; - //Not from specification - class CFormPr : public ComplexType - { - public: - ComplexTypes_AdditionConstructors(CFormPr) - CFormPr() - { - } - virtual ~CFormPr() - { - } - - virtual void FromXML(XmlUtils::CXmlNode& oNode); - virtual void FromXML(XmlUtils::CXmlLiteReader& oReader); - virtual std::wstring ToString() const; - private: - - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - - public: - - nullable_string m_oKey; - nullable_string m_oLabel; - nullable_string m_oHelpText; - nullable_bool m_oRequired; - }; //Not from specification class CComb : public ComplexType { @@ -462,6 +436,32 @@ namespace OOX { namespace Logic { + //Not from specification + class CFormPr : public WritingElement + { + public: + WritingElement_AdditionConstructors(CFormPr) + CFormPr(OOX::Document *pMain = NULL) : WritingElement(pMain) + { + } + virtual ~CFormPr() + { + } + virtual void fromXML(XmlUtils::CXmlNode& oNode); + virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); + virtual std::wstring toXML() const; + virtual EElementType getType() const; + private: + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); + public: + nullable_string m_oKey; + nullable_string m_oLabel; + nullable_string m_oHelpText; + nullable_bool m_oRequired; + + nullable m_oBorder; + nullable m_oShd; + }; //Not from specification class CTextFormPr : public WritingElement { @@ -1163,7 +1163,7 @@ namespace OOX nullable m_oText; nullable m_oCheckbox; - nullable m_oFormPr; //Not from specification + nullable m_oFormPr; //Not from specification nullable m_oTextFormPr; //Not from specification nullable m_oPicture; //Not from specification }; diff --git a/Common/DocxFormat/Source/DocxFormat/WritingElement.h b/Common/DocxFormat/Source/DocxFormat/WritingElement.h index 9d8d543012..6840003d21 100644 --- a/Common/DocxFormat/Source/DocxFormat/WritingElement.h +++ b/Common/DocxFormat/Source/DocxFormat/WritingElement.h @@ -729,6 +729,7 @@ namespace OOX et_w_cols, // et_w_comboBox, // et_w_textFormPr, // custom! + et_w_formPr,// custom! et_w_comment, // et_w_commentRangeEnd, // et_w_commentRangeStart, // From 1d04e2dddc90d7c84715eaf6080315677e2011b6 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Fri, 30 Jul 2021 16:27:53 +0300 Subject: [PATCH 75/84] remove some debug cout --- .../Reader/PPTDocumentInfoOneUser.cpp | 16 ++++++++-------- ASCOfficePPTFile/PPTFormatLib/Records/CString.h | 5 +++-- .../Records/Drawing/ShapeContainer.cpp | 13 +++++++------ .../PPTFormatLib/Records/ExHyperlinkAtom.h | 7 +++++++ .../PPTFormatLib/Records/InteractiveInfoAtom.h | 4 ++++ 5 files changed, 29 insertions(+), 16 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp b/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp index 556bd40b30..d50792e1eb 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp @@ -2386,14 +2386,14 @@ void CPPTUserInfo::LoadExternal(CRecordExObjListContainer* pExObjects) if (pExHyperlink->m_friendlyNameAtom.IsInit()) { std::wstring& recStr =pExHyperlink->m_friendlyNameAtom->m_strText; -// int slideNum = oInfo.GetSlideNumber(recStr); -// if (slideNum != -1) -// { -// oInfo.m_strFilePath = recStr; -// oInfo.m_type = CExFilesInfo::ExFilesType::eftSlide; -// m_oExMedia.m_arSlides.push_back(oInfo); -// wasSlide = true; -// } + int slideNum = oInfo.GetSlideNumber(recStr); + if (slideNum != -1) + { + oInfo.m_strFilePath = recStr; + oInfo.m_type = CExFilesInfo::ExFilesType::eftSlide; + m_oExMedia.m_arSlides.push_back(oInfo); + wasSlide = true; + } } if (pExHyperlink->m_targetAtom.IsInit()) diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/CString.h b/ASCOfficePPTFile/PPTFormatLib/Records/CString.h index 4961a5a5f6..36b18000aa 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/CString.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/CString.h @@ -31,6 +31,7 @@ */ #pragma once #include "../Reader/Records.h" +#include class CRecordCString : public CUnknownRecord { @@ -48,7 +49,7 @@ public: virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream) { m_oHeader = oHeader; - m_strText = StreamUtils::ReadStringW(pStream, m_oHeader.RecLen / 2); + m_strText = StreamUtils::ReadStringW(pStream, m_oHeader.RecLen / 2); } -}; \ No newline at end of file +}; diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp index 1613c63b40..28d83143e6 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.cpp @@ -1921,7 +1921,7 @@ CElementPtr CRecordShapeContainer::GetElement (bool inGroup, CExMedia* pMapIDs, { oArrayTextBox[0]->GetRecordsByType(&oArrayTextInteractive, false); - oArrayTextBox[0]->GetRecordsByType(&oArrayInteractiveCont, false); +// oArrayTextBox[0]->GetRecordsByType(&oArrayInteractiveCont, false); } for (const auto* pInerAtom : oArrayInteractiveCont) @@ -2618,11 +2618,12 @@ void CRecordShapeContainer::ConvertInteractiveInfo(CInteractiveInfo &interactive if (NULL != pInfo2) { interactiveInfo.m_strHyperlink = pInfo2->m_strFilePath; - } - pInfo2 = pMapIDs->LockHyperlink(interactiveAtom.m_nExHyperlinkIdRef); - if (NULL != pInfo2) - { - interactiveInfo.m_strHyperlink = pInfo2->m_strFilePath; + } else { + pInfo2 = pMapIDs->LockHyperlink(interactiveAtom.m_nExHyperlinkIdRef); + if (NULL != pInfo2) + { + interactiveInfo.m_strHyperlink = pInfo2->m_strFilePath; + } } } if (interactiveCont->macroNameAtom.is_init()) diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/ExHyperlinkAtom.h b/ASCOfficePPTFile/PPTFormatLib/Records/ExHyperlinkAtom.h index 6405f84681..5db31e9052 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/ExHyperlinkAtom.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/ExHyperlinkAtom.h @@ -34,6 +34,7 @@ #include "CString.h" + class CRecordExHyperlinkAtom : public CUnknownRecord { @@ -101,5 +102,11 @@ public: } currentLen += 8 + header.RecLen; // headerLen + CStringLen } +// if (m_friendlyNameAtom.IsInit() && (int)m_friendlyNameAtom->m_strText.find(L"NEXT") == -1) +// std::wcout << m_exHyperlinkAtom.m_nHyperlinkID << L" " +// << (m_friendlyNameAtom.IsInit() ? m_friendlyNameAtom->m_strText : L"-") << L" " +// << (m_targetAtom.IsInit() ? m_targetAtom->m_strText : L"-") << L" " +// << (m_locationAtom.IsInit() ? m_locationAtom->m_strText : L"-") +// << std::endl; } }; diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/InteractiveInfoAtom.h b/ASCOfficePPTFile/PPTFormatLib/Records/InteractiveInfoAtom.h index d0542489ce..6683558f7c 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/InteractiveInfoAtom.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/InteractiveInfoAtom.h @@ -31,6 +31,7 @@ */ #pragma once #include "../Reader/Records.h" +#include class CRecordInteractiveInfoAtom : public CUnknownRecord { @@ -74,5 +75,8 @@ public: m_nHyperlinkType = StreamUtils::ReadBYTE(pStream); StreamUtils::StreamSkip(3, pStream); +// if (m_nExHyperlinkIdRef) +// std::wcout << L"HyperlinkIDRef: " << m_nExHyperlinkIdRef << std::endl;; + } }; From 11ebcfa4765838f4934492ca2f7436eb01967759 Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Sat, 31 Jul 2021 10:39:04 +0300 Subject: [PATCH 76/84] fix forms --- Common/DocxFormat/Source/DocxFormat/Logic/Sdt.cpp | 12 ++++++------ XlsxSerializerCom/Common/BinReaderWriterDefines.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Common/DocxFormat/Source/DocxFormat/Logic/Sdt.cpp b/Common/DocxFormat/Source/DocxFormat/Logic/Sdt.cpp index 5952f15697..88ad4f3cec 100644 --- a/Common/DocxFormat/Source/DocxFormat/Logic/Sdt.cpp +++ b/Common/DocxFormat/Source/DocxFormat/Logic/Sdt.cpp @@ -351,25 +351,25 @@ namespace OOX if (m_oKey.IsInit()) { - sResult += L"w:key=\"" + XmlUtils::EncodeXmlString(m_oKey.get()) + L"\" "; + sResult += L" w:key=\"" + XmlUtils::EncodeXmlString(m_oKey.get()) + L"\""; } if (m_oLabel.IsInit()) { - sResult += L"w:label=\"" + XmlUtils::EncodeXmlString(m_oLabel.get()) + L"\" "; + sResult += L" w:label=\"" + XmlUtils::EncodeXmlString(m_oLabel.get()) + L"\""; } if (m_oHelpText.IsInit()) { - sResult += L"w:helpText=\"" + XmlUtils::EncodeXmlString(m_oHelpText.get()) + L"\" "; + sResult += L" w:helpText=\"" + XmlUtils::EncodeXmlString(m_oHelpText.get()) + L"\""; } if (m_oRequired.IsInit()) { if (*m_oRequired) { - sResult += L"w:required=\"1\" "; + sResult += L" w:required=\"1\" "; } else { - sResult += L"w:required=\"0\" "; + sResult += L" w:required=\"0\" "; } } @@ -377,7 +377,7 @@ namespace OOX WritingElement_WriteNode_1(L""; + sResult += L""; return sResult; diff --git a/XlsxSerializerCom/Common/BinReaderWriterDefines.h b/XlsxSerializerCom/Common/BinReaderWriterDefines.h index 626814e011..76d4ce7b28 100755 --- a/XlsxSerializerCom/Common/BinReaderWriterDefines.h +++ b/XlsxSerializerCom/Common/BinReaderWriterDefines.h @@ -143,7 +143,7 @@ namespace BinXlsxRW Aligment = 13, Protection = 14 };} - namespace c_oSerProtectionTypes {enum c_oSerAligmentTypes + namespace c_oSerProtectionTypes {enum c_oSerProtectionTypes { Hidden = 0, Locked = 1 From 0ed170de454677a270bd505a0617fd35c11332fa Mon Sep 17 00:00:00 2001 From: Oleg Korshul Date: Mon, 2 Aug 2021 16:22:31 +0300 Subject: [PATCH 77/84] Fix bug 50866 --- PdfReader/Src/JBIG2Stream.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PdfReader/Src/JBIG2Stream.cpp b/PdfReader/Src/JBIG2Stream.cpp index 13b760c07f..3331bfed99 100644 --- a/PdfReader/Src/JBIG2Stream.cpp +++ b/PdfReader/Src/JBIG2Stream.cpp @@ -3182,7 +3182,8 @@ namespace PdfReader } if (bLtp) { - pBitmap->DuplicateRow(nY, nY - 1); + if (nY > 0) + pBitmap->DuplicateRow(nY, nY - 1); continue; } } From 389387eebf2ede346f25d6d67e0c7d305dbe504a Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Mon, 2 Aug 2021 17:52:16 +0300 Subject: [PATCH 78/84] was repaired vbaProject.bin file writer --- .../Reader/PPTDocumentInfoOneUser.cpp | 16 ++++++++----- .../Records/DocInfoListContainer.h | 24 ++++++++++++++++++- .../Records/OfficeArtClientData.h | 6 +++++ .../PPTFormatLib/Records/SlideContainer.h | 11 +++++++++ .../PPTFormatLib/Records/VBAInfoAtom.h | 14 +++++++++++ ASCOfficePPTXFile/Editor/Drawing/Document.h | 2 +- 6 files changed, 65 insertions(+), 8 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp b/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp index f84be5a6bc..b2f038d0ad 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Reader/PPTDocumentInfoOneUser.cpp @@ -403,14 +403,18 @@ bool CPPTUserInfo::ReadDocumentPersists(POLE::Stream* pStream) if (m_bMacros) { m_bMacros = false; - std::vector oArrayVba; - m_oDocument.GetRecordsByType(&oArrayVba, true, true); + std::vector oArrayDocInfo; + m_oDocument.GetRecordsByType(&oArrayDocInfo, true, true); - if (!oArrayVba.empty()) + CRecordVBAInfoAtom* pVbaAtom = nullptr; + if (!oArrayDocInfo.empty()) + pVbaAtom = oArrayDocInfo[0]->getVBAInfoAtom(); + + if (pVbaAtom) { - if (oArrayVba[0]->m_nHasMacros) + if (pVbaAtom->m_nHasMacros) { - nIndexPsrRef = m_mapOffsetInPIDs.find(oArrayVba[0]->m_nObjStgDataRef); + nIndexPsrRef = m_mapOffsetInPIDs.find(pVbaAtom->m_nObjStgDataRef); if (m_mapOffsetInPIDs.end() != nIndexPsrRef) { @@ -420,7 +424,7 @@ bool CPPTUserInfo::ReadDocumentPersists(POLE::Stream* pStream) POLE::Stream *pStreamTmp = pStream; if (m_pDecryptor) { - DecryptStream(pStream, oArrayVba[0]->m_nObjStgDataRef); + DecryptStream(pStream, pVbaAtom->m_nObjStgDataRef); pStreamTmp = m_arStreamDecrypt.back()->stream_; } oHeader.ReadFromStream(pStreamTmp); diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/DocInfoListContainer.h b/ASCOfficePPTFile/PPTFormatLib/Records/DocInfoListContainer.h index 28f5ec1a06..1386de7875 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/DocInfoListContainer.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/DocInfoListContainer.h @@ -32,6 +32,7 @@ #pragma once #include "DocProgTagsContainer.h" +#include "VBAInfoAtom.h" namespace PPT_FORMAT { @@ -46,7 +47,13 @@ public: { case RT_ProgTags: { - m_record = new CRecordDocProgTagsContainer; + m_record.reset(new CRecordDocProgTagsContainer); + m_record->ReadFromStream(oHeader, pStream); + break; + } + case RT_VbaInfo: + { + m_record.reset(new CRecordVBAInfoContainer); m_record->ReadFromStream(oHeader, pStream); break; } @@ -105,5 +112,20 @@ public: } StreamUtils::StreamSeek(lPos + m_oHeader.RecLen, pStream); } + + CRecordVBAInfoAtom* getVBAInfoAtom()const + { + for (const auto* pChild : m_rgChildRec) + { + if (!pChild || !pChild->m_record.IsInit()) + continue; + IRecord* pRecord = pChild->m_record.GetPointer(); + auto* pVBA = dynamic_cast(pRecord); + if (pVBA) + return static_cast(pVBA->m_arRecords[0]); + } + + return nullptr; + } }; } diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/OfficeArtClientData.h b/ASCOfficePPTFile/PPTFormatLib/Records/OfficeArtClientData.h index 6884fe8e58..62efbc2752 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/OfficeArtClientData.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/OfficeArtClientData.h @@ -100,6 +100,12 @@ public: m_rgShapeClientRoundtripData.push_back(pRec); break; } + case RT_VbaInfo: + { + auto pRec = new CRecordsContainer; + pRec->ReadFromStream(ReadHeader, pStream); + break; + } default: IRecord* pRecord = CreateByType(ReadHeader); pRecord->ReadFromStream(ReadHeader, pStream); diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/SlideContainer.h b/ASCOfficePPTFile/PPTFormatLib/Records/SlideContainer.h index 0e0bd8d52e..84ba071894 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/SlideContainer.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/SlideContainer.h @@ -32,6 +32,7 @@ #pragma once #include "../Reader/Records.h" #include "SlideProgTagsContainer.h" +#include "VBAInfoAtom.h" #include "../Records/SSSlideInfoAtom.h" @@ -110,6 +111,16 @@ public: continue; } + if (RT_VbaInfo == oRec.RecType) + { + auto pVbaInfo = new CRecordsContainer; + pVbaInfo->ReadFromStream(oRec, pStream); + m_arRecords.push_back(pVbaInfo); + + lCurLen += (8 + oRec.RecLen); + continue; + } + IRecord* pRecord = CreateByType ( oRec ); diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/VBAInfoAtom.h b/ASCOfficePPTFile/PPTFormatLib/Records/VBAInfoAtom.h index 82f0930d36..dd540afcc2 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/VBAInfoAtom.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/VBAInfoAtom.h @@ -59,6 +59,20 @@ public: }; +class CRecordVBAInfoContainer : public CRecordsContainer +{ +public: + CRecordVBAInfoContainer() + {} + ~CRecordVBAInfoContainer() + {} + virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream) + { + m_oHeader = oHeader; + CRecordsContainer::ReadFromStream(oHeader, pStream); + } +}; + class CRecordVbaProjectStg : public CUnknownRecord { public: diff --git a/ASCOfficePPTXFile/Editor/Drawing/Document.h b/ASCOfficePPTXFile/Editor/Drawing/Document.h index 172320b4e5..af7038c5f0 100644 --- a/ASCOfficePPTXFile/Editor/Drawing/Document.h +++ b/ASCOfficePPTXFile/Editor/Drawing/Document.h @@ -55,7 +55,7 @@ namespace PPT_FORMAT bool m_bMacros; std::wstring m_sVbaProjectFile; - CDocument() : m_bMacros (false) + CDocument() : m_bMacros (true) { m_lSlideWidth = 0; m_lSlideHeight = 0; From 9cdd43cfa9d3366899732cfa725e930541fa9a37 Mon Sep 17 00:00:00 2001 From: Oleg Korshul Date: Mon, 2 Aug 2021 17:57:19 +0300 Subject: [PATCH 79/84] Fix bug 50975 --- PdfReader/Src/SecurityHandler.cpp | 4 ++-- PdfReader/Src/XRef.cpp | 10 ++++++++++ PdfReader/Src/XRef.h | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/PdfReader/Src/SecurityHandler.cpp b/PdfReader/Src/SecurityHandler.cpp index 72db2f49ae..d75391c898 100644 --- a/PdfReader/Src/SecurityHandler.cpp +++ b/PdfReader/Src/SecurityHandler.cpp @@ -151,7 +151,7 @@ namespace PdfReader if (oCryptCurFilter.DictLookup("Length", &oCFLength)->IsInt()) { // Согласно спецификации, должно быть oCFLength / 8 - m_nFileKeyLength = oCFLength.GetInt(); + m_nFileKeyLength = oCFLength.GetInt() / 8; } oCFLength.Free(); @@ -265,4 +265,4 @@ namespace PdfReader } return true; } -} \ No newline at end of file +} diff --git a/PdfReader/Src/XRef.cpp b/PdfReader/Src/XRef.cpp index 0fa33f6dcf..7e1ccb754e 100644 --- a/PdfReader/Src/XRef.cpp +++ b/PdfReader/Src/XRef.cpp @@ -229,6 +229,8 @@ namespace PdfReader { m_oCS.InitializeCriticalSection(); + m_arrDecryptKey = NULL; + m_bValidXref = true; m_eErrorCode = errorNone; m_nEntrySize = 0; @@ -314,6 +316,10 @@ namespace PdfReader delete m_pObjectStream; } + if (NULL != m_arrDecryptKey) + MemUtilsFree(m_arrDecryptKey); + m_arrDecryptKey = NULL; + m_oCS.DeleteCriticalSection(); } @@ -926,6 +932,10 @@ namespace PdfReader m_bOwnerPassword = bOwnerPassword; m_nKeyLength = nKeyLength; + if (NULL != m_arrDecryptKey) + MemUtilsFree(m_arrDecryptKey); + m_arrDecryptKey = (unsigned char*)MemUtilsMalloc(m_nKeyLength); + for (int nIndex = 0; nIndex < m_nKeyLength; ++nIndex) { m_arrDecryptKey[nIndex] = sDecryptKey[nIndex]; diff --git a/PdfReader/Src/XRef.h b/PdfReader/Src/XRef.h index 03bedf285d..65e80b0932 100644 --- a/PdfReader/Src/XRef.h +++ b/PdfReader/Src/XRef.h @@ -181,7 +181,7 @@ namespace PdfReader bool m_bEncrypted; // Поток зашифрован или нет? int m_nPermissionFlags; // Различные ограничения bool m_bOwnerPassword; // Проверяем правильный ли был введен пароль владельца файла - unsigned char m_arrDecryptKey[32]; // Ключ для расшифровки + unsigned char* m_arrDecryptKey; // Ключ для расшифровки int m_nKeyLength; // Размер ключа в байтах int m_nEncryptVersion; // Версия шифровки CryptAlgorithm m_eEncryptAlgorithm; // Алгоритм шифрования From f8db90b29ad335780d97f6a16bbf1afadbd0592d Mon Sep 17 00:00:00 2001 From: Oleg Korshul Date: Mon, 2 Aug 2021 18:02:03 +0300 Subject: [PATCH 80/84] . --- PdfReader/Src/SecurityHandler.cpp | 2 +- PdfReader/Src/XRef.cpp | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/PdfReader/Src/SecurityHandler.cpp b/PdfReader/Src/SecurityHandler.cpp index d75391c898..d5020bef92 100644 --- a/PdfReader/Src/SecurityHandler.cpp +++ b/PdfReader/Src/SecurityHandler.cpp @@ -151,7 +151,7 @@ namespace PdfReader if (oCryptCurFilter.DictLookup("Length", &oCFLength)->IsInt()) { // Согласно спецификации, должно быть oCFLength / 8 - m_nFileKeyLength = oCFLength.GetInt() / 8; + m_nFileKeyLength = oCFLength.GetInt() / 8; } oCFLength.Free(); diff --git a/PdfReader/Src/XRef.cpp b/PdfReader/Src/XRef.cpp index 7e1ccb754e..3459d19103 100644 --- a/PdfReader/Src/XRef.cpp +++ b/PdfReader/Src/XRef.cpp @@ -229,7 +229,7 @@ namespace PdfReader { m_oCS.InitializeCriticalSection(); - m_arrDecryptKey = NULL; + m_arrDecryptKey = NULL; m_bValidXref = true; m_eErrorCode = errorNone; @@ -316,9 +316,8 @@ namespace PdfReader delete m_pObjectStream; } - if (NULL != m_arrDecryptKey) - MemUtilsFree(m_arrDecryptKey); - m_arrDecryptKey = NULL; + if (NULL != m_arrDecryptKey) + MemUtilsFree(m_arrDecryptKey); m_oCS.DeleteCriticalSection(); } @@ -932,9 +931,9 @@ namespace PdfReader m_bOwnerPassword = bOwnerPassword; m_nKeyLength = nKeyLength; - if (NULL != m_arrDecryptKey) - MemUtilsFree(m_arrDecryptKey); - m_arrDecryptKey = (unsigned char*)MemUtilsMalloc(m_nKeyLength); + if (NULL != m_arrDecryptKey) + MemUtilsFree(m_arrDecryptKey); + m_arrDecryptKey = (unsigned char*)MemUtilsMalloc(m_nKeyLength); for (int nIndex = 0; nIndex < m_nKeyLength; ++nIndex) { From de9812479dc8cd8786963e4a70ad7d460dedee8d Mon Sep 17 00:00:00 2001 From: Oleg Korshul Date: Mon, 2 Aug 2021 18:03:20 +0300 Subject: [PATCH 81/84] . --- PdfReader/Src/XRef.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PdfReader/Src/XRef.h b/PdfReader/Src/XRef.h index 65e80b0932..55da215318 100644 --- a/PdfReader/Src/XRef.h +++ b/PdfReader/Src/XRef.h @@ -181,7 +181,7 @@ namespace PdfReader bool m_bEncrypted; // Поток зашифрован или нет? int m_nPermissionFlags; // Различные ограничения bool m_bOwnerPassword; // Проверяем правильный ли был введен пароль владельца файла - unsigned char* m_arrDecryptKey; // Ключ для расшифровки + unsigned char* m_arrDecryptKey; // Ключ для расшифровки int m_nKeyLength; // Размер ключа в байтах int m_nEncryptVersion; // Версия шифровки CryptAlgorithm m_eEncryptAlgorithm; // Алгоритм шифрования From da6b89af94dc292b5feeeb97f8e0c1e114a6f047 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Mon, 2 Aug 2021 18:55:23 +0300 Subject: [PATCH 82/84] trying to fix 51660 --- ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp index 6cd8fab2e3..aae42edeb8 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp @@ -1227,10 +1227,11 @@ void PPT_FORMAT::CPPTXWriter::WriteTransition(CStringWriter& oWriter, CSlideShow case 6: { auto pTrBase = new PPTX::Logic::OptionalBlackTransition; - if (transition.m_nEffectType == 0) param_name = L"cut"; - else if (transition.m_nEffectType == 5) param_name = L"dissolve"; - else if (transition.m_nEffectType == 6) param_name = L"fade"; + if (transition.m_nEffectType == 0) pTrBase->name = L"cut"; + else if (transition.m_nEffectType == 5) pTrBase->name = L"dissolve"; + else if (transition.m_nEffectType == 6) pTrBase->name = L"fade"; pTrBase->thruBlk = transition.m_nEffectDirection; + Tr.base.base.reset(pTrBase); }break; case 4: case 7: From 5d505d58ce195d6573f86b119d4ae3cfe59c87d5 Mon Sep 17 00:00:00 2001 From: Alexander Yuzhin Date: Tue, 3 Aug 2021 11:11:27 +0300 Subject: [PATCH 83/84] [mobile] Add event type for send theme color --- DesktopEditor/Word_Api/Editor_Defines.h | 1 + 1 file changed, 1 insertion(+) diff --git a/DesktopEditor/Word_Api/Editor_Defines.h b/DesktopEditor/Word_Api/Editor_Defines.h index 2e28587665..31198c7df7 100644 --- a/DesktopEditor/Word_Api/Editor_Defines.h +++ b/DesktopEditor/Word_Api/Editor_Defines.h @@ -782,6 +782,7 @@ #define ASC_MENU_EVENT_TYPE_COLOR_SCHEMES 2404 // CAscColorSchemes #define ASC_MENU_EVENT_TYPE_CHANGE_COLOR_SCHEME 2415 // SET(int) #define ASC_MENU_EVENT_TYPE_GET_COLOR_SCHEME 2416 // GET(int) +#define ASC_MENU_EVENT_TYPE_THEMECOLORS 2417 #define ASC_MENU_EVENT_TYPE_GO_TO_INTERNAL_LINK 5000 From 84c4447fa219710fdb3923dda9a4bf58093cfcc4 Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Tue, 3 Aug 2021 17:58:30 +0300 Subject: [PATCH 84/84] fix bug #51648 --- .../odf/style_paragraph_properties_docx.cpp | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/ASCOfficeOdfFile/src/odf/style_paragraph_properties_docx.cpp b/ASCOfficeOdfFile/src/odf/style_paragraph_properties_docx.cpp index 6ecf8462ce..e353ba5520 100644 --- a/ASCOfficeOdfFile/src/odf/style_paragraph_properties_docx.cpp +++ b/ASCOfficeOdfFile/src/odf/style_paragraph_properties_docx.cpp @@ -171,7 +171,7 @@ void paragraph_format_properties::docx_convert(oox::docx_conversion_context & Co if (style_inst) { if (level < 0 && style_inst->outline_level()) - { + { level = style_inst->outline_level().get(); } @@ -183,12 +183,29 @@ void paragraph_format_properties::docx_convert(oox::docx_conversion_context & Co if (level >= 0 && level < 10) { - if (list_styles.outline_style()) + text_outline_style* outline_style = list_styles.outline_style(); + if (outline_style) { - _pPr << L""; - if (level < 9 && bOutlineList) + bool bListEnabled = true; + if (level < outline_style->content_.size()) + { + office_element_ptr elm = outline_style->content_[level]; + text_outline_level_style* outline_level = dynamic_cast(elm.get()); + if (outline_level) { - _pPr << L""; + if (!outline_level->common_num_format_attlist_.style_num_format_) + bListEnabled = false; + else if (outline_level->common_num_format_attlist_.style_num_format_->get_type() == odf_types::style_numformat::none) + bListEnabled = false; + } + } + else + bListEnabled = false; + + _pPr << L""; + if (bListEnabled && level < 9 && bOutlineList) + { + _pPr << L""; _pPr << L""; } else