Java Code Examples for com.sun.star.uno.UnoRuntime#areSame()

The following examples show how to use com.sun.star.uno.UnoRuntime#areSame() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FormService.java    From noa-libre with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Returns the OpenOffice.org XEventAttacherManager interface for the given form,
 * or null if not available.
 * 
 * @param form the form to be used
 * 
 * @return the OpenOffice.org XEventAttacherManager interface for the given form,
 * or null
 * 
 * @throws NOAException if the return of OpenOffice.org XEventAttacherManager interface fails
 * 
 * @author Markus Krüger
 * @date 26.01.2007
 */
public XEventAttacherManager getXEventAttacherManager(IForm form) throws NOAException {
  try {
    if(form != null) {
      XFormsSupplier formsSupplier = (XFormsSupplier) UnoRuntime.queryInterface(XFormsSupplier.class, xDrawPage);
      if(formsSupplier != null) {
        XNameContainer nameContainer = formsSupplier.getForms();
        XIndexContainer indexContainer = (XIndexContainer) UnoRuntime.queryInterface(XIndexContainer.class, nameContainer);
        int len = indexContainer.getCount();
        for(int i = 0; i < len; i++) { 
          XForm tmpForm = (XForm) UnoRuntime.queryInterface(XForm.class, indexContainer.getByIndex(i));
          if(tmpForm != null && UnoRuntime.areSame(form.getXFormComponent(),tmpForm)) {
            XEventAttacherManager tmpEventAttacherManager = 
              (XEventAttacherManager) UnoRuntime.queryInterface(XEventAttacherManager.class, tmpForm);
            return tmpEventAttacherManager;
          }
        }
      }
    }
    return null;
  }
  catch(Throwable throwable) {
    throw new NOAException(throwable);
  }
}
 
Example 2
Source File: FormService.java    From noa-libre with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Returns the index of the given form component in the given form, or -1 if not found.
 * 
 * @param form the form to check index in
 * @param formComponent the form component to get index for
 * 
 * @return the index of the given form component in the given form, or -1
 * 
 * @throws NOAException if anything fails
 * 
 * @author Markus Krüger
 * @date 25.01.2007
 */
public int getIndexInForm(IForm form, IFormComponent formComponent) throws NOAException {
  try {
    if(form!= null && formComponent != null) {
      XFormsSupplier formsSupplier = (XFormsSupplier) UnoRuntime.queryInterface(XFormsSupplier.class, xDrawPage);
      if(formsSupplier != null) {
        XNameContainer nameContainer = formsSupplier.getForms();
        XIndexContainer indexContainer = (XIndexContainer) UnoRuntime.queryInterface(XIndexContainer.class, nameContainer);
        int len = indexContainer.getCount();
        for(int i = 0; i < len; i++) {
          XForm tmpForm = (XForm) UnoRuntime.queryInterface(XForm.class, indexContainer.getByIndex(i));
          if(tmpForm != null && UnoRuntime.areSame(form.getXFormComponent(),tmpForm)) {    
            XIndexContainer container = (XIndexContainer) UnoRuntime.queryInterface(XIndexContainer.class, tmpForm);
            int lenFormPComponents = container.getCount();           
            for(int j = 0; j < lenFormPComponents; j++) {
              Object tmpObject = container.getByIndex(j);
              if(tmpObject != null) {
                XFormComponent tmpFormComponent = (XFormComponent) UnoRuntime.queryInterface(XFormComponent.class, tmpObject);
                if(tmpFormComponent != null && UnoRuntime.areSame(tmpFormComponent,formComponent.getXFormComponent()))
                  return j;
              }
            }
          }
        }
      }        
    }
    return -1;
  }
  catch(Throwable throwable) {
    throw new NOAException(throwable);
  }
  
}
 
Example 3
Source File: AbstractDocument.java    From noa-libre with GNU Lesser General Public License v2.1 3 votes vote down vote up
/**
 * Checks if the document equals another document.
 * 
 * @param compareDocument
 *            document to be compared
 * 
 * @return true if they are equal, flase if they are different
 * 
 * @author Markus Krüger
 * @author Andreas Bröker
 */
public boolean equalsTo(IDocument compareDocument) {
	if (compareDocument == null) {
		return false;
	}

	if (UnoRuntime.areSame(xComponent, compareDocument.getXComponent())) {
		return true;
	}
	return false;
}