File indexing completed on 2025-01-05 04:01:11
0001 /* 0002 * SPDX-FileCopyrightText: 2019-2023 Mattia Basaglia <dev@dragon.best> 0003 * 0004 * SPDX-License-Identifier: GPL-3.0-or-later 0005 */ 0006 #include "aep_format.hpp" 0007 #include "aep_parser.hpp" 0008 #include "aep_loader.hpp" 0009 #include "aepx.hpp" 0010 0011 glaxnimate::io::Autoreg<glaxnimate::io::aep::AepFormat> glaxnimate::io::aep::AepFormat::autoreg; 0012 glaxnimate::io::Autoreg<glaxnimate::io::aep::AepxFormat> glaxnimate::io::aep::AepxFormat::autoreg; 0013 0014 0015 bool glaxnimate::io::aep::AepFormat::riff_to_document(const RiffChunk& chunk, model::Document* document, const QString& filename) 0016 { 0017 AepParser parser(this); 0018 try { 0019 Project project = parser.parse(chunk); 0020 QFileInfo finfo(filename); 0021 AepLoader loader(document, project, finfo.dir(), this); 0022 loader.load_project(); 0023 return true; 0024 } catch ( const AepError& err ) { 0025 return false; 0026 } 0027 } 0028 0029 bool glaxnimate::io::aep::AepFormat::on_open(QIODevice& file, const QString& filename, model::Document* document, const QVariantMap&) 0030 { 0031 AepRiff riff_parser; 0032 try { 0033 RiffChunk chunk = riff_parser.parse(&file); 0034 return riff_to_document(chunk, document, filename); 0035 } catch ( const RiffError& r ) { 0036 error(i18n("Could not load file: %1", r.message)); 0037 return false; 0038 } 0039 } 0040 0041 bool glaxnimate::io::aep::AepxFormat::on_open(QIODevice& file, const QString& filename, model::Document* document, const QVariantMap&) 0042 { 0043 QDomDocument dom; 0044 dom.setContent(file.readAll()); 0045 AepxConverter aepx; 0046 return riff_to_document(aepx.aepx_to_chunk(dom.documentElement()), document, filename); 0047 }