2
Copyright (c) 1993-2008, Cognitive Technologies
5
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½,
6
ļæ½ļæ½ļæ½ ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½:
8
* ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½
9
ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½
10
ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½.
11
* ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½/ļæ½ļæ½ļæ½ ļæ½
12
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½
13
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½
14
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½.
15
* ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ Cognitive Technologies, ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½
16
ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½/ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½
17
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½, ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½
18
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½.
20
ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½/ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ "ļæ½ļæ½ļæ½
21
ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½" ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½-ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½,
22
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ ļæ½ļæ½
23
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½. ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½
24
ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½/ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½
25
ļæ½ļæ½ŃØļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½
26
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½
27
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ (ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½,
28
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½/ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½-ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½
29
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ ļæ½/ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½,
30
ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½), ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½
31
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½.
33
Redistribution and use in source and binary forms, with or without modification,
34
are permitted provided that the following conditions are met:
36
* Redistributions of source code must retain the above copyright notice,
37
this list of conditions and the following disclaimer.
38
* Redistributions in binary form must reproduce the above copyright notice,
39
this list of conditions and the following disclaimer in the documentation
40
and/or other materials provided with the distribution.
41
* Neither the name of the Cognitive Technologies nor the names of its
42
contributors may be used to endorse or promote products derived from this
43
software without specific prior written permission.
45
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
46
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
47
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
48
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
49
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
51
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
52
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
53
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
54
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
60
#include "ced_struct.h"
66
//#include "ced_struct.h"
68
//First of all, we define all .dib as metafiles since word does not know about .dib
69
static CEDPage * mainPage;
70
static CEDLine * curEdLine;
72
static int font,kegl,lang;
73
static int foregroundColor,backgroundColor,fontNum;
74
static char * verInfo;
76
static void ExtDataProc(Word8* _ptr, Word32 lth);
77
void NewFormattedSDD(const sheet_disk_descr* pt);
78
void NewFormattedFDD(const fragm_disk_descr* pt);
79
void NewFormattedTR(const text_ref* pt);
80
//void NewFormattedFD(const fragm_disk* pt);
81
void NewFormattedLB(const line_beg* pt);
82
void NewFormattedL(const letter* pt,const Word32 alternatives);
83
void NewFormattedBMR(const bit_map_ref * pt);
84
void NewFormattedFK(const font_kegl * pt);
85
void NewFormattedE(const edExtention* pt,const void* ptExt);
86
void NewFormattedENew(const edExtentionNew* pt,const void* ptExt);
87
void NewFormattedLang(const EdTagLanguage* pt);
89
void CED_DeleteTree(CEDPage * pg)
94
void RepairStructure();
96
CEDPage * CED_FormattedLoad (char * file,Bool32 readFromFile, Word32 bufLen)
98
CED_SetRawDataProc(ExtDataProc);
99
if (CED_IsEdFile(file,readFromFile,bufLen)==96)
102
// return Formattedload_96(char * file,Bool32 readFromFile, Word32 bufLen);
104
else if (CED_IsEdFile(file,readFromFile,bufLen)!=2000)
106
CED_SheetDiskDescr=NewFormattedSDD;
107
CED_TextRef=NewFormattedTR;
108
// CED_FragmDiskDescr=FormattedFDD;
109
// CED_FragmDisk=NewFormattedFD;
110
CED_LineBeg=NewFormattedLB;
111
CED_Letter=NewFormattedL;
112
CED_BitmapRef=NewFormattedBMR;
113
CED_FontKegl=NewFormattedFK;
114
CED_Extention=NewFormattedE;
115
CED_ExtentionNew=NewFormattedENew;
116
CED_EdTagLanguage=NewFormattedLang;
117
mainPage=new(CEDPage);
118
refBox.x=refBox.y=refBox.h=refBox.w=0;
120
foregroundColor=backgroundColor=fontNum=-1;
122
CED_ReadED(file,readFromFile,bufLen);
123
if (verInfo&&strcmp(verInfo,"CuneiForm2000 file format")==0)
133
//Put non-recognized codes to the corresponding field of extData
134
void ExtDataProc(Word8* _ptr, Word32 lth)
137
void NewFormattedSDD(const sheet_disk_descr* pt)
139
mainPage->dpi.cx=mainPage->dpi.cy=pt->resolution;
140
mainPage->pageNumber=pt->sheet_numb;
141
mainPage->turn=pt->incline;
142
mainPage->NumberOfParagraphs=pt->quant_fragm;
143
mainPage->turn=pt->incline;
146
void NewFormattedE(const edExtention* pt,const void* ptExt)
151
verInfo=new char[pt->length-sizeof(edExtention)];
152
memcpy(verInfo,ptExt,pt->length-sizeof(edExtention));
156
fontDiscr *fond=(fontDiscr *)ptExt;
157
while((char*)fond-(char*)ptExt<signed (pt->length-sizeof(edExtention)))
159
mainPage->CreateFont(fond->fontNumber,fond->fontPitchAndFamily, fond->fontCharset,
160
(char*)fond+sizeof(fontDiscr));
161
fond=(fontDiscr *)((char*)fond+fond->size);
167
pageDescr* pd=(pageDescr*)ptExt;
168
mainPage->pageSizeInTwips.cx= pd->paperw;
169
mainPage->pageSizeInTwips.cy= pd->paperh;
170
mainPage->pageBordersInTwips.top= pd->margt;
171
mainPage->pageBordersInTwips.left= pd->margl;
172
mainPage->pageBordersInTwips.bottom= pd->margb;
173
mainPage->pageBordersInTwips.right= pd->margr;
174
mainPage->resizeToFit= pd->resizeToFit;
175
//for backward compatibility
176
if ( unsigned( (&(pd->recogLang)) - ((BYTE*)pd) )<pt->length-sizeof(edExtention))
177
mainPage->recogLang=pd->recogLang;
180
case EDEXT_TIFF_DESC:
182
originalImageDesc* fond=(originalImageDesc*)ptExt;
183
mainPage->sizeOfImage.cy=fond->height;
184
mainPage->sizeOfImage.cx=fond->width;
185
mainPage->pageNumber= fond->pageNum;
186
mainPage->turn= fond->inclune;
187
mainPage->dpi.cx= fond->resolutionX;
188
mainPage->dpi.cy= fond->resolutionY;
189
mainPage->unrecogChar= fond->unrecogSymbol;
190
mainPage->imageName=strdup((char*)ptExt+sizeof(originalImageDesc));
195
pictDescr *picd=(pictDescr *)ptExt;
196
while((char*)picd-(char*)ptExt<pt->length-sizeof(edExtention))
198
mainPage->CreatePicture(picd->pictNumber, picd->pictSize, picd->pictGoal, picd->pictAlign, picd->type, (char*)picd+sizeof(pictDescr),picd->len);
199
picd=(pictDescr *)(char*)picd+picd->size;
203
*/ case EDEXT_SECTION:
205
CEDSection * sect=mainPage->InsertSection();
206
sectParams1* sp=(sectParams1*)ptExt;
207
sect->borders.bottom=sp->bottomMargin ;
208
sect->borders.top= sp->topMargin ;
209
sect->borders.left= sp->leftMargin ;
210
sect->borders.right= sp->rightMargin ;
211
sect->numberOfColumns=0;// sp->columns ;
212
sect->colInterval= sp->colInterval ;
213
sect->numSnakeCols= sp->numSnakeCols;
214
sect->colInfo=new EDCOL[sect->numSnakeCols];
215
char * c=(char*)ptExt+sizeof(sectParams1);
217
for(i=0;i<sect->numSnakeCols;i++)
219
sect->colInfo[i].width=*((Int32*)c);
222
for(i=0;i<sect->numSnakeCols;i++)
224
sect->colInfo[i].space=*((Int32*)c);
227
sectParams2* sp2=(sectParams2*)c;
228
sect->footerY= sp2->footerY ;
229
sect->headerY= sp2->headerY ;
230
sect->width= sp2->width ;
231
sect->height= sp2->height ;
232
sect->orientation= sp2->orientation ;
233
sect->sectionBreak= sp2->sectionBreak;
234
//for backward compatibility
235
if ( unsigned( (&(sp2->lineBetCol)) - ((BYTE*)sp) )<pt->length-sizeof(edExtention))
236
sect->lineBetCol=sp2->lineBetCol;
239
case EDEXT_PARAGRAPH:
241
paraParams * pard=(paraParams *)ptExt;
242
CEDParagraph* hPara=mainPage->GetCurSection()->GetCurParagraph();
243
hPara->color= (signed short)pard->color;
244
hPara->interval.cx= pard->spaceBefore;
245
hPara->interval.cy= pard->spaceAfter;
246
hPara->alignment= pard->alignment;
247
hPara->indent.top= pard->firstIndent;
248
hPara->indent.left= pard->leftIndent;
249
hPara->indent.right= pard->rightIndent;
250
hPara->keep= pard->keep;
251
hPara->shading= (signed short)pard->shading;
252
hPara->spaceBetweenLines= pard->spaceBetweenLines;
253
hPara->spcBtwLnsMult= pard->spcBtwLnsMult;
254
hPara->userNumber= (signed short)pard->userNum;
255
//for backward compatibility
256
if ( unsigned( (&(pard->topBrdrType)) - ((BYTE*)pard) )<pt->length-sizeof(edExtention))
257
hPara->topBrdrType=pard->topBrdrType ;
258
if ( unsigned( (BYTE*)(&(pard->topBrdrWidth)) - ((BYTE*)pard) )<pt->length-sizeof(edExtention))
259
hPara->topBrdrWidth= pard->topBrdrWidth ;
260
if ( unsigned( (&(pard->bottomBrdrType)) - ((BYTE*)pard) )<pt->length-sizeof(edExtention))
261
hPara->bottomBrdrType= pard->bottomBrdrType ;
262
if ( unsigned( (BYTE*)(&(pard->bottomBrdrWidth)) - ((BYTE*)pard) )<pt->length-sizeof(edExtention))
263
hPara->bottomBrdrWidth= pard->bottomBrdrWidth ;
264
if ( unsigned( (&(pard->leftBrdrType)) - ((BYTE*)pard) )<pt->length-sizeof(edExtention))
265
hPara->leftBrdrType= pard->leftBrdrType ;
266
if ( unsigned( (BYTE*)(&(pard->leftBrdrWidth)) - ((BYTE*)pard) )<pt->length-sizeof(edExtention))
267
hPara->leftBrdrWidth= pard->leftBrdrWidth ;
268
if ( unsigned( (&(pard->rightBrdrType)) - ((BYTE*)pard) )<pt->length-sizeof(edExtention))
269
hPara->rightBrdrType= pard->rightBrdrType ;
270
if ( unsigned( (BYTE*)(&(pard->rightBrdrWidth)) - ((BYTE*)pard) )<pt->length-sizeof(edExtention))
271
hPara->rightBrdrWidth= pard->rightBrdrWidth ;
275
case EDEXT_TABLE_ROW:
277
CEDParagraph *hPara=mainPage->GetCurSection()->GetCurParagraph();
278
edRowDescr *rd=(edRowDescr*)(hPara)->descriptor;
279
rowParam* rp=(rowParam*)ptExt;
280
rd->topBrdrType= rp->topBrdrType ;
281
rd->topBrdrWidth= rp->topBrdrWidth ;
282
rd->bottomBrdrType= rp->bottomBrdrType ;
283
rd->bottomBrdrWidth= rp->bottomBrdrWidth ;
284
rd->leftBrdrType= rp->leftBrdrType ;
285
rd->leftBrdrWidth= rp->leftBrdrWidth ;
286
rd->rightBrdrType= rp->rightBrdrType ;
287
rd->rightBrdrWidth= rp->rightBrdrWidth ;
289
rd->header= rp->header ;
290
rd->header= rp->left ;
291
rd->position= rp->position ;
292
rd->rowHeight= rp->rowHeight ;
296
case EDEXT_TABLE_CELL:
298
CEDParagraph *hPara=mainPage->GetCurSection()->GetCurParagraph();
299
cellParam *cp=(cellParam *)ptExt;
300
edCellDescr *cd=(edCellDescr*)(hPara)->descriptor;
301
cd->topBrdrType= cp->topBrdrType ;
302
cd->topBrdrWidth= cp->topBrdrWidth ;
303
cd->bottomBrdrType= cp->bottomBrdrType ;
304
cd->bottomBrdrWidth= cp->bottomBrdrWidth ;
305
cd->leftBrdrType= cp->leftBrdrType ;
306
cd->leftBrdrWidth= cp->leftBrdrWidth ;
307
cd->rightBrdrType= cp->rightBrdrType ;
308
cd->rightBrdrWidth= cp->rightBrdrWidth ;
309
cd->cellX= cp->cellX ;
310
cd->color= (signed short)cp->color ;
311
cd->shading= (signed short)cp->shading ;
312
cd->merging= cp->merging ;
313
cd->vertTextAlign= cp->vertTextAlign;
314
//for backward compatibility
315
if ( unsigned( (&(cp->flag)) - ((BYTE*)cp) )<pt->length-sizeof(edExtention))
321
CEDParagraph *hPara=mainPage->GetCurSection()->GetCurParagraph();
322
edFrameDescr *fd=(edFrameDescr*)(hPara)->descriptor;
323
frameParam* fp=(frameParam*)ptExt;
324
fd->rec.x= fp->posx ;
325
fd->rec.y= fp->posy ;
326
fd->rec.w= fp->absw ;
327
fd->rec.h= fp->absh ;
328
fd->borderSpace=fp->borderSpace ;
329
fd->dxfrtextx= fp->dxfrtextx ;
330
fd->dxfrtexty= fp->dxfrtexty ;
331
fd->position= fp->position;
332
//for backward compatiility
333
if ( unsigned( (&(fp->flag)) - ((BYTE*)fp) )<pt->length-sizeof(edExtention))
339
charParams* chp=(charParams*)ptExt;
340
fontNum=chp->fontNumber;
341
foregroundColor=chp->foregroundColor;
342
//for backward compatibility
343
if ( unsigned( (BYTE*)(&(chp->backgroundColor)) - ((BYTE*)chp) )<pt->length-sizeof(edExtention))
344
backgroundColor=chp->backgroundColor;
351
void NewFormattedENew(const edExtentionNew* pt,const void* ptExt)
357
pictDescr *picd=(pictDescr *)ptExt;
358
while((char*)picd-(char*)ptExt<signed (pt->length-sizeof(edExtentionNew)))
360
mainPage->CreatePicture(picd->pictNumber, picd->pictSize, picd->pictGoal, picd->pictAlign, picd->type, (char*)picd+sizeof(pictDescr),picd->len);
361
picd=(pictDescr *)((char*)picd+picd->size);
367
void NewFormattedTR(const text_ref* pt)
373
CEDParagraph * para=mainPage->GetCurSection()->InsertParagraph();
377
para->type=COLUMN_BEGIN;
378
para->descriptor=malloc(sizeof(EDCOLDESCR));
381
para->type=COLUMN_BEGIN;
382
para->descriptor=malloc(sizeof(EDCOLDESCR));
385
para->type=LAST_IN_COLUMN;
388
para->type=TAB_BEGIN;
389
para->descriptor=malloc(sizeof(EDTABDESCR));
392
para->type=TAB_ROW_BEGIN;
393
para->descriptor=malloc(sizeof(EDROWDESCR));
395
case TP_NEW_CELL_BEG:
396
para->type=TAB_CELL_BEGIN;
397
para->descriptor=malloc(sizeof(EDCELLDESCR));
403
para->type=FRAME_BEGIN;
404
para->descriptor=malloc(sizeof(EDFRAMEDESCR));
407
para->type=FRAME_END;
414
CEDParagraph *hPara=mainPage->GetParagraph(pt->object);
415
curEdLine=hPara->InsertLine();
421
void NewFormattedLB(const line_beg* pt)
423
curEdLine->defChrFontHeight=pt->height;
424
curEdLine->hardBreak=!pt->base_line;
427
void NewFormattedBMR(const bit_map_ref * pt)
435
void NewFormattedFK(const font_kegl * pt)
441
void NewFormattedLang(const EdTagLanguage* pt)
445
void NewFormattedL(const letter* pt,const Word32 alternatives)
449
CEDLine *lin=curEdLine;
450
/* if(!mainPage->GetCurSection())
451
mainPage->InsertSection()->CreateColumn();//In case of wrong 'ed', such that symbols are before the definition of fragment
452
CEDLine * lin=mainPage->GetCurSection()->GetCurParagraph()->GetCurLine();
454
lin=mainPage->GetCurSection()->GetCurParagraph()->InsertLine();//In case of wrong 'ed', such that symbols are before the definition of line
455
*/ CEDChar *chr=lin->InsertChar();
456
letterEx * lpData = new letterEx[alternatives];
457
memcpy(lpData,(void*)pt,alternatives*sizeof(letterEx));
458
chr->alternatives=/*(letter*)*/lpData;
459
chr->numOfAltern=alternatives;
460
chr->layout.left=refBox.x;
461
chr->layout.top=refBox.y;
462
chr->layout.right=refBox.x+refBox.w;
463
chr->layout.bottom=refBox.y+refBox.h;
464
// memcpy(&(chr->layout),&refBox,sizeof(edBox));
465
chr->fontHeight=kegl;
466
chr->fontAttribs=font;
467
chr->fontNum=fontNum;
469
chr->backgroundColor=backgroundColor;
470
chr->foregroundColor=foregroundColor;
473
void RepairStructure()
475
CEDParagraph * tabBeg=0,*rowBeg=0,*cellBeg=0,*colBeg=0,*frmBeg=0;
476
CEDParagraph *hPara=mainPage->GetParagraph(0);
483
//Memorized beginning of table
485
EDTABDESCR *td=(EDTABDESCR*)(tabBeg->descriptor);
494
//If it is not a first line - refer to the current one
497
EDROWDESCR *rd=(EDROWDESCR*)(rowBeg->descriptor);
500
//In a table of lines+1
503
EDTABDESCR *td=(EDTABDESCR*)(tabBeg->descriptor);
505
//If it is a first line
511
EDROWDESCR *rd=(EDROWDESCR*)(rowBeg->descriptor);
522
EDCELLDESCR *cd=(EDCELLDESCR*)(cellBeg->descriptor);
527
EDROWDESCR *rd=(EDROWDESCR*)(rowBeg->descriptor);
540
EDROWDESCR *rd=(EDROWDESCR*)(rowBeg->descriptor);
545
EDTABDESCR *td=(EDTABDESCR*)(tabBeg->descriptor);
550
EDCELLDESCR *cd=(EDCELLDESCR*)(cellBeg->descriptor);
553
cellBeg=tabBeg=rowBeg=0;
563
EDFRAMEDESCR *fd=(EDFRAMEDESCR*)(frmBeg->descriptor);
570
CEDSection * sec=mainPage->GetSection(hPara->parentNumber);
573
EDCOLDESCR *cd=(EDCOLDESCR*)(colBeg->descriptor);
577
sec->columnsBeg=hPara;
579
sec->numberOfColumns++;
580
sec->columnsCur=hPara;
587
EDCOLDESCR *cd=(EDCOLDESCR*)(colBeg->descriptor);
591
mainPage->GetSection(hPara->parentNumber)->columnsEnd=hPara;
600
void PrintPara(FILE *stream,Handle para);
601
void CED_ShowTree(char * name, Handle hEdPage)
603
// CEDPage * page=(CEDPage *)hEdPage;
604
Bool32 inFrm=FALSE, inTbl=FALSE;
607
unsigned int tblRowNum=0,tblCellNum=0;
608
FILE *stream = fopen( name, "w" );
609
fprintf(stream,"Page,dpi=%i,imName=%s,\ntw.x=%i,tw.y=%i,sz.x=%i,sz.y=%i,turn=%i,char=%c\n",
610
CED_GetPageDpi(hEdPage).cx,CED_GetPageImageName(hEdPage),CED_GetPageSize(hEdPage).cx,
611
CED_GetPageSize(hEdPage).cy,CED_GetPageImageSize(hEdPage).cx,
612
CED_GetPageImageSize(hEdPage).cy,CED_GetPageTurn(hEdPage),CED_GetPageUnrecogChar(hEdPage));
613
fprintf(stream,"\nTable of pictures:\nTotal pictures:%d",CED_GetNumOfPics(hEdPage));
614
for (unsigned int p=0;p<CED_GetNumOfPics(hEdPage);p++)
616
int pictNumber, pictAlign , type,length;
617
EDSIZE pictSize, pictGoal;
618
CED_GetPicture(hEdPage,p, &pictNumber, &pictSize, &pictGoal, &pictAlign , &type, 0, &length);
619
fprintf(stream,"\npictNumber=%d, type=%d, length=%d, pictSize.x=%d, pictSize.y=%d,\npictGoal.x=%d, pictGoal.y=%d, pictAlign=%d\n",
620
pictNumber, type, length, pictSize.cx,pictSize.cy, pictGoal.cx,pictGoal.cy, pictAlign);
623
for (unsigned int i=0;i<CED_GetCountSection(hEdPage);i++)
625
Handle sect=CED_GetSection(hEdPage,i);
626
fprintf(stream,"\nSection %i,borders:l=%i,r=%i,t=%i,b=%i\n",i,
627
CED_GetSectionBorder(sect).left,CED_GetSectionBorder(sect).right,
628
CED_GetSectionBorder(sect).top,CED_GetSectionBorder(sect).bottom);
629
fprintf(stream,"\ncolumns:");
630
for (unsigned int c=0;c<CED_GetNumSnakeCols(sect);c++)
631
fprintf(stream,"\ncolumn %i,wd=%i,sp=%i",c,
632
CED_GetSnakeColumnWidth(sect,c),CED_GetSnakeColumnSpacing(sect,c));
634
for (unsigned int j=0;j<CED_GetCountColumn(sect);j++)
636
Handle col=CED_GetColumn(sect,j);
639
printf("Internal error in CED_GetColumn");
642
fprintf(stream,"\nNewCol");
643
Handle para=CED_GetFirstObject(col);
646
if (!CED_IsParagraph(para))
648
if (CED_IsTable(para))
650
fprintf(stream,"\nHere goes a table!!!!!!!!!!!!!!!!!!!!!!\n");
651
for (tblRowNum=0;tblRowNum<CED_GetCountRow(para);tblRowNum++)
653
tblRow=CED_GetTableRow(para,tblRowNum);
654
int left,heig,lb,rb,tb,bb,gp,pos;
655
CED_GetTableRowParams(tblRow,&left,&heig,&lb,0,&rb,0,&tb,0,&bb,0,&gp,&pos,0);
656
fprintf(stream,"\nRow: left=%d,heig=%d,lb=%d,rb=%d,tb=%d,bb=%d,gp=%d,pos=%d",left,heig,lb,rb,tb,bb,gp,pos);
657
for (tblCellNum=0;tblCellNum<CED_GetCountCell(tblRow);tblCellNum++)
659
Handle hPara=CED_GetCell(tblRow,tblCellNum);
661
CED_GetCellParams(hPara,&cx,&mg,&va,0,0,0,0,0,0,0,0,0,0,0);
662
int flag=CED_GetCellFlag(hPara);
666
strcpy(ss,",ED_TDIR_UP");
667
if (flag&ED_TDIR_DOWN)
668
strcpy(ss,",ED_TDIR_DOWN");
669
fprintf(stream,"\nCellX:%d,mrg:%d,vAlign:%d%s",cx,mg,va,ss);
670
Handle para1=CED_GetFirstObject(hPara);
673
PrintPara(stream,para1);
674
para1=CED_GetNextObject(para1);
676
fprintf(stream,"\nHere is end of cell--------------------");
678
fprintf(stream,"\nHere is end of row========================");
680
fprintf(stream,"\nHere is end of table!!!!!!!!!!!!!!!!!!!!\n");
681
para=CED_GetNextObject(para);
684
if (CED_IsFrame(para))
688
EDBOX bx=CED_GetFrameRect(para);
689
fprintf(stream,"\nHere is a frame,x=%d,y=%d,w=%d,h=%d,pos=%x,dx=%d,dy=%d!!!!!!!!!\n",bx.x,bx.y,bx.w,bx.h,CED_GetFramePosition(para),CED_GetFrameDxfrtextx(para),CED_GetFrameDxfrtexty(para));
690
para=CED_GetFirstObject(frm);
695
PrintPara(stream,para);
696
para=CED_GetNextObject(para);
700
para=CED_GetNextObject(frm);
702
fprintf(stream,"Here is end of frame!!!!!!!!!!!!!!!!!!!!\n");
710
void PrintPara(FILE *stream,Handle para)
712
fprintf(stream,"\nparagraph,alig=%i,FInd=%d,LInd=%i,RInd=%d",
713
CED_GetAlignment(para),CED_GetIndent(para).top,CED_GetIndent(para).left,CED_GetIndent(para).right);
714
fprintf(stream,",usNum=%i,sb=%i,sa=%i\n",CED_GetUserNumber(para),CED_GetInterval(para).cx,CED_GetInterval(para).cy);
715
for (unsigned l=0;l<CED_GetCountLine(para);l++)
717
Handle line=CED_GetLine(para,l);
718
for (unsigned c=0;c<CED_GetCountChar(line);c++)
720
Handle chr=CED_GetChar(line,c);
721
if (!CED_IsPicture(chr))
722
fprintf(stream,"%c",CED_GetAlternatives(chr)[0].alternative);
724
fprintf(stream,"\\pict%d\\",CED_GetCharFontNum(chr)-ED_PICT_BASE);
726
fprintf(stream,"\n");
732
Bool32 WriteRemark(HANDLE hFile,int type, int object);
733
Bool32 WriteExtCode(HANDLE hFile,int Ecode, void* object, int lenOfObj, int etraLen=0);
734
Bool32 WriteFontTable(HANDLE hFile, CEDPage *page);
735
Bool32 WriteTiffDescr(HANDLE hFile, CEDPage* page);
736
Bool32 WritePictTable(HANDLE hFile, CEDPage* page);
737
Bool32 WritePara(HANDLE hFile,CEDParagraph* hPara);
739
Bool32 CED_FormattedWrite(char * fileName, CEDPage *page)
745
HANDLE hFile=Open(0, (PInt8)fileName,OSF_CREATE|OSF_BINARY|OSF_WRITE);
748
SetReturnCode_ced(CFIO_GetReturnCode());
752
sheet_disk_descr sdd;
753
sdd.code=SS_SHEET_DESCR;
755
sdd.sheet_numb=page->pageNumber;
756
sdd.descr_lth=sizeof(sdd)+sizeof(fragm_disk_descr);
757
sdd.resolution=(Word16)page->dpi.cx;
758
sdd.incline=page->turn;
760
if (!Write(hFile,(PInt8)&sdd,sizeof(sdd))) goto ED_WRITE_END;
761
fragm_disk_descr fdd;
762
memset((void*)&fdd,0,sizeof(fdd));
763
fdd.code=SS_FRAGMENT;
764
if (!Write(hFile,(PInt8)&fdd,sizeof(fdd))) goto ED_WRITE_END;
765
//Write text description of version
766
if (!WriteExtCode(hFile,EDEXT_VERSION,(void*)"CuneiForm2000 file format",strlen("CuneiForm2000 file format")+1)) goto ED_WRITE_END;
767
//Write table of fonts
768
if (!WriteFontTable(hFile,page)) goto ED_WRITE_END;
769
//Write the boundaries of the page
771
pd.paperw=page->pageSizeInTwips.cx;
772
pd.paperh=page->pageSizeInTwips.cy;
773
pd.margt=page->pageBordersInTwips.top;
774
pd.margl=page->pageBordersInTwips.left;
775
pd.margb=page->pageBordersInTwips.bottom;
776
pd.margr=page->pageBordersInTwips.right;
777
pd.resizeToFit=BYTE(page->resizeToFit);
778
pd.recogLang=page->recogLang;
779
if (!WriteExtCode(hFile,EDEXT_BORDERS, &pd,sizeof(pd))) goto ED_WRITE_END;
780
//Write parameters of .tif
781
if (!WriteTiffDescr(hFile,page)) goto ED_WRITE_END;
782
//Write all available pictures
783
if (!WritePictTable(hFile, page)) goto ED_WRITE_END;
784
//Write descriptions of sections and paragraphs.
785
for (sec=0;sec<page->GetNumberOfSections();sec++)
787
CEDSection * sect=page->GetSection(sec);
790
sp.bottomMargin=sect->borders.bottom;
791
sp.topMargin=sect->borders.top;
792
sp.leftMargin=sect->borders.left;
793
sp.rightMargin=sect->borders.right;
794
sp.columns=sect->numberOfColumns;
795
sp.colInterval=sect->colInterval;
796
sp.numSnakeCols=sect->numSnakeCols;
797
if (!WriteExtCode(hFile,EDEXT_SECTION,&sp,sizeof(sp),sizeof(sectParams2)+sect->numSnakeCols*8)) goto ED_WRITE_END;
798
for (i=0;i<sect->numSnakeCols;i++)
799
if (!Write(hFile,(PInt8)&(sect->colInfo[i].width),4)) goto ED_WRITE_END;
800
for (i=0;i<sect->numSnakeCols;i++)
801
if (!Write(hFile,(PInt8)&(sect->colInfo[i].space),4)) goto ED_WRITE_END;
803
sp2.footerY=sect->footerY;
804
sp2.headerY=sect->headerY;
805
sp2.width=sect->width;
806
sp2.height=sect->height;
807
sp2.orientation=sect->orientation;
808
sp2.sectionBreak=sect->sectionBreak;
809
sp2.lineBetCol=sect->lineBetCol;
810
if (!Write(hFile,(PInt8)&sp2,sizeof(sp2))) goto ED_WRITE_END;
811
if (!WriteRemark(hFile,SSR_FRAG_TYPE,TP_MCOL_BEG)) goto ED_WRITE_END;
812
if (!WriteRemark(hFile,SSR_FRAG_PNUM,MIN(sect->numberOfColumns,1))) goto ED_WRITE_END;
813
//Write headers of paragraphs in rows
814
Bool32 fisrtCol=TRUE;//In order for it not to write NEW_COL in the beginning og first column
815
CEDParagraph* hPara=sect->paragraphs;
816
while (hPara&&hPara->parentNumber==sec)
827
if (!WritePara(hFile,hPara)) goto ED_WRITE_END;
830
if (!WriteRemark(hFile,SSR_FRAG_TYPE,TP_NEW_TAB_BEG)) goto ED_WRITE_END;
833
if (!WriteRemark(hFile,SSR_FRAG_TYPE,TP_NEW_ROW_BEG)) goto ED_WRITE_END;
834
rd=(edRowDescr*)(hPara)->descriptor;
835
rp.topBrdrType=rd->topBrdrType;
836
rp.topBrdrWidth=rd->topBrdrWidth;
837
rp.bottomBrdrType=rd->bottomBrdrType;
838
rp.bottomBrdrWidth=rd->bottomBrdrWidth;
839
rp.leftBrdrType=rd->leftBrdrType;
840
rp.leftBrdrWidth=rd->leftBrdrWidth;
841
rp.rightBrdrType=rd->rightBrdrType;
842
rp.rightBrdrWidth=rd->rightBrdrWidth;
844
rp.header=BYTE(rd->header);
846
rp.position=rd->position;
847
rp.rowHeight=rd->rowHeight;
850
if (!WriteExtCode(hFile,EDEXT_TABLE_ROW,&rp,sizeof(rp))) goto ED_WRITE_END;
854
if (!WriteRemark(hFile,SSR_FRAG_TYPE,TP_NEW_CELL_BEG)) goto ED_WRITE_END;
855
cd=(edCellDescr*)(hPara)->descriptor;
856
cp.topBrdrType=cd->topBrdrType;
857
cp.topBrdrWidth=cd->topBrdrWidth;
858
cp.bottomBrdrType=cd->bottomBrdrType;
859
cp.bottomBrdrWidth=cd->bottomBrdrWidth;
860
cp.leftBrdrType=cd->leftBrdrType;
861
cp.leftBrdrWidth=cd->leftBrdrWidth;
862
cp.rightBrdrType=cd->rightBrdrType;
863
cp.rightBrdrWidth=cd->rightBrdrWidth;
866
cp.shading=cd->shading;
867
cp.merging=cd->merging;
868
cp.vertTextAlign=cd->vertTextAlign;
870
memcpy(&(cp.layout),&(cd->layout),sizeof(edBox));
871
if (!WriteExtCode(hFile,EDEXT_TABLE_CELL,&cp,sizeof(cp))) goto ED_WRITE_END;
875
if (!WriteRemark(hFile,SSR_FRAG_TYPE,TP_NEW_TAB_END)) goto ED_WRITE_END;
879
if (!WriteRemark(hFile,SSR_FRAG_TYPE,TP_FRAME_BEG)) goto ED_WRITE_END;
880
fd=(edFrameDescr*)(hPara)->descriptor;
885
fp.borderSpace=fd->borderSpace;
886
fp.dxfrtextx=fd->dxfrtextx;
887
fp.dxfrtexty=fd->dxfrtexty;
888
fp.position=fd->position;
890
if (!WriteExtCode(hFile,EDEXT_FRAME,&fp,sizeof(fp),0)) goto ED_WRITE_END;
894
if (!WriteRemark(hFile,SSR_FRAG_TYPE,TP_FRAME_END)) goto ED_WRITE_END;
899
if (!WriteRemark(hFile,SSR_FRAG_TYPE,TP_NEW_COL)) goto ED_WRITE_END;
907
if (!WriteRemark(hFile,SSR_FRAG_TYPE,TP_MCOL_END)) goto ED_WRITE_END;
910
if (!WriteRemark(hFile,SSR_FRAG_END,0)) goto ED_WRITE_END;
912
//Write the file itself
913
tmpChr=page->GetChar(0);
917
fk.code=SS_FONT_KEGL;
918
font=fk.new_font=tmpChr->fontAttribs;
919
kegl=fk.new_kegl=tmpChr->fontHeight;
920
if (!Write(hFile,(PInt8)&fk,sizeof(fk))) goto ED_WRITE_END;
922
chp.fontNumber=fontNum=tmpChr->fontNum;
923
chp.foregroundColor=foregroundColor=tmpChr->foregroundColor;
924
chp.backgroundColor=backgroundColor=tmpChr->backgroundColor;
925
if (!WriteExtCode(hFile,EDEXT_CHAR,&chp,sizeof(chp))) goto ED_WRITE_END;
928
fl.language=lang=tmpChr->fontLang;
929
if (!Write(hFile,(PInt8)&fl,sizeof(fl))) goto ED_WRITE_END;
936
if(line=page->GetLine(0))
940
//Write(hFile,(char*)&lb,sizeof(lb));
941
if (!WriteRemark(hFile,SSR_LINE_FN,line->parentNumber)) goto ED_WRITE_END;
942
if(line->SetCurChar(0))
944
CEDChar *chr=line->GetCurChar();
947
line->SetCurChar(chr);
949
bmr.code=SS_BITMAP_REF;
950
bmr.col=(Word16)chr->layout.left;
951
bmr.row=(Word16)chr->layout.top;
952
bmr.height=(Word16)(chr->layout.bottom-chr->layout.top);
953
bmr.width=Word16(chr->layout.right-chr->layout.left);
954
if (!Write(hFile,(PInt8)(&bmr),sizeof(bmr))) goto ED_WRITE_END;
955
if(chr->fontHeight!=kegl||chr->fontAttribs!=font)
958
fk.code=SS_FONT_KEGL;
959
font=fk.new_font=chr->fontAttribs;
960
kegl=fk.new_kegl=chr->fontHeight;
961
if (!Write(hFile,(PInt8)&fk,sizeof(fk))) goto ED_WRITE_END;
963
if(chr->fontNum!=fontNum||chr->foregroundColor!=foregroundColor||chr->backgroundColor!=backgroundColor)
966
chp.fontNumber=fontNum=chr->fontNum;
967
chp.foregroundColor=foregroundColor=chr->foregroundColor;
968
chp.backgroundColor=backgroundColor=chr->backgroundColor;
969
if (!WriteExtCode(hFile,EDEXT_CHAR,&chp,sizeof(chp))) goto ED_WRITE_END;
971
if(chr->fontLang!=lang)
975
fl.language=lang=chr->fontLang;
976
if (!Write(hFile,(PInt8)&fl,sizeof(fl))) goto ED_WRITE_END;
978
if (chr->alternatives)
980
if (!Write(hFile,(PInt8)chr->alternatives,chr->numOfAltern*sizeof(letterEx))) goto ED_WRITE_END;
987
if (!Write(hFile,(PInt8)&l,sizeof(letterEx))) goto ED_WRITE_END;
989
chr=line->NextChar(FALSE);
992
if (line->hardBreak||line->defChrFontHeight>0)
996
lb.base_line=!line->hardBreak;
997
lb.height=line->defChrFontHeight;
998
if (!Write(hFile,(PInt8)&lb,sizeof(line_beg))) goto ED_WRITE_END;
1000
line=line->next;//para->NextLine(FALSE);
1004
SetReturnCode_ced(IDS_ERR_NO);
1008
SetReturnCode_ced(CFIO_GetReturnCode());
1011
Close(hFile,CSF_SAVEDISK);
1015
Bool32 WriteFontTable(HANDLE hFile, CEDPage* page)
1018
//define the sum of lengths of all names of fonts
1021
if (!(page->fontsUsed))
1023
for (q=0;q<page->fontsUsed;q++)
1025
page->GetFont(q,0,0,0,&ch);
1029
if (!WriteExtCode(hFile,EDEXT_FONTS,0,0,len+sizeof(fontDiscr)*page->fontsUsed)) return FALSE;
1032
for (q=0;q<page->fontsUsed;q++)
1034
page->GetFont(q,&(fond.fontNumber),&(fond.fontPitchAndFamily),
1035
&(fond.fontCharset),&ch);
1036
fond.size=strlen(ch)+1+sizeof(fontDiscr);
1037
//write info about font
1038
if (!Write(hFile,(PInt8)&fond,sizeof(fontDiscr))) return FALSE;
1040
if (!Write(hFile,(PInt8)ch,strlen(ch)+1)) return FALSE;
1045
Bool32 WriteTiffDescr(HANDLE hFile, CEDPage* page)
1047
originalImageDesc fond;
1048
fond.height=page->sizeOfImage.cy;
1049
fond.width=page->sizeOfImage.cx;
1050
fond.pageNum=page->pageNumber;
1051
fond.inclune=page->turn;
1052
fond.resolutionX=(WORD)page->dpi.cx;
1053
fond.resolutionY=(WORD)page->dpi.cy;
1054
fond.unrecogSymbol=page->unrecogChar;
1055
if (!WriteExtCode(hFile,EDEXT_TIFF_DESC,&fond,sizeof(fond),strlen(page->imageName)+1)) return FALSE;
1056
if (!Write(hFile,(PInt8)page->imageName,strlen(page->imageName)+1)) return FALSE;
1060
Bool32 WritePictTable(HANDLE hFile, CEDPage* page)
1062
//define sum of lengths of all pictures
1065
if (!(page->picsUsed))
1067
for (q=0;q<page->picsUsed;q++)
1069
len+=page->picsTable[q].len;
1071
if (!WriteExtCode(hFile,EDEXT_PICS,0,0,len+sizeof(pictDescr)*page->picsUsed)) return FALSE;
1074
for (q=0;q<page->picsUsed;q++)
1076
picd.pictAlign=page->picsTable[q].pictAlign;
1077
picd.pictGoal.cx=page->picsTable[q].pictGoal.cx;
1078
picd.pictGoal.cy=page->picsTable[q].pictGoal.cy;
1079
picd.pictNumber=page->picsTable[q].pictNumber;
1080
picd.pictSize.cx=page->picsTable[q].pictSize.cx;
1081
picd.pictSize.cy=page->picsTable[q].pictSize.cy;
1082
picd.len=page->picsTable[q].len;
1083
picd.type=page->picsTable[q].type;
1084
picd.size=page->picsTable[q].len+sizeof(picd);
1085
//write picture info.
1086
if (!Write(hFile,(PInt8)&picd,sizeof(picd))) return FALSE;
1088
if (!Write(hFile,(PInt8)page->picsTable[q].data,page->picsTable[q].len)) return FALSE;
1093
Bool32 WritePara(HANDLE hFile,CEDParagraph* hPara)
1096
if (!WriteRemark(hFile,SSR_FRAG_TYPE,hPara->alignment)) return FALSE;
1097
pard.color=hPara->color;
1098
pard.spaceBefore=hPara->interval.cx;
1099
pard.spaceAfter=hPara->interval.cy;
1100
pard.alignment=hPara->alignment;
1101
pard.firstIndent=hPara->indent.top;
1102
pard.leftIndent=hPara->indent.left;
1103
pard.rightIndent=hPara->indent.right;
1104
pard.keep=hPara->keep;
1105
pard.shading=hPara->shading;
1106
pard.spaceBetweenLines=hPara->spaceBetweenLines;
1107
pard.spcBtwLnsMult=hPara->spcBtwLnsMult;
1108
pard.userNum=hPara->userNumber;
1109
pard.topBrdrType=hPara->topBrdrType;
1110
pard.topBrdrWidth=hPara->topBrdrWidth;
1111
pard.bottomBrdrType=hPara->bottomBrdrType;
1112
pard.bottomBrdrWidth=hPara->bottomBrdrWidth;
1113
pard.leftBrdrType=hPara->leftBrdrType;
1114
pard.leftBrdrWidth=hPara->leftBrdrWidth;
1115
pard.rightBrdrType=hPara->rightBrdrType;
1116
pard.rightBrdrWidth=hPara->rightBrdrWidth;
1117
pard.brdrBtw=hPara->brdrBtw;
1118
if (!WriteExtCode(hFile,EDEXT_PARAGRAPH,&pard,sizeof(pard))) return FALSE;
1122
//write lenOfObj+extraLen to the field corresponding to length
1123
Bool32 WriteExtCode(HANDLE hFile,int Ecode, void* object, int lenOfObj, int extraLen)
1125
if (!(Ecode&0x8000))
1128
ext.code=SS_EXTENTION;
1130
ext.length=lenOfObj+extraLen+sizeof(ext);
1131
if (!Write(hFile,(PInt8)&ext,sizeof(ext))) return FALSE;
1136
ext.code=SS_EXTENTION;
1138
ext.length=lenOfObj+extraLen+sizeof(ext);
1139
if (!Write(hFile,(PInt8)&ext,sizeof(ext))) return FALSE;
1142
if (!Write(hFile,(PInt8)object,lenOfObj)) return FALSE;
1146
Bool32 WriteRemark(HANDLE hFile,int type, int object)
1152
if (!Write(hFile,(PInt8)&tr,sizeof(tr))) return FALSE;
1157
Word32 CED_IsEdFile (char * file,Bool32 readFromFile, Word32 bufLen)
1165
len=MemFromFile((PInt8)file,&PedHandle);
1168
start = (PWord8)Lock(PedHandle);
1178
start =(Word8*)file;
1182
if (len<sizeof(sheet_disk_descr)+sizeof(fragm_disk_descr)+1)
1192
if (start[sizeof(sheet_disk_descr)]!=0x0b)
1197
if (start[sizeof(sheet_disk_descr)+sizeof(fragm_disk_descr)]>=0x20)
1202
if (((sheet_disk_descr*)start)->version=2000)