xref: /AOO41X/main/sw/inc/txtfld.hxx (revision e3d3059aa63baf4465a68a781f19c7522bcb5eaf)
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 #include <boost/shared_ptr.hpp>
31 
32 class SwTxtNode;
33 
34 // ATT_FLD ***********************************
35 
36 class SwTxtFld : public SwTxtAttr
37 {
38     mutable String m_aExpand; // only used to determine, if field content is changing in <ExpandTxtFld()>
39     SwTxtNode * m_pTxtNode;
40 
41 public:
42     SwTxtFld(
43         SwFmtFld & rAttr,
44         xub_StrLen const nStart );
45 
46     virtual ~SwTxtFld();
47 
48     void CopyTxtFld( SwTxtFld *pDest ) const;
49 
50     void ExpandTxtFld() const;
51     inline void ExpandAlways()
52     {
53         m_aExpand += ' '; // changing current value to assure that <ExpandTxtFld()> changes the value.
54         ExpandTxtFld();
55     }
56 
57     // get and set TxtNode pointer
58     inline SwTxtNode* GetpTxtNode() const
59     {
60         return m_pTxtNode;
61     }
62     inline SwTxtNode& GetTxtNode() const
63     {
64         ASSERT( m_pTxtNode, "SwTxtFld:: where is my TxtNode?" );
65         return *m_pTxtNode;
66     }
67     inline void ChgTxtNode( SwTxtNode* pNew )
68     {
69         m_pTxtNode = pNew;
70     }
71 
72     bool IsFldInDoc() const;
73 
74     // enable notification that field content has changed and needs reformatting
75     virtual void NotifyContentChange( SwFmtFld& rFmtFld );
76 
77     // deletes the given field via removing the corresponding text selection from the document's content
78     static void DeleteTxtFld( const SwTxtFld& rTxtFld );
79 
80     // return text selection for the given field
81     static void GetPamForTxtFld( const SwTxtFld& rTxtFld,
82                                  boost::shared_ptr< SwPaM >& rPamForTxtFld );
83 
84 };
85 
86 class SwTxtInputFld : public SwTxtFld
87 {
88 public:
89     SwTxtInputFld(
90         SwFmtFld & rAttr,
91         xub_StrLen const nStart,
92         xub_StrLen const nEnd );
93 
94     virtual ~SwTxtInputFld();
95 
96     virtual xub_StrLen* GetEnd();
97 
98     void LockNotifyContentChange();
99     void UnlockNotifyContentChange();
100     virtual void NotifyContentChange( SwFmtFld& rFmtFld );
101 
102     void UpdateTextNodeContent( const String& rNewContent );
103 
104     const String GetFieldContent() const;
105     void UpdateFieldContent();
106 
107 private:
108     xub_StrLen m_nEnd;
109 
110     bool m_bLockNotifyContentChange;
111 };
112 
113 #endif
114 
115