Categories > [old] TbsOoo & TinyDoc >

[var.x] replacement in Oo chart

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: SunWuKung
Date: 2006-04-07
Time: 17:04

[var.x] replacement in Oo chart

Hi,
I am new to TBS and experimenting with its capabilities.
I wanted to generate dynamic charts with Oo and TBS and started to look how could I do it.

Simply opening the content XML and inserting [var.x] in the text worked as expected, but when I did the same in with the XML in the Object 1 folder (where the chart definition is) I find that [var.x] doesn't get replaced with its value.

I had this assumption that [var.x] simply gets replaced with its value wherever it occures - what do I do wrong here and what would be the solution?

Thanks for the help.
SWK
By: Olivier Loynet
Date: 2006-04-07
Time: 19:58

Re: [var.x] replacement in Oo chart

Send me your files to have a look

Olivier
By: SunWuKung
Date: 2006-04-07
Time: 21:44

Re: [var.x] replacement in Oo chart

Hi Oliver,
it is clear now what is happening - the unzip function only unzips and processes the content.xml it finds in the root directory.
It seems however that the properties of a chart (and probably anything else that you insert as a separate object) in a document has another folder within the zip file and within its folder it has a separate content.xml file.

My suggestion is to look into the zip file first to find all the content.xml files and their paths unzip and process them one by one than zip them back to where they came from.
Being able to do dynamic charts this way sounds good I guess.
I would do it myself but my programming skills are pathetic.

On other subjects:
Although you write that one can't put a picture into the document dynamically I hope one can insert a picture by linking it instead of copy - at least you can do that in MSWord so I am sure you can here as well. Since Oo must store the filename somewhere in theory I see no reason why that couldn't be substituted with a variable.

One more question:
All the demo docs use Oo version 1 file formats. Is there anything in TBS (except the extension) specific to v1 or I can use it with v2 files as well?


Thanks for your help.
SWK

By: Olivier Loynet
Date: 2006-04-07
Time: 22:11

Re: [var.x] replacement in Oo chart

Hello,

There is a little bug in the class with the ZIP parameters. It will be correct in next version. You can change in the class :
    exec($this->_zip_bin.' -u -j -m '.$this->_ooo_basename.'.'.$this->_ooo_file_ext.' '.$this->_ooo_basename.'/'.$this->_xml_filename);

by
    exec($this->_zip_bin.' -j -m '.$this->_ooo_basename.'.'.$this->_ooo_file_ext.' '.$this->_ooo_basename.'/'.$this->_xml_filename);

> On other subjects:
> Although you write that one can't put a picture into the document dynamically
> I hope one can insert a picture by linking it instead of copy - at least you can do that in MSWord so I am sure you can here as well.
> Since Oo must store the filename somewhere in theory I see no reason why that couldn't be substituted with a variable.

For image substitution, I write some code, but it's work only with PHP5, because of the native XML functions in PHP5.
I will release that in a next version who works with TBS 3.0

> One more question:
> All the demo docs use Oo version 1 file formats. Is there anything in
> TBS (except the extension) specific to v1 or I can use it with v2 files as well?

tbsOOo work with all the OOo format, V1 and V2.

Olivier
By: SunWuKung
Date: 2006-04-08
Time: 00:44

Re: [var.x] replacement in Oo chart

Thanks for your reply - it is very good to hear that TBS is developed so actively.

The issue I raised - I think - relates to the unzip line of LoadXmlFromDoc:

// unzip the XML files
    exec($this->_unzip_bin.' '.$this->_ooo_basename.'.'.$this->_ooo_file_ext.' -d '.$this->_ooo_basename.' '.$this->_xml_filename);

this unzip will only extract one content.xml - the one that is sitting in the root directory. There could be other content.xml files in the Oo document - eg. creating a chart would create an Object 1 directory in the Oo file with a content.xml document in it. Since this file is not extracted it remains invisible to TBS. The LoadXmlFromDoc function should process all content.xml files in the Oo document.
By: Olivier Loynet
Date: 2006-04-08
Time: 10:10

Re: [var.x] replacement in Oo chart

Hi,

IHMO, I think it's not useful to extract all files from the OOo document, because the main used files are 'content.xml', 'styles.xml' and 'meta.xml'
By example if there are big files (like pictures or else), why extract them ?

Olivier
By: SunWuKung
Date: 2006-04-08
Time: 12:48

Re: [var.x] replacement in Oo chart

True, there is no point in extracting files that TBS wouldn't process anyway. But I think these files that TBS does process should be processed even if they are in a subfolder of an Oo document.
Eg.
You create a document and place some text in it.
Than you have a 'content.xml', 'styles.xml' and 'meta.xml' in the root of the document. TBS processes them and life is fine.

Than you insert a chart into the document.
Oo creates a subfolder called Object 1 and puts all the relevant info about the chart there in a 'content.xml' and 'styles.xml' file. But TBS is not looking into subfolders so these files are not processed and life is poorer with dynamic charting.