LibreOffice Module chart2 (master) 1
StatusBarCommandDispatch.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
22#include <com/sun/star/view/XSelectionSupplier.hpp>
23#include <ChartModel.hxx>
24#include <utility>
25
26using namespace ::com::sun::star;
27
28using ::com::sun::star::uno::Reference;
29using ::com::sun::star::uno::Sequence;
30
31namespace chart
32{
33
37 const Reference< view::XSelectionSupplier > & xSelSupp ) :
39 m_xChartModel(std::move( xModel )),
40 m_xSelectionSupplier( xSelSupp ),
41 m_bIsModified( false )
42{}
43
45{}
46
48{
49 if( m_xChartModel.is())
50 {
51 m_xChartModel->addModifyListener( this );
52 }
53
54 if( m_xSelectionSupplier.is())
55 {
56 m_xSelectionSupplier->addSelectionChangeListener( this );
57 }
58}
59
61 const OUString & rURL,
62 const Reference< frame::XStatusListener > & xSingleListener /* = 0 */ )
63{
64 bool bFireAll( rURL.isEmpty() );
65 bool bFireContext( bFireAll || rURL == ".uno:Context" );
66 bool bFireModified( bFireAll || rURL == ".uno:ModifiedStatus" );
67
68 if( bFireContext && m_xChartModel.is())
69 {
70 uno::Any aArg;
72 fireStatusEventForURL( ".uno:Context", aArg, true, xSingleListener );
73 }
74 if( bFireModified )
75 {
76 uno::Any aArg;
77 if( m_bIsModified )
78 aArg <<= OUString("*");
79 fireStatusEventForURL( ".uno:ModifiedStatus", aArg, true, xSingleListener );
80 }
81}
82
83// ____ XDispatch ____
85 const util::URL& /* URL */,
86 const Sequence< beans::PropertyValue >& /* Arguments */ )
87{
88 // nothing to do here
89}
90
91// ____ WeakComponentImplHelperBase ____
93void StatusBarCommandDispatch::disposing(std::unique_lock<std::mutex>& /*rGuard*/)
94{
95 m_xChartModel.clear();
97}
98
99// ____ XEventListener (base of XModifyListener) ____
100void SAL_CALL StatusBarCommandDispatch::disposing( const lang::EventObject& /* Source */ )
101{
102 m_xChartModel.clear();
103 m_xSelectionSupplier.clear();
104}
105
106// ____ XModifyListener ____
107void SAL_CALL StatusBarCommandDispatch::modified( const lang::EventObject& aEvent )
108{
109 if( m_xChartModel.is())
110 m_bIsModified = m_xChartModel->isModified();
111
113}
114
115// ____ XSelectionChangeListener ____
116void SAL_CALL StatusBarCommandDispatch::selectionChanged( const lang::EventObject& /* aEvent */ )
117{
118 if( m_xSelectionSupplier.is())
120 else
122 fireAllStatusEvents( nullptr );
123}
124
125} // namespace chart
126
127/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
AnyEventRef aEvent
virtual void SAL_CALL modified(const css::lang::EventObject &aEvent) override
const OUString & getObjectCID() const
static OUString getSelectedObjectText(std::u16string_view rObjectCID, const rtl::Reference<::chart::ChartModel > &xChartDocument)
This is used for showing the currently selected object in the status bar (command "Context")
virtual void SAL_CALL selectionChanged(const css::lang::EventObject &aEvent) override
virtual void fireStatusEvent(const OUString &rURL, const css::uno::Reference< css::frame::XStatusListener > &xSingleListener) override
css::uno::Reference< css::view::XSelectionSupplier > m_xSelectionSupplier
StatusBarCommandDispatch(const css::uno::Reference< css::uno::XComponentContext > &xContext, rtl::Reference<::chart::ChartModel > xModel, const css::uno::Reference< css::view::XSelectionSupplier > &xSelSupp)
virtual void SAL_CALL modified(const css::lang::EventObject &aEvent) override
virtual void SAL_CALL dispatch(const css::util::URL &URL, const css::uno::Sequence< css::beans::PropertyValue > &Arguments) override
rtl::Reference<::chart::ChartModel > m_xChartModel
virtual void disposing(std::unique_lock< std::mutex > &rGuard) override
is called when this is disposed
::cppu::ImplInheritanceHelper< CommandDispatch, css::view::XSelectionChangeListener > StatusBarCommandDispatch_Base
Reference< XModel > xModel