Re: [api-dev] Re: Variant vs other types...

2007-01-29 Thread Johnny Andersson

Thanks for your reply again! I will definitely take a look on that
presentation.

Have a great day!

Johnny Andersson

2007/1/30, Andrew Douglas Pitonyak <[EMAIL PROTECTED]>:




Johnny Andersson wrote:
>
> 2007/1/29, Andrew Douglas Pitonyak <[EMAIL PROTECTED]>:
>> What do you really want to accomplish? Do you want to copy a range of
>> data from one location to another? If so, you can use methods to
>> directly copy the data. I have used "cheat" methods such as
>>
>> oCellRange1.setData(oCellRange2.getData())
> No, a function will use the data (and other data) for calculation. The
> function will return a value that will be written to another cell. The
> function will be in a loop and use three of the values (one
> column), different every time.
Very good. I assume that you now know how to do this.
>>
>> > Another solution would perharps be to create a struct (as it's called
>> > in C),
>> > but is that possible in OpenOffice.org Basic?
>> Yes, you can create a user defined structure/type. To quote from my
>> AndrewMacro.odt document.
>>
>>
>> 1.1. User Defined Data Types
>> As of OOo 1.1.1, you can define your own data types.
>> Listing 5.51: You can define your own data types.
>> Type PersonType
>>   FirstName As String
>>   LastName As String
>> End Type
>>
>> Sub ExampleCreateNewType
>>   Dim Person As PersonType
>>   Person.FirstName = "Andrew"
>>   Person.LastName  = "Pitonyak"
>>   PrintPerson(Person)
>> End Sub
>>
>> Sub PrintPerson(x)
>>   Print "Person = " & x.FirstName & " " & x.LastName
>> End Sub
>
>
> Wow, I didn't know that! Now I have to rewrite everything macro and
> every function I've made so far..!
> They are not that many, on the other hand...
>
> In your example above, is the following possible?
>
> Sub ExampleCreateNewType
>  Dim Person(100) As PersonType
>  Person(0).FirstName = "Andrew"
>  Person(0).LastName  = "Pitonyak"
>  PrintPerson(Person(0))
> End Sub
Try it, yes, it works
> And is the following possible?
>
> Type PersonType
>  FirstName As String
>  LastName As String
>  ThingsToDo(9) As String
> End Type
No, you can NOT have an array inside of a struct. You need to fake it:

Type PersonType
  FirstName As String
  LastName As String

  REM You can NOT have an array inside a structure
  REM ThingsToDo(9) As String
  REM But you can fake it...
  ThingsToDo As Variant
End Type

Sub ExampleCreateNewType
  Dim Person As PersonType
  Dim aa(9) As String

  Person.FirstName = "Andrew"
  Person.LastName  = "Pitonyak"
  Person.ThingsToDo = aa()
  Print UBound(Person.ThingsToDo)  REM Prints 9
  Person.ThingsToDo = DimArray(9)
  Print UBound(Person.ThingsToDo)  REM Prints 9
  'PrintPerson(Person)
End Sub
>
> And finally, is the following possible?
>
> Type PersonType
>  FirstName As String
>  LastName As String
> End Type
>
> Type Human
>  Properties As PersonType
>  Friends(9) As PersonType
> End Type
You can not have an array inside of a struct. A struct in a struct,
however, is fine.
> And even more finally, is there something similar to pointers in
> OpenOffice.org Basic?
I demonstrate this in the presentation I referenced.
> I gave a presentation at the 2004 OOo Conference in Berlin concerning
>> creating advanced data types using structures. The examples are in the
>> presentation available on my web site.
>
>
> Interesting! I'd better take a look there then!
>
> Thanks for your reply!
>
> Johnny
>

--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info:  http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html

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




[api-dev] Thanks For The Help -- Upgraded From 1.x to 2.x (and upgrade notes)

2007-01-29 Thread John Sisson
Hello
I upgraded from OO 1.x to 2.x [nice product] and have begun to look at
our automated install procedures [Wintel :: XP]. The Orca tool required
to massage msi files is impenetrably obscure, so I applied for and
downloaded a trial version of Star-8 which is claimed to have a
customization wizard to produce response files (Mathias Bauer; this
thread; 10-jan-06 14:42). I cannot find this tool in the [free, timed]
download; none of the executables other than star itself run when
invoked. Is there something extra to be done, or is the customizer only
on the distribution CD?
We have sites with 100 and more clients using our product which runs OO
in a managed window as a service to a Java app. As you can imagine,
providing a 'one-touch' install is pretty important at update time. Your
help here will be greatly appreciated.
Thanx
John Sisson


