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 44 virtual ~SwTxtFld(); 45 46 void CopyTxtFld( SwTxtFld *pDest ) const; 47 48 void ExpandTxtFld() const; 49 inline void ExpandAlways() 50 { 51 m_aExpand += ' '; // changing current value to assure that <ExpandTxtFld()> changes the value. 52 ExpandTxtFld(); 53 } 54 55 // get and set TxtNode pointer 56 inline SwTxtNode* GetpTxtNode() const 57 { 58 return m_pTxtNode; 59 } 60 inline SwTxtNode& GetTxtNode() const 61 { 62 ASSERT( m_pTxtNode, "SwTxtFld:: where is my TxtNode?" ); 63 return *m_pTxtNode; 64 } 65 inline void ChgTxtNode( SwTxtNode* pNew ) 66 { 67 m_pTxtNode = pNew; 68 } 69 70 bool IsFldInDoc() const; 71 72 // enable notification that field content has changed and needs reformatting 73 virtual void NotifyContentChange( SwFmtFld& rFmtFld ); 74 75 }; 76 77 class SwTxtInputFld : public SwTxtFld 78 { 79 public: 80 SwTxtInputFld( 81 SwFmtFld & rAttr, 82 xub_StrLen const nStart, 83 xub_StrLen const nEnd ); 84 85 virtual ~SwTxtInputFld(); 86 87 virtual xub_StrLen* GetEnd(); 88 89 virtual void NotifyContentChange( SwFmtFld& rFmtFld ); 90 91 void UpdateTextNodeContent( const String& rNewContent ); 92 93 const String GetFieldContent() const; 94 void UpdateFieldContent(); 95 96 private: 97 xub_StrLen m_nEnd; 98 }; 99 100 #endif 101 102