Пример по протезированию здесь
http://sourceforge.net/p/mw2odf/home/Home/В общем дальше записки охотника (буду живодерить QTextOdfWriter) учитывая мой уровень
думаю это затянется
итак
экспериментировать решил с приведенным выше кодом немного его поменяв
C++ (Qt)
void TestsToOdf::test(){
QString text;
QTextBlockFormat format;
QTextCharFormat chformat;
QTextTableFormat StTableFormat;
QTextTableCell cell;
QVector<QTextLength> constraints;
constraints << QTextLength(QTextLength::PercentageLength, 20);
constraints << QTextLength(QTextLength::PercentageLength, 80);
StTableFormat.setBorder(10);
//StTableFormat.setBorderBrush(Qt::cyan);
text = QString("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
cursor.insertText(text);
StTableFormat.setBorderStyle(QTextFrameFormat::BorderStyle_Ridge);
StTableFormat.setWidth(QTextLength(QTextLength::PercentageLength, 100));
StTableFormat.setColumnWidthConstraints(constraints);
cursor.insertTable(1, 2, StTableFormat);
QTextTable *StTable = cursor.currentTable();
StTable->setName("StTable");
//StTable->setObjectName("StTableObject");
cursor.setBlockFormat(format);
cursor.movePosition(QTextCursor::PreviousRow);
text = QString("1");
cursor.setCharFormat(chformat);
cursor.insertText(text);
cursor.movePosition(QTextCursor::NextCell);
text = QString("2");
StTable->appendRows(1);
cursor.movePosition(QTextCursor::End);
}
данный метод вызывал два раза чтобы получить две одинаковые таблицы в документе. после чего полученный одф распаковал zip.ОМ и обнаружилась горстка файлов где основное зодчество в content.xml следущего содержания
XML
<office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0">
<office:automatic-styles>
<style:style style:name="c0" style:family="text">
<style:text-properties fo:font-family="Sans"/>
</style:style>
<style:style style:name="p1" style:family="paragraph">
<style:paragraph-properties/>
</style:style>
<style:style style:name="s2" style:family="section">
<style:section-properties/>
</style:style>
<style:style style:name="T3" style:family="table">
<style:table-properties/>
</style:style>
<style:style style:name="T5" style:family="table">
<style:table-properties/>
</style:style>
</office:automatic-styles>
<office:body>
<office:text>
<text:p text:style-name="p1"><text:span text:style-name="c0">FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF</text:span></text:p>
<table:table>
<table:table-column table:number-columns-repeated="2"/>
<table:table-row>
<table:table-cell table:style-name="T3">
<text:p text:style-name="p1"><text:span text:style-name="c0">1</text:span></text:p>
</table:table-cell>
<table:table-cell table:style-name="T3">
<text:p text:style-name="p1"/>
</table:table-cell>
</table:table-row>
<table:table-row>
<table:table-cell table:style-name="T3">
<text:p text:style-name="p1"/>
</table:table-cell>
<table:table-cell table:style-name="T3">
<text:p text:style-name="p1"/>
</table:table-cell>
</table:table-row>
</table:table>
<text:p text:style-name="p1"><text:span text:style-name="c0">FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF</text:span></text:p>
<table:table>
<table:table-column table:number-columns-repeated="2"/>
<table:table-row>
<table:table-cell table:style-name="T5">
<text:p text:style-name="p1"><text:span text:style-name="c0">1</text:span></text:p>
</table:table-cell>
<table:table-cell table:style-name="T5">
<text:p text:style-name="p1"/>
</table:table-cell>
</table:table-row>
<table:table-row>
<table:table-cell table:style-name="T5">
<text:p text:style-name="p1"/>
</table:table-cell>
<table:table-cell table:style-name="T5">
<text:p text:style-name="p1"/>
</table:table-cell>
</table:table-row>
</table:table>
<text:p text:style-name="p1"/>
</office:text>
</office:body>
</office:document-content>
состояние строк
<style:style style:name="T3" style:family="table">
<style:table-properties/>
</style:style>
тонко намикает на то что чембы не открывать границ и форматирования не будет стили пустые
решил посмотреть как должно быть. Открыл сотворенный файл опенОфисом ручками поставил границы и изменил размер первого (из всех двух) столбца первой таблицы. после сохранения и распаковки получилось следующие
XML
<office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" office:version="1.2" grddl:transformation="http://docs.oasis-open.org/office/1.2/xslt/odf2rdf.xsl">
<office:scripts/>
<office:font-face-decls>
<style:font-face style:name="Sans" svg:font-family="Sans"/>
<style:font-face style:name="Times New Roman" svg:font-family="'Times New Roman'" style:font-family-generic="roman" style:font-pitch="variable"/>
<style:font-face style:name="Arial Unicode MS" svg:font-family="'Arial Unicode MS'" style:font-family-generic="system" style:font-pitch="variable"/>
<style:font-face style:name="Tahoma" svg:font-family="Tahoma" style:font-family-generic="system" style:font-pitch="variable"/>
</office:font-face-decls>
<office:automatic-styles>
<style:style style:name="Table1" style:family="table">
<style:table-properties style:width="17.013cm" fo:margin-left="0cm" fo:margin-right="-0.012cm" table:align="margins"/>
</style:style>
<style:style style:name="Table1.A" style:family="table-column">
<style:table-column-properties style:column-width="1.508cm" style:rel-column-width="855*"/>
</style:style>
<style:style style:name="Table1.B" style:family="table-column">
<style:table-column-properties style:column-width="15.505cm" style:rel-column-width="8790*"/>
</style:style>
<style:style style:name="Table1.A1" style:family="table-cell">
<style:table-cell-properties fo:padding="0.097cm" fo:border-left="0.002cm solid #000000" fo:border-right="none" fo:border-top="0.002cm solid #000000" fo:border-bottom="0.002cm solid #000000"/>
</style:style>
<style:style style:name="Table1.B1" style:family="table-cell">
<style:table-cell-properties fo:padding="0.097cm" fo:border="0.002cm solid #000000"/>
</style:style>
<style:style style:name="Table1.A2" style:family="table-cell">
<style:table-cell-properties fo:padding="0.097cm" fo:border-left="0.002cm solid #000000" fo:border-right="none" fo:border-top="none" fo:border-bottom="0.002cm solid #000000"/>
</style:style>
<style:style style:name="Table1.B2" style:family="table-cell">
<style:table-cell-properties fo:padding="0.097cm" fo:border-left="0.002cm solid #000000" fo:border-right="0.002cm solid #000000" fo:border-top="none" fo:border-bottom="0.002cm solid #000000"/>
</style:style>
<style:style style:name="Table2" style:family="table">
<style:table-properties style:width="17cm" table:align="margins"/>
</style:style>
<style:style style:name="Table2.A" style:family="table-column">
<style:table-column-properties style:column-width="8.5cm" style:rel-column-width="32767*"/>
</style:style>
<style:style style:name="Table2.B" style:family="table-column">
<style:table-column-properties style:column-width="8.5cm" style:rel-column-width="32768*"/>
</style:style>
<style:style style:name="Table2.A1" style:family="table-cell">
<style:table-cell-properties fo:padding="0.097cm" fo:border-left="0.002cm solid #000000" fo:border-right="none" fo:border-top="0.002cm solid #000000" fo:border-bottom="0.002cm solid #000000"/>
</style:style>
<style:style style:name="Table2.B1" style:family="table-cell">
<style:table-cell-properties fo:padding="0.097cm" fo:border="0.002cm solid #000000"/>
</style:style>
<style:style style:name="Table2.A2" style:family="table-cell">
<style:table-cell-properties fo:padding="0.097cm" fo:border-left="0.002cm solid #000000" fo:border-right="none" fo:border-top="none" fo:border-bottom="0.002cm solid #000000"/>
</style:style>
<style:style style:name="Table2.B2" style:family="table-cell">
<style:table-cell-properties fo:padding="0.097cm" fo:border-left="0.002cm solid #000000" fo:border-right="0.002cm solid #000000" fo:border-top="none" fo:border-bottom="0.002cm solid #000000"/>
</style:style>
<style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard">
<style:text-properties style:font-name="Sans"/>
</style:style>
</office:automatic-styles>
<office:body>
<office:text>
<text:sequence-decls>
<text:sequence-decl text:display-outline-level="0" text:name="Illustration"/>
<text:sequence-decl text:display-outline-level="0" text:name="Table"/>
<text:sequence-decl text:display-outline-level="0" text:name="Text"/>
<text:sequence-decl text:display-outline-level="0" text:name="Drawing"/>
</text:sequence-decls>
<text:p text:style-name="P1">FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF</text:p>
<table:table table:name="Table1" table:style-name="Table1">
<table:table-column table:style-name="Table1.A"/>
<table:table-column table:style-name="Table1.B"/>
<table:table-row>
<table:table-cell table:style-name="Table1.A1" office:value-type="string">
<text:p text:style-name="P1">1</text:p>
</table:table-cell>
<table:table-cell table:style-name="Table1.B1" office:value-type="string">
<text:p text:style-name="Standard"/>
</table:table-cell>
</table:table-row>
<table:table-row>
<table:table-cell table:style-name="Table1.A2" office:value-type="string">
<text:p text:style-name="Standard"/>
</table:table-cell>
<table:table-cell table:style-name="Table1.B2" office:value-type="string">
<text:p text:style-name="Standard"/>
</table:table-cell>
</table:table-row>
</table:table>
<text:p text:style-name="P1">FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF</text:p>
<table:table table:name="Table2" table:style-name="Table2">
<table:table-column table:style-name="Table2.A"/>
<table:table-column table:style-name="Table2.B"/>
<table:table-row>
<table:table-cell table:style-name="Table2.A1" office:value-type="string">
<text:p text:style-name="P1">1</text:p>
</table:table-cell>
<table:table-cell table:style-name="Table2.B1" office:value-type="string">
<text:p text:style-name="Standard"/>
</table:table-cell>
</table:table-row>
<table:table-row>
<table:table-cell table:style-name="Table2.A2" office:value-type="string">
<text:p text:style-name="Standard"/>
</table:table-cell>
<table:table-cell table:style-name="Table2.B2" office:value-type="string">
<text:p text:style-name="Standard"/>
</table:table-cell>
</table:table-row>
</table:table>
<text:p text:style-name="Standard"/>
</office:text>
</office:body>
</office:document-content>
Только а оригинале не Table1.A например а Таблица1.A (наверное по тому что на сайте офиса предупреждали что он нашими перепилен спецально)