Coverage Report

Created: 2026-05-16 09:25

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sw/inc/ddefld.hxx
Line
Count
Source
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
#pragma once
20
21
#include <sfx2/lnkbase.hxx>
22
#include <svl/hint.hxx>
23
#include "swdllapi.h"
24
#include "fldbas.hxx"
25
26
class SwDoc;
27
class SwNode;
28
class SwNodes;
29
30
namespace sw
31
{
32
    struct LinkAnchorSearchHint final : public SfxHint
33
    {
34
        SwNodes& m_rNodes;
35
        const SwNode*& m_rpFoundNode;
36
        LinkAnchorSearchHint(SwNodes& rNodes, const SwNode*& rpFoundNode)
37
0
            : SfxHint(SfxHintId::SwLinkAnchorSearch), m_rNodes(rNodes), m_rpFoundNode(rpFoundNode) {};
38
        virtual ~LinkAnchorSearchHint() override;
39
    };
40
    struct InRangeSearchHint final : public SfxHint
41
    {
42
        const SwNodeOffset m_nSttNd, m_nEndNd;
43
        bool& m_rIsInRange;
44
        InRangeSearchHint(const SwNodeOffset nSttNd, const SwNodeOffset nEndNd, bool& rIsInRange)
45
0
            : SfxHint(SfxHintId::SwInRangeSearch), m_nSttNd(nSttNd), m_nEndNd(nEndNd), m_rIsInRange(rIsInRange) {}
46
    };
47
}
48
49
// FieldType for DDE
50
class SW_DLLPUBLIC SwDDEFieldType final : public SwFieldType
51
{
52
    UIName m_aName;
53
    OUString m_aExpansion;
54
55
    tools::SvRef<sfx2::SvBaseLink> m_RefLink;
56
    SwDoc* m_pDoc;
57
58
    sal_uInt16 m_nRefCount;
59
    bool m_bCRLFFlag : 1;
60
    bool m_bDeleted : 1;
61
62
    SAL_DLLPRIVATE void RefCntChgd();
63
64
public:
65
    SwDDEFieldType( UIName aName, const OUString& rCmd,
66
                    SfxLinkUpdateMode );
67
    virtual ~SwDDEFieldType() override;
68
69
0
    const OUString& GetExpansion() const               { return m_aExpansion; }
70
0
    void SetExpansion( const OUString& rStr )   { m_aExpansion = rStr;
71
0
                                                  m_bCRLFFlag = false; }
72
73
    virtual std::unique_ptr<SwFieldType> Copy() const override;
74
    virtual UIName GetName() const override;
75
    virtual void SetName(const UIName& newName) 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
83
0
    SfxLinkUpdateMode GetType() const          { return m_RefLink->GetUpdateMode();  }
84
0
    void SetType( SfxLinkUpdateMode nType )    { m_RefLink->SetUpdateMode( nType );  }
85
86
0
    bool IsDeleted() const          { return m_bDeleted; }
87
0
    void SetDeleted( bool b )       { m_bDeleted = b; }
88
89
0
    void Disconnect()               { m_RefLink->Disconnect(); }
90
91
0
    const ::sfx2::SvBaseLink& GetBaseLink() const    { return *m_RefLink; }
92
0
          ::sfx2::SvBaseLink& GetBaseLink()          { return *m_RefLink; }
93
94
0
    const SwDoc* GetDoc() const     { return m_pDoc; }
95
0
          SwDoc* GetDoc()           { return m_pDoc; }
96
    void SetDoc( SwDoc* pDoc );
97
98
0
    void IncRefCnt() {  if( !m_nRefCount++ && m_pDoc ) RefCntChgd(); }
99
0
    void DecRefCnt() {  if( !--m_nRefCount && m_pDoc ) RefCntChgd(); }
100
101
0
    void SetCRLFDelFlag( bool bFlag )    { m_bCRLFFlag = bFlag; }
102
    virtual void UpdateFields() override
103
0
            { UpdateDDE(false); };
104
    void UpdateDDE(const bool bNotifyShells = true);
105
};
106
107
// DDE-field
108
class SwDDEField final : public SwField
109
{
110
private:
111
    virtual OUString ExpandImpl(SwRootFrame const* pLayout) const override;
112
    virtual std::unique_ptr<SwField> Copy() const override;
113
114
public:
115
    SwDDEField(SwDDEFieldType*);
116
    virtual ~SwDDEField() override;
117
118
    /** Get parameter via types.
119
     Name cannot be changed. */
120
    virtual OUString GetPar1() const override;
121
122
    // Command
123
    virtual OUString GetPar2() const override;
124
    virtual void SetPar2(const OUString& rStr) override;
125
};
126
127
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */