1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 #ifndef _DOCXFOOTNOTES_HXX_ 23 #define _DOCXFOOTNOTES_HXX_ 24 25 #include <fmtftn.hxx> 26 27 #include <rtl/string.hxx> 28 #include <rtl/ustring.hxx> 29 #include <sax/fshelper.hxx> 30 31 #include <vector> 32 33 namespace docx { 34 35 typedef ::std::vector< const SwFmtFtn* > FootnotesVector; 36 37 /** Remember footnotes/endnotes so that we can dump them in one go. 38 39 Also remember the last added footnote Id to be able to write it in the 40 DocxAttributeOutput::EndRunProperties() method. 41 */ 42 class FootnotesList { 43 // The current footnote, that was not written yet. 44 sal_Int32 m_nCurrent; 45 46 // List of the footnotes. 47 FootnotesVector m_aFootnotes; 48 49 public: FootnotesList()50 FootnotesList() : m_nCurrent( -1 ) {} 51 add(const SwFmtFtn & rFootnote)52 void add( const SwFmtFtn& rFootnote ) 53 { 54 m_aFootnotes.push_back( &rFootnote ); 55 m_nCurrent = m_aFootnotes.size() - 1; 56 } 57 58 // Return the current footnote/endnote and clear the 'current' state. getCurrent(sal_Int32 & rId)59 const SwFmtFtn* getCurrent( sal_Int32& rId ) 60 { 61 // skip ids 0 and 1 - they are reserved for separator and 62 // continuationSeparator 63 rId = m_nCurrent + 2; 64 65 // anything to write at all? 66 if ( m_nCurrent < 0 ) 67 { 68 rId = -1; 69 return NULL; 70 } 71 72 const SwFmtFtn *pFootnote = m_aFootnotes[m_nCurrent]; 73 m_nCurrent = -1; 74 75 return pFootnote; 76 } 77 78 // Return all the footnotes/endnotes. getVector() const79 const FootnotesVector& getVector() const 80 { 81 return m_aFootnotes; 82 } 83 84 // Do we have any footnotes/endnotes at all? isEmpty() const85 bool isEmpty() const 86 { 87 return m_aFootnotes.empty(); 88 } 89 }; 90 91 } // namespace docx 92 93 #endif // _DOCXFOOTNOTES_HXX_ 94 95 /* vim: set noet sw=4 ts=4: */ 96