Re: [api-dev] Macro writer to get filename document

2007-01-29 Thread TerryJ
There are some functions in the Tools library ("Strings" module) which 
you can use.  The one you specifically want is called FileNameoutofPath


Jurgen van Doorn wrote:

Thanx Stephan. I'm going to try this.
Regards,Jurgen
 
 




Van: Stephan Wunderlich [mailto:[EMAIL PROTECTED]
Verzonden: ma 29-1-2007 9:53
Aan: dev@api.openoffice.org
Onderwerp: Re: [api-dev] Macro writer to get filename document



Hi Jurgen,

  
I'm looking for code to get the filename of the current document in 
writer.

In MS word is it like Activedocument.name but in Openoffice?



you can query the XModel from your document, which has a method getURL
() that should do what you want.

Regards

Stephan


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



Re: [api-dev] Re: Variant vs other types...

2007-01-29 Thread Andrew Douglas Pitonyak



Johnny Andersson wrote:


2007/1/29, Andrew Douglas Pitonyak <[EMAIL PROTECTED]>:

What do you really want to accomplish? Do you want to copy a range of
data from one location to another? If so, you can use methods to
directly copy the data. I have used "cheat" methods such as

oCellRange1.setData(oCellRange2.getData())

No, a function will use the data (and other data) for calculation. The
function will return a value that will be written to another cell. The
function will be in a loop and use three of the values (one
column), different every time.

Very good. I assume that you now know how to do this.


> Another solution would perharps be to create a struct (as it's called
> in C),
> but is that possible in OpenOffice.org Basic?
Yes, you can create a user defined structure/type. To quote from my
AndrewMacro.odt document.


1.1. User Defined Data Types
As of OOo 1.1.1, you can define your own data types.
Listing 5.51: You can define your own data types.
Type PersonType
  FirstName As String
  LastName As String
End Type

Sub ExampleCreateNewType
  Dim Person As PersonType
  Person.FirstName = "Andrew"
  Person.LastName  = "Pitonyak"
  PrintPerson(Person)
End Sub

Sub PrintPerson(x)
  Print "Person = " & x.FirstName & " " & x.LastName
End Sub



Wow, I didn't know that! Now I have to rewrite everything macro and
every function I've made so far..!
They are not that many, on the other hand...

In your example above, is the following possible?

Sub ExampleCreateNewType
 Dim Person(100) As PersonType
 Person(0).FirstName = "Andrew"
 Person(0).LastName  = "Pitonyak"
 PrintPerson(Person(0))
End Sub

Try it, yes, it works

And is the following possible?

Type PersonType
 FirstName As String
 LastName As String
 ThingsToDo(9) As String
End Type

No, you can NOT have an array inside of a struct. You need to fake it:

Type PersonType
 FirstName As String
 LastName As String

 REM You can NOT have an array inside a structure
 REM ThingsToDo(9) As String
 REM But you can fake it...
 ThingsToDo As Variant
End Type

Sub ExampleCreateNewType
 Dim Person As PersonType
 Dim aa(9) As String

 Person.FirstName = "Andrew"
 Person.LastName  = "Pitonyak"
 Person.ThingsToDo = aa()
 Print UBound(Person.ThingsToDo)  REM Prints 9
 Person.ThingsToDo = DimArray(9)
 Print UBound(Person.ThingsToDo)  REM Prints 9
 'PrintPerson(Person)
End Sub


And finally, is the following possible?

Type PersonType
 FirstName As String
 LastName As String
End Type

Type Human
 Properties As PersonType
 Friends(9) As PersonType
End Type
You can not have an array inside of a struct. A struct in a struct, 
however, is fine.

And even more finally, is there something similar to pointers in
OpenOffice.org Basic?

I demonstrate this in the presentation I referenced.

I gave a presentation at the 2004 OOo Conference in Berlin concerning

creating advanced data types using structures. The examples are in the
presentation available on my web site.



Interesting! I'd better take a look there then!

Thanks for your reply!

Johnny



--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info:  http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html

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



Re: [api-dev] Pause execution of script for user input into spreadsheet

2007-01-29 Thread Mathias Bauer
TerryJ wrote:

> Mathias Bauer wrote:
>> TerryJ wrote:
>>   
>>> An example of its use would be to have the script navigate to various 
>>> locations in the spreadsheet and pause for input by the user at each 
>>> location.
>>
>> Waiting is bad - it creates a loop that can cause reentrance problems.
>> It's better to end macro execution and install a listener for an event
>> to be triggered by user input. Perhaps if you described what kind of
>> user input you are talking about we could find out which listener is
>> possible.
> 
> Thank you for the reply.  I was hoping for a solution suitable for more
> general use.
> 
> Typically, some data is typed and the ENTER (return) key is used to
> place it in the cell.
> 
> The ENTER key will be used each time data is entered but the desired
> result is that the cell pointer would then move to the next location in
> the series, not to the same location each time.
> 
> I suppose you would need to install and remove the listener on each
> occasion.  {?} was so much simpler and seemed to have no undesirable
> results - no loops and no difficulty proceeding.  It was in use for many
> years in Lotus 123 and, evidently, in QuattroPro, so there was nothing
> shonky about it.

It should be enough to install a single, permanent listener. I'm not a
Calc expert, perhaps a "SelectionChangedListener" (how ever it is named)
or something else is available to achieve this. Perhaps a Calc expert
drops by here to give more detailed advice.

Ciao,
Mathias


-- 
Mathias Bauer (mba) - Project Lead OpenOffice.org Writer
OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS
Please don't reply to "[EMAIL PROTECTED]".
I use it for the OOo lists and only rarely read other mails sent to it.

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



Re: [api-dev] Re: Variant vs other types...

2007-01-29 Thread Johnny Andersson

Thanks for your interesting reply!

Parts of original messages and comments and maybe more questions below:

2007/1/29, Andrew Douglas Pitonyak <[EMAIL PROTECTED]>:


Johnny Andersson wrote:
> Maybe I should put it another way:
>
> Let's say that I have these lines, among others:
>
>
>Dim Ctl As Object
>Dim Doc As Object, Sheet As Object
>
>Dim A As String
>Dim  OBDef As Double ' Or whatever, it doesn't seem to matter in this
> case, see further below...
>
>Doc=ThisComponent
>Sheet=Doc.Sheets.getByName("Blah")
>
>OBDef=DataSheet.getCellRangeByPosition(4,1,9,3).getDataArray() ' Now
> OBDef seems to change to Variant.

You have a Calc sheet and you return a cell range based on its position.
Next, you call getDataArray() on the cell range.

The "official" return type is sequence< sequence< any > >, which means
an array of arrays of variants. My opinion is that this should cause an
error because an array of arrays of any should not be assigned to a
double unless the type can be "coerced" or "cast" into the double type.
so, you found a but (that has been around a long time) in StarBasic. I
rarely think about it because it has never caused me any problems. There
might be some reason for the behavior but I am not aware of the reasons.



So it is an array of arrays? That explains what happens when I copy it to a
variable: The variable is shown as MyVariable(x)(y) rather than
MyVariable(x,y) in the "Basic debugger" (I called it "Övervakaren"
before, I just found out that it's actually "Bevakaren", but in this case
it's just about the same thing).

If you wanted the specific values, i expect you to write something like

this:

Dim oData()
Dim oRow()
Dim i%, j%
Dim s$

s = ""
oData() = DataSheet.getCellRangeByPosition(4,1,9,3).getDataArray()
For i=LBound(oData()) To UBound(oData())
  oRow() = oData(i)
  For j = LBound(oRow()) To UBound(oRow())
s = s & " " & CStr(oRow(j))
  Next
  s = s & CHR$(10)
Next
MsgBox s




What do you really want to accomplish? Do you want to copy a range of
data from one location to another? If so, you can use methods to
directly copy the data. I have used "cheat" methods such as

oCellRange1.setData(oCellRange2.getData())



No, a function will use the data (and other data) for calculation. The
function will return a value that will be written to another cell. The
function will be in a loop and use three of the values (one
column), different every time.



> Another solution would perharps be to create a struct (as it's called
> in C),
> but is that possible in OpenOffice.org Basic?
Yes, you can create a user defined structure/type. To quote from my
AndrewMacro.odt document.


1.1. User Defined Data Types
As of OOo 1.1.1, you can define your own data types.
Listing 5.51: You can define your own data types.
Type PersonType
  FirstName As String
  LastName As String
End Type

Sub ExampleCreateNewType
  Dim Person As PersonType
  Person.FirstName = "Andrew"
  Person.LastName  = "Pitonyak"
  PrintPerson(Person)
End Sub

Sub PrintPerson(x)
  Print "Person = " & x.FirstName & " " & x.LastName
End Sub



Wow, I didn't know that! Now I have to rewrite everything macro and
every function I've made so far..!
They are not that many, on the other hand...

In your example above, is the following possible?

Sub ExampleCreateNewType
 Dim Person(100) As PersonType
 Person(0).FirstName = "Andrew"
 Person(0).LastName  = "Pitonyak"
 PrintPerson(Person(0))
End Sub


And is the following possible?

Type PersonType
 FirstName As String
 LastName As String
 ThingsToDo(9) As String
End Type

And finally, is the following possible?

Type PersonType
 FirstName As String
 LastName As String
End Type

Type Human
 Properties As PersonType
 Friends(9) As PersonType
End Type


And even more finally, is there something similar to pointers in
OpenOffice.org Basic?

I gave a presentation at the 2004 OOo Conference in Berlin concerning

creating advanced data types using structures. The examples are in the
presentation available on my web site.



Interesting! I'd better take a look there then!

Thanks for your reply!

Johnny


Re: [api-dev] Pause execution of script for user input into spreadsheet

2007-01-29 Thread TerryJ

Mathias Bauer wrote:

TerryJ wrote:

  
Someone has asked about this in the forum and I believe there is no 
provision in the API for this.  I used such code with another 
spreadsheet and the person enquiring now has used similar code with 
other software.


An example of its use would be to have the script navigate to various 
locations in the spreadsheet and pause for input by the user at each 
location.


It occurs to me that an issue could be filed requesting such a feature.  
Is there already a method in the API which can be used to write such a 
routine?



Waiting is bad - it creates a loop that can cause reentrance problems.
It's better to end macro execution and install a listener for an event
to be triggered by user input. Perhaps if you described what kind of
user input you are talking about we could find out which listener is
possible.

Ciao,
Mathias


Thank you for the reply.  I was hoping for a solution suitable for more
general use.

Typically, some data is typed and the ENTER (return) key is used to
place it in the cell.

The ENTER key will be used each time data is entered but the desired
result is that the cell pointer would then move to the next location in
the series, not to the same location each time.

I suppose you would need to install and remove the listener on each
occasion.  {?} was so much simpler and seemed to have no undesirable
results - no loops and no difficulty proceeding.  It was in use for many
years in Lotus 123 and, evidently, in QuattroPro, so there was nothing
shonky about it.

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



RE: [api-dev] Macro writer to get filename document

2007-01-29 Thread Jurgen van Doorn
Thanx Stephan. I'm going to try this.
Regards,Jurgen
 
 



Van: Stephan Wunderlich [mailto:[EMAIL PROTECTED]
Verzonden: ma 29-1-2007 9:53
Aan: dev@api.openoffice.org
Onderwerp: Re: [api-dev] Macro writer to get filename document



Hi Jurgen,

> I'm looking for code to get the filename of the current document in 
> writer.
> In MS word is it like Activedocument.name but in Openoffice?

you can query the XModel from your document, which has a method getURL
() that should do what you want.

Regards

Stephan

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




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

Re: [api-dev] Macro writer to get filename document

2007-01-29 Thread Stephan Wunderlich

Hi Jurgen,

I'm looking for code to get the filename of the current document in  
writer.

In MS word is it like Activedocument.name but in Openoffice?


you can query the XModel from your document, which has a method getURL 
() that should do what you want.


Regards

Stephan

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



[api-dev] Macro writer to get filename document

2007-01-29 Thread Jurgen van Doorn
Hi,
 
I'm looking for code to get the filename of the current document in writer.
In MS word is it like Activedocument.name but in Openoffice?
 
 
Kind regards, met vriendelijke groet,
 
Jurgen van Doorn
 
de Realisatiegroep BV
Utrechtseweg 79
1213 TM  Hilversum
 
M. 06 - 143 58 858
T.  035 - 62 22 170
F.  035 - 62 22 171
E.  [EMAIL PROTECTED]  
W. www.derealisatiegroep.nl  

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

Re: [api-dev] Pause execution of script for user input into spreadsheet

2007-01-29 Thread Mathias Bauer
TerryJ wrote:

> Someone has asked about this in the forum and I believe there is no 
> provision in the API for this.  I used such code with another 
> spreadsheet and the person enquiring now has used similar code with 
> other software.
> 
> An example of its use would be to have the script navigate to various 
> locations in the spreadsheet and pause for input by the user at each 
> location.
> 
> It occurs to me that an issue could be filed requesting such a feature.  
> Is there already a method in the API which can be used to write such a 
> routine?

Waiting is bad - it creates a loop that can cause reentrance problems.
It's better to end macro execution and install a listener for an event
to be triggered by user input. Perhaps if you described what kind of
user input you are talking about we could find out which listener is
possible.

Ciao,
Mathias

-- 
Mathias Bauer (mba) - Project Lead OpenOffice.org Writer
OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS
Please don't reply to "[EMAIL PROTECTED]".
I use it for the OOo lists and only rarely read other mails sent to it.

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