Hi,
The API does not support columns. As I was told, the tables are
organized in rows and cells. That would explain, why the Any.Value
cannot be casted to a XPropertySet, because it is not implemented. This
does not work in Java either.
So the Developer's Guide is right, saying that getByIndex supporty
XInterface only.
--Joachim
Florian Limberger wrote:
Hi!
> Have you checked the type within the Any:
>
> Type t = Any.Type;
--
System.Type type = cols.getByIndex(i).Type;
Console.WriteLine(type.ToString());
--
Yields: System.Object
OOo2 did not install anything into the assembly cache on my pc. So I'm
using the assemblies in the ./OpenOffice.org 1.9.109/program/assembly
directory. So far everything has worked correctly (Document creation,
text insertion, table insertion, etc..) except setting properties of the
XTableColumns elements.
Is it for sure, that it's possible to access the PropertySet of the
TextTable-Column?
(OO-Dev-Manual "Text Documents" under section "7.3.4 Tables", where the
Methods in XTabelColumns are described, says, that getByIndex() supports
the XInterface only. Does this mean, that I can not access the
XPopertySet?)
Here comes an example-code:
----------------------------------------------------------------------------
using System;
using unoidl.com.sun.star.lang;
using unoidl.com.sun.star.uno;
using unoidl.com.sun.star.bridge;
using unoidl.com.sun.star.frame;
using unoidl.com.sun.star.container;
using unoidl.com.sun.star.text;
using unoidl.com.sun.star.table;
using unoidl.com.sun.star.beans;
namespace OpenOfficeWrapper
{
class Test
{
static void Main(string[] args)
{
unoidl.com.sun.star.lang.XMultiServiceFactory
ooMSFactory
=
(XMultiServiceFactory)uno.util.Bootstrap.bootstrap().getServiceManager();
XComponentLoader aLoader = (XComponentLoader)
ooMSFactory.createInstance( "com.sun.star.frame.Desktop" );
XComponent xComponent = aLoader.loadComponentFromURL(
"private:factory/swriter", "_blank", 0,
new unoidl.com.sun.star.beans.PropertyValue[0] );
XTextDocument ooDoc = (XTextDocument)xComponent;
XMultiServiceFactory docFactory = (XMultiServiceFactory)ooDoc;
XTextTable xTable = (XTextTable)
docFactory.createInstance("com.sun.star.text.TextTable");
XNamed name = (XNamed)xTable;
name.setName("TestTable");
xTable.initialize(2,2);
XText xText = ooDoc.getText();
xText.insertTextContent(xText.getStart(),xTable,false);
XText xCellText = (XText)xTable.getCellByName("A1");
xCellText.setString("A1");
xCellText = (XText)xTable.getCellByName("B1");
xCellText.setString("B1");
XTableColumns cols = xTable.getColumns();
for(int i=0;i<cols.getCount();i++)
{
XPropertySet props =
(XPropertySet)cols.getByIndex(i).Value;
props.setPropertyValue("OptimalWidth",new uno.Any(true));
}
}
}
}
----------------------------------------------------------------------------
Joachim Lingner wrote:
Have you checked the type within the Any:
Type t = Any.Type;
If it is XPropertySet type, then there seems to be bug. Could you then
provide a stripped down (but still buildable) example that lets me
reproduce this problem?
BTW, I assume you are NOT using the assemblies which were once
provided through the udk.openoffice.org website. Instead one needs to
use the cli-uno bridge and assemblies which are automatically
installed with OOo2.
Joachim
Florian Limberger wrote:
Hi,
I'm using C# with cli-uno to control OO. I want to set the
column-property "OptimalWidth" of a TextTable to true.
Casting the column to a XPropertySet does not work (invalid cast).
Does anyone know, how to set the OptimalWidth of a whole TextTable ?
cheers
Flo
----------------------------------------------------------------
XTextTable table = null;
XMultiServiceFactory factory = (XMultiServiceFactory)doc;
table = (XTextTable)
factory.createInstance("com.sun.star.text.TextTable");
XTableColumns cols = table.getColumns();
int count = cols.getCount();
for(int i=0;i<cols.getCount();i++)
{
XPropertySet props = (XPropertySet)cols.getByIndex(i).Value;
props.setPropertyValue("OptimalWidth",new uno.Any(true));
}
----------------------------------------------------------------
---------------------------------------------------------------------
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]
---------------------------------------------------------------------
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]