From 4ad5b8dfcbf4df56baa0a68f5acefcfcdf82cdc3 Mon Sep 17 00:00:00 2001 From: "Ivan.Shulga" Date: Thu, 30 Oct 2014 16:09:51 +0000 Subject: [PATCH] linux build, changes some file separators git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@59360 954022d7-b5bf-4e40-9824-e11837661b57 --- .../ASCGraphics/Objects/Image/Wmf/WmfUtils.h | 5 ++-- .../BinReader/ContentTypesWriter.h | 5 ++-- ASCOfficeDocxFile2/BinReader/MediaWriter.h | 4 ++-- ASCOfficePPTXFile/Editor/PPTXWriter.h | 2 +- Common/DocxFormat/Source/Base/Base.h | 15 ++++++++++++ .../FileSystem/DirectoryPosix.cpp | 4 ++-- .../Source/SystemUtility/SystemUtility.h | 8 +++---- DesktopEditor/cximage/CxImage/ximaenc.cpp | 8 +++++++ DesktopEditor/cximage/CxImage/xiofile.h | 4 ++++ DesktopEditor/graphics/Image.cpp | 1 + .../Reader/ChartFromToBinary.cpp | 2 +- XlsxSerializerCom/Writer/BinaryReader.h | 24 +++++++++---------- 12 files changed, 56 insertions(+), 26 deletions(-) diff --git a/ASCImageStudio3/ASCGraphics/Objects/Image/Wmf/WmfUtils.h b/ASCImageStudio3/ASCGraphics/Objects/Image/Wmf/WmfUtils.h index 88fc0d60d2..5f36ddf70d 100644 --- a/ASCImageStudio3/ASCGraphics/Objects/Image/Wmf/WmfUtils.h +++ b/ASCImageStudio3/ASCGraphics/Objects/Image/Wmf/WmfUtils.h @@ -5,6 +5,7 @@ #include #include +#include "../../../../../Common/DocxFormat/Source/Base/Base.h" #ifndef _USE_MATH_DEFINES #define _USE_MATH_DEFINES #endif @@ -1357,12 +1358,12 @@ static BOOL WmfOpenTempFile(CString *pwsName, FILE **ppFile, wchar_t *wsMode, wc std::wstring wsTempDir = UTF8_TO_U( wsTempDirA ); wsTemp = wsTempDir.c_str(); #endif - wsTemp.Append( L"\\" ); + wsTemp.Append( _T("/") ); } else if( wsFolder != NULL ) { wsTemp = CString( wsFolder ); - wsTemp.Append( L"\\" ); + wsTemp.Append( _T("/") ); } else { diff --git a/ASCOfficeDocxFile2/BinReader/ContentTypesWriter.h b/ASCOfficeDocxFile2/BinReader/ContentTypesWriter.h index be2f504d8c..a36265c6fa 100644 --- a/ASCOfficeDocxFile2/BinReader/ContentTypesWriter.h +++ b/ASCOfficeDocxFile2/BinReader/ContentTypesWriter.h @@ -28,7 +28,8 @@ namespace Writers m_oWriter.WriteString(g_string_ct_End); CFile oFile; - oFile.CreateFile(m_sDir + _T("\\[Content_Types].xml")); + + oFile.CreateFile (m_sDir + _T("/[Content_Types].xml")); oFile.WriteStringUTF8(m_oWriter.GetData()); oFile.CloseFile(); } @@ -43,4 +44,4 @@ namespace Writers } }; } -#endif // #ifndef CONTENT_TYPES_WRITER \ No newline at end of file +#endif // #ifndef CONTENT_TYPES_WRITER diff --git a/ASCOfficeDocxFile2/BinReader/MediaWriter.h b/ASCOfficeDocxFile2/BinReader/MediaWriter.h index fa3acdcaa8..fcb32810a8 100644 --- a/ASCOfficeDocxFile2/BinReader/MediaWriter.h +++ b/ASCOfficeDocxFile2/BinReader/MediaWriter.h @@ -25,7 +25,7 @@ namespace Writers OOX::CSystemUtility::CreateDirectories(m_sMediaDir); CString sNewImgName;sNewImgName.Format(_T("image%d.jpg"), (nImageCount + 1)); - CString sNewImg = m_sMediaDir + _T("\\") + sNewImgName; + CString sNewImg = m_sMediaDir + _T("/") + sNewImgName; nImageCount++; return sNewImg; } @@ -60,4 +60,4 @@ namespace Writers } }; } -#endif // #ifndef MEDIA_WRITER \ No newline at end of file +#endif // #ifndef MEDIA_WRITER diff --git a/ASCOfficePPTXFile/Editor/PPTXWriter.h b/ASCOfficePPTXFile/Editor/PPTXWriter.h index 6c5019e988..6e956a5191 100644 --- a/ASCOfficePPTXFile/Editor/PPTXWriter.h +++ b/ASCOfficePPTXFile/Editor/PPTXWriter.h @@ -743,7 +743,7 @@ namespace NSBinPptxRW oContentTypes.WriteString(_T("")); CFile oFile; - oFile.CreateFile(m_strDstFolder + _T("\\[Content_Types].xml")); + oFile.CreateFile(m_strDstFolder + _T("/[Content_Types].xml")); CString strContentTypes = oContentTypes.GetData(); oFile.WriteStringUTF8(strContentTypes); oFile.CloseFile(); diff --git a/Common/DocxFormat/Source/Base/Base.h b/Common/DocxFormat/Source/Base/Base.h index 9739562512..2bfb9cca39 100644 --- a/Common/DocxFormat/Source/Base/Base.h +++ b/Common/DocxFormat/Source/Base/Base.h @@ -52,6 +52,13 @@ #include #include +// windows-stype separator for paths i.e. 'c:\home\documents\file.ext' +#ifndef FILE_SEPARATOR +#define FILE_SEPARATOR +#define FILE_SEPARATOR_CHAR '\\' +#define FILE_SEPARATOR_STR _T("\\") +#endif + typedef unsigned int size_t; #include "../../../ASCUtils.h" @@ -62,6 +69,14 @@ using namespace ATL; #include "ASCString.h" #include "stdint.h" +// linux-stype separator for paths i.e. '/home/documents/file.ext' +#ifndef FILE_SEPARATOR +#define FILE_SEPARATOR +#define FILE_SEPARATOR_CHAR '/' +#define FILE_SEPARATOR_STR _T("/") +#endif + + /* typedef int BOOL; static const BOOL TRUE = 1; diff --git a/Common/DocxFormat/Source/SystemUtility/FileSystem/DirectoryPosix.cpp b/Common/DocxFormat/Source/SystemUtility/FileSystem/DirectoryPosix.cpp index 4e887319a0..49222028db 100644 --- a/Common/DocxFormat/Source/SystemUtility/FileSystem/DirectoryPosix.cpp +++ b/Common/DocxFormat/Source/SystemUtility/FileSystem/DirectoryPosix.cpp @@ -1,6 +1,6 @@ #include "Directory.h" #include "../../Base/ASCString.h" - +#include "../../Base/Base.h" #include #include @@ -182,7 +182,7 @@ namespace FileSystem { } CString Directory::GetFolderPath(const CString& strFolderPath) { - int n1 = strFolderPath.rfind(_T("\\")); + int n1 = strFolderPath.rfind(FILE_SEPARATOR_STR); if (n1 < 0 ) return _T(""); return strFolderPath.substr(0,n1); diff --git a/Common/DocxFormat/Source/SystemUtility/SystemUtility.h b/Common/DocxFormat/Source/SystemUtility/SystemUtility.h index 16e6b33645..40e0dd64a2 100644 --- a/Common/DocxFormat/Source/SystemUtility/SystemUtility.h +++ b/Common/DocxFormat/Source/SystemUtility/SystemUtility.h @@ -69,7 +69,7 @@ namespace OOX } AVSINLINE CString GetDirectory(bool bIsSlash = true) const { - int nPos = m_strFilename.ReverseFind('\\'); + int nPos = m_strFilename.ReverseFind(FILE_SEPARATOR_CHAR); if (-1 == nPos) { return m_strFilename; @@ -87,7 +87,7 @@ namespace OOX } AVSINLINE CString GetFilename() const { - int nPos = m_strFilename.ReverseFind('\\'); + int nPos = m_strFilename.ReverseFind(FILE_SEPARATOR_CHAR); if (-1 == nPos) { return m_strFilename; @@ -118,7 +118,7 @@ namespace OOX while (nCurrent < nLen) { - if (pData[nCurrent] == (TCHAR)'\\' || pData[nCurrent] == (TCHAR)'/') + if (pData[nCurrent] == (TCHAR) '\\' || pData[nCurrent] == (TCHAR)'/') { if (nStart < nCurrent) { @@ -137,7 +137,7 @@ namespace OOX } if (!bIsUp) { - pDataNorm[nCurrentW++] = (TCHAR)'\\'; + pDataNorm[nCurrentW++] = (TCHAR) FILE_SEPARATOR_CHAR; ++nCurrentSlash; pSlashPoints[nCurrentSlash] = nCurrentW; } diff --git a/DesktopEditor/cximage/CxImage/ximaenc.cpp b/DesktopEditor/cximage/CxImage/ximaenc.cpp index d9db654e4c..89d7138e4e 100644 --- a/DesktopEditor/cximage/CxImage/ximaenc.cpp +++ b/DesktopEditor/cximage/CxImage/ximaenc.cpp @@ -108,6 +108,9 @@ bool CxImage::EncodeSafeCheck(CxFile *hFile) */ bool CxImage::Save(const TCHAR * filename, uint32_t imagetype) { +#ifdef CXIMAGE_DONT_USE_LOAD_SAVE + return false; +#else FILE* hFile; //file handle to write the image #ifdef WIN32 @@ -124,6 +127,7 @@ bool CxImage::Save(const TCHAR * filename, uint32_t imagetype) bool bOK = Encode(hFile,imagetype); fclose(hFile); return bOK; +#endif //#ifdef CXIMAGE_DONT_USE_LOAD_SAVE } //////////////////////////////////////////////////////////////////////////////// /** @@ -570,6 +574,9 @@ bool CxImage::Encode2RGBA(CxFile *hFile, bool bFlipY) bool CxImage::Load(const TCHAR * filename, uint32_t imagetype) //bool CxImage::Load(const char * filename, uint32_t imagetype) { +#ifdef CXIMAGE_DONT_USE_LOAD_SAVE + return false; +#else /*FILE* hFile; //file handle to read the image if ((hFile=fopen(filename,"rb"))==NULL) return false; bool bOK = Decode(hFile,imagetype); @@ -619,6 +626,7 @@ bool CxImage::Load(const TCHAR * filename, uint32_t imagetype) if (!bOK && imagetype > 0) strcpy(info.szLastError,szError); //restore the first error return bOK; +#endif // #ifdef CXIMAGE_DONT_USE_LOAD_SAVE } //////////////////////////////////////////////////////////////////////////////// #ifdef WIN32 diff --git a/DesktopEditor/cximage/CxImage/xiofile.h b/DesktopEditor/cximage/CxImage/xiofile.h index 6c9c03dbc3..4e558767e7 100644 --- a/DesktopEditor/cximage/CxImage/xiofile.h +++ b/DesktopEditor/cximage/CxImage/xiofile.h @@ -31,6 +31,9 @@ public: ////////////////////////////////////////////////////////// bool Open(const TCHAR * filename, const TCHAR * mode) { +#ifdef CXIMAGE_DONT_USE_LOAD_SAVE + return false; +#else #ifdef WIN32 if (m_fp) return false; // Can't re-open without closing first @@ -41,6 +44,7 @@ public: #endif return true; +#endif // #ifdef CXIMAGE_DONT_USE_LOAD_SAVE } ////////////////////////////////////////////////////////// virtual bool Close() diff --git a/DesktopEditor/graphics/Image.cpp b/DesktopEditor/graphics/Image.cpp index 85d4a7d7b0..3e3f44d557 100644 --- a/DesktopEditor/graphics/Image.cpp +++ b/DesktopEditor/graphics/Image.cpp @@ -2,6 +2,7 @@ #include "../raster/BgraFrame.h" +#include // memset namespace Aggplus { //////////////////////////////////////////////////////////////////////////////////////// diff --git a/XlsxSerializerCom/Reader/ChartFromToBinary.cpp b/XlsxSerializerCom/Reader/ChartFromToBinary.cpp index 1b19fc42bf..2614112325 100644 --- a/XlsxSerializerCom/Reader/ChartFromToBinary.cpp +++ b/XlsxSerializerCom/Reader/ChartFromToBinary.cpp @@ -950,7 +950,7 @@ namespace BinXlsxRW{ { CString sThemeOverrideName;sThemeOverrideName.Format(_T("themeOverride%d.xml"), m_oSaveParams.nThemeOverrideCount++); CString sThemeOverrideRelsPath;sThemeOverrideRelsPath.Format(_T("../theme/%s"), sThemeOverrideName); - CString sThemeOverridePath;sThemeOverridePath.Format(_T("%s\\%s"), m_oSaveParams.sThemePath, sThemeOverrideName); + CString sThemeOverridePath;sThemeOverridePath.Format(_T("%s/%s"), m_oSaveParams.sThemePath, sThemeOverrideName); long nCurPos = m_oBufferedStream.GetPos(); m_pOfficeDrawingConverter->SaveThemeXml(nCurPos, length, sThemeOverridePath); diff --git a/XlsxSerializerCom/Writer/BinaryReader.h b/XlsxSerializerCom/Writer/BinaryReader.h index a637d9bbb3..3858bc7fe1 100644 --- a/XlsxSerializerCom/Writer/BinaryReader.h +++ b/XlsxSerializerCom/Writer/BinaryReader.h @@ -1839,11 +1839,11 @@ namespace BinXlsxRW { else if(c_oSerWorksheetsTypes::Drawings == type) { CString sDrawingsDir; - sDrawingsDir.Format(_T("%s\\xl\\drawings"), m_sDestinationDir); + sDrawingsDir.Format(_T("%s/xl/drawings"), m_sDestinationDir); if( !NSDirectory::Exists(string2std_string(sDrawingsDir)) ) OOX::CSystemUtility::CreateDirectories(sDrawingsDir); CString sRelsDir; - sRelsDir.Format(_T("%s\\_rels"), sDrawingsDir); + sRelsDir.Format(_T("%s/_rels"), sDrawingsDir); if( !NSDirectory::Exists(string2std_string(sRelsDir)) ) OOX::CSystemUtility::CreateDirectories(sRelsDir); @@ -1858,7 +1858,7 @@ namespace BinXlsxRW { CString sFilename = m_pCurDrawing->m_sFilename; CString sRelsPath; - sRelsPath.Format(_T("%s\\%s.rels"), sRelsDir, sFilename); + sRelsPath.Format(_T("%s/%s.rels"), sRelsDir, sFilename); m_pOfficeDrawingConverter->SaveDstContentRels(sRelsPath); } else if(c_oSerWorksheetsTypes::SheetData == type) @@ -2421,11 +2421,11 @@ namespace BinXlsxRW { { //создаем папку для rels CString sChartsDir; - sChartsDir.Format(_T("%s\\xl\\charts"), m_sDestinationDir); + sChartsDir.Format(_T("%s/xl/charts"), m_sDestinationDir); if( !NSDirectory::Exists(string2std_string(sChartsDir)) ) OOX::CSystemUtility::CreateDirectories(sChartsDir); CString sRelsDir; - sRelsDir.Format(_T("%s\\_rels"), sChartsDir); + sRelsDir.Format(_T("%s/_rels"), sChartsDir); if( !NSDirectory::Exists(string2std_string(sRelsDir)) ) OOX::CSystemUtility::CreateDirectories(sRelsDir); m_pOfficeDrawingConverter->SetDstContentRels(); @@ -2437,7 +2437,7 @@ namespace BinXlsxRW { pChartFile->m_bDoNotAddRels = true; m_pCurDrawing->Add(pChartFile); - CString sRelsPath;sRelsPath.Format(_T("%s\\%s.rels"), sRelsDir, pChartFile->m_sFilename); + CString sRelsPath;sRelsPath.Format(_T("%s/%s.rels"), sRelsDir, pChartFile->m_sFilename); m_pOfficeDrawingConverter->SaveDstContentRels(sRelsPath); long rId; @@ -2834,7 +2834,7 @@ namespace BinXlsxRW { res = Read1(length, &BinaryOtherTableReader::ReadMediaContent, this, poResult); else if(c_oSer_OtherType::Theme == type) { - CString sThemePath;sThemePath.Format(_T("%s\\%s"), m_oSaveParams.sThemePath, OOX::FileTypes::Theme.DefaultFileName().GetPath()); + CString sThemePath;sThemePath.Format(_T("%s/%s"), m_oSaveParams.sThemePath, OOX::FileTypes::Theme.DefaultFileName().GetPath()); long nCurPos = m_oBufferedStream.GetPos(); m_pOfficeDrawingConverter->SaveThemeXml(nCurPos, length, sThemePath); m_oBufferedStream.Seek(nCurPos + length); @@ -2894,7 +2894,7 @@ namespace BinXlsxRW { else { //local - sImageSrc = m_sFileInDir + _T("media\\") + sImage; + sImageSrc = m_sFileInDir + _T("media/") + sImage; } } //Проверяем что файл существует @@ -2925,7 +2925,7 @@ namespace BinXlsxRW { CString sNewImageName; sNewImageName.Format(_T("image%d%s"), m_nCurIndex, OOX::CPath(sTempPath).GetExtention(true)); m_nCurIndex++; - CString sNewImagePath = m_sMediaDir + _T("\\") + sNewImageName; + CString sNewImagePath = m_sMediaDir + FILE_SEPARATOR_STR + sNewImageName; return sNewImagePath; } void ReadMediaItemSaveFileFILE(FILE* pFile) @@ -3042,7 +3042,7 @@ namespace BinXlsxRW { sDstPath += _T("Temp"); OOX::Spreadsheet::CXlsx oXlsx; - SaveParams oSaveParams(sDstPath + _T("\\") + OOX::Spreadsheet::FileTypes::Workbook.DefaultDirectory().GetPath() + _T("\\") + OOX::FileTypes::Theme.DefaultDirectory().GetPath()); + SaveParams oSaveParams(sDstPath + _T("/") + OOX::Spreadsheet::FileTypes::Workbook.DefaultDirectory().GetPath() + _T("/") + OOX::FileTypes::Theme.DefaultDirectory().GetPath()); ReadMainTable(oXlsx, oBufferedStream, OOX::CPath(sSrcFileName).GetDirectory(), sDstPath, oSaveParams, pOfficeDrawingConverter); CString sAdditionalContentTypes = oSaveParams.sAdditionalContentTypes; if(NULL != pOfficeDrawingConverter) @@ -3101,7 +3101,7 @@ namespace BinXlsxRW { aOffBits.push_back(mtiOffBits); } } - CString sMediaDir = sOutDir + _T("\\xl\\media"); + CString sMediaDir = sOutDir + _T("/xl/media"); std::map mapMedia; if(-1 != nOtherOffBits) { @@ -3162,4 +3162,4 @@ namespace BinXlsxRW { } }; }; -#endif // #ifndef BINARY_READER \ No newline at end of file +#endif // #ifndef BINARY_READER