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

From Apache OpenOffice Wiki
Jump to: navigation, search
m (Robot: Changing Category:Drawing Documents and Presentation Documents)
m (FINAL VERSION FOR L10N)
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.

Revision as of 12:15, 15 May 2009



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