11d2dbeb0SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 31d2dbeb0SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 41d2dbeb0SAndrew Rist * or more contributor license agreements. See the NOTICE file 51d2dbeb0SAndrew Rist * distributed with this work for additional information 61d2dbeb0SAndrew Rist * regarding copyright ownership. The ASF licenses this file 71d2dbeb0SAndrew Rist * to you under the Apache License, Version 2.0 (the 81d2dbeb0SAndrew Rist * "License"); you may not use this file except in compliance 91d2dbeb0SAndrew Rist * with the License. You may obtain a copy of the License at 101d2dbeb0SAndrew Rist * 111d2dbeb0SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 121d2dbeb0SAndrew Rist * 131d2dbeb0SAndrew Rist * Unless required by applicable law or agreed to in writing, 141d2dbeb0SAndrew Rist * software distributed under the License is distributed on an 151d2dbeb0SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 161d2dbeb0SAndrew Rist * KIND, either express or implied. See the License for the 171d2dbeb0SAndrew Rist * specific language governing permissions and limitations 181d2dbeb0SAndrew Rist * under the License. 191d2dbeb0SAndrew Rist * 201d2dbeb0SAndrew Rist *************************************************************/ 211d2dbeb0SAndrew Rist 221d2dbeb0SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef IDOCUMENTMARKACCESS_HXX_INCLUDED 25cdf0e10cSrcweir #define IDOCUMENTMARKACCESS_HXX_INCLUDED 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <sal/types.h> 28cdf0e10cSrcweir #include <IMark.hxx> 29cdf0e10cSrcweir #include <boost/shared_ptr.hpp> 30cdf0e10cSrcweir 31cdf0e10cSrcweir class SwPaM; 32cdf0e10cSrcweir class KeyCode; 33cdf0e10cSrcweir class String; 34cdf0e10cSrcweir struct SwPosition; 35cdf0e10cSrcweir class SwTxtNode; 36cdf0e10cSrcweir 37cdf0e10cSrcweir namespace sw { namespace mark { 38cdf0e10cSrcweir class SaveBookmark; // FIXME: Ugly: SaveBookmark is a core-internal class, and should not be used in the interface 39cdf0e10cSrcweir }} 40cdf0e10cSrcweir 41cdf0e10cSrcweir /** Provides access to the marks of a document. 42cdf0e10cSrcweir */ 43cdf0e10cSrcweir class IDocumentMarkAccess 44cdf0e10cSrcweir { 45cdf0e10cSrcweir public: 46cdf0e10cSrcweir enum MarkType 47cdf0e10cSrcweir { 48cdf0e10cSrcweir UNO_BOOKMARK, 49cdf0e10cSrcweir DDE_BOOKMARK, 50cdf0e10cSrcweir BOOKMARK, 51cdf0e10cSrcweir CROSSREF_HEADING_BOOKMARK, 52cdf0e10cSrcweir CROSSREF_NUMITEM_BOOKMARK, 53cdf0e10cSrcweir TEXT_FIELDMARK, 54cdf0e10cSrcweir CHECKBOX_FIELDMARK, 55cdf0e10cSrcweir NAVIGATOR_REMINDER 56cdf0e10cSrcweir }; 57cdf0e10cSrcweir 58cdf0e10cSrcweir typedef ::boost::shared_ptr< ::sw::mark::IMark> pMark_t; 59cdf0e10cSrcweir typedef ::std::vector< pMark_t > container_t; 60cdf0e10cSrcweir typedef container_t::iterator iterator_t; 61cdf0e10cSrcweir typedef container_t::const_iterator const_iterator_t; 62cdf0e10cSrcweir typedef container_t::const_reverse_iterator const_reverse_iterator_t; 63cdf0e10cSrcweir 64cdf0e10cSrcweir /** Generates a new mark in the document for a certain selection. 65cdf0e10cSrcweir 66cdf0e10cSrcweir @param rPaM 67cdf0e10cSrcweir [in] the selection being marked. 68cdf0e10cSrcweir 69cdf0e10cSrcweir @param rProposedName 70cdf0e10cSrcweir [in] the proposed name of the new mark. 71cdf0e10cSrcweir 72cdf0e10cSrcweir @param eMark 73cdf0e10cSrcweir [in] the type of the new mark. 74cdf0e10cSrcweir 75cdf0e10cSrcweir @returns 76cdf0e10cSrcweir a pointer to the new mark (name might have changed). 77cdf0e10cSrcweir */ 78cdf0e10cSrcweir virtual ::sw::mark::IMark* makeMark(const SwPaM& rPaM, 79cdf0e10cSrcweir const ::rtl::OUString& rProposedName, 80cdf0e10cSrcweir MarkType eMark) =0; 81cdf0e10cSrcweir 82cdf0e10cSrcweir virtual sw::mark::IFieldmark* makeFieldBookmark( const SwPaM& rPaM, 83cdf0e10cSrcweir const rtl::OUString& rName, 84cdf0e10cSrcweir const rtl::OUString& rType) = 0; 85cdf0e10cSrcweir virtual sw::mark::IFieldmark* makeNoTextFieldBookmark( const SwPaM& rPaM, 86cdf0e10cSrcweir const rtl::OUString& rName, 87cdf0e10cSrcweir const rtl::OUString& rType) = 0; 88cdf0e10cSrcweir 89cdf0e10cSrcweir /** Returns a mark in the document for a paragraph. 90cdf0e10cSrcweir If there is none, a mark will be created. 91cdf0e10cSrcweir 92cdf0e10cSrcweir @param rTxtNode 93cdf0e10cSrcweir [in] the paragraph being marked (a selection over the paragraph is marked) 94cdf0e10cSrcweir 95cdf0e10cSrcweir @param eMark 96cdf0e10cSrcweir [in] the type of the new mark. 97cdf0e10cSrcweir 98cdf0e10cSrcweir @returns 99cdf0e10cSrcweir a pointer to the new mark (name might have changed). 100cdf0e10cSrcweir */ 101cdf0e10cSrcweir virtual ::sw::mark::IMark* getMarkForTxtNode(const SwTxtNode& rTxtNode, 102cdf0e10cSrcweir MarkType eMark) =0; 103cdf0e10cSrcweir 104cdf0e10cSrcweir /** Moves an existing mark to a new selection and performs needed updates. 105cdf0e10cSrcweir @param io_pMark 106cdf0e10cSrcweir [in/out] the mark to be moved 107cdf0e10cSrcweir 108cdf0e10cSrcweir @param rPaM 109cdf0e10cSrcweir [in] new selection to be marked 110cdf0e10cSrcweir */ 111cdf0e10cSrcweir 112cdf0e10cSrcweir virtual void repositionMark(::sw::mark::IMark* io_pMark, 113cdf0e10cSrcweir const SwPaM& rPaM) =0; 114cdf0e10cSrcweir 115cdf0e10cSrcweir /** Renames an existing Mark, if possible. 116cdf0e10cSrcweir @param io_pMark 117cdf0e10cSrcweir [in/out] the mark to be renamed 118cdf0e10cSrcweir 119cdf0e10cSrcweir @param rNewName 120cdf0e10cSrcweir [in] new name for the mark 121cdf0e10cSrcweir 122cdf0e10cSrcweir @returns false, if renaming failed (because the name is already in use) 123cdf0e10cSrcweir */ 124cdf0e10cSrcweir virtual bool renameMark(::sw::mark::IMark* io_pMark, 125cdf0e10cSrcweir const ::rtl::OUString& rNewName) =0; 126cdf0e10cSrcweir 127cdf0e10cSrcweir /** Corrects marks (absolute) 128cdf0e10cSrcweir This method ignores the previous position of the mark in the paragraph 129cdf0e10cSrcweir 130cdf0e10cSrcweir @param rOldNode 131cdf0e10cSrcweir [in] the node from which nodes should be moved 132cdf0e10cSrcweir 133cdf0e10cSrcweir @param rNewPos 134cdf0e10cSrcweir [in] new position to which marks will be moved, if nOffset == 0 135cdf0e10cSrcweir 136cdf0e10cSrcweir @param nOffset 137cdf0e10cSrcweir [in] the offset by which the mark gets positioned of rNewPos 138cdf0e10cSrcweir */ 139cdf0e10cSrcweir virtual void correctMarksAbsolute(const SwNodeIndex& rOldNode, 140cdf0e10cSrcweir const SwPosition& rNewPos, 141cdf0e10cSrcweir const xub_StrLen nOffset) =0; 142cdf0e10cSrcweir 143cdf0e10cSrcweir /** Corrects marks (relative) 144cdf0e10cSrcweir This method uses the previous position of the mark in the paragraph as offset 145cdf0e10cSrcweir 146cdf0e10cSrcweir @param rOldNode 147cdf0e10cSrcweir [in] the node from which nodes should be moved 148cdf0e10cSrcweir 149cdf0e10cSrcweir @param rNewPos 150cdf0e10cSrcweir [in] new position to which marks from the start of the paragraph will be 151cdf0e10cSrcweir moved, if nOffset == 0 152cdf0e10cSrcweir 153cdf0e10cSrcweir @param nOffset 154cdf0e10cSrcweir [in] the offset by which the mark gets positioned of rNewPos in addition to 155cdf0e10cSrcweir its old position in the paragraph 156cdf0e10cSrcweir */ 157cdf0e10cSrcweir virtual void correctMarksRelative(const SwNodeIndex& rOldNode, 158cdf0e10cSrcweir const SwPosition& rNewPos, 159cdf0e10cSrcweir const xub_StrLen nOffset) =0; 160cdf0e10cSrcweir 161cdf0e10cSrcweir /** Deletes marks in a range 162cdf0e10cSrcweir */ 163cdf0e10cSrcweir virtual void deleteMarks( 164cdf0e10cSrcweir const SwNodeIndex& rStt, 165cdf0e10cSrcweir const SwNodeIndex& rEnd, 166cdf0e10cSrcweir ::std::vector< ::sw::mark::SaveBookmark>* pSaveBkmk, // Ugly: SaveBookmark is core-internal 167cdf0e10cSrcweir const SwIndex* pSttIdx, 168cdf0e10cSrcweir const SwIndex* pEndIdx) =0; 169cdf0e10cSrcweir 170cdf0e10cSrcweir /** Deletes a mark. 171cdf0e10cSrcweir 172cdf0e10cSrcweir @param ppMark 173cdf0e10cSrcweir [in] an iterator pointing to the Mark to be deleted. 174cdf0e10cSrcweir */ 175cdf0e10cSrcweir virtual void deleteMark(const IDocumentMarkAccess::const_iterator_t ppMark) =0; 176cdf0e10cSrcweir 177cdf0e10cSrcweir /** Deletes a mark. 178cdf0e10cSrcweir 179cdf0e10cSrcweir @param ppMark 180cdf0e10cSrcweir [in] the name of the mark to be deleted. 181cdf0e10cSrcweir */ 182cdf0e10cSrcweir virtual void deleteMark(const ::sw::mark::IMark* const pMark) =0; 183cdf0e10cSrcweir 184cdf0e10cSrcweir /** Clear (deletes) all marks. 185cdf0e10cSrcweir */ 186cdf0e10cSrcweir virtual void clearAllMarks() =0; 187cdf0e10cSrcweir 188cdf0e10cSrcweir /** returns a STL-like random access iterator to the begin of the sequence of marks. 189cdf0e10cSrcweir */ 190cdf0e10cSrcweir virtual const_iterator_t getMarksBegin() const =0; 191cdf0e10cSrcweir 192cdf0e10cSrcweir /** returns a STL-like random access iterator to the end of the sequence of marks. 193cdf0e10cSrcweir */ 194cdf0e10cSrcweir virtual const_iterator_t getMarksEnd() const =0; 195cdf0e10cSrcweir 196cdf0e10cSrcweir /** returns the number of marks. 197cdf0e10cSrcweir */ 198cdf0e10cSrcweir virtual sal_Int32 getMarksCount() const =0; 199cdf0e10cSrcweir 200cdf0e10cSrcweir /** Finds a mark by name. 201cdf0e10cSrcweir 202cdf0e10cSrcweir @param rName 203cdf0e10cSrcweir [in] the name of the mark to find. 204cdf0e10cSrcweir 205cdf0e10cSrcweir @returns 206cdf0e10cSrcweir an iterator pointing to the mark, or pointing to getMarksEnd() if nothing was found. 207cdf0e10cSrcweir */ 208cdf0e10cSrcweir virtual const_iterator_t findMark(const ::rtl::OUString& rMark) const =0; 209cdf0e10cSrcweir 210cdf0e10cSrcweir 211cdf0e10cSrcweir // interface IBookmarks (BOOKMARK, CROSSREF_NUMITEM_BOOKMARK, CROSSREF_HEADING_BOOKMARK) 212cdf0e10cSrcweir 213cdf0e10cSrcweir /** returns a STL-like random access iterator to the begin of the sequence the IBookmarks. 214cdf0e10cSrcweir */ 215cdf0e10cSrcweir virtual const_iterator_t getBookmarksBegin() const =0; 216cdf0e10cSrcweir 217cdf0e10cSrcweir /** returns a STL-like random access iterator to the end of the sequence of IBookmarks. 218cdf0e10cSrcweir */ 219cdf0e10cSrcweir virtual const_iterator_t getBookmarksEnd() const =0; 220cdf0e10cSrcweir 221cdf0e10cSrcweir /** returns the number of IBookmarks. 222cdf0e10cSrcweir */ 223cdf0e10cSrcweir virtual sal_Int32 getBookmarksCount() const =0; 224cdf0e10cSrcweir 225cdf0e10cSrcweir /** Finds a bookmark by name. 226cdf0e10cSrcweir 227cdf0e10cSrcweir @param rName 228cdf0e10cSrcweir [in] the name of the bookmark to find. 229cdf0e10cSrcweir 230cdf0e10cSrcweir @returns 231cdf0e10cSrcweir an iterator pointing to the bookmark, or getBookmarksEnd() if nothing was found. 232cdf0e10cSrcweir */ 233cdf0e10cSrcweir virtual const_iterator_t findBookmark(const ::rtl::OUString& rMark) const =0; 234cdf0e10cSrcweir 235cdf0e10cSrcweir 236cdf0e10cSrcweir // Fieldmarks 237cdf0e10cSrcweir virtual ::sw::mark::IFieldmark* getFieldmarkFor(const SwPosition& pos) const =0; 238cdf0e10cSrcweir virtual ::sw::mark::IFieldmark* getFieldmarkBefore(const SwPosition& pos) const =0; 239cdf0e10cSrcweir virtual ::sw::mark::IFieldmark* getFieldmarkAfter(const SwPosition& pos) const =0; 240cdf0e10cSrcweir 241cdf0e10cSrcweir // Returns the MarkType used to create the mark 242cdf0e10cSrcweir static MarkType SAL_DLLPUBLIC_EXPORT GetType(const ::sw::mark::IMark& rMark); 243*3078b051SOliver-Rainer Wittmann 244*3078b051SOliver-Rainer Wittmann static const ::rtl::OUString SAL_DLLPUBLIC_EXPORT & GetCrossRefHeadingBookmarkNamePrefix(); 245*3078b051SOliver-Rainer Wittmann static const bool SAL_DLLPUBLIC_EXPORT IsLegalPaMForCrossRefHeadingBookmark( const SwPaM& rPaM ); 246cdf0e10cSrcweir protected: 247cdf0e10cSrcweir virtual ~IDocumentMarkAccess() {}; 248cdf0e10cSrcweir }; 249cdf0e10cSrcweir 250cdf0e10cSrcweir #endif // IDOCUMENTBOOKMARKACCESS_HXX_INCLUDED 251