09/04/2008

C#: Creating Tables in Open Office using C#.... Open Office Sucks and So Does Your Face

OK ... you're going to have to use your imagination a bit here because there is too much code to put everything in here ... the basic premise is as such:

// get the row counts out of my parameter => MyUserDefinedCustomTableObject is obviously a class in my app - and no, it is not a DataTable it is a Generic Matrix.
int RowCount = MyUserDefinedCustomTableObject.Rows.Count;

// get the col counts out of ma parameter
int ColCount = MyUserDefinedCustomTableObject.Rows[0].Cells.Count;

// create a context consisting of the oo bootstrap
unoidl.com.sun.star.uno.XComponentContext localContext = uno.util.Bootstrap.bootstrap();

// create a service factory to get shit from
unoidl.com.sun.star.lang.XMultiServiceFactory multiServiceFactory = (unoidl.com.sun.star.lang.XMultiServiceFactory )localContext.getServiceManager();

// create a component loader to get stuff from
XComponentLoader componentLoader = (XComponentLoader)multiServiceFactory.createInstance( "com.sun.star.frame.Desktop");

// create a frame which is basically the document reference
XFrame frame = ((unoidl.com.sun.star.text.XTextDocument)xComponent).getCurrentController().getFrame();

// the tricky part, create a dispatch helper - this is the work horse
XDispatchHelper xDispatchHelper = (XDispatchHelper )multiServiceFactory.createInstance( "com.sun.star.frame.DispatchHelper");

// this is only used if you want to set bookmark text within the table cells ... we use bookmarks as placeholders where there will be text in the future.
XNameAccess xna = ((XBookmarksSupplier)xComponent).getBookmarks();

// Create the property values - this uses a local function that I'm not nice enough to give you but on a primitive level it is propertyvalue.Name = first param, propertyvalue.value = 2nd param.
PropertyValue[] tableArgs = new unoidl.com.sun.star.beans.PropertyValue[4];
tableArgs[0] = CreateNewProperty("TableName", new uno.Any(MyUserDefinedCustomTableObject.TableName));
tableArgs[1] = CreateNewProperty("Columns", new uno.Any(ColCount));
tableArgs[2] = CreateNewProperty("Rows", new uno.Any(RowCount));

// check to determine if we should show borders
if (MyUserDefinedCustomTableObject.ShowBorders)
tableArgs[3] = CreateNewProperty("Flags", new uno.Any(9));
else
tableArgs[3] = CreateNewProperty("Flags", new uno.Any(8));

// dispatch the table creation event to the UI ...
xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertTable", "", 0, tableArgs);

// you have a table in your document, the cursor is usually in the first cell of the table so you can use this function to jump between cells and insert text / bookmarks.
xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:JumpToNextCell", "", 0, new unoidl.com.sun.star.beans.PropertyValue[0]);

// if you are in a table cell and want to set the text of that cell then you can use this
cellTextArgs[0] = CreateNewProperty("Text", new uno.Any("My lovely text i love you text"));
xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertText", "", 0, cellTextArgs);

// if you want to insert a bookmark into the cell you could try this (note you do not have to be in a table cell for this to insert a bookmark).
PropertyValue[] cellBkmkArgs = new unoidl.com.sun.star.beans.PropertyValue[1];
cellBkmkArgs[0] = CreateNewProperty("Bookmark", new uno.Any(cell.CellBookmark));
xDispatchHelper.executeDispatch((XDispatchProvider)frame, ".uno:InsertBookmark", "", 0, cellBkmkArgs);

Over and Out

Please Sign Mayor David Millers Handgun Ban Petition

Please sign Mayor David Millers Handgun Ban Petition. You can do it online. It takes all of 2 mins. Even if you hate David Miller this is worth it. Think about your children.

Click below, then click "Sign the Petition", type in your name and address and click submit.
http://www.toronto.ca/handgunban/index.htm

Facts below,

Cheers,

Matt

IMPACT OF FIREARMS IN CANADA, FACT SHEET:

Canadian police services reported 8,105 victims of violent gun crime, ranging from assault to
robbery and homicide in 2006 – a rate of almost 1 person per hour victimized by violent
gun crime.

On average more than 1,200 Canadians are killed and over 1,000 injured with firearms
each year. The economic costs of gun deaths and injuries in Canada are estimated at $6
billion per year.

Impact on Children and Youth
  1. Firearms deaths are the third leading cause of death among young people aged 15-24.3
  2. Among 26 industrialized countries, Canada ranks fifth in the rate of firearm deaths among children under the age of 14 years.4 In 2004/2005, 49 Ontario children aged 10-14 required emergency department visits due to firearm injuries.
  3. Youth (12-17 years) accused of committing a violent offence are more likely than adults to use a firearm. In 2006, Canadian police services reported 1,287 youth accused of a firearm-related violent offence – a rate of over 3 youths per day accused of a firearm-related violent offence.
  4. The national rate of youth accused of a firearm-related violent crime increased by 32% between 2002 and 2006, with the 2006 rate being the highest point recorded since Statistics Canada began making data available in 1998.
  5. The 2006 rates of youth accused of a firearm-related violent crime in Toronto (96.2 per 100,000 youth) is well above the national average (55.5) and higher than all other Canadian Census Metropolitan Areas (CMAs).

07/04/2008

The Grid vs. The Internet .... now what about The Google ...

Blah Blah Blah ... this is actually kind of neat. I wonder how far away from this we really are. Science has a habit of producing vapor-ware, but this may be different. It may become a necessity.

Unfortunately, I believe the internet will be private before this Grid goes mainstream. Rogers has started capping my bandwidth at 95GB per month, about 1/3 of my typical usage pattern. They are then charging $1.50 for each additional GB. IPTV goes right out the window. Then they try to offer me deep discounts on Cable - forcing me to use their service offerings. Ghetto.

Now how would wireless work on top of this grid thing?

“Projects like the grid will bring huge changes in business and society as well as science,” Doyle said.

“Holographic video conferencing is not that far away. Online gaming could evolve to include many thousands of people, and social networking could become the main way we communicate.

“The history of the internet shows you cannot predict its real impacts but we know they will be huge.”

Read The Article: The Grid

Over and Out