LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/core/inc - bookmrk.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 47 62 75.8 %
Date: 2013-07-09 Functions: 27 38 71.1 %
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 _BOOKMRK_HXX
      21             : #define _BOOKMRK_HXX
      22             : 
      23             : #include <cppuhelper/weakref.hxx>
      24             : #include <sfx2/Metadatable.hxx>
      25             : #include <boost/scoped_ptr.hpp>
      26             : #include <boost/noncopyable.hpp>
      27             : #include <map>
      28             : #include <rtl/ustring.hxx>
      29             : #include <IMark.hxx>
      30             : 
      31             : namespace com {
      32             :     namespace sun {
      33             :         namespace star {
      34             :             namespace text {
      35             :                 class XTextContent;
      36             :             }
      37             :         }
      38             :     }
      39             : }
      40             : 
      41             : struct SwPosition;  // fwd Decl. wg. UI
      42             : class SwDoc;
      43             : 
      44             : namespace sw {
      45             :     namespace mark {
      46             :         class MarkBase
      47             :             : virtual public IMark
      48             :         {
      49             :         public:
      50     3714779 :             virtual SwPosition& GetMarkPos() const
      51     3714779 :                 { return *m_pPos1; }
      52     2372121 :             virtual const OUString& GetName() const
      53     2372121 :                 { return m_aName; }
      54     5831421 :             virtual SwPosition& GetOtherMarkPos() const
      55             :             {
      56             :                 OSL_PRECOND(IsExpanded(), "<SwPosition::GetOtherMarkPos(..)> - I have no other Pos set." );
      57     5831421 :                 return *m_pPos2;
      58             :             }
      59      333641 :             virtual SwPosition& GetMarkStart() const
      60             :             {
      61      333641 :                 if( !IsExpanded() ) return GetMarkPos( );
      62      271819 :                 if ( GetMarkPos( ) < GetOtherMarkPos( ) )
      63      270768 :                     return GetMarkPos();
      64             :                 else
      65        1051 :                     return GetOtherMarkPos( );
      66             :             }
      67     2491650 :             virtual SwPosition& GetMarkEnd() const
      68             :             {
      69     2491650 :                 if( !IsExpanded() ) return GetMarkPos();
      70     2482815 :                 if ( GetMarkPos( ) >= GetOtherMarkPos( ) )
      71          15 :                     return GetMarkPos( );
      72             :                 else
      73     2482800 :                     return GetOtherMarkPos( );
      74             :             }
      75             : 
      76             :             virtual bool IsCoveringPosition(const SwPosition& rPos) const;
      77     3287789 :             virtual bool IsExpanded() const
      78     3287789 :                 { return static_cast< bool >(m_pPos2); }
      79             : 
      80        2068 :             virtual void SetName(const OUString& rName)
      81        2068 :                 { m_aName = rName; }
      82             :             virtual void SetMarkPos(const SwPosition& rNewPos);
      83             :             virtual void SetOtherMarkPos(const SwPosition& rNewPos);
      84           0 :             virtual void ClearOtherMarkPos()
      85           0 :                 { m_pPos2.reset(); }
      86             : 
      87             :             virtual OUString ToString( ) const;
      88             : 
      89        1018 :             virtual void Swap()
      90             :             {
      91        1018 :                 if(m_pPos2)
      92        1018 :                     m_pPos1.swap(m_pPos2);
      93        1018 :             }
      94             : 
      95       11731 :             virtual void InitDoc(SwDoc* const)
      96             :             {
      97       11731 :             }
      98             : 
      99             :             virtual ~MarkBase();
     100             : 
     101             :             const ::com::sun::star::uno::WeakReference<
     102        6817 :                 ::com::sun::star::text::XTextContent> & GetXBookmark() const
     103        6817 :                     { return m_wXBookmark; }
     104        7425 :             void SetXBookmark(::com::sun::star::uno::Reference<
     105             :                         ::com::sun::star::text::XTextContent> const& xBkmk)
     106        7425 :                     { m_wXBookmark = xBkmk; }
     107             : 
     108             :         protected:
     109             :             // SwClient
     110             :             virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew );
     111             : 
     112             :             MarkBase(const SwPaM& rPaM, const OUString& rName);
     113             :             ::boost::scoped_ptr<SwPosition> m_pPos1;
     114             :             ::boost::scoped_ptr<SwPosition> m_pPos2;
     115             :             OUString m_aName;
     116             :             static OUString GenerateNewName(const OUString& rPrefix);
     117             : 
     118             :             ::com::sun::star::uno::WeakReference<
     119             :                 ::com::sun::star::text::XTextContent> m_wXBookmark;
     120             :         };
     121             : 
     122           0 :         class NavigatorReminder
     123             :             : public MarkBase
     124             :         {
     125             :         public:
     126             :             NavigatorReminder(const SwPaM& rPaM);
     127             :         };
     128             : 
     129       23462 :         class UnoMark
     130             :             : public MarkBase
     131             :         {
     132             :         public:
     133             :             UnoMark(const SwPaM& rPaM);
     134             :         };
     135             : 
     136             :         class DdeBookmark
     137             :             : public MarkBase
     138             :         {
     139             :         public:
     140             :             DdeBookmark(const SwPaM& rPaM);
     141             : 
     142             :             const SwServerObject* GetRefObject() const
     143             :                 { return &m_aRefObj; }
     144           0 :             SwServerObject* GetRefObject()
     145           0 :                 { return &m_aRefObj; }
     146             : 
     147           0 :             bool IsServer() const
     148           0 :                 { return m_aRefObj.Is(); }
     149             : 
     150             :             void SetRefObject( SwServerObject* pObj );
     151             : 
     152             :             void DeregisterFromDoc(SwDoc* const pDoc);
     153             :             virtual ~DdeBookmark();
     154             : 
     155             :         private:
     156             :             SwServerObjectRef m_aRefObj;
     157             :         };
     158             : 
     159        4085 :         class Bookmark
     160             :             : virtual public IBookmark
     161             :             , public DdeBookmark
     162             :             , public ::sfx2::Metadatable
     163             :         {
     164             :         public:
     165             :             Bookmark(const SwPaM& rPaM,
     166             :                 const KeyCode& rCode,
     167             :                 const OUString& rName,
     168             :                 const OUString& rShortName);
     169             :             virtual void InitDoc(SwDoc* const io_Doc);
     170             : 
     171        1270 :             virtual const OUString& GetShortName() const
     172        1270 :                 { return m_sShortName; }
     173        1270 :             virtual const KeyCode& GetKeyCode() const
     174        1270 :                 { return m_aCode; }
     175           0 :             virtual void SetShortName(const OUString& rShortName)
     176           0 :                 { m_sShortName = rShortName; }
     177           0 :             virtual void SetKeyCode(const KeyCode& rCode)
     178           0 :                 { m_aCode = rCode; }
     179             : 
     180             :             // ::sfx2::Metadatable
     181             :             virtual ::sfx2::IXmlIdRegistry& GetRegistry();
     182             :             virtual bool IsInClipboard() const;
     183             :             virtual bool IsInUndo() const;
     184             :             virtual bool IsInContent() const;
     185             :             virtual ::com::sun::star::uno::Reference<
     186             :                 ::com::sun::star::rdf::XMetadatable > MakeUnoObject();
     187             : 
     188             :         private:
     189             :             KeyCode m_aCode;
     190             :             OUString m_sShortName;
     191             :         };
     192             : 
     193          16 :         class Fieldmark
     194             :             : virtual public IFieldmark
     195             :             , public MarkBase
     196             :         {
     197             :         public:
     198             :             Fieldmark(const SwPaM& rPaM);
     199             : 
     200          99 :             virtual OUString GetFieldname() const
     201          99 :                 { return m_aFieldname; }
     202           0 :             virtual OUString GetFieldHelptext() const
     203           0 :                 { return m_aFieldHelptext; }
     204             : 
     205           3 :             virtual IFieldmark::parameter_map_t* GetParameters()
     206           3 :                 { return &m_vParams; }
     207             : 
     208           8 :             virtual const IFieldmark::parameter_map_t* GetParameters() const
     209           8 :                 { return &m_vParams; }
     210             : 
     211          16 :             virtual void SetFieldname(const OUString& aFieldname)
     212          16 :                 { m_aFieldname = aFieldname; }
     213           0 :             virtual void SetFieldHelptext(const OUString& aFieldHelptext)
     214           0 :                 { m_aFieldHelptext = aFieldHelptext; }
     215             : 
     216             :             virtual void ReleaseDoc(SwDoc* const) = 0;
     217             : 
     218             :             virtual void Invalidate();
     219             :             virtual OUString ToString() const;
     220             : 
     221             :         private:
     222             :             OUString m_aFieldname;
     223             :             OUString m_aFieldHelptext;
     224             :             IFieldmark::parameter_map_t m_vParams;
     225             :         };
     226             : 
     227          24 :         class TextFieldmark
     228             :             : public Fieldmark
     229             :         {
     230             :         public:
     231             :             TextFieldmark(const SwPaM& rPaM);
     232             :             virtual void InitDoc(SwDoc* const io_pDoc);
     233             :             virtual void ReleaseDoc(SwDoc* const pDoc);
     234             :         };
     235             : 
     236           8 :         class CheckboxFieldmark
     237             :             : virtual public ICheckboxFieldmark
     238             :             , public Fieldmark
     239             :         {
     240             :         public:
     241             :             CheckboxFieldmark(const SwPaM& rPaM);
     242             :             virtual void InitDoc(SwDoc* const io_pDoc);
     243             :             virtual void ReleaseDoc(SwDoc* const pDoc);
     244             :             bool IsChecked() const;
     245             :             void SetChecked(bool checked);
     246             : 
     247             :             virtual OUString toString( ) const;
     248             :         };
     249             :     }
     250             : }
     251             : #endif
     252             : 
     253             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10