1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <svx/svxids.hrc>
21 #include <sfx2/event.hxx>
22 #include <svx/hlnkitem.hxx>
26 SfxPoolItem
* SvxHyperlinkItem::CreateDefault() { return new SvxHyperlinkItem(TypedWhichId
<SvxHyperlinkItem
>(0));}
28 SvxHyperlinkItem::SvxHyperlinkItem( const SvxHyperlinkItem
& rHyperlinkItem
):
29 SfxPoolItem(rHyperlinkItem
)
31 sName
= rHyperlinkItem
.sName
;
32 sURL
= rHyperlinkItem
.sURL
;
33 sTarget
= rHyperlinkItem
.sTarget
;
34 eType
= rHyperlinkItem
.eType
;
35 sIntName
= rHyperlinkItem
.sIntName
;
36 nMacroEvents
= rHyperlinkItem
.nMacroEvents
;
37 sReplacementText
= rHyperlinkItem
.sReplacementText
;
39 if( rHyperlinkItem
.GetMacroTable() )
40 pMacroTable
.reset( new SvxMacroTableDtor( *rHyperlinkItem
.GetMacroTable() ) );
44 SvxHyperlinkItem::SvxHyperlinkItem( TypedWhichId
<SvxHyperlinkItem
> _nWhich
, OUString aName
, OUString aURL
,
45 OUString aTarget
, OUString aIntName
, SvxLinkInsertMode eTyp
,
46 HyperDialogEvent nEvents
, SvxMacroTableDtor
const *pMacroTbl
, OUString aReplacementText
):
47 SfxPoolItem (_nWhich
),
48 sName (std::move(aName
)),
49 sURL (std::move(aURL
)),
50 sTarget (std::move(aTarget
)),
52 sReplacementText (std::move(aReplacementText
)),
53 sIntName (std::move(aIntName
)),
54 nMacroEvents (nEvents
)
57 pMacroTable
.reset( new SvxMacroTableDtor ( *pMacroTbl
) );
60 SvxHyperlinkItem
* SvxHyperlinkItem::Clone( SfxItemPool
* ) const
62 return new SvxHyperlinkItem( *this );
65 bool SvxHyperlinkItem::operator==( const SfxPoolItem
& rAttr
) const
67 assert(SfxPoolItem::operator==(rAttr
));
69 const SvxHyperlinkItem
& rItem
= static_cast<const SvxHyperlinkItem
&>(rAttr
);
71 bool bRet
= ( sName
== rItem
.sName
&&
73 sTarget
== rItem
.sTarget
&&
74 eType
== rItem
.eType
&&
75 sIntName
== rItem
.sIntName
&&
76 nMacroEvents
== rItem
.nMacroEvents
&&
77 sReplacementText
== rItem
.sReplacementText
);
81 const SvxMacroTableDtor
* pOther
= static_cast<const SvxHyperlinkItem
&>(rAttr
).pMacroTable
.get();
83 return ( !pOther
|| pOther
->empty() );
85 return pMacroTable
->empty();
87 const SvxMacroTableDtor
& rOwn
= *pMacroTable
;
88 const SvxMacroTableDtor
& rOther
= *pOther
;
90 return rOwn
== rOther
;
93 void SvxHyperlinkItem::SetMacro( HyperDialogEvent nEvent
, const SvxMacro
& rMacro
)
95 SvMacroItemId nSfxEvent
= SvMacroItemId::NONE
;
98 case HyperDialogEvent::MouseOverObject
:
99 nSfxEvent
= SvMacroItemId::OnMouseOver
;
101 case HyperDialogEvent::MouseClickObject
:
102 nSfxEvent
= SvMacroItemId::OnClick
;
104 case HyperDialogEvent::MouseOutObject
:
105 nSfxEvent
= SvMacroItemId::OnMouseOut
;
111 pMacroTable
.reset( new SvxMacroTableDtor
);
113 pMacroTable
->Insert( nSfxEvent
, rMacro
);
116 void SvxHyperlinkItem::SetMacroTable( const SvxMacroTableDtor
& rTbl
)
118 pMacroTable
.reset( new SvxMacroTableDtor ( rTbl
) );
121 bool SvxHyperlinkItem::QueryValue( css::uno::Any
& rVal
, sal_uInt8 nMemberId
) const
123 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
124 nMemberId
&= ~CONVERT_TWIPS
;
127 case MID_HLINK_NAME
:
130 case MID_HLINK_TEXT
:
136 case MID_HLINK_TARGET
:
140 rVal
<<= static_cast<sal_Int32
>(eType
);
142 case MID_HLINK_REPLACEMENTTEXT
:
143 rVal
<<= sReplacementText
;
152 bool SvxHyperlinkItem::PutValue( const css::uno::Any
& rVal
, sal_uInt8 nMemberId
)
154 nMemberId
&= ~CONVERT_TWIPS
;
159 case MID_HLINK_NAME
:
164 case MID_HLINK_TEXT
:
174 case MID_HLINK_TARGET
:
182 eType
= static_cast<SvxLinkInsertMode
>(static_cast<sal_uInt16
>(nVal
));
184 case MID_HLINK_REPLACEMENTTEXT
:
187 sReplacementText
= aStr
;
196 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */