Compare commits

..

4 Commits

Author SHA1 Message Date
eb9d69d1ec Fix svg bug 2019-05-15 19:28:02 +03:00
9670d021c2 x2t - fix bug #41503 2019-05-14 19:22:20 +03:00
79f18355fe x2t - fix bug #41515 2019-05-13 15:27:03 +03:00
f86055c713 Epub images bug (xml files) 2019-05-08 12:51:29 +03:00
4 changed files with 64 additions and 11 deletions

View File

@ -1818,7 +1818,7 @@ void CDrawingConverter::doc_LoadShape(PPTX::Logic::SpTreeElem *elem, XmlUtils::C
std::wstring strCoord1 = oNodeShape.GetAttributeOrValue(L"from");
std::wstring strCoord2 = oNodeShape.GetAttributeOrValue(L"to");
if (strCoord1 != L"" && strCoord2 != L"")
if (!strCoord1.empty() && !strCoord2.empty())
{
std::vector<std::wstring> oArray1;
boost::algorithm::split(oArray1, strCoord1, boost::algorithm::is_any_of(L","), boost::algorithm::token_compress_on);
@ -1905,7 +1905,7 @@ void CDrawingConverter::doc_LoadShape(PPTX::Logic::SpTreeElem *elem, XmlUtils::C
int nOffsetX = _POINTS[0] - _x;
int nOffsetY = _POINTS[1] - _y;
strStyleAdvenced = L";margin-left:" + std::to_wstring(_x) + L";margin-top:" + std::to_wstring(_y)
strStyleAdvenced += L";margin-left:" + std::to_wstring(_x) + L";margin-top:" + std::to_wstring(_y)
+ L";width:" + std::to_wstring(_r - _x) + L";height:" + std::to_wstring(_b - _y) + L";polyline_correct:true;";
double dKoefX = 21600.0 / (std::max)((_r - _x), 1);
@ -3302,6 +3302,7 @@ std::wstring CDrawingConverter::GetDrawingMainProps(XmlUtils::CXmlNode& oNode, P
std::map<std::wstring, std::wstring>::iterator pFind;
bool bIsInline = false;
bool bIsMargin = false;
if (oProps.IsTop == true)
{
@ -3312,12 +3313,19 @@ std::wstring CDrawingConverter::GetDrawingMainProps(XmlUtils::CXmlNode& oNode, P
{
bIsInline = true;
}
if (((oCssStyles.m_mapSettings.end() != oCssStyles.m_mapSettings.find(L"margin-left")) &&
(oCssStyles.m_mapSettings.end() != oCssStyles.m_mapSettings.find(L"margin-top")))
||
((oCssStyles.m_mapSettings.end() != oCssStyles.m_mapSettings.find(L"left")) &&
(oCssStyles.m_mapSettings.end() != oCssStyles.m_mapSettings.find(L"top"))))
{
bIsMargin = true;
}
pFind = oCssStyles.m_mapSettings.find(L"mso-position-horizontal-relative");
if (oCssStyles.m_mapSettings.end() != pFind && (pFind->second == L"text" || pFind->second == L"char"))
if (oCssStyles.m_mapSettings.end() != pFind && ((pFind->second == L"text" && !bIsMargin) || pFind->second == L"char"))
{
pFind = oCssStyles.m_mapSettings.find(L"mso-position-vertical-relative");
if (oCssStyles.m_mapSettings.end() != pFind && (pFind->second == L"text" || pFind->second == L"line"))
if (oCssStyles.m_mapSettings.end() != pFind && ((pFind->second == L"text" && !bIsMargin) || pFind->second == L"line"))
{
bIsInline = true;
}
@ -3355,7 +3363,13 @@ std::wstring CDrawingConverter::GetDrawingMainProps(XmlUtils::CXmlNode& oNode, P
if (oCssStyles.m_mapSettings.end() != pFind)
{
left = (LONG)(dKoefSize * parserPoint.FromString(pFind->second) + 0.5);
std::vector<std::wstring> oArray1;
boost::algorithm::split(oArray1, pFind->second, boost::algorithm::is_any_of(L","), boost::algorithm::token_compress_on);
for (size_t i = 0; i < oArray1.size(); i++)
{
left += (LONG)(dKoefSize * parserPoint.FromString(oArray1[i]) + 0.5);
}
}
pFind = oCssStyles.m_mapSettings.find(L"margin-top");
@ -3365,7 +3379,12 @@ std::wstring CDrawingConverter::GetDrawingMainProps(XmlUtils::CXmlNode& oNode, P
if (oCssStyles.m_mapSettings.end() != pFind)
{
top = (LONG)(dKoefSize * parserPoint.FromString(pFind->second) + 0.5);
std::vector<std::wstring> oArray1;
boost::algorithm::split(oArray1, pFind->second, boost::algorithm::is_any_of(L","), boost::algorithm::token_compress_on);
for (size_t i = 0; i < oArray1.size(); i++)
{
top += (LONG)(dKoefSize * parserPoint.FromString(oArray1[i]) + 0.5);
}
}
}

View File

@ -5580,6 +5580,10 @@ namespace SVG
inline bool LoadFromFile (const std::wstring& strFile, Storage* model)
{
std::wstring sExt = NSFile::GetFileExtention(strFile);
if (sExt != L"svg" && sExt != L"xml")
return false;
if (model)
{
m_model = model;

View File

@ -51,14 +51,26 @@
#include <stdio.h>
#endif
class CHtmlFile_Private
{
public:
bool m_bIsEpub;
public:
CHtmlFile_Private()
{
m_bIsEpub = false;
}
};
CHtmlFile::CHtmlFile()
{
m_internal = new CHtmlFile_Private();
}
CHtmlFile::~CHtmlFile()
{
RELEASEOBJECT(m_internal);
}
static std::wstring GetSdkPath()
@ -261,7 +273,20 @@ int CHtmlFile::Convert(const std::vector<std::wstring>& arFiles, const std::wstr
oBuilder.WriteEncodeXmlString(CorrectHtmlPath(sFilePath));
else
{
std::wstring sTmpFile = NSFile::CFileBinary::CreateTempFileWithUniqueName(NSDirectory::GetTempPath(), L"HTM");
std::wstring sTmpDir = L"";
if (m_internal->m_bIsEpub)
{
// чтобы ссылки на картинки остались
sTmpDir = NSFile::GetDirectoryName(sFilePath);
if (!NSDirectory::Exists(sTmpDir))
sTmpDir = NSDirectory::GetTempPath();
}
else
{
sTmpDir = NSDirectory::GetTempPath();
}
std::wstring sTmpFile = NSFile::CFileBinary::CreateTempFileWithUniqueName(sTmpDir, L"HTM");
if (NSFile::CFileBinary::Exists(sTmpFile))
NSFile::CFileBinary::Remove(sTmpFile);
@ -665,7 +690,10 @@ int CHtmlFile::ConvertEpub(const std::wstring& sFolder, std::wstring& sMetaInfo,
if (arHtmls.size() == 0)
return 1;
return this->Convert(arHtmls, sDstfolder, sPathInternal);
m_internal->m_bIsEpub = true;
int nErr = this->Convert(arHtmls, sDstfolder, sPathInternal);
m_internal->m_bIsEpub = false;
return nErr;
}
/////////////////////////////////////////////////////////////////

View File

@ -42,9 +42,11 @@
#define HTMLFILE_DECL_EXPORT Q_DECL_EXPORT
#endif
class CHtmlFile_Private;
class HTMLFILE_DECL_EXPORT CHtmlFile
{
private:
CHtmlFile_Private* m_internal;
public: