Warning, file /office/calligra/filters/libmsooxml/MsooXmlCommonReaderImpl.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002  * This file is part of Office 2007 Filters for Calligra
0003  *
0004  * Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
0005  *
0006  * Contact: Suresh Chande suresh.chande@nokia.com
0007  *
0008  * This library is free software; you can redistribute it and/or
0009  * modify it under the terms of the GNU Lesser General Public License
0010  * version 2.1 as published by the Free Software Foundation.
0011  *
0012  * This library is distributed in the hope that it will be useful, but
0013  * WITHOUT ANY WARRANTY; without even the implied warranty of
0014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0015  * Lesser General Public License for more details.
0016  *
0017  * You should have received a copy of the GNU Lesser General Public
0018  * License along with this library; if not, write to the Free Software
0019  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
0020  * 02110-1301 USA
0021  *
0022  */
0023 
0024 #ifndef MSOOXMLCOMMONREADER_IMPL_H
0025 #define MSOOXMLCOMMONREADER_IMPL_H
0026 
0027 #include <KoXmlWriter.h>
0028 
0029 void MSOOXML_CURRENT_CLASS::initInternal()
0030 {
0031     m_insideHdr = false;
0032     m_insideFtr = false;
0033     m_hasPosOffsetH = false;
0034     m_hasPosOffsetV = false;
0035     m_posOffsetH = 0;
0036     m_posOffsetV = 0;
0037     m_currentTextStyleProperties = 0;
0038     m_read_t_args = false;
0039 }
0040 
0041 void MSOOXML_CURRENT_CLASS::doneInternal()
0042 {
0043     delete m_currentTextStyleProperties;
0044     m_currentTextStyleProperties = nullptr;
0045 }
0046 
0047 #undef CURRENT_EL
0048 #define CURRENT_EL t
0049 //! t (Text)
0050 //! ECMA-376, 17.3.3.31, p.379. (WordprocessingML)
0051 //! ECMA-376, 21.1.2.3.11, p.3632 (DrawingML)
0052 //! ECMA-376, 22.1.2.116, p.4226 (MathML)
0053 /*! This element specifies the actual text for this text run. This is
0054   the text that is formatted using all specified body, paragraph and
0055   run properties. This element shall be present within a run of text.
0056 
0057  Parent elements:
0058  ----------------
0059  WordprocessingML:
0060  - r (§22.1.2.87)
0061  - [done] r (§17.3.2.25)
0062 
0063  DrawingML:
0064  - [done] fld (§21.1.2.2.4)
0065  - [done] r (§21.1.2.3.8)
0066 
0067  No child elements.
0068 */
0069 //! @todo support all elements
0070 KoFilter::ConversionStatus MSOOXML_CURRENT_CLASS::read_t()
0071 {
0072     if (m_read_t_args) {
0073         READ_PROLOGUE_IF_NS(a)
0074     } else {
0075         READ_PROLOGUE
0076     }
0077 
0078     while (!atEnd()) {
0079         readNext();
0080         //debugMsooXml << *this;
0081         if (isCharacters()) {
0082             body->addTextSpan(text().toString());
0083 #ifdef PPTXXMLSLIDEREADER_CPP
0084             d->textBoxHasContent = true;
0085 #endif
0086         }
0087         if (m_read_t_args) {
0088             BREAK_IF_END_OF_WITH_NS(a, CURRENT_EL)
0089         } else {
0090             BREAK_IF_END_OF(CURRENT_EL)
0091         }
0092     }
0093 //debugMsooXml << "{1}";
0094 
0095     if (m_read_t_args) {
0096         m_read_t_args = false;
0097         READ_EPILOGUE_IF_NS(a)
0098     } else {
0099         READ_EPILOGUE
0100     }
0101 }
0102 
0103 
0104 
0105 // ================================================================
0106 //                     Namespace: mc
0107 // ================================================================
0108 // ARRRRRGH!
0109 
0110 // The way that READ_PROLOGUE is defined via QUALIFIED_NAME makes it
0111 // impossible to use it in files that handle tags both with and
0112 // without namespaces.  This means that we cannot use READ_PROLOGUE in
0113 // the functions below, and most likely also not the READ_IF variants.
0114 // The above is only true when called from XmlWorksheetReader.  For Docx,
0115 // there are always namespaces, so it doesn't apply.
0116 // Same is true for READ_EPILOGUE.
0117 
0118 
0119 #undef MSOOXML_CURRENT_NS
0120 #define MSOOXML_CURRENT_NS "mc"
0121 
0122 #undef CURRENT_EL
0123 #define CURRENT_EL AlternateContent
0124 //! Alternate content handler
0125 KoFilter::ConversionStatus MSOOXML_CURRENT_CLASS::read_AlternateContent()
0126 {
0127     m_choiceAccepted = false;
0128 
0129     while (!atEnd()) {
0130         readNext();
0131         if (isEndElement() && name() == "AlternateContent") {
0132             break;
0133         }
0134 
0135         if (isStartElement()) {
0136             if (name() == "Choice") {
0137                 TRY_READ(Choice)
0138             }
0139             else if (!m_choiceAccepted && qualifiedName() == "mc:Fallback") {
0140                 TRY_READ(Fallback)
0141             }
0142             else {
0143                 skipCurrentElement();
0144             }
0145         }
0146     }
0147 
0148     return KoFilter::OK;
0149 }
0150 
0151 #undef CURRENT_EL
0152 #define CURRENT_EL Choice
0153 //! Choice handler
0154 KoFilter::ConversionStatus MSOOXML_CURRENT_CLASS::read_Choice()
0155 {
0156 
0157     const QXmlStreamAttributes attrs(attributes());
0158 
0159     TRY_READ_ATTR_WITHOUT_NS(Requires)
0160 
0161     // 'Requires="v"' means that the contents of the Choice part
0162     // is VML, which we support (or something else we do support,
0163     // Lassi is not sure).  For all other alternatives we
0164     // don't dare try to interpret it, but instead we use the
0165     // AlternateContent which is what MSO 2007 would have given us.
0166     if (Requires != "v") {
0167         skipCurrentElement();
0168         return KoFilter::OK;
0169     }
0170 
0171     m_choiceAccepted = true;
0172     while (!atEnd()) {
0173         readNext();
0174         if (isEndElement() && name() == "Choice") {
0175             break;
0176         }
0177         if (isStartElement()) {
0178 #ifdef PPTXXMLSLIDEREADER_CPP
0179             TRY_READ_IF_NS(p, oleObj)
0180 #endif
0181         }
0182     }
0183     return KoFilter::OK;
0184 }
0185 
0186 #undef CURRENT_EL
0187 #define CURRENT_EL Fallback
0188 //! Fallback handler
0189 KoFilter::ConversionStatus MSOOXML_CURRENT_CLASS::read_Fallback()
0190 {
0191 
0192     while (!atEnd()) {
0193         readNext();
0194         if (isEndElement() && name() == "Fallback") {
0195             break;
0196         }
0197 
0198         if (isStartElement()) {
0199 #ifdef PPTXXMLSLIDEREADER_CPP
0200             TRY_READ_IF_NS(p, sp)
0201 #endif
0202 #ifdef DOCXXMLDOCUMENTREADER_H
0203             TRY_READ_IF_NS(w, pict)
0204 #endif
0205 #ifdef XLSXXMLWORKSHEETREADER_CPP
0206             // FIXME: This Choice/Content/Fallback structure needs a more general treatment.
0207             if (name() == "oleObject") {
0208                 TRY_READ(oleObject)
0209             }
0210 #endif
0211         }
0212     }
0213     return KoFilter::OK;
0214 }
0215 
0216 #endif