Warning, file /office/calligra/filters/libmsooxml/ooxml_pole.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* POLE - Portable C++ library to access OLE Storage 0002 Copyright (C) 2002-2005 Ariya Hidayat <ariya@kde.org> 0003 0004 Redistribution and use in source and binary forms, with or without 0005 modification, are permitted provided that the following conditions 0006 are met: 0007 * Redistributions of source code must retain the above copyright notice, 0008 this list of conditions and the following disclaimer. 0009 * Redistributions in binary form must reproduce the above copyright notice, 0010 this list of conditions and the following disclaimer in the documentation 0011 and/or other materials provided with the distribution. 0012 * Neither the name of the authors nor the names of its contributors may be 0013 used to endorse or promote products derived from this software without 0014 specific prior written permission. 0015 0016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 0017 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0018 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0019 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 0020 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 0021 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 0022 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0023 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0024 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 0025 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 0026 THE POSSIBILITY OF SUCH DAMAGE. 0027 */ 0028 0029 #ifndef OOXML_POLE_H 0030 #define OOXML_POLE_H 0031 0032 #include "komsooxml_export.h" 0033 0034 class QIODevice; 0035 0036 #include <string> 0037 #include <list> 0038 0039 namespace OOXML_POLE 0040 { 0041 0042 class StorageIO; 0043 class Stream; 0044 class StreamIO; 0045 0046 class KOMSOOXML_EXPORT Storage 0047 { 0048 friend class Stream; 0049 friend class StreamOut; 0050 0051 public: 0052 0053 // for Storage::result() 0054 enum { Ok, OpenFailed, NotOLE, BadOLE, UnknownError }; 0055 0056 /** 0057 * Constructs a storage with name filename. 0058 **/ 0059 explicit Storage(QIODevice* file); 0060 0061 /** 0062 * Destroys the storage. 0063 **/ 0064 ~Storage(); 0065 0066 /** 0067 * Opens the storage. Returns true if no error occurs. 0068 **/ 0069 bool open(); 0070 0071 /** 0072 * Closes the storage. 0073 **/ 0074 void close(); 0075 0076 /** 0077 * Returns the error code of last operation. 0078 **/ 0079 int result(); 0080 0081 /** 0082 * Finds all stream and directories in given path. 0083 **/ 0084 std::list<std::string> entries(const std::string& path = "/"); 0085 0086 /** 0087 * Returns true if specified entry name is a directory. 0088 */ 0089 bool isDirectory(const std::string& name); 0090 0091 /** 0092 * Finds and returns a stream with the specified name. 0093 * If reuse is true, this function returns the already created stream 0094 * (if any). Otherwise it will create the stream. 0095 * 0096 * When errors occur, this function returns nullptr. 0097 * 0098 * You do not need to delete the created stream, it will be handled 0099 * automatically. 0100 **/ 0101 Stream* stream(const std::string& name, bool reuse = true); 0102 //Stream* stream( const std::string& name, int mode = Stream::ReadOnly, bool reuse = true ); 0103 0104 private: 0105 StorageIO* io; 0106 0107 // no copy or assign 0108 Storage(const Storage&); 0109 Storage& operator=(const Storage&); 0110 0111 }; 0112 0113 class KOMSOOXML_EXPORT Stream 0114 { 0115 friend class Storage; 0116 friend class StorageIO; 0117 0118 public: 0119 0120 /** 0121 * Creates a new stream. 0122 */ 0123 // name must be absolute, e.g "/Workbook" 0124 Stream(Storage* storage, const std::string& name); 0125 0126 /** 0127 * Destroys the stream. 0128 */ 0129 ~Stream(); 0130 0131 /** 0132 * Returns the full stream name. 0133 */ 0134 std::string fullName(); 0135 0136 /** 0137 * Returns the stream size. 0138 **/ 0139 unsigned long size(); 0140 0141 /** 0142 * Returns the current read/write position. 0143 **/ 0144 unsigned long tell(); 0145 0146 /** 0147 * Sets the read/write position. 0148 **/ 0149 void seek(unsigned long pos); 0150 0151 /** 0152 * Reads a byte. 0153 **/ 0154 int getch(); 0155 0156 /** 0157 * Reads a block of data. 0158 **/ 0159 unsigned long read(unsigned char* data, unsigned long maxlen); 0160 0161 /** 0162 * Returns true if the read/write position is past the file. 0163 **/ 0164 bool eof(); 0165 0166 /** 0167 * Returns true whenever error occurs. 0168 **/ 0169 bool fail(); 0170 0171 private: 0172 StreamIO* io; 0173 0174 // no copy or assign 0175 Stream(const Stream&); 0176 Stream& operator=(const Stream&); 0177 }; 0178 0179 } 0180 0181 #endif // POLE_H