diff --git a/.gitmodules b/.gitmodules index 012ecb9d1..7101234a7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -78,3 +78,6 @@ [submodule "third_party/qoi"] path = third_party/qoi url = https://github.com/aseprite/qoi.git +[submodule "third_party/tinyxml2"] + path = third_party/tinyxml2 + url = https://github.com/aseprite/tinyxml2.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 4945a70dd..225f55a58 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ # Aseprite -# Copyright (C) 2018-2022 Igara Studio S.A. +# Copyright (C) 2018-2024 Igara Studio S.A. # Copyright (C) 2001-2018 David Capello cmake_minimum_required(VERSION 3.16) @@ -163,7 +163,7 @@ set(PIXMAN_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/pixman) set(FREETYPE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/freetype2) set(HARFBUZZ_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/harfbuzz) set(SIMPLEINI_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/simpleini) -set(TINYXML_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/tinyxml) +set(TINYXML_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/tinyxml2) set(ZLIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/zlib) # Search in the "cmake" directory for additional CMake modules. @@ -225,12 +225,12 @@ endif() include_directories(${PNG_INCLUDE_DIRS}) add_definitions(-DPNG_NO_MMX_CODE) # Do not use MMX optimizations in PNG code -# tinyxml +# tinyxml2 if(USE_SHARED_TINYXML) - find_library(TINYXML_LIBRARY NAMES tinyxml) - find_path(TINYXML_INCLUDE_DIR NAMES tinyxml.h) + find_library(TINYXML_LIBRARY NAMES tinyxml2) + find_path(TINYXML_INCLUDE_DIR NAMES tinyxml2.h) else() - set(TINYXML_LIBRARY tinyxml) + set(TINYXML_LIBRARY tinyxml2) set(TINYXML_INCLUDE_DIR ${TINYXML_DIR}) endif() include_directories(${TINYXML_INCLUDE_DIR}) diff --git a/docs/LICENSES.md b/docs/LICENSES.md index 5be4b2a76..f6749f79e 100644 --- a/docs/LICENSES.md +++ b/docs/LICENSES.md @@ -1139,10 +1139,10 @@ freely, subject to the following restrictions: 3. This notice may not be removed or altered from any source distribution. ``` -# [tinyxml](http://www.grinninglizard.com/tinyxml/) +# [tinyxml2](https://github.com/leethomason/tinyxml2) ``` -TinyXML is released under the zlib license: +Original code by Lee Thomason (www.grinninglizard.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any @@ -1162,12 +1162,6 @@ must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. - --- - -TinyXML was originally written by Lee Thomason. Lee reviews changes -and releases new versions, with the help of Yves Berquin, Andrew -Ellerton, and the tinyXml community. ``` # [ucdn](https://github.com/grigorig/ucdn) diff --git a/src/app/app_brushes.cpp b/src/app/app_brushes.cpp index a328ca282..4e3028ab7 100644 --- a/src/app/app_brushes.cpp +++ b/src/app/app_brushes.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2020-2023 Igara Studio S.A. +// Copyright (C) 2020-2024 Igara Studio S.A. // Copyright (C) 2001-2016 David Capello // // This program is distributed under the terms of @@ -23,6 +23,8 @@ #include "doc/image.h" #include "doc/image_impl.h" +#include "tinyxml2.h" + #include namespace app { @@ -30,15 +32,16 @@ namespace app { using namespace doc; using namespace base::serialization; using namespace base::serialization::little_endian; +using namespace tinyxml2; namespace { -ImageRef load_xml_image(const TiXmlElement* imageElem) +ImageRef load_xml_image(const XMLElement* imageElem) { ImageRef image; int w, h; - if (imageElem->QueryIntAttribute("width", &w) != TIXML_SUCCESS || - imageElem->QueryIntAttribute("height", &h) != TIXML_SUCCESS || + if (imageElem->QueryIntAttribute("width", &w) != XML_SUCCESS || + imageElem->QueryIntAttribute("height", &h) != XML_SUCCESS || w < 0 || w > 9999 || h < 0 || h > 9999) return image; @@ -109,7 +112,7 @@ ImageRef load_xml_image(const TiXmlElement* imageElem) return image; } -void save_xml_image(TiXmlElement* imageElem, const Image* image) +void save_xml_image(XMLElement* imageElem, const Image* image) { int w = image->width(); int h = image->height(); @@ -167,8 +170,7 @@ void save_xml_image(TiXmlElement* imageElem, const Image* image) std::string data_base64; base::encode_base64(data, data_base64); - TiXmlText textElem(data_base64.c_str()); - imageElem->InsertEndChild(textElem); + imageElem->InsertNewText(data_base64.c_str()); } } // anonymous namespace @@ -305,11 +307,11 @@ static const int kBrushFlags = void AppBrushes::load(const std::string& filename) { - XmlDocumentRef doc = app::open_xml(filename); - TiXmlHandle handle(doc.get()); - TiXmlElement* brushElem = handle - .FirstChild("brushes") - .FirstChild("brush").ToElement(); + XMLDocumentRef doc = app::open_xml(filename); + XMLHandle handle(doc.get()); + XMLElement* brushElem = handle + .FirstChildElement("brushes") + .FirstChildElement("brush").ToElement(); while (brushElem) { // flags @@ -339,9 +341,9 @@ void AppBrushes::load(const std::string& filename) // Brush image ImageRef image, mask; - if (TiXmlElement* imageElem = brushElem->FirstChildElement("image")) + if (XMLElement* imageElem = brushElem->FirstChildElement("image")) image = load_xml_image(imageElem); - if (TiXmlElement* maskElem = brushElem->FirstChildElement("mask")) + if (XMLElement* maskElem = brushElem->FirstChildElement("mask")) mask = load_xml_image(maskElem); if (image) { @@ -351,14 +353,14 @@ void AppBrushes::load(const std::string& filename) } // Colors - if (TiXmlElement* fgcolorElem = brushElem->FirstChildElement("fgcolor")) { + if (XMLElement* fgcolorElem = brushElem->FirstChildElement("fgcolor")) { if (auto value = fgcolorElem->Attribute("value")) { fgColor = app::Color::fromString(value); flags |= int(BrushSlot::Flags::FgColor); } } - if (TiXmlElement* bgcolorElem = brushElem->FirstChildElement("bgcolor")) { + if (XMLElement* bgcolorElem = brushElem->FirstChildElement("bgcolor")) { if (auto value = bgcolorElem->Attribute("value")) { bgColor = app::Color::fromString(value); flags |= int(BrushSlot::Flags::BgColor); @@ -366,14 +368,14 @@ void AppBrushes::load(const std::string& filename) } // Ink - if (TiXmlElement* inkTypeElem = brushElem->FirstChildElement("inktype")) { + if (XMLElement* inkTypeElem = brushElem->FirstChildElement("inktype")) { if (auto value = inkTypeElem->Attribute("value")) { inkType = app::tools::string_id_to_ink_type(value); flags |= int(BrushSlot::Flags::InkType); } } - if (TiXmlElement* inkOpacityElem = brushElem->FirstChildElement("inkopacity")) { + if (XMLElement* inkOpacityElem = brushElem->FirstChildElement("inkopacity")) { if (auto value = inkOpacityElem->Attribute("value")) { inkOpacity = base::convert_to(std::string(value)); flags |= int(BrushSlot::Flags::InkOpacity); @@ -381,7 +383,7 @@ void AppBrushes::load(const std::string& filename) } // Shade - if (TiXmlElement* shadeElem = brushElem->FirstChildElement("shade")) { + if (XMLElement* shadeElem = brushElem->FirstChildElement("shade")) { if (auto value = shadeElem->Attribute("value")) { shade = shade_from_string(value); flags |= int(BrushSlot::Flags::Shade); @@ -389,7 +391,7 @@ void AppBrushes::load(const std::string& filename) } // Pixel-perfect - if (TiXmlElement* pixelPerfectElem = brushElem->FirstChildElement("pixelperfect")) { + if (XMLElement* pixelPerfectElem = brushElem->FirstChildElement("pixelperfect")) { pixelPerfect = bool_attr(pixelPerfectElem, "value", false); flags |= int(BrushSlot::Flags::PixelPerfect); } @@ -414,13 +416,13 @@ void AppBrushes::load(const std::string& filename) void AppBrushes::save(const std::string& filename) const { - XmlDocumentRef doc(new TiXmlDocument()); - TiXmlElement brushesElem("brushes"); - - // + auto doc = std::make_unique(); + XMLElement* brushesElem = doc->NewElement("brushes"); + doc->InsertEndChild(doc->NewDeclaration("xml version=\"1.0\" encoding=\"utf-8\"")); + doc->InsertEndChild(brushesElem); for (const auto& slot : m_slots) { - TiXmlElement brushElem("brush"); + XMLElement* brushElem = brushesElem->InsertNewChildElement("brush"); if (slot.locked()) { // Flags int flags = int(slot.flags()); @@ -435,32 +437,30 @@ void AppBrushes::save(const std::string& filename) const ASSERT(slot.brush()); if (flags & int(BrushSlot::Flags::BrushType)) { - brushElem.SetAttribute( + brushElem->SetAttribute( "type", brush_type_to_string_id(slot.brush()->type()).c_str()); } if (flags & int(BrushSlot::Flags::BrushSize)) { - brushElem.SetAttribute("size", slot.brush()->size()); + brushElem->SetAttribute("size", slot.brush()->size()); } if (flags & int(BrushSlot::Flags::BrushAngle)) { - brushElem.SetAttribute("angle", slot.brush()->angle()); + brushElem->SetAttribute("angle", slot.brush()->angle()); } if (slot.brush()->type() == kImageBrushType && slot.brush()->originalImage()) { - TiXmlElement elem("image"); - save_xml_image(&elem, slot.brush()->originalImage()); - brushElem.InsertEndChild(elem); + XMLElement* elem = brushElem->InsertNewChildElement("image"); + save_xml_image(elem, slot.brush()->originalImage()); if (slot.brush()->maskBitmap()) { - TiXmlElement maskElem("mask"); - save_xml_image(&maskElem, slot.brush()->maskBitmap()); - brushElem.InsertEndChild(maskElem); + XMLElement* maskElem = brushElem->InsertNewChildElement("mask"); + save_xml_image(maskElem, slot.brush()->maskBitmap()); } // Image color - brushElem.SetAttribute( + brushElem->SetAttribute( "imagecolor", (flags & int(BrushSlot::Flags::ImageColor)) ? "true": "false"); } @@ -468,53 +468,42 @@ void AppBrushes::save(const std::string& filename) const // Colors if (flags & int(BrushSlot::Flags::FgColor)) { - TiXmlElement elem("fgcolor"); - elem.SetAttribute("value", slot.fgColor().toString().c_str()); - brushElem.InsertEndChild(elem); + XMLElement* elem = brushElem->InsertNewChildElement("fgcolor"); + elem->SetAttribute("value", slot.fgColor().toString().c_str()); } if (flags & int(BrushSlot::Flags::BgColor)) { - TiXmlElement elem("bgcolor"); - elem.SetAttribute("value", slot.bgColor().toString().c_str()); - brushElem.InsertEndChild(elem); + XMLElement* elem = brushElem->InsertNewChildElement("bgcolor"); + elem->SetAttribute("value", slot.bgColor().toString().c_str()); } // Ink if (flags & int(BrushSlot::Flags::InkType)) { - TiXmlElement elem("inktype"); - elem.SetAttribute( + XMLElement* elem = brushElem->InsertNewChildElement("inktype"); + elem->SetAttribute( "value", app::tools::ink_type_to_string_id(slot.inkType()).c_str()); - brushElem.InsertEndChild(elem); } if (flags & int(BrushSlot::Flags::InkOpacity)) { - TiXmlElement elem("inkopacity"); - elem.SetAttribute("value", slot.inkOpacity()); - brushElem.InsertEndChild(elem); + XMLElement* elem = brushElem->InsertNewChildElement("inkopacity"); + elem->SetAttribute("value", slot.inkOpacity()); } // Shade if (flags & int(BrushSlot::Flags::Shade)) { - TiXmlElement elem("shade"); - elem.SetAttribute("value", shade_to_string(slot.shade()).c_str()); - brushElem.InsertEndChild(elem); + XMLElement* elem = brushElem->InsertNewChildElement("shade"); + elem->SetAttribute("value", shade_to_string(slot.shade()).c_str()); } // Pixel-perfect if (flags & int(BrushSlot::Flags::PixelPerfect)) { - TiXmlElement elem("pixelperfect"); - elem.SetAttribute("value", slot.pixelPerfect() ? "true": "false"); - brushElem.InsertEndChild(elem); + XMLElement* elem = brushElem->InsertNewChildElement("pixelperfect"); + elem->SetAttribute("value", slot.pixelPerfect() ? "true": "false"); } } - - brushesElem.InsertEndChild(brushElem); } - TiXmlDeclaration declaration("1.0", "utf-8", ""); - doc->InsertEndChild(declaration); - doc->InsertEndChild(brushesElem); - save_xml(doc, filename); + save_xml(doc.get(), filename); } // static diff --git a/src/app/app_menus.cpp b/src/app/app_menus.cpp index b50a0a68c..efd329414 100644 --- a/src/app/app_menus.cpp +++ b/src/app/app_menus.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2019-2023 Igara Studio S.A. +// Copyright (C) 2019-2024 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -35,7 +35,7 @@ #include "ui/ui.h" #include "ver/info.h" -#include "tinyxml.h" +#include "tinyxml2.h" #include #include @@ -47,6 +47,7 @@ namespace app { +using namespace tinyxml2; using namespace ui; namespace { @@ -343,8 +344,8 @@ void AppMenus::reload() { MENUS_TRACE("MENUS: AppMenus::reload()"); - XmlDocumentRef doc(GuiXml::instance()->doc()); - TiXmlHandle handle(doc.get()); + XMLDocument* doc = GuiXml::instance()->doc(); + XMLHandle handle(doc); const char* path = GuiXml::instance()->filename(); //////////////////////////////////////// @@ -454,9 +455,9 @@ void AppMenus::reload() LOG("MENU: Loading commands keyboard shortcuts from %s\n", path); - TiXmlElement* xmlKey = handle - .FirstChild("gui") - .FirstChild("keyboard").ToElement(); + XMLElement* xmlKey = handle + .FirstChildElement("gui") + .FirstChildElement("keyboard").ToElement(); // From a fresh start, load the default keys KeyboardShortcuts::instance()->clear(); @@ -716,15 +717,15 @@ void AppMenus::removeMenuItemFromGroup(Widget* menuItem) }); } -Menu* AppMenus::loadMenuById(TiXmlHandle& handle, const char* id) +Menu* AppMenus::loadMenuById(XMLHandle& handle, const char* id) { ASSERT(id != NULL); // - TiXmlElement* xmlMenu = handle - .FirstChild("gui") - .FirstChild("menus") - .FirstChild("menu").ToElement(); + XMLElement* xmlMenu = handle + .FirstChildElement("gui") + .FirstChildElement("menus") + .FirstChildElement("menu").ToElement(); while (xmlMenu) { const char* menuId = xmlMenu->Attribute("id"); @@ -739,12 +740,12 @@ Menu* AppMenus::loadMenuById(TiXmlHandle& handle, const char* id) throw base::Exception("Error loading menu '%s'\nReinstall the application.", id); } -Menu* AppMenus::convertXmlelemToMenu(TiXmlElement* elem) +Menu* AppMenus::convertXmlelemToMenu(XMLElement* elem) { Menu* menu = new Menu(); menu->setText(m_xmlTranslator(elem, "text")); - TiXmlElement* child = elem->FirstChildElement(); + XMLElement* child = elem->FirstChildElement(); while (child) { Widget* menuitem = convertXmlelemToMenuitem(child, menu); if (menuitem) @@ -759,7 +760,7 @@ Menu* AppMenus::convertXmlelemToMenu(TiXmlElement* elem) return menu; } -Widget* AppMenus::convertXmlelemToMenuitem(TiXmlElement* elem, Menu* menu) +Widget* AppMenus::convertXmlelemToMenuitem(XMLElement* elem, Menu* menu) { const char* id = elem->Attribute("id"); const char* group = elem->Attribute("group"); @@ -791,7 +792,7 @@ Widget* AppMenus::convertXmlelemToMenuitem(TiXmlElement* elem, Menu* menu) // load params Params params; if (command) { - TiXmlElement* xmlParam = elem->FirstChildElement("param"); + XMLElement* xmlParam = elem->FirstChildElement("param"); while (xmlParam) { const char* param_name = xmlParam->Attribute("name"); const char* param_value = xmlParam->Attribute("value"); diff --git a/src/app/app_menus.h b/src/app/app_menus.h index 644b9fbd8..04db11037 100644 --- a/src/app/app_menus.h +++ b/src/app/app_menus.h @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2019-2023 Igara Studio S.A. +// Copyright (C) 2019-2024 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -20,8 +20,10 @@ #include -class TiXmlElement; -class TiXmlHandle; +namespace tinyxml2 { + class XMLElement; + class XMLHandle; +} namespace app { class Command; @@ -73,9 +75,9 @@ namespace app { template void removeMenuItemFromGroup(Pred pred); - Menu* loadMenuById(TiXmlHandle& handle, const char *id); - Menu* convertXmlelemToMenu(TiXmlElement* elem); - Widget* convertXmlelemToMenuitem(TiXmlElement* elem, Menu* menu); + Menu* loadMenuById(tinyxml2::XMLHandle& handle, const char *id); + Menu* convertXmlelemToMenu(tinyxml2::XMLElement* elem); + Widget* convertXmlelemToMenuitem(tinyxml2::XMLElement* elem, Menu* menu); void applyShortcutToMenuitemsWithCommand(Menu* menu, Command* command, const Params& params, const KeyPtr& key); void syncNativeMenuItemKeyShortcuts(Menu* menu); diff --git a/src/app/file/file_data.cpp b/src/app/file/file_data.cpp index 6d3acc7a4..713313c5d 100644 --- a/src/app/file/file_data.cpp +++ b/src/app/file/file_data.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2019-2023 Igara Studio S.A. +// Copyright (C) 2019-2024 Igara Studio S.A. // Copyright (C) 2001-2017 David Capello // // This program is distributed under the terms of @@ -21,6 +21,8 @@ #include "fmt/format.h" #include "gfx/color.h" +#include "tinyxml2.h" + #include #include #include @@ -29,6 +31,7 @@ namespace app { using namespace base; using namespace doc; +using namespace tinyxml2; namespace { @@ -89,7 +92,7 @@ template void update_xml_collection(const Container& container, - TiXmlElement* xmlParent, + XMLElement* xmlParent, const char* childElemName, const char* idAttrName, ChildNameGetterFunc childNameGetter, @@ -98,12 +101,12 @@ void update_xml_collection(const Container& container, if (!xmlParent) return; - TiXmlElement* xmlNext = nullptr; + XMLElement* xmlNext = nullptr; std::set existent; // Update existent children - for (TiXmlElement* xmlChild=(xmlParent->FirstChild(childElemName) ? - xmlParent->FirstChild(childElemName)->ToElement(): nullptr); + for (XMLElement* xmlChild=(xmlParent->FirstChildElement(childElemName) ? + xmlParent->FirstChildElement(childElemName): nullptr); xmlChild; xmlChild=xmlNext) { xmlNext = xmlChild->NextSiblingElement(); @@ -126,35 +129,33 @@ void update_xml_collection(const Container& container, // Delete this element (as the child was removed from the // original container) if (!found) - xmlParent->RemoveChild(xmlChild); + xmlParent->DeleteChild(xmlChild); } // Add new children for (const auto& child : container) { std::string thisChildName = childNameGetter(child); if (existent.find(thisChildName) == existent.end()) { - TiXmlElement xmlChild(childElemName); - xmlChild.SetAttribute(idAttrName, thisChildName.c_str()); - updateXmlChild(child, &xmlChild); - - xmlParent->InsertEndChild(xmlChild); + XMLElement* xmlChild = xmlParent->InsertNewChildElement(childElemName); + xmlChild->SetAttribute(idAttrName, thisChildName.c_str()); + updateXmlChild(child, xmlChild); } } } -void update_xml_part_from_slice_key(const doc::SliceKey* key, TiXmlElement* xmlPart) +void update_xml_part_from_slice_key(const doc::SliceKey* key, XMLElement* xmlPart) { xmlPart->SetAttribute("x", key->bounds().x); xmlPart->SetAttribute("y", key->bounds().y); if (!key->hasCenter()) { xmlPart->SetAttribute("w", key->bounds().w); xmlPart->SetAttribute("h", key->bounds().h); - if (xmlPart->Attribute("w1")) xmlPart->RemoveAttribute("w1"); - if (xmlPart->Attribute("w2")) xmlPart->RemoveAttribute("w2"); - if (xmlPart->Attribute("w3")) xmlPart->RemoveAttribute("w3"); - if (xmlPart->Attribute("h1")) xmlPart->RemoveAttribute("h1"); - if (xmlPart->Attribute("h2")) xmlPart->RemoveAttribute("h2"); - if (xmlPart->Attribute("h3")) xmlPart->RemoveAttribute("h3"); + if (xmlPart->Attribute("w1")) xmlPart->DeleteAttribute("w1"); + if (xmlPart->Attribute("w2")) xmlPart->DeleteAttribute("w2"); + if (xmlPart->Attribute("w3")) xmlPart->DeleteAttribute("w3"); + if (xmlPart->Attribute("h1")) xmlPart->DeleteAttribute("h1"); + if (xmlPart->Attribute("h2")) xmlPart->DeleteAttribute("h2"); + if (xmlPart->Attribute("h3")) xmlPart->DeleteAttribute("h3"); } else { xmlPart->SetAttribute("w1", key->center().x); @@ -163,8 +164,8 @@ void update_xml_part_from_slice_key(const doc::SliceKey* key, TiXmlElement* xmlP xmlPart->SetAttribute("h1", key->center().y); xmlPart->SetAttribute("h2", key->center().h); xmlPart->SetAttribute("h3", key->bounds().h - key->center().y2()); - if (xmlPart->Attribute("w")) xmlPart->RemoveAttribute("w"); - if (xmlPart->Attribute("h")) xmlPart->RemoveAttribute("h"); + if (xmlPart->Attribute("w")) xmlPart->DeleteAttribute("w"); + if (xmlPart->Attribute("h")) xmlPart->DeleteAttribute("h"); } if (key->hasPivot()) { @@ -172,17 +173,17 @@ void update_xml_part_from_slice_key(const doc::SliceKey* key, TiXmlElement* xmlP xmlPart->SetAttribute("focusy", key->pivot().y); } else { - if (xmlPart->Attribute("focusx")) xmlPart->RemoveAttribute("focusx"); - if (xmlPart->Attribute("focusy")) xmlPart->RemoveAttribute("focusy"); + if (xmlPart->Attribute("focusx")) xmlPart->DeleteAttribute("focusx"); + if (xmlPart->Attribute("focusy")) xmlPart->DeleteAttribute("focusy"); } } -void update_xml_slice(const doc::Slice* slice, TiXmlElement* xmlSlice) +void update_xml_slice(const doc::Slice* slice, XMLElement* xmlSlice) { if (!slice->userData().text().empty()) xmlSlice->SetAttribute("text", slice->userData().text().c_str()); else if (xmlSlice->Attribute("text")) - xmlSlice->RemoveAttribute("text"); + xmlSlice->DeleteAttribute("text"); xmlSlice->SetAttribute("color", color_to_hex(slice->userData().color()).c_str()); // Update elements @@ -192,7 +193,7 @@ void update_xml_slice(const doc::Slice* slice, TiXmlElement* xmlSlice) [](const Keyframes::Key& key) -> std::string { return base::convert_to(key.frame()); }, - [](const Keyframes::Key& key, TiXmlElement* xmlKey) { + [](const Keyframes::Key& key, XMLElement* xmlKey) { SliceKey* sliceKey = key.value(); xmlKey->SetAttribute("x", sliceKey->bounds().x); @@ -207,10 +208,10 @@ void update_xml_slice(const doc::Slice* slice, TiXmlElement* xmlSlice) xmlKey->SetAttribute("ch", sliceKey->center().h); } else { - if (xmlKey->Attribute("cx")) xmlKey->RemoveAttribute("cx"); - if (xmlKey->Attribute("cy")) xmlKey->RemoveAttribute("cy"); - if (xmlKey->Attribute("cw")) xmlKey->RemoveAttribute("cw"); - if (xmlKey->Attribute("ch")) xmlKey->RemoveAttribute("ch"); + if (xmlKey->Attribute("cx")) xmlKey->DeleteAttribute("cx"); + if (xmlKey->Attribute("cy")) xmlKey->DeleteAttribute("cy"); + if (xmlKey->Attribute("cw")) xmlKey->DeleteAttribute("cw"); + if (xmlKey->Attribute("ch")) xmlKey->DeleteAttribute("ch"); } if (sliceKey->hasPivot()) { @@ -218,8 +219,8 @@ void update_xml_slice(const doc::Slice* slice, TiXmlElement* xmlSlice) xmlKey->SetAttribute("py", sliceKey->pivot().y); } else { - if (xmlKey->Attribute("px")) xmlKey->RemoveAttribute("px"); - if (xmlKey->Attribute("py")) xmlKey->RemoveAttribute("py"); + if (xmlKey->Attribute("px")) xmlKey->DeleteAttribute("px"); + if (xmlKey->Attribute("py")) xmlKey->DeleteAttribute("py"); } }); } @@ -230,12 +231,12 @@ void load_aseprite_data_file(const std::string& dataFilename, doc::Document* doc, app::Color& defaultSliceColor) { - XmlDocumentRef xmlDoc = open_xml(dataFilename); - TiXmlHandle handle(xmlDoc.get()); + XMLDocumentRef xmlDoc = open_xml(dataFilename); + XMLHandle handle(xmlDoc.get()); - TiXmlElement* xmlSlices = handle - .FirstChild("sprite") - .FirstChild("slices").ToElement(); + XMLElement* xmlSlices = handle + .FirstChildElement("sprite") + .FirstChildElement("slices").ToElement(); // Load slices/parts from theme.xml file if (xmlSlices && @@ -243,13 +244,13 @@ void load_aseprite_data_file(const std::string& dataFilename, std::string themeFileName = xmlSlices->Attribute("theme"); // Open theme XML file - XmlDocumentRef xmlThemeDoc = open_xml( + XMLDocumentRef xmlThemeDoc = open_xml( base::join_path(base::get_file_path(dataFilename), themeFileName)); - TiXmlHandle themeHandle(xmlThemeDoc.get()); - for (TiXmlElement* xmlPart = themeHandle - .FirstChild("theme") - .FirstChild("parts") - .FirstChild("part").ToElement(); + XMLHandle themeHandle(xmlThemeDoc.get()); + for (XMLElement* xmlPart = themeHandle + .FirstChildElement("theme") + .FirstChildElement("parts") + .FirstChildElement("part").ToElement(); xmlPart; xmlPart=xmlPart->NextSiblingElement()) { const char* partId = xmlPart->Attribute("id"); @@ -300,8 +301,8 @@ void load_aseprite_data_file(const std::string& dataFilename, } // Load slices from elements else if (xmlSlices) { - for (TiXmlElement* xmlSlice=(xmlSlices->FirstChild("slice") ? - xmlSlices->FirstChild("slice")->ToElement(): nullptr); + for (XMLElement* xmlSlice=(xmlSlices->FirstChildElement("slice") ? + xmlSlices->FirstChildElement("slice")->ToElement(): nullptr); xmlSlice; xmlSlice=xmlSlice->NextSiblingElement()) { const char* sliceId = xmlSlice->Attribute("id"); @@ -332,8 +333,8 @@ void load_aseprite_data_file(const std::string& dataFilename, } slice->userData().setColor(color); - for (TiXmlElement* xmlKey=(xmlSlice->FirstChild("key") ? - xmlSlice->FirstChild("key")->ToElement(): nullptr); + for (XMLElement* xmlKey=(xmlSlice->FirstChildElement("key") ? + xmlSlice->FirstChildElement("key")->ToElement(): nullptr); xmlKey; xmlKey=xmlKey->NextSiblingElement()) { if (!xmlKey->Attribute("frame")) @@ -373,12 +374,12 @@ void load_aseprite_data_file(const std::string& dataFilename, #ifdef ENABLE_SAVE void save_aseprite_data_file(const std::string& dataFilename, const doc::Document* doc) { - XmlDocumentRef xmlDoc = open_xml(dataFilename); - TiXmlHandle handle(xmlDoc.get()); + XMLDocumentRef xmlDoc = open_xml(dataFilename); + XMLHandle handle(xmlDoc.get()); - TiXmlElement* xmlSlices = handle - .FirstChild("sprite") - .FirstChild("slices").ToElement(); + XMLElement* xmlSlices = handle + .FirstChildElement("sprite") + .FirstChildElement("slices").ToElement(); // Update theme.xml file if (xmlSlices && @@ -386,13 +387,13 @@ void save_aseprite_data_file(const std::string& dataFilename, const doc::Documen // Open theme XML file std::string themeFileName = base::join_path( base::get_file_path(dataFilename), xmlSlices->Attribute("theme")); - XmlDocumentRef xmlThemeDoc = open_xml(themeFileName); + XMLDocumentRef xmlThemeDoc = open_xml(themeFileName); - TiXmlHandle themeHandle(xmlThemeDoc.get()); - TiXmlElement* xmlParts = + XMLHandle themeHandle(xmlThemeDoc.get()); + XMLElement* xmlParts = themeHandle - .FirstChild("theme") - .FirstChild("parts").ToElement(); + .FirstChildElement("theme") + .FirstChildElement("parts").ToElement(); update_xml_collection( doc->sprite()->slices(), @@ -403,13 +404,13 @@ void save_aseprite_data_file(const std::string& dataFilename, const doc::Documen else return std::string(); }, - [](Slice* slice, TiXmlElement* xmlSlice) { + [](Slice* slice, XMLElement* xmlSlice) { ASSERT(slice->getByFrame(0)); update_xml_part_from_slice_key(slice->getByFrame(0), xmlSlice); }); // Save theme.xml file - save_xml(xmlThemeDoc, themeFileName); + save_xml(xmlThemeDoc.get(), themeFileName); } // without "theme" attribute else if (xmlSlices) { @@ -422,7 +423,7 @@ void save_aseprite_data_file(const std::string& dataFilename, const doc::Documen update_xml_slice); // Save .aseprite-data file - save_xml(xmlDoc, dataFilename); + save_xml(xmlDoc.get(), dataFilename); } } #endif diff --git a/src/app/gui_xml.h b/src/app/gui_xml.h index cbad619f9..60073317c 100644 --- a/src/app/gui_xml.h +++ b/src/app/gui_xml.h @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2020-2022 Igara Studio S.A. +// Copyright (C) 2020-2024 Igara Studio S.A. // Copyright (C) 2001-2015 David Capello // // This program is distributed under the terms of @@ -28,8 +28,8 @@ namespace app { GuiXml(); // Returns the tinyxml document instance. - XmlDocumentRef doc() { - return m_doc; + tinyxml2::XMLDocument* doc() { + return m_doc.get(); } // Returns the name of the gui.xml file. @@ -38,7 +38,7 @@ namespace app { } private: - XmlDocumentRef m_doc; + XMLDocumentRef m_doc; friend class std::unique_ptr; }; diff --git a/src/app/i18n/xml_translator.cpp b/src/app/i18n/xml_translator.cpp index f724567fa..21ff28f9f 100644 --- a/src/app/i18n/xml_translator.cpp +++ b/src/app/i18n/xml_translator.cpp @@ -1,4 +1,5 @@ // Aseprite +// Copyright (C) 2024 Igara Studio S.A. // Copyright (C) 2017 David Capello // // This program is distributed under the terms of @@ -11,11 +12,13 @@ #include "app/i18n/xml_translator.h" #include "app/i18n/strings.h" -#include "tinyxml.h" +#include "tinyxml2.h" namespace app { -std::string XmlTranslator::operator()(const TiXmlElement* elem, +using namespace tinyxml2; + +std::string XmlTranslator::operator()(const XMLElement* elem, const char* attrName) { const char* value = elem->Attribute(attrName); diff --git a/src/app/i18n/xml_translator.h b/src/app/i18n/xml_translator.h index 1415b75f0..ed0df5b4b 100644 --- a/src/app/i18n/xml_translator.h +++ b/src/app/i18n/xml_translator.h @@ -1,4 +1,5 @@ // Aseprite +// Copyright (C) 2024 Igara Studio S.A. // Copyright (C) 2017 David Capello // // This program is distributed under the terms of @@ -10,13 +11,15 @@ #include -class TiXmlElement; +namespace tinyxml2 { + class XMLElement; +} namespace app { class XmlTranslator { public: - std::string operator()(const TiXmlElement* elem, + std::string operator()(const tinyxml2::XMLElement* elem, const char* attrName); void clearStringIdPrefix(); diff --git a/src/app/tools/tool_box.cpp b/src/app/tools/tool_box.cpp index cf4a4accd..2a3f4655e 100644 --- a/src/app/tools/tool_box.cpp +++ b/src/app/tools/tool_box.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2018-2020 Igara Studio S.A. +// Copyright (C) 2018-2024 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -29,6 +29,8 @@ #include "doc/image_impl.h" #include "doc/mask.h" +#include "tinyxml2.h" + #include #include @@ -41,6 +43,7 @@ namespace app { namespace tools { using namespace gfx; +using namespace tinyxml2; const char* WellKnownTools::RectangularMarquee = "rectangular_marquee"; const char* WellKnownTools::Lasso = "lasso"; @@ -206,11 +209,14 @@ void ToolBox::loadTools() { LOG("TOOL: Loading tools...\n"); - XmlDocumentRef doc(GuiXml::instance()->doc()); - TiXmlHandle handle(doc.get()); + XMLDocument* doc = GuiXml::instance()->doc(); + XMLHandle handle(doc); // For each group - TiXmlElement* xmlGroup = handle.FirstChild("gui").FirstChild("tools").FirstChild("group").ToElement(); + XMLElement* xmlGroup = handle + .FirstChildElement("gui") + .FirstChildElement("tools") + .FirstChildElement("group").ToElement(); while (xmlGroup) { const char* groupId = xmlGroup->Attribute("id"); if (!groupId) @@ -233,8 +239,8 @@ void ToolBox::loadTools() } // For each tool - TiXmlNode* xmlToolNode = xmlGroup->FirstChild("tool"); - TiXmlElement* xmlTool = xmlToolNode ? xmlToolNode->ToElement(): NULL; + XMLNode* xmlToolNode = xmlGroup->FirstChildElement("tool"); + XMLElement* xmlTool = (xmlToolNode ? xmlToolNode->ToElement(): nullptr); while (xmlTool) { const char* toolId = xmlTool->Attribute("id"); std::string toolText = m_xmlTranslator(xmlTool, "text"); @@ -272,7 +278,7 @@ void ToolBox::loadTools() LOG("TOOL: Done. %d tools, %d groups.\n", m_tools.size(), m_groups.size()); } -void ToolBox::loadToolProperties(TiXmlElement* xmlTool, Tool* tool, int button, const std::string& suffix) +void ToolBox::loadToolProperties(XMLElement* xmlTool, Tool* tool, int button, const std::string& suffix) { const char* tool_id = tool->getId().c_str(); const char* fill = xmlTool->Attribute(("fill_"+suffix).c_str()); diff --git a/src/app/tools/tool_box.h b/src/app/tools/tool_box.h index 7f2b48fd6..7fa653583 100644 --- a/src/app/tools/tool_box.h +++ b/src/app/tools/tool_box.h @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2018-2020 Igara Studio S.A. +// Copyright (C) 2018-2024 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -16,7 +16,9 @@ #include "app/i18n/xml_translator.h" #include "app/tools/tool.h" -class TiXmlElement; +namespace tinyxml2 { + class XMLElement; +} namespace app { namespace tools { @@ -113,7 +115,7 @@ namespace app { private: void loadTools(); - void loadToolProperties(TiXmlElement* xmlTool, Tool* tool, int button, const std::string& suffix); + void loadToolProperties(tinyxml2::XMLElement* xmlTool, Tool* tool, int button, const std::string& suffix); std::map m_inks; std::map m_controllers; diff --git a/src/app/ui/keyboard_shortcuts.cpp b/src/app/ui/keyboard_shortcuts.cpp index ab785d8a3..2991b983b 100644 --- a/src/app/ui/keyboard_shortcuts.cpp +++ b/src/app/ui/keyboard_shortcuts.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2018-2023 Igara Studio S.A. +// Copyright (C) 2018-2024 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -31,6 +31,8 @@ #include "ui/accelerator.h" #include "ui/message.h" +#include "tinyxml2.h" + #include #include #include @@ -39,6 +41,8 @@ #define I18N_KEY(a) app::Strings::keyboard_shortcuts_##a() +using namespace tinyxml2; + namespace { struct KeyShortcutAction { @@ -138,7 +142,7 @@ namespace { return g_wheel_actions; } - const char* get_shortcut(TiXmlElement* elem) { + const char* get_shortcut(XMLElement* elem) { const char* shortcut = NULL; #ifdef _WIN32 @@ -613,13 +617,13 @@ void KeyboardShortcuts::clear() m_keys.clear(); } -void KeyboardShortcuts::importFile(TiXmlElement* rootElement, KeySource source) +void KeyboardShortcuts::importFile(XMLElement* rootElement, KeySource source) { // - TiXmlHandle handle(rootElement); - TiXmlElement* xmlKey = handle - .FirstChild("commands") - .FirstChild("key").ToElement(); + XMLHandle handle(rootElement); + XMLElement* xmlKey = handle + .FirstChildElement("commands") + .FirstChildElement("key").ToElement(); while (xmlKey) { const char* command_name = xmlKey->Attribute("command"); const char* command_key = get_shortcut(xmlKey); @@ -637,7 +641,7 @@ void KeyboardShortcuts::importFile(TiXmlElement* rootElement, KeySource source) // Read params Params params; - TiXmlElement* xmlParam = xmlKey->FirstChildElement("param"); + XMLElement* xmlParam = xmlKey->FirstChildElement("param"); while (xmlParam) { const char* param_name = xmlParam->Attribute("name"); const char* param_value = xmlParam->Attribute("value"); @@ -677,8 +681,8 @@ void KeyboardShortcuts::importFile(TiXmlElement* rootElement, KeySource source) // Load keyboard shortcuts for tools // xmlKey = handle - .FirstChild("tools") - .FirstChild("key").ToElement(); + .FirstChildElement("tools") + .FirstChildElement("key").ToElement(); while (xmlKey) { const char* tool_id = xmlKey->Attribute("tool"); const char* tool_key = get_shortcut(xmlKey); @@ -705,8 +709,8 @@ void KeyboardShortcuts::importFile(TiXmlElement* rootElement, KeySource source) // Load keyboard shortcuts for quicktools // xmlKey = handle - .FirstChild("quicktools") - .FirstChild("key").ToElement(); + .FirstChildElement("quicktools") + .FirstChildElement("key").ToElement(); while (xmlKey) { const char* tool_id = xmlKey->Attribute("tool"); const char* tool_key = get_shortcut(xmlKey); @@ -733,8 +737,8 @@ void KeyboardShortcuts::importFile(TiXmlElement* rootElement, KeySource source) // Load special keyboard shortcuts for sprite editor customization // xmlKey = handle - .FirstChild("actions") - .FirstChild("key").ToElement(); + .FirstChildElement("actions") + .FirstChildElement("key").ToElement(); while (xmlKey) { const char* action_id = xmlKey->Attribute("action"); const char* action_key = get_shortcut(xmlKey); @@ -768,8 +772,8 @@ void KeyboardShortcuts::importFile(TiXmlElement* rootElement, KeySource source) // Load special keyboard shortcuts for mouse wheel customization // xmlKey = handle - .FirstChild("wheel") - .FirstChild("key").ToElement(); + .FirstChildElement("wheel") + .FirstChildElement("key").ToElement(); while (xmlKey) { const char* action_id = xmlKey->Attribute("action"); const char* action_key = get_shortcut(xmlKey); @@ -796,8 +800,8 @@ void KeyboardShortcuts::importFile(TiXmlElement* rootElement, KeySource source) // Load special keyboard shortcuts to simulate mouse wheel actions // xmlKey = handle - .FirstChild("drag") - .FirstChild("key").ToElement(); + .FirstChildElement("drag") + .FirstChildElement("key").ToElement(); while (xmlKey) { const char* action_id = xmlKey->Attribute("action"); const char* action_key = get_shortcut(xmlKey); @@ -835,26 +839,25 @@ void KeyboardShortcuts::importFile(TiXmlElement* rootElement, KeySource source) void KeyboardShortcuts::importFile(const std::string& filename, KeySource source) { - XmlDocumentRef doc = app::open_xml(filename); - TiXmlHandle handle(doc.get()); - TiXmlElement* xmlKey = handle.FirstChild("keyboard").ToElement(); + XMLDocumentRef doc = app::open_xml(filename); + XMLHandle handle(doc.get()); + XMLElement* xmlKey = handle.FirstChildElement("keyboard").ToElement(); importFile(xmlKey, source); } void KeyboardShortcuts::exportFile(const std::string& filename) { - XmlDocumentRef doc(new TiXmlDocument()); + auto doc = std::make_unique(); + XMLElement* keyboard = doc->NewElement("keyboard"); + XMLElement* commands = keyboard->InsertNewChildElement("commands"); + XMLElement* tools = keyboard->InsertNewChildElement("tools"); + XMLElement* quicktools = keyboard->InsertNewChildElement("quicktools"); + XMLElement* actions = keyboard->InsertNewChildElement("actions"); + XMLElement* wheel = keyboard->InsertNewChildElement("wheel"); + XMLElement* drag = keyboard->InsertNewChildElement("drag"); - TiXmlElement keyboard("keyboard"); - TiXmlElement commands("commands"); - TiXmlElement tools("tools"); - TiXmlElement quicktools("quicktools"); - TiXmlElement actions("actions"); - TiXmlElement wheel("wheel"); - TiXmlElement drag("drag"); - - keyboard.SetAttribute("version", XML_KEYBOARD_FILE_VERSION); + keyboard->SetAttribute("version", XML_KEYBOARD_FILE_VERSION); exportKeys(commands, KeyType::Command); exportKeys(tools, KeyType::Tool); @@ -863,20 +866,12 @@ void KeyboardShortcuts::exportFile(const std::string& filename) exportKeys(wheel, KeyType::WheelAction); exportKeys(drag, KeyType::DragAction); - keyboard.InsertEndChild(commands); - keyboard.InsertEndChild(tools); - keyboard.InsertEndChild(quicktools); - keyboard.InsertEndChild(actions); - keyboard.InsertEndChild(wheel); - keyboard.InsertEndChild(drag); - - TiXmlDeclaration declaration("1.0", "utf-8", ""); - doc->InsertEndChild(declaration); + doc->InsertEndChild(doc->NewDeclaration("xml version=\"1.0\" encoding=\"utf-8\"")); doc->InsertEndChild(keyboard); - save_xml(doc, filename); + save_xml(doc.get(), filename); } -void KeyboardShortcuts::exportKeys(TiXmlElement& parent, KeyType type) +void KeyboardShortcuts::exportKeys(XMLElement* parent, KeyType type) { for (KeyPtr& key : m_keys) { // Save only user defined accelerators. @@ -893,17 +888,17 @@ void KeyboardShortcuts::exportKeys(TiXmlElement& parent, KeyType type) } } -void KeyboardShortcuts::exportAccel(TiXmlElement& parent, const Key* key, const ui::Accelerator& accel, bool removed) +void KeyboardShortcuts::exportAccel(XMLElement* parent, const Key* key, const ui::Accelerator& accel, bool removed) { - TiXmlElement elem("key"); + XMLElement* elem = parent->InsertNewChildElement("key"); switch (key->type()) { case KeyType::Command: { - elem.SetAttribute("command", key->command()->id().c_str()); + elem->SetAttribute("command", key->command()->id().c_str()); if (key->keycontext() != KeyContext::Any) { - elem.SetAttribute("context", + elem->SetAttribute("context", base::convert_to(key->keycontext()).c_str()); } @@ -911,48 +906,45 @@ void KeyboardShortcuts::exportAccel(TiXmlElement& parent, const Key* key, const if (param.second.empty()) continue; - TiXmlElement paramElem("param"); - paramElem.SetAttribute("name", param.first.c_str()); - paramElem.SetAttribute("value", param.second.c_str()); - elem.InsertEndChild(paramElem); + XMLElement* paramElem = elem->InsertNewChildElement("param"); + paramElem->SetAttribute("name", param.first.c_str()); + paramElem->SetAttribute("value", param.second.c_str()); } break; } case KeyType::Tool: case KeyType::Quicktool: - elem.SetAttribute("tool", key->tool()->getId().c_str()); + elem->SetAttribute("tool", key->tool()->getId().c_str()); break; case KeyType::Action: - elem.SetAttribute("action", + elem->SetAttribute("action", base::convert_to(key->action()).c_str()); if (key->keycontext() != KeyContext::Any) - elem.SetAttribute("context", + elem->SetAttribute("context", base::convert_to(key->keycontext()).c_str()); break; case KeyType::WheelAction: - elem.SetAttribute("action", - base::convert_to(key->wheelAction())); + elem->SetAttribute("action", + base::convert_to(key->wheelAction()).c_str()); break; case KeyType::DragAction: - elem.SetAttribute("action", - base::convert_to(key->wheelAction())); - elem.SetAttribute("vector", - fmt::format("{},{}", - key->dragVector().x, - key->dragVector().y)); + elem->SetAttribute("action", + base::convert_to(key->wheelAction()).c_str()); + elem->SetAttribute("vector", + fmt::format("{},{}", + key->dragVector().x, + key->dragVector().y).c_str()); break; } - elem.SetAttribute("shortcut", accel.toString().c_str()); + elem->SetAttribute("shortcut", accel.toString().c_str()); if (removed) - elem.SetAttribute("removed", "true"); - - parent.InsertEndChild(elem); + elem->SetAttribute("removed", "true"); } void KeyboardShortcuts::reset() diff --git a/src/app/ui/keyboard_shortcuts.h b/src/app/ui/keyboard_shortcuts.h index 6ebe2cc51..893a1d7e0 100644 --- a/src/app/ui/keyboard_shortcuts.h +++ b/src/app/ui/keyboard_shortcuts.h @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2020-2023 Igara Studio S.A. +// Copyright (C) 2020-2024 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -12,7 +12,9 @@ #include "app/ui/key.h" #include "obs/signal.h" -class TiXmlElement; +namespace tinyxml2 { + class XMLElement; +} namespace app { @@ -38,7 +40,7 @@ namespace app { const bool cloneKeys); void clear(); - void importFile(TiXmlElement* rootElement, KeySource source); + void importFile(tinyxml2::XMLElement* rootElement, KeySource source); void importFile(const std::string& filename, KeySource source); void exportFile(const std::string& filename); void reset(); @@ -78,8 +80,8 @@ namespace app { obs::signal UserChange; private: - void exportKeys(TiXmlElement& parent, KeyType type); - void exportAccel(TiXmlElement& parent, const Key* key, const ui::Accelerator& accel, bool removed); + void exportKeys(tinyxml2::XMLElement* parent, KeyType type); + void exportAccel(tinyxml2::XMLElement* parent, const Key* key, const ui::Accelerator& accel, bool removed); mutable Keys m_keys; }; diff --git a/src/app/ui/news_listbox.cpp b/src/app/ui/news_listbox.cpp index 6d492c6fd..b4aa723a3 100644 --- a/src/app/ui/news_listbox.cpp +++ b/src/app/ui/news_listbox.cpp @@ -27,15 +27,16 @@ #include "ui/view.h" #include "ver/info.h" -#include "tinyxml.h" +#include "tinyxml2.h" #include #include namespace app { -using namespace ui; using namespace app::skin; +using namespace tinyxml2; +using namespace ui; namespace { @@ -267,7 +268,7 @@ void NewsListBox::parseFile(const std::string& filename) { View* view = View::getView(this); - XmlDocumentRef doc; + XMLDocumentRef doc; try { doc = open_xml(filename); } @@ -278,18 +279,18 @@ void NewsListBox::parseFile(const std::string& filename) return; } - TiXmlHandle handle(doc.get()); - TiXmlElement* itemXml = handle - .FirstChild("rss") - .FirstChild("channel") - .FirstChild("item").ToElement(); + XMLHandle handle(doc.get()); + XMLElement* itemXml = handle + .FirstChildElement("rss") + .FirstChildElement("channel") + .FirstChildElement("item").ToElement(); int count = 0; while (itemXml) { - TiXmlElement* titleXml = itemXml->FirstChildElement("title"); - TiXmlElement* descXml = itemXml->FirstChildElement("description"); - TiXmlElement* linkXml = itemXml->FirstChildElement("link"); + XMLElement* titleXml = itemXml->FirstChildElement("title"); + XMLElement* descXml = itemXml->FirstChildElement("description"); + XMLElement* linkXml = itemXml->FirstChildElement("link"); if (titleXml && titleXml->GetText() && descXml && descXml->GetText() && linkXml && linkXml->GetText()) { @@ -316,10 +317,10 @@ void NewsListBox::parseFile(const std::string& filename) itemXml = itemXml->NextSiblingElement(); } - TiXmlElement* linkXml = handle - .FirstChild("rss") - .FirstChild("channel") - .FirstChild("link").ToElement(); + XMLElement* linkXml = handle + .FirstChildElement("rss") + .FirstChildElement("channel") + .FirstChildElement("link").ToElement(); if (linkXml && linkXml->GetText()) addChild( new NewsItem(linkXml->GetText(), Strings::news_listbox_more(), "")); diff --git a/src/app/ui/skin/skin_theme.cpp b/src/app/ui/skin/skin_theme.cpp index c7d8a99b5..2a21bf130 100644 --- a/src/app/ui/skin/skin_theme.cpp +++ b/src/app/ui/skin/skin_theme.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2019-2023 Igara Studio S.A. +// Copyright (C) 2019-2024 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -40,7 +40,7 @@ #include "ui/intern.h" #include "ui/ui.h" -#include "tinyxml.h" +#include "tinyxml2.h" #include #include @@ -52,6 +52,7 @@ namespace app { namespace skin { using namespace gfx; +using namespace tinyxml2; using namespace ui; // TODO For backward compatibility, in future versions we should remove this (extensions are preferred) @@ -77,7 +78,8 @@ class app::skin::SkinTheme::BackwardCompatibility { // Loaded XML