tdf#133030: DOCX export: fix formula alignment - part 3

Follow-up of commit 1237acf9851f8b12d1ccd929e2aa8b184c06d552
(tdf#132811 DOCX: fix formula alignment – part 2)

Co-authored-by: Tibor Nagy (NISZ)

Change-Id: I5466649a2aa6b7ffdb0def723f79dfbecdf1495f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93665
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
diff --git a/include/oox/mathml/export.hxx b/include/oox/mathml/export.hxx
index 5711337..e9589a0 100644
--- a/include/oox/mathml/export.hxx
+++ b/include/oox/mathml/export.hxx
@@ -28,8 +28,9 @@ class OOX_DLLPUBLIC FormulaExportBase
public:
    virtual void writeFormulaOoxml(::sax_fastparser::FSHelperPtr pSerializer,
            oox::core::OoxmlVersion version,
            oox::drawingml::DocumentType documentType) = 0;
            oox::drawingml::DocumentType documentType, sal_Int8 nAlign) = 0;
    virtual void writeFormulaRtf( OStringBuffer& rBuffer, rtl_TextEncoding nEncoding ) = 0;
    enum eFormulaAlign { INLINE, CENTER, GROUPEDCENTER, LEFT, RIGHT };

protected:
    FormulaExportBase();
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 214c4bc..9a6a72b 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -1955,7 +1955,8 @@ void ShapeExport::WriteMathShape(Reference<XShape> const& xShape)

    oox::FormulaExportBase *const pMagic(dynamic_cast<oox::FormulaExportBase*>(xMathModel.get()));
    assert(pMagic);
    pMagic->writeFormulaOoxml(GetFS(), GetFB()->getVersion(), GetDocumentType());
    pMagic->writeFormulaOoxml(GetFS(), GetFB()->getVersion(), GetDocumentType(),
        FormulaExportBase::eFormulaAlign::INLINE);

    mpFS->endElementNS(XML_a14, XML_m);
    mpFS->endElementNS(XML_a, XML_p);
diff --git a/starmath/inc/document.hxx b/starmath/inc/document.hxx
index 3fedfb1..1b425c9 100644
--- a/starmath/inc/document.hxx
+++ b/starmath/inc/document.hxx
@@ -207,7 +207,8 @@ public:

    void writeFormulaOoxml(const ::sax_fastparser::FSHelperPtr& pSerializer,
            oox::core::OoxmlVersion version,
            oox::drawingml::DocumentType documentType);
            oox::drawingml::DocumentType documentType,
            const sal_Int8 nAlign);
    void writeFormulaRtf(OStringBuffer& rBuffer, rtl_TextEncoding nEncoding);
    void readFormulaOoxml( oox::formulaimport::XmlStream& stream );

diff --git a/starmath/inc/unomodel.hxx b/starmath/inc/unomodel.hxx
index b2b536d..f18b093 100644
--- a/starmath/inc/unomodel.hxx
+++ b/starmath/inc/unomodel.hxx
@@ -86,7 +86,7 @@ public:
    // oox::FormulaExportBase
    virtual void writeFormulaOoxml(::sax_fastparser::FSHelperPtr pSerializer,
            oox::core::OoxmlVersion version,
            oox::drawingml::DocumentType documentType) override;
            oox::drawingml::DocumentType documentType, sal_Int8 nAlign) override;
    virtual void writeFormulaRtf(OStringBuffer& rBuffer, rtl_TextEncoding nEncoding) override;
    // oox::FormulaImportBase
    virtual void readFormulaOoxml( oox::formulaimport::XmlStream& stream ) override;
diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx
index 6449421..8f9925c 100644
--- a/starmath/source/document.cxx
+++ b/starmath/source/document.cxx
@@ -83,6 +83,7 @@
#include "cfgitem.hxx"
#include <memory>
#include <utility>
#include <oox/mathml/export.hxx>

using namespace ::com::sun::star;
using namespace ::com::sun::star::accessibility;
@@ -854,14 +855,18 @@ bool SmDocShell::ConvertTo( SfxMedium &rMedium )
void SmDocShell::writeFormulaOoxml(
        ::sax_fastparser::FSHelperPtr const& pSerializer,
        oox::core::OoxmlVersion const version,
        oox::drawingml::DocumentType const documentType)
        oox::drawingml::DocumentType const documentType,
        const sal_Int8 nAlign)
{
    if( !mpTree )
        Parse();
    if( mpTree )
        ArrangeFormula();
    SmOoxmlExport aEquation(mpTree.get(), version, documentType);
    aEquation.ConvertFromStarMath( pSerializer );
    if(documentType == oox::drawingml::DOCUMENT_DOCX)
        aEquation.ConvertFromStarMath( pSerializer, nAlign);
    else
        aEquation.ConvertFromStarMath(pSerializer, oox::FormulaExportBase::eFormulaAlign::INLINE);
}

void SmDocShell::writeFormulaRtf(OStringBuffer& rBuffer, rtl_TextEncoding nEncoding)
diff --git a/starmath/source/ooxmlexport.cxx b/starmath/source/ooxmlexport.cxx
index f52c727..fff9cd7 100644
--- a/starmath/source/ooxmlexport.cxx
+++ b/starmath/source/ooxmlexport.cxx
@@ -13,6 +13,7 @@
#include <oox/token/tokens.hxx>
#include <rtl/ustring.hxx>
#include <sal/log.hxx>
#include <oox/mathml/export.hxx>

using namespace oox;
using namespace oox::core;
@@ -25,15 +26,57 @@ SmOoxmlExport::SmOoxmlExport(const SmNode *const pIn, OoxmlVersion const v,
{
}

void SmOoxmlExport::ConvertFromStarMath( const ::sax_fastparser::FSHelperPtr& serializer )
void SmOoxmlExport::ConvertFromStarMath( const ::sax_fastparser::FSHelperPtr& serializer, const sal_Int8 nAlign )
{
    if( m_pTree == nullptr )
        return;
    m_pSerializer = serializer;
    m_pSerializer->startElementNS( XML_m, XML_oMath,
        FSNS( XML_xmlns, XML_m ), "http://schemas.openxmlformats.org/officeDocument/2006/math" );
    HandleNode( m_pTree, 0 );
    m_pSerializer->endElementNS( XML_m, XML_oMath );

    //Formula alignment situations:
    //
    //  1)Inline(as before):
    //
    //      <m:oMath>
    //          <m:r>  ... </m:r>
    //      </m:oMath>
    //
    //  2)Aligned:
    //
    //      <m:oMathPara>
    //          <m:oMathParaPr>
    //              <m:jc m:val="left|right|center">
    //          </m:oMathParaPr>
    //          <m:oMath>
    //              <m:r>  ... </m:r>
    //          </m:oMath>
    //      </m:oMathPara>

    if (nAlign != FormulaExportBase::eFormulaAlign::INLINE)
    {
        m_pSerializer->startElementNS(XML_m, XML_oMathPara,
            FSNS(XML_xmlns, XML_m), "http://schemas.openxmlformats.org/officeDocument/2006/math");
        m_pSerializer->startElementNS(XML_m, XML_oMathParaPr);
        if (nAlign == FormulaExportBase::eFormulaAlign::CENTER)
            m_pSerializer->singleElementNS(XML_m, XML_jc, FSNS(XML_m, XML_val), "center");
        if (nAlign == FormulaExportBase::eFormulaAlign::GROUPEDCENTER)
            m_pSerializer->singleElementNS(XML_m, XML_jc, FSNS(XML_m, XML_val), "center");
        if (nAlign == FormulaExportBase::eFormulaAlign::LEFT)
            m_pSerializer->singleElementNS(XML_m, XML_jc, FSNS(XML_m, XML_val), "left");
        if (nAlign == FormulaExportBase::eFormulaAlign::RIGHT)
            m_pSerializer->singleElementNS(XML_m, XML_jc, FSNS(XML_m, XML_val), "right");
        m_pSerializer->endElementNS(XML_m, XML_oMathParaPr);
        m_pSerializer->startElementNS(XML_m, XML_oMath);
        HandleNode(m_pTree, 0);
        m_pSerializer->endElementNS(XML_m, XML_oMath);
        m_pSerializer->endElementNS(XML_m, XML_oMathPara);
    }
    else //else, inline as was before
    {
        m_pSerializer->startElementNS(XML_m, XML_oMath,
            FSNS(XML_xmlns, XML_m), "http://schemas.openxmlformats.org/officeDocument/2006/math");
        HandleNode( m_pTree, 0 );
        m_pSerializer->endElementNS( XML_m, XML_oMath );
    }
}

// NOTE: This is still work in progress and unfinished, but it already covers a good
diff --git a/starmath/source/ooxmlexport.hxx b/starmath/source/ooxmlexport.hxx
index f7e05d7..fec33ab 100644
--- a/starmath/source/ooxmlexport.hxx
+++ b/starmath/source/ooxmlexport.hxx
@@ -24,7 +24,7 @@ class SmOoxmlExport : public SmWordExportBase
public:
    SmOoxmlExport(const SmNode* pIn, oox::core::OoxmlVersion version,
            oox::drawingml::DocumentType documentType);
    void ConvertFromStarMath( const ::sax_fastparser::FSHelperPtr& m_pSerializer );
    void ConvertFromStarMath( const ::sax_fastparser::FSHelperPtr& m_pSerializer, const sal_Int8 );
private:
    void HandleVerticalStack( const SmNode* pNode, int nLevel ) override;
    void HandleText( const SmNode* pNode, int nLevel ) override;
diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx
index 62c2aeb6..17d52ce 100644
--- a/starmath/source/unomodel.cxx
+++ b/starmath/source/unomodel.cxx
@@ -1077,9 +1077,9 @@ void SAL_CALL SmModel::setParent( const uno::Reference< uno::XInterface >& xPare
void SmModel::writeFormulaOoxml(
        ::sax_fastparser::FSHelperPtr const pSerializer,
        oox::core::OoxmlVersion const version,
        oox::drawingml::DocumentType const documentType)
        oox::drawingml::DocumentType const documentType, sal_Int8 nAlign)
{
    static_cast<SmDocShell*>(GetObjectShell())->writeFormulaOoxml(pSerializer, version, documentType);
    static_cast<SmDocShell*>(GetObjectShell())->writeFormulaOoxml(pSerializer, version, documentType, nAlign);
}

void SmModel::writeFormulaRtf(OStringBuffer& rBuffer, rtl_TextEncoding nEncoding)
diff --git a/sw/qa/extras/ooxmlexport/data/tdf133030.docx b/sw/qa/extras/ooxmlexport/data/tdf133030.docx
new file mode 100644
index 0000000..e23f09a
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf133030.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index 60725f0..10b55a3 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -193,6 +193,15 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf130120, "tdf130120.docx")
        "mc:Choice/w:drawing/wp:anchor", "layoutInCell", "0");
}

DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(Tdf133030, "tdf133030.docx")
{
    auto pExport = parseExport("word/document.xml");
    CPPUNIT_ASSERT(pExport);

    assertXPath(pExport, "/w:document/w:body/w:p[3]/m:oMathPara/m:oMathParaPr/m:jc", "val", "center");
    assertXPath(pExport, "/w:document/w:body/w:p[5]/m:oMathPara/m:oMathParaPr/m:jc", "val", "left");
    assertXPath(pExport, "/w:document/w:body/w:p[7]/m:oMathPara/m:oMathParaPr/m:jc", "val", "right");
}

DECLARE_OOXMLEXPORT_TEST(testTdf87569v, "tdf87569_vml.docx")
{
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
index 109c961..4df9baf 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
@@ -998,7 +998,7 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testFileOpenInputOutputError,"floatingtbl_wi
    assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:pStyle", "val", "Normal");

    // let's also assert that the formula was exported properly
    assertXPathContent(pXmlDoc, "//w:tbl/w:tr/w:tc[2]/w:p/m:oMath/m:sSubSup/m:e/m:r/m:t", u"\u03C3");
    assertXPathContent(pXmlDoc, "//w:tbl/w:tr/w:tc[2]/w:p/m:oMathPara/m:oMath/m:sSubSup/m:e/m:r/m:t", u"\u03C3");
}

DECLARE_OOXMLEXPORT_TEST(testSingleCellTableBorders, "tdf124399_SingleCellTableBorders.docx")
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
index 621cc13..4dd7062 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
@@ -619,7 +619,7 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(test_Tdf115030, "tdf115030.docx")
    sal_Unicode aDobleDot = {0x00A8};
    assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/m:oMath[1]/m:acc/m:accPr/m:chr", "val", OUString(aDot));
    assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/m:oMath[2]/m:acc/m:accPr/m:chr", "val", OUString(aDobleDot));
    assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/m:oMath[1]/m:acc/m:accPr/m:chr", "val", OUString(aDot));
    assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/m:oMathPara/m:oMath[1]/m:acc/m:accPr/m:chr", "val", OUString(aDot));
}

DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(test_OpeningBrace, "2120112713_OpenBrace.docx")
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 590fcfd..16c9e51 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -143,6 +143,7 @@
#include <stdarg.h>

