LCOV - code coverage report
Current view: top level - libreoffice/sw/source/filter/ww8 - docxfootnotes.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 9 18 50.0 %
Date: 2012-12-17 Functions: 4 6 66.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef _DOCXFOOTNOTES_HXX_
      21             : #define _DOCXFOOTNOTES_HXX_
      22             : 
      23             : #include <fmtftn.hxx>
      24             : 
      25             : #include <rtl/string.hxx>
      26             : #include <rtl/ustring.hxx>
      27             : #include <sax/fshelper.hxx>
      28             : 
      29             : #include <vector>
      30             : 
      31             : namespace docx {
      32             : 
      33             : typedef ::std::vector< const SwFmtFtn* > FootnotesVector;
      34             : 
      35             : /** Remember footnotes/endnotes so that we can dump them in one go.
      36             : 
      37             :     Also rememeber the last added footnote Id to be able to write it in the
      38             :     DocxAttributeOutput::EndRunProperties() method.
      39             : */
      40          96 : class FootnotesList {
      41             :     /// The current footnote, that was not written yet.
      42             :     sal_Int32 m_nCurrent;
      43             : 
      44             :     /// List of the footnotes.
      45             :     FootnotesVector m_aFootnotes;
      46             : 
      47             : public:
      48          96 :     FootnotesList() : m_nCurrent( -1 ) {}
      49             : 
      50           0 :     void add( const SwFmtFtn& rFootnote )
      51             :     {
      52           0 :         m_aFootnotes.push_back( &rFootnote );
      53           0 :         m_nCurrent = m_aFootnotes.size() - 1;
      54           0 :     }
      55             : 
      56             :     /// Return the current footnote/endnote and clear the 'current' state.
      57         440 :     const SwFmtFtn* getCurrent( sal_Int32& rId )
      58             :     {
      59             :         // skip ids 0 and 1 - they are reserved for separator and
      60             :         // continuationSeparator
      61         440 :         rId = m_nCurrent + 2;
      62             : 
      63             :         // anything to write at all?
      64         440 :         if ( m_nCurrent < 0 )
      65             :         {
      66         440 :             rId = -1;
      67         440 :             return NULL;
      68             :         }
      69             : 
      70           0 :         const SwFmtFtn *pFootnote = m_aFootnotes[m_nCurrent];
      71           0 :         m_nCurrent = -1;
      72             : 
      73           0 :         return pFootnote;
      74             :     }
      75             : 
      76             :     /// Return all the footnotes/endnotes.
      77           0 :     const FootnotesVector& getVector() const
      78             :     {
      79           0 :         return m_aFootnotes;
      80             :     }
      81             : 
      82             :     /// Do we have any footnotes/endnotes at all?
      83         288 :     bool isEmpty() const
      84             :     {
      85         288 :         return m_aFootnotes.empty();
      86             :     }
      87             : };
      88             : 
      89             : } // namespace docx
      90             : 
      91             : #endif // _DOCXFOOTNOTES_HXX_
      92             : 
      93             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10