IServerDocument interface

Overview 
The IServerDocument interface represents the document container. Each IServerDocument interface is a document container made up of views of the same kind. 
A view can be a design document form or a panel form. 
Every document editor server (encapsulated by the IServerModule interface) that supports creation of documents will have a IServerDocument interface.

The IServerDocument interface hierarchy is as follows;

IServerDocument Methods and Properties Table

IServerDocument 
methods 
AddView
SetModified
SetIsShown
SetBeingClosed
Focus
DoFileLoad
DoFileSave
SupportsReload
GetCanClose
GetCount
GetFileName
SetFileName
GetKind
GetModified
GetIsShown
GetBeingClosed
GetFileModifiedDate
UpdateModifiedDate
GetServerModule
GetView
GetViewByName
NotifyViews
GetSupportsOwnSave
GetContextHelpTopicName
SetFileModifiedDate
WarnIfOwnedByOther
AcquireFileOwnership
ReleaseFileOwnership
ReleaseDataFileHandle
AcquireDataFileHandle
OwnsFile
DoSafeFileSave
DoSafeChangeFileNameAndSave
CreateSnippetFile
ZoomSnippetContents
GetSnippetView
PlaceSnippet
CanPlaceSnippet
CanCreateSnippet

IServerDocument 
properties 
CanClose
Count
FileName
Kind
Modified
IsShown
BeingClosed
ServerModule
View
SupportsOwnSave

IServerDocument example

 

Procedure  OpenAndShowADocument(Filename  :  TDynamicString);
Var
  ReportDocument  :  IServerDocument;
Begin
  If  Client  =  Nil  Then  Exit;
  ReportDocument  :=  Client.OpenDocument('Text',FileName);
  If  ReportDocument  <>  Nil  Then
  Client.ShowDocument(ReportDocument);
End;

 

See also 
IClient interface
IServerDocumentView interface
IServerView interface
CS server example in the \Developer Kit\Examples\DXP\ClientServer Interfaces\ folder.

IServerDocument Methods

AddView method

(IServerDocument interface)
Syntax 
Procedure AddView (Const AView : IServerDocumentView);
Description 
This procedure adds a IServerDocumentView object in the server document. A IServerDocument object is a container containing views of document views and panel views.
Example

See also 
IServerDocument interface
IServerDocumentView interface

DoFileLoad method

(IServerDocument interface)
Syntax 
Function DoFileLoad : LongBool;
Description 
This function allows the re-loading of the document. This is useful if the document has been modified and saved and it needs to be re-loaded to ensure that the document is in the latest state.
Example

See also 
IServerDocument interface

DoFileSave method

(IServerDocument interface)
Syntax 
Function DoFileSave (Const AKind : Widestring) : LongBool;
Description 
This function provides you an option to save the document in a different format if the document supported by the specific document editor provides the option of saving in a different format other than the default format. Normally these file formats are stored in the SaveFilters block within the EditorWindowKind section within a server installation file (with an INS extension).
File Formats 
For example with PCB documents in Altium Designer, you can save them as a PCB ASCII format, PCB Binary 3 format etc - PCB Binary, PCB 3.0 Binary, PCB 4.0 Binary, PCB ASCII. By default its PCB Binary 5.0.
With Schematic documents, you can save them as a Advanced Schematic binary, Advanced Schematic ascii, Schematic binary 4.0, Orcad SDT Schematic, Advanced Schematic template.

Server Installation files 
The file formats supported by editors can be found in the server installation files within the SaveFilters - End blocks.

DelphiScript Example

 

Var
  Board  :  IPCB_Document;
  AView  :  IServerDocumentView;
  AServerDocument  :  IServerDocument;
