1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_chart2.hxx"
31 #include "StatusBarCommandDispatch.hxx"
32 #include "ObjectNameProvider.hxx"
34 #include <com/sun/star/util/XModifyBroadcaster.hpp>
36 // #ifndef _VOS_MUTEX_HXX_
37 // #include <vos/mutex.hxx>
39 // #ifndef _SV_SVAPP_HXX
40 // #include <vcl/svapp.hxx>
43 // for ressource strings STR_UNDO and STR_REDO
44 #include <sfx2/sfx.hrc>
48 using namespace ::com::sun::star
;
50 using ::com::sun::star::uno::Reference
;
51 using ::com::sun::star::uno::Sequence
;
52 using ::rtl::OUString
;
57 StatusBarCommandDispatch::StatusBarCommandDispatch(
58 const Reference
< uno::XComponentContext
> & xContext
,
59 const Reference
< frame::XModel
> & xModel
,
60 const Reference
< view::XSelectionSupplier
> & xSelSupp
) :
61 impl::StatusBarCommandDispatch_Base( xContext
),
62 m_xModifiable( xModel
, uno::UNO_QUERY
),
63 m_xSelectionSupplier( xSelSupp
),
64 m_bIsModified( false )
67 StatusBarCommandDispatch::~StatusBarCommandDispatch()
70 void StatusBarCommandDispatch::initialize()
72 if( m_xModifiable
.is())
74 Reference
< util::XModifyBroadcaster
> xModifyBroadcaster( m_xModifiable
, uno::UNO_QUERY
);
75 OSL_ASSERT( xModifyBroadcaster
.is());
76 if( xModifyBroadcaster
.is())
77 xModifyBroadcaster
->addModifyListener( this );
80 if( m_xSelectionSupplier
.is())
82 m_xSelectionSupplier
->addSelectionChangeListener( this );
86 void StatusBarCommandDispatch::fireStatusEvent(
87 const OUString
& rURL
,
88 const Reference
< frame::XStatusListener
> & xSingleListener
/* = 0 */ )
90 bool bFireAll(rURL
.getLength() == 0);
91 bool bFireContext( bFireAll
|| rURL
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(".uno:Context")));
92 bool bFireModified( bFireAll
|| rURL
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(".uno:ModifiedStatus")));
97 Reference
< chart2::XChartDocument
> xDoc( m_xModifiable
, uno::UNO_QUERY
);
98 aArg
<<= ObjectNameProvider::getSelectedObjectText( m_aSelectedOID
.getObjectCID(), xDoc
);
99 fireStatusEventForURL( C2U(".uno:Context"), aArg
, true, xSingleListener
);
106 fireStatusEventForURL( C2U(".uno:ModifiedStatus"), aArg
, true, xSingleListener
);
110 // ____ XDispatch ____
111 void SAL_CALL
StatusBarCommandDispatch::dispatch(
112 const util::URL
& /* URL */,
113 const Sequence
< beans::PropertyValue
>& /* Arguments */ )
114 throw (uno::RuntimeException
)
116 // nothing to do here
119 // ____ WeakComponentImplHelperBase ____
120 /// is called when this is disposed
121 void SAL_CALL
StatusBarCommandDispatch::disposing()
123 m_xModifiable
.clear();
124 m_xSelectionSupplier
.clear();
127 // ____ XEventListener (base of XModifyListener) ____
128 void SAL_CALL
StatusBarCommandDispatch::disposing( const lang::EventObject
& /* Source */ )
129 throw (uno::RuntimeException
)
131 m_xModifiable
.clear();
132 m_xSelectionSupplier
.clear();
135 // ____ XModifyListener ____
136 void SAL_CALL
StatusBarCommandDispatch::modified( const lang::EventObject
& aEvent
)
137 throw (uno::RuntimeException
)
139 if( m_xModifiable
.is())
140 m_bIsModified
= m_xModifiable
->isModified();
142 CommandDispatch::modified( aEvent
);
145 // ____ XSelectionChangeListener ____
146 void SAL_CALL
StatusBarCommandDispatch::selectionChanged( const lang::EventObject
& /* aEvent */ )
147 throw (uno::RuntimeException
)
149 if( m_xSelectionSupplier
.is())
150 m_aSelectedOID
= ObjectIdentifier( m_xSelectionSupplier
->getSelection() );
152 m_aSelectedOID
= ObjectIdentifier();
153 fireAllStatusEvents( 0 );