Difference between revisions of "Documentation/DevGuide/Spreadsheets/Cell Annotations"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (1 revision(s))
 
(3 intermediate revisions by one other user not shown)
Line 7: Line 7:
 
|NextPage=Documentation/DevGuide/Spreadsheets/Cell Ranges and Cells Container
 
|NextPage=Documentation/DevGuide/Spreadsheets/Cell Ranges and Cells Container
 
}}
 
}}
{{DISPLAYTITLE:Cell Annotations}}
+
{{Documentation/DevGuideLanguages|Documentation/DevGuide/Spreadsheets/{{SUBPAGENAME}}}}
 +
{{DISPLAYTITLE:Cell Annotations}}
 
<idltopic>com.sun.star.sheet.CellAnnotation;com.sun.star.sheet.XSheetAnnotation;com.sun.star.sheet.XSheetAnnotationAnchor</idltopic>
 
<idltopic>com.sun.star.sheet.CellAnnotation;com.sun.star.sheet.XSheetAnnotation;com.sun.star.sheet.XSheetAnnotationAnchor</idltopic>
 
A spreadsheet cell may contain one annotation that consists of simple unformatted Text.
 
A spreadsheet cell may contain one annotation that consists of simple unformatted Text.
Line 30: Line 31:
 
The following example inserts an annotation and makes it permanently visible.  
 
The following example inserts an annotation and makes it permanently visible.  
 
<!--[SOURCE:Spreadsheet/SpreadsheetSample.java]-->
 
<!--[SOURCE:Spreadsheet/SpreadsheetSample.java]-->
 
+
<syntaxhighlight lang="java">
 
   public void doAnnotationSample(
 
   public void doAnnotationSample(
 
           com.sun.star.sheet.XSpreadsheet xSheet,
 
           com.sun.star.sheet.XSpreadsheet xSheet,
Line 54: Line 55:
 
       xAnnotation.setIsVisible(true);
 
       xAnnotation.setIsVisible(true);
 
   }
 
   }
 
+
</syntaxhighlight>
 
{{PDL1}}
 
{{PDL1}}
[[Category: Spreadsheet Documents]]
+
 
 +
[[Category:Documentation/Developer's Guide/Spreadsheet Documents]]

Latest revision as of 15:33, 3 January 2021



A spreadsheet cell may contain one annotation that consists of simple unformatted Text.

Cell annotations

This service com.sun.star.sheet.CellAnnotation represents an annotation. It implements interfaces to manipulate the contents and access the source cell.

It is possible to access the annotations through a container object from the spreadsheet or directly from a cell object.

The service com.sun.star.sheet.CellAnnotations represents the collection of annotations for the spreadsheet and implements two interfaces to access the annotations.

The following example inserts an annotation and makes it permanently visible.

  public void doAnnotationSample(
          com.sun.star.sheet.XSpreadsheet xSheet,
          int nColumn, int nRow ) throws RuntimeException, Exception {
      // create the CellAddress struct
      com.sun.star.table.XCell xCell = xSheet.getCellByPosition(nColumn, nRow);
      com.sun.star.sheet.XCellAddressable xCellAddr = (com.sun.star.sheet.XCellAddressable)
          UnoRuntime.queryInterface(com.sun.star.sheet.XCellAddressable.class, xCell);
      com.sun.star.table.CellAddress aAddress = xCellAddr.getCellAddress();
 
      // insert an annotation
      com.sun.star.sheet.XSheetAnnotationsSupplier xAnnotationsSupp =
          (com.sun.star.sheet.XSheetAnnotationsSupplier) UnoRuntime.queryInterface(
              com.sun.star.sheet.XSheetAnnotationsSupplier.class, xSheet);
      com.sun.star.sheet.XSheetAnnotations xAnnotations = xAnnotationsSupp.getAnnotations();
      xAnnotations.insertNew(aAddress, "This is an annotation");
 
      // make the annotation visible
      com.sun.star.sheet.XSheetAnnotationAnchor xAnnotAnchor =
          (com.sun.star.sheet.XSheetAnnotationAnchor) UnoRuntime.queryInterface(
              com.sun.star.sheet.XSheetAnnotationAnchor.class, xCell);
      com.sun.star.sheet.XSheetAnnotation xAnnotation = xAnnotAnchor.getAnnotation();
      xAnnotation.setIsVisible(true);
  }
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages