~ubuntu-branches/ubuntu/breezy/koffice/breezy

« back to all changes in this revision

Viewing changes to filters/kword/starwriter/polestorageio.h

  • Committer: Bazaar Package Importer
  • Author(s): Ben Burton
  • Date: 2004-05-09 11:33:00 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040509113300-vfrdadqsvjfuhn3b
Tags: 1:1.3.1-1
* New upstream bugfix release.
* Built against newer imagemagick (closes: #246623).
* Made koffice-libs/kformula recommend/depend on latex-xft-fonts, which
  provides mathematical fonts that the formula editor can use.  Also
  patched the kformula part to make these fonts the default.
* Changed kword menu hint from "WordProcessors" to "Word processors"
  (closes: #246209).
* Spellchecker configuration is now fixed (closes: #221256, #227568).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* POLE - Portable library to access OLE Storage 
 
2
   Copyright (C) 2002 Ariya Hidayat <ariya@kde.org>
 
3
 
 
4
   This library is free software; you can redistribute it and/or
 
5
   modify it under the terms of the GNU Library General Public
 
6
   License as published by the Free Software Foundation; either
 
7
   version 2 of the License, or (at your option) any later version.
 
8
   
 
9
   This library is distributed in the hope that it will be useful,
 
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
   Library General Public License for more details.
 
13
 
 
14
   You should have received a copy of the GNU Library General Public License
 
15
   along with this library; see the file COPYING.LIB.  If not, write to
 
16
   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
17
   Boston, MA 02111-1307, US
 
18
*/
 
19
 
 
20
#ifndef POLE_STORAGEIO_H
 
21
#define POLE_STORAGEIO_H
 
22
 
 
23
#include <fstream>
 
24
#include <string>
 
25
#include <vector>
 
26
 
 
27
#include <polestorage.h>
 
28
 
 
29
namespace POLE
 
30
{
 
31
 
 
32
class Entry
 
33
{
 
34
  public:
 
35
    Entry* parent;
 
36
    std::string name;
 
37
    unsigned long size;
 
38
    unsigned start;
 
39
    bool dir;
 
40
    std::vector<Entry*> children;
 
41
    Entry();
 
42
    ~Entry();
 
43
  private:
 
44
    Entry( const Entry& );
 
45
    Entry& operator=( const Entry& );
 
46
};
 
47
 
 
48
class AllocTable
 
49
{
 
50
  public:
 
51
 
 
52
    AllocTable();
 
53
 
 
54
    ~AllocTable();
 
55
 
 
56
    bool dirty;
 
57
 
 
58
    void clear();
 
59
 
 
60
    unsigned long size();
 
61
 
 
62
    void resize( unsigned long newsize );
 
63
 
 
64
    void set( unsigned long index, unsigned long val );
 
65
 
 
66
    std::vector<unsigned long> follow( unsigned long start );
 
67
 
 
68
    unsigned long operator[](unsigned long index );
 
69
 
 
70
  private:
 
71
 
 
72
    std::vector<unsigned long> data;
 
73
 
 
74
    AllocTable( const AllocTable& );
 
75
 
 
76
    AllocTable& operator=( const AllocTable& );
 
77
};
 
78
 
 
79
class StorageIO
 
80
{
 
81
  public:
 
82
 
 
83
    // result of operation
 
84
    int result;
 
85
 
 
86
    // owner of this object
 
87
    Storage* doc;
 
88
 
 
89
    // filename (possible required)
 
90
    std::string filename;
 
91
 
 
92
    // working mode: ReadOnly, WriteOnly, or ReadWrite
 
93
    int mode;
 
94
 
 
95
    // working file
 
96
    std::fstream file;
 
97
 
 
98
    // size of the file
 
99
    unsigned long filesize;
 
100
 
 
101
    // header (first 512 byte)
 
102
    unsigned char header[512];
 
103
 
 
104
    // magic id, first 8 bytes of header
 
105
    unsigned char magic[8];
 
106
 
 
107
    // switch from small to big file (usually 4K)
 
108
    unsigned threshold;
 
109
 
 
110
    // size of big block (should be 512 bytes)
 
111
    unsigned bb_size;
 
112
 
 
113
    //  size of small block (should be 64 bytes )
 
114
    unsigned sb_size;
 
115
 
 
116
    // allocation table for big blocks
 
117
    AllocTable bb;
 
118
    
 
119
    // allocation table for small blocks
 
120
    AllocTable sb;
 
121
 
 
122
    // starting block index to store small-BAT
 
123
    unsigned sbat_start;
 
124
 
 
125
    // blocks where to find data for "small" files
 
126
    std::vector<unsigned long> sb_blocks;
 
127
 
 
128
    // starting block to store meta BAT
 
129
    unsigned mbat_start;
 
130
    
 
131
    // starting block index to store directory info
 
132
    unsigned dirent_start;
 
133
 
 
134
    // root directory entry
 
135
    Entry* root;
 
136
    
 
137
    // current directory entry
 
138
    Entry* current_dir;
 
139
 
 
140
    // constructor
 
141
    StorageIO( Storage* storage, const char* fileName, int mode );
 
142
 
 
143
    // destructor
 
144
    ~StorageIO();
 
145
 
 
146
    void flush();
 
147
 
 
148
    unsigned long loadBigBlocks( std::vector<unsigned long> blocks, unsigned char* buffer, unsigned long maxlen );
 
149
 
 
150
    unsigned long loadBigBlock( unsigned long block, unsigned char* buffer, unsigned long maxlen );
 
151
 
 
152
    unsigned long loadSmallBlocks( std::vector<unsigned long> blocks, unsigned char* buffer, unsigned long maxlen );
 
153
 
 
154
    unsigned long loadSmallBlock( unsigned long block, unsigned char* buffer, unsigned long maxlen );
 
155
 
 
156
    // construct directory tree
 
157
    Entry* buildTree( Entry* parent, int index, const unsigned char* dirent );
 
158
 
 
159
    std::string fullName( Entry* e );
 
160
 
 
161
    // given a fullname (e.g "/ObjectPool/_1020961869"), find the entry
 
162
    Entry* entry( const std::string& name );
 
163
 
 
164
 
 
165
  private:
 
166
 
 
167
    void load();
 
168
 
 
169
    void create();
 
170
 
 
171
    // no copy or assign
 
172
    StorageIO( const StorageIO& );
 
173
    StorageIO& operator=( const StorageIO& );
 
174
 
 
175
};
 
176
 
 
177
 
 
178
}
 
179
 
 
180
#endif // POLE_STORAGEIO_H