1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: StatusBarCommandDispatch.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
34 #include "StatusBarCommandDispatch.hxx"
35 #include "ObjectNameProvider.hxx"
37 #include <com/sun/star/util/XModifyBroadcaster.hpp>
39 // #ifndef _VOS_MUTEX_HXX_
40 // #include <vos/mutex.hxx>
42 // #ifndef _SV_SVAPP_HXX
43 // #include <vcl/svapp.hxx>
46 // for ressource strings STR_UNDO and STR_REDO
47 #include <sfx2/sfx.hrc>
51 using namespace ::com::sun::star
;
53 using ::com::sun::star::uno::Reference
;
54 using ::com::sun::star::uno::Sequence
;
55 using ::rtl::OUString
;
60 StatusBarCommandDispatch::StatusBarCommandDispatch(
61 const Reference
< uno::XComponentContext
> & xContext
,
62 const Reference
< frame::XModel
> & xModel
,
63 const Reference
< view::XSelectionSupplier
> & xSelSupp
) :
64 impl::StatusBarCommandDispatch_Base( xContext
),
65 m_xModifiable( xModel
, uno::UNO_QUERY
),
66 m_xSelectionSupplier( xSelSupp
),
67 m_bIsModified( false )
70 StatusBarCommandDispatch::~StatusBarCommandDispatch()
73 void StatusBarCommandDispatch::initialize()
75 if( m_xModifiable
.is())
77 Reference
< util::XModifyBroadcaster
> xModifyBroadcaster( m_xModifiable
, uno::UNO_QUERY
);
78 OSL_ASSERT( xModifyBroadcaster
.is());
79 if( xModifyBroadcaster
.is())
80 xModifyBroadcaster
->addModifyListener( this );
83 if( m_xSelectionSupplier
.is())
85 m_xSelectionSupplier
->addSelectionChangeListener( this );
89 void StatusBarCommandDispatch::fireStatusEvent(
90 const OUString
& rURL
,
91 const Reference
< frame::XStatusListener
> & xSingleListener
/* = 0 */ )
93 bool bFireAll(rURL
.getLength() == 0);
94 bool bFireContext( bFireAll
|| rURL
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(".uno:Context")));
95 bool bFireModified( bFireAll
|| rURL
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(".uno:ModifiedStatus")));
100 Reference
< chart2::XChartDocument
> xDoc( m_xModifiable
, uno::UNO_QUERY
);
101 aArg
<<= ObjectNameProvider::getSelectedObjectText( m_aSelectedCID
, xDoc
);
102 fireStatusEventForURL( C2U(".uno:Context"), aArg
, true, xSingleListener
);
109 fireStatusEventForURL( C2U(".uno:ModifiedStatus"), aArg
, true, xSingleListener
);
113 // ____ XDispatch ____
114 void SAL_CALL
StatusBarCommandDispatch::dispatch(
115 const util::URL
& /* URL */,
116 const Sequence
< beans::PropertyValue
>& /* Arguments */ )
117 throw (uno::RuntimeException
)
119 // nothing to do here
122 // ____ WeakComponentImplHelperBase ____
123 /// is called when this is disposed
124 void SAL_CALL
StatusBarCommandDispatch::disposing()
126 m_xModifiable
.clear();
127 m_xSelectionSupplier
.clear();
130 // ____ XEventListener (base of XModifyListener) ____
131 void SAL_CALL
StatusBarCommandDispatch::disposing( const lang::EventObject
& /* Source */ )
132 throw (uno::RuntimeException
)
134 m_xModifiable
.clear();
135 m_xSelectionSupplier
.clear();
138 // ____ XModifyListener ____
139 void SAL_CALL
StatusBarCommandDispatch::modified( const lang::EventObject
& aEvent
)
140 throw (uno::RuntimeException
)
142 if( m_xModifiable
.is())
143 m_bIsModified
= m_xModifiable
->isModified();
145 CommandDispatch::modified( aEvent
);
148 // ____ XSelectionChangeListener ____
149 void SAL_CALL
StatusBarCommandDispatch::selectionChanged( const lang::EventObject
& /* aEvent */ )
150 throw (uno::RuntimeException
)
152 if( m_xSelectionSupplier
.is())
153 m_xSelectionSupplier
->getSelection() >>= m_aSelectedCID
;
155 m_aSelectedCID
= OUString();
156 fireAllStatusEvents( 0 );