| View previous topic :: View next topic |
| Author |
Message |
matthewp General User

Joined: 02 Jan 2009 Posts: 19
|
Posted: Tue Oct 20, 2009 8:46 am Post subject: How do I set the properties for an XTextTable using C#? |
|
|
Discussion on Stack Overflow
In python, I can do something like this:
| Code: | table.BreakType = PAGE_BEFORE
table.HoriOrient = 0
table.RightMargin = 6.93 * 2540 - table_width |
In C#, I can't find a way to set properties. XTableTable only has a few methods available to it, and none of them seem to do anything like this. How do I set properties in C#?[/url] |
|
| Back to top |
|
 |
phazzy Power User

Joined: 26 Mar 2009 Posts: 60 Location: Bucharest, Romania
|
Posted: Wed Oct 21, 2009 6:05 am Post subject: |
|
|
Hello,
Now you acces your TextTable by its XTextTable interface, but the TextTable service provides many interfaces.
You have to instantiate the XPropertySet interface of the XTextTable.
| Code: |
// Example
XPropertySet tablePropSet = (XPropertySet)textTable;
// This is how you set a property in C#
// You have to create a new Any object to pass it as parameter
tablePropSet.setPropertyValue("HeaderRowCount", new Any(typeof(int), 1));
|
Look through the API :
http://api.openoffice.org/docs/common/ref/com/sun/star/beans/XPropertySet.html |
|
| Back to top |
|
 |
matthewp General User

Joined: 02 Jan 2009 Posts: 19
|
Posted: Wed Oct 21, 2009 1:06 pm Post subject: |
|
|
Thanks phazzy,
I can't figure out how to create an Any object. Using your code (new Any(...)) doesn't work, because the compiler doesn't recognize the Any object:
| Code: | | The type or namespace name `Any' could not be found. Are you missing a using directive or an assembly reference?(CS0246) |
This page doesn't really help, and this page makes it sound like Any is in the uno namespace, but I am already using this namespace:
| Code: | | using unoidl.com.sun.star.uno; |
Of course, the documentation I linked to is for Java, so perhaps it is different for C#. Any ideas? |
|
| Back to top |
|
 |
phazzy Power User

Joined: 26 Mar 2009 Posts: 60 Location: Bucharest, Romania
|
Posted: Thu Oct 22, 2009 12:42 am Post subject: |
|
|
The Any structure is in the uno namespace :
| Code: |
using System;
namespace uno
{
public struct Any
{
public static Any VOID;
public Any(bool value);
public Any(byte value);
public Any(char value);
public Any(double value);
public Any(float value);
public Any(int value);
public Any(long value);
public Any(short value);
public Any(string value);
public Any(Type value);
public Any(uint value);
public Any(ulong value);
public Any(ushort value);
public Any(Type type, object value);
public Type Type { get; }
public object Value { get; }
public bool Equals(Any obj);
public override bool Equals(object obj);
public override int GetHashCode();
public bool hasValue();
public void setValue(Type type, object value);
public override string ToString();
}
|
So, you have to include just uno : using uno;
Also, make sure you included all OO dll's as references in your project. You have to include all the dll's in the directory OFFICE_HOME\program\assembly (path valid for 2.x)
From what I see above, in uno.Any structure definition, for the basic types it has a simpler constructor, but you can use the 2-args one anyway. |
|
| Back to top |
|
 |
matthewp General User

Joined: 02 Jan 2009 Posts: 19
|
Posted: Thu Oct 22, 2009 6:18 pm Post subject: |
|
|
| Thanks phazzy, using the uno namespace (instead of just unoidl.com.sun.star.uno) solved my problem. |
|
| Back to top |
|
 |
phazzy Power User

Joined: 26 Mar 2009 Posts: 60 Location: Bucharest, Romania
|
Posted: Fri Oct 23, 2009 12:31 am Post subject: |
|
|
Glad I helped. You can add [SOLVED] to your thread for others to know taht have similar problems.
Cheers,
phazzy |
|
| Back to top |
|
 |
|