Compare commits

..

3 Commits

Author SHA1 Message Date
4071fa315b Added building hunspell 2017-07-26 13:22:00 +03:00
82eae7fc3e hunspell dynamic link 2017-07-26 11:18:25 +03:00
8efed345b0 fix bug #35412 2017-07-24 17:32:31 +03:00
6 changed files with 72 additions and 34 deletions

View File

@ -47,24 +47,21 @@
int _tmain(int argc, _TCHAR* argv[])
{
if (argc < 3) return 0;
if (argc < 2) return 0;
std::wstring sXMLOptions = _T("<Options><TXTOptions><Encoding>1000</Encoding></TXTOptions></Options>");
std::wstring sXMLOptions = _T("<Options><TXTOptions><Encoding>50</Encoding></TXTOptions></Options>");
std::wstring srcFileName = argv[1];
std::wstring dstFileName = argv[2];
std::wstring outputDir = NSDirectory::GetFolderPath(dstFileName);
std::wstring dstTempPath = NSDirectory::CreateDirectoryWithUniqueName(outputDir);
int n1 = srcFileName.rfind(L".");
int n2 = dstFileName.rfind(L".");
std::wstring ext_1 = n1>=0 ? srcFileName.substr(n1+1, srcFileName.length() - n1): L""; //ext_1.MakeLower();
std::wstring ext_2 = n2>=0 ? dstFileName.substr(n2+1, dstFileName.length() - n2): L""; //ext_2.MakeLower();
int n1 = srcFileName.rfind(_T('.'));
std::wstring ext_1 = n1 >= 0 ? srcFileName.substr(n1+1, srcFileName.length() - n1) : _T("");
std::transform(ext_1.begin(), ext_1.end(), ext_1.begin(), ::tolower);
std::wstring dstFileName = argc > 2 ? argv[2] : srcFileName + L"_my." + (ext_1 == L"txt" ? L"docx" : L"txt");
std::wstring outputDir = NSDirectory::GetFolderPath(dstFileName);
std::wstring dstTempPath = NSDirectory::CreateDirectoryWithUniqueName(outputDir);
CTxtXmlFile txtFile;
COfficeUtils oCOfficeUtils(NULL);
@ -77,7 +74,7 @@ int _tmain(int argc, _TCHAR* argv[])
if (S_OK != oCOfficeUtils.CompressFileOrDirectory(dstTempPath.c_str(), dstFileName.c_str(), -1))
return S_FALSE;
}
if (ext_2 == L"txt")
else
{
// docx->txt
if (S_OK != oCOfficeUtils.ExtractToDirectory(srcFileName.c_str(), dstTempPath.c_str(), NULL, 0))

View File

@ -85,7 +85,7 @@ namespace Docx2Txt
OOX::CDocument *pDocument, OOX::CNumbering* pNumbering, OOX::CStyles *pStyles);
size_t NoteCount;
std::list<std::wstring> Notes;
std::map<std::wstring, std::list<std::wstring>> Notes;
static std::wstring IntToLowerLetter (int number);
static std::wstring IntToUpperLetter (int number);
@ -198,10 +198,20 @@ namespace Docx2Txt
if(NoteCount != 0)
{
m_outputFile.m_listContent.push_back(_T("---------------------------"));
for(std::list<std::wstring>::const_iterator iter = Notes.begin(); iter != Notes.end(); iter++)
m_outputFile.m_listContent.push_back(L"");
m_outputFile.m_listContent.push_back(L"---------------------------");
for(std::map<std::wstring, std::list<std::wstring>>::const_iterator iter_map = Notes.begin(); iter_map != Notes.end(); iter_map++)
{
m_outputFile.m_listContent.push_back(*iter);
bool bFirst = true;
for(std::list<std::wstring>::const_iterator iter = iter_map->second.begin(); iter != iter_map->second.end(); iter++)
{
if (bFirst) m_outputFile.m_listContent.push_back(iter_map->first + L" " + *iter);
else m_outputFile.m_listContent.push_back(*iter);
bFirst = false;
}
}
}
}
@ -491,31 +501,52 @@ namespace Docx2Txt
if (run->m_arrItems[j]->getType() == OOX::et_w_footnoteReference || run->m_arrItems[j]->getType() == OOX::et_w_endnoteReference)
{// todooo Ref ????
std::list<std::wstring> notes_content;
OOX::Logic::CFootnoteReference* footnote_ref = dynamic_cast<OOX::Logic::CFootnoteReference*>(run->m_arrItems[j]);
OOX::Logic::CEndnoteReference* endnote_ref = dynamic_cast<OOX::Logic::CEndnoteReference*>(run->m_arrItems[j]);
NoteCount++;
std::wstring s = _T("[") + ToWString(NoteCount) + _T("]");
Notes.push_back(s);
if(run->m_arrItems[j]->getType() == OOX::et_w_footnoteReference)
if (footnote_ref)
{
smart_ptr<OOX::File> pFile = pDocument->Find(OOX::FileTypes::FootNote);
if (pFile.IsInit())
{
OOX::CFootnotes *pFootnotes = (OOX::CFootnotes*)pFile.operator->();
for (long r =0 ;r < pFootnotes->m_arrFootnote.size(); r++)
convert(pFootnotes->m_arrFootnote[r]->m_arrItems, Notes, Event, false, pDocument, pNumbering, pStyles);
for (size_t r = 0; r < pFootnotes->m_arrFootnote.size(); r++)
{
OOX::CFtnEdn* note = dynamic_cast<OOX::CFtnEdn*>(pFootnotes->m_arrFootnote[r]);
if (note && note->m_oId == footnote_ref->m_oId)
{
convert(pFootnotes->m_arrFootnote[r]->m_arrItems, notes_content, Event, false, pDocument, pNumbering, pStyles);
}
}
}
Notes.insert(std::make_pair(ToWString(NoteCount), notes_content));
}
else if(run->m_arrItems[j]->getType() == OOX::et_w_endnoteReference)
if (endnote_ref)
{
smart_ptr<OOX::File> pFile = pDocument->Find(OOX::FileTypes::EndNote);
if (pFile.IsInit())
{
OOX::CEndnotes *pEndnotes = (OOX::CEndnotes*)pFile.operator->();
for (long r =0 ;r < pEndnotes->m_arrEndnote.size(); r++)
convert(pEndnotes->m_arrEndnote[r]->m_arrItems, Notes, Event, false, pDocument, pNumbering, pStyles);
for (size_t r =0; r < pEndnotes->m_arrEndnote.size(); r++)
{
OOX::CFtnEdn* note = dynamic_cast<OOX::CFtnEdn*>(pEndnotes->m_arrEndnote[r]);
if (note && note->m_oId == endnote_ref->m_oId)
{
convert(pEndnotes->m_arrEndnote[r]->m_arrItems, notes_content, Event, false, pDocument, pNumbering, pStyles);
}
}
}
Notes.insert(std::make_pair(ToWString(NoteCount), notes_content));
}
wstr.replace(wstr.find(_T("_")), 1 , ToWString(NoteCount));
wstr += L"[" + ToWString(NoteCount) + L"]"; ;
}
line += wstr;
}

