上一次我们提到,Database icon 文档里面包含很多数据库属性信息。实际上它们都保存在 $Flags 域中,而这个域中每个字符都代表一个属性,列表如下(来源于 Notes C API 中的 stdnames.h 文件):

Flag = Meaning / Action
4 = Allow Soft Deletes
Z = Enable LZ1 Compression
f = Do Not Allow Stored Forms
z = Do Not Maintain Unread Marks
h = Mark Parent Document on Reply or Forward
J = Use JavaScript when generating Web Pages
F = Launch Designated Frameset
n = Never Show Policy (ie. Never show About Database when first opened)
7 = Large UNK Table (ie. allow more fields in database)
6 = Allow Design Locking
K = Restore as lasted viewed by user
c = Show About Database if Modified
Q = Replicate Unread Marks to Clustered Servers Only
U = Replicate Unread Marks to All Servers (appears with Q set)
2 = Optimise Document Table Bitmap
3 = Maintain LastAccessed Property
1 = Don’t Support Specialised Response Hierarchy
M = Multilingual Database
X = Web Access Requires SSL Connection
8 = Web Access Don’t Allow URL Open
i = Display Images After Loading
5 = Allow Document Locking
g = Database Type = Library
j = Database Type = Personal Journal
b = Database Type = Domino Directory
B = Database Type = Directory Catalog
m = Database Type = Multi DB Search
u = Database Type = Portfolio
A = Database Type = Mailbox
r = Database Type = Mailfile
p = Always Show About Database Document (ie. When Opened in the Client Property)
l = Launch Designated Navigator
s = Launch Designated Navigator in Own Window (used in conjuction with l above)
a = Launch First Attachment in About Database Document
d = Launch First DocLink in About Database Document
P = Web Launch = Show About Database Document
S = Web Launch = Open Designated Frameset
E = Web Launch = Open Designated Page
L = Web Launch = Open Designated Navigator in its Own Window
D = Web Launch = Open First DocLink in About Database Document
T = Web Launch = Open Designated DocLink
V = Web Launch = Open First Document in Designated View

通过向这个域中增加(或除去)字符标记,即可设置(或取消)相应的属性。下面是一段具体的代码:

Set doc = db.GetDocumentByID(“FFFF0010”) ‘获得 Icon 文档
doc.~$Flags = doc.~$Flags(0) & “x” ‘x代表需要增加的属性
doc.Save (True, False)

数据库中的一些特殊元素,他们有着固定的 Note ID。如下表:

Note ID Database Element
FFFF0002 “About This Database” document
FFFF0004 Default form
FFFF0008 Default view
FFFF0010 Database icon
FFFF0020 Database Design Collection (view)
FFFF0040 Database ACL
FFFF0100 “Using This Database” document
FFFF0800 Replication Formul

比如通过 db.GetDocumentByID(“FFFF0010”) 即可获得 Database icon 文档。而这个文档中保存了很多数据库属性信息,也就是说我们可以通过编程来修改这些数据库属性。是不是有点意思了呢?

请参考 Getting Default Elements in the Database

一般情况下,视图都是用来显示文档的。实际上通过更改视图 $FormulaClass 的值,我们可以让它显示其他的内容。参照下表:

Note Class Type Hex Value Decimal Value Comments
NOTE_CLASS_DOCUMENT 0x0001 1 document note
NOTE_CLASS_INFO 0x0002 2 notefile info (help-about) note
NOTE_CLASS_FORM 0x0004 4 form note
NOTE_CLASS_VIEW 0x0008 8 view note
NOTE_CLASS_ICON 0x0010 16 icon note
NOTE_CLASS_DESIGN 0x0020 32 design note collection
NOTE_CLASS_ACL 0x0040 64 acl note
NOTE_CLASS_HELP_INDEX 0x0080 128 Notes product help index note
NOTE_CLASS_HELP 0x0100 256 designer’s help note
NOTE_CLASS_FILTER 0x0200 512 filter note
NOTE_CLASS_FIELD 0x0400 1024 field note
NOTE_CLASS_REPLFORMULA 0x0800 2048 replication formula
NOTE_CLASS_PRIVATE 0x1000 4096 Private design note, use $PrivateDesign view to locate/classify
NOTE_CLASS_DEFAULT 0x8000 32,768 MODIFIER – default version of each
NOTE_CLASS_ALL 0x7fff 32,767 all note types
NOTE_CLASS_ALLNONDATA 0x7ffe 32,766 all non-data notes
NOTE_CLASS_NONE 0x0000 0 no notes

比如我们一般的视图,$FormulaClass 的值为1,所以显示一般文档 ;如果是4,则显示所有表单设计元素(实际上,每个设计元素都可以说是一种特殊的文档)。另外还可以这样用:如果将 $FormulaClass 的值指定为 1548(4 + 8 + 512 + 1024),则可以同时显示表单、视图等几种设计元素。

修改 $FormulaClass 域的方法,可以通过类似如下的代码实现:

Set view= db.GetView(“FormView”)
Set doc = db.GetDocumentByUNID(view.UniversalID)
Call doc.ReplaceItemValue(“$FormulaClass”, “4”)

至于这样的视图有什么用,就要看自己的想像力了。比如创建一个包含所有设计元素的视图,就可以通过名字来查找设计元素文档了。

请参考 Modifying $FormulaClass in ViewsFun with $FormulaClass