| View previous topic :: View next topic |
| Author |
Message |
PeteS General User

Joined: 12 Feb 2005 Posts: 43
|
Posted: Tue Apr 26, 2005 7:58 am Post subject: Sheet Change Event |
|
|
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 |
|
 |
Cybb20 Super User


Joined: 02 Mar 2004 Posts: 1569 Location: Frankfurt, Germany
|
Posted: Tue Apr 26, 2005 2:38 pm Post subject: |
|
|
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 |
|
 |
SergeM Super User

Joined: 09 Sep 2003 Posts: 3211 Location: Troyes France
|
|
| Back to top |
|
 |
PeteS General User

Joined: 12 Feb 2005 Posts: 43
|
Posted: Wed Apr 27, 2005 6:23 am Post subject: |
|
|
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 |
|
 |
SergeM Super User

Joined: 09 Sep 2003 Posts: 3211 Location: Troyes France
|
|
| Back to top |
|
 |
PeteS General User

Joined: 12 Feb 2005 Posts: 43
|
Posted: Thu Apr 28, 2005 9:21 am Post subject: |
|
|
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 |
|
 |
SergeM Super User

Joined: 09 Sep 2003 Posts: 3211 Location: Troyes France
|
|
| Back to top |
|
 |
|