Skip to content

Commit 22f46bd

Browse files
author
Noel Grandin
committed
use more concrete UNO classes
Change-Id: Id10786bbf7985adbb251224b45f9dabcc84d0a3d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182721 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]>
1 parent 376466a commit 22f46bd

File tree

34 files changed

+347
-406
lines changed

34 files changed

+347
-406
lines changed

UnoControls/source/controls/OConnectionPointContainerHelper.cxx

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include <cppuhelper/queryinterface.hxx>
2525
#include <comphelper/sequence.hxx>
26+
#include <rtl/ref.hxx>
2627

2728
// namespaces
2829

@@ -98,7 +99,7 @@ Sequence< Type > SAL_CALL OConnectionPointContainerHelper::getConnectionPointTyp
9899
Reference< XConnectionPoint > SAL_CALL OConnectionPointContainerHelper::queryConnectionPoint( const Type& aType )
99100
{
100101
// Set default return value, if method failed.
101-
Reference< XConnectionPoint > xConnectionPoint;
102+
rtl::Reference< OConnectionPointHelper > xConnectionPoint;
102103

103104
// Get all elements of the container, which have the searched type.
104105
comphelper::OInterfaceContainerHelper2* pSpecialContainer = m_aMultiTypeContainer.getContainer( aType );

animations/source/animcore/animcore.cxx

+11-15
Original file line numberDiff line numberDiff line change
@@ -1214,29 +1214,25 @@ Reference< XCloneable > SAL_CALL AnimationNode::createClone()
12141214
{
12151215
std::unique_lock aGuard( m_aMutex );
12161216

1217-
Reference< XCloneable > xNewNode;
1217+
rtl::Reference< AnimationNode > xNewNode;
12181218
try
12191219
{
12201220
xNewNode = new AnimationNode( *this );
12211221

12221222
if( !maChildren.empty() )
12231223
{
1224-
Reference< XTimeContainer > xContainer( xNewNode, UNO_QUERY );
1225-
if( xContainer.is() )
1224+
for (auto const& child : maChildren)
12261225
{
1227-
for (auto const& child : maChildren)
1226+
Reference< XCloneable > xCloneable(child, UNO_QUERY );
1227+
if( xCloneable.is() ) try
12281228
{
1229-
Reference< XCloneable > xCloneable(child, UNO_QUERY );
1230-
if( xCloneable.is() ) try
1231-
{
1232-
Reference< XAnimationNode > xNewChildNode( xCloneable->createClone(), UNO_QUERY );
1233-
if( xNewChildNode.is() )
1234-
xContainer->appendChild( xNewChildNode );
1235-
}
1236-
catch(const Exception&)
1237-
{
1238-
SAL_INFO("animations", "animations::AnimationNode::createClone(), exception caught!");
1239-
}
1229+
Reference< XAnimationNode > xNewChildNode( xCloneable->createClone(), UNO_QUERY );
1230+
if( xNewChildNode.is() )
1231+
xNewNode->appendChild( xNewChildNode );
1232+
}
1233+
catch(const Exception&)
1234+
{
1235+
SAL_INFO("animations", "animations::AnimationNode::createClone(), exception caught!");
12401236
}
12411237
}
12421238
}

avmedia/source/gstreamer/gstplayer.cxx

+70-73
Original file line numberDiff line numberDiff line change
@@ -830,8 +830,6 @@ uno::Reference< ::media::XPlayerWindow > SAL_CALL Player::createPlayerWindow( co
830830
{
831831
::osl::MutexGuard aGuard(m_aMutex);
832832

833-
uno::Reference< ::media::XPlayerWindow > xRet;
834-
835833
if (rArguments.getLength() > 1)
836834
rArguments[1] >>= maArea;
837835

@@ -842,93 +840,92 @@ uno::Reference< ::media::XPlayerWindow > SAL_CALL Player::createPlayerWindow( co
842840

843841
SAL_INFO( "avmedia.gstreamer", AVVERSION "Player::createPlayerWindow " << aSize.Width << "x" << aSize.Height << " length: " << rArguments.getLength() );
844842

845-
if( aSize.Width > 0 && aSize.Height > 0 )
843+
if( aSize.Width <= 0 || aSize.Height <= 0 )
844+
return nullptr;
845+
846+
if (rArguments.getLength() <= 2)
846847
{
847-
if (rArguments.getLength() <= 2)
848-
{
849-
xRet = new ::avmedia::gstreamer::Window;
850-
return xRet;
851-
}
848+
return new ::avmedia::gstreamer::Window;
849+
}
852850

853-
sal_IntPtr pIntPtr = 0;
854-
rArguments[ 2 ] >>= pIntPtr;
855-
SystemChildWindow *pParentWindow = reinterpret_cast< SystemChildWindow* >( pIntPtr );
856-
if (!pParentWindow)
857-
return nullptr;
851+
sal_IntPtr pIntPtr = 0;
852+
rArguments[ 2 ] >>= pIntPtr;
853+
SystemChildWindow *pParentWindow = reinterpret_cast< SystemChildWindow* >( pIntPtr );
854+
if (!pParentWindow)
855+
return nullptr;
858856

859-
const SystemEnvData* pEnvData = pParentWindow->GetSystemData();
860-
if (!pEnvData)
861-
return nullptr;
857+
const SystemEnvData* pEnvData = pParentWindow->GetSystemData();
858+
if (!pEnvData)
859+
return nullptr;
862860

863-
// tdf#124027: the position of embedded window is identical w/ the position
864-
// of media object in all other vclplugs (kf5, gen), in gtk3 w/o gtksink it
865-
// needs to be translated
866-
if (pEnvData->toolkit == SystemEnvData::Toolkit::Gtk)
867-
{
868-
Point aPoint = pParentWindow->GetPosPixel();
869-
maArea.X = aPoint.getX();
870-
maArea.Y = aPoint.getY();
871-
}
861+
// tdf#124027: the position of embedded window is identical w/ the position
862+
// of media object in all other vclplugs (kf5, gen), in gtk3 w/o gtksink it
863+
// needs to be translated
864+
if (pEnvData->toolkit == SystemEnvData::Toolkit::Gtk)
865+
{
866+
Point aPoint = pParentWindow->GetPosPixel();
867+
maArea.X = aPoint.getX();
868+
maArea.Y = aPoint.getY();
869+
}
872870

873-
mbUseGtkSink = false;
871+
mbUseGtkSink = false;
874872

875-
GstElement *pVideosink = static_cast<GstElement*>(pParentWindow->CreateGStreamerSink());
876-
if (pVideosink)
877-
{
878-
if (pEnvData->toolkit == SystemEnvData::Toolkit::Gtk)
879-
mbUseGtkSink = true;
880-
}
873+
GstElement *pVideosink = static_cast<GstElement*>(pParentWindow->CreateGStreamerSink());
874+
if (pVideosink)
875+
{
876+
if (pEnvData->toolkit == SystemEnvData::Toolkit::Gtk)
877+
mbUseGtkSink = true;
878+
}
879+
else
880+
{
881+
if (pEnvData->platform == SystemEnvData::Platform::Wayland)
882+
pVideosink = gst_element_factory_make("waylandsink", "video-output");
881883
else
882-
{
883-
if (pEnvData->platform == SystemEnvData::Platform::Wayland)
884-
pVideosink = gst_element_factory_make("waylandsink", "video-output");
885-
else
886-
pVideosink = gst_element_factory_make("autovideosink", "video-output");
887-
if (!pVideosink)
888-
return nullptr;
889-
}
884+
pVideosink = gst_element_factory_make("autovideosink", "video-output");
885+
if (!pVideosink)
886+
return nullptr;
887+
}
890888

891-
xRet = new ::avmedia::gstreamer::Window;
889+
rtl::Reference< ::avmedia::gstreamer::Window > xRet = new ::avmedia::gstreamer::Window;
892890

893-
g_object_set(G_OBJECT(mpPlaybin), "video-sink", pVideosink, nullptr);
894-
g_object_set(G_OBJECT(mpPlaybin), "force-aspect-ratio", FALSE, nullptr);
891+
g_object_set(G_OBJECT(mpPlaybin), "video-sink", pVideosink, nullptr);
892+
g_object_set(G_OBJECT(mpPlaybin), "force-aspect-ratio", FALSE, nullptr);
895893

896-
if ((rArguments.getLength() >= 4) && (rArguments[3] >>= pIntPtr) && pIntPtr)
894+
if ((rArguments.getLength() >= 4) && (rArguments[3] >>= pIntPtr) && pIntPtr)
895+
{
896+
auto pItem = reinterpret_cast<const avmedia::MediaItem*>(pIntPtr);
897+
Graphic aGraphic = pItem->getGraphic();
898+
const text::GraphicCrop& rCrop = pItem->getCrop();
899+
if (!aGraphic.IsNone() && (rCrop.Bottom > 0 || rCrop.Left > 0 || rCrop.Right > 0 || rCrop.Top > 0))
897900
{
898-
auto pItem = reinterpret_cast<const avmedia::MediaItem*>(pIntPtr);
899-
Graphic aGraphic = pItem->getGraphic();
900-
const text::GraphicCrop& rCrop = pItem->getCrop();
901-
if (!aGraphic.IsNone() && (rCrop.Bottom > 0 || rCrop.Left > 0 || rCrop.Right > 0 || rCrop.Top > 0))
901+
// The media item has a non-empty cropping set. Try to crop the video accordingly.
902+
Size aPref = aGraphic.GetPrefSize();
903+
Size aPixel = aGraphic.GetSizePixel();
904+
tools::Long nLeft = aPixel.getWidth() * rCrop.Left / aPref.getWidth();
905+
tools::Long nTop = aPixel.getHeight() * rCrop.Top / aPref.getHeight();
906+
tools::Long nRight = aPixel.getWidth() * rCrop.Right / aPref.getWidth();
907+
tools::Long nBottom = aPixel.getHeight() * rCrop.Bottom / aPref.getHeight();
908+
GstElement* pVideoFilter = gst_element_factory_make("videocrop", nullptr);
909+
if (pVideoFilter)
902910
{
903-
// The media item has a non-empty cropping set. Try to crop the video accordingly.
904-
Size aPref = aGraphic.GetPrefSize();
905-
Size aPixel = aGraphic.GetSizePixel();
906-
tools::Long nLeft = aPixel.getWidth() * rCrop.Left / aPref.getWidth();
907-
tools::Long nTop = aPixel.getHeight() * rCrop.Top / aPref.getHeight();
908-
tools::Long nRight = aPixel.getWidth() * rCrop.Right / aPref.getWidth();
909-
tools::Long nBottom = aPixel.getHeight() * rCrop.Bottom / aPref.getHeight();
910-
GstElement* pVideoFilter = gst_element_factory_make("videocrop", nullptr);
911-
if (pVideoFilter)
912-
{
913-
g_object_set(G_OBJECT(pVideoFilter), "left", nLeft, nullptr);
914-
g_object_set(G_OBJECT(pVideoFilter), "top", nTop, nullptr);
915-
g_object_set(G_OBJECT(pVideoFilter), "right", nRight, nullptr);
916-
g_object_set(G_OBJECT(pVideoFilter), "bottom", nBottom, nullptr);
917-
g_object_set(G_OBJECT(mpPlaybin), "video-filter", pVideoFilter, nullptr);
918-
}
911+
g_object_set(G_OBJECT(pVideoFilter), "left", nLeft, nullptr);
912+
g_object_set(G_OBJECT(pVideoFilter), "top", nTop, nullptr);
913+
g_object_set(G_OBJECT(pVideoFilter), "right", nRight, nullptr);
914+
g_object_set(G_OBJECT(pVideoFilter), "bottom", nBottom, nullptr);
915+
g_object_set(G_OBJECT(mpPlaybin), "video-filter", pVideoFilter, nullptr);
919916
}
920917
}
918+
}
921919

922-
if (!mbUseGtkSink)
923-
{
924-
mnWindowID = pEnvData->GetWindowHandle(pParentWindow->ImplGetFrame());
925-
mpDisplay = pEnvData->pDisplay;
926-
SAL_INFO( "avmedia.gstreamer", AVVERSION "set window id to " << static_cast<int>(mnWindowID) << " XOverlay " << mpXOverlay);
927-
}
928-
gst_element_set_state( mpPlaybin, GST_STATE_PAUSED );
929-
if (!mbUseGtkSink && mpXOverlay)
930-
gst_video_overlay_set_window_handle( mpXOverlay, mnWindowID );
920+
if (!mbUseGtkSink)
921+
{
922+
mnWindowID = pEnvData->GetWindowHandle(pParentWindow->ImplGetFrame());
923+
mpDisplay = pEnvData->pDisplay;
924+
SAL_INFO( "avmedia.gstreamer", AVVERSION "set window id to " << static_cast<int>(mnWindowID) << " XOverlay " << mpXOverlay);
931925
}
926+
gst_element_set_state( mpPlaybin, GST_STATE_PAUSED );
927+
if (!mbUseGtkSink && mpXOverlay)
928+
gst_video_overlay_set_window_handle( mpXOverlay, mnWindowID );
932929

933930
return xRet;
934931
}

basctl/source/basicide/unomodel.cxx

+4-8
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,11 @@ void SIDEModel::notImplemented()
120120
css::uno::Reference< css::uno::XInterface > SAL_CALL SIDEModel::getCurrentSelection()
121121
{
122122
SolarMutexGuard aGuard;
123-
uno::Reference<container::XEnumeration> xEnum;
124123
Shell* pShell = GetShell();
125-
126-
if (pShell)
127-
{
128-
OUString sText = GetShell()->GetSelectionText(false);
129-
xEnum = new SelectionEnumeration(sText);
130-
}
131-
return xEnum;
124+
if (!pShell)
125+
return nullptr;
126+
OUString sText = GetShell()->GetSelectionText(false);
127+
return uno::Reference<container::XEnumeration>(new SelectionEnumeration(sText));
132128
}
133129

134130
} // namespace basctl

comphelper/source/container/embeddedobjectcontainer.cxx

+17-16
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#include <comphelper/propertyvalue.hxx>
4848
#include <cppuhelper/weakref.hxx>
4949
#include <sal/log.hxx>
50+
#include <rtl/ref.hxx>
5051

5152
#include <officecfg/Office/Common.hxx>
5253

@@ -1433,23 +1434,23 @@ uno::Reference< io::XInputStream > EmbeddedObjectContainer::GetGraphicReplacemen
14331434
const uno::Reference< embed::XEmbeddedObject >& xObj,
14341435
OUString* pMediaType )
14351436
{
1436-
uno::Reference< io::XInputStream > xInStream;
1437-
if ( xObj.is() )
1438-
{
1439-
try
1440-
{
1441-
// retrieving of the visual representation can switch object to running state
1442-
embed::VisualRepresentation aRep = xObj->getPreferredVisualRepresentation( nViewAspect );
1443-
if ( pMediaType )
1444-
*pMediaType = aRep.Flavor.MimeType;
1437+
if ( !xObj.is() )
1438+
return nullptr;
14451439

1446-
uno::Sequence < sal_Int8 > aSeq;
1447-
aRep.Data >>= aSeq;
1448-
xInStream = new ::comphelper::SequenceInputStream( aSeq );
1449-
}
1450-
catch (const uno::Exception&)
1451-
{
1452-
}
1440+
rtl::Reference< ::comphelper::SequenceInputStream > xInStream;
1441+
try
1442+
{
1443+
// retrieving of the visual representation can switch object to running state
1444+
embed::VisualRepresentation aRep = xObj->getPreferredVisualRepresentation( nViewAspect );
1445+
if ( pMediaType )
1446+
*pMediaType = aRep.Flavor.MimeType;
1447+
1448+
uno::Sequence < sal_Int8 > aSeq;
1449+
aRep.Data >>= aSeq;
1450+
xInStream = new ::comphelper::SequenceInputStream( aSeq );
1451+
}
1452+
catch (const uno::Exception&)
1453+
{
14531454
}
14541455

14551456
return xInStream;

editeng/source/accessibility/AccessibleEditableTextPara.cxx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2510,7 +2510,7 @@ namespace accessibility
25102510

25112511
css::uno::Reference< css::accessibility::XAccessibleHyperlink > SAL_CALL AccessibleEditableTextPara::getHyperLink( ::sal_Int32 nLinkIndex )
25122512
{
2513-
css::uno::Reference< css::accessibility::XAccessibleHyperlink > xRef;
2513+
rtl::Reference< AccessibleHyperlink > xRef;
25142514

25152515
SvxAccessibleTextAdapter& rT = GetTextForwarder();
25162516
const sal_Int32 nPara = GetParagraphIndex();

editeng/source/accessibility/AccessibleHyperlink.cxx

+11-14
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,19 @@ namespace accessibility
7878

7979
uno::Reference< css::accessibility::XAccessibleKeyBinding > SAL_CALL AccessibleHyperlink::getAccessibleActionKeyBinding( sal_Int32 nIndex )
8080
{
81-
uno::Reference< css::accessibility::XAccessibleKeyBinding > xKeyBinding;
81+
if( !isValid() || ( nIndex != 0 ) )
82+
return nullptr;
8283

83-
if( isValid() && ( nIndex == 0 ) )
84-
{
85-
rtl::Reference<::comphelper::OAccessibleKeyBindingHelper> pKeyBindingHelper = new ::comphelper::OAccessibleKeyBindingHelper();
86-
xKeyBinding = pKeyBindingHelper;
87-
88-
awt::KeyStroke aKeyStroke;
89-
aKeyStroke.Modifiers = 0;
90-
aKeyStroke.KeyCode = KEY_RETURN;
91-
aKeyStroke.KeyChar = 0;
92-
aKeyStroke.KeyFunc = 0;
93-
pKeyBindingHelper->AddKeyBinding( aKeyStroke );
94-
}
84+
rtl::Reference<::comphelper::OAccessibleKeyBindingHelper> pKeyBindingHelper = new ::comphelper::OAccessibleKeyBindingHelper();
85+
86+
awt::KeyStroke aKeyStroke;
87+
aKeyStroke.Modifiers = 0;
88+
aKeyStroke.KeyCode = KEY_RETURN;
89+
aKeyStroke.KeyChar = 0;
90+
aKeyStroke.KeyFunc = 0;
91+
pKeyBindingHelper->AddKeyBinding( aKeyStroke );
9592

96-
return xKeyBinding;
93+
return pKeyBindingHelper;
9794
}
9895

9996
// XAccessibleHyperlink

0 commit comments

Comments
 (0)