Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

OfficeHelper.hpp

Go to the documentation of this file.
00001 /*==========================================================================
00002  * Copyright (c) 2003-2004 University of Massachusetts.  All Rights Reserved.
00003  *
00004  * Use of the Lemur Toolkit for Language Modeling and Information Retrieval
00005  * is subject to the terms of the software license set forth in the LICENSE
00006  * file included with this software, and also available at
00007  * http://www.lemurproject.org/license.html
00008  *
00009  *==========================================================================
00010  */
00011 
00012 #ifndef INDRI_OFFICEHELPER_HPP
00013 #define INDRI_OFFICEHELPER_HPP
00014 
00015 
00016 #ifdef WIN32
00017 #include "lemur-compat.hpp"
00018 #include "indri/Buffer.hpp"
00019 #include "indri/UnparsedDocument.hpp"
00020 #include "Exception.hpp"
00021 #include <string>
00022 #include "indri/DocumentIterator.hpp"
00023 
00024 
00025 #include <ole2.h>
00026 
00027 #define OFFICE_AUTHOR ("Author")//<field>author</field> 
00028 #define OFFICE_TITLE ("Title")//<field>title</field>    
00029 #define OFFICE_SUBJECT ("Subject")//<field>subject</field>      
00030 #define OFFICE_LASTAUTHOR ("Last author")//<field>lastauthor</field>    
00031 #define OFFICE_COMPANY ("Company")//<field>company</field>
00032 
00033 namespace indri
00034 {
00035   namespace parse
00036   {
00037 
00038     class OfficeHelper{
00039     private:
00040       static const char* _office_properties[];
00041       char _keyNames[10][100];
00042       //buildInDocumentproperties
00043       std::string _author;
00044       std::string _subject;
00045       std::string _lastAuthor;
00046       std::string _company;
00047       std::string _title;
00048       int _length_office_properties;
00049 
00050 
00051       std::string GetPropertyValue(IDispatch *pDoc, OLECHAR *pItem);
00052       std::string* GetOfficeMemberVariable(const char* pOfficeProperty);
00053       void setMetadataPair(UnparsedDocument* unparsedDocument,int propertyNr);
00054       void setMetadataPair(UnparsedDocument* unparsedDocument,const char* pOfficeProperty);
00055     public:
00056       OfficeHelper();
00057       ~OfficeHelper();
00058       HRESULT AutoWrap(int autoType, VARIANT *pvResult, IDispatch *pDisp, LPOLESTR ptName, int cArgs...);                 
00059 
00060       //get the MetaData from the OfficeDocument and Set them in the IndriMetaData
00061       void SetOfficeMetaData(IDispatch* iDocumentDispatch, UnparsedDocument* unparsedDocument);
00062       void SetOfficeMetaData(const char *officeType, BSTR *bStr, UnparsedDocument *unparsedDocument);
00063       //com helpers
00064       void com_property_get( VARIANT* result, IDispatch* dispatch, LPOLESTR name ) ;
00065       void com_property_put( VARIANT* result, IDispatch* dispatch, LPOLESTR name, VARIANT* parameter );
00066       void com_method_execute( VARIANT* result, IDispatch* dispatch, LPOLESTR name, VARIANT* parameter = 0 );
00067       void com_method_execute( VARIANT* result, IDispatch* dispatch, LPOLESTR name, DISPPARAMS* parameters );
00068       DISPID com_get_dispatch_id( IDispatch* dispatch, LPOLESTR name );
00069       void copy_bstr_to_buffer( indri::utility::Buffer& docBuffer, BSTR bstr );
00070       void copy_bstr_to_string(std::string& pString, BSTR bstr, bool append=false);
00071 
00072       std::string GetAuthor();
00073       std::string GetSubject();
00074       std::string GetLastAuthor();
00075       std::string GetCompany();
00076       std::string GetTitle();
00077       void writeHeaderToBuffer(indri::utility::Buffer& docBuffer);
00078     };
00079   }
00080 }
00081 #endif
00082 #endif // INDRI_OFFICEHELPER_HPP

Generated on Tue Jun 15 11:02:54 2010 for Lemur by doxygen 1.3.4