View File

@ -104,13 +104,6 @@ static int ParseTxtOptions(const std::wstring & sXmlOptions)
HRESULT CTxtXmlFile::txt_LoadFromFile(const std::wstring & sSrcFileName, const std::wstring & sDstPath, const std::wstring & sXMLOptions)
{
//проверка на структуру xml - если что не так выкинет быстро
//HRESULT hr = xml_LoadFromFile(sSrcFileName, sDstPath, sXMLOptions);
//if(hr == S_OK)
// return S_OK;
//As Text
Writers::FileWriter *pDocxWriter = new Writers::FileWriter(sDstPath, L"", true, 1, false, NULL, L"");
if (pDocxWriter == NULL) return S_FALSE;

View File

@ -1,4 +1,6 @@
hunspell_build_static {
DEFINES += HUNSPELL_STATIC
}
building_hunspell {
DEFINES += BUILDING_LIBHUNSPELL

View File

@ -9,7 +9,17 @@ QT -= core gui
TARGET = hunspell
TEMPLATE = lib
hunspell_build_static {
CONFIG += staticlib
} else {
CONFIG += shared
CONFIG += plugin
}
CONFIG += building_hunspell
CORE_ROOT_DIR = $$PWD/../../../..

View File

@ -61,6 +61,7 @@ ASCDOCUMENTSCORE := $(LIBDIR)/$(LIB_PREFIX)ascdocumentscore$(SHARED_EXT)
LIBXML := $(LIBDIR)/$(LIB_PREFIX)libxml$(LIB_EXT)
LICENSEMANAGER := $(LIBDIR)/$(LIB_PREFIX)LicenceManager$(LIB_EXT)
OOXMLSIGNATURE := $(LIBDIR)/$(LIB_PREFIX)ooxmlsignature$(LIB_EXT)
HUNSPELL := $(LIBDIR)/$(LIB_PREFIX)hunspell$(SHARED_EXT)
TARGETS += $(ALLFONTSGEN)
TARGETS += $(X2T)
@ -89,6 +90,7 @@ TARGETS += $(ASCDOCUMENTSCORE)
TARGETS += $(LIBXML)
TARGETS += $(LICENSEMANAGER)
TARGETS += $(OOXMLSIGNATURE)
TARGETS += $(HUNSPELL)
X2T_PRO := $(abspath X2tConverter/build/Qt/X2tSLN.pro)
HTMLFILEINTERNAL_PRO := $(abspath ../desktop-sdk/HtmlFile/Internal/Internal.pro)
@ -117,6 +119,7 @@ ASCDOCUMENTSCORE_PRO := $(abspath ../desktop-sdk/ChromiumBasedEditors/lib/AscDoc
LIBXML_PRO := $(abspath DesktopEditor/xml/build/qt/libxml2.pro)
LICENSEMANAGER_PRO := $(abspath LicenceManager/linux/LicenseManager.pro)
OOXMLSIGNATURE_PRO := $(abspath DesktopEditor/xmlsec/src/ooxmlsignature.pro)
HUNSPELL_PRO := $(abspath DesktopEditor/hunspell-1.3.3/src/qt/hunspell.pro)
# PROS += $(basename $(X2T_PRO)).build
# PROS += ALLFONTSGEN_PRO
@ -168,6 +171,7 @@ QT_PROJ += ASCDOCUMENTSCORE
QT_PROJ += LIBXML
QT_PROJ += LICENSEMANAGER
QT_PROJ += OOXMLSIGNATURE
QT_PROJ += HUNSPELL
# X2T_DEP += $(XLSFORMATLIB)
# X2T_DEP += $(ODFFILEWRITERLIB)
@ -217,6 +221,7 @@ ASCDOCUMENTSCORE_DEP += $(XPSFILE)
#ASCDOCUMENTSCORE_DEP += $(LICENSEMANAGER)
ASCDOCUMENTSCORE_DEP += $(LIBXML)
ASCDOCUMENTSCORE_DEP += $(OOXMLSIGNATURE)
ASCDOCUMENTSCORE_DEP += $(HUNSPELL)
OOXMLSIGNATURE_DEP += $(LIBXML)