update dev300-m58
[ooovba.git] / writerfilter / source / doctok / XNoteHelper.hxx
blob7da69d72f4856f5409341ac586e489a8dee2303f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: XNoteHelper.hxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef INCLUDED_X_NOTE_HELPER_HXX
32 #define INCLUDED_X_NOTE_HELPER_HXX
34 #ifndef INLCUED_PLCF_HXX
35 #include <PLCF.hxx>
36 #endif
37 #include <WW8DocumentImpl.hxx>
39 namespace writerfilter {
40 namespace doctok
42 /**
43 A helper class for footnotes and endnotes and annotations(aka X-notes).
45 template <class T>
46 class XNoteHelper
48 /// Character positions of X-notes in footnote document
49 WW8StructBase::Pointer_t mpCps;
51 /// Character positions of references to X-notes
52 typename PLCF<T>::Pointer_t mpRefs;
54 /// piece table for CP to FC conversion
55 WW8PieceTable::Pointer_t mpPieceTable;
57 /// the document
58 WW8DocumentImpl * mpDocument;
60 /// type of X-notes handled by this helper (PROP_FOOTNOTE, PROP_ENDNOTE)
61 PropertyType meType;
63 /// offset in document where X-note subdocument starts
64 CpAndFc mCpAndFcOffset;
66 /**
67 Return CpAndFc in document for X-note.
69 @param nPos index of X-note
71 CpAndFc getCpAndFc(sal_uInt32 nPos);
73 /**
74 Return CpAndFc in document for reference to a certain X-note.
76 @param nPos index of the X-note
78 CpAndFc getRefCpAndFc(sal_uInt32 nPos);
80 public:
81 typedef boost::shared_ptr<XNoteHelper> Pointer_t;
83 XNoteHelper(WW8StructBase::Pointer_t pCps,
84 typename PLCF<T>::Pointer_t pRefs,
85 WW8PieceTable::Pointer_t pPieceTable,
86 WW8DocumentImpl * pDocument,
87 PropertyType eType,
88 CpAndFc cpAndFcOffset)
89 : mpCps(pCps), mpRefs(pRefs), mpPieceTable(pPieceTable),
90 mpDocument(pDocument), meType(eType), mCpAndFcOffset(cpAndFcOffset)
94 /**
95 Initialize.
97 Generates CpAndFcs in document for X-notes.
99 void init();
102 Return number of X-notes.
104 sal_uInt32 getCount() const;
107 Return index of CpAndFc.
109 @param rCpAndFc the CpAndFc to search
111 @return the index of the rCpAndFc found or getCount() otherwise
113 sal_uInt32 getIndexOfCpAndFc(const CpAndFc & rCpAndFc);
115 /**
116 Return subdocument containing X-note.
118 @param nIndex index of X-note.
120 writerfilter::Reference<Stream>::Pointer_t get(sal_uInt32 nIndex);
123 Return subdocument containing X-note.
125 @param rCpAndFc CpAndFc of the X-note's reference
127 writerfilter::Reference<Stream>::Pointer_t get(const CpAndFc & rCpAndFc);
130 Return reference data structure of X-note.
132 @param nIndex index of X-note
134 T * getRef(sal_uInt32 nIndex);
137 Return reference data structure of X-note.
139 @param rCpAndFc CpAndFc for the X-note's reference
141 T * getRef(const CpAndFc & rCpAndFc);
146 #endif // INCLUDED_X_NOTE_HELPER_HXX