Difference between revisions of "NL/Documentation/BASIC Guide/Editing Drawing Objects"

From Apache OpenOffice Wiki
Jump to: navigation, search
(Created page with "{{NL/Documentation/BASICGuideTOC/v2 |ShowPrevNext=block |ShowPrevPage=block |PrevPage=NL/Documentation/BASIC Guide/Structure of Drawings |NextPage=NL/Documentation/BASIC Guide..." (tussenstap opslaan))
 
 
(3 intermediate revisions by the same user not shown)
Line 14: Line 14:
 
Het volgende voorbeeld groepeert twee tekenobjecten:
 
Het volgende voorbeeld groepeert twee tekenobjecten:
  
<source lang="oobas">
+
<syntaxhighlight lang="oobas">
 
Dim Doc As Object
 
Dim Doc As Object
 
Dim Pagina As Object
 
Dim Pagina As Object
Line 64: Line 64:
 
NieuwPos.Y = NieuwPos.Y - Hoogte / 2
 
NieuwPos.Y = NieuwPos.Y - Hoogte / 2
 
Groep.Position = NieuwPos
 
Groep.Position = NieuwPos
</source>
+
</syntaxhighlight>
  
This code creates a rectangle and a circle and inserts them into a page. It then creates an object that supports the <idl>com.sun.star.drawing.ShapeCollection</idl> service and uses the <tt>Add</tt> method to add the rectangle and the circle to this object. The <tt>ShapeCollection</tt> is added to the page using the <tt>Group</tt> method and returns the actual <tt>Group</tt> object that can be edited like an individual <tt>Shape</tt>.
+
Deze code maakt een rechthoek en een cirkel en voegt die op de pagina in. Het maakt dan een object dat de service <idl>com.sun.star.drawing.ShapeCollection</idl> ondersteunt en gebruikt dan de methode <tt>Add</tt> om de rechthoek en cirkel aan dat object toe te voegen. De <tt>ShapeCollection</tt> wordt toegevoegd aan de pagina met behulp van de methode <tt>Group</tt> en geeft het actuele object <tt>Group</tt> weer dat kan worden bewerkt als een individuele <tt>Shape</tt>.
  
If you want to format the individual objects of a group, apply the formatting before you add them to the group. You cannot modify the objects once they are in the group.
+
Als u de individuele objecten van een groep wilt opmaken, pas dan de opmaak toe vóórdat u ze toevoegt aan de groep. U kunt de objecten niet aanpassen als zij aan de groep zijn toegevoegd.
  
== Rotating and Shearing Drawing Objects ==
+
== Roteren en schuin trekken van tekenobjecten ==
  
All of the drawing objects that are described in the previous sections can also be rotated and sheared using the <idl>com.sun.star.drawing.RotationDescriptor</idl> service.
+
Alle teken-objecten die worden beschreven in de voorgaande gedeelten kunnen ook worden geroteerd of vervormt met behulp van de service <idl>com.sun.star.drawing.RotationDescriptor</idl>.
  
The service provides the following properties:
+
De service verschaft de volgende eigenschappen:
  
;<tt>RotateAngle (Long)</tt>:rotary angle in hundredths of a degree
+
;<tt>RotateAngle (Long)</tt>:draaihoek in 100-en van een graad
;<tt>ShearAngle (Long)</tt>:shear angle in hundredths of a degree
+
;<tt>ShearAngle (Long)</tt>:hoek om schuin te trekken in 100-en van een graad
  
The following example creates a rectangle and rotates it by 30 degrees using the <tt>RotateAngle</tt> property:
+
Het volgende voorbeeld maakt een rechthoek en draait die 30 graden met behulp van de eigenschap <tt>RotateAngle</tt>:
  
<source lang="oobas">
+
<syntaxhighlight lang="oobas">
 
Dim Doc As Object
 
Dim Doc As Object
Dim Page As Object
+
Dim Pagina As Object
Dim RectangleShape As Object
+
Dim RechthoekVorm As Object
Dim Point As New com.sun.star.awt.Point
+
Dim Punt As New com.sun.star.awt.Point
Dim Size As New com.sun.star.awt.Size
+
Dim Grootte As New com.sun.star.awt.Size
  
