LCOV - code coverage report
Current view: top level - libreoffice/sw/inc - IDocumentMarkAccess.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 2 2 100.0 %
Date: 2012-12-27 Functions: 2 3 66.7 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10