LCOV - code coverage report
Current view: top level - src/project/internal - engravingpluginapihelper.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 39 0
Test Date: 2026-11-05 04:07:02

            Line data    Source code
       1              : /*
       2              :  * SPDX-License-Identifier: GPL-3.0-only
       3              :  * MuseScore-Studio-CLA-applies
       4              :  *
       5              :  * MuseScore Studio
       6              :  * Music Composition & Notation
       7              :  *
       8              :  * Copyright (C) 2021 MuseScore Limited and others
       9              :  *
      10              :  * This program is free software: you can redistribute it and/or modify
      11              :  * it under the terms of the GNU General Public License version 3 as
      12              :  * published by the Free Software Foundation.
      13              :  *
      14              :  * This program is distributed in the hope that it will be useful,
      15              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      16              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17              :  * GNU General Public License for more details.
      18              :  *
      19              :  * You should have received a copy of the GNU General Public License
      20              :  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
      21              :  */
      22              : 
      23              : #include "engravingpluginapihelper.h"
      24              : 
      25              : #include "notation/inotation.h"
      26              : #include "notation/inotationelements.h" // IWYU pragma: keep
      27              : 
      28              : #include "inotationwriter.h"
      29              : #include "types/projectfile.h"
      30              : 
      31              : #include "log.h"
      32              : 
      33              : using namespace mu::project;
      34              : using namespace mu::notation;
      35              : using namespace mu::engraving;
      36              : using namespace muse;
      37              : 
      38            0 : bool EngravingPluginAPIHelper::writeScore(const QString& name, const QString& ext)
      39              : {
      40            0 :     const INotationPtr notation = projectSession()->currentNotation();
      41            0 :     if (!notation) {
      42            0 :         LOGW() << "No notation found";
      43            0 :         return false;
      44              :     }
      45              : 
      46            0 :     const auto unitType = determineWriterUnitType(ext.toStdString());
      47            0 :     if (!unitType) {
      48            0 :         LOGW() << "'" << ext << "' format is not supported";
      49            0 :         return false;
      50              :     }
      51              : 
      52            0 :     const QString outPath = name.endsWith(ext) ? name : (name + '.' + ext);
      53            0 :     return exportProjectScenario()->exportScores({ notation }, outPath, *unitType, /* openDestinationFolderOnExport */ false);
      54            0 : }
      55              : 
      56            0 : Score* EngravingPluginAPIHelper::readScore(const QString& name)
      57              : {
      58            0 :     const muse::io::path_t path(name);
      59            0 :     const ProjectFile file(path);
      60              : 
      61            0 :     openProjectScenario()->openProject(file)
      62            0 :     .onResolve(this, [](const Ret& ret) {
      63            0 :         if (!ret) {
      64            0 :             LOGD() << "score was not opened: " << ret.toString();
      65              :         }
      66            0 :     });
      67              : 
      68              :     //! TODO: return promise to js
      69            0 :     return nullptr;
      70            0 : }
      71              : 
      72            0 : void EngravingPluginAPIHelper::closeScore()
      73              : {
      74            0 :     closeProjectController()->closeOpenedProject()
      75            0 :     .onResolve(this, [](const Ret& ret) {
      76            0 :         if (!ret) {
      77            0 :             LOGD() << "score was not closed: " << ret.toString();
      78              :         }
      79            0 :     });
      80            0 : }
      81              : 
      82            0 : std::optional<INotationWriter::UnitType> EngravingPluginAPIHelper::determineWriterUnitType(const std::string& ext) const
      83              : {
      84            0 :     const INotationWriterPtr writer = writers()->writer(ext);
      85            0 :     if (!writer) {
      86            0 :         return std::nullopt;
      87              :     }
      88              : 
      89            0 :     if (writer->supportsUnitType(INotationWriter::UnitType::PER_PAGE)) {
      90            0 :         return INotationWriter::UnitType::PER_PAGE;
      91            0 :     } else if (writer->supportsUnitType(INotationWriter::UnitType::PER_PART)) {
      92            0 :         return INotationWriter::UnitType::PER_PART;
      93              :     } else {
      94            0 :         return INotationWriter::UnitType::MULTI_PART;
      95              :     }
      96            0 : }
        

Generated by: LCOV version 2.0-1