Hi Peter,

sorry for the late answer, I was very busy the last week... I read
your approach on http://qa.openoffice.org/issues/show_bug.cgi?id=65951
which i found very interesting and I have at least the following
question:

What should happen when a document containing the (Base)-FormControls
gets printed?

1) what about the shadow of the FormControls? The shadow should not be
printed, but how do you want to determine the real background-color If
you put a fix shadow on the FormElements? One possible way could be to
calculate the shadow with a revertable function like XOR (eg.
SHADOW=ORIG_BGCOLOR xor rgb(200, 200, 200)), and when it's time to
print, just recalculate the ORIG_BGCOLOR...

2) what about ComboBoxes and other complex elements? How to print
these elements? I don't want to print all the graphic-widgets, but a
textual representation instead...

I tried to write a small prototype in Basic which reflects one central
part of your concept: a function that inserts a
com.sun.star.form.component.TextField at the viewCursor-position,
using the character-properties of the viewCursor. (I don't copy all
required character-properties at the moment, but this should only be a
prototype...)

Inserting the TextField and setting the charakter-properties is easy.
I had the most difficulties trying to calculate the position and the
size of the corresponding Shape-Object. Unfortunately I didn't manage
to solve the problems yet, so setting the correct position does not
work in the prototype.

Here is the basic-code. I would appreciate if you could test and
commend on this code. You have to call insertTextFormField to get a
FormField inserted at the viewCursor-position:

Sub insertTextFormField
   doc = ThisComponent
        
   vcursor = doc.CurrentController.getViewCursor()
        
   ' a control model
   oControlModel = createUnoService("com.sun.star.form.component.TextField" )
   oControlModel.Border = 0
   oControlModel.BackgroundColor = rgb(200,200,200)
   oControlModel.TextColor = rgb(255,0,0)

   oControlModel.RichText = true
   oControlModel.CharFontName = vcursor.CharFontName
   oControlModel.CharHeight = vcursor.CharHeight
   oControlModel.CharWeight = vcursor.CharWeight

   oControlModel.setString("Halgo")

   ' calculate size of shape using the size of the current font
   fdesc = oControlModel.FontDescriptor
   font = oControlModel.ReferenceDevice.getFont(fdesc)
   fdesc = font.FontDescriptor
   fmetric = font.FontMetric
   height = fmetric.Ascent + fmetric.Descent + fmetric.Leading + 110
   width = font.getStringWidth(oControlModel.String)
   print "Height=" & height & "  Width=" & width        

   ' a shape
   oControlShape = doc.createInstance( "com.sun.star.drawing.ControlShape" )
   positionShape( oControlShape, 0, -1*height, 2*width, 1.3*height)

   ' knit both
   oControlShape.Control = oControlModel

   vcursor.Text.insertTextContent(vcursor, oControlShape, true)
End Sub

' this sets the size and position of a given shape
Sub positionShape( oShape as Object, X as Integer, Y as Integer, Width
as Integer, Height as Integer )
       oShape.AnchorType = com.sun.star.text.TextContentAnchorType.AS_CHARACTER
               ' Not that this implies that you can use it for text
documents only.
               ' The rest of the function also works for shapes in
other documents

        Dim oPos as new com.sun.star.awt.Point
       oPos.X = X
       oPos.Y = Y
       oShape.setPosition( oPos )
       Erase oPos
       Dim oSize as new com.sun.star.awt.Size
       oSize.Width = Width
       oSize.Height = Height
       oShape.setSize( oSize )
       Erase oSize
End Sub


Finally I would like to hint to "13.9.4  Programmatic Assignment of
Scripts to Events" in the dev-guid where a good example about
inserting and handling Form-elements is found.

regards, christoph

---------------------------------------------------------------
original message:
Hi,

for those people, who have worked with forms in MS Word and now are
migrating to OpenOffice, the situation is not satisfying, others would
say annoying.
I've submitted http://www.openoffice.org/issues/show_bug.cgi?id=65951 to
show how the problems could be solved.
Don't know, if this is the appropriate list, because form controls are a
matter of the base team. But they are used without any database access
in writer documents, so let's start here.
I would like to discuss the future of forms handling in this thread and
will appreciate any comments.
In a simple (imported) form you have a mix of controls (CheckBox) and
fields (input fields list fields or placeholders). If the behavior of
input fields could be improved, would this fit your needs?

Regards

Peter

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to