Browse Source

Take use of existing theme file

master
Debao Zhang 11 years ago
parent
commit
7e3e463983
  1. 6
      src/xlsx/xlsxpackage.cpp
  2. 184
      src/xlsx/xlsxtheme.cpp
  3. 3
      src/xlsx/xlsxtheme_p.h
  4. 7
      src/xlsx/xlsxworkbook.cpp
  5. 2
      src/xlsx/xlsxworkbook.h
  6. 2
      src/xlsx/xlsxworkbook_p.h

6
src/xlsx/xlsxpackage.cpp

@ -168,7 +168,9 @@ bool Package::parsePackage(QIODevice *packageDevice)
QList<XlsxRelationship> rels_theme = xlworkbook_Rels.documentRelationships(QStringLiteral("/theme"));
if (!rels_theme.isEmpty()) {
//In normal case this should be theme/theme1.xml which in xl
//:Todo
QString name = rels_theme[0].target;
QString path = xlworkbook_Dir + QLatin1String("/") + name;
m_document->workbook()->theme()->loadFromXmlData(zipReader.fileData(path));
}
//load worksheets
@ -338,7 +340,7 @@ void Package::writeThemeFile(ZipWriter &zipWriter)
QByteArray data;
QBuffer buffer(&data);
buffer.open(QIODevice::WriteOnly);
Theme().saveToXmlFile(&buffer);
m_workbook->theme()->saveToXmlFile(&buffer);
zipWriter.addFile(QStringLiteral("xl/theme/theme1.xml"), data);
}

184
src/xlsx/xlsxtheme.cpp

File diff suppressed because one or more lines are too long

3
src/xlsx/xlsxtheme_p.h

@ -36,6 +36,9 @@ public:
Theme();
void saveToXmlFile(QIODevice *device);
void loadFromXmlData(const QByteArray &data);
QByteArray xmlData;
};
}

7
src/xlsx/xlsxworkbook.cpp

@ -43,6 +43,7 @@ WorkbookPrivate::WorkbookPrivate(Workbook *q) :
{
sharedStrings = QSharedPointer<SharedStrings> (new SharedStrings);
styles = QSharedPointer<Styles>(new Styles);
theme = QSharedPointer<Theme>(new Theme);
x_window = 240;
y_window = 15;
@ -247,6 +248,12 @@ Styles *Workbook::styles()
return d->styles.data();
}
Theme *Workbook::theme()
{
Q_D(Workbook);
return d->theme.data();
}
QList<QImage> Workbook::images()
{
Q_D(Workbook);

2
src/xlsx/xlsxworkbook.h

@ -41,6 +41,7 @@ class Styles;
class Package;
class Drawing;
class Document;
class Theme;
class DocumentPrivate;
class WorkbookPrivate;
@ -82,6 +83,7 @@ private:
SharedStrings *sharedStrings() const;
Styles *styles();
Theme *theme();
QList<QImage> images();
QList<Drawing *> drawings();
void prepareDrawings();

2
src/xlsx/xlsxworkbook_p.h

@ -25,6 +25,7 @@
#ifndef XLSXWORKBOOK_P_H
#define XLSXWORKBOOK_P_H
#include "xlsxworkbook.h"
#include "xlsxtheme_p.h"
#include <QSharedPointer>
#include <QPair>
@ -68,6 +69,7 @@ public:
QSharedPointer<SharedStrings> sharedStrings;
QList<QSharedPointer<Worksheet> > worksheets;
QSharedPointer<Styles> styles;
QSharedPointer<Theme> theme;
QList<QImage> images;
QList<Drawing *> drawings;
QList<XlsxDefineNameData> definedNamesList;

Loading…
Cancel
Save