home *** CD-ROM | disk | FTP | other *** search
- unit OLEReg;
-
- interface
-
- uses WinTypes, WinProcs, Classes, DsgnIntf, Messages, Forms, Proxies;
-
- type
-
- { TOleEditor }
- TOleEditor = class(TDefaultEditor)
- public
- procedure Edit; override;
- procedure ExecuteVerb(Index: Integer); override;
- function GetVerb(Index: Integer): string; override;
- function GetVerbCount: Integer; override;
- procedure Copy; override;
- end;
-
-
- { TOleObjTypeProperty
- Property editor the Ole Class (e.g.Word,Excel) and Ole Doc properties }
-
- TOleObjTypeProperty = class(TPropertyEditor)
- public
- function GetAttributes: TPropertyAttributes; override;
- procedure Edit; override;
- function GetValue: string; override;
- end;
-
-
- { TOleObjItemProperty
- Property editor the TOleItem - i.e. Paste Special Dlg }
-
- TOleObjItemProperty = class(TPropertyEditor)
- public
- function GetAttributes: TPropertyAttributes; override;
- procedure Edit; override;
- function GetValue: string; override;
- end;
-
- TLibOle = class (TLibOleHelper)
- public
- function GetObjectMenuItemCount (Obj : TComponent) :
- Integer; override;
- function GetObjectMenuItem (Obj : TComponent; Index : Integer) :
- String; override;
- procedure ObjectMenuItemAction (Obj : TComponent; Index : Integer);
- override;
- procedure RegisterFormAsDropTarget (Form : TForm);
- override;
- end;
-
- procedure Register;
-
- implementation
-
- uses BoleDefs, BoleIntf, ToCtrl, ToIntf, SysUtils, Dialogs, ToConsts,
- LibConst, Controls, LibHelp;
-
- {---------------------------------------}
- { TOleEditor }
- procedure TOleEditor.Edit;
- begin
- TOleContainer(Component).Active := True;
- end;
-
-
- procedure TOleEditor.ExecuteVerb(Index: Integer);
- begin
- TOleContainer(Component).ObjectMenuAction(Index);
- end;
-
-
- function TOleEditor.GetVerb(Index: Integer): string;
- begin
- Result := TOleContainer(Component).GetObjectMenuItem(Index);
- end;
-
-
- function TOleEditor.GetVerbCount: Integer;
- begin
- Result := TOleContainer(Component).GetObjectMenuItemCount;
- if Result > 2 then
- Result := Result - 2; {remove the convert menu item and spacer}
- end;
-
-
- procedure TOleEditor.Copy;
- begin
- TOleContainer(Component).CopyToClipboard (False);
- end;
-
-
- { TOleObjTypeProperty }
-
- function TOleObjTypeProperty.GetAttributes: TPropertyAttributes;
- begin
- Result := inherited GetAttributes + [paDialog, paReadOnly]
- - [paMultiSelect, paSubProperties];
- end;
-
-
- procedure TOleObjTypeProperty.Edit;
- var
- Ptr : Pointer;
- OleCtrl : TOleContainer;
- begin
- OleCtrl := TOleContainer (GetComponent(0));
- if InsertOleObjectDlg (GetParentForm (OleCtrl),
- THelpContext(hcOleInsertObject), Ptr) = True then
- begin
- if OleCtrl.OleObjAllocated = True then
- begin
- if MessageDlg ( LoadStr(SInitInfo), mtConfirmation, mbOKCancel, 0) <> idOK then
- Exit;
- end;
-
- OleCtrl.PInitInfo := Ptr;
- ReleaseOleInitInfo (Ptr);
- Modified;
- end;
- end;
-
-
- function TOleObjTypeProperty.GetValue: string;
- begin
- if GetStrValue = '' then Result := ''
- else Result := Format ('(%s)', [GetStrValue]);
- end;
-
- {-----------------------------------------}
-
- { TOleObjItemProperty }
-
- function TOleObjItemProperty.GetAttributes: TPropertyAttributes;
- begin
- Result := inherited GetAttributes + [paDialog, paReadOnly]
- - [paMultiSelect, paSubProperties];
- end;
-
-
- procedure TOleObjItemProperty.Edit;
- var
- Ptr : Pointer;
- OleCtrl : TOleContainer;
- begin
- OleCtrl := TOleContainer (GetComponent(0));
- if PasteSpecialOleDlg (GetParentForm (OleCtrl),
- THelpContext (hcOlePasteSpecial), Ptr) = True then
- begin
- if OleCtrl.OleObjAllocated = True then
- begin
- if MessageDlg ( LoadStr(SInitInfo), mtConfirmation, mbOKCancel, 0) <> idOK then
- Exit;
- end;
-
- OleCtrl.PInitInfo := Ptr;
- ReleaseOleInitInfo (Ptr);
- Modified;
- end;
- end;
-
-
- function TOleObjItemProperty.GetValue: string;
- begin
- Result := GetStrValue;
- end;
-
- {-------}
-
- function TLibOle.GetObjectMenuItemCount (Obj : TComponent) :
- Integer;
- begin
- Result := 0;
- if Obj.InheritsFrom (TOleContainer) then
- Result := TOleContainer (Obj).GetObjectMenuItemCount;
- end;
-
-
- function TLibOle.GetObjectMenuItem (Obj : TComponent; Index : Integer) :
- String;
- begin
- Result := EmptyStr;
- if Obj.InheritsFrom (TOleContainer) then
- Result := TOleContainer (Obj).GetObjectMenuItem (Index);
- end;
-
-
- procedure TLibOle.ObjectMenuItemAction (Obj : TComponent; Index : Integer);
- begin
- if Obj.InheritsFrom (TOleContainer) then
- TOleContainer (Obj).ObjectMenuAction (Index);
- end;
-
-
- procedure TLibOle.RegisterFormAsDropTarget (Form : TForm);
- begin
- RegisterFormAsOleDropTarget (Form,
- [OleFormat (BoleroObj.EmbedClipFmt, '%s', '%s', TRUE),
- OleFormat (BoleroObj.LinkClipFmt, '%s', '%s', TRUE)]);
- end;
-
- procedure Register;
- begin
- LibOleHelper := TLibOle.Create;
- RegisterComponents(LoadStr(srSystem), [TOleContainer]);
- RegisterPropertyEditor(TypeInfo(string), TOleContainer, 'ObjClass', TOleObjTypeProperty);
- RegisterPropertyEditor(TypeInfo(string), TOleContainer, 'ObjDoc', TOleObjTypeProperty);
- RegisterPropertyEditor(TypeInfo(string), TOleContainer, 'ObjItem', TOleObjItemProperty);
- RegisterComponentEditor(TOleContainer, TOleEditor);
- end;
-
- end.
-
-