LCOV - code coverage report
Current view: top level - src/engraving/rw/read500 - tread.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 52.6 % 3462 1821
Test Date: 2026-11-19 04:14:36

            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) 2026 MuseScore Limited
       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 "tread.h"
      24              : 
      25              : #include "iengravingconfiguration.h" // IWYU pragma: keep
      26              : 
      27              : #include "../../types/typesconv.h"
      28              : #include "../../types/symnames.h"
      29              : #include "../../infrastructure/rtti.h"
      30              : #include "../../infrastructure/htmlparser.h"
      31              : 
      32              : #include "../../compat/midi/event.h"
      33              : 
      34              : #include "../../dom/accidental.h"
      35              : #include "../../dom/actionicon.h"
      36              : #include "../../dom/ambitus.h"
      37              : #include "../../dom/arpeggio.h"
      38              : #include "../../dom/articulation.h"
      39              : #include "../../dom/bagpembell.h"
      40              : #include "../../dom/barline.h"
      41              : #include "../../dom/beam.h"
      42              : #include "../../dom/bend.h"
      43              : #include "../../dom/box.h"
      44              : #include "../../dom/bracket.h"
      45              : #include "../../dom/breath.h"
      46              : #include "../../dom/capo.h"
      47              : #include "../../dom/chord.h"
      48              : #include "../../dom/chordbracket.h"
      49              : #include "../../dom/chordline.h"
      50              : #include "../../dom/chordlist.h"
      51              : #include "../../dom/clef.h"
      52              : #include "../../dom/drumset.h"
      53              : #include "../../dom/dynamic.h"
      54              : #include "../../dom/excerpt.h"
      55              : #include "../../dom/expression.h"
      56              : #include "../../dom/factory.h"
      57              : #include "../../dom/fermata.h"
      58              : #include "../../dom/figuredbass.h"
      59              : #include "../../dom/fingering.h"
      60              : #include "../../dom/fret.h"
      61              : #include "../../dom/glissando.h"
      62              : #include "../../dom/gradualtempochange.h"
      63              : #include "../../dom/groups.h"
      64              : #include "../../dom/guitarbend.h"
      65              : #include "../../dom/hairpin.h"
      66              : #include "../../dom/hammeronpulloff.h"
      67              : #include "../../dom/harmonicmark.h"
      68              : #include "../../dom/harmony.h"
      69              : #include "../../dom/harppedaldiagram.h"
      70              : #include "../../dom/hook.h"
      71              : #include "../../dom/image.h"
      72              : #include "../../dom/instrchange.h"
      73              : #include "../../dom/instrument.h"
      74              : #include "../../dom/jump.h"
      75              : #include "../../dom/keysig.h"
      76              : #include "../../dom/laissezvib.h"
      77              : #include "../../dom/layoutbreak.h"
      78              : #include "../../dom/ledgerline.h"
      79              : #include "../../dom/letring.h"
      80              : #include "../../dom/line.h"
      81              : #include "../../dom/linkedobjects.h"
      82              : #include "../../dom/lyrics.h"
      83              : #include "../../dom/marker.h"
      84              : #include "../../dom/masterscore.h"
      85              : #include "../../dom/measure.h"
      86              : #include "../../dom/measurenumber.h"
      87              : #include "../../dom/measurerepeat.h"
      88              : #include "../../dom/mmrest.h"
      89              : #include "../../dom/mmrestrange.h"
      90              : #include "../../dom/mscore.h"
      91              : #include "../../dom/note.h"
      92              : #include "../../dom/notedot.h"
      93              : #include "../../dom/noteline.h"
      94              : #include "../../dom/ornament.h"
      95              : #include "../../dom/ottava.h"
      96              : #include "../../dom/page.h"
      97              : #include "../../dom/palmmute.h"
      98              : #include "../../dom/parenthesis.h"
      99              : #include "../../dom/part.h"
     100              : #include "../../dom/partialtie.h"
     101              : #include "../../dom/pedal.h"
     102              : #include "../../dom/playcounttext.h"
     103              : #include "../../dom/playtechannotation.h"
     104              : #include "../../dom/rasgueado.h"
     105              : #include "../../dom/rehearsalmark.h"
     106              : #include "../../dom/rest.h"
     107              : #include "../../dom/score.h"
     108              : #include "../../dom/segment.h"
     109              : #include "../../dom/sharedpart.h"
     110              : #include "../../dom/slur.h"
     111              : #include "../../dom/slurtie.h"
     112              : #include "../../dom/soundflag.h"
     113              : #include "../../dom/spacer.h"
     114              : #include "../../dom/spanner.h"
     115              : #include "../../dom/staff.h"
     116              : #include "../../dom/staffstate.h"
     117              : #include "../../dom/stafftext.h"
     118              : #include "../../dom/stafftextbase.h"
     119              : #include "../../dom/stafftype.h"
     120              : #include "../../dom/stafftypechange.h"
     121              : #include "../../dom/stavesharinglabel.h"
     122              : #include "../../dom/stem.h"
     123              : #include "../../dom/stemslash.h"
     124              : #include "../../dom/sticking.h"
     125              : #include "../../dom/stringtunings.h"
     126              : #include "../../dom/system.h"
     127              : #include "../../dom/systemdivider.h"
     128              : #include "../../dom/systemtext.h"
     129              : #include "../../dom/tapping.h"
     130              : #include "../../dom/tempotext.h"
     131              : #include "../../dom/text.h"
     132              : #include "../../dom/textline.h"
     133              : #include "../../dom/textlinebase.h"
     134              : #include "../../dom/tie.h"
     135              : #include "../../dom/timesig.h"
     136              : #include "../../dom/tremolobar.h"
     137              : #include "../../dom/tremolosinglechord.h"
     138              : #include "../../dom/tremolotwochord.h"
     139              : #include "../../dom/trill.h"
     140              : #include "../../dom/tuplet.h"
     141              : #include "../../dom/vibrato.h"
     142              : #include "../../dom/volta.h"
     143              : #include "../../dom/whammybar.h"
     144              : 
     145              : #include "../../editing/editstaffbrackets.h"
     146              : 
     147              : #include "../xmlreader.h"
     148              : #include "../read206/read206.h"
     149              : #include "../compat/compatutils.h"
     150              : #include "../compat/tremolocompat.h"
     151              : #include "readcontext.h"
     152              : 
     153              : #include "log.h"
     154              : 
     155              : using namespace muse::draw;
     156              : using namespace mu::engraving;
     157              : using namespace mu::engraving::read500;
     158              : 
     159         1515 : void TRead::readItem(EngravingItem* item, XmlReader& xml, ReadContext& ctx)
     160              : {
     161         1515 :     switch (item->type()) {
     162            0 :     case ElementType::ACCIDENTAL: read(item_cast<Accidental*>(item), xml, ctx);
     163            0 :         break;
     164            0 :     case ElementType::ACTION_ICON: read(item_cast<ActionIcon*>(item), xml, ctx);
     165            0 :         break;
     166            0 :     case ElementType::AMBITUS: read(item_cast<Ambitus*>(item), xml, ctx);
     167            0 :         break;
     168            0 :     case ElementType::ARPEGGIO: read(item_cast<Arpeggio*>(item), xml, ctx);
     169            0 :         break;
     170            0 :     case ElementType::CHORD_BRACKET: read(item_cast<ChordBracket*>(item), xml, ctx);
     171            0 :         break;
     172           22 :     case ElementType::ARTICULATION: read(item_cast<Articulation*>(item), xml, ctx);
     173           22 :         break;
     174            0 :     case ElementType::TAPPING: read(item_cast<Tapping*>(item), xml, ctx);
     175            0 :         break;
     176            0 :     case ElementType::BAGPIPE_EMBELLISHMENT: read(item_cast<BagpipeEmbellishment*>(item), xml, ctx);
     177            0 :         break;
     178            0 :     case ElementType::BAR_LINE: read(item_cast<BarLine*>(item), xml, ctx);
     179            0 :         break;
     180            0 :     case ElementType::BEAM: read(item_cast<Beam*>(item), xml, ctx);
     181            0 :         break;
     182            0 :     case ElementType::BEND: read(item_cast<Bend*>(item), xml, ctx);
     183            0 :         break;
     184           13 :     case ElementType::HBOX: read(item_cast<HBox*>(item), xml, ctx);
     185           13 :         break;
     186          204 :     case ElementType::VBOX: read(item_cast<VBox*>(item), xml, ctx);
     187          204 :         break;
     188            0 :     case ElementType::FBOX: read(item_cast<FBox*>(item), xml, ctx);
     189            0 :         break;
     190            1 :     case ElementType::TBOX: read(item_cast<TBox*>(item), xml, ctx);
     191            1 :         break;
     192            0 :     case ElementType::BRACKET: read(item_cast<Bracket*>(item), xml, ctx);
     193            0 :         break;
     194            0 :     case ElementType::BREATH: read(item_cast<Breath*>(item), xml, ctx);
     195            0 :         break;
     196          326 :     case ElementType::CHORD: read(item_cast<Chord*>(item), xml, ctx);
     197          326 :         break;
     198            1 :     case ElementType::CHORDLINE: read(item_cast<ChordLine*>(item), xml, ctx);
     199            1 :         break;
     200            0 :     case ElementType::CLEF: read(item_cast<Clef*>(item), xml, ctx);
     201            0 :         break;
     202            0 :     case ElementType::CAPO: read(item_cast<Capo*>(item), xml, ctx);
     203            0 :         break;
     204           17 :     case ElementType::DYNAMIC: read(item_cast<Dynamic*>(item), xml, ctx);
     205           17 :         break;
     206            0 :     case ElementType::EXPRESSION: read(item_cast<Expression*>(item), xml, ctx);
     207            0 :         break;
     208            1 :     case ElementType::FERMATA: read(item_cast<Fermata*>(item), xml, ctx);
     209            1 :         break;
     210            0 :     case ElementType::FIGURED_BASS: read(item_cast<FiguredBass*>(item), xml, ctx);
     211            0 :         break;
     212            0 :     case ElementType::FINGERING: read(item_cast<Fingering*>(item), xml, ctx);
     213            0 :         break;
     214            0 :     case ElementType::FRET_DIAGRAM: read(item_cast<FretDiagram*>(item), xml, ctx);
     215            0 :         break;
     216            4 :     case ElementType::GLISSANDO: read(item_cast<Glissando*>(item), xml, ctx);
     217            4 :         break;
     218           41 :     case ElementType::GRADUAL_TEMPO_CHANGE: read(item_cast<GradualTempoChange*>(item), xml, ctx);
     219           41 :         break;
     220            4 :     case ElementType::GUITAR_BEND: read(item_cast<GuitarBend*>(item), xml, ctx);
     221            4 :         break;
     222           68 :     case ElementType::HAIRPIN: read(item_cast<Hairpin*>(item), xml, ctx);
     223           68 :         break;
     224            0 :     case ElementType::HAMMER_ON_PULL_OFF: read(item_cast<HammerOnPullOff*>(item), xml, ctx);
     225            0 :         break;
     226            0 :     case ElementType::HARMONY: read(item_cast<Harmony*>(item), xml, ctx);
     227            0 :         break;
     228           30 :     case ElementType::HARMONIC_MARK: read(item_cast<HarmonicMark*>(item), xml, ctx);
     229           30 :         break;
     230            7 :     case ElementType::HARP_DIAGRAM: read(item_cast<HarpPedalDiagram*>(item), xml, ctx);
     231            7 :         break;
     232            0 :     case ElementType::HOOK: read(item_cast<Hook*>(item), xml, ctx);
     233            0 :         break;
     234            0 :     case ElementType::IMAGE: read(item_cast<Image*>(item), xml, ctx);
     235            0 :         break;
     236            6 :     case ElementType::INSTRUMENT_CHANGE: read(item_cast<InstrumentChange*>(item), xml, ctx);
     237            6 :         break;
     238            3 :     case ElementType::JUMP: read(item_cast<Jump*>(item), xml, ctx);
     239            3 :         break;
     240            1 :     case ElementType::KEYSIG: read(item_cast<KeySig*>(item), xml, ctx);
     241            1 :         break;
     242            0 :     case ElementType::LAISSEZ_VIB: read(item_cast<LaissezVib*>(item), xml, ctx);
     243            0 :         break;
     244            0 :     case ElementType::LAYOUT_BREAK: read(item_cast<LayoutBreak*>(item), xml, ctx);
     245            0 :         break;
     246            0 :     case ElementType::LEDGER_LINE: read(item_cast<LedgerLine*>(item), xml, ctx);
     247            0 :         break;
     248           30 :     case ElementType::LET_RING: read(item_cast<LetRing*>(item), xml, ctx);
     249           30 :         break;
     250            2 :     case ElementType::LYRICS: read(item_cast<Lyrics*>(item), xml, ctx);
     251            2 :         break;
     252            1 :     case ElementType::LYRICSLINE: read(item_cast<LyricsLine*>(item), xml, ctx);
     253            1 :         break;
     254            4 :     case ElementType::MARKER: read(item_cast<Marker*>(item), xml, ctx);
     255            4 :         break;
     256            0 :     case ElementType::MEASURE_NUMBER: read(item_cast<MeasureNumber*>(item), xml, ctx);
     257            0 :         break;
     258            0 :     case ElementType::MEASURE_REPEAT: read(item_cast<MeasureRepeat*>(item), xml, ctx);
     259            0 :         break;
     260            0 :     case ElementType::MMREST: read(item_cast<MMRest*>(item), xml, ctx);
     261            0 :         break;
     262            0 :     case ElementType::MMREST_RANGE: read(item_cast<MMRestRange*>(item), xml, ctx);
     263            0 :         break;
     264          205 :     case ElementType::NOTE: read(item_cast<Note*>(item), xml, ctx);
     265          205 :         break;
     266            0 :     case ElementType::NOTEDOT: read(item_cast<NoteDot*>(item), xml, ctx);
     267            0 :         break;
     268            0 :     case ElementType::NOTEHEAD: read(item_cast<NoteHead*>(item), xml, ctx);
     269            0 :         break;
     270            1 :     case ElementType::NOTELINE: read(item_cast<NoteLine*>(item), xml, ctx);
     271            1 :         break;
     272            0 :     case ElementType::PAGE: read(item_cast<Page*>(item), xml, ctx);
     273            0 :         break;
     274           38 :     case ElementType::PALM_MUTE: read(item_cast<PalmMute*>(item), xml, ctx);
     275           38 :         break;
     276            5 :     case ElementType::PARTIAL_LYRICSLINE: read(item_cast<PartialLyricsLine*>(item), xml, ctx);
     277            5 :         break;
     278            0 :     case ElementType::PARTIAL_TIE: read(item_cast<PartialTie*>(item), xml, ctx);
     279            0 :         break;
     280           41 :     case ElementType::PEDAL: read(item_cast<Pedal*>(item), xml, ctx);
     281           41 :         break;
     282            0 :     case ElementType::PLAY_COUNT_TEXT: read(item_cast<PlayCountText*>(item), xml, ctx);
     283            0 :         break;
     284            0 :     case ElementType::PLAYTECH_ANNOTATION: read(item_cast<PlayTechAnnotation*>(item), xml, ctx);
     285            0 :         break;
     286           30 :     case ElementType::RASGUEADO: read(item_cast<Rasgueado*>(item), xml, ctx);
     287           30 :         break;
     288            0 :     case ElementType::REHEARSAL_MARK: read(item_cast<RehearsalMark*>(item), xml, ctx);
     289            0 :         break;
     290          137 :     case ElementType::REST: read(item_cast<Rest*>(item), xml, ctx);
     291          137 :         break;
     292            3 :     case ElementType::ORNAMENT: read(item_cast<Ornament*>(item), xml, ctx);
     293            3 :         break;
     294           41 :     case ElementType::OTTAVA: read(item_cast<Ottava*>(item), xml, ctx);
     295           41 :         break;
     296            0 :     case ElementType::SEGMENT: read(item_cast<Segment*>(item), xml, ctx);
     297            0 :         break;
     298           32 :     case ElementType::SLUR: read(item_cast<Slur*>(item), xml, ctx);
     299           32 :         break;
     300            0 :     case ElementType::SPACER: read(item_cast<Spacer*>(item), xml, ctx);
     301            0 :         break;
     302            0 :     case ElementType::STAFF_STATE: read(item_cast<StaffState*>(item), xml, ctx);
     303            0 :         break;
     304           15 :     case ElementType::STAFF_TEXT: read(item_cast<StaffText*>(item), xml, ctx);
     305           15 :         break;
     306            0 :     case ElementType::STAVE_SHARING_LABEL: read(item_cast<StaveSharingLabel*>(item), xml, ctx);
     307            0 :         break;
     308            0 :     case ElementType::STAFFTYPE_CHANGE: read(item_cast<StaffTypeChange*>(item), xml, ctx);
     309            0 :         break;
     310            0 :     case ElementType::STEM: read(item_cast<Stem*>(item), xml, ctx);
     311            0 :         break;
     312            0 :     case ElementType::STEM_SLASH: read(item_cast<StemSlash*>(item), xml, ctx);
     313            0 :         break;
     314           15 :     case ElementType::STICKING: read(item_cast<Sticking*>(item), xml, ctx);
     315           15 :         break;
     316            0 :     case ElementType::STRING_TUNINGS: read(item_cast<StringTunings*>(item), xml, ctx);
     317            0 :         break;
     318            0 :     case ElementType::SYMBOL: read(item_cast<Symbol*>(item), xml, ctx);
     319            0 :         break;
     320            0 :     case ElementType::SOUND_FLAG: read(item_cast<SoundFlag*>(item), xml, ctx);
     321            0 :         break;
     322            0 :     case ElementType::FSYMBOL: read(item_cast<FSymbol*>(item), xml, ctx);
     323            0 :         break;
     324            0 :     case ElementType::SYSTEM: read(item_cast<System*>(item), xml, ctx);
     325            0 :         break;
     326            0 :     case ElementType::SYSTEM_DIVIDER: read(item_cast<SystemDivider*>(item), xml, ctx);
     327            0 :         break;
     328            1 :     case ElementType::SYSTEM_TEXT: read(item_cast<SystemText*>(item), xml, ctx);
     329            1 :         break;
     330            0 :     case ElementType::TEMPO_TEXT: read(item_cast<TempoText*>(item), xml, ctx);
     331            0 :         break;
     332            0 :     case ElementType::TEXT: read(item_cast<Text*>(item), xml, ctx);
     333            0 :         break;
     334           37 :     case ElementType::TEXTLINE: read(item_cast<TextLine*>(item), xml, ctx);
     335           37 :         break;
     336           34 :     case ElementType::TIE: read(item_cast<Tie*>(item), xml, ctx);
     337           34 :         break;
     338            0 :     case ElementType::TIMESIG: read(item_cast<TimeSig*>(item), xml, ctx);
     339            0 :         break;
     340           17 :     case ElementType::TREMOLO_SINGLECHORD: read(item_cast<TremoloSingleChord*>(item), xml, ctx);
     341           17 :         break;
     342            0 :     case ElementType::TREMOLO_TWOCHORD: read(item_cast<TremoloTwoChord*>(item), xml, ctx);
     343            0 :         break;
     344            0 :     case ElementType::TREMOLOBAR: read(item_cast<TremoloBar*>(item), xml, ctx);
     345            0 :         break;
     346            2 :     case ElementType::TRILL: read(item_cast<Trill*>(item), xml, ctx);
     347            2 :         break;
     348            0 :     case ElementType::TUPLET: read(item_cast<Tuplet*>(item), xml, ctx);
     349            0 :         break;
     350            1 :     case ElementType::VIBRATO: read(item_cast<Vibrato*>(item), xml, ctx);
     351            1 :         break;
     352           43 :     case ElementType::VOLTA: read(item_cast<Volta*>(item), xml, ctx);
     353           43 :         break;
     354           31 :     case ElementType::WHAMMY_BAR: read(item_cast<WhammyBar*>(item), xml, ctx);
     355           31 :         break;
     356            0 :     default:
     357            0 :         UNREACHABLE;
     358              :         LOGE() << "Not implemented read for type: " << item->typeName();
     359              :         break;
     360              :     }
     361         1515 : }
     362              : 
     363         1817 : PropertyValue TRead::readPropertyValue(Pid id, XmlReader& e, ReadContext& ctx)
     364              : {
     365         1817 :     switch (propertyType(id)) {
     366          203 :     case P_TYPE::BOOL:
     367          203 :         return PropertyValue(bool(e.readInt()));
     368          113 :     case P_TYPE::INT:
     369              :     case P_TYPE::SIZE_T:
     370          113 :         return PropertyValue(e.readInt());
     371          123 :     case P_TYPE::REAL:
     372          123 :         return PropertyValue(e.readDouble());
     373          173 :     case P_TYPE::SPATIUM: return PropertyValue(Spatium(e.readDouble()));
     374            0 :     case P_TYPE::ABSOLUTE: return PropertyValue(Spatium(e.readDouble())); //! NOTE type mm, but stored in xml as spatium
     375            0 :     case P_TYPE::TEMPO:
     376            0 :         return PropertyValue(e.readDouble());
     377            0 :     case P_TYPE::FRACTION:
     378            0 :         return PropertyValue::fromValue(e.readFraction());
     379              : 
     380            0 :     case P_TYPE::SYMID:
     381            0 :         return PropertyValue(TConv::fromXml(e.readAsciiText(), SymId::noSym));
     382            1 :     case P_TYPE::COLOR:
     383            1 :         return PropertyValue::fromValue(e.readColor());
     384            0 :     case P_TYPE::ORNAMENT_STYLE:
     385            0 :         return PropertyValue::fromValue(TConv::fromXml(e.readAsciiText(), OrnamentStyle::DEFAULT));
     386            1 :     case P_TYPE::ORNAMENT_INTERVAL:
     387            1 :         return PropertyValue(TConv::fromXml(e.readText(), DEFAULT_ORNAMENT_INTERVAL));
     388            0 :     case P_TYPE::ORNAMENT_SHOW_ACCIDENTAL:
     389            0 :         return OrnamentShowAccidental(e.readInt());
     390          173 :     case P_TYPE::POINT:
     391          173 :         return PropertyValue::fromValue(e.readPoint());
     392            0 :     case P_TYPE::SCALE:
     393            0 :         return PropertyValue::fromValue(e.readScale());
     394            0 :     case P_TYPE::SIZE:
     395            0 :         return PropertyValue::fromValue(e.readSize());
     396           89 :     case P_TYPE::STRING:
     397           89 :         return PropertyValue(e.readText());
     398              : 
     399           30 :     case P_TYPE::ALIGN:
     400           30 :         return PropertyValue(TConv::fromXml(e.readText(), Align()));
     401           30 :     case P_TYPE::ALIGN_H:
     402           30 :         return PropertyValue(TConv::fromXml(e.readAsciiText(), AlignH::HCENTER));
     403           27 :     case P_TYPE::PLACEMENT_V:
     404           27 :         return PropertyValue(TConv::fromXml(e.readAsciiText(), PlacementV::ABOVE));
     405            0 :     case P_TYPE::PLACEMENT_H:
     406            0 :         return PropertyValue(TConv::fromXml(e.readAsciiText(), PlacementH::LEFT));
     407           82 :     case P_TYPE::TEXT_PLACE:
     408           82 :         return PropertyValue(TConv::fromXml(e.readAsciiText(), TextPlace::AUTO));
     409          227 :     case P_TYPE::DIRECTION_V:
     410          227 :         return PropertyValue(TConv::fromXml(e.readAsciiText(), DirectionV::AUTO));
     411            7 :     case P_TYPE::DIRECTION_H:
     412            7 :         return PropertyValue(TConv::fromXml(e.readAsciiText(), DirectionH::AUTO));
     413            0 :     case P_TYPE::ORIENTATION:
     414            0 :         return PropertyValue(TConv::fromXml(e.readAsciiText(), Orientation::VERTICAL));
     415              : 
     416          119 :     case P_TYPE::LAYOUTBREAK_TYPE:
     417          119 :         return PropertyValue(TConv::fromXml(e.readAsciiText(), LayoutBreakType::NOBREAK));
     418            0 :     case P_TYPE::VELO_TYPE:
     419            0 :         return PropertyValue(TConv::fromXml(e.readAsciiText(), VeloType::OFFSET_VAL));
     420            0 :     case P_TYPE::GLISS_STYLE:
     421            0 :         return PropertyValue(TConv::fromXml(e.readAsciiText(), GlissandoStyle::CHROMATIC));
     422            0 :     case P_TYPE::GLISS_TYPE:
     423            0 :         return PropertyValue(TConv::fromXml(e.readAsciiText(), GlissandoType::STRAIGHT));
     424            0 :     case P_TYPE::BARLINE_TYPE:
     425            0 :         return PropertyValue(TConv::fromXml(e.readAsciiText(), BarLineType::NORMAL));
     426              : 
     427          106 :     case P_TYPE::NOTEHEAD_TYPE:
     428          106 :         return PropertyValue(TConv::fromXml(e.readAsciiText(), NoteHeadType::HEAD_AUTO));
     429            3 :     case P_TYPE::NOTEHEAD_SCHEME:
     430            3 :         return PropertyValue(TConv::fromXml(e.readAsciiText(), NoteHeadScheme::HEAD_AUTO));
     431          181 :     case P_TYPE::NOTEHEAD_GROUP:
     432          181 :         return PropertyValue(TConv::fromXml(e.readAsciiText(), NoteHeadGroup::HEAD_NORMAL));
     433              : 
     434            0 :     case P_TYPE::CLEF_TYPE:
     435            0 :         return PropertyValue(TConv::fromXml(e.readAsciiText(), ClefType::G));
     436            0 :     case P_TYPE::CLEF_TO_BARLINE_POS:
     437            0 :         return ClefToBarlinePosition(e.readInt());
     438              : 
     439            0 :     case P_TYPE::DYNAMIC_TYPE:
     440            0 :         return PropertyValue(TConv::fromXml(e.readAsciiText(), DynamicType::OTHER));
     441              : 
     442           10 :     case P_TYPE::LINE_TYPE:
     443           10 :         return PropertyValue(TConv::fromXml(e.readAsciiText(), LineType::SOLID));
     444           69 :     case P_TYPE::HOOK_TYPE:
     445           69 :         return PropertyValue(TConv::fromXml(e.readAsciiText(), HookType::NONE));
     446              : 
     447            0 :     case P_TYPE::KEY_MODE:
     448            0 :         return PropertyValue(TConv::fromXml(e.readAsciiText(), KeyMode::NONE));
     449            0 :     case P_TYPE::KEY:
     450            0 :         return PropertyValue(TConv::fromXml(e.readAsciiText(), Key::C));
     451              : 
     452            0 :     case P_TYPE::JIANPU_NUMBERING:
     453            0 :         return PropertyValue(TConv::fromXml(e.readAsciiText(), JianpuNumbering::FOLLOW_SCORE_KEY));
     454              : 
     455           14 :     case P_TYPE::TEXT_STYLE:
     456           14 :         return PropertyValue(TConv::fromXml(e.readAsciiText(), TextStyleType::DEFAULT));
     457            0 :     case P_TYPE::SLUR_STYLE_TYPE:
     458            0 :         return SlurStyleType(e.readInt());
     459              : 
     460            0 :     case P_TYPE::CHANGE_METHOD:
     461            0 :         return PropertyValue(TConv::fromXml(e.readAsciiText(), ChangeMethod::NORMAL));
     462              : 
     463            0 :     case P_TYPE::BEAM_MODE:
     464            0 :         return PropertyValue(int(0));
     465            0 :     case P_TYPE::GROUPS: {
     466            0 :         Groups g;
     467            0 :         TRead::read(&g, e, ctx);
     468            0 :         return PropertyValue::fromValue(g.nodes());
     469            0 :     }
     470            0 :     case P_TYPE::DURATION_TYPE_WITH_DOTS:
     471              :     case P_TYPE::INT_VEC:
     472            0 :         return PropertyValue(TConv::fromXml(String(e.readText()), std::vector<int>()));
     473              : 
     474            0 :     case P_TYPE::PLAYTECH_TYPE:
     475            0 :         return PropertyValue(TConv::fromXml(e.readAsciiText(), PlayingTechniqueType::Natural));
     476            2 :     case P_TYPE::TEMPOCHANGE_TYPE:
     477            2 :         return PropertyValue(TConv::fromXml(e.readAsciiText(), GradualTempoChangeType::Undefined));
     478            0 :     case P_TYPE::TIE_PLACEMENT:
     479            0 :         return PropertyValue(TConv::fromXml(e.readAsciiText(), TiePlacement::AUTO));
     480            2 :     case P_TYPE::VOICE_ASSIGNMENT:
     481            2 :         return PropertyValue(TConv::fromXml(e.readAsciiText(), VoiceAssignment::ALL_VOICE_IN_INSTRUMENT));
     482            2 :     case P_TYPE::AUTO_ON_OFF:
     483            2 :         return PropertyValue(TConv::fromXml(e.readAsciiText(), AutoOnOff::AUTO));
     484           23 :     case P_TYPE::PARTIAL_SPANNER_DIRECTION:
     485           23 :         return PropertyValue(TConv::fromXml(e.readAsciiText(), PartialSpannerDirection::OUTGOING));
     486            3 :     case P_TYPE::PARENTHESES_MODE:
     487            3 :         return PropertyValue(TConv::fromXml(e.readAsciiText(), ParenthesesMode::NONE));
     488            0 :     case P_TYPE::AUTO_CUSTOM_HIDE:
     489            0 :         return PropertyValue(TConv::fromXml(e.readAsciiText(), AutoCustomHide::AUTO));
     490            4 :     case P_TYPE::MARKER_TYPE:
     491            4 :         return PropertyValue(TConv::fromXml(e.readAsciiText(), MarkerType::USER));
     492            0 :     default:
     493            0 :         ASSERT_X("unhandled PID type");
     494              :         break;
     495              :     }
     496              :     return PropertyValue();
     497              : }
     498              : 
     499       285674 : bool TRead::readProperty(EngravingItem* item, const AsciiStringView& tag, XmlReader& xml, ReadContext& ctx, Pid pid)
     500              : {
     501       285674 :     if (tag == propertyName(pid)) {
     502         1247 :         readProperty(item, xml, ctx, pid);
     503         1247 :         return true;
     504              :     }
     505       284427 :     return false;
     506              : }
     507              : 
     508         1817 : void TRead::readProperty(EngravingItem* item, XmlReader& xml, ReadContext& ctx, Pid pid)
     509              : {
     510         1817 :     double spatium = ctx.score() ? ctx.spatium() : item->spatium();
     511         1817 :     PropertyValue v = readPropertyValue(pid, xml, ctx);
     512         1817 :     switch (propertyType(pid)) {
     513            0 :     case P_TYPE::ABSOLUTE: //! NOTE type mm, but stored in xml as spatium
     514            0 :         v = v.value<Spatium>().toAbsolute(spatium);
     515            0 :         break;
     516          173 :     case P_TYPE::POINT:
     517          173 :         if (item->offsetIsSpatiumDependent()) {
     518          173 :             v = v.value<PointF>() * spatium;
     519              :         } else {
     520            0 :             v = v.value<PointF>() * DPMM;
     521              :         }
     522          173 :         break;
     523         1644 :     default:
     524         1644 :         break;
     525              :     }
     526              : 
     527              :     // Pre-4.4 compatibility: these items now use DIRECTION property
     528         1817 :     if (pid == Pid::PLACEMENT && item->hasVoiceAssignmentProperties()) {
     529            0 :         pid = Pid::DIRECTION;
     530            0 :         v = v.value<PlacementV>() == PlacementV::ABOVE ? PropertyValue(DirectionV::UP) : PropertyValue(DirectionV::DOWN);
     531              :     }
     532              : 
     533         1817 :     if (pid == Pid::OFFSET && ctx.mscVersion() < 500) {
     534            0 :         compat::CompatUtils::migrateOffset500(item, v);
     535              :     }
     536              : 
     537         1817 :     if (!ctx.shouldSkipProperty(pid)) {
     538         1817 :         item->setProperty(pid, v);
     539         1817 :         if (item->isStyled(pid)) {
     540          417 :             item->setPropertyFlags(pid, PropertyFlags::UNSTYLED);
     541              :         }
     542              :     }
     543         1817 : }
     544              : 
     545        32842 : bool TRead::readStyledProperty(EngravingItem* item, const AsciiStringView& tag, XmlReader& xml, ReadContext& ctx)
     546              : {
     547       104686 :     for (const StyledProperty& spp : *item->styledProperties()) {
     548        71950 :         if (readProperty(item, tag, xml, ctx, spp.pid)) {
     549          106 :             return true;
     550              :         }
     551              :     }
     552        32736 :     return false;
     553              : }
     554              : 
     555        30531 : bool TRead::readItemProperties(EngravingItem* item, XmlReader& e, ReadContext& ctx)
     556              : {
     557        30531 :     const AsciiStringView tag(e.name());
     558              : 
     559        30531 :     if (tag == "eid") {
     560        25410 :         readItemEID(item, e, ctx);
     561         5121 :     } else if (TRead::readProperty(item, tag, e, ctx, Pid::SIZE_SPATIUM_DEPENDENT)) {
     562         4949 :     } else if (TRead::readProperty(item, tag, e, ctx, Pid::OFFSET)) {
     563         4915 :     } else if (TRead::readProperty(item, tag, e, ctx, Pid::MIN_DISTANCE)) {
     564         4915 :     } else if (TRead::readProperty(item, tag, e, ctx, Pid::AUTOPLACE)) {
     565         4908 :     } else if (tag == "track") {
     566          622 :         item->setTrack(e.readInt() + ctx.trackOffset());
     567         4286 :     } else if (tag == "color") {
     568           10 :         item->setColor(e.readColor());
     569         4276 :     } else if (tag == "visible") {
     570            1 :         item->setVisible(e.readInt());
     571         4275 :     } else if (tag == "linkedTo") {
     572         4202 :         readItemLink(item, e, ctx);
     573           73 :     } else if (TRead::readProperty(item, tag, e, ctx, Pid::POSITION_LINKED_TO_MASTER)) {
     574           73 :     } else if (TRead::readProperty(item, tag, e, ctx, Pid::APPEARANCE_LINKED_TO_MASTER)) {
     575           73 :     } else if (TRead::readProperty(item, tag, e, ctx, Pid::EXCLUDE_FROM_OTHER_PARTS)) {
     576           73 :     } else if (tag == "voice") {
     577            0 :         item->setVoice(e.readInt());
     578           73 :     } else if (tag == "tag") {
     579            0 :         e.skipCurrentElement();
     580           73 :     } else if (TRead::readProperty(item, tag, e, ctx, Pid::PLACEMENT)) {
     581           59 :     } else if (tag == "z") {
     582            4 :         item->setZ(e.readInt());
     583           55 :     } else if (TRead::readProperty(item, tag, e, ctx, Pid::HAS_PARENTHESES)) {
     584           52 :     } else if (tag == "Parenthesis") {
     585            0 :         Parenthesis* p = Factory::createParenthesis(item);
     586            0 :         TRead::read(p, e, ctx);
     587            0 :         p->setTrack(ctx.track());
     588            0 :         item->add(p);
     589              :     } else {
     590           52 :         return false;
     591              :     }
     592        30479 :     return true;
     593              : }
     594              : 
     595         4714 : static Spanner* tryCreateSpanner(const AsciiStringView& tag, ReadContext& ctx, bool requireNoteAnchor)
     596              : {
     597         4714 :     ElementType type = TConv::fromXml(tag, ElementType::INVALID);
     598         4714 :     if (type == ElementType::INVALID) {
     599         4560 :         return nullptr;
     600              :     }
     601              : 
     602          154 :     EngravingItem* item = Factory::createItem(type, ctx.dummy());
     603          154 :     if (!item || !item->isSpanner()) {
     604            0 :         delete item;
     605            0 :         return nullptr;
     606              :     }
     607              : 
     608          154 :     Spanner* spanner = toSpanner(item);
     609          154 :     if ((spanner->anchor() == Spanner::Anchor::NOTE) != requireNoteAnchor) {
     610            0 :         delete item;
     611            0 :         return nullptr;
     612              :     }
     613              : 
     614          154 :     return spanner;
     615              : }
     616              : 
     617           62 : void TRead::readScoreSpanners(Score* score, XmlReader& e, ReadContext& ctx)
     618              : {
     619          173 :     while (e.readNextStartElement()) {
     620          111 :         const AsciiStringView tag(e.name());
     621          111 :         if (Spanner* spanner = tryCreateSpanner(tag, ctx, /*requireNoteAnchor*/ false)) {
     622          111 :             TRead::readItem(spanner, e, ctx);
     623          111 :             if (ctx.pasteMode()) {
     624           22 :                 score->undoAddElement(spanner);
     625              :             } else {
     626           89 :                 score->addSpanner(spanner);
     627              :             }
     628              :         } else {
     629            0 :             e.unknown();
     630              :         }
     631              :     }
     632           62 : }
     633              : 
     634        26458 : void TRead::readItemEID(EngravingObject* item, XmlReader& xml, ReadContext& ctx)
     635              : {
     636        26458 :     AsciiStringView s = xml.readAsciiText();
     637        26458 :     EID eid = EID::fromStdString(s);
     638        26458 :     IF_ASSERT_FAILED(eid.isValid()) {
     639         1910 :         return;
     640              :     }
     641              : 
     642        26458 :     if (ctx.pasteMode()) {
     643              :         // On pasting we must create new EIDs for the elements, as the serialized EID is the EID of the item which was copied
     644              :         // This could still be in use elsewhere in the score
     645         1910 :         EID realEid = item->assignNewEID();
     646         1910 :         ctx.registerPastedEID(eid, realEid);
     647         1910 :         return;
     648              :     }
     649              : 
     650        24548 :     item->setEID(eid);
     651              : }
     652              : 
     653         4302 : void TRead::readItemLink(EngravingItem* item, XmlReader& xml, ReadContext& ctx)
     654              : {
     655         4302 :     AsciiStringView s = xml.readAsciiText();
     656         4302 :     EID eid = EID::fromStdString(s);
     657         4302 :     DO_ASSERT(eid.isValid());
     658         4302 :     EIDRegister* eidRegister = ctx.score()->masterScore()->eidRegister();
     659         4302 :     EngravingObject* mainElement = eidRegister->itemFromEID(eid);
     660         4302 :     IF_ASSERT_FAILED(mainElement) {
     661            0 :         LOGE() << "Link failed: Main linked element not found for " << item->typeName() << " at " << ctx.tick().toString();
     662            0 :         return;
     663              :     }
     664         4302 :     IF_ASSERT_FAILED(mainElement->type() == item->type()) {
     665            0 :         LOGE() << "Link failed: Main element type (" << mainElement->typeName() << ") does not match linked item type (" <<
     666            0 :             item->typeName() << ") at " << ctx.tick().toString();
     667            0 :         return;
     668              :     }
     669              : 
     670         4302 :     item->linkTo(mainElement);
     671              : }
     672              : 
     673           15 : void TRead::read(TextBase* t, XmlReader& xml, ReadContext& ctx)
     674              : {
     675           75 :     while (xml.readNextStartElement()) {
     676           45 :         if (!readProperties(toTextBase(t), xml, ctx)) {
     677            0 :             xml.unknown();
     678              :         }
     679              :     }
     680           15 : }
     681              : 
     682          148 : void TRead::read(TempoText* t, XmlReader& e, ReadContext& ctx)
     683              : {
     684              :     /// This property was written in the wrong order from 4.6.0-4.6.2
     685              :     /// It was written before the text style and was reset on initialising the text style
     686          148 :     std::optional<double> symbolSize;
     687              : 
     688          687 :     while (e.readNextStartElement()) {
     689          539 :         const AsciiStringView tag(e.name());
     690          539 :         if (readProperty(t, tag, e, ctx, Pid::PLAY)) {
     691          539 :         } else if (tag == "tempo") {
     692          148 :             t->setTempo(TConv::fromXml(e.readAsciiText(), Constants::DEFAULT_TEMPO));
     693          391 :         } else if (tag == "followText") {
     694            3 :             t->setFollowText(e.readInt());
     695          388 :         } else if (tag == "type") {
     696            2 :             auto type = e.readAsciiText();
     697            2 :             if (type == "aTempo") {
     698            1 :                 t->setTempoTextType(TempoTextType::A_TEMPO);
     699            1 :             } else if (type == "tempoPrimo") {
     700            1 :                 t->setTempoTextType(TempoTextType::TEMPO_PRIMO);
     701            0 :             } else if (type == "normal") {
     702            0 :                 t->setTempoTextType(TempoTextType::NORMAL);
     703              :             } else {
     704            0 :                 e.unknown();
     705              :             }
     706          386 :         } else if (tag == "musicSymbolSize") {
     707            0 :             symbolSize = e.readDouble();
     708          386 :         } else if (!readProperties(toTextBase(t), e, ctx)) {
     709            0 :             e.unknown();
     710              :         }
     711              :     }
     712              :     // check sanity
     713          148 :     if (t->xmlText().isEmpty()) {
     714            0 :         t->setXmlText(String(u"<sym>metNoteQuarterUp</sym> = %1").arg(int(lrint(t->tempo().toBPM().val))));
     715            0 :         t->setVisible(false);
     716              :     }
     717              : 
     718          148 :     if (symbolSize.has_value()) {
     719            0 :         t->setProperty(Pid::MUSIC_SYMBOL_SIZE, symbolSize.value());
     720            0 :         if (t->isStyled(Pid::MUSIC_SYMBOL_SIZE)) {
     721            0 :             t->setPropertyFlags(Pid::MUSIC_SYMBOL_SIZE, PropertyFlags::UNSTYLED);
     722              :         }
     723              :     }
     724          148 : }
     725              : 
     726           30 : void TRead::read(StaffText* t, XmlReader& xml, ReadContext& ctx)
     727              : {
     728          112 :     while (xml.readNextStartElement()) {
     729           82 :         const AsciiStringView tag(xml.name());
     730           82 :         if (tag == "SoundFlag") {
     731            0 :             SoundFlag* flag = Factory::createSoundFlag(t);
     732            0 :             read(flag, xml, ctx);
     733            0 :             t->setSoundFlag(flag);
     734           82 :         } else if (!readProperties(static_cast<StaffTextBase*>(t), xml, ctx)) {
     735            0 :             xml.unknown();
     736              :         }
     737              :     }
     738           30 : }
     739              : 
     740            0 : void TRead::read(StaveSharingLabel* t, XmlReader& xml, ReadContext& ctx)
     741              : {
     742            0 :     while (xml.readNextStartElement()) {
     743            0 :         if (!readProperties(static_cast<StaffTextBase*>(t), xml, ctx)) {
     744            0 :             xml.unknown();
     745              :         }
     746              :     }
     747            0 : }
     748              : 
     749            1 : void TRead::read(StaffTextBase* t, XmlReader& xml, ReadContext& ctx)
     750              : {
     751            1 :     t->clear();
     752              : 
     753              :     /// This property was written in the wrong order from 4.6.0-4.6.2
     754              :     /// It was written before the text style and was reset on initialising the text style
     755            1 :     std::optional<double> symbolSize;
     756              : 
     757            5 :     while (xml.readNextStartElement()) {
     758            4 :         const AsciiStringView tag(xml.name());
     759              : 
     760            4 :         if (tag == "musicSymbolSize") {
     761            0 :             symbolSize = xml.readDouble();
     762            4 :         } else if (!readProperties(t, xml, ctx)) {
     763            0 :             xml.unknown();
     764              :         }
     765              :     }
     766              : 
     767            1 :     if (symbolSize.has_value()) {
     768            0 :         t->setProperty(Pid::MUSIC_SYMBOL_SIZE, symbolSize.value());
     769            0 :         if (t->isStyled(Pid::MUSIC_SYMBOL_SIZE)) {
     770            0 :             t->setPropertyFlags(Pid::MUSIC_SYMBOL_SIZE, PropertyFlags::UNSTYLED);
     771              :         }
     772              :     }
     773            1 : }
     774              : 
     775           86 : bool TRead::readProperties(StaffTextBase* t, XmlReader& e, ReadContext& ctx)
     776              : {
     777           86 :     const AsciiStringView tag(e.name());
     778              : 
     779           86 :     if (tag == "MidiAction") {
     780            0 :         int channel = e.intAttribute("channel", 0);
     781            0 :         String name = e.attribute("name");
     782            0 :         bool found = false;
     783            0 :         size_t n = t->channelActions().size();
     784            0 :         for (size_t i = 0; i < n; ++i) {
     785            0 :             ChannelActions* a = &t->channelActions()[i];
     786            0 :             if (a->channel == channel) {
     787            0 :                 a->midiActionNames.append(name);
     788            0 :                 found = true;
     789            0 :                 break;
     790              :             }
     791              :         }
     792            0 :         if (!found) {
     793            0 :             ChannelActions a;
     794            0 :             a.channel = channel;
     795            0 :             a.midiActionNames.append(name);
     796            0 :             t->channelActions().push_back(a);
     797            0 :         }
     798            0 :         e.readNext();
     799           86 :     } else if (tag == "channelSwitch" || tag == "articulationChange") {
     800            0 :         voice_idx_t voice = static_cast<voice_idx_t>(e.intAttribute("voice", -1));
     801            0 :         if (voice < VOICES) {
     802            0 :             t->setChannelName(voice, e.attribute("name"));
     803            0 :         } else if (voice == muse::nidx) {
     804              :             // no voice applies channel to all voices for
     805              :             // compatibility
     806            0 :             for (voice_idx_t i = 0; i < VOICES; ++i) {
     807            0 :                 t->setChannelName(i, e.attribute("name"));
     808              :             }
     809              :         }
     810            0 :         e.readNext();
     811           86 :     } else if (tag == "aeolus") {
     812            0 :         int group = e.intAttribute("group", -1);
     813            0 :         if (group >= 0 && group < 4) {
     814            0 :             t->setAeolusStop(group, e.readInt());
     815              :         } else {
     816            0 :             e.readNext();
     817              :         }
     818            0 :         t->setSetAeolusStops(true);
     819           86 :     } else if (tag == "swing") {
     820            1 :         DurationType swingUnit = TConv::fromXml(e.asciiAttribute("unit"), DurationType::V_INVALID);
     821            1 :         int unit = 0;
     822            1 :         if (swingUnit == DurationType::V_EIGHTH) {
     823            1 :             unit = Constants::DIVISION / 2;
     824            0 :         } else if (swingUnit == DurationType::V_16TH) {
     825            0 :             unit = Constants::DIVISION / 4;
     826            0 :         } else if (swingUnit == DurationType::V_ZERO) {
     827            0 :             unit = 0;
     828              :         }
     829            1 :         int ratio = e.intAttribute("ratio", 60);
     830            1 :         t->setSwing(true);
     831            1 :         t->setSwingParameters(unit, ratio);
     832            1 :         e.readNext();
     833           85 :     } else if (tag == "capo") {
     834            0 :         int fretId = e.intAttribute("fretId", 0);
     835            0 :         t->setCapo(fretId);
     836            0 :         e.readNext();
     837           85 :     } else if (!readProperties(toTextBase(t), e, ctx)) {
     838            0 :         return false;
     839              :     }
     840           86 :     return true;
     841              : }
     842              : 
     843          112 : void TRead::read(Dynamic* d, XmlReader& e, ReadContext& ctx)
     844              : {
     845          310 :     while (e.readNextStartElement()) {
     846          198 :         const AsciiStringView tag = e.name();
     847          198 :         if (tag == "subtype") {
     848          112 :             d->setDynamicType(e.readText());
     849           86 :         } else if (tag == "velocity") {
     850           28 :             d->setVelocity(e.readInt());
     851           58 :         } else if (tag == "veloChange") {
     852            0 :             d->setChangeInVelocity(e.readInt());
     853           58 :         } else if (tag == "veloChangeSpeed") {
     854            0 :             d->setVelChangeSpeed(TConv::fromXml(e.readAsciiText(), DynamicSpeed::NORMAL));
     855           58 :         } else if (tag == "play") {
     856            0 :             d->setPlayDynamic(e.readBool());
     857           58 :         } else if (ctx.mscVersion() < 470 && tag == "dynamicsSize") {
     858            0 :             readProperty(d, e, ctx, Pid::MUSICAL_SYMBOLS_SCALE);
     859           58 :         } else if (readProperty(d, tag, e, ctx, Pid::AVOID_BARLINES)) {
     860           52 :         } else if (readProperty(d, tag, e, ctx, Pid::CENTER_ON_NOTEHEAD)) {
     861           52 :         } else if (readProperty(d, tag, e, ctx, Pid::ANCHOR_TO_END_OF_PREVIOUS)) {
     862           52 :         } else if (!readProperties(toTextBase(d), e, ctx)) {
     863            0 :             e.unknown();
     864              :         }
     865              :     }
     866          112 : }
     867              : 
     868            0 : void TRead::read(Expression* expr, XmlReader& xml, ReadContext& ctx)
     869              : {
     870            0 :     while (xml.readNextStartElement()) {
     871            0 :         const AsciiStringView tag = xml.name();
     872            0 :         if (tag == "snapToDynamics") {
     873            0 :             readProperty(expr, xml, ctx, Pid::SNAP_TO_DYNAMICS);
     874            0 :         } else if (!readProperties(toTextBase(expr), xml, ctx)) {
     875            0 :             xml.unknown();
     876              :         }
     877              :     }
     878            0 : }
     879              : 
     880            0 : void TRead::read(FretDiagram* d, XmlReader& e, ReadContext& ctx)
     881              : {
     882            0 :     while (e.readNextStartElement()) {
     883            0 :         const AsciiStringView tag(e.name());
     884              : 
     885            0 :         if (tag == "fretDiagram") {
     886            0 :             while (e.readNextStartElement()) {
     887            0 :                 const AsciiStringView tag2(e.name());
     888              : 
     889            0 :                 if (tag2 == "string") {
     890            0 :                     int no = e.intAttribute("no");
     891            0 :                     while (e.readNextStartElement()) {
     892            0 :                         const AsciiStringView t(e.name());
     893            0 :                         if (t == "dot") {
     894            0 :                             int fret = e.intAttribute("fret", 0);
     895            0 :                             FretDotType dtype = FretItem::nameToDotType(e.readText());
     896            0 :                             d->setDot(no, fret, true, dtype);
     897            0 :                         } else if (t == "marker") {
     898            0 :                             FretMarkerType mtype = FretItem::nameToMarkerType(e.readText());
     899            0 :                             d->setMarker(no, mtype);
     900            0 :                         } else if (t == "fingering") {
     901            0 :                             e.readText();
     902              :                             /*setFingering(no, e.readInt()); NOTE:JT todo */
     903              :                         } else {
     904            0 :                             e.unknown();
     905              :                         }
     906              :                     }
     907            0 :                 } else if (tag2 == "barre") {
     908            0 :                     int start = e.intAttribute("start", -1);
     909            0 :                     int end = e.intAttribute("end", -1);
     910            0 :                     int fret = e.readInt();
     911              : 
     912            0 :                     d->setBarre(start, end, fret);
     913            0 :                 } else if (!readItemProperties(d, e, ctx)) {
     914            0 :                     e.unknown();
     915              :                 }
     916              :             }
     917            0 :         } else if (tag == "showNut") {
     918            0 :             TRead::readProperty(d, e, ctx, Pid::FRET_NUT);
     919            0 :         } else if (tag == "orientation") {
     920            0 :             TRead::readProperty(d, e, ctx, Pid::ORIENTATION);
     921            0 :         } else if (tag == "strings") {
     922            0 :             TRead::readProperty(d, e, ctx, Pid::FRET_STRINGS);
     923            0 :         } else if (tag == "frets") {
     924            0 :             TRead::readProperty(d, e, ctx, Pid::FRET_FRETS);
     925            0 :         } else if (tag == "fretOffset") {
     926            0 :             TRead::readProperty(d, e, ctx, Pid::FRET_OFFSET);
     927            0 :         } else if (tag == "mag") {
     928            0 :             TRead::readProperty(d, e, ctx, Pid::MAG);
     929            0 :         } else if (tag == "Harmony") {
     930            0 :             Harmony* h = new Harmony(d->score()->dummy());
     931            0 :             read(h, e, ctx);
     932            0 :             if (h->chords().empty()) {
     933              :                 // Invalid harmony
     934            0 :                 delete h;
     935              :             } else {
     936            0 :                 d->add(h);
     937              :             }
     938            0 :         } else if (readProperty(d, tag, e, ctx, Pid::FRET_SHOW_FINGERINGS)) {
     939            0 :         } else if (readProperty(d, tag, e, ctx, Pid::FRET_FINGERING)) {
     940            0 :         } else if (TRead::readProperty(d, tag, e, ctx, Pid::EXCLUDE_VERTICAL_ALIGN)) {
     941            0 :         } else if (!readItemProperties(d, e, ctx)) {
     942            0 :             e.unknown();
     943              :         }
     944              :     }
     945            0 : }
     946              : 
     947            0 : void TRead::read(TremoloBar* b, XmlReader& e, ReadContext& ctx)
     948              : {
     949            0 :     while (e.readNextStartElement()) {
     950            0 :         auto tag = e.name();
     951            0 :         if (tag == "point") {
     952            0 :             PitchValue pv;
     953            0 :             pv.time    = e.intAttribute("time");
     954            0 :             pv.pitch   = e.intAttribute("pitch");
     955            0 :             pv.vibrato = e.intAttribute("vibrato");
     956            0 :             b->points().push_back(pv);
     957            0 :             e.readNext();
     958            0 :         } else if (tag == "mag") {
     959            0 :             b->setUserMag(e.readDouble(0.1, 10.0));
     960            0 :         } else if (TRead::readStyledProperty(b, tag, e, ctx)) {
     961            0 :         } else if (tag == "play") {
     962            0 :             b->setPlay(e.readInt());
     963            0 :         } else if (TRead::readProperty(b, tag, e, ctx, Pid::LINE_WIDTH)) {
     964            0 :         } else if (!readItemProperties(b, e, ctx)) {
     965            0 :             e.unknown();
     966              :         }
     967              :     }
     968            0 : }
     969              : 
     970           15 : void TRead::read(Sticking* s, XmlReader& xml, ReadContext& ctx)
     971              : {
     972           15 :     read(toTextBase(s), xml, ctx);
     973           15 : }
     974              : 
     975            1 : void TRead::read(SystemText* t, XmlReader& xml, ReadContext& ctx)
     976              : {
     977            1 :     read(static_cast<StaffTextBase*>(t), xml, ctx);
     978            1 : }
     979              : 
     980            0 : void TRead::read(PlayCountText* t, XmlReader& xml, ReadContext& ctx)
     981              : {
     982            0 :     while (xml.readNextStartElement()) {
     983            0 :         const AsciiStringView tag(xml.name());
     984              : 
     985            0 :         if (TRead::readProperty(t, tag, xml, ctx, Pid::PLAY_COUNT_TEXT_SETTING)) {
     986            0 :         } else if (TRead::readProperty(t, tag, xml, ctx, Pid::PLAY_COUNT_TEXT)) {
     987            0 :         } else if (!readProperties(toTextBase(t), xml, ctx)) {
     988            0 :             xml.unknown();
     989              :         }
     990              :     }
     991            0 : }
     992              : 
     993            0 : void TRead::read(PlayTechAnnotation* a, XmlReader& xml, ReadContext& ctx)
     994              : {
     995            0 :     while (xml.readNextStartElement()) {
     996            0 :         const AsciiStringView tag(xml.name());
     997              : 
     998            0 :         if (TRead::readProperty(a, tag, xml, ctx, Pid::PLAY_TECH_TYPE)) {
     999            0 :         } else if (TRead::readProperty(a, tag, xml, ctx, Pid::PLAY)) {
    1000            0 :         } else if (!readProperties(toStaffTextBase(a), xml, ctx)) {
    1001            0 :             xml.unknown();
    1002              :         }
    1003              :     }
    1004            0 : }
    1005              : 
    1006            0 : void TRead::read(RehearsalMark* m, XmlReader& xml, ReadContext& ctx)
    1007              : {
    1008            0 :     read(toTextBase(m), xml, ctx);
    1009            0 : }
    1010              : 
    1011          507 : void TRead::read(Instrument* item, XmlReader& e, ReadContext& ctx, Part* part)
    1012              : {
    1013          507 :     bool customDrumset = false;
    1014          507 :     bool readSingleNoteDynamics = false;
    1015              : 
    1016          507 :     item->clearChannels();         // remove default channel
    1017          507 :     item->setId(e.attribute("id"));
    1018         6255 :     while (e.readNextStartElement()) {
    1019         5748 :         const AsciiStringView tag(e.name());
    1020         5748 :         if (tag == "singleNoteDynamics") {
    1021            0 :             item->setSingleNoteDynamics(e.readBool());
    1022            0 :             readSingleNoteDynamics = true;
    1023         5748 :         } else if (!readProperties(item, e, ctx, part, &customDrumset)) {
    1024            0 :             e.unknown();
    1025              :         }
    1026              :     }
    1027              : 
    1028          507 :     item->updateInstrumentId();
    1029              : 
    1030          507 :     if (item->channel().empty()) { // for backward compatibility
    1031            4 :         InstrChannel* fallbackChannel = new InstrChannel;
    1032            4 :         fallbackChannel->setName(String::fromUtf8(InstrChannel::DEFAULT_NAME));
    1033            4 :         fallbackChannel->setProgram(item->recognizeMidiProgram());
    1034            4 :         item->appendChannel(fallbackChannel);
    1035          503 :     } else if (item->channel(0)->program() == -1) {
    1036            6 :         item->channel(0)->setProgram(item->recognizeMidiProgram());
    1037              :     }
    1038              : 
    1039          507 :     if (!readSingleNoteDynamics) {
    1040          507 :         item->setSingleNoteDynamicsFromTemplate();
    1041              :     }
    1042          507 : }
    1043              : 
    1044         5748 : bool TRead::readProperties(Instrument* item, XmlReader& e, ReadContext& ctx, Part* part, bool* customDrumset)
    1045              : {
    1046         5748 :     PartAudioSettingsCompat partAudioSetting;
    1047         5748 :     InstrumentTrackId trackId;
    1048         5748 :     if (part && part->score()) {
    1049        17190 :         trackId = { part->score()->parts().size() + 1, item->id() };//part is not assigned to score, _id field is not correct
    1050              :     }
    1051         5748 :     partAudioSetting.instrumentId = trackId;
    1052              : 
    1053         5748 :     const AsciiStringView tag(e.name());
    1054         5748 :     if (tag == "soundId") {
    1055            0 :         item->setSoundId(e.readText());
    1056         5748 :     } else if (tag == "longName") {
    1057           80 :         item->setLongName(readLegacyStaffName(e)); // Old implementation
    1058         5668 :     } else if (tag == "shortName") {
    1059           70 :         item->setShortName(readLegacyStaffName(e)); // Old implementation
    1060         5598 :     } else if (tag == "InstrumentLabel") {
    1061          400 :         readInstrumentLabel(item->instrumentLabel(), e); // New implementation
    1062         5198 :     } else if (tag == "trackName") {
    1063          507 :         item->setTrackName(e.readText());
    1064         4691 :     } else if (tag == "minPitchA") {
    1065          481 :         item->setMinPitchA(e.readInt());
    1066         4210 :     } else if (tag == "minPitchP") {
    1067          481 :         item->setMinPitchP(e.readInt());
    1068         3729 :     } else if (tag == "maxPitchA") {
    1069          481 :         item->setMaxPitchA(e.readInt());
    1070         3248 :     } else if (tag == "maxPitchP") {
    1071          481 :         item->setMaxPitchP(e.readInt());
    1072         2767 :     } else if (tag == "transposeChromatic") {
    1073            7 :         Interval transpose = item->transpose();
    1074            7 :         transpose.chromatic = e.readInt();
    1075            7 :         item->setTranspose(transpose);
    1076         2760 :     } else if (tag == "transposeDiatonic") {
    1077            7 :         Interval transpose = item->transpose();
    1078            7 :         transpose.diatonic = e.readInt();
    1079            7 :         item->setTranspose(transpose);
    1080         2753 :     } else if (tag == "instrumentId") {
    1081          497 :         item->setMusicXmlId(e.readText());
    1082         2256 :     } else if (tag == "useDrumset") {
    1083            0 :         item->setUseDrumset(e.readInt());
    1084            0 :         if (item->useDrumset()) {
    1085            0 :             item->setDrumset(new Drumset(*smDrumset));
    1086              :         }
    1087         2256 :     } else if (tag == "Drum") {
    1088              :         // if we see one of this tags, a custom drumset will be created
    1089            0 :         if (!item->drumset()) {
    1090            0 :             item->setDrumset(new Drumset(*smDrumset));
    1091              :         }
    1092            0 :         if (!(*customDrumset)) {
    1093            0 :             const_cast<Drumset*>(item->drumset())->clear();
    1094            0 :             *customDrumset = true;
    1095              :         }
    1096            0 :         const_cast<Drumset*>(item->drumset())->loadDrum(e);
    1097         2256 :     } else if (tag == "percussionPanelColumns") {
    1098              :         // if we see one of these tags, a custom drumset will be created
    1099            0 :         if (!item->drumset()) {
    1100            0 :             item->setDrumset(new Drumset(*smDrumset));
    1101              :         }
    1102            0 :         if (!(*customDrumset)) {
    1103            0 :             const_cast<Drumset*>(item->drumset())->clear();
    1104            0 :             *customDrumset = true;
    1105              :         }
    1106            0 :         item->drumset()->setPercussionPanelColumns(e.readInt());
    1107              :     }
    1108              :     // support tag "Tablature" for a while for compatibility with existent 2.0 scores
    1109         2256 :     else if (tag == "Tablature" || tag == "StringData") {
    1110            2 :         StringData sd;
    1111            2 :         read(&sd, e);
    1112            2 :         item->setStringData(sd);
    1113         2256 :     } else if (tag == "MidiAction") {
    1114            0 :         NamedEventList a;
    1115            0 :         read(&a, e);
    1116            0 :         item->addMidiAction(a);
    1117         2254 :     } else if (tag == "Articulation") {
    1118         1716 :         MidiArticulation a;
    1119         1716 :         read(&a, e);
    1120         1716 :         item->addMidiArticulation(a);
    1121         2254 :     } else if (tag == "Channel" || tag == "channel") {
    1122          520 :         InstrChannel* a = new InstrChannel;
    1123          520 :         read(a, e, ctx, part, trackId);
    1124          520 :         item->appendChannel(a);
    1125           18 :     } else if (tag == "clef") {           // sets both transposing and concert clef
    1126           18 :         int idx = e.intAttribute("staff", 1) - 1;
    1127           18 :         ClefType ct = TConv::fromXml(e.readAsciiText(), ClefType::G);
    1128           18 :         item->setClefType(idx, ClefTypeList(ct, ct));
    1129            0 :     } else if (tag == "concertClef") {
    1130            0 :         int idx = e.intAttribute("staff", 1) - 1;
    1131            0 :         item->setClefType(idx, ClefTypeList(TConv::fromXml(e.readAsciiText(), ClefType::G), item->clefType(idx).transposingClef));
    1132            0 :     } else if (tag == "transposingClef") {
    1133            0 :         int idx = e.intAttribute("staff", 1) - 1;
    1134            0 :         item->setClefType(idx, ClefTypeList(item->clefType(idx).concertClef, TConv::fromXml(e.readAsciiText(), ClefType::G)));
    1135            0 :     } else if (tag == "glissandoStyle") {
    1136            0 :         item->setGlissandoStyle(TConv::fromXml(e.readAsciiText(), GlissandoStyle::CHROMATIC));
    1137              :     } else {
    1138            0 :         return false;
    1139              :     }
    1140              : 
    1141         5748 :     return true;
    1142        17208 : }
    1143              : 
    1144          520 : void TRead::read(InstrChannel* item, XmlReader& e, ReadContext& ctx, Part* part, const InstrumentTrackId& instrId)
    1145              : {
    1146          520 :     item->setNotifyAboutChangedEnabled(false);
    1147              : 
    1148              :     // synti = 0;
    1149          520 :     item->setName(e.attribute("name"));
    1150          520 :     if (item->name() == "") {
    1151          503 :         item->setName(String::fromUtf8(InstrChannel::DEFAULT_NAME));
    1152              :     }
    1153              : 
    1154          520 :     int midiPort = -1;
    1155          520 :     int midiChannel = -1;
    1156          520 :     PartAudioSettingsCompat partAudioSetting;
    1157          520 :     partAudioSetting.instrumentId = instrId;
    1158              : 
    1159         1187 :     while (e.readNextStartElement()) {
    1160          667 :         const AsciiStringView tag(e.name());
    1161          667 :         if (tag == "program") {
    1162          511 :             item->setProgram(e.intAttribute("value", -1));
    1163          511 :             if (item->program() == -1) {
    1164            0 :                 item->setProgram(e.readInt());
    1165              :             } else {
    1166          511 :                 e.readNext();
    1167              :             }
    1168          156 :         } else if (tag == "controller") {
    1169           10 :             int value = e.intAttribute("value", 0);
    1170           10 :             int ctrl  = e.intAttribute("ctrl", 0);
    1171           10 :             switch (ctrl) {
    1172            2 :             case CTRL_HBANK:
    1173            2 :                 item->setBank((value << 7) + (item->bank() & 0x7f));
    1174            2 :                 item->setUserBankController(true);
    1175            2 :                 break;
    1176            2 :             case CTRL_LBANK:
    1177            2 :                 item->setBank((item->bank() & ~0x7f) + (value & 0x7f));
    1178            2 :                 item->setUserBankController(true);
    1179            2 :                 break;
    1180            0 :             case CTRL_VOLUME:
    1181            0 :                 item->setVolume(value);
    1182            0 :                 break;
    1183            6 :             case CTRL_PANPOT:
    1184            6 :                 item->setPan(value);
    1185            6 :                 break;
    1186            0 :             case CTRL_CHORUS_SEND:
    1187            0 :                 item->setChorus(value);
    1188            0 :                 break;
    1189            0 :             case CTRL_REVERB_SEND:
    1190            0 :                 item->setReverb(value);
    1191            0 :                 break;
    1192            0 :             default:
    1193              :             {
    1194            0 :                 Event ev(ME_CONTROLLER);
    1195            0 :                 ev.setOntime(-1);
    1196            0 :                 ev.setChannel(0);
    1197            0 :                 ev.setDataA(ctrl);
    1198            0 :                 ev.setDataB(value);
    1199            0 :                 item->addToInit(ev);
    1200            0 :             }
    1201            0 :             break;
    1202              :             }
    1203           10 :             e.readNext();
    1204          146 :         } else if (tag == "Articulation") {
    1205            0 :             MidiArticulation a;
    1206            0 :             read(&a, e);
    1207            0 :             item->articulation.push_back(a);
    1208          146 :         } else if (tag == "MidiAction") {
    1209            0 :             NamedEventList a;
    1210            0 :             read(&a, e);
    1211            0 :             item->midiActions.push_back(a);
    1212          146 :         } else if (tag == "synti") {
    1213           96 :             item->setSynti(e.readText());
    1214           50 :         } else if (tag == "color") {
    1215            0 :             item->setColor(e.readInt());
    1216           50 :         } else if (tag == "mute") {
    1217            0 :             partAudioSetting.mute = e.readInt();
    1218           50 :         } else if (tag == "solo") {
    1219            0 :             partAudioSetting.solo = e.readInt();
    1220           50 :         } else if (tag == "midiPort") {
    1221           25 :             midiPort = e.readInt();
    1222           25 :         } else if (tag == "midiChannel") {
    1223           25 :             midiChannel = e.readInt();
    1224              :         } else {
    1225            0 :             e.unknown();
    1226              :         }
    1227              :     }
    1228              : 
    1229          520 :     item->setMustUpdateInit(true);
    1230              : 
    1231          520 :     ctx.addPartAudioSettingCompat(partAudioSetting);
    1232              : 
    1233          520 :     item->setNotifyAboutChangedEnabled(true);
    1234              : 
    1235          520 :     if ((midiPort != -1 || midiChannel != -1) && part && part->score()->isMaster()) {
    1236           23 :         part->masterScore()->addMidiMapping(item, part, midiPort, midiChannel);
    1237              :     }
    1238          520 : }
    1239              : 
    1240         1716 : void TRead::read(MidiArticulation* item, XmlReader& e)
    1241              : {
    1242         1716 :     item->name = e.attribute("name");
    1243         5148 :     while (e.readNextStartElement()) {
    1244         3432 :         const AsciiStringView tag(e.name());
    1245         3432 :         if (tag == "velocity") {
    1246         1716 :             String text(e.readText());
    1247         1716 :             if (text.endsWith(u"%")) {
    1248            0 :                 text = text.left(text.size() - 1);
    1249              :             }
    1250         1716 :             item->velocity = text.toInt();
    1251         3432 :         } else if (tag == "gateTime") {
    1252         1716 :             String text(e.readText());
    1253         1716 :             if (text.endsWith(u"%")) {
    1254            0 :                 text = text.left(text.size() - 1);
    1255              :             }
    1256         1716 :             item->gateTime = text.toInt();
    1257         1716 :         } else if (tag == "descr") {
    1258            0 :             item->descr = e.readText();
    1259              :         } else {
    1260            0 :             e.unknown();
    1261              :         }
    1262              :     }
    1263         1716 : }
    1264              : 
    1265            0 : void TRead::read(NamedEventList* item, XmlReader& e)
    1266              : {
    1267            0 :     item->name = e.attribute("name");
    1268            0 :     while (e.readNextStartElement()) {
    1269            0 :         const AsciiStringView tag(e.name());
    1270            0 :         if (tag == "program") {
    1271            0 :             MidiCoreEvent ev(ME_CONTROLLER, 0, CTRL_PROGRAM, e.intAttribute("value", 0));
    1272            0 :             item->events.push_back(ev);
    1273            0 :             e.skipCurrentElement();
    1274            0 :         } else if (tag == "controller") {
    1275            0 :             MidiCoreEvent ev;
    1276            0 :             ev.setType(ME_CONTROLLER);
    1277            0 :             ev.setDataA(e.intAttribute("ctrl", 0));
    1278            0 :             ev.setDataB(e.intAttribute("value", 0));
    1279            0 :             item->events.push_back(ev);
    1280            0 :             e.skipCurrentElement();
    1281            0 :         } else if (tag == "descr") {
    1282            0 :             item->descr = e.readText();
    1283              :         } else {
    1284            0 :             e.unknown();
    1285              :         }
    1286              :     }
    1287            0 : }
    1288              : 
    1289            6 : void TRead::read(InstrumentChange* c, XmlReader& e, ReadContext& ctx)
    1290              : {
    1291            6 :     Instrument inst;
    1292           27 :     while (e.readNextStartElement()) {
    1293           21 :         const AsciiStringView tag(e.name());
    1294           21 :         if (tag == "Instrument") {
    1295            6 :             read(&inst, e, ctx, c->part());
    1296           15 :         } else if (tag == "init") {
    1297            6 :             c->setInit(e.readBool());
    1298            9 :         } else if (!readProperties(toTextBase(c), e, ctx)) {
    1299            0 :             e.unknown();
    1300              :         }
    1301              :     }
    1302              : 
    1303            6 :     c->setInstrument(inst);
    1304            6 : }
    1305              : 
    1306            0 : void TRead::read(KeyList* item, XmlReader& e, ReadContext& ctx)
    1307              : {
    1308            0 :     while (e.readNextStartElement()) {
    1309            0 :         if (e.name() == "key") {
    1310              :             Key k;
    1311            0 :             int tick = e.intAttribute("tick", 0);
    1312            0 :             if (e.hasAttribute("custom")) {
    1313            0 :                 k = Key::C;              // ke.setCustomType(e.intAttribute("custom"));
    1314              :             } else {
    1315            0 :                 k = Key(e.intAttribute("idx"));
    1316              :             }
    1317            0 :             KeySigEvent ke;
    1318            0 :             ke.setConcertKey(k);
    1319            0 :             (*item)[ctx.fileDivision(tick)] = ke;
    1320            0 :             e.readNext();
    1321            0 :         } else {
    1322            0 :             e.unknown();
    1323              :         }
    1324              :     }
    1325            0 : }
    1326              : 
    1327          127 : void TRead::read(KeySig* s, XmlReader& e, ReadContext& ctx)
    1328              : {
    1329          127 :     KeySigEvent sig;
    1330          127 :     int subtype = 0;
    1331          127 :     Part* p = s->part();
    1332              : 
    1333          365 :     while (e.readNextStartElement()) {
    1334          238 :         const AsciiStringView tag(e.name());
    1335          238 :         if (tag == "CustDef") {
    1336            0 :             CustDef cd;
    1337            0 :             while (e.readNextStartElement()) {
    1338            0 :                 const AsciiStringView t(e.name());
    1339            0 :                 if (t == "sym") {
    1340            0 :                     AsciiStringView val(e.readAsciiText());
    1341              :                     bool valid;
    1342            0 :                     SymId id = SymId(val.toInt(&valid));
    1343            0 :                     if (!valid) {
    1344            0 :                         id = SymNames::symIdByName(val);
    1345              :                     }
    1346            0 :                     cd.sym = id;
    1347            0 :                 } else if (t == "def") {
    1348            0 :                     cd.degree = e.intAttribute("degree", 0);
    1349            0 :                     cd.octAlt = e.intAttribute("octAlt", 0);
    1350            0 :                     cd.xAlt = Spatium(e.doubleAttribute("xAlt", 0.0));
    1351            0 :                     e.readNext();
    1352            0 :                 } else if (t == "pos") { // for older files
    1353            0 :                     Spatium prevx = 0_sp;
    1354            0 :                     Spatium accidentalGap = ctx.score()->style().styleS(Sid::keysigAccidentalDistance);
    1355            0 :                     double _spatium = s->spatium();
    1356              :                     // count default x position
    1357            0 :                     for (CustDef& cd2 : sig.customKeyDefs()) {
    1358            0 :                         prevx += Spatium::fromAbsolute(s->symWidth(cd2.sym), _spatium) + accidentalGap + cd2.xAlt;
    1359              :                     }
    1360            0 :                     bool flat = std::string(SymNames::nameForSymId(cd.sym).ascii()).find("Flat") != std::string::npos;
    1361              :                     // if x not there, use default step
    1362            0 :                     cd.xAlt = Spatium(e.doubleAttribute("x", prevx.val())) - prevx;
    1363              :                     // if y not there, use middle line
    1364            0 :                     int line = static_cast<int>(e.doubleAttribute("y", 2) * 2);
    1365            0 :                     cd.degree = (3 - line) % 7;
    1366            0 :                     cd.degree += (cd.degree < 0) ? 7 : 0;
    1367            0 :                     line += flat ? -1 : 1; // top point in treble for # is -1 (gis), and for b is 1 (es)
    1368            0 :                     cd.octAlt = static_cast<int>((line - (line >= 0 ? 0 : 6)) / 7);
    1369            0 :                     e.readNext();
    1370              :                 } else {
    1371            0 :                     e.unknown();
    1372              :                 }
    1373              :             }
    1374            0 :             sig.customKeyDefs().push_back(cd);
    1375          238 :         } else if (TRead::readProperty(s, tag, e, ctx, Pid::SHOW_COURTESY)) {
    1376          238 :         } else if (tag == "concertKey") {
    1377          127 :             sig.setConcertKey(Key(e.readInt()));
    1378          111 :         } else if (tag == "actualKey") {
    1379            5 :             sig.setKey(Key(e.readInt()));
    1380          106 :         } else if (tag == "custom") {
    1381            0 :             e.readInt();
    1382            0 :             sig.setCustom(true);
    1383          106 :         } else if (tag == "mode") {
    1384            0 :             sig.setMode(TConv::fromXml(e.readAsciiText(), KeyMode::UNKNOWN));
    1385          106 :         } else if (tag == "jianpuNumbering") {
    1386            1 :             sig.setJianpuNumbering(TConv::fromXml(e.readAsciiText(), JianpuNumbering::FOLLOW_SCORE_KEY));
    1387          105 :         } else if (tag == "jianpuTonicKey") {
    1388            1 :             sig.setJianpuTonicKey(TConv::fromXml(e.readAsciiText(), Key::C));
    1389          104 :         } else if (tag == "jianpuTonicMode") {
    1390            1 :             sig.setJianpuTonicMode(TConv::fromXml(e.readAsciiText(), KeyMode::MAJOR));
    1391          103 :         } else if (tag == "subtype") {
    1392            0 :             subtype = e.readInt();
    1393          103 :         } else if (tag == "forInstrumentChange") {
    1394            5 :             sig.setForInstrumentChange(e.readBool());
    1395           98 :         } else if (TRead::readProperty(s, tag, e, ctx, Pid::IS_COURTESY)) {
    1396           98 :         } else if (!readItemProperties(s, e, ctx)) {
    1397            0 :             e.unknown();
    1398              :         }
    1399              :     }
    1400              :     // for backward compatibility
    1401          127 :     if (!sig.isValid()) {
    1402            0 :         sig.initFromSubtype(subtype);
    1403              :     }
    1404          127 :     if (sig.custom() && sig.customKeyDefs().empty()) {
    1405            0 :         sig.setMode(KeyMode::NONE);
    1406              :     }
    1407              :     // if there are more than 6 accidentals in transposing key, it cannot be PreferSharpFlat::AUTO
    1408          126 :     if (p && !s->concertPitch() && (sig.key() > 6 || sig.key() < -6)
    1409          253 :         && p->preferSharpFlat() == PreferSharpFlat::AUTO && !p->instrument(s->tick())->transpose().isZero()) {
    1410            0 :         p->setPreferSharpFlat(PreferSharpFlat::NONE);
    1411              :     }
    1412              : 
    1413          127 :     s->setKeySigEvent(sig);
    1414          127 : }
    1415              : 
    1416            1 : void TRead::read(LaissezVib* lv, XmlReader& xml, ReadContext& ctx)
    1417              : {
    1418            4 :     while (xml.readNextStartElement()) {
    1419            3 :         const AsciiStringView tag(xml.name());
    1420            3 :         if (TRead::readProperty(lv, tag, xml, ctx, Pid::TIE_PLACEMENT)) {
    1421            3 :         } else if (TRead::readProperty(lv, tag, xml, ctx, Pid::MIN_LENGTH)) {
    1422            3 :         } else if (!readProperties(toSlurTie(lv), xml, ctx)) {
    1423            0 :             xml.unknown();
    1424              :         }
    1425              :     }
    1426            1 : }
    1427              : 
    1428            0 : void TRead::read(StaffState* s, XmlReader& e, ReadContext& ctx)
    1429              : {
    1430            0 :     while (e.readNextStartElement()) {
    1431            0 :         const AsciiStringView tag(e.name());
    1432            0 :         if (tag == "subtype") {
    1433            0 :             s->setStaffStateType(StaffStateType(e.readInt()));
    1434            0 :         } else if (tag == "Instrument") {
    1435            0 :             Instrument i;
    1436            0 :             read(&i, e, ctx, nullptr);
    1437            0 :             s->setInstrument(std::move(i));
    1438            0 :         } else if (!readItemProperties(s, e, ctx)) {
    1439            0 :             e.unknown();
    1440              :         }
    1441              :     }
    1442            0 : }
    1443              : 
    1444            0 : void TRead::read(FiguredBass* b, XmlReader& e, ReadContext& ctx)
    1445              : {
    1446            0 :     String normalizedText;
    1447            0 :     int idx = 0;
    1448            0 :     while (e.readNextStartElement()) {
    1449            0 :         const AsciiStringView tag(e.name());
    1450            0 :         if (tag == "ticks") {
    1451            0 :             b->setTicks(e.readFraction());
    1452            0 :         } else if (tag == "onNote") {
    1453            0 :             b->setOnNote(e.readInt() != 0l);
    1454            0 :         } else if (tag == "FiguredBassItem") {
    1455            0 :             FiguredBassItem* pItem = b->createItem(idx++);
    1456            0 :             pItem->setTrack(b->track());
    1457            0 :             pItem->setOwnershipParent(b);
    1458            0 :             TRead::read(pItem, e, ctx);
    1459            0 :             b->appendItem(pItem);
    1460              :             // add item normalized text
    1461            0 :             if (!normalizedText.isEmpty()) {
    1462            0 :                 normalizedText.append('\n');
    1463              :             }
    1464            0 :             normalizedText.append(pItem->normalizedText());
    1465              :         }
    1466              : //            else if (tag == "style")
    1467              : //                  setStyledPropertyListIdx(e.readElementText());
    1468            0 :         else if (!readProperties(toTextBase(b), e, ctx)) {
    1469            0 :             e.unknown();
    1470              :         }
    1471              :     }
    1472              :     // if items could be parsed set normalized text
    1473            0 :     if (b->items().size() > 0) {
    1474            0 :         b->setXmlText(normalizedText);          // this is the text to show while editing
    1475              :     }
    1476            0 : }
    1477              : 
    1478            0 : void TRead::read(FiguredBassItem* i, XmlReader& e, ReadContext& ctx)
    1479              : {
    1480            0 :     while (e.readNextStartElement()) {
    1481            0 :         const AsciiStringView tag(e.name());
    1482              : 
    1483            0 :         if (tag == "brackets") {
    1484            0 :             i->setParenth1((FiguredBassItem::Parenthesis)e.intAttribute("b0"));
    1485            0 :             i->setParenth2((FiguredBassItem::Parenthesis)e.intAttribute("b1"));
    1486            0 :             i->setParenth3((FiguredBassItem::Parenthesis)e.intAttribute("b2"));
    1487            0 :             i->setParenth4((FiguredBassItem::Parenthesis)e.intAttribute("b3"));
    1488            0 :             i->setParenth5((FiguredBassItem::Parenthesis)e.intAttribute("b4"));
    1489            0 :             e.readNext();
    1490            0 :         } else if (tag == "prefix") {
    1491            0 :             i->setPrefix((FiguredBassItem::Modifier)(e.readInt()));
    1492            0 :         } else if (tag == "digit") {
    1493            0 :             i->setDigit(e.readInt());
    1494            0 :         } else if (tag == "suffix") {
    1495            0 :             i->setSuffix((FiguredBassItem::Modifier)(e.readInt()));
    1496            0 :         } else if (tag == "continuationLine") {
    1497            0 :             i->setContLine((FiguredBassItem::ContLine)(e.readInt()));
    1498            0 :         } else if (!readItemProperties(i, e, ctx)) {
    1499            0 :             e.unknown();
    1500              :         }
    1501              :     }
    1502            0 : }
    1503              : 
    1504            0 : void TRead::read(Excerpt* item, XmlReader& e, ReadContext&)
    1505              : {
    1506            0 :     const std::vector<Part*>& pl = item->masterScore()->parts();
    1507            0 :     std::vector<Part*> parts;
    1508            0 :     while (e.readNextStartElement()) {
    1509            0 :         const AsciiStringView tag = e.name();
    1510            0 :         if (tag == "name" || tag == "title") {
    1511            0 :             item->setName(e.readText().trimmed(), /*saveAndNotify=*/ false);
    1512            0 :         } else if (tag == "part") {
    1513            0 :             size_t partIdx = static_cast<size_t>(e.readInt());
    1514            0 :             if (partIdx >= pl.size()) {
    1515            0 :                 LOGD("Excerpt::read: bad part index");
    1516              :             } else {
    1517            0 :                 parts.push_back(pl.at(partIdx));
    1518              :             }
    1519              :         }
    1520              :     }
    1521            0 :     item->setParts(parts);
    1522            0 : }
    1523              : 
    1524            2 : void TRead::read(Fermata* f, XmlReader& e, ReadContext& ctx)
    1525              : {
    1526            8 :     while (e.readNextStartElement()) {
    1527            4 :         if (!readProperties(f, e, ctx)) {
    1528            0 :             e.unknown();
    1529              :         }
    1530              :     }
    1531            2 : }
    1532              : 
    1533            4 : bool TRead::readProperties(Fermata* f, XmlReader& xml, ReadContext& ctx)
    1534              : {
    1535            4 :     const AsciiStringView tag(xml.name());
    1536              : 
    1537            4 :     if (tag == "subtype") {
    1538            2 :         AsciiStringView s = xml.readAsciiText();
    1539            2 :         SymId id = SymNames::symIdByName(s);
    1540            2 :         f->setSymIdAndTimeStretch(id);
    1541            2 :     } else if (tag == "play") {
    1542            0 :         f->setPlay(xml.readBool());
    1543            2 :     } else if (tag == "timeStretch") {
    1544            0 :         f->setTimeStretch(xml.readDouble());
    1545            2 :     } else if (tag == "offset") {
    1546            0 :         readItemProperties(f, xml, ctx);
    1547            2 :     } else if (readItemProperties(f, xml, ctx)) {
    1548              :     } else {
    1549            0 :         return false;
    1550              :     }
    1551            4 :     return true;
    1552              : }
    1553              : 
    1554            0 : void TRead::read(Image* img, XmlReader& e, ReadContext& ctx)
    1555              : {
    1556            0 :     bool loaded = false;
    1557              : 
    1558            0 :     while (e.readNextStartElement()) {
    1559            0 :         const AsciiStringView tag(e.name());
    1560            0 :         if (tag == "autoScale") {
    1561            0 :             TRead::readProperty(img, e, ctx, Pid::AUTOSCALE);
    1562            0 :         } else if (tag == "size") {
    1563            0 :             TRead::readProperty(img, e, ctx, Pid::SIZE);
    1564            0 :         } else if (tag == "lockAspectRatio") {
    1565            0 :             TRead::readProperty(img, e, ctx, Pid::LOCK_ASPECT_RATIO);
    1566            0 :         } else if (tag == "sizeIsSpatium") {
    1567              :             // setting this using the property Pid::SIZE_IS_SPATIUM breaks, because the
    1568              :             // property setter attempts to maintain a constant size. If we're reading, we
    1569              :             // don't want to do that, because the stored size will be in:
    1570              :             //    absolute if size isn't spatium
    1571              :             //    sp if size is spatium
    1572            0 :             img->setSizeIsSpatium(e.readBool());
    1573            0 :         } else if (tag == "path") {
    1574            0 :             loaded = img->loadFromStore(e.readText().toStdString());
    1575            0 :         } else if (tag == "linkPath") {
    1576            0 :             if (img->configuration()->allowReadingImagesFromOutsideMscz() && !loaded) {
    1577            0 :                 loaded = img->loadFromFile(e.readText());
    1578              :             } else {
    1579            0 :                 e.skipCurrentElement();
    1580              :             }
    1581            0 :         } else if (!TRead::readProperties(img, e, ctx)) {
    1582            0 :             e.unknown();
    1583              :         }
    1584              :     }
    1585              : 
    1586            0 :     compat::CompatUtils::convertPre470ImageSize(img);
    1587            0 : }
    1588              : 
    1589          141 : void TRead::read(Tuplet* t, XmlReader& e, ReadContext& ctx)
    1590              : {
    1591          141 :     Text* number = nullptr;
    1592          141 :     Fraction ratio;
    1593          141 :     TDuration baseLen;
    1594              : 
    1595          826 :     while (e.readNextStartElement()) {
    1596          685 :         const AsciiStringView tag(e.name());
    1597              : 
    1598          685 :         if (TRead::readStyledProperty(t, tag, e, ctx)) {
    1599          641 :         } else if (tag == "bold") { //important that these properties are read after number is created
    1600            0 :             bool val = e.readInt();
    1601            0 :             if (number) {
    1602            0 :                 number->setBold(val);
    1603              :             }
    1604            0 :             if (t->isStyled(Pid::FONT_STYLE)) {
    1605            0 :                 t->setPropertyFlags(Pid::FONT_STYLE, PropertyFlags::UNSTYLED);
    1606              :             }
    1607          641 :         } else if (tag == "italic") {
    1608            0 :             bool val = e.readInt();
    1609            0 :             if (number) {
    1610            0 :                 number->setItalic(val);
    1611              :             }
    1612            0 :             if (t->isStyled(Pid::FONT_STYLE)) {
    1613            0 :                 t->setPropertyFlags(Pid::FONT_STYLE, PropertyFlags::UNSTYLED);
    1614              :             }
    1615          641 :         } else if (tag == "underline") {
    1616            0 :             bool val = e.readInt();
    1617            0 :             if (number) {
    1618            0 :                 number->setUnderline(val);
    1619              :             }
    1620            0 :             if (t->isStyled(Pid::FONT_STYLE)) {
    1621            0 :                 t->setPropertyFlags(Pid::FONT_STYLE, PropertyFlags::UNSTYLED);
    1622              :             }
    1623          641 :         } else if (tag == "strike") {
    1624            0 :             bool val = e.readInt();
    1625            0 :             if (number) {
    1626            0 :                 number->setStrike(val);
    1627              :             }
    1628            0 :             if (t->isStyled(Pid::FONT_STYLE)) {
    1629            0 :                 t->setPropertyFlags(Pid::FONT_STYLE, PropertyFlags::UNSTYLED);
    1630              :             }
    1631          641 :         } else if (tag == "normalNotes") {
    1632          141 :             ratio.setDenominator(e.readInt());
    1633          500 :         } else if (tag == "actualNotes") {
    1634          141 :             ratio.setNumerator(e.readInt());
    1635          359 :         } else if (tag == "p1") {
    1636            0 :             t->setUserPoint1(e.readPoint() * t->style().spatium());
    1637          359 :         } else if (tag == "p2") {
    1638            0 :             t->setUserPoint2(e.readPoint() * t->style().spatium());
    1639          359 :         } else if (tag == "baseNote") {
    1640          141 :             baseLen = TDuration(TConv::fromXml(e.readAsciiText(), DurationType::V_INVALID));
    1641          218 :         } else if (tag == "baseDots") {
    1642            0 :             baseLen.setDots(e.readInt());
    1643          218 :         } else if (tag == "Number") {
    1644          141 :             number = Factory::createText(t, TextStyleType::TUPLET);
    1645          141 :             number->setComposition(true);
    1646          141 :             Tuplet::resetNumberProperty(number);
    1647          141 :             TRead::read(number, e, ctx);
    1648          141 :             number->setVisible(t->visible());         //?? override saved property
    1649          141 :             number->setColor(t->color());
    1650          141 :             number->setTrack(t->track());
    1651              :             // move property flags from _number back to tuplet
    1652          846 :             for (auto p : { Pid::FONT_FACE, Pid::FONT_SIZE, Pid::FONT_STYLE, Pid::ALIGN, Pid::POSITION }) {
    1653          705 :                 t->setPropertyFlags(p, number->propertyFlags(p));
    1654              :             }
    1655           77 :         } else if (!readItemProperties(t, e, ctx)) {
    1656            0 :             e.unknown();
    1657              :         }
    1658              :     }
    1659              : 
    1660          141 :     t->setNumber(number);
    1661          141 :     t->setBaseLen(baseLen);
    1662          141 :     t->setRatio(ratio);
    1663              : 
    1664          141 :     Fraction f =  t->baseLen().fraction() * t->ratio().denominator();
    1665          141 :     t->setTicks(f.reduced());
    1666          141 : }
    1667              : 
    1668          721 : void TRead::read(Beam* b, XmlReader& e, ReadContext& ctx)
    1669              : {
    1670         3037 :     while (e.readNextStartElement()) {
    1671         2316 :         const AsciiStringView tag(e.name());
    1672         2316 :         if (tag == "StemDirection") {
    1673          153 :             TRead::readProperty(b, e, ctx, Pid::STEM_DIRECTION);
    1674         2163 :         } else if (TRead::readStyledProperty(b, tag, e, ctx)) {
    1675         2163 :         } else if (tag == "growLeft") {
    1676            0 :             b->setGrowLeft(e.readDouble());
    1677         2163 :         } else if (tag == "growRight") {
    1678            0 :             b->setGrowRight(e.readDouble());
    1679         2163 :         } else if (tag == "Fragment") {
    1680            0 :             BeamFragment* f = new BeamFragment;
    1681            0 :             int idx = b->directionIdx();
    1682            0 :             b->setUserModified(true);
    1683            0 :             double _spatium = b->spatium();
    1684            0 :             while (e.readNextStartElement()) {
    1685            0 :                 const AsciiStringView tag1(e.name());
    1686            0 :                 if (tag1 == "y1") {
    1687            0 :                     f->py1[idx] = e.readDouble() * _spatium;
    1688            0 :                 } else if (tag1 == "y2") {
    1689            0 :                     f->py2[idx] = e.readDouble() * _spatium;
    1690              :                 } else {
    1691            0 :                     e.unknown();
    1692              :                 }
    1693              :             }
    1694            0 :             b->addBeamFragment(f);
    1695         2163 :         } else if (tag == "l1" || tag == "l2") {      // ignore
    1696         1442 :             e.skipCurrentElement();
    1697          721 :         } else if (readProperty(b, tag, e, ctx, Pid::BEAM_CROSS_STAFF_MOVE)) {
    1698          721 :         } else if (!readItemProperties(b, e, ctx)) {
    1699            0 :             e.unknown();
    1700              :         }
    1701              :     }
    1702          721 : }
    1703              : 
    1704            0 : void TRead::read(Ambitus* a, XmlReader& e, ReadContext& ctx)
    1705              : {
    1706            0 :     while (e.readNextStartElement()) {
    1707            0 :         if (!readProperties(a, e, ctx)) {
    1708            0 :             e.unknown();
    1709              :         }
    1710              :     }
    1711            0 : }
    1712              : 
    1713            0 : bool TRead::readProperties(Ambitus* a, XmlReader& e, ReadContext& ctx)
    1714              : {
    1715            0 :     const AsciiStringView tag(e.name());
    1716            0 :     if (tag == "head") {
    1717            0 :         TRead::readProperty(a, e, ctx, Pid::HEAD_GROUP);
    1718            0 :     } else if (tag == "headType") {
    1719            0 :         TRead::readProperty(a, e, ctx, Pid::HEAD_TYPE);
    1720            0 :     } else if (tag == "mirror") {
    1721            0 :         TRead::readProperty(a, e, ctx, Pid::MIRROR_HEAD);
    1722            0 :     } else if (tag == "hasLine") {
    1723            0 :         a->setHasLine(e.readInt());
    1724            0 :     } else if (tag == "lineWidth") {
    1725            0 :         TRead::readProperty(a, e, ctx, Pid::LINE_WIDTH);
    1726            0 :     } else if (tag == "topPitch") {
    1727            0 :         a->setTopPitch(e.readInt(), false);
    1728            0 :     } else if (tag == "bottomPitch") {
    1729            0 :         a->setBottomPitch(e.readInt(), false);
    1730            0 :     } else if (tag == "topTpc") {
    1731            0 :         a->setTopTpc(e.readInt(), false);
    1732            0 :     } else if (tag == "bottomTpc") {
    1733            0 :         a->setBottomTpc(e.readInt(), false);
    1734            0 :     } else if (tag == "topAccidental") {
    1735            0 :         while (e.readNextStartElement()) {
    1736            0 :             if (e.name() == "Accidental") {
    1737            0 :                 TRead::read(a->topAccidental(), e, ctx);
    1738              :             } else {
    1739            0 :                 e.skipCurrentElement();
    1740              :             }
    1741              :         }
    1742            0 :     } else if (tag == "bottomAccidental") {
    1743            0 :         while (e.readNextStartElement()) {
    1744            0 :             if (e.name() == "Accidental") {
    1745            0 :                 TRead::read(a->bottomAccidental(), e, ctx);
    1746              :             } else {
    1747            0 :                 e.skipCurrentElement();
    1748              :             }
    1749              :         }
    1750            0 :     } else if (readItemProperties(a, e, ctx)) {
    1751              :     } else {
    1752            0 :         return false;
    1753              :     }
    1754            0 :     return true;
    1755              : }
    1756              : 
    1757            9 : void TRead::read(Accidental* a, XmlReader& e, ReadContext& ctx)
    1758              : {
    1759           27 :     while (e.readNextStartElement()) {
    1760           18 :         const AsciiStringView tag(e.name());
    1761           18 :         if (tag == "bracket") {
    1762            0 :             int i = e.readInt();
    1763            0 :             if (i == 0 || i == 1 || i == 2) {
    1764            0 :                 a->setBracket(AccidentalBracket(i));
    1765              :             }
    1766           18 :         } else if (tag == "subtype") {
    1767            9 :             a->setSubtype(e.readAsciiText());
    1768            9 :         } else if (tag == "role") {
    1769            0 :             a->setRole(TConv::fromXml(e.readAsciiText(), AccidentalRole::AUTO));
    1770            9 :         } else if (tag == "small") {
    1771            0 :             a->setSmall(e.readInt());
    1772            9 :         } else if (readProperty(a, tag, e, ctx, Pid::ACCIDENTAL_STACKING_ORDER_OFFSET)) {
    1773            9 :         } else if (readItemProperties(a, e, ctx)) {
    1774              :         } else {
    1775            0 :             e.unknown();
    1776              :         }
    1777              :     }
    1778            9 : }
    1779              : 
    1780            4 : void TRead::read(Marker* m, XmlReader& e, ReadContext& ctx)
    1781              : {
    1782              :     /// This property was written in the wrong order from 4.6.0-4.6.2
    1783              :     /// It was written before the text style and was reset on initialising the text style
    1784            4 :     std::optional<double> symbolSize;
    1785              : 
    1786           24 :     while (e.readNextStartElement()) {
    1787           20 :         const AsciiStringView tag(e.name());
    1788           20 :         if (tag == "label") {
    1789            4 :             AsciiStringView s(e.readAsciiText());
    1790            4 :             m->setLabel(String::fromAscii(s.ascii()));
    1791           16 :         } else if (readProperty(m, tag, e, ctx, Pid::MARKER_TYPE)) {
    1792           12 :         } else if (readProperty(m, tag, e, ctx, Pid::MARKER_CENTER_ON_SYMBOL)) {
    1793           12 :         } else if (tag == "musicSymbolSize") {
    1794            0 :             symbolSize = e.readDouble();
    1795           12 :         } else if (!readProperties(toTextBase(m), e, ctx)) {
    1796            0 :             e.unknown();
    1797              :         }
    1798              :     }
    1799              : 
    1800            4 :     if (symbolSize.has_value()) {
    1801            0 :         m->setProperty(Pid::MUSIC_SYMBOL_SIZE, symbolSize.value());
    1802            0 :         if (m->isStyled(Pid::MUSIC_SYMBOL_SIZE)) {
    1803            0 :             m->setPropertyFlags(Pid::MUSIC_SYMBOL_SIZE, PropertyFlags::UNSTYLED);
    1804              :         }
    1805              :     }
    1806            4 : }
    1807              : 
    1808            3 : void TRead::read(Jump* j, XmlReader& e, ReadContext& ctx)
    1809              : {
    1810           21 :     while (e.readNextStartElement()) {
    1811           18 :         const AsciiStringView tag(e.name());
    1812           18 :         if (tag == "jumpTo") {
    1813            3 :             j->setJumpTo(e.readText());
    1814           15 :         } else if (tag == "playUntil") {
    1815            3 :             j->setPlayUntil(e.readText());
    1816           12 :         } else if (tag == "continueAt") {
    1817            3 :             j->setContinueAt(e.readText());
    1818            9 :         } else if (tag == "playRepeats") {
    1819            0 :             j->setPlayRepeats(e.readBool());
    1820            9 :         } else if (!readProperties(toTextBase(j), e, ctx)) {
    1821            0 :             e.unknown();
    1822              :         }
    1823              :     }
    1824            3 : }
    1825              : 
    1826            0 : void TRead::read(MeasureNumber* n, XmlReader& xml, ReadContext& ctx)
    1827              : {
    1828            0 :     read(static_cast<MeasureNumberBase*>(n), xml, ctx);
    1829            0 : }
    1830              : 
    1831            0 : void TRead::read(MeasureNumberBase* b, XmlReader& xml, ReadContext& ctx)
    1832              : {
    1833            0 :     while (xml.readNextStartElement()) {
    1834            0 :         if (!readProperties(b, xml, ctx)) {
    1835            0 :             xml.unknown();
    1836              :         }
    1837              :     }
    1838            0 : }
    1839              : 
    1840            0 : bool TRead::readProperties(MeasureNumberBase* n, XmlReader& xml, ReadContext& ctx)
    1841              : {
    1842            0 :     if (TRead::readProperty(n, xml.name(), xml, ctx, Pid::HPLACEMENT)) {
    1843            0 :         return true;
    1844              :     } else {
    1845            0 :         return readProperties(toTextBase(n), xml, ctx);
    1846              :     }
    1847              : }
    1848              : 
    1849            0 : void TRead::read(MMRestRange* r, XmlReader& xml, ReadContext& ctx)
    1850              : {
    1851            0 :     read(static_cast<MeasureNumberBase*>(r), xml, ctx);
    1852            0 : }
    1853              : 
    1854            0 : void TRead::read(SystemDivider* d, XmlReader& e, ReadContext& ctx)
    1855              : {
    1856            0 :     SystemDividerType type = e.attribute("type") == "left" ? SystemDividerType::LEFT : SystemDividerType::RIGHT;
    1857            0 :     d->setDividerType(type);
    1858            0 :     TRead::read(static_cast<Symbol*>(d), e, ctx);
    1859            0 : }
    1860              : 
    1861            0 : void TRead::read(ActionIcon* i, XmlReader& e, ReadContext&)
    1862              : {
    1863            0 :     while (e.readNextStartElement()) {
    1864            0 :         const AsciiStringView tag(e.name());
    1865            0 :         if (tag == "action") {
    1866            0 :             i->setActionType(TConv::fromXml(e.readAsciiText(), ActionIconType::UNDEFINED));
    1867              :         } else {
    1868            0 :             e.unknown();
    1869              :         }
    1870              :     }
    1871            0 : }
    1872              : 
    1873            1 : void TRead::read(Arpeggio* a, XmlReader& e, ReadContext& ctx)
    1874              : {
    1875            3 :     while (e.readNextStartElement()) {
    1876            2 :         const AsciiStringView tag(e.name());
    1877            2 :         if (tag == "subtype") {
    1878            1 :             a->setArpeggioType(TConv::fromXml(e.readAsciiText(), ArpeggioType::NORMAL));
    1879            1 :         } else if (!readProperties(a, e, ctx)) {
    1880            0 :             e.unknown();
    1881              :         }
    1882              :     }
    1883            1 : }
    1884              : 
    1885            1 : bool TRead::readProperties(Arpeggio* a, XmlReader& e, ReadContext& ctx)
    1886              : {
    1887            1 :     const AsciiStringView tag(e.name());
    1888            1 :     if (tag == "userLen1") {
    1889            0 :         a->setUserLen1(e.readDouble() * a->spatium());
    1890            1 :     } else if (tag == "userLen2") {
    1891            0 :         a->setUserLen2(e.readDouble() * a->spatium());
    1892            1 :     } else if (tag == "span") {
    1893            0 :         a->setSpan(e.readInt());
    1894            1 :     } else if (tag == "play") {
    1895            0 :         a->setPlayArpeggio(e.readBool());
    1896            1 :     } else if (tag == "timeStretch") {
    1897            0 :         a->setStretch(e.readDouble());
    1898            1 :     } else if (!readItemProperties(a, e, ctx)) {
    1899            0 :         return false;
    1900              :     }
    1901              : 
    1902            1 :     return true;
    1903              : }
    1904              : 
    1905            0 : void TRead::read(ChordBracket* b, XmlReader& e, ReadContext& ctx)
    1906              : {
    1907            0 :     while (e.readNextStartElement()) {
    1908            0 :         const AsciiStringView tag(e.name());
    1909            0 :         if (readProperty(b, tag, e, ctx, Pid::BRACKET_HOOK_LEN)) {
    1910            0 :         } else if (readProperty(b, tag, e, ctx, Pid::BRACKET_HOOK_POS)) {
    1911            0 :         } else if (readProperty(b, tag, e, ctx, Pid::BRACKET_RIGHT_SIDE)) {
    1912            0 :         } else if (!readProperties(b, e, ctx)) {
    1913            0 :             e.unknown();
    1914              :         }
    1915              :     }
    1916            0 : }
    1917              : 
    1918            4 : void TRead::read(Ornament* o, XmlReader& xml, ReadContext& ctx)
    1919              : {
    1920           21 :     while (xml.readNextStartElement()) {
    1921           13 :         if (!readProperties(o, xml, ctx)) {
    1922            0 :             xml.unknown();
    1923              :         }
    1924              :     }
    1925            4 : }
    1926              : 
    1927           13 : bool TRead::readProperties(Ornament* o, XmlReader& xml, ReadContext& ctx)
    1928              : {
    1929           13 :     const AsciiStringView tag(xml.name());
    1930           13 :     if (readProperty(o, tag, xml, ctx, Pid::INTERVAL_ABOVE)) {
    1931           12 :     } else if (readProperty(o, tag, xml, ctx, Pid::INTERVAL_BELOW)) {
    1932           12 :     } else if (readProperty(o, tag, xml, ctx, Pid::ORNAMENT_SHOW_ACCIDENTAL)) {
    1933           12 :     } else if (readProperty(o, tag, xml, ctx, Pid::ORNAMENT_SHOW_CUE_NOTE)) {
    1934           12 :     } else if (readProperty(o, tag, xml, ctx, Pid::START_ON_UPPER_NOTE)) {
    1935           12 :     } else if (readProperties(toArticulation(o), xml, ctx)) {
    1936            1 :     } else if (tag == "Accidental") {
    1937            0 :         Accidental* accidental = Factory::createAccidental(o);
    1938            0 :         TRead::read(accidental, xml, ctx);
    1939            0 :         accidental->setTrack(ctx.track());
    1940            0 :         accidental->placement() == PlacementV::ABOVE ? o->setAccidentalAbove(accidental) : o->setAccidentalBelow(accidental);
    1941            1 :     } else if (tag == "Chord") {
    1942            1 :         Chord* chord = Factory::createChord(ctx.score()->dummy());
    1943            1 :         TRead::read(chord, xml, ctx);
    1944            1 :         chord->setTrack(ctx.track());
    1945            1 :         chord->setIsTrillCueNote(true);
    1946            1 :         o->setCueNoteChord(chord);
    1947            1 :         o->setNoteAbove(chord->notes().front());
    1948            2 :         for (Note* note : chord->notes()) {
    1949            1 :             compat::CompatUtils::doMigrateNoteParens(note);
    1950              :         }
    1951              :     } else {
    1952            0 :         return false;
    1953              :     }
    1954           13 :     return true;
    1955              : }
    1956              : 
    1957           34 : void TRead::read(Articulation* a, XmlReader& xml, ReadContext& ctx)
    1958              : {
    1959          156 :     while (xml.readNextStartElement()) {
    1960           88 :         if (!readProperties(a, xml, ctx)) {
    1961            0 :             xml.unknown();
    1962              :         }
    1963              :     }
    1964           34 : }
    1965              : 
    1966          100 : bool TRead::readProperties(Articulation* a, XmlReader& xml, ReadContext& ctx)
    1967              : {
    1968          100 :     const AsciiStringView tag(xml.name());
    1969              : 
    1970          100 :     if (tag == "subtype") {
    1971           38 :         AsciiStringView s = xml.readAsciiText();
    1972           38 :         ArticulationTextType textType = TConv::fromXml(s, ArticulationTextType::NO_TEXT);
    1973           38 :         if (textType != ArticulationTextType::NO_TEXT) {
    1974            0 :             a->setTextType(textType);
    1975              :         } else {
    1976           38 :             a->setSymId(SymNames::symIdByName(s));
    1977              :         }
    1978           62 :     } else if (tag == "channel") {
    1979            0 :         a->setChannelName(xml.attribute("name"));
    1980            0 :         xml.readNext();
    1981           62 :     } else if (tag == "anchor") {
    1982            0 :         TRead::readProperty(a, tag, xml, ctx, Pid::ARTICULATION_ANCHOR);
    1983           62 :     } else if (tag == "direction") {
    1984            0 :         TRead::readProperty(a, xml, ctx, Pid::DIRECTION);
    1985           62 :     } else if (tag == "ornamentStyle") {
    1986            0 :         TRead::readProperty(a, xml, ctx, Pid::ORNAMENT_STYLE);
    1987           62 :     } else if (tag == "play") {
    1988            0 :         a->setPlayArticulation(xml.readBool());
    1989           62 :     } else if (tag == "offset") {
    1990            0 :         readItemProperties(a, xml, ctx);
    1991           62 :     } else if (readItemProperties(a, xml, ctx)) {
    1992              :     } else {
    1993            1 :         return false;
    1994              :     }
    1995           99 :     return true;
    1996              : }
    1997              : 
    1998            0 : void TRead::read(Tapping* t, XmlReader& xml, ReadContext& ctx)
    1999              : {
    2000            0 :     while (xml.readNextStartElement()) {
    2001            0 :         AsciiStringView tag = xml.name();
    2002            0 :         if (tag == "hand") {
    2003            0 :             t->setHand(TConv::fromXml(xml.readAsciiText(), TappingHand::INVALID));
    2004            0 :         } else if (tag == TConv::toXml(ElementType::TAPPING_HALF_SLUR)) {
    2005            0 :             TappingHalfSlur* tappingHalfSlur = new TappingHalfSlur(t);
    2006            0 :             read(tappingHalfSlur, xml, ctx);
    2007            0 :             if (tappingHalfSlur->isHalfSlurAbove()) {
    2008            0 :                 t->setHalfSlurAbove(tappingHalfSlur);
    2009              :             } else {
    2010            0 :                 t->setHalfSlurBelow(tappingHalfSlur);
    2011              :             }
    2012            0 :         } else if (!readProperties(toArticulation(t), xml, ctx)) {
    2013            0 :             xml.unknown();
    2014              :         }
    2015              :     }
    2016            0 : }
    2017              : 
    2018            0 : void TRead::read(TappingHalfSlur* t, XmlReader& xml, ReadContext& ctx)
    2019              : {
    2020            0 :     while (xml.readNextStartElement()) {
    2021            0 :         if (xml.name() == "isHalfSlurAbove") {
    2022            0 :             t->setIsHalfSlurAbove(xml.readBool());
    2023            0 :         } else if (!readProperties(toSlur(t), xml, ctx)) {
    2024            0 :             xml.unknown();
    2025              :         }
    2026              :     }
    2027            0 : }
    2028              : 
    2029            0 : void TRead::read(BagpipeEmbellishment* b, XmlReader& e, ReadContext&)
    2030              : {
    2031            0 :     while (e.readNextStartElement()) {
    2032            0 :         const AsciiStringView tag(e.name());
    2033            0 :         if (tag == "subtype") {
    2034            0 :             b->setEmbelType(TConv::fromXml(e.readAsciiText(), EmbellishmentType(0)));
    2035              :         } else {
    2036            0 :             e.unknown();
    2037              :         }
    2038              :     }
    2039            0 : }
    2040              : 
    2041           15 : void TRead::read(BarLine* b, XmlReader& e, ReadContext& ctx)
    2042              : {
    2043              :     // initialize span properties with staff values
    2044           15 :     b->resetProperty(Pid::BARLINE_SPAN);
    2045           15 :     b->resetProperty(Pid::BARLINE_SPAN_FROM);
    2046           15 :     b->resetProperty(Pid::BARLINE_SPAN_TO);
    2047              : 
    2048           47 :     while (e.readNextStartElement()) {
    2049           32 :         const AsciiStringView tag(e.name());
    2050           32 :         if (tag == "subtype") {
    2051            8 :             b->setBarLineType(TConv::fromXml(e.readAsciiText(), BarLineType::NORMAL));
    2052           24 :         } else if (tag == "span") {
    2053            2 :             b->setSpanStaff(e.readBool());
    2054           22 :         } else if (tag == "spanFromOffset") {
    2055            2 :             b->setSpanFrom(e.readInt());
    2056           20 :         } else if (tag == "spanToOffset") {
    2057            1 :             b->setSpanTo(e.readInt());
    2058           19 :         } else if (tag == "Articulation") {
    2059            0 :             Articulation* a = Factory::createArticulation(b->score()->dummy());
    2060            0 :             TRead::read(a, e, ctx);
    2061            0 :             b->add(a);
    2062           19 :         } else if (tag == "Symbol") {
    2063            0 :             Symbol* s = Factory::createSymbol(b);
    2064            0 :             s->setTrack(b->track());
    2065            0 :             TRead::read(s, e, ctx);
    2066            0 :             b->add(s);
    2067           19 :         } else if (tag == "Image") {
    2068            0 :             if (MScore::noImages) {
    2069            0 :                 e.skipCurrentElement();
    2070              :             } else {
    2071            0 :                 Image* image = Factory::createImage(b);
    2072            0 :                 image->setTrack(b->track());
    2073            0 :                 TRead::read(image, e, ctx);
    2074            0 :                 b->add(image);
    2075              :             }
    2076           19 :         } else if (!readItemProperties(b, e, ctx)) {
    2077            0 :             e.unknown();
    2078              :         }
    2079              :     }
    2080           15 : }
    2081              : 
    2082            0 : void TRead::read(Bend* b, XmlReader& e, ReadContext& ctx)
    2083              : {
    2084            0 :     while (e.readNextStartElement()) {
    2085            0 :         const AsciiStringView tag(e.name());
    2086              : 
    2087            0 :         if (TRead::readStyledProperty(b, tag, e, ctx)) {
    2088            0 :         } else if (tag == "point") {
    2089            0 :             PitchValue pv;
    2090            0 :             pv.time    = e.intAttribute("time");
    2091            0 :             pv.pitch   = e.intAttribute("pitch");
    2092            0 :             pv.vibrato = e.intAttribute("vibrato");
    2093            0 :             b->addPoint(pv);
    2094            0 :             e.readNext();
    2095            0 :         } else if (tag == "play") {
    2096            0 :             b->setPlayBend(e.readBool());
    2097            0 :         } else if (!readItemProperties(b, e, ctx)) {
    2098            0 :             e.unknown();
    2099              :         }
    2100              :     }
    2101            0 : }
    2102              : 
    2103          204 : void TRead::read(Box* b, XmlReader& e, ReadContext& ctx)
    2104              : {
    2105         1440 :     while (e.readNextStartElement()) {
    2106         1032 :         if (!readProperties(b, e, ctx)) {
    2107            0 :             e.unknown();
    2108              :         }
    2109              :     }
    2110          204 : }
    2111              : 
    2112           13 : void TRead::read(HBox* b, XmlReader& e, ReadContext& ctx)
    2113              : {
    2114           55 :     while (e.readNextStartElement()) {
    2115           29 :         if (!readProperties(b, e, ctx)) {
    2116            0 :             e.unknown();
    2117              :         }
    2118              :     }
    2119           13 : }
    2120              : 
    2121           29 : bool TRead::readProperties(HBox* b, XmlReader& e, ReadContext& ctx)
    2122              : {
    2123           29 :     const AsciiStringView tag(e.name());
    2124           29 :     if (readProperty(b, tag, e, ctx, Pid::CREATE_SYSTEM_HEADER)) {
    2125           29 :     } else if (readProperties(static_cast<Box*>(b), e, ctx)) {
    2126              :     } else {
    2127            0 :         return false;
    2128              :     }
    2129           29 :     return true;
    2130              : }
    2131              : 
    2132          204 : void TRead::read(VBox* b, XmlReader& xml, ReadContext& ctx)
    2133              : {
    2134          204 :     TRead::read(static_cast<Box*>(b), xml, ctx);
    2135          204 : }
    2136              : 
    2137            0 : void TRead::read(FBox* b, XmlReader& xml, ReadContext& ctx)
    2138              : {
    2139            0 :     while (xml.readNextStartElement()) {
    2140            0 :         const AsciiStringView tag(xml.name());
    2141            0 :         if (readProperty(b, tag, xml, ctx, Pid::FRET_FRAME_TEXT_SCALE)) {
    2142            0 :         } else if (readProperty(b, tag, xml, ctx, Pid::FRET_FRAME_DIAGRAM_SCALE)) {
    2143            0 :         } else if (readProperty(b, tag, xml, ctx, Pid::FRET_FRAME_COLUMN_GAP)) {
    2144            0 :         } else if (readProperty(b, tag, xml, ctx, Pid::FRET_FRAME_ROW_GAP)) {
    2145            0 :         } else if (readProperty(b, tag, xml, ctx, Pid::FRET_FRAME_CHORDS_PER_ROW)) {
    2146            0 :         } else if (readProperty(b, tag, xml, ctx, Pid::FRET_FRAME_H_ALIGN)) {
    2147            0 :         } else if (TRead::readProperties(static_cast<Box*>(b), xml, ctx)) {
    2148              :         } else {
    2149            0 :             xml.unknown();
    2150              :         }
    2151              :     }
    2152            0 : }
    2153              : 
    2154            1 : void TRead::read(TBox* b, XmlReader& e, ReadContext& ctx)
    2155              : {
    2156            3 :     while (e.readNextStartElement()) {
    2157            2 :         const AsciiStringView tag(e.name());
    2158            2 :         if (tag == "Text") {
    2159            1 :             TRead::read(b->text(), e, ctx);
    2160            1 :         } else if (TRead::readProperties(static_cast<Box*>(b), e, ctx)) {
    2161              :         } else {
    2162            0 :             e.unknown();
    2163              :         }
    2164              :     }
    2165            1 : }
    2166              : 
    2167            0 : bool TRead::readBoxProperties(Box* b, XmlReader& e, ReadContext& ctx)
    2168              : {
    2169            0 :     if (b->isHBox()) {
    2170            0 :         return readProperties(dynamic_cast<HBox*>(b), e, ctx);
    2171              :     }
    2172            0 :     return readProperties(b, e, ctx);
    2173              : }
    2174              : 
    2175         1062 : bool TRead::readProperties(Box* b, XmlReader& e, ReadContext& ctx)
    2176              : {
    2177         1062 :     const AsciiStringView tag(e.name());
    2178         1062 :     if (tag == "height") {
    2179          204 :         b->setBoxHeight(Spatium(e.readDouble()));
    2180          858 :     } else if (tag == "width") {
    2181           13 :         b->setBoxWidth(Spatium(e.readDouble()));
    2182          845 :     } else if (tag == "topGap") {
    2183            0 :         b->setTopGap(Spatium(e.readDouble()));
    2184            0 :         b->setPropertyFlags(Pid::TOP_GAP, PropertyFlags::UNSTYLED);
    2185          845 :     } else if (tag == "bottomGap") {
    2186            0 :         b->setBottomGap(Spatium(e.readDouble()));
    2187            0 :         b->setPropertyFlags(Pid::BOTTOM_GAP, PropertyFlags::UNSTYLED);
    2188          845 :     } else if (tag == "leftMargin") {
    2189            0 :         b->setLeftMargin(e.readDouble());
    2190          845 :     } else if (tag == "rightMargin") {
    2191            0 :         b->setRightMargin(e.readDouble());
    2192          845 :     } else if (tag == "topMargin") {
    2193            0 :         b->setTopMargin(e.readDouble());
    2194          845 :     } else if (tag == "bottomMargin") {
    2195            0 :         b->setBottomMargin(e.readDouble());
    2196          845 :     } else if (tag == "boxAutoSize") {
    2197           11 :         b->setAutoSizeEnabled(e.readBool());
    2198          834 :     } else if (tag == "Text") {
    2199              :         Text* t;
    2200          344 :         if (b->isTBox()) {
    2201            0 :             t = toTBox(b)->text();
    2202            0 :             TRead::read(t, e, ctx);
    2203              :         } else {
    2204          344 :             t = Factory::createText(b);
    2205          344 :             TRead::read(t, e, ctx);
    2206          344 :             if (t->empty()) {
    2207            0 :                 LOGD("read empty text");
    2208              :             } else {
    2209          344 :                 b->add(t);
    2210              :             }
    2211              :         }
    2212          490 :     } else if (tag == "Symbol") {
    2213            0 :         Symbol* s = new Symbol(b);
    2214            0 :         TRead::read(s, e, ctx);
    2215            0 :         b->add(s);
    2216          490 :     } else if (tag == "Image") {
    2217            0 :         if (MScore::noImages) {
    2218            0 :             e.skipCurrentElement();
    2219              :         } else {
    2220            0 :             Image* image = new Image(b);
    2221            0 :             image->setTrack(ctx.track());
    2222            0 :             TRead::read(image, e, ctx);
    2223            0 :             b->add(image);
    2224              :         }
    2225          490 :     } else if (tag == "FretDiagram") {
    2226            0 :         FretDiagram* f = Factory::createFretDiagram(b->score()->dummy());
    2227            0 :         TRead::read(f, e, ctx);
    2228              :         //! TODO Looks like a bug.
    2229              :         //! The FretDiagram parent must be Segment
    2230              :         //! there is a method: `Segment* segment() const { return toSegment(parent()); }`,
    2231              :         //! but when we add it to Box, the parent will be rewritten.
    2232            0 :         b->add(f);
    2233          490 :     } else if (tag == "HBox") {
    2234              :         // m_parent is used here (rather than system()) because explicit parent isn't set for this object
    2235              :         // until it is fully read. m_parent is nonetheless valid and using it here matches MU3 behavior.
    2236              :         // If we do not set the parent of this new box correctly, it will cause a crash on read()
    2237              :         // because it needs access to the system it is being added to. (c.r. issue #14643)
    2238            0 :         if (b->parent() && b->parent()->isSystem()) {
    2239            0 :             HBox* hb = new HBox(b->score());
    2240            0 :             TRead::read(hb, e, ctx);
    2241              :             //! TODO Looks like a bug.
    2242              :             //! The HBox parent must be System
    2243              :             //! there is a method: `System* system() const { return (System*)parent(); }`,
    2244              :             //! but when we add it to Box, the parent will be rewritten.
    2245            0 :             b->add(hb);
    2246              :         }
    2247          490 :     } else if (tag == "VBox") {
    2248            0 :         if (b->parent() && b->parent()->isSystem()) {
    2249            0 :             VBox* vb = new VBox(b->score());
    2250            0 :             TRead::read(vb, e, ctx);
    2251              :             //! TODO Looks like a bug.
    2252              :             //! The VBox parent must be System
    2253              :             //! there is a method: `System* system() const { return (System*)parent(); }`,
    2254              :             //! but when we add it to Box, the parent will be rewritten.
    2255            0 :             b->add(vb);
    2256              :         }
    2257          490 :     } else if (TRead::readProperty(b, tag, e, ctx, Pid::PADDING_TO_NOTATION_ABOVE)) {
    2258          489 :     } else if (TRead::readProperty(b, tag, e, ctx, Pid::PADDING_TO_NOTATION_BELOW)) {
    2259          488 :     } else if (TRead::readProperties(static_cast<MeasureBase*>(b), e, ctx)) {
    2260              :     } else {
    2261            0 :         return false;
    2262              :     }
    2263         1062 :     return true;
    2264              : }
    2265              : 
    2266         6597 : bool TRead::readProperties(MeasureBase* b, XmlReader& e, ReadContext& ctx)
    2267              : {
    2268         6597 :     const AsciiStringView tag(e.name());
    2269         6597 :     if (tag == "LayoutBreak") {
    2270          119 :         LayoutBreak* lb = Factory::createLayoutBreak(b);
    2271          119 :         TRead::read(lb, e, ctx);
    2272          119 :         lb->setTrack(0);
    2273          119 :         bool doAdd = true;
    2274          119 :         switch (lb->layoutBreakType()) {
    2275           95 :         case LayoutBreakType::LINE:
    2276           95 :             if (b->lineBreak()) {
    2277            0 :                 doAdd = false;
    2278              :             }
    2279           95 :             break;
    2280            0 :         case LayoutBreakType::PAGE:
    2281            0 :             if (b->pageBreak()) {
    2282            0 :                 doAdd = false;
    2283              :             }
    2284            0 :             break;
    2285            0 :         case LayoutBreakType::SECTION:
    2286            0 :             if (b->sectionBreak()) {
    2287            0 :                 doAdd = false;
    2288              :             }
    2289            0 :             break;
    2290           24 :         case LayoutBreakType::NOBREAK:
    2291           24 :             if (b->noBreak()) {
    2292            0 :                 doAdd = false;
    2293              :             }
    2294           24 :             break;
    2295              :         }
    2296          119 :         if (doAdd) {
    2297          119 :             b->add(lb);
    2298          119 :             b->cleanupLayoutBreaks(false);
    2299              :         }
    2300         6478 :     } else if (tag == "StaffTypeChange") {
    2301            0 :         StaffTypeChange* stc = Factory::createStaffTypeChange(b);
    2302            0 :         stc->setTrack(ctx.track());
    2303            0 :         TRead::read(stc, e, ctx);
    2304            0 :         b->add(stc);
    2305         6478 :     } else if (readItemProperties(b, e, ctx)) {
    2306              :     } else {
    2307            0 :         return false;
    2308              :     }
    2309         6597 :     return true;
    2310              : }
    2311              : 
    2312            0 : void TRead::read(Bracket* b, XmlReader& e, ReadContext& ctx)
    2313              : {
    2314            0 :     BracketItem* bi = Factory::createBracketItem(b->score()->dummy());
    2315            0 :     bi->setBracketType(TConv::fromXml(e.asciiAttribute("type"), BracketType::NORMAL));
    2316              : 
    2317            0 :     while (e.readNextStartElement()) {
    2318            0 :         if (e.name() == "level") {
    2319            0 :             bi->setColumn(e.readInt());
    2320            0 :         } else if (!readItemProperties(b, e, ctx)) {
    2321            0 :             e.unknown();
    2322              :         }
    2323              :     }
    2324              : 
    2325            0 :     b->setBracketItem(bi);
    2326            0 : }
    2327              : 
    2328           11 : void TRead::read(Breath* b, XmlReader& e, ReadContext& ctx)
    2329              : {
    2330           37 :     while (e.readNextStartElement()) {
    2331           26 :         const AsciiStringView tag(e.name());
    2332           26 :         if (tag == "symbol") {
    2333           11 :             b->setSymId(SymNames::symIdByName(e.readAsciiText()));
    2334           15 :         } else if (tag == "pause") {
    2335            1 :             b->setPause(e.readDouble());
    2336           14 :         } else if (!readItemProperties(b, e, ctx)) {
    2337            0 :             e.unknown();
    2338              :         }
    2339              :     }
    2340           11 : }
    2341              : 
    2342           10 : bool TRead::readProperties(BSymbol* sym, XmlReader& e, ReadContext& ctx)
    2343              : {
    2344           10 :     const AsciiStringView tag = e.name();
    2345              : 
    2346           10 :     if (readItemProperties(sym, e, ctx)) {
    2347           10 :         return true;
    2348            0 :     } else if (tag == "systemFlag") {
    2349            0 :         sym->setSystemFlag(e.readInt());
    2350            0 :     } else if (tag == "Symbol") {
    2351            0 :         Symbol* s = Factory::createSymbol(sym);
    2352            0 :         TRead::read(s, e, ctx);
    2353            0 :         sym->add(s);
    2354            0 :     } else if (tag == "FSymbol") {
    2355            0 :         FSymbol* s = Factory::createFSymbol(sym);
    2356            0 :         TRead::read(s, e, ctx);
    2357            0 :         sym->add(s);
    2358            0 :     } else if (tag == "Image") {
    2359            0 :         if (MScore::noImages) {
    2360            0 :             e.skipCurrentElement();
    2361              :         } else {
    2362            0 :             Image* image = new Image(sym);
    2363            0 :             TRead::read(image, e, ctx);
    2364            0 :             sym->add(image);
    2365              :         }
    2366              :     } else {
    2367            0 :         return false;
    2368              :     }
    2369            0 :     return true;
    2370              : }
    2371              : 
    2372            7 : void TRead::read(Symbol* sym, XmlReader& e, ReadContext& ctx)
    2373              : {
    2374            7 :     SymId symId = SymId::noSym;
    2375            7 :     String fontName;
    2376           24 :     while (e.readNextStartElement()) {
    2377           17 :         const AsciiStringView tag(e.name());
    2378           17 :         if (tag == "name") {
    2379            7 :             String val(e.readText());
    2380            7 :             symId = SymNames::symIdByName(val);
    2381            7 :             if (val != "noSym" && symId == SymId::noSym) {
    2382              :                 // if symbol name not found, fall back to user names
    2383              :                 // TODO: does it make sense? user names are probably localized
    2384            0 :                 symId = SymNames::symIdByUserName(val);
    2385            0 :                 if (symId == SymId::noSym) {
    2386            0 :                     LOGD("unknown symbol <%s>, falling back to no symbol", muPrintable(val));
    2387              :                     // set a default symbol, or layout() will crash
    2388            0 :                     symId = SymId::noSym;
    2389              :                 }
    2390              :             }
    2391            7 :             sym->setSym(symId);
    2392           17 :         } else if (tag == "font") {
    2393            0 :             readProperty(sym, e, ctx, Pid::SCORE_FONT);
    2394           10 :         } else if (readProperty(sym, tag, e, ctx, Pid::SCORE_FONT)) {
    2395           10 :         } else if (readProperty(sym, tag, e, ctx, Pid::SYMBOLS_SIZE)) {
    2396           10 :         } else if (readProperty(sym, tag, e, ctx, Pid::SYMBOL_ANGLE)) {
    2397           10 :         } else if (tag == "Symbol") {
    2398            0 :             Symbol* s = new Symbol(sym);
    2399            0 :             TRead::read(s, e, ctx);
    2400            0 :             sym->add(s);
    2401           10 :         } else if (tag == "Image") {
    2402            0 :             if (MScore::noImages) {
    2403            0 :                 e.skipCurrentElement();
    2404              :             } else {
    2405            0 :                 Image* image = new Image(sym);
    2406            0 :                 TRead::read(image, e, ctx);
    2407            0 :                 sym->add(image);
    2408              :             }
    2409           10 :         } else if (!TRead::readProperties(static_cast<BSymbol*>(sym), e, ctx)) {
    2410            0 :             e.unknown();
    2411              :         }
    2412              :     }
    2413              : 
    2414            7 :     sym->setPos(PointF());
    2415            7 : }
    2416              : 
    2417            0 : void TRead::read(SoundFlag* item, XmlReader& xml, ReadContext&)
    2418              : {
    2419            0 :     while (xml.readNextStartElement()) {
    2420            0 :         const AsciiStringView tag(xml.name());
    2421              : 
    2422            0 :         if (tag == "play") {
    2423            0 :             item->setPlay(xml.readBool());
    2424            0 :         } else if (tag == "presets") {
    2425            0 :             item->setSoundPresets(xml.readText().split(u","));
    2426            0 :         } else if (tag == "playingTechnique") {
    2427            0 :             item->setPlayingTechnique(xml.readText());
    2428            0 :         } else if (tag == "applyToAllStaves") {
    2429            0 :             item->setApplyToAllStaves(xml.readBool());
    2430              :         } else {
    2431            0 :             xml.unknown();
    2432              :         }
    2433              :     }
    2434            0 : }
    2435              : 
    2436            0 : void TRead::read(FSymbol* sym, XmlReader& e, ReadContext& ctx)
    2437              : {
    2438            0 :     Font font = sym->font();
    2439            0 :     while (e.readNextStartElement()) {
    2440            0 :         const AsciiStringView tag(e.name());
    2441            0 :         if (tag == "font") {
    2442            0 :             font.setFamily(e.readText(), Font::Type::Unknown);
    2443            0 :         } else if (tag == "fontsize") {
    2444            0 :             font.setPointSizeF(e.readDouble());
    2445            0 :         } else if (tag == "code") {
    2446            0 :             sym->setCode(e.readInt());
    2447            0 :         } else if (!TRead::readProperties(static_cast<BSymbol*>(sym), e, ctx)) {
    2448            0 :             e.unknown();
    2449              :         }
    2450              :     }
    2451              : 
    2452            0 :     sym->setPos(PointF());
    2453            0 :     sym->setFont(font);
    2454            0 : }
    2455              : 
    2456         5089 : void TRead::read(Chord* ch, XmlReader& e, ReadContext& ctx)
    2457              : {
    2458        25050 :     while (e.readNextStartElement()) {
    2459        14872 :         if (TRead::readProperties(ch, e, ctx)) {
    2460              :         } else {
    2461            0 :             e.unknown();
    2462              :         }
    2463              :     }
    2464         5089 : }
    2465              : 
    2466        14872 : bool TRead::readProperties(Chord* ch, XmlReader& e, ReadContext& ctx)
    2467              : {
    2468        14872 :     const AsciiStringView tag(e.name());
    2469              : 
    2470        14872 :     if (tag == "Note") {
    2471         5379 :         Note* note = Factory::createNote(ch);
    2472              :         // the note needs to know the properties of the track it belongs to
    2473         5379 :         note->setTrack(ch->track());
    2474         5379 :         TRead::read(note, e, ctx);
    2475         5379 :         ch->add(note);
    2476         9493 :     } else if (TRead::readProperties(toChordRest(ch), e, ctx)) {
    2477           45 :     } else if (tag == "Stem") {
    2478            0 :         Stem* s = Factory::createStem(ch);
    2479            0 :         TRead::read(s, e, ctx);
    2480            0 :         ch->add(s);
    2481           45 :     } else if (tag == "Hook") {
    2482            0 :         Hook* hook = new Hook(ch);
    2483            0 :         TRead::read(hook, e, ctx);
    2484            0 :         ch->setHook(hook);
    2485            0 :         ch->add(hook);
    2486           45 :     } else if (tag == "appoggiatura") {
    2487            3 :         ch->setNoteType(NoteType::APPOGGIATURA);
    2488            3 :         e.readNext();
    2489           42 :     } else if (tag == "acciaccatura") {
    2490            4 :         ch->setNoteType(NoteType::ACCIACCATURA);
    2491            4 :         e.readNext();
    2492           38 :     } else if (tag == "grace4") {
    2493            0 :         ch->setNoteType(NoteType::GRACE4);
    2494            0 :         e.readNext();
    2495           38 :     } else if (tag == "grace16") {
    2496            0 :         ch->setNoteType(NoteType::GRACE16);
    2497            0 :         e.readNext();
    2498           38 :     } else if (tag == "grace32") {
    2499            1 :         ch->setNoteType(NoteType::GRACE32);
    2500            1 :         e.readNext();
    2501           37 :     } else if (tag == "grace8after") {
    2502            0 :         ch->setNoteType(NoteType::GRACE8_AFTER);
    2503            0 :         e.readNext();
    2504           37 :     } else if (tag == "grace16after") {
    2505            0 :         ch->setNoteType(NoteType::GRACE16_AFTER);
    2506            0 :         e.readNext();
    2507           37 :     } else if (tag == "grace32after") {
    2508            0 :         ch->setNoteType(NoteType::GRACE32_AFTER);
    2509            0 :         e.readNext();
    2510           37 :     } else if (tag == "StemSlash") {
    2511            0 :         StemSlash* ss = Factory::createStemSlash(ch);
    2512            0 :         TRead::read(ss, e, ctx);
    2513            0 :         ch->add(ss);
    2514           37 :     } else if (TRead::readProperty(ch, tag, e, ctx, Pid::STEM_DIRECTION)) {
    2515           19 :     } else if (tag == "noStem") {
    2516            2 :         ch->setNoStem(e.readInt());
    2517           17 :     } else if (tag == "showStemSlash") {
    2518            0 :         ch->setShowStemSlash(e.readBool());
    2519           17 :     } else if (tag == "Arpeggio") {
    2520            1 :         Arpeggio* arpeggio = Factory::createArpeggio(ch);
    2521            1 :         arpeggio->setTrack(ch->track());
    2522            1 :         TRead::read(arpeggio, e, ctx);
    2523            1 :         ch->setArpeggio(arpeggio);
    2524           16 :     } else if (tag == "ChordBracket") {
    2525            0 :         ChordBracket* bracket = Factory::createChordBracket(ch);
    2526            0 :         bracket->setTrack(ch->track());
    2527            0 :         TRead::read(bracket, e, ctx);
    2528            0 :         ch->add(bracket);
    2529           16 :     } else if (tag == "Tremolo") { // compat
    2530            0 :         compat::TremoloCompat tcompat { ch };
    2531            0 :         TRead::read(&tcompat, e, ctx);
    2532            0 :         if (tcompat.two) {
    2533            0 :             tcompat.two->setOwnershipParent(ch);
    2534            0 :             tcompat.two->setDurationType(ch->durationType());
    2535            0 :             ch->setTremoloTwoChord(tcompat.two, false);
    2536            0 :         } else if (tcompat.single) {
    2537            0 :             tcompat.single->setOwnershipParent(ch);
    2538            0 :             tcompat.single->setDurationType(ch->durationType());
    2539            0 :             ch->setTremoloSingleChord(tcompat.single);
    2540              :         } else {
    2541            0 :             UNREACHABLE;
    2542              :         }
    2543           16 :     } else if (tag == "TremoloSingleChord") {
    2544            1 :         TremoloSingleChord* trem = Factory::createTremoloSingleChord(ch);
    2545            1 :         trem->setTrack(ch->track());
    2546            1 :         TRead::read(trem, e, ctx);
    2547            1 :         trem->setDurationType(ch->durationType());
    2548            1 :         ch->setTremoloSingleChord(trem);
    2549           15 :     } else if (tag == "TremoloTwoChord") {
    2550            3 :         TremoloTwoChord* trem = Factory::createTremoloTwoChord(ch);
    2551            3 :         trem->setTrack(ch->track());
    2552            3 :         TRead::read(trem, e, ctx);
    2553            3 :         trem->setDurationType(ch->durationType());
    2554            3 :         ch->setTremoloTwoChord(trem, false);
    2555           12 :     } else if (tag == "ChordLine") {
    2556            9 :         ChordLine* cl = Factory::createChordLine(ch);
    2557            9 :         TRead::read(cl, e, ctx);
    2558            9 :         ch->add(cl);
    2559            3 :     } else if (tag == "combineVoice") {
    2560            0 :         readProperty(ch, tag, e, ctx, Pid::COMBINE_VOICE);
    2561            3 :     } else if (tag == "NoteParenGroup") {
    2562            3 :         readNoteParenGroup(ch, e, ctx);
    2563              :     } else {
    2564            0 :         return false;
    2565              :     }
    2566              : 
    2567        14872 :     if (!ch->visible()) {
    2568              :         // By convention, the chord can't be set to invisible (only its elements can).
    2569              :         // If it was written and read as invisible that was an error so we fix it here.
    2570            0 :         ch->setVisible(true);
    2571              :     }
    2572              : 
    2573        14872 :     return true;
    2574              : }
    2575              : 
    2576        37286 : bool TRead::readProperties(ChordRest* ch, XmlReader& e, ReadContext& ctx)
    2577              : {
    2578        37286 :     const AsciiStringView tag(e.name());
    2579              : 
    2580        37286 :     if (tag == "durationType") {
    2581        13682 :         ch->setDurationType(TConv::fromXml(e.readAsciiText(), DurationType::V_QUARTER));
    2582        13682 :         if (ch->actualDurationType().type() != DurationType::V_MEASURE) {
    2583         5943 :             ch->setTicks(ch->actualDurationType().fraction());
    2584              :         }
    2585        23604 :     } else if (tag == "BeamMode") {
    2586          187 :         ch->setBeamMode(TConv::fromXml(e.readAsciiText(), BeamMode::AUTO));
    2587        23417 :     } else if (tag == "Articulation") {
    2588           12 :         Articulation* atr = Factory::createArticulation(ch);
    2589           12 :         atr->setTrack(ch->track());
    2590           12 :         TRead::read(atr, e, ctx);
    2591           12 :         ch->add(atr);
    2592        23405 :     } else if (tag == "Ornament") {
    2593            0 :         Ornament* ornament = Factory::createOrnament(ch);
    2594            0 :         ornament->setTrack(ch->track());
    2595            0 :         TRead::read(ornament, e, ctx);
    2596            0 :         ch->add(ornament);
    2597        23405 :     } else if (tag == "Tapping") {
    2598            0 :         Tapping* tapping = Factory::createTapping(ch);
    2599            0 :         tapping->setTrack(ch->track());
    2600            0 :         TRead::read(tapping, e, ctx);
    2601            0 :         ch->add(tapping);
    2602        23405 :     } else if (tag == "small") {
    2603            1 :         ch->setSmall(e.readInt());
    2604        23404 :     } else if (tag == "duration") {
    2605         7745 :         ch->setTicks(e.readFraction());
    2606        15659 :     } else if (tag == "dots") {
    2607           26 :         ch->setDots(e.readInt());
    2608        15633 :     } else if (tag == "staffMove") {
    2609            1 :         ch->setStaffMove(e.readInt());
    2610            1 :         ch->checkStaffMoveValidity();
    2611        15632 :     } else if (tag == "Lyrics") {
    2612           81 :         Lyrics* lyr = Factory::createLyrics(ch);
    2613           81 :         lyr->setTrack(ctx.track());
    2614           81 :         TRead::read(lyr, e, ctx);
    2615           81 :         ch->add(lyr);
    2616        15551 :     } else if (tag == "pos") {
    2617            0 :         PointF pt = e.readPoint();
    2618            0 :         ch->setOffset(pt * ch->spatium());
    2619        15551 :     } else if (!readItemProperties(ch, e, ctx)) {
    2620           45 :         return false;
    2621              :     }
    2622        37241 :     return true;
    2623              : }
    2624              : 
    2625           11 : void TRead::read(ChordLine* l, XmlReader& e, ReadContext& ctx)
    2626              : {
    2627           38 :     while (e.readNextStartElement()) {
    2628           27 :         const AsciiStringView tag(e.name());
    2629           27 :         if (tag == "Path") {
    2630            0 :             compat::CompatUtils::readChordLinePath(l, e);
    2631           27 :         } else if (tag == "subtype") {
    2632           11 :             l->setChordLineType(TConv::fromXml(e.readAsciiText(), ChordLineType::NOTYPE));
    2633           16 :         } else if (tag == "straight") {
    2634            0 :             l->setStraight(e.readInt());
    2635           16 :         } else if (tag == "wavy") {
    2636            0 :             l->setWavy(e.readInt());
    2637           16 :         } else if (tag == "lengthX" || tag == "lengthY") { // obsolete
    2638            0 :             e.skipCurrentElement();
    2639           16 :         } else if (readProperty(l, tag, e, ctx, Pid::BEZIER_OFFSET1)) {
    2640           16 :         } else if (readProperty(l, tag, e, ctx, Pid::BEZIER_OFFSET2)) {
    2641           15 :         } else if (readProperty(l, tag, e, ctx, Pid::BEZIER_OFFSET3)) {
    2642           15 :         } else if (readProperty(l, tag, e, ctx, Pid::BEZIER_OFFSET4)) {
    2643           14 :         } else if (tag == "play") {
    2644            0 :             l->setPlayChordLine(e.readBool());
    2645           14 :         } else if (!readItemProperties(l, e, ctx)) {
    2646            0 :             e.unknown();
    2647              :         }
    2648              :     }
    2649           11 : }
    2650              : 
    2651          236 : void TRead::read(Clef* c, XmlReader& e, ReadContext& ctx, bool* isHeader)
    2652              : {
    2653         1272 :     while (e.readNextStartElement()) {
    2654         1036 :         const AsciiStringView tag(e.name());
    2655         1036 :         if (tag == "concertClefType") {
    2656          236 :             c->setConcertClef(TConv::fromXml(e.readAsciiText(), ClefType::G));
    2657          800 :         } else if (tag == "transposingClefType") {
    2658          236 :             c->setTransposingClef(TConv::fromXml(e.readAsciiText(), ClefType::G));
    2659          564 :         } else if (tag == "showCourtesyClef") {
    2660            0 :             c->setShowCourtesy(e.readInt());
    2661          564 :         } else if (tag == "forInstrumentChange") {
    2662            0 :             c->setForInstrumentChange(e.readBool());
    2663          564 :         } else if (tag == "clefToBarlinePos") {
    2664            0 :             c->setClefToBarlinePosition(ClefToBarlinePosition(e.readInt()));
    2665          564 :         } else if (tag == "isHeader") {
    2666          232 :             const bool header = e.readBool();
    2667          232 :             if (isHeader) {
    2668          232 :                 *isHeader = header;
    2669              :             }
    2670          332 :         } else if (!readItemProperties(c, e, ctx)) {
    2671            0 :             e.unknown();
    2672              :         }
    2673              :     }
    2674              : 
    2675          236 :     if (c->clefType() == ClefType::INVALID) {
    2676            0 :         c->setClefType(ClefType::G);
    2677              :     }
    2678          236 : }
    2679              : 
    2680            0 : void TRead::read(Capo* c, XmlReader& xml, ReadContext& ctx)
    2681              : {
    2682            0 :     CapoParams params = c->params();
    2683              : 
    2684            0 :     while (xml.readNextStartElement()) {
    2685            0 :         const AsciiStringView tag(xml.name());
    2686              : 
    2687            0 :         if (tag == "active") {
    2688            0 :             params.active = xml.readBool();
    2689            0 :         } else if (tag == "fretPosition") {
    2690            0 :             params.fretPosition = xml.readInt();
    2691            0 :         } else if (tag == "string") {
    2692            0 :             string_idx_t idx = static_cast<string_idx_t>(xml.intAttribute("no"));
    2693              : 
    2694            0 :             while (xml.readNextStartElement()) {
    2695            0 :                 const AsciiStringView stringTag(xml.name());
    2696              : 
    2697            0 :                 if (stringTag == "apply") {
    2698            0 :                     bool apply = xml.readBool();
    2699            0 :                     if (!apply) {
    2700            0 :                         params.ignoredStrings.insert(idx);
    2701              :                     }
    2702              :                 } else {
    2703            0 :                     xml.unknown();
    2704              :                 }
    2705              :             }
    2706            0 :         } else if (tag == "generateText") {
    2707            0 :             c->setProperty(Pid::CAPO_GENERATE_TEXT, xml.readBool());
    2708            0 :         } else if (TRead::readProperty(c, tag, xml, ctx, Pid::CAPO_TRANSPOSE_MODE)) {
    2709            0 :             continue;
    2710            0 :         } else if (!readProperties(static_cast<StaffTextBase*>(c), xml, ctx)) {
    2711            0 :             xml.unknown();
    2712              :         }
    2713              :     }
    2714            0 :     params.transposeMode = c->params().transposeMode;
    2715              : 
    2716            0 :     c->setParams(params);
    2717            0 : }
    2718              : 
    2719            0 : bool TRead::readProperties(Clef* c, XmlReader& xml, ReadContext& ctx)
    2720              : {
    2721            0 :     return readItemProperties(c, xml, ctx);
    2722              : }
    2723              : 
    2724           10 : void TRead::read(Fingering* f, XmlReader& e, ReadContext& ctx)
    2725              : {
    2726           53 :     while (e.readNextStartElement()) {
    2727           33 :         if (!readProperties(toTextBase(f), e, ctx)) {
    2728            0 :             e.unknown();
    2729              :         }
    2730              :     }
    2731           10 : }
    2732              : 
    2733            4 : void TRead::read(Glissando* g, XmlReader& e, ReadContext& ctx)
    2734              : {
    2735            4 :     g->eraseSpannerSegments();
    2736              : 
    2737            4 :     staff_idx_t staffIdx = track2staff(ctx.track());
    2738            4 :     Staff* staff = ctx.score()->staff(staffIdx);
    2739            4 :     if (staff) {
    2740            4 :         String instrId = staff->part()->instrumentId(g->tick());
    2741            4 :         g->setIsHarpGliss(instrId == "harp");
    2742            4 :     }
    2743            4 :     g->resetProperty(Pid::GLISS_STYLE);
    2744              : 
    2745           25 :     while (e.readNextStartElement()) {
    2746           21 :         const AsciiStringView tag = e.name();
    2747           21 :         if (tag == "text") {
    2748            0 :             TRead::readProperty(g, e, ctx, Pid::GLISS_TEXT);
    2749           21 :         } else if (tag == "isHarpGliss" && ctx.pasteMode()) {
    2750            1 :             g->setIsHarpGliss(e.readBool());
    2751            1 :             g->resetProperty(Pid::GLISS_STYLE);
    2752           20 :         } else if (tag == "easeInSpin") {
    2753            0 :             g->setEaseIn(e.readInt());
    2754           20 :         } else if (tag == "easeOutSpin") {
    2755            0 :             g->setEaseOut(e.readInt());
    2756           20 :         } else if (tag == "glissandoShift") {
    2757            0 :             g->setGlissandoShift(e.readBool());
    2758           20 :         } else if (!TRead::readProperties(static_cast<SLine*>(g), e, ctx)) {
    2759            0 :             e.unknown();
    2760              :         }
    2761              :     }
    2762            4 : }
    2763              : 
    2764           41 : void TRead::read(GradualTempoChange* c, XmlReader& xml, ReadContext& ctx)
    2765              : {
    2766          416 :     while (xml.readNextStartElement()) {
    2767          375 :         const AsciiStringView tag(xml.name());
    2768              : 
    2769          375 :         if (TRead::readProperty(c, tag, xml, ctx, Pid::TEMPO_CHANGE_TYPE)) {
    2770            3 :             continue;
    2771              :         }
    2772              : 
    2773          373 :         if (TRead::readProperty(c, tag, xml, ctx, Pid::TEMPO_EASING_METHOD)) {
    2774            0 :             continue;
    2775              :         }
    2776              : 
    2777          373 :         if (TRead::readProperty(c, tag, xml, ctx, Pid::TEMPO_CHANGE_FACTOR)) {
    2778            1 :             continue;
    2779              :         }
    2780              : 
    2781          372 :         if (TRead::readProperty(c, tag, xml, ctx, Pid::SNAP_AFTER)) {
    2782            0 :             continue;
    2783              :         }
    2784              : 
    2785          372 :         if (!readProperties(toTextLineBase(c), xml, ctx)) {
    2786            0 :             xml.unknown();
    2787              :         }
    2788              :     }
    2789           41 :     if (ctx.mscVersion() < 470) {
    2790            0 :         compat::CompatUtils::setTextLineTextPositionFromAlign(c);
    2791              :     }
    2792           41 : }
    2793              : 
    2794            0 : void TRead::read(Groups* g, XmlReader& e, ReadContext&)
    2795              : {
    2796            0 :     while (e.readNextStartElement()) {
    2797            0 :         const AsciiStringView tag(e.name());
    2798            0 :         if (tag == "Node") {
    2799            0 :             GroupNode n;
    2800            0 :             n.pos    = e.intAttribute("pos");
    2801            0 :             n.action = e.intAttribute("action");
    2802            0 :             g->addNode(n);
    2803            0 :             e.skipCurrentElement();
    2804              :         } else {
    2805            0 :             e.unknown();
    2806              :         }
    2807              :     }
    2808            0 : }
    2809              : 
    2810            4 : void TRead::read(GuitarBend* g, XmlReader& e, ReadContext& ctx)
    2811              : {
    2812            4 :     g->eraseSpannerSegments();
    2813              : 
    2814           32 :     while (e.readNextStartElement()) {
    2815           28 :         const AsciiStringView tag = e.name();
    2816           28 :         if (tag == "guitarBendType") {
    2817            4 :             g->setBendType(TConv::fromXml(e.readAsciiText(), GuitarBendType::BEND));
    2818           24 :         } else if (tag == "GuitarBendHold") {
    2819            0 :             GuitarBendHold* hold = new GuitarBendHold(g);
    2820            0 :             TRead::read(hold, e, ctx);
    2821            0 :             g->setHoldLine(hold);
    2822           24 :         } else if (TRead::readProperty(g, tag, e, ctx, Pid::DIRECTION)) {
    2823           24 :         } else if (TRead::readProperty(g, tag, e, ctx, Pid::BEND_SHOW_HOLD_LINE)) {
    2824           24 :         } else if (TRead::readProperty(g, tag, e, ctx, Pid::BEND_START_TIME_FACTOR)) {
    2825           20 :         } else if (TRead::readProperty(g, tag, e, ctx, Pid::BEND_TARGET_TIME_FACTOR)) {
    2826           20 :         } else if (TRead::readProperty(g, tag, e, ctx, Pid::BEND_END_TIME_FACTOR)) {
    2827           16 :         } else if (TRead::readProperty(g, tag, e, ctx, Pid::GUITAR_DIVE_TAB_POS)) {
    2828           16 :         } else if (TRead::readProperty(g, tag, e, ctx, Pid::GUITAR_BEND_AMOUNT)) {
    2829           16 :         } else if (TRead::readProperty(g, tag, e, ctx, Pid::VIBRATO_LINE_TYPE)) {
    2830           16 :         } else if (TRead::readProperty(g, tag, e, ctx, Pid::GUITAR_DIVE_IS_SLACK)) {
    2831           16 :         } else if (!TRead::readProperties(static_cast<SLine*>(g), e, ctx)) {
    2832            0 :             e.unknown();
    2833              :         }
    2834              :     }
    2835            4 : }
    2836              : 
    2837            0 : void TRead::read(GuitarBendHold* h, XmlReader& xml, ReadContext& ctx)
    2838              : {
    2839            0 :     h->eraseSpannerSegments();
    2840              : 
    2841            0 :     while (xml.readNextStartElement()) {
    2842            0 :         if (!TRead::readProperties(static_cast<SLine*>(h), xml, ctx)) {
    2843            0 :             xml.unknown();
    2844              :         }
    2845              :     }
    2846            0 : }
    2847              : 
    2848            0 : bool TRead::readProperties(GuitarBendSegment* g, const AsciiStringView& tag, XmlReader& xml, ReadContext& ctx)
    2849              : {
    2850            0 :     if (tag == "bendVertexOffset") {
    2851            0 :         g->setVertexPointOff(xml.readPoint() * g->style().spatium());
    2852            0 :     } else if (tag == "GuitarBendText") {
    2853            0 :         GuitarBendText* bendText = new GuitarBendText(g);
    2854            0 :         read(toTextBase(bendText), xml, ctx);
    2855            0 :         g->setBendText(bendText);
    2856              :     } else {
    2857            0 :         return false;
    2858              :     }
    2859              : 
    2860            0 :     return true;
    2861              : }
    2862              : 
    2863           68 : void TRead::read(Hairpin* h, XmlReader& e, ReadContext& ctx)
    2864              : {
    2865           68 :     h->eraseSpannerSegments();
    2866              : 
    2867          480 :     while (e.readNextStartElement()) {
    2868          412 :         const AsciiStringView tag(e.name());
    2869          412 :         if (tag == "subtype") {
    2870           68 :             h->setHairpinType(HairpinType(e.readInt()));
    2871          344 :         } else if (tag == "hairpinCircledTip") {
    2872            0 :             h->setHairpinCircledTip(e.readInt());
    2873          344 :         } else if (tag == "veloChange") {
    2874            3 :             h->setVeloChange(e.readInt());
    2875          341 :         } else if (tag == "singleNoteDynamics") {
    2876            0 :             h->setSingleNoteDynamics(e.readBool());
    2877          341 :         } else if (tag == "veloChangeMethod") {
    2878            0 :             h->setVeloChangeMethod(TConv::fromXml(e.readAsciiText(), ChangeMethod::NORMAL));
    2879          341 :         } else if (readProperty(h, tag, e, ctx, Pid::VOICE_ASSIGNMENT)) {
    2880          341 :         } else if (readProperty(h, tag, e, ctx, Pid::DIRECTION)) {
    2881          341 :         } else if (readProperty(h, tag, e, ctx, Pid::CENTER_BETWEEN_STAVES)) {
    2882          341 :         } else if (readProperty(h, tag, e, ctx, Pid::SNAP_BEFORE)) {
    2883          341 :         } else if (readProperty(h, tag, e, ctx, Pid::SNAP_AFTER)) {
    2884          341 :         } else if (!readProperties(toTextLineBase(h), e, ctx)) {
    2885            0 :             e.unknown();
    2886              :         }
    2887              :     }
    2888           68 :     if (ctx.mscVersion() < 470) {
    2889            4 :         compat::CompatUtils::setTextLineTextPositionFromAlign(h);
    2890              :     }
    2891           68 :     h->styleChanged();
    2892           68 : }
    2893              : 
    2894            0 : void TRead::read(HammerOnPullOff* h, XmlReader& xml, ReadContext& ctx)
    2895              : {
    2896            0 :     while (xml.readNextStartElement()) {
    2897            0 :         if (!readProperties(toSlur(h), xml, ctx)) {
    2898            0 :             xml.unknown();
    2899              :         }
    2900              :     }
    2901            0 : }
    2902              : 
    2903           23 : static void readHarmonyInfo(HarmonyInfo* info, XmlReader& e)
    2904              : {
    2905           58 :     while (e.readNextStartElement()) {
    2906           35 :         const AsciiStringView tag(e.name());
    2907           35 :         if (tag == "bass") {
    2908            0 :             info->setBassTpc(e.readInt());
    2909           35 :         } else if (tag == "extension") {
    2910            0 :             info->setId(e.readInt());
    2911           35 :         } else if (tag == "name") {
    2912           12 :             info->setTextName(e.readText());
    2913           23 :         } else if (tag == "root") {
    2914           23 :             info->setRootTpc(e.readInt());
    2915              :         } else {
    2916            0 :             e.unknown();
    2917              :         }
    2918              :     }
    2919           23 : }
    2920              : 
    2921           23 : void TRead::read(Harmony* h, XmlReader& e, ReadContext& ctx)
    2922              : {
    2923           85 :     while (e.readNextStartElement()) {
    2924           62 :         const AsciiStringView tag(e.name());
    2925           62 :         if (tag == "bassCase") {
    2926            0 :             h->setBassCase(TConv::fromXml(e.readAsciiText(), NoteCaseType::AUTO));
    2927           62 :         } else if (tag == "rootCase") {
    2928            0 :             h->setRootCase(TConv::fromXml(e.readAsciiText(), NoteCaseType::AUTO));
    2929           62 :         } else if (tag == "harmonyInfo") {
    2930           23 :             HarmonyInfo* info = new HarmonyInfo(ctx.score());
    2931           23 :             readHarmonyInfo(info, e);
    2932           23 :             h->addChord(info);
    2933           39 :         } else if (tag == "degree") {
    2934            0 :             int degreeValue = 0;
    2935            0 :             int degreeAlter = 0;
    2936            0 :             String degreeType;
    2937            0 :             while (e.readNextStartElement()) {
    2938            0 :                 const AsciiStringView t(e.name());
    2939            0 :                 if (t == "degree-value") {
    2940            0 :                     degreeValue = e.readInt();
    2941            0 :                 } else if (t == "degree-alter") {
    2942            0 :                     degreeAlter = e.readInt();
    2943            0 :                 } else if (t == "degree-type") {
    2944            0 :                     degreeType = e.readText();
    2945              :                 } else {
    2946            0 :                     e.unknown();
    2947              :                 }
    2948              :             }
    2949            0 :             if (degreeValue <= 0 || degreeValue > 13
    2950            0 :                 || degreeAlter < -2 || degreeAlter > 2
    2951            0 :                 || (degreeType != "add" && degreeType != "alter" && degreeType != "subtract")) {
    2952            0 :                 LOGD("incorrect degree: degreeValue=%d degreeAlter=%d degreeType=%s",
    2953            0 :                      degreeValue, degreeAlter, muPrintable(degreeType));
    2954              :             } else {
    2955            0 :                 if (degreeType == "add") {
    2956            0 :                     h->addDegree(HDegree(degreeValue, degreeAlter, HDegreeType::ADD));
    2957            0 :                 } else if (degreeType == "alter") {
    2958            0 :                     h->addDegree(HDegree(degreeValue, degreeAlter, HDegreeType::ALTER));
    2959            0 :                 } else if (degreeType == "subtract") {
    2960            0 :                     h->addDegree(HDegree(degreeValue, degreeAlter, HDegreeType::SUBTRACT));
    2961              :                 }
    2962              :             }
    2963           39 :         } else if (TRead::readProperty(h, tag, e, ctx, Pid::POS_ABOVE)) {
    2964           39 :         } else if (TRead::readProperty(h, tag, e, ctx, Pid::HARMONY_TYPE)) {
    2965           39 :         } else if (TRead::readProperty(h, tag, e, ctx, Pid::PLAY)) {
    2966           39 :         } else if (TRead::readProperty(h, tag, e, ctx, Pid::HARMONY_VOICE_LITERAL)) {
    2967           39 :         } else if (TRead::readProperty(h, tag, e, ctx, Pid::HARMONY_VOICING)) {
    2968           39 :         } else if (TRead::readProperty(h, tag, e, ctx, Pid::HARMONY_DURATION)) {
    2969           39 :         } else if (TRead::readProperty(h, tag, e, ctx, Pid::HARMONY_BASS_SCALE)) {
    2970           39 :         } else if (TRead::readProperty(h, tag, e, ctx, Pid::HARMONY_DO_NOT_STACK_MODIFIERS)) {
    2971           39 :         } else if (TRead::readProperty(h, tag, e, ctx, Pid::EXCLUDE_VERTICAL_ALIGN)) {
    2972           39 :         } else if (!readProperties(toTextBase(h), e, ctx)) {
    2973            0 :             e.unknown();
    2974              :         }
    2975              :     }
    2976              : 
    2977           23 :     h->afterRead();
    2978           23 : }
    2979              : 
    2980           30 : void TRead::read(HarmonicMark* h, XmlReader& xml, ReadContext& ctx)
    2981              : {
    2982           30 :     TRead::read(toTextLineBase(h), xml, ctx);
    2983           30 : }
    2984              : 
    2985            7 : void TRead::read(HarpPedalDiagram* h, XmlReader& xml, ReadContext& ctx)
    2986              : {
    2987           40 :     while (xml.readNextStartElement()) {
    2988           33 :         const AsciiStringView tag = xml.name();
    2989           33 :         if (tag == "isDiagram") {
    2990            6 :             h->setIsDiagram(xml.readBool());
    2991           27 :         } else if (tag == "pedalState") {
    2992           56 :             while (xml.readNextStartElement()) {
    2993           49 :                 const AsciiStringView stringTag = xml.name();
    2994           49 :                 if (stringTag == "string") {
    2995           49 :                     HarpStringType str = HarpStringType(xml.intAttribute("name"));
    2996           49 :                     PedalPosition pos = PedalPosition(xml.readInt());
    2997           49 :                     h->setPedal(str, pos);
    2998              :                 } else {
    2999            0 :                     xml.unknown();
    3000              :                 }
    3001              :             }
    3002            7 :             h->setPlayableTpcs();
    3003           20 :         } else if (!readProperties(h, xml, ctx)) {
    3004            0 :             xml.unknown();
    3005              :         }
    3006              :     }
    3007            7 : }
    3008              : 
    3009            0 : void TRead::read(Hook* h, XmlReader& xml, ReadContext& ctx)
    3010              : {
    3011            0 :     TRead::read(static_cast<Symbol*>(h), xml, ctx);
    3012            0 : }
    3013              : 
    3014          119 : void TRead::read(LayoutBreak* b, XmlReader& e, ReadContext& ctx)
    3015              : {
    3016          361 :     while (e.readNextStartElement()) {
    3017          242 :         const AsciiStringView tag(e.name());
    3018          242 :         if (tag == "subtype") {
    3019          119 :             TRead::readProperty(b, e, ctx, Pid::LAYOUT_BREAK);
    3020          123 :         } else if (tag == "pause") {
    3021            0 :             TRead::readProperty(b, e, ctx, Pid::PAUSE);
    3022          123 :         } else if (tag == "startWithLongNames") {
    3023            0 :             TRead::readProperty(b, e, ctx, Pid::START_WITH_LONG_NAMES);
    3024          123 :         } else if (tag == "startWithMeasureOne") {
    3025            0 :             TRead::readProperty(b, e, ctx, Pid::START_WITH_MEASURE_ONE);
    3026          123 :         } else if (tag == "firstSystemIndentation") {
    3027            0 :             TRead::readProperty(b, e, ctx, Pid::FIRST_SYSTEM_INDENTATION);
    3028          123 :         } else if (tag == "showCourtesySig") {
    3029            0 :             TRead::readProperty(b, e, ctx, Pid::SHOW_COURTESY);
    3030          123 :         } else if (!readItemProperties(b, e, ctx)) {
    3031            0 :             e.unknown();
    3032              :         }
    3033              :     }
    3034          119 : }
    3035              : 
    3036            0 : void TRead::read(LedgerLine* l, XmlReader& e, ReadContext& ctx)
    3037              : {
    3038            0 :     while (e.readNextStartElement()) {
    3039            0 :         if (!readProperties(l, e, ctx)) {
    3040            0 :             e.unknown();
    3041              :         }
    3042              :     }
    3043            0 : }
    3044              : 
    3045            0 : bool TRead::readProperties(LedgerLine* l, XmlReader& e, ReadContext&)
    3046              : {
    3047            0 :     const AsciiStringView tag(e.name());
    3048              : 
    3049            0 :     if (tag == "lineWidth") {
    3050              :         //! NOTE Probably need to be removed, because it is calculated in Layout
    3051            0 :         LedgerLine::LayoutData* ldata = l->mutldata();
    3052            0 :         ldata->lineWidth = (e.readDouble() * l->spatium());
    3053            0 :     } else if (tag == "lineLen") {
    3054            0 :         l->setLen(e.readDouble() * l->spatium());
    3055            0 :     } else if (tag == "vertical") {
    3056            0 :         l->setVertical(e.readInt());
    3057              :     } else {
    3058            0 :         return false;
    3059              :     }
    3060            0 :     return true;
    3061              : }
    3062              : 
    3063           30 : void TRead::read(LetRing* r, XmlReader& e, ReadContext& ctx)
    3064              : {
    3065          210 :     while (e.readNextStartElement()) {
    3066          150 :         if (!readProperties(toTextLineBase(r), e, ctx)) {
    3067            0 :             e.unknown();
    3068              :         }
    3069              :     }
    3070           30 :     if (ctx.mscVersion() < 470) {
    3071            0 :         compat::CompatUtils::setTextLineTextPositionFromAlign(r);
    3072              :     }
    3073           30 : }
    3074              : 
    3075          132 : void TRead::read(Location* l, XmlReader& e, ReadContext&)
    3076              : {
    3077          232 :     while (e.readNextStartElement()) {
    3078          100 :         const AsciiStringView tag(e.name());
    3079              : 
    3080          100 :         if (tag == "staves") {
    3081            0 :             l->setStaff(e.readInt());
    3082          100 :         } else if (tag == "voices") {
    3083           11 :             l->setVoice(e.readInt());
    3084           89 :         } else if (tag == "measures") {
    3085            0 :             l->setMeasure(e.readInt());
    3086           89 :         } else if (tag == "fractions") {
    3087           89 :             l->setFrac(e.readFraction());
    3088            0 :         } else if (tag == "grace") {
    3089            0 :             l->setGraceIndex(e.readInt());
    3090            0 :         } else if (tag == "notes") {
    3091            0 :             l->setNote(e.readInt());
    3092            0 :         } else if (tag == "timeTick") {
    3093            0 :             l->setIsTimeTick(e.readBool());
    3094              :         } else {
    3095            0 :             e.unknown();
    3096              :         }
    3097              :     }
    3098          132 : }
    3099              : 
    3100           94 : void TRead::read(Lyrics* l, XmlReader& e, ReadContext& ctx)
    3101              : {
    3102          335 :     while (e.readNextStartElement()) {
    3103          147 :         if (!TRead::readProperties(l, e, ctx)) {
    3104            0 :             e.unknown();
    3105              :         }
    3106              :     }
    3107           94 : }
    3108              : 
    3109            1 : void TRead::read(LyricsLine* l, XmlReader& e, ReadContext& ctx)
    3110              : {
    3111            7 :     while (e.readNextStartElement()) {
    3112            5 :         if (!readProperties(static_cast<SLine*>(l), e, ctx)) {
    3113            0 :             e.unknown();
    3114              :         }
    3115              :     }
    3116            1 : }
    3117              : 
    3118            2 : void TRead::read(LineSegment* l, XmlReader& e, ReadContext& ctx)
    3119              : {
    3120           16 :     while (e.readNextStartElement()) {
    3121           12 :         if (!readProperties(l, e, ctx)) {
    3122            0 :             e.unknown();
    3123              :         }
    3124              :     }
    3125            2 : }
    3126              : 
    3127           12 : bool TRead::readProperties(LineSegment* l, XmlReader& e, ReadContext& ctx)
    3128              : {
    3129           12 :     const AsciiStringView tag(e.name());
    3130           12 :     if (tag == "subtype") {
    3131            2 :         l->setSpannerSegmentType(SpannerSegmentType(e.readInt()));
    3132           10 :     } else if (tag == "off2") {
    3133            2 :         l->setUserOff2(e.readPoint() * l->style().spatium());
    3134            8 :     } else if (l->isGuitarBendSegment() && readProperties(static_cast<GuitarBendSegment*>(l), tag, e, ctx)) {
    3135            8 :     } else if (!readItemProperties(l, e, ctx)) {
    3136            0 :         return false;
    3137              :     }
    3138           12 :     return true;
    3139              : }
    3140              : 
    3141          147 : bool TRead::readProperties(Lyrics* l, XmlReader& e, ReadContext& ctx)
    3142              : {
    3143          147 :     const AsciiStringView tag(e.name());
    3144              : 
    3145          147 :     if (tag == "no") {
    3146            1 :         l->setVerse(e.readInt());
    3147            1 :         if (l->isEven()) {
    3148            1 :             l->initTextStyleType(TextStyleType::LYRICS_EVEN);
    3149              :         }
    3150          146 :     } else if (tag == "syllabic") {
    3151           12 :         l->setSyllabic(TConv::fromXml(e.readAsciiText(), LyricsSyllabic::SINGLE));
    3152          134 :     } else if (tag == "ticks_f") {
    3153            6 :         l->setTicks(e.readFraction());
    3154          128 :     } else if (TRead::readProperty(l, tag, e, ctx, Pid::PLACEMENT)) {
    3155          128 :     } else if (tag == "LyricsLine") {
    3156            0 :         LyricsLine* ll = Factory::createLyricsLine(l);
    3157            0 :         TRead::read(ll, e, ctx);
    3158            0 :         ll->setTick(ctx.tick());
    3159            0 :         l->setSeparator(ll);
    3160            0 :         ctx.score()->addUnmanagedSpanner(ll);
    3161          128 :     } else if (!readProperties(toTextBase(l), e, ctx)) {
    3162            0 :         return false;
    3163              :     }
    3164          147 :     return true;
    3165              : }
    3166              : 
    3167           50 : void TRead::read(MeasureRepeat* r, XmlReader& e, ReadContext& ctx)
    3168              : {
    3169          271 :     while (e.readNextStartElement()) {
    3170          221 :         const AsciiStringView tag(e.name());
    3171          221 :         if (tag == "subtype") {
    3172           50 :             r->setNumMeasures(e.readInt());
    3173          171 :         } else if (TRead::readProperty(r, tag, e, ctx, Pid::MEASURE_REPEAT_NUMBER_OFFSET)) {
    3174          171 :         } else if (!readProperties(toRest(r), e, ctx)) {
    3175            0 :             e.unknown();
    3176              :         }
    3177              :     }
    3178           50 : }
    3179              : 
    3180           14 : void TRead::read(MMRest* r, XmlReader& e, ReadContext& ctx)
    3181              : {
    3182           71 :     while (e.readNextStartElement()) {
    3183           57 :         const AsciiStringView tag(e.name());
    3184           57 :         if (tag == "Symbol") {
    3185            0 :             Symbol* s = new Symbol(r);
    3186            0 :             s->setTrack(r->track());
    3187            0 :             TRead::read(s, e, ctx);
    3188            0 :             r->add(s);
    3189           57 :         } else if (tag == "Image") {
    3190            0 :             if (MScore::noImages) {
    3191            0 :                 e.skipCurrentElement();
    3192              :             } else {
    3193            0 :                 Image* image = new Image(r);
    3194            0 :                 image->setTrack(r->track());
    3195            0 :                 TRead::read(image, e, ctx);
    3196            0 :                 r->add(image);
    3197              :             }
    3198           57 :         } else if (tag == "NoteDot") {
    3199            0 :             NoteDot* dot = Factory::createNoteDot(r);
    3200            0 :             TRead::read(dot, e, ctx);
    3201            0 :             r->add(dot);
    3202           57 :         } else if (tag == "mmRestNumberPos") {
    3203              :             // Old property, deprecated in 4.5
    3204            0 :             r->setNumberOffset(Spatium(e.readDouble()) - ctx.style().styleS(Sid::mmRestNumberPos));
    3205           57 :         } else if (TRead::readProperty(r, tag, e, ctx, Pid::MMREST_NUMBER_OFFSET)) {
    3206           56 :         } else if (TRead::readStyledProperty(r, tag, e, ctx)) {
    3207           56 :         } else if (readProperties(r, e, ctx)) {
    3208              :         } else {
    3209            0 :             e.unknown();
    3210              :         }
    3211              :     }
    3212           14 : }
    3213              : 
    3214           56 : bool TRead::readProperties(MMRest* r, XmlReader& xml, ReadContext& ctx)
    3215              : {
    3216           56 :     const AsciiStringView tag(xml.name());
    3217           56 :     if (tag == "mmRestNumberVisible") {
    3218            0 :         r->setProperty(Pid::MMREST_NUMBER_VISIBLE, xml.readBool());
    3219           56 :     } else if (TRead::readProperties(toRest(r), xml, ctx)) {
    3220              :     } else {
    3221            0 :         return false;
    3222              :     }
    3223           56 :     return true;
    3224              : }
    3225              : 
    3226         5584 : void TRead::read(Note* n, XmlReader& e, ReadContext& ctx)
    3227              : {
    3228         5584 :     n->setTpc1(Tpc::TPC_INVALID);
    3229         5584 :     n->setTpc2(Tpc::TPC_INVALID);
    3230              : 
    3231        28139 :     while (e.readNextStartElement()) {
    3232        16971 :         if (TRead::readProperties(n, e, ctx)) {
    3233              :         } else {
    3234            0 :             e.unknown();
    3235              :         }
    3236              :     }
    3237              : 
    3238         5584 :     n->setupAfterRead(ctx.tick(), ctx.pasteMode());
    3239         5584 : }
    3240              : 
    3241        16971 : bool TRead::readProperties(Note* n, XmlReader& e, ReadContext& ctx)
    3242              : {
    3243        16971 :     const AsciiStringView tag(e.name());
    3244              : 
    3245        16971 :     if (tag == "pitch") {
    3246         5584 :         n->setPitch(clampPitch(e.readInt()), false);
    3247        11387 :     } else if (TRead::readProperty(n, tag, e, ctx, Pid::CENT_OFFSET)) {
    3248        11387 :     } else if (tag == "tpc") {
    3249         5584 :         int tpc = e.readInt();
    3250         5584 :         n->setTpc1(tpc);
    3251         5584 :         n->setTpc2(tpc);
    3252         5803 :     } else if (tag == "track") {          // for performance
    3253           15 :         n->setTrack(e.readInt());
    3254         5788 :     } else if (tag == "Accidental") {
    3255            9 :         Accidental* a = Factory::createAccidental(n);
    3256            9 :         a->setTrack(n->track());
    3257            9 :         TRead::read(a, e, ctx);
    3258            9 :         n->add(a);
    3259         5779 :     } else if (tag == "tpc2") {
    3260          136 :         n->setTpc2(e.readInt());
    3261         5643 :     } else if (tag == "small") {
    3262          194 :         n->setSmall(e.readInt());
    3263         5449 :     } else if (tag == "mirror") {
    3264            4 :         TRead::readProperty(n, e, ctx, Pid::MIRROR_HEAD);
    3265         5445 :     } else if (tag == "dotPosition") {
    3266            4 :         TRead::readProperty(n, e, ctx, Pid::DOT_POSITION);
    3267         5441 :     } else if (tag == "fixed") {
    3268            0 :         n->setFixed(e.readBool());
    3269         5441 :     } else if (tag == "fixedLine") {
    3270            0 :         n->setFixedLine(e.readInt());
    3271         5441 :     } else if (tag == "headScheme") {
    3272            3 :         TRead::readProperty(n, e, ctx, Pid::HEAD_SCHEME);
    3273         5438 :     } else if (tag == "head") {
    3274          181 :         TRead::readProperty(n, e, ctx, Pid::HEAD_GROUP);
    3275         5257 :     } else if (tag == "velocity") {
    3276          101 :         n->setUserVelocity(e.readInt());
    3277         5156 :     } else if (tag == "play") {
    3278            0 :         n->setPlay(e.readInt());
    3279         5156 :     } else if (tag == "tuning") {
    3280          103 :         n->setTuning(e.readDouble());
    3281         5053 :     } else if (tag == "fret") {
    3282          103 :         n->setFret(e.readInt());
    3283         4950 :     } else if (tag == "string") {
    3284          106 :         n->setString(e.readInt());
    3285         4844 :     } else if (tag == "ghost") {
    3286           98 :         n->setGhost(e.readInt());
    3287         4746 :     } else if (tag == "dead") {
    3288            0 :         n->setDeadNote(e.readInt());
    3289         4746 :     } else if (tag == "headType") {
    3290          106 :         TRead::readProperty(n, e, ctx, Pid::HEAD_TYPE);
    3291         4640 :     } else if (tag == "veloType") {
    3292            0 :         TRead::readProperty(n, e, ctx, Pid::VELO_TYPE);
    3293         4640 :     } else if (tag == "line") {
    3294            0 :         n->setLine(e.readInt());
    3295         4640 :     } else if (tag == "Fingering") {
    3296           10 :         Fingering* f = Factory::createFingering(n);
    3297           10 :         f->setTrack(n->track());
    3298           10 :         TRead::read(f, e, ctx);
    3299           10 :         n->add(f);
    3300         4630 :     } else if (tag == "Text") {
    3301            0 :         Text* t = Factory::createText(n);
    3302            0 :         t->setTrack(n->track());
    3303            0 :         TRead::read(t, e, ctx);
    3304            0 :         n->add(t);
    3305         4630 :     } else if (tag == "Symbol") {
    3306            7 :         Symbol* s = new Symbol(n);
    3307            7 :         s->setTrack(n->track());
    3308            7 :         TRead::read(s, e, ctx);
    3309            7 :         n->add(s);
    3310         4623 :     } else if (tag == "Image") {
    3311            0 :         if (MScore::noImages) {
    3312            0 :             e.skipCurrentElement();
    3313              :         } else {
    3314            0 :             Image* image = new Image(n);
    3315            0 :             image->setTrack(n->track());
    3316            0 :             TRead::read(image, e, ctx);
    3317            0 :             n->add(image);
    3318              :         }
    3319         4623 :     } else if (tag == "Bend") {
    3320            0 :         Bend* b = Factory::createBend(n);
    3321            0 :         b->setTrack(n->track());
    3322            0 :         TRead::read(b, e, ctx);
    3323            0 :         n->add(b);
    3324         4623 :     } else if (tag == "NoteDot") {
    3325            0 :         NoteDot* dot = Factory::createNoteDot(n);
    3326            0 :         TRead::read(dot, e, ctx);
    3327            0 :         n->add(dot);
    3328         4623 :     } else if (tag == "Events") {
    3329            0 :         NoteEventList playEvents;
    3330            0 :         while (e.readNextStartElement()) {
    3331            0 :             const AsciiStringView t(e.name());
    3332            0 :             if (t == "Event") {
    3333            0 :                 NoteEvent ne;
    3334            0 :                 TRead::read(&ne, e, ctx);
    3335            0 :                 playEvents.push_back(ne);
    3336              :             } else {
    3337            0 :                 e.unknown();
    3338              :             }
    3339              :         }
    3340            0 :         n->setPlayEvents(playEvents);
    3341            0 :         if (n->chord()) {
    3342            0 :             n->chord()->setPlayEventType(PlayEventType::User);
    3343              :         }
    3344         4623 :     } else if (tag == "offset") {
    3345            0 :         readItemProperties(n, e, ctx);
    3346         4623 :     } else if (tag == "ChordLine" && n->chord()) {
    3347            1 :         ChordLine* cl = Factory::createChordLine(n->chord());
    3348            1 :         TRead::read(cl, e, ctx);
    3349            1 :         cl->setNote(n);
    3350            1 :         n->chord()->add(cl);
    3351         4622 :     } else if (tag == "LaissezVib") {
    3352            1 :         LaissezVib* lv = Factory::createLaissezVib(n);
    3353            1 :         TRead::read(lv, e, ctx);
    3354            1 :         n->add(lv);
    3355         4621 :     } else if (tag == "PartialTie") {
    3356           18 :         PartialTie* pt = Factory::createPartialTie(n);
    3357           18 :         TRead::read(pt, e, ctx);
    3358           18 :         if (pt->isOutgoing()) {
    3359            6 :             pt->setStartNote(n);
    3360              :         } else {
    3361           12 :             pt->setEndNote(n);
    3362              :         }
    3363           18 :         n->add(pt);
    3364         4603 :     } else if (Spanner* spanner = tryCreateSpanner(tag, ctx, /*requireNoteAnchor*/ true)) {
    3365           43 :         TRead::readItem(spanner, e, ctx);
    3366         4560 :     } else if (tag == "overrideBendVisibilityRules") {
    3367            0 :         n->setOverrideBendVisibilityRules(e.readBool());
    3368         4560 :     } else if (TRead::readProperty(n, tag, e, ctx, Pid::HIDE_GENERATED_PARENTHESES)) {
    3369         4560 :     } else if (readItemProperties(n, e, ctx)) {
    3370              :     } else {
    3371            0 :         return false;
    3372              :     }
    3373        16971 :     return true;
    3374              : }
    3375              : 
    3376            0 : void TRead::read(NoteEvent* item, XmlReader& e, ReadContext&)
    3377              : {
    3378            0 :     while (e.readNextStartElement()) {
    3379            0 :         const AsciiStringView tag(e.name());
    3380            0 :         if (tag == "pitch") {
    3381            0 :             item->setPitch(e.readInt());
    3382            0 :         } else if (tag == "ontime") {
    3383            0 :             item->setOntime(e.readInt());
    3384            0 :         } else if (tag == "len") {
    3385            0 :             item->setLen(e.readInt());
    3386              :         } else {
    3387            0 :             e.unknown();
    3388              :         }
    3389              :     }
    3390            0 : }
    3391              : 
    3392            0 : void TRead::read(NoteDot* d, XmlReader& e, ReadContext& ctx)
    3393              : {
    3394            0 :     while (e.readNextStartElement()) {
    3395            0 :         if (!readItemProperties(d, e, ctx)) {
    3396            0 :             e.unknown();
    3397              :         }
    3398              :     }
    3399            0 : }
    3400              : 
    3401            0 : void TRead::read(NoteHead* h, XmlReader& xml, ReadContext& ctx)
    3402              : {
    3403            0 :     read(static_cast<Symbol*>(h), xml, ctx);
    3404            0 : }
    3405              : 
    3406            1 : void TRead::read(NoteLine* nl, XmlReader& xml, ReadContext& ctx)
    3407              : {
    3408            1 :     TRead::read(toTextLineBase(nl), xml, ctx);
    3409            1 : }
    3410              : 
    3411           41 : void TRead::read(Ottava* o, XmlReader& e, ReadContext& ctx)
    3412              : {
    3413           41 :     o->eraseSpannerSegments();
    3414          287 :     while (e.readNextStartElement()) {
    3415          246 :         readProperties(o, e, ctx);
    3416              :     }
    3417           41 :     if (ctx.mscVersion() < 470) {
    3418            2 :         compat::CompatUtils::setTextLineTextPositionFromAlign(o);
    3419              :     }
    3420           41 :     if (o->ottavaType() != OttavaType::OTTAVA_8VA || o->numbersOnly() != o->propertyDefault(Pid::NUMBERS_ONLY).toBool()) {
    3421            1 :         o->styleChanged();
    3422              :     }
    3423           41 : }
    3424              : 
    3425          246 : bool TRead::readProperties(Ottava* o, XmlReader& e, ReadContext& ctx)
    3426              : {
    3427          246 :     const AsciiStringView tag(e.name());
    3428          246 :     if (tag == "subtype") {
    3429           41 :         String s = e.readText();
    3430              :         bool ok;
    3431           41 :         int idx = s.toInt(&ok);
    3432           41 :         if (!ok) {
    3433           41 :             o->setOttavaType(OttavaType::OTTAVA_8VA);
    3434           41 :             for (OttavaDefault d : ottavaDefault) {
    3435           41 :                 if (s == d.name) {
    3436           41 :                     o->setOttavaType(d.type);
    3437           41 :                     break;
    3438              :                 }
    3439           41 :             }
    3440              :         } else {
    3441            0 :             o->setOttavaType(OttavaType(idx));
    3442              :         }
    3443          246 :     } else if (!readProperties(toTextLineBase(o), e, ctx)) {
    3444            0 :         e.unknown();
    3445            0 :         return false;
    3446              :     }
    3447          246 :     return true;
    3448              : }
    3449              : 
    3450            0 : void TRead::read(Page* p, XmlReader& e, ReadContext& ctx)
    3451              : {
    3452            0 :     while (e.readNextStartElement()) {
    3453            0 :         if (e.name() == "System") {
    3454            0 :             System* system = Factory::createSystem(p->score());
    3455            0 :             p->score()->systems().push_back(system);
    3456            0 :             read(system, e, ctx);
    3457              :         } else {
    3458            0 :             e.unknown();
    3459              :         }
    3460              :     }
    3461            0 : }
    3462              : 
    3463           38 : void TRead::read(PalmMute* p, XmlReader& e, ReadContext& ctx)
    3464              : {
    3465          266 :     while (e.readNextStartElement()) {
    3466          190 :         if (!readProperties(toTextLineBase(p), e, ctx)) {
    3467            0 :             e.unknown();
    3468              :         }
    3469              :     }
    3470           38 :     if (ctx.mscVersion() < 470) {
    3471            0 :         compat::CompatUtils::setTextLineTextPositionFromAlign(p);
    3472              :     }
    3473           38 : }
    3474              : 
    3475            6 : void TRead::read(Parenthesis* p, XmlReader& xml, ReadContext& ctx)
    3476              : {
    3477           15 :     while (xml.readNextStartElement()) {
    3478            9 :         const AsciiStringView tag(xml.name());
    3479            9 :         if (TRead::readProperty(p, tag, xml, ctx, Pid::HORIZONTAL_DIRECTION)) {
    3480            6 :         } else if (!readItemProperties(p, xml, ctx)) {
    3481            0 :             xml.unknown();
    3482              :         }
    3483              :     }
    3484            6 : }
    3485              : 
    3486          497 : void TRead::read(Part* p, XmlReader& e, ReadContext& ctx)
    3487              : {
    3488          497 :     p->setId(e.intAttribute("id", 0));
    3489              : 
    3490         2402 :     while (e.readNextStartElement()) {
    3491         1408 :         if (!readProperties(p, e, ctx)) {
    3492            0 :             e.unknown();
    3493              :         }
    3494              :     }
    3495          497 : }
    3496              : 
    3497            0 : static void readStaveSharingState(SharedPart* p, XmlReader& e)
    3498              : {
    3499            0 :     const Fraction tick = Fraction::fromString(e.attribute("tick"));
    3500            0 :     StaveSharingState state;
    3501            0 :     SharedTrackMap trackMap;
    3502              : 
    3503            0 :     while (e.readNextStartElement()) {
    3504            0 :         const AsciiStringView tag(e.name());
    3505            0 :         if (tag == "isReset") {
    3506            0 :             state.setIsReset(e.readBool());
    3507            0 :         } else if (tag == "trackMap") {
    3508            0 :             const int originTrack = e.intAttribute("origin", -1);
    3509            0 :             const int sharedTrack = e.intAttribute("shared", -1);
    3510            0 :             if (originTrack != -1 && sharedTrack != -1) {
    3511            0 :                 trackMap.insert({ static_cast<track_idx_t>(originTrack), static_cast<track_idx_t>(sharedTrack) });
    3512              :             }
    3513            0 :             e.skipCurrentElement();
    3514              :         } else {
    3515            0 :             e.unknown();
    3516              :         }
    3517              :     }
    3518              : 
    3519            0 :     state.setUserTrackMap(trackMap);
    3520            0 :     p->setStaveSharingStateAtTick(state, tick);
    3521            0 : }
    3522              : 
    3523            4 : void TRead::read(SharedPart* p, XmlReader& e, ReadContext& ctx)
    3524              : {
    3525            4 :     p->setId(e.intAttribute("id", 0));
    3526              : 
    3527           26 :     while (e.readNextStartElement()) {
    3528           22 :         const AsciiStringView tag(e.name());
    3529           22 :         if (tag == "sharedPartEnabled") {
    3530            4 :             p->setProperty(Pid::SHARED_PART_ENABLED, e.readBool());
    3531           18 :         } else if (tag == "StaveSharingState") {
    3532            0 :             readStaveSharingState(p, e);
    3533           18 :         } else if (!readProperties(p, e, ctx)) {
    3534            0 :             e.unknown();
    3535              :         }
    3536              :     }
    3537            4 : }
    3538              : 
    3539            5 : void TRead::read(PartialLyricsLine* p, XmlReader& xml, ReadContext& ctx)
    3540              : {
    3541           36 :     while (xml.readNextStartElement()) {
    3542           31 :         const AsciiStringView tag(xml.name());
    3543           31 :         if (tag == "isEndMelisma") {
    3544            5 :             p->setIsEndMelisma(xml.readBool());
    3545           26 :         } else if (TRead::readProperty(p, tag, xml, ctx, Pid::VERSE)) {
    3546           26 :         } else if (TRead::readProperty(p, tag, xml, ctx, Pid::CENTER_BETWEEN_STAVES)) {
    3547           25 :         } else if (!readProperties(static_cast<SLine*>(p), xml, ctx)) {
    3548            0 :             xml.unknown();
    3549              :         }
    3550              :     }
    3551            5 : }
    3552              : 
    3553           18 : void TRead::read(PartialTie* p, XmlReader& xml, ReadContext& ctx)
    3554              : {
    3555           84 :     while (xml.readNextStartElement()) {
    3556           66 :         const AsciiStringView tag(xml.name());
    3557           66 :         if (TRead::readProperty(p, tag, xml, ctx, Pid::TIE_PLACEMENT)) {
    3558           66 :         } else if (TRead::readProperty(p, tag, xml, ctx, Pid::PARTIAL_SPANNER_DIRECTION)) {
    3559           54 :         } else if (!readProperties(toSlurTie(p), xml, ctx)) {
    3560            0 :             xml.unknown();
    3561              :         }
    3562              :     }
    3563           18 : }
    3564              : 
    3565         1426 : bool TRead::readProperties(Part* p, XmlReader& e, ReadContext& ctx)
    3566              : {
    3567         1426 :     const AsciiStringView tag(e.name());
    3568         1426 :     if (tag == "id") {
    3569            0 :         p->setId(e.readInt());
    3570         1426 :     } else if (tag == "eid") {
    3571          375 :         readItemEID(p, e, ctx);
    3572         1051 :     } else if (tag == "sharedPart") {
    3573           10 :         AsciiStringView s = e.readAsciiText();
    3574           10 :         EID eid = EID::fromStdString(s);
    3575           10 :         DO_ASSERT(eid.isValid());
    3576           10 :         EIDRegister* eidRegister = ctx.score()->masterScore()->eidRegister();
    3577           10 :         EngravingObject* obj = eidRegister->itemFromEID(eid);
    3578           10 :         DO_ASSERT(obj && obj->isSharedPart());
    3579           10 :         SharedPart* sharedPart = toSharedPart(obj);
    3580           10 :         sharedPart->addOriginPart(p);
    3581         1041 :     } else if (tag == "Staff") {
    3582          538 :         Staff* staff = Factory::createStaff(p);
    3583          538 :         p->score()->appendStaff(staff);
    3584          538 :         TRead::read(staff, e, ctx);
    3585          503 :     } else if (tag == "Instrument") {
    3586          501 :         Instrument* instr = new Instrument;
    3587          501 :         read(instr, e, ctx, p);
    3588          501 :         p->setInstrument(instr, Fraction(-1, 1));
    3589            2 :     } else if (tag == "name") {
    3590            0 :         p->instrument()->setLongName(e.readText());
    3591            2 :     } else if (tag == "color") {
    3592            0 :         e.skipCurrentElement(); // Unused
    3593            2 :     } else if (tag == "shortName") {
    3594            0 :         p->instrument()->setShortName(e.readText());
    3595            2 :     } else if (tag == "show") {
    3596            2 :         p->setShow(e.readInt());
    3597            0 :     } else if (tag == "soloist") {
    3598            0 :         p->setSoloist(e.readInt());
    3599            0 :     } else if (tag == "hideWhenEmpty") {
    3600            0 :         p->setHideWhenEmpty(TConv::fromXml(e.readAsciiText(), AutoOnOff::AUTO));
    3601            0 :     } else if (tag == "hideStavesWhenIndividuallyEmpty") {
    3602            0 :         p->setHideStavesWhenIndividuallyEmpty(e.readBool());
    3603            0 :     } else if (tag == "preferSharpFlat") {
    3604            0 :         String val = e.readText();
    3605            0 :         if (val == "sharps") {
    3606            0 :             p->setPreferSharpFlat(PreferSharpFlat::SHARPS);
    3607            0 :         } else if (val == "flats") {
    3608            0 :             p->setPreferSharpFlat(PreferSharpFlat::FLATS);
    3609            0 :         } else if (val == "none") {
    3610            0 :             p->setPreferSharpFlat(PreferSharpFlat::NONE);
    3611              :         } else {
    3612            0 :             p->setPreferSharpFlat(PreferSharpFlat::AUTO);
    3613              :         }
    3614            0 :     } else {
    3615            0 :         return false;
    3616              :     }
    3617         1426 :     return true;
    3618              : }
    3619              : 
    3620           41 : void TRead::read(Pedal* p, XmlReader& e, ReadContext& ctx)
    3621              : {
    3622           41 :     bool beginTextTag = false;
    3623           41 :     bool continueTextTag = false;
    3624           41 :     bool endTextTag = false;
    3625              : 
    3626          329 :     while (e.readNextStartElement()) {
    3627          288 :         const AsciiStringView tag(e.name());
    3628          288 :         beginTextTag = beginTextTag || tag == "beginText";
    3629          288 :         continueTextTag = continueTextTag || tag == "continueText";
    3630          288 :         endTextTag = endTextTag || tag == "endText";
    3631              : 
    3632          288 :         if (TRead::readProperty(p, tag, e, ctx, Pid::LINE_VISIBLE)) {
    3633            0 :             p->resetProperty(Pid::END_TEXT);
    3634          288 :         } else if (TRead::readProperty(p, tag, e, ctx, Pid::BEGIN_HOOK_TYPE)) {
    3635            0 :             if (p->beginHookType() != HookType::NONE) {
    3636            0 :                 p->setBeginText(String());
    3637            0 :                 p->setContinueText(String());
    3638              :             }
    3639          288 :         } else if (!readProperties(toTextLineBase(p), e, ctx)) {
    3640            0 :             e.unknown();
    3641              :         }
    3642              :     }
    3643           41 :     if (ctx.mscVersion() < 470) {
    3644            1 :         compat::CompatUtils::setTextLineTextPositionFromAlign(p);
    3645              : 
    3646            1 :         if (p->endText() == Pedal::STAR_SYMBOL) {
    3647            0 :             p->setEndHookType(HookType::ROSETTE);
    3648              :         }
    3649              :     }
    3650           41 : }
    3651              : 
    3652           30 : void TRead::read(Rasgueado* r, XmlReader& xml, ReadContext& ctx)
    3653              : {
    3654           30 :     TRead::read(toTextLineBase(r), xml, ctx);
    3655           30 : }
    3656              : 
    3657         8530 : void TRead::read(Rest* r, XmlReader& e, ReadContext& ctx)
    3658              : {
    3659        36096 :     while (e.readNextStartElement()) {
    3660        27566 :         const AsciiStringView tag(e.name());
    3661        27566 :         if (tag == "NoteDot") {
    3662            0 :             NoteDot* dot = Factory::createNoteDot(r);
    3663            0 :             TRead::read(dot, e, ctx);
    3664            0 :             r->add(dot);
    3665        27566 :         } else if (TRead::readStyledProperty(r, tag, e, ctx)) {
    3666        27566 :         } else if (TRead::readProperty(r, tag, e, ctx, Pid::ALIGN_WITH_OTHER_RESTS)) {
    3667        27566 :         } else if (TRead::readProperties(r, e, ctx)) {
    3668              :         } else {
    3669            0 :             e.unknown();
    3670              :         }
    3671              :     }
    3672         8530 : }
    3673              : 
    3674            0 : void TRead::read(Segment* s, XmlReader& e, ReadContext& ctx)
    3675              : {
    3676              :     UNUSED(ctx);
    3677            0 :     while (e.readNextStartElement()) {
    3678            0 :         const AsciiStringView tag(e.name());
    3679              : 
    3680            0 :         if (tag == "subtype") {
    3681            0 :             e.skipCurrentElement();
    3682            0 :         } else if (tag == "leadingSpace") {
    3683            0 :             s->setExtraLeadingSpace(Spatium(e.readDouble()));
    3684              :         } else {
    3685            0 :             e.unknown();
    3686              :         }
    3687              :     }
    3688            0 : }
    3689              : 
    3690            0 : void TRead::read(SLine* l, XmlReader& e, ReadContext& ctx)
    3691              : {
    3692            0 :     l->eraseSpannerSegments();
    3693              : 
    3694            0 :     while (e.readNextStartElement()) {
    3695            0 :         if (!readProperties(l, e, ctx)) {
    3696            0 :             e.unknown();
    3697              :         }
    3698              :     }
    3699            0 : }
    3700              : 
    3701         1850 : bool TRead::readProperties(SLine* l, XmlReader& e, ReadContext& ctx)
    3702              : {
    3703         1850 :     const AsciiStringView tag(e.name());
    3704              : 
    3705         1850 :     if (tag == "Segment") {
    3706            2 :         LineSegment* ls = l->createLineSegment();
    3707            2 :         ls->setTrack(l->track());     // needed in read to get the right staff mag
    3708            2 :         l->add(ls);
    3709            2 :         TRead::read(ls, e, ctx);
    3710            2 :         ls->setVisible(l->visible());
    3711         1848 :     } else if (TRead::readStyledProperty(l, tag, e, ctx)) {
    3712         1786 :     } else if (TRead::readProperty(l, tag, e, ctx, Pid::DIAGONAL)) {
    3713         1781 :     } else if (TRead::readProperty(l, tag, e, ctx, Pid::LINE_WIDTH)) {
    3714         1780 :     } else if (TRead::readProperty(l, tag, e, ctx, Pid::LINE_STYLE)) {
    3715         1780 :     } else if (TRead::readProperty(l, tag, e, ctx, Pid::DASH_LINE_LEN)) {
    3716         1780 :     } else if (TRead::readProperty(l, tag, e, ctx, Pid::DASH_GAP_LEN)) {
    3717         1780 :     } else if (tag == "lineColor" || tag == "color") {
    3718            0 :         l->setLineColor(e.readColor());
    3719         1780 :     } else if (!readProperties(toSpanner(l), e, ctx)) {
    3720            0 :         return false;
    3721              :     }
    3722         1850 :     return true;
    3723              : }
    3724              : 
    3725           32 : void TRead::read(Slur* s, XmlReader& e, ReadContext& ctx)
    3726              : {
    3727          198 :     while (e.readNextStartElement()) {
    3728          134 :         if (!readProperties(s, e, ctx)) {
    3729            0 :             e.unknown();
    3730              :         }
    3731              :     }
    3732           32 : }
    3733              : 
    3734          134 : bool TRead::readProperties(Slur* s, XmlReader& e, ReadContext& ctx)
    3735              : {
    3736          134 :     const AsciiStringView tag(e.name());
    3737              : 
    3738          134 :     if (TRead::readProperty(s, tag, e, ctx, Pid::PARTIAL_SPANNER_DIRECTION)) {
    3739           11 :         return true;
    3740              :     }
    3741              : 
    3742          123 :     return readProperties(toSlurTie(s), e, ctx);
    3743              : }
    3744              : 
    3745            0 : void TRead::read(SlurTie* s, XmlReader& e, ReadContext& ctx)
    3746              : {
    3747            0 :     while (e.readNextStartElement()) {
    3748            0 :         if (!readProperties(s, e, ctx)) {
    3749            0 :             e.unknown();
    3750              :         }
    3751              :     }
    3752            0 : }
    3753              : 
    3754          316 : bool TRead::readProperties(SlurTie* s, XmlReader& e, ReadContext& ctx)
    3755              : {
    3756          316 :     const AsciiStringView tag(e.name());
    3757              : 
    3758          316 :     if (TRead::readProperty(s, tag, e, ctx, Pid::SLUR_DIRECTION)) {
    3759          314 :     } else if (TRead::readProperty(s, tag, e, ctx, Pid::MASK_SLURTIE)) {
    3760          314 :     } else if (tag == "lineType") {
    3761            3 :         s->setStyleType(static_cast<SlurStyleType>(e.readInt()));
    3762          619 :     } else if (tag == "SlurSegment" || tag == "TieSegment" || tag == "LaissezVibSegment" || tag == "PartialTieSegment"
    3763          619 :                || tag == "HammerOnPullOffSegment" || tag == "TappingHalfSlurSegment") {
    3764            3 :         const int idx = e.intAttribute("no", 0);
    3765            3 :         const int n = int(s->spannerSegments().size());
    3766            4 :         for (int i = n; i < idx; ++i) {
    3767            1 :             s->add(s->newSlurTieSegment());
    3768              :         }
    3769            3 :         SlurTieSegment* sts = s->newSlurTieSegment();
    3770            3 :         s->add(sts);
    3771            3 :         TRead::read(sts, e, ctx);
    3772          308 :     } else if (!readProperties(toSpanner(s), e, ctx)) {
    3773            0 :         return false;
    3774              :     }
    3775          316 :     return true;
    3776              : }
    3777              : 
    3778            3 : void TRead::read(SlurTieSegment* s, XmlReader& e, ReadContext& ctx)
    3779              : {
    3780           17 :     while (e.readNextStartElement()) {
    3781           14 :         const AsciiStringView tag(e.name());
    3782           14 :         if (readProperty(s, tag, e, ctx, Pid::BEZIER_OFFSET1)) {
    3783           14 :         } else if (readProperty(s, tag, e, ctx, Pid::BEZIER_OFFSET2)) {
    3784           11 :         } else if (readProperty(s, tag, e, ctx, Pid::BEZIER_OFFSET3)) {
    3785            9 :         } else if (readProperty(s, tag, e, ctx, Pid::BEZIER_OFFSET4)) {
    3786            9 :         } else if (tag == "HammerOnPullOffText") {
    3787            0 :             DO_ASSERT(s->isHammerOnPullOffSegment());
    3788            0 :             readHopoText(toHammerOnPullOffSegment(s), e, ctx, e.intAttribute("idx"));
    3789            9 :         } else if (!readItemProperties(s, e, ctx)) {
    3790            0 :             e.unknown();
    3791              :         }
    3792              :     }
    3793            3 : }
    3794              : 
    3795            0 : void TRead::readHopoText(HammerOnPullOffSegment* hopoSeg, XmlReader& xml, ReadContext& ctx, int idx)
    3796              : {
    3797            0 :     int hopoTextCount = static_cast<int>(hopoSeg->hopoText().size());
    3798            0 :     for (int i = hopoTextCount; i < idx; ++i) {
    3799            0 :         hopoSeg->addHopoText(new HammerOnPullOffText(hopoSeg));
    3800              :     }
    3801              : 
    3802            0 :     HammerOnPullOffText* hopoText = new HammerOnPullOffText(hopoSeg);
    3803            0 :     while (xml.readNextStartElement()) {
    3804            0 :         if (!readProperties(toTextBase(hopoText), xml, ctx)) {
    3805            0 :             xml.unknown();
    3806              :         }
    3807              :     }
    3808              : 
    3809            0 :     hopoSeg->addHopoText(hopoText);
    3810            0 : }
    3811              : 
    3812         3965 : String TRead::lineBreakFromTag(const String& str)
    3813              : {
    3814              :     // Raw newlines appearing next to tags (<font size="10> or <sym>...) get eaten by XML readers.
    3815         3965 :     String s = str;
    3816         7930 :     return s.replace(u"<br/>", u"\n");
    3817         3965 : }
    3818              : 
    3819            3 : void TRead::readNoteParenGroup(Chord* ch, XmlReader& e, ReadContext& ctx)
    3820              : {
    3821            3 :     Parenthesis* leftParen = nullptr;
    3822            3 :     Parenthesis* rightParen = nullptr;
    3823            3 :     std::vector<Note*> notes;
    3824           12 :     while (e.readNextStartElement()) {
    3825            9 :         const AsciiStringView t(e.name());
    3826              : 
    3827            9 :         if (t == "Parenthesis") {
    3828            6 :             Parenthesis* paren = Factory::createParenthesis(ch);
    3829            6 :             TRead::read(paren, e, ctx);
    3830            6 :             paren->setTrack(ctx.track());
    3831              : 
    3832            6 :             if (paren->direction() == DirectionH::LEFT) {
    3833            3 :                 leftParen = paren;
    3834              :             } else {
    3835            3 :                 rightParen = paren;
    3836              :             }
    3837            3 :         } else if (t == "Notes") {
    3838            6 :             while (e.readNextStartElement()) {
    3839            3 :                 const AsciiStringView noteTag(e.name());
    3840            3 :                 if (noteTag == "NoteEID") {
    3841            3 :                     AsciiStringView s = e.readAsciiText();
    3842            3 :                     EID eid = EID::fromStdString(s);
    3843            3 :                     IF_ASSERT_FAILED(eid.isValid()) {
    3844            0 :                         continue;
    3845              :                     }
    3846            3 :                     if (ctx.pasteMode()) {
    3847            1 :                         eid = ctx.resolvePastedEID(eid);
    3848              :                     }
    3849            3 :                     EIDRegister* eidRegister = ctx.score()->masterScore()->eidRegister();
    3850            3 :                     EngravingObject* obj = eidRegister->itemFromEID(eid);
    3851            3 :                     IF_ASSERT_FAILED(obj && obj->isNote()) {
    3852            0 :                         continue;
    3853              :                     }
    3854            3 :                     notes.push_back(toNote(obj));
    3855              :                 } else {
    3856            0 :                     e.unknown();
    3857              :                 }
    3858              :             }
    3859              :         } else {
    3860            0 :             e.unknown();
    3861              :         }
    3862              :     }
    3863              : 
    3864            3 :     if (!leftParen) {
    3865            0 :         leftParen = Factory::createParenthesis(ch);
    3866            0 :         leftParen->setTrack(ctx.track());
    3867              :     }
    3868              : 
    3869            3 :     if (!rightParen) {
    3870            0 :         rightParen = Factory::createParenthesis(ch);
    3871            0 :         rightParen->setDirection(DirectionH::RIGHT);
    3872            0 :         rightParen->setTrack(ctx.track());
    3873              :     }
    3874              : 
    3875            3 :     NoteParenthesisInfo* noteParenInfo = new NoteParenthesisInfo(leftParen, rightParen, notes);
    3876            3 :     ch->addNoteParenthesisInfo(noteParenInfo);
    3877            3 : }
    3878              : 
    3879         2088 : bool TRead::readProperties(Spanner* s, XmlReader& e, ReadContext& ctx)
    3880              : {
    3881         2088 :     const AsciiStringView tag(e.name());
    3882         2088 :     if (tag == "play") {
    3883            0 :         s->setPlaySpanner(e.readBool());
    3884            0 :         return true;
    3885         2088 :     } else if (tag == "track2") {
    3886          396 :         track_idx_t track2 = e.readInt();
    3887          396 :         s->setTrack2(track2 + ctx.trackOffset());
    3888         1692 :     } else if (tag == "startTick") {
    3889          396 :         Fraction startTick = e.readFraction() + ctx.tickOffset();
    3890          396 :         s->setTick(startTick);
    3891         1296 :     } else if (tag == "ticks") {
    3892           36 :         Fraction ticks = e.readFraction();
    3893           36 :         s->setTicks(ticks);
    3894         1260 :     } else if (tag == "startElement") {
    3895          125 :         EIDRegister* eidRegister = ctx.score()->masterScore()->eidRegister();
    3896          125 :         EID startElEID = EID::fromStdString(e.readAsciiText());
    3897          125 :         IF_ASSERT_FAILED(startElEID.isValid()) {
    3898           43 :             return false;
    3899              :         }
    3900          125 :         if (ctx.pasteMode()) {
    3901           36 :             startElEID = ctx.resolvePastedEID(startElEID);
    3902              :         }
    3903          125 :         if (s->anchor() == Spanner::Anchor::NOTE && !(s->isPartialTie() || s->isLaissezVib())) {
    3904              :             // Store spanner and EIDs to be connected at the end of file reading
    3905           43 :             ctx.addNoteAnchoredSpannerStartEl(s, startElEID);
    3906           43 :             return true;
    3907              :         }
    3908              : 
    3909           82 :         EngravingItem* startEl = toEngravingItem(eidRegister->itemFromEID(startElEID));
    3910           82 :         IF_ASSERT_FAILED(startEl) {
    3911            0 :             return false;
    3912              :         }
    3913           82 :         s->setStartElement(startEl);
    3914           82 :         s->setTick(startEl->tick());
    3915           82 :         s->setTrack(startEl->track());
    3916         1135 :     } else if (tag == "endElement") {
    3917          130 :         EIDRegister* eidRegister = ctx.score()->masterScore()->eidRegister();
    3918          130 :         EID endElEID = EID::fromStdString(e.readAsciiText());
    3919          130 :         IF_ASSERT_FAILED(endElEID.isValid()) {
    3920           43 :             return false;
    3921              :         }
    3922          130 :         if (ctx.pasteMode()) {
    3923           36 :             endElEID = ctx.resolvePastedEID(endElEID);
    3924              :         }
    3925          130 :         if (s->anchor() == Spanner::Anchor::NOTE && !(s->isPartialTie() || s->isLaissezVib())) {
    3926              :             // Store spanner and EIDs to be connected at the end of file reading
    3927           43 :             ctx.addNoteAnchoredSpannerEndEl(s, endElEID);
    3928           43 :             return true;
    3929              :         }
    3930              : 
    3931           87 :         EngravingItem* endEl = toEngravingItem(eidRegister->itemFromEID(endElEID));
    3932           87 :         IF_ASSERT_FAILED(endEl) {
    3933            0 :             return false;
    3934              :         }
    3935           87 :         s->setEndElement(endEl);
    3936           87 :         if (s->anchor() == Spanner::Anchor::MEASURE) {
    3937           43 :             s->setTick2(s->endMeasure()->endTick());
    3938              :         } else {
    3939           44 :             s->setTick2(endEl->tick());
    3940           44 :             s->setTrack2(endEl->track());
    3941              :         }
    3942         1005 :     } else if (!readItemProperties(s, e, ctx)) {
    3943            0 :         return false;
    3944              :     }
    3945         2002 :     return true;
    3946              : }
    3947              : 
    3948            0 : void TRead::read(Spacer* s, XmlReader& e, ReadContext& ctx)
    3949              : {
    3950            0 :     while (e.readNextStartElement()) {
    3951            0 :         const AsciiStringView tag(e.name());
    3952            0 :         if (tag == "subtype") {
    3953            0 :             s->setSpacerType(SpacerType(e.readInt()));
    3954            0 :         } else if (tag == "space") {
    3955            0 :             s->setGap(Spatium(e.readDouble()));
    3956            0 :         } else if (!readItemProperties(s, e, ctx)) {
    3957            0 :             e.unknown();
    3958              :         }
    3959              :     }
    3960            0 : }
    3961              : 
    3962          538 : void TRead::read(StaffType* t, XmlReader& e, ReadContext& ctx)
    3963              : {
    3964          538 :     t->setScore(ctx.score());
    3965          538 :     t->setGroup(TConv::fromXml(e.asciiAttribute("group"), StaffGroup::STANDARD));
    3966              : 
    3967          538 :     if (t->group() == StaffGroup::TAB) {
    3968            2 :         t->setGenKeysig(false);
    3969              :     }
    3970              : 
    3971         1159 :     while (e.readNextStartElement()) {
    3972          621 :         const AsciiStringView tag(e.name());
    3973          621 :         if (tag == "name") {
    3974          537 :             t->setType(TConv::fromXml(e.readAsciiText(), StaffTypes::STANDARD));
    3975           84 :         } else if (tag == "StaffLabel") {
    3976            0 :             StaffLabel& staffLabel = t->staffLabel();
    3977            0 :             readStaffLabel(staffLabel, e);
    3978           84 :         } else if (tag == "lines") {
    3979           22 :             t->setLines(e.readInt());
    3980           62 :         } else if (tag == "lineDistance") {
    3981            2 :             t->setLineDistance(Spatium(e.readDouble()));
    3982           60 :         } else if (tag == "yoffset") {
    3983            0 :             t->setYoffset(Spatium(e.readDouble()));
    3984           60 :         } else if (tag == "mag") {
    3985            0 :             t->setUserMag(e.readDouble());
    3986           60 :         } else if (tag == "small") {
    3987            0 :             t->setSmall(e.readBool());
    3988           60 :         } else if (tag == "stepOffset") {
    3989            0 :             t->setStepOffset(e.readInt());
    3990           60 :         } else if (tag == "clef") {
    3991            0 :             t->setGenClef(e.readInt());
    3992           60 :         } else if (tag == "stemless") {
    3993            2 :             bool val = e.readInt() != 0;
    3994            2 :             t->setStemless(val);
    3995            2 :             t->setShowBackTied(!val);        // for compatibility with 2.0.2 scores where this prop
    3996              :         }                                 // was lacking and controlled by "slashStyle" instead
    3997           58 :         else if (tag == "barlines") {
    3998            0 :             t->setShowBarlines(e.readInt());
    3999           58 :         } else if (tag == "timesig") {
    4000            2 :             t->setGenTimesig(e.readInt());
    4001           56 :         } else if (tag == "noteheadScheme") {
    4002            0 :             t->setNoteHeadScheme(TConv::fromXml(e.readAsciiText(), NoteHeadScheme::HEAD_NORMAL));
    4003           56 :         } else if (tag == "instrumentLabelVisibility") {
    4004            0 :             t->setInstrumentLabelVisibility(TConv::fromXml(e.readAsciiText(), InstrumentLabelVisibility::AUTO));
    4005           56 :         } else if (tag == "keysig") {
    4006            0 :             t->setGenKeysig(e.readInt());
    4007           56 :         } else if (tag == "ledgerlines") {
    4008            0 :             t->setShowLedgerLines(e.readInt());
    4009           56 :         } else if (tag == "invisible") {
    4010            0 :             t->setInvisible(e.readInt());
    4011           56 :         } else if (tag == "color") {
    4012            0 :             t->setColor(e.readColor());
    4013           56 :         } else if (tag == "durations") {
    4014            2 :             t->setGenDurations(e.readBool());
    4015           54 :         } else if (tag == "durationFontName") {
    4016            2 :             t->setDurationFontName(e.readText());
    4017           52 :         } else if (tag == "durationFontSize") {
    4018            2 :             t->setDurationFontSize(e.readDouble());
    4019           50 :         } else if (tag == "durationFontY") {
    4020            2 :             t->setDurationFontUserY(e.readDouble());
    4021           48 :         } else if (tag == "fretPresetIdx") {
    4022            2 :             t->setFretPresetIdx(e.readInt());
    4023           46 :         } else if (tag == "fretFontSize") {
    4024            2 :             t->setFretFontSize(e.readDouble());
    4025           44 :         } else if (tag == "fretFontY") {
    4026            2 :             t->setFretFontUserY(e.readDouble());
    4027           42 :         } else if (tag == "fretUseTextStyle") {
    4028            2 :             t->setFretUseTextStyle(e.readBool());
    4029           40 :         } else if (tag == "fretTextStyle") {
    4030            0 :             t->setFretTextStyle(TextStyleType(TConv::fromXml(e.readAsciiText(), TextStyleType::TAB_FRET_NUMBER)));
    4031           40 :         } else if (tag == "jianpuTextStyle") {
    4032           20 :             t->setJianpuTextStyle(TextStyleType(TConv::fromXml(e.readAsciiText(), TextStyleType::JIANPU_NUMBER)));
    4033           20 :         } else if (tag == "symbolRepeat") {
    4034            2 :             t->setSymbolRepeat((TablatureSymbolRepeat)e.readInt());
    4035           18 :         } else if (tag == "linesThrough") {
    4036            2 :             t->setLinesThrough(e.readBool());
    4037           16 :         } else if (tag == "minimStyle") {
    4038            2 :             t->setMinimStyle((TablatureMinimStyle)e.readInt());
    4039           14 :         } else if (tag == "onLines") {
    4040            2 :             t->setOnLines(e.readBool());
    4041           12 :         } else if (tag == "showRests") {
    4042            2 :             t->setShowRests(e.readBool());
    4043           10 :         } else if (tag == "stemsDown") {
    4044            2 :             t->setStemsDown(e.readBool());
    4045            8 :         } else if (tag == "stemsThrough") {
    4046            2 :             t->setStemsThrough(e.readBool());
    4047            6 :         } else if (tag == "upsideDown") {
    4048            2 :             t->setUpsideDown(e.readBool());
    4049            4 :         } else if (tag == "showTabFingering") {
    4050            0 :             t->setShowTabFingering(e.readBool());
    4051            4 :         } else if (tag == "useNumbers") {
    4052            2 :             t->setUseNumbers(e.readBool());
    4053            2 :         } else if (tag == "showBackTied") {           // must be after reading "slashStyle"/"stemless" prop, as in older
    4054            2 :             t->setShowBackTied(e.readBool());            // scores, this prop was lacking and controlled by "slashStyle"
    4055              :         } else {
    4056            0 :             e.unknown();
    4057              :         }
    4058              :     }
    4059          538 : }
    4060              : 
    4061            0 : void TRead::read(StaffTypeChange* c, XmlReader& e, ReadContext& ctx)
    4062              : {
    4063            0 :     while (e.readNextStartElement()) {
    4064            0 :         const AsciiStringView tag(e.name());
    4065            0 :         if (tag == "StaffType") {
    4066            0 :             StaffType* st = new StaffType();
    4067            0 :             TRead::read(st, e, ctx);
    4068              :             // Measure::add() will replace this with a pointer to a copy in the staff
    4069            0 :             c->setStaffType(st, true);
    4070            0 :         } else if (!readItemProperties(c, e, ctx)) {
    4071            0 :             e.unknown();
    4072              :         }
    4073              :     }
    4074            0 : }
    4075              : 
    4076          538 : void TRead::read(Staff* s, XmlReader& e, ReadContext& ctx)
    4077              : {
    4078         2289 :     while (e.readNextStartElement()) {
    4079         1213 :         if (!readProperties(s, e, ctx)) {
    4080            0 :             e.unknown();
    4081              :         }
    4082              :     }
    4083          538 : }
    4084              : 
    4085         1213 : bool TRead::readProperties(Staff* s, XmlReader& e, ReadContext& ctx)
    4086              : {
    4087         1213 :     const AsciiStringView tag(e.name());
    4088         1213 :     if (tag == "StaffType") {
    4089          538 :         StaffType st;
    4090          538 :         TRead::read(&st, e, ctx);
    4091          538 :         s->setStaffType(Fraction(0, 1), st);
    4092         1213 :     } else if (tag == "defaultClef") {           // sets both default transposing and concert clef
    4093           15 :         ClefType ct = TConv::fromXml(e.readAsciiText(), ClefType::G);
    4094           15 :         s->setDefaultClefType(ClefTypeList(ct, ct));
    4095          660 :     } else if (tag == "defaultConcertClef") {
    4096            0 :         s->setDefaultClefType(ClefTypeList(TConv::fromXml(e.readAsciiText(), ClefType::G), s->defaultClefType().transposingClef));
    4097          660 :     } else if (tag == "defaultTransposingClef") {
    4098            0 :         s->setDefaultClefType(ClefTypeList(s->defaultClefType().concertClef, TConv::fromXml(e.readAsciiText(), ClefType::G)));
    4099          660 :     } else if (tag == "invisible") {
    4100            0 :         s->staffType(Fraction(0, 1))->setInvisible(e.readInt());              // same as: setInvisible(Fraction(0,1)), e.readInt())
    4101          660 :     } else if (tag == "hideWhenEmpty") {
    4102            0 :         s->setHideWhenEmpty(TConv::fromXml(e.readAsciiText(), AutoOnOff::AUTO));
    4103          660 :     } else if (tag == "cutaway") {
    4104            0 :         s->setCutaway(e.readInt());
    4105          660 :     } else if (tag == "showIfSystemEmpty") {
    4106            0 :         s->setShowIfEntireSystemEmpty(e.readInt());
    4107          660 :     } else if (tag == "hideSystemBarLine") {
    4108            0 :         s->setHideSystemBarLine(e.readInt());
    4109          660 :     } else if (tag == "mergeMatchingRests") {
    4110            0 :         s->setMergeMatchingRests(TConv::fromXml(e.readAsciiText(), AutoOnOff::AUTO));
    4111          660 :     } else if (tag == "isStaffVisible") {
    4112            0 :         s->setVisible(e.readBool());
    4113          660 :     } else if (tag == "keylist") {
    4114            0 :         TRead::read(&s->keyList(), e, ctx);
    4115          660 :     } else if (tag == "bracket") { // LEGACY
    4116            0 :         Color color = Color::fromString(e.attribute("color"));
    4117            0 :         int col = e.intAttribute("col", -1);
    4118            0 :         if (col == -1) {
    4119            0 :             col = static_cast<int>(ctx.score()->brackets(s->idx()).size());
    4120              :         }
    4121            0 :         EditStaffBrackets::setBracketType(ctx.score(), s->idx(), col, BracketType(e.intAttribute("type", -1)));
    4122            0 :         EditStaffBrackets::setBracketSpan(ctx.score(), s->idx(), col, e.intAttribute("span", 0));
    4123            0 :         EditStaffBrackets::setBracketVisible(ctx.score(), s->idx(), col, static_cast<bool>(e.intAttribute("visible", 1)));
    4124            0 :         BracketItem* bi = ctx.score()->brackets(s->idx()).at(col);
    4125            0 :         if (color.isValid()) {
    4126            0 :             bi->setColor(color);
    4127              :         }
    4128            0 :         e.readNext();
    4129          660 :     } else if (tag == "BracketItem") {
    4130           80 :         BracketItem* b = Factory::createBracketItem(s);
    4131           80 :         b->setStartStaffIdx(s->idx());
    4132           80 :         read(b, e, ctx);
    4133           80 :         EditStaffBrackets::insertBracket(ctx.score(), s->idx(), b);
    4134          580 :     } else if (tag == "barLineSpan") {
    4135           73 :         const int barLineSpan = e.readInt();
    4136           73 :         if (barLineSpan < 0) {
    4137            0 :             LOGW() << "barLineSpan is negative: " << barLineSpan;
    4138            0 :             s->setBarLineSpan(false);
    4139           73 :         } else if (barLineSpan > 1) {
    4140            0 :             LOGW() << "barLineSpan is > 1: " << barLineSpan;
    4141            0 :             s->setBarLineSpan(true);
    4142              :         } else {
    4143           73 :             s->setBarLineSpan(static_cast<bool>(barLineSpan));
    4144              :         }
    4145          507 :     } else if (tag == "barLineSpanFrom") {
    4146            0 :         s->setBarLineFrom(e.readInt());
    4147          507 :     } else if (tag == "barLineSpanTo") {
    4148            0 :         s->setBarLineTo(e.readInt());
    4149          507 :     } else if (tag == "distOffset") {
    4150            0 :         s->setUserDist(Spatium(e.readDouble()));
    4151          507 :     } else if (tag == "mag") {
    4152              :         /*_userMag =*/
    4153            0 :         e.readDouble(0.1, 10.0);
    4154          507 :     } else if (tag == "eid") {
    4155          407 :         readItemEID(s, e, ctx);
    4156          100 :     } else if (tag == "linkedTo") {
    4157          100 :         readItemLink(s, e, ctx);
    4158            0 :     } else if (tag == "color") {
    4159            0 :         s->staffType(Fraction(0, 1))->setColor(e.readColor());
    4160            0 :     } else if (tag == "transposeDiatonic") {
    4161            0 :         ctx.setTransposeDiatonic(static_cast<int8_t>(e.readInt()));
    4162            0 :     } else if (tag == "transposeChromatic") {
    4163            0 :         ctx.setTransposeChromatic(static_cast<int8_t>(e.readInt()));
    4164            0 :     } else if (tag == "playbackVoice1") {
    4165            0 :         s->setPlaybackVoice(0, e.readInt());
    4166            0 :     } else if (tag == "playbackVoice2") {
    4167            0 :         s->setPlaybackVoice(1, e.readInt());
    4168            0 :     } else if (tag == "playbackVoice3") {
    4169            0 :         s->setPlaybackVoice(2, e.readInt());
    4170            0 :     } else if (tag == "playbackVoice4") {
    4171            0 :         s->setPlaybackVoice(3, e.readInt());
    4172            0 :     } else if (TRead::readProperty(s, tag, e, ctx, Pid::SHOW_MEASURE_NUMBERS)) {
    4173              :     } else {
    4174            0 :         return false;
    4175              :     }
    4176         1213 :     return true;
    4177              : }
    4178              : 
    4179           80 : void TRead::read(BracketItem* b, XmlReader& xml, ReadContext& ctx)
    4180              : {
    4181          320 :     while (xml.readNextStartElement()) {
    4182          240 :         const AsciiStringView& tag = xml.name();
    4183          240 :         if (tag == "type") {
    4184           80 :             b->setBracketType(TConv::fromXml(xml.readAsciiText(), BracketType::NORMAL));
    4185          160 :         } else if (readProperty(b, tag, xml, ctx, Pid::BRACKET_SPAN)) {
    4186           80 :         } else if (tag == "level") {
    4187           80 :             b->setColumn(xml.readInt());
    4188            0 :         } else if (readProperty(b, tag, xml, ctx, Pid::VISIBLE)) {
    4189            0 :         } else if (readProperty(b, tag, xml, ctx, Pid::GROUP_BRACKET_SHOW_TEXT)) {
    4190            0 :         } else if (readProperty(b, tag, xml, ctx, Pid::GROUP_BRACKET_SHOW_BRACKET)) {
    4191            0 :         } else if (tag == "StaffLabel") {
    4192            0 :             StaffLabel& label = b->label();
    4193            0 :             readStaffLabel(label, xml);
    4194              :         } else {
    4195            0 :             xml.unknown();
    4196              :         }
    4197              :     }
    4198           80 : }
    4199              : 
    4200         2357 : String TRead::readLegacyStaffName(XmlReader& xml)
    4201              : {
    4202         2357 :     String name = lineBreakFromTag(xml.readXml());
    4203         2357 :     if (name.startsWith(u"<html>")) {
    4204              :         // compatibility to old html implementation:
    4205            0 :         name = HtmlParser::parse(name);
    4206              :     }
    4207         2357 :     return name;
    4208            0 : }
    4209              : 
    4210            0 : void TRead::readStaffLabel(StaffLabel& item, XmlReader& xml)
    4211              : {
    4212            0 :     while (xml.readNextStartElement()) {
    4213            0 :         if (!readProperties(item, xml)) {
    4214            0 :             xml.unknown();
    4215              :         }
    4216              :     }
    4217            0 : }
    4218              : 
    4219          847 : bool TRead::readProperties(StaffLabel& item, XmlReader& xml)
    4220              : {
    4221          847 :     AsciiStringView tag = xml.name();
    4222              : 
    4223          847 :     if (tag == "longName") {
    4224          400 :         item.setLongName(lineBreakFromTag(xml.readXml()));
    4225          447 :     } else if (tag == "shortName") {
    4226          394 :         item.setShortName(lineBreakFromTag(xml.readXml()));
    4227              :     } else {
    4228           53 :         return false;
    4229              :     }
    4230              : 
    4231          794 :     return true;
    4232              : }
    4233              : 
    4234          400 : void TRead::readInstrumentLabel(InstrumentLabel& item, XmlReader& xml)
    4235              : {
    4236         1647 :     while (xml.readNextStartElement()) {
    4237          847 :         if (!readProperties(item, xml)) {
    4238            0 :             xml.unknown();
    4239              :         }
    4240              :     }
    4241          400 : }
    4242              : 
    4243          847 : bool TRead::readProperties(InstrumentLabel& item, XmlReader& xml)
    4244              : {
    4245          847 :     AsciiStringView tag = xml.name();
    4246              : 
    4247          847 :     if (readProperties(static_cast<StaffLabel&>(item), xml)) {
    4248           53 :     } else if (tag == "transposition") {
    4249            0 :         item.setTransposition(lineBreakFromTag(xml.readXml()));
    4250           53 :     } else if (tag == "showTranspositionLong") {
    4251            0 :         item.setShowTranspositionLong(xml.readBool());
    4252           53 :     } else if (tag == "showTranspositionShort") {
    4253            0 :         item.setShowTranspositionShort(xml.readBool());
    4254           53 :     } else if (tag == "number") {
    4255           42 :         item.setNumber(xml.readInt());
    4256           11 :     } else if (tag == "showNumberLong") {
    4257            4 :         item.setShowNumberLong(xml.readBool());
    4258            7 :     } else if (tag == "showNumberShort") {
    4259            3 :         item.setShowNumberShort(xml.readBool());
    4260            4 :     } else if (tag == "useCustomName") {
    4261            0 :         item.setUseCustomName(xml.readBool());
    4262            4 :     } else if (tag == "customNameLong") {
    4263            0 :         item.setCustomNameLong(lineBreakFromTag(xml.readXml()));
    4264            4 :     } else if (tag == "customNameShort") {
    4265            0 :         item.setCustomNameShort(lineBreakFromTag(xml.readXml()));
    4266            4 :     } else if (tag == "allowGroupName") {
    4267            4 :         item.setAllowGroupName(xml.readBool());
    4268            0 :     } else if (tag == "customNameLongGroup") {
    4269            0 :         item.setCustomNameLongGroup(lineBreakFromTag(xml.readXml()));
    4270            0 :     } else if (tag == "customNameShortGroup") {
    4271            0 :         item.setCustomNameShortGroup(lineBreakFromTag(xml.readXml()));
    4272            0 :     } else if (tag == "useCustomGroupName") {
    4273            0 :         item.setUseCustomGroupName(xml.readBool());
    4274            0 :     } else if (tag == "customNameLongIndividual") {
    4275            0 :         item.setCustomNameLongIndividual(lineBreakFromTag(xml.readXml()));
    4276            0 :     } else if (tag == "customNameShortIndividual") {
    4277            0 :         item.setCustomNameShortIndividual(lineBreakFromTag(xml.readXml()));
    4278            0 :     } else if (tag == "useCustomIndividualName") {
    4279            0 :         item.setUseCustomIndividualName(xml.readBool());
    4280              :     } else {
    4281            0 :         return false;
    4282              :     }
    4283              : 
    4284          847 :     return true;
    4285              : }
    4286              : 
    4287            0 : void TRead::read(Stem* s, XmlReader& e, ReadContext& ctx)
    4288              : {
    4289            0 :     while (e.readNextStartElement()) {
    4290            0 :         if (!TRead::readProperties(s, e, ctx)) {
    4291            0 :             e.unknown();
    4292              :         }
    4293              :     }
    4294            0 : }
    4295              : 
    4296            0 : bool TRead::readProperties(Stem* s, XmlReader& e, ReadContext& ctx)
    4297              : {
    4298            0 :     const AsciiStringView tag(e.name());
    4299              : 
    4300            0 :     if (TRead::readProperty(s, tag, e, ctx, Pid::USER_LEN)) {
    4301            0 :     } else if (TRead::readStyledProperty(s, tag, e, ctx)) {
    4302            0 :     } else if (readItemProperties(s, e, ctx)) {
    4303              :     } else {
    4304            0 :         return false;
    4305              :     }
    4306            0 :     return true;
    4307              : }
    4308              : 
    4309            0 : void TRead::read(StemSlash* s, XmlReader& e, ReadContext& ctx)
    4310              : {
    4311            0 :     while (e.readNextStartElement()) {
    4312            0 :         if (!readItemProperties(s, e, ctx)) {
    4313            0 :             e.unknown();
    4314              :         }
    4315              :     }
    4316            0 : }
    4317              : 
    4318            2 : void TRead::read(StringData* item, XmlReader& e)
    4319              : {
    4320            2 :     item->stringList().clear();
    4321           16 :     while (e.readNextStartElement()) {
    4322           14 :         const AsciiStringView tag(e.name());
    4323           14 :         if (tag == "frets") {
    4324            2 :             item->setFrets(e.readInt());
    4325           12 :         } else if (tag == "string") {
    4326           12 :             instrString strg;
    4327           12 :             strg.open  = e.intAttribute("open", 0);
    4328           12 :             strg.useFlat = e.intAttribute("useFlat", 0);
    4329           12 :             strg.pitch = e.readInt();
    4330           12 :             item->stringList().push_back(strg);
    4331              :         } else {
    4332            0 :             e.unknown();
    4333              :         }
    4334              :     }
    4335            2 :     if (item->isFiveStringBanjo()) {
    4336            0 :         item->configBanjo5thString();
    4337              :     }
    4338            2 : }
    4339              : 
    4340            0 : void TRead::read(StringTunings* s, XmlReader& xml, ReadContext& ctx)
    4341              : {
    4342            0 :     while (xml.readNextStartElement()) {
    4343            0 :         const AsciiStringView tag(xml.name());
    4344              : 
    4345            0 :         if (tag == "preset") {
    4346            0 :             s->setPreset(xml.readText());
    4347            0 :         } else if (tag == "StringData") {
    4348            0 :             StringData sd;
    4349            0 :             read(&sd, xml);
    4350            0 :             s->setStringData(sd);
    4351            0 :         } else if (tag == "visibleStrings") {
    4352            0 :             s->setVisibleStrings(TConv::fromXml(xml.readText(), std::vector<string_idx_t>()));
    4353            0 :         } else if (!readProperties(static_cast<StaffTextBase*>(s), xml, ctx)) {
    4354            0 :             xml.unknown();
    4355              :         }
    4356              :     }
    4357            0 : }
    4358              : 
    4359            0 : void TRead::read(System* s, XmlReader& e, ReadContext& ctx)
    4360              : {
    4361            0 :     while (e.readNextStartElement()) {
    4362            0 :         const AsciiStringView tag(e.name());
    4363            0 :         if (tag == "SystemDivider") {
    4364            0 :             SystemDivider* sd = new SystemDivider(s);
    4365            0 :             TRead::read(sd, e, ctx);
    4366            0 :             s->add(sd);
    4367              :         } else {
    4368            0 :             e.unknown();
    4369              :         }
    4370              :     }
    4371            0 : }
    4372              : 
    4373          486 : void TRead::read(Text* t, XmlReader& e, ReadContext& ctx)
    4374              : {
    4375         1907 :     while (e.readNextStartElement()) {
    4376         1421 :         const AsciiStringView tag(e.name());
    4377         1421 :         if (tag == "style") {
    4378          486 :             TextStyleType s = TConv::fromXml(e.readAsciiText(), TextStyleType::DEFAULT);
    4379          486 :             if (TextStyleType::TUPLET == s) {  // ugly hack for compatibility
    4380          141 :                 continue;
    4381              :             }
    4382          345 :             t->initTextStyleType(s);
    4383          935 :         } else if (!readProperties(toTextBase(t), e, ctx)) {
    4384            0 :             e.unknown();
    4385              :         }
    4386              :     }
    4387          486 : }
    4388              : 
    4389           37 : void TRead::read(TextLine* l, XmlReader& e, ReadContext& ctx)
    4390              : {
    4391           37 :     bool system =  e.intAttribute("system", 0) == 1;
    4392           37 :     l->setSystemFlag(system);
    4393           37 :     l->initStyle();
    4394           37 :     TRead::read(toTextLineBase(l), e, ctx);
    4395           37 : }
    4396              : 
    4397          129 : void TRead::read(TextLineBase* b, XmlReader& e, ReadContext& ctx)
    4398              : {
    4399          129 :     b->eraseSpannerSegments();
    4400              : 
    4401          994 :     while (e.readNextStartElement()) {
    4402          736 :         if (!readProperties(b, e, ctx)) {
    4403            0 :             e.unknown();
    4404              :         }
    4405              :     }
    4406          129 :     if (ctx.mscVersion() < 470) {
    4407            0 :         compat::CompatUtils::setTextLineTextPositionFromAlign(b);
    4408              :     }
    4409          129 : }
    4410              : 
    4411           34 : void TRead::read(Tie* t, XmlReader& xml, ReadContext& ctx)
    4412              : {
    4413          170 :     while (xml.readNextStartElement()) {
    4414          136 :         AsciiStringView tag = xml.name();
    4415          136 :         if (TRead::readProperty(t, tag, xml, ctx, Pid::TIE_PLACEMENT)) {
    4416          136 :         } else if (!readProperties(toSlurTie(t), xml, ctx)) {
    4417            0 :             xml.unknown();
    4418              :         }
    4419              :     }
    4420           34 : }
    4421              : 
    4422          530 : void TRead::read(TimeSig* s, XmlReader& e, ReadContext& ctx)
    4423              : {
    4424          530 :     int n=0, z1=0, z2=0, z3=0, z4=0;
    4425          530 :     bool old = false;
    4426              : 
    4427          530 :     TimeSigType timeSigType = TimeSigType::NORMAL;
    4428          530 :     Fraction sig;
    4429          530 :     Fraction stretch(1, 1);
    4430          530 :     String numeratorString;
    4431          530 :     String denominatorString;
    4432              : 
    4433         2072 :     while (e.readNextStartElement()) {
    4434         1542 :         const AsciiStringView tag(e.name());
    4435              : 
    4436         1542 :         if (tag == "den") {
    4437            0 :             old = true;
    4438            0 :             n = e.readInt();
    4439         1542 :         } else if (tag == "nom1") {
    4440            0 :             old = true;
    4441            0 :             z1 = e.readInt();
    4442         1542 :         } else if (tag == "nom2") {
    4443            0 :             old = true;
    4444            0 :             z2 = e.readInt();
    4445         1542 :         } else if (tag == "nom3") {
    4446            0 :             old = true;
    4447            0 :             z3 = e.readInt();
    4448         1542 :         } else if (tag == "nom4") {
    4449            0 :             old = true;
    4450            0 :             z4 = e.readInt();
    4451         1542 :         } else if (tag == "subtype") {
    4452            0 :             timeSigType = TimeSigType(e.readInt());
    4453         1542 :         } else if (tag == "showCourtesySig") {
    4454            0 :             s->setShowCourtesySig(e.readInt());
    4455         1542 :         } else if (tag == "sigN") {
    4456          530 :             sig.setNumerator(e.readInt());
    4457         1012 :         } else if (tag == "sigD") {
    4458          530 :             sig.setDenominator(e.readInt());
    4459          482 :         } else if (tag == "stretchN") {
    4460            1 :             stretch.setNumerator(e.readInt());
    4461          481 :         } else if (tag == "stretchD") {
    4462            1 :             stretch.setDenominator(e.readInt());
    4463          480 :         } else if (tag == "textN") {
    4464            0 :             numeratorString = e.readText();
    4465          480 :         } else if (tag == "textD") {
    4466            0 :             denominatorString = e.readText();
    4467          480 :         } else if (tag == "Groups") {
    4468            0 :             Groups groups;
    4469            0 :             TRead::read(&groups, e, ctx);
    4470            0 :             s->setGroups(groups);
    4471          480 :         } else if (tag == "isCourtesy") {
    4472            0 :             s->setIsCourtesy(e.readBool());
    4473          480 :         } else if (TRead::readStyledProperty(s, tag, e, ctx)) {
    4474          480 :         } else if (!readItemProperties(s, e, ctx)) {
    4475            0 :             e.unknown();
    4476              :         }
    4477              :     }
    4478          530 :     if (old) {
    4479            0 :         sig.set(z1 + z2 + z3 + z4, n);
    4480              :     }
    4481          530 :     stretch.reduce();
    4482              : 
    4483          530 :     s->setSig(sig, timeSigType);
    4484          530 :     s->setStretch(stretch);
    4485          530 :     s->setNumeratorString(numeratorString);
    4486          530 :     s->setDenominatorString(denominatorString);
    4487          530 : }
    4488              : 
    4489            3 : void TRead::read(TremoloTwoChord* t, XmlReader& xml, ReadContext& ctx)
    4490              : {
    4491            3 :     compat::TremoloCompat tc { parentOrDummy(t->chord(), ctx.dummy()) };
    4492            3 :     tc.two = t;
    4493            3 :     read(&tc, xml, ctx);
    4494            3 : }
    4495              : 
    4496           18 : void TRead::read(TremoloSingleChord* t, XmlReader& xml, ReadContext& ctx)
    4497              : {
    4498           18 :     compat::TremoloCompat tc { parentOrDummy(t->chord(), ctx.dummy()) };
    4499           18 :     tc.single = t;
    4500           18 :     read(&tc, xml, ctx);
    4501           18 : }
    4502              : 
    4503           21 : void TRead::read(compat::TremoloCompat* tc, XmlReader& e, ReadContext& ctx)
    4504              : {
    4505           88 :     auto item = [](compat::TremoloCompat* tc) -> EngravingItem* {
    4506           88 :         if (tc->two) {
    4507           18 :             return tc->two;
    4508              :         }
    4509           70 :         return tc->single;
    4510              :     };
    4511              : 
    4512           21 :     const Chord* chord = tc->parent.as<Chord>();
    4513           21 :     const track_idx_t track = chord ? chord->track() : 0;
    4514              : 
    4515           86 :     while (e.readNextStartElement()) {
    4516           65 :         const AsciiStringView tag(e.name());
    4517           65 :         if (tag == "subtype") {
    4518           21 :             TremoloType type = TConv::fromXml(e.readAsciiText(), TremoloType::INVALID_TREMOLO);
    4519           21 :             if (isTremoloTwoChord(type)) {
    4520            3 :                 if (!tc->two) {
    4521            0 :                     tc->two = Factory::createTremoloTwoChord(tc->parent);
    4522            0 :                     tc->two->setTrack(track);
    4523              :                 }
    4524            3 :                 tc->two->setTremoloType(type);
    4525              :             } else {
    4526           18 :                 if (!tc->single) {
    4527            0 :                     tc->single = Factory::createTremoloSingleChord(tc->parent);
    4528            0 :                     tc->single->setTrack(track);
    4529              :                 }
    4530           18 :                 tc->single->setTremoloType(type);
    4531              :             }
    4532              :         }
    4533              :         // Style needs special handling other than readStyledProperty()
    4534              :         // to avoid calling customStyleApplicable() in setProperty(),
    4535              :         // which cannot be called now because durationType() isn't defined yet.
    4536           44 :         else if (tag == "strokeStyle") {
    4537            0 :             if (tc->two) {
    4538            0 :                 tc->two->setTremoloStyle(TremoloStyle(e.readInt()));
    4539            0 :                 tc->two->setPropertyFlags(Pid::TREMOLO_STYLE, PropertyFlags::UNSTYLED);
    4540              :             } else {
    4541            0 :                 UNREACHABLE;
    4542              :                 e.skipCurrentElement();
    4543              :             }
    4544           44 :         } else if (tag == "Fragment") {
    4545            0 :             if (tc->two) {
    4546            0 :                 BeamFragment f = BeamFragment();
    4547            0 :                 int idx = tc->two->directionIdx();
    4548            0 :                 tc->two->setUserModified(true);
    4549            0 :                 double _spatium = tc->two->spatium();
    4550            0 :                 while (e.readNextStartElement()) {
    4551            0 :                     const AsciiStringView tag1(e.name());
    4552            0 :                     if (tag1 == "y1") {
    4553            0 :                         f.py1[idx] = e.readDouble() * _spatium;
    4554            0 :                     } else if (tag1 == "y2") {
    4555            0 :                         f.py2[idx] = e.readDouble() * _spatium;
    4556              :                     } else {
    4557            0 :                         e.unknown();
    4558              :                     }
    4559              :                 }
    4560            0 :                 tc->two->setBeamFragment(f);
    4561              :             } else {
    4562            0 :                 UNREACHABLE;
    4563              :                 e.skipCurrentElement();
    4564              :             }
    4565           44 :         } else if (tag == "play") {
    4566            0 :             if (tc->two) {
    4567            0 :                 tc->two->setPlayTremolo(e.readBool());
    4568            0 :             } else if (tc->single) {
    4569            0 :                 tc->single->setPlayTremolo(e.readBool());
    4570              :             } else {
    4571            0 :                 UNREACHABLE;
    4572              :             }
    4573           44 :         } else if (TRead::readStyledProperty(item(tc), tag, e, ctx)) {
    4574           44 :         } else if (!readItemProperties(item(tc), e, ctx)) {
    4575            6 :             e.unknown();
    4576              :         }
    4577              :     }
    4578           21 : }
    4579              : 
    4580              : static constexpr std::array<Pid, 18> TextBasePropertyId { {
    4581              :     Pid::TEXT_STYLE,
    4582              :     Pid::FONT_FACE,
    4583              :     Pid::FONT_SIZE,
    4584              :     Pid::TEXT_LINE_SPACING,
    4585              :     Pid::FONT_STYLE,
    4586              :     Pid::COLOR,
    4587              :     Pid::FRAME_TYPE,
    4588              :     Pid::FRAME_WIDTH,
    4589              :     Pid::FRAME_PADDING,
    4590              :     Pid::FRAME_ROUND,
    4591              :     Pid::FRAME_FG_COLOR,
    4592              :     Pid::FRAME_BG_COLOR,
    4593              :     Pid::ALIGN,
    4594              :     Pid::POSITION,
    4595              : } };
    4596              : 
    4597            0 : bool TRead::readTextProperties(TextBase* t, XmlReader& xml, ReadContext& ctx)
    4598              : {
    4599            0 :     if (t->isStaffTextBase()) {
    4600            0 :         return readProperties(dynamic_cast<StaffTextBase*>(t), xml, ctx);
    4601              :     }
    4602            0 :     return readProperties(t, xml, ctx);
    4603              : }
    4604              : 
    4605         1753 : bool TRead::readProperties(TextBase* t, XmlReader& e, ReadContext& ctx)
    4606              : {
    4607         1753 :     const AsciiStringView tag(e.name());
    4608        33023 :     for (Pid i : TextBasePropertyId) {
    4609        31286 :         if (TRead::readProperty(t, tag, e, ctx, i)) {
    4610           16 :             if (ctx.mscVersion() >= 470 || tag != "align" || t->isMarker() || t->isJump() || t->isHarmony()) {
    4611           16 :                 return true;
    4612              :             }
    4613              : 
    4614            0 :             t->setPosition(t->align().horizontal);
    4615            0 :             if (t->position() != t->propertyDefault(Pid::POSITION).value<AlignH>()) {
    4616            0 :                 t->setPropertyFlags(Pid::POSITION, PropertyFlags::UNSTYLED);
    4617              :             }
    4618            0 :             return true;
    4619              :         }
    4620              :     }
    4621              : 
    4622         1737 :     if (tag == "text") {
    4623          814 :         String str = lineBreakFromTag(e.readXml());
    4624          814 :         t->setXmlText(str);
    4625          814 :         t->checkCustomFormatting(str);
    4626         1737 :     } else if (tag == "bold") {
    4627            0 :         bool val = e.readInt();
    4628            0 :         if (val) {
    4629            0 :             t->setFontStyle(t->fontStyle() + FontStyle::Bold);
    4630              :         } else {
    4631            0 :             t->setFontStyle(t->fontStyle() - FontStyle::Bold);
    4632              :         }
    4633            0 :         if (t->isStyled(Pid::FONT_STYLE)) {
    4634            0 :             t->setPropertyFlags(Pid::FONT_STYLE, PropertyFlags::UNSTYLED);
    4635              :         }
    4636          923 :     } else if (tag == "italic") {
    4637            0 :         bool val = e.readInt();
    4638            0 :         if (val) {
    4639            0 :             t->setFontStyle(t->fontStyle() + FontStyle::Italic);
    4640              :         } else {
    4641            0 :             t->setFontStyle(t->fontStyle() - FontStyle::Italic);
    4642              :         }
    4643            0 :         if (t->isStyled(Pid::FONT_STYLE)) {
    4644            0 :             t->setPropertyFlags(Pid::FONT_STYLE, PropertyFlags::UNSTYLED);
    4645              :         }
    4646          923 :     } else if (tag == "underline") {
    4647            0 :         bool val = e.readInt();
    4648            0 :         if (val) {
    4649            0 :             t->setFontStyle(t->fontStyle() + FontStyle::Underline);
    4650              :         } else {
    4651            0 :             t->setFontStyle(t->fontStyle() - FontStyle::Underline);
    4652              :         }
    4653            0 :         if (t->isStyled(Pid::FONT_STYLE)) {
    4654            0 :             t->setPropertyFlags(Pid::FONT_STYLE, PropertyFlags::UNSTYLED);
    4655              :         }
    4656          923 :     } else if (tag == "strike") {
    4657            0 :         bool val = e.readInt();
    4658            0 :         if (val) {
    4659            0 :             t->setFontStyle(t->fontStyle() + FontStyle::Strike);
    4660              :         } else {
    4661            0 :             t->setFontStyle(t->fontStyle() - FontStyle::Strike);
    4662              :         }
    4663            0 :         if (t->isStyled(Pid::FONT_STYLE)) {
    4664            0 :             t->setPropertyFlags(Pid::FONT_STYLE, PropertyFlags::UNSTYLED);
    4665              :         }
    4666          923 :     } else if (TRead::readProperty(t, tag, e, ctx, Pid::TEXT_LINKED_TO_MASTER)) {
    4667          923 :     } else if (readProperty(t, tag, e, ctx, Pid::VOICE_ASSIGNMENT)) {
    4668          921 :     } else if (readProperty(t, tag, e, ctx, Pid::DIRECTION)) {
    4669          911 :     } else if (readProperty(t, tag, e, ctx, Pid::CENTER_BETWEEN_STAVES)) {
    4670          910 :     } else if (readProperty(t, tag, e, ctx, Pid::MUSIC_SYMBOL_SIZE)) {
    4671          910 :     } else if (readProperty(t, tag, e, ctx, Pid::MUSICAL_SYMBOLS_SCALE)) {
    4672          908 :     } else if (!readItemProperties(t, e, ctx)) {
    4673            0 :         return false;
    4674              :     }
    4675         1737 :     return true;
    4676              : }
    4677              : 
    4678         2483 : bool TRead::readProperties(TextLineBase* b, XmlReader& e, ReadContext& ctx)
    4679              : {
    4680         2483 :     const AsciiStringView tag(e.name());
    4681        97084 :     for (Pid i : TextLineBase::textLineBasePropertyIds()) {
    4682        95316 :         if (TRead::readProperty(b, tag, e, ctx, i)) {
    4683          715 :             return true;
    4684              :         }
    4685              :     }
    4686         1768 :     return readProperties(static_cast<SLine*>(b), e, ctx);
    4687              : }
    4688              : 
    4689            2 : void TRead::read(Trill* t, XmlReader& e, ReadContext& ctx)
    4690              : {
    4691            2 :     t->eraseSpannerSegments();
    4692              : 
    4693           16 :     while (e.readNextStartElement()) {
    4694           14 :         const AsciiStringView tag(e.name());
    4695           14 :         if (tag == "subtype") {
    4696            2 :             t->setTrillType(TConv::fromXml(e.readAsciiText(), TrillType::TRILL_LINE));
    4697           12 :         } else if (tag == "Ornament") {
    4698            1 :             Ornament* ornament = t->ornament();
    4699            1 :             if (!ornament) {
    4700            0 :                 ornament = Factory::createOrnament(toChordRest(t->ownershipParent()));
    4701            0 :                 t->setOrnament(ornament);
    4702              :             }
    4703            1 :             ornament->setSymId(Ornament::fromTrillType(t->trillType()));
    4704            1 :             TRead::read(ornament, e, ctx);
    4705            1 :             ornament->setTrack(t->track());
    4706           11 :         } else if (tag == "Accidental") {
    4707            0 :             Accidental* accidental = Factory::createAccidental(t);
    4708            0 :             TRead::read(accidental, e, ctx);
    4709            0 :             t->setAccidental(accidental);
    4710            0 :             if (t->ornament()) {
    4711            0 :                 t->ornament()->setTrillOldCompatAccidental(accidental);
    4712              :             }
    4713           11 :         } else if (tag == "ornamentStyle") {
    4714            0 :             readProperty(t, e, ctx, Pid::ORNAMENT_STYLE);
    4715           11 :         } else if (!readProperties(static_cast<SLine*>(t), e, ctx)) {
    4716            0 :             e.unknown();
    4717              :         }
    4718              :     }
    4719            2 : }
    4720              : 
    4721            1 : void TRead::read(Vibrato* v, XmlReader& e, ReadContext& ctx)
    4722              : {
    4723            1 :     v->eraseSpannerSegments();
    4724              : 
    4725            7 :     while (e.readNextStartElement()) {
    4726            6 :         const AsciiStringView tag(e.name());
    4727            6 :         if (tag == "subtype") {
    4728            1 :             v->setVibratoType(TConv::fromXml(e.readAsciiText(), VibratoType::GUITAR_VIBRATO));
    4729            5 :         } else if (!readProperties(static_cast<SLine*>(v), e, ctx)) {
    4730            0 :             e.unknown();
    4731              :         }
    4732              :     }
    4733            1 : }
    4734              : 
    4735           43 : void TRead::read(Volta* v, XmlReader& e, ReadContext& ctx)
    4736              : {
    4737           43 :     v->eraseSpannerSegments();
    4738              : 
    4739          287 :     while (e.readNextStartElement()) {
    4740          244 :         const AsciiStringView tag(e.name());
    4741          244 :         if (tag == "endings") {
    4742           43 :             v->setEndings(TConv::fromXml(e.readText(), std::vector<int>()));
    4743          201 :         } else if (!readProperties(v, e, ctx)) {
    4744            0 :             e.unknown();
    4745              :         }
    4746              :     }
    4747           43 :     if (ctx.mscVersion() < 470) {
    4748            0 :         compat::CompatUtils::setTextLineTextPositionFromAlign(v);
    4749              :     }
    4750           43 : }
    4751              : 
    4752          201 : bool TRead::readProperties(Volta* v, XmlReader& e, ReadContext& ctx)
    4753              : {
    4754          201 :     if (!readProperties(toTextLineBase(v), e, ctx)) {
    4755            0 :         return false;
    4756              :     }
    4757              : 
    4758          201 :     return true;
    4759              : }
    4760              : 
    4761            7 : void TRead::readPageLocks(Score* score, XmlReader& e)
    4762              : {
    4763           35 :     while (e.readNextStartElement()) {
    4764           28 :         if (e.name() == "pageLock") {
    4765           28 :             readPageLock(score, e);
    4766              :         } else {
    4767            0 :             e.unknown();
    4768              :         }
    4769              :     }
    4770            7 : }
    4771              : 
    4772            0 : void TRead::readSystemLocks(Score* score, XmlReader& e)
    4773              : {
    4774            0 :     while (e.readNextStartElement()) {
    4775            0 :         if (e.name() == "systemLock") {
    4776            0 :             readSystemLock(score, e);
    4777              :         } else {
    4778            0 :             e.unknown();
    4779              :         }
    4780              :     }
    4781            0 : }
    4782              : 
    4783           28 : void TRead::readPageLock(Score* score, XmlReader& e)
    4784              : {
    4785           28 :     MeasureBase* startMeas = nullptr;
    4786           28 :     MeasureBase* endMeas = nullptr;
    4787           28 :     EIDRegister* eidRegister = score->masterScore()->eidRegister();
    4788              : 
    4789           84 :     while (e.readNextStartElement()) {
    4790           56 :         AsciiStringView tag(e.name());
    4791           56 :         if (tag == "startMeasure") {
    4792           28 :             EID startMeasId = EID::fromStdString(e.readAsciiText());
    4793           28 :             startMeas = toMeasureBase(eidRegister->itemFromEID(startMeasId));
    4794           28 :         } else if (tag == "endMeasure") {
    4795           28 :             EID endMeasId = EID::fromStdString(e.readAsciiText());
    4796           28 :             endMeas = toMeasureBase(eidRegister->itemFromEID(endMeasId));
    4797              :         } else {
    4798            0 :             e.unknown();
    4799              :         }
    4800              :     }
    4801              : 
    4802           28 :     IF_ASSERT_FAILED(startMeas && endMeas) {
    4803            0 :         return;
    4804              :     }
    4805              : 
    4806           28 :     score->addPageLock(new RangeLock(startMeas, endMeas));
    4807              : }
    4808              : 
    4809            0 : void TRead::readSystemLock(Score* score, XmlReader& e)
    4810              : {
    4811            0 :     MeasureBase* startMeas = nullptr;
    4812            0 :     MeasureBase* endMeas = nullptr;
    4813            0 :     EIDRegister* eidRegister = score->masterScore()->eidRegister();
    4814              : 
    4815            0 :     while (e.readNextStartElement()) {
    4816            0 :         AsciiStringView tag(e.name());
    4817            0 :         if (tag == "startMeasure") {
    4818            0 :             EID startMeasId = EID::fromStdString(e.readAsciiText());
    4819            0 :             startMeas = toMeasureBase(eidRegister->itemFromEID(startMeasId));
    4820            0 :         } else if (tag == "endMeasure") {
    4821            0 :             EID endMeasId = EID::fromStdString(e.readAsciiText());
    4822            0 :             endMeas = toMeasureBase(eidRegister->itemFromEID(endMeasId));
    4823              :         } else {
    4824            0 :             e.unknown();
    4825              :         }
    4826              :     }
    4827              : 
    4828            0 :     IF_ASSERT_FAILED(startMeas && endMeas) {
    4829            0 :         return;
    4830              :     }
    4831              : 
    4832            0 :     score->addSystemLock(new RangeLock(startMeas, endMeas));
    4833              : }
    4834              : 
    4835            0 : void TRead::readSystemDividers(Score* score, XmlReader& e, ReadContext& ctx)
    4836              : {
    4837            0 :     while (e.readNextStartElement()) {
    4838            0 :         if (e.name() == "system") {
    4839            0 :             size_t systemIdx = e.intAttribute("idx");
    4840            0 :             while (e.readNextStartElement()) {
    4841            0 :                 if (e.name() == "SystemDivider") {
    4842            0 :                     SystemDivider* divider = new SystemDivider(score->dummy());
    4843            0 :                     read(divider, e, ctx);
    4844            0 :                     score->addSystemDivider(systemIdx, divider);
    4845              :                 } else {
    4846            0 :                     e.unknown();
    4847              :                 }
    4848              :             }
    4849              :         } else {
    4850            0 :             e.unknown();
    4851              :         }
    4852              :     }
    4853            0 : }
        

Generated by: LCOV version 2.0-1