| View previous topic :: View next topic |
| Author |
Message |
corbpm Newbie

Joined: 27 Jun 2005 Posts: 3
|
Posted: Mon Dec 12, 2005 9:05 am Post subject: Checking whether a document is visible |
|
|
Any one know how to find out if a document is actually visible, what i want to do is loop through any open documents and close them if they are hidden
any hints will be appreciated
Following snippet in Delphi tells me there are OOobjects there
FDesktop := FOpenOffice.createInstance('com.sun.star.frame.Desktop');
FDispatcher := FOpenOffice.createInstance('com.sun.star.frame.DispatchHelper') ;
tVal:=FDesktop.Frames.GetbyIndex(0);
ShowMessage(IntToStr(FDesktop.Frames.GetCount - 1)); ************
The idea is for clean up code, if the program is restarted and finds hidden documents it closes them BUT not visible documents. I have read elsewhere here that u cannot make the document visible if it was created/opened hidden which would have been preferred .
Doesn't have to be delphi code, just would like a pointer on how to do it plz |
|
| Back to top |
|
 |
pitonyak Administrator


Joined: 09 Mar 2004 Posts: 3622 Location: Columbus, Ohio, USA
|
Posted: Mon Dec 12, 2005 9:29 am Post subject: |
|
|
I do not really understand what you mean by hidden, but have you inspected things such as the frame or the component window?
| Code: | | ThisComponent.getcurrentController().getFrame().getComponentWindow() |
I have not checked to see what these things really mean, but they probably do NOT tell you what you want to know, but it might give you a starting point...
| Code: | 'Print ThisComponent.getCurrentController().getFrame().isActive()
'Print ThisComponent.getCurrentController().getFrame().isTop()
'Print ThisComponent.getCurrentController().getFrame().isHidden
Inspect(ThisComponent.getCurrentController().getFrame().getContainerWindow().isVisible())
Inspect(ThisComponent.getCurrentController().getFrame().getComponentWindow())
BOOL isActive ( void )
BOOL isChild ( OBJECT )
BOOL isDesignMode ( void )
BOOL isEnabled ( void )
BOOL isFloating ( void )
BOOL isInPopupMode ( void )
BOOL isVisible ( void ) |
_________________ --
Andrew Pitonyak
http://www.pitonyak.org/oo.php |
|
| Back to top |
|
 |
corbpm Newbie

Joined: 27 Jun 2005 Posts: 3
|
Posted: Tue Dec 13, 2005 12:51 am Post subject: |
|
|
Thanks for the suggestion will try them out today
By hidden i meant the following
Params := VarArrayCreate([0,2], VarVariant);
Params[0] := MakePropertyValue('AsTemplate',True);
Params[1] := MakePropertyValue('Hidden',True);
Params[2] := MakePropertyValue('ReadOnly',ReadOnly);
Template := FormatFilename( Template ) ;
tDoc := FDesktop.loadComponentFromURL( Template,'_blank',0,Params );
Srry for the Delphi code again |
|
| Back to top |
|
 |
corbpm Newbie

Joined: 27 Jun 2005 Posts: 3
|
Posted: Tue Dec 13, 2005 3:59 am Post subject: |
|
|
// This seems to work for any1 who's interested
FDesktop := FOpenOffice.createInstance('com.sun.star.frame.Desktop');
For iCount:=FDesktop.Frames.GetCount - 1 downto 0 do
begin
// Get the frame
tVal:=FDesktop.Frames.GetbyIndex(iCount);
// Is active no help as only the topmost visible is active
tVal2:=tVal.IsActive;
// Get the container window and find the size
tVal3:=tVal.GetContainerWindow.GetPosSize;
// The window size is Zero , probably hidden ???
// So Get rid
if tVal3.Width=0 then
begin
tVal.Close( True ) ;
end;
end; |
|
| Back to top |
|
 |
|