xlsxabstractooxmlfile.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // xlsxabstractooxmlfile.cpp
  2. #include <QtGlobal>
  3. #include <QBuffer>
  4. #include <QByteArray>
  5. #include "xlsxabstractooxmlfile.h"
  6. #include "xlsxabstractooxmlfile_p.h"
  7. QT_BEGIN_NAMESPACE_XLSX
  8. AbstractOOXmlFilePrivate::AbstractOOXmlFilePrivate(AbstractOOXmlFile *q, AbstractOOXmlFile::CreateFlag flag=AbstractOOXmlFile::F_NewFromScratch)
  9. : relationships(new Relationships), flag(flag), q_ptr(q)
  10. {
  11. }
  12. AbstractOOXmlFilePrivate::~AbstractOOXmlFilePrivate()
  13. {
  14. }
  15. /*!
  16. * \internal
  17. *
  18. * \class AbstractOOXmlFile
  19. *
  20. * Base class of all the ooxml part file.
  21. */
  22. AbstractOOXmlFile::AbstractOOXmlFile(CreateFlag flag)
  23. :d_ptr(new AbstractOOXmlFilePrivate(this, flag))
  24. {
  25. }
  26. AbstractOOXmlFile::AbstractOOXmlFile(AbstractOOXmlFilePrivate *d)
  27. :d_ptr(d)
  28. {
  29. }
  30. AbstractOOXmlFile::~AbstractOOXmlFile()
  31. {
  32. if (d_ptr->relationships)
  33. delete d_ptr->relationships;
  34. delete d_ptr;
  35. }
  36. QByteArray AbstractOOXmlFile::saveToXmlData() const
  37. {
  38. QByteArray data;
  39. QBuffer buffer(&data);
  40. buffer.open(QIODevice::WriteOnly);
  41. saveToXmlFile(&buffer);
  42. return data;
  43. }
  44. bool AbstractOOXmlFile::loadFromXmlData(const QByteArray &data)
  45. {
  46. QBuffer buffer;
  47. buffer.setData(data);
  48. buffer.open(QIODevice::ReadOnly);
  49. return loadFromXmlFile(&buffer);
  50. }
  51. /*!
  52. * \internal
  53. */
  54. void AbstractOOXmlFile::setFilePath(const QString path)
  55. {
  56. Q_D(AbstractOOXmlFile);
  57. d->filePathInPackage = path;
  58. }
  59. /*!
  60. * \internal
  61. */
  62. QString AbstractOOXmlFile::filePath() const
  63. {
  64. Q_D(const AbstractOOXmlFile);
  65. return d->filePathInPackage;
  66. }
  67. /*!
  68. * \internal
  69. */
  70. Relationships *AbstractOOXmlFile::relationships() const
  71. {
  72. Q_D(const AbstractOOXmlFile);
  73. return d->relationships;
  74. }
  75. QT_END_NAMESPACE_XLSX