Difference between revisions of "Documentation/DevGuide/Charts/Chart Document Controller"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (FINAL VERSION FOR L10N)
Line 16: Line 16:
 
With a call to <code>lockControllers()</code> all registered controllers will no longer be notified about changes in the model.  If there are changes those are notified no earlier than after calling <code>unlockControllers()</code>.  This is especially useful if you do many changes to the chart model at a time but do not need the view to be updated after every single change.  The method <code>hasControllersLocked()</code> just gives you the state whether controllers are locked or not.
 
With a call to <code>lockControllers()</code> all registered controllers will no longer be notified about changes in the model.  If there are changes those are notified no earlier than after calling <code>unlockControllers()</code>.  This is especially useful if you do many changes to the chart model at a time but do not need the view to be updated after every single change.  The method <code>hasControllersLocked()</code> just gives you the state whether controllers are locked or not.
  
{{Documentation/Note| You can nest calls to <tt>lockControllers()</tt>.  Every call to <tt>lockControllers()</tt> needs a corresponding <tt>unlockControllers()</tt> call. Only after the correct number of unlocking calls, notifications of the model will be sent again.  So, you can safely lock and unlock the controllers in your code without having to check if they have already been locked or not. Just make sure that you call both methods and do not leave the controllers in a locked state after your code finishes.}}
+
{{Note| You can nest calls to <tt>lockControllers()</tt>.  Every call to <tt>lockControllers()</tt> needs a corresponding <tt>unlockControllers()</tt> call. Only after the correct number of unlocking calls, notifications of the model will be sent again.  So, you can safely lock and unlock the controllers in your code without having to check if they have already been locked or not. Just make sure that you call both methods and do not leave the controllers in a locked state after your code finishes.}}
  
 
{{PDL1}}
 
{{PDL1}}
  
 
[[Category:Documentation/Developer's Guide/Charts]]
 
[[Category:Documentation/Developer's Guide/Charts]]

Revision as of 16:23, 3 July 2018



The chart document model implements com.sun.star.frame.XModel. Therefore, controllers can be registered with the method connectController(). When one of the registered controllers is set as current one with setCurrentController(), this one is also returned in the method getCurrentController().

Apart from using the controller directly, there are three other useful methods:

  void lockControllers()
  void unlockControllers()
  boolean hasControllersLocked()

With a call to lockControllers() all registered controllers will no longer be notified about changes in the model. If there are changes those are notified no earlier than after calling unlockControllers(). This is especially useful if you do many changes to the chart model at a time but do not need the view to be updated after every single change. The method hasControllersLocked() just gives you the state whether controllers are locked or not.

Documentation note.png You can nest calls to lockControllers(). Every call to lockControllers() needs a corresponding unlockControllers() call. Only after the correct number of unlocking calls, notifications of the model will be sent again. So, you can safely lock and unlock the controllers in your code without having to check if they have already been locked or not. Just make sure that you call both methods and do not leave the controllers in a locked state after your code finishes.
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages