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) 2022 MuseScore Limited and others
9 : *
10 : * This program is free software: you can redistribute it and/or modify
11 : * it under the terms of the GNU General Public License version 3 as
12 : * published by the Free Software Foundation.
13 : *
14 : * This program is distributed in the hope that it will be useful,
15 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : * GNU General Public License for more details.
18 : *
19 : * You should have received a copy of the GNU General Public License
20 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 : */
22 :
23 : #include "braillewriter.h"
24 :
25 : #include <QBuffer>
26 :
27 : #include "notation/inotation.h"
28 : #include "notation/inotationelements.h" // IWYU pragma: keep
29 :
30 : #include "braille.h"
31 :
32 : using namespace mu::project;
33 : using namespace muse;
34 :
35 : namespace mu::engraving {
36 0 : std::vector<INotationWriter::UnitType> BrailleWriter::supportedUnitTypes() const
37 : {
38 0 : return { UnitType::PER_PART };
39 : }
40 :
41 0 : bool BrailleWriter::supportsUnitType(UnitType unitType) const
42 : {
43 0 : std::vector<UnitType> unitTypes = supportedUnitTypes();
44 0 : return std::find(unitTypes.cbegin(), unitTypes.cend(), unitType) != unitTypes.cend();
45 0 : }
46 :
47 0 : muse::Ret BrailleWriter::write(notation::INotationPtr notation, muse::io::IODevice& destinationDevice, const Options&)
48 : {
49 0 : IF_ASSERT_FAILED(notation) {
50 0 : return make_ret(Ret::Code::UnknownError);
51 : }
52 :
53 0 : mu::engraving::Score* score = notation->elements()->msScore();
54 0 : IF_ASSERT_FAILED(score) {
55 0 : return make_ret(Ret::Code::UnknownError);
56 : }
57 :
58 0 : QByteArray qdata;
59 0 : QBuffer buf(&qdata);
60 0 : buf.open(QIODevice::WriteOnly);
61 :
62 0 : Ret ret = Braille(score).write(buf);
63 0 : if (ret) {
64 0 : ByteArray data = ByteArray::fromQByteArrayNoCopy(qdata);
65 0 : destinationDevice.write(data);
66 0 : }
67 0 : return ret;
68 0 : }
69 :
70 0 : muse::Ret BrailleWriter::writeList(const notation::INotationPtrList&, muse::io::IODevice&, const Options&)
71 : {
72 0 : NOT_SUPPORTED;
73 0 : return muse::Ret(muse::Ret::Code::NotSupported);
74 : }
75 : }
|