LibreOffice Module sw (master)  1
atrref.cxx
Go to the documentation of this file.
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 
20 #include <fmtrfmrk.hxx>
21 
22 #include <hintids.hxx>
23 #include <hints.hxx>
24 #include <txtrfmrk.hxx>
25 #include <swfont.hxx>
26 
28 {
29 }
30 
31 SwFormatRefMark::SwFormatRefMark( const OUString& rName )
33  , SwModify(nullptr)
34  , m_pTextAttr(nullptr)
35  , m_aRefName(rName)
36 {
37 }
38 
41  , SwModify(nullptr)
42  , BroadcasterMixin()
43  , m_pTextAttr(nullptr)
44  , m_aRefName(rAttr.m_aRefName)
45 {
46 }
47 
48 bool SwFormatRefMark::operator==( const SfxPoolItem& rAttr ) const
49 {
50  assert(SfxPoolItem::operator==(rAttr));
51  return m_aRefName == static_cast<const SwFormatRefMark&>(rAttr).m_aRefName;
52 }
53 
55 {
56  return new SwFormatRefMark( *this );
57 }
58 
59 void SwFormatRefMark::Modify(SfxPoolItem const* pOld, SfxPoolItem const* pNew)
60 {
61  NotifyClients(pOld, pNew);
62  if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which()))
63  { // invalidate cached UNO object
64  SetXRefMark(css::uno::Reference<css::text::XTextContent>(nullptr));
65  }
66 }
67 
69 {
71  &static_cast<SwModify&>(*this)); // cast to base class (void*)
72  NotifyClients(&item, &item);
73 }
74 
75 // attribute for content references in the text
76 
78  sal_Int32 const nStartPos, sal_Int32 const*const pEnd)
79  : SwTextAttr(rAttr, nStartPos)
80  , SwTextAttrEnd( rAttr, nStartPos, nStartPos )
81  , m_pTextNode( nullptr )
82  , m_pEnd( nullptr )
83 {
84  rAttr.m_pTextAttr = this;
85  if ( pEnd )
86  {
87  m_nEnd = *pEnd;
88  m_pEnd = & m_nEnd;
89  }
90  else
91  {
92  SetHasDummyChar(true);
93  }
94  SetDontMoveAttr( true );
95  SetOverlapAllowedAttr( true );
96 }
97 
98 const sal_Int32* SwTextRefMark::GetEnd() const
99 {
100  return m_pEnd;
101 }
102 
103 void SwTextRefMark::SetEnd(sal_Int32 n)
104 {
105  *m_pEnd = n;
106  if (m_pHints)
108 }
109 
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 m_nEnd
Definition: txatbase.hxx:130
void SetHasDummyChar(const bool bFlag)
Definition: txatbase.hxx:72
virtual void Modify(SfxPoolItem const *pOld, SfxPoolItem const *pNew) override
Definition: atrref.cxx:59
SwpHints * m_pHints
Definition: txatbase.hxx:61
sal_Int32 * m_pEnd
Definition: txtrfmrk.hxx:30
#define RES_REMOVE_UNO_OBJECT
Definition: hintids.hxx:304
void SetOverlapAllowedAttr(bool bFlag)
Definition: txatbase.hxx:69
virtual ~SwFormatRefMark() override
Definition: atrref.cxx:27
virtual void SetEnd(sal_Int32) override
Definition: atrref.cxx:103
void SetDontMoveAttr(bool bFlag)
Definition: txatbase.hxx:67
SwTextRefMark * m_pTextAttr
Definition: fmtrfmrk.hxx:42
void InvalidateRefMark()
Definition: atrref.cxx:68
void SetXRefMark(css::uno::Reference< css::text::XTextContent > const &xMark)
Definition: fmtrfmrk.hxx:71
void NotifyClients(const SfxPoolItem *pOldValue, const SfxPoolItem *pNewValue)
Definition: calbck.cxx:167
virtual const sal_Int32 * GetEnd() const override
end position
Definition: atrref.cxx:98
virtual bool operator==(const SfxPoolItem &) const override
"Pure virtual methods" of SfxPoolItem.
Definition: atrref.cxx:48
SwFormatRefMark(const OUString &rText)
Definition: atrref.cxx:31
void EndPosChanged() const
Definition: ndhints.hxx:213
#define RES_TXTATR_REFMARK
Definition: hintids.hxx:136
OUString m_aRefName
Definition: fmtrfmrk.hxx:45
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: atrref.cxx:54
sal_uInt16 Which() const
SwTextRefMark(SwFormatRefMark &rAttr, sal_Int32 const nStart, sal_Int32 const *const pEnd=nullptr)
Definition: atrref.cxx:77