[Probably Solved - Sorry] simplify OOXML / document.xml

Post your questions, bug reports and suggestions here for TextMaker 2018 for Linux.

Moderator: SoftMaker Team

Post Reply
User avatar
Michael Uplawski
Posts: 172
Joined: Thu Dec 11, 2014 11:43 pm
Location: Canton Magny (previously Canton Carrouges), Orne, Normandy (previously Lower Normandy)

[Probably Solved - Sorry] simplify OOXML / document.xml

Post by Michael Uplawski » Sat Dec 01, 2018 8:07 am

All that follows concerns TextMaker, not PlanMaker, although I speak of tables. The more perceptive among you will notice this anyway, but I want to keep the uproar manageable. Thank You. :)

Good morning.

In the attempt to facilitate and automate some tasks in SoftMaker Office, I am already transforming the XML-code of the document-xml file, included in the *.tmdx archives to other formats.

Now I am about to automate the creation of new tables in TextMaker, i.e. the creation of a new document, containing a basic, initial table which may already contain some values and/or properties. For the time I concentrate on the tmdx-format (which is, more or less, OOXML) and will not invest time in ODF.

The Question to a larger public than that of the German speaking SoftMaker Forum (for a change): Does anybody know, if table-properties, more exactly cell-properties can be centralized somewhere and how to do it? There is a styles.xml file and THERE IS information on the Web... However, and although my current ability to do quite a few nifty things with XML does not certify complete dumbness on my side, I DO NOT GET IT !!

Chances are, nobody does.

I confront you with a concrete example, anyway. What follows is the definition of 1 table-cell from an original document.xml, with lines that can be commented out or deleted without TextMaker choking on the new resulting XML-code. What I want to know, for now, is how the definitions in the <w:tcBorders/> tag can be centralized. You can remove the tag completely in an attempt to reduce work, but then you lose the table-borders. You cannot define an empty tag <w:tcBorders/>, as TextMaker does then complain about the format of the new document.

Code: Select all

<w:tc>
          <w:tcPr>
            <!--
            <w:tcW w:w="1665" w:type="pct" />
            <w:tcMar>
              <w:top w:w="56" w:type="dxa" />
              <w:left w:w="56" w:type="dxa" />
              <w:bottom w:w="56" w:type="dxa" />
              <w:right w:w="56" w:type="dxa" />
            </w:tcMar>
            -->
            <w:tcBorders>
              <w:top w:val="single" w:sz="4" w:space="0"
              w:color="000000" tmln="10, 20, 20, 0, 0" />
              <w:left w:val="single" w:sz="4" w:space="0"
              w:color="000000" tmln="10, 20, 20, 0, 0" />
              <w:bottom w:val="single" w:sz="4" w:space="0"
              w:color="000000" tmln="10, 20, 20, 0, 0" />
              <w:right w:val="single" w:sz="4" w:space="0"
              w:color="000000" tmln="10, 20, 20, 0, 0" />
              <w:tl2br w:val="nil" w:sz="0" w:space="0"
              w:color="000000" tmln="20, 20, 20, 0, 0" />
              <w:tr2bl w:val="nil" w:sz="0" w:space="0"
              w:color="000000" tmln="20, 20, 20, 0, 0" />
            </w:tcBorders>
            <w:tmTcPr id="1543646498" protected="0" />
          </w:tcPr>
          <w:p>
            <w:r>
              <w:t>1.1.2011</w:t>
            </w:r>
          </w:p>
        </w:tc>
Beware that.., if you happen to know stuff, I may come back and ask for more... :twisted:

I can automate the creation of a tcBorders tag to all cells, but apart from bloating up the document (as it does already), this conflicts with my sense of ... whatever... beauty? Efficiency? Error-Proneness... maybe. It looks procedural and I already hate that...
On the other hand, a generator cannot be made intelligent enough to liberate us of just all these boring tasks, else it becomes a weapon. For suicide, mainly, but anyway.

Edits: Many attempts to render this comprehensible. All may fail.
Hindsight is in the eye of the beholder.

User avatar
Michael Uplawski
Posts: 172
Joined: Thu Dec 11, 2014 11:43 pm
Location: Canton Magny (previously Canton Carrouges), Orne, Normandy (previously Lower Normandy)

Re: [Probably Solved - Sorry] simplify OOXML / document.xml

Post by Michael Uplawski » Sat Dec 01, 2018 12:12 pm

I found one working solution on the Web, from a source that I considered unreliable as it confuses me more than it helps, most of the time... But darn. This works.

My error or misunderstanding comes from the fact, that I tried to style table-cells, not whole tables. Now it looks like the cell-style is part of a table-style, when you define it in the styles.xml file. At least, something like this in styles.xml:

Code: Select all

 <w:style w:type="table" w:styleId="DefTableStyle">
    <w:name w:val="Default Table Style"/>
    <w:basedOn w:val="TableNormal"/>
    <w:tblPr>
      <w:tblBorders>
        <w:top w:val="single" w:sz="4" w:space="0" w:color="FF0000"/>
        <w:left w:val="single" w:sz="18" w:space="0" w:color="FF0000"/>
        <w:bottom w:val="single" w:sz="4" w:space="0" w:color="auto"/>
      </w:tblBorders>
    </w:tblPr>
    <w:tblStylePr w:type="firstRow">
      <w:rPr>
        <w:b/>
      </w:rPr>
      <w:tcPr>
        <w:shd w:val="clear" w:color="auto" w:fill="ED1C24"/>
      </w:tcPr>
    </w:tblStylePr>
  </w:style>
produces a document like this:
sc_styled_table_tmdx.png
sc_styled_table_tmdx.png (3.13 KiB) Viewed 358 times
And now you can eliminate all occurences of the border-styles from the document.xml without fearing punishment from TextMaker.

Here is the tmdx-file:
new_test.tmdx
(10.86 KiB) Downloaded 28 times
This is much better, than styling each cell inline, although there is still overhead. I do not need conditional styles, but the w:tblStylePr tag appears to be mandatory in styles.xml! If you know something about that...

I will mark this as solved, however.
Hindsight is in the eye of the beholder.

Post Reply

Return to “TextMaker 2018 for Linux”