filters

powerpoint.cc

00001 /*
00002     Copyright (C) 2000, S.R.Haque <shaheedhaque@hotmail.com>.
00003     This file is part of the KDE project
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public License
00016     along with this library; see the file COPYING.LIB.  If not, write to
00017     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018     Boston, MA 02111-1307, USA.
00019 
00020 DESCRIPTION
00021 */
00022 
00023 #include <kdebug.h>
00024 #include <myfile.h>
00025 #include <powerpoint.h>
00026 
00027 const int Powerpoint::s_area = 30512;
00028 
00029 Powerpoint::Powerpoint()
00030 {
00031     mEditOffset = 0;
00032     m_pptSlide = 0;
00033 }
00034 
00035 Powerpoint::~Powerpoint()
00036 {
00037     m_persistentReferences.clear();
00038     //m_slides.clear();
00039 }
00040 
00041 void Powerpoint::invokeHandler(
00042     Header &op,
00043     Q_UINT32 bytes,
00044     QDataStream &operands)
00045 {
00046     typedef void (Powerpoint::*method)(Header &op, Q_UINT32 bytes, QDataStream &operands);
00047 
00048     typedef struct
00049     {
00050         const char *name;
00051         Q_UINT16 opcode;
00052         method handler;
00053     } opcodeEntry;
00054 
00055     static const opcodeEntry funcTab[] =
00056     {
00057         { "ANIMATIONINFO",              4116,   0 /* &Powerpoint::opAnimationInfo */ },
00058         { "ANIMATIONINFOATOM",          4081,   0 /* &Powerpoint::opAnimationInfoAtom */ },
00059         { "ARRAYELEMENTATOM",           2030,   0 /* &Powerpoint::opArrayElementAtom */ },
00060         { "BASETEXTPROPATOM",           4002,   0 /* &Powerpoint::opBaseTextPropAtom */ },
00061         { "BINARYTAGDATA",              5003,   0 /* &Powerpoint::opBinaryTagData */ },
00062         { "BOOKMARKCOLLECTION",         2019,   0 /* &Powerpoint::opBookmarkCollection */ },
00063         { "BOOKMARKENTITYATOM",         4048,   0 /* &Powerpoint::opBookmarkEntityAtom */ },
00064         { "BOOKMARKSEEDATOM",           2025,   0 /* &Powerpoint::opBookmarkSeedAtom */ },
00065         { "CHARFORMATATOM",             4066,   0 /* &Powerpoint::opCharFormatAtom */ },
00066         { "CLIENTSIGNAL1",              6,      0 /* &Powerpoint::opClientSignal1 */ },
00067         { "CLIENTSIGNAL2",              7,      0 /* &Powerpoint::opClientSignal2 */ },
00068         { "COLORSCHEMEATOM",            2032,   &Powerpoint::opColorSchemeAtom },
00069         { "COREPICT",                   4037,   0 /* &Powerpoint::opCorePict */ },
00070         { "COREPICTATOM",               4038,   0 /* &Powerpoint::opCorePictAtom */ },
00071         { "CSTRING",                    4026,   &Powerpoint::opCString },
00072         { "CURRENTUSERATOM",            4086,   &Powerpoint::opCurrentUserAtom },
00073         { "DATETIMEMCATOM",             4087,   0 /* &Powerpoint::opDateTimeMCAtom */ },
00074         { "DEFAULTRULERATOM",           4011,   0 /* &Powerpoint::opDefaultRulerAtom */ },
00075         { "DOCROUTINGSLIP",             1030,   0 /* &Powerpoint::opDocRoutingSlip */ },
00076         { "DOCUMENT",                   1000,   &Powerpoint::opDocument },
00077         { "DOCUMENTATOM",               1001,   &Powerpoint::opDocumentAtom },
00078         { "DOCVIEWINFO",                1014,   0 /* &Powerpoint::opDocViewInfo */ },
00079         { "EMFORMATATOM",               4065,   0 /* &Powerpoint::opEmFormatAtom */ },
00080         { "ENDDOCUMENT",                1002,   &Powerpoint::opEndDocument },
00081         { "ENVIRONMENT",                1010,   &Powerpoint::opEnvironment },
00082         { "EXAVIMOVIE",                 4102,   0 /* &Powerpoint::opExAviMovie */ },
00083         { "EXCDAUDIO",                  4110,   0 /* &Powerpoint::opExCDAudio */ },
00084         { "EXCDAUDIOATOM",              4114,   0 /* &Powerpoint::opExCDAudioAtom */ },
00085         { "EXCONTROL",                  4078,   0 /* &Powerpoint::opExControl */ },
00086         { "EXCONTROLATOM",              4091,   0 /* &Powerpoint::opExControlAtom */ },
00087         { "EXEMBED",                    4044,   &Powerpoint::opExEmbed },
00088         { "EXEMBEDATOM",                4045,   &Powerpoint::opExEmbedAtom },
00089         { "EXHYPERLINK",                4055,   0 /* &Powerpoint::opExHyperlink */ },
00090         { "EXHYPERLINKATOM",            4051,   0 /* &Powerpoint::opExHyperlinkAtom */ },
00091         { "EXLINK",                     4046,   0 /* &Powerpoint::opExLink */ },
00092         { "EXLINKATOM",                 4049,   0 /* &Powerpoint::opExLinkAtom */ },
00093         { "EXLINKATOM_OLD",             4047,   0 /* &Powerpoint::opExLinkAtom_old */ },
00094         { "EXMCIMOVIE",                 4103,   0 /* &Powerpoint::opExMCIMovie */ },
00095         { "EXMEDIAATOM",                4100,   0 /* &Powerpoint::opExMediaAtom */ },
00096         { "EXMIDIAUDIO",                4109,   0 /* &Powerpoint::opExMIDIAudio */ },
00097         { "EXOBJLIST",                  1033,   &Powerpoint::opExObjList },
00098         { "EXOBJLISTATOM",              1034,   &Powerpoint::opExObjListAtom },
00099         { "EXOBJREFATOM",               3009,   &Powerpoint::opExObjRefAtom },
00100         { "EXOLEOBJ",                   4034,   &Powerpoint::opExOleObj },
00101         { "EXOLEOBJATOM",               4035,   &Powerpoint::opExOleObjAtom },
00102         { "EXOLEOBJSTG",                4113,   &Powerpoint::opExOleObjStg },
00103         { "EXPLAIN",                    4053,   0 /* &Powerpoint::opExPlain */ },
00104         { "EXPLAINATOM",                4039,   0 /* &Powerpoint::opExPlainAtom */ },
00105         { "EXPLAINLINK",                4054,   0 /* &Powerpoint::opExPlainLink */ },
00106         { "EXPLAINLINKATOM",            4036,   0 /* &Powerpoint::opExPlainLinkAtom */ },
00107         { "EXQUICKTIME",                4073,   0 /* &Powerpoint::opExQuickTime */ },
00108         { "EXQUICKTIMEMOVIE",           4074,   0 /* &Powerpoint::opExQuickTimeMovie */ },
00109         { "EXQUICKTIMEMOVIEDATA",       4075,   0 /* &Powerpoint::opExQuickTimeMovieData */ },
00110         { "EXSUBSCRIPTION",             4076,   0 /* &Powerpoint::opExSubscription */ },
00111         { "EXSUBSCRIPTIONSECTION",      4077,   0 /* &Powerpoint::opExSubscriptionSection */ },
00112         { "EXTERNALOBJECT",             4027,   0 /* &Powerpoint::opExternalObject */ },
00113         { "EXVIDEO",                    4101,   0 /* &Powerpoint::opExVideo */ },
00114         { "EXWAVAUDIOEMBEDDED",         4111,   0 /* &Powerpoint::opExWAVAudioEmbedded */ },
00115         { "EXWAVAUDIOEMBEDDEDATOM",     4115,   0 /* &Powerpoint::opExWAVAudioEmbeddedAtom */ },
00116         { "EXWAVAUDIOLINK",             4112,   0 /* &Powerpoint::opExWAVAudioLink */ },
00117         { "FONTCOLLECTION",             2005,   &Powerpoint::opFontCollection },
00118         { "FONTEMBEDDATA",              4024,   0 /* &Powerpoint::opFontEmbedData */ },
00119         { "FONTENTITYATOM",             4023,   &Powerpoint::opFontEntityAtom },
00120         { "FOOTERMCATOM",               4090,   0 /* &Powerpoint::opFooterMCAtom */ },
00121         { "GENERICDATEMCATOM",          4088,   0 /* &Powerpoint::opGenericDateMCAtom */ },
00122         { "GLINEATOM",                  10004,  0 /* &Powerpoint::opGlineAtom */ },
00123         { "GLPOINTATOM",                10003,  0 /* &Powerpoint::opGLPointAtom */ },
00124         { "GPOINTATOM",                 3034,   0 /* &Powerpoint::opGpointAtom */ },
00125         { "GRATIOATOM",                 3031,   0 /* &Powerpoint::opGratioAtom */ },
00126         { "GRCOLOR",                    3020,   0 /* &Powerpoint::opGrColor */ },
00127         { "GRCOLORATOM",                10002,  0 /* &Powerpoint::opGrColorAtom */ },
00128         { "GRECTATOM",                  3025,   0 /* &Powerpoint::opGrectAtom */ },
00129         { "GSCALING",                   3032,   0 /* &Powerpoint::opGscaling */ },
00130         { "GSCALINGATOM",               10001,  0 /* &Powerpoint::opGscalingAtom */ },
00131         { "GUIDEATOM",                  1019,   0 /* &Powerpoint::opGuideAtom */ },
00132         { "GUIDELIST",                  2026,   0 /* &Powerpoint::opGuideList */ },
00133         { "HANDOUT",                    4041,   0 /* &Powerpoint::opHandout */ },
00134         { "HEADERMCATOM",               4089,   0 /* &Powerpoint::opHeaderMCAtom */ },
00135         { "HEADERSFOOTERS",             4057,   &Powerpoint::opHeadersFooters },
00136         { "HEADERSFOOTERSATOM",         4058,   &Powerpoint::opHeadersFootersAtom },
00137         { "INT4ARRAYATOM",              2031,   0 /* &Powerpoint::opInt4ArrayAtom */ },
00138         { "INTERACTIVEINFO",            4082,   0 /* &Powerpoint::opInteractiveInfo */ },
00139         { "INTERACTIVEINFOATOM",        4083,   0 /* &Powerpoint::opInteractiveInfoAtom */ },
00140         { "IRRATOM",                    2,      0 /* &Powerpoint::opIRRAtom */ },
00141         { "LIST",                       2000,   &Powerpoint::opList },
00142         { "LISTPLACEHOLDER",            2017,   0 /* &Powerpoint::opListPlaceholder */ },
00143         { "MAINMASTER",                 1016,   &Powerpoint::opMainMaster },
00144         { "MASTERTEXT",                 4068,   0 /* &Powerpoint::opMasterText */ },
00145         { "METAFILE",                   4033,   0 /* &Powerpoint::opMetaFile */ },
00146         { "NAMEDSHOW",                  1041,   0 /* &Powerpoint::opNamedShow */ },
00147         { "NAMEDSHOWS",                 1040,   0 /* &Powerpoint::opNamedShows */ },
00148         { "NAMEDSHOWSLIDES",            1042,   0 /* &Powerpoint::opNamedShowSlides */ },
00149         { "NOTES",                      1008,   &Powerpoint::opNotes },
00150         { "NOTESATOM",                  1009,   &Powerpoint::opNotesAtom },
00151         { "OEPLACEHOLDERATOM",          3011,   0 /* &Powerpoint::opOEPlaceholderAtom */ },
00152         { "OESHAPE",                    3008,   0 /* &Powerpoint::opOEShape */ },
00153         { "OESHAPEATOM",                3035,   0 /* &Powerpoint::opOEShapeAtom */ },
00154         { "OUTLINETEXTREFATOM",         3998,   0 /* &Powerpoint::opOutlineTextRefAtom */ },
00155         { "OUTLINEVIEWINFO",            1031,   &Powerpoint::opOutlineViewInfo },
00156         { "PARAFORMATATOM",             4067,   0 /* &Powerpoint::opParaFormatAtom */ },
00157         { "PERSISTPTRFULLBLOCK",        6001,   0 /* &Powerpoint::opPersistPtrFullBlock */ },
00158         { "PERSISTPTRINCREMENTALBLOCK", 6002,   &Powerpoint::opPersistPtrIncrementalBlock },
00159         { "POWERPOINTSTATEINFOATOM",    10,     0 /* &Powerpoint::opPowerPointStateInfoAtom */ },
00160         { "PPDRAWING",                  1036,   &Powerpoint::opPPDrawing },
00161         { "PPDRAWINGGROUP",             1035,   &Powerpoint::opPPDrawingGroup },
00162         { "PRINTOPTIONS",               6000,   0 /* &Powerpoint::opPrintOptions */ },
00163         { "PROGBINARYTAG",              5002,   0 /* &Powerpoint::opProgBinaryTag */ },
00164         { "PROGSTRINGTAG",              5001,   0 /* &Powerpoint::opProgStringTag */ },
00165         { "PROGTAGS",                   5000,   0 /* &Powerpoint::opProgTags */ },
00166         { "PSS",                        3,      0 /* &Powerpoint::opPSS */ },
00167         { "RECOLORENTRYATOM",           4062,   0 /* &Powerpoint::opRecolorEntryAtom */ },
00168         { "RECOLORINFOATOM",            4071,   0 /* &Powerpoint::opRecolorInfoAtom */ },
00169         { "RTFDATETIMEMCATOM",          4117,   0 /* &Powerpoint::opRTFDateTimeMCAtom */ },
00170         { "RULERINDENTATOM",            10000,  0 /* &Powerpoint::opRulerIndentAtom */ },
00171         { "RUNARRAY",                   2028,   0 /* &Powerpoint::opRunArray */ },
00172         { "RUNARRAYATOM",               2029,   0 /* &Powerpoint::opRunArrayAtom */ },
00173         { "SCHEME",                     1012,   0 /* &Powerpoint::opScheme */ },
00174         { "SCHEMEATOM",                 1013,   0 /* &Powerpoint::opSchemeAtom */ },
00175         { "SLIDE",                      1006,   &Powerpoint::opSlide },
00176         { "SLIDEATOM",                  1007,   &Powerpoint::opSlideAtom },
00177         { "SLIDEBASE",                  1004,   0 /* &Powerpoint::opSlideBase */ },
00178         { "SLIDEBASEATOM",              1005,   0 /* &Powerpoint::opSlideBaseAtom */ },
00179         { "SLIDELIST",                  4084,   0 /* &Powerpoint::opSlideList */ },
00180         { "SLIDELISTWITHTEXT",          4080,   &Powerpoint::opSlideListWithText },
00181         { "SLIDENUMBERMCATOM",          4056,   0 /* &Powerpoint::opSlideNumberMCAtom */ },
00182         { "SLIDEPERSIST",               1003,   0 /* &Powerpoint::opSlidePersist */ },
00183         { "SLIDEPERSISTATOM",           1011,   &Powerpoint::opSlidePersistAtom },
00184         { "SLIDEVIEWINFO",              1018,   &Powerpoint::opSlideViewInfo },
00185         { "SLIDEVIEWINFOATOM",          1022,   0 /* &Powerpoint::opSlideViewInfoAtom */ },
00186         { "SORTERVIEWINFO",             1032,   0 /* &Powerpoint::opSorterViewInfo */ },
00187         { "SOUND",                      2022,   0 /* &Powerpoint::opSound */ },
00188         { "SOUNDCOLLATOM",              2021,   0 /* &Powerpoint::opSoundCollAtom */ },
00189         { "SOUNDCOLLECTION",            2020,   0 /* &Powerpoint::opSoundCollection */ },
00190         { "SOUNDDATA",                  2023,   0 /* &Powerpoint::opSoundData */ },
00191         { "SRKINSOKU",                  4040,   &Powerpoint::opSrKinsoku },
00192         { "SRKINSOKUATOM",              4050,   0 /* &Powerpoint::opSrKinsokuAtom */ },
00193         { "SSDOCINFOATOM",              1025,   &Powerpoint::opSSDocInfoAtom },
00194         { "SSLIDELAYOUTATOM",           1015,   &Powerpoint::opSSSlideLayoutAtom },
00195         { "SSSLIDEINFOATOM",            1017,   0 /* &Powerpoint::opSSSlideInfoAtom */ },
00196         { "STYLETEXTPROPATOM",          4001,   &Powerpoint::opStyleTextPropAtom },
00197         { "SUBCONTAINERCOMPLETED",      1,      0 /* &Powerpoint::opSubContainerCompleted */ },
00198         { "SUBCONTAINEREXCEPTION",      4,      0 /* &Powerpoint::opSubContainerException */ },
00199         { "SUMMARY",                    1026,   0 /* &Powerpoint::opSummary */ },
00200         { "TEXTBOOKMARKATOM",           4007,   0 /* &Powerpoint::opTextBookmarkAtom */ },
00201         { "TEXTBYTESATOM",              4008,   &Powerpoint::opTextBytesAtom },
00202         { "TEXTCHARSATOM",              4000,   &Powerpoint::opTextCharsAtom },
00203         { "TEXTHEADERATOM",             3999,   &Powerpoint::opTextHeaderAtom },
00204         { "TEXTRULERATOM",              4006,   0 /* &Powerpoint::opTextRulerAtom */ },
00205         { "TEXTSPECINFOATOM",           4010,   &Powerpoint::opTextSpecInfoAtom },
00206         { "TEXTURE",                    1027,   0 /* &Powerpoint::opTexture */ },
00207         { "TXCFSTYLEATOM",              4004,   0 /* &Powerpoint::opTxCFStyleAtom */ },
00208         { "TXINTERACTIVEINFOATOM",      4063,   0 /* &Powerpoint::opTxInteractiveInfoAtom */ },
00209         { "TXMASTERSTYLEATOM",          4003,   &Powerpoint::opTxMasterStyleAtom },
00210         { "TXPFSTYLEATOM",              4005,   0 /* &Powerpoint::opTxPFStyleAtom */ },
00211         { "TXSISTYLEATOM",              4009,   &Powerpoint::opTxSIStyleAtom },
00212         { "TYPEFACE",                   4025,   0 /* &Powerpoint::opTypeFace */ },
00213         { "USEREDITATOM",               4085,   &Powerpoint::opUserEditAtom },
00214         { "VBAINFO",                    1023,   &Powerpoint::opVBAInfo },
00215         { "VBAINFOATOM",                1024,   0 /* &Powerpoint::opVBAInfoAtom */ },
00216         { "VBASLIDEINFO",               1028,   0 /* &Powerpoint::opVBASlideInfo */ },
00217         { "VBASLIDEINFOATOM",           1029,   0 /* &Powerpoint::opVBASlideInfoAtom */ },
00218         { "VIEWINFO",                   1020,   0 /* &Powerpoint::opViewInfo */ },
00219         { "VIEWINFOATOM",               1021,   0 /* &Powerpoint::opViewInfoAtom */ },
00220         { NULL,                         0,      0 },
00221         { "MSOD",                       0,      &Powerpoint::opMsod }
00222     };
00223     unsigned i;
00224     method result;
00225 
00226     // Scan lookup table for operation.
00227 
00228     for (i = 0; funcTab[i].name; i++)
00229     {
00230         if (funcTab[i].opcode == op.type)
00231         {
00232             break;
00233         }
00234     }
00235 
00236     // Invoke handler.
00237 
00238     result = funcTab[i].handler;
00239     if (!result && (op.type >= 0xF000) && (0xFFFF >= op.type))
00240         result = funcTab[++i].handler;
00241     if (!result)
00242     {
00243         if (funcTab[i].name)
00244             kdWarning(s_area) << "invokeHandler: unsupported opcode: " <<
00245                 funcTab[i].name <<
00246                 " operands: " << bytes << endl;
00247         else
00248             kdWarning(s_area) << "invokeHandler: unsupported opcode: " <<
00249                 op.type <<
00250                 " operands: " << bytes << endl;
00251 
00252         // Skip data we cannot use.
00253         skip(bytes, operands);
00254     }
00255     else
00256     {
00257         kdDebug(s_area) << "invokeHandler: opcode: " << funcTab[i].name <<
00258             " operands: " << bytes << endl;
00259 
00260         // We don't invoke the handler directly on the incoming operands, but
00261         // via a temporary datastream. This adds overhead, but eliminates the
00262         // need for the individual handlers to read *exactly* the right amount
00263         // of data (thus speeding development, and possibly adding some
00264         // future-proofing).
00265 
00266         if (bytes)
00267         {
00268             QByteArray *record = new QByteArray(bytes);
00269             QDataStream *body;
00270 
00271             operands.readRawBytes(record->data(), bytes);
00272             body = new QDataStream(*record, IO_ReadOnly);
00273             body->setByteOrder(QDataStream::LittleEndian);
00274             (this->*result)(op, bytes, *body);
00275             delete body;
00276             delete record;
00277         }
00278         else
00279         {
00280             QDataStream *body = new QDataStream();
00281 
00282             (this->*result)(op, bytes, *body);
00283             delete body;
00284         }
00285     }
00286 }
00287 
00288 bool Powerpoint::parse(
00289     myFile &mainStream,
00290     myFile &currentUser,
00291     myFile &pictures)
00292 {
00293     unsigned i;
00294 
00295     m_mainStream = mainStream;
00296     m_pictures = pictures;
00297     m_documentRef = 0;
00298     m_documentRefFound = false;
00299     m_persistentReferences.clear();
00300     m_slideList.clear();
00301     m_editDepth = 0;
00302 
00303     // Find the slide references.
00304 
00305     m_pass = PASS_GET_SLIDE_REFERENCES;
00306     kdError(s_area) << "parseing step 1 walkRecord..." << endl;
00307     walkRecord(currentUser.length, currentUser.data);//get curren user information
00308 
00309     kdError(s_area) << "parseing step 2 walkReference..." << endl;
00310     //for(i = 0; i <= 2; i++)//walk the 2 slide atoms
00311     //{
00312     //  kdError(s_area) << "ref == :" << i <<endl;
00313     //walkReference(i);
00314     //}
00315     kdError(s_area) << "walking slide list!!!!.." << endl;
00316     if(mEditOffset != 0) walk(mEditOffset);
00317     else walkDocument();
00318     // We should have a complete list of slide persistent references.
00319     m_pass = PASS_GET_SLIDE_CONTENTS;
00320     kdError(s_area) << "TOTAL SLIDES XXxx: " << m_slideList.count() << endl;
00321 
00322      for (i = 0; i < m_slideList.count(); i++)
00323     {
00324         m_pptSlide = m_slideList.at(i);
00325         walkReference(i);
00326         gotSlide(*m_pptSlide);
00327     }
00328 
00329     return true;
00330 }
00331 
00332 void Powerpoint::opColorSchemeAtom(
00333     Header & /* op */,
00334     Q_UINT32,
00335     QDataStream &operands)
00336 {
00337     struct
00338     {
00339         Q_UINT32 background;
00340         Q_UINT32 textAndLines;
00341         Q_UINT32 shadows;
00342         Q_UINT32 titleText;
00343         Q_UINT32 fills;
00344         Q_UINT32 accent;
00345         Q_UINT32 accentAndHyperlink;
00346         Q_UINT32 accentAndFollowedHyperlink;
00347     } data;
00348 
00349     operands >> data.background >> data.textAndLines >> data.shadows >>
00350         data.titleText >> data.fills >> data.accent >> data.accentAndHyperlink >>
00351         data.accentAndFollowedHyperlink;
00352 }
00353 
00354 //
00355 // A Unicode String.
00356 //
00357 void Powerpoint::opCString(
00358     Header & /* op */,
00359     Q_UINT32 bytes,
00360     QDataStream &operands)
00361 {
00362     QString value;
00363     unsigned i;
00364 
00365     for (i = 0; i < bytes / 2; i++)
00366     {
00367         Q_UINT16 tmp;
00368 
00369         operands >> tmp;
00370         value += tmp;
00371     }
00372     kdDebug(s_area) << "value: " << value << endl;
00373 }
00374 
00375 void Powerpoint::opCurrentUserAtom(
00376     Header & /* op */,
00377     Q_UINT32 /*bytes*/,
00378     QDataStream &operands)
00379 {
00380 
00381     const Q_UINT32 MAGIC_NUMBER = (Q_UINT32)(-476987297);
00382     //unsigned i;
00383 
00384     operands >> mCurrentUserAtom.size >> mCurrentUserAtom.magic >> mCurrentUserAtom.offsetToCurrentEdit >>
00385         mCurrentUserAtom.lenUserName >> mCurrentUserAtom.docFileVersion >> mCurrentUserAtom.majorVersion >>
00386         mCurrentUserAtom.minorVersion;
00387 
00388     kdDebug(s_area) << "\nPSR_CurrentUserAtom:" <<
00389         "\n\tsize: " << mCurrentUserAtom.size <<
00390         "\n\tmagic: " << mCurrentUserAtom.magic <<
00391         "\n\toffsetToCurrentEdit: " << mCurrentUserAtom.offsetToCurrentEdit <<
00392         "\n\tlenUserName: " << mCurrentUserAtom.lenUserName <<
00393         "\n\tdocFileVersion: " << mCurrentUserAtom.docFileVersion <<
00394         "\n\tmajorVersion: " << mCurrentUserAtom.majorVersion <<
00395         "\n\tminorVersion: " << mCurrentUserAtom.minorVersion << endl;
00396 
00397     switch (m_pass)
00398     {
00399     case PASS_GET_SLIDE_REFERENCES:
00400         if (mCurrentUserAtom.size != 20)
00401         {
00402             kdError(s_area) << "invalid size: " << mCurrentUserAtom.size << endl;
00403         }
00404         if (mCurrentUserAtom.magic != MAGIC_NUMBER)
00405         {
00406             kdError(s_area) << "invalid magic number: " << mCurrentUserAtom.magic << endl;
00407         }
00408         if ((mCurrentUserAtom.docFileVersion != 1012) ||
00409             (mCurrentUserAtom.majorVersion != 3) ||
00410             (mCurrentUserAtom.minorVersion != 0))// ||
00411            // (data.release < 8) ||
00412            // (data.release > 10))
00413         {
00414             kdError(s_area) << "invalid version: " << mCurrentUserAtom.docFileVersion <<
00415                 "." << mCurrentUserAtom.majorVersion <<
00416                 "." << mCurrentUserAtom.minorVersion <<
00417                 endl;
00418                 //"." << data.release << endl;
00419         }
00420 
00421         // Now walk main stream starting at current edit point.
00422 
00423         walkRecord(mCurrentUserAtom.offsetToCurrentEdit);
00424         break;
00425     case PASS_GET_SLIDE_CONTENTS:
00426         break;
00427     };
00428 }
00429 
00430 void Powerpoint::opDocument(
00431     Header & /* op */,
00432     Q_UINT32 bytes,
00433     QDataStream &operands)
00434 {
00435     walk(bytes, operands);
00436 }
00437 
00438 void Powerpoint::opDocumentAtom(
00439     Header & /* op */,
00440     Q_UINT32 /*bytes*/,
00441     QDataStream &/*operands*/)
00442 {
00443 }
00444 
00445 void Powerpoint::opEndDocument(
00446     Header & /* op */,
00447     Q_UINT32 bytes,
00448     QDataStream &operands)
00449 {
00450     walk(bytes, operands);
00451 }
00452 
00453 void Powerpoint::opEnvironment(
00454     Header & /* op */,
00455     Q_UINT32 bytes,
00456     QDataStream &operands)
00457 {
00458     walk(bytes, operands);
00459 }
00460 
00461 //
00462 // Contains an ExEmbedAtom and 3 CStrings (the menu name, the program id which
00463 // unqiuely identifies the type of object, and the "paste special" name).
00464 //
00465 void Powerpoint::opExEmbed(
00466     Header & /* op */,
00467     Q_UINT32 bytes,
00468     QDataStream &operands)
00469 {
00470     walk(bytes, operands);
00471 }
00472 
00473 //
00474 // Information about an embedded object.
00475 //
00476 void Powerpoint::opExEmbedAtom(
00477     Header & /* op */,
00478     Q_UINT32,
00479     QDataStream &operands)
00480 {
00481     struct
00482     {
00483         Q_INT32 followColorScheme;
00484         Q_UINT8 cantLockServerB;
00485         Q_UINT8 noSizeToServerB;
00486         Q_UINT8 isTable;
00487     } data;
00488 
00489     operands >> data.followColorScheme;
00490     operands >> data.cantLockServerB;
00491     operands >> data.noSizeToServerB;
00492     operands >> data.isTable;
00493 }
00494 
00495 void Powerpoint::opFontCollection(
00496     Header & /* op */,
00497     Q_UINT32 bytes,
00498     QDataStream &operands)
00499 {
00500     walk(bytes, operands);
00501 }
00502 
00503 void Powerpoint::opFontEntityAtom(
00504     Header & /* op */,
00505     Q_UINT32 /*bytes*/,
00506     QDataStream &/*operands*/)
00507 {
00508 }
00509 
00510 void Powerpoint::opHeadersFooters(
00511     Header & /* op */,
00512     Q_UINT32 bytes,
00513     QDataStream &operands)
00514 {
00515     walk(bytes, operands);
00516 }
00517 
00518 void Powerpoint::opHeadersFootersAtom(
00519     Header & /* op */,
00520     Q_UINT32 /*bytes*/,
00521     QDataStream &/*operands*/)
00522 {
00523 }
00524 
00525 void Powerpoint::opList(
00526     Header & /* op */,
00527     Q_UINT32 bytes,
00528     QDataStream &operands)
00529 {
00530     walk(bytes, operands);
00531 }
00532 
00533 void Powerpoint::opMainMaster(
00534     Header & /* op */,
00535     Q_UINT32 bytes,
00536     QDataStream &operands)
00537 {
00538     walk(bytes, operands);
00539 }
00540 
00541 void Powerpoint::opMsod(
00542     Header & /* op */,
00543     Q_UINT32 bytes,
00544     QDataStream &operands)
00545 {
00546     char *data;
00547 
00548     switch (m_pass)
00549     {
00550     case PASS_GET_SLIDE_REFERENCES:
00551         break;
00552     case PASS_GET_SLIDE_CONTENTS:
00553         data = new char[bytes];
00554         operands.readRawBytes((char *)data, bytes);
00555 kdError() <<"       drgid: "<< m_pptSlide->getPsrReference() << endl;
00556         gotDrawing(m_pptSlide->getPsrReference(), "msod", bytes, data);
00557         delete [] data;
00558         break;
00559     };
00560 }
00561 
00562 void Powerpoint::opNotes(
00563     Header & /* op */,
00564     Q_UINT32 bytes,
00565     QDataStream &operands)
00566 {
00567     walk(bytes, operands);
00568 }
00569 
00570 void Powerpoint::opNotesAtom(
00571     Header & /* op */,
00572     Q_UINT32 /*bytes*/,
00573     QDataStream &operands)
00574 {
00575     struct
00576     {
00577         Q_INT32 slideId;    // Id for the corresponding slide.
00578         Q_UINT16 flags;
00579     } data;
00580 
00581     operands >> data.slideId >> data.flags;
00582 }
00583 
00584 //
00585 // Contains an ExObjListAtom and a list of all objects in a document.
00586 //
00587 void Powerpoint::opExObjList(
00588     Header & /* op */,
00589     Q_UINT32 bytes,
00590     QDataStream &operands)
00591 {
00592     walk(bytes, operands);
00593 }
00594 
00595 //
00596 // Get the next unique identifier for OLE objects.
00597 //
00598 void Powerpoint::opExObjListAtom(
00599     Header & /* op */,
00600     Q_UINT32,
00601     QDataStream &operands)
00602 {
00603     Q_UINT32 objectSeedId;
00604 
00605     operands >> objectSeedId;
00606     kdDebug(s_area) << "next OLE obj id: " << objectSeedId << endl;
00607 }
00608 
00609 void Powerpoint::opExObjRefAtom(
00610     Header & /* op */,
00611     Q_UINT32 /*bytes*/,
00612     QDataStream &/*operands*/)
00613 {
00614 }
00615 
00616 void Powerpoint::opExOleObj(
00617     Header & /* op */,
00618     Q_UINT32 /*bytes*/,
00619     QDataStream &/*operands*/)
00620 {
00621 }
00622 
00623 void Powerpoint::opExOleObjAtom(
00624     Header & /* op */,
00625     Q_UINT32 /*bytes*/,
00626     QDataStream &operands)
00627 {
00628     struct
00629     {
00630         Q_UINT32 drawAspect;
00631         Q_INT32 type;
00632         Q_INT32 objID;
00633         Q_INT32 subType;
00634         Q_INT8 isBlank;
00635     } data;
00636 
00637     operands >> data.drawAspect;
00638     operands >> data.type;
00639     operands >> data.objID;
00640     operands >> data.subType;
00641     operands >> data.isBlank;
00642     kdDebug(s_area) << ((data.type == 0) ? "embedded " : "linked ") <<
00643         "OLE obj id: " << data.objID << endl;
00644 }
00645 
00646 void Powerpoint::opExOleObjStg(
00647     Header & /* op */,
00648     Q_UINT32 /*bytes*/,
00649     QDataStream &/*operands*/)
00650 {
00651 }
00652 
00653 void Powerpoint::opOutlineViewInfo(
00654     Header & /* op */,
00655     Q_UINT32 bytes,
00656     QDataStream &operands)
00657 {
00658     walk(bytes, operands);
00659 }
00660 
00661 void Powerpoint::opPersistPtrIncrementalBlock2(
00662     Header & /* op */,
00663     Q_UINT32 /*bytes*/,
00664     QDataStream &/*operands*/)
00665 {
00666     //PSR_UserEditAtom userEdit;
00667     //Q_INT16 offsetToEdit = mCurrentUserAtom.offsetToCurrentEdit;
00668 
00669     /* huh?
00670     while(0 < offsetToEdit)
00671     {
00672 
00673     }*/
00674 
00675 //       mpLastUserEditAtom;
00676 
00677 }
00678 
00679 void Powerpoint::opPersistPtrIncrementalBlock(
00680     Header & /* op */,
00681     Q_UINT32 bytes,
00682     QDataStream &operands)
00683 {
00684     struct
00685     {
00686         union
00687         {
00688             Q_UINT32 info;
00689             struct
00690             {
00691                 Q_UINT32 offsetNumber: 20;
00692                 Q_UINT32 offsetCount: 12;
00693             } fields;
00694         } header;
00695         Q_UINT32 offset;
00696     } data;
00697     Q_UINT32 length = 0;
00698 
00699     while (length < bytes)
00700     {
00701         unsigned i;
00702 
00703         // Walk references numbered between:
00704         //
00705         //    offsetNumber..offsetNumber + offsetCount - 1
00706         //
00707         operands >> data.header.info;
00708         length += sizeof(data.header.info);
00709     kdDebug(s_area) << "length1: " << length << endl;
00710     kdDebug(s_area) << "m_pass: " << m_pass << endl;
00711     //kdDebug(s_area) << "PASS_GET_SLIDE_REFERENCES: " << PASS_GET_SLIDE_REFERENCES << endl;
00712     kdDebug(s_area) << "data.header.fields.offsetCount: " << data.header.fields.offsetCount << endl;
00713 
00714         for (i = 0; i < data.header.fields.offsetCount; i++)
00715         {
00716             unsigned reference = data.header.fields.offsetNumber + i;
00717 
00718             operands >> data.offset;
00719             length += sizeof(data.offset);
00720         //kdDebug(s_area) << "length2: " << length << endl;
00721             switch (m_pass)
00722             {
00723             case PASS_GET_SLIDE_REFERENCES:
00724 
00725                 // Create a record of this persistent reference.
00726 
00727                 if (m_persistentReferences.end() == m_persistentReferences.find(reference))
00728                 {
00729             if(reference < 5)
00730             {
00731                         kdDebug(s_area) << "persistent reference: " << reference <<
00732                                    ": " << data.offset << endl;
00733                 }
00734                     m_persistentReferences.insert(reference, data.offset);
00735                 }
00736                 else
00737                 {
00738                     // This reference has already been seen! Since the parse proceeds
00739                     // backwards in time form the most recent edit, I assume this means
00740                     // that this is an older version of this slide...so just ignore it.
00741                    // kdDebug(s_area) << "superseded reference: " << reference <<
00742                    //     ": " << data.offset << endl;
00743                 }
00744                 break;
00745             case PASS_GET_SLIDE_CONTENTS:
00746                 break;
00747             };
00748         }
00749     kdDebug(s_area) << "LEAVING persistant block -- " << endl;
00750    }
00751 
00752 }
00753 
00754 void Powerpoint::opPPDrawing(
00755     Header & /* op */,
00756     Q_UINT32 bytes,
00757     QDataStream &operands)
00758 {
00759     walk(bytes, operands);
00760 }
00761 
00762 void Powerpoint::opPPDrawingGroup(
00763     Header & /* op */,
00764     Q_UINT32 bytes,
00765     QDataStream &operands)
00766 {
00767     walk(bytes, operands);
00768 }
00769 
00770 void Powerpoint::opSlide(
00771     Header & /* op */,
00772     Q_UINT32 bytes,
00773     QDataStream &operands)
00774 {
00775     walk(bytes, operands);
00776 }
00777 
00778 void Powerpoint::opSlideAtom(
00779     Header & /* op */,
00780     Q_UINT32 /*bytes*/,
00781     QDataStream &operands)
00782 {
00783     struct
00784     {
00785         Q_UINT8 layout[12];  // Slide layout descriptor.
00786         Q_INT32 masterId;   // Id of the master of the slide. Zero for a master slide.
00787         Q_INT32 notesId;    // Id for the corresponding notes slide. Zero if slide has no notes.
00788         Q_UINT16 flags;
00789     } data;
00790 
00791     Header tmp;
00792     tmp.type = 1015;
00793     tmp.length = sizeof(data.layout);
00794     invokeHandler(tmp, tmp.length, operands);
00795     operands >> data.masterId >> data.notesId >> data.flags;
00796 
00797     kdDebug(s_area) << "\nSlideAtom:" <<
00798                        "\n\tmasterId: " << data.masterId <<
00799                "\n\tnotesId: " << data.notesId <<
00800                "\n\tflags: " << data.flags << endl;
00801 
00802     //invokeHandler(tmp, tmp.length, operands);
00803 
00804 }
00805 
00806 void Powerpoint::opSlideListWithText(
00807     Header & /* op */,
00808     Q_UINT32 bytes,
00809     QDataStream &operands)
00810 {
00811     walk(bytes, operands);
00812 }
00813 
00814 void Powerpoint::opSlidePersistAtom(
00815     Header & /* op */,
00816     Q_UINT32 /*bytes*/,
00817     QDataStream &operands)
00818 {
00819     struct
00820     {
00821         Q_UINT32 psrReference;   // Logical reference to the slide persist object.
00822         Q_UINT32 flags;          // If bit 3 set then slide contains shapes other than placeholders.
00823         Q_INT32 numberTexts;    // Number of placeholder texts stored with the persist object.
00824         Q_INT32 slideId;        // Unique slide identifier, used for OLE link monikers for example.
00825         Q_UINT32 reserved;
00826     } data;
00827 
00828     operands >> data.psrReference >> data.flags >> data.numberTexts >>
00829         data.slideId >> data.reserved;
00830 
00831      kdDebug(s_area) << "\nopSlidePersistAtom: " <<
00832                        "\n\tpsrReference: " << data.psrReference <<
00833                "\n\tflags: " << data.flags <<
00834                "\n\tnumberTexts: " << data.numberTexts <<
00835                "\n\tslideId: " << data.slideId <<
00836                "\n\treserved: " << data.reserved << endl;
00837 
00838    switch (m_pass)
00839     {
00840     case PASS_GET_SLIDE_REFERENCES:
00841         if(data.slideId > 0)//if not master slide.. is there another way to tell???
00842     {
00843         m_pptSlide = new PptSlide;
00844         m_pptSlide->setPsrReference(data.psrReference);
00845         m_slideList.append(m_pptSlide);
00846 
00847         kdDebug(s_area) << "XXXXXXXXXslide: " << data.psrReference <<
00848         " has texts: " << data.numberTexts << endl;
00849     }
00850         break;
00851     case PASS_GET_SLIDE_CONTENTS:
00852         break;
00853     };
00854 }
00855 
00856 void Powerpoint::opSlideViewInfo(
00857     Header & /* op */,
00858     Q_UINT32 bytes,
00859     QDataStream &operands)
00860 {
00861     walk(bytes, operands);
00862 }
00863 
00864 void Powerpoint::opSrKinsoku(
00865     Header & /* op */,
00866     Q_UINT32 bytes,
00867     QDataStream &operands)
00868 {
00869     walk(bytes, operands);
00870 }
00871 
00872 void Powerpoint::opSSDocInfoAtom(
00873     Header & /* op */,
00874     Q_UINT32 /*bytes*/,
00875     QDataStream &/*operands*/)
00876 {
00877 }
00878 
00879 void Powerpoint::opSSSlideLayoutAtom(
00880     Header & /* op */,
00881     Q_UINT32 /*bytes*/,
00882     QDataStream &operands)
00883 {
00884 
00885     PSR_SSlideLayoutAtom data;
00886     unsigned i;
00887 
00888     operands >> data.geom;
00889     for (i = 0; i < sizeof(data.placeholderId); i++)
00890     {
00891         operands >> data.placeholderId[i];
00892     }
00893 
00894     kdDebug(s_area) << "\nPSR_SSlideLayoutAtom:" <<
00895                        "\n\tgeom: " << data.geom <<
00896                "\n\tplaceholderId[0]: " << data.placeholderId[0] <<
00897                "\n\tplaceholderId[1]: " << data.placeholderId[1] <<
00898                "\n\tplaceholderId[2]: " << data.placeholderId[2] <<
00899                "\n\tplaceholderId[3]: " << data.placeholderId[3] <<
00900                "\n\tplaceholderId[4]: " << data.placeholderId[4] <<
00901                "\n\tplaceholderId[5]: " << data.placeholderId[5] <<
00902                "\n\tplaceholderId[6]: " << data.placeholderId[6] <<
00903                "\n\tplaceholderId[7]: " << data.placeholderId[7] << endl;
00904 
00905 }
00906 //this is where we set bold/italic/etc and paragraph styles
00907 void Powerpoint::opStyleTextPropAtom(
00908     Header & /* op */,
00909     Q_UINT32 bytes,
00910     QDataStream &operands)
00911 {
00912 
00913     Q_UINT16 totalLength = 0;
00914     Q_UINT16 length = 0;
00915     Q_UINT32 style1 = 0;
00916     Q_UINT32 style2 = 0;
00917     Q_UINT16 style3 = 0;
00918     Q_UINT32 BOLD       = 0x00010000;
00919     Q_UINT32 ITALIC     = 0x00020000;
00920     Q_UINT32 UNDERLINE  = 0x00040000;
00921 
00922     //--get the paragraph style?
00923     operands >> length >> style1 >> style2;
00924     totalLength += 10;
00925 
00926     kdDebug(s_area) << "\nopStyleTextPropAtom1:" <<
00927             "\n\tlength: " << length <<
00928             "\n\tstyle1: " << style1 <<
00929             "\n\tstyle2: " << style2 << endl;
00930     //--
00931 
00932     //--get the char styles
00933     while(bytes > totalLength)
00934     {
00935         length = 0;
00936         style1 = 0;
00937         style2 = 0;
00938         style3 = 0;
00939 
00940         operands >> length >> style1;
00941         totalLength += 6;
00942         if(style1 == 0)
00943         {
00944             operands >> style3;
00945             totalLength += 2;
00946         }
00947         else
00948         {
00949             operands >> style2;
00950             totalLength += 4;
00951         }
00952 
00953         kdDebug(s_area) << "\nopStyleTextPropAtom2:" <<
00954                 "\n\tlength: " << length <<
00955                 "\n\tstyle1: " << style1 <<
00956                 "\n\tstyle2: " << style2 <<
00957                 "\n\tstyle3: " << style3 << endl;
00958         if(style1 & BOLD)
00959             kdDebug(s_area) << "BOLD here" << endl;
00960         if(style1 & ITALIC)
00961             kdDebug(s_area) << "ITALIC here" << endl;
00962         if(style1 & UNDERLINE)
00963             kdDebug(s_area) << "UNDERLINE here" << endl;
00964     }
00965     //--
00966 }
00967 
00968 void Powerpoint::opTextBytesAtom(
00969     Header & /* op */,
00970     Q_UINT32 bytes,
00971     QDataStream &operands)
00972 {
00973     QString data;
00974     unsigned i;
00975 
00976     for (i = 0; i < bytes; i++)
00977     {
00978         Q_UINT8 tmp;
00979 
00980         operands >> tmp;
00981         data += tmp;
00982     }
00983      kdDebug(s_area) << "\nopTextBytesAtom: " <<
00984                    "\n\tdata: " << data << endl;
00985 
00986     //SlideText *text;
00987     switch (m_pass)
00988     {
00989     case PASS_GET_SLIDE_REFERENCES:
00990         //text = new SlideText;
00991         //text->type = m_textType;
00992         //text->data = data;
00993         //m_slide->text.append(text);
00994     if(m_pptSlide)
00995     {
00996         m_pptSlide->addText(data, m_textType);
00997         kdDebug(s_area) << "Text Added: " << data << " type: " << m_textType << endl;
00998     }
00999     else
01000             kdDebug(s_area) << "WEVE GOTS US AN ERROR!!!" << endl;
01001 
01002         break;
01003     case PASS_GET_SLIDE_CONTENTS:
01004         break;
01005     };
01006 }
01007 
01008 void Powerpoint::opTextCharsAtom(
01009     Header & /* op */,
01010     Q_UINT32 bytes,
01011     QDataStream &operands)
01012 {
01013     QString data;
01014     unsigned i;
01015 
01016     for (i = 0; i < bytes / 2; i++)
01017     {
01018         Q_UINT16 tmp;
01019 
01020         operands >> tmp;
01021         data += tmp;
01022     }
01023 
01024     //SlideText *text;
01025     switch (m_pass)
01026     {
01027     case PASS_GET_SLIDE_REFERENCES:
01028         //text = new SlideText;
01029         //text->type = m_textType;
01030         //text->data = data;
01031         //m_slide->text.append(text);
01032     if(m_pptSlide)
01033     {
01034         m_pptSlide->addText(data, m_textType);
01035         kdDebug(s_area) << "Text Added: " << data << " type: " << m_textType << endl;
01036     }
01037     else
01038             kdDebug(s_area) << "WEVE GOTS US AN ERROR!!!" << endl;
01039 
01040         break;
01041     case PASS_GET_SLIDE_CONTENTS:
01042         break;
01043     };
01044 }
01045 
01046 void Powerpoint::opTextHeaderAtom(
01047     Header & /* op */,
01048     Q_UINT32 /*bytes*/,
01049     QDataStream &operands)
01050 {
01051     struct
01052     {
01053         Q_UINT32 txType;    // Type of text:
01054                             //
01055                             // 0 Title
01056                             // 1 Body
01057                             // 2 Notes
01058                             // 3 Not Used
01059                             // 4 Other (Text in a shape)
01060                             // 5 Center body (subtitle in title slide)
01061                             // 6 Center title (title in title slide)
01062                             // 7 Half body (body in two-column slide)
01063                             // 8 Quarter body (body in four-body slide)
01064      } data;
01065 
01066     operands >> data.txType;
01067 
01068     kdDebug(s_area) << "\nopTextHeaderAtom:" <<
01069                    "\n\ttxType: " << data.txType << endl;
01070 
01071     switch (m_pass)
01072     {
01073     case PASS_GET_SLIDE_REFERENCES:
01074         m_textType = data.txType;
01075         break;
01076     case PASS_GET_SLIDE_CONTENTS:
01077         break;
01078     };
01079 }
01080 
01081 void Powerpoint::opTextSpecInfoAtom(
01082     Header & /* op */,
01083     Q_UINT32 /*bytes*/,
01084     QDataStream &/*operands*/)
01085 {
01086 }
01087 
01088 void Powerpoint::opTxMasterStyleAtom(
01089     Header & /* op */,
01090     Q_UINT32 /*bytes*/,
01091     QDataStream &/*operands*/)
01092 {
01093 }
01094 
01095 void Powerpoint::opTxSIStyleAtom(
01096     Header & /* op */,
01097     Q_UINT32 /*bytes*/,
01098     QDataStream &/*operands*/)
01099 {
01100 }
01101 
01102 //
01103 // This routine is where the parse actually gets going. It should be the first
01104 // structure encoutered in the main OLE stream.
01105 //
01106 void Powerpoint::opUserEditAtom(
01107     Header & /* op */,
01108     Q_UINT32 /*bytes*/,
01109     QDataStream &operands)
01110 {
01111 
01112     operands >> mUserEditAtom.lastSlideID  >> mUserEditAtom.version >> mUserEditAtom.offsetLastEdit >>
01113         mUserEditAtom.offsetPersistDirectory >> mUserEditAtom.documentRef >>
01114         mUserEditAtom.maxPersistWritten >> mUserEditAtom.lastViewType;
01115 
01116     if(mEditOffset == 0)mEditOffset = mUserEditAtom.offsetLastEdit;
01117 
01118     kdDebug(s_area) << "\nPSR_UserEditAtom:" <<
01119                        "\n\tlastSlideID: " << mUserEditAtom.lastSlideID <<
01120                "\n\tversion: " << mUserEditAtom.version <<
01121                "\n\toffsetLastEdit: " << mUserEditAtom.offsetLastEdit <<
01122                "\n\toffsetPersistDirectory: " << mUserEditAtom.offsetPersistDirectory <<
01123                "\n\tdocumentRef: " << mUserEditAtom.documentRef <<
01124                "\n\tmaxPersistWritten: " << mUserEditAtom.maxPersistWritten <<
01125                "\n\tlastViewType: " << mUserEditAtom.lastViewType << endl;
01126 
01127     if (!m_documentRefFound)
01128     {
01129         m_documentRef = mUserEditAtom.documentRef;
01130         m_documentRefFound = true;
01131     }
01132     switch (m_pass)
01133     {
01134     case PASS_GET_SLIDE_REFERENCES:
01135 
01136         // Gather the persistent references. That should fill the list of
01137         // references which we then use to look up our document.
01138 
01139         walkRecord(mUserEditAtom.offsetPersistDirectory);
01140 
01141         // Now recursively walk the main OLE stream parsing previous edits.
01142 
01143         if (mUserEditAtom.offsetLastEdit)
01144         {
01145             m_editDepth++;
01146             walkRecord(mUserEditAtom.offsetLastEdit);
01147             m_editDepth--;
01148         }
01149         break;
01150     case PASS_GET_SLIDE_CONTENTS:
01151         break;
01152     };
01153 }
01154 
01155 void Powerpoint::opVBAInfo(
01156     Header & /* op */,
01157     Q_UINT32 bytes,
01158     QDataStream &operands)
01159 {
01160     walk(bytes, operands);
01161 }
01162 
01163 void Powerpoint::skip(Q_UINT32 bytes, QDataStream &operands)
01164 {
01165     if ((int)bytes < 0)
01166     {
01167         kdError(s_area) << "skip: " << (int)bytes << endl;
01168         return;
01169     }
01170     if (bytes)
01171     {
01172         Q_UINT32 i;
01173         Q_UINT8 discard;
01174 
01175         kdDebug(s_area) << "skip: " << bytes << endl;
01176         for (i = 0; i < bytes; i++)
01177         {
01178             operands >> discard;
01179         }
01180     }
01181 }
01182 
01183 //
01184 // Handle a container record.
01185 //
01186 void Powerpoint::walk(Q_UINT32 bytes, QDataStream &operands)
01187 {
01188     Header op;
01189     Q_UINT32 length = 0;
01190 
01191     // Stop parsing when there are no more records. Note that we stop as soon
01192     // as we cannot get a complete header.
01193     while (length + 8 <= bytes)
01194     {
01195         operands >> op.opcode.info >> op.type >> op.length;
01196 
01197         // If we get some duff data, protect ourselves.
01198         if (length + op.length + 8 > bytes)
01199         {
01200             op.length = bytes - length - 8;
01201         }
01202         length += op.length + 8;
01203 
01204         // Package the arguments...
01205 
01206     invokeHandler(op, op.length, operands);
01207     }
01208 
01209     // Eat unexpected data that the caller may expect us to consume.
01210     skip(bytes - length, operands);
01211 }
01212 
01213 void Powerpoint::walk(Q_UINT32 mainStreamOffset)
01214 {
01215     Q_UINT32 length = m_mainStream.length - mainStreamOffset;
01216     QByteArray a;
01217 
01218     a.setRawData((const char *)m_mainStream.data + mainStreamOffset, length);
01219     QDataStream stream(a, IO_ReadOnly);
01220     stream.setByteOrder(QDataStream::LittleEndian);
01221     walk(length, stream);
01222     a.resetRawData((const char *)m_mainStream.data + mainStreamOffset, length);
01223 }
01224 void Powerpoint::walkDocument()
01225 {
01226     QByteArray a;
01227     Q_UINT32 mainStreamOffset = 0;
01228     Q_UINT32 bytes = m_mainStream.length - mainStreamOffset;
01229 
01230     a.setRawData((const char *)m_mainStream.data + mainStreamOffset, bytes);
01231     QDataStream stream(a, IO_ReadOnly);
01232     stream.setByteOrder(QDataStream::LittleEndian);
01233     //--get tho the slide list
01234     Header op;
01235     Q_UINT32 length = 0;
01236 
01237     // Stop parsing when there are no more records. Note that we stop as soon
01238     // as we cannot get a complete header.
01239     while (length + 8 <= bytes && op.type != 1000)//document
01240     {
01241         stream >> op.opcode.info >> op.type >> op.length;
01242 
01243         // If we get some duff data, protect ourselves.
01244         if (length + op.length + 8 > bytes)
01245         {
01246             op.length = bytes - length - 8;
01247         }
01248         length += op.length + 8;
01249     }
01250 
01251     //--
01252     invokeHandler(op, op.length, stream);
01253     a.resetRawData((const char *)m_mainStream.data + mainStreamOffset, bytes);
01254 
01255 }
01256 
01257 void Powerpoint::walkRecord(Q_UINT32 bytes, const unsigned char *operands)
01258 {
01259     // First read what should be the next header using one stream.
01260 
01261     kdError(s_area) << "WalkRecord - bytes: " << bytes << endl;
01262 
01263     Q_UINT32 length = sizeof(Header);
01264     QByteArray a;
01265     Header op;
01266 
01267     a.setRawData((const char *)operands, bytes);
01268     QDataStream stream1(a, IO_ReadOnly);
01269     stream1.setByteOrder(QDataStream::LittleEndian);
01270     stream1 >> op.opcode.info >> op.type >> op.length;
01271     a.resetRawData((const char *)operands, bytes);
01272 
01273     // Armed with the length, parse in the usual way using a second stream.
01274 
01275     length += op.length;
01276     a.setRawData((const char *)operands, length);
01277     QDataStream stream2(a, IO_ReadOnly);
01278     stream2.setByteOrder(QDataStream::LittleEndian);
01279     walk(length, stream2);
01280     a.resetRawData((const char *)operands, length);
01281 }
01282 
01283 void Powerpoint::walkRecord(Q_UINT32 mainStreamOffset)
01284 {
01285     walkRecord(sizeof(Header), m_mainStream.data + mainStreamOffset);
01286 }
01287 
01288 void Powerpoint::walkReference(Q_UINT32 reference)
01289 {
01290     if (m_persistentReferences.end() == m_persistentReferences.find(reference))
01291     {
01292         kdError(s_area) << "cannot find reference: " << reference << endl;
01293     }
01294     else
01295     {
01296         unsigned offset = m_persistentReferences[reference];
01297         kdDebug(s_area) << "found reference: " << reference <<
01298             " offset: " << offset << endl;
01299         walkRecord(offset);
01300     kdDebug(s_area) << "****************************" << endl;
01301 
01302     }
01303 }
KDE Home | KDE Accessibility Home | Description of Access Keys