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 : #include <boost/shared_ptr.hpp>
26 :
27 : class SwPaM;
28 : class SwTxtNode;
29 :
30 : class SwTxtFld : public virtual SwTxtAttr
31 : {
32 : mutable OUString m_aExpand; // only used to determine, if field content is changing in <ExpandTxtFld()>
33 : SwTxtNode * m_pTxtNode;
34 :
35 : public:
36 : SwTxtFld(
37 : SwFmtFld & rAttr,
38 : sal_Int32 const nStart,
39 : bool const bInClipboard );
40 :
41 : virtual ~SwTxtFld();
42 :
43 : void CopyTxtFld( SwTxtFld *pDest ) const;
44 :
45 : void ExpandTxtFld( const bool bForceNotify = false ) const;
46 :
47 : // get and set TxtNode pointer
48 14692 : SwTxtNode* GetpTxtNode() const
49 : {
50 14692 : return m_pTxtNode;
51 : }
52 7792 : SwTxtNode& GetTxtNode() const
53 : {
54 : OSL_ENSURE( m_pTxtNode, "SwTxtFld:: where is my TxtNode?" );
55 7792 : return *m_pTxtNode;
56 : }
57 2962 : void ChgTxtNode( SwTxtNode* pNew )
58 : {
59 2962 : m_pTxtNode = pNew;
60 2962 : }
61 :
62 : bool IsFldInDoc() const;
63 :
64 : // enable notification that field content has changed and needs reformatting
65 : virtual void NotifyContentChange( SwFmtFld& rFmtFld );
66 :
67 : // deletes the given field via removing the corresponding text selection from the document's content
68 : static void DeleteTxtFld( const SwTxtFld& rTxtFld );
69 :
70 : // return text selection for the given field
71 : static void GetPamForTxtFld( const SwTxtFld& rTxtFld,
72 : boost::shared_ptr< SwPaM >& rPamForTxtFld );
73 :
74 : };
75 :
76 : class SwTxtInputFld
77 : : public SwTxtAttrNesting
78 : , public SwTxtFld
79 : {
80 : public:
81 : SwTxtInputFld(
82 : SwFmtFld & rAttr,
83 : sal_Int32 const nStart,
84 : sal_Int32 const nEnd,
85 : bool const bInClipboard );
86 :
87 : virtual ~SwTxtInputFld();
88 :
89 : void LockNotifyContentChange();
90 : void UnlockNotifyContentChange();
91 : virtual void NotifyContentChange( SwFmtFld& rFmtFld ) SAL_OVERRIDE;
92 :
93 : void UpdateTextNodeContent( const OUString& rNewContent );
94 :
95 : const OUString GetFieldContent() const;
96 : void UpdateFieldContent();
97 :
98 : private:
99 :
100 : bool m_bLockNotifyContentChange;
101 : };
102 :
103 : #endif
104 :
105 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|