diff --git a/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp index d8e947882e..549e18ecd2 100755 --- a/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp @@ -847,8 +847,6 @@ namespace DocFileFormat } else if (TextMark::FieldBeginMark == code) { - _embeddedObject = false; - int cpFieldStart = initialCp + i; int cpFieldEnd = searchNextTextMark( m_document->Text, cpFieldStart, TextMark::FieldEndMark ); @@ -1036,14 +1034,21 @@ namespace DocFileFormat if (!bFormula) { - m_pXmlWriter->WriteString(pictWriter.GetXmlString()); - - if ((false == _fieldLevels.empty()) && (_fieldLevels.back().bSeparate && !_fieldLevels.back().bResult)) //ege15.doc + if (false == _fieldLevels.empty()) { - _fieldLevels.back().bResult = true; - }//imrtemplate(endnotes).doc + if (_fieldLevels.back().bSeparate && !_fieldLevels.back().bResult) //ege15.doc + { + m_pXmlWriter->WriteString(pictWriter.GetXmlString()); + _fieldLevels.back().bResult = true; + } + } + else + { + m_pXmlWriter->WriteString(pictWriter.GetXmlString()); + } } } + } } else if ((TextMark::AutoNumberedFootnoteReference == code) && fSpec) @@ -1093,20 +1098,9 @@ namespace DocFileFormat } else if (!FormatUtils::IsControlSymbol(c) && ((int)c != 0xFFFF)) { + + writeNotesReferences(cp);//for word95 & non-automatic notes text += FormatUtils::GetXMLSymbol(c); - - //non-automatic notes - if ((m_document->IndividualFootnotesPlex != NULL) && (m_document->IndividualFootnotesPlex->IsCpExists(cp - m_document->FIB->m_RgLw97.ccpText))) - { - _writeNoteRef = L""; - } - else if ((m_document->IndividualEndnotesPlex != NULL) && - (m_document->IndividualEndnotesPlex->IsCpExists(cp - m_document->FIB->m_RgLw97.ccpAtn - m_document->FIB->m_RgLw97.ccpHdr - m_document->FIB->m_RgLw97.ccpFtn - m_document->FIB->m_RgLw97.ccpText))) - { - _writeNoteRef = L""; - } - else - writeNotesReferences(cp);//for word95 } cp++; @@ -1824,11 +1818,6 @@ namespace DocFileFormat m_pXmlWriter->WriteNodeBegin( L"w:endnoteRef", true ); m_pXmlWriter->WriteNodeEnd( L"", true ); } - else if (false == _writeNoteRef.empty()) - { - m_pXmlWriter->WriteString(_writeNoteRef); - _writeNoteRef.clear(); - } return true; } bool DocumentMapping::writeBookmarks(int cp) diff --git a/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.h b/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.h index af6fde4ebb..672cf93178 100644 --- a/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.h @@ -158,7 +158,6 @@ namespace DocFileFormat bool _writeWebHidden; std::wstring _writeAfterRun; std::wstring _lastOLEObject; - std::wstring _writeNoteRef; int _cacheListNum; std::wstring _paraId; diff --git a/ASCOfficeDocFile/DocDocxConverter/TablePropertiesMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/TablePropertiesMapping.cpp index 4308e75d2b..6abdbc4fd1 100644 --- a/ASCOfficeDocFile/DocDocxConverter/TablePropertiesMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/TablePropertiesMapping.cpp @@ -65,9 +65,7 @@ namespace DocFileFormat XMLTools::XMLElement tblLayout ( L"w:tblLayout"); XMLTools::XMLElement tblpPr ( L"w:tblpPr"); XMLTools::XMLAttribute layoutType ( L"w:type", L""); - bool bLayoutFixed = true; - //layoutType.SetValue(L"fixed"); _CP_OPT(short) tblIndent; short gabHalf = 0; diff --git a/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.cpp index b9e4da8f19..97ae14e551 100644 --- a/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.cpp @@ -142,9 +142,7 @@ namespace DocFileFormat m_pXmlWriter->WriteNodeBegin( L"v:group", true ); m_pXmlWriter->WriteAttribute( L"id", m_shapeId); - bool layoutInCell = true; bool twistDimensions = false; - m_pXmlWriter->WriteAttribute( L"style", FormatUtils::XmlEncode(buildStyle(shape, anchor, options, container->Index, twistDimensions))); m_pXmlWriter->WriteAttribute( L"coordorigin", ( FormatUtils::IntToWideString(gsr->rcgBounds.topLeftAngle.x) + L"," + FormatUtils::IntToWideString( gsr->rcgBounds.topLeftAngle.y))); m_pXmlWriter->WriteAttribute( L"coordsize", ( FormatUtils::IntToWideString(gsr->rcgBounds.size.cx) + L"," + FormatUtils::IntToWideString(gsr->rcgBounds.size.cy))); @@ -159,24 +157,13 @@ namespace DocFileFormat std::wstring wrapCoords = GetWrapCoords(options[i]); if (!wrapCoords.empty()) m_pXmlWriter->WriteAttribute(L"wrapcoords", wrapCoords); - }break; - case ODRAW::groupShapeBooleanProperties: - { - ODRAW::GroupShapeBooleanProperties *booleans = dynamic_cast(options[i].get()); - if (booleans && booleans->fUsefLayoutInCell) - { - layoutInCell = booleans->fLayoutInCell; - } } break; default: break; } } - if (!layoutInCell) - { - m_pXmlWriter->WriteAttribute(L"o:allowincell", L"f"); - } + m_pXmlWriter->WriteNodeEnd(L"", true, false); // Convert the shapes/groups in the group @@ -319,7 +306,7 @@ namespace DocFileFormat ODRAW::OfficeArtFOPTEPtr & iter = options[i]; switch (iter->opid) { - //BOOLEANS + //BOOLEANS case ODRAW::geometryBooleanProperties: { ODRAW::GeometryBooleanProperties *booleans = dynamic_cast(iter.get()); @@ -381,7 +368,7 @@ namespace DocFileFormat } } break; - // GEOMETRY + // GEOMETRY case ODRAW::shapePath: { bHavePath = true; @@ -532,7 +519,7 @@ namespace DocFileFormat case 3: m_pXmlWriter->WriteAttribute(L"o:connectortype", L"none"); break; } }break; - // FILL + // FILL case ODRAW::fillColor: { RGBColor fillColor((int)iter->op, RedFirst); @@ -603,7 +590,7 @@ namespace DocFileFormat { appendValueAttribute(&m_fill, L"o:opacity2", (FormatUtils::IntToWideString(iter->op) + L"f")); }break; - // SHADOW + // SHADOW case ODRAW::shadowType: { appendValueAttribute(&m_shadow, L"type", getShadowType(iter->op)); @@ -649,12 +636,12 @@ namespace DocFileFormat //ODRAW::ShadowStyleBooleanProperties }break; - // OLE + // OLE case ODRAW::pictureId: { indexOLE = iter->op; }break; - // PICTURE + // PICTURE case ODRAW::pib: { int index = (int)(iter->op - 1); @@ -693,35 +680,6 @@ namespace DocFileFormat { appendValueAttribute(&m_imagedata, L"gamma", (FormatUtils::IntToWideString(iter->op) + L"f")); }break; - //CROPPING - case ODRAW::cropFromBottom: - { - //cast to signed integer - int cropBottom = (int)iter->op; - appendValueAttribute(&m_imagedata, L"cropbottom", FormatUtils::IntToWideString(cropBottom) + L"f"); - } - break; - case ODRAW::cropFromLeft: - { - //cast to signed integer - int cropLeft = (int)iter->op; - appendValueAttribute(&m_imagedata, L"cropleft", FormatUtils::IntToWideString(cropLeft) + L"f"); - } - break; - case ODRAW::cropFromRight: - { - //cast to signed integer - int cropRight = (int)iter->op; - appendValueAttribute(&m_imagedata, L"cropright", FormatUtils::IntToWideString(cropRight) + L"f"); - } - break; - case ODRAW::cropFromTop: - { - //cast to signed integer - int cropTop = (int)iter->op; - appendValueAttribute(&m_imagedata, L"croptop", FormatUtils::IntToWideString(cropTop) + L"f"); - } - break; // 3D STYLE case ODRAW::threeDStyleBooleanProperties: { @@ -826,16 +784,6 @@ namespace DocFileFormat break; } }break; - case ODRAW::textBooleanProperties: - { - ODRAW::TextBooleanProperties *props = dynamic_cast(iter.get()); - - if (props->fUsefFitShapeToText && props->fFitShapeToText) - { - appendStyleProperty(sTextboxStyle, L"mso-fit-shape-to-text", L"t"); - } - }break; - // Word Art case ODRAW::gtextUNICODE: { @@ -1437,7 +1385,7 @@ namespace DocFileFormat { if (oBlip->btWin32 == Global::msoblipDIB) { - std::wstring file_name = m_context->_doc->m_sTempFolder + FILE_SEPARATOR_STR + L"tmp_image"; + std::wstring file_name = m_context->_doc->m_sTempFolder + L"tmp_image"; oBlip->btWin32 = ImageHelper::SaveImageToFileFromDIB(bitBlip->m_pvBits, bitBlip->pvBitsSize, file_name); @@ -1691,19 +1639,7 @@ namespace DocFileFormat return L"margin"; } } - std::wstring VMLShapeMapping::mapWrapText(int val) - { - switch (val) - { - case 0: return L"square"; - //case 1: return L"ByPoints"; - case 2: return L"none"; - //case 3: return L"TopBottom"; - //case 3: return L"Through"; - default: - return L"square"; - } - } + void VMLShapeMapping::AppendOptionsToStyle (std::wstring& oStyle, const std::vector& options, int zIndex) const { int nRelH = -1; @@ -1719,11 +1655,7 @@ namespace DocFileFormat const ODRAW::OfficeArtFOPTEPtr & iter = options[i]; switch (iter->opid) { - case ODRAW::WrapText: - { - appendStyleProperty(oStyle, L"mso-wrap-style", mapWrapText(iter->op)); - }break; - // POSITIONING +// POSITIONING case ODRAW::posh: { nPosH = iter->op; diff --git a/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.h b/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.h index a6efeaf2cc..bb6ede067e 100644 --- a/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.h @@ -61,11 +61,10 @@ namespace DocFileFormat virtual ~VMLShapeMapping(); virtual void Apply(IVisitable* visited); - static std::wstring mapVerticalPosition (PositionVertical vPos ); + static std::wstring mapVerticalPosition (PositionVertical vPos ); static std::wstring mapVerticalPositionRelative (int vRel ); - static std::wstring mapHorizontalPosition (PositionHorizontal hPos ); - static std::wstring mapHorizontalPositionRelative (int hRel ); - static std::wstring mapWrapText (int val_); + static std::wstring mapHorizontalPosition (PositionHorizontal hPos ); + static std::wstring mapHorizontalPositionRelative(int hRel ); bool m_isBullete; bool m_isPictureBroken; diff --git a/ASCOfficeDocxFile2/BinReader/FileWriter.cpp b/ASCOfficeDocxFile2/BinReader/FileWriter.cpp index c0b4c0ca34..76ffc70fc3 100644 --- a/ASCOfficeDocxFile2/BinReader/FileWriter.cpp +++ b/ASCOfficeDocxFile2/BinReader/FileWriter.cpp @@ -39,7 +39,7 @@ namespace Writers { -FileWriter::FileWriter(std::wstring sDirOutput,std::wstring sFontDir, bool bNoFontDir, int nVersion, NSBinPptxRW::CDrawingConverter* pDrawingConverter, std::wstring sThemePath) +FileWriter::FileWriter(std::wstring sDirOutput,std::wstring sFontDir, bool bNoFontDir, int nVersion, bool bSaveChartAsImg, NSBinPptxRW::CDrawingConverter* pDrawingConverter, std::wstring sThemePath) : m_oMain(sDirOutput, sFontDir, bNoFontDir, nVersion), m_oGlossary(sDirOutput, sFontDir, bNoFontDir, nVersion), @@ -47,6 +47,7 @@ FileWriter::FileWriter(std::wstring sDirOutput,std::wstring sFontDir, bool bNoFo m_oChartWriter (sDirOutput), m_oCustomXmlWriter (sDirOutput, pDrawingConverter), m_pDrawingConverter (pDrawingConverter), + m_bSaveChartAsImg (bSaveChartAsImg), m_sThemePath (sThemePath), m_oDocumentRelsWriter (sDirOutput), m_nDocPrIndex (0), diff --git a/ASCOfficeDocxFile2/BinReader/FileWriter.h b/ASCOfficeDocxFile2/BinReader/FileWriter.h index 31a0538ab4..b675422fa0 100644 --- a/ASCOfficeDocxFile2/BinReader/FileWriter.h +++ b/ASCOfficeDocxFile2/BinReader/FileWriter.h @@ -120,7 +120,7 @@ namespace Writers _part_summary_writers m_oGlossary; public: - FileWriter(std::wstring sDirOutput, std::wstring sFontDir, bool bNoFontDir, int nVersion, NSBinPptxRW::CDrawingConverter* pDrawingConverter, std::wstring sThemePath); + FileWriter(std::wstring sDirOutput, std::wstring sFontDir, bool bNoFontDir, int nVersion, bool bSaveChartAsImg, NSBinPptxRW::CDrawingConverter* pDrawingConverter, std::wstring sThemePath); ~FileWriter(); FontTableWriter& get_font_table_writer() { return m_bGlossaryMode ? m_oGlossary.font_table : m_oMain.font_table; } @@ -161,7 +161,7 @@ namespace Writers smart_ptr m_pVbaProject; NSBinPptxRW::CDrawingConverter* m_pDrawingConverter; - + bool m_bSaveChartAsImg; std::wstring m_sThemePath; int m_nDocPrIndex; BinDocxRW::CComments* m_pComments; diff --git a/ASCOfficeDocxFile2/BinReader/ReaderClasses.h b/ASCOfficeDocxFile2/BinReader/ReaderClasses.h index fef206774c..b81c01f42f 100644 --- a/ASCOfficeDocxFile2/BinReader/ReaderClasses.h +++ b/ASCOfficeDocxFile2/BinReader/ReaderClasses.h @@ -280,33 +280,6 @@ public: } return sRes; } - void ToCThemeColor( nullable>& oColor, - nullable>& oThemeColor, - nullable>& oThemeTint, - nullable>& oThemeShade) - { - if (Auto) - { - if(!oColor.IsInit()) - oColor.Init(); - oColor->SetValue(SimpleTypes::hexcolorAuto); - } - if (bColor) - { - oThemeColor.Init(); - oThemeColor->SetValue((SimpleTypes::EThemeColor)Color); - } - if (bTint) - { - oThemeTint.Init(); - oThemeTint->SetValue(Tint); - } - if (bShade) - { - oThemeShade.Init(); - oThemeShade->SetValue(Shade); - } - } }; class Spacing { @@ -387,16 +360,17 @@ class Shd public: BYTE Value; docRGB Color; - docRGB Fill; - CThemeColor ThemeColor; - - bool bValue = false; - bool bColor = false; - bool bThemeColor = false; - bool bFill = false; - - Shd(){} + CThemeColor ThemeColor; + bool bValue; + bool bColor; + bool bThemeColor; + Shd() + { + bValue = false; + bColor = false; + bThemeColor = false; + } std::wstring ToString() { std::wstring sShd; @@ -449,17 +423,17 @@ public: } } if (bColor) + { + sShd += L" w:fill=\"" + Color.ToString() + L"\""; sShd += L" w:color=\"" + Color.ToString() + L"\""; - - if (bFill) - sShd += L" w:fill=\"#" + Fill.ToString() + L"\""; - - if (!bColor && !bFill) + } + else + { sShd += L" w:color=\"auto\""; - + } if(bThemeColor && ThemeColor.IsNoEmpty()) { - if(ThemeColor.Auto && !bColor && !bFill) + if(ThemeColor.Auto && !bColor) sShd += L" w:fill=\"auto\""; if(ThemeColor.bColor) sShd += L" w:themeFill=\"" + ThemeColor.ToStringColor() + L"\""; @@ -504,10 +478,6 @@ public: std::wstring FontHAnsi; std::wstring FontAE; std::wstring FontCS; - std::wstring FontAsciiTheme; - std::wstring FontHAnsiTheme; - std::wstring FontAETheme; - std::wstring FontCSTheme; long FontSize; docRGB Color; BYTE VertAlign; @@ -631,7 +601,7 @@ public: { return bBold || bItalic || bUnderline || bStrikeout || bFontAscii || bFontHAnsi || bFontAE || bFontCS || bFontSize || bColor || bVertAlign || nHighLight > 0 || bShd || bRStyle || bSpacing || bDStrikeout || bCaps || bSmallCaps || bPosition || bFontHint || bBoldCs || bItalicCs || bFontSizeCs || bCs || bRtl || bLang || bLangBidi || bLangEA || bThemeColor || bVanish || - !Outline.empty() || !Fill.empty() || !Del.empty() || !Ins.empty() || !MoveFrom.empty() || !MoveTo.empty() || !rPrChange.empty() || !FontAsciiTheme.empty() || !FontHAnsiTheme.empty() || !FontAETheme.empty() || !FontCSTheme.empty(); + !Outline.empty() || !Fill.empty() || !Del.empty() || !Ins.empty() || !MoveFrom.empty() || !MoveTo.empty() || !rPrChange.empty(); } void Write(NSStringUtils::CStringBuilder* pCStringWriter) { @@ -640,7 +610,7 @@ public: { pCStringWriter->WriteString(L""); } - if(bFontAscii || bFontHAnsi || bFontAE || bFontCS || bFontHint || !FontAsciiTheme.empty() || !FontHAnsiTheme.empty() || !FontAETheme.empty() || !FontCSTheme.empty()) + if(bFontAscii || bFontHAnsi || bFontAE || bFontCS || bFontHint) { std::wstring sFont = _T("\ -"; - } - else - { - sXml += L""; - } + else + sXml += L"\ +"; if(bEffectExtentL && bEffectExtentT && bEffectExtentR && bEffectExtentB) { @@ -2498,17 +2446,18 @@ distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\">"; } - if (!sGraphicFramePr.empty()) + if(!sGraphicFramePr.empty()) { - sXml += sGraphicFramePr; + sXml += (sGraphicFramePr); } else { sXml += L""; } - if (bGraphicFrameContent) + if(bChart) { - sXml += sGraphicFrameContent + L""; + sXml += L""; } else { @@ -2548,10 +2497,9 @@ distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\">"; - } + if(bChart) + sXml += L""; + sXml += L""; - if (bPositionHRelativeFrom && (bPositionHAlign || bPositionHPosOffset || bPositionHPctOffset)) + if(bPositionHRelativeFrom && (bPositionHAlign || bPositionHPosOffset || bPositionHPctOffset)) { std::wstring sRelativeFrom; switch(PositionHRelativeFrom) @@ -2607,7 +2555,7 @@ distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\">" + sContent + L""; } - if (bPositionVRelativeFrom && (bPositionVAlign || bPositionVPosOffset || bPositionVPctOffset)) + if(bPositionVRelativeFrom && (bPositionVAlign || bPositionVPosOffset || bPositionVPctOffset)) { std::wstring sRelativeFrom; switch(PositionVRelativeFrom) @@ -2622,7 +2570,7 @@ distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\">"; - if (bEffectExtentL && bEffectExtentT && bEffectExtentR && bEffectExtentB) + if(bEffectExtentL && bEffectExtentT && bEffectExtentR && bEffectExtentB) { sXml += L""; } - if (bDrawingPropertyWrap && DrawingPropertyWrap.bWrappingType) + if(bDrawingPropertyWrap && DrawingPropertyWrap.bWrappingType) { std::wstring sTagName; switch(DrawingPropertyWrap.WrappingType) { - case c_oSerImageType2::WrapNone:sTagName = _T("wrapNone"); break; - case c_oSerImageType2::WrapSquare:sTagName = _T("wrapSquare"); break; - case c_oSerImageType2::WrapThrough:sTagName = _T("wrapThrough"); break; - case c_oSerImageType2::WrapTight:sTagName = _T("wrapTight"); break; - case c_oSerImageType2::WrapTopAndBottom:sTagName = _T("wrapTopAndBottom"); break; + case c_oSerImageType2::WrapNone:sTagName = _T("wrapNone"); break; + case c_oSerImageType2::WrapSquare:sTagName = _T("wrapSquare"); break; + case c_oSerImageType2::WrapThrough:sTagName = _T("wrapThrough"); break; + case c_oSerImageType2::WrapTight:sTagName = _T("wrapTight"); break; + case c_oSerImageType2::WrapTopAndBottom:sTagName = _T("wrapTopAndBottom"); break; } if(DrawingPropertyWrap.bStart || DrawingPropertyWrap.Points.size() > 0) { @@ -2727,9 +2675,10 @@ distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\">"; } - if (bGraphicFrameContent) + if(bChart) { - sXml += sGraphicFrameContent; + sXml += L""; } if(!sSizeRelH.empty()) @@ -2743,7 +2692,7 @@ distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\">"; - if (bGraphicFrameContent) + if(bChart) sXml += L""; } } diff --git a/ASCOfficeDocxFile2/BinReader/Readers.cpp b/ASCOfficeDocxFile2/BinReader/Readers.cpp index b0f6fd948a..c8e3fcdf0a 100644 --- a/ASCOfficeDocxFile2/BinReader/Readers.cpp +++ b/ASCOfficeDocxFile2/BinReader/Readers.cpp @@ -245,12 +245,6 @@ docRGB Binary_CommonReader2::ReadColor() oRGB.B = m_oBufferedStream.GetUChar(); return oRGB; } -void Binary_CommonReader2::ReadColor2(SimpleTypes::CHexColor<>& color) -{ - color.Set_R(m_oBufferedStream.GetUChar()); - color.Set_G(m_oBufferedStream.GetUChar()); - color.Set_B(m_oBufferedStream.GetUChar()); -} void Binary_CommonReader2::ReadThemeColor(int length, CThemeColor& oCThemeColor) { int res = c_oSerConstants::ReadOk; @@ -307,10 +301,6 @@ int Binary_CommonReader2::ReadShd(BYTE type, long length, void* poResult) pShd->bThemeColor = true; ReadThemeColor(length, pShd->ThemeColor); break; - case c_oSerShdType::Fill: - pShd->bFill = true; - pShd->Fill = ReadColor(); - break; default: res = c_oSerConstants::ReadUnknown; break; @@ -478,13 +468,6 @@ int Binary_rPrReader::ReadContent(BYTE type, long length, void* poResult) } break; } - case c_oSerProp_rPrType::FontAsciiTheme: - { - SimpleTypes::CTheme<> theme; - theme.SetValue((SimpleTypes::ETheme)m_oBufferedStream.GetUChar()); - orPr->FontAsciiTheme = theme.ToString(); - break; - } case c_oSerProp_rPrType::FontHAnsi: { std::wstring sFontName(m_oBufferedStream.GetString3(length)); @@ -496,13 +479,6 @@ int Binary_rPrReader::ReadContent(BYTE type, long length, void* poResult) } break; } - case c_oSerProp_rPrType::FontHAnsiTheme: - { - SimpleTypes::CTheme<> theme; - theme.SetValue((SimpleTypes::ETheme)m_oBufferedStream.GetUChar()); - orPr->FontHAnsiTheme = theme.ToString(); - break; - } case c_oSerProp_rPrType::FontCS: { std::wstring sFontName(m_oBufferedStream.GetString3(length)); @@ -514,13 +490,6 @@ int Binary_rPrReader::ReadContent(BYTE type, long length, void* poResult) } break; } - case c_oSerProp_rPrType::FontCSTheme: - { - SimpleTypes::CTheme<> theme; - theme.SetValue((SimpleTypes::ETheme)m_oBufferedStream.GetUChar()); - orPr->FontCSTheme = theme.ToString(); - break; - } case c_oSerProp_rPrType::FontAE: { std::wstring sFontName(m_oBufferedStream.GetString3(length)); @@ -532,13 +501,6 @@ int Binary_rPrReader::ReadContent(BYTE type, long length, void* poResult) } break; } - case c_oSerProp_rPrType::FontAETheme: - { - SimpleTypes::CTheme<> theme; - theme.SetValue((SimpleTypes::ETheme)m_oBufferedStream.GetUChar()); - orPr->FontAETheme = theme.ToString(); - break; - } case c_oSerProp_rPrType::FontSize: { long nFontSize = m_oBufferedStream.GetLong(); @@ -1331,54 +1293,6 @@ int Binary_pPrReader::ReadBorder(BYTE type, long length, void* poResult) res = c_oSerConstants::ReadUnknown; return res; } -int Binary_pPrReader::ReadBorder2(BYTE type, long length, void* poResult) -{ - int res = c_oSerConstants::ReadOk; - ComplexTypes::Word::CBorder* pBorder = static_cast(poResult); - if( c_oSerBorderType::Color == type ) - { - pBorder->m_oColor.Init(); - pBorder->m_oColor->SetValue(SimpleTypes::hexcolorRGB); - oBinary_CommonReader2.ReadColor2(pBorder->m_oColor.get2()); - } - else if( c_oSerBorderType::Space == type ) - { - pBorder->m_oSpace.Init(); - pBorder->m_oSpace->SetValue(SerializeCommon::Round(g_dKoef_mm_to_pt * m_oBufferedStream.GetDouble())); - } - else if( c_oSerBorderType::SpacePoint == type ) - { - pBorder->m_oSpace.Init(); - pBorder->m_oSpace->SetValue(m_oBufferedStream.GetLong()); - } - else if( c_oSerBorderType::Size == type ) - { - pBorder->m_oSz.Init(); - pBorder->m_oSz->SetValue(SerializeCommon::Round(g_dKoef_mm_to_eightpoint * m_oBufferedStream.GetDouble())); - } - else if( c_oSerBorderType::Size8Point == type ) - { - pBorder->m_oSz.Init(); - pBorder->m_oSz->SetValue(m_oBufferedStream.GetLong()); - } - else if( c_oSerBorderType::Value == type ) - { - pBorder->m_oVal.Init(); - if(border_Single == m_oBufferedStream.GetUChar()) - pBorder->m_oVal->SetValue(SimpleTypes::bordervalueSingle); - else - pBorder->m_oVal->SetValue(SimpleTypes::bordervalueNone); - } - else if( c_oSerBorderType::ColorTheme == type ) - { - CThemeColor ThemeColor; - oBinary_CommonReader2.ReadThemeColor(length, ThemeColor); - ThemeColor.ToCThemeColor(pBorder->m_oColor, pBorder->m_oThemeColor, pBorder->m_oThemeShade, pBorder->m_oThemeTint); - } - else - res = c_oSerConstants::ReadUnknown; - return res; -} int Binary_pPrReader::ReadFramePr(BYTE type, long length, void* poResult) { int res = c_oSerConstants::ReadOk; @@ -3845,13 +3759,6 @@ int Binary_SettingsTableReader::ReadSettings(BYTE type, long length, void* poRes m_oSettingsCustom.m_oSdtGlobalShowHighlight.Init(); m_oSettingsCustom.m_oSdtGlobalShowHighlight->m_oVal.FromBool(m_oBufferedStream.GetBool()); } - else if( c_oSer_SettingsType::SpecialFormsHighlight == type ) - { - rPr oRPr(m_oFileWriter.get_font_table_writer().m_mapFonts); - res = m_oBinary_rPrReader.Read(length, &oRPr); - m_oSettingsCustom.m_oSpecialFormsHighlight.Init(); - InnerColorToOOX(oRPr, m_oSettingsCustom.m_oSpecialFormsHighlight.get2()); - } else if( c_oSer_SettingsType::Compat == type ) { OOX::Settings::CCompat oCompat; @@ -7721,15 +7628,14 @@ int Binary_DocumentTableReader::ReadRunContent(BYTE type, long length, void* poR CDrawingProperty oCDrawingProperty(m_oFileWriter.getNextDocPr()); READ2_DEF(length, res, this->ReadPptxDrawing, &oCDrawingProperty); - if(oCDrawingProperty.IsGraphicFrameContent()) + if(oCDrawingProperty.IsChart()) { GetRunStringWriter().WriteString(oCDrawingProperty.Write()); } else if(oCDrawingProperty.bDataPos && oCDrawingProperty.bDataLength) { std::wstring sDrawingProperty = oCDrawingProperty.Write(); - - if(false == sDrawingProperty.empty()) + if(false == sDrawingProperty.empty()) { ReadDrawing(oCDrawingProperty); } @@ -8248,58 +8154,110 @@ int Binary_DocumentTableReader::ReadPptxDrawing(BYTE type, long length, void* po { int res = c_oSerConstants::ReadOk; CDrawingProperty* pDrawingProperty = static_cast(poResult); - if (c_oSerImageType2::Type == type) + if ( c_oSerImageType2::Type == type ) { pDrawingProperty->bType = true; pDrawingProperty->Type = m_oBufferedStream.GetUChar(); } - else if (c_oSerImageType2::PptxData == type) + else if ( c_oSerImageType2::PptxData == type ) { pDrawingProperty->bDataPos = true; pDrawingProperty->bDataLength = true; pDrawingProperty->DataPos = m_oBufferedStream.GetPos(); pDrawingProperty->DataLength = length; - //сейчас пропуская, потому что перед чтение этого поля надо собрать остальные данные + //сейчас пропуская, потому что перед чтение этого поля надо собрать остальные данные res = c_oSerConstants::ReadUnknown; } - else if (c_oSerImageType2::Chart == type) + else if ( c_oSerImageType2::Chart2 == type ) { - OOX::CPath pathCharts = m_oFileWriter.m_oChartWriter.m_sDir + FILE_SEPARATOR_STR + L"word" + FILE_SEPARATOR_STR + L"charts"; - OOX::CSystemUtility::CreateDirectories(pathCharts.GetPath()); - - m_oBufferedStream.m_pRels->m_pManager->SetDstCharts(pathCharts.GetPath()); - - m_oBufferedStream.Seek(m_oBufferedStream.GetPos() - 4); //roll back length - - PPTX::Logic::GraphicFrame graphicFrame; - - graphicFrame.chartRec.Init(); - graphicFrame.chartRec->fromPPTY(&m_oBufferedStream); - - if (graphicFrame.chartRec->id_data.IsInit()) + if(false == m_oFileWriter.m_bSaveChartAsImg) { - pDrawingProperty->sGraphicFrameContent = graphicFrame.toXML2(); + OOX::CPath pathChartsDir = m_oFileWriter.m_oChartWriter.m_sDir + FILE_SEPARATOR_STR + L"word" + FILE_SEPARATOR_STR + L"charts"; + OOX::CSystemUtility::CreateDirectories(pathChartsDir.GetPath()); + + OOX::CPath pathChartsRelsDir = pathChartsDir.GetPath() + FILE_SEPARATOR_STR + L"_rels"; + OOX::CSystemUtility::CreateDirectories(pathChartsRelsDir.GetPath()); + + OOX::CPath pathChartsWorksheetDir = m_oFileWriter.m_oChartWriter.m_sDir + FILE_SEPARATOR_STR + L"word" + FILE_SEPARATOR_STR + L"embeddings"; + OOX::CSystemUtility::CreateDirectories(pathChartsWorksheetDir.GetPath()); + + int nativeDocumentType = m_oFileWriter.m_pDrawingConverter->m_pImageManager->m_nDocumentType; + + m_oFileWriter.m_pDrawingConverter->m_pImageManager->m_nDocumentType = XMLWRITER_DOC_TYPE_XLSX; + m_oFileWriter.m_pDrawingConverter->SetDstContentRels(); + + std::wstring sThemePath = m_oFileWriter.m_sThemePath; + std::wstring sDrawingsPath = m_oFileWriter.m_oChartWriter.m_sDir + FILE_SEPARATOR_STR + L"word" + FILE_SEPARATOR_STR + L"drawings"; + + size_t nPos = sThemePath.rfind(FILE_SEPARATOR_STR); + if (std::wstring::npos != nPos) + { + sThemePath = sThemePath.substr(0, nPos); + } + + BinXlsxRW::SaveParams oSaveParams(sDrawingsPath, sThemePath, m_oFileWriter.m_pDrawingConverter->GetContentTypes()); + BinXlsxRW::BinaryChartReader oBinaryChartReader(m_oBufferedStream, oSaveParams, m_oFileWriter.m_pDrawingConverter); + + OOX::Spreadsheet::CChartSpace* pChartSpace = new OOX::Spreadsheet::CChartSpace(NULL); + oBinaryChartReader.ReadCT_ChartSpace(length, pChartSpace); + + //save xlsx + _INT32 nChartCount = m_oFileWriter.m_pDrawingConverter->GetDocumentChartsCount(); + _INT32 nChartIndex = nChartCount + 1; + m_oFileWriter.m_pDrawingConverter->SetDocumentChartsCount(nChartCount + 1); + std::wstring sXlsxFilename = L"Microsoft_Excel_Worksheet" + std::to_wstring(nChartIndex) + L".xlsx"; + std::wstring sXlsxPath = pathChartsWorksheetDir.GetPath() + FILE_SEPARATOR_STR + sXlsxFilename; + BinXlsxRW::CXlsxSerializer oXlsxSerializer; + if (oXlsxSerializer.writeChartXlsx(sXlsxPath, *pChartSpace)) + { + std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename; + unsigned int rIdXlsx; + std::wstring bstrChartsWorksheetRelType = OOX::FileTypes::MicrosoftOfficeExcelWorksheet.RelationType(); + + m_oFileWriter.m_pDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, std::wstring(), &rIdXlsx); + m_oFileWriter.m_pDrawingConverter->m_pImageManager->m_pContentTypes->AddDefault(L"xlsx"); + + pChartSpace->m_oChartSpace.m_externalData = new OOX::Spreadsheet::CT_ExternalData(); + pChartSpace->m_oChartSpace.m_externalData->m_id = new std::wstring(); + pChartSpace->m_oChartSpace.m_externalData->m_id->append(L"rId"); + pChartSpace->m_oChartSpace.m_externalData->m_id->append(std::to_wstring(rIdXlsx)); + pChartSpace->m_oChartSpace.m_externalData->m_autoUpdate = new OOX::Spreadsheet::CT_Boolean(); + pChartSpace->m_oChartSpace.m_externalData->m_autoUpdate->m_val = new bool(false); + } + + std::wstring sFilename = L"chart" + std::to_wstring(nChartIndex) + L".xml"; + std::wstring sRelsName = L"charts/" + sFilename; + + OOX::CPath pathChartsFile = pathChartsDir + FILE_SEPARATOR_STR + sFilename; + pChartSpace->write(pathChartsFile, OOX::CPath(L"/word/charts"), *m_oFileWriter.m_pDrawingConverter->GetContentTypes()); + + OOX::CPath pathChartsRels = pathChartsRelsDir.GetPath() + FILE_SEPARATOR_STR + sFilename + L".rels"; + m_oFileWriter.m_pDrawingConverter->SaveDstContentRels(pathChartsRels.GetPath()); + + unsigned int rIdChart; + std::wstring bstrChartRelType = OOX::FileTypes::Chart.RelationType(); + + m_oFileWriter.m_pDrawingConverter->WriteRels(bstrChartRelType, sRelsName, std::wstring(), &rIdChart); + //m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.drawingml.chart+xml", L"/word/charts", sFilename); + + pDrawingProperty->sChartRels = L"rId" + std::to_wstring( rIdChart); + + m_oFileWriter.m_pDrawingConverter->m_pImageManager->m_nDocumentType = nativeDocumentType; } + else + res = c_oSerConstants::ReadUnknown; } - else if (c_oSerImageType2::ChartEx == type) + else if ( c_oSerImageType2::ChartImg == type ) { - OOX::CPath pathCharts = m_oFileWriter.m_oChartWriter.m_sDir + FILE_SEPARATOR_STR + L"word" + FILE_SEPARATOR_STR + L"charts"; - OOX::CSystemUtility::CreateDirectories(pathCharts.GetPath()); - - m_oBufferedStream.m_pRels->m_pManager->SetDstCharts(pathCharts.GetPath()); - - m_oBufferedStream.Seek(m_oBufferedStream.GetPos() - 4); //roll back length - - PPTX::Logic::GraphicFrame graphicFrame; - - graphicFrame.chartRec.Init(); - graphicFrame.chartRec->m_bChartEx = true; - graphicFrame.chartRec->fromPPTY(&m_oBufferedStream); - - if (graphicFrame.chartRec->id_data.IsInit()) + if(true == m_oFileWriter.m_bSaveChartAsImg) { - pDrawingProperty->sGraphicFrameContent = graphicFrame.toXML2(); + pDrawingProperty->bDataPos = true; + pDrawingProperty->bDataLength = true; + pDrawingProperty->DataPos = m_oBufferedStream.GetPos(); + pDrawingProperty->DataLength = length; + //сейчас пропуская, потому что перед чтение этого поля надо собрать остальные данные } + res = c_oSerConstants::ReadUnknown; } else if ( c_oSerImageType2::BehindDoc == type ) { @@ -8488,12 +8446,11 @@ int Binary_DocumentTableReader::ReadEmbedded(BYTE type, long length, void* poRes std::wstring strDstEmbeddedTempThemePath = strDstEmbeddedTempXl + FILE_SEPARATOR_STR + L"theme"; std::wstring strDstEmbeddedTempDrawingPath = strDstEmbeddedTempXl + FILE_SEPARATOR_STR + L"drawings"; - std::wstring strDstEmbeddedTempEmbeddingsPath = strDstEmbeddedTempXl + FILE_SEPARATOR_STR + L"embeddings"; - + int id = m_oFileWriter.m_oChartWriter.nEmbeddedCount++; std::wstring sXlsxFilename = L"Microsoft_Excel_Worksheet" + std::to_wstring( id + 1) + L".xlsx"; - BinXlsxRW::SaveParams oSaveParams(strDstEmbeddedTempDrawingPath, strDstEmbeddedTempEmbeddingsPath, strDstEmbeddedTempThemePath, m_oFileWriter.m_pDrawingConverter->GetContentTypes());//??? + BinXlsxRW::SaveParams oSaveParams(strDstEmbeddedTempDrawingPath, strDstEmbeddedTempThemePath, m_oFileWriter.m_pDrawingConverter->GetContentTypes());//??? OOX::Spreadsheet::CXlsx oXlsx; @@ -9285,11 +9242,6 @@ int Binary_DocumentTableReader::ReadSdtTextFormPr(BYTE type, long length, void* pTextFormPr->m_oMaxCharacters.Init(); pTextFormPr->m_oMaxCharacters->m_oVal = m_oBufferedStream.GetLong(); } - else if (c_oSerSdt::TextFormPrCombBorder == type) - { - pTextFormPr->m_oCombBorder.Init(); - READ2_DEF(length, res, oBinary_pPrReader.ReadBorder2, pTextFormPr->m_oCombBorder.GetPointer()); - } else res = c_oSerConstants::ReadUnknown; return res; @@ -9730,7 +9682,7 @@ int BinaryFileReader::ReadMainTable() m_oFileWriter.m_pDrawingConverter->Registration( L"application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml", - L"/word" + (m_oFileWriter.m_bGlossaryMode ? std::wstring(L"/glossary") : L""), pFooter->m_sFilename); + L"/word" + m_oFileWriter.m_bGlossaryMode ? std::wstring(L"/glossary") : L"", pFooter->m_sFilename); } } if (!oSettingsCustom.IsEmpty()){ diff --git a/ASCOfficeDocxFile2/BinReader/Readers.h b/ASCOfficeDocxFile2/BinReader/Readers.h index 6497891132..96d996879e 100644 --- a/ASCOfficeDocxFile2/BinReader/Readers.h +++ b/ASCOfficeDocxFile2/BinReader/Readers.h @@ -56,7 +56,6 @@ class Binary_CommonReader2 : public Binary_CommonReader public: Binary_CommonReader2(NSBinPptxRW::CBinaryFileReader& poBufferedStream); docRGB ReadColor(); - void ReadColor2(SimpleTypes::CHexColor<>& color); void ReadThemeColor(int length, CThemeColor& oCThemeColor); int _ReadThemeColor(BYTE type, long length, void* poResult); template int ReadTrackRevision(long length, T* poResult); @@ -127,7 +126,6 @@ public: int ReadNumPr(BYTE type, long length, void* poResult); int ReadBorders(BYTE type, long length, void* poResult); int ReadBorder(BYTE type, long length, void* poResult); - int ReadBorder2(BYTE type, long length, void* poResult); int ReadFramePr(BYTE type, long length, void* poResult); int Read_SecPr(BYTE type, long length, void* poResult); int ReadFootnotePr(BYTE type, long length, void* poResult); diff --git a/ASCOfficeDocxFile2/BinWriter/BinReaderWriterDefines.h b/ASCOfficeDocxFile2/BinWriter/BinReaderWriterDefines.h index 59fc86a1a8..136a93be75 100644 --- a/ASCOfficeDocxFile2/BinWriter/BinReaderWriterDefines.h +++ b/ASCOfficeDocxFile2/BinWriter/BinReaderWriterDefines.h @@ -411,11 +411,7 @@ extern int g_nCurFormatVersion; MoveFrom = 36, MoveTo = 37, SpacingTwips = 38, - PositionHps = 39, - FontAsciiTheme = 40, - FontHAnsiTheme = 41, - FontAETheme = 42, - FontCSTheme = 43 + PositionHps = 39 };} namespace c_oSerProp_rowPrType{enum c_oSerProp_rowPrType { @@ -643,7 +639,9 @@ extern int g_nCurFormatVersion; WrapThrough = 20, WrapTight = 21, WrapTopAndBottom = 22, - Chart = 25, + Chart = 23, + ChartImg = 24, + Chart2 = 25, CachedImage = 26, SizeRelH = 27, SizeRelV = 28, @@ -653,8 +651,7 @@ extern int g_nCurFormatVersion; DistBEmu = 32, DistLEmu = 33, DistREmu = 34, - DistTEmu = 35, - ChartEx = 36 + DistTEmu = 35 };} namespace c_oSerEffectExtent{enum c_oSerEffectExtent { @@ -752,8 +749,7 @@ extern int g_nCurFormatVersion; { Value = 0, Color = 1, - ColorTheme = 2, - Fill = 3 + ColorTheme = 2 };} namespace c_oSerPaddingType{enum c_oSerPaddingType { @@ -861,8 +857,7 @@ extern int g_nCurFormatVersion; PrintTwoOnOne = 14, BookFoldPrinting = 15, BookFoldPrintingSheets = 16, - BookFoldRevPrinting = 17, - SpecialFormsHighlight = 18 + BookFoldRevPrinting = 17 };} namespace c_oSer_MathPrType{enum c_oSer_SettingsType { @@ -1222,8 +1217,7 @@ extern int g_nCurFormatVersion; TextFormPrCombWidth = 52, TextFormPrCombSym = 53, TextFormPrCombFont = 54, - TextFormPrMaxCharacters = 55, - TextFormPrCombBorder = 56 + TextFormPrMaxCharacters = 55 };} namespace c_oSerFFData{enum c_oSerFFData { diff --git a/ASCOfficeDocxFile2/BinWriter/BinWriters.cpp b/ASCOfficeDocxFile2/BinWriter/BinWriters.cpp index cc7c65bc19..a7e631fdca 100644 --- a/ASCOfficeDocxFile2/BinWriter/BinWriters.cpp +++ b/ASCOfficeDocxFile2/BinWriter/BinWriters.cpp @@ -305,15 +305,13 @@ void BinaryCommonWriter::WriteShd(const ComplexTypes::Word::CShading& Shd) m_oStream.WriteBYTE(Shd.m_oVal.get().GetValue()); //Misalignment-footer.doc } - //Color - if (false != Shd.m_oColor.IsInit()) - WriteColor(c_oSerShdType::Color, Shd.m_oColor.get()); - - WriteThemeColor(c_oSerShdType::ColorTheme, Shd.m_oFill, Shd.m_oThemeFill, Shd.m_oThemeFillTint, Shd.m_oThemeFillShade); - - //Fill + //Value if (false != Shd.m_oFill.IsInit()) - WriteColor(c_oSerShdType::Fill, Shd.m_oFill.get()); + WriteColor(c_oSerShdType::Color, Shd.m_oFill.get()); + else if (false != Shd.m_oColor.IsInit()) + WriteColor(c_oSerShdType::Color, Shd.m_oColor.get()); + + WriteThemeColor(c_oSerShdType::ColorTheme, Shd.m_oFill, Shd.m_oThemeFill, Shd.m_oThemeFillTint, Shd.m_oThemeFillShade); } void BinaryCommonWriter::WritePaddings(const nullable& left, const nullable& top, const nullable& right, const nullable& bottom) @@ -347,7 +345,7 @@ void BinaryCommonWriter::WritePaddings(const nullableToTwips()); } } -void BinaryCommonWriter::WriteFont(std::wstring sFontName, BYTE bType, DocWrapper::FontProcessor& m_oFontProcessor) +void BinaryCommonWriter::WriteFont(std::wstring& sFontName, BYTE bType, DocWrapper::FontProcessor& m_oFontProcessor) { if(!sFontName.empty()) { @@ -522,39 +520,92 @@ void Binary_rPrWriter::Write_rPr(OOX::Logic::CRunProperty* rPr) //FontFamily if(false != rPr->m_oRFonts.IsInit()) { + std::wstring sFontAscii; + std::wstring sFontHAnsi; + std::wstring sFontAE; + std::wstring sFontCS; const ComplexTypes::Word::CFonts& oFont = rPr->m_oRFonts.get(); - if(oFont.m_sAscii.IsInit()) - m_oBcw.WriteFont(oFont.m_sAscii.get(), c_oSerProp_rPrType::FontAscii, *m_oParamsWriter.m_pFontProcessor); - if(oFont.m_oAsciiTheme.IsInit()) + + if(NULL != m_oParamsWriter.m_pTheme && oFont.m_oAsciiTheme.IsInit()) { - m_oBcw.m_oStream.WriteBYTE(c_oSerProp_rPrType::FontAsciiTheme); - m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte); - m_oBcw.m_oStream.WriteBYTE((BYTE)oFont.m_oAsciiTheme->GetValue()); + const SimpleTypes::ETheme& eTheme = oFont.m_oAsciiTheme.get().GetValue(); + switch(eTheme) + { + case SimpleTypes::themeMajorAscii: + case SimpleTypes::themeMajorBidi: + case SimpleTypes::themeMajorEastAsia: + case SimpleTypes::themeMajorHAnsi: sFontAscii = m_oParamsWriter.m_pTheme->themeElements.fontScheme.majorFont.latin.typeface; break; + case SimpleTypes::themeMinorAscii: + case SimpleTypes::themeMinorBidi: + case SimpleTypes::themeMinorEastAsia: + case SimpleTypes::themeMinorHAnsi: sFontAscii = m_oParamsWriter.m_pTheme->themeElements.fontScheme.minorFont.latin.typeface; break; + default: + break; + } } - if(oFont.m_sHAnsi.IsInit()) - m_oBcw.WriteFont(oFont.m_sHAnsi.get(), c_oSerProp_rPrType::FontHAnsi, *m_oParamsWriter.m_pFontProcessor); - if(oFont.m_oHAnsiTheme.IsInit()) + else if(oFont.m_sAscii.IsInit()) + sFontAscii = oFont.m_sAscii.get(); + + if(NULL != m_oParamsWriter.m_pTheme && oFont.m_oHAnsiTheme.IsInit()) { - m_oBcw.m_oStream.WriteBYTE(c_oSerProp_rPrType::FontHAnsiTheme); - m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte); - m_oBcw.m_oStream.WriteBYTE((BYTE)oFont.m_oHAnsiTheme->GetValue()); + const SimpleTypes::ETheme& eTheme = oFont.m_oHAnsiTheme.get().GetValue(); + switch(eTheme) + { + case SimpleTypes::themeMajorAscii: + case SimpleTypes::themeMajorBidi: + case SimpleTypes::themeMajorEastAsia: + case SimpleTypes::themeMajorHAnsi: sFontHAnsi = m_oParamsWriter.m_pTheme->themeElements.fontScheme.majorFont.latin.typeface; break; + case SimpleTypes::themeMinorAscii: + case SimpleTypes::themeMinorBidi: + case SimpleTypes::themeMinorEastAsia: + case SimpleTypes::themeMinorHAnsi: sFontHAnsi = m_oParamsWriter.m_pTheme->themeElements.fontScheme.minorFont.latin.typeface; break; + default: + break; + } } - if(oFont.m_sEastAsia.IsInit()) - m_oBcw.WriteFont(oFont.m_sEastAsia.get(), c_oSerProp_rPrType::FontAE, *m_oParamsWriter.m_pFontProcessor); - if(oFont.m_oEastAsiaTheme.IsInit()) + else if(oFont.m_sHAnsi.IsInit()) + sFontHAnsi = oFont.m_sHAnsi.get(); + if(NULL != m_oParamsWriter.m_pTheme && oFont.m_oCsTheme.IsInit()) { - m_oBcw.m_oStream.WriteBYTE(c_oSerProp_rPrType::FontAETheme); - m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte); - m_oBcw.m_oStream.WriteBYTE((BYTE)oFont.m_oEastAsiaTheme->GetValue()); + const SimpleTypes::ETheme& eTheme = oFont.m_oCsTheme.get().GetValue(); + switch(eTheme) + { + case SimpleTypes::themeMajorAscii: + case SimpleTypes::themeMajorBidi: + case SimpleTypes::themeMajorEastAsia: + case SimpleTypes::themeMajorHAnsi: sFontCS = m_oParamsWriter.m_pTheme->themeElements.fontScheme.majorFont.latin.typeface; break; + case SimpleTypes::themeMinorAscii: + case SimpleTypes::themeMinorBidi: + case SimpleTypes::themeMinorEastAsia: + case SimpleTypes::themeMinorHAnsi: sFontCS = m_oParamsWriter.m_pTheme->themeElements.fontScheme.minorFont.latin.typeface; break; + default: break; + } } - if(oFont.m_sCs.IsInit()) - m_oBcw.WriteFont(oFont.m_sCs.get(), c_oSerProp_rPrType::FontCS, *m_oParamsWriter.m_pFontProcessor); - if(oFont.m_oCsTheme.IsInit()) + else if(oFont.m_sCs.IsInit()) + sFontCS = oFont.m_sCs.get(); + if(NULL != m_oParamsWriter.m_pTheme && oFont.m_oEastAsiaTheme.IsInit()) { - m_oBcw.m_oStream.WriteBYTE(c_oSerProp_rPrType::FontCSTheme); - m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte); - m_oBcw.m_oStream.WriteBYTE((BYTE)oFont.m_oCsTheme->GetValue()); + const SimpleTypes::ETheme& eTheme = oFont.m_oEastAsiaTheme.get().GetValue(); + switch(eTheme) + { + case SimpleTypes::themeMajorAscii: + case SimpleTypes::themeMajorBidi: + case SimpleTypes::themeMajorEastAsia: + case SimpleTypes::themeMajorHAnsi: sFontAE = m_oParamsWriter.m_pTheme->themeElements.fontScheme.majorFont.latin.typeface; break; + case SimpleTypes::themeMinorAscii: + case SimpleTypes::themeMinorBidi: + case SimpleTypes::themeMinorEastAsia: + case SimpleTypes::themeMinorHAnsi: sFontAE = m_oParamsWriter.m_pTheme->themeElements.fontScheme.minorFont.latin.typeface; break; + default: break; + } } + else if(oFont.m_sEastAsia.IsInit()) + sFontAE = oFont.m_sEastAsia.get(); + m_oBcw.WriteFont(sFontAscii, c_oSerProp_rPrType::FontAscii, *m_oParamsWriter.m_pFontProcessor); + m_oBcw.WriteFont(sFontHAnsi, c_oSerProp_rPrType::FontHAnsi, *m_oParamsWriter.m_pFontProcessor); + m_oBcw.WriteFont(sFontAE, c_oSerProp_rPrType::FontAE, *m_oParamsWriter.m_pFontProcessor); + m_oBcw.WriteFont(sFontCS, c_oSerProp_rPrType::FontCS, *m_oParamsWriter.m_pFontProcessor); + //Hint if(false != oFont.m_oHint.IsInit()) { @@ -6345,7 +6396,7 @@ void BinaryDocumentTableWriter::WriteDrawing(std::wstring* pXml, OOX::Logic::CDr { if (pGraphic->chartRec.IsInit() && pGraphic->chartRec->id_data.IsInit() ) { - m_oBcw.m_oStream.WriteBYTE(pGraphic->chartRec->m_bChartEx ? c_oSerImageType2::ChartEx : c_oSerImageType2::Chart); + m_oBcw.m_oStream.WriteBYTE(c_oSerImageType2::Chart2); m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Variable); int nCurPos = m_oBcw.WriteItemWithLengthStart(); @@ -6411,12 +6462,11 @@ void BinaryDocumentTableWriter::WriteDrawing(std::wstring* pXml, OOX::Logic::CDr WriteEffectExtent(pInline.m_oEffectExtent.get()); m_oBcw.WriteItemWithLengthEnd(nCurPos); } - if (pInline.m_oGraphic.nvGraphicFramePr.IsInit()) { m_oBcw.m_oStream.WriteBYTE(c_oSerImageType2::GraphicFramePr); m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Variable); nCurPos = m_oBcw.WriteItemWithLengthStart(); - WriteNvGraphicFramePr(pInline.m_oGraphic.nvGraphicFramePr.get()); + WriteNvGraphicFramePr(pInline.m_oGraphic.nvGraphicFramePr); m_oBcw.WriteItemWithLengthEnd(nCurPos); } if(pInline.m_oDocPr.IsInit()) @@ -6595,12 +6645,11 @@ void BinaryDocumentTableWriter::WriteDrawing(std::wstring* pXml, OOX::Logic::CDr WriteWrapTopBottom(pAnchor.m_oWrapTopAndBottom.get()); m_oBcw.WriteItemWithLengthEnd(nCurPos); } - if (pAnchor.m_oGraphic.nvGraphicFramePr.IsInit()) { m_oBcw.m_oStream.WriteBYTE(c_oSerImageType2::GraphicFramePr); m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Variable); nCurPos = m_oBcw.WriteItemWithLengthStart(); - WriteNvGraphicFramePr(pAnchor.m_oGraphic.nvGraphicFramePr.get()); + WriteNvGraphicFramePr(pAnchor.m_oGraphic.nvGraphicFramePr); m_oBcw.WriteItemWithLengthEnd(nCurPos); } if(pAnchor.m_oDocPr.IsInit()) @@ -7840,12 +7889,6 @@ void BinaryDocumentTableWriter::WriteSdtTextFormPr(const OOX::Logic::CTextFormPr m_oBcw.m_oStream.WriteLONG(oTextFormPr.m_oMaxCharacters->m_oVal.get()); m_oBcw.WriteItemEnd(nCurPos); } - if(oTextFormPr.m_oCombBorder.IsInit()) - { - nCurPos = m_oBcw.WriteItemStart(c_oSerSdt::TextFormPrCombBorder); - m_oBcw.WriteBorder(oTextFormPr.m_oCombBorder.get()); - m_oBcw.WriteItemEnd(nCurPos); - } } void BinaryDocumentTableWriter::WriteSdtTextFormPrComb(const ComplexTypes::Word::CComb& oComb) { @@ -8277,14 +8320,6 @@ void BinarySettingsTableWriter::WriteSettingsContent(OOX::CSettings& oSettings, m_oBcw.m_oStream.WriteBOOL(oSettingsCustom.m_oSdtGlobalShowHighlight->m_oVal.ToBool()); m_oBcw.WriteItemEnd(nCurPos); } - if(oSettingsCustom.m_oSpecialFormsHighlight.IsInit()) - { - nCurPos = m_oBcw.WriteItemStart(c_oSer_SettingsType::SpecialFormsHighlight); - OOX::Logic::CRunProperty oRPr; - oRPr.m_oColor = oSettingsCustom.m_oSpecialFormsHighlight; - brPrs.Write_rPr(&oRPr); - m_oBcw.WriteItemEnd(nCurPos); - } }; void BinarySettingsTableWriter::WriteMathPr(const OOX::Logic::CMathPr &pMathPr) { diff --git a/ASCOfficeDocxFile2/BinWriter/BinWriters.h b/ASCOfficeDocxFile2/BinWriter/BinWriters.h index 694b1161e4..9132f471e5 100644 --- a/ASCOfficeDocxFile2/BinWriter/BinWriters.h +++ b/ASCOfficeDocxFile2/BinWriter/BinWriters.h @@ -136,7 +136,7 @@ namespace BinDocxRW void WriteShd(const ComplexTypes::Word::CShading& Shd); void WritePaddings(const nullable& left, const nullable& top, const nullable& right, const nullable& bottom); - void WriteFont(std::wstring sFontName, BYTE bType, DocWrapper::FontProcessor& m_oFontProcessor); + void WriteFont(std::wstring& sFontName, BYTE bType, DocWrapper::FontProcessor& m_oFontProcessor); void WriteBytesArray(BYTE* pData, long nDataSize); template void WriteTrackRevision(const T& elem); }; @@ -567,4 +567,4 @@ namespace BinDocxRW void ParagraphAddBreak(OOX::Logic::CParagraph* pParagraph); }; -} +} \ No newline at end of file diff --git a/ASCOfficeDocxFile2/DocWrapper/DocxSerializer.cpp b/ASCOfficeDocxFile2/DocWrapper/DocxSerializer.cpp index 26aa14b895..edf2ebad62 100644 --- a/ASCOfficeDocxFile2/DocWrapper/DocxSerializer.cpp +++ b/ASCOfficeDocxFile2/DocWrapper/DocxSerializer.cpp @@ -182,6 +182,7 @@ BinDocxRW::CDocxSerializer::CDocxSerializer() m_bIsNoBase64Save = false; m_bIsNoBase64 = false; + m_bSaveChartAsImg = false; } BinDocxRW::CDocxSerializer::~CDocxSerializer() { @@ -406,7 +407,7 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const std::wstring& sSrcFileName, oDrawingConverter.SetMediaDstPath(sMediaPath); oDrawingConverter.SetEmbedDstPath(sEmbedPath); - m_pCurFileWriter = new Writers::FileWriter(sDstPath, m_sFontDir, false, nVersion, &oDrawingConverter, sThemePath); + m_pCurFileWriter = new Writers::FileWriter(sDstPath, m_sFontDir, false, nVersion, m_bSaveChartAsImg, &oDrawingConverter, sThemePath); //папка с картинками std::wstring strFileInDir = NSSystemPath::GetDirectoryName(sSrcFileName); @@ -599,6 +600,11 @@ void BinDocxRW::CDocxSerializer::setIsNoBase64(bool bIsNoBase64) { m_bIsNoBase64 = bIsNoBase64; } +void BinDocxRW::CDocxSerializer::setSaveChartAsImg(bool bSaveChartAsImg) +{ + m_bSaveChartAsImg = bSaveChartAsImg; +} + bool BinDocxRW::CDocxSerializer::unpackageFile(const std::wstring& sSrcFileName, const std::wstring& sDstPath) { BinDocxRW::CPackageFile file; diff --git a/ASCOfficeDocxFile2/DocWrapper/DocxSerializer.h b/ASCOfficeDocxFile2/DocWrapper/DocxSerializer.h index 6e23918656..aed6ad8feb 100644 --- a/ASCOfficeDocxFile2/DocWrapper/DocxSerializer.h +++ b/ASCOfficeDocxFile2/DocWrapper/DocxSerializer.h @@ -54,6 +54,7 @@ namespace BinDocxRW std::wstring m_sEmbeddedFontsDir; bool m_bIsNoBase64Save; bool m_bIsNoBase64; + bool m_bSaveChartAsImg; ParamsWriter* m_pParamsWriter; Writers::FileWriter* m_pCurFileWriter; diff --git a/ASCOfficeDocxFile2/DocWrapper/XlsxSerializer.cpp b/ASCOfficeDocxFile2/DocWrapper/XlsxSerializer.cpp index 1b0d5c0c68..dc35c4db4d 100644 --- a/ASCOfficeDocxFile2/DocWrapper/XlsxSerializer.cpp +++ b/ASCOfficeDocxFile2/DocWrapper/XlsxSerializer.cpp @@ -141,61 +141,59 @@ namespace BinXlsxRW{ RELEASEOBJECT(pFontPicker); return result; } - bool CXlsxSerializer::saveChart(NSBinPptxRW::CBinaryFileReader* pReader, long lLength, NSCommon::smart_ptr &file, const int& nChartNumber) + bool CXlsxSerializer::saveChart(NSBinPptxRW::CBinaryFileReader* pReader, long lLength, const std::wstring& sFilepath, const long& lChartNumber) { if (NULL == pReader) return false; if (NULL == m_pExternalDrawingConverter) return false; - - if (false == file.IsInit()) return false; + bool bRes = false; m_pExternalDrawingConverter->SetDstContentRels(); + //получаем sThemePath из bsFilename предполагая что папка theme находится на уровень выше bsFilename + std::wstring sDrawingsPath; + std::wstring sThemePath; + std::wstring sEmbedingPath; std::wstring sContentTypePath; + size_t nIndex = (int)sFilepath.rfind(FILE_SEPARATOR_CHAR); + nIndex = (int)sFilepath.rfind(FILE_SEPARATOR_CHAR, nIndex - 1); + + if(std::wstring::npos != nIndex) + { + std::wstring sFilepathLeft = sFilepath.substr(0, nIndex + 1); + + sThemePath = sFilepathLeft + L"theme"; + sEmbedingPath = sFilepathLeft + L"embeddings"; + sDrawingsPath = sFilepathLeft + L"drawings"; + } if (pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX || pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) sContentTypePath = L"/word/charts/"; else if (pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_XLSX) sContentTypePath = L"/xl/charts/"; else sContentTypePath = L"/ppt/charts/"; - std::wstring sChartPath = pReader->m_pRels->m_pManager->GetDstCharts(); - size_t nIndex = sChartPath.rfind(FILE_SEPARATOR_CHAR); - - std::wstring sFilePathDocument = sChartPath; - if (std::wstring::npos != nIndex) - { - sFilePathDocument = sFilePathDocument.substr(0, nIndex + 1); - } - std::wstring sDrawingsPath = sFilePathDocument + L"drawings"; - std::wstring sThemePath = sFilePathDocument + L"theme"; - std::wstring sEmbedingPath = sFilePathDocument + L"embeddings"; - - std::wstring sFileName; - - BinXlsxRW::SaveParams oSaveParams(sDrawingsPath, sEmbedingPath, sThemePath, m_pExternalDrawingConverter->GetContentTypes()); + //todo theme path + BinXlsxRW::SaveParams oSaveParams(sDrawingsPath, sThemePath, m_pExternalDrawingConverter->GetContentTypes()); + OOX::Spreadsheet::CChartSpace oChartSpace(NULL); BinXlsxRW::BinaryChartReader oBinaryChartReader(*pReader, oSaveParams, m_pExternalDrawingConverter); - bool bResult = false; - - int nDocumentTypeOwner = pReader->m_pRels->m_pManager->m_nDocumentType; - pReader->m_pRels->m_pManager->m_nDocumentType = XMLWRITER_DOC_TYPE_XLSX; - - NSCommon::smart_ptr chart_file = file.smart_dynamic_cast(); - if (chart_file.IsInit()) + try { - sFileName = L"chart" + std::to_wstring(nChartNumber) + L".xml"; - - bResult = (0 == oBinaryChartReader.ReadCT_ChartFile(lLength, chart_file.GetPointer())); + oBinaryChartReader.ReadCT_ChartSpace(lLength, &oChartSpace); + } + catch(...) + { + //todooo + } - bool bXlsxPresent = (chart_file->m_oChartSpace.m_externalData) && (chart_file->m_oChartSpace.m_externalData->m_id); - - if (bResult && pReader->m_nDocumentType != XMLWRITER_DOC_TYPE_XLSX && !sEmbedingPath.empty() && !bXlsxPresent) + if(oChartSpace.isValid()) + { + //save xlsx embedded for chart + if(pReader->m_nDocumentType != XMLWRITER_DOC_TYPE_XLSX && !sEmbedingPath.empty()) { - std::wstring sXlsxFilename = L"Microsoft_Excel_Worksheet" + std::to_wstring(pReader->m_nCountEmbedded) + L".xlsx"; + std::wstring sXlsxFilename = L"Microsoft_Excel_Worksheet" + std::to_wstring(lChartNumber) + L".xlsx"; std::wstring sXlsxPath = sEmbedingPath + FILE_SEPARATOR_STR + sXlsxFilename; - - pReader->m_nCountEmbedded++; - - if (writeChartXlsx(sXlsxPath, file)) + + if (writeChartXlsx(sXlsxPath, oChartSpace)) { pReader->m_pRels->m_pManager->m_pContentTypes->AddDefault(L"xlsx"); @@ -204,48 +202,31 @@ namespace BinXlsxRW{ std::wstring bstrChartsWorksheetRelType = OOX::FileTypes::MicrosoftOfficeExcelWorksheet.RelationType(); m_pExternalDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, std::wstring(), &rId); - chart_file->m_oChartSpace.m_externalData = new OOX::Spreadsheet::CT_ExternalData(); - chart_file->m_oChartSpace.m_externalData->m_id = new std::wstring(); - chart_file->m_oChartSpace.m_externalData->m_id->append(L"rId"); - chart_file->m_oChartSpace.m_externalData->m_id->append(std::to_wstring(rId)); - chart_file->m_oChartSpace.m_externalData->m_autoUpdate = new OOX::Spreadsheet::CT_Boolean(); - chart_file->m_oChartSpace.m_externalData->m_autoUpdate->m_val = new bool(false); + oChartSpace.m_oChartSpace.m_externalData = new OOX::Spreadsheet::CT_ExternalData(); + oChartSpace.m_oChartSpace.m_externalData->m_id = new std::wstring(); + oChartSpace.m_oChartSpace.m_externalData->m_id->append(L"rId"); + oChartSpace.m_oChartSpace.m_externalData->m_id->append(std::to_wstring(rId)); + oChartSpace.m_oChartSpace.m_externalData->m_autoUpdate = new OOX::Spreadsheet::CT_Boolean(); + oChartSpace.m_oChartSpace.m_externalData->m_autoUpdate->m_val = new bool(false); } } - } - else - { - NSCommon::smart_ptr chartEx_file = file.smart_dynamic_cast(); - if (chartEx_file.IsInit()) - { - sFileName = L"chartEx" + std::to_wstring(nChartNumber) + L".xml"; - bResult = (0 == oBinaryChartReader.ReadCT_ChartExFile(lLength, chartEx_file.GetPointer())); - - bool bXlsxPresent = (chartEx_file->m_oChartSpace.m_chartData.m_externalData.IsInit()) && - (chartEx_file->m_oChartSpace.m_chartData.m_externalData->m_id.IsInit()); - } - } - pReader->m_pRels->m_pManager->m_nDocumentType = nDocumentTypeOwner; - - if(bResult) - { - if (pReader->m_nDocumentType != XMLWRITER_DOC_TYPE_DOCX && pReader->m_nDocumentType != XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) - { - file->m_sOutputFilename = L"../"; - } - file->m_sOutputFilename += L"charts/" + sFileName; - - std::wstring sFilePath = sChartPath + FILE_SEPARATOR_STR + sFileName; - file->write(sFilePath, sContentTypePath, *pReader->m_pRels->m_pManager->m_pContentTypes); - - OOX::CPath pathRelsDir = sChartPath + FILE_SEPARATOR_STR + _T("_rels"); + std::wstring strFilepath = sFilepath; + std::wstring strDir = NSSystemPath::GetDirectoryName(strFilepath); + std::wstring strFilename = NSSystemPath::GetFileName(strFilepath); + + OOX::CPath pathRelsDir = strDir + FILE_SEPARATOR_STR + _T("_rels"); + OOX::CSystemUtility::CreateDirectories(pathRelsDir.GetPath()); - OOX::CPath pathRelsFile = pathRelsDir + FILE_SEPARATOR_STR + NSSystemPath::GetFileName(sFilePath) + _T(".rels"); + oChartSpace.write(sFilepath, sContentTypePath, *pReader->m_pRels->m_pManager->m_pContentTypes); + + OOX::CPath pathRelsFile = pathRelsDir + FILE_SEPARATOR_STR + strFilename + _T(".rels"); m_pExternalDrawingConverter->SaveDstContentRels(pathRelsFile.GetPath()); + + bRes = true; } - return bResult; + return bRes; } void CXlsxSerializer::setFontDir(const std::wstring& sFontDir) { @@ -264,14 +245,11 @@ namespace BinXlsxRW{ m_bIsNoBase64 = bIsNoBase64; } - bool CXlsxSerializer::writeChartXlsx(const std::wstring& sDstFile, NSCommon::smart_ptr &file) + bool CXlsxSerializer::writeChartXlsx(const std::wstring& sDstFile, const OOX::Spreadsheet::CChartSpace& oChart) { - NSCommon::smart_ptr oChart = file.smart_dynamic_cast(); - - if (oChart.IsInit() == false) return false; //анализируем chart BinXlsxRW::ChartWriter helper; - helper.parseChart(oChart->m_oChartSpace.m_chart); + helper.parseChart(oChart.m_oChartSpace.m_chart); //создаем temp std::wstring sTempDir = NSSystemPath::GetDirectoryName(sDstFile) + FILE_SEPARATOR_STR + NSSystemPath::GetFileName(sDstFile) + L"_TEMP"; NSDirectory::CreateDirectory(sTempDir); diff --git a/ASCOfficeDocxFile2/DocWrapper/XlsxSerializer.h b/ASCOfficeDocxFile2/DocWrapper/XlsxSerializer.h index cac472a805..caf16fb5e6 100644 --- a/ASCOfficeDocxFile2/DocWrapper/XlsxSerializer.h +++ b/ASCOfficeDocxFile2/DocWrapper/XlsxSerializer.h @@ -29,15 +29,18 @@ * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode * */ -#pragma once +#ifndef XLSX_SERIALIZER +#define XLSX_SERIALIZER #include #include "../../Common/DocxFormat/Source/Base/Types_32.h" -#include "../../Common/DocxFormat/Source/Base/SmartPtr.h" namespace OOX { - class File; +namespace Spreadsheet +{ +class CChartSpace; +} } namespace NSBinPptxRW{ class CDrawingConverter; @@ -48,8 +51,7 @@ namespace NSBinPptxRW{ } namespace BinXlsxRW { - class CXlsxSerializer - { + class CXlsxSerializer{ private: std::wstring m_sFontDir; std::wstring m_sEmbeddedFontsDir; @@ -64,14 +66,15 @@ namespace BinXlsxRW { _UINT32 loadFromFile (const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions, const std::wstring& sMediaDir, const std::wstring& sEmbedPath); _UINT32 saveToFile (const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions); - bool saveChart (NSBinPptxRW::CBinaryFileReader* pReader, long lLength, NSCommon::smart_ptr &file, const int& nChartNumber); + bool saveChart (NSBinPptxRW::CBinaryFileReader* pReader, long lLength, const std::wstring& sFilename, const long& lChartNumber); void setFontDir (const std::wstring& sFontDir); void setEmbeddedFontsDir(const std::wstring& sEmbeddedFontsDir); void setDrawingConverter(NSBinPptxRW::CDrawingConverter* pDrawingConverter); void setIsNoBase64 (bool bIsNoBase64); - bool writeChartXlsx (const std::wstring& sDstFile, NSCommon::smart_ptr &file); + bool writeChartXlsx (const std::wstring& sDstFile ,const OOX::Spreadsheet::CChartSpace& oChart); bool hasPivot (const std::wstring& sSrcPath); }; } +#endif // #ifndef XLSX_SERIALIZER diff --git a/ASCOfficeOdfFile/linux/OdfFileReaderLib.pro b/ASCOfficeOdfFile/linux/OdfFileReaderLib.pro index e5168ec1c0..7073286dea 100644 --- a/ASCOfficeOdfFile/linux/OdfFileReaderLib.pro +++ b/ASCOfficeOdfFile/linux/OdfFileReaderLib.pro @@ -220,7 +220,6 @@ SOURCES += \ ../src/odf/datatypes/styleprint.cpp \ ../src/odf/datatypes/charttimeunit.cpp \ ../src/odf/datatypes/drawangle.cpp \ - ../src/odf/datatypes/messagetype.cpp \ ../src/docx/xlsx_conditionalFormatting.cpp \ ../src/docx/xlsx_dxfs.cpp \ ../src/docx/docx_content_type.cpp \ @@ -484,7 +483,6 @@ HEADERS += \ ../src/odf/datatypes/styleprint.h \ ../src/odf/datatypes/drawangle.h \ ../src/odf/datatypes/charttimeunit.h \ - ../src/odf/datatypes/messagetype.h \ ../src/docx/docx_content_type.h \ ../src/docx/docx_conversion_context.h \ ../src/docx/docx_conversion_state.h \ diff --git a/ASCOfficeOdfFile/linux/odffilereaderlib_odf_datatypes.cpp b/ASCOfficeOdfFile/linux/odffilereaderlib_odf_datatypes.cpp index e6dc1e45f4..c21cd18101 100644 --- a/ASCOfficeOdfFile/linux/odffilereaderlib_odf_datatypes.cpp +++ b/ASCOfficeOdfFile/linux/odffilereaderlib_odf_datatypes.cpp @@ -134,4 +134,3 @@ #include "../src/odf/datatypes/styleprint.cpp" #include "../src/odf/datatypes/charttimeunit.cpp" #include "../src/odf/datatypes/drawangle.cpp" -#include "../src/odf/datatypes/messagetype.cpp"" diff --git a/ASCOfficeOdfFile/src/docx/docx_conversion_context.cpp b/ASCOfficeOdfFile/src/docx/docx_conversion_context.cpp index d7eb8123be..da43cc66c8 100644 --- a/ASCOfficeOdfFile/src/docx/docx_conversion_context.cpp +++ b/ASCOfficeOdfFile/src/docx/docx_conversion_context.cpp @@ -921,8 +921,14 @@ namespace } else { - bDisplayed = false; - return std::wstring(L"DStyle_") + boost::lexical_cast(odf_types::style_family(Type) ); + switch(Type) + { + case odf_types::style_family::Paragraph: + return L"Normal"; + default: + bDisplayed = false; + return std::wstring(L"DStyle_") + boost::lexical_cast(odf_types::style_family( Type) ); + } } } } @@ -1126,22 +1132,15 @@ void docx_conversion_context::process_styles() arStyles[i]->type() == odf_types::style_family::Text)) { const std::wstring id = styles_map_.get(arStyles[i]->name(), arStyles[i]->type()); - bool bDefault = (arStyles[i]->style_class() == L"default"); - bool bDisplayed = (arStyles[i]->type() == odf_types::style_family::Paragraph); - - _Wostream << L"type()) << L"\""; - - if (bDefault) // style - { - _Wostream << L" w:default=\"1\""; - } - else if (!arStyles[i]->is_default()) // default-style + _Wostream << L"type()) << L"\""; + if (!arStyles[i]->is_default()) { _Wostream << L" w:customStyle=\"1\""; } _Wostream << L">"; - - const std::wstring displayName = StyleDisplayName(arStyles[i]->name(), arStyles[i]->display_name(), arStyles[i]->type(), bDisplayed); + + bool bDisplayed = (arStyles[i]->type() == odf_types::style_family::Paragraph); + const std::wstring displayName = StyleDisplayName(arStyles[i]->name(), arStyles[i]->display_name(), arStyles[i]->type(), bDisplayed); _Wostream << L""; @@ -1150,27 +1149,27 @@ void docx_conversion_context::process_styles() const std::wstring basedOnId = styles_map_.get(baseOn->name(), baseOn->type()); _Wostream << L""; } - // else if (false == bDefault && false == arStyles[i]->is_default() && styles_map_.check(L"", arStyles[i]->type())) - // { - //bDisplayed = false; - // const std::wstring basedOnId = styles_map_.get(L"", arStyles[i]->type()); - // _Wostream << L""; - // } + else if (false == arStyles[i]->is_default() && styles_map_.check(L"", arStyles[i]->type())) + { + bDisplayed = false; + const std::wstring basedOnId = styles_map_.get(L"", arStyles[i]->type()); + _Wostream << L""; + } if (bDisplayed) { _Wostream << L""; } - if (odf_reader::style_instance * next = arStyles[i]->next()) - { - const std::wstring nextId = styles_map_.get(next->name(), next->type()); - _Wostream << L""; - } - //else if (arStyles[i]->is_default()) - //{ - // // self - // _Wostream << L""; - //} + if (odf_reader::style_instance * next = arStyles[i]->next()) + { + const std::wstring nextId = styles_map_.get(next->name(), next->type()); + _Wostream << L""; + } + else if (arStyles[i]->is_default()) + { + // self + _Wostream << L""; + } if (odf_reader::style_content * content = arStyles[i]->content()) { @@ -1625,12 +1624,9 @@ int docx_conversion_context::process_text_attr(odf_reader::text::paragraph_attrs push_text_properties(styleContent->get_style_text_properties()); return 1; } -int docx_conversion_context::process_paragraph_style(_CP_OPT(std::wstring) style_name_ptr) +int docx_conversion_context::process_paragraph_style(const std::wstring & style_name) { - if (!style_name_ptr) return 0; - if (style_name_ptr->empty()) return 0; - - std::wstring & style_name = *style_name_ptr; + if (style_name.empty()) return 0; if (odf_reader::style_instance * styleInst = root()->odf_context().styleContainer().style_by_name(style_name, odf_types::style_family::Paragraph, process_headers_footers_)) diff --git a/ASCOfficeOdfFile/src/docx/docx_conversion_context.h b/ASCOfficeOdfFile/src/docx/docx_conversion_context.h index ec9e2495b1..ccab83cc29 100644 --- a/ASCOfficeOdfFile/src/docx/docx_conversion_context.h +++ b/ASCOfficeOdfFile/src/docx/docx_conversion_context.h @@ -833,7 +833,7 @@ public: bool process_page_properties(std::wostream & strm); void process_section (std::wostream & strm, odf_reader::style_columns * columns = NULL); - int process_paragraph_style (_CP_OPT(std::wstring) style_name_ptr); + int process_paragraph_style (const std::wstring & style_name); int process_paragraph_attr (odf_reader::text::paragraph_attrs *attr); int process_text_attr (odf_reader::text::paragraph_attrs *Attr); void process_page_break_after(const odf_reader::style_instance *styleInst); @@ -931,16 +931,7 @@ public: void start_paragraph_style(const std::wstring& style_name) {paragraph_style_stack_.push_back(style_name);} void end_paragraph_style() { if (!paragraph_style_stack_.empty()) paragraph_style_stack_.pop_back();} - - _CP_OPT(std::wstring) get_current_paragraph_style() - { - _CP_OPT(std::wstring) result; - if (false == paragraph_style_stack_.empty()) - - result = paragraph_style_stack_.back(); - - return result; - } + std::wstring get_current_paragraph_style() {return paragraph_style_stack_.empty() ? L"" : paragraph_style_stack_.back();} oox_chart_context & current_chart(); void start_chart(std::wstring name); diff --git a/ASCOfficeOdfFile/src/docx/oox_chart_axis.cpp b/ASCOfficeOdfFile/src/docx/oox_chart_axis.cpp index 38f7f76418..c651334f84 100644 --- a/ASCOfficeOdfFile/src/docx/oox_chart_axis.cpp +++ b/ASCOfficeOdfFile/src/docx/oox_chart_axis.cpp @@ -41,12 +41,12 @@ namespace cpdoccore { namespace oox { -_CP_PTR(oox_axis_content) oox_axis_content::create(int type, unsigned int id) +_CP_PTR(oox_axis_content) oox_axis_content::create(int type) { - return boost::make_shared(type, id); + return boost::make_shared(type); } -oox_axis_content::oox_axis_content(int type/*,std::wstring name*/, unsigned int id) +oox_axis_content::oox_axis_content(int type/*,std::wstring name*/) { if (type == 0) { @@ -54,13 +54,13 @@ oox_axis_content::oox_axis_content(int type/*,std::wstring name*/, unsigned int } else { - id_ = id; + id_ = abs((long)this); } type_ = type; } void oox_axis_content::oox_serialize(std::wostream & _Wostream) { - if (id_ < 1 ) return; //not activate, blank axis + if (id_ < 1 )return; //not activate, blank axis CP_XML_WRITER(_Wostream) { diff --git a/ASCOfficeOdfFile/src/docx/oox_chart_axis.h b/ASCOfficeOdfFile/src/docx/oox_chart_axis.h index dda0b56af4..c93fe1c4e4 100644 --- a/ASCOfficeOdfFile/src/docx/oox_chart_axis.h +++ b/ASCOfficeOdfFile/src/docx/oox_chart_axis.h @@ -50,10 +50,10 @@ class oox_axis_content public: odf_reader::chart::oox_typeconvert oox_typeconvert_; - oox_axis_content(int type/*,std::wstring name*/, unsigned int id); + oox_axis_content(int type/*,std::wstring name*/); ~oox_axis_content(){} - static oox_axis_content_ptr create(int type/*,std::wstring name*/, unsigned int id); + static oox_axis_content_ptr create(int type/*,std::wstring name*/); void oox_serialize(std::wostream & _Wostream); void oox_serialize_content(std::wostream & _Wostream); @@ -61,7 +61,7 @@ public: int get_Id(){return id_;} void add_CrossedId (int id){cross_id_.push_back( id);} - unsigned int id_; + int id_; std::vector cross_id_; odf_reader::chart::axis content_; diff --git a/ASCOfficeOdfFile/src/docx/oox_drawing.cpp b/ASCOfficeOdfFile/src/docx/oox_drawing.cpp index 697c9ba9d1..0fedfc7ce1 100644 --- a/ASCOfficeOdfFile/src/docx/oox_drawing.cpp +++ b/ASCOfficeOdfFile/src/docx/oox_drawing.cpp @@ -193,7 +193,7 @@ void oox_serialize_effects(std::wostream & strm, const std::vector _CP_OPT(int) w, h; - _CP_OPT(bool) stroke; odf_reader::GetProperty(additional, L"custom_path_w", w); odf_reader::GetProperty(additional, L"custom_path_h", h); - - odf_reader::GetProperty(additional, L"custom_path_s", stroke); CP_XML_NODE(L"a:pathLst") @@ -643,11 +640,6 @@ void _oox_drawing::serialize_shape(std::wostream & strm) CP_XML_ATTR(L"w", path_w); CP_XML_ATTR(L"h", path_h); - - if (stroke) - { - CP_XML_ATTR(L"stroke", *stroke ? 1 : 0); - } if (sCustomPath) { diff --git a/ASCOfficeOdfFile/src/docx/oox_plot_area.cpp b/ASCOfficeOdfFile/src/docx/oox_plot_area.cpp index 72b42ee441..2ff23e9717 100644 --- a/ASCOfficeOdfFile/src/docx/oox_plot_area.cpp +++ b/ASCOfficeOdfFile/src/docx/oox_plot_area.cpp @@ -32,7 +32,6 @@ #include "oox_plot_area.h" -#include #include #include #include @@ -44,14 +43,6 @@ namespace cpdoccore { namespace oox { - oox_plot_area::oox_plot_area() : no_used_local_tables_(false) - { - std::random_device rd; - std::mt19937 gen(rd()); - std::uniform_int_distribution<> distrib(1001, 9999); - - axis_id_ += distrib(gen); - } void oox_plot_area::add_chart(int type) { @@ -101,8 +92,7 @@ namespace cpdoccore { void oox_plot_area::add_axis(int type, odf_reader::chart::axis & content) { - unsigned int id = axis_id_++; - oox_axis_content_ptr ax = oox_axis_content::create(type, id); + oox_axis_content_ptr ax = oox_axis_content::create(type); ax->content_ = content; axis_.push_back(ax); diff --git a/ASCOfficeOdfFile/src/docx/oox_plot_area.h b/ASCOfficeOdfFile/src/docx/oox_plot_area.h index d148563ff2..be83dc5762 100644 --- a/ASCOfficeOdfFile/src/docx/oox_plot_area.h +++ b/ASCOfficeOdfFile/src/docx/oox_plot_area.h @@ -45,7 +45,7 @@ namespace oox { class oox_plot_area: boost::noncopyable { public: - oox_plot_area(); + oox_plot_area() : no_used_local_tables_(false) {} ~oox_plot_area(){} std::vector charts_; @@ -72,8 +72,6 @@ private: void reset_cross_axis(); //обязательно после всех добавлений bool no_used_local_tables_; - unsigned int axis_id_ = 0xf2905; - }; } diff --git a/ASCOfficeOdfFile/src/docx/pptx_default_serializes.h b/ASCOfficeOdfFile/src/docx/pptx_default_serializes.h index bf1ef963c3..3a31dd23db 100644 --- a/ASCOfficeOdfFile/src/docx/pptx_default_serializes.h +++ b/ASCOfficeOdfFile/src/docx/pptx_default_serializes.h @@ -255,7 +255,7 @@ namespace oox { CP_XML_NODE(L"a:srgbClr") { CP_XML_ATTR(L"val",L"000000"); - CP_XML_NODE(L"a:alpha"){CP_XML_ATTR(L"val", 38000);} + CP_XML_NODE(L"a:alpha"){CP_XML_ATTR(L"val",38000);} } } } @@ -273,7 +273,7 @@ namespace oox { CP_XML_NODE(L"a:srgbClr") { CP_XML_ATTR(L"val",L"000000"); - CP_XML_NODE(L"a:alpha"){CP_XML_ATTR(L"val", 35000);} + CP_XML_NODE(L"a:alpha"){CP_XML_ATTR(L"val",35000);} } } } @@ -291,7 +291,7 @@ namespace oox { CP_XML_NODE(L"a:srgbClr") { CP_XML_ATTR(L"val",L"000000"); - CP_XML_NODE(L"a:alpha"){CP_XML_ATTR(L"val", 35000);} + CP_XML_NODE(L"a:alpha"){CP_XML_ATTR(L"val",35000);} } } } diff --git a/ASCOfficeOdfFile/src/docx/xlsx_data_validation.cpp b/ASCOfficeOdfFile/src/docx/xlsx_data_validation.cpp index afd3c8fbd0..fe8151d158 100644 --- a/ASCOfficeOdfFile/src/docx/xlsx_data_validation.cpp +++ b/ASCOfficeOdfFile/src/docx/xlsx_data_validation.cpp @@ -38,8 +38,6 @@ #include #include -#include -#include #include "../formulasconvert/formulasconvert.h" #include "../../../Common/DocxFormat/Source/XML/Utils.h" @@ -70,8 +68,6 @@ struct xlsx_dataValidation std::wstring promt_title; std::wstring activate_ref; - - int error_type = 0;//stop }; typedef shared_ptr::Type xlsx_dataValidation_ptr; @@ -255,14 +251,6 @@ public: { CP_XML_ATTR(L"error", it->second->error_text); } - switch (it->second->error_type) - { - case 1: CP_XML_ATTR(L"errorStyle", L"warning"); break; - case 2: CP_XML_ATTR(L"errorStyle", L"information"); break; - case 0: - default: - CP_XML_ATTR(L"errorStyle", L"stop"); break; - } if (!it->second->promt_title.empty()) { CP_XML_ATTR(L"promptTitle", it->second->promt_title); @@ -392,7 +380,7 @@ void xlsx_dataValidations_context::add_help_msg(const std::wstring & name, const pFind->second->promt_text = content; } -void xlsx_dataValidations_context::add_error_msg(const std::wstring & name, const std::wstring & title, const std::wstring & content, bool display, int type) +void xlsx_dataValidations_context::add_error_msg(const std::wstring & name, const std::wstring & title, const std::wstring & content, bool display) { std::map::iterator pFind = impl_->mapDataValidations.find(name); @@ -401,56 +389,49 @@ void xlsx_dataValidations_context::add_error_msg(const std::wstring & name, cons pFind->second->showErrorMessage = display; pFind->second->error_title = title; pFind->second->error_text = content; - pFind->second->error_type = type; } -void xlsx_dataValidations_context::add_formula(const std::wstring & name, const std::wstring & formula) +void xlsx_dataValidations_context::add_formula(const std::wstring & name, const std::wstring & f) // todooo пооптимальней { std::map::iterator pFind = impl_->mapDataValidations.find(name); if (pFind == impl_->mapDataValidations.end()) return; formulasconvert::odf2oox_converter converter; - - std::vector arrFormula; - boost::algorithm::split_regex(arrFormula, formula, boost::wregex(L"and")); - - std::wstring val, val2, operator_; - - for (size_t i = 0; i < arrFormula.size(); ++i) + size_t pos; + std::wstring val, val2; + + if ( std::wstring::npos != (pos = f.find(L"cell-content-is-in-list"))) //oooc: , of: { - std::wstring & f = arrFormula[i]; - size_t pos; - - if (std::wstring::npos != (pos = f.find(L"cell-content-is-in-list"))) //oooc: , of: + pFind->second->type = L"list"; + val = f.substr(24 + pos, f.size() - 25 - pos); + + if ( val.substr(0, 1) == L"\"") { - pFind->second->type = L"list"; - val = f.substr(24 + pos, f.size() - 25 - pos); + std::wstring keep = val; + XmlUtils::replace_all(val, L"\"", L""); + + pFind->second->formula1 = converter.convert(val); - if (val.substr(0, 1) == L"\"") + if ( (std::wstring::npos != val.find(L";")) || //convert formula replacing ; on , + L"\"" + pFind->second->formula1 + L"\"" == keep) { - std::wstring keep = val; - XmlUtils::replace_all(val, L"\"", L""); - - pFind->second->formula1 = converter.convert(val); - - if ((std::wstring::npos != val.find(L";")) || //convert formula replacing ; on , - L"\"" + pFind->second->formula1 + L"\"" == keep) - { - pFind->second->formula1 = L"\"" + pFind->second->formula1 + L"\""; - } - } - else - { - pFind->second->formula1 = converter.convert(val); + pFind->second->formula1 = L"\"" + pFind->second->formula1 + L"\""; } } - else if (std::wstring::npos != (pos = f.find(L"is-true-formula"))) + else { - pFind->second->type = L"custom"; - val = f.substr(16 + pos, f.size() - 17 - pos); pFind->second->formula1 = converter.convert(val); } - else if (std::wstring::npos != (pos = f.find(L"cell-content-is-date"))) + } + else if ( std::wstring::npos != (pos = f.find(L"is-true-formula"))) + { + pFind->second->type = L"custom"; + val = f.substr(16 + pos, f.size() - 17 - pos); + pFind->second->formula1 = converter.convert(val); + } + else + { + if (std::wstring::npos != (pos = f.find(L"cell-content-is-date"))) { pFind->second->type = L"date"; } @@ -466,78 +447,81 @@ void xlsx_dataValidations_context::add_formula(const std::wstring & name, const { pFind->second->type = L"whole"; } - else if (std::wstring::npos != (pos = f.find(L"cell-content-text-length"))) + + if (std::wstring::npos != (pos = f.find(L"cell-content()=="))) { - pFind->second->type = L"textLength"; - operator_ = f.substr(pos + 24); - } - else if (std::wstring::npos != (pos = f.find(L"cell-content"))) - { - operator_ = f.substr(pos + 12); - } - } - if (false == operator_.empty()) - { - size_t pos; - if (std::wstring::npos != (pos = operator_.find(L"-is-not-between("))) - { - pFind->second->operator_ = L"notBetween"; + pFind->second->operator_ = L"equal"; + + size_t pos2 = f.find(L"and", pos + 16); + if (pos2 == std::wstring::npos) pos2 = f.length(); - size_t pos2 = operator_.find(L",", pos + 15); - size_t pos3 = operator_.rfind(L")"); - - val = operator_.substr(pos + 15, pos2 - pos - 15); - val2 = operator_.substr(pos2 + 1, pos3 - pos2 - 1); + val = f.substr(pos + 16, pos2 - pos - 16); } - else if (std::wstring::npos != (pos = operator_.find(L"-is-between("))) + else if (std::wstring::npos != (pos = f.find(L"cell-content()<>"))) + { + pFind->second->operator_ = L"notEqual"; + + size_t pos2 = f.find(L"and", pos + 16); + if (pos2 == std::wstring::npos) pos2 = f.length(); + + val = f.substr(pos + 16, pos2 - pos - 16); + } + else if (std::wstring::npos != (pos = f.find(L"cell-content()<="))) + { + pFind->second->operator_ = L"lessThanOrEqual"; + + size_t pos2 = f.find(L"and", pos + 16); + if (pos2 == std::wstring::npos) pos2 = f.length(); + + val = f.substr(pos + 16, pos2 - pos - 16); + } + else if (std::wstring::npos != (pos = f.find(L"cell-content()<"))) + { + pFind->second->operator_ = L"lessThan"; + + size_t pos2 = f.find(L"and", pos + 15); + if (pos2 == std::wstring::npos) pos2 = f.length(); + + val = f.substr(pos + 15, pos2 - pos - 15); + } + else if (std::wstring::npos != (pos = f.find(L"cell-content()>="))) + { + pFind->second->operator_ = L"greaterThanOrEqual"; + + size_t pos2 = f.find(L"and", pos + 16); + if (pos2 == std::wstring::npos) pos2 = f.length(); + + val = f.substr(pos + 16, pos2 - pos - 16); + } + else if (std::wstring::npos != (pos = f.find(L"cell-content()>"))) + { + pFind->second->operator_ = L"greaterThan"; + + size_t pos2 = f.find(L"and", pos + 15); + if (pos2 == std::wstring::npos) pos2 = f.length(); + + val = f.substr(pos + 15, pos2 - pos - 15); + } + else if (std::wstring::npos != (pos = f.find(L"cell-content-is-not-between("))) + { + pFind->second->operator_ = L"greaterThanOrEqual"; + + size_t pos2 = f.find(L",", pos + 27); + size_t pos3 = f.rfind(L")"); + + val = f.substr(pos + 27, pos2 - pos - 27); + val2 = f.substr(pos2 + 1, pos3 - pos2 - 1); + } + else if (std::wstring::npos != (pos = f.find(L"cell-content-is-between("))) { pFind->second->operator_ = L"between"; - size_t pos2 = operator_.find(L",", pos + 12); - size_t pos3 = operator_.rfind(L")"); - - val = operator_.substr(pos + 12, pos2 - pos - 12); - val2 = operator_.substr(pos2 + 1, pos3 - pos2 - 1); + size_t pos2 = f.find(L",", pos + 24); + size_t pos3 = f.rfind(L")"); + + val = f.substr(pos + 24, pos2 - pos - 24); + val2 = f.substr(pos2 + 1, pos3 - pos2 - 1); } - else - { - size_t split = std::wstring::npos; - if (std::wstring::npos != (pos = operator_.find(L"()=="))) - { - pFind->second->operator_ = L"equal"; - split = 4; - } - else if (std::wstring::npos != (pos = operator_.find(L"()!="))) - { - pFind->second->operator_ = L"notEqual"; - split = 4; - } - else if (std::wstring::npos != (pos = operator_.find(L"()<="))) - { - pFind->second->operator_ = L"lessThanOrEqual"; - split = 4; - } - else if (std::wstring::npos != (pos = operator_.find(L"()<"))) - { - pFind->second->operator_ = L"lessThan"; - split = 3; - } - else if (std::wstring::npos != (pos = operator_.find(L"()>="))) - { - pFind->second->operator_ = L"greaterThanOrEqual"; - split = 4; - } - else if (std::wstring::npos != (pos = operator_.find(L"()>"))) - { - pFind->second->operator_ = L"greaterThan"; - split = 3; - } - if (split != std::wstring::npos) - { - val = operator_.substr(pos + split, operator_.length() - pos - split); - } - } - pFind->second->formula1 = converter.convert(val); pFind->second->formula2 = converter.convert(val2); } diff --git a/ASCOfficeOdfFile/src/docx/xlsx_data_validation.h b/ASCOfficeOdfFile/src/docx/xlsx_data_validation.h index e43e61cf88..9d9783f047 100644 --- a/ASCOfficeOdfFile/src/docx/xlsx_data_validation.h +++ b/ASCOfficeOdfFile/src/docx/xlsx_data_validation.h @@ -47,7 +47,7 @@ public: void add(const std::wstring & name, /*int col, int row*/const std::wstring & ref); void add_formula(const std::wstring & name, const std::wstring & f); void add_help_msg(const std::wstring & name, const std::wstring & title, const std::wstring & content, bool display); - void add_error_msg(const std::wstring & name, const std::wstring & title, const std::wstring & content, bool display, int type); + void add_error_msg(const std::wstring & name, const std::wstring & title, const std::wstring & content, bool display); void activate(const std::wstring & name, int col, int row/*const std::wstring & ref*/); diff --git a/ASCOfficeOdfFile/src/odf/datatypes/messagetype.cpp b/ASCOfficeOdfFile/src/odf/datatypes/messagetype.cpp deleted file mode 100644 index 13b2af8816..0000000000 --- a/ASCOfficeOdfFile/src/odf/datatypes/messagetype.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * (c) Copyright Ascensio System SIA 2010-2019 - * - * This program is a free software product. You can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License (AGPL) - * version 3 as published by the Free Software Foundation. In accordance with - * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement - * of any third-party rights. - * - * This program is distributed WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For - * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html - * - * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha - * street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions - * of the Program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product - * logo when distributing the program. Pursuant to Section 7(e) we decline to - * grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as - * well as technical writing content are licensed under the terms of the - * Creative Commons Attribution-ShareAlike 4.0 International. See the License - * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - * - */ - -#include "messagetype.h" - -#include -#include - -namespace cpdoccore { namespace odf_types { - -std::wostream & operator << (std::wostream & _Wostream, const message_type & _Val) -{ - switch(_Val.get_type()) - { - case message_type::stop: - _Wostream << L"stop"; - break; - case message_type::warning: - _Wostream << L"warning"; - break; - case message_type::information: - _Wostream << L"information"; - break; - } - return _Wostream; -} - -message_type message_type::parse(const std::wstring & Str) -{ - std::wstring tmp = Str; - boost::algorithm::to_lower(tmp); - - if (tmp == L"stop") - return message_type(stop); - else if (tmp == L"warning") - return message_type(warning); - else if (tmp == L"information") - return message_type(information); - else - { - return message_type(stop); - } -} - -} } diff --git a/ASCOfficeOdfFile/src/odf/datatypes/messagetype.h b/ASCOfficeOdfFile/src/odf/datatypes/messagetype.h deleted file mode 100644 index f4eb3f84eb..0000000000 --- a/ASCOfficeOdfFile/src/odf/datatypes/messagetype.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * (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 -#include -#include "odfattributes.h" - - -namespace cpdoccore { namespace odf_types { - -class message_type -{ -public: - enum type - { - stop, - warning, - information - }; - message_type() {} - - message_type(type _Type) : type_(_Type) - {} - - type get_type() const - { - return type_; - }; - - static message_type parse(const std::wstring & Str); - -private: - type type_; - -}; - -std::wostream & operator << (std::wostream & _Wostream, const message_type & _Val); - -} - -APPLY_PARSE_XML_ATTRIBUTES(odf_types::message_type); - -} diff --git a/ASCOfficeOdfFile/src/odf/draw_shapes.cpp b/ASCOfficeOdfFile/src/odf/draw_shapes.cpp index 943a65067d..7945058cc3 100644 --- a/ASCOfficeOdfFile/src/odf/draw_shapes.cpp +++ b/ASCOfficeOdfFile/src/odf/draw_shapes.cpp @@ -257,8 +257,8 @@ void draw_path::reset_svg_path() std::vector<::svg_path::_polyline> o_Polyline_pt; std::vector<::svg_path::_polyline> o_Polyline_cm; - bool bClosed = false, bStroked = true; - bool res = ::svg_path::parseSvgD(o_Polyline_cm, draw_path_attlist_.svg_d_.get(), false, bClosed, bStroked); + bool bClosed = false; + bool res = ::svg_path::parseSvgD(o_Polyline_cm, draw_path_attlist_.svg_d_.get(), false, bClosed); if (!bClosed) lined_shape_ = true; @@ -713,8 +713,8 @@ void draw_connector::reset_svg_path() std::vector<::svg_path::_polyline> o_Polyline_pt; std::vector<::svg_path::_polyline> o_Polyline_cm; - bool bClosed = false, bStroked = true; - bool res = ::svg_path::parseSvgD(o_Polyline_cm, draw_connector_attlist_.svg_d_.get(), false, bClosed, bStroked); + bool bClosed = false; + bool res = ::svg_path::parseSvgD(o_Polyline_cm, draw_connector_attlist_.svg_d_.get(), false, bClosed); if (!bClosed) lined_shape_ = true; diff --git a/ASCOfficeOdfFile/src/odf/draw_shapes_docx.cpp b/ASCOfficeOdfFile/src/odf/draw_shapes_docx.cpp index 774e97f55b..6c855bc9f7 100644 --- a/ASCOfficeOdfFile/src/odf/draw_shapes_docx.cpp +++ b/ASCOfficeOdfFile/src/odf/draw_shapes_docx.cpp @@ -318,11 +318,11 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context std::vector<::svg_path::_polyline> o_Polyline; bool res = false; - bool bClosed = false, bStroked = true; + bool bClosed = false; try { - res = ::svg_path::parseSvgD(o_Polyline, odf_path_, true, bClosed, bStroked); + res = ::svg_path::parseSvgD(o_Polyline, odf_path_, true, bClosed); } catch(...) { @@ -342,10 +342,6 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context int w = 0; int h = 0; - if (false == bStroked) - { - shape->additional_.push_back(odf_reader::_property(L"custom_path_s", false)); - } if (attlist_.drawooo_sub_view_size_) { std::vector< std::wstring > splitted; diff --git a/ASCOfficeOdfFile/src/odf/draw_shapes_pptx.cpp b/ASCOfficeOdfFile/src/odf/draw_shapes_pptx.cpp index 4deacef7ce..53a5316696 100644 --- a/ASCOfficeOdfFile/src/odf/draw_shapes_pptx.cpp +++ b/ASCOfficeOdfFile/src/odf/draw_shapes_pptx.cpp @@ -369,11 +369,11 @@ void draw_enhanced_geometry::pptx_convert(oox::pptx_conversion_context & Context std::vector<::svg_path::_polyline> o_Polyline; bool res = false; - bool bClosed = false, bStroked = true; + bool bClosed =false; try { - res = ::svg_path::parseSvgD(o_Polyline, odf_path_, true, bClosed, bStroked); + res = ::svg_path::parseSvgD(o_Polyline, odf_path_, true, bClosed); } catch(...) { @@ -389,11 +389,7 @@ void draw_enhanced_geometry::pptx_convert(oox::pptx_conversion_context & Context Context.get_slide_context().set_property(odf_reader::_property(L"custom_path", output_.str())); set_shape = true; - - if (false == bStroked) - { - Context.get_slide_context().set_property(odf_reader::_property(L"custom_path_s", false)); - } + if (attlist_.drawooo_sub_view_size_) { std::vector< std::wstring > splitted; diff --git a/ASCOfficeOdfFile/src/odf/draw_shapes_xlsx.cpp b/ASCOfficeOdfFile/src/odf/draw_shapes_xlsx.cpp index b3d3f455a7..2026d85215 100644 --- a/ASCOfficeOdfFile/src/odf/draw_shapes_xlsx.cpp +++ b/ASCOfficeOdfFile/src/odf/draw_shapes_xlsx.cpp @@ -303,11 +303,11 @@ void draw_enhanced_geometry::xlsx_convert(oox::xlsx_conversion_context & Context std::vector<::svg_path::_polyline> o_Polyline; bool res = false; - bool bClosed = false, bStroked = true; + bool bClosed = false; try { - res = ::svg_path::parseSvgD(o_Polyline, odf_path_, true, bClosed, bStroked); + res = ::svg_path::parseSvgD(o_Polyline, odf_path_, true, bClosed); } catch(...) { @@ -322,10 +322,6 @@ void draw_enhanced_geometry::xlsx_convert(oox::xlsx_conversion_context & Context ::svg_path::oox_serialize(output_, o_Polyline); Context.get_drawing_context().set_property(odf_reader::_property(L"custom_path", output_.str())); - if (false == bStroked) - { - Context.get_drawing_context().set_property(odf_reader::_property(L"custom_path_s", false)); - } if (attlist_.drawooo_sub_view_size_) { std::vector< std::wstring > splitted; diff --git a/ASCOfficeOdfFile/src/odf/odfcontext.cpp b/ASCOfficeOdfFile/src/odf/odfcontext.cpp index 559cf7b147..76c937a41f 100644 --- a/ASCOfficeOdfFile/src/odf/odfcontext.cpp +++ b/ASCOfficeOdfFile/src/odf/odfcontext.cpp @@ -190,7 +190,7 @@ style_instance * style_instance::next() const { if (next_) return next_; - else if (container_ && next_name_.empty() == false) + else if (container_) next_ = container_->style_by_name(next_name_, type(), false); return next_; diff --git a/ASCOfficeOdfFile/src/odf/paragraph_elements.cpp b/ASCOfficeOdfFile/src/odf/paragraph_elements.cpp index 44eff586d7..9b1dae2eba 100644 --- a/ASCOfficeOdfFile/src/odf/paragraph_elements.cpp +++ b/ASCOfficeOdfFile/src/odf/paragraph_elements.cpp @@ -1383,12 +1383,9 @@ void sequence::docx_convert(oox::docx_conversion_context & Context) // Context.start_bookmark(ref); //} - if (template_) - { - Context.add_new_run(); - Context.output_stream() << L"" << *template_ << L""; - Context.finish_run(); - } + Context.add_new_run(); + Context.output_stream() << L"" << template_ << L""; + Context.finish_run(); std::wstring num_format = L"ARABIC"; if (style_num_format_) diff --git a/ASCOfficeOdfFile/src/odf/svg_parser.cpp b/ASCOfficeOdfFile/src/odf/svg_parser.cpp index 4d7b5e687d..83eab03c22 100644 --- a/ASCOfficeOdfFile/src/odf/svg_parser.cpp +++ b/ASCOfficeOdfFile/src/odf/svg_parser.cpp @@ -185,7 +185,7 @@ namespace svg_path return bUseRelativeCoordinates ? cLowerCaseCommand : cUpperCaseCommand; } - bool parseSvgD(std::vector<_polyline> & Polyline, const std::wstring & rSvgDStatement, bool bWrongPositionAfterZ, bool & bIsClosed, bool & bStroked) + bool parseSvgD(std::vector<_polyline> & Polyline, const std::wstring & rSvgDStatement, bool bWrongPositionAfterZ, bool & bIsClosed) { Polyline.clear(); const int nLen(rSvgDStatement.length()); @@ -200,7 +200,6 @@ namespace svg_path _polyline aCurrPoly; bIsClosed = false; - bStroked = true; // skip initial whitespace skipSpaces(nPos, rSvgDStatement, nLen); @@ -221,6 +220,7 @@ namespace svg_path nPos++; skipSpaces(nPos, rSvgDStatement, nLen); + // remember closed state of current polygon bIsClosed = true; // update current point - we're back at the start @@ -329,6 +329,7 @@ namespace svg_path case 'v' : { bRelative = true; + // FALLTHROUGH intended } case 'V' ://вертикальная линия { @@ -361,16 +362,15 @@ namespace svg_path case 's' : { bRelative = true; + // FALLTHROUGH intended } case 'S' : { nPos++; skipSpaces(nPos, rSvgDStatement, nLen); - bool bPresentNumber = false; while(nPos < nLen && isOnNumberChar(rSvgDStatement, nPos)) { - bPresentNumber = true; double nX, nY; double nX2, nY2; double nX1, nY1; @@ -408,11 +408,7 @@ namespace svg_path //keep control point nLastControlX = nX2; nLastControlY = nY2; - } - if (false == bPresentNumber) - { - bStroked = false; - } + } }break; case 'c' : @@ -504,9 +500,298 @@ namespace svg_path nLastControlY = nY; } }break; + + // #100617# quadratic beziers are imported as cubic ones + //case 'q' : + //{ + // bRelative = true; + //} + //case 'Q' : + //{ + // nPos++; + // skipSpaces(nPos, rSvgDStatement, nLen); + + // while(nPos < nLen && isOnNumberChar(rSvgDStatement, nPos)) + // { + // double nX, nY; + // double nX1, nY1; + + // if(!importDoubleAndSpaces(nX1, nPos, rSvgDStatement, nLen)) return false; + // if(!importDoubleAndSpaces(nY1, nPos, rSvgDStatement, nLen)) return false; + // if(!importDoubleAndSpaces(nX, nPos, rSvgDStatement, nLen)) return false; + // if(!importDoubleAndSpaces(nY, nPos, rSvgDStatement, nLen)) return false; + + // if(bRelative) + // { + // nX1 += nLastX; + // nY1 += nLastY; + // nX += nLastX; + // nY += nLastY; + // } + + // // calculate the cubic bezier coefficients from the quadratic ones + // const double nX1Prime((nX1 * 2.0 + nLastX) / 3.0); + // const double nY1Prime((nY1 * 2.0 + nLastY) / 3.0); + // const double nX2Prime((nX1 * 2.0 + nX) / 3.0); + // const double nY2Prime((nY1 * 2.0 + nY) / 3.0); + + // // ensure existance of start point + // if(!aCurrPoly.size()) + // { + // aCurrPoly.append(_point(nLastX, nLastY)); + // } + + // // append curved edge + // aCurrPoly.appendBezierSegment(_point(nX1Prime, nY1Prime), _point(nX2Prime, nY2Prime), _point(nX, nY)); + + // // set last position + // nLastX = nX; + // nLastY = nY; + // } + // break; + //} + + //// #100617# relative quadratic beziers are imported as cubic + //case 't' : + //{ + // bRelative = true; + //} + //case 'T' : + //{ + // nPos++; + // skipSpaces(nPos, rSvgDStatement, nLen); + + // while(nPos < nLen && isOnNumberChar(rSvgDStatement, nPos)) + // { + // double nX, nY; + + // if(!importDoubleAndSpaces(nX, nPos, rSvgDStatement, nLen)) return false; + // if(!importDoubleAndSpaces(nY, nPos, rSvgDStatement, nLen)) return false; + + // if(bRelative) + // { + // nX += nLastX; + // nY += nLastY; + // } + + // // ensure existance of start point + // if(!aCurrPoly.size()) + // { + // aCurrPoly.append(_point(nLastX, nLastY)); + // } + + // // get first control point. It's the reflection of the PrevControlPoint + // // of the last point. If not existent, use current point (see SVG) + // _point aPrevControl(_point(nLastX, nLastY)); + // const sal_uInt32 nIndex(aCurrPoly.size() - 1); + // const _point aPrevPoint(aCurrPoly.getB2DPoint(nIndex)); + + // if(aCurrPoly.areControlPointsUsed() && aCurrPoly.isPrevControlPointUsed(nIndex)) + // { + // const _point aPrevControlPoint(aCurrPoly.getPrevControlPoint(nIndex)); + + // // use mirrored previous control point + // aPrevControl.setX((2.0 * aPrevPoint.getX()) - aPrevControlPoint.getX()); + // aPrevControl.setY((2.0 * aPrevPoint.getY()) - aPrevControlPoint.getY()); + // } + + // if(!aPrevControl.equal(aPrevPoint)) + // { + // // there is a prev control point, and we have the already mirrored one + // // in aPrevControl. We also need the quadratic control point for this + // // new quadratic segment to calculate the 2nd cubic control point + // const _point aQuadControlPoint( + // ((3.0 * aPrevControl.getX()) - aPrevPoint.getX()) / 2.0, + // ((3.0 * aPrevControl.getY()) - aPrevPoint.getY()) / 2.0); + + // // calculate the cubic bezier coefficients from the quadratic ones. + // const double nX2Prime((aQuadControlPoint.getX() * 2.0 + nX) / 3.0); + // const double nY2Prime((aQuadControlPoint.getY() * 2.0 + nY) / 3.0); + + // // append curved edge, use mirrored cubic control point directly + // aCurrPoly.appendBezierSegment(aPrevControl, _point(nX2Prime, nY2Prime), _point(nX, nY)); + // } + // else + // { + // // when no previous control, SVG says to use current point -> straight line. + // // Just add end point + // aCurrPoly.append(_point(nX, nY)); + // } + + // // set last position + // nLastX = nX; + // nLastY = nY; + // } + // break; + //} + + //case 'a' : + //{ + // bRelative = true; + //} + //case 'A' : + //{ + // nPos++; + // skipSpaces(nPos, rSvgDStatement, nLen); + + // while(nPos < nLen && isOnNumberChar(rSvgDStatement, nPos)) + // { + // double nX, nY; + // double fRX, fRY, fPhi; + // int bLargeArcFlag, bSweepFlag; + + // if(!importDoubleAndSpaces(fRX, nPos, rSvgDStatement, nLen)) return false; + // if(!importDoubleAndSpaces(fRY, nPos, rSvgDStatement, nLen)) return false; + // if(!importDoubleAndSpaces(fPhi, nPos, rSvgDStatement, nLen)) return false; + // if(!importFlagAndSpaces(bLargeArcFlag, nPos, rSvgDStatement, nLen)) return false; + // if(!importFlagAndSpaces(bSweepFlag, nPos, rSvgDStatement, nLen)) return false; + // if(!importDoubleAndSpaces(nX, nPos, rSvgDStatement, nLen)) return false; + // if(!importDoubleAndSpaces(nY, nPos, rSvgDStatement, nLen)) return false; + + // if(bRelative) + // { + // nX += nLastX; + // nY += nLastY; + // } + + // if( nX == nLastX && nY == nLastY ) + // continue; // start==end -> skip according to SVG spec + + // if( fRX == 0.0 || fRY == 0.0 ) + // { + // // straight line segment according to SVG spec + // aCurrPoly.append(_point(nX, nY)); + // } + // else + // { + // // normalize according to SVG spec + // fRX=fabs(fRX); fRY=fabs(fRY); + + // // from the SVG spec, appendix F.6.4 + + // // |x1'| |cos phi sin phi| |(x1 - x2)/2| + // // |y1'| = |-sin phi cos phi| |(y1 - y2)/2| + // const _point p1(nLastX, nLastY); + // const _point p2(nX, nY); + // B2DHomMatrix aTransform(basegfx::tools::createRotateB2DHomMatrix(-fPhi*M_PI/180)); + + // const _point p1_prime( aTransform * _point(((p1-p2)/2.0)) ); + + // // ______________________________________ rx y1' + // // |cx'| + / rx^2 ry^2 - rx^2 y1'^2 - ry^2 x1^2 ry + // // |cy'| =-/ rx^2y1'^2 + ry^2 x1'^2 - ry x1' + // // rx + // // chose + if f_A != f_S + // // chose - if f_A = f_S + // _point aCenter_prime; + // const double fRadicant( + // (fRX*fRX*fRY*fRY - fRX*fRX*p1_prime.getY()*p1_prime.getY() - fRY*fRY*p1_prime.getX()*p1_prime.getX())/ + // (fRX*fRX*p1_prime.getY()*p1_prime.getY() + fRY*fRY*p1_prime.getX()*p1_prime.getX())); + // if( fRadicant < 0.0 ) + // { + // // no solution - according to SVG + // // spec, scale up ellipse + // // uniformly such that it passes + // // through end points (denominator + // // of radicant solved for fRY, + // // with s=fRX/fRY) + // const double fRatio(fRX/fRY); + // const double fRadicant2( + // p1_prime.getY()*p1_prime.getY() + + // p1_prime.getX()*p1_prime.getX()/(fRatio*fRatio)); + // if( fRadicant2 < 0.0 ) + // { + // // only trivial solution, one + // // of the axes 0 -> straight + // // line segment according to + // // SVG spec + // aCurrPoly.append(_point(nX, nY)); + // continue; + // } + + // fRY=sqrt(fRadicant2); + // fRX=fRatio*fRY; + + // // keep center_prime forced to (0,0) + // } + // else + // { + // const double fFactor( + // (bLargeArcFlag==bSweepFlag ? -1.0 : 1.0) * + // sqrt(fRadicant)); + + // // actually calculate center_prime + // aCenter_prime = _point( + // fFactor*fRX*p1_prime.getY()/fRY, + // -fFactor*fRY*p1_prime.getX()/fRX); + // } + + // // + u - v + // // angle(u,v) = arccos( ------------ ) (take the sign of (ux vy - uy vx)) + // // - ||u|| ||v|| + + // // 1 | (x1' - cx')/rx | + // // theta1 = angle(( ), | | ) + // // 0 | (y1' - cy')/ry | + // const _point aRadii(fRX,fRY); + // double fTheta1( + // B2DVector(1.0,0.0).angle( + // (p1_prime-aCenter_prime)/aRadii)); + + // // |1| | (-x1' - cx')/rx | + // // theta2 = angle( | | , | | ) + // // |0| | (-y1' - cy')/ry | + // double fTheta2( + // B2DVector(1.0,0.0).angle( + // (-p1_prime-aCenter_prime)/aRadii)); + + // // map both angles to [0,2pi) + // fTheta1 = fmod(2*M_PI+fTheta1,2*M_PI); + // fTheta2 = fmod(2*M_PI+fTheta2,2*M_PI); + + // // make sure the large arc is taken + // // (since + // // createPolylineFromEllipseSegment() + // // normalizes to e.g. cw arc) + // if( !bSweepFlag ) + // std::swap(fTheta1,fTheta2); + + // // finally, create bezier polygon from this + // B2DPolyline aSegment( + // tools::createPolylineFromUnitEllipseSegment( + // fTheta1, fTheta2 )); + + // // transform ellipse by rotation & move to final center + // aTransform = basegfx::tools::createScaleB2DHomMatrix(fRX, fRY); + // aTransform.translate(aCenter_prime.getX(), + // aCenter_prime.getY()); + // aTransform.rotate(fPhi*M_PI/180); + // const _point aOffset((p1+p2)/2.0); + // aTransform.translate(aOffset.getX(), + // aOffset.getY()); + // aSegment.transform(aTransform); + + // // createPolylineFromEllipseSegment() + // // always creates arcs that are + // // positively oriented - flip polygon + // // if we swapped angles above + // if( !bSweepFlag ) + // aSegment.flip(); + // aCurrPoly.append(aSegment); + // } + + // // set last position + // nLastX = nX; + // nLastY = nY; + // } + // break; + //} + default: { - ++nPos; + //OSL_FAIL("importFromSvgD(): skipping tags in svg:d element (unknown)!"); + //OSL_TRACE("importFromSvgD(): skipping tags in svg:d element (unknown: \"%c\")!", aCurrChar); + ++nPos; break; } } diff --git a/ASCOfficeOdfFile/src/odf/svg_parser.h b/ASCOfficeOdfFile/src/odf/svg_parser.h index abd5bf8091..e439782dd9 100644 --- a/ASCOfficeOdfFile/src/odf/svg_parser.h +++ b/ASCOfficeOdfFile/src/odf/svg_parser.h @@ -58,7 +58,7 @@ namespace svg_path }; bool parseVml(std::vector<_polyline> & Polyline, const std::wstring & path); - bool parseSvgD(std::vector<_polyline> & Polyline, const std::wstring & path, bool bWrongPositionAfterZ, bool & bIsClosed, bool & bIsStroked); + bool parseSvgD(std::vector<_polyline> & Polyline, const std::wstring & path, bool bWrongPositionAfterZ, bool & bIsClosed); bool parsePolygon(std::vector<_polyline> & Polyline, const std::wstring & path, bool bWrongPositionAfterZ, bool closed); } diff --git a/ASCOfficeOdfFile/src/odf/table.cpp b/ASCOfficeOdfFile/src/odf/table.cpp index 0ee30990a2..b8b8d2a72c 100644 --- a/ASCOfficeOdfFile/src/odf/table.cpp +++ b/ASCOfficeOdfFile/src/odf/table.cpp @@ -837,6 +837,7 @@ const wchar_t * table_help_message::name = L"help-message"; void table_help_message::add_attributes(xml::attributes_wc_ptr const & Attributes) { CP_APPLY_ATTR(L"table:title", table_title_); + CP_APPLY_ATTR(L"table:message-type", table_message_type_); CP_APPLY_ATTR(L"table:display", table_display_); } void table_help_message::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name) diff --git a/ASCOfficeOdfFile/src/odf/table.h b/ASCOfficeOdfFile/src/odf/table.h index 353a73c6d0..c0ad35d64f 100644 --- a/ASCOfficeOdfFile/src/odf/table.h +++ b/ASCOfficeOdfFile/src/odf/table.h @@ -47,7 +47,6 @@ #include "datatypes/tablemode.h" #include "datatypes/common_attlists.h" #include "datatypes/tablevisibility.h" -#include "datatypes/messagetype.h" namespace cpdoccore { namespace odf_reader { @@ -777,11 +776,11 @@ public: virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name); - _CP_OPT(std::wstring) table_title_; - _CP_OPT(odf_types::Bool) table_display_; - _CP_OPT(odf_types::message_type) table_message_type_; + _CP_OPT(std::wstring) table_title_; + _CP_OPT(odf_types::Bool) table_display_; + _CP_OPT(std::wstring) table_message_type_; - office_element_ptr_array content_; + office_element_ptr_array content_; }; CP_REGISTER_OFFICE_ELEMENT2(table_error_message); @@ -801,10 +800,11 @@ public: virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name); - _CP_OPT(std::wstring) table_title_; - _CP_OPT(odf_types::Bool) table_display_; - - office_element_ptr_array content_; + _CP_OPT(std::wstring) table_title_; + _CP_OPT(odf_types::Bool) table_display_; + _CP_OPT(std::wstring) table_message_type_; + + office_element_ptr_array content_; }; CP_REGISTER_OFFICE_ELEMENT2(table_help_message); diff --git a/ASCOfficeOdfFile/src/odf/table_xlsx.cpp b/ASCOfficeOdfFile/src/odf/table_xlsx.cpp index f4238f3199..ca93344c68 100644 --- a/ASCOfficeOdfFile/src/odf/table_xlsx.cpp +++ b/ASCOfficeOdfFile/src/odf/table_xlsx.cpp @@ -1329,8 +1329,7 @@ void table_content_validation::xlsx_convert(oox::xlsx_conversion_context & Conte std::wstring content = Context.get_text_context().end_only_text(); Context.get_dataValidations_context().add_error_msg(name, error->table_title_.get_value_or(L""), content, - error->table_display_ ? error->table_display_->get() : true, - error->table_message_type_.get_value_or(message_type::stop).get_type()); + error->table_display_ ? error->table_display_->get() : true); } else if (content_[i]->get_type() == typeTableHelpMassage) { diff --git a/ASCOfficeOdfFile/src/odf/text_elements.cpp b/ASCOfficeOdfFile/src/odf/text_elements.cpp index e01991d664..eed26d0c19 100644 --- a/ASCOfficeOdfFile/src/odf/text_elements.cpp +++ b/ASCOfficeOdfFile/src/odf/text_elements.cpp @@ -111,6 +111,21 @@ void process_paragraph_drop_cap_attr(const paragraph_attrs & Attr, oox::docx_con } } +void process_paragraph_index(const paragraph_attrs & Attr, oox::docx_conversion_context & Context) +{ + if (false == Context.is_table_content()) return; + + if (Attr.text_style_name_.empty())return; + + style_instance * styleInst + = Context.root()->odf_context().styleContainer().style_by_name(Attr.text_style_name_, style_family::Paragraph, Context.process_headers_footers_); + if ((!styleInst) || (styleInst->is_automatic() == false))return; + + if (L"index" != styleInst->style_class()) return; + + +} + } std::wostream & paragraph::text_to_stream(std::wostream & _Wostream, bool bXmlEncode) const @@ -255,7 +270,7 @@ size_t paragraph::drop_cap_docx_convert(oox::docx_conversion_context & Context) } void paragraph::docx_convert(oox::docx_conversion_context & Context) { - std::wstring styleName = attrs_.text_style_name_; + const std::wstring & styleName = attrs_.text_style_name_; bool in_drawing = false; @@ -925,13 +940,11 @@ void table_of_content::add_child_element( xml::sax * Reader, const std::wstring } void table_of_content::docx_convert(oox::docx_conversion_context & Context) { - if (section_attr_.style_name_ && false == section_attr_.name_.empty()) // ??? || - { - std::wstring current_page_properties = Context.get_page_properties(); - Context.get_section_context().add_section(section_attr_.name_, section_attr_.style_name_.get_value_or(L""), current_page_properties); - Context.add_page_properties(current_page_properties); - } - + std::wstring current_page_properties = Context.get_page_properties(); + + Context.get_section_context().add_section (section_attr_.name_, section_attr_.style_name_.get_value_or(L""), current_page_properties); + + Context.add_page_properties(current_page_properties); if (index_body_) { Context.start_sdt(1); @@ -1136,22 +1149,22 @@ const wchar_t * table_index_entry_template::name = L"table-index-entry-template" const wchar_t * illustration_index::ns = L"text"; const wchar_t * illustration_index::name = L"illustration-index"; -//void illustration_index::afterCreate() -//{ -// office_element::afterCreate(); -// -// if (document_context * context = getContext()) -// { -// if (p *lastPar = dynamic_cast(context->get_last_element())) -// { -// lastPar->paragraph_.set_next_section(true); -// } -// else if (h *lastPar = dynamic_cast(context->get_last_element())) -// { -// lastPar->paragraph_.set_next_section(true); -// } -// } -//} +void illustration_index::afterCreate() +{ + office_element::afterCreate(); + + if (document_context * context = getContext()) + { + if (p *lastPar = dynamic_cast(context->get_last_element())) + { + lastPar->paragraph_.set_next_section(true); + } + else if (h *lastPar = dynamic_cast(context->get_last_element())) + { + lastPar->paragraph_.set_next_section(true); + } + } +} void illustration_index::afterReadContent() { @@ -1170,12 +1183,9 @@ void illustration_index::afterReadContent() } void illustration_index::docx_convert(oox::docx_conversion_context & Context) { - if (section_attr_.style_name_ && false == section_attr_.name_.empty()) // ??? || - { - std::wstring current_page_properties = Context.get_page_properties(); - Context.get_section_context().add_section(section_attr_.name_, section_attr_.style_name_.get_value_or(L""), current_page_properties); - Context.add_page_properties(current_page_properties); - } + std::wstring current_page_properties = Context.get_page_properties(); + Context.get_section_context().add_section (section_attr_.name_,section_attr_.style_name_.get_value_or(L""), current_page_properties); + Context.add_page_properties(current_page_properties); if (index_body_) { @@ -1293,22 +1303,22 @@ void alphabetical_index::add_child_element( xml::sax * Reader, const std::wstrin CP_CREATE_ELEMENT(alphabetical_index_source_); } } -//void alphabetical_index::afterCreate() -//{ -// office_element::afterCreate(); -// -// if (document_context * context = getContext()) -// { -// if (p *lastPar = dynamic_cast(context->get_last_element())) -// { -// lastPar->paragraph_.set_next_section(true); -// } -// else if (h *lastPar = dynamic_cast(context->get_last_element())) -// { -// lastPar->paragraph_.set_next_section(true); -// } -// } -//} +void alphabetical_index::afterCreate() +{ + office_element::afterCreate(); + + if (document_context * context = getContext()) + { + if (p *lastPar = dynamic_cast(context->get_last_element())) + { + lastPar->paragraph_.set_next_section(true); + } + else if (h *lastPar = dynamic_cast(context->get_last_element())) + { + lastPar->paragraph_.set_next_section(true); + } + } +} void alphabetical_index::afterReadContent() { if (document_context * context = getContext()) @@ -1326,12 +1336,9 @@ void alphabetical_index::afterReadContent() } void alphabetical_index::docx_convert(oox::docx_conversion_context & Context) { - if (section_attr_.style_name_ && false == section_attr_.name_.empty()) // ??? || - { - std::wstring current_page_properties = Context.get_page_properties(); - Context.get_section_context().add_section(section_attr_.name_, section_attr_.style_name_.get_value_or(L""), current_page_properties); - Context.add_page_properties(current_page_properties); - } + std::wstring current_page_properties = Context.get_page_properties(); + Context.get_section_context().add_section (section_attr_.name_, section_attr_.style_name_.get_value_or(L""), current_page_properties); + Context.add_page_properties(current_page_properties); if (index_body_) { @@ -1412,22 +1419,22 @@ void alphabetical_index_entry_template::docx_convert(oox::docx_conversion_contex const wchar_t * object_index::ns = L"text"; const wchar_t * object_index::name = L"object-index"; -//void object_index::afterCreate() -//{ -// office_element::afterCreate(); -// -// if (document_context * context = getContext()) -// { -// if (p *lastPar = dynamic_cast(context->get_last_element())) -// { -// lastPar->paragraph_.set_next_section(true); -// } -// else if (h *lastPar = dynamic_cast(context->get_last_element())) -// { -// lastPar->paragraph_.set_next_section(true); -// } -// } -//} +void object_index::afterCreate() +{ + office_element::afterCreate(); + + if (document_context * context = getContext()) + { + if (p *lastPar = dynamic_cast(context->get_last_element())) + { + lastPar->paragraph_.set_next_section(true); + } + else if (h *lastPar = dynamic_cast(context->get_last_element())) + { + lastPar->paragraph_.set_next_section(true); + } + } +} void object_index::afterReadContent() { if (document_context * context = getContext()) @@ -1711,12 +1718,9 @@ void bibliography::afterReadContent() } void bibliography::docx_convert(oox::docx_conversion_context & Context) { - if (section_attr_.style_name_ && false == section_attr_.name_.empty()) // ??? || - { - std::wstring current_page_properties = Context.get_page_properties(); - Context.get_section_context().add_section(section_attr_.name_, section_attr_.style_name_.get_value_or(L""), current_page_properties); - Context.add_page_properties(current_page_properties); - } + std::wstring current_page_properties = Context.get_page_properties(); + Context.get_section_context().add_section (section_attr_.name_, section_attr_.style_name_.get_value_or(L""), current_page_properties); + Context.add_page_properties(current_page_properties); if (index_body_) { diff --git a/ASCOfficeOdfFile/src/odf/text_elements.h b/ASCOfficeOdfFile/src/odf/text_elements.h index 251852e373..81e9bdc12a 100644 --- a/ASCOfficeOdfFile/src/odf/text_elements.h +++ b/ASCOfficeOdfFile/src/odf/text_elements.h @@ -366,7 +366,7 @@ public: CPDOCCORE_DEFINE_VISITABLE(); - //virtual void afterCreate(); + virtual void afterCreate(); virtual void afterReadContent(); void docx_convert(oox::docx_conversion_context & Context); @@ -398,7 +398,7 @@ public: CPDOCCORE_DEFINE_VISITABLE(); - //virtual void afterCreate(); + virtual void afterCreate(); virtual void afterReadContent(); void docx_convert(oox::docx_conversion_context & Context); @@ -430,7 +430,7 @@ public: CPDOCCORE_DEFINE_VISITABLE(); - //virtual void afterCreate(); + virtual void afterCreate(); virtual void afterReadContent(); void docx_convert(oox::docx_conversion_context & Context); diff --git a/ASCOfficeOdfFile/win32/cpcommon.vcxproj b/ASCOfficeOdfFile/win32/cpcommon.vcxproj index 1478f57960..857c809a91 100644 --- a/ASCOfficeOdfFile/win32/cpcommon.vcxproj +++ b/ASCOfficeOdfFile/win32/cpcommon.vcxproj @@ -229,7 +229,6 @@ - @@ -357,7 +356,6 @@ - diff --git a/ASCOfficeOdfFile/win32/cpcommon.vcxproj.filters b/ASCOfficeOdfFile/win32/cpcommon.vcxproj.filters index 3334a2dc46..4bb9b4efd9 100644 --- a/ASCOfficeOdfFile/win32/cpcommon.vcxproj.filters +++ b/ASCOfficeOdfFile/win32/cpcommon.vcxproj.filters @@ -345,9 +345,6 @@ datatypes odf - - datatypes odf - @@ -671,8 +668,5 @@ datatypes odf - - datatypes odf - \ No newline at end of file diff --git a/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.cpp b/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.cpp index 72f6c19a72..38aae63581 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.cpp @@ -1330,16 +1330,11 @@ void odf_drawing_context::set_opacity(double percent_) switch(impl_->current_drawing_part_) { case Area: - { - if (impl_->current_drawing_state_.oox_shape_preset_ == 3000) - impl_->current_graphic_properties->common_draw_fill_attlist_.draw_image_opacity_ = percent(percent_); - else - impl_->current_graphic_properties->common_draw_fill_attlist_.draw_opacity_ = percent(percent_); - }break; + impl_->current_graphic_properties->common_draw_fill_attlist_.draw_opacity_ = percent(percent_); + break; case Line: - { impl_->current_graphic_properties->svg_stroke_opacity_ = percent(percent_); - }break; + break; } } void odf_drawing_context::set_grayscale() @@ -2186,8 +2181,7 @@ void odf_drawing_context::set_size( _CP_OPT(double) & width_pt, _CP_OPT(double) } void odf_drawing_context::set_line_width(double pt) { - if (!impl_->current_graphic_properties) return; - + if (!impl_->current_graphic_properties)return; impl_->current_graphic_properties->svg_stroke_width_ = length(length(pt,length::pt).get_value_unit(length::cm), length::cm); } @@ -2463,9 +2457,9 @@ void odf_drawing_context::set_textarea_font(std::wstring & latin, std::wstring & if (!impl_->current_text_properties) return; - if (!ea.empty()) impl_->current_text_properties->content_.fo_font_family_ = latin; + if (!ea.empty()) impl_->current_text_properties->content_.fo_font_family_ = ea; if (!cs.empty()) impl_->current_text_properties->content_.style_font_family_complex_ = cs; - if (!latin.empty()) impl_->current_text_properties->content_.style_font_family_asian_ = ea; + if (!latin.empty()) impl_->current_text_properties->content_.style_font_family_asian_ = latin; } void odf_drawing_context::set_textarea_fontcolor(std::wstring hexColor) diff --git a/ASCOfficeOdfFileW/source/OdfFormat/odf_number_styles_context.cpp b/ASCOfficeOdfFileW/source/OdfFormat/odf_number_styles_context.cpp index 818de0dbf0..007bd0804b 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/odf_number_styles_context.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/odf_number_styles_context.cpp @@ -245,7 +245,7 @@ void odf_number_styles_context::create(int oox_num_fmt, std::wstring formatCode) number_format_state state; state.oox_num_fmt = oox_num_fmt; - state.style_name = std::wstring(L"NF1000") + boost::lexical_cast( number_format_array_.size() + 1); + state.style_name = std::wstring(L"NF1000") + boost::lexical_cast( number_format_array_.size()+1); state.ods_type = office_value_type::Custom; state.language_code = 0; @@ -253,7 +253,7 @@ void odf_number_styles_context::create(int oox_num_fmt, std::wstring formatCode) boost::algorithm::split(state.format_code, formatCode, boost::algorithm::is_any_of(L";"), boost::algorithm::token_compress_on); - if (state.format_code.size() > 1 && state.format_code[state.format_code.size() - 1].find(L"@") >= 0) + if (state.format_code.size()>1 && state.format_code[state.format_code.size()-1].find(L"@")>=0) { state.format_code.pop_back(); } @@ -357,13 +357,7 @@ void odf_number_styles_context::create_default(int oox_num_fmt, std::wstring for } number_format_state & odf_number_styles_context::add_or_find(int oox_num_fmt, std::wstring formatCode) { - if (oox_num_fmt < 0) - { - //not spreadsheet todooo - search by formatCode - oox_num_fmt = 0xffff + named_link_map_.size(); - } - - if (named_link_map_.count(oox_num_fmt) > 0) + if (named_link_map_.count(oox_num_fmt) > 0) { return number_format_array_[named_link_map_.at(oox_num_fmt)]; } @@ -376,7 +370,7 @@ number_format_state & odf_number_styles_context::add_or_find(int oox_num_fmt, st void odf_number_styles_context::process_styles(office_element_ptr root ) { - for (size_t i = 0; i< number_format_array_.size(); i++) + for (size_t i=0; i< number_format_array_.size(); i++) { create_style(number_format_array_[i]); @@ -822,7 +816,7 @@ void odf_number_styles_context::create_text_style(number_format_state & state, o void odf_number_styles_context::detect_format(number_format_state & state) { - if (state.ods_type != office_value_type::Custom) return; + if (state.ods_type != office_value_type::Custom)return; if (state.format_code.empty())return; //find [$-]. diff --git a/ASCOfficeOdfFileW/source/OdfFormat/odf_page_layout_state.h b/ASCOfficeOdfFileW/source/OdfFormat/odf_page_layout_state.h index b7699da4da..f042ed307a 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/odf_page_layout_state.h +++ b/ASCOfficeOdfFileW/source/OdfFormat/odf_page_layout_state.h @@ -82,7 +82,6 @@ public: void set_layout_style_name (std::wstring name); void set_display_name (std::wstring & name); - void set_class(const std::wstring &value); office_element_ptr & get_root(); office_element_ptr & get_last_element(); diff --git a/ASCOfficeOdfFileW/source/OdfFormat/odf_style_state.cpp b/ASCOfficeOdfFileW/source/OdfFormat/odf_style_state.cpp index 3bef812db0..549286c567 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/odf_style_state.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/odf_style_state.cpp @@ -85,7 +85,7 @@ void odf_style_state::add_child(office_element_ptr & child) odf_style_->add_child_element(child); } -void odf_style_state::set_name(const std::wstring &name) +void odf_style_state::set_name(std::wstring name) { odf_style_name_ = name; @@ -94,19 +94,14 @@ void odf_style_state::set_name(const std::wstring &name) style_->style_name_ = name; } -void odf_style_state::set_display_name(const std::wstring &name) + +void odf_style_state::set_display_name(std::wstring name) { style* style_ = dynamic_cast(odf_style_.get()); if (!style_)return; style_->style_display_name_ = name; -} -void odf_style_state::set_class(const std::wstring &value) -{ - style* style_ = dynamic_cast(odf_style_.get()); - if (!style_)return; - style_->style_class_ = value; } std::wstring odf_style_state::get_name() { @@ -119,12 +114,13 @@ style_family::type odf_style_state::get_family_type() { return style_family_; } + void odf_style_state::set_family_type (odf_types::style_family::type type) { style_family_ = type; } -void odf_style_state::set_parent_style_name(const std::wstring &name) +void odf_style_state::set_parent_style_name(std::wstring name) { if (name.length() < 1) return; @@ -135,7 +131,7 @@ void odf_style_state::set_parent_style_name(const std::wstring &name) return; style_->style_parent_style_name_ = name; } -void odf_style_state::set_list_style_name(const std::wstring &name) +void odf_style_state::set_list_style_name(std::wstring name) { if (name.length() < 1) return; @@ -150,7 +146,7 @@ void odf_style_state::set_dont_write(bool Val) { writable_ = !Val; } -void odf_style_state::set_data_style_name(const std::wstring &name) +void odf_style_state::set_data_style_name(std::wstring name) { style* style_ = dynamic_cast(odf_style_.get()); if (!style_)return; diff --git a/ASCOfficeOdfFileW/source/OdfFormat/odf_style_state.h b/ASCOfficeOdfFileW/source/OdfFormat/odf_style_state.h index b91d63adf1..87871d7661 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/odf_style_state.h +++ b/ASCOfficeOdfFileW/source/OdfFormat/odf_style_state.h @@ -78,22 +78,20 @@ public: void add_child(office_element_ptr & child); ///////////////////////////////////////////////////////////////////////////////////////// - void set_name(const std::wstring &name); + void set_name(std::wstring name); std::wstring get_name(); - void set_class(const std::wstring &value); - odf_types::style_family::type get_family_type (); void set_family_type (odf_types::style_family::type type); void set_number_format(int id) {num_fmt_id_ = id;} int get_number_format() {return num_fmt_id_;} - void set_parent_style_name(const std::wstring &name) ; - void set_data_style_name(const std::wstring &name); - void set_list_style_name(const std::wstring &name); + void set_parent_style_name(std::wstring name) ; + void set_data_style_name(std::wstring name); + void set_list_style_name(std::wstring name); - void set_display_name(const std::wstring &name); + void set_display_name(std::wstring name); ////////////////////////////////////////////////////////////////////////////////////////// graphic_format_properties * get_graphic_properties() ; diff --git a/ASCOfficeOdfFileW/source/OdfFormat/odf_text_context.cpp b/ASCOfficeOdfFileW/source/OdfFormat/odf_text_context.cpp index 4a86170dda..5dddad68df 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/odf_text_context.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/odf_text_context.cpp @@ -522,7 +522,7 @@ void odf_text_context::end_list() } //------------------------------------------------------------------------------------------ LIST -bool odf_text_context::start_field(int type, const std::wstring& value, const std::wstring& format) +bool odf_text_context::start_field(int type, const std::wstring& value) { if (single_paragraph_ == true) return false; @@ -561,34 +561,16 @@ bool odf_text_context::start_field(int type, const std::wstring& value, const st { create_element(L"text", L"page-count", elm, odf_context_); }break; - case fieldTime: - { - create_element(L"text", L"time", elm, odf_context_); - - text_time *time = dynamic_cast(elm.get()); - if (time) - { - if (false == value.empty()) time->text_time_value_ = value; - if (false == format.empty() && styles_context_) - { - number_format_state state = styles_context_->numbers_styles().add_or_find(-1, format); - time->style_data_style_name_ = state.style_name; - } - - } - }break; case fieldDateTime: { create_element(L"text", L"date", elm, odf_context_); - text_date *date = dynamic_cast(elm.get()); - if (date) - { - if (false == value.empty()) date->text_date_value_ = value; - if (false == format.empty() && styles_context_) + if (false == value.empty()) + { + text_date *date = dynamic_cast(elm.get()); + if (date) { - number_format_state state = styles_context_->numbers_styles().add_or_find(-1, format); - date->style_data_style_name_ = state.style_name; + date->text_date_value_ = value; } } }break; diff --git a/ASCOfficeOdfFileW/source/OdfFormat/odf_text_context.h b/ASCOfficeOdfFileW/source/OdfFormat/odf_text_context.h index e94a6e1283..ed740b6ea9 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/odf_text_context.h +++ b/ASCOfficeOdfFileW/source/OdfFormat/odf_text_context.h @@ -56,8 +56,6 @@ namespace odf_writer fieldTextInput, fieldExpression, fieldDropDown, - fieldDate, - fieldTime, fieldBibliography = 0xff + 1, fieldIndex, @@ -107,7 +105,7 @@ public: void add_element_in_span_or_par(office_element_ptr & elm); - bool start_field (int type, const std::wstring& value, const std::wstring& format); + bool start_field (int type, const std::wstring& value); void end_field (); void start_span (bool styled = false); diff --git a/ASCOfficeOdfFileW/source/OdfFormat/ods_conversion_context.cpp b/ASCOfficeOdfFileW/source/OdfFormat/ods_conversion_context.cpp index fd93f3383c..892406ab9a 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/ods_conversion_context.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/ods_conversion_context.cpp @@ -213,7 +213,31 @@ void ods_conversion_context::start_row(int _start_row, int repeated, int level, { int repeated_default = _start_row - current_table()->current_row() - 1; - add_default_row(repeated_default); + while(true) + { + //делим на 3 - до, с комметом, после; + int comment_idx = current_table()->is_row_comment(current_table()->current_row() + 1, repeated_default); + + if (comment_idx < 0) break; + int rows = current_table()->comments_[comment_idx].row - current_table()->current_row() - 1; + + if (rows > 0) + { + start_row(current_table()->current_row() + 1, rows, 0, true); + end_row(); + } + + start_row(current_table()->current_row() + 1, 1, 0, true); + end_row(); + + repeated_default -= (1 + rows); + } + + if (repeated_default > 0) + { + start_row(_start_row - repeated_default, repeated_default, 0, true); + end_row(); + } } //------------------------------------------------------------------------------------------- while (level < current_table()->current_level()) @@ -387,9 +411,9 @@ void ods_conversion_context::set_data_validation_operator(int val) { table_context_.set_data_validation_operator(val); } -void ods_conversion_context::set_data_validation_error(const std::wstring &title, const std::wstring &content, bool display, int type) +void ods_conversion_context::set_data_validation_error(const std::wstring &title, const std::wstring &content, bool display) { - table_context_.set_data_validation_error(title, content, display, type); + table_context_.set_data_validation_error(title, content, display); } void ods_conversion_context::set_data_validation_promt(const std::wstring &title, const std::wstring &content, bool display) { @@ -517,51 +541,37 @@ void ods_conversion_context::end_columns() void ods_conversion_context::start_rows() { } -void ods_conversion_context::add_default_row(int repeated) -{ - if (repeated < 1) return; - - if (repeated > 1) - { - int row_comment_repeated = 1; - int row_comment = current_table()->is_row_comment(current_table()->current_row() + 1, repeated); - int row_validation_repeated = repeated; - int row_validation = current_table()->is_row_validation(current_table()->current_row() + 1, row_validation_repeated); - - int row_split = row_comment; int row_split_repeated = 1; - if (row_validation > 0) - { - if (row_split < 0 || row_validation < row_split) - { - row_split = row_validation; - row_split_repeated = row_validation_repeated; - } - } - if (row_split > current_table()->current_row() && row_split_repeated != repeated) - {//делим на 3 - до, с --, после; - int r = current_table()->current_row(); - - add_default_row(row_split - r - 1); - add_default_row(row_split_repeated); - add_default_row(repeated + r + row_split_repeated - row_split - 1); - - return; - } - } - - if (repeated > 0 && current_table()->get_last_row_repeated() < 1024) - { - start_row(current_table()->current_row() + 1, repeated, 0, true); - end_row(); - } -} void ods_conversion_context::end_rows() { //add default last row int repeated = (std::max)(current_table()->dimension_row, 64) - current_table()->current_row(); if (repeated < 0) repeated = 1; - add_default_row(repeated); + while(true) + { + //делим на 3 - до, с комметом, после; + int comment_idx = current_table()->is_row_comment(current_table()->current_row() + 1, repeated); + + if (comment_idx < 0) break; + int rows = current_table()->comments_[comment_idx].row - current_table()->current_row() - 1; + + if (rows > 0) + { + start_row(current_table()->current_row() + 1, rows, 0, true); + end_row(); + } + + start_row(current_table()->current_row() + 1, 1, 0, true); + end_row(); + + repeated -= (1 + rows); + } + + if (repeated > 0 && current_table()->get_last_row_repeated() < 1024) + { + start_row(current_table()->current_row() + 1, repeated, 0, true); + end_row(); + } } void ods_conversion_context::add_column(int start_column, int repeated, int level, bool _default) { diff --git a/ASCOfficeOdfFileW/source/OdfFormat/ods_conversion_context.h b/ASCOfficeOdfFileW/source/OdfFormat/ods_conversion_context.h index 0f3d18654a..82447f9393 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/ods_conversion_context.h +++ b/ASCOfficeOdfFileW/source/OdfFormat/ods_conversion_context.h @@ -84,7 +84,6 @@ public: void end_cell(); void add_row_repeated(); - void add_default_row(int repeated); void end_rows(); void start_cell_text(); @@ -106,7 +105,7 @@ public: void set_data_validation_operator(int val); void set_data_validation_content(const std::wstring &val1, const std::wstring &val2); void set_data_validation_allow_empty(bool val); - void set_data_validation_error(const std::wstring &title, const std::wstring &content, bool display, int type); + void set_data_validation_error(const std::wstring &title, const std::wstring &content, bool display); void set_data_validation_promt(const std::wstring &title, const std::wstring &content, bool display); void end_data_validation(); diff --git a/ASCOfficeOdfFileW/source/OdfFormat/ods_table_context.cpp b/ASCOfficeOdfFileW/source/OdfFormat/ods_table_context.cpp index ad32049d9c..53aef037dc 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/ods_table_context.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/ods_table_context.cpp @@ -330,71 +330,62 @@ void ods_table_context::set_data_validation_content( std::wstring oox_formula1, table_content_validation *validation = dynamic_cast(state()->data_validations_.back().elm.get()); std::wstring odf_condition; - - if (state()->data_validations_.back().type == 5) odf_condition = L"cell-content-text-length"; - else odf_condition = L"cell-content"; - switch(state()->data_validations_.back().operator_) { case 1: // SimpleTypes::spreadsheet::operatorNotBetween - odf_condition += L"-is-not-between(" + odf_formula1 + L"," + odf_formula2 + L")"; break; + odf_condition = L" and cell-content-is-not-between(" + odf_formula1 + L"," + odf_formula2 + L")"; break; case 2: // SimpleTypes::spreadsheet::operatorEqual - odf_condition += L"()==" + odf_formula1; break; + odf_condition = L" and cell-content()==" + odf_formula1; break; case 3: // SimpleTypes::spreadsheet::operatorNotEqual - odf_condition += L"()!=" + odf_formula1; break; + odf_condition = L" and cell-content()<>" + odf_formula1; break; case 4: // SimpleTypes::spreadsheet::operatorLessThan - odf_condition += L"()<" + odf_formula1; break; + odf_condition = L" and cell-content()<" + odf_formula1; break; case 5: // SimpleTypes::spreadsheet::operatorLessThanOrEqual - odf_condition += L"()<=" + odf_formula1; break; + odf_condition = L" and cell-content()<=" + odf_formula1; break; case 6: // SimpleTypes::spreadsheet::operatorGreaterThan - odf_condition += L"()>" + odf_formula1; break; + odf_condition = L" and cell-content()>" + odf_formula1; break; case 7: // SimpleTypes::spreadsheet::operatorGreaterThanOrEqual - odf_condition += L"()>=" + odf_formula1; break; + odf_condition = L" and cell-content()>=" + odf_formula1; break; case 0: // SimpleTypes::spreadsheet::operatorBetween default: - odf_condition += + L"-is-between(" + odf_formula1 + L"," + odf_formula2 + L")"; break; + odf_condition = L" and cell-content-is-between(" + odf_formula1 + L"," + odf_formula2 + L")"; break; } switch (state()->data_validations_.back().type) { - case 0://SimpleTypes::spreadsheet::validationTypeNone: + case 0://SimpleTypes::spreadsheet::validationTypeNone: + odf_condition.clear(); + break; + case 1://SimpleTypes::spreadsheet::validationTypeCustom: + odf_condition = L"of:is-true-formula(" + odf_formula1 + L")"; + break; + case 2://SimpleTypes::spreadsheet::validationTypeDate: { - odf_condition.clear(); + odf_condition = L"of:cell-content-is-date()" + odf_condition; }break; - case 1://SimpleTypes::spreadsheet::validationTypeCustom: + case 3://SimpleTypes::spreadsheet::validationTypeDecimal: { - odf_condition = L"of:is-true-formula(" + odf_formula1 + L")"; + odf_condition = L"of:cell-content-is-decimal-number()" + odf_condition; }break; - case 2://SimpleTypes::spreadsheet::validationTypeDate: - { - odf_condition = L"of:cell-content-is-date() and " + odf_condition; - }break; - case 3://SimpleTypes::spreadsheet::validationTypeDecimal: - { - odf_condition = L"of:cell-content-is-decimal-number() and " + odf_condition; - }break; - case 4://SimpleTypes::spreadsheet::validationTypeList: + case 4://SimpleTypes::spreadsheet::validationTypeList: { odf_condition = L"of:cell-content-is-in-list(" + odf_formula1 + L")"; }break; - case 6://SimpleTypes::spreadsheet::validationTypeTime: + case 5://SimpleTypes::spreadsheet::validationTypeTextLength: + break; + case 6://SimpleTypes::spreadsheet::validationTypeTime: { - odf_condition = L"of:cell-content-is-time() and " + odf_condition; + odf_condition = L"of:cell-content-is-time()" + odf_condition; }break; - case 7://SimpleTypes::spreadsheet::validationTypeWhole: + case 7://SimpleTypes::spreadsheet::validationTypeWhole: { - odf_condition = L"of:cell-content-is-whole-number() and " + odf_condition; + odf_condition = L"of:cell-content-is-whole-number()" + odf_condition; }break; - case 5://SimpleTypes::spreadsheet::validationTypeTextLength: - default: - { - odf_condition = L"of:" + odf_condition; - }break; } state()->data_validations_.back().condition = odf_condition; validation->table_condition_ = odf_condition; } -void ods_table_context::set_data_validation_error(const std::wstring &title, const std::wstring &content, bool display, int type) +void ods_table_context::set_data_validation_error(const std::wstring &title, const std::wstring &content, bool display) { if (state()->data_validations_.empty()) return; @@ -407,7 +398,6 @@ void ods_table_context::set_data_validation_error(const std::wstring &title, con if (error_message) { - error_message->table_message_type_ = (odf_types::message_type::type)type; error_message->table_display_ = display; if (false == title.empty()) error_message->table_title_ = title; diff --git a/ASCOfficeOdfFileW/source/OdfFormat/ods_table_context.h b/ASCOfficeOdfFileW/source/OdfFormat/ods_table_context.h index d377fd48f9..a8110d0ced 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/ods_table_context.h +++ b/ASCOfficeOdfFileW/source/OdfFormat/ods_table_context.h @@ -77,7 +77,7 @@ public: void set_data_validation_operator(int val); void set_data_validation_content(std::wstring val1, std::wstring val2); void set_data_validation_allow_empty(bool val); - void set_data_validation_error(const std::wstring &title, const std::wstring &content, bool display, int type); + void set_data_validation_error(const std::wstring &title, const std::wstring &content, bool display); void set_data_validation_promt(const std::wstring &title, const std::wstring &content, bool display); void end_data_validation(); diff --git a/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.cpp b/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.cpp index c8974c09bb..4a5d87d3bc 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.cpp @@ -508,7 +508,7 @@ bool ods_table_state::is_cell_comment() } bool ods_table_state::is_cell_data_validation() { - if ( cells_size_ < 1 ) return false; + if ( cells_size_ < 1 )return false; return cells_.back().data_validation_name.empty() ? true : false; } int ods_table_state::is_cell_hyperlink(int col, int row) @@ -522,32 +522,17 @@ int ods_table_state::is_cell_hyperlink(int col, int row) } return -1; } -std::wstring ods_table_state::is_cell_data_validation(int col, int row, unsigned int repeate_col, data_validation_state::_ref & ref) +std::wstring ods_table_state::is_cell_data_validation(int col, int row) { - for (size_t i = 0; i < data_validations_.size(); i++) + for (size_t i = 0; i < data_validations_.size(); i++) { - if (data_validations_[i].in_ref(col, row, repeate_col, ref)) + if (data_validations_[i].in_ref(col, row)) { return data_validations_[i].name; } } return L""; } -int ods_table_state::is_row_validation(int row, int & repeate_row) -{ - for (size_t i = 0; i < data_validations_.size(); i++) - { - data_validation_state::_ref ref; - if (data_validations_[i].in_row(row, repeate_row, ref)) - { - repeate_row = (std::min)(ref.row_end, row + repeate_row - 1) - (std::max)(row, ref.row_start) + 1; - - if (ref.row_start > row) row = ref.row_start; - return row; - } - } - return -1; -} int ods_table_state::is_cell_comment(int col, int row, unsigned int repeate_col) { for (size_t i = 0; i < comments_.size(); i++) @@ -565,7 +550,7 @@ int ods_table_state::is_row_comment(int row, int repeate_row) { if (comments_[i].row < row + repeate_row && comments_[i].row >= row && comments_[i].used == false) { - return comments_[i].row; + return (int)i; } } return -1; @@ -648,12 +633,9 @@ void ods_table_state::start_cell(office_element_ptr & elm, office_element_ptr & state.elm = elm; state.repeated = 1; state.style_name = style_name; state.style_elm = style_elm; state.row = current_table_row_; state.col = current_table_column_ + 1; - data_validation_state::_ref ref; - std::wstring validation_name = is_cell_data_validation(state.col, state.row, 1, ref); - state.hyperlink_idx = is_cell_hyperlink(state.col, state.row); state.comment_idx = is_cell_comment(state.col, state.row); - state.data_validation_name = validation_name; + state.data_validation_name = is_cell_data_validation(state.col, state.row); current_table_column_ += state.repeated; cells_.push_back(state); @@ -1431,7 +1413,7 @@ void ods_table_state::end_cell() } } -void ods_table_state::add_default_cell( int repeated) +void ods_table_state::add_default_cell( unsigned int repeated) { if (repeated < 1) return; @@ -1443,11 +1425,12 @@ void ods_table_state::add_default_cell( int repeated) add_default_cell(comments_[comment_idx].col - c - 1); add_default_cell(1); - add_default_cell(repeated + c - comments_[comment_idx].col); + add_default_cell(repeated + c + 1 - comments_[comment_idx].col); return; } -//----------------------------------------------------------------------------------------- + +////////////////////////////////////////////////// std::map>::iterator pFindRow = map_merged_cells.find(current_table_row_); bool bSpanned = false; @@ -1464,7 +1447,7 @@ void ods_table_state::add_default_cell( int repeated) add_default_cell(it->first - c - 1); add_default_cell(1); - add_default_cell(repeated + c - current_table_column_); + add_default_cell(repeated + c + 1 - it->first); return; } @@ -1476,24 +1459,7 @@ void ods_table_state::add_default_cell( int repeated) } } } -//----------------------------------------------------------------------------------------- - data_validation_state::_ref ref; - std::wstring validation_name = is_cell_data_validation(current_table_column_ + 1, current_table_row_, repeated, ref); - int repeated_validation = (std::min)(ref.col_end, current_table_column_ + (int)repeated) - (std::max)(ref.col_start, current_table_column_ + 1) + 1; - - if (false == validation_name.empty() && repeated > 1 && repeated_validation != repeated) - { - //делим на 3 - до, с validation, после; - int c = current_table_column_; - - add_default_cell(ref.col_start - c - 1); - add_default_cell(repeated_validation); - add_default_cell(repeated + c - current_table_column_); - - return; - } -//----------------------------------------------------------------------------------------- bool bCovered = false; if (!bSpanned) { @@ -1521,7 +1487,7 @@ void ods_table_state::add_default_cell( int repeated) } } } -//----------------------------------------------------------------------------------------- + office_element_ptr default_cell_elm; if (bCovered) { @@ -1556,7 +1522,7 @@ void ods_table_state::add_default_cell( int repeated) state.col = current_table_column_ + 1; state.hyperlink_idx = is_cell_hyperlink(state.col, current_table_row_); - state.data_validation_name = validation_name; + state.data_validation_name = is_cell_data_validation(state.col, current_table_row_); state.comment_idx = comment_idx; cells_.push_back(state); diff --git a/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.h b/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.h index 8347e7ef89..496425f317 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.h +++ b/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.h @@ -269,30 +269,16 @@ struct data_validation_state std::wstring condition; - bool in_ref(int col, int row, unsigned int repeate_col, _ref & ref) + bool in_ref(int col, int row) { for (size_t i = 0; i < refs.size(); i++) { - if (row < refs[i].row_start || row > refs[i].row_end) continue; - - if (col + repeate_col <= refs[i].col_start || col > refs[i].col_end) continue; - - ref = refs[i]; - return true; + if (col >= refs[i].col_start && col <= refs[i].col_end && row >= refs[i].row_start && row <= refs[i].row_end) + return true; } return false; } - bool in_row(int row, unsigned int repeate_row, _ref & ref) - { - for (size_t i = 0; i < refs.size(); i++) - { - if (row + repeate_row <= refs[i].row_start || row > refs[i].row_end) continue; - ref = refs[i]; - return true; - } - return false; - } }; struct ods_array_formula_state { @@ -352,7 +338,7 @@ public: void start_cell(office_element_ptr & elm ,office_element_ptr & style); void end_cell(); - void add_default_cell(int repeated); + void add_default_cell(unsigned int repeated); void check_spanned_cells(); @@ -416,8 +402,7 @@ public: int is_cell_hyperlink(int col, int row); int is_cell_comment(int col, int row, unsigned int repeate_col = 1); int is_row_comment(int row, int repeate_row = 1); - int is_row_validation(int row, int & repeate_row); - std::wstring is_cell_data_validation(int col, int row, unsigned int repeate_col, data_validation_state::_ref & ref); + std::wstring is_cell_data_validation(int col, int row); unsigned int get_last_row_repeated (); diff --git a/ASCOfficeOdfFileW/source/OdfFormat/odt_conversion_context.cpp b/ASCOfficeOdfFileW/source/OdfFormat/odt_conversion_context.cpp index 407bcf0436..76d207232d 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/odt_conversion_context.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/odt_conversion_context.cpp @@ -585,11 +585,6 @@ void odt_conversion_context::end_bookmark (int id) } void odt_conversion_context::start_hyperlink(std::wstring ref) { - if (false == current_fields.empty() && current_fields.back().status == 1 && false == current_fields.back().in_span) - { - end_paragraph(); - start_paragraph(true); - } office_element_ptr hyperlink_elm; create_element(L"text", L"a", hyperlink_elm, this); @@ -758,12 +753,7 @@ void odt_conversion_context::set_field_instr() res1 = instr.find(L"TIME"); if (std::wstring::npos != res1 && current_fields.back().type == 0) { - current_fields.back().type = fieldTime; - } - res1 = instr.find(L"DATE"); - if (std::wstring::npos != res1 && current_fields.back().type == 0) - { - current_fields.back().type = fieldDate; + current_fields.back().type = fieldDateTime; } res1 = instr.find(L"FORMTEXT"); if (std::wstring::npos != res1 && current_fields.back().type == 0) @@ -843,8 +833,7 @@ void odt_conversion_context::set_field_instr() boost::algorithm::split(arLevels, pFind->second, boost::algorithm::is_any_of(L"-"), boost::algorithm::token_compress_on); if (arLevels.size() > 1) { - if (current_fields.back().captionSEQ.empty()) - current_fields.back().type = fieldToc; + current_fields.back().type = fieldToc; current_fields.back().outline_levels = XmlUtils::GetInteger(arLevels[1]); } } @@ -867,30 +856,25 @@ void odt_conversion_context::set_field_instr() } } pFind = options.find(L"z"); - if ( pFind != options.end()) + if ( pFind != options.end())//table of content outline levels style { current_fields.back().bHidePageNumbers = true; } } ////////////////////////////////////////// - res1 = instr.find(L" "); + res1 = instr.find(L"@"); if (std::wstring::npos != res1) { - if (current_fields.back().format.empty()) - { - std::map options = parse_instr_options(instr.substr(res1 + 1)); + current_fields.back().format = instr.substr(res1 + 1, instr.length()); + } - std::map::iterator pFind = options.find(L"@"); - if (pFind != options.end()) - { - current_fields.back().format = pFind->second; - } - } - - if (current_fields.back().type == 0) + if (current_fields.back().type == 0) + { + res1 = instr.find(L" "); + if (std::wstring::npos != res1) { current_fields.back().name = instr.substr(0, res1); - } + } } } void odt_conversion_context::set_field_date_time(const std::wstring &date_time) @@ -1102,7 +1086,7 @@ void odt_conversion_context::end_field() else if (current_fields.back().type == fieldSeq) start_sequence(); else if (current_fields.back().type == fieldDropDown) start_drop_down(); else - text_context()->start_field(current_fields.back().type, current_fields.back().value, current_fields.back().format); + text_context()->start_field(current_fields.back().type, current_fields.back().value); } if (current_fields.back().status == 2) { @@ -1122,14 +1106,6 @@ void odt_conversion_context::end_field() { current_fields.pop_back(); } - if (false == current_fields.empty()) - { - if (current_fields.back().type < 0xff && current_fields.back().type != fieldHyperlink - && current_fields.back().type != fieldSeq - && current_fields.back().type != fieldDropDown) - text_context()->in_field_ = true; - } - } void odt_conversion_context::end_paragraph() { @@ -1259,7 +1235,7 @@ void odt_conversion_context::start_run(bool styled) else if (current_fields.back().type == fieldSeq) start_sequence(); else if (current_fields.back().type == fieldDropDown) start_drop_down(); else - text_context()->start_field(current_fields.back().type, current_fields.back().value, current_fields.back().format); + text_context()->start_field(current_fields.back().type, current_fields.back().value); } text_context()->start_span(styled); @@ -1274,7 +1250,7 @@ void odt_conversion_context::start_run(bool styled) if (!current_fields.empty() && current_fields.back().status == 1 && current_fields.back().in_span)//поле стартуется в span - нужно для сохранения стиля { current_fields.back().status = 2; - text_context()->start_field(current_fields.back().type, current_fields.back().value, current_fields.back().format); + text_context()->start_field(current_fields.back().type, current_fields.back().value); } } void odt_conversion_context::end_run() diff --git a/ASCOfficeOdfFileW/source/OdfFormat/table.h b/ASCOfficeOdfFileW/source/OdfFormat/table.h index bf42cca4fe..cf9db99e02 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/table.h +++ b/ASCOfficeOdfFileW/source/OdfFormat/table.h @@ -39,7 +39,6 @@ #include "office_elements_create.h" #include "tablevisibility.h" -#include "messagetype.h" #include "common_attlists.h" #include "tablemode.h" @@ -747,11 +746,11 @@ public: virtual void serialize(std::wostream & _Wostream); - _CP_OPT(std::wstring) table_title_; - _CP_OPT(odf_types::Bool) table_display_; - _CP_OPT(odf_types::message_type) table_message_type_; + _CP_OPT(std::wstring) table_title_; + _CP_OPT(odf_types::Bool) table_display_; + _CP_OPT(std::wstring) table_message_type_; - office_element_ptr_array content_; + office_element_ptr_array content_; }; CP_REGISTER_OFFICE_ELEMENT2(table_error_message); diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConvertDrawing.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConvertDrawing.cpp index be9f164b89..735aabe255 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConvertDrawing.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConvertDrawing.cpp @@ -36,7 +36,7 @@ #include "../utils.h" #include "../../../Common/DocxFormat/Source/DocxFormat/Diagram/DiagramDrawing.h" -#include "../../../Common/DocxFormat/Source/XlsxFormat/Chart/ChartDrawing.h" +#include "../../../Common/DocxFormat/Source/DocxFormat/ChartDrawing.h" #include "../../../Common/DocxFormat/Source/XlsxFormat/Chart/Chart.h" #include "../../../ASCOfficePPTXFile/PPTXFormat/Slide.h" #include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/SpTreeElem.h" @@ -105,7 +105,7 @@ void OoxConverter::convert(PPTX::Logic::GraphicFrame *oox_graphic_frame) { if (!oox_graphic_frame)return; - convert(oox_graphic_frame->nvGraphicFramePr.GetPointer()); + convert(&oox_graphic_frame->nvGraphicFramePr); convert(oox_graphic_frame->xfrm.GetPointer()); if ( oox_graphic_frame->chartRec.is_init()) @@ -381,8 +381,6 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture) odf_context()->drawing_context()->set_image_client_rect_inch( l * Width, t * Height, r * Width, b * Height ); } - - odf_context()->drawing_context()->start_area_properties(); if (oox_picture->blipFill.blip.IsInit()) { for (size_t i = 0 ; i < oox_picture->blipFill.blip->Effects.size(); i++) @@ -390,9 +388,7 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture) convert(oox_picture->blipFill.blip->Effects[i].Effect.GetPointer()); } } - odf_context()->drawing_context()->end_area_properties(); - - OoxConverter::convert(&oox_picture->nvPicPr.cNvPr); + OoxConverter::convert(&oox_picture->nvPicPr.cNvPr); OoxConverter::convert(&oox_picture->spPr, oox_picture->style.GetPointer()); } @@ -444,8 +440,8 @@ void OoxConverter::convert(PPTX::Logic::ChartRec *oox_chart) smart_ptr oFile = find_file_by_id (oox_chart->id_data->get()); if (oFile.IsInit()) { - OOX::Spreadsheet::CChartFile* pChart = dynamic_cast(oFile.GetPointer()); - OOX::Spreadsheet::CChartExFile* pChartEx = dynamic_cast(oFile.GetPointer()); + OOX::Spreadsheet::CChartSpace* pChart = dynamic_cast(oFile.GetPointer()); + OOX::Spreadsheet::CChartSpaceEx* pChartEx = dynamic_cast(oFile.GetPointer()); if (pChart || pChartEx) { @@ -1149,7 +1145,6 @@ void OoxConverter::convert(PPTX::Logic::BlipFill *oox_bitmap_fill) if (oox_bitmap_fill == NULL)return; odf_context()->drawing_context()->start_bitmap_style(); - odf_context()->drawing_context()->start_area_properties(); { double Width=0, Height = 0; if (oox_bitmap_fill->blip.IsInit()) @@ -1222,7 +1217,6 @@ void OoxConverter::convert(PPTX::Logic::BlipFill *oox_bitmap_fill) if (oox_bitmap_fill->stretch->fillRect.IsInit()){} //заполнение неполного объема } } - odf_context()->drawing_context()->end_area_properties(); odf_context()->drawing_context()->end_bitmap_style(); } void OoxConverter::convert(PPTX::Logic::GradFill *oox_grad_fill, DWORD nARGB) @@ -1402,15 +1396,7 @@ void OoxConverter::convert(PPTX::Logic::Ln *oox_line_prop, DWORD ARGB, PPTX::Log } if (oox_line_prop->w.IsInit()) { - int width = oox_line_prop->w.get(); - - if (width == 12700 && false == oox_line_prop->Fill.is_init()) - { - width = 0; - odf_context()->drawing_context()->set_no_fill(); - } - - odf_context()->drawing_context()->set_line_width(width / 12700.); //pt + odf_context()->drawing_context()->set_line_width(oox_line_prop->w.get() / 12700.); //pt } if (oox_line_prop->headEnd.IsInit()) { diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.cpp index 572a4541a7..84762d7964 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.cpp @@ -187,21 +187,21 @@ bool OoxConverter::encrypt_file (const std::wstring &password, const std::wstrin std::wstring sApplication = NSSystemUtils::GetEnvVariable(NSSystemUtils::gc_EnvMethodEncrypt); -// if (sApplication == L"Weak") -// { -////----------------------- -////blowfish -// cryptData.cipherAlgorithm = CRYPT_METHOD::Blowfish_CFB; -// cryptData.start_hashAlgorithm = CRYPT_METHOD::SHA1; -// cryptData.start_hashSize = 20; -// -// cryptData.spinCount = 1024; -// cryptData.keySize = 7;//16; -// -// cryptData.checksum_size = 1024; -// cryptData.checksum_hashAlgorithm = CRYPT_METHOD::SHA1; -// } -// else + if (sApplication == L"Weak") + { +//----------------------- +//blowfish + cryptData.cipherAlgorithm = CRYPT_METHOD::Blowfish_CFB; + cryptData.start_hashAlgorithm = CRYPT_METHOD::SHA1; + cryptData.start_hashSize = 20; + + cryptData.spinCount = 1024; + cryptData.keySize = 7;//16; + + cryptData.checksum_size = 1024; + cryptData.checksum_hashAlgorithm = CRYPT_METHOD::SHA1; + } + else { //----------------------- //aes diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp index 81ad1ed0cf..8a9c295767 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp @@ -2167,7 +2167,6 @@ void DocxConverter::convert(OOX::Logic::CBgPict *oox_bg_pict, int type) odf_writer::style_page_layout_properties *current_layout_properties = odt_context->page_layout_context()->last_layout()->get_properties(); odt_context->drawing_context()->end_drawing_background(current_layout_properties->attlist_.common_draw_fill_attlist_); - odt_context->drawing_context()->set_background_state(false); odt_context->end_drawings(); } void DocxConverter::convert(OOX::Logic::CBackground *oox_background, int type) @@ -2197,7 +2196,6 @@ void DocxConverter::convert(OOX::Logic::CBackground *oox_background, int type) odf_writer::style_page_layout_properties * current_layout_properties = odt_context->page_layout_context()->last_layout()->get_properties(); odt_context->drawing_context()->end_drawing_background(current_layout_properties->attlist_.common_draw_fill_attlist_); - odt_context->drawing_context()->set_background_state(false); odt_context->end_drawings(); } @@ -2875,19 +2873,6 @@ void DocxConverter::convert(OOX::Logic::CRunProperty *oox_run_pr, odf_writer::st if (oox_run_pr->m_oVanish.IsInit()) text_properties->content_.text_display_ = odf_types::text_display(odf_types::text_display::None); - if (oox_run_pr->m_oLang.IsInit()) - { - if (oox_run_pr->m_oLang->m_oVal.IsInit()) - { - std::wstring lang = oox_run_pr->m_oLang->m_oVal->GetValue(); - size_t split = lang.find(L"-"); - if (split != std::wstring::npos) - { - text_properties->content_.fo_language_ = lang.substr(0, split); - text_properties->content_.fo_country_ = lang.substr(split + 1); - } - } - } } void DocxConverter::convert(SimpleTypes::CTheme<>* oox_font_theme, _CP_OPT(std::wstring) & odf_font_name) @@ -4121,8 +4106,6 @@ void DocxConverter::convert(OOX::CStyle *oox_style) return; } - std::wstring oox_name_id = oox_style->m_sStyleId.get_value_or(L""); - bool bDefault = oox_style->m_oDefault.IsInit() && oox_style->m_oDefault->ToBool(); switch(oox_style->m_oType->GetValue()) { @@ -4131,14 +4114,10 @@ void DocxConverter::convert(OOX::CStyle *oox_style) default: return; } - if (bDefault && family == odf_types::style_family::Paragraph && oox_name_id != L"Standart") - { - //todooo ??? - //odt_context->sRenamedStyle = oox_name_id; - //oox_name_id = L"Standart"; - } - odt_context->styles_context()->create_style(oox_name_id, family, false, true, -1); + std::wstring oox_name_id = oox_style->m_sStyleId.get_value_or(L""); + + odt_context->styles_context()->create_style(oox_name_id, family, false, true, -1); std::wstring style_name; if (oox_style->m_oName.IsInit() && oox_style->m_oName->m_sVal.IsInit()) @@ -4146,20 +4125,18 @@ void DocxConverter::convert(OOX::CStyle *oox_style) style_name = *oox_style->m_oName->m_sVal; odt_context->styles_context()->last_state()->set_display_name(style_name); } - if (bDefault) - { - odt_context->styles_context()->last_state()->set_class(L"default"); - } + odf_writer::style_text_properties* text_properties = NULL; if (oox_style->m_oRunPr.IsInit()) { text_properties = odt_context->styles_context()->last_state()->get_text_properties(); - if (bDefault) + if (oox_style->m_oDefault.IsInit() && oox_style->m_oDefault->ToBool()) { + //основан на дефолтовом - накатить odf_writer::odf_style_state_ptr def_style_state; if (odt_context->styles_context()->find_odf_default_style_state(odf_types::style_family::Paragraph, def_style_state) && def_style_state) - {//?? + { odf_writer::style_text_properties * props = def_style_state->get_text_properties(); text_properties->apply_from(props); } @@ -4172,9 +4149,10 @@ void DocxConverter::convert(OOX::CStyle *oox_style) odf_writer::style_paragraph_properties *paragraph_properties = odt_context->styles_context()->last_state()->get_paragraph_properties(); if (oox_style->m_oDefault.IsInit() && oox_style->m_oDefault->ToBool()) { + //основан на дефолтовом - накатить odf_writer::odf_style_state_ptr def_style_state; if (odt_context->styles_context()->find_odf_default_style_state(odf_types::style_family::Paragraph, def_style_state) && def_style_state) - {//?? + { odf_writer::style_paragraph_properties *props = def_style_state->get_paragraph_properties(); paragraph_properties->apply_from(props); } diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/PptxConverter.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/PptxConverter.cpp index ab496f2448..bde34c48ea 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/PptxConverter.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/PptxConverter.cpp @@ -1449,7 +1449,6 @@ void PptxConverter::convert(PPTX::Logic::Bg *oox_background) //} odp_context->drawing_context()->end_drawing_background(page_props->content_.common_draw_fill_attlist_); - odp_context->drawing_context()->set_background_state(false); odp_context->end_drawings(); } @@ -1510,23 +1509,23 @@ void PptxConverter::convert_slide(PPTX::Logic::CSld *oox_slide, PPTX::Logic::TxS if (pPic.IsInit()) pPic->FillLevelUp(); } - int ph_type = 0; if (pNvPr->ph->type.IsInit()) { - ph_type = pNvPr->ph->type->GetBYTECode(); + int ph_type = pNvPr->ph->type->GetBYTECode(); if (type == Layout && (ph_type == 5 || ph_type == 6 || ph_type == 7 || ph_type == 12)) continue; + + odf_context()->drawing_context()->set_placeholder_type(ph_type); } + else + odf_context()->drawing_context()->set_placeholder_type(0); - if (!bPlaceholders) - continue; - - odf_context()->drawing_context()->set_placeholder_type(ph_type); - if (pNvPr->ph->idx.IsInit()) odf_context()->drawing_context()->set_placeholder_id(pNvPr->ph->idx.get()); + if (!bPlaceholders) + continue; PPTX::Logic::TextListStyle * listMasterStyle = NULL; diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp index a869901eb0..f417f6084e 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp @@ -898,12 +898,11 @@ void XlsxConverter::convert(OOX::Spreadsheet::CDataValidation *oox_validation) ods_context->set_data_validation_content(formula_1, formula_2); - ods_context->set_data_validation_error( oox_validation->m_oErrorTitle.IsInit() ? *oox_validation->m_oErrorTitle : L"", + ods_context->set_data_validation_error(oox_validation->m_oErrorTitle.IsInit() ? *oox_validation->m_oErrorTitle : L"", oox_validation->m_oError.IsInit() ? *oox_validation->m_oError : L"", - oox_validation->m_oShowErrorMessage.IsInit() ? oox_validation->m_oShowErrorMessage->ToBool() : true, - oox_validation->m_oErrorStyle.IsInit() ? oox_validation->m_oErrorStyle->GetValue() : SimpleTypes::Spreadsheet::errorStyleStop); + oox_validation->m_oShowErrorMessage.IsInit() ? oox_validation->m_oShowErrorMessage->ToBool() : true); - ods_context->set_data_validation_promt( oox_validation->m_oPromptTitle.IsInit() ? *oox_validation->m_oPromptTitle : L"", + ods_context->set_data_validation_promt(oox_validation->m_oPromptTitle.IsInit() ? *oox_validation->m_oPromptTitle : L"", oox_validation->m_oPrompt.IsInit() ? *oox_validation->m_oPrompt : L"", oox_validation->m_oShowInputMessage.IsInit() ? oox_validation->m_oShowInputMessage->ToBool() : true); ods_context->end_data_validation(); @@ -1160,9 +1159,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CRow *oox_row, OOX::Spreadsheet::C if (bEqual) { - int repeated = 1; - if ( ods_context->current_table()->is_row_comment(row_number, repeated) < 0 && - ods_context->current_table()->is_row_validation(row_number, repeated) < 0) + if ( ods_context->current_table()->is_row_comment(row_number, 1) < 0) { ods_context->add_row_repeated(); return; @@ -2832,23 +2829,20 @@ void XlsxConverter::convert(OOX::Spreadsheet::COleObjects *oox_objects, OOX::Spr OOX::Vml::CClientData* pClientData = static_cast(pChildElemShape); SimpleTypes::Spreadsheet::CCellAnchorType<> eAnchorType; - eAnchorType.SetValue(SimpleTypes::Spreadsheet::cellanchorTwoCell); + OOX::Spreadsheet::CCellAnchor *pCellAnchor = new OOX::Spreadsheet::CCellAnchor(eAnchorType); - OOX::Spreadsheet::CCellAnchor *pCellAnchor = new OOX::Spreadsheet::CCellAnchor(eAnchorType); - if (pClientData->toCellAnchor(pCellAnchor)) - { - oox_table_position from = {}, to = {}; - - convert(pCellAnchor->m_oFrom.GetPointer(), &from); - convert(pCellAnchor->m_oTo.GetPointer(), &to); - - double x1 = 0, y1 = 0, x2 = 0, y2 = 0; - ods_context->current_table()->convert_position(from, x1, y1); - ods_context->current_table()->convert_position(to, x2, y2); - - ods_context->drawing_context()->set_drawings_rect(x1, y1, x2 - x1, y2 - y1); - } + pClientData->toCellAnchor(pCellAnchor); + + oox_table_position from = {}, to = {}; + convert(pCellAnchor->m_oFrom.GetPointer(), &from); + convert(pCellAnchor->m_oTo.GetPointer(), &to); delete pCellAnchor; + + double x1 = 0, y1 = 0, x2 = 0, y2 = 0; + ods_context->current_table()->convert_position(from, x1, y1); + ods_context->current_table()->convert_position(to, x2, y2); + + ods_context->drawing_context()->set_drawings_rect(x1, y1, x2 - x1, y2 - y1); } if(OOX::et_v_imagedata == pChildElemShape->getType()) { @@ -2994,8 +2988,9 @@ void XlsxConverter::convert(OOX::Spreadsheet::CControls *oox_controls, OOX::Spre OOX::Vml::CClientData* pClientData = static_cast(pChildElemShape); if (!bSetAnchor ) - { - bSetAnchor = pClientData->toCellAnchor(oCellAnchor.GetPointer()); + { + pClientData->toCellAnchor(oCellAnchor.GetPointer()); + bSetAnchor = true; } pClientData->toFormControlPr(oFormControlPr.GetPointer()); } diff --git a/ASCOfficePPTXFile/ASCOfficeDrawingConverter.cpp b/ASCOfficePPTXFile/ASCOfficeDrawingConverter.cpp index f6fd44b9cc..2dc9febd6f 100644 --- a/ASCOfficePPTXFile/ASCOfficeDrawingConverter.cpp +++ b/ASCOfficePPTXFile/ASCOfficeDrawingConverter.cpp @@ -2083,8 +2083,7 @@ void CDrawingConverter::doc_LoadShape(PPTX::Logic::SpTreeElem *elem, XmlUtils::C PPTX::Logic::SpPr* pSpPr = NULL; PPTX::Logic::CNvPr* pCNvPr = NULL; - - if (bPicture && false == pPPTShape->m_oSignatureLine.IsInit()) + if (bPicture) { pPicture = new PPTX::Logic::Pic(); elem->InitElem(pPicture); @@ -5059,7 +5058,10 @@ HRESULT CDrawingConverter::SaveObject(LONG lStart, LONG lLength, const std::wstr bSignatureLine = true; } } + NSBinPptxRW::CXmlWriter oXmlWriter(m_pReader->m_nDocumentType); + + m_pReader->m_nDocumentType = XMLWRITER_DOC_TYPE_PPTX; oXmlWriter.m_lObjectIdVML = m_pXmlWriter->m_lObjectIdVML; oXmlWriter.m_lObjectIdOle = m_pXmlWriter->m_lObjectIdOle; @@ -5968,6 +5970,15 @@ HRESULT CDrawingConverter::GetAdditionalParam(const std::wstring& ParamName, BYT return S_OK; } +void CDrawingConverter::SetDocumentChartsCount (int val) +{ + m_pReader->m_lChartNumber = val + 1; +} +int CDrawingConverter::GetDocumentChartsCount () +{ + return m_pReader->m_lChartNumber - 1; +} + OOX::CContentTypes* CDrawingConverter::GetContentTypes() { return m_pImageManager->m_pContentTypes; diff --git a/ASCOfficePPTXFile/ASCOfficeDrawingConverter.h b/ASCOfficePPTXFile/ASCOfficeDrawingConverter.h index c9dd925c35..ad8da7beae 100644 --- a/ASCOfficePPTXFile/ASCOfficeDrawingConverter.h +++ b/ASCOfficePPTXFile/ASCOfficeDrawingConverter.h @@ -212,6 +212,7 @@ namespace NSBinPptxRW std::wstring m_strFontDirectory; CDrawingConverter(); + ~CDrawingConverter(); void SetRels(OOX::IFileContainer *container); @@ -264,6 +265,9 @@ namespace NSBinPptxRW void SetFontManager (NSFonts::IFontManager* pFontManager); + void SetDocumentChartsCount (int val); + int GetDocumentChartsCount (); + OOX::CContentTypes* GetContentTypes(); protected: nullable m_oxfrm_override; diff --git a/ASCOfficePPTXFile/Editor/BinReaderWriterDefines.h b/ASCOfficePPTXFile/Editor/BinReaderWriterDefines.h index d48b654733..c205317587 100644 --- a/ASCOfficePPTXFile/Editor/BinReaderWriterDefines.h +++ b/ASCOfficePPTXFile/Editor/BinReaderWriterDefines.h @@ -96,7 +96,6 @@ namespace NSBinPptxRW #define COLOR_TYPE_PRST 2 #define COLOR_TYPE_SCHEME 3 #define COLOR_TYPE_SYS 4 -#define COLOR_TYPE_STYLE 5 #define FILL_TYPE_NONE 0 #define FILL_TYPE_BLIP 1 diff --git a/ASCOfficePPTXFile/Editor/BinaryFileReaderWriter.cpp b/ASCOfficePPTXFile/Editor/BinaryFileReaderWriter.cpp index e58a0f94d3..903b910733 100644 --- a/ASCOfficePPTXFile/Editor/BinaryFileReaderWriter.cpp +++ b/ASCOfficePPTXFile/Editor/BinaryFileReaderWriter.cpp @@ -155,14 +155,6 @@ namespace NSBinPptxRW { return m_strDstMedia; } - void CImageManager2::SetDstCharts(const std::wstring& strDst) - { - m_strDstCharts = strDst; - } - std::wstring CImageManager2::GetDstCharts() - { - return m_strDstCharts; - } void CImageManager2::SetDstEmbed(const std::wstring& strDst) { m_strDstEmbed = strDst; @@ -1635,6 +1627,24 @@ namespace NSBinPptxRW m_mapImages.insert(std::pair(strImageRelsPath, oRelsGeneratorInfo)); return oRelsGeneratorInfo; } + unsigned int CRelsGenerator::WriteChart(int nChartNumber, _INT32 lDocType = XMLWRITER_DOC_TYPE_PPTX) + { + std::wstring strChart = L"charts/chart" + std::to_wstring(nChartNumber) + L".xml"; + + if (lDocType != XMLWRITER_DOC_TYPE_DOCX) + { + strChart = L"../" + strChart; + } + + std::wstring strRid = L"rId" + std::to_wstring(m_lNextRelsID++); + + std::wstring strRels = L""; + m_pWriter->WriteString(strRels); + + return m_lNextRelsID - 1; + } unsigned int CRelsGenerator::WriteRels(const std::wstring& bsType, const std::wstring& bsTarget, const std::wstring& bsTargetMode) { @@ -1691,6 +1701,7 @@ namespace NSBinPptxRW { m_pMainDocument = NULL; m_lNextId = 0; + m_lChartNumber = 1; m_nDocumentType = XMLWRITER_DOC_TYPE_PPTX; m_pRels = new CRelsGenerator(); diff --git a/ASCOfficePPTXFile/Editor/BinaryFileReaderWriter.h b/ASCOfficePPTXFile/Editor/BinaryFileReaderWriter.h index c386e7d208..6b4eb3e0bf 100644 --- a/ASCOfficePPTXFile/Editor/BinaryFileReaderWriter.h +++ b/ASCOfficePPTXFile/Editor/BinaryFileReaderWriter.h @@ -188,7 +188,6 @@ namespace NSBinPptxRW _INT32 m_lIndexNextImage; _INT32 m_lIndexCounter; - std::wstring m_strDstCharts; std::wstring m_strDstMedia; std::wstring m_strDstEmbed; std::wstring m_strDstFolder; @@ -205,9 +204,6 @@ namespace NSBinPptxRW void SetDstEmbed(const std::wstring& strDst); std::wstring GetDstEmbed(); - - void SetDstCharts(const std::wstring& strDst); - std::wstring GetDstCharts(); void SetDstFolder(const std::wstring& strDst); std::wstring GetDstFolder(); @@ -487,6 +483,7 @@ namespace NSBinPptxRW void WriteSlideComments (int nComment); void WritePresentationComments (int nComment); + unsigned int WriteChart (int nChartNumber, _INT32 lDocType); unsigned int WriteRels (const std::wstring& bsType, const std::wstring& bsTarget, const std::wstring& bsTargetMode); unsigned int WriteHyperlink (const std::wstring& strLink, const bool& bIsActionInit); @@ -515,8 +512,7 @@ namespace NSBinPptxRW std::wstring m_strFolderThemes; std::wstring m_strFolderExternalThemes; - _INT32 m_nCountEmbedded = 1; - _INT32 m_nCountCharts = 1; + _INT32 m_lChartNumber; BinDocxRW::CDocxSerializer* m_pMainDocument; int m_nDocumentType; diff --git a/ASCOfficePPTXFile/Editor/PPTXWriter.h b/ASCOfficePPTXFile/Editor/PPTXWriter.h index a43344f184..514efa3e33 100644 --- a/ASCOfficePPTXFile/Editor/PPTXWriter.h +++ b/ASCOfficePPTXFile/Editor/PPTXWriter.h @@ -107,14 +107,14 @@ namespace NSBinPptxRW m_oImageManager.SetDstFolder(pathPPT.GetPath()); OOX::CPath pathMedia = pathPPT / _T("media"); - m_oImageManager.SetDstMedia(pathMedia.GetPath()); NSDirectory::CreateDirectory(pathMedia.GetPath()); - OOX::CPath pathCharts = pathPPT / _T("charts"); - m_oImageManager.SetDstCharts(pathCharts.GetPath()); + m_oImageManager.SetDstMedia(pathMedia.GetPath()); - OOX::CPath pathEmbeddings = pathPPT / _T("embeddings"); - m_oImageManager.SetDstEmbed(pathEmbeddings.GetPath()); + OOX::CPath pathEmbeddings = pathPPT / _T("embeddings"); + NSDirectory::CreateDirectory(pathEmbeddings.GetPath()); + + m_oImageManager.SetDstEmbed(pathEmbeddings.GetPath()); m_oReader.m_pRels->m_pManager = &m_oImageManager; diff --git a/ASCOfficePPTXFile/PPTXFormat/FileFactory.cpp b/ASCOfficePPTXFile/PPTXFormat/FileFactory.cpp index c206ddf0f9..5e8f3c5063 100644 --- a/ASCOfficePPTXFile/PPTXFormat/FileFactory.cpp +++ b/ASCOfficePPTXFile/PPTXFormat/FileFactory.cpp @@ -55,8 +55,8 @@ #include "../../Common/DocxFormat/Source/DocxFormat/Rels.h" #include "../../Common/DocxFormat/Source/DocxFormat/FileTypes.h" #include "../../Common/DocxFormat/Source/XlsxFormat/Chart/Chart.h" -#include "../../Common/DocxFormat/Source/XlsxFormat/Chart/ChartDrawing.h" #include "../../Common/DocxFormat/Source/DocxFormat/VmlDrawing.h" +#include "../../Common/DocxFormat/Source/DocxFormat/ChartDrawing.h" #include "../../Common/DocxFormat/Source/DocxFormat/Diagram/DiagramData.h" #include "../../Common/DocxFormat/Source/DocxFormat/Diagram/DiagramDrawing.h" #include "../../Common/DocxFormat/Source/DocxFormat/Media/Image.h" @@ -121,13 +121,13 @@ namespace PPTX return smart_ptr(new PPTX::Comments(pMain, filename, map)); else if (relation.Type() == OOX::FileTypes::Chart) - return smart_ptr(new OOX::Spreadsheet::CChartFile(pMain, filename, filename)); + return smart_ptr(new OOX::Spreadsheet::CChartSpace(pMain, filename, filename)); else if (relation.Type() == OOX::FileTypes::ChartEx) - return smart_ptr(new OOX::Spreadsheet::CChartExFile(pMain, filename, filename)); + return smart_ptr(new OOX::Spreadsheet::CChartSpaceEx(pMain, filename, filename)); else if (relation.Type() == OOX::FileTypes::ChartStyle) - return smart_ptr(new OOX::Spreadsheet::CChartStyleFile(pMain, filename, filename)); - else if (relation.Type() == OOX::FileTypes::ChartColors) - return smart_ptr(new OOX::Spreadsheet::CChartColorsFile(pMain, filename, filename)); + return smart_ptr(new OOX::Spreadsheet::CChartStyle(pMain, filename, filename)); + else if (relation.Type() == OOX::FileTypes::ChartColorStyle) + return smart_ptr(new OOX::Spreadsheet::CChartColorStyle(pMain, filename, filename)); else if (relation.Type() == OOX::FileTypes::HyperLink) return smart_ptr(new OOX::HyperLink(pMain, relation.Target())); else if (relation.Type() == OOX::FileTypes::Image) diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/CNvPr.h b/ASCOfficePPTXFile/PPTXFormat/Logic/CNvPr.h index 8fb87b97fd..cda145247c 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/CNvPr.h +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/CNvPr.h @@ -314,7 +314,7 @@ namespace PPTX std::wstring m_namespace; - int id = -1; + int id; std::wstring name; nullable_string descr; nullable_bool hidden; diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/Colors/ColorBase.h b/ASCOfficePPTXFile/PPTXFormat/Logic/Colors/ColorBase.h index 9ab336d9da..766cfc6f84 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/Colors/ColorBase.h +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/Colors/ColorBase.h @@ -76,10 +76,12 @@ namespace PPTX luminance = oSrc.luminance; return *this; } + virtual ~ColorBase() { } + public: //Эти функции возвращают цвет с учетом модификаторов virtual DWORD GetRGBA(DWORD RGBA) const { @@ -377,6 +379,16 @@ namespace PPTX } return 0; } + + public: + //origin color + unsigned char alpha; + unsigned char red; + unsigned char green; + unsigned char blue; + unsigned char hue; + unsigned char saturation; + unsigned char luminance; //Эти функции использовать для заполнения "origin color" void SetRGB2HSL() { @@ -533,6 +545,7 @@ namespace PPTX summa += HexChar2Int((char)value[i]) << (4 * (value.length() - i - 1)); return summa; } + public: void SetHexString(const std::wstring& val) { if (val.length() == 6) @@ -548,6 +561,10 @@ namespace PPTX blue = HexString2Int(val.substr(2, 1) + val.substr(2, 1)); } } + + std::vector Modifiers; + + public: void ReadModsFromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) { LONG _start = pReader->GetPos(); @@ -599,20 +616,8 @@ namespace PPTX pReader->Seek(_end); } - - //origin color - unsigned char alpha; - unsigned char red; - unsigned char green; - unsigned char blue; - unsigned char hue; - unsigned char saturation; - unsigned char luminance; - - std::vector Modifiers; friend class UniColor; - std::wstring m_namespace; }; } // namespace Logic } // namespace PPTX diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/Colors/ColorModifier.h b/ASCOfficePPTXFile/PPTXFormat/Logic/Colors/ColorModifier.h index a8682e234f..9f812ef8fa 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/Colors/ColorModifier.h +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/Colors/ColorModifier.h @@ -30,6 +30,9 @@ * */ #pragma once +#ifndef PPTX_LOGIC_COLORMODIFIER_INCLUDE_H_ +#define PPTX_LOGIC_COLORMODIFIER_INCLUDE_H_ + #include "./../../WrapperWritingElement.h" namespace PPTX @@ -83,7 +86,7 @@ namespace PPTX } virtual void fromXML(XmlUtils::CXmlNode& node) { - name = node.GetName(); + name = node.GetName(); XmlMacroReadAttributeBase(node, L"val", val); if (XmlUtils::GetNameNoNS(name) == _T("alpha")) @@ -119,50 +122,32 @@ namespace PPTX pWriter->WriteInt2(1, val); pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); } - virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) - { - 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; - - if (0 == _at) - name = pReader->GetString2(); - else if (1 == _at) - val = pReader->GetLong(); - else - break; - } - pReader->Seek(_end_rec); - } virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const { std::wstring _name; std::wstring sAttrNamespace; if (XMLWRITER_DOC_TYPE_WORDART == pWriter->m_lDocType) { - _name = L"w14:" + XmlUtils::GetNameNoNS(name); - sAttrNamespace = L"w14:"; + _name = _T("w14:") + XmlUtils::GetNameNoNS(name); + sAttrNamespace = _T("w14:"); } else _name = name; pWriter->StartNode(_name); pWriter->StartAttributes(); - pWriter->WriteAttribute(sAttrNamespace + L"val", val); + pWriter->WriteAttribute(sAttrNamespace + _T("val"), val); pWriter->EndAttributes(); pWriter->EndNode(_name); } public: - std::wstring name; + std::wstring name; nullable_int val; protected: virtual void FillParentPointersForChilds(){}; }; } // namespace Logic -} // namespace PPTX \ No newline at end of file +} // namespace PPTX + +#endif // PPTX_LOGIC_COLORMODIFIER_INCLUDE_H diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SchemeClr.cpp b/ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SchemeClr.cpp index f38947dbcb..cb629cbce1 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SchemeClr.cpp +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SchemeClr.cpp @@ -77,53 +77,6 @@ namespace PPTX return XmlUtils::CreateNode(_T("a:schemeClr"), oAttr, oValue); } - void SchemeClr::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - std::wstring sNodeNamespace; - std::wstring sAttrNamespace; - if (XMLWRITER_DOC_TYPE_WORDART == pWriter->m_lDocType) - { - sNodeNamespace = _T("w14:"); - sAttrNamespace = sNodeNamespace; - } - else - sNodeNamespace = _T("a:"); - pWriter->StartNode(sNodeNamespace + _T("schemeClr")); - - pWriter->StartAttributes(); - pWriter->WriteAttribute(sAttrNamespace + _T("val"), val.get()); - pWriter->EndAttributes(); - - size_t nCount = Modifiers.size(); - for (size_t i = 0; i < nCount; ++i) - Modifiers[i].toXmlWriter(pWriter); - - pWriter->EndNode(sNodeNamespace + _T("schemeClr")); - } - void SchemeClr::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->StartRecord(COLOR_TYPE_SCHEME); - - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - pWriter->WriteLimit1(0, val); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - - ULONG len = (ULONG)Modifiers.size(); - if (len != 0) - { - pWriter->StartRecord(0); - pWriter->WriteULONG(len); - - for (ULONG i = 0; i < len; ++i) - { - pWriter->WriteRecord1(1, Modifiers[i]); - } - - pWriter->EndRecord(); - } - - pWriter->EndRecord(); - } DWORD SchemeClr::GetRGBA(DWORD RGBA) const { @@ -233,90 +186,5 @@ namespace PPTX red = static_cast((RGB & 0xFF0000)>>16); alpha = static_cast((RGB & 0xFF000000)>>24); } -//-------------------------------------------------------------------------------- - void StyleClr::fromXML(XmlUtils::CXmlNode& node) - { - std::wstring sVal = node.GetAttribute(_T("val")); - - if (sVal == L"auto") bAuto = true; - else if (false == sVal.empty()) val = sVal; - - Modifiers.clear(); - XmlMacroLoadArray(node, _T("*"), Modifiers, ColorModifier); - } - void StyleClr::fromXML(XmlUtils::CXmlLiteReader& oReader) - { - ReadAttributes(oReader); - - if (oReader.IsEmptyNode()) - return; - - int nCurDepth = oReader.GetDepth(); - while (oReader.ReadNextSiblingNode(nCurDepth)) - { - std::wstring strName = oReader.GetName(); - - ColorModifier m; - Modifiers.push_back(m); - Modifiers.back().fromXML(oReader); - } - } - std::wstring StyleClr::toXML() const - { - XmlUtils::CNodeValue oValue; - oValue.WriteArray(Modifiers); - - XmlUtils::CAttribute oAttr; - if (val.IsInit()) - oAttr.Write(L"val", std::to_wstring(*val)); - else if (bAuto) - oAttr.Write(L"val", std::wstring(L"auto")); - - return XmlUtils::CreateNode(L"cs:styleClr", oAttr, oValue); - } - void StyleClr::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const - { - pWriter->StartNode(L"cs:styleClr"); - - pWriter->StartAttributes(); - if (val.IsInit()) - pWriter->WriteAttribute(L"val", std::to_wstring(*val)); - else if (bAuto) - pWriter->WriteAttribute(L"val", std::wstring(L"auto")); - pWriter->EndAttributes(); - - for (size_t i = 0; i < Modifiers.size(); ++i) - Modifiers[i].toXmlWriter(pWriter); - - pWriter->EndNode(L"cs:styleClr"); - } - void StyleClr::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const - { - pWriter->StartRecord(COLOR_TYPE_STYLE); - - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - if (val.IsInit()) - pWriter->WriteUInt2(0, val); - else - pWriter->WriteBool1(1, bAuto); - pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - - ULONG len = (ULONG)Modifiers.size(); - if (len != 0) - { - pWriter->StartRecord(0); - pWriter->WriteULONG(len); - - for (ULONG i = 0; i < len; ++i) - { - pWriter->WriteRecord1(1, Modifiers[i]); - } - - pWriter->EndRecord(); - } - - pWriter->EndRecord(); - } - } // namespace Logic } // namespace PPTX diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SchemeClr.h b/ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SchemeClr.h index a185f586d6..b433c54c92 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SchemeClr.h +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SchemeClr.h @@ -30,6 +30,8 @@ * */ #pragma once +#ifndef PPTX_LOGIC_SCHEMECLR_INCLUDE_H_ +#define PPTX_LOGIC_SCHEMECLR_INCLUDE_H_ #include "./../../Limit/SchemeClrVal.h" #include "./../../Theme/ClrScheme.h" @@ -60,7 +62,29 @@ namespace PPTX WritingElement_ReadAttributes_Read_if ( oReader, _T("val"), val) WritingElement_ReadAttributes_End_No_NS( oReader ) } - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; + virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const + { + std::wstring sNodeNamespace; + std::wstring sAttrNamespace; + if (XMLWRITER_DOC_TYPE_WORDART == pWriter->m_lDocType) + { + sNodeNamespace = _T("w14:"); + sAttrNamespace = sNodeNamespace; + } + else + sNodeNamespace = _T("a:"); + pWriter->StartNode(sNodeNamespace + _T("schemeClr")); + + pWriter->StartAttributes(); + pWriter->WriteAttribute(sAttrNamespace + _T("val"), val.get()); + pWriter->EndAttributes(); + + size_t nCount = Modifiers.size(); + for (size_t i = 0; i < nCount; ++i) + Modifiers[i].toXmlWriter(pWriter); + + pWriter->EndNode(sNodeNamespace + _T("schemeClr")); + } virtual DWORD GetRGBA(DWORD RGBA) const; virtual DWORD GetARGB(DWORD ARGB) const; @@ -69,7 +93,30 @@ namespace PPTX virtual DWORD GetRGBColor(NSCommon::smart_ptr& _oTheme, NSCommon::smart_ptr& _oClrMap, DWORD ARGB = 0); - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; + virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const + { + pWriter->StartRecord(COLOR_TYPE_SCHEME); + + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); + pWriter->WriteLimit1(0, val); + pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); + + ULONG len = (ULONG)Modifiers.size(); + if (len != 0) + { + pWriter->StartRecord(0); + pWriter->WriteULONG(len); + + for (ULONG i = 0; i < len; ++i) + { + pWriter->WriteRecord1(1, Modifiers[i]); + } + + pWriter->EndRecord(); + } + + pWriter->EndRecord(); + } public: Limit::SchemeClrVal val; @@ -79,43 +126,7 @@ namespace PPTX protected: virtual void FillParentPointersForChilds(){}; }; - class StyleClr : public ColorBase - { - public: - WritingElement_AdditionConstructors(StyleClr) - PPTX_LOGIC_BASE2(StyleClr) - - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - virtual void fromXML(XmlUtils::CXmlNode& node); - virtual std::wstring toXML() const; - - virtual OOX::EElementType getType() const - { - return OOX::et_a_styleClr; - } - - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - nullable_string sVal; - - WritingElement_ReadAttributes_Start_No_NS(oReader) - WritingElement_ReadAttributes_Read_if(oReader, L"val", sVal) - WritingElement_ReadAttributes_End_No_NS(oReader) - - if (sVal.IsInit()) - { - if (*sVal == L"auto") bAuto = true; - else - val = *sVal; - } - } - virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const; - virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const; - - nullable_uint val; - bool bAuto = false; - protected: - virtual void FillParentPointersForChilds() {}; - }; } // namespace Logic } // namespace PPTX + +#endif // PPTX_LOGIC_SCHEMECLR_INCLUDE_H \ No newline at end of file diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SrgbClr.h b/ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SrgbClr.h index b542d181d5..ea0c3afb62 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SrgbClr.h +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SrgbClr.h @@ -30,6 +30,8 @@ * */ #pragma once +#ifndef PPTX_LOGIC_SRGBCLR_INCLUDE_H_ +#define PPTX_LOGIC_SRGBCLR_INCLUDE_H_ #include "ColorBase.h" #include @@ -54,7 +56,7 @@ namespace PPTX std::wstring val; WritingElement_ReadAttributes_Start_No_NS( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, _T("val"), val) + WritingElement_ReadAttributes_Read_if ( oReader, _T("val"), val) WritingElement_ReadAttributes_End_No_NS( oReader ) if (6 == val.length()) @@ -193,3 +195,4 @@ namespace PPTX } // namespace Logic } // namespace PPTX +#endif // PPTX_LOGIC_SRGBCLR_INCLUDE_H diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SysClr.h b/ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SysClr.h index 62c8729d8c..9d763b9d1e 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SysClr.h +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SysClr.h @@ -30,11 +30,15 @@ * */ #pragma once +#ifndef PPTX_LOGIC_SYSCLR_INCLUDE_H_ +#define PPTX_LOGIC_SYSCLR_INCLUDE_H_ #include "ColorBase.h" #include "./../../Limit/SysClrVal.h" #include "../../../../Common/DocxFormat/Source/Base/ASCWinAPI.h" // GetSysColor + + namespace PPTX { namespace Logic @@ -263,3 +267,4 @@ namespace PPTX } // namespace Logic } // namespace PPTX +#endif // PPTX_LOGIC_SYSCLR_INCLUDE_H diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/ExtP.h b/ASCOfficePPTXFile/PPTXFormat/Logic/ExtP.h index 1d55ba19e7..e0d88669f6 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/ExtP.h +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/ExtP.h @@ -238,7 +238,7 @@ namespace PPTX } if (sectionLst.IsInit()) { - pWriter->StartNode(namespace_ext + L":ext"); + pWriter->StartNode(namespace_ext + L"ext"); pWriter->StartAttributes(); pWriter->WriteAttribute(L"uri", std::wstring(L"{521415D9-36F7-43E2-AB2F-B90AF26B5E84}")); pWriter->EndAttributes(); diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/Fills/Blip.h b/ASCOfficePPTXFile/PPTXFormat/Logic/Fills/Blip.h index 36a95e4ecb..dd45cdd328 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/Fills/Blip.h +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/Fills/Blip.h @@ -102,8 +102,6 @@ namespace PPTX nullable embed; nullable link; std::wstring m_namespace; - - std::wstring imageFilepath; //internal std::wstring mediaRid; std::wstring mediaFilepath; diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/Fills/BlipFill.cpp b/ASCOfficePPTXFile/PPTXFormat/Logic/Fills/BlipFill.cpp index aa0cee3341..02f11523fd 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/Fills/BlipFill.cpp +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/Fills/BlipFill.cpp @@ -387,7 +387,6 @@ namespace PPTX if (oRelsGeneratorInfo.nImageRId > 0) { blip->embed = new OOX::RId(oRelsGeneratorInfo.nImageRId); - blip->imageFilepath = oRelsGeneratorInfo.sFilepathImage; } if(oRelsGeneratorInfo.nOleRId > 0) diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/GraphicFrame.cpp b/ASCOfficePPTXFile/PPTXFormat/Logic/GraphicFrame.cpp index 1df1957092..23e38ff9bc 100755 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/GraphicFrame.cpp +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/GraphicFrame.cpp @@ -52,7 +52,7 @@ namespace PPTX }; namespace Logic { - GraphicFrame::GraphicFrame(std::wstring ns) + GraphicFrame::GraphicFrame(std::wstring ns) : nvGraphicFramePr(ns) { m_namespace = ns; } @@ -133,15 +133,10 @@ namespace PPTX if (L"xfrm" == strName) xfrm = oReader; else if (L"cNvGraphicFramePr" == strName) - { - if (!nvGraphicFramePr.IsInit()) - nvGraphicFramePr.Init(); - nvGraphicFramePr->cNvGraphicFramePr.fromXML(oReader); - } + nvGraphicFramePr.cNvGraphicFramePr.fromXML( oReader ); else if (L"nvGraphicFramePr" == strName) - { - nvGraphicFramePr = oReader; - } + nvGraphicFramePr.fromXML( oReader ); + else if (L"graphic" == strName) { int nCurDepth = oReader.GetDepth(); @@ -384,15 +379,14 @@ namespace PPTX } void GraphicFrame::toXmlWriter2(NSBinPptxRW::CXmlWriter* pWriter) const { - if (nvGraphicFramePr.IsInit()) - nvGraphicFramePr->toXmlWriter(pWriter); + nvGraphicFramePr.toXmlWriter(pWriter); if (xfrm.IsInit() && (!(pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) || pWriter->m_lGroupIndex >= 0)) { if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX && pWriter->m_lGroupIndex >= 0) xfrm->m_ns = L"xdr"; else if ((pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX || - pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) && pWriter->m_lGroupIndex >= 0) xfrm->m_ns = L"wpg"; + pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) && pWriter->m_lGroupIndex >= 0) xfrm->m_ns = L"wpg"; else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_GRAPHICS) xfrm->m_ns = L"a"; else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_CHART_DRAWING) xfrm->m_ns = L"cdr"; @@ -406,9 +400,7 @@ namespace PPTX } else if (chartRec.is_init()) { - std::wstring sUri = chartRec->m_bChartEx ? L"http://schemas.microsoft.com/office/drawing/2014/chartex" : L"http://schemas.openxmlformats.org/drawingml/2006/chart"; - - pWriter->WriteString(L""); + pWriter->WriteString(L""); chartRec->toXmlWriter(pWriter); pWriter->WriteString(L""); } @@ -474,11 +466,8 @@ namespace PPTX if (smartArt->m_diag.is_init()) { - if (nvGraphicFramePr.IsInit()) - { - smartArt->m_diag->nvGrpSpPr.cNvPr = nvGraphicFramePr->cNvPr; - smartArt->m_diag->nvGrpSpPr.nvPr = nvGraphicFramePr->nvPr; - } + smartArt->m_diag->nvGrpSpPr.cNvPr = nvGraphicFramePr.cNvPr; + smartArt->m_diag->nvGrpSpPr.nvPr = nvGraphicFramePr.nvPr; bool bIsInitCoords = false; if (smartArt->m_diag->grpSpPr.xfrm.IsInit()) @@ -557,7 +546,7 @@ namespace PPTX pWriter->WriteString2(0, vmlSpid); pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd); - pWriter->WriteRecord2(0, nvGraphicFramePr); + pWriter->WriteRecord1(0, nvGraphicFramePr); pWriter->WriteRecord2(1, xfrm); if (table.is_init()) @@ -568,7 +557,7 @@ namespace PPTX { if (chartRec->m_bChartEx) { - pWriter->WriteRecord2(7, chartRec); + pWriter->WriteRecord2(4, chartRec); } else { @@ -618,6 +607,8 @@ namespace PPTX } } + nvGraphicFramePr.cNvPr.id = -1; + while (pReader->GetPos() < _end_rec) { BYTE _at = pReader->GetUChar(); @@ -625,8 +616,7 @@ namespace PPTX { case 0: { - nvGraphicFramePr.Init(); - nvGraphicFramePr->fromPPTY(pReader); + nvGraphicFramePr.fromPPTY(pReader); }break; case 1: { @@ -643,10 +633,12 @@ namespace PPTX { chartRec = new Logic::ChartRec(); chartRec->fromPPTY(pReader); - }break; + }break; case 4: { - element.fromPPTY(pReader); + chartRec = new Logic::ChartRec(); + chartRec->m_bChartEx = true; + chartRec->fromPPTY(pReader); }break; case 5: { @@ -658,12 +650,6 @@ namespace PPTX slicerExt = new OOX::Spreadsheet::CDrawingSlicer(); slicerExt->fromPPTY(pReader); }break; - case 7: - { - chartRec = new Logic::ChartRec(); - chartRec->m_bChartEx = true; - chartRec->fromPPTY(pReader); - }break; default: pReader->SkipRecord(); break; @@ -694,9 +680,7 @@ namespace PPTX std::wstring GraphicFrame::toXML2() const { std::wstring sXml; - - if (nvGraphicFramePr.IsInit()) - sXml += nvGraphicFramePr->toXML(); + sXml += nvGraphicFramePr.toXML(); if (xfrm.IsInit() && m_namespace != L"wp") { @@ -705,27 +689,25 @@ namespace PPTX if (table.IsInit()) { - sXml += L""; + sXml += L""; sXml += table->toXML(); sXml += L""; } else if (chartRec.IsInit()) { - std::wstring sUri = chartRec->m_bChartEx ? L"http://schemas.microsoft.com/office/drawing/2014/chartex" : L"http://schemas.openxmlformats.org/drawingml/2006/chart"; - - sXml += L""; + sXml += L""; sXml += chartRec->toXML(); sXml += L""; } else if (slicer.IsInit()) { - sXml += L""; + sXml += L""; sXml += slicer->toXML(); sXml += L""; } else if (slicerExt.IsInit()) { - sXml += L""; + sXml += L""; sXml += slicerExt->toXML(); sXml += L""; } @@ -747,12 +729,13 @@ namespace PPTX void GraphicFrame::FillParentPointersForChilds() { - if (nvGraphicFramePr.is_init()) nvGraphicFramePr->SetParentPointer(this); - if (xfrm.IsInit()) xfrm->SetParentPointer(this); - if (table.IsInit()) table->SetParentPointer(this); - if (smartArt.is_init()) smartArt->SetParentPointer(this); - if (chartRec.is_init()) chartRec->SetParentPointer(this); - if (olePic.is_init()) olePic->SetParentPointer(this); + nvGraphicFramePr.SetParentPointer(this); + + if (xfrm.IsInit()) xfrm->SetParentPointer(this); + if (table.IsInit()) table->SetParentPointer(this); + if (smartArt.is_init()) smartArt->SetParentPointer(this); + if (chartRec.is_init()) chartRec->SetParentPointer(this); + if (olePic.is_init()) olePic->SetParentPointer(this); } std::wstring GraphicFrame::GetVmlXmlBySpid(smart_ptr & rels)const { @@ -901,7 +884,7 @@ namespace PPTX if(parentFileIs()) file = parentFileAs().Find(*chartRec->id_data); else if (pRels != NULL) file = pRels->Find(*chartRec->id_data); } - smart_ptr pChart = file.smart_dynamic_cast(); + smart_ptr pChart = file.smart_dynamic_cast(); if (pChart.IsInit() == false) return L""; diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/GraphicFrame.h b/ASCOfficePPTXFile/PPTXFormat/Logic/GraphicFrame.h index 4c2fbdd164..d3c9ac3526 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/GraphicFrame.h +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/GraphicFrame.h @@ -85,7 +85,7 @@ namespace PPTX std::wstring m_namespace; - nullable nvGraphicFramePr; + NvGraphicFramePr nvGraphicFramePr; nullable xfrm; diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/Pic.cpp b/ASCOfficePPTXFile/PPTXFormat/Logic/Pic.cpp index 03119a4f8f..5863776fb8 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/Pic.cpp +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/Pic.cpp @@ -341,7 +341,7 @@ namespace PPTX oDrawingConverter.SetMainDocument(&oDocxSerializer); //oDocxSerializer.m_pParamsWriter = new BinDocxRW::ParamsWriter(oDrawingConverter.m_pBinaryWriter, &oFontProcessor, &oDrawingConverter, NULL); - oDocxSerializer.m_pCurFileWriter = new Writers::FileWriter(L"", L"", false, 111, &oDrawingConverter, L""); + oDocxSerializer.m_pCurFileWriter = new Writers::FileWriter(L"", L"", false, 111, false, &oDrawingConverter, L""); oDocxSerializer.getXmlContentElem(OOX::et_m_oMathPara, *pReader, sXmlContent); } @@ -355,7 +355,7 @@ namespace PPTX { m_OleObjectFile = new OOX::OleObject(NULL, true, pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX); - int id = pReader->m_nCountEmbedded++; + int id = pReader->m_lChartNumber++; //todoooo -> countEmbeddedObjects BinDocxRW::CDocxSerializer oDocxSerializer; NSBinPptxRW::CDrawingConverter oDrawingConverter; @@ -377,7 +377,7 @@ namespace PPTX NSBinPptxRW::CBinaryFileReader& oBufferedStream = *oDrawingConverter.m_pReader; - oDocxSerializer.m_pCurFileWriter = new Writers::FileWriter(sDstEmbeddedTemp, L"", false, 111, &oDrawingConverter, sThemePath); + oDocxSerializer.m_pCurFileWriter = new Writers::FileWriter(sDstEmbeddedTemp, L"", false, 111, false, &oDrawingConverter, sThemePath); BinDocxRW::BinaryFileReader oBinaryFileReader(pReader->m_strFolder, oBufferedStream, *oDocxSerializer.m_pCurFileWriter); oBinaryFileReader.ReadFile(); @@ -418,7 +418,7 @@ namespace PPTX { m_OleObjectFile = new OOX::OleObject(NULL, true, pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX); - int id = pReader->m_nCountEmbedded++; //todoooo -> countEmbeddedObjects + int id = pReader->m_lChartNumber++; //todoooo -> countEmbeddedObjects OOX::Spreadsheet::CXlsx oXlsx; BinXlsxRW::BinaryFileReader oEmbeddedReader; @@ -426,9 +426,8 @@ namespace PPTX std::wstring sDrawingsPath = sDstEmbeddedTemp + FILE_SEPARATOR_STR + L"xl" + FILE_SEPARATOR_STR + L"drawings"; std::wstring sThemePath = sDstEmbeddedTemp + FILE_SEPARATOR_STR + L"xl" + FILE_SEPARATOR_STR + L"theme"; - std::wstring sEmbeddingsPath = sDstEmbeddedTemp + FILE_SEPARATOR_STR + L"xl" + FILE_SEPARATOR_STR + L"embeddings"; - BinXlsxRW::SaveParams oSaveParams(sDrawingsPath, sEmbeddingsPath, sThemePath, oDrawingConverter.GetContentTypes()); + BinXlsxRW::SaveParams oSaveParams(sDrawingsPath, sThemePath, oDrawingConverter.GetContentTypes()); std::wstring sXmlOptions, sMediaPath, sEmbedPath; BinXlsxRW::CXlsxSerializer::CreateXlsxFolders (sXmlOptions, sDstEmbeddedTemp, sMediaPath, sEmbedPath); diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/Runs/MathParaWrapper.cpp b/ASCOfficePPTXFile/PPTXFormat/Logic/Runs/MathParaWrapper.cpp index 34ca73be70..454e03a5bc 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/Runs/MathParaWrapper.cpp +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/Runs/MathParaWrapper.cpp @@ -210,7 +210,7 @@ xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\">\ oDrawingConverter.m_pImageManager = pReader->m_pRels->m_pManager; oDrawingConverter.m_pReader = pReader; - oDocxSerializer.m_pCurFileWriter = new Writers::FileWriter(L"", L"", true, BinDocxRW::g_nFormatVersion, &oDrawingConverter, L""); + oDocxSerializer.m_pCurFileWriter = new Writers::FileWriter(L"", L"", true, BinDocxRW::g_nFormatVersion, false, &oDrawingConverter, L""); oDocxSerializer.getXmlContentElem(eType, *pReader, sXml); oDrawingConverter.m_pReader = pOldReader; diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/Shape.cpp b/ASCOfficePPTXFile/PPTXFormat/Logic/Shape.cpp index a7488fa812..ad021da164 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/Shape.cpp +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/Shape.cpp @@ -619,7 +619,7 @@ namespace PPTX lH = spPr.xfrm->extY.get_value_or(43200); } - spPr.Geometry.ConvertToCustomVML(pWriter->m_pOOXToVMLRenderer, strPath, strTextRect, lW, lH ); + spPr.Geometry.ConvertToCustomVML(pWriter->m_pOOXToVMLRenderer, strPath, strTextRect, lW, lH); std::wstring strId = L"shape " + std::to_wstring(pWriter->m_lObjectIdVML); std::wstring strSpid = L"_x0000_s" + std::to_wstring(pWriter->m_lObjectIdVML); @@ -632,7 +632,7 @@ namespace PPTX std::wstring strStrokeNode;; CalculateFill(spPr, style, oTheme, oClrMap, strFillAttr, strFillNode, false, bSignature); - CalculateLine(spPr, style, oTheme, oClrMap, strStrokeAttr, strStrokeNode, false); + CalculateLine(spPr, style, oTheme, oClrMap, strStrokeAttr, strStrokeNode, false, bSignature); pWriter->StartNode(L"v:shape"); @@ -763,32 +763,11 @@ namespace PPTX pWriter->WriteString(*strTextBoxShape); //??? todooo -> oTextBoxShape pWriter->EndNode(L"v:textbox"); } - if (spPr.Fill.m_type == UniFill::blipFill) - { - BlipFill& blipFill = spPr.Fill.as(); - - pWriter->StartNode(L"v:imagedata"); - pWriter->StartAttributes(); - if (XMLWRITER_DOC_TYPE_XLSX == pWriter->m_lDocType) - { - pWriter->WriteAttribute(L"o:relid", blipFill.blip->embed->ToString()); - } - else - { - pWriter->WriteAttribute(L"r:id", blipFill.blip->embed->ToString()); - } - pWriter->WriteAttribute(L"o:title", L""); - pWriter->EndAttributes(); - pWriter->EndNode(L"v:imagedata"); - } - if (signatureLine.is_init()) { signatureLine->toXmlWriter(pWriter); } - pWriter->WriteString(m_sClientDataXml); - pWriter->EndNode(L"v:shape"); pWriter->m_strStyleMain.clear(); diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/Shape.h b/ASCOfficePPTXFile/PPTXFormat/Logic/Shape.h index b9ce6909da..e9bc6e7897 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/Shape.h +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/Shape.h @@ -333,9 +333,7 @@ namespace PPTX nullable oTextBoxBodyPr; nullable_bool attrUseBgFill; -//------------------------------------------------------------------------------------------------- nullable signatureLine; - std::wstring m_sClientDataXml; protected: virtual void FillParentPointersForChilds(); }; diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/SmartArt.cpp b/ASCOfficePPTXFile/PPTXFormat/Logic/SmartArt.cpp index 5db3e78e44..eee917aebe 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/SmartArt.cpp +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/SmartArt.cpp @@ -37,17 +37,13 @@ #include "../../ASCOfficeDrawingConverter.h" -#include "../../../XlsxSerializerCom/Reader/BinaryWriter.h" - +#include "../../../XlsxSerializerCom/Reader/ChartFromToBinary.h" #include "../../../ASCOfficeDocxFile2/DocWrapper/XlsxSerializer.h" -#include "../../../ASCOfficeDocxFile2/DocWrapper/FontProcessor.h" #include "../../../ASCOfficeDocxFile2/BinWriter/BinWriters.h" #include "../../../Common/DocxFormat/Source/DocxFormat/Diagram/DiagramData.h" #include "../../../Common/DocxFormat/Source/DocxFormat/Diagram/DiagramDrawing.h" -#include "../../../Common/OfficeFileFormatChecker.h" -#include "../../../OfficeUtils/src/OfficeUtils.h" namespace PPTX { namespace Logic @@ -148,7 +144,7 @@ namespace PPTX bool result = LoadDrawing(&pRelsPPTX); if (!result) - result = LoadDrawing( pRels ); + result = LoadDrawing( pRels ); } void SmartArt::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const { @@ -178,171 +174,52 @@ namespace PPTX if(parentFileIs()) file = parentFileAs().Find(*id_data); else if (pRels != NULL) file = pRels->Find(*id_data); } - smart_ptr pChart = file.smart_dynamic_cast(); - smart_ptr pChartEx = file.smart_dynamic_cast(); + smart_ptr pChart = file.smart_dynamic_cast(); + smart_ptr pChartEx = file.smart_dynamic_cast(); - if (false == pChart.IsInit() && false == pChartEx.IsInit()) return; + if (false == pChart.IsInit() && false == pChartEx.IsInit()) return; - //---------------------------------------------------------------- - std::wstring id; - if ((pChart.IsInit()) && (pChart->m_oChartSpace.m_externalData) && (pChart->m_oChartSpace.m_externalData->m_id)) - id = *pChart->m_oChartSpace.m_externalData->m_id; - else if ((pChartEx.IsInit()) && (true == pChartEx->m_oChartSpace.m_chartData.m_externalData.IsInit())) - id = pChartEx->m_oChartSpace.m_chartData.m_externalData->m_id.get_value_or(L""); - - if (false == id.empty()) - { - smart_ptr oFile = pChart.IsInit() ? pChart->Find(id) : pChartEx->Find(id); - smart_ptr oMediaFile = oFile.smart_dynamic_cast(); - - if (oMediaFile.IsInit()) - { - OOX::CPath oox_file = oMediaFile->filename(); - OOX::CPath embed_folder = oox_file.GetDirectory(true); - OOX::CPath oox_unpacked = embed_folder + L"Temp_unpacked"; - NSDirectory::CreateDirectory(oox_unpacked.GetPath()); - - COfficeUtils oOfficeUtils(NULL); - oOfficeUtils.ExtractToDirectory(oox_file.GetPath(), oox_unpacked.GetPath(), NULL, 0); - - COfficeFileFormatChecker office_checker; - office_checker.isOOXFormatFile(oox_file.GetPath()); - - if (office_checker.nFileType == AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX || - office_checker.nFileType == AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSM) - { - DocWrapper::FontProcessor oFontProcessor; - NSBinPptxRW::CDrawingConverter oDrawingConverter; - - NSCommon::smart_ptr old_rels = *pWriter->m_pCurrentContainer; - NSCommon::smart_ptr old_theme = *pWriter->m_pTheme; - - NSShapeImageGen::CMediaManager* old_manager = oDrawingConverter.m_pBinaryWriter->m_pCommon->m_pMediaManager; - oDrawingConverter.m_pBinaryWriter->m_pCommon->m_pMediaManager = pWriter->m_pCommon->m_pMediaManager; - - oDrawingConverter.SetFontPicker(pWriter->m_pCommon->m_pFontPicker); - - BinXlsxRW::BinaryFileWriter xlsxBinaryWriter(oFontProcessor); -//---------------------------- - OOX::Spreadsheet::CXlsx oXlsxEmbedded(oox_unpacked); - - //startheader for test - //oDrawingConverter.m_pBinaryWriter->WriteStringUtf8(xlsxBinaryWriter.WriteFileHeader(0, BinXlsxRW::g_nFormatVersionNoBase64)); - - xlsxBinaryWriter.intoBindoc(&oXlsxEmbedded, *oDrawingConverter.m_pBinaryWriter, NULL, &oDrawingConverter); -//------------------------------ - *pWriter->m_pCurrentContainer = old_rels; - *pWriter->m_pTheme = old_theme; - oDrawingConverter.m_pBinaryWriter->m_pCommon->m_pMediaManager = old_manager; - - pWriter->StartRecord(/*c_oserct_chartspaceXLSX*/16); - - BYTE* pbBinBuffer = oDrawingConverter.m_pBinaryWriter->GetBuffer(); - int nBinBufferLen = oDrawingConverter.m_pBinaryWriter->GetPosition(); - - pWriter->WriteBYTEArray(pbBinBuffer, nBinBufferLen); - - pWriter->EndRecord(); - - //for test - //NSFile::CFileBinary oFile; - //oFile.CreateFileW(L"d:\\Editor.bin"); - //oFile.WriteFile(pbBinBuffer, nBinBufferLen); - //oFile.CloseFile(); - } - - NSDirectory::DeleteDirectory(oox_unpacked.GetPath()); - } - } - //---------------------------------------------------------------- NSBinPptxRW::CDrawingConverter oDrawingConverter; + NSBinPptxRW::CBinaryFileWriter *pOldDrawingWriter = oDrawingConverter.m_pBinaryWriter; BinDocxRW::CDocxSerializer *pOldMainDocument = pWriter->m_pMainDocument; pWriter->m_pMainDocument = NULL; oDrawingConverter.m_pBinaryWriter = pWriter; smart_ptr oldRels = oDrawingConverter.GetRels(); - oDrawingConverter.SetRels(file.smart_dynamic_cast()); + oDrawingConverter.SetRels(pChart.smart_dynamic_cast()); BinXlsxRW::BinaryChartWriter oBinaryChartWriter(*pWriter, &oDrawingConverter); if (pChart.IsInit()) { - oBinaryChartWriter.WriteCT_ChartFile(*pChart); + oBinaryChartWriter.WriteCT_ChartSpace(*pChart); } else if (pChartEx.IsInit()) { - oBinaryChartWriter.WriteCT_ChartExFile(*pChartEx); + //oBinaryChartWriter.WriteCT_ChartSpace(*pChartEx); } - //---------------------------------------------------------------- - std::vector>& container = pChartEx.IsInit() ? pChartEx->GetContainer() : pChart->GetContainer(); - for (size_t i = 0; i < container.size(); ++i) - { - if (OOX::FileTypes::ThemeOverride == container[i]->type()) - { - PPTX::Theme* pThemeOverride = dynamic_cast(container[i].GetPointer()); - - pWriter->StartRecord(/*c_oserct_chartspaceTHEMEOVERRIDE = */15); - pThemeOverride->toPPTY(pWriter); - pWriter->EndRecord(); - break; - } - else if (OOX::FileTypes::ChartStyle == container[i]->type()) - { - OOX::Spreadsheet::CChartStyleFile* pChartStyle = dynamic_cast(container[i].GetPointer()); - - pWriter->StartRecord(/*c_oserct_chartspaceSTYLES = */17); - oBinaryChartWriter.WriteCT_ChartStyle(*pChartStyle); - pWriter->EndRecord(); - } - else if (OOX::FileTypes::ChartColors == container[i]->type()) - { - OOX::Spreadsheet::CChartColorsFile* pChartColors = dynamic_cast(container[i].GetPointer()); - - pWriter->StartRecord(/*c_oserct_chartspaceCOLORS = */18); - oBinaryChartWriter.WriteCT_ChartColor(*pChartColors); - pWriter->EndRecord(); - } - } - //---------------------------------------------------------------- oDrawingConverter.SetRels(oldRels); oDrawingConverter.m_pBinaryWriter = pOldDrawingWriter; pWriter->m_pMainDocument = pOldMainDocument; - } std::wstring ChartRec::toXML() const { - if (!id_data.is_init()) + if (!id_data.is_init() || false == m_bData) return L""; + std::wstring strData = L"ToString() + L"\"/>"; - std::wstring strData; - if (m_bChartEx) - { - strData = L"ToString() + L"\"/>"; return strData; } void ChartRec::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const { - if (!id_data.is_init()) + if (!id_data.is_init() || false == m_bData) return; - std::wstring strData; - if (m_bChartEx) - { - strData = L"ToString() + L"\"/>"; + std::wstring strData = L"ToString() + L"\"/>"; pWriter->WriteString(strData); } @@ -350,9 +227,11 @@ namespace PPTX void ChartRec::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) { ULONG lLen = pReader->GetLong(); + m_bData = true; - m_nCountCharts = pReader->m_nCountCharts; - pReader->m_nCountCharts++; + m_lChartNumber = pReader->m_lChartNumber; + pReader->m_lChartNumber++; + unsigned int lId = pReader->m_pRels->WriteChart(m_lChartNumber, pReader->m_nDocumentType); BinXlsxRW::CXlsxSerializer oXlsxSerializer; NSBinPptxRW::CDrawingConverter oDrawingConverter; @@ -365,35 +244,23 @@ namespace PPTX oXlsxSerializer.setDrawingConverter(&oDrawingConverter); - std::wstring strDstChart = pReader->m_pRels->m_pManager->GetDstCharts(); - NSDirectory::CreateDirectory(strDstChart); + std::wstring strDstChart = pReader->m_pRels->m_pManager->GetDstMedia(); + int nPos = (int)strDstChart.rfind(wchar_t('m')); + if (-1 != nPos) + strDstChart = strDstChart.substr(0, nPos); + + strDstChart += L"charts"; + //на всякий случай всегда создаем, нет уверенности что 1 == m_lChartNumber для первого chart + NSDirectory::CreateDirectory(strDstChart); + + std::wstring strChart = strDstChart + FILE_SEPARATOR_STR + L"chart" + std::to_wstring(m_lChartNumber) + L".xml"; + + oXlsxSerializer.saveChart(pReader, lLen, strChart, m_lChartNumber); - smart_ptr file; - if (m_bChartEx) - { - smart_ptr chartEx = new OOX::Spreadsheet::CChartExFile(NULL); - file = chartEx.smart_dynamic_cast(); - } - else - { - smart_ptr chart = new OOX::Spreadsheet::CChartFile(NULL); - file = chart.smart_dynamic_cast(); - } - if (true == oXlsxSerializer.saveChart(pReader, lLen, file, m_nCountCharts)) - { - if (m_bChartEx) - { - unsigned int nRId = pReader->m_pRels->WriteRels(L"http://schemas.microsoft.com/office/2014/relationships/chartEx", file->m_sOutputFilename, L""); - id_data = new OOX::RId(nRId); - } - else - { - unsigned int nRId = pReader->m_pRels->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart", file->m_sOutputFilename, L""); - id_data = new OOX::RId(nRId); - } - } oDrawingConverter.m_pReader = pOldReader; oDrawingConverter.m_pImageManager = pOldImageManager; + + id_data = new OOX::RId(lId); } } // namespace Logic } // namespace PPTX diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/SmartArt.h b/ASCOfficePPTXFile/PPTXFormat/Logic/SmartArt.h index 5381aac6dc..2131e3378f 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/SmartArt.h +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/SmartArt.h @@ -123,7 +123,7 @@ namespace PPTX public: WritingElement_AdditionConstructors(ChartRec) - ChartRec() + ChartRec() : m_bChartEx(false), m_bData(false), m_lChartNumber(0) { } @@ -148,11 +148,17 @@ namespace PPTX { std::wstring ns = XmlUtils::GetNamespace(oReader.GetName()); + m_bData = false; m_bChartEx = false; ReadAttributes( oReader ); FillParentPointersForChilds(); + if (id_data.IsInit()) + { + m_bData = true; + } + if (ns == L"cx") { m_bChartEx = true; @@ -160,6 +166,7 @@ namespace PPTX } virtual void fromXML(XmlUtils::CXmlNode& node) { + m_bData = false; m_bChartEx = false; std::wstring ns = XmlUtils::GetNamespace(node.GetName()); @@ -167,6 +174,10 @@ namespace PPTX XmlMacroReadAttributeBase(node, L"r:id", id_data); FillParentPointersForChilds(); + if (id_data.IsInit()) + { + m_bData = true; + } if (ns == L"cx") { m_bChartEx = true; @@ -180,8 +191,9 @@ namespace PPTX nullable id_data; - bool m_bChartEx = false; - int m_nCountCharts = 0; + LONG m_lChartNumber; + bool m_bData; + bool m_bChartEx; protected: virtual void FillParentPointersForChilds() { diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/SpTreeElem.cpp b/ASCOfficePPTXFile/PPTXFormat/Logic/SpTreeElem.cpp index 2c5eaead68..b96adc135e 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/SpTreeElem.cpp +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/SpTreeElem.cpp @@ -184,7 +184,7 @@ namespace PPTX */ } void CalculateLine(PPTX::Logic::SpPr& oSpPr, nullable& pShapeStyle, NSCommon::smart_ptr& oTheme, - NSCommon::smart_ptr& oClrMap, std::wstring& strAttr, std::wstring& strNode, bool bOle) + NSCommon::smart_ptr& oClrMap, std::wstring& strAttr, std::wstring& strNode, bool bOle, bool bSignature) { PPTX::Logic::Ln line; DWORD ARGB = 0; @@ -202,7 +202,7 @@ namespace PPTX ARGB = line.Fill.as().Color.GetRGBColor(oTheme, oClrMap, ARGB); strAttr = L" strokecolor=\"" + GetHexColor(ARGB) + L"\""; } - else if (line.Fill.is() || bOle) + else if (bOle || bSignature) strAttr = L" stroked=\"f\""; if (line.w.is_init()) @@ -319,7 +319,7 @@ namespace PPTX XmlUtils::CXmlNodes oNodesC; std::wstring sRequires; //todo better check (a14 can be math, slicer) - if(oNodeChoice.GetAttributeIfExist(L"Requires", sRequires) && (L"a14" == sRequires || L"cx1" == sRequires)) + if(oNodeChoice.GetAttributeIfExist(L"Requires", sRequires) && L"a14" == sRequires) { oNodeChoice.GetNodes(L"*", oNodesC); } diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/SpTreeElem.h b/ASCOfficePPTXFile/PPTXFormat/Logic/SpTreeElem.h index b6aaee1026..38d1c6660f 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/SpTreeElem.h +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/SpTreeElem.h @@ -47,7 +47,7 @@ namespace PPTX smart_ptr& oClrMap, std::wstring& strAttr, std::wstring& strNode, bool bOle = false, bool bSignature = false); void CalculateLine(PPTX::Logic::SpPr& oSpPr, nullable& pShapeStyle, - smart_ptr& oTheme, smart_ptr& oClrMap, std::wstring& strAttr, std::wstring& strNode, bool bOle = false); + smart_ptr& oTheme, smart_ptr& oClrMap, std::wstring& strAttr, std::wstring& strNode, bool bOle = false, bool bSignature = false); class SpTreeElem : public WrapperWritingElement { diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/UniColor.cpp b/ASCOfficePPTXFile/PPTXFormat/Logic/UniColor.cpp index 82d6dc01c2..d8478c8783 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/UniColor.cpp +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/UniColor.cpp @@ -41,18 +41,25 @@ namespace PPTX { namespace Logic { + UniColor::UniColor() { Color.reset(); } + + UniColor::~UniColor() { //Color.reset(); } + + UniColor::UniColor(XmlUtils::CXmlNode& node) { fromXML(node); } + + const UniColor& UniColor::operator =(XmlUtils::CXmlNode& node) { fromXML(node); @@ -88,9 +95,7 @@ namespace PPTX Color.reset(new Logic::SchemeClr(oReader)); else if (name == _T("sysClr")) Color.reset(new Logic::SysClr(oReader)); - else if (name == _T("styleClr")) - Color.reset(new Logic::StyleClr(oReader)); - else Color.reset(); + else Color.reset(); } OOX::EElementType UniColor::getType () const { @@ -116,8 +121,6 @@ namespace PPTX Color.reset(new Logic::SchemeClr(node)); else if (name == _T("sysClr")) Color.reset(new Logic::SysClr(node)); - else if (name == _T("styleClr")) - Color.reset(new Logic::StyleClr(node)); else Color.reset(); } @@ -147,8 +150,10 @@ namespace PPTX { Color->ReadModsFromPPTY(pReader); } - } - }break; + } + + break; + } case COLOR_TYPE_SCHEME: { pReader->Skip(2); @@ -165,8 +170,10 @@ namespace PPTX { Color->ReadModsFromPPTY(pReader); } - } - }break; + } + + break; + } case COLOR_TYPE_SRGB: { pReader->Skip(1); @@ -204,61 +211,31 @@ namespace PPTX { case 0: { - pColor->val = pReader->GetString2(); - }break; + pColor->val = pReader->GetString2(); + break; + } case 1: { - pColor->red = pReader->GetUChar(); - }break; + pColor->red = pReader->GetUChar(); + break; + } case 2: { - pColor->green = pReader->GetUChar(); - }break; + pColor->green = pReader->GetUChar(); + break; + } case 3: { - pColor->blue = pReader->GetUChar(); - }break; + pColor->blue = pReader->GetUChar(); + break; + } default: break; } } - Color = pColor; - if (pReader->GetPos() < _e) - { - if (0 == pReader->GetUChar()) - { - Color->ReadModsFromPPTY(pReader); - } - } - }break; - case COLOR_TYPE_STYLE: - { - pReader->Skip(1); - Logic::StyleClr* pColor = new Logic::StyleClr(); - while (true) - { - BYTE _at = pReader->GetUChar_TypeNode(); - if (_at == NSBinPptxRW::g_nodeAttributeEnd) - break; - switch (_at) - { - case 0: - { - pColor->val = pReader->GetULong(); - }break; - case 1: - { - pColor->bAuto = pReader->GetBool(); - }break; - default: - break; - } - } Color = pColor; - pReader->Skip(1); - if (pReader->GetPos() < _e) { if (0 == pReader->GetUChar()) @@ -266,7 +243,9 @@ namespace PPTX Color->ReadModsFromPPTY(pReader); } } - }break; + + break; + } } } diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/UniFill.cpp b/ASCOfficePPTXFile/PPTXFormat/Logic/UniFill.cpp index 630cc19ec4..758a60cef9 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/UniFill.cpp +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/UniFill.cpp @@ -394,8 +394,6 @@ namespace PPTX pFill->blip = new PPTX::Logic::Blip(); pFill->blip->embed = new OOX::RId(oRelsGeneratorInfo.nImageRId); - pFill->blip->imageFilepath = oRelsGeneratorInfo.sFilepathImage; - if (pFill->blip.is_init()) pFill->blip->m_namespace = _T("a"); diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/RtfReader.cpp b/ASCOfficeRtfFile/RtfFormatLib/source/RtfReader.cpp index 465ae0c20d..f59b78a94c 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/RtfReader.cpp +++ b/ASCOfficeRtfFile/RtfFormatLib/source/RtfReader.cpp @@ -78,9 +78,7 @@ std::wstring RtfAbstractReader::ExecuteTextInternalCodePage( std::string& sCharS if( false == sCharString.empty()) { - if (sCharString == "*") return L"*"; - - int nCodepage = -1; + int nCodepage = -1; //применяем параметры codepage от текущего шрифта todo associated fonts. RtfFont oFont; diff --git a/ASCOfficeTxtFile/TxtXmlFormatLib/Source/TxtXmlFile.cpp b/ASCOfficeTxtFile/TxtXmlFormatLib/Source/TxtXmlFile.cpp index 13c4ebc3f4..126d4acda5 100644 --- a/ASCOfficeTxtFile/TxtXmlFormatLib/Source/TxtXmlFile.cpp +++ b/ASCOfficeTxtFile/TxtXmlFormatLib/Source/TxtXmlFile.cpp @@ -108,7 +108,7 @@ static int ParseTxtOptions(const std::wstring & sXmlOptions) _UINT32 CTxtXmlFile::txt_LoadFromFile(const std::wstring & sSrcFileName, const std::wstring & sDstPath, const std::wstring & sXMLOptions) { - Writers::FileWriter *pDocxWriter = new Writers::FileWriter(sDstPath, L"", true, 1, NULL, L""); + Writers::FileWriter *pDocxWriter = new Writers::FileWriter(sDstPath, L"", true, 1, false, NULL, L""); if (pDocxWriter == NULL) return AVS_FILEUTILS_ERROR_CONVERT; CreateDocxEmpty(sDstPath, pDocxWriter); diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/GlobalsSubstream.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/GlobalsSubstream.cpp index 99534375e4..e1742c15da 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/GlobalsSubstream.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/GlobalsSubstream.cpp @@ -339,7 +339,7 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc) case rt_XFCRC: { if (proc.mandatory()) - { + { if (m_Formating ) //Zakaz_detalizatcii(08_fevralia_2014-21_fevralia_2014).XLS {//check previus FORMATTING* fmts = dynamic_cast(m_Formating.get()); @@ -349,19 +349,6 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc) { m_Formating = NULL; } - else - { - FORMATTING* fmts_new = dynamic_cast(elements_.back().get()); - - if (!fmts->m_Palette && fmts_new->m_Palette) - fmts->m_Palette = fmts_new->m_Palette; - - if (!fmts->m_TABLESTYLES && fmts_new->m_TABLESTYLES) - fmts->m_TABLESTYLES = fmts_new->m_TABLESTYLES; - - if (!fmts->m_THEME && fmts_new->m_THEME) - fmts->m_THEME = fmts_new->m_THEME; - } } if (!m_Formating ) { diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/WorksheetSubstream.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/WorksheetSubstream.cpp index 7968324dd4..49fd919d50 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/WorksheetSubstream.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/WorksheetSubstream.cpp @@ -172,11 +172,8 @@ const bool WorksheetSubstream::loadContent(BinProcessor& proc) { if (proc.optional()) { - COLUMNS *columns = dynamic_cast(m_COLUMNS.get()); - if (!columns || (columns && columns->elements_.empty())) - { + if (!m_COLUMNS)//??? m_COLUMNS = elements_.back(); - } elements_.pop_back(); } }break; diff --git a/Common/3dParty/html/css/src/CCompiledStyle.cpp b/Common/3dParty/html/css/src/CCompiledStyle.cpp index a02637345a..febd9d8dfa 100644 --- a/Common/3dParty/html/css/src/CCompiledStyle.cpp +++ b/Common/3dParty/html/css/src/CCompiledStyle.cpp @@ -16,902 +16,139 @@ namespace NSCSS { typedef std::map::const_iterator styles_iterator; - CCompiledStyle::CCompiledStyle() : m_nDpi(96), m_UnitMeasure(Default){} + CCompiledStyle::CCompiledStyle() {} + CCompiledStyle::CCompiledStyle(const std::map& mStyle) : m_mStyle(mStyle) {} CCompiledStyle::CCompiledStyle(const CCompiledStyle& oStyle) : - m_arParentsStyles(oStyle.m_arParentsStyles), m_sId(oStyle.m_sId), - m_nDpi(oStyle.m_nDpi), m_UnitMeasure(oStyle.m_UnitMeasure), - m_pFont(oStyle.m_pFont), m_pMargin(oStyle.m_pMargin), m_pBackground(oStyle.m_pBackground), - m_pText(oStyle.m_pText), m_pBorder(oStyle.m_pBorder){} + m_mStyle(oStyle.m_mStyle), m_arParentsStyles(oStyle.m_arParentsStyles), m_sId(oStyle.m_sId) {} CCompiledStyle::~CCompiledStyle() { + m_mStyle. clear(); m_arParentsStyles.clear(); } CCompiledStyle& CCompiledStyle::operator+= (const CCompiledStyle &oElement) { - m_pBackground += oElement.m_pBackground; - m_pBorder += oElement.m_pBorder; - m_pFont += oElement.m_pFont; - m_pMargin += oElement.m_pMargin; - m_pText += oElement.m_pText; - + for (const std::map::value_type& oItem : oElement.m_mStyle) + { + if (!oItem.second.empty() && oItem.second != L"inherit") + { + m_mStyle[oItem.first] = oItem.second; + } + } return *this; } CCompiledStyle& CCompiledStyle::operator= (const CCompiledStyle &oElement) { - m_sId = oElement.m_sId; - m_arParentsStyles = oElement.m_arParentsStyles; - - m_nDpi = oElement.m_nDpi; - m_UnitMeasure = oElement.m_UnitMeasure; - - m_pBackground = oElement.m_pBackground; - m_pBorder = oElement.m_pBorder; - m_pFont = oElement.m_pFont; - m_pMargin = oElement.m_pMargin; - m_pText = oElement.m_pText; - + m_mStyle = oElement.m_mStyle; + m_sId = oElement.m_sId; + m_arParentsStyles = oElement.m_arParentsStyles; return *this; } bool CCompiledStyle::operator== (const CCompiledStyle& oStyle) const { + if (oStyle.m_mStyle.size() != m_mStyle.size() || + oStyle.m_arParentsStyles.size() != m_arParentsStyles.size() || + oStyle.GetId()[0] != m_sId[0]) + return false; + return GetId()[0] == oStyle.GetId()[0] && m_arParentsStyles == oStyle.m_arParentsStyles && - m_pBackground == oStyle.m_pBackground && - m_pBorder == oStyle.m_pBorder && - m_pFont == oStyle.m_pFont && - m_pMargin == oStyle.m_pMargin && - m_pText == oStyle.m_pText; + m_mStyle == oStyle.m_mStyle; } - void CCompiledStyle::StyleEquation(CCompiledStyle &oFirstStyle, CCompiledStyle &oSecondStyle) + std::wstring CCompiledStyle::GetStyleW() const { - NSConstValues::NSCssProperties::Font::FontEquation(oFirstStyle.m_pFont, oSecondStyle.m_pFont); - NSConstValues::NSCssProperties::Margin::MarginEquation(oFirstStyle.m_pMargin, oSecondStyle.m_pMargin); - NSConstValues::NSCssProperties::Background::BackgroundEquation(oFirstStyle.m_pBackground, oSecondStyle.m_pBackground); - NSConstValues::NSCssProperties::Text::TextEquation(oFirstStyle.m_pText, oSecondStyle.m_pText); - NSConstValues::NSCssProperties::Border::BorderEquation(oFirstStyle.m_pBorder, oSecondStyle.m_pBorder); - - oFirstStyle.ClearImportants(); - oSecondStyle.ClearImportants(); + return std::accumulate(m_mStyle.begin(), m_mStyle.end(), std::wstring(), + [] (std::wstring& sRes, const std::map::value_type& oIter) { return sRes += oIter.first + L":" + oIter.second + L";"; }); } - void CCompiledStyle::SetDpi(const unsigned short &uiDpi) + std::map* CCompiledStyle::GetStyleMap() { - m_nDpi = uiDpi; + return &m_mStyle; } - void CCompiledStyle::SetUnitMeasure(const UnitMeasure &enUnitMeasure) +// bool CCompiledStyle::operator<(const CCompiledStyle &oElement) const +// { +// return m_sId < oElement.m_sId; +// } + + /* + bool CCompiledStyle::operator!=(const CCompiledStyle &oElement) const { - m_UnitMeasure = enUnitMeasure; + if (*this > oElement) + return false; + + if (*this < oElement) + return false; + + return true; } + bool CCompiledStyle::operator>(const CCompiledStyle &oElement) const + { + return GetWeidth() > oElement.GetWeidth(); + } + + std::string CCompiledStyle::GetStyle() const + { + std::wstring sStyle = GetStyleW(); + return U_TO_UTF8(sStyle); + } + + size_t CCompiledStyle::GetSize() const + { + return m_mStyle.size(); + } + */ + bool CCompiledStyle::Empty() const { - return m_pBackground.Empty() && m_pBorder.Empty() && - m_pFont.Empty() && m_pMargin.Empty() && m_pText.Empty(); + return m_mStyle.empty(); } - void CCompiledStyle::AddPropSel(const std::wstring& sProperty, const std::wstring& sValue, const unsigned int unLevel, const bool& bHardMode) + /* + void CCompiledStyle::Clear() { - AddStyle({{sProperty, sValue}}, unLevel, bHardMode); + m_mStyle.clear(); + m_sId.clear(); + m_arParentsStyles.clear(); + } + */ + + void CCompiledStyle::AddPropSel(const std::wstring& sProperty, const std::wstring& sValue, const bool& bHardMode) + { + if (m_mStyle[sProperty].find(L'!') != std::wstring::npos) + return; + + std::wstring sNetValue = sValue; + if (sNetValue.substr(0, 3) == L"rgb") + sNetValue = NSCSS::NS_STATIC_FUNCTIONS::ConvertRgbToHex(sNetValue); + + if (!bHardMode) + m_mStyle.emplace(sProperty, sNetValue); + else + m_mStyle[sProperty] = sNetValue; } - void CCompiledStyle::AddStyle(const std::map& mStyle, const unsigned int unLevel, const bool& bHardMode) + void CCompiledStyle::AddStyle(const std::map& mStyle, const bool& bHardMode) { - const bool bIsThereBorder = (m_pBorder.Empty()) ? false : true; - const float fSize = m_pFont.GetSize(); - - for (std::pair pPropertie : mStyle) + for (const std::pair pPropertie : mStyle) { - std::transform(pPropertie.first.begin(), pPropertie.first.end(), pPropertie.first.begin(), tolower); - SWITCH(pPropertie.first) - { - //FONT - CASE(L"font"): - { - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - m_pFont.SetFont(ConvertUnitMeasure(pPropertie.second.c_str(), fSize), unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - m_pFont.SetFont(ConvertUnitMeasure(pPropertie.second.substr(0, unPositionImp - 1), fSize), unLevel, true); - m_pFont.SetImportantAll(true); - } - break; - } - CASE(L"font-size"): - CASE(L"font-size-adjust"): - { - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - m_pFont.SetSize(ConvertUnitMeasure(pPropertie.second, fSize), unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - m_pFont.SetSize(ConvertUnitMeasure(pPropertie.second.substr(0, unPositionImp - 1), fSize), unLevel, true); - m_pFont.SetImportantSize(true); - } - break; - } - - CASE(L"font-stretch"): - { - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - m_pFont.SetStretch(pPropertie.second, unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - m_pFont.SetStretch(pPropertie.second.substr(0, unPositionImp - 1), unLevel, true); - m_pFont.SetImportantenStretch(true); - } - break; - } - CASE(L"font-style"): - { - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - m_pFont.SetStyle(pPropertie.second, unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - m_pFont.SetStyle(pPropertie.second.substr(0, unPositionImp - 1), unLevel, true); - m_pFont.SetImportantenStyle(true); - } - break; - } - CASE(L"font-variant"): - { - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - m_pFont.SetVariant(pPropertie.second, unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - m_pFont.SetVariant(pPropertie.second.substr(0, unPositionImp - 1), unLevel, true); - m_pFont.SetImportantenVariant(true); - } - break; - } - CASE(L"font-weight"): - { - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - m_pFont.SetWeight(pPropertie.second, unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - m_pFont.SetWeight(pPropertie.second.substr(0, unPositionImp - 1), unLevel, true); - m_pFont.SetImportantenWeight(true); - } - break; - } - CASE(L"font-family"): - { - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - m_pFont.SetFontFamily(pPropertie.second, unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - m_pFont.SetFontFamily(pPropertie.second.substr(0, unPositionImp - 1), unLevel, true); - m_pFont.SetImportantenFamily(true); - } - break; - } - CASE(L"line-height"): - { - size_t unCoefficient = 1; - const size_t unPositionImp = pPropertie.second.find(L"!i"); - const size_t unPositionSymbol = pPropertie.second.find_first_of(L"abcdefghijklmnopqrstuvwxyz%"); - - if (unPositionSymbol == std::wstring::npos) - unCoefficient = m_pFont.GetSize(); - - if (unPositionImp == std::wstring::npos) - { - const float fValue = wcstof(ConvertUnitMeasure(pPropertie.second, m_pFont.GetSize()).c_str(), NULL); - m_pFont.SetLineHeight(std::to_wstring(fValue * unCoefficient), unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - const float fValue = wcstof(ConvertUnitMeasure(pPropertie.second.substr(0, unPositionImp - 1), m_pFont.GetSize()).c_str(), NULL); - m_pFont.SetLineHeight(std::to_wstring(fValue * unCoefficient), unLevel, true); - m_pFont.SetImportantenLineHeight(true); - } - break; - } - //MARGIN - CASE(L"margin"): - { - if (bIsThereBorder) - break; - - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - const std::wstring sValue = ConvertUnitMeasure(pPropertie.second, 540.0f); - if (sValue.find_first_not_of(L" 0") != std::wstring::npos) - m_pMargin.AddMargin(sValue, unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - const std::wstring sValue = ConvertUnitMeasure(pPropertie.second.substr(0, unPositionImp - 1), 540.0f); - if (sValue.find_first_not_of(L" 0") != std::wstring::npos) - m_pMargin.AddMargin(sValue, unLevel, true); - - m_pMargin.SetImportantAll(true); - } - - break; - } - CASE(L"margin-top"): - { - if (bIsThereBorder) - break; - - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - const std::wstring sValue = ConvertUnitMeasure(pPropertie.second, 540.0f); - if (sValue.find_first_not_of(L" 0") != std::wstring::npos) - m_pMargin.AddTopMargin(sValue, unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - const std::wstring sValue = ConvertUnitMeasure(pPropertie.second.substr(0, unPositionImp - 1), 540.0f); - if (sValue.find_first_not_of(L" 0") != std::wstring::npos) - m_pMargin.AddTopMargin(sValue, unLevel, true); - - m_pMargin.SetImportantTopSide(true); - } - break; - } - CASE(L"margin-right"): - CASE(L"margin-block-end"): - { - if (bIsThereBorder) - break; - - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - const std::wstring sValue = ConvertUnitMeasure(pPropertie.second, 540.0f); - if (sValue.find_first_not_of(L" 0") != std::wstring::npos) - m_pMargin.AddRightMargin(sValue, unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - const std::wstring sValue = ConvertUnitMeasure(pPropertie.second.substr(0, unPositionImp - 1), 540.0f); - if (sValue.find_first_not_of(L" 0") != std::wstring::npos) - m_pMargin.AddRightMargin(sValue, unLevel, true); - - m_pMargin.SetImportantRightSide(true); - } - break; - } - CASE(L"margin-bottom"): - { - if (bIsThereBorder) - break; - - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - const std::wstring sValue = ConvertUnitMeasure(pPropertie.second, 540.0f); - if (sValue.find_first_not_of(L" 0") != std::wstring::npos) - m_pMargin.AddBottomMargin(sValue, unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - const std::wstring sValue = ConvertUnitMeasure(pPropertie.second.substr(0, unPositionImp - 1), 540.0f); - if (sValue.find_first_not_of(L" 0") != std::wstring::npos) - m_pMargin.AddBottomMargin(sValue, unLevel, true); - - m_pMargin.SetImportantBottomSide(true); - } - break; - } - CASE(L"margin-left"): - CASE(L"margin-block-start"): - { - if (bIsThereBorder) - break; - - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - const std::wstring sValue = ConvertUnitMeasure(pPropertie.second, 540.0f); - if (sValue.find_first_not_of(L" 0") != std::wstring::npos) - m_pMargin.AddLeftMargin(sValue, unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - const std::wstring sValue = ConvertUnitMeasure(pPropertie.second.substr(0, unPositionImp - 1), 540.0f); - if (sValue.find_first_not_of(L" 0") != std::wstring::npos) - m_pMargin.AddLeftMargin(sValue, unLevel, true); - - m_pMargin.SetImportantLeftSide(true); - } - break; - } - //PADDING - CASE(L"padding"): - { - if (bIsThereBorder) - break; - - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - const std::wstring sValue = ConvertUnitMeasure(pPropertie.second, 540.0f); - if (sValue.find_first_not_of(L" 0") != std::wstring::npos) - m_pMargin.AddMargin(sValue, unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - const std::wstring sValue = ConvertUnitMeasure(pPropertie.second.substr(0, unPositionImp - 1), 540.0f); - if (sValue.find_first_not_of(L" 0") != std::wstring::npos) - m_pMargin.AddMargin(sValue, unLevel, true); - - m_pMargin.SetImportantAll(true); - } - - break; - } - CASE(L"padding-top"): - { - if (bIsThereBorder) - break; - - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - const std::wstring sValue = ConvertUnitMeasure(pPropertie.second, 540.0f); - if (sValue.find_first_not_of(L" 0") != std::wstring::npos) - m_pMargin.AddTopMargin(sValue, unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - const std::wstring sValue = ConvertUnitMeasure(pPropertie.second.substr(0, unPositionImp - 1), 540.0f); - if (sValue.find_first_not_of(L" 0") != std::wstring::npos) - m_pMargin.AddTopMargin(sValue, unLevel, true); - - m_pMargin.SetImportantTopSide(true); - } - - break; - } - CASE(L"padding-right"): - { - if (bIsThereBorder) - break; - - - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - const std::wstring sValue = ConvertUnitMeasure(pPropertie.second, 540.0f); - if (sValue.find_first_not_of(L" 0") != std::wstring::npos) - m_pMargin.AddRightMargin(sValue, unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - const std::wstring sValue = ConvertUnitMeasure(pPropertie.second.substr(0, unPositionImp - 1), 540.0f); - if (sValue.find_first_not_of(L" 0") != std::wstring::npos) - m_pMargin.AddRightMargin(sValue, unLevel, true); - - m_pMargin.SetImportantRightSide(true); - } - - break; - } - CASE(L"padding-bottom"): - { - if (bIsThereBorder) - break; - - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - const std::wstring sValue = ConvertUnitMeasure(pPropertie.second, 540.0f); - if (sValue.find_first_not_of(L" 0") != std::wstring::npos) - m_pMargin.AddBottomMargin(sValue, unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - const std::wstring sValue = ConvertUnitMeasure(pPropertie.second.substr(0, unPositionImp - 1), 540.0f); - if (sValue.find_first_not_of(L" 0") != std::wstring::npos) - m_pMargin.AddBottomMargin(sValue, unLevel, true); - - m_pMargin.SetImportantBottomSide(true); - } - - break; - } - CASE(L"padding-left"): - { - if (bIsThereBorder) - break; - - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - const std::wstring sValue = ConvertUnitMeasure(pPropertie.second, 540.0f); - if (sValue.find_first_not_of(L" 0") != std::wstring::npos) - m_pMargin.AddLeftMargin(sValue, unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - const std::wstring sValue = ConvertUnitMeasure(pPropertie.second.substr(0, unPositionImp - 1), 540.0f); - if (sValue.find_first_not_of(L" 0") != std::wstring::npos) - m_pMargin.AddLeftMargin(sValue, unLevel, true); - - m_pMargin.SetImportantLeftSide(true); - } - - break; - } - // TEXT - CASE(L"text-align"): - { - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - m_pText.SetAlign(pPropertie.second, unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - m_pText.SetAlign(pPropertie.second.substr(0, unPositionImp - 1), unLevel, true); - m_pText.SetImportantAlign(true); - } - - break; - } - CASE(L"text-indent"): - { - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - m_pText.SetIndent(ConvertUnitMeasure(pPropertie.second, 540.0f), unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - m_pText.SetIndent(ConvertUnitMeasure(pPropertie.second.substr(0, unPositionImp - 1), 540.0f), unLevel, true); - m_pText.SetImportantIndent(true); - } - - break; - } - CASE(L"text-decoration"): - { - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - m_pText.SetDecoration(pPropertie.second, unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - m_pText.SetDecoration(pPropertie.second.substr(0, unPositionImp - 1), unLevel, true); - m_pText.SetImportantDecoration(true); - } - - break; - } - CASE(L"text-color"): - CASE(L"color"): - { - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - m_pText.SetColor(pPropertie.second, unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - m_pText.SetColor(pPropertie.second.substr(0, unPositionImp - 1), unLevel, true); - m_pText.SetImportantColor(true); - } - break; - } - //BORDER - CASE(L"border"): - CASE(L"mso-border-alt"): - { - NSConstValues::NSCssProperties::BorderSide oBorderSide = NSConstValues::NSCssProperties::BorderSide::GetCorrectSide(ConvertUnitMeasure(pPropertie.second, 0.0f)); - - if (oBorderSide.GetWidth() < 0) - break; - - oBorderSide.SetAllLevels(unLevel); - - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - m_pText.SetAlign(pPropertie.second, bHardMode); - - m_pBorder.SetTopSide(oBorderSide, bHardMode); - m_pBorder.SetRightSide(oBorderSide, bHardMode); - m_pBorder.SetBottomSide(oBorderSide, bHardMode); - m_pBorder.SetLeftSide(oBorderSide, bHardMode); - } - else if (unPositionImp != 0) - { - oBorderSide.SetImportantAll(true); - m_pBorder.SetTopSide(oBorderSide, true); - m_pBorder.SetRightSide(oBorderSide, true); - m_pBorder.SetBottomSide(oBorderSide, true); - m_pBorder.SetLeftSide(oBorderSide, true); - } - - break; - } - CASE(L"border-width"): - { - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - const float fValue = wcstof(ConvertUnitMeasure(pPropertie.second, 0.0f).c_str(), NULL); - m_pBorder.SetWidth(fValue, unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - const float fValue = wcstof(ConvertUnitMeasure(pPropertie.second.substr(0, unPositionImp - 1), 0.0f).c_str(), NULL); - m_pBorder.SetWidth(fValue, unLevel, true); - m_pBorder.SetImportantWidth(true); - } - - break; - } - CASE(L"border-style"): - { - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - m_pBorder.SetStyle(pPropertie.second, unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - m_pBorder.SetStyle(pPropertie.second.substr(0, unPositionImp - 1), unLevel, true); - m_pBorder.SetImportantStyle(true); - } - - break; - } - CASE(L"border-color"): - { - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - m_pBorder.SetColor(pPropertie.second, unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - m_pBorder.SetColor(pPropertie.second.substr(0, unPositionImp - 1), unLevel, true); - m_pBorder.SetImportantColor(true); - } - - break; - } - //BORDER TOP - CASE(L"border-top"): - { - NSConstValues::NSCssProperties::BorderSide oBorderSide = NSConstValues::NSCssProperties::BorderSide::GetCorrectSide(ConvertUnitMeasure(pPropertie.second, 0.0f)); - if (oBorderSide.GetWidth() < 0) - break; - - oBorderSide.SetAllLevels(unLevel); - - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - m_pBorder.SetTopSide(oBorderSide, bHardMode); - } - else if (unPositionImp != 0) - { - oBorderSide.SetImportantAll(true); - m_pBorder.SetTopSide(oBorderSide, true); - } - - break; - } - CASE(L"border-top-width"): - { - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - m_pBorder.SetTopSideWidth(wcstof(ConvertUnitMeasure(pPropertie.second, 0.0f).c_str(), NULL), unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - m_pBorder.SetTopSideWidth(wcstof(ConvertUnitMeasure(pPropertie.second.substr(0, unPositionImp - 1), 0.0f).c_str(), NULL), unLevel, true); - m_pBorder.SetImportantWidthTopSide(true); - } - - break; - } - CASE(L"border-top-style"): - { - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - m_pBorder.SetTopSideStyle(pPropertie.second, unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - m_pBorder.SetTopSideStyle(pPropertie.second.substr(0, unPositionImp - 1), unLevel, true); - m_pBorder.SetImportantStyleTopSide(true); - } - - break; - } - CASE(L"border-top-color"): - { - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - m_pBorder.SetTopSideColor(pPropertie.second, unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - m_pBorder.SetTopSideColor(pPropertie.second.substr(0, unPositionImp - 1), unLevel, true); - m_pBorder.SetImportantColorTopSide(true); - } - - break; - } - //BORDER RIGHT - CASE(L"border-right"): - { - NSConstValues::NSCssProperties::BorderSide oBorderSide = NSConstValues::NSCssProperties::BorderSide::GetCorrectSide(ConvertUnitMeasure(pPropertie.second, 0.0f)); - - if (oBorderSide.GetWidth() < 0) - break; - - oBorderSide.SetAllLevels(unLevel); - - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - m_pBorder.SetRightSide(oBorderSide, bHardMode); - } - else if (unPositionImp != 0) - { - oBorderSide.SetImportantAll(true); - m_pBorder.SetRightSide(oBorderSide, true); - } - - break; - } - CASE(L"border-right-width"): - { - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - m_pBorder.SetRightSideWidth(wcstof(ConvertUnitMeasure(pPropertie.second, 0.0f).c_str(), NULL), unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - m_pBorder.SetRightSideWidth(wcstof(ConvertUnitMeasure(pPropertie.second.substr(0, unPositionImp - 1), 0.0f).c_str(), NULL), unLevel, true); - m_pBorder.SetImportantWidthRightSide(true); - } - - break; - } - CASE(L"border-right-style"): - { - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - m_pBorder.SetRightSideStyle(pPropertie.second, unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - m_pBorder.SetRightSideStyle(pPropertie.second.substr(0, unPositionImp - 1), unLevel, true); - m_pBorder.SetImportantStyleRightSide(true); - } - - break; - } - CASE(L"border-right-color"): - { - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - m_pBorder.SetRightSideColor(pPropertie.second, unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - m_pBorder.SetRightSideColor(pPropertie.second.substr(0, unPositionImp - 1), unLevel, true); - m_pBorder.SetImportantColorRightSide(true); - } - - break; - } - //BORDER bottom - CASE(L"border-bottom"): - { - NSConstValues::NSCssProperties::BorderSide oBorderSide = NSConstValues::NSCssProperties::BorderSide::GetCorrectSide(ConvertUnitMeasure(pPropertie.second, 0.0f)); - - if (oBorderSide.GetWidth() < 0) - break; - - oBorderSide.SetAllLevels(unLevel); - - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - m_pBorder.SetBottomSide(oBorderSide, bHardMode); - } - else if (unPositionImp != 0) - { - oBorderSide.SetImportantAll(true); - m_pBorder.SetBottomSide(oBorderSide, true); - } - - break; - } - CASE(L"border-bottom-width"): - { - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - m_pBorder.SetBottomSideWidth(wcstof(ConvertUnitMeasure(pPropertie.second, 0.0f).c_str(), NULL), unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - m_pBorder.SetBottomSideWidth(wcstof(ConvertUnitMeasure(pPropertie.second.substr(0, unPositionImp - 1), 0.0f).c_str(), NULL), unLevel, true); - m_pBorder.SetImportantWidthBottomSide(true); - } - - break; - } - CASE(L"border-bottom-style"): - { - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - m_pBorder.SetBottomSideStyle(pPropertie.second, unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - m_pBorder.SetBottomSideStyle(pPropertie.second.substr(0, unPositionImp - 1), unLevel, true); - m_pBorder.SetImportantStyleBottomSide(true); - } - - break; - } - CASE(L"border-bottom-color"): - { - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - m_pBorder.SetBottomSideColor(pPropertie.second, unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - m_pBorder.SetBottomSideColor(pPropertie.second.substr(0, unPositionImp - 1), unLevel, true); - m_pBorder.SetImportantColorBottomSide(true); - } - - break; - } - //BORDER LEFT - CASE(L"border-left"): - { - NSConstValues::NSCssProperties::BorderSide oBorderSide = NSConstValues::NSCssProperties::BorderSide::GetCorrectSide(ConvertUnitMeasure(pPropertie.second, 0.0f)); - - if (oBorderSide.GetWidth() < 0) - break; - - oBorderSide.SetAllLevels(unLevel); - - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - m_pBorder.SetLeftSide(oBorderSide, bHardMode); - } - else if (unPositionImp != 0) - { - oBorderSide.SetImportantAll(true); - m_pBorder.SetLeftSide(oBorderSide, true); - } - - break; - } - CASE(L"border-left-width"): - { - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - m_pBorder.SetLeftSideWidth(wcstof(ConvertUnitMeasure(pPropertie.second, 0.0f).c_str(), NULL), unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - m_pBorder.SetLeftSideWidth(wcstof(ConvertUnitMeasure(pPropertie.second.substr(0, unPositionImp - 1), 0.0f).c_str(), NULL), unLevel, true); - m_pBorder.SetImportantWidthLeftSide(true); - } - - break; - } - CASE(L"border-left-style"): - { - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - m_pBorder.SetLeftSideStyle(pPropertie.second, unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - m_pBorder.SetLeftSideStyle(pPropertie.second.substr(0, unPositionImp - 1), unLevel, true); - m_pBorder.SetImportantStyleLeftSide(true); - } - - break; - } - CASE(L"border-left-color"): - { - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - m_pBorder.SetLeftSideColor(pPropertie.second, unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - m_pBorder.SetLeftSideColor(pPropertie.second.substr(0, unPositionImp - 1), unLevel, true); - m_pBorder.SetImportantColorLeftSide(true); - } - - break; - } - // BACKGROUND - CASE(L"background-color"): - { - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - m_pBackground.SetColor(pPropertie.second, unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - m_pBackground.SetColor(pPropertie.second.substr(0, unPositionImp - 1), unLevel, true); - m_pBackground.SetImportantBackground(true); - } - break; - } - CASE(L"background"): - { - const size_t unPositionImp = pPropertie.second.find(L"!i"); - if (unPositionImp == std::wstring::npos) - { - m_pBackground.SetBackground(pPropertie.second, unLevel, bHardMode); - } - else if (unPositionImp != 0) - { - m_pBackground.SetBackground(pPropertie.second.substr(0, unPositionImp - 1), unLevel, true); - m_pBackground.SetImportantAll(true); - } - break; - } - } + if (m_mStyle[pPropertie.first].empty() || bHardMode) + m_mStyle[pPropertie.first] = pPropertie.second; + else if (!bHardMode || m_mStyle[pPropertie.first].find(L'!') != std::wstring::npos) + continue; } } - void CCompiledStyle::AddStyle(const std::wstring& sStyle, const unsigned int unLevel, const bool& bHardMode) + + void CCompiledStyle::AddStyle(const std::wstring& sStyle, const bool& bHardMode) { if (sStyle.empty()) return; @@ -934,7 +171,7 @@ namespace NSCSS sValue.pop_back(); std::transform(sProperty.begin(), sProperty.end(), sProperty.begin(), tolower); std::transform(sValue.begin(), sValue.end(), sValue.begin(), tolower); - AddPropSel(sProperty, sValue, unLevel, bHardMode); + AddPropSel(sProperty, sValue, bHardMode); sProperty.clear(); sValue.clear(); } @@ -944,23 +181,20 @@ namespace NSCSS AddPropSel(sProperty, sValue, bHardMode); } + void CCompiledStyle::SetStyle(const std::map &mStyle) + { + m_mStyle = mStyle; + } + void CCompiledStyle::AddParent(const std::wstring& sParentName) { if (!sParentName.empty()) - m_arParentsStyles.insert(sParentName); + m_arParentsStyles.push_back(sParentName); } std::vector CCompiledStyle::GetParentsName() const { - if (m_arParentsStyles.empty()) - return std::vector(); - - std::vector arParentsName; - - for (std::set::iterator iParentName = m_arParentsStyles.begin(); iParentName != m_arParentsStyles.end(); ++iParentName) - arParentsName.push_back(*iParentName); - - return arParentsName; + return m_arParentsStyles; } void CCompiledStyle::SetID(const std::wstring& sId) @@ -973,539 +207,1602 @@ namespace NSCSS return m_sId; } - void CCompiledStyle::ClearImportants() + /* + const std::map::iterator& CCompiledStyle::GetBegin() { - m_pBackground .ClearImportants(); - m_pBorder .ClearImportants(); - m_pFont .ClearImportants(); - m_pMargin .ClearImportants(); - m_pText .ClearImportants(); + return m_mStyle.begin(); } - std::wstring CCompiledStyle::ConvertUnitMeasure(const std::wstring &sValue, const float& fPreviousValue) const + const std::map::iterator& CCompiledStyle::GetEnd() + { + return m_mStyle.end(); + } + + double CCompiledStyle::GetWeidth() const + { + double dWidth = 0.0; + dWidth = std::accumulate(m_mStyle.begin(), m_mStyle.end(), dWidth, + [] (double dW, const std::pair& sValue) { return dW + sValue.first.length() + sValue.second.length(); }); + dWidth = std::accumulate(m_arParentsStyles.begin(), m_arParentsStyles.end(), dWidth, + [] (double dW, const std::wstring& sValue) { return dW + sValue.length() / 2; }); + return dWidth; + } + */ + + /* FONT */ + + std::wstring CCompiledStyle::GetFont() const { - if (sValue.empty()) - return sValue; + styles_iterator oFont = m_mStyle.find(L"font"); + if (oFont != m_mStyle.end()) + return oFont->second; - std::vector arValues = NS_STATIC_FUNCTIONS::GetWordsWithSigns(sValue); + std::wstring sValue = GetFontStyle() + L" " + + GetFontVariant() + L" " + + GetFontWeight() + L" " + + GetFontSize() + L"/" + + GetLineHeight() + L" " + + GetFontFamily(); - std::wstring sValueString; + return sValue.length() == 5 ? std::wstring() : sValue; + } - for (std::wstring& sValueTemp : arValues) + std::wstring CCompiledStyle::GetFontFamily() const + { + styles_iterator oFontFamily = m_mStyle.find(L"font-family"); + + if (oFontFamily != m_mStyle.end()) { - const size_t nPosImportant = sValueTemp.find(L'!'); - if (nPosImportant != std::wstring::npos) - sValueTemp = sValueTemp.substr(0, nPosImportant); - - size_t nPosGrid = sValueTemp.find(L'#'); - - if (nPosGrid != std::wstring::npos || !NS_STATIC_FUNCTIONS::ThereIsNumber(sValueTemp)) + const std::wstring& sFont = oFontFamily->second; + size_t nLeftQuote = sFont.find_first_of(L"'\""); + while (nLeftQuote != std::wstring::npos) { - if (!NS_STATIC_FUNCTIONS::ConvertAbsoluteValue(sValueTemp, fPreviousValue)) + const size_t nRightQuote = sFont.find_first_of(L"'\"", nLeftQuote + 1); + const size_t nNewLeftQuote = sFont.find_first_of(L"'\"", nRightQuote + 1); + if (nNewLeftQuote == std::wstring::npos) + return sFont.substr(nLeftQuote, nRightQuote - nLeftQuote + 1); + nLeftQuote = nNewLeftQuote; + } + } + + std::wstring sFont; + styles_iterator oFont = m_mStyle.find(L"font"); + + if (oFont != m_mStyle.end()) + sFont = oFont->second; + + if (sFont.empty()) + return std::wstring(); + + size_t nLeftQuote = sFont.find_first_of(L"'\""); + while (nLeftQuote != std::wstring::npos) + { + const size_t nRightQuote = sFont.find_first_of(L"'\"", nLeftQuote + 1); + const size_t nNewLeftQuote = sFont.find_first_of(L"'\"", nRightQuote + 1); + if (nNewLeftQuote == std::wstring::npos) + return sFont.substr(nLeftQuote, nRightQuote - nLeftQuote + 1); + nLeftQuote = nNewLeftQuote; + } + + return std::wstring(); + } + + std::wstring CCompiledStyle::GetFontSize() const + { + styles_iterator oFontSize = m_mStyle.find(L"font-size"); + + if (oFontSize != m_mStyle.end()) + return oFontSize->second; + + std::wstring sFont; + + styles_iterator oFont = m_mStyle.find(L"font"); + + if (oFont != m_mStyle.end()) + sFont = oFont->second; + + if (sFont.empty()) + return std::wstring(); + + const std::vector arWords = NS_STATIC_FUNCTIONS::GetWordsW(sFont); + + std::wstring sValue; + + for (const std::wstring& sWord : arWords) + if (isdigit(sWord[0])) + sValue = sWord; + else if (sWord == L"/") + return sValue; + + return sValue; + } + + std::wstring CCompiledStyle::GetFontSizeAdjust() const + { + styles_iterator oFontSizeAdj = m_mStyle.find(L"font-size-adjust"); + return oFontSizeAdj != m_mStyle.end() ? oFontSizeAdj->second : std::wstring(); + } + + std::wstring CCompiledStyle::GetFontStretch() const + { + styles_iterator oFontStretch = m_mStyle.find(L"font-stretch"); + return oFontStretch != m_mStyle.end() ? oFontStretch->second : std::wstring(); + } + + std::wstring CCompiledStyle::GetFontStyle() const + { + styles_iterator oFontStyle = m_mStyle.find(L"font-style"); + + if (oFontStyle != m_mStyle.end()) + return oFontStyle->second; + + std::wstring sFont; + + styles_iterator oFont = m_mStyle.find(L"font"); + + if (oFont != m_mStyle.end()) + sFont = oFont->second; + + if (sFont.empty()) + return std::wstring(); + + const std::vector arWords = NS_STATIC_FUNCTIONS::GetWordsW(sFont); + + for (const std::wstring& sWord : arWords) + if (sWord == L"italic" || sWord == L"oblique") + return sWord; + + return std::wstring(); + } + + std::wstring CCompiledStyle::GetFontVariant() const + { + styles_iterator oFontVariant = m_mStyle.find(L"font-variant"); + + if (oFontVariant != m_mStyle.end()) + return oFontVariant->second; + + styles_iterator oFont = m_mStyle.find(L"font"); + std::wstring sFont; + + if (oFont != m_mStyle.end()) + sFont = oFont->second; + + if (sFont.empty()) + return std::wstring(); + + const std::vector arWords = NS_STATIC_FUNCTIONS::GetWordsW(sFont); + + for (const std::wstring& sWord : arWords) + if (sWord == L"small-caps") + return sWord; + + return std::wstring(); + } + + std::wstring CCompiledStyle::GetFontWeight() const + { + styles_iterator oFontWeight = m_mStyle.find(L"font-weight"); + + if (oFontWeight != m_mStyle.end()) + return oFontWeight->second; + + styles_iterator oFont = m_mStyle.find(L"font"); + std::wstring sFont; + + if (oFont != m_mStyle.end()) + sFont = oFont->second; + + if (sFont.empty()) + return std::wstring(); + + const std::vector arWords = NS_STATIC_FUNCTIONS::GetWordsW(sFont); + + for (const std::wstring& sWord : arWords) + if (sWord == L"bold" || sWord == L"bolder" || L"lighter" || (sWord.length() == 3 && isdigit(sWord[0]) && isdigit(sWord[1]) && isdigit(sWord[2]))) + return std::wstring(L"bold"); + + return std::wstring(); + } + + std::wstring CCompiledStyle::GetLineHeight() const + { + styles_iterator oLineHeight = m_mStyle.find(L"line-height"); + + if (oLineHeight != m_mStyle.end()) + return oLineHeight->second; + + std::wstring sFont; + + styles_iterator oFont = m_mStyle.find(L"font"); + + if (oFont != m_mStyle.end()) + sFont = oFont->second; + + if (sFont.empty()) + return std::wstring(); + + const std::vector arWords = NS_STATIC_FUNCTIONS::GetWordsW(sFont); + + std::wstring sValue; + + for (size_t i = 0; i < arWords.size() - 1; ++i) + if (arWords[i] == L"/" && i < arWords.size() - 2) + return arWords[i + 1]; + + return std::wstring(); + + } + + std::vector CCompiledStyle::GetFontNames() const + { + const std::wstring sFontFamily = GetFontFamily(); + if (sFontFamily.empty()) + return std::vector(); + + + size_t posFirst = sFontFamily.find_first_of(L"'\""); + if (posFirst == std::wstring::npos) + return std::vector({sFontFamily}); + + std::vector arWords; + while (posFirst != std::wstring::npos) + { + const size_t& posSecond = sFontFamily.find_first_of(L"'\"", posFirst + 1); + arWords.push_back(sFontFamily.substr(posFirst, posSecond - posFirst + 1)); + posFirst = sFontFamily.find_first_of(L"'\"", posSecond + 1); + } + + return arWords; + } + + std::vector CCompiledStyle::GetFontNames2(const std::wstring& sFontFamily) const + { + if (sFontFamily.empty()) + return std::vector(); + + size_t posFirst = sFontFamily.find_first_of(L"'\""); + if (posFirst == std::wstring::npos) + return std::vector({sFontFamily}); + + std::vector arWords; + while (posFirst != std::wstring::npos) + { + const size_t& posSecond = sFontFamily.find_first_of(L"'\"", posFirst + 1); + arWords.push_back(sFontFamily.substr(posFirst, posSecond - posFirst + 1)); + posFirst = sFontFamily.find_first_of(L"'\"", posSecond + 1); + } + return arWords; + } + + /* MARGIN */ + std::wstring CCompiledStyle::GetMargin() const + { + styles_iterator oMargin = m_mStyle.find(L"margin"); + if (oMargin != m_mStyle.end()) + return oMargin->second; + + const std::wstring& sTop = GetMarginTop(); + const std::wstring& sLeft = GetMarginLeft(); + const std::wstring& sRight = GetMarginRight(); + const std::wstring& sBottom = GetMarginBottom(); + + if ((sTop == sLeft) && (sLeft == sRight) && (sRight == sBottom)) + return sTop; + + if ((sTop == sBottom) && (sLeft == sRight)) + return sTop + L" " + sLeft; + + if (sLeft == sRight) + return sTop + L" " + sLeft + L" " + sBottom; + + return sTop + L" " + sRight + L" " + sBottom + L" " + sLeft; + + return std::wstring(); + } + + std::vector CCompiledStyle::GetMargins() const + { + styles_iterator oMargin = m_mStyle.find(L"margin"); + + std::vector sRes(4); + + std::wstring sMargin; + if (oMargin != m_mStyle.end()) + sMargin = oMargin->second; + + std::wstring sTop = GetMarginTop2(); + std::wstring sBottom = GetMarginBottom2(); + std::wstring sLeft = GetMarginLeft2 (); + std::wstring sRight = GetMarginRight2 (); + + if(!sMargin.empty()) + { + std::vector arValues; + size_t pre = 0; + size_t find = sMargin.find(' '); + while(find != std::wstring::npos) + { + arValues.push_back(sMargin.substr(pre, find - pre)); + pre = find + 1; + find = sMargin.find(' ', pre); + } + if(pre < sMargin.size()) + arValues.push_back(sMargin.substr(pre)); + + if(sTop.empty()) + sTop = arValues[0]; + if(sLeft.empty()) + sLeft = arValues.size() == 4 ? arValues[3] : (arValues.size() > 1 ? arValues[1] : arValues[0]); + if(sRight.empty()) + sRight = arValues.size() > 1 ? arValues[1] : arValues[0]; + if(sBottom.empty()) + sBottom = arValues.size() > 2 ? arValues[2] : arValues[0]; + } + sRes[0] = sTop; + sRes[1] = sRight; + sRes[2] = sBottom; + sRes[3] = sLeft; + return sRes; + } + + std::wstring CCompiledStyle::GetMarginTop2() const + { + styles_iterator oMarginTop = m_mStyle.find(L"margin-top"); + if (oMarginTop != m_mStyle.end()) + return oMarginTop->second; + + const std::wstring& sMarginBlockStart = GetMarginBlockStart(); + return sMarginBlockStart.empty() ? std::wstring() : sMarginBlockStart; + } + + std::wstring CCompiledStyle::GetMarginTop() const + { + styles_iterator oMarginTop = m_mStyle.find(L"margin-top"); + + if (oMarginTop != m_mStyle.end()) + return oMarginTop->second; + + const std::wstring& sMarginBlockStart = GetMarginBlockStart(); + + if (!sMarginBlockStart.empty()) + return sMarginBlockStart; + + std::wstring sMargin; + styles_iterator oMargin = m_mStyle.find(L"margin"); + + if (oMargin != m_mStyle.end()) + sMargin = oMargin->second; + else + return std::wstring(); + + if (sMargin.empty()) + return std::wstring(); + + std::vector arValues; + + std::wstring sTemp; + + for (const wchar_t& wc : sMargin) + { + sTemp += wc; + + if (wc == L' ') + { + arValues.push_back(sTemp); + sTemp.clear(); + } + } + if (!sTemp.empty()) + arValues.push_back(sTemp); + + if (!arValues.empty()) + return arValues[0]; + + return std::wstring(); + } + + std::wstring CCompiledStyle::GetMarginBlockStart() const + { + styles_iterator oMarginBlockStart = m_mStyle.find(L"margin-block-start"); + return oMarginBlockStart != m_mStyle.end() ? oMarginBlockStart->second : std::wstring(); + } + + std::wstring CCompiledStyle::GetMarginLeft2() const + { + styles_iterator oMarginLeft = m_mStyle.find(L"margin-left"); + return oMarginLeft != m_mStyle.end() ? oMarginLeft->second : std::wstring(); + } + + std::wstring CCompiledStyle::GetMarginLeft() const + { + styles_iterator oMarginLeft = m_mStyle.find(L"margin-left"); + + if (oMarginLeft != m_mStyle.end()) + return oMarginLeft->second; + + std::wstring sValue; + styles_iterator oMargin = m_mStyle.find(L"margin"); + + if (oMargin != m_mStyle.end()) + sValue = oMargin->second; + else + return std::wstring(); + + if (sValue.empty()) + return std::wstring(); + + std::vector arValues; + + std::wstring sTemp; + + for (const wchar_t& wc : sValue) + { + sTemp += wc; + + if (wc == L' ') + { + arValues.push_back(sTemp); + sTemp.clear(); + } + } + if (!sTemp.empty()) + arValues.push_back(sTemp); + + if (arValues.size() == 4) + return arValues[3]; + else if (arValues.size() > 1) + return arValues[1]; + else if (arValues.size() == 1) + return arValues[0]; + + return std::wstring(); + } + + std::wstring CCompiledStyle::GetMarginRight2() const + { + styles_iterator oMarginRight = m_mStyle.find(L"margin-right"); + + if (oMarginRight != m_mStyle.end()) + return oMarginRight->second; + + return L""; + } + + std::wstring CCompiledStyle::GetMarginRight() const + { + styles_iterator oMarginRight = m_mStyle.find(L"margin-right"); + + if (oMarginRight != m_mStyle.end()) + return oMarginRight->second; + + std::wstring sValue; + styles_iterator oMargin = m_mStyle.find(L"margin"); + + if (oMargin != m_mStyle.end()) + sValue = oMargin->second; + else + return std::wstring(); + + if (sValue.empty()) + return std::wstring(); + + std::vector arValues; + + std::wstring sTemp; + + for (const wchar_t& wc : sValue) + { + sTemp += wc; + + if (wc == L' ') + { + arValues.push_back(sTemp); + sTemp.clear(); + } + } + + if (!sTemp.empty()) + arValues.push_back(sTemp); + + if (arValues.size() > 1) + return arValues[1]; + else if (arValues.size() == 1) + return arValues[0]; + + return std::wstring(); + } + + std::wstring CCompiledStyle::GetMarginBottom2() const + { + styles_iterator oMarginBottom = m_mStyle.find(L"margin-bottom"); + if (oMarginBottom != m_mStyle.end()) + return oMarginBottom->second; + + const std::wstring& sMarginBlockEnd = GetMarginBlockEnd(); + return sMarginBlockEnd.empty() ? std::wstring() : sMarginBlockEnd; + } + + std::wstring CCompiledStyle::GetMarginBottom() const + { + styles_iterator oMarginBottom = m_mStyle.find(L"margin-bottom"); + + if (oMarginBottom != m_mStyle.end()) + return oMarginBottom->second; + + const std::wstring& sMarginBlockEnd = GetMarginBlockEnd(); + + if (!sMarginBlockEnd.empty()) + return sMarginBlockEnd; + + std::wstring sValue; + styles_iterator oMargin = m_mStyle.find(L"margin"); + + if (oMargin != m_mStyle.end()) + sValue = oMargin->second; + else + return std::wstring(); + + if (sValue.empty()) + return std::wstring(); + + std::vector arValues; + + std::wstring sTemp; + + for (const wchar_t& wc : sValue) + { + sTemp += wc; + + if (wc == L' ') + { + arValues.push_back(sTemp); + sTemp.clear(); + } + } + if (!sTemp.empty()) + arValues.push_back(sTemp); + + if (arValues.size() > 2) + return arValues[2]; + else if (arValues.size() > 0) + return arValues[0]; + + return std::wstring(); + } + + std::wstring CCompiledStyle::GetMarginBlockEnd() const + { + styles_iterator oMarginBlockEnd = m_mStyle.find(L"margin-block-end"); + return oMarginBlockEnd != m_mStyle.end() ? oMarginBlockEnd->second : std::wstring(); + } + + /* PADDING */ + std::wstring CCompiledStyle::GetPadding() const + { + styles_iterator oPadding = m_mStyle.find(L"padding"); + + if (oPadding != m_mStyle.end()) + return oPadding->second; + + const std::wstring& sTop = GetPaddingTop(); + const std::wstring& sLeft = GetPaddingLeft(); + const std::wstring& sRight = GetPaddingRight(); + const std::wstring& sBottom = GetPaddingBottom(); + + if ((sTop == sLeft) && (sLeft == sRight) && (sRight == sBottom)) + return sTop; + + if ((sTop == sBottom) && (sLeft == sRight)) + return sTop + L" " + sLeft; + + if (sLeft == sRight) + return sTop + L" " + sLeft + L" " + sBottom; + + return sTop + L" " + sRight + L" " + sBottom + L" " + sLeft; + } + + std::wstring CCompiledStyle::GetPaddingTop() const + { + styles_iterator oPaddingTop = m_mStyle.find(L"padding-top"); + + if (oPaddingTop != m_mStyle.end()) + return oPaddingTop->second; + + std::wstring sValue; + styles_iterator oPadding = m_mStyle.find(L"padding"); + + if (oPadding != m_mStyle.end()) + sValue = oPadding->second; + else + return std::wstring(); + + if (sValue.empty()) + return std::wstring(); + + std::vector arValues; + + std::wstring sTemp; + + for (const wchar_t& wc : sValue) + { + sTemp += wc; + + if (wc == L' ') + { + arValues.push_back(sTemp); + sTemp.clear(); + } + } + if (!sTemp.empty()) + arValues.push_back(sTemp); + + if (!arValues.empty()) + return arValues[0]; + + return std::wstring(); + } + + std::wstring CCompiledStyle::GetPaddingLeft() const + { + styles_iterator oPaddingLeft = m_mStyle.find(L"padding-left"); + + if (oPaddingLeft != m_mStyle.end()) + return oPaddingLeft->second; + + std::wstring sValue; + styles_iterator oPadding = m_mStyle.find(L"padding"); + + if (oPadding != m_mStyle.end()) + sValue = oPadding->second; + else + return std::wstring(); + + if (sValue.empty()) + return std::wstring(); + + std::vector arValues; + + std::wstring sTemp; + + for (const wchar_t& wc : sValue) + { + sTemp += wc; + + if (wc == L' ') + { + arValues.push_back(sTemp); + sTemp.clear(); + } + } + + if (!sTemp.empty()) + arValues.push_back(sTemp); + + if (arValues.size() == 4) + return arValues[3]; + else if (arValues.size() > 1) + return arValues[1]; + else if (arValues.size() == 1) + return arValues[0]; + + return std::wstring(); + } + + std::wstring CCompiledStyle::GetPaddingRight() const + { + styles_iterator + oPaddingRight = m_mStyle.find(L"padding-right"); + + if (oPaddingRight != m_mStyle.end()) + return oPaddingRight->second; + + std::wstring sValue; + styles_iterator oPadding = m_mStyle.find(L"padding"); + + if (oPadding != m_mStyle.end()) + sValue = oPadding->second; + else + return std::wstring(); + + if (sValue.empty()) + return std::wstring(); + + std::vector arValues; + + std::wstring sTemp; + + for (const wchar_t& wc : sValue) + { + sTemp += wc; + + if (wc == L' ') + { + arValues.push_back(sTemp); + sTemp.clear(); + } + } + + if (!sTemp.empty()) + arValues.push_back(sTemp); + + if (arValues.size() > 1) + return arValues[1]; + else if (arValues.size() == 1) + return arValues[0]; + + return std::wstring(); + } + + std::wstring CCompiledStyle::GetPaddingBottom() const + { + styles_iterator oPaddingBottom = m_mStyle.find(L"padding-bottom"); + + if (oPaddingBottom != m_mStyle.end()) + return oPaddingBottom->second; + + std::wstring sValue; + styles_iterator oPadding = m_mStyle.find(L"padding"); + + if (oPadding != m_mStyle.end()) + sValue = oPadding->second; + else + return std::wstring(); + + if (sValue.empty()) + return std::wstring(); + + std::vector arValues; + + std::wstring sTemp; + + for (const wchar_t& wc : sValue) + { + sTemp += wc; + + if (wc == L' ') + { + arValues.push_back(sTemp); + sTemp.clear(); + } + } + + if (!sTemp.empty()) + arValues.push_back(sTemp); + + if (arValues.size() > 2) + return arValues[2]; + else if (arValues.size() > 0) + return arValues[0]; + + return std::wstring(); + } + + /* SPACING */ + std::wstring CCompiledStyle::GetLetterSpacing() const + { + styles_iterator oLetterSpacing = m_mStyle.find(L"letter-spacing"); + + if (oLetterSpacing != m_mStyle.end()) + return oLetterSpacing->second; + + return std::wstring(); + } + + std::wstring CCompiledStyle::GetWordSpacing() const + { + styles_iterator oWordSpacing = m_mStyle.find(L"word-spacing"); + + if (oWordSpacing != m_mStyle.end()) + return oWordSpacing->second; + + return std::wstring(); + } + + std::wstring CCompiledStyle::GetBorderSpacing() const + { + styles_iterator oBorderSpacing = m_mStyle.find(L"border-spacing"); + + if (oBorderSpacing != m_mStyle.end()) + return oBorderSpacing->second; + + return std::wstring(); + } + + /* COLOR */ + std::wstring CCompiledStyle::GetTextDecorationColor() const + { + styles_iterator oTextDecorationColor = m_mStyle.find(L"text-decoration-color"); + + if (oTextDecorationColor != m_mStyle.end()) + return oTextDecorationColor->second; + + return std::wstring(); + } + + std::wstring CCompiledStyle::GetBackgroundColor() const + { + styles_iterator oBackgroundColor = m_mStyle.find(L"background-color"); + + if (oBackgroundColor != m_mStyle.end()) + { + std::wstring sColor = oBackgroundColor->second; + + if (sColor[0] == L'#') + { + if (sColor.length() == 7) + return sColor.substr(1, 7); + else if (sColor.length() == 4) { - sValueString += sValueTemp; - continue; + std::wstring sRetColor; + sRetColor += sColor[1]; + sRetColor += sColor[1]; + sRetColor += sColor[2]; + sRetColor += sColor[2]; + sRetColor += sColor[3]; + sRetColor += sColor[3]; + return sRetColor; } + else + return L"auto"; } - const size_t posPercent = sValueTemp.find(L'%'); + std::transform(sColor.begin(), sColor.end(), sColor.begin(), tolower); - if (posPercent != std::wstring::npos) + styles_iterator oHEX = NS_CONST_VALUES::mColors.find(sColor); + + if (oHEX != NS_CONST_VALUES::mColors.end()) + return oHEX->second; + } + const std::wstring& sBackground = GetBackground(); + + if (sBackground.empty()) + return std::wstring(); + + const std::vector& arWords = NS_STATIC_FUNCTIONS::GetWordsW(sBackground); + + for (std::wstring sColor : arWords) + { + if (sColor[0] == L'#') { - const float dValue = wcstof(sValueTemp.substr(0, posPercent).c_str(), NULL) * fPreviousValue / 100; - - sValueString += std::to_wstring(static_cast(dValue + 0.5f)); - - if (sValueTemp.find(L';') != std::wstring::npos) - sValueString += L';'; - else if (arValues.size() > 1 && sValueTemp.find(L':') == std::wstring::npos) - sValueString += L' '; + if (sColor.length() == 7) + return sColor.substr(1, 7); + else if (sColor.length() == 4) + { + std::wstring sRetColor; + sRetColor += sColor[1]; + sRetColor += sColor[1]; + sRetColor += sColor[2]; + sRetColor += sColor[2]; + sRetColor += sColor[3]; + sRetColor += sColor[3]; + return sRetColor; + } + else + return L"auto"; } - else if (sValueTemp.find(L"px") != std::wstring::npos) - { - sValueString += ConvertPx(sValueTemp); - if (sValueTemp.find(L';') != std::wstring::npos) - sValueString += L';'; - else if (arValues.size() > 1 && sValueTemp.find(L':') == std::wstring::npos) - sValueString += L' '; - } - else if (sValueTemp.find(L"cm") != std::wstring::npos) - { - sValueString += ConvertCm(sValueTemp); + std::transform(sColor.begin(), sColor.end(), sColor.begin(), tolower); - if (sValueTemp.find(L';') != std::wstring::npos) - sValueString += L';'; - else if (arValues.size() > 1 && sValueTemp.find(L':') == std::wstring::npos) - sValueString += L' '; - } - else if (sValueTemp.find(L"mm") != std::wstring::npos) - { - sValueString += ConvertMm(sValueTemp); + styles_iterator oHEX = NS_CONST_VALUES::mColors.find(sColor); - if (sValueTemp.find(L';') != std::wstring::npos) - sValueString += L';'; - else if (arValues.size() > 1 && sValueTemp.find(L':') == std::wstring::npos) - sValueString += L' '; - } - else if (sValueTemp.find(L"in") != std::wstring::npos) - { - sValueString += ConvertIn(sValueTemp); + if (oHEX != NS_CONST_VALUES::mColors.end()) + return oHEX->second; + } - if (sValueTemp.find(L';') != std::wstring::npos) - sValueString += L';'; - else if (arValues.size() > 1 && sValueTemp.find(L':') == std::wstring::npos) - sValueString += L' '; - } - else if (sValueTemp.find(L"pt") != std::wstring::npos) - { - sValueString += ConvertPt(sValueTemp); + return std::wstring(); + } - if (sValueTemp.find(L';') != std::wstring::npos) - sValueString += L';'; - else if (arValues.size() > 1 && sValueTemp.find(L':') == std::wstring::npos) - sValueString += L' '; - } - else if (sValueTemp.find(L"pc") != std::wstring::npos) - { - sValueString += ConvertPc(sValueTemp); + std::wstring CCompiledStyle::GetColor() const + { + styles_iterator oColor = m_mStyle.find(L"color"); + if (oColor == m_mStyle.end()) + return std::wstring(); - if (sValueTemp.find(L';') != std::wstring::npos) - sValueString += L';'; - else if (arValues.size() > 1 && sValueTemp.find(L':') == std::wstring::npos) - sValueString += L' '; - } - else if (sValueTemp.find(L"em") != std::wstring::npos) - { - const float fValue = wcstof(sValue.c_str(), NULL) * m_pFont.GetSize(); - sValueString += std::to_wstring(static_cast(fValue + 0.5f)); + std::wstring sColor = oColor->second; - if (sValueTemp.find(L';') != std::wstring::npos) - sValueString += L';'; - else if (arValues.size() > 1 && sValueTemp.find(L':') == std::wstring::npos) - sValueString += L' '; + if (sColor[0] == L'#') + { + if (sColor.length() == 7) + return sColor.substr(1, 7); + else if (sColor.length() == 4) + { + std::wstring sRetColor; + sRetColor = sColor[1] + sColor[1] + sColor[2] + sColor[2] + sColor[3] + sColor[3]; + return sRetColor; } + else + return L""; + } + + std::transform(sColor.begin(), sColor.end(), sColor.begin(), tolower); + + styles_iterator oHEX = NS_CONST_VALUES::mColors.find(sColor); + + if (oHEX != NS_CONST_VALUES::mColors.end()) + return oHEX->second; + + return L""; + } + + std::wstring CCompiledStyle::GetOutlineColor() const + { + styles_iterator oOutlineColor = m_mStyle.find(L"outline-color"); + return oOutlineColor != m_mStyle.end() ? oOutlineColor->second : std::wstring(); + } + + std::wstring CCompiledStyle::GetColumnRuleColor() const + { + styles_iterator oColumnRuleColor = m_mStyle.find(L"column-rule-color"); + return oColumnRuleColor != m_mStyle.end() ? oColumnRuleColor->second : std::wstring(); + } + + std::wstring CCompiledStyle::GetBackground() const + { + styles_iterator oBackground = m_mStyle.find(L"background"); + return oBackground != m_mStyle.end() ? oBackground->second : std::wstring(); + } + + /* TEXT */ + std::wstring CCompiledStyle::GetTextAlign() const + { + styles_iterator oTextAlign = m_mStyle.find(L"text-align"); + return oTextAlign != m_mStyle.end() ? oTextAlign->second : std::wstring(); + } + + std::wstring CCompiledStyle::GetTextIndent() const + { + styles_iterator oTextIndent = m_mStyle.find(L"text-indent"); + return oTextIndent != m_mStyle.end() ? oTextIndent->second : std::wstring(); + } + + std::wstring CCompiledStyle::GetTextDecoration() const + { + styles_iterator oTextDecoration = m_mStyle.find(L"text-decoration"); + + if (oTextDecoration != m_mStyle.end()) + { + if (oTextDecoration->second == L"underline") + return std::wstring(L"single"); + else if (oTextDecoration->second == L"none") + return oTextDecoration->second; + } + + return L""; + +// return oTextDecoration != m_mStyle.end() ? oTextDecoration->second : std::wstring(); + } + + /* BORDER */ + + std::wstring CCompiledStyle::GetBorder() const + { + styles_iterator oBorder = m_mStyle.find(L"border"); + + if (oBorder != m_mStyle.end() && oBorder->second != L"none") + return oBorder->second; else { - sValueString += sValueTemp; - - if (sValueTemp.find(L";") != std::wstring::npos) - sValueString += L';'; - - continue; + styles_iterator oMsoBorder = m_mStyle.find(L"mso-border-alt"); + if (oMsoBorder != m_mStyle.end() && oMsoBorder->second != L"none") + return oMsoBorder->second; } - if (sValueTemp.back() != L';' && sValueTemp.back() != L':' && sValueTemp.back() != L' ') - sValueTemp += L' '; - } + const std::wstring& sBorderWidth = GetBorderWidth(); + const std::wstring& sBorderStyle = GetBorderStyle(); + const std::wstring& sBorderColor = GetBorderColor(); - return sValueString; - } + if (!sBorderWidth.empty() && !sBorderStyle.empty() && !sBorderColor.empty()) + return sBorderWidth + L" " + sBorderStyle + L" " + sBorderColor; - inline std::wstring CCompiledStyle::ConvertPx(const std::wstring& sValue) const - { - if (sValue.empty()) return std::wstring(); - - const std::wstring& sConvertValue = sValue.substr(0, sValue.find_last_of(L"px") - 1); - const float dValue = wcstof(sConvertValue.c_str(), NULL) * 2.0f; - - switch (m_UnitMeasure) - { - case Pixel: - return std::to_wstring(static_cast(dValue));; - case Default: - case Point: - return ConvertPxToPt(dValue); - case Cantimeter: - return ConvertPxToCm(dValue); - case Millimeter: - return ConvertPxToMm(dValue); - case Inch: - return ConvertPxToIn(dValue); - case Peak: - return ConvertPxToPc(dValue); } - return std::wstring(); - } + std::wstring CCompiledStyle::GetBorderWidth() const + { + styles_iterator oBorderWidth = m_mStyle.find(L"border-width"); - inline std::wstring CCompiledStyle::ConvertPxToCm(const float& dValue) const - { - if (dValue == 0.0f) - return std::wstring(L"0"); + if (oBorderWidth != m_mStyle.end()) + return oBorderWidth->second; - return std::to_wstring(static_cast(dValue / static_cast(m_nDpi) * 2.54f + 0.5f)); - } + styles_iterator oBorder = m_mStyle.find(L"border"); - inline std::wstring CCompiledStyle::ConvertPxToIn(const float& dValue) const - { - if (dValue == 0.0f) - return std::wstring(L"0"); + std::wstring sBorder; - return std::to_wstring(static_cast(1.0f / static_cast(m_nDpi) * dValue + 0.5f)); - } + if (oBorder != m_mStyle.end() && oBorder->second != L"none") + sBorder = oBorder->second; + else + { + styles_iterator oMsoBorder = m_mStyle.find(L"mso-border-alt"); + if (oMsoBorder != m_mStyle.end() && oMsoBorder->second != L"none") + sBorder = oMsoBorder->second; + else + return std::wstring(); + } - inline std::wstring CCompiledStyle::ConvertPxToMm(const float& dValue) const - { - if (dValue == 0.0f) - return std::wstring(L"0"); + const std::vector& arWords = NS_STATIC_FUNCTIONS::GetWordsW(sBorder); - return std::to_wstring(static_cast(dValue / static_cast(m_nDpi) * 25.4f + 0.5f)); - } + for (const std::wstring& sWidth : arWords) + if (iswdigit(sWidth[0])) + return sWidth; - inline std::wstring CCompiledStyle::ConvertPxToPc(const float& dValue) const - { - if (dValue == 0.0f) - return std::wstring(L"0"); - - return std::to_wstring(static_cast(0.16667f / static_cast(m_nDpi) * dValue + 0.5f)); - } - - inline std::wstring CCompiledStyle::ConvertPxToPt(const float& dValue) const - { - if (dValue == 0.0f) - return std::wstring(L"0"); - - return std::to_wstring(static_cast(72.0f / static_cast(m_nDpi) * dValue + 0.5f)); - } - - inline std::wstring CCompiledStyle::ConvertCm(const std::wstring& sValue) const - { - if (sValue.empty()) return std::wstring(); - - const std::wstring& sConvertValue = sValue.substr(0, sValue.find_last_of(L"cm") - 1); - const float dValue = wcstof(sConvertValue.c_str(), NULL) * 2.0f; - - switch (m_UnitMeasure) - { - case Default: - case Point: - return ConvertCmToPt(dValue); - case Pixel: - return ConvertCmToPx(dValue); - case Cantimeter: - return std::to_wstring(static_cast(dValue));; - case Millimeter: - return ConvertCmToMm(dValue); - case Inch: - return ConvertCmToIn(dValue); - case Peak: - return ConvertCmToPc(dValue); } - return std::wstring(); - } + std::wstring CCompiledStyle::GetBorderStyle() const + { + styles_iterator oBorderStyle = m_mStyle.find(L"border-style"); - inline std::wstring CCompiledStyle::ConvertCmToIn(const float& dValue) const - { - if (dValue == 0.0f) - return std::wstring(L"0"); + if (oBorderStyle != m_mStyle.end()) + return oBorderStyle->second; - return std::to_wstring(static_cast(dValue / 2.54f + 0.5f)); - } + styles_iterator oBorder = m_mStyle.find(L"border"); - inline std::wstring CCompiledStyle::ConvertCmToMm(const float& dValue) const - { - if (dValue == 0.0f) - return std::wstring(L"0"); + std::wstring sBorder; - return std::to_wstring(static_cast(dValue * 10.0f + 0.5f)); - } + if (oBorder != m_mStyle.end() && oBorder->second != L"none") + sBorder = oBorder->second; + else + { + styles_iterator oMsoBorder = m_mStyle.find(L"mso-border-alt"); + if (oMsoBorder != m_mStyle.end() && oMsoBorder->second != L"none") + sBorder = oMsoBorder->second; + else + return std::wstring(); + } - inline std::wstring CCompiledStyle::ConvertCmToPc(const float& dValue) const - { - if (dValue == 0.0f) - return std::wstring(L"0"); + const std::vector& arWords = NS_STATIC_FUNCTIONS::GetWordsW(sBorder); - return std::to_wstring(static_cast(2.36f * dValue + 0.5f)); - } + for (std::wstring sStyle : arWords) + { + std::transform(sStyle.begin(), sStyle.end(), sStyle.begin(), tolower); + styles_iterator oStyle = NS_CONST_VALUES::mStyles.find(sStyle); - inline std::wstring CCompiledStyle::ConvertCmToPt(const float& dValue) const - { - if (dValue == 0.0f) - return std::wstring(L"0"); + if (oStyle != NS_CONST_VALUES::mStyles.end()) + return oStyle->second; + } - return std::to_wstring(static_cast(28.35f * dValue + 0.5f)); - } - - inline std::wstring CCompiledStyle::ConvertCmToPx(const float& dValue) const - { - if (dValue == 0.0f) - return std::wstring(L"0"); - - return std::to_wstring(static_cast(static_cast(m_nDpi) / 2.54f * dValue + 0.5f)); - } - - inline std::wstring CCompiledStyle::ConvertMm(const std::wstring& sValue) const - { - if (sValue.empty()) return std::wstring(); - - const std::wstring& sConvertValue = sValue.substr(0, sValue.find_last_of(L"mm") - 1); - const float dValue = wcstof(sConvertValue.c_str(), NULL) * 2.0f; - - switch (m_UnitMeasure) - { - case Pixel: - return ConvertMmToPx(dValue); - case Default: - case Point: - return ConvertMmToPt(dValue); - case Cantimeter: - return ConvertMmToCm(dValue); - case Millimeter: - return std::to_wstring(static_cast(dValue));; - case Inch: - return ConvertMmToIn(dValue); - case Peak: - return ConvertMmToPc(dValue); } - return std::wstring(); - } - inline std::wstring CCompiledStyle::ConvertMmToIn(const float& dValue) const - { - if (dValue == 0.0f) - return std::wstring(L"0"); + std::wstring CCompiledStyle::GetBorderColor() const + { + styles_iterator oBorderColor = m_mStyle.find(L"border-color"); - return std::to_wstring(static_cast(dValue / 25.4f + 0.5f)); - } + if (oBorderColor != m_mStyle.end()) + return oBorderColor->second; - inline std::wstring CCompiledStyle::ConvertMmToCm(const float& dValue) const - { - if (dValue == 0.0f) - return std::wstring(L"0"); + styles_iterator oBorder = m_mStyle.find(L"border"); - return std::to_wstring(static_cast(dValue / 10.0f + 0.5f)); - } + std::wstring sBorder; - inline std::wstring CCompiledStyle::ConvertMmToPc(const float& dValue) const - { - if (dValue == 0.0f) - return std::wstring(L"0"); + if (oBorder != m_mStyle.end() && oBorder->second != L"none") + sBorder = oBorder->second; + else + { + styles_iterator oMsoBorder = m_mStyle.find(L"mso-border-alt"); + if (oMsoBorder != m_mStyle.end() && oMsoBorder->second != L"none") + sBorder = oMsoBorder->second; + else + return std::wstring(); + } - return std::to_wstring(static_cast(2.8346f * dValue + 0.5f)); - } + const std::vector& arWords = NS_STATIC_FUNCTIONS::GetWordsW(sBorder); - inline std::wstring CCompiledStyle::ConvertMmToPt(const float& dValue) const - { - if (dValue == 0) - return std::wstring(L"0"); + for (std::wstring sColor : arWords) + { + if (sColor[0] == L'#') + { + if (sColor.length() == 7) + return sColor.substr(1, 7); + else if (sColor.length() == 4) + { + std::wstring sRetColor; + sRetColor += sColor[1]; + sRetColor += sColor[1]; + sRetColor += sColor[2]; + sRetColor += sColor[2]; + sRetColor += sColor[3]; + sRetColor += sColor[3]; + return sRetColor; + } + else + return L"auto"; + } - return std::to_wstring(static_cast(0.23262f * dValue + 0.5f)); - } + std::transform(sColor.begin(), sColor.end(), sColor.begin(), tolower); - inline std::wstring CCompiledStyle::ConvertMmToPx(const float& dValue) const - { - if (dValue == 0) - return std::wstring(L"0"); + styles_iterator oHEX = NS_CONST_VALUES::mColors.find(sColor); - return std::to_wstring(static_cast(static_cast(m_nDpi) / 25.4f * dValue + 0.5f)); - } + if (oHEX != NS_CONST_VALUES::mColors.end()) + return oHEX->second; + } - inline std::wstring CCompiledStyle::ConvertIn(const std::wstring& sValue) const - { - if (sValue.empty()) return std::wstring(); - - const std::wstring& sConvertValue = sValue.substr(0, sValue.find_last_of(L"in") - 1); - const float dValue = wcstof(sConvertValue.c_str(), NULL) * 2.0f; - - switch (m_UnitMeasure) - { - case Pixel: - return ConvertInToPx(dValue); - case Default: - case Point: - return ConvertInToPt(dValue); - case Cantimeter: - return ConvertInToCm(dValue); - case Millimeter: - return ConvertInToMm(dValue); - case Inch: - return std::to_wstring(static_cast(dValue));; - case Peak: - return ConvertInToPc(dValue); } - return std::wstring(); - } - inline std::wstring CCompiledStyle::ConvertInToMm(const float& dValue) const - { - if (dValue == 0.0f) - return std::wstring(L"0"); + std::wstring CCompiledStyle::GetBorderBottom() const + { + styles_iterator oBorderBottom = m_mStyle.find(L"border-bottom"); - return std::to_wstring(static_cast(dValue * 25.4f + 0.5f)); - } + if (oBorderBottom != m_mStyle.end()) + return oBorderBottom->second; - inline std::wstring CCompiledStyle::ConvertInToCm(const float& dValue) const - { - if (dValue == 0.0f) - return std::wstring(L"0"); + const std::wstring& sBorderBottomWidth = GetBorderBottomWidth(); + const std::wstring& sBorderBottomStyle = GetBorderBottomStyle(); + const std::wstring& sBorderBottomColor = GetBorderBottomColor(); - return std::to_wstring(static_cast(dValue * 2.54f + 0.5f)); - } + if (!sBorderBottomWidth.empty() && !sBorderBottomStyle.empty() && !sBorderBottomColor.empty()) + return sBorderBottomWidth + L" " + sBorderBottomStyle + L" " + sBorderBottomColor; - inline std::wstring CCompiledStyle::ConvertInToPc(const float& dValue) const - { - if (dValue == 0.0f) - return std::wstring(L"0"); - - return std::to_wstring(static_cast(dValue / 72.0f + 0.5f)); - } - - inline std::wstring CCompiledStyle::ConvertInToPt(const float& dValue) const - { - if (dValue == 0.0f) - return std::wstring(L"0"); - - return std::to_wstring(static_cast(dValue / 6.0f + 0.5f)); - } - - inline std::wstring CCompiledStyle::ConvertInToPx(const float& dValue) const - { - if (dValue == 0.0f) - return std::wstring(L"0"); - - return std::to_wstring(static_cast(dValue * static_cast(m_nDpi) + 0.5f)); - } - - inline std::wstring CCompiledStyle::ConvertPt(const std::wstring& sValue) const - { - if (sValue.empty()) return std::wstring(); - - const std::wstring& sConvertValue = sValue.substr(0, sValue.find_last_of(L"pt") - 1); - const float dValue = wcstof(sConvertValue.c_str(), NULL) * 2.0f; - - switch (m_UnitMeasure) - { - case Pixel: - return ConvertPtToPx(dValue); - case Default: - case Point: - return std::to_wstring(static_cast(dValue)); - case Cantimeter: - return ConvertPtToCm(dValue); - case Millimeter: - return ConvertPtToMm(dValue); - case Inch: - return ConvertPtToIn(dValue); - case Peak: - return ConvertPtToPc(dValue); } - return std::wstring(); - } + std::wstring CCompiledStyle::GetBorderBottomWidth() const + { + styles_iterator oBorderBottomWidth = m_mStyle.find(L"border-bottom-width"); - inline std::wstring CCompiledStyle::ConvertPtToIn(const float& dValue) const - { - if (dValue == 0.0f) - return std::wstring(L"0"); + if (oBorderBottomWidth != m_mStyle.end()) + return oBorderBottomWidth->second; - return std::to_wstring((dValue / 72.0f + 0.5f)); - } + styles_iterator oBorderBottom = m_mStyle.find(L"border-bottom"); - inline std::wstring CCompiledStyle::ConvertPtToCm(const float& dValue) const - { - if (dValue == 0.0f) - return std::wstring(L"0"); + std::wstring sBorderBottom; - return std::to_wstring(static_cast(dValue * 0.03528f + 0.5f)); - } + if (oBorderBottom != m_mStyle.end()) + sBorderBottom = oBorderBottom->second; + else + return std::wstring(); - inline std::wstring CCompiledStyle::ConvertPtToPc(const float& dValue) const - { - if (dValue == 0.0f) - return std::wstring(L"0"); + const std::vector& arWords = NS_STATIC_FUNCTIONS::GetWordsW(sBorderBottom); - return std::to_wstring(static_cast(dValue / 12.0f + 0.5f)); - } + for (const std::wstring& sWidth : arWords) + if (iswdigit(sWidth[0])) + return sWidth; - inline std::wstring CCompiledStyle::ConvertPtToMm(const float& dValue) const - { - if (dValue == 0.0f) - return std::wstring(L"0"); - - return std::to_wstring((dValue * 0.3528f + 0.5f)); - } - - inline std::wstring CCompiledStyle::ConvertPtToPx(const float& dValue) const - { - if (dValue == 0.0f) - return std::wstring(L"0"); - - return std::to_wstring(static_cast(static_cast(m_nDpi) / 72.0f * dValue + 0.5f)); - } - - inline std::wstring CCompiledStyle::ConvertPc(const std::wstring& sValue) const - { - if (sValue.empty()) return std::wstring(); - - const std::wstring& sConvertValue = sValue.substr(0, sValue.find_last_of(L"pc") - 1); - const float dValue = wcstof(sConvertValue.c_str(), NULL) * 2.0f; - - switch (m_UnitMeasure) - { - case Pixel: - return ConvertPcToPx(dValue); - case Default: - case Point: - return ConvertPcToPt(dValue); - case Cantimeter: - return ConvertPcToCm(dValue); - case Millimeter: - return ConvertPcToMm(dValue); - case Inch: - return ConvertPcToIn(dValue); - case Peak: - return std::to_wstring(static_cast(dValue)); } - return std::wstring(); - } + std::wstring CCompiledStyle::GetBorderBottomStyle() const + { + styles_iterator oBorderBottomStyle = m_mStyle.find(L"border-bottom-style"); - inline std::wstring CCompiledStyle::ConvertPcToIn(const float& dValue) const - { - if (dValue == 0.0f) - return std::wstring(L"0"); + if (oBorderBottomStyle != m_mStyle.end()) + return oBorderBottomStyle->second; - return std::to_wstring(static_cast(dValue / 6.0f + 0.5f)); - } + styles_iterator oBorderBottom = m_mStyle.find(L"border-bottom"); - inline std::wstring CCompiledStyle::ConvertPcToCm(const float& dValue) const - { - if (dValue == 0.0f) - return std::wstring(L"0"); + std::wstring sBorderBottom; - return std::to_wstring(static_cast(dValue * 0.423f + 0.5f)); - } + if (oBorderBottom != m_mStyle.end()) + sBorderBottom = oBorderBottom->second; + else + return std::wstring(); - inline std::wstring CCompiledStyle::ConvertPcToPt(const float& dValue) const - { - if (dValue == 0.0f) - return std::wstring(L"0"); + const std::vector& arWords = NS_STATIC_FUNCTIONS::GetWordsW(sBorderBottom); - return std::to_wstring(static_cast(dValue * 12.0f + 0.5f)); - } + for (std::wstring sStyle : arWords) + { + std::transform(sStyle.begin(), sStyle.end(), sStyle.begin(), tolower); + styles_iterator oStyle = NS_CONST_VALUES::mStyles.find(sStyle); - inline std::wstring CCompiledStyle::ConvertPcToMm(const float& dValue) const - { - if (dValue == 0.0f) - return std::wstring(L"0"); + if (oStyle != NS_CONST_VALUES::mStyles.end()) + return oStyle->second; + } - return std::to_wstring(static_cast(dValue * 4.23f + 0.5f)); - } + return std::wstring(); + } - inline std::wstring CCompiledStyle::ConvertPcToPx(const float& dValue) const - { - if (dValue == 0.0f) - return std::wstring(L"0"); + std::wstring CCompiledStyle::GetBorderBottomColor() const + { + styles_iterator oBorderBottomColor = m_mStyle.find(L"border-bottom-color"); - return std::to_wstring(static_cast(static_cast(m_nDpi) / 6.0f * dValue + 0.5f)); - } + if (oBorderBottomColor != m_mStyle.end()) + return oBorderBottomColor->second;\ + + styles_iterator oBorderBottom = m_mStyle.find(L"border-bottom"); + + std::wstring sBorderBottom; + + if (oBorderBottom != m_mStyle.end()) + sBorderBottom = oBorderBottom->second; + else + return std::wstring(); + + const std::vector& arWords = NS_STATIC_FUNCTIONS::GetWordsW(sBorderBottom); + + for (std::wstring sColor : arWords) + { + if (sColor[0] == L'#') + { + if (sColor.length() == 7) + return sColor.substr(1, 7); + else if (sColor.length() == 4) + { + std::wstring sRetColor; + sRetColor += sColor[1]; + sRetColor += sColor[1]; + sRetColor += sColor[2]; + sRetColor += sColor[2]; + sRetColor += sColor[3]; + sRetColor += sColor[3]; + return sRetColor; + } + else + return L"auto"; + } + + std::transform(sColor.begin(), sColor.end(), sColor.begin(), tolower); + + styles_iterator oHEX = NS_CONST_VALUES::mColors.find(sColor); + + if (oHEX != NS_CONST_VALUES::mColors.end()) + return oHEX->second; + } + + return std::wstring(); + } + + std::wstring CCompiledStyle::GetBorderLeft() const + { + styles_iterator oBorderLeft = m_mStyle.find(L"border-left"); + + if (oBorderLeft != m_mStyle.end()) + return oBorderLeft->second; + + const std::wstring& sBorderLeftWidth = GetBorderLeftWidth(); + const std::wstring& sBorderLeftStyle = GetBorderLeftStyle(); + const std::wstring& sBorderLeftColor = GetBorderLeftColor(); + + if (!sBorderLeftWidth.empty() && !sBorderLeftStyle.empty() && !sBorderLeftColor.empty()) + return sBorderLeftWidth + L" " + sBorderLeftStyle + L" " + sBorderLeftColor; + + return std::wstring(); + } + + std::wstring CCompiledStyle::GetBorderLeftWidth() const + { + styles_iterator oBorderLeftWidth = m_mStyle.find(L"border-left-width"); + + if (oBorderLeftWidth != m_mStyle.end()) + return oBorderLeftWidth->second; + + styles_iterator oBorderLeft = m_mStyle.find(L"border-left"); + + std::wstring sBorderLeft; + + if (oBorderLeft != m_mStyle.end()) + sBorderLeft = oBorderLeft->second; + else + return std::wstring(); + + const std::vector& arWords = NS_STATIC_FUNCTIONS::GetWordsW(sBorderLeft); + + for (const std::wstring& sWidth : arWords) + if (iswdigit(sWidth[0])) + return sWidth; + + return std::wstring(); + } + + std::wstring CCompiledStyle::GetBorderLeftStyle() const + { + styles_iterator oBorderLeftStyle = m_mStyle.find(L"border-left-style"); + + if (oBorderLeftStyle != m_mStyle.end()) + return oBorderLeftStyle->second; + + styles_iterator oBorderLeft = m_mStyle.find(L"border-left"); + + std::wstring sBorderLeft; + + if (oBorderLeft != m_mStyle.end()) + sBorderLeft = oBorderLeft->second; + else + return std::wstring(); + + const std::vector& arWords = NS_STATIC_FUNCTIONS::GetWordsW(sBorderLeft); + + for (std::wstring sStyle : arWords) + { + styles_iterator oStyle = NS_CONST_VALUES::mStyles.find(sStyle); + + if (oStyle != NS_CONST_VALUES::mStyles.end()) + return oStyle->second; + } + + return std::wstring(); + } + + std::wstring CCompiledStyle::GetBorderLeftColor() const + { + styles_iterator oBorderLeftColor = m_mStyle.find(L"border-left-color"); + + if (oBorderLeftColor != m_mStyle.end()) + return oBorderLeftColor->second; + + styles_iterator oBorderLeft = m_mStyle.find(L"border-left"); + + std::wstring sBorderLeft; + + if (oBorderLeft != m_mStyle.end()) + sBorderLeft = oBorderLeft->second; + else + return std::wstring(); + + const std::vector& arWords = NS_STATIC_FUNCTIONS::GetWordsW(sBorderLeft); + + for (std::wstring sColor : arWords) + { + if (sColor[0] == L'#') + { + if (sColor.length() == 7) + return sColor.substr(1, 7); + else if (sColor.length() == 4) + { + std::wstring sRetColor; + sRetColor += sColor[1]; + sRetColor += sColor[1]; + sRetColor += sColor[2]; + sRetColor += sColor[2]; + sRetColor += sColor[3]; + sRetColor += sColor[3]; + return sRetColor; + } + else + return L"auto"; + } + + const styles_iterator oHEX = NS_CONST_VALUES::mColors.find(sColor); + + if (oHEX != NS_CONST_VALUES::mColors.end()) + return oHEX->second; + } + + return std::wstring(); + } + + std::wstring CCompiledStyle::GetBorderRight() const + { + styles_iterator oBorderRight = m_mStyle.find(L"border-right"); + + if (oBorderRight != m_mStyle.end()) + return oBorderRight->second; + + const std::wstring& sBorderRightWidth = GetBorderRightWidth(); + const std::wstring& sBorderRightStyle = GetBorderRightStyle(); + const std::wstring& sBorderRightColor = GetBorderRightColor(); + + if (!sBorderRightWidth.empty() && !sBorderRightStyle.empty() && !sBorderRightColor.empty()) + return sBorderRightWidth + L" " + sBorderRightStyle + L" " + sBorderRightColor; + + return std::wstring(); + } + + std::wstring CCompiledStyle::GetBorderRightWidth() const + { + styles_iterator oBorderRightWidth = m_mStyle.find(L"border-right-width"); + + if (oBorderRightWidth != m_mStyle.end()) + return oBorderRightWidth->second; + + styles_iterator oBorderRight = m_mStyle.find(L"border-right"); + + std::wstring sBorderRight; + + if (oBorderRight != m_mStyle.end()) + sBorderRight = oBorderRight->second; + else + return std::wstring(); + + const std::vector& arWords = NS_STATIC_FUNCTIONS::GetWordsW(sBorderRight); + + for (const std::wstring& sWidth : arWords) + if (iswdigit(sWidth[0])) + return sWidth; + + return std::wstring(); + } + + std::wstring CCompiledStyle::GetBorderRightStyle() const + { + styles_iterator oBorderRightStyle = m_mStyle.find(L"border-right-style"); + + if (oBorderRightStyle != m_mStyle.end()) + return oBorderRightStyle->second; + + styles_iterator oBorderRight = m_mStyle.find(L"border-right"); + + std::wstring sBorderRight; + + if (oBorderRight != m_mStyle.end()) + sBorderRight = oBorderRight->second; + else + return std::wstring(); + + const std::vector& arWords = NS_STATIC_FUNCTIONS::GetWordsW(sBorderRight); + + for (std::wstring sStyle : arWords) + { + std::transform(sStyle.begin(), sStyle.end(), sStyle.begin(), tolower); + styles_iterator oStyle = NS_CONST_VALUES::mStyles.find(sStyle); + + if (oStyle != NS_CONST_VALUES::mStyles.end()) + return oStyle->second; + } + + return std::wstring(); + } + + std::wstring CCompiledStyle::GetBorderRightColor() const + { + styles_iterator oBorderRightColor = m_mStyle.find(L"border-right-color"); + + if (oBorderRightColor != m_mStyle.end()) + return oBorderRightColor->second; + + styles_iterator oBorderRight = m_mStyle.find(L"border-right"); + + std::wstring sBorderRight; + + if (oBorderRight != m_mStyle.end()) + sBorderRight = oBorderRight->second; + else + return std::wstring(); + + const std::vector& arWords = NS_STATIC_FUNCTIONS::GetWordsW(sBorderRight); + + for (std::wstring sColor : arWords) + { + if (sColor[0] == L'#') + { + if (sColor.length() == 7) + return sColor.substr(1, 7); + else if (sColor.length() == 4) + { + std::wstring sRetColor; + sRetColor += sColor[1]; + sRetColor += sColor[1]; + sRetColor += sColor[2]; + sRetColor += sColor[2]; + sRetColor += sColor[3]; + sRetColor += sColor[3]; + return sRetColor; + } + else + return L"auto"; + } + + std::transform(sColor.begin(), sColor.end(), sColor.begin(), tolower); + + styles_iterator oHEX = NS_CONST_VALUES::mColors.find(sColor); + + if (oHEX != NS_CONST_VALUES::mColors.end()) + return oHEX->second; + } + + return std::wstring(); + } + + std::wstring CCompiledStyle::GetBorderTop() const + { + styles_iterator oBorderTop = m_mStyle.find(L"border-top"); + + if (oBorderTop != m_mStyle.end()) + return oBorderTop->second; + + const std::wstring& sBorderTopWidth = GetBorderTopWidth(); + const std::wstring& sBorderTopStyle = GetBorderTopStyle(); + const std::wstring& sBorderTopColor = GetBorderTopColor(); + + if (!sBorderTopWidth.empty() && !sBorderTopStyle.empty() && !sBorderTopColor.empty()) + return sBorderTopWidth + L" " + sBorderTopStyle + L" " + sBorderTopColor; + + return std::wstring(); + } + + std::wstring CCompiledStyle::GetBorderTopWidth() const + { + styles_iterator oBorderTopWidth = m_mStyle.find(L"border-top-width"); + + if (oBorderTopWidth != m_mStyle.end()) + return oBorderTopWidth->second; + + styles_iterator oBorderTop = m_mStyle.find(L"border-top"); + + std::wstring sBorderTop; + + if (oBorderTop != m_mStyle.end()) + sBorderTop = oBorderTop->second; + else + return std::wstring(); + + const std::vector& arWords = NS_STATIC_FUNCTIONS::GetWordsW(sBorderTop); + + for (const std::wstring& sWidth : arWords) + if (iswdigit(sWidth[0])) + return sWidth; + + return std::wstring(); + } + + std::wstring CCompiledStyle::GetBorderTopStyle() const + { + styles_iterator oBorderTopStyle = m_mStyle.find(L"border-top-style"); + + if (oBorderTopStyle != m_mStyle.end()) + return oBorderTopStyle->second; + + styles_iterator oBorderTop = m_mStyle.find(L"border-top"); + + std::wstring sBorderTop; + + if (oBorderTop != m_mStyle.end()) + sBorderTop = oBorderTop->second; + else + return std::wstring(); + + const std::vector& arWords = NS_STATIC_FUNCTIONS::GetWordsW(sBorderTop); + + for (std::wstring sStyle : arWords) + { + std::transform(sStyle.begin(), sStyle.end(), sStyle.begin(), tolower); + styles_iterator oStyle = NS_CONST_VALUES::mStyles.find(sStyle); + + if (oStyle != NS_CONST_VALUES::mStyles.end()) + return oStyle->second; + } + + return std::wstring(); + } + + std::wstring CCompiledStyle::GetBorderTopColor() const + { + styles_iterator oBorderTopColor = m_mStyle.find(L"border-top-color"); + + if (oBorderTopColor != m_mStyle.end()) + return oBorderTopColor->second; + + styles_iterator oBorderTop = m_mStyle.find(L"border-top"); + + std::wstring sBorderTop; + + if (oBorderTop != m_mStyle.end()) + sBorderTop = oBorderTop->second; + else + return std::wstring(); + + const std::vector& arWords = NS_STATIC_FUNCTIONS::GetWordsW(sBorderTop); + + for (std::wstring sColor : arWords) + { + if (sColor[0] == L'#') + { + if (sColor.length() == 7) + return sColor.substr(1, 7); + else if (sColor.length() == 4) + { + std::wstring sRetColor; + sRetColor += sColor[1]; + sRetColor += sColor[1]; + sRetColor += sColor[2]; + sRetColor += sColor[2]; + sRetColor += sColor[3]; + sRetColor += sColor[3]; + return sRetColor; + } + else + return L"auto"; + } + std::transform(sColor.begin(), sColor.end(), sColor.begin(), tolower); + + styles_iterator oHEX = NS_CONST_VALUES::mColors.find(sColor); + + if (oHEX != NS_CONST_VALUES::mColors.end()) + return oHEX->second; + } + + return std::wstring(); + } } diff --git a/Common/3dParty/html/css/src/CCompiledStyle.h b/Common/3dParty/html/css/src/CCompiledStyle.h index 41bce6586b..52937a5307 100644 --- a/Common/3dParty/html/css/src/CCompiledStyle.h +++ b/Common/3dParty/html/css/src/CCompiledStyle.h @@ -2,10 +2,8 @@ #define CCOMPILEDSTYLE_H #include "CssCalculator_global.h" -#include "ConstValues.h" #include -#include #include #include @@ -13,78 +11,29 @@ namespace NSCSS { class CSSCALCULATOR_EXPORT CCompiledStyle { - std::set m_arParentsStyles; + std::map m_mStyle; + std::vector m_arParentsStyles; std::wstring m_sId; - unsigned short int m_nDpi; - UnitMeasure m_UnitMeasure; - - std::wstring ConvertUnitMeasure(const std::wstring& sValue, const float& fPreviousValue) const; - - std::wstring ConvertPx(const std::wstring& sValue) const; - std::wstring ConvertPxToCm(const float& dValue) const; - std::wstring ConvertPxToIn(const float& dValue) const; - std::wstring ConvertPxToMm(const float& dValue) const; - std::wstring ConvertPxToPt(const float& dValue) const; - std::wstring ConvertPxToPc(const float& dValue) const; - - std::wstring ConvertCm(const std::wstring& sValue) const; - std::wstring ConvertCmToPx(const float& dValue) const; - std::wstring ConvertCmToIn(const float& dValue) const; - std::wstring ConvertCmToMm(const float& dValue) const; - std::wstring ConvertCmToPt(const float& dValue) const; - std::wstring ConvertCmToPc(const float& dValue) const; - - std::wstring ConvertMm(const std::wstring& sValue) const; - std::wstring ConvertMmToPx(const float& dValue) const; - std::wstring ConvertMmToIn(const float& dValue) const; - std::wstring ConvertMmToCm(const float& dValue) const; - std::wstring ConvertMmToPt(const float& dValue) const; - std::wstring ConvertMmToPc(const float& dValue) const; - - std::wstring ConvertIn(const std::wstring& sValue) const; - std::wstring ConvertInToPx(const float& dValue) const; - std::wstring ConvertInToMm(const float& dValue) const; - std::wstring ConvertInToCm(const float& dValue) const; - std::wstring ConvertInToPt(const float& dValue) const; - std::wstring ConvertInToPc(const float& dValue) const; - - std::wstring ConvertPt(const std::wstring& sValue) const; - std::wstring ConvertPtToPx(const float& dValue) const; - std::wstring ConvertPtToMm(const float& dValue) const; - std::wstring ConvertPtToCm(const float& dValue) const; - std::wstring ConvertPtToIn(const float& dValue) const; - std::wstring ConvertPtToPc(const float& dValue) const; - - std::wstring ConvertPc(const std::wstring& sValue) const; - std::wstring ConvertPcToPx(const float& dValue) const; - std::wstring ConvertPcToMm(const float& dValue) const; - std::wstring ConvertPcToCm(const float& dValue) const; - std::wstring ConvertPcToIn(const float& dValue) const; - std::wstring ConvertPcToPt(const float& dValue) const; - public: - - NSConstValues::NSCssProperties::Font m_pFont; - NSConstValues::NSCssProperties::Margin m_pMargin; - NSConstValues::NSCssProperties::Background m_pBackground; - NSConstValues::NSCssProperties::Text m_pText; - NSConstValues::NSCssProperties::Border m_pBorder; - CCompiledStyle(); explicit CCompiledStyle(const std::map& mStyle); CCompiledStyle(const CCompiledStyle& oStyle); ~CCompiledStyle(); - void SetDpi(const unsigned short& uiDpi); - void SetUnitMeasure(const UnitMeasure& enUnitMeasure); + std::map* GetStyleMap(); + std::wstring GetStyleW() const; + // std::string GetStyle() const; + // size_t GetSize() const; bool Empty() const; + // void Clear(); - void AddPropSel(const std::wstring& sProperty, const std::wstring& sValue, const unsigned int unLevel, const bool& bHardMode = true); - void AddStyle(const std::map& mStyle, const unsigned int unLevel, const bool& bHardMode = true); - void AddStyle(const std::wstring& sStyle, const unsigned int unLevel, const bool& bHardMode = false); + void AddPropSel(const std::wstring& sProperty, const std::wstring& sValue, const bool& bHardMode = false); + void AddStyle(const std::map& mStyle, const bool& bHardMode = false); + void AddStyle(const std::wstring& sStyle, const bool& bHardMode = false); + void SetStyle(const std::map& mStyle); void AddParent(const std::wstring& sParentName); std::vector GetParentsName() const; @@ -92,13 +41,98 @@ namespace NSCSS void SetID(const std::wstring& sId); std::wstring GetId() const; - void ClearImportants(); + // const std::map::iterator& GetBegin(); + // const std::map::iterator& GetEnd(); + + // double GetWeidth() const; + + /* FONT */ + std::wstring GetFont() const; + std::wstring GetFontFamily() const; + std::vector GetFontNames() const; + std::vector GetFontNames2(const std::wstring& sFontFamily) const; + std::wstring GetFontSize() const; + std::wstring GetFontSizeAdjust() const; + std::wstring GetFontStretch() const; + std::wstring GetFontStyle() const; + std::wstring GetFontVariant() const; + std::wstring GetFontWeight() const; + std::wstring GetLineHeight() const; + + /* MARGIN */ + std::wstring GetMargin() const; + std::wstring GetMarginBottom() const; + std::wstring GetMarginBlockEnd() const; + std::wstring GetMarginLeft() const; + std::wstring GetMarginRight() const; + std::wstring GetMarginTop() const; + std::wstring GetMarginBlockStart() const; + + std::vector GetMargins() const; + std::wstring GetMarginTop2 () const; + std::wstring GetMarginBottom2() const; + std::wstring GetMarginLeft2 () const; + std::wstring GetMarginRight2 () const; + + /* PADDING */ + std::wstring GetPadding() const; + std::wstring GetPaddingBottom() const; + std::wstring GetPaddingLeft() const; + std::wstring GetPaddingRight() const; + std::wstring GetPaddingTop() const; + + /* SPACING */ + std::wstring GetLetterSpacing() const; + std::wstring GetWordSpacing() const; + std::wstring GetBorderSpacing() const; + + /* COLOR */ + std::wstring GetTextDecorationColor() const; + std::wstring GetBackgroundColor() const; + std::wstring GetColor() const; + std::wstring GetOutlineColor() const; + std::wstring GetColumnRuleColor() const; + std::wstring GetBackground() const; + + /* TEXT */ + std::wstring GetTextAlign() const; + std::wstring GetTextIndent() const; + std::wstring GetTextDecoration() const; + + /* BORDER */ + std::wstring GetBorder() const; + std::wstring GetBorderWidth() const; + std::wstring GetBorderStyle() const; + std::wstring GetBorderColor() const; + + std::wstring GetBorderBottom() const; + std::wstring GetBorderBottomWidth() const; + std::wstring GetBorderBottomStyle() const; + std::wstring GetBorderBottomColor() const; + + std::wstring GetBorderLeft() const; + std::wstring GetBorderLeftWidth() const; + std::wstring GetBorderLeftStyle() const; + std::wstring GetBorderLeftColor() const; + + std::wstring GetBorderRight() const; + std::wstring GetBorderRightWidth() const; + std::wstring GetBorderRightStyle() const; + std::wstring GetBorderRightColor() const; + + std::wstring GetBorderTop() const; + std::wstring GetBorderTopWidth() const; + std::wstring GetBorderTopStyle() const; + std::wstring GetBorderTopColor() const; + CCompiledStyle& operator+= (const CCompiledStyle& oElement); CCompiledStyle& operator= (const CCompiledStyle& oElement); bool operator== (const CCompiledStyle& oElement) const; + // bool operator != (const CCompiledStyle& oElement) const; + // bool operator > (const CCompiledStyle& oElement) const; + //bool operator < (const CCompiledStyle& oElement) const; - static void StyleEquation(CCompiledStyle& oFirstStyle, CCompiledStyle& oSecondStyle); }; } diff --git a/Common/3dParty/html/css/src/CCssCalculator.cpp b/Common/3dParty/html/css/src/CCssCalculator.cpp index 3717c542b1..8101af8530 100644 --- a/Common/3dParty/html/css/src/CCssCalculator.cpp +++ b/Common/3dParty/html/css/src/CCssCalculator.cpp @@ -14,11 +14,18 @@ namespace NSCSS delete m_pInternal; } - CCompiledStyle CCssCalculator::GetCompiledStyle(const std::vector &arSelectors, const bool& bIsSettings, const UnitMeasure& unitMeasure) const + CCompiledStyle CCssCalculator::GetCompiledStyle(const std::vector &arSelectors, const UnitMeasure& unitMeasure) const { - return m_pInternal->GetCompiledStyle(arSelectors, bIsSettings, unitMeasure); + return m_pInternal->GetCompiledStyle(arSelectors, unitMeasure); } + /* + void CCssCalculator::AddStyle(const std::vector& sSelectors, const std::string &sStyle) + { + m_pInternal->AddStyle(sSelectors, sStyle); + } + */ + void CCssCalculator::AddStyles(const std::string &sStyle) { m_pInternal->AddStyles(sStyle); @@ -44,11 +51,6 @@ namespace NSCSS m_pInternal->SetDpi(nValue); } - void CCssCalculator::SetBodyTree(const CTree &oTree) - { - m_pInternal->SetBodyTree(oTree); - } - UnitMeasure CCssCalculator::GetUnitMeasure() const { return m_pInternal->GetUnitMeasure(); diff --git a/Common/3dParty/html/css/src/CCssCalculator.h b/Common/3dParty/html/css/src/CCssCalculator.h index 0e8be17e31..e8ddce4317 100644 --- a/Common/3dParty/html/css/src/CCssCalculator.h +++ b/Common/3dParty/html/css/src/CCssCalculator.h @@ -3,13 +3,73 @@ #include "CssCalculator_global.h" #include "CCompiledStyle.h" -#include "ConstValues.h" #include #include #include namespace NSCSS { + typedef enum { + Default = 0, + Pixel, + Point, + Cantimeter, + Millimeter, + Inch, + Peak + } UnitMeasure; + + struct CNode + { + std::wstring m_sName; // Имя тэга + std::wstring m_sClass; // Класс тэга + std::wstring m_sId; // Id тэга + std::wstring m_sStyle; // Стиль тэга + + CNode(){}; + CNode(std::wstring sName, std::wstring sClass, std::wstring sId) : m_sName(sName), m_sClass(sClass), m_sId(sId){}; + + bool Empty() const + { + return m_sName.empty() && m_sClass.empty() && m_sId.empty() && m_sStyle.empty(); + } + + std::vector GetData() const + { + std::vector arValues; + if (!m_sClass.empty()) + arValues.push_back(m_sClass); + if (!m_sName.empty()) + arValues.push_back(m_sName); + return arValues; + } + + bool operator< (const CNode& oNode) const + { + if(m_sName != oNode.m_sName) + return m_sName < oNode.m_sName; + + if(m_sClass != oNode.m_sClass) + return m_sClass < oNode.m_sClass; + + if(m_sId != oNode.m_sId) + return m_sId < oNode.m_sId; + + if(m_sStyle != oNode.m_sStyle) + return m_sStyle < oNode.m_sStyle; + + return false; + } + + bool operator== (const CNode& oNode) const + { + return((m_sId == oNode.m_sId) && + (m_sName == oNode.m_sName) && + (m_sClass == oNode.m_sClass) && + (m_sStyle == oNode.m_sStyle)); + } + }; + class CCssCalculator_Private; class CSSCALCULATOR_EXPORT CCssCalculator { @@ -19,7 +79,7 @@ namespace NSCSS CCssCalculator(); ~CCssCalculator(); - CCompiledStyle GetCompiledStyle(const std::vector &arSelectors, const bool& bIsSettings = false, const UnitMeasure& unitMeasure = Default) const; + CCompiledStyle GetCompiledStyle(const std::vector &arSelectors, const UnitMeasure& unitMeasure = Default) const; // void AddStyle(const std::vector& sSelectors, const std::string& sStyle); void AddStyles (const std::string& sStyle); @@ -28,8 +88,6 @@ namespace NSCSS void SetUnitMeasure(const UnitMeasure& nType); void SetDpi(const unsigned short int& nValue); - void SetBodyTree(const CTree &oTree); - UnitMeasure GetUnitMeasure() const; std::wstring GetEncoding() const; diff --git a/Common/3dParty/html/css/src/CCssCalculator_Private.cpp b/Common/3dParty/html/css/src/CCssCalculator_Private.cpp index 206cddcb9d..8fe8633f46 100644 --- a/Common/3dParty/html/css/src/CCssCalculator_Private.cpp +++ b/Common/3dParty/html/css/src/CCssCalculator_Private.cpp @@ -14,7 +14,6 @@ #include "../../../../../DesktopEditor/common/File.h" #include "StaticFunctions.h" -#define MaxNumberRepetitions 6 inline static std::wstring StringifyValueList(const KatanaArray* oValues); inline static std::wstring StringifyValue(const KatanaValue* oValue); @@ -40,7 +39,7 @@ bool operator<(const std::vector &arLeftSelectors, const std::vect namespace NSCSS { - CCssCalculator_Private::CCssCalculator_Private() : m_nDpi(96), m_nCountNodes(0), m_UnitMeasure(Default), m_mStatictics(NULL), m_sEncoding(L"UTF-8"){} + CCssCalculator_Private::CCssCalculator_Private() : m_nDpi(96), m_nCountNodes(0), m_UnitMeasure(Default), m_sEncoding(L"UTF-8") {} CCssCalculator_Private::~CCssCalculator_Private() { @@ -56,15 +55,36 @@ namespace NSCSS delete iter->second; m_mUsedStyles.clear(); - - if (NULL != m_mStatictics) - delete m_mStatictics; } + /* + inline CElement* CCssCalculator_Private::GetElement(const int& nIndex) const + { + if (nIndex < 0 || nIndex >= (int)m_arData.size()) + return NULL; + + return m_arData[nIndex]; + } + + inline void CCssCalculator_Private::AddElement(CElement *oElement) + { + if (oElement != NULL) + { + const std::vector>& arDeclarations = oElement->GetDeclarations(); + + for (std::pair pDeclaration : arDeclarations) + pDeclaration.second = ConvertUnitMeasure(pDeclaration.second); + + oElement->SetDeclaratins(arDeclarations); + m_arData.push_back(oElement); + } + } + */ + inline void CCssCalculator_Private::GetOutputData(KatanaOutput *oOutput) { if ( NULL == oOutput ) - return; + return; switch (oOutput->mode) { case KatanaParserModeStylesheet: @@ -119,9 +139,10 @@ namespace NSCSS return; const std::map mStyle = GetDeclarationList(oRule->declarations); - for (const std::wstring &sSelector : GetSelectorList(oRule->selectors)) + for (const std::wstring sSelector : GetSelectorList(oRule->selectors)) { std::vector arWords = NS_STATIC_FUNCTIONS::GetWordsW(sSelector, L" "); +// std::wcout << sSelector << std::endl; CElement* oLastElement = NULL; CElement* oFirstElement = NULL; @@ -304,7 +325,7 @@ namespace NSCSS return StringifyValueList(oValues); } - CCompiledStyle CCssCalculator_Private::GetCompiledStyle(const std::vector& arSelectors, const bool& bIsSettings, const UnitMeasure& unitMeasure) + CCompiledStyle CCssCalculator_Private::GetCompiledStyle(const std::vector& arSelectors, const UnitMeasure& unitMeasure) { if (arSelectors.empty()) return CCompiledStyle(); @@ -312,46 +333,27 @@ namespace NSCSS if (unitMeasure != Default) SetUnitMeasure(unitMeasure); - if (!bIsSettings) - { - const std::map, CCompiledStyle*>::iterator oItem = m_mUsedStyles.find(arSelectors); + const std::map, CCompiledStyle*>::iterator oItem = m_mUsedStyles.find(arSelectors); - if (oItem != m_mUsedStyles.end()) - return *oItem->second; - } - else if (NULL == m_mStatictics || m_mStatictics->empty()) - { - CCompiledStyle oStyle; - oStyle.SetDpi(m_nDpi); - oStyle.SetUnitMeasure(m_UnitMeasure); - oStyle.SetID(arSelectors.back().m_sName + ((!arSelectors.back().m_sClass.empty()) ? L'.' + arSelectors.back().m_sClass : L"") + ((arSelectors.back().m_sId.empty()) ? L"" : L'#' + arSelectors.back().m_sId) + L'-' + std::to_wstring(++m_nCountNodes)); - - return oStyle; - } + if (oItem != m_mUsedStyles.end()) + return *oItem->second; CCompiledStyle *oStyle = new CCompiledStyle(); - oStyle->SetDpi(m_nDpi); - oStyle->SetUnitMeasure(m_UnitMeasure); - std::vector arWords; arWords.reserve(arSelectors.size() * 2); - std::vector arNextNodes; - arNextNodes.reserve(arSelectors.size() * 2); - - for (std::vector::const_reverse_iterator oNode = arSelectors.rbegin(); oNode != arSelectors.rend(); ++oNode) + for (const CNode& oNode : arSelectors) { - arWords.push_back(oNode->m_sName); + oStyle->AddStyle(oNode.m_sStyle, true); - if (oNode->m_sName == L"td") - oStyle->m_pMargin.SetPermission(false); + arWords.push_back(oNode.m_sName); - if (!oNode->m_sClass.empty()) + if (!oNode.m_sClass.empty()) { - if (oNode->m_sClass.find(L' ') != std::wstring::npos) + if (oNode.m_sClass.find(L' ') != std::wstring::npos) { - std::vector arClasses = NS_STATIC_FUNCTIONS::GetWordsW(oNode->m_sClass, L" "); + std::vector arClasses = NS_STATIC_FUNCTIONS::GetWordsW(oNode.m_sClass, L" "); if (arClasses.size() > 1) arClasses.resize(unique(arClasses.begin(),arClasses.end()) - arClasses.begin()); @@ -382,16 +384,23 @@ namespace NSCSS } } else - arWords.push_back(L'.' + oNode->m_sClass); + arWords.push_back(L'.' + oNode.m_sClass); } - if (!oNode->m_sId.empty()) - arWords.push_back(L'#' + oNode->m_sId); + if (!oNode.m_sId.empty()) + arWords.push_back(L'#' + oNode.m_sId); } std::vector arElements; - for (size_t i = 0; i < arSelectors.size(); ++i) + for (std::vector::const_reverse_iterator iNode = arSelectors.rbegin(); iNode != arSelectors.rend(); ++iNode) { + std::vector arKins; + for (std::vector::const_reverse_iterator sNode = arWords.rbegin(); sNode != arWords.rend(); ++sNode) + { + arKins.push_back(*sNode); + if ((*sNode)[0] != L'#' && (*sNode)[0] != L'.') + break; + } std::wstring sName, sId; std::vector arClasses; @@ -399,117 +408,77 @@ namespace NSCSS { sId = arWords.back(); arWords.pop_back(); - arNextNodes.push_back(sId); } if (arWords.back()[0] == L'.') { arClasses = NS_STATIC_FUNCTIONS::GetWordsW(arWords.back(), L" "); - arNextNodes.push_back(arWords.back()); arWords.pop_back(); } sName = arWords.back(); - arWords.pop_back(); - arNextNodes.push_back(sName); oStyle->AddParent(sName); const std::map::const_iterator oFindName = m_mData.find(sName); std::map::const_iterator oFindId; std::vector arFindElements; + if (!sId.empty()) { oFindId = m_mData.find(sId); if (oFindId != m_mData.end()) { - std::map::const_iterator oFindCountId = m_mStatictics->find(StatistickElement{StatistickElement::IsId, sId}); + const std::vector arTemp1 = oFindId->second->GetNextOfKin(sName, arClasses); + const std::vector arTemp2 = oFindId->second->GetAllElements(arWords); - if (((bIsSettings && oFindCountId->second < MaxNumberRepetitions) || - (!bIsSettings && oFindCountId->second >= MaxNumberRepetitions))) - { - if (!oFindId->second->Empty()) - arFindElements.push_back(oFindId->second); - } - - const std::vector arTempPrev = oFindId->second->GetPrevElements(arNextNodes.rbegin() + ((arClasses.empty()) ? 1 : 2), arNextNodes.rend()); - - if (!arTempPrev.empty()) - arFindElements.insert(arFindElements.end(), arTempPrev.begin(), arTempPrev.end()); + arFindElements.insert(arFindElements.end(), arTemp1.begin(), arTemp1.end()); + arFindElements.insert(arFindElements.end(), arTemp2.begin(), arTemp2.end()); } } if (!arClasses.empty()) { - if (!bIsSettings) + for (std::vector::const_reverse_iterator iClass = arClasses.rbegin(); iClass != arClasses.rend(); ++iClass) { - for (std::vector::const_reverse_iterator iClass = arClasses.rbegin(); iClass != arClasses.rend(); ++iClass) + const std::map::const_iterator oFindClass = m_mData.find(*iClass); + if (oFindClass != m_mData.end()) { - const std::map::const_iterator oFindClass = m_mData.find(*iClass); - if (oFindClass != m_mData.end()) - { - if (!oFindClass->second->Empty()) - arFindElements.push_back(oFindClass->second); + arFindElements.push_back(oFindClass->second); + const std::vector arTemp1 = oFindClass->second->GetNextOfKin(sName); + const std::vector arTemp2 = oFindClass->second->GetAllElements(arWords); - const std::vector arTempPrev = oFindClass->second->GetPrevElements(arNextNodes.rbegin() + 2, arNextNodes.rend()); - const std::vector arTempKins = oFindClass->second->GetNextOfKin(sName); - - if (!arTempPrev.empty()) - arFindElements.insert(arFindElements.end(), arTempPrev.begin(), arTempPrev.end()); - - if (!arTempKins.empty()) - arFindElements.insert(arFindElements.end(), arTempKins.begin(), arTempKins.end()); - } + arFindElements.insert(arFindElements.end(), arTemp1.begin(), arTemp1.end()); + arFindElements.insert(arFindElements.end(), arTemp2.begin(), arTemp2.end()); } } } if (oFindName != m_mData.end()) { - if (!bIsSettings) - { - if (!oFindName->second->Empty()) - arFindElements.push_back(oFindName->second); - - const std::vector arTempPrev = oFindName->second->GetPrevElements(arNextNodes.rbegin() + 1, arNextNodes.rend()); - const std::vector arTempKins = oFindName->second->GetNextOfKin(sName, arClasses); - - if (!arTempPrev.empty()) - arFindElements.insert(arFindElements.end(), arTempPrev.begin(), arTempPrev.end()); - - if (!arTempKins.empty()) - arFindElements.insert(arFindElements.end(), arTempKins.begin(), arTempKins.end()); - } + const std::vector arTemp = oFindName->second->GetAllElements(arWords); + arFindElements.insert(arFindElements.end(), arTemp.begin(), arTemp.end()); } - - if (arFindElements.size() > 1) + std::sort(arFindElements.rbegin(), arFindElements.rend(), [](CElement* oFirstElement, CElement* oSecondElement) { - std::sort(arFindElements.rbegin(), arFindElements.rend(), - [](CElement* oFirstElement, CElement* oSecondElement) - { - return oFirstElement->GetWeight() < oSecondElement->GetWeight(); - }); - } + return oFirstElement->GetWeight() < oSecondElement->GetWeight(); + }); + for (const CElement* oElement : arFindElements) - oStyle->AddStyle(oElement->GetStyle(), i + 1); - - std::map::const_iterator oFindCountStyle = m_mStatictics->find(StatistickElement{StatistickElement::IsStyle, arSelectors[i].m_sStyle}); - - if(oFindCountStyle != m_mStatictics->end()) - if ((bIsSettings && oFindCountStyle->second < MaxNumberRepetitions) || - (!bIsSettings && oFindCountStyle->second >= MaxNumberRepetitions)) - oStyle->AddStyle(arSelectors[i].m_sStyle, i + 1, true); + oStyle->AddStyle(oElement->GetStyle()); + arWords.pop_back(); } - if (!bIsSettings) - { - oStyle->SetID(arSelectors.back().m_sName + ((!arSelectors.back().m_sClass.empty()) ? L'.' + arSelectors.back().m_sClass : L"") + ((arSelectors.back().m_sId.empty()) ? L"" : L'#' + arSelectors.back().m_sId) + L'-' + std::to_wstring(++m_nCountNodes)); - m_mUsedStyles[arSelectors] = oStyle; - } + oStyle->SetID(arSelectors.back().m_sName + ((!arSelectors.back().m_sClass.empty()) ? L'.' + arSelectors.back().m_sClass : L"") + ((arSelectors.back().m_sId.empty()) ? L"" : L'#' + arSelectors.back().m_sId) + L'-' + std::to_wstring(++m_nCountNodes)); + + for (std::pair& pProperie : *(oStyle->GetStyleMap())) + pProperie.second = ConvertUnitMeasure(pProperie.second); + + m_mUsedStyles[arSelectors] = oStyle; return *oStyle; } @@ -542,19 +511,545 @@ namespace NSCSS AddStyles(NS_STATIC_FUNCTIONS::GetContentAsUTF8(sFileName)); } + std::wstring CCssCalculator_Private::ConvertUnitMeasure(const std::wstring &sValue) const + { + if (sValue.empty()) + return sValue; + + std::vector arValues = NS_STATIC_FUNCTIONS::GetWordsWithSigns(sValue); + + std::wstring sValueString; + + for (std::wstring& sValueTemp : arValues) + { + const size_t nPosImportant = sValueTemp.find(L'!'); + if (nPosImportant != std::wstring::npos) + sValueTemp = sValueTemp.substr(0, nPosImportant); + + size_t nPosGrid = sValueTemp.find(L'#'); + + if (nPosGrid != std::wstring::npos || !NS_STATIC_FUNCTIONS::ThereIsNumber(sValueTemp)) + { + if (!NS_STATIC_FUNCTIONS::ConvertAbsoluteValue(sValueTemp)) + { + sValueString += sValueTemp; + continue; + } + } + + const size_t posPercent = sValueTemp.find(L'%'); + + if (posPercent != std::wstring::npos) + { + const float dValue = wcstof(sValueTemp.substr(0, posPercent).c_str(), NULL) * NS_CONST_VALUES::FONT_SIZE / 100; + + sValueString += std::to_wstring(static_cast(dValue + 0.5f)); + + if (sValueTemp.find(L';') != std::wstring::npos) + sValueString += L';'; + else if (arValues.size() > 1 && sValueTemp.find(L':') == std::wstring::npos) + sValueString += L' '; + } + else if (sValueTemp.find(L"px") != std::wstring::npos) + { + sValueString += ConvertPx(sValueTemp); + + if (sValueTemp.find(L';') != std::wstring::npos) + sValueString += L';'; + else if (arValues.size() > 1 && sValueTemp.find(L':') == std::wstring::npos) + sValueString += L' '; + } + else if (sValueTemp.find(L"cm") != std::wstring::npos) + { + sValueString += ConvertCm(sValueTemp); + + if (sValueTemp.find(L';') != std::wstring::npos) + sValueString += L';'; + else if (arValues.size() > 1 && sValueTemp.find(L':') == std::wstring::npos) + sValueString += L' '; + } + else if (sValueTemp.find(L"mm") != std::wstring::npos) + { + sValueString += ConvertMm(sValueTemp); + + if (sValueTemp.find(L';') != std::wstring::npos) + sValueString += L';'; + else if (arValues.size() > 1 && sValueTemp.find(L':') == std::wstring::npos) + sValueString += L' '; + } + else if (sValueTemp.find(L"in") != std::wstring::npos) + { + sValueString += ConvertIn(sValueTemp); + + if (sValueTemp.find(L';') != std::wstring::npos) + sValueString += L';'; + else if (arValues.size() > 1 && sValueTemp.find(L':') == std::wstring::npos) + sValueString += L' '; + } + else if (sValueTemp.find(L"pt") != std::wstring::npos) + { + sValueString += ConvertPt(sValueTemp); + + if (sValueTemp.find(L';') != std::wstring::npos) + sValueString += L';'; + else if (arValues.size() > 1 && sValueTemp.find(L':') == std::wstring::npos) + sValueString += L' '; + } + else if (sValueTemp.find(L"pc") != std::wstring::npos) + { + sValueString += ConvertPc(sValueTemp); + + if (sValueTemp.find(L';') != std::wstring::npos) + sValueString += L';'; + else if (arValues.size() > 1 && sValueTemp.find(L':') == std::wstring::npos) + sValueString += L' '; + } + else if (sValueTemp.find(L"em") != std::wstring::npos) + { + sValueString += ConvertEm(sValueTemp); + + if (sValueTemp.find(L';') != std::wstring::npos) + sValueString += L';'; + else if (arValues.size() > 1 && sValueTemp.find(L':') == std::wstring::npos) + sValueString += L' '; + } + else + { + sValueString += sValueTemp; + + if (sValueTemp.find(L";") != std::wstring::npos) + sValueString += L';'; + + break; + } + + if (sValueTemp.back() != L';' && sValueTemp.back() != L':' && sValueTemp.back() != L' ') + sValueTemp += L' '; + } + + return sValueString; + } + + inline std::wstring CCssCalculator_Private::ConvertPx(const std::wstring& sValue) const + { + if (sValue.empty()) + return std::wstring(); + + const std::wstring& sConvertValue = sValue.substr(0, sValue.find_last_of(L"px") - 1); + const float dValue = wcstof(sConvertValue.c_str(), NULL) * 2.0f; + + switch (m_UnitMeasure) + { + case Pixel: + return std::to_wstring(static_cast(dValue));; + case Default: + case Point: + return ConvertPxToPt(dValue); + case Cantimeter: + return ConvertPxToCm(dValue); + case Millimeter: + return ConvertPxToMm(dValue); + case Inch: + return ConvertPxToIn(dValue); + case Peak: + return ConvertPxToPc(dValue); + } + + return std::wstring(); + } + + inline std::wstring CCssCalculator_Private::ConvertPxToCm(const float& dValue) const + { + if (dValue == 0.0f) + return std::wstring(L"0"); + + return std::to_wstring(static_cast(dValue / static_cast(m_nDpi) * 2.54f + 0.5f)); + } + + inline std::wstring CCssCalculator_Private::ConvertPxToIn(const float& dValue) const + { + if (dValue == 0.0f) + return std::wstring(L"0"); + + return std::to_wstring(static_cast(1.0f / static_cast(m_nDpi) * dValue + 0.5f)); + } + + inline std::wstring CCssCalculator_Private::ConvertPxToMm(const float& dValue) const + { + if (dValue == 0.0f) + return std::wstring(L"0"); + + return std::to_wstring(static_cast(dValue / static_cast(m_nDpi) * 25.4f + 0.5f)); + } + + inline std::wstring CCssCalculator_Private::ConvertPxToPc(const float& dValue) const + { + if (dValue == 0.0f) + return std::wstring(L"0"); + + return std::to_wstring(static_cast(0.16667f / static_cast(m_nDpi) * dValue + 0.5f)); + } + + inline std::wstring CCssCalculator_Private::ConvertPxToPt(const float& dValue) const + { + if (dValue == 0.0f) + return std::wstring(L"0"); + + return std::to_wstring(static_cast(72.0f / static_cast(m_nDpi) * dValue + 0.5f)); + } + + inline std::wstring CCssCalculator_Private::ConvertCm(const std::wstring& sValue) const + { + if (sValue.empty()) + return std::wstring(); + + const std::wstring& sConvertValue = sValue.substr(0, sValue.find_last_of(L"cm") - 1); + const float dValue = wcstof(sConvertValue.c_str(), NULL) * 2.0f; + + switch (m_UnitMeasure) + { + case Default: + case Point: + return ConvertCmToPt(dValue); + case Pixel: + return ConvertCmToPx(dValue); + case Cantimeter: + return std::to_wstring(static_cast(dValue));; + case Millimeter: + return ConvertCmToMm(dValue); + case Inch: + return ConvertCmToIn(dValue); + case Peak: + return ConvertCmToPc(dValue); + } + + return std::wstring(); + } + + inline std::wstring CCssCalculator_Private::ConvertCmToIn(const float& dValue) const + { + if (dValue == 0.0f) + return std::wstring(L"0"); + + return std::to_wstring(static_cast(dValue / 2.54f + 0.5f)); + } + + inline std::wstring CCssCalculator_Private::ConvertCmToMm(const float& dValue) const + { + if (dValue == 0.0f) + return std::wstring(L"0"); + + return std::to_wstring(static_cast(dValue * 10.0f + 0.5f)); + } + + inline std::wstring CCssCalculator_Private::ConvertCmToPc(const float& dValue) const + { + if (dValue == 0.0f) + return std::wstring(L"0"); + + return std::to_wstring(static_cast(2.36f * dValue + 0.5f)); + } + + inline std::wstring CCssCalculator_Private::ConvertCmToPt(const float& dValue) const + { + if (dValue == 0.0f) + return std::wstring(L"0"); + + return std::to_wstring(static_cast(28.35f * dValue + 0.5f)); + } + + inline std::wstring CCssCalculator_Private::ConvertCmToPx(const float& dValue) const + { + if (dValue == 0.0f) + return std::wstring(L"0"); + + return std::to_wstring(static_cast(static_cast(m_nDpi) / 2.54f * dValue + 0.5f)); + } + + inline std::wstring CCssCalculator_Private::ConvertMm(const std::wstring& sValue) const + { + if (sValue.empty()) + return std::wstring(); + + const std::wstring& sConvertValue = sValue.substr(0, sValue.find_last_of(L"mm") - 1); + const float dValue = wcstof(sConvertValue.c_str(), NULL) * 2.0f; + + switch (m_UnitMeasure) + { + case Pixel: + return ConvertMmToPx(dValue); + case Default: + case Point: + return ConvertMmToPt(dValue); + case Cantimeter: + return ConvertMmToCm(dValue); + case Millimeter: + return std::to_wstring(static_cast(dValue));; + case Inch: + return ConvertMmToIn(dValue); + case Peak: + return ConvertMmToPc(dValue); + } + return std::wstring(); + } + + inline std::wstring CCssCalculator_Private::ConvertMmToIn(const float& dValue) const + { + if (dValue == 0.0f) + return std::wstring(L"0"); + + return std::to_wstring(static_cast(dValue / 25.4f + 0.5f)); + } + + inline std::wstring CCssCalculator_Private::ConvertMmToCm(const float& dValue) const + { + if (dValue == 0.0f) + return std::wstring(L"0"); + + return std::to_wstring(static_cast(dValue / 10.0f + 0.5f)); + } + + inline std::wstring CCssCalculator_Private::ConvertMmToPc(const float& dValue) const + { + if (dValue == 0.0f) + return std::wstring(L"0"); + + return std::to_wstring(static_cast(2.8346f * dValue + 0.5f)); + } + + inline std::wstring CCssCalculator_Private::ConvertMmToPt(const float& dValue) const + { + if (dValue == 0) + return std::wstring(L"0"); + + return std::to_wstring(static_cast(0.23262f * dValue + 0.5f)); + } + + inline std::wstring CCssCalculator_Private::ConvertMmToPx(const float& dValue) const + { + if (dValue == 0) + return std::wstring(L"0"); + + return std::to_wstring(static_cast(static_cast(m_nDpi) / 25.4f * dValue + 0.5f)); + } + + inline std::wstring CCssCalculator_Private::ConvertIn(const std::wstring& sValue) const + { + if (sValue.empty()) + return std::wstring(); + + const std::wstring& sConvertValue = sValue.substr(0, sValue.find_last_of(L"in") - 1); + const float dValue = wcstof(sConvertValue.c_str(), NULL) * 2.0f; + + switch (m_UnitMeasure) + { + case Pixel: + return ConvertInToPx(dValue); + case Default: + case Point: + return ConvertInToPt(dValue); + case Cantimeter: + return ConvertInToCm(dValue); + case Millimeter: + return ConvertInToMm(dValue); + case Inch: + return std::to_wstring(static_cast(dValue));; + case Peak: + return ConvertInToPc(dValue); + } + return std::wstring(); + } + + inline std::wstring CCssCalculator_Private::ConvertInToMm(const float& dValue) const + { + if (dValue == 0.0f) + return std::wstring(L"0"); + + return std::to_wstring(static_cast(dValue * 25.4f + 0.5f)); + } + + inline std::wstring CCssCalculator_Private::ConvertInToCm(const float& dValue) const + { + if (dValue == 0.0f) + return std::wstring(L"0"); + + return std::to_wstring(static_cast(dValue * 2.54f + 0.5f)); + } + + inline std::wstring CCssCalculator_Private::ConvertInToPc(const float& dValue) const + { + if (dValue == 0.0f) + return std::wstring(L"0"); + + return std::to_wstring(static_cast(dValue / 72.0f + 0.5f)); + } + + inline std::wstring CCssCalculator_Private::ConvertInToPt(const float& dValue) const + { + if (dValue == 0.0f) + return std::wstring(L"0"); + + return std::to_wstring(static_cast(dValue / 6.0f + 0.5f)); + } + + inline std::wstring CCssCalculator_Private::ConvertInToPx(const float& dValue) const + { + if (dValue == 0.0f) + return std::wstring(L"0"); + + return std::to_wstring(static_cast(dValue * static_cast(m_nDpi) + 0.5f)); + } + + inline std::wstring CCssCalculator_Private::ConvertPt(const std::wstring& sValue) const + { + if (sValue.empty()) + return std::wstring(); + + const std::wstring& sConvertValue = sValue.substr(0, sValue.find_last_of(L"pt") - 1); + const float dValue = wcstof(sConvertValue.c_str(), NULL) * 2.0f; + + switch (m_UnitMeasure) + { + case Pixel: + return ConvertPtToPx(dValue); + case Default: + case Point: + return std::to_wstring(static_cast(dValue)); + case Cantimeter: + return ConvertPtToCm(dValue); + case Millimeter: + return ConvertPtToMm(dValue); + case Inch: + return ConvertPtToIn(dValue); + case Peak: + return ConvertPtToPc(dValue); + } + + return std::wstring(); + } + + inline std::wstring CCssCalculator_Private::ConvertPtToIn(const float& dValue) const + { + if (dValue == 0.0f) + return std::wstring(L"0"); + + return std::to_wstring((dValue / 72.0f + 0.5f)); + } + + inline std::wstring CCssCalculator_Private::ConvertPtToCm(const float& dValue) const + { + if (dValue == 0.0f) + return std::wstring(L"0"); + + return std::to_wstring(static_cast(dValue * 0.03528f + 0.5f)); + } + + inline std::wstring CCssCalculator_Private::ConvertPtToPc(const float& dValue) const + { + if (dValue == 0.0f) + return std::wstring(L"0"); + + return std::to_wstring(static_cast(dValue / 12.0f + 0.5f)); + } + + inline std::wstring CCssCalculator_Private::ConvertPtToMm(const float& dValue) const + { + if (dValue == 0.0f) + return std::wstring(L"0"); + + return std::to_wstring((dValue * 0.3528f + 0.5f)); + } + + inline std::wstring CCssCalculator_Private::ConvertPtToPx(const float& dValue) const + { + if (dValue == 0.0f) + return std::wstring(L"0"); + + return std::to_wstring(static_cast(static_cast(m_nDpi) / 72.0f * dValue + 0.5f)); + } + + inline std::wstring CCssCalculator_Private::ConvertPc(const std::wstring& sValue) const + { + if (sValue.empty()) + return std::wstring(); + + const std::wstring& sConvertValue = sValue.substr(0, sValue.find_last_of(L"pc") - 1); + const float dValue = wcstof(sConvertValue.c_str(), NULL) * 2.0f; + + switch (m_UnitMeasure) + { + case Pixel: + return ConvertPcToPx(dValue); + case Default: + case Point: + return ConvertPcToPt(dValue); + case Cantimeter: + return ConvertPcToCm(dValue); + case Millimeter: + return ConvertPcToMm(dValue); + case Inch: + return ConvertPcToIn(dValue); + case Peak: + return std::to_wstring(static_cast(dValue)); + } + + return std::wstring(); + } + + inline std::wstring CCssCalculator_Private::ConvertPcToIn(const float& dValue) const + { + if (dValue == 0.0f) + return std::wstring(L"0"); + + return std::to_wstring(static_cast(dValue / 6.0f + 0.5f)); + } + + inline std::wstring CCssCalculator_Private::ConvertPcToCm(const float& dValue) const + { + if (dValue == 0.0f) + return std::wstring(L"0"); + + return std::to_wstring(static_cast(dValue * 0.423f + 0.5f)); + } + + inline std::wstring CCssCalculator_Private::ConvertPcToPt(const float& dValue) const + { + if (dValue == 0.0f) + return std::wstring(L"0"); + + return std::to_wstring(static_cast(dValue * 12.0f + 0.5f)); + } + + inline std::wstring CCssCalculator_Private::ConvertPcToMm(const float& dValue) const + { + if (dValue == 0.0f) + return std::wstring(L"0"); + + return std::to_wstring(static_cast(dValue * 4.23f + 0.5f)); + } + + inline std::wstring CCssCalculator_Private::ConvertPcToPx(const float& dValue) const + { + if (dValue == 0.0f) + return std::wstring(L"0"); + + return std::to_wstring(static_cast(static_cast(m_nDpi) / 6.0f * dValue + 0.5f)); + } + + inline std::wstring CCssCalculator_Private::ConvertEm(const std::wstring& sValue) const + { + if (sValue.empty()) + return std::wstring(L""); + + const float fValue = wcstof(sValue.c_str(), NULL) * NS_CONST_VALUES::FONT_SIZE; + return std::to_wstring(static_cast(fValue + 0.5f)); + } + void CCssCalculator_Private::SetDpi(unsigned short int nValue) { m_nDpi = nValue; } - void CCssCalculator_Private::SetBodyTree(const CTree &oTree) - { - if (NULL == m_mStatictics) - m_mStatictics = new std::map(); - - CTree::CountingNumberRepetitions(oTree, *m_mStatictics); - } - void CCssCalculator_Private::SetUnitMeasure(const UnitMeasure& nType) { m_UnitMeasure = nType; @@ -565,6 +1060,12 @@ namespace NSCSS return m_nDpi; } + /* + inline size_t CCssCalculator_Private::GetSize() const + { + return m_arData.size(); + } + */ UnitMeasure CCssCalculator_Private::GetUnitMeasure() const { @@ -582,6 +1083,10 @@ namespace NSCSS m_nDpi = 96; m_UnitMeasure = Default; +// for (CElement* oElement : m_arData) +// delete oElement; + +// m_arStyleUsed.clear(); m_mData.clear(); m_arFiles.clear(); } diff --git a/Common/3dParty/html/css/src/CCssCalculator_Private.h b/Common/3dParty/html/css/src/CCssCalculator_Private.h index 00bc815f18..4db9917305 100644 --- a/Common/3dParty/html/css/src/CCssCalculator_Private.h +++ b/Common/3dParty/html/css/src/CCssCalculator_Private.h @@ -21,17 +21,22 @@ namespace NSCSS std::map m_mData; - std::map *m_mStatictics; // Количество повторений свойств id и style у селекторов +// std::map, std::map*> m_mData; std::map, CCompiledStyle*> m_mUsedStyles; std::wstring m_sEncoding; + // void AddElement(CElement* oElement); + // size_t GetSize() const; + void GetStylesheet(const KatanaStylesheet* oStylesheet); void GetRule(const KatanaRule* oRule); void GetStyleRule(const KatanaStyleRule* oRule); + // CElement* GetElement(const int& nIndex) const; + std::wstring GetValueList(const KatanaArray* oValues); std::vector GetSelectorList(const KatanaArray* oSelectors) const; @@ -40,21 +45,67 @@ namespace NSCSS std::map GetDeclarationList(const KatanaArray* oDeclarations) const; std::pair GetDeclaration(const KatanaDeclaration* oDecl) const; + std::wstring ConvertUnitMeasure(const std::wstring& sValue) const; + + std::wstring ConvertPx(const std::wstring& sValue) const; + std::wstring ConvertPxToCm(const float& dValue) const; + std::wstring ConvertPxToIn(const float& dValue) const; + std::wstring ConvertPxToMm(const float& dValue) const; + std::wstring ConvertPxToPt(const float& dValue) const; + std::wstring ConvertPxToPc(const float& dValue) const; + + std::wstring ConvertCm(const std::wstring& sValue) const; + std::wstring ConvertCmToPx(const float& dValue) const; + std::wstring ConvertCmToIn(const float& dValue) const; + std::wstring ConvertCmToMm(const float& dValue) const; + std::wstring ConvertCmToPt(const float& dValue) const; + std::wstring ConvertCmToPc(const float& dValue) const; + + std::wstring ConvertMm(const std::wstring& sValue) const; + std::wstring ConvertMmToPx(const float& dValue) const; + std::wstring ConvertMmToIn(const float& dValue) const; + std::wstring ConvertMmToCm(const float& dValue) const; + std::wstring ConvertMmToPt(const float& dValue) const; + std::wstring ConvertMmToPc(const float& dValue) const; + + std::wstring ConvertIn(const std::wstring& sValue) const; + std::wstring ConvertInToPx(const float& dValue) const; + std::wstring ConvertInToMm(const float& dValue) const; + std::wstring ConvertInToCm(const float& dValue) const; + std::wstring ConvertInToPt(const float& dValue) const; + std::wstring ConvertInToPc(const float& dValue) const; + + std::wstring ConvertPt(const std::wstring& sValue) const; + std::wstring ConvertPtToPx(const float& dValue) const; + std::wstring ConvertPtToMm(const float& dValue) const; + std::wstring ConvertPtToCm(const float& dValue) const; + std::wstring ConvertPtToIn(const float& dValue) const; + std::wstring ConvertPtToPc(const float& dValue) const; + + std::wstring ConvertPc(const std::wstring& sValue) const; + std::wstring ConvertPcToPx(const float& dValue) const; + std::wstring ConvertPcToMm(const float& dValue) const; + std::wstring ConvertPcToCm(const float& dValue) const; + std::wstring ConvertPcToIn(const float& dValue) const; + std::wstring ConvertPcToPt(const float& dValue) const; + + std::wstring ConvertEm(const std::wstring& sValue) const; + void GetOutputData(KatanaOutput* oOutput); public: CCssCalculator_Private(); ~CCssCalculator_Private(); - CCompiledStyle GetCompiledStyle(const std::vector &arSelectors, const bool& bIsSettings = false, const UnitMeasure& unitMeasure = Default); + CCompiledStyle GetCompiledStyle(const std::vector &arSelectors, const UnitMeasure& unitMeasure = Default); + // void AddStyle(const std::vector& sSelectors, const std::string& sStyle); void AddStyles(const std::string& sStyle); void AddStyles(const std::wstring& sStyle); void AddStylesFromFile(const std::wstring& sFileName); void SetUnitMeasure(const UnitMeasure& nType); void SetDpi(unsigned short int nValue); - void SetBodyTree(const CTree &oTree); UnitMeasure GetUnitMeasure() const; std::wstring GetEncoding() const; diff --git a/Common/3dParty/html/css/src/CElement.cpp b/Common/3dParty/html/css/src/CElement.cpp index ef79f4ac3f..400948549d 100644 --- a/Common/3dParty/html/css/src/CElement.cpp +++ b/Common/3dParty/html/css/src/CElement.cpp @@ -31,11 +31,6 @@ namespace NSCSS return m_sFullSelector; } - bool CElement::Empty() const - { - return m_mStyle.empty(); - } - void CElement::SetSelector(const std::wstring &sSelector) { m_sSelector = sSelector; @@ -82,6 +77,11 @@ namespace NSCSS oKinElement->m_sFullSelector += m_sFullSelector; } + size_t CElement::EmptyPrevElements() const + { + return m_arPrevElements.empty(); + } + std::map CElement::GetStyle() const { return m_mStyle; @@ -121,6 +121,8 @@ namespace NSCSS if (arNodes.empty() || (m_mStyle.empty() && m_arPrevElements.empty())) return std::map(); +// Print(); +// std::wcout << L"++++++++++++++++++++++++++++++++++++++++++++++" << std::endl; std::map mStyle(m_mStyle); for (const CElement* oElement : m_arPrevElements) @@ -138,6 +140,8 @@ namespace NSCSS for (const std::pair pPropertie : oElement->GetFullStyle(sTempNodes)) mStyle[pPropertie.first] = pPropertie.second; + // const std::map mTempStyle = oElement->GetFullStyle((arNodes.size() > 1) ? std::vector(&arNodes[1], &arNodes[arNodes.size() - 1]) : std::vector()); + // mStyle.insert(mTempStyle.begin(), mTempStyle.end()); } } } @@ -147,6 +151,8 @@ namespace NSCSS sTempNodes.pop_back(); for (const std::pair pPropertie : oElement->GetFullStyle(sTempNodes)) mStyle[pPropertie.first] = pPropertie.second; +// const std::map mTempStyle = oElement->GetFullStyle((arNodes.size() > 1) ? std::vector(&arNodes[1], &arNodes[arNodes.size() - 1]) : std::vector()); +// mStyle.insert(mTempStyle.begin(), mTempStyle.end()); } } } @@ -154,7 +160,58 @@ namespace NSCSS return mStyle; } - std::vector CElement::GetNextOfKin(const std::wstring &sName, const std::vector& arClasses) const + std::vector CElement::GetAllElements(const std::vector &arNodes) const + { + if (arNodes.empty()) + return std::vector({const_cast(this)}); + + std::vector arElements; + + if (!m_mStyle.empty()) + arElements.push_back(const_cast(this)); + + + std::vector arKins; + for (std::vector::const_reverse_iterator sNode = arNodes.rbegin(); sNode != arNodes.rend(); ++sNode) + { + arKins.push_back(*sNode); + if ((*sNode)[0] != L'#' && (*sNode)[0] != L'.') + break; + } + + for (const CElement* oElement : m_arKinElements) + { + for (std::vector::const_reverse_iterator sNode = arKins.rbegin(); sNode != arKins.rend(); ++sNode) + { + if (oElement->m_sSelector == *sNode) + { + std::vector arWords = arNodes; + arWords.pop_back(); + const std::vector arTemp = oElement->GetAllElements(arWords); + arElements.insert(arElements.end(), arTemp.begin(), arTemp.end()); + } + } + } + + for (const CElement* oElement : m_arPrevElements) + { + for (std::vector::const_reverse_iterator sNode = arNodes.rbegin(); sNode != arNodes.rend(); ++sNode) + { + if (oElement->m_sSelector == *sNode) + { + std::vector arWords = arNodes; + arWords.pop_back(); + + const std::vector arTemp = oElement->GetAllElements(arWords); + arElements.insert(arElements.end(), arTemp.begin(), arTemp.end()); + } + } + } + + return arElements; + } + + std::vector CElement::GetNextOfKin(const std::wstring &sName, const std::vector& arClasses) { if (m_arKinElements.empty()) return std::vector(); @@ -177,52 +234,6 @@ namespace NSCSS return arElements; } - std::vector CElement::GetPrevElements(const std::vector::reverse_iterator &arNodesRBegin, const std::vector::reverse_iterator &arNodesREnd) const - { - if (arNodesRBegin >= arNodesREnd || m_arPrevElements.empty()) - return std::vector(); - - std::vector arElements; - - for (std::vector::reverse_iterator iWord = arNodesRBegin; iWord != arNodesREnd; ++iWord) - { - if ((*arNodesRBegin) == L".module_title") - std::wcout << *iWord << std::endl; - if ((*iWord)[0] == L'.' && ((*iWord).find(L" ") != std::wstring::npos)) - { - std::vector arClasses = NS_STATIC_FUNCTIONS::GetWordsW(*iWord, L" "); - for (std::wstring sClass : arClasses) - { - for (CElement* oPrevElement : m_arPrevElements) - { - if (oPrevElement->m_sSelector == sClass) - { - arElements.push_back(oPrevElement); - std::vector arTempElements = oPrevElement->GetPrevElements(iWord + 1, arNodesREnd); - arElements.insert(arElements.end(), arTempElements.begin(), arTempElements.end()); - } - } - } - } - else - { - for (CElement* oPrevElement : m_arPrevElements) - { - if (oPrevElement->m_sSelector == *iWord) - { - arElements.push_back(oPrevElement); - std::vector arTempElements = oPrevElement->GetPrevElements(iWord + 1, arNodesREnd); - arElements.insert(arElements.end(), arTempElements.begin(), arTempElements.end()); - // return arElements; - } - } - } - } - - return arElements; - - } - CElement *CElement::FindPrevElement(const std::wstring &sSelector) const { if (sSelector.empty()) @@ -258,7 +269,7 @@ namespace NSCSS std::wcout << L"Selector: " << m_sSelector << std::endl; std::wcout << L"Full Selector: " << m_sFullSelector << std::endl; std::wcout << L"===========STYLE(" << m_mStyle.size() << ")===========" << std::endl; - for (const std::pair oPropertie : m_mStyle) + for (const std::pair& oPropertie : m_mStyle) std::wcout << oPropertie.first << L" - " << oPropertie.second << std::endl; std::wcout << L"===========================" << std::endl; diff --git a/Common/3dParty/html/css/src/CElement.h b/Common/3dParty/html/css/src/CElement.h index ef2f77505b..29085cf978 100644 --- a/Common/3dParty/html/css/src/CElement.h +++ b/Common/3dParty/html/css/src/CElement.h @@ -26,19 +26,19 @@ namespace NSCSS std::wstring GetSelector() const; std::wstring GetFullSelector() const; - bool Empty() const; - void SetSelector(const std::wstring& sSelector); void AddPropertie(const std::wstring& sName, const std::wstring& sValue); void AddProperties(const std::map& mProperties); void AddPrevElement(CElement* oPrevElement); void AddKinElement(CElement* oKinElement); + size_t EmptyPrevElements() const; + std::map GetStyle() const; std::map GetFullStyle(const std::vector& arSelectors) const; std::map GetFullStyle(const std::vector& arNodes) const; - std::vector GetNextOfKin(const std::wstring& sName, const std::vector& arClasses = {}) const; - std::vector GetPrevElements(const std::vector::reverse_iterator &arNodesRBegin, const std::vector::reverse_iterator &arNodesREnd) const; + std::vector GetAllElements(const std::vector& arNodes) const; + std::vector GetNextOfKin(const std::wstring& sName, const std::vector& arClasses = {}); std::map GetConvertStyle(const std::vector& arNodes) const; CElement *FindPrevElement(const std::wstring& sSelector) const; diff --git a/Common/3dParty/html/css/src/ConstValues.h b/Common/3dParty/html/css/src/ConstValues.h index 6b7465d720..2c47278b18 100644 --- a/Common/3dParty/html/css/src/ConstValues.h +++ b/Common/3dParty/html/css/src/ConstValues.h @@ -2,2500 +2,151 @@ #define CONSTVALUES_H #include "CssCalculator_global.h" -#include "StaticFunctions.h" -#include "CNode.h" + +#include #include -#include namespace NSCSS { - typedef enum { - Default = 0, - Pixel, - Point, - Cantimeter, - Millimeter, - Inch, - Peak - } UnitMeasure; - - struct StatistickElement + namespace NS_CONST_VALUES { - enum TypeElement + const unsigned short int FONT_SIZE = 22; + typedef enum { - IsStyle = 0, - IsId - } m_enType; - std::wstring sValue; + B_CustomStyle = 0, + B_StyleId = 1, + B_Type = 2, + B_Default = 3, - bool operator<(const StatistickElement& oStatistickElement) const + B_Name = 4, + B_BasedOn = 5, + B_QFormat = 6, + B_Link = 7, + B_UnhideWhenUsed = 8, + B_UiPriority = 9, +// B_SemiHidden = 10, +// B_S = 11, + } BasicProperties; + + typedef enum { - return sValue < oStatistickElement.sValue; - } - }; + P_Jc = 0, + P_Spacing = 1, + P_ContextualSpacing = 2, + P_Ind = 3, + P_OutlineLvl = 4, + P_Shd = 5, + // + P_TopBorder = 6, + P_LeftBorder = 7, + P_BottomBorder = 8, + P_RightBorder = 9, + // + P_KeepLines = 10, + P_KeepNext = 11, + } ParagraphProperties; - struct CTree - { - NSCSS::CNode m_oNode; - std::vector m_arrChild; - - inline static void CountingNumberRepetitions(const CTree &oTree, std::map &mStatictics) + typedef enum { - if (!oTree.m_oNode.m_sId.empty()) - ++mStatictics[StatistickElement{StatistickElement::IsId, L'#' + oTree.m_oNode.m_sId}]; - if (!oTree.m_oNode.m_sStyle.empty()) - ++mStatictics[StatistickElement{StatistickElement::IsStyle, oTree.m_oNode.m_sStyle}]; + R_RFonts = 0, + R_Sz = 1, + R_B = 2, + R_I = 3, + R_Color = 4, + R_U = 5, + R_Shd = 6 + } RunnerProperties; - if (!oTree.m_arrChild.empty()) - for (const CTree& oChildren : oTree.m_arrChild) - CountingNumberRepetitions(oChildren, mStatictics); - } - }; - - namespace NSConstValues - { - namespace NSMaps { - const std::map mColors { - /* Red tones */ - {L"indianeed", L"CD5C5C"}, {L"lightcoral", L"F08080"}, {L"salmon", L"FA8072"}, - {L"darksalmon", L"E9967A"}, {L"lightsalmon", L"FFA07A"}, {L"crimson", L"DC143C"}, - {L"red", L"FF0000"}, {L"firebrick", L"B22222"}, {L"darkeed", L"8B0000"}, - /* Pink tones */ - {L"pink", L"FFC0CB"}, {L"lightpink", L"FFB6C1"}, {L"hotpink", L"FF69B4"}, - {L"deeppink", L"FF1493"}, {L"mediumvioletred", L"C71585"}, {L"palevioleteed", L"DB7093"}, - /* Orange tones */ - {L"lightsalmon", L"FFA07A"}, {L"coral", L"FF7F50"}, {L"tomato", L"FF6347"}, - {L"orangered", L"FF4500"}, {L"darkorange", L"FF8C00"}, {L"orange", L"FFA500"}, - /* Yellow tones */ - {L"gold", L"FFD700"}, {L"yellow", L"FFFF00"}, {L"lightyellow", L"FFFFE0"}, - {L"lemonchiffon", L"FFFACD"}, {L"lightgoldenrodyellow", L"FAFAD2"}, {L"papayawhip", L"FFEFD5"}, - {L"moccasin", L"FFE4B5"}, {L"peachpuff", L"FFDAB9"}, {L"palegoldenrod", L"EEE8AA"}, - {L"khaki", L"F0E68C"}, {L"darkkhaki", L"BDB76B"}, - /* Purple tones */ - {L"lavender", L"E6E6FA"}, {L"thistle", L"D8BFD8"}, {L"plum", L"DDA0DD"}, - {L"violet", L"EE82EE"}, {L"orchid", L"DA70D6"}, {L"fuchsia", L"FF00FF"}, - {L"magenta", L"FF00FF"}, {L"mediumorchid", L"BA55D3"}, {L"mediumpurple", L"9370DB"}, - {L"blueviolet", L"8A2BE2"}, {L"darkviolet", L"9400D3"}, {L"darkorchid", L"9932CC"}, - {L"darkmagenta", L"8B008B"}, {L"purple", L"800080"}, {L"indigo", L"4B0082"}, - {L"slateblue", L"6A5ACD"}, {L"darkslateblue", L"483D8B"}, - /* Brown tones */ - {L"cornsilk", L"FFF8DC"}, {L"blanchedalmond", L"FFEBCD"}, {L"bisque", L"FFE4C4"}, - {L"navajowhite", L"FFDEAD"}, {L"wheat", L"F5DEB3"}, {L"burlywood", L"DEB887"}, - {L"tan", L"D2B48C"}, {L"rosybrown", L"BC8F8F"}, {L"sandybrown", L"F4A460"}, - {L"goldenrod", L"DAA520"}, {L"darkgoldenrod", L"B8860B"}, {L"peru", L"CD853F"}, - {L"chocolate", L"D2691E"}, {L"saddlebrown", L"8B4513"}, {L"sienna", L"A0522D"}, - {L"brown", L"A52A2A"}, {L"maroon", L"800000"}, - /* Green tones */ - {L"greenyellow", L"ADFF2F"}, {L"chartreuse", L"7FFF00"}, {L"lawngreen", L"7CFC00"}, - {L"lime", L"00FF00"}, {L"limegreen", L"32CD32"}, {L"palegreen", L"98FB98"}, - {L"lightgreen", L"90EE90"}, {L"mediumspringgreen", L"00FA9A"}, {L"springgreen", L"00FF7F"}, - {L"mediumseagreen", L"3CB371"}, {L"seagreen", L"2E8B57"}, {L"forestgreen", L"228B22"}, - {L"green", L"008000"}, {L"darkgreen", L"006400"}, {L"yellowgreen", L"9ACD32"}, - {L"olivedrab", L"6B8E23"}, {L"olive", L"808000"}, {L"darkolivegreen",L"556B2F"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"}, - {L"mediumaquamarine", L"66CDAA"}, {L"darkseagreen", L"8FBC8F"}, {L"lightseagreen", L"20B2AA"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"}, - {L"darkcyan", L"008B8B"}, {L"teal", L"008080"}, - /* Blue tones */ - {L"aqua", L"00FFFF"}, {L"cyan", L"00FFFF"}, {L"lightcyan", L"E0FFFF"}, - {L"paleturquoise", L"AFEEEE"}, {L"aquamarine", L"7FFFD4"}, {L"turquoise", L"40E0D0"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"}, - {L"mediumturquoise", L"48D1CC"}, {L"darkturquoise", L"00CED1"}, {L"cadetblue", L"5F9EA0"}, - {L"steelblue", L"4682B4"}, {L"lightsteelblue", L"B0C4DE"}, {L"powderblue", L"B0E0E6"}, - {L"lightblue", L"ADD8E6"}, {L"skyblue", L"87CEEB"}, {L"lightskyblue", L"87CEFA"}, - {L"deepskyblue", L"00BFFF"}, {L"dodgerblue", L"1E90FF"}, {L"cornflowerblue",L"6495ED"}, - {L"mediumdlateblue", L"7B68EE"}, {L"royalblue", L"4169E1"}, {L"blue", L"0000FF"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"}, - {L"mediumblue", L"0000CD"}, {L"darkblue", L"00008B"}, {L"navy", L"000080"}, - {L"midnightblue", L"191970"}, - /* White tones */ - {L"white", L"FFFFFF"}, {L"snow", L"FFFAFA"}, {L"honeydew", L"F0FFF0"}, - {L"mintcream", L"F5FFFA"}, {L"azure", L"F0FFFF"}, {L"aliceblue", L"F0F8FF"}, - {L"ghostwhite", L"F8F8FF"}, {L"whitesmoke", L"F5F5F5"}, {L"seashell", L"FFF5EE"}, - {L"beige", L"F5F5DC"}, {L"oldlace", L"FDF5E6"}, {L"floralwhite", L"FFFAF0"}, - {L"ivory", L"FFFFF0"}, {L"antiquewhite", L"FAEBD7"}, {L"linen", L"FAF0E6"}, - {L"lavenderblush", L"FFF0F5"}, {L"mistyrose", L"FFE4E1"}, - /* Gray tones */ - {L"gainsboro", L"DCDCDC"}, {L"lightgrey", L"D3D3D3"}, {L"silver", L"C0C0C0"}, - {L"darkgray", L"A9A9A9"}, {L"gray", L"808080"}, {L"dimgray", L"696969"}, - {L"lightslategray", L"778899"}, {L"slategray", L"708090"}, {L"darkslategray", L"2F4F4F"}, - {L"black", L"000000"}, - /* Outdated */ - {L"windowtext", L"000000"}, {L"transparent", L"000000"} - }; - } - - namespace NSProperties { - - typedef enum - { - B_CustomStyle = 0, - B_StyleId = 1, - B_Type = 2, - B_Default = 3, - - B_Name = 4, - B_BasedOn = 5, - B_QFormat = 6, - B_Link = 7, - B_UnhideWhenUsed = 8, - B_UiPriority = 9, - } BasicProperties; - - typedef enum - { - P_Jc = 0, - P_Spacing = 1, - P_ContextualSpacing = 2, - P_Ind = 3, - P_OutlineLvl = 4, - P_Shd = 5, - // - P_TopBorder = 6, - P_LeftBorder = 7, - P_BottomBorder = 8, - P_RightBorder = 9, - // - P_KeepLines = 10, - P_KeepNext = 11, - } ParagraphProperties; - - typedef enum - { - R_RFonts = 0, - R_Sz = 1, - R_B = 2, - R_I = 3, - R_Color = 4, - R_U = 5, - R_Shd = 6, - R_SmallCaps = 7 - } RunnerProperties; - - typedef enum - { - T_TblInd = 0, - // - T_CellTop = 1, - T_CellLeft = 2, - T_CellBottom = 3, - T_CellRight = 4, - // - - // - T_BorderTop = 5, - T_BorderLeft = 6, - T_BorderBottom = 7, - T_BorderRight = 8, - T_BorderInsideH = 9, - T_BorderInsideV = 10 - // - } TableProperties; - } - - namespace NSCssProperties + typedef enum { - const float fNoneValue = -99999999999.0f; - - enum class FontStretch - { - none = 0, - normal, - ultraCondensed, - extraCondensed, - condensed, - semiCondensed, - semiExpanded, - expanded, - extraExpanded, - ultraExpanded, - }; - - enum class FontStyle - { - none = 0, - normal, - italic, - oblique, - }; - - enum class FontVariant - { - none = 0, - normal, - smallCaps, - }; - - enum class FontWeight - { - none = 0, - normal, - bold - }; - - class Font - { - float fSize; - FontStretch enStretch; - FontStyle enStyle; - FontVariant enVariant; - FontWeight enWeight; - float fLineHeight; - std::wstring sFamily; - - std::vector bImportants; - std::vector arLevels; - - public: - - Font() : fSize (fNoneValue), - enStretch (FontStretch::none), - enStyle (FontStyle::none), - enVariant (FontVariant::none), - enWeight (FontWeight::none), - fLineHeight(fNoneValue), - bImportants({false, false, false, false, false, false, false}), - arLevels ({0, 0, 0, 0, 0, 0, 0}){}; - - void ClearImportants() - { - bImportants = {false, false, false, false, false, false, false}; - } - - Font operator+=(const Font& oFont) - { - if (NS_STATIC_FUNCTIONS::IsTrue(bImportants)) - return *this; - - if (oFont.fSize != fNoneValue) - fSize = oFont.fSize; - if (oFont.enStretch != FontStretch::none) - enStretch = oFont.enStretch; - if (oFont.enStyle != FontStyle::none) - enStyle = oFont.enStyle; - if (oFont.enVariant != FontVariant::none) - enVariant = oFont.enVariant; - if (oFont.enWeight != FontWeight::none) - enWeight = oFont.enWeight; - if (oFont.fLineHeight != fNoneValue) - fLineHeight = oFont.fLineHeight; - if (!oFont.sFamily.empty()) - sFamily = oFont.sFamily; - - bImportants = oFont.bImportants; - arLevels = oFont.arLevels; - - return *this; - } - - static void FontEquation(Font &oFirstFont, Font &oSecondFont) - { - if (oFirstFont.bImportants[0] && !oSecondFont.bImportants[0] && oFirstFont.fSize != fNoneValue) - oSecondFont.fSize = fNoneValue; - else if (oSecondFont.bImportants[0] && !oFirstFont.bImportants[0] && oSecondFont.fSize != fNoneValue) - oFirstFont.fSize = fNoneValue; - else if (oFirstFont.fSize != fNoneValue && oSecondFont.fSize != fNoneValue) - { - if (oFirstFont.arLevels[0] < oSecondFont.arLevels[0]) - oFirstFont.fSize = fNoneValue; - else - oSecondFont.fSize = fNoneValue; - } - - if (oFirstFont.bImportants[1] && !oSecondFont.bImportants[1] && oFirstFont.enStretch != FontStretch::none) - oSecondFont.enStretch = FontStretch::none; - else if (oSecondFont.bImportants[1] && !oFirstFont.bImportants[1] && oSecondFont.enStretch != FontStretch::none) - oFirstFont.enStretch = FontStretch::none; - else if (oFirstFont.enStretch != FontStretch::none && oSecondFont.enStretch != FontStretch::none) - { - if (oFirstFont.arLevels[1] < oSecondFont.arLevels[1]) - oFirstFont.enStretch = FontStretch::none; - else - oSecondFont.enStretch = FontStretch::none; - } - - if (oFirstFont.bImportants[2] && !oSecondFont.bImportants[2] && oFirstFont.enStyle != FontStyle::none) - oSecondFont.enStyle = FontStyle::none; - else if (oSecondFont.bImportants[2] && !oFirstFont.bImportants[2] && oSecondFont.enStyle != FontStyle::none) - oFirstFont.enStyle = FontStyle::none; - else if (oFirstFont.enStyle != FontStyle::none && oSecondFont.enStyle != FontStyle::none) - { - if (oFirstFont.arLevels[2] < oSecondFont.arLevels[2]) - oFirstFont.enStyle = FontStyle::none; - else - oSecondFont.enStyle = FontStyle::none; - } - - if (oFirstFont.bImportants[3] && !oSecondFont.bImportants[3] && oFirstFont.enVariant != FontVariant::none) - oSecondFont.enVariant = FontVariant::none; - else if (oSecondFont.bImportants[3] && !oFirstFont.bImportants[3] && oSecondFont.enVariant != FontVariant::none) - oFirstFont.enVariant = FontVariant::none; - else if (oFirstFont.enVariant != FontVariant::none && oSecondFont.enVariant != FontVariant::none) - { - if (oFirstFont.arLevels[3] < oSecondFont.arLevels[3]) - oFirstFont.enVariant = FontVariant::none; - else - oSecondFont.enVariant = FontVariant::none; - } - - if (oFirstFont.bImportants[4] && !oSecondFont.bImportants[4] && oFirstFont.enWeight != FontWeight::none) - oSecondFont.enWeight = FontWeight::none; - else if (oSecondFont.bImportants[4] && !oFirstFont.bImportants[4] && oSecondFont.enWeight != FontWeight::none) - oFirstFont.enWeight = FontWeight::none; - else if (oFirstFont.enWeight != FontWeight::none && oSecondFont.enWeight != FontWeight::none) - { - if (oFirstFont.arLevels[4] < oSecondFont.arLevels[4]) - oFirstFont.enWeight = FontWeight::none; - else - oSecondFont.enWeight = FontWeight::none; - } - - if (oFirstFont.bImportants[5] && !oSecondFont.bImportants[5] && oFirstFont.fLineHeight != fNoneValue) - oSecondFont.fLineHeight = fNoneValue; - else if (oSecondFont.bImportants[5] && !oFirstFont.bImportants[5] && oSecondFont.fLineHeight != fNoneValue) - oFirstFont.fLineHeight = fNoneValue; - else if (oFirstFont.fLineHeight != fNoneValue && oSecondFont.fLineHeight != fNoneValue) - { - if (oFirstFont.arLevels[5] < oSecondFont.arLevels[5]) - oFirstFont.fLineHeight = fNoneValue; - else - oSecondFont.fLineHeight = fNoneValue; - } - - if (oFirstFont.bImportants[6] && !oSecondFont.bImportants[6] && !oFirstFont.sFamily.empty()) - oSecondFont.sFamily.clear(); - else if (oSecondFont.bImportants[6] && !oFirstFont.bImportants[6] && !oSecondFont.sFamily.empty()) - oFirstFont.sFamily.clear(); - else if (!oFirstFont.sFamily.empty() && !oSecondFont.sFamily.empty()) - { - if (oFirstFont.arLevels[6] < oSecondFont.arLevels[6]) - oFirstFont.sFamily.clear(); - else - oSecondFont.sFamily.clear(); - } - } - - bool operator==(const Font& oFont) const - { - return fSize == oFont.fSize && - fLineHeight == oFont.fLineHeight && - sFamily == oFont.sFamily && - enStretch == oFont.enStretch && - enStyle == oFont.enStyle && - enVariant == oFont.enVariant && - enWeight == oFont.enWeight; - } - - bool Empty() const - { - return fSize == fNoneValue && enStretch == FontStretch::none && - enStyle == FontStyle::none && enVariant == FontVariant::none && - enWeight == FontWeight::none && fLineHeight == fNoneValue && sFamily.empty(); - } - - void Clear() - { - fSize = fNoneValue; - enStretch = FontStretch::none; - enStyle = FontStyle::none; - enVariant = FontVariant::none; - enWeight = FontWeight::none; - fLineHeight = fNoneValue; - sFamily .clear(); - bImportants = {false, false, false, false, false, false, false}; - - } - - void SetFont(const std::wstring &sFont, const unsigned int unLevel, const bool& bHardMode = false) - { - if (sFont.empty() || (NS_STATIC_FUNCTIONS::IsTrue(bImportants) && !bHardMode)) - return; - - const std::vector arValues = NSCSS::NS_STATIC_FUNCTIONS::GetWordsW(sFont, L" ,/"); - - bool bIsBrackets = false; - unsigned short nPosition = 0; - - for (const std::wstring &sWord : arValues) - { - if (nPosition < 4) - { - if (sWord == L"normal") - { - if (!bImportants[2] || bHardMode) - { - enStyle = FontStyle::normal; - arLevels[2] = unLevel; - } - ++nPosition; - continue; - } - else if (sWord == L"italic") - { - if (!bImportants[2] || bHardMode) - { - enStyle = FontStyle::italic; - arLevels[2] = unLevel; - } - ++nPosition; - continue; - } - else if (sWord == L"oblique") - { - if (!bImportants[2] || bHardMode) - { - enStyle = FontStyle::oblique; - arLevels[2] = unLevel; - } - ++nPosition; - continue; - } - else if (sWord == L"inherit") - { - ++nPosition; - continue; - } - } - - if (nPosition < 4 && enVariant == FontVariant::none) - { - if (sWord == L"normal") - { - if (!bImportants[3] || bHardMode) - { - enVariant = FontVariant::normal; - arLevels[3] = unLevel; - } - ++nPosition; - continue; - } - else if (sWord == L"small-caps") - { - if (!bImportants[3] || bHardMode) - { - enVariant = FontVariant::smallCaps; - arLevels[3] = unLevel; - } - ++nPosition; - continue; - } - else if (sWord == L"inherit") - { - ++nPosition; - continue; - } - } - - if (nPosition < 4 && enWeight == FontWeight::none) - { - if (sWord == L"bold" || sWord == L"bolder" || ((sWord[0] == L'6' || sWord[0] == L'7' || sWord[0] == L'8' ||sWord[0] == L'9') && sWord.length() == 3)) - { - if (!bImportants[4] || bHardMode) - { - arLevels[4] = unLevel; - enWeight = FontWeight::bold; - } - ++nPosition; - continue; - } - else if (sWord == L"normal" || ((sWord[0] == L'3' || sWord[0] == L'4' ||sWord[0] == L'5') && sWord.length() == 3)) - { - if (!bImportants[4] || bHardMode) - { - arLevels[4] = unLevel; - enWeight = FontWeight::normal; - } - ++nPosition; - continue; - } - } - - if (nPosition < 4 && enStretch == FontStretch::none) - { - if (sWord == L"ultra-condensed") - { - if (!bImportants[1] || bHardMode) - { - arLevels[1] = unLevel; - enStretch = FontStretch::ultraCondensed; - } - ++nPosition; - continue; - } - else if (sWord == L"extra-condensed") - { - if (!bImportants[1] || bHardMode) - { - arLevels[1] = unLevel; - enStretch = FontStretch::extraCondensed; - } - ++nPosition; - continue; - } - else if (sWord == L"condensed") - { - if (!bImportants[1] || bHardMode) - { - arLevels[1] = unLevel; - enStretch = FontStretch::condensed; - } - ++nPosition; - continue; - } - else if (sWord == L"semi-condensed") - { - if (!bImportants[1] || bHardMode) - { - arLevels[1] = unLevel; - enStretch = FontStretch::semiCondensed; - } - ++nPosition; - continue; - } - else if (sWord == L"normal") - { - if (!bImportants[1] || bHardMode) - { - arLevels[1] = unLevel; - enStretch = FontStretch::normal; - } - ++nPosition; - continue; - } - else if (sWord == L"semi-expanded") - { - if (!bImportants[1] || bHardMode) - { - arLevels[1] = unLevel; - enStretch = FontStretch::semiExpanded; - } - ++nPosition; - continue; - } - else if (sWord == L"extra-expanded") - { - if (!bImportants[1] || bHardMode) - { - arLevels[1] = unLevel; - enStretch = FontStretch::extraExpanded; - } - ++nPosition; - continue; - } - else if (sWord == L"ultra-expanded") - { - if (!bImportants[1] || bHardMode) - { - arLevels[1] = unLevel; - enStretch = FontStretch::ultraExpanded; - } - ++nPosition; - continue; - } - else if (sWord == L"inherit") - { - ++nPosition; - continue; - } - } - - if ((nPosition < 5 && iswdigit(sWord[0])) || iswdigit(sWord[0])) - { - nPosition = 5; - if (!bImportants[0] || bHardMode) - { - arLevels[0] = unLevel; - fSize = wcstof(sWord.c_str(), NULL); - } - continue; - } - - if (nPosition == 5 && iswdigit(sWord[0])) - { - if (!bImportants[5] || bHardMode) - { - arLevels[5] = unLevel; - fLineHeight = wcstof(sWord.c_str(), NULL); - } - ++nPosition; - continue; - } - - if (nPosition >= 5) - { - if (bIsBrackets) - { - arLevels[6] = unLevel; - if (!bImportants[6] || bHardMode) - sFamily += L' ' + sWord; - if (sWord.back() == L'"' || sWord.back() == L'\'') - bIsBrackets = false; - continue; - } - - if (sWord[0] == L'"' || sWord[0] == L'\'') - { - if (bIsBrackets) - bIsBrackets = false; - else - { - bIsBrackets = true; - if (!bImportants[6] || bHardMode) - sFamily = sWord; - } - - if (sWord.back() == L'"' || sWord.back() == L'\'') - bIsBrackets = false; - - continue; - } - } - } - } - - void SetFontFamily(const std::wstring &sFamily, const unsigned int& unLevel, const bool& bHardMode = false) - { - if (sFamily.empty() || (bImportants[6] && !bHardMode)) - return; - - std::vector arWords = NS_STATIC_FUNCTIONS::GetWordsW(sFamily, L","); - - for (std::vector::reverse_iterator iWord = arWords.rbegin() + ((arWords.size() == 1) ? 0 : 1); iWord != arWords.rend(); ++iWord) - { - if ((*iWord).empty()) - continue; - - const std::wstring sValue = NS_STATIC_FUNCTIONS::StripSymbols(*iWord, L" "); - - if (sValue[0] == L'"' || sValue[0] == L'\'') - { - arLevels[6] = unLevel; - this->sFamily = sValue; - return; - } - else if (sValue != L"serif" && sValue != L"sans-serif" && sValue != L"monospace" && - sValue != L"cursive" && sValue != L"fantasy" && sValue != L"system-ui" && - sValue != L"emoji" && sValue != L"math" && sValue != L"fangsong" && - sValue != L"inherit" && sValue != L"initial" && sValue != L"unset") - { - arLevels[6] = unLevel; - this->sFamily = L'\'' + sValue + L'\''; - return; - } - } - } - - void SetSize(const std::wstring &sSize, const unsigned int& unLevel, const bool& bHardMode = false) - { - if (sSize.empty() || (bImportants[0] && !bHardMode)) - return; - - const float fValue = wcstof(sSize.c_str(), NULL); - if (fValue > 0.0f) - { - arLevels[0] = unLevel; - fSize = fValue; - } - } - - void SetStretch(const std::wstring &sStretch, const unsigned int& unLevel, const bool& bHardMode = false) - { - if (sStretch.empty() || (bImportants[1] && !bHardMode)) - return; - - if (sStretch == L"ultra-condensed") - { - enStretch = NSConstValues::NSCssProperties::FontStretch::ultraCondensed; - arLevels[1] = unLevel; - } - else if (sStretch == L"extra-condensed") - { - enStretch = NSConstValues::NSCssProperties::FontStretch::extraCondensed; - arLevels[1] = unLevel; - } - else if (sStretch == L"condensed") - { - enStretch = NSConstValues::NSCssProperties::FontStretch::condensed; - arLevels[1] = unLevel; - } - else if (sStretch == L"semi-condensed") - { - enStretch = NSConstValues::NSCssProperties::FontStretch::semiCondensed; - arLevels[1] = unLevel; - } - else if (sStretch == L"normal") - { - enStretch = NSConstValues::NSCssProperties::FontStretch::normal; - arLevels[1] = unLevel; - } - else if (sStretch == L"semi-expanded") - { - enStretch = NSConstValues::NSCssProperties::FontStretch::semiExpanded; - arLevels[1] = unLevel; - } - else if (sStretch == L"expanded") - { - enStretch = NSConstValues::NSCssProperties::FontStretch::expanded; - arLevels[1] = unLevel; - } - else if (sStretch == L"extra-expanded") - { - enStretch = NSConstValues::NSCssProperties::FontStretch::extraExpanded; - arLevels[1] = unLevel; - } - else if (sStretch == L"ultra-expanded") - { - enStretch = NSConstValues::NSCssProperties::FontStretch::ultraExpanded; - arLevels[1] = unLevel; - } - } - - void SetStyle(const std::wstring &sStyle, const unsigned int& unLevel, const bool& bHardMode = false) - { - if (sStyle.empty() || (bImportants[2] && !bHardMode)) - return; - - if (sStyle == L"italic") - { - arLevels[2] = unLevel; - enStyle = NSConstValues::NSCssProperties::FontStyle::italic; - } - else if (sStyle == L"oblique") - { - arLevels[2] = unLevel; - enStyle = NSConstValues::NSCssProperties::FontStyle::oblique; - } - else if (sStyle == L"normal") - { - arLevels[2] = unLevel; - enStyle = NSConstValues::NSCssProperties::FontStyle::normal; - } - } - - void SetVariant(const std::wstring &sVariant, const unsigned int& unLevel, const bool& bHardMode = false) - { - if (sVariant.empty() || (bImportants[3] && !bHardMode)) - return; - - if (sVariant == L"small-caps") - { - arLevels[3] = unLevel; - enVariant = NSConstValues::NSCssProperties::FontVariant::smallCaps; - } - else if (sVariant == L"normal") - { - arLevels[3] = unLevel; - enVariant = NSConstValues::NSCssProperties::FontVariant::normal; - } - } - - void SetWeight(const std::wstring &sWeight, const unsigned int& unLevel, const bool& bHardMode = false) - { - if (sWeight.empty() || (bImportants[4] && !bHardMode)) - return; - - if (sWeight == L"bold" || sWeight == L"bolder" || - sWeight[0] == L'6' || sWeight[0] == L'7' || - sWeight[0] == L'8' || sWeight[0] == L'9') - { - arLevels[4] = unLevel; - enWeight = NSConstValues::NSCssProperties::FontWeight::bold; - } - else if (sWeight == L"normal" || sWeight[0] == L'3' || - sWeight[0] == L'4' || sWeight[0] == L'5') - { - arLevels[4] = unLevel; - enWeight = NSConstValues::NSCssProperties::FontWeight::normal; - } - } - - void SetLineHeight(const std::wstring &sLineHeight, const unsigned int& unLevel, const bool& bHardMode = false) - { - if (sLineHeight.empty() || (bImportants[5] && !bHardMode)) - return; - - if (sLineHeight == L"normal") - fLineHeight = 1.2; - else - { - const float fValue = wcstof(sLineHeight.c_str(), NULL); - if (fValue > 0.0f) - { - arLevels[5] = unLevel; - fLineHeight = fValue; - } - } - } - - void SetImportantAll(const bool &bImportant) - { - if (bImportant) - bImportants = {true, true, true, true, true, true, true}; - else - bImportants = {false, false, false, false, false, false, false}; - } - - void SetImportantSize(const bool &bImportant) - { - bImportants[0] = bImportant; - } - - void SetImportantenStretch(const bool &bImportant) - { - bImportants[1] = bImportant; - } - - void SetImportantenStyle(const bool &bImportant) - { - bImportants[2] = bImportant; - } - - void SetImportantenVariant(const bool &bImportant) - { - bImportants[3] = bImportant; - } - - void SetImportantenWeight(const bool &bImportant) - { - bImportants[4] = bImportant; - } - - void SetImportantenLineHeight(const bool &bImportant) - { - bImportants[5] = bImportant; - } - - void SetImportantenFamily(const bool &bImportant) - { - bImportants[6] = bImportant; - } - - float GetSize() const - { - return (fSize == fNoneValue) ? 22.0f : fSize; - } - - std::wstring GetSizeW() const - { - if (fSize == fNoneValue) - return std::wstring(); - - return std::to_wstring(static_cast(fSize + 0.5f)); - } - - std::wstring GetFamily() const - { - return sFamily; - } - - std::wstring GetStyle() const - { - if (enStyle == FontStyle::italic) - return L"italic"; - - if (enStyle == FontStyle::normal) - return L"normal"; - - return std::wstring(); - } - - std::wstring GetWeight() const - { - if (enWeight == FontWeight::bold) - return L"bold"; - - if (enWeight == FontWeight::normal) - return L"normal"; - - return std::wstring(); - } - - std::wstring GetLineHeight() const - { - if (fLineHeight < 0.0f || fLineHeight < fSize) - return std::wstring(); - - return std::to_wstring(static_cast(fLineHeight * 10.0f + 0.5f)); - } - - std::wstring GetVariant() const - { - if (enVariant == FontVariant::smallCaps) - return L"smallCaps"; - - if (enVariant == FontVariant::normal) - return L"normal"; - - return std::wstring(); - } - }; - - class Margin - { - float fTopSide; - float fRightSide; - float fBottomSide; - float fLeftSide; - - bool bPermission; - std::vector bImportants; - std::vector arLevels; - - public: - Margin() : fTopSide (fNoneValue), - fRightSide (fNoneValue), - fBottomSide (fNoneValue), - fLeftSide (fNoneValue), - bPermission (true), - bImportants ({false, false, false, false}), - arLevels ({0, 0, 0, 0}){} - - void ClearImportants() - { - bImportants = {false, false, false, false}; - } - - Margin operator+=(const Margin& oMargin) - { - if (NS_STATIC_FUNCTIONS::IsTrue(bImportants)) - return *this; - - if (oMargin.fTopSide != fNoneValue) - fTopSide = oMargin.fTopSide; - if (oMargin.fRightSide != fNoneValue) - fRightSide = oMargin.fRightSide; - if (oMargin.fBottomSide != fNoneValue) - fBottomSide = oMargin.fBottomSide; - if (oMargin.fLeftSide != fNoneValue) - fLeftSide = oMargin.fLeftSide; - - bImportants = oMargin.bImportants; - arLevels = oMargin.arLevels; - - return *this;; - } - - static void MarginEquation(Margin &oFirstMargin, Margin &oSecondMargin) - { - if (oFirstMargin.bImportants[0] && !oSecondMargin.bImportants[0] && oFirstMargin.fTopSide != fNoneValue) - oSecondMargin.fTopSide = fNoneValue; - else if (oSecondMargin.bImportants[0] && !oFirstMargin.bImportants[0] && oSecondMargin.fTopSide != fNoneValue) - oFirstMargin.fTopSide = fNoneValue; - else if (oFirstMargin.fTopSide != fNoneValue && oSecondMargin.fTopSide != fNoneValue) - { - if (oFirstMargin.arLevels[0] < oSecondMargin.arLevels[0]) - oFirstMargin.fTopSide = fNoneValue; - else - oSecondMargin.fTopSide = fNoneValue; - } - - if (oFirstMargin.bImportants[1] && !oSecondMargin.bImportants[1] && oFirstMargin.fRightSide != fNoneValue) - oSecondMargin.fRightSide = fNoneValue; - else if (oSecondMargin.bImportants[1] && !oFirstMargin.bImportants[1] && oSecondMargin.fRightSide != fNoneValue) - oFirstMargin.fRightSide = fNoneValue; - else if (oFirstMargin.fRightSide != fNoneValue && oSecondMargin.fRightSide != fNoneValue) - { - if (oFirstMargin.arLevels[1] < oSecondMargin.arLevels[1]) - oFirstMargin.fRightSide = fNoneValue; - else - oSecondMargin.fRightSide = fNoneValue; - } - - if (oFirstMargin.bImportants[2] && !oSecondMargin.bImportants[2] && oFirstMargin.fBottomSide != fNoneValue) - oSecondMargin.fBottomSide = fNoneValue; - else if (oSecondMargin.bImportants[2] && !oFirstMargin.bImportants[2] && oSecondMargin.fBottomSide != fNoneValue) - oFirstMargin.fBottomSide = fNoneValue; - else if (oFirstMargin.fBottomSide != fNoneValue && oSecondMargin.fBottomSide != fNoneValue) - { - if (oFirstMargin.arLevels[2] < oSecondMargin.arLevels[2]) - oFirstMargin.fBottomSide = fNoneValue; - else - oSecondMargin.fBottomSide = fNoneValue; - } - - if (oFirstMargin.bImportants[3] && !oSecondMargin.bImportants[3] && oFirstMargin.fLeftSide != fNoneValue) - oSecondMargin.fLeftSide = fNoneValue; - else if (oSecondMargin.bImportants[3] && !oFirstMargin.bImportants[3] && oSecondMargin.fLeftSide != fNoneValue) - oFirstMargin.fLeftSide = fNoneValue; - else if (oFirstMargin.fLeftSide != fNoneValue && oSecondMargin.fLeftSide != fNoneValue) - { - if (oFirstMargin.arLevels[3] < oSecondMargin.arLevels[3]) - oFirstMargin.fLeftSide = fNoneValue; - else - oSecondMargin.fLeftSide = fNoneValue; - } - } - - bool operator==(const Margin& oMargin) const - { - return fTopSide == oMargin.fTopSide && - fRightSide == oMargin.fRightSide && - fBottomSide == oMargin.fBottomSide && - fLeftSide == oMargin.fLeftSide; - } - - bool Empty() const - { - if (!bPermission) - return true; - - return fTopSide == fNoneValue && fRightSide == fNoneValue && fBottomSide == fNoneValue && fLeftSide == fNoneValue; - }; - - void SetPermission(const bool &bPermission) - { - this->bPermission = bPermission; - } - - void SetImportantAll(const bool &bImportant) - { - if (bImportant) - bImportants = {true, true, true, true}; - else - bImportants = {false, false, false, false}; - } - - void SetImportantTopSide(const bool &bImportant) - { - bImportants[0] = bImportant; - } - - void SetImportantRightSide(const bool &bImportant) - { - bImportants[1] = bImportant; - } - - void SetImportantBottomSide(const bool &bImportant) - { - bImportants[2] = bImportant; - } - - void SetImportantLeftSide(const bool &bImportant) - { - bImportants[3] = bImportant; - } - - void AddMargin(const std::wstring& sMargin, const unsigned int& unLevel, const bool& bHardMode = false) - { - if (sMargin.empty() || !bPermission || (NS_STATIC_FUNCTIONS::IsTrue(bImportants) && !bHardMode)) - return; - - if (fTopSide == fNoneValue) - fTopSide = 0; - if (fRightSide == fNoneValue) - fRightSide = 0; - if (fBottomSide == fNoneValue) - fBottomSide = 0; - if (fLeftSide == fNoneValue) - fLeftSide = 0; - - const std::vector arValues = NS_STATIC_FUNCTIONS::GetWordsW(sMargin, L" "); - switch (arValues.size()) - { - case 0: - return; - case 1: - { - const float fValue = wcstof(arValues[0].c_str(), NULL); - - if (!bImportants[0] || bHardMode) - { - arLevels[0] = unLevel; - fTopSide += fValue; - } - if (!bImportants[1] || bHardMode) - { - arLevels[1] = unLevel; - fRightSide += fValue; - } - if (!bImportants[2] || bHardMode) - { - arLevels[2] = unLevel; - fBottomSide += fValue; - } - if (!bImportants[3] || bHardMode) - { - arLevels[3] = unLevel; - fLeftSide += fValue; - } - break; - } - case 2: - { - const float fValue1 = wcstof(arValues[0].c_str(), NULL); - const float fValue2 = wcstof(arValues[1].c_str(), NULL); - - if (!bImportants[0] || bHardMode) - { - arLevels[0] = unLevel; - fTopSide += fValue1; - } - if (!bImportants[1] || bHardMode) - { - arLevels[1] = unLevel; - fRightSide += fValue2; - } - if (!bImportants[2] || bHardMode) - { - arLevels[2] = unLevel; - fBottomSide += fValue1; - } - if (!bImportants[3] || bHardMode) - { - arLevels[3] = unLevel; - fLeftSide += fValue2; - } - break; - } - case 3: - { - const float fValue = wcstof(arValues[1].c_str(), NULL); - if (!bImportants[0] || bHardMode) - { - arLevels[0] = unLevel; - fTopSide += wcstof(arValues[0].c_str(), NULL); - } - if (!bImportants[1] || bHardMode) - { - arLevels[1] = unLevel; - fRightSide += fValue; - } - if (!bImportants[2] || bHardMode) - { - arLevels[2] = unLevel; - fBottomSide += wcstof(arValues[2].c_str(), NULL); - } - if (!bImportants[3] || bHardMode) - { - arLevels[3] = unLevel; - fLeftSide += fValue; - } - break; - } - case 4: - { - if (!bImportants[0] || bHardMode) - { - arLevels[0] = unLevel; - fTopSide += wcstof(arValues[0].c_str(), NULL); - } - if (!bImportants[1] || bHardMode) - { - arLevels[1] = unLevel; - fRightSide += wcstof(arValues[1].c_str(), NULL); - } - if (!bImportants[2] || bHardMode) - { - arLevels[2] = unLevel; - fBottomSide += wcstof(arValues[2].c_str(), NULL); - } - if (!bImportants[3] || bHardMode) - { - arLevels[3] = unLevel; - fLeftSide += wcstof(arValues[3].c_str(), NULL); - } - break; - } - } - }; - - void AddTopMargin(const std::wstring& sTopMargin, const unsigned int& unLevel, const bool& bHardMode = false) - { - if (sTopMargin.empty() || !bPermission || (bImportants[0] && !bHardMode)) - return; - - if (fTopSide == fNoneValue) - fTopSide = 0; - - arLevels[0] = unLevel; - fTopSide += wcstof(sTopMargin.c_str(), NULL); - } - - void AddRightMargin(const std::wstring& sRightMargin, const unsigned int& unLevel, const bool& bHardMode = false) - { - if (sRightMargin.empty() || !bPermission || (bImportants[1] && !bHardMode)) - return; - - if (fRightSide == fNoneValue) - fRightSide = 0; - - arLevels[1] = unLevel; - fRightSide += wcstof(sRightMargin.c_str(), NULL); - } - - void AddBottomMargin(const std::wstring& sBottomMargin, const unsigned int& unLevel, const bool& bHardMode = false) - { - if (sBottomMargin.empty() || !bPermission || (bImportants[2] && !bHardMode)) - return; - - if (fBottomSide == fNoneValue) - fBottomSide = 0; - - arLevels[2] = unLevel; - fBottomSide += wcstof(sBottomMargin.c_str(), NULL); - } - - void AddLeftMargin(const std::wstring& sLeftMargin, const unsigned int& unLevel, const bool& bHardMode = false) - { - if (sLeftMargin.empty() || !bPermission || (bImportants[3] && !bHardMode)) - return; - - if (fLeftSide == fNoneValue) - fLeftSide = 0; - - arLevels[3] = unLevel; - fLeftSide += wcstof(sLeftMargin.c_str(), NULL); - } - - std::wstring GetTopSide() const - { - if (fTopSide == fNoneValue || !bPermission) - return std::wstring(); - - return std::to_wstring(static_cast(fTopSide * 10.0f + 0.5f)); - } - - std::wstring GetRightSide() const - { - if (fTopSide == fNoneValue || !bPermission) - return std::wstring(); - - return (fRightSide >= -128.0f) ? std::to_wstring(static_cast(fRightSide * 10.0f + ((fLeftSide > 0) ? 0.5f : -0.5f))) : L"-1280"; - } - - std::wstring GetBottomSide() const - { - if (fBottomSide == fNoneValue || !bPermission) - return std::wstring(); - - return std::to_wstring(static_cast(fBottomSide * 10.0f + 0.5f)); - } - - std::wstring GetLeftSide() const - { - if (fLeftSide == fNoneValue || !bPermission) - return std::wstring(); - - return (fLeftSide >= -128.0f) ? std::to_wstring(static_cast(fLeftSide * 10.0f + ((fLeftSide > 0) ? 0.5f : -0.5f))) : L"-1280"; - } - }; - - enum class TextDecoration - { - none = 0, - underline, - normal - }; - - enum class TextAlign - { - none = 0, - left, - right, - center, - justify - }; - - class Text - { - float fIndent; - TextAlign enAlign; - TextDecoration enDecoration; - std::wstring sColor; //HEX color - - std::vector bImportants; - std::vector arLevels; - - public: - - Text() : fIndent (fNoneValue), - enAlign (TextAlign::none), - enDecoration (TextDecoration::none), - bImportants ({false, false, false, false}), - arLevels ({0, 0, 0, 0}){} - - void ClearImportants() - { - bImportants = {false, false, false, false}; - } - - Text operator+=(const Text& oText) - { - if (oText.fIndent != fNoneValue) - fIndent = oText.fIndent; - if (oText.enAlign != TextAlign::none) - enAlign = oText.enAlign; - if (oText.enDecoration != TextDecoration::none) - enDecoration = oText.enDecoration; - if (!oText.sColor.empty()) - sColor = oText.sColor; - - bImportants = oText.bImportants; - - return *this; - } - - static void TextEquation(Text &oFirstText, Text &oSecondText) - { - if (oFirstText.bImportants[0] && !oSecondText.bImportants[0] && oFirstText.fIndent != fNoneValue) - oSecondText.fIndent = fNoneValue; - else if (oSecondText.bImportants[0] && !oFirstText.bImportants[0] && oSecondText.fIndent != fNoneValue) - oFirstText.fIndent = fNoneValue; - else if (oFirstText.fIndent != fNoneValue && oSecondText.fIndent != fNoneValue) - { - if (oFirstText.arLevels[0] < oSecondText.arLevels[0]) - oFirstText.fIndent = fNoneValue; - else - oSecondText.fIndent = fNoneValue; - } - - if (oFirstText.bImportants[1] && !oSecondText.bImportants[1] && oFirstText.enAlign != TextAlign::none) - oSecondText.enAlign = TextAlign::none; - else if (oSecondText.bImportants[1] && !oFirstText.bImportants[1] && oSecondText.enAlign != TextAlign::none) - oFirstText.enAlign = TextAlign::none; - else if (oFirstText.enAlign != TextAlign::none && oSecondText.enAlign != TextAlign::none) - { - if (oFirstText.arLevels[1] < oSecondText.arLevels[1]) - oFirstText.enAlign = TextAlign::none; - else - oSecondText.enAlign = TextAlign::none; - } - - if (oFirstText.bImportants[2] && !oSecondText.bImportants[2] && oFirstText.enDecoration != TextDecoration::none) - oSecondText.enDecoration = TextDecoration::none; - else if (oSecondText.bImportants[2] && !oFirstText.bImportants[2] && oSecondText.enDecoration != TextDecoration::none) - oFirstText.enDecoration = TextDecoration::none; - else if (oFirstText.enDecoration != TextDecoration::none && oSecondText.enDecoration != TextDecoration::none) - { - if (oFirstText.arLevels[2] < oSecondText.arLevels[2]) - oFirstText.enDecoration = TextDecoration::none; - else - oSecondText.enDecoration = TextDecoration::none; - } - - if (oFirstText.bImportants[3] && !oSecondText.bImportants[3] && !oFirstText.sColor.empty()) - oSecondText.sColor.clear(); - else if(oSecondText.bImportants[3] && !oFirstText.bImportants[3] && !oSecondText.sColor.empty()) - oFirstText.sColor.clear(); - else if (!oFirstText.sColor.empty() && !oSecondText.sColor.empty()) - { - if (oFirstText.arLevels[3] < oSecondText.arLevels[3]) - oFirstText.sColor.clear(); - else - oSecondText.sColor.clear(); - } - } - - bool operator==(const Text& oText) const - { - return fIndent == oText.fIndent && - enAlign == oText.enAlign && - enDecoration == oText.enDecoration && - sColor == oText.sColor; - } - - bool Empty() const - { - return fIndent == fNoneValue && enAlign == TextAlign::none && - enDecoration == TextDecoration::none && sColor.empty(); - } - - void SetAlign(const std::wstring& sAlign, const unsigned int& unLevel, const bool& bHardMode = false) - { - if (sAlign.empty() || (bImportants[1] && !bHardMode)) - return; - - if (sAlign == L"center") - { - arLevels[1] = unLevel; - enAlign = NSConstValues::NSCssProperties::TextAlign::center; - } - else if(sAlign == L"justify") - { - arLevels[1] = unLevel; - enAlign = NSConstValues::NSCssProperties::TextAlign::justify; - } - else if(sAlign == L"left" || sAlign == L"start") - { - arLevels[1] = unLevel; - enAlign = NSConstValues::NSCssProperties::TextAlign::left; - } - else if(sAlign == L"right" || sAlign == L"end") - { - arLevels[1] = unLevel; - enAlign = NSConstValues::NSCssProperties::TextAlign::right; - } - } - - void SetDecoration(const std::wstring sDecoration, const unsigned int& unLevel, const bool& bHardMode = false) - { - if (sDecoration.empty() || (bImportants[2] && !bHardMode)) - return; - - if (sDecoration == L"underline") - { - arLevels[2] = unLevel; - enDecoration = NSConstValues::NSCssProperties::TextDecoration::underline; - } - else if (sDecoration == L"none") - { - arLevels[2] = unLevel; - enDecoration = NSConstValues::NSCssProperties::TextDecoration::normal; - } - } - - void SetIndent(const std::wstring& sIndent, const unsigned int& unLevel, const bool& bHardMode = false) - { - if (sIndent.empty() || (bImportants[0] && !bHardMode)) - return; - - if (sIndent.find_first_not_of(L" 0") != std::wstring::npos) - { - fIndent = wcstof(sIndent.c_str(), NULL) * 10.0f; - arLevels[0] = unLevel; - } - } - - void SetColor(const std::wstring& sValue, const unsigned int& unLevel, const bool& bHardMode = false) - { - if (sValue.empty() || (bImportants[3] && !bHardMode)) - return; - - if (sValue[0] == L'#') - { - if (sValue.length() == 7) - { - arLevels[3] = unLevel; - sColor = sValue.substr(1, 7); - } - else if (sValue.length() == 4) - { - sColor.clear(); - arLevels[3] = unLevel; - sColor += sValue[1]; - sColor += sValue[1]; - sColor += sValue[2]; - sColor += sValue[2]; - sColor += sValue[3]; - sColor += sValue[3]; - } - } - else if (sValue.substr(0, 3) == L"rgb") - { - const std::wstring sNewColor = NSCSS::NS_STATIC_FUNCTIONS::ConvertRgbToHex(sValue); - if (!sNewColor.empty()) - { - arLevels[3] = unLevel; - sColor = sNewColor; - } - } - else - { - std::wstring sNewColor = sValue; - std::transform(sNewColor.begin(), sNewColor.end(), sNewColor.begin(), towlower); - - const std::map::const_iterator oHEX = NSMaps::mColors.find(sNewColor); - if (oHEX != NSMaps::mColors.end()) - { - arLevels[3] = unLevel; - sColor = oHEX->second; - } - } - } - - void SetImportantAll(const bool& bImportant) - { - if (bImportant) - bImportants = {true, true, true, true}; - else - bImportants = {false, false, false, false}; - } - - void SetImportantIndent(const bool& bImportant) - { - bImportants[0] = bImportant; - } - - void SetImportantAlign(const bool& bImportant) - { - bImportants[1] = bImportant; - } - - void SetImportantDecoration(const bool& bImportant) - { - bImportants[2] = bImportant; - } - - void SetImportantColor(const bool& bImportant) - { - bImportants[3] = bImportant; - } - - std::wstring GetIndentW() const - { - if (fIndent == fNoneValue) - return std::wstring(); - - return std::to_wstring(static_cast(fIndent + ((fIndent > 0.0f) ? 0.5f : -0.5f))); - } - - std::wstring GetAlign() const - { - if (enAlign == TextAlign::left) - return L"left"; - if (enAlign == TextAlign::center) - return L"center"; - if (enAlign == TextAlign::right) - return L"right"; - if (enAlign == TextAlign::justify) - return L"both"; - - return std::wstring(); - } - - std::wstring GetDecoration() const - { - if (enDecoration == TextDecoration::underline) - return L"single"; - else if (enDecoration == TextDecoration::normal) - return L"none"; - - return std::wstring(); - } - - std::wstring GetColor() const - { - return sColor; - } - }; - - enum class BorderStyle - { - none = 0, - single, - dotted, - dashed, - dual, - threeDEmboss, - threeDEngrave, - thinThickMediumGap, - thickThinMediumGap - }; - - class BorderSide - { - float fWidth; - std::wstring sStyle; - std::wstring sColor; //HEX color - - std::vector bImportants; - std::vector arLevels; - - public: - - BorderSide() : fWidth(fNoneValue), - sStyle(L"auto"), - sColor(L"auto"), - bImportants({false, false, false}), - arLevels({0, 0, 0}){} - - void ClearImportants() - { - bImportants = {false, false, false}; - } - - BorderSide operator+=(const BorderSide& oBorderSide) - { - if (oBorderSide.Empty()) - return *this; - - fWidth = oBorderSide.fWidth; - sStyle = oBorderSide.sStyle; - sColor = oBorderSide.sColor; - - bImportants = oBorderSide.bImportants; - arLevels = oBorderSide.arLevels; - - return *this; - } - - static void BorderSideEquation(BorderSide &oFirstBorderSide, BorderSide &oSecondBorderSide) - { - if (oFirstBorderSide.bImportants[0] && !oSecondBorderSide.bImportants[0] && oFirstBorderSide.fWidth != fNoneValue) - oSecondBorderSide.fWidth = fNoneValue; - else if (oSecondBorderSide.bImportants[0] && !oFirstBorderSide.bImportants[0] && oSecondBorderSide.fWidth != fNoneValue) - oFirstBorderSide.fWidth = fNoneValue; - else if (oFirstBorderSide.fWidth != fNoneValue && oSecondBorderSide.fWidth != fNoneValue) - { - if (oFirstBorderSide.arLevels[0] < oSecondBorderSide.arLevels[0]) - oFirstBorderSide.fWidth = fNoneValue; - else - oSecondBorderSide.fWidth = fNoneValue; - } - - if (oFirstBorderSide.bImportants[1] && !oSecondBorderSide.bImportants[1] && !oFirstBorderSide.sStyle.empty()) - oSecondBorderSide.sStyle = L"auto"; - else if (oSecondBorderSide.bImportants[1] && !oFirstBorderSide.bImportants[1] && !oSecondBorderSide.sStyle.empty()) - oFirstBorderSide.sStyle = L"auto"; - else if (!oFirstBorderSide.sStyle.empty() && !oSecondBorderSide.sStyle.empty()) - { - if (oFirstBorderSide.arLevels[1] < oSecondBorderSide.arLevels[1]) - oFirstBorderSide.sStyle = L"auto"; - else - oSecondBorderSide.sStyle = L"auto"; - } - - if (oFirstBorderSide.bImportants[2] && !oSecondBorderSide.bImportants[2] && !oFirstBorderSide.sColor.empty()) - oSecondBorderSide.sColor = L"auto"; - else if (oSecondBorderSide.bImportants[2] && !oFirstBorderSide.bImportants[2] && !oSecondBorderSide.sColor.empty()) - oFirstBorderSide.sColor = L"auto"; - else if (!oFirstBorderSide.sColor.empty() && !oSecondBorderSide.sColor.empty()) - { - if (oFirstBorderSide.arLevels[2] < oSecondBorderSide.arLevels[2]) - oFirstBorderSide.sColor = L"auto"; - else - oSecondBorderSide.sColor = L"auto"; - } - } - - bool operator==(const BorderSide& oBorderSide) const - { - return fWidth == oBorderSide.fWidth && - sStyle == oBorderSide.sStyle && - sColor == oBorderSide.sColor; - } - - bool Empty() const - { - return fWidth <= 0; - } - - void SetWidthWithoutChecking(const float& fWidth, const unsigned int& unLevel, const bool &bHardMode = false) - { - if (bImportants[0] && !bHardMode) - { - arLevels[0] = unLevel; - this->fWidth = fWidth; - } - } - - void SetStyleWithoutChecking(const std::wstring& sStyle, const unsigned int& unLevel, const bool &bHardMode = false) - { - if (bImportants[1] && !bHardMode) - { - arLevels[1] = unLevel; - this->sStyle = sStyle; - } - } - - void SetColorWithoutChecking(const std::wstring& sColor, const unsigned int& unLevel, const bool &bHardMode = false) - { - if (bImportants[2] && !bHardMode) - { - arLevels[2] = unLevel; - this->sColor = sColor; - } - } - - void SetWidth(const float& fWidth, const unsigned int& unLevel, const bool &bHardMode = false) - { - if (fWidth >= 0.0f && bImportants[0] && !bHardMode) - { - arLevels[0] = unLevel; - this->fWidth = fWidth; - } - } - - void SetStyle(const std::wstring& sValue, const unsigned int& unLevel, const bool &bHardMode = false) - { - if (sValue.empty() || (bImportants[1] && !bHardMode)) - return; - - std::wstring sNewValue = sValue; - if (!sNewValue.empty()) - { - std::transform(sNewValue.begin(), sNewValue.end(), sNewValue.begin(), towlower); - - if (sNewValue == L"dotted") - { - arLevels[1] = unLevel; - sStyle = sNewValue; - } - else if (sNewValue == L"dashed") - { - arLevels[1] = unLevel; - sStyle = sNewValue; - } - else if (sNewValue == L"solid") - { - arLevels[1] = unLevel; - sStyle = L"single"; - } - else if (sNewValue == L"double") - { - arLevels[1] = unLevel; - sStyle = L"double"; - } - else if (sNewValue == L"groove") - { - arLevels[1] = unLevel; - sStyle = L"threeDEmboss"; - } - else if (sNewValue == L"ridge") - { - arLevels[1] = unLevel; - sStyle = L"threeDEngrave"; - } - else if (sNewValue == L"inset") - { - arLevels[1] = unLevel; - sStyle = L"thinThickMediumGap"; - } - else if (sNewValue == L"outset") - { - arLevels[1] = unLevel; - sStyle = L"thickThinMediumGap"; - } - } - } - - void SetColor(const std::wstring& sValue, const unsigned int& unLevel, const bool &bHardMode = false) - { - if (sValue.empty() || (bImportants[2] && !bHardMode)) - return; - - if (sValue[0] == L'#') - { - if (sValue.length() == 6) - { - arLevels[2] = unLevel; - sColor = sValue; - } - else if (sValue.length() == 7) - { - arLevels[2] = unLevel; - sColor = sValue.substr(1, 7); - } - else if (sValue.length() == 4) - { - sColor.clear(); - arLevels[2] = unLevel; - sColor += sValue[1]; - sColor += sValue[1]; - sColor += sValue[2]; - sColor += sValue[2]; - sColor += sValue[3]; - sColor += sValue[3]; - } - } - else if (sValue.substr(0, 3) == L"rgb") - { - const std::wstring sNewColor = NSCSS::NS_STATIC_FUNCTIONS::ConvertRgbToHex(sValue); - if (!sNewColor.empty()) - { - arLevels[2] = unLevel; - sColor = sNewColor; - } - } - else - { - std::wstring sNewColor = sValue; - std::transform(sNewColor.begin(), sNewColor.end(), sNewColor.begin(), towlower); - const std::map::const_iterator oHEX = NSMaps::mColors.find(sNewColor); - if (oHEX != NSMaps::mColors.cend()) - { - arLevels[2] = unLevel; - sColor = oHEX->second; - } - } - } - - void SetImportantAll(const bool &bImportant) - { - if (bImportant) - bImportants = {true, true, true}; - else - bImportants = {false, false, false}; - } - - void SetImportantWidth(const bool &bImportant) - { - bImportants[0] = bImportant; - } - - void SetImportantStyle(const bool &bImportant) - { - bImportants[1] = bImportant; - } - - void SetImportantColor(const bool &bImportant) - { - bImportants[2] = bImportant; - } - - bool GetImportantWidth() const - { - return bImportants[0]; - } - - bool GetImportantStyle() const - { - return bImportants[1]; - } - - bool GetImportantColor() const - { - return bImportants[2]; - } - - std::vector GetImportants() const - { - return bImportants; - } - - std::wstring GetStyle() const - { - return sStyle; - } - - std::wstring GetColor() const - { - return sColor; - } - - std::wstring GetWidthW() const - { - if (fWidth < 0) - return L"0"; - - return std::to_wstring(static_cast(fWidth + 0.5f)); - } - - float GetWidth() const - { - return fWidth; - } - - void SetAllLevels(const unsigned int& unLevel) - { - for (size_t i = 0; i < arLevels.size(); ++i) - arLevels[i] = unLevel; - } - - static BorderSide GetCorrectSide(const std::wstring& sValue) - { - if (sValue.empty()) - return BorderSide(); - - const std::vector arValues = NS_STATIC_FUNCTIONS::GetWordsW(sValue, L" "); - BorderSide oBorderSide; - for (std::wstring sValue : arValues) - { - if (sValue[0] == L'#') - { - if (sValue.length() == 7) - oBorderSide.sColor = sValue.substr(1, 7); - else if (sValue.length() == 4) - { - oBorderSide.sColor += sValue[1]; - oBorderSide.sColor += sValue[1]; - oBorderSide.sColor += sValue[2]; - oBorderSide.sColor += sValue[2]; - oBorderSide.sColor += sValue[3]; - oBorderSide.sColor += sValue[3]; - } - } - else if (iswdigit(sValue[0])) - { - const float fWidth = wcstof(sValue.c_str(), NULL); - if (fWidth > 0.0f) - oBorderSide.fWidth = fWidth; - } - else if (sValue.substr(0, 3) == L"rgb") - { - const std::wstring sColor = NSCSS::NS_STATIC_FUNCTIONS::ConvertRgbToHex(sValue); - if (!sColor.empty()) - oBorderSide.sColor = sColor; - } - else - { - std::transform(sValue.begin(), sValue.end(), sValue.begin(), towlower); - - if (sValue == L"dotted") - oBorderSide.sStyle = sValue; - else if (sValue == L"dashed") - oBorderSide.sStyle = sValue; - else if (sValue == L"solid") - oBorderSide.sStyle = L"single"; - else if (sValue == L"double") - oBorderSide.sStyle = L"double"; - else if (sValue == L"groove") - oBorderSide.sStyle = L"threeDEmboss"; - else if (sValue == L"ridge") - oBorderSide.sStyle = L"threeDEngrave"; - else if (sValue == L"inset") - oBorderSide.sStyle = L"thinThickMediumGap"; - else if (sValue == L"outset") - oBorderSide.sStyle = L"thickThinMediumGap"; - else if (sValue == L"none") - oBorderSide.sStyle = L"none"; - else - { - const std::map::const_iterator oHEX = NSMaps::mColors.find(sValue); - if (oHEX != NSMaps::mColors.end()) - oBorderSide.sColor = oHEX->second; - } - } - } - return oBorderSide; - }; - }; - - class Border - { - BorderSide oTop; - BorderSide oRight; - BorderSide oBottom; - BorderSide oLeft; - - public: - - void ClearImportants() - { - oTop.ClearImportants(); - oRight.ClearImportants(); - oBottom.ClearImportants(); - oLeft.ClearImportants(); - } - - Border operator+=(const Border& oBorder) - { - oTop += oBorder.oTop; - oRight += oBorder.oRight; - oBottom += oBorder.oBottom; - oLeft += oBorder.oLeft; - - return *this; - } - - static void BorderEquation(Border &oFirstBorder, Border &oSecondBorder) - { - BorderSide::BorderSideEquation(oFirstBorder.oTop, oSecondBorder.oTop); - BorderSide::BorderSideEquation(oFirstBorder.oRight, oSecondBorder.oRight); - BorderSide::BorderSideEquation(oFirstBorder.oBottom, oSecondBorder.oBottom); - BorderSide::BorderSideEquation(oFirstBorder.oLeft, oSecondBorder.oLeft); - } - - bool operator==(const Border& oBorder) const - { - return oTop == oBorder.oTop && - oRight == oBorder.oRight && - oBottom == oBorder.oBottom && - oLeft == oBorder.oLeft; - } - - bool EqualSides() const - { - return oTop == oRight && - oRight == oBottom && - oBottom == oLeft; - } - - bool Empty() const - { - return oTop.Empty() && oRight.Empty() && oBottom.Empty() && oLeft.Empty(); - } - - void SetTopSide(const BorderSide &oTopSide, const bool& bHardMode = false) - { - if (NS_STATIC_FUNCTIONS::IsTrue(oTop.GetImportants()) && !bHardMode) - return; - - oTop = oTopSide; - } - - void SetRightSide(const BorderSide &oRightSide, const bool& bHardMode = false) - { - if (NS_STATIC_FUNCTIONS::IsTrue(oRight.GetImportants()) && !bHardMode) - return; - - oRight = oRightSide; - } - - void SetBottomSide(const BorderSide &oBottomSide, const bool& bHardMode = false) - { - if (NS_STATIC_FUNCTIONS::IsTrue(oBottom.GetImportants()) && !bHardMode) - return; - - oBottom = oBottomSide; - } - - void SetLeftSide(const BorderSide &oLeftSide, const bool& bHardMode = false) - { - if (NS_STATIC_FUNCTIONS::IsTrue(oLeft.GetImportants()) && !bHardMode) - return; - - oLeft = oLeftSide; - } - - void SetWidth(const float& fValue, const unsigned int& unLevel, const bool &bHardMode = false) - { - if (fValue < 0.0f) - return; - - if ((!oTop.GetImportantWidth() || bHardMode)) - oTop .SetWidthWithoutChecking(fValue, unLevel); - if ((!oRight.GetImportantWidth() || bHardMode)) - oRight .SetWidthWithoutChecking(fValue, unLevel); - if ((!oBottom.GetImportantWidth() || bHardMode)) - oBottom.SetWidthWithoutChecking(fValue, unLevel); - if ((!oLeft.GetImportantWidth() || bHardMode)) - oLeft .SetWidthWithoutChecking(fValue, unLevel); - } - - void SetStyle(const std::wstring& sValue, const unsigned int& unLevel, const bool &bHardMode = false) - { - if (!sValue.empty()) - return; - - std::wstring sNewValue = sValue; - std::transform(sNewValue.begin(), sNewValue.end(), sNewValue.begin(), towlower); - std::wstring sStyle; - - if (sNewValue == L"dotted") - sStyle = sValue; - else if (sNewValue == L"dashed") - sStyle = sValue; - else if (sNewValue == L"solid") - sStyle = L"single"; - else if (sNewValue == L"double") - sStyle = L"double"; - else if (sNewValue == L"groove") - sStyle = L"threeDEmboss"; - else if (sNewValue == L"ridge") - sStyle = L"threeDEngrave"; - else if (sNewValue == L"inset") - sStyle = L"thinThickMediumGap"; - else if (sNewValue == L"outset") - sStyle = L"thickThinMediumGap"; - else - return; - - if ((!oTop.GetImportantStyle() || bHardMode)) - oTop .SetStyleWithoutChecking(sStyle, unLevel); - if ((!oRight.GetImportantStyle() || bHardMode)) - oRight .SetStyleWithoutChecking(sStyle, unLevel); - if ((!oBottom.GetImportantStyle() || bHardMode)) - oBottom.SetStyleWithoutChecking(sStyle, unLevel); - if ((!oLeft.GetImportantStyle() || bHardMode)) - oLeft .SetStyleWithoutChecking(sStyle, unLevel); - } - - void SetColor(const std::wstring& sValue, const unsigned int& unLevel, const bool &bHardMode = false) - { - if (sValue.empty()) - return; - - std::wstring sNewColor; - - if (sValue[0] == L'#') - { - if (sValue.length() == 7) - sNewColor = sValue.substr(1, 7); - else if (sValue.length() == 4) - { - sNewColor.clear(); - sNewColor += sValue[1]; - sNewColor += sValue[1]; - sNewColor += sValue[2]; - sNewColor += sValue[2]; - sNewColor += sValue[3]; - sNewColor += sValue[3]; - } - } - else if (sValue.substr(0, 3) == L"rgb") - { - sNewColor = NSCSS::NS_STATIC_FUNCTIONS::ConvertRgbToHex(sValue); - } - else - { - std::wstring sTempvalue = sValue; - std::transform(sTempvalue.begin(), sTempvalue.end(), sTempvalue.begin(), towlower); - const std::map::const_iterator oHEX = NSMaps::mColors.find(sTempvalue); - if (oHEX != NSMaps::mColors.end()) - sNewColor = oHEX->second; - } - - if (!sNewColor.empty()) - { - if ((!oTop.GetImportantColor() || bHardMode)) - oTop .SetColorWithoutChecking(sNewColor, unLevel); - if ((!oRight.GetImportantColor() || bHardMode)) - oRight .SetColorWithoutChecking(sNewColor, unLevel); - if ((!oBottom.GetImportantColor() || bHardMode)) - oBottom.SetColorWithoutChecking(sNewColor, unLevel); - if ((!oLeft.GetImportantColor() || bHardMode)) - oLeft .SetColorWithoutChecking(sNewColor, unLevel); - } - } - - void SetImportantWidth(const bool& bImportant) - { - oTop.SetImportantWidth(bImportant); - oRight.SetImportantWidth(bImportant); - oBottom.SetImportantWidth(bImportant); - oLeft.SetImportantWidth(bImportant); - } - - void SetImportantWidthTopSide(const bool& bImportant) - { - oTop.SetImportantWidth(bImportant); - } - - void SetImportantWidthRightSide(const bool& bImportant) - { - oRight.SetImportantWidth(bImportant); - } - - void SetImportantWidthBottomSide(const bool& bImportant) - { - oBottom.SetImportantWidth(bImportant); - } - - void SetImportantWidthLeftSide(const bool& bImportant) - { - oLeft.SetImportantWidth(bImportant); - } - - void SetImportantStyle(const bool& bImportant) - { - oTop.SetImportantStyle(bImportant); - oRight.SetImportantStyle(bImportant); - oBottom.SetImportantStyle(bImportant); - oLeft.SetImportantStyle(bImportant); - } - - void SetImportantStyleTopSide(const bool& bImportant) - { - oTop.SetImportantStyle(bImportant); - } - - void SetImportantStyleRightSide(const bool& bImportant) - { - oRight.SetImportantStyle(bImportant); - } - - void SetImportantStyleBottomSide(const bool& bImportant) - { - oBottom.SetImportantStyle(bImportant); - } - - void SetImportantStyleLeftSide(const bool& bImportant) - { - oLeft.SetImportantStyle(bImportant); - } - - void SetImportantColor(const bool &bImportant) - { - oTop.SetImportantColor(bImportant); - oRight.SetImportantColor(bImportant); - oBottom.SetImportantColor(bImportant); - oLeft.SetImportantColor(bImportant); - } - - void SetImportantColorTopSide(const bool& bImportant) - { - oTop.SetImportantColor(bImportant); - } - - void SetImportantColorRightSide(const bool& bImportant) - { - oRight.SetImportantColor(bImportant); - } - - void SetImportantColorBottomSide(const bool& bImportant) - { - oBottom.SetImportantColor(bImportant); - } - - void SetImportantColorLeftSide(const bool& bImportant) - { - oLeft.SetImportantColor(bImportant); - } - - void SetTopSideWidth(const float& fWidth, const unsigned int& unLevel, const bool &bHardMode = false) - { - oTop.SetWidth(fWidth, unLevel, bHardMode); - } - - void SetRightSideWidth(const float& fWidth, const unsigned int& unLevel, const bool &bHardMode = false) - { - oRight.SetWidth(fWidth, unLevel, bHardMode); - } - - void SetBottomSideWidth(const float& fWidth, const unsigned int& unLevel, const bool &bHardMode = false) - { - oBottom.SetWidth(fWidth, unLevel, bHardMode); - } - - void SetLeftSideWidth(const float& fWidth, const unsigned int& unLevel, const bool &bHardMode = false) - { - oLeft.SetWidth(fWidth, unLevel, bHardMode); - } - - void SetTopSideStyle(const std::wstring& sValue, const unsigned int& unLevel, const bool &bHardMode = false) - { - oTop.SetStyle(sValue, unLevel, bHardMode); - } - - void SetRightSideStyle(const std::wstring& sValue, const unsigned int& unLevel, const bool &bHardMode = false) - { - oRight.SetStyle(sValue, unLevel, bHardMode); - } - - void SetBottomSideStyle(const std::wstring& sValue, const unsigned int& unLevel, const bool &bHardMode = false) - { - oBottom.SetStyle(sValue, unLevel, bHardMode); - } - - void SetLeftSideStyle(const std::wstring& sValue, const unsigned int& unLevel, const bool &bHardMode = false) - { - oLeft.SetStyle(sValue, unLevel, bHardMode); - } - - void SetTopSideColor(const std::wstring& sValue, const unsigned int& unLevel, const bool &bHardMode = false) - { - oTop.SetColor(sValue, unLevel, bHardMode); - } - - void SetRightSideColor(const std::wstring& sValue, const unsigned int& unLevel, const bool &bHardMode = false) - { - oRight.SetColor(sValue, unLevel, bHardMode); - } - - void SetBottomSideColor(const std::wstring& sValue, const unsigned int& unLevel, const bool &bHardMode = false) - { - oBottom.SetColor(sValue, unLevel, bHardMode); - } - - void SetLeftSideColor(const std::wstring& sValue, const unsigned int& unLevel, const bool &bHardMode = false) - { - oLeft.SetColor(sValue, unLevel, bHardMode); - } - - - std::wstring GetWidthTopSideW() const - { - return oTop.GetWidthW(); - } - - std::wstring GetStyleTopSide() const - { - return oTop.GetStyle(); - } - - std::wstring GetColorTopSide() const - { - return oTop.GetColor(); - } - - std::wstring GetWidthRightSideW() const - { - return oRight.GetWidthW(); - } - - std::wstring GetStyleRightSide() const - { - return oRight.GetStyle(); - } - - std::wstring GetColorRightSide() const - { - return oRight.GetColor(); - } - - std::wstring GetWidthBottomSideW() const - { - return oBottom.GetWidthW(); - } - - std::wstring GetStyleBottomSide() const - { - return oBottom.GetStyle(); - } - - std::wstring GetColorBottomSide() const - { - return oBottom.GetColor(); - } - - std::wstring GetWidthLeftSideW() const - { - return oLeft.GetWidthW(); - } - - std::wstring GetStyleLeftSide() const - { - return oLeft.GetStyle(); - } - - std::wstring GetColorLeftSide() const - { - return oLeft.GetColor(); - } - - bool EmptyTopSide() const - { - return oTop.Empty(); - } - - bool EmptyRightSide() const - { - return oRight.Empty(); - } - - bool EmptyBottomSide() const - { - return oBottom.Empty(); - } - - bool EmptyLeftSide() const - { - return oLeft.Empty(); - } - - }; - - class Background - { - std::wstring sColor; - - std::vector bImportants; - std::vector arLevels; - public: - - Background() : bImportants({false}), arLevels({0}){} - - void ClearImportants() - { - bImportants = {false}; - } - - - Background operator+=(const Background& oBackground) - { - if (oBackground.sColor.empty()) - sColor = oBackground.sColor; - - return *this; - } - - static void BackgroundEquation(Background &oFirstBackground, Background &oSecondBackground) - { - if (oFirstBackground.bImportants[0] && !oSecondBackground.bImportants[0] && !oFirstBackground.sColor.empty()) - oSecondBackground.sColor.clear(); - else if (oSecondBackground.bImportants[0] && !oFirstBackground.bImportants[0] && !oSecondBackground.sColor.empty()) - oFirstBackground.sColor.clear(); - else if (!oSecondBackground.sColor.empty()) - { - if (oFirstBackground.arLevels[0] < oSecondBackground.arLevels[0]) - oFirstBackground.sColor.clear(); - else - oSecondBackground.sColor.clear(); - } - } - - bool operator==(const Background& oBackground) const - { - return sColor == oBackground.sColor; - } - - bool Empty() const - { - return sColor.empty(); - } - - void SetColor(const std::wstring &sValue, const unsigned int& unLevel, const bool &bHardMode = false) - { - if (sValue.empty() || (bImportants[0] && !bHardMode)) - return; - - if (sValue[0] == L'#') - { - if (sValue.length() == 7) - { - arLevels[0] = unLevel; - sColor = sValue.substr(1, 7); - } - else if (sValue.length() == 4) - { - arLevels[0] = unLevel; - sColor.clear(); - sColor += sValue[1]; - sColor += sValue[1]; - sColor += sValue[2]; - sColor += sValue[2]; - sColor += sValue[3]; - sColor += sValue[3]; - } - } - else if (sValue.substr(0, 3) == L"rgb") - { - const std::wstring sNewColor = NSCSS::NS_STATIC_FUNCTIONS::ConvertRgbToHex(sValue); - if (!sNewColor.empty()) - { - arLevels[0] = unLevel; - sColor = sNewColor; - } - } - else - { - std::wstring sNewColor = sValue; - std::transform(sNewColor.begin(), sNewColor.end(), sNewColor.begin(), towlower); - - if (sNewColor == L"transparent") - return; - - const std::map::const_iterator oHEX = NSMaps::mColors.find(sNewColor); - if (oHEX != NSMaps::mColors.end()) - { - arLevels[0] = unLevel; - sColor = oHEX->second; - } - } - } - - void SetBackground(const std::wstring& sBackground, const unsigned int& unLevel, const bool &bHardMode = false) - { - if (sBackground.empty() || (bImportants[0] && !bHardMode)) - return; - - const std::vector &arValues = NS_STATIC_FUNCTIONS::GetWordsW(sBackground, L" "); - - for (const std::wstring& sValue : arValues) - { - SetColor(sValue, unLevel); - if (!sColor.empty()) - return; - } - } - - void SetImportantAll(const bool &bImportant) - { - if (bImportant) - bImportants = {true}; - else - bImportants = {false}; - } - - void SetImportantBackground(const bool &bImportant) - { - bImportants[0] = bImportant; - } - - std::wstring GetColor() const - { - return sColor; - } - }; - } - + T_TblInd = 0, + // + T_CellTop = 1, + T_CellLeft = 2, + T_CellBottom = 3, + T_CellRight = 4, + // + + // + T_BorderTop = 5, + T_BorderLeft = 6, + T_BorderBottom = 7, + T_BorderRight = 8, + T_BorderInsideH = 9, + T_BorderInsideV = 10 + // + } TableProperties; + + const std::map mStyles { + {L"dotted", L"dotted"}, {L"dashed", L"dashed"}, + {L"solid", L"single"}, {L"double", L"double"}, + {L"groove", L"threeDEmboss"}, {L"ridge", L"threeDEngrave"}, + {L"inset", L"thinThickMediumGap"}, {L"outset", L"thickThinMediumGap"}}; + + const std::map mColors { + /* Red tones */ + {L"indianeed", L"CD5C5C"}, {L"lightcoral", L"F08080"}, {L"salmon", L"FA8072"}, + {L"darksalmon", L"E9967A"}, {L"lightsalmon", L"FFA07A"}, {L"crimson", L"DC143C"}, + {L"red", L"FF0000"}, {L"firebrick", L"B22222"}, {L"darkeed", L"8B0000"}, + /* Pink tones */ + {L"pink", L"FFC0CB"}, {L"lightpink", L"FFB6C1"}, {L"hotpink", L"FF69B4"}, + {L"deeppink", L"FF1493"}, {L"mediumvioletred", L"C71585"}, {L"palevioleteed", L"DB7093"}, + /* Orange tones */ + {L"lightsalmon", L"FFA07A"}, {L"coral", L"FF7F50"}, {L"tomato", L"FF6347"}, + {L"orangered", L"FF4500"}, {L"darkorange", L"FF8C00"}, {L"orange", L"FFA500"}, + /* Yellow tones */ + {L"gold", L"FFD700"}, {L"yellow", L"FFFF00"}, {L"lightyellow", L"FFFFE0"}, + {L"lemonchiffon", L"FFFACD"}, {L"lightgoldenrodyellow", L"FAFAD2"}, {L"papayawhip", L"FFEFD5"}, + {L"moccasin", L"FFE4B5"}, {L"peachpuff", L"FFDAB9"}, {L"palegoldenrod", L"EEE8AA"}, + {L"khaki", L"F0E68C"}, {L"darkkhaki", L"BDB76B"}, + /* Purple tones */ + {L"lavender", L"E6E6FA"}, {L"thistle", L"D8BFD8"}, {L"plum", L"DDA0DD"}, + {L"violet", L"EE82EE"}, {L"orchid", L"DA70D6"}, {L"fuchsia", L"FF00FF"}, + {L"magenta", L"FF00FF"}, {L"mediumorchid", L"BA55D3"}, {L"mediumpurple", L"9370DB"}, + {L"blueviolet", L"8A2BE2"}, {L"darkviolet", L"9400D3"}, {L"darkorchid", L"9932CC"}, + {L"darkmagenta", L"8B008B"}, {L"purple", L"800080"}, {L"indigo", L"4B0082"}, + {L"slateblue", L"6A5ACD"}, {L"darkslateblue", L"483D8B"}, + /* Brown tones */ + {L"cornsilk", L"FFF8DC"}, {L"blanchedalmond", L"FFEBCD"}, {L"bisque", L"FFE4C4"}, + {L"navajowhite", L"FFDEAD"}, {L"wheat", L"F5DEB3"}, {L"burlywood", L"DEB887"}, + {L"tan", L"D2B48C"}, {L"rosybrown", L"BC8F8F"}, {L"sandybrown", L"F4A460"}, + {L"goldenrod", L"DAA520"}, {L"darkgoldenrod", L"B8860B"}, {L"peru", L"CD853F"}, + {L"chocolate", L"D2691E"}, {L"saddlebrown", L"8B4513"}, {L"sienna", L"A0522D"}, + {L"brown", L"A52A2A"}, {L"maroon", L"800000"}, + /* Green tones */ + {L"greenyellow", L"ADFF2F"}, {L"chartreuse", L"7FFF00"}, {L"lawngreen", L"7CFC00"}, + {L"lime", L"00FF00"}, {L"limegreen", L"32CD32"}, {L"palegreen", L"98FB98"}, + {L"lightgreen", L"90EE90"}, {L"mediumspringgreen", L"00FA9A"}, {L"springgreen", L"00FF7F"}, + {L"mediumseagreen", L"3CB371"}, {L"seagreen", L"2E8B57"}, {L"forestgreen", L"228B22"}, + {L"green", L"008000"}, {L"darkgreen", L"006400"}, {L"yellowgreen", L"9ACD32"}, + {L"olivedrab", L"6B8E23"}, {L"olive", L"808000"}, {L"darkolivegreen",L"556B2F"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"}, + {L"mediumaquamarine", L"66CDAA"}, {L"darkseagreen", L"8FBC8F"}, {L"lightseagreen", L"20B2AA"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"}, + {L"darkcyan", L"008B8B"}, {L"teal", L"008080"}, + /* Blue tones */ + {L"aqua", L"00FFFF"}, {L"cyan", L"00FFFF"}, {L"lightcyan", L"E0FFFF"}, + {L"paleturquoise", L"AFEEEE"}, {L"aquamarine", L"7FFFD4"}, {L"turquoise", L"40E0D0"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"}, + {L"mediumturquoise", L"48D1CC"}, {L"darkturquoise", L"00CED1"}, {L"cadetblue", L"5F9EA0"}, + {L"steelblue", L"4682B4"}, {L"lightsteelblue", L"B0C4DE"}, {L"powderblue", L"B0E0E6"}, + {L"lightblue", L"ADD8E6"}, {L"skyblue", L"87CEEB"}, {L"lightskyblue", L"87CEFA"}, + {L"deepskyblue", L"00BFFF"}, {L"dodgerblue", L"1E90FF"}, {L"cornflowerblue",L"6495ED"}, + {L"mediumdlateblue", L"7B68EE"}, {L"royalblue", L"4169E1"}, {L"blue", L"0000FF"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"}, {L"LightCoral", L"#F08080"}, + {L"mediumblue", L"0000CD"}, {L"darkblue", L"00008B"}, {L"navy", L"000080"}, + {L"midnightblue", L"191970"}, + /* White tones */ + {L"white", L"FFFFFF"}, {L"snow", L"FFFAFA"}, {L"honeydew", L"F0FFF0"}, + {L"mintcream", L"F5FFFA"}, {L"azure", L"F0FFFF"}, {L"aliceblue", L"F0F8FF"}, + {L"ghostwhite", L"F8F8FF"}, {L"whitesmoke", L"F5F5F5"}, {L"seashell", L"FFF5EE"}, + {L"beige", L"F5F5DC"}, {L"oldlace", L"FDF5E6"}, {L"floralwhite", L"FFFAF0"}, + {L"ivory", L"FFFFF0"}, {L"antiquewhite", L"FAEBD7"}, {L"linen", L"FAF0E6"}, + {L"lavenderblush", L"FFF0F5"}, {L"mistyrose", L"FFE4E1"}, + /* Gray tones */ + {L"gainsboro", L"DCDCDC"}, {L"lightgrey", L"D3D3D3"}, {L"silver", L"C0C0C0"}, + {L"darkgray", L"A9A9A9"}, {L"gray", L"808080"}, {L"dimgray", L"696969"}, + {L"lightslategray", L"778899"}, {L"slategray", L"708090"}, {L"darkslategray", L"2F4F4F"}, + {L"black", L"000000"}, + /* Outdated */ + {L"windowtext", L"000000"} + }; const std::vector arPseudoClasses { L"invalid", L"read-only", @@ -2530,7 +181,7 @@ namespace NSCSS L"target", L"valid", L"visited"}; -} + } } #endif // CONSTVALUES_H diff --git a/Common/3dParty/html/css/src/StaticFunctions.h b/Common/3dParty/html/css/src/StaticFunctions.h index 7bb68007e3..24f97b5671 100644 --- a/Common/3dParty/html/css/src/StaticFunctions.h +++ b/Common/3dParty/html/css/src/StaticFunctions.h @@ -3,7 +3,9 @@ #include "../../../../../UnicodeConverter/UnicodeConverter.h" #include "../../../../../DesktopEditor/common/File.h" -#include "CNode.h" +#include "CCssCalculator.h" +#include "CssCalculator_global.h" +#include "ConstValues.h" #include #include #include @@ -96,16 +98,16 @@ namespace NSCSS return (posDigit < posNoDigit) || (posDigit == 0 && posNoDigit == 0); } - inline std::wstring StripSymbols(const std::wstring& sValue, const std::wstring& sSymbols = L" \n\r\t\f\v") + inline std::wstring DeleteSpace(const std::wstring& sValue) { if (sValue.empty()) return std::wstring(); - size_t start = sValue.find_first_not_of(sSymbols); + size_t start = sValue.find_first_not_of(L" \n\r\t\f\v"); if (std::wstring::npos == start) return sValue; - size_t end = sValue.find_last_not_of(sSymbols); // точно >=0 + size_t end = sValue.find_last_not_of(L" \n\r\t\f\v"); // точно >=0 return sValue.substr(start, end - start + 1); } @@ -147,24 +149,17 @@ namespace NSCSS return arWords; } - inline bool ConvertAbsoluteValue(std::wstring& sAbsoluteValue, const float &unId) + inline bool ConvertAbsoluteValue(std::wstring& sAbsoluteValue) { if (sAbsoluteValue.empty()) return false; bool bIsConvert = false; - std::map arAbsoluteFontValues = {{L"xx-small", L"9px"}, {L"x-small", L"10px"}, - {L"small", L"13px"}, {L"medium", L"16px"}, - {L"large", L"18px"}, {L"x-large", L"24px"}, - {L"xx-large", L"32px"}}; - - std::map arAbsoluteBorderValues = {{L"thin", L"2px"}, - {L"medium", L"4px"}, - {L"thick", L"6px"}}; - - std::map arAbsoluteValues = ((unId == 0.0f) ? arAbsoluteBorderValues : arAbsoluteFontValues); - + std::map arAbsoluteValues = {{L"xx-small", L"9px"}, {L"x-small", L"10px"}, + {L"small", L"13px"}, {L"medium", L"16px"}, + {L"large", L"18px"}, {L"x-large", L"24px"}, + {L"xx-large", L"32px"}}; if (sAbsoluteValue.find(L' ') == std::wstring::npos && arAbsoluteValues.find(sAbsoluteValue) != arAbsoluteValues.end()) { @@ -324,9 +319,9 @@ namespace NSCSS if (posFirst == std::wstring::npos) return std::wstring(); - const wchar_t cHex[17]{L"0123456789abcdef"}; + const wchar_t cHex[17]{L"0123456789ABCDEF"}; - std::wstring sValue; + std::wstring sValue = L"#"; while (posFirst != std::wstring::npos) { @@ -339,7 +334,7 @@ namespace NSCSS if (nValue < 0) sHex += L"00"; else if (nValue > 255) - sHex += L"ff"; + sHex += L"FF"; else { do @@ -382,7 +377,7 @@ namespace NSCSS { std::wstring sTemp(sSel); sTemp.erase(std::remove_if(sTemp.begin(), sTemp.end(), [] (const wchar_t& wc) { return !std::iswalpha(wc);})); -// std::find(NSConstValues::arPseudoClasses.begin(), NSConstValues::arPseudoClasses.end(), sTemp) != NSConstValues::arPseudoClasses.end() ? ++arWeight[1] : ++arWeight[2]; + std::find(NS_CONST_VALUES::arPseudoClasses.begin(), NS_CONST_VALUES::arPseudoClasses.end(), sTemp) != NS_CONST_VALUES::arPseudoClasses.end() ? ++arWeight[1] : ++arWeight[2]; } else if (sSel.find_last_of(L".[]") != std::wstring::npos) ++arWeight[1]; @@ -393,58 +388,7 @@ namespace NSCSS return arWeight; } - inline bool IsTrue(const std::vector arValues) - { - for (const bool bValue : arValues) - if (!bValue) - return false; - return true; - } - } - - #define SWITCH(str) switch(SWITCH_CASE::str_hash_for_switch(str)) - #define CASE(str) static_assert(SWITCH_CASE::str_is_correct(str) && (SWITCH_CASE::str_len(str) <= SWITCH_CASE::MAX_LEN),\ - "CASE string contains wrong characters, or its length is greater than 9");\ - case SWITCH_CASE::str_hash(str, SWITCH_CASE::str_len(str)) - #define DEFAULT default - - namespace SWITCH_CASE - { - typedef unsigned long long ullong; - - const unsigned int MAX_LEN = 32; - const ullong N_HASH = static_cast(-1); - - constexpr ullong raise_128_to(const wchar_t power) - { - return (1ULL << 7) * power; - } - - constexpr bool str_is_correct(const wchar_t* const str) - { - return (static_cast(*str) > 0) ? str_is_correct(str + 1) : (*str ? false : true); - } - - constexpr unsigned int str_len(const wchar_t* const str) - { - return *str ? (1 + str_len(str + 1)) : 0; - } - - constexpr ullong str_hash(const wchar_t* const str, const wchar_t current_len) - { - return *str ? (raise_128_to(current_len - 1) * static_cast(*str) + str_hash(str + 1, current_len - 1)) : 0; - } - - inline ullong str_hash_for_switch(const wchar_t* const str) - { - return (str_is_correct(str) && (str_len(str) <= MAX_LEN)) ? str_hash(str, str_len(str)) : N_HASH; - } - - inline ullong str_hash_for_switch(const std::wstring& str) - { - return (str_is_correct(str.c_str()) && (str.length() <= MAX_LEN)) ? str_hash(str.c_str(), str.length()) : N_HASH; - } } } diff --git a/Common/3dParty/html/css/src/xhtml/CDocumentStyle.cpp b/Common/3dParty/html/css/src/xhtml/CDocumentStyle.cpp index f3197932f5..3a882f48c7 100644 --- a/Common/3dParty/html/css/src/xhtml/CDocumentStyle.cpp +++ b/Common/3dParty/html/css/src/xhtml/CDocumentStyle.cpp @@ -20,7 +20,7 @@ namespace NSCSS std::wstring CDocumentStyle::GetStyle() const { - return m_sStyle; + return m_sId.empty() ? std::wstring() : m_sStyle; } std::wstring CDocumentStyle::GetIdAndClear() @@ -73,15 +73,15 @@ namespace NSCSS CreateStandardStyle(*iStyleName, oTempElement); if (std::find(m_arStandardStylesUsed.begin(), m_arStandardStylesUsed.end(), *iStyleName) == m_arStandardStylesUsed.end()) { - m_sStyle = oTempElement.GetStyle() + m_sStyle; + m_sStyle += oTempElement.GetStyle(); m_arStandardStylesUsed.push_back(*iStyleName); } oElement += oTempElement; } sId.pop_back(); - oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_Name, sId); - oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_StyleId, sId); + oElement.AddBasicProperties(NS_CONST_VALUES::BasicProperties::B_Name, sId); + oElement.AddBasicProperties(NS_CONST_VALUES::BasicProperties::B_StyleId, sId); } void CDocumentStyle::CreateStandardStyle(const std::wstring& sNameStyle, CXmlElement& oElement) @@ -129,11 +129,11 @@ namespace NSCSS if (!oParentStyle.Empty()) { - oParentStyle.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_StyleId, L"(" + oParentStyle.GetStyleId() + L")"); + oParentStyle.AddBasicProperties(NS_CONST_VALUES::BasicProperties::B_StyleId, L"(" + oParentStyle.GetStyleId() + L")"); if (!bIsPStyle) { - oParentStyle.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_StyleId, oParentStyle.GetStyleId() + L"-c"); - oParentStyle.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_Type, L"character"); + oParentStyle.AddBasicProperties(NS_CONST_VALUES::BasicProperties::B_StyleId, oParentStyle.GetStyleId() + L"-c"); + oParentStyle.AddBasicProperties(NS_CONST_VALUES::BasicProperties::B_Type, L"character"); } } } @@ -149,7 +149,7 @@ namespace NSCSS { if (bIsPStyle) { - oParentStyle.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_QFormat, L"true"); + oParentStyle.AddBasicProperties(NS_CONST_VALUES::BasicProperties::B_QFormat, L"true"); m_sStyle += oParentStyle.GetPStyle(); } else @@ -163,7 +163,7 @@ namespace NSCSS return; } - oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_BasedOn, sParentsStyleID); + oElement.AddBasicProperties(NS_CONST_VALUES::BasicProperties::B_BasedOn, sParentsStyleID); } else if (!oStandardXmlElement.Empty() && !oParentStyle.Empty()) { @@ -175,31 +175,30 @@ namespace NSCSS m_sId = sStandPlusParent; return; } - oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_BasedOn, sStandPlusParent); + oElement.AddBasicProperties(NS_CONST_VALUES::BasicProperties::B_BasedOn, sStandPlusParent); } else { CXmlElement oTempElement = oParentStyle; oTempElement += oStandardXmlElement; - oTempElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_StyleId, sStandPlusParent); + oTempElement.AddBasicProperties(NS_CONST_VALUES::BasicProperties::B_StyleId, sStandPlusParent); if (bIsPStyle) { - oTempElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_QFormat, L"true"); + oTempElement.AddBasicProperties(NS_CONST_VALUES::BasicProperties::B_QFormat, L"true"); m_sStyle += oTempElement.GetPStyle(); } else m_sStyle += oTempElement.GetRStyle(); m_arStandardStylesUsed.push_back(sStandPlusParent); - if (oStyle.Empty()) { m_sId = sStandPlusParent; return; } - oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_BasedOn, oTempElement.GetStyleId()); + oElement.AddBasicProperties(NS_CONST_VALUES::BasicProperties::B_BasedOn, oTempElement.GetStyleId()); } } else if (!oStandardXmlElement.Empty() && oParentStyle.Empty()) @@ -209,7 +208,7 @@ namespace NSCSS { if (bIsPStyle) { - oStandardXmlElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_QFormat, L"true"); + oStandardXmlElement.AddBasicProperties(NS_CONST_VALUES::BasicProperties::B_QFormat, L"true"); m_sStyle += oStandardXmlElement.GetPStyle(); } else @@ -222,7 +221,7 @@ namespace NSCSS m_sId = sStandartStyleID; return; } - oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_BasedOn, sStandartStyleID); + oElement.AddBasicProperties(NS_CONST_VALUES::BasicProperties::B_BasedOn, sStandartStyleID); } if (oStyle.Empty() && oElement.Empty()) @@ -235,149 +234,191 @@ namespace NSCSS if(!bIsPStyle) m_sId += L"-c"; else - oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_QFormat, L"true"); + oElement.AddBasicProperties(NS_CONST_VALUES::BasicProperties::B_QFormat, L"true"); - oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_StyleId, m_sId); - oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_Name, m_sId); - oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_Type, bIsPStyle ? L"paragraph" : L"character"); - oElement.AddBasicProperties(NSConstValues::NSProperties::BasicProperties::B_CustomStyle, L"1"); + oElement.AddBasicProperties(NS_CONST_VALUES::BasicProperties::B_StyleId, m_sId); + oElement.AddBasicProperties(NS_CONST_VALUES::BasicProperties::B_Name, m_sId); + oElement.AddBasicProperties(NS_CONST_VALUES::BasicProperties::B_Type, bIsPStyle ? L"paragraph" : L"character"); + oElement.AddBasicProperties(NS_CONST_VALUES::BasicProperties::B_CustomStyle, L"1"); } void CDocumentStyle::SetPStyle (const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement) { ConvertStyle(oStyle, oXmlElement, true); - if (oStyle.Empty() && oXmlElement.Empty()) + if (oStyle.Empty() || oXmlElement.Empty()) return; - oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_Jc, oStyle.m_pText.GetAlign()); + std::wstring sTextAlign = oStyle.GetTextAlign(); + + if (sTextAlign == L"justify") + sTextAlign = L"both"; + else if (sTextAlign == L"middle") + sTextAlign = L"center"; + else if (sTextAlign != L"left" && sTextAlign != L"center" && sTextAlign != L"right" && sTextAlign != L"both") + sTextAlign.clear(); + + oXmlElement.AddPropertiesInP(NS_CONST_VALUES::ParagraphProperties::P_Jc, sTextAlign); std::wstring sInfValue; sInfValue.reserve(64); - if (!oStyle.m_pMargin.Empty()) + const std::wstring& sTextIndent = oStyle.GetTextIndent(); + if (!sTextIndent.empty() && oStyle.GetId().find(L"table") == std::wstring::npos) { - const std::wstring& sLeftSide = oStyle.m_pMargin.GetLeftSide(); - const std::wstring& sRightSide = oStyle.m_pMargin.GetRightSide(); - - if (!sLeftSide.empty()) - sInfValue += L"w:left=\"" + sLeftSide + L"\" "; - if (!sRightSide.empty()) - sInfValue += L"w:right=\"" + sRightSide + L"\" "; + const float fFirstLineValue = wcstof(sTextIndent.c_str(), NULL) * 10.0f; + sInfValue += L"w:firstLine=\"" + std::to_wstring(static_cast(fFirstLineValue + 0.5f)) + L"\" "; } - const std::wstring& sIndent = oStyle.m_pText.GetIndentW(); - if (!sIndent.empty()) - sInfValue += L"w:firstLine=\"" + sIndent + L"\" "; + const std::vector& sMargins = oStyle.GetMargins(); + if (!sMargins.empty()) + { + const float fLeftValue = wcstof(sMargins[3].c_str(), NULL) * 10.0f; + const float fRightValue = wcstof(sMargins[1].c_str(), NULL) * 10.0f; + sInfValue += L"w:left=\"" + std::to_wstring(static_cast(fLeftValue + 0.5f)) + L"\" "; + sInfValue += L"w:right=\"" + std::to_wstring(static_cast(fRightValue + 0.5f)) + L"\" "; + } - oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_Ind, sInfValue); + oXmlElement.AddPropertiesInP(NS_CONST_VALUES::ParagraphProperties::P_Ind, sInfValue); std::wstring sSpacingValue; sSpacingValue.reserve(128); - if (!oStyle.m_pMargin.Empty()) + if (!sMargins.empty()) { - sSpacingValue += L"w:after=\"" + oStyle.m_pMargin.GetTopSide() + L"\" "; - sSpacingValue += L"w:before=\"" + oStyle.m_pMargin.GetTopSide() + L"\" "; + const float fAfterValue = wcstof(sMargins[0].c_str(), NULL); + const float fBeforeValue = wcstof(sMargins[2].c_str(), NULL); + + sSpacingValue += L"w:after=\"" + std::to_wstring(static_cast((fAfterValue > 0.0f) ? (fAfterValue + 0.5f) : 0.0f)) + L"\" "; + sSpacingValue += L"w:before=\"" + std::to_wstring(static_cast((fBeforeValue > 0.0f) ? (fBeforeValue + 0.5f) : 0.0f)) + L"\" "; } - const std::wstring &sLineHeight = oStyle.m_pFont.GetLineHeight(); + const std::wstring sLineHeight = oStyle.GetLineHeight(); if (!sLineHeight.empty()) { - sSpacingValue += L"w:line=\"" + sLineHeight + L"\" "; - sSpacingValue += L"w:lineRule=\"auto\""; - } + float fValue = wcstof(oStyle.GetFontSize().c_str(), NULL); + if (fValue <= 0.0f) + fValue = NS_CONST_VALUES::FONT_SIZE; + float fLineHeight = wcstof(sLineHeight.c_str(), NULL); + + if (fLineHeight >= 1.0f) + { + fLineHeight *= (fLineHeight < fValue / 2) ? 10.0f : (10.0f / fLineHeight); + float fLine = fLineHeight * fValue; + + sSpacingValue += L"w:line=\"" + std::to_wstring(static_cast((fLine < fValue * 20.0f) ? fLine : fValue * 5.0f + 0.5f)) + L"\" "; + sSpacingValue += L"w:lineRule=\"auto\""; + } + } if (!sSpacingValue.empty()) { - oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_Spacing, sSpacingValue); - oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_ContextualSpacing, L"true"); + oXmlElement.AddPropertiesInP(NS_CONST_VALUES::ParagraphProperties::P_Spacing, sSpacingValue); + oXmlElement.AddPropertiesInP(NS_CONST_VALUES::ParagraphProperties::P_ContextualSpacing, L"true"); } - oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_Shd, oStyle.m_pBackground.GetColor()); + oXmlElement.AddPropertiesInP(NS_CONST_VALUES::ParagraphProperties::P_Shd, oStyle.GetBackgroundColor()); - if (!oStyle.m_pBorder.Empty()) +// if (!oStyle.GetBorder().empty() && oStyle.GetBorder() != L"none") + + const std::wstring sBorderColor = oStyle.GetBorderColor(); + const std::wstring sBorderStyle = oStyle.GetBorderStyle(); + const float fValue = wcstof(oStyle.GetBorderWidth().c_str(), NULL) * 4.0f; + const std::wstring sBorderWidth = std::to_wstring(static_cast(fValue + 0.5f)); + if (!sBorderColor.empty() && !sBorderWidth.empty() && !sBorderStyle.empty()) { - if (oStyle.m_pBorder.EqualSides()) - { - const std::wstring sBorderColor = oStyle.m_pBorder.GetColorBottomSide(); - const std::wstring sBorderStyle = oStyle.m_pBorder.GetStyleBottomSide(); - const std::wstring sBorderWidth = oStyle.m_pBorder.GetWidthBottomSideW(); + const std::wstring sBorder = L" w:color=\"" + sBorderColor + L"\" w:space=\"4\" w:sz=\"" + + sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\""; - const std::wstring sBorder = L" w:color=\"" + sBorderColor + L"\" w:space=\"4\" w:sz=\"" + - sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\""; + oXmlElement.AddPropertiesInP(NS_CONST_VALUES::ParagraphProperties::P_TopBorder, sBorder); + oXmlElement.AddPropertiesInP(NS_CONST_VALUES::ParagraphProperties::P_LeftBorder, sBorder); + oXmlElement.AddPropertiesInP(NS_CONST_VALUES::ParagraphProperties::P_BottomBorder, sBorder); + oXmlElement.AddPropertiesInP(NS_CONST_VALUES::ParagraphProperties::P_RightBorder, sBorder); - oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_TopBorder, sBorder); - oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_LeftBorder, sBorder); - oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_BottomBorder, sBorder); - oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_RightBorder, sBorder); - } - else - { - if (!oStyle.m_pBorder.EmptyTopSide()) - { - const std::wstring sBorderColor = oStyle.m_pBorder.GetColorTopSide(); - const std::wstring sBorderStyle = oStyle.m_pBorder.GetStyleTopSide(); - const std::wstring sBorderWidth = oStyle.m_pBorder.GetWidthTopSideW(); - - const std::wstring sBorder = L" w:color=\"" + sBorderColor + L"\" w:space=\"4\" w:sz=\"" + - sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\""; - - oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_TopBorder, sBorder); - } - - if (!oStyle.m_pBorder.EmptyRightSide()) - { - const std::wstring sBorderColor = oStyle.m_pBorder.GetColorRightSide(); - const std::wstring sBorderStyle = oStyle.m_pBorder.GetStyleRightSide(); - const std::wstring sBorderWidth = oStyle.m_pBorder.GetWidthRightSideW(); - - const std::wstring sBorder = L" w:color=\"" + sBorderColor + L"\" w:space=\"4\" w:sz=\"" + - sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\""; - - oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_RightBorder, sBorder); - } - - if (!oStyle.m_pBorder.EmptyBottomSide()) - { - const std::wstring sBorderColor = oStyle.m_pBorder.GetColorBottomSide(); - const std::wstring sBorderStyle = oStyle.m_pBorder.GetStyleBottomSide(); - const std::wstring sBorderWidth = oStyle.m_pBorder.GetWidthBottomSideW(); - - const std::wstring sBorder = L" w:color=\"" + sBorderColor + L"\" w:space=\"4\" w:sz=\"" + - sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\""; - - oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_BottomBorder, sBorder); - } - - if (!oStyle.m_pBorder.EmptyLeftSide()) - { - const std::wstring sBorderColor = oStyle.m_pBorder.GetColorLeftSide(); - const std::wstring sBorderStyle = oStyle.m_pBorder.GetStyleLeftSide(); - const std::wstring sBorderWidth = oStyle.m_pBorder.GetWidthLeftSideW(); - - const std::wstring sBorder = L" w:color=\"" + sBorderColor + L"\" w:space=\"4\" w:sz=\"" + - sBorderWidth + L"\" w:val=\"" + sBorderStyle + L"\""; - - oXmlElement.AddPropertiesInP(NSConstValues::NSProperties::ParagraphProperties::P_LeftBorder, sBorder); - } - } + return; } + + const std::wstring sBorderTopColor = oStyle.GetBorderTopColor(); + const std::wstring sBorderTopStyle = oStyle.GetBorderTopStyle(); + const float fValueTop = wcstof(oStyle.GetBorderTopWidth().c_str(), NULL) * 4.0f; + const std::wstring sBorderTopWidth = std::to_wstring(static_cast(fValueTop + 0.5f)); + if (!sBorderTopColor.empty() && !sBorderTopWidth.empty() && !sBorderTopStyle.empty()) + oXmlElement.AddPropertiesInP(NS_CONST_VALUES::ParagraphProperties::P_TopBorder, + L" w:color=\"" + sBorderTopColor + L"\" w:space=\"4\" w:sz=\"" + + sBorderTopWidth + L"\" w:val=\"" + sBorderTopStyle + L"\""); + + const std::wstring sBorderLeftColor = oStyle.GetBorderLeftColor(); + const std::wstring sBorderLeftStyle = oStyle.GetBorderLeftStyle(); + const float fValueLeft = wcstof(oStyle.GetBorderLeftWidth().c_str(), NULL) * 4.0f; + const std::wstring sBorderLeftWidth = std::to_wstring(static_cast(fValueLeft + 0.5f)); + if (!sBorderLeftColor.empty() && !sBorderLeftWidth.empty() && !sBorderLeftStyle.empty()) + oXmlElement.AddPropertiesInP(NS_CONST_VALUES::ParagraphProperties::P_LeftBorder, + L" w:color=\"" + sBorderLeftColor + L"\" w:space=\"4\" w:sz=\"" + + sBorderLeftWidth + L"\" w:val=\"" + sBorderLeftStyle + L"\""); + + const std::wstring sBorderBottomColor = oStyle.GetBorderBottomColor(); + const std::wstring sBorderBottomStyle = oStyle.GetBorderBottomStyle(); + const float fValueBottom = wcstof(oStyle.GetBorderBottomWidth().c_str(), NULL) * 4.0f; + const std::wstring sBorderBottomWidth = std::to_wstring(static_cast(fValueBottom + 0.5f)); + if (!sBorderBottomColor.empty() && !sBorderBottomWidth.empty() && !sBorderBottomStyle.empty()) + oXmlElement.AddPropertiesInP(NS_CONST_VALUES::ParagraphProperties::P_BottomBorder, + L" w:color=\"" + sBorderBottomColor + L"\" w:space=\"4\" w:sz=\"" + + sBorderBottomWidth + L"\" w:val=\"" + sBorderBottomStyle + L"\""); + + const std::wstring sBorderRightColor = oStyle.GetBorderRightColor(); + const std::wstring sBorderRightStyle = oStyle.GetBorderRightStyle(); + const float fValueRight = wcstof(oStyle.GetBorderRightWidth().c_str(), NULL) * 4.0f; + const std::wstring sBorderRightWidth = std::to_wstring(static_cast(fValueRight + 0.5f)); + if (!sBorderRightColor.empty() && !sBorderRightWidth.empty() && !sBorderRightStyle.empty()) + oXmlElement.AddPropertiesInP(NS_CONST_VALUES::ParagraphProperties::P_RightBorder, + L" w:color=\"" + sBorderRightColor + L"\" w:space=\"4\" w:sz=\"" + + sBorderRightWidth + L"\" w:val=\"" + sBorderRightStyle + L"\""); + } void CDocumentStyle::SetRStyle (const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement) { ConvertStyle(oStyle, oXmlElement, false); - if (oStyle.Empty() && oXmlElement.Empty()) + if (oStyle.Empty() || oXmlElement.Empty()) return; - oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_Color, oStyle.m_pText.GetColor()); - oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_Shd, oStyle.m_pBackground.GetColor()); - oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_U, oStyle.m_pText.GetDecoration()); - oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_Sz, oStyle.m_pFont.GetSizeW()); - oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_RFonts, oStyle.m_pFont.GetFamily()); - oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_I, oStyle.m_pFont.GetStyle()); - oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_B, oStyle.m_pFont.GetWeight()); - oXmlElement.AddPropertiesInR(NSConstValues::NSProperties::RunnerProperties::R_SmallCaps, oStyle.m_pFont.GetVariant()); + oXmlElement.AddPropertiesInR(NS_CONST_VALUES::RunnerProperties::R_Color, oStyle.GetColor()); + oXmlElement.AddPropertiesInR(NS_CONST_VALUES::RunnerProperties::R_Shd, oStyle.GetBackgroundColor()); + oXmlElement.AddPropertiesInR(NS_CONST_VALUES::RunnerProperties::R_U, oStyle.GetTextDecoration()); + + const std::wstring sFontSize = oStyle.GetFontSize(); + if (!sFontSize.empty()) + { + const float fValue = wcstof(sFontSize.c_str(), NULL); + oXmlElement.AddPropertiesInR(NS_CONST_VALUES::RunnerProperties::R_Sz, std::to_wstring(static_cast((fValue > 0.0f) ? fValue : NS_CONST_VALUES::FONT_SIZE))); + } + + const std::wstring sFontFamily = oStyle.GetFontFamily(); + if (!sFontFamily.empty()) + oXmlElement.AddPropertiesInR(NS_CONST_VALUES::RunnerProperties::R_RFonts, sFontFamily); + + const std::wstring sFontWeight = oStyle.GetFontWeight(); + + if (sFontWeight == L"bold") + oXmlElement.AddPropertiesInR(NS_CONST_VALUES::RunnerProperties::R_B, L"true"); + else if (sFontWeight == L"normal") + oXmlElement.AddPropertiesInR(NS_CONST_VALUES::RunnerProperties::R_B, L"false"); + + if (oStyle.GetFontStyle() == L"italic") + oXmlElement.AddPropertiesInR(NS_CONST_VALUES::RunnerProperties::R_I, L"true"); + else if (oStyle.GetFontStyle() == L"normal") + oXmlElement.AddPropertiesInR(NS_CONST_VALUES::RunnerProperties::R_I, L"false"); + + std::wstring sSpacingValue; + const std::vector sMargins = oStyle.GetMargins(); + if (!sMargins.empty()) + { + const float fAfterValue = wcstof(sMargins[0].c_str(), NULL) * 10.0f; + const float fBeforeValue = wcstof(sMargins[2].c_str(), NULL) * 10.0f; + sSpacingValue += L"w:after=\"" + std::to_wstring(static_cast(fAfterValue + 0.5f)) + L"\" "; + sSpacingValue += L"w:before=\"" + std::to_wstring(static_cast(fBeforeValue + 0.5f)) + L"\" "; + } + + // spacing в rPr } void CDocumentStyle::WriteRStyle (const NSCSS::CCompiledStyle& oStyle) @@ -408,30 +449,6 @@ namespace NSCSS } } - void CDocumentStyle::WriteLitePStyle(const CCompiledStyle &oStyle) - { - if (oStyle.Empty()) - return; - - CXmlElement oXmlElement; - SetPStyle(oStyle, oXmlElement); - - if (!oXmlElement.Empty()) - m_sStyle += oXmlElement.GetLitePStyle(); - } - - void CDocumentStyle::WriteLiteRStyle(const CCompiledStyle &oStyle) - { - if (oStyle.Empty()) - return; - - CXmlElement oXmlElement; - SetRStyle(oStyle, oXmlElement); - - if (!oXmlElement.Empty()) - m_sStyle += oXmlElement.GetLiteRStyle(); - } - void CDocumentStyle::WritePStyle (const NSCSS::CCompiledStyle& oStyle) { if(oStyle.GetId().empty()) diff --git a/Common/3dParty/html/css/src/xhtml/CDocumentStyle.h b/Common/3dParty/html/css/src/xhtml/CDocumentStyle.h index 9017351c25..fbec6d4fa0 100644 --- a/Common/3dParty/html/css/src/xhtml/CDocumentStyle.h +++ b/Common/3dParty/html/css/src/xhtml/CDocumentStyle.h @@ -32,6 +32,12 @@ namespace NSCSS m_sId = sId; } + /* + bool operator<(const CStyleUsed& oUsedStyle) const + { + return m_oStyle < oUsedStyle.m_oStyle; + } + */ }; class CSSCALCULATOR_EXPORT CDocumentStyle @@ -56,8 +62,6 @@ namespace NSCSS void WritePStyle(const NSCSS::CCompiledStyle& oStyle); void WriteRStyle(const NSCSS::CCompiledStyle& oStyle); - void WriteLitePStyle(const NSCSS::CCompiledStyle& oStyle); - void WriteLiteRStyle(const NSCSS::CCompiledStyle& oStyle); void SetStyle(const std::wstring& sStyle); void SetId (const std::wstring& sId); diff --git a/Common/3dParty/html/css/src/xhtml/CXmlElement.cpp b/Common/3dParty/html/css/src/xhtml/CXmlElement.cpp index 9b1f76cf19..7e3460a04d 100644 --- a/Common/3dParty/html/css/src/xhtml/CXmlElement.cpp +++ b/Common/3dParty/html/css/src/xhtml/CXmlElement.cpp @@ -36,221 +36,233 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement) if (sNameDefaultElement == L"li") { - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Type, L"paragraph"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_StyleId, L"li"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Name, L"List Paragraph"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_BasedOn, L"normal"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_UiPriority, L"34"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Type, L"paragraph"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_StyleId, L"li"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Name, L"List Paragraph"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_BasedOn, L"normal"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_UiPriority, L"34"); - AddPropertiesInP(NSCSS::NSConstValues::NSProperties::ParagraphProperties::P_ContextualSpacing, L"true"); - AddPropertiesInP(NSCSS::NSConstValues::NSProperties::ParagraphProperties::P_Ind, L"w:left=\"720\""); + AddPropertiesInP(NSCSS::NS_CONST_VALUES::ParagraphProperties::P_ContextualSpacing, L"true"); + AddPropertiesInP(NSCSS::NS_CONST_VALUES::ParagraphProperties::P_Ind, L"w:left=\"720\""); } else if (sNameDefaultElement == L"h1") { - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Type, L"paragraph"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_StyleId, L"h1"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Name, L"Heading 1"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_BasedOn, L"normal"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Link, L"h1-c"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Type, L"paragraph"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_StyleId, L"h1"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Name, L"Heading 1"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_BasedOn, L"normal"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Link, L"h1-c"); - AddPropertiesInP(NSCSS::NSConstValues::NSProperties::ParagraphProperties::P_OutlineLvl, L"0"); - AddPropertiesInP(NSCSS::NSConstValues::NSProperties::ParagraphProperties::P_Spacing, L"w:after=\"0\" w:before=\"480\""); + AddPropertiesInP(NSCSS::NS_CONST_VALUES::ParagraphProperties::P_OutlineLvl, L"0"); + AddPropertiesInP(NSCSS::NS_CONST_VALUES::ParagraphProperties::P_Spacing, L"w:after=\"0\" w:before=\"480\""); } else if (sNameDefaultElement == L"h2") { - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Type, L"paragraph"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_StyleId, L"h2"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Name, L"Heading 2"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_BasedOn, L"normal"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Link, L"h2-c"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Type, L"paragraph"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_StyleId, L"h2"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Name, L"Heading 2"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_BasedOn, L"normal"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Link, L"h2-c"); - AddPropertiesInP(NSCSS::NSConstValues::NSProperties::ParagraphProperties::P_OutlineLvl, L"1"); - AddPropertiesInP(NSCSS::NSConstValues::NSProperties::ParagraphProperties::P_Spacing, L"w:after=\"0\" w:before=\"400\""); + AddPropertiesInP(NSCSS::NS_CONST_VALUES::ParagraphProperties::P_OutlineLvl, L"1"); + AddPropertiesInP(NSCSS::NS_CONST_VALUES::ParagraphProperties::P_Spacing, L"w:after=\"0\" w:before=\"400\""); } else if (sNameDefaultElement == L"h3") { - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Type, L"paragraph"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_StyleId, L"h3"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Name, L"Heading 3"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_BasedOn, L"normal"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Link, L"h3-c"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Type, L"paragraph"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_StyleId, L"h3"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Name, L"Heading 3"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_BasedOn, L"normal"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Link, L"h3-c"); - AddPropertiesInP(NSCSS::NSConstValues::NSProperties::ParagraphProperties::P_OutlineLvl, L"2"); - AddPropertiesInP(NSCSS::NSConstValues::NSProperties::ParagraphProperties::P_Spacing, L"w:after=\"0\" w:before=\"360\""); + AddPropertiesInP(NSCSS::NS_CONST_VALUES::ParagraphProperties::P_OutlineLvl, L"2"); + AddPropertiesInP(NSCSS::NS_CONST_VALUES::ParagraphProperties::P_Spacing, L"w:after=\"0\" w:before=\"360\""); } else if (sNameDefaultElement == L"h4") { - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Type, L"paragraph"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_StyleId, L"h4"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Name, L"Heading 4"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_BasedOn, L"normal"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Link, L"h4-c"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Type, L"paragraph"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_StyleId, L"h4"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Name, L"Heading 4"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_BasedOn, L"normal"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Link, L"h4-c"); - AddPropertiesInP(NSCSS::NSConstValues::NSProperties::ParagraphProperties::P_OutlineLvl, L"3"); - AddPropertiesInP(NSCSS::NSConstValues::NSProperties::ParagraphProperties::P_Spacing, L"w:after=\"0\" w:before=\"320\""); + AddPropertiesInP(NSCSS::NS_CONST_VALUES::ParagraphProperties::P_OutlineLvl, L"3"); + AddPropertiesInP(NSCSS::NS_CONST_VALUES::ParagraphProperties::P_Spacing, L"w:after=\"0\" w:before=\"320\""); } else if (sNameDefaultElement == L"h5") { - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Type, L"paragraph"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_StyleId, L"h5"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Name, L"Heading 5"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_BasedOn, L"normal"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Link, L"h5-c"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Type, L"paragraph"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_StyleId, L"h5"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Name, L"Heading 5"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_BasedOn, L"normal"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Link, L"h5-c"); - AddPropertiesInP(NSCSS::NSConstValues::NSProperties::ParagraphProperties::P_OutlineLvl, L"4"); - AddPropertiesInP(NSCSS::NSConstValues::NSProperties::ParagraphProperties::P_Spacing, L"w:after=\"0\" w:before=\"280\""); + AddPropertiesInP(NSCSS::NS_CONST_VALUES::ParagraphProperties::P_OutlineLvl, L"4"); + AddPropertiesInP(NSCSS::NS_CONST_VALUES::ParagraphProperties::P_Spacing, L"w:after=\"0\" w:before=\"280\""); } else if (sNameDefaultElement == L"h6") { - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Type, L"paragraph"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_StyleId, L"h6"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Name, L"Heading 6"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_BasedOn, L"normal"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Link, L"h6-c"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Type, L"paragraph"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_StyleId, L"h6"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Name, L"Heading 6"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_BasedOn, L"normal"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Link, L"h6-c"); - AddPropertiesInP(NSCSS::NSConstValues::NSProperties::ParagraphProperties::P_OutlineLvl, L"5"); - AddPropertiesInP(NSCSS::NSConstValues::NSProperties::ParagraphProperties::P_Spacing, L"w:after=\"0\" w:before=\"280\""); + AddPropertiesInP(NSCSS::NS_CONST_VALUES::ParagraphProperties::P_OutlineLvl, L"5"); + AddPropertiesInP(NSCSS::NS_CONST_VALUES::ParagraphProperties::P_Spacing, L"w:after=\"0\" w:before=\"280\""); } else if (sNameDefaultElement == L"h1-c") { - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Type, L"character"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_StyleId, L"h1-c"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Name, L"Title 1 Sign"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_CustomStyle, L"1"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_UiPriority, L"9"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Link, L"h1"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Type, L"character"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_StyleId, L"h1-c"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Name, L"Title 1 Sign"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_CustomStyle, L"1"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_UiPriority, L"9"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Link, L"h1"); - AddPropertiesInR(NSCSS::NSConstValues::NSProperties::RunnerProperties::R_RFonts, L"\"Arial\""); - AddPropertiesInR(NSCSS::NSConstValues::NSProperties::RunnerProperties::R_B, L"bold"); - AddPropertiesInR(NSCSS::NSConstValues::NSProperties::RunnerProperties::R_Sz, L"44"); + AddPropertiesInR(NSCSS::NS_CONST_VALUES::RunnerProperties::R_RFonts, L"\"Arial\""); + AddPropertiesInR(NSCSS::NS_CONST_VALUES::RunnerProperties::R_B, L"true"); + AddPropertiesInR(NSCSS::NS_CONST_VALUES::RunnerProperties::R_Color, L"000000"); + AddPropertiesInR(NSCSS::NS_CONST_VALUES::RunnerProperties::R_Sz, L"48"); } else if (sNameDefaultElement == L"h2-c") { - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Type, L"character"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_StyleId, L"h2-c"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Name, L"Title 2 Sign"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_CustomStyle, L"1"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_UiPriority, L"9"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_UnhideWhenUsed, L"true"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Link, L"h2"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Type, L"character"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_StyleId, L"h2-c"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Name, L"Title 2 Sign"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_CustomStyle, L"1"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_UiPriority, L"9"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_UnhideWhenUsed, L"true"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Link, L"h2"); - AddPropertiesInR(NSCSS::NSConstValues::NSProperties::RunnerProperties::R_RFonts, L"\"Arial\""); - AddPropertiesInR(NSCSS::NSConstValues::NSProperties::RunnerProperties::R_B, L"bold"); - AddPropertiesInR(NSCSS::NSConstValues::NSProperties::RunnerProperties::R_Sz, L"33"); + AddPropertiesInR(NSCSS::NS_CONST_VALUES::RunnerProperties::R_RFonts, L"\"Arial\""); + AddPropertiesInR(NSCSS::NS_CONST_VALUES::RunnerProperties::R_B, L"true"); + AddPropertiesInR(NSCSS::NS_CONST_VALUES::RunnerProperties::R_Color, L"000000"); + AddPropertiesInR(NSCSS::NS_CONST_VALUES::RunnerProperties::R_Sz, L"40"); } else if (sNameDefaultElement == L"h3-c") { - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Type, L"character"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_StyleId, L"h3-c"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Name, L"Title 3 Sign"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_CustomStyle, L"1"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_UiPriority, L"9"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_UnhideWhenUsed, L"true"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Link, L"h3"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Type, L"character"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_StyleId, L"h3-c"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Name, L"Title 3 Sign"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_CustomStyle, L"1"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_UiPriority, L"9"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_UnhideWhenUsed, L"true"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Link, L"h3"); - AddPropertiesInR(NSCSS::NSConstValues::NSProperties::RunnerProperties::R_RFonts, L"\"Arial\""); - AddPropertiesInR(NSCSS::NSConstValues::NSProperties::RunnerProperties::R_B, L"bold"); - AddPropertiesInR(NSCSS::NSConstValues::NSProperties::RunnerProperties::R_Sz, L"26"); + AddPropertiesInR(NSCSS::NS_CONST_VALUES::RunnerProperties::R_RFonts, L"\"Arial\""); + AddPropertiesInR(NSCSS::NS_CONST_VALUES::RunnerProperties::R_B, L"true"); + AddPropertiesInR(NSCSS::NS_CONST_VALUES::RunnerProperties::R_Color, L"000000"); + AddPropertiesInR(NSCSS::NS_CONST_VALUES::RunnerProperties::R_Sz, L"36"); } else if (sNameDefaultElement == L"h4-c") { - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Type, L"character"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_StyleId, L"h4-c"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Name, L"Title 4 Sign"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_CustomStyle, L"1"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_UiPriority, L"9"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_UnhideWhenUsed, L"true"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Link, L"h4"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Type, L"character"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_StyleId, L"h4-c"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Name, L"Title 4 Sign"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_CustomStyle, L"1"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_UiPriority, L"9"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_UnhideWhenUsed, L"true"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Link, L"h4"); - AddPropertiesInR(NSCSS::NSConstValues::NSProperties::RunnerProperties::R_RFonts, L"\"Arial\""); - AddPropertiesInR(NSCSS::NSConstValues::NSProperties::RunnerProperties::R_B, L"bold"); - AddPropertiesInR(NSCSS::NSConstValues::NSProperties::RunnerProperties::R_Sz, L"22"); + AddPropertiesInR(NSCSS::NS_CONST_VALUES::RunnerProperties::R_RFonts, L"\"Arial\""); + AddPropertiesInR(NSCSS::NS_CONST_VALUES::RunnerProperties::R_B, L"true"); +// AddPropertiesInR(NSCSS::NS_CONST_VALUES::RunnerProperties::R_Color, L"232323"); + AddPropertiesInR(NSCSS::NS_CONST_VALUES::RunnerProperties::R_Sz, L"32"); } else if (sNameDefaultElement == L"h5-c") { - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Type, L"character"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_StyleId, L"h5-c"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Name, L"Title 5 Sign"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_CustomStyle, L"1"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_UiPriority, L"9"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_UnhideWhenUsed, L"true"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Link, L"h5"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Type, L"character"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_StyleId, L"h5-c"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Name, L"Title 5 Sign"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_CustomStyle, L"1"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_UiPriority, L"9"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_UnhideWhenUsed, L"true"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Link, L"h5"); - AddPropertiesInR(NSCSS::NSConstValues::NSProperties::RunnerProperties::R_RFonts, L"\"Arial\""); - AddPropertiesInR(NSCSS::NSConstValues::NSProperties::RunnerProperties::R_B, L"bold"); - AddPropertiesInR(NSCSS::NSConstValues::NSProperties::RunnerProperties::R_Sz, L"18"); + AddPropertiesInR(NSCSS::NS_CONST_VALUES::RunnerProperties::R_RFonts, L"\"Arial\""); + AddPropertiesInR(NSCSS::NS_CONST_VALUES::RunnerProperties::R_B, L"true"); + AddPropertiesInR(NSCSS::NS_CONST_VALUES::RunnerProperties::R_Color, L"444444"); + AddPropertiesInR(NSCSS::NS_CONST_VALUES::RunnerProperties::R_Sz, L"28"); } else if (sNameDefaultElement == L"h6-c") { - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Type, L"character"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_StyleId, L"h6-c"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Name, L"Title 6 Sign"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_CustomStyle, L"1"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_UiPriority, L"9"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_UnhideWhenUsed, L"true"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Link, L"h6"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Type, L"character"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_StyleId, L"h6-c"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Name, L"Title 6 Sign"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_CustomStyle, L"1"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_UiPriority, L"9"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_UnhideWhenUsed, L"true"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Link, L"h6"); - AddPropertiesInR(NSCSS::NSConstValues::NSProperties::RunnerProperties::R_RFonts, L"\"Arial\""); - AddPropertiesInR(NSCSS::NSConstValues::NSProperties::RunnerProperties::R_B, L"bold"); - AddPropertiesInR(NSCSS::NSConstValues::NSProperties::RunnerProperties::R_Sz, L"15"); + AddPropertiesInR(NSCSS::NS_CONST_VALUES::RunnerProperties::R_RFonts, L"\"Arial\""); + AddPropertiesInR(NSCSS::NS_CONST_VALUES::RunnerProperties::R_B, L"true"); + AddPropertiesInR(NSCSS::NS_CONST_VALUES::RunnerProperties::R_I, L"true"); + AddPropertiesInR(NSCSS::NS_CONST_VALUES::RunnerProperties::R_Color, L"232323"); + AddPropertiesInR(NSCSS::NS_CONST_VALUES::RunnerProperties::R_Sz, L"24"); } else if (sNameDefaultElement == L"p-c") { - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Type, L"character"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_StyleId, L"p-c"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_CustomStyle, L"1"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Name, L"Paragraph character"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Link, L"p"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Type, L"character"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_StyleId, L"p-c"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_CustomStyle, L"1"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Name, L"Paragraph character"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Link, L"p"); - AddPropertiesInR(NSCSS::NSConstValues::NSProperties::RunnerProperties::R_RFonts, L"\"Arial\""); + AddPropertiesInR(NSCSS::NS_CONST_VALUES::RunnerProperties::R_RFonts, L"\"Arial\""); } else if (sNameDefaultElement == L"p") { - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Type, L"paragraph"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_StyleId, L"p"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_CustomStyle, L"1"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Name, L"Paragraph"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_BasedOn, L"normal"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Link, L"p-c"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Type, L"paragraph"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_StyleId, L"p"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_CustomStyle, L"1"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Name, L"Paragraph"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_BasedOn, L"normal"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Link, L"p-c"); +// SetInd(L"w:firstLine=\"567\""); +// SetJc(L"both"); } else if (sNameDefaultElement == L"div-c") { - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Type, L"character"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_StyleId, L"div-c"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_CustomStyle, L"1"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Name, L"Div character"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Link, L"div"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Type, L"character"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_StyleId, L"div-c"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_CustomStyle, L"1"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Name, L"Div character"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Link, L"div"); - AddPropertiesInR(NSCSS::NSConstValues::NSProperties::RunnerProperties::R_RFonts, L"\"Arial\""); + AddPropertiesInR(NSCSS::NS_CONST_VALUES::RunnerProperties::R_RFonts, L"\"Arial\""); } else if (sNameDefaultElement == L"div") { - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Type, L"paragraph"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_StyleId, L"div"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_CustomStyle, L"1"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Name, L"Div paragraph"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_BasedOn, L"normal"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Link, L"div-c"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Type, L"paragraph"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_StyleId, L"div"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_CustomStyle, L"1"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Name, L"Div paragraph"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_BasedOn, L"normal"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Link, L"div-c"); +// SetInd(L"w:firstLine=\"567\""); +// SetJc(L"both"); } else if (sNameDefaultElement == L"a-c") { - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Type, L"character"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_StyleId, L"a-c"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Name, L"Hyperlink character"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_UiPriority, L"99"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_UnhideWhenUsed, L"true"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Type, L"character"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_StyleId, L"a-c"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Name, L"Hyperlink character"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_UiPriority, L"99"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_UnhideWhenUsed, L"true"); - AddPropertiesInR(NSCSS::NSConstValues::NSProperties::RunnerProperties::R_Color, L"0000FF"); - AddPropertiesInR(NSCSS::NSConstValues::NSProperties::RunnerProperties::R_U, L"single"); - AddPropertiesInR(NSCSS::NSConstValues::NSProperties::RunnerProperties::R_RFonts, L"\"Arial\""); + AddPropertiesInR(NSCSS::NS_CONST_VALUES::RunnerProperties::R_Color, L"0000FF"); + AddPropertiesInR(NSCSS::NS_CONST_VALUES::RunnerProperties::R_U, L"single"); +// AddPropertiesInR(NSCSS::NS_CONST_VALUES::RunerProperties::R_Sz, L"24"); + AddPropertiesInR(NSCSS::NS_CONST_VALUES::RunnerProperties::R_RFonts, L"\"Arial\""); } else if (sNameDefaultElement == L"a") { - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Type, L"character"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_BasedOn, L"a-c"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_StyleId, L"a"); - AddBasicProperties(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Name, L"Hyperlink"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Type, L"character"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_BasedOn, L"a-c"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_StyleId, L"a"); + AddBasicProperties(NSCSS::NS_CONST_VALUES::BasicProperties::B_Name, L"Hyperlink"); } } @@ -261,7 +273,7 @@ void CXmlElement::Clear() m_mRStyleValues.clear(); } -void CXmlElement::AddPropertiesInP(const NSCSS::NSConstValues::NSProperties::ParagraphProperties &nProperties, const std::wstring &sValue) +void CXmlElement::AddPropertiesInP(const NSCSS::NS_CONST_VALUES::ParagraphProperties &nProperties, const std::wstring &sValue) { if (sValue.empty()) return; @@ -269,7 +281,7 @@ void CXmlElement::AddPropertiesInP(const NSCSS::NSConstValues::NSProperties::Par m_mPStyleValues[nProperties] = sValue; } -void CXmlElement::AddPropertiesInR(const NSCSS::NSConstValues::NSProperties::RunnerProperties &nProperties, const std::wstring &sValue) +void CXmlElement::AddPropertiesInR(const NSCSS::NS_CONST_VALUES::RunnerProperties &nProperties, const std::wstring &sValue) { if (sValue.empty()) return; @@ -277,7 +289,7 @@ void CXmlElement::AddPropertiesInR(const NSCSS::NSConstValues::NSProperties::Run m_mRStyleValues[nProperties] = sValue; } -void CXmlElement::AddBasicProperties(const NSCSS::NSConstValues::NSProperties::BasicProperties &nProperties, const std::wstring &sValue) +void CXmlElement::AddBasicProperties(const NSCSS::NS_CONST_VALUES::BasicProperties &nProperties, const std::wstring &sValue) { if (sValue.empty()) return; @@ -290,13 +302,13 @@ CXmlElement& CXmlElement::operator+=(const CXmlElement& oElement) if (oElement.Empty()) return *this; - for (const std::map::value_type& oBasicElement : oElement.m_mBasicValues) + for (const std::map::value_type& oBasicElement : oElement.m_mBasicValues) m_mBasicValues[oBasicElement.first] = oBasicElement.second; - for (const std::map::value_type& oPElement : oElement.m_mPStyleValues) + for (const std::map::value_type& oPElement : oElement.m_mPStyleValues) m_mPStyleValues[oPElement.first] = oPElement.second; - for (const std::map::value_type& oRElement : oElement.m_mRStyleValues) + for (const std::map::value_type& oRElement : oElement.m_mRStyleValues) m_mRStyleValues[oRElement.first] = oRElement.second; return *this; @@ -323,69 +335,69 @@ std::wstring CXmlElement::ConvertPStyle() const if (m_mPStyleValues.empty()) return std::wstring(); - std::wstring sPPr; - std::wstring sPBdr; + std::wstring sPPr = L""; + std::wstring sPBdr = L""; - for (const std::map::value_type& oItem : m_mPStyleValues) + for (const std::map::value_type& oItem : m_mPStyleValues) { switch (oItem.first) { - case NSCSS::NSConstValues::NSProperties::ParagraphProperties::P_Jc: + case NSCSS::NS_CONST_VALUES::ParagraphProperties::P_Jc: { sPPr += L""; break; } - case NSCSS::NSConstValues::NSProperties::ParagraphProperties::P_Spacing: + case NSCSS::NS_CONST_VALUES::ParagraphProperties::P_Spacing: { sPPr += L""; break; } - case NSCSS::NSConstValues::NSProperties::ParagraphProperties::P_ContextualSpacing: + case NSCSS::NS_CONST_VALUES::ParagraphProperties::P_ContextualSpacing: { sPPr += L""; break; } - case NSCSS::NSConstValues::NSProperties::ParagraphProperties::P_Ind: + case NSCSS::NS_CONST_VALUES::ParagraphProperties::P_Ind: { sPPr += L""; break; } - case NSCSS::NSConstValues::NSProperties::ParagraphProperties::P_OutlineLvl: + case NSCSS::NS_CONST_VALUES::ParagraphProperties::P_OutlineLvl: { sPPr += L""; break; } - case NSCSS::NSConstValues::NSProperties::ParagraphProperties::P_Shd: + case NSCSS::NS_CONST_VALUES::ParagraphProperties::P_Shd: { sPPr += L""; break; } - case NSCSS::NSConstValues::NSProperties::ParagraphProperties::P_TopBorder: + case NSCSS::NS_CONST_VALUES::ParagraphProperties::P_TopBorder: { sPBdr += L""; break; } - case NSCSS::NSConstValues::NSProperties::ParagraphProperties::P_LeftBorder: + case NSCSS::NS_CONST_VALUES::ParagraphProperties::P_LeftBorder: { sPBdr += L""; break; } - case NSCSS::NSConstValues::NSProperties::ParagraphProperties::P_BottomBorder: + case NSCSS::NS_CONST_VALUES::ParagraphProperties::P_BottomBorder: { sPBdr += L""; break; } - case NSCSS::NSConstValues::NSProperties::ParagraphProperties::P_RightBorder: + case NSCSS::NS_CONST_VALUES::ParagraphProperties::P_RightBorder: { sPBdr += L""; break; } - case NSCSS::NSConstValues::NSProperties::ParagraphProperties::P_KeepLines: + case NSCSS::NS_CONST_VALUES::ParagraphProperties::P_KeepLines: { sPPr += L""; break; } - case NSCSS::NSConstValues::NSProperties::ParagraphProperties::P_KeepNext: + case NSCSS::NS_CONST_VALUES::ParagraphProperties::P_KeepNext: { sPPr += L""; break; @@ -395,10 +407,14 @@ std::wstring CXmlElement::ConvertPStyle() const } } - if (!sPBdr.empty()) - sPPr += L"" + sPBdr + L""; + sPBdr += L""; - return L"" + sPPr + L""; + if (sPBdr.length() > 17) + sPPr += sPBdr; + + sPPr += L""; + + return sPPr; } std::wstring CXmlElement::ConvertRStyle() const @@ -406,13 +422,13 @@ std::wstring CXmlElement::ConvertRStyle() const if (m_mRStyleValues.empty()) return std::wstring(); - std::wstring sRStyle; + std::wstring sRStyle = L""; - for (const std::map::value_type& oItem : m_mRStyleValues) + for (const std::map::value_type& oItem : m_mRStyleValues) { switch (oItem.first) { - case NSCSS::NSConstValues::NSProperties::RunnerProperties::R_RFonts: + case NSCSS::NS_CONST_VALUES::RunnerProperties::R_RFonts: { sRStyle += (oItem.second != L"\"inherit\"") ? L""; break; } - case NSCSS::NSConstValues::NSProperties::RunnerProperties::R_Sz: + case NSCSS::NS_CONST_VALUES::RunnerProperties::R_Sz: { sRStyle += L"" + L""; break; } - case NSCSS::NSConstValues::NSProperties::RunnerProperties::R_B: + case NSCSS::NS_CONST_VALUES::RunnerProperties::R_B: { - if (oItem.second == L"bold") + if (oItem.second == L"true") sRStyle += L""; - else if (oItem.second == L"normal") + else if (oItem.second == L"false") sRStyle += L""; break; } - case NSCSS::NSConstValues::NSProperties::RunnerProperties::R_I: + case NSCSS::NS_CONST_VALUES::RunnerProperties::R_I: { - if (oItem.second == L"italic") + if (oItem.second == L"true") sRStyle += L""; - else if (oItem.second == L"normal") + else if (oItem.second == L"false") sRStyle += L""; break; } - case NSCSS::NSConstValues::NSProperties::RunnerProperties::R_Color: + case NSCSS::NS_CONST_VALUES::RunnerProperties::R_Color: { sRStyle += L""; break; } - case NSCSS::NSConstValues::NSProperties::RunnerProperties::R_U: + case NSCSS::NS_CONST_VALUES::RunnerProperties::R_U: { sRStyle += L""; break; } - case NSCSS::NSConstValues::NSProperties::RunnerProperties::R_Shd: + case NSCSS::NS_CONST_VALUES::RunnerProperties::R_Shd: { sRStyle += L""; break; } - case NSCSS::NSConstValues::NSProperties::RunnerProperties::R_SmallCaps: - { - if (oItem.second == L"smallCaps") - sRStyle += L""; - else if (oItem.second == L"normal") - sRStyle += L""; - break; - } default: break; } } - return L"" + sRStyle + L""; + sRStyle += L""; + + return sRStyle; } std::wstring CXmlElement::ConvertBasicInfoStyle() const @@ -481,36 +491,36 @@ std::wstring CXmlElement::ConvertBasicInfoStyle() const std::wstring sBasicInfo; - for (const std::map::value_type& oItem : m_mBasicValues) + for (const std::map::value_type& oItem : m_mBasicValues) { switch (oItem.first) { - case NSCSS::NSConstValues::NSProperties::BasicProperties::B_Name: + case NSCSS::NS_CONST_VALUES::BasicProperties::B_Name: { sBasicInfo += L""; break; } - case NSCSS::NSConstValues::NSProperties::BasicProperties::B_BasedOn: + case NSCSS::NS_CONST_VALUES::BasicProperties::B_BasedOn: { sBasicInfo += L""; break; } - case NSCSS::NSConstValues::NSProperties::BasicProperties::B_QFormat: + case NSCSS::NS_CONST_VALUES::BasicProperties::B_QFormat: { sBasicInfo += L""; break; } - case NSCSS::NSConstValues::NSProperties::BasicProperties::B_Link: + case NSCSS::NS_CONST_VALUES::BasicProperties::B_Link: { sBasicInfo += L""; break; } - case NSCSS::NSConstValues::NSProperties::BasicProperties::B_UnhideWhenUsed: + case NSCSS::NS_CONST_VALUES::BasicProperties::B_UnhideWhenUsed: { sBasicInfo += L""; break; } - case NSCSS::NSConstValues::NSProperties::BasicProperties::B_UiPriority: + case NSCSS::NS_CONST_VALUES::BasicProperties::B_UiPriority: { sBasicInfo += L""; break; @@ -530,30 +540,35 @@ std::wstring CXmlElement::GetStyle() const std::wstring sStyle = L"::value_type& oItem : m_mBasicValues) + for (const std::map::value_type& oItem : m_mBasicValues) { switch (oItem.first) { - case NSCSS::NSConstValues::NSProperties::BasicProperties::B_CustomStyle: + case NSCSS::NS_CONST_VALUES::BasicProperties::B_CustomStyle: { sStyle += L" w:customStyle=\"" + oItem.second + L"\""; break; } - case NSCSS::NSConstValues::NSProperties::BasicProperties::B_StyleId: + case NSCSS::NS_CONST_VALUES::BasicProperties::B_StyleId: { sStyle += L" w:styleId=\"" + oItem.second + L"\""; break; } - case NSCSS::NSConstValues::NSProperties::BasicProperties::B_Type: + case NSCSS::NS_CONST_VALUES::BasicProperties::B_Type: { sStyle += L" w:type=\"" + oItem.second + L"\""; break; } - case NSCSS::NSConstValues::NSProperties::BasicProperties::B_Default: + case NSCSS::NS_CONST_VALUES::BasicProperties::B_Default: { sStyle += L" w:default=\"" + oItem.second + L"\""; break; } +// case NSCSS::NS_CONST_VALUES::BasicProperties::B_S: +// { +// sStyle += L" w:S=\"" + oItem.second + L"\""; +// break; +// } default: break; } @@ -567,26 +582,6 @@ std::wstring CXmlElement::GetStyle() const return sStyle.length() > 19 ? sStyle : std::wstring(); } -std::wstring CXmlElement::GetLitePStyle() const -{ - if (Empty()) - return std::wstring(); - - const std::wstring &sLitePStyle = ConvertPStyle(); - - return (sLitePStyle.empty()) ? sLitePStyle : sLitePStyle.substr(7, sLitePStyle.length() - 15); -} - -std::wstring CXmlElement::GetLiteRStyle() const -{ - if (Empty()) - return std::wstring(); - - const std::wstring &sLiteRStyle = ConvertRStyle(); - - return (sLiteRStyle.empty()) ? sLiteRStyle : sLiteRStyle.substr(7, sLiteRStyle.length() - 15); -} - std::wstring CXmlElement::GetPStyle() const { if (m_mBasicValues.empty() && m_mPStyleValues.empty()) @@ -594,30 +589,35 @@ std::wstring CXmlElement::GetPStyle() const std::wstring sPStyle = L"::value_type& oItem : m_mBasicValues) + for (const std::map::value_type& oItem : m_mBasicValues) { switch (oItem.first) { - case NSCSS::NSConstValues::NSProperties::BasicProperties::B_CustomStyle: + case NSCSS::NS_CONST_VALUES::BasicProperties::B_CustomStyle: { sPStyle += L" w:customStyle=\"" + oItem.second + L"\""; break; } - case NSCSS::NSConstValues::NSProperties::BasicProperties::B_StyleId: + case NSCSS::NS_CONST_VALUES::BasicProperties::B_StyleId: { sPStyle += L" w:styleId=\"" + oItem.second + L"\""; break; } - case NSCSS::NSConstValues::NSProperties::BasicProperties::B_Type: + case NSCSS::NS_CONST_VALUES::BasicProperties::B_Type: { sPStyle += L" w:type=\"" + oItem.second + L"\""; break; } - case NSCSS::NSConstValues::NSProperties::BasicProperties::B_Default: + case NSCSS::NS_CONST_VALUES::BasicProperties::B_Default: { sPStyle += L" w:default=\"" + oItem.second + L"\""; break; } +// case NSCSS::NS_CONST_VALUES::BasicProperties::B_S: +// { +// sPStyle += L" w:S=\"" + oItem.second + L"\""; +// break; +// } default: break; } @@ -638,32 +638,36 @@ std::wstring CXmlElement::GetRStyle() const std::wstring sRStyle = L"::value_type& oItem : m_mBasicValues) + for (const std::map::value_type& oItem : m_mBasicValues) { switch (oItem.first) { - case NSCSS::NSConstValues::NSProperties::BasicProperties::B_CustomStyle: + case NSCSS::NS_CONST_VALUES::BasicProperties::B_CustomStyle: { sRStyle += L" w:customStyle=\"" + oItem.second + L"\""; break; } - case NSCSS::NSConstValues::NSProperties::BasicProperties::B_StyleId: + case NSCSS::NS_CONST_VALUES::BasicProperties::B_StyleId: { sRStyle += L" w:styleId=\"" + oItem.second + L"\""; break; } - case NSCSS::NSConstValues::NSProperties::BasicProperties::B_Type: + case NSCSS::NS_CONST_VALUES::BasicProperties::B_Type: { sRStyle += L" w:type=\"" + oItem.second + L"\""; break; } - case NSCSS::NSConstValues::NSProperties::BasicProperties::B_Default: + case NSCSS::NS_CONST_VALUES::BasicProperties::B_Default: { sRStyle += L" w:default=\"" + oItem.second + L"\""; break; } - +// case NSCSS::NS_CONST_VALUES::BasicProperties::B_S: +// { +// sRStyle += L" w:S=\"" + oItem.second + L"\""; +// break; +// } default: break; } @@ -678,19 +682,19 @@ std::wstring CXmlElement::GetRStyle() const std::wstring CXmlElement::GetBasedOn() const { - std::map::const_iterator posBasedOn = m_mBasicValues.find(NSCSS::NSConstValues::NSProperties::BasicProperties::B_BasedOn); + std::map::const_iterator posBasedOn = m_mBasicValues.find(NSCSS::NS_CONST_VALUES::BasicProperties::B_BasedOn); return (posBasedOn != m_mBasicValues.end()) ? posBasedOn->second : std::wstring(); } std::wstring CXmlElement::GetStyleId() const { - std::map::const_iterator posStyleId = m_mBasicValues.find(NSCSS::NSConstValues::NSProperties::BasicProperties::B_StyleId); + std::map::const_iterator posStyleId = m_mBasicValues.find(NSCSS::NS_CONST_VALUES::BasicProperties::B_StyleId); return (posStyleId != m_mBasicValues.end()) ? posStyleId->second : std::wstring(); } std::wstring CXmlElement::GetName() const { - std::map::const_iterator posName = m_mBasicValues.find(NSCSS::NSConstValues::NSProperties::BasicProperties::B_Name); + std::map::const_iterator posName = m_mBasicValues.find(NSCSS::NS_CONST_VALUES::BasicProperties::B_Name); return (posName != m_mBasicValues.end()) ? posName->second : std::wstring(); } diff --git a/Common/3dParty/html/css/src/xhtml/CXmlElement.h b/Common/3dParty/html/css/src/xhtml/CXmlElement.h index 2030bf7d9f..08595cd164 100644 --- a/Common/3dParty/html/css/src/xhtml/CXmlElement.h +++ b/Common/3dParty/html/css/src/xhtml/CXmlElement.h @@ -8,9 +8,9 @@ class CXmlElement { - std::map m_mRStyleValues; - std::map m_mPStyleValues; - std::map m_mBasicValues; + std::map m_mRStyleValues; + std::map m_mPStyleValues; + std::map m_mBasicValues; std::wstring ConvertPStyle() const; std::wstring ConvertRStyle() const; @@ -26,18 +26,16 @@ public: void CreateDefaultElement(const std::wstring& sNameDefaultElement); void Clear(); - void AddPropertiesInP (const NSCSS::NSConstValues::NSProperties::ParagraphProperties& nProperties, const std::wstring& sValue); - void AddPropertiesInR (const NSCSS::NSConstValues::NSProperties::RunnerProperties& nProperties, const std::wstring& sValue); - void AddBasicProperties(const NSCSS::NSConstValues::NSProperties::BasicProperties& nProperties, const std::wstring& sValue); + void AddPropertiesInP (const NSCSS::NS_CONST_VALUES::ParagraphProperties& nProperties, const std::wstring& sValue); + void AddPropertiesInR (const NSCSS::NS_CONST_VALUES::RunnerProperties& nProperties, const std::wstring& sValue); + void AddBasicProperties(const NSCSS::NS_CONST_VALUES::BasicProperties& nProperties, const std::wstring& sValue); - std::wstring GetLitePStyle() const; - std::wstring GetLiteRStyle() const; - std::wstring GetPStyle() const; - std::wstring GetRStyle() const; - std::wstring GetStyle() const; - std::wstring GetBasedOn() const; - std::wstring GetStyleId() const; - std::wstring GetName() const; + std::wstring GetPStyle() const; + std::wstring GetRStyle() const; + std::wstring GetStyle() const; + std::wstring GetBasedOn() const; + std::wstring GetStyleId() const; + std::wstring GetName() const; CXmlElement& operator+=(const CXmlElement& oElement); CXmlElement& operator= (const CXmlElement& oelement); diff --git a/Common/3dParty/html/htmltoxhtml.h b/Common/3dParty/html/htmltoxhtml.h index b4a1ec2a61..55953c0092 100644 --- a/Common/3dParty/html/htmltoxhtml.h +++ b/Common/3dParty/html/htmltoxhtml.h @@ -27,10 +27,11 @@ static std::string mhtTohtml(std::string& sFileContent); static void replace_all(std::string& s, const std::string& s1, const std::string& s2) { size_t pos = s.find(s1); + size_t l = s2.length(); while(pos != std::string::npos) { s.replace(pos, s1.length(), s2); - pos = s.find(s1, pos + s2.length()); + pos = s.find(s1, pos + l); } } @@ -62,17 +63,6 @@ static std::wstring htmlToXhtml(std::string& sFileContent) } } - // Избавление от - size_t posA = sFileContent.find("", posA); - if(nEnd < nBegin) - sFileContent.replace(nEnd, 2, ">"); - posA = sFileContent.find("&;\"\'()[]{}"); + size_t nBad = sName.find_first_of("-'+,.:=?#%<>&;\"\'()[]{}"); while(nBad != std::string::npos) { sName.erase(nBad, 1); - nBad = sName.find_first_of("+,.:=?#%<>&;\"\'()[]{}", nBad); + nBad = sName.find_first_of("-'+,.:=?#%<>&;\"\'()[]{}", nBad); if(sName.empty()) break; bCheck = true; diff --git a/Common/3dParty/icu/icu.pri b/Common/3dParty/icu/icu.pri index 67801f20a0..d562eae214 100644 --- a/Common/3dParty/icu/icu.pri +++ b/Common/3dParty/icu/icu.pri @@ -18,7 +18,7 @@ core_linux { } core_mac { - INCLUDEPATH += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/include + INCLUDEPATH += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/usr/local/include LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicuuc.$${ICU_MAJOR_VER}.dylib LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicudata.$${ICU_MAJOR_VER}.dylib diff --git a/Common/DocxFormat/Projects/DocxFormatLib.vcxproj b/Common/DocxFormat/Projects/DocxFormatLib.vcxproj index 12a3b3799e..25363d6cbf 100644 --- a/Common/DocxFormat/Projects/DocxFormatLib.vcxproj +++ b/Common/DocxFormat/Projects/DocxFormatLib.vcxproj @@ -256,6 +256,7 @@ + @@ -341,11 +342,8 @@ - - - diff --git a/Common/DocxFormat/Projects/DocxFormatLib.vcxproj.filters b/Common/DocxFormat/Projects/DocxFormatLib.vcxproj.filters index 39851d321c..e9df65f6cb 100644 --- a/Common/DocxFormat/Projects/DocxFormatLib.vcxproj.filters +++ b/Common/DocxFormat/Projects/DocxFormatLib.vcxproj.filters @@ -432,6 +432,9 @@ XlsxFormat\Chart + + XlsxFormat\Chart + XlsxFormat\Chart @@ -688,15 +691,6 @@ Logic\DocParts - - XlsxFormat\Chart - - - XlsxFormat\Chart - - - XlsxFormat\Chart - diff --git a/Common/DocxFormat/Source/Common/ComplexTypes.h b/Common/DocxFormat/Source/Common/ComplexTypes.h index fd75ca9766..b4f32ee6bc 100644 --- a/Common/DocxFormat/Source/Common/ComplexTypes.h +++ b/Common/DocxFormat/Source/Common/ComplexTypes.h @@ -190,7 +190,7 @@ namespace ComplexTypes if ( m_oColor.IsInit() ) { sResult += _T("w:color=\""); - sResult += m_oColor->ToStringNoAlpha(); + sResult += m_oColor->ToString(); sResult += _T("\" "); } @@ -723,9 +723,9 @@ namespace ComplexTypes } void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) { - WritingElement_ReadAttributes_Start_No_NS( oReader ) - WritingElement_ReadAttributes_ReadSingle( oReader, _T("val"), m_oVal ) - WritingElement_ReadAttributes_End_No_NS( oReader ) + WritingElement_ReadAttributes_Start( oReader ) + WritingElement_ReadAttributes_ReadSingle( oReader, _T("w:val"), m_oVal ) + WritingElement_ReadAttributes_End( oReader ) } public: diff --git a/Common/DocxFormat/Source/Common/SimpleTypes_Word.cpp b/Common/DocxFormat/Source/Common/SimpleTypes_Word.cpp index 8c9857ce0b..7b1c4c8ea8 100644 --- a/Common/DocxFormat/Source/Common/SimpleTypes_Word.cpp +++ b/Common/DocxFormat/Source/Common/SimpleTypes_Word.cpp @@ -46,11 +46,6 @@ namespace SimpleTypes { sValue = sValue.substr(0, split); } - size_t s0 = sValue.find(L"#"); // ala #ff9 - if (0 == s0) - { - sValue = sValue.substr(1); - } //В документации не написано, что цвет может приходить строкой, но в реальных докуентах встречается и word это разруливает. CPresetColorVal<> oPresetColorVal; if(oPresetColorVal.FromStringIgnoreCase(sValue)) diff --git a/Common/DocxFormat/Source/XlsxFormat/Chart/ChartDrawing.h b/Common/DocxFormat/Source/DocxFormat/ChartDrawing.h similarity index 98% rename from Common/DocxFormat/Source/XlsxFormat/Chart/ChartDrawing.h rename to Common/DocxFormat/Source/DocxFormat/ChartDrawing.h index ca21c2d726..942ae30c71 100644 --- a/Common/DocxFormat/Source/XlsxFormat/Chart/ChartDrawing.h +++ b/Common/DocxFormat/Source/DocxFormat/ChartDrawing.h @@ -31,9 +31,9 @@ */ #pragma once -#include "../../DocxFormat/IFileContainer.h" -#include "../../../../../ASCOfficePPTXFile/PPTXFormat/Logic/SpTreeElem.h" -#include "../WritingElement.h" +#include "IFileContainer.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/SpTreeElem.h" +#include "../XlsxFormat/WritingElement.h" namespace OOX { diff --git a/Common/DocxFormat/Source/DocxFormat/ContentTypes.h b/Common/DocxFormat/Source/DocxFormat/ContentTypes.h index 09181676fe..93aa79e25c 100644 --- a/Common/DocxFormat/Source/DocxFormat/ContentTypes.h +++ b/Common/DocxFormat/Source/DocxFormat/ContentTypes.h @@ -99,7 +99,7 @@ namespace OOX { std::map::const_iterator it = m_mTable.find(sExtension); if (it == m_mTable.end()) - return _T("application/unknown"); + return _T(""); return it->second; } diff --git a/Common/DocxFormat/Source/DocxFormat/FileFactory.cpp b/Common/DocxFormat/Source/DocxFormat/FileFactory.cpp index c412b050ad..94acc1a3fe 100644 --- a/Common/DocxFormat/Source/DocxFormat/FileFactory.cpp +++ b/Common/DocxFormat/Source/DocxFormat/FileFactory.cpp @@ -58,10 +58,10 @@ #include "Diagram/DiagramDrawing.h" #include "Diagram/DiagramData.h" #include "VmlDrawing.h" +#include "ChartDrawing.h" #include "CustomXml.h" #include "../XlsxFormat/Chart/Chart.h" -#include "../XlsxFormat/Chart/ChartDrawing.h" #include "../../../../ASCOfficePPTXFile/PPTXFormat/Theme.h" #include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/HeadingVariant.h" @@ -159,13 +159,13 @@ namespace OOX else if ( oRelation.Type() == OOX::FileTypes::ChartDrawing) return smart_ptr(new CChartDrawing( pMain, oRootPath, oFileName )); else if ( oRelation.Type() == OOX::FileTypes::Chart ) - return smart_ptr(new OOX::Spreadsheet::CChartFile( pMain, oRootPath, oFileName )); + return smart_ptr(new OOX::Spreadsheet::CChartSpace( pMain, oRootPath, oFileName )); else if ( oRelation.Type() == OOX::FileTypes::ChartEx ) - return smart_ptr(new OOX::Spreadsheet::CChartExFile( pMain, oRootPath, oFileName )); + return smart_ptr(new OOX::Spreadsheet::CChartSpaceEx( pMain, oRootPath, oFileName )); else if ( oRelation.Type() == OOX::FileTypes::ChartStyle ) - return smart_ptr(new OOX::Spreadsheet::CChartStyleFile( pMain, oRootPath, oFileName )); - else if ( oRelation.Type() == OOX::FileTypes::ChartColors ) - return smart_ptr(new OOX::Spreadsheet::CChartColorsFile( pMain, oRootPath, oFileName )); + return smart_ptr(new OOX::Spreadsheet::CChartStyle( pMain, oRootPath, oFileName )); + else if ( oRelation.Type() == OOX::FileTypes::ChartColorStyle ) + return smart_ptr(new OOX::Spreadsheet::CChartColorStyle( pMain, oRootPath, oFileName )); else if ( oRelation.Type() == OOX::FileTypes::ActiveX_xml) return smart_ptr(new OOX::ActiveX_xml( pMain, oRootPath, oFileName)); else if ( oRelation.Type() == OOX::FileTypes::ActiveX_bin) @@ -285,13 +285,13 @@ namespace OOX else if (pRelation->Type() == FileTypes::MicrosoftOfficeUnknown) //ms package return smart_ptr(new OleObject( pMain, oFileName, true )); else if ( pRelation->Type() == OOX::FileTypes::Chart ) - return smart_ptr(new OOX::Spreadsheet::CChartFile( pMain, oRootPath, oFileName )); + return smart_ptr(new OOX::Spreadsheet::CChartSpace( pMain, oRootPath, oFileName )); else if ( pRelation->Type() == OOX::FileTypes::ChartEx ) - return smart_ptr(new OOX::Spreadsheet::CChartExFile( pMain, oRootPath, oFileName )); + return smart_ptr(new OOX::Spreadsheet::CChartSpaceEx( pMain, oRootPath, oFileName )); else if ( pRelation->Type() == OOX::FileTypes::ChartStyle ) - return smart_ptr(new OOX::Spreadsheet::CChartStyleFile( pMain, oRootPath, oFileName )); - else if ( pRelation->Type() == OOX::FileTypes::ChartColors) - return smart_ptr(new OOX::Spreadsheet::CChartColorsFile( pMain, oRootPath, oFileName )); + return smart_ptr(new OOX::Spreadsheet::CChartStyle( pMain, oRootPath, oFileName )); + else if ( pRelation->Type() == OOX::FileTypes::ChartColorStyle ) + return smart_ptr(new OOX::Spreadsheet::CChartColorStyle( pMain, oRootPath, oFileName )); else if ( pRelation->Type() == FileTypes::ActiveX_xml) return smart_ptr(new ActiveX_xml( pMain, oRootPath, oFileName )); else if ( pRelation->Type() == FileTypes::ActiveX_bin) diff --git a/Common/DocxFormat/Source/DocxFormat/FileTypes.h b/Common/DocxFormat/Source/DocxFormat/FileTypes.h index e55b8076cc..3a83e327f1 100644 --- a/Common/DocxFormat/Source/DocxFormat/FileTypes.h +++ b/Common/DocxFormat/Source/DocxFormat/FileTypes.h @@ -66,7 +66,7 @@ namespace OOX L"application/vnd.openxmlformats-officedocument.theme+xml", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme", L"theme", true); - + const FileType ThemeOverride (L"themeOverride", L"themeOverride.xml", L"application/vnd.openxmlformats-officedocument.theme+xml", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/themeOverride", @@ -224,12 +224,12 @@ namespace OOX L"http://schemas.microsoft.com/office/2014/relationships/chartEx", L"charts/chartEx", true, true); - const FileType ChartStyle (L"", L"style.xml", + const FileType ChartStyle (L"charts", L"style.xml", L"application/vnd.ms-office.chartstyle+xml", L"http://schemas.microsoft.com/office/2011/relationships/chartStyle", L"charts/style", true, true); - const FileType ChartColors (L"", L"colors.xml", + const FileType ChartColorStyle (L"charts", L"colors.xml", L"application/vnd.ms-office.chartcolorstyle+xml", L"http://schemas.microsoft.com/office/2011/relationships/chartColorStyle", L"charts/colors", true, true); diff --git a/Common/DocxFormat/Source/DocxFormat/Logic/Sdt.cpp b/Common/DocxFormat/Source/DocxFormat/Logic/Sdt.cpp index e2eaefd908..31d0d37ce2 100644 --- a/Common/DocxFormat/Source/DocxFormat/Logic/Sdt.cpp +++ b/Common/DocxFormat/Source/DocxFormat/Logic/Sdt.cpp @@ -369,7 +369,6 @@ namespace OOX WritingElement_ReadNode( oNode, oChild, _T("w:comb"), m_oComb ); WritingElement_ReadNode( oNode, oChild, _T("w:maxCharacters"), m_oMaxCharacters ); - WritingElement_ReadNode( oNode, oChild, _T("w:combBorder"), m_oCombBorder ); } void CTextFormPr::fromXML(XmlUtils::CXmlLiteReader& oReader) @@ -387,8 +386,6 @@ namespace OOX m_oComb = oReader; else if ( _T("w:maxCharacters") == sName ) m_oMaxCharacters = oReader; - else if ( _T("w:combBorder") == sName ) - m_oCombBorder = oReader; } } std::wstring CTextFormPr::toXML() const @@ -397,7 +394,6 @@ namespace OOX WritingElement_WriteNode_1( _T(""); diff --git a/Common/DocxFormat/Source/DocxFormat/Logic/Sdt.h b/Common/DocxFormat/Source/DocxFormat/Logic/Sdt.h index 63b243d9e8..52d36fc589 100644 --- a/Common/DocxFormat/Source/DocxFormat/Logic/Sdt.h +++ b/Common/DocxFormat/Source/DocxFormat/Logic/Sdt.h @@ -484,7 +484,6 @@ namespace OOX // Nodes nullable m_oComb; nullable m_oMaxCharacters; - nullable m_oCombBorder; }; //-------------------------------------------------------------------------------- // CSdtComboBox 17.5.2.5 (Part 1) diff --git a/Common/DocxFormat/Source/DocxFormat/Logic/Vml.cpp b/Common/DocxFormat/Source/DocxFormat/Logic/Vml.cpp index b78674e52e..50e41810bc 100644 --- a/Common/DocxFormat/Source/DocxFormat/Logic/Vml.cpp +++ b/Common/DocxFormat/Source/DocxFormat/Logic/Vml.cpp @@ -1354,16 +1354,24 @@ namespace OOX sResult += L""; return sResult; } - bool CClientData::toCellAnchor(OOX::Spreadsheet::CCellAnchor *pCellAnchor) + void CClientData::toCellAnchor(OOX::Spreadsheet::CCellAnchor *pCellAnchor) { - if (!m_oAnchor.IsInit()) return false; - if (!pCellAnchor) return false; + if (!m_oAnchor.IsInit()) return; + if (!pCellAnchor) return; std::vector sAnchors; boost::algorithm::split(sAnchors, m_oAnchor.get(), boost::algorithm::is_any_of(L","), boost::algorithm::token_compress_on); - if (sAnchors.size() < 8) return false; + if (sAnchors.size() < 8) return; + if (pCellAnchor == NULL) + { + SimpleTypes::Spreadsheet::CCellAnchorType<> eAnchorType; + eAnchorType.SetValue(SimpleTypes::Spreadsheet::cellanchorTwoCell); + + pCellAnchor = new OOX::Spreadsheet::CCellAnchor(eAnchorType); + } + pCellAnchor->m_oFrom.Init(); pCellAnchor->m_oFrom->m_oCol.Init(); pCellAnchor->m_oFrom->m_oCol->SetValue(XmlUtils::GetInteger(sAnchors[0])); @@ -1384,7 +1392,6 @@ namespace OOX pCellAnchor->m_oTo->m_oRowOff.Init(); pCellAnchor->m_oTo->m_oRowOff->FromPx(XmlUtils::GetInteger(sAnchors[7])); - return true; } void CClientData::toFormControlPr(OOX::Spreadsheet::CFormControlPr* pFormControlPr) { diff --git a/Common/DocxFormat/Source/DocxFormat/Logic/Vml.h b/Common/DocxFormat/Source/DocxFormat/Logic/Vml.h index af8c7a3c54..89bfa6c98b 100644 --- a/Common/DocxFormat/Source/DocxFormat/Logic/Vml.h +++ b/Common/DocxFormat/Source/DocxFormat/Logic/Vml.h @@ -1493,7 +1493,7 @@ namespace OOX } } } - bool toCellAnchor(OOX::Spreadsheet::CCellAnchor* pCellAnchor); + void toCellAnchor(OOX::Spreadsheet::CCellAnchor* pCellAnchor); void toFormControlPr(OOX::Spreadsheet::CFormControlPr* pFormControlPr); void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) diff --git a/Common/DocxFormat/Source/DocxFormat/Settings/Settings.h b/Common/DocxFormat/Source/DocxFormat/Settings/Settings.h index f8b0b529a5..bc9d098a0d 100644 --- a/Common/DocxFormat/Source/DocxFormat/Settings/Settings.h +++ b/Common/DocxFormat/Source/DocxFormat/Settings/Settings.h @@ -3647,8 +3647,6 @@ namespace OOX m_oSdtGlobalColor = oReader; else if ( _T("w:SdtGlobalShowHighlight") == sName ) m_oSdtGlobalShowHighlight = oReader; - else if ( _T("w:SpecialFormsHighlight") == sName ) - m_oSpecialFormsHighlight = oReader; } } } @@ -3668,22 +3666,15 @@ namespace OOX sXml += m_oSdtGlobalShowHighlight->ToString(); sXml += L"/>"; } - if(m_oSpecialFormsHighlight.IsInit()) - { - sXml += L"ToString(); - sXml += L"/>"; - } sXml += L""; return sXml; } bool IsEmpty() { - return !(m_oSdtGlobalColor.IsInit() || m_oSdtGlobalShowHighlight.IsInit() || m_oSpecialFormsHighlight.IsInit()); + return !(m_oSdtGlobalColor.IsInit() || m_oSdtGlobalShowHighlight.IsInit()); } nullable m_oSdtGlobalColor; nullable> m_oSdtGlobalShowHighlight; - nullable m_oSpecialFormsHighlight; }; } // namespace OOX diff --git a/Common/DocxFormat/Source/DocxFormat/WritingElement.h b/Common/DocxFormat/Source/DocxFormat/WritingElement.h index ef3ddfcb57..203c2e7b26 100644 --- a/Common/DocxFormat/Source/DocxFormat/WritingElement.h +++ b/Common/DocxFormat/Source/DocxFormat/WritingElement.h @@ -372,7 +372,6 @@ namespace OOX et_a_scene3d, // et_a_schemeClr, // et_a_scrgbClr, // - et_a_styleClr, et_a_shade, // et_a_snd, // et_a_softEdge, // @@ -1123,14 +1122,7 @@ namespace OOX et_ct_StrDimension, et_ct_NumDimension, et_ct_ChartData, - et_ct_ExternalData, - et_cs_ChartStyle, - et_cs_StyleEntry, - et_cs_MarkerLayout, - et_cs_ColorStyle, - et_cs_SchemeClr, - et_cs_Variation, et_cdr_FromTo, et_cdr_Ext, @@ -1142,7 +1134,6 @@ namespace OOX et_x_BookViews, // et_x_Workbook, et_x_WorkbookPr, - et_x_WorkbookProtection, et_x_WorkbookView, // et_x_DefinedNames, // et_x_DefinedName, // diff --git a/Common/DocxFormat/Source/XlsxFormat/Chart/Chart.h b/Common/DocxFormat/Source/XlsxFormat/Chart/Chart.h index 6b2ca35f7e..1559de08eb 100644 --- a/Common/DocxFormat/Source/XlsxFormat/Chart/Chart.h +++ b/Common/DocxFormat/Source/XlsxFormat/Chart/Chart.h @@ -38,19 +38,19 @@ namespace OOX { namespace Spreadsheet { - class CChartFile: public OOX::FileGlobalEnumerated, public OOX::IFileContainer + class CChartSpace : public OOX::FileGlobalEnumerated, public OOX::IFileContainer { public: - CChartFile(OOX::Document* pMain) : OOX::FileGlobalEnumerated(pMain), OOX::IFileContainer(pMain) + CChartSpace(OOX::Document* pMain) : OOX::FileGlobalEnumerated(pMain), OOX::IFileContainer(pMain) { m_bSpreadsheets = true; } - CChartFile(OOX::Document* pMain, const CPath& oRootPath, const CPath& oPath) : OOX::FileGlobalEnumerated(pMain), OOX::IFileContainer(pMain) + CChartSpace(OOX::Document* pMain, const CPath& oRootPath, const CPath& oPath) : OOX::FileGlobalEnumerated(pMain), OOX::IFileContainer(pMain) { m_bSpreadsheets = true; read( oRootPath, oPath ); } - virtual ~CChartFile() + virtual ~CChartSpace() { } virtual void read(const CPath& oPath) @@ -92,6 +92,10 @@ namespace OOX { m_oChartSpace.toXML(L"c:chartSpace", writer); } + bool isValid() const + { + return true; + } virtual const OOX::FileType type() const { return OOX::FileTypes::Chart; @@ -109,26 +113,26 @@ namespace OOX return m_oReadPath; } - CT_ChartSpace m_oChartSpace; + CT_ChartSpace m_oChartSpace; private: - CPath m_oReadPath; + CPath m_oReadPath; void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) { } }; - class CChartExFile : public OOX::FileGlobalEnumerated, public OOX::IFileContainer + class CChartSpaceEx : public OOX::FileGlobalEnumerated, public OOX::IFileContainer { public: - CChartExFile(OOX::Document* pMain) : OOX::FileGlobalEnumerated(pMain), OOX::IFileContainer(pMain) + CChartSpaceEx(OOX::Document* pMain) : OOX::FileGlobalEnumerated(pMain), OOX::IFileContainer(pMain) { m_bSpreadsheets = true; } - CChartExFile(OOX::Document* pMain, const CPath& oRootPath, const CPath& oPath) : OOX::FileGlobalEnumerated(pMain), OOX::IFileContainer(pMain) + CChartSpaceEx(OOX::Document* pMain, const CPath& oRootPath, const CPath& oPath) : OOX::FileGlobalEnumerated(pMain), OOX::IFileContainer(pMain) { m_bSpreadsheets = true; read( oRootPath, oPath ); } - virtual ~CChartExFile() + virtual ~CChartSpaceEx() { } virtual void read(const CPath& oPath) @@ -170,6 +174,10 @@ namespace OOX { m_oChartSpace.toXML(writer); } + bool isValid() const + { + return true; + } virtual const OOX::FileType type() const { return OOX::FileTypes::ChartEx; @@ -187,26 +195,26 @@ namespace OOX return m_oReadPath; } - ChartEx::CChartSpace m_oChartSpace; + ChartEx::CChartSpace m_oChartSpace; private: - CPath m_oReadPath; + CPath m_oReadPath; void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) { } }; - class CChartStyleFile : public OOX::FileGlobalEnumerated/*, public OOX::IFileContainer*/ + class CChartStyle : public OOX::FileGlobalEnumerated/*, public OOX::IFileContainer*/ { public: - CChartStyleFile(OOX::Document* pMain) : OOX::FileGlobalEnumerated(pMain)/*, OOX::IFileContainer(pMain)*/ + CChartStyle(OOX::Document* pMain) : OOX::FileGlobalEnumerated(pMain)/*, OOX::IFileContainer(pMain)*/ { //m_bSpreadsheets = true; } - CChartStyleFile(OOX::Document* pMain, const CPath& oRootPath, const CPath& oPath) : OOX::FileGlobalEnumerated(pMain)/*, OOX::IFileContainer(pMain)*/ + CChartStyle(OOX::Document* pMain, const CPath& oRootPath, const CPath& oPath) : OOX::FileGlobalEnumerated(pMain)/*, OOX::IFileContainer(pMain)*/ { //m_bSpreadsheets = true; read( oRootPath, oPath ); } - virtual ~CChartStyleFile() + virtual ~CChartStyle() { } virtual void read(const CPath& oPath) @@ -228,7 +236,7 @@ namespace OOX if ( !oReader.ReadNextNode() ) return; - m_oChartStyle.fromXML(oReader); + //m_oChartSpace.fromXML(oReader); } virtual void write(const CPath& oPath, const CPath& oDirectory, CContentTypes& oContent) const { @@ -246,7 +254,7 @@ namespace OOX } void toXML(NSStringUtils::CStringBuilder& writer) const { - m_oChartStyle.toXML(writer); + //m_oChartSpace.toXML(L"cs:chartStyle", writer); } bool isValid() const { @@ -269,23 +277,25 @@ namespace OOX return m_oReadPath; } - ChartEx::CChartStyle m_oChartStyle; private: - CPath m_oReadPath; + CPath m_oReadPath; + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + } }; - class CChartColorsFile: public OOX::FileGlobalEnumerated/*, public OOX::IFileContainer*/ + class CChartColorStyle : public OOX::FileGlobalEnumerated/*, public OOX::IFileContainer*/ { public: - CChartColorsFile(OOX::Document* pMain) : OOX::FileGlobalEnumerated(pMain)/*, OOX::IFileContainer(pMain)*/ + CChartColorStyle(OOX::Document* pMain) : OOX::FileGlobalEnumerated(pMain)/*, OOX::IFileContainer(pMain)*/ { //m_bSpreadsheets = true; } - CChartColorsFile(OOX::Document* pMain, const CPath& oRootPath, const CPath& oPath) : OOX::FileGlobalEnumerated(pMain)/*, OOX::IFileContainer(pMain)*/ + CChartColorStyle(OOX::Document* pMain, const CPath& oRootPath, const CPath& oPath) : OOX::FileGlobalEnumerated(pMain)/*, OOX::IFileContainer(pMain)*/ { //m_bSpreadsheets = true; read( oRootPath, oPath ); } - virtual ~CChartColorsFile() + virtual ~CChartColorStyle() { } virtual void read(const CPath& oPath) @@ -307,7 +317,7 @@ namespace OOX if ( !oReader.ReadNextNode() ) return; - m_oColorStyle.fromXML(oReader); + //m_oChartSpace.fromXML(oReader); } virtual void write(const CPath& oPath, const CPath& oDirectory, CContentTypes& oContent) const { @@ -325,7 +335,7 @@ namespace OOX } void toXML(NSStringUtils::CStringBuilder& writer) const { - m_oColorStyle.toXML(writer); + //m_oChartSpace.toXML(L"cs:chartStyle", writer); } bool isValid() const { @@ -333,7 +343,7 @@ namespace OOX } virtual const OOX::FileType type() const { - return OOX::FileTypes::ChartColors; + return OOX::FileTypes::ChartColorStyle; } virtual const CPath DefaultDirectory() const { @@ -348,11 +358,11 @@ namespace OOX return m_oReadPath; } - ChartEx::CColorStyle m_oColorStyle; - private: - CPath m_oReadPath; - + CPath m_oReadPath; + void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + } }; } //Spreadsheet } // namespace OOX diff --git a/Common/DocxFormat/Source/XlsxFormat/Chart/ChartColors.h b/Common/DocxFormat/Source/XlsxFormat/Chart/ChartColors.h deleted file mode 100644 index cdcefd11d6..0000000000 --- a/Common/DocxFormat/Source/XlsxFormat/Chart/ChartColors.h +++ /dev/null @@ -1,167 +0,0 @@ -/* - * (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 - * - */ -//Generated code -#pragma once - -#include "../WritingElement.h" -#include "../../DocxFormat/Drawing/DrawingExt.h" -#include "../../../../../ASCOfficePPTXFile/PPTXFormat/Logic/UniColor.h" -#include "../../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Colors/ColorModifier.h" - -namespace OOX -{ -namespace Spreadsheet -{ -namespace ChartEx -{ - class CVariation : public WritingElementWithChilds - { - public: - WritingElement_AdditionConstructors(CVariation) - - CVariation() {} - - virtual void fromXML(XmlUtils::CXmlNode& node) {} - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - if (oReader.IsEmptyNode()) - return; - - int nParentDepth = oReader.GetDepth(); - while (oReader.ReadNextSiblingNode(nParentDepth)) - { - m_arrItems.push_back(new PPTX::Logic::ColorModifier()); - m_arrItems.back()->fromXML(oReader); - } - } - virtual void toXML(NSStringUtils::CStringBuilder& writer) const - { - writer.WriteString(L""); - - for (size_t i = 0; i < m_arrItems.size(); ++i) - { - if (m_arrItems[i]) - writer.WriteString(m_arrItems[i]->toXML()); - } - writer.WriteString(L""); - } - virtual std::wstring toXML() const - { - NSStringUtils::CStringBuilder writer; - toXML(writer); - return writer.GetData(); - } - virtual EElementType getType() - { - return et_cs_Variation; - } - }; - //------------------------------------------------------------------------------ - class CColorStyle : public OOX::WritingElementWithChilds<> - { - public: - CColorStyle() {} - - WritingElement_AdditionConstructors(CColorStyle) - - virtual void fromXML(XmlUtils::CXmlNode& node) {} - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - ReadAttributes(oReader); - - if (oReader.IsEmptyNode()) - return; - - int nParentDepth = oReader.GetDepth(); - while (oReader.ReadNextSiblingNode(nParentDepth)) - { - std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName()); - if (L"extLst" == sName) - { - m_extLst = oReader; - } - else if (L"variation" == sName) - { - m_arrItems.push_back(new CVariation()); - m_arrItems.back()->fromXML(oReader); - } - else - { - PPTX::Logic::UniColor *pColor = new PPTX::Logic::UniColor(); - pColor->fromXML(oReader); - - m_arrItems.push_back(dynamic_cast(pColor)); - } - } - } - virtual void toXML(NSStringUtils::CStringBuilder& writer) const - { - writer.WriteString(L""); - - for (size_t i = 0; i < m_arrItems.size(); ++i) - { - if (m_arrItems[i]) - writer.WriteString(m_arrItems[i]->toXML()); - } - writer.WriteString(L""); - } - virtual std::wstring toXML() const - { - NSStringUtils::CStringBuilder writer; - toXML(writer); - return writer.GetData(); - } - virtual EElementType getType() const - { - return et_cs_ColorStyle; - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start_No_NS(oReader) - WritingElement_ReadAttributes_Read_if(oReader, L"id", m_id) - WritingElement_ReadAttributes_Read_else_if(oReader, L"meth", m_meth) - WritingElement_ReadAttributes_End_No_NS(oReader) - } - - nullable_uint m_id; - nullable_string m_meth; - nullable m_extLst; - }; -} -} -} - diff --git a/Common/DocxFormat/Source/XlsxFormat/Chart/ChartSerialize.cpp b/Common/DocxFormat/Source/XlsxFormat/Chart/ChartSerialize.cpp index 07bb0149e1..1b90851b0e 100644 --- a/Common/DocxFormat/Source/XlsxFormat/Chart/ChartSerialize.cpp +++ b/Common/DocxFormat/Source/XlsxFormat/Chart/ChartSerialize.cpp @@ -1060,8 +1060,9 @@ namespace OOX{ } else if(_T("style") == sName) { - m_style = new CT_Style; - m_style->fromXML(oReader); + CT_Style1* pNewElem = new CT_Style1; + pNewElem->fromXML(oReader); + m_style = pNewElem; } else if(_T("clrMapOvr") == sName) { @@ -1154,7 +1155,8 @@ xmlns:c14=\"http://schemas.microsoft.com/office/drawing/2007/8/2/chart\""); } if(NULL != m_style) { - m_style->toXML(writer); + std::wstring sNodeName = _T("c:style"); + m_style->toXML(sNodeName, writer); } if(m_oClrMapOvr.IsInit()) { @@ -1172,7 +1174,8 @@ xmlns:c14=\"http://schemas.microsoft.com/office/drawing/2007/8/2/chart\""); } if(NULL != m_chart) { - m_chart->toXML(writer); + std::wstring sNodeName = _T("c:chart"); + m_chart->toXML(sNodeName, writer); } if (m_oSpPr.IsInit()) { @@ -13983,8 +13986,7 @@ xmlns:c14=\"http://schemas.microsoft.com/office/drawing/2007/8/2/chart\""); } } } - void CT_pivotFmts::toXML(const std::wstring& sNodeName, NSStringUtils::CStringBuilder& writer) const - { + void CT_pivotFmts::toXML(const std::wstring& sNodeName, NSStringUtils::CStringBuilder& writer) const{ writer.WriteString(L"<"); writer.WriteString(sNodeName); writer.WriteString(L">"); @@ -14134,10 +14136,10 @@ xmlns:c14=\"http://schemas.microsoft.com/office/drawing/2007/8/2/chart\""); } } } - void CT_Chart::toXML(NSStringUtils::CStringBuilder& writer) const - { - writer.WriteString(L""); - + void CT_Chart::toXML(const std::wstring& sNodeName, NSStringUtils::CStringBuilder& writer) const{ + writer.WriteString(L"<"); + writer.WriteString(sNodeName); + writer.WriteString(L">"); if(NULL != m_title) { std::wstring sNodeName = _T("c:title"); @@ -14203,7 +14205,9 @@ xmlns:c14=\"http://schemas.microsoft.com/office/drawing/2007/8/2/chart\""); std::wstring sNodeName = _T("c:extLst"); m_extLst->toXML(sNodeName, writer); } - writer.WriteString(L""); + writer.WriteString(L""); } EElementType CT_Chart::getType(){return et_ct_Chart;} CT_Protection::CT_Protection() @@ -14375,25 +14379,62 @@ xmlns:c14=\"http://schemas.microsoft.com/office/drawing/2007/8/2/chart\""); writer.WriteString(L">"); } EElementType CT_PivotSource::getType(){return et_ct_pivotsource;} - CT_Style::CT_Style() : m_val(NULL), m_namespace(L"c") + CT_Style1::CT_Style1() { + m_val = NULL; + } + CT_Style1::~CT_Style1() + { + if(NULL != m_val) + delete m_val; + } + void CT_Style1::fromXML(XmlUtils::CXmlLiteReader& oReader) + { + ReadAttributes(oReader); + + if(!oReader.IsEmptyNode()) + oReader.ReadTillEnd(); + } + void CT_Style1::toXML(const std::wstring& sNodeName, NSStringUtils::CStringBuilder& writer) const{ + writer.WriteString(L"<"); + writer.WriteString(sNodeName); + if(NULL != m_val) + { + WritingStringAttrInt(L"val", *m_val); + } + writer.WriteString(L"/>"); + } + EElementType CT_Style1::getType(){return et_ct_style1;} + void CT_Style1::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) + { + WritingElement_ReadAttributes_Start_No_NS( oReader ) + if(_T("val") == wsName) + { + unsigned char* pNewElem = new unsigned char; + std::wstring sVal = oReader.GetText(); + *pNewElem = _ttoi(sVal.c_str()); + m_val = pNewElem; + } + WritingElement_ReadAttributes_End_No_NS( oReader ) + } + CT_Style::CT_Style() + { + m_val = NULL; } CT_Style::~CT_Style() { if(NULL != m_val) delete m_val; } - void CT_Style::fromXML(XmlUtils::CXmlLiteReader& oReader) - { - m_namespace = XmlUtils::GetNamespace(oReader.GetName()); - ReadAttributes(oReader); + void CT_Style::fromXML(XmlUtils::CXmlLiteReader& oReader){ + ReadAttributes(oReader); - if(!oReader.IsEmptyNode()) - oReader.ReadTillEnd(); + if(!oReader.IsEmptyNode()) + oReader.ReadTillEnd(); } - void CT_Style::toXML(NSStringUtils::CStringBuilder& writer) const - { - writer.WriteString(L"<" + m_namespace + L":style"); + void CT_Style::toXML(const std::wstring& sNodeName, NSStringUtils::CStringBuilder& writer) const{ + writer.WriteString(L"<"); + writer.WriteString(sNodeName); if(NULL != m_val) { WritingStringAttrInt(L"val", *m_val); @@ -14411,7 +14452,7 @@ xmlns:c14=\"http://schemas.microsoft.com/office/drawing/2007/8/2/chart\""); *pNewElem = _ttoi(sVal.c_str()); m_val = pNewElem; } - WritingElement_ReadAttributes_End_No_NS( oReader ) + WritingElement_ReadAttributes_End_No_NS( oReader ) } CT_TextLanguageID::CT_TextLanguageID() { @@ -14536,8 +14577,9 @@ xmlns:c14=\"http://schemas.microsoft.com/office/drawing/2007/8/2/chart\""); std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName()); if(_T("style") == sName) { - m_style = new CT_Style; - m_style->fromXML(oReader); + CT_Style* pNewElem = new CT_Style; + pNewElem->fromXML(oReader); + m_style = pNewElem; } } } @@ -14552,8 +14594,8 @@ xmlns:c14=\"http://schemas.microsoft.com/office/drawing/2007/8/2/chart\""); writer.WriteString(L">"); if(NULL != m_style) { - m_style->m_namespace = L"c14"; - m_style->toXML(writer); + std::wstring sNodeName = _T("c14:style"); + m_style->toXML(sNodeName, writer); } writer.WriteString(L"fromXML(oReader); + CT_Style1* pNewElem = new CT_Style1; + pNewElem->fromXML(oReader); + m_style = pNewElem; } } } @@ -14606,7 +14649,8 @@ xmlns:c14=\"http://schemas.microsoft.com/office/drawing/2007/8/2/chart\""); writer.WriteString(L">"); if(NULL != m_style) { - m_style->toXML(writer); + std::wstring sNodeName = _T("c:style"); + m_style->toXML(sNodeName, writer); } writer.WriteString(L" m_Choice; + //Member AlternateContentFallback* m_Fallback; - AlternateContent(); ~AlternateContent(); void fromXML(XmlUtils::CXmlLiteReader& oReader); @@ -2817,22 +2822,22 @@ namespace OOX class AlternateContentChoice { public: + //Member CT_Style* m_style; + //Attribute std::wstring* m_Requires; - AlternateContentChoice(); ~AlternateContentChoice(); void fromXML(XmlUtils::CXmlLiteReader& oReader); void toXML(const std::wstring& sNodeName, NSStringUtils::CStringBuilder& writer) const; EElementType getType(); - private: - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); + private: void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); }; class AlternateContentFallback { public: - CT_Style* m_style; - + //Member + CT_Style1* m_style; AlternateContentFallback(); ~AlternateContentFallback(); void fromXML(XmlUtils::CXmlLiteReader& oReader); diff --git a/Common/DocxFormat/Source/XlsxFormat/Chart/ChartSerializeEx.cpp b/Common/DocxFormat/Source/XlsxFormat/Chart/ChartSerializeEx.cpp index f4d2eaa02f..7c2e47b490 100644 --- a/Common/DocxFormat/Source/XlsxFormat/Chart/ChartSerializeEx.cpp +++ b/Common/DocxFormat/Source/XlsxFormat/Chart/ChartSerializeEx.cpp @@ -97,7 +97,7 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"" m_oTxPr->m_name = L"cx:txPr"; writer.WriteString(m_oTxPr->toXML()); } - if (m_oClrMapOvr.IsInit()) + if(m_oClrMapOvr.IsInit()) { m_oClrMapOvr->m_name = L"cx:clrMapOvr"; writer.WriteString(m_oClrMapOvr->toXML()); @@ -156,7 +156,7 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"" if(m_legend.IsInit()) { - m_legend->toXML(writer); + //m_legend->toXML(writer); } if(m_oExtLst.IsInit()) { @@ -185,10 +185,6 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"" CData *item = new CData(oReader); m_arData.push_back(item); } - else if (L"externalData" == sName) - { - m_externalData = oReader; - } else if( L"extLst" == sName) { m_oExtLst = oReader; @@ -199,11 +195,7 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"" { writer.WriteString(L""); - if (m_externalData.IsInit()) - { - m_externalData->toXML(writer); - } - for (size_t i = 0; i < m_arData.size(); ++i) + for(size_t i = 0; i < m_arData.size(); ++i) { m_arData[i]->toXML(writer); } @@ -418,7 +410,7 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"" void CData::toXML(NSStringUtils::CStringBuilder& writer) const { writer.WriteString(L"ToString()); writer.WriteString(L">"); for (size_t i = 0; i < m_arDimension.size(); ++i) @@ -432,29 +424,6 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"" writer.WriteString(L""); } EElementType CData::getType() const {return et_ct_Data;} -//---------------------------------------------------------------------------------------------- - void CExternalData::fromXML(XmlUtils::CXmlLiteReader& oReader) - { - ReadAttributes(oReader); - - if (oReader.IsEmptyNode()) - return; - } - void CExternalData::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start_No_NS(oReader) - WritingElement_ReadAttributes_Read_if(oReader, L"id", m_id) - WritingElement_ReadAttributes_Read_else_if(oReader, L"autoUpdate", m_autoUpdate) - WritingElement_ReadAttributes_End_No_NS(oReader) - } - void CExternalData::toXML(NSStringUtils::CStringBuilder& writer) const - { - writer.WriteString(L""); - } - EElementType CExternalData::getType() const { return et_ct_ExternalData; } //------------------------------------------------------------------------------------------------ CPlotArea::~CPlotArea() { @@ -585,7 +554,7 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"" } void CPlotSurface::toXML(NSStringUtils::CStringBuilder& writer) const { - writer.WriteString(L""); + writer.WriteString(L""); if (m_oSpPr.IsInit()) { @@ -596,7 +565,7 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"" { writer.WriteString(m_oExtLst->toXMLWithNS(L"cx:")); } - writer.WriteString(L""); + writer.WriteString(L""); } EElementType CPlotSurface::getType() const {return et_ct_PlotSurface;} //------------------------------------------------------------------------------------------------ @@ -680,7 +649,7 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"" void CAxis::toXML(NSStringUtils::CStringBuilder& writer) const { writer.WriteString(L"ToString()); WritingStringNullableAttrString(L"hidden", m_hidden, *m_hidden ? L"true" : L"false"); writer.WriteString(L">"); if(m_valScaling.IsInit()) @@ -958,35 +927,34 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"" WritingStringNullableAttrString(L"uniqueId", m_sUniqueId, m_sUniqueId.get()) WritingStringNullableAttrInt(L"formatIdx", m_nFormatIdx, m_nFormatIdx.get()) writer.WriteString(L">"); + if(m_dataId.IsInit()) + { + writer.WriteString(L""); + writer.WriteString(m_dataId->ToString()); + writer.WriteString(L""); + } if (m_tx.IsInit()) { m_tx->toXML(writer); } - for (size_t i = 0; i < m_arDataPt.size(); i++) - { - m_arDataPt[i]->toXML(writer); - } - if (m_dataLabels.IsInit()) - { - m_dataLabels->toXML(writer); - } - if (m_dataId.IsInit()) - { - writer.WriteString(L"ToString()); - writer.WriteString(L"/>"); - } if (m_layoutPr.IsInit()) { m_layoutPr->toXML(writer); } + if (m_dataLabels.IsInit()) + { + m_dataLabels->toXML(writer); + } for (size_t i = 0; i < m_arAxisId.size(); i++) { writer.WriteString(L""); writer.WriteString(std::to_wstring(m_arAxisId[i])); writer.WriteString(L""); } - + for (size_t i = 0; i < m_arDataPt.size(); i++) + { + m_arDataPt[i]->toXML(writer); + } if (m_oSpPr.IsInit()) { m_oSpPr->m_namespace = L"cx"; @@ -1193,7 +1161,7 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"" void CNumericLevel::toXML(NSStringUtils::CStringBuilder& writer) const { writer.WriteString(L""); @@ -1272,7 +1240,7 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"" void CStringLevel::toXML(NSStringUtils::CStringBuilder& writer) const { writer.WriteString(L""); @@ -1602,8 +1570,6 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"" //---------------------------------------------------------------------------------------------- void CDataLabel::fromXML(XmlUtils::CXmlLiteReader& oReader) { - ReadAttributes(oReader); - if ( oReader.IsEmptyNode() ) return; @@ -1689,16 +1655,8 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"" delete m_arDataLabelHidden[i]; m_arDataLabelHidden.clear(); } - void CDataLabels::ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start_No_NS(oReader) - WritingElement_ReadAttributes_Read_if(oReader, L"pos", m_pos) - WritingElement_ReadAttributes_End_No_NS(oReader) - } void CDataLabels::fromXML(XmlUtils::CXmlLiteReader& oReader) { - ReadAttributes(oReader); - if ( oReader.IsEmptyNode() ) return; @@ -1744,10 +1702,7 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"" void CDataLabels::toXML(NSStringUtils::CStringBuilder& writer) const { - writer.WriteString(L"ToString()) - writer.WriteString(L">"); + writer.WriteString(L""); if (m_numFmt.IsInit()) { diff --git a/Common/DocxFormat/Source/XlsxFormat/Chart/ChartSerializeEx.h b/Common/DocxFormat/Source/XlsxFormat/Chart/ChartSerializeEx.h index 3692c05d0f..9a37f1fd94 100644 --- a/Common/DocxFormat/Source/XlsxFormat/Chart/ChartSerializeEx.h +++ b/Common/DocxFormat/Source/XlsxFormat/Chart/ChartSerializeEx.h @@ -404,8 +404,6 @@ namespace ChartEx virtual std::wstring toXML() const { return L""; } virtual EElementType getType () const; - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - nullable m_numFmt; nullable m_oTxPr; nullable m_oSpPr; @@ -414,8 +412,6 @@ namespace ChartEx nullable_string m_separator; std::vector m_arDataLabel; std::vector m_arDataLabelHidden; - - nullable> m_pos; }; //------------------------------------------------------------------------------ class CDataPoint : public WritingElement @@ -489,7 +485,7 @@ namespace ChartEx void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - nullable> m_gapWidth; //typedef ST_DoubleOrAutomatic ST_GapWidthRatio + nullable> m_gapWidth; //typedef ST_DoubleOrAutomatic ST_GapWidthRatio }; //------------------------------------------------------------------------------ class CValScaling : public WritingElement @@ -510,7 +506,7 @@ namespace ChartEx nullable> m_max; nullable> m_min; - nullable> m_majorUnit; //ST_ValueAxisUnit == ST_DoubleOrAutomatic + nullable> m_majorUnit; //typedef ST_DoubleOrAutomatic ST_ValueAxisUnit nullable> m_minorUnit; }; //------------------------------------------------------------------------------ @@ -625,8 +621,8 @@ namespace ChartEx nullable m_oTxPr; nullable m_oExtLst; - nullable_uint m_id; - nullable_bool m_hidden; + nullable> m_id; + nullable_bool m_hidden; }; //------------------------------------------------------------------------------ class CPlotSurface : public WritingElement @@ -805,25 +801,7 @@ namespace ChartEx std::vector m_arDimension; nullable m_oExtLst; - nullable_uint m_id; - }; -//------------------------------------------------------------------------------ - class CExternalData : public WritingElement - { - public: - WritingElement_AdditionConstructors(CExternalData) - CExternalData() {} - - virtual void fromXML(XmlUtils::CXmlNode& node) {} - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader); - virtual void toXML(NSStringUtils::CStringBuilder& writer) const; - virtual std::wstring toXML() const { return L""; } - virtual EElementType getType() const; - - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader); - - nullable_string m_id; - nullable_bool m_autoUpdate; + nullable> m_id; }; //------------------------------------------------------------------------------ class CChartData : public WritingElement @@ -840,7 +818,6 @@ namespace ChartEx virtual std::wstring toXML() const { return L""; } virtual EElementType getType () const; - nullable m_externalData; std::vector m_arData; nullable m_oExtLst; }; diff --git a/Common/DocxFormat/Source/XlsxFormat/Chart/ChartStyle.h b/Common/DocxFormat/Source/XlsxFormat/Chart/ChartStyle.h deleted file mode 100644 index af1bf5bdd2..0000000000 --- a/Common/DocxFormat/Source/XlsxFormat/Chart/ChartStyle.h +++ /dev/null @@ -1,346 +0,0 @@ -/* - * (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 - * - */ -//Generated code -#pragma once - -#include "../../Base/Nullable.h" -#include "../../DocxFormat/Drawing/DrawingExt.h" -#include "../SimpleTypes_Spreadsheet.h" -#include "../WritingElement.h" -#include "../../../../../ASCOfficePPTXFile/PPTXFormat/Logic/StyleRef.h" -#include "../../../../../ASCOfficePPTXFile/PPTXFormat/Logic/FontRef.h" -#include "../../../../../ASCOfficePPTXFile/PPTXFormat/Logic/RunProperties.h" - -namespace OOX -{ -namespace Spreadsheet -{ -namespace ChartEx -{ - class CStyleEntry : public WritingElement - { - public: - WritingElement_AdditionConstructors(CStyleEntry) - - CStyleEntry() {} - - virtual void fromXML(XmlUtils::CXmlNode& node) {} - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - m_name = XmlUtils::GetNameNoNS(oReader.GetName()); - if (oReader.IsEmptyNode()) - return; - - int nParentDepth = oReader.GetDepth(); - while (oReader.ReadNextSiblingNode(nParentDepth)) - { - std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName()); - if (L"extLst" == sName) - { - m_extLst = oReader; - } - else if(L"bodyPr" == sName) - { - m_bodyPr = oReader; - } - else if (L"spPr" == sName) - { - m_spPr = oReader; - } - else if (L"defRPr" == sName) - { - m_defRPr = oReader; - } - else if (L"lineWidthScale" == sName) - { - m_lineWidthScale = oReader.GetText(); - } - else if (L"lnRef" == sName) - { - m_lnRef.fromXML(oReader); - } - else if (L"fillRef" == sName) - { - m_fillRef.fromXML(oReader); - } - else if (L"effectRef" == sName) - { - m_effectRef.fromXML(oReader); - } - else if (L"fontRef" == sName) - { - m_fontRef.fromXML(oReader); - } - } - } - virtual void toXML(NSStringUtils::CStringBuilder& writer) const - { - writer.WriteString(L""); - - writer.WriteString(m_lnRef.toXML()); - writer.WriteString(m_fillRef.toXML()); - writer.WriteString(m_effectRef.toXML()); - writer.WriteString(m_fontRef.toXML()); - - if (m_spPr.IsInit()) - { - m_spPr->m_namespace = L"cs"; - writer.WriteString(m_spPr->toXML()); - } - if (m_defRPr.IsInit()) - { - m_defRPr->m_name = L"cs:defRPr"; - writer.WriteString(m_defRPr->toXML()); - } - if (m_bodyPr.IsInit()) - { - m_bodyPr->m_namespace = L"cs"; - writer.WriteString(m_bodyPr->toXML()); - } - writer.WriteString(L""); - } - virtual std::wstring toXML() const { return L""; } - virtual EElementType getType() - { - return et_cs_StyleEntry; - } - BYTE getTypeStyleEntry() - { - if (m_name == L"axisTitle") return 1; - else if (m_name == L"categoryAxis") return 2; - else if (m_name == L"chartArea") return 3; - else if (m_name == L"dataLabel") return 4; - else if (m_name == L"dataLabelCallout") return 5; - else if (m_name == L"dataPoint") return 6; - else if (m_name == L"dataPoint3D") return 7; - else if (m_name == L"dataPointLine") return 8; - else if (m_name == L"dataPointMarker") return 9; - else if (m_name == L"dataPointWireframe") return 10; - else if (m_name == L"dataTable") return 11; - else if (m_name == L"downBar") return 12; - else if (m_name == L"dropLine") return 13; - else if (m_name == L"errorBar") return 14; - else if (m_name == L"floor") return 15; - else if (m_name == L"gridlineMajor") return 16; - else if (m_name == L"gridlineMinor") return 17; - else if (m_name == L"hiLoLine") return 18; - else if (m_name == L"leaderLine") return 19; - else if (m_name == L"legend") return 20; - else if (m_name == L"plotArea") return 21; - else if (m_name == L"plotArea3D") return 22; - else if (m_name == L"seriesAxis") return 23; - else if (m_name == L"seriesLine") return 24; - else if (m_name == L"title") return 25; - else if (m_name == L"trendline") return 26; - else if (m_name == L"trendlineLabel") return 27; - else if (m_name == L"upBar") return 28; - else if (m_name == L"valueAxis") return 29; - else if (m_name == L"wall") return 30; - else - return 0; - } - void setTypeStyleEntry(BYTE type) - { - switch (type) - { - case 1: m_name = L"axisTitle"; break; - case 2: m_name = L"categoryAxis"; break; - case 3: m_name = L"chartArea"; break; - case 4: m_name = L"dataLabel"; break; - case 5: m_name = L"dataLabelCallout"; break; - case 6: m_name = L"dataPoint"; break; - case 7: m_name = L"dataPoint3D"; break; - case 8: m_name = L"dataPointLine"; break; - case 9: m_name = L"dataPointMarker"; break; - case 10: m_name = L"dataPointWireframe"; break; - case 11: m_name = L"dataTable"; break; - case 12: m_name = L"downBar"; break; - case 13: m_name = L"dropLine"; break; - case 14: m_name = L"errorBar"; break; - case 15: m_name = L"floor"; break; - case 16: m_name = L"gridlineMajor"; break; - case 17: m_name = L"gridlineMinor"; break; - case 18: m_name = L"hiLoLine"; break; - case 19: m_name = L"leaderLine"; break; - case 20: m_name = L"legend"; break; - case 21: m_name = L"plotArea"; break; - case 22: m_name = L"plotArea3D"; break; - case 23: m_name = L"seriesAxis"; break; - case 24: m_name = L"seriesLine"; break; - case 25: m_name = L"title"; break; - case 26: m_name = L"trendline"; break; - case 27: m_name = L"trendlineLabel"; break; - case 28: m_name = L"upBar"; break; - case 29: m_name = L"valueAxis"; break; - case 30: m_name = L"wall"; break; - default: - break; - } - } - - nullable_double m_lineWidthScale; - PPTX::Logic::StyleRef m_lnRef; - PPTX::Logic::StyleRef m_fillRef; - PPTX::Logic::StyleRef m_effectRef; - PPTX::Logic::FontRef m_fontRef; - - nullable m_defRPr; - nullable m_bodyPr; - nullable m_spPr; - - nullable m_extLst; - private: - std::wstring m_name; - }; - - //------------------------------------------------------------------------------ - class CMarkerLayout : public WritingElement - { - public: - WritingElement_AdditionConstructors(CMarkerLayout) - - CMarkerLayout(){} - - virtual void fromXML(XmlUtils::CXmlNode& node) {} - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - ReadAttributes(oReader); - } - virtual void toXML(NSStringUtils::CStringBuilder& writer) const - { - writer.WriteString(L"ToString()) - WritingStringNullableAttrInt(L"size", m_size, *m_size) - writer.WriteString(L"/>"); - } - virtual std::wstring toXML() const { return L""; } - virtual EElementType getType() - { - return et_cs_MarkerLayout; - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start_No_NS(oReader) - WritingElement_ReadAttributes_Read_if(oReader, L"symbol", m_symbol) - WritingElement_ReadAttributes_Read_else_if(oReader, L"size", m_size) - WritingElement_ReadAttributes_End_No_NS(oReader) - } - nullable> m_symbol; - nullable_uint m_size; - }; - -//------------------------------------------------------------------------------ - class CChartStyle : public WritingElement - { - public: - CChartStyle() {} - virtual ~CChartStyle() - { - for (size_t i = 0; i < m_arStyleEntries.size(); ++i) - if (m_arStyleEntries[i]) delete m_arStyleEntries[i]; - - m_arStyleEntries.clear(); - } - WritingElement_AdditionConstructors(CChartStyle) - - virtual void fromXML(XmlUtils::CXmlNode& node) {} - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - ReadAttributes(oReader); - - if (oReader.IsEmptyNode()) - return; - - int nParentDepth = oReader.GetDepth(); - while (oReader.ReadNextSiblingNode(nParentDepth)) - { - std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName()); - if (L"extLst" == sName) - { - m_extLst = oReader; - } - else if (L"dataPointMarkerLayout" == sName) - { - m_dataPointMarkerLayout = oReader; - } - else - { - m_arStyleEntries.push_back(new CStyleEntry(oReader)); - } - } - } - virtual void toXML(NSStringUtils::CStringBuilder& writer) const - { - writer.WriteString(L""); - - for (size_t i = 0; i < m_arStyleEntries.size(); ++i) - m_arStyleEntries[i]->toXML(writer); - - if (m_dataPointMarkerLayout.IsInit()) - { - m_dataPointMarkerLayout->toXML(writer); - } - if (m_extLst.IsInit()) - { - writer.WriteString(m_extLst->toXML()); - } - writer.WriteString(L""); - } - virtual std::wstring toXML() const - { - NSStringUtils::CStringBuilder writer; - toXML(writer); - return writer.GetData(); - } - virtual EElementType getType() const - { - return et_cs_ChartStyle; - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start_No_NS(oReader) - WritingElement_ReadAttributes_Read_if(oReader, L"id", m_id) - WritingElement_ReadAttributes_End_No_NS(oReader) - } - nullable_uint m_id; - std::vector m_arStyleEntries; - nullable m_dataPointMarkerLayout; - nullable m_extLst; - }; -} -} -} - diff --git a/Common/DocxFormat/Source/XlsxFormat/Drawing/CellAnchor.h b/Common/DocxFormat/Source/XlsxFormat/Drawing/CellAnchor.h index 46c8aefab0..6961837112 100644 --- a/Common/DocxFormat/Source/XlsxFormat/Drawing/CellAnchor.h +++ b/Common/DocxFormat/Source/XlsxFormat/Drawing/CellAnchor.h @@ -70,21 +70,6 @@ namespace OOX { return _T(""); } - std::wstring toVmlXML() const - { - std::wstring sAnchor; - sAnchor += m_oFrom->m_oCol->ToString() + L","; - sAnchor += std::to_wstring(m_oFrom->m_oColOff->ToPx()) + L","; - sAnchor += m_oFrom->m_oRow->ToString() + L","; - sAnchor += std::to_wstring(m_oFrom->m_oRowOff->ToPx()) + L","; - sAnchor += m_oTo->m_oCol->ToString() + L","; - sAnchor += std::to_wstring(m_oTo->m_oColOff->ToPx()) + L","; - sAnchor += m_oTo->m_oRow->ToString() + L","; - sAnchor += std::to_wstring(m_oTo->m_oRowOff->ToPx()); - - return sAnchor; - } - virtual void toXML(NSStringUtils::CStringBuilder& writer) const { if(isValid() == false) return; diff --git a/Common/DocxFormat/Source/XlsxFormat/FileFactory_Spreadsheet.cpp b/Common/DocxFormat/Source/XlsxFormat/FileFactory_Spreadsheet.cpp index ba9ad00a0f..31d614a164 100644 --- a/Common/DocxFormat/Source/XlsxFormat/FileFactory_Spreadsheet.cpp +++ b/Common/DocxFormat/Source/XlsxFormat/FileFactory_Spreadsheet.cpp @@ -64,7 +64,7 @@ #include "ExternalLinks/ExternalLinkPath.h" #include "../DocxFormat/Diagram/DiagramDrawing.h" #include "../DocxFormat/Diagram/DiagramData.h" -#include "Chart//ChartDrawing.h" +#include "../DocxFormat/ChartDrawing.h" #ifdef CreateFile #undef CreateFile @@ -129,13 +129,13 @@ namespace OOX return smart_ptr(new CConnectionsFile( pMain, oRootPath, oFileName )); else if ( oRelation.Type() == OOX::FileTypes::Chart ) - return smart_ptr(new CChartFile( pMain, oRootPath, oFileName )); + return smart_ptr(new CChartSpace( pMain, oRootPath, oFileName )); else if ( oRelation.Type() == OOX::FileTypes::ChartEx ) - return smart_ptr(new CChartExFile( pMain, oRootPath, oFileName )); + return smart_ptr(new CChartSpaceEx( pMain, oRootPath, oFileName )); else if ( oRelation.Type() == OOX::FileTypes::ChartStyle ) - return smart_ptr(new CChartStyleFile( pMain, oRootPath, oFileName )); - else if ( oRelation.Type() == OOX::FileTypes::ChartColors ) - return smart_ptr(new CChartColorsFile( pMain, oRootPath, oFileName )); + return smart_ptr(new CChartStyle( pMain, oRootPath, oFileName )); + else if ( oRelation.Type() == OOX::FileTypes::ChartColorStyle ) + return smart_ptr(new CChartColorStyle( pMain, oRootPath, oFileName )); else if ( oRelation.Type() == OOX::FileTypes::ExternalLinkPath || oRelation.Type() == OOX::FileTypes::ExternalLinkPathMissing || oRelation.Type() == OOX::FileTypes::ExternalLinkPathStartup || @@ -245,13 +245,13 @@ namespace OOX else if ( pRelation->Type() == FileTypes::Persons) return smart_ptr(new CPersonList( pMain, oRootPath, oFileName)); else if ( pRelation->Type() == OOX::FileTypes::Chart ) - return smart_ptr(new CChartFile( pMain, oRootPath, oFileName )); + return smart_ptr(new CChartSpace( pMain, oRootPath, oFileName )); else if ( pRelation->Type() == OOX::FileTypes::ChartEx ) - return smart_ptr(new CChartExFile( pMain, oRootPath, oFileName )); + return smart_ptr(new CChartSpaceEx( pMain, oRootPath, oFileName )); else if ( pRelation->Type() == OOX::FileTypes::ChartStyle ) - return smart_ptr(new CChartStyleFile( pMain, oRootPath, oFileName )); - else if ( pRelation->Type() == OOX::FileTypes::ChartColors ) - return smart_ptr(new CChartColorsFile( pMain, oRootPath, oFileName )); + return smart_ptr(new CChartStyle( pMain, oRootPath, oFileName )); + else if ( pRelation->Type() == OOX::FileTypes::ChartColorStyle ) + return smart_ptr(new CChartColorStyle( pMain, oRootPath, oFileName )); else if ( pRelation->Type() == FileTypes::ExternalLinks ) return smart_ptr(new CExternalLink( pMain, oRootPath, oFileName )); else if ( pRelation->Type() == OOX::FileTypes::ExternalLinkPath || diff --git a/Common/DocxFormat/Source/XlsxFormat/SimpleTypes_Spreadsheet.h b/Common/DocxFormat/Source/XlsxFormat/SimpleTypes_Spreadsheet.h index a9c7620a22..3399b34e9f 100644 --- a/Common/DocxFormat/Source/XlsxFormat/SimpleTypes_Spreadsheet.h +++ b/Common/DocxFormat/Source/XlsxFormat/SimpleTypes_Spreadsheet.h @@ -1526,14 +1526,7 @@ namespace SimpleTypes celltypeInlineStr = 3, celltypeNumber = 4, celltypeSharedString = 5, - celltypeStr = 6, -//--------------- for our using - celltypePercentage = 7, - celltypeScientific = 8, - celltypeFraction = 9, - celltypeTime = 10, - celltypeCurrency = 11, - celltypeDateTime = 12 + celltypeStr = 6 }; template class CCellTypeType : public CSimpleType diff --git a/Common/DocxFormat/Source/XlsxFormat/Styles/NumFmts.h b/Common/DocxFormat/Source/XlsxFormat/Styles/NumFmts.h index ef5da6c4f1..93ea4397b7 100644 --- a/Common/DocxFormat/Source/XlsxFormat/Styles/NumFmts.h +++ b/Common/DocxFormat/Source/XlsxFormat/Styles/NumFmts.h @@ -146,15 +146,8 @@ namespace OOX { std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName()); - if (L"numFmt" == sName) - { - m_arrItems.push_back(new CNumFmt(oReader)); - - if (m_arrItems.back()->m_oNumFmtId.IsInit()) - { - m_mapNumFmtIndex.insert(std::make_pair(m_arrItems.back()->m_oNumFmtId->GetValue(), m_arrItems.size() - 1)); - } - } + if ( _T("numFmt") == sName ) + m_arrItems.push_back( new CNumFmt( oReader )); } } @@ -167,13 +160,11 @@ namespace OOX void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) { WritingElement_ReadAttributes_Start( oReader ) - WritingElement_ReadAttributes_Read_if ( oReader, _T("count"), m_oCount ) + WritingElement_ReadAttributes_Read_if ( oReader, _T("count"), m_oCount ) WritingElement_ReadAttributes_End( oReader ) } public: - nullable> m_oCount; - - std::map m_mapNumFmtIndex; + nullable> m_oCount; }; } //Spreadsheet } // namespace OOX diff --git a/Common/DocxFormat/Source/XlsxFormat/Styles/rPr.cpp b/Common/DocxFormat/Source/XlsxFormat/Styles/rPr.cpp index fdd0c0504c..7ad8926186 100644 --- a/Common/DocxFormat/Source/XlsxFormat/Styles/rPr.cpp +++ b/Common/DocxFormat/Source/XlsxFormat/Styles/rPr.cpp @@ -338,9 +338,7 @@ namespace OOX BYTE ucR; BYTE ucG; BYTE ucB; - int index = m_oColor->m_oIndexed->GetValue(); - //64 is auto color - if(64 != index && OOX::Spreadsheet::CIndexedColors::GetDefaultRGBAByIndex(index, ucR, ucG, ucB, ucA)) + if(OOX::Spreadsheet::CIndexedColors::GetDefaultRGBAByIndex(m_oColor->m_oIndexed->GetValue(), ucR, ucG, ucB, ucA)) { xColorType |= 0x1; xColorType |= 0x4; diff --git a/Common/DocxFormat/Source/XlsxFormat/Workbook/Workbook.h b/Common/DocxFormat/Source/XlsxFormat/Workbook/Workbook.h index 627617e644..d323dc92bf 100644 --- a/Common/DocxFormat/Source/XlsxFormat/Workbook/Workbook.h +++ b/Common/DocxFormat/Source/XlsxFormat/Workbook/Workbook.h @@ -47,7 +47,7 @@ namespace OOX namespace Spreadsheet { class CPersonList; - //необработанные child: + //необработанные child: // // // @@ -60,6 +60,8 @@ namespace OOX // // // + // + // class CWorkbook : public OOX::File, public OOX::IFileContainer, public WritingElement { public: @@ -137,8 +139,6 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"> if(m_oWorkbookPr.IsInit()) m_oWorkbookPr->toXML(writer); - if (m_oWorkbookProtection.IsInit()) - m_oWorkbookProtection->toXML(writer); if(m_oBookViews.IsInit()) m_oBookViews->toXML(writer); if(m_oSheets.IsInit()) @@ -174,8 +174,6 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"> m_oSheets = oReader; else if ( L"workbookPr" == sName ) m_oWorkbookPr = oReader; - else if (L"workbookProtection" == sName) - m_oWorkbookProtection = oReader; else if ( L"externalReferences" == sName ) m_oExternalReferences = oReader; else if ( L"extLst" == sName ) @@ -283,7 +281,6 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"> } CPath m_oReadPath; - nullable m_oWorkbookProtection; nullable m_oBookViews; nullable m_oDefinedNames; nullable m_oSheets; diff --git a/Common/DocxFormat/Source/XlsxFormat/Workbook/WorkbookPr.h b/Common/DocxFormat/Source/XlsxFormat/Workbook/WorkbookPr.h index 21bf4a002d..028d102497 100644 --- a/Common/DocxFormat/Source/XlsxFormat/Workbook/WorkbookPr.h +++ b/Common/DocxFormat/Source/XlsxFormat/Workbook/WorkbookPr.h @@ -40,6 +40,8 @@ namespace OOX { namespace Spreadsheet { + //необработано: + // class CWorkbookPr : public WritingElement { public: @@ -140,74 +142,6 @@ namespace OOX nullable> m_oUpdateLinks; }; - class CWorkbookProtection : public WritingElement - { - public: - WritingElement_AdditionConstructors(CWorkbookProtection) - CWorkbookProtection() - { - } - virtual ~CWorkbookProtection() - { - } - virtual void fromXML(XmlUtils::CXmlNode& node) - { - } - virtual std::wstring toXML() const - { - return L""; - } - virtual void toXML(NSStringUtils::CStringBuilder& writer) const - { - writer.WriteString(L"ToString()); - WritingStringNullableAttrString(L"workbookHashValue", m_oWorkbookHashValue, m_oWorkbookHashValue.get()); - WritingStringNullableAttrString(L"workbookSaltValue", m_oWorkbookSaltValue, m_oWorkbookSaltValue.get()); - WritingStringNullableAttrInt(L"workbookSpinCount", m_oWorkbookSpinCount, m_oWorkbookSpinCount->GetValue()); - writer.WriteString(L"/>"); - } - virtual void fromXML(XmlUtils::CXmlLiteReader& oReader) - { - ReadAttributes(oReader); - - if (!oReader.IsEmptyNode()) - oReader.ReadTillEnd(); - } - - virtual EElementType getType() const - { - return et_x_WorkbookProtection; - } - void ReadAttributes(XmlUtils::CXmlLiteReader& oReader) - { - WritingElement_ReadAttributes_Start(oReader) - WritingElement_ReadAttributes_Read_if(oReader, (L"workbookAlgorithmName"), m_oWorkbookAlgorithmName) - WritingElement_ReadAttributes_Read_else_if(oReader, (L"workbookHashValue"), m_oWorkbookHashValue) - WritingElement_ReadAttributes_Read_else_if(oReader, (L"workbookSaltValue"), m_oWorkbookSaltValue) - WritingElement_ReadAttributes_Read_else_if(oReader, (L"workbookSpinCount"), m_oWorkbookSpinCount) - WritingElement_ReadAttributes_Read_else_if(oReader, (L"revisionsAlgorithmName"), m_oRevisionsAlgorithmName) - WritingElement_ReadAttributes_Read_else_if(oReader, (L"revisionsHashValue"), m_oRevisionsHashValue) - WritingElement_ReadAttributes_Read_else_if(oReader, (L"revisionsSaltValue"), m_oRevisionsSaltValue) - WritingElement_ReadAttributes_Read_else_if(oReader, (L"revisionsSpinCount"), m_oRevisionsSpinCount) - WritingElement_ReadAttributes_Read_else_if(oReader, (L"lockRevision"), m_oLockRevision) - WritingElement_ReadAttributes_Read_else_if(oReader, (L"lockStructure"), m_oLockStructure) - WritingElement_ReadAttributes_Read_else_if(oReader, (L"lockWindows"), m_oLockWindows) - WritingElement_ReadAttributes_End(oReader) - } - nullable> m_oLockRevision; - nullable> m_oLockStructure; - nullable> m_oLockWindows; - - nullable> m_oWorkbookAlgorithmName; - nullable> m_oWorkbookSpinCount; - nullable_string m_oWorkbookHashValue; - nullable_string m_oWorkbookSaltValue; - - nullable> m_oRevisionsAlgorithmName; - nullable> m_oRevisionsSpinCount; - nullable_string m_oRevisionsHashValue; - nullable_string m_oRevisionsSaltValue; - }; } //Spreadsheet } // namespace OOX diff --git a/Common/DocxFormat/Source/XlsxFormat/Worksheets/SheetData.cpp b/Common/DocxFormat/Source/XlsxFormat/Worksheets/SheetData.cpp index dc37ca2dee..0d8f7654c1 100644 --- a/Common/DocxFormat/Source/XlsxFormat/Worksheets/SheetData.cpp +++ b/Common/DocxFormat/Source/XlsxFormat/Worksheets/SheetData.cpp @@ -1013,7 +1013,6 @@ namespace OOX } //o:SmartTags, x:PhoneticText } - PrepareForBinaryWriter(); } void CCell::ReadComment(XmlUtils::CXmlLiteReader& oReader, CCommentItem* pComment) @@ -1206,16 +1205,6 @@ namespace OOX } else if (xlsx_flat) { - if (false == m_oRef.IsInit()) - { - CWorksheet* sheet = xlsx_flat->m_arWorksheets.back(); - - xlsx_flat->m_nLastReadCol = (xlsx_flat->m_nLastReadCol < 0 ? 1 : xlsx_flat->m_nLastReadCol + 1); - //m_oRef = "R" + std::to_string(xlsx_flat->m_nLastReadRow) + "C" + std::to_string(xlsx_flat->m_nLastReadCol); - m_oRef = getCellAddressA(xlsx_flat->m_nLastReadRow, xlsx_flat->m_nLastReadCol); - } - setRowCol(xlsx_flat->m_nLastReadRow, xlsx_flat->m_nLastReadCol - 1); - if (false == xlsx_flat->m_pSharedStrings.IsInit()) { xlsx_flat->m_pSharedStrings = new CSharedStrings(m_pMainDocument); diff --git a/Common/DocxFormat/Source/XlsxFormat/WritingElement.h b/Common/DocxFormat/Source/XlsxFormat/WritingElement.h index e38f7d4192..be47fa44e2 100644 --- a/Common/DocxFormat/Source/XlsxFormat/WritingElement.h +++ b/Common/DocxFormat/Source/XlsxFormat/WritingElement.h @@ -119,8 +119,6 @@ namespace Spreadsheet WritingStringNullableAttr(name, WriteEncodeXmlStringHHHH, elem, val) #define WritingStringNullableAttrInt(name, elem, val) \ WritingStringNullableAttr(name, AddInt, elem, val) -#define WritingStringNullableAttrUInt(name, elem, val) \ - WritingStringNullableAttr(name, AddUInt, elem, val) #define WritingStringNullableAttrInt64(name, elem, val) \ WritingStringNullableAttr(name, AddInt64, elem, val) #define WritingStringNullableAttrDouble(name, elem, val) \ diff --git a/Common/base.pri b/Common/base.pri index ce717405e9..6edeb81d18 100644 --- a/Common/base.pri +++ b/Common/base.pri @@ -187,11 +187,6 @@ core_linux_64 { } core_mac_64 { CORE_BUILDS_PLATFORM_PREFIX = mac_64 - - apple_silicon { - CORE_BUILDS_PLATFORM_PREFIX = mac_arm64 - QMAKE_APPLE_DEVICE_ARCHS = arm64 - } } core_linux_arm { CORE_BUILDS_PLATFORM_PREFIX = arm diff --git a/DesktopEditor/common/File.cpp b/DesktopEditor/common/File.cpp index 2309b9f302..7b2129febc 100644 --- a/DesktopEditor/common/File.cpp +++ b/DesktopEditor/common/File.cpp @@ -1657,11 +1657,7 @@ namespace NSFile } std::wstring GetFileName(const std::wstring& sPath) { -#ifdef _WIN32 std::wstring::size_type nPos1 = sPath.rfind('\\'); -#else - std::wstring::size_type nPos1 = std::wstring::npos; -#endif std::wstring::size_type nPos2 = sPath.rfind('/'); std::wstring::size_type nPos = std::wstring::npos; @@ -1680,11 +1676,7 @@ namespace NSFile } std::wstring GetDirectoryName(const std::wstring& sPath) { -#ifdef _WIN32 std::wstring::size_type nPos1 = sPath.rfind('\\'); -#else - std::wstring::size_type nPos1 = std::wstring::npos; -#endif std::wstring::size_type nPos2 = sPath.rfind('/'); std::wstring::size_type nPos = std::wstring::npos; diff --git a/DesktopEditor/cximage/CxImage/ximage.cpp b/DesktopEditor/cximage/CxImage/ximage.cpp index 221840c39d..b0d43043ea 100644 --- a/DesktopEditor/cximage/CxImage/ximage.cpp +++ b/DesktopEditor/cximage/CxImage/ximage.cpp @@ -443,7 +443,7 @@ void CxImage::Bitfield2RGB(uint8_t *src, uint32_t redmask, uint32_t greenmask, u * \param bFlipImage: tune this parameter if the image is upsidedown * \return true if everything is ok */ -bool CxImage::CreateFromArray(uint8_t* pArray,uint32_t dwWidth,uint32_t dwHeight,uint32_t dwBitsperpixel, uint32_t dwBytesperline, bool bFlipImage, bool isBGRA) +bool CxImage::CreateFromArray(uint8_t* pArray,uint32_t dwWidth,uint32_t dwHeight,uint32_t dwBitsperpixel, uint32_t dwBytesperline, bool bFlipImage) { if (pArray==NULL) return false; if (!((dwBitsperpixel==1)||(dwBitsperpixel==4)||(dwBitsperpixel==8)|| @@ -459,18 +459,14 @@ bool CxImage::CreateFromArray(uint8_t* pArray,uint32_t dwWidth,uint32_t dwHeight uint8_t *dst,*src; - unsigned char ShiftR = isBGRA ? 2 : 0; - unsigned char ShiftG = 1; - unsigned char ShiftB = isBGRA ? 0 : 2; - for (uint32_t y = 0; yCreateGlobalForContext(); CNativeControlEmbed::CreateObjectBuilderInContext("CreateNativeEngine", m_context); CMemoryStreamEmbed::CreateObjectInContext ("CreateNativeMemoryStream", m_context); - CGraphicsEmbed::CreateObjectInContext ("CreateNativeGraphics", m_context); m_context->CreateContext(); JSSmart context_scope = m_context->CreateContextScope(); diff --git a/DesktopEditor/doctrenderer/docbuilder_p.h b/DesktopEditor/doctrenderer/docbuilder_p.h index 90897309e2..f65c099a11 100644 --- a/DesktopEditor/doctrenderer/docbuilder_p.h +++ b/DesktopEditor/doctrenderer/docbuilder_p.h @@ -49,7 +49,6 @@ #include "embed/NativeBuilderEmbed.h" #include "embed/NativeControlEmbed.h" #include "embed/MemoryStreamEmbed.h" -#include "embed/GraphicsEmbed.h" #ifdef LINUX #include #include diff --git a/DesktopEditor/doctrenderer/doctrenderer.cpp b/DesktopEditor/doctrenderer/doctrenderer.cpp index 79036eeca7..827a848b08 100644 --- a/DesktopEditor/doctrenderer/doctrenderer.cpp +++ b/DesktopEditor/doctrenderer/doctrenderer.cpp @@ -38,7 +38,6 @@ #include "embed/NativeControlEmbed.h" #include "embed/MemoryStreamEmbed.h" -#include "embed/GraphicsEmbed.h" #include "../xml/include/xmlutils.h" @@ -459,22 +458,6 @@ namespace NSDoctRenderer } case DoctRendererFormat::HTML: { - // CALCULATE - if (pParams->m_sJsonParams.empty()) - args[0] = CJSContext::createNull(); - else - { - std::string sTmp = U_TO_UTF8((pParams->m_sJsonParams)); - args[0] = context->JSON_Parse(sTmp.c_str()); - } - - JSSmart js_result1 = js_objectApi->call_func("asc_nativeCalculateFile", 1, args); - if(try_catch->Check()) - { - strError = L"code=\"calculate\""; - bIsBreak = true; - } - JSSmart js_result2 = js_objectApi->call_func("asc_nativeGetHtml", 1, args); if(try_catch->Check()) { @@ -639,7 +622,6 @@ namespace NSDoctRenderer context->CreateGlobalForContext(); CNativeControlEmbed::CreateObjectBuilderInContext("CreateNativeEngine", context); CMemoryStreamEmbed::CreateObjectInContext ("CreateNativeMemoryStream", context); - CGraphicsEmbed::CreateObjectInContext ("CreateNativeGraphics", context); context->CreateContext(); JSSmart context_scope = context->CreateContextScope(); diff --git a/DesktopEditor/doctrenderer/doctrenderer.pro b/DesktopEditor/doctrenderer/doctrenderer.pro index 1cf223d6f6..e16eab216e 100644 --- a/DesktopEditor/doctrenderer/doctrenderer.pro +++ b/DesktopEditor/doctrenderer/doctrenderer.pro @@ -20,6 +20,8 @@ ADD_DEPENDENCY(graphics, kernel, UnicodeConverter) #CONFIG += build_xp +core_mac:CONFIG += use_javascript_core + core_ios { CONFIG += doct_renderer_empty } @@ -38,8 +40,7 @@ SOURCES += \ nativecontrol.cpp \ doctrenderer.cpp \ docbuilder.cpp \ - docbuilder_p.cpp \ - graphics.cpp + docbuilder_p.cpp SOURCES += \ ../../Common/OfficeFileFormatChecker2.cpp \ @@ -50,18 +51,15 @@ SOURCES += \ HEADERS += \ docbuilder_p.h \ memorystream.h \ - nativecontrol.h \ - graphics.h + nativecontrol.h HEADERS += \ - embed/GraphicsEmbed.h \ embed/MemoryStreamEmbed.h \ embed/NativeControlEmbed.h \ embed/NativeBuilderEmbed.h \ js_internal/js_base.h SOURCES += \ - embed/GraphicsEmbed.cpp \ embed/MemoryStreamEmbed.cpp \ embed/NativeControlEmbed.cpp \ embed/NativeBuilderEmbed.cpp @@ -72,8 +70,7 @@ SOURCES += \ SOURCES += \ embed/v8/v8_MemoryStream.cpp \ embed/v8/v8_NativeControl.cpp \ - embed/v8/v8_NativeBuilder.cpp \ - embed/v8/v8_Graphics.cpp + embed/v8/v8_NativeBuilder.cpp !build_xp { include(../../Common/3dParty/v8/v8.pri) @@ -87,7 +84,6 @@ SOURCES += \ OBJECTIVE_SOURCES += js_internal/jsc/jsc_base.mm OBJECTIVE_SOURCES += ../common/Mac/NSString+StringUtils.mm OBJECTIVE_SOURCES += \ - embed/jsc/jsc_Graphics.mm \ embed/jsc/jsc_MemoryStream.mm \ embed/jsc/jsc_NativeControl.mm \ embed/jsc/jsc_NativeBuilder.mm diff --git a/DesktopEditor/doctrenderer/embed/GraphicsEmbed.cpp b/DesktopEditor/doctrenderer/embed/GraphicsEmbed.cpp deleted file mode 100644 index 25c4899e43..0000000000 --- a/DesktopEditor/doctrenderer/embed/GraphicsEmbed.cpp +++ /dev/null @@ -1,564 +0,0 @@ -#include "GraphicsEmbed.h" - -JSSmart CGraphicsEmbed::init(JSSmart Native, JSSmart width_px, JSSmart height_px, JSSmart width_mm, JSSmart height_mm) -{ - m_pInternal->init((NSNativeControl::CNativeControl*)Native->toObject()->getNative()->getObject(), width_px->toDouble(), height_px->toDouble(), width_mm->toDouble(), height_mm->toDouble()); - return NULL; -} -JSSmart CGraphicsEmbed::EndDraw() -{ - m_pInternal->EndDraw(); - return NULL; -} -JSSmart CGraphicsEmbed::put_GlobalAlpha(JSSmart enable, JSSmart globalAlpha) -{ - m_pInternal->put_GlobalAlpha(enable->toBool(), globalAlpha->toDouble()); - return NULL; -} -JSSmart CGraphicsEmbed::Start_GlobalAlpha() -{ - m_pInternal->Start_GlobalAlpha(); - return NULL; -} -JSSmart CGraphicsEmbed::End_GlobalAlpha() -{ - m_pInternal->End_GlobalAlpha(); - return NULL; -} -JSSmart CGraphicsEmbed::p_color(JSSmart r, JSSmart g, JSSmart b, JSSmart a) -{ - m_pInternal->p_color(r->toInt32(), g->toInt32(), b->toInt32(), a->toInt32()); - return NULL; -} -JSSmart CGraphicsEmbed::p_width(JSSmart w) -{ - m_pInternal->p_width(w->toDouble()); - return NULL; -} -JSSmart CGraphicsEmbed::p_dash(JSSmart params) -{ - JSSmart items = params->toArray(); - size_t length = items->getCount(); - double* dash = NULL; - if(length > 0) - dash = new double[length]; - for(size_t i = 0; i < length; i++) - dash[i] = items->get(i)->toDouble(); - m_pInternal->p_dash(length, dash); - RELEASEARRAYOBJECTS(dash); - return NULL; -} -JSSmart CGraphicsEmbed::b_color1(JSSmart r, JSSmart g, JSSmart b, JSSmart a) -{ - m_pInternal->b_color1(r->toInt32(), g->toInt32(), b->toInt32(), a->toInt32()); - return NULL; -} -JSSmart CGraphicsEmbed::b_color2(JSSmart r, JSSmart g, JSSmart b, JSSmart a) -{ - m_pInternal->b_color2(r->toInt32(), g->toInt32(), b->toInt32(), a->toInt32()); - return NULL; -} -JSSmart CGraphicsEmbed::transform(JSSmart sx, JSSmart shy, JSSmart shx, JSSmart sy, JSSmart tx, JSSmart ty) -{ - m_pInternal->transform(sx->toDouble(), shy->toDouble(), shx->toDouble(), sy->toDouble(), tx->toDouble(), ty->toDouble()); - return NULL; -} -JSSmart CGraphicsEmbed::CalculateFullTransform(JSSmart isInvertNeed) -{ - m_pInternal->CalculateFullTransform(); - return NULL; -} -JSSmart CGraphicsEmbed::_s() -{ - m_pInternal->_s(); - return NULL; -} -JSSmart CGraphicsEmbed::_e() -{ - m_pInternal->_e(); - return NULL; -} -JSSmart CGraphicsEmbed::_z() -{ - m_pInternal->_z(); - return NULL; -} -JSSmart CGraphicsEmbed::_m (JSSmart x, JSSmart y) -{ - m_pInternal->_m(x->toDouble(), y->toDouble()); - return NULL; -} -JSSmart CGraphicsEmbed::_l (JSSmart x, JSSmart y) -{ - m_pInternal->_l(x->toDouble(), y->toDouble()); - return NULL; -} -JSSmart CGraphicsEmbed::_c (JSSmart x1, JSSmart y1, JSSmart x2, JSSmart y2, JSSmart x3, JSSmart y3) -{ - m_pInternal->_c(x1->toDouble(), y1->toDouble(), x2->toDouble(), y2->toDouble(), x3->toDouble(), y3->toDouble()); - return NULL; -} -JSSmart CGraphicsEmbed::_c2(JSSmart x1, JSSmart y1, JSSmart x2, JSSmart y2) -{ - m_pInternal->_c2(x1->toDouble(), y1->toDouble(), x2->toDouble(), y2->toDouble()); - return NULL; -} -JSSmart CGraphicsEmbed::ds() -{ - m_pInternal->ds(); - return NULL; -} -JSSmart CGraphicsEmbed::df() -{ - m_pInternal->df(); - return NULL; -} -JSSmart CGraphicsEmbed::save() -{ - m_pInternal->save(); - return NULL; -} -JSSmart CGraphicsEmbed::restore() -{ - m_pInternal->restore(); - return NULL; -} -JSSmart CGraphicsEmbed::clip() -{ - m_pInternal->clip(); - return NULL; -} -JSSmart CGraphicsEmbed::reset() -{ - m_pInternal->reset(); - return NULL; -} -JSSmart CGraphicsEmbed::FreeFont() -{ - m_pInternal->FreeFont(); - return NULL; -} -JSSmart CGraphicsEmbed::ClearLastFont() -{ - m_pInternal->ClearLastFont(); - return NULL; -} -JSSmart CGraphicsEmbed::drawImage2(JSSmart img, JSSmart x, JSSmart y, JSSmart w, JSSmart h, JSSmart alpha, JSSmart srcRect) -{ - m_pInternal->drawImage(img->toStringW(), x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble(), alpha->toInt32()); - return NULL; -} -JSSmart CGraphicsEmbed::drawImage (JSSmart img, JSSmart x, JSSmart y, JSSmart w, JSSmart h, JSSmart alpha, JSSmart srcRect, JSSmart nativeImage) -{ - m_pInternal->drawImage(img->toStringW(), x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble(), alpha->toInt32()); - return NULL; -} -JSSmart CGraphicsEmbed::GetFont() -{ - return CJSContext::createString(m_pInternal->GetFont()); -} -JSSmart CGraphicsEmbed::font(JSSmart font_id, JSSmart font_size) -{ - m_pInternal->font(); - return NULL; -} -JSSmart CGraphicsEmbed::SetFont(JSSmart path, JSSmart face, JSSmart size, JSSmart style) -{ - m_pInternal->SetFont(path->toStringW(), face->toInt32(), size->toDouble(), style->toInt32()); - return NULL; -} -JSSmart CGraphicsEmbed::GetTextPr() -{ - m_pInternal->GetTextPr(); - return NULL; -} -JSSmart CGraphicsEmbed::FillText(JSSmart x, JSSmart y, JSSmart text) -{ - m_pInternal->FillText(x->toDouble(), y->toDouble(), text->toInt32()); - return NULL; -} -JSSmart CGraphicsEmbed::t(JSSmart x, JSSmart y, JSSmart _arr) -{ - m_pInternal->t(x->toDouble(), y->toDouble(), _arr->toStringW()); - return NULL; -} -JSSmart CGraphicsEmbed::FillText2(JSSmart x, JSSmart y, JSSmart text, JSSmart cropX, JSSmart cropW) -{ - m_pInternal->FillText(x->toDouble(), y->toDouble(), text->toInt32()); - return NULL; -} -JSSmart CGraphicsEmbed::t2(JSSmart x, JSSmart y, JSSmart _arr, JSSmart cropX, JSSmart cropW) -{ - m_pInternal->t(x->toDouble(), y->toDouble(), _arr->toStringW()); - return NULL; -} -JSSmart CGraphicsEmbed::FillTextCode(JSSmart x, JSSmart y, JSSmart lUnicode) -{ - m_pInternal->FillText(x->toDouble(), y->toDouble(), lUnicode->toInt32()); - return NULL; -} -JSSmart CGraphicsEmbed::tg(JSSmart text, JSSmart x, JSSmart y) -{ - m_pInternal->tg(text->toInt32(), x->toDouble(), y->toDouble()); - return NULL; -} -JSSmart CGraphicsEmbed::charspace(JSSmart space) -{ - m_pInternal->charspace(); - return NULL; -} -JSSmart CGraphicsEmbed::private_FillGlyph (JSSmart pGlyph, JSSmart _bounds) -{ - m_pInternal->private_FillGlyph(); - return NULL; -} -JSSmart CGraphicsEmbed::private_FillGlyphC(JSSmart pGlyph, JSSmart cropX, JSSmart cropW) -{ - m_pInternal->private_FillGlyphC(); - return NULL; -} -JSSmart CGraphicsEmbed::private_FillGlyph2(JSSmart pGlyph) -{ - m_pInternal->private_FillGlyph2(); - return NULL; -} -JSSmart CGraphicsEmbed::SetIntegerGrid(JSSmart param) -{ - m_pInternal->SetIntegerGrid(param->toBool()); - return NULL; -} -JSSmart CGraphicsEmbed::GetIntegerGrid() -{ - return CJSContext::createBool(m_pInternal->GetIntegerGrid()); -} -JSSmart CGraphicsEmbed::DrawStringASCII (JSSmart text, JSSmart x, JSSmart y) -{ - m_pInternal->DrawStringASCII(text->toStringW(), x->toDouble(), y->toDouble()); - return NULL; -} -JSSmart CGraphicsEmbed::DrawStringASCII2(JSSmart text, JSSmart x, JSSmart y) -{ - m_pInternal->DrawStringASCII(text->toStringW(), x->toDouble(), y->toDouble()); - return NULL; -} -JSSmart CGraphicsEmbed::DrawHeaderEdit(JSSmart yPos, JSSmart lock_type, JSSmart sectionNum, JSSmart bIsRepeat, JSSmart type) -{ - m_pInternal->DrawHeaderEdit(yPos->toDouble()); - return NULL; -} -JSSmart CGraphicsEmbed::DrawFooterEdit(JSSmart yPos, JSSmart lock_type, JSSmart sectionNum, JSSmart bIsRepeat, JSSmart type) -{ - m_pInternal->DrawFooterEdit(yPos->toDouble()); - return NULL; -} -JSSmart CGraphicsEmbed::DrawLockParagraph (JSSmart x, JSSmart y1, JSSmart y2) -{ - m_pInternal->DrawLockParagraph(x->toDouble(), y1->toDouble(), y2->toDouble()); - return NULL; -} -JSSmart CGraphicsEmbed::DrawLockObjectRect(JSSmart x, JSSmart y, JSSmart w, JSSmart h) -{ - m_pInternal->DrawLockObjectRect(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble()); - return NULL; -} -JSSmart CGraphicsEmbed::DrawEmptyTableLine(JSSmart x1, JSSmart y1, JSSmart x2, JSSmart y2) -{ - m_pInternal->DrawEmptyTableLine(x1->toDouble(), y1->toDouble(), x2->toDouble(), y2->toDouble()); - return NULL; -} -JSSmart CGraphicsEmbed::DrawSpellingLine (JSSmart y0, JSSmart x0, JSSmart x1, JSSmart w) -{ - m_pInternal->DrawSpellingLine(y0->toDouble(), x0->toDouble(), x1->toDouble(), w->toDouble()); - return NULL; -} -JSSmart CGraphicsEmbed::drawHorLine (JSSmart align, JSSmart y, JSSmart x, JSSmart r, JSSmart penW) -{ - m_pInternal->drawHorLine(align->toInt32(), y->toDouble(), x->toDouble(), r->toDouble(), penW->toDouble()); - return NULL; -} -JSSmart CGraphicsEmbed::drawHorLine2(JSSmart align, JSSmart y, JSSmart x, JSSmart r, JSSmart penW) -{ - m_pInternal->drawHorLine2(align->toInt32(), y->toDouble(), x->toDouble(), r->toDouble(), penW->toDouble()); - return NULL; -} -JSSmart CGraphicsEmbed::drawVerLine (JSSmart align, JSSmart x, JSSmart y, JSSmart b, JSSmart penW) -{ - m_pInternal->drawVerLine(align->toInt32(), x->toDouble(), y->toDouble(), b->toDouble(), penW->toDouble()); - return NULL; -} -JSSmart CGraphicsEmbed::drawHorLineExt(JSSmart align, JSSmart y, JSSmart x, JSSmart r, JSSmart penW, JSSmart leftMW, JSSmart rightMW) -{ - m_pInternal->drawHorLineExt(align->toInt32(), y->toDouble(), x->toDouble(), r->toDouble(), penW->toDouble(), leftMW->toDouble(), rightMW->toDouble()); - return NULL; -} -JSSmart CGraphicsEmbed::rect (JSSmart x, JSSmart y, JSSmart w, JSSmart h) -{ - m_pInternal->rect(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble()); - return NULL; -} -JSSmart CGraphicsEmbed::TableRect(JSSmart x, JSSmart y, JSSmart w, JSSmart h) -{ - m_pInternal->TableRect(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble()); - return NULL; -} -JSSmart CGraphicsEmbed::AddClipRect(JSSmart x, JSSmart y, JSSmart w, JSSmart h) -{ - m_pInternal->AddClipRect(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble()); - return NULL; -} -JSSmart CGraphicsEmbed::RemoveClipRect() -{ - m_pInternal->RemoveClipRect(); - return NULL; -} -JSSmart CGraphicsEmbed::SetClip(JSSmart x, JSSmart y, JSSmart w, JSSmart h) -{ - m_pInternal->SetClip(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble()); - return NULL; -} -JSSmart CGraphicsEmbed::RemoveClip() -{ - m_pInternal->restore(); - return NULL; -} -JSSmart CGraphicsEmbed::drawCollaborativeChanges(JSSmart x, JSSmart y, JSSmart w, JSSmart h, JSSmart r, JSSmart g, JSSmart b, JSSmart a) -{ - m_pInternal->drawCollaborativeChanges(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble(), r->toInt32(), g->toInt32(), b->toInt32(), a->toInt32()); - return NULL; -} -JSSmart CGraphicsEmbed::drawMailMergeField(JSSmart x, JSSmart y, JSSmart w, JSSmart h) -{ - m_pInternal->drawMailMergeField(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble()); - return NULL; -} -JSSmart CGraphicsEmbed::drawSearchResult (JSSmart x, JSSmart y, JSSmart w, JSSmart h) -{ - m_pInternal->drawSearchResult(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble()); - return NULL; -} -JSSmart CGraphicsEmbed::drawFlowAnchor (JSSmart x, JSSmart y) -{ - return NULL; -} -JSSmart CGraphicsEmbed::SavePen() -{ - m_pInternal->SavePen(); - return NULL; -} -JSSmart CGraphicsEmbed::RestorePen() -{ - m_pInternal->RestorePen(); - return NULL; -} -JSSmart CGraphicsEmbed::SaveBrush() -{ - m_pInternal->SaveBrush(); - return NULL; -} -JSSmart CGraphicsEmbed::RestoreBrush() -{ - m_pInternal->RestoreBrush(); - return NULL; -} -JSSmart CGraphicsEmbed::SavePenBrush() -{ - m_pInternal->SavePenBrush(); - return NULL; -} -JSSmart CGraphicsEmbed::RestorePenBrush() -{ - m_pInternal->RestorePenBrush(); - return NULL; -} -JSSmart CGraphicsEmbed::SaveGrState() -{ - m_pInternal->SaveGrState(); - return NULL; -} -JSSmart CGraphicsEmbed::RestoreGrState() -{ - m_pInternal->RestoreGrState(); - return NULL; -} -JSSmart CGraphicsEmbed::StartClipPath() -{ - m_pInternal->StartClipPath(); - return NULL; -} -JSSmart CGraphicsEmbed::EndClipPath() -{ - m_pInternal->EndClipPath(); - return NULL; -} -JSSmart CGraphicsEmbed::StartCheckTableDraw() -{ - return CJSContext::createBool(m_pInternal->StartCheckTableDraw()); -} -JSSmart CGraphicsEmbed::SetTextClipRect(JSSmart _l, JSSmart _t, JSSmart _r, JSSmart _b) -{ - m_pInternal->SetTextClipRect(_l->toDouble(), _t->toDouble(), _r->toDouble(), _b->toDouble()); - return NULL; -} -JSSmart CGraphicsEmbed::AddSmartRect (JSSmart x, JSSmart y, JSSmart w, JSSmart h, JSSmart pen_w) -{ - m_pInternal->rect(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble()); - return NULL; -} -JSSmart CGraphicsEmbed::CheckUseFonts2 (JSSmart _transform) -{ - return NULL; -} -JSSmart CGraphicsEmbed::UncheckUseFonts2() -{ - return NULL; -} -JSSmart CGraphicsEmbed::Drawing_StartCheckBounds(JSSmart x, JSSmart y, JSSmart w, JSSmart h) -{ - return NULL; -} -JSSmart CGraphicsEmbed::Drawing_EndCheckBounds() -{ - return NULL; -} -JSSmart CGraphicsEmbed::DrawPresentationComment(JSSmart type, JSSmart x, JSSmart y, JSSmart w, JSSmart h) -{ - return NULL; -} -JSSmart CGraphicsEmbed::DrawPolygon(JSSmart oPath, JSSmart lineWidth, JSSmart shift) -{ - return NULL; -} -JSSmart CGraphicsEmbed::DrawFootnoteRect(JSSmart x, JSSmart y, JSSmart w, JSSmart h) -{ - m_pInternal->DrawFootnoteRect(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble()); - return NULL; -} -JSSmart CGraphicsEmbed::toDataURL(JSSmart type) -{ - return CJSContext::createString(m_pInternal->toDataURL(type->toStringW())); -} -JSSmart CGraphicsEmbed::GetPenColor() -{ - JSSmart e = CJSContext::createObject(); - NSGraphics::CColor res = m_pInternal->GetPenColor(); - e->set("R", res.r); - e->set("G", res.g); - e->set("B", res.b); - e->set("A", res.a); - return e->toValue(); -} -JSSmart CGraphicsEmbed::GetBrushColor() -{ - JSSmart e = CJSContext::createObject(); - NSGraphics::CColor res = m_pInternal->GetBrushColor(); - e->set("R", res.r); - e->set("G", res.g); - e->set("B", res.b); - e->set("A", res.a); - return e->toValue(); -} -JSSmart CGraphicsEmbed::put_brushTexture(JSSmart src, JSSmart type) -{ - m_pInternal->put_brushTexture(src->toStringW(), type->toInt32()); - return NULL; -} -JSSmart CGraphicsEmbed::put_brushTextureMode(JSSmart mode) -{ - m_pInternal->put_brushTextureMode(mode->toInt32()); - return NULL; -} -JSSmart CGraphicsEmbed::put_BrushTextureAlpha(JSSmart a) -{ - m_pInternal->put_BrushTextureAlpha(a->toInt32()); - return NULL; -} -JSSmart CGraphicsEmbed::put_BrushGradient(JSSmart colors, JSSmart transparent, JSSmart x0, JSSmart y0, JSSmart x1, JSSmart y1, JSSmart r0, JSSmart r1) -{ - JSSmart items = colors->toArray(); - size_t length = items->getCount(); - LONG* color = NULL; - double* pos = NULL; - if(length > 0) - { - color = new LONG[length]; - pos = new double[length]; - } - for(size_t i = 0; i < length; i++) - { - JSSmart item = items->get(i)->toObject(); - pos[i] = item->get("pos")->toDouble() / 100000.0; - LONG R = item->get("color")->toObject()->get("RGBA")->toObject()->get("R")->toInt32(); - LONG G = item->get("color")->toObject()->get("RGBA")->toObject()->get("G")->toInt32(); - LONG B = item->get("color")->toObject()->get("RGBA")->toObject()->get("B")->toInt32(); - LONG A = item->get("color")->toObject()->get("RGBA")->toObject()->get("A")->toInt32(); - if(!transparent->isNull()) - A = transparent->toInt32(); - color[i] = R | (G << 8) | (B << 16) | (A << 24); - } - - double _x0 = x0->toDouble() / 100000.0; - double _y0 = y0->toDouble() / 100000.0; - double _x1 = x1->toDouble() / 100000.0; - double _y1 = y1->toDouble() / 100000.0; - double _r0 = NAN; - double _r1 = NAN; - if(!r0->isNull()) - { - _r0 = r0->toDouble() / 100000.0; - _r1 = r1->toDouble() / 100000.0; - } - - m_pInternal->put_BrushGradient(color, pos, length, _x0, _y0, _x1, _y1, _r0, _r1); - - RELEASEARRAYOBJECTS(color); - RELEASEARRAYOBJECTS(pos); - return NULL; -} -JSSmart CGraphicsEmbed::TransformPointX(JSSmart x, JSSmart y) -{ - return CJSContext::createDouble(m_pInternal->TransformPointX(x->toDouble(), y->toDouble())); -} -JSSmart CGraphicsEmbed::TransformPointY(JSSmart x, JSSmart y) -{ - return CJSContext::createDouble(m_pInternal->TransformPointY(x->toDouble(), y->toDouble())); -} -JSSmart CGraphicsEmbed::put_LineJoin(JSSmart join) -{ - m_pInternal->put_LineJoin(join->toInt32()); - return NULL; -} -JSSmart CGraphicsEmbed::get_LineJoin() -{ - return CJSContext::createInt(m_pInternal->GetLineJoin()); -} -JSSmart CGraphicsEmbed::put_TextureBounds(JSSmart x, JSSmart y, JSSmart w, JSSmart h) -{ - m_pInternal->put_TextureBounds(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble()); - return NULL; -} -JSSmart CGraphicsEmbed::GetlineWidth() -{ - return CJSContext::createDouble(m_pInternal->GetlineWidth()); -} -JSSmart CGraphicsEmbed::DrawPath(JSSmart path) -{ - m_pInternal->DrawPath(path->toInt32()); - return NULL; -} -JSSmart CGraphicsEmbed::CoordTransformOffset(JSSmart tx, JSSmart ty) -{ - m_pInternal->CoordTransformOffset(tx->toDouble(), ty->toDouble()); - return NULL; -} -JSSmart CGraphicsEmbed::GetTransform() -{ - JSSmart e = CJSContext::createObject(); - NSGraphics::CTransform res = m_pInternal->GetTransform(); - e->set("sx", res.sx); - e->set("shx", res.shx); - e->set("shy", res.shy); - e->set("sy", res.sy); - e->set("tx", res.tx); - e->set("ty", res.ty); - return e->toValue(); -} diff --git a/DesktopEditor/doctrenderer/embed/GraphicsEmbed.h b/DesktopEditor/doctrenderer/embed/GraphicsEmbed.h deleted file mode 100644 index 565630a870..0000000000 --- a/DesktopEditor/doctrenderer/embed/GraphicsEmbed.h +++ /dev/null @@ -1,138 +0,0 @@ -#ifndef _BUILD_NATIVE_GRAPHICS_EMBED_H_ -#define _BUILD_NATIVE_GRAPHICS_EMBED_H_ - -#include "../graphics.h" -#include "../js_internal/js_base.h" - -using namespace NSJSBase; -class CGraphicsEmbed : public CJSEmbedObject -{ -public: - NSGraphics::CGraphics* m_pInternal; - -public: - CGraphicsEmbed() : m_pInternal(new NSGraphics::CGraphics()) {} - ~CGraphicsEmbed() { RELEASEOBJECT(m_pInternal); } - - virtual void* getObject() override { return (void*)m_pInternal; } - -public: - JSSmart init(JSSmart Native, JSSmart width_px, JSSmart height_px, JSSmart width_mm, JSSmart height_mm); - JSSmart EndDraw(); - JSSmart put_GlobalAlpha(JSSmart enable, JSSmart globalAlpha); - JSSmart Start_GlobalAlpha(); - JSSmart End_GlobalAlpha(); - // pen methods - JSSmart p_color(JSSmart r, JSSmart g, JSSmart b, JSSmart a); - JSSmart p_width(JSSmart w); - JSSmart p_dash(JSSmart params); - // brush methods - JSSmart b_color1(JSSmart r, JSSmart g, JSSmart b, JSSmart a); - JSSmart b_color2(JSSmart r, JSSmart g, JSSmart b, JSSmart a); - JSSmart transform(JSSmart sx, JSSmart shy, JSSmart shx, JSSmart sy, JSSmart tx, JSSmart ty); - JSSmart CalculateFullTransform(JSSmart isInvertNeed); - // path commands - JSSmart _s(); - JSSmart _e(); - JSSmart _z(); - JSSmart _m (JSSmart x, JSSmart y); - JSSmart _l (JSSmart x, JSSmart y); - JSSmart _c (JSSmart x1, JSSmart y1, JSSmart x2, JSSmart y2, JSSmart x3, JSSmart y3); - JSSmart _c2(JSSmart x1, JSSmart y1, JSSmart x2, JSSmart y2); - JSSmart ds(); - JSSmart df(); - // canvas state - JSSmart save(); - JSSmart restore(); - JSSmart clip(); - JSSmart reset(); - JSSmart FreeFont(); - JSSmart ClearLastFont(); - // images - JSSmart drawImage2(JSSmart img, JSSmart x, JSSmart y, JSSmart w, JSSmart h, JSSmart alpha, JSSmart srcRect); - JSSmart drawImage (JSSmart img, JSSmart x, JSSmart y, JSSmart w, JSSmart h, JSSmart alpha, JSSmart srcRect, JSSmart nativeImage); - // text - JSSmart GetFont(); - JSSmart font(JSSmart font_id, JSSmart font_size); - JSSmart SetFont(JSSmart path, JSSmart face, JSSmart size, JSSmart style); - JSSmart GetTextPr(); - JSSmart FillText(JSSmart x, JSSmart y, JSSmart text); - JSSmart t(JSSmart x, JSSmart y, JSSmart _arr); - JSSmart FillText2(JSSmart x, JSSmart y, JSSmart text, JSSmart cropX, JSSmart cropW); - JSSmart t2(JSSmart text, JSSmart x, JSSmart y, JSSmart cropX, JSSmart cropW); - JSSmart FillTextCode(JSSmart x, JSSmart y, JSSmart lUnicode); - JSSmart tg(JSSmart text, JSSmart x, JSSmart y); - JSSmart charspace(JSSmart space); - // private methods - JSSmart private_FillGlyph (JSSmart pGlyph, JSSmart _bounds); - JSSmart private_FillGlyphC(JSSmart pGlyph, JSSmart cropX, JSSmart cropW); - JSSmart private_FillGlyph2(JSSmart pGlyph); - JSSmart SetIntegerGrid(JSSmart param); - JSSmart GetIntegerGrid(); - JSSmart DrawStringASCII (JSSmart text, JSSmart x, JSSmart y); - JSSmart DrawStringASCII2(JSSmart text, JSSmart x, JSSmart y); - JSSmart DrawHeaderEdit(JSSmart yPos, JSSmart lock_type, JSSmart sectionNum, JSSmart bIsRepeat, JSSmart type); - JSSmart DrawFooterEdit(JSSmart yPos, JSSmart lock_type, JSSmart sectionNum, JSSmart bIsRepeat, JSSmart type); - JSSmart DrawLockParagraph (JSSmart x, JSSmart y1, JSSmart y2); - JSSmart DrawLockObjectRect(JSSmart x, JSSmart y, JSSmart w, JSSmart h); - JSSmart DrawEmptyTableLine(JSSmart x1, JSSmart y1, JSSmart x2, JSSmart y2); - JSSmart DrawSpellingLine (JSSmart y0, JSSmart x0, JSSmart x1, JSSmart w); - // smart methods for horizontal / vertical lines - JSSmart drawHorLine (JSSmart align, JSSmart y, JSSmart x, JSSmart r, JSSmart penW); - JSSmart drawHorLine2(JSSmart align, JSSmart y, JSSmart x, JSSmart r, JSSmart penW); - JSSmart drawVerLine (JSSmart align, JSSmart x, JSSmart y, JSSmart b, JSSmart penW); - // мега крутые функции для таблиц - JSSmart drawHorLineExt(JSSmart align, JSSmart y, JSSmart x, JSSmart r, JSSmart penW, JSSmart leftMW, JSSmart rightMW); - JSSmart rect (JSSmart x, JSSmart y, JSSmart w, JSSmart h); - JSSmart TableRect(JSSmart x, JSSmart y, JSSmart w, JSSmart h); - // функции клиппирования - JSSmart AddClipRect(JSSmart x, JSSmart y, JSSmart w, JSSmart h); - JSSmart RemoveClipRect(); - JSSmart SetClip(JSSmart x, JSSmart y, JSSmart w, JSSmart h); - JSSmart RemoveClip(); - JSSmart drawCollaborativeChanges(JSSmart x, JSSmart y, JSSmart w, JSSmart h, JSSmart r, JSSmart g, JSSmart b, JSSmart a); - JSSmart drawMailMergeField(JSSmart x, JSSmart y, JSSmart w, JSSmart h); - JSSmart drawSearchResult (JSSmart x, JSSmart y, JSSmart w, JSSmart h); - JSSmart drawFlowAnchor (JSSmart x, JSSmart y); - JSSmart SavePen(); - JSSmart RestorePen(); - JSSmart SaveBrush(); - JSSmart RestoreBrush(); - JSSmart SavePenBrush(); - JSSmart RestorePenBrush(); - JSSmart SaveGrState(); - JSSmart RestoreGrState(); - JSSmart StartClipPath(); - JSSmart EndClipPath(); - JSSmart StartCheckTableDraw(); - JSSmart SetTextClipRect(JSSmart _l, JSSmart _t, JSSmart _r, JSSmart _b); - JSSmart AddSmartRect (JSSmart x, JSSmart y, JSSmart w, JSSmart h, JSSmart pen_w); - JSSmart CheckUseFonts2 (JSSmart _transform); - JSSmart UncheckUseFonts2(); - JSSmart Drawing_StartCheckBounds(JSSmart x, JSSmart y, JSSmart w, JSSmart h); - JSSmart Drawing_EndCheckBounds(); - JSSmart DrawPresentationComment(JSSmart type, JSSmart x, JSSmart y, JSSmart w, JSSmart h); - JSSmart DrawPolygon(JSSmart oPath, JSSmart lineWidth, JSSmart shift); - JSSmart DrawFootnoteRect(JSSmart x, JSSmart y, JSSmart w, JSSmart h); - // new methods - JSSmart toDataURL(JSSmart type); - JSSmart GetPenColor(); - JSSmart GetBrushColor(); - JSSmart put_brushTexture(JSSmart src, JSSmart type); - JSSmart put_brushTextureMode(JSSmart mode); - JSSmart put_BrushTextureAlpha(JSSmart a); - JSSmart put_BrushGradient(JSSmart colors, JSSmart n, JSSmart x0, JSSmart y0, JSSmart x1, JSSmart y1, JSSmart r0, JSSmart r1); - JSSmart TransformPointX(JSSmart x, JSSmart y); - JSSmart TransformPointY(JSSmart x, JSSmart y); - JSSmart put_LineJoin(JSSmart join); - JSSmart get_LineJoin(); - JSSmart put_TextureBounds(JSSmart x, JSSmart y, JSSmart w, JSSmart h); - JSSmart GetlineWidth(); - JSSmart DrawPath(JSSmart path); - JSSmart CoordTransformOffset(JSSmart tx, JSSmart ty); - JSSmart GetTransform(); - - static void CreateObjectInContext(const std::string& name, JSSmart context); -}; - -#endif // _BUILD_NATIVE_GRAPHICS_EMBED_H_ diff --git a/DesktopEditor/doctrenderer/embed/jsc/jsc_Graphics.mm b/DesktopEditor/doctrenderer/embed/jsc/jsc_Graphics.mm deleted file mode 100644 index 7ceb4ed0b9..0000000000 --- a/DesktopEditor/doctrenderer/embed/jsc/jsc_Graphics.mm +++ /dev/null @@ -1,255 +0,0 @@ -#include "../GraphicsEmbed.h" -#include "../../js_internal/jsc/jsc_base.h" - -@protocol IJSCGraphics --(JSValue*) create : (JSValue*)Native : (JSValue*)width_px : (JSValue*)height_px : (JSValue*)width_mm : (JSValue*)height_mm; --(JSValue*) EndDraw; --(JSValue*) put_GlobalAlpha : (JSValue*)enable : (JSValue*)globalAlpha; --(JSValue*) Start_GlobalAlpha; --(JSValue*) End_GlobalAlpha; -// pen methods --(JSValue*) p_color : (JSValue*)r : (JSValue*)g : (JSValue*)b : (JSValue*)a; --(JSValue*) p_width : (JSValue*)w; --(JSValue*) p_dash : (JSValue*)params; -// brush methods --(JSValue*) b_color1 : (JSValue*)r : (JSValue*)g : (JSValue*)b :(JSValue*)a; --(JSValue*) b_color2 : (JSValue*)r : (JSValue*)g : (JSValue*)b :(JSValue*)a; --(JSValue*) transform : (JSValue*)sx : (JSValue*)shy : (JSValue*)shx : (JSValue*)sy : (JSValue*)tx : (JSValue*)ty; --(JSValue*) CalculateFullTransform : (JSValue*)isInvertNeed; -// path commands --(JSValue*) _s; --(JSValue*) _e; --(JSValue*) _z; --(JSValue*) _m : (JSValue*)x : (JSValue*)y; --(JSValue*) _l : (JSValue*)x : (JSValue*)y; --(JSValue*) _c : (JSValue*)x1 : (JSValue*)y1 : (JSValue*)x2 : (JSValue*)y2 : (JSValue*)x3 : (JSValue*)y3; --(JSValue*) _c2 : (JSValue*)x1 : (JSValue*)y1 : (JSValue*)x2 : (JSValue*)y2; --(JSValue*) ds; --(JSValue*) df; -// canvas state --(JSValue*)save; --(JSValue*)restore; --(JSValue*)clip; --(JSValue*)reset; --(JSValue*)FreeFont; --(JSValue*)ClearLastFont; -// images --(JSValue*)drawImage2 : (JSValue*)img : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h : (JSValue*)alpha : (JSValue*)srcRect; --(JSValue*)drawImage : (JSValue*)img : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h : (JSValue*)alpha : (JSValue*)srcRect : (JSValue*)nativeImage; -// text --(JSValue*)GetFont; --(JSValue*)font : (JSValue*)font_id : (JSValue*)font_size; --(JSValue*)SetFont : (JSValue*)path : (JSValue*)face : (JSValue*)size : (JSValue*)style; --(JSValue*)GetTextPr; --(JSValue*)FillText : (JSValue*)x : (JSValue*)y : (JSValue*)text; --(JSValue*)t : (JSValue*)x : (JSValue*)y : (JSValue*)_arr; --(JSValue*)FillText2 : (JSValue*)x : (JSValue*)y : (JSValue*)text : (JSValue*)cropX : (JSValue*)cropW; --(JSValue*)t2 : (JSValue*)text : (JSValue*)x : (JSValue*)y : (JSValue*)cropX : (JSValue*)cropW; --(JSValue*)FillTextCode : (JSValue*)x : (JSValue*)y : (JSValue*)lUnicode; --(JSValue*)tg : (JSValue*)text : (JSValue*)x : (JSValue*)y; --(JSValue*)charspace : (JSValue*)space; -// private methods --(JSValue*)private_FillGlyph : (JSValue*)pGlyph : (JSValue*)_bounds; --(JSValue*)private_FillGlyphC : (JSValue*)pGlyph : (JSValue*)cropX : (JSValue*)cropW; --(JSValue*)private_FillGlyph2 : (JSValue*)pGlyph; --(JSValue*)SetIntegerGrid : (JSValue*)param; --(JSValue*)GetIntegerGrid; --(JSValue*)DrawStringASCII : (JSValue*)text : (JSValue*)x : (JSValue*)y; --(JSValue*)DrawStringASCII2 : (JSValue*)text : (JSValue*)x : (JSValue*)y; --(JSValue*)DrawHeaderEdit : (JSValue*)yPos : (JSValue*)lock_type : (JSValue*)sectionNum : (JSValue*)bIsRepeat : (JSValue*)type; --(JSValue*)DrawFooterEdit : (JSValue*)yPos : (JSValue*)lock_type : (JSValue*)sectionNum : (JSValue*)bIsRepeat : (JSValue*)type; --(JSValue*)DrawLockParagraph : (JSValue*)x : (JSValue*)y1 : (JSValue*)y2; --(JSValue*)DrawLockObjectRect : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h; --(JSValue*)DrawEmptyTableLine : (JSValue*)x1 : (JSValue*)y1 : (JSValue*)x2 : (JSValue*)y2; --(JSValue*)DrawSpellingLine : (JSValue*)y0 : (JSValue*)x0 : (JSValue*)x1 : (JSValue*)w; -// smart methods for horizontal / vertical lines --(JSValue*)drawHorLine : (JSValue*)align : (JSValue*)y : (JSValue*)x : (JSValue*)r : (JSValue*)penW; --(JSValue*)drawHorLine2 : (JSValue*)align : (JSValue*)y : (JSValue*)x : (JSValue*)r : (JSValue*)penW; --(JSValue*)drawVerLine : (JSValue*)align : (JSValue*)x : (JSValue*)y : (JSValue*)b : (JSValue*)penW; -// мега крутые функции для таблиц --(JSValue*)drawHorLineExt : (JSValue*)align : (JSValue*)y : (JSValue*)x : (JSValue*)r : (JSValue*)penW : (JSValue*)leftMW : (JSValue*)rightMW; --(JSValue*)rect : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h; --(JSValue*)TableRect : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h; -// функции клиппирования --(JSValue*)AddClipRect : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h; --(JSValue*)RemoveClipRect; --(JSValue*)SetClip : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h; --(JSValue*)RemoveClip; --(JSValue*)drawCollaborativeChanges : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h : (JSValue*)r : (JSValue*)g : (JSValue*)b : (JSValue*)a; --(JSValue*)drawMailMergeField : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h; --(JSValue*)drawSearchResult : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h; --(JSValue*)drawFlowAnchor : (JSValue*)x : (JSValue*)y; --(JSValue*)SavePen; --(JSValue*)RestorePen; --(JSValue*)SaveBrush; --(JSValue*)RestoreBrush; --(JSValue*)SavePenBrush; --(JSValue*)RestorePenBrush; --(JSValue*)SaveGrState; --(JSValue*)RestoreGrState; --(JSValue*)StartClipPath; --(JSValue*)EndClipPath; --(JSValue*)StartCheckTableDraw; --(JSValue*)SetTextClipRect : (JSValue*)_l : (JSValue*)_t : (JSValue*)_r : (JSValue*)_b; --(JSValue*)AddSmartRect : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h : (JSValue*)pen_w; --(JSValue*)CheckUseFonts2 : (JSValue*)_transform; --(JSValue*)UncheckUseFonts2; --(JSValue*)Drawing_StartCheckBounds : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h; --(JSValue*)Drawing_EndCheckBounds; --(JSValue*)DrawPresentationComment : (JSValue*)type : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h; --(JSValue*)DrawPolygon : (JSValue*)oPath : (JSValue*)lineWidth : (JSValue*)shift; --(JSValue*)DrawFootnoteRect : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h; -// new methods --(JSValue*)toDataURL: (JSValue*)type; --(JSValue*)GetPenColor; --(JSValue*)GetBrushColor; --(JSValue*)put_brushTexture : (JSValue*)src : (JSValue*)type; --(JSValue*)put_brushTextureMode : (JSValue*)mode; --(JSValue*)put_BrushTextureAlpha : (JSValue*)a; --(JSValue*)put_BrushGradient : (JSValue*)colors : (JSValue*)n : (JSValue*)x0 : (JSValue*)y0 : (JSValue*)x1 : (JSValue*)y1 : (JSValue*)r0 : (JSValue*)r1; --(JSValue*)TransformPointX : (JSValue*)x : (JSValue*)y; --(JSValue*)TransformPointY : (JSValue*)x : (JSValue*)y; --(JSValue*)put_LineJoin : (JSValue*)join; --(JSValue*)get_LineJoin; --(JSValue*)put_TextureBounds : (JSValue*)x : (JSValue*)y : (JSValue*)w : (JSValue*)h; --(JSValue*)GetlineWidth; --(JSValue*)DrawPath : (JSValue*)path; --(JSValue*)CoordTransformOffset : (JSValue*)tx : (JSValue*)ty; --(JSValue*)GetTransform; - -@end - -@interface CJSCGraphics : NSObject -{ -@public - CGraphicsEmbed* m_internal; -} -@end - -@implementation CJSCGraphics - -EMBED_OBJECT_WRAPPER_METHODS(CGraphicsEmbed) - -FUNCTION_WRAPPER_JS_5(create, init) -FUNCTION_WRAPPER_JS(EndDraw, EndDraw) -FUNCTION_WRAPPER_JS_2(put_GlobalAlpha, put_GlobalAlpha) -FUNCTION_WRAPPER_JS(Start_GlobalAlpha, Start_GlobalAlpha) -FUNCTION_WRAPPER_JS(End_GlobalAlpha, End_GlobalAlpha) -// pen methods -FUNCTION_WRAPPER_JS_4(p_color, p_color) -FUNCTION_WRAPPER_JS_1(p_width, p_width) -FUNCTION_WRAPPER_JS_1(p_dash, p_dash) -// brush methods -FUNCTION_WRAPPER_JS_4(b_color1, b_color1) -FUNCTION_WRAPPER_JS_4(b_color2, b_color2) -FUNCTION_WRAPPER_JS_6(transform, transform) -FUNCTION_WRAPPER_JS_1(CalculateFullTransform, CalculateFullTransform) -// path commands -FUNCTION_WRAPPER_JS(_s, _s) -FUNCTION_WRAPPER_JS(_e, _e) -FUNCTION_WRAPPER_JS(_z, _z) -FUNCTION_WRAPPER_JS_2(_m, _m) -FUNCTION_WRAPPER_JS_2(_l, _l) -FUNCTION_WRAPPER_JS_6(_c, _c) -FUNCTION_WRAPPER_JS_4(_c2, _c2) -FUNCTION_WRAPPER_JS(_ds, ds) -FUNCTION_WRAPPER_JS(_df, df) -// canvas state -FUNCTION_WRAPPER_JS(_save, save) -FUNCTION_WRAPPER_JS(_restore, restore) -FUNCTION_WRAPPER_JS(_clip, clip) -FUNCTION_WRAPPER_JS(_reset, reset) -FUNCTION_WRAPPER_JS(_FreeFont, FreeFont) -FUNCTION_WRAPPER_JS(_ClearLastFont, ClearLastFont) -// images -FUNCTION_WRAPPER_JS_7(drawImage2, drawImage2) -FUNCTION_WRAPPER_JS_8(drawImage, drawImage) -// text -FUNCTION_WRAPPER_JS(GetFont, GetFont) -FUNCTION_WRAPPER_JS_2(font, font) -FUNCTION_WRAPPER_JS_4(SetFont, SetFont) -FUNCTION_WRAPPER_JS (GetTextPr, GetTextPr) -FUNCTION_WRAPPER_JS_3(FillText, FillText) -FUNCTION_WRAPPER_JS_3(t, t) -FUNCTION_WRAPPER_JS_5(FillText2, FillText2) -FUNCTION_WRAPPER_JS_5(t2, t2) -FUNCTION_WRAPPER_JS_3(FillTextCode, FillTextCode) -FUNCTION_WRAPPER_JS_3(tg, tg) -FUNCTION_WRAPPER_JS_1(charspace, charspace) -// private methods -FUNCTION_WRAPPER_JS_2(private_FillGlyph, private_FillGlyph) -FUNCTION_WRAPPER_JS_3(private_FillGlyphC, private_FillGlyphC) -FUNCTION_WRAPPER_JS_1(private_FillGlyph2, private_FillGlyph2) -FUNCTION_WRAPPER_JS_1(SetIntegerGrid, SetIntegerGrid) -FUNCTION_WRAPPER_JS (GetIntegerGrid, GetIntegerGrid) -FUNCTION_WRAPPER_JS_3(DrawStringASCII, DrawStringASCII) -FUNCTION_WRAPPER_JS_3(DrawStringASCII2, DrawStringASCII2) -FUNCTION_WRAPPER_JS_5(DrawHeaderEdit, DrawHeaderEdit) -FUNCTION_WRAPPER_JS_5(DrawFooterEdit, DrawFooterEdit) -FUNCTION_WRAPPER_JS_3(DrawLockParagraph, DrawLockParagraph) -FUNCTION_WRAPPER_JS_4(DrawLockObjectRect, DrawLockObjectRect) -FUNCTION_WRAPPER_JS_4(DrawEmptyTableLine, DrawEmptyTableLine) -FUNCTION_WRAPPER_JS_4(DrawSpellingLine, DrawSpellingLine) -// smart methods for horizontal / vertical lines -FUNCTION_WRAPPER_JS_5(drawHorLine, drawHorLine) -FUNCTION_WRAPPER_JS_5(drawHorLine2, drawHorLine2) -FUNCTION_WRAPPER_JS_5(drawVerLine, drawVerLine) -// мега крутые функции для таблиц -FUNCTION_WRAPPER_JS_7(drawHorLineExt, drawHorLineExt) -FUNCTION_WRAPPER_JS_4(rect, rect) -FUNCTION_WRAPPER_JS_4(TableRect, TableRect) -// функции клиппирования -FUNCTION_WRAPPER_JS_4(AddClipRect, AddClipRect) -FUNCTION_WRAPPER_JS (RemoveClipRect, RemoveClipRect) -FUNCTION_WRAPPER_JS_4(SetClip, SetClip) -FUNCTION_WRAPPER_JS(RemoveClip, RemoveClip) -FUNCTION_WRAPPER_JS_8(drawCollaborativeChanges, drawCollaborativeChanges) -FUNCTION_WRAPPER_JS_4(drawMailMergeField, drawMailMergeField) -FUNCTION_WRAPPER_JS_4(drawSearchResult, drawSearchResult) -FUNCTION_WRAPPER_JS_2(drawFlowAnchor, drawFlowAnchor) -FUNCTION_WRAPPER_JS(SavePen, SavePen) -FUNCTION_WRAPPER_JS(RestorePen, RestorePen) -FUNCTION_WRAPPER_JS(SaveBrush, SaveBrush) -FUNCTION_WRAPPER_JS(RestoreBrush, RestoreBrush) -FUNCTION_WRAPPER_JS(SavePenBrush, SavePenBrush) -FUNCTION_WRAPPER_JS(RestorePenBrush, RestorePenBrush) -FUNCTION_WRAPPER_JS(SaveGrState, SaveGrState) -FUNCTION_WRAPPER_JS(RestoreGrState, RestoreGrState) -FUNCTION_WRAPPER_JS(StartClipPath, StartClipPath) -FUNCTION_WRAPPER_JS(EndClipPath, EndClipPath) -FUNCTION_WRAPPER_JS(StartCheckTableDraw, StartCheckTableDraw) -FUNCTION_WRAPPER_JS_4(SetTextClipRect, SetTextClipRect) -FUNCTION_WRAPPER_JS_5(AddSmartRect, AddSmartRect) -FUNCTION_WRAPPER_JS_1(CheckUseFonts2, CheckUseFonts2) -FUNCTION_WRAPPER_JS(UncheckUseFonts2, UncheckUseFonts2) -FUNCTION_WRAPPER_JS_4(Drawing_StartCheckBounds, Drawing_StartCheckBounds) -FUNCTION_WRAPPER_JS(Drawing_EndCheckBounds, Drawing_EndCheckBounds) -FUNCTION_WRAPPER_JS_5(DrawPresentationComment, DrawPresentationComment) -FUNCTION_WRAPPER_JS_3(DrawPolygon, DrawPolygon) -FUNCTION_WRAPPER_JS_4(DrawFootnoteRect, DrawFootnoteRect) -// new methods -FUNCTION_WRAPPER_JS_1(toDataURL, toDataURL) -FUNCTION_WRAPPER_JS(GetPenColor, GetPenColor) -FUNCTION_WRAPPER_JS(GetBrushColor, GetBrushColor) -FUNCTION_WRAPPER_JS_2(put_brushTexture, put_brushTexture) -FUNCTION_WRAPPER_JS_1(put_brushTextureMode, put_brushTextureMode) -FUNCTION_WRAPPER_JS_1(put_BrushTextureAlpha, put_BrushTextureAlpha) -FUNCTION_WRAPPER_JS_8(put_BrushGradient, put_BrushGradient) -FUNCTION_WRAPPER_JS_2(TransformPointX, TransformPointX) -FUNCTION_WRAPPER_JS_2(TransformPointY, TransformPointY) -FUNCTION_WRAPPER_JS_1(put_LineJoin, put_LineJoin) -FUNCTION_WRAPPER_JS(get_LineJoin, get_LineJoin) -FUNCTION_WRAPPER_JS_4(put_TextureBounds, put_TextureBounds) -FUNCTION_WRAPPER_JS(GetlineWidth, GetlineWidth) -FUNCTION_WRAPPER_JS_1(DrawPath, DrawPath) -FUNCTION_WRAPPER_JS_2(_oordTransformOffset, CoordTransformOffset) -FUNCTION_WRAPPER_JS(GetTransform, GetTransform) - -@end - -void CGraphicsEmbed::CreateObjectInContext(const std::string &name, JSSmart context) -{ - context->m_internal->context[[NSString stringWithAString:name]] = ^(){ - return [[CJSCGraphics alloc] init]; - }; -} diff --git a/DesktopEditor/doctrenderer/embed/v8/v8_Graphics.cpp b/DesktopEditor/doctrenderer/embed/v8/v8_Graphics.cpp deleted file mode 100644 index 3fccac2b71..0000000000 --- a/DesktopEditor/doctrenderer/embed/v8/v8_Graphics.cpp +++ /dev/null @@ -1,260 +0,0 @@ -#include "../GraphicsEmbed.h" -#include "../../js_internal/v8/v8_base.h" - -namespace NSGraphics -{ - #define CURRENTWRAPPER CGraphicsEmbed - - // FUNCTION - FUNCTION_WRAPPER_V8_5(_init, init) - FUNCTION_WRAPPER_V8 (_EndDraw, EndDraw) - FUNCTION_WRAPPER_V8_2(_put_GlobalAlpha, put_GlobalAlpha) - FUNCTION_WRAPPER_V8 (_Start_GlobalAlpha, Start_GlobalAlpha) - FUNCTION_WRAPPER_V8 (_End_GlobalAlpha, End_GlobalAlpha) - // pen methods - FUNCTION_WRAPPER_V8_4(_p_color, p_color) - FUNCTION_WRAPPER_V8_1(_p_width, p_width) - FUNCTION_WRAPPER_V8_1(_p_dash, p_dash) - // brush methods - FUNCTION_WRAPPER_V8_4(_b_color1, b_color1) - FUNCTION_WRAPPER_V8_4(_b_color2, b_color2) - FUNCTION_WRAPPER_V8_6(_transform, transform) - FUNCTION_WRAPPER_V8_1(_CalculateFullTransform, CalculateFullTransform) - // path commands - FUNCTION_WRAPPER_V8 (__s, _s) - FUNCTION_WRAPPER_V8 (__e, _e) - FUNCTION_WRAPPER_V8 (__z, _z) - FUNCTION_WRAPPER_V8_2(__m, _m) - FUNCTION_WRAPPER_V8_2(__l, _l) - FUNCTION_WRAPPER_V8_6(__c, _c) - FUNCTION_WRAPPER_V8_4(__c2, _c2) - FUNCTION_WRAPPER_V8 (_ds, ds) - FUNCTION_WRAPPER_V8 (_df, df) - // canvas state - FUNCTION_WRAPPER_V8 (_save, save) - FUNCTION_WRAPPER_V8 (_restore, restore) - FUNCTION_WRAPPER_V8 (_clip, clip) - FUNCTION_WRAPPER_V8 (_reset, reset) - FUNCTION_WRAPPER_V8 (_FreeFont, FreeFont) - FUNCTION_WRAPPER_V8 (_ClearLastFont, ClearLastFont) - // images - FUNCTION_WRAPPER_V8_7(_drawImage2, drawImage2) - FUNCTION_WRAPPER_V8_8(_drawImage, drawImage) - // text - FUNCTION_WRAPPER_V8 (_GetFont, GetFont) - FUNCTION_WRAPPER_V8_2(_font, font) - FUNCTION_WRAPPER_V8_4(_SetFont, SetFont) - FUNCTION_WRAPPER_V8 (_GetTextPr, GetTextPr) - FUNCTION_WRAPPER_V8_3(_FillText, FillText) - FUNCTION_WRAPPER_V8_3(_t, t) - FUNCTION_WRAPPER_V8_5(_FillText2, FillText2) - FUNCTION_WRAPPER_V8_5(_t2, t2) - FUNCTION_WRAPPER_V8_3(_FillTextCode, FillTextCode) - FUNCTION_WRAPPER_V8_3(_tg, tg) - FUNCTION_WRAPPER_V8_1(_charspace, charspace) - // private methods - FUNCTION_WRAPPER_V8_2(_private_FillGlyph, private_FillGlyph) - FUNCTION_WRAPPER_V8_3(_private_FillGlyphC, private_FillGlyphC) - FUNCTION_WRAPPER_V8_1(_private_FillGlyph2, private_FillGlyph2) - FUNCTION_WRAPPER_V8_1(_SetIntegerGrid, SetIntegerGrid) - FUNCTION_WRAPPER_V8 (_GetIntegerGrid, GetIntegerGrid) - FUNCTION_WRAPPER_V8_3(_DrawStringASCII, DrawStringASCII) - FUNCTION_WRAPPER_V8_3(_DrawStringASCII2, DrawStringASCII2) - FUNCTION_WRAPPER_V8_5(_DrawHeaderEdit, DrawHeaderEdit) - FUNCTION_WRAPPER_V8_5(_DrawFooterEdit, DrawFooterEdit) - FUNCTION_WRAPPER_V8_3(_DrawLockParagraph, DrawLockParagraph) - FUNCTION_WRAPPER_V8_4(_DrawLockObjectRect, DrawLockObjectRect) - FUNCTION_WRAPPER_V8_4(_DrawEmptyTableLine, DrawEmptyTableLine) - FUNCTION_WRAPPER_V8_4(_DrawSpellingLine, DrawSpellingLine) - // smart methods for horizontal / vertical lines - FUNCTION_WRAPPER_V8_5(_drawHorLine, drawHorLine) - FUNCTION_WRAPPER_V8_5(_drawHorLine2, drawHorLine2) - FUNCTION_WRAPPER_V8_5(_drawVerLine, drawVerLine) - // мега крутые функции для таблиц - FUNCTION_WRAPPER_V8_7(_drawHorLineExt, drawHorLineExt) - FUNCTION_WRAPPER_V8_4(_rect, rect) - FUNCTION_WRAPPER_V8_4(_TableRect, TableRect) - // функции клиппирования - FUNCTION_WRAPPER_V8_4(_AddClipRect, AddClipRect) - FUNCTION_WRAPPER_V8 (_RemoveClipRect, RemoveClipRect) - FUNCTION_WRAPPER_V8_4(_SetClip, SetClip) - FUNCTION_WRAPPER_V8 (_RemoveClip, RemoveClip) - FUNCTION_WRAPPER_V8_8(_drawCollaborativeChanges, drawCollaborativeChanges) - FUNCTION_WRAPPER_V8_4(_drawMailMergeField, drawMailMergeField) - FUNCTION_WRAPPER_V8_4(_drawSearchResult, drawSearchResult) - FUNCTION_WRAPPER_V8_2(_drawFlowAnchor, drawFlowAnchor) - FUNCTION_WRAPPER_V8 (_SavePen, SavePen) - FUNCTION_WRAPPER_V8 (_RestorePen, RestorePen) - FUNCTION_WRAPPER_V8 (_SaveBrush, SaveBrush) - FUNCTION_WRAPPER_V8 (_RestoreBrush, RestoreBrush) - FUNCTION_WRAPPER_V8 (_SavePenBrush, SavePenBrush) - FUNCTION_WRAPPER_V8 (_RestorePenBrush, RestorePenBrush) - FUNCTION_WRAPPER_V8 (_SaveGrState, SaveGrState) - FUNCTION_WRAPPER_V8 (_RestoreGrState, RestoreGrState) - FUNCTION_WRAPPER_V8 (_StartClipPath, StartClipPath) - FUNCTION_WRAPPER_V8 (_EndClipPath, EndClipPath) - FUNCTION_WRAPPER_V8 (_StartCheckTableDraw, StartCheckTableDraw) - FUNCTION_WRAPPER_V8_4(_SetTextClipRect, SetTextClipRect) - FUNCTION_WRAPPER_V8_5(_AddSmartRect, AddSmartRect) - FUNCTION_WRAPPER_V8_1(_CheckUseFonts2, CheckUseFonts2) - FUNCTION_WRAPPER_V8 (_UncheckUseFonts2, UncheckUseFonts2) - FUNCTION_WRAPPER_V8_4(_Drawing_StartCheckBounds, Drawing_StartCheckBounds) - FUNCTION_WRAPPER_V8 (_Drawing_EndCheckBounds, Drawing_EndCheckBounds) - FUNCTION_WRAPPER_V8_5(_DrawPresentationComment, DrawPresentationComment) - FUNCTION_WRAPPER_V8_3(_DrawPolygon, DrawPolygon) - FUNCTION_WRAPPER_V8_4(_DrawFootnoteRect, DrawFootnoteRect) - // new methods - FUNCTION_WRAPPER_V8_1(_toDataURL, toDataURL) - FUNCTION_WRAPPER_V8 (_GetPenColor, GetPenColor) - FUNCTION_WRAPPER_V8 (_GetBrushColor, GetBrushColor) - FUNCTION_WRAPPER_V8_2(_put_brushTexture, put_brushTexture) - FUNCTION_WRAPPER_V8_1(_put_brushTextureMode, put_brushTextureMode) - FUNCTION_WRAPPER_V8_1(_put_BrushTextureAlpha, put_BrushTextureAlpha) - FUNCTION_WRAPPER_V8_8(_put_BrushGradient, put_BrushGradient) - FUNCTION_WRAPPER_V8_2(_TransformPointX, TransformPointX) - FUNCTION_WRAPPER_V8_2(_TransformPointY, TransformPointY) - FUNCTION_WRAPPER_V8_1(_put_LineJoin, put_LineJoin) - FUNCTION_WRAPPER_V8 (_get_LineJoin, get_LineJoin) - FUNCTION_WRAPPER_V8_4(_put_TextureBounds, put_TextureBounds) - FUNCTION_WRAPPER_V8 (_GetlineWidth, GetlineWidth) - FUNCTION_WRAPPER_V8_1(_DrawPath, DrawPath) - FUNCTION_WRAPPER_V8_2(_CoordTransformOffset, CoordTransformOffset) - FUNCTION_WRAPPER_V8 (_GetTransform, GetTransform) - - v8::Handle CreateGraphicsTemplate(v8::Isolate* isolate) - { - v8::EscapableHandleScope handle_scope(isolate); - - v8::Local result = v8::ObjectTemplate::New(); - result->SetInternalFieldCount(1); - - v8::Isolate* current = v8::Isolate::GetCurrent(); - - // методы - NSV8Objects::Template_Set(result, "create", _init); - NSV8Objects::Template_Set(result, "EndDraw", _EndDraw); - NSV8Objects::Template_Set(result, "put_GlobalAlpha", _put_GlobalAlpha); - NSV8Objects::Template_Set(result, "Start_GlobalAlpha", _Start_GlobalAlpha); - NSV8Objects::Template_Set(result, "End_GlobalAlpha", _End_GlobalAlpha); - NSV8Objects::Template_Set(result, "p_color", _p_color); - NSV8Objects::Template_Set(result, "p_width", _p_width); - NSV8Objects::Template_Set(result, "p_dash", _p_dash); - NSV8Objects::Template_Set(result, "b_color1", _b_color1); - NSV8Objects::Template_Set(result, "b_color2", _b_color2); - NSV8Objects::Template_Set(result, "transform", _transform); - NSV8Objects::Template_Set(result, "CalculateFullTransform", _CalculateFullTransform); - NSV8Objects::Template_Set(result, "_s", __s); - NSV8Objects::Template_Set(result, "_e", __e); - NSV8Objects::Template_Set(result, "_z", __z); - NSV8Objects::Template_Set(result, "_m", __m); - NSV8Objects::Template_Set(result, "_l", __l); - NSV8Objects::Template_Set(result, "_c", __c); - NSV8Objects::Template_Set(result, "_c2", __c2); - NSV8Objects::Template_Set(result, "ds", _ds); - NSV8Objects::Template_Set(result, "df", _df); - NSV8Objects::Template_Set(result, "save", _save); - NSV8Objects::Template_Set(result, "restore", _restore); - NSV8Objects::Template_Set(result, "clip", _clip); - NSV8Objects::Template_Set(result, "reset", _reset); - NSV8Objects::Template_Set(result, "FreeFont", _FreeFont); - NSV8Objects::Template_Set(result, "ClearLastFont", _ClearLastFont); - NSV8Objects::Template_Set(result, "drawImage2", _drawImage2); - NSV8Objects::Template_Set(result, "drawImage", _drawImage); - NSV8Objects::Template_Set(result, "GetFont", _GetFont); - NSV8Objects::Template_Set(result, "font", _font); - NSV8Objects::Template_Set(result, "SetFont", _SetFont); - NSV8Objects::Template_Set(result, "GetTextPr", _GetTextPr); - NSV8Objects::Template_Set(result, "FillText", _FillText); - NSV8Objects::Template_Set(result, "t", _t); - NSV8Objects::Template_Set(result, "FillText2", _FillText2); - NSV8Objects::Template_Set(result, "t2", _t2); - NSV8Objects::Template_Set(result, "FillTextCode", _FillTextCode); - NSV8Objects::Template_Set(result, "tg", _tg); - NSV8Objects::Template_Set(result, "charspace", _charspace); - NSV8Objects::Template_Set(result, "private_FillGlyph", _private_FillGlyph); - NSV8Objects::Template_Set(result, "private_FillGlyphC", _private_FillGlyphC); - NSV8Objects::Template_Set(result, "private_FillGlyph2", _private_FillGlyph2); - NSV8Objects::Template_Set(result, "SetIntegerGrid", _SetIntegerGrid); - NSV8Objects::Template_Set(result, "GetIntegerGrid", _GetIntegerGrid); - NSV8Objects::Template_Set(result, "DrawStringASCII", _DrawStringASCII); - NSV8Objects::Template_Set(result, "DrawStringASCII2", _DrawStringASCII2); - NSV8Objects::Template_Set(result, "DrawHeaderEdit", _DrawHeaderEdit); - NSV8Objects::Template_Set(result, "DrawFooterEdit", _DrawFooterEdit); - NSV8Objects::Template_Set(result, "DrawLockParagraph", _DrawLockParagraph); - NSV8Objects::Template_Set(result, "DrawLockObjectRect", _DrawLockObjectRect); - NSV8Objects::Template_Set(result, "DrawEmptyTableLine", _DrawEmptyTableLine); - NSV8Objects::Template_Set(result, "DrawSpellingLine", _DrawSpellingLine); - NSV8Objects::Template_Set(result, "drawHorLine", _drawHorLine); - NSV8Objects::Template_Set(result, "drawHorLine2", _drawHorLine2); - NSV8Objects::Template_Set(result, "drawVerLine", _drawVerLine); - NSV8Objects::Template_Set(result, "drawHorLineExt", _drawHorLineExt); - NSV8Objects::Template_Set(result, "rect", _rect); - NSV8Objects::Template_Set(result, "TableRect", _TableRect); - NSV8Objects::Template_Set(result, "AddClipRect", _AddClipRect); - NSV8Objects::Template_Set(result, "RemoveClipRect", _RemoveClipRect); - NSV8Objects::Template_Set(result, "SetClip", _SetClip); - NSV8Objects::Template_Set(result, "RemoveClip", _RemoveClip); - NSV8Objects::Template_Set(result, "drawCollaborativeChanges", _drawCollaborativeChanges); - NSV8Objects::Template_Set(result, "drawMailMergeField", _drawMailMergeField); - NSV8Objects::Template_Set(result, "drawSearchResult", _drawSearchResult); - NSV8Objects::Template_Set(result, "drawFlowAnchor", _drawFlowAnchor); - NSV8Objects::Template_Set(result, "SavePen", _SavePen); - NSV8Objects::Template_Set(result, "RestorePen", _RestorePen); - NSV8Objects::Template_Set(result, "SaveBrush", _SaveBrush); - NSV8Objects::Template_Set(result, "RestoreBrush", _RestoreBrush); - NSV8Objects::Template_Set(result, "SavePenBrush", _SavePenBrush); - NSV8Objects::Template_Set(result, "RestorePenBrush", _RestorePenBrush); - NSV8Objects::Template_Set(result, "SaveGrState", _SaveGrState); - NSV8Objects::Template_Set(result, "RestoreGrState", _RestoreGrState); - NSV8Objects::Template_Set(result, "StartClipPath", _StartClipPath); - NSV8Objects::Template_Set(result, "EndClipPath", _EndClipPath); - NSV8Objects::Template_Set(result, "StartCheckTableDraw", _StartCheckTableDraw); - NSV8Objects::Template_Set(result, "SetTextClipRect", _SetTextClipRect); - NSV8Objects::Template_Set(result, "AddSmartRect", _AddSmartRect); - NSV8Objects::Template_Set(result, "CheckUseFonts2", _CheckUseFonts2); - NSV8Objects::Template_Set(result, "UncheckUseFonts2", _UncheckUseFonts2); - NSV8Objects::Template_Set(result, "Drawing_StartCheckBounds", _Drawing_StartCheckBounds); - NSV8Objects::Template_Set(result, "Drawing_EndCheckBounds", _Drawing_EndCheckBounds); - NSV8Objects::Template_Set(result, "DrawPresentationComment", _DrawPresentationComment); - NSV8Objects::Template_Set(result, "DrawPolygon", _DrawPolygon); - NSV8Objects::Template_Set(result, "DrawFootnoteRect", _DrawFootnoteRect); - NSV8Objects::Template_Set(result, "toDataURL", _toDataURL); - NSV8Objects::Template_Set(result, "GetPenColor", _GetPenColor); - NSV8Objects::Template_Set(result, "GetBrushColor", _GetBrushColor); - NSV8Objects::Template_Set(result, "put_brushTexture", _put_brushTexture); - NSV8Objects::Template_Set(result, "put_brushTextureMode", _put_brushTextureMode); - NSV8Objects::Template_Set(result, "put_BrushTextureAlpha", _put_BrushTextureAlpha); - NSV8Objects::Template_Set(result, "put_BrushGradient", _put_BrushGradient); - NSV8Objects::Template_Set(result, "TransformPointX", _TransformPointX); - NSV8Objects::Template_Set(result, "TransformPointY", _TransformPointY); - NSV8Objects::Template_Set(result, "put_LineJoin", _put_LineJoin); - NSV8Objects::Template_Set(result, "get_LineJoin", _get_LineJoin); - NSV8Objects::Template_Set(result, "put_TextureBounds", _put_TextureBounds); - NSV8Objects::Template_Set(result, "GetlineWidth", _GetlineWidth); - NSV8Objects::Template_Set(result, "DrawPath", _DrawPath); - NSV8Objects::Template_Set(result, "CoordTransformOffset", _CoordTransformOffset); - NSV8Objects::Template_Set(result, "GetTransform", _GetTransform); - - return handle_scope.Escape(result); - } - - void CreateNativeGraphics(const v8::FunctionCallbackInfo& args) - { - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope scope(isolate); - - v8::Handle GraphicsTemplate = NSGraphics::CreateGraphicsTemplate(isolate); - CGraphicsEmbed* pGraphics = new CGraphicsEmbed(); - - v8::Local obj = GraphicsTemplate->NewInstance(isolate->GetCurrentContext()).ToLocalChecked(); - obj->SetInternalField(0, v8::External::New(CV8Worker::GetCurrent(), pGraphics)); - - args.GetReturnValue().Set(obj); - } -} - -void CGraphicsEmbed::CreateObjectInContext(const std::string& name, JSSmart context) -{ - v8::Isolate* current = CV8Worker::GetCurrent(); - context->m_internal->m_global->Set(current, name.c_str(), v8::FunctionTemplate::New(current, NSGraphics::CreateNativeGraphics)); -} diff --git a/DesktopEditor/doctrenderer/graphics.cpp b/DesktopEditor/doctrenderer/graphics.cpp deleted file mode 100644 index 82c3c755f4..0000000000 --- a/DesktopEditor/doctrenderer/graphics.cpp +++ /dev/null @@ -1,1339 +0,0 @@ -#include "graphics.h" -#include "../common/Base64.h" - -#include -#include - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -namespace NSGraphics -{ -void CGraphics::init(NSNativeControl::CNativeControl* oNative, double width_px, double height_px, double width_mm, double height_mm) -{ - m_sApplicationImagesDirectory = oNative->m_strImagesDirectory; - m_sApplicationFontsDirectory = oNative->m_strFontsDirectory; - #ifdef _DEBUG - std::wcout << L"init "<< m_sApplicationImagesDirectory << L" " << m_sApplicationFontsDirectory << L" " << width_px << L" " << height_px << L" " << width_mm << L" " << height_mm << std::endl; - #endif - m_pApplicationFonts = NSFonts::NSApplication::Create(); - m_pApplicationFonts->InitializeFromFolder(m_sApplicationFontsDirectory.empty() ? NSFile::GetProcessDirectory() : m_sApplicationFontsDirectory); - NSFonts::IFontManager* pManager = m_pApplicationFonts->GenerateFontManager(); - - m_pRenderer = NSGraphics::Create(); - m_pRenderer->SetFontManager(pManager); - - int nRasterW = (int)width_px; - int nRasterH = (int)height_px; - BYTE* pData = new BYTE[4 * nRasterW * nRasterH]; - - unsigned int back = 0xffffff; - unsigned int* pData32 = (unsigned int*)pData; - unsigned int* pData32End = pData32 + nRasterW * nRasterH; - while (pData32 < pData32End) - *pData32++ = back; - - m_oFrame.put_Data(pData); - m_oFrame.put_Width(nRasterW); - m_oFrame.put_Height(nRasterH); - m_oFrame.put_Stride(4 * nRasterW); - - m_pRenderer->CreateFromBgraFrame(&m_oFrame); - m_pRenderer->SetSwapRGB(false); - - m_pRenderer->put_Width(width_mm); - m_pRenderer->put_Height(height_mm); -} -void CGraphics::put_GlobalAlpha(bool enable, double alpha) -{ - #ifdef _DEBUG - std::cout << "put_GlobalAlpha " << enable << " " << alpha << std::endl; - #endif - m_pRenderer->put_GlobalAlphaEnabled(enable, alpha); -} -void CGraphics::End_GlobalAlpha() -{ - #ifdef _DEBUG - std::cout << "End_GlobalAlpha " << std::endl; - #endif - bool bIsInteger = m_pRenderer->get_IntegerGrid(); - m_pRenderer->put_IntegerGrid(true); - - m_pRenderer->PathCommandEnd(); - b_color1(255, 255, 255, 140); - - m_pRenderer->AddRect(0.0, 0.0, m_pRenderer->GetPixW(), m_pRenderer->GetPixH()); - m_pRenderer->Fill(); - m_pRenderer->PathCommandEnd(); - - m_pRenderer->put_IntegerGrid(bIsInteger); -} -void CGraphics::p_color(int r, int g, int b, int a) -{ - #ifdef _DEBUG - std::cout << "p_color " << r << " " << g << " " << b << " " << a << std::endl; - #endif - m_pRenderer->put_PenColor(r | (g << 8) | (b << 16)); - m_pRenderer->put_PenAlpha(a); -} -void CGraphics::p_width(double w) -{ - #ifdef _DEBUG - std::cout << "p_width " << w << std::endl; - #endif - m_pRenderer->put_PenSize(w / 1000.0); -} -void CGraphics::p_dash(size_t length, double* dash) -{ - #ifdef _DEBUG - std::cout << "p_dash " << length << std::endl; - #endif - if(length > 0) - { - double dDpiX = 0; - m_pRenderer->get_DpiX(&dDpiX); - for(size_t i = 0; i < length; i++) - dash[i] *= (dDpiX / 25.4); - - m_pRenderer->put_PenDashStyle(Aggplus::DashStyleCustom); - m_pRenderer->PenDashPattern(dash, length); - } - else - m_pRenderer->put_PenDashStyle(Aggplus::DashStyleSolid); -} -void CGraphics::b_color1(int r, int g, int b, int a) -{ - #ifdef _DEBUG - std::cout << "b_color1 " << r << " " << g << " " << b << " " << a << std::endl; - #endif - m_pRenderer->put_BrushType(c_BrushTypeSolid); - m_pRenderer->put_BrushColor1(r | (g << 8) | (b << 16)); - m_pRenderer->put_BrushAlpha1(a); -} -void CGraphics::b_color2(int r, int g, int b, int a) -{ - #ifdef _DEBUG - std::cout << "b_color2 " << r << " " << g << " " << b << " " << a << std::endl; - #endif - m_pRenderer->put_BrushColor2(r | (g << 8) | (b << 16)); - m_pRenderer->put_BrushAlpha2(a); -} -void CGraphics::transform(double sx, double shy, double shx, double sy, double tx, double ty) -{ - #ifdef _DEBUG - std::cout << "transform " << sx << " " << shy << " " << shx << " " << sy << " " << tx << " " << ty << std::endl; - #endif - m_pRenderer->SetTransform(sx, shy, shx, sy, tx, ty); -} -void CGraphics::CalculateFullTransform() -{ - #ifdef _DEBUG - std::cout << "CalculateFullTransform " << std::endl; - #endif - m_pRenderer->CalculateFullTransform(); -} -void CGraphics::_s() -{ - #ifdef _DEBUG - std::cout << "_s " << std::endl; - #endif - m_pRenderer->PathCommandEnd(); -} -void CGraphics::_e() -{ - #ifdef _DEBUG - std::cout << "_e " << std::endl; - #endif - m_pRenderer->PathCommandEnd(); -} -void CGraphics::_z() -{ - #ifdef _DEBUG - std::cout << "_z " << std::endl; - #endif - m_pRenderer->PathCommandClose(); -} -void CGraphics::_m(double x, double y) -{ - #ifdef _DEBUG - std::cout << "_m " << x << " " << y << std::endl; - #endif - if (!m_pRenderer->get_IntegerGrid()) - m_pRenderer->PathCommandMoveTo(x, y); - else - { - m_pRenderer->GetFullTransform()->TransformPoint(x, y); - m_pRenderer->PathCommandMoveTo((int)x + 0.5, (int)y + 0.5); - } -} -void CGraphics::_l(double x, double y) -{ - #ifdef _DEBUG - std::cout << "_l " << x << " " << y << std::endl; - #endif - if (!m_pRenderer->get_IntegerGrid()) - m_pRenderer->PathCommandLineTo(x, y); - else - { - m_pRenderer->GetFullTransform()->TransformPoint(x, y); - m_pRenderer->PathCommandLineTo((int)x + 0.5, (int)y + 0.5); - } -} -void CGraphics::_c (double x1, double y1, double x2, double y2, double x3, double y3) -{ - #ifdef _DEBUG - std::cout << "_c " << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << std::endl; - #endif - if (!m_pRenderer->get_IntegerGrid()) - m_pRenderer->PathCommandCurveTo(x1, y1, x2, y2, x3, y3); - else - { - m_pRenderer->GetFullTransform()->TransformPoint(x1, y1); - m_pRenderer->GetFullTransform()->TransformPoint(x2, y2); - m_pRenderer->GetFullTransform()->TransformPoint(x3, y3); - m_pRenderer->PathCommandCurveTo((int)x1 + 0.5, (int)y1 + 0.5, (int)x2 + 0.5, (int)y2 + 0.5, (int)x3 + 0.5, (int)y3 + 0.5); - } -} -void CGraphics::_c2(double x1, double y1, double x2, double y2) -{ - #ifdef _DEBUG - std::cout << "_c2 " << x1 << " " << y1 << " " << x2 << " " << y2 << std::endl; - #endif - if (!m_pRenderer->get_IntegerGrid()) - m_pRenderer->PathCommandCurveTo(x1, y1, x1, y1, x2, y2); - else - { - m_pRenderer->GetFullTransform()->TransformPoint(x1, y1); - m_pRenderer->GetFullTransform()->TransformPoint(x2, y2); - m_pRenderer->PathCommandCurveTo((int)x1 + 0.5, (int)y1 + 0.5, (int)x1 + 0.5, (int)y1 + 0.5, (int)x2 + 0.5, (int)y2 + 0.5); - } -} -void CGraphics::ds() -{ - #ifdef _DEBUG - std::cout << "ds " << std::endl; - #endif - m_pRenderer->Stroke(); -} -void CGraphics::df() -{ - #ifdef _DEBUG - std::cout << "df " << std::endl; - #endif - m_pRenderer->Fill(); -} -void CGraphics::save() -{ - #ifdef _DEBUG - std::cout << "save " << std::endl; - #endif - m_oFrame.SaveFile(m_sApplicationImagesDirectory + L"/img.png", _CXIMAGE_FORMAT_PNG); -} -void CGraphics::restore() -{ - #ifdef _DEBUG - std::cout << "restore " << std::endl; - #endif - m_pRenderer->BeginCommand(c_nResetClipType); - m_pRenderer->EndCommand (c_nResetClipType); -} -void CGraphics::clip() -{ - #ifdef _DEBUG - std::cout << "clip " << std::endl; - #endif - m_pRenderer->BeginCommand(c_nClipType); - m_pRenderer->EndCommand (c_nClipType); -} -void CGraphics::reset() -{ - #ifdef _DEBUG - std::cout << "reset " << std::endl; - #endif - m_pRenderer->ResetTransform(); -} -void CGraphics::FreeFont() -{ - #ifdef _DEBUG - std::cout << "FreeFont " << std::endl; - #endif - m_pRenderer->CloseFont(); -} -void CGraphics::ClearLastFont() -{ - #ifdef _DEBUG - std::cout << "ClearLastFont " << std::endl; - #endif - m_pRenderer->ClearInstallFont(); -} -void CGraphics::drawImage(const std::wstring& img, double x, double y, double w, double h, BYTE alpha) -{ - std::wstring strImage = (0 == img.find(L"theme") ? m_sApplicationThemesDirectory : m_sApplicationImagesDirectory) + L'/' + img; - #ifdef _DEBUG - std::wcout << L"drawImage " << strImage << L" " << x << " " << y << L" " << w << L" " << h << L" " << alpha << std::endl; - #endif - m_pRenderer->DrawImageFromFile(strImage, x, y, w, h, alpha); -} -std::wstring CGraphics::GetFont() -{ - #ifdef _DEBUG - std::cout << "GetFont " << std::endl; - #endif - return m_pRenderer->GetFontManager()->GetName(); -} -void CGraphics::SetFont(const std::wstring& name, int face, double size, int style) -{ - #ifdef _DEBUG - std::wcout << L"SetFont " << name << L" " << face << L" " << size << L" " << style << std::endl; - #endif - double DpiX, DpiY; - m_pRenderer->get_DpiX(&DpiX); - m_pRenderer->get_DpiY(&DpiY); - m_pRenderer->GetFontManager()->LoadFontByName(name, size, style, DpiX, DpiY); - - m_pRenderer->put_FontName (name); - m_pRenderer->put_FontFaceIndex(face); - m_pRenderer->put_FontSize (size); - m_pRenderer->put_FontStyle (style); -} -void CGraphics::FillText(double x, double y, int text) -{ - #ifdef _DEBUG - std::wcout << L"FillText " << (wchar_t)text << L" " << x << L" " << y << std::endl; - #endif - m_pRenderer->CommandDrawTextCHAR(text, x, y, 0, 0); -} -void CGraphics::t(double x, double y, const std::wstring& text) -{ - #ifdef _DEBUG - std::wcout << L"t " << text << L" " << x << L" " << y << std::endl; - #endif - m_pRenderer->CommandDrawText(text, x, y, 0, 0); -} -void CGraphics::tg(int text, double x, double y) -{ - #ifdef _DEBUG - std::wcout << L"tg " << text << L" " << x << L" " << y << std::endl; - #endif - m_pRenderer->put_FontStringGID(TRUE); - m_pRenderer->CommandDrawTextCHAR(text, x, y, 0, 0); - m_pRenderer->put_FontStringGID(FALSE); -} -void CGraphics::SetIntegerGrid(bool param) -{ - #ifdef _DEBUG - std::cout << "SetIntegerGrid " << param << std::endl; - #endif - m_pRenderer->put_IntegerGrid(param); -} -bool CGraphics::GetIntegerGrid() -{ - #ifdef _DEBUG - std::cout << "GetIntegerGrid " << std::endl; - #endif - return m_pRenderer->get_IntegerGrid(); -} -void CGraphics::DrawStringASCII (const std::wstring& text, double x, double y) -{ - #ifdef _DEBUG - std::wcout << L"DrawStringASCII " << text << L" " << x << L" " << y << std::endl; - #endif - double DpiY; - m_pRenderer->get_DpiY(&DpiY); - - SavePenBrush(); - - b_color1(225, 225, 225, 255); - m_pRenderer->GetFontManager()->LoadString2(text, x, y); - TBBox oBox = m_pRenderer->GetFontManager()->MeasureString2(); - rect(x, y, oBox.fMinX, oBox.fMinY); - df(); - ds(); - - b_color1(68, 68, 68, 255); - t(x + 10.0 * 25.4 / DpiY, y - 5.0 * 25.4 / DpiY, text); - - RestorePenBrush(); -} -void CGraphics::DrawHeaderEdit(double yPos) -{ - #ifdef _DEBUG - std::cout << "DrawHeaderEdit " << std::endl; - #endif - m_pRenderer->PathCommandEnd(); - - Aggplus::CMatrix* pFull = m_pRenderer->GetFullTransform(); - double dPenSize = 0; - m_pRenderer->get_PenSize(&dPenSize); - - double _width; - m_pRenderer->get_Width(&_width); - pFull->TransformPoint(_width, yPos); - - BYTE nPenDashStyle = 0; - m_pRenderer->get_PenDashStyle(&nPenDashStyle); - - bool bIsIntegerGrid = m_pRenderer->get_IntegerGrid(); - if (!bIsIntegerGrid) - m_pRenderer->put_IntegerGrid(true); - - m_pRenderer->put_PenSize(2); - m_pRenderer->PathCommandStart(); - - double dash[2] = { 6, 3 }; - m_pRenderer->put_PenDashStyle(Aggplus::DashStyleCustom); - m_pRenderer->PenDashPattern(dash, 2); - - m_pRenderer->put_PenColor(0xBBBEC2); - - m_pRenderer->PathCommandMoveTo(0, (int)(yPos)); - m_pRenderer->PathCommandLineTo(_width, (int)(yPos)); - - m_pRenderer->Stroke(); - m_pRenderer->PathCommandEnd(); - - if (!bIsIntegerGrid) - m_pRenderer->put_IntegerGrid(false); - - m_pRenderer->put_PenSize(dPenSize); - m_pRenderer->put_PenDashStyle(nPenDashStyle); -} -void CGraphics::DrawFooterEdit(double yPos) -{ - #ifdef _DEBUG - std::cout << "DrawFooterEdit " << std::endl; - #endif - m_pRenderer->PathCommandEnd(); - - Aggplus::CMatrix* pFull = m_pRenderer->GetFullTransform(); - double dPenSize = 0; - m_pRenderer->get_PenSize(&dPenSize); - - double _width; - m_pRenderer->get_Width(&_width); - pFull->TransformPoint(_width, yPos); - - BYTE nPenDashStyle = 0; - m_pRenderer->get_PenDashStyle(&nPenDashStyle); - - bool bIsIntegerGrid = m_pRenderer->get_IntegerGrid(); - if (!bIsIntegerGrid) - m_pRenderer->put_IntegerGrid(true); - - m_pRenderer->put_PenSize(2); - m_pRenderer->PathCommandStart(); - - double dash[2] = { 6, 3 }; - m_pRenderer->put_PenDashStyle(Aggplus::DashStyleCustom); - m_pRenderer->PenDashPattern(dash, 2); - - m_pRenderer->put_PenColor(0xBBBEC2); - - m_pRenderer->PathCommandMoveTo(0, (int)(yPos)); - m_pRenderer->PathCommandLineTo(_width, (int)(yPos)); - - m_pRenderer->Stroke(); - m_pRenderer->PathCommandEnd(); - - if (!bIsIntegerGrid) - m_pRenderer->put_IntegerGrid(false); - - m_pRenderer->put_PenSize(dPenSize); - m_pRenderer->put_PenDashStyle(nPenDashStyle); -} -void CGraphics::DrawLockParagraph (double x, double y1, double y2) -{ - #ifdef _DEBUG - std::cout << "DrawLockParagraph " << std::endl; - #endif - m_pRenderer->PathCommandEnd(); - - Aggplus::CMatrix* pFull = m_pRenderer->GetFullTransform(); - double dPenSize = 0.0; - m_pRenderer->get_PenSize(&dPenSize); - BYTE nPenDashStyle = 0; - m_pRenderer->get_PenDashStyle(&nPenDashStyle); - m_pRenderer->put_PenColor(0x009C16); - - double _x = x; - double _xT = x; - double _y1 = y1; - double _y2 = y2; - pFull->TransformPoint(_x, _y1); - pFull->TransformPoint(_xT, _y2); - - _x = ((int)_x); - _xT = ((int)_xT); - _y1 = ((int)_y1) + 0.5; - _y2 = ((int)_y2) - 1.5; - - m_pRenderer->put_PenSize(1); - m_pRenderer->PathCommandStart(); - - double dash[2] = { 2.0, 2.0 }; - m_pRenderer->put_PenDashStyle(Aggplus::DashStyleCustom); - m_pRenderer->PenDashPattern(dash, 2); - - if(fabs(_x - _xT) > 0.001) - { - m_pRenderer->PathCommandMoveTo(x, y1); - m_pRenderer->PathCommandLineTo(x, y2); - - m_pRenderer->PathCommandMoveTo(x, y1); - m_pRenderer->PathCommandLineTo(x + 3.0, y1); - - m_pRenderer->PathCommandMoveTo(x, y2); - m_pRenderer->PathCommandLineTo(x + 3.0, y2); - - m_pRenderer->Stroke(); - m_pRenderer->PathCommandEnd(); - } - else - { - bool bIsIntegerGrid = m_pRenderer->get_IntegerGrid(); - if (!bIsIntegerGrid) - m_pRenderer->put_IntegerGrid(true); - - m_pRenderer->PathCommandMoveTo(_x + 0.5, _y1 - 0.5); - m_pRenderer->PathCommandLineTo(_x + 0.5, _y2 - 2.0); - - m_pRenderer->PathCommandMoveTo(_x, _y1); - m_pRenderer->PathCommandLineTo(_x + 3.0, _y1); - - m_pRenderer->PathCommandMoveTo(_x, _y2); - m_pRenderer->PathCommandLineTo(_x + 3.0, _y2); - - m_pRenderer->Stroke(); - m_pRenderer->PathCommandEnd(); - - if (!bIsIntegerGrid) - m_pRenderer->put_IntegerGrid(false); - } - - m_pRenderer->put_PenSize(dPenSize); - m_pRenderer->put_PenDashStyle(nPenDashStyle); -} -void CGraphics::DrawLockObjectRect(double x, double y, double w, double h) -{ - #ifdef _DEBUG - std::cout << "DrawLockObjectRect " << std::endl; - #endif - m_pRenderer->PathCommandEnd(); - - double dPenSize = 0.0; - m_pRenderer->get_PenSize(&dPenSize); - BYTE nPenDashStyle = 0; - m_pRenderer->get_PenDashStyle(&nPenDashStyle); - m_pRenderer->put_PenColor(0x009C16); - - m_pRenderer->put_PenSize(1); - - double dash[2] = { 2.0, 2.0 }; - m_pRenderer->put_PenDashStyle(Aggplus::DashStyleCustom); - m_pRenderer->PenDashPattern(dash, 2); - - double eps = 5.0; - rect(x - eps, y - eps, w + eps, h + eps); - - m_pRenderer->Stroke(); - m_pRenderer->put_PenSize(dPenSize); - m_pRenderer->put_PenDashStyle(nPenDashStyle); -} -void CGraphics::DrawEmptyTableLine(double x1, double y1, double x2, double y2) -{ - #ifdef _DEBUG - std::cout << "DrawEmptyTableLine " << std::endl; - #endif - m_pRenderer->PathCommandEnd(); - - Aggplus::CMatrix* pFull = m_pRenderer->GetFullTransform(); - double dPenSize = 0; - m_pRenderer->get_PenSize(&dPenSize); - - BYTE nPenDashStyle = 0; - m_pRenderer->get_PenDashStyle(&nPenDashStyle); - - double _x1 = x1; - double _y1 = y1; - double _x2 = x2; - double _y2 = y2; - pFull->TransformPoint(_x1, _y1); - pFull->TransformPoint(_x2, _y2); - - if (fabs(_x1 - _x2) < 0.001 || fabs(_y1 - _y2) < 0.001) - { - bool bIsIntegerGrid = m_pRenderer->get_IntegerGrid(); - if (!bIsIntegerGrid) - m_pRenderer->put_IntegerGrid(true); - - m_pRenderer->put_PenSize(1); - m_pRenderer->PathCommandStart(); - - double dash[2] = { 2, 2 }; - m_pRenderer->put_PenDashStyle(Aggplus::DashStyleCustom); - m_pRenderer->PenDashPattern(dash, 2); - - m_pRenderer->put_PenColor(0xBFA28A); - - if (fabs(_x1 - _x2) < 0.001) - { - double _dx = ((int)_x1) + 0.5; - double _dy1 = ((int)_y1); - double _dy2 = ((int)_y2); - m_pRenderer->PathCommandMoveTo(_dx, _dy1); - m_pRenderer->PathCommandLineTo(_dx, _dy2); - } - else - { - double _dy = ((int)_y1) + 0.5; - double _dx1 = ((int)_x1); - double _dx2 = ((int)_x2); - m_pRenderer->PathCommandMoveTo(_dx1, _dy); - m_pRenderer->PathCommandLineTo(_dx2, _dy); - } - - m_pRenderer->Stroke(); - m_pRenderer->PathCommandEnd(); - - if (!bIsIntegerGrid) - m_pRenderer->put_IntegerGrid(false); - } - else - { - bool bIsIntegerGrid = m_pRenderer->get_IntegerGrid(); - if (bIsIntegerGrid) - m_pRenderer->put_IntegerGrid(false); - - m_pRenderer->put_PenSize(0); - m_pRenderer->PathCommandStart(); - - double dash[2] = { 2, 2 }; - m_pRenderer->put_PenDashStyle(Aggplus::DashStyleCustom); - m_pRenderer->PenDashPattern(dash, 2); - - m_pRenderer->put_PenColor(0xBFA28A); - m_pRenderer->PathCommandMoveTo(x1, y1); - m_pRenderer->PathCommandLineTo(x2, y2); - m_pRenderer->Stroke(); - m_pRenderer->PathCommandEnd(); - - if (bIsIntegerGrid) - m_pRenderer->put_IntegerGrid(true); - } - - m_pRenderer->put_PenSize(dPenSize); - m_pRenderer->put_PenDashStyle(nPenDashStyle); -} -void CGraphics::DrawSpellingLine (double y0, double x0, double x1, double w) -{ - #ifdef _DEBUG - std::cout << "DrawSpellingLine " << std::endl; - #endif - Aggplus::CMatrix* pMatrix = m_pRenderer->GetTransformMatrix(); - if (!m_pRenderer->get_IntegerGrid()) - { - if (pMatrix->IsIdentity2()) - { - m_pRenderer->put_IntegerGrid(true); - m_pRenderer->drawHorLine(1, y0, x0, x1, w); - m_pRenderer->put_IntegerGrid(false); - } - else - { - m_pRenderer->put_PenSize(w); - m_pRenderer->PathCommandEnd(); - m_pRenderer->PathCommandMoveTo(x0, y0); - m_pRenderer->PathCommandLineTo(x1, y0); - m_pRenderer->Stroke(); - } - } - else - { - if(pMatrix->IsIdentity2()) - { - m_pRenderer->drawHorLine(1, y0, x0, x1, w); - } - else - { - m_pRenderer->put_IntegerGrid(false); - m_pRenderer->put_PenSize(w); - m_pRenderer->PathCommandEnd(); - m_pRenderer->PathCommandMoveTo(x0, y0); - m_pRenderer->PathCommandLineTo(x1, y0); - m_pRenderer->Stroke(); - m_pRenderer->put_IntegerGrid(true); - } - - } -} -void CGraphics::drawHorLine (BYTE align, double y, double x, double r, double penW) -{ - Aggplus::CMatrix* pMatrix = m_pRenderer->GetTransformMatrix(); - if (!m_pRenderer->get_IntegerGrid()) - { - if (pMatrix->IsIdentity2()) - { - m_pRenderer->put_IntegerGrid(true); - m_pRenderer->drawHorLine(align, y, x, r, penW); - m_pRenderer->put_IntegerGrid(false); - } - else - { - m_pRenderer->put_PenSize(penW); - m_pRenderer->PathCommandEnd(); - m_pRenderer->PathCommandMoveTo(x, y); - m_pRenderer->PathCommandLineTo(r, y); - m_pRenderer->Stroke(); - } - } - else - { - if(pMatrix->IsIdentity2()) - { - m_pRenderer->drawHorLine(align, y, x, r, penW); - } - else - { - m_pRenderer->put_IntegerGrid(false); - m_pRenderer->put_PenSize(penW); - m_pRenderer->PathCommandEnd(); - m_pRenderer->PathCommandMoveTo(x, y); - m_pRenderer->PathCommandLineTo(r, y); - m_pRenderer->Stroke(); - m_pRenderer->put_IntegerGrid(true); - } - - } -} -void CGraphics::drawHorLine2 (BYTE align, double y, double x, double r, double penW) -{ - Aggplus::CMatrix* pMatrix = m_pRenderer->GetTransformMatrix(); - if (!m_pRenderer->get_IntegerGrid()) - { - if (pMatrix->IsIdentity2()) - { - m_pRenderer->put_IntegerGrid(true); - m_pRenderer->drawHorLine2(align, y, x, r, penW); - m_pRenderer->put_IntegerGrid(false); - } - else - { - double _y1 = y - penW / 2; - double _y2 = _y1 + 2 * penW; - - m_pRenderer->put_PenSize(penW); - m_pRenderer->PathCommandEnd(); - m_pRenderer->PathCommandMoveTo(x, _y1); - m_pRenderer->PathCommandLineTo(r, _y1); - m_pRenderer->Stroke(); - - m_pRenderer->PathCommandEnd(); - m_pRenderer->PathCommandMoveTo(x, _y2); - m_pRenderer->PathCommandLineTo(r, _y2); - m_pRenderer->Stroke(); - } - } - else - { - if (pMatrix->IsIdentity2()) - { - m_pRenderer->drawHorLine2(align, y, x, r, penW); - } - else - { - m_pRenderer->put_IntegerGrid(false); - double _y1 = y - penW / 2; - double _y2 = _y1 + 2 * penW; - - m_pRenderer->put_PenSize(penW); - m_pRenderer->PathCommandEnd(); - m_pRenderer->PathCommandMoveTo(x, _y1); - m_pRenderer->PathCommandLineTo(r, _y1); - m_pRenderer->Stroke(); - - m_pRenderer->PathCommandEnd(); - m_pRenderer->PathCommandMoveTo(x, _y2); - m_pRenderer->PathCommandLineTo(r, _y2); - m_pRenderer->Stroke(); - m_pRenderer->put_IntegerGrid(true); - } - } -} -void CGraphics::drawVerLine (BYTE align, double x, double y, double b, double penW) -{ - if (!m_pRenderer->get_IntegerGrid()) - { - Aggplus::CMatrix* pMatrix = m_pRenderer->GetTransformMatrix(); - if (pMatrix->IsIdentity2()) - { - m_pRenderer->put_IntegerGrid(true); - m_pRenderer->drawVerLine(align, x, y, b, penW); - m_pRenderer->put_IntegerGrid(false); - } - else - { - m_pRenderer->put_PenSize(penW); - m_pRenderer->PathCommandEnd(); - m_pRenderer->PathCommandMoveTo(x, y); - m_pRenderer->PathCommandLineTo(x, b); - m_pRenderer->Stroke(); - } - } - else - { - m_pRenderer->drawVerLine(align, x, y, b, penW); - } -} -void CGraphics::drawHorLineExt(BYTE align, double y, double x, double r, double penW, double leftMW, double rightMW) -{ - if (!m_pRenderer->get_IntegerGrid()) - { - Aggplus::CMatrix* pMatrix = m_pRenderer->GetTransformMatrix(); - if (pMatrix->IsIdentity2()) - { - m_pRenderer->put_IntegerGrid(true); - m_pRenderer->drawHorLineExt(align, y, x, r, penW, leftMW, rightMW); - m_pRenderer->put_IntegerGrid(false); - } - else - { - m_pRenderer->put_PenSize(penW); - m_pRenderer->PathCommandEnd(); - m_pRenderer->PathCommandMoveTo(x, y); - m_pRenderer->PathCommandLineTo(r, y); - m_pRenderer->Stroke(); - } - } - else - { - m_pRenderer->drawHorLineExt(align, y, x, r, penW, leftMW, rightMW); - } -} -void CGraphics::rect (double x, double y, double w, double h) -{ - m_pRenderer->PathCommandEnd(); - if (m_pRenderer->get_IntegerGrid()) - { - double r = x + w; - double b = y + h; - - m_pRenderer->GetFullTransform()->TransformPoint(x, y); - m_pRenderer->GetFullTransform()->TransformPoint(r, b); - - x = (int)(x + 0.5); - y = (int)(y + 0.5); - r = (int)(r + 0.5); - b = (int)(b + 0.5); - - m_pRenderer->AddRect(x, y, r - x, b - y); - } - else - { - m_pRenderer->AddRect(x, y, w, h); - } -} -void CGraphics::TableRect (double x, double y, double w, double h) -{ - m_pRenderer->PathCommandEnd(); - if (m_pRenderer->get_IntegerGrid()) - { - double r = x + w; - double b = y + h; - - m_pRenderer->GetFullTransform()->TransformPoint(x, y); - m_pRenderer->GetFullTransform()->TransformPoint(r, b); - - x = (int)x; - y = (int)y; - r = (int)r; - b = (int)b; - - m_pRenderer->AddRect(x, y, r - x + 1, b - y + 1); - } - else - { - m_pRenderer->AddRect(x, y, w, h); - } - m_pRenderer->Fill(); -} -void CGraphics::AddClipRect(double x, double y, double w, double h) -{ - CHist_Clip* _histClip = new CHist_Clip(); - - double sx, shy, shx, sy, tx, ty; - m_pRenderer->GetTransform(&sx, ­, &shx, &sy, &tx, &ty); - _histClip->Transform.SetElements(sx, shy, shx, sy, tx, ty); - - _histClip->IsIntegerGrid = m_pRenderer->get_IntegerGrid(); - _histClip->Rect.left = x; - _histClip->Rect.top = y; - _histClip->Rect.right = x + w; - _histClip->Rect.bottom = y + h; - - m_oGrState.Clips.push_back(_histClip); - - StartClipPath(); - - _s(); - _m(x, y); - _l(x + w, y); - _l(x + w, y + h); - _l(x, y + h); - _l(x, y); - - EndClipPath(); -} -void CGraphics::RemoveClipRect() -{ - if(m_oGrState.Clips.back()) - { - delete m_oGrState.Clips.back(); - m_oGrState.Clips.pop_back(); - } - restore(); -} -void CGraphics::SetClip (double x, double y, double w, double h) -{ - rect(x, y, w, h); - clip(); -} -void CGraphics::drawCollaborativeChanges(double x, double y, double w, double h, int r, int g, int b, int a) -{ - b_color1(r, g, b, a); - rect(x, y, w, h); - df(); - m_pRenderer->PathCommandEnd(); -} -void CGraphics::drawMailMergeField(double x, double y, double w, double h) -{ - b_color1(206, 212, 223, 204); - rect(x, y, w, h); - df(); - m_pRenderer->PathCommandEnd(); -} -void CGraphics::drawSearchResult (double x, double y, double w, double h) -{ - b_color1(255, 238, 128, 255); - rect(x, y, w, h); - df(); - m_pRenderer->PathCommandEnd(); -} -void CGraphics::SavePen() -{ - CGrStatePen* pState = new CGrStatePen(); - m_pRenderer->SavePen(pState->m_oPen); - m_oGrState.States.push_back(pState); -} -void CGraphics::RestorePen() -{ - if(m_oGrState.States.empty()) - return; - - IGrState* pState = m_oGrState.States.back(); - if(pState->m_eType == gstPen) - { - m_pRenderer->RestorePen(((CGrStatePen*)pState)->m_oPen); - m_oGrState.States.pop_back(); - RELEASEOBJECT(pState); - } -} -void CGraphics::SaveBrush() -{ - CGrStateBrush* pState = new CGrStateBrush(); - m_pRenderer->SaveBrush(pState->m_oBrush); - m_oGrState.States.push_back(pState); -} -void CGraphics::RestoreBrush() -{ - if (m_oGrState.States.empty()) - return; - - IGrState* pState = m_oGrState.States.back(); - if (pState->m_eType == gstBrush) - { - m_pRenderer->RestoreBrush(((CGrStateBrush*)pState)->m_oBrush); - m_oGrState.States.pop_back(); - RELEASEOBJECT(pState); - } -} -void CGraphics::SavePenBrush() -{ - CGrStatePenBrush* pState = new CGrStatePenBrush(); - m_pRenderer->SavePen(pState->m_oPen); - m_pRenderer->SaveBrush(pState->m_oBrush); - m_oGrState.States.push_back(pState); -} -void CGraphics::RestorePenBrush() -{ - if (m_oGrState.States.empty()) - return; - - IGrState* pState = m_oGrState.States.back(); - if (pState->m_eType == gstPenBrush) - { - m_pRenderer->RestorePen(((CGrStatePenBrush*)pState)->m_oPen); - m_pRenderer->RestoreBrush(((CGrStatePenBrush*)pState)->m_oBrush); - m_oGrState.States.pop_back(); - RELEASEOBJECT(pState); - } -} -void CGraphics::SaveGrState() -{ - #ifdef _DEBUG - std::cout << "SaveGrState " << std::endl; - #endif - CGrStateState* pState = new CGrStateState(); - pState->IsIntegerGrid = m_pRenderer->get_IntegerGrid(); - pState->Clips = m_oGrState.Clips; - - double sx, shy, shx, sy, tx, ty; - m_pRenderer->GetTransform(&sx, ­, &shx, &sy, &tx, &ty); - pState->Transform.SetElements(sx, shy, shx, sy, tx, ty); - - m_oGrState.Clips.clear(); - m_oGrState.States.push_back(pState); -} -void CGraphics::RestoreGrState() -{ - #ifdef _DEBUG - std::cout << "RestoreGrState " << std::endl; - #endif - if (m_oGrState.States.empty()) - return; - - IGrState* pState = m_oGrState.States.back(); - if (pState->m_eType != gstState) - return; - - CGrStateState* pGrState = (CGrStateState*)pState; - - if (!m_oGrState.Clips.empty()) - { - restore(); - - for (IGrState* i : m_oGrState.States) - { - if (i->m_eType == gstState) - { - std::vector& arr = ((CGrStateState*)i)->Clips; - - for (CHist_Clip* j : arr) - { - Aggplus::CMatrix& oMatrix = j->Transform; - transform(oMatrix.sx(), oMatrix.shy(), oMatrix.shx(), oMatrix.sy(), oMatrix.tx(), oMatrix.ty()); - SetIntegerGrid(j->IsIntegerGrid); - - StartClipPath(); - - double x = j->Rect.left; - double y = j->Rect.top; - double r = j->Rect.right; - double b = j->Rect.bottom; - - _s(); - _m(x, y); - _l(r, y); - _l(r, b); - _l(x, b); - _l(x, y); - - EndClipPath(); - } - } - } - } - - for (CHist_Clip* pClip : m_oGrState.Clips) - RELEASEOBJECT(pClip); - m_oGrState.Clips.clear(); - - m_oGrState.Clips = pGrState->Clips; - pGrState->Clips.clear(); - m_oGrState.States.pop_back(); - - Aggplus::CMatrix& oMatrix = pGrState->Transform; - transform(oMatrix.sx(), oMatrix.shy(), oMatrix.shx(), oMatrix.sy(), oMatrix.tx(), oMatrix.ty()); - SetIntegerGrid(pGrState->IsIntegerGrid); - - RELEASEOBJECT(pState); -} -void CGraphics::StartClipPath() -{ - #ifdef _DEBUG - std::cout << "StartClipPath " << std::endl; - #endif - m_pRenderer->BeginCommand(c_nClipType); -} -void CGraphics::EndClipPath() -{ - #ifdef _DEBUG - std::cout << "EndClipPath " << std::endl; - #endif - m_pRenderer->EndCommand(c_nClipType); -} -bool CGraphics::StartCheckTableDraw() -{ - if(!m_pRenderer->get_IntegerGrid()) - { - Aggplus::CMatrix* pMatrix = m_pRenderer->GetTransformMatrix(); - if(pMatrix->IsIdentity2()) - { - SaveGrState(); - m_pRenderer->put_IntegerGrid(true); - return true; - } - } - return false; -} -void CGraphics::SetTextClipRect(double _l, double _t, double _r, double _b) -{ - AddClipRect(_l, _t, _r - _l, _b - _t); -} -void CGraphics::DrawFootnoteRect(double x, double y, double w, double h) -{ - BYTE nPenDashStyle = 0; - m_pRenderer->get_PenDashStyle(&nPenDashStyle); - - bool bIsIntegerGrid = m_pRenderer->get_IntegerGrid(); - if (!bIsIntegerGrid) - m_pRenderer->put_IntegerGrid(true); - - double dash[2] = { 2.0, 2.0 }; - m_pRenderer->put_PenDashStyle(Aggplus::DashStyleCustom); - m_pRenderer->PenDashPattern(dash, 2); - - m_pRenderer->PathCommandEnd(); - - double l = x; - double t = y; - double r = x + w; - double b = y + h; - - drawHorLineExt(1, t, l, r, 0, 0, 0); - drawVerLine (1, l, t, b, 0); - drawVerLine (1, r, t, b, 0); - drawHorLineExt(1, b, l, r, 0, 0, 0); - - m_pRenderer->PathCommandEnd(); - m_pRenderer->Stroke(); - - if (!bIsIntegerGrid) - m_pRenderer->put_IntegerGrid(false); - - m_pRenderer->put_PenDashStyle(nPenDashStyle); -} -std::string CGraphics::toDataURL(std::wstring type) -{ - std::wstring sPath = NSFile::CFileBinary::CreateTempFileWithUniqueName(m_sApplicationImagesDirectory, L"img"); - #ifdef _DEBUG - std::wcout << "toDataURL " << sPath << std::endl; - #endif - m_oFrame.SaveFile(sPath, _CXIMAGE_FORMAT_PNG); - - NSFile::CFileBinary oReader; - if (oReader.OpenFile(sPath)) - { - DWORD dwFileSize = oReader.GetFileSize(); - BYTE* pFileContent = new BYTE[dwFileSize]; - DWORD dwReaded; - oReader.ReadFile(pFileContent, dwFileSize, dwReaded); - oReader.CloseFile(); - - NSFile::CFileBinary::Remove(sPath); - int nEncodeLen = NSBase64::Base64EncodeGetRequiredLength(dwFileSize); - BYTE* pImageData = new BYTE[nEncodeLen]; - if (TRUE == NSBase64::Base64Encode(pFileContent, dwFileSize, pImageData, &nEncodeLen)) - return "data:" + U_TO_UTF8(type) + ";base64, " + std::string((char*)pImageData, nEncodeLen); - } - return ""; -} -CColor CGraphics::GetPenColor() -{ - LONG color; - LONG a; - m_pRenderer->get_PenColor(&color); - m_pRenderer->get_PenAlpha(&a); - return {(int)(color & 0xFF), (int)((color >> 8) & 0xFF), (int)((color >> 16) & 0xFF), (int)a}; -} -CColor CGraphics::GetBrushColor() -{ - LONG color; - LONG a; - m_pRenderer->get_BrushColor1(&color); - m_pRenderer->get_BrushAlpha1(&a); - return {(int)(color & 0xFF), (int)((color >> 8) & 0xFF), (int)((color >> 16) & 0xFF), (int)a}; -} -void CGraphics::put_brushTexture(std::wstring src, int type) -{ - if (src.find(L"data:") == 0) - { - std::wstring strImage = m_sApplicationImagesDirectory + L"/texture.png"; - bool bIsOnlyOfficeHatch = false; - if(src.find(L"onlyoffice_hatch") != std::wstring::npos) - bIsOnlyOfficeHatch = true; - #ifdef _DEBUG - std::wcout << L"put_brushTexture " << src << L" " << bIsOnlyOfficeHatch << std::endl; - #endif - src.erase(0, src.find(L',') + 1); - - std::string sBase64MultyByte(src.begin(), src.end()); - int nDecodeLen = NSBase64::Base64DecodeGetRequiredLength(sBase64MultyByte.length()); - if(nDecodeLen == 0) - return; - BYTE* pImageData = new BYTE[nDecodeLen + 64]; - if (TRUE == NSBase64::Base64Decode(sBase64MultyByte.c_str(), sBase64MultyByte.length(), pImageData, &nDecodeLen)) - { - if(!bIsOnlyOfficeHatch) - { - NSFile::CFileBinary oImageWriter; - if (oImageWriter.CreateFileW(strImage)) - { - oImageWriter.WriteFile(pImageData, (DWORD)nDecodeLen); - oImageWriter.CloseFile(); - } - } - else - { - int nSize = (int)sqrt(nDecodeLen >> 2); - CBgraFrame oFrame; - oFrame.put_Data(pImageData); - oFrame.put_Width(nSize); - oFrame.put_Height(nSize); - oFrame.put_Stride(4 * nSize); - oFrame.SaveFile(strImage, 4); - } - m_pRenderer->put_BrushType(c_BrushTypeTexture); - m_pRenderer->put_BrushTexturePath(strImage); - m_pRenderer->put_BrushTextureMode(type); - } - } - else - { - std::wstring strImage = (0 == src.find(L"theme") ? m_sApplicationThemesDirectory : m_sApplicationImagesDirectory) + L'/' + src; - #ifdef _DEBUG - std::wcout << L"put_brushTexture " << strImage << L" " << type << std::endl; - #endif - m_pRenderer->put_BrushType(c_BrushTypeTexture); - m_pRenderer->put_BrushTexturePath(strImage); - m_pRenderer->put_BrushTextureMode(type); - } -} -void CGraphics::put_brushTextureMode(int mode) -{ - #ifdef _DEBUG - std::cout << "put_brushTextureMode " << mode << std::endl; - #endif - m_pRenderer->put_BrushTextureMode(mode); -} -void CGraphics::put_BrushTextureAlpha(int a) -{ - #ifdef _DEBUG - std::cout << "put_BrushTextureAlpha " << a << std::endl; - #endif - m_pRenderer->put_BrushTextureAlpha(a == 0 ? 255 : a); -} -void CGraphics::put_BrushGradient(LONG* pColors, double* pPositions, size_t nCount, double x0, double y0, double x1, double y1, double r0, double r1) -{ - #ifdef _DEBUG - std::cout << "put_BrushGradient " << std::endl; - #endif - if(isnan(r0)) - { - double dX = x1 - x0, dY = y1 - y0; - double dHyp = sqrt(dX * dX + dY * dY); - double dAngle = acos(dX / dHyp) * 180 / M_PI; - m_pRenderer->put_BrushType(c_BrushTypePathGradient1); - m_pRenderer->put_BrushGradientColors(pColors, pPositions, nCount); - m_pRenderer->put_BrushLinearAngle(dAngle); - } - else - { - m_pRenderer->put_BrushType(c_BrushTypePathGradient2); - m_pRenderer->put_BrushGradientColors(pColors, pPositions, nCount); - } -} -double CGraphics::TransformPointX(double x, double y) -{ - #ifdef _DEBUG - std::cout << "TransformPointX " << std::endl; - #endif - m_pRenderer->GetFullTransform()->TransformPoint(x, y); - return x; -} -double CGraphics::TransformPointY(double x, double y) -{ - #ifdef _DEBUG - std::cout << "TransformPointY " << std::endl; - #endif - m_pRenderer->GetFullTransform()->TransformPoint(x, y); - return y; -} -void CGraphics::put_LineJoin(int nJoin) -{ - #ifdef _DEBUG - std::cout << "put_LineJoin " << std::endl; - #endif - m_pRenderer->put_PenLineJoin(nJoin); -} -int CGraphics::GetLineJoin() -{ - #ifdef _DEBUG - std::cout << "GetLineJoin " << std::endl; - #endif - BYTE nRes; - m_pRenderer->get_PenLineJoin(&nRes); - return nRes; -} -void CGraphics::put_TextureBounds(double x, double y, double w, double h) -{ - #ifdef _DEBUG - std::cout << "put_TextureBounds " << L" " << x << " " << y << L" " << w << L" " << h << std::endl; - #endif - if(m_pRenderer->get_IntegerGrid()) - { - double r = x + w; - double b = y + h; - m_pRenderer->GetFullTransform()->TransformPoint(x, y); - m_pRenderer->GetFullTransform()->TransformPoint(r, b); - m_pRenderer->BrushBounds(x, y, r - x, b - y); - } - else - m_pRenderer->BrushBounds(x, y, w, h); -} -double CGraphics::GetlineWidth() -{ - #ifdef _DEBUG - std::cout << "GetlineWidth " << std::endl; - #endif - double nRes; - m_pRenderer->get_PenSize(&nRes); - return nRes; -} -void CGraphics::DrawPath(int path) -{ - #ifdef _DEBUG - std::cout << "DrawPath " << path << std::endl; - #endif - if(path == 257) - { - m_pRenderer->DrawPath(256); - m_pRenderer->DrawPath(1); - } - else - m_pRenderer->DrawPath(path); -} -void CGraphics::CoordTransformOffset(double tx, double ty) -{ - #ifdef _DEBUG - std::cout << "CoordTransformOffset " << tx << " " << ty << std::endl; - #endif - m_pRenderer->SetCoordTransformOffset(tx, ty); -} -CTransform CGraphics::GetTransform() -{ - CTransform oRes; - m_pRenderer->GetTransform(&oRes.sx, &oRes.shy, &oRes.shx, &oRes.sy, &oRes.tx, &oRes.ty); - return oRes; -} -} diff --git a/DesktopEditor/doctrenderer/graphics.h b/DesktopEditor/doctrenderer/graphics.h deleted file mode 100644 index b8127fa61c..0000000000 --- a/DesktopEditor/doctrenderer/graphics.h +++ /dev/null @@ -1,238 +0,0 @@ -#ifndef CGRAPHICS_H -#define CGRAPHICS_H - -#include - -#include "../common/Types.h" -#include "../common/File.h" -#include "nativecontrol.h" -#include "../graphics/pro/Graphics.h" - -namespace NSGraphics -{ - enum EGrStateType - { - gstPen = 0, - gstBrush = 1, - gstPenBrush = 2, - gstState = 3, - gstNone = 4 - }; - - struct IGrState - { - public: - EGrStateType m_eType; - IGrState() { m_eType = gstNone; } - virtual ~IGrState() {} - }; - - struct CGrStatePen : public IGrState - { - NSStructures::CPen m_oPen; - CGrStatePen() { m_eType = gstPen; } - }; - - struct CGrStateBrush : public IGrState - { - NSStructures::CBrush m_oBrush; - CGrStateBrush() { m_eType = gstBrush; } - }; - - struct CGrStatePenBrush : public IGrState - { - NSStructures::CPen m_oPen; - NSStructures::CBrush m_oBrush; - - CGrStatePenBrush() { m_eType = gstPenBrush; } - }; - - struct CHist_Clip - { - Aggplus::CDoubleRect Rect; - bool IsIntegerGrid; - Aggplus::CMatrix Transform; - - CHist_Clip() : IsIntegerGrid(false) {} - }; - - struct CGrStateState : public IGrState - { - Aggplus::CMatrix Transform; - bool IsIntegerGrid; - std::vector Clips; - - CGrStateState() - { - m_eType = gstState; - IsIntegerGrid = false; - } - ~CGrStateState() - { - for(CHist_Clip* pClip : Clips) - RELEASEOBJECT(pClip); - Clips.clear(); - } - }; - - struct CGrState - { - std::vector States; - std::vector Clips; - - CGrState() {} - ~CGrState() - { - for(IGrState* pState : States) - RELEASEOBJECT(pState); - States.clear(); - - for(CHist_Clip* pState : Clips) - RELEASEOBJECT(pState); - Clips.clear(); - } - }; - - struct CColor - { - int r; - int g; - int b; - int a; - }; - - struct CTransform - { - double sx; - double shy; - double shx; - double sy; - double tx; - double ty; - }; - - class CGraphics - { - public: - std::wstring m_sApplicationFontsDirectory; - std::wstring m_sApplicationImagesDirectory; - std::wstring m_sApplicationThemesDirectory; - - private: - NSFonts ::IApplicationFonts* m_pApplicationFonts; - NSGraphics::IGraphicsRenderer* m_pRenderer; - CBgraFrame m_oFrame; - CGrState m_oGrState; - - public: - CGraphics() {} - ~CGraphics() - { - RELEASEINTERFACE(m_pRenderer); - RELEASEINTERFACE(m_pApplicationFonts); - } - - void init(NSNativeControl::CNativeControl* oNative, double width_px, double height_px, double width_mm, double height_mm); - void EndDraw() {} - void put_GlobalAlpha(bool enable, double globalAlpha); - void Start_GlobalAlpha() {} - void End_GlobalAlpha(); - // pen methods - void p_color(int r, int g, int b, int a); - void p_width(double w); - void p_dash(size_t length, double* dash); - // brush methods - void b_color1(int r, int g, int b, int a); - void b_color2(int r, int g, int b, int a); - void transform(double sx, double shy, double shx, double sy, double tx, double ty); - void CalculateFullTransform(); - // path commands - void _s(); - void _e(); - void _z(); - void _m (double x, double y); - void _l (double x, double y); - void _c (double x1, double y1, double x2, double y2, double x3, double y3); - void _c2(double x1, double y1, double x2, double y2); - void ds(); - void df(); - // canvas state - void save(); - void restore(); - void clip(); - void reset(); - void FreeFont(); - void ClearLastFont(); - // images - void drawImage(const std::wstring& img, double x, double y, double w, double h, BYTE alpha); - // text - std::wstring GetFont(); - void font() {} - void SetFont(const std::wstring& name, int face, double size, int style); - void GetTextPr() {} - void FillText(double x, double y, int text); - void t(double x, double y, const std::wstring& text); - void tg(int text, double x, double y); - void charspace() {} - // private methods - void private_FillGlyph() {} - void private_FillGlyphC() {} - void private_FillGlyph2() {} - void SetIntegerGrid(bool param); - bool GetIntegerGrid(); - void DrawStringASCII(const std::wstring& text, double x, double y); - void DrawHeaderEdit(double yPos); - void DrawFooterEdit(double yPos); - void DrawLockParagraph (double x, double y1, double y2); - void DrawLockObjectRect(double x, double y, double w, double h); - void DrawEmptyTableLine(double x1, double y1, double x2, double y2); - void DrawSpellingLine (double y0, double x0, double x1, double w); - // smart methods for horizontal / vertical lines - void drawHorLine (BYTE align, double y, double x, double r, double penW); - void drawHorLine2(BYTE align, double y, double x, double r, double penW); - void drawVerLine (BYTE align, double x, double y, double b, double penW); - // мега крутые функции для таблиц - void drawHorLineExt(BYTE align, double y, double x, double r, double penW, double leftMW, double rightMW); - void rect (double x, double y, double w, double h); - void TableRect(double x, double y, double w, double h); - // функции клиппирования - void AddClipRect(double x, double y, double w, double h); - void RemoveClipRect(); - void SetClip (double x, double y, double w, double h); - void drawCollaborativeChanges(double x, double y, double w, double h, int r, int g, int b, int a); - void drawMailMergeField (double x, double y, double w, double h); - void drawSearchResult (double x, double y, double w, double h); - void SavePen(); - void RestorePen(); - void SaveBrush(); - void RestoreBrush(); - void SavePenBrush(); - void RestorePenBrush(); - void SaveGrState(); - void RestoreGrState(); - void StartClipPath(); - void EndClipPath(); - bool StartCheckTableDraw(); - void SetTextClipRect(double _l, double _t, double _r, double _b); - void DrawFootnoteRect(double x, double y, double w, double h); - // new methods - std::string toDataURL(std::wstring type); - CColor GetPenColor(); - CColor GetBrushColor(); - void put_brushTexture(std::wstring src, int type); - void put_brushTextureMode(int mode); - void put_BrushTextureAlpha(int a); - void put_BrushGradient(LONG* pColors, double* pPositions, size_t nCount, double x0, double y0, double x1, double y1, double r0, double r1); - double TransformPointX(double x, double y); - double TransformPointY(double x, double y); - void put_LineJoin(int nJoin); - int GetLineJoin(); - void put_TextureBounds(double x, double y, double w, double h); - double GetlineWidth(); - void DrawPath(int path); - void CoordTransformOffset(double tx, double ty); - CTransform GetTransform(); - }; -} - -#endif // CGRAPHICS_H diff --git a/DesktopEditor/doctrenderer/js/NativeGraphics.js b/DesktopEditor/doctrenderer/js/NativeGraphics.js new file mode 100644 index 0000000000..25398e1ccf --- /dev/null +++ b/DesktopEditor/doctrenderer/js/NativeGraphics.js @@ -0,0 +1,521 @@ + +function CNativeGraphics() +{ + this.Native = CreateNativeGraphics(); + + this.m_oContext = null; + this.m_dWidthMM = 0; + this.m_dHeightMM = 0; + this.m_lWidthPix = 0; + this.m_lHeightPix = 0; + this.m_dDpiX = 96.0; + this.m_dDpiY = 96.0; + this.m_bIsBreak = false; + + //this.m_oPen = new AscCommon.CPen(); + this.m_bPenColorInit = false; + //this.m_oBrush = new AscCommon.CBrush(); + this.m_bBrushColorInit = false; + + this.m_oFontManager = null; + + //this.m_oCoordTransform = new AscCommon.CMatrixL(); + //this.m_oBaseTransform = new AscCommon.CMatrixL(); + //this.m_oTransform = new AscCommon.CMatrixL(); + //this.m_oFullTransform = new AscCommon.CMatrixL(); + //this.m_oInvertFullTransform = new AscCommon.CMatrixL(); + + this.ArrayPoints = null; + + this.m_oCurFont = + { + Name : "", + FontSize : 10, + Bold : false, + Italic : false + }; + + // RFonts + this.m_oTextPr = null; + //this.m_oGrFonts = new AscCommon.CGrRFonts(); + //this.m_oLastFont = new AscCommon.CFontSetup(); + + this.LastFontOriginInfo = { Name : "", Replace : null }; + + this.m_bIntegerGrid = true; + + //this.ClipManager = new AscCommon.CClipManager(); + //this.ClipManager.BaseObject = this; + + this.TextureFillTransformScaleX = 1; + this.TextureFillTransformScaleY = 1; + this.IsThumbnail = false; + + this.IsDemonstrationMode = false; + + //this.GrState = new AscCommon.CGrState(); + //this.GrState.Parent = this; + + this.TextClipRect = null; + this.IsClipContext = false; + + this.IsUseFonts2 = false; + this.m_oFontManager2 = null; + this.m_oLastFont2 = null; + + this.ClearMode = false; + this.IsRetina = false; + + this.dash_no_smart = null; + + this.RENDERER_PDF_FLAG = true; +} + +CNativeGraphics.prototype = +{ + init : function(context, width_px, height_px, width_mm, height_mm) + { + this.Native["init"](width_px, height_px, width_mm, height_mm); + }, + EndDraw : function() + { + // this.Native["EndDraw"](); + }, + put_GlobalAlpha : function(enable, alpha) + { + this.Native["put_GlobalAlpha"](enable, alpha); + }, + Start_GlobalAlpha : function() + { + // this.Native["Start_GlobalAlpha"](); + }, + End_GlobalAlpha : function() + { + this.Native["End_GlobalAlpha"](); + }, + // pen methods + p_color : function(r, g, b, a) + { + this.Native["p_color"](r, g, b, a); + }, + p_width : function(w) + { + this.Native["p_width"](w); + }, + p_dash : function(params) + { + this.Native["p_dash"](params ? params : []); + }, + // brush methods + b_color1 : function(r, g, b, a) + { + this.Native["b_color1"](r, g, b, a); + }, + b_color2 : function(r, g, b, a) + { + this.Native["b_color2"](r, g, b, a); + }, + transform : function(sx, shy, shx, sy, tx, ty) + { + this.Native["transform"](sx, shy, shx, sy, tx, ty); + }, + CalculateFullTransform : function(isInvertNeed) + { + this.Native["CalculateFullTransform"](isInvertNeed); + }, + // path commands + _s : function() + { + this.Native["_s"](); + }, + _e : function() + { + this.Native["_e"](); + }, + _z : function() + { + this.Native["_z"](); + }, + _m : function(x, y) + { + this.Native["_m"](x, y); + }, + _l : function(x, y) + { + this.Native["_l"](x, y); + }, + _c : function(x1, y1, x2, y2, x3, y3) + { + this.Native["_c"](x1, y1, x2, y2, x3, y3); + }, + _c2 : function(x1, y1, x2, y2) + { + this.Native["_c2"](x1, y1, x2, y2); + }, + ds : function() + { + this.Native["ds"](); + }, + df : function() + { + this.Native["df"](); + }, + // canvas state + save : function() + { + this.Native["save"](); + }, + restore : function() + { + this.Native["restore"](); + }, + clip : function() + { + this.Native["clip"](); + }, + reset : function() + { + this.Native["reset"](); + }, + transform3 : function(m, isNeedInvert) + { + this.Native["transform3"](m.sx, m.shy, m.shx, m.sy, m.tx, m.ty, isNeedInvert); + }, + FreeFont : function() + { + // this.Native["FreeFont"](); + }, + ClearLastFont : function() + { + // this.Native["ClearLastFont"](); + }, + // images + drawImage2 : function(img, x, y, w, h, alpha, srcRect) + { + this.Native["drawImage2"](img, x, y, w, h, alpha, srcRect); + }, + drawImage : function(img, x, y, w, h, alpha, srcRect, nativeImage) + { + this.Native["drawImage"](img, x, y, w, h, alpha, srcRect, nativeImage); + }, + // text + GetFont : function() + { + return this.Native["GetFont"](); + }, + font : function(font_id, font_size) + { + this.Native["font"](font_id, font_size); + }, + SetFont : function(font) + { + if (null == font) + return; + + var flag = 0; + if (font.Bold) flag |= 0x01; + if (font.Italic) flag |= 0x02; + if (font.Bold) flag |= 0x04; + if (font.Italic) flag |= 0x08; + + this.Native["SetFont"](font.FontFamily.Name, font.FontFamily.Index, font.FontSize, flag); + }, + SetTextPr : function(textPr, theme) + { + // this.Native["SetTextPr"](textPr, theme); + }, + SetFontSlot : function(slot, fontSizeKoef) + { + // this.Native["SetFontSlot"](slot, fontSizeKoef); + }, + GetTextPr : function() + { + // return this.Native["GetTextPr"](); + }, + FillText : function(x, y, text) + { + var _code = text.charCodeAt(0); + this.Native["FillText"](x, y, _code); + }, + t : function(text, x, y, isBounds) + { + this.Native["t"](x, y, text); + }, + FillText2 : function(x, y, text, cropX, cropW) + { + var _code = text.charCodeAt(0); + this.Native["FillText2"](x, y, _code, cropX, cropW); + }, + t2 : function(text, x, y, cropX, cropW) + { + this.Native["t2"](x, y, text, cropX, cropW); + }, + FillTextCode : function(x, y, lUnicode) + { + var _code = lUnicode.charCodeAt(0); + this.Native["FillTextCode"](x, y, _code); + }, + tg : function(text, x, y) + { + var _code = text.charCodeAt(0); + this.Native["tg"](_code, x, y); + }, + charspace : function(space) + { + // this.Native["charspace"](space); + }, + // private methods + private_FillGlyph : function(pGlyph, _bounds) + { + // this.Native["private_FillGlyph"](pGlyph, _bounds); + }, + private_FillGlyphC : function(pGlyph, cropX, cropW) + { + // this.Native["private_FillGlyphC"](pGlyph, cropX, cropW); + }, + private_FillGlyph2 : function(pGlyph) + { + // this.Native["private_FillGlyph2"](pGlyph); + }, + SetIntegerGrid : function(param) + { + this.Native["SetIntegerGrid"](param); + }, + GetIntegerGrid : function() + { + return this.Native["GetIntegerGrid"](); + }, + DrawStringASCII : function(name, size, bold, italic, text, x, y, bIsHeader) + { + this.SetFont({FontFamily : {Name : name, Index : -1}, FontSize : size, Italic : italic, Bold : bold}); + this.Native["DrawStringASCII"](text, x, y); + }, + DrawStringASCII2 : function(name, size, bold, italic, text, x, y, bIsHeader) + { + this.SetFont({FontFamily : {Name : name, Index : -1}, FontSize : size, Italic : italic, Bold : bold}); + this.Native["DrawStringASCII2"](text, x, y); + }, + DrawHeaderEdit : function(yPos, lock_type, sectionNum, bIsRepeat, type) + { + this.Native["DrawHeaderEdit"](yPos, lock_type, sectionNum, bIsRepeat, type); + }, + DrawFooterEdit : function(yPos, lock_type, sectionNum, bIsRepeat, type) + { + this.Native["DrawFooterEdit"](yPos, lock_type, sectionNum, bIsRepeat, type); + }, + DrawLockParagraph : function(lock_type, x, y1, y2) + { + this.Native["DrawLockParagraph"](x, y1, y2); + }, + DrawLockObjectRect : function(lock_type, x, y, w, h) + { + this.Native["DrawLockObjectRect"](x, y, w, h); + }, + DrawEmptyTableLine : function(x1, y1, x2, y2) + { + this.Native["DrawEmptyTableLine"](x1, y1, x2, y2); + }, + DrawSpellingLine : function(y0, x0, x1, w) + { + this.Native["DrawSpellingLine"](y0, x0, x1, w); + }, + // smart methods for horizontal / vertical lines + drawHorLine : function(align, y, x, r, penW) + { + this.Native["drawHorLine"](align, y, x, r, penW); + }, + drawHorLine2 : function(align, y, x, r, penW) + { + this.Native["drawHorLine2"](align, y, x, r, penW); + }, + drawVerLine : function(align, x, y, b, penW) + { + this.Native["drawVerLine"](align, x, y, b, penW); + }, + // мега крутые функции для таблиц + drawHorLineExt : function(align, y, x, r, penW, leftMW, rightMW) + { + this.Native["drawHorLineExt"](align, y, x, r, penW, leftMW, rightMW); + }, + rect : function(x, y, w, h) + { + this.Native["rect"](x, y, w, h); + }, + TableRect : function(x, y, w, h) + { + this.Native["TableRect"](x, y, w, h); + }, + // функции клиппирования + AddClipRect : function(x, y, w, h) + { + this.Native["AddClipRect"](x, y, w, h); + }, + RemoveClipRect : function() + { + this.Native["RemoveClipRect"](); + }, + SetClip : function(r) + { + this.Native["SetClip"](r.x, r.y, r.w, r.h); + }, + RemoveClip : function() + { + this.Native["RemoveClip"](); + }, + drawCollaborativeChanges : function(x, y, w, h, Color) + { + this.Native["drawCollaborativeChanges"](x, y, w, h, Color.r, Color.g, Color.b, 255); + }, + drawMailMergeField : function(x, y, w, h) + { + this.Native["drawMailMergeField"](x, y, w, h); + }, + drawSearchResult : function(x, y, w, h) + { + this.Native["drawSearchResult"](x, y, w, h); + }, + drawFlowAnchor : function(x, y) + { + this.Native["drawFlowAnchor"](x, y); + }, + SavePen : function() + { + this.Native["SavePen"](); + }, + RestorePen : function() + { + this.Native["RestorePen"](); + }, + SaveBrush : function() + { + this.Native["SaveBrush"](); + }, + RestoreBrush : function() + { + this.Native["RestoreBrush"](); + }, + SavePenBrush : function() + { + this.Native["SavePenBrush"](); + }, + RestorePenBrush : function() + { + this.Native["RestorePenBrush"](); + }, + SaveGrState : function() + { + this.Native["SaveGrState"](); + }, + RestoreGrState : function() + { + this.Native["RestoreGrState"](); + }, + StartClipPath : function() + { + this.Native["StartClipPath"](); + }, + EndClipPath : function() + { + this.Native["EndClipPath"](); + }, + StartCheckTableDraw : function() + { + return this.Native["StartCheckTableDraw"](); + }, + EndCheckTableDraw : function(bIsRestore) + { + if(bIsRestore) + this.RestoreGrState(); + }, + SetTextClipRect : function(_l, _t, _r, _b) + { + this.Native["SetTextClipRect"](_l, _t, _r, _b); + }, + AddSmartRect : function(x, y, w, h, pen_w) + { + this.Native["AddSmartRect"](x, y, w, h, pen_w); + }, + CheckUseFonts2 : function(_transform) + { + // this.Native["CheckUseFonts2"](_transform); + }, + UncheckUseFonts2 : function() + { + // this.Native["UncheckUseFonts2"](); + }, + Drawing_StartCheckBounds : function(x, y, w, h) + { + // this.Native["Drawing_StartCheckBounds"](x, y, w, h); + }, + Drawing_EndCheckBounds : function() + { + // this.Native["Drawing_EndCheckBounds"](); + }, + DrawPresentationComment : function(type, x, y, w, h) + { + // this.Native["DrawPresentationComment"](type, x, y, w, h); + }, + DrawPolygon : function(oPath, lineWidth, shift) + { + this.p_width(lineWidth); + this._s(); + + var Points = oPath.Points; + var nCount = Points.length; + // берем предпоследнюю точку, т.к. последняя совпадает с первой + var PrevX = Points[nCount - 2].X, PrevY = Points[nCount - 2].Y; + var _x = Points[nCount - 2].X, _y = Points[nCount - 2].Y; + var StartX, StartY; + + for (var nIndex = 0; nIndex < nCount; nIndex++) + { + if(PrevX > Points[nIndex].X) + { + _y = Points[nIndex].Y - shift; + } + else if(PrevX < Points[nIndex].X) + { + _y = Points[nIndex].Y + shift; + } + + if(PrevY < Points[nIndex].Y) + { + _x = Points[nIndex].X - shift; + } + else if(PrevY > Points[nIndex].Y) + { + _x = Points[nIndex].X + shift; + } + + PrevX = Points[nIndex].X; + PrevY = Points[nIndex].Y; + + if(nIndex > 0) + { + if (1 == nIndex) + { + StartX = _x; + StartY = _y; + this._m(_x, _y); + } + else + { + this._l(_x, _y); + } + } + } + + this._l(StartX, StartY); + this._z(); + this.ds(); + }, + DrawFootnoteRect : function(x, y, w, h) + { + this.Native["DrawFootnoteRect"](x, y, w, h); + }, + // new methods + toDataURL : function(type) + { + return this.Native["toDataURL"](type); + } +}; diff --git a/DesktopEditor/doctrenderer/js/test.js b/DesktopEditor/doctrenderer/js/test.js new file mode 100644 index 0000000000..c337dcf009 --- /dev/null +++ b/DesktopEditor/doctrenderer/js/test.js @@ -0,0 +1,108 @@ + +var MyGraphics = new CNativeGraphics(); + +// Задаём размеры холста и всё будет полупрозрачное +MyGraphics.init(null, 1000, 1000, 1000 * 25.4 / 96, 1000 * 25.4 / 96); +MyGraphics.put_GlobalAlpha(true, 0.5); + +// Рисуем желтый квадрат с красной пунктирной обводкой и толщиной 2 +MyGraphics.p_color(255, 0, 0, 255); +MyGraphics.p_width(2); +MyGraphics.p_dash([5, 5]); +MyGraphics.b_color1(255, 255, 0, 255); +MyGraphics._s(); +MyGraphics._m(10, 10); +MyGraphics._l(100, 10); +MyGraphics._l(100, 100); +MyGraphics._l(10, 100); +MyGraphics._z(); +MyGraphics.df(); +MyGraphics.ds(); + +// Поварачиваем плоскость рисования +MyGraphics.transform(1, 0.5, 0.1, 1, 0, 0); + +// Рисуем розовый квадрат с бардовой сплошной обводкой и толщиной 1 +MyGraphics.p_color(111, 0, 53, 255); +MyGraphics.p_width(1); +MyGraphics.p_dash(); +MyGraphics.b_color1(222, 155, 176, 255); +MyGraphics.rect(75, 50, 100, 100) +MyGraphics.df(); +MyGraphics.ds(); + +// Восстанавливаем плоскость рисования до нормальной и убираем полупрозрачность +MyGraphics.reset(); +MyGraphics.put_GlobalAlpha(true, 1); + +MyGraphics.SetFont({FontFamily : {Name : "Arial", Index : -1}, FontSize : 16, Italic : true, Bold : true}); +MyGraphics.FillText(10, 110, "A"); +MyGraphics.tg("A", 10, 130); +MyGraphics.t("ABCDEFGHIJKLMNOPQRSTUVWXYZ", 10, 230, false); + +// Рисуем кривую с одной контрольной точкой +MyGraphics.b_color1(66, 255, 158, 255); +MyGraphics._s(); +MyGraphics._m(10, 10); +MyGraphics._c2(100, 50, 10, 100); +MyGraphics._z(); +MyGraphics.df(); +MyGraphics.ds(); + +// Отсекаем область рисования последним контруром и снова полупрозрачность +MyGraphics.clip(); +MyGraphics.put_GlobalAlpha(true, 0.5); + +// Рисуем кривую с двумя контрольными точками +MyGraphics.b_color1(121, 160, 255, 255); +MyGraphics._s(); +MyGraphics._m(100, 10); +MyGraphics._c(10, 10, 10, 100, 100, 100); +MyGraphics._z(); +MyGraphics.df(); +MyGraphics.ds(); + +// Восстанавливаем область рисования и поворачиваем плоскость рисования +MyGraphics.restore(); +MyGraphics.transform3({ sx : 1, shy : 0.5, shx : 0.1, sy : 1, tx : 0, ty : 0 }, false); + +// Рисуем изображение из файла +MyGraphics.drawImage2("image1.png", 95, 76, 60, 48, 0, null); + +MyGraphics.reset(); +MyGraphics.DrawStringASCII("Times New Roman", 16, false, false, "Test TEXT TEXT TEXT TEXT", 10, 210, false); +MyGraphics.DrawHeaderEdit(10); +MyGraphics.DrawFooterEdit(250); +MyGraphics.DrawLockParagraph(null, 10, 110, 200); +MyGraphics.DrawLockObjectRect(null, 20, 110, 90, 90); +MyGraphics.DrawEmptyTableLine(10, 110, 110, 210); +MyGraphics.DrawSpellingLine(120, 10, 100, 5); +MyGraphics.drawHorLine(1, 130, 10, 110, 10); +MyGraphics.drawVerLine(1, 30, 110, 200, 10); +MyGraphics.drawHorLineExt(1, 170, 20, 110, 5, 20, 0); + +MyGraphics.p_color(111, 0, 53, 255); +MyGraphics.p_width(3); +MyGraphics.b_color1(222, 155, 176, 255); +MyGraphics._s(); +MyGraphics.TableRect(110, 10, 90, 90); +MyGraphics._z(); + +// Рисует замыкание со второй до предпоследней точки +MyGraphics.DrawPolygon({Points : [{X : 10, Y : 10}, {X : 20, Y : 20}, {X : 20, Y : 30}, {X : 10, Y : 40}, {X : 0, Y : 30}]}, 3, 0); + +MyGraphics.DrawFootnoteRect(30, 30, 90, 90); + +MyGraphics.b_color1(255, 0, 0, 255); +MyGraphics._s(); +MyGraphics.AddClipRect(210, 10, 50, 50); +MyGraphics.ds(); +MyGraphics._z(); +MyGraphics.RemoveClipRect(); + +MyGraphics.SetClip({ x : 210, y : 70, w : 50, h : 50}); +MyGraphics.RemoveClip(); + +var imageBase64 = MyGraphics.toDataURL("png"); +MyGraphics.save(); +MyGraphics.GetFont(); diff --git a/DesktopEditor/doctrenderer/js_internal/jsc/jsc_base.h b/DesktopEditor/doctrenderer/js_internal/jsc/jsc_base.h index f8608b7e85..e1bb5641af 100644 --- a/DesktopEditor/doctrenderer/js_internal/jsc/jsc_base.h +++ b/DesktopEditor/doctrenderer/js_internal/jsc/jsc_base.h @@ -525,11 +525,6 @@ inline JSValue* js_return(JSSmart _value) { \ return js_return(m_internal->NAME_EMBED(js_value(p1), js_value(p2), js_value(p3), js_value(p4), js_value(p5), js_value(p6), js_value(p7))); \ } -#define FUNCTION_WRAPPER_JS_8(NAME, NAME_EMBED) \ - -(JSValue*) NAME:(JSValue*)p1 : (JSValue*)p2 : (JSValue*)p3 : (JSValue*)p4 : (JSValue*)p5 : (JSValue*)p6 : (JSValue*)p7 : (JSValue*)p8 \ - { \ - return js_return(m_internal->NAME_EMBED(js_value(p1), js_value(p2), js_value(p3), js_value(p4), js_value(p5), js_value(p6), js_value(p7), js_value(p8))); \ - } #if __has_feature(objc_arc) #define EMBED_OBJECT_WRAPPER_METHODS(CLASS) \ diff --git a/DesktopEditor/doctrenderer/js_internal/v8/v8_base.cpp b/DesktopEditor/doctrenderer/js_internal/v8/v8_base.cpp index 91703e0640..49c17b2adb 100644 --- a/DesktopEditor/doctrenderer/js_internal/v8/v8_base.cpp +++ b/DesktopEditor/doctrenderer/js_internal/v8/v8_base.cpp @@ -284,19 +284,15 @@ namespace NSJSBase CJSValueV8* _return = new CJSValueV8(); - v8::MaybeLocal retValue; if (exception.is_init()) { if (!exception->Check()) - retValue = _script->Run(V8ContextOneArg); + _return->value = _script->Run(V8ContextOneArg).ToLocalChecked(); } else { - retValue = _script->Run(V8ContextOneArg); + _return->value = _script->Run(V8ContextOneArg).ToLocalChecked(); } - - if (!retValue.IsEmpty()) - _return->value = retValue.ToLocalChecked(); return _return; } diff --git a/DesktopEditor/doctrenderer/js_internal/v8/v8_base.h b/DesktopEditor/doctrenderer/js_internal/v8/v8_base.h index 7073f1cb8e..ce0c8af9c2 100644 --- a/DesktopEditor/doctrenderer/js_internal/v8/v8_base.h +++ b/DesktopEditor/doctrenderer/js_internal/v8/v8_base.h @@ -420,9 +420,7 @@ namespace NSJSBase CJSValueV8* _value_arg = static_cast(argv[i].operator ->()); args[i] = _value_arg->value; } - v8::MaybeLocal retValue = _funcN->Call(V8ContextFirstArg value, argc, args); - if (!retValue.IsEmpty()) - _return->value = retValue.ToLocalChecked(); + _return->value = _funcN->Call(V8ContextFirstArg value, argc, args).ToLocalChecked(); RELEASEARRAYOBJECTS(args); } } diff --git a/DesktopEditor/fontengine/ApplicationFonts.cpp b/DesktopEditor/fontengine/ApplicationFonts.cpp index d07048a513..3b74db1df8 100644 --- a/DesktopEditor/fontengine/ApplicationFonts.cpp +++ b/DesktopEditor/fontengine/ApplicationFonts.cpp @@ -1337,8 +1337,6 @@ void CFontList::LoadFromArrayFiles(std::vector& oArray, int nFlag) std::wstring wsFamilyName = GetCorrectSfntName(pFace->family_name); std::wstring wsStyleName = GetCorrectSfntName(pFace->style_name); - bool isBadASCII = (std::wstring::npos != wsFamilyName.find('?')) ? true : false; - #ifdef _MAC if (wsFamilyName.find(L".") == 0) { @@ -1454,13 +1452,7 @@ void CFontList::LoadFromArrayFiles(std::vector& oArray, int nFlag) break; } - if (isBadASCII && pFontInfo->names.empty()) - { - wsFamilyName = sNameW; - pFontInfo->m_wsFontName = wsFamilyName; - isBadASCII = false; - } - else if (iter == pFontInfo->names.end()) + if (iter == pFontInfo->names.end()) { pFontInfo->names.push_back(sNameW); @@ -1782,7 +1774,6 @@ std::vector CApplicationFonts::GetSetupFontFiles() NSDirectory::GetFiles2(L"/usr/share/X11/fonts", _array, true); NSDirectory::GetFiles2(L"/usr/X11R6/lib/X11/fonts", _array, true); NSDirectory::GetFiles2(L"/usr/local/share/fonts", _array, true); - NSDirectory::GetFiles2(L"/run/host/fonts", _array, true); return _array; #endif diff --git a/DesktopEditor/fontengine/application_generate_fonts_common.h b/DesktopEditor/fontengine/application_generate_fonts_common.h index 06e3a864fa..bef5c57f5d 100644 --- a/DesktopEditor/fontengine/application_generate_fonts_common.h +++ b/DesktopEditor/fontengine/application_generate_fonts_common.h @@ -145,11 +145,7 @@ namespace NSCommon } static std::wstring GetFileName(const std::wstring& sPath) { -#ifdef _WIN32 std::wstring::size_type nPos1 = sPath.rfind('\\'); -#else - std::wstring::size_type nPos1 = std::wstring::npos; -#endif std::wstring::size_type nPos2 = sPath.rfind('/'); std::wstring::size_type nPos = std::wstring::npos; @@ -168,11 +164,7 @@ namespace NSCommon } static std::wstring GetDirectoryName(const std::wstring& sPath) { -#ifdef _WIN32 std::wstring::size_type nPos1 = sPath.rfind('\\'); -#else - std::wstring::size_type nPos1 = std::wstring::npos; -#endif std::wstring::size_type nPos2 = sPath.rfind('/'); std::wstring::size_type nPos = std::wstring::npos; diff --git a/DesktopEditor/hunspell-1.3.3/src/qt/wasm/make.py b/DesktopEditor/hunspell-1.3.3/src/qt/wasm/make.py index fa9bc6a3e8..6a68e0b641 100644 --- a/DesktopEditor/hunspell-1.3.3/src/qt/wasm/make.py +++ b/DesktopEditor/hunspell-1.3.3/src/qt/wasm/make.py @@ -14,12 +14,11 @@ base.create_dir("./deploy") base.create_dir("./deploy/spell") # fetch emsdk -command_prefix = "" if ("windows" == base.host_platform()) else "./" if not base.is_dir("emsdk"): base.cmd("git", ["clone", "https://github.com/emscripten-core/emsdk.git"]) os.chdir("emsdk") - base.cmd(command_prefix + "emsdk", ["install", "latest"]) - base.cmd(command_prefix + "emsdk", ["activate", "latest"]) + base.cmd("emsdk", ["install", "latest"]) + base.cmd("emsdk", ["activate", "latest"]) os.chdir("../") # compile @@ -90,13 +89,8 @@ for item in sources: # command windows_bat = [] -if (base.host_platform() == "windows"): - windows_bat.append("call emsdk/emsdk_env.bat") - windows_bat.append("call emcc " + arguments) -else: - windows_bat.append("#!/bin/bash") - windows_bat.append("source ./emsdk/emsdk_env.sh") - windows_bat.append("emcc " + arguments) +windows_bat.append("call emsdk/emsdk_env.bat") +windows_bat.append("call emcc " + arguments) base.run_as_bat(windows_bat) # finalize @@ -116,13 +110,8 @@ arguments = arguments.replace("WASM=1", "WASM=0") # command windows_bat = [] -if (base.host_platform() == "windows"): - windows_bat.append("call emsdk/emsdk_env.bat") - windows_bat.append("call emcc " + arguments) -else: - windows_bat.append("#!/bin/bash") - windows_bat.append("source ./emsdk/emsdk_env.sh") - windows_bat.append("emcc " + arguments) +windows_bat.append("call emsdk/emsdk_env.bat") +windows_bat.append("call emcc " + arguments) base.run_as_bat(windows_bat) # finalize diff --git a/DesktopEditor/raster/BgraFrame.cpp b/DesktopEditor/raster/BgraFrame.cpp index f7562bb0c8..9fa3ba263e 100644 --- a/DesktopEditor/raster/BgraFrame.cpp +++ b/DesktopEditor/raster/BgraFrame.cpp @@ -343,7 +343,6 @@ void CBgraFrame::Clear() m_lPaletteColors = 0; m_bIsGrayScale = false; m_dJpegSaveQuality = -1; - m_bIsRGBA = false; } void CBgraFrame::ClearNoAttack() @@ -393,15 +392,6 @@ void CBgraFrame::SetJpegQuality(const double& value) m_dJpegSaveQuality = value; } -void CBgraFrame::put_IsRGBA(const bool& bIsRGBA) -{ - m_bIsRGBA = bIsRGBA; -} -bool CBgraFrame::get_IsRGBA() -{ - return m_bIsRGBA; -} - void CBgraFrame::put_Palette(BYTE* pDataColors, const int& colors) { if (!pDataColors || colors < 1) return; @@ -459,7 +449,7 @@ bool CBgraFrame::SaveFile(const std::wstring& strFileName, unsigned int nFileTyp if (21/*CXIMAGE_FORMAT_JBIG2*/ == nFileType) { CJBig2File jBig2File; - bool res = jBig2File.MemoryToJBig2(m_pData, m_lWidth * m_lHeight * 24, m_lWidth, m_lHeight, strFileName, !m_bIsRGBA); + bool res = jBig2File.MemoryToJBig2(m_pData, m_lWidth * m_lHeight * 24, m_lWidth, m_lHeight, strFileName); return res; } @@ -471,7 +461,7 @@ bool CBgraFrame::SaveFile(const std::wstring& strFileName, unsigned int nFileTyp CxImage img; - if (!img.CreateFromArray(m_pData, m_lWidth, m_lHeight, lBitsPerPixel * 8, lStride, (m_lStride >= 0) ? true : false, !m_bIsRGBA)) + if (!img.CreateFromArray(m_pData, m_lWidth, m_lHeight, lBitsPerPixel * 8, lStride, (m_lStride >= 0) ? true : false)) return false; if (m_pPalette) diff --git a/DesktopEditor/raster/BgraFrame.h b/DesktopEditor/raster/BgraFrame.h index 4fd151ade7..50ac67d267 100644 --- a/DesktopEditor/raster/BgraFrame.h +++ b/DesktopEditor/raster/BgraFrame.h @@ -55,8 +55,6 @@ private: bool m_bIsGrayScale; double m_dJpegSaveQuality; - bool m_bIsRGBA; - public: CBgraFrame(); ~CBgraFrame(); @@ -82,13 +80,10 @@ public: bool IsGrayScale(); - void put_IsRGBA(const bool& bIsRGBA); - bool get_IsRGBA(); - void SetJpegQuality(const double& value); bool OpenFile(const std::wstring& strFileName, unsigned int nFileType = 0); //0 - detect - bool SaveFile(const std::wstring& strFileName, unsigned int nFileType); + bool SaveFile(const std::wstring& strFileName, unsigned int nFileType); bool Encode(BYTE*& pBuffer, int& nSize, unsigned int nFileType); bool Resize(const long& nNewWidth, const long& nNewHeight, bool bDestroyData = true); diff --git a/DesktopEditor/raster/JBig2/source/JBig2File.cpp b/DesktopEditor/raster/JBig2/source/JBig2File.cpp index 789c116271..66ba943379 100644 --- a/DesktopEditor/raster/JBig2/source/JBig2File.cpp +++ b/DesktopEditor/raster/JBig2/source/JBig2File.cpp @@ -25,7 +25,7 @@ CJBig2File::CJBig2File() m_nBwTreshold = 188; } -bool CJBig2File::MemoryToJBig2(unsigned char* pBufferBGRA ,int BufferSize, int nWidth, int nHeight, std::wstring sDstFileName, bool isBGRA) +bool CJBig2File::MemoryToJBig2(unsigned char* pBufferBGRA ,int BufferSize, int nWidth, int nHeight, std::wstring sDstFileName) { // check for valid input parameters @@ -38,14 +38,11 @@ bool CJBig2File::MemoryToJBig2(unsigned char* pBufferBGRA ,int BufferSize, int n PIX *pSource = pixCreate( nWidth, nHeight, 32 ); if ( !pSource ) return false; - unsigned char ShiftR = isBGRA ? 2 : 0; - unsigned char ShiftG = 1; - unsigned char ShiftB = isBGRA ? 0 : 2; for ( int nY = 0; nY < nHeight; nY++ ) { for ( int nX = 0; nX < nWidth; nX++, pSourceBuffer += 3 )//todooo сделать 3 ? 4 { - pixSetRGBPixel( pSource, nX, nY, pSourceBuffer[ ShiftR ], pSourceBuffer[ ShiftG ], pSourceBuffer[ ShiftB ] ); + pixSetRGBPixel( pSource, nX, nY, pSourceBuffer[ 2 ], pSourceBuffer[ 1 ], pSourceBuffer[ 0 ] ); } } diff --git a/DesktopEditor/raster/JBig2/source/JBig2File.h b/DesktopEditor/raster/JBig2/source/JBig2File.h index 7a6fddef5c..5a36742710 100644 --- a/DesktopEditor/raster/JBig2/source/JBig2File.h +++ b/DesktopEditor/raster/JBig2/source/JBig2File.h @@ -8,7 +8,7 @@ class CJBig2File public: CJBig2File(); - bool MemoryToJBig2(unsigned char* pBufferBGRA ,int BufferSize, int nWidth, int nHeight, std::wstring sDstFileName, bool isBGRA = true); + bool MemoryToJBig2(unsigned char* pBufferBGRA ,int BufferSize, int nWidth, int nHeight, std::wstring sDstFileName); bool m_bDuplicateLineRemoval; bool m_bPDFMode; @@ -22,4 +22,4 @@ public: std::wstring m_sBaseName; std::string m_sOutputTreshold; -}; +}; \ No newline at end of file diff --git a/DesktopEditor/raster/Metafile/Wmf/WmfFile.h b/DesktopEditor/raster/Metafile/Wmf/WmfFile.h index 953074ce65..b848e53fe4 100644 --- a/DesktopEditor/raster/Metafile/Wmf/WmfFile.h +++ b/DesktopEditor/raster/Metafile/Wmf/WmfFile.h @@ -1568,7 +1568,7 @@ namespace MetaFile { short shX, shY; m_oStream >> shY >> shX; - m_pDC->SetWindowExt(shX, shY); + m_pDC->SetWindowExt(fabs(shX), fabs(shY)); UpdateOutputDC(); } void Read_META_SETWINDOWORG() diff --git a/DesktopEditor/xmlsec/src/include/XmlCertificate.h b/DesktopEditor/xmlsec/src/include/XmlCertificate.h index 8115de1a75..1213d92adf 100644 --- a/DesktopEditor/xmlsec/src/include/XmlCertificate.h +++ b/DesktopEditor/xmlsec/src/include/XmlCertificate.h @@ -121,7 +121,6 @@ public: public: virtual int ShowSelectDialog(void* parent = NULL) = 0; virtual int ShowCertificate(void* parent = NULL) = 0; - virtual std::string Print() = 0; static CCertificateInfo GetDefault(); static ICertificate* GetById(const std::string& id); diff --git a/DesktopEditor/xmlsec/src/src/OOXMLSigner.cpp b/DesktopEditor/xmlsec/src/src/OOXMLSigner.cpp index 7c8a0bad72..fd243027e7 100644 --- a/DesktopEditor/xmlsec/src/src/OOXMLSigner.cpp +++ b/DesktopEditor/xmlsec/src/src/OOXMLSigner.cpp @@ -159,89 +159,47 @@ public: return builder.GetData(); } - int GetCountSigns(const std::wstring& folder) + int GetCountSigns(const std::wstring& file) { - std::wstring sRelsFolder = folder + L"/_rels"; - - std::vector arFiles = NSDirectory::GetFiles(sRelsFolder, false); - std::map arSigFiles; - - for (std::vector::iterator iter = arFiles.begin(); iter != arFiles.end(); iter++) + if (!NSFile::CFileBinary::Exists(file)) { - XmlUtils::CXmlNode oNodeRels; - if (!oNodeRels.FromXmlFile(*iter)) - continue; - XmlUtils::CXmlNodes oNodesRels = oNodeRels.GetNodes(L"Relationship"); - int nCount = oNodesRels.GetCount(); - for (int nIndex = 0; nIndex < nCount; nIndex++) - { - XmlUtils::CXmlNode oNodeRel; - oNodesRels.GetAt(nIndex, oNodeRel); + std::wstring sRels = L"\ +\ +\ +"; - std::wstring sTarget = oNodeRel.GetAttribute(L"Target"); - if (!sTarget.empty() && arSigFiles.find(sTarget) == arSigFiles.end() && NSFile::CFileBinary::Exists(folder + L"/" + sTarget)) - arSigFiles.insert(std::pair(sTarget, true)); - } - NSFile::CFileBinary::Remove(*iter); + NSFile::CFileBinary::SaveToFile(file, sRels, false); + return 1; } - int nCountSigs = (int)arSigFiles.size(); - std::wstring sFile = sRelsFolder + L"/origin.sigs.rels"; + XmlUtils::CXmlNode oNode; + oNode.FromXmlFile(file); - NSStringUtils::CStringBuilder oBuilder; - oBuilder.WriteString(L""); + XmlUtils::CXmlNodes oNodes; + oNode.GetNodes(L"Relationship", oNodes); - for (int nIndex = 0; nIndex <= nCountSigs/*old + one new*/; nIndex++) - { - oBuilder.WriteString(L""); - } + int rId = oNodes.GetCount() + 1; - oBuilder.WriteString(L""); + std::string sXmlA; + NSFile::CFileBinary::ReadAllTextUtf8A(file, sXmlA); + + std::string::size_type pos = sXmlA.rfind(""); + if (pos == std::string::npos) + return 1; + + std::string sRet = sXmlA.substr(0, pos); + sRet += ("\ +"); + + NSFile::CFileBinary::Remove(file); - NSFile::CFileBinary::Remove(sFile); NSFile::CFileBinary oFile; - oFile.CreateFileW(sFile); - oFile.WriteStringUTF8(oBuilder.GetData()); + oFile.CreateFileW(file); + oFile.WriteFile((BYTE*)sRet.c_str(), (DWORD)sRet.length()); oFile.CloseFile(); - // теперь перебьем все имена файлов - - std::vector arSigs; - - std::vector arFilesXml = NSDirectory::GetFiles(folder, false); - for (std::vector::iterator iter = arFilesXml.begin(); iter != arFilesXml.end(); iter++) - { - std::wstring sXmlFileName = NSFile::GetFileName(*iter); - if (NSFile::GetFileExtention(sXmlFileName) != L"xml") - continue; - - std::map::iterator find = arSigFiles.find(sXmlFileName); - if (find == arSigFiles.end()) - { - // ненужная xml - NSFile::CFileBinary::Remove(*iter); - continue; - } - - arSigs.push_back(sXmlFileName); - } - - std::sort(arSigs.begin(), arSigs.end()); - for (std::vector::iterator iter = arSigs.begin(); iter != arSigs.end(); iter++) - { - NSFile::CFileBinary::Move(folder + L"/" + *iter, folder + L"/onlyoffice_" + *iter); - } - int nSigNumber = 1; - for (std::vector::iterator iter = arSigs.begin(); iter != arSigs.end(); iter++) - { - NSFile::CFileBinary::Move(folder + L"/onlyoffice_" + *iter, folder + L"/sig" + std::to_wstring(nSigNumber++) + L".xml"); - } - - return (int)arSigs.size(); + return rId; } void ParseContentTypes() @@ -300,8 +258,7 @@ public: // check needed file if (0 == sCheckFile.find(L"/_xmlsignatures") || 0 == sCheckFile.find(L"/docProps") || - 0 == sCheckFile.find(L"/[Content_Types].xml") || - 0 == sCheckFile.find(L"/[trash]")) + 0 == sCheckFile.find(L"/[Content_Types].xml")) continue; // check rels and add to needed array @@ -365,61 +322,74 @@ public: builder.WriteString(L""); } - void CorrectContentTypes(int nCountSignatures) + void CorrectContentTypes(int nCountSigsNeeds) { std::wstring file = m_sFolder + L"/[Content_Types].xml"; XmlUtils::CXmlNode oNode; oNode.FromXmlFile(file); - NSStringUtils::CStringBuilder oBuilder; - oBuilder.WriteString(L""); + XmlUtils::CXmlNodes nodesDefaults; + oNode.GetNodes(L"Default", nodesDefaults); - int nAttributesCount = oNode.GetAttributesCount(); - oBuilder.WriteNodeBegin(oNode.GetName(), nAttributesCount != 0); + XmlUtils::CXmlNodes nodesOverrides; + oNode.GetNodes(L"Override", nodesOverrides); - std::vector attrNames; - std::vector attrValues; - oNode.GetAllAttributes(attrNames, attrValues); + std::string sAddition = ""; - for (int nAttrIndex = 0; nAttrIndex < nAttributesCount; ++nAttrIndex) + bool bIsSigsExist = false; + int nCount = nodesDefaults.GetCount(); + for (int i = 0; i < nCount; ++i) { - oBuilder.WriteAttributeEncodeXml(attrNames[nAttrIndex], attrValues[nAttrIndex]); + XmlUtils::CXmlNode node; + nodesDefaults.GetAt(i, node); + + if ("sigs" == node.GetAttributeA("Extension") && + "application/vnd.openxmlformats-package.digital-signature-origin" == node.GetAttributeA("ContentType")) + { + bIsSigsExist = true; + break; + } } - oBuilder.WriteNodeEnd(oNode.GetName(), true, false); + if (!bIsSigsExist) + sAddition += ""; - XmlUtils::CXmlNodes oNodes = oNode.GetNodes(L"*"); - - int nCountNodes = oNodes.GetCount(); - for (int nIndex = 0; nIndex < nCountNodes; ++nIndex) + int nCountSigs = 0; + nCount = nodesOverrides.GetCount(); + for (int i = 0; i < nCount; ++i) { - XmlUtils::CXmlNode oCurrentRecord; - oNodes.GetAt(nIndex, oCurrentRecord); + XmlUtils::CXmlNode node; + nodesOverrides.GetAt(i, node); - if (L"Default" == oCurrentRecord.GetName() && oCurrentRecord.GetAttributeA("Extension") == "sigs") - continue; - if (L"Override" == oCurrentRecord.GetName() && oCurrentRecord.GetAttributeA("ContentType") == "application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml") - continue; - - oBuilder.WriteString(oCurrentRecord.GetXml()); + if ("application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml" == node.GetAttributeA("ContentType")) + { + ++nCountSigs; + } } - if (0 != nCountSignatures) - oBuilder.WriteString(L""); - - for (int nIndex = 0; nIndex < nCountSignatures; ++nIndex) + for (int i = nCountSigs; i < nCountSigsNeeds; ++i) { - oBuilder.WriteString(L""); + sAddition += ""; } - oBuilder.WriteNodeEnd(oNode.GetName()); + std::string sXmlA; + NSFile::CFileBinary::ReadAllTextUtf8A(file, sXmlA); + + std::string::size_type pos = sXmlA.rfind(""); + if (pos == std::string::npos) + return; + + std::string sRet = sXmlA.substr(0, pos); + sRet += sAddition; + sRet += ""; NSFile::CFileBinary::Remove(file); + NSFile::CFileBinary oFile; oFile.CreateFileW(file); - oFile.WriteStringUTF8(oBuilder.GetData()); + oFile.WriteFile((BYTE*)sRet.c_str(), (DWORD)sRet.length()); oFile.CloseFile(); } @@ -588,30 +558,20 @@ public: if (!NSDirectory::Exists(sDirectory)) NSDirectory::CreateDirectory(sDirectory); - // remove old .sig file - std::vector arFiles = NSDirectory::GetFiles(sDirectory, false); - for (std::vector::iterator i = arFiles.begin(); i != arFiles.end(); i++) - { - if (NSFile::GetFileExtention(*i) == L"sigs") - { - NSFile::CFileBinary::Remove(*i); - } - } - - std::wstring sOriginName = L"origin.sigs"; - if (!NSFile::CFileBinary::Exists(sDirectory + L"/" + sOriginName)) + if (!NSFile::CFileBinary::Exists(sDirectory + L"/origin.sigs")) { NSFile::CFileBinary oFile; - oFile.CreateFileW(sDirectory + L"/" + sOriginName); + oFile.CreateFileW(sDirectory + L"/origin.sigs"); oFile.CloseFile(); } if (!NSDirectory::Exists(sDirectory + L"/_rels")) NSDirectory::CreateDirectory(sDirectory + L"/_rels"); - int nSignNum = GetCountSigns(sDirectory); + int nSignNum = GetCountSigns(sDirectory + L"/_rels/origin.sigs.rels"); + + CorrectContentTypes(nSignNum); - CorrectContentTypes(nSignNum + 1); return nSignNum; } @@ -649,7 +609,7 @@ public: int nSignNum = AddSignatureReference(); - NSFile::CFileBinary::SaveToFile(m_sFolder + L"/_xmlsignatures/sig" + std::to_wstring(nSignNum + 1) + L".xml", builderResult.GetData(), false); + NSFile::CFileBinary::SaveToFile(m_sFolder + L"/_xmlsignatures/sig" + std::to_wstring(nSignNum) + L".xml", builderResult.GetData(), false); } }; diff --git a/DesktopEditor/xmlsec/src/src/OOXMLVerifier.cpp b/DesktopEditor/xmlsec/src/src/OOXMLVerifier.cpp index e009584389..fc8d76a7d8 100644 --- a/DesktopEditor/xmlsec/src/src/OOXMLVerifier.cpp +++ b/DesktopEditor/xmlsec/src/src/OOXMLVerifier.cpp @@ -568,19 +568,7 @@ public: { m_sFolder = sFolder; - // check .sig file - std::vector arFiles = NSDirectory::GetFiles(m_sFolder + L"/_xmlsignatures", false); - bool bIsFound = false; - for (std::vector::iterator i = arFiles.begin(); i != arFiles.end(); i++) - { - if (NSFile::GetFileExtention(*i) == L"sigs") - { - bIsFound = true; - break; - } - } - - if (!bIsFound) + if (!NSFile::CFileBinary::Exists(m_sFolder + L"/_xmlsignatures/origin.sigs")) return; XmlUtils::CXmlNode oContentTypes; diff --git a/DesktopEditor/xmlsec/src/src/XmlRels.h b/DesktopEditor/xmlsec/src/src/XmlRels.h index 0abec4835b..a1cd7ad098 100644 --- a/DesktopEditor/xmlsec/src/src/XmlRels.h +++ b/DesktopEditor/xmlsec/src/src/XmlRels.h @@ -25,7 +25,6 @@ public: rid = node.GetAttribute("Id"); type = node.GetAttribute("Type"); target = node.GetAttribute("Target"); - target_mode = node.GetAttribute("TargetMode"); CheckTargetMode(); } @@ -53,9 +52,6 @@ public: protected: void CheckTargetMode() { - if (!target_mode.empty()) - return; - if (0 == target.find(L"http") || 0 == target.find(L"www") || 0 == target.find(L"ftp")) target_mode = L"External"; else @@ -164,15 +160,11 @@ public: void CheckOriginSigs(const std::wstring& file) { int rId = 0; - std::string sReplace = ""; std::vector::iterator i = rels.begin(); while (i != rels.end()) { if (0 == i->target.find(L"_xmlsignatures/")) - { - sReplace = U_TO_UTF8(i->target); - break; - } + return; std::wstring rid = i->rid; rid = rid.substr(3); @@ -185,23 +177,6 @@ public: i++; } - if (!sReplace.empty()) - { - if (sReplace == "_xmlsignatures/origin.sigs") - return; - - std::string sXmlA; - NSFile::CFileBinary::ReadAllTextUtf8A(file, sXmlA); - NSStringUtils::string_replaceA(sXmlA, sReplace, "_xmlsignatures/origin.sigs"); - - NSFile::CFileBinary::Remove(file); - NSFile::CFileBinary oFile; - oFile.CreateFileW(file); - oFile.WriteFile((BYTE*)sXmlA.c_str(), (DWORD)sXmlA.length()); - oFile.CloseFile(); - return; - } - std::string sXmlA; NSFile::CFileBinary::ReadAllTextUtf8A(file, sXmlA); @@ -216,6 +191,7 @@ Type=\"http://schemas.openxmlformats.org/package/2006/relationships/digital-sign "); NSFile::CFileBinary::Remove(file); + NSFile::CFileBinary oFile; oFile.CreateFileW(file); oFile.WriteFile((BYTE*)sRet.c_str(), (DWORD)sRet.length()); diff --git a/DesktopEditor/xmlsec/src/src/XmlSigner_mscrypto.h b/DesktopEditor/xmlsec/src/src/XmlSigner_mscrypto.h index bae58c4ae7..38a6931536 100644 --- a/DesktopEditor/xmlsec/src/src/XmlSigner_mscrypto.h +++ b/DesktopEditor/xmlsec/src/src/XmlSigner_mscrypto.h @@ -572,9 +572,6 @@ public: virtual bool Verify(const std::string& sXml, std::string& sXmlSignature, int nAlg) { - if (sXmlSignature.empty()) - return false; - DWORD dwKeySpec = 0; HCRYPTHASH hHash = NULL; HCRYPTKEY hPubKey = NULL; @@ -671,8 +668,6 @@ public: virtual int ShowCertificate(void* parent = NULL) { - if (NULL == m_context) - return 0; return (int)CryptUIDlgViewContext(CERT_STORE_CERTIFICATE_CONTEXT, m_context, (NULL == parent) ? NULL : (*((HWND*)parent)), NULL, 0, NULL); } @@ -706,11 +701,6 @@ public: return 1; } - virtual std::string Print() - { - return ""; - } - private: void ConvertEndian(const BYTE* src, BYTE* dst, DWORD size) { diff --git a/DesktopEditor/xmlsec/src/src/XmlSigner_openssl.cpp b/DesktopEditor/xmlsec/src/src/XmlSigner_openssl.cpp index 4989396609..751a8cfb89 100644 --- a/DesktopEditor/xmlsec/src/src/XmlSigner_openssl.cpp +++ b/DesktopEditor/xmlsec/src/src/XmlSigner_openssl.cpp @@ -211,9 +211,9 @@ public: char* dataDst = NULL; int lenDst = 0; - NSFile::CBase64Converter::Encode(data, size, dataDst, lenDst, NSBase64::B64_BASE64_FLAG_NOCRLF); + NSFile::CBase64Converter::Encode(data, size, dataDst, lenDst); - std::string sReturn(dataDst, lenDst); + std::string sReturn(dataDst); RELEASEARRAYOBJECTS(dataDst); @@ -540,20 +540,6 @@ public: return -1; } - std::string Print() - { - if (NULL == m_cert) - return ""; - - BIO* bio = BIO_new(BIO_s_mem()); - X509_print_ex(bio, m_cert, XN_FLAG_COMPAT, X509_FLAG_COMPAT); - char *buf = NULL; - size_t len = BIO_get_mem_data(bio, &buf); - std::string sRet((char*)buf, len); - BIO_free (bio); - return sRet; - } - int VerifySelf() { return OPEN_SSL_WARNING_OK; @@ -761,22 +747,8 @@ end: nErr = OPEN_SSL_WARNING_PASS; goto end; } - BIO_FREE(bio); - bio = BIO_new_mem_buf((void*)pData, (int)dwDataLen); - if (PEM_read_bio_X509_AUX(bio, &pCert, NULL, (void*)pPassword)) - { - nErr = OPEN_SSL_WARNING_OK; - goto end; - } - sError = GetOpenSslErrors(); - if (IsOpenSslPasswordError(sError)) - { - nErr = OPEN_SSL_WARNING_PASS; - goto end; - } BIO_FREE(bio); - bio = BIO_new_mem_buf((void*)pData, (int)dwDataLen); if (d2i_X509_bio(bio, &pCert)) { @@ -789,9 +761,10 @@ end: nErr = OPEN_SSL_WARNING_PASS; goto end; } - BIO_FREE(bio); + BIO_FREE(bio); bio = BIO_new_mem_buf((void*)pData, (int)dwDataLen); + p12 = d2i_PKCS12_bio(bio, NULL); if (p12) { @@ -932,11 +905,6 @@ int CCertificate_openssl::ShowCertificate(void* parent) return m_internal->ShowCertificate(); } -std::string CCertificate_openssl::Print() -{ - return m_internal->Print(); -} - bool CCertificate_openssl::FromFiles(const std::wstring& keyPath, const std::string& keyPassword, const std::wstring& certPath, const std::string& certPassword) { return m_internal->FromFiles(keyPath, keyPassword, certPath, certPassword); diff --git a/DesktopEditor/xmlsec/src/src/XmlSigner_openssl.h b/DesktopEditor/xmlsec/src/src/XmlSigner_openssl.h index 4bd272b189..70270bcad4 100644 --- a/DesktopEditor/xmlsec/src/src/XmlSigner_openssl.h +++ b/DesktopEditor/xmlsec/src/src/XmlSigner_openssl.h @@ -51,7 +51,6 @@ public: public: virtual int ShowSelectDialog(void* parent = NULL); virtual int ShowCertificate(void* parent = NULL); - virtual std::string Print(); virtual bool FromFiles(const std::wstring& keyPath, const std::string& keyPassword, const std::wstring& certPath, const std::string& certPassword); bool FromId(const std::string& id); diff --git a/EpubFile/CEpubFile.h b/EpubFile/CEpubFile.h index 623735a661..89ce14522c 100644 --- a/EpubFile/CEpubFile.h +++ b/EpubFile/CEpubFile.h @@ -17,9 +17,9 @@ class EPUBFILE_EXPORT CEpubFile std::wstring m_sTempDir; CBookInfo m_oBookInfo; - CBookToc m_oToc; std::map m_mapRefs; - std::vector m_arContents; + CBookToc m_oToc; + std::vector m_arContents; public: CEpubFile(); @@ -30,7 +30,6 @@ public: void SetTempDirectory(const std::wstring& stempDir); HRESULT Convert(const std::wstring& sInputFile, const std::wstring& sOutputFile, bool bIsOutCompress = true); void ShowMap(); - HRESULT FromHtml(const std::wstring& sHtmlFile, const std::wstring& sCoreFile, const std::wstring& sDstFile); }; #endif // CEPUBFILE_H diff --git a/EpubFile/CEpubFile.pro b/EpubFile/CEpubFile.pro index 9976c87322..21d17eec67 100644 --- a/EpubFile/CEpubFile.pro +++ b/EpubFile/CEpubFile.pro @@ -16,7 +16,7 @@ PWD_ROOT_DIR = $$PWD include($$CORE_ROOT_DIR/Common/base.pri) -ADD_DEPENDENCY(kernel, graphics, HtmlFile2) +ADD_DEPENDENCY(kernel, HtmlFile2) SOURCES += src/CEpubFile.cpp \ src/CBookToc.cpp \ diff --git a/EpubFile/src/CBookItem.cpp b/EpubFile/src/CBookItem.cpp index 4d77414847..882ac17a74 100644 --- a/EpubFile/src/CBookItem.cpp +++ b/EpubFile/src/CBookItem.cpp @@ -17,40 +17,6 @@ void CBookItem::Clear() m_eType = Default; } */ -wchar_t _is_hex_char(wchar_t ch) -{ - if(L'0' <= ch && ch <= L'9') - return (ch - L'0'); - else if(L'A' <= ch && ch <= L'F') - return (ch - L'A') + 10; - else if(L'a' <= ch && ch <= L'f') - return (ch - L'a') + 10; - return static_cast(-1); -} - -wchar_t _hex_str2int(wchar_t* str) -{ - return _is_hex_char(str[0]) << 4 | _is_hex_char(str[1]); -} - -std::wstring URLDecode(const std::wstring& src) -{ - std::wstring dst; - wchar_t* buf = new wchar_t[3]; - buf[2] = L'\0'; - for(size_t i = 0; i < src.length(); i++) - { - if(src[i] == L'%') - { - buf[0] = src.at(++i); - buf[1] = src.at(++i); - dst.append(1, _hex_str2int(buf)); - } else - dst.append(1, src.at(i)); - } - delete buf; - return dst; -} bool CBookItem::ReadItem(XmlUtils::CXmlLiteReader& oXmlLiteReader, int depth) { @@ -64,7 +30,6 @@ bool CBookItem::ReadItem(XmlUtils::CXmlLiteReader& oXmlLiteReader, int depth) if (sAttributeName == L"href") { - sAttributeValue = URLDecode(sAttributeValue); size_t posLastSlash = sAttributeValue.rfind(L'/'); m_sRef = posLastSlash == std::wstring::npos ? sAttributeValue : sAttributeValue.substr(posLastSlash + 1); } diff --git a/EpubFile/src/CBookToc.cpp b/EpubFile/src/CBookToc.cpp index f40838b274..4f7affca67 100644 --- a/EpubFile/src/CBookToc.cpp +++ b/EpubFile/src/CBookToc.cpp @@ -39,12 +39,13 @@ std::wstring CBookToc::GetAttributeValue(XmlUtils::CXmlLiteReader& oXmlLiteReade { while(oXmlLiteReader.MoveToNextAttribute()) { - if (oXmlLiteReader.GetName() == sAttributeName) + std::wstring _sAttributeName = oXmlLiteReader.GetName(); + if(_sAttributeName == sAttributeName) { std::wstring sText = oXmlLiteReader.GetText(); size_t posLastSlash = sText.rfind(L'/'); if (posLastSlash != std::wstring::npos) - sText.erase(0, posLastSlash + 1); + sText = sText.substr(posLastSlash + 1); oXmlLiteReader.MoveToElement(); return sText; } @@ -78,7 +79,7 @@ void CBookToc::ReadMap(XmlUtils::CXmlLiteReader& oXmlLiteReader) structData.sRef = GetAttributeValue(oXmlLiteReader, L"src"); } - if (structData.Full()) + if(structData.Full()) { m_arData.push_back(structData); structData.Clear(); diff --git a/EpubFile/src/CEpubFile.cpp b/EpubFile/src/CEpubFile.cpp index edf8668dd9..8c7543ba01 100644 --- a/EpubFile/src/CEpubFile.cpp +++ b/EpubFile/src/CEpubFile.cpp @@ -3,43 +3,23 @@ #include "../../OfficeUtils/src/OfficeUtils.h" #include "../../DesktopEditor/xml/include/xmlutils.h" #include "../../HtmlFile2/htmlfile2.h" -#include "../../DesktopEditor/raster/BgraFrame.h" #include "src/CBookInfo.h" #include -#include #include -#include -#include // Заменяет в строке s все символы s1 на s2 -void replace_all(std::wstring& s, const std::wstring& s1, const std::wstring& s2) +static void replace_all(std::wstring& s, const std::wstring& s1, const std::wstring& s2) { size_t pos = s.find(s1); size_t l = s2.length(); - while (pos != std::string::npos) + while(pos != std::string::npos) { s.replace(pos, s1.length(), s2); pos = s.find(s1, pos + l); } } -std::wstring GenerateUUID() -{ - std::mt19937 oRand(time(0)); - std::wstringstream sstream; - sstream << std::setfill(L'0') << std::hex << std::setw(8) << (oRand() & 0xffffffff); - sstream << L'-'; - sstream << std::setfill(L'0') << std::hex << std::setw(4) << (oRand() & 0xffff); - sstream << L'-'; - sstream << std::setfill(L'0') << std::hex << std::setw(4) << (oRand() & 0xffff); - sstream << L'-'; - sstream << std::setfill(L'0') << std::hex << std::setw(4) << (oRand() & 0xffff); - sstream << L'-'; - sstream << std::setfill(L'0') << std::hex << std::setw(8) << (oRand() & 0xffffffff); - return sstream.str(); -} - CEpubFile::CEpubFile() { } @@ -74,10 +54,10 @@ HRESULT CEpubFile::Convert(const std::wstring& sInputFile, const std::wstring& s std::wstring sFileContent; std::wstring sContent; - if (!NSFile::CFileBinary::ReadAllTextUtf8(m_sTempDir + L"/container.xml", sFileContent)) + if(!NSFile::CFileBinary::ReadAllTextUtf8(m_sTempDir + L"/container.xml", sFileContent)) return S_FALSE; size_t nContent = sFileContent.find(L"full-path"); - if (nContent != std::wstring::npos) + if(nContent != std::wstring::npos) { nContent += 11; sContent = sFileContent.substr(nContent, sFileContent.find(L'\"', nContent) - nContent); @@ -87,44 +67,50 @@ HRESULT CEpubFile::Convert(const std::wstring& sInputFile, const std::wstring& s } sContent = m_sTempDir + (sContent.empty() ? L"/content.opf" : L'/' + sContent); + XmlUtils::CXmlLiteReader oXmlLiteReader; - if (!oXmlLiteReader.FromFile(sContent)) - return S_FALSE; - oXmlLiteReader.ReadNextNode(); - int nParentDepth = oXmlLiteReader.GetDepth(); - while (oXmlLiteReader.ReadNextSiblingNode(nParentDepth)) + if (oXmlLiteReader.FromFile(sContent)) { - std::wstring sName = oXmlLiteReader.GetName(); - size_t nDot = sName.find(L':'); - if (nDot != std::wstring::npos) - sName.erase(0, nDot + 1); - if (sName == L"metadata") - m_oBookInfo.ReadInfo(oXmlLiteReader); - else if (sName == L"manifest") + oXmlLiteReader.ReadNextNode(); + int nParentDepth = oXmlLiteReader.GetDepth(); + while (oXmlLiteReader.ReadNextSiblingNode(nParentDepth)) { - int _nParentDepth = oXmlLiteReader.GetDepth(); - while (true) + std::wstring sName = oXmlLiteReader.GetName(); + if (sName == L"metadata") { - CBookItem oItem; - if (oItem.ReadItem(oXmlLiteReader, _nParentDepth)) - m_mapRefs.insert(std::make_pair(oItem.GetID(), oItem)); - else - break; + m_oBookInfo.ReadInfo(oXmlLiteReader); +// #ifdef _DEBUG +// m_oBookInfo.ShowInfo(); +// #endif } - } - else if (sName == L"spine") - { - int _nParentDepth = oXmlLiteReader.GetDepth(); - while (true) + else if (sName == L"manifest") { - CBookContentItem oContentItem; - if (oContentItem.ReadContentItem(oXmlLiteReader, _nParentDepth)) - m_arContents.push_back(oContentItem); - else - break; + int _nParentDepth = oXmlLiteReader.GetDepth(); + while (true) + { + CBookItem oItem; + if (oItem.ReadItem(oXmlLiteReader, _nParentDepth)) + m_mapRefs.insert(std::make_pair(oItem.GetID(), oItem)); + else + break; + } + } + else if (sName == L"spine") + { + int _nParentDepth = oXmlLiteReader.GetDepth(); + while (true) + { + CBookContentItem oContentItem; + if (oContentItem.ReadContentItem(oXmlLiteReader, _nParentDepth)) + m_arContents.push_back(oContentItem); + else + break; + } } } } + else + return S_FALSE; /* if (!oXmlLiteReader.FromFile(m_sTempDir + L"/toc.ncx")) @@ -141,9 +127,9 @@ HRESULT CEpubFile::Convert(const std::wstring& sInputFile, const std::wstring& s CHtmlParams oFileParams; oFileParams.SetAuthors(m_oBookInfo.GetCreators()); - oFileParams.SetGenres (m_oBookInfo.GetSubjects()); - oFileParams.SetTitle (m_oBookInfo.GetTitle()); - oFileParams.SetDate (m_oBookInfo.GetDate()); + oFileParams.SetGenres(m_oBookInfo.GetSubjects()); + oFileParams.SetTitle(m_oBookInfo.GetTitle()); + oFileParams.SetDate(m_oBookInfo.GetDate()); oFileParams.SetDescription(m_oBookInfo.GetDescriptions()); oFileParams.SetPageBreakBefore(true); @@ -195,156 +181,3 @@ void CEpubFile::ShowMap() for (const CBookContentItem& oItem : m_arContents) std::wcout << oItem.m_sID << L" - " << m_mapRefs[oItem.m_sID].GetRef() << std::endl; } - -HRESULT CEpubFile::FromHtml(const std::wstring& sHtmlFile, const std::wstring& sCoreFile, const std::wstring& sDstFile) -{ - NSDirectory::CreateDirectory(m_sTempDir + L"/META-INF"); - NSDirectory::CreateDirectory(m_sTempDir + L"/OEBPS"); - // index.html - std::wstring sIndexHtml; - NSFile::CFileBinary::ReadAllTextUtf8(sHtmlFile, sIndexHtml); - - size_t nImage = sIndexHtml.find(L"data:image/png;base64, "); - int nNumImage = 1; - if (nImage != std::wstring::npos) - NSDirectory::CreateDirectory(m_sTempDir + L"/OEBPS/images"); - while (nImage != std::wstring::npos) - { - size_t nImageBegin = sIndexHtml.find(L' ', nImage) + 1; - size_t nImageEnd = sIndexHtml.find(L'\"', nImageBegin); - std::wstring sImage = sIndexHtml.substr(nImageBegin, nImageEnd - nImageBegin); - NSFile::CFileBinary oImageWriter; - if (oImageWriter.CreateFileW(m_sTempDir + L"/OEBPS/images/img" + std::to_wstring(nNumImage) + L".png")) - { - int nSrcLen = (int)sImage.length(); - int nDecodeLen = NSBase64::Base64DecodeGetRequiredLength(nSrcLen); - BYTE* pImageData = new BYTE[nDecodeLen]; - if (TRUE == NSBase64::Base64Decode(U_TO_UTF8(sImage).c_str(), nSrcLen, pImageData, &nDecodeLen)) - oImageWriter.WriteFile(pImageData, (DWORD)nDecodeLen); - RELEASEARRAYOBJECTS(pImageData); - oImageWriter.CloseFile(); - } - sIndexHtml.replace(nImage, nImageEnd - nImage, L"images/img" + std::to_wstring(nNumImage++) + L".png"); - nImage = sIndexHtml.find(L"data:image/png;base64, ", nImage); - } - - NSFile::CFileBinary oIndexHtml; - if (oIndexHtml.CreateFileW(m_sTempDir + L"/OEBPS/index.html")) - { - oIndexHtml.WriteStringUTF8(L""); - oIndexHtml.WriteStringUTF8(sIndexHtml); - oIndexHtml.CloseFile(); - } - // mimetype - NSFile::CFileBinary oMimeType; - if (oMimeType.CreateFileW(m_sTempDir + L"/mimetype")) - { - oMimeType.WriteStringUTF8(L"application/epub+zip"); - oMimeType.CloseFile(); - } - // container.xml - NSFile::CFileBinary oContainerXml; - if (oContainerXml.CreateFileW(m_sTempDir + L"/META-INF/container.xml")) - { - oContainerXml.WriteStringUTF8(L""); - oContainerXml.CloseFile(); - } - // cover.html - bool bCoverFromImg1 = NSFile::CFileBinary::Exists(m_sTempDir + L"/OEBPS/images/img1.png"); - if (bCoverFromImg1) - { - int nHy = 0; - int nWx = 0; - CBgraFrame oBgraFrame; - if (oBgraFrame.OpenFile(m_sTempDir + L"/OEBPS/images/img1.png")) - { - nHy = oBgraFrame.get_Height(); - nWx = oBgraFrame.get_Width(); - } - NSFile::CFileBinary oCoverHtml; - if (oCoverHtml.CreateFileW(m_sTempDir + L"/OEBPS/cover.html")) - { - oCoverHtml.WriteStringUTF8(L"Cover
"); - oCoverHtml.CloseFile(); - } - } - // content.opf - NSFile::CFileBinary oContentOpf; - std::wstring sTitle; - std::wstring sUUID = GenerateUUID(); - if (oContentOpf.CreateFileW(m_sTempDir + L"/OEBPS/content.opf")) - { - oContentOpf.WriteStringUTF8(L""); - // metadata - std::wstring sCoreXml; - bool bWasIdentifier = false; - XmlUtils::CXmlLiteReader oCoreReader; - if (NSFile::CFileBinary::ReadAllTextUtf8(sCoreFile, sCoreXml)) - { - oCoreReader.FromString(sCoreXml); - oCoreReader.ReadNextNode(); - int nDeath = oCoreReader.GetDepth(); - while (oCoreReader.ReadNextSiblingNode(nDeath)) - { - if (oCoreReader.GetNamespacePrefix() == L"dc") - { - std::wstring sOut = oCoreReader.GetOuterXml(); - oContentOpf.WriteStringUTF8(sOut); - std::wstring sName = oCoreReader.GetName(); - if (sName == L"dc:identifier") - bWasIdentifier = true; - else if (sName == L"dc:title") - { - size_t nBegin = sOut.find(L'>'); - if (nBegin == std::wstring::npos) - continue; - sOut.erase(0, nBegin + 1); - nBegin = sOut.find(L'<'); - if (nBegin == std::wstring::npos) - continue; - sOut.erase(nBegin); - sTitle = sOut; - } - } - } - } - if (!bWasIdentifier) - { - oContentOpf.WriteStringUTF8(L"urn:uuid:"); - oContentOpf.WriteStringUTF8(sUUID); - oContentOpf.WriteStringUTF8(L""); - } - if (bCoverFromImg1) - oContentOpf.WriteStringUTF8(L""); - // manifest - oContentOpf.WriteStringUTF8(L""); - std::vector arFiles = NSDirectory::GetFiles(m_sTempDir + L"/OEBPS/images"); - for (const std::wstring& sFileName : arFiles) - { - std::wstring sName = NSFile::GetFileName(sFileName); - oContentOpf.WriteStringUTF8(L""); - } - oContentOpf.WriteStringUTF8(L""); - if (bCoverFromImg1) - oContentOpf.WriteStringUTF8(L""); - // spine - oContentOpf.WriteStringUTF8(L""); - if (bCoverFromImg1) - oContentOpf.WriteStringUTF8(L""); - // guide - oContentOpf.WriteStringUTF8(L""); - if (bCoverFromImg1) - oContentOpf.WriteStringUTF8(L""); - oContentOpf.WriteStringUTF8(L""); - oContentOpf.CloseFile(); - } - // toc.ncx - NSFile::CFileBinary oTocNcx; - if (oTocNcx.CreateFileW(m_sTempDir + L"/OEBPS/toc.ncx")) - { - oTocNcx.WriteStringUTF8(L"" + sTitle + L"Start"); - oTocNcx.CloseFile(); - } - COfficeUtils oOfficeUtils; - return oOfficeUtils.CompressFileOrDirectory(m_sTempDir, sDstFile); -} diff --git a/EpubFile/test/main.cpp b/EpubFile/test/main.cpp index a862d259c3..932733f4dd 100644 --- a/EpubFile/test/main.cpp +++ b/EpubFile/test/main.cpp @@ -10,24 +10,12 @@ int main() { + std::vector arFiles = NSDirectory::GetFiles(NSFile::GetProcessDirectory() + L"/../../../Files"); std::wstring sTmp = NSFile::GetProcessDirectory() + L"/tmp"; std::wstring sOutputDirectory = NSFile::GetProcessDirectory() + L"/OutputFiles"; NSDirectory::CreateDirectory(sOutputDirectory); NSDirectory::CreateDirectory(sTmp); - bool bFromHtml = false; - if (bFromHtml) - { - std::wstring sFile = NSFile::GetProcessDirectory() + L"/../../../FromHtmlTest/test3"; - CEpubFile oEpub; - oEpub.SetTempDirectory(sTmp); - oEpub.FromHtml(sFile, sOutputDirectory + L"/res.epub"); - NSDirectory::DeleteDirectory(sTmp); - return 0; - } - - std::vector arFiles = NSDirectory::GetFiles(NSFile::GetProcessDirectory() + L"/../../../Files"); - clock_t tTime1 = clock(); //Русские символы в консоль не выводятся for (const std::wstring& sFileName : arFiles) diff --git a/Fb2File/Fb2File.cpp b/Fb2File/Fb2File.cpp index ebcade32a9..30ec21dfa2 100644 --- a/Fb2File/Fb2File.cpp +++ b/Fb2File/Fb2File.cpp @@ -8,16 +8,11 @@ #include "../DesktopEditor/common/SystemUtils.h" #include "../DesktopEditor/raster/BgraFrame.h" #include "../OfficeUtils/src/OfficeUtils.h" -#include "../Common/3dParty/html/htmltoxhtml.h" #include "./template/template.h" #include #include #include -#include -#include -#include -#include #ifndef VALUE2STR #define VALUE_TO_STRING(x) #x @@ -30,8 +25,8 @@ struct SAuthor std::wstring first_name; std::wstring middle_name; std::wstring last_name; - std::wstring nickname; /* + std::wstring nickname; std::vector home_page; std::vector email; std::wstring id; @@ -96,7 +91,7 @@ struct STitleInfo std::wstring getAuthors() { return std::accumulate(m_arAuthors.begin(), m_arAuthors.end(), std::wstring(), - [] (std::wstring& sRes, const SAuthor& vElem) { return sRes += vElem.middle_name + L' ' + vElem.first_name + L' ' + vElem.last_name + L' ' + vElem.nickname + L';'; }); + [] (std::wstring& sRes, const SAuthor& vElem) { return sRes += vElem.middle_name + L" " + vElem.first_name + L" " + vElem.last_name + L";"; }); } }; @@ -191,7 +186,7 @@ public: CFb2File_Private() { // m_pSrcTitleInfo = NULL; - // m_pPublishInfo = NULL; + // m_pPublishInfo = NULL; m_nContentsId = 1; m_nCrossReferenceId = 1; } @@ -201,8 +196,6 @@ public: m_oLightReader.Clear(); m_mFootnotes.clear(); m_mImages.clear(); - m_oTitleInfo.m_arAuthors.clear(); - m_oTitleInfo.m_arGenres.clear(); /* m_mCustomInfo.clear(); if(m_pSrcTitleInfo) @@ -223,29 +216,29 @@ public: // Проверяет наличие тэга FictionBook bool isFictionBook() { - return m_oLightReader.ReadNextNode() && m_oLightReader.GetName() == L"FictionBook"; + return m_oLightReader.ReadNextNode() ? m_oLightReader.GetName() == L"FictionBook" : false; } // Читает поля автора void getAuthor(std::vector& arAuthor) { - if (m_oLightReader.IsEmptyNode()) + if(m_oLightReader.IsEmptyNode()) return; SAuthor oAuthor; int nDepth = m_oLightReader.GetDepth(); - while (m_oLightReader.ReadNextSiblingNode(nDepth)) + while(m_oLightReader.ReadNextSiblingNode(nDepth)) { std::wstring sName = m_oLightReader.GetName(); - if (sName == L"first-name") + if(sName == L"first-name") oAuthor.first_name = content(); - else if (sName == L"middle-name") + else if(sName == L"middle-name") oAuthor.middle_name = content(); - else if (sName == L"last-name") + else if(sName == L"last-name") oAuthor.last_name = content(); - else if (sName == L"nickname") - oAuthor.nickname = content(); /* + else if(sName == L"nickname") + oAuthor.nickname = content(); else if(sName == L"home-page") oAuthor.home_page.push_back(content()); else if(sName == L"email") @@ -262,15 +255,15 @@ public: void readImage(NSStringUtils::CStringBuilder& oBuilder) { // Читаем href - std::wstring sImageName; - while (m_oLightReader.MoveToNextAttribute()) + std::wstring sImageName = L""; + while(m_oLightReader.MoveToNextAttribute()) { std::wstring sName = m_oLightReader.GetName(); size_t nLen = (sName.length() > 4 ? sName.length() - 4 : 0); - if (sName.substr(nLen) == L"href") + if(sName.substr(nLen) == L"href") { std::wstring sText = m_oLightReader.GetText(); - if (sText.length() > 1) + if(sText.length() > 1) sImageName = sText.substr(1); } } @@ -279,7 +272,7 @@ public: readCrossReference(oBuilder); std::map>::iterator it = m_mImages.find(sImageName); - if (it != m_mImages.end()) + if(it != m_mImages.end()) { // Пишем картинку в файл // extent @@ -309,24 +302,24 @@ public: } // Читает title - void readTitle(const std::wstring& sLevel, NSStringUtils::CStringBuilder& oBuilder) + void readTitle(std::wstring sLevel, NSStringUtils::CStringBuilder& oBuilder) { - if (m_oLightReader.IsEmptyNode()) + if(m_oLightReader.IsEmptyNode()) return; bool bFirstP = true; int nDeath = m_oLightReader.GetDepth(); - while (m_oLightReader.ReadNextSiblingNode(nDeath)) + while(m_oLightReader.ReadNextSiblingNode(nDeath)) { // Пишем заголовок - if (m_oLightReader.GetName() == L"p") + if(m_oLightReader.GetName() == L"p") { // Пишем title + sLevel oBuilder += L""; // Заголовок книги с новой страницы - if (sLevel == L"title" && bFirstP) + if(sLevel == L"title" && bFirstP) { oBuilder += L""; bFirstP = false; @@ -334,7 +327,7 @@ public: oBuilder += L""; // Пишем ссылку от оглавления std::wstring sContentsId; - if (sLevel == L"title1") + if(sLevel == L"title1") { sContentsId = std::to_wstring(m_nContentsId++); oBuilder += L""; readP(L"", oBuilder); oBuilder += L""; } - else if (sName == L"poem") + else if(sName == L"poem") readPoem(oBuilder); - else if (sName == L"cite") + else if(sName == L"cite") readCite(oBuilder); - else if (sName == L"empty-line") + else if(sName == L"empty-line") oBuilder += L""; // Автор эпиграфа выделяется полужирным - else if (sName == L"text-author") + else if(sName == L"text-author") { oBuilder += L""; readP(L"", oBuilder); @@ -393,19 +386,19 @@ public: // Читает p // НЕ имеет право писать p // sRStyle - накопленный стиль - void readP(const std::wstring& sRStyle, NSStringUtils::CStringBuilder& oBuilder) + void readP(std::wstring sRStyle, NSStringUtils::CStringBuilder& oBuilder) { readCrossReference(oBuilder); - if (m_oLightReader.IsEmptyNode()) + if(m_oLightReader.IsEmptyNode()) return; int nDepth = m_oLightReader.GetDepth(); - while (m_oLightReader.ReadNextSiblingNode2(nDepth)) + while(m_oLightReader.ReadNextSiblingNode2(nDepth)) { std::wstring sName = m_oLightReader.GetName(); // Читаем обычный текст - if (sName == L"#text") + if(sName == L"#text") { // Стиль текста oBuilder += L""; @@ -420,24 +413,24 @@ public: else if (sName == L"strong") readP(sRStyle + L"", oBuilder); // Читаем курсивный текст - else if (sName == L"emphasis") + else if(sName == L"emphasis") readP(sRStyle + L"", oBuilder); // Читаем стилизованный текст - else if (sName == L"style") + else if(sName == L"style") readP(sRStyle, oBuilder); // Читаем ссылку - else if (sName == L"a") + else if(sName == L"a") { // Читаем href - std::wstring sFootnoteName; - while (m_oLightReader.MoveToNextAttribute()) + std::wstring sFootnoteName = L""; + while(m_oLightReader.MoveToNextAttribute()) { std::wstring sTName = m_oLightReader.GetName(); size_t nLen = (sTName.length() > 4 ? sTName.length() - 4 : 0); - if (sTName.substr(nLen) == L"href") + if(sTName.substr(nLen) == L"href") { std::wstring sText = m_oLightReader.GetText(); - if (sText.length() > 1) + if(sText.length() > 1) sFootnoteName = sText.substr(1); break; } @@ -445,7 +438,7 @@ public: m_oLightReader.MoveToElement(); std::map::iterator it = m_mFootnotes.find(sFootnoteName); - if (it != m_mFootnotes.end()) + if(it != m_mFootnotes.end()) { // Пробел перед текстом внутри сноски oBuilder += L" "; @@ -468,19 +461,19 @@ public: } } // Читаем вычеркнутый текст - else if (sName == L"strikethrough") + else if(sName == L"strikethrough") readP(sRStyle + L"", oBuilder); // Читает нижний текст - else if (sName == L"sub") + else if(sName == L"sub") readP(sRStyle + L"", oBuilder); // Читает верхний текст - else if (sName == L"sup") + else if(sName == L"sup") readP(sRStyle + L"", oBuilder); // Читает код - else if (sName == L"code") + else if(sName == L"code") readP(sRStyle + L"", oBuilder); // Читает картинку в тексте - else if (sName == L"image") + else if(sName == L"image") readImage(oBuilder); } } @@ -490,29 +483,29 @@ public: { readCrossReference(oBuilder); - if (m_oLightReader.IsEmptyNode()) + if(m_oLightReader.IsEmptyNode()) return; int nDeath = m_oLightReader.GetDepth(); - while (m_oLightReader.ReadNextSiblingNode(nDeath)) + while(m_oLightReader.ReadNextSiblingNode(nDeath)) { std::wstring sName = m_oLightReader.GetName(); - if (sName == L"title") + if(sName == L"title") readTitle(L"title4", oBuilder); - else if (sName == L"epigraph") + else if(sName == L"epigraph") readEpigraph(oBuilder); - else if (sName == L"stanza") + else if(sName == L"stanza") { - if (m_oLightReader.IsEmptyNode()) + if(m_oLightReader.IsEmptyNode()) continue; int nSDeath = m_oLightReader.GetDepth(); - while (m_oLightReader.ReadNextSiblingNode(nSDeath)) + while(m_oLightReader.ReadNextSiblingNode(nSDeath)) { std::wstring sSName = m_oLightReader.GetName(); - if (sSName == L"title") + if(sSName == L"title") readTitle(L"title5", oBuilder); - else if (sSName == L"v" || sSName == L"subtitle") + else if(sSName == L"v" || sSName == L"subtitle") { oBuilder += L""; readP(L"", oBuilder); @@ -521,13 +514,13 @@ public: } } // Автор поэмы выделяется полужирным - else if (sName == L"text-author") + else if(sName == L"text-author") { oBuilder += L""; readP(L"", oBuilder); oBuilder += L""; } - else if (sName == L"date") + else if(sName == L"date") { oBuilder += L""; oBuilder.WriteEncodeXmlString(content()); @@ -541,27 +534,27 @@ public: { readCrossReference(oBuilder); - if (m_oLightReader.IsEmptyNode()) + if(m_oLightReader.IsEmptyNode()) return; int nDeath = m_oLightReader.GetDepth(); - while (m_oLightReader.ReadNextSiblingNode(nDeath)) + while(m_oLightReader.ReadNextSiblingNode(nDeath)) { std::wstring sName = m_oLightReader.GetName(); - if (sName == L"p" || sName == L"subtitle") + if(sName == L"p" || sName == L"subtitle") { oBuilder += L""; readP(L"", oBuilder); oBuilder += L""; } - else if (sName == L"empty-line") + else if(sName == L"empty-line") oBuilder += L""; - else if (sName == L"poem") + else if(sName == L"poem") readPoem(oBuilder); - else if (sName == L"table") + else if(sName == L"table") readTable(oBuilder); // Автор цитаты выделяется полужирным - else if (sName == L"text-author") + else if(sName == L"text-author") { oBuilder += L""; readP(L"", oBuilder); @@ -575,7 +568,7 @@ public: { readCrossReference(oBuilder); - if (m_oLightReader.IsEmptyNode()) + if(m_oLightReader.IsEmptyNode()) return; // Стиль таблицы @@ -584,43 +577,47 @@ public: NSStringUtils::CStringBuilder oTmpBuilder; int nGridCol = 0; int nDeath = m_oLightReader.GetDepth(); - while (m_oLightReader.ReadNextSiblingNode(nDeath)) + while(m_oLightReader.ReadNextSiblingNode(nDeath)) { // tr - строки в таблице - if (m_oLightReader.GetName() != L"tr" || m_oLightReader.IsEmptyNode()) - continue; - int nTCol = 0; - oTmpBuilder += L""; - int nTrDeath = m_oLightReader.GetDepth(); - while (m_oLightReader.ReadNextSiblingNode(nTrDeath)) + if(m_oLightReader.GetName() == L"tr") { - oTmpBuilder += L""; - // Читаем th. Ячейка заголовка таблицы. Выравнивание посередине. Выделяется полужирным - if (m_oLightReader.GetName() == L"th") + if(m_oLightReader.IsEmptyNode()) + continue; + + int nTCol = 0; + oTmpBuilder += L""; + int nTrDeath = m_oLightReader.GetDepth(); + while(m_oLightReader.ReadNextSiblingNode(nTrDeath)) { - if (++nTCol > nGridCol) - nGridCol = nTCol; - oTmpBuilder += L""; - readP(L"", oTmpBuilder); + oTmpBuilder += L""; + // Читаем th. Ячейка заголовка таблицы. Выравнивание посередине. Выделяется полужирным + if(m_oLightReader.GetName() == L"th") + { + if(++nTCol > nGridCol) + nGridCol = nTCol; + oTmpBuilder += L""; + readP(L"", oTmpBuilder); + } + // Читаем td. Ячейка таблицы. Выравнивание вправо + else if(m_oLightReader.GetName() == L"td") + { + if(++nTCol > nGridCol) + nGridCol = nTCol; + oTmpBuilder += L""; + readP(L"", oTmpBuilder); + } + oTmpBuilder += L""; } - // Читаем td. Ячейка таблицы. Выравнивание вправо - else if (m_oLightReader.GetName() == L"td") - { - if(++nTCol > nGridCol) - nGridCol = nTCol; - oTmpBuilder += L""; - readP(L"", oTmpBuilder); - } - oTmpBuilder += L""; + oTmpBuilder += L""; } - oTmpBuilder += L""; } // Размеры таблицы - std::wstring sGridCol; - if (nGridCol != 0) + std::wstring sGridCol = L""; + if(nGridCol != 0) sGridCol = std::to_wstring((int)(9570.0 / (double)nGridCol)); oBuilder += L""; - for (int i = 0; i < nGridCol; i++) + for(int i = 0; i < nGridCol; i++) { oBuilder += L""; readP(L"", oBuilder); oBuilder += L""; } - else if (sAnName == L"poem") + else if(sAnName == L"poem") readPoem(oBuilder); - else if (sAnName == L"cite") + else if(sAnName == L"cite") readCite(oBuilder); - else if (sAnName == L"empty-line") + else if(sAnName == L"empty-line") oBuilder += L""; - else if (sAnName == L"table") + else if(sAnName == L"table") readTable(oBuilder); } } @@ -667,9 +664,9 @@ public: void readCrossReference(NSStringUtils::CStringBuilder& oBuilder) { // id для перекрестных ссылок - while (m_oLightReader.MoveToNextAttribute()) + while(m_oLightReader.MoveToNextAttribute()) { - if (m_oLightReader.GetName() == L"id") + if(m_oLightReader.GetName() == L"id") { std::wstring sCrossId = std::to_wstring(m_nCrossReferenceId++); oBuilder += L""; readImage(oBuilder); oBuilder += L""; } - else if (sName == L"annotation") + else if(sName == L"annotation") readAnnotation(oBuilder); - else if (sName == L"section") + else if(sName == L"section") readSection(nLevel + 1, oBuilder); - else if (sName == L"p") + else if(sName == L"p") { oBuilder += L""; readP(L"", oBuilder); oBuilder += L""; } - else if (sName == L"subtitle") + else if(sName == L"subtitle") { oBuilder += L""; readP(L"", oBuilder); oBuilder += L""; } - else if (sName == L"poem") + else if(sName == L"poem") readPoem(oBuilder); - else if (sName == L"cite") + else if(sName == L"cite") readCite(oBuilder); - else if (sName == L"empty-line") + else if(sName == L"empty-line") oBuilder += L""; - else if (sName == L"table") + else if(sName == L"table") readTable(oBuilder); } } @@ -742,24 +739,24 @@ public: // Читает body void readBody(NSStringUtils::CStringBuilder& oBuilder) { - if (m_oLightReader.IsEmptyNode()) + if(m_oLightReader.IsEmptyNode()) return; int nDeath = m_oLightReader.GetDepth(); - while (m_oLightReader.ReadNextSiblingNode(nDeath)) + while(m_oLightReader.ReadNextSiblingNode(nDeath)) { std::wstring sName = m_oLightReader.GetName(); - if (sName == L"image") + if(sName == L"image") { oBuilder += L""; readImage(oBuilder); oBuilder += L""; } - else if (sName == L"title") + else if(sName == L"title") readTitle(L"title", oBuilder); - else if (sName == L"epigraph") + else if(sName == L"epigraph") readEpigraph(oBuilder); - else if (sName == L"section") + else if(sName == L"section") readSection(1, oBuilder); } } @@ -767,50 +764,53 @@ public: // Читает содержание, binary, body, сноски, description bool readText(const std::wstring& sPath, const std::wstring& sMediaDirectory, NSStringUtils::CStringBuilder& oContents, NSStringUtils::CStringBuilder& oRels, NSStringUtils::CStringBuilder& oFootnotes) { - if (!m_oLightReader.IsValid()) + if(!m_oLightReader.IsValid()) { // Открывает файл на проверку if (!OpenFromFile(sPath)) return false; // Читаем FictionBook - if (!isFictionBook()) + if(!isFictionBook()) return false; } - if (m_oLightReader.IsEmptyNode()) + if(m_oLightReader.IsEmptyNode()) return true; int nContentsId = 1; - int nImageId = 1; + int nImageId = 1; int nFootnoteId = 1; oContents += L""; int nDeath = m_oLightReader.GetDepth(); - while (m_oLightReader.ReadNextSiblingNode(nDeath)) + while(m_oLightReader.ReadNextSiblingNode(nDeath)) { std::wstring sName = m_oLightReader.GetName(); // Читаем body - if (sName == L"body") + if(sName == L"body") { // Сноски bool bNotes = false; while(m_oLightReader.MoveToNextAttribute()) { - if (m_oLightReader.GetName() == L"name" && - m_oLightReader.GetText() == L"notes") + if(m_oLightReader.GetName() == L"name" && + m_oLightReader.GetText() == L"notes") bNotes = true; } m_oLightReader.MoveToElement(); // Читаем сноски - if (bNotes) + if(bNotes) readNotes(nFootnoteId, oFootnotes); // Читаем содержание else readContents(nContentsId, oContents); } // Читаем картинки - else if (sName == L"binary") - getImage(std::to_wstring(nImageId++), sMediaDirectory, oRels); + else if(sName == L"binary") + { + std::wstring sImageId = std::to_wstring(nImageId++); + getImage(sImageId, sMediaDirectory, oRels); + } } oContents += L""; return true; @@ -819,170 +819,186 @@ public: // Читает содержание void readContents(int& nContentsId, NSStringUtils::CStringBuilder& oContents) { - if (m_oLightReader.IsEmptyNode()) + if(m_oLightReader.IsEmptyNode()) return; bool bFirstTitle = true; int nBDeath = m_oLightReader.GetDepth(); - while (m_oLightReader.ReadNextSiblingNode(nBDeath)) + while(m_oLightReader.ReadNextSiblingNode(nBDeath)) { + std::wstring sName = m_oLightReader.GetName(); // Читаем section - if (m_oLightReader.GetName() != L"section" || m_oLightReader.IsEmptyNode()) - continue; - int nSDeath = m_oLightReader.GetDepth(); - while (m_oLightReader.ReadNextSiblingNode(nSDeath)) + if(sName == L"section") { - // Читаем title - if (m_oLightReader.GetName() != L"title" || m_oLightReader.IsEmptyNode()) + if(m_oLightReader.IsEmptyNode()) continue; - oContents += L""; - // Абзац с новой страницы - if (bFirstTitle) - oContents += L""; - oContents += L""; - if (bFirstTitle) - { - oContents += L"TOC \\n \\h "; - bFirstTitle = false; - } - oContents += L""; - int nTDeath = m_oLightReader.GetDepth(); - while (m_oLightReader.ReadNextSiblingNode(nTDeath)) + int nSDeath = m_oLightReader.GetDepth(); + while(m_oLightReader.ReadNextSiblingNode(nSDeath)) { - if (m_oLightReader.GetName() == L"p") + // Читаем title + if(m_oLightReader.GetName() == L"title") { - readP(L"", oContents); - // Вставляем пробел между словами - oContents += L" "; + if(m_oLightReader.IsEmptyNode()) + continue; + + std::wstring sContentsId = std::to_wstring(nContentsId++); + oContents += L""; + // Абзац с новой страницы + if(bFirstTitle) + oContents += L""; + oContents += L""; + if(bFirstTitle) + { + oContents += L"TOC \\n \\h "; + bFirstTitle = false; + } + oContents += L""; + + int nTDeath = m_oLightReader.GetDepth(); + while(m_oLightReader.ReadNextSiblingNode(nTDeath)) + { + if(m_oLightReader.GetName() == L"p") + { + readP(L"", oContents); + // Вставляем пробел между словами + oContents += L" "; + } + } + oContents += L""; } } - oContents += L""; } } - if (!bFirstTitle) + if(!bFirstTitle) oContents += L""; } // Читает сноски void readNotes(int& nFootnoteId, NSStringUtils::CStringBuilder& oFootnotes) { - if (m_oLightReader.IsEmptyNode()) + if(m_oLightReader.IsEmptyNode()) return; int nBDepth = m_oLightReader.GetDepth(); - while (m_oLightReader.ReadNextSiblingNode(nBDepth)) + while(m_oLightReader.ReadNextSiblingNode(nBDepth)) { - if (m_oLightReader.GetName() != L"section") - continue; - // Читаем id - std::wstring sFootnoteName; - while (m_oLightReader.MoveToNextAttribute()) + if(m_oLightReader.GetName() == L"section") { - if (m_oLightReader.GetName() == L"id") + // Читаем id + std::wstring sFootnoteName = L""; + while(m_oLightReader.MoveToNextAttribute()) { - sFootnoteName = m_oLightReader.GetText(); - break; - } - } - m_oLightReader.MoveToElement(); - if (sFootnoteName.empty() || m_oLightReader.IsEmptyNode()) - continue; - - std::wstring sFootnoteId = std::to_wstring(nFootnoteId++); - m_mFootnotes.insert(std::make_pair(sFootnoteName, sFootnoteId)); - // Пишем сноску - oFootnotes += L""; - - // Читаем внутренность section - int nSDepth = m_oLightReader.GetDepth(); - while (m_oLightReader.ReadNextSiblingNode(nSDepth)) - { - std::wstring sName = m_oLightReader.GetName(); - if (sName == L"title") - { - if (m_oLightReader.IsEmptyNode()) - continue; - - int nTDepth = m_oLightReader.GetDepth(); - while (m_oLightReader.ReadNextSiblingNode(nTDepth)) + if(m_oLightReader.GetName() == L"id") { - if (m_oLightReader.GetName() == L"p") - { - oFootnotes += L""; - readP(L"", oFootnotes); - oFootnotes += L""; - } + sFootnoteName = m_oLightReader.GetText(); + break; } } - else if (sName == L"p" || sName == L"subtitle") - { - oFootnotes += L""; - readP(L"", oFootnotes); - oFootnotes += L""; - } - else if (sName == L"poem") - { - if (m_oLightReader.IsEmptyNode()) - continue; + m_oLightReader.MoveToElement(); + if(sFootnoteName == L"") + continue; + if(m_oLightReader.IsEmptyNode()) + continue; - int nPDepth = m_oLightReader.GetDepth(); - while (m_oLightReader.ReadNextSiblingNode(nPDepth)) + std::wstring sFootnoteId = std::to_wstring(nFootnoteId++); + m_mFootnotes.insert(std::make_pair(sFootnoteName, sFootnoteId)); + // Пишем сноску + oFootnotes += L""; + + // Читаем внутренность section + int nSDepth = m_oLightReader.GetDepth(); + while(m_oLightReader.ReadNextSiblingNode(nSDepth)) + { + std::wstring sName = m_oLightReader.GetName(); + if(sName == L"title") { - std::wstring sPName = m_oLightReader.GetName(); - // Читаем stanza (один или более) - if (sPName == L"stanza") - { - if (m_oLightReader.IsEmptyNode()) - continue; + if(m_oLightReader.IsEmptyNode()) + continue; - int nSDeath = m_oLightReader.GetDepth(); - while (m_oLightReader.ReadNextSiblingNode(nSDeath)) + int nTDepth = m_oLightReader.GetDepth(); + while(m_oLightReader.ReadNextSiblingNode(nTDepth)) + { + if(m_oLightReader.GetName() == L"p") { - // Читаем v (один или более) - if (m_oLightReader.GetName() == L"v") - { - oFootnotes += L""; - readP(L"", oFootnotes); - oFootnotes += L""; - } + oFootnotes += L""; + readP(L"", oFootnotes); + oFootnotes += L""; } } - // Читаем text-author (любое) - else if (sPName == L"text-author") + } + else if(sName == L"p" || sName == L"subtitle") + { + oFootnotes += L""; + readP(L"", oFootnotes); + oFootnotes += L""; + } + else if(sName == L"poem") + { + if(m_oLightReader.IsEmptyNode()) + continue; + + int nPDepth = m_oLightReader.GetDepth(); + while(m_oLightReader.ReadNextSiblingNode(nPDepth)) { - oFootnotes += L""; - readP(L"", oFootnotes); - oFootnotes += L""; + std::wstring sPName = m_oLightReader.GetName(); + // Читаем stanza (один или более) + if(sPName == L"stanza") + { + if(m_oLightReader.IsEmptyNode()) + continue; + + int nSDeath = m_oLightReader.GetDepth(); + while(m_oLightReader.ReadNextSiblingNode(nSDeath)) + { + // Читаем v (один или более) + if(m_oLightReader.GetName() == L"v") + { + oFootnotes += L""; + readP(L"", oFootnotes); + oFootnotes += L""; + } + } + } + // Читаем text-author (любое) + else if(sPName == L"text-author") + { + oFootnotes += L""; + readP(L"", oFootnotes); + oFootnotes += L""; + } } } } + oFootnotes += L""; } - oFootnotes += L""; } } // Читает binary void getImage(const std::wstring& sImageId, const std::wstring& sMediaDirectory, NSStringUtils::CStringBuilder& oRels) { - std::wstring sId; - while (m_oLightReader.MoveToNextAttribute()) + std::wstring sId = L""; + while(m_oLightReader.MoveToNextAttribute()) { // Читает id - if (m_oLightReader.GetName() == L"id") + if(m_oLightReader.GetName() == L"id") sId = m_oLightReader.GetText(); } m_oLightReader.MoveToElement(); - if (sId.empty() || m_oLightReader.IsEmptyNode()) + if(sId == L"") + return; + + if(m_oLightReader.IsEmptyNode()) return; // Пишет картинку в файл NSFile::CFileBinary oImageWriter; - if (oImageWriter.CreateFileW(sMediaDirectory + L'/' + sId + (sId.find(L'.') == std::wstring::npos ? L".png" : L""))) + if(oImageWriter.CreateFileW(sMediaDirectory + L"/" + sId)) { std::string sBase64 = contentA(); int nSrcLen = (int)sBase64.length(); @@ -995,10 +1011,10 @@ public: // Получаем размеры картинки CBgraFrame oBgraFrame; - oBgraFrame.OpenFile(sMediaDirectory + L'/' + sId); + oBgraFrame.OpenFile(sMediaDirectory + L"/" + sId); int nHy = oBgraFrame.get_Height(); int nWx = oBgraFrame.get_Width(); - if (nWx > nHy) + if(nWx > nHy) { int nW = nWx * 9525; nW = (nW > 7000000 ? 7000000 : nW); @@ -1010,7 +1026,7 @@ public: int nH = nHy * 9525; nH = (nH > 9000000 ? 9000000 : nH); int nW = (int)((double)nWx * (double)nH / (double)nHy); - if (nW > 7000000) + if(nW > 7000000) { nW = 7000000; nHy = (int)((double)nHy * (double)nW / (double)nWx); @@ -1037,14 +1053,15 @@ public: // Читает description void readDescription(NSStringUtils::CStringBuilder& oBuilder) { - if (m_oLightReader.IsEmptyNode()) + if(m_oLightReader.IsEmptyNode()) return; int nDepth = m_oLightReader.GetDepth(); - while (m_oLightReader.ReadNextSiblingNode(nDepth)) + while(m_oLightReader.ReadNextSiblingNode(nDepth)) { + std::wstring sName = m_oLightReader.GetName(); // Читаем title-info - if (m_oLightReader.GetName() == L"title-info") + if(sName == L"title-info") getTitleInfo(m_oTitleInfo, oBuilder); /* // Читаем src-title-info (ноль или один) @@ -1082,6 +1099,7 @@ public: } */ + // Читает publish-info /* void getPublishInfo() @@ -1209,24 +1227,24 @@ public: // Читает title-info и src-title-info void getTitleInfo(STitleInfo& oTitleInfo, NSStringUtils::CStringBuilder& oBuilder) { - if (m_oLightReader.IsEmptyNode()) + if(m_oLightReader.IsEmptyNode()) return; int nDepth = m_oLightReader.GetDepth(); - while (m_oLightReader.ReadNextSiblingNode(nDepth)) + while(m_oLightReader.ReadNextSiblingNode(nDepth)) { std::wstring sName = m_oLightReader.GetName(); - if (sName == L"annotation") + if(sName == L"annotation") readAnnotation(oBuilder); - else if (sName == L"coverpage") + else if(sName == L"coverpage") { - if (m_oLightReader.IsEmptyNode()) + if(m_oLightReader.IsEmptyNode()) continue; int nCDepth = m_oLightReader.GetDepth(); - while (m_oLightReader.ReadNextSiblingNode(nCDepth)) + while(m_oLightReader.ReadNextSiblingNode(nCDepth)) { - if (m_oLightReader.GetName() == L"image") + if(m_oLightReader.GetName() == L"image") { oBuilder += L""; readImage(oBuilder); @@ -1234,11 +1252,11 @@ public: } } } - else if (sName == L"genre") + else if(sName == L"genre") oTitleInfo.m_arGenres.push_back(content()); - else if (sName == L"author") + else if(sName == L"author") getAuthor(oTitleInfo.m_arAuthors); - else if (sName == L"book-title") + else if(sName == L"book-title") oTitleInfo.m_sBookTitle = content(); /* // Читаем keywords (ноль или один) @@ -1300,16 +1318,22 @@ public: // Возвращает содержание узла std::wstring content() { - if (!m_oLightReader.IsEmptyNode() && m_oLightReader.ReadNextSiblingNode2(m_oLightReader.GetDepth())) - return m_oLightReader.GetText(); - return L""; + std::wstring sRes = L""; + if(m_oLightReader.IsEmptyNode()) + return sRes; + if(m_oLightReader.ReadNextSiblingNode2(m_oLightReader.GetDepth())) + sRes = m_oLightReader.GetText(); + return sRes; } std::string contentA() { - if(!m_oLightReader.IsEmptyNode() && m_oLightReader.ReadNextSiblingNode2(m_oLightReader.GetDepth())) - return m_oLightReader.GetTextA(); - return ""; + std::string sRes = ""; + if(m_oLightReader.IsEmptyNode()) + return sRes; + if(m_oLightReader.ReadNextSiblingNode2(m_oLightReader.GetDepth())) + sRes = m_oLightReader.GetTextA(); + return sRes; } }; @@ -1330,7 +1354,9 @@ bool CFb2File::IsFb2File(const std::wstring& sFile) if (!m_internal->OpenFromFile(sFile)) return false; // Читаем FictionBook - return m_internal->isFictionBook(); + if(!m_internal->isFictionBook()) + return false; + return true; } // Выставление рабочей папки @@ -1339,11 +1365,12 @@ void CFb2File::SetTmpDirectory(const std::wstring& sFolder) // m_internal->m_sTmpFolder = sFolder; } +// Проверяет, соответствует ли fb2 файл формату // sPath - путь к файлу fb2, sDirectory - директория, где формируется и создается docx HRESULT CFb2File::Open(const std::wstring& sPath, const std::wstring& sDirectory, CFb2Params* oParams) { // Копирование шаблона - if (!ExtractTemplate(sDirectory)) + if(!ExtractTemplate(sDirectory)) return S_FALSE; // Начало файла @@ -1375,32 +1402,32 @@ HRESULT CFb2File::Open(const std::wstring& sPath, const std::wstring& sDirectory // Читаем содержание, картинки, сноски bool bNeedContents = false; - if (oParams) + if(oParams) bNeedContents = oParams->bNeedContents; - if (!m_internal->readText(sPath, sMediaDirectory, oContents, oRels, oFootnotes)) + if(!m_internal->readText(sPath, sMediaDirectory, oContents, oRels, oFootnotes)) return S_FALSE; // Переходим в начало - if (!m_internal->m_oLightReader.MoveToStart()) + if(!m_internal->m_oLightReader.MoveToStart()) return S_FALSE; int nDeath = m_internal->m_oLightReader.GetDepth(); - while (m_internal->m_oLightReader.ReadNextSiblingNode(nDeath)) + while(m_internal->m_oLightReader.ReadNextSiblingNode(nDeath)) { std::wstring sName = m_internal->m_oLightReader.GetName(); - if (sName == L"description") + if(sName == L"description") m_internal->readDescription(oDescription); - else if (sName == L"body") + else if(sName == L"body") { bool bNotes = false; - while (m_internal->m_oLightReader.MoveToNextAttribute()) + while(m_internal->m_oLightReader.MoveToNextAttribute()) { - if (m_internal->m_oLightReader.GetName() == L"name" && - m_internal->m_oLightReader.GetText() == L"notes") + if(m_internal->m_oLightReader.GetName() == L"name" && + m_internal->m_oLightReader.GetText() == L"notes") bNotes = true; } m_internal->m_oLightReader.MoveToElement(); - if (bNotes) + if(bNotes) continue; m_internal->readBody(oBuilder); } @@ -1419,7 +1446,7 @@ HRESULT CFb2File::Open(const std::wstring& sPath, const std::wstring& sDirectory // Вставляем description oDocument += oDescription.GetData(); // Вставляем содержание - if (bNeedContents) + if(bNeedContents) oDocument += oContents.GetData(); // Вставляем основное тело oDocument += oBuilder.GetData(); @@ -1472,9 +1499,9 @@ HRESULT CFb2File::Open(const std::wstring& sPath, const std::wstring& sDirectory std::wstring sApplication = NSSystemUtils::GetEnvVariable(NSSystemUtils::gc_EnvApplicationName); if (sApplication.empty()) sApplication = NSSystemUtils::gc_EnvApplicationNameDefault; - #if defined(INTVER) +#if defined(INTVER) std::string sVersion = VALUE2STR(INTVER); - #endif +#endif sApplication += L"/"; sApplication += UTF8_TO_U(sVersion); // Создаем app.xml @@ -1492,302 +1519,13 @@ HRESULT CFb2File::Open(const std::wstring& sPath, const std::wstring& sDirectory // Архивим в docx bool bNeedDocx = false; - if (oParams) + if(oParams) bNeedDocx = oParams->bNeedDocx; - if (bNeedDocx) + if(bNeedDocx) { COfficeUtils oZip; - return oZip.CompressFileOrDirectory(sDirectory, sDirectory + L"/" + NSFile::GetFileName(sPath) + L".docx"); + HRESULT oRes = oZip.CompressFileOrDirectory(sDirectory, sDirectory + L"/" + NSFile::GetFileName(sPath) + L".docx"); + return oRes; } return S_OK; } - -void readLi(NSStringUtils::CStringBuilder& oXml, XmlUtils::CXmlLiteReader& oIndexHtml, std::vector& arrBinary, bool bUl); -void readStream(NSStringUtils::CStringBuilder& oXml, XmlUtils::CXmlLiteReader& oIndexHtml, std::vector& arrBinary, bool bWasP) -{ - int nDeath = oIndexHtml.GetDepth(); - if (oIndexHtml.IsEmptyNode() || !oIndexHtml.ReadNextSiblingNode2(nDeath)) - return; - do - { - std::wstring sName = oIndexHtml.GetName(); - if (sName == L"#text") - oXml.WriteString(oIndexHtml.GetText()); - else if (sName == L"p") - { - if (!bWasP) - oXml.WriteString(L"

"); - readStream(oXml, oIndexHtml, arrBinary, true); - if (!bWasP) - oXml.WriteString(L"

"); - } - else if (sName == L"h1") - { - oXml.WriteString(L"
<p>"); - readStream(oXml, oIndexHtml, arrBinary, true); - oXml.WriteString(L"</p>
"); - } - else if (sName == L"h2") - { - oXml.WriteString(L"
<p>"); - readStream(oXml, oIndexHtml, arrBinary, true); - oXml.WriteString(L"</p>
"); - } - else if (sName == L"h3") - { - oXml.WriteString(L"
<p>"); - readStream(oXml, oIndexHtml, arrBinary, true); - oXml.WriteString(L"</p>
"); - } - else if (sName == L"h4") - { - oXml.WriteString(L"
<p>"); - readStream(oXml, oIndexHtml, arrBinary, true); - oXml.WriteString(L"</p>
"); - } - else if (sName == L"h5") - { - oXml.WriteString(L"
<p>"); - readStream(oXml, oIndexHtml, arrBinary, true); - oXml.WriteString(L"</p>
"); - } - else if (sName == L"h6") - { - oXml.WriteString(L"
<p>"); - readStream(oXml, oIndexHtml, arrBinary, true); - oXml.WriteString(L"</p>
"); - } - else if (sName == L"span") - { - std::wstring sStyle; - while (oIndexHtml.MoveToNextAttribute()) - if (oIndexHtml.GetName() == L"style") - sStyle = oIndexHtml.GetText(); - oIndexHtml.MoveToElement(); - - std::wstring sAlign; - size_t nAlign = sStyle.find(L"vertical-align"); - if (nAlign != std::wstring::npos) - { - nAlign = sStyle.find(L':', nAlign); - size_t nAlignEnd = sStyle.find(L';', nAlign); - sAlign = sStyle.substr(nAlign + 1, (nAlignEnd < sStyle.length() ? nAlignEnd : sStyle.length()) - nAlign); - if (sAlign == L"super") - { - oXml.WriteString(L""); - readStream(oXml, oIndexHtml, arrBinary, bWasP); - oXml.WriteString(L""); - } - else if (sAlign == L"sub") - { - oXml.WriteString(L""); - readStream(oXml, oIndexHtml, arrBinary, bWasP); - oXml.WriteString(L""); - } - else - readStream(oXml, oIndexHtml, arrBinary, bWasP); - } - else - readStream(oXml, oIndexHtml, arrBinary, bWasP); - } - else if (sName == L"s") - { - oXml.WriteString(L""); - readStream(oXml, oIndexHtml, arrBinary, bWasP); - oXml.WriteString(L""); - } - else if (sName == L"i") - { - oXml.WriteString(L""); - readStream(oXml, oIndexHtml, arrBinary, bWasP); - oXml.WriteString(L""); - } - else if (sName == L"b") - { - oXml.WriteString(L""); - readStream(oXml, oIndexHtml, arrBinary, bWasP); - oXml.WriteString(L""); - } - else if (sName == L"table") - { - oXml.WriteString(L""); - readStream(oXml, oIndexHtml, arrBinary, bWasP); - oXml.WriteString(L"
"); - } - else if (sName == L"tr") - { - oXml.WriteString(L""); - readStream(oXml, oIndexHtml, arrBinary, bWasP); - oXml.WriteString(L""); - } - else if (sName == L"th") - { - oXml.WriteString(L""); - readStream(oXml, oIndexHtml, arrBinary, true); - oXml.WriteString(L""); - } - else if (sName == L"td") - { - oXml.WriteString(L""); - readStream(oXml, oIndexHtml, arrBinary, true); - oXml.WriteString(L""); - } - else if (sName == L"a") - { - oIndexHtml.MoveToNextAttribute(); - oXml.WriteString(L"
"); - oIndexHtml.MoveToElement(); - readStream(oXml, oIndexHtml, arrBinary, bWasP); - oXml.WriteString(L""); - } - else if (sName == L"ul") - { - oXml.WriteString(L"
    "); - readLi(oXml, oIndexHtml, arrBinary, true); - oXml.WriteString(L"
"); - } - else if (sName == L"ol") - { - oXml.WriteString(L"
    "); - readLi(oXml, oIndexHtml, arrBinary, false); - oXml.WriteString(L"
"); - } - else if (sName == L"img") - { - std::wstring sBinary; - while (oIndexHtml.MoveToNextAttribute()) - { - if (oIndexHtml.GetName() == L"src") - { - sBinary = oIndexHtml.GetText(); - sBinary.erase(0, sBinary.find(L',') + 2); - arrBinary.push_back(sBinary); - } - } - oIndexHtml.MoveToElement(); - oXml.WriteString(L""); - } - else - readStream(oXml, oIndexHtml, arrBinary, bWasP); - } while (oIndexHtml.ReadNextSiblingNode2(nDeath)); -} - -void readLi(NSStringUtils::CStringBuilder& oXml, XmlUtils::CXmlLiteReader& oIndexHtml, std::vector& arrBinary, bool bUl) -{ - int nNum = 1; - int nDeath = oIndexHtml.GetDepth(); - if (oIndexHtml.IsEmptyNode() || !oIndexHtml.ReadNextSiblingNode2(nDeath)) - return; - do - { - if (oIndexHtml.GetName() == L"li") - { - oXml.WriteString(L"

"); - bUl ? oXml.AddCharSafe(183) : oXml.AddInt(nNum++); - oXml.WriteString(L" "); - readStream(oXml, oIndexHtml, arrBinary, true); - oXml.WriteString(L"

"); - } - } while (oIndexHtml.ReadNextSiblingNode2(nDeath)); -} - -std::wstring GenerateUUID() -{ - std::mt19937 oRand(time(0)); - std::wstringstream sstream; - sstream << std::setfill(L'0') << std::hex << std::setw(8) << (oRand() & 0xffffffff); - sstream << L'-'; - sstream << std::setfill(L'0') << std::hex << std::setw(4) << (oRand() & 0xffff); - sstream << L'-'; - sstream << std::setfill(L'0') << std::hex << std::setw(4) << (oRand() & 0xffff); - sstream << L'-'; - sstream << std::setfill(L'0') << std::hex << std::setw(4) << (oRand() & 0xffff); - sstream << L'-'; - sstream << std::setfill(L'0') << std::hex << std::setw(8) << (oRand() & 0xffffffff); - return sstream.str(); -} - -HRESULT CFb2File::FromHtml(const std::wstring& sHtmlFile, const std::wstring& sCoreFile, const std::wstring& sDst) -{ - NSStringUtils::CStringBuilder oDocument; - oDocument.WriteString(L""); - // description - std::wstring sCoreXml; - if (NSFile::CFileBinary::ReadAllTextUtf8(sCoreFile, sCoreXml)) - { - // title-info - oDocument.WriteString(L""); - std::wstring sBookTitle = NSFile::GetFileName(sDst); - std::wstring sAuthor = sBookTitle; - std::wstring sAnnotation; - std::wstring sKeywords; - - XmlUtils::CXmlLiteReader oCoreReader; - oCoreReader.FromString(sCoreXml); - oCoreReader.ReadNextNode(); - int nDeath = oCoreReader.GetDepth(); - while (oCoreReader.ReadNextSiblingNode(nDeath)) - { - if (oCoreReader.GetNamespacePrefix() == L"dc") - { - std::wstring sName = oCoreReader.GetName(); - if (sName == L"dc:creator") - sAuthor = oCoreReader.GetText2(); - else if (sName == L"dc:title") - sBookTitle = oCoreReader.GetText2(); - else if (sName == L"dc:description") - sAnnotation = oCoreReader.GetText2(); - else if (sName == L"dc:subject") - sKeywords += oCoreReader.GetText2() + L' '; - } - } - - oDocument.WriteString(L"dramaturgy"); - oDocument.WriteString(sAuthor); - oDocument.WriteString(L""); - oDocument.WriteString(sBookTitle); - oDocument.WriteString(L""); - if (!sAnnotation.empty()) - oDocument.WriteString(L"

" + sAnnotation + L"

"); - if (!sKeywords.empty()) - oDocument.WriteString(L"" + sKeywords + L""); - oDocument.WriteString(L"en
"); - // document-info - oDocument.WriteString(sAuthor); - oDocument.WriteString(L""); - oDocument.WriteString(GenerateUUID()); - oDocument.WriteString(L"1.0"); - } - // body - oDocument.WriteString(L"
"); - std::string sContent; - NSFile::CFileBinary::ReadAllTextUtf8A(sHtmlFile, sContent);; - XmlUtils::CXmlLiteReader oIndexHtml; - std::vector arrBinary; - if (oIndexHtml.FromString(htmlToXhtml(sContent))) - { - oIndexHtml.ReadNextNode(); // html - int nDepth = oIndexHtml.GetDepth(); - oIndexHtml.ReadNextSiblingNode(nDepth); // head - oIndexHtml.ReadNextSiblingNode(nDepth); // body - readStream(oDocument, oIndexHtml, arrBinary, false); - } - oDocument.WriteString(L"
"); - // binary - for (size_t i = 0; i < arrBinary.size(); i++) - { - oDocument.WriteString(L""); - oDocument.WriteString(arrBinary[i]); - oDocument.WriteString(L""); - } - oDocument.WriteString(L"
"); - // Запись в файл - NSFile::CFileBinary oWriter; - if (oWriter.CreateFileW(sDst)) - { - oWriter.WriteStringUTF8(oDocument.GetData()); - oWriter.CloseFile(); - } - return S_OK; - -} diff --git a/Fb2File/Fb2File.h b/Fb2File/Fb2File.h index b277d6a35d..cda589065d 100644 --- a/Fb2File/Fb2File.h +++ b/Fb2File/Fb2File.h @@ -16,7 +16,11 @@ struct CFb2Params bool bNeedDocx; bool bNeedContents; - CFb2Params() : bNeedDocx(false), bNeedContents(false) {} + CFb2Params() + { + bNeedDocx = false; + bNeedContents = false; + } }; class CFb2File_Private; @@ -31,7 +35,6 @@ public: bool IsFb2File(const std::wstring& sFile); void SetTmpDirectory(const std::wstring& sFolder); HRESULT Open(const std::wstring& sPath, const std::wstring& sDirectory, CFb2Params* oParams = NULL); - HRESULT FromHtml(const std::wstring& sHtmlFile, const std::wstring& sCoreFile, const std::wstring& sDst); }; #endif // _FB2FILE_FB2FILE_H diff --git a/Fb2File/Fb2File.pro b/Fb2File/Fb2File.pro index 1dd6a8518d..6cbfe712c1 100644 --- a/Fb2File/Fb2File.pro +++ b/Fb2File/Fb2File.pro @@ -7,6 +7,7 @@ TEMPLATE = lib CONFIG += shared CONFIG += plugin + CONFIG += core_static_link_libstd DEFINES += FB2FILE_USE_DYNAMIC_LIBRARY @@ -15,8 +16,6 @@ CORE_ROOT_DIR = $$PWD/.. PWD_ROOT_DIR = $$PWD include($$CORE_ROOT_DIR/Common/base.pri) -include($$CORE_ROOT_DIR/Common/3dParty/html/gumbo.pri) - ADD_DEPENDENCY(kernel, UnicodeConverter, graphics) SOURCES += Fb2File.cpp diff --git a/Fb2File/test/main.cpp b/Fb2File/test/main.cpp index 1e9a5995ce..ca79eade5d 100644 --- a/Fb2File/test/main.cpp +++ b/Fb2File/test/main.cpp @@ -9,15 +9,14 @@ void getDirectories(const std::wstring& sDirectory, std::vector& arrDirectory) { arrDirectory.push_back(sDirectory); - for (const std::wstring& sT : NSDirectory::GetDirectories(sDirectory)) + for(const std::wstring& sT : NSDirectory::GetDirectories(sDirectory)) getDirectories(sT, arrDirectory); } int main() { bool bBatchMode = false; - bool bFromHtml = false; - if (bBatchMode) + if(bBatchMode) { // Директория файлов std::wstring sDirectory = NSFile::GetProcessDirectory() + L"/../../../examples/fb2"; @@ -38,46 +37,40 @@ int main() int nErrorCol = 0; std::vector arrError; - for (std::wstring sD : arrDirectory) + for(const std::wstring& sD : arrDirectory) { - if (bFromHtml) - { - } - else - { - std::vector arrFiles = NSDirectory::GetFiles(sD); + std::vector arrFiles = NSDirectory::GetFiles(sD); - // Директория, где будем создавать docx - size_t nPos = sD.find(L"/fb2"); - sD.insert(nPos + 4, L"-res"); - NSDirectory::DeleteDirectory(sD); - NSDirectory::CreateDirectory(sD); + // Директория, где будем создавать docx + size_t nPos = sD.find(L"/fb2"); + std::wstring sOutputDirectory = sD.insert(nPos + 4, L"-res"); + NSDirectory::DeleteDirectory(sOutputDirectory); + NSDirectory::CreateDirectory(sOutputDirectory); - for(const std::wstring& sFile : arrFiles) + for(const std::wstring& sFile : arrFiles) + { + CFb2File oFile; + std::wstring sFileName = NSFile::GetFileName(sFile); + std::wcout << sFileName << std::endl; + if(!oFile.IsFb2File(sFile)) { - CFb2File oFile; - std::wstring sFileName = NSFile::GetFileName(sFile); - std::wcout << sFileName << std::endl; - if(!oFile.IsFb2File(sFile)) - { - nErrorCol++; - arrError.push_back(sFileName); - std::cout << "This isn't a fb2 file" << std::endl; - continue; - } + nErrorCol++; + arrError.push_back(sFileName); + std::cout << "This isn't a fb2 file" << std::endl; + continue; + } - if(oFile.Open(sFile, sTmp, &oParams) == S_OK) - { - std::cout << "Success" << std::endl; - oZip.CompressFileOrDirectory(sTmp, sD + L"/" + sFileName + L".docx"); - NSDirectory::DeleteDirectory(sTmp + L"/word/media"); - } - else - { - nErrorCol++; - arrError.push_back(sFileName); - std::cout << "Failure" << std::endl; - } + if(oFile.Open(sFile, sTmp, &oParams) == S_OK) + { + std::cout << "Success" << std::endl; + oZip.CompressFileOrDirectory(sTmp, sOutputDirectory + L"/" + sFileName + L".docx"); + NSDirectory::DeleteDirectory(sTmp + L"/word/media"); + } + else + { + nErrorCol++; + arrError.push_back(sFileName); + std::cout << "Failure" << std::endl; } } } @@ -91,21 +84,13 @@ int main() CFb2File oFile; // Файл, который открываем - std::wstring sFile = NSFile::GetProcessDirectory() + L"/../../../examples/8-sezon-groz.fb2"; + std::wstring sFile = NSFile::GetProcessDirectory() + L"/../../../examples/test2.fb2"; // Директория, где будем создавать docx std::wstring sOutputDirectory = NSFile::GetProcessDirectory() + L"/res"; NSDirectory::DeleteDirectory(sOutputDirectory); NSDirectory::CreateDirectory(sOutputDirectory); - - if (bFromHtml) - { - sFile = NSFile::GetProcessDirectory() + L"/../../../examples/test3"; - oFile.FromHtml(sFile, sOutputDirectory + L"/res.fb2"); - return 0; - } - if (!oFile.IsFb2File(sFile)) { std::cout << "This isn't a fb2 file" << std::endl; @@ -116,7 +101,7 @@ int main() oParams.bNeedDocx = true; oParams.bNeedContents = true; - std::cout << (oFile.Open(sFile, sOutputDirectory, &oParams) == S_OK ? "Success" : "Failure") << std::endl; + std::cout << oFile.Open(sFile, sOutputDirectory, &oParams) == S_OK ? "Success" : "Failure" << std::endl; } std::cout << "THE END" << std::endl; return 0; diff --git a/HtmlFile2/htmlfile2.cpp b/HtmlFile2/htmlfile2.cpp index 431e43f286..6b4fcd6316 100644 --- a/HtmlFile2/htmlfile2.cpp +++ b/HtmlFile2/htmlfile2.cpp @@ -31,13 +31,7 @@ #define VALUE2STR(x) VALUE_TO_STRING(x) #endif -std::wstring rStyle = L" a area b strong bdo bdi big br center cite dfn em i var code kbd samp tt del s font img ins u mark q rt sup small sub svg input basefont button label data object noscript output abbr time ruby progress hgroup meter span acronym "; - -//struct CTree -//{ -// NSCSS::CNode m_oNode; -// std::vector m_arrChild; -//}; +std::wstring rStyle = L"a area b strong bdo bdi big br center cite dfn em i var code kbd samp tt del s font img ins u mark q rt sup small sub svg input basefont button label data object noscript output abbr time ruby progress hgroup meter span acronym"; // Ячейка таблицы struct CTc @@ -82,8 +76,6 @@ public: std::wstring m_sDst; // Директория назначения std::wstring m_sBase; // Полный базовый адрес - NSCSS::CTree m_oTree; // Дерево body html-файла - private: int m_nImageId; // ID картинки int m_nFootnoteId; // ID сноски @@ -96,6 +88,7 @@ private: NSStringUtils::CStringBuilder m_oDocXml; // document.xml NSStringUtils::CStringBuilder m_oNoteXml; // footnotes.xml NSStringUtils::CStringBuilder m_oNumberXml; // numbering.xml + public: CHtmlFile2_Private() : m_nImageId(1), m_nFootnoteId(1), m_nHyperlinkId(1), m_nCrossId(1), m_nNumberingId(1) {} @@ -394,18 +387,7 @@ public: } if(NSFile::GetFileExtention(sSrc) != L"xhtml") - { - /* - std::wstring sRes = htmlToXhtml(sFileContent); - NSFile::CFileBinary oWriter; - if (oWriter.CreateFileW(m_sTmp + L"/res.html")) - { - oWriter.WriteStringUTF8(sRes); - oWriter.CloseFile(); - } - */ return m_oLightReader.FromString(htmlToXhtml(sFileContent)); - } return m_oLightReader.FromStringA(sFileContent); } @@ -428,114 +410,41 @@ public: while(m_oLightReader.ReadNextSiblingNode(nDeath)) { std::wstring sName = m_oLightReader.GetName(); - - if(sName == L"body") - readStyle2(m_oTree); - else + // Стиль по ссылке + if(sName == L"link") { - // Стиль по ссылке - if(sName == L"link") + while(m_oLightReader.MoveToNextAttribute()) { - while(m_oLightReader.MoveToNextAttribute()) + if(m_oLightReader.GetName() != L"href") + continue; + std::wstring sRef = m_oLightReader.GetText(); + if(NSFile::GetFileExtention(sRef) != L"css") + continue; + std::wstring sFName = NSFile::GetFileName(sRef); + // Стиль в сети + if(sRef.substr(0, 4) == L"http") { - if(m_oLightReader.GetName() != L"href") - continue; - std::wstring sRef = m_oLightReader.GetText(); - if(NSFile::GetFileExtention(sRef) != L"css") - continue; - std::wstring sFName = NSFile::GetFileName(sRef); - // Стиль в сети - if(sRef.substr(0, 4) == L"http") + sFName = m_sTmp + L'/' + sFName; + CFileDownloader oDownloadStyle(sRef, false); + oDownloadStyle.SetFilePath(sFName); + if(oDownloadStyle.DownloadSync()) { - sFName = m_sTmp + L'/' + sFName; - CFileDownloader oDownloadStyle(sRef, false); - oDownloadStyle.SetFilePath(sFName); - if(oDownloadStyle.DownloadSync()) - { - m_oStylesCalculator.AddStylesFromFile(sFName); - NSFile::CFileBinary::Remove(sFName); - } - } - else - { - m_oStylesCalculator.AddStylesFromFile(m_sSrc + L'/' + sFName); - m_oStylesCalculator.AddStylesFromFile(m_sSrc + L'/' + sRef); + m_oStylesCalculator.AddStylesFromFile(sFName); + NSFile::CFileBinary::Remove(sFName); } } - m_oLightReader.MoveToElement(); - } - // тэг style содержит стили для styles.xml - else if(sName == L"style") - m_oStylesCalculator.AddStyles(m_oLightReader.GetText2()); - else - readStyle(); - } - } - } - - void readStyle2(NSCSS::CTree& oTree) - { - std::wstring sName = m_oLightReader.GetName(); - // Стиль по ссылке - if(sName == L"link") - { - while(m_oLightReader.MoveToNextAttribute()) - { - if(m_oLightReader.GetName() != L"href") - continue; - std::wstring sRef = m_oLightReader.GetText(); - if(NSFile::GetFileExtention(sRef) != L"css") - continue; - std::wstring sFName = NSFile::GetFileName(sRef); - // Стиль в сети - if(sRef.substr(0, 4) == L"http") - { - sFName = m_sTmp + L'/' + sFName; - CFileDownloader oDownloadStyle(sRef, false); - oDownloadStyle.SetFilePath(sFName); - if(oDownloadStyle.DownloadSync()) + else { - m_oStylesCalculator.AddStylesFromFile(sFName); - NSFile::CFileBinary::Remove(sFName); + m_oStylesCalculator.AddStylesFromFile(m_sSrc + L'/' + sFName); + m_oStylesCalculator.AddStylesFromFile(m_sSrc + L'/' + sRef); } } - else - { - m_oStylesCalculator.AddStylesFromFile(m_sSrc + L'/' + sFName); - m_oStylesCalculator.AddStylesFromFile(m_sSrc + L'/' + sRef); - } - } - m_oLightReader.MoveToElement(); - } - // тэг style содержит стили для styles.xml - else if(sName == L"style") - m_oStylesCalculator.AddStyles(m_oLightReader.GetText2()); - - oTree.m_oNode.m_sName = sName; - // Стиль по атрибуту - while(m_oLightReader.MoveToNextAttribute()) - { - std::wstring sNameA = m_oLightReader.GetName(); - if(sNameA == L"class") - oTree.m_oNode.m_sClass = m_oLightReader.GetText(); - else if(sNameA == L"id") - oTree.m_oNode.m_sId = m_oLightReader.GetText(); - else if(sNameA == L"style") - oTree.m_oNode.m_sStyle += m_oLightReader.GetText(); - else if(sNameA == L"align") - oTree.m_oNode.m_sStyle += L"; text-align: " + m_oLightReader.GetText() + L";"; - } - m_oLightReader.MoveToElement(); - - int nDeath = m_oLightReader.GetDepth(); - while(m_oLightReader.ReadNextSiblingNode(nDeath)) - { - if(!m_oLightReader.IsEmptyNode()) - { - NSCSS::CTree oChildTree; - readStyle2(oChildTree); - oTree.m_arrChild.push_back(oChildTree); + m_oLightReader.MoveToElement(); } + // тэг style содержит стили для styles.xml + else if(sName == L"style") + m_oStylesCalculator.AddStyles(m_oLightReader.GetText2()); + readStyle(); } } @@ -581,9 +490,9 @@ private: return sNote; } - std::wstring GetStyle(const NSCSS::CCompiledStyle& oStyle, bool bP) + std::wstring GetStyle(const std::vector& sSelectors, bool bP) { -// NSCSS::CCompiledStyle oStyle = m_oStylesCalculator.GetCompiledStyle(sSelectors); + NSCSS::CCompiledStyle oStyle = m_oStylesCalculator.GetCompiledStyle(sSelectors); bP ? m_oXmlStyle.WritePStyle(oStyle) : m_oXmlStyle.WriteRStyle(oStyle); m_oStylesXml.WriteString(m_oXmlStyle.GetStyle()); return m_oXmlStyle.GetIdAndClear(); @@ -621,7 +530,6 @@ private: m_oDocXml.WriteString(sCrossId); m_oDocXml.WriteString(L"\"/>"); */ - bool bWasP = true; readStream(&m_oDocXml, sSelectors, { false, false, -1, L"", L"" }, bWasP); } @@ -727,7 +635,7 @@ private: wrP(oXml, sSelectors, oTS, bWasP); oXml->WriteString(L""); NSCSS::CCompiledStyle oStyle = m_oStylesCalculator.GetCompiledStyle(sSelectors); - if(oStyle.m_pText.GetAlign() == L"both") + if(oStyle.GetTextAlign() == L"justify") oXml->WriteString(L""); oXml->WriteString(L""); } @@ -932,8 +840,6 @@ private: nHyp++; } } - if(bWasP) - oXml->WriteString(L""); oXml->WriteString(L""); readTable(oXml, sSelectors, oTS, bWasP); oXml->WriteString(L""); @@ -972,7 +878,7 @@ private: return true; } - void readTr (NSStringUtils::CStringBuilder* oXml, std::vector& sSelectors, const CTextSettings& oTS, bool& bWasP, bool bNeedBorder) + void readTr (NSStringUtils::CStringBuilder* oXml, std::vector& sSelectors, const CTextSettings& oTS, bool& bWasP) { std::vector mTable; int nDeath = m_oLightReader.GetDepth(); @@ -1012,12 +918,7 @@ private: std::vector::iterator it2 = std::find_if(mTable.begin(), mTable.end(), [j] (const CTc& item){ return item.i == 0 && item.j == j; }); while(it1 != mTable.end() || it2 != mTable.end()) { - oXml->WriteString(L""); - if(bNeedBorder) - oXml->WriteString(L""); - else - oXml->WriteString(L""); - oXml->WriteString(L"WriteString(L"sGridSpan : it2->sGridSpan); oXml->WriteString(sCol); oXml->WriteString(L"\"/>"); @@ -1026,11 +927,7 @@ private: it2 = std::find_if(mTable.begin(), mTable.end(), [j] (const CTc& item){ return item.i == 0 && item.j == j; }); } - oXml->WriteString(L""); - if (bNeedBorder) - oXml->WriteString(L""); - else - oXml->WriteString(L""); + oXml->WriteString(L""); if(nRowspan != 1) { oXml->WriteString(L""); @@ -1075,12 +972,7 @@ private: it2 = std::find_if(mTable.begin(), mTable.end(), [j] (const CTc& item){ return item.i == 0 && item.j == j; }); while(it1 != mTable.end() || it2 != mTable.end()) { - oXml->WriteString(L""); - if(bNeedBorder) - oXml->WriteString(L""); - else - oXml->WriteString(L""); - oXml->WriteString(L"WriteString(L"sGridSpan : it2->sGridSpan); oXml->WriteString(sCol); oXml->WriteString(L"\"/>"); @@ -1099,14 +991,6 @@ private: if(m_oLightReader.IsEmptyNode()) return; - bool bNeedBorder = false; - while (m_oLightReader.MoveToNextAttribute()) - { - if (m_oLightReader.GetName() == L"border") - bNeedBorder = true; - } - m_oLightReader.MoveToElement(); - NSStringUtils::CStringBuilder oHead; NSStringUtils::CStringBuilder oBody; NSStringUtils::CStringBuilder oFoot; @@ -1138,31 +1022,23 @@ private: bWasP = false; } if(sName == L"thead") - readTr(&oHead, sSelectors, oTS, bWasP, bNeedBorder); + readTr(&oHead, sSelectors, oTS, bWasP); else if(sName == L"tbody") - readTr(&oBody, sSelectors, oTS, bWasP, bNeedBorder); + readTr(&oBody, sSelectors, oTS, bWasP); else if(sName == L"tfoot") - readTr(&oFoot, sSelectors, oTS, bWasP, bNeedBorder); + readTr(&oFoot, sSelectors, oTS, bWasP); sSelectors.pop_back(); } // Начало таблицы - oXml->WriteString(L""); - NSCSS::CNode oLast = sSelectors.back(); - sSelectors.pop_back(); - NSCSS::CCompiledStyle oStyle = m_oStylesCalculator.GetCompiledStyle(sSelectors); - std::wstring sAlign = oStyle.m_pText.GetAlign(); - if(sAlign == L"left" || sAlign == L"center" || sAlign == L"right" || sAlign == L"both") - oXml->WriteString(L""); - oXml->WriteString(L""); - sSelectors.push_back(oLast); + oXml->WriteString(L""); // Конец таблицы oXml->WriteString(oHead.GetData()); oXml->WriteString(oBody.GetData()); oXml->WriteString(oFoot.GetData()); oXml->WriteString(L""); // Пустая строка после таблицы, чтобы следующий текст не приклеивался - // oXml->WriteString(L""); + oXml->WriteString(L""); bWasP = false; } @@ -1472,7 +1348,7 @@ private: size_t i = 0; while(i != sSelectors.size()) { - if(rStyle.find(L' ' + sSelectors[i].m_sName + L' ') != std::wstring::npos) + if(rStyle.find(sSelectors[i].m_sName) != std::wstring::npos) { temporary.push_back(std::make_pair(i, sSelectors[i])); sSelectors.erase(sSelectors.begin() + i); @@ -1480,23 +1356,15 @@ private: else i++; } - NSCSS::CCompiledStyle oStyleSetting = m_oStylesCalculator.GetCompiledStyle(sSelectors, true); - NSCSS::CCompiledStyle oStyle = m_oStylesCalculator.GetCompiledStyle(sSelectors); - - NSCSS::CCompiledStyle::StyleEquation(oStyle, oStyleSetting); - - std::wstring sPStyle = GetStyle(oStyle, true); - - m_oXmlStyle.WriteLitePStyle(oStyleSetting); - const std::wstring sPSettings = m_oXmlStyle.GetStyle(); - m_oXmlStyle.Clear(); + std::wstring sPStyle = GetStyle(sSelectors, true); + for(int i = temporary.size() - 1; i >= 0; i--) sSelectors.insert(sSelectors.begin() + temporary[i].first, temporary[i].second); oXml->WriteString(sPStyle); oXml->WriteString(L"\"/>"); - oXml->WriteString(oTS.sPStyle + L' ' + sPSettings); + oXml->WriteString(oTS.sPStyle); oXml->WriteString(L""); bWasP = false; return sPStyle; @@ -1504,22 +1372,11 @@ private: std::wstring wrR(NSStringUtils::CStringBuilder* oXml, std::vector& sSelectors, const CTextSettings& oTS) { - NSCSS::CCompiledStyle oStyleSetting = m_oStylesCalculator.GetCompiledStyle(sSelectors, true); - NSCSS::CCompiledStyle oStyle = m_oStylesCalculator.GetCompiledStyle(sSelectors); - - NSCSS::CCompiledStyle::StyleEquation(oStyle, oStyleSetting); - - std::wstring sRStyle = GetStyle(oStyle, false); - - m_oXmlStyle.WriteLiteRStyle(oStyleSetting); - const std::wstring sRSettings = m_oXmlStyle.GetStyle(); - m_oXmlStyle.Clear(); - oXml->WriteString(L"WriteString(sRStyle); oXml->WriteString(L"\"/>"); - - oXml->WriteString(oTS.sRStyle + L' ' + sRSettings); + oXml->WriteString(oTS.sRStyle); oXml->WriteString(L""); return sRStyle; } @@ -1733,8 +1590,6 @@ HRESULT CHtmlFile2::OpenHtml(const std::wstring& sSrc, const std::wstring& sDst, m_internal->CreateDocxEmpty(oParams); m_internal->readStyle(); - m_internal->m_oStylesCalculator.SetBodyTree(m_internal->m_oTree); - // Переходим в начало if(!m_internal->m_oLightReader.MoveToStart()) return S_FALSE; @@ -1757,8 +1612,6 @@ HRESULT CHtmlFile2::OpenMht(const std::wstring& sSrc, const std::wstring& sDst, m_internal->CreateDocxEmpty(oParams); m_internal->readStyle(); - m_internal->m_oStylesCalculator.SetBodyTree(m_internal->m_oTree); - // Переходим в начало if(!m_internal->m_oLightReader.MoveToStart()) return S_FALSE; @@ -1786,8 +1639,6 @@ HRESULT CHtmlFile2::OpenBatchHtml(const std::vector& sSrc, const s continue; m_internal->readStyle(); - m_internal->m_oStylesCalculator.SetBodyTree(m_internal->m_oTree); - // Переходим в начало if(m_internal->m_oLightReader.MoveToStart()) { diff --git a/Makefile b/Makefile index ef7dfa685b..cbcf30b568 100644 --- a/Makefile +++ b/Makefile @@ -326,7 +326,6 @@ $(VIDEOPLAYERLIB): $(VIDEOPLAYERLIB_DEP) qmake -r $< $(ARCHIVE) : - mkdir -p $(dir $@) $(AR) $@ $(ARTIFACTS) clean: diff --git a/OfficeCryptReader/source/ECMACryptFile.cpp b/OfficeCryptReader/source/ECMACryptFile.cpp index a730c51066..0d97a9c95a 100644 --- a/OfficeCryptReader/source/ECMACryptFile.cpp +++ b/OfficeCryptReader/source/ECMACryptFile.cpp @@ -648,18 +648,18 @@ bool ECMACryptFile::EncryptOfficeFile(const std::wstring &file_name_inp, const s std::wstring sApplication = NSSystemUtils::GetEnvVariable(NSSystemUtils::gc_EnvMethodEncrypt); - //if (sApplication == L"Weak") - //{ - // cryptData.bAgile = false; - // cryptData.cipherAlgorithm = CRYPT_METHOD::DES_ECB; - // cryptData.hashAlgorithm = CRYPT_METHOD::SHA1; - // cryptData.keySize = 0x08; - // cryptData.hashSize = 0x14; - // cryptData.blockSize = 0x10; - // cryptData.saltSize = 0x10; - // cryptData.spinCount = 50000; - //} - //else + if (sApplication == L"Weak") + { + cryptData.bAgile = false; + cryptData.cipherAlgorithm = CRYPT_METHOD::DES_ECB; + cryptData.hashAlgorithm = CRYPT_METHOD::SHA1; + cryptData.keySize = 0x08; + cryptData.hashSize = 0x14; + cryptData.blockSize = 0x10; + cryptData.saltSize = 0x10; + cryptData.spinCount = 50000; + } + else { cryptData.bAgile = true; cryptData.cipherAlgorithm = CRYPT_METHOD::AES_CBC; diff --git a/PdfWriter/OnlineOfficeBinToPdf.cpp b/PdfWriter/OnlineOfficeBinToPdf.cpp index 44a4f8cf61..ffe1e32856 100644 --- a/PdfWriter/OnlineOfficeBinToPdf.cpp +++ b/PdfWriter/OnlineOfficeBinToPdf.cpp @@ -94,7 +94,6 @@ namespace NSOnlineOfficeBinToPdf oFrame.put_Width(nSize); oFrame.put_Height(nSize); oFrame.put_Stride(4 * nSize); - oFrame.put_IsRGBA(true); oFrame.SaveFile(wsBase64TempFile, 4); // PNG wsTempString = wsBase64TempFile; } diff --git a/X2tConverter/build/Android/libx2t/build.gradle b/X2tConverter/build/Android/libx2t/build.gradle index 1c17ef7dd9..5e21b704b9 100644 --- a/X2tConverter/build/Android/libx2t/build.gradle +++ b/X2tConverter/build/Android/libx2t/build.gradle @@ -1,16 +1,17 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' android { - buildToolsVersion '30.0.3' + buildToolsVersion '30.0.2' compileSdkVersion 30 ndkVersion = NDK_VERSION defaultConfig { minSdkVersion 23 - targetSdkVersion 30 + targetSdkVersion 29 versionCode 1 versionName '1.0' diff --git a/X2tConverter/build/Android/libx2t/src/main/java/lib/x2t/X2t.kt b/X2tConverter/build/Android/libx2t/src/main/java/lib/x2t/X2t.kt index c947ee1a1a..950c3754dd 100644 --- a/X2tConverter/build/Android/libx2t/src/main/java/lib/x2t/X2t.kt +++ b/X2tConverter/build/Android/libx2t/src/main/java/lib/x2t/X2t.kt @@ -238,14 +238,14 @@ class X2t private constructor() { FileUtils.getCache(context, mConvertFileName, mConvertFolderName)?.let { cache -> result.to = mInputParams.to ?: cache.to - result.root = File(result.to ?: "").parent + result.root = File(result.to).parent mInputParams.to = mInputParams.to ?: cache.to mInputParams.temp = mInputParams.temp ?: cache.temp mInputParams.themes = mInputParams.themes ?: "${cache.root}/themes" mInputParams.xml = mInputParams.xml ?: "${cache.temp}/param.xml" - if (File(mInputParams.to ?: "").exists()) { + if (File(mInputParams.to).exists()) { if (mIsOverwrite) { FileUtils.deletePath(result.to!!) } else { @@ -382,16 +382,16 @@ class X2t private constructor() { fileOutputStream.close() } catch (e: FileNotFoundException) { - e.printStackTrace() + e.printStackTrace(); } catch (e: IllegalArgumentException) { - e.printStackTrace() + e.printStackTrace(); } catch (e: IllegalStateException) { - e.printStackTrace() + e.printStackTrace(); } catch (e: IOException) { - e.printStackTrace() + e.printStackTrace(); } } diff --git a/X2tConverter/src/ASCConverters.cpp b/X2tConverter/src/ASCConverters.cpp index 0addae45e9..ba6bc2a6f9 100644 --- a/X2tConverter/src/ASCConverters.cpp +++ b/X2tConverter/src/ASCConverters.cpp @@ -1500,144 +1500,30 @@ namespace NExtractTools return nRes; } - // doct_bin -> epub - _UINT32 doct_bin2epub(NSDoctRenderer::DoctRendererFormat::FormatFile eFromType, const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, bool bPaid, const std::wstring &sThemeDir, InputParams& params) - { - _UINT32 nRes = 0; - NSDoctRenderer::DoctRendererFormat::FormatFile eToType = NSDoctRenderer::DoctRendererFormat::FormatFile::HTML; - std::wstring sFileFromDir = NSDirectory::GetFolderPath(sFrom); - std::wstring sFileToDir = NSDirectory::GetFolderPath(sTo); - std::wstring sImagesDirectory = sFileFromDir + FILE_SEPARATOR_STR + L"media"; - std::wstring sHtmlFile = sFileFromDir + FILE_SEPARATOR_STR + L"index.html"; - NSDoctRenderer::CDoctrenderer oDoctRenderer(NULL != params.m_sAllFontsPath ? *params.m_sAllFontsPath : L""); - std::wstring sXml = getDoctXml(eFromType, eToType, sFileFromDir, sHtmlFile, sImagesDirectory, sThemeDir, -1, L"", params); - std::wstring sResult; - oDoctRenderer.Execute(sXml, sResult); - if (sResult.find(L"error") != std::wstring::npos) - { - std::wcerr << L"DoctRenderer:" << sResult << std::endl; - nRes = AVS_FILEUTILS_ERROR_CONVERT; - } - else - { - std::wstring sDocxDir = sTemp + FILE_SEPARATOR_STR + _T("docx_unpacked"); - NSDirectory::CreateDirectory(sDocxDir); - nRes = doct_bin2docx_dir(sFrom, sTo, sDocxDir, false, sThemeDir, params); - if(SUCCEEDED_X2T(nRes)) - { - CEpubFile oFile; - std::wstring sEpubTemp = sTemp + FILE_SEPARATOR_STR + L"tmp"; - NSDirectory::CreateDirectory(sEpubTemp); - oFile.SetTempDirectory(sEpubTemp); - if (S_FALSE == oFile.FromHtml(sHtmlFile, sDocxDir + FILE_SEPARATOR_STR + L"docProps" + FILE_SEPARATOR_STR + L"core.xml", sTo)) - nRes = AVS_FILEUTILS_ERROR_CONVERT; - } - } - return nRes; - } - // doct_bin -> fb2 - _UINT32 doct_bin2fb(NSDoctRenderer::DoctRendererFormat::FormatFile eFromType, const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, bool bPaid, const std::wstring &sThemeDir, InputParams& params) - { - _UINT32 nRes = 0; - NSDoctRenderer::DoctRendererFormat::FormatFile eToType = NSDoctRenderer::DoctRendererFormat::FormatFile::HTML; - std::wstring sFileFromDir = NSDirectory::GetFolderPath(sFrom); - std::wstring sFileToDir = NSDirectory::GetFolderPath(sTo); - std::wstring sImagesDirectory = sFileFromDir + FILE_SEPARATOR_STR + L"media"; - std::wstring sHtmlFile = sFileFromDir + FILE_SEPARATOR_STR + L"index.html"; - NSDoctRenderer::CDoctrenderer oDoctRenderer(NULL != params.m_sAllFontsPath ? *params.m_sAllFontsPath : L""); - std::wstring sXml = getDoctXml(eFromType, eToType, sFileFromDir, sHtmlFile, sImagesDirectory, sThemeDir, -1, L"", params); - std::wstring sResult; - oDoctRenderer.Execute(sXml, sResult); - if (sResult.find(L"error") != std::wstring::npos) - { - std::wcerr << L"DoctRenderer:" << sResult << std::endl; - nRes = AVS_FILEUTILS_ERROR_CONVERT; - } - else - { - std::wstring sDocxDir = sTemp + FILE_SEPARATOR_STR + _T("docx_unpacked"); - NSDirectory::CreateDirectory(sDocxDir); - nRes = doct_bin2docx_dir(sFrom, sTo, sDocxDir, false, sThemeDir, params); - if(SUCCEEDED_X2T(nRes)) - { - CFb2File fb2File; - fb2File.SetTmpDirectory(sTemp); - if (S_FALSE == fb2File.FromHtml(sHtmlFile, sDocxDir + FILE_SEPARATOR_STR + L"docProps" + FILE_SEPARATOR_STR + L"core.xml", sTo)) - nRes = AVS_FILEUTILS_ERROR_CONVERT; - } - } - return nRes; - } - // doct_bin -> html - _UINT32 doct_bin2html(NSDoctRenderer::DoctRendererFormat::FormatFile eFromType, const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, bool bPaid, const std::wstring &sThemeDir, InputParams& params) - { - _UINT32 nRes = 0; - NSDoctRenderer::DoctRendererFormat::FormatFile eToType = NSDoctRenderer::DoctRendererFormat::FormatFile::HTML; - std::wstring sFileFromDir = NSDirectory::GetFolderPath(sFrom); - std::wstring sImagesDirectory = sFileFromDir + FILE_SEPARATOR_STR + L"media"; - std::wstring sHtmlFile = sFileFromDir + FILE_SEPARATOR_STR + L"index.html"; - NSDoctRenderer::CDoctrenderer oDoctRenderer(NULL != params.m_sAllFontsPath ? *params.m_sAllFontsPath : L""); - std::wstring sXml = getDoctXml(eFromType, eToType, sFileFromDir, sHtmlFile, sImagesDirectory, sThemeDir, -1, L"", params); - std::wstring sResult; - oDoctRenderer.Execute(sXml, sResult); - if (sResult.find(L"error") != std::wstring::npos) - { - std::wcerr << L"DoctRenderer:" << sResult << std::endl; - nRes = AVS_FILEUTILS_ERROR_CONVERT; - } - else if (!NSFile::CFileBinary::Copy(sHtmlFile, sTo)) - nRes = AVS_FILEUTILS_ERROR_CONVERT; - return nRes; - } - // doct_bin -> html_zip - _UINT32 doct_bin2html_zip(NSDoctRenderer::DoctRendererFormat::FormatFile eFromType, const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, bool bPaid, const std::wstring &sThemeDir, InputParams& params) - { - _UINT32 nRes = 0; - NSDoctRenderer::DoctRendererFormat::FormatFile eToType = NSDoctRenderer::DoctRendererFormat::FormatFile::HTML; - std::wstring sFileFromDir = NSDirectory::GetFolderPath(sFrom); - std::wstring sImagesDirectory = sFileFromDir + FILE_SEPARATOR_STR + L"media"; - std::wstring sHtmlFile = sFileFromDir + FILE_SEPARATOR_STR + L"index.html"; - NSDoctRenderer::CDoctrenderer oDoctRenderer(NULL != params.m_sAllFontsPath ? *params.m_sAllFontsPath : L""); - std::wstring sXml = getDoctXml(eFromType, eToType, sFileFromDir, sHtmlFile, sImagesDirectory, sThemeDir, -1, L"", params); - std::wstring sResult; - oDoctRenderer.Execute(sXml, sResult); - if (sResult.find(L"error") != std::wstring::npos) - { - std::wcerr << L"DoctRenderer:" << sResult << std::endl; - nRes = AVS_FILEUTILS_ERROR_CONVERT; - } - else - { - COfficeUtils oZip; - if (S_FALSE == oZip.CompressFileOrDirectory(sHtmlFile, sTo)) - nRes = AVS_FILEUTILS_ERROR_CONVERT; - } - return nRes; - } - // doct_bin -> pdf + //doct_bin -> pdf _UINT32 doct_bin2pdf(NSDoctRenderer::DoctRendererFormat::FormatFile eFromType, const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, bool bPaid, const std::wstring &sThemeDir, InputParams& params) - { - _UINT32 nRes = 0; - NSDoctRenderer::DoctRendererFormat::FormatFile eToType = NSDoctRenderer::DoctRendererFormat::FormatFile::PDF; - std::wstring sTFileDir = NSDirectory::GetFolderPath(sFrom); - std::wstring sImagesDirectory = sTFileDir + FILE_SEPARATOR_STR + _T("media"); - std::wstring sPdfBinFile = sTFileDir + FILE_SEPARATOR_STR + _T("pdf.bin"); - NSDoctRenderer::CDoctrenderer oDoctRenderer(NULL != params.m_sAllFontsPath ? *params.m_sAllFontsPath : _T("")); - std::wstring sXml = getDoctXml(eFromType, eToType, sTFileDir, sPdfBinFile, sImagesDirectory, sThemeDir, -1, _T(""), params); - std::wstring sResult; - bool bRes = oDoctRenderer.Execute(sXml, sResult); - if (sResult.find(L"error") != std::wstring::npos) - { - std::wcerr << _T("DoctRenderer:") << sResult << std::endl; - nRes = AVS_FILEUTILS_ERROR_CONVERT; - } - else - { - NSFonts::IApplicationFonts* pApplicationFonts = NSFonts::NSApplication::Create(); - initApplicationFonts(pApplicationFonts, params); - - CPdfRenderer pdfWriter(pApplicationFonts, params.getIsPDFA()); - + { + _UINT32 nRes = 0; + NSDoctRenderer::DoctRendererFormat::FormatFile eToType = NSDoctRenderer::DoctRendererFormat::FormatFile::PDF; + std::wstring sTFileDir = NSDirectory::GetFolderPath(sFrom); + std::wstring sImagesDirectory = sTFileDir + FILE_SEPARATOR_STR + _T("media"); + std::wstring sPdfBinFile = sTFileDir + FILE_SEPARATOR_STR + _T("pdf.bin"); + NSDoctRenderer::CDoctrenderer oDoctRenderer(NULL != params.m_sAllFontsPath ? *params.m_sAllFontsPath : _T("")); + std::wstring sXml = getDoctXml(eFromType, eToType, sTFileDir, sPdfBinFile, sImagesDirectory, sThemeDir, -1, _T(""), params); + std::wstring sResult; + bool bRes = oDoctRenderer.Execute(sXml, sResult); + if (-1 != sResult.find(_T("error"))) + { + std::wcerr << _T("DoctRenderer:") << sResult << std::endl; + nRes = AVS_FILEUTILS_ERROR_CONVERT; + } + else + { + NSFonts::IApplicationFonts* pApplicationFonts = NSFonts::NSApplication::Create(); + initApplicationFonts(pApplicationFonts, params); + + CPdfRenderer pdfWriter(pApplicationFonts, params.getIsPDFA()); + pdfWriter.SetTempFolder(sTemp); pdfWriter.SetThemesPlace(sThemeDir); @@ -1648,22 +1534,23 @@ namespace NExtractTools std::wstring password = params.getSavePassword(); if (false == password.empty()) pdfWriter.SetPassword(password); + + int nReg = (bPaid == false) ? 0 : 1; + nRes = (S_OK == pdfWriter.OnlineWordToPdfFromBinary(sPdfBinFile, sTo)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT; + RELEASEOBJECT(pApplicationFonts); + } + //удаляем sPdfBinFile, потому что он не в Temp + if (NSFile::CFileBinary::Exists(sPdfBinFile)) + NSFile::CFileBinary::Remove(sPdfBinFile); + return nRes; + } - int nReg = (bPaid == false) ? 0 : 1; - nRes = (S_OK == pdfWriter.OnlineWordToPdfFromBinary(sPdfBinFile, sTo)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT; - RELEASEOBJECT(pApplicationFonts); - } - //удаляем sPdfBinFile, потому что он не в Temp - if (NSFile::CFileBinary::Exists(sPdfBinFile)) - NSFile::CFileBinary::Remove(sPdfBinFile); - return nRes; - } - // doct_bin -> image + //doct_bin -> image _UINT32 doct_bin2image(NSDoctRenderer::DoctRendererFormat::FormatFile eFromType, const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, bool bPaid, const std::wstring &sThemeDir, InputParams& params) { _UINT32 nRes = 0; NSDoctRenderer::DoctRendererFormat::FormatFile eToType = NSDoctRenderer::DoctRendererFormat::FormatFile::PDF; - std::wstring sTFileDir = NSDirectory::GetFolderPath(sFrom); + std::wstring sTFileDir = NSDirectory::GetFolderPath(sFrom); std::wstring sImagesDirectory = sTFileDir + FILE_SEPARATOR_STR + _T("media"); std::wstring sPdfBinFile = sTFileDir + FILE_SEPARATOR_STR + _T("pdf.bin"); NSDoctRenderer::CDoctrenderer oDoctRenderer(NULL != params.m_sAllFontsPath ? *params.m_sAllFontsPath : _T("")); @@ -3333,7 +3220,7 @@ namespace NExtractTools if (!bIsOnlyFirst) { sThumbnailDir = sTemp + FILE_SEPARATOR_STR + _T("thumbnails"); - NSDirectory::CreateDirectory(sThumbnailDir); + NSDirectory::CreateDirectory(sThumbnailDir); sFileToExt = getExtentionByRasterFormat(nRasterFormat); } int nPagesCount = pReader->GetPagesCount(); @@ -3404,23 +3291,10 @@ namespace NExtractTools } _UINT32 fromDocxDir(const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, InputParams& params) - { - _UINT32 nRes = 0; - bool bIsNeedDoct = false; - switch (nFormatTo) - { - // перечислить все "документные" форматы, которым нужна конвертация через doct - case AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML: - case AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML_IN_CONTAINER: - case AVS_OFFICESTUDIO_FILE_DOCUMENT_FB2: - case AVS_OFFICESTUDIO_FILE_DOCUMENT_EPUB: - bIsNeedDoct = true; - break; - default: - break; - } - if(0 != (AVS_OFFICESTUDIO_FILE_DOCUMENT & nFormatTo) && !bIsNeedDoct) - { + { + _UINT32 nRes = 0; + if(0 != (AVS_OFFICESTUDIO_FILE_DOCUMENT & nFormatTo)) + { if (AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX == nFormatTo || AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCM == nFormatTo || AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTX == nFormatTo || AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTM == nFormatTo) { @@ -3452,103 +3326,83 @@ namespace NExtractTools nRes = dir2zip(sFrom, sTo, true); } } - } - else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC == nFormatTo) - { - nRes = docx_dir2doc(sFrom, sTo, sTemp, params); - } - else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT == nFormatTo) - { - nRes = docx_dir2odt(sFrom, sTo, sTemp, params, false); - } - else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_OTT == nFormatTo) - { - nRes = docx_dir2odt(sFrom, sTo, sTemp, params, true); - } - else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_RTF == nFormatTo) - { - nRes = docx_dir2rtf(sFrom, sTo, sTemp, params); - } - else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT == nFormatTo) - { - nRes = docx_dir2txt(sFrom, sTo, sTemp, params); - } - else - nRes = AVS_FILEUTILS_ERROR_CONVERT_PARAMS; - } - else if(AVS_OFFICESTUDIO_FILE_CANVAS_WORD == nFormatTo) - { - nRes = docx_dir2doct_bin(sFrom, sTo, sTemp, params); - } - else - { - std::wstring sDoctDir = sTemp + FILE_SEPARATOR_STR + _T("doct_unpacked"); - NSDirectory::CreateDirectory(sDoctDir); - std::wstring sTFile = sDoctDir + FILE_SEPARATOR_STR + _T("Editor.bin"); + } + else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC == nFormatTo) + { + nRes = docx_dir2doc(sFrom, sTo, sTemp, params); + } + else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT == nFormatTo) + { + nRes = docx_dir2odt(sFrom, sTo, sTemp, params, false); + } + else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_OTT == nFormatTo) + { + nRes = docx_dir2odt(sFrom, sTo, sTemp, params, true); + } + else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_RTF == nFormatTo) + { + nRes = docx_dir2rtf(sFrom, sTo, sTemp, params); + } + else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT == nFormatTo) + { + nRes = docx_dir2txt(sFrom, sTo, sTemp, params); + } + else + nRes = AVS_FILEUTILS_ERROR_CONVERT_PARAMS; + } + else if(AVS_OFFICESTUDIO_FILE_CANVAS_WORD == nFormatTo) + { + nRes = docx_dir2doct_bin(sFrom, sTo, sTemp, params); + } + else + { + std::wstring sDoctDir = sTemp + FILE_SEPARATOR_STR + _T("doct_unpacked"); + NSDirectory::CreateDirectory(sDoctDir); + std::wstring sTFile = sDoctDir + FILE_SEPARATOR_STR + _T("Editor.bin"); - nRes = docx_dir2doct_bin(sFrom, sTFile, sTemp, params); - - if(SUCCEEDED_X2T(nRes)) - { - nRes = fromDoctBin(sTFile, sTo, nFormatTo, sTemp, sThemeDir, bFromChanges, bPaid, params); - } - } - return nRes; - } + nRes = docx_dir2doct_bin(sFrom, sTFile, sTemp, params); + + if(SUCCEEDED_X2T(nRes)) + { + nRes = fromDoctBin(sTFile, sTo, nFormatTo, sTemp, sThemeDir, bFromChanges, bPaid, params); + } + } + return nRes; + } _UINT32 fromDoctBin(const std::wstring &sFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, InputParams& params) - { - _UINT32 nRes = 0; - if(AVS_OFFICESTUDIO_FILE_TEAMLAB_DOCY == nFormatTo) - { - std::wstring sFromDir = NSDirectory::GetFolderPath(sFrom); - nRes = dir2zip(sFromDir, sTo); - } - else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_EPUB == nFormatTo) - { - NSDoctRenderer::DoctRendererFormat::FormatFile eFromType = NSDoctRenderer::DoctRendererFormat::FormatFile::DOCT; - nRes = doct_bin2epub(eFromType, sFrom, sTo, sTemp, bPaid, sThemeDir, params); - } - else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_FB2 == nFormatTo) - { - NSDoctRenderer::DoctRendererFormat::FormatFile eFromType = NSDoctRenderer::DoctRendererFormat::FormatFile::DOCT; - nRes = doct_bin2fb(eFromType, sFrom, sTo, sTemp, bPaid, sThemeDir, params); - } - else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML == nFormatTo) - { - NSDoctRenderer::DoctRendererFormat::FormatFile eFromType = NSDoctRenderer::DoctRendererFormat::FormatFile::DOCT; - nRes = doct_bin2html(eFromType, sFrom, sTo, sTemp, bPaid, sThemeDir, params); - } - else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML_IN_CONTAINER == nFormatTo) - { - NSDoctRenderer::DoctRendererFormat::FormatFile eFromType = NSDoctRenderer::DoctRendererFormat::FormatFile::DOCT; - nRes = doct_bin2html_zip(eFromType, sFrom, sTo, sTemp, bPaid, sThemeDir, params); - } - else if(AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF == nFormatTo) - { - NSDoctRenderer::DoctRendererFormat::FormatFile eFromType = NSDoctRenderer::DoctRendererFormat::FormatFile::DOCT; - nRes = doct_bin2pdf(eFromType, sFrom, sTo, sTemp, bPaid, sThemeDir, params); - } - else if(0 != (AVS_OFFICESTUDIO_FILE_IMAGE & nFormatTo)) - { - NSDoctRenderer::DoctRendererFormat::FormatFile eFromType = NSDoctRenderer::DoctRendererFormat::FormatFile::DOCT; - nRes = doct_bin2image(eFromType, sFrom, sTo, sTemp, bPaid, sThemeDir, params); - } - else if(0 != (AVS_OFFICESTUDIO_FILE_DOCUMENT & nFormatTo)) - { - std::wstring sDocxDir = sTemp + FILE_SEPARATOR_STR + _T("docx_unpacked"); - NSDirectory::CreateDirectory(sDocxDir); - nRes = doct_bin2docx_dir(sFrom, sTo, sDocxDir, bFromChanges, sThemeDir, params); - if(SUCCEEDED_X2T(nRes)) - { - nRes = fromDocxDir(sDocxDir, sTo, nFormatTo, sTemp, sThemeDir, bFromChanges, bPaid, params); - } - } - else - nRes = AVS_FILEUTILS_ERROR_CONVERT_PARAMS; - return nRes; - } + { + _UINT32 nRes = 0; + if(AVS_OFFICESTUDIO_FILE_TEAMLAB_DOCY == nFormatTo) + { + std::wstring sFromDir = NSDirectory::GetFolderPath(sFrom); + nRes = dir2zip(sFromDir, sTo); + } + else if(AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF == nFormatTo) + { + NSDoctRenderer::DoctRendererFormat::FormatFile eFromType = NSDoctRenderer::DoctRendererFormat::FormatFile::DOCT; + nRes = doct_bin2pdf(eFromType, sFrom, sTo, sTemp, bPaid, sThemeDir, params); + } + else if(0 != (AVS_OFFICESTUDIO_FILE_IMAGE & nFormatTo)) + { + NSDoctRenderer::DoctRendererFormat::FormatFile eFromType = NSDoctRenderer::DoctRendererFormat::FormatFile::DOCT; + nRes = doct_bin2image(eFromType, sFrom, sTo, sTemp, bPaid, sThemeDir, params); + } + else if(0 != (AVS_OFFICESTUDIO_FILE_DOCUMENT & nFormatTo)) + { + std::wstring sDocxDir = sTemp + FILE_SEPARATOR_STR + _T("docx_unpacked"); + NSDirectory::CreateDirectory(sDocxDir); + nRes = doct_bin2docx_dir(sFrom, sTo, sDocxDir, bFromChanges, sThemeDir, params); + if(SUCCEEDED_X2T(nRes)) + { + nRes = fromDocxDir(sDocxDir, sTo, nFormatTo, sTemp, sThemeDir, bFromChanges, bPaid, params); + } + } + else + nRes = AVS_FILEUTILS_ERROR_CONVERT_PARAMS; + return nRes; + } _UINT32 fromDocument(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTemp, InputParams& params) - { + { std::wstring sTo = *params.m_sFileTo; int nFormatTo = AVS_OFFICESTUDIO_FILE_UNKNOWN; if(NULL != params.m_nFormatTo) @@ -4234,30 +4088,30 @@ namespace NExtractTools return AVS_FILEUTILS_ERROR_CONVERT; } _UINT32 xls2xlsx_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) - { - bool bMacros = false; + { + bool bMacros = false; - int lcid = (NULL != params.m_nLcid) ? *params.m_nLcid : -1; - - _UINT32 nRes = ConvertXls2Xlsx( sFrom, sTo, params.getPassword(), params.getFontPath(), sTemp, lcid, bMacros); + int lcid = (NULL != params.m_nLcid) ? *params.m_nLcid : -1; + + _UINT32 nRes = ConvertXls2Xlsx( sFrom, sTo, params.getPassword(), params.getFontPath(), sTemp, lcid, bMacros); - nRes = processEncryptionError(nRes, sFrom, params); - return nRes; - } + nRes = processEncryptionError(nRes, sFrom, params); + return nRes; + } // xls -> xlsm _UINT32 xls2xlsm (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) { - std::wstring sResultXlsmDir = sTemp + FILE_SEPARATOR_STR + _T("xlsm_unpacked"); + std::wstring sResultXlsmDir = sTemp + FILE_SEPARATOR_STR + _T("xlsm_unpacked"); - NSDirectory::CreateDirectory(sResultXlsmDir); + NSDirectory::CreateDirectory(sResultXlsmDir); - _UINT32 nRes = xls2xlsm_dir(sFrom, sResultXlsmDir, sTemp, params); + _UINT32 nRes = xls2xlsm_dir(sFrom, sResultXlsmDir, sTemp, params); if(SUCCEEDED_X2T(nRes)) { - COfficeUtils oCOfficeUtils(NULL); - if(S_OK == oCOfficeUtils.CompressFileOrDirectory(sResultXlsmDir, sTo, true)) - return 0; + COfficeUtils oCOfficeUtils(NULL); + if(S_OK == oCOfficeUtils.CompressFileOrDirectory(sResultXlsmDir, sTo, true)) + return 0; } return nRes; } @@ -4269,48 +4123,48 @@ namespace NExtractTools nRes = processEncryptionError(nRes, sFrom, params); return nRes; - } + } // xls -> xlst _UINT32 xls2xlst (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) - { - // Extract xlsx to temp directory - std::wstring sResultDoctDir = sTemp + FILE_SEPARATOR_STR + _T("xlst_unpacked"); - std::wstring sResultDoctFileEditor = sResultDoctDir + FILE_SEPARATOR_STR + _T("Editor.bin"); + { + // Extract xlsx to temp directory + std::wstring sResultDoctDir = sTemp + FILE_SEPARATOR_STR + _T("xlst_unpacked"); + std::wstring sResultDoctFileEditor = sResultDoctDir + FILE_SEPARATOR_STR + _T("Editor.bin"); - NSDirectory::CreateDirectory(sResultDoctDir); + NSDirectory::CreateDirectory(sResultDoctDir); - _UINT32 nRes = xls2xlst_bin(sFrom, sResultDoctFileEditor, sTemp, params); + _UINT32 nRes = xls2xlst_bin(sFrom, sResultDoctFileEditor, sTemp, params); - if (SUCCEEDED_X2T(nRes)) - { - COfficeUtils oCOfficeUtils(NULL); - nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory(sResultDoctDir, sTo)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT; - } + if (SUCCEEDED_X2T(nRes)) + { + COfficeUtils oCOfficeUtils(NULL); + nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory(sResultDoctDir, sTo)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT; + } - return nRes; - } + return nRes; + } // xls -> xlst_bin _UINT32 xls2xlst_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) - { - std::wstring sResultXlsxDir = sTemp + FILE_SEPARATOR_STR + _T("xlsx_unpacked"); + { + std::wstring sResultXlsxDir = sTemp + FILE_SEPARATOR_STR + _T("xlsx_unpacked"); - NSDirectory::CreateDirectory(sResultXlsxDir); + NSDirectory::CreateDirectory(sResultXlsxDir); bool bMacros = true; _UINT32 nRes = ConvertXls2Xlsx( sFrom, sResultXlsxDir, params.getPassword(), params.getFontPath(), sTemp, NULL, bMacros); nRes = processEncryptionError(nRes, sFrom, params); if (SUCCEEDED_X2T(nRes)) - { - BinXlsxRW::CXlsxSerializer m_oCXlsxSerializer; + { + BinXlsxRW::CXlsxSerializer m_oCXlsxSerializer; - m_oCXlsxSerializer.setFontDir(params.getFontPath()); + m_oCXlsxSerializer.setFontDir(params.getFontPath()); return m_oCXlsxSerializer.saveToFile (sTo, sResultXlsxDir, params.getXmlOptions()); - } - return nRes; - } + } + return nRes; + } _UINT32 html2doct_bin(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params) { std::wstring sDocxDir = sTemp + FILE_SEPARATOR_STR + _T("docx_unpacked"); @@ -4335,18 +4189,18 @@ namespace NExtractTools } _UINT32 html2doct(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params) { - std::wstring sResultDoctDir = sTemp + FILE_SEPARATOR_STR + _T("doct_unpacked"); - std::wstring sResultDoctFileEditor = sResultDoctDir + FILE_SEPARATOR_STR + _T("Editor.bin"); + std::wstring sResultDoctDir = sTemp + FILE_SEPARATOR_STR + _T("doct_unpacked"); + std::wstring sResultDoctFileEditor = sResultDoctDir + FILE_SEPARATOR_STR + _T("Editor.bin"); - NSDirectory::CreateDirectory(sResultDoctDir); + NSDirectory::CreateDirectory(sResultDoctDir); - _UINT32 nRes = html2doct_bin(sFrom, sResultDoctFileEditor, sTemp, params); + _UINT32 nRes = html2doct_bin(sFrom, sResultDoctFileEditor, sTemp, params); - if (SUCCEEDED_X2T(nRes)) - { - COfficeUtils oCOfficeUtils(NULL); - nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory(sResultDoctDir, sTo)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT; - } + if (SUCCEEDED_X2T(nRes)) + { + COfficeUtils oCOfficeUtils(NULL); + nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory(sResultDoctDir, sTo)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT; + } return nRes; } _UINT32 html_zip2doct(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params) @@ -4365,7 +4219,7 @@ namespace NExtractTools } return nRes; } - _UINT32 html2docx(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params) + _UINT32 html2docx(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params) { std::wstring sDocxDir = sTemp + FILE_SEPARATOR_STR + _T("docx_unpacked"); NSDirectory::CreateDirectory(sDocxDir); @@ -4396,17 +4250,17 @@ namespace NExtractTools //------------------------------------------------------------------------------------------------------------------ _UINT32 detectMacroInFile(InputParams& oInputParams) { - _UINT32 nRes = 0;// no macro + _UINT32 nRes = 0;// no macro std::wstring sFileFrom = *oInputParams.m_sFileFrom; COfficeFileFormatChecker OfficeFileFormatChecker; if (OfficeFileFormatChecker.isOfficeFile(sFileFrom)) - { - if (OfficeFileFormatChecker.bMacroEnabled) - { - nRes = AVS_ERROR_MACRO; - } + { + if (OfficeFileFormatChecker.bMacroEnabled) + { + nRes = AVS_ERROR_MACRO; + } } return nRes; @@ -4488,7 +4342,7 @@ namespace NExtractTools return AVS_FILEUTILS_ERROR_CONVERT_LIMITS; } - NSDoctRenderer::CDocBuilder::Initialize(); + NSDoctRenderer::CDocBuilder::Initialize(); _UINT32 result = 0; switch(conversion) @@ -4505,19 +4359,6 @@ namespace NExtractTools { result = docxflat2doct_bin (sFileFrom, sFileTo, sTempDir, oInputParams); }break; - case TCD_PKG2DOCT: - { - result = package2doct(sFileFrom, sFileTo, sTempDir, oInputParams); - }break; - case TCD_PKG2DOCT_BIN: - { - result = package2doct_bin(sFileFrom, sFileTo, sTempDir, oInputParams); - }break; - case TCD_PKG2DOCX: - { - oInputParams.m_nFormatTo = new int(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX); - result = package2docx(sFileFrom, sFileTo, sTempDir, oInputParams); - }break; case TCD_DOCT2DOCX: { oInputParams.m_nFormatTo = new int(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX); @@ -4693,20 +4534,20 @@ namespace NExtractTools }break; case TCD_BIN2T: { - result = dir2zip (NSDirectory::GetFolderPath(sFileFrom), sFileTo); + result = dir2zip (NSDirectory::GetFolderPath(sFileFrom), sFileTo); }break; case TCD_T2BIN: { - result = zip2dir (sFileFrom, NSDirectory::GetFolderPath(sFileTo)); + result = zip2dir (sFileFrom, NSDirectory::GetFolderPath(sFileTo)); }break; case TCD_PPT2PPTX: { result = ppt2pptx (sFileFrom, sFileTo, sTempDir, oInputParams); - }break; + }break; case TCD_PPT2PPTM: { result = ppt2pptm (sFileFrom, sFileTo, sTempDir, oInputParams); - }break; + }break; case TCD_PPT2PPTT: { result = ppt2pptt (sFileFrom, sFileTo, sTempDir, oInputParams); @@ -4790,7 +4631,7 @@ namespace NExtractTools case TCD_ODF2OOT_BIN: { result = odf2oot_bin (sFileFrom, sFileTo, sTempDir, oInputParams); - }break; + }break; case TCD_ODF_FLAT2OOX: { result = odf_flat2oox (sFileFrom, sFileTo, sTempDir, oInputParams); @@ -4802,7 +4643,7 @@ namespace NExtractTools case TCD_ODF_FLAT2OOT_BIN: { result = odf_flat2oot_bin (sFileFrom, sFileTo, sTempDir, oInputParams); - }break; + }break; case TCD_DOCX2ODT: { result = docx2odt (sFileFrom, sFileTo, sTempDir, oInputParams); @@ -4924,7 +4765,7 @@ namespace NExtractTools } //clean up v8 - NSDoctRenderer::CDocBuilder::Dispose(); + NSDoctRenderer::CDocBuilder::Dispose(); if (SUCCEEDED_X2T(result) && oInputParams.m_bOutputConvertCorrupted) { return AVS_FILEUTILS_ERROR_CONVERT_CORRUPTED; diff --git a/X2tConverter/src/cextracttools.cpp b/X2tConverter/src/cextracttools.cpp index 83b41c97ba..078f6e6860 100644 --- a/X2tConverter/src/cextracttools.cpp +++ b/X2tConverter/src/cextracttools.cpp @@ -129,13 +129,13 @@ namespace NExtractTools } else if (0 == sExt2.compare(_T(".docm"))) res = TCD_DOTM2DOCM; }break; - case AVS_OFFICESTUDIO_FILE_DOCUMENT_PACKAGE: + case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX_FLAT: { if (0 == sExt2.compare(_T(".doct"))) res = TCD_PKG2DOCT; else if (0 == sExt2.compare(_T(".bin"))) res = TCD_PKG2DOCT_BIN; else if (0 == sExt2.compare(_T(".docx"))) res = TCD_PKG2DOCX; }break; - case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX_FLAT: + case AVS_OFFICESTUDIO_FILE_DOCUMENT_PACKAGE: { if (0 == sExt2.compare(_T(".doct"))) res = TCD_DOCXFLAT2DOCT; else if (0 == sExt2.compare(_T(".bin"))) res = TCD_DOCXFLAT2DOCT_BIN; diff --git a/XlsxSerializerCom/Common/BinReaderWriterDefines.h b/XlsxSerializerCom/Common/BinReaderWriterDefines.h index ec556f6db8..49746cdb0b 100755 --- a/XlsxSerializerCom/Common/BinReaderWriterDefines.h +++ b/XlsxSerializerCom/Common/BinReaderWriterDefines.h @@ -219,16 +219,8 @@ namespace BinXlsxRW AppName = 17, SlicerCaches = 18, SlicerCachesExt = 19, - SlicerCache = 20, - Protection = 21 + SlicerCache = 20 };} - namespace c_oSerWorkbookProtection{ enum c_oSerWorkbookProtection - { - AlgorithmName = 0, - SpinCount = 1, - HashValue = 2, - SaltValue = 3 - }; } namespace c_oSerDbPrTypes{enum c_oSerDbPrTypes { Connection = 0, @@ -397,33 +389,7 @@ namespace BinXlsxRW Slicers = 37, SlicersExt = 38, Slicer = 39, - NamedSheetView = 40, - Protection = 41 - };} - namespace c_oSerWorksheetProtection {enum c_oSerWorksheetPropTypes - { - AlgorithmName = 0, - SpinCount = 1, - HashValue = 2, - SaltValue = 3, - Password = 4, - AutoFilter = 5, - Content = 6, - DeleteColumns = 7, - DeleteRows = 8, - FormatCells = 9, - FormatColumns = 10, - FormatRows = 11, - InsertColumns = 12, - InsertHyperlinks = 13, - InsertRows = 14, - Objects = 15, - PivotTables = 16, - Scenarios = 17, - SelectLockedCells = 18, - SelectUnlockedCell = 19, - Sheet = 20, - Sort = 21 + NamedSheetView = 40 };} namespace c_oSerWorksheetPropTypes{enum c_oSerWorksheetPropTypes { diff --git a/XlsxSerializerCom/Reader/BinaryWriter.cpp b/XlsxSerializerCom/Reader/BinaryWriter.cpp index 17ee2dc680..3b3e76afc5 100644 --- a/XlsxSerializerCom/Reader/BinaryWriter.cpp +++ b/XlsxSerializerCom/Reader/BinaryWriter.cpp @@ -2007,13 +2007,6 @@ void BinaryWorkbookTableWriter::WriteWorkbook(OOX::Spreadsheet::CWorkbook& workb WriteWorkbookPr(workbook.m_oWorkbookPr.get()); m_oBcw.WriteItemWithLengthEnd(nCurPos); } -//WorkbookPr - if (workbook.m_oWorkbookProtection.IsInit()) - { - nCurPos = m_oBcw.WriteItemStart(c_oSerWorkbookTypes::Protection); - WriteProtection(workbook.m_oWorkbookProtection.get()); - m_oBcw.WriteItemWithLengthEnd(nCurPos); - } //BookViews if(workbook.m_oBookViews.IsInit()) { @@ -2112,33 +2105,6 @@ void BinaryWorkbookTableWriter::WriteWorkbook(OOX::Spreadsheet::CWorkbook& workb m_oBcw.WriteItemWithLengthEnd(nCurPos); } } -void BinaryWorkbookTableWriter::WriteProtection(const OOX::Spreadsheet::CWorkbookProtection& protection) -{ - if (protection.m_oWorkbookAlgorithmName.IsInit()) - { - m_oBcw.m_oStream.WriteBYTE(c_oSerWorkbookProtection::AlgorithmName); - m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte); - m_oBcw.m_oStream.WriteBYTE(protection.m_oWorkbookAlgorithmName->GetValue()); - } - if (protection.m_oWorkbookSpinCount.IsInit()) - { - m_oBcw.m_oStream.WriteBYTE(c_oSerWorkbookProtection::SpinCount); - m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long); - m_oBcw.m_oStream.WriteULONG(protection.m_oWorkbookSpinCount->GetValue()); - } - if (protection.m_oWorkbookHashValue.IsInit()) - { - m_oBcw.m_oStream.WriteBYTE(c_oSerWorkbookProtection::HashValue); - m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Variable); - m_oBcw.m_oStream.WriteStringW(*protection.m_oWorkbookHashValue); - } - if (protection.m_oWorkbookSaltValue.IsInit()) - { - m_oBcw.m_oStream.WriteBYTE(c_oSerWorkbookProtection::SaltValue); - m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Variable); - m_oBcw.m_oStream.WriteStringW(*protection.m_oWorkbookSaltValue); - } -} void BinaryWorkbookTableWriter::WriteWorkbookPr(const OOX::Spreadsheet::CWorkbookPr& workbookPr) { //Date1904 @@ -3165,13 +3131,7 @@ void BinaryWorksheetTableWriter::WriteWorksheet(OOX::Spreadsheet::CSheet* pSheet WriteWorksheetProp(*pSheet); m_oBcw.WriteItemWithLengthEnd(nCurPos); } - //Protection - if (oWorksheet.m_oSheetProtection.IsInit()) - { - nCurPos = m_oBcw.WriteItemStart(c_oSerWorksheetsTypes::Protection); - WriteProtection(oWorksheet.m_oSheetProtection.get()); - m_oBcw.WriteItemWithLengthEnd(nCurPos); - } + //Cols if(oWorksheet.m_oCols.IsInit()) { @@ -3276,9 +3236,7 @@ void BinaryWorksheetTableWriter::WriteWorksheet(OOX::Spreadsheet::CSheet* pSheet WriteDataValidations(oWorksheet.m_oDataValidations.get()); m_oBcw.WriteItemWithLengthEnd(nCurPos); } -//Drawing smart_ptr currentVmlDrawing; - smart_ptr currentDrawing; if (oWorksheet.m_oLegacyDrawing.IsInit() && oWorksheet.m_oLegacyDrawing->m_oId.IsInit()) @@ -3286,30 +3244,28 @@ void BinaryWorksheetTableWriter::WriteWorksheet(OOX::Spreadsheet::CSheet* pSheet smart_ptr oFile = oWorksheet.Find(oWorksheet.m_oLegacyDrawing->m_oId->GetValue()); currentVmlDrawing = oFile.smart_dynamic_cast(); } + //Drawing if (oWorksheet.m_oDrawing.IsInit() && oWorksheet.m_oDrawing->m_oId.IsInit()) { + smart_ptr currentDrawing; + smart_ptr oFile = oWorksheet.Find(oWorksheet.m_oDrawing->m_oId->GetValue()); currentDrawing = oFile.smart_dynamic_cast(); - } - WriteControls(oWorksheet, currentVmlDrawing.GetPointer()); + if (currentDrawing.IsInit()) + { + smart_ptr oldRels = m_pOfficeDrawingConverter->GetRels(); + m_pOfficeDrawingConverter->SetRels(currentDrawing.smart_dynamic_cast()); + + //из Drawing могут быть ссылки на объекты в VmlDrawing + nCurPos = m_oBcw.WriteItemStart(c_oSerWorksheetsTypes::Drawings); + WriteDrawings(oWorksheet, currentDrawing.GetPointer(), currentVmlDrawing.GetPointer()); + m_oBcw.WriteItemWithLengthEnd(nCurPos); - smart_ptr oldRels; - if (currentDrawing.IsInit()) - { - oldRels = m_pOfficeDrawingConverter->GetRels(); - m_pOfficeDrawingConverter->SetRels(currentDrawing.smart_dynamic_cast()); - } - if (currentDrawing.IsInit() || currentVmlDrawing.IsInit()) - { - nCurPos = m_oBcw.WriteItemStart(c_oSerWorksheetsTypes::Drawings); - WriteDrawings(oWorksheet, currentDrawing.GetPointer(), currentVmlDrawing.GetPointer()); - m_oBcw.WriteItemWithLengthEnd(nCurPos); - } - if (oldRels.IsInit()) - { - m_pOfficeDrawingConverter->SetRels(oldRels); + m_pOfficeDrawingConverter->SetRels(oldRels); + } } + WriteControls(oWorksheet, currentVmlDrawing.GetPointer()); if (oWorksheet.m_oLegacyDrawingHF.IsInit()) { @@ -3470,141 +3426,6 @@ void BinaryWorksheetTableWriter::WriteWorksheetProp(OOX::Spreadsheet::CSheet& oS m_oBcw.m_oStream.WriteBYTE(oSheet.m_oState->GetValue()); } } -void BinaryWorksheetTableWriter::WriteProtection(const OOX::Spreadsheet::CSheetProtection& protection) -{ - if (protection.m_oAlgorithmName.IsInit()) - { - m_oBcw.m_oStream.WriteBYTE(c_oSerWorksheetProtection::AlgorithmName); - m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte); - m_oBcw.m_oStream.WriteBYTE(protection.m_oAlgorithmName->GetValue()); - } - if (protection.m_oSpinCount.IsInit()) - { - m_oBcw.m_oStream.WriteBYTE(c_oSerWorksheetProtection::SpinCount); - m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long); - m_oBcw.m_oStream.WriteULONG(protection.m_oSpinCount->GetValue()); - } - if (protection.m_oHashValue.IsInit()) - { - m_oBcw.m_oStream.WriteBYTE(c_oSerWorksheetProtection::HashValue); - m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Variable); - m_oBcw.m_oStream.WriteStringW(*protection.m_oHashValue); - } - if (protection.m_oSaltValue.IsInit()) - { - m_oBcw.m_oStream.WriteBYTE(c_oSerWorksheetProtection::SaltValue); - m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Variable); - m_oBcw.m_oStream.WriteStringW(*protection.m_oSaltValue); - } - if (protection.m_oPassword.IsInit()) - { - m_oBcw.m_oStream.WriteBYTE(c_oSerWorksheetProtection::Password); - m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Variable); - m_oBcw.m_oStream.WriteStringW(*protection.m_oPassword); - } - if (protection.m_oAutoFilter.IsInit()) - { - m_oBcw.m_oStream.WriteBYTE(c_oSerWorksheetProtection::AutoFilter); - m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte); - m_oBcw.m_oStream.WriteBOOL(protection.m_oAutoFilter->ToBool()); - } - if (protection.m_oContent.IsInit()) - { - m_oBcw.m_oStream.WriteBYTE(c_oSerWorksheetProtection::Content); - m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte); - m_oBcw.m_oStream.WriteBOOL(protection.m_oContent->ToBool()); - } - if (protection.m_oDeleteColumns.IsInit()) - { - m_oBcw.m_oStream.WriteBYTE(c_oSerWorksheetProtection::DeleteColumns); - m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte); - m_oBcw.m_oStream.WriteBOOL(protection.m_oDeleteColumns->ToBool()); - } - if (protection.m_oDeleteRows.IsInit()) - { - m_oBcw.m_oStream.WriteBYTE(c_oSerWorksheetProtection::DeleteRows); - m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte); - m_oBcw.m_oStream.WriteBOOL(protection.m_oDeleteRows->ToBool()); - } - if (protection.m_oFormatCells.IsInit()) - { - m_oBcw.m_oStream.WriteBYTE(c_oSerWorksheetProtection::FormatCells); - m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte); - m_oBcw.m_oStream.WriteBOOL(protection.m_oFormatCells->ToBool()); - } - if (protection.m_oFormatColumns.IsInit()) - { - m_oBcw.m_oStream.WriteBYTE(c_oSerWorksheetProtection::FormatColumns); - m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte); - m_oBcw.m_oStream.WriteBOOL(protection.m_oFormatColumns->ToBool()); - } - if (protection.m_oFormatRows.IsInit()) - { - m_oBcw.m_oStream.WriteBYTE(c_oSerWorksheetProtection::FormatRows); - m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte); - m_oBcw.m_oStream.WriteBOOL(protection.m_oFormatRows->ToBool()); - } - if (protection.m_oInsertColumns.IsInit()) - { - m_oBcw.m_oStream.WriteBYTE(c_oSerWorksheetProtection::InsertColumns); - m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte); - m_oBcw.m_oStream.WriteBOOL(protection.m_oInsertColumns->ToBool()); - } - if (protection.m_oInsertHyperlinks.IsInit()) - { - m_oBcw.m_oStream.WriteBYTE(c_oSerWorksheetProtection::InsertHyperlinks); - m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte); - m_oBcw.m_oStream.WriteBOOL(protection.m_oInsertHyperlinks->ToBool()); - } - if (protection.m_oInsertRows.IsInit()) - { - m_oBcw.m_oStream.WriteBYTE(c_oSerWorksheetProtection::InsertRows); - m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte); - m_oBcw.m_oStream.WriteBOOL(protection.m_oInsertRows->ToBool()); - } - if (protection.m_oObjects.IsInit()) - { - m_oBcw.m_oStream.WriteBYTE(c_oSerWorksheetProtection::Objects); - m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte); - m_oBcw.m_oStream.WriteBOOL(protection.m_oObjects->ToBool()); - } - if (protection.m_oPivotTables.IsInit()) - { - m_oBcw.m_oStream.WriteBYTE(c_oSerWorksheetProtection::PivotTables); - m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte); - m_oBcw.m_oStream.WriteBOOL(protection.m_oPivotTables->ToBool()); - } - if (protection.m_oScenarios.IsInit()) - { - m_oBcw.m_oStream.WriteBYTE(c_oSerWorksheetProtection::Scenarios); - m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte); - m_oBcw.m_oStream.WriteBOOL(protection.m_oScenarios->ToBool()); - } - if (protection.m_oSelectLockedCells.IsInit()) - { - m_oBcw.m_oStream.WriteBYTE(c_oSerWorksheetProtection::SelectLockedCells); - m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte); - m_oBcw.m_oStream.WriteBOOL(protection.m_oSelectLockedCells->ToBool()); - } - if (protection.m_oSelectUnlockedCell.IsInit()) - { - m_oBcw.m_oStream.WriteBYTE(c_oSerWorksheetProtection::SelectUnlockedCell); - m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte); - m_oBcw.m_oStream.WriteBOOL(protection.m_oSelectUnlockedCell->ToBool()); - } - if (protection.m_oSheet.IsInit()) - { - m_oBcw.m_oStream.WriteBYTE(c_oSerWorksheetProtection::Sheet); - m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte); - m_oBcw.m_oStream.WriteBOOL(protection.m_oSheet->ToBool()); - } - if (protection.m_oSort.IsInit()) - { - m_oBcw.m_oStream.WriteBYTE(c_oSerWorksheetProtection::Sort); - m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte); - m_oBcw.m_oStream.WriteBOOL(protection.m_oSort->ToBool()); - } -} void BinaryWorksheetTableWriter::WriteCols(const OOX::Spreadsheet::CCols& oCols) { int nCurPos; @@ -4666,17 +4487,11 @@ void BinaryWorksheetTableWriter::WriteControls(const OOX::Spreadsheet::CWorkshee } std::wstring sShapeId = L"_x0000_s" + std::to_wstring(pControl->m_oShapeId->GetValue()); - OOX::Vml::CShape* pShape = NULL; - boost::unordered_map::iterator pFind; - + smart_ptr oShape; if (pVmlDrawing) { - pFind = pVmlDrawing->m_mapShapes.find(sShapeId); - - if (pFind != pVmlDrawing->m_mapShapes.end() && !pFind->second.bUsed) - { - pShape = dynamic_cast(pFind->second.pElement); - } + smart_ptr oObjectElement = pVmlDrawing->FindVmlObject(sShapeId); + oShape = oObjectElement.smart_dynamic_cast(); } SimpleTypes::Spreadsheet::CCellAnchorType<> eAnchorType; eAnchorType.SetValue(SimpleTypes::Spreadsheet::cellanchorTwoCell); @@ -4707,18 +4522,19 @@ void BinaryWorksheetTableWriter::WriteControls(const OOX::Spreadsheet::CWorkshee oCellAnchor.reset(new OOX::Spreadsheet::CCellAnchor(eAnchorType)); oCellAnchor->m_bShapeOle= true; } - if ((pShape) && (OOX::et_v_shapetype != pShape->getType())) + if ((oShape.IsInit()) && (OOX::et_v_shapetype != oShape->getType())) { - for(size_t j = 0; (pShape) && (j < pShape->m_arrItems.size()); ++j) + for(size_t j = 0; (oShape.IsInit()) && (j < oShape->m_arrItems.size()); ++j) { - OOX::WritingElement* pChildElemShape = pShape->m_arrItems[j]; + OOX::WritingElement* pChildElemShape = oShape->m_arrItems[j]; if (OOX::et_v_ClientData == pChildElemShape->getType()) { OOX::Vml::CClientData* pClientData = static_cast(pChildElemShape); if (!bSetAnchor ) - { - bSetAnchor = pClientData->toCellAnchor(oCellAnchor.GetPointer()); + { + pClientData->toCellAnchor(oCellAnchor.GetPointer()); + bSetAnchor = true; } pClientData->toFormControlPr(pFormControlPr); } @@ -4735,8 +4551,6 @@ void BinaryWorksheetTableWriter::WriteControls(const OOX::Spreadsheet::CWorkshee { continue; } - if (pShape) - pFind->second.bUsed = true; //----------------------------------------------------------------------------------------------------- int nCurPos2 = m_oBcw.WriteItemStart(c_oSerControlTypes::Control); int nCurPos3 = m_oBcw.WriteItemStart(c_oSerControlTypes::ControlAnchor); @@ -5024,7 +4838,7 @@ void BinaryWorksheetTableWriter::WriteControlPr(OOX::Spreadsheet::CControlPr* pC void BinaryWorksheetTableWriter::WriteDrawings(const OOX::Spreadsheet::CWorksheet& oWorksheet, OOX::Spreadsheet::CDrawing* pDrawing, OOX::CVmlDrawing *pVmlDrawing) { - for (size_t i = 0; pDrawing && i < pDrawing->m_arrItems.size(); ++i) + for (size_t i = 0, length = pDrawing->m_arrItems.size(); i < length ; ++i) { OOX::Spreadsheet::CCellAnchor* pCellAnchor = pDrawing->m_arrItems[i]; @@ -5077,20 +4891,20 @@ void BinaryWorksheetTableWriter::WriteDrawings(const OOX::Spreadsheet::CWorkshee //преобразуем ClientData в CellAnchor OOX::Vml::CClientData* pClientData = static_cast(pElemShape); - SimpleTypes::Spreadsheet::CCellAnchorType<> eAnchorType; - eAnchorType.SetValue(SimpleTypes::Spreadsheet::cellanchorTwoCell); + OOX::Spreadsheet::CCellAnchor *pCellAnchor = NULL; + pClientData->toCellAnchor(pCellAnchor); - OOX::Spreadsheet::CCellAnchor *pCellAnchor = new OOX::Spreadsheet::CCellAnchor(eAnchorType); - if (pClientData->toCellAnchor(pCellAnchor)) + if (pCellAnchor) { pCellAnchor->m_sVmlSpId.Init(); pCellAnchor->m_sVmlSpId->append(it->first); int nCurPos = m_oBcw.WriteItemStart(c_oSerWorksheetsTypes::Drawing); WriteDrawing(oWorksheet, pDrawing, pCellAnchor, pVmlDrawing, NULL); - m_oBcw.WriteItemEnd(nCurPos); + m_oBcw.WriteItemEnd(nCurPos); + + delete pCellAnchor; } - delete pCellAnchor; } } } @@ -7119,16 +6933,13 @@ void BinaryFileWriter::intoBindoc(OOX::Document *pDocument, NSBinPptxRW::CBinary this->WriteTableEnd(nCurPos); } - if (pXlsx) + smart_ptr pFile = pXlsx->Find(OOX::FileTypes::CustomProperties); + PPTX::CustomProperties *pCustomProperties = dynamic_cast(pFile.GetPointer()); + if (pCustomProperties) { - smart_ptr pFile = pXlsx->Find(OOX::FileTypes::CustomProperties); - PPTX::CustomProperties *pCustomProperties = dynamic_cast(pFile.GetPointer()); - if (pCustomProperties) - { - nCurPos = this->WriteTableStart(c_oSerTableTypes::CustomProperties); - pCustomProperties->toPPTY(&oBufferedStream); - this->WriteTableEnd(nCurPos); - } + nCurPos = this->WriteTableStart(c_oSerTableTypes::CustomProperties); + pCustomProperties->toPPTY(&oBufferedStream); + this->WriteTableEnd(nCurPos); } if(pSharedStrings) diff --git a/XlsxSerializerCom/Reader/BinaryWriter.h b/XlsxSerializerCom/Reader/BinaryWriter.h index 57f4304182..aeaef1a873 100755 --- a/XlsxSerializerCom/Reader/BinaryWriter.h +++ b/XlsxSerializerCom/Reader/BinaryWriter.h @@ -159,7 +159,6 @@ namespace BinXlsxRW void Write(OOX::Spreadsheet::CWorkbook& workbook); void WriteWorkbook(OOX::Spreadsheet::CWorkbook& workbook); void WriteWorkbookPr(const OOX::Spreadsheet::CWorkbookPr& workbookPr); - void WriteProtection(const OOX::Spreadsheet::CWorkbookProtection& protection); void WriteBookViews(const OOX::Spreadsheet::CBookViews& bookViews); void WriteWorkbookView(const OOX::Spreadsheet::CWorkbookView& workbookView); void WriteDefinedNames(const OOX::Spreadsheet::CDefinedNames& definedNames); @@ -217,7 +216,6 @@ namespace BinXlsxRW void WriteWorksheet(OOX::Spreadsheet::CSheet* pSheet, OOX::Spreadsheet::CWorksheet& oWorksheet); void WriteWorksheetProp(OOX::Spreadsheet::CSheet& oSheet); - void WriteProtection(const OOX::Spreadsheet::CSheetProtection& protection); void WriteCols(const OOX::Spreadsheet::CCols& oCols); void WriteCol(const OOX::Spreadsheet::CCol& oCol); void WriteSheetViews(const OOX::Spreadsheet::CSheetViews& oSheetViews); @@ -329,6 +327,7 @@ namespace BinXlsxRW private: BinaryCommonWriter* m_oBcw; int m_nLastFilePos; + int m_nLastFilePosOffset; int m_nRealTableCount; int m_nMainTableStart; DocWrapper::FontProcessor& m_oFontProcessor; @@ -339,14 +338,11 @@ namespace BinXlsxRW NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter, const std::wstring& sXMLOptions, bool bIsNoBase64); void intoBindoc(OOX::Document *pDocument, NSBinPptxRW::CBinaryFileWriter &oBufferedStream, NSFontCutter::CEmbeddedFontsManager* pEmbeddedFontsManager, NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter); - - std::wstring WriteFileHeader(int nDataSize, int version); - int GetMainTableSize(); - - int m_nLastFilePosOffset; - private: + private: + std::wstring WriteFileHeader(int nDataSize, int version); void WriteMainTableStart(); void WriteMainTableEnd(); + int GetMainTableSize(); int WriteTableStart(BYTE type, int nStartPos = -1); void WriteTableEnd(int nCurPos); }; diff --git a/XlsxSerializerCom/Reader/ChartFromToBinary.cpp b/XlsxSerializerCom/Reader/ChartFromToBinary.cpp index dca9817a73..795241c2cc 100644 --- a/XlsxSerializerCom/Reader/ChartFromToBinary.cpp +++ b/XlsxSerializerCom/Reader/ChartFromToBinary.cpp @@ -30,29 +30,24 @@ * */ -#include "../Writer/BinaryReader.h" - +#include "ChartFromToBinary.h" +#include "../Common/BinReaderWriterDefines.h" #include "../../ASCOfficePPTXFile/Editor/BinReaderWriterDefines.h" #include "../../ASCOfficeDocxFile2/BinReader/DefaultThemeWriter.h" #include "../../Common/DocxFormat/Source/XlsxFormat/Chart/Chart.h" -#include "../../Common/DocxFormat/Source/XlsxFormat/Chart/ChartDrawing.h" - +#include "../../Common/DocxFormat/Source/DocxFormat/ChartDrawing.h" #include "../../ASCOfficePPTXFile/PPTXFormat/Theme.h" -#include "../../ASCOfficeDocxFile2/DocWrapper/XlsxSerializer.h" -#include "../../OfficeUtils/src/OfficeUtils.h" - using namespace OOX::Spreadsheet; namespace BinXlsxRW { - SaveParams::SaveParams(const std::wstring& _sDrawingsPath, const std::wstring& _sEmbeddingsPath, const std::wstring& _sThemePath, OOX::CContentTypes* _pContentTypes, CSVWriter::CCSVWriter* _pCSVWriter) + SaveParams::SaveParams(const std::wstring& _sDrawingsPath, const std::wstring& _sThemePath, OOX::CContentTypes* _pContentTypes, CSVWriter::CCSVWriter* _pCSVWriter) { pContentTypes = _pContentTypes; sThemePath = _sThemePath; sDrawingsPath = _sDrawingsPath; - sEmbeddingsPath = _sEmbeddingsPath; nThemeOverrideCount = 1; pCSVWriter = _pCSVWriter; @@ -76,16 +71,15 @@ namespace BinXlsxRW BYTE c_oserct_chartspaceUSERSHAPES = 13; BYTE c_oserct_chartspaceEXTLST = 14; BYTE c_oserct_chartspaceTHEMEOVERRIDE = 15; - BYTE c_oserct_chartspaceXLSX = 16; - BYTE c_oserct_chartspaceSTYLES = 17; - BYTE c_oserct_chartspaceCOLORS = 18; - + BYTE c_oserct_usershapes_COUNT = 0; BYTE c_oserct_usershapes_SHAPE_REL = 1; BYTE c_oserct_usershapes_SHAPE_ABS = 2; BYTE c_oserct_booleanVAL = 0; + BYTE c_oserct_relidID = 0; + BYTE c_oserct_pagesetupPAPERSIZE = 0; BYTE c_oserct_pagesetupPAPERHEIGHT = 1; BYTE c_oserct_pagesetupPAPERWIDTH = 2; @@ -120,6 +114,7 @@ namespace BinXlsxRW BYTE c_oserct_printsettingsPAGESETUP = 2; BYTE c_oserct_externaldataAUTOUPDATE = 0; + BYTE c_oserct_externaldataID = 1; BYTE c_oserct_dispblanksasVAL = 0; @@ -851,203 +846,6 @@ namespace BinXlsxRW BYTE c_oseralternatecontentfallbackSTYLE = 0; - BYTE c_oserct_chartstyleID = 0; - BYTE c_oserct_chartstyleENTRY = 1; - BYTE c_oserct_chartstyleMARKERLAYOUT = 2; - - BYTE c_oserct_chartstyleENTRYTYPE = 0; - BYTE c_oserct_chartstyleLNREF = 1; - BYTE c_oserct_chartstyleFILLREF = 2; - BYTE c_oserct_chartstyleEFFECTREF = 3; - BYTE c_oserct_chartstyleFONTREF = 4; - BYTE c_oserct_chartstyleDEFPR = 5; - BYTE c_oserct_chartstyleBODYPR = 6; - BYTE c_oserct_chartstyleSPPR = 7; - BYTE c_oserct_chartstyleLINEWIDTH = 8; - - BYTE c_oserct_chartstyleMARKERSYMBOL = 0; - BYTE c_oserct_chartstyleMARKERSIZE = 1; - - BYTE c_oserct_chartcolorsID = 0; - BYTE c_oserct_chartcolorsMETH = 1; - BYTE c_oserct_chartcolorsVARIATION = 2; - BYTE c_oserct_chartcolorsCOLOR = 3; - BYTE c_oserct_chartcolorsEFFECT = 4; - - BYTE c_oserct_chartExSpaceCHARTDATA = 0; - BYTE c_oserct_chartExSpaceCHART = 1; - BYTE c_oserct_chartExSpaceSPPR = 2; - BYTE c_oserct_chartExSpaceTXPR = 3; - BYTE c_oserct_chartExSpaceCLRMAPOVR = 4; - BYTE c_oserct_chartExSpaceEXTLST = 5; - BYTE c_oserct_chartExSpaceXLSX = c_oserct_chartspaceXLSX;/* = 16*/ - BYTE c_oserct_chartExSpaceSTYLES = c_oserct_chartspaceSTYLES;/* = 17*/ - BYTE c_oserct_chartExSpaceCOLORS = c_oserct_chartspaceCOLORS;/* = 18*/ - - BYTE c_oserct_chartExDATA = 0; - BYTE c_oserct_chartExEXTERNALDATA = 1; - - BYTE c_oserct_chartExExternalAUTOUPDATE = 0; - - BYTE c_oserct_chartExChartPLOTAREA = 0; - BYTE c_oserct_chartExChartTITLE = 1; - BYTE c_oserct_chartExChartLEGEND = 2; - - BYTE c_oserct_chartExChartAREAREGION = 0; - BYTE c_oserct_chartExChartAXIS = 1; - BYTE c_oserct_chartExChartSPPR = 2; - - BYTE c_oserct_chartExAreaPLOTSURFACE = 0; - BYTE c_oserct_chartExAreaSERIES = 1; - - BYTE c_oserct_chartExAxisID = 0; - - BYTE c_oserct_chartExPlotSurfaceSPPR = 0; - BYTE c_oserct_chartExAxisHIDDEN = 1; - BYTE c_oserct_chartExAxisCATSCALING = 2; - BYTE c_oserct_chartExAxisVALSCALING = 3; - BYTE c_oserct_chartExAxisTITLE = 4; - BYTE c_oserct_chartExAxisUNIT = 5; - BYTE c_oserct_chartExAxisNUMFMT = 6; - BYTE c_oserct_chartExAxisMAJORTICK = 7; - BYTE c_oserct_chartExAxisMINORTICK = 8; - BYTE c_oserct_chartExAxisMAJORGRID = 9; - BYTE c_oserct_chartExAxisMINORGRID = 10; - BYTE c_oserct_chartExAxisTICKLABELS = 11; - BYTE c_oserct_chartExAxisTXPR = 12; - BYTE c_oserct_chartExAxisSPPR = 13; - - BYTE c_oserct_chartExSeriesDATAPT = 0; - BYTE c_oserct_chartExSeriesDATALABELS = 1; - BYTE c_oserct_chartExSeriesLAYOUTPROPS = 2; - BYTE c_oserct_chartExSeriesTEXT = 3; - BYTE c_oserct_chartExSeriesAXIS = 4; - BYTE c_oserct_chartExSeriesDATAID = 5; - BYTE c_oserct_chartExSeriesSPPR = 6; - BYTE c_oserct_chartExSeriesLAYOUTID = 7; - BYTE c_oserct_chartExSeriesHIDDEN = 8; - BYTE c_oserct_chartExSeriesOWNERIDX = 9; - BYTE c_oserct_chartExSeriesFORMATIDX = 10; - BYTE c_oserct_chartExSeriesUNIQUEID = 11; - - BYTE c_oserct_chartExDataPointIDX = 0; - BYTE c_oserct_chartExDataPointSPPR = 1; - - BYTE c_oserct_chartExDataLabelsPOS = 0; - BYTE c_oserct_chartExDataLabelsNUMFMT = 1; - BYTE c_oserct_chartExDataLabelsTXPR = 2; - BYTE c_oserct_chartExDataLabelsSPPR = 3; - BYTE c_oserct_chartExDataLabelsVISABILITIES = 4; - BYTE c_oserct_chartExDataLabelsSEPARATOR = 5; - BYTE c_oserct_chartExDataLabelsDATALABEL = 6; - BYTE c_oserct_chartExDataLabelsDATALABELHIDDEN = 7; - - BYTE c_oserct_chartExNumberFormatFORMATCODE = 0; - BYTE c_oserct_chartExNumberFormatSOURCELINKED = 1; - - BYTE c_oserct_chartExDataLabelIDX = 0; - BYTE c_oserct_chartExDataLabelPOS = 1; - BYTE c_oserct_chartExDataLabelNUMFMT = 2; - BYTE c_oserct_chartExDataLabelTXPR = 3; - BYTE c_oserct_chartExDataLabelSPPR = 4; - BYTE c_oserct_chartExDataLabelVISABILITIES = 5; - BYTE c_oserct_chartExDataLabelSEPARATOR = 6; - - BYTE c_oserct_chartExDataLabelHiddenIDX = 0; - - BYTE c_oserct_chartExSeriesLayoutPARENT = 0; - BYTE c_oserct_chartExSeriesLayoutREGION = 1; - BYTE c_oserct_chartExSeriesLayoutVISABILITIES = 2; - BYTE c_oserct_chartExSeriesLayoutAGGREGATION = 3; - BYTE c_oserct_chartExSeriesLayoutBINNING = 4; - BYTE c_oserct_chartExSeriesLayoutSTATISTIC = 5; - BYTE c_oserct_chartExSeriesLayoutSUBTOTALS = 6; - - BYTE c_oserct_chartExDataLabelVisibilitiesSERIES = 0; - BYTE c_oserct_chartExDataLabelVisibilitiesCATEGORY = 1; - BYTE c_oserct_chartExDataLabelVisibilitiesVALUE = 2; - - BYTE c_oserct_chartExBinningBINSIZE = 0; - BYTE c_oserct_chartExBinningBINCOUNT = 1; - BYTE c_oserct_chartExBinningINTERVAL = 2; - BYTE c_oserct_chartExBinningUNDERVAL = 3; - BYTE c_oserct_chartExBinningUNDERAUTO = 4; - BYTE c_oserct_chartExBinningOVERVAL = 5; - BYTE c_oserct_chartExBinningOVERAUTO = 6; - - BYTE c_oserct_chartExTitleTX = 0; - BYTE c_oserct_chartExTitleTXPR = 1; - BYTE c_oserct_chartExTitleSPPR = 2; - BYTE c_oserct_chartExTitlePOS = 3; - BYTE c_oserct_chartExTitleALIGN = 4; - BYTE c_oserct_chartExTitleOVERLAY = 5; - - BYTE c_oserct_chartExLegendTXPR = 0; - BYTE c_oserct_chartExLegendSPPR = 1; - BYTE c_oserct_chartExLegendPOS = 2; - BYTE c_oserct_chartExLegendALIGN = 3; - BYTE c_oserct_chartExLegendOVERLAY = 4; - - BYTE c_oserct_chartExTextRICH = 0; - BYTE c_oserct_chartExTextDATA = 1; - - BYTE c_oserct_chartExTextDataFORMULA = 0; - BYTE c_oserct_chartExTextDataVALUE = 1; - - BYTE c_oserct_chartExDataID = 0; - BYTE c_oserct_chartExDataSTRDIMENSION = 1; - BYTE c_oserct_chartExDataNUMDIMENSION = 2; - - BYTE c_oserct_chartExSubtotalsIDX = 0; - - BYTE c_oserct_chartExSeriesVisibilitiesCONNECTOR = 0; - BYTE c_oserct_chartExSeriesVisibilitiesMEANLINE = 1; - BYTE c_oserct_chartExSeriesVisibilitiesMEANMARKER = 2; - BYTE c_oserct_chartExSeriesVisibilitiesNONOUTLIERS = 3; - BYTE c_oserct_chartExSeriesVisibilitiesOUTLIERS = 4; - - BYTE c_oserct_chartExCatScalingGAPAUTO = 0; - BYTE c_oserct_chartExCatScalingGAPVAL = 1; - - BYTE c_oserct_chartExValScalingMAXAUTO = 0; - BYTE c_oserct_chartExValScalingMAXVAL = 1; - BYTE c_oserct_chartExValScalingMINAUTO = 2; - BYTE c_oserct_chartExValScalingMINVAL = 3; - BYTE c_oserct_chartExValScalingMAJUNITAUTO = 4; - BYTE c_oserct_chartExValScalingMAJUNITVAL = 5; - BYTE c_oserct_chartExValScalingMINUNITAUTO = 6; - BYTE c_oserct_chartExValScalingMINUNITVAL = 7; - - BYTE c_oserct_chartExAxisUnitTYPE = 0; - BYTE c_oserct_chartExAxisUnitLABEL = 1; - - BYTE c_oserct_chartExAxisUnitsLabelTEXT = 0; - BYTE c_oserct_chartExAxisUnitsLabelSPPR = 1; - BYTE c_oserct_chartExAxisUnitsLabelTXPR = 2; - - BYTE c_oserct_chartExTickMarksTYPE = 0; - - BYTE c_oserct_chartExGridlinesSPPR = 0; - - BYTE c_oserct_chartExStatisticsMETHOD = 0; - - BYTE c_oserct_chartExDataDimensionTYPE = 0; - BYTE c_oserct_chartExDataDimensionFORMULA = 1; - BYTE c_oserct_chartExDataDimensionNF = 2; - BYTE c_oserct_chartExDataDimensionSTRINGLEVEL = 3; - BYTE c_oserct_chartExDataDimensionNUMERICLEVEL = 4; - - BYTE c_oserct_chartExFormulaCONTENT = 0; - BYTE c_oserct_chartExFormulaDIRECTION = 1; - - BYTE c_oserct_chartExDataLevelNAME = 0; - BYTE c_oserct_chartExDataLevelCOUNT = 1; - BYTE c_oserct_chartExDataLevelPT = 2; - BYTE c_oserct_chartExDataLevelFORMATCODE = 3; - - BYTE c_oserct_chartExDataValueIDX = 0; - BYTE c_oserct_chartExDataValueCONTENT = 1; - BinaryChartReader::BinaryChartReader(NSBinPptxRW::CBinaryFileReader& oBufferedStream, SaveParams& oSaveParams, NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter) : Binary_CommonReader(oBufferedStream), m_oSaveParams(oSaveParams), m_pOfficeDrawingConverter(pOfficeDrawingConverter) {} @@ -1066,17 +864,17 @@ namespace BinXlsxRW res = c_oSerConstants::ReadUnknown; return res; } - int BinaryChartReader::ReadCT_ChartFile(long length, OOX::Spreadsheet::CChartFile* pChartFile) + int BinaryChartReader::ReadCT_ChartSpace(long length, OOX::Spreadsheet::CChartSpace* pChartSpace) { int res = c_oSerConstants::ReadOk; - READ1_DEF(length, res, this->ReadCT_ChartFileContent, pChartFile); + READ1_DEF(length, res, this->ReadCT_ChartSpace, pChartSpace); return res; } - int BinaryChartReader::ReadCT_ChartFileContent(BYTE type, long length, void* poResult) + int BinaryChartReader::ReadCT_ChartSpace(BYTE type, long length, void* poResult) { int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::CChartFile *pChart = static_cast(poResult); + OOX::Spreadsheet::CChartSpace *pChart = static_cast(poResult); if(c_oserct_chartspaceDATE1904 == type) { @@ -1104,8 +902,9 @@ namespace BinXlsxRW } else if(c_oserct_chartspaceSTYLE == type) { - pChart->m_oChartSpace.m_style = new CT_Style; - READ1_DEF(length, res, this->ReadCT_Style, pChart->m_oChartSpace.m_style); + CT_Style1* pNewElem = new CT_Style1; + READ1_DEF(length, res, this->ReadCT_Style1, pNewElem); + pChart->m_oChartSpace.m_style = pNewElem; } else if(c_oserct_chartspaceCLRMAPOVR == type) { @@ -1130,30 +929,37 @@ namespace BinXlsxRW } else if(c_oserct_chartspaceCHART == type) { - pChart->m_oChartSpace.m_chart = new CT_Chart; - READ1_DEF(length, res, this->ReadCT_Chart, pChart->m_oChartSpace.m_chart); + CT_Chart* pNewElem = new CT_Chart; + READ1_DEF(length, res, this->ReadCT_Chart, pNewElem); + pChart->m_oChartSpace.m_chart = pNewElem; } else if(c_oserct_chartspaceSPPR == type) { pChart->m_oChartSpace.m_oSpPr = new PPTX::Logic::SpPr; - pChart->m_oChartSpace.m_oSpPr->m_namespace = L"c"; - res = ReadCT_PptxElement(0, length, pChart->m_oChartSpace.m_oSpPr.GetPointer()); + res = ReadCT_SpPr(0, length, pChart->m_oChartSpace.m_oSpPr.GetPointer()); } else if(c_oserct_chartspaceTXPR == type) { pChart->m_oChartSpace.m_oTxPr = new PPTX::Logic::TxBody; - pChart->m_oChartSpace.m_oTxPr->m_name = L"c:txPr"; - res = ReadCT_PptxElement(0, length, pChart->m_oChartSpace.m_oTxPr.GetPointer()); + res = ReadCT_TxPr(0, length, pChart->m_oChartSpace.m_oTxPr.GetPointer()); } + //else if(c_oserct_chartspaceEXTERNALDATA == type) + //{ + // CT_ExternalData* pNewElem = new CT_ExternalData; + // READ1_DEF(length, res, this->ReadCT_ExternalData, pNewElem); + // pChart->m_oChartSpace.m_externalData = pNewElem; + //} else if(c_oserct_chartspacePRINTSETTINGS == type) { - pChart->m_oChartSpace.m_printSettings = new CT_PrintSettings; - READ1_DEF(length, res, this->ReadCT_PrintSettings, pChart->m_oChartSpace.m_printSettings); + CT_PrintSettings* pNewElem = new CT_PrintSettings; + READ1_DEF(length, res, this->ReadCT_PrintSettings, pNewElem); + pChart->m_oChartSpace.m_printSettings = pNewElem; } else if(c_oserct_chartspaceEXTLST == type) { - pChart->m_oChartSpace.m_extLst = new CT_extLst; - READ1_DEF(length, res, this->ReadCT_extLst, pChart->m_oChartSpace.m_extLst); + CT_extLst* pNewElem = new CT_extLst; + READ1_DEF(length, res, this->ReadCT_extLst, pNewElem); + pChart->m_oChartSpace.m_extLst = pNewElem; } else if(c_oserct_chartspaceTHEMEOVERRIDE == type) { @@ -1199,154 +1005,23 @@ namespace BinXlsxRW OOX::CChartDrawing* pChartDrawing = new OOX::CChartDrawing(NULL); READ1_DEF(length, res, this->ReadCT_userShapes, pChartDrawing); - OOX::CPath pathDrawingsRels = pathDrawingsRelsDir.GetPath() + FILE_SEPARATOR_STR + pChartDrawing->m_sOutputFilename + _T(".rels"); - m_pOfficeDrawingConverter->SaveDstContentRels(pathDrawingsRels.GetPath()); - - if (res == c_oSerConstants::ReadOk) - { - NSCommon::smart_ptr pDrawingFile(pChartDrawing); - pChart->Add(pDrawingFile); - - unsigned int rId = 0; - m_pOfficeDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartUserShapes", L"../drawings/" + pChartDrawing->m_sOutputFilename, std::wstring(), &rId); - - pChart->m_oChartSpace.m_userShapes = new CT_RelId; - pChart->m_oChartSpace.m_userShapes->m_id = new std::wstring; - *pChart->m_oChartSpace.m_userShapes->m_id = OOX::RId(rId).ToString(); - } - } - else if(c_oserct_chartspaceEXTERNALDATA == type) - { - if (!pChart->m_oChartSpace.m_externalData) - pChart->m_oChartSpace.m_externalData = new CT_ExternalData; + NSCommon::smart_ptr pDrawingFile(pChartDrawing); + pChart->Add(pDrawingFile); - READ1_DEF(length, res, this->ReadCT_ExternalData, pChart->m_oChartSpace.m_externalData); + OOX::CPath pathDrawingsRels = pathDrawingsRelsDir.GetPath() + FILE_SEPARATOR_STR + pChartDrawing->m_sOutputFilename + _T(".rels"); + m_pOfficeDrawingConverter->SaveDstContentRels(pathDrawingsRels.GetPath()); + + unsigned int rId = 0; + m_pOfficeDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartUserShapes", L"../drawings/" + pChartDrawing->m_sOutputFilename, std::wstring(), &rId); + + pChart->m_oChartSpace.m_userShapes = new CT_RelId; + pChart->m_oChartSpace.m_userShapes->m_id = new std::wstring; + *pChart->m_oChartSpace.m_userShapes->m_id = OOX::RId(rId).ToString(); } - else if (c_oserct_chartspaceXLSX == type) - { - OOX::CSystemUtility::CreateDirectories(m_oSaveParams.sEmbeddingsPath); - - OOX::CPath pathEmbeddingRelsDir = m_oSaveParams.sEmbeddingsPath + FILE_SEPARATOR_STR + _T("_rels"); - OOX::CSystemUtility::CreateDirectories(pathEmbeddingRelsDir.GetPath()); - - m_pOfficeDrawingConverter->SetDstContentRels(); - - NSCommon::smart_ptr pXlsxFile; - ReadCT_ExternalXlsx(m_oBufferedStream.GetPointer(0), length, pXlsxFile); - - m_oBufferedStream.Skip(length); - - if (pXlsxFile.IsInit()) - { - OOX::CPath pathDrawingsRels = pathEmbeddingRelsDir.GetPath() + FILE_SEPARATOR_STR + pXlsxFile->m_sOutputFilename + _T(".rels"); - m_pOfficeDrawingConverter->SaveDstContentRels(pathDrawingsRels.GetPath()); - - NSCommon::smart_ptr pFile = pXlsxFile.smart_dynamic_cast(); - pChart->Add(pFile); - - unsigned int rId = 0; - m_pOfficeDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/package", L"../embeddings/" + pXlsxFile->m_sOutputFilename, std::wstring(), &rId); - m_pOfficeDrawingConverter->m_pImageManager->m_pContentTypes->AddDefault(L"xlsx"); - - if (!pChart->m_oChartSpace.m_externalData) - pChart->m_oChartSpace.m_externalData = new CT_ExternalData; - - pChart->m_oChartSpace.m_externalData->m_id = new std::wstring; - *pChart->m_oChartSpace.m_externalData->m_id = OOX::RId(rId).ToString(); - } - } - else if (c_oserct_chartspaceSTYLES == type) - { - NSCommon::smart_ptr chartstyle = new OOX::Spreadsheet::CChartStyleFile(NULL); - READ1_DEF(length, res, ReadCT_ChartStyle, chartstyle.GetPointer()); - - if (res == c_oSerConstants::ReadOk) - { - NSCommon::smart_ptr pFile = chartstyle.smart_dynamic_cast(); - pChart->Add(pFile); - - unsigned int rId = 0; - m_pOfficeDrawingConverter->WriteRels(L"http://schemas.microsoft.com/office/2011/relationships/chartStyle", chartstyle->m_sOutputFilename, std::wstring(), &rId); - } - } - else if (c_oserct_chartspaceCOLORS == type) - { - NSCommon::smart_ptr chartcolors = new OOX::Spreadsheet::CChartColorsFile(NULL); - READ1_DEF(length, res, ReadCT_ChartColors, chartcolors.GetPointer()); - - if (res == c_oSerConstants::ReadOk) - { - NSCommon::smart_ptr pFile = chartcolors.smart_dynamic_cast(); - pChart->Add(pFile); - - unsigned int rId = 0; - m_pOfficeDrawingConverter->WriteRels(L"http://schemas.microsoft.com/office/2011/relationships/chartColorStyle", chartcolors->m_sOutputFilename, std::wstring(), &rId); - } - } - else res = c_oSerConstants::ReadUnknown; return res; } - int BinaryChartReader::ReadCT_ExternalXlsx(BYTE *pData, long length, NSCommon::smart_ptr & file) - { - if (length < 1 || !pData) - return c_oSerConstants::ReadUnknown; - //------------------------------------------------------------------ - std::wstring sDstEmbedded = m_oSaveParams.sEmbeddingsPath; - - std::wstring sDstEmbeddedTemp = NSDirectory::CreateDirectoryWithUniqueName(sDstEmbedded); - { - file = new OOX::OleObject(NULL, true, m_pOfficeDrawingConverter->m_pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX); - - int id = m_pOfficeDrawingConverter->m_pReader->m_nCountEmbedded++; - - OOX::Spreadsheet::CXlsx oXlsx; - BinXlsxRW::BinaryFileReader oEmbeddedReader; - NSBinPptxRW::CDrawingConverter oDrawingConverter; - - std::wstring sDrawingsPath = sDstEmbeddedTemp + FILE_SEPARATOR_STR + L"xl" + FILE_SEPARATOR_STR + L"drawings"; - std::wstring sThemePath = sDstEmbeddedTemp + FILE_SEPARATOR_STR + L"xl" + FILE_SEPARATOR_STR + L"theme"; - std::wstring sEmbeddingsPath = sDstEmbeddedTemp + FILE_SEPARATOR_STR + L"xl" + FILE_SEPARATOR_STR + L"embeddings"; - - BinXlsxRW::SaveParams oSaveParams(sDrawingsPath, sEmbeddingsPath, sThemePath, oDrawingConverter.GetContentTypes()); - - std::wstring sXmlOptions, sMediaPath, sEmbedPath; - BinXlsxRW::CXlsxSerializer::CreateXlsxFolders(sXmlOptions, sDstEmbeddedTemp, sMediaPath, sEmbedPath); - - boost::unordered_map old_enum_map = oXlsx.m_mapEnumeratedGlobal; - - oXlsx.m_mapEnumeratedGlobal.clear(); - - oDrawingConverter.m_pReader->Init(pData, 0, length); - - oDrawingConverter.SetDstPath(sDstEmbeddedTemp + FILE_SEPARATOR_STR + L"xl"); - oDrawingConverter.SetSrcPath(m_pOfficeDrawingConverter->m_pReader->m_strFolder, 2); - - oDrawingConverter.SetMediaDstPath(sMediaPath); - oDrawingConverter.SetEmbedDstPath(sEmbedPath); - - std::wstring sXlsxFilename = L"Microsoft_Excel_Worksheet" + std::to_wstring(id) + L".xlsx"; - oEmbeddedReader.ReadMainTable(oXlsx, *oDrawingConverter.m_pReader, m_pOfficeDrawingConverter->m_pReader->m_strFolder, sDstEmbeddedTemp, oSaveParams, &oDrawingConverter); - - oXlsx.PrepareToWrite(); - - oXlsx.Write(sDstEmbeddedTemp, *oSaveParams.pContentTypes); - - COfficeUtils oOfficeUtils(NULL); - oOfficeUtils.CompressFileOrDirectory(sDstEmbeddedTemp, sDstEmbedded + FILE_SEPARATOR_STR + sXlsxFilename, true); - - oXlsx.m_mapEnumeratedGlobal = old_enum_map; - - file->set_filename(sDstEmbedded + FILE_SEPARATOR_STR + sXlsxFilename, false); - - m_pOfficeDrawingConverter->m_pReader->m_pRels->m_pManager->m_pContentTypes->AddDefault(L"xlsx"); - } - NSDirectory::DeleteDirectory(sDstEmbeddedTemp); - - return c_oSerConstants::ReadOk; - } - int BinaryChartReader::ReadCT_Boolean(BYTE type, long length, void* poResult) { int res = c_oSerConstants::ReadOk; @@ -1361,12 +1036,13 @@ namespace BinXlsxRW res = c_oSerConstants::ReadUnknown; return res; } - int BinaryChartReader::ReadCT_PptxElement(BYTE type, long length, void* poResult) + int BinaryChartReader::ReadCT_SpPr(BYTE type, long length, void* poResult) { int res = c_oSerConstants::ReadOk; - PPTX::WrapperWritingElement* poVal = static_cast(poResult); - if (length > 0) + PPTX::Logic::SpPr* poVal = static_cast(poResult); + if(length > 0) { + poVal->m_namespace = L"c"; long nCurPos = m_oBufferedStream.GetPos(); BYTE typeRec1 = m_oBufferedStream.GetUChar(); @@ -1376,6 +1052,23 @@ namespace BinXlsxRW } return res; } + int BinaryChartReader::ReadCT_TxPr(BYTE type, long length, void* poResult) + { + int res = c_oSerConstants::ReadOk; + PPTX::Logic::TxBody* poVal = static_cast(poResult); + if(length > 0) + { + poVal->m_name = L"c:txPr"; + long nCurPos = m_oBufferedStream.GetPos(); + + BYTE typeRec1 = m_oBufferedStream.GetUChar(); + poVal->fromPPTY(&m_oBufferedStream); + + m_oBufferedStream.Seek(nCurPos + length); + } + return res; + } + int BinaryChartReader::ReadCT_userShapes(BYTE type, long length, void* poResult) { int res = c_oSerConstants::ReadOk; @@ -1695,6 +1388,13 @@ namespace BinXlsxRW READ1_DEF(length, res, this->ReadCT_Boolean, pNewElem); poVal->m_autoUpdate = pNewElem; } + else if(c_oserct_externaldataID == type) + { + std::wstring* pNewElem = new std::wstring; + //todo + *pNewElem = m_oBufferedStream.GetString4(length); + poVal->m_id = pNewElem; + } else res = c_oSerConstants::ReadUnknown; return res; @@ -1707,6 +1407,7 @@ namespace BinXlsxRW { ST_DispBlanksAs* pNewElem = new ST_DispBlanksAs; *pNewElem = (ST_DispBlanksAs)m_oBufferedStream.GetUChar(); + ; poVal->m_val = pNewElem; } else @@ -1732,8 +1433,7 @@ namespace BinXlsxRW else if(c_oserct_legendentryTXPR == type) { poVal->m_oTxPr = new PPTX::Logic::TxBody; - poVal->m_oTxPr->m_name = L"c:txPr"; - res = ReadCT_PptxElement(0, length, poVal->m_oTxPr.GetPointer()); + res = ReadCT_TxPr(0, length, poVal->m_oTxPr.GetPointer()); } else if(c_oserct_legendentryEXTLST == type) { @@ -1825,14 +1525,12 @@ namespace BinXlsxRW else if(c_oserct_legendSPPR == type) { poVal->m_oSpPr = new PPTX::Logic::SpPr; - poVal->m_oSpPr->m_namespace = L"c"; - ReadCT_PptxElement(0, length, poVal->m_oSpPr.GetPointer()); + ReadCT_SpPr(0, length, poVal->m_oSpPr.GetPointer()); } else if(c_oserct_legendTXPR == type) { poVal->m_oTxPr = new PPTX::Logic::TxBody; - poVal->m_oTxPr->m_name = L"c:txPr"; - res = ReadCT_PptxElement(0, length, poVal->m_oTxPr.GetPointer()); + res = ReadCT_TxPr(0, length, poVal->m_oTxPr.GetPointer()); } else if(c_oserct_legendEXTLST == type) { @@ -2007,14 +1705,12 @@ namespace BinXlsxRW else if(c_oserct_dtableSPPR == type) { poVal->m_oSpPr = new PPTX::Logic::SpPr; - poVal->m_oSpPr->m_namespace = L"c"; - ReadCT_PptxElement(0, length, poVal->m_oSpPr.GetPointer()); + ReadCT_SpPr(0, length, poVal->m_oSpPr.GetPointer()); } else if(c_oserct_dtableTXPR == type) { poVal->m_oTxPr = new PPTX::Logic::TxBody; - poVal->m_oTxPr->m_name = L"c:txPr"; - res = ReadCT_PptxElement(0, length, poVal->m_oTxPr.GetPointer()); + res = ReadCT_TxPr(0, length, poVal->m_oTxPr.GetPointer()); } else if(c_oserct_dtableEXTLST == type) { @@ -2099,14 +1795,12 @@ namespace BinXlsxRW else if(c_oserct_seraxSPPR == type) { poVal->m_oSpPr = new PPTX::Logic::SpPr; - poVal->m_oSpPr->m_namespace = L"c"; - ReadCT_PptxElement(0, length, poVal->m_oSpPr.GetPointer()); + ReadCT_SpPr(0, length, poVal->m_oSpPr.GetPointer()); } else if(c_oserct_seraxTXPR == type) { poVal->m_oTxPr = new PPTX::Logic::TxBody; - poVal->m_oTxPr->m_name = L"c:txPr"; - res = ReadCT_PptxElement(0, length, poVal->m_oTxPr.GetPointer()); + res = ReadCT_TxPr(0, length, poVal->m_oTxPr.GetPointer()); } else if(c_oserct_seraxCROSSAX == type) { @@ -2237,8 +1931,7 @@ namespace BinXlsxRW if(c_oserct_chartlinesSPPR == type) { poVal->m_oSpPr = new PPTX::Logic::SpPr; - poVal->m_oSpPr->m_namespace = L"c"; - ReadCT_PptxElement(0, length, poVal->m_oSpPr.GetPointer()); + ReadCT_SpPr(0, length, poVal->m_oSpPr.GetPointer()); } else res = c_oSerConstants::ReadUnknown; @@ -2269,14 +1962,12 @@ namespace BinXlsxRW else if(c_oserct_titleSPPR == type) { poVal->m_oSpPr = new PPTX::Logic::SpPr; - poVal->m_oSpPr->m_namespace = L"c"; - ReadCT_PptxElement(0, length, poVal->m_oSpPr.GetPointer()); + ReadCT_SpPr(0, length, poVal->m_oSpPr.GetPointer()); } else if(c_oserct_titleTXPR == type) { poVal->m_oTxPr = new PPTX::Logic::TxBody; - poVal->m_oTxPr->m_name = L"c:txPr"; - res = ReadCT_PptxElement(0, length, poVal->m_oTxPr.GetPointer()); + res = ReadCT_TxPr(0, length, poVal->m_oTxPr.GetPointer()); } else if(c_oserct_titleEXTLST == type) { @@ -2550,14 +2241,12 @@ namespace BinXlsxRW else if(c_oserct_dateaxSPPR == type) { poVal->m_oSpPr = new PPTX::Logic::SpPr; - poVal->m_oSpPr->m_namespace = L"c"; - ReadCT_PptxElement(0, length, poVal->m_oSpPr.GetPointer()); + ReadCT_SpPr(0, length, poVal->m_oSpPr.GetPointer()); } else if(c_oserct_dateaxTXPR == type) { poVal->m_oTxPr = new PPTX::Logic::TxBody; - poVal->m_oTxPr->m_name = L"c:txPr"; - res = ReadCT_PptxElement(0, length, poVal->m_oTxPr.GetPointer()); + res = ReadCT_TxPr(0, length, poVal->m_oTxPr.GetPointer()); } else if(c_oserct_dateaxCROSSAX == type) { @@ -2745,14 +2434,12 @@ namespace BinXlsxRW else if(c_oserct_cataxSPPR == type) { poVal->m_oSpPr = new PPTX::Logic::SpPr; - poVal->m_oSpPr->m_namespace = L"c"; - ReadCT_PptxElement(0, length, poVal->m_oSpPr.GetPointer()); + ReadCT_SpPr(0, length, poVal->m_oSpPr.GetPointer()); } else if(c_oserct_cataxTXPR == type) { poVal->m_oTxPr = new PPTX::Logic::TxBody; - poVal->m_oTxPr->m_name = L"c:txPr"; - res = ReadCT_PptxElement(0, length, poVal->m_oTxPr.GetPointer()); + res = ReadCT_TxPr(0, length, poVal->m_oTxPr.GetPointer()); } else if(c_oserct_cataxCROSSAX == type) { @@ -2837,14 +2524,12 @@ namespace BinXlsxRW else if(c_oserct_dispunitslblSPPR == type) { poVal->m_oSpPr = new PPTX::Logic::SpPr; - poVal->m_oSpPr->m_namespace = L"c"; - ReadCT_PptxElement(0, length, poVal->m_oSpPr.GetPointer()); + ReadCT_SpPr(0, length, poVal->m_oSpPr.GetPointer()); } else if(c_oserct_dispunitslblTXPR == type) { poVal->m_oTxPr = new PPTX::Logic::TxBody; - poVal->m_oTxPr->m_name = L"c:txPr"; - res = ReadCT_PptxElement(0, length, poVal->m_oTxPr.GetPointer()); + res = ReadCT_TxPr(0, length, poVal->m_oTxPr.GetPointer()); } else res = c_oSerConstants::ReadUnknown; @@ -2985,14 +2670,12 @@ namespace BinXlsxRW else if(c_oserct_valaxSPPR == type) { poVal->m_oSpPr = new PPTX::Logic::SpPr; - poVal->m_oSpPr->m_namespace = L"c"; - ReadCT_PptxElement(0, length, poVal->m_oSpPr.GetPointer()); + ReadCT_SpPr(0, length, poVal->m_oSpPr.GetPointer()); } else if(c_oserct_valaxTXPR == type) { poVal->m_oTxPr = new PPTX::Logic::TxBody; - poVal->m_oTxPr->m_name = L"c:txPr"; - res = ReadCT_PptxElement(0, length, poVal->m_oTxPr.GetPointer()); + res = ReadCT_TxPr(0, length, poVal->m_oTxPr.GetPointer()); } else if(c_oserct_valaxCROSSAX == type) { @@ -3100,8 +2783,7 @@ namespace BinXlsxRW else if(c_oserct_bubbleserSPPR == type) { poVal->m_oSpPr = new PPTX::Logic::SpPr; - poVal->m_oSpPr->m_namespace = L"c"; - ReadCT_PptxElement(0, length, poVal->m_oSpPr.GetPointer()); + ReadCT_SpPr(0, length, poVal->m_oSpPr.GetPointer()); } else if(c_oserct_bubbleserINVERTIFNEGATIVE == type) { @@ -3224,8 +2906,7 @@ namespace BinXlsxRW else if(c_oserct_dptSPPR == type) { poVal->m_oSpPr = new PPTX::Logic::SpPr; - poVal->m_oSpPr->m_namespace = L"c"; - ReadCT_PptxElement(0, length, poVal->m_oSpPr.GetPointer()); + ReadCT_SpPr(0, length, poVal->m_oSpPr.GetPointer()); } else if(c_oserct_dptPICTUREOPTIONS == type) { @@ -3262,8 +2943,7 @@ namespace BinXlsxRW else if(c_oserct_markerSPPR == type) { poVal->m_oSpPr = new PPTX::Logic::SpPr; - poVal->m_oSpPr->m_namespace = L"c"; - ReadCT_PptxElement(0, length, poVal->m_oSpPr.GetPointer()); + ReadCT_SpPr(0, length, poVal->m_oSpPr.GetPointer()); } else if(c_oserct_markerEXTLST == type) { @@ -3497,8 +3177,7 @@ namespace BinXlsxRW poVal->m_ItemsElementName0.push_back(eElemtype); PPTX::Logic::SpPr * pNewElem = new PPTX::Logic::SpPr(); - pNewElem->m_namespace = L"c"; - res = ReadCT_PptxElement(0, length, pNewElem); + res = ReadCT_SpPr(0, length, pNewElem); poVal->m_Items.push_back(pNewElem); } else if(c_oserct_dlblsTXPR == type) @@ -3508,8 +3187,7 @@ namespace BinXlsxRW poVal->m_ItemsElementName0.push_back(eElemtype); PPTX::Logic::TxBody * pNewElem = new PPTX::Logic::TxBody(); - pNewElem->m_name = L"c:txPr"; - res = ReadCT_PptxElement(0, length, pNewElem); + res = ReadCT_TxPr(0, length, pNewElem); poVal->m_Items.push_back(pNewElem); } else if(c_oserct_dlblsEXTLST == type) @@ -3638,8 +3316,7 @@ namespace BinXlsxRW poVal->m_ItemsElementName0.push_back(eElemtype); PPTX::Logic::SpPr *pNewElem = new PPTX::Logic::SpPr; - pNewElem->m_namespace = L"c"; - res = ReadCT_PptxElement(0, length, pNewElem); + res = ReadCT_SpPr(0, length, pNewElem); poVal->m_Items.push_back(pNewElem); } else if(c_oserct_dlblTX == type) @@ -3658,8 +3335,7 @@ namespace BinXlsxRW poVal->m_ItemsElementName0.push_back(eElemtype); PPTX::Logic::TxBody * pNewElem = new PPTX::Logic::TxBody(); - pNewElem->m_name = L"c:txPr"; - res = ReadCT_PptxElement(0, length, pNewElem); + res = ReadCT_TxPr(0, length, pNewElem); poVal->m_Items.push_back(pNewElem); } else if(c_oserct_dlblEXTLST == type) @@ -3700,8 +3376,7 @@ namespace BinXlsxRW else if(c_oserct_trendlineSPPR == type) { poVal->m_oSpPr = new PPTX::Logic::SpPr; - poVal->m_oSpPr->m_namespace = L"c"; - res = ReadCT_PptxElement(0, length, poVal->m_oSpPr.GetPointer()); + ReadCT_SpPr(0, length, poVal->m_oSpPr.GetPointer()); } else if(c_oserct_trendlineTRENDLINETYPE == type) { @@ -3835,14 +3510,12 @@ namespace BinXlsxRW else if(c_oserct_trendlinelblSPPR == type) { poVal->m_oSpPr = new PPTX::Logic::SpPr; - poVal->m_oSpPr->m_namespace = L"c"; - res = ReadCT_PptxElement(0, length, poVal->m_oSpPr.GetPointer()); + ReadCT_SpPr(0, length, poVal->m_oSpPr.GetPointer()); } else if(c_oserct_trendlinelblTXPR == type) { poVal->m_oTxPr = new PPTX::Logic::TxBody; - poVal->m_oTxPr->m_name = L"c:txPr"; - res = ReadCT_PptxElement(0, length, poVal->m_oTxPr.GetPointer()); + res = ReadCT_TxPr(0, length, poVal->m_oTxPr.GetPointer()); } else if(c_oserct_trendlinelblEXTLST == type) { @@ -3903,8 +3576,7 @@ namespace BinXlsxRW else if(c_oserct_errbarsSPPR == type) { poVal->m_oSpPr = new PPTX::Logic::SpPr; - poVal->m_oSpPr->m_namespace = L"c"; - res = ReadCT_PptxElement(0, length, poVal->m_oSpPr.GetPointer()); + ReadCT_SpPr(0, length, poVal->m_oSpPr.GetPointer()); } else if(c_oserct_errbarsEXTLST == type) { @@ -4308,8 +3980,7 @@ namespace BinXlsxRW else if(c_oserct_surfaceserSPPR == type) { poVal->m_oSpPr = new PPTX::Logic::SpPr; - poVal->m_oSpPr->m_namespace = L"c"; - res = ReadCT_PptxElement(0, length, poVal->m_oSpPr.GetPointer()); + ReadCT_SpPr(0, length, poVal->m_oSpPr.GetPointer()); } else if(c_oserct_surfaceserCAT == type) { @@ -4346,8 +4017,7 @@ namespace BinXlsxRW else if(c_oserct_bandfmtSPPR == type) { poVal->m_oSpPr = new PPTX::Logic::SpPr; - poVal->m_oSpPr->m_namespace = L"c"; - res = ReadCT_PptxElement(0, length, poVal->m_oSpPr.GetPointer()); + ReadCT_SpPr(0, length, poVal->m_oSpPr.GetPointer()); } else res = c_oSerConstants::ReadUnknown; @@ -4548,8 +4218,7 @@ namespace BinXlsxRW else if(c_oserct_pieserSPPR == type) { poVal->m_oSpPr = new PPTX::Logic::SpPr; - poVal->m_oSpPr->m_namespace = L"c"; - res = ReadCT_PptxElement(0, length, poVal->m_oSpPr.GetPointer()); + ReadCT_SpPr(0, length, poVal->m_oSpPr.GetPointer()); } else if(c_oserct_pieserEXPLOSION == type) { @@ -4728,8 +4397,7 @@ namespace BinXlsxRW else if(c_oserct_barserSPPR == type) { poVal->m_oSpPr = new PPTX::Logic::SpPr; - poVal->m_oSpPr->m_namespace = L"c"; - res = ReadCT_PptxElement(0, length, poVal->m_oSpPr.GetPointer()); + ReadCT_SpPr(0, length, poVal->m_oSpPr.GetPointer()); } else if(c_oserct_barserINVERTIFNEGATIVE == type) { @@ -5059,8 +4727,7 @@ namespace BinXlsxRW else if(c_oserct_scatterserSPPR == type) { poVal->m_oSpPr = new PPTX::Logic::SpPr; - poVal->m_oSpPr->m_namespace = L"c"; - res = ReadCT_PptxElement(0, length, poVal->m_oSpPr.GetPointer()); + ReadCT_SpPr(0, length, poVal->m_oSpPr.GetPointer()); } else if(c_oserct_scatterserMARKER == type) { @@ -5204,8 +4871,7 @@ namespace BinXlsxRW else if(c_oserct_radarserSPPR == type) { poVal->m_oSpPr = new PPTX::Logic::SpPr; - poVal->m_oSpPr->m_namespace = L"c"; - res = ReadCT_PptxElement(0, length, poVal->m_oSpPr.GetPointer()); + ReadCT_SpPr(0, length, poVal->m_oSpPr.GetPointer()); } else if(c_oserct_radarserMARKER == type) { @@ -5381,8 +5047,7 @@ namespace BinXlsxRW else if(c_oserct_lineserSPPR == type) { poVal->m_oSpPr = new PPTX::Logic::SpPr; - poVal->m_oSpPr->m_namespace = L"c"; - res = ReadCT_PptxElement(0, length, poVal->m_oSpPr.GetPointer()); + ReadCT_SpPr(0, length, poVal->m_oSpPr.GetPointer()); } else if(c_oserct_lineserMARKER == type) { @@ -5481,8 +5146,7 @@ namespace BinXlsxRW if(c_oserct_updownbarSPPR == type) { poVal->m_oSpPr = new PPTX::Logic::SpPr; - poVal->m_oSpPr->m_namespace = L"c"; - res = ReadCT_PptxElement(0, length, poVal->m_oSpPr.GetPointer()); + ReadCT_SpPr(0, length, poVal->m_oSpPr.GetPointer()); } else res = c_oSerConstants::ReadUnknown; @@ -5714,8 +5378,7 @@ namespace BinXlsxRW else if(c_oserct_areaserSPPR == type) { poVal->m_oSpPr = new PPTX::Logic::SpPr; - poVal->m_oSpPr->m_namespace = L"c"; - res = ReadCT_PptxElement(0, length, poVal->m_oSpPr.GetPointer()); + ReadCT_SpPr(0, length, poVal->m_oSpPr.GetPointer()); } else if(c_oserct_areaserPICTUREOPTIONS == type) { @@ -6018,8 +5681,7 @@ namespace BinXlsxRW else if(c_oserct_plotareaSPPR == type) { poVal->m_oSpPr = new PPTX::Logic::SpPr; - poVal->m_oSpPr->m_namespace = L"c"; - res = ReadCT_PptxElement(0, length, poVal->m_oSpPr.GetPointer()); + ReadCT_SpPr(0, length, poVal->m_oSpPr.GetPointer()); } else if(c_oserct_plotareaEXTLST == type) { @@ -6058,8 +5720,7 @@ namespace BinXlsxRW else if(c_oserct_surfaceSPPR == type) { poVal->m_oSpPr = new PPTX::Logic::SpPr; - poVal->m_oSpPr->m_namespace = L"c"; - res = ReadCT_PptxElement(0, length, poVal->m_oSpPr.GetPointer()); + ReadCT_SpPr(0, length, poVal->m_oSpPr.GetPointer()); } else if(c_oserct_surfacePICTUREOPTIONS == type) { @@ -6210,14 +5871,12 @@ namespace BinXlsxRW else if(c_oserct_pivotfmtSPPR == type) { poVal->m_oSpPr = new PPTX::Logic::SpPr; - poVal->m_oSpPr->m_namespace = L"c"; - res = ReadCT_PptxElement(0, length, poVal->m_oSpPr.GetPointer()); + ReadCT_SpPr(0, length, poVal->m_oSpPr.GetPointer()); } else if(c_oserct_pivotfmtTXPR == type) { poVal->m_oTxPr = new PPTX::Logic::TxBody; - poVal->m_oTxPr->m_name = L"c:txPr"; - res = ReadCT_PptxElement(0, length, poVal->m_oTxPr.GetPointer()); + res = ReadCT_TxPr(0, length, poVal->m_oTxPr.GetPointer()); } else if(c_oserct_pivotfmtMARKER == type) { @@ -6405,6 +6064,20 @@ namespace BinXlsxRW res = c_oSerConstants::ReadUnknown; return res; } + int BinaryChartReader::ReadCT_Style1(BYTE type, long length, void* poResult) + { + int res = c_oSerConstants::ReadOk; + CT_Style1* poVal = static_cast(poResult); + if(c_oserct_style1VAL == type) + { + unsigned char* pNewElem = new unsigned char; + *pNewElem = m_oBufferedStream.GetUChar(); + poVal->m_val = pNewElem; + } + else + res = c_oSerConstants::ReadUnknown; + return res; + } int BinaryChartReader::ReadCT_Style(BYTE type, long length, void* poResult) { int res = c_oSerConstants::ReadOk; @@ -6459,13 +6132,15 @@ namespace BinXlsxRW AlternateContentChoice* poVal = static_cast(poResult); if(c_oseralternatecontentchoiceSTYLE == type) { - poVal->m_style = new CT_Style; - READ1_DEF(length, res, this->ReadCT_Style, poVal->m_style); + CT_Style* pNewElem = new CT_Style; + READ1_DEF(length, res, this->ReadCT_Style, pNewElem); + poVal->m_style = pNewElem; } else if(c_oseralternatecontentchoiceREQUIRES == type) { - poVal->m_Requires = new std::wstring; - *poVal->m_Requires = m_oBufferedStream.GetString4(length); + std::wstring* pNewElem = new std::wstring; + *pNewElem = m_oBufferedStream.GetString4(length); + poVal->m_Requires = pNewElem; } else res = c_oSerConstants::ReadUnknown; @@ -6477,1241 +6152,14 @@ namespace BinXlsxRW AlternateContentFallback* poVal = static_cast(poResult); if(c_oseralternatecontentfallbackSTYLE == type) { - poVal->m_style = new CT_Style; - READ1_DEF(length, res, this->ReadCT_Style, poVal->m_style); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartColors(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::CChartColorsFile* poVal = static_cast(poResult); - - if (c_oserct_chartcolorsID == type) - { - poVal->m_oColorStyle.m_id = m_oBufferedStream.GetULong(); - } - else if (c_oserct_chartcolorsMETH == type) - { - poVal->m_oColorStyle.m_meth = m_oBufferedStream.GetString4(length); - } - else if (c_oserct_chartcolorsVARIATION == type) - { - OOX::Spreadsheet::ChartEx::CVariation *pVariation = new OOX::Spreadsheet::ChartEx::CVariation(); - - READ1_DEF(length, res, this->ReadCT_ColorsVariation, pVariation); - poVal->m_oColorStyle.m_arrItems.push_back(pVariation); - } - else if (c_oserct_chartcolorsCOLOR == type) - { - PPTX::Logic::UniColor *pColor = new PPTX::Logic::UniColor(); - - ReadCT_PptxElement(0, length, pColor); - poVal->m_oColorStyle.m_arrItems.push_back(pColor); + CT_Style1* pNewElem = new CT_Style1; + READ1_DEF(length, res, this->ReadCT_Style1, pNewElem); + poVal->m_style = pNewElem; } else res = c_oSerConstants::ReadUnknown; return res; } - int BinaryChartReader::ReadCT_ColorsVariation(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CVariation * poVal = static_cast(poResult); - - if (c_oserct_chartcolorsEFFECT == type) - { - PPTX::Logic::ColorModifier *pEffect = new PPTX::Logic::ColorModifier(); - - ReadCT_PptxElement(0, length, pEffect); - poVal->m_arrItems.push_back(pEffect); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartStyle(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::CChartStyleFile* poVal = static_cast(poResult); - - if (c_oserct_chartstyleID == type) - { - poVal->m_oChartStyle.m_id = m_oBufferedStream.GetULong(); - } - else if (c_oserct_chartstyleENTRY == type) - { - poVal->m_oChartStyle.m_arStyleEntries.push_back(new OOX::Spreadsheet::ChartEx::CStyleEntry()); - READ1_DEF(length, res, this->ReadCT_StyleEntry, poVal->m_oChartStyle.m_arStyleEntries.back()); - } - else if (c_oserct_chartstyleMARKERLAYOUT == type) - { - poVal->m_oChartStyle.m_dataPointMarkerLayout = new OOX::Spreadsheet::ChartEx::CMarkerLayout(); - READ1_DEF(length, res, this->ReadCT_StyleMarkerLayout, poVal->m_oChartStyle.m_dataPointMarkerLayout.GetPointer()); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_StyleEntry(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CStyleEntry* poVal = static_cast(poResult); - - if (c_oserct_chartstyleENTRYTYPE == type) - { - poVal->setTypeStyleEntry(m_oBufferedStream.GetUChar()); - } - else if (c_oserct_chartstyleLNREF == type) - { - poVal->m_lnRef.m_name = L"cs:lnRef"; - res = ReadCT_PptxElement(0, length, &poVal->m_lnRef); - } - else if (c_oserct_chartstyleFILLREF == type) - { - poVal->m_fillRef.m_name = L"cs:fillRef"; - res = ReadCT_PptxElement(0, length, &poVal->m_fillRef); - } - else if (c_oserct_chartstyleEFFECTREF == type) - { - poVal->m_effectRef.m_name = L"cs:effectRef"; - res = ReadCT_PptxElement(0, length, &poVal->m_effectRef); - } - else if (c_oserct_chartstyleFONTREF == type) - { - poVal->m_fontRef.m_name = L"cs:fontRef"; - res = ReadCT_PptxElement(0, length, &poVal->m_fontRef); - } - else if (c_oserct_chartstyleDEFPR == type) - { - poVal->m_defRPr = new PPTX::Logic::RunProperties(); - poVal->m_defRPr->m_name = L"cs:defPr"; - res = ReadCT_PptxElement(0, length, poVal->m_defRPr.GetPointer()); - } - else if (c_oserct_chartstyleBODYPR == type) - { - poVal->m_bodyPr = new PPTX::Logic::BodyPr(); - poVal->m_bodyPr->m_namespace = L"cs"; - res = ReadCT_PptxElement(0, length, poVal->m_bodyPr.GetPointer()); - } - else if (c_oserct_chartstyleSPPR == type) - { - poVal->m_spPr = new PPTX::Logic::SpPr(); - poVal->m_spPr->m_namespace = L"cs"; - res = ReadCT_PptxElement(0, length, poVal->m_spPr.GetPointer()); - } - else if (c_oserct_chartstyleLINEWIDTH == type) - { - poVal->m_lineWidthScale = m_oBufferedStream.GetULong(); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_StyleMarkerLayout(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CMarkerLayout* poVal = static_cast(poResult); - - if (c_oserct_chartstyleMARKERSYMBOL == type) - { - poVal->m_symbol = (SimpleTypes::Spreadsheet::EChartSymbol)m_oBufferedStream.GetUChar(); - } - else if (c_oserct_chartstyleMARKERSIZE == type) - { - poVal->m_size = m_oBufferedStream.GetULong(); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExFile(long length, OOX::Spreadsheet::CChartExFile* pChartExFile) - { - int res = c_oSerConstants::ReadOk; - READ1_DEF(length, res, this->ReadCT_ChartExFileContent, pChartExFile); - return res; - } - int BinaryChartReader::ReadCT_ChartExFileContent(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::CChartExFile *pChart = static_cast(poResult); - - if (c_oserct_chartExSpaceCHART == type) - { - READ1_DEF(length, res, this->ReadCT_ChartExChart, &pChart->m_oChartSpace.m_chart); - } - else if (c_oserct_chartExSpaceCHARTDATA == type) - { - READ1_DEF(length, res, this->ReadCT_ChartExChartData, &pChart->m_oChartSpace.m_chartData); - } - else if (c_oserct_chartExSpaceCLRMAPOVR == type) - { - BYTE typeRec1 = m_oBufferedStream.GetUChar(); - - pChart->m_oChartSpace.m_oClrMapOvr = new PPTX::Logic::ClrMap(); - - pChart->m_oChartSpace.m_oClrMapOvr->m_name = L"cx:clrMapOvr"; - pChart->m_oChartSpace.m_oClrMapOvr->fromPPTY(&m_oBufferedStream); - } - else if (c_oserct_chartExSpaceSPPR == type) - { - pChart->m_oChartSpace.m_oSpPr = new PPTX::Logic::SpPr; - pChart->m_oChartSpace.m_oSpPr->m_namespace = L"cx"; - res = ReadCT_PptxElement(0, length, pChart->m_oChartSpace.m_oSpPr.GetPointer()); - } - else if (c_oserct_chartExSpaceTXPR == type) - { - pChart->m_oChartSpace.m_oTxPr = new PPTX::Logic::TxBody; - pChart->m_oChartSpace.m_oTxPr->m_name = L"cx:txPr"; - res = ReadCT_PptxElement(0, length, pChart->m_oChartSpace.m_oTxPr.GetPointer()); - } - else if (c_oserct_chartspaceXLSX == type) - { - OOX::CSystemUtility::CreateDirectories(m_oSaveParams.sEmbeddingsPath); - - OOX::CPath pathEmbeddingRelsDir = m_oSaveParams.sEmbeddingsPath + FILE_SEPARATOR_STR + _T("_rels"); - OOX::CSystemUtility::CreateDirectories(pathEmbeddingRelsDir.GetPath()); - - m_pOfficeDrawingConverter->SetDstContentRels(); - - NSCommon::smart_ptr pXlsxFile; - ReadCT_ExternalXlsx(m_oBufferedStream.GetPointer(0), length, pXlsxFile); - - m_oBufferedStream.Skip(length); - - if (pXlsxFile.IsInit()) - { - OOX::CPath pathDrawingsRels = pathEmbeddingRelsDir.GetPath() + FILE_SEPARATOR_STR + pXlsxFile->m_sOutputFilename + _T(".rels"); - m_pOfficeDrawingConverter->SaveDstContentRels(pathDrawingsRels.GetPath()); - - NSCommon::smart_ptr pFile = pXlsxFile.smart_dynamic_cast(); - pChart->Add(pFile); - - unsigned int rId = 0; - m_pOfficeDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/package", L"../embeddings/" + pXlsxFile->m_sOutputFilename, std::wstring(), &rId); - m_pOfficeDrawingConverter->m_pImageManager->m_pContentTypes->AddDefault(L"xlsx"); - - if (false == pChart->m_oChartSpace.m_chartData.m_externalData.IsInit()) - pChart->m_oChartSpace.m_chartData.m_externalData.Init(); - - pChart->m_oChartSpace.m_chartData.m_externalData->m_id = OOX::RId(rId).ToString(); - } - } - else if (c_oserct_chartspaceSTYLES == type) - { - NSCommon::smart_ptr chartstyle = new OOX::Spreadsheet::CChartStyleFile(NULL); - READ1_DEF(length, res, ReadCT_ChartStyle, chartstyle.GetPointer()); - - if (res == c_oSerConstants::ReadOk) - { - NSCommon::smart_ptr pFile = chartstyle.smart_dynamic_cast(); - pChart->Add(pFile); - - unsigned int rId = 0; - m_pOfficeDrawingConverter->WriteRels(L"http://schemas.microsoft.com/office/2011/relationships/chartStyle", chartstyle->m_sOutputFilename, std::wstring(), &rId); - } - } - else if (c_oserct_chartspaceCOLORS == type) - { - NSCommon::smart_ptr chartcolors = new OOX::Spreadsheet::CChartColorsFile(NULL); - READ1_DEF(length, res, ReadCT_ChartColors, chartcolors.GetPointer()); - - if (res == c_oSerConstants::ReadOk) - { - NSCommon::smart_ptr pFile = chartcolors.smart_dynamic_cast(); - pChart->Add(pFile); - - unsigned int rId = 0; - m_pOfficeDrawingConverter->WriteRels(L"http://schemas.microsoft.com/office/2011/relationships/chartColorStyle", chartcolors->m_sOutputFilename, std::wstring(), &rId); - } - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExChart(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CChart *pChart = static_cast(poResult); - - if (c_oserct_chartExChartPLOTAREA == type) - { - READ1_DEF(length, res, this->ReadCT_ChartExPlotArea, &pChart->m_plotArea); - } - else if (c_oserct_chartExChartTITLE == type) - { - pChart->m_title.Init(); - READ1_DEF(length, res, this->ReadCT_ChartExTitle, pChart->m_title.GetPointer()); - } - else if (c_oserct_chartExChartLEGEND == type) - { - pChart->m_legend.Init(); - READ1_DEF(length, res, this->ReadCT_ChartExLegend, pChart->m_legend.GetPointer()); - } - - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExChartData(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CChartData *pChartData = static_cast(poResult); - - if (c_oserct_chartExDATA == type) - { - pChartData->m_arData.push_back(new OOX::Spreadsheet::ChartEx::CData()); - READ1_DEF(length, res, this->ReadCT_ChartExData, pChartData->m_arData.back()); - } - else if (c_oserct_chartExEXTERNALDATA == type) - { - if (false == pChartData->m_externalData.IsInit()) - pChartData->m_externalData.Init(); - - READ1_DEF(length, res, this->ReadCT_ChartExExternalData, pChartData->m_externalData.GetPointer()); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExData(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CData *pData = static_cast(poResult); - - if (c_oserct_chartExDataID == type) - { - pData->m_id = m_oBufferedStream.GetULong(); - } - else if (c_oserct_chartExDataSTRDIMENSION == type) - { - OOX::Spreadsheet::ChartEx::CStrDimension *pDimension = new OOX::Spreadsheet::ChartEx::CStrDimension(); - READ1_DEF(length, res, this->ReadCT_ChartExDataStrDimension, pDimension); - - pData->m_arDimension.push_back(dynamic_cast(pDimension)); - } - else if (c_oserct_chartExDataNUMDIMENSION == type) - { - OOX::Spreadsheet::ChartEx::CNumDimension *pDimension = new OOX::Spreadsheet::ChartEx::CNumDimension(); - READ1_DEF(length, res, this->ReadCT_ChartExDataNumDimension, pDimension); - - pData->m_arDimension.push_back(dynamic_cast(pDimension)); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExDataStrDimension(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CStrDimension *pDimension = static_cast(poResult); - - if (c_oserct_chartExDataDimensionTYPE == type) - { - pDimension->m_type.Init(); - pDimension->m_type->SetValue((SimpleTypes::Spreadsheet::EDimensionType)m_oBufferedStream.GetUChar()); - } - else if (c_oserct_chartExDataDimensionFORMULA == type) - { - pDimension->m_f.Init(); - READ1_DEF(length, res, this->ReadCT_ChartExFormula, pDimension->m_f.GetPointer()); - } - else if (c_oserct_chartExDataDimensionNF == type) - { - pDimension->m_nf = m_oBufferedStream.GetString4(length); - } - else if (c_oserct_chartExDataDimensionSTRINGLEVEL == type) - { - pDimension->m_levelData.push_back(new OOX::Spreadsheet::ChartEx::CStringLevel()); - READ1_DEF(length, res, this->ReadCT_ChartExStringLevel, pDimension->m_levelData.back()); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExDataNumDimension(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CNumDimension *pDimension = static_cast(poResult); - - if (c_oserct_chartExDataDimensionTYPE == type) - { - pDimension->m_type.Init(); - pDimension->m_type->SetValue((SimpleTypes::Spreadsheet::EDimensionType)m_oBufferedStream.GetUChar()); - } - else if (c_oserct_chartExDataDimensionFORMULA == type) - { - pDimension->m_f.Init(); - READ1_DEF(length, res, this->ReadCT_ChartExFormula, pDimension->m_f.GetPointer()); - } - else if (c_oserct_chartExDataDimensionNF == type) - { - pDimension->m_nf = m_oBufferedStream.GetString4(length); - } - else if (c_oserct_chartExDataDimensionNUMERICLEVEL == type) - { - pDimension->m_levelData.push_back(new OOX::Spreadsheet::ChartEx::CNumericLevel()); - READ1_DEF(length, res, this->ReadCT_ChartExNumericLevel, pDimension->m_levelData.back()); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExExternalData(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CExternalData *pChartData = static_cast(poResult); - - if (c_oserct_chartExExternalAUTOUPDATE == type) - { - pChartData->m_autoUpdate = m_oBufferedStream.GetBool(); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExFormula(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CFormula*pFormula = static_cast(poResult); - - if (c_oserct_chartExFormulaCONTENT == type) - { - pFormula->m_content = m_oBufferedStream.GetString4(length); - } - else if (c_oserct_chartExFormulaDIRECTION == type) - { - pFormula->m_dir.Init(); - pFormula->m_dir->SetValue((SimpleTypes::Spreadsheet::EFormulaDirection)m_oBufferedStream.GetUChar()); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExStringLevel(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CStringLevel *pLevel = static_cast(poResult); - - if (c_oserct_chartExDataLevelNAME == type) - { - pLevel->m_name = m_oBufferedStream.GetString4(length); - } - else if (c_oserct_chartExDataLevelCOUNT == type) - { - pLevel->m_ptCount = m_oBufferedStream.GetLong(); - } - else if (c_oserct_chartExDataLevelPT == type) - { - pLevel->m_arPt.push_back(new OOX::Spreadsheet::ChartEx::CStringValue()); - READ1_DEF(length, res, this->ReadCT_ChartExStringValue, pLevel->m_arPt.back()); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExNumericLevel(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CNumericLevel *pLevel = static_cast(poResult); - - if (c_oserct_chartExDataLevelNAME == type) - { - pLevel->m_name = m_oBufferedStream.GetString4(length); - } - else if (c_oserct_chartExDataLevelCOUNT == type) - { - pLevel->m_ptCount = m_oBufferedStream.GetLong(); - } - else if (c_oserct_chartExDataLevelPT == type) - { - pLevel->m_arPt.push_back(new OOX::Spreadsheet::ChartEx::CNumericValue()); - READ1_DEF(length, res, this->ReadCT_ChartExNumericValue, pLevel->m_arPt.back()); - } - else if (c_oserct_chartExDataLevelFORMATCODE == type) - { - pLevel->m_formatCode = m_oBufferedStream.GetString4(length); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExStringValue(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CStringValue *pValue = static_cast(poResult); - - if (c_oserct_chartExDataValueIDX == type) - { - pValue->m_idx = m_oBufferedStream.GetLong(); - } - else if (c_oserct_chartExDataValueCONTENT == type) - { - pValue->m_content = m_oBufferedStream.GetString4(length); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExNumericValue(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CNumericValue *pValue = static_cast(poResult); - - if (c_oserct_chartExDataValueIDX == type) - { - pValue->m_idx = m_oBufferedStream.GetLong(); - } - else if (c_oserct_chartExDataValueCONTENT == type) - { - pValue->m_content = m_oBufferedStream.GetDouble(); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExPlotArea(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CPlotArea *pPlotArea = static_cast(poResult); - - if (c_oserct_chartExChartAREAREGION == type) - { - READ1_DEF(length, res, this->ReadCT_ChartExPlotAreaRegion, &pPlotArea->m_plotAreaRegion); - } - else if (c_oserct_chartExChartAXIS == type) - { - pPlotArea->m_arAxis.push_back(new OOX::Spreadsheet::ChartEx::CAxis()); - READ1_DEF(length, res, this->ReadCT_ChartExAxis, pPlotArea->m_arAxis.back()); - } - else if (c_oserct_chartExChartSPPR == type) - { - pPlotArea->m_oSpPr = new PPTX::Logic::SpPr; - pPlotArea->m_oSpPr->m_namespace = L"cx"; - res = ReadCT_PptxElement(0, length, pPlotArea->m_oSpPr.GetPointer()); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExPlotAreaRegion(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CPlotAreaRegion *pPlotAreaRegion = static_cast(poResult); - - if (c_oserct_chartExAreaPLOTSURFACE == type) - { - pPlotAreaRegion->m_plotSurface.Init(); - READ1_DEF(length, res, this->ReadCT_ChartExPlotSurface, pPlotAreaRegion->m_plotSurface.GetPointer()); - } - else if (c_oserct_chartExAreaSERIES == type) - { - pPlotAreaRegion->m_arSeries.push_back(new OOX::Spreadsheet::ChartEx::CSeries()); - READ1_DEF(length, res, this->ReadCT_ChartExSeries, pPlotAreaRegion->m_arSeries.back()); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExTitle(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CTitle *pTitle = static_cast(poResult); - - if (c_oserct_chartExTitleTX == type) - { - pTitle->m_tx.Init(); - READ1_DEF(length, res, this->ReadCT_ChartExText, pTitle->m_tx.GetPointer()); - } - else if (c_oserct_chartExTitleTXPR == type) - { - pTitle->m_oTxPr = new PPTX::Logic::TxBody; - pTitle->m_oTxPr->m_name = L"cx:txPr"; - res = ReadCT_PptxElement(0, length, pTitle->m_oTxPr.GetPointer()); - } - else if (c_oserct_chartExTitleSPPR == type) - { - pTitle->m_oSpPr = new PPTX::Logic::SpPr; - pTitle->m_oSpPr->m_namespace = L"cx"; - res = ReadCT_PptxElement(0, length, pTitle->m_oSpPr.GetPointer()); - } - else if (c_oserct_chartExTitlePOS == type) - { - pTitle->m_pos = (SimpleTypes::Spreadsheet::ESidePos)m_oBufferedStream.GetUChar(); - } - else if (c_oserct_chartExTitleALIGN == type) - { - pTitle->m_align = (SimpleTypes::Spreadsheet::EPosAlign)m_oBufferedStream.GetUChar(); - } - else if (c_oserct_chartExTitleOVERLAY == type) - { - pTitle->m_overlay = m_oBufferedStream.GetBool(); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExLegend(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CLegend *pLegend = static_cast(poResult); - - if (c_oserct_chartExLegendTXPR == type) - { - pLegend->m_oTxPr = new PPTX::Logic::TxBody; - pLegend->m_oTxPr->m_name = L"cx:txPr"; - res = ReadCT_PptxElement(0, length, pLegend->m_oTxPr.GetPointer()); - } - else if (c_oserct_chartExLegendSPPR == type) - { - pLegend->m_oSpPr = new PPTX::Logic::SpPr; - pLegend->m_oSpPr->m_namespace = L"cx"; - res = ReadCT_PptxElement(0, length, pLegend->m_oSpPr.GetPointer()); - } - else if (c_oserct_chartExTitlePOS == type) - { - pLegend->m_pos = (SimpleTypes::Spreadsheet::ESidePos)m_oBufferedStream.GetUChar(); - } - else if (c_oserct_chartExTitleALIGN == type) - { - pLegend->m_align = (SimpleTypes::Spreadsheet::EPosAlign)m_oBufferedStream.GetUChar(); - } - else if (c_oserct_chartExTitleOVERLAY == type) - { - pLegend->m_overlay = m_oBufferedStream.GetBool(); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExText(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CText *pText = static_cast(poResult); - - if (c_oserct_chartExTextRICH == type) - { - pText->m_oRich.Init(); - pText->m_oRich->m_name = L"cx:rich"; - res = ReadCT_PptxElement(0, length, pText->m_oRich.GetPointer()); - } - else if (c_oserct_chartExTextDATA == type) - { - pText->m_txData.Init(); - READ1_DEF(length, res, this->ReadCT_ChartExTextData, pText->m_txData.GetPointer()); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExTextData(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CTextData *pTextData = static_cast(poResult); - - if (c_oserct_chartExTextDataFORMULA == type) - { - pTextData->m_oF.Init(); - READ1_DEF(length, res, this->ReadCT_ChartExFormula, pTextData->m_oF.GetPointer()); - } - else if (c_oserct_chartExTextDataVALUE == type) - { - pTextData->m_oV = m_oBufferedStream.GetString4(length); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExPlotSurface(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CPlotSurface *pPlotSurface = static_cast(poResult); - - if (c_oserct_chartExPlotSurfaceSPPR == type) - { - pPlotSurface->m_oSpPr = new PPTX::Logic::SpPr; - pPlotSurface->m_oSpPr->m_namespace = L"cx"; - res = ReadCT_PptxElement(0, length, pPlotSurface->m_oSpPr.GetPointer()); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExSeries(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CSeries *pSeries = static_cast(poResult); - - if (c_oserct_chartExSeriesDATAPT == type) - { - pSeries->m_arDataPt.push_back(new OOX::Spreadsheet::ChartEx::CDataPoint()); - READ1_DEF(length, res, this->ReadCT_ChartExDataPoint, pSeries->m_arDataPt.back()); - } - else if (c_oserct_chartExSeriesDATALABELS == type) - { - pSeries->m_dataLabels.Init(); - READ1_DEF(length, res, this->ReadCT_ChartExDataLabels, pSeries->m_dataLabels.GetPointer()); - } - else if (c_oserct_chartExSeriesLAYOUTPROPS == type) - { - pSeries->m_layoutPr.Init(); - READ1_DEF(length, res, this->ReadCT_ChartExSeriesLayoutProperties, pSeries->m_layoutPr.GetPointer()); - } - else if (c_oserct_chartExSeriesTEXT == type) - { - pSeries->m_tx.Init(); - READ1_DEF(length, res, this->ReadCT_ChartExText, pSeries->m_tx.GetPointer()); - } - else if (c_oserct_chartExSeriesAXIS == type) - { - pSeries->m_arAxisId.push_back(m_oBufferedStream.GetULong()); - } - else if (c_oserct_chartExSeriesDATAID == type) - { - pSeries->m_dataId.Init(); - pSeries->m_dataId->m_oVal = m_oBufferedStream.GetLong(); - } - else if (c_oserct_chartExSeriesSPPR == type) - { - pSeries->m_oSpPr = new PPTX::Logic::SpPr; - pSeries->m_oSpPr->m_namespace = L"cx"; - res = ReadCT_PptxElement(0, length, pSeries->m_oSpPr.GetPointer()); - } - else if (c_oserct_chartExSeriesLAYOUTID == type) - { - pSeries->m_oLayoutId = (SimpleTypes::Spreadsheet::ESeriesLayout)m_oBufferedStream.GetUChar(); - } - else if (c_oserct_chartExSeriesHIDDEN == type) - { - pSeries->m_bHidden = m_oBufferedStream.GetBool(); - } - else if (c_oserct_chartExSeriesOWNERIDX == type) - { - pSeries->m_nOwnerIdx = m_oBufferedStream.GetLong(); - } - else if (c_oserct_chartExSeriesFORMATIDX == type) - { - pSeries->m_nFormatIdx = m_oBufferedStream.GetLong(); - } - else if (c_oserct_chartExSeriesUNIQUEID == type) - { - pSeries->m_sUniqueId = m_oBufferedStream.GetString4(length); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExDataPoint(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CDataPoint *pDataPoint = static_cast(poResult); - - if (c_oserct_chartExDataPointIDX == type) - { - pDataPoint->m_idx = m_oBufferedStream.GetLong(); - } - else if (c_oserct_chartExDataPointSPPR == type) - { - pDataPoint->m_oSpPr = new PPTX::Logic::SpPr; - pDataPoint->m_oSpPr->m_namespace = L"cx"; - res = ReadCT_PptxElement(0, length, pDataPoint->m_oSpPr.GetPointer()); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExDataLabels(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CDataLabels *pDataLabels = static_cast(poResult); - - if (c_oserct_chartExDataLabelsPOS == type) - { - pDataLabels->m_pos = (SimpleTypes::Spreadsheet::EDataLabelPos)m_oBufferedStream.GetUChar(); - } - else if (c_oserct_chartExDataLabelsNUMFMT == type) - { - pDataLabels->m_numFmt.Init(); - READ1_DEF(length, res, this->ReadCT_ChartExNumberFormat, pDataLabels->m_numFmt.GetPointer()); - } - else if (c_oserct_chartExDataLabelsTXPR == type) - { - pDataLabels->m_oTxPr = new PPTX::Logic::TxBody; - pDataLabels->m_oTxPr->m_name = L"cx:txPr"; - res = ReadCT_PptxElement(0, length, pDataLabels->m_oTxPr.GetPointer()); - } - else if (c_oserct_chartExDataLabelsSPPR == type) - { - pDataLabels->m_oSpPr = new PPTX::Logic::SpPr; - pDataLabels->m_oSpPr->m_namespace = L"cx"; - res = ReadCT_PptxElement(0, length, pDataLabels->m_oSpPr.GetPointer()); - } - else if (c_oserct_chartExDataLabelsVISABILITIES == type) - { - pDataLabels->m_visibility.Init(); - READ1_DEF(length, res, this->ReadCT_ChartExDataLabelVisibilities, pDataLabels->m_visibility.GetPointer()); - } - else if (c_oserct_chartExDataLabelsSEPARATOR == type) - { - pDataLabels->m_separator = m_oBufferedStream.GetString4(length); - } - else if (c_oserct_chartExDataLabelsDATALABEL == type) - { - pDataLabels->m_arDataLabel.push_back(new OOX::Spreadsheet::ChartEx::CDataLabel()); - READ1_DEF(length, res, this->ReadCT_ChartExDataLabel, pDataLabels->m_arDataLabel.back()); - } - else if (c_oserct_chartExDataLabelsDATALABELHIDDEN == type) - { - pDataLabels->m_arDataLabelHidden.push_back(new OOX::Spreadsheet::ChartEx::CDataLabelHidden()); - READ1_DEF(length, res, this->ReadCT_ChartExDataLabelHidden, pDataLabels->m_arDataLabelHidden.back()); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExDataLabel(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CDataLabel *pDataLabel = static_cast(poResult); - - if (c_oserct_chartExDataLabelIDX == type) - { - pDataLabel->m_idx = m_oBufferedStream.GetLong(); - } - else if (c_oserct_chartExDataLabelPOS == type) - { - pDataLabel->m_dataLabelPos = (SimpleTypes::Spreadsheet::EDataLabelPos)m_oBufferedStream.GetUChar(); - } - else if (c_oserct_chartExDataLabelNUMFMT == type) - { - pDataLabel->m_numFmt.Init(); - READ1_DEF(length, res, this->ReadCT_ChartExNumberFormat, pDataLabel->m_numFmt.GetPointer()); - } - else if (c_oserct_chartExDataLabelTXPR == type) - { - pDataLabel->m_oTxPr = new PPTX::Logic::TxBody; - pDataLabel->m_oTxPr->m_name = L"cx:txPr"; - res = ReadCT_PptxElement(0, length, pDataLabel->m_oTxPr.GetPointer()); - } - else if (c_oserct_chartExDataLabelSPPR == type) - { - pDataLabel->m_oSpPr = new PPTX::Logic::SpPr; - pDataLabel->m_oSpPr->m_namespace = L"cx"; - res = ReadCT_PptxElement(0, length, pDataLabel->m_oSpPr.GetPointer()); - } - else if (c_oserct_chartExDataLabelsVISABILITIES == type) - { - pDataLabel->m_visibility.Init(); - READ1_DEF(length, res, this->ReadCT_ChartExDataLabelVisibilities, pDataLabel->m_visibility.GetPointer()); - } - else if (c_oserct_chartExDataLabelSEPARATOR == type) - { - pDataLabel->m_separator = m_oBufferedStream.GetString4(length); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExDataLabelHidden(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CDataLabelHidden *pDataLabelHidden = static_cast(poResult); - - if (c_oserct_chartExDATA == type) - { - pDataLabelHidden->m_idx = m_oBufferedStream.GetLong(); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExSeriesLayoutProperties(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CSeriesLayoutProperties *pLayout = static_cast(poResult); - - if (c_oserct_chartExSeriesLayoutPARENT == type) - { - pLayout->m_parentLabelLayout.Init(); - pLayout->m_parentLabelLayout->m_oVal = (SimpleTypes::Spreadsheet::EParentLabelLayout)m_oBufferedStream.GetUChar(); - } - else if (c_oserct_chartExSeriesLayoutREGION == type) - { - pLayout->m_regionLabelLayout.Init(); - pLayout->m_regionLabelLayout->m_oVal = (SimpleTypes::Spreadsheet::ERegionLabelLayout)m_oBufferedStream.GetUChar(); - } - else if (c_oserct_chartExSeriesLayoutVISABILITIES == type) - { - pLayout->m_visibility.Init(); - READ1_DEF(length, res, this->ReadCT_ChartExSeriesElementVisibilities, pLayout->m_visibility.GetPointer()); - } - else if (c_oserct_chartExSeriesLayoutAGGREGATION == type) - { - pLayout->m_aggregation = m_oBufferedStream.GetBool(); - } - else if (c_oserct_chartExSeriesLayoutBINNING == type) - { - pLayout->m_binning.Init(); - READ1_DEF(length, res, this->ReadCT_ChartExBinning, pLayout->m_binning.GetPointer()); - } - else if (c_oserct_chartExSeriesLayoutSTATISTIC == type) - { - pLayout->m_statistics.Init(); - READ1_DEF(length, res, this->ReadCT_ChartExStatistics, pLayout->m_statistics.GetPointer()); - } - else if (c_oserct_chartExSeriesLayoutSUBTOTALS == type) - { - pLayout->m_subtotals.Init(); - READ1_DEF(length, res, this->ReadCT_ChartExSubtotals, pLayout->m_subtotals.GetPointer()); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExNumberFormat(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CNumberFormat *pNumberFormat = static_cast(poResult); - - if (c_oserct_chartExNumberFormatFORMATCODE == type) - { - pNumberFormat->m_formatCode = m_oBufferedStream.GetString4(length); - } - else if (c_oserct_chartExNumberFormatSOURCELINKED == type) - { - pNumberFormat->m_sourceLinked = m_oBufferedStream.GetBool(); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExDataLabelVisibilities(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CDataLabelVisibilities *pVisibilities = static_cast(poResult); - - if (c_oserct_chartExDataLabelVisibilitiesSERIES == type) - { - pVisibilities->m_seriesName = m_oBufferedStream.GetBool(); - } - else if (c_oserct_chartExDataLabelVisibilitiesCATEGORY == type) - { - pVisibilities->m_categoryName = m_oBufferedStream.GetBool(); - } - else if (c_oserct_chartExDataLabelVisibilitiesVALUE == type) - { - pVisibilities->m_value = m_oBufferedStream.GetBool(); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExBinning(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CBinning *pBinning = static_cast(poResult); - - if (c_oserct_chartExBinningBINSIZE == type) - { - pBinning->m_binSize = m_oBufferedStream.GetDouble(); - } - else if (c_oserct_chartExBinningBINCOUNT == type) - { - pBinning->m_binCount = m_oBufferedStream.GetLong(); - } - else if (c_oserct_chartExBinningINTERVAL == type) - { - pBinning->m_intervalClosed = (SimpleTypes::Spreadsheet::ESidePos)m_oBufferedStream.GetUChar(); - } - else if (c_oserct_chartExBinningUNDERVAL == type) - { - pBinning->m_underflow = m_oBufferedStream.GetDouble(); - } - else if (c_oserct_chartExBinningOVERVAL == type) - { - pBinning->m_overflow = m_oBufferedStream.GetDouble(); - } - else if (c_oserct_chartExBinningUNDERAUTO == type) - { - pBinning->m_underflow = (SimpleTypes::Spreadsheet::EDoubleOrAutomatic)m_oBufferedStream.GetUChar(); - } - else if (c_oserct_chartExBinningOVERAUTO == type) - { - pBinning->m_overflow = (SimpleTypes::Spreadsheet::EDoubleOrAutomatic)m_oBufferedStream.GetUChar(); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExStatistics(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CStatistics *pStatistics = static_cast(poResult); - - if (c_oserct_chartExDATA == type) - { - pStatistics->m_quartileMethod = (SimpleTypes::Spreadsheet::EQuartileMethod)m_oBufferedStream.GetUChar(); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExSubtotals(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CSubtotals *pSubtotals = static_cast(poResult); - - if (c_oserct_chartExStatisticsMETHOD == type) - { - pSubtotals->m_arIdx.push_back(m_oBufferedStream.GetULong()); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExSeriesElementVisibilities(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CSeriesElementVisibilities *pVisibilities = static_cast(poResult); - - if (c_oserct_chartExSeriesVisibilitiesCONNECTOR == type) - { - pVisibilities->m_connectorLines = m_oBufferedStream.GetBool(); - } - else if (c_oserct_chartExSeriesVisibilitiesMEANLINE == type) - { - pVisibilities->m_meanLine = m_oBufferedStream.GetBool(); - } - else if (c_oserct_chartExSeriesVisibilitiesMEANMARKER == type) - { - pVisibilities->m_meanMarker = m_oBufferedStream.GetBool(); - } - else if (c_oserct_chartExSeriesVisibilitiesNONOUTLIERS == type) - { - pVisibilities->m_nonoutliers = m_oBufferedStream.GetBool(); - } - else if (c_oserct_chartExSeriesVisibilitiesOUTLIERS == type) - { - pVisibilities->m_outliers = m_oBufferedStream.GetBool(); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExAxis(BYTE type, long length, void* poResult) - { - OOX::Spreadsheet::ChartEx::CAxis *pAxis = static_cast(poResult); - int res = c_oSerConstants::ReadOk; - - if (c_oserct_chartExAxisID == type) - { - pAxis->m_id = m_oBufferedStream.GetLong(); - } - else if (c_oserct_chartExAxisHIDDEN == type) - { - pAxis->m_hidden = m_oBufferedStream.GetBool(); - } - else if (c_oserct_chartExAxisCATSCALING == type) - { - pAxis->m_catScaling.Init(); - READ1_DEF(length, res, this->ReadCT_ChartExCatScaling, pAxis->m_catScaling.GetPointer()); - } - else if (c_oserct_chartExAxisVALSCALING == type) - { - pAxis->m_valScaling.Init(); - READ1_DEF(length, res, this->ReadCT_ChartExValScaling, pAxis->m_valScaling.GetPointer()); - } - else if (c_oserct_chartExAxisTITLE == type) - { - pAxis->m_title.Init(); - READ1_DEF(length, res, this->ReadCT_ChartExTitle, pAxis->m_title.GetPointer()); - } - else if (c_oserct_chartExAxisUNIT == type) - { - pAxis->m_units.Init(); - READ1_DEF(length, res, this->ReadCT_ChartExAxisUnit, pAxis->m_units.GetPointer()); - } - else if (c_oserct_chartExAxisNUMFMT == type) - { - pAxis->m_numFmt.Init(); - READ1_DEF(length, res, this->ReadCT_ChartExNumberFormat, pAxis->m_numFmt.GetPointer()); - } - else if (c_oserct_chartExAxisMAJORTICK == type) - { - pAxis->m_majorTickMarks.Init(); - pAxis->m_majorTickMarks->m_name = L"cx:majorTickMarks"; - READ1_DEF(length, res, this->ReadCT_ChartExTickMarks, pAxis->m_majorTickMarks.GetPointer()); - } - else if (c_oserct_chartExAxisMINORTICK == type) - { - pAxis->m_minorTickMarks.Init(); - pAxis->m_minorTickMarks->m_name = L"cx:minorTickMarks"; - READ1_DEF(length, res, this->ReadCT_ChartExTickMarks, pAxis->m_minorTickMarks.GetPointer()); - } - else if (c_oserct_chartExAxisMAJORGRID == type) - { - pAxis->m_majorGridlines.Init(); - pAxis->m_majorGridlines->m_name = L"cx:majorGridlines"; - READ1_DEF(length, res, this->ReadCT_ChartExGridlines, pAxis->m_majorGridlines.GetPointer()); - } - else if (c_oserct_chartExAxisMAJORGRID == type) - { - pAxis->m_minorGridlines.Init(); - pAxis->m_minorGridlines->m_name = L"cx:minorGridlines"; - READ1_DEF(length, res, this->ReadCT_ChartExGridlines, pAxis->m_minorGridlines.GetPointer()); - } - else if (c_oserct_chartExAxisTICKLABELS == type) - { - pAxis->m_tickLabels = m_oBufferedStream.GetBool(); - } - else if (c_oserct_chartExAxisTXPR == type) - { - pAxis->m_oTxPr = new PPTX::Logic::TxBody; - pAxis->m_oTxPr->m_name = L"cx:txPr"; - res = ReadCT_PptxElement(0, length, pAxis->m_oTxPr.GetPointer()); - } - else if (c_oserct_chartExDataLabelSPPR == type) - { - pAxis->m_oSpPr = new PPTX::Logic::SpPr; - pAxis->m_oSpPr->m_namespace = L"cx"; - res = ReadCT_PptxElement(0, length, pAxis->m_oSpPr.GetPointer()); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExCatScaling(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CCatScaling *pScaling = static_cast(poResult); - - if (c_oserct_chartExCatScalingGAPAUTO == type) - { - pScaling->m_gapWidth = (SimpleTypes::Spreadsheet::EDoubleOrAutomatic)m_oBufferedStream.GetUChar(); - } - else if (c_oserct_chartExCatScalingGAPVAL == type) - { - pScaling->m_gapWidth = m_oBufferedStream.GetDouble(); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExValScaling(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CValScaling *pScaling = static_cast(poResult); - - if (c_oserct_chartExValScalingMINAUTO == type) - { - pScaling->m_min = (SimpleTypes::Spreadsheet::EDoubleOrAutomatic)m_oBufferedStream.GetUChar(); - } - else if (c_oserct_chartExValScalingMINVAL == type) - { - pScaling->m_min = m_oBufferedStream.GetDouble(); - } - else if (c_oserct_chartExValScalingMAXAUTO == type) - { - pScaling->m_max = (SimpleTypes::Spreadsheet::EDoubleOrAutomatic)m_oBufferedStream.GetUChar(); - } - else if (c_oserct_chartExValScalingMAXVAL == type) - { - pScaling->m_max = m_oBufferedStream.GetDouble(); - } - else if (c_oserct_chartExValScalingMAJUNITAUTO == type) - { - pScaling->m_majorUnit = (SimpleTypes::Spreadsheet::EDoubleOrAutomatic)m_oBufferedStream.GetUChar(); - } - else if (c_oserct_chartExValScalingMAJUNITVAL == type) - { - pScaling->m_majorUnit = m_oBufferedStream.GetDouble(); - } - else if (c_oserct_chartExValScalingMINUNITAUTO == type) - { - pScaling->m_minorUnit = (SimpleTypes::Spreadsheet::EDoubleOrAutomatic)m_oBufferedStream.GetUChar(); - } - else if (c_oserct_chartExValScalingMINUNITVAL == type) - { - pScaling->m_minorUnit = m_oBufferedStream.GetDouble(); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExAxisUnit(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CAxisUnit *pAxisUnit = static_cast(poResult); - - if (c_oserct_chartExAxisUnitTYPE == type) - { - pAxisUnit->m_unit = (SimpleTypes::Spreadsheet::EAxisUnit)m_oBufferedStream.GetUChar(); - } - else if (c_oserct_chartExAxisUnitLABEL == type) - { - pAxisUnit->m_unitsLabel.Init(); - READ1_DEF(length, res, this->ReadCT_ChartExAxisUnitsLabel, pAxisUnit->m_unitsLabel.GetPointer()); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExTickMarks(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CTickMarks *pTickMarks = static_cast(poResult); - - if (c_oserct_chartExTickMarksTYPE == type) - { - pTickMarks->m_type = (SimpleTypes::Spreadsheet::ETickMarksType)m_oBufferedStream.GetUChar(); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExGridlines(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CGridlines *pGridlines = static_cast(poResult); - - if (c_oserct_chartExGridlinesSPPR == type) - { - pGridlines->m_oSpPr = new PPTX::Logic::SpPr; - pGridlines->m_oSpPr->m_namespace = L"cx"; - res = ReadCT_PptxElement(0, length, pGridlines->m_oSpPr.GetPointer()); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } - int BinaryChartReader::ReadCT_ChartExAxisUnitsLabel(BYTE type, long length, void* poResult) - { - int res = c_oSerConstants::ReadOk; - OOX::Spreadsheet::ChartEx::CAxisUnitsLabel *pAxisUnitsLabel = static_cast(poResult); - - if (c_oserct_chartExAxisUnitsLabelSPPR == type) - { - pAxisUnitsLabel->m_oSpPr = new PPTX::Logic::SpPr; - pAxisUnitsLabel->m_oSpPr->m_namespace = L"cx"; - res = ReadCT_PptxElement(0, length, pAxisUnitsLabel->m_oSpPr.GetPointer()); - } - else if (c_oserct_chartExAxisUnitsLabelTXPR == type) - { - pAxisUnitsLabel->m_oTxPr = new PPTX::Logic::TxBody; - pAxisUnitsLabel->m_oTxPr->m_name = L"cx:txPr"; - res = ReadCT_PptxElement(0, length, pAxisUnitsLabel->m_oTxPr.GetPointer()); - } - else if (c_oserct_chartExAxisUnitsLabelTEXT == type) - { - pAxisUnitsLabel->m_tx.Init(); - READ1_DEF(length, res, this->ReadCT_ChartExText, pAxisUnitsLabel->m_tx.GetPointer()); - } - else - res = c_oSerConstants::ReadUnknown; - return res; - } -//--------------------------------------------------------------- BinaryChartWriter::BinaryChartWriter(NSBinPptxRW::CBinaryFileWriter &oBufferedStream, NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter):m_oBcw(oBufferedStream),m_pOfficeDrawingConverter(pOfficeDrawingConverter) {} @@ -7728,10 +6176,9 @@ namespace BinXlsxRW } } } - void BinaryChartWriter::WriteCT_ChartFile(OOX::Spreadsheet::CChartFile& oChartFile) + void BinaryChartWriter::WriteCT_ChartSpace(OOX::Spreadsheet::CChartSpace& oChartSpace) { - CT_ChartSpace& oVal = oChartFile.m_oChartSpace; - + CT_ChartSpace& oVal = oChartSpace.m_oChartSpace; if(NULL != oVal.m_date1904) { int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartspaceDATE1904); @@ -7759,7 +6206,7 @@ namespace BinXlsxRW if(NULL != oVal.m_style) { int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartspaceSTYLE); - WriteCT_Style(*oVal.m_style); + WriteCT_Style1(*oVal.m_style); m_oBcw.WriteItemEnd(nCurPos); } if(oVal.m_oClrMapOvr.IsInit()) @@ -7798,12 +6245,12 @@ namespace BinXlsxRW m_oBcw.m_oStream.WriteRecord2(0, oVal.m_oTxPr); m_oBcw.WriteItemEnd(nCurPos); } - if(NULL != oVal.m_externalData) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartspaceEXTERNALDATA); - WriteCT_ExternalData(*oVal.m_externalData); - m_oBcw.WriteItemEnd(nCurPos); - } + //if(NULL != oVal.m_externalData) + //{ + // int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartspaceEXTERNALDATA); + // WriteCT_ExternalData(*oVal.m_externalData); + // m_oBcw.WriteItemEnd(nCurPos); + //} if(NULL != oVal.m_printSettings) { int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartspacePRINTSETTINGS); @@ -7817,9 +6264,24 @@ namespace BinXlsxRW WriteCT_extLst(*oVal.m_extLst); m_oBcw.WriteItemEnd(nCurPos); } + + std::vector>& container = oChartSpace.GetContainer(); + + for (size_t i = 0; i < container.size(); ++i) + { + if (OOX::FileTypes::ThemeOverride == container[i]->type()) + { + PPTX::Theme* pThemeOverride = dynamic_cast(container[i].GetPointer()); + + int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartspaceTHEMEOVERRIDE); + pThemeOverride->toPPTY(&m_oBcw.m_oStream); + m_oBcw.WriteItemEnd(nCurPos); + break; + } + } if ((NULL != oVal.m_userShapes) && (NULL != oVal.m_userShapes->m_id)) { - smart_ptr oFile = oChartFile.Find(*oVal.m_userShapes->m_id); + smart_ptr oFile = oChartSpace.Find(*oVal.m_userShapes->m_id); if (oFile.IsInit() && OOX::FileTypes::ChartDrawing == oFile->type()) { @@ -7934,6 +6396,16 @@ namespace BinXlsxRW m_oBcw.WriteItemEnd(nCurPos); } } + void BinaryChartWriter::WriteCT_RelId(CT_RelId& oVal) + { + if(NULL != oVal.m_id) + { + int nCurPos = m_oBcw.WriteItemStart(c_oserct_relidID); + //todo + m_oBcw.m_oStream.WriteStringW4(*oVal.m_id); + m_oBcw.WriteItemEnd(nCurPos); + } + } void BinaryChartWriter::WriteCT_PageSetup(CT_PageSetup& oVal) { if(NULL != oVal.m_paperSize) @@ -8129,7 +6601,13 @@ namespace BinXlsxRW WriteCT_Boolean(*oVal.m_autoUpdate); m_oBcw.WriteItemEnd(nCurPos); } - //if(NULL != oVal.m_id) - выше + if(NULL != oVal.m_id) + { + int nCurPos = m_oBcw.WriteItemStart(c_oserct_externaldataID); + //todo + m_oBcw.m_oStream.WriteStringW4(*oVal.m_id); + m_oBcw.WriteItemEnd(nCurPos); + } } void BinaryChartWriter::WriteCT_DispBlanksAs(CT_DispBlanksAs& oVal) { @@ -12557,11 +11035,20 @@ namespace BinXlsxRW } } } + void BinaryChartWriter::WriteCT_Style1(CT_Style1& oVal) + { + if(NULL != oVal.m_val) + { + int nCurPos = m_oBcw.WriteItemStart(c_oserct_style1VAL); + m_oBcw.m_oStream.WriteBYTE(*oVal.m_val); + m_oBcw.WriteItemEnd(nCurPos); + } + } void BinaryChartWriter::WriteCT_Style(CT_Style& oVal) { if(NULL != oVal.m_val) { - int nCurPos = m_oBcw.WriteItemStart(oVal.m_namespace == L"c14" ? c_oserct_style1VAL : c_oserct_styleVAL); + int nCurPos = m_oBcw.WriteItemStart(c_oserct_styleVAL); m_oBcw.m_oStream.WriteBYTE(*oVal.m_val); m_oBcw.WriteItemEnd(nCurPos); } @@ -12614,1202 +11101,7 @@ namespace BinXlsxRW if(NULL != oVal.m_style) { int nCurPos = m_oBcw.WriteItemStart(c_oseralternatecontentfallbackSTYLE); - WriteCT_Style(*oVal.m_style); - m_oBcw.WriteItemEnd(nCurPos); - } - } - void BinaryChartWriter::WriteCT_ChartStyle(OOX::Spreadsheet::CChartStyleFile & oVal) - { - if (oVal.m_oChartStyle.m_id.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartstyleID); - m_oBcw.m_oStream.WriteULONG(*oVal.m_oChartStyle.m_id); - m_oBcw.WriteItemEnd(nCurPos); - } - - for (size_t i = 0; i < oVal.m_oChartStyle.m_arStyleEntries.size(); ++i) - { - if (!oVal.m_oChartStyle.m_arStyleEntries[i]) continue; - - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartstyleENTRY); - WriteCT_StyleEntry(*oVal.m_oChartStyle.m_arStyleEntries[i]); - m_oBcw.WriteItemEnd(nCurPos); - } - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartstyleMARKERLAYOUT); - WriteCT_MarkerLayout(*oVal.m_oChartStyle.m_dataPointMarkerLayout); - m_oBcw.WriteItemEnd(nCurPos); - } - void BinaryChartWriter::WriteCT_StyleEntry(OOX::Spreadsheet::ChartEx::CStyleEntry & oVal) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartstyleENTRYTYPE); - m_oBcw.m_oStream.WriteBYTE(oVal.getTypeStyleEntry()); - m_oBcw.WriteItemEnd(nCurPos); - - nCurPos = m_oBcw.WriteItemStart(c_oserct_chartstyleLNREF); - m_oBcw.m_oStream.WriteRecord1(0, oVal.m_lnRef); - m_oBcw.WriteItemEnd(nCurPos); - - nCurPos = m_oBcw.WriteItemStart(c_oserct_chartstyleFILLREF); - m_oBcw.m_oStream.WriteRecord1(0, oVal.m_fillRef); - m_oBcw.WriteItemEnd(nCurPos); - - nCurPos = m_oBcw.WriteItemStart(c_oserct_chartstyleEFFECTREF); - m_oBcw.m_oStream.WriteRecord1(0, oVal.m_effectRef); - m_oBcw.WriteItemEnd(nCurPos); - - nCurPos = m_oBcw.WriteItemStart(c_oserct_chartstyleFONTREF); - m_oBcw.m_oStream.WriteRecord1(0, oVal.m_fontRef); - m_oBcw.WriteItemEnd(nCurPos); - - if (oVal.m_defRPr.IsInit()) - { - nCurPos = m_oBcw.WriteItemStart(c_oserct_chartstyleDEFPR); - m_oBcw.m_oStream.WriteRecord2(0, oVal.m_defRPr); - m_oBcw.WriteItemEnd(nCurPos); - } - if (oVal.m_bodyPr.IsInit()) - { - nCurPos = m_oBcw.WriteItemStart(c_oserct_chartstyleBODYPR); - m_oBcw.m_oStream.WriteRecord2(0, oVal.m_bodyPr); - m_oBcw.WriteItemEnd(nCurPos); - } - if (oVal.m_spPr.IsInit()) - { - nCurPos = m_oBcw.WriteItemStart(c_oserct_chartstyleSPPR); - m_oBcw.m_oStream.WriteRecord2(0, oVal.m_spPr); - m_oBcw.WriteItemEnd(nCurPos); - } - if (oVal.m_lineWidthScale.IsInit()) - { - nCurPos = m_oBcw.WriteItemStart(c_oserct_chartstyleLINEWIDTH); - m_oBcw.m_oStream.WriteDouble(*oVal.m_lineWidthScale); - m_oBcw.WriteItemEnd(nCurPos); - } - } - void BinaryChartWriter::WriteCT_MarkerLayout(OOX::Spreadsheet::ChartEx::CMarkerLayout & oVal) - { - if (oVal.m_symbol.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartstyleMARKERSYMBOL); - m_oBcw.m_oStream.WriteBYTE(oVal.m_symbol->GetValue()); - m_oBcw.WriteItemEnd(nCurPos); - } - if (oVal.m_size.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartstyleMARKERSIZE); - m_oBcw.m_oStream.WriteULONG(*oVal.m_size); - m_oBcw.WriteItemEnd(nCurPos); - } - } - void BinaryChartWriter::WriteCT_ChartColor(OOX::Spreadsheet::CChartColorsFile & oVal) - { - if (oVal.m_oColorStyle.m_id.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartcolorsID); - m_oBcw.m_oStream.WriteULONG(*oVal.m_oColorStyle.m_id); - m_oBcw.WriteItemEnd(nCurPos); - } - if (oVal.m_oColorStyle.m_meth.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartcolorsMETH); - m_oBcw.m_oStream.WriteStringW4(*oVal.m_oColorStyle.m_meth); - m_oBcw.WriteItemEnd(nCurPos); - } - for (size_t i = 0; i < oVal.m_oColorStyle.m_arrItems.size(); ++i) - { - OOX::Spreadsheet::ChartEx::CVariation *pVariation = dynamic_cast(oVal.m_oColorStyle.m_arrItems[i]); - - if (pVariation) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartcolorsVARIATION); - WriteCT_Variation(*pVariation); - m_oBcw.WriteItemEnd(nCurPos); - } - else - { - PPTX::Logic::UniColor *pColor = dynamic_cast(oVal.m_oColorStyle.m_arrItems[i]); - if (pColor) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartcolorsCOLOR); - m_oBcw.m_oStream.WriteRecord1(0, *pColor); - m_oBcw.WriteItemEnd(nCurPos); - } - } - } - - } - void BinaryChartWriter::WriteCT_Variation(OOX::Spreadsheet::ChartEx::CVariation & oVal) - { - for (size_t i = 0; i < oVal.m_arrItems.size(); ++i) - { - if (!oVal.m_arrItems[i]) continue; - - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartcolorsEFFECT); - m_oBcw.m_oStream.WriteRecord1(0, *oVal.m_arrItems[i]); - m_oBcw.WriteItemEnd(nCurPos); - } - } -//------------------------------------------------------------------------------------------------------------- - void BinaryChartWriter::WriteCT_ChartExFile(OOX::Spreadsheet::CChartExFile & oChartFile) - { - OOX::Spreadsheet::ChartEx::CChartSpace & oVal = oChartFile.m_oChartSpace; - - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExSpaceCHARTDATA); - WriteCT_ChartExChartData(&oVal.m_chartData); - m_oBcw.WriteItemEnd(nCurPos); - } - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExSpaceCHART); - WriteCT_ChartExChart(&oVal.m_chart); - m_oBcw.WriteItemEnd(nCurPos); - } - if (oVal.m_oClrMapOvr.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExSpaceCLRMAPOVR); - m_oBcw.m_oStream.WriteRecord2(0, oVal.m_oClrMapOvr); - m_oBcw.WriteItemEnd(nCurPos); - } - if (oVal.m_oSpPr.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExSpaceSPPR); - m_oBcw.m_oStream.WriteRecord2(0, oVal.m_oSpPr); - m_oBcw.WriteItemEnd(nCurPos); - } - if (oVal.m_oTxPr.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExSpaceTXPR); - m_oBcw.m_oStream.WriteRecord2(0, oVal.m_oTxPr); - m_oBcw.WriteItemEnd(nCurPos); - } - } - void BinaryChartWriter::WriteCT_ChartExChartData(OOX::Spreadsheet::ChartEx::CChartData *pVal) - { - if (!pVal) return; - - for (size_t i = 0; i < pVal->m_arData.size(); ++i) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDATA); - WriteCT_ChartExData(pVal->m_arData[i]); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_externalData.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExEXTERNALDATA); - WriteCT_ChartExExternalData(pVal->m_externalData.GetPointer()); - m_oBcw.WriteItemEnd(nCurPos); - } - } - void BinaryChartWriter::WriteCT_ChartExChart(OOX::Spreadsheet::ChartEx::CChart *pVal) - { - if (!pVal) return; - - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExChartPLOTAREA); - WriteCT_ChartExPlotArea(&pVal->m_plotArea); - m_oBcw.WriteItemEnd(nCurPos); - - if (pVal->m_title.IsInit()) - { - nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExChartTITLE); - WriteCT_ChartExTitle(pVal->m_title.GetPointer()); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_legend.IsInit()) - { - nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExChartLEGEND); - WriteCT_ChartExLegend(pVal->m_legend.GetPointer()); - m_oBcw.WriteItemEnd(nCurPos); - } - } - void BinaryChartWriter::WriteCT_ChartExData(OOX::Spreadsheet::ChartEx::CData *pVal) - { - if (!pVal) return; - - if (pVal->m_id.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataID); - m_oBcw.m_oStream.WriteULONG(*pVal->m_id); - m_oBcw.WriteItemEnd(nCurPos); - } - for (size_t i = 0; i < pVal->m_arDimension.size(); ++i) - { - OOX::Spreadsheet::ChartEx::CStrDimension *pStr = dynamic_cast(pVal->m_arDimension[i]); - if (pStr) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataSTRDIMENSION); - WriteCT_ChartExDataDimension(pStr); - m_oBcw.WriteItemEnd(nCurPos); - } - else - { - OOX::Spreadsheet::ChartEx::CNumDimension *pNum = dynamic_cast(pVal->m_arDimension[i]); - if (pNum) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataNUMDIMENSION); - WriteCT_ChartExDataDimension(pNum); - m_oBcw.WriteItemEnd(nCurPos); - } - } - } - } - void BinaryChartWriter::WriteCT_ChartExDataDimension(OOX::Spreadsheet::ChartEx::CStrDimension *pVal) - { - if (!pVal) return; - - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataDimensionTYPE); - m_oBcw.m_oStream.WriteBYTE(pVal->m_type->GetValue()); - m_oBcw.WriteItemEnd(nCurPos); - - if (pVal->m_f.IsInit()) - { - nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataDimensionFORMULA); - WriteCT_ChartExFormula(pVal->m_f.GetPointer()); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_nf.IsInit()) - { - nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataDimensionNF); - m_oBcw.m_oStream.WriteStringW4(*pVal->m_nf); - m_oBcw.WriteItemEnd(nCurPos); - } - - for (size_t i = 0; i < pVal->m_levelData.size(); ++i) - { - if (pVal->m_levelData[i]) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataDimensionSTRINGLEVEL); - WriteCT_ChartExStringLevel(pVal->m_levelData[i]); - m_oBcw.WriteItemEnd(nCurPos); - } - } - } - void BinaryChartWriter::WriteCT_ChartExDataDimension(OOX::Spreadsheet::ChartEx::CNumDimension *pVal) - { - if (!pVal) return; - - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataDimensionTYPE); - m_oBcw.m_oStream.WriteBYTE(pVal->m_type->GetValue()); - m_oBcw.WriteItemEnd(nCurPos); - - if (pVal->m_f.IsInit()) - { - nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataDimensionFORMULA); - WriteCT_ChartExFormula(pVal->m_f.GetPointer()); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_nf.IsInit()) - { - nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataDimensionNF); - m_oBcw.m_oStream.WriteStringW4(*pVal->m_nf); - m_oBcw.WriteItemEnd(nCurPos); - } - for (size_t i = 0; i < pVal->m_levelData.size(); ++i) - { - if (pVal->m_levelData[i]) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataDimensionNUMERICLEVEL); - WriteCT_ChartExNumericLevel(pVal->m_levelData[i]); - m_oBcw.WriteItemEnd(nCurPos); - } - } - } - void BinaryChartWriter::WriteCT_ChartExExternalData(OOX::Spreadsheet::ChartEx::CExternalData *pVal) - { - if (!pVal) return; - - if (pVal->m_autoUpdate.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExExternalAUTOUPDATE); - m_oBcw.m_oStream.WriteBOOL(*pVal->m_autoUpdate); - m_oBcw.WriteItemEnd(nCurPos); - } - //if(NULL != pVal.m_id) - выше - } - void BinaryChartWriter::WriteCT_ChartExFormula(OOX::Spreadsheet::ChartEx::CFormula *pVal) - { - if (!pVal) return; - - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExFormulaCONTENT); - m_oBcw.m_oStream.WriteStringW4(pVal->m_content); - m_oBcw.WriteItemEnd(nCurPos); - - if (pVal->m_dir.IsInit()) - { - nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExFormulaDIRECTION); - m_oBcw.m_oStream.WriteBYTE(pVal->m_dir->GetValue()); - m_oBcw.WriteItemEnd(nCurPos); - } - } - void BinaryChartWriter::WriteCT_ChartExStringLevel(OOX::Spreadsheet::ChartEx::CStringLevel *pVal) - { - if (!pVal) return; - - if (pVal->m_name.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataLevelNAME); - m_oBcw.m_oStream.WriteStringW4(*pVal->m_name); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_ptCount.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataLevelCOUNT); - m_oBcw.m_oStream.WriteINT(*pVal->m_ptCount); - m_oBcw.WriteItemEnd(nCurPos); - } - for (size_t i = 0; i < pVal->m_arPt.size(); ++i) - { - if (pVal->m_arPt[i]) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataLevelPT); - WriteCT_ChartExStringValue(pVal->m_arPt[i]); - m_oBcw.WriteItemEnd(nCurPos); - } - } - } - void BinaryChartWriter::WriteCT_ChartExNumericLevel(OOX::Spreadsheet::ChartEx::CNumericLevel *pVal) - { - if (!pVal) return; - - if (pVal->m_name.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataLevelNAME); - m_oBcw.m_oStream.WriteStringW4(*pVal->m_name); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_ptCount.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataLevelCOUNT); - m_oBcw.m_oStream.WriteINT(*pVal->m_ptCount); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_formatCode.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataLevelFORMATCODE); - m_oBcw.m_oStream.WriteStringW4(*pVal->m_formatCode); - m_oBcw.WriteItemEnd(nCurPos); - } - for (size_t i = 0; i < pVal->m_arPt.size(); ++i) - { - if (pVal->m_arPt[i]) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataLevelPT); - WriteCT_ChartExNumericValue(pVal->m_arPt[i]); - m_oBcw.WriteItemEnd(nCurPos); - } - } - } - void BinaryChartWriter::WriteCT_ChartExStringValue(OOX::Spreadsheet::ChartEx::CStringValue *pVal) - { - if (!pVal) return; - - if (pVal->m_idx.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataValueIDX); - m_oBcw.m_oStream.WriteLONG(*pVal->m_idx); - m_oBcw.WriteItemEnd(nCurPos); - } - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataValueCONTENT); - m_oBcw.m_oStream.WriteStringW4(pVal->m_content); - m_oBcw.WriteItemEnd(nCurPos); - } - void BinaryChartWriter::WriteCT_ChartExNumericValue(OOX::Spreadsheet::ChartEx::CNumericValue *pVal) - { - if (!pVal) return; - - if (pVal->m_idx.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataValueIDX); - m_oBcw.m_oStream.WriteLONG(*pVal->m_idx); - m_oBcw.WriteItemEnd(nCurPos); - } - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataValueCONTENT); - m_oBcw.m_oStream.WriteDouble(*pVal->m_content); - m_oBcw.WriteItemEnd(nCurPos); - } - void BinaryChartWriter::WriteCT_ChartExPlotArea(OOX::Spreadsheet::ChartEx::CPlotArea*pVal) - { - if (!pVal) return; - - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExChartAREAREGION); - WriteCT_ChartExPlotAreaRegion(&pVal->m_plotAreaRegion); - m_oBcw.WriteItemEnd(nCurPos); - - for (size_t i = 0; i < pVal->m_arAxis.size(); ++i) - { - if (pVal->m_arAxis[i]) - { - nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExChartAXIS); - WriteCT_ChartExAxis(pVal->m_arAxis[i]); - m_oBcw.WriteItemEnd(nCurPos); - } - } - if (pVal->m_oSpPr.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExChartSPPR); - m_oBcw.m_oStream.WriteRecord2(0, pVal->m_oSpPr); - m_oBcw.WriteItemEnd(nCurPos); - } - } - void BinaryChartWriter::WriteCT_ChartExTitle(OOX::Spreadsheet::ChartEx::CTitle *pVal) - { - if (!pVal) return; - - if (pVal->m_tx.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExTitleTX); - WriteCT_ChartExText(pVal->m_tx.GetPointer()); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_oTxPr.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExTitleTXPR); - m_oBcw.m_oStream.WriteRecord2(0, pVal->m_oTxPr); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_oSpPr.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExTitleSPPR); - m_oBcw.m_oStream.WriteRecord2(0, pVal->m_oSpPr); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_pos.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExTitlePOS); - m_oBcw.m_oStream.WriteBYTE(pVal->m_pos->GetValue()); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_align.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExTitleALIGN); - m_oBcw.m_oStream.WriteBYTE(pVal->m_align->GetValue()); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_overlay.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExTitleOVERLAY); - m_oBcw.m_oStream.WriteBOOL(*pVal->m_overlay); - m_oBcw.WriteItemEnd(nCurPos); - } - } - void BinaryChartWriter::WriteCT_ChartExLegend(OOX::Spreadsheet::ChartEx::CLegend *pVal) - { - if (!pVal) return; - - if (pVal->m_oTxPr.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExLegendTXPR); - m_oBcw.m_oStream.WriteRecord2(0, pVal->m_oTxPr); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_oSpPr.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExLegendSPPR); - m_oBcw.m_oStream.WriteRecord2(0, pVal->m_oSpPr); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_pos.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExLegendPOS); - m_oBcw.m_oStream.WriteBYTE(pVal->m_pos->GetValue()); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_align.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExLegendALIGN); - m_oBcw.m_oStream.WriteBYTE(pVal->m_align->GetValue()); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_overlay.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExLegendOVERLAY); - m_oBcw.m_oStream.WriteBOOL(*pVal->m_overlay); - m_oBcw.WriteItemEnd(nCurPos); - } - } - void BinaryChartWriter::WriteCT_ChartExPlotAreaRegion(OOX::Spreadsheet::ChartEx::CPlotAreaRegion *pVal) - { - if (!pVal) return; - - if (pVal->m_plotSurface.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExAreaPLOTSURFACE); - WriteCT_ChartExPlotSurface(pVal->m_plotSurface.GetPointer()); - m_oBcw.WriteItemEnd(nCurPos); - } - for (size_t i = 0; i < pVal->m_arSeries.size(); ++i) - { - if (pVal->m_arSeries[i]) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExAreaSERIES); - WriteCT_ChartExSeries(pVal->m_arSeries[i]); - m_oBcw.WriteItemEnd(nCurPos); - } - } - } - void BinaryChartWriter::WriteCT_ChartExAxis(OOX::Spreadsheet::ChartEx::CAxis *pVal) - { - if (pVal->m_id.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExAxisID); - m_oBcw.m_oStream.WriteLONG(*pVal->m_id); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_hidden.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExAxisHIDDEN); - m_oBcw.m_oStream.WriteBOOL(*pVal->m_hidden); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_catScaling.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExAxisCATSCALING); - WriteCT_ChartExCatScaling(pVal->m_catScaling.GetPointer()); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_valScaling.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExAxisVALSCALING); - WriteCT_ChartExValScaling(pVal->m_valScaling.GetPointer()); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_title.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExAxisTITLE); - WriteCT_ChartExTitle(pVal->m_title.GetPointer()); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_units.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExAxisUNIT); - WriteCT_ChartExAxisUnit(pVal->m_units.GetPointer()); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_numFmt.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExAxisNUMFMT); - WriteCT_ChartExNumberFormat(pVal->m_numFmt.GetPointer()); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_majorTickMarks.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExAxisMAJORTICK); - WriteCT_ChartExTickMarks(pVal->m_majorTickMarks.GetPointer()); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_minorTickMarks.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExAxisMINORTICK); - WriteCT_ChartExTickMarks(pVal->m_minorTickMarks.GetPointer()); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_majorGridlines.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExAxisMAJORGRID); - WriteCT_ChartExGridlines(pVal->m_majorGridlines.GetPointer()); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_minorGridlines.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExAxisMINORGRID); - WriteCT_ChartExGridlines(pVal->m_minorGridlines.GetPointer()); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_tickLabels.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExAxisTICKLABELS); - m_oBcw.m_oStream.WriteBOOL(*pVal->m_tickLabels); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_oTxPr.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExAxisTXPR); - m_oBcw.m_oStream.WriteRecord2(0, pVal->m_oTxPr); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_oSpPr.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExAxisSPPR); - m_oBcw.m_oStream.WriteRecord2(0, pVal->m_oSpPr); - m_oBcw.WriteItemEnd(nCurPos); - } - } - void BinaryChartWriter::WriteCT_ChartExText(OOX::Spreadsheet::ChartEx::CText *pVal) - { - if (!pVal) return; - - if (pVal->m_oRich.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExTextRICH); - m_oBcw.m_oStream.WriteRecord2(0, pVal->m_oRich); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_txData.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExTextDATA); - WriteCT_ChartExTextData(pVal->m_txData.GetPointer()); - m_oBcw.WriteItemEnd(nCurPos); - } - } - void BinaryChartWriter::WriteCT_ChartExTextData(OOX::Spreadsheet::ChartEx::CTextData *pVal) - { - if (!pVal) return; - - if (pVal->m_oF.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExTextDataFORMULA); - WriteCT_ChartExFormula(pVal->m_oF.GetPointer()); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_oV.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExTextDataVALUE); - m_oBcw.m_oStream.WriteStringW4(*pVal->m_oV); - m_oBcw.WriteItemEnd(nCurPos); - } - - } - void BinaryChartWriter::WriteCT_ChartExPlotSurface(OOX::Spreadsheet::ChartEx::CPlotSurface *pVal) - { - if (!pVal) return; - - if (pVal->m_oSpPr.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExPlotSurfaceSPPR); - m_oBcw.m_oStream.WriteRecord2(0, pVal->m_oSpPr); - m_oBcw.WriteItemEnd(nCurPos); - } - } - void BinaryChartWriter::WriteCT_ChartExSeries(OOX::Spreadsheet::ChartEx::CSeries *pVal) - { - for (size_t i = 0; i < pVal->m_arDataPt.size(); ++i) - { - if (pVal->m_arDataPt[i]) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExSeriesDATAPT); - WriteCT_ChartExDataPoint(pVal->m_arDataPt[i]); - m_oBcw.WriteItemEnd(nCurPos); - } - } - if (pVal->m_dataLabels.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExSeriesDATALABELS); - WriteCT_ChartExDataLabels(pVal->m_dataLabels.GetPointer()); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_layoutPr.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExSeriesLAYOUTPROPS); - WriteCT_ChartExSeriesLayoutProperties(pVal->m_layoutPr.GetPointer()); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_tx.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExSeriesTEXT); - WriteCT_ChartExText(pVal->m_tx.GetPointer()); - m_oBcw.WriteItemEnd(nCurPos); - } - for (size_t i = 0; i < pVal->m_arAxisId.size(); ++i) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExSeriesAXIS); - m_oBcw.m_oStream.WriteULONG(pVal->m_arAxisId[i]); - m_oBcw.WriteItemEnd(nCurPos); - } - if ((pVal->m_dataId.IsInit()) && (pVal->m_dataId->m_oVal.IsInit())) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExSeriesDATAID); - m_oBcw.m_oStream.WriteLONG(*(pVal->m_dataId->m_oVal)); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_oSpPr.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExSeriesSPPR); - m_oBcw.m_oStream.WriteRecord2(0, pVal->m_oSpPr); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_oLayoutId.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExSeriesLAYOUTID); - m_oBcw.m_oStream.WriteBYTE(pVal->m_oLayoutId->GetValue()); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_bHidden.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExSeriesHIDDEN); - m_oBcw.m_oStream.WriteBOOL(*pVal->m_bHidden); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_nOwnerIdx.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExSeriesOWNERIDX); - m_oBcw.m_oStream.WriteLONG(*pVal->m_nOwnerIdx); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_nFormatIdx.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExSeriesFORMATIDX); - m_oBcw.m_oStream.WriteLONG(*pVal->m_nFormatIdx); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_sUniqueId.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExSeriesUNIQUEID); - m_oBcw.m_oStream.WriteStringW4(*pVal->m_sUniqueId); - m_oBcw.WriteItemEnd(nCurPos); - } - } - void BinaryChartWriter::WriteCT_ChartExDataPoint(OOX::Spreadsheet::ChartEx::CDataPoint *pVal) - { - if (pVal->m_idx.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataPointIDX); - m_oBcw.m_oStream.WriteLONG(*pVal->m_idx); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_oSpPr.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataPointSPPR); - m_oBcw.m_oStream.WriteRecord2(0, pVal->m_oSpPr); - m_oBcw.WriteItemEnd(nCurPos); - } - } - void BinaryChartWriter::WriteCT_ChartExDataLabels(OOX::Spreadsheet::ChartEx::CDataLabels *pVal) - { - if (pVal->m_pos.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataLabelsPOS); - m_oBcw.m_oStream.WriteBYTE(pVal->m_pos->GetValue()); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_numFmt.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataLabelsNUMFMT); - WriteCT_ChartExNumberFormat(pVal->m_numFmt.GetPointer()); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_oTxPr.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataLabelsTXPR); - m_oBcw.m_oStream.WriteRecord2(0, pVal->m_oTxPr); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_oSpPr.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataLabelsSPPR); - m_oBcw.m_oStream.WriteRecord2(0, pVal->m_oSpPr); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_visibility.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataLabelsVISABILITIES); - WriteCT_ChartExDataLabelVisibilities(pVal->m_visibility.GetPointer()); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_separator.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataLabelsSEPARATOR); - m_oBcw.m_oStream.WriteStringW4(*pVal->m_separator); - m_oBcw.WriteItemEnd(nCurPos); - } - for (size_t i = 0; i < pVal->m_arDataLabel.size(); ++i) - { - if (pVal->m_arDataLabel[i]) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataLabelsDATALABEL); - WriteCT_ChartExDataLabel(pVal->m_arDataLabel[i]); - m_oBcw.WriteItemEnd(nCurPos); - } - } - for (size_t i = 0; i < pVal->m_arDataLabelHidden.size(); ++i) - { - if (pVal->m_arDataLabelHidden[i]) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataLabelsDATALABELHIDDEN); - WriteCT_ChartExDataLabelHidden(pVal->m_arDataLabelHidden[i]); - m_oBcw.WriteItemEnd(nCurPos); - } - } - } - void BinaryChartWriter::WriteCT_ChartExDataLabel(OOX::Spreadsheet::ChartEx::CDataLabel *pVal) - { - if (pVal->m_idx.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataLabelIDX); - m_oBcw.m_oStream.WriteLONG(*pVal->m_idx); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_dataLabelPos.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataLabelPOS); - m_oBcw.m_oStream.WriteBYTE(pVal->m_dataLabelPos->GetValue()); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_numFmt.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataLabelNUMFMT); - WriteCT_ChartExNumberFormat(pVal->m_numFmt.GetPointer()); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_oTxPr.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataLabelTXPR); - m_oBcw.m_oStream.WriteRecord2(0, pVal->m_oTxPr); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_oSpPr.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataLabelSPPR); - m_oBcw.m_oStream.WriteRecord2(0, pVal->m_oSpPr); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_separator.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataLabelSEPARATOR); - m_oBcw.m_oStream.WriteStringW4(*pVal->m_separator); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_visibility.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataLabelVISABILITIES); - WriteCT_ChartExDataLabelVisibilities(pVal->m_visibility.GetPointer()); - m_oBcw.WriteItemEnd(nCurPos); - } - } - void BinaryChartWriter::WriteCT_ChartExDataLabelHidden(OOX::Spreadsheet::ChartEx::CDataLabelHidden *pVal) - { - if (pVal->m_idx.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataLabelHiddenIDX); - m_oBcw.m_oStream.WriteLONG(*pVal->m_idx); - m_oBcw.WriteItemEnd(nCurPos); - } - } - void BinaryChartWriter::WriteCT_ChartExSeriesLayoutProperties(OOX::Spreadsheet::ChartEx::CSeriesLayoutProperties *pVal) - { - if ((pVal->m_parentLabelLayout.IsInit()) && (pVal->m_parentLabelLayout->m_oVal.IsInit())) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExSeriesLayoutPARENT); - m_oBcw.m_oStream.WriteBYTE(pVal->m_parentLabelLayout->m_oVal->GetValue()); - m_oBcw.WriteItemEnd(nCurPos); - } - if ((pVal->m_regionLabelLayout.IsInit()) && (pVal->m_regionLabelLayout->m_oVal.IsInit())) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExSeriesLayoutREGION); - m_oBcw.m_oStream.WriteBYTE(pVal->m_regionLabelLayout->m_oVal->GetValue()); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_visibility.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExSeriesLayoutVISABILITIES); - WriteCT_ChartExSeriesElementVisibilities(pVal->m_visibility.GetPointer()); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_aggregation.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExSeriesLayoutAGGREGATION); - m_oBcw.m_oStream.WriteBOOL(*pVal->m_aggregation); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_binning.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExSeriesLayoutBINNING); - WriteCT_ChartExBinning(pVal->m_binning.GetPointer()); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_statistics.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExSeriesLayoutSTATISTIC); - WriteCT_ChartExStatistics(pVal->m_statistics.GetPointer()); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_subtotals.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExSeriesLayoutSUBTOTALS); - WriteCT_ChartExSubtotals(pVal->m_subtotals.GetPointer()); - m_oBcw.WriteItemEnd(nCurPos); - } - } - void BinaryChartWriter::WriteCT_ChartExNumberFormat(OOX::Spreadsheet::ChartEx::CNumberFormat *pVal) - { - if (pVal->m_formatCode.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExNumberFormatFORMATCODE); - m_oBcw.m_oStream.WriteStringW4(*pVal->m_formatCode); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_sourceLinked.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExNumberFormatSOURCELINKED); - m_oBcw.m_oStream.WriteBOOL(*pVal->m_sourceLinked); - m_oBcw.WriteItemEnd(nCurPos); - } - } - void BinaryChartWriter::WriteCT_ChartExDataLabelVisibilities(OOX::Spreadsheet::ChartEx::CDataLabelVisibilities *pVal) - { - if (pVal->m_seriesName.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataLabelVisibilitiesSERIES); - m_oBcw.m_oStream.WriteBOOL(*pVal->m_seriesName); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_categoryName.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataLabelVisibilitiesCATEGORY); - m_oBcw.m_oStream.WriteBOOL(*pVal->m_categoryName); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_value.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExDataLabelVisibilitiesVALUE); - m_oBcw.m_oStream.WriteBOOL(*pVal->m_value); - m_oBcw.WriteItemEnd(nCurPos); - } - } - void BinaryChartWriter::WriteCT_ChartExBinning(OOX::Spreadsheet::ChartEx::CBinning *pVal) - { - if (pVal->m_binSize.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExBinningBINSIZE); - m_oBcw.m_oStream.WriteDouble(*pVal->m_binSize); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_binCount.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExBinningBINCOUNT); - m_oBcw.m_oStream.WriteLONG(*pVal->m_binCount); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_intervalClosed.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExBinningINTERVAL); - m_oBcw.m_oStream.WriteBYTE(pVal->m_intervalClosed->GetValue()); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_underflow.IsInit()) - { - if (pVal->m_underflow->GetValue() == SimpleTypes::Spreadsheet::typeAuto) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExBinningUNDERAUTO); - m_oBcw.m_oStream.WriteBYTE(pVal->m_underflow->GetValue()); - m_oBcw.WriteItemEnd(nCurPos); - } - else - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExBinningUNDERVAL); - m_oBcw.m_oStream.WriteDouble(pVal->m_underflow->GetDoubleValue()); - m_oBcw.WriteItemEnd(nCurPos); - } - } - if (pVal->m_overflow.IsInit()) - { - if (pVal->m_underflow->GetValue() == SimpleTypes::Spreadsheet::typeAuto) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExBinningOVERAUTO); - m_oBcw.m_oStream.WriteBYTE(pVal->m_overflow->GetValue()); - m_oBcw.WriteItemEnd(nCurPos); - } - else - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExBinningOVERVAL); - m_oBcw.m_oStream.WriteDouble(pVal->m_overflow->GetDoubleValue()); - m_oBcw.WriteItemEnd(nCurPos); - } - } - } - void BinaryChartWriter::WriteCT_ChartExStatistics(OOX::Spreadsheet::ChartEx::CStatistics *pVal) - { - if (pVal->m_quartileMethod.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExStatisticsMETHOD); - m_oBcw.m_oStream.WriteBYTE(pVal->m_quartileMethod->GetValue()); - m_oBcw.WriteItemEnd(nCurPos); - } - } - void BinaryChartWriter::WriteCT_ChartExSubtotals(OOX::Spreadsheet::ChartEx::CSubtotals *pVal) - { - for (size_t i = 0; i < pVal->m_arIdx.size(); ++i) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExSubtotalsIDX); - m_oBcw.m_oStream.WriteULONG(pVal->m_arIdx[i]); - m_oBcw.WriteItemEnd(nCurPos); - } - - } - void BinaryChartWriter::WriteCT_ChartExSeriesElementVisibilities(OOX::Spreadsheet::ChartEx::CSeriesElementVisibilities *pVal) - { - if (pVal->m_connectorLines.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExSeriesVisibilitiesCONNECTOR); - m_oBcw.m_oStream.WriteBOOL(*pVal->m_connectorLines); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_meanLine.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExSeriesVisibilitiesMEANLINE); - m_oBcw.m_oStream.WriteBOOL(*pVal->m_meanLine); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_meanMarker.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExSeriesVisibilitiesMEANMARKER); - m_oBcw.m_oStream.WriteBOOL(*pVal->m_meanMarker); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_nonoutliers.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExSeriesVisibilitiesNONOUTLIERS); - m_oBcw.m_oStream.WriteBOOL(*pVal->m_nonoutliers); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_outliers.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExSeriesVisibilitiesOUTLIERS); - m_oBcw.m_oStream.WriteBOOL(*pVal->m_outliers); - m_oBcw.WriteItemEnd(nCurPos); - } - } - void BinaryChartWriter::WriteCT_ChartExCatScaling(OOX::Spreadsheet::ChartEx::CCatScaling *pVal) - { - if (!pVal) return; - - if (pVal->m_gapWidth.IsInit()) - { - if (pVal->m_gapWidth->GetValue() == SimpleTypes::Spreadsheet::typeAuto) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExCatScalingGAPAUTO); - m_oBcw.m_oStream.WriteBYTE(pVal->m_gapWidth->GetValue()); - m_oBcw.WriteItemEnd(nCurPos); - } - else - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExCatScalingGAPVAL); - m_oBcw.m_oStream.WriteDouble(pVal->m_gapWidth->GetDoubleValue()); - m_oBcw.WriteItemEnd(nCurPos); - } - } - } - void BinaryChartWriter::WriteCT_ChartExValScaling(OOX::Spreadsheet::ChartEx::CValScaling *pVal) - { - if (!pVal) return; - - if (pVal->m_max.IsInit()) - { - if (pVal->m_max->GetValue() == SimpleTypes::Spreadsheet::typeAuto) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExValScalingMAXAUTO); - m_oBcw.m_oStream.WriteBYTE(pVal->m_max->GetValue()); - m_oBcw.WriteItemEnd(nCurPos); - } - else - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExValScalingMAXVAL); - m_oBcw.m_oStream.WriteDouble(pVal->m_max->GetDoubleValue()); - m_oBcw.WriteItemEnd(nCurPos); - } - } - if (pVal->m_min.IsInit()) - { - if (pVal->m_min->GetValue() == SimpleTypes::Spreadsheet::typeAuto) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExValScalingMINAUTO); - m_oBcw.m_oStream.WriteBYTE(pVal->m_min->GetValue()); - m_oBcw.WriteItemEnd(nCurPos); - } - else - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExValScalingMINVAL); - m_oBcw.m_oStream.WriteDouble(pVal->m_min->GetDoubleValue()); - m_oBcw.WriteItemEnd(nCurPos); - } - } - if (pVal->m_majorUnit.IsInit()) - { - if (pVal->m_majorUnit->GetValue() == SimpleTypes::Spreadsheet::typeAuto) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExValScalingMAJUNITAUTO); - m_oBcw.m_oStream.WriteBYTE(pVal->m_majorUnit->GetValue()); - m_oBcw.WriteItemEnd(nCurPos); - } - else - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExValScalingMAJUNITVAL); - m_oBcw.m_oStream.WriteDouble(pVal->m_majorUnit->GetDoubleValue()); - m_oBcw.WriteItemEnd(nCurPos); - } - } - if (pVal->m_minorUnit.IsInit()) - { - if (pVal->m_minorUnit->GetValue() == SimpleTypes::Spreadsheet::typeAuto) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExValScalingMINUNITAUTO); - m_oBcw.m_oStream.WriteBYTE(pVal->m_minorUnit->GetValue()); - m_oBcw.WriteItemEnd(nCurPos); - } - else - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExValScalingMINUNITVAL); - m_oBcw.m_oStream.WriteDouble(pVal->m_minorUnit->GetDoubleValue()); - m_oBcw.WriteItemEnd(nCurPos); - } - } - } - void BinaryChartWriter::WriteCT_ChartExAxisUnit(OOX::Spreadsheet::ChartEx::CAxisUnit *pVal) - { - if (!pVal) return; - - if (pVal->m_unitsLabel.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExAxisUnitLABEL); - WriteCT_ChartExAxisUnitsLabel(pVal->m_unitsLabel.GetPointer()); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_unit.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExAxisUnitTYPE); - m_oBcw.m_oStream.WriteBYTE(pVal->m_unit->GetValue()); - m_oBcw.WriteItemEnd(nCurPos); - } - } - void BinaryChartWriter::WriteCT_ChartExAxisUnitsLabel(OOX::Spreadsheet::ChartEx::CAxisUnitsLabel *pVal) - { - if (!pVal) return; - if (pVal->m_tx.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExAxisUnitsLabelTEXT); - WriteCT_ChartExText(pVal->m_tx.GetPointer()); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_oSpPr.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExAxisUnitsLabelSPPR); - m_oBcw.m_oStream.WriteRecord2(0, pVal->m_oSpPr); - m_oBcw.WriteItemEnd(nCurPos); - } - if (pVal->m_oTxPr.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExAxisUnitsLabelTXPR); - m_oBcw.m_oStream.WriteRecord2(0, pVal->m_oTxPr); - m_oBcw.WriteItemEnd(nCurPos); - } - } - void BinaryChartWriter::WriteCT_ChartExTickMarks(OOX::Spreadsheet::ChartEx::CTickMarks *pVal) - { - if (!pVal) return; - - if (pVal->m_type.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExTickMarksTYPE); - m_oBcw.m_oStream.WriteBYTE(pVal->m_type->GetValue()); - m_oBcw.WriteItemEnd(nCurPos); - } - } - void BinaryChartWriter::WriteCT_ChartExGridlines(OOX::Spreadsheet::ChartEx::CGridlines *pVal) - { - if (!pVal) return; - - if (pVal->m_oSpPr.IsInit()) - { - int nCurPos = m_oBcw.WriteItemStart(c_oserct_chartExGridlinesSPPR); - m_oBcw.m_oStream.WriteRecord2(0, pVal->m_oSpPr); + WriteCT_Style1(*oVal.m_style); m_oBcw.WriteItemEnd(nCurPos); } } diff --git a/XlsxSerializerCom/Reader/ChartFromToBinary.h b/XlsxSerializerCom/Reader/ChartFromToBinary.h index 7e12549502..3728f59543 100644 --- a/XlsxSerializerCom/Reader/ChartFromToBinary.h +++ b/XlsxSerializerCom/Reader/ChartFromToBinary.h @@ -41,50 +41,7 @@ namespace OOX { namespace Spreadsheet { - class CChartFile; - class CChartStyleFile; - class CChartColorsFile; - class CChartExFile; - namespace ChartEx - { - class CChartData; - class CChart; - class CData; - class CExternalData; - class CStrDimension; - class CNumDimension; - class CNumericLevel; - class CStringLevel; - class CNumericValue; - class CStringValue; - class CFormula; - class CPlotArea; - class CTitle; - class CLegend; - class CPlotAreaRegion; - class CAxis; - class CText; - class CTextData; - class CPlotSurface; - class CSeries; - class CDataPoint; - class CDataLabels; - class CDataLabel; - class CDataLabelHidden; - class CSeriesLayoutProperties; - class CNumberFormat; - class CDataLabelVisibilities; - class CBinning; - class CStatistics; - class CSubtotals; - class CSeriesElementVisibilities; - class CCatScaling; - class CValScaling; - class CAxisUnit; - class CTickMarks; - class CGridlines; - class CAxisUnitsLabel; - } + class CChartSpace; } class CSizeAnchor; class CFromTo; @@ -96,12 +53,11 @@ namespace BinXlsxRW class SaveParams { public: - SaveParams (const std::wstring& _sDrawingsPath, const std::wstring& _sEmbeddingsPath, const std::wstring& _sThemePath, OOX::CContentTypes *pContentTypes, CSVWriter::CCSVWriter* pCSVWriter = NULL); + SaveParams (const std::wstring& _sDrawingsPath, const std::wstring& _sThemePath, OOX::CContentTypes *pContentTypes, CSVWriter::CCSVWriter* pCSVWriter = NULL); smart_ptr pTheme; std::wstring sThemePath; std::wstring sDrawingsPath; - std::wstring sEmbeddingsPath; OOX::CContentTypes* pContentTypes; int nThemeOverrideCount; CSVWriter::CCSVWriter* pCSVWriter; @@ -114,16 +70,10 @@ namespace BinXlsxRW public: BinaryChartReader (NSBinPptxRW::CBinaryFileReader& oBufferedStream, SaveParams& oSaveParams, NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter); - int ReadCT_ChartFile (long length, OOX::Spreadsheet::CChartFile* poResult); - int ReadCT_ChartExFile (long length, OOX::Spreadsheet::CChartExFile* poResult); - private: - int ReadCT_ChartColors (BYTE type, long length, void* poResult); - int ReadCT_ColorsVariation (BYTE type, long length, void* poResult); - int ReadCT_ChartStyle (BYTE type, long length, void* poResult); - int ReadCT_StyleEntry (BYTE type, long length, void* poResult); - int ReadCT_StyleMarkerLayout (BYTE type, long length, void* poResult); + int ReadCT_ChartSpace (long length, OOX::Spreadsheet::CChartSpace* poResult); + private: int ReadCT_extLst (BYTE type, long length, void* poResult); - int ReadCT_ChartFileContent (BYTE type, long length, void* poResult); + int ReadCT_ChartSpace (BYTE type, long length, void* poResult); int ReadCT_Boolean (BYTE type, long length, void* poResult); int ReadCT_PageSetup (BYTE type, long length, void* poResult); int ReadCT_PageMargins (BYTE type, long length, void* poResult); @@ -255,261 +205,173 @@ namespace BinXlsxRW int ReadCT_Chart (BYTE type, long length, void* poResult); int ReadCT_Protection (BYTE type, long length, void* poResult); int ReadCT_PivotSource (BYTE type, long length, void* poResult); + int ReadCT_Style1 (BYTE type, long length, void* poResult); int ReadCT_Style (BYTE type, long length, void* poResult); int ReadCT_TextLanguageID (BYTE type, long length, void* poResult); int ReadAlternateContent (BYTE type, long length, void* poResult); int ReadAlternateContentChoice (BYTE type, long length, void* poResult); int ReadAlternateContentFallback(BYTE type, long length, void* poResult); - int ReadCT_PptxElement (BYTE type, long length, void* poResult); - + int ReadCT_SpPr (BYTE type, long length, void* poResult); + int ReadCT_TxPr (BYTE type, long length, void* poResult); + int ReadCT_userShapes (BYTE type, long length, void* poResult); int ReadCT_userShape (BYTE type, long length, void* poResult); int ReadCT_FromTo (BYTE type, long length, void* poResult); int ReadCT_Ext (BYTE type, long length, void* poResult); - - int ReadCT_ExternalXlsx (BYTE *pData, long length, NSCommon::smart_ptr & file); - - int ReadCT_ChartExFileContent (BYTE type, long length, void* poResult); - int ReadCT_ChartExChart (BYTE type, long length, void* poResult); - int ReadCT_ChartExChartData (BYTE type, long length, void* poResult); - int ReadCT_ChartExData (BYTE type, long length, void* poResult); - int ReadCT_ChartExExternalData (BYTE type, long length, void* poResult); - int ReadCT_ChartExDataStrDimension (BYTE type, long length, void* poResult); - int ReadCT_ChartExDataNumDimension (BYTE type, long length, void* poResult); - int ReadCT_ChartExFormula (BYTE type, long length, void* poResult); - int ReadCT_ChartExStringLevel (BYTE type, long length, void* poResult); - int ReadCT_ChartExNumericLevel (BYTE type, long length, void* poResult); - int ReadCT_ChartExStringValue (BYTE type, long length, void* poResult); - int ReadCT_ChartExNumericValue (BYTE type, long length, void* poResult); - int ReadCT_ChartExPlotArea(BYTE type, long length, void* poResult); - int ReadCT_ChartExPlotAreaRegion(BYTE type, long length, void* poResult); - int ReadCT_ChartExTitle(BYTE type, long length, void* poResult); - int ReadCT_ChartExLegend(BYTE type, long length, void* poResult); - int ReadCT_ChartExText(BYTE type, long length, void* poResult); - int ReadCT_ChartExTextData(BYTE type, long length, void* poResult); - int ReadCT_ChartExPlotSurface(BYTE type, long length, void* poResult); - int ReadCT_ChartExSeries(BYTE type, long length, void* poResult); - int ReadCT_ChartExDataPoint(BYTE type, long length, void* poResult); - int ReadCT_ChartExDataLabels(BYTE type, long length, void* poResult); - int ReadCT_ChartExDataLabel(BYTE type, long length, void* poResult); - int ReadCT_ChartExDataLabelHidden(BYTE type, long length, void* poResult); - int ReadCT_ChartExSeriesLayoutProperties(BYTE type, long length, void* poResult); - int ReadCT_ChartExNumberFormat(BYTE type, long length, void* poResult); - int ReadCT_ChartExDataLabelVisibilities(BYTE type, long length, void* poResult); - int ReadCT_ChartExBinning(BYTE type, long length, void* poResult); - int ReadCT_ChartExStatistics(BYTE type, long length, void* poResult); - int ReadCT_ChartExSubtotals(BYTE type, long length, void* poResult); - int ReadCT_ChartExSeriesElementVisibilities(BYTE type, long length, void* poResult); - int ReadCT_ChartExAxis(BYTE type, long length, void* poResult); - int ReadCT_ChartExCatScaling(BYTE type, long length, void* poResult); - int ReadCT_ChartExValScaling(BYTE type, long length, void* poResult); - int ReadCT_ChartExAxisUnit(BYTE type, long length, void* poResult); - int ReadCT_ChartExTickMarks(BYTE type, long length, void* poResult); - int ReadCT_ChartExGridlines(BYTE type, long length, void* poResult); - int ReadCT_ChartExAxisUnitsLabel(BYTE type, long length, void* poResult); }; class BinaryChartWriter { NSBinPptxRW::CDrawingConverter* m_pOfficeDrawingConverter; BinaryCommonWriter m_oBcw; public: - BinaryChartWriter (NSBinPptxRW::CBinaryFileWriter &oCBufferedStream, NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter); - - void WriteCT_ChartFile (OOX::Spreadsheet::CChartFile& oChartFile); - - void WriteAlternateContent (OOX::Spreadsheet::AlternateContent& oVal); - void WriteAlternateContentChoice (OOX::Spreadsheet::AlternateContentChoice& oVal); - void WriteAlternateContentFallback (OOX::Spreadsheet::AlternateContentFallback& oVal); -//------------------------------------------------------------------------------------------------------------- - void WriteCT_ChartStyle(OOX::Spreadsheet::CChartStyleFile & oVal); -//------------------------------------------------------------------------------------------------------------- - void WriteCT_ChartColor(OOX::Spreadsheet::CChartColorsFile & oVal); -//------------------------------------------------------------------------------------------------------------- - void WriteCT_ChartExFile(OOX::Spreadsheet::CChartExFile & oChartFile); - private: - - void WriteCT_extLst(OOX::Spreadsheet::CT_extLst& oVal); - void WriteCT_Boolean(OOX::Spreadsheet::CT_Boolean& oVal); - void WriteCT_PageSetup(OOX::Spreadsheet::CT_PageSetup& oVal); - void WriteCT_PageMargins(OOX::Spreadsheet::CT_PageMargins& oVal); - void WriteCT_HeaderFooter(OOX::Spreadsheet::CT_HeaderFooter& oVal); - void WriteCT_PrintSettings(OOX::Spreadsheet::CT_PrintSettings& oVal); - void WriteCT_ExternalData(OOX::Spreadsheet::CT_ExternalData& oVal); - void WriteCT_DispBlanksAs(OOX::Spreadsheet::CT_DispBlanksAs& oVal); + BinaryChartWriter (NSBinPptxRW::CBinaryFileWriter &oCBufferedStream, NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter); + void WriteCT_extLst (OOX::Spreadsheet::CT_extLst& oVal); + void WriteCT_ChartSpace (OOX::Spreadsheet::CChartSpace& ChartSpace); + void WriteCT_Boolean (OOX::Spreadsheet::CT_Boolean& oVal); + void WriteCT_RelId (OOX::Spreadsheet::CT_RelId& oVal); + void WriteCT_PageSetup (OOX::Spreadsheet::CT_PageSetup& oVal); + void WriteCT_PageMargins (OOX::Spreadsheet::CT_PageMargins& oVal); + void WriteCT_HeaderFooter (OOX::Spreadsheet::CT_HeaderFooter& oVal); + void WriteCT_PrintSettings (OOX::Spreadsheet::CT_PrintSettings& oVal); + void WriteCT_ExternalData (OOX::Spreadsheet::CT_ExternalData& oVal); + void WriteCT_DispBlanksAs (OOX::Spreadsheet::CT_DispBlanksAs& oVal); void WriteCT_LegendEntry(OOX::Spreadsheet::CT_LegendEntry& oVal); void WriteCT_UnsignedInt(OOX::Spreadsheet::CT_UnsignedInt& oVal); - void WriteCT_Extension(OOX::Spreadsheet::CT_Extension& oVal); - void WriteCT_LegendPos(OOX::Spreadsheet::CT_LegendPos& oVal); - void WriteCT_Legend(OOX::Spreadsheet::CT_Legend& oVal); - void WriteCT_Layout(OOX::Spreadsheet::CT_Layout& oVal); - void WriteCT_ManualLayout(OOX::Spreadsheet::CT_ManualLayout& oVal); - void WriteCT_LayoutTarget(OOX::Spreadsheet::CT_LayoutTarget& oVal); - void WriteCT_LayoutMode(OOX::Spreadsheet::CT_LayoutMode& oVal); - void WriteCT_Double(OOX::Spreadsheet::CT_Double& oVal); - void WriteCT_DTable(OOX::Spreadsheet::CT_DTable& oVal); - void WriteCT_SerAx(OOX::Spreadsheet::CT_SerAx& oVal); - void WriteCT_Scaling(OOX::Spreadsheet::CT_Scaling& oVal); - void WriteCT_LogBase(OOX::Spreadsheet::CT_LogBase& oVal); + void WriteCT_Extension (OOX::Spreadsheet::CT_Extension& oVal); + void WriteCT_LegendPos (OOX::Spreadsheet::CT_LegendPos& oVal); + void WriteCT_Legend (OOX::Spreadsheet::CT_Legend& oVal); + void WriteCT_Layout (OOX::Spreadsheet::CT_Layout& oVal); + void WriteCT_ManualLayout (OOX::Spreadsheet::CT_ManualLayout& oVal); + void WriteCT_LayoutTarget (OOX::Spreadsheet::CT_LayoutTarget& oVal); + void WriteCT_LayoutMode (OOX::Spreadsheet::CT_LayoutMode& oVal); + void WriteCT_Double (OOX::Spreadsheet::CT_Double& oVal); + void WriteCT_DTable (OOX::Spreadsheet::CT_DTable& oVal); + void WriteCT_SerAx (OOX::Spreadsheet::CT_SerAx& oVal); + void WriteCT_Scaling (OOX::Spreadsheet::CT_Scaling& oVal); + void WriteCT_LogBase (OOX::Spreadsheet::CT_LogBase& oVal); void WriteCT_Orientation(OOX::Spreadsheet::CT_Orientation& oVal); - void WriteCT_AxPos(OOX::Spreadsheet::CT_AxPos& oVal); - void WriteCT_ChartLines(OOX::Spreadsheet::CT_ChartLines& oVal); - void WriteCT_Title(OOX::Spreadsheet::CT_Title& oVal); - void WriteCT_Tx(OOX::Spreadsheet::CT_Tx& oVal); - void WriteCT_StrRef(OOX::Spreadsheet::CT_StrRef& oVal); - void WriteCT_StrData(OOX::Spreadsheet::CT_StrData& oVal); - void WriteCT_StrVal(OOX::Spreadsheet::CT_StrVal& oVal); - void WriteCT_NumFmt(OOX::Spreadsheet::CT_NumFmt& oVal); - void WriteCT_TickMark(OOX::Spreadsheet::CT_TickMark& oVal); - void WriteCT_TickLblPos(OOX::Spreadsheet::CT_TickLblPos& oVal); - void WriteCT_Crosses(OOX::Spreadsheet::CT_Crosses& oVal); - void WriteCT_Skip(OOX::Spreadsheet::CT_Skip& oVal); - void WriteCT_TimeUnit(OOX::Spreadsheet::CT_TimeUnit& oVal); - void WriteCT_DateAx(OOX::Spreadsheet::CT_DateAx& oVal); - void WriteCT_LblOffset(OOX::Spreadsheet::CT_LblOffset& oVal); - void WriteCT_AxisUnit(OOX::Spreadsheet::CT_AxisUnit& oVal); - void WriteCT_LblAlgn(OOX::Spreadsheet::CT_LblAlgn& oVal); - void WriteCT_CatAx(OOX::Spreadsheet::CT_CatAx& oVal); - void WriteCT_DispUnitsLbl(OOX::Spreadsheet::CT_DispUnitsLbl& oVal); - void WriteCT_BuiltInUnit(OOX::Spreadsheet::CT_BuiltInUnit& oVal); - void WriteCT_DispUnits(OOX::Spreadsheet::CT_DispUnits& oVal); - void WriteCT_CrossBetween(OOX::Spreadsheet::CT_CrossBetween& oVal); - void WriteCT_ValAx(OOX::Spreadsheet::CT_ValAx& oVal); - void WriteCT_SizeRepresents(OOX::Spreadsheet::CT_SizeRepresents& oVal); - void WriteCT_BubbleScale(OOX::Spreadsheet::CT_BubbleScale& oVal); - void WriteCT_BubbleSer(OOX::Spreadsheet::CT_BubbleSer& oVal); - void WriteCT_SerTx(OOX::Spreadsheet::CT_SerTx& oVal); - void WriteCT_DPt(OOX::Spreadsheet::CT_DPt& oVal); - void WriteCT_Marker(OOX::Spreadsheet::CT_Marker& oVal); - void WriteCT_MarkerStyle(OOX::Spreadsheet::CT_MarkerStyle& oVal); - void WriteCT_MarkerSize(OOX::Spreadsheet::CT_MarkerSize& oVal); - void WriteCT_PictureOptions(OOX::Spreadsheet::CT_PictureOptions& oVal); - void WriteCT_PictureFormat(OOX::Spreadsheet::CT_PictureFormat& oVal); + void WriteCT_AxPos (OOX::Spreadsheet::CT_AxPos& oVal); + void WriteCT_ChartLines (OOX::Spreadsheet::CT_ChartLines& oVal); + void WriteCT_Title (OOX::Spreadsheet::CT_Title& oVal); + void WriteCT_Tx (OOX::Spreadsheet::CT_Tx& oVal); + void WriteCT_StrRef (OOX::Spreadsheet::CT_StrRef& oVal); + void WriteCT_StrData (OOX::Spreadsheet::CT_StrData& oVal); + void WriteCT_StrVal (OOX::Spreadsheet::CT_StrVal& oVal); + void WriteCT_NumFmt (OOX::Spreadsheet::CT_NumFmt& oVal); + void WriteCT_TickMark (OOX::Spreadsheet::CT_TickMark& oVal); + void WriteCT_TickLblPos (OOX::Spreadsheet::CT_TickLblPos& oVal); + void WriteCT_Crosses (OOX::Spreadsheet::CT_Crosses& oVal); + void WriteCT_Skip (OOX::Spreadsheet::CT_Skip& oVal); + void WriteCT_TimeUnit (OOX::Spreadsheet::CT_TimeUnit& oVal); + void WriteCT_DateAx (OOX::Spreadsheet::CT_DateAx& oVal); + void WriteCT_LblOffset (OOX::Spreadsheet::CT_LblOffset& oVal); + void WriteCT_AxisUnit (OOX::Spreadsheet::CT_AxisUnit& oVal); + void WriteCT_LblAlgn (OOX::Spreadsheet::CT_LblAlgn& oVal); + void WriteCT_CatAx (OOX::Spreadsheet::CT_CatAx& oVal); + void WriteCT_DispUnitsLbl (OOX::Spreadsheet::CT_DispUnitsLbl& oVal); + void WriteCT_BuiltInUnit (OOX::Spreadsheet::CT_BuiltInUnit& oVal); + void WriteCT_DispUnits (OOX::Spreadsheet::CT_DispUnits& oVal); + void WriteCT_CrossBetween (OOX::Spreadsheet::CT_CrossBetween& oVal); + void WriteCT_ValAx (OOX::Spreadsheet::CT_ValAx& oVal); + void WriteCT_SizeRepresents (OOX::Spreadsheet::CT_SizeRepresents& oVal); + void WriteCT_BubbleScale (OOX::Spreadsheet::CT_BubbleScale& oVal); + void WriteCT_BubbleSer (OOX::Spreadsheet::CT_BubbleSer& oVal); + void WriteCT_SerTx (OOX::Spreadsheet::CT_SerTx& oVal); + void WriteCT_DPt (OOX::Spreadsheet::CT_DPt& oVal); + void WriteCT_Marker (OOX::Spreadsheet::CT_Marker& oVal); + void WriteCT_MarkerStyle (OOX::Spreadsheet::CT_MarkerStyle& oVal); + void WriteCT_MarkerSize (OOX::Spreadsheet::CT_MarkerSize& oVal); + void WriteCT_PictureOptions (OOX::Spreadsheet::CT_PictureOptions& oVal); + void WriteCT_PictureFormat (OOX::Spreadsheet::CT_PictureFormat& oVal); void WriteCT_PictureStackUnit(OOX::Spreadsheet::CT_PictureStackUnit& oVal); - void WriteCT_DLbls(OOX::Spreadsheet::CT_DLbls& oVal); - void WriteCT_DLbl(OOX::Spreadsheet::CT_DLbl& oVal); - void WriteCT_DLblPos(OOX::Spreadsheet::CT_DLblPos& oVal); - void WriteCT_Trendline(OOX::Spreadsheet::CT_Trendline& oVal); - void WriteCT_TrendlineType(OOX::Spreadsheet::CT_TrendlineType& oVal); - void WriteCT_Order(OOX::Spreadsheet::CT_Order& oVal); - void WriteCT_Period(OOX::Spreadsheet::CT_Period& oVal); - void WriteCT_TrendlineLbl(OOX::Spreadsheet::CT_TrendlineLbl& oVal); - void WriteCT_ErrBars(OOX::Spreadsheet::CT_ErrBars& oVal); - void WriteCT_ErrDir(OOX::Spreadsheet::CT_ErrDir& oVal); - void WriteCT_ErrBarType(OOX::Spreadsheet::CT_ErrBarType& oVal); - void WriteCT_ErrValType(OOX::Spreadsheet::CT_ErrValType& oVal); - void WriteCT_NumDataSource(OOX::Spreadsheet::CT_NumDataSource& oVal); - void WriteCT_NumData(OOX::Spreadsheet::CT_NumData& oVal); - void WriteCT_NumVal(OOX::Spreadsheet::CT_NumVal& oVal); - void WriteCT_NumRef(OOX::Spreadsheet::CT_NumRef& oVal); - void WriteCT_AxDataSource(OOX::Spreadsheet::CT_AxDataSource& oVal); - void WriteCT_MultiLvlStrRef(OOX::Spreadsheet::CT_MultiLvlStrRef& oVal); - void WriteCT_lvl(OOX::Spreadsheet::CT_lvl& oVal); + void WriteCT_DLbls (OOX::Spreadsheet::CT_DLbls& oVal); + void WriteCT_DLbl (OOX::Spreadsheet::CT_DLbl& oVal); + void WriteCT_DLblPos (OOX::Spreadsheet::CT_DLblPos& oVal); + void WriteCT_Trendline (OOX::Spreadsheet::CT_Trendline& oVal); + void WriteCT_TrendlineType (OOX::Spreadsheet::CT_TrendlineType& oVal); + void WriteCT_Order (OOX::Spreadsheet::CT_Order& oVal); + void WriteCT_Period (OOX::Spreadsheet::CT_Period& oVal); + void WriteCT_TrendlineLbl (OOX::Spreadsheet::CT_TrendlineLbl& oVal); + void WriteCT_ErrBars (OOX::Spreadsheet::CT_ErrBars& oVal); + void WriteCT_ErrDir (OOX::Spreadsheet::CT_ErrDir& oVal); + void WriteCT_ErrBarType (OOX::Spreadsheet::CT_ErrBarType& oVal); + void WriteCT_ErrValType (OOX::Spreadsheet::CT_ErrValType& oVal); + void WriteCT_NumDataSource (OOX::Spreadsheet::CT_NumDataSource& oVal); + void WriteCT_NumData (OOX::Spreadsheet::CT_NumData& oVal); + void WriteCT_NumVal (OOX::Spreadsheet::CT_NumVal& oVal); + void WriteCT_NumRef (OOX::Spreadsheet::CT_NumRef& oVal); + void WriteCT_AxDataSource (OOX::Spreadsheet::CT_AxDataSource& oVal); + void WriteCT_MultiLvlStrRef (OOX::Spreadsheet::CT_MultiLvlStrRef& oVal); + void WriteCT_lvl (OOX::Spreadsheet::CT_lvl& oVal); void WriteCT_MultiLvlStrData(OOX::Spreadsheet::CT_MultiLvlStrData& oVal); - void WriteCT_BubbleChart(OOX::Spreadsheet::CT_BubbleChart& oVal); - void WriteCT_bandFmts(OOX::Spreadsheet::CT_bandFmts& oVal); - void WriteCT_Surface3DChart(OOX::Spreadsheet::CT_Surface3DChart& oVal); - void WriteCT_SurfaceSer(OOX::Spreadsheet::CT_SurfaceSer& oVal); - void WriteCT_BandFmt(OOX::Spreadsheet::CT_BandFmt& oVal); - void WriteCT_SurfaceChart(OOX::Spreadsheet::CT_SurfaceChart& oVal); - void WriteCT_SecondPieSize(OOX::Spreadsheet::CT_SecondPieSize& oVal); - void WriteCT_SplitType(OOX::Spreadsheet::CT_SplitType& oVal); - void WriteCT_OfPieType(OOX::Spreadsheet::CT_OfPieType& oVal); - void WriteCT_custSplit(OOX::Spreadsheet::CT_custSplit& oVal); - void WriteCT_OfPieChart(OOX::Spreadsheet::CT_OfPieChart& oVal); - void WriteCT_PieSer(OOX::Spreadsheet::CT_PieSer& oVal); - void WriteCT_GapAmount(OOX::Spreadsheet::CT_GapAmount& oVal); - void WriteCT_Bar3DChart(OOX::Spreadsheet::CT_Bar3DChart& oVal); - void WriteCT_BarDir(OOX::Spreadsheet::CT_BarDir& oVal); - void WriteCT_BarGrouping(OOX::Spreadsheet::CT_BarGrouping& oVal); - void WriteCT_BarSer(OOX::Spreadsheet::CT_BarSer& oVal); - void WriteCT_Shape(OOX::Spreadsheet::CT_Shape& oVal); - void WriteCT_Overlap(OOX::Spreadsheet::CT_Overlap& oVal); - void WriteCT_BarChart(OOX::Spreadsheet::CT_BarChart& oVal); - void WriteCT_HoleSize(OOX::Spreadsheet::CT_HoleSize& oVal); - void WriteCT_DoughnutChart(OOX::Spreadsheet::CT_DoughnutChart& oVal); - void WriteCT_FirstSliceAng(OOX::Spreadsheet::CT_FirstSliceAng& oVal); - void WriteCT_Pie3DChart(OOX::Spreadsheet::CT_Pie3DChart& oVal); - void WriteCT_PieChart(OOX::Spreadsheet::CT_PieChart& oVal); - void WriteCT_ScatterSer(OOX::Spreadsheet::CT_ScatterSer& oVal); - void WriteCT_ScatterStyle(OOX::Spreadsheet::CT_ScatterStyle& oVal); - void WriteCT_ScatterChart(OOX::Spreadsheet::CT_ScatterChart& oVal); - void WriteCT_RadarSer(OOX::Spreadsheet::CT_RadarSer& oVal); - void WriteCT_RadarStyle(OOX::Spreadsheet::CT_RadarStyle& oVal); - void WriteCT_RadarChart(OOX::Spreadsheet::CT_RadarChart& oVal); - void WriteCT_StockChart(OOX::Spreadsheet::CT_StockChart& oVal); - void WriteCT_LineSer(OOX::Spreadsheet::CT_LineSer& oVal); - void WriteCT_UpDownBars(OOX::Spreadsheet::CT_UpDownBars& oVal); - void WriteCT_UpDownBar(OOX::Spreadsheet::CT_UpDownBar& oVal); - void WriteCT_Line3DChart(OOX::Spreadsheet::CT_Line3DChart& oVal); - void WriteCT_Grouping(OOX::Spreadsheet::CT_Grouping& oVal); - void WriteCT_LineChart(OOX::Spreadsheet::CT_LineChart& oVal); - void WriteCT_Area3DChart(OOX::Spreadsheet::CT_Area3DChart& oVal); - void WriteCT_AreaSer(OOX::Spreadsheet::CT_AreaSer& oVal); - void WriteCT_AreaChart(OOX::Spreadsheet::CT_AreaChart& oVal); - void WriteCT_PlotArea(OOX::Spreadsheet::CT_PlotArea& oVal); - void WriteCT_Thickness(OOX::Spreadsheet::CT_Thickness& oVal); - void WriteCT_Surface(OOX::Spreadsheet::CT_Surface& oVal); - void WriteCT_Perspective(OOX::Spreadsheet::CT_Perspective& oVal); - void WriteCT_DepthPercent(OOX::Spreadsheet::CT_DepthPercent& oVal); - void WriteCT_RotY(OOX::Spreadsheet::CT_RotY& oVal); - void WriteCT_HPercent(OOX::Spreadsheet::CT_HPercent& oVal); - void WriteCT_RotX(OOX::Spreadsheet::CT_RotX& oVal); - void WriteCT_View3D(OOX::Spreadsheet::CT_View3D& oVal); - void WriteCT_PivotFmt(OOX::Spreadsheet::CT_PivotFmt& oVal); - void WriteCT_pivotFmts(OOX::Spreadsheet::CT_pivotFmts& oVal); - void WriteCT_Chart(OOX::Spreadsheet::CT_Chart& oVal); - void WriteCT_Protection(OOX::Spreadsheet::CT_Protection& oVal); - void WriteCT_PivotSource(OOX::Spreadsheet::CT_PivotSource& oVal); - void WriteCT_Style(OOX::Spreadsheet::CT_Style& oVal); - void WriteCT_TextLanguageID(OOX::Spreadsheet::CT_TextLanguageID& oVal); - - void WriteCT_Shape (OOX::CSizeAnchor* pVal); - void WriteCT_FromTo (OOX::CFromTo& oFromTo); - void WriteCT_Ext (OOX::CExt& oExt); - - void WriteCT_Variation(OOX::Spreadsheet::ChartEx::CVariation & oVal); + void WriteCT_BubbleChart (OOX::Spreadsheet::CT_BubbleChart& oVal); + void WriteCT_bandFmts (OOX::Spreadsheet::CT_bandFmts& oVal); + void WriteCT_Surface3DChart (OOX::Spreadsheet::CT_Surface3DChart& oVal); + void WriteCT_SurfaceSer (OOX::Spreadsheet::CT_SurfaceSer& oVal); + void WriteCT_BandFmt (OOX::Spreadsheet::CT_BandFmt& oVal); + void WriteCT_SurfaceChart (OOX::Spreadsheet::CT_SurfaceChart& oVal); + void WriteCT_SecondPieSize (OOX::Spreadsheet::CT_SecondPieSize& oVal); + void WriteCT_SplitType (OOX::Spreadsheet::CT_SplitType& oVal); + void WriteCT_OfPieType (OOX::Spreadsheet::CT_OfPieType& oVal); + void WriteCT_custSplit (OOX::Spreadsheet::CT_custSplit& oVal); + void WriteCT_OfPieChart (OOX::Spreadsheet::CT_OfPieChart& oVal); + void WriteCT_PieSer (OOX::Spreadsheet::CT_PieSer& oVal); + void WriteCT_GapAmount (OOX::Spreadsheet::CT_GapAmount& oVal); + void WriteCT_Bar3DChart (OOX::Spreadsheet::CT_Bar3DChart& oVal); + void WriteCT_BarDir (OOX::Spreadsheet::CT_BarDir& oVal); + void WriteCT_BarGrouping (OOX::Spreadsheet::CT_BarGrouping& oVal); + void WriteCT_BarSer (OOX::Spreadsheet::CT_BarSer& oVal); + void WriteCT_Shape (OOX::Spreadsheet::CT_Shape& oVal); + void WriteCT_Overlap (OOX::Spreadsheet::CT_Overlap& oVal); + void WriteCT_BarChart (OOX::Spreadsheet::CT_BarChart& oVal); + void WriteCT_HoleSize (OOX::Spreadsheet::CT_HoleSize& oVal); + void WriteCT_DoughnutChart (OOX::Spreadsheet::CT_DoughnutChart& oVal); + void WriteCT_FirstSliceAng (OOX::Spreadsheet::CT_FirstSliceAng& oVal); + void WriteCT_Pie3DChart (OOX::Spreadsheet::CT_Pie3DChart& oVal); + void WriteCT_PieChart (OOX::Spreadsheet::CT_PieChart& oVal); + void WriteCT_ScatterSer (OOX::Spreadsheet::CT_ScatterSer& oVal); + void WriteCT_ScatterStyle (OOX::Spreadsheet::CT_ScatterStyle& oVal); + void WriteCT_ScatterChart (OOX::Spreadsheet::CT_ScatterChart& oVal); + void WriteCT_RadarSer (OOX::Spreadsheet::CT_RadarSer& oVal); + void WriteCT_RadarStyle (OOX::Spreadsheet::CT_RadarStyle& oVal); + void WriteCT_RadarChart (OOX::Spreadsheet::CT_RadarChart& oVal); + void WriteCT_StockChart (OOX::Spreadsheet::CT_StockChart& oVal); + void WriteCT_LineSer (OOX::Spreadsheet::CT_LineSer& oVal); + void WriteCT_UpDownBars (OOX::Spreadsheet::CT_UpDownBars& oVal); + void WriteCT_UpDownBar (OOX::Spreadsheet::CT_UpDownBar& oVal); + void WriteCT_Line3DChart (OOX::Spreadsheet::CT_Line3DChart& oVal); + void WriteCT_Grouping (OOX::Spreadsheet::CT_Grouping& oVal); + void WriteCT_LineChart (OOX::Spreadsheet::CT_LineChart& oVal); + void WriteCT_Area3DChart (OOX::Spreadsheet::CT_Area3DChart& oVal); + void WriteCT_AreaSer (OOX::Spreadsheet::CT_AreaSer& oVal); + void WriteCT_AreaChart (OOX::Spreadsheet::CT_AreaChart& oVal); + void WriteCT_PlotArea (OOX::Spreadsheet::CT_PlotArea& oVal); + void WriteCT_Thickness (OOX::Spreadsheet::CT_Thickness& oVal); + void WriteCT_Surface (OOX::Spreadsheet::CT_Surface& oVal); + void WriteCT_Perspective (OOX::Spreadsheet::CT_Perspective& oVal); + void WriteCT_DepthPercent (OOX::Spreadsheet::CT_DepthPercent& oVal); + void WriteCT_RotY (OOX::Spreadsheet::CT_RotY& oVal); + void WriteCT_HPercent (OOX::Spreadsheet::CT_HPercent& oVal); + void WriteCT_RotX (OOX::Spreadsheet::CT_RotX& oVal); + void WriteCT_View3D (OOX::Spreadsheet::CT_View3D& oVal); + void WriteCT_PivotFmt (OOX::Spreadsheet::CT_PivotFmt& oVal); + void WriteCT_pivotFmts (OOX::Spreadsheet::CT_pivotFmts& oVal); + void WriteCT_Chart (OOX::Spreadsheet::CT_Chart& oVal); + void WriteCT_Protection (OOX::Spreadsheet::CT_Protection& oVal); + void WriteCT_PivotSource (OOX::Spreadsheet::CT_PivotSource& oVal); + void WriteCT_Style1 (OOX::Spreadsheet::CT_Style1& oVal); + void WriteCT_Style (OOX::Spreadsheet::CT_Style& oVal); + void WriteCT_TextLanguageID (OOX::Spreadsheet::CT_TextLanguageID& oVal); - void WriteCT_StyleEntry(OOX::Spreadsheet::ChartEx::CStyleEntry & oVal); - void WriteCT_MarkerLayout(OOX::Spreadsheet::ChartEx::CMarkerLayout & oVal); - - void WriteCT_ChartExChartData(OOX::Spreadsheet::ChartEx::CChartData *pVal); - void WriteCT_ChartExChart(OOX::Spreadsheet::ChartEx::CChart *pVal); - void WriteCT_ChartExData(OOX::Spreadsheet::ChartEx::CData * pVal); - void WriteCT_ChartExExternalData(OOX::Spreadsheet::ChartEx::CExternalData *pVal); - void WriteCT_ChartExDataDimension(OOX::Spreadsheet::ChartEx::CStrDimension *pVal); - void WriteCT_ChartExDataDimension(OOX::Spreadsheet::ChartEx::CNumDimension *pVal); - void WriteCT_ChartExFormula(OOX::Spreadsheet::ChartEx::CFormula *pVal); - void WriteCT_ChartExStringLevel(OOX::Spreadsheet::ChartEx::CStringLevel *pVal); - void WriteCT_ChartExNumericLevel(OOX::Spreadsheet::ChartEx::CNumericLevel *pVal); - void WriteCT_ChartExStringValue(OOX::Spreadsheet::ChartEx::CStringValue *pVal); - void WriteCT_ChartExNumericValue(OOX::Spreadsheet::ChartEx::CNumericValue *pVal); - void WriteCT_ChartExPlotArea(OOX::Spreadsheet::ChartEx::CPlotArea*pVal); - void WriteCT_ChartExTitle(OOX::Spreadsheet::ChartEx::CTitle *pVal); - void WriteCT_ChartExLegend(OOX::Spreadsheet::ChartEx::CLegend *pVal); - void WriteCT_ChartExPlotAreaRegion(OOX::Spreadsheet::ChartEx::CPlotAreaRegion *pVal); - void WriteCT_ChartExAxis(OOX::Spreadsheet::ChartEx::CAxis *pVal); - void WriteCT_ChartExText(OOX::Spreadsheet::ChartEx::CText *pVal); - void WriteCT_ChartExTextData(OOX::Spreadsheet::ChartEx::CTextData *pVal); - void WriteCT_ChartExPlotSurface(OOX::Spreadsheet::ChartEx::CPlotSurface *pVal); - void WriteCT_ChartExSeries(OOX::Spreadsheet::ChartEx::CSeries *pVal); - void WriteCT_ChartExDataPoint(OOX::Spreadsheet::ChartEx::CDataPoint *pVal); - void WriteCT_ChartExDataLabels(OOX::Spreadsheet::ChartEx::CDataLabels *pVal); - void WriteCT_ChartExDataLabel(OOX::Spreadsheet::ChartEx::CDataLabel *pVal); - void WriteCT_ChartExDataLabelHidden(OOX::Spreadsheet::ChartEx::CDataLabelHidden *pVal); - void WriteCT_ChartExSeriesLayoutProperties(OOX::Spreadsheet::ChartEx::CSeriesLayoutProperties *pVal); - void WriteCT_ChartExNumberFormat(OOX::Spreadsheet::ChartEx::CNumberFormat *pVal); - void WriteCT_ChartExDataLabelVisibilities(OOX::Spreadsheet::ChartEx::CDataLabelVisibilities *pVal); - void WriteCT_ChartExBinning(OOX::Spreadsheet::ChartEx::CBinning *pVal); - void WriteCT_ChartExStatistics(OOX::Spreadsheet::ChartEx::CStatistics *pVal); - void WriteCT_ChartExSubtotals(OOX::Spreadsheet::ChartEx::CSubtotals *pVal); - void WriteCT_ChartExSeriesElementVisibilities(OOX::Spreadsheet::ChartEx::CSeriesElementVisibilities *pVal); - void WriteCT_ChartExCatScaling(OOX::Spreadsheet::ChartEx::CCatScaling *pVal); - void WriteCT_ChartExValScaling(OOX::Spreadsheet::ChartEx::CValScaling *pVal); - void WriteCT_ChartExAxisUnit(OOX::Spreadsheet::ChartEx::CAxisUnit *pVal); - void WriteCT_ChartExTickMarks(OOX::Spreadsheet::ChartEx::CTickMarks *pVal); - void WriteCT_ChartExGridlines(OOX::Spreadsheet::ChartEx::CGridlines *pVal); - void WriteCT_ChartExAxisUnitsLabel(OOX::Spreadsheet::ChartEx::CAxisUnitsLabel *pVal); + void WriteCT_Shape (OOX::CSizeAnchor* pVal); + void WriteCT_FromTo (OOX::CFromTo& oFromTo); + void WriteCT_Ext (OOX::CExt& oExt); + + void WriteAlternateContent (OOX::Spreadsheet::AlternateContent& oVal); + void WriteAlternateContentChoice (OOX::Spreadsheet::AlternateContentChoice& oVal); + void WriteAlternateContentFallback (OOX::Spreadsheet::AlternateContentFallback& oVal); + private: void toBin(OOX::Spreadsheet::ItemsChoiceType5 eType, void* pVal); void toBin(OOX::Spreadsheet::ItemsChoiceType6 eType, void* pVal); void toBin(OOX::Spreadsheet::ItemsChoiceType4 eType, void* pVal); diff --git a/XlsxSerializerCom/Reader/CommonWriter.cpp b/XlsxSerializerCom/Reader/CommonWriter.cpp index 9a32073cc7..8cb409c7c0 100644 --- a/XlsxSerializerCom/Reader/CommonWriter.cpp +++ b/XlsxSerializerCom/Reader/CommonWriter.cpp @@ -108,8 +108,7 @@ namespace BinXlsxRW unsigned char ucR; unsigned char ucG; unsigned char ucB; - //64 is auto color - if(64 != nIndex && OOX::Spreadsheet::CIndexedColors::GetDefaultRGBAByIndex(nIndex, ucR, ucG, ucB, ucA)) + if(OOX::Spreadsheet::CIndexedColors::GetDefaultRGBAByIndex(nIndex, ucR, ucG, ucB, ucA)) { bEmpty = false; oRgbColor.Set_A(ucA); @@ -150,4 +149,4 @@ namespace BinXlsxRW m_oStream.WriteBYTEArray(pData, nDataSize); WriteItemWithLengthEnd(nCurPos); } -} +} \ No newline at end of file diff --git a/XlsxSerializerCom/Writer/BinaryReader.cpp b/XlsxSerializerCom/Writer/BinaryReader.cpp index c38c6560a3..1fe806e4aa 100644 --- a/XlsxSerializerCom/Writer/BinaryReader.cpp +++ b/XlsxSerializerCom/Writer/BinaryReader.cpp @@ -2038,11 +2038,6 @@ int BinaryWorkbookTableReader::ReadWorkbookTableContent(BYTE type, long length, m_oWorkbook.m_oWorkbookPr.Init(); READ2_DEF_SPREADSHEET(length, res, this->ReadWorkbookPr, poResult); } - else if (c_oSerWorkbookTypes::Protection == type) - { - m_oWorkbook.m_oWorkbookProtection.Init(); - READ2_DEF_SPREADSHEET(length, res, this->ReadProtection, poResult); - } else if(c_oSerWorkbookTypes::BookViews == type) { m_oWorkbook.m_oBookViews.Init(); @@ -2497,31 +2492,7 @@ int BinaryWorkbookTableReader::ReadConnectionWebPr(BYTE type, long length, void* res = c_oSerConstants::ReadUnknown; return res; } -int BinaryWorkbookTableReader::ReadProtection(BYTE type, long length, void* poResult) -{ - int res = c_oSerConstants::ReadOk; - if (c_oSerWorkbookProtection::AlgorithmName == type) - { - m_oWorkbook.m_oWorkbookProtection->m_oWorkbookAlgorithmName.Init(); - m_oWorkbook.m_oWorkbookProtection->m_oWorkbookAlgorithmName->SetValue((SimpleTypes::ECryptAlgoritmName)m_oBufferedStream.GetUChar()); - } - else if (c_oSerWorkbookProtection::SpinCount == type) - { - m_oWorkbook.m_oWorkbookProtection->m_oWorkbookSpinCount.Init(); - m_oWorkbook.m_oWorkbookProtection->m_oWorkbookSpinCount->SetValue(m_oBufferedStream.GetULong()); - } - else if (c_oSerWorkbookProtection::HashValue == type) - { - m_oWorkbook.m_oWorkbookProtection->m_oWorkbookHashValue = m_oBufferedStream.GetString4(length); - } - else if (c_oSerWorkbookProtection::SaltValue == type) - { - m_oWorkbook.m_oWorkbookProtection->m_oWorkbookSaltValue = m_oBufferedStream.GetString4(length); - } - else - res = c_oSerConstants::ReadUnknown; - return res; -} + int BinaryWorkbookTableReader::ReadWorkbookPr(BYTE type, long length, void* poResult) { int res = c_oSerConstants::ReadOk; @@ -3767,11 +3738,6 @@ int BinaryWorksheetsTableReader::ReadWorksheet(boost::unordered_mapReadHyperlinks, &oHyperlinks); SEEK_TO_POS_END(oHyperlinks); -//------------------------------------------------------------------------------------------------------------- - SEEK_TO_POS_START(c_oSerWorksheetsTypes::Protection); - OOX::Spreadsheet::CSheetProtection oProtection; - READ2_DEF_SPREADSHEET(length, res, this->ReadProtection, &oProtection); - SEEK_TO_POS_END(oProtection); //------------------------------------------------------------------------------------------------------------- SEEK_TO_POS_START(c_oSerWorksheetsTypes::PrintOptions); OOX::Spreadsheet::CPrintOptions oPrintOptions; @@ -4682,122 +4648,6 @@ int BinaryWorksheetsTableReader::ReadPageSetup(BYTE type, long length, void* poR res = c_oSerConstants::ReadUnknown; return res; } -int BinaryWorksheetsTableReader::ReadProtection(BYTE type, long length, void* poResult) -{ - OOX::Spreadsheet::CSheetProtection* pProtection = static_cast(poResult); - int res = c_oSerConstants::ReadOk; - - if (c_oSerWorksheetProtection::AlgorithmName == type) - { - pProtection->m_oAlgorithmName.Init(); - pProtection->m_oAlgorithmName->SetValue((SimpleTypes::ECryptAlgoritmName)m_oBufferedStream.GetUChar()); - } - else if (c_oSerWorksheetProtection::SpinCount == type) - { - pProtection->m_oSpinCount.Init(); - pProtection->m_oSpinCount->SetValue(m_oBufferedStream.GetULong()); - } - else if (c_oSerWorksheetProtection::HashValue == type) - { - pProtection->m_oHashValue = m_oBufferedStream.GetString4(length); - } - else if (c_oSerWorksheetProtection::SaltValue == type) - { - pProtection->m_oSaltValue = m_oBufferedStream.GetString4(length); - } - else if (c_oSerWorksheetProtection::Password == type) - { - pProtection->m_oPassword = m_oBufferedStream.GetString4(length); - } - else if (c_oSerWorksheetProtection::AutoFilter == type) - { - pProtection->m_oAutoFilter.Init(); - pProtection->m_oAutoFilter->FromBool(m_oBufferedStream.GetBool()); - } - else if (c_oSerWorksheetProtection::Content == type) - { - pProtection->m_oContent.Init(); - pProtection->m_oContent->FromBool(m_oBufferedStream.GetBool()); - } - else if (c_oSerWorksheetProtection::DeleteColumns == type) - { - pProtection->m_oDeleteColumns.Init(); - pProtection->m_oDeleteColumns->FromBool(m_oBufferedStream.GetBool()); - } - else if (c_oSerWorksheetProtection::DeleteRows == type) - { - pProtection->m_oDeleteRows.Init(); - pProtection->m_oDeleteRows->FromBool(m_oBufferedStream.GetBool()); - } - else if (c_oSerWorksheetProtection::FormatCells == type) - { - pProtection->m_oFormatCells.Init(); - pProtection->m_oFormatCells->FromBool(m_oBufferedStream.GetBool()); - } - else if (c_oSerWorksheetProtection::FormatColumns == type) - { - pProtection->m_oFormatColumns.Init(); - pProtection->m_oFormatColumns->FromBool(m_oBufferedStream.GetBool()); - } - else if (c_oSerWorksheetProtection::FormatRows == type) - { - pProtection->m_oFormatRows.Init(); - pProtection->m_oFormatRows->FromBool(m_oBufferedStream.GetBool()); - } - else if (c_oSerWorksheetProtection::InsertColumns == type) - { - pProtection->m_oInsertColumns.Init(); - pProtection->m_oInsertColumns->FromBool(m_oBufferedStream.GetBool()); - } - else if (c_oSerWorksheetProtection::InsertHyperlinks == type) - { - pProtection->m_oInsertHyperlinks.Init(); - pProtection->m_oInsertHyperlinks->FromBool(m_oBufferedStream.GetBool()); - } - else if (c_oSerWorksheetProtection::InsertRows == type) - { - pProtection->m_oInsertRows.Init(); - pProtection->m_oInsertRows->FromBool(m_oBufferedStream.GetBool()); - } - else if (c_oSerWorksheetProtection::Objects == type) - { - pProtection->m_oObjects.Init(); - pProtection->m_oObjects->FromBool(m_oBufferedStream.GetBool()); - } - else if (c_oSerWorksheetProtection::PivotTables == type) - { - pProtection->m_oPivotTables.Init(); - pProtection->m_oPivotTables->FromBool(m_oBufferedStream.GetBool()); - } - else if (c_oSerWorksheetProtection::Scenarios == type) - { - pProtection->m_oScenarios.Init(); - pProtection->m_oScenarios->FromBool(m_oBufferedStream.GetBool()); - } - else if (c_oSerWorksheetProtection::SelectLockedCells == type) - { - pProtection->m_oSelectLockedCells.Init(); - pProtection->m_oSelectLockedCells->FromBool(m_oBufferedStream.GetBool()); - } - else if (c_oSerWorksheetProtection::SelectUnlockedCell == type) - { - pProtection->m_oSelectUnlockedCell.Init(); - pProtection->m_oSelectUnlockedCell->FromBool(m_oBufferedStream.GetBool()); - } - else if (c_oSerWorksheetProtection::Sheet == type) - { - pProtection->m_oSheet.Init(); - pProtection->m_oSheet->FromBool(m_oBufferedStream.GetBool()); - } - else if (c_oSerWorksheetProtection::Sort == type) - { - pProtection->m_oSort.Init(); - pProtection->m_oSort->FromBool(m_oBufferedStream.GetBool()); - } - else - res = c_oSerConstants::ReadUnknown; - return res; -} int BinaryWorksheetsTableReader::ReadHeaderFooter(BYTE type, long length, void* poResult) { OOX::Spreadsheet::CHeaderFooter* pHeaderFooter = static_cast(poResult); @@ -5003,8 +4853,6 @@ int BinaryWorksheetsTableReader::ReadDrawings(BYTE type, long length, void* poRe pCellAnchor->m_bShapeOle = false; pCellAnchor->m_bShapeControl = false; - bool bAddToDrawing = true; - if (pCellAnchor->m_oElement.is_init() && pCellAnchor->m_oElement->is()) { PPTX::Logic::Pic& oPic = pCellAnchor->m_oElement->as(); @@ -5031,16 +4879,27 @@ int BinaryWorksheetsTableReader::ReadDrawings(BYTE type, long length, void* poRe if(pOleObject->m_OleObjectFile.IsInit()) { - //generate ClientData + //generate ClientData + std::wstring sAnchor; + sAnchor += pCellAnchor->m_oFrom->m_oCol->ToString() + L","; + sAnchor += std::to_wstring(pCellAnchor->m_oFrom->m_oColOff->ToPx()) + L","; + sAnchor += pCellAnchor->m_oFrom->m_oRow->ToString() + L","; + sAnchor += std::to_wstring(pCellAnchor->m_oFrom->m_oRowOff->ToPx()) + L","; + sAnchor += pCellAnchor->m_oTo->m_oCol->ToString() + L","; + sAnchor += std::to_wstring(pCellAnchor->m_oTo->m_oColOff->ToPx()) + L","; + sAnchor += pCellAnchor->m_oTo->m_oRow->ToString() + L","; + sAnchor += std::to_wstring(pCellAnchor->m_oTo->m_oRowOff->ToPx()); + OOX::Vml::CClientData oClientData; oClientData.m_oObjectType.Init(); oClientData.m_oObjectType->SetValue(SimpleTypes::Vml::vmlclientdataobjecttypePict); oClientData.m_oSizeWithCells = true; - oClientData.m_oAnchor = pCellAnchor->toVmlXML(); - + + oClientData.m_oAnchor = sAnchor; + + //add VmlDrawing oPic.m_sClientDataXml = oClientData.toXML(); - //add VmlDrawing NSBinPptxRW::CXmlWriter oWriter(XMLWRITER_DOC_TYPE_XLSX); COOXToVMLGeometry oOOXToVMLRenderer; @@ -5078,7 +4937,8 @@ int BinaryWorksheetsTableReader::ReadDrawings(BYTE type, long length, void* poRe oRIdImg = new OOX::RId(m_pCurWorksheet->Add(pFileWorksheet)); } - //add oleObject rels + //add oleObject rels + smart_ptr pFileObject = pOleObject->m_OleObjectFile.smart_dynamic_cast(); const OOX::RId oRIdBin = m_pCurWorksheet->Add(pFileObject); @@ -5121,58 +4981,9 @@ int BinaryWorksheetsTableReader::ReadDrawings(BYTE type, long length, void* poRe } } } - } - else if (pCellAnchor->m_oElement.is_init() && pCellAnchor->m_oElement->is()) - { - PPTX::Logic::Shape& oShape = pCellAnchor->m_oElement->as(); - if (oShape.signatureLine.IsInit()) - { - bAddToDrawing = false; - //generate ClientData - OOX::Vml::CClientData oClientData; - oClientData.m_oObjectType.Init(); - oClientData.m_oObjectType->SetValue(SimpleTypes::Vml::vmlclientdataobjecttypePict); - oClientData.m_oSizeWithCells = true; - oClientData.m_oAnchor = pCellAnchor->toVmlXML(); + } - oShape.m_sClientDataXml = oClientData.toXML(); - - //add VmlDrawing - NSBinPptxRW::CXmlWriter oWriter(XMLWRITER_DOC_TYPE_XLSX); - COOXToVMLGeometry oOOXToVMLRenderer; - - oWriter.m_pOOXToVMLRenderer = &oOOXToVMLRenderer; - oWriter.m_lObjectIdVML = m_pCurVmlDrawing->m_lObjectIdVML; - - NSCommon::smart_ptr oClrMap; - oShape.toXmlWriterVML(&oWriter, m_oSaveParams.pTheme, oClrMap, NULL, false, true); - - std::wstring strXml = oWriter.GetXmlString(); - - m_pCurVmlDrawing->m_arObjectXml.push_back(strXml); - m_lObjectIdVML = m_pCurVmlDrawing->m_lObjectIdVML = oWriter.m_lObjectIdVML; - - if (oShape.spPr.Fill.m_type == PPTX::Logic::UniFill::blipFill) - { - OOX::CPath pathImageCache = oShape.spPr.Fill.as().blip->imageFilepath; - - smart_ptr oRIdImg; - if (pathImageCache.GetPath().empty() == false) - { - //add image rels to VmlDrawing - NSCommon::smart_ptr pImageFileVml(new OOX::Image(NULL, false)); - pImageFileVml->set_filename(pathImageCache, false); - - smart_ptr pFileVml = pImageFileVml.smart_dynamic_cast(); - m_pCurVmlDrawing->Add(*oShape.spPr.Fill.as().blip->embed, pFileVml); - } - } - } - } - if (bAddToDrawing) - { - pDrawing->m_arrItems.push_back(pCellAnchor); - } + pDrawing->m_arrItems.push_back(pCellAnchor); } else res = c_oSerConstants::ReadUnknown; @@ -5639,7 +5450,7 @@ int BinaryWorksheetsTableReader::ReadCell(BYTE type, long length, void* poResult { int nRow = m_oBufferedStream.GetLong(); int nCol = m_oBufferedStream.GetLong(); - pCell->setRowCol(nRow - 1, nCol); + pCell->setRowCol(nRow, nCol); } else if(c_oSerCellTypes::Style == type) { @@ -7095,16 +6906,12 @@ int BinaryFileReader::ReadFile(const std::wstring& sSrcFileName, std::wstring sD std::wstring themePath = sDstPath + FILE_SEPARATOR_STR + OOX::Spreadsheet::FileTypes::Workbook.DefaultDirectory().GetPath() + FILE_SEPARATOR_STR + OOX::FileTypes::Theme.DefaultDirectory().GetPath(); std::wstring drawingsPath = sDstPath + FILE_SEPARATOR_STR + OOX::Spreadsheet::FileTypes::Workbook.DefaultDirectory().GetPath() + FILE_SEPARATOR_STR + OOX::Spreadsheet::FileTypes::Drawings.DefaultDirectory().GetPath(); - std::wstring embeddingsPath = sDstPath + FILE_SEPARATOR_STR + OOX::Spreadsheet::FileTypes::Workbook.DefaultDirectory().GetPath() + FILE_SEPARATOR_STR + OOX::FileTypes::MicrosoftOfficeUnknown.DefaultDirectory().GetPath(); - std::wstring chartsPath = sDstPath + FILE_SEPARATOR_STR + OOX::Spreadsheet::FileTypes::Workbook.DefaultDirectory().GetPath() + FILE_SEPARATOR_STR + OOX::FileTypes::Chart.DefaultDirectory().GetPath(); - - oBufferedStream.m_pRels->m_pManager->SetDstCharts(chartsPath); - + bResultOk = true; if(BinXlsxRW::c_oFileTypes::XLSX == fileType) { - SaveParams oSaveParams(drawingsPath, embeddingsPath, themePath, pOfficeDrawingConverter->GetContentTypes(), NULL); + SaveParams oSaveParams(drawingsPath, themePath, pOfficeDrawingConverter->GetContentTypes(), NULL); try { @@ -7122,7 +6929,7 @@ int BinaryFileReader::ReadFile(const std::wstring& sSrcFileName, std::wstring sD { CSVWriter::CCSVWriter oCSVWriter(oXlsx, nCodePage, sDelimiter, false); oCSVWriter.Start(sDstPathCSV); - SaveParams oSaveParams(drawingsPath, embeddingsPath, themePath, pOfficeDrawingConverter->GetContentTypes(), &oCSVWriter); + SaveParams oSaveParams(drawingsPath, themePath, pOfficeDrawingConverter->GetContentTypes(), &oCSVWriter); try { diff --git a/XlsxSerializerCom/Writer/BinaryReader.h b/XlsxSerializerCom/Writer/BinaryReader.h index 647374b82a..e714b98742 100644 --- a/XlsxSerializerCom/Writer/BinaryReader.h +++ b/XlsxSerializerCom/Writer/BinaryReader.h @@ -202,7 +202,6 @@ namespace BinXlsxRW int Read(); int ReadWorkbookTableContent(BYTE type, long length, void* poResult); int ReadWorkbookPr(BYTE type, long length, void* poResult); - int ReadProtection(BYTE type, long length, void* poResult); int ReadBookViews(BYTE type, long length, void* poResult); int ReadWorkbookView(BYTE type, long length, void* poResult); int ReadExternalReferences(BYTE type, long length, void* poResult); @@ -306,7 +305,6 @@ namespace BinXlsxRW int ReadPageMargins(BYTE type, long length, void* poResult); int ReadPageSetup(BYTE type, long length, void* poResult); int ReadHeaderFooter(BYTE type, long length, void* poResult); - int ReadProtection(BYTE type, long length, void* poResult); int ReadRowColBreaks(BYTE type, long length, void* poResult); int ReadBreak(BYTE type, long length, void* poResult); int ReadPrintOptions(BYTE type, long length, void* poResult); diff --git a/XlsxSerializerCom/Writer/CSVWriter.cpp b/XlsxSerializerCom/Writer/CSVWriter.cpp index 910954b331..449192ca25 100644 --- a/XlsxSerializerCom/Writer/CSVWriter.cpp +++ b/XlsxSerializerCom/Writer/CSVWriter.cpp @@ -39,91 +39,8 @@ #include "../../Common/DocxFormat/Source/XlsxFormat/Styles/Styles.h" #include "../../Common/DocxFormat/Source/XlsxFormat/Worksheets/Worksheet.h" -#include - namespace CSVWriter { - std::wstring convert_date_time (const std::wstring & sValue, const std::wstring & format_code, bool bDate = true, bool bTime = true) - { - double dTime = XmlUtils::GetDouble(sValue); - int iDate = (int)dTime; - dTime -= iDate; - - std::wstring date_str, time_str; - - // format_code todooo - try - { - if (bDate) - { - boost::gregorian::date date_ = boost::gregorian::date(1900, 1, 1) + boost::gregorian::date_duration(iDate - 2); - - date_str = boost::lexical_cast(date_.year()) - + L"-" + - (date_.month() < 10 ? L"0" : L"") + boost::lexical_cast(date_.month().as_number()) - + L"-" + - (date_.day() < 10 ? L"0" : L"") + boost::lexical_cast(date_.day()); - } - - if (bTime) - { - int hours = 0, minutes = 0; - double sec = 0; - - boost::posix_time::time_duration day(24, 0, 0); - - double millisec = day.total_milliseconds() * dTime; - - sec = millisec / 1000.; - hours = sec / 60. / 60.; - minutes = (sec - (hours * 60 * 60)) / 60.; - sec = sec - (hours * 60 + minutes) * 60.; - - time_str = - (hours < 10 ? L"0" : L"") + std::to_wstring(hours) + L":" + - (minutes < 10 ? L"0" : L"") + std::to_wstring(minutes) + L":" + - (sec < 10 ? L"0" : L"") + std::to_wstring((int)sec); - } - } - catch (...) - { - return sValue; - } - return (bDate ? date_str : L"") + (bDate & bTime ? L" " : L"" ) + (bTime ? time_str : L""); - } - long gcd(long a, long b) - { - if (a == 0) return b; - else if (b == 0) return a; - - if (a < b) return gcd(a, b % a); - else return gcd(b, a % b); - } - std::wstring convert_fraction(const std::wstring & sValue) - { - double dValue = XmlUtils::GetDouble(sValue); - - double integral = std::floor(dValue); - double frac = dValue - integral; - - const long precision = 1000000000; - - long gcd_ = gcd(round(frac * precision), precision); - - long denominator = precision / gcd_; - long numerator = round(frac * precision) / gcd_; - - return std::to_wstring((int)integral) + L" " + std::to_wstring(numerator) + L"/" + std::to_wstring(denominator); - } - std::wstring convert_scientific(const std::wstring & sValue) - { - double dValue = XmlUtils::GetDouble(sValue); - - std::wstringstream strm; - strm << std::setprecision(2) << std::scientific << dValue; - return strm.str(); - } -//--------------------------------------------------------------------------------------------- static std::wstring g_sNewLineN = _T("\n"); static std::wstring g_sEndJson = _T("]"); static std::wstring g_sQuote = _T("\""); @@ -349,7 +266,6 @@ namespace CSVWriter // Get cell value std::wstring sCellValue = _T(""); - if (pCell->m_oValue.IsInit()) { if (pCell->m_oType.IsInit() && SimpleTypes::Spreadsheet::celltypeNumber != pCell->m_oType->GetValue()) @@ -374,42 +290,7 @@ namespace CSVWriter } else { - std::wstring format_code; - int format_type = SimpleTypes::Spreadsheet::celltypeNumber; - - if (pCell->m_oStyle.IsInit() && m_oXlsx.m_pStyles) - { - int style = pCell->m_oStyle->GetValue(); - OOX::Spreadsheet::CXfs* xfs = m_oXlsx.m_pStyles->m_oCellXfs->m_arrItems[style]; - if (xfs) - { - if ((xfs->m_oApplyNumberFormat.IsInit()) && (xfs->m_oApplyNumberFormat->ToBool())) - { - if ((xfs->m_oNumFmtId.IsInit()) /*&& (xfs->m_oNumFmtId->GetValue() != 0*/) - { - int numFmt = xfs->m_oNumFmtId->GetValue(); - //get default code - - GetDefaultFormatCode(numFmt, format_code, format_type); - - if (m_oXlsx.m_pStyles->m_oNumFmts.IsInit()) - { - std::map::iterator pFind = m_oXlsx.m_pStyles->m_oNumFmts->m_mapNumFmtIndex.find(numFmt); - if (pFind != m_oXlsx.m_pStyles->m_oNumFmts->m_mapNumFmtIndex.end()) - { - OOX::Spreadsheet::CNumFmt *fmt = m_oXlsx.m_pStyles->m_oNumFmts->m_arrItems[pFind->second]; - if (fmt) - { - if (fmt->m_oFormatCode.IsInit()) - format_code = *fmt->m_oFormatCode; - } - } - } - } - } - } - } - sCellValue = ConvertValueCellToString(pCell->m_oValue->ToString(), format_type, format_code); + sCellValue = pCell->m_oValue->ToString(); } } @@ -434,18 +315,21 @@ namespace CSVWriter } void CCSVWriter::WriteRowEnd(OOX::Spreadsheet::CRow* pWorksheet) { + while (m_nColDimension > m_nColCurrent) // todooo - прописывать в бинарнике dimension - и данные брать оттуда + { + if (m_bJSON && false == m_bIsWriteCell) + { + // Запишем пустые строки (для JSON-а) + WriteFile(&m_oFile, &m_pWriteBuffer, m_nCurrentIndex, g_sDoubleQuote, m_nCodePage); + } + // Write delimiter + ++m_nColCurrent; + WriteFile(&m_oFile, &m_pWriteBuffer, m_nCurrentIndex, m_sDelimiter, m_nCodePage); + m_bIsWriteCell = false; + } + if (m_bJSON) WriteFile(&m_oFile, &m_pWriteBuffer, m_nCurrentIndex, g_sEndJson, m_nCodePage); - else - { - while (m_nColDimension > m_nColCurrent) // todooo - прописывать в бинарнике dimension - и данные брать оттуда - { - // Write delimiter - ++m_nColCurrent; - WriteFile(&m_oFile, &m_pWriteBuffer, m_nCurrentIndex, m_sDelimiter, m_nCodePage); - m_bIsWriteCell = false; - } - } } void CCSVWriter::WriteSheetEnd(OOX::Spreadsheet::CWorksheet* pWorksheet) { @@ -470,85 +354,4 @@ namespace CSVWriter RELEASEARRAYOBJECTS(m_pWriteBuffer); m_oFile.CloseFile(); } - void CCSVWriter::GetDefaultFormatCode(int numFmt, std::wstring & format_code, int & format_type) - { - switch (numFmt) - { - case 1: format_code = L"0"; format_type = SimpleTypes::Spreadsheet::celltypeNumber; break; - case 2: format_code = L"0.00"; format_type = SimpleTypes::Spreadsheet::celltypeNumber; break; - case 3: format_code = L"#,##0"; format_type = SimpleTypes::Spreadsheet::celltypeNumber; break; - case 4: format_code = L"#,##0.00"; format_type = SimpleTypes::Spreadsheet::celltypeNumber; break; - - case 9: format_code = L"0%"; format_type = SimpleTypes::Spreadsheet::celltypePercentage; break; - case 10: format_code = L"0.00%"; format_type = SimpleTypes::Spreadsheet::celltypePercentage; break; - - case 11: format_code = L"0.00E+00"; format_type = SimpleTypes::Spreadsheet::celltypeScientific; break; - case 12: format_code = L"# ?/?"; format_type = SimpleTypes::Spreadsheet::celltypeFraction; break; - case 13: format_code = L"# ??/??"; format_type = SimpleTypes::Spreadsheet::celltypeFraction; break; - - case 14: format_code = L"mm-dd-yy"; format_type = SimpleTypes::Spreadsheet::celltypeDate; break; - case 15: format_code = L"d-mmm-yy"; format_type = SimpleTypes::Spreadsheet::celltypeDate; break; - case 16: format_code = L"d-mmm"; format_type = SimpleTypes::Spreadsheet::celltypeDate; break; - case 17: format_code = L"mmm-yy"; format_type = SimpleTypes::Spreadsheet::celltypeDate; break; - - case 18: format_code = L"h:mm AM/PM"; format_type = SimpleTypes::Spreadsheet::celltypeTime; break; - case 19: format_code = L"h:mm:ss AM/PM"; format_type = SimpleTypes::Spreadsheet::celltypeTime; break; - case 20: format_code = L"h:mm"; format_type = SimpleTypes::Spreadsheet::celltypeTime; break; - case 21: format_code = L"h:mm:ss"; format_type = SimpleTypes::Spreadsheet::celltypeTime; break; - case 22: format_code = L"m/d/yy h:mm"; format_type = SimpleTypes::Spreadsheet::celltypeDateTime; break; - - case 37: format_code = L"#,##0 ;(#,##0)"; format_type = SimpleTypes::Spreadsheet::celltypeNumber; break; - case 38: format_code = L"#,##0 ;[Red](#,##0)"; format_type = SimpleTypes::Spreadsheet::celltypeNumber; break; - case 39: format_code = L"#,##0.00;(#,##0.00)"; format_type = SimpleTypes::Spreadsheet::celltypeNumber; break; - case 40: format_code = L"#,##0.00;[Red](#,##0.00)"; format_type = SimpleTypes::Spreadsheet::celltypeNumber; break; - - case 41: format_code = L""; format_type = SimpleTypes::Spreadsheet::celltypeCurrency; break; - case 42: format_code = L""; format_type = SimpleTypes::Spreadsheet::celltypeCurrency; break; - - case 45: format_code = L"mm:ss"; format_type = SimpleTypes::Spreadsheet::celltypeTime; break; - case 46: format_code = L"[h]:mm:ss"; format_type = SimpleTypes::Spreadsheet::celltypeTime; break; - case 47: format_code = L"mmss.0"; format_type = SimpleTypes::Spreadsheet::celltypeTime; break; - - case 49: format_code = L"@"; format_type = SimpleTypes::Spreadsheet::celltypeStr; break; - - default: - /////////////////////////////////// с неопределенным format_code .. он задается в файле - if (numFmt >= 5 && numFmt <= 8) format_type = SimpleTypes::Spreadsheet::celltypeCurrency; - if (numFmt >= 43 && numFmt <= 44) format_type = SimpleTypes::Spreadsheet::celltypeCurrency; - - if (numFmt >= 27 && numFmt <= 31) format_type = SimpleTypes::Spreadsheet::celltypeDate; - if (numFmt >= 50 && numFmt <= 54) format_type = SimpleTypes::Spreadsheet::celltypeDate; - if (numFmt >= 57 && numFmt <= 58) format_type = SimpleTypes::Spreadsheet::celltypeDate; - if (numFmt == 36) format_type = SimpleTypes::Spreadsheet::celltypeDate; - - if (numFmt >= 32 && numFmt <= 35) format_type = SimpleTypes::Spreadsheet::celltypeTime; - if (numFmt >= 55 && numFmt <= 56) format_type = SimpleTypes::Spreadsheet::celltypeTime; - - if (numFmt >= 60 && numFmt <= 62) format_type = SimpleTypes::Spreadsheet::celltypeNumber; - if (numFmt >= 69 && numFmt <= 70) format_type = SimpleTypes::Spreadsheet::celltypeNumber; - - if (numFmt >= 67 && numFmt <= 68) format_type = SimpleTypes::Spreadsheet::celltypePercentage; - - if (numFmt >= 71 && numFmt <= 74) format_type = SimpleTypes::Spreadsheet::celltypeDate; - if (numFmt >= 75 && numFmt <= 80) format_type = SimpleTypes::Spreadsheet::celltypeTime; - if (numFmt == 81) format_type = SimpleTypes::Spreadsheet::celltypeDate; - } - } - std::wstring CCSVWriter::ConvertValueCellToString(const std::wstring &value, int format_type, const std::wstring & format_code) - { - switch (format_type) - { - case SimpleTypes::Spreadsheet::celltypeNumber: - case SimpleTypes::Spreadsheet::celltypeStr: return value; - case SimpleTypes::Spreadsheet::celltypePercentage: return value + L"%"; - - case SimpleTypes::Spreadsheet::celltypeDate: return convert_date_time(value, format_code, true, false); - case SimpleTypes::Spreadsheet::celltypeTime: return convert_date_time(value, format_code, false, true); - case SimpleTypes::Spreadsheet::celltypeDateTime: return convert_date_time(value, format_code); - case SimpleTypes::Spreadsheet::celltypeFraction: return convert_fraction(value); - case SimpleTypes::Spreadsheet::celltypeScientific: return convert_scientific(value); - default: - return value; - } - } } diff --git a/XlsxSerializerCom/Writer/CSVWriter.h b/XlsxSerializerCom/Writer/CSVWriter.h index e600ef2983..d510b94a42 100644 --- a/XlsxSerializerCom/Writer/CSVWriter.h +++ b/XlsxSerializerCom/Writer/CSVWriter.h @@ -64,9 +64,6 @@ namespace CSVWriter bool m_bIsWriteCell; // Нужно только для записи JSON-а bool m_bStartRow; bool m_bStartCell; - - void GetDefaultFormatCode(int numFmt, std::wstring & format_code, int & format_type); - std::wstring ConvertValueCellToString(const std::wstring &Value, int format_type, const std::wstring & format_code); public: CCSVWriter(OOX::Spreadsheet::CXlsx &oXlsx, unsigned int m_nCodePage, const std::wstring& sDelimiter, bool m_bJSON); ~CCSVWriter();