xref: /aoo42x/main/sw/inc/txtfld.hxx (revision 36375bf3)
11d2dbeb0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
31d2dbeb0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
41d2dbeb0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
51d2dbeb0SAndrew Rist  * distributed with this work for additional information
61d2dbeb0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
71d2dbeb0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
81d2dbeb0SAndrew Rist  * "License"); you may not use this file except in compliance
91d2dbeb0SAndrew Rist  * with the License.  You may obtain a copy of the License at
101d2dbeb0SAndrew Rist  *
111d2dbeb0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
121d2dbeb0SAndrew Rist  *
131d2dbeb0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
141d2dbeb0SAndrew Rist  * software distributed under the License is distributed on an
151d2dbeb0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
161d2dbeb0SAndrew Rist  * KIND, either express or implied.  See the License for the
171d2dbeb0SAndrew Rist  * specific language governing permissions and limitations
181d2dbeb0SAndrew Rist  * under the License.
191d2dbeb0SAndrew Rist  *
201d2dbeb0SAndrew Rist  *************************************************************/
211d2dbeb0SAndrew Rist 
221d2dbeb0SAndrew Rist 
23cdf0e10cSrcweir #ifndef _TXTFLD_HXX
24cdf0e10cSrcweir #define _TXTFLD_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <txatbase.hxx>
27cdf0e10cSrcweir #include <tools/string.hxx>
28cdf0e10cSrcweir #include <pam.hxx>
29cdf0e10cSrcweir 
30*36375bf3SOliver-Rainer Wittmann #include <boost/shared_ptr.hpp>
31*36375bf3SOliver-Rainer Wittmann 
32cdf0e10cSrcweir class SwTxtNode;
33cdf0e10cSrcweir 
34cdf0e10cSrcweir // ATT_FLD ***********************************
35cdf0e10cSrcweir 
36cdf0e10cSrcweir class SwTxtFld : public SwTxtAttr
37cdf0e10cSrcweir {
3869a74367SOliver-Rainer Wittmann     mutable String m_aExpand; // only used to determine, if field content is changing in <ExpandTxtFld()>
39cdf0e10cSrcweir     SwTxtNode * m_pTxtNode;
40cdf0e10cSrcweir 
41cdf0e10cSrcweir public:
4269a74367SOliver-Rainer Wittmann     SwTxtFld(
4369a74367SOliver-Rainer Wittmann         SwFmtFld & rAttr,
447887cc2eSOliver-Rainer Wittmann         xub_StrLen const nStart,
457887cc2eSOliver-Rainer Wittmann         const bool bIsClipboardDoc );
4669a74367SOliver-Rainer Wittmann 
47cdf0e10cSrcweir     virtual ~SwTxtFld();
48cdf0e10cSrcweir 
4969a74367SOliver-Rainer Wittmann     void CopyTxtFld( SwTxtFld *pDest ) const;
5069a74367SOliver-Rainer Wittmann 
517887cc2eSOliver-Rainer Wittmann     void ExpandTxtFld( const bool bForceNotify = false ) const;
52cdf0e10cSrcweir 
53cdf0e10cSrcweir     // get and set TxtNode pointer
GetpTxtNode() const5469a74367SOliver-Rainer Wittmann     inline SwTxtNode* GetpTxtNode() const
5569a74367SOliver-Rainer Wittmann     {
5669a74367SOliver-Rainer Wittmann         return m_pTxtNode;
5769a74367SOliver-Rainer Wittmann     }
GetTxtNode() const5869a74367SOliver-Rainer Wittmann     inline SwTxtNode& GetTxtNode() const
5969a74367SOliver-Rainer Wittmann     {
6069a74367SOliver-Rainer Wittmann         ASSERT( m_pTxtNode, "SwTxtFld:: where is my TxtNode?" );
6169a74367SOliver-Rainer Wittmann         return *m_pTxtNode;
6269a74367SOliver-Rainer Wittmann     }
ChgTxtNode(SwTxtNode * pNew)6369a74367SOliver-Rainer Wittmann     inline void ChgTxtNode( SwTxtNode* pNew )
6469a74367SOliver-Rainer Wittmann     {
6569a74367SOliver-Rainer Wittmann         m_pTxtNode = pNew;
6669a74367SOliver-Rainer Wittmann     }
67cdf0e10cSrcweir 
6869a74367SOliver-Rainer Wittmann     bool IsFldInDoc() const;
6969a74367SOliver-Rainer Wittmann 
7069a74367SOliver-Rainer Wittmann     // enable notification that field content has changed and needs reformatting
7169a74367SOliver-Rainer Wittmann     virtual void NotifyContentChange( SwFmtFld& rFmtFld );
72cdf0e10cSrcweir 
73*36375bf3SOliver-Rainer Wittmann     // deletes the given field via removing the corresponding text selection from the document's content
74*36375bf3SOliver-Rainer Wittmann     static void DeleteTxtFld( const SwTxtFld& rTxtFld );
75*36375bf3SOliver-Rainer Wittmann 
76*36375bf3SOliver-Rainer Wittmann     // return text selection for the given field
77*36375bf3SOliver-Rainer Wittmann     static void GetPamForTxtFld( const SwTxtFld& rTxtFld,
78*36375bf3SOliver-Rainer Wittmann                                  boost::shared_ptr< SwPaM >& rPamForTxtFld );
79*36375bf3SOliver-Rainer Wittmann 
80cdf0e10cSrcweir };
81cdf0e10cSrcweir 
8269a74367SOliver-Rainer Wittmann class SwTxtInputFld : public SwTxtFld
83cdf0e10cSrcweir {
8469a74367SOliver-Rainer Wittmann public:
8569a74367SOliver-Rainer Wittmann     SwTxtInputFld(
8669a74367SOliver-Rainer Wittmann         SwFmtFld & rAttr,
8769a74367SOliver-Rainer Wittmann         xub_StrLen const nStart,
887887cc2eSOliver-Rainer Wittmann         xub_StrLen const nEnd,
897887cc2eSOliver-Rainer Wittmann         const bool bIsClipboardDoc );
90cdf0e10cSrcweir 
9169a74367SOliver-Rainer Wittmann     virtual ~SwTxtInputFld();
9269a74367SOliver-Rainer Wittmann 
9369a74367SOliver-Rainer Wittmann     virtual xub_StrLen* GetEnd();
9469a74367SOliver-Rainer Wittmann 
951bf9188dSOliver-Rainer Wittmann     void LockNotifyContentChange();
961bf9188dSOliver-Rainer Wittmann     void UnlockNotifyContentChange();
9769a74367SOliver-Rainer Wittmann     virtual void NotifyContentChange( SwFmtFld& rFmtFld );
9869a74367SOliver-Rainer Wittmann 
9969a74367SOliver-Rainer Wittmann     void UpdateTextNodeContent( const String& rNewContent );
10069a74367SOliver-Rainer Wittmann 
10169a74367SOliver-Rainer Wittmann     const String GetFieldContent() const;
10269a74367SOliver-Rainer Wittmann     void UpdateFieldContent();
10369a74367SOliver-Rainer Wittmann 
10469a74367SOliver-Rainer Wittmann private:
10569a74367SOliver-Rainer Wittmann     xub_StrLen m_nEnd;
1061bf9188dSOliver-Rainer Wittmann 
1071bf9188dSOliver-Rainer Wittmann     bool m_bLockNotifyContentChange;
10869a74367SOliver-Rainer Wittmann };
109cdf0e10cSrcweir 
110cdf0e10cSrcweir #endif
111cdf0e10cSrcweir 
112