fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / framework / source / inc / pattern / frame.hxx
blob9be9949bb9bdacb11b0b59c891fd016c57486ee5
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 .
20 #ifndef INCLUDED_FRAMEWORK_SOURCE_INC_PATTERN_FRAME_HXX
21 #define INCLUDED_FRAMEWORK_SOURCE_INC_PATTERN_FRAME_HXX
23 #include <general.h>
25 #include <com/sun/star/frame/XFrame.hpp>
26 #include <com/sun/star/frame/XController.hpp>
27 #include <com/sun/star/frame/XModel.hpp>
28 #include <com/sun/star/lang/XComponent.hpp>
29 #include <com/sun/star/lang/DisposedException.hpp>
30 #include <com/sun/star/util/XCloseable.hpp>
32 // namespaces
34 namespace framework{
35 namespace pattern{
36 namespace frame{
38 inline css::uno::Reference< css::frame::XModel > extractFrameModel(const css::uno::Reference< css::frame::XFrame >& xFrame)
40 css::uno::Reference< css::frame::XModel > xModel;
41 css::uno::Reference< css::frame::XController > xController;
42 if (xFrame.is())
43 xController = xFrame->getController();
44 if (xController.is())
45 xModel = xController->getModel();
46 return xModel;
49 /** @short close (or dispose) the given resource.
51 @descr It try to close the given resource first.
52 Delegating of the ownership can be influenced from
53 outside. If closing isn't possible (because the
54 needed interface isn't available) dispose() is tried instead.
55 Al possible exception are handled inside.
56 So the user of this method has to look for the return value only.
58 @attention The given resource will not be cleared.
59 But later using of it can produce an exception!
61 @param xResource
62 the object, which should be closed here.
64 @param bDelegateOwnership
65 used at the XCloseable->close() method to define
66 the right owner in case closing failed.
68 @return [bool]
69 sal_True if closing failed.
71 inline bool closeIt(const css::uno::Reference< css::uno::XInterface >& xResource ,
72 bool bDelegateOwnership)
74 css::uno::Reference< css::util::XCloseable > xClose (xResource, css::uno::UNO_QUERY);
75 css::uno::Reference< css::lang::XComponent > xDispose(xResource, css::uno::UNO_QUERY);
77 try
79 if (xClose.is())
80 xClose->close(bDelegateOwnership);
81 else
82 if (xDispose.is())
83 xDispose->dispose();
84 else
85 return false;
87 catch(const css::util::CloseVetoException&)
88 { return false; }
89 catch(const css::lang::DisposedException&)
90 {} // disposed is closed is ...
91 catch(const css::uno::RuntimeException&)
92 { throw; } // should not be suppressed!
93 catch(const css::uno::Exception&)
94 { return false; } // ??? We defined to return a boolen value instead of throwing exceptions ...
95 // (OK: RuntimeExceptions should not be catched inside the core ..)
97 return true;
100 } // namespace frame
101 } // namespace pattern
102 } // namespace framework
104 #endif // INCLUDED_FRAMEWORK_SOURCE_INC_PATTERN_FRAME_HXX
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */