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 : #include <osl/diagnose.h>
25 :
26 : #include <boost/shared_ptr.hpp>
27 :
28 : class SwPaM;
29 : class SwTextNode;
30 :
31 : class SwTextField : public virtual SwTextAttr
32 : {
33 : mutable OUString m_aExpand; // only used to determine, if field content is changing in <ExpandTextField()>
34 : SwTextNode * m_pTextNode;
35 :
36 : public:
37 : SwTextField(
38 : SwFormatField & rAttr,
39 : sal_Int32 const nStart,
40 : bool const bInClipboard );
41 :
42 : virtual ~SwTextField();
43 :
44 : void CopyTextField( SwTextField *pDest ) const;
45 :
46 : void ExpandTextField( const bool bForceNotify = false ) const;
47 :
48 : // get and set TextNode pointer
49 11304 : SwTextNode* GetpTextNode() const
50 : {
51 11304 : return m_pTextNode;
52 : }
53 6489 : SwTextNode& GetTextNode() const
54 : {
55 : OSL_ENSURE( m_pTextNode, "SwTextField:: where is my TextNode?" );
56 6489 : return *m_pTextNode;
57 : }
58 2043 : void ChgTextNode( SwTextNode* pNew )
59 : {
60 2043 : m_pTextNode = pNew;
61 2043 : }
62 :
63 : bool IsFieldInDoc() const;
64 :
65 : // enable notification that field content has changed and needs reformatting
66 : virtual void NotifyContentChange( SwFormatField& rFormatField );
67 :
68 : // deletes the given field via removing the corresponding text selection from the document's content
69 : static void DeleteTextField( const SwTextField& rTextField );
70 :
71 : // return text selection for the given field
72 : static void GetPamForTextField( const SwTextField& rTextField,
73 : boost::shared_ptr< SwPaM >& rPamForTextField );
74 :
75 : };
76 :
77 : class SwTextInputField
78 : : public SwTextAttrNesting
79 : , public SwTextField
80 : {
81 : public:
82 : SwTextInputField(
83 : SwFormatField & rAttr,
84 : sal_Int32 const nStart,
85 : sal_Int32 const nEnd,
86 : bool const bInClipboard );
87 :
88 : virtual ~SwTextInputField();
89 :
90 : void LockNotifyContentChange();
91 : void UnlockNotifyContentChange();
92 : virtual void NotifyContentChange( SwFormatField& rFormatField ) SAL_OVERRIDE;
93 :
94 : void UpdateTextNodeContent( const OUString& rNewContent );
95 :
96 : const OUString GetFieldContent() const;
97 : void UpdateFieldContent();
98 :
99 : private:
100 :
101 : bool m_bLockNotifyContentChange;
102 : };
103 :
104 : #endif
105 :
106 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|