removed QIODevice from XmlStreamWriter
This commit is contained in:
parent
e8e5a577fe
commit
5e289e4d51
7 changed files with 89 additions and 24 deletions
|
@ -106,6 +106,8 @@ set(MODULE_SRC
|
|||
${CMAKE_CURRENT_LIST_DIR}/serialization/internal/qzip.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/serialization/internal/qzipreader_p.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/serialization/internal/qzipwriter_p.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/serialization/textstream.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/serialization/textstream.h
|
||||
)
|
||||
|
||||
if (NOT NO_GLOBAL_INTERNAL)
|
||||
|
|
36
src/framework/global/serialization/textstream.cpp
Normal file
36
src/framework/global/serialization/textstream.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* SPDX-License-Identifier: GPL-3.0-only
|
||||
* MuseScore-CLA-applies
|
||||
*
|
||||
* MuseScore
|
||||
* Music Composition & Notation
|
||||
*
|
||||
* Copyright (C) 2021 MuseScore BVBA and others
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 3 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "textstream.h"
|
||||
|
||||
using namespace mu;
|
||||
|
||||
TextStream::TextStream()
|
||||
{
|
||||
}
|
||||
|
||||
TextStream::TextStream(io::IODevice* device)
|
||||
{
|
||||
}
|
||||
|
||||
TextStream::~TextStream()
|
||||
{
|
||||
}
|
37
src/framework/global/serialization/textstream.h
Normal file
37
src/framework/global/serialization/textstream.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* SPDX-License-Identifier: GPL-3.0-only
|
||||
* MuseScore-CLA-applies
|
||||
*
|
||||
* MuseScore
|
||||
* Music Composition & Notation
|
||||
*
|
||||
* Copyright (C) 2021 MuseScore BVBA and others
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 3 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef MU_GLOBAL_TEXTSTREAM_H
|
||||
#define MU_GLOBAL_TEXTSTREAM_H
|
||||
|
||||
#include "io/iodevice.h"
|
||||
|
||||
namespace mu {
|
||||
class TextStream
|
||||
{
|
||||
public:
|
||||
TextStream();
|
||||
explicit TextStream(io::IODevice* device);
|
||||
virtual ~TextStream();
|
||||
};
|
||||
}
|
||||
|
||||
#endif // MU_GLOBAL_TEXTSTREAM_H
|
|
@ -33,12 +33,6 @@ XmlStreamWriter::XmlStreamWriter()
|
|||
m_stream->setCodec("UTF-8");
|
||||
}
|
||||
|
||||
XmlStreamWriter::XmlStreamWriter(QIODevice* dev)
|
||||
{
|
||||
m_stream = new QTextStream(dev);
|
||||
m_stream->setCodec("UTF-8");
|
||||
}
|
||||
|
||||
XmlStreamWriter::XmlStreamWriter(io::IODevice* dev)
|
||||
{
|
||||
m_device = dev;
|
||||
|
@ -52,11 +46,6 @@ XmlStreamWriter::~XmlStreamWriter()
|
|||
delete m_stream;
|
||||
}
|
||||
|
||||
void XmlStreamWriter::setDevice(QIODevice* dev)
|
||||
{
|
||||
m_stream->setDevice(dev);
|
||||
}
|
||||
|
||||
void XmlStreamWriter::setDevice(io::IODevice* dev)
|
||||
{
|
||||
m_device = dev;
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#define MU_GLOBAL_XMLSTREAMWRITER_H
|
||||
|
||||
#include <list>
|
||||
#include <QIODevice>
|
||||
#include <QString>
|
||||
|
||||
#include "io/iodevice.h"
|
||||
|
@ -35,11 +34,9 @@ class XmlStreamWriter
|
|||
{
|
||||
public:
|
||||
XmlStreamWriter();
|
||||
explicit XmlStreamWriter(QIODevice* dev);
|
||||
explicit XmlStreamWriter(io::IODevice* dev);
|
||||
virtual ~XmlStreamWriter();
|
||||
|
||||
void setDevice(QIODevice* dev);
|
||||
void setDevice(io::IODevice* dev);
|
||||
void setString(QString* string, QIODevice::OpenMode openMode = QIODevice::ReadWrite);
|
||||
void flush();
|
||||
|
|
|
@ -45,7 +45,8 @@
|
|||
#include <QRegularExpression>
|
||||
|
||||
#include "containers.h"
|
||||
|
||||
#include "io/iodevice.h"
|
||||
#include "io/buffer.h"
|
||||
#include "serialization/internal/qzipwriter_p.h"
|
||||
|
||||
#include "engraving/style/style.h"
|
||||
|
@ -417,7 +418,7 @@ public:
|
|||
millimeters = _score->spatium() * tenths / (10 * DPMM);
|
||||
}
|
||||
|
||||
void write(QIODevice* dev);
|
||||
void write(mu::io::IODevice* dev);
|
||||
void credits(XmlWriter& xml);
|
||||
void moveToTick(const Fraction& t);
|
||||
void words(TextBase const* const text, staff_idx_t staff);
|
||||
|
@ -7231,7 +7232,7 @@ static std::vector<const Jump*> findJumpElements(const Score* score)
|
|||
Write the score to \a dev in MusicXML format.
|
||||
*/
|
||||
|
||||
void ExportMusicXml::write(QIODevice* dev)
|
||||
void ExportMusicXml::write(mu::io::IODevice* dev)
|
||||
{
|
||||
// must export in transposed pitch to prevent
|
||||
// losing the transposition information
|
||||
|
@ -7294,8 +7295,10 @@ void ExportMusicXml::write(QIODevice* dev)
|
|||
|
||||
bool saveXml(Score* score, QIODevice* device)
|
||||
{
|
||||
mu::io::Buffer buf;
|
||||
ExportMusicXml em(score);
|
||||
em.write(device);
|
||||
em.write(&buf);
|
||||
device->write(buf.data().toQByteArrayNoCopy());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -7332,8 +7335,8 @@ bool saveXml(Score* score, const QString& name)
|
|||
|
||||
static void writeMxlArchive(Score* score, MQZipWriter& zipwriter, const QString& filename)
|
||||
{
|
||||
QBuffer cbuf;
|
||||
cbuf.open(QIODevice::ReadWrite);
|
||||
mu::io::Buffer cbuf;
|
||||
cbuf.open(mu::io::IODevice::ReadWrite);
|
||||
|
||||
XmlWriter xml;
|
||||
xml.setDevice(&cbuf);
|
||||
|
@ -7346,14 +7349,14 @@ static void writeMxlArchive(Score* score, MQZipWriter& zipwriter, const QString&
|
|||
xml.endObject();
|
||||
cbuf.seek(0);
|
||||
|
||||
zipwriter.addFile("META-INF/container.xml", cbuf.data());
|
||||
zipwriter.addFile("META-INF/container.xml", cbuf.data().toQByteArrayNoCopy());
|
||||
|
||||
QBuffer dbuf;
|
||||
dbuf.open(QIODevice::ReadWrite);
|
||||
mu::io::Buffer dbuf;
|
||||
dbuf.open(mu::io::IODevice::ReadWrite);
|
||||
ExportMusicXml em(score);
|
||||
em.write(&dbuf);
|
||||
dbuf.seek(0);
|
||||
zipwriter.addFile(filename, dbuf.data());
|
||||
zipwriter.addFile(filename, dbuf.data().toQByteArrayNoCopy());
|
||||
}
|
||||
|
||||
bool saveMxl(Score* score, QIODevice* device)
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#define MU_IMPORTEXPORT_EXPORTXML_H
|
||||
|
||||
#include <QString>
|
||||
#include "io/iodevice.h"
|
||||
|
||||
class QIODevice;
|
||||
|
||||
|
|
Loading…
Reference in a new issue