Begin
  //  save  the  file  in  a  different  PCB  format
  //check  if  current  document  is  a  PCB  document  otherwise  exit!
  Board  :=  PCBServer.GetCurrentPCBBoard;
  If  Board  =  Nil  Then  Exit;
  If  Client  =  Nil  Then  Exit;
 
  //  Grab  the  current  document  view  using  the  Client's  Interface.
  AView  :=  Client.GetCurrentView;
  AServerDocument  :=  AView.OwnerDocument;
  AServerDocument.DoFileSave('PCB  ASCII');
  Close;
End;

 

See also 
IServerDocument interface
IServerDocument interface
GetCanClose method
GetModified method
GetFileName method

Focus method

(IServerDocument interface)
Syntax 
Procedure Focus;
Description 
The procedure forces the document to be the focussed document in Altium Designer. A focussed document is the top level document and in view in Altium Designer workspace that responds to commands etc.
Example

See also 
IServerDocument interface

GetBeingClosed method

(IServerDocument interface)
Syntax 
Function GetBeingClosed : LongBool;
Description 
The function determines whether the server document is being closed or not. Use the GetCanClose function to check if the document can be closed or not.
Example

See also 
IServerDocument interface
GetCanClose method
GetModified method
GetFileName method
DoFileSave method

GetCanClose method

(IServerDocument interface)
Syntax 
Function GetCanClose : LongBool;
Description 
This function checks whether the document can be closed or not. This method is used for the CanClose property.
Example

See also 
IServerDocument interface
GetModified method
GetFileName method
DoFileSave method

GetContextHelpTopicName method

(IServerDocument interface)
Syntax 
Function GetContextHelpTopicName : Widestring;
Description 
The GetContextHelpTopicName function retrieves the help topic name for the document. Normally the returned string would be the ServerModuleName.DocumentKind format for example 'SCH.SCH' Some servers provide more detailed information, for example Schematic Editor server returns Sch.Sheet.Port when the mouse is over the Port object on a schematic sheet.
Notes 
Third party developers can use this function to provide context sensitive help.
To implement the help for your server, you should have a .HELPID file in the Help folder where the link between the string returned by the GetContextHelpTopicName and the actual help document is established.
For example the CXTSystemDesignCapture.HelpID contains a Sch.Sheet.Port = CXTSystemDesignCapture.chm,Document_Objects\Port.htm. This means when the F1 key is pressed and the Sch.Sheet.Port string is returned, it will use the CXTSystemDesignCapture.chm filename and display the Document_Objects\Port.htm topic.
Example

See also 
IServerDocument interface

GetCount method

(IServerDocument interface)
Syntax 
Function GetCount : Integer;
Description 
The Count property returns the number of views (of the same type) in the IServerDocument container. Use in conjunction with the View property.
This method is used for the Count property.
Example

 

Var
  ServerModule  :  IServerModule;
  ServerDocument  :  IServerDocument;
  ServerDocumentView  :  IServerDocumentView;
Begin
ServerModule  :=  Client.ServerModuleByName['PCB'];
If  ServerModule  =  Nil  Then  Exit;
   
For  I  :=  0  to  ServerModule.DocumentCount  -  1  Do
Begin
  ServerDocument  :=  ServerModule.Documents[I];
  ShowMessage('Document  View  Count  ' 
  IntToStr(ServerDocument.Count)  +  #13  +
  'Kind  '  +  ServerDocument.Kind));
End;
End;

 

See also 
IServerDocument interface

GetFileModifiedDate method

(IServerDocument interface)
Syntax 
Function GetFileModifiedDate: TDateTime;
Description 
This function returns the date and time of the modified file.
Example

See also 
IServerDocument interface
GetFileModifiedDate method
SetFileModifiedDate method
TDateTime type from Borland Delphi Run Time Library.

GetFileName method

(IServerDocument interface)
Syntax 
Function GetFileName : Widestring;
Description 
This function retrieves the file name as a string for the server document. Note a server document can be a document view or a panel view, and thus if it is a panel view, the GetFileName method is invalid.
Example

 