Point.x = 1000
+
Punt.x = 1000
Point.y = 1000
+
Punt.y = 1000
Size.Width = 10000
+
Grootte.Width = 10000
Size.Height = 10000
+
Grootte.Height = 10000
  
 
Doc = ThisComponent
 
Doc = ThisComponent
Page = Doc.DrawPages(0)
+
Pagina = Doc.DrawPages(0)
  
RectangleShape = Doc.createInstance("com.sun.star.drawing.RectangleShape")
+
RechthoekVorm = Doc.createInstance("com.sun.star.drawing.RectangleShape")
RectangleShape.Size = Size
+
RechthoekVorm.Size = Grootte
RectangleShape.Position = Point
+
RechthoekVorm.Position = Punt
  
RectangleShape.RotateAngle = 3000
+
RechthoekVorm.RotateAngle = 3000
  
Page.add(RectangleShape)
+
Pagina.add(RechthoekVorm)
</source>
+
</syntaxhighlight>
  
The next example creates the same rectangle as in the previous example, but instead shears it through 30 degrees using the <tt>ShearAngle</tt> property.
+
Het volgende voorbeeld maakt dezelfde rechthoek als in het voorgaande voorbeeld, maar trekt die schuin over 30 graden met behulp van de eigenschap <tt>ShearAngle</tt>.
  
<source lang="oobas">
+
<syntaxhighlight lang="oobas">
 
Dim Doc As Object
 
Dim Doc As Object
Dim Page As Object
+
Dim Pagina As Object
Dim RectangleShape As Object
+
Dim RechthoekVorm As Object
Dim Point As New com.sun.star.awt.Point
+
Dim Punt As New com.sun.star.awt.Point
Dim Size As New com.sun.star.awt.Size
+
Dim Grootte As New com.sun.star.awt.Size
  
Point.x = 1000
+
Punt.x = 1000
Point.y = 1000
+
Punt.y = 1000
Size.Width = 10000
+
Grootte.Width = 10000
Size.Height = 10000
+
Grootte.Height = 10000
  
 
Doc = ThisComponent
 
Doc = ThisComponent
Page = Doc.DrawPages(0)
+
Pagina = Doc.DrawPages(0)
RectangleShape = Doc.createInstance("com.sun.star.drawing.RectangleShape")
+
RectangleShape.Size = Size
+
RectangleShape.Position = Point
+
  
RectangleShape.ShearAngle = 3000
+
RechthoekVorm = Doc.createInstance("com.sun.star.drawing.RectangleShape")
 +
RechthoekVorm.Size = Grootte
 +
RechthoekVorm.Position = Punt
  
Page.add(RectangleShape)
+
RechthoekVorm.ShearAngle = 3000
</source>
+
  
== Searching and Replacing ==
+
Pagina.add(RechthoekVorm)
 +
</syntaxhighlight>
  
As in text documents, drawing documents provide a function for searching and replace. This function is similar to the one that is used in text documents as described in [[Documentation/BASIC_Guide/Text_Documents|Text Documents]]. However, in drawing documents the descriptor objects for searching and replacing are not created directly through the document object, but rather through the associated character level. The following example outlines the replacement process within a drawing:
+
== Zoeken en vervangen ==
  
<source lang="oobas">
+
Net als in tekstdocumenten verschaffen documenten voor tekeningen een functie voor Zoeken en vervangen. Deze functie komt overeen met die welke wordt gebruikt in tekstdocumenten, zoals beschreven in [[NL/Documentation/BASIC_Guide/Text_Documents|Tekstdocumenten]]. Echter, in documenten voor tekeningen worden de beschrijvingsobjecten voor Zoeken en vervangen niet direct door het documentobject gemaakt, maar door het geassocieerde niveau van het teken.
 +
 
 +
<syntaxhighlight lang="oobas">
 
