xref: /aoo4110/main/sw/inc/txtfld.hxx (revision b1cdbd2c)
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         const bool bIsClipboardDoc );
46 
47     virtual ~SwTxtFld();
48 
49     void CopyTxtFld( SwTxtFld *pDest ) const;
50 
51     void ExpandTxtFld( const bool bForceNotify = false ) const;
52 
53     // get and set TxtNode pointer
GetpTxtNode() const54     inline SwTxtNode* GetpTxtNode() const
55     {
56         return m_pTxtNode;
57     }
GetTxtNode() const58     inline SwTxtNode& GetTxtNode() const
59     {
60         ASSERT( m_pTxtNode, "SwTxtFld:: where is my TxtNode?" );
61         return *m_pTxtNode;
62     }
ChgTxtNode(SwTxtNode * pNew)63     inline void ChgTxtNode( SwTxtNode* pNew )
64     {
65         m_pTxtNode = pNew;
66     }
67 
68     bool IsFldInDoc() const;
69 
70     // enable notification that field content has changed and needs reformatting
71     virtual void NotifyContentChange( SwFmtFld& rFmtFld );
72 
73     // deletes the given field via removing the corresponding text selection from the document's content
74     static void DeleteTxtFld( const SwTxtFld& rTxtFld );
75 
76     // return text selection for the given field
77     static void GetPamForTxtFld( const SwTxtFld& rTxtFld,
78                                  boost::shared_ptr< SwPaM >& rPamForTxtFld );
79 
80 };
81 
82 class SwTxtInputFld : public SwTxtFld
83 {
84 public:
85     SwTxtInputFld(
86         SwFmtFld & rAttr,
87         xub_StrLen const nStart,
88         xub_StrLen const nEnd,
89         const bool bIsClipboardDoc );
90 
91     virtual ~SwTxtInputFld();
92 
93     virtual xub_StrLen* GetEnd();
94 
95     void LockNotifyContentChange();
96     void UnlockNotifyContentChange();
97     virtual void NotifyContentChange( SwFmtFld& rFmtFld );
98 
99     void UpdateTextNodeContent( const String& rNewContent );
100 
101     const String GetFieldContent() const;
102     void UpdateFieldContent();
103 
104 private:
105     xub_StrLen m_nEnd;
106 
107     bool m_bLockNotifyContentChange;
108 };
109 
110 #endif
111 
112