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