Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

/MacBase/NSAttributedString document attributes
Required plugins for this example: MBS MacBase Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacBase/NSAttributedString document attributes
This example is the version from Sun, 17th Mar 2012.
Project "NSAttributedString document attributes.rbp"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
EventHandler Sub Open() dim f as FolderItem = SpecialFolder.Desktop.Child("test.doc") dim b as BinaryStream = f.OpenAsBinaryFile(false) dim s as string = b.Read(b.Length) dim d as Dictionary dim n as NSAttributedStringMBS = NSAttributedStringMBS.attributedStringWithDocFormat(s,d) list.AddRow "Title", d.lookup(n.NSTitleDocumentAttribute, "") list.AddRow "Company", d.lookup(n.NSCompanyDocumentAttribute, "") list.AddRow "Copyright", d.lookup(n.NSCopyrightDocumentAttribute, "") list.AddRow "Subject", d.lookup(n.NSSubjectDocumentAttribute, "") list.AddRow "Author", d.lookup(n.NSAuthorDocumentAttribute, "") list.AddRow "Keywords", getstringArray(d, n.NSKeywordsDocumentAttribute) list.AddRow "Comment", d.lookup(n.NSCommentDocumentAttribute, "") list.AddRow "Editor", d.lookup(n.NSEditorDocumentAttribute, "") list.AddRow "CreationTime", getdate(d, n.NSCreationTimeDocumentAttribute) list.AddRow "ModificationTime", getdate(d, n.NSModificationTimeDocumentAttribute) // last save date End EventHandler
Function getdate(d as Dictionary, key as Variant) As string dim v as Variant = d.Lookup(key, nil) if v isa date then dim da as date = v Return da.SQLDateTime end if End Function
Function getstringArray(d as Dictionary, key as Variant) As string dim v as Variant = d.Lookup(key, nil) if v.IsArray then dim a(-1) as Variant = v dim s(-1) as string for each n as string in a s.Append n next Return Join(s, ", ") end if End Function
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
Module Module1
Sub AddRow(extends l as listbox, n1 as string, n2 as string) // only for older RB Version l.AddRow n1 l.Cell(l.LastIndex,1) = n2 End Sub
End Module
End Project

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS MacBase Plugin.

MBS Xojo Chart Plugins