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 23 24 #ifndef INCLUDED_X_NOTE_HELPER_HXX 25 #define INCLUDED_X_NOTE_HELPER_HXX 26 27 #ifndef INLCUED_PLCF_HXX 28 #include <PLCF.hxx> 29 #endif 30 #include <WW8DocumentImpl.hxx> 31 32 namespace writerfilter { 33 namespace doctok 34 { 35 /** 36 A helper class for footnotes and endnotes and annotations(aka X-notes). 37 */ 38 template <class T> 39 class XNoteHelper 40 { 41 /// Character positions of X-notes in footnote document 42 WW8StructBase::Pointer_t mpCps; 43 44 /// Character positions of references to X-notes 45 typename PLCF<T>::Pointer_t mpRefs; 46 47 /// piece table for CP to FC conversion 48 WW8PieceTable::Pointer_t mpPieceTable; 49 50 /// the document 51 WW8DocumentImpl * mpDocument; 52 53 /// type of X-notes handled by this helper (PROP_FOOTNOTE, PROP_ENDNOTE) 54 PropertyType meType; 55 56 /// offset in document where X-note subdocument starts 57 CpAndFc mCpAndFcOffset; 58 59 /** 60 Return CpAndFc in document for X-note. 61 62 @param nPos index of X-note 63 */ 64 CpAndFc getCpAndFc(sal_uInt32 nPos); 65 66 /** 67 Return CpAndFc in document for reference to a certain X-note. 68 69 @param nPos index of the X-note 70 */ 71 CpAndFc getRefCpAndFc(sal_uInt32 nPos); 72 73 public: 74 typedef boost::shared_ptr<XNoteHelper> Pointer_t; 75 XNoteHelper(WW8StructBase::Pointer_t pCps,typename PLCF<T>::Pointer_t pRefs,WW8PieceTable::Pointer_t pPieceTable,WW8DocumentImpl * pDocument,PropertyType eType,CpAndFc cpAndFcOffset)76 XNoteHelper(WW8StructBase::Pointer_t pCps, 77 typename PLCF<T>::Pointer_t pRefs, 78 WW8PieceTable::Pointer_t pPieceTable, 79 WW8DocumentImpl * pDocument, 80 PropertyType eType, 81 CpAndFc cpAndFcOffset) 82 : mpCps(pCps), mpRefs(pRefs), mpPieceTable(pPieceTable), 83 mpDocument(pDocument), meType(eType), mCpAndFcOffset(cpAndFcOffset) 84 { 85 } 86 87 /** 88 Initialize. 89 90 Generates CpAndFcs in document for X-notes. 91 */ 92 void init(); 93 94 /** 95 Return number of X-notes. 96 */ 97 sal_uInt32 getCount() const; 98 99 /** 100 Return index of CpAndFc. 101 102 @param rCpAndFc the CpAndFc to search 103 104 @return the index of the rCpAndFc found or getCount() otherwise 105 */ 106 sal_uInt32 getIndexOfCpAndFc(const CpAndFc & rCpAndFc); 107 108 /** 109 Return subdocument containing X-note. 110 111 @param nIndex index of X-note. 112 */ 113 writerfilter::Reference<Stream>::Pointer_t get(sal_uInt32 nIndex); 114 115 /** 116 Return subdocument containing X-note. 117 118 @param rCpAndFc CpAndFc of the X-note's reference 119 */ 120 writerfilter::Reference<Stream>::Pointer_t get(const CpAndFc & rCpAndFc); 121 122 /** 123 Return reference data structure of X-note. 124 125 @param nIndex index of X-note 126 */ 127 T * getRef(sal_uInt32 nIndex); 128 129 /** 130 Return reference data structure of X-note. 131 132 @param rCpAndFc CpAndFc for the X-note's reference 133 */ 134 T * getRef(const CpAndFc & rCpAndFc); 135 }; 136 137 }} 138 139 #endif // INCLUDED_X_NOTE_HELPER_HXX 140