Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef INCLUDED_SW_INC_TXTFLD_HXX
20 : #define INCLUDED_SW_INC_TXTFLD_HXX
21 :
22 : #include <txatbase.hxx>
23 : #include <rtl/ustring.hxx>
24 :
25 : class SwTxtNode;
26 :
27 : // ATT_FLD ***********************************
28 :
29 : class SwTxtFld : public SwTxtAttr
30 : {
31 : mutable OUString m_aExpand; // only used to determine, if field content is changing in <ExpandTxtFld()>
32 : SwTxtNode * m_pTxtNode;
33 :
34 : public:
35 : SwTxtFld(
36 : SwFmtFld & rAttr,
37 : sal_Int32 const nStart,
38 : bool const bInClipboard );
39 :
40 : virtual ~SwTxtFld();
41 :
42 : void CopyTxtFld( SwTxtFld *pDest ) const;
43 :
44 : void ExpandTxtFld() const;
45 0 : void ExpandAlways()
46 : {
47 0 : m_aExpand += " "; // changing current value to assure that <ExpandTxtFld()> changes the value.
48 0 : ExpandTxtFld();
49 0 : }
50 :
51 : // get and set TxtNode pointer
52 0 : SwTxtNode* GetpTxtNode() const
53 : {
54 0 : return m_pTxtNode;
55 : }
56 0 : SwTxtNode& GetTxtNode() const
57 : {
58 : OSL_ENSURE( m_pTxtNode, "SwTxtFld:: where is my TxtNode?" );
59 0 : return *m_pTxtNode;
60 : }
61 0 : void ChgTxtNode( SwTxtNode* pNew )
62 : {
63 0 : m_pTxtNode = pNew;
64 0 : }
65 :
66 : bool IsFldInDoc() const;
67 :
68 : // enable notification that field content has changed and needs reformatting
69 : virtual void NotifyContentChange( SwFmtFld& rFmtFld );
70 :
71 : };
72 :
73 : class SwTxtInputFld : public SwTxtFld
74 : {
75 : public:
76 : SwTxtInputFld(
77 : SwFmtFld & rAttr,
78 : sal_Int32 const nStart,
79 : sal_Int32 const nEnd,
80 : bool const bInClipboard );
81 :
82 : virtual ~SwTxtInputFld();
83 :
84 : virtual sal_Int32* GetEnd() SAL_OVERRIDE;
85 :
86 : void LockNotifyContentChange();
87 : void UnlockNotifyContentChange();
88 : virtual void NotifyContentChange( SwFmtFld& rFmtFld ) SAL_OVERRIDE;
89 :
90 : void UpdateTextNodeContent( const OUString& rNewContent );
91 :
92 : const OUString GetFieldContent() const;
93 : void UpdateFieldContent();
94 :
95 : private:
96 : sal_Int32 m_nEnd;
97 :
98 : bool m_bLockNotifyContentChange;
99 : };
100 :
101 : #endif
102 :
103 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|