Dim Doc As Object
 
Dim Doc As Object
Dim Page As Object
+
Dim Pagina As Object
Dim ReplaceDescriptor As Object
+
Dim VervangOmschijving As Object
 
Dim I As Integer
 
Dim I As Integer
  
 
Doc = ThisComponent
 
Doc = ThisComponent
Page = Doc.DrawPages(0)
+
Pagina = Doc.DrawPages(0)
  
ReplaceDescriptor = Page.createReplaceDescriptor()
+
VervangOmschijving = Pagina.createReplaceDescriptor()
ReplaceDescriptor.SearchString = "is"
+
VervangOmschijving.SearchString = "is"
ReplaceDescriptor.ReplaceString = "was"
+
VervangOmschijving.ReplaceString = "was"
  
 
For I = 0 to Doc.DrawPages.Count - 1
 
For I = 0 to Doc.DrawPages.Count - 1
   Page = Doc.DrawPages(I)
+
   Pagina = Doc.DrawPages(I)
   Page.ReplaceAll(ReplaceDescriptor)  
+
   Pagina.ReplaceAll(VervangOmschijving)  
 
Next I
 
Next I
</source>
+
</syntaxhighlight>
  
This code uses the first page of the document to create a <tt>ReplaceDescriptor</tt> and then applies this descriptor in a loop to all of the pages in the drawing document.
+
Deze code gebruikt de eerste pagina van het document om een <tt>ReplaceDescriptor</tt> te maken en past de omschrijving dan toe op alle pagina's in het document, door middel van een lus.
 
+
+
 
{{InterWiki Languages BasicGuide|articletitle=Documentation/BASIC Guide/Editing Drawing Objects}}
 
{{InterWiki Languages BasicGuide|articletitle=Documentation/BASIC Guide/Editing Drawing Objects}}
 
{{PDL1}}
 
{{PDL1}}

Latest revision as of 14:10, 10 February 2021

Book.png


Objecten groeperen

In veel situaties, is het handig om verschillende individuele tekenobjecten te groeperen zodat zij zich gaan gedragen als één enkel groot object.

Het volgende voorbeeld groepeert twee tekenobjecten:

Dim Doc As Object
Dim Pagina As Object
Dim Vierkant As Object
Dim Cirkel As Object
Dim Vormen As Object
Dim Groep As Object
Dim Punt As New com.sun.star.awt.Point
Dim Grootte As New com.sun.star.awt.Size
Dim NieuwPos As New com.sun.star.awt.Point
Dim Hoogte As Long
Dim Breedte As Long
 
Doc = ThisComponent
Pagina = Doc.DrawPages(0)
Punt.x = 3000
Punt.y = 3000
Grootte.Width = 3000
Grootte.Height = 3000
' maak tekenelement vierkant
Vierkant = Doc.createInstance("com.sun.star.drawing.RectangleShape")
Vierkant.Size = Grootte
Vierkant.Position = Punt
Vierkant.FillColor = RGB(255,128,128) 
Pagina.add(Vierkant)
 
' maak tekenelement cirkel
Cirkel = Doc.createInstance("com.sun.star.drawing.EllipseShape")
Cirkel.Size = Grootte
Cirkel.Position = Punt
Cirkel.FillColor = RGB(255,128,128) 
Cirkel.FillColor = RGB(0,255,0)
Pagina.add(Cirkel)
 
' combineer de tekenelementen vierkant en cirkel
Vormen = createUnoService("com.sun.star.drawing.ShapeCollection")
Vormen.add(Vierkant)
 
Vormen.add(Cirkel)
Groep = Pagina.group(Vormen)
' centreer gecombineerde tekenelementen
Hoogte = Pagina.Height
Breedte = Pagina.Width
NieuwPos.X = Breedte / 2
NieuwPos.Y = Hoogte / 2
Hoogte = Groep.Size.Height
Breetde = Groep.Size.Width
NieuwPos.X = NieuwPos.X - Breedte / 2
NieuwPos.Y = NieuwPos.Y - Hoogte / 2
Groep.Position = NieuwPos

