diff --git a/ASCOfficePPTXFile/ASCOfficeDrawingConverter.cpp b/ASCOfficePPTXFile/ASCOfficeDrawingConverter.cpp index b3a68ee0c8..104301f3cd 100644 --- a/ASCOfficePPTXFile/ASCOfficeDrawingConverter.cpp +++ b/ASCOfficePPTXFile/ASCOfficeDrawingConverter.cpp @@ -691,11 +691,13 @@ CElementProps::~CElementProps() } void CElementProps::FinalRelease() { +#ifdef _WIN32 // linux: BSTR = CString for (std::map::iterator pPair = m_Properties.begin(); pPair != m_Properties.end(); ++pPair) { if (pPair->second.vt == VT_BSTR) SysFreeString(pPair->second.bstrVal); } +#endif m_Properties.clear(); } HRESULT CElementProps::GetProperty(LONG lId, VARIANT* pProp) @@ -934,7 +936,7 @@ HRESULT CDrawingConverter::AddObject(const CString& bsXml, CString** pMainProps) return bResult ? S_OK : S_FALSE; } -bool CDrawingConverter::ParceObject(const ATL::CString& strXml, CString** pMainProps) +bool CDrawingConverter::ParceObject(const CString& strXml, CString** pMainProps) { XmlUtils::CXmlNode oMainNode; if (!oMainNode.FromXmlString(strXml)) diff --git a/ASCOfficePPTXFile/Editor/WMFToImageConverter.h b/ASCOfficePPTXFile/Editor/WMFToImageConverter.h index 862568312e..1f3bf4c03c 100644 --- a/ASCOfficePPTXFile/Editor/WMFToImageConverter.h +++ b/ASCOfficePPTXFile/Editor/WMFToImageConverter.h @@ -196,10 +196,13 @@ namespace NSWMFToImageConverter m_pSVGRenderer->put_Width(lWidth); m_pSVGRenderer->put_Height(lHeight); +#ifndef _WIN32 + MetaDrawOnRenderer(m_pSVGRenderer, strPath, (double)lWidth, (double)lHeight); +#else BSTR bsFilePath = strPath.AllocSysString(); MetaDrawOnRenderer(m_pSVGRenderer, bsFilePath, (double)lWidth, (double)lHeight); SysFreeString(bsFilePath); - +#endif bool bIsRaster = false; m_pSVGRenderer->IsRaster(&bIsRaster); if (bIsRaster) @@ -217,4 +220,4 @@ namespace NSWMFToImageConverter }; } -#endif \ No newline at end of file +#endif diff --git a/ASCOfficePPTXFile/Editor/imagemanager.h b/ASCOfficePPTXFile/Editor/imagemanager.h index a1ecba4771..e498b42edd 100644 --- a/ASCOfficePPTXFile/Editor/imagemanager.h +++ b/ASCOfficePPTXFile/Editor/imagemanager.h @@ -19,6 +19,7 @@ using namespace NSFontCutter; #include "../../DesktopEditor/raster/ImageFileFormatChecker.h" #include "../../DesktopEditor/raster/BgraFrame.h" #include "../../DesktopEditor/graphics/Image.h" +#include "../../Common/DocxFormat/Source/SystemUtility/File.h" #include @@ -28,8 +29,9 @@ namespace NSShapeImageGen static BOOL _CopyFile(CString strExists, CString strNew, LPPROGRESS_ROUTINE lpFunc, LPVOID lpData) { - ::DeleteFile(strNew); - return ::CopyFileEx(strExists, strNew, lpFunc, lpData, FALSE, 0); + //::DeleteFile(strNew); + //return ::CopyFileEx(strExists, strNew, lpFunc, lpData, FALSE, 0); + return CDirectory::CopyFile (strExists, strNew, lpFunc, lpData); } enum ImageType diff --git a/ASCOfficePPTXFile/PPTXFormat/Theme/ClrScheme.h b/ASCOfficePPTXFile/PPTXFormat/Theme/ClrScheme.h index 9588239506..33fea85d96 100644 --- a/ASCOfficePPTXFile/PPTXFormat/Theme/ClrScheme.h +++ b/ASCOfficePPTXFile/PPTXFormat/Theme/ClrScheme.h @@ -22,7 +22,8 @@ namespace PPTX Logic::UniColor lColor; Scheme.clear(); - lColor.GetColorFrom(node.ReadNode(_T("a:dk1"))); Scheme.insert(std::pair(_T("dk1"), lColor)); + lColor.GetColorFrom(node.ReadNode(_T("a:dk1"))); + Scheme.insert(std::pair(_T("dk1"), lColor)); lColor.GetColorFrom(node.ReadNode(_T("a:lt1"))); Scheme.insert(std::pair(_T("lt1"), lColor)); lColor.GetColorFrom(node.ReadNode(_T("a:dk2"))); Scheme.insert(std::pair(_T("dk2"), lColor)); lColor.GetColorFrom(node.ReadNode(_T("a:lt2"))); Scheme.insert(std::pair(_T("lt2"), lColor)); @@ -206,4 +207,4 @@ namespace PPTX } // namespace nsTheme } // namespace PPTX -#endif // PPTX_THEME_CLRSCHEME_INCLUDE_H \ No newline at end of file +#endif // PPTX_THEME_CLRSCHEME_INCLUDE_H diff --git a/ASCOfficePPTXFile/PPTXLib/Linux/PPTXFormatLib/PPTXFormatLib.pro b/ASCOfficePPTXFile/PPTXLib/Linux/PPTXFormatLib/PPTXFormatLib.pro index c63a28795d..4c44803577 100644 --- a/ASCOfficePPTXFile/PPTXLib/Linux/PPTXFormatLib/PPTXFormatLib.pro +++ b/ASCOfficePPTXFile/PPTXLib/Linux/PPTXFormatLib/PPTXFormatLib.pro @@ -17,7 +17,8 @@ DEFINES += UNICODE \ _USE_XMLLITE_READER_ \ NODOCX \ DISABLE_FILE_DOWNLOADER \ - CXIMAGE_DONT_DECLARE_TCHAR + CXIMAGE_DONT_DECLARE_TCHAR \ + BUILD_CONFIG_FULL_VERSION INCLUDEPATH += \ /usr/include/libxml2 diff --git a/ASCPresentationEditor/OfficeDrawing/Attributes.h b/ASCPresentationEditor/OfficeDrawing/Attributes.h index fb415183b0..285bf04d80 100644 --- a/ASCPresentationEditor/OfficeDrawing/Attributes.h +++ b/ASCPresentationEditor/OfficeDrawing/Attributes.h @@ -500,16 +500,11 @@ namespace NSPresentationEditor if (DashStyle != Gdiplus::DashStyleSolid) { - SAFEARRAYBOUND rgsab; - rgsab.lLbound = 0; - rgsab.cElements = Count; - SAFEARRAY* pArray = SafeArrayCreate(VT_R8, 1, &rgsab); - memcpy(pArray->pvData, DashPattern, Count * sizeof(double)); pRenderer->PenDashPattern(DashPattern, Count); - RELEASEARRAY(pArray); + pRenderer->put_PenDashOffset(DashOffset); } } @@ -817,9 +812,9 @@ namespace NSPresentationEditor } else if (IsTexture()) { - BSTR bstrTexturePath = TexturePath.AllocSysString(); - pRenderer->put_BrushTexturePath(bstrTexturePath); - SysFreeString(bstrTexturePath); + //BSTR bstrTexturePath = TexturePath.AllocSysString(); + pRenderer->put_BrushTexturePath(TexturePath); + //SysFreeString(bstrTexturePath); pRenderer->put_BrushTextureMode(TextureMode); pRenderer->put_BrushTextureAlpha(TextureAlpha); pRenderer->BrushRect(Rectable, Rect.X, Rect.Y, Rect.Width, Rect.Height); diff --git a/ASCPresentationEditor/OfficeDrawing/Base.h b/ASCPresentationEditor/OfficeDrawing/Base.h index d1a6dd3853..2db7c6a2ca 100644 --- a/ASCPresentationEditor/OfficeDrawing/Base.h +++ b/ASCPresentationEditor/OfficeDrawing/Base.h @@ -64,11 +64,6 @@ namespace NSPresentationEditor if ((NULL == pMapDst) || (NULL == pMapSrc)) return; - for (std::map::const_iterator pPair = pMapSrc->begin(); pPair != pMapSrc->end(); ++pPair) - { - TKey key = pPair->first; - TVal value = pPair->second; - (*pMapDst)[key] = value; - } + (*pMapDst) = (*pMapSrc); } } diff --git a/ASCPresentationEditor/OfficeDrawing/Elements.h b/ASCPresentationEditor/OfficeDrawing/Elements.h index 1af4f3beee..ba4bb03721 100644 --- a/ASCPresentationEditor/OfficeDrawing/Elements.h +++ b/ASCPresentationEditor/OfficeDrawing/Elements.h @@ -1876,11 +1876,13 @@ namespace NSStrings public: +#ifdef _WIN32 AVSINLINE void WriteString(_bstr_t& bsString) { size_t nLen = bsString.length(); CTextItem::WriteString(bsString.GetBSTR(), nLen); } +#endif AVSINLINE void WriteString(CString& sString) { size_t nLen = (size_t)sString.GetLength(); diff --git a/ASCPresentationEditor/PPTXWriter/CSS.h b/ASCPresentationEditor/PPTXWriter/CSS.h index 32f344bba4..d34ed82f96 100644 --- a/ASCPresentationEditor/PPTXWriter/CSS.h +++ b/ASCPresentationEditor/PPTXWriter/CSS.h @@ -577,7 +577,7 @@ public: if (_T("p") == oNodePar.GetName()) { - pParagraph->m_oPFRun.hasBullet = FALSE; + pParagraph->m_oPFRun.hasBullet = false; CString strClass = oNodePar.GetAttribute(_T("class")); diff --git a/Common/DocxFormat/Source/SystemUtility/File.h b/Common/DocxFormat/Source/SystemUtility/File.h index 01781c58e2..a7a2ffbf3d 100644 --- a/Common/DocxFormat/Source/SystemUtility/File.h +++ b/Common/DocxFormat/Source/SystemUtility/File.h @@ -675,6 +675,289 @@ namespace StreamUtils } #else +#include +#include +#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 OpenOrCreate(CString strFileName) + { + CloseFile(); + + HRESULT hRes = S_OK; + DWORD AccessMode = GENERIC_READ | GENERIC_WRITE; + DWORD ShareMode = FILE_SHARE_WRITE; + DWORD Disposition = OPEN_ALWAYS; + m_hFileHandle = ::CreateFile(strFileName, AccessMode, ShareMode, NULL, Disposition, FILE_ATTRIBUTE_NORMAL, NULL); + + if (NULL == m_hFileHandle || INVALID_HANDLE_VALUE == m_hFileHandle) + hRes = S_FALSE; + else + { + ULARGE_INTEGER nTempSize; + nTempSize.LowPart = ::GetFileSize(m_hFileHandle, &nTempSize.HighPart); + m_lFileSize = nTempSize.QuadPart; + + SetPosition(m_lFileSize); + } + + return hRes; + } + virtual HRESULT OpenFile(CString FileName) + { + CloseFile(); + + HRESULT hRes = S_OK; + DWORD AccessMode = GENERIC_READ; + DWORD ShareMode = FILE_SHARE_READ; + DWORD Disposition = OPEN_EXISTING; + m_hFileHandle = ::CreateFile(FileName, AccessMode, ShareMode, NULL, Disposition, FILE_ATTRIBUTE_NORMAL, NULL); + + if (NULL == m_hFileHandle || INVALID_HANDLE_VALUE == m_hFileHandle) + hRes = S_FALSE; + else + { + ULARGE_INTEGER nTempSize; + nTempSize.LowPart = ::GetFileSize(m_hFileHandle, &nTempSize.HighPart); + m_lFileSize = nTempSize.QuadPart; + + SetPosition(0); + } + + return hRes; + } + + virtual HRESULT OpenFileRW(CString FileName) + { + CloseFile(); + + HRESULT hRes = S_OK; + DWORD AccessMode = GENERIC_READ | GENERIC_WRITE; + DWORD ShareMode = FILE_SHARE_READ; + DWORD Disposition = OPEN_EXISTING; + m_hFileHandle = ::CreateFile(FileName, AccessMode, ShareMode, NULL, Disposition, 0, 0); + + if (NULL == m_hFileHandle || INVALID_HANDLE_VALUE == m_hFileHandle) + { + hRes = S_FALSE; + } + else + { + ULARGE_INTEGER nTempSize; + nTempSize.LowPart = ::GetFileSize(m_hFileHandle, &nTempSize.HighPart); + m_lFileSize = nTempSize.QuadPart; + + SetPosition(0); + } + + return hRes; + } + + + HRESULT ReadFile2(BYTE* pData, DWORD nBytesToRead) + { + DWORD nBytesRead = 0; + if(NULL == pData) + return S_FALSE; + + if(m_hFileHandle && (pData)) + { + SetPosition(m_lFilePosition); + ::ReadFile(m_hFileHandle, pData, nBytesToRead, &nBytesRead, NULL); + m_lFilePosition += nBytesRead; + + for (size_t index = 0; index < nBytesToRead / 2; ++index) + { + BYTE temp = pData[index]; + pData[index] = pData[nBytesToRead - index - 1]; + pData[nBytesToRead - index - 1] = temp; + } + } + return S_OK; + } + HRESULT ReadFile3(void* pData, DWORD nBytesToRead) + { + DWORD nBytesRead = 0; + if(NULL == pData) + return S_FALSE; + + if(m_hFileHandle && (pData)) + { + SetPosition(m_lFilePosition); + ::ReadFile(m_hFileHandle, pData, nBytesToRead, &nBytesRead, NULL); + m_lFilePosition += nBytesRead; + } + return S_OK; + } + + HRESULT WriteFile2(void* pData, DWORD nBytesToWrite) + { + if(m_hFileHandle) + { + BYTE* mem = new BYTE[nBytesToWrite]; + memcpy(mem, pData, nBytesToWrite); + + for (size_t index = 0; index < nBytesToWrite / 2; ++index) + { + BYTE temp = mem[index]; + mem[index] = mem[nBytesToWrite - index - 1]; + mem[nBytesToWrite - index - 1] = temp; + } + + DWORD dwWritten = 0; + ::WriteFile(m_hFileHandle, (void*)mem, nBytesToWrite, &dwWritten, NULL); + m_lFilePosition += nBytesToWrite; + RELEASEARRAYOBJECTS(mem); + } + return S_OK; + } + + HRESULT SetPosition( ULONG64 nPos ) + { + if (m_hFileHandle && nPos <= (ULONG)m_lFileSize) + { + LARGE_INTEGER nTempPos; + nTempPos.QuadPart = nPos; + ::SetFilePointer(m_hFileHandle, nTempPos.LowPart, &nTempPos.HighPart, FILE_BEGIN); + m_lFilePosition = nPos; + return S_OK; + } + else + { + return (INVALID_HANDLE_VALUE == m_hFileHandle) ? S_FALSE : S_OK; + } + } + LONG64 GetPosition() + { + return m_lFilePosition; + } + HRESULT SkipBytes(ULONG64 nCount) + { + return SetPosition(m_lFilePosition + nCount); + } + + HRESULT CloseFile() + { + m_lFileSize = 0; + m_lFilePosition = 0; + RELEASEHANDLE(m_hFileHandle); + return S_OK; + } + + ULONG64 GetFileSize() + { + return m_lFileSize; + } + + HRESULT WriteReserved(DWORD dwCount) + { + BYTE* buf = new BYTE[dwCount]; + memset(buf, 0, (size_t)dwCount); + HRESULT hr = WriteFile(buf, dwCount); + RELEASEARRAYOBJECTS(buf); + return hr; + } + HRESULT WriteReserved2(DWORD dwCount) + { + BYTE* buf = new BYTE[dwCount]; + memset(buf, 0xFF, (size_t)dwCount); + HRESULT hr = WriteFile(buf, dwCount); + RELEASEARRAYOBJECTS(buf); + return hr; + } + HRESULT WriteReservedTo(DWORD dwPoint) + { + if (m_lFilePosition >= dwPoint) + return S_OK; + + DWORD dwCount = dwPoint - (DWORD)m_lFilePosition; + BYTE* buf = new BYTE[dwCount]; + memset(buf, 0, (size_t)dwCount); + HRESULT hr = WriteFile(buf, dwCount); + RELEASEARRAYOBJECTS(buf); + return hr; + } + HRESULT SkipReservedTo(DWORD dwPoint) + { + if (m_lFilePosition >= dwPoint) + return S_OK; + + DWORD dwCount = dwPoint - (DWORD)m_lFilePosition; + return SkipBytes(dwCount); + } + + LONG GetProgress() + { + if (0 >= m_lFileSize) + return -1; + + double dVal = (double)(100 * m_lFilePosition); + LONG lProgress = (LONG)(dVal / m_lFileSize); + return lProgress; + } + + void WriteStringUTF8(CString& strXml) + { + int nLength = strXml.GetLength(); + + CStringA saStr; + +#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(); +#else + wchar_t* pWStr = new wchar_t[nLength + 1]; + if (!pWStr) + return; + + // set end string + pWStr[nLength] = 0; + + // Encoding ASCII to Unicode + MultiByteToWideChar(CP_ACP, 0, strXml, nLength, pWStr, nLength); + + int nLengthW = (int)wcslen(pWStr); + + // Encoding Unicode to UTF-8 + WideCharToMultiByte(CP_UTF8, 0, pWStr, nLengthW + 1, saStr.GetBuffer(nLengthW*3 + 1), nLengthW*3, NULL, NULL); + saStr.ReleaseBuffer(); + + delete[] pWStr; +#endif + + WriteFile((void*)saStr.GetBuffer(), saStr.GetLength()); + } + +private: + FILE* m_pFile; + + long m_lFilePosition; + long m_lFileSize; + */ +}; + namespace CDirectory { static void SaveToFile(CString strFileName, CString strXml) @@ -697,6 +980,27 @@ namespace CDirectory str.Format(_T("%d"), (LONG)val); return str; } +#ifndef LPPROGRESS_ROUTINE +#define LPPROGRESS_ROUTINE LPVOID +#endif + static BOOL CopyFile (CString strExists, CString strNew, LPPROGRESS_ROUTINE lpFunc = NULL, LPVOID lpData = NULL) + { + BOOL bRes = TRUE; + try + { + std::string stdstrFrom = stringWstingToUtf8String(strExists); + std::string stdstrTo = stringWstingToUtf8String(strNew); + std::ifstream src (stdstrFrom.c_str(), std::ios::binary); + std::ofstream dst (stdstrTo.c_str(), std::ios::binary); + + dst << src.rdbuf(); + } + catch (...) + { + bRes = FALSE; + } + return bRes; + } } #endif diff --git a/DesktopEditor/common/ASCVariant.h b/DesktopEditor/common/ASCVariant.h index 7f028760b1..96f4a9747d 100644 --- a/DesktopEditor/common/ASCVariant.h +++ b/DesktopEditor/common/ASCVariant.h @@ -82,6 +82,7 @@ struct VARIANT SHORT iVal; FLOAT fltVal; BSTR bstrVal; + VARIANT_BOOL boolVal; double dblVal; }; /*