xref: /AOO41X/main/sw/inc/txtfld.hxx (revision e91b5f924acdd0a8f9af313ce7188803a0faa193)
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
10cdf0e10cSrcweir  *
111d2dbeb0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
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.
19cdf0e10cSrcweir  *
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 
306a85fc09SOliver-Rainer Wittmann #include <boost/shared_ptr.hpp>
316a85fc09SOliver-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,
44*e91b5f92SOliver-Rainer Wittmann         xub_StrLen const nStart,
45*e91b5f92SOliver-Rainer Wittmann         const bool bIsClipboardDoc );
4669a74367SOliver-Rainer Wittmann 
47cdf0e10cSrcweir     virtual ~SwTxtFld();
48cdf0e10cSrcweir 
4969a74367SOliver-Rainer Wittmann     void CopyTxtFld( SwTxtFld *pDest ) const;
5069a74367SOliver-Rainer Wittmann 
51*e91b5f92SOliver-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
59cdf0e10cSrcweir     {
60cdf0e10cSrcweir         ASSERT( m_pTxtNode, "SwTxtFld:: where is my TxtNode?" );
61cdf0e10cSrcweir         return *m_pTxtNode;
62cdf0e10cSrcweir     }
ChgTxtNode(SwTxtNode * pNew)6369a74367SOliver-Rainer Wittmann     inline void ChgTxtNode( SwTxtNode* pNew )
64cdf0e10cSrcweir     {
6569a74367SOliver-Rainer Wittmann         m_pTxtNode = pNew;
66cdf0e10cSrcweir     }
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 );
7269a74367SOliver-Rainer Wittmann 
736a85fc09SOliver-Rainer Wittmann     // deletes the given field via removing the corresponding text selection from the document's content
746a85fc09SOliver-Rainer Wittmann     static void DeleteTxtFld( const SwTxtFld& rTxtFld );
756a85fc09SOliver-Rainer Wittmann 
766a85fc09SOliver-Rainer Wittmann     // return text selection for the given field
776a85fc09SOliver-Rainer Wittmann     static void GetPamForTxtFld( const SwTxtFld& rTxtFld,
786a85fc09SOliver-Rainer Wittmann                                  boost::shared_ptr< SwPaM >& rPamForTxtFld );
796a85fc09SOliver-Rainer Wittmann 
8069a74367SOliver-Rainer Wittmann };
8169a74367SOliver-Rainer Wittmann 
8269a74367SOliver-Rainer Wittmann class SwTxtInputFld : public SwTxtFld
8369a74367SOliver-Rainer Wittmann {
8469a74367SOliver-Rainer Wittmann public:
8569a74367SOliver-Rainer Wittmann     SwTxtInputFld(
8669a74367SOliver-Rainer Wittmann         SwFmtFld & rAttr,
8769a74367SOliver-Rainer Wittmann         xub_StrLen const nStart,
88*e91b5f92SOliver-Rainer Wittmann         xub_StrLen const nEnd,
89*e91b5f92SOliver-Rainer Wittmann         const bool bIsClipboardDoc );
9069a74367SOliver-Rainer Wittmann 
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 };
10969a74367SOliver-Rainer Wittmann 
110cdf0e10cSrcweir #endif
111cdf0e10cSrcweir 
112