xref: /AOO41X/main/sw/inc/fmtfld.hxx (revision 707fc0d4d52eb4f69d89a98ffec6918ca5de6326)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _FMTFLD_HXX
24 #define _FMTFLD_HXX
25 
26 #include <list>
27 #include <svl/poolitem.hxx>
28 #include <svl/brdcst.hxx>
29 #include <svl/smplhint.hxx>
30 
31 #include "swdllapi.h"
32 #include <calbck.hxx>
33 
34 class SwField;
35 class SwTxtFld;
36 class SwView;
37 class SwFieldType;
38 
39 // ATT_FLD ***********************************
40 class SW_DLLPUBLIC SwFmtFld : public SfxPoolItem, public SwClient, public SfxBroadcaster
41 {
42     friend class SwTxtFld;
43     friend void _InitCore();
44 
45     SwField *pField;
46     SwTxtFld* pTxtAttr;     // mein TextAttribut
47 
48     SwFmtFld();             // das default-Attibut
49 
50     // geschuetzter CopyCtor
51     // @@@ copy construction allowed, but copy assignment is not? @@@
52     SwFmtFld& operator=(const SwFmtFld& rFld);
53 
54 protected:
55     virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew);
56     virtual void SwClientNotify( const SwModify& rModify, const SfxHint& rHint );
57 
58 public:
59     TYPEINFO();
60 
61     // single argument constructors shall be explicit.
62     explicit SwFmtFld( const SwField &rFld );
63 
64     // @@@ copy construction allowed, but copy assignment is not? @@@
65     SwFmtFld( const SwFmtFld& rAttr );
66 
67     virtual ~SwFmtFld();
68 
69     // "pure virtual Methoden" vom SfxPoolItem
70     virtual int             operator==( const SfxPoolItem& ) const;
71     virtual SfxPoolItem*    Clone( SfxItemPool* pPool = 0 ) const;
72 
73     virtual sal_Bool GetInfo( SfxPoolItem& rInfo ) const;
74 
75     const SwField *GetFld() const   { return pField; }
76     SwField *GetFld()               { return pField; }
77 
78     // #111840#
79     /**
80        Sets current field.
81 
82        @param pField          new field
83 
84        @attention The current field will be destroyed before setting the new field.
85      */
86     void SetFld(SwField * pField);
87 
88     const SwTxtFld *GetTxtFld() const   { return pTxtAttr; }
89     SwTxtFld *GetTxtFld()               { return pTxtAttr; }
90 
91     void RegisterToFieldType( SwFieldType& );
92     sal_Bool IsFldInDoc() const;
93     sal_Bool IsProtect() const;
94 };
95 
96 class SW_DLLPUBLIC SwFmtFldHint : public SfxHint
97 {
98 #define SWFMTFLD_INSERTED   1
99 #define SWFMTFLD_REMOVED    2
100 #define SWFMTFLD_FOCUS      3
101 #define SWFMTFLD_CHANGED    4
102 #define SWFMTFLD_LANGUAGE   5
103 
104     const SwFmtFld* pFld;
105     sal_Int16 nWhich;
106     const SwView* pView;
107 
108 public:
109     SwFmtFldHint( const SwFmtFld* p, sal_Int16 n, const SwView* pV = 0)
110         : pFld(p)
111         , nWhich(n)
112         , pView(pV)
113     {}
114 
115     TYPEINFO();
116     const SwFmtFld* GetField() const { return pFld; }
117     sal_Int16 Which() const { return nWhich; }
118     const SwView* GetView() const { return pView; }
119 };
120 
121 #endif
122