LCOV - code coverage report
Current view: top level - sw/inc - fmtfld.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 18 19 94.7 %
Date: 2014-11-03 Functions: 10 12 83.3 %
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 INCLUDED_SW_INC_FMTFLD_HXX
      21             : #define INCLUDED_SW_INC_FMTFLD_HXX
      22             : 
      23             : #include <com/sun/star/text/XTextField.hpp>
      24             : 
      25             : #include <cppuhelper/weakref.hxx>
      26             : #include <svl/poolitem.hxx>
      27             : #include <svl/SfxBroadcaster.hxx>
      28             : #include <svl/smplhint.hxx>
      29             : 
      30             : #include "swdllapi.h"
      31             : #include <calbck.hxx>
      32             : 
      33             : class SwField;
      34             : class SwTxtFld;
      35             : class SwView;
      36             : class SwFieldType;
      37             : 
      38             : // ATT_FLD
      39             : class SW_DLLPUBLIC SwFmtFld
      40             :     : public SfxPoolItem
      41             :     , public SwModify
      42             :     , public SfxBroadcaster
      43             : {
      44             :     friend void _InitCore();
      45             :     SwFmtFld( sal_uInt16 nWhich ); // for default-Attibute
      46             : 
      47             :     ::com::sun::star::uno::WeakReference<
      48             :         ::com::sun::star::text::XTextField> m_wXTextField;
      49             : 
      50             :     SwField* mpField;
      51             :     SwTxtFld* mpTxtFld; // the TextAttribute
      52             : 
      53             :     // @@@ copy construction allowed, but copy assignment is not? @@@
      54             :     SwFmtFld& operator=(const SwFmtFld& rFld);
      55             : 
      56             : protected:
      57             :     virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) SAL_OVERRIDE;
      58             :     virtual void SwClientNotify( const SwModify& rModify, const SfxHint& rHint ) SAL_OVERRIDE;
      59             : 
      60             : public:
      61             :     TYPEINFO_OVERRIDE();
      62             : 
      63             :     /// Single argument constructors shall be explicit.
      64             :     explicit SwFmtFld( const SwField &rFld );
      65             : 
      66             :     /// @@@ copy construction allowed, but copy assignment is not? @@@
      67             :     SwFmtFld( const SwFmtFld& rAttr );
      68             : 
      69             :     virtual ~SwFmtFld();
      70             : 
      71             :     /// "Pure virtual methods" of SfxPoolItem.
      72             :     virtual bool            operator==( const SfxPoolItem& ) const SAL_OVERRIDE;
      73             :     virtual SfxPoolItem*    Clone( SfxItemPool* pPool = 0 ) const SAL_OVERRIDE;
      74             : 
      75             :     virtual bool GetInfo( SfxPoolItem& rInfo ) const SAL_OVERRIDE;
      76             : 
      77             :     void InvalidateField();
      78             : 
      79      298482 :     const SwField* GetField() const
      80             :     {
      81      298482 :         return mpField;
      82             :     }
      83       39223 :     SwField* GetField()
      84             :     {
      85       39223 :         return mpField;
      86             :     }
      87             : 
      88             :     /**
      89             :        Sets current field.
      90             : 
      91             :        @param pField          new field
      92             : 
      93             :        @attention The current field will be destroyed before setting the new field.
      94             :      */
      95             :     void SetField( SwField * pField );
      96             : 
      97        7584 :     const SwTxtFld* GetTxtFld() const
      98             :     {
      99        7584 :         return mpTxtFld;
     100             :     }
     101       10234 :     SwTxtFld* GetTxtFld()
     102             :     {
     103       10234 :         return mpTxtFld;
     104             :     }
     105             :     void SetTxtFld( SwTxtFld& rTxtFld );
     106             :     void ClearTxtFld();
     107             : 
     108             :     void RegisterToFieldType( SwFieldType& );
     109             :     bool IsFldInDoc() const;
     110             :     bool IsProtect() const;
     111             : 
     112             :     SAL_DLLPRIVATE ::com::sun::star::uno::WeakReference<
     113        1712 :         ::com::sun::star::text::XTextField> const& GetXTextField() const
     114        1712 :             { return m_wXTextField; }
     115        1690 :     SAL_DLLPRIVATE void SetXTextField(::com::sun::star::uno::Reference<
     116             :                     ::com::sun::star::text::XTextField> const& xTextField)
     117        1690 :             { m_wXTextField = xTextField; }
     118             : };
     119             : 
     120             : enum class SwFmtFldHintWhich
     121             : {
     122             :     INSERTED   = 1,
     123             :     REMOVED    = 2,
     124             :     FOCUS      = 3,
     125             :     CHANGED    = 4,
     126             :     LANGUAGE   = 5
     127             : };
     128             : 
     129       10540 : class SW_DLLPUBLIC SwFmtFldHint : public SfxHint
     130             : {
     131             :     const SwFmtFld*   pFld;
     132             :     SwFmtFldHintWhich nWhich;
     133             :     const SwView*     pView;
     134             : 
     135             : public:
     136       10540 :     SwFmtFldHint( const SwFmtFld* p, SwFmtFldHintWhich n, const SwView* pV = 0)
     137             :         : pFld(p)
     138             :         , nWhich(n)
     139       10540 :         , pView(pV)
     140       10540 :     {}
     141             : 
     142         158 :     const SwFmtFld* GetField() const { return pFld; }
     143         158 :     SwFmtFldHintWhich Which() const { return nWhich; }
     144           0 :     const SwView* GetView() const { return pView; }
     145             : };
     146             : 
     147             : #endif
     148             : 
     149             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10