Difference between revisions of "Documentation/DevGuide/Drawings/Layer Handling"

From Apache OpenOffice Wiki
Jump to: navigation, search
(Initial author Sun Microsystems, Inc.)
 
 
(4 intermediate revisions by 3 users not shown)
Line 7: Line 7:
 
|NextPage=Documentation/DevGuide/Drawings/Inserting Files
 
|NextPage=Documentation/DevGuide/Drawings/Inserting Files
 
}}
 
}}
{{DISPLAYTITLE:Layer Handling}}
+
{{Documentation/DevGuideLanguages|Documentation/DevGuide/Drawings/{{SUBPAGENAME}}}}
 +
{{DISPLAYTITLE:Layer Handling}}
 
<!--<idltopic>com.sun.star.drawing.XLayerManager</idltopic>-->
 
<!--<idltopic>com.sun.star.drawing.XLayerManager</idltopic>-->
 
In Draw and Impress, each shape is associated to exactly ''one'' layer. The layer has properties that specify if connected shapes are visible, printable or editable.
 
In Draw and Impress, each shape is associated to exactly ''one'' layer. The layer has properties that specify if connected shapes are visible, printable or editable.
Line 13: Line 14:
 
The service <idl>com.sun.star.drawing.DrawingDocument</idl> implements the interface <idl>com.sun.star.drawing.XLayerSupplier</idl> that gives access to the <idl>com.sun.star.drawing.XLayerManager</idl> interface. The <idl>com.sun.star.drawing.XLayerManager</idl> interface is used to create and edit a layer, and is used to attach a layer to a shape.  
 
The service <idl>com.sun.star.drawing.DrawingDocument</idl> implements the interface <idl>com.sun.star.drawing.XLayerSupplier</idl> that gives access to the <idl>com.sun.star.drawing.XLayerManager</idl> interface. The <idl>com.sun.star.drawing.XLayerManager</idl> interface is used to create and edit a layer, and is used to attach a layer to a shape.  
 
<!--[SOURCE:Drawing/LayerDemo.java]-->
 
<!--[SOURCE:Drawing/LayerDemo.java]-->
 
+
<syntaxhighlight lang="java">
 
   XShapes xShapes = (XShapes)UnoRuntime.queryInterface(XShapes.class, xPage);
 
   XShapes xShapes = (XShapes)UnoRuntime.queryInterface(XShapes.class, xPage);
 
   XShape xRect1 = ShapeHelper.createShape(xComponent, new Point(1000, 1000), new Size(5000, 5000),
 
   XShape xRect1 = ShapeHelper.createShape(xComponent, new Point(1000, 1000), new Size(5000, 5000),
Line 47: Line 48:
 
   // attach the layer to the rectangles
 
   // attach the layer to the rectangles
 
   xLayerManager.attachShapeToLayer(xRect1, xNotVisibleAndEditable);
 
   xLayerManager.attachShapeToLayer(xRect1, xNotVisibleAndEditable);
   xLayerManager.attachShapeToLayer(xRect2, xNotEditable);
+
   xLayerManager.attachShapeToLayer(xRect2, xNotEditable);</syntaxhighlight>
  
 
{{PDL1}}
 
{{PDL1}}
[[Category: Drawing Documents and Presentation Documents]]
+
 
 +
[[Category:Documentation/Developer's Guide/Drawing Documents and Presentation Documents]]

Latest revision as of 14:35, 20 December 2020



In Draw and Impress, each shape is associated to exactly one layer. The layer has properties that specify if connected shapes are visible, printable or editable.

The service com.sun.star.drawing.DrawingDocument implements the interface com.sun.star.drawing.XLayerSupplier that gives access to the com.sun.star.drawing.XLayerManager interface. The com.sun.star.drawing.XLayerManager interface is used to create and edit a layer, and is used to attach a layer to a shape.

  XShapes xShapes = (XShapes)UnoRuntime.queryInterface(XShapes.class, xPage);
  XShape xRect1 = ShapeHelper.createShape(xComponent, new Point(1000, 1000), new Size(5000, 5000),
      "com.sun.star.drawing.RectangleShape");
  XShape xRect2 = ShapeHelper.createShape(xComponent, new Point(1000, 7000), new Size(5000, 5000),
      "com.sun.star.drawing.RectangleShape" );
  xShapes.add(xRect1);
  xShapes.add(xRect2);
  XPropertySet xTextProp = ShapeHelper.addPortion(xRect2, "this shape is locked", false);
  xTextProp.setPropertyValue("ParaAdjust", ParagraphAdjust.CENTER);
  ShapeHelper.addPortion(xRect2, "and the shape above is not visible", true);
  ShapeHelper.addPortion(xRect2, "(switch to the layer view to gain access)", true);
  // query for the XLayerManager
  XLayerSupplier xLayerSupplier = (XLayerSupplier)UnoRuntime.queryInterface(
      XLayerSupplier.class, xComponent);
  XNameAccess xNameAccess = xLayerSupplier.getLayerManager();
  XLayerManager xLayerManager = (XLayerManager)UnoRuntime.queryInterface(
      XLayerManager.class, xNameAccess);
  // create a layer and set its properties
  XPropertySet xLayerPropSet;
  XLayer xNotVisibleAndEditable = xLayerManager.insertNewByIndex(xLayerManager.getCount());
  xLayerPropSet = (XPropertySet)UnoRuntime.queryInterface(
      XPropertySet.class, xNotVisibleAndEditable);
  xLayerPropSet.setPropertyValue("Name", "NotVisibleAndEditable");
  xLayerPropSet.setPropertyValue("IsVisible", new Boolean(false));
  xLayerPropSet.setPropertyValue("IsLocked", new Boolean(true));
  // create a second layer
  XLayer xNotEditable = xLayerManager.insertNewByIndex(xLayerManager.getCount());
  xLayerPropSet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xNotEditable);
  xLayerPropSet.setPropertyValue("Name", "NotEditable" );
  xLayerPropSet.setPropertyValue("IsVisible", new Boolean(true));
  xLayerPropSet.setPropertyValue("IsLocked", new Boolean(true));
  // attach the layer to the rectangles
  xLayerManager.attachShapeToLayer(xRect1, xNotVisibleAndEditable);
  xLayerManager.attachShapeToLayer(xRect2, xNotEditable);
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages