Line data Source code
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 :
27 547 : SwFormatRefMark::~SwFormatRefMark( )
28 : {
29 547 : }
30 :
31 98 : SwFormatRefMark::SwFormatRefMark( const OUString& rName )
32 : : SfxPoolItem(RES_TXTATR_REFMARK)
33 : , SwModify(0)
34 : , pTextAttr(0)
35 98 : , aRefName(rName)
36 : {
37 98 : }
38 :
39 195 : SwFormatRefMark::SwFormatRefMark( const SwFormatRefMark& rAttr )
40 : : SfxPoolItem(RES_TXTATR_REFMARK)
41 : , SwModify(0)
42 : , pTextAttr(0)
43 195 : , aRefName(rAttr.aRefName)
44 : {
45 195 : }
46 :
47 39 : bool SwFormatRefMark::operator==( const SfxPoolItem& rAttr ) const
48 : {
49 : assert(SfxPoolItem::operator==(rAttr));
50 39 : return aRefName == static_cast<const SwFormatRefMark&>(rAttr).aRefName;
51 : }
52 :
53 195 : SfxPoolItem* SwFormatRefMark::Clone( SfxItemPool* ) const
54 : {
55 195 : return new SwFormatRefMark( *this );
56 : }
57 :
58 0 : void SwFormatRefMark::Modify(SfxPoolItem const* pOld, SfxPoolItem const* pNew)
59 : {
60 0 : NotifyClients(pOld, pNew);
61 0 : if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which()))
62 : { // invalidate cached UNO object
63 0 : SetXRefMark(css::uno::Reference<css::text::XTextContent>(0));
64 : }
65 0 : }
66 :
67 39 : void SwFormatRefMark::InvalidateRefMark()
68 : {
69 : SwPtrMsgPoolItem const item(RES_REMOVE_UNO_OBJECT,
70 39 : &static_cast<SwModify&>(*this)); // cast to base class (void*)
71 39 : NotifyClients(&item, &item);
72 39 : }
73 :
74 : // Attribut fuer Inhalts-/Positions-Referenzen im Text
75 :
76 39 : SwTextRefMark::SwTextRefMark( SwFormatRefMark& rAttr,
77 : sal_Int32 const nStartPos, sal_Int32 const*const pEnd)
78 : : SwTextAttr(rAttr, nStartPos)
79 : , SwTextAttrEnd( rAttr, nStartPos, nStartPos )
80 : , m_pTextNode( 0 )
81 39 : , m_pEnd( 0 )
82 : {
83 39 : rAttr.pTextAttr = this;
84 39 : if ( pEnd )
85 : {
86 14 : m_nEnd = *pEnd;
87 14 : m_pEnd = & m_nEnd;
88 : }
89 : else
90 : {
91 25 : SetHasDummyChar(true);
92 : }
93 39 : SetDontMoveAttr( true );
94 39 : SetOverlapAllowedAttr( true );
95 39 : }
96 :
97 2661 : sal_Int32* SwTextRefMark::GetEnd()
98 : {
99 2661 : return m_pEnd;
100 177 : }
101 :
102 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|