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 1074 : SwFmtRefMark::~SwFmtRefMark( )
28 : {
29 1074 : }
30 :
31 172 : SwFmtRefMark::SwFmtRefMark( const OUString& rName )
32 : : SfxPoolItem(RES_TXTATR_REFMARK)
33 : , SwModify(0)
34 : , pTxtAttr(0)
35 172 : , aRefName(rName)
36 : {
37 172 : }
38 :
39 406 : SwFmtRefMark::SwFmtRefMark( const SwFmtRefMark& rAttr )
40 : : SfxPoolItem(RES_TXTATR_REFMARK)
41 : , SwModify(0)
42 : , pTxtAttr(0)
43 406 : , aRefName(rAttr.aRefName)
44 : {
45 406 : }
46 :
47 78 : bool SwFmtRefMark::operator==( const SfxPoolItem& rAttr ) const
48 : {
49 : assert(SfxPoolItem::operator==(rAttr));
50 78 : return aRefName == ((SwFmtRefMark&)rAttr).aRefName;
51 : }
52 :
53 406 : SfxPoolItem* SwFmtRefMark::Clone( SfxItemPool* ) const
54 : {
55 406 : return new SwFmtRefMark( *this );
56 : }
57 :
58 0 : void SwFmtRefMark::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 82 : void SwFmtRefMark::InvalidateRefMark()
68 : {
69 : SwPtrMsgPoolItem const item(RES_REMOVE_UNO_OBJECT,
70 82 : &static_cast<SwModify&>(*this)); // cast to base class (void*)
71 82 : NotifyClients(&item, &item);
72 82 : }
73 :
74 : // Attribut fuer Inhalts-/Positions-Referenzen im Text
75 :
76 82 : SwTxtRefMark::SwTxtRefMark( SwFmtRefMark& rAttr,
77 : sal_Int32 const nStartPos, sal_Int32 const*const pEnd)
78 : : SwTxtAttr(rAttr, nStartPos)
79 : , SwTxtAttrEnd( rAttr, nStartPos, nStartPos )
80 : , m_pTxtNode( 0 )
81 82 : , m_pEnd( 0 )
82 : {
83 82 : rAttr.pTxtAttr = this;
84 82 : if ( pEnd )
85 : {
86 28 : m_nEnd = *pEnd;
87 28 : m_pEnd = & m_nEnd;
88 : }
89 : else
90 : {
91 54 : SetHasDummyChar(true);
92 : }
93 82 : SetDontMoveAttr( true );
94 82 : SetOverlapAllowedAttr( true );
95 82 : }
96 :
97 5086 : sal_Int32* SwTxtRefMark::GetEnd()
98 : {
99 5086 : return m_pEnd;
100 270 : }
101 :
102 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|