LCOV - code coverage report
Current view: top level - src/engraving/compat - writescorehook.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 100.0 % 19 19
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              : #include "writescorehook.h"
      23              : 
      24              : #include "rw/xmlwriter.h"
      25              : 
      26              : #include "dom/masterscore.h"
      27              : #include "dom/excerpt.h"
      28              : 
      29              : #include "rw/write/writer.h"
      30              : 
      31              : using namespace mu::engraving;
      32              : using namespace mu::engraving::compat;
      33              : using namespace mu::engraving::write;
      34              : 
      35         1388 : void WriteScoreHook::onWriteStyle302(Score* score, XmlWriter& xml)
      36              : {
      37         1388 :     bool isWriteStyle = false;
      38              : 
      39              :     //! NOTE If not the master score, because the Excerpts (parts) have not yet been write to separate files
      40         1388 :     if (!score->isMaster()) {
      41          145 :         isWriteStyle = true;
      42              :     }
      43              : 
      44              :     //! NOTE If the test mode, because the tests have not yet been adapted to the new format
      45         1388 :     if (MScore::testMode && MScore::testWriteStyleToScore) {
      46         1096 :         isWriteStyle = true;
      47              :     }
      48              : 
      49         1388 :     if (isWriteStyle) {
      50         1096 :         score->style().save(xml, true);     // save only differences to builtin style (logic from 3.)
      51              :     }
      52         1388 : }
      53              : 
      54         1388 : void WriteScoreHook::onWriteExcerpts302(Score* score, XmlWriter& xml, WriteContext& ctx)
      55              : {
      56         1388 :     bool isWriteExcerpts = false;
      57              : 
      58              :     //! NOTE If the test mode, because the tests have not yet been adapted to the new format
      59         1388 :     if (MScore::testMode) {
      60         1388 :         isWriteExcerpts = true;
      61              :     }
      62              : 
      63         1388 :     if (isWriteExcerpts && score->isMaster() && !ctx.shouldWriteRange()) {
      64         1243 :         MasterScore* mScore = static_cast<MasterScore*>(score);
      65         1382 :         for (const Excerpt* excerpt : mScore->excerpts()) {
      66          139 :             if (excerpt->excerptScore() != score) {
      67          139 :                 write::Writer::write(excerpt->excerptScore(), xml, ctx, *this); // recursion write
      68              :             }
      69              :         }
      70              :     }
      71         1388 : }
        

Generated by: LCOV version 2.0-1