notesgrip 0.0.4
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.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +22 -0
- data/README.rdoc +135 -0
- data/Rakefile +2 -0
- data/Sample/sample_NotesDatabase.rb +77 -0
- data/Sample/sample_NotesSession.rb +17 -0
- data/Sample/sample_NotesView.rb +63 -0
- data/lib/notesgrip/DocCollection.rb +53 -0
- data/lib/notesgrip/GripWrapper.rb +43 -0
- data/lib/notesgrip/NotesDatabase.rb +468 -0
- data/lib/notesgrip/NotesDocument.rb +258 -0
- data/lib/notesgrip/NotesItem.rb +172 -0
- data/lib/notesgrip/NotesRichTextItem.rb +256 -0
- data/lib/notesgrip/NotesSession.rb +317 -0
- data/lib/notesgrip/NotesView.rb +447 -0
- data/lib/notesgrip/version.rb +3 -0
- data/lib/notesgrip.rb +17 -0
- data/notesgrip.gemspec +23 -0
- metadata +92 -0
@@ -0,0 +1,258 @@
|
|
1
|
+
module Notesgrip
|
2
|
+
# ====================================================
|
3
|
+
# ============= NotesDocument Class ================
|
4
|
+
# ====================================================
|
5
|
+
class NotesDocument < GripWrapper
|
6
|
+
def initialize(raw_doc)
|
7
|
+
super(raw_doc)
|
8
|
+
@parent_db = nil
|
9
|
+
@parent_view = nil
|
10
|
+
end
|
11
|
+
|
12
|
+
def EmbeddedObjects
|
13
|
+
raw_embeddedObjects = @raw_object.EmbeddedObjects
|
14
|
+
ret_list = []
|
15
|
+
raw_embeddedObjects.each {|raw_embeddedObject|
|
16
|
+
ret_list.push NotesEmbeddedObject.new(raw_embeddedObject)
|
17
|
+
}
|
18
|
+
ret_list
|
19
|
+
end
|
20
|
+
|
21
|
+
def Items
|
22
|
+
ret_list = []
|
23
|
+
@raw_object.Items.each {|raw_item|
|
24
|
+
if raw_item.Type == NotesItem::RICHTEXT
|
25
|
+
ret_list.push NotesRichTextItem.new(raw_item)
|
26
|
+
else
|
27
|
+
ret_list.push NotesItem.new(raw_item)
|
28
|
+
end
|
29
|
+
}
|
30
|
+
ret_list
|
31
|
+
end
|
32
|
+
|
33
|
+
def ParentDatabase
|
34
|
+
NotesDatabase.new(@raw_object.ParentDatabase)
|
35
|
+
end
|
36
|
+
|
37
|
+
def ParentView
|
38
|
+
raw_view = @raw_object.ParentView
|
39
|
+
raw_view ? NotesView(raw_view) : nil
|
40
|
+
end
|
41
|
+
|
42
|
+
def Responses
|
43
|
+
raw_docCollection = @raw_object.Responses
|
44
|
+
NotesDocumentCollection.new(raw_docCollection)
|
45
|
+
end
|
46
|
+
|
47
|
+
def AppendItemValue( itemName, value )
|
48
|
+
raw_item = @raw_object.AppendItemValue( itemName, value )
|
49
|
+
NotesItem.new(raw_item)
|
50
|
+
end
|
51
|
+
|
52
|
+
def AttachVCard( clientADTObject )
|
53
|
+
raw_obj = toRaw(clientADTObject)
|
54
|
+
@raw_object.AttachVCard(raw_obj)
|
55
|
+
end
|
56
|
+
|
57
|
+
def CopyAllItems( sourceDoc, replace=false )
|
58
|
+
raw_sourceDoc = toRaw(sourceDoc)
|
59
|
+
@raw_object.CopyAllItems( raw_sourceDoc, replace)
|
60
|
+
end
|
61
|
+
|
62
|
+
def CopyItem( sourceItem, newName=nil )
|
63
|
+
raw_sourceItem = toRaw(sourceItem)
|
64
|
+
unless newName
|
65
|
+
newName = sourceItem.Name
|
66
|
+
end
|
67
|
+
raw_item = @raw_object.CopyItem(raw_sourceItem, newName)
|
68
|
+
NotesItem.new(raw_item)
|
69
|
+
end
|
70
|
+
|
71
|
+
def CopyToDatabase( destDatabase )
|
72
|
+
raw_destDB = toRaw(destDatabase)
|
73
|
+
new_rawDoc = @raw_object.CopyToDatabase( raw_destDB )
|
74
|
+
NotesDocument.new(new_rawDoc)
|
75
|
+
end
|
76
|
+
|
77
|
+
def CreateMIMEEntity( itemName )
|
78
|
+
raw_mimeEntry = @raw_object.CreateMIMEEntity( itemName )
|
79
|
+
NotesMIMEEntity.new(raw_mimeEntry)
|
80
|
+
end
|
81
|
+
|
82
|
+
def CreateReplyMessage( all )
|
83
|
+
raw_replyDoc = @raw_object.CreateReplyMessage( all )
|
84
|
+
NotesDocument.new(raw_replyDoc)
|
85
|
+
end
|
86
|
+
|
87
|
+
def CreateRichTextItem( name )
|
88
|
+
raw_richTextItem = @raw_object.CreateRichTextItem( name )
|
89
|
+
NotesRichTextItem.new(raw_richTextItem)
|
90
|
+
end
|
91
|
+
|
92
|
+
def GetAttachment( fileName )
|
93
|
+
raw_embeddedObject = @raw_object.GetAttachment( fileName )
|
94
|
+
raw_embeddedObject ? NotesEmbeddedObject.new(raw_embeddedObject) : nil
|
95
|
+
end
|
96
|
+
|
97
|
+
def GetFirstItem( name )
|
98
|
+
raw_item = @raw_object.GetFirstItem( name )
|
99
|
+
raw_item ? NotesItem.new(raw_item) : nil
|
100
|
+
end
|
101
|
+
|
102
|
+
def GetItemValue( itemName )
|
103
|
+
@raw_object.GetItemValue( itemName )
|
104
|
+
end
|
105
|
+
|
106
|
+
def GetItemValueCustomDataBytes( itemName, dataTypeName )
|
107
|
+
@raw_object.GetItemValueCustomDataBytes( itemName, dataTypeName )
|
108
|
+
end
|
109
|
+
|
110
|
+
def GetItemValueDateTimeArray( itemName )
|
111
|
+
obj_list = @raw_object.GetItemValueDateTimeArray( itemName )
|
112
|
+
ret_list = []
|
113
|
+
obj_list.each {|date_obj|
|
114
|
+
ret_list.push NotesDateTime.new(date_obj)
|
115
|
+
}
|
116
|
+
end
|
117
|
+
|
118
|
+
def GetMIMEEntity( itemName )
|
119
|
+
raw_mimeEntry = @raw_object.GetMIMEEntity( itemName )
|
120
|
+
raw_mimeEntry ? NotesMIMEEntity.new(raw_mimeEntry) : nil
|
121
|
+
end
|
122
|
+
|
123
|
+
def MakeResponse( document )
|
124
|
+
NotesDocument.new(toRaw(document))
|
125
|
+
end
|
126
|
+
|
127
|
+
def RenderToRTItem( notesRichTextItem )
|
128
|
+
raw_richTextItem = toRaw(notesRichTextItem)
|
129
|
+
@raw_object.RenderToRTItem(raw_richTextItem)
|
130
|
+
end
|
131
|
+
|
132
|
+
def ReplaceItemValue( itemName, value )
|
133
|
+
raw_item = @raw_object.ReplaceItemValue( itemName, value )
|
134
|
+
NotesItem.new(raw_item)
|
135
|
+
end
|
136
|
+
|
137
|
+
def ReplaceItemValueCustomDataBytes( itemName, dataTypeName, byteArray )
|
138
|
+
@raw_object.ReplaceItemValueCustomDataBytes( itemName, dataTypeName, byteArray )
|
139
|
+
end
|
140
|
+
|
141
|
+
# ---- Additional Methods ------
|
142
|
+
def unid
|
143
|
+
@raw_object.UniversalID
|
144
|
+
end
|
145
|
+
|
146
|
+
def [](itemname)
|
147
|
+
if @raw_object.HasItem(itemname)
|
148
|
+
raw_item = @raw_object.GetFirstItem(itemname)
|
149
|
+
else
|
150
|
+
# If this document hasn't itemname field, create new item.
|
151
|
+
raw_item = @raw_object.AppendItemValue(itemname, "")
|
152
|
+
end
|
153
|
+
if raw_item.Type == NotesItem::RICHTEXT
|
154
|
+
NotesRichTextItem.new(raw_item)
|
155
|
+
else
|
156
|
+
NotesItem.new(raw_item)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
# Copy Field
|
161
|
+
def []=(itemname, other_item)
|
162
|
+
if @raw_object.HasItem(itemname)
|
163
|
+
@raw_object.RemoveItem(itemname) # �����̃f�[�^����������Ԃ�CopyItem���ĂԂƁA�lj������ɂȂ�̂�
|
164
|
+
end
|
165
|
+
|
166
|
+
raw_otherItem = toRaw(other_item)
|
167
|
+
raw_item = @raw_object.CopyItem(raw_otherItem, itemname)
|
168
|
+
NotesItem.new(raw_item)
|
169
|
+
end
|
170
|
+
|
171
|
+
def each_item
|
172
|
+
self.Items.each {|notes_item|
|
173
|
+
yield notes_item
|
174
|
+
}
|
175
|
+
end
|
176
|
+
|
177
|
+
def save(force=true, createResponse=false , markRead = false)
|
178
|
+
@raw_object.Save(force, createResponse, markRead)
|
179
|
+
end
|
180
|
+
|
181
|
+
def inspect
|
182
|
+
"<#{self.class}, Form:#{self['Form'].text.inspect}>"
|
183
|
+
end
|
184
|
+
|
185
|
+
end
|
186
|
+
|
187
|
+
# ====================================================
|
188
|
+
# ====== NotesDocumentCollection Class ===============
|
189
|
+
# ====================================================
|
190
|
+
class NotesDocumentCollection < GripWrapper
|
191
|
+
include DocCollection
|
192
|
+
|
193
|
+
def Count
|
194
|
+
@raw_object.count
|
195
|
+
end
|
196
|
+
alias size Count
|
197
|
+
|
198
|
+
def Parent
|
199
|
+
NotesDatabase.new(@raw_object.Parent)
|
200
|
+
end
|
201
|
+
|
202
|
+
def AddDocument( document)
|
203
|
+
raw_doc = toRaw(document)
|
204
|
+
@raw_object.AddDocument(raw_doc)
|
205
|
+
end
|
206
|
+
|
207
|
+
def Clone()
|
208
|
+
NotesDocumentCollection.new(@raw_object.Clone())
|
209
|
+
end
|
210
|
+
|
211
|
+
def Contains( inputNotes )
|
212
|
+
raw_obj = toRaw(inputNotes)
|
213
|
+
@raw_object.Contains(raw_obj)
|
214
|
+
end
|
215
|
+
|
216
|
+
def DeleteDocument( document )
|
217
|
+
raw_doc = toRaw(document)
|
218
|
+
@raw_object.DeleteDocument(raw_doc)
|
219
|
+
end
|
220
|
+
|
221
|
+
def FTSearch( query, maxDocs )
|
222
|
+
raw_docCollection = @raw_object.FTSearch( query, maxDocs )
|
223
|
+
FTSearch( raw_docCollection )
|
224
|
+
end
|
225
|
+
|
226
|
+
def GetDocument( document )
|
227
|
+
raw_doc = toRaw(document)
|
228
|
+
raw_doc2 = @raw_object.GetDocument(raw_doc)
|
229
|
+
raw_doc2 ? NotesDocument.new(raw_doc2) : nil
|
230
|
+
end
|
231
|
+
|
232
|
+
def Intersect( inputNotes )
|
233
|
+
raw_obj = toRaw(inputNotes)
|
234
|
+
@raw_object.Intersect(raw_obj)
|
235
|
+
end
|
236
|
+
|
237
|
+
def Merge( inputNotes )
|
238
|
+
raw_obj = toRaw(inputNotes)
|
239
|
+
@raw_object.Merge(raw_obj)
|
240
|
+
end
|
241
|
+
|
242
|
+
def StampAllMulti( document )
|
243
|
+
raw_doc = toRaw(document)
|
244
|
+
@raw_object.StampAllMulti(raw_doc)
|
245
|
+
end
|
246
|
+
|
247
|
+
def Subtract( inputNotes )
|
248
|
+
raw_obj = toRaw(inputNotes)
|
249
|
+
@raw_object.Subtract(raw_obj)
|
250
|
+
end
|
251
|
+
|
252
|
+
# ---- Additional Methods ------
|
253
|
+
def inspect
|
254
|
+
"<#{self.class}, Count:#{self.Count}>"
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
end
|
@@ -0,0 +1,172 @@
|
|
1
|
+
module Notesgrip
|
2
|
+
# ====================================================
|
3
|
+
# ================= NotesItem Class ==================
|
4
|
+
# ====================================================
|
5
|
+
class NotesItem < GripWrapper
|
6
|
+
class NameError < StandardError
|
7
|
+
end
|
8
|
+
class RichFieldError < StandardError
|
9
|
+
end
|
10
|
+
|
11
|
+
RICH_TYP = 1
|
12
|
+
DATE_TYP = 1024
|
13
|
+
ATTACHMENT_TYP = 1084
|
14
|
+
TEXT_TYP = 1280
|
15
|
+
NAME_TYP = 1074
|
16
|
+
|
17
|
+
def DateTimeValue
|
18
|
+
raw_dateTimeVal = @raw_object.DateTimeValue
|
19
|
+
raw_dateTimeVal ? NotesDateTime.new(raw_dateTimeVal) : nil
|
20
|
+
end
|
21
|
+
|
22
|
+
def Parent
|
23
|
+
NotesDocument.new(@raw_object.Parent)
|
24
|
+
end
|
25
|
+
|
26
|
+
ACTIONCD = 16 # saved action CD records; non-Computable; canonical form.
|
27
|
+
ASSISTANTINFO = 17 # saved assistant information; non-Computable; canonical form.
|
28
|
+
ATTACHMENT = 1084 # file attachment.
|
29
|
+
AUTHORS = 1076 # authors.
|
30
|
+
COLLATION = 2 # COLLATION?
|
31
|
+
DATETIMES = 1024 # date-time value or range of date-time values.
|
32
|
+
EMBEDDEDOBJECT = 1090 # embedded object.
|
33
|
+
ERRORITEM = 256 # an error occurred while accessing the type.
|
34
|
+
FORMULA = 1536 # Notes formula.
|
35
|
+
HTML = 21 # HTML source text.
|
36
|
+
ICON = 6 # icon.
|
37
|
+
LSOBJECT = 20 # saved LotusScript Object code for an agent.
|
38
|
+
MIME_PART = 25 # MIME support.
|
39
|
+
NAMES = 1074 # names.
|
40
|
+
NOTELINKS = 7 # link to a database, view, or document.
|
41
|
+
NOTEREFS = 4 # reference to the parent document.
|
42
|
+
NUMBERS = 768 # number or number list.
|
43
|
+
OTHEROBJECT = 1085 # other object.
|
44
|
+
QUERYCD = 15 # saved query CD records; non-Computable; canonical form.
|
45
|
+
READERS = 1075 # readers.
|
46
|
+
RFC822Text = 1282 # RFC822 Internet mail text.
|
47
|
+
RICHTEXT = 1 # rich text.
|
48
|
+
SIGNATURE = 8 # signature.
|
49
|
+
TEXT = 1280 # text or text list.
|
50
|
+
UNAVAILABLE = 512 # the item type isn't available.
|
51
|
+
UNKNOWN = 0 # the item type isn't known.
|
52
|
+
USERDATA = 14 # user data.
|
53
|
+
USERID = 1792 # user ID name.
|
54
|
+
VIEWMAPDATA = 18 # saved ViewMap dataset; non-Computable; canonical form.
|
55
|
+
VIEWMAPLAYOUT = 19 # saved ViewMap layout; non-Computable; canonical form.
|
56
|
+
def Type
|
57
|
+
@raw_object.Type
|
58
|
+
end
|
59
|
+
|
60
|
+
def Text
|
61
|
+
@raw_object.text
|
62
|
+
end
|
63
|
+
|
64
|
+
def ValueLength
|
65
|
+
@raw_object.ValueLength
|
66
|
+
end
|
67
|
+
alias length ValueLength
|
68
|
+
|
69
|
+
|
70
|
+
def Values
|
71
|
+
@raw_object.Values
|
72
|
+
end
|
73
|
+
alias values Values
|
74
|
+
|
75
|
+
|
76
|
+
def AppendToTextList( newValue )
|
77
|
+
@raw_object.AppendToTextList( newValue )
|
78
|
+
end
|
79
|
+
|
80
|
+
def contains?(value)
|
81
|
+
@raw_object.Contains(value)
|
82
|
+
end
|
83
|
+
|
84
|
+
def CopyItemToDocument( otherDoc, newName=nil )
|
85
|
+
unless newName
|
86
|
+
newName = self.Name
|
87
|
+
end
|
88
|
+
raw_newItem = @raw_object.CopyItemToDocument( toRaw(otherDoc), newName )
|
89
|
+
NotesItem.new(raw_newItem)
|
90
|
+
end
|
91
|
+
|
92
|
+
def GetValueDateTimeArray()
|
93
|
+
rawDateTimeArray = @raw_object.GetValueDateTimeArray()
|
94
|
+
return nil unless rawDateTimeArray
|
95
|
+
ret_list = []
|
96
|
+
rawDateTimeArray.each {|rawDateTime|
|
97
|
+
# ? �ǂ������NotesDateTime�� NotesDateRange����ʂ����?
|
98
|
+
ret_list.push NotesDateTime.new(rawDateTime)
|
99
|
+
raise "Not Implement"
|
100
|
+
}
|
101
|
+
end
|
102
|
+
|
103
|
+
def GetMIMEEntity()
|
104
|
+
rawMIMEEntry = @raw_object.GetMIMEEntity()
|
105
|
+
rawMIMEEntry ? NotesMIMEEntity.new(rawMIMEEntry) : nil
|
106
|
+
end
|
107
|
+
|
108
|
+
def Remove
|
109
|
+
@raw_object.Remove()
|
110
|
+
@raw_object = nil
|
111
|
+
end
|
112
|
+
|
113
|
+
# ----- Additional Methods ----
|
114
|
+
def Values=(item_value)
|
115
|
+
# @raw_object.Type returns data type of field(ex: RICH_TYP,DATE_TYP...)
|
116
|
+
case @raw_object.Type
|
117
|
+
when RICH_TYP
|
118
|
+
val_array = [item_value].flatten
|
119
|
+
raw_doc = self.Parent.raw
|
120
|
+
item_name = @raw_object.Name
|
121
|
+
raw_doc.RemoveItem(item_name)
|
122
|
+
new_item = raw_doc.CreateRichTextItem( item_name )
|
123
|
+
@raw_object = new_item.AppendText(val_array.join(""))
|
124
|
+
else
|
125
|
+
val_array = [item_value].flatten
|
126
|
+
raw_doc = self.Parent.raw
|
127
|
+
item_name = @raw_object.Name
|
128
|
+
raw_newitem = raw_doc.ReplaceItemValue(item_name, val_array)
|
129
|
+
@raw_object = raw_newitem # replace @raw_object
|
130
|
+
end
|
131
|
+
end
|
132
|
+
alias text= Values=
|
133
|
+
|
134
|
+
ItemTypeDic = {
|
135
|
+
16=>'ACTIONCD', 17=>'ASSISTANTINFO', 1084=>'ATTACHMENT', 1076=>'AUTHORS', 2=>'COLLATION', 1024=>'DATETIMES',
|
136
|
+
1090=>'EMBEDDEDOBJECT', 256=>'ERRORITEM', 1536=>'FORMULA', 21=>'HTML', 6=>'ICON', 20=>'LSOBJECT', 25=>'MIME_PART',
|
137
|
+
1074=>'NAMES', 7=>'NOTELINKS', 4=>'NOTEREFS', 768=>'NUMBERS', 1085=>'OTHEROBJECT', 15=>'QUERYCD', 1075=>'READERS',
|
138
|
+
1282=>'RFC822Text', 1=>'RICHTEXT', 8=>'SIGNATURE', 1280=>'TEXT', 512=>'UNAVAILABLE', 0=>'UNKNOWN', 14=>'USERDATA',
|
139
|
+
1792=>'USERID', 18=>'VIEWMAPDATA', 19=>'VIEWMAPLAYOUT'
|
140
|
+
}
|
141
|
+
def inspect
|
142
|
+
if self.Values == nil
|
143
|
+
val = self.text
|
144
|
+
elsif self.Values.size > 1
|
145
|
+
val = self.Values
|
146
|
+
else
|
147
|
+
val = self.Text
|
148
|
+
end
|
149
|
+
"<#{self.class}, Type:#{ItemTypeDic[self.Type]}, #{self.name.inspect}=>#{val.inspect}>"
|
150
|
+
end
|
151
|
+
|
152
|
+
def each_value
|
153
|
+
@raw_object.Values.each {|val|
|
154
|
+
yield val
|
155
|
+
}
|
156
|
+
end
|
157
|
+
|
158
|
+
def EmbeddedObjects
|
159
|
+
[]
|
160
|
+
end
|
161
|
+
|
162
|
+
def to_s
|
163
|
+
self.Text
|
164
|
+
end
|
165
|
+
|
166
|
+
def CopyItem(other_item)
|
167
|
+
parent_doc = self.Parent
|
168
|
+
@raw_object = parent_doc.CopyItem(other_item, self.Name)
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|
172
|
+
end
|
@@ -0,0 +1,256 @@
|
|
1
|
+
module Notesgrip
|
2
|
+
# ====================================================
|
3
|
+
# =========== NotesRichTextItem Class ================
|
4
|
+
# ====================================================
|
5
|
+
class NotesRichTextItem < NotesItem
|
6
|
+
EMBED_ATTACHMENT = 1454
|
7
|
+
EMBED_OBJECT = 1453
|
8
|
+
EMBED_OBJECTLINK = 1452
|
9
|
+
def EmbeddedObjects
|
10
|
+
obj_list = []
|
11
|
+
return obj_list unless @raw_object.EmbeddedObjects
|
12
|
+
@raw_object.EmbeddedObjects.each {|rawEmbObj|
|
13
|
+
obj_list.push NotesEmbeddedObject.new(rawEmbObj)
|
14
|
+
}
|
15
|
+
obj_list
|
16
|
+
end
|
17
|
+
|
18
|
+
def AddNewLine( n=1, forceParagraph=true )
|
19
|
+
@raw_object.AddNewLine( n, forceParagraph)
|
20
|
+
end
|
21
|
+
|
22
|
+
def AppendDocLink( linkTo, comment=nil, hotSpotText=nil )
|
23
|
+
raw_linkTo = toRaw(linkTo)
|
24
|
+
@raw_object.AppendDocLink( raw_linkTo, comment, hotSpotText )
|
25
|
+
end
|
26
|
+
|
27
|
+
def AppendParagraphStyle( paragStyle )
|
28
|
+
raw_paragStyle = toRaw(paragStyle)
|
29
|
+
@raw_object.AppendParagraphStyle( raw_paragStyle )
|
30
|
+
end
|
31
|
+
|
32
|
+
def AppendRTItem( otherRichItem )
|
33
|
+
raw_otherRichItem = toRaw(otherRichItem)
|
34
|
+
@raw_object.AppendRTItem( raw_otherRichItem )
|
35
|
+
end
|
36
|
+
|
37
|
+
def AppendStyle( richTextStyle )
|
38
|
+
raw_richTextStyle = toRaw(richTextStyle)
|
39
|
+
@raw_object.AppendStyle( raw_richTextStyle )
|
40
|
+
end
|
41
|
+
|
42
|
+
def AppendTable( rows, columns, labels=nil, leftMargin=1440, rtpsStyleArray=nil )
|
43
|
+
raw_styleArray = []
|
44
|
+
if rtpsStyleArray
|
45
|
+
rtpsStyleArray.each {|rtpsStyle|
|
46
|
+
raw_styleArray.push toRaw(rtpsStyle)
|
47
|
+
}
|
48
|
+
end
|
49
|
+
@raw_object.AppendTable( rows, columns, labels, leftMargin, raw_styleArray )
|
50
|
+
end
|
51
|
+
|
52
|
+
def AppendText( text )
|
53
|
+
@raw_object.AppendText( text )
|
54
|
+
end
|
55
|
+
|
56
|
+
def BeginInsert( element, after=false )
|
57
|
+
raw_element = toRaw(element)
|
58
|
+
@raw_object.BeginInsert(raw_element)
|
59
|
+
end
|
60
|
+
|
61
|
+
def BeginSection( title, titleStyle=nil, barColor=nil, expand=false )
|
62
|
+
raw_titleStyle = toRaw(titleStyle)
|
63
|
+
raw_barColor = toRaw(barColor)
|
64
|
+
@raw_object.BeginSection( title, raw_titleStyle, raw_barColor, expand)
|
65
|
+
end
|
66
|
+
|
67
|
+
def CreateNavigator()
|
68
|
+
raw_RichTextNavigator = @raw_object.CreateNavigator()
|
69
|
+
NotesRichTextNavigator.new(raw_RichTextNavigator)
|
70
|
+
end
|
71
|
+
|
72
|
+
def CreateRange()
|
73
|
+
raw_notesRichTextRange = @raw_object.CreateRange()
|
74
|
+
NotesRichTextRange.new(raw_notesRichTextRange)
|
75
|
+
end
|
76
|
+
|
77
|
+
def EmbedObject( type, appClass, source )
|
78
|
+
case type
|
79
|
+
when EMBED_ATTACHMENT
|
80
|
+
fullpath = FileSystemObject.instance.fullpath(source)
|
81
|
+
added_object = @raw_object.EmbedObject( EMBED_ATTACHMENT, "", fullpath)
|
82
|
+
when EMBED_OBJECT
|
83
|
+
added_object = @raw_object.EmbedObject( EMBED_OBJECT, appClass, "")
|
84
|
+
when EMBED_OBJECTLINK
|
85
|
+
added_object = @raw_object.EmbedObject( EMBED_OBJECTLINK, "", source)
|
86
|
+
else
|
87
|
+
raise "Illegal Type."
|
88
|
+
end
|
89
|
+
NotesEmbeddedObject.new(added_object)
|
90
|
+
end
|
91
|
+
|
92
|
+
def GetEmbeddedObject( name )
|
93
|
+
raw_EmbeddedObject = @raw_object.GetEmbeddedObject( name )
|
94
|
+
raw_EmbeddedObject ? NotesEmbeddedObject.new(raw_EmbeddedObject) : nil
|
95
|
+
end
|
96
|
+
|
97
|
+
def GetFormattedText( tabstrip, lineLength=0 )
|
98
|
+
@raw_object.GetFormattedText( tabstrip, lineLength )
|
99
|
+
end
|
100
|
+
|
101
|
+
def [](embobj_name)
|
102
|
+
raw_embobj = @raw_object.GetEmbeddedObject(embobj_name)
|
103
|
+
if raw_embobj
|
104
|
+
NotesEmbeddedObject.new(raw_embobj)
|
105
|
+
else
|
106
|
+
nil
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def add_file(filename)
|
111
|
+
self.EmbedObject(EMBED_ATTACHMENT, "", filename)
|
112
|
+
end
|
113
|
+
|
114
|
+
def inspect
|
115
|
+
val = self.Text
|
116
|
+
"<#{self.class}, Type:#{ItemTypeDic[self.Type]}, #{self.name.inspect}=>#{val.inspect}>"
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
# ====================================================
|
121
|
+
# ============= NotesEmbeddedObject Class ================
|
122
|
+
# An embedded object(attached file(EMBED_ATTACHMENT), object link(EMBED_OBJECTLINK), OLE(EMBED_OBJECT), etc)
|
123
|
+
# ====================================================
|
124
|
+
class NotesEmbeddedObject < GripWrapper
|
125
|
+
EMBED_ATTACHMENT = 1454
|
126
|
+
EMBED_OBJECT = 1453
|
127
|
+
EMBED_OBJECTLINK = 1452
|
128
|
+
TypeDic = {
|
129
|
+
1454=>'EMBED_ATTACHMENT', 1453=>'EMBED_OBJECT', 1452=>'EMBED_OBJECTLINK'
|
130
|
+
}
|
131
|
+
def Parent
|
132
|
+
NotesRichTextItem.new(@raw_object.Parent)
|
133
|
+
end
|
134
|
+
alias parent Parent
|
135
|
+
|
136
|
+
def ExtractFile( path )
|
137
|
+
fullpath = FileSystemObject.instance.fullpath(path)
|
138
|
+
@raw_object.ExtractFile(fullpath)
|
139
|
+
end
|
140
|
+
|
141
|
+
def Remove()
|
142
|
+
@raw_object.Remove()
|
143
|
+
@raw_object = nil
|
144
|
+
end
|
145
|
+
|
146
|
+
def inspect
|
147
|
+
"<#{self.class} Type:#{TypeDic[self.Type]} Name:#{self.Name.inspect}>"
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
# ====================================================
|
152
|
+
# ================= NotesRichTextRange Class ===============
|
153
|
+
# Represents a range of elements in a rich text item.
|
154
|
+
# ====================================================
|
155
|
+
class NotesRichTextRange < GripWrapper
|
156
|
+
def Navigator
|
157
|
+
raw_richTextNavigator = @raw_object.Vavigator
|
158
|
+
NotesRichTextNavigator.new(raw_richTextNavigator)
|
159
|
+
end
|
160
|
+
|
161
|
+
def Style
|
162
|
+
raw_richTextStyle = @raw_object.Stle
|
163
|
+
NotesRichTextStyle.new(raw_richTextStyle)
|
164
|
+
end
|
165
|
+
|
166
|
+
RTELEM_TYPE_DOCLINK = 5
|
167
|
+
RTELEM_TYPE_FILEATTACHMENT = 8
|
168
|
+
RTELEM_TYPE_OLE = 9
|
169
|
+
RTELEM_TYPE_SECTION = 6
|
170
|
+
RTELEM_TYPE_TABLE = 1
|
171
|
+
RTELEM_TYPE_TABLECELL = 7
|
172
|
+
RTELEM_TYPE_TEXTPARAGRAPH = 4
|
173
|
+
RTELEM_TYPE_TEXTPOSITION = 10
|
174
|
+
RTELEM_TYPE_TEXTRUN = 3
|
175
|
+
RTELEM_TYPE_TEXTSTRING = 11
|
176
|
+
def Type
|
177
|
+
@raw_object.Type
|
178
|
+
end
|
179
|
+
|
180
|
+
def Clone
|
181
|
+
raw_richTextRange = @raw_object.Clone
|
182
|
+
NotesRichTextRange.new(raw_richTextRange)
|
183
|
+
end
|
184
|
+
|
185
|
+
RT_FIND_ACCENTINSENSITIVE = 4 # accent insensitive search (default is accent sensitive)
|
186
|
+
RT_FIND_CASEINSENSITIVE = 1 # case insensitive search (default is case sensitive)
|
187
|
+
RT_FIND_PITCHINSENSITIVE = 2 # pitch insensitive search (default is pitch sensitive)
|
188
|
+
RT_REPL_ALL = 16 # replace all occurrences of the search string
|
189
|
+
RT_REPL_PRESERVECASE = 8 # preserve case in the replacement string
|
190
|
+
def FindAndReplace( target , replacemen, options=0 )
|
191
|
+
@raw_object.FindAndReplace( target , replacemen, options )
|
192
|
+
end
|
193
|
+
|
194
|
+
def Remove
|
195
|
+
@raw_object.Remove
|
196
|
+
@raw_object = nil
|
197
|
+
end
|
198
|
+
|
199
|
+
def SetBegin( element )
|
200
|
+
raw_element = toRaw(element)
|
201
|
+
@raw_object.SetBegin(raw_element)
|
202
|
+
end
|
203
|
+
|
204
|
+
def SetEnd( element )
|
205
|
+
raw_element = toRaw(element)
|
206
|
+
@raw_object.SetEnd(raw_element)
|
207
|
+
end
|
208
|
+
|
209
|
+
def SetStyle( style )
|
210
|
+
raw_style = toRaw(style)
|
211
|
+
@raw_object.SetStyle(raw_style)
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
class NotesRichTextSection < GripWrapper
|
216
|
+
end
|
217
|
+
|
218
|
+
class NotesRichTextStyle < GripWrapper
|
219
|
+
end
|
220
|
+
|
221
|
+
class NotesRichTextTab < GripWrapper
|
222
|
+
end
|
223
|
+
|
224
|
+
# ====================================================
|
225
|
+
# ================= NotesRichTextTable Class ===============
|
226
|
+
# Represents a table in a rich text item.
|
227
|
+
# ====================================================
|
228
|
+
class NotesRichTextTable < GripWrapper
|
229
|
+
end
|
230
|
+
|
231
|
+
class NotesRichTextDocLink < GripWrapper
|
232
|
+
end
|
233
|
+
|
234
|
+
class NotesRichTextNavigator < GripWrapper
|
235
|
+
end
|
236
|
+
|
237
|
+
class NotesRichTextParagraphStyle < GripWrapper
|
238
|
+
end
|
239
|
+
|
240
|
+
class NotesMIMEEntity < GripWrapper
|
241
|
+
end
|
242
|
+
|
243
|
+
class NotesMIMEHeader < GripWrapper
|
244
|
+
end
|
245
|
+
|
246
|
+
class FileSystemObject
|
247
|
+
include Singleton
|
248
|
+
def initialize
|
249
|
+
@body = WIN32OLE.new('Scripting.FileSystemObject')
|
250
|
+
end
|
251
|
+
|
252
|
+
def fullpath(filename)
|
253
|
+
@body.getAbsolutePathName(filename)
|
254
|
+
end
|
255
|
+
end
|
256
|
+
end
|