Deze code maakt een rechthoek en een cirkel en voegt die op de pagina in. Het maakt dan een object dat de service com.sun.star.drawing.ShapeCollection ondersteunt en gebruikt dan de methode Add om de rechthoek en cirkel aan dat object toe te voegen. De ShapeCollection wordt toegevoegd aan de pagina met behulp van de methode Group en geeft het actuele object Group weer dat kan worden bewerkt als een individuele Shape.

Als u de individuele objecten van een groep wilt opmaken, pas dan de opmaak toe vóórdat u ze toevoegt aan de groep. U kunt de objecten niet aanpassen als zij aan de groep zijn toegevoegd.

Roteren en schuin trekken van tekenobjecten

Alle teken-objecten die worden beschreven in de voorgaande gedeelten kunnen ook worden geroteerd of vervormt met behulp van de service com.sun.star.drawing.RotationDescriptor.

De service verschaft de volgende eigenschappen:

RotateAngle (Long)
draaihoek in 100-en van een graad
ShearAngle (Long)
hoek om schuin te trekken in 100-en van een graad

Het volgende voorbeeld maakt een rechthoek en draait die 30 graden met behulp van de eigenschap RotateAngle:

Dim Doc As Object
Dim Pagina As Object
Dim RechthoekVorm As Object
Dim Punt As New com.sun.star.awt.Point
Dim Grootte As New com.sun.star.awt.Size
 
Punt.x = 1000
Punt.y = 1000
Grootte.Width = 10000
Grootte.Height = 10000
 
Doc = ThisComponent
Pagina = Doc.DrawPages(0)
 
RechthoekVorm = Doc.createInstance("com.sun.star.drawing.RectangleShape")
RechthoekVorm.Size = Grootte
RechthoekVorm.Position = Punt
 
RechthoekVorm.RotateAngle = 3000
 
Pagina.add(RechthoekVorm)

Het volgende voorbeeld maakt dezelfde rechthoek als in het voorgaande voorbeeld, maar trekt die schuin over 30 graden met behulp van de eigenschap ShearAngle.

Dim Doc As Object
Dim Pagina As Object
Dim RechthoekVorm As Object
Dim Punt As New com.sun.star.awt.Point
Dim Grootte As New com.sun.star.awt.Size
 
Punt.x = 1000
Punt.y = 1000
Grootte.Width = 10000
Grootte.Height = 10000
 
Doc = ThisComponent
Pagina = Doc.DrawPages(0)
 
RechthoekVorm = Doc.createInstance("com.sun.star.drawing.RectangleShape")
RechthoekVorm.Size = Grootte
RechthoekVorm.Position = Punt
 
RechthoekVorm.ShearAngle = 3000
 
Pagina.add(RechthoekVorm)

Zoeken en vervangen

Net als in tekstdocumenten verschaffen documenten voor tekeningen een functie voor Zoeken en vervangen. Deze functie komt overeen met die welke wordt gebruikt in tekstdocumenten, zoals beschreven in Tekstdocumenten. Echter, in documenten voor tekeningen worden de beschrijvingsobjecten voor Zoeken en vervangen niet direct door het documentobject gemaakt, maar door het geassocieerde niveau van het teken.

Dim Doc As Object
Dim Pagina As Object
Dim VervangOmschijving As Object
Dim I As Integer
 
Doc = ThisComponent
Pagina = Doc.DrawPages(0)
 
VervangOmschijving = Pagina.createReplaceDescriptor()
VervangOmschijving.SearchString = "is"
VervangOmschijving.ReplaceString = "was"
 
For I = 0 to Doc.DrawPages.Count - 1
   Pagina = Doc.DrawPages(I)
   Pagina.ReplaceAll(VervangOmschijving) 
Next I

Deze code gebruikt de eerste pagina van het document om een ReplaceDescriptor te maken en past de omschrijving dan toe op alle pagina's in het document, door middel van een lus.


Content on this page is licensed under the Public Documentation License (PDL).
Personal tools