fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / framework / source / dispatch / dispatchinformationprovider.cxx
blob9d0464faf4d4dde09bdc9f19be1a7a8893e42522
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 #include <dispatch/dispatchinformationprovider.hxx>
21 #include <dispatch/closedispatcher.hxx>
22 #include <stdtypes.h>
23 #include <services.h>
25 #include <com/sun/star/frame/CommandGroup.hpp>
26 #include <com/sun/star/frame/AppDispatchProvider.hpp>
28 #include <comphelper/sequence.hxx>
30 namespace framework{
32 DispatchInformationProvider::DispatchInformationProvider(const css::uno::Reference< css::uno::XComponentContext >& xContext ,
33 const css::uno::Reference< css::frame::XFrame >& xFrame)
34 : m_xContext (xContext )
35 , m_xFrame (xFrame )
39 DispatchInformationProvider::~DispatchInformationProvider()
43 css::uno::Sequence< sal_Int16 > SAL_CALL DispatchInformationProvider::getSupportedCommandGroups()
44 throw (css::uno::RuntimeException, std::exception)
46 css::uno::Sequence< css::uno::Reference< css::frame::XDispatchInformationProvider > > lProvider = implts_getAllSubProvider();
47 sal_Int32 c1 = lProvider.getLength();
48 sal_Int32 i1 = 0;
50 ::std::vector< sal_Int16 > lGroups;
52 for (i1=0; i1<c1; ++i1)
54 // ignore controller, which doesn't implement the right interface
55 css::uno::Reference< css::frame::XDispatchInformationProvider > xProvider = lProvider[i1];
56 if (!xProvider.is())
57 continue;
59 const css::uno::Sequence< sal_Int16 > lProviderGroups = xProvider->getSupportedCommandGroups();
60 sal_Int32 c2 = lProviderGroups.getLength();
61 sal_Int32 i2 = 0;
62 for (i2=0; i2<c2; ++i2)
64 const sal_Int16& rGroup = lProviderGroups[i2];
65 ::std::vector< sal_Int16 >::const_iterator pGroup =
66 ::std::find(lGroups.begin(), lGroups.end(), rGroup);
67 if (pGroup == lGroups.end())
68 lGroups.push_back(rGroup);
72 return ::comphelper::containerToSequence(lGroups);
75 css::uno::Sequence< css::frame::DispatchInformation > SAL_CALL DispatchInformationProvider::getConfigurableDispatchInformation(sal_Int16 nCommandGroup)
76 throw (css::uno::RuntimeException, std::exception)
78 css::uno::Sequence< css::uno::Reference< css::frame::XDispatchInformationProvider > > lProvider = implts_getAllSubProvider();
79 sal_Int32 c1 = lProvider.getLength();
80 sal_Int32 i1 = 0;
82 BaseHash< css::frame::DispatchInformation > lInfos;
84 for (i1=0; i1<c1; ++i1)
86 try
88 // ignore controller, which doesn't implement the right interface
89 css::uno::Reference< css::frame::XDispatchInformationProvider > xProvider = lProvider[i1];
90 if (!xProvider.is())
91 continue;
93 const css::uno::Sequence< css::frame::DispatchInformation > lProviderInfos = xProvider->getConfigurableDispatchInformation(nCommandGroup);
94 sal_Int32 c2 = lProviderInfos.getLength();
95 sal_Int32 i2 = 0;
96 for (i2=0; i2<c2; ++i2)
98 const css::frame::DispatchInformation& rInfo = lProviderInfos[i2];
99 BaseHash< css::frame::DispatchInformation >::const_iterator pInfo = lInfos.find(rInfo.Command);
100 if (pInfo == lInfos.end())
101 lInfos[rInfo.Command] = rInfo;
104 catch(const css::uno::RuntimeException&)
105 { throw; }
106 catch(const css::uno::Exception&)
107 { continue; }
110 c1 = (sal_Int32)lInfos.size();
111 i1 = 0;
113 css::uno::Sequence< css::frame::DispatchInformation > lReturn(c1);
114 BaseHash< css::frame::DispatchInformation >::const_iterator pStepp;
115 for ( pStepp = lInfos.begin();
116 pStepp != lInfos.end () && i1<c1;
117 ++pStepp, ++i1 )
119 lReturn[i1] = pStepp->second;
121 return lReturn;
124 css::uno::Sequence< css::uno::Reference< css::frame::XDispatchInformationProvider > > DispatchInformationProvider::implts_getAllSubProvider()
126 css::uno::Reference< css::frame::XFrame > xFrame(m_xFrame);
127 if (!xFrame.is())
128 return css::uno::Sequence< css::uno::Reference< css::frame::XDispatchInformationProvider > >();
130 CloseDispatcher* pCloser = new CloseDispatcher(m_xContext, xFrame, OUString("_self")); // explicit "_self" ... not "" ... see implementation of close dispatcher itself!
131 css::uno::Reference< css::uno::XInterface > xCloser(static_cast< css::frame::XDispatch* >(pCloser), css::uno::UNO_QUERY);
133 css::uno::Reference< css::frame::XDispatchInformationProvider > xCloseDispatch(xCloser , css::uno::UNO_QUERY);
134 css::uno::Reference< css::frame::XDispatchInformationProvider > xController (xFrame->getController() , css::uno::UNO_QUERY);
135 css::uno::Reference< css::frame::XDispatchInformationProvider > xAppDispatcher = css::frame::AppDispatchProvider::create(m_xContext);
136 css::uno::Sequence< css::uno::Reference< css::frame::XDispatchInformationProvider > > lProvider(3);
137 lProvider[0] = xController;
138 lProvider[1] = xCloseDispatch;
139 lProvider[2] = xAppDispatcher;
141 return lProvider;
144 } // namespace framework
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */