LibreOffice Module svx (master) 1
viewcontactofsdrmediaobj.cxx
Go to the documentation of this file.
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
22#include <svx/svdomedia.hxx>
25#include <vcl/canvastools.hxx>
26
27namespace sdr::contact {
28
30 ViewContactOfSdrObj( rMediaObj )
31{
32}
33
35{
36}
37
39{
40 return *( new ViewObjectContactOfSdrMediaObj( rObjectContact, *this, static_cast< SdrMediaObj& >( GetSdrObject() ).getMediaProperties() ) );
41}
42
44{
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());
48
49 for(sal_uInt32 a(0); a < nCount; a++)
50 {
52 Size aSize(pCandidate ? static_cast< ViewObjectContactOfSdrMediaObj* >(pCandidate)->getPreferredSize() : Size());
53
54 if(0 != aSize.getWidth() || 0 != aSize.getHeight())
55 {
56 return aSize;
57 }
58 }
59
60 return Size();
61}
62
64{
65 // #i71805# Since we may have a whole bunch of VOCs here, make a loop
66 const sal_uInt32 nCount(getViewObjectContactCount());
67
68 for(sal_uInt32 a(0); a < nCount; a++)
69 {
71
72 if(pCandidate)
73 {
74 static_cast< ViewObjectContactOfSdrMediaObj* >(pCandidate)->updateMediaItem(rItem);
75 }
76 }
77}
78
79void ViewContactOfSdrMediaObj::executeMediaItem( const ::avmedia::MediaItem& rItem )
80{
81 const sal_uInt32 nCount(getViewObjectContactCount());
82
83 for(sal_uInt32 a(0); a < nCount; a++)
84 {
86
87 if(pCandidate)
88 {
89 static_cast< ViewObjectContactOfSdrMediaObj* >(pCandidate)->executeMediaItem(rItem);
90 }
91 }
92}
93
94void ViewContactOfSdrMediaObj::mediaPropertiesChanged( const ::avmedia::MediaItem& rNewState )
95{
96 static_cast< SdrMediaObj& >(GetSdrObject()).mediaPropertiesChanged(rNewState);
97}
98
100{
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());
105
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());
112
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);
121 aTransform, rURL, aBackgroundColor, nPixelBorder,
122 GetSdrMediaObj().getSnapshot()));
123
124 rVisitor.visit(xRetval);
125}
126
127}
128
129/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr tools::Long getHeight() const
constexpr tools::Long getWidth() const
void set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue)
TYPE getWidth() const
TYPE getMinX() const
TYPE getMinY() const
TYPE getHeight() const
virtual void visit(const Primitive2DReference &)=0
void mediaPropertiesChanged(const ::avmedia::MediaItem &rNewState)
void executeMediaItem(const ::avmedia::MediaItem &rItem)
virtual void createViewIndependentPrimitive2DSequence(drawinglayer::primitive2d::Primitive2DDecompositionVisitor &rVisitor) const override
virtual ViewObjectContact & CreateObjectSpecificViewObjectContact(ObjectContact &rObjectContact) override
void updateMediaItem(::avmedia::MediaItem &rItem) const
sal_uInt32 getViewObjectContactCount() const
Definition: viewcontact.hxx:65
ViewObjectContact * getViewObjectContact(sal_uInt32 a) const
Definition: viewcontact.hxx:66
int nCount
uno_Any a
basegfx::B2DRange b2DRectangleFromRectangle(const ::tools::Rectangle &rRect)