1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef IDOCUMENTMARKACCESS_HXX_INCLUDED 29*cdf0e10cSrcweir #define IDOCUMENTMARKACCESS_HXX_INCLUDED 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <sal/types.h> 32*cdf0e10cSrcweir #include <IMark.hxx> 33*cdf0e10cSrcweir #include <boost/shared_ptr.hpp> 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir class SwPaM; 36*cdf0e10cSrcweir class KeyCode; 37*cdf0e10cSrcweir class String; 38*cdf0e10cSrcweir struct SwPosition; 39*cdf0e10cSrcweir class SwTxtNode; 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir namespace sw { namespace mark { 42*cdf0e10cSrcweir class SaveBookmark; // FIXME: Ugly: SaveBookmark is a core-internal class, and should not be used in the interface 43*cdf0e10cSrcweir }} 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir /** Provides access to the marks of a document. 46*cdf0e10cSrcweir */ 47*cdf0e10cSrcweir class IDocumentMarkAccess 48*cdf0e10cSrcweir { 49*cdf0e10cSrcweir public: 50*cdf0e10cSrcweir enum MarkType 51*cdf0e10cSrcweir { 52*cdf0e10cSrcweir UNO_BOOKMARK, 53*cdf0e10cSrcweir DDE_BOOKMARK, 54*cdf0e10cSrcweir BOOKMARK, 55*cdf0e10cSrcweir CROSSREF_HEADING_BOOKMARK, 56*cdf0e10cSrcweir CROSSREF_NUMITEM_BOOKMARK, 57*cdf0e10cSrcweir TEXT_FIELDMARK, 58*cdf0e10cSrcweir CHECKBOX_FIELDMARK, 59*cdf0e10cSrcweir NAVIGATOR_REMINDER 60*cdf0e10cSrcweir }; 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir typedef ::boost::shared_ptr< ::sw::mark::IMark> pMark_t; 63*cdf0e10cSrcweir typedef ::std::vector< pMark_t > container_t; 64*cdf0e10cSrcweir typedef container_t::iterator iterator_t; 65*cdf0e10cSrcweir typedef container_t::const_iterator const_iterator_t; 66*cdf0e10cSrcweir typedef container_t::const_reverse_iterator const_reverse_iterator_t; 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir /** Generates a new mark in the document for a certain selection. 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir @param rPaM 71*cdf0e10cSrcweir [in] the selection being marked. 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir @param rProposedName 74*cdf0e10cSrcweir [in] the proposed name of the new mark. 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir @param eMark 77*cdf0e10cSrcweir [in] the type of the new mark. 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir @returns 80*cdf0e10cSrcweir a pointer to the new mark (name might have changed). 81*cdf0e10cSrcweir */ 82*cdf0e10cSrcweir virtual ::sw::mark::IMark* makeMark(const SwPaM& rPaM, 83*cdf0e10cSrcweir const ::rtl::OUString& rProposedName, 84*cdf0e10cSrcweir MarkType eMark) =0; 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir virtual sw::mark::IFieldmark* makeFieldBookmark( const SwPaM& rPaM, 87*cdf0e10cSrcweir const rtl::OUString& rName, 88*cdf0e10cSrcweir const rtl::OUString& rType) = 0; 89*cdf0e10cSrcweir virtual sw::mark::IFieldmark* makeNoTextFieldBookmark( const SwPaM& rPaM, 90*cdf0e10cSrcweir const rtl::OUString& rName, 91*cdf0e10cSrcweir const rtl::OUString& rType) = 0; 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir /** Returns a mark in the document for a paragraph. 94*cdf0e10cSrcweir If there is none, a mark will be created. 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir @param rTxtNode 97*cdf0e10cSrcweir [in] the paragraph being marked (a selection over the paragraph is marked) 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir @param eMark 100*cdf0e10cSrcweir [in] the type of the new mark. 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir @returns 103*cdf0e10cSrcweir a pointer to the new mark (name might have changed). 104*cdf0e10cSrcweir */ 105*cdf0e10cSrcweir virtual ::sw::mark::IMark* getMarkForTxtNode(const SwTxtNode& rTxtNode, 106*cdf0e10cSrcweir MarkType eMark) =0; 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir /** Moves an existing mark to a new selection and performs needed updates. 109*cdf0e10cSrcweir @param io_pMark 110*cdf0e10cSrcweir [in/out] the mark to be moved 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir @param rPaM 113*cdf0e10cSrcweir [in] new selection to be marked 114*cdf0e10cSrcweir */ 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir virtual void repositionMark(::sw::mark::IMark* io_pMark, 117*cdf0e10cSrcweir const SwPaM& rPaM) =0; 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir /** Renames an existing Mark, if possible. 120*cdf0e10cSrcweir @param io_pMark 121*cdf0e10cSrcweir [in/out] the mark to be renamed 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir @param rNewName 124*cdf0e10cSrcweir [in] new name for the mark 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir @returns false, if renaming failed (because the name is already in use) 127*cdf0e10cSrcweir */ 128*cdf0e10cSrcweir virtual bool renameMark(::sw::mark::IMark* io_pMark, 129*cdf0e10cSrcweir const ::rtl::OUString& rNewName) =0; 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir /** Corrects marks (absolute) 132*cdf0e10cSrcweir This method ignores the previous position of the mark in the paragraph 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir @param rOldNode 135*cdf0e10cSrcweir [in] the node from which nodes should be moved 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir @param rNewPos 138*cdf0e10cSrcweir [in] new position to which marks will be moved, if nOffset == 0 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir @param nOffset 141*cdf0e10cSrcweir [in] the offset by which the mark gets positioned of rNewPos 142*cdf0e10cSrcweir */ 143*cdf0e10cSrcweir virtual void correctMarksAbsolute(const SwNodeIndex& rOldNode, 144*cdf0e10cSrcweir const SwPosition& rNewPos, 145*cdf0e10cSrcweir const xub_StrLen nOffset) =0; 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir /** Corrects marks (relative) 148*cdf0e10cSrcweir This method uses the previous position of the mark in the paragraph as offset 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir @param rOldNode 151*cdf0e10cSrcweir [in] the node from which nodes should be moved 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir @param rNewPos 154*cdf0e10cSrcweir [in] new position to which marks from the start of the paragraph will be 155*cdf0e10cSrcweir moved, if nOffset == 0 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir @param nOffset 158*cdf0e10cSrcweir [in] the offset by which the mark gets positioned of rNewPos in addition to 159*cdf0e10cSrcweir its old position in the paragraph 160*cdf0e10cSrcweir */ 161*cdf0e10cSrcweir virtual void correctMarksRelative(const SwNodeIndex& rOldNode, 162*cdf0e10cSrcweir const SwPosition& rNewPos, 163*cdf0e10cSrcweir const xub_StrLen nOffset) =0; 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir /** Deletes marks in a range 166*cdf0e10cSrcweir */ 167*cdf0e10cSrcweir virtual void deleteMarks( 168*cdf0e10cSrcweir const SwNodeIndex& rStt, 169*cdf0e10cSrcweir const SwNodeIndex& rEnd, 170*cdf0e10cSrcweir ::std::vector< ::sw::mark::SaveBookmark>* pSaveBkmk, // Ugly: SaveBookmark is core-internal 171*cdf0e10cSrcweir const SwIndex* pSttIdx, 172*cdf0e10cSrcweir const SwIndex* pEndIdx) =0; 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir /** Deletes a mark. 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir @param ppMark 177*cdf0e10cSrcweir [in] an iterator pointing to the Mark to be deleted. 178*cdf0e10cSrcweir */ 179*cdf0e10cSrcweir virtual void deleteMark(const IDocumentMarkAccess::const_iterator_t ppMark) =0; 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir /** Deletes a mark. 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir @param ppMark 184*cdf0e10cSrcweir [in] the name of the mark to be deleted. 185*cdf0e10cSrcweir */ 186*cdf0e10cSrcweir virtual void deleteMark(const ::sw::mark::IMark* const pMark) =0; 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir /** Clear (deletes) all marks. 189*cdf0e10cSrcweir */ 190*cdf0e10cSrcweir virtual void clearAllMarks() =0; 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir /** returns a STL-like random access iterator to the begin of the sequence of marks. 193*cdf0e10cSrcweir */ 194*cdf0e10cSrcweir virtual const_iterator_t getMarksBegin() const =0; 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir /** returns a STL-like random access iterator to the end of the sequence of marks. 197*cdf0e10cSrcweir */ 198*cdf0e10cSrcweir virtual const_iterator_t getMarksEnd() const =0; 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir /** returns the number of marks. 201*cdf0e10cSrcweir */ 202*cdf0e10cSrcweir virtual sal_Int32 getMarksCount() const =0; 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir /** Finds a mark by name. 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir @param rName 207*cdf0e10cSrcweir [in] the name of the mark to find. 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir @returns 210*cdf0e10cSrcweir an iterator pointing to the mark, or pointing to getMarksEnd() if nothing was found. 211*cdf0e10cSrcweir */ 212*cdf0e10cSrcweir virtual const_iterator_t findMark(const ::rtl::OUString& rMark) const =0; 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir // interface IBookmarks (BOOKMARK, CROSSREF_NUMITEM_BOOKMARK, CROSSREF_HEADING_BOOKMARK) 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir /** returns a STL-like random access iterator to the begin of the sequence the IBookmarks. 218*cdf0e10cSrcweir */ 219*cdf0e10cSrcweir virtual const_iterator_t getBookmarksBegin() const =0; 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir /** returns a STL-like random access iterator to the end of the sequence of IBookmarks. 222*cdf0e10cSrcweir */ 223*cdf0e10cSrcweir virtual const_iterator_t getBookmarksEnd() const =0; 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir /** returns the number of IBookmarks. 226*cdf0e10cSrcweir */ 227*cdf0e10cSrcweir virtual sal_Int32 getBookmarksCount() const =0; 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir /** Finds a bookmark by name. 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir @param rName 232*cdf0e10cSrcweir [in] the name of the bookmark to find. 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir @returns 235*cdf0e10cSrcweir an iterator pointing to the bookmark, or getBookmarksEnd() if nothing was found. 236*cdf0e10cSrcweir */ 237*cdf0e10cSrcweir virtual const_iterator_t findBookmark(const ::rtl::OUString& rMark) const =0; 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir // Fieldmarks 241*cdf0e10cSrcweir virtual ::sw::mark::IFieldmark* getFieldmarkFor(const SwPosition& pos) const =0; 242*cdf0e10cSrcweir virtual ::sw::mark::IFieldmark* getFieldmarkBefore(const SwPosition& pos) const =0; 243*cdf0e10cSrcweir virtual ::sw::mark::IFieldmark* getFieldmarkAfter(const SwPosition& pos) const =0; 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir // Returns the MarkType used to create the mark 246*cdf0e10cSrcweir static MarkType SAL_DLLPUBLIC_EXPORT GetType(const ::sw::mark::IMark& rMark); 247*cdf0e10cSrcweir protected: 248*cdf0e10cSrcweir virtual ~IDocumentMarkAccess() {}; 249*cdf0e10cSrcweir }; 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir #endif // IDOCUMENTBOOKMARKACCESS_HXX_INCLUDED 252