From 51569b626fc38c66d4dbc98c60d8f21d88d2332b Mon Sep 17 00:00:00 2001 From: Oleg Korshul Date: Thu, 19 Apr 2018 16:10:29 +0300 Subject: [PATCH] Fix build on macOS --- ASCOfficeOdfFile/linux/OdfFileReaderLib.pro | 5 ----- ASCOfficeOdfFile/src/xml/sax_xmllite.cpp | 19 ++++++------------ .../source/OdfFormat/ods_table_state.cpp | 4 ++-- Common/3dParty/cef/fetch.sh | 2 +- Common/kernel.pro | 1 + DesktopEditor/xml/include/xmlutils.h | 16 +++++++++------ DesktopEditor/xml/src/xmllight.cpp | 13 ++++++++++++ DesktopEditor/xml/src/xmllight_private.h | 20 +++++++++++++++++++ X2tConverter/build/Qt/X2tSLN.pri | 14 ++++--------- 9 files changed, 57 insertions(+), 37 deletions(-) diff --git a/ASCOfficeOdfFile/linux/OdfFileReaderLib.pro b/ASCOfficeOdfFile/linux/OdfFileReaderLib.pro index cd28ac0d8a..f891fd53d8 100644 --- a/ASCOfficeOdfFile/linux/OdfFileReaderLib.pro +++ b/ASCOfficeOdfFile/linux/OdfFileReaderLib.pro @@ -21,14 +21,9 @@ include($$PWD/../../Common/3dParty/boost/boost.pri) DEFINES += UNICODE \ _UNICODE \ - _USE_LIBXML2_READER_ \ - LIBXML_READER_ENABLED \ DONT_WRITE_EMBEDDED_FONTS INCLUDEPATH += ../include -INCLUDEPATH += ../../DesktopEditor/freetype-2.5.2/include -INCLUDEPATH += ../../DesktopEditor/xml/libxml2/include -INCLUDEPATH += ../../DesktopEditor/xml/build/qt CONFIG(debug, debug|release){ DEFINES += _DEBUG diff --git a/ASCOfficeOdfFile/src/xml/sax_xmllite.cpp b/ASCOfficeOdfFile/src/xml/sax_xmllite.cpp index 7934a9a58d..c9f27fe5c4 100644 --- a/ASCOfficeOdfFile/src/xml/sax_xmllite.cpp +++ b/ASCOfficeOdfFile/src/xml/sax_xmllite.cpp @@ -34,7 +34,6 @@ #include "../../../Common/DocxFormat/Source/Base/Nullable.h" #include "../../../DesktopEditor/xml/include/xmlutils.h" -#include "../../../DesktopEditor/xml/src/xmllight_private.h" #include "../../include/cpdoccore/xml/sax.h" @@ -73,7 +72,7 @@ public: virtual NodeType next(int Depth); private: - smart_ptr< XmlUtils::CXmlLiteReader_Private > xml_; + smart_ptr< XmlUtils::CXmlLiteReader > xml_; }; @@ -113,7 +112,7 @@ namespace saxXmlLiteReader::saxXmlLiteReader(const wchar_t * FileName) { - xml_ = new XmlUtils::CXmlLiteReader_Private(); + xml_ = new XmlUtils::CXmlLiteReader(); xml_->FromFile(FileName); @@ -157,20 +156,14 @@ std::wstring saxXmlLiteReader::namespacePrefix() { if (xml_.IsInit() == false) return _T(""); - xmlChar* pName = xmlTextReaderPrefix(xml_->getNativeReader()); - if (NULL == pName) - return L""; - - std::wstring sTemp = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)pName, (LONG)strlen((const char*)pName)); - free(pName); - return sTemp; + return xml_->GetNamespacePrefix(); } NodeType saxXmlLiteReader::nodeType() { if (xml_.IsInit() == false) return typeNone; - XmlUtils::XmlNodeType nTempType = (XmlUtils::XmlNodeType)xmlTextReaderNodeType(xml_->getNativeReader()); + XmlUtils::XmlNodeType nTempType = xml_->GetNodeType(); return NodeTypeConvert(nTempType); } @@ -214,14 +207,14 @@ bool saxXmlLiteReader::attrDefault() { if (xml_.IsInit() == false) return false; - return (FALSE != xmlTextReaderIsDefault(xml_->getNativeReader())); + return xml_->IsDefaultAttribute(); } NodeType saxXmlLiteReader::next(int Depth) { if (xml_->ReadNextSiblingNode2(Depth)) { - XmlUtils::XmlNodeType nTempType = (XmlUtils::XmlNodeType)xmlTextReaderNodeType(xml_->getNativeReader()); + XmlUtils::XmlNodeType nTempType = xml_->GetNodeType(); return NodeTypeConvert(nTempType); } else diff --git a/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.cpp b/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.cpp index a2c8f0eebd..5324aaaa46 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/ods_table_state.cpp @@ -254,7 +254,7 @@ void ods_table_state::add_column(office_element_ptr & elm, unsigned int repeated odf_writer::style* style = dynamic_cast(style_elm.get()); if (style)style_name = style->style_name_; - ods_element_state state = {elm, repeated, style_name, style_elm, defaut_column_width_ , current_level_.size()}; + ods_element_state state = {elm, repeated, style_name, style_elm, defaut_column_width_ , (unsigned int)current_level_.size()}; if (repeated > 10000)repeated = 1024;//???? @@ -343,7 +343,7 @@ void ods_table_state::add_row(office_element_ptr & elm, unsigned int repeated, o odf_writer::style* style = dynamic_cast(style_elm.get()); if (style)style_name = style->style_name_; - ods_element_state state = {elm, repeated, style_name, style_elm, defaut_row_height_ , current_level_.size()}; + ods_element_state state = {elm, repeated, style_name, style_elm, defaut_row_height_ , (unsigned int)current_level_.size()}; rows_.push_back(state); diff --git a/Common/3dParty/cef/fetch.sh b/Common/3dParty/cef/fetch.sh index 4fd70c9c04..a41d1d5bc3 100755 --- a/Common/3dParty/cef/fetch.sh +++ b/Common/3dParty/cef/fetch.sh @@ -1,6 +1,6 @@ #!/bin/bash -SCRIPT=$(readlink -f "$0" || grealpath "$0") +SCRIPT=$(readlink -n "$0" || grealpath "$0") SCRIPTPATH=$(dirname "$SCRIPT") os=$(uname -s) diff --git a/Common/kernel.pro b/Common/kernel.pro index 7c9727d31a..741aededa4 100644 --- a/Common/kernel.pro +++ b/Common/kernel.pro @@ -23,6 +23,7 @@ include(../Common/base.pri) CONFIG += build_all_zlib build_zlib_as_sources include(../OfficeUtils/OfficeUtils.pri) +CONFIG += core_static_link_xml_full include(../DesktopEditor/xml/build/qt/libxml2.pri) # DOWNLOADER diff --git a/DesktopEditor/xml/include/xmlutils.h b/DesktopEditor/xml/include/xmlutils.h index 07a93dcef7..1b51816ba1 100644 --- a/DesktopEditor/xml/include/xmlutils.h +++ b/DesktopEditor/xml/include/xmlutils.h @@ -92,15 +92,15 @@ namespace XmlUtils bool ReadTillEnd(int nDepth = -2); std::wstring GetName(); - std::string GetNameA(); - int GetDepth(); - bool IsEmptyNode(); + std::string GetNameA(); + int GetDepth(); + bool IsEmptyNode(); std::wstring GetText(); - std::string GetTextA(); + std::string GetTextA(); std::wstring GetText2(); - std::string GetText2A(); + std::string GetText2A(); std::wstring GetText3(); @@ -112,7 +112,11 @@ namespace XmlUtils bool MoveToNextAttribute(); bool MoveToElement(); - bool IsEmptyElement(); + bool IsEmptyElement(); + + std::wstring GetNamespacePrefix(); + XmlNodeType GetNodeType(); + bool IsDefaultAttribute(); }; class KERNEL_DECL IXmlDOMDocument diff --git a/DesktopEditor/xml/src/xmllight.cpp b/DesktopEditor/xml/src/xmllight.cpp index e9a9d5eacd..f8da8c97c8 100644 --- a/DesktopEditor/xml/src/xmllight.cpp +++ b/DesktopEditor/xml/src/xmllight.cpp @@ -187,4 +187,17 @@ namespace XmlUtils { return m_pInternal->IsEmptyElement(); } + + std::wstring CXmlLiteReader::GetNamespacePrefix() + { + return m_pInternal->GetNamespacePrefix(); + } + XmlNodeType CXmlLiteReader::GetNodeType() + { + return m_pInternal->GetNodeType(); + } + bool CXmlLiteReader::IsDefaultAttribute() + { + return m_pInternal->IsDefaultAttribute(); + } } diff --git a/DesktopEditor/xml/src/xmllight_private.h b/DesktopEditor/xml/src/xmllight_private.h index 29c84f84fc..00e3ccc020 100644 --- a/DesktopEditor/xml/src/xmllight_private.h +++ b/DesktopEditor/xml/src/xmllight_private.h @@ -36,6 +36,7 @@ #include "../libxml2/libxml.h" #include "../libxml2/include/libxml/xmlreader.h" +#include "../include/xmlutils.h" namespace XmlUtils { @@ -429,6 +430,25 @@ namespace XmlUtils return 1 == xmlTextReaderIsEmptyElement(reader) ? true : false; } + std::wstring GetNamespacePrefix() + { + xmlChar* pName = xmlTextReaderPrefix(reader); + if (NULL == pName) + return L""; + + std::wstring sTemp = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)pName, (LONG)strlen((const char*)pName)); + free(pName); + return sTemp; + } + XmlNodeType GetNodeType() + { + return (XmlUtils::XmlNodeType)xmlTextReaderNodeType(reader); + } + bool IsDefaultAttribute() + { + return (0 != xmlTextReaderIsDefault(reader)) ? true : false; + } + private: inline std::wstring GetXml(bool bInner) { diff --git a/X2tConverter/build/Qt/X2tSLN.pri b/X2tConverter/build/Qt/X2tSLN.pri index 0675ebd7d5..7f51250c4b 100644 --- a/X2tConverter/build/Qt/X2tSLN.pri +++ b/X2tConverter/build/Qt/X2tSLN.pri @@ -6,7 +6,7 @@ PWD_ROOT_DIR = $$PWD include(../../../Common/base.pri) SUBDIRS = \ - OfficeUtils \ + kernel \ graphics \ cryptopp \ DocxFormatLib \ @@ -19,11 +19,10 @@ SUBDIRS = \ OdfFileReaderLib \ OdfFileWriterLib \ XlsFormatLib \ - XmlLib \ X2tConverter -OfficeUtils.file = ../../../OfficeUtils/OfficeUtils.pro -graphics.file = ../../../DesktopEditor/Qt_build/graphics/project/graphics.pro +kernel.file = ../../../Common/kernel.pro +graphics.file = ../../../DesktopEditor/graphics/pro/graphics.pro cryptopp.file = ../../../Common/3dParty/cryptopp/project/cryptopp.pro DocxFormatLib.file = ../../../Common/DocxFormat/DocxFormatLib/DocxFormatLib.pro @@ -36,10 +35,9 @@ DocFormatLib.file = ../../../ASCOfficeDocFile/DocFormatLib/Linux/DocFormatLib.pr OdfFileReaderLib.file = ../../../ASCOfficeOdfFile/linux/OdfFileReaderLib.pro OdfFileWriterLib.file = ../../../ASCOfficeOdfFileW/linux/OdfFileWriterLib.pro XlsFormatLib.file = ../../../ASCOfficeXlsFile2/source/linux/XlsFormatLib.pro -XmlLib.file = ../../../DesktopEditor/xml/build/qt/libxml2.pro X2tConverter.depends = \ - OfficeUtils \ + kernel \ graphics \ cryptopp \ DocxFormatLib \ @@ -52,10 +50,6 @@ X2tConverter.depends = \ OdfFileReaderLib \ OdfFileWriterLib \ XlsFormatLib - -core_windows { - X2tConverter.depends += XmlLib -} # for run in qt from this solution LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH