OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Checking whether a document is visible

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
corbpm
Newbie
Newbie


Joined: 27 Jun 2005
Posts: 3

PostPosted: Mon Dec 12, 2005 9:05 am    Post subject: Checking whether a document is visible Reply with quote

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
View user's profile Send private message
pitonyak
Administrator
Administrator


Joined: 09 Mar 2004
Posts: 3655
Location: Columbus, Ohio, USA

PostPosted: Mon Dec 12, 2005 9:29 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website AIM Address
corbpm
Newbie
Newbie


Joined: 27 Jun 2005
Posts: 3

PostPosted: Tue Dec 13, 2005 12:51 am    Post subject: Reply with quote

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
View user's profile Send private message
corbpm
Newbie
Newbie


Joined: 27 Jun 2005
Posts: 3

PostPosted: Tue Dec 13, 2005 3:59 am    Post subject: Reply with quote

// 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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group