Exemplo n.º 1
0
void Document::finishDocument()
{
    kDebug(30513);

    const wvWare::Word97::DOP& dop = m_parser->dop();

    Q_ASSERT(m_mainStyles);

    if (m_mainStyles) {
        QString footnoteConfig("<text:notes-configuration "
                               "text:note-class=\"footnote\" "
                               "text:default-style-name=\"Footnote\" "
                               "text:citation-style-name=\"Footnote_20_Symbol\" "
                               "text:citation-body-style-name=\"Footnote_20_anchor\" "
                               "text:master-page-name=\"Footnote\" "
                               "style:num-format=\"%1\" "
                               "text:start-value=\"%2\" "
                               "text:footnotes-position=\"%3\" "
                               "text:start-numbering-at=\"%4\" "
                               "/>");
        //FIXME: If document that has an nFib <= 0x00D9, then use DOP.  Else
        //use the info from SEP (sprmSFpc, sprmSRncFtn, sprmSNFtn, sprmSNfcFtnRef).
        m_mainStyles->insertRawOdfStyles(KoGenStyles::DocumentStyles,
                                         footnoteConfig.arg(Conversion::numberFormatCode(dop.nfcFtnRef2))
                                         .arg(dop.nFtn)
                                         .arg(Conversion::fpcToFtnPosition(dop.fpc))
                                         .arg(Conversion::rncToStartNumberingAt(dop.rncFtn))
                                         .toLatin1());

        // MS Word has start-numbering-at (rncEdn) for endnotes, but ODF doesn't really support it
        QString endnoteConfig("<text:notes-configuration "
                              "text:note-class=\"endnote\" "
                              "text:default-style-name=\"Endnote\" "
                              "text:citation-style-name=\"Endnote_20_Symbol\" "
                              "text:citation-body-style-name=\"Endnote_20_anchor\" "
                              "text:master-page-name=\"Endnote\" "
                              "style:num-format=\"%1\" "
                              "text:start-value=\"%2\" "
                              //"text:start-numbering-at=\"%3\" "
                              "/>");

        //FIXME: If document that has an nFib <= 0x00D9, then use DOP.  Else
        //use the info from SEP (sprmSFEndnote, sprmSRncEdn, sprmSNEdn, sprmSNfcEdnRef).
        m_mainStyles->insertRawOdfStyles(KoGenStyles::DocumentStyles,
                                         endnoteConfig.arg(Conversion::numberFormatCode(dop.nfcEdnRef2))
                                         .arg(dop.nEdn)
                                         // .arg(Conversion::rncToStartNumberingAt(dop.rncEdn))
                                         .toLatin1());
    }
}
Exemplo n.º 2
0
//set whether or not document has header or footer
//set tabstop value
//add footnote settings & endnote settings
//write out header & footer type
//write out picture information
void Document::finishDocument()
{
    kDebug(30513);

    //finish a header if we need to - this should only be necessary if there's
    //an even header w/o an odd header
//     if (m_oddOpen) {
//         QString contents = QString::fromUtf8(m_buffer->buffer(), m_buffer->buffer().size());
//         m_masterStyle->addChildElement(QString::number(m_headerCount), contents);

//         m_oddOpen = false;
//         delete m_headerWriter;
//         m_headerWriter = 0;
//         delete m_buffer;
//         m_buffer = 0;
//         //we're done with this header, so reset to false
//         m_writingHeader = false;
//     }

    const wvWare::Word97::DOP& dop = m_parser->dop();

    m_initialFootnoteNumber = dop.nFtn;
    m_initialEndnoteNumber = dop.nEdn;

    //"tabStopValue", (double)dop.dxaTab / 20.0

    Q_ASSERT(m_mainStyles);
    if (m_mainStyles) {

        QString footnoteConfig("<text:notes-configuration "
                               "text:note-class=\"footnote\" "
                               "text:default-style-name=\"Footnote\" "
                               "text:citation-style-name=\"Footnote_20_Symbol\" "
                               "text:citation-body-style-name=\"Footnote_20_anchor\" "
                               "text:master-page-name=\"Footnote\" "
                               "style:num-format=\"%1\" "
                               "text:start-value=\"%2\" "
                               "text:footnotes-position=\"page\" "
                               "text:start-numbering-at=\"%3\" "
                               "/>");

        m_mainStyles->insertRawOdfStyles(KoGenStyles::DocumentStyles,
                                         footnoteConfig.arg(Conversion::numberFormatCode(dop.nfcFtnRef2))
                                                       .arg(m_initialFootnoteNumber)
                                                       .arg(Conversion::rncToStartNumberingAt(dop.rncFtn))
                                                       .toLatin1());

        // ms-word has start-numbering-at (rncEdn) for endnotes, but ODF doesn't really support it
        QString endnoteConfig("<text:notes-configuration "
                              "text:note-class=\"endnote\" "
                              "text:default-style-name=\"Endnote\" "
                              "text:citation-style-name=\"Endnote_20_Symbol\" "
                              "text:citation-body-style-name=\"Endnote_20_anchor\" "
                              "text:master-page-name=\"Endnote\" "
                              "style:num-format=\"%1\" "
                              "text:start-value=\"%2\" "
                              //"text:start-numbering-at=\"%3\" "
                              "/>");

        m_mainStyles->insertRawOdfStyles(KoGenStyles::DocumentStyles,
                                         endnoteConfig.arg(Conversion::numberFormatCode(dop.nfcEdnRef2))
                                                      .arg(m_initialEndnoteNumber)
//                                                           .arg(Conversion::rncToStartNumberingAt(dop.rncEdn))
                                                      .toLatin1());
    }
//     QDomElement elementDoc = m_mainDocument.documentElement();
//     QDomElement element;
//     element = m_mainDocument.createElement("ATTRIBUTES");
//     element.setAttribute("processing",0); // WP
//     char allHeaders = ( wvWare::HeaderData::HeaderEven |
//                         wvWare::HeaderData::HeaderOdd |
//                         wvWare::HeaderData::HeaderFirst );
//     element.setAttribute("hasHeader", m_headerFooters & allHeaders ? 1 : 0 );
//     char allFooters = ( wvWare::HeaderData::FooterEven |
//                         wvWare::HeaderData::FooterOdd |
//                         wvWare::HeaderData::FooterFirst );
//     element.setAttribute("hasFooter", m_headerFooters & allFooters ? 1 : 0 );
//     //element.setAttribute("unit","mm"); // How to figure out the unit to use?

//     element.setAttribute("tabStopValue", (double)dop.dxaTab / 20.0 );
//     elementDoc.appendChild(element);

//     // Done at the end: write the type of headers/footers,
//     // depending on which kind of headers and footers we received.
//     QDomElement paperElement = elementDoc.namedItem("PAPER").toElement();
//     Q_ASSERT ( !paperElement.isNull() ); // slotSectionFound should have been called!
//     if ( !paperElement.isNull() ) {
//         kDebug(30513) <<"m_headerFooters=" << m_headerFooters;
//         paperElement.setAttribute("hType", Conversion::headerMaskToHType( m_headerFooters ) );
//         paperElement.setAttribute("fType", Conversion::headerMaskToFType( m_headerFooters ) );
//     }

//     // Write out <PICTURES> tag
//     QDomElement picturesElem = m_mainDocument.createElement("PICTURES");
//     elementDoc.appendChild( picturesElem );
//     for( QStringList::Iterator it = m_pictureList.begin(); it != m_pictureList.end(); ++it ) {
//         QDomElement keyElem = m_mainDocument.createElement("KEY");
//         picturesElem.appendChild( keyElem );
//         keyElem.setAttribute( "filename", *it );
//         keyElem.setAttribute( "name", *it );
//     }
}