merge the formfield patch from ooo-build
[ooovba.git] / applied_patches / 0571-slideshow-mute-sound.diff
bloba0e182f9e8c66573b7a7dae51d67b0445aa361fa
1 Play sound only in exactly one slideshow view
3 From: Thorsten Behrens <thb@openoffice.org>
6 ---
8 sdext/source/presenter/PresenterSlideShowView.cxx | 12 ++++++++-
9 slideshow/source/engine/shapes/viewmediashape.cxx | 12 ++++++++-
10 slideshow/source/engine/shapes/viewmediashape.hxx | 1 +
11 slideshow/source/engine/slideshowimpl.cxx | 28 +++++++++++++++++++++
12 slideshow/source/engine/slideview.cxx | 16 +++++++++++-
13 slideshow/source/inc/unoview.hxx | 10 ++++++++
14 6 files changed, 75 insertions(+), 4 deletions(-)
17 diff --git sdext/source/presenter/PresenterSlideShowView.cxx sdext/source/presenter/PresenterSlideShowView.cxx
18 index 339ba3b..4dbd709 100644
19 --- sdext/source/presenter/PresenterSlideShowView.cxx
20 +++ sdext/source/presenter/PresenterSlideShowView.cxx
21 @@ -173,7 +173,17 @@ void PresenterSlideShowView::LateInit (void)
22 // Add the new slide show view to the slide show.
23 if (mxSlideShow.is() && ! mbIsViewAdded)
25 - mxSlideShow->addView(this);
26 + Reference<presentation::XSlideShowView> xView (this);
27 + mxSlideShow->addView(xView);
28 + // Prevent embeded sounds being played twice at the same time by
29 + // disabling sound for the new slide show view.
30 + beans::PropertyValue aProperty;
31 + aProperty.Name = A2S("IsSoundEnabled");
32 + Sequence<Any> aValues (2);
33 + aValues[0] <<= xView;
34 + aValues[1] <<= sal_False;
35 + aProperty.Value <<= aValues;
36 + mxSlideShow->setProperty(aProperty);
37 mbIsViewAdded = true;
40 diff --git slideshow/source/engine/shapes/viewmediashape.cxx slideshow/source/engine/shapes/viewmediashape.cxx
41 index 1d4714c..3778c55 100644
42 --- slideshow/source/engine/shapes/viewmediashape.cxx
43 +++ slideshow/source/engine/shapes/viewmediashape.cxx
44 @@ -74,6 +74,7 @@
45 #include "viewmediashape.hxx"
46 #include "mediashape.hxx"
47 #include "tools.hxx"
48 +#include "unoview.hxx"
50 using namespace ::com::sun::star;
52 @@ -91,12 +92,19 @@ namespace slideshow
53 mxShape( rxShape ),
54 mxPlayer(),
55 mxPlayerWindow(),
56 - mxComponentContext( rxContext )
57 + mxComponentContext( rxContext ),
58 + mbIsSoundEnabled(true)
60 ENSURE_OR_THROW( mxShape.is(), "ViewMediaShape::ViewMediaShape(): Invalid Shape" );
61 ENSURE_OR_THROW( mpViewLayer, "ViewMediaShape::ViewMediaShape(): Invalid View" );
62 ENSURE_OR_THROW( mpViewLayer->getCanvas(), "ViewMediaShape::ViewMediaShape(): Invalid ViewLayer canvas" );
63 ENSURE_OR_THROW( mxComponentContext.is(), "ViewMediaShape::ViewMediaShape(): Invalid component context" );
65 + UnoViewSharedPtr pUnoView (::boost::dynamic_pointer_cast<UnoView>(rViewLayer));
66 + if (pUnoView)
67 + {
68 + mbIsSoundEnabled = pUnoView->isSoundEnabled();
69 + }
72 // ---------------------------------------------------------------------
73 @@ -360,7 +368,7 @@ namespace slideshow
74 getPropertyValue( bMute,
75 rxProps,
76 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Mute" )));
77 - mxPlayer->setMute( bMute );
78 + mxPlayer->setMute( bMute || !mbIsSoundEnabled);
80 sal_Int16 nVolumeDB(0);
81 getPropertyValue( nVolumeDB,
82 diff --git slideshow/source/engine/shapes/viewmediashape.hxx slideshow/source/engine/shapes/viewmediashape.hxx
83 index 5351890..fa4b305 100644
84 --- slideshow/source/engine/shapes/viewmediashape.hxx
85 +++ slideshow/source/engine/shapes/viewmediashape.hxx
86 @@ -171,6 +171,7 @@ namespace slideshow
87 ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > mxPlayer;
88 ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayerWindow > mxPlayerWindow;
89 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> mxComponentContext;
90 + bool mbIsSoundEnabled;
93 typedef ::boost::shared_ptr< ViewMediaShape > ViewMediaShapeSharedPtr;
94 diff --git slideshow/source/engine/slideshowimpl.cxx slideshow/source/engine/slideshowimpl.cxx
95 index 92a1562..340e5d3 100644
96 --- slideshow/source/engine/slideshowimpl.cxx
97 +++ slideshow/source/engine/slideshowimpl.cxx
98 @@ -1484,6 +1484,34 @@ sal_Bool SlideShowImpl::setProperty( beans::PropertyValue const& rProperty )
99 return (rProperty.Value >>= mbNoSlideTransitions);
102 + if (rProperty.Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("IsSoundEnabled")))
104 + uno::Sequence<uno::Any> aValues;
105 + uno::Reference<presentation::XSlideShowView> xView;
106 + sal_Bool bValue (false);
107 + if ((rProperty.Value >>= aValues)
108 + && aValues.getLength()==2
109 + && (aValues[0] >>= xView)
110 + && (aValues[1] >>= bValue))
112 + // Look up the view.
113 + for (UnoViewVector::const_iterator
114 + iView (maViewContainer.begin()),
115 + iEnd (maViewContainer.end());
116 + iView!=iEnd;
117 + ++iView)
119 + if (*iView && (*iView)->getUnoView()==xView)
121 + // Store the flag at the view so that media shapes have
122 + // access to it.
123 + (*iView)->setIsSoundEnabled(bValue);
124 + return true;
130 return false;
133 diff --git slideshow/source/engine/slideview.cxx slideshow/source/engine/slideview.cxx
134 index c9efa47..bdc82dc 100644
135 --- slideshow/source/engine/slideview.cxx
136 +++ slideshow/source/engine/slideview.cxx
137 @@ -715,6 +715,8 @@ private:
138 // UnoView:
139 virtual void _dispose();
140 virtual uno::Reference<presentation::XSlideShowView> getUnoView()const;
141 + virtual void setIsSoundEnabled (const bool bValue);
142 + virtual bool isSoundEnabled (void) const;
144 // XEventListener:
145 virtual void SAL_CALL disposing( lang::EventObject const& evt )
146 @@ -755,6 +757,7 @@ private:
148 basegfx::B2DHomMatrix maViewTransform;
149 basegfx::B2DSize maUserSize;
150 + bool mbIsSoundEnabled;
154 @@ -770,7 +773,8 @@ SlideView::SlideView( const uno::Reference<presentation::XSlideShowView>& xView,
155 maViewLayers(),
156 maClip(),
157 maViewTransform(),
158 - maUserSize( 1.0, 1.0 ) // default size: one-by-one rectangle
159 + maUserSize( 1.0, 1.0 ), // default size: one-by-one rectangle
160 + mbIsSoundEnabled(true)
162 // take care not constructing any UNO references to this _inside_
163 // ctor, shift that code to createSlideView()!
164 @@ -1001,6 +1005,16 @@ uno::Reference<presentation::XSlideShowView> SlideView::getUnoView() const
165 return mxView;
168 +void SlideView::setIsSoundEnabled (const bool bValue)
170 + mbIsSoundEnabled = bValue;
173 +bool SlideView::isSoundEnabled (void) const
175 + return mbIsSoundEnabled;
178 void SlideView::_dispose()
180 dispose();
181 diff --git slideshow/source/inc/unoview.hxx slideshow/source/inc/unoview.hxx
182 index bf14bab..70e8250 100644
183 --- slideshow/source/inc/unoview.hxx
184 +++ slideshow/source/inc/unoview.hxx
185 @@ -68,6 +68,16 @@ namespace slideshow
186 with a different calling convention under Windows).
188 virtual void _dispose() = 0;
190 + /** Return whether the sound play back is enabled.
191 + */
192 + virtual bool isSoundEnabled (void) const = 0;
194 + /** Tell the view whether it may play sounds. Disabling this
195 + can be used to prevent different views to play the same
196 + sounds at the same time.
197 + */
198 + virtual void setIsSoundEnabled (const bool bValue) = 0;
201 typedef ::boost::shared_ptr< UnoView > UnoViewSharedPtr;