muhammara 3.1.1 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -2
- package/PDFRStreamForBuffer.js +7 -2
- package/PDFRStreamForFile.js +7 -2
- package/package.json +1 -1
- package/src/ObjectByteReaderWithPosition.cpp +15 -0
- package/src/ObjectByteReaderWithPosition.h +1 -0
- package/src/deps/PDFWriter/IByteReaderWithPosition.h +4 -0
- package/src/deps/PDFWriter/InputBufferedStream.cpp +10 -3
- package/src/deps/PDFWriter/InputBufferedStream.h +2 -0
- package/src/deps/PDFWriter/InputByteArrayStream.cpp +9 -2
- package/src/deps/PDFWriter/InputByteArrayStream.h +2 -0
- package/src/deps/PDFWriter/InputFileStream.cpp +9 -2
- package/src/deps/PDFWriter/InputFileStream.h +2 -0
- package/src/deps/PDFWriter/InputStringBufferStream.cpp +10 -3
- package/src/deps/PDFWriter/InputStringBufferStream.h +2 -0
- package/src/deps/PDFWriter/InputStringStream.cpp +7 -0
- package/src/deps/PDFWriter/InputStringStream.h +2 -0
- package/src/deps/PDFWriter/PDFParser.cpp +12 -6
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [3.2.0] - 2022-10-26
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Add electron 20.3.3
|
|
15
|
+
- Ignore extra data above the header and below the footer in PDF Parser
|
|
16
|
+
- Add node 19.0.0
|
|
17
|
+
|
|
10
18
|
## [3.1.1] - 2022-10-23
|
|
11
19
|
|
|
12
20
|
### Fixed
|
|
@@ -48,6 +56,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
|
48
56
|
- Node < 11 and Electron < 11 removed
|
|
49
57
|
- Renamed typo exported value from eTokenSeprator to eTokenSeparator
|
|
50
58
|
|
|
59
|
+
## [2.6.1] - 2022-10-23
|
|
60
|
+
|
|
61
|
+
### Fixed
|
|
62
|
+
|
|
63
|
+
- Backport: NPE in parser when file ends before it really starts
|
|
64
|
+
|
|
51
65
|
## [2.6.0] - 2022-06-30
|
|
52
66
|
|
|
53
67
|
### Changed
|
|
@@ -280,10 +294,12 @@ with the following changes.
|
|
|
280
294
|
|
|
281
295
|
- Initial release
|
|
282
296
|
|
|
283
|
-
[unreleased]: https://github.com/julianhille/MuhammaraJS/compare/3.
|
|
297
|
+
[unreleased]: https://github.com/julianhille/MuhammaraJS/compare/3.2.0...HEAD
|
|
298
|
+
[3.2.0]: https://github.com/julianhille/MuhammaraJS/compare/3.1.1...3.2.0
|
|
284
299
|
[3.1.1]: https://github.com/julianhille/MuhammaraJS/compare/3.1.0...3.1.1
|
|
285
300
|
[3.1.0]: https://github.com/julianhille/MuhammaraJS/compare/3.0.0...3.1.0
|
|
286
|
-
[3.0.0]: https://github.com/julianhille/MuhammaraJS/compare/2.6.
|
|
301
|
+
[3.0.0]: https://github.com/julianhille/MuhammaraJS/compare/2.6.1...3.0.0
|
|
302
|
+
[2.6.1]: https://github.com/julianhille/MuhammaraJS/compare/2.6.0...2.6.1
|
|
287
303
|
[2.6.0]: https://github.com/julianhille/MuhammaraJS/compare/2.5.0...2.6.0
|
|
288
304
|
[2.5.0]: https://github.com/julianhille/MuhammaraJS/compare/2.4.0...2.5.0
|
|
289
305
|
[2.4.0]: https://github.com/julianhille/MuhammaraJS/compare/2.3.0...2.4.0
|
package/PDFRStreamForBuffer.js
CHANGED
|
@@ -8,6 +8,7 @@ function PDFRStreamForBuffer(buffer) {
|
|
|
8
8
|
this.innerArray = Array.prototype.slice.call(buffer, 0);
|
|
9
9
|
this.rposition = 0;
|
|
10
10
|
this.fileSize = this.innerArray.length;
|
|
11
|
+
this.mStartPosition = 0;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
PDFRStreamForBuffer.prototype.read = function (inAmount) {
|
|
@@ -25,7 +26,7 @@ PDFRStreamForBuffer.prototype.notEnded = function () {
|
|
|
25
26
|
};
|
|
26
27
|
|
|
27
28
|
PDFRStreamForBuffer.prototype.setPosition = function (inPosition) {
|
|
28
|
-
this.rposition = inPosition;
|
|
29
|
+
this.rposition = this.mStartPosition + inPosition;
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
PDFRStreamForBuffer.prototype.setPositionFromEnd = function (inPosition) {
|
|
@@ -37,7 +38,11 @@ PDFRStreamForBuffer.prototype.skip = function (inAmount) {
|
|
|
37
38
|
};
|
|
38
39
|
|
|
39
40
|
PDFRStreamForBuffer.prototype.getCurrentPosition = function () {
|
|
40
|
-
return this.rposition;
|
|
41
|
+
return this.rposition - this.mStartPosition;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
PDFRStreamForBuffer.prototype.moveStartPosition = function (inPosition) {
|
|
45
|
+
this.mStartPosition = inPosition;
|
|
41
46
|
};
|
|
42
47
|
|
|
43
48
|
module.exports = PDFRStreamForBuffer;
|
package/PDFRStreamForFile.js
CHANGED
|
@@ -8,6 +8,7 @@ function PDFRStreamForFile(inPath) {
|
|
|
8
8
|
this.path = inPath;
|
|
9
9
|
this.rposition = 0;
|
|
10
10
|
this.fileSize = fs.statSync(inPath)["size"];
|
|
11
|
+
this.mStartPosition = 0;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
PDFRStreamForFile.prototype.read = function (inAmount) {
|
|
@@ -25,7 +26,7 @@ PDFRStreamForFile.prototype.notEnded = function () {
|
|
|
25
26
|
};
|
|
26
27
|
|
|
27
28
|
PDFRStreamForFile.prototype.setPosition = function (inPosition) {
|
|
28
|
-
this.rposition = inPosition;
|
|
29
|
+
this.rposition = this.mStartPosition + inPosition;
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
PDFRStreamForFile.prototype.setPositionFromEnd = function (inPosition) {
|
|
@@ -37,7 +38,11 @@ PDFRStreamForFile.prototype.skip = function (inAmount) {
|
|
|
37
38
|
};
|
|
38
39
|
|
|
39
40
|
PDFRStreamForFile.prototype.getCurrentPosition = function () {
|
|
40
|
-
return this.rposition;
|
|
41
|
+
return this.rposition - this.mStartPosition;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
PDFRStreamForFile.prototype.moveStartPosition = function (inPosition) {
|
|
45
|
+
this.mStartPosition = inPosition;
|
|
41
46
|
};
|
|
42
47
|
|
|
43
48
|
function noop() {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "muhammara",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "Create, read and modify PDF files and streams. A drop in replacement for hummusjs PDF library",
|
|
5
5
|
"homepage": "https://github.com/julianhille/Muhammarajs",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -129,3 +129,18 @@ void ObjectByteReaderWithPosition::Skip(LongBufferSizeType inSkipSize)
|
|
|
129
129
|
args[0] = NEW_NUMBER(inSkipSize);
|
|
130
130
|
func->Call(GET_CURRENT_CONTEXT, OBJECT_FROM_PERSISTENT(mObject), 1, args).ToLocalChecked();
|
|
131
131
|
}
|
|
132
|
+
|
|
133
|
+
void ObjectByteReaderWithPosition::MoveStartPosition(LongFilePositionType inStartPosition)
|
|
134
|
+
{
|
|
135
|
+
CREATE_ISOLATE_CONTEXT;
|
|
136
|
+
CREATE_ESCAPABLE_SCOPE;
|
|
137
|
+
|
|
138
|
+
Local<Value> value = OBJECT_FROM_PERSISTENT(mObject)->Get(GET_CURRENT_CONTEXT, NEW_STRING("moveStartPosition")).ToLocalChecked();
|
|
139
|
+
if(value->IsUndefined())
|
|
140
|
+
return;
|
|
141
|
+
Local<Function> func = Local<Function>::Cast(value);
|
|
142
|
+
|
|
143
|
+
Local<Value> args[1];
|
|
144
|
+
args[0] = NEW_NUMBER(inStartPosition);
|
|
145
|
+
func->Call(GET_CURRENT_CONTEXT, OBJECT_FROM_PERSISTENT(mObject), 1, args).ToLocalChecked();
|
|
146
|
+
}
|
|
@@ -38,6 +38,7 @@ public:
|
|
|
38
38
|
virtual void SetPositionFromEnd(LongFilePositionType inOffsetFromEnd);
|
|
39
39
|
virtual LongFilePositionType GetCurrentPosition();
|
|
40
40
|
virtual void Skip(LongBufferSizeType inSkipSize);
|
|
41
|
+
virtual void MoveStartPosition(LongFilePositionType inStartPosition);
|
|
41
42
|
|
|
42
43
|
|
|
43
44
|
private:
|
|
@@ -50,6 +50,7 @@ void InputBufferedStream::Assign(IByteReaderWithPosition* inReader)
|
|
|
50
50
|
{
|
|
51
51
|
mSourceStream = inReader;
|
|
52
52
|
mCurrentBufferIndex = mBuffer;
|
|
53
|
+
mStartPosition = 0;
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
LongBufferSizeType InputBufferedStream::Read(Byte* inBuffer,LongBufferSizeType inBufferSize)
|
|
@@ -121,6 +122,7 @@ void InputBufferedStream::Initiate(IByteReaderWithPosition* inSourceReader,IOBas
|
|
|
121
122
|
mBuffer = new Byte[mBufferSize];
|
|
122
123
|
mLastAvailableIndex = mCurrentBufferIndex = mBuffer;
|
|
123
124
|
mSourceStream = inSourceReader;
|
|
125
|
+
mStartPosition = 0;
|
|
124
126
|
}
|
|
125
127
|
|
|
126
128
|
void InputBufferedStream::Skip(LongBufferSizeType inSkipSize)
|
|
@@ -140,7 +142,7 @@ void InputBufferedStream::Skip(LongBufferSizeType inSkipSize)
|
|
|
140
142
|
void InputBufferedStream::SetPosition(LongFilePositionType inOffsetFromStart)
|
|
141
143
|
{
|
|
142
144
|
mLastAvailableIndex = mCurrentBufferIndex = mBuffer;
|
|
143
|
-
mSourceStream->SetPosition(inOffsetFromStart);
|
|
145
|
+
mSourceStream->SetPosition(mStartPosition + inOffsetFromStart);
|
|
144
146
|
}
|
|
145
147
|
|
|
146
148
|
void InputBufferedStream::SetPositionFromEnd(LongFilePositionType inOffsetFromEnd)
|
|
@@ -158,5 +160,10 @@ LongFilePositionType InputBufferedStream::GetCurrentPosition()
|
|
|
158
160
|
{
|
|
159
161
|
// when reading the current position is the current stream position minus how much is left
|
|
160
162
|
// to read from the buffer
|
|
161
|
-
return mSourceStream->GetCurrentPosition() - (mLastAvailableIndex - mCurrentBufferIndex);
|
|
162
|
-
}
|
|
163
|
+
return mSourceStream->GetCurrentPosition() - (mLastAvailableIndex - mCurrentBufferIndex) - mStartPosition;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
void InputBufferedStream::MoveStartPosition(LongFilePositionType inStartPosition)
|
|
167
|
+
{
|
|
168
|
+
mStartPosition = inStartPosition;
|
|
169
|
+
}
|
|
@@ -62,6 +62,7 @@ public:
|
|
|
62
62
|
virtual void SetPosition(LongFilePositionType inOffsetFromStart);
|
|
63
63
|
virtual void SetPositionFromEnd(LongFilePositionType inOffsetFromEnd);
|
|
64
64
|
virtual LongFilePositionType GetCurrentPosition();
|
|
65
|
+
virtual void MoveStartPosition(LongFilePositionType inStartPosition);
|
|
65
66
|
|
|
66
67
|
IByteReaderWithPosition* GetSourceStream();
|
|
67
68
|
|
|
@@ -71,6 +72,7 @@ private:
|
|
|
71
72
|
IOBasicTypes::Byte* mCurrentBufferIndex;
|
|
72
73
|
IOBasicTypes::Byte* mLastAvailableIndex;
|
|
73
74
|
IByteReaderWithPosition* mSourceStream;
|
|
75
|
+
LongFilePositionType mStartPosition;
|
|
74
76
|
|
|
75
77
|
void Initiate(IByteReaderWithPosition* inSourceReader,IOBasicTypes::LongBufferSizeType inBufferSize);
|
|
76
78
|
|
|
@@ -31,6 +31,7 @@ InputByteArrayStream::InputByteArrayStream(Byte* inByteArray,LongFilePositionTyp
|
|
|
31
31
|
mByteArray = inByteArray;
|
|
32
32
|
mArrayLength = inArrayLength;
|
|
33
33
|
mCurrentPosition = 0;
|
|
34
|
+
mStartPosition = 0;
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
InputByteArrayStream::~InputByteArrayStream(void)
|
|
@@ -42,6 +43,7 @@ void InputByteArrayStream::Assign(IOBasicTypes::Byte* inByteArray,IOBasicTypes::
|
|
|
42
43
|
mByteArray = inByteArray;
|
|
43
44
|
mArrayLength = inArrayLength;
|
|
44
45
|
mCurrentPosition = 0;
|
|
46
|
+
mStartPosition = 0;
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
LongBufferSizeType InputByteArrayStream::Read(IOBasicTypes::Byte* inBuffer,IOBasicTypes::LongBufferSizeType inBufferSize)
|
|
@@ -73,7 +75,7 @@ void InputByteArrayStream::Skip(LongBufferSizeType inSkipSize)
|
|
|
73
75
|
|
|
74
76
|
void InputByteArrayStream::SetPosition(LongFilePositionType inOffsetFromStart)
|
|
75
77
|
{
|
|
76
|
-
mCurrentPosition = inOffsetFromStart > mArrayLength ? mArrayLength:inOffsetFromStart;
|
|
78
|
+
mCurrentPosition = inOffsetFromStart > mArrayLength - mStartPosition ? mArrayLength : (mStartPosition + inOffsetFromStart);
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
void InputByteArrayStream::SetPositionFromEnd(LongFilePositionType inOffsetFromEnd)
|
|
@@ -83,5 +85,10 @@ void InputByteArrayStream::SetPositionFromEnd(LongFilePositionType inOffsetFromE
|
|
|
83
85
|
|
|
84
86
|
LongFilePositionType InputByteArrayStream::GetCurrentPosition()
|
|
85
87
|
{
|
|
86
|
-
return mCurrentPosition;
|
|
88
|
+
return mCurrentPosition - mStartPosition;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
void InputByteArrayStream::MoveStartPosition(LongFilePositionType inStartPosition)
|
|
92
|
+
{
|
|
93
|
+
mStartPosition = inStartPosition;
|
|
87
94
|
}
|
|
@@ -38,11 +38,13 @@ public:
|
|
|
38
38
|
virtual void SetPosition(LongFilePositionType inOffsetFromStart);
|
|
39
39
|
virtual void SetPositionFromEnd(LongFilePositionType inOffsetFromEnd);
|
|
40
40
|
virtual LongFilePositionType GetCurrentPosition();
|
|
41
|
+
virtual void MoveStartPosition(LongFilePositionType inStartPosition);
|
|
41
42
|
|
|
42
43
|
private:
|
|
43
44
|
|
|
44
45
|
IOBasicTypes::Byte* mByteArray;
|
|
45
46
|
LongFilePositionType mArrayLength;
|
|
46
47
|
LongFilePositionType mCurrentPosition;
|
|
48
|
+
LongFilePositionType mStartPosition;
|
|
47
49
|
|
|
48
50
|
};
|
|
@@ -26,6 +26,7 @@ using namespace PDFHummus;
|
|
|
26
26
|
InputFileStream::InputFileStream(void)
|
|
27
27
|
{
|
|
28
28
|
mStream = NULL;
|
|
29
|
+
mStartPosition = 0;
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
InputFileStream::~InputFileStream(void)
|
|
@@ -39,6 +40,7 @@ InputFileStream::InputFileStream(const std::string& inFilePath)
|
|
|
39
40
|
{
|
|
40
41
|
mStream = NULL;
|
|
41
42
|
Open(inFilePath);
|
|
43
|
+
mStartPosition = 0;
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
EStatusCode InputFileStream::Open(const std::string& inFilePath)
|
|
@@ -78,13 +80,13 @@ void InputFileStream::Skip(LongBufferSizeType inSkipSize)
|
|
|
78
80
|
void InputFileStream::SetPosition(LongFilePositionType inOffsetFromStart)
|
|
79
81
|
{
|
|
80
82
|
if(mStream)
|
|
81
|
-
SAFE_FSEEK64(mStream,inOffsetFromStart,SEEK_SET);
|
|
83
|
+
SAFE_FSEEK64(mStream,mStartPosition + inOffsetFromStart,SEEK_SET);
|
|
82
84
|
}
|
|
83
85
|
|
|
84
86
|
LongFilePositionType InputFileStream::GetCurrentPosition()
|
|
85
87
|
{
|
|
86
88
|
if(mStream)
|
|
87
|
-
return SAFE_FTELL64(mStream);
|
|
89
|
+
return SAFE_FTELL64(mStream) - mStartPosition;
|
|
88
90
|
else
|
|
89
91
|
return 0;
|
|
90
92
|
}
|
|
@@ -115,3 +117,8 @@ void InputFileStream::SetPositionFromEnd(LongFilePositionType inOffsetFromEnd)
|
|
|
115
117
|
SAFE_FSEEK64(mStream,0,SEEK_SET);
|
|
116
118
|
}
|
|
117
119
|
}
|
|
120
|
+
|
|
121
|
+
void InputFileStream::MoveStartPosition(LongFilePositionType inStartPosition)
|
|
122
|
+
{
|
|
123
|
+
mStartPosition = inStartPosition;
|
|
124
|
+
}
|
|
@@ -50,10 +50,12 @@ public:
|
|
|
50
50
|
virtual void SetPosition(LongFilePositionType inOffsetFromStart);
|
|
51
51
|
virtual void SetPositionFromEnd(LongFilePositionType inOffsetFromEnd);
|
|
52
52
|
virtual LongFilePositionType GetCurrentPosition();
|
|
53
|
+
virtual void MoveStartPosition(LongFilePositionType inStartPosition);
|
|
53
54
|
|
|
54
55
|
LongFilePositionType GetFileSize();
|
|
55
56
|
|
|
56
57
|
private:
|
|
57
58
|
|
|
58
59
|
FILE* mStream;
|
|
60
|
+
LongFilePositionType mStartPosition;
|
|
59
61
|
};
|
|
@@ -24,11 +24,13 @@
|
|
|
24
24
|
InputStringBufferStream::InputStringBufferStream(MyStringBuf* inBufferToReadFrom)
|
|
25
25
|
{
|
|
26
26
|
mBufferToReadFrom = inBufferToReadFrom;
|
|
27
|
+
mStartPosition = 0;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
void InputStringBufferStream::Assign(MyStringBuf* inBufferToReadFrom)
|
|
30
31
|
{
|
|
31
32
|
mBufferToReadFrom = inBufferToReadFrom;
|
|
33
|
+
mStartPosition = 0;
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
InputStringBufferStream::~InputStringBufferStream(void)
|
|
@@ -52,7 +54,7 @@ void InputStringBufferStream::Skip(LongBufferSizeType inSkipSize)
|
|
|
52
54
|
|
|
53
55
|
void InputStringBufferStream::SetPosition(LongFilePositionType inOffsetFromStart)
|
|
54
56
|
{
|
|
55
|
-
mBufferToReadFrom->pubseekoff((long)inOffsetFromStart,std::ios_base::beg);
|
|
57
|
+
mBufferToReadFrom->pubseekoff((long)mStartPosition + (long)inOffsetFromStart,std::ios_base::beg);
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
void InputStringBufferStream::SetPositionFromEnd(LongFilePositionType inOffsetFromEnd)
|
|
@@ -63,5 +65,10 @@ void InputStringBufferStream::SetPositionFromEnd(LongFilePositionType inOffsetFr
|
|
|
63
65
|
|
|
64
66
|
LongFilePositionType InputStringBufferStream::GetCurrentPosition()
|
|
65
67
|
{
|
|
66
|
-
return mBufferToReadFrom->GetCurrentReadPosition();
|
|
67
|
-
}
|
|
68
|
+
return mBufferToReadFrom->GetCurrentReadPosition() - mStartPosition;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
void InputStringBufferStream::MoveStartPosition(LongFilePositionType inStartPosition)
|
|
72
|
+
{
|
|
73
|
+
mStartPosition = inStartPosition;
|
|
74
|
+
}
|
|
@@ -43,9 +43,11 @@ public:
|
|
|
43
43
|
virtual void SetPosition(LongFilePositionType inOffsetFromStart);
|
|
44
44
|
virtual void SetPositionFromEnd(LongFilePositionType inOffsetFromEnd);
|
|
45
45
|
virtual LongFilePositionType GetCurrentPosition();
|
|
46
|
+
virtual void MoveStartPosition(LongFilePositionType inStartPosition);
|
|
46
47
|
|
|
47
48
|
private:
|
|
48
49
|
MyStringBuf* mBufferToReadFrom;
|
|
50
|
+
LongFilePositionType mStartPosition;
|
|
49
51
|
|
|
50
52
|
|
|
51
53
|
};
|
|
@@ -32,6 +32,7 @@ InputStringStream::InputStringStream(const string& inString)
|
|
|
32
32
|
mStartPosition = inString.begin();
|
|
33
33
|
mEndPosition = inString.end();
|
|
34
34
|
mCurrentPosition = mStartPosition;
|
|
35
|
+
mString = inString;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
InputStringStream::~InputStringStream(void)
|
|
@@ -43,6 +44,7 @@ void InputStringStream::Assign(const string& inString)
|
|
|
43
44
|
mStartPosition = inString.begin();
|
|
44
45
|
mEndPosition = inString.end();
|
|
45
46
|
mCurrentPosition = mStartPosition;
|
|
47
|
+
mString = inString;
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
LongBufferSizeType InputStringStream::Read(Byte* inBuffer, LongBufferSizeType inBufferSize)
|
|
@@ -79,3 +81,8 @@ LongFilePositionType InputStringStream::GetCurrentPosition()
|
|
|
79
81
|
{
|
|
80
82
|
return mCurrentPosition - mStartPosition;
|
|
81
83
|
}
|
|
84
|
+
|
|
85
|
+
void InputStringStream::MoveStartPosition(LongFilePositionType inStartPosition)
|
|
86
|
+
{
|
|
87
|
+
mStartPosition = mString.begin() + (string::size_type)inStartPosition;
|
|
88
|
+
}
|
|
@@ -40,11 +40,13 @@ public:
|
|
|
40
40
|
virtual void SetPosition(LongFilePositionType inOffsetFromStart);
|
|
41
41
|
virtual void SetPositionFromEnd(LongFilePositionType inOffsetFromEnd);
|
|
42
42
|
virtual LongFilePositionType GetCurrentPosition();
|
|
43
|
+
virtual void MoveStartPosition(LongFilePositionType inStartPosition);
|
|
43
44
|
|
|
44
45
|
private:
|
|
45
46
|
|
|
46
47
|
std::string::const_iterator mStartPosition;
|
|
47
48
|
std::string::const_iterator mEndPosition;
|
|
48
49
|
std::string::const_iterator mCurrentPosition;
|
|
50
|
+
std::string mString;
|
|
49
51
|
|
|
50
52
|
};
|
|
@@ -166,14 +166,20 @@ EStatusCode PDFParser::ParseHeaderLine()
|
|
|
166
166
|
return PDFHummus::eFailure;
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
|
|
169
|
+
do
|
|
170
170
|
{
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
171
|
+
if(tokenizerResult.second.compare(0,scPDFMagic.size(),scPDFMagic) == 0)
|
|
172
|
+
{
|
|
173
|
+
mPDFLevel = Double(tokenizerResult.second.substr(scPDFMagic.size()));
|
|
174
|
+
mStream->MoveStartPosition(mStream->GetCurrentPosition() - tokenizerResult.second.size() - 1);
|
|
175
|
+
return PDFHummus::eSuccess;
|
|
176
|
+
}
|
|
174
177
|
|
|
175
|
-
|
|
176
|
-
|
|
178
|
+
tokenizerResult = tokenizer.GetNextToken();
|
|
179
|
+
} while (tokenizerResult.first && mStream->GetCurrentPosition() < 1024);
|
|
180
|
+
|
|
181
|
+
TRACE_LOG("PDFParser::ParseHeaderLine, file does not begin as a PDF file. a PDF file should contain \"%%PDF-\" within the first 1024 bytes.");
|
|
182
|
+
return PDFHummus::eFailure;
|
|
177
183
|
}
|
|
178
184
|
|
|
179
185
|
static const std::string scEOF = "%%EOF";
|