LCOV - code coverage report
Current view: top level - src/engraving/rw/read410 - readcontext.h Coverage Total Hit
Test: filtered_coverage.info Lines: 70.8 % 24 17
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              : #pragma once
      24              : 
      25              : #include <map>
      26              : #include <vector>
      27              : 
      28              : #include "iengravingfontsprovider.h"
      29              : 
      30              : #include "../types/types.h"
      31              : 
      32              : #include "dom/connector.h"
      33              : #include "dom/interval.h"
      34              : #include "dom/location.h"
      35              : 
      36              : #include "../linksindexer.h"
      37              : #include "../inoutdata.h"
      38              : 
      39              : #include "connectorinforeader.h"
      40              : 
      41              : namespace mu::engraving {
      42              : class Beam;
      43              : class DummyParent;
      44              : class EngravingObject;
      45              : class LinkedObjects;
      46              : class Measure;
      47              : class Score;
      48              : class Spanner;
      49              : class Staff;
      50              : class Tuplet;
      51              : class MStyle;
      52              : }
      53              : 
      54              : namespace mu::engraving::read410 {
      55              : struct TextStyleMap {
      56              :     String name;
      57              :     TextStyleType ss;
      58              : };
      59              : 
      60              : class ReadContext
      61              : {
      62              : public:
      63              : 
      64              :     ReadContext() = default;
      65              :     ReadContext(Score* score);
      66              :     ~ReadContext();
      67              : 
      68              :     Score* score() const;
      69              :     void setScore(Score* score);
      70              : 
      71              :     const MStyle& style() const;
      72              :     std::shared_ptr<IEngravingFontsProvider> engravingFonts() const;
      73              : 
      74         4759 :     bool pasteMode() const { return _pasteMode; }
      75            0 :     void setPasteMode(bool v) { _pasteMode = v; }
      76              : 
      77              :     String mscoreVersion() const;
      78              :     int mscVersion() const;
      79              : 
      80              :     int fileDivision() const;
      81              :     int fileDivision(int t) const;
      82              : 
      83              :     double spatium() const;
      84              :     void setSpatium(double v);
      85          186 :     void setPropertiesToSkip(const PropertyIdSet& propertiesToSkip) { m_propertiesToSkip = propertiesToSkip; }
      86          578 :     bool shouldSkipProperty(Pid pid) const { return muse::contains(m_propertiesToSkip, pid); }
      87              : 
      88            0 :     bool forcePageMode() const { return m_forcePageMode; }
      89          186 :     void setForcePageMode(bool v) { m_forcePageMode = v; }
      90              : 
      91              :     DummyParent* dummy() const;
      92              : 
      93              :     Staff* staff(staff_idx_t n);
      94              : 
      95              :     bool isSameScore(const EngravingObject* obj) const;
      96              : 
      97        10993 :     Fraction tick()  const { return _tick + _tickOffset; }
      98              :     Fraction rtick()  const;
      99              :     Fraction tickOffset() const { return _tickOffset; }
     100              :     void setTick(const Fraction& f);
     101              :     void incTick(const Fraction& f);
     102            0 :     void setTickOffset(const Fraction& val) { _tickOffset = val; }
     103              : 
     104         6048 :     track_idx_t track() const { return _track + _trackOffset; }
     105            0 :     void setTrackOffset(int val) { _trackOffset = val; }
     106            0 :     int trackOffset() const { return _trackOffset; }
     107         8187 :     void setTrack(track_idx_t val) { _track = val; }
     108              : 
     109         3474 :     void setCurrentMeasure(Measure* m) { _curMeasure = m; }
     110           31 :     Measure* currentMeasure() const { return _curMeasure; }
     111         1733 :     void setLastMeasure(Measure* m) { _lastMeasure = m; }
     112         1067 :     Measure* lastMeasure() const { return _lastMeasure; }
     113         2037 :     void setCurrentMeasureIndex(int idx) { _curMeasureIdx = idx; }
     114          571 :     int currentMeasureIndex() const { return _curMeasureIdx; }
     115              : 
     116              :     Interval transpose() const { return _transpose; }
     117            0 :     void setTransposeChromatic(int8_t v) { _transpose.chromatic = v; }
     118            0 :     void setTransposeDiatonic(int8_t v) { _transpose.diatonic = v; }
     119              : 
     120           17 :     TracksMap& tracks() { return _tracks; }
     121              : 
     122              :     void addPartAudioSettingCompat(PartAudioSettingsCompat partAudioSetting);
     123          186 :     const SettingsCompat& settingCompat() { return _settingsCompat; }
     124              : 
     125         1052 :     Fraction timeSigForNextMeasure() { return m_timeSigForNextMeasure; }
     126            4 :     void setTimeSigForNextMeasure(Fraction timeSig) { m_timeSigForNextMeasure = timeSig; }
     127              : 
     128              :     Location location(bool forceAbsFrac = false) const;
     129              :     void fillLocation(Location&, bool forceAbsFrac = false) const;
     130              :     void setLocation(const Location&);   // sets a new reading point, taking into account its type (absolute or relative).
     131              : 
     132              :     rw::ReadLinks readLinks() const;
     133              :     void initLinks(const rw::ReadLinks& l);
     134              :     void addLink(Staff* staff, LinkedObjects* link, const Location& location);
     135              :     LinkedObjects* getLink(bool isMasterScore, const Location& location, int localIndexDiff);
     136              : 
     137              :     void addConnectorInfoLater(std::shared_ptr<ConnectorInfoReader> c);   // add connector info to be checked after calling checkConnectors()
     138              :     void checkConnectors();
     139              :     void reconnectBrokenConnectors();
     140              :     void clearOrphanedConnectors();
     141              : 
     142              : private:
     143              :     void addConnectorInfo(std::shared_ptr<ConnectorInfoReader>);
     144              :     void removeConnector(const ConnectorInfoReader*);   // Removes the whole ConnectorInfo chain from the connectors list.
     145              : 
     146              :     Score* m_score = nullptr;
     147              : 
     148              :     bool _pasteMode = false;  // modifies read behaviour on paste operation
     149              :     bool m_forcePageMode = false;
     150              : 
     151              :     std::map<int /*staffIndex*/, std::vector<std::pair<LinkedObjects*, Location> > > m_staffLinkedElements; // one list per staff
     152              :     LinksIndexer m_linksIndexer;
     153              : 
     154              :     std::vector<std::shared_ptr<ConnectorInfoReader> > _connectors;
     155              :     std::vector<std::shared_ptr<ConnectorInfoReader> > _pendingConnectors;  // connectors that are pending to be updated and added to _connectors. That will happen when checkConnectors() is called.
     156              : 
     157              :     Fraction _tick             { Fraction(0, 1) };
     158              :     Fraction _tickOffset       { Fraction(0, 1) };
     159              :     int _intTick = 0;
     160              : 
     161              :     track_idx_t _track = 0;
     162              :     int _trackOffset = 0;
     163              : 
     164              :     Measure* _curMeasure = nullptr;
     165              :     Measure* _lastMeasure = nullptr;
     166              :     int _curMeasureIdx = 0;
     167              : 
     168              :     Interval _transpose;
     169              :     TracksMap _tracks;
     170              : 
     171              :     SettingsCompat _settingsCompat;
     172              : 
     173              :     PropertyIdSet m_propertiesToSkip;
     174              : 
     175              :     Fraction m_timeSigForNextMeasure = Fraction(0, 1);
     176              : };
     177              : }
        

Generated by: LCOV version 2.0-1