Commit 4fcc2101 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

X2t Converter подключение txt &ppt

fix bugs ppt

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@62503 954022d7-b5bf-4e40-9824-e11837661b57
parent 009f2b44
......@@ -20,17 +20,17 @@ COfficePPTFile::~COfficePPTFile()
CloseFile();
}
bool COfficePPTFile::OpenFile(CString sFileName)
bool COfficePPTFile::OpenFile(std::wstring sFileName)
{
CloseFile();
POLE::Storage *pStgFrom = new POLE::Storage(sFileName);
POLE::Storage *pStgFrom = new POLE::Storage(sFileName.c_str());
if (pStgFrom == NULL) return FALSE;
pStgFrom->open(false,false);
m_pReader = new CPPTFileReader(pStgFrom, m_strTempDirectory);
((CPPTFileReader*)m_pReader)->m_oDocumentInfo.m_strFileDirectory = GetDirectory(sFileName);
((CPPTFileReader*)m_pReader)->m_oDocumentInfo.m_strFileDirectory = GetDirectory(sFileName.c_str());
if (!((CPPTFileReader*)m_pReader)->IsPowerPoint())
{
......@@ -54,11 +54,11 @@ bool COfficePPTFile::CloseFile()
m_pReader = NULL;
return S_OK;
}
HRESULT COfficePPTFile::LoadFromFile(CString sSrcFileName, CString sDstPath, CString sXMLOptions)
HRESULT COfficePPTFile::LoadFromFile(std::wstring sSrcFileName, std::wstring sDstPath)
{
if (m_strTempDirectory.GetLength() < 1)
if (m_strTempDirectory.length() < 1)
{
m_strTempDirectory = FileSystem::Directory::GetTempPath();
m_strTempDirectory = FileSystem::Directory::GetTempPath().GetBuffer();
}
bool bRes = OpenFile(sSrcFileName);
......@@ -78,40 +78,20 @@ HRESULT COfficePPTFile::LoadFromFile(CString sSrcFileName, CString sDstPath, CSt
if (m_strEditorXml.GetLength() <1) return S_FALSE;
if (sDstPath.GetLength() > 0)
if (sDstPath.length() > 0)
{
bool bNeedPPTXFile = false;
#if !(defined(_WIN32) || defined (_WIN64)) || defined(_DEBUG)
bNeedPPTXFile = true;
#endif
NSPresentationEditor::CDocument oPresentationEditor;
NSPresentationEditor::CPPTXWriter oPPTXWriter;
oPresentationEditor.LoadFromXML(m_strEditorXml);
oPPTXWriter.m_strTempDirectory = sDstPath;
oPPTXWriter.m_strTempDirectory = std_string2string(sDstPath);
if (bNeedPPTXFile)
{
oPPTXWriter.m_strTempDirectory = FileSystem::Directory::CreateDirectoryWithUniqueName(m_strTempDirectory);
}
oPPTXWriter.CreateFile(&oPresentationEditor);
oPPTXWriter.CloseFile();
if (bNeedPPTXFile)
{
COfficeUtils oOfficeUtils(NULL);
std::wstring bstrSrcPath = string2std_string(oPPTXWriter.m_strTempDirectory);
std::wstring bstrDstPath = string2std_string(sDstPath);
oOfficeUtils.CompressFileOrDirectory( bstrSrcPath, bstrDstPath, -1 );
FileSystem::Directory::DeleteDirectory(oPPTXWriter.m_strTempDirectory);
}
}
//CloseFile(); нельзя тута- поскольку в Win32 используется PresentationEditor для конвертации xml -> pptx
......
......@@ -32,27 +32,27 @@ private:
std::vector<CString> m_arUserSources;
CString m_strEditorXml;
CString m_strTempDirectory;
std::wstring m_strTempDirectory;
public:
HRESULT put_TempDirectory(CString sDir)
HRESULT put_TempDirectory(std::wstring sDir)
{
m_strTempDirectory = sDir;
return S_OK;
}
CString get_TempDirectory()
std::wstring get_TempDirectory()
{
return m_strTempDirectory;
}
HRESULT LoadFromFile(CString sSrcFileName, CString sDstPath, CString sXMLOptions);
HRESULT LoadFromFile(std::wstring sSrcFileName, std::wstring sDstPath);
HRESULT GetAdditionalParam (CString sParamName, VARIANT* ParamValue);
private:
bool OpenFile(CString sFileName);
bool OpenFile(std::wstring sFileName);
bool CloseFile();
......
......@@ -88,7 +88,7 @@ public:
m_arUsers[i]->FromDocument();
}
#ifdef _DEBUG
#if defined(_DEBUG) && (defined(_WIN32) || defined(_WIN64))
SaveXmlInfo();
#endif
}
......
......@@ -12,10 +12,10 @@
typedef BYTE BOOL1;
#define PSFLAG_CONTAINER 0xFF
#ifdef _DEBUG
#define PPT_DUMP_LOG FALSE // TRUE - xml
#if defined(_DEBUG) && (defined(_WIN32) || defined(_WIN64))
#define PPT_DUMP_LOG FALSE // TRUE - xml
#else
#define PPT_DUMP_LOG FALSE //
#define PPT_DUMP_LOG FALSE //
#endif
#define PPT_DEFAULT_SLIDE_DURATION 5000
......
......@@ -68,7 +68,7 @@ public:
m_nRelVersion = StreamUtils::ReadDWORD(pStream);
m_strUNICODEUserName = StreamUtils::ReadCStringW(pStream, m_nLenUserName);
m_strUNICODEUserName = StreamUtils::ReadCStringW(pStream, m_nLenUserName );
}
virtual CString ToString()
......
......@@ -30,7 +30,37 @@ public:
{
m_oHeader = oHeader;
m_strFaceName = StreamUtils::ReadCStringW(pStream, 32);
//face name - utf16 string with 0, 64 bytes always allocated
unsigned char utf16FaceName[64+2] = {};
ULONG lReadByte = pStream->read(utf16FaceName, 64);
if (sizeof(wchar_t) == 4)
{
int lLen = 0;
for (lLen = 0; lLen < lReadByte; lLen +=2)
if (utf16FaceName[lLen] == 0)break;
lLen/=2;
UTF32 *pStrUtf32 = new UTF32 [lLen + 1];
pStrUtf32[lLen] = 0 ;
const UTF16 *pStrUtf16_Conv = (const UTF16 *) utf16FaceName;
UTF32 *pStrUtf32_Conv = pStrUtf32;
if (conversionOK == ConvertUTF16toUTF32 ( &pStrUtf16_Conv, &pStrUtf16_Conv[lLen]
, &pStrUtf32_Conv, &pStrUtf32 [lLen]
, strictConversion))
{
m_strFaceName = CString((wchar_t*)pStrUtf32, lLen);
}
delete [] pStrUtf32;
}
else
{
m_strFaceName = CString((wchar_t*)utf16FaceName, lReadByte/2);
}
m_lfCharSet = StreamUtils::ReadBYTE(pStream);
BYTE Mem = 0;
......
......@@ -49,7 +49,7 @@
#define RENDER_RTF_BOOL( prop, sResult, sName)\
if( 0 == prop )\
sResult.AppendFormat( _T("\\%s0"), sName );\
sResult.AppendFormat( _T("\\%ls0"), sName );\
else if( PROP_DEF != prop )\
sResult.AppendFormat( _T("\\%ls"), sName );
......@@ -638,7 +638,7 @@ private:
CString sTheme;
if( true == GetStringByTheme( sTheme, m_eTheme ) )
{
sResult.AppendFormat(_T("theme%sColor = \"%ls\" theme%sShade = \"%d\" theme%sTint = \"%d\""),
sResult.AppendFormat(_T("theme%lsColor = \"%ls\" theme%lsShade = \"%d\" theme%lsTint = \"%d\""),
sParam.GetBuffer(), sTheme.GetBuffer(), sParam.GetBuffer(), m_byteShade ,sParam.GetBuffer(), m_byteTint);
}
}
......
......@@ -366,7 +366,7 @@ namespace NSPresentationEditor
CString element;
element.Format ( _T("<VideoStream left='%d' top='%d' right='%d' bottom='%d' angle='%f' loop='%d' ")
_T(" widthmetric='%d' heightmetric='%d' ")
_T(" file='%s' begin='%f' end='%f' >"),
_T(" file='%ls' begin='%f' end='%f' >"),
(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 );
......@@ -407,7 +407,7 @@ namespace NSPresentationEditor
CorrectXmlString(strFileName);
CString source;
source.Format(_T("<Source StartTime='%lf' EndTime='%lf' FilePath='%s'/>"), m_dClipStartTime, m_dClipEndTime, strFileName);
source.Format(_T("<Source StartTime='%lf' EndTime='%lf' FilePath='%ls'/>"), m_dClipStartTime, m_dClipEndTime, strFileName);
element += source;
CString animations;
......@@ -480,7 +480,7 @@ namespace NSPresentationEditor
lFlags |= 0x0002;
CString strEffect = _T("");
strEffect.Format(_T("<ImagePaint-DrawImageFromFile left='%d' top='%d' right='%d' bottom='%d' angle='%lf' flags='%d' filepath='%s' metric='0' backcolor='-1' scaletype='-1' scalecolor='255' widthmetric='%d' heightmetric='%d'>\
strEffect.Format(_T("<ImagePaint-DrawImageFromFile left='%d' top='%d' right='%d' bottom='%d' angle='%lf' flags='%d' filepath='%ls' metric='0' backcolor='-1' scaletype='-1' scalecolor='255' widthmetric='%d' heightmetric='%d'>\
<timeline type='1' begin='%lf' end='%lf' fadein='0' fadeout='0' completeness='1.0' /></ImagePaint-DrawImageFromFile>"),
(LONG)m_rcBounds.left, (LONG)m_rcBounds.top, (LONG)m_rcBounds.right, (LONG)m_rcBounds.bottom,
m_dRotate, lFlags, m_strFileName,
......@@ -499,7 +499,7 @@ namespace NSPresentationEditor
lFlags |= 0x0002;
CString strEffect = _T("");
strEffect.Format(_T("<ImagePaint-DrawImageFromFile left='%d' top='%d' right='%d' bottom='%d' angle='%lf' flags='%d' filepath='%s' metric='0' backcolor='-1' scaletype='-1' scalecolor='255' widthmetric='%d' heightmetric='%d'>\
strEffect.Format(_T("<ImagePaint-DrawImageFromFile left='%d' top='%d' right='%d' bottom='%d' angle='%lf' flags='%d' filepath='%ls' metric='0' backcolor='-1' scaletype='-1' scalecolor='255' widthmetric='%d' heightmetric='%d'>\
<timeline type='1' begin='%lf' end='%lf' fadein='0' fadeout='0' completeness='1.0' /></ImagePaint-DrawImageFromFile>"),
(LONG)m_rcBounds.left, (LONG)m_rcBounds.top, (LONG)m_rcBounds.right, (LONG)m_rcBounds.bottom,
m_dRotate, lFlags, m_strFileName,
......@@ -1603,7 +1603,7 @@ namespace NSPresentationEditor
CorrectXmlString(strFileName);
CString source;
source.Format(_T("<Source StartTime='%lf' EndTime='%lf' FilePath='%s' loop='%d' />"), m_dClipStartTime, m_dClipEndTime, strFileName, m_bLoop);
source.Format(_T("<Source StartTime='%lf' EndTime='%lf' FilePath='%ls' loop='%d' />"), m_dClipStartTime, m_dClipEndTime, strFileName, m_bLoop);
element += source;
CString animations;
......
......@@ -947,7 +947,7 @@ namespace SVG
PathParser& oPath = element->GetPath ();
for (long i = 0; i < (long)element->GetSize (); ++i)
{
#ifdef _DEBUG
#if defined(_DEBUG) && (defined(_WIN32) || defined(_WIN64))
WCHAR Code = element->GetCode(i);
#endif
if (_T('Z') == element->GetCode(i) || _T('z') == element->GetCode(i))
......@@ -1301,7 +1301,7 @@ namespace SVG
for (long i = 0; i < (long)element->GetSize (); ++i)
{
#ifdef _DEBUG
#if defined(_DEBUG) && (defined(_WIN32) || defined(_WIN64))
WCHAR Code = element->GetCode (i);
#endif
if ( _T('Z') == element->GetCode (i) || _T('z') == element->GetCode (i) )
......@@ -2549,7 +2549,7 @@ namespace SVG
// m_render->DrawImage(m_pFrame, t.X - Width * mul.X, t.Y, Width * mul.X, Height * mul.Y);
// }
// m_sLivePath.Format (_T("%s\\%s.png"), FileUtils::GetTempFolder(), m_pattern->nodeId());
// m_sLivePath.Format (_T("%ls\\%ls.png"), FileUtils::GetTempFolder(), m_pattern->nodeId());
// SaveImage(m_pPatternFrame, m_sLivePath);
// }
......
......@@ -2700,7 +2700,7 @@ namespace SVG
CString Source = path.Tokenize ( Tokens, To );
// ATLTRACE ( _T("%c : - %s\n"), symbol, Source );
// ATLTRACE ( _T("%c : - %ls\n"), symbol, Source );
std::vector<double> Values;
if (StrUtils::DoubleValues(Source, Values))
......@@ -2881,7 +2881,7 @@ namespace SVG
CString Source = path.Tokenize ( Tokens, To );
// ATLTRACE ( _T("%c : - %s\n"), symbol, Source );
// ATLTRACE ( _T("%c : - %ls\n"), symbol, Source );
std::vector<double> Values;
if (StrUtils::DoubleValues(Source, Values))
......@@ -3200,7 +3200,7 @@ namespace SVG
{
if (0 == m_sXml.GetLength())
{
m_sXml.Format(_T("<linearGradient x1='%f' y1='%f' x2='%f' y2='%f' gradientUnits ='%s' gradientTransform='matrix(%f, %f, %f, %f, %f, %f)' sourceType='svg' >"),
m_sXml.Format(_T("<linearGradient x1='%f' y1='%f' x2='%f' y2='%f' gradientUnits ='%ls' gradientTransform='matrix(%f, %f, %f, %f, %f, %f)' sourceType='svg' >"),
m_begin.X, m_begin.Y, m_end.X, m_end.Y, m_gradientUnits,
m_gradientTransform[0], m_gradientTransform[1],
m_gradientTransform[3], m_gradientTransform[4],
......@@ -3316,7 +3316,7 @@ namespace SVG
{
if (0 == m_sXml.GetLength())
{
m_sXml.Format(_T("<radialGradient cx='%f' cy='%f' fx='%f' fy='%f' r='%f' gradientUnits='%s' gradientTransform='matrix(%f, %f, %f, %f, %f, %f)' sourceType='svg' >"),
m_sXml.Format(_T("<radialGradient cx='%f' cy='%f' fx='%f' fy='%f' r='%f' gradientUnits='%ls' gradientTransform='matrix(%f, %f, %f, %f, %f, %f)' sourceType='svg' >"),
m_c.X, m_c.Y, m_f.X, m_f.Y, m_R,
m_gradientUnits,
m_gradientTransform[0], m_gradientTransform[1],
......@@ -3406,8 +3406,8 @@ namespace SVG
// link
virtual bool RefreshXLinkSource (IRefStorage* pStorage)
{
#ifdef _DEBUG
// ATLTRACE (L"NOT IMPLEMENTED - RefreshXLinkSource: id - %s\n", nodeId());
#if defined(_DEBUG) && (defined(_WIN32) || defined(_WIN64))
// ATLTRACE (L"NOT IMPLEMENTED - RefreshXLinkSource: id - %ls\n", nodeId());
#endif
return false;
}
......@@ -4097,7 +4097,7 @@ namespace SVG
// GetSystemTime ( &oTime );
// CString fileName;
// fileName.Format (_T("%s\\%d%d%d%d%d%d%s"), sTempPath, oTime.wYear, oTime.wDay, oTime.wHour, oTime.wMinute, oTime.wSecond, oTime.wMilliseconds, strExts );
// fileName.Format (_T("%ls\\%d%d%d%d%d%d%ls"), sTempPath, oTime.wYear, oTime.wDay, oTime.wHour, oTime.wMinute, oTime.wSecond, oTime.wMilliseconds, strExts );
// CImageManager::CopyFile(strInput, fileName, NULL, NULL);
......@@ -4316,7 +4316,7 @@ namespace SVG
{
m_pRefLink = pRefLink;
// ATLTRACE(_T("RefLink for object : %s - %s\n"), nodeId(), m_pRefLink->nodeId());
// ATLTRACE(_T("RefLink for object : %ls - %ls\n"), nodeId(), m_pRefLink->nodeId());
return true;
}
......@@ -4523,8 +4523,9 @@ namespace SVG
{
if (L"clipPath" == oXml.GetName ())
return false;
#ifdef _DEBUG
ATLTRACE (L"[svg] ClipPath-NodeName : %s\n", oXml.GetName());
#if defined(_DEBUG) && (defined(_WIN32) || defined(_WIN64))
ATLTRACE (L"[svg] ClipPath-NodeName : %ls\n", oXml.GetName());
#endif
DrawElement* pClip = m_oBuilder.Build (oXml.GetName());
......@@ -4675,8 +4676,8 @@ namespace SVG
}
inline bool Load(XmlUtils::CXmlNode& oXml)
{
#ifdef _DEBUG
ATLTRACE (L"[svg] Pattern-NodeName : %s\n", oXml.GetName());
#if defined(_DEBUG) && (defined(_WIN32) || defined(_WIN64))
ATLTRACE (L"[svg] Pattern-NodeName : %ls\n", oXml.GetName());
#endif
DrawElement* element = m_oBuilder.Build (oXml.GetName());
......@@ -4985,8 +4986,9 @@ namespace SVG
if (m_model->HashRef(pReference, true))
UpdateSymbol(pReference, oXml);
#ifdef _DEBUG
ATLTRACE(L"[svg] ref element (g) - : %s\n", strXmlNode);
#if defined(_DEBUG) && (defined(_WIN32) || defined(_WIN64))
ATLTRACE(L"[svg] ref element (g) - : %ls\n", strXmlNode);
#endif
return true;
}
......@@ -5000,8 +5002,9 @@ namespace SVG
inline DrawElement* Create(XmlUtils::CXmlNode& oXml, bool bAddStorage = true)
{
CString strXmlNode = oXml.GetName();
#ifdef _DEBUG
ATLTRACE(L"[svg] render element (g) - : %s\n", strXmlNode);
#if defined(_DEBUG) && (defined(_WIN32) || defined(_WIN64))
ATLTRACE(L"[svg] render element (g) - : %ls\n", strXmlNode);
#endif
DrawElement* element = m_oDrawBuilder.Build(strXmlNode);
if (element)
......@@ -5050,7 +5053,7 @@ namespace SVG
element->FromXml(oXml, m_oUs);
// ATLTRACE(L"GraphicsContainer : %s - push : %s\n", m_nodeId, oXmlNode.GetName());
// ATLTRACE(L"GraphicsContainer : %ls - push : %ls\n", m_nodeId, oXmlNode.GetName());
if (bAddStorage)
m_arrGroup.push_back(element);
......@@ -5223,8 +5226,8 @@ namespace SVG
const Style& style = pRef->GetStyle();
if (style.GetFillUrlRef().GetLength() && (NULL == style.GetFill()))
{
#ifdef _DEBUG
ATLTRACE (_T("[svg] NEED JOIN FILL STYLE : id - %s"), pRef->nodeId());
#if defined(_DEBUG) && (defined(_WIN32) || defined(_WIN64))
ATLTRACE (_T("[svg] NEED JOIN FILL STYLE : id - %ls"), pRef->nodeId());
#endif
}
}
......@@ -5239,7 +5242,7 @@ namespace SVG
if (index > (long)m_arrGroup.size())
return NULL;
// ATLTRACE ( _T("get : %s\n"), m_arrGroup [nIndex]->nodeId () );
// ATLTRACE ( _T("get : %ls\n"), m_arrGroup [nIndex]->nodeId () );
return m_arrGroup [index];
}
......@@ -5249,7 +5252,7 @@ namespace SVG
}
virtual bool Push (ISvgRef* Elem)
{
// ATLTRACE ( _T("push : %s\n"), Elem->nodeId () );
// ATLTRACE ( _T("push : %ls\n"), Elem->nodeId () );
if (!Elem) return false;
m_arrGroup.push_back(Elem);
......@@ -5266,7 +5269,7 @@ namespace SVG
if (m_arrRef.end() == pPair)
{
ISvgRef* search = pPair->second;
//ATLTRACE(_T("IRefStorage - Hash : %s, %d\n"), element->nodeId(), element->nodeType());
//ATLTRACE(_T("IRefStorage - Hash : %ls, %d\n"), element->nodeId(), element->nodeType());
m_arrRef.insert(std::pair<CString, ISvgRef*>(element->nodeId(), element));
......@@ -5857,7 +5860,9 @@ namespace SVG
}
inline bool Explore (XmlUtils::CXmlNode& oXml)
{
CString strXmlNode = oXml.GetName(); // ATLTRACE ( L"%s\n", strXmlNode);
CString strXmlNode = oXml.GetName();
// ATLTRACE ( L"%ls\n", strXmlNode);
bool ExploreLayer = false;
bool readInnerNodes = true;
......@@ -5915,7 +5920,7 @@ namespace SVG
}
// ATLTRACE ( L"Node : %s\n", oXml.GetName() );
// ATLTRACE ( L"Node : %ls\n", oXml.GetName() );
ExploreLayer = true;
......@@ -6098,7 +6103,7 @@ namespace SVG
return false;
}
// ATLTRACE ( L"LoadElement : %s\n", strXmlNode );
// ATLTRACE ( L"LoadElement : %ls\n", strXmlNode );
if (m_model)
{
......@@ -6148,8 +6153,8 @@ namespace SVG
return false;
}
#ifdef _DEBUG
ATLTRACE (L"[svg] render element : %s\n", strXmlNode);
#if defined(_DEBUG) && (defined(_WIN32) || defined(_WIN64))
ATLTRACE (L"[svg] render element : %ls\n", strXmlNode);
#endif
DrawElement* element = m_oDrawBuilder.Build (strXmlNode);
......
......@@ -426,7 +426,7 @@ namespace NSPresentationEditor
if (pTextElement->m_oShape.m_oText.m_bIsSlideFontRef && (0 <= lFontRef) && (lFontRef < (LONG)pTheme->m_arFonts.size()))
{
CString strRef = _T("");
strRef.Format(_T("s_font%d { font-index:%d;font-family:%s; }\n"),
strRef.Format(_T("s_font%d { font-index:%d;font-family:%ls; }\n"),
pTextElement->m_lID, lFontRef, pTheme->m_arFonts[lFontRef].Name);
strFontRefs += strRef;
}
......
......@@ -34,7 +34,7 @@ namespace NSPresentationEditor
{
CString strFormat = _T("");
strFormat.Format(_T(".font%u { font-family:%s;tmdocs_charset:%d;tmdocs_monospace:%d;tmdocs_panose:%s; }\n"),
strFormat.Format(_T(".font%u { font-family:%ls;tmdocs_charset:%d;tmdocs_monospace:%d;tmdocs_panose:%ls; }\n"),
i + 1, m_arFonts[i].Name, m_arFonts[i].Charset, m_arFonts[i].Monospace, m_arFonts[i].Panose);
oWriter.WriteString(strFormat);
......@@ -50,7 +50,7 @@ namespace NSPresentationEditor
{
CString strFormat = _T("");
strFormat.Format(_T(".font_d%u { font-family:%s; }\n"), i + 1, m_arFonts[i].Name);
strFormat.Format(_T(".font_d%u { font-family:%ls; }\n"), i + 1, m_arFonts[i].Name);
oWriter.WriteString(strFormat);
}
......
......@@ -324,7 +324,7 @@ namespace StreamUtils
{
lDWord = ((pMem[3] << 24) | (pMem[2] << 16) | (pMem[1] << 8) | pMem[0]);
}
return lDWord;
return 0xFFFFFFFF & lDWord;
}
static SHORT ReadSHORT(POLE::Stream* pStream)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment