LCOV - code coverage report
Current view: top level - libreoffice/sw/source/core/inc - bookmrk.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 42 62 67.7 %
Date: 2012-12-27 Functions: 22 38 57.9 %
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       26176 :             virtual SwPosition& GetMarkPos() const
      51       26176 :                 { return *m_pPos1; }
      52        4202 :             virtual const ::rtl::OUString& GetName() const
      53        4202 :                 { return m_aName; }
      54        3217 :             virtual SwPosition& GetOtherMarkPos() const
      55             :             {
      56             :                 OSL_PRECOND(IsExpanded(), "<SwPosition::GetOtherMarkPos(..)> - I have no other Pos set." );
      57        3217 :                 return *m_pPos2;
      58             :             }
      59       14467 :             virtual SwPosition& GetMarkStart() const
      60             :             {
      61       14467 :                 if( !IsExpanded() ) return GetMarkPos( );
      62        2835 :                 if ( GetMarkPos( ) < GetOtherMarkPos( ) )
      63        2826 :                     return GetMarkPos();
      64             :                 else
      65           9 :                     return GetOtherMarkPos( );
      66             :             }
      67        3906 :             virtual SwPosition& GetMarkEnd() const
      68             :             {
      69        3906 :                 if( !IsExpanded() ) return GetMarkPos();
      70         126 :                 if ( GetMarkPos( ) >= GetOtherMarkPos( ) )
      71           3 :                     return GetMarkPos( );
      72             :                 else
      73         123 :                     return GetOtherMarkPos( );
      74             :             }
      75             : 
      76             :             virtual bool IsCoveringPosition(const SwPosition& rPos) const;
      77       21133 :             virtual bool IsExpanded() const
      78       21133 :                 { return m_pPos2; }
      79             : 
      80          28 :             virtual void SetName(const ::rtl::OUString& rName)
      81          28 :                 { 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 rtl::OUString ToString( ) const;
      88             : 
      89           7 :             virtual void Swap()
      90             :             {
      91           7 :                 if(m_pPos2)
      92           7 :                     m_pPos1.swap(m_pPos2);
      93           7 :             }
      94             : 
      95        2059 :             virtual void InitDoc(SwDoc* const)
      96             :             {
      97        2059 :             }
      98             : 
      99             :             virtual ~MarkBase();
     100             : 
     101             :             const ::com::sun::star::uno::WeakReference<
     102          16 :                 ::com::sun::star::text::XTextContent> & GetXBookmark() const
     103          16 :                     { return m_wXBookmark; }
     104          25 :             void SetXBookmark(::com::sun::star::uno::Reference<
     105             :                         ::com::sun::star::text::XTextContent> const& xBkmk)
     106          25 :                     { 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 ::rtl::OUString& rName);
     113             :             ::boost::scoped_ptr<SwPosition> m_pPos1;
     114             :             ::boost::scoped_ptr<SwPosition> m_pPos2;
     115             :             ::rtl::OUString m_aName;
     116             :             static ::rtl::OUString GenerateNewName(const ::rtl::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        4112 :         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          22 :         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 ::rtl::OUString& rName,
     168             :                 const ::rtl::OUString& rShortName);
     169             :             virtual void InitDoc(SwDoc* const io_Doc);
     170             : 
     171           0 :             virtual const ::rtl::OUString& GetShortName() const
     172           0 :                 { return m_sShortName; }
     173           0 :             virtual const KeyCode& GetKeyCode() const
     174           0 :                 { return m_aCode; }
     175           0 :             virtual void SetShortName(const ::rtl::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             :             ::rtl::OUString m_sShortName;
     191             :         };
     192             : 
     193           3 :         class Fieldmark
     194             :             : virtual public IFieldmark
     195             :             , public MarkBase
     196             :         {
     197             :         public:
     198             :             Fieldmark(const SwPaM& rPaM);
     199             : 
     200          86 :             virtual ::rtl::OUString GetFieldname() const
     201          86 :                 { return m_aFieldname; }
     202           0 :             virtual ::rtl::OUString GetFieldHelptext() const
     203           0 :                 { return m_aFieldHelptext; }
     204             : 
     205           2 :             virtual IFieldmark::parameter_map_t* GetParameters()
     206           2 :                 { return &m_vParams; }
     207             : 
     208           2 :             virtual const IFieldmark::parameter_map_t* GetParameters() const
     209           2 :                 { return &m_vParams; }
     210             : 
     211           7 :             virtual void SetFieldname(const ::rtl::OUString& aFieldname)
     212           7 :                 { m_aFieldname = aFieldname; }
     213           0 :             virtual void SetFieldHelptext(const ::rtl::OUString& aFieldHelptext)
     214           0 :                 { m_aFieldHelptext = aFieldHelptext; }
     215             : 
     216             :             virtual void Invalidate();
     217             :             virtual rtl::OUString ToString() const;
     218             : 
     219             :         private:
     220             :             ::rtl::OUString m_aFieldname;
     221             :             ::rtl::OUString m_aFieldHelptext;
     222             :             IFieldmark::parameter_map_t m_vParams;
     223             :         };
     224             : 
     225           6 :         class TextFieldmark
     226             :             : public Fieldmark
     227             :         {
     228             :         public:
     229             :             TextFieldmark(const SwPaM& rPaM);
     230             :             virtual void InitDoc(SwDoc* const io_pDoc);
     231             :             void ReleaseDoc(SwDoc* const pDoc);
     232             :         };
     233             : 
     234           0 :         class CheckboxFieldmark
     235             :             : virtual public ICheckboxFieldmark
     236             :             , public Fieldmark
     237             :         {
     238             :         public:
     239             :             CheckboxFieldmark(const SwPaM& rPaM);
     240             :             virtual void InitDoc(SwDoc* const io_pDoc);
     241             :             bool IsChecked() const;
     242             :             void SetChecked(bool checked);
     243             : 
     244             :             virtual rtl::OUString toString( ) const;
     245             :         };
     246             :     }
     247             : }
     248             : #endif
     249             : 
     250             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10