xref: /aoo42x/main/sw/inc/txtfld.hxx (revision 7887cc2e)
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 _TXTFLD_HXX
24 #define _TXTFLD_HXX
25 
26 #include <txatbase.hxx>
27 #include <tools/string.hxx>
28 #include <pam.hxx>
29 
30 class SwTxtNode;
31 
32 // ATT_FLD ***********************************
33 
34 class SwTxtFld : public SwTxtAttr
35 {
36     mutable String m_aExpand; // only used to determine, if field content is changing in <ExpandTxtFld()>
37     SwTxtNode * m_pTxtNode;
38 
39 public:
40     SwTxtFld(
41         SwFmtFld & rAttr,
42         xub_StrLen const nStart,
43         const bool bIsClipboardDoc );
44 
45     virtual ~SwTxtFld();
46 
47     void CopyTxtFld( SwTxtFld *pDest ) const;
48 
49     void ExpandTxtFld( const bool bForceNotify = false ) const;
50 
51     // get and set TxtNode pointer
52     inline SwTxtNode* GetpTxtNode() const
53     {
54         return m_pTxtNode;
55     }
56     inline SwTxtNode& GetTxtNode() const
57     {
58         ASSERT( m_pTxtNode, "SwTxtFld:: where is my TxtNode?" );
59         return *m_pTxtNode;
60     }
61     inline void ChgTxtNode( SwTxtNode* pNew )
62     {
63         m_pTxtNode = pNew;
64     }
65 
66     bool IsFldInDoc() const;
67 
68     // enable notification that field content has changed and needs reformatting
69     virtual void NotifyContentChange( SwFmtFld& rFmtFld );
70 
71 };
72 
73 class SwTxtInputFld : public SwTxtFld
74 {
75 public:
76     SwTxtInputFld(
77         SwFmtFld & rAttr,
78         xub_StrLen const nStart,
79         xub_StrLen const nEnd,
80         const bool bIsClipboardDoc );
81 
82     virtual ~SwTxtInputFld();
83 
84     virtual xub_StrLen* GetEnd();
85 
86     void LockNotifyContentChange();
87     void UnlockNotifyContentChange();
88     virtual void NotifyContentChange( SwFmtFld& rFmtFld );
89 
90     void UpdateTextNodeContent( const String& rNewContent );
91 
92     const String GetFieldContent() const;
93     void UpdateFieldContent();
94 
95 private:
96     xub_StrLen m_nEnd;
97 
98     bool m_bLockNotifyContentChange;
99 };
100 
101 #endif
102 
103