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 <svl/hint.hxx> 24 #include <tools/solar.h> 25 #include "swdllapi.h" 26 #include "fldbas.hxx" 27 28 class SwDoc; 29 class SwNode; 30 class SwNodes; 31 32 namespace sw 33 { 34 struct LinkAnchorSearchHint final : public SfxHint 35 { 36 SwNodes& m_rNodes; 37 const SwNode*& m_rpFoundNode; LinkAnchorSearchHintsw::LinkAnchorSearchHint38 LinkAnchorSearchHint(SwNodes& rNodes, const SwNode*& rpFoundNode) : m_rNodes(rNodes), m_rpFoundNode(rpFoundNode) {}; 39 virtual ~LinkAnchorSearchHint() override; 40 }; 41 struct InRangeSearchHint final : public SfxHint 42 { 43 const sal_uLong m_nSttNd, m_nEndNd; 44 bool& m_rIsInRange; InRangeSearchHintsw::InRangeSearchHint45 InRangeSearchHint(const sal_uLong nSttNd, const sal_uLong nEndNd, bool& rIsInRange) 46 : m_nSttNd(nSttNd), m_nEndNd(nEndNd), m_rIsInRange(rIsInRange) {} 47 }; 48 } 49 50 // FieldType for DDE 51 class SW_DLLPUBLIC SwDDEFieldType final : public SwFieldType 52 { 53 OUString const aName; 54 OUString aExpansion; 55 56 tools::SvRef<sfx2::SvBaseLink> refLink; 57 SwDoc* pDoc; 58 59 sal_uInt16 nRefCnt; 60 bool bCRLFFlag : 1; 61 bool bDeleted : 1; 62 63 SAL_DLLPRIVATE void RefCntChgd(); 64 65 public: 66 SwDDEFieldType( const OUString& rName, const OUString& rCmd, 67 SfxLinkUpdateMode ); 68 virtual ~SwDDEFieldType() override; 69 GetExpansion() const70 const OUString& GetExpansion() const { return aExpansion; } SetExpansion(const OUString & rStr)71 void SetExpansion( const OUString& rStr ) { aExpansion = rStr; 72 bCRLFFlag = false; } 73 74 virtual std::unique_ptr<SwFieldType> Copy() const override; 75 virtual OUString GetName() const override; 76 77 virtual void QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override; 78 virtual void PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override; 79 80 OUString const & GetCmd() const; 81 void SetCmd( const OUString& aStr ); 82 GetType() const83 SfxLinkUpdateMode GetType() const { return refLink->GetUpdateMode(); } SetType(SfxLinkUpdateMode nType)84 void SetType( SfxLinkUpdateMode nType ) { refLink->SetUpdateMode( nType ); } 85 IsDeleted() const86 bool IsDeleted() const { return bDeleted; } SetDeleted(bool b)87 void SetDeleted( bool b ) { bDeleted = b; } 88 Disconnect()89 void Disconnect() { refLink->Disconnect(); } 90 GetBaseLink() const91 const ::sfx2::SvBaseLink& GetBaseLink() const { return *refLink; } GetBaseLink()92 ::sfx2::SvBaseLink& GetBaseLink() { return *refLink; } 93 GetDoc() const94 const SwDoc* GetDoc() const { return pDoc; } GetDoc()95 SwDoc* GetDoc() { return pDoc; } 96 void SetDoc( SwDoc* pDoc ); 97 IncRefCnt()98 void IncRefCnt() { if( !nRefCnt++ && pDoc ) RefCntChgd(); } DecRefCnt()99 void DecRefCnt() { if( !--nRefCnt && pDoc ) RefCntChgd(); } 100 SetCRLFDelFlag(bool bFlag)101 void SetCRLFDelFlag( bool bFlag ) { bCRLFFlag = bFlag; } 102 }; 103 104 // DDE-field 105 class SwDDEField final : public SwField 106 { 107 private: 108 virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override; 109 virtual std::unique_ptr<SwField> Copy() const override; 110 111 public: 112 SwDDEField(SwDDEFieldType*); 113 virtual ~SwDDEField() override; 114 115 /** Get parameter via types. 116 Name cannot be changed. */ 117 virtual OUString GetPar1() const override; 118 119 // Command 120 virtual OUString GetPar2() const override; 121 virtual void SetPar2(const OUString& rStr) override; 122 }; 123 124 #endif // INCLUDED_SW_INC_DDEFLD_HXX 125 126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 127