Welcome, Guest. Please login or register.
Did you miss your activation email?

Author Topic: Загрузка отчета с помощью QDomDocument  (Read 406 times)

tech 49

  • Newbie
  • *
  • Posts: 7
    • View Profile
Загрузка отчета с помощью QDomDocument
« on: November 27, 2020, 01:53:24 PM »
Здравствуйте можно ли в библиотеки реализовать такой метод bool loadFromDom(const QDomDocument & document); в классе ReportEngine, для предобработки отчёта

lrreportengine.h

Code: [Select]
#include <QDomComment>

class LIMEREPORT_EXPORT ReportEngine : public QObject{
...
public:
bool    loadFromDom(const QDomDocument & document);
...
}


lrreportengine_p.h

Code: [Select]
class ReportEnginePrivate : public QObject,
        public ICollectionContainer,
        public ITranslationContainer,
        public IExternalPainter,
        public ReportEnginePrivateInterface
{
...
public:
bool    loadFromDom(const QDomDocument & document, const QString & name = "");
...
}

lrreportengine.cpp

Code: [Select]

bool ReportEnginePrivate::loadFromDom(const QDomDocument &document, const QString &name){
    clearReport();

    ItemsReaderIntf::Ptr reader = DomXMLReader::create(document);
    reader->setPassPhrase(m_passPhrase);
    if (reader->first()){
        if (reader->readItem(this)){
            m_fileName = "";
            m_reportName = name;
            emit loadFinished();
            return true;
        };
    }
    return false;
}

bool ReportEngine::loadFromDom(const QDomDocument & document)
{
    Q_D(ReportEngine);
    return d->loadFromDom(document);
}


lrxmlreader.h

Code: [Select]

class DomXMLReader : public XMLReader{
public:
    static ItemsReaderIntf::Ptr create(const QDomDocument & content){ return ItemsReaderIntf::Ptr(new DomXMLReader(content));}
protected:
    virtual bool prepareReader(QDomDocument *doc);
private:
    DomXMLReader(const QDomDocument & content): m_content(content){}
    const QDomDocument & m_content;
};


lrxmlreader.cpp

Code: [Select]

bool DomXMLReader::prepareReader(QDomDocument * doc)
{
    if (!m_content.isNull()){
        * doc = m_content;
    } else {m_error = QString(QObject::tr("Document is empty")); return false;}
    return true;
}