-
Notifications
You must be signed in to change notification settings - Fork 4
/
FBDoc.h
167 lines (132 loc) · 4.43 KB
/
FBDoc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
// FBDoc.h: interface for the FBDoc class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_FBDOC_H__205AB072_350A_4D2F_B58B_61BBC255FFE5__INCLUDED_)
#define AFX_FBDOC_H__205AB072_350A_4D2F_B58B_61BBC255FFE5__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "FBEView.h"
namespace FB // put all FB2 related stuff into its own namespace
{
// an fb2 document in-memory representation
class Doc
{
public:
// document encoding
CString m_encoding;
// owner frame
HWND m_frame;
// document text is stored here
//CFBEView m_desc;
CFBEView m_body;
// filename
CString m_filename;
bool m_namevalid;
bstr_t m_save_marker;
static bool m_fast_mode;
MSHTML::IHTMLElementPtr m_saved_element;
// construction and destruction
Doc(HWND hWndFrame);
~Doc();
void SaveSelectedPos();
void DeleteSaveMarker();
long GetSavedPos(bstr_t& dom, bool deleteMarker = true);
// loading and savingaa
void CreateBlank(HWND hWndParent);
bool Load(HWND hWndParent,const CString& filename);
//bool LoadFromDOM(HWND hWndParent,MSXML2::IXMLDOMDocument2 *dom);
bool LoadFromHTML(HWND hWndParent,const CString& filename);
MSXML2::IXMLDOMDocument2Ptr CreateDOM(const CString& encoding);
HRESULT InvokeFunc(BSTR FuncName, CComVariant *params, int count, CComVariant &vtResult);
void ShowDescription(bool Show);
void RunScript(BSTR filePath);
VARIANT_BOOL Doc::CheckScript(BSTR filePath);
bool Save(const CString& filename);
bool Validate(int &errline,int &errcol) {
AU::CPersistentWaitCursor wc;
return SaveToFile(CString(),true,&errline,&errcol);
}
bool SetXMLAndValidate(HWND sci,bool fValidateOnly,int& errline,int& errcol);
bool TextToXML(BSTR text, MSXML2::IXMLDOMDocument2Ptr *xml);
//bool SetXML(MSXML2::IXMLDOMDocument2 *dom);
bool Save();
// changes
bool DocChanged() {
return m_body_ver!=m_body.GetVersionNumber() ||
//m_desc_ver!=m_desc.GetVersionNumber() ||
m_body.IsFormChanged(); }
// added by SeNS
void AdvanceDocVersion (int delta) {
m_body_ver += delta;
}
void MarkSavePoint() {
m_body_ver=m_body.GetVersionNumber();
//m_desc_ver=m_desc.GetVersionNumber();
m_body.ResetFormChanged();
}
void ResetSavePoint() { m_body_ver=-1; }
void MarkDocCP() {
m_body_cp=m_body.GetVersionNumber();
//m_desc_cp=m_desc.GetVersionNumber();
m_body.ResetFormCP(); }
bool DocRelChanged() {
return m_body_cp!=m_body.GetVersionNumber() ||
// m_desc_cp!=m_desc.GetVersionNumber() ||
m_body.IsFormCP();
}
// IDs
void BinIDsToComboBox(CComboBox& box);
void ParaIDsToComboBox(CComboBox& box);
// binary objects
BSTR PrepareDefaultId(const CString& filename);
void AddBinary(const CString& filename);
// config
void ApplyConfChanges();
// active document table
static Doc *LocateDocument(const wchar_t *id);
static Doc* m_active_doc;
// binary objects
bool GetBinary(const wchar_t *id,_variant_t& vt);
// Word lists
struct Word
{
CString word;
CString replacement;
int count;
int flags;
Word() : count(0), flags(0) { }
Word(CString& word, int count) : word(word), count(count), flags(0) { }
};
enum
{
GW_INCLUDE_HYPHENS = 1,
GW_HYPHENS_ONLY = 2,
GW_SORT_BY_COUNT = 4
};
void GetWordList(int flags, CSimpleArray<Word>& words, CString tagName);
private:
//long m_desc_ver;
long m_body_ver;
//long m_desc_cp;
long m_body_cp;
// saving support
bool SaveToFile(const CString& filename,bool fValidateOnly=false,int *errline=NULL,int *errcol=NULL);
MSXML2::IXMLDOMDocument2Ptr CreateDOMImp(const CString& encoding);
// loading support
void TransformXML(MSXML2::IXSLTemplatePtr tp,MSXML2::IXMLDOMDocument2Ptr doc,
CFBEView& dest);
CString MyID() { CString ret; ret.Format(_T("%lu"),(unsigned long)this); return ret; }
CString MyURL(const wchar_t *part) { CString ret; ret.Format(_T("fbw-internal:%lu:%s"),(unsigned long)this,part); return ret; }
static CSimpleMap<Doc*,Doc*> m_active_docs;
public:
MSHTML::IHTMLDOMNodePtr MoveNode(MSHTML::IHTMLDOMNodePtr from, MSHTML::IHTMLDOMNodePtr to, MSHTML::IHTMLDOMNodePtr insertBefore);
void SetFastMode(bool fast);
bool GetFastMode();
int GetSelectedPos();
CString GetOpenFileName()const;
private:
void FastMode();
};
} // namespace FB
#endif // !defined(AFX_FBDOC_H__205AB072_350A_4D2F_B58B_61BBC255FFE5__INCLUDED_)