tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / svx / source / sdr / contact / viewcontactofsdrmediaobj.cxx
blob7c713bc4b7b9620bc26f86f6e532b66a0ca0c168
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 .
21 #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
22 #include <svx/svdomedia.hxx>
23 #include <sdr/contact/viewobjectcontactofsdrmediaobj.hxx>
24 #include <drawinglayer/primitive2d/mediaprimitive2d.hxx>
25 #include <vcl/canvastools.hxx>
27 namespace sdr::contact {
29 ViewContactOfSdrMediaObj::ViewContactOfSdrMediaObj( SdrMediaObj& rMediaObj ) :
30 ViewContactOfSdrObj( rMediaObj )
34 ViewContactOfSdrMediaObj::~ViewContactOfSdrMediaObj()
38 ViewObjectContact& ViewContactOfSdrMediaObj::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
40 return *( new ViewObjectContactOfSdrMediaObj( rObjectContact, *this, static_cast< SdrMediaObj& >( GetSdrObject() ).getMediaProperties() ) );
43 Size ViewContactOfSdrMediaObj::getPreferredSize() const
45 // #i71805# Since we may have a whole bunch of VOCs here, make a loop
46 // return first useful size -> the size from the first which is visualized as a window
47 const sal_uInt32 nCount(getViewObjectContactCount());
49 for(sal_uInt32 a(0); a < nCount; a++)
51 ViewObjectContact* pCandidate = getViewObjectContact(a);
52 Size aSize(pCandidate ? static_cast< ViewObjectContactOfSdrMediaObj* >(pCandidate)->getPreferredSize() : Size());
54 if(0 != aSize.getWidth() || 0 != aSize.getHeight())
56 return aSize;
60 return Size();
63 void ViewContactOfSdrMediaObj::updateMediaItem( ::avmedia::MediaItem& rItem ) const
65 // #i71805# Since we may have a whole bunch of VOCs here, make a loop
66 const sal_uInt32 nCount(getViewObjectContactCount());
68 for(sal_uInt32 a(0); a < nCount; a++)
70 ViewObjectContact* pCandidate = getViewObjectContact(a);
72 if(pCandidate)
74 static_cast< ViewObjectContactOfSdrMediaObj* >(pCandidate)->updateMediaItem(rItem);
79 void ViewContactOfSdrMediaObj::executeMediaItem( const ::avmedia::MediaItem& rItem )
81 const sal_uInt32 nCount(getViewObjectContactCount());
83 for(sal_uInt32 a(0); a < nCount; a++)
85 ViewObjectContact* pCandidate = getViewObjectContact(a);
87 if(pCandidate)
89 static_cast< ViewObjectContactOfSdrMediaObj* >(pCandidate)->executeMediaItem(rItem);
94 void ViewContactOfSdrMediaObj::mediaPropertiesChanged( const ::avmedia::MediaItem& rNewState )
96 static_cast< SdrMediaObj& >(GetSdrObject()).mediaPropertiesChanged(rNewState);
99 void ViewContactOfSdrMediaObj::createViewIndependentPrimitive2DSequence(drawinglayer::primitive2d::Primitive2DDecompositionVisitor& rVisitor) const
101 // create range using the model data directly. This is in SdrTextObj::aRect which i will access using
102 // GetGeoRect() to not trigger any calculations. It's the unrotated geometry which is okay for MediaObjects ATM.
103 const tools::Rectangle aRectangle(GetSdrMediaObj().GetGeoRect());
104 const basegfx::B2DRange aRange = vcl::unotools::b2DRectangleFromRectangle(aRectangle);
106 // create object transform
107 basegfx::B2DHomMatrix aTransform;
108 aTransform.set(0, 0, aRange.getWidth());
109 aTransform.set(1, 1, aRange.getHeight());
110 aTransform.set(0, 2, aRange.getMinX());
111 aTransform.set(1, 2, aRange.getMinY());
113 // create media primitive. Always create primitives to allow the
114 // decomposition of MediaPrimitive2D to create needed invisible elements for HitTest
115 // and/or BoundRect
116 const basegfx::BColor aBackgroundColor(67.0 / 255.0, 67.0 / 255.0, 67.0 / 255.0);
117 const OUString& rURL(GetSdrMediaObj().getURL());
118 const sal_uInt32 nPixelBorder(4);
119 const drawinglayer::primitive2d::Primitive2DReference xRetval(
120 new drawinglayer::primitive2d::MediaPrimitive2D(
121 aTransform, rURL, aBackgroundColor, nPixelBorder,
122 GetSdrMediaObj().getSnapshot()));
124 rVisitor.visit(xRetval);
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */