LCOV - code coverage report
Current view: top level - src/notation/internal - mscnotationwriter.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 38 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 "mscnotationwriter.h"
      24              : 
      25              : #include "io/file.h"
      26              : 
      27              : #include "inotation.h"
      28              : #include "inotationelements.h" // IWYU pragma: keep
      29              : 
      30              : #include "engraving/engravingproject.h"
      31              : #include "engraving/dom/masterscore.h"
      32              : 
      33              : #include "log.h"
      34              : 
      35              : using namespace muse;
      36              : using namespace muse::io;
      37              : using namespace mu::engraving;
      38              : using namespace mu::notation;
      39              : using namespace mu::project;
      40              : 
      41            0 : MscNotationWriter::MscNotationWriter(engraving::MscIoMode mode)
      42            0 :     : m_mode(mode)
      43              : {
      44            0 : }
      45              : 
      46            0 : std::vector<INotationWriter::UnitType> MscNotationWriter::supportedUnitTypes() const
      47              : {
      48            0 :     return { UnitType::MULTI_PART };
      49              : }
      50              : 
      51            0 : bool MscNotationWriter::supportsUnitType(UnitType unitType) const
      52              : {
      53            0 :     std::vector<UnitType> unitTypes = supportedUnitTypes();
      54            0 :     return std::find(unitTypes.cbegin(), unitTypes.cend(), unitType) != unitTypes.cend();
      55            0 : }
      56              : 
      57            0 : Ret MscNotationWriter::write(INotationPtr notation, io::IODevice& device, const Options&)
      58              : {
      59            0 :     IF_ASSERT_FAILED(notation) {
      60            0 :         return make_ret(Ret::Code::UnknownError);
      61              :     }
      62              : 
      63            0 :     mu::engraving::Score* score = notation->elements()->msScore();
      64              : 
      65            0 :     IF_ASSERT_FAILED(score) {
      66            0 :         return make_ret(Ret::Code::UnknownError);
      67              :     }
      68              : 
      69            0 :     MscWriter::Params params;
      70            0 :     params.mode = m_mode;
      71            0 :     params.filePath = device.meta("file_path");
      72            0 :     if (m_mode == MscIoMode::Dir) {
      73            0 :         IF_ASSERT_FAILED(!params.filePath.empty()) {
      74            0 :             return make_ret(Ret::Code::InternalError);
      75              :         }
      76              : 
      77            0 :         if (File::exists(params.filePath)) {
      78            0 :             File::remove(params.filePath);
      79              :         }
      80              :     } else {
      81            0 :         params.device = &device;
      82              :     }
      83              : 
      84            0 :     MscWriter msczWriter(params);
      85            0 :     if (!msczWriter.open()) {
      86            0 :         LOGE() << "MscWriter is not opened";
      87            0 :         return Ret(Ret::Code::UnknownError);
      88              :     }
      89              : 
      90            0 :     notation->elements()->msScore()->masterScore()->project().lock()->writeMscz(msczWriter, true);
      91              : 
      92            0 :     msczWriter.close();
      93              : 
      94            0 :     if (msczWriter.hasError()) {
      95            0 :         LOGE() << "MscWriter has error";
      96            0 :         return Ret(Ret::Code::UnknownError);
      97              :     }
      98              : 
      99            0 :     return Ret(Ret::Code::Ok);
     100            0 : }
     101              : 
     102            0 : Ret MscNotationWriter::writeList(const INotationPtrList&, io::IODevice&, const Options&)
     103              : {
     104            0 :     NOT_SUPPORTED;
     105            0 :     return Ret(Ret::Code::NotSupported);
     106              : }
        

Generated by: LCOV version 2.0-1