#include <toolkit/helper/vclunohelper.hxx>
#include <oox/mathml/export.hxx>

using ::editeng::SvxBorderLine;

@@ -1559,7 +1560,7 @@ void DocxAttributeOutput::EndRun(const SwTextNode* pNode, sal_Int32 nPos, bool /
    DoWritePermissionsEnd();

    for (const auto& rpMath : m_aPostponedMaths)
        WritePostponedMath(rpMath);
        WritePostponedMath(rpMath.pMathObject, rpMath.nMathObjAlignment);
    m_aPostponedMaths.clear();

    for (const auto& rpControl : m_aPostponedFormControls)
@@ -5086,11 +5087,11 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size
    m_rExport.SdrExporter().endDMLAnchorInline(pFrameFormat);
}

void DocxAttributeOutput::WriteOLE2Obj( const SdrObject* pSdrObj, SwOLENode& rOLENode, const Size& rSize, const SwFlyFrameFormat* pFlyFrameFormat )
void DocxAttributeOutput::WriteOLE2Obj( const SdrObject* pSdrObj, SwOLENode& rOLENode, const Size& rSize, const SwFlyFrameFormat* pFlyFrameFormat, const sal_Int8 nFormulaAlignment )
{
    if( WriteOLEChart( pSdrObj, rSize, pFlyFrameFormat ))
        return;
    if( WriteOLEMath( rOLENode ))
    if( WriteOLEMath( rOLENode , nFormulaAlignment))
        return;
    PostponeOLE( rOLENode, rSize, pFlyFrameFormat );
}
@@ -5185,18 +5186,28 @@ void DocxAttributeOutput::WritePostponedChart()
    m_aPostponedCharts.clear();
}

bool DocxAttributeOutput::WriteOLEMath( const SwOLENode& rOLENode )
bool DocxAttributeOutput::WriteOLEMath( const SwOLENode& rOLENode ,const sal_Int8 nAlign)
{
    uno::Reference < embed::XEmbeddedObject > xObj(const_cast<SwOLENode&>(rOLENode).GetOLEObj().GetOleRef());
    SvGlobalName aObjName(xObj->getClassID());

    if( !SotExchange::IsMath(aObjName) )
        return false;
    m_aPostponedMaths.push_back(&rOLENode);

    PostponedMathObjects aPostponedMathObject;
    try
    {
        aPostponedMathObject.pMathObject = const_cast<SwOLENode*>( &rOLENode);
        aPostponedMathObject.nMathObjAlignment = nAlign;
        m_aPostponedMaths.push_back(aPostponedMathObject);
    }
    catch (const uno::Exception&)
    {
    }
    return true;
}

void DocxAttributeOutput::WritePostponedMath(const SwOLENode* pPostponedMath)
void DocxAttributeOutput::WritePostponedMath(const SwOLENode* pPostponedMath, sal_Int8 nAlign)
{
    uno::Reference < embed::XEmbeddedObject > xObj(const_cast<SwOLENode*>(pPostponedMath)->GetOLEObj().GetOleRef());
    if (embed::EmbedStates::LOADED == xObj->getCurrentState())
@@ -5223,7 +5234,7 @@ void DocxAttributeOutput::WritePostponedMath(const SwOLENode* pPostponedMath)
    assert( formulaexport != nullptr );
    if (formulaexport)
        formulaexport->writeFormulaOoxml( m_pSerializer, GetExport().GetFilter().getVersion(),
                oox::drawingml::DOCUMENT_DOCX);
                oox::drawingml::DOCUMENT_DOCX, nAlign);
}

