~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to filters/kspread/xlsx/XlsxXmlDocumentReader.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-10-27 17:52:57 UTC
  • mfrom: (0.12.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101027175257-s04zqqk5bs8ckm9o
Tags: 1:2.2.83-0ubuntu1
* Merge with Debian git remaining changes:
 - Add build-deps on librcps-dev, opengtl-dev, libqtgtl-dev, freetds-dev,
   create-resources, libspnav-dev
 - Remove needless build-dep on libwv2-dev
 - koffice-libs recommends create-resources
 - krita recommends pstoedit
 - Keep our patches
* New upstream release 2.3 beta 3
  - Remove debian/patches fixed by upstream
  - Update install files

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
#include "XlsxXmlDocumentReader.h"
25
25
#include "XlsxXmlWorksheetReader.h"
 
26
#include "XlsxXmlCommentsReader.h"
26
27
#include "XlsxImport.h"
27
28
#include <MsooXmlSchemas.h>
28
29
#include <MsooXmlUtils.h>
29
30
#include <MsooXmlRelationships.h>
30
31
#include <KoXmlWriter.h>
31
32
#include <KoFontFace.h>
 
33
#include <VmlDrawingReader.h>
32
34
 
33
35
#undef MSOOXML_CURRENT_NS
34
36
#define MSOOXML_CURRENT_CLASS XlsxXmlDocumentReader
38
40
 
39
41
XlsxXmlDocumentReaderContext::XlsxXmlDocumentReaderContext(
40
42
    XlsxImport& _import,
41
 
    const QMap<QString, MSOOXML::DrawingMLTheme*>& _themes,
 
43
    MSOOXML::DrawingMLTheme* _themes,
42
44
    const XlsxSharedStringVector& _sharedStrings,
 
45
    const XlsxComments& _comments,
43
46
    const XlsxStyles& _styles,
44
47
    MSOOXML::MsooXmlRelationships& _relationships
45
48
    )
46
49
        : MSOOXML::MsooXmlReaderContext(&_relationships)
47
50
        , import(&_import)
48
 
        , themes(&_themes)
 
51
        , themes(_themes)
49
52
        , sharedStrings(&_sharedStrings)
 
53
        , comments(&_comments)
50
54
        , styles(&_styles)
51
55
{
52
56
}
131
135
    TRY_READ(workbook)
132
136
 
133
137
//! @todo hardcoded font face list; look at fonts used by theme
134
 
    ;
135
138
    mainStyles->insertFontFace(KoFontFace("Calibri"));
136
139
    mainStyles->insertFontFace(KoFontFace("Arial"));
137
140
    mainStyles->insertFontFace(KoFontFace("Tahoma"));
181
184
    while (!atEnd()) {
182
185
        readNext();
183
186
        kDebug() << *this;
 
187
        BREAK_IF_END_OF(CURRENT_EL);
184
188
        if (isStartElement()) {
185
189
            TRY_READ_IF(sheets)
186
190
//! @todo add ELSE_WRONG_FORMAT
187
191
        }
188
 
        BREAK_IF_END_OF(CURRENT_EL);
189
192
    }
190
193
 
191
194
    READ_EPILOGUE
210
213
    while (!atEnd()) {
211
214
        readNext();
212
215
        kDebug() << *this;
 
216
        BREAK_IF_END_OF(CURRENT_EL);
213
217
        if (isStartElement()) {
214
218
            TRY_READ_IF(sheet)
215
219
            ELSE_WRONG_FORMAT
216
220
        }
217
 
        BREAK_IF_END_OF(CURRENT_EL);
218
221
    }
219
222
 
220
223
    READ_EPILOGUE
239
242
    READ_ATTR_WITH_NS(r, id)
240
243
    READ_ATTR_WITHOUT_NS(sheetId)
241
244
    READ_ATTR_WITHOUT_NS(name)
242
 
    kDebug() << "r:id:" << r_id << "sheetId:" << sheetId << "name:" << name;
 
245
    TRY_READ_ATTR_WITHOUT_NS(state)
 
246
    kDebug() << "r:id:" << r_id << "sheetId:" << sheetId << "name:" << name << "state:" << state;
243
247
//! @todo    TRY_READ_ATTR_WITHOUT_NS(state)
244
248
 
245
249
//! @todo implement MsooXmlRelationships with internal MsooXmlRelationshipsReader
250
254
    QString filepath = path + "/" + file;
251
255
    kDebug() << "path:" << path << "file:" << file;
252
256
 
 
257
    // Loading potential ole replacements
 
258
    VmlDrawingReader vmlreader(this);
 
259
    QString vmlTarget = m_context->relationships->targetForType(path, file,
 
260
        "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing");
 
261
 
 
262
    if (!vmlTarget.isEmpty()) {
 
263
        QString errorMessage, vmlPath, vmlFile;
 
264
 
 
265
        MSOOXML::Utils::splitPathAndFile(vmlTarget, &vmlPath, &vmlFile);
 
266
 
 
267
        VmlDrawingReaderContext vmlContext(*m_context->import,
 
268
            vmlPath, vmlFile, *m_context->relationships);
 
269
 
 
270
        const KoFilter::ConversionStatus status =
 
271
            m_context->import->loadAndParseDocument(&vmlreader, vmlTarget, errorMessage, &vmlContext);
 
272
        if (status != KoFilter::OK) {
 
273
            vmlreader.raiseError(errorMessage);
 
274
        }
 
275
    }
 
276
 
253
277
    XlsxXmlWorksheetReader worksheetReader(this);
254
 
    XlsxXmlWorksheetReaderContext context(d->worksheetNumber, name, path, file,
255
 
                                          *m_context->themes, *m_context->sharedStrings, *m_context->styles,
256
 
                                          *m_context->relationships, m_context->import );
 
278
    XlsxXmlWorksheetReaderContext context(d->worksheetNumber, name, state, path, file,
 
279
                                          m_context->themes, *m_context->sharedStrings,
 
280
                                          *m_context->comments,
 
281
                                          *m_context->styles,
 
282
                                          *m_context->relationships, m_context->import,
 
283
                                          vmlreader.content());
257
284
    const KoFilter::ConversionStatus result = m_context->import->loadAndParseDocument(
258
285
                &worksheetReader, filepath, &context);
259
286
    if (result != KoFilter::OK) {
261
288
        return result;
262
289
    }
263
290
 
264
 
 
265
 
    SKIP_EVERYTHING
 
291
    readNext();
266
292
    READ_EPILOGUE
267
293
}