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