void DocxAttributeOutput::WritePostponedFormControl(const SdrObject* pObject)
@@ -5765,7 +5776,35 @@ void DocxAttributeOutput::OutputFlyFrame_Impl( const ww8::Frame &rFrame, const P
                {
                    SwNodeIndex aIdx(*rFrameFormat.GetContent().GetContentIdx(), 1);
                    SwOLENode& rOLENd = *aIdx.GetNode().GetOLENode();
                    WriteOLE2Obj( pSdrObj, rOLENd, rFrame.GetLayoutSize(), dynamic_cast<const SwFlyFrameFormat*>( &rFrameFormat ));

                    //output variable for the formula alignment (default inline)
                    sal_Int8 nAlign(FormulaExportBase::eFormulaAlign::INLINE);
                    auto xObj(rOLENd.GetOLEObj().GetOleRef()); //get the xObject of the forumla

                    //tdf133030: Export formula position
                    //If we have a formula with inline anchor...
                    if(SotExchange::IsMath(xObj->getClassID()) && rFrame.IsInline())
                    {
                        SwPosition const* const aAPos = rFrameFormat.GetAnchor().GetContentAnchor();
                        if(aAPos)
                        {
                            //Get the text node what the forumla anchored to
                            const SwTextNode* pTextNode = aAPos->nNode.GetNode().GetTextNode();
                            if(pTextNode && pTextNode->Len() == 1)
                            {
                                //Get the paragraph alignment
                                auto aParaAdjust = pTextNode->GetSwAttrSet().GetAdjust().GetAdjust();
                                //And set the formula according to the paragraph alignment
                                if (aParaAdjust == SvxAdjust::Center)
                                    nAlign = FormulaExportBase::eFormulaAlign::CENTER;
                                else if (aParaAdjust == SvxAdjust::Right)
                                    nAlign = FormulaExportBase::eFormulaAlign::RIGHT;
                                else // left in the case of left and justified paragraph alignments
                                    nAlign = FormulaExportBase::eFormulaAlign::LEFT;
                            }
                        }
                    }
                    WriteOLE2Obj( pSdrObj, rOLENd, rFrame.GetLayoutSize(), dynamic_cast<const SwFlyFrameFormat*>( &rFrameFormat ), nAlign);
                    m_bPostponedProcessingFly = false ;
                }
            }
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 083a0fd..83e3110 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -403,9 +403,9 @@ private:
    /// @see WriteOLE2Obj()
    void FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size& rSize, const SwFlyFrameFormat* pOLEFrameFormat, SwOLENode* pOLENode, const SdrObject* pSdrObj = nullptr);
    void WriteSrcRect( const SdrObject* pSdrObj, const SwFrameFormat* pFrameFormat );
    void WriteOLE2Obj( const SdrObject* pSdrObj, SwOLENode& rNode, const Size& rSize, const SwFlyFrameFormat* pFlyFrameFormat);
    void WriteOLE2Obj( const SdrObject* pSdrObj, SwOLENode& rNode, const Size& rSize, const SwFlyFrameFormat* pFlyFrameFormat, const sal_Int8 nFormulaAlignment);
    bool WriteOLEChart( const SdrObject* pSdrObj, const Size& rSize, const SwFlyFrameFormat* pFlyFrameFormat);
    bool WriteOLEMath( const SwOLENode& rNode );
    bool WriteOLEMath( const SwOLENode& rNode, const sal_Int8 nAlign );
    void PostponeOLE( SwOLENode& rNode, const Size& rSize, const SwFlyFrameFormat* pFlyFrameFormat );
    void WriteOLE( SwOLENode& rNode, const Size& rSize, const SwFlyFrameFormat* rFlyFrameFormat );

@@ -700,7 +700,7 @@ private:

    void DoWriteAnnotationMarks( );
    void WritePostponedGraphic();
    void WritePostponedMath(const SwOLENode* pObject);
    void WritePostponedMath(const SwOLENode* pObject, sal_Int8 /*nAlign*/);
    void WritePostponedFormControl(const SdrObject* pObject);
    void WritePostponedActiveXControl(bool bInsideRun);
    void WritePostponedDiagram();
@@ -901,7 +901,12 @@ private:
    };
    std::unique_ptr< std::vector<PostponedOLE> > m_pPostponedOLEs;

    std::vector<const SwOLENode*> m_aPostponedMaths;
    struct PostponedMathObjects
    {
        SwOLENode* pMathObject;
        sal_Int8 nMathObjAlignment;
    };
    std::vector<PostponedMathObjects> m_aPostponedMaths;
    /// count charts consistently for unit tests
    unsigned int m_nChartCount;
    struct PostponedChart
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index d9e97d1..db0a03f 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -682,7 +682,7 @@ public:
    void appendTextContent(const css::uno::Reference<css::text::XTextContent>&, const css::uno::Sequence<css::beans::PropertyValue>&);
    void appendOLE( const OUString& rStreamName, const std::shared_ptr<OLEHandler>& pOleHandler );
    void appendStarMath( const Value& v);
    void adjustLastPara(sal_Int8);
    void adjustLastPara(sal_Int8 nAlign);
    css::uno::Reference<css::beans::XPropertySet> appendTextSectionAfter(css::uno::Reference<css::text::XTextRange> const & xBefore);

    /// AutoText import: each entry is placed in the separate section