tdf#163486: PVS: Numeric Truncation Error. Return value of the 'size' function is...
[LibreOffice.git] / sd / source / core / anminfo.cxx
blob5f763708ccda01b16145850739ef3d4566049ec2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <editeng/flditem.hxx>
21 #include <editeng/eeitem.hxx>
22 #include <tools/debug.hxx>
24 #include <anminfo.hxx>
25 #include <glob.hxx>
27 using namespace ::com::sun::star;
29 SdAnimationInfo::SdAnimationInfo(SdrObject& rObject)
30 : SdrObjUserData(SdrInventor::StarDrawUserData, SD_ANIMATIONINFO_ID),
31 mePresObjKind (PresObjKind::NONE),
32 meEffect (presentation::AnimationEffect_NONE),
33 meTextEffect (presentation::AnimationEffect_NONE),
34 meSpeed (presentation::AnimationSpeed_SLOW),
35 mbActive (true),
36 mbDimPrevious (false),
37 mbIsMovie (false),
38 mbDimHide (false),
39 mbSoundOn (false),
40 mbPlayFull (false),
41 meClickAction (presentation::ClickAction_NONE),
42 meSecondEffect (presentation::AnimationEffect_NONE),
43 meSecondSpeed (presentation::AnimationSpeed_SLOW),
44 mbSecondSoundOn (false),
45 mbSecondPlayFull (false),
46 mnVerb (0),
47 mrObject (rObject)
49 maBlueScreen = COL_LIGHTMAGENTA;
50 maDimColor = COL_LIGHTGRAY;
53 SdAnimationInfo::SdAnimationInfo(const SdAnimationInfo& rAnmInfo, SdrObject& rObject)
54 : SdrObjUserData (rAnmInfo),
55 mePresObjKind (PresObjKind::NONE),
56 meEffect (rAnmInfo.meEffect),
57 meTextEffect (rAnmInfo.meTextEffect),
58 meSpeed (rAnmInfo.meSpeed),
59 mbActive (rAnmInfo.mbActive),
60 mbDimPrevious (rAnmInfo.mbDimPrevious),
61 mbIsMovie (rAnmInfo.mbIsMovie),
62 mbDimHide (rAnmInfo.mbDimHide),
63 maBlueScreen (rAnmInfo.maBlueScreen),
64 maDimColor (rAnmInfo.maDimColor),
65 maSoundFile (rAnmInfo.maSoundFile),
66 mbSoundOn (rAnmInfo.mbSoundOn),
67 mbPlayFull (rAnmInfo.mbPlayFull),
68 meClickAction (rAnmInfo.meClickAction),
69 meSecondEffect (rAnmInfo.meSecondEffect),
70 meSecondSpeed (rAnmInfo.meSecondSpeed),
71 maSecondSoundFile (rAnmInfo.maSecondSoundFile),
72 mbSecondSoundOn (rAnmInfo.mbSecondSoundOn),
73 mbSecondPlayFull (rAnmInfo.mbSecondPlayFull),
74 mnVerb (rAnmInfo.mnVerb),
75 mrObject (rObject)
77 // can not be copied
78 if(meEffect == presentation::AnimationEffect_PATH)
79 meEffect = presentation::AnimationEffect_NONE;
82 SdAnimationInfo::~SdAnimationInfo()
86 std::unique_ptr<SdrObjUserData> SdAnimationInfo::Clone(SdrObject* pObject) const
88 DBG_ASSERT( pObject, "SdAnimationInfo::Clone(), pObject must not be null!" );
89 if( pObject == nullptr )
90 pObject = &mrObject;
92 return std::unique_ptr<SdrObjUserData>(new SdAnimationInfo(*this, *pObject ));
95 void SdAnimationInfo::SetBookmark( const OUString& rBookmark )
97 if( meClickAction == css::presentation::ClickAction_BOOKMARK )
99 OUString sURL = "#" + rBookmark;
100 SvxFieldItem aURLItem( SvxURLField( sURL, sURL ), EE_FEATURE_FIELD );
101 mrObject.SetMergedItem( aURLItem );
103 else
105 SvxFieldItem aURLItem( SvxURLField( rBookmark, rBookmark ), EE_FEATURE_FIELD );
106 mrObject.SetMergedItem( aURLItem );
110 OUString SdAnimationInfo::GetBookmark() const
112 OUString sBookmark;
114 const SvxFieldItem* pFldItem = &mrObject.GetMergedItem( EE_FEATURE_FIELD );
115 if( pFldItem )
117 SvxURLField* pURLField = const_cast< SvxURLField* >( dynamic_cast<const SvxURLField*>( pFldItem->GetField() ) );
118 if( pURLField )
119 sBookmark = pURLField->GetURL();
122 if( (meClickAction == css::presentation::ClickAction_BOOKMARK) && sBookmark.startsWith("#") )
123 sBookmark = sBookmark.copy( 1 );
125 return sBookmark;
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */