LCOV - code coverage report
Current view: top level - src/converter/internal - convertercontroller.h Coverage Total Hit
Test: filtered_coverage.info Lines: 100.0 % 3 3
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              : #pragma once
      23              : 
      24              : #include <vector>
      25              : 
      26              : #include "../iconvertercontroller.h"
      27              : 
      28              : #include "modularity/ioc.h"
      29              : #include "io/ifilesystem.h"
      30              : #include "notation/notationtypes.h"
      31              : #include "project/iprojectcreator.h"
      32              : #include "project/inotationwritersregister.h"
      33              : #include "project/iprojectsession.h"
      34              : #include "extensions/iextensionsprovider.h"
      35              : 
      36              : #include "types/retval.h"
      37              : 
      38              : namespace mu::converter {
      39              : class ConverterController : public IConverterController, public muse::Contextable
      40              : {
      41              : public:
      42              :     muse::GlobalInject<muse::io::IFileSystem> fileSystem;
      43              :     muse::GlobalInject<project::IProjectCreator> notationCreator;
      44              :     muse::GlobalInject<project::INotationWritersRegister> writers;
      45              :     muse::ContextInject<project::IProjectSession> projectSession = { this };
      46              :     muse::ContextInject<muse::extensions::IExtensionsProvider> extensionsProvider = { this };
      47              : 
      48              : public:
      49           17 :     ConverterController(const muse::modularity::ContextPtr& iocCtx)
      50           17 :         : muse::Contextable(iocCtx) {}
      51              : 
      52              :     muse::Ret fileConvert(const muse::io::path_t& in, const muse::io::path_t& out, const OpenParams& openParams = {},
      53              :                           const muse::String& soundProfile = {}, const muse::io::path_t& tracksDiffPath = {},
      54              :                           const muse::UriQuery& extensionUri = {}, const std::string& transposeOptionsJson = {},
      55              :                           const std::optional<ConvertTarget>& target = std::nullopt) override;
      56              : 
      57              :     muse::Ret batchConvert(const muse::io::path_t& batchJobFile, const OpenParams& openParams = {}, const muse::String& soundProfile = {},
      58              :                            const muse::UriQuery& extensionUri = {}, muse::ProgressPtr progress = nullptr) override;
      59              : 
      60              :     muse::Ret convertScoreParts(const muse::io::path_t& in, const muse::io::path_t& out, const OpenParams& openParams = {}) override;
      61              : 
      62              :     muse::Ret exportScoreMedia(const muse::io::path_t& in, const muse::io::path_t& out,  const OpenParams& openParams = {},
      63              :                                const muse::io::path_t& highlightConfigPath = muse::io::path_t()) override;
      64              :     muse::Ret exportScoreMeta(const muse::io::path_t& in, const muse::io::path_t& out, const OpenParams& openParams = {}) override;
      65              :     muse::Ret exportScoreParts(const muse::io::path_t& in, const muse::io::path_t& out, const OpenParams& openParams = {}) override;
      66              :     muse::Ret exportScorePartsPdfs(const muse::io::path_t& in, const muse::io::path_t& out, const OpenParams& openParams = {}) override;
      67              :     muse::Ret exportScoreTranspose(const muse::io::path_t& in, const muse::io::path_t& out, const std::string& optionsJson,
      68              :                                    const OpenParams& openParams = {}) override;
      69              : 
      70              :     muse::Ret exportScoreElements(const muse::io::path_t& in, const muse::io::path_t& out, const OpenParams& openParams = {}) override;
      71              : 
      72              :     muse::Ret exportScoreVideo(const muse::io::path_t& in, const muse::io::path_t& out, const OpenParams& openParams = {},
      73              :                                bool withAudio = true) override;
      74              : 
      75              :     muse::Ret updateSource(const muse::io::path_t& in, const std::string& newSource, bool forceMode = false) override;
      76              : 
      77              : private:
      78              :     struct CopyrightInfo {
      79           16 :         CopyrightInfo() {}
      80              : 
      81              :         muse::String text;
      82              :         bool showOnAllPages = false;
      83              :     };
      84              : 
      85              :     struct Job {
      86              :         muse::io::path_t in;
      87              :         muse::io::path_t out;
      88              :         muse::io::path_t tracksDiffPath;
      89              :         std::optional<notation::TransposeOptions> transposeOptions;
      90              :         std::optional<size_t> pageNum;
      91              :         std::vector<size_t> visibleParts;
      92              :         CopyrightInfo copyright;
      93              :     };
      94              : 
      95              :     using BatchJob = std::vector<Job>;
      96              :     using TransposeOpts = std::optional<notation::TransposeOptions>;
      97              : 
      98              :     muse::RetVal<BatchJob> parseBatchJob(const muse::io::path_t& batchJobFile) const;
      99              : 
     100              :     muse::Ret convertFile(const muse::io::path_t& in, const muse::io::path_t& out, const OpenParams& openParams = {},
     101              :                           const muse::String& soundProfile = {}, const muse::io::path_t& tracksDiffPath = {},
     102              :                           const muse::UriQuery& extensionUri = {}, const TransposeOpts& transposeOptions = std::nullopt,
     103              :                           const std::optional<ConvertTarget>& target = std::nullopt, const std::vector<size_t>& visibleParts = {},
     104              :                           const CopyrightInfo& copyright = {});
     105              : 
     106              :     muse::Ret convertScoreParts(project::INotationWriterPtr writer, notation::IMasterNotationPtr masterNotation,
     107              :                                 const muse::io::path_t& out);
     108              : 
     109              :     muse::Ret convertByExtension(project::INotationWriterPtr writer, notation::INotationPtr notation, const muse::io::path_t& out,
     110              :                                  const muse::UriQuery& extensionUri);
     111              :     bool isConvertPageByPage(const std::string& suffix) const;
     112              :     muse::Ret convertPageByPage(project::INotationWriterPtr writer, notation::INotationPtr notation, const muse::io::path_t& out) const;
     113              :     muse::Ret convertPage(project::INotationWriterPtr writer, notation::INotationPtr notation, const size_t pageNum,
     114              :                           const muse::io::path_t& filePath, const muse::io::path_t& dirPath = {}) const;
     115              :     muse::Ret convertFullNotation(project::INotationWriterPtr writer, notation::INotationPtr notation, const muse::io::path_t& out,
     116              :                                   const project::INotationWriter::Options& options = {}) const;
     117              : 
     118              :     muse::Ret writeNotationToFile(project::INotationWriterPtr writer, notation::INotationPtr notation, const muse::io::path_t& filePath,
     119              :                                   const project::INotationWriter::Options& options = {}, const muse::io::path_t& dirPath = {}) const;
     120              : 
     121              :     muse::Ret convertScorePartsToPdf(project::INotationWriterPtr writer, notation::IMasterNotationPtr masterNotation,
     122              :                                      const muse::io::path_t& out) const;
     123              :     muse::Ret convertScorePartsToPngs(project::INotationWriterPtr writer, notation::IMasterNotationPtr masterNotation,
     124              :                                       const muse::io::path_t& out) const;
     125              :     muse::Ret convertScorePartsToMp3(project::INotationWriterPtr writer, notation::IMasterNotationPtr masterNotation,
     126              :                                      const muse::io::path_t& out) const;
     127              : 
     128              :     muse::Ret saveRegion(project::INotationProjectPtr project, const ConvertRegionJson& regionJson, const muse::io::path_t& out) const;
     129              : 
     130              :     muse::Ret writeTracksDiff(project::INotationProjectPtr project, const QJsonArray& oldTracks, const muse::io::path_t& path) const;
     131              : };
     132              : }
        

Generated by: LCOV version 2.0-1