1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <unoviewcontainer.hxx>
23 #include <osl/diagnose.h>
28 using namespace ::com::sun::star
;
35 UnoViewContainer::UnoViewContainer() :
40 bool UnoViewContainer::addView( const UnoViewSharedPtr
& rView
)
42 // check whether same view is already added
44 uno::Reference
< presentation::XSlideShowView
> rTmpView
= rView
->getUnoView();
46 if( ::std::any_of( maViews
.begin(),
48 [&rTmpView
]( const UnoViewSharedPtr
& pView
)
49 { return rTmpView
== pView
->getUnoView(); } ) )
56 maViews
.push_back( rView
);
61 UnoViewSharedPtr
UnoViewContainer::removeView( const uno::Reference
< presentation::XSlideShowView
>& xView
)
63 // check whether same view is already added
64 const UnoViewVector::iterator
aEnd( maViews
.end() );
65 UnoViewVector::iterator aIter
;
67 // added in the first place?
68 if( (aIter
=::std::find_if( maViews
.begin(),
70 [&xView
]( const UnoViewSharedPtr
& pView
)
71 { return xView
== pView
->getUnoView(); } )) == aEnd
)
73 // nope, nothing to do
74 return UnoViewSharedPtr();
81 [&xView
]( const UnoViewSharedPtr
& pView
)
82 { return xView
== pView
->getUnoView(); } ) == 1,
83 "UnoViewContainer::removeView(): View was added multiple times" );
85 UnoViewSharedPtr
pView( *aIter
);
87 // actually erase from container
88 maViews
.erase( aIter
);
93 void UnoViewContainer::dispose()
95 for( const auto& pView
: maViews
)
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */