tdf#92527 construct default Segments sequence, when there is none
[LibreOffice.git] / sw / inc / ddefld.hxx
blob7b9868638ac4a4149465eb9db27183213eedcaf2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SW_INC_DDEFLD_HXX
20 #define INCLUDED_SW_INC_DDEFLD_HXX
22 #include <sfx2/lnkbase.hxx>
23 #include "swdllapi.h"
24 #include "fldbas.hxx"
26 class SwDoc;
28 // FieldType for DDE
29 class SW_DLLPUBLIC SwDDEFieldType : public SwFieldType
31 OUString aName;
32 OUString aExpansion;
34 tools::SvRef<sfx2::SvBaseLink> refLink;
35 SwDoc* pDoc;
37 sal_uInt16 nRefCnt;
38 bool bCRLFFlag : 1;
39 bool bDeleted : 1;
41 SAL_DLLPRIVATE void _RefCntChgd();
43 public:
44 SwDDEFieldType( const OUString& rName, const OUString& rCmd,
45 SfxLinkUpdateMode = SfxLinkUpdateMode::ONCALL );
46 virtual ~SwDDEFieldType();
48 OUString GetExpansion() const { return aExpansion; }
49 void SetExpansion( const OUString& rStr ) { aExpansion = rStr;
50 bCRLFFlag = false; }
52 virtual SwFieldType* Copy() const override;
53 virtual OUString GetName() const override;
55 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override;
56 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override;
58 OUString GetCmd() const;
59 void SetCmd( const OUString& aStr );
61 SfxLinkUpdateMode GetType() const { return refLink->GetUpdateMode(); }
62 void SetType( SfxLinkUpdateMode nType ) { refLink->SetUpdateMode( nType ); }
64 bool IsDeleted() const { return bDeleted; }
65 void SetDeleted( bool b ) { bDeleted = b; }
67 void UpdateNow() { refLink->Update(); }
68 void Disconnect() { refLink->Disconnect(); }
70 const ::sfx2::SvBaseLink& GetBaseLink() const { return *refLink; }
71 ::sfx2::SvBaseLink& GetBaseLink() { return *refLink; }
73 const SwDoc* GetDoc() const { return pDoc; }
74 SwDoc* GetDoc() { return pDoc; }
75 void SetDoc( SwDoc* pDoc );
77 void IncRefCnt() { if( !nRefCnt++ && pDoc ) _RefCntChgd(); }
78 void DecRefCnt() { if( !--nRefCnt && pDoc ) _RefCntChgd(); }
80 void SetCRLFDelFlag( bool bFlag = true ) { bCRLFFlag = bFlag; }
83 // DDE-field
84 class SwDDEField : public SwField
86 private:
87 virtual OUString Expand() const override;
88 virtual SwField* Copy() const override;
90 public:
91 SwDDEField(SwDDEFieldType*);
92 virtual ~SwDDEField();
94 /** Get parameter via types.
95 Name cannot be changed. */
96 virtual OUString GetPar1() const override;
98 // Command
99 virtual OUString GetPar2() const override;
100 virtual void SetPar2(const OUString& rStr) override;
103 #endif // INCLUDED_SW_INC_DDEFLD_HXX
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */