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

Sheet Change Event

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


Joined: 12 Feb 2005
Posts: 43

PostPosted: Tue Apr 26, 2005 7:58 am    Post subject: Sheet Change Event Reply with quote

Under Tools - Customize - Events, we can specify macros to run when certain events are performed, like Start Application, Open Document, Activate Document.

How about an event (handler/listener?) for when the sheet is changed (like when the user clicks on Sheet2 while Sheet1 is visible)?
Back to top
View user's profile Send private message
Cybb20
Super User
Super User


Joined: 02 Mar 2004
Posts: 1569
Location: Frankfurt, Germany

PostPosted: Tue Apr 26, 2005 2:38 pm    Post subject: Reply with quote

Not sure about that one. A hint of mine (since I don't have the time for it):
Go and search through the IDL Reference for all interfaces that have a "handler" or "listener" in its name.

Good luck for your search.

Christian
_________________
- Knowledge is Power -
Back to top
View user's profile Send private message Send e-mail
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Tue Apr 26, 2005 10:20 pm    Post subject: Reply with quote

Quote:
How about an event (handler/listener?) for when the sheet is changed (like when the user clicks on Sheet2 while Sheet1 is visible)?

I have posted OOoBasic code resolving the last problem. But I am not at home and then haven't my magic file where I keep such references. If you don't find it post again in this thread I will have a look this evening.
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
PeteS
General User
General User


Joined: 12 Feb 2005
Posts: 43

PostPosted: Wed Apr 27, 2005 6:23 am    Post subject: Reply with quote

SergeM, I assume you are talking about the following code:

Code:

Sub EventListenerOn
   'Dim oSheet As Object
   oScalcDocument=ThisComponent
    'oSheet = oScalcDocument.Sheets(0)
   oSheet = ThisComponent.CurrentController.getActiveSheet
   oGroup=oSheet.getCellRangeByName("A1:B5")
   '--- installation of an event listener
   'oListener = createUnoListener("OOO_","com.sun.star.lang.XEventListener")
   oListener = createUnoListener("OOO_","com.sun.star.chart.XChartDataChangeEventListener")
   oGroup.addChartDataChangeEventListener(oListener)
End Sub

Sub EventListenerOff
  oGroup.removeChartDataChangeEventListener(oListener)
End Sub 

Sub OOO_chartDataChanged
   print("OK it works")
End Sub


This works.

It uses XChartDataChangeEventListener for cells, but what about the group of tabs ("Sheet1", "Sheet2", "Sheet3") at the bottom of the screen?
Back to top
View user's profile Send private message
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Wed Apr 27, 2005 8:41 am    Post subject: Reply with quote

No I want to speak of this thread :
Event handler which detect sheet change : http://www.oooforum.org/forum/viewtopic.phtml?t=5135

But there is also :
A thread about event listener with example :
http://www.oooforum.org/forum/viewtopic.phtml?t=4490
Event handler and keypressed http://www.oooforum.org/forum/viewtopic.phtml?t=4390
Listener on a calc cell http://www.oooforum.org/forum/viewtopic.phtml?t=6445
Listener which is fired evry time the cell changes http://www.oooforum.org/forum/viewtopic.phtml?t=6773
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
PeteS
General User
General User


Joined: 12 Feb 2005
Posts: 43

PostPosted: Thu Apr 28, 2005 9:21 am    Post subject: Reply with quote

Thanks for your help SergeM. Here is the code I ended up using for handling an Active Sheet Change (in case anyone is curious):

Code:

Global oListener As Object
Global oScalcDocument As Object

Sub SheetEventListenerOff
   oScalcDocument.CurrentController.removePropertyChangeListener("ActiveSheet",oListener)
End Sub

Sub SheetEventListenerOn
   oScalcDocument=ThisComponent
   'oListener = createUnoListener("OOO_","com.sun.star.lang.XEventListener")
   oListener = createUnoListener("OOO_","com.sun.star.beans.XPropertyChangeListener")
   oScalcDocument.CurrentController.addPropertyChangeListener("ActiveSheet",oListener)
End Sub

Sub OOO_propertyChange(oEvent)
   'Sheet = thisComponent.getSheets().getByName(destsheetname)
   if ThisComponent.CurrentController.getActiveSheet.Name = "Report Entry" then
      'view = normal
      ViewNormal
   else
      'view = page break preview
      ViewPageBreakPreview
   end if
End Sub
Back to top
View user's profile Send private message
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Fri Apr 29, 2005 8:05 am    Post subject: Reply with quote

Thank you for the code. Smile
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
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