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_DDEFLD_HXX
20 : #define INCLUDED_SW_INC_DDEFLD_HXX
21 :
22 : #include <sfx2/lnkbase.hxx>
23 : #include "swdllapi.h"
24 : #include "fldbas.hxx"
25 :
26 : class SwDoc;
27 :
28 : /*--------------------------------------------------------------------
29 : FieldType for DDE
30 : --------------------------------------------------------------------*/
31 :
32 : class SW_DLLPUBLIC SwDDEFieldType : public SwFieldType
33 : {
34 : OUString aName;
35 : OUString aExpansion;
36 :
37 : ::sfx2::SvBaseLinkRef refLink;
38 : SwDoc* pDoc;
39 :
40 : sal_uInt16 nRefCnt;
41 : sal_Bool bCRLFFlag : 1;
42 : sal_Bool bDeleted : 1;
43 :
44 : SAL_DLLPRIVATE void _RefCntChgd();
45 :
46 : public:
47 : SwDDEFieldType( const OUString& rName, const OUString& rCmd,
48 : sal_uInt16 = sfx2::LINKUPDATE_ONCALL );
49 : virtual ~SwDDEFieldType();
50 :
51 0 : OUString GetExpansion() const { return aExpansion; }
52 0 : void SetExpansion( const OUString& rStr ) { aExpansion = rStr;
53 0 : bCRLFFlag = sal_False; }
54 :
55 : virtual SwFieldType* Copy() const SAL_OVERRIDE;
56 : virtual OUString GetName() const SAL_OVERRIDE;
57 :
58 : virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) const SAL_OVERRIDE;
59 : virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich ) SAL_OVERRIDE;
60 :
61 : OUString GetCmd() const;
62 : void SetCmd( const OUString& aStr );
63 :
64 0 : sal_uInt16 GetType() const { return refLink->GetUpdateMode(); }
65 0 : void SetType( sal_uInt16 nType ) { refLink->SetUpdateMode( nType ); }
66 :
67 0 : sal_Bool IsDeleted() const { return bDeleted; }
68 0 : void SetDeleted( sal_Bool b ) { bDeleted = b; }
69 :
70 0 : void UpdateNow() { refLink->Update(); }
71 0 : void Disconnect() { refLink->Disconnect(); }
72 :
73 : const ::sfx2::SvBaseLink& GetBaseLink() const { return *refLink; }
74 0 : ::sfx2::SvBaseLink& GetBaseLink() { return *refLink; }
75 :
76 : const SwDoc* GetDoc() const { return pDoc; }
77 0 : SwDoc* GetDoc() { return pDoc; }
78 : void SetDoc( SwDoc* pDoc );
79 :
80 0 : void IncRefCnt() { if( !nRefCnt++ && pDoc ) _RefCntChgd(); }
81 0 : void DecRefCnt() { if( !--nRefCnt && pDoc ) _RefCntChgd(); }
82 :
83 0 : void SetCRLFDelFlag( sal_Bool bFlag = sal_True ) { bCRLFFlag = bFlag; }
84 : };
85 :
86 : /*--------------------------------------------------------------------
87 : DDE-field
88 : --------------------------------------------------------------------*/
89 :
90 : class SwDDEField : public SwField
91 : {
92 : private:
93 : virtual OUString Expand() const SAL_OVERRIDE;
94 : virtual SwField* Copy() const SAL_OVERRIDE;
95 :
96 : public:
97 : SwDDEField(SwDDEFieldType*);
98 : virtual ~SwDDEField();
99 :
100 : /** Get parameter via types.
101 : Name cannot be changed. */
102 : virtual OUString GetPar1() const SAL_OVERRIDE;
103 :
104 : // Command
105 : virtual OUString GetPar2() const SAL_OVERRIDE;
106 : virtual void SetPar2(const OUString& rStr) SAL_OVERRIDE;
107 : };
108 :
109 : #endif // INCLUDED_SW_INC_DDEFLD_HXX
110 :
111 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|