From 2c945b7166f86fb407971374c641ece5850c762f Mon Sep 17 00:00:00 2001 From: ElenaSubbotina Date: Wed, 21 Dec 2016 19:29:18 +0300 Subject: [PATCH] x2t - refactoring (delete double conversions string) --- ASCOfficeDocFile/DocDocxConverter/RGBColor.h | 8 +- ASCOfficeDocxFile2/BinReader/ChartWriter.h | 11 +- ASCOfficeDocxFile2/BinReader/MediaWriter.h | 8 +- ASCOfficeDocxFile2/BinReader/Readers.h | 17 +- .../BinReader/fontTableWriter.h | 2 +- ASCOfficeDocxFile2/DocWrapper/ChartWriter.cpp | 2 +- .../DocWrapper/DocxSerializer.cpp | 59 ++- .../DocWrapper/FontProcessor.cpp | 19 +- .../DocWrapper/XlsxSerializer.cpp | 54 +-- .../DocWrapper/XlsxSerializer.h | 4 +- ASCOfficeOdfFile/src/docx/mediaitems.cpp | 2 +- ASCOfficeOdfFile/win32/cpodf.vcproj | 4 - .../source/Oox2OdfConverter/ConvertVml.cpp | 26 +- .../source/Oox2OdfConverter/Converter.cpp | 32 +- .../Oox2OdfConverter/ConverterChart.cpp | 4 +- .../source/Oox2OdfConverter/DocxConverter.cpp | 72 +-- .../source/Oox2OdfConverter/XlsxConverter.cpp | 14 +- .../PPTFormatLib/PPTFormatLib.cpp | 4 +- .../PPTFormatLib/PPTXWriter/Converter.cpp | 5 +- .../PPTFormatLib/PPTXWriter/ImageManager.h | 43 +- .../PPTFormatLib/PPTXWriter/ShapeWriter.cpp | 416 ++++++++---------- .../PPTFormatLib/PPTXWriter/StylesWriter.h | 109 ++--- .../PPTFormatLib/Reader/ReadStructures.h | 2 +- .../PPTFormatLib/Records/Drawing/ArtBlip.cpp | 10 +- .../PPTFormatLib/Records/Drawing/ArtBlip.h | 4 +- .../Records/Drawing/ShapeContainer.h | 2 +- .../PPTFormatLib/Records/TextBytesAtom.h | 2 +- .../PPTFormatLib/Win32/PPTFormatLib.vcproj | 4 + .../ASCOfficeDrawingConverter.cpp | 10 +- ASCOfficePPTXFile/ASCOfficePPTXFile.h | 63 +-- .../ASCOfficePPTXFileRealization.cpp | 47 +- .../Editor/BinaryFileReaderWriter.cpp | 25 +- ASCOfficePPTXFile/Editor/Converter.h | 4 +- .../Editor/Drawing/AudioOverlay.h | 2 +- ASCOfficePPTXFile/Editor/Drawing/Elements.h | 29 +- .../Editor/Drawing/XmlStringWriter.h | 12 - ASCOfficePPTXFile/Editor/FontPicker.h | 2 +- ASCOfficePPTXFile/Editor/PPTXWriter.h | 8 +- ASCOfficePPTXFile/Editor/XmlWriter.h | 209 ++++----- ASCOfficePPTXFile/Editor/imagemanager.h | 131 +++--- .../PPTXFormat/DocxFormat/ContentTypes/File.h | 2 +- .../DocxFormat/Drawing/LegacyDiagramText.h | 2 +- .../PPTXFormat/DocxFormat/Rels/RelationShip.h | 4 +- .../PPTXFormat/Logic/Fills/BlipFill.h | 2 +- ASCOfficePPTXFile/PPTXFormat/Logic/Pic.cpp | 8 +- ASCOfficePPTXFile/PPTXFormat/Logic/Shape.cpp | 8 +- .../PPTXFormat/Logic/SmartArt.cpp | 7 +- ASCOfficePPTXFile/PPTXFormat/Logic/SpTree.cpp | 4 +- ASCOfficePPTXFile/PPTXFormat/Logic/UniFill.h | 2 +- .../Linux/PPTXFormatLib/PPTXFormatLib.pro | 6 +- .../PPTXFormatLib/pptxformatlib_converter.cpp | 4 - ASCOfficePPTXFile/PPTXLib/PPTXFormat.vcproj | 4 - .../source/ConvertationManager.cpp | 4 +- .../source/Reader/OOXMathReader.cpp | 4 +- .../Reader/OOXParagraphElementReaders.cpp | 14 +- .../source/Reader/OOXPictureGraphicReader.h | 8 +- .../RtfFormatLib/source/Reader/OOXReader.cpp | 2 +- .../source/Reader/OOXTableReader.cpp | 2 +- .../RtfFormatLib/source/RtfProperty.cpp | 24 +- .../RtfFormatLib/source/RtfWriter.h | 4 +- .../TxtXmlFormatLib/Linux/TxtXmlFormatLib.pro | 3 + .../TxtXmlFormatLib/Source/Common/Utility.h | 1 - .../Source/ConvertDocx2Txt.cpp | 6 +- .../Source/ConvertTxt2Docx.cpp | 2 +- .../Source/TxtFormat/TxtFile.cpp | 22 +- .../TxtXmlFormatLib/Source/TxtXmlFile.cpp | 12 +- .../DocxFormatLib/DocxFormatLib.pro | 6 +- .../DocxFormatLib/docxformatlib_file.cpp | 1 - .../DocxFormat/Projects/DocxFormat2005.vcproj | 12 +- .../Source/DocxFormat/ContentTypes.h | 21 +- Common/DocxFormat/Source/DocxFormat/Docx.h | 2 +- Common/DocxFormat/Source/DocxFormat/File.h | 11 +- .../Source/DocxFormat/FileFactory.cpp | 4 +- .../Source/DocxFormat/IFileContainer.cpp | 2 +- Common/DocxFormat/Source/DocxFormat/Rels.h | 4 +- .../DocxFormat/Source/DocxFormat/VmlDrawing.h | 2 +- Common/DocxFormat/Source/SystemUtility/File.h | 235 ++++------ .../Source/SystemUtility/SystemUtility.cpp | 41 +- .../Source/SystemUtility/SystemUtility.h | 128 +++--- .../DocxFormat/Source/XML/libxml2/libxml2.cpp | 16 +- .../DocxFormat/Source/XML/libxml2/libxml2.h | 237 +--------- Common/DocxFormat/Source/XML/stringcommon.cpp | 50 --- Common/DocxFormat/Source/XML/stringcommon.h | 44 -- Common/DocxFormat/Source/XML/xmlutils.h | 1 - .../Source/XlsxFormat/Drawing/CellAnchor.h | 2 +- .../XlsxFormat/FileFactory_Spreadsheet.cpp | 4 +- .../XlsxFormat/IFileContainer_Spreadsheet.cpp | 4 +- .../Source/XlsxFormat/Worksheets/Worksheet.h | 2 +- Common/DocxFormat/Source/XlsxFormat/Xlsx.h | 4 +- DesktopEditor/common/String.h | 4 +- X2tConverter/src/ASCConverters.cpp | 413 ++++++++--------- X2tConverter/src/cextracttools.h | 5 +- X2tConverter/src/main.cpp | 21 +- XlsxSerializerCom/Common/Common.cpp | 4 +- XlsxSerializerCom/Reader/BinaryWriter.h | 22 +- XlsxSerializerCom/Reader/CSVReader.cpp | 10 +- .../Reader/ChartFromToBinary.cpp | 8 +- XlsxSerializerCom/Writer/BinaryReader.h | 33 +- XlsxSerializerCom/Writer/CSVWriter.cpp | 4 +- 99 files changed, 1215 insertions(+), 1784 deletions(-) delete mode 100644 Common/DocxFormat/Source/XML/stringcommon.cpp delete mode 100644 Common/DocxFormat/Source/XML/stringcommon.h diff --git a/ASCOfficeDocFile/DocDocxConverter/RGBColor.h b/ASCOfficeDocFile/DocDocxConverter/RGBColor.h index a1227351de..b74795f576 100644 --- a/ASCOfficeDocFile/DocDocxConverter/RGBColor.h +++ b/ASCOfficeDocFile/DocDocxConverter/RGBColor.h @@ -79,8 +79,8 @@ namespace DocFileFormat //rgbColor6.Format( _T( "%02x%02x%02x" ), /*R*/this->Red, /*G*/this->Green, /*B*/this->Blue ); //rgbColor8.Format( _T( "%02x%02x%02x%02x" ), /*R*/this->Red, /*G*/this->Green, /*B*/this->Blue, /*A*/this->Alpha ); - //SixDigitHexCode = string2std_string( rgbColor6 ); - //EightDigitHexCode = string2std_string( rgbColor8 ); + //SixDigitHexCode = rgbColor6; + //EightDigitHexCode = rgbColor8; rgbColor6 << boost::wformat( L"%02x%02x%02x" ) % /*R*/this->Red % /*G*/this->Green % /*B*/this->Blue; rgbColor8 << boost::wformat( L"%02x%02x%02x%02x" ) % /*R*/this->Red % /*G*/this->Green % /*B*/this->Blue % /*A*/this->Alpha; @@ -101,8 +101,8 @@ namespace DocFileFormat //rgbColor6.Format( _T( "%02x%02x%02x" ), /*R*/this->Red, /*G*/this->Green, /*B*/this->Blue ); //rgbColor8.Format( _T( "%02x%02x%02x%02x" ), /*R*/this->Red, /*G*/this->Green, /*B*/this->Blue, /*A*/this->Alpha ); - //SixDigitHexCode = string2std_string( rgbColor6 ); - //EightDigitHexCode = string2std_string( rgbColor8 ); + //SixDigitHexCode = rgbColor6; + //EightDigitHexCode = rgbColor8; rgbColor6 << boost::wformat( L"%02x%02x%02x" ) % /*R*/this->Red % /*G*/this->Green % /*B*/this->Blue; rgbColor8 << boost::wformat( L"%02x%02x%02x%02x" ) % /*R*/this->Red % /*G*/this->Green % /*B*/this->Blue % /*A*/this->Alpha; diff --git a/ASCOfficeDocxFile2/BinReader/ChartWriter.h b/ASCOfficeDocxFile2/BinReader/ChartWriter.h index c21b8cd189..027d0dc0ea 100644 --- a/ASCOfficeDocxFile2/BinReader/ChartWriter.h +++ b/ASCOfficeDocxFile2/BinReader/ChartWriter.h @@ -71,7 +71,7 @@ namespace Writers if(false == IsEmpty()) { OOX::CPath pathChartDir = m_sDir + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR + _T("charts"); - FileSystem::Directory::CreateDirectory(string2std_string(pathChartDir.GetPath())); + FileSystem::Directory::CreateDirectory(pathChartDir.GetPath()); for(int i = 0, length = m_aCharts.size(); i < length; ++i) { @@ -80,7 +80,7 @@ namespace Writers OOX::CPath filePath = pathChartDir + FILE_SEPARATOR_STR + elem->filename; NSFile::CFileBinary oFile; - oFile.CreateFileW(string2std_string(filePath.GetPath())); + oFile.CreateFileW(filePath.GetPath()); oFile.WriteStringUTF8(L"\r\n"); oFile.WriteStringUTF8(elem->content); oFile.CloseFile(); @@ -91,14 +91,15 @@ namespace Writers } } } - void AddChart(std::wstring& content, CString& sRelsName, CString& sFileName, int& index) + void AddChart(std::wstring& content, std::wstring& sRelsName, std::wstring& sFileName, int& index) { ChartElem* pChartElem = new ChartElem(); pChartElem->content = content; pChartElem->index = nChartCount + 1; nChartCount++; - pChartElem->filename.Format(_T("chart%d.xml"), pChartElem->index); - sRelsName = _T("charts/") + pChartElem->filename; + pChartElem->filename.Format(L"chart%d.xml", pChartElem->index); + + sRelsName = L"charts/" + pChartElem->filename; sFileName = pChartElem->filename; index = pChartElem->index; diff --git a/ASCOfficeDocxFile2/BinReader/MediaWriter.h b/ASCOfficeDocxFile2/BinReader/MediaWriter.h index 75f56fe2bc..9284c634d6 100644 --- a/ASCOfficeDocxFile2/BinReader/MediaWriter.h +++ b/ASCOfficeDocxFile2/BinReader/MediaWriter.h @@ -74,10 +74,10 @@ namespace Writers { CString sNewImagePath = AddImageGetNewPath(); NSFile::CFileBinary oFile; - oFile.CreateFileW(string2std_string(sNewImagePath)); + oFile.CreateFileW(sNewImagePath); oFile.WriteFile(pData, dwSizeRead); oFile.CloseFile(); - CString sFilename = NSSystemPath::GetFileName(string2std_string(sNewImagePath)).c_str(); + CString sFilename = NSSystemPath::GetFileName(sNewImagePath); m_aImageNames.push_back(sFilename); } RELEASEARRAYOBJECTS(pData); @@ -87,8 +87,8 @@ namespace Writers { OOX::CPath pathNewImg = AddImageGetNewPath(); - NSFile::CFileBinary::Copy(string2std_string(sImg), string2std_string(pathNewImg.GetPath())); - CString sFilename = NSSystemPath::GetFileName(string2std_string(pathNewImg.GetPath())).c_str(); + NSFile::CFileBinary::Copy(sImg, pathNewImg.GetPath()); + CString sFilename = NSSystemPath::GetFileName(pathNewImg.GetPath()).c_str(); m_aImageNames.push_back(sFilename); } }; diff --git a/ASCOfficeDocxFile2/BinReader/Readers.h b/ASCOfficeDocxFile2/BinReader/Readers.h index 352f099d6a..d020aa95bc 100644 --- a/ASCOfficeDocxFile2/BinReader/Readers.h +++ b/ASCOfficeDocxFile2/BinReader/Readers.h @@ -2936,11 +2936,11 @@ public: { m_oFileWriter.m_oMediaWriter.AddImage2(pFileNative); } - else if(NSFile::CFileBinary::Exists(string2std_string(sFilePath))) + else if(NSFile::CFileBinary::Exists(sFilePath)) { m_oFileWriter.m_oMediaWriter.AddImage(sFilePath); if(bDeleteFile) - NSFile::CFileBinary::Remove(string2std_string(sFilePath)); + NSFile::CFileBinary::Remove(sFilePath); } } else @@ -6653,14 +6653,14 @@ public: //save xlsx std::wstring sXlsxFilename = L"Microsoft_Excel_Worksheet" + std::to_wstring(m_oFileWriter.m_oChartWriter.getChartCount() + 1) + L".xlsx"; - std::wstring sXlsxPath = string2std_string(pathChartsWorksheetDir.GetPath() + FILE_SEPARATOR_STR) + sXlsxFilename; + std::wstring sXlsxPath = pathChartsWorksheetDir.GetPath() + FILE_SEPARATOR_STR + sXlsxFilename; BinXlsxRW::CXlsxSerializer oXlsxSerializer; oXlsxSerializer.writeChartXlsx(sXlsxPath, *pChartSpace); std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename; long rIdXlsx; CString bstrChartsWorksheetRelType = OOX::Spreadsheet::FileTypes::ChartsWorksheet.RelationType(); - m_oFileWriter.m_pDrawingConverter->WriteRels(bstrChartsWorksheetRelType, std_string2string(sChartsWorksheetRelsName), CString(), &rIdXlsx); + m_oFileWriter.m_pDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, CString(), &rIdXlsx); pChartSpace->m_oChartSpace.m_externalData = new OOX::Spreadsheet::CT_ExternalData(); pChartSpace->m_oChartSpace.m_externalData->m_id = new std::wstring(); @@ -6673,14 +6673,15 @@ public: NSStringUtils::CStringBuilder sw; pChartSpace->toXML(sw); - CString sFilename; - CString sRelsName; + std::wstring sFilename; + std::wstring sRelsName; int nChartIndex; std::wstring sContent = sw.GetData(); - m_oFileWriter.m_oChartWriter.AddChart(sContent, sRelsName, sFilename, nChartIndex); + + m_oFileWriter.m_oChartWriter.AddChart(sContent, sRelsName, sFilename, nChartIndex); m_oFileWriter.m_oContentTypesWriter.AddOverrideRaw(oSaveParams.sAdditionalContentTypes); - OOX::CPath pathChartsRels = pathChartsRelsDir.GetPath() + FILE_SEPARATOR_STR + sFilename + _T(".rels"); + OOX::CPath pathChartsRels = pathChartsRelsDir.GetPath() + FILE_SEPARATOR_STR + sFilename + L".rels"; m_oFileWriter.m_pDrawingConverter->SaveDstContentRels(pathChartsRels.GetPath()); long rIdChart; diff --git a/ASCOfficeDocxFile2/BinReader/fontTableWriter.h b/ASCOfficeDocxFile2/BinReader/fontTableWriter.h index 5f7c45db18..1cf50c3fa8 100644 --- a/ASCOfficeDocxFile2/BinReader/fontTableWriter.h +++ b/ASCOfficeDocxFile2/BinReader/fontTableWriter.h @@ -57,7 +57,7 @@ namespace Writers if(sFontDir.IsEmpty()) m_oApplicationFonts.Initialize(); else - m_oApplicationFonts.InitializeFromFolder(string2std_string(sFontDir)); + m_oApplicationFonts.InitializeFromFolder(sFontDir); CFontList* pFontList = m_oApplicationFonts.GetList(); if(NULL != pFontList) { diff --git a/ASCOfficeDocxFile2/DocWrapper/ChartWriter.cpp b/ASCOfficeDocxFile2/DocWrapper/ChartWriter.cpp index d3c9255ab0..3cfd4a7777 100644 --- a/ASCOfficeDocxFile2/DocWrapper/ChartWriter.cpp +++ b/ASCOfficeDocxFile2/DocWrapper/ChartWriter.cpp @@ -248,7 +248,7 @@ namespace BinXlsxRW{ pTable->m_oTable->m_oDisplayName.Init(); pTable->m_oTable->m_oDisplayName->append(L"Table1"); pTable->m_oTable->m_oRef.Init(); - pTable->m_oTable->m_oRef->SetValue(std_string2string(OOX::Spreadsheet::CCell::combineRef(m_nRow1 - 1, m_nCol1 - 1) + L":" + OOX::Spreadsheet::CCell::combineRef(m_nRow2 - 1, m_nCol2 - 1))); + pTable->m_oTable->m_oRef->SetValue(OOX::Spreadsheet::CCell::combineRef(m_nRow1 - 1, m_nCol1 - 1) + L":" + OOX::Spreadsheet::CCell::combineRef(m_nRow2 - 1, m_nCol2 - 1)); pTable->m_oTable->m_oTotalsRowCount.Init(); pTable->m_oTable->m_oTotalsRowCount->SetValue(0); pTable->m_oTable->m_oTableBorderDxfId.Init(); diff --git a/ASCOfficeDocxFile2/DocWrapper/DocxSerializer.cpp b/ASCOfficeDocxFile2/DocWrapper/DocxSerializer.cpp index ad96a3139c..91751f37aa 100644 --- a/ASCOfficeDocxFile2/DocWrapper/DocxSerializer.cpp +++ b/ASCOfficeDocxFile2/DocWrapper/DocxSerializer.cpp @@ -50,48 +50,45 @@ BinDocxRW::CDocxSerializer::CDocxSerializer() } bool BinDocxRW::CDocxSerializer::ConvertDocxToDoct(const CString& sSrcFileName, const CString& sDstFileName, const CString& sTmpDir, const CString& sXMLOptions) { - std::wstring strDirSrc = NSSystemPath::Combine(string2std_string(sTmpDir), _T("from")); - std::wstring strDirDst = NSSystemPath::Combine(string2std_string(sTmpDir), _T("to")); - std::wstring strEditorBin = NSSystemPath::Combine(strDirDst, _T("Editor.bin")); + std::wstring strDirSrc = NSSystemPath::Combine(sTmpDir, L"from"); + std::wstring strDirDst = NSSystemPath::Combine(sTmpDir, L"to"); + std::wstring strEditorBin = NSSystemPath::Combine(strDirDst, L"Editor.bin"); NSDirectory::CreateDirectory(strDirSrc); NSDirectory::CreateDirectory(strDirDst); - CString sDirSrc = std_string2string(strDirSrc); - CString sEditorBin = std_string2string(strEditorBin); - COfficeUtils oCOfficeUtils(NULL); - if(S_OK == oCOfficeUtils.ExtractToDirectory(string2std_string(sSrcFileName), strDirSrc, NULL, 0)) - if(saveToFile(sEditorBin, sDirSrc, sXMLOptions)) - if(S_OK == oCOfficeUtils.CompressFileOrDirectory(strDirDst, string2std_string(sDstFileName), -1)) + if(S_OK == oCOfficeUtils.ExtractToDirectory(sSrcFileName, strDirSrc, NULL, 0)) + if(saveToFile(strEditorBin, strDirSrc, sXMLOptions)) + if(S_OK == oCOfficeUtils.CompressFileOrDirectory(strDirDst, sDstFileName, -1)) return true; return false; } bool BinDocxRW::CDocxSerializer::ConvertDoctToDocx(const CString& sSrcFileName, const CString& sDstFileName, const CString& sTmpDir, const CString& sXMLOptions) { - std::wstring strDirSrc = NSSystemPath::Combine(string2std_string(sTmpDir), _T("from")); - std::wstring strEditorBin = NSSystemPath::Combine(strDirSrc, _T("Editor.bin")); - std::wstring strDirDst = NSSystemPath::Combine(string2std_string(sTmpDir), _T("to")); + std::wstring strDirSrc = NSSystemPath::Combine(sTmpDir, L"from"); + std::wstring strEditorBin = NSSystemPath::Combine(strDirSrc, L"Editor.bin"); + std::wstring strDirDst = NSSystemPath::Combine(sTmpDir, L"to"); NSDirectory::CreateDirectory(strDirSrc); NSDirectory::CreateDirectory(strDirDst); - CString sEditorBin = std_string2string(strEditorBin); + CString sEditorBin = strEditorBin; COfficeUtils oCOfficeUtils(NULL); - if(S_OK == oCOfficeUtils.ExtractToDirectory(string2std_string(sSrcFileName), strDirSrc, NULL, 0)) + if(S_OK == oCOfficeUtils.ExtractToDirectory(sSrcFileName, strDirSrc, NULL, 0)) { CString sMediaPath; CString sThemePath; CString sEmbedPath; - CreateDocxFolders(std_string2string(strDirDst), sThemePath, sMediaPath, sEmbedPath); + CreateDocxFolders(strDirDst, sThemePath, sMediaPath, sEmbedPath); - if(loadFromFile(sEditorBin, std_string2string(strDirDst), sXMLOptions, sThemePath, sMediaPath, sEmbedPath)) + if(loadFromFile(sEditorBin, strDirDst, sXMLOptions, sThemePath, sMediaPath, sEmbedPath)) { - if(S_OK == oCOfficeUtils.CompressFileOrDirectory(strDirDst, string2std_string(sDstFileName), -1)) + if(S_OK == oCOfficeUtils.CompressFileOrDirectory(strDirDst, sDstFileName, -1)) return true; } } @@ -102,7 +99,7 @@ bool BinDocxRW::CDocxSerializer::saveToFile(const CString& sSrcFileName, const C OOX::CPath pathMain(sSrcFileName); OOX::CPath pathMedia = pathMain.GetDirectory() + FILE_SEPARATOR_STR + _T("media"); - NSDirectory::CreateDirectory(string2std_string(pathMedia.GetPath())); + NSDirectory::CreateDirectory(pathMedia.GetPath()); COfficeFontPicker* pFontPicker = new COfficeFontPicker(); pFontPicker->Init(m_sFontDir); @@ -116,7 +113,7 @@ bool BinDocxRW::CDocxSerializer::saveToFile(const CString& sSrcFileName, const C NSFontCutter::CEmbeddedFontsManager* pEmbeddedFontsManager = NULL; if(false == m_sEmbeddedFontsDir.IsEmpty()) { - NSDirectory::CreateDirectory(string2std_string(m_sEmbeddedFontsDir)); + NSDirectory::CreateDirectory(m_sEmbeddedFontsDir); pFontPicker->SetEmbeddedFontsDirectory(m_sEmbeddedFontsDir); @@ -146,7 +143,7 @@ bool BinDocxRW::CDocxSerializer::saveToFile(const CString& sSrcFileName, const C if (m_bIsNoBase64Save) { NSFile::CFileBinary oFile; - oFile.CreateFileW(string2std_string(sSrcFileName)); + oFile.CreateFileW(sSrcFileName); oFile.WriteFile(pbBinBuffer, nBinBufferLen); oFile.CloseFile(); } @@ -158,8 +155,8 @@ bool BinDocxRW::CDocxSerializer::saveToFile(const CString& sSrcFileName, const C if(true == Base64_1::Base64Encode(pbBinBuffer, nBinBufferLen, pbBase64Buffer, &nBase64BufferLen)) { NSFile::CFileBinary oFile; - oFile.CreateFileW(string2std_string(sSrcFileName)); - oFile.WriteStringUTF8(string2std_string(oBinaryFileWriter.WriteFileHeader(nBinBufferLen))); + oFile.CreateFileW(sSrcFileName); + oFile.WriteStringUTF8(oBinaryFileWriter.WriteFileHeader(nBinBufferLen)); oFile.WriteFile(pbBase64Buffer, nBase64BufferLen); oFile.CloseFile(); } @@ -175,32 +172,32 @@ bool BinDocxRW::CDocxSerializer::CreateDocxFolders(CString strDirectory, CString bool res = true; // rels OOX::CPath pathRels = strDirectory + FILE_SEPARATOR_STR + _T("_rels"); - if (!NSDirectory::CreateDirectory(pathRels.GetPath().GetBuffer())) res = false; + if (!NSDirectory::CreateDirectory(pathRels.GetPath())) res = false; // word OOX::CPath pathWord = strDirectory + FILE_SEPARATOR_STR + _T("word"); - if (!NSDirectory::CreateDirectory(pathWord.GetPath().GetBuffer())) res = false; + if (!NSDirectory::CreateDirectory(pathWord.GetPath())) res = false; // documentRels OOX::CPath pathWordRels = pathWord + FILE_SEPARATOR_STR + _T("_rels"); - if (!NSDirectory::CreateDirectory(pathWordRels.GetPath().GetBuffer()))res = false; + if (!NSDirectory::CreateDirectory(pathWordRels.GetPath()))res = false; //media OOX::CPath pathMedia = pathWord + FILE_SEPARATOR_STR + _T("media"); - if (!NSDirectory::CreateDirectory(pathMedia.GetPath().GetBuffer())) res = false; + if (!NSDirectory::CreateDirectory(pathMedia.GetPath())) res = false; sMediaPath = pathMedia.GetPath(); //embeddings OOX::CPath pathEmbeddings = pathWord + FILE_SEPARATOR_STR + _T("embeddings"); - if (!NSDirectory::CreateDirectory(pathEmbeddings.GetPath().GetBuffer()))res = false; + if (!NSDirectory::CreateDirectory(pathEmbeddings.GetPath()))res = false; sEmbedPath = pathEmbeddings.GetPath(); // theme OOX::CPath pathTheme = pathWord + FILE_SEPARATOR_STR + _T("theme"); - if (!NSDirectory::CreateDirectory(pathTheme.GetPath().GetBuffer())) res = false; + if (!NSDirectory::CreateDirectory(pathTheme.GetPath())) res = false; OOX::CPath pathThemeRels = pathTheme + FILE_SEPARATOR_STR + _T("_rels"); - if (!NSDirectory::CreateDirectory(pathThemeRels.GetPath().GetBuffer())) res = false; + if (!NSDirectory::CreateDirectory(pathThemeRels.GetPath())) res = false; pathTheme = pathTheme + FILE_SEPARATOR_STR + _T("theme1.xml"); sThemePath = pathTheme.GetPath(); @@ -212,7 +209,7 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const CString& sSrcFileName, const bool bResultOk = false; NSFile::CFileBinary oFile; - if(oFile.OpenFile(string2std_string(sSrcFileName))) + if(oFile.OpenFile(sSrcFileName)) { DWORD nBase64DataSize = 0; BYTE* pBase64Data = new BYTE[oFile.GetFileSize()]; @@ -286,7 +283,7 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const CString& sSrcFileName, const m_pCurFileWriter = new Writers::FileWriter(sDstPath, m_sFontDir, false, nVersion, m_bSaveChartAsImg, &oDrawingConverter, sThemePath); //папка с картинками - std::wstring strFileInDir = NSSystemPath::GetDirectoryName(string2std_string(sSrcFileName)); + std::wstring strFileInDir = NSSystemPath::GetDirectoryName(sSrcFileName); CString sFileInDir = strFileInDir.c_str(); VARIANT var; diff --git a/ASCOfficeDocxFile2/DocWrapper/FontProcessor.cpp b/ASCOfficeDocxFile2/DocWrapper/FontProcessor.cpp index 614fdefce6..d6e864cb87 100644 --- a/ASCOfficeDocxFile2/DocWrapper/FontProcessor.cpp +++ b/ASCOfficeDocxFile2/DocWrapper/FontProcessor.cpp @@ -95,13 +95,14 @@ namespace DocWrapper { sFontName = pTheme->GetMinorFont(); } if(sFontName.IsEmpty() && oRFont.IsInit() && oRFont->m_sVal.IsInit()) - sFontName = std_string2string(oRFont->ToString2()); + sFontName = oRFont->ToString2(); if(sFontName.IsEmpty()) sFontName = CString(gc_sNoNameFont); //подбор перенесен в js return sFontName; - oFontSelectFormat.wsName = new std::wstring; - *oFontSelectFormat.wsName = string2std_string(sFontName); + + oFontSelectFormat.wsName = new std::wstring(sFontName); + if(oCharset.IsInit() && oCharset->m_oCharset.IsInit()) { SimpleTypes::Spreadsheet::EFontCharset eCharset = oCharset->m_oCharset->GetValue(); @@ -121,7 +122,7 @@ namespace DocWrapper { CString sRes; CFontInfo* pFontInfo = m_pFontManager->GetFontInfoByParams(oFontSelectFormat); if(NULL != pFontInfo) - sRes = std_string2string(pFontInfo->m_wsFontName); + sRes = pFontInfo->m_wsFontName; else sRes = gc_sDefaultFontName; fontMap[sFontName] = sRes; @@ -135,12 +136,12 @@ namespace DocWrapper { sFontName = CString(gc_sNoNameFont); else sFontName = font.m_sName; - oFontSelectFormat.wsName = new std::wstring; - *oFontSelectFormat.wsName = string2std_string(sFontName); + + oFontSelectFormat.wsName = new std::wstring(sFontName); + if (font.m_oAltName.IsInit() && font.m_oAltName->GetLength() > 0) { - oFontSelectFormat.wsAltName = new std::wstring; - *oFontSelectFormat.wsAltName = string2std_string(*font.m_oAltName); + oFontSelectFormat.wsAltName = new std::wstring(*font.m_oAltName); } if(font.m_oCharset.IsInit()) { @@ -216,7 +217,7 @@ namespace DocWrapper { CFontInfo* pFontInfo = m_pFontManager->GetFontInfoByParams(oFontSelectFormat); if(NULL != pFontInfo) - fontMap[sFontName] = std_string2string(pFontInfo->m_wsFontName); + fontMap[sFontName] = pFontInfo->m_wsFontName; else fontMap[sFontName] = gc_sDefaultFontName; } diff --git a/ASCOfficeDocxFile2/DocWrapper/XlsxSerializer.cpp b/ASCOfficeDocxFile2/DocWrapper/XlsxSerializer.cpp index 438db43aed..5c88434d7f 100644 --- a/ASCOfficeDocxFile2/DocWrapper/XlsxSerializer.cpp +++ b/ASCOfficeDocxFile2/DocWrapper/XlsxSerializer.cpp @@ -68,11 +68,11 @@ namespace BinXlsxRW{ OOX::CPath pathThemeThemeRelsDir = pathThemeDir + FILE_SEPARATOR_STR + _T("_rels"); - NSDirectory::CreateDirectory(string2std_string(pathXlDir.GetPath())); - NSDirectory::CreateDirectory(string2std_string(pathThemeDir.GetPath())); - NSDirectory::CreateDirectory(string2std_string(pathThemeThemeRelsDir.GetPath())); - NSDirectory::CreateDirectory(string2std_string(pathMediaDir.GetPath())); - NSDirectory::CreateDirectory(string2std_string(pathEmbedDir.GetPath())); + NSDirectory::CreateDirectory(pathXlDir.GetPath()); + NSDirectory::CreateDirectory(pathThemeDir.GetPath()); + NSDirectory::CreateDirectory(pathThemeThemeRelsDir.GetPath()); + NSDirectory::CreateDirectory(pathMediaDir.GetPath()); + NSDirectory::CreateDirectory(pathEmbedDir.GetPath()); //Create Default Theme { @@ -90,7 +90,7 @@ namespace BinXlsxRW{ oOfficeDrawingConverter.SetEmbedDstPath(sEmbedDir); //папка с бинарников - std::wstring strFileInDir = NSSystemPath::GetDirectoryName(string2std_string(sSrcFileName)); + std::wstring strFileInDir = NSSystemPath::GetDirectoryName(sSrcFileName); CString sFileInDir = strFileInDir.c_str(); VARIANT var; @@ -119,7 +119,7 @@ namespace BinXlsxRW{ NSFontCutter::CEmbeddedFontsManager* pEmbeddedFontsManager = NULL; if(false == m_sEmbeddedFontsDir.IsEmpty()) { - NSDirectory::CreateDirectory(string2std_string(m_sEmbeddedFontsDir)); + NSDirectory::CreateDirectory(m_sEmbeddedFontsDir); pFontPicker->SetEmbeddedFontsDirectory(m_sEmbeddedFontsDir); pEmbeddedFontsManager = pFontPicker->GetNativeCutter(); @@ -182,40 +182,42 @@ namespace BinXlsxRW{ { m_pExternalDrawingConverter->SetDstContentRels(); - //получаем sThemePath из bsFilename предполагая что папка theme находится на уровень выше bsFilename - CString sThemePath; - CString sEmbedingPath; - CString sFilenameReverse = sFilepath;sFilenameReverse.MakeReverse(); + //получаем sThemePath из bsFilename предполагая что папка theme находится на уровень выше bsFilename + std::wstring sThemePath; + std::wstring sEmbedingPath; + + CString sFilenameReverse = sFilepath; sFilenameReverse.MakeReverse(); int nIndex = sFilenameReverse.Find(FILE_SEPARATOR_CHAR); nIndex = sFilenameReverse.Find(FILE_SEPARATOR_CHAR, nIndex + 1); if(-1 != nIndex) { CString sFilepathLeft = sFilepath.Left(sFilepath.GetLength() - nIndex); - sThemePath = sFilepathLeft + _T("theme"); - sEmbedingPath = sFilepathLeft + _T("embeddings"); + sThemePath = sFilepathLeft + L"theme"; + sEmbedingPath = sFilepathLeft + L"embeddings"; } - //todo theme path - BinXlsxRW::SaveParams oSaveParams(sThemePath); - OOX::Spreadsheet::CChartSpace oChartSpace; - BinXlsxRW::BinaryChartReader oBinaryChartReader(oBufferedStream, oSaveParams, m_pExternalDrawingConverter); + //todo theme path + BinXlsxRW::SaveParams oSaveParams(sThemePath); + OOX::Spreadsheet::CChartSpace oChartSpace; + BinXlsxRW::BinaryChartReader oBinaryChartReader(oBufferedStream, oSaveParams, m_pExternalDrawingConverter); + oBinaryChartReader.ReadCT_ChartSpace(lLength, &oChartSpace.m_oChartSpace); if(oChartSpace.isValid()) { //todo не делать embeddings, если пишем xlsx //save xlsx - if(!sEmbedingPath.IsEmpty()) + if(!sEmbedingPath.empty()) { std::wstring sXlsxFilename = L"Microsoft_Excel_Worksheet" + std::to_wstring(lChartNumber) + L".xlsx"; - std::wstring sXlsxPath = string2std_string(sEmbedingPath + FILE_SEPARATOR_STR) + sXlsxFilename; + std::wstring sXlsxPath = sEmbedingPath + FILE_SEPARATOR_STR + sXlsxFilename; writeChartXlsx(sXlsxPath, oChartSpace); std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename; long rId; CString bstrChartsWorksheetRelType = OOX::Spreadsheet::FileTypes::ChartsWorksheet.RelationType(); - m_pExternalDrawingConverter->WriteRels(bstrChartsWorksheetRelType, std_string2string(sChartsWorksheetRelsName), CString(), &rId); + m_pExternalDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, CString(), &rId); oChartSpace.m_oChartSpace.m_externalData = new OOX::Spreadsheet::CT_ExternalData(); oChartSpace.m_oChartSpace.m_externalData->m_id = new std::wstring(); @@ -225,9 +227,9 @@ namespace BinXlsxRW{ oChartSpace.m_oChartSpace.m_externalData->m_autoUpdate->m_val = new bool(false); } - std::wstring strFilepath = string2std_string(sFilepath); - CString strDir = std_string2string(NSSystemPath::GetDirectoryName(strFilepath)); - CString strFilename = std_string2string(NSSystemPath::GetFileName(strFilepath)); + std::wstring strFilepath = sFilepath; + CString strDir = NSSystemPath::GetDirectoryName(strFilepath); + CString strFilename = NSSystemPath::GetFileName(strFilepath); OOX::CPath pathRelsDir = strDir + FILE_SEPARATOR_STR + _T("_rels"); @@ -250,11 +252,11 @@ namespace BinXlsxRW{ } return bRes; } - void CXlsxSerializer::setFontDir(CString& sFontDir) + void CXlsxSerializer::setFontDir(std::wstring& sFontDir) { m_sFontDir = sFontDir; } - void CXlsxSerializer::setEmbeddedFontsDir(CString& sEmbeddedFontsDir) + void CXlsxSerializer::setEmbeddedFontsDir(std::wstring& sEmbeddedFontsDir) { m_sEmbeddedFontsDir = sEmbeddedFontsDir; } @@ -275,7 +277,7 @@ namespace BinXlsxRW{ CString sXmlOptions = _T(""); CString sMediaPath;// will be filled by 'CreateXlsxFolders' method CString sEmbedPath; // will be filled by 'CreateXlsxFolders' method - CreateXlsxFolders (sXmlOptions, std_string2string(sTempDir), sMediaPath, sEmbedPath); + CreateXlsxFolders (sXmlOptions, sTempDir, sMediaPath, sEmbedPath); //заполняем Xlsx OOX::Spreadsheet::CXlsx oXlsx; helper.toXlsx(oXlsx); diff --git a/ASCOfficeDocxFile2/DocWrapper/XlsxSerializer.h b/ASCOfficeDocxFile2/DocWrapper/XlsxSerializer.h index 5e20723e05..5770060edb 100644 --- a/ASCOfficeDocxFile2/DocWrapper/XlsxSerializer.h +++ b/ASCOfficeDocxFile2/DocWrapper/XlsxSerializer.h @@ -68,8 +68,8 @@ namespace BinXlsxRW { bool loadChart(CString& sChartPath, NSBinPptxRW::CBinaryFileWriter& oBufferedStream, long& lDataSize); bool saveChart(NSBinPptxRW::CBinaryFileReader& oBufferedStream, long lLength, CString& sFilename, CString& sContentTypePath, CString** sContentTypeElement, const long& lChartNumber); - void setFontDir(CString& sFontDir); - void setEmbeddedFontsDir(CString& sEmbeddedFontsDir); + void setFontDir (std::wstring& sFontDir); + void setEmbeddedFontsDir(std::wstring& sEmbeddedFontsDir); void setDrawingConverter(NSBinPptxRW::CDrawingConverter* pDrawingConverter); void writeChartXlsx(const std::wstring& sDstFile ,const OOX::Spreadsheet::CChartSpace& oChart); diff --git a/ASCOfficeOdfFile/src/docx/mediaitems.cpp b/ASCOfficeOdfFile/src/docx/mediaitems.cpp index 30a83b2037..4343614ee9 100644 --- a/ASCOfficeOdfFile/src/docx/mediaitems.cpp +++ b/ASCOfficeOdfFile/src/docx/mediaitems.cpp @@ -148,7 +148,7 @@ std::wstring mediaitems::detectImageFileExtension(std::wstring &fileName) CFile file; std::wstring sExt; - if (file.OpenFile(std_string2string(fileName)) == S_OK) + if (file.OpenFile(fileName) == S_OK) { BYTE buffer[128]; int buffer_size = 128; diff --git a/ASCOfficeOdfFile/win32/cpodf.vcproj b/ASCOfficeOdfFile/win32/cpodf.vcproj index e030a5fbdc..cc777e1b9f 100644 --- a/ASCOfficeOdfFile/win32/cpodf.vcproj +++ b/ASCOfficeOdfFile/win32/cpodf.vcproj @@ -1720,10 +1720,6 @@ RelativePath="..\..\Common\DocxFormat\Source\SystemUtility\FileSystem\Directory.cpp" > - - diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConvertVml.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConvertVml.cpp index 0ab4a4df06..d23522371e 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConvertVml.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConvertVml.cpp @@ -321,7 +321,7 @@ void OoxConverter::convert(OOX::Vml::CShape *vml_shape) if (vml_shape->m_oPath.IsInit()) { - odf_context()->drawing_context()->set_path(string2std_string(vml_shape->m_oPath->GetValue())); + odf_context()->drawing_context()->set_path(vml_shape->m_oPath->GetValue()); } OOX::Vml::CVmlCommonElements *vml_common = static_cast(vml_shape); @@ -352,7 +352,7 @@ void OoxConverter::convert(OOX::Vml::CImageData *vml_image_data) odf_context()->drawing_context()->start_area_properties(); odf_context()->drawing_context()->start_bitmap_style(); - odf_context()->drawing_context()->set_bitmap_link(string2std_string(pathImage)); + odf_context()->drawing_context()->set_bitmap_link(pathImage); odf_context()->drawing_context()->set_image_style_repeat(1);//stretch double gain = vml_image_data->m_oGain.GetValue(); @@ -405,7 +405,7 @@ void OoxConverter::convert(OOX::Vml::CFill *vml_fill) if (pathImage.GetLength() > 0) { - odf_context()->drawing_context()->set_bitmap_link(string2std_string(pathImage)); + odf_context()->drawing_context()->set_bitmap_link(pathImage); _graphics_utils_::GetResolution(pathImage, Width, Height); } odf_context()->drawing_context()->set_image_style_repeat(1); @@ -429,9 +429,9 @@ void OoxConverter::convert(OOX::Vml::CFill *vml_fill) _CP_OPT(double) no_set; if (vml_fill->m_oColor.IsInit()) - odf_context()->drawing_context()->set_gradient_start(string2std_string(vml_fill->m_oColor->ToString()),no_set); + odf_context()->drawing_context()->set_gradient_start(vml_fill->m_oColor->ToString(), no_set); if (vml_fill->m_oColor2.IsInit()) - odf_context()->drawing_context()->set_gradient_end(string2std_string(vml_fill->m_oColor2->ToString()),no_set); + odf_context()->drawing_context()->set_gradient_end(vml_fill->m_oColor2->ToString(), no_set); if (vml_fill->m_oFocusPosition.IsInit()) odf_context()->drawing_context()->set_gradient_center(vml_fill->m_oFocusPosition->GetX(), vml_fill->m_oFocusPosition->GetY()); @@ -442,9 +442,9 @@ void OoxConverter::convert(OOX::Vml::CFill *vml_fill) { odf_context()->drawing_context()->start_hatch_style(); if (vml_fill->m_oColor2.IsInit()) - odf_context()->drawing_context()->set_hatch_line_color(string2std_string(vml_fill->m_oColor2->ToString())); + odf_context()->drawing_context()->set_hatch_line_color(vml_fill->m_oColor2->ToString()); if (vml_fill->m_oColor.IsInit()) - odf_context()->drawing_context()->set_hatch_area_color(string2std_string(vml_fill->m_oColor->ToString())); + odf_context()->drawing_context()->set_hatch_area_color(vml_fill->m_oColor->ToString()); else odf_context()->drawing_context()->set_hatch_area_color(L"#ffffff"); @@ -454,7 +454,7 @@ void OoxConverter::convert(OOX::Vml::CFill *vml_fill) case SimpleTypes::filltypeSolid: default: if (vml_fill->m_oColor.IsInit()) - odf_context()->drawing_context()->set_solid_fill(string2std_string(vml_fill->m_oColor->ToString())); + odf_context()->drawing_context()->set_solid_fill(vml_fill->m_oColor->ToString()); break; } } @@ -557,7 +557,7 @@ void OoxConverter::convert(OOX::Vml::CShadow *vml_shadow) if (vml_shadow == NULL) return; if (vml_shadow->m_oOn.GetValue() == false) return; - std::wstring hexColor = string2std_string(vml_shadow->m_oColor.ToString()); + std::wstring hexColor = vml_shadow->m_oColor.ToString(); _CP_OPT(double) opacity; if (vml_shadow->m_oOpacity.IsInit()) opacity = 100 - 100 * vml_shadow->m_oOpacity->GetValue(); @@ -587,7 +587,7 @@ void OoxConverter::convert(OOX::Vml::CStroke *vml_stroke) if (vml_stroke->m_oColor.IsInit()) { - std::wstring hexColor = string2std_string(vml_stroke->m_oColor->ToString()); + std::wstring hexColor = vml_stroke->m_oColor->ToString(); if (hexColor.length() < 1)hexColor = L"000000"; odf_context()->drawing_context()->set_solid_fill(hexColor); } @@ -675,7 +675,7 @@ void OoxConverter::convert(OOX::Vml::CTextPath *vml_textpath) odf_context()->text_context()->start_paragraph(false); odf_context()->text_context()->start_span(false); - odf_context()->text_context()->add_text_content(string2std_string(vml_textpath->m_sString.get())); + odf_context()->text_context()->add_text_content(vml_textpath->m_sString.get()); odf_context()->text_context()->end_span(); odf_context()->text_context()->end_paragraph(); @@ -795,7 +795,7 @@ void OoxConverter::convert(OOX::Vml::CVmlCommonElements *vml_common) SimpleTypes::CHexColor<> *oRgbColor = new SimpleTypes::CHexColor<>(ucR,ucG,ucB); if (oRgbColor) { - odf_context()->drawing_context()->set_solid_fill(string2std_string(oRgbColor->ToString().Right(6))); + odf_context()->drawing_context()->set_solid_fill(oRgbColor->ToString().Right(6)); delete oRgbColor; } } @@ -812,7 +812,7 @@ void OoxConverter::convert(OOX::Vml::CVmlCommonElements *vml_common) if (oRgbColor) { odf_context()->drawing_context()->start_area_properties(); - odf_context()->drawing_context()->set_solid_fill(string2std_string(oRgbColor->ToString().Right(6))); + odf_context()->drawing_context()->set_solid_fill(oRgbColor->ToString().Right(6)); odf_context()->drawing_context()->end_area_properties(); delete oRgbColor; } diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.cpp index 48e523c427..600eecb0c8 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/Converter.cpp @@ -332,7 +332,7 @@ void OoxConverter::convert(OOX::Drawing::CLockedCanvas *oox_canvas) if (oox_canvas->m_oNvGroupSpPr.IsInit() && oox_canvas->m_oNvGroupSpPr->m_oCNvPr.IsInit()) { if (oox_canvas->m_oNvGroupSpPr->m_oCNvPr->m_sName.IsInit()) - odf_context()->drawing_context()->set_group_name(string2std_string(*oox_canvas->m_oNvGroupSpPr->m_oCNvPr->m_sName)); + odf_context()->drawing_context()->set_group_name(*oox_canvas->m_oNvGroupSpPr->m_oCNvPr->m_sName); if (oox_canvas->m_oNvGroupSpPr->m_oCNvPr->m_oId.IsInit()) odf_context()->drawing_context()->set_group_z_order(oox_canvas->m_oNvGroupSpPr->m_oCNvPr->m_oId->GetValue()); } @@ -427,9 +427,9 @@ void OoxConverter::convert(OOX::Drawing::CFontCollection *style_font, CString *s if (style_font == NULL) return; _CP_OPT(std::wstring) font_latin, font_cs, font_ea; - if (style_font->m_oCs.m_oTypeFace.IsInit()) font_cs = string2std_string(style_font->m_oCs.m_oTypeFace->GetValue()); - if (style_font->m_oEa.m_oTypeFace.IsInit()) font_ea = string2std_string(style_font->m_oEa.m_oTypeFace->GetValue()); - if (style_font->m_oLatin.m_oTypeFace.IsInit()) font_latin = string2std_string(style_font->m_oLatin.m_oTypeFace->GetValue()); + if (style_font->m_oCs.m_oTypeFace.IsInit()) font_cs = style_font->m_oCs.m_oTypeFace->GetValue(); + if (style_font->m_oEa.m_oTypeFace.IsInit()) font_ea = style_font->m_oEa.m_oTypeFace->GetValue(); + if (style_font->m_oLatin.m_oTypeFace.IsInit()) font_latin = style_font->m_oLatin.m_oTypeFace->GetValue(); odf_context()->drawing_context()->set_textarea_font(font_latin,font_ea,font_cs); @@ -595,7 +595,7 @@ void OoxConverter::convert(OOX::Drawing::CNonVisualDrawingProps * oox_cnvPr) if (oox_cnvPr->m_sName.IsInit()) { - std::wstring name = string2std_string(oox_cnvPr->m_sName.get()); + std::wstring name = oox_cnvPr->m_sName.get(); odf_context()->drawing_context()->set_name(name); } @@ -684,7 +684,7 @@ void OoxConverter::convert(OOX::Drawing::CPresetGeometry2D *oox_prst_geom) for (unsigned int i=0; im_oAvLst->m_arrGd.size(); i++) { if (oox_prst_geom->m_oAvLst->m_arrGd[i] == NULL) continue; - odf_context()->drawing_context()->add_modifier(string2std_string(oox_prst_geom->m_oAvLst->m_arrGd[i]->m_oFmla.GetValue())); + odf_context()->drawing_context()->add_modifier(oox_prst_geom->m_oAvLst->m_arrGd[i]->m_oFmla.GetValue()); } } } @@ -798,7 +798,7 @@ void OoxConverter::convert(OOX::Drawing::CBlipFillProperties *oox_bitmap_fill, C if (pathImage.GetLength() > 0) { - odf_context()->drawing_context()->set_bitmap_link(string2std_string(pathImage)); + odf_context()->drawing_context()->set_bitmap_link(pathImage); _graphics_utils_::GetResolution(pathImage, Width, Height); } else @@ -1021,7 +1021,7 @@ void OoxConverter::convert(OOX::Drawing::Colors::CColorTransform *oox_Clr, s SimpleTypes::CHexColor *oRgbColor = new SimpleTypes::CHexColor(ucR,ucG,ucB); if (oRgbColor) { - hexString = string2std_string(oRgbColor->ToString().Right(6)); + hexString = oRgbColor->ToString().Right(6); delete oRgbColor; } if (ucA !=255)opacity = (ucA/255.)* 100.; @@ -1076,7 +1076,7 @@ void OoxConverter::convert(OOX::Drawing::CSchemeColor *oox_ShemeClr, std::ws SimpleTypes::CHexColor *oRgbColor = new SimpleTypes::CHexColor(ucR,ucG,ucB); if (oRgbColor) { - hexString = string2std_string(oRgbColor->ToString().Right(6)); + hexString = oRgbColor->ToString().Right(6); delete oRgbColor; } if (ucA !=255)opacity = (ucA/255.)* 100.; @@ -1170,7 +1170,7 @@ void OoxConverter::convert(OOX::Drawing::CTextBodyProperties *oox_bodyPr) for (unsigned int i=0; i< oox_bodyPr->m_oPrstTxWrap->m_oAvLst->m_arrGd.size(); i++) { if (oox_bodyPr->m_oPrstTxWrap->m_oAvLst->m_arrGd[i] == NULL) continue; - odf_context()->drawing_context()->add_modifier(string2std_string(oox_bodyPr->m_oPrstTxWrap->m_oAvLst->m_arrGd[i]->m_oFmla.GetValue())); + odf_context()->drawing_context()->add_modifier(oox_bodyPr->m_oPrstTxWrap->m_oAvLst->m_arrGd[i]->m_oFmla.GetValue()); } } } @@ -1220,7 +1220,7 @@ void OoxConverter::convert(OOX::Drawing::CRunProperty * oox_run_pr, odf_writer:: if (oox_run_pr->m_oLatinFont.IsInit()) { if (oox_run_pr->m_oLatinFont->m_oTypeFace.IsInit()) - text_properties->content().fo_font_family_ = string2std_string(oox_run_pr->m_oLatinFont->m_oTypeFace->GetValue()); + text_properties->content().fo_font_family_ = oox_run_pr->m_oLatinFont->m_oTypeFace->GetValue(); else { text_properties->content().fo_font_family_ = L"Calibri";//default_font; ???? @@ -1229,7 +1229,7 @@ void OoxConverter::convert(OOX::Drawing::CRunProperty * oox_run_pr, odf_writer:: if (oox_run_pr->m_oAsianFont.IsInit()) { if (oox_run_pr->m_oAsianFont->m_oTypeFace.IsInit()) - text_properties->content().style_font_family_asian_ = string2std_string(oox_run_pr->m_oAsianFont->m_oTypeFace->GetValue()); + text_properties->content().style_font_family_asian_ = oox_run_pr->m_oAsianFont->m_oTypeFace->GetValue(); else { } @@ -1237,7 +1237,7 @@ void OoxConverter::convert(OOX::Drawing::CRunProperty * oox_run_pr, odf_writer:: if (oox_run_pr->m_oComplexFont.IsInit()) { if (oox_run_pr->m_oComplexFont->m_oTypeFace.IsInit()) - text_properties->content().style_font_family_complex_ = string2std_string(oox_run_pr->m_oComplexFont->m_oTypeFace->GetValue()); + text_properties->content().style_font_family_complex_ = oox_run_pr->m_oComplexFont->m_oTypeFace->GetValue(); else { } @@ -1252,9 +1252,9 @@ void OoxConverter::convert(OOX::Drawing::CRunProperty * oox_run_pr, odf_writer:: oox_language = oox_language.Left(res); } - text_properties->content().fo_language_ = string2std_string(oox_language); + text_properties->content().fo_language_ = oox_language; if (oox_country.GetLength() > 0) - text_properties->content().fo_country_ = string2std_string(oox_country); + text_properties->content().fo_country_ = oox_country; } if (oox_run_pr->m_oSpace.IsInit()) @@ -1320,7 +1320,7 @@ void OoxConverter::convert(OOX::Drawing::CRun *oox_run) odf_context()->text_context()->start_span(styled); if (oox_run->m_oText.IsInit()) { - odf_context()->text_context()->add_text_content( string2std_string(oox_run->m_oText->m_sText)); + odf_context()->text_context()->add_text_content( oox_run->m_oText->m_sText); } odf_context()->text_context()->end_span(); } diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConverterChart.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConverterChart.cpp index 6e470d8b70..bcb151aa3d 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConverterChart.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/ConverterChart.cpp @@ -455,7 +455,7 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_Bar3DChart *chart) odf_context()->chart_context()->set_chart_bar_gap_width(*chart->m_gapWidth->m_val); //if (chart->m_overlap && chart->m_overlap->m_val) - // odf_context()->chart_context()->set_chart_bar_overlap(string2std_string(*chart->m_overlap->m_val)); + // odf_context()->chart_context()->set_chart_bar_overlap(*chart->m_overlap->m_val); odf_context()->chart_context()->start_group_series(); convert(chart->m_dLbls); @@ -1043,7 +1043,7 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_SerTx* ser_tx) convert(ser_tx->m_strRef->m_strCache, false, true); } - //if (ser_tx->m_v)odf_context()->chart_context()->set_series_name(string2std_string(*ser_tx->m_v)); + //if (ser_tx->m_v)odf_context()->chart_context()->set_series_name(*ser_tx->m_v); } void OoxConverter::convert(OOX::Spreadsheet::CT_AxDataSource* cat, int type) diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp index 4703d72df9..43e28ee57d 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp @@ -472,7 +472,7 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph) { if (oox_paragraph->m_oParagraphProperty->m_oPStyle.IsInit() && oox_paragraph->m_oParagraphProperty->m_oPStyle->m_sVal.IsInit()) { - std::wstring style_name = string2std_string(*oox_paragraph->m_oParagraphProperty->m_oPStyle->m_sVal); + std::wstring style_name = *oox_paragraph->m_oParagraphProperty->m_oPStyle->m_sVal; odf_writer::odf_style_state_ptr style_state; if (odt_context->styles_context()->find_odf_style_state(style_name, odf_types::style_family::Paragraph, style_state) && style_state) @@ -786,10 +786,10 @@ void DocxConverter::convert(OOX::Logic::CSym *oox_sym) if (oox_sym->m_oChar.IsInit() == false) return; if (oox_sym->m_oFont.IsInit()) - odt_context->text_context()->set_symbol_font(string2std_string(*oox_sym->m_oFont)); + odt_context->text_context()->set_symbol_font(*oox_sym->m_oFont); odt_context->text_context()->set_symbol_text(oox_sym->m_oChar->GetValue()); - //odt_context->text_context()->add_text_content(std::wstring(L"/") + string2std_string(oox_sym->m_oChar->ToString())); + //odt_context->text_context()->add_text_content(std::wstring(L"/") + oox_sym->m_oChar->ToString()); } void DocxConverter::convert(OOX::Logic::CFldChar *oox_fld) { @@ -816,7 +816,7 @@ void DocxConverter::convert(OOX::Logic::CFldSimple *oox_fld) odt_context->start_field(true); { if (oox_fld->m_sInstr.IsInit()) - odt_context->set_field_instr(string2std_string(oox_fld->m_sInstr.get2())); + odt_context->set_field_instr(oox_fld->m_sInstr.get2()); for (unsigned int i=0; i< oox_fld->m_arrItems.size(); i++) { @@ -829,7 +829,7 @@ void DocxConverter::convert(OOX::Logic::CInstrText *oox_instrText) { if (oox_instrText == NULL) return; - odt_context->set_field_instr(string2std_string(oox_instrText->m_sText)); + odt_context->set_field_instr(oox_instrText->m_sText); } void DocxConverter::convert(OOX::Logic::CDelText *oox_delText) @@ -842,7 +842,7 @@ void DocxConverter::convert(OOX::Logic::CDelText *oox_delText) { } } - odt_context->add_text_content(string2std_string(oox_delText->m_sText)); + odt_context->add_text_content(oox_delText->m_sText); } void DocxConverter::convert(OOX::Logic::CIns *oox_ins) { @@ -1034,7 +1034,7 @@ int DocxConverter::convert(OOX::Logic::CTblPrChange *oox_table_prop_change) if (oox_table_prop_change->m_pTblPr->m_oTblStyle.IsInit() && oox_table_prop_change->m_pTblPr->m_oTblStyle->m_sVal.IsInit()) {//настройка предустановленного стиля - std::wstring base_style_name = string2std_string(*oox_table_prop_change->m_pTblPr->m_oTblStyle->m_sVal); + std::wstring base_style_name = *oox_table_prop_change->m_pTblPr->m_oTblStyle->m_sVal; table_styled = odt_context->styles_context()->table_styles().start_table(base_style_name); } @@ -1093,7 +1093,7 @@ void DocxConverter::convert(OOX::Logic::CParagraphProperty *oox_paragraph_pr, cp if (oox_paragraph_pr->m_oPStyle.IsInit() && oox_paragraph_pr->m_oPStyle->m_sVal.IsInit()) { - std::wstring style_name = string2std_string(*oox_paragraph_pr->m_oPStyle->m_sVal); + std::wstring style_name = *oox_paragraph_pr->m_oPStyle->m_sVal; odt_context->styles_context()->last_state()->set_parent_style_name(style_name); /////////////////////////find parent properties @@ -2043,7 +2043,7 @@ void DocxConverter::convert(OOX::Logic::CRunProperty *oox_run_pr, odf_writer::st if (oox_run_pr->m_oRStyle.IsInit() && oox_run_pr->m_oRStyle->m_sVal.IsInit()) { - odt_context->styles_context()->last_state()->set_parent_style_name(string2std_string(*oox_run_pr->m_oRStyle->m_sVal)); + odt_context->styles_context()->last_state()->set_parent_style_name(*oox_run_pr->m_oRStyle->m_sVal); } if (oox_run_pr->m_oBold.IsInit()) { @@ -2157,15 +2157,15 @@ void DocxConverter::convert(OOX::Logic::CRunProperty *oox_run_pr, odf_writer::st if (oox_run_pr->m_oRFonts.IsInit()) { if (oox_run_pr->m_oRFonts->m_sAscii.IsInit()) - text_properties->content().fo_font_family_ = string2std_string(oox_run_pr->m_oRFonts->m_sAscii.get()); + text_properties->content().fo_font_family_ = oox_run_pr->m_oRFonts->m_sAscii.get(); else convert(oox_run_pr->m_oRFonts->m_oAsciiTheme.GetPointer(), text_properties->content().fo_font_family_); if (oox_run_pr->m_oRFonts->m_sCs.IsInit()) - text_properties->content().style_font_family_complex_ = string2std_string(oox_run_pr->m_oRFonts->m_sCs.get()); + text_properties->content().style_font_family_complex_ = oox_run_pr->m_oRFonts->m_sCs.get(); else convert(oox_run_pr->m_oRFonts->m_oCsTheme.GetPointer(), text_properties->content().style_font_family_complex_); if (oox_run_pr->m_oRFonts->m_sEastAsia.IsInit()) - text_properties->content().style_font_family_asian_= string2std_string(oox_run_pr->m_oRFonts->m_sEastAsia.get()); + text_properties->content().style_font_family_asian_= oox_run_pr->m_oRFonts->m_sEastAsia.get(); else convert(oox_run_pr->m_oRFonts->m_oEastAsiaTheme.GetPointer(), text_properties->content().style_font_family_asian_); //nullable m_sHAnsi; @@ -2207,11 +2207,13 @@ void DocxConverter::convert(OOX::Logic::CRunProperty *oox_run_pr, odf_writer::st BYTE ucG = oox_run_pr->m_oHighlight->m_oVal->Get_G(); SimpleTypes::CHexColor<> *oRgbColor = new SimpleTypes::CHexColor<>(ucR,ucG,ucB); if (oRgbColor) - { - text_properties->content().fo_background_color_ = odf_types::color(std::wstring(L"#") + string2std_string(oRgbColor->ToString().Right(6))); + { + std::wstring strColor = L"#" + oRgbColor->ToString().Right(6); + text_properties->content().fo_background_color_ = odf_types::color(strColor); delete oRgbColor; } } + if (oox_run_pr->m_oShd.IsInit()) { _CP_OPT(odf_types::color) odf_color; @@ -2243,21 +2245,21 @@ void DocxConverter::convert(SimpleTypes::CTheme<>* oox_font_theme, _CP_OPT(std:: case SimpleTypes::themeMajorHAnsi : if (docx_theme->m_oThemeElements.m_oFontScheme.m_oMajorFont.m_oLatin.m_oTypeFace.IsInit()) { - font = string2std_string(docx_theme->m_oThemeElements.m_oFontScheme.m_oMajorFont.m_oLatin.m_oTypeFace->GetValue()); + font = docx_theme->m_oThemeElements.m_oFontScheme.m_oMajorFont.m_oLatin.m_oTypeFace->GetValue(); if (font.length() > 0) odf_font_name = font; } break; case SimpleTypes::themeMajorBidi: if (docx_theme->m_oThemeElements.m_oFontScheme.m_oMajorFont.m_oCs.m_oTypeFace.IsInit()) { - font = string2std_string(docx_theme->m_oThemeElements.m_oFontScheme.m_oMajorFont.m_oCs.m_oTypeFace->GetValue()); + font = docx_theme->m_oThemeElements.m_oFontScheme.m_oMajorFont.m_oCs.m_oTypeFace->GetValue(); if (font.length() > 0) odf_font_name = font; } break; case SimpleTypes::themeMajorEastAsia: if (docx_theme->m_oThemeElements.m_oFontScheme.m_oMajorFont.m_oEa.m_oTypeFace.IsInit()) { - font = string2std_string(docx_theme->m_oThemeElements.m_oFontScheme.m_oMajorFont.m_oEa.m_oTypeFace->GetValue()); + font = docx_theme->m_oThemeElements.m_oFontScheme.m_oMajorFont.m_oEa.m_oTypeFace->GetValue(); if (font.length() > 0) odf_font_name = font; } break; @@ -2265,21 +2267,21 @@ void DocxConverter::convert(SimpleTypes::CTheme<>* oox_font_theme, _CP_OPT(std:: case SimpleTypes::themeMinorHAnsi: if (docx_theme->m_oThemeElements.m_oFontScheme.m_oMinorFont.m_oLatin.m_oTypeFace.IsInit()) { - font = string2std_string(docx_theme->m_oThemeElements.m_oFontScheme.m_oMinorFont.m_oLatin.m_oTypeFace->GetValue()); + font = docx_theme->m_oThemeElements.m_oFontScheme.m_oMinorFont.m_oLatin.m_oTypeFace->GetValue(); if (font.length() > 0) odf_font_name = font; } break; case SimpleTypes::themeMinorBidi: if (docx_theme->m_oThemeElements.m_oFontScheme.m_oMinorFont.m_oCs.m_oTypeFace.IsInit()) { - font = string2std_string(docx_theme->m_oThemeElements.m_oFontScheme.m_oMinorFont.m_oCs.m_oTypeFace->GetValue()); + font = docx_theme->m_oThemeElements.m_oFontScheme.m_oMinorFont.m_oCs.m_oTypeFace->GetValue(); if (font.length() > 0) odf_font_name = font; } break; case SimpleTypes::themeMinorEastAsia: if (docx_theme->m_oThemeElements.m_oFontScheme.m_oMinorFont.m_oEa.m_oTypeFace.IsInit()) { - font = string2std_string(docx_theme->m_oThemeElements.m_oFontScheme.m_oMinorFont.m_oEa.m_oTypeFace->GetValue()); + font = docx_theme->m_oThemeElements.m_oFontScheme.m_oMinorFont.m_oEa.m_oTypeFace->GetValue(); if (font.length() > 0) odf_font_name = font; } break; @@ -2299,7 +2301,7 @@ void DocxConverter::convert(OOX::Logic::CText *oox_text) } //odt_context->text_context()->add_text_space(26); } - odt_context->add_text_content(string2std_string(oox_text->m_sText)); + odt_context->add_text_content(oox_text->m_sText); } void DocxConverter::convert(OOX::Logic::CAlternateContent *oox_alt_content) { @@ -2778,7 +2780,7 @@ void DocxConverter::convert(OOX::Drawing::CPicture * oox_picture) } _graphics_utils_::GetResolution(pathImage, Width, Height); } - odt_context->start_image(string2std_string(pathImage)); + odt_context->start_image(pathImage); { if (oox_picture->m_oBlipFill.m_oTile.IsInit()) { @@ -2928,7 +2930,7 @@ void DocxConverter::convert(OOX::Logic::CGroupShape *oox_group_shape) if (oox_group_shape->m_oCNvPr.IsInit()) { if (oox_group_shape->m_oCNvPr->m_sName.IsInit()) - odt_context->drawing_context()->set_group_name(string2std_string(*oox_group_shape->m_oCNvPr->m_sName)); + odt_context->drawing_context()->set_group_name(*oox_group_shape->m_oCNvPr->m_sName); if (oox_group_shape->m_oCNvPr->m_oId.IsInit()) odt_context->drawing_context()->set_group_z_order(oox_group_shape->m_oCNvPr->m_oId->GetValue()); } @@ -3104,8 +3106,10 @@ void DocxConverter::convert(SimpleTypes::CHexColor<> *color, { SimpleTypes::CHexColor<> *oRgbColor = new SimpleTypes::CHexColor<>(ucR,ucG,ucB); if (oRgbColor) - { - odf_color = odf_types::color(std::wstring(L"#") + string2std_string(oRgbColor->ToString().Right(6))); + { + std::wstring strColor = L"#" + oRgbColor->ToString().Right(6); + + odf_color = odf_types::color(strColor); delete oRgbColor; } } @@ -3488,9 +3492,9 @@ void DocxConverter::convert(OOX::Numbering::CLvl* oox_num_lvl) if (oox_num_lvl->m_oLvlText.IsInit() && oox_num_lvl->m_oLvlText->m_sVal.IsInit()) { if (type_list == 2) - odt_context->styles_context()->lists_styles().set_bullet_char(string2std_string(oox_num_lvl->m_oLvlText->m_sVal.get())); + odt_context->styles_context()->lists_styles().set_bullet_char(oox_num_lvl->m_oLvlText->m_sVal.get()); else if (type_list == 1) - odt_context->styles_context()->lists_styles().set_numeric_format(string2std_string(oox_num_lvl->m_oLvlText->m_sVal.get())); + odt_context->styles_context()->lists_styles().set_numeric_format(oox_num_lvl->m_oLvlText->m_sVal.get()); } if (oox_num_lvl->m_oLvlPicBulletId.IsInit() && oox_num_lvl->m_oLvlPicBulletId->m_oVal.IsInit()) { @@ -3532,7 +3536,7 @@ void DocxConverter::convert_table_style(OOX::CStyle *oox_style) { if (oox_style == NULL)return; - std::wstring oox_name = oox_style->m_sStyleId.IsInit() ? string2std_string(*oox_style->m_sStyleId) : L""; + std::wstring oox_name = oox_style->m_sStyleId.IsInit() ? *oox_style->m_sStyleId : L""; odt_context->styles_context()->table_styles().start_style(oox_name); //общие @@ -3648,13 +3652,13 @@ void DocxConverter::convert(OOX::CStyle *oox_style) return; } - std::wstring oox_name = oox_style->m_sStyleId.IsInit() ? string2std_string(*oox_style->m_sStyleId) : L""; + std::wstring oox_name = oox_style->m_sStyleId.IsInit() ? *oox_style->m_sStyleId : L""; odt_context->styles_context()->create_style(oox_name,family, false, true, -1); if (oox_style->m_oName.IsInit() && oox_style->m_oName->m_sVal.IsInit()) - odt_context->styles_context()->last_state()->set_display_name(string2std_string(*oox_style->m_oName->m_sVal)); + odt_context->styles_context()->last_state()->set_display_name(*oox_style->m_oName->m_sVal); if (oox_style->m_oRunPr.IsInit()) { @@ -3708,7 +3712,7 @@ void DocxConverter::convert(OOX::CStyle *oox_style) } } if (oox_style->m_oBasedOn.IsInit() && oox_style->m_oBasedOn->m_sVal.IsInit()) - odt_context->styles_context()->last_state()->set_parent_style_name(string2std_string(*oox_style->m_oBasedOn->m_sVal)); + odt_context->styles_context()->last_state()->set_parent_style_name(*oox_style->m_oBasedOn->m_sVal); //nullable> m_oQFormat; //nullable m_oAliases; @@ -3788,8 +3792,8 @@ void DocxConverter::convert_comment(int oox_comm_id) { odt_context->start_comment_content(); { - if (oox_comment->m_oAuthor.IsInit()) odt_context->comment_context()->set_author (string2std_string(*oox_comment->m_oAuthor)); - if (oox_comment->m_oDate.IsInit()) odt_context->comment_context()->set_date (string2std_string(oox_comment->m_oDate->GetValue())); + if (oox_comment->m_oAuthor.IsInit()) odt_context->comment_context()->set_author (*oox_comment->m_oAuthor); + if (oox_comment->m_oDate.IsInit()) odt_context->comment_context()->set_date (oox_comment->m_oDate->GetValue()); if (oox_comment->m_oInitials.IsInit()) {} for (unsigned int i = 0; i m_arrItems.size(); i++) @@ -3895,7 +3899,7 @@ void DocxConverter::convert(OOX::Logic::CTbl *oox_table) if (oox_table->m_oTableProperties && (oox_table->m_oTableProperties->m_oTblStyle.IsInit() && oox_table->m_oTableProperties->m_oTblStyle->m_sVal.IsInit())) {//настройка предустановленного стиля - std::wstring base_style_name = string2std_string(*oox_table->m_oTableProperties->m_oTblStyle->m_sVal); + std::wstring base_style_name = *oox_table->m_oTableProperties->m_oTblStyle->m_sVal; styled_table = odt_context->styles_context()->table_styles().start_table(base_style_name); } diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp index 3a06a7c777..c05f7d94a8 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp @@ -181,7 +181,7 @@ void XlsxConverter::convert_sheets() if(pSheet->m_oRid.IsInit()) { CString sSheetRId = pSheet->m_oRid.get2().ToString(); - std::map::iterator pItWorksheet = arrWorksheets.find(string2std_string(sSheetRId)); + std::map::iterator pItWorksheet = arrWorksheets.find(sSheetRId); if (pItWorksheet->second) { @@ -656,7 +656,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CRPr *oox_run_pr) if (oox_run_pr->m_oRFont.IsInit()) { - //text_properties->content().style_font_name_ = string2std_string(oox_run_pr->m_oRFont->m_sVal.get()); + //text_properties->content().style_font_name_ = oox_run_pr->m_oRFont->m_sVal.get(); text_properties->content().fo_font_family_ = oox_run_pr->m_oRFont->m_sVal.get(); } @@ -1795,7 +1795,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CGroupShape* oox_group_shape) if (oox_group_shape->m_oNvGroupSpPr->m_oCNvPr.IsInit()) { if (oox_group_shape->m_oNvGroupSpPr->m_oCNvPr->m_sName.IsInit()) - ods_context->drawing_context()->set_group_name(string2std_string(*oox_group_shape->m_oNvGroupSpPr->m_oCNvPr->m_sName)); + ods_context->drawing_context()->set_group_name(*oox_group_shape->m_oNvGroupSpPr->m_oCNvPr->m_sName); if (oox_group_shape->m_oNvGroupSpPr->m_oCNvPr->m_oId.IsInit()) ods_context->drawing_context()->set_group_z_order(oox_group_shape->m_oNvGroupSpPr->m_oCNvPr->m_oId->GetValue()); } @@ -2024,7 +2024,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CPic* oox_picture) } _graphics_utils_::GetResolution(pathImage, Width, Height); } - ods_context->start_image(string2std_string(pathImage)); + ods_context->start_image(pathImage); { if (oox_picture->m_oBlipFill->m_oTile.IsInit()) { @@ -2077,7 +2077,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CConditionalFormatting *oox_cond_f if (oox_cond_fmt->m_oSqRef.IsInit()) { - ods_context->current_table().start_conditional_format(string2std_string(oox_cond_fmt->m_oSqRef->GetValue())); + ods_context->current_table().start_conditional_format(oox_cond_fmt->m_oSqRef->GetValue()); for (unsigned int i=0; i< oox_cond_fmt->m_arrItems.size(); i++) convert(oox_cond_fmt->m_arrItems[i]);//rule @@ -2190,12 +2190,12 @@ void XlsxConverter::convert(OOX::Spreadsheet::CAutofilter *oox_filter) std::wstring ref, sort_ref; bool sort = false, caseSensitive = false; if (oox_filter->m_oRef.IsInit()) - ref = string2std_string(oox_filter->m_oRef->GetValue()); + ref = oox_filter->m_oRef->GetValue(); if (oox_filter->m_oSortState.IsInit()) { sort = true; if (oox_filter->m_oSortState->m_oRef.IsInit()) - sort_ref = string2std_string(oox_filter->m_oSortState->m_oRef->GetValue()); + sort_ref = oox_filter->m_oSortState->m_oRef->GetValue(); if (oox_filter->m_oSortState->m_oCaseSensitive.IsInit() && oox_filter->m_oSortState->m_oCaseSensitive->GetValue()==1) caseSensitive = true; } diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTFormatLib.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTFormatLib.cpp index 9efacd9156..71f23e7e07 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTFormatLib.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTFormatLib.cpp @@ -60,7 +60,7 @@ bool COfficePPTFile::OpenFile(std::wstring sFileName) pStgFrom->open(false,false); - m_pReader = new CPPTFileReader(pStgFrom, std_string2string(m_strTempDirectory)); + m_pReader = new CPPTFileReader(pStgFrom, m_strTempDirectory); ((CPPTFileReader*)m_pReader)->m_oDocumentInfo.m_strFileDirectory = GetDirectory(sFileName.c_str()); if (!((CPPTFileReader*)m_pReader)->IsPowerPoint()) @@ -102,7 +102,7 @@ HRESULT COfficePPTFile::LoadFromFile(std::wstring sSrcFileName, std::wstring sDs if (!((CPPTFileReader*)m_pReader)->m_oDocumentInfo.m_arUsers.empty()) { NSPresentationEditor::CPPTXWriter oPPTXWriter; - oPPTXWriter.m_strTempDirectory = std_string2string(sDstPath); + oPPTXWriter.m_strTempDirectory = sDstPath; oPPTXWriter.CreateFile(((CPPTFileReader*)m_pReader)->m_oDocumentInfo.m_arUsers[0]); diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp index 3b71b311a9..cfd2e277ab 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp @@ -571,9 +571,8 @@ void NSPresentationEditor::CPPTXWriter::WriteThemes() for (int i = 0 ; i < pTheme->m_arExtraColorScheme.size(); i++) { - CString str; - str.Format(_T(" %d"), i + 1); - WriteColorScheme(oStringWriter, pTheme->m_sThemeName + string2std_string(str), pTheme->m_arExtraColorScheme[i], true); //extra + std::wstring str = L" " + std::to_wstring(i + 1); + WriteColorScheme(oStringWriter, pTheme->m_sThemeName + str, pTheme->m_arExtraColorScheme[i], true); //extra } oStringWriter.WriteString(std::wstring(L"")); diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ImageManager.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ImageManager.h index a6d1f672b7..a009af85b3 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ImageManager.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ImageManager.h @@ -81,29 +81,28 @@ namespace NSPresentationEditor if (strExts == _T(".tmp")) strExts = _T(".png"); - CString strImage = _T(""); - strImage.Format(_T("image%d"), m_lIndexNextImage++); + std::wstring strImage = L"image" + std::to_wstring(m_lIndexNextImage++); - std::wstring strOutput = m_strDstMedia + string2std_string(strImage) + strExts; - strImage = _T("../media/") + strImage + std_string2string(strExts); + std::wstring strOutput = m_strDstMedia + strImage + strExts; + strImage = _T("../media/") + strImage + strExts; // теперь нужно скопировать картинку if (strOutput != strInput) { - if (CDirectory::CopyFile(std_string2string(strInput), std_string2string(strOutput), NULL, NULL) == false) + if (CDirectory::CopyFile(strInput, strOutput, NULL, NULL) == false) { return L""; } } - m_mapImages[strInput] = string2std_string(strImage); + m_mapImages[strInput] = strImage; return strImage; } AVSINLINE bool IsNeedDownload(const std::wstring& strFile) { - int n1 = strFile.find(_T("www")); - int n2 = strFile.find(_T("http")); - int n3 = strFile.find(_T("ftp")); + int n1 = strFile.find(L"www"); + int n2 = strFile.find(L"http"); + int n3 = strFile.find(L"ftp"); if (((n1 >= 0) && (n1 < 10)) || ((n2 >= 0) && (n2 < 10)) || ((n3 >= 0) && (n3 < 10))) return true; @@ -280,13 +279,13 @@ namespace NSPresentationEditor } m_mapHyperlinks[strHyperlink] = m_lNextRelsID; - CString strRid = _T(""); - strRid.Format(_T("rId%d"), m_lNextRelsID++); + CString strRid; + strRid.Format(L"rId%d", m_lNextRelsID++); - std::wstring strRels = _T(""); + strRels += strRid + L"\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink\" Target=\""; + strRels += strHyperlink + L"\"/>"; m_oWriter.WriteString(strRels); } @@ -304,17 +303,15 @@ namespace NSPresentationEditor m_mapImages[strImage] = m_lNextRelsID; - CString strRid = _T(""); - strRid.Format(_T("rId%d"), m_lNextRelsID++); - - std::wstring strRels = _T(""); + strRels += L" TargetMode=\"External\""; + strRels += L"/>"; m_oWriter.WriteString(strRels); diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp index 0d2d4abc80..9836116a47 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/ShapeWriter.cpp @@ -40,13 +40,15 @@ #endif void CStylesWriter::ConvertStyleLevel(NSPresentationEditor::CTextStyleLevel& oLevel, NSPresentationEditor::CMetricInfo& oMetricInfo, - NSPresentationEditor::CStringWriter& oWriter, const int& nLevel) + NSPresentationEditor::CStringWriter& oWriter, const int& nLevel) {//дублирование CTextPFRun и CTextCFRun с ShapeWriter - todooo - вынести отдельно CString str1; if (nLevel == 9) str1 = _T("textDirection.is_init()) { - if (pPF->textDirection.get() == 1) oWriter.WriteString(std::wstring(L" rtl=\"1\"")); - else oWriter.WriteString(std::wstring(L" rtl=\"0\"")); + if (pPF->textDirection.get() == 1) oWriter.WriteString(L" rtl=\"1\""); + else oWriter.WriteString(L" rtl=\"0\""); } if (pPF->fontAlign.is_init()) { - CString strProp = GetFontAlign(pPF->fontAlign.get()); - oWriter.WriteString(std::wstring(L" fontAlgn=\"") + string2std_string(strProp) + _T("\"")); + std::wstring strProp = GetFontAlign(pPF->fontAlign.get()); + oWriter.WriteString(L" fontAlgn=\"" + strProp + L"\""); } if (pPF->leftMargin.is_init()) { - CString strProp; - strProp.Format(_T(" marL=\"%d\""), pPF->leftMargin.get()); - oWriter.WriteString(strProp); + std::wstring strProp = std::to_wstring(pPF->leftMargin.get()); + oWriter.WriteString(L" marL=\"" + strProp + L"\""); if (pPF->indent.is_init() == false) pPF->indent = (LONG)0; } if (pPF->indent.is_init()) { - CString strProp; - strProp.Format(_T(" indent=\"%d\""), pPF->indent.get()); - oWriter.WriteString(strProp); + std::wstring strProp = std::to_wstring(pPF->indent.get()); + oWriter.WriteString(L" indent=\"" + strProp + L"\""); } if (pPF->textAlignment.is_init()) { - CString strProp = GetTextAlign(pPF->textAlignment.get()); - oWriter.WriteString(std::wstring(L" algn=\"") + string2std_string(strProp) + _T("\"")); + std::wstring strProp = GetTextAlign(pPF->textAlignment.get()); + oWriter.WriteString(L" algn=\"" + strProp + L"\""); } if (pPF->defaultTabSize.is_init()) { - CString strProp; - strProp.Format(_T(" defTabSz=\"%d\""), pPF->defaultTabSize.get()); - oWriter.WriteString(strProp); + std::wstring strProp = std::to_wstring(pPF->defaultTabSize.get()); + oWriter.WriteString(L" defTabSz=\"" + strProp + L"\""); } - CString str2 = _T(">"); - oWriter.WriteString(str2); + oWriter.WriteString(L">"); if (pPF->tabStops.size() > 0) { - oWriter.WriteString(std::wstring(L"")); + oWriter.WriteString(L""); for (int t = 0 ; t < pPF->tabStops.size(); t++) { - CString strTabPos; strTabPos.Format(L"%d", pPF->tabStops[t].first) ; - oWriter.WriteString(std::wstring(L"tabStops[t].first); + oWriter.WriteString(L"tabStops[t].second == 1) oWriter.WriteString(std::wstring(L" algn=\"ctr\"/>")); - else if (pPF->tabStops[t].second == 2) oWriter.WriteString(std::wstring(L" algn=\"r\"/>")); - else if (pPF->tabStops[t].second == 3) oWriter.WriteString(std::wstring(L" algn=\"dec\"/>")); - else oWriter.WriteString(std::wstring(L" algn=\"l\"/>")); + if (pPF->tabStops[t].second == 1) oWriter.WriteString(L" algn=\"ctr\"/>"); + else if (pPF->tabStops[t].second == 2) oWriter.WriteString(L" algn=\"r\"/>"); + else if (pPF->tabStops[t].second == 3) oWriter.WriteString(L" algn=\"dec\"/>"); + else oWriter.WriteString(L" algn=\"l\"/>"); } - oWriter.WriteString(std::wstring(L"")); + oWriter.WriteString(L""); } if (pPF->hasBullet.is_init()) @@ -113,42 +111,39 @@ void CStylesWriter::ConvertStyleLevel(NSPresentationEditor::CTextStyleLevel& oLe { if (pPF->bulletColor.is_init()) { - oWriter.WriteString(std::wstring(L"")); + oWriter.WriteString(L""); oWriter.WriteString(NSPresentationEditor::CShapeWriter::ConvertColor(pPF->bulletColor.get(), 255)); - oWriter.WriteString(std::wstring(L"")); + oWriter.WriteString(L""); } if (pPF->bulletSize.is_init()) { if (pPF->bulletSize.get() > 24 && pPF->bulletSize.get() < 401) { - CString str; - str.Format(_T(""), pPF->bulletSize.get() * 1000 ); - oWriter.WriteString(str); + std::wstring strProp = std::to_wstring(pPF->bulletSize.get() * 1000 ); + oWriter.WriteString(L""); } if (pPF->bulletSize.get() < 0 && pPF->bulletSize.get() > -4001) { - CString str; - str.Format(_T(""), - pPF->bulletSize.get() ); - oWriter.WriteString(str); + std::wstring strProp = std::to_wstring(- pPF->bulletSize.get() ); + oWriter.WriteString(L""); } } if (pPF->bulletFontProperties.is_init()) { - oWriter.WriteString(std::wstring(L"bulletFontProperties->strFontName + _T("\"/>")); + oWriter.WriteString(L"bulletFontProperties->strFontName + L"\"/>"); } if (pPF->bulletChar.is_init()) { wchar_t bu = pPF->bulletChar.get(); - oWriter.WriteString(std::wstring(L"")); + oWriter.WriteString(L"\"/>"); } } else { - CString strB = _T(""); - oWriter.WriteString(strB); + oWriter.WriteString(L""); } } @@ -158,15 +153,13 @@ void CStylesWriter::ConvertStyleLevel(NSPresentationEditor::CTextStyleLevel& oLe LONG val = pPF->lineSpacing.get(); if (val > 0) { - CString str = _T(""); - str.Format(_T(""), (int)(val * 0.125 * 100/*/ dKoef1*/)); - oWriter.WriteString(str); + std::wstring str = std::to_wstring( (int)(val * 0.125 * 100/*/ dKoef1*/)); + oWriter.WriteString(L""); } else if (val < 0 && val > -13200) { - CString str = _T(""); - str.Format(_T(""), -val * 1000); - oWriter.WriteString(str); + std::wstring str = std::to_wstring(-val * 1000); + oWriter.WriteString(L""); } } if (pPF->spaceAfter.is_init()) @@ -174,15 +167,13 @@ void CStylesWriter::ConvertStyleLevel(NSPresentationEditor::CTextStyleLevel& oLe LONG val = pPF->spaceAfter.get(); if (val > 0) { - CString str = _T(""); - str.Format(_T(""), (int)(val * 0.125 * 100/*/ dKoef1*/)); - oWriter.WriteString(str); + std::wstring str = std::to_wstring((int)(val * 0.125 * 100/*/ dKoef1*/)); + oWriter.WriteString(L""); } else if (val < 0 && val > -13200) { - CString str = _T(""); - str.Format(_T(""), -val * 1000); - oWriter.WriteString(str); + std::wstring str = std::to_wstring(-val * 1000); + oWriter.WriteString(L""); } } if (pPF->spaceBefore.is_init()) @@ -190,35 +181,31 @@ void CStylesWriter::ConvertStyleLevel(NSPresentationEditor::CTextStyleLevel& oLe LONG val = pPF->spaceBefore.get(); if (val > 0) { - CString str = _T(""); - str.Format(_T(""), (int)(val * 0.125 * 100/*/ dKoef1*/)); - oWriter.WriteString(str); + std::wstring str = std::to_wstring((int)(val * 0.125 * 100/*/ dKoef1*/)); + oWriter.WriteString(L""); } else if (val < 0 && val > -13200) { - CString str = _T(""); - str.Format(_T(""), -val * 1000); - oWriter.WriteString(str); + std::wstring str = std::to_wstring(-val * 1000); + oWriter.WriteString(L""); } } - CString strCF1 = _T("Size.is_init()) { - CString strProp = _T(""); - strProp.Format(_T(" sz=\"%d\""), (int)(100 * pCF->Size.get())); - oWriter.WriteString(strProp); + std::wstring str = std::to_wstring((int)(100 * pCF->Size.get())); + oWriter.WriteString(L" sz=\"" + str + L"\""); } if (pCF->FontBold.is_init()) { if (pCF->FontBold.get()) - oWriter.WriteString(std::wstring(L" b=\"1\"")); + oWriter.WriteString(L" b=\"1\""); else - oWriter.WriteString(std::wstring(L" b=\"0\"")); + oWriter.WriteString(L" b=\"0\""); } if (pCF->FontItalic.is_init()) { @@ -240,51 +227,46 @@ void CStylesWriter::ConvertStyleLevel(NSPresentationEditor::CTextStyleLevel& oLe { if (pCF->Color->m_lSchemeIndex != -1) { - CString strProp = _T("Color->m_lSchemeIndex) + _T("\"/>"); - oWriter.WriteString(strProp); + oWriter.WriteString(L"Color->m_lSchemeIndex) + L"\"/>"); } else { - CString strColor = _T(""); + CString strColor; strColor.Format(_T("%06x"), pCF->Color->GetLONG_RGB()); - CString strProp = _T(""); - oWriter.WriteString(strProp); + oWriter.WriteString(L""); } } if (pCF->Typeface.is_init()) { if (0 == pCF->Typeface.get()) { - CString strProp = _T(""); - oWriter.WriteString(strProp); + oWriter.WriteString(L""); } else { - CString strProp = _T(""); - oWriter.WriteString(strProp); + oWriter.WriteString(L""); } } else if ((pCF->FontProperties.is_init()) && (!pCF->FontProperties->strFontName.empty())) { - oWriter.WriteString(std::wstring(L"FontProperties->strFontName + _T("\"/>")); + oWriter.WriteString(L"FontProperties->strFontName + L"\"/>"); } if (pCF->FontPropertiesEA.is_init()) { - oWriter.WriteString(std::wstring(L"FontPropertiesEA->strFontName + _T("\"/>")); + oWriter.WriteString(L"FontPropertiesEA->strFontName + L"\"/>"); } if (pCF->FontPropertiesSym.is_init()) { - oWriter.WriteString(std::wstring(L"FontPropertiesSym->strFontName + _T("\"/>")); + oWriter.WriteString(L"FontPropertiesSym->strFontName + L"\"/>"); } - CString strCF2 = _T(""); - oWriter.WriteString(strCF2); + oWriter.WriteString(L""); - CString str3 = _T(""); + CString str3; if (nLevel == 9) - str3 = _T(""); + str3 = L""; else - str3.Format(_T(""), nLevel + 1); + str3 = L""; oWriter.WriteString(str3); } @@ -319,15 +301,14 @@ CString NSPresentationEditor::CShapeWriter::ConvertLine(CPen & pen) { NSPresentationEditor::CStringWriter line_writer; - CString strLine = _T(""); - strLine.Format(_T(""), (int)(pen.Size * 36000)); - line_writer.WriteString(strLine); + std::wstring str = std::to_wstring( (int)(pen.Size * 36000)); + line_writer.WriteString(L""); - line_writer.WriteString(std::wstring(L"")); + line_writer.WriteString(L""); line_writer.WriteString(ConvertColor(pen.Color, pen.Alpha)); - line_writer.WriteString(std::wstring(L"")); + line_writer.WriteString(L""); - line_writer.WriteString(std::wstring(L"")); + line_writer.WriteString(L""); return line_writer.GetData(); } @@ -339,25 +320,25 @@ CString NSPresentationEditor::CShapeWriter::ConvertBrush(CBrush & brush) { if (m_pImageElement)//фон для картинки с празрачностью { - brush_writer.WriteString(std::wstring(L"")); + brush_writer.WriteString(L""); } else { - CString strRid = m_pRels->WriteImage(brush.TexturePath); + std::wstring strRid = m_pRels->WriteImage(brush.TexturePath); - brush_writer.WriteString(std::wstring(L"")); + brush_writer.WriteString(L""); if ( brush.TextureMode == c_BrushTextureModeTile) - brush_writer.WriteString(std::wstring(L"")); + brush_writer.WriteString(L""); else - brush_writer.WriteString(std::wstring(L"")); + brush_writer.WriteString(L""); - brush_writer.WriteString(std::wstring(L"")); + brush_writer.WriteString(L""); } } else if ( brush.Type == c_BrushTypeNoFill) { - brush_writer.WriteString(std::wstring(L"")); + brush_writer.WriteString(L""); } else if ( brush.Type == c_BrushTypePathGradient1 || brush.Type == c_BrushTypePathGradient2 || @@ -365,30 +346,30 @@ CString NSPresentationEditor::CShapeWriter::ConvertBrush(CBrush & brush) brush.Type == c_BrushTypeHorizontal || brush.Type == c_BrushTypeVertical ) { - brush_writer.WriteString(std::wstring(L"")); + brush_writer.WriteString(L""); if (brush.ColorsPosition.empty() == false) { for (int i = 0; i < brush.ColorsPosition.size(); i++) { - CString strPos; strPos.Format(L"%d", (int)(brush.ColorsPosition[i].second * 1000)); + std::wstring str = std::to_wstring( (int)(brush.ColorsPosition[i].second * 1000)); - brush_writer.WriteString(std::wstring(L""); + brush_writer.WriteString(L""); brush_writer.WriteString(ConvertColor(brush.ColorsPosition[i].first, 255)); - brush_writer.WriteString(std::wstring(L"")); + brush_writer.WriteString(L""); } } else { - brush_writer.WriteString(std::wstring(L"")); + brush_writer.WriteString(L""); brush_writer.WriteString(ConvertColor(brush.Color1, brush.Alpha1)); - brush_writer.WriteString(std::wstring(L"")); + brush_writer.WriteString(L""); - brush_writer.WriteString(std::wstring(L"")); + brush_writer.WriteString(L""); brush_writer.WriteString(ConvertColor(brush.Color2, brush.Alpha2)); - brush_writer.WriteString(std::wstring(L"")); + brush_writer.WriteString(L""); } - brush_writer.WriteString(std::wstring(L"")); - brush_writer.WriteString(std::wstring(L""); + brush_writer.WriteString(L" 180) brush.LinearAngle -= 180; @@ -397,22 +378,22 @@ CString NSPresentationEditor::CShapeWriter::ConvertBrush(CBrush & brush) if (val < 0) val = 0; if (val > 360) val -= 360; - CString str; str.Format(_T("%d"), val * 60000); + std::wstring str = std::to_wstring(val * 60000); brush_writer.WriteString(str); } - brush_writer.WriteString(std::wstring(L"\" scaled=\"1\"/>")); - brush_writer.WriteString(std::wstring(L"")); + brush_writer.WriteString(L"\" scaled=\"1\"/>"); + brush_writer.WriteString(L""); } else if(brush.Type == c_BrushTypePattern) {//типов нету в ппт - вместо них шаблон-картинка - brush_writer.WriteString(std::wstring(L"")); - brush_writer.WriteString(std::wstring(L"")); + brush_writer.WriteString(L""); + brush_writer.WriteString(L""); brush_writer.WriteString(ConvertColor(brush.Color1, brush.Alpha1)); - brush_writer.WriteString(std::wstring(L"")); - brush_writer.WriteString(std::wstring(L"")); + brush_writer.WriteString(L""); + brush_writer.WriteString(L""); brush_writer.WriteString(ConvertColor(brush.Color2, brush.Alpha2)); - brush_writer.WriteString(std::wstring(L"")); - brush_writer.WriteString(std::wstring(L"")); + brush_writer.WriteString(L""); + brush_writer.WriteString(L""); } else { @@ -463,81 +444,80 @@ CString NSPresentationEditor::CShapeWriter::ConvertShadow(CShadow & shadow) } } - CString strDir = _T(""); - CString strDist = _T(""); + std::wstring strDir; + std::wstring strDist; if (shadow.DistanceY != 0 && shadow.DistanceX != 0) { if (shadow.DistanceY < 0 && shadow.DistanceX < 0) dir /=2; - strDir.Format(_T(" dir=\"%d\""), (int)(dir * 60000)); - strDist.Format(_T(" dist=\"%d\""), (int)(dist * 36000)); + strDir = L" dir=\"" + std::to_wstring((int)(dir * 60000)) + L"\""; + strDist = L" dist=\"" + std::to_wstring((int)(dist * 36000)) + L"\""; } - CString strSY = _T(""); + std::wstring strSY; if (shadow.ScaleYToY < 1 || shadow.ScaleYToY > 1) { if (shadow.ScaleYToX < 1)shadow.ScaleYToY = -shadow.ScaleYToY; - strSY.Format(_T(" sy=\"%d\""), (int)(shadow.ScaleYToY * 100000)); + strSY = L" sy=\"" + std::to_wstring((int)(shadow.ScaleYToY * 100000)) + L"\""; } - CString strSX = _T(""); + std::wstring strSX; if (shadow.ScaleYToX < 1 || shadow.ScaleYToX > 1) { - //strSX.Format(_T(" sx=\"%d\""), (int)(shadow.ScaleYToX * 100000)); - strSX.Format(_T(" kx=\"%d\""), (int)((shadow.ScaleYToX + 0.5) * 360000)); + strSX = L" kx=\"" + std::to_wstring((int)((shadow.ScaleYToX + 0.5) * 360000)) + L"\""; } NSPresentationEditor::CStringWriter shadow_writer; - shadow_writer.WriteString(std::wstring(L"")); + shadow_writer.WriteString(L""); if (!Preset.empty()) { - shadow_writer.WriteString(std::wstring(L"")); + shadow_writer.WriteString(L">"); shadow_writer.WriteString(ConvertColor(shadow.Color,shadow.Alpha)); - shadow_writer.WriteString(std::wstring(L"")); + shadow_writer.WriteString(L""); } else if (Inner) { - shadow_writer.WriteString(std::wstring(L"")); + shadow_writer.WriteString(L">"); shadow_writer.WriteString(ConvertColor(shadow.Color,shadow.Alpha)); - shadow_writer.WriteString(std::wstring(L"")); + shadow_writer.WriteString(L""); } else { - shadow_writer.WriteString(std::wstring(L"")); + shadow_writer.WriteString(L">"); shadow_writer.WriteString(ConvertColor(shadow.Color,shadow.Alpha)); - shadow_writer.WriteString(std::wstring(L"")); + shadow_writer.WriteString(L""); } - shadow_writer.WriteString(std::wstring(L"")); + shadow_writer.WriteString(L""); return shadow_writer.GetData(); } @@ -548,14 +528,14 @@ CString NSPresentationEditor::CShapeWriter::ConvertColor(CColor & color, long a { if (255 == alpha) { - CString str = _T(""); - str.Format(_T(""), color.GetLONG_RGB()); + CString str; + str.Format(L"", color.GetLONG_RGB()); color_writer.WriteString(str); } else { - CString str = _T(""); - str.Format(_T(""), color.GetLONG_RGB(), (int)(alpha * 100000 / 255)); + CString str; + str.Format(L"", color.GetLONG_RGB(), (int)(alpha * 100000 / 255)); color_writer.WriteString(str); } } @@ -563,16 +543,12 @@ CString NSPresentationEditor::CShapeWriter::ConvertColor(CColor & color, long a { if (255 == alpha) { - CString str = _T(""); - color_writer.WriteString(str); + color_writer.WriteString(L""); } else { - CString strAlpha; strAlpha.Format(_T("%d"), (int)(alpha * 100000 / 255)); - - CString str = _T(""); - - color_writer.WriteString(str); + std::wstring strAlpha = std::to_wstring((int)(alpha * 100000 / 255)); + color_writer.WriteString(L""); } } return color_writer.GetData(); @@ -581,12 +557,12 @@ void NSPresentationEditor::CShapeWriter::WriteImageInfo() { m_oWriter.WriteString(std::wstring(L"")); - CString strShapeID; - strShapeID.Format(_T("%d"), m_lNextShapeID); + std::wstring strShapeID = std::to_wstring(m_lNextShapeID); - m_oWriter.WriteString(std::wstring(L"m_sName.empty()) m_pImageElement->m_sName = std::wstring(L"Image ") + string2std_string(strShapeID); + if (m_pImageElement->m_sName.empty()) + m_pImageElement->m_sName = std::wstring(L"Image ") + strShapeID; if (m_pImageElement->m_bHidden) m_oWriter.WriteString(std::wstring(L" hidden=\"1\"")); @@ -609,12 +585,12 @@ void NSPresentationEditor::CShapeWriter::WriteImageInfo() { m_oWriter.WriteString(std::wstring(L"m_lPlaceholderType > 0) - m_oWriter.WriteString(std::wstring(L" type=\"") + GetPhType(m_pImageElement->m_lPlaceholderType) +_T("\"")); + m_oWriter.WriteString(std::wstring(L" type=\"") + GetPhType(m_pImageElement->m_lPlaceholderType) + L"\""); if (-1 != m_pImageElement->m_lPlaceholderID) { - CString strIdx; strIdx.Format(_T("%d"), m_pImageElement->m_lPlaceholderID ); - m_oWriter.WriteString(std::wstring(L" idx=\"") + string2std_string(strIdx) + _T("\"")); + std::wstring strIdx = std::to_wstring(m_pImageElement->m_lPlaceholderID ); + m_oWriter.WriteString(std::wstring(L" idx=\"") + strIdx + L"\""); } m_oWriter.WriteString(std::wstring(L"/>")); @@ -632,16 +608,14 @@ void NSPresentationEditor::CShapeWriter::WriteShapeInfo() { m_oWriter.WriteString(std::wstring(L"")); - CString strShapeID = _T(""); - if (m_pShapeElement->m_lID < 0) m_pShapeElement->m_lID = m_lNextShapeID; - strShapeID.Format(L"%d", m_pShapeElement->m_lID); + std::wstring strShapeID = std::to_wstring(m_pShapeElement->m_lID); - m_oWriter.WriteString(std::wstring(L"m_sName.empty()) m_pShapeElement->m_sName = std::wstring(L"Shape ") + string2std_string(strShapeID); + if (m_pShapeElement->m_sName.empty()) m_pShapeElement->m_sName = std::wstring(L"Shape ") + strShapeID; if (m_pShapeElement->m_bHidden) m_oWriter.WriteString(std::wstring(L" hidden=\"1\"")); @@ -684,8 +658,8 @@ void NSPresentationEditor::CShapeWriter::WriteShapeInfo() if ( m_pShapeElement->m_lPlaceholderID != -1) { - CString strIdx; strIdx.Format(_T("%d"), m_pShapeElement->m_lPlaceholderID ); - m_oWriter.WriteString(std::wstring(L" idx=\"") + string2std_string(strIdx) + _T("\"")); + std::wstring strIdx = std::to_wstring( m_pShapeElement->m_lPlaceholderID ); + m_oWriter.WriteString(std::wstring(L" idx=\"") + strIdx + L"\""); } if (m_pShapeElement->m_lPlaceholderSizePreset > 1 && !isTitlePlaceholder(m_pShapeElement->m_lPlaceholderType)) @@ -732,25 +706,24 @@ void NSPresentationEditor::CShapeWriter::WriteTextInfo() // m_oWriter.WriteString(std::wstring(L" lIns=\"0\" tIns=\"0\" rIns=\"0\" bIns=\"0\"")); if (m_pShapeElement->m_oShape.m_oText.m_oAttributes.m_nTextAlignVertical == 0 ) - m_oWriter.WriteString(" anchor=\"t\""); + m_oWriter.WriteString(L" anchor=\"t\""); else if (m_pShapeElement->m_oShape.m_oText.m_oAttributes.m_nTextAlignVertical == 2 ) - m_oWriter.WriteString(" anchor=\"b\""); + m_oWriter.WriteString(L" anchor=\"b\""); else if (m_pShapeElement->m_oShape.m_oText.m_oAttributes.m_nTextAlignVertical == 1 ) { - m_oWriter.WriteString(" anchor=\"ctr\""); - m_oWriter.WriteString(" anchorCtr=\"0\""); + m_oWriter.WriteString(L" anchor=\"ctr\""); + m_oWriter.WriteString(L" anchorCtr=\"0\""); } if (m_pShapeElement->m_oShape.m_oText.m_oAttributes.m_dTextRotate > 0) { - CString strProp; - strProp.Format(_T(" rot=\"%d\""), (int)(m_pShapeElement->m_oShape.m_oText.m_oAttributes.m_dTextRotate * 60000)); - m_oWriter.WriteString(strProp); + std::wstring strProp = std::to_wstring((int)(m_pShapeElement->m_oShape.m_oText.m_oAttributes.m_dTextRotate * 60000)); + m_oWriter.WriteString(L" rot=\"" + strProp + L"\""); } if (m_pShapeElement->m_oShape.m_oText.m_bVertical) { - m_oWriter.WriteString(" vert=\"eaVert\""); + m_oWriter.WriteString(L" vert=\"eaVert\""); } - m_oWriter.WriteString(std::wstring(L">")); + m_oWriter.WriteString(L">"); if (m_bWordArt) { @@ -769,29 +742,30 @@ void NSPresentationEditor::CShapeWriter::WriteTextInfo() case oox::msosptTextFadeUp: { double kf = 4.63; //"волшебный" - strVal.Format(L"%d", (int)(kf * pPPTShape->m_arAdjustments[i])); - m_oWriter.WriteString(std::wstring(L"")); + std::wstring strVal = std::to_wstring((int)(kf * pPPTShape->m_arAdjustments[i])); + + m_oWriter.WriteString(L""); }break; } } - m_oWriter.WriteString(std::wstring(L"")); - m_oWriter.WriteString(std::wstring(L"")); + m_oWriter.WriteString(L""); + m_oWriter.WriteString(L""); } if (m_pShapeElement->m_oShape.m_oText.m_bAutoFit) { - m_oWriter.WriteString(std::wstring(L"")); + m_oWriter.WriteString(L""); } - m_oWriter.WriteString(std::wstring(L"")); + m_oWriter.WriteString(L""); if (0 == nCount) { - m_oWriter.WriteString(std::wstring(L"")); + m_oWriter.WriteString(L""); return; } - m_oWriter.WriteString(std::wstring(L"")); + m_oWriter.WriteString(L""); if (!m_bWordArt) { @@ -810,9 +784,8 @@ void NSPresentationEditor::CShapeWriter::WriteTextInfo() // if (pParagraph->m_arSpans.size() == 1 && pParagraph->m_arSpans[0].m_strText.empty()) break; //} - CString _str1 = _T(""); - _str1.Format(_T("m_lTextLevel); - m_oWriter.WriteString(_str1); + std::wstring _str1 = std::to_wstring(pParagraph->m_lTextLevel); + m_oWriter.WriteString(L"m_oPFRun; @@ -823,38 +796,34 @@ void NSPresentationEditor::CShapeWriter::WriteTextInfo() } if (pPF->fontAlign.is_init()) { - CString strProp = CStylesWriter::GetFontAlign(pPF->fontAlign.get()); - m_oWriter.WriteString(std::wstring(L" fontAlgn=\"") + string2std_string(strProp) + _T("\"")); + std::wstring strProp = CStylesWriter::GetFontAlign(pPF->fontAlign.get()); + m_oWriter.WriteString(std::wstring(L" fontAlgn=\"") + strProp + L"\""); } if (pPF->leftMargin.is_init()) { - CString strProp; - strProp.Format(_T(" marL=\"%d\""), pPF->leftMargin.get()); - m_oWriter.WriteString(strProp); + CString strProp = std::to_wstring( pPF->leftMargin.get() ); + m_oWriter.WriteString(L" marL=\"" + strProp + L"\""); + if (pPF->indent.is_init() == false) pPF->indent = (LONG)0; } if (pPF->indent.is_init()) { - int ind = pPF->indent.get(); - CString strProp = _T(""); - strProp.Format(_T(" indent=\"%d\""), pPF->indent.get()); - m_oWriter.WriteString(strProp); + std::wstring strProp = std::to_wstring(pPF->indent.get()); + m_oWriter.WriteString(L" indent=\"" + strProp + L"\""); } if (pPF->textAlignment.is_init()) { CString strProp = CStylesWriter::GetTextAlign(pPF->textAlignment.get()); - m_oWriter.WriteString(std::wstring(L" algn=\"") + string2std_string(strProp) + _T("\"")); + m_oWriter.WriteString(L" algn=\"" + strProp + L"\""); } if (pPF->defaultTabSize.is_init()) { - CString strProp = _T(""); - strProp.Format(_T(" defTabSz=\"%d\""), pPF->defaultTabSize.get()); - m_oWriter.WriteString(strProp); + std::wstring strProp= std::to_wstring( pPF->defaultTabSize.get()); + m_oWriter.WriteString(L" defTabSz=\"" + strProp + L"\""); } - CString _str2 = _T(">"); - m_oWriter.WriteString(_str2); + m_oWriter.WriteString(L">"); double dKoef1 = 3.52777778; // :-) чё это не понятно ... if (pPF->lineSpacing.is_init()) @@ -864,16 +833,13 @@ void NSPresentationEditor::CShapeWriter::WriteTextInfo() //1 inch = 576 master unit -> 1 master unit = 0.125 pt if (val > 0)//The absolute value specifies spacing in master units. { - CString str = _T(""); - str.Format(_T(""), (int)(val* 0.125 * 100/*/ dKoef1*/)); - m_oWriter.WriteString(str); + std::wstring strProp = std::to_wstring( (int)(val* 0.125 * 100/*/ dKoef1*/)); + m_oWriter.WriteString(L""); } else if (val < 0 && val > -13200) {//0 to 13200, inclusive - The value specifies spacing as a percentage of the text line height. - - CString str = _T(""); - str.Format(_T(""), -val * 1000); - m_oWriter.WriteString(str); + std::wstring strProp = std::to_wstring( -val * 1000); + m_oWriter.WriteString(L""); } } if (pPF->spaceAfter.is_init()) @@ -881,15 +847,13 @@ void NSPresentationEditor::CShapeWriter::WriteTextInfo() LONG val = pPF->spaceAfter.get(); if (val > 0) { - CString str = _T(""); - str.Format(_T(""), (int)(val * 0.125 * 100/*/ dKoef1*/)); - m_oWriter.WriteString(str); + std::wstring strProp = std::to_wstring((int)(val * 0.125 * 100/*/ dKoef1*/)); + m_oWriter.WriteString(L""); } else if (val < 0 && val > -13200) { - CString str; - str.Format(_T(""), -val * 1000); - m_oWriter.WriteString(str); + std::wstring strProp = std::to_wstring(-val * 1000); + m_oWriter.WriteString(L""); } } if (pPF->spaceBefore.is_init()) @@ -897,15 +861,13 @@ void NSPresentationEditor::CShapeWriter::WriteTextInfo() LONG val = pPF->spaceBefore.get(); if (val > 0) { - CString str = _T(""); - str.Format(_T(""), (int)(val * 0.125 * 100/*/ dKoef1*/)); - m_oWriter.WriteString(str); + std::wstring strProp = std::to_wstring((int)(val * 0.125 * 100/*/ dKoef1*/)); + m_oWriter.WriteString(L""); } else if (val < 0 && val > -13200) { - CString str; - str.Format(_T(""), -val * 1000); - m_oWriter.WriteString(str); + std::wstring strProp = std::to_wstring(-val * 1000); + m_oWriter.WriteString(L""); } } @@ -923,15 +885,13 @@ void NSPresentationEditor::CShapeWriter::WriteTextInfo() { if (pPF->bulletSize.get() > 24 && pPF->bulletSize.get() < 401) { - CString str; - str.Format(_T(""), pPF->bulletSize.get() * 1000 ); - m_oWriter.WriteString(str); + std::wstring strProp = std::to_wstring(pPF->bulletSize.get() * 1000 ); + m_oWriter.WriteString(L""); } if (pPF->bulletSize.get() < 0 && pPF->bulletSize.get() > -4001) { - CString str; - str.Format(_T(""), - pPF->bulletSize.get() ); - m_oWriter.WriteString(str); + std::wstring strProp = std::to_wstring(- pPF->bulletSize.get() ); + m_oWriter.WriteString(L""); } } if (pPF->bulletFontProperties.is_init()) @@ -1734,7 +1694,7 @@ HRESULT NSPresentationEditor::CShapeWriter::get_FontPath(std::wstring* bsName) } HRESULT NSPresentationEditor::CShapeWriter::put_FontPath(const std::wstring& bsName) { - m_oFont.Path = std_string2string(bsName); + m_oFont.Path = bsName; return S_OK; } HRESULT NSPresentationEditor::CShapeWriter::get_FontSize(double* dSize) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/StylesWriter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/StylesWriter.h index 79cdaf92b1..cc4affebaa 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/StylesWriter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/StylesWriter.h @@ -34,89 +34,58 @@ class CStylesWriter { public: - AVSINLINE static CString GetTextAnchor(const WORD& value) + AVSINLINE static std::wstring GetTextAnchor(const WORD& value) { - if (0 == value) - return _T("t"); - if (1 == value) - return _T("ctr"); - if (2 == value) - return _T("b"); - return _T("t"); + if (0 == value) return L"t"; + if (1 == value) return L"ctr"; + if (2 == value) return L"b"; + return L"t"; } - AVSINLINE static CString GetTextAlign(const WORD& value) + AVSINLINE static std::wstring GetTextAlign(const WORD& value) { - if (0 == value) - return _T("l"); - if (1 == value) - return _T("ctr"); - if (2 == value) - return _T("r"); - if (3 == value) - return _T("just"); - if (4 == value) - return _T("dist"); - if (5 == value) - return _T("thaiDist"); - if (6 == value) - return _T("justLow"); - return _T("l"); + if (0 == value) return L"l"; + if (1 == value) return L"ctr"; + if (2 == value) return L"r"; + if (3 == value) return L"just"; + if (4 == value) return L"dist"; + if (5 == value) return L"thaiDist"; + if (6 == value) return L"justLow"; + return L"l"; } - //oArrayMem.push_back(oScheme[0]);//0 - //oArrayMem.push_back(oScheme[1]);//1 - //oArrayMem.push_back(oScheme[2]);//2 - //oArrayMem.push_back(oScheme[3]);//3 - //oArrayMem.push_back(oScheme[0]);//4 - //oArrayMem.push_back(oScheme[4]);//5 //accent1 - //oArrayMem.push_back(oScheme[5]);//6 //accent2 - //oArrayMem.push_back(oScheme[0]);//7 //accent3 - //oArrayMem.push_back(oScheme[5]);//8 //accent4 - //oArrayMem.push_back(oScheme[4]);//9 //accent5 - //oArrayMem.push_back(oScheme[7]);//10 //accent6 - //oArrayMem.push_back(oScheme[6]);//11 //hlink - //oArrayMem.push_back(oScheme[7]);//12 //folHlink - //oArrayMem.push_back(oScheme[0]);//13 //lt1 - //oArrayMem.push_back(oScheme[1]);//14 //dk1 - //oArrayMem.push_back(oScheme[2]);//15 //lt2 - //oArrayMem.push_back(oScheme[3]);//16 //dk2 - AVSINLINE static CString GetColorInScheme(const LONG& lIndex) + AVSINLINE static std::wstring GetColorInScheme(const LONG& lIndex) { switch (lIndex) { - case 0: return _T("phClr"); - case 1: return _T("bg1"); - case 2: return _T("tx1"); - case 3: return _T("bg2"); - case 4: return _T("tx2"); - case 5: return _T("accent1"); - case 6: return _T("accent2"); - case 7: return _T("accent3"); - case 8: return _T("accent4"); - case 9: return _T("accent5"); - case 10: return _T("accent6"); - case 11: return _T("hlink"); - case 12: return _T("folHlink"); - case 13: return _T("lt1"); - case 14: return _T("dk1"); - case 15: return _T("lt2"); - case 16: return _T("dk2"); + case 0: return L"phClr"; + case 1: return L"bg1"; + case 2: return L"tx1"; + case 3: return L"bg2"; + case 4: return L"tx2"; + case 5: return L"accent1"; + case 6: return L"accent2"; + case 7: return L"accent3"; + case 8: return L"accent4"; + case 9: return L"accent5"; + case 10: return L"accent6"; + case 11: return L"hlink"; + case 12: return L"folHlink"; + case 13: return L"lt1"; + case 14: return L"dk1"; + case 15: return L"lt2"; + case 16: return L"dk2"; break; }; - return _T("none"); + return L"none"; } - AVSINLINE static CString GetFontAlign(const WORD& value) + AVSINLINE static std::wstring GetFontAlign(const WORD& value) { - if (0 == value) - return _T("base"); - if (1 == value) - return _T("t"); - if (2 == value) - return _T("ctr"); - if (3 == value) - return _T("b"); - return _T("auto"); + if (0 == value) return L"base"; + if (1 == value) return L"t"; + if (2 == value) return L"ctr"; + if (3 == value) return L"b"; + return L"auto"; } static CString ConvertStyles(NSPresentationEditor::CTextStyles& oStyles, NSPresentationEditor::CMetricInfo& oMetricInfo, int nCount = 10) diff --git a/ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.h b/ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.h index f48f66621c..6f03b91531 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.h +++ b/ASCOfficePPTFile/PPTFormatLib/Reader/ReadStructures.h @@ -183,7 +183,7 @@ public: bool m_bIsCompressed; bool m_bIsValid; - CString m_sExtension; + std::wstring m_sExtension; private: BYTE* m_pMetaHeader; BYTE* m_pMetaFile; diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ArtBlip.cpp b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ArtBlip.cpp index 236e06009d..607d1ca70e 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ArtBlip.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ArtBlip.cpp @@ -41,7 +41,7 @@ void CRecordOfficeArtBlip::ReadFromStream(SRecordHeader & oHeader, POLE::Stream* { CMetaFileBuffer oMetaFile; - CString sExt = L".jpg"; + std::wstring sExt = L".jpg"; int pos = pStream->tell(); @@ -179,7 +179,7 @@ void CRecordOfficeArtBlip::ReadFromStream(SRecordHeader & oHeader, POLE::Stream* if (oMetaFile.m_bIsValid) { - CString strFile = CString(L"Image ") + CDirectory::ToString(nImagesCount + 1) + oMetaFile.m_sExtension; + std::wstring strFile = L"Image " +std::to_wstring(nImagesCount + 1) + oMetaFile.m_sExtension; CFile fileMeta; HRESULT hr = fileMeta.CreateFile(m_strMemoryForder + FILE_SEPARATOR_STR + strFile); @@ -189,7 +189,7 @@ void CRecordOfficeArtBlip::ReadFromStream(SRecordHeader & oHeader, POLE::Stream* oMetaFile.ToFile(&fileMeta); fileMeta.CloseFile(); } - m_sFileName = string2std_string(strFile); + m_sFileName = strFile; } else { @@ -197,7 +197,7 @@ void CRecordOfficeArtBlip::ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream->read(pImage, oHeader.RecLen - lOffset); - CString strFile = CString(L"Image ") + CDirectory::ToString(nImagesCount + 1) + sExt; + std::wstring strFile = L"Image " + std::to_wstring(nImagesCount + 1) + sExt; CFile fileImage; HRESULT hr = fileImage.CreateFile(m_strMemoryForder + FILE_SEPARATOR_STR + strFile); @@ -220,7 +220,7 @@ void CRecordOfficeArtBlip::ReadFromStream(SRecordHeader & oHeader, POLE::Stream* if (pImage)delete[] pImage; pImage = NULL; - m_sFileName = string2std_string(strFile); + m_sFileName = strFile; } int dwOffset = pos - 8; diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ArtBlip.h b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ArtBlip.h index 36b58d5d43..43f09b52e8 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ArtBlip.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ArtBlip.h @@ -40,9 +40,9 @@ class CRecordOfficeArtBlip : public CUnknownRecord { public: CPPTDocumentInfo * m_oDocumentInfo; + std::wstring m_sFileName; - - CString m_strMemoryForder; + std::wstring m_strMemoryForder; CRecordOfficeArtBlip() { diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h index 845d41aed9..b8f1ba54c7 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Drawing/ShapeContainer.h @@ -1081,7 +1081,7 @@ public: if (pProperty->m_bComplex && 0 < pProperty->m_lValue) { std::wstring str = NSFile::CUtf8Converter::GetWStringFromUTF16((unsigned short*)pProperty->m_pOptions, pProperty->m_lValue/2-1); - pParentShape->m_oText.m_oAttributes.m_oFont.Name = std_string2string(str); + pParentShape->m_oText.m_oAttributes.m_oFont.Name = str; } }break; case NSOfficeDrawing::gtextSize: diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/TextBytesAtom.h b/ASCOfficePPTFile/PPTFormatLib/Records/TextBytesAtom.h index 6a5004137b..9dcb1bde7f 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/TextBytesAtom.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/TextBytesAtom.h @@ -71,7 +71,7 @@ public: RELEASEARRAYOBJECTS(pUTF16_low); RELEASEARRAYOBJECTS(pUTF16); - //std::string tmpStrTextA = string2std_string(StreamUtils::ReadCStringA(pStream, m_oHeader.RecLen)); + //std::string tmpStrTextA = StreamUtils::ReadCStringA(pStream, m_oHeader.RecLen); //std::wstring tmpStrTextW (tmpStrTextA.begin(), tmpStrTextA.end()); diff --git a/ASCOfficePPTFile/PPTFormatLib/Win32/PPTFormatLib.vcproj b/ASCOfficePPTFile/PPTFormatLib/Win32/PPTFormatLib.vcproj index c078f8c5d6..9af5b68d25 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Win32/PPTFormatLib.vcproj +++ b/ASCOfficePPTFile/PPTFormatLib/Win32/PPTFormatLib.vcproj @@ -438,6 +438,10 @@ /> + + diff --git a/ASCOfficePPTXFile/ASCOfficeDrawingConverter.cpp b/ASCOfficePPTXFile/ASCOfficeDrawingConverter.cpp index aa26c512c5..57ec50ada2 100644 --- a/ASCOfficePPTXFile/ASCOfficeDrawingConverter.cpp +++ b/ASCOfficePPTXFile/ASCOfficeDrawingConverter.cpp @@ -1948,7 +1948,7 @@ PPTX::Logic::SpTreeElem CDrawingConverter::doc_LoadShape(XmlUtils::CXmlNode& oNo NSPresentationEditor::CColor color; if (sColor2->Find(L"fill") != -1) { - std::wstring sColorEffect = string2std_string(*sColor2); + std::wstring sColorEffect = *sColor2; if (sColorEffect.length() > 5) sColorEffect = sColorEffect.substr(5); @@ -3596,7 +3596,7 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem& oElem, XmlUtils Gs_.color.Color = new PPTX::Logic::SrgbClr(); if (sColor2->Find(L"fill") != -1) { - std::wstring sColorEffect = string2std_string(*sColor2); + std::wstring sColorEffect = *sColor2; if (sColorEffect.length() > 5) sColorEffect = sColorEffect.substr(5); @@ -5163,9 +5163,11 @@ HRESULT CDrawingConverter::GetAdditionalParam(const CString& ParamName, VARIANT* } else if (name == L"OleXlsx") { - ParamValue->vt = VT_BSTR; + ParamValue->vt = VT_BSTR; #if defined(_WIN32) || defined (_WIN64) - ParamValue->bstrVal = m_pXmlWriter->m_strOleXlsx.AllocSysString(); + BSTR val = SysAllocString(m_pXmlWriter->m_strOleXlsx.c_str()); + ParamValue->bstrVal = val; + SysFreeString(val); #else ParamValue->bstrVal = m_pXmlWriter->m_strOleXlsx; #endif diff --git a/ASCOfficePPTXFile/ASCOfficePPTXFile.h b/ASCOfficePPTXFile/ASCOfficePPTXFile.h index a8ebf93dfc..246c48e404 100644 --- a/ASCOfficePPTXFile/ASCOfficePPTXFile.h +++ b/ASCOfficePPTXFile/ASCOfficePPTXFile.h @@ -44,10 +44,10 @@ #include "PPTXFormat/PPTXEvent.h" -typedef void (*load_from_resource)(void*, int, CString&); -typedef bool (*extract_to_directory)(void*, CString&, CString&); -typedef bool (*compress_from_directory)(void*, CString&, CString&); -typedef bool (*progress_operation)(void*, long, long); +typedef void (*load_from_resource) (void*, int, std::wstring&); +typedef bool (*extract_to_directory) (void*, std::wstring&, std::wstring&); +typedef bool (*compress_from_directory) (void*, std::wstring&, std::wstring&); +typedef bool (*progress_operation) (void*, long, long); namespace PPTX { @@ -57,8 +57,6 @@ namespace PPTX class CPPTXFile : public PPTX::IPPTXEvent { private: - //todo - //OfficeUtils::IOfficeUtils* m_pOfficeUtils; PPTX::Folder* m_pFolder; CString m_strTempDir; CString m_strDirectory; @@ -82,50 +80,29 @@ public: ~CPPTXFile(); - HRESULT LoadFromFile(BSTR sSrcFileName, BSTR sDstPath, BSTR sXMLOptions); + HRESULT LoadFromFile(std::wstring sSrcFileName, std::wstring sDstPath, std::wstring sXMLOptions); - HRESULT SaveToFile(BSTR sDstFileName, BSTR sSrcPath, BSTR sXMLOptions); + HRESULT SaveToFile(std::wstring sDstFileName, std::wstring sSrcPath, std::wstring sXMLOptions); -#if defined(_WIN32) || defined (_WIN64) - STDMETHOD(get_TempDirectory)(BSTR* pVal); - STDMETHOD(put_TempDirectory)(BSTR newVal); + HRESULT get_TempDirectory(std::wstring* pVal); + HRESULT put_TempDirectory(std::wstring newVal); - STDMETHOD(GetDVDXml)(BSTR* pbstrPTTXml); - STDMETHOD(GetBluRayXml)(BSTR* pbstrDVDXml); + HRESULT GetDVDXml(std::wstring* pbstrPTTXml); + HRESULT GetBluRayXml(std::wstring* pbstrDVDXml); - STDMETHOD(get_DrawingXml)(BSTR* pVal); - STDMETHOD(SetAdditionalParam)(BSTR ParamName, VARIANT ParamValue); - STDMETHOD(GetAdditionalParam)(BSTR ParamName, VARIANT* ParamValue); - virtual bool Progress(long ID, long Percent); - // to PPTY - STDMETHOD(SetMediaDir)(BSTR bsMediaDir); - STDMETHOD(SetFontDir)(BSTR bsFontDir); - STDMETHOD(SetThemesDir)(BSTR bsDir); - STDMETHOD(SetUseSystemFonts)(VARIANT_BOOL useSystemFonts); - STDMETHOD(OpenFileToPPTY)(BSTR bsInput, BSTR bsOutput); - STDMETHOD(OpenDirectoryToPPTY)(BSTR bsInput, BSTR bsOutput); - STDMETHOD(ConvertPPTYToPPTX)(BSTR bsInput, BSTR bsOutput, BSTR bsThemesFolder); -#else - HRESULT get_TempDirectory(BSTR* pVal); - HRESULT put_TempDirectory(BSTR newVal); - - HRESULT GetDVDXml(BSTR* pbstrPTTXml); - HRESULT GetBluRayXml(BSTR* pbstrDVDXml); - - HRESULT get_DrawingXml(BSTR* pVal); - HRESULT SetAdditionalParam(BSTR ParamName, VARIANT ParamValue); - HRESULT GetAdditionalParam(BSTR ParamName, VARIANT* ParamValue); + HRESULT get_DrawingXml(std::wstring* pVal); + HRESULT SetAdditionalParam(std::wstring ParamName, VARIANT ParamValue); + HRESULT GetAdditionalParam(std::wstring ParamName, VARIANT* ParamValue); virtual bool Progress(long ID, long Percent); // to PPTY - HRESULT SetMediaDir(BSTR bsMediaDir); - HRESULT SetFontDir(BSTR bsFontDir); - HRESULT SetThemesDir(BSTR bsDir); - HRESULT SetUseSystemFonts(VARIANT_BOOL useSystemFonts); - HRESULT OpenFileToPPTY(BSTR bsInput, BSTR bsOutput); - HRESULT OpenDirectoryToPPTY(BSTR bsInput, BSTR bsOutput); - HRESULT ConvertPPTYToPPTX(BSTR bsInput, BSTR bsOutput, BSTR bsThemesFolder); -#endif + HRESULT SetMediaDir (std::wstring bsMediaDir); + HRESULT SetFontDir (std::wstring bsFontDir); + HRESULT SetThemesDir (std::wstring bsDir); + HRESULT SetUseSystemFonts (VARIANT_BOOL useSystemFonts); + HRESULT OpenFileToPPTY (std::wstring bsInput, std::wstring bsOutput); + HRESULT OpenDirectoryToPPTY (std::wstring bsInput, std::wstring bsOutput); + HRESULT ConvertPPTYToPPTX (std::wstring bsInput, std::wstring bsOutput, std::wstring bsThemesFolder); }; #endif //ASC_OFFICE_PPTX_FILE diff --git a/ASCOfficePPTXFile/ASCOfficePPTXFileRealization.cpp b/ASCOfficePPTXFile/ASCOfficePPTXFileRealization.cpp index 1b580965ae..d8f081c7da 100644 --- a/ASCOfficePPTXFile/ASCOfficePPTXFileRealization.cpp +++ b/ASCOfficePPTXFile/ASCOfficePPTXFileRealization.cpp @@ -84,10 +84,10 @@ CPPTXFile::~CPPTXFile() { RELEASEOBJECT(m_pFolder); } -HRESULT CPPTXFile::LoadFromFile(BSTR sSrcFileName, BSTR sDstPath, BSTR sXMLOptions) +HRESULT CPPTXFile::LoadFromFile(std::wstring sSrcFileName, std::wstring sDstPath, std::wstring sXMLOptions) { - CStringW localTempDir(sDstPath); - if((sDstPath != NULL) || (localTempDir != _T(""))) + std::wstring localTempDir(sDstPath); + if(!localTempDir.empty()) { bool res = FileSystem::Directory::CreateDirectory(localTempDir); if (res == false) return S_FALSE; @@ -118,7 +118,7 @@ HRESULT CPPTXFile::LoadFromFile(BSTR sSrcFileName, BSTR sDstPath, BSTR sXMLOptio if(SHFileOperationW(&shfos) != 0) return S_FALSE; */ - CString srcFileName = sSrcFileName; + std::wstring srcFileName = sSrcFileName; if (m_pCallbackArg) { if(!m_fCallbackExtract(m_pCallbackArg, srcFileName , localTempDir)) @@ -157,7 +157,7 @@ HRESULT CPPTXFile::LoadFromFile(BSTR sSrcFileName, BSTR sDstPath, BSTR sXMLOptio return S_OK; } -HRESULT CPPTXFile::SaveToFile(BSTR sDstFileName, BSTR sSrcPath, BSTR sXMLOptions) +HRESULT CPPTXFile::SaveToFile(std::wstring sDstFileName, std::wstring sSrcPath, std::wstring sXMLOptions) { if (NULL == m_pFolder) return S_FALSE; @@ -170,7 +170,7 @@ HRESULT CPPTXFile::SaveToFile(BSTR sDstFileName, BSTR sSrcPath, BSTR sXMLOptions CString dstFileName = sDstFileName; return m_fCallbackCompress ? (m_fCallbackCompress(m_pCallbackArg, srcFilePath, dstFileName) ? S_OK : S_FALSE) : S_OK; } -HRESULT CPPTXFile::get_TempDirectory(BSTR* pVal) +HRESULT CPPTXFile::get_TempDirectory(std::wstring* pVal) { #if defined(_WIN32) || defined (_WIN64) *pVal = m_strTempDir.AllocSysString(); @@ -179,7 +179,7 @@ HRESULT CPPTXFile::get_TempDirectory(BSTR* pVal) #endif return S_OK; } -HRESULT CPPTXFile::put_TempDirectory(BSTR newVal) +HRESULT CPPTXFile::put_TempDirectory(std::wstring newVal) { CStringW TempStr(newVal); @@ -201,15 +201,15 @@ HRESULT CPPTXFile::put_TempDirectory(BSTR newVal) #endif return S_FALSE; } -HRESULT CPPTXFile::GetDVDXml(BSTR* pbstrPTTXml) +HRESULT CPPTXFile::GetDVDXml(std::wstring* pbstrPTTXml) { return S_OK; } -HRESULT CPPTXFile::GetBluRayXml(BSTR* pbstrDVDXml) +HRESULT CPPTXFile::GetBluRayXml(std::wstring* pbstrDVDXml) { return S_OK; } -HRESULT CPPTXFile::get_DrawingXml(BSTR* pVal) +HRESULT CPPTXFile::get_DrawingXml(std::wstring* pVal) { if ((NULL == m_pFolder) || (NULL == pVal)) return S_FALSE; @@ -217,7 +217,7 @@ HRESULT CPPTXFile::get_DrawingXml(BSTR* pVal) return S_OK; } -HRESULT CPPTXFile::SetAdditionalParam(BSTR ParamName, VARIANT ParamValue) +HRESULT CPPTXFile::SetAdditionalParam(std::wstring ParamName, VARIANT ParamValue) { CString sParamName; sParamName = ParamName; if (_T("EmbeddedFontsDirectory") == sParamName && ParamValue.vt == VT_BSTR) @@ -228,7 +228,7 @@ HRESULT CPPTXFile::SetAdditionalParam(BSTR ParamName, VARIANT ParamValue) return S_OK; } -HRESULT CPPTXFile::GetAdditionalParam(BSTR ParamName, VARIANT* ParamValue) +HRESULT CPPTXFile::GetAdditionalParam(std::wstring ParamName, VARIANT* ParamValue) { if (NULL == ParamValue) return S_FALSE; @@ -249,17 +249,17 @@ bool CPPTXFile::Progress(long ID, long Percent) } // to PPTY -HRESULT CPPTXFile::SetMediaDir(BSTR bsMediaDir) +HRESULT CPPTXFile::SetMediaDir(std::wstring bsMediaDir) { m_strMediaDirectory = bsMediaDir; return S_OK; } -HRESULT CPPTXFile::SetFontDir(BSTR bsFontDir) +HRESULT CPPTXFile::SetFontDir(std::wstring bsFontDir) { m_strFontDirectory = bsFontDir; return S_OK; } -HRESULT CPPTXFile::SetThemesDir(BSTR bsDir) +HRESULT CPPTXFile::SetThemesDir(std::wstring bsDir) { m_strFolderThemes = bsDir; return S_OK; @@ -269,7 +269,7 @@ HRESULT CPPTXFile::SetUseSystemFonts(VARIANT_BOOL useSystemFonts) m_bIsUseSystemFonts = (VARIANT_TRUE == useSystemFonts); return S_OK; } -HRESULT CPPTXFile::OpenFileToPPTY(BSTR bsInput, BSTR bsOutput) +HRESULT CPPTXFile::OpenFileToPPTY(std::wstring bsInput, std::wstring bsOutput) { if (m_strTempDir.GetLength() < 1) { @@ -298,25 +298,16 @@ HRESULT CPPTXFile::OpenFileToPPTY(BSTR bsInput, BSTR bsOutput) pathLocalInputTemp = bsInput; notDeleteInput = true; } - BSTR bsLocalInputTemp; - -#if defined(_WIN32) || defined (_WIN64) - bsLocalInputTemp= pathLocalInputTemp.GetPath().AllocSysString(); -#else - bsLocalInputTemp= pathLocalInputTemp.GetPath(); -#endif + std::wstring bsLocalInputTemp= pathLocalInputTemp.GetPath(); HRESULT hr = OpenDirectoryToPPTY(bsLocalInputTemp, bsOutput); if (notDeleteInput == false) FileSystem::Directory::DeleteDirectory(pathLocalInputTemp.GetPath()); -#if defined(_WIN32) || defined (_WIN64) - if (bsLocalInputTemp)SysFreeString(bsLocalInputTemp); -#endif return hr; } -HRESULT CPPTXFile::OpenDirectoryToPPTY(BSTR bsInput, BSTR bsOutput) +HRESULT CPPTXFile::OpenDirectoryToPPTY(std::wstring bsInput, std::wstring bsOutput) { OOX::CPath pathInputDirectory = bsInput; @@ -376,7 +367,7 @@ HRESULT CPPTXFile::OpenDirectoryToPPTY(BSTR bsInput, BSTR bsOutput) return S_OK; } -HRESULT CPPTXFile::ConvertPPTYToPPTX(BSTR bsInput, BSTR bsOutput, BSTR bsThemesFolder)//bsOutput и файл и директория может быть +HRESULT CPPTXFile::ConvertPPTYToPPTX(std::wstring bsInput, std::wstring bsOutput, std::wstring bsThemesFolder)//bsOutput и файл и директория может быть { OOX::CPath pathLocalTempDirectory; diff --git a/ASCOfficePPTXFile/Editor/BinaryFileReaderWriter.cpp b/ASCOfficePPTXFile/Editor/BinaryFileReaderWriter.cpp index 841ae3b5fd..2548b2dc2d 100644 --- a/ASCOfficePPTXFile/Editor/BinaryFileReaderWriter.cpp +++ b/ASCOfficePPTXFile/Editor/BinaryFileReaderWriter.cpp @@ -304,7 +304,7 @@ namespace NSBinPptxRW CString strOleImageOut = pathOutputOle.GetPath(); if(!oleData.IsEmpty()) { - WriteOleData(string2std_string(strOleImageOut), string2std_string(oleData)); + WriteOleData(strOleImageOut, oleData); } else { @@ -325,15 +325,15 @@ namespace NSBinPptxRW void CImageManager2::SaveImageAsPng(const CString& strFileSrc, const CString& strFileDst) { CBgraFrame oBgraFrame; - if(oBgraFrame.OpenFile(string2std_string(strFileSrc))) - oBgraFrame.SaveFile(string2std_string(strFileDst), _CXIMAGE_FORMAT_PNG); + if(oBgraFrame.OpenFile(strFileSrc)) + oBgraFrame.SaveFile(strFileDst, _CXIMAGE_FORMAT_PNG); } void CImageManager2::SaveImageAsJPG(const CString& strFileSrc, const CString& strFileDst) { CBgraFrame oBgraFrame; - if(oBgraFrame.OpenFile(string2std_string(strFileSrc))) - oBgraFrame.SaveFile(string2std_string(strFileDst), _CXIMAGE_FORMAT_JPG); + if(oBgraFrame.OpenFile(strFileSrc)) + oBgraFrame.SaveFile(strFileDst, _CXIMAGE_FORMAT_JPG); } bool CImageManager2::IsNeedDownload(const CString& strFile) @@ -404,11 +404,11 @@ namespace NSBinPptxRW CString CImageManager2::DownloadImageExec(const CString& strFile) { #ifndef DISABLE_FILE_DOWNLOADER - CFileDownloader oDownloader(string2std_string(strFile), false); + CFileDownloader oDownloader(strFile, false); if ( oDownloader.DownloadSync() ) { - return std_string2string(oDownloader.GetFilePath()); + return oDownloader.GetFilePath(); } #endif return _T(""); @@ -1085,15 +1085,14 @@ namespace NSBinPptxRW } void CRelsGenerator::StartNote(int nIndexSlide) { - m_pWriter->WriteString(_T("")); - m_pWriter->WriteString(_T("")); + m_pWriter->WriteString(L""); + m_pWriter->WriteString(L""); - CString sNum = _T(""); - sNum.Format(_T("%d"), nIndexSlide + 1); - CString strNoteSlideRels = _T(""); + std::wstring sNum = std::to_wstring(nIndexSlide + 1); + std::wstring strNoteSlideRels = L""; m_pWriter->WriteString(strNoteSlideRels); - m_pWriter->WriteString(_T("")); + m_pWriter->WriteString(L""); m_lNextRelsID = 3; } diff --git a/ASCOfficePPTXFile/Editor/Converter.h b/ASCOfficePPTXFile/Editor/Converter.h index 41aac22025..ea27be3145 100644 --- a/ASCOfficePPTXFile/Editor/Converter.h +++ b/ASCOfficePPTXFile/Editor/Converter.h @@ -336,10 +336,10 @@ namespace PPTX2EditorAdvanced oBinaryWriter.StartRecord(NSMainTables::ImageMap); oBinaryWriter.WriteBYTE(NSBinPptxRW::g_nodeAttributeStart); - std::map* pIMaps = &oBinaryWriter.m_pCommon->m_pImageManager->m_mapImagesFile; + std::map* pIMaps = &oBinaryWriter.m_pCommon->m_pImageManager->m_mapImagesFile; LONG lIndexI = 0; - for (std::map::iterator pPair = pIMaps->begin(); pPair != pIMaps->end(); ++pPair) + for (std::map::iterator pPair = pIMaps->begin(); pPair != pIMaps->end(); ++pPair) { NSShapeImageGen::CImageInfo& oRec = pPair->second; oBinaryWriter.WriteString1(lIndexI++, oRec.GetPath2()); diff --git a/ASCOfficePPTXFile/Editor/Drawing/AudioOverlay.h b/ASCOfficePPTXFile/Editor/Drawing/AudioOverlay.h index 234642dcbc..74375cfcb7 100644 --- a/ASCOfficePPTXFile/Editor/Drawing/AudioOverlay.h +++ b/ASCOfficePPTXFile/Editor/Drawing/AudioOverlay.h @@ -283,7 +283,7 @@ namespace NSPresentationEditor //pPart->m_strFile.Replace(L"%20", L" "); } - CString strFile_ = std_string2string(pPart->m_strFile); + CString strFile_ = pPart->m_strFile; CorrectXmlString(strFile_); strOverlay2.Format(_T(""), diff --git a/ASCOfficePPTXFile/Editor/Drawing/Elements.h b/ASCOfficePPTXFile/Editor/Drawing/Elements.h index f541df1208..84d584145b 100644 --- a/ASCOfficePPTXFile/Editor/Drawing/Elements.h +++ b/ASCOfficePPTXFile/Editor/Drawing/Elements.h @@ -973,7 +973,7 @@ namespace NSPresentationEditor //m_strFileName.Replace(L"%20", L" "); } - CString strFileName = std_string2string(m_strAudioFileName); + std::wstring strFileName = m_strAudioFileName; CorrectXmlString(strFileName); CString source; @@ -1111,13 +1111,12 @@ namespace NSPresentationEditor /*m_strFileName.Replace('/', '\\');*/ } - CString strFileName = std_string2string(m_strVideoFileName); + std::wstring strFileName = m_strVideoFileName; CorrectXmlString(strFileName); CString element; - element.Format ( _T(""), + element.Format ( L"", (LONG)m_rcBounds.left, (LONG)m_rcBounds.top, (LONG)m_rcBounds.right, (LONG)m_rcBounds.bottom, m_dRotate, m_bLoop, m_oMetric.m_lMillimetresHor, m_oMetric.m_lMillimetresVer, strFileName, m_dClipStartTime, m_dClipEndTime ); @@ -1127,24 +1126,24 @@ namespace NSPresentationEditor { m_oAnimations.m_dSlideWidth = m_oMetric.m_lMillimetresHor; m_oAnimations.m_dSlideHeight = m_oMetric.m_lMillimetresVer; - animations = m_oAnimations.ToXml(m_dStartTime, m_dEndTime); + animations = m_oAnimations.ToXml(m_dStartTime, m_dEndTime); element += animations; } CString timeLine; - timeLine.Format ( _T(" "), m_dStartTime, m_dEndTime ); + timeLine.Format ( L" ", m_dStartTime, m_dEndTime ); element += timeLine; - element += _T(""); + element += L""; return element; } inline CString GetAudioStream () { - CString element = _T(""); - element.Format(_T(""), m_dStartTime, m_dEndTime - m_dStartTime, 100.0, m_bLoop); + CString element; + element.Format(L"", m_dStartTime, m_dEndTime - m_dStartTime, 100.0, m_bLoop); int lIndex = m_strVideoFileName.find(L"file:///"); if (0 == lIndex) @@ -1154,11 +1153,11 @@ namespace NSPresentationEditor //m_strFileName.Replace(L"%20", L" "); } - CString strFileName = std_string2string(m_strVideoFileName); + std::wstring strFileName = m_strVideoFileName; CorrectXmlString(strFileName); CString source; - source.Format(_T(""), m_dClipStartTime, m_dClipEndTime, strFileName); + source.Format(L"", m_dClipStartTime, m_dClipEndTime, strFileName); element += source; CString animations; @@ -1166,16 +1165,16 @@ namespace NSPresentationEditor { m_oAnimations.m_dSlideWidth = m_oMetric.m_lMillimetresHor; m_oAnimations.m_dSlideHeight = m_oMetric.m_lMillimetresVer; - animations = m_oAnimations.ToXml(m_dStartTime, m_dEndTime); + animations = m_oAnimations.ToXml(m_dStartTime, m_dEndTime); element += animations; } CString timeLine; - timeLine.Format ( _T(" "), m_dStartTime, m_dEndTime ); + timeLine.Format ( L" ", m_dStartTime, m_dEndTime ); element += timeLine; - element += _T(""); + element += L""; return element; } diff --git a/ASCOfficePPTXFile/Editor/Drawing/XmlStringWriter.h b/ASCOfficePPTXFile/Editor/Drawing/XmlStringWriter.h index 102b45abf6..efc5ddf3c6 100644 --- a/ASCOfficePPTXFile/Editor/Drawing/XmlStringWriter.h +++ b/ASCOfficePPTXFile/Editor/Drawing/XmlStringWriter.h @@ -162,18 +162,6 @@ namespace NSPresentationEditor size_t nLen = wString.length(); WriteString(wString.c_str(), nLen); } - AVSINLINE void WriteString(const CString & sString) - { - size_t nLen = (size_t)sString.GetLength(); - - #ifdef _UNICODE - CString str = sString; - WriteString(str.GetBuffer(), nLen); - #else - CStringW str = (CStringW)sString; - WriteString(str.GetBuffer(), nLen); - #endif - } AVSINLINE size_t GetCurSize() { diff --git a/ASCOfficePPTXFile/Editor/FontPicker.h b/ASCOfficePPTXFile/Editor/FontPicker.h index 13266ac1c0..51dca7eecf 100644 --- a/ASCOfficePPTXFile/Editor/FontPicker.h +++ b/ASCOfficePPTXFile/Editor/FontPicker.h @@ -73,7 +73,7 @@ namespace NSFontCutter if(strDir.IsEmpty()) m_oApplicationFonts.Initialize(); else - m_oApplicationFonts.InitializeFromFolder(string2std_string(strDir)); + m_oApplicationFonts.InitializeFromFolder(strDir); CFontList* pFontList = m_oApplicationFonts.GetList(); if(NULL != pFontList) { diff --git a/ASCOfficePPTXFile/Editor/PPTXWriter.h b/ASCOfficePPTXFile/Editor/PPTXWriter.h index 8e884629d9..329b46e327 100644 --- a/ASCOfficePPTXFile/Editor/PPTXWriter.h +++ b/ASCOfficePPTXFile/Editor/PPTXWriter.h @@ -90,8 +90,8 @@ namespace NSBinPptxRW m_strDstFolder = strFolder; OOX::CPath pathPPT = m_strDstFolder + FILE_SEPARATOR_STR + _T("ppt"); - FileSystem::Directory::CreateDirectory(string2std_string(m_strDstFolder)); - FileSystem::Directory::CreateDirectory(string2std_string(m_strDstFolder), _T("docProps")); + FileSystem::Directory::CreateDirectory(m_strDstFolder); + FileSystem::Directory::CreateDirectory(m_strDstFolder, _T("docProps")); FileSystem::Directory::CreateDirectory(pathPPT.GetPath()); m_oImageManager.Clear(); @@ -755,7 +755,7 @@ namespace NSBinPptxRW // content types CStringWriter oContentTypes; - oContentTypes.WriteString(_T("\ + oContentTypes.WriteString(L"\ \ \ \ @@ -773,7 +773,7 @@ namespace NSBinPptxRW \ \ \ - ")); + "); // themes for (LONG i = 0; i < (LONG)m_arThemes.size(); ++i) diff --git a/ASCOfficePPTXFile/Editor/XmlWriter.h b/ASCOfficePPTXFile/Editor/XmlWriter.h index f4e7ad0481..2b31ce80ef 100644 --- a/ASCOfficePPTXFile/Editor/XmlWriter.h +++ b/ASCOfficePPTXFile/Editor/XmlWriter.h @@ -40,6 +40,8 @@ #include "../../Common/DocxFormat/Source/SystemUtility/File.h" #include "../../Common/DocxFormat/Source/Base/ASCString.h" +#include + namespace NSBinPptxRW { static std::wstring g_bstr_nodeopen = L"<"; @@ -138,60 +140,23 @@ namespace NSBinPptxRW m_pDataCur += nLen; m_lSizeCur += nLen; } - AVSINLINE void WriteString(std::wstring& wString) + AVSINLINE void WriteString(const std::wstring& wString) { size_t nLen = wString.length(); WriteString(wString.c_str(), nLen); } -#ifdef _WIN32 - AVSINLINE void WriteString(_bstr_t& bsString) - { - size_t nLen = bsString.length(); - WriteString(bsString.GetBSTR(), nLen); - } -#endif // #ifdef _WIN32 - AVSINLINE void WriteString(const CString& sString) - { - size_t nLen = (size_t)sString.GetLength(); - -#ifdef _UNICODE - CString* pString = const_cast(&sString); - WriteString(pString->GetBuffer(), nLen); - pString->ReleaseBuffer(); -#else - CStringW str = (CStringW)sString; - WriteString(str.GetBuffer(), nLen); - str.ReleaseBuffer(); -#endif - } - AVSINLINE void WriteStringXML(const CString& strValue) + AVSINLINE void WriteStringXML(const std::wstring& _strValue) { // можно ускорить (см. как сделано в шейпах) - CString s = strValue; - s.Replace(_T("&"), _T("&")); - s.Replace(_T("'"), _T("'")); - s.Replace(_T("<"), _T("<")); - s.Replace(_T(">"), _T(">")); - s.Replace(_T("\""), _T(""")); - WriteString(s); - } - AVSINLINE void WriteStringXML(const std::wstring & wString) - { - std::wstring buffer; - buffer.reserve(wString.size()); - for(size_t pos = 0; pos != wString.size(); ++pos) - { - switch(wString[pos]) - { - case '&': buffer.append(_T("&")); break; - case '\"': buffer.append(_T(""")); break; - case '\'': buffer.append(_T("'")); break; - case '<': buffer.append(_T("<")); break; - case '>': buffer.append(_T(">")); break; - default: buffer.append(&wString[pos], 1); break; - } - } - WriteString(buffer); + std::wstring strValue = _strValue; + + boost::algorithm::replace_all(strValue, L"&", L"&"); + boost::algorithm::replace_all(strValue, L"'", L"'"); + boost::algorithm::replace_all(strValue, L"<", L"<"); + boost::algorithm::replace_all(strValue, L">", L">"); + boost::algorithm::replace_all(strValue, L"\"", L"""); + + WriteString(strValue); } AVSINLINE size_t GetCurSize() { @@ -229,10 +194,9 @@ namespace NSBinPptxRW m_lSizeCur = 0; } - CString GetData() + std::wstring GetData() { - CString str(m_pData, (int)m_lSizeCur); - return str; + return std::wstring(m_pData, (int)m_lSizeCur); } AVSINLINE void AddCharNoCheck(const WCHAR& wc) @@ -304,10 +268,10 @@ namespace NSBinPptxRW LONG m_lObjectIdVML; LONG m_lObjectIdOle; - CString m_strStyleMain; - CString m_strAttributesMain; - CString m_strNodes; - CString m_strOleXlsx; + std::wstring m_strStyleMain; + std::wstring m_strAttributesMain; + std::wstring m_strNodes; + std::wstring m_strOleXlsx; IRenderer* m_pOOXToVMLRenderer; @@ -325,19 +289,15 @@ namespace NSBinPptxRW m_lObjectIdOle = 0; m_bIsUseOffice2007 = false; - m_strStyleMain = _T(""); - m_strAttributesMain = _T(""); - m_strNodes = _T(""); - m_strOleXlsx = _T(""); - m_pOOXToVMLRenderer = NULL; + m_pOOXToVMLRenderer = NULL; m_bIsTop = false; } ~CXmlWriter() { } - AVSINLINE CString GetXmlString() + AVSINLINE std::wstring GetXmlString() { return m_oWriter.GetData(); } @@ -351,44 +311,37 @@ namespace NSBinPptxRW } // write value - AVSINLINE void WriteString(const CString& strValue) + AVSINLINE void WriteString(const std::wstring& strValue) { m_oWriter.WriteString(strValue); } - AVSINLINE void WriteStringXML(CString strValue) + AVSINLINE void WriteStringXML(std::wstring strValue) { - // можно ускорить (см. как сделано в шейпах) - CString s = strValue; - s.Replace(L"&", L"&"); - s.Replace(L"'", L"'"); - s.Replace(L"<", L"<"); - s.Replace(L">", L">"); - s.Replace(L"\"", L"""); + std::wstring s = strValue; + boost::algorithm::replace_all( s, L"&", L"&"); + boost::algorithm::replace_all( s, L"'", L"'"); + boost::algorithm::replace_all( s, L"<", L"<"); + boost::algorithm::replace_all( s, L">", L">"); + boost::algorithm::replace_all( s, L"\"", L"""); m_oWriter.WriteString(s); } AVSINLINE void WriteDouble(const double& val) { - CString str; - str.Format(L"%lf", val); - m_oWriter.WriteString(str); + m_oWriter.WriteString(std::to_wstring(val)); } AVSINLINE void WriteLONG(const long& val) { - CString str; - str.Format(L"%d", val); - m_oWriter.WriteString(str); + m_oWriter.WriteString(std::to_wstring(val)); + } AVSINLINE void WriteINT(const int& val) { - CString str; - str.Format(L"%d", val); - m_oWriter.WriteString(str); + m_oWriter.WriteString(std::to_wstring(val)); } AVSINLINE void WriteDWORD(const DWORD& val) { - CString str; - str.Format(L"%u", val); - m_oWriter.WriteString(str); + m_oWriter.WriteString(std::to_wstring(val)); + } AVSINLINE void WriteDWORD_hex(const DWORD& val) { @@ -404,7 +357,7 @@ namespace NSBinPptxRW m_oWriter.WriteString(g_bstr_boolean_false2); } // write attribute - AVSINLINE void WriteAttributeCSS(const CString& strAttributeName, const CString& val) + AVSINLINE void WriteAttributeCSS(const std::wstring& strAttributeName, const std::wstring& val) { m_oWriter.WriteString(strAttributeName); m_oWriter.AddSize(15); @@ -412,7 +365,7 @@ namespace NSBinPptxRW m_oWriter.WriteString(val); m_oWriter.AddCharNoCheck(WCHAR(';')); } - AVSINLINE void WriteAttributeCSS_int(const CString& strAttributeName, const int& val) + AVSINLINE void WriteAttributeCSS_int(const std::wstring& strAttributeName, const int& val) { m_oWriter.WriteString(strAttributeName); m_oWriter.AddSize(15); @@ -420,7 +373,7 @@ namespace NSBinPptxRW m_oWriter.AddIntNoCheck(val); m_oWriter.AddCharNoCheck(WCHAR(';')); } - AVSINLINE void WriteAttributeCSS_double1(const CString& strAttributeName, const double& val) + AVSINLINE void WriteAttributeCSS_double1(const std::wstring& strAttributeName, const double& val) { m_oWriter.WriteString(strAttributeName); m_oWriter.AddSize(15); @@ -430,7 +383,7 @@ namespace NSBinPptxRW m_oWriter.WriteString(s); m_oWriter.AddCharNoCheck(WCHAR(';')); } - AVSINLINE void WriteAttributeCSS_int_pt(const CString& strAttributeName, const int& val) + AVSINLINE void WriteAttributeCSS_int_pt(const std::wstring& strAttributeName, const int& val) { m_oWriter.WriteString(strAttributeName); m_oWriter.AddSize(15); @@ -440,7 +393,7 @@ namespace NSBinPptxRW m_oWriter.AddCharNoCheck(WCHAR('t')); m_oWriter.AddCharNoCheck(WCHAR(';')); } - AVSINLINE void WriteAttributeCSS_double1_pt(const CString& strAttributeName, const double& val) + AVSINLINE void WriteAttributeCSS_double1_pt(const std::wstring& strAttributeName, const double& val) { m_oWriter.WriteString(strAttributeName); m_oWriter.AddSize(20); @@ -453,7 +406,7 @@ namespace NSBinPptxRW m_oWriter.AddCharNoCheck(WCHAR(';')); } // - AVSINLINE void WriteAttribute(const CString& strAttributeName, const CString& val) + AVSINLINE void WriteAttribute(const std::wstring& strAttributeName, const std::wstring& val) { m_oWriter.WriteString(g_bstr_node_space); m_oWriter.WriteString(strAttributeName); @@ -462,7 +415,7 @@ namespace NSBinPptxRW m_oWriter.WriteString(val); m_oWriter.WriteString(g_bstr_node_quote); } - AVSINLINE void WriteAttribute2(const CString& strAttributeName, const CString& val) + AVSINLINE void WriteAttribute2(const std::wstring& strAttributeName, const std::wstring& val) { m_oWriter.WriteString(g_bstr_node_space); m_oWriter.WriteString(strAttributeName); @@ -471,7 +424,7 @@ namespace NSBinPptxRW m_oWriter.WriteStringXML(val); m_oWriter.WriteString(g_bstr_node_quote); } - AVSINLINE void WriteAttribute(const CString& strAttributeName, const double& val) + AVSINLINE void WriteAttribute(const std::wstring& strAttributeName, const double& val) { m_oWriter.WriteString(g_bstr_node_space); m_oWriter.WriteString(strAttributeName); @@ -480,7 +433,7 @@ namespace NSBinPptxRW WriteDouble(val); m_oWriter.WriteString(g_bstr_node_quote); } - AVSINLINE void WriteAttribute(const CString& strAttributeName, const int& val) + AVSINLINE void WriteAttribute(const std::wstring& strAttributeName, const int& val) { m_oWriter.WriteString(g_bstr_node_space); m_oWriter.WriteString(strAttributeName); @@ -489,7 +442,7 @@ namespace NSBinPptxRW WriteINT(val); m_oWriter.WriteString(g_bstr_node_quote); } - AVSINLINE void WriteAttribute(const CString& strAttributeName, const bool& val) + AVSINLINE void WriteAttribute(const std::wstring& strAttributeName, const bool& val) { m_oWriter.WriteString(g_bstr_node_space); m_oWriter.WriteString(strAttributeName); @@ -498,7 +451,7 @@ namespace NSBinPptxRW WriteBool(val); m_oWriter.WriteString(g_bstr_node_quote); } - AVSINLINE void WriteAttribute(const CString& strAttributeName, const LONG& val) + AVSINLINE void WriteAttribute(const std::wstring& strAttributeName, const LONG& val) { m_oWriter.WriteString(g_bstr_node_space); m_oWriter.WriteString(strAttributeName); @@ -507,7 +460,7 @@ namespace NSBinPptxRW WriteLONG(val); m_oWriter.WriteString(g_bstr_node_quote); } - AVSINLINE void WriteAttribute(const CString& strAttributeName, const DWORD& val) + AVSINLINE void WriteAttribute(const std::wstring& strAttributeName, const DWORD& val) { m_oWriter.WriteString(g_bstr_node_space); m_oWriter.WriteString(strAttributeName); @@ -516,7 +469,7 @@ namespace NSBinPptxRW WriteDWORD(val); m_oWriter.WriteString(g_bstr_node_quote); } - AVSINLINE void WriteAttributeDWORD_hex(const CString& strAttributeName, const DWORD& val) + AVSINLINE void WriteAttributeDWORD_hex(const std::wstring& strAttributeName, const DWORD& val) { m_oWriter.WriteString(g_bstr_node_space); m_oWriter.WriteString(strAttributeName); @@ -526,7 +479,7 @@ namespace NSBinPptxRW m_oWriter.WriteString(g_bstr_node_quote); } // document methods - AVSINLINE void WriteNodeBegin(CString strNodeName, bool bAttributed = false) + AVSINLINE void WriteNodeBegin(std::wstring strNodeName, bool bAttributed = false) { m_oWriter.WriteString(g_bstr_nodeopen); m_oWriter.WriteString(strNodeName); @@ -534,7 +487,7 @@ namespace NSBinPptxRW if (!bAttributed) m_oWriter.WriteString(g_bstr_nodeclose); } - AVSINLINE void WriteNodeEnd(CString strNodeName, bool bEmptyNode = false, bool bEndNode = true) + AVSINLINE void WriteNodeEnd(std::wstring strNodeName, bool bEmptyNode = false, bool bEndNode = true) { if (bEmptyNode) { @@ -551,13 +504,13 @@ namespace NSBinPptxRW } } // write node values - AVSINLINE void WriteNodeValue(const CString& strNodeName, const CString& val) + AVSINLINE void WriteNodeValue(const std::wstring& strNodeName, const std::wstring& val) { WriteNodeBegin(strNodeName); WriteString(val); WriteNodeEnd(strNodeName); } - AVSINLINE void WriteNodeValue(const CString& strNodeName, const bool& val) + AVSINLINE void WriteNodeValue(const std::wstring& strNodeName, const bool& val) { WriteNodeBegin(strNodeName); @@ -568,45 +521,45 @@ namespace NSBinPptxRW WriteNodeEnd(strNodeName); } - AVSINLINE void WriteNodeValue(const CString& strNodeName, const double& val) + AVSINLINE void WriteNodeValue(const std::wstring& strNodeName, const double& val) { WriteNodeBegin(strNodeName); WriteDouble(val); WriteNodeEnd(strNodeName); } - AVSINLINE void WriteNodeValue(const CString& strNodeName, const LONG& val) + AVSINLINE void WriteNodeValue(const std::wstring& strNodeName, const LONG& val) { WriteNodeBegin(strNodeName); WriteLONG(val); WriteNodeEnd(strNodeName); } - AVSINLINE void WriteNodeValue(const CString& strNodeName, const int& val) + AVSINLINE void WriteNodeValue(const std::wstring& strNodeName, const int& val) { WriteNodeBegin(strNodeName); WriteINT(val); WriteNodeEnd(strNodeName); } - AVSINLINE void WriteNodeValue(const CString& strNodeName, const DWORD& val) + AVSINLINE void WriteNodeValue(const std::wstring& strNodeName, const DWORD& val) { WriteNodeBegin(strNodeName); WriteDWORD(val); WriteNodeEnd(strNodeName); } - AVSINLINE void WriteNodeValueDWORD_hex(const CString& strNodeName, const DWORD& val) + AVSINLINE void WriteNodeValueDWORD_hex(const std::wstring& strNodeName, const DWORD& val) { WriteNodeBegin(strNodeName); WriteDWORD_hex(val); WriteNodeEnd(strNodeName); } - bool SaveToFile(CString strFilePath, bool bEncodingToUTF8 = true, bool bIsClearNoAttack = true) + bool SaveToFile(std::wstring strFilePath, bool bEncodingToUTF8 = true, bool bIsClearNoAttack = true) { - CString strData = m_oWriter.GetData(); + std::wstring strData = m_oWriter.GetData(); if (!bEncodingToUTF8) { CFile oFile; oFile.CreateFile(strFilePath); - oFile.WriteFile((void*)strData.GetBuffer(), strData.GetLength()); + oFile.WriteFile((void*)strData.c_str(), strData.length()); oFile.CloseFile(); } else @@ -615,7 +568,7 @@ namespace NSBinPptxRW CFile oFile; oFile.CreateFile(strFilePath); - CString strHead = _T(""); + std::wstring strHead = _T(""); oFile.WriteStringUTF8(strHead); oFile.WriteStringUTF8(strData); oFile.CloseFile(); @@ -631,68 +584,68 @@ namespace NSBinPptxRW public: // ATTRIBUTES -------------------------------------------------------------------------- - AVSINLINE void WriteAttribute(const CString& strName, const nullable_int& value) + AVSINLINE void WriteAttribute(const std::wstring& strName, const nullable_int& value) { if (value.IsInit()) WriteAttribute(strName, *value); } - AVSINLINE void WriteAttribute(const CString& strName, const nullable_double& value) + AVSINLINE void WriteAttribute(const std::wstring& strName, const nullable_double& value) { if (value.IsInit()) WriteAttribute(strName, *value); } - AVSINLINE void WriteAttribute(const CString& strName, const nullable_string& value) + AVSINLINE void WriteAttribute(const std::wstring& strName, const nullable_string& value) { if (value.IsInit()) WriteAttribute(strName, *value); } - AVSINLINE void WriteAttribute2(const CString& strName, const nullable_string& value) + AVSINLINE void WriteAttribute2(const std::wstring& strName, const nullable_string& value) { if (value.IsInit()) WriteAttribute2(strName, *value); } - AVSINLINE void WriteAttribute(const CString& strName, const nullable_bool& value) + AVSINLINE void WriteAttribute(const std::wstring& strName, const nullable_bool& value) { if (value.IsInit()) WriteAttribute(strName, *value); } template - AVSINLINE void WriteAttribute(const CString& strName, const nullable_limit& value) + AVSINLINE void WriteAttribute(const std::wstring& strName, const nullable_limit& value) { if (value.IsInit()) WriteAttribute(strName, (*value).get()); } // ------------------------------------------------------------------------------------- // NODES ------------------------------------------------------------------------------- - AVSINLINE void WriteNodeValue(const CString& strName, const nullable_int& value) + AVSINLINE void WriteNodeValue(const std::wstring& strName, const nullable_int& value) { if (value.IsInit()) WriteNodeValue(strName, *value); } - AVSINLINE void WriteNodeValue(const CString& strName, const nullable_double& value) + AVSINLINE void WriteNodeValue(const std::wstring& strName, const nullable_double& value) { if (value.IsInit()) WriteNodeValue(strName, *value); } - AVSINLINE void WriteNodeValue(const CString& strName, const nullable_string& value) + AVSINLINE void WriteNodeValue(const std::wstring& strName, const nullable_string& value) { if (value.IsInit()) WriteNodeValue(strName, *value); } - AVSINLINE void WriteNodeValue(const CString& strName, const nullable_bool& value) + AVSINLINE void WriteNodeValue(const std::wstring& strName, const nullable_bool& value) { if (value.IsInit()) WriteNodeValue(strName, *value); } template - AVSINLINE void WriteNodeValue(const CString& strName, const nullable_limit& value) + AVSINLINE void WriteNodeValue(const std::wstring& strName, const nullable_limit& value) { if (value.IsInit()) WriteNodeValue(strName, (*value).get); } // ------------------------------------------------------------------------------------- // DOCUMENT ---------------------------------------------------------------------------- - AVSINLINE void StartNode(const CString& name) + AVSINLINE void StartNode(const std::wstring& name) { m_oWriter.WriteString(g_bstr_nodeopen); m_oWriter.WriteString(name); @@ -705,7 +658,7 @@ namespace NSBinPptxRW { m_oWriter.WriteString(g_bstr_nodeclose); } - AVSINLINE void EndNode(const CString& name) + AVSINLINE void EndNode(const std::wstring& name) { m_oWriter.WriteString(g_bstr_nodeopen_slash); m_oWriter.WriteString(name); @@ -713,7 +666,7 @@ namespace NSBinPptxRW } template - AVSINLINE void WriteArray(const CString& strName, const std::vector& arr) + AVSINLINE void WriteArray(const std::wstring& strName, const std::vector& arr) { size_t nCount = arr.size(); if (0 != nCount) @@ -744,12 +697,14 @@ namespace NSBinPptxRW } // ------------------------------------------------------------------------------------- - void ReplaceString(CString str1, CString str2) + void ReplaceString(std::wstring str1, std::wstring str2) { - // ужасная функция. вызывать ее не надо. не для этого класс писался. - CString sCur = m_oWriter.GetData(); - sCur.Replace(str1, str2); - ClearNoAttack(); + // ужасная функция. вызывать ее не надо. не для этого класс писался. .. получше .. но все равно не надо !!! + + std::wstring sCur = m_oWriter.GetData(); + boost::algorithm::replace_all(sCur, str1, str2); + + ClearNoAttack(); WriteString(sCur); } }; diff --git a/ASCOfficePPTXFile/Editor/imagemanager.h b/ASCOfficePPTXFile/Editor/imagemanager.h index 9fafc8c987..f79bdf494d 100644 --- a/ASCOfficePPTXFile/Editor/imagemanager.h +++ b/ASCOfficePPTXFile/Editor/imagemanager.h @@ -57,11 +57,13 @@ using namespace NSFontCutter; #include "../../HtmlRenderer/include/ASCSVGWriter.h" #include +#include + namespace NSShapeImageGen { const long c_nMaxImageSize = 2000; - static bool _CopyFile(CString strExists, CString strNew, LPVOID lpFunc, LPVOID lpData) + static bool _CopyFile(std::wstring strExists, std::wstring strNew, LPVOID lpFunc, LPVOID lpData) { //::DeleteFile(strNew); //return ::CopyFileEx(strExists, strNew, lpFunc, lpData, false, 0); @@ -82,16 +84,16 @@ namespace NSShapeImageGen { public: NSShapeImageGen::ImageType m_eType; - LONG m_lID; - bool m_bValid; - CString m_sName; + LONG m_lID; + bool m_bValid; + std::wstring m_sName; CImageInfo() { m_eType = itJPG; m_lID = -1; m_bValid = true; - m_sName = _T("image"); + m_sName = L"image"; } CImageInfo(const CImageInfo& oSrc) { @@ -108,7 +110,7 @@ namespace NSShapeImageGen } void SetNameModificator(NSShapeImageGen::ImageType eType, bool bOle) { - CString sPrefix = _T(""); + std::wstring sPrefix; int nRes = 0; if(itWMF == eType) nRes += 1; @@ -117,53 +119,47 @@ namespace NSShapeImageGen if(bOle) nRes += 4; if(0 != nRes) - m_sName.Format(_T("display%dimage"), nRes); + m_sName = L"display" + std::to_wstring(nRes) + L"image"; } - AVSINLINE CString GetPath2() + AVSINLINE std::wstring GetPath2() { - CString _strExt = _T("png"); + std::wstring _strExt = L"png"; switch (m_eType) { case itJPG: - _strExt = _T("jpg"); + _strExt = L"jpg"; break; case itWMF: - _strExt = _T("wmf"); + _strExt = L"wmf"; break; case itEMF: - _strExt = _T("emf"); + _strExt = L"emf"; break; case itSVG: - _strExt = _T("svg"); + _strExt = L"svg"; break; default: break; } - - CString strExt = _T(""); - strExt.Format(_T("%ls%d."), m_sName, m_lID); - strExt += _strExt; - return strExt; + return m_sName + std::to_wstring(m_lID) + L"." + _strExt; } - AVSINLINE CString GetPathWithoutExtension() + AVSINLINE std::wstring GetPathWithoutExtension() { - CString strFilename = _T(""); - strFilename.Format(_T("%ls%d"), m_sName, m_lID); - return strFilename; + return m_sName + std::to_wstring(m_lID); } }; class CImageManager { public: - std::map m_mapImagesFile; + std::map m_mapImagesFile; std::map m_mapImageData; std::vector m_listDrawings; std::list m_listImages; - CString m_strDstMedia; + std::wstring m_strDstMedia; LONG m_lMaxSizeImage; LONG m_lNextIDImage; @@ -187,7 +183,7 @@ namespace NSShapeImageGen AVSINLINE void NewDocument() { - m_strDstMedia = _T(""); + m_strDstMedia = L""; m_lMaxSizeImage = 1200; m_lNextIDImage = 0; @@ -208,7 +204,7 @@ namespace NSShapeImageGen int lCount = (int)m_mapImagesFile.size(); pWriter->WriteINT(lCount); - for (std::map::iterator pPair = m_mapImagesFile.begin(); pPair != m_mapImagesFile.end(); ++pPair) + for (std::map::iterator pPair = m_mapImagesFile.begin(); pPair != m_mapImagesFile.end(); ++pPair) { pWriter->WriteString(pPair->first); pWriter->WriteINT((int)(pPair->second.m_eType)); @@ -242,14 +238,14 @@ namespace NSShapeImageGen LONG lCount = pReader->GetLong(); for (LONG i = 0; i < lCount; ++i) { - CString sKey = pReader->GetString2(); + std::wstring sKey = pReader->GetString2(); CImageInfo oInfo; oInfo.m_eType = (NSShapeImageGen::ImageType)pReader->GetLong(); oInfo.m_lID = pReader->GetLong(); oInfo.m_bValid = pReader->GetBool(); - m_mapImagesFile.insert(std::pair(sKey, oInfo)); + m_mapImagesFile.insert(std::pair(sKey, oInfo)); } lCount = pReader->GetLong(); @@ -282,13 +278,13 @@ namespace NSShapeImageGen return GenerateImageID(punkImage, (std::max)(1.0, width), (std::max)(1.0, height)); } - CImageInfo WriteImage(const CString& strFile, const CString& strOleFile, double& x, double& y, double& width, double& height) + CImageInfo WriteImage(const std::wstring& strFile, const std::wstring& strOleFile, double& x, double& y, double& width, double& height) { bool bIsDownload = false; - int n1 = strFile.Find(_T("www")); - int n2 = strFile.Find(_T("http")); - int n3 = strFile.Find(_T("ftp")); - int n4 = strFile.Find(_T("https")); + int n1 = strFile.find (L"www"); + int n2 = strFile.find (L"http"); + int n3 = strFile.find (L"ftp"); + int n4 = strFile.find (L"https"); //если nI сранивать не с 0, то будут проблемы //потому что в инсталяции мы кладем файлы в /var/www... @@ -298,27 +294,28 @@ namespace NSShapeImageGen if (bIsDownload) { - CString strFile1 = strFile; - strFile1.Replace(_T("\\"), _T("/")); - strFile1.Replace(_T("http:/"), _T("http://")); - strFile1.Replace(_T("https:/"), _T("https://")); - strFile1.Replace(_T("ftp:/"), _T("ftp://")); + std::wstring strFile1 = strFile; + + boost::algorithm::replace_all(strFile1, L"\\", L"/"); + boost::algorithm::replace_all(strFile1, L"http:/", L"http://"); + boost::algorithm::replace_all(strFile1, L"https:/", L"https://"); + boost::algorithm::replace_all(strFile1, L"ftp:/", L"ftp://"); CImageInfo oInfo; - std::map::iterator pPair = m_mapImagesFile.find(strFile1); + std::map::iterator pPair = m_mapImagesFile.find(strFile1); if (pPair != m_mapImagesFile.end()) return pPair->second; - CString strDownload = _T(""); + std::wstring strDownload; #ifndef DISABLE_FILE_DOWNLOADER - CFileDownloader oDownloader(string2std_string(strFile1), true); + CFileDownloader oDownloader(strFile1, true); if (oDownloader.DownloadSync()) { - strDownload = std_string2string(oDownloader.GetFilePath()); + strDownload = oDownloader.GetFilePath(); } #endif @@ -336,20 +333,20 @@ namespace NSShapeImageGen oFile.CloseFile(); if (-1 == width && -1 == height) - return GenerateImageID(strFile, CString(L""), strOleFile, width, height); - return GenerateImageID(strFile, CString(L""), strOleFile, (std::max)(1.0, width), (std::max)(1.0, height)); + return GenerateImageID(strFile, L"", strOleFile, width, height); + return GenerateImageID(strFile, L"", strOleFile, (std::max)(1.0, width), (std::max)(1.0, height)); } void SetFontManager(CFontManager* pFontManager) { m_pFontManager = pFontManager; } protected: - inline void CopyFile(CString& strFileSrc, CString& strFileDst) + inline void CopyFile(std::wstring& strFileSrc, std::wstring& strFileDst) { _CopyFile(strFileSrc, strFileDst, NULL, NULL); } - bool CheckImageSimpleCopy(const CString& strFileSrc, CImageInfo& oInfo) + bool CheckImageSimpleCopy(const std::wstring& strFileSrc, CImageInfo& oInfo) { CFile oFile; HRESULT hr = oFile.OpenFile(strFileSrc); @@ -392,13 +389,13 @@ namespace NSShapeImageGen return false; } - void SaveImage(const CString& strFileSrc, CImageInfo& oInfo, LONG __width, LONG __height) + void SaveImage(const std::wstring& strFileSrc, CImageInfo& oInfo, LONG __width, LONG __height) { if (CheckImageSimpleCopy(strFileSrc, oInfo)) return; CBgraFrame oBgraFrame; - if (oBgraFrame.OpenFile(std::wstring(strFileSrc.GetString())) == true) + if (oBgraFrame.OpenFile(strFileSrc) == true) { SaveImage(oBgraFrame, oInfo, __width, __height); } @@ -407,7 +404,7 @@ namespace NSShapeImageGen //конвертация неудачная - берем оригинальный файл OOX::CPath pathOriginal = strFileSrc; - CString strSaveItem = oInfo.GetPathWithoutExtension(); + std::wstring strSaveItem = oInfo.GetPathWithoutExtension(); strSaveItem = m_strDstMedia + FILE_SEPARATOR_STR + strSaveItem + pathOriginal.GetExtention(); @@ -421,7 +418,7 @@ namespace NSShapeImageGen oInfo.m_eType = GetImageType(oBgraFrame); - CString strSaveItem = _T(""); + std::wstring strSaveItem = L""; unsigned int nOutputFormat; if (itJPG == oInfo.m_eType) { @@ -495,15 +492,15 @@ namespace NSShapeImageGen return oInfo; } - CImageInfo GenerateImageID(const CString& strFileName, const CString & strUrl, const CString& strOleFile, double dWidth, double dHeight) + CImageInfo GenerateImageID(const std::wstring& strFileName, const std::wstring & strUrl, const std::wstring& strOleFile, double dWidth, double dHeight) { - CString sMapKey = strFileName; - if(!strUrl.IsEmpty()) - sMapKey = strUrl; - if(!strOleFile.IsEmpty()) - sMapKey += strOleFile; + std::wstring sMapKey = strFileName; + + if(!strUrl.empty()) sMapKey = strUrl; + if(!strOleFile.empty()) sMapKey += strOleFile; + CImageInfo oInfo; - std::map::iterator pPair = m_mapImagesFile.find(sMapKey); + std::map::iterator pPair = m_mapImagesFile.find(sMapKey); LONG lWidth = (LONG)(dWidth * 96 / 25.4); LONG lHeight = (LONG)(dHeight * 96 / 25.4); @@ -515,29 +512,29 @@ namespace NSShapeImageGen LONG lImageType = m_oImageExt.GetImageType(strFileName); bool bVector = (1 == lImageType || 2 == lImageType); - bool bOle = !strOleFile.IsEmpty(); + bool bOle = !strOleFile.empty(); if(bVector) oInfo.m_eType = (1 == lImageType) ? itWMF : itEMF; oInfo.SetNameModificator(oInfo.m_eType, bOle); std::wstring strSaveDir = m_strDstMedia + FILE_SEPARATOR_STR; - std::wstring strSaveItemWE = strSaveDir + string2std_string(oInfo.GetPathWithoutExtension()); + std::wstring strSaveItemWE = strSaveDir + std::wstring(oInfo.GetPathWithoutExtension()); //copy ole bin if(bOle) { - CString sCopyOlePath = std_string2string(strSaveItemWE) + _T(".bin"); + std::wstring sCopyOlePath = strSaveItemWE + L".bin"; CDirectory::CopyFile(strOleFile, sCopyOlePath, NULL, NULL); } if (bVector) { //copy source vector image - OOX::CPath pathSaveItem = std_string2string(strSaveDir) + oInfo.GetPath2(); + OOX::CPath pathSaveItem = strSaveDir + oInfo.GetPath2(); CDirectory::CopyFile(strFileName, pathSaveItem.GetPath(), NULL, NULL); ::MetaFile::CMetaFile oMetafile(m_pFontManager->m_pApplication); - if (oMetafile.LoadFromFile(strFileName)) + if (oMetafile.LoadFromFile(strFileName.c_str())) { double x = 0, y = 0, w = 0, h = 0; oMetafile.GetBounds(&x, &y, &w, &h); @@ -578,7 +575,7 @@ namespace NSShapeImageGen } } - std::wstring strSaveItem = strSaveItemWE + _T(".png"); + std::wstring strSaveItem = strSaveItemWE + L".png"; oMetafile.ConvertToRaster(strSaveItem.c_str(), 4 /*CXIMAGE_FORMAT_PNG*/, lWidth, lHeight); bool bIsSuccess = NSFile::CFileBinary::Exists(strSaveItem); @@ -586,7 +583,7 @@ namespace NSShapeImageGen { oInfo.m_eType = itPNG; - m_mapImagesFile.insert(std::pair(sMapKey, oInfo)); + m_mapImagesFile.insert(std::pair(sMapKey, oInfo)); m_listImages.push_back(oInfo); return oInfo; } @@ -595,8 +592,8 @@ namespace NSShapeImageGen { oInfo.m_eType = itSVG; - oWriterSVG.SaveFile(strSaveItemWE + _T(".svg")); - m_mapImagesFile.insert(std::pair(sMapKey, oInfo)); + oWriterSVG.SaveFile(strSaveItemWE + L".svg"); + m_mapImagesFile.insert(std::pair(sMapKey, oInfo)); m_listImages.push_back(oInfo); return oInfo; } @@ -605,7 +602,7 @@ namespace NSShapeImageGen SaveImage(strFileName, oInfo, lWidth, lHeight); - m_mapImagesFile.insert(std::pair(sMapKey, oInfo)); + m_mapImagesFile.insert(std::pair(sMapKey, oInfo)); m_listImages.push_back(oInfo); } else diff --git a/ASCOfficePPTXFile/PPTXFormat/DocxFormat/ContentTypes/File.h b/ASCOfficePPTXFile/PPTXFormat/DocxFormat/ContentTypes/File.h index 90b4ad3643..e945151c61 100644 --- a/ASCOfficePPTXFile/PPTXFormat/DocxFormat/ContentTypes/File.h +++ b/ASCOfficePPTXFile/PPTXFormat/DocxFormat/ContentTypes/File.h @@ -42,7 +42,7 @@ namespace PPTX { namespace ContentTypes { - static const OOX::CPath s_filename (_T("[Content_Types].xml")); + static const OOX::CPath s_filename (L"[Content_Types].xml"); class File { diff --git a/ASCOfficePPTXFile/PPTXFormat/DocxFormat/Drawing/LegacyDiagramText.h b/ASCOfficePPTXFile/PPTXFormat/DocxFormat/Drawing/LegacyDiagramText.h index 9fa49f69d4..493dd8b773 100644 --- a/ASCOfficePPTXFile/PPTXFormat/DocxFormat/Drawing/LegacyDiagramText.h +++ b/ASCOfficePPTXFile/PPTXFormat/DocxFormat/Drawing/LegacyDiagramText.h @@ -194,7 +194,7 @@ namespace PPTX { std::string strAnsi = std::string((char*)m_Data+pos, rec.RecLen); std::wstring strUnicode(strAnsi.begin(), strAnsi.end()); - m_Text = std_string2string(strUnicode); + m_Text = strUnicode; }break; case 0x0FA1: //StyleTextPropAtom { diff --git a/ASCOfficePPTXFile/PPTXFormat/DocxFormat/Rels/RelationShip.h b/ASCOfficePPTXFile/PPTXFormat/DocxFormat/Rels/RelationShip.h index 6c0630f280..edd39476d0 100644 --- a/ASCOfficePPTXFile/PPTXFormat/DocxFormat/Rels/RelationShip.h +++ b/ASCOfficePPTXFile/PPTXFormat/DocxFormat/Rels/RelationShip.h @@ -37,6 +37,8 @@ #include "./../RId.h" #include "./../External/External.h" +#include + namespace PPTX { namespace Rels @@ -46,7 +48,7 @@ namespace PPTX public: RelationShip(const PPTX::RId& rId, const CString& type, const OOX::CPath& filename) : m_rId(rId), m_target(filename), m_type(type) { - m_target.m_strFilename.Replace(_T(" "), _T("_")); + boost::algorithm::replace_all(m_target.m_strFilename, L" ", L"_"); } RelationShip(const PPTX::RId& rId, const smart_ptr external): m_rId(rId), m_target(external->Uri()), m_type(external->type().RelationType()) diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/Fills/BlipFill.h b/ASCOfficePPTXFile/PPTXFormat/Logic/Fills/BlipFill.h index 4ea7288347..cb360e8531 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/Fills/BlipFill.h +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/Fills/BlipFill.h @@ -351,7 +351,7 @@ namespace PPTX if (sImageExtension.GetLength() < 1) { CImageFileFormatChecker checker; - sImageExtension = std_string2string(checker.DetectFormatByData(pDstBuffer, dstLen)); + sImageExtension = checker.DetectFormatByData(pDstBuffer, dstLen); } //папки media может не быть в случае, когда все картинки base64(поскольку файл временный, папку media не создаем) CString tempFilePath = pReader->m_strFolder + FILE_SEPARATOR_STR; diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/Pic.cpp b/ASCOfficePPTXFile/PPTXFormat/Logic/Pic.cpp index e606ce49b7..06a1ca34f2 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/Pic.cpp +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/Pic.cpp @@ -145,7 +145,7 @@ namespace PPTX } if(!sFilePath.IsEmpty()) { - sData = GetOleData(string2std_string(sFilePath)); + sData = GetOleData(sFilePath); } } @@ -664,10 +664,10 @@ namespace PPTX pWriter->WriteAttribute(_T("path"), strPath); } - if (pWriter->m_strAttributesMain) + if (!pWriter->m_strAttributesMain.empty()) { pWriter->WriteString(pWriter->m_strAttributesMain); - pWriter->m_strAttributesMain = _T(""); + pWriter->m_strAttributesMain.clear(); } if(bOle) { @@ -764,7 +764,7 @@ namespace PPTX oleObject->m_sObjectId = strObjectid; if (XMLWRITER_DOC_TYPE_XLSX == pWriter->m_lDocType) { - oleObject->m_sShapeId = std_string2string(std::to_wstring(nShapeId)); + oleObject->m_sShapeId = std::to_wstring(nShapeId); NSBinPptxRW::CXmlWriter oTempWriter; oleObject->toXmlWriterXlsx(&oTempWriter); pWriter->m_strOleXlsx = oTempWriter.GetXmlString(); diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/Shape.cpp b/ASCOfficePPTXFile/PPTXFormat/Logic/Shape.cpp index dc9aeab9be..8e0c73c2bf 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/Shape.cpp +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/Shape.cpp @@ -499,10 +499,10 @@ namespace PPTX pWriter->WriteAttribute(_T("path"), strPath); } - if (pWriter->m_strAttributesMain) + if (!pWriter->m_strAttributesMain.empty()) { pWriter->WriteString(pWriter->m_strAttributesMain); - pWriter->m_strAttributesMain = _T(""); + pWriter->m_strAttributesMain.clear(); } pWriter->WriteString(strFillAttr); @@ -623,10 +623,10 @@ namespace PPTX pWriter->WriteAttribute(_T("path"), strPath); } - if (pWriter->m_strAttributesMain) + if (!pWriter->m_strAttributesMain.empty()) { pWriter->WriteString(pWriter->m_strAttributesMain); - pWriter->m_strAttributesMain = _T(""); + pWriter->m_strAttributesMain.clear(); } pWriter->WriteString(strFillAttr); diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/SmartArt.cpp b/ASCOfficePPTXFile/PPTXFormat/Logic/SmartArt.cpp index 200ad2bbb3..17730d07fb 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/SmartArt.cpp +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/SmartArt.cpp @@ -140,9 +140,10 @@ namespace PPTX OOX::CPath pathDiagramData = strDataPath; - int a1 = pathDiagramData.GetFilename().Find(_T(".")); - CString strId = pathDiagramData.GetFilename().Mid(4,pathDiagramData.GetFilename().GetLength() - 8); - OOX::CPath pathDiagramDrawing = pathDiagramData.GetDirectory() + FILE_SEPARATOR_STR + _T("drawing") + strId + _T(".xml"); + int a1 = pathDiagramData.GetFilename().find(L"."); + std::wstring strId = pathDiagramData.GetFilename().substr(4,pathDiagramData.GetFilename().length() - 8); + + OOX::CPath pathDiagramDrawing = pathDiagramData.GetDirectory() + FILE_SEPARATOR_STR + L"drawing" + strId + L".xml"; XmlUtils::CXmlNode oNodeDW; if (oNodeDW.FromXmlFile2(pathDiagramDrawing.GetPath()))//todooo ... сделать отдельно .. повтор diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/SpTree.cpp b/ASCOfficePPTXFile/PPTXFormat/Logic/SpTree.cpp index fe9f2f4cda..a5b5fab14b 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/SpTree.cpp +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/SpTree.cpp @@ -145,10 +145,10 @@ namespace PPTX pWriter->WriteAttribute(_T("style"), oStylesWriter.GetXmlString()); } - if (pWriter->m_strAttributesMain) + if (!pWriter->m_strAttributesMain.empty()) { pWriter->WriteString(pWriter->m_strAttributesMain); - pWriter->m_strAttributesMain = _T(""); + pWriter->m_strAttributesMain.clear(); } int dL = 0; diff --git a/ASCOfficePPTXFile/PPTXFormat/Logic/UniFill.h b/ASCOfficePPTXFile/PPTXFormat/Logic/UniFill.h index de24913516..c32428ce95 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Logic/UniFill.h +++ b/ASCOfficePPTXFile/PPTXFormat/Logic/UniFill.h @@ -346,7 +346,7 @@ namespace PPTX if (sImageExtension.GetLength() < 1) { CImageFileFormatChecker checker; - sImageExtension = std_string2string(checker.DetectFormatByData(pDstBuffer, dstLen)); + sImageExtension = checker.DetectFormatByData(pDstBuffer, dstLen); } //папки media может не быть в случае, когда все картинки base64(поскольку файл временный, папку media не создаем) CString tempFilePath = pReader->m_strFolder + FILE_SEPARATOR_STR; diff --git a/ASCOfficePPTXFile/PPTXLib/Linux/PPTXFormatLib/PPTXFormatLib.pro b/ASCOfficePPTXFile/PPTXLib/Linux/PPTXFormatLib/PPTXFormatLib.pro index 79e449fe6c..18cef9af55 100644 --- a/ASCOfficePPTXFile/PPTXLib/Linux/PPTXFormatLib/PPTXFormatLib.pro +++ b/ASCOfficePPTXFile/PPTXLib/Linux/PPTXFormatLib/PPTXFormatLib.pro @@ -61,7 +61,6 @@ SOURCES += \ SOURCES += \ ../../../ASCOfficeDrawingConverter.cpp \ ../../../ASCOfficePPTXFileRealization.cpp \ - ../../../../Common/DocxFormat/Source/XML/stringcommon.cpp \ ../../../PPTXFormat/DocxFormat/IFileContainer.cpp \ ../../../PPTXFormat/Logic/Colors/SchemeClr.cpp \ ../../../PPTXFormat/Logic/Fills/Blip.cpp \ @@ -110,9 +109,8 @@ SOURCES += \ } HEADERS += pptxformatlib.h \ -../../../ASCOfficeDrawingConverter.h \ -../../../ASCOfficePPTXFile.h \ -../../../../Common/DocxFormat/Source/XML/stringcommon.h \ + ../../../ASCOfficeDrawingConverter.h \ + ../../../ASCOfficePPTXFile.h \ ../../../PPTXFormat/DocxFormat/ContentTypes/Default.h \ ../../../PPTXFormat/DocxFormat/ContentTypes/DefaultTable.h \ ../../../PPTXFormat/DocxFormat/ContentTypes/ExtensionTable.h \ diff --git a/ASCOfficePPTXFile/PPTXLib/Linux/PPTXFormatLib/pptxformatlib_converter.cpp b/ASCOfficePPTXFile/PPTXLib/Linux/PPTXFormatLib/pptxformatlib_converter.cpp index 769f429b64..7b475b989b 100644 --- a/ASCOfficePPTXFile/PPTXLib/Linux/PPTXFormatLib/pptxformatlib_converter.cpp +++ b/ASCOfficePPTXFile/PPTXLib/Linux/PPTXFormatLib/pptxformatlib_converter.cpp @@ -29,11 +29,7 @@ * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode * */ -//#include "../../../../Common/DocxFormat/Source/XML/stringcommon.cpp" // docxformat.lib #include "../../../Editor/FontPicker.cpp" -//#include "../../../Editor/Drawing/Layout.cpp" -//#include "../../../Editor/Drawing/TextAttributesEx.cpp" -//#include "../../../Editor/Drawing/Elements.cpp" // pptformat.lib #include "../../../../HtmlRenderer/src/ASCSVGWriter.cpp" #include "../../../ASCOfficeDrawingConverter.cpp" #include "../../../ASCOfficePPTXFileRealization.cpp" diff --git a/ASCOfficePPTXFile/PPTXLib/PPTXFormat.vcproj b/ASCOfficePPTXFile/PPTXLib/PPTXFormat.vcproj index 3250983120..42cff27d94 100644 --- a/ASCOfficePPTXFile/PPTXLib/PPTXFormat.vcproj +++ b/ASCOfficePPTXFile/PPTXLib/PPTXFormat.vcproj @@ -351,10 +351,6 @@ /> - - m_oDate.IsInit()) { - std::wstring sVal = string2std_string(pIns->m_oDate->GetValue()); + std::wstring sVal = pIns->m_oDate->GetValue(); m_oCharProperty.m_nRevdttm = RtfUtility::convertDateTime( sVal ); } @@ -81,7 +81,7 @@ bool OOXMathReader::ParseElement(ReaderParameter oParam , OOX::WritingElement * if (pDel->m_oDate.IsInit()) { - std::wstring sVal = string2std_string(pDel->m_oDate->GetValue()); + std::wstring sVal = pDel->m_oDate->GetValue(); m_oCharProperty.m_nRevdttmDel = RtfUtility::convertDateTime( sVal ); } diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXParagraphElementReaders.cpp b/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXParagraphElementReaders.cpp index 8738628742..1eefd7f205 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXParagraphElementReaders.cpp +++ b/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXParagraphElementReaders.cpp @@ -137,7 +137,7 @@ bool OOXParagraphReader::Parse2( ReaderParameter oParam , RtfParagraph& oOutputP if (pIns->m_oDate.IsInit()) { - std::wstring sVal = string2std_string(pIns->m_oDate->GetValue()); + std::wstring sVal = pIns->m_oDate->GetValue(); oSubParReader.m_oCharProperty.m_nRevdttm = RtfUtility::convertDateTime( sVal ); } @@ -156,7 +156,7 @@ bool OOXParagraphReader::Parse2( ReaderParameter oParam , RtfParagraph& oOutputP if (pDel->m_oDate.IsInit()) { - std::wstring sVal = string2std_string(pDel->m_oDate->GetValue()); + std::wstring sVal = pDel->m_oDate->GetValue(); oSubParReader.m_oCharProperty.m_nRevdttmDel = RtfUtility::convertDateTime( sVal ); } @@ -1269,7 +1269,7 @@ bool OOXpPrReader::Parse( ReaderParameter oParam ,RtfParagraphProperty& oOutputP if (m_ooxParaProps->m_oPPrChange->m_oDate.IsInit()) { - std::wstring sVal = string2std_string(m_ooxParaProps->m_oPPrChange->m_oDate->GetValue()); + std::wstring sVal = m_ooxParaProps->m_oPPrChange->m_oDate->GetValue(); oOutputProperty.m_nPrDate = RtfUtility::convertDateTime( sVal ); } @@ -1498,7 +1498,7 @@ bool OOXrPrReader::Parse( ReaderParameter oParam ,RtfCharProperty& oOutputProper if (m_ooxRunProps->m_oIns->m_oDate.IsInit()) { - std::wstring sVal = string2std_string(m_ooxRunProps->m_oIns->m_oDate->GetValue()); + std::wstring sVal = m_ooxRunProps->m_oIns->m_oDate->GetValue(); oOutputProperty.m_nRevdttm = RtfUtility::convertDateTime( sVal ); } } @@ -1511,7 +1511,7 @@ bool OOXrPrReader::Parse( ReaderParameter oParam ,RtfCharProperty& oOutputProper if (m_ooxRunProps->m_oDel->m_oDate.IsInit()) { - std::wstring sVal = string2std_string(m_ooxRunProps->m_oDel->m_oDate->GetValue()); + std::wstring sVal = m_ooxRunProps->m_oDel->m_oDate->GetValue(); oOutputProperty.m_nRevdttmDel = RtfUtility::convertDateTime( sVal ); } } @@ -1523,7 +1523,7 @@ bool OOXrPrReader::Parse( ReaderParameter oParam ,RtfCharProperty& oOutputProper if (m_ooxRunProps->m_oRPrChange->m_oDate.IsInit()) { - std::wstring sVal = string2std_string(m_ooxRunProps->m_oRPrChange->m_oDate->GetValue()); + std::wstring sVal = m_ooxRunProps->m_oRPrChange->m_oDate->GetValue(); oOutputProperty.m_nCrDate = RtfUtility::convertDateTime( sVal ); } @@ -1974,7 +1974,7 @@ bool OOXSectionPropertyReader::Parse( ReaderParameter oParam , RtfSectionPropert if (m_ooxSectionProperty->m_oSectPrChange->m_oDate.IsInit()) { - std::wstring sVal = string2std_string(m_ooxSectionProperty->m_oSectPrChange->m_oDate->GetValue()); + std::wstring sVal = m_ooxSectionProperty->m_oSectPrChange->m_oDate->GetValue(); oOutput.m_nSrDate = RtfUtility::convertDateTime( sVal ); } diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXPictureGraphicReader.h b/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXPictureGraphicReader.h index de53566bf5..d5c0294108 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXPictureGraphicReader.h +++ b/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXPictureGraphicReader.h @@ -68,15 +68,15 @@ public: { //в туже папку что и исходная картинка CBgraFrame image; - if (image.OpenFile(string2std_string(sPath)) == FALSE ) return false; + if (image.OpenFile(sPath) == FALSE ) return false; //правильно выставляем размеры oOutput.m_nWidthGoal = image.get_Width(); oOutput.m_nHeightGoal = image.get_Height(); - CString sTargetFile = FileSystem::Directory::CreateTempFileWithUniqueName(ooxPath.GetDirectory(), L"img"); + std::wstring sTargetFile = FileSystem::Directory::CreateTempFileWithUniqueName(ooxPath.GetDirectory(), L"img"); - if (image.SaveFile(string2std_string(sTargetFile), 4 /*_CXIMAGE_FORMAT_PNG*/) ) + if (image.SaveFile(sTargetFile, 4 /*_CXIMAGE_FORMAT_PNG*/) ) { oOutput.eDataType = RtfPicture::dt_png; //Запоминаем имя @@ -142,7 +142,7 @@ public: int cxFormats [6] = {0, 4, 3, 10, 10, 10}; CBgraFrame image; - if (image.OpenFile(string2std_string(sPath), cxFormats[oOutput.eDataType]) == FALSE ) return false; + if (image.OpenFile(sPath, cxFormats[oOutput.eDataType]) == FALSE ) return false; //правильно выставляем размеры oOutput.m_nWidthGoal = image.get_Width(); oOutput.m_nHeightGoal = image.get_Height(); diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXReader.cpp b/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXReader.cpp index b63681fd1b..1a6a1d8f45 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXReader.cpp +++ b/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXReader.cpp @@ -42,7 +42,7 @@ OOXReader::OOXReader( RtfDocument& oDocument, std::wstring path ): m_oDocument(oDocument) { - m_sPath = std_string2string(path); + m_sPath = path; m_nCurItap = 0; m_convertationManager = NULL; diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXTableReader.cpp b/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXTableReader.cpp index 1d52aeb7a5..78512b73a2 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXTableReader.cpp +++ b/ASCOfficeRtfFile/RtfFormatLib/source/Reader/OOXTableReader.cpp @@ -103,7 +103,7 @@ bool OOXtrPrReader::Parse( ReaderParameter oParam , RtfRowProperty& oOutputPrope if (m_ooxTableRowProps->m_oTrPrChange->m_oDate.IsInit()) { - std::wstring sVal = string2std_string(m_ooxTableRowProps->m_oTrPrChange->m_oDate->GetValue()); + std::wstring sVal = m_ooxTableRowProps->m_oTrPrChange->m_oDate->GetValue(); oOutputProperty.m_nTrDate = RtfUtility::convertDateTime( sVal); } diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/RtfProperty.cpp b/ASCOfficeRtfFile/RtfFormatLib/source/RtfProperty.cpp index 433ff4bbc7..742fa0e55d 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/RtfProperty.cpp +++ b/ASCOfficeRtfFile/RtfFormatLib/source/RtfProperty.cpp @@ -1240,18 +1240,18 @@ CString RtfStyle::RenderToRtfEnd( RenderParameter oRenderParameter ) if( false == IsValid() ) return L""; CString sResult; - RENDER_RTF_INT( m_nBasedOn, sResult, L"sbasedon" ) - RENDER_RTF_INT( m_nNext, sResult, L"snext" ) - RENDER_RTF_BOOL( m_bHidden, sResult, L"shidden" ) - RENDER_RTF_INT( m_nLink, sResult, L"slink" ) - RENDER_RTF_BOOL( m_bLocked, sResult, L"slocked" ) - RENDER_RTF_BOOL( m_bPersonal, sResult, L"spersonal" ) - RENDER_RTF_BOOL( m_bCompose, sResult, L"scompose" ) - RENDER_RTF_BOOL( m_bReply, sResult, L"sreply" ) - RENDER_RTF_BOOL( m_nSemiHidden, sResult, L"ssemihidden" ) - RENDER_RTF_BOOL( m_bQFormat, sResult, L"sqformat" ) - RENDER_RTF_INT( m_nPriority, sResult, L"spriority" ) - RENDER_RTF_BOOL( m_bUnhiddenWhenUse, sResult, L"sunhideused" ) + RENDER_RTF_INT ( m_nBasedOn, sResult, L"sbasedon" ) + RENDER_RTF_INT ( m_nNext, sResult, L"snext" ) + RENDER_RTF_BOOL ( m_bHidden, sResult, L"shidden" ) + RENDER_RTF_INT ( m_nLink, sResult, L"slink" ) + RENDER_RTF_BOOL ( m_bLocked, sResult, L"slocked" ) + RENDER_RTF_BOOL ( m_bPersonal, sResult, L"spersonal" ) + RENDER_RTF_BOOL ( m_bCompose, sResult, L"scompose" ) + RENDER_RTF_BOOL ( m_bReply, sResult, L"sreply" ) + RENDER_RTF_BOOL ( m_nSemiHidden, sResult, L"ssemihidden" ) + RENDER_RTF_BOOL ( m_bQFormat, sResult, L"sqformat" ) + RENDER_RTF_INT ( m_nPriority, sResult, L"spriority" ) + RENDER_RTF_BOOL ( m_bUnhiddenWhenUse, sResult, L"sunhideused" ) sResult += L" " + RtfChar::renderRtfText( m_sName, oRenderParameter.poDocument ) + L";}"; return sResult; diff --git a/ASCOfficeRtfFile/RtfFormatLib/source/RtfWriter.h b/ASCOfficeRtfFile/RtfFormatLib/source/RtfWriter.h index ffc6adeb8b..6b6ba000e6 100644 --- a/ASCOfficeRtfFile/RtfFormatLib/source/RtfWriter.h +++ b/ASCOfficeRtfFile/RtfFormatLib/source/RtfWriter.h @@ -47,8 +47,8 @@ public: RtfWriter( RtfDocument& oDocument , std::wstring sFilename, std::wstring sFolder ):m_oDocument(oDocument) { - m_sFilename = std_string2string(sFilename); - m_sTempFolder = std_string2string(sFolder); + m_sFilename = sFilename; + m_sTempFolder = sFolder; m_bFirst = true; m_oCurTempFileWriter = NULL; m_oCurTempFileSectWriter = NULL; diff --git a/ASCOfficeTxtFile/TxtXmlFormatLib/Linux/TxtXmlFormatLib.pro b/ASCOfficeTxtFile/TxtXmlFormatLib/Linux/TxtXmlFormatLib.pro index b26974de0b..07e496a6c6 100644 --- a/ASCOfficeTxtFile/TxtXmlFormatLib/Linux/TxtXmlFormatLib.pro +++ b/ASCOfficeTxtFile/TxtXmlFormatLib/Linux/TxtXmlFormatLib.pro @@ -29,6 +29,9 @@ INCLUDEPATH += \ ../../../DesktopEditor/freetype-2.5.2/include \ ../../../DesktopEditor/xml/libxml2/include +#BOOST +include($$PWD/../../../Common/3dParty/boost/boost.pri) + HEADERS += \ ../Source/TxtXmlEvent.h \ ../Source/TxtXmlFile.h \ diff --git a/ASCOfficeTxtFile/TxtXmlFormatLib/Source/Common/Utility.h b/ASCOfficeTxtFile/TxtXmlFormatLib/Source/Common/Utility.h index 64d16f7e03..df1364c076 100644 --- a/ASCOfficeTxtFile/TxtXmlFormatLib/Source/Common/Utility.h +++ b/ASCOfficeTxtFile/TxtXmlFormatLib/Source/Common/Utility.h @@ -31,7 +31,6 @@ */ #pragma once -#include "../../../../Common/DocxFormat/Source/XML/stringcommon.h" #include "../Common/Encoding.h" #include diff --git a/ASCOfficeTxtFile/TxtXmlFormatLib/Source/ConvertDocx2Txt.cpp b/ASCOfficeTxtFile/TxtXmlFormatLib/Source/ConvertDocx2Txt.cpp index 07b5157935..77d787174f 100644 --- a/ASCOfficeTxtFile/TxtXmlFormatLib/Source/ConvertDocx2Txt.cpp +++ b/ASCOfficeTxtFile/TxtXmlFormatLib/Source/ConvertDocx2Txt.cpp @@ -110,7 +110,7 @@ namespace Docx2Txt void Converter::read(const std::wstring & path) { - bool res = converter_->m_inputFile.Read(std_string2string(path)); + bool res = converter_->m_inputFile.Read(path); return; } @@ -404,7 +404,7 @@ namespace Docx2Txt std::wstring strLevelText; if ((abstractNum->m_arrLvl[ind_level]->m_oLvlText.IsInit()) && (abstractNum->m_arrLvl[ind_level]->m_oLvlText->m_sVal.IsInit())) { - strLevelText = string2std_string(abstractNum->m_arrLvl[ind_level]->m_oLvlText->m_sVal.get()); + strLevelText = abstractNum->m_arrLvl[ind_level]->m_oLvlText->m_sVal.get(); } if (abstractNum->m_arrLvl[ind_level]->m_oNumFmt->m_oVal->GetValue() == SimpleTypes::numberformatBullet) @@ -481,7 +481,7 @@ namespace Docx2Txt else if (run->m_arrItems[j]->getType() == OOX::et_w_t) { OOX::Logic::CText* text = dynamic_cast(run->m_arrItems[j]); - wstr = string2std_string(text->m_sText); + wstr = text->m_sText; if(caps) { //std::locale loc; diff --git a/ASCOfficeTxtFile/TxtXmlFormatLib/Source/ConvertTxt2Docx.cpp b/ASCOfficeTxtFile/TxtXmlFormatLib/Source/ConvertTxt2Docx.cpp index 08e4473425..6e69573a44 100644 --- a/ASCOfficeTxtFile/TxtXmlFormatLib/Source/ConvertTxt2Docx.cpp +++ b/ASCOfficeTxtFile/TxtXmlFormatLib/Source/ConvertTxt2Docx.cpp @@ -49,7 +49,7 @@ namespace Txt2Docx static CString PrepareToXML( const std::wstring & sInput) { - CString sResult = std_string2string(sInput); + CString sResult = sInput; //& («&И), < («<И), > («>И), ' («'И), и " («"И) sResult.Replace(_T("&"), _T("&")); sResult.Replace(_T("<"), _T("<")); diff --git a/ASCOfficeTxtFile/TxtXmlFormatLib/Source/TxtFormat/TxtFile.cpp b/ASCOfficeTxtFile/TxtXmlFormatLib/Source/TxtFormat/TxtFile.cpp index 1873e9b70d..663e74f176 100644 --- a/ASCOfficeTxtFile/TxtXmlFormatLib/Source/TxtFormat/TxtFile.cpp +++ b/ASCOfficeTxtFile/TxtXmlFormatLib/Source/TxtFormat/TxtFile.cpp @@ -51,7 +51,7 @@ const std::list TxtFile::readAnsiOrCodePage() // == readUtf8without std::list result; CFile file_binary; - if (file_binary.OpenFile(std_string2string(m_path)) != S_OK) return result; + if (file_binary.OpenFile(m_path) != S_OK) return result; long file_size = file_binary.GetFileSize(); char *file_data = new char[file_size]; @@ -118,7 +118,7 @@ const std::list TxtFile::readUnicode() std::list result; CFile file_binary; - if (file_binary.OpenFile(std_string2string(m_path)) != S_OK) return result; + if (file_binary.OpenFile(m_path) != S_OK) return result; long file_size = file_binary.GetFileSize(); char *file_data = new char[file_size]; @@ -135,7 +135,7 @@ const std::list TxtFile::readBigEndian() std::list result; CFile file_binary; - if (file_binary.OpenFile(std_string2string(m_path)) != S_OK) return result; + if (file_binary.OpenFile(m_path) != S_OK) return result; long file_size = file_binary.GetFileSize(); char *file_data = new char[file_size]; @@ -160,7 +160,7 @@ const std::list TxtFile::readUtf8() std::list result; CFile file_binary; - if (file_binary.OpenFile(std_string2string(m_path)) != S_OK) return result; + if (file_binary.OpenFile(m_path) != S_OK) return result; long file_size = file_binary.GetFileSize(); char *file_data = new char[file_size]; @@ -198,7 +198,7 @@ const std::list TxtFile::readUtf8() void TxtFile::writeAnsiOrCodePage(const std::list& content) // === writeUtf8withoutPref также { CFile file; - if (file.CreateFile(std_string2string(m_path)) == S_OK) + if (file.CreateFile(m_path) == S_OK) { BYTE endLine[2] = {0x0d, 0x0a}; for (std::list::const_iterator iter = content.begin(); iter != content.end(); ++iter) @@ -214,7 +214,7 @@ void TxtFile::writeAnsiOrCodePage(const std::list& content) // === void TxtFile::writeUnicode(const std::list& content) { CFile file; - if (file.CreateFile(std_string2string(m_path)) == S_OK) + if (file.CreateFile(m_path) == S_OK) { BYTE Header[2] = {0xff, 0xfe}; BYTE EndLine[4] = {0x0d, 0x00, 0x0a, 0x00}; @@ -244,7 +244,7 @@ void TxtFile::writeUnicode(const std::list& content) void TxtFile::writeBigEndian(const std::list& content) { CFile file; - if (file.CreateFile(std_string2string(m_path)) == S_OK) + if (file.CreateFile(m_path) == S_OK) { BYTE Header[2] = {0xfe, 0xff}; BYTE EndLine[4] = {0x00, 0x0d, 0x00, 0x0a}; @@ -280,7 +280,7 @@ void TxtFile::writeBigEndian(const std::list& content) void TxtFile::writeUtf8(const std::list& content) { CFile file; - if (file.CreateFile(std_string2string(m_path)) == S_OK) + if (file.CreateFile(m_path) == S_OK) { BYTE Header[3] = {0xef ,0xbb , 0xbf}; BYTE EndLine[2] = {0x0d ,0x0a}; @@ -301,7 +301,7 @@ const bool TxtFile::isUnicode() { CFile file; - if (file.OpenFile(std_string2string(m_path)) != S_OK) return false; + if (file.OpenFile(m_path) != S_OK) return false; BYTE data [2]; file.ReadFile(data,2); @@ -316,7 +316,7 @@ const bool TxtFile::isBigEndian() { CFile file; - if (file.OpenFile(std_string2string(m_path)) != S_OK) return false; + if (file.OpenFile(m_path) != S_OK) return false; BYTE data [2]; file.ReadFile(data,2); @@ -331,7 +331,7 @@ const bool TxtFile::isUtf8() { CFile file; - if (file.OpenFile(std_string2string(m_path)) != S_OK) return false; + if (file.OpenFile(m_path) != S_OK) return false; BYTE data [3]; file.ReadFile(data,3); diff --git a/ASCOfficeTxtFile/TxtXmlFormatLib/Source/TxtXmlFile.cpp b/ASCOfficeTxtFile/TxtXmlFormatLib/Source/TxtXmlFile.cpp index 8acc0777f6..c8bbcd3dd9 100644 --- a/ASCOfficeTxtFile/TxtXmlFormatLib/Source/TxtXmlFile.cpp +++ b/ASCOfficeTxtFile/TxtXmlFormatLib/Source/TxtXmlFile.cpp @@ -93,7 +93,7 @@ static int ParseTxtOptions(const std::wstring & sXmlOptions) if (sName1 == _T("Encoding")) { CString strValue = xmlReader.GetText2(); - encoding = StlUtils::ToInteger(string2std_string(strValue)); + encoding = StlUtils::ToInteger(strValue); } } } @@ -112,10 +112,10 @@ HRESULT CTxtXmlFile::txt_LoadFromFile(const std::wstring & sSrcFileName, const s //As Text - Writers::FileWriter *pDocxWriter = new Writers::FileWriter(std_string2string(sDstPath), _T(""), true, 1, false, NULL, _T("")); + Writers::FileWriter *pDocxWriter = new Writers::FileWriter(sDstPath, L"", true, 1, false, NULL, L""); if (pDocxWriter == NULL) return S_FALSE; - CreateDocxEmpty(std_string2string(sDstPath), pDocxWriter); + CreateDocxEmpty(sDstPath, pDocxWriter); try { @@ -183,13 +183,13 @@ HRESULT CTxtXmlFile::txt_SaveToFile(const std::wstring & sDstFileName, const std void CTxtXmlFile::CreateDocxEmpty(const std::wstring & _strDirectory, Writers::FileWriter * pDocxWriter) { - CString strDirectory = std_string2string(_strDirectory); + CString strDirectory = _strDirectory; // rels - OOX::CPath pathRels = strDirectory + FILE_SEPARATOR_STR + _T("_rels"); + OOX::CPath pathRels = strDirectory + FILE_SEPARATOR_STR +L"_rels"; FileSystem::Directory::CreateDirectory(pathRels.GetPath()); // word - OOX::CPath pathWord = strDirectory + FILE_SEPARATOR_STR + _T("word"); + OOX::CPath pathWord = strDirectory + FILE_SEPARATOR_STR + L"word"; FileSystem::Directory::CreateDirectory(pathWord.GetPath()); // documentRels diff --git a/Common/DocxFormat/DocxFormatLib/DocxFormatLib.pro b/Common/DocxFormat/DocxFormatLib/DocxFormatLib.pro index 8adaa05da9..8d77718e0d 100644 --- a/Common/DocxFormat/DocxFormatLib/DocxFormatLib.pro +++ b/Common/DocxFormat/DocxFormatLib/DocxFormatLib.pro @@ -22,6 +22,9 @@ INCLUDEPATH += \ ../../../DesktopEditor/freetype-2.5.2/include \ ../../../DesktopEditor/xml/libxml2/include +#BOOST +include($$PWD/../../3dParty/boost/boost.pri) + build_fast { SOURCES += \ docxformatlib_logic.cpp \ @@ -51,10 +54,8 @@ SOURCES += \ ../Source/MathEquation/MathEquation.cpp \ ../Source/DocxFormat/Docx.cpp \ ../Source/XlsxFormat/Chart/ChartSerialize.cpp \ - \ ../Source/XlsxFormat/Common.cpp \ ../Source/XML/libxml2/libxml2.cpp \ - ../Source/XML/stringcommon.cpp \ ../Source/DocxFormat/FileFactory.cpp \ ../Source/DocxFormat/IFileContainer.cpp \ ../Source/SystemUtility/SystemUtility.cpp \ @@ -275,7 +276,6 @@ HEADERS += docxformatlib.h \ ../Source/DocxFormat/Drawing/DrawingShapeElements.h \ ../Source/DocxFormat/Drawing/DrawingText.h \ ../Source/DocxFormat/Drawing/DrawingTextProperties.h \ - ../Source/XML/stringcommon.h \ ../Source/MathEquation/LEStream.h \ ../Source/MathEquation/MathEquation.h \ ../Source/MathEquation/OutputDev.h \ diff --git a/Common/DocxFormat/DocxFormatLib/docxformatlib_file.cpp b/Common/DocxFormat/DocxFormatLib/docxformatlib_file.cpp index 75728cbc8a..8af3be6552 100644 --- a/Common/DocxFormat/DocxFormatLib/docxformatlib_file.cpp +++ b/Common/DocxFormat/DocxFormatLib/docxformatlib_file.cpp @@ -39,5 +39,4 @@ #include "../Source/XlsxFormat/Common.cpp" #include "../Source/XML/libxml2/libxml2.cpp" -#include "../Source/XML/stringcommon.cpp" #include "../Source/SystemUtility/SystemUtility.cpp" diff --git a/Common/DocxFormat/Projects/DocxFormat2005.vcproj b/Common/DocxFormat/Projects/DocxFormat2005.vcproj index bf63e5c3a7..9616f4f4f4 100644 --- a/Common/DocxFormat/Projects/DocxFormat2005.vcproj +++ b/Common/DocxFormat/Projects/DocxFormat2005.vcproj @@ -1331,6 +1331,10 @@ + + @@ -1907,14 +1911,6 @@ - - - - diff --git a/Common/DocxFormat/Source/DocxFormat/ContentTypes.h b/Common/DocxFormat/Source/DocxFormat/ContentTypes.h index ad5213fbca..c38b2cb891 100644 --- a/Common/DocxFormat/Source/DocxFormat/ContentTypes.h +++ b/Common/DocxFormat/Source/DocxFormat/ContentTypes.h @@ -259,7 +259,7 @@ namespace OOX public: - bool Read (const CPath& oDirPath) + bool Read (const CPath& oDirPath) { OOX::CPath oFullPath = oDirPath / c_oContentTypeFileName; @@ -268,14 +268,14 @@ namespace OOX return false; return ReadFromReader(oReader); } - bool ReadFromString (CString& sXml) + bool ReadFromString (CString& sXml) { XmlUtils::CXmlLiteReader oReader; if ( !oReader.FromString( sXml ) ) return false; return ReadFromReader(oReader); } - bool Write(const CPath& oDirPath) const + bool Write(const CPath& oDirPath) const { CString sXml = _T(""); @@ -298,20 +298,20 @@ namespace OOX OOX::CPath oFullPath = oDirPath / c_oContentTypeFileName; XmlUtils::SaveToFile( oFullPath.m_strFilename, sXml ); - return true; + return true; } public: void Registration(const CString& sType, const CPath& oDirectory, const CPath& oFilename) { OOX::CPath oFullPath = oDirectory / oFilename; - AddOverride( sType, oFullPath.m_strFilename ); + AddOverride( sType, oFullPath.m_strFilename.c_str() ); AddDefault ( oFullPath ); } void AddDefault(const OOX::CPath& oPath) { - CString sExt = oPath.GetExtention(); + CString sExt(oPath.GetExtention().c_str()); const CString sExtension = sExt.Mid( 1 ); size_t nCount = m_arrDefault.size(); @@ -330,11 +330,11 @@ namespace OOX } private: - bool ReadFromReader (XmlUtils::CXmlLiteReader& oReader) + bool ReadFromReader (XmlUtils::CXmlLiteReader& oReader) { std::wstring sName; if ( !oReader.ReadNextNode() || _T("Types") != ( sName = oReader.GetName() ) || oReader.IsEmptyNode() ) - return false; + return false; int nTypesDepth = oReader.GetDepth(); while ( oReader.ReadNextSiblingNode( nTypesDepth ) ) @@ -352,10 +352,9 @@ namespace OOX m_arrOverride [oOverride.filename().GetPath()] = oOverride; } } - - return true; + return true; } - void AddOverride(const CString& sType, CString& sPath) + void AddOverride(const CString& sType, const CString& sPath) { #if !defined(_WIN32) && !defined (_WIN64) if (sPath.GetAt(0) == FILE_SEPARATOR_CHAR) diff --git a/Common/DocxFormat/Source/DocxFormat/Docx.h b/Common/DocxFormat/Source/DocxFormat/Docx.h index 8581a1b401..5c02bd206a 100644 --- a/Common/DocxFormat/Source/DocxFormat/Docx.h +++ b/Common/DocxFormat/Source/DocxFormat/Docx.h @@ -113,7 +113,7 @@ namespace OOX // Создаем папку #if defined(_WIN32) || defined (_WIN64) - CreateDirectoryW( oFilePath.GetPath(), NULL ); + CreateDirectoryW( oFilePath.GetPath().c_str(), NULL ); #else std::string sFileParthUtf8 = stringWstingToUtf8String (oFilePath.GetPath()); mkdir (sFileParthUtf8.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); diff --git a/Common/DocxFormat/Source/DocxFormat/File.h b/Common/DocxFormat/Source/DocxFormat/File.h index 6189b9545b..78b3a8ea4f 100644 --- a/Common/DocxFormat/Source/DocxFormat/File.h +++ b/Common/DocxFormat/Source/DocxFormat/File.h @@ -54,11 +54,12 @@ namespace OOX virtual void write(const CPath& filename, const CPath& directory, CContentTypes& content) const = 0; public: - virtual const OOX::FileType type() const = 0; - virtual const CPath DefaultDirectory() const = 0; - virtual const CPath DefaultFileName() const = 0; - CString m_sOutputFilename; - bool m_bDoNotAddRels; + virtual const OOX::FileType type() const = 0; + virtual const CPath DefaultDirectory() const = 0; + virtual const CPath DefaultFileName() const = 0; + + std::wstring m_sOutputFilename; + bool m_bDoNotAddRels; }; class FileGlobalEnumerated : public File { diff --git a/Common/DocxFormat/Source/DocxFormat/FileFactory.cpp b/Common/DocxFormat/Source/DocxFormat/FileFactory.cpp index 3edabd2721..6651610bdc 100644 --- a/Common/DocxFormat/Source/DocxFormat/FileFactory.cpp +++ b/Common/DocxFormat/Source/DocxFormat/FileFactory.cpp @@ -66,7 +66,7 @@ namespace OOX { OOX::CPath oRelationFilename = oRelation.Filename(); CPath oFileName; - if(oRelationFilename.GetIsRoot() && oRootPath.GetPath().GetLength() > 0) + if(oRelationFilename.GetIsRoot() && oRootPath.GetPath().length() > 0) oFileName = oRootPath / oRelationFilename; else oFileName = oPath / oRelationFilename; @@ -139,7 +139,7 @@ namespace OOX OOX::CPath oRelationFilename = pRelation->Filename(); CPath oFileName; - if(oRelationFilename.GetIsRoot() && oRootPath.GetPath().GetLength() > 0) + if(oRelationFilename.GetIsRoot() && oRootPath.GetPath().length() > 0) oFileName = oRootPath / oRelationFilename; else oFileName = oPath / oRelationFilename; diff --git a/Common/DocxFormat/Source/DocxFormat/IFileContainer.cpp b/Common/DocxFormat/Source/DocxFormat/IFileContainer.cpp index 7ce4c1e10a..2f151c96d9 100644 --- a/Common/DocxFormat/Source/DocxFormat/IFileContainer.cpp +++ b/Common/DocxFormat/Source/DocxFormat/IFileContainer.cpp @@ -96,7 +96,7 @@ namespace OOX { OOX::CPath oDefDir = pFile->DefaultDirectory(); OOX::CPath oName = pFile->DefaultFileName(); - if(false == pFile->m_sOutputFilename.IsEmpty()) + if(false == pFile->m_sOutputFilename.empty()) oName.SetName(pFile->m_sOutputFilename, false); std::map::const_iterator pNamePair = mNamePair.find( oName.m_strFilename ); diff --git a/Common/DocxFormat/Source/DocxFormat/Rels.h b/Common/DocxFormat/Source/DocxFormat/Rels.h index 0a09881937..6e247ae674 100644 --- a/Common/DocxFormat/Source/DocxFormat/Rels.h +++ b/Common/DocxFormat/Source/DocxFormat/Rels.h @@ -43,6 +43,8 @@ #include "../Base/SmartPtr.h" #include "../SystemUtility/SystemUtility.h" +#include + namespace OOX { namespace Rels @@ -53,7 +55,7 @@ namespace OOX WritingElement_AdditionConstructors(CRelationShip) CRelationShip(const OOX::RId& rId, const CString& sType, const OOX::CPath& oFilePath) : m_rId(rId), m_oTarget(oFilePath), m_sType(sType) { - m_oTarget.m_strFilename.Replace(_T(" "), _T("_")); + boost::algorithm::replace_all(m_oTarget.m_strFilename, L" ", L"_"); } CRelationShip(const OOX::RId& rId, const smart_ptr pExternal): m_rId(rId), m_oTarget(pExternal->Uri()), m_sType(pExternal->type().RelationType()) { diff --git a/Common/DocxFormat/Source/DocxFormat/VmlDrawing.h b/Common/DocxFormat/Source/DocxFormat/VmlDrawing.h index d781c75515..6199e48090 100644 --- a/Common/DocxFormat/Source/DocxFormat/VmlDrawing.h +++ b/Common/DocxFormat/Source/DocxFormat/VmlDrawing.h @@ -84,7 +84,7 @@ namespace OOX { XmlUtils::CXmlLiteReader oReader; - if ( !oReader.FromString( std_string2string(fileContent))) + if ( !oReader.FromString( fileContent)) return; if ( !oReader.ReadNextNode() ) diff --git a/Common/DocxFormat/Source/SystemUtility/File.h b/Common/DocxFormat/Source/SystemUtility/File.h index 7c4a709498..6b688559ad 100644 --- a/Common/DocxFormat/Source/SystemUtility/File.h +++ b/Common/DocxFormat/Source/SystemUtility/File.h @@ -47,7 +47,7 @@ class CFile { private: - HRESULT _Open(const CString& strFileName, bool bOpen = false, bool bCreate = false, bool bReadWrite = false) + HRESULT _Open(const std::wstring& strFileName, bool bOpen = false, bool bCreate = false, bool bReadWrite = false) { HRESULT hRes = S_OK; CloseFile(); @@ -66,9 +66,9 @@ private: pModeCreate = L"wb"; } if(NULL == m_pFile && bOpen) - m_pFile = _wfopen(strFileName, pModeOpen); + m_pFile = _wfopen(strFileName.c_str(), pModeOpen); if(NULL == m_pFile && bCreate) - m_pFile = _wfopen(strFileName, pModeCreate); + m_pFile = _wfopen(strFileName.c_str(), pModeCreate); #else BYTE* pUtf8 = NULL; LONG lLen = 0; @@ -100,9 +100,9 @@ private: m_lFilePosition = 0; - if (0 < strFileName.GetLength()) + if (0 < strFileName.length()) { - if (((wchar_t)'/') == strFileName[strFileName.GetLength() - 1]) + if (((wchar_t)'/') == strFileName[strFileName.length() - 1]) m_lFileSize = 0x7FFFFFFF; } @@ -129,16 +129,16 @@ public: CloseFile(); } - HRESULT OpenOrCreate(CString strFileName, bool bOnlyOpen = false, bool bReadWrite = false) + HRESULT OpenOrCreate(std::wstring strFileName, bool bOnlyOpen = false, bool bReadWrite = false) { return _Open(strFileName, true, true, true); } - virtual HRESULT OpenFile(CString FileName) + virtual HRESULT OpenFile(std::wstring FileName) { return _Open(FileName, true, false, false); } - virtual HRESULT OpenFileRW(CString FileName) + virtual HRESULT OpenFileRW(std::wstring FileName) { return _Open(FileName, true, false, true); } @@ -199,7 +199,7 @@ public: return WriteFile(mem, nBytesToWrite); } - HRESULT CreateFile(CString strFileName) + HRESULT CreateFile(std::wstring strFileName) { return _Open(strFileName, false, true, true); } @@ -207,7 +207,7 @@ public: { if (m_pFile && nPos <= (ULONG)m_lFileSize) { - m_lFilePosition = nPos; + m_lFilePosition = (long)nPos; fseek(m_pFile, m_lFilePosition, SEEK_SET); return S_OK; } @@ -261,7 +261,7 @@ public: } HRESULT WriteReservedTo(DWORD dwPoint) { - if (m_lFilePosition >= dwPoint) + if ((DWORD)m_lFilePosition >= dwPoint) return S_OK; DWORD dwCount = dwPoint - (DWORD)m_lFilePosition; @@ -273,7 +273,7 @@ public: } HRESULT SkipReservedTo(DWORD dwPoint) { - if (m_lFilePosition >= dwPoint) + if ((DWORD)m_lFilePosition >= dwPoint) return S_OK; DWORD dwCount = dwPoint - (DWORD)m_lFilePosition; @@ -290,23 +290,12 @@ public: return lProgress; } - void WriteStringUTF8(const CString& strXml) - { - BYTE* pData = NULL; - LONG lLen = 0; - - NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strXml.GetString(), strXml.GetLength(), pData, lLen, false); - - WriteFile(pData, lLen); - - RELEASEARRAYOBJECTS(pData); - } void WriteStringUTF8(const std::wstring& strXml) { BYTE* pData = NULL; LONG lLen = 0; - NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strXml.c_str(), strXml.length(), pData, lLen, false); + NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strXml.c_str(), (LONG)strXml.length(), pData, lLen, false); WriteFile(pData, lLen); @@ -356,7 +345,7 @@ namespace StreamUtils DWORD lDWord = 0; BYTE pMem[4]; ULONG lReadByte = 0; - lReadByte = pStream->read(pMem, 4); + lReadByte = (ULONG)pStream->read(pMem, 4); //#if defined(_DEBUG) && (defined(_WIN32) || defined(_WIN64)) // ATLASSERT(4 == lReadByte); @@ -393,7 +382,7 @@ namespace StreamUtils char* pData = new char[lLen + 1]; ULONG lReadByte = 0; - lReadByte = pStream->read((unsigned char*)pData, lLen); + lReadByte = (ULONG)pStream->read((unsigned char*)pData, lLen); pData[lLen] = 0; @@ -410,7 +399,7 @@ namespace StreamUtils memset (pData, 0, 2 * (lLen + 1)); ULONG lReadByte = 0; - lReadByte = pStream->read(pData, 2 * lLen); + lReadByte = (ULONG)pStream->read(pData, 2 * lLen); if (sizeof(wchar_t) == 4) { @@ -444,16 +433,11 @@ namespace StreamUtils } } - static CStringA ConvertCStringWToCStringA(CStringW& strW) + static std::string ConvertCStringWToCStringA(std::wstring& strW) { - /*WCHAR* pData = strW.GetBuffer(); - CString str(pData);*/ - //strW.ReleaseBuffer(); + std::string str_a(strW.begin(), strW.end()); - std::wstring str_w = string2std_string(strW); - std::string str_a(str_w.begin(), str_w.end()); - - return std_string2string(str_a); + return str_a; } static void StreamSeek(long lOffset, POLE::Stream* pStream) { @@ -465,7 +449,7 @@ namespace StreamUtils { if (pStream == NULL) return ; - lPosition = pStream->tell(); + lPosition = (LONG)pStream->tell(); } static void StreamSkip(long lCount, POLE::Stream* pStream) { @@ -484,102 +468,100 @@ namespace StreamUtils #if defined(_WIN32) || defined(_WIN64) namespace CDirectory { - static CString GetFolderName(CString strFolderPath) + static std::wstring GetFolderName(std::wstring strFolderPath) { - int n1 = strFolderPath.ReverseFind('\\'); + int n1 = strFolderPath.rfind('\\'); if (-1 == n1) return _T(""); - return strFolderPath.Mid(n1 + 1); + return strFolderPath.substr(n1 + 1); } - static CString GetFolderPath(CString strFolderPath) + static std::wstring GetFolderPath(std::wstring strFolderPath) { - int n1 = strFolderPath.ReverseFind('\\'); + int n1 = strFolderPath.rfind('\\'); if (-1 == n1) return _T(""); - return strFolderPath.Mid(0, n1); + return strFolderPath.substr(0, n1); } - static bool OpenFile(CString strFolderPath, CString strFileName, CFile* pFile) + static bool OpenFile(std::wstring strFolderPath, std::wstring strFileName, CFile* pFile) { - CString strFile = strFolderPath + FILE_SEPARATOR_STR + strFileName; + std::wstring strFile = strFolderPath + FILE_SEPARATOR_STR + strFileName; return (S_OK == pFile->OpenFile(strFile)); } - static bool CreateFile(CString strFolderPath, CString strFileName, CFile* pFile) + static bool CreateFile(std::wstring strFolderPath, std::wstring strFileName, CFile* pFile) { - CString strFile = strFolderPath + FILE_SEPARATOR_STR + strFileName; + std::wstring strFile = strFolderPath + FILE_SEPARATOR_STR + strFileName; return (S_OK == pFile->CreateFile(strFile)); } - static bool CreateDirectory(CString strFolderPathRoot, CString strFolderName) + static bool CreateDirectory(std::wstring strFolderPathRoot, std::wstring strFolderName) { - CString strFolder = strFolderPathRoot + FILE_SEPARATOR_STR + strFolderName; - return ::CreateDirectory(strFolder, NULL); + std::wstring strFolder = strFolderPathRoot + FILE_SEPARATOR_STR + strFolderName; + return (bool)CreateDirectory(strFolder, NULL); } - static bool CreateDirectory(CString strFolderPath) + static bool CreateDirectory(std::wstring strFolderPath) { - return ::CreateDirectory(strFolderPath, NULL); + return (bool)CreateDirectory(strFolderPath, NULL); } - static bool DeleteFile (CString strFileName) + static bool DeleteFile (std::wstring strFileName) { - ::DeleteFile (strFileName); + ::DeleteFile (strFileName.c_str()); return true; } - static bool MoveFile(CString strExists, CString strNew, LPVOID lpFunc, LPVOID lpData) + static bool MoveFile(std::wstring strExists, std::wstring strNew, LPVOID lpFunc, LPVOID lpData) { #if (_WIN32_WINNT >= 0x0500) && !defined (_WIN64) - return ::MoveFileWithProgress(strExists, strNew, (LPPROGRESS_ROUTINE)lpFunc, lpData, MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH); + return (bool)MoveFileWithProgress(strExists.c_str(), strNew.c_str(), (LPPROGRESS_ROUTINE)lpFunc, lpData, MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH); #else - return ::MoveFileEx(strExists, strNew, MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH); + return (bool)MoveFileEx(strExists.c_str(), strNew.c_str(), MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH); #endif } - static bool CopyFile(CString strExists, CString strNew, LPVOID lpFunc, LPVOID lpData) + static bool CopyFile(std::wstring strExists, std::wstring strNew, LPVOID lpFunc, LPVOID lpData) { DeleteFile(strNew); -#if defined (_WIN64) - return ::CopyFile(strExists, strNew, true); -#else - return ::CopyFileEx(strExists, strNew, (LPPROGRESS_ROUTINE)lpFunc, lpData, FALSE, 0); -#endif +//#if (_WIN32_WINNT >= 0x0500) && !defined (_WIN64) +// return (bool)CopyFile(strExists.c_str(), strNew.c_str(), true); +//#else + return (bool)CopyFileEx(strExists.c_str(), strNew.c_str(), (LPPROGRESS_ROUTINE)lpFunc, lpData, FALSE, 0); +//#endif } - static CString GetUnder(CString strFolderPathRoot, CString strFolderName) + static std::wstring GetUnder(std::wstring strFolderPathRoot, std::wstring strFolderName) { - CString strFolder = strFolderPathRoot + L"\\" + strFolderName; + std::wstring strFolder = strFolderPathRoot + L"\\" + strFolderName; return strFolder; } - static CString GetFileName(CString strFullName) + static std::wstring GetFileName(std::wstring strFullName) { - int nStart = strFullName.ReverseFind(L"\\"); - CString strName = strFullName.Mid(nStart + 1); + size_t nStart = strFullName.rfind(L"\\"); + std::wstring strName = strFullName.substr(nStart + 1); return strName; } - static CString BYTEArrayToString2(USHORT* arr, size_t nCount) + static std::wstring BYTEArrayToString2(USHORT* arr, size_t nCount) { - CString str; + std::wstring str; for (size_t index = 0; index < nCount; ++index) { if ('\0' != (char)(arr[index])) str += (char)(arr[index]); } - if (str.GetLength() == 0) + if (str.length() == 0) str = _T("0"); return str; } - static CString ToString(DWORD val) + static std::wstring ToString(DWORD val) { - CString str = _T(""); - str.Format(_T("%d"), (LONG)val); - return str; + return std::to_wstring(val); } - static CString ToString(UINT64 val, bool bInit) + static std::wstring ToString(UINT64 val, bool bInit) { - CString strCoarse = ToString((DWORD)(val >> 32)); + std::wstring strCoarse = ToString((DWORD)(val >> 32)); if (_T("0") != strCoarse) { return strCoarse + ToString((DWORD)val); @@ -588,35 +570,34 @@ namespace CDirectory return ToString((DWORD)val); } - static UINT64 GetUINT64(CString strVal) + static UINT64 GetUINT64(std::wstring strVal) { UINT64 nRet = 0; - int nLen = strVal.GetLength(); + int nLen = (int)strVal.length(); while (nLen > 0) { int nDig = XmlUtils::GetDigit(strVal[0]); nRet *= 10; nRet += nDig; - strVal.Delete(0); + strVal.erase(0); --nLen; } return nRet; } - static UINT GetUINT(CString strVal) + static UINT GetUINT(std::wstring strVal) { return (UINT)GetUINT64(strVal); } - static void SaveToFile(CString strFileName, CString strXml) + static void SaveToFile(std::wstring strFileName, std::wstring strXml) { - int nLength = strXml.GetLength(); + int nLength = (int)strXml.length(); - CStringA saStr; + std::string saStr; saStr.reserve(nLength*3 + 1); #ifdef UNICODE // Encoding Unicode to UTF-8 - WideCharToMultiByte(CP_UTF8, 0, strXml.GetBuffer(), nLength + 1, saStr.GetBuffer(nLength*3 + 1), nLength*3, NULL, NULL); - saStr.ReleaseBuffer(); + WideCharToMultiByte(CP_UTF8, 0, strXml.c_str(), nLength + 1, (LPSTR)saStr.c_str(), nLength * 3, NULL, NULL); #else wchar_t* pWStr = new wchar_t[nLength + 1]; if (!pWStr) @@ -639,11 +620,11 @@ namespace CDirectory CFile oFile; oFile.CreateFile(strFileName); - oFile.WriteFile((void*)saStr.GetBuffer(), saStr.GetLength()); + oFile.WriteFile((void*)saStr.c_str(), saStr.length()); oFile.CloseFile(); } - static void SaveToFile2(CString strFileName, CStringA strVal) + static void SaveToFile2(std::wstring strFileName, std::string strVal) { CFile oFile; HRESULT hr = oFile.OpenFileRW(strFileName); @@ -652,7 +633,7 @@ namespace CDirectory oFile.CreateFile(strFileName); oFile.SkipBytes(oFile.GetFileSize()); - oFile.WriteFile((void*)strVal.GetBuffer(), strVal.GetLength()); + oFile.WriteFile((void*)strVal.c_str(), strVal.length()); oFile.CloseFile(); } } @@ -665,46 +646,11 @@ namespace CDirectory #include "../../../../DesktopEditor/common/Types.h" #include "../../../../DesktopEditor/common/File.h" -/* -class CFile: public NSFile::CFileBinary -{ -public: - CFile() - : NSFile::CFileBinary () - { - } - HRESULT WriteFile(void* pData, DWORD nBytesToWrite) - { - return (WriteFile (static_cast (pData), nBytesToWrite) ? S_OK : S_FALSE); - } - HRESULT CreateFile(CString strFileName) - { - return CreateFileW(strFileName) ? S_OK : S_FALSE; - } - HRESULT ReadFile(BYTE* pData, DWORD nBytesToRead) - { - DWORD dwRead = 0; - return NSFile::CFileBinary::ReadFile(pData, nBytesToRead, dwRead) ? S_OK : S_FALSE; - } - HRESULT SetPosition( ULONG64 nPos ) - { - if ((NULL != m_pFile) && nPos <= (ULONG)m_lFileSize) - { - int res = fseek(m_pFile, 0, SEEK_SET); - - m_lFilePosition = nPos; - return 0 == res ? S_OK : S_FALSE; - } - - return S_FALSE; - } -}; -*/ namespace CDirectory { - static void SaveToFile(CString strFileName, CString strXml) + static void SaveToFile(std::wstring strFileName, std::wstring strXml) { std::string aContentUtf8 = stringWstingToUtf8String (strXml); std::string aFileNameUtf8 = stringWstingToUtf8String (strFileName); @@ -718,19 +664,19 @@ namespace CDirectory fwrite (aContentUtf8.c_str() , sizeof(char), aContentUtf8.size(), pFile); fclose (pFile); } - static bool DeleteFile (CString strFileName) + static bool DeleteFile (std::wstring strFileName) { std::string aFileNameUtf8 = stringWstingToUtf8String (strFileName); return 0 == unlink (aFileNameUtf8.c_str()); } - static CString ToString(DWORD val) + static std::wstring ToString(DWORD val) { - CString str = _T(""); + std::wstring str = _T(""); str.Format(_T("%d"), (LONG)val); return str; } - static bool CopyFile (CString strExists, CString strNew, LPVOID lpFunc = NULL, LPVOID lpData = NULL) + static bool CopyFile (std::wstring strExists, std::wstring strNew, LPVOID lpFunc = NULL, LPVOID lpData = NULL) { bool bRes = true; try @@ -753,40 +699,41 @@ namespace CDirectory namespace CDirectory { - static void WriteValueToNode(CString strName, DWORD value, XmlUtils::CXmlWriter* pWriter) + static void WriteValueToNode(std::wstring strName, DWORD value, XmlUtils::CXmlWriter* pWriter) { pWriter->WriteNodeBegin(strName); pWriter->WriteString(CDirectory::ToString(value)); pWriter->WriteNodeEnd(strName); } - static void WriteValueToNode(CString strName, LONG value, XmlUtils::CXmlWriter* pWriter) + static void WriteValueToNode(std::wstring strName, LONG value, XmlUtils::CXmlWriter* pWriter) { pWriter->WriteNodeBegin(strName); - CString strLONG = _T(""); - strLONG.Format(_T("%d"), value); - pWriter->WriteString(strLONG); + + std::wstring strLONG = std::to_wstring(value); + + pWriter->WriteString(strLONG); pWriter->WriteNodeEnd(strName); } - static void WriteValueToNode(CString strName, CString value, XmlUtils::CXmlWriter* pWriter) + static void WriteValueToNode(std::wstring strName, std::wstring value, XmlUtils::CXmlWriter* pWriter) { pWriter->WriteNodeBegin(strName); pWriter->WriteString(value); pWriter->WriteNodeEnd(strName); } - static void WriteValueToNode(CString strName, WCHAR value, XmlUtils::CXmlWriter* pWriter) + static void WriteValueToNode(std::wstring strName, WCHAR value, XmlUtils::CXmlWriter* pWriter) { wchar_t str_arr[2]={}; str_arr[0] = value; - CString str(str_arr); + std::wstring str(str_arr); pWriter->WriteNodeBegin(strName); pWriter->WriteString(str); pWriter->WriteNodeEnd(strName); } - static void WriteValueToNode(CString strName, bool value, XmlUtils::CXmlWriter* pWriter) + static void WriteValueToNode(std::wstring strName, bool value, XmlUtils::CXmlWriter* pWriter) { pWriter->WriteNodeBegin(strName); - CString str = (true == value) ? _T("1") : _T("0"); + std::wstring str = (true == value) ? _T("1") : _T("0"); pWriter->WriteString(str); pWriter->WriteNodeEnd(strName); } @@ -803,29 +750,29 @@ namespace CDirectory } - static CString BYTEArrayToString(BYTE* arr, size_t nCount) + static std::wstring BYTEArrayToString(BYTE* arr, size_t nCount) { - CString str; + std::wstring str; for (size_t index = 0; index < nCount; ++index) { if ('\0' != (char)(arr[index])) str += (char)(arr[index]); } - if (str.GetLength() == 0) + if (str.length() == 0) str = _T("0"); return str; } - static CStringW BYTEArrayToStringW(BYTE* arr, size_t nCount) + static std::wstring BYTEArrayToStringW(BYTE* arr, size_t nCount) { - CStringW str; + std::wstring str; wchar_t* pArr = (wchar_t*)arr; size_t nCountNew = nCount / 2; for (size_t index = 0; index < nCountNew; ++index) { str += pArr[index]; } - if (str.GetLength() == 0) + if (str.length() == 0) str = _T("0"); return str; } diff --git a/Common/DocxFormat/Source/SystemUtility/SystemUtility.cpp b/Common/DocxFormat/Source/SystemUtility/SystemUtility.cpp index 620666f824..222d2e1c0a 100644 --- a/Common/DocxFormat/Source/SystemUtility/SystemUtility.cpp +++ b/Common/DocxFormat/Source/SystemUtility/SystemUtility.cpp @@ -33,17 +33,10 @@ #if defined(_WIN32) || defined (_WIN64) #include -#else - #include "../Base/ASCString.h" #endif - - - #include "FileSystem/FileSystem.h" -//#include "AVSUtils.h" -//#include "File.h" namespace OOX { @@ -51,14 +44,17 @@ namespace OOX { CheckIsRoot(); } - CPath::CPath(const CString& sName, bool bIsNorm) : m_strFilename(sName) + + CPath::CPath(const std::wstring& sName, bool bIsNorm) : m_strFilename(sName) { CheckIsRoot(); if (bIsNorm) Normalize(); } - CPath::CPath(LPCSTR& sName, bool bIsNorm) : m_strFilename(sName) + CPath::CPath(LPCSTR& sName, bool bIsNorm) { + std::string s(sName); + m_strFilename = std::wstring(s.begin(), s.end()); CheckIsRoot(); if (bIsNorm) Normalize(); @@ -85,7 +81,7 @@ namespace OOX //Normalize(); return *this; } - CPath& CPath::operator=(const CString& oSrc) + CPath& CPath::operator=(const std::wstring& oSrc) { m_strFilename = oSrc; Normalize(); @@ -93,7 +89,8 @@ namespace OOX } CPath& CPath::operator=(LPCSTR oSrc) { - m_strFilename = oSrc; + std::string s(oSrc); + m_strFilename = std::wstring(s.begin(), s.end()); Normalize(); return *this; } @@ -105,7 +102,7 @@ namespace OOX } /* - AVSINLINE CString CPath::GetExtention(bool bIsPoint) const + AVSINLINE std::wstring CPath::GetExtention(bool bIsPoint) const { int nFind = m_strFilename.ReverseFind('.'); if (-1 == nFind) @@ -118,7 +115,7 @@ namespace OOX } */ /* - AVSINLINE CString CPath::GetDirectory(bool bIsSlash) const + AVSINLINE std::wstring CPath::GetDirectory(bool bIsSlash) const { int nPos = m_strFilename.ReverseFind('\\'); if (-1 == nPos) @@ -134,7 +131,7 @@ namespace OOX } */ /* - AVSINLINE CString CPath::GetPath() const + AVSINLINE std::wstring CPath::GetPath() const { return m_strFilename; } @@ -143,13 +140,11 @@ namespace OOX namespace OOX { - bool CSystemUtility::CreateFile(const CString& strFileName) + bool CSystemUtility::CreateFile(const std::wstring& strFileName) { #if defined(_WIN32) || defined (_WIN64) - BSTR strPath = strFileName.AllocSysString(); - HANDLE hResult = ::CreateFile(strPath, GENERIC_READ, 0, NULL, + HANDLE hResult = ::CreateFile(strFileName.c_str(), GENERIC_READ, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - SysFreeString(strPath); if (hResult == INVALID_HANDLE_VALUE) return false; @@ -170,7 +165,7 @@ namespace OOX #endif } - bool CSystemUtility::IsFileExist(const CString& strFileName) + bool CSystemUtility::IsFileExist(const std::wstring& strFileName) { return FileSystem::File::Exists(strFileName); } @@ -179,18 +174,18 @@ namespace OOX return IsFileExist(oPath.GetPath()); } - CString CSystemUtility::GetDirectoryName(const CString& strFileName) + std::wstring CSystemUtility::GetDirectoryName(const std::wstring& strFileName) { CPath oPath(strFileName); return oPath.GetDirectory(); } - int CSystemUtility::GetFilesCount(const CString& strDirPath, const bool& bRecursive) + int CSystemUtility::GetFilesCount(const std::wstring& strDirPath, const bool& bRecursive) { return FileSystem::Directory::GetFilesCount(strDirPath, bRecursive); } - CString CSystemUtility::GetFileExtention(const CString& strFileName) + std::wstring CSystemUtility::GetFileExtention(const std::wstring& strFileName) { CPath oPath(strFileName); return oPath.GetExtention(); @@ -201,7 +196,7 @@ namespace OOX return FileSystem::Directory::CreateDirectory(oPath.GetPath()); } - void CSystemUtility::ReplaceExtention(CString& strName, CString& str1, CString& str2) + void CSystemUtility::ReplaceExtention(std::wstring& strName, std::wstring& str1, std::wstring& str2) { return; } diff --git a/Common/DocxFormat/Source/SystemUtility/SystemUtility.h b/Common/DocxFormat/Source/SystemUtility/SystemUtility.h index 30507e955b..71faa01dbb 100644 --- a/Common/DocxFormat/Source/SystemUtility/SystemUtility.h +++ b/Common/DocxFormat/Source/SystemUtility/SystemUtility.h @@ -38,22 +38,22 @@ namespace OOX class CPath { public: - CString m_strFilename; + std::wstring m_strFilename; //флаг введен, чтобы отличать относительные и абсолютные пути в rels bool m_bIsRoot; public: CPath(); - CPath(const CString& sName, bool bIsNorm = true); - CPath(LPCSTR& sName, bool bIsNorm = true); - CPath(LPCWSTR& sName, bool bIsNorm = true); + CPath(const std::wstring& sName, bool bIsNorm = true); + CPath(LPCSTR& sName, bool bIsNorm = true); + CPath(LPCWSTR& sName, bool bIsNorm = true); CPath(const CPath& oSrc); - CPath& operator=(const CPath& oSrc); - CPath& operator=(const CString& oSrc); - CPath& operator=(LPCSTR oSrc); - CPath& operator=(LPCWSTR oSrc); + CPath& operator=(const CPath& oSrc); + CPath& operator=(const std::wstring& oSrc); + CPath& operator=( LPCSTR oSrc); + CPath& operator=( LPCWSTR oSrc); friend CPath operator/(const CPath& path1, const CPath& path2) { @@ -62,7 +62,7 @@ namespace OOX return path; } - friend CPath operator/(const CPath& path1, const CString& path2) + friend CPath operator/(const CPath& path1, const std::wstring& path2) { CPath path(path1.m_strFilename + FILE_SEPARATOR_STR + path2); path.Normalize(); @@ -76,72 +76,72 @@ namespace OOX path.Normalize(); return path; } - friend CPath operator+(const CPath& path1, const CString& path2) + friend CPath operator+(const CPath& path1, const std::wstring& path2) { CPath path(path1.m_strFilename + path2); path.Normalize(); return path; } - friend CPath operator+(const CString& path1, const CPath& path2) + friend CPath operator+(const std::wstring& path1, const CPath& path2) { CPath path(path1 + path2.m_strFilename); path.Normalize(); return path; } - AVSINLINE CString GetExtention(bool bIsPoint = true) const + AVSINLINE std::wstring GetExtention(bool bIsPoint = true) const { - int nFind = m_strFilename.ReverseFind('.'); + int nFind = (int)m_strFilename.rfind('.'); if (-1 == nFind) - return _T(""); + return L""; if (!bIsPoint) ++nFind; - return m_strFilename.Mid(nFind); + return m_strFilename.substr(nFind); } - AVSINLINE CString GetDirectory(bool bIsSlash = true) const + AVSINLINE std::wstring GetDirectory(bool bIsSlash = true) const { - int nPos = m_strFilename.ReverseFind(FILE_SEPARATOR_CHAR); - if (-1 == nPos) - { - return m_strFilename; - } - else - { - if (bIsSlash) - ++nPos; - return m_strFilename.Mid(0, nPos); - } + int nPos = (int)m_strFilename.rfind(FILE_SEPARATOR_CHAR); + if (-1 == nPos) + { + return m_strFilename; + } + else + { + if (bIsSlash) + ++nPos; + return m_strFilename.substr(0, nPos); + } } - AVSINLINE CString GetPath() const + AVSINLINE std::wstring GetPath() const { return m_strFilename; } - AVSINLINE CString GetFilename() const + AVSINLINE std::wstring GetFilename() const { - int nPos = m_strFilename.ReverseFind(FILE_SEPARATOR_CHAR); + int nPos = (int)m_strFilename.rfind(FILE_SEPARATOR_CHAR); if (-1 == nPos) { return m_strFilename; } else { - int nLast = (int) m_strFilename.GetLength(); - return m_strFilename.Mid(nPos + 1, nLast); + int nLast = (int) m_strFilename.length(); + return m_strFilename.substr(nPos + 1, nLast); } } #if defined(_WIN32) || defined (_WIN64) AVSINLINE void Normalize() { - if (0 == m_strFilename.GetLength()) + if (0 == m_strFilename.length()) return; - TCHAR* pData = m_strFilename.GetBuffer(); - int nLen = m_strFilename.GetLength(); + const wchar_t* pData = m_strFilename.c_str(); + int nLen = (int)m_strFilename.length(); - TCHAR* pDataNorm = new TCHAR[nLen + 1]; + wchar_t* pDataNorm = new wchar_t[nLen + 1]; int* pSlashPoints = new int[nLen + 1]; int nStart = 0; @@ -152,14 +152,14 @@ namespace OOX while (nCurrent < nLen) { - if (pData[nCurrent] == (TCHAR) '\\' || pData[nCurrent] == (TCHAR)'/') + if (pData[nCurrent] == (wchar_t) '\\' || pData[nCurrent] == (wchar_t)'/') { if (nStart < nCurrent) { bIsUp = false; if ((nCurrent - nStart) == 2) { - if (pData[nStart] == (TCHAR)'.' && pData[nStart + 1] == (TCHAR)'.') + if (pData[nStart] == (wchar_t)'.' && pData[nStart + 1] == (wchar_t)'.') { if (nCurrentSlash > 0) { @@ -171,7 +171,7 @@ namespace OOX } if (!bIsUp) { - pDataNorm[nCurrentW++] = (TCHAR) FILE_SEPARATOR_CHAR; + pDataNorm[nCurrentW++] = (wchar_t) FILE_SEPARATOR_CHAR; ++nCurrentSlash; pSlashPoints[nCurrentSlash] = nCurrentW; } @@ -184,17 +184,17 @@ namespace OOX ++nCurrent; } - pDataNorm[nCurrentW] = (TCHAR)'\0'; + pDataNorm[nCurrentW] = (wchar_t)'\0'; - m_strFilename.ReleaseBuffer(); - m_strFilename = CString(pDataNorm, nCurrentW); + m_strFilename.clear(); + m_strFilename = std::wstring(pDataNorm, nCurrentW); delete []pSlashPoints; delete []pDataNorm; } void CheckIsRoot() { - if(m_strFilename.GetLength() > 0 && ('/' == m_strFilename[0] || '\\' == m_strFilename[0])) + if(m_strFilename.length() > 0 && ('/' == m_strFilename[0] || '\\' == m_strFilename[0])) m_bIsRoot = true; else m_bIsRoot = false; @@ -202,13 +202,13 @@ namespace OOX #else AVSINLINE void Normalize() { - if (0 == m_strFilename.GetLength()) + if (0 == m_strFilename.length()) return; - TCHAR* pData = m_strFilename.GetBuffer(); - int nLen = m_strFilename.GetLength(); + wchar_t* pData = m_strFilename.GetBuffer(); + int nLen = m_strFilename.length(); - TCHAR* pDataNorm = new TCHAR[nLen + 1]; + wchar_t* pDataNorm = new wchar_t[nLen + 1]; int* pSlashPoints = new int[nLen + 1]; int nStart = 0; @@ -217,19 +217,19 @@ namespace OOX int nCurrentW = 0; bool bIsUp = false; - if (pData[nCurrent] == (TCHAR)'/') - pDataNorm[nCurrentW++] = (TCHAR) FILE_SEPARATOR_CHAR; + if (pData[nCurrent] == (wchar_t)'/') + pDataNorm[nCurrentW++] = (wchar_t) FILE_SEPARATOR_CHAR; while (nCurrent < nLen) { - if (pData[nCurrent] == (TCHAR)'/') + if (pData[nCurrent] == (wchar_t)'/') { if (nStart < nCurrent) { bIsUp = false; if ((nCurrent - nStart) == 2) { - if (pData[nStart] == (TCHAR)'.' && pData[nStart + 1] == (TCHAR)'.') + if (pData[nStart] == (wchar_t)'.' && pData[nStart + 1] == (wchar_t)'.') { if (nCurrentSlash > 0) { @@ -241,7 +241,7 @@ namespace OOX } if (!bIsUp) { - pDataNorm[nCurrentW++] = (TCHAR) FILE_SEPARATOR_CHAR; + pDataNorm[nCurrentW++] = (wchar_t) FILE_SEPARATOR_CHAR; ++nCurrentSlash; pSlashPoints[nCurrentSlash] = nCurrentW; } @@ -254,24 +254,24 @@ namespace OOX ++nCurrent; } - pDataNorm[nCurrentW] = (TCHAR)'\0'; + pDataNorm[nCurrentW] = (wchar_t)'\0'; m_strFilename.ReleaseBuffer(); - m_strFilename = CString(pDataNorm, nCurrentW); + m_strFilename = std::wstring(pDataNorm, nCurrentW); delete []pSlashPoints; delete []pDataNorm; } void CheckIsRoot() { - if(m_strFilename.GetLength() > 0 && ( '/' == m_strFilename[0] )) + if(m_strFilename.length() > 0 && ( '/' == m_strFilename[0] )) m_bIsRoot = true; else m_bIsRoot = false; } #endif - void SetName(CString sName, bool bNormalize) + void SetName(std::wstring sName, bool bNormalize) { m_strFilename = sName; CheckIsRoot(); @@ -288,13 +288,13 @@ namespace OOX class CSystemUtility { public: - static bool CreateFile(const CString& strFileName); - static bool IsFileExist(const CString& strFileName); - static bool IsFileExist(const CPath& sPath); - static CString GetDirectoryName(const CString& strFileName); - static int GetFilesCount(const CString& strDirPath, const bool& bRecursive = false); - static CString GetFileExtention(const CString& strFileName); - static bool CreateDirectories(const CPath& oPath); - static void ReplaceExtention(CString& strName, CString& str1, CString& str2); + static bool CreateFile (const std::wstring& strFileName); + static bool IsFileExist (const std::wstring& strFileName); + static bool IsFileExist (const CPath& sPath); + static std::wstring GetDirectoryName (const std::wstring& strFileName); + static int GetFilesCount (const std::wstring& strDirPath, const bool& bRecursive = false); + static std::wstring GetFileExtention (const std::wstring& strFileName); + static bool CreateDirectories (const CPath& oPath); + static void ReplaceExtention ( std::wstring& strName, std::wstring& str1, std::wstring& str2); }; } diff --git a/Common/DocxFormat/Source/XML/libxml2/libxml2.cpp b/Common/DocxFormat/Source/XML/libxml2/libxml2.cpp index 108a376dcf..e66079b5f2 100644 --- a/Common/DocxFormat/Source/XML/libxml2/libxml2.cpp +++ b/Common/DocxFormat/Source/XML/libxml2/libxml2.cpp @@ -369,7 +369,7 @@ namespace XmlUtils return _default; std::map::const_iterator pFind = - m_pBase->m_attributes.find(std_string2string(NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(sName.GetString(), sName.GetLength()))); + m_pBase->m_attributes.find(NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(sName.GetString(), sName.GetLength())); if (pFind == m_pBase->m_attributes.end()) return _default; @@ -386,7 +386,7 @@ namespace XmlUtils if (pFind == m_pBase->m_attributes.end()) return _default; - return std_string2string(NSFile::CUtf8Converter::GetUnicodeFromCharPtr(pFind->second.GetString(), pFind->second.GetLength(), true)); + return NSFile::CUtf8Converter::GetUnicodeFromCharPtr(pFind->second.GetString(), pFind->second.GetLength(), true); } CString CXmlNode::GetAttribute(const CString& sName, const CString& _default) { @@ -394,12 +394,12 @@ namespace XmlUtils return _default; std::map::const_iterator pFind = - m_pBase->m_attributes.find(std_string2string(NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(sName.GetString(), sName.GetLength()))); + m_pBase->m_attributes.find(NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(sName.GetString(), sName.GetLength())); if (pFind == m_pBase->m_attributes.end()) return _default; - return std_string2string(NSFile::CUtf8Converter::GetUnicodeFromCharPtr(pFind->second.GetString(), pFind->second.GetLength(), true)); + return NSFile::CUtf8Converter::GetUnicodeFromCharPtr(pFind->second.GetString(), pFind->second.GetLength(), true); } bool CXmlNode::GetAttributeIfExist(const CString& sName, CString& sOutput) { @@ -407,11 +407,11 @@ namespace XmlUtils if (IsValid()) { std::map::const_iterator pFind = - m_pBase->m_attributes.find(std_string2string(NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(sName.GetString(), sName.GetLength()))); + m_pBase->m_attributes.find(NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(sName.GetString(), sName.GetLength())); if (pFind != m_pBase->m_attributes.end()) { - sOutput = std_string2string(NSFile::CUtf8Converter::GetUnicodeFromCharPtr(pFind->second.GetString(), pFind->second.GetLength(), true)); + sOutput = NSFile::CUtf8Converter::GetUnicodeFromCharPtr(pFind->second.GetString(), pFind->second.GetLength(), true); bRes = true; } } @@ -448,7 +448,7 @@ namespace XmlUtils return _default; std::map::const_iterator pFind = - m_pBase->m_attributes.find(std_string2string(NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(sName.GetString(), sName.GetLength()))); + m_pBase->m_attributes.find(NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(sName.GetString(), sName.GetLength())); if (pFind == m_pBase->m_attributes.end()) return _default; @@ -487,7 +487,7 @@ namespace XmlUtils return _default; std::map::const_iterator pFind = - m_pBase->m_attributes.find(std_string2string(NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(sName.GetString(), (LONG)sName.GetLength()))); + m_pBase->m_attributes.find(NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(sName.GetString(), (LONG)sName.GetLength())); if (pFind == m_pBase->m_attributes.end()) return _default; diff --git a/Common/DocxFormat/Source/XML/libxml2/libxml2.h b/Common/DocxFormat/Source/XML/libxml2/libxml2.h index 136bc81677..9c2aa274e8 100644 --- a/Common/DocxFormat/Source/XML/libxml2/libxml2.h +++ b/Common/DocxFormat/Source/XML/libxml2/libxml2.h @@ -37,243 +37,12 @@ #include #include -#include "../../XML/stringcommon.h" #include "../../../../../DesktopEditor/common/File.h" #include "../Utils.h" namespace XmlUtils { - //class CStringWriter - //{ - //private: - // wchar_t* m_pData; - // size_t m_lSize; - - // wchar_t* m_pDataCur; - // size_t m_lSizeCur; - - // int m_lBinaryFactor; - - //public: - // CStringWriter() - // { - // m_pData = NULL; - // m_lSize = 0; - - // m_pDataCur = m_pData; - // m_lSizeCur = m_lSize; - - // m_bInitTable = false; - - // m_lBinaryFactor = (((sizeof(wchar_t)) >> 1)); - // } - // ~CStringWriter() - // { - // RELEASEMEM(m_pData); - // } - - // AVSINLINE void AddSize(size_t nSize) - // { - // if (NULL == m_pData) - // { - // m_lSize = max(nSize, 1000); - // m_pData = (wchar_t*)malloc(m_lSize * sizeof(wchar_t)); - - // m_lSizeCur = 0; - // m_pDataCur = m_pData; - // return; - // } - - // if ((m_lSizeCur + nSize) > m_lSize) - // { - // while ((m_lSizeCur + nSize) > m_lSize) - // { - // m_lSize *= 2; - // } - - // wchar_t* pRealloc = (wchar_t*)realloc(m_pData, m_lSize * sizeof(wchar_t)); - // if (NULL != pRealloc) - // { - // // ������� �������� - // m_pData = pRealloc; - // m_pDataCur = m_pData + m_lSizeCur; - // } - // else - // { - // wchar_t* pMalloc = (wchar_t*)malloc(m_lSize * sizeof(wchar_t)); - // memcpy(pMalloc, m_pData, m_lSizeCur * sizeof(wchar_t)); - - // free(m_pData); - // m_pData = pMalloc; - // m_pDataCur = m_pData + m_lSizeCur; - // } - // } - // } - - //public: - - // AVSINLINE void WriteString(const wchar_t* pString, const size_t& nLen) - // { - // AddSize(nLen); - // memcpy(m_pDataCur, pString, nLen << m_lBinaryFactor); - // m_pDataCur += nLen; - // m_lSizeCur += nLen; - // } - // AVSINLINE void WriteString(const std::wstring& bsString) - // { - // WriteString(bsString.c_str(), (size_t)bsString.length()); - // } - // - // AVSINLINE void AddCharSafe(const TCHAR& _c) - // { - // AddSize(1); - // *m_pDataCur++ = _c; - // ++m_lSizeCur; - // } - // AVSINLINE void AddChar2Safe(const TCHAR _c1, const TCHAR& _c2) - // { - // AddSize(2); - // *m_pDataCur++ = _c1; - // *m_pDataCur++ = _c2; - // m_lSizeCur += 2; - // } - - // inline void WriteEncodeXmlString(const std::wstring& _string) - // { - // WriteEncodeXmlString(_string.c_str()); - // } - - // inline void WriteEncodeXmlString(const wchar_t* pString) - // { - // const wchar_t* pData = pString; - // while (*pData != 0) - // { - // BYTE _code = CheckCode(*pData); - - // switch (_code) - // { - // case 1: - // AddCharSafe(*pData); - // break; - // case 0: - // AddCharSafe((WCHAR)' '); - // break; - // case 2: - // AddSize(5); - // *m_pDataCur++ = (WCHAR)('&'); - // *m_pDataCur++ = (WCHAR)('a'); - // *m_pDataCur++ = (WCHAR)('m'); - // *m_pDataCur++ = (WCHAR)('p'); - // *m_pDataCur++ = (WCHAR)(';'); - // m_lSizeCur += 5; - // break; - // case 3: - // AddSize(6); - // *m_pDataCur++ = (WCHAR)('&'); - // *m_pDataCur++ = (WCHAR)('a'); - // *m_pDataCur++ = (WCHAR)('p'); - // *m_pDataCur++ = (WCHAR)('o'); - // *m_pDataCur++ = (WCHAR)('s'); - // *m_pDataCur++ = (WCHAR)(';'); - // m_lSizeCur += 6; - // break; - // case 4: - // AddSize(4); - // *m_pDataCur++ = (WCHAR)('&'); - // *m_pDataCur++ = (WCHAR)('l'); - // *m_pDataCur++ = (WCHAR)('t'); - // *m_pDataCur++ = (WCHAR)(';'); - // m_lSizeCur += 4; - // break; - // case 5: - // AddSize(4); - // *m_pDataCur++ = (WCHAR)('&'); - // *m_pDataCur++ = (WCHAR)('g'); - // *m_pDataCur++ = (WCHAR)('t'); - // *m_pDataCur++ = (WCHAR)(';'); - // m_lSizeCur += 4; - // break; - // case 6: - // AddSize(6); - // *m_pDataCur++ = (WCHAR)('&'); - // *m_pDataCur++ = (WCHAR)('q'); - // *m_pDataCur++ = (WCHAR)('u'); - // *m_pDataCur++ = (WCHAR)('o'); - // *m_pDataCur++ = (WCHAR)('t'); - // *m_pDataCur++ = (WCHAR)(';'); - // m_lSizeCur += 6; - // break; - // default: - // break; - // } - // - // ++pData; - // } - // } - - // AVSINLINE size_t GetCurSize() - // { - // return m_lSizeCur; - // } - - // AVSINLINE void Write(CStringWriter& oWriter) - // { - // WriteString(oWriter.m_pData, oWriter.m_lSizeCur); - // } - - // inline void Clear() - // { - // RELEASEMEM(m_pData); - - // m_pData = NULL; - // m_lSize = 0; - - // m_pDataCur = m_pData; - // m_lSizeCur = 0; - // } - // inline void ClearNoAttack() - // { - // m_pDataCur = m_pData; - // m_lSizeCur = 0; - // } - - // std::wstring GetData() - // { - // std::wstring str(m_pData, (int)m_lSizeCur); - // return str; - // } - - //protected: - // BYTE m_arTableUnicodes[65536]; - // bool m_bInitTable; - - //protected: - // BYTE CheckCode(const WCHAR& c) - // { - // if (!m_bInitTable) - // { - // memset(m_arTableUnicodes, 0, 65536); - // m_arTableUnicodes[0x0009] = 1; - // m_arTableUnicodes[0x000A] = 1; - // m_arTableUnicodes[0x000D] = 1; - - // memset(m_arTableUnicodes + 0x0020, 1, 0xD7FF - 0x0020 + 1); - // memset(m_arTableUnicodes + 0xE000, 1, 0xFFFD - 0xE000 + 1); - - // m_arTableUnicodes['&'] = 2; - // m_arTableUnicodes['\''] = 3; - // m_arTableUnicodes['<'] = 4; - // m_arTableUnicodes['>'] = 5; - // m_arTableUnicodes['\"'] = 6; - - // m_bInitTable = true; - // } - // return m_arTableUnicodes[c]; - // } - //}; - - typedef - enum XmlNodeType + typedef enum XmlNodeType { XmlNodeType_None = 0, XmlNodeType_Element = 1, @@ -904,8 +673,8 @@ namespace XmlUtils std::map::iterator p; for (p = m_pBase->m_attributes.begin(); p != m_pBase->m_attributes.end(); ++p) { - strNames.push_back(std_string2string(NSFile::CUtf8Converter::GetUnicodeFromCharPtr(p->first.GetString(), p->first.GetLength(), true))); - strValues.push_back(std_string2string(NSFile::CUtf8Converter::GetUnicodeFromCharPtr(p->second.GetString(), p->second.GetLength(), true))); + strNames.push_back(NSFile::CUtf8Converter::GetUnicodeFromCharPtr(p->first.GetString(), p->first.GetLength(), true)); + strValues.push_back(NSFile::CUtf8Converter::GetUnicodeFromCharPtr(p->second.GetString(), p->second.GetLength(), true)); } } diff --git a/Common/DocxFormat/Source/XML/stringcommon.cpp b/Common/DocxFormat/Source/XML/stringcommon.cpp deleted file mode 100644 index 61dc97d355..0000000000 --- a/Common/DocxFormat/Source/XML/stringcommon.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * (c) Copyright Ascensio System SIA 2010-2016 - * - * 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 Lubanas st. 125a-25, Riga, Latvia, - * EU, LV-1021. - * - * 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 "stdafx.h" -#include "stringcommon.h" - -std::wstring string2std_string(const CString& val) -{ - return std::wstring(val.GetString(), val.GetLength()); -} -std::string string2std_string(const CStringA& val) -{ - return std::string(val.GetString(), val.GetLength()); -} -CString std_string2string(const std::wstring& val) -{ - return CString(val.c_str(), val.length()); -} -CStringA std_string2string(const std::string& val) -{ - return CStringA(val.c_str(), val.length()); -} \ No newline at end of file diff --git a/Common/DocxFormat/Source/XML/stringcommon.h b/Common/DocxFormat/Source/XML/stringcommon.h deleted file mode 100644 index 954b8b9b54..0000000000 --- a/Common/DocxFormat/Source/XML/stringcommon.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * (c) Copyright Ascensio System SIA 2010-2016 - * - * 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 Lubanas st. 125a-25, Riga, Latvia, - * EU, LV-1021. - * - * 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 - * - */ -#ifndef XML_COMMON -#define XML_COMMON - -#include - -#include "../Base/ASCString.h" - -std::wstring string2std_string(const CString& val); -std::string string2std_string(const CStringA& val); -CString std_string2string(const std::wstring& val); -CStringA std_string2string(const std::string& val); - -#endif //XML_COMMON \ No newline at end of file diff --git a/Common/DocxFormat/Source/XML/xmlutils.h b/Common/DocxFormat/Source/XML/xmlutils.h index 26c0b17492..9da9073061 100644 --- a/Common/DocxFormat/Source/XML/xmlutils.h +++ b/Common/DocxFormat/Source/XML/xmlutils.h @@ -32,7 +32,6 @@ #pragma once #include "Utils.h" -#include "stringcommon.h" #include "../Base/Base.h" #include "../../../Base64.h" diff --git a/Common/DocxFormat/Source/XlsxFormat/Drawing/CellAnchor.h b/Common/DocxFormat/Source/XlsxFormat/Drawing/CellAnchor.h index 11fe2acced..5495a92a0a 100644 --- a/Common/DocxFormat/Source/XlsxFormat/Drawing/CellAnchor.h +++ b/Common/DocxFormat/Source/XlsxFormat/Drawing/CellAnchor.h @@ -186,7 +186,7 @@ namespace OOX { //собственно это и есть ссылка на обеъект -> переложим ее "повыше" (для удобства) m_oXml.reset(); - m_sSpId = string2std_string(pExt->m_oCompatExt->m_sSpId.get()); + m_sSpId = pExt->m_oCompatExt->m_sSpId.get(); } } } diff --git a/Common/DocxFormat/Source/XlsxFormat/FileFactory_Spreadsheet.cpp b/Common/DocxFormat/Source/XlsxFormat/FileFactory_Spreadsheet.cpp index df7daa56e6..23efb14f7c 100644 --- a/Common/DocxFormat/Source/XlsxFormat/FileFactory_Spreadsheet.cpp +++ b/Common/DocxFormat/Source/XlsxFormat/FileFactory_Spreadsheet.cpp @@ -58,7 +58,7 @@ namespace OOX { OOX::CPath oRelationFilename = oRelation.Filename(); CPath oFileName; - if(oRelationFilename.GetIsRoot() && oRootPath.GetPath().GetLength() > 0) + if(oRelationFilename.GetIsRoot() && oRootPath.GetPath().length() > 0) oFileName = oRootPath / oRelationFilename; else oFileName = oPath / oRelationFilename; @@ -106,7 +106,7 @@ namespace OOX OOX::CPath oRelationFilename = pRelation->Filename(); CPath oFileName; - if(oRelationFilename.GetIsRoot() && oRootPath.GetPath().GetLength() > 0) + if(oRelationFilename.GetIsRoot() && oRootPath.GetPath().length() > 0) oFileName = oRootPath / oRelationFilename; else oFileName = oPath / oRelationFilename; diff --git a/Common/DocxFormat/Source/XlsxFormat/IFileContainer_Spreadsheet.cpp b/Common/DocxFormat/Source/XlsxFormat/IFileContainer_Spreadsheet.cpp index 28305ef0f9..e920c105e6 100644 --- a/Common/DocxFormat/Source/XlsxFormat/IFileContainer_Spreadsheet.cpp +++ b/Common/DocxFormat/Source/XlsxFormat/IFileContainer_Spreadsheet.cpp @@ -92,14 +92,14 @@ namespace OOX { OOX::CPath oDefDir = pFile->DefaultDirectory(); OOX::CPath oName = pFile->DefaultFileName(); - if(false == pFile->m_sOutputFilename.IsEmpty()) + if(false == pFile->m_sOutputFilename.empty()) oName.SetName(pFile->m_sOutputFilename, false); OOX::CSystemUtility::CreateDirectories( oCurrent / oDefDir ); pFile->write( oCurrent / oDefDir / oName, oDir / oDefDir, oContent ); if(true != pFile->m_bDoNotAddRels) { - if (oDefDir.GetPath().GetLength() > 0)//todooo перенести в CPath + if (oDefDir.GetPath().length() > 0)//todooo перенести в CPath oRels.Registration( pPair->first, pFile->type(), oDefDir / oName ); else oRels.Registration( pPair->first, pFile->type(), oName ); diff --git a/Common/DocxFormat/Source/XlsxFormat/Worksheets/Worksheet.h b/Common/DocxFormat/Source/XlsxFormat/Worksheets/Worksheet.h index 935b2dbd31..6715a34d06 100644 --- a/Common/DocxFormat/Source/XlsxFormat/Worksheets/Worksheet.h +++ b/Common/DocxFormat/Source/XlsxFormat/Worksheets/Worksheet.h @@ -198,7 +198,7 @@ namespace OOX if(pComment->m_oRef.IsInit() && pComment->m_oAuthorId.IsInit()) { int nRow, nCol; - if(CCell::parseRef(string2std_string(pComment->m_oRef->GetValue()), nRow, nCol)) + if(CCell::parseRef(pComment->m_oRef->GetValue(), nRow, nCol)) { CCommentItem* pCommentItem = new CCommentItem(); pCommentItem->m_nRow = nRow - 1; diff --git a/Common/DocxFormat/Source/XlsxFormat/Xlsx.h b/Common/DocxFormat/Source/XlsxFormat/Xlsx.h index f529cfa2fc..3cf53ae4d2 100644 --- a/Common/DocxFormat/Source/XlsxFormat/Xlsx.h +++ b/Common/DocxFormat/Source/XlsxFormat/Xlsx.h @@ -148,7 +148,7 @@ namespace OOX for (std::map>::const_iterator it = aWorksheetsFiles.begin(); it != aWorksheetsFiles.end(); ++it) { - m_aWorksheets [string2std_string(it->first)] = (OOX::Spreadsheet::CWorksheet*) it->second.operator->(); + m_aWorksheets [it->first] = (OOX::Spreadsheet::CWorksheet*) it->second.operator->(); } } @@ -350,7 +350,7 @@ namespace OOX pWorksheet->m_oPageMargins->m_oFooter->FromInches(0.3); smart_ptr pWorksheetFile(pWorksheet); OOX::RId oRId = this->Add(pWorksheetFile); - m_aWorksheets [string2std_string(oRId.ToString())] = pWorksheet; + m_aWorksheets [oRId.ToString()] = pWorksheet; m_pWorkbook->m_oSheets.Init(); OOX::Spreadsheet::CSheet* pSheet = new OOX::Spreadsheet::CSheet(); pSheet->m_oName.Init(); diff --git a/DesktopEditor/common/String.h b/DesktopEditor/common/String.h index b848955618..63bad5c82a 100644 --- a/DesktopEditor/common/String.h +++ b/DesktopEditor/common/String.h @@ -320,7 +320,7 @@ namespace NSStringExt } static unsigned short* GetUtf16FromUnicode(const std::wstring& wsUnicodeText, unsigned int& unLen) { - unsigned int unTextLen = wsUnicodeText.size(); + unsigned int unTextLen = (unsigned int)wsUnicodeText.size(); if (unTextLen <= 0) return NULL; @@ -394,7 +394,7 @@ namespace NSStringExt } static std::vector& Split(const std::wstring& wsString, const std::wstring wsDelim, std::vector &arrElements) { - int nDelimLen = wsDelim.length(); + int nDelimLen = (int)wsDelim.length(); int nPrevPos = 0; if (nDelimLen > 0) diff --git a/X2tConverter/src/ASCConverters.cpp b/X2tConverter/src/ASCConverters.cpp index ba179d5ceb..eb755fbfed 100644 --- a/X2tConverter/src/ASCConverters.cpp +++ b/X2tConverter/src/ASCConverters.cpp @@ -80,7 +80,7 @@ namespace NExtractTools int docx2doct_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) { // Extract docx to temp directory - std::wstring sTempUnpackedDOCX = sTemp + FILE_SEPARATOR_STR + _T("docx_unpacked"); + std::wstring sTempUnpackedDOCX = sTemp + FILE_SEPARATOR_STR + L"docx_unpacked"; FileSystem::Directory::CreateDirectory(sTempUnpackedDOCX); @@ -108,13 +108,9 @@ namespace NExtractTools // Save to file (from temp dir) BinDocxRW::CDocxSerializer m_oCDocxSerializer; - CString sFontPath = std_string2string(params.getFontPath()); - m_oCDocxSerializer.setFontDir(sFontPath); + m_oCDocxSerializer.setFontDir(params.getFontPath()); - //bool bRes = m_oCDocxSerializer.saveToFile (sResDoct, sSrcDocx, sTemp); - int nRes = m_oCDocxSerializer.saveToFile (std_string2string(sTo), std_string2string(sFrom), std_string2string(params.getXmlOptions())) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; - -// sleep(3*60); + int nRes = m_oCDocxSerializer.saveToFile (sTo, sFrom, params.getXmlOptions()) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; return nRes; } @@ -123,8 +119,8 @@ namespace NExtractTools int docx2doct (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) { // Extract docx to temp directory - 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 + L"doct_unpacked"; + std::wstring sResultDoctFileEditor = sResultDoctDir + FILE_SEPARATOR_STR + L"Editor.bin"; FileSystem::Directory::CreateDirectory(sResultDoctDir); @@ -143,7 +139,7 @@ namespace NExtractTools int doct_bin2docx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, bool bFromChanges, const std::wstring &sThemeDir, InputParams& params) { int nRes = 0; - std::wstring sResultDocxDir = sTemp + FILE_SEPARATOR_STR + _T("docx_unpacked"); + std::wstring sResultDocxDir = sTemp + FILE_SEPARATOR_STR + L"docx_unpacked"; FileSystem::Directory::CreateDirectory(sResultDocxDir); @@ -169,20 +165,19 @@ namespace NExtractTools BinDocxRW::CDocxSerializer m_oCDocxSerializer; - CString sFontPath = std_string2string(params.getFontPath()); - m_oCDocxSerializer.setFontDir(sFontPath); + m_oCDocxSerializer.setFontDir(params.getFontPath()); - CString sXmlOptions = _T(""); + CString sXmlOptions; CString sThemePath; // will be filled by 'CreateDocxFolders' method CString sMediaPath; // will be filled by 'CreateDocxFolders' method CString sEmbedPath; // will be filled by 'CreateDocxFolders' method - CString sToDir2 = std_string2string(sTo); + CString sToDir2 = sTo; m_oCDocxSerializer.CreateDocxFolders (sToDir2, sThemePath, sMediaPath, sEmbedPath); if (SUCCEEDED_X2T(nRes)) { - nRes = m_oCDocxSerializer.loadFromFile (std_string2string(sTargetBin), sToDir2, sXmlOptions, sThemePath, sMediaPath, sEmbedPath) ? nRes : AVS_FILEUTILS_ERROR_CONVERT; + nRes = m_oCDocxSerializer.loadFromFile (sTargetBin, sToDir2, sXmlOptions, sThemePath, sMediaPath, sEmbedPath) ? nRes : AVS_FILEUTILS_ERROR_CONVERT; } //удаляем EditorWithChanges, потому что он не в Temp if (sFrom != sTargetBin) @@ -194,8 +189,8 @@ namespace NExtractTools int doct2docx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, bool bFromChanges, const std::wstring &sThemeDir, InputParams& params) { // Extract docx to temp directory - std::wstring sTempUnpackedDOCT = sTemp + FILE_SEPARATOR_STR + _T("doct_unpacked"); - std::wstring sTempDoctFileEditor = sTempUnpackedDOCT + FILE_SEPARATOR_STR + _T("Editor.bin"); + std::wstring sTempUnpackedDOCT = sTemp + FILE_SEPARATOR_STR + L"doct_unpacked"; + std::wstring sTempDoctFileEditor = sTempUnpackedDOCT + FILE_SEPARATOR_STR + L"Editor.bin"; FileSystem::Directory::CreateDirectory(sTempUnpackedDOCT); @@ -211,7 +206,7 @@ namespace NExtractTools int xlsx2xlst_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) { // Extract xlsx to temp directory - std::wstring sTempUnpackedXLSX = sTemp + FILE_SEPARATOR_STR + _T("xlsx_unpacked"); + std::wstring sTempUnpackedXLSX = sTemp + FILE_SEPARATOR_STR + L"xlsx_unpacked"; FileSystem::Directory::CreateDirectory(sTempUnpackedXLSX); @@ -238,19 +233,17 @@ namespace NExtractTools // Save to file (from temp dir) BinXlsxRW::CXlsxSerializer m_oCXlsxSerializer; - CString sFontPath = std_string2string(params.getFontPath()); - m_oCXlsxSerializer.setFontDir(sFontPath); + m_oCXlsxSerializer.setFontDir(params.getFontPath()); - CString sTo1 = std_string2string(sTo); - return m_oCXlsxSerializer.saveToFile (sTo1, std_string2string(sXlsxDir), std_string2string(params.getXmlOptions())) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; + return m_oCXlsxSerializer.saveToFile (sTo, sXlsxDir, params.getXmlOptions()) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; } // xslx -> xslt int xlsx2xlst (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) { // Extract xlsx to temp directory - std::wstring sResultXlstDir = sTemp + FILE_SEPARATOR_STR + _T("xlst_unpacked"); - std::wstring sResultXlstFileEditor = sResultXlstDir + FILE_SEPARATOR_STR + _T("Editor.bin"); + std::wstring sResultXlstDir = sTemp + FILE_SEPARATOR_STR + L"xlst_unpacked"; + std::wstring sResultXlstFileEditor = sResultXlstDir + FILE_SEPARATOR_STR + L"Editor.bin"; FileSystem::Directory::CreateDirectory(sResultXlstDir); @@ -269,7 +262,7 @@ namespace NExtractTools { int nRes = 0; // Extract xlsx to temp directory - std::wstring sResultXlsxDir = sTemp + FILE_SEPARATOR_STR + _T("xlsx_unpacked"); + std::wstring sResultXlsxDir = sTemp + FILE_SEPARATOR_STR + L"xlsx_unpacked"; FileSystem::Directory::CreateDirectory(sResultXlsxDir); @@ -294,18 +287,17 @@ namespace NExtractTools BinXlsxRW::CXlsxSerializer m_oCXlsxSerializer; - CString sFontPath = std_string2string(params.getFontPath()); - m_oCXlsxSerializer.setFontDir(sFontPath); + m_oCXlsxSerializer.setFontDir(params.getFontPath()); - CString sXmlOptions = _T(""); + CString sXmlOptions; CString sMediaPath; // will be filled by 'CreateXlsxFolders' method CString sEmbedPath; // will be filled by 'CreateXlsxFolders' method - m_oCXlsxSerializer.CreateXlsxFolders (sXmlOptions, std_string2string(sTo), sMediaPath, sEmbedPath); + m_oCXlsxSerializer.CreateXlsxFolders (sXmlOptions, sTo, sMediaPath, sEmbedPath); if(SUCCEEDED_X2T(nRes)) { - nRes = m_oCXlsxSerializer.loadFromFile (std_string2string(sTargetBin), std_string2string(sTo), sXmlOptions, sMediaPath, sEmbedPath) ? nRes : AVS_FILEUTILS_ERROR_CONVERT; + nRes = m_oCXlsxSerializer.loadFromFile (sTargetBin, sTo, sXmlOptions, sMediaPath, sEmbedPath) ? nRes : AVS_FILEUTILS_ERROR_CONVERT; } //удаляем EditorWithChanges, потому что он не в Temp if (sFrom != sTargetBin) @@ -317,8 +309,8 @@ namespace NExtractTools int xlst2xlsx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, bool bFromChanges, const std::wstring &sThemeDir, InputParams& params) { // Extract xlsx to temp directory - std::wstring sTempUnpackedXLST = sTemp + FILE_SEPARATOR_STR + _T("xlst_unpacked"); - std::wstring sTempXlstFileEditor = sTempUnpackedXLST + FILE_SEPARATOR_STR + _T("Editor.bin"); + std::wstring sTempUnpackedXLST = sTemp + FILE_SEPARATOR_STR + L"xlst_unpacked"; + std::wstring sTempXlstFileEditor = sTempUnpackedXLST + FILE_SEPARATOR_STR + L"Editor.bin"; FileSystem::Directory::CreateDirectory(sTempUnpackedXLST); @@ -333,7 +325,7 @@ namespace NExtractTools int pptx2pptt_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) { // unzip pptx to temp folder - std::wstring sTempUnpackedPPTX = sTemp + FILE_SEPARATOR_STR + _T("pptx_unpacked")+ FILE_SEPARATOR_STR; // leading slash is very important! + std::wstring sTempUnpackedPPTX = sTemp + FILE_SEPARATOR_STR + L"pptx_unpacked" + FILE_SEPARATOR_STR; // leading slash is very important! FileSystem::Directory::CreateDirectory(sTempUnpackedPPTX); @@ -386,8 +378,8 @@ namespace NExtractTools // pptx -> pptt int pptx2pptt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) { - std::wstring sResultPpttDir = sTemp + FILE_SEPARATOR_STR + _T("pptt_unpacked"); - std::wstring sTempPpttFileEditor = sResultPpttDir + FILE_SEPARATOR_STR + _T("Editor.bin"); + std::wstring sResultPpttDir = sTemp + FILE_SEPARATOR_STR + L"pptt_unpacked"; + std::wstring sTempPpttFileEditor = sResultPpttDir + FILE_SEPARATOR_STR + L"Editor.bin"; FileSystem::Directory::CreateDirectory(sResultPpttDir); @@ -405,7 +397,7 @@ namespace NExtractTools int pptt_bin2pptx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, bool bFromChanges, const std::wstring &sThemeDir, InputParams& params) { int nRes = 0; - std::wstring sResultPptxDir = sTemp + FILE_SEPARATOR_STR + _T("pptx_unpacked"); + std::wstring sResultPptxDir = sTemp + FILE_SEPARATOR_STR + L"pptx_unpacked"; FileSystem::Directory::CreateDirectory(sResultPptxDir); @@ -435,25 +427,10 @@ namespace NExtractTools if (pptx_file) { -#if defined(_WIN32) || defined (_WIN64) - BSTR bstrFontPath = SysAllocString(params.getFontPath().c_str()); - BSTR bstrTargetBin = SysAllocString(sTargetBin.c_str()); - BSTR bstrResultPptxDir = SysAllocString(sTo.c_str()); - BSTR bstrThemeDir = SysAllocString(sThemeDir.c_str()); - - pptx_file->SetFontDir (bstrFontPath); - nRes = (S_OK == pptx_file->ConvertPPTYToPPTX(bstrTargetBin, bstrResultPptxDir, bstrThemeDir)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT; - - SysFreeString(bstrFontPath); - SysFreeString(bstrTargetBin); - SysFreeString(bstrResultPptxDir); - SysFreeString(bstrThemeDir); -#else pptx_file->SetFontDir(params.getFontPath()); - nRes = (S_OK == pptx_file->ConvertPPTYToPPTX(sTargetBin, sTo, sThemeDir)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT; -#endif - delete pptx_file; + + delete pptx_file; } //удаляем EditorWithChanges, потому что он не в Temp if (sFrom != sTargetBin) @@ -465,8 +442,8 @@ namespace NExtractTools int pptt2pptx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, bool bFromChanges, const std::wstring &sThemeDir, InputParams& params) { // unzip pptt to temp folder - std::wstring sTempUnpackedPPTT = sTemp + FILE_SEPARATOR_STR + _T("pptt_unpacked"); - std::wstring sTempPpttFileEditor = sTempUnpackedPPTT + FILE_SEPARATOR_STR + _T("Editor.bin"); + std::wstring sTempUnpackedPPTT = sTemp + FILE_SEPARATOR_STR + L"pptt_unpacked"; + std::wstring sTempPpttFileEditor = sTempUnpackedPPTT + FILE_SEPARATOR_STR + L"Editor.bin"; FileSystem::Directory::CreateDirectory(sTempUnpackedPPTT); @@ -494,9 +471,9 @@ namespace NExtractTools // csv -> xslt int csv2xlst (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) { - CString sCSV = std_string2string(sFrom); - std::wstring sResultXlstDir = sTemp + FILE_SEPARATOR_STR + _T("xlst_unpacked"); - std::wstring sResultXlstFileEditor = sResultXlstDir + FILE_SEPARATOR_STR + _T("Editor.bin"); + CString sCSV = sFrom; + std::wstring sResultXlstDir = sTemp + FILE_SEPARATOR_STR + L"xlst_unpacked"; + std::wstring sResultXlstFileEditor = sResultXlstDir + FILE_SEPARATOR_STR + L"Editor.bin"; FileSystem::Directory::CreateDirectory(sResultXlstDir); @@ -504,10 +481,9 @@ namespace NExtractTools // Save to file (from temp dir) BinXlsxRW::CXlsxSerializer m_oCXlsxSerializer; - CString sFontPath = std_string2string(params.getFontPath()); - m_oCXlsxSerializer.setFontDir(sFontPath); + m_oCXlsxSerializer.setFontDir(params.getFontPath()); - int nRes = m_oCXlsxSerializer.saveToFile (std_string2string(sResultXlstFileEditor), sCSV, std_string2string(params.getXmlOptions())) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; + int nRes = m_oCXlsxSerializer.saveToFile (sResultXlstFileEditor, sCSV, params.getXmlOptions()) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; if (SUCCEEDED_X2T(nRes)) { nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory(sResultXlstDir, sTo, -1)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT; @@ -519,10 +495,10 @@ namespace NExtractTools // csv -> xslx int csv2xlsx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) { - CString sCSV = std_string2string(sFrom); - std::wstring sTempUnpackedXLSX = sTemp + FILE_SEPARATOR_STR + _T("xlsx_unpacked"); - std::wstring sResultXlstDir = sTemp + FILE_SEPARATOR_STR + _T("xlst_unpacked"); - std::wstring sResultXlstFileEditor = sResultXlstDir + FILE_SEPARATOR_STR + _T("Editor.bin"); + CString sCSV = sFrom; + std::wstring sTempUnpackedXLSX = sTemp + FILE_SEPARATOR_STR + L"xlsx_unpacked"; + std::wstring sResultXlstDir = sTemp + FILE_SEPARATOR_STR + L"xlst_unpacked"; + std::wstring sResultXlstFileEditor = sResultXlstDir + FILE_SEPARATOR_STR + L"Editor.bin"; FileSystem::Directory::CreateDirectory(sTempUnpackedXLSX); FileSystem::Directory::CreateDirectory(sResultXlstDir); @@ -530,18 +506,17 @@ namespace NExtractTools // Save to file (from temp dir) BinXlsxRW::CXlsxSerializer m_oCXlsxSerializer; - CString sFontPath = std_string2string(params.getFontPath()); - m_oCXlsxSerializer.setFontDir(sFontPath); + m_oCXlsxSerializer.setFontDir(params.getFontPath()); COfficeUtils oCOfficeUtils(NULL); CString sMediaPath; CString sEmbedPath; - int nRes = m_oCXlsxSerializer.saveToFile (std_string2string(sResultXlstFileEditor), sCSV, std_string2string(params.getXmlOptions())) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; + int nRes = m_oCXlsxSerializer.saveToFile (sResultXlstFileEditor, sCSV, params.getXmlOptions()) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; if (SUCCEEDED_X2T(nRes)) { - nRes = m_oCXlsxSerializer.loadFromFile(std_string2string(sResultXlstFileEditor), std_string2string(sTempUnpackedXLSX), std_string2string(params.getXmlOptions()), sMediaPath, sEmbedPath) ? nRes : AVS_FILEUTILS_ERROR_CONVERT; + nRes = m_oCXlsxSerializer.loadFromFile(sResultXlstFileEditor, sTempUnpackedXLSX, params.getXmlOptions(), sMediaPath, sEmbedPath) ? nRes : AVS_FILEUTILS_ERROR_CONVERT; if (SUCCEEDED_X2T(nRes)) { nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory(sTempUnpackedXLSX, sTo, -1)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT; @@ -555,17 +530,15 @@ namespace NExtractTools // Save to file (from temp dir) BinXlsxRW::CXlsxSerializer m_oCXlsxSerializer; - CString sFontPath = std_string2string(params.getFontPath()); - m_oCXlsxSerializer.setFontDir(sFontPath); + m_oCXlsxSerializer.setFontDir(params.getFontPath()); - return m_oCXlsxSerializer.saveToFile(std_string2string(sTo), std_string2string(sFrom), std_string2string(params.getXmlOptions())) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; + return m_oCXlsxSerializer.saveToFile(sTo, sFrom, params.getXmlOptions()) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; } // xlst -> csv int xlst2csv (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) { - CString sCSV = std_string2string(sTo); - std::wstring sTempUnpackedXLST = sTemp + FILE_SEPARATOR_STR + _T("xlst_unpacked"); - std::wstring sTempXlstFileEditor = sTempUnpackedXLST + FILE_SEPARATOR_STR + _T("Editor.bin"); + std::wstring sTempUnpackedXLST = sTemp + FILE_SEPARATOR_STR + L"xlst_unpacked"; + std::wstring sTempXlstFileEditor = sTempUnpackedXLST + FILE_SEPARATOR_STR + L"Editor.bin"; FileSystem::Directory::CreateDirectory(sTempUnpackedXLST); @@ -577,21 +550,19 @@ namespace NExtractTools BinXlsxRW::CXlsxSerializer m_oCXlsxSerializer; - CString sFontPath = std_string2string(params.getFontPath()); - m_oCXlsxSerializer.setFontDir(sFontPath); + m_oCXlsxSerializer.setFontDir(params.getFontPath()); CString sMediaPath; CString sEmbedPath; - return m_oCXlsxSerializer.loadFromFile (std_string2string(sTempXlstFileEditor), sCSV, std_string2string(params.getXmlOptions()), sMediaPath, sEmbedPath) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; + return m_oCXlsxSerializer.loadFromFile (sTempXlstFileEditor, sTo, params.getXmlOptions(), sMediaPath, sEmbedPath) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; } // xslx -> csv int xlsx2csv (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) { - CString sCSV = std_string2string(sTo); - std::wstring sTempUnpackedXLSX = sTemp + FILE_SEPARATOR_STR + _T("xlsx_unpacked"); - std::wstring sResultXlstDir = sTemp + FILE_SEPARATOR_STR + _T("xlst_unpacked"); - std::wstring sResultXlstFileEditor = sResultXlstDir + FILE_SEPARATOR_STR + _T("Editor.bin"); + std::wstring sTempUnpackedXLSX = sTemp + FILE_SEPARATOR_STR + L"xlsx_unpacked"; + std::wstring sResultXlstDir = sTemp + FILE_SEPARATOR_STR + L"xlst_unpacked"; + std::wstring sResultXlstFileEditor = sResultXlstDir + FILE_SEPARATOR_STR + L"Editor.bin"; FileSystem::Directory::CreateDirectory(sTempUnpackedXLSX); FileSystem::Directory::CreateDirectory(sResultXlstDir); @@ -603,17 +574,16 @@ namespace NExtractTools // Save to file (from temp dir) BinXlsxRW::CXlsxSerializer m_oCXlsxSerializer; - CString sFontPath = std_string2string(params.getFontPath()); - m_oCXlsxSerializer.setFontDir(sFontPath); + m_oCXlsxSerializer.setFontDir(params.getFontPath()); - CString sXMLOptions = _T(""); - int nRes = m_oCXlsxSerializer.saveToFile (std_string2string(sResultXlstFileEditor), std_string2string(sTempUnpackedXLSX), sXMLOptions) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; + CString sXMLOptions; + int nRes = m_oCXlsxSerializer.saveToFile (sResultXlstFileEditor, sTempUnpackedXLSX, sXMLOptions) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; if (SUCCEEDED_X2T(nRes)) { CString sMediaPath; CString sEmbedPath; - nRes = m_oCXlsxSerializer.loadFromFile (std_string2string(sResultXlstDir), sCSV, sXMLOptions, sMediaPath, sEmbedPath) ? nRes : AVS_FILEUTILS_ERROR_CONVERT; + nRes = m_oCXlsxSerializer.loadFromFile (sResultXlstDir, sTo, sXMLOptions, sMediaPath, sEmbedPath) ? nRes : AVS_FILEUTILS_ERROR_CONVERT; } return nRes; @@ -634,17 +604,16 @@ namespace NExtractTools // Save to file (from temp dir) BinXlsxRW::CXlsxSerializer m_oCXlsxSerializer; - CString sFontPath = std_string2string(params.getFontPath()); - m_oCXlsxSerializer.setFontDir(sFontPath); + m_oCXlsxSerializer.setFontDir(params.getFontPath()); - std::wstring sToTemp = sTemp + FILE_SEPARATOR_STR + _T("output.csv"); + std::wstring sToTemp = sTemp + FILE_SEPARATOR_STR + L"output.csv"; CString sMediaPath; // will be filled by 'CreateXlsxFolders' method CString sEmbedPath; // will be filled by 'CreateXlsxFolders' method - CString sXmlOptions = std_string2string(params.getXmlOptions()); + CString sXmlOptions = params.getXmlOptions(); - m_oCXlsxSerializer.CreateXlsxFolders (sXmlOptions, std_string2string(sTemp), sMediaPath, sEmbedPath); + m_oCXlsxSerializer.CreateXlsxFolders (sXmlOptions, sTemp, sMediaPath, sEmbedPath); - nRes = m_oCXlsxSerializer.loadFromFile(std_string2string(sTargetBin), std_string2string(sToTemp), sXmlOptions, sMediaPath, sEmbedPath) ? nRes : AVS_FILEUTILS_ERROR_CONVERT; + nRes = m_oCXlsxSerializer.loadFromFile(sTargetBin, sToTemp, sXmlOptions, sMediaPath, sEmbedPath) ? nRes : AVS_FILEUTILS_ERROR_CONVERT; //пишем в Temp и копируем, чтобы не возникало лишних файлов рядом с sTo, а лучше перейти на отдельный метод if(SUCCEEDED_X2T(nRes)) @@ -670,16 +639,19 @@ namespace NExtractTools { int nRes = 0; NSDoctRenderer::DoctRendererFormat::FormatFile eToType = NSDoctRenderer::DoctRendererFormat::FormatFile::PDF; - std::wstring sTFileDir = FileSystem::Directory::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 sTFileDir = FileSystem::Directory::GetFolderPath(sFrom); + + std::wstring sImagesDirectory = sTFileDir + FILE_SEPARATOR_STR + L"media"; + std::wstring sPdfBinFile = sTFileDir + FILE_SEPARATOR_STR + L"pdf.bin"; + + NSDoctRenderer::CDoctrenderer oDoctRenderer(NULL != params.m_sAllFontsPath ? *params.m_sAllFontsPath : L""); + std::wstring sXml = getDoctXml(eFromType, eToType, sTFileDir, sPdfBinFile, sImagesDirectory, sThemeDir, -1, L"", params); std::wstring sResult; bool bRes = oDoctRenderer.Execute(sXml, sResult); - if (-1 != sResult.find(_T("error"))) + if (-1 != sResult.find(L"error")) { - std::wcerr << _T("DoctRenderer:") << sResult << std::endl; + std::wcerr << L"DoctRenderer:" << sResult << std::endl; nRes = AVS_FILEUTILS_ERROR_CONVERT; } else @@ -702,16 +674,19 @@ namespace NExtractTools { int nRes = 0; NSDoctRenderer::DoctRendererFormat::FormatFile eToType = NSDoctRenderer::DoctRendererFormat::FormatFile::PDF; + std::wstring sTFileDir = FileSystem::Directory::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 sImagesDirectory = sTFileDir + FILE_SEPARATOR_STR + L"media"; + std::wstring sPdfBinFile = sTFileDir + FILE_SEPARATOR_STR + L"pdf.bin"; + + NSDoctRenderer::CDoctrenderer oDoctRenderer(NULL != params.m_sAllFontsPath ? *params.m_sAllFontsPath : L""); + std::wstring sXml = getDoctXml(eFromType, eToType, sTFileDir, sPdfBinFile, sImagesDirectory, sThemeDir, -1, L"", params); std::wstring sResult; bool bRes = oDoctRenderer.Execute(sXml, sResult); - if (-1 != sResult.find(_T("error"))) + if (-1 != sResult.find(L"error")) { - std::wcerr << _T("DoctRenderer:") << sResult << std::endl; + std::wcerr << L"DoctRenderer:" << sResult << std::endl; nRes = AVS_FILEUTILS_ERROR_CONVERT; } else @@ -754,7 +729,7 @@ namespace NExtractTools } else { - sThumbnailDir = sTemp + FILE_SEPARATOR_STR + _T("thumbnails"); + sThumbnailDir = sTemp + FILE_SEPARATOR_STR + L"thumbnails"; FileSystem::Directory::CreateDirectory(sThumbnailDir); std::wstring::size_type pos = sTo.find_last_of('.'); std::wstring sExt = std::wstring::npos == pos ? L"" : sTo.substr(pos); @@ -776,7 +751,7 @@ namespace NExtractTools // ppsx -> pptx int ppsx2pptx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) { - std::wstring sTempUnpackedPPSX = sTemp + FILE_SEPARATOR_STR + _T("ppsx_unpacked"); + std::wstring sTempUnpackedPPSX = sTemp + FILE_SEPARATOR_STR + L"ppsx_unpacked"; FileSystem::Directory::CreateDirectory(sTempUnpackedPPSX); int nRes = ppsx2pptx_dir(sFrom, sTempUnpackedPPSX, params); @@ -793,14 +768,14 @@ namespace NExtractTools COfficeUtils oCOfficeUtils(NULL); if (S_OK == oCOfficeUtils.ExtractToDirectory(sFrom, sTo, NULL, 0)) { - std::wstring sContentTypesPath = sTo + FILE_SEPARATOR_STR + _T("[Content_Types].xml"); + std::wstring sContentTypesPath = sTo + FILE_SEPARATOR_STR + L"[Content_Types].xml"; if(NSFile::CFileBinary::Exists(sContentTypesPath)) { std::wstring sData; if(NSFile::CFileBinary::ReadAllTextUtf8(sContentTypesPath, sData)) { - std::wstring sCTFrom = _T("application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml"); - std::wstring sCTTo = _T("application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml"); + std::wstring sCTFrom = L"application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml"; + std::wstring sCTTo = L"application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml"; sData = string_replaceAll(sData, sCTFrom, sCTTo); @@ -817,7 +792,7 @@ namespace NExtractTools // ppt -> pptx int ppt2pptx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) { - std::wstring sResultPptxDir = sTemp + FILE_SEPARATOR_STR + _T("pptx_unpacked"); + std::wstring sResultPptxDir = sTemp + FILE_SEPARATOR_STR + L"pptx_unpacked"; FileSystem::Directory::CreateDirectory(sResultPptxDir); @@ -840,8 +815,8 @@ namespace NExtractTools // ppt -> pptt int ppt2pptt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) { - std::wstring sResultPpttDir = sTemp + FILE_SEPARATOR_STR + _T("pptt_unpacked"); - std::wstring sTempPpttFileEditor = sResultPpttDir + FILE_SEPARATOR_STR + _T("Editor.bin"); + std::wstring sResultPpttDir = sTemp + FILE_SEPARATOR_STR + L"pptt_unpacked"; + std::wstring sTempPpttFileEditor = sResultPpttDir + FILE_SEPARATOR_STR + L"Editor.bin"; FileSystem::Directory::CreateDirectory(sResultPpttDir); @@ -858,7 +833,7 @@ namespace NExtractTools int ppt2pptt_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) { // unzip pptx to temp folder - std::wstring sTempUnpackedPPTX = sTemp + FILE_SEPARATOR_STR + _T("pptx_unpacked")+ FILE_SEPARATOR_STR; // leading slash is very important! + std::wstring sTempUnpackedPPTX = sTemp + FILE_SEPARATOR_STR + L"pptx_unpacked"+ FILE_SEPARATOR_STR; // leading slash is very important! FileSystem::Directory::CreateDirectory(sTempUnpackedPPTX); @@ -899,7 +874,7 @@ namespace NExtractTools // rtf -> docx int rtf2docx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) { - std::wstring sResultDocxDir = sTemp + FILE_SEPARATOR_STR + _T("docx_unpacked"); + std::wstring sResultDocxDir = sTemp + FILE_SEPARATOR_STR + L"docx_unpacked"; FileSystem::Directory::CreateDirectory(sResultDocxDir); int nRes = rtf2docx_dir(sFrom, sResultDocxDir, sTemp, params); @@ -922,8 +897,8 @@ namespace NExtractTools int rtf2doct (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) { // Extract docx to temp directory - 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 + L"doct_unpacked"; + std::wstring sResultDoctFileEditor = sResultDoctDir + FILE_SEPARATOR_STR + L"Editor.bin"; FileSystem::Directory::CreateDirectory(sResultDoctDir); @@ -941,7 +916,7 @@ namespace NExtractTools // rtf -> doct_bin int rtf2doct_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) { - std::wstring sResultDocxDir = sTemp + FILE_SEPARATOR_STR + _T("docx_unpacked"); + std::wstring sResultDocxDir = sTemp + FILE_SEPARATOR_STR + L"docx_unpacked"; FileSystem::Directory::CreateDirectory(sResultDocxDir); RtfConvertationManager rtfConvert; @@ -952,12 +927,10 @@ namespace NExtractTools { BinDocxRW::CDocxSerializer m_oCDocxSerializer; - CString sFontPath = std_string2string(params.getFontPath()); - - m_oCDocxSerializer.setFontDir(sFontPath); + m_oCDocxSerializer.setFontDir(params.getFontPath()); CString sXmlOptions; - int res = m_oCDocxSerializer.saveToFile (std_string2string(sTo), std_string2string(sResultDocxDir), sXmlOptions) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; + int res = m_oCDocxSerializer.saveToFile (sTo, sResultDocxDir, sXmlOptions) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; return res; @@ -968,7 +941,7 @@ namespace NExtractTools // docx -> rtf int docx2rtf (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) { - std::wstring sTempUnpackedDOCX = sTemp + FILE_SEPARATOR_STR + _T("docx_unpacked"); + std::wstring sTempUnpackedDOCX = sTemp + FILE_SEPARATOR_STR + L"docx_unpacked"; FileSystem::Directory::CreateDirectory(sTempUnpackedDOCX); COfficeUtils oCOfficeUtils(NULL); @@ -993,7 +966,7 @@ namespace NExtractTools // doc -> docx int doc2docx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) { - std::wstring sResultDocxDir = sTemp + FILE_SEPARATOR_STR + _T("docx_unpacked"); + std::wstring sResultDocxDir = sTemp + FILE_SEPARATOR_STR + L"docx_unpacked"; FileSystem::Directory::CreateDirectory(sResultDocxDir); @@ -1042,8 +1015,8 @@ namespace NExtractTools int doc2doct (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) { // Extract docx to temp directory - 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 + L"doct_unpacked"; + std::wstring sResultDoctFileEditor = sResultDoctDir + FILE_SEPARATOR_STR + L"Editor.bin"; FileSystem::Directory::CreateDirectory(sResultDoctDir); @@ -1061,7 +1034,7 @@ namespace NExtractTools // doc -> doct_bin int doc2doct_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) { - std::wstring sResultDocxDir = sTemp + FILE_SEPARATOR_STR + _T("docx_unpacked"); + std::wstring sResultDocxDir = sTemp + FILE_SEPARATOR_STR + L"docx_unpacked"; FileSystem::Directory::CreateDirectory(sResultDocxDir); @@ -1074,12 +1047,11 @@ namespace NExtractTools { BinDocxRW::CDocxSerializer m_oCDocxSerializer; - CString sFontPath = std_string2string(params.getFontPath()); - m_oCDocxSerializer.setFontDir(sFontPath); + m_oCDocxSerializer.setFontDir(params.getFontPath()); std::wstring xml_options = params.getXmlOptions(); - int res = m_oCDocxSerializer.saveToFile (std_string2string(sTo), std_string2string(sResultDocxDir), std_string2string(xml_options)) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; + int res = m_oCDocxSerializer.saveToFile (sTo, sResultDocxDir, xml_options) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; return res; } @@ -1108,8 +1080,8 @@ namespace NExtractTools int doct2rtf (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, bool bFromChanges, const std::wstring &sThemeDir, InputParams& params) { // Extract docx to temp directory - std::wstring sTempUnpackedDOCT = sTemp + FILE_SEPARATOR_STR + _T("doct_unpacked"); - std::wstring sTempDoctFileEditor = sTempUnpackedDOCT + FILE_SEPARATOR_STR + _T("Editor.bin"); + std::wstring sTempUnpackedDOCT = sTemp + FILE_SEPARATOR_STR + L"doct_unpacked"; + std::wstring sTempDoctFileEditor = sTempUnpackedDOCT + FILE_SEPARATOR_STR + L"Editor.bin"; FileSystem::Directory::CreateDirectory(sTempUnpackedDOCT); @@ -1125,22 +1097,21 @@ namespace NExtractTools int doct_bin2rtf (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, bool bFromChanges, const std::wstring &sThemeDir, InputParams& params) { int nRes = 0; - CString sResultDocxDir = std_string2string(sTemp) + FILE_SEPARATOR_STR + _T("docx_unpacked"); + std::wstring sResultDocxDir = sTemp + FILE_SEPARATOR_STR + L"docx_unpacked"; FileSystem::Directory::CreateDirectory(sResultDocxDir); std::wstring sTargetBin; if(bFromChanges) - nRes = apply_changes(sFrom, _T(""), NSDoctRenderer::DoctRendererFormat::FormatFile::DOCT, sThemeDir, sTargetBin, params); + nRes = apply_changes(sFrom, L"", NSDoctRenderer::DoctRendererFormat::FormatFile::DOCT, sThemeDir, sTargetBin, params); else sTargetBin = sFrom; BinDocxRW::CDocxSerializer m_oCDocxSerializer; - CString sFontPath = std_string2string(params.getFontPath()); - m_oCDocxSerializer.setFontDir(sFontPath); + m_oCDocxSerializer.setFontDir(params.getFontPath()); - CString sXmlOptions = _T(""); + CString sXmlOptions; CString sThemePath; // will be filled by 'CreateDocxFolders' method CString sMediaPath; // will be filled by 'CreateDocxFolders' method CString sEmbedPath; // will be filled by 'CreateDocxFolders' method @@ -1149,7 +1120,7 @@ namespace NExtractTools if (SUCCEEDED_X2T(nRes)) { - nRes = m_oCDocxSerializer.loadFromFile (std_string2string(sTargetBin), sResultDocxDir, sXmlOptions, sThemePath, sMediaPath, sEmbedPath) ? nRes : AVS_FILEUTILS_ERROR_CONVERT; + nRes = m_oCDocxSerializer.loadFromFile (sTargetBin, sResultDocxDir, sXmlOptions, sThemePath, sMediaPath, sEmbedPath) ? nRes : AVS_FILEUTILS_ERROR_CONVERT; if (SUCCEEDED_X2T(nRes)) { //docx folder to rtf @@ -1157,7 +1128,7 @@ namespace NExtractTools rtfConvert.m_sTempFolder = sTemp; - if (rtfConvert.ConvertOOXToRtf(sTo, string2std_string(sResultDocxDir)) == S_OK) + if (rtfConvert.ConvertOOXToRtf(sTo, sResultDocxDir) == S_OK) return 0; } } @@ -1169,7 +1140,7 @@ namespace NExtractTools // txt -> docx int txt2docx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) { - std::wstring sResultDocxDir = sTemp + FILE_SEPARATOR_STR + _T("docx_unpacked"); + std::wstring sResultDocxDir = sTemp + FILE_SEPARATOR_STR + L"docx_unpacked"; FileSystem::Directory::CreateDirectory(sResultDocxDir); int nRes = txt2docx_dir(sFrom, sResultDocxDir, sTemp, params); @@ -1192,8 +1163,8 @@ namespace NExtractTools // txt -> doct int txt2doct (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 + L"doct_unpacked"; + std::wstring sResultDoctFileEditor = sResultDoctDir + FILE_SEPARATOR_STR + L"Editor.bin"; FileSystem::Directory::CreateDirectory(sResultDoctDir); @@ -1211,7 +1182,7 @@ namespace NExtractTools // txt -> doct_bin int txt2doct_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) { - std::wstring sResultDocxDir = sTemp + FILE_SEPARATOR_STR + _T("docx_unpacked"); + std::wstring sResultDocxDir = sTemp + FILE_SEPARATOR_STR + L"docx_unpacked"; FileSystem::Directory::CreateDirectory(sResultDocxDir); @@ -1223,10 +1194,9 @@ namespace NExtractTools { BinDocxRW::CDocxSerializer m_oCDocxSerializer; - CString sFontPath = std_string2string(params.getFontPath()); - m_oCDocxSerializer.setFontDir(sFontPath); + m_oCDocxSerializer.setFontDir(params.getFontPath()); - int res = m_oCDocxSerializer.saveToFile (std_string2string(sTo), std_string2string(sResultDocxDir), std_string2string(params.getXmlOptions())) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; + int res = m_oCDocxSerializer.saveToFile (sTo, sResultDocxDir, params.getXmlOptions()) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; return res; @@ -1242,8 +1212,8 @@ namespace NExtractTools int odf2oot(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 + L"doct_unpacked"; + std::wstring sResultDoctFileEditor = sResultDoctDir + FILE_SEPARATOR_STR + L"Editor.bin"; FileSystem::Directory::CreateDirectory(sResultDoctDir); @@ -1260,8 +1230,8 @@ namespace NExtractTools int odf2oot_bin(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params) { - std::wstring sTempUnpackedOdf = sTemp + FILE_SEPARATOR_STR + _T("odf_unpacked"); - std::wstring sTempUnpackedOox = sTemp + FILE_SEPARATOR_STR + _T("oox_unpacked"); + std::wstring sTempUnpackedOdf = sTemp + FILE_SEPARATOR_STR + L"odf_unpacked"; + std::wstring sTempUnpackedOox = sTemp + FILE_SEPARATOR_STR + L"oox_unpacked"; FileSystem::Directory::CreateDirectory(sTempUnpackedOdf); @@ -1275,10 +1245,9 @@ namespace NExtractTools { BinDocxRW::CDocxSerializer m_oCDocxSerializer; - CString sFontPath = std_string2string(params.getFontPath()); - m_oCDocxSerializer.setFontDir(sFontPath); + m_oCDocxSerializer.setFontDir(params.getFontPath()); - int res = m_oCDocxSerializer.saveToFile (std_string2string(sTo), std_string2string(sTempUnpackedOox), std_string2string(params.getXmlOptions())) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; + int res = m_oCDocxSerializer.saveToFile (sTo, sTempUnpackedOox, params.getXmlOptions()) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; return res; } @@ -1288,7 +1257,7 @@ namespace NExtractTools int odf2oox(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params) { - std::wstring sTempUnpackedOox = sTemp + FILE_SEPARATOR_STR + _T("oox_unpacked"); + std::wstring sTempUnpackedOox = sTemp + FILE_SEPARATOR_STR + L"oox_unpacked"; FileSystem::Directory::CreateDirectory(sTempUnpackedOox); int nRes = odf2oox_dir(sFrom, sTempUnpackedOox, sTemp, params); @@ -1301,7 +1270,7 @@ namespace NExtractTools } int odf2oox_dir(const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params) { - std::wstring sTempUnpackedOdf = sTemp + FILE_SEPARATOR_STR + _T("odf_unpacked"); + std::wstring sTempUnpackedOdf = sTemp + FILE_SEPARATOR_STR + L"odf_unpacked"; FileSystem::Directory::CreateDirectory(sTempUnpackedOdf); COfficeUtils oCOfficeUtils(NULL); @@ -1313,7 +1282,7 @@ namespace NExtractTools // docx -> odt int docx2odt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params ) { - std::wstring sTempUnpackedDOCX = sTemp + FILE_SEPARATOR_STR + _T("docx_unpacked"); + std::wstring sTempUnpackedDOCX = sTemp + FILE_SEPARATOR_STR + L"docx_unpacked"; FileSystem::Directory::CreateDirectory(sTempUnpackedDOCX); COfficeUtils oCOfficeUtils(NULL); @@ -1326,10 +1295,10 @@ namespace NExtractTools // docx dir -> odt int docx_dir2odt (const std::wstring &sDocxDir, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params ) { - std::wstring sTempUnpackedODT = sTemp + FILE_SEPARATOR_STR + _T("odt_unpacked"); + std::wstring sTempUnpackedODT = sTemp + FILE_SEPARATOR_STR + L"odt_unpacked"; FileSystem::Directory::CreateDirectory(sTempUnpackedODT); - Oox2Odf::Converter converter(sDocxDir, _T("text"), params.getFontPath(), NULL); + Oox2Odf::Converter converter(sDocxDir, L"text", params.getFontPath(), NULL); int nRes = 0; try @@ -1348,7 +1317,7 @@ namespace NExtractTools // xlsx -> ods int xlsx2ods (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params ) { - std::wstring sTempUnpackedXLSX = sTemp + FILE_SEPARATOR_STR + _T("xlsx_unpacked"); + std::wstring sTempUnpackedXLSX = sTemp + FILE_SEPARATOR_STR + L"xlsx_unpacked"; FileSystem::Directory::CreateDirectory(sTempUnpackedXLSX); @@ -1362,12 +1331,12 @@ namespace NExtractTools int xlsx_dir2ods (const std::wstring &sXlsxDir, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) { - std::wstring sTempUnpackedODS = sTemp + FILE_SEPARATOR_STR + _T("ods_unpacked"); + std::wstring sTempUnpackedODS = sTemp + FILE_SEPARATOR_STR + L"ods_unpacked"; FileSystem::Directory::CreateDirectory(sTempUnpackedODS); try { - Oox2Odf::Converter converter(sXlsxDir, _T("spreadsheet"),params.getFontPath(), NULL); + Oox2Odf::Converter converter(sXlsxDir, L"spreadsheet",params.getFontPath(), NULL); converter.convert(); converter.write(sTempUnpackedODS); @@ -1384,8 +1353,8 @@ namespace NExtractTools int mscrypt2oot (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params) { - std::wstring sResultOotDir = sTemp + FILE_SEPARATOR_STR + _T("oot_unpacked"); - std::wstring sResultOotFileEditor = sResultOotDir + FILE_SEPARATOR_STR + _T("Editor.bin"); + std::wstring sResultOotDir = sTemp + FILE_SEPARATOR_STR + L"oot_unpacked"; + std::wstring sResultOotFileEditor = sResultOotDir + FILE_SEPARATOR_STR + L"Editor.bin"; FileSystem::Directory::CreateDirectory(sResultOotDir); @@ -1519,7 +1488,7 @@ namespace NExtractTools } int epub2doct_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) { - std::wstring sEpubDir = sTemp + FILE_SEPARATOR_STR + _T("epub_unpacked"); + std::wstring sEpubDir = sTemp + FILE_SEPARATOR_STR + L"epub_unpacked"; FileSystem::Directory::CreateDirectory(sEpubDir); int nRes = zip2dir(sFrom, sEpubDir); if(SUCCEEDED_X2T(nRes)) @@ -1537,39 +1506,40 @@ namespace NExtractTools if(NULL == oMailMergeSend.mailFormat || NULL == oMailMergeSend.recordFrom || NULL == oMailMergeSend.recordTo) return AVS_FILEUTILS_ERROR_CONVERT; int nRes = 0; - std::wstring sFileFromDir = NSSystemPath::GetDirectoryName(sFrom); - std::wstring sFileToDir = NSSystemPath::GetDirectoryName(sTo); - std::wstring sImagesDirectory = sFileFromDir + FILE_SEPARATOR_STR +_T("media"); + std::wstring sFileFromDir = NSSystemPath::GetDirectoryName(sFrom); + std::wstring sFileToDir = NSSystemPath::GetDirectoryName(sTo); + std::wstring sImagesDirectory = sFileFromDir + FILE_SEPARATOR_STR +L"media"; + NSDoctRenderer::DoctRendererFormat::FormatFile eTypeTo; switch(*oMailMergeSend.mailFormat) { - case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX:eTypeTo = NSDoctRenderer::DoctRendererFormat::FormatFile::DOCT;break; - case AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF:eTypeTo = NSDoctRenderer::DoctRendererFormat::FormatFile::PDF;break; - case AVS_OFFICESTUDIO_FILE_OTHER_HTMLZIP:eTypeTo = NSDoctRenderer::DoctRendererFormat::FormatFile::HTML;break; - default:eTypeTo = NSDoctRenderer::DoctRendererFormat::FormatFile::HTML;break; + case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX: eTypeTo = NSDoctRenderer::DoctRendererFormat::FormatFile::DOCT; break; + case AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF: eTypeTo = NSDoctRenderer::DoctRendererFormat::FormatFile::PDF; break; + case AVS_OFFICESTUDIO_FILE_OTHER_HTMLZIP: eTypeTo = NSDoctRenderer::DoctRendererFormat::FormatFile::HTML; break; + default: eTypeTo = NSDoctRenderer::DoctRendererFormat::FormatFile::HTML; break; } - std::wstring sJsonPath = sFileFromDir + FILE_SEPARATOR_STR +_T("Editor.json"); + std::wstring sJsonPath = sFileFromDir + FILE_SEPARATOR_STR + L"Editor.json"; int recordTo = *oMailMergeSend.recordFrom + 4; if(recordTo > *oMailMergeSend.recordTo) recordTo = *oMailMergeSend.recordTo; - NSDoctRenderer::CDoctrenderer oDoctRenderer(NULL != params.m_sAllFontsPath ? *params.m_sAllFontsPath : _T("")); + NSDoctRenderer::CDoctrenderer oDoctRenderer(NULL != params.m_sAllFontsPath ? *params.m_sAllFontsPath : L""); std::wstring sMailMergeXml = getMailMergeXml(sJsonPath, *oMailMergeSend.recordFrom, recordTo, *oMailMergeSend.to); //посылаем выходную папку sFileFromDir, чтобы файлы лежали на одном уровне с папкой media, важно для дальнейшей конвертации в docx, pdf std::wstring sXml = getDoctXml(NSDoctRenderer::DoctRendererFormat::FormatFile::DOCT, eTypeTo, sFileFromDir, sFileFromDir, sImagesDirectory, sThemeDir, -1, sMailMergeXml, params); std::wstring sResult; oDoctRenderer.Execute(sXml, sResult); - if (-1 != sResult.find(_T("error"))) + if (-1 != sResult.find(L"error")) { - std::wcerr << _T("DoctRenderer:") << sResult << std::endl; + std::wcerr << L"DoctRenderer:" << sResult << std::endl; nRes = AVS_FILEUTILS_ERROR_CONVERT; } else { nRes = AVS_FILEUTILS_ERROR_CONVERT; XmlUtils::CXmlNode oRoot; - if(TRUE == oRoot.FromXmlString(std_string2string(sResult))) + if(TRUE == oRoot.FromXmlString(sResult)) { - XmlUtils::CXmlNode oMailMergeFields = oRoot.ReadNode(_T("MailMergeFields")); + XmlUtils::CXmlNode oMailMergeFields = oRoot.ReadNode(L"MailMergeFields"); XmlUtils::CXmlNodes oXmlNodes; if(TRUE == oMailMergeFields.GetChilds(oXmlNodes)) { @@ -1578,28 +1548,28 @@ namespace NExtractTools XmlUtils::CXmlNode oXmlNode; if(oXmlNodes.GetAt(i, oXmlNode)) { - std::wstring sFilePathIn = string2std_string(oXmlNode.GetAttribute(_T("path"))); - std::wstring wsFilePathInFilename = NSSystemPath::GetFileName(sFilePathIn); - std::wstring sFilePathOut = sFileToDir + FILE_SEPARATOR_STR + wsFilePathInFilename; - if (NSDoctRenderer::DoctRendererFormat::FormatFile::DOCT == eTypeTo) + std::wstring sFilePathIn = oXmlNode.GetAttribute(L"path"); + std::wstring wsFilePathInFilename = NSSystemPath::GetFileName(sFilePathIn); + std::wstring sFilePathOut = sFileToDir + FILE_SEPARATOR_STR + wsFilePathInFilename; + + if (NSDoctRenderer::DoctRendererFormat::FormatFile::DOCT == eTypeTo) { - sFilePathOut += _T(".docx"); + sFilePathOut += L".docx"; - std::wstring sTempDocx = sTemp + FILE_SEPARATOR_STR + wsFilePathInFilename + _T("_DOCX"); + std::wstring sTempDocx = sTemp + FILE_SEPARATOR_STR + wsFilePathInFilename + L"_DOCX"; FileSystem::Directory::CreateDirectory(sTempDocx); BinDocxRW::CDocxSerializer m_oCDocxSerializer; - CString sFontPath = std_string2string(params.getFontPath()); - m_oCDocxSerializer.setFontDir(sFontPath); + m_oCDocxSerializer.setFontDir(params.getFontPath()); - CString sXmlOptions = _T(""); + CString sXmlOptions = L""; CString sThemePath; // will be filled by 'CreateDocxFolders' method CString sMediaPath; // will be filled by 'CreateDocxFolders' method CString sEmbedPath; // will be filled by 'CreateDocxFolders' method - m_oCDocxSerializer.CreateDocxFolders (std_string2string(sTempDocx), sThemePath, sMediaPath, sEmbedPath); - nRes = m_oCDocxSerializer.loadFromFile (std_string2string(sFilePathIn), std_string2string(sTempDocx), sXmlOptions, sThemePath, sMediaPath, sEmbedPath) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; + m_oCDocxSerializer.CreateDocxFolders (sTempDocx, sThemePath, sMediaPath, sEmbedPath); + nRes = m_oCDocxSerializer.loadFromFile (sFilePathIn, sTempDocx, sXmlOptions, sThemePath, sMediaPath, sEmbedPath) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; if(SUCCEEDED_X2T(nRes)) { COfficeUtils oCOfficeUtils(NULL); @@ -1608,7 +1578,7 @@ namespace NExtractTools } else if (NSDoctRenderer::DoctRendererFormat::FormatFile::PDF == eTypeTo) { - sFilePathOut += _T(".pdf"); + sFilePathOut += L".pdf"; CApplicationFonts oApplicationFonts; initApplicationFonts(oApplicationFonts, params); @@ -1620,7 +1590,7 @@ namespace NExtractTools } else if (NSDoctRenderer::DoctRendererFormat::FormatFile::HTML == eTypeTo) { - sFilePathOut += _T(".html"); + sFilePathOut += L".html"; bool bCopy = NSFile::CFileBinary::Copy(sFilePathIn,sFilePathOut); nRes = bCopy ? 0 : AVS_FILEUTILS_ERROR_CONVERT; } @@ -1775,7 +1745,7 @@ namespace NExtractTools std::wstring sFileToExt; if (!bIsOnlyFirst) { - sThumbnailDir = sTemp + FILE_SEPARATOR_STR + _T("thumbnails"); + sThumbnailDir = sTemp + FILE_SEPARATOR_STR + L"thumbnails"; FileSystem::Directory::CreateDirectory(sThumbnailDir); std::wstring::size_type pos = sTo.find_last_of('.'); @@ -1882,9 +1852,10 @@ namespace NExtractTools } else { - std::wstring sDoctDir = sTemp + FILE_SEPARATOR_STR + _T("doct_unpacked"); - FileSystem::Directory::CreateDirectory(sDoctDir); - std::wstring sTFile = sDoctDir + FILE_SEPARATOR_STR + _T("Editor.bin"); + std::wstring sDoctDir = sTemp + FILE_SEPARATOR_STR + L"doct_unpacked"; + std::wstring sTFile = sDoctDir + FILE_SEPARATOR_STR + L"Editor.bin"; + + FileSystem::Directory::CreateDirectory(sDoctDir); nRes = docx_dir2doct_bin(sFrom, sTFile, params); @@ -1915,7 +1886,7 @@ namespace NExtractTools } else if(0 != (AVS_OFFICESTUDIO_FILE_DOCUMENT & nFormatTo)) { - std::wstring sDocxDir = sTemp + FILE_SEPARATOR_STR + _T("docx_unpacked"); + std::wstring sDocxDir = sTemp + FILE_SEPARATOR_STR + L"docx_unpacked"; NSDirectory::CreateDirectory(sDocxDir); nRes = doct_bin2docx_dir(sFrom, sTo, sDocxDir, bFromChanges, sThemeDir, params); if(SUCCEEDED_X2T(nRes)) @@ -1964,10 +1935,11 @@ namespace NExtractTools } else { - std::wstring sDoctDir = sTemp + FILE_SEPARATOR_STR + _T("doct_unpacked"); - FileSystem::Directory::CreateDirectory(sDoctDir); - std::wstring sTFile = sDoctDir + FILE_SEPARATOR_STR + _T("Editor.bin"); + std::wstring sDoctDir = sTemp + FILE_SEPARATOR_STR + L"doct_unpacked"; + std::wstring sTFile = sDoctDir + FILE_SEPARATOR_STR + L"Editor.bin"; + FileSystem::Directory::CreateDirectory(sDoctDir); + if(AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML == nFormatFrom) nRes = html2doct_dir(sFrom, sDoctDir, sTemp, params); else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_MHT == nFormatFrom) @@ -1985,7 +1957,7 @@ namespace NExtractTools } else { - std::wstring sDocxDir = sTemp + FILE_SEPARATOR_STR + _T("docx_unpacked"); + std::wstring sDocxDir = sTemp + FILE_SEPARATOR_STR + L"docx_unpacked"; FileSystem::Directory::CreateDirectory(sDocxDir); if(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX == nFormatFrom) { @@ -2044,9 +2016,9 @@ namespace NExtractTools } else { - std::wstring sXlstDir = sTemp + FILE_SEPARATOR_STR + _T("xlst_unpacked"); + std::wstring sXlstDir = sTemp + FILE_SEPARATOR_STR + L"xlst_unpacked"; FileSystem::Directory::CreateDirectory(sXlstDir); - std::wstring sTFile = sXlstDir + FILE_SEPARATOR_STR + _T("Editor.bin"); + std::wstring sTFile = sXlstDir + FILE_SEPARATOR_STR + L"Editor.bin"; if(AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV == nFormatTo) nRes = xlsx_dir2xlst_bin(sFrom, sTFile, params); else @@ -2082,7 +2054,7 @@ namespace NExtractTools } else if(0 != (AVS_OFFICESTUDIO_FILE_SPREADSHEET & nFormatTo)) { - std::wstring sXlsxDir = sTemp + FILE_SEPARATOR_STR + _T("xlsx_unpacked"); + std::wstring sXlsxDir = sTemp + FILE_SEPARATOR_STR + L"xlsx_unpacked"; NSDirectory::CreateDirectory(sXlsxDir); nRes = xlst_bin2xlsx_dir(sFrom, sTo, sXlsxDir, bFromChanges, sThemeDir, params); if(SUCCEEDED_X2T(nRes)) @@ -2122,9 +2094,9 @@ namespace NExtractTools } else { - std::wstring sXlstDir = sTemp + FILE_SEPARATOR_STR + _T("xlst_unpacked"); + std::wstring sXlstDir = sTemp + FILE_SEPARATOR_STR + L"xlst_unpacked"; + std::wstring sTFile = sXlstDir + FILE_SEPARATOR_STR + L"Editor.bin"; FileSystem::Directory::CreateDirectory(sXlstDir); - std::wstring sTFile = sXlstDir + FILE_SEPARATOR_STR + _T("Editor.bin"); nRes = csv2xlst_bin(sFrom, sTFile, params); if(SUCCEEDED_X2T(nRes)) { @@ -2135,7 +2107,7 @@ namespace NExtractTools } else { - std::wstring sXlsxDir = sTemp + FILE_SEPARATOR_STR + _T("xlsx_unpacked"); + std::wstring sXlsxDir = sTemp + FILE_SEPARATOR_STR + L"xlsx_unpacked"; FileSystem::Directory::CreateDirectory(sXlsxDir); if(AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX == nFormatFrom) { @@ -2179,9 +2151,9 @@ namespace NExtractTools } else { - std::wstring sPpttDir = sTemp + FILE_SEPARATOR_STR + _T("pptt_unpacked"); + std::wstring sPpttDir = sTemp + FILE_SEPARATOR_STR + L"pptt_unpacked"; FileSystem::Directory::CreateDirectory(sPpttDir); - std::wstring sTFile = sPpttDir + FILE_SEPARATOR_STR + _T("Editor.bin"); + std::wstring sTFile = sPpttDir + FILE_SEPARATOR_STR + L"Editor.bin"; nRes = pptx_dir2pptt_bin(sFrom, sTFile, params); if(SUCCEEDED_X2T(nRes)) @@ -2211,7 +2183,7 @@ namespace NExtractTools } else if(0 != (AVS_OFFICESTUDIO_FILE_PRESENTATION & nFormatTo)) { - std::wstring sPptxDir = sTemp + FILE_SEPARATOR_STR + _T("pptx_unpacked"); + std::wstring sPptxDir = sTemp + FILE_SEPARATOR_STR + L"pptx_unpacked"; NSDirectory::CreateDirectory(sPptxDir); nRes = pptt_bin2pptx_dir(sFrom, sTo, sPptxDir, bFromChanges, sThemeDir, params); if(SUCCEEDED_X2T(nRes)) @@ -2243,7 +2215,7 @@ namespace NExtractTools bPaid = *params.m_bPaid; int nRes = 0; - std::wstring sPptxDir = sTemp + FILE_SEPARATOR_STR + _T("pptx_unpacked"); + std::wstring sPptxDir = sTemp + FILE_SEPARATOR_STR + L"pptx_unpacked"; FileSystem::Directory::CreateDirectory(sPptxDir); if(AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX == nFormatFrom) { @@ -2280,9 +2252,9 @@ namespace NExtractTools } else { - std::wstring sTDir = sTemp + FILE_SEPARATOR_STR + _T("doct_unpacked"); + std::wstring sTDir = sTemp + FILE_SEPARATOR_STR + L"doct_unpacked"; NSDirectory::CreateDirectory(sTDir); - std::wstring sTFile = sTDir + FILE_SEPARATOR_STR + _T("Editor.bin"); + std::wstring sTFile = sTDir + FILE_SEPARATOR_STR + L"Editor.bin"; nRes = zip2dir(sFrom, sTDir); if(SUCCEEDED_X2T(nRes)) { @@ -2363,7 +2335,7 @@ namespace NExtractTools // xls -> xlsx int xls2xlsx (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params) { - std::wstring sResultDocxDir = sTemp + FILE_SEPARATOR_STR + _T("xlsx_unpacked"); + std::wstring sResultDocxDir = sTemp + FILE_SEPARATOR_STR + L"xlsx_unpacked"; FileSystem::Directory::CreateDirectory(sResultDocxDir); @@ -2398,8 +2370,8 @@ namespace NExtractTools int 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"); + std::wstring sResultDoctDir = sTemp + FILE_SEPARATOR_STR + L"xlst_unpacked"; + std::wstring sResultDoctFileEditor = sResultDoctDir + FILE_SEPARATOR_STR + L"Editor.bin"; FileSystem::Directory::CreateDirectory(sResultDoctDir); @@ -2417,7 +2389,7 @@ namespace NExtractTools // xls -> xlst_bin int 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 + L"xlsx_unpacked"; FileSystem::Directory::CreateDirectory(sResultXlsxDir); @@ -2425,12 +2397,9 @@ namespace NExtractTools { BinXlsxRW::CXlsxSerializer m_oCXlsxSerializer; - CString sFontPath = std_string2string(params.getFontPath()); - m_oCXlsxSerializer.setFontDir(sFontPath); + m_oCXlsxSerializer.setFontDir(params.getFontPath()); - CString sTo1 = std_string2string(sTo); - - int res = m_oCXlsxSerializer.saveToFile (sTo1, std_string2string(sResultXlsxDir), std_string2string(params.getXmlOptions())) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; + int res = m_oCXlsxSerializer.saveToFile (sTo, sResultXlsxDir, params.getXmlOptions()) ? 0 : AVS_FILEUTILS_ERROR_CONVERT; return res; @@ -2493,7 +2462,7 @@ namespace NExtractTools if(NULL != oInputParams.m_oMailMergeSend) oMailMerge = oInputParams.m_oMailMergeSend; - std::wstring sTempDir = FileSystem::Directory::GetFolderPath(sFileFrom) + FILE_SEPARATOR_STR + _T("Temp"); + std::wstring sTempDir = FileSystem::Directory::GetFolderPath(sFileFrom) + FILE_SEPARATOR_STR + L"Temp"; NSDirectory::CreateDirectory(sTempDir); if (sTempDir.empty()) diff --git a/X2tConverter/src/cextracttools.h b/X2tConverter/src/cextracttools.h index c88645d2f8..4597359a24 100644 --- a/X2tConverter/src/cextracttools.h +++ b/X2tConverter/src/cextracttools.h @@ -36,7 +36,6 @@ #include "../../Common/OfficeFileFormatChecker.h" #include "../../Common/DocxFormat/Source/SystemUtility/SystemUtility.h" #include "../../Common/DocxFormat/Source/SystemUtility/FileSystem/Directory.h" -#include "../../Common/DocxFormat/Source/XML/stringcommon.h" #include "../../Common/DocxFormat/Source/XML/xmlutils.h" #include "../../DesktopEditor/doctrenderer/doctrenderer.h" #include "../../DesktopEditor/common/StringBuilder.h" @@ -388,7 +387,7 @@ namespace NExtractTools bool FromXmlFile(const std::wstring& sFilename) { XmlUtils::CXmlNode oRoot; - if(TRUE == oRoot.FromXmlFile2(std_string2string(sFilename))) + if(TRUE == oRoot.FromXmlFile2(sFilename)) { return FromXmlNode(oRoot); } @@ -400,7 +399,7 @@ namespace NExtractTools bool FromXml(const std::wstring& sXml) { XmlUtils::CXmlNode oRoot; - if(TRUE == oRoot.FromXmlString(std_string2string(sXml))) + if(TRUE == oRoot.FromXmlString(sXml)) { return FromXmlNode(oRoot); } diff --git a/X2tConverter/src/main.cpp b/X2tConverter/src/main.cpp index 1ccd0ab4a1..461a71d69d 100644 --- a/X2tConverter/src/main.cpp +++ b/X2tConverter/src/main.cpp @@ -75,9 +75,13 @@ static std::wstring utf8_to_unicode(const char *src) return wsEntryName; } #endif -int main(int argc, char *argv[]) -{ +#if !defined(_WIN32) && !defined (_WIN64) + int main(int argc, char *argv[]) +#else + int wmain(int argc, wchar_t *argv[]) +#endif +{ // check arguments if (argc < 2) { @@ -106,9 +110,8 @@ int main(int argc, char *argv[]) sExePath = utf8_to_unicode(argv [0]); sArg1 = utf8_to_unicode(argv [1]); #else - std::string s; - s = std::string(argv [0]); sExePath = std::wstring(s.begin(), s.end()); - s = std::string(argv [1]); sArg1 = std::wstring(s.begin(), s.end()); + sExePath = std::wstring(argv [0]); + sArg1 = std::wstring(argv [1]); #endif int result = 0; @@ -127,10 +130,10 @@ int main(int argc, char *argv[]) if (argc >= 5) sArg4 = utf8_to_unicode(argv [4]); if (argc >= 6) sArg5 = utf8_to_unicode(argv [5]); #else - if (argc >= 3) { s = std::string(argv [2]); sArg2 = std::wstring(s.begin(), s.end()); } - if (argc >= 4) { s = std::string(argv [3]); sArg3 = std::wstring(s.begin(), s.end()); } - if (argc >= 5) { s = std::string(argv [4]); sArg4 = std::wstring(s.begin(), s.end()); } - if (argc >= 6) { s = std::string(argv [5]); sArg5 = std::wstring(s.begin(), s.end()); } + if (argc >= 3) sArg2 = std::wstring(argv [2]); + if (argc >= 4) sArg3 = std::wstring(argv [3]); + if (argc >= 5) sArg4 = std::wstring(argv [4]); + if (argc >= 6) sArg5 = std::wstring(argv [5]); #endif InputParams oInputParams; oInputParams.m_sFileFrom = new std::wstring(sArg1); diff --git a/XlsxSerializerCom/Common/Common.cpp b/XlsxSerializerCom/Common/Common.cpp index 4331c9f853..127a7d05c9 100644 --- a/XlsxSerializerCom/Common/Common.cpp +++ b/XlsxSerializerCom/Common/Common.cpp @@ -49,11 +49,11 @@ namespace SerializeCommon CString DownloadImage(const CString& strFile) { #ifndef DISABLE_FILE_DOWNLOADER - CFileDownloader oDownloader(string2std_string(strFile), false); + CFileDownloader oDownloader(strFile, false); CString strFileName; if ( oDownloader.DownloadSync() ) { - strFileName = std_string2string(oDownloader.GetFilePath()); + strFileName = oDownloader.GetFilePath(); } return strFileName; #else diff --git a/XlsxSerializerCom/Reader/BinaryWriter.h b/XlsxSerializerCom/Reader/BinaryWriter.h index 3892e5e921..424b37ef4d 100644 --- a/XlsxSerializerCom/Reader/BinaryWriter.h +++ b/XlsxSerializerCom/Reader/BinaryWriter.h @@ -1083,7 +1083,7 @@ namespace BinXlsxRW { m_oBcw.m_oStream.WriteStringWStd(sFormatCode); if(NULL != m_pEmbeddedFontsManager) - m_pEmbeddedFontsManager->CheckString(std_string2string(sFormatCode)); + m_pEmbeddedFontsManager->CheckString(sFormatCode); } //NumFmtId if(numFmt.m_oNumFmtId.IsInit()) @@ -1337,7 +1337,7 @@ namespace BinXlsxRW { m_oBcw.m_oStream.WriteStringWStd(pText->m_sText); if(NULL != m_pEmbeddedFontsManager) - m_pEmbeddedFontsManager->CheckString(std_string2string(pText->m_sText)); + m_pEmbeddedFontsManager->CheckString(pText->m_sText); } } }; @@ -1361,7 +1361,7 @@ namespace BinXlsxRW { m_oBcw.m_oStream.WriteStringWStd(pText->m_sText); if(NULL != m_pEmbeddedFontsManager) - m_pEmbeddedFontsManager->CheckString(std_string2string(pText->m_sText)); + m_pEmbeddedFontsManager->CheckString(pText->m_sText); } } }; @@ -1647,7 +1647,7 @@ namespace BinXlsxRW { OOX::Spreadsheet::CSheet* pSheet = aWs[i]; if(pSheet->m_oRid.IsInit()) { - std::map::const_iterator pair = aWorksheets.find(string2std_string(pSheet->m_oRid->GetValue())); + std::map::const_iterator pair = aWorksheets.find(pSheet->m_oRid->GetValue()); if(aWorksheets.end() != pair) { nCurPos = m_oBcw.WriteItemStart(c_oSerWorksheetsTypes::Worksheet); @@ -2548,7 +2548,7 @@ namespace BinXlsxRW { m_oBcw.m_oStream.WriteStringWStd(oFormula.m_sText); if(NULL != m_pEmbeddedFontsManager) - m_pEmbeddedFontsManager->CheckString(std_string2string(oFormula.m_sText)); + m_pEmbeddedFontsManager->CheckString(oFormula.m_sText); } }; @@ -2616,7 +2616,7 @@ namespace BinXlsxRW { eAnchorType.SetValue(SimpleTypes::Spreadsheet::cellanchorTwoCell); OOX::Spreadsheet::CCellAnchor oCellAnchor = OOX::Spreadsheet::CCellAnchor(eAnchorType); oCellAnchor.m_sSpId.Init(); - oCellAnchor.m_sSpId->append(string2std_string(sShapeId)); + oCellAnchor.m_sSpId->append(sShapeId); oCellAnchor.m_oFrom.Init(); oCellAnchor.m_oFrom->m_oCol.Init(); oCellAnchor.m_oFrom->m_oCol->SetValue(m_aAnchor[0]); @@ -2697,7 +2697,7 @@ namespace BinXlsxRW { } else if (pCellAnchor.m_sSpId.IsInit() && pVmlDrawing) { - std::map::iterator pFind = pVmlDrawing->m_mapShapesXml.find(std_string2string(pCellAnchor.m_sSpId.get2())); + std::map::iterator pFind = pVmlDrawing->m_mapShapesXml.find(pCellAnchor.m_sSpId.get2()); if (pFind != pVmlDrawing->m_mapShapesXml.end()) { CString* bstrOutputXml = NULL; @@ -2705,7 +2705,7 @@ namespace BinXlsxRW { int nCurPos = m_oBcw.WriteItemWithLengthStart(); std::wstring temp = _T(""); - temp.append(string2std_string(pFind->second)); + temp.append(pFind->second); if (NULL != pOleObject) { //ищем физический файл, потому что rId относительно sheet.xml, а SetRelsPath(pVmlDrawing @@ -2725,7 +2725,7 @@ namespace BinXlsxRW { CString keepRels = m_pOfficeDrawingConverter->GetRelsPath(); m_pOfficeDrawingConverter->SetRelsPath(pVmlDrawing->GetReadPath().GetPath()); - HRESULT hRes = m_pOfficeDrawingConverter->AddObject(std_string2string(temp), &bstrOutputXml); + HRESULT hRes = m_pOfficeDrawingConverter->AddObject(temp, &bstrOutputXml); m_oBcw.WriteItemWithLengthEnd(nCurPos); RELEASEOBJECT(bstrOutputXml); m_pOfficeDrawingConverter->SetRelsPath(keepRels); @@ -2740,7 +2740,7 @@ namespace BinXlsxRW { CString* bstrOutputXml = NULL; m_oBcw.m_oStream.WriteBYTE(c_oSer_DrawingType::pptxDrawing); int nCurPos = m_oBcw.WriteItemWithLengthStart(); - HRESULT hRes = m_pOfficeDrawingConverter->AddObject(std_string2string(bstrXml), &bstrOutputXml); + HRESULT hRes = m_pOfficeDrawingConverter->AddObject(bstrXml, &bstrOutputXml); m_oBcw.WriteItemWithLengthEnd(nCurPos); RELEASEOBJECT(bstrOutputXml); } @@ -3775,7 +3775,7 @@ namespace BinXlsxRW { OOX::CPath path(sFileDst); //создаем папку для media CString mediaDir = path.GetDirectory() + gc_sMediaDirName; - NSDirectory::CreateDirectory(string2std_string(mediaDir)); + NSDirectory::CreateDirectory(mediaDir); pOfficeDrawingConverter->SetMediaDstPath(mediaDir); diff --git a/XlsxSerializerCom/Reader/CSVReader.cpp b/XlsxSerializerCom/Reader/CSVReader.cpp index f33154460b..080bf3f419 100644 --- a/XlsxSerializerCom/Reader/CSVReader.cpp +++ b/XlsxSerializerCom/Reader/CSVReader.cpp @@ -125,23 +125,25 @@ namespace CSVReader pXfs->m_oAligment->m_oWrapText->SetValue(SimpleTypes::onoffTrue); pStyles->m_oCellXfs->m_arrItems.push_back(pXfs); - std::wstring sSheetRId = _T("rId1"); + std::wstring sSheetRId = L"rId1"; OOX::Spreadsheet::CWorksheet* pWorksheet = new OOX::Spreadsheet::CWorksheet(); pWorksheet->m_oSheetData.Init(); + OOX::Spreadsheet::CSheet *pSheet = new OOX::Spreadsheet::CSheet(); + pSheet->m_oName.Init(); - pSheet->m_oName->append(_T("Sheet1")); + pSheet->m_oName->append(L"Sheet1"); pSheet->m_oSheetId.Init(); pSheet->m_oSheetId->SetValue(1); pSheet->m_oRid.Init(); - pSheet->m_oRid->SetValue(std_string2string(sSheetRId)); + pSheet->m_oRid->SetValue(sSheetRId); OOX::Spreadsheet::CWorkbook *pWorkbook = oXlsx.GetWorkbook(); pWorkbook->m_oSheets.Init(); pWorkbook->m_oSheets->m_arrItems.push_back(pSheet); NSFile::CFileBinary oFile; - if(oFile.OpenFile(string2std_string(sFileName))) + if(oFile.OpenFile(sFileName)) { DWORD nFileSize = 0; BYTE* pFileData = new BYTE[oFile.GetFileSize()]; diff --git a/XlsxSerializerCom/Reader/ChartFromToBinary.cpp b/XlsxSerializerCom/Reader/ChartFromToBinary.cpp index 8fec0e19b7..a2e6d6d688 100644 --- a/XlsxSerializerCom/Reader/ChartFromToBinary.cpp +++ b/XlsxSerializerCom/Reader/ChartFromToBinary.cpp @@ -5980,13 +5980,17 @@ namespace BinXlsxRW{ void BinaryChartWriter::GetRecordBinary(int nType, std::wstring& sXml, int nRecordType) { int nCurPos = m_oBcw.WriteItemStart(nType); - HRESULT hRes = m_pOfficeDrawingConverter->GetRecordBinary(nRecordType, std_string2string(sXml)); + HRESULT hRes = m_pOfficeDrawingConverter->GetRecordBinary(nRecordType, sXml); m_oBcw.WriteItemEnd(nCurPos); } void BinaryChartWriter::GetTxBodyBinary(int nType, std::wstring& sXml) { int nCurPos = m_oBcw.WriteItemStart(nType); - CString bstrXml = _T("") + std_string2string(sXml) + _T(""); + + std::wstring bstrXml = L""; + bstrXml += sXml; + bstrXml += L""; + HRESULT hRes = m_pOfficeDrawingConverter->GetTxBodyBinary(bstrXml); m_oBcw.WriteItemEnd(nCurPos); } diff --git a/XlsxSerializerCom/Writer/BinaryReader.h b/XlsxSerializerCom/Writer/BinaryReader.h index a4d8ca967d..186c72adc7 100644 --- a/XlsxSerializerCom/Writer/BinaryReader.h +++ b/XlsxSerializerCom/Writer/BinaryReader.h @@ -2011,7 +2011,7 @@ namespace BinXlsxRW { if(pCommentItem->m_nRow.IsInit() && pCommentItem->m_nCol.IsInit()) { pNewComment->m_oRef.Init(); - pNewComment->m_oRef->SetValue(std_string2string(OOX::Spreadsheet::CCell::combineRef(pCommentItem->m_nRow.get(), pCommentItem->m_nCol.get()))); + pNewComment->m_oRef->SetValue(OOX::Spreadsheet::CCell::combineRef(pCommentItem->m_nRow.get(), pCommentItem->m_nCol.get())); } if(pCommentItem->m_sAuthor.IsInit()) @@ -2830,7 +2830,7 @@ namespace BinXlsxRW { std::map::const_iterator pPair = pair->second->mapDrawings.find(m_pCurDrawing); if(pair->second->mapDrawings.end() == pPair) { - std::wstring sNewImageName = NSSystemPath::GetFileName(string2std_string(pair->second->sPath)); + std::wstring sNewImageName = NSSystemPath::GetFileName(pair->second->sPath); long rId; CString sNewImgRel; @@ -3306,7 +3306,9 @@ namespace BinXlsxRW { res = Read1(length, &BinaryOtherTableReader::ReadMediaContent, this, poResult); else if(c_oSer_OtherType::Theme == type) { - CString sThemePath = m_oSaveParams.sThemePath + FILE_SEPARATOR_STR + OOX::FileTypes::Theme.DefaultFileName().GetPath(); + CString sThemePath = m_oSaveParams.sThemePath + FILE_SEPARATOR_STR; + sThemePath += OOX::FileTypes::Theme.DefaultFileName().GetPath(); + long nCurPos = m_oBufferedStream.GetPos(); m_pOfficeDrawingConverter->SaveThemeXml(nCurPos, length, sThemePath); m_oBufferedStream.Seek(nCurPos + length); @@ -3352,7 +3354,7 @@ namespace BinXlsxRW { //url sImageSrc = SerializeCommon::DownloadImage(sImage); CString sNewTempFile = SerializeCommon::changeExtention(sImageSrc, CString(_T("jpg"))); - NSFile::CFileBinary::Move(string2std_string(sImageSrc), string2std_string(sNewTempFile)); + NSFile::CFileBinary::Move(sImageSrc, sNewTempFile); sImageSrc = sNewTempFile; bAddToDelete = true; } @@ -3375,11 +3377,11 @@ namespace BinXlsxRW { { ReadMediaItemSaveFileFILE(pFileNative); } - else if(NSFile::CFileBinary::Exists(string2std_string(sImageSrc))) + else if(NSFile::CFileBinary::Exists(sImageSrc)) { ReadMediaItemSaveFilePath(sImageSrc); if(bAddToDelete) - NSFile::CFileBinary::Remove(string2std_string(sImageSrc)); + NSFile::CFileBinary::Remove(sImageSrc); } } else if(c_oSer_OtherType::MediaId == type) @@ -3392,7 +3394,7 @@ namespace BinXlsxRW { }; CString ReadMediaItemSaveFileGetNewPath(const CString& sTempPath) { - if( !NSDirectory::Exists(string2std_string(m_sMediaDir)) ) + if( !NSDirectory::Exists(m_sMediaDir) ) OOX::CSystemUtility::CreateDirectories(m_sMediaDir); CString sNewImageName; sNewImageName.Format(_T("image%d"), m_nCurIndex); @@ -3413,7 +3415,7 @@ namespace BinXlsxRW { { CString sNewImagePath = ReadMediaItemSaveFileGetNewPath(CString(_T("1.jpg"))); NSFile::CFileBinary oFile; - oFile.CreateFileW(string2std_string(sNewImagePath)); + oFile.CreateFileW(sNewImagePath); oFile.WriteFile(pData, dwSizeRead); oFile.CloseFile(); m_sCurSrc = sNewImagePath; @@ -3425,7 +3427,7 @@ namespace BinXlsxRW { { CString sNewImagePath = ReadMediaItemSaveFileGetNewPath(sTempPath); - NSFile::CFileBinary::Copy(string2std_string(sTempPath), string2std_string(sNewImagePath)); + NSFile::CFileBinary::Copy(sTempPath, sNewImagePath); m_sCurSrc = sNewImagePath; } }; @@ -3434,11 +3436,12 @@ namespace BinXlsxRW { public: BinaryFileReader() { } - int ReadFile(const CString& sSrcFileName, CString sDstPath, NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter, const CString& sXMLOptions) + int ReadFile(const std::wstring& sSrcFileName, std::wstring sDstPath, NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter, const CString& sXMLOptions) { bool bResultOk = false; NSFile::CFileBinary oFile; - if(oFile.OpenFile(string2std_string(sSrcFileName))) + + if(oFile.OpenFile(sSrcFileName)) { DWORD nBase64DataSize = 0; BYTE* pBase64Data = new BYTE[oFile.GetFileSize()]; @@ -3512,11 +3515,15 @@ namespace BinXlsxRW { BYTE saveFileType; SerializeCommon::ReadFileType(sXMLOptions, fileType, nCodePage, wcDelimiter, saveFileType); // Делаем для CSV перебивку пути, иначе создается папка с одинаковым имеем (для rels) и файл не создается. + if (BinXlsxRW::c_oFileTypes::CSV == fileType) - sDstPath = std_string2string(NSSystemPath::GetDirectoryName(string2std_string(sDstPath))); + sDstPath = NSSystemPath::GetDirectoryName(sDstPath); OOX::Spreadsheet::CXlsx oXlsx; - SaveParams oSaveParams(sDstPath + FILE_SEPARATOR_STR + OOX::Spreadsheet::FileTypes::Workbook.DefaultDirectory().GetPath() + FILE_SEPARATOR_STR + OOX::FileTypes::Theme.DefaultDirectory().GetPath()); + std::wstring params_path = sDstPath + FILE_SEPARATOR_STR + OOX::Spreadsheet::FileTypes::Workbook.DefaultDirectory().GetPath() + FILE_SEPARATOR_STR + OOX::FileTypes::Theme.DefaultDirectory().GetPath(); + + SaveParams oSaveParams(params_path.c_str()); + ReadMainTable(oXlsx, oBufferedStream, OOX::CPath(sSrcFileName).GetDirectory(), sDstPath, oSaveParams, pOfficeDrawingConverter); CString sAdditionalContentTypes = oSaveParams.sAdditionalContentTypes; if(NULL != pOfficeDrawingConverter) diff --git a/XlsxSerializerCom/Writer/CSVWriter.cpp b/XlsxSerializerCom/Writer/CSVWriter.cpp index 69f6040ce7..706fc69cf3 100644 --- a/XlsxSerializerCom/Writer/CSVWriter.cpp +++ b/XlsxSerializerCom/Writer/CSVWriter.cpp @@ -109,7 +109,7 @@ namespace CSVWriter void WriteFromXlsxToCsv(const CString &sFileDst, OOX::Spreadsheet::CXlsx &oXlsx, UINT nCodePage, const WCHAR wcDelimiter, bool bJSON) { NSFile::CFileBinary oFile; - oFile.CreateFileW(string2std_string(sFileDst)); + oFile.CreateFileW(sFileDst); // Нужно записать шапку if (CP_UTF8 == nCodePage) @@ -158,7 +158,7 @@ namespace CSVWriter else pSheet = pWorkbook->m_oSheets->m_arrItems[0]; - sSheetRId = bJSON ? string2std_string(pSheet->m_oRid->GetValue()) : pSheet->m_oName.get2(); + sSheetRId = bJSON ? pSheet->m_oRid->GetValue() : pSheet->m_oName.get2(); } std::map &arrWorksheets = oXlsx.GetWorksheets();