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 INCLUDED_SW_SOURCE_FILTER_WW8_DOCXFOOTNOTES_HXX
21 : #define INCLUDED_SW_SOURCE_FILTER_WW8_DOCXFOOTNOTES_HXX
22 :
23 : #include <vector>
24 :
25 : class SwFmtFtn;
26 :
27 : namespace docx {
28 :
29 : typedef ::std::vector< const SwFmtFtn* > FootnotesVector;
30 :
31 : /** Remember footnotes/endnotes so that we can dump them in one go.
32 :
33 : Also rememeber the last added footnote Id to be able to write it in the
34 : DocxAttributeOutput::EndRunProperties() method.
35 : */
36 544 : class FootnotesList {
37 : /// The current footnote, that was not written yet.
38 : sal_Int32 m_nCurrent;
39 :
40 : /// List of the footnotes.
41 : FootnotesVector m_aFootnotes;
42 :
43 : public:
44 544 : FootnotesList() : m_nCurrent( -1 ) {}
45 :
46 5 : void add( const SwFmtFtn& rFootnote )
47 : {
48 5 : m_aFootnotes.push_back( &rFootnote );
49 5 : m_nCurrent = m_aFootnotes.size() - 1;
50 5 : }
51 :
52 : /// Return the current footnote/endnote and clear the 'current' state.
53 12985 : const SwFmtFtn* getCurrent( sal_Int32& rId )
54 : {
55 : // anything to write at all?
56 12985 : if ( m_nCurrent < 0 )
57 : {
58 12980 : rId = -1;
59 12980 : return NULL;
60 : }
61 :
62 : // skip ids 0 and 1 - they are reserved for separator and
63 : // continuationSeparator
64 5 : rId = m_nCurrent + 2;
65 :
66 5 : const SwFmtFtn *pFootnote = m_aFootnotes[m_nCurrent];
67 5 : m_nCurrent = -1;
68 :
69 5 : return pFootnote;
70 : }
71 :
72 : /// Return all the footnotes/endnotes.
73 3 : const FootnotesVector& getVector() const
74 : {
75 3 : return m_aFootnotes;
76 : }
77 :
78 : /// Do we have any footnotes/endnotes at all?
79 1684 : bool isEmpty() const
80 : {
81 1684 : return m_aFootnotes.empty();
82 : }
83 : };
84 :
85 : } // namespace docx
86 :
87 : #endif // INCLUDED_SW_SOURCE_FILTER_WW8_DOCXFOOTNOTES_HXX
88 :
89 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|