ServerDocumentView  :=  ServerDocument.View[j];
If  Not(ServerDocumentView.IsPanel)  Then 
  ShowMessage('  Document  Name  ' 
  ServerDocument.FileName);

 

See also 
IServerDocument interface

GetIsShown method

(IServerDocument interface)
Syntax 
Function GetIsShown : LongBool;
Description 
The IsShown property denotes whether or not this document is displayed in Altium Designer. This property is supported by the GetIsShown and SetIsShown methods.
Example

See also 
IServerDocument interface

GetKind method

(IServerDocument interface)
Syntax 
Function GetKind : Widestring;
Description 
This function returns the Kind string for this document and this function is used for the Kind property. Examples include 'PCB', 'PCBLIB','SCH','SCHLIB' etc.

Example

 

ServerModule  :=  Client.ServerModuleByName['PCB'];
If  ServerModule  =  Nil  Then  Exit;
   
For  I  :=  0  to  ServerModule.DocumentCount  -  1  Do
Begin
  ServerDocument  :=  ServerModule.Documents[I];
  ShowMessage('Document  View  Count  ' 
  IntToStr(ServerDocument.Count)  +  #13  +
  'Kind  '  +  ServerDocument.GetKind));
End;

 

See also 
IServerDocument interface

GetModified method

(IServerDocument interface)
Syntax 
Function GetModified : LongBool;
Description 
The Modified property denotes whether this document has been modified or not, and can be taken as a "dirty" flag, that is a document has been modified and it has been marked dirty.
This property is supported by the GetModified and SetModified methods.
Example

 

Var
  AView  :  IServerDocumentView;
  AServerDocument  :  IServerDocument;
Begin
  If  Client  =  Nil  Then  Exit;
  //  Grab  the  current  document  view  using  the  Client's  Interface.
  AView  :=  Client.GetCurrentView;
 
  //  Grab  the  server  document  which  stores  views  by  extracting  the  ownerdocument  field.
  AServerDocument  :=  AView.OwnerDocument;
 
  //  Set  the  document  dirty.
  AServerDocument.Modified  :=  True;
End;

 

See also 
IServerDocument interface

GetServerModule method

(IServerDocument interface)
Syntax 
Function GetServerModule : IServerModule;
Description 
The ServerModule is a read-only property which returns the IServerModule interface that the document is associated with. The server module represents the server object installed and running in Altium Designer.
A server module manages its own documents and panels. This property is supported by the GetServerModule method.
Example

 

//IServerModule  interface
ServerModule  :=  Client.ServerModuleByName['PCB'];
If  ServerModule  =  Nil  Then  Exit;
 
ShowMessage(IntToStr(ServerModule.DocumentCount));
For  I  :=  0  to  ServerModule.DocumentCount  -  1  Do
Begin
  //IServerDocument  interface
  ServerDocument  :=  ServerModule.Documents[I];
  //  do  what  you  want  with  server  documents
End;

 

See also 
IServerDocument interface
IServerModule interface

GetSupportsOwnSave method

(IServerDocument interface)
Syntax 
Function GetSupportsOwnSave : LongBool;
Description 
The SupportsOwnSave property returns a boolean value whether a save routine has been provided to save these documents associated with the server. This is a read only property and is supported by the GetSupportsOwnSave method.
Example

See also 
IServerDocument interface

GetView method

(IServerDocument interface)
Syntax 
Function GetView (Index : Integer) : IServerDocumentView;

Description 
The View property is an indexed property and represents a document or panel view. The IServerDocument.Count method returns the list of views (which could be document or panel windows) as part of the IServerDocument container.
This property is supported by the GetView method.

Example

 

For  J  :=  0  to  ServerDocument.Count  -  1  Do
Begin
  ServerDocumentView  :=  ServerDocument.View[j];
  ShowMessage('View  Name  '  +  ServerDocumentView.ViewName);
 
  If  Not(ServerDocumentView.IsPanel)  Then 
  ShowMessage('  Document  Name  '  +
  ServerDocument.FileName);
End;

 

See also 
IServerDocument interface

GetViewByName method

(IServerDocument interface)
Syntax 
Function GetViewByName (Const ViewName : Widestring) : IServerDocumentView;
Description 
The GetViewByName function returns the View object which represents a document or panel view.
Example

 

ServerDocumentView  :=  ServerDocument.GetViewByName(PCBExpressionFilter);
If  ServerDocumentView.IsPanel  Then 
  ShowMessage('This  Server  Document  View  is  a  Panel');

 

See also 
IServerDocument interface
IServerDocumentView interface

SetBeingClosed method

(IServerDocument interface)
Syntax 
Procedure SetBeingClosed (Const Value : LongBool);
Description 
The BeingClosed property denotes that this design document is being closed before this design document can be successfully destroyed. This property is a read only property. You can check the status of the document before you attempt to modify or update the document before it is being closed.
This property is supported by the GetBeingClosed and SetBeingClosed methods.
Example

See also 
IServerDocument interface

SetFileModifiedDate method

(IServerDocument interface)
Syntax 
Procedure SetFileModifiedDate(Const AValue : TDateTime);
Description 
The procedure sets the modified date for the document if the document has been modified by an outside agent.
Example

See also 
IServerDocument interface
GetModified method
SetModified method
SetFileName method 
(IServerDocument interface)
Syntax 
Function SetFileName (Const AFileName : Widestring): Widestring;
Description 
The SetFileName function sets the filename for the document.
Example

See also 
IServerDocument interface

SetIsShown method

(IServerDocument interface)
Syntax 
Procedure SetIsShown (Const Value : LongBool);
Description 
The IsShown property denotes whether or not this document is displayed in Altium Designer. This property is supported by the GetIsShown and SetIsShown methods.
Example

See also 
IServerDocument interface

SetModified method

(IServerDocument interface)
Syntax 
Procedure SetModified (Const Value : LongBool);
Description 
The Modified property denotes whether this document has been modified or not, and can be taken as a "dirty" flag, that is a document has been modified and it has been marked dirty.
This property is supported by the GetModified and SetModified methods.
Example

 

Var
  AView  :  IServerDocumentView;
  AServerDocument  :  IServerDocument;
Begin
  If  Client  =  Nil  Then  Exit;
  //  Grab  the  current  document  view  using  the  Client's  Interface.
  AView  :=  Client.GetCurrentView;
 
  //  Grab  the  server  document  which  stores  views  by  extracting  the  ownerdocument  field.
  AServerDocument  :=  AView.OwnerDocument;
 
  //  Set  the  document  dirty.
  AServerDocument.Modified  :=  True;
End;

 

See also 
IServerDocument interface

NotifyViews method

(IServerDocument interface)
Syntax 
Procedure NotifyViews (ANotification : INotification);
Description 
This procedure sends a notification to all the views associated with the IServerDocument container.
Example

See also 
IServerDocument interface
INotification interface

SupportsReload method

(IServerDocument interface)
Syntax 
Function SupportsReload : LongBool;
Description 
This method determines whether the document in Altium Designer can be re loaded or not (to refresh and to make sure that the document state is the latest).
Example

See also 
IServerDocument interface
DoFileLoad method

UpdateModifiedDate method

(IServerDocument interface)
Syntax 
Procedure UpdateModifiedDate;
Description 
The procedure updates the modified document's date after this document has been modified.
Example

See also 
IServerDocument interface
GetModified method

SetModified method

ReleaseFileOwnership method

(IServerDocument interface)
Syntax 
Procedure ReleaseFileOwnership;
Description 
For internal use only.
Example

See also 
IServerDocument interface

ReleaseDataFileHandle method

(IServerDocument interface)
Syntax 
Procedure ReleaseDataFileHandle;
Description 
For internal use only.
Example

See also 
IServerDocument interface

OwnsFile method

(IServerDocument interface)
Syntax 
Function OwnsFile : Boolean;
Description 
The OwnsFile function determines whether the document is owned by the Altium Designer product and thus this document can be saved or not.
Example

See also 
IServerDocument interface

DoSafeFileSave method

(IServerDocument interface)
Syntax 
Function DoSafeFileSave (Const AKind : Widestring) : LongBool;
Description 
The function determines whether the document can be saved of specified document type safely.
Example

See also 
IServerDocument interface

DoSafeChangeFileNameAndSave method

(IServerDocument interface)
Syntax 
Function DoSafeChangeFileNameAndSave(Const ANewFileName, AKind : Widestring) : LongBool;
Description 
The function determines whether the current document can be saved with the new file name and new document type or not.
Example

See also 
IServerDocument interface

AcquireFileOwnership method

(IServerDocument interface)
Syntax 
Procedure AcquireFileOwnership;
Description 
For internal use only.
Example

See also 
IServerDocument interface

AcquireDataFileHandle method

(IServerDocument interface)
Syntax 
Procedure AcquireDataFileHandle;
Description 
For internal use only.
Example

See also 
IServerDocument interface

WarnIfOwnedByOther method

(IServerDocument interface)
Syntax 
Function WarnIfOwnedByOther(AWarningLevel : TFileOwnershipWarningLevel) : LongBool;
Description 
This function determines whether the document is owned by another user. A document can be shared amongst other users but the other users cannot save this document when this document is owned solely by one user.
Example

See also 
IServerDocument interface

IServerDocument Properties

BeingClosed property

(IServerDocument interface)
Syntax 
Property BeingClosed : LongBool Read GetBeingClosed Write SetBeingClosed;
Description 
The BeingClosed property denotes that this design document is being closed before this design document can be successfully destroyed. This property is a read only property. You can check the status of the document before you attempt to modify or update the document before it is being closed.
This property is supported by the GetBeingClosed and SetBeingClosed methods.
Example

See also 
IClient interface
IServerDocument interface

CanClose property

(IServerDocument interface)
Syntax 
Property CanClose : LongBool Read GetCanClose;
Description 
This CanClose property determines whether the document can be closed or not.
Example

See also 
IClient interface
IServerDocument interface

Count property

(IServerDocument interface)
Syntax 
Property Count : Integer Read GetCount;
Description 
The Count property returns the number of views (of the same type) in the IServerDocument container. Use in conjunction with the View property.
This property is supported by the GetCount method.
Example

 

Var
  ServerModule  :  IServerModule;
  ServerDocument  :  IServerDocument;
  ServerDocumentView  :  IServerDocumentView;
Begin
ServerModule  :=  Client.ServerModuleByName['PCB'];
If  ServerModule  =  Nil  Then  Exit;
   
For  I  :=  0  to  ServerModule.DocumentCount  -  1  Do
Begin
  ServerDocument  :=  ServerModule.Documents[I];
  ShowMessage('Document  View  Count  ' 
  IntToStr(ServerDocument.Count)  +  #13  +
  'Kind  '  +  ServerDocument.Kind));
End;
End;

 

See also 
IClient interface
IServerDocument interface

Filename property

(IServerDocument interface)
Syntax 
Property FileName : Widestring Read GetFileName;
Description 
The FileName property returns the filename for the server document (not the corresponding server panel). This property is a read-only property and is supported by the GetFileName method.
Note a server document can be a document view or a panel view, and thus if it is a panel view, the FileName property is invalid.

Example

 

ServerDocumentView  :=  ServerDocument.View[j];
If  Not(ServerDocumentView.IsPanel)  Then 
  ShowMessage('  Document  Name  ' 
  ServerDocument.FileName);

 

See also 
IClient interface
IServerDocument interface

IsShown property

(IServerDocument interface)
Syntax 
Property IsShown : LongBool Read GetIsShown Write SetIsShown;
Description 
This property denotes whether or not this document is displayed in Altium Designer. This property is supported by the GetIsShown and SetIsShown methods.
Example

See also 
IClient interface
IServerDocument interface

Kind property

(IServerDocument interface)
Syntax 
Property Kind : Widestring Read GetKind;
Description 
The Kind reports the type of the document opened in Altium Designer. 
Examples include 'PCB', 'PCBLIB','SCH','SCHLIB' etc. This property is a read-only property. This property is supported by the GetKind method.
Example

 

ServerModule  :=  Client.ServerModuleByName['PCB'];
If  ServerModule  =  Nil  Then  Exit;
   
For  I  :=  0  to  ServerModule.DocumentCount  -  1  Do
Begin
  ServerDocument  :=  ServerModule.Documents[I];
  ShowMessage('Document  View  Count  ' 
  IntToStr(ServerDocument.Count)  +  #13  +
  'Kind  '  +  ServerDocument.Kind));
End;

 

See also 
IClient interface
IServerDocument interface

Modified property

(IServerDocument interface)
Syntax 
Property Modified : LongBool Read GetModified Write SetModified;
Description 
The Modified property denotes whether this document has been modified or not, and can be taken as a "dirty" flag, that is a document has been modified and it has been marked dirty.
This property is supported by the GetModified and SetModified methods.
Example 
Var
AView : IServerDocumentView;
AServerDocument : IServerDocument;
Begin
If Client = Nil Then Exit;
// Grab the current document view using the Client's Interface.
AView := Client.GetCurrentView;

// Grab the server document which stores views by extracting the ownerdocument field.
AServerDocument := AView.OwnerDocument;

// Set the document dirty.
AServerDocument.Modified := True;
End;
See also 
IClient interface
IServerDocument interface

ServerModule property

(IServerDocument interface)
Syntax 
Property ServerModule : IServerModule Read GetServerModule;
Description 
The ServerModule is a read-only property which returns the IServerModule interface that the document is associated with. The server module represents the server object installed and running in Altium Designer.
A server module manages its own documents and panels. This property is supported by the GetServerModule method.
Example

 

//IServerModule  interface
ServerModule  :=  Client.ServerModuleByName['PCB'];
If  ServerModule  =  Nil  Then  Exit;
 
ShowMessage(IntToStr(ServerModule.DocumentCount));
For  I  :=  0  to  ServerModule.DocumentCount  -  1  Do
Begin
  //IServerDocument  interface
  ServerDocument  :=  ServerModule.Documents[I];
  //  do  what  you  want  with  server  documents
End;

 

See also 
IClient interface
IServerDocument interface
IServerModule interface

SupportsOwnSave property

(IServerDocument interface)
Syntax 
Property SupportsOwnSave : LongBool Read GetSupportsOwnSave;
Description 
The SupportsOwnSave property returns a boolean value whether a save routine has been provided to save these documents associated with the server. Read only property.
Example

See also 
IClient interface
IServerDocument interface

View property

(IServerDocument interface)
Syntax 
Property View Integer : IServerDocumentView Read GetView;
Description 
The View property is an indexed property and represents a document or panel view part of the IDocument container associated with a specific IServerModule interface. The IServerDocument.Count method returns the list of views (which could be document or panel windows) as part of the IServerDocument container.
This property is supported by the GetView method.
Example

For  J  :=  0  to  ServerDocument.Count  -  1  Do
Begin
  ServerDocumentView  :=  ServerDocument.View[j];
  ShowMessage('View  Name  '  +  ServerDocumentView.ViewName);
 
  If  Not(ServerDocumentView.IsPanel)  Then 
  ShowMessage('  Document  Name  '  +
  ServerDocument.FileName);
End;

 

See also 
IClient interface
IServerDocument interface

If you find an issue, select the text/image and pressCtrl + Enterto send us your feedback.