1*9e0e4191SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*9e0e4191SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*9e0e4191SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*9e0e4191SAndrew Rist * distributed with this work for additional information
6*9e0e4191SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*9e0e4191SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*9e0e4191SAndrew Rist * "License"); you may not use this file except in compliance
9*9e0e4191SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*9e0e4191SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*9e0e4191SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*9e0e4191SAndrew Rist * software distributed under the License is distributed on an
15*9e0e4191SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9e0e4191SAndrew Rist * KIND, either express or implied. See the License for the
17*9e0e4191SAndrew Rist * specific language governing permissions and limitations
18*9e0e4191SAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*9e0e4191SAndrew Rist *************************************************************/
21*9e0e4191SAndrew Rist
22*9e0e4191SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_reportdesign.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <ReportControllerObserver.hxx>
28cdf0e10cSrcweir #include <ReportController.hxx>
29cdf0e10cSrcweir #include <svl/smplhint.hxx>
30cdf0e10cSrcweir #include <vos/mutex.hxx>
31cdf0e10cSrcweir #include <vcl/svapp.hxx>
32cdf0e10cSrcweir #include <com/sun/star/report/XFormattedField.hpp>
33cdf0e10cSrcweir #include <com/sun/star/awt/FontSlant.hpp>
34cdf0e10cSrcweir #include <FormattedFieldBeautifier.hxx>
35cdf0e10cSrcweir
36cdf0e10cSrcweir #include <svx/unopage.hxx>
37cdf0e10cSrcweir
38cdf0e10cSrcweir // DBG_*
39cdf0e10cSrcweir #include <tools/debug.hxx>
40cdf0e10cSrcweir // DBG_UNHANDLED_EXCEPTION
41cdf0e10cSrcweir #include <tools/diagnose_ex.h>
42cdf0e10cSrcweir
43cdf0e10cSrcweir namespace rptui
44cdf0e10cSrcweir {
45cdf0e10cSrcweir
46cdf0e10cSrcweir using namespace ::com::sun::star;
47cdf0e10cSrcweir
48cdf0e10cSrcweir // const OReportController *& m_pReportController;
49cdf0e10cSrcweir
50cdf0e10cSrcweir DECLARE_STL_USTRINGACCESS_MAP(bool, AllProperties);
51cdf0e10cSrcweir DECLARE_STL_STDKEY_MAP(uno::Reference< beans::XPropertySet >, AllProperties, PropertySetInfoCache);
52cdf0e10cSrcweir
53cdf0e10cSrcweir class OXReportControllerObserverImpl
54cdf0e10cSrcweir {
55cdf0e10cSrcweir OXReportControllerObserverImpl(OXReportControllerObserverImpl&);
56cdf0e10cSrcweir void operator =(OXReportControllerObserverImpl&);
57cdf0e10cSrcweir public:
58cdf0e10cSrcweir const OReportController& m_rReportController;
59cdf0e10cSrcweir ::std::vector< uno::Reference< container::XChild> > m_aSections;
60cdf0e10cSrcweir ::osl::Mutex m_aMutex;
61cdf0e10cSrcweir oslInterlockedCount m_nLocks;
62cdf0e10cSrcweir sal_Bool m_bReadOnly;
63cdf0e10cSrcweir
64cdf0e10cSrcweir OXReportControllerObserverImpl(const OReportController& _rController);
65cdf0e10cSrcweir ~OXReportControllerObserverImpl();
66cdf0e10cSrcweir };
67cdf0e10cSrcweir
68cdf0e10cSrcweir // -----------------------------------------------------------------------------
69cdf0e10cSrcweir
OXReportControllerObserverImpl(const OReportController & _rController)70cdf0e10cSrcweir OXReportControllerObserverImpl::OXReportControllerObserverImpl(const OReportController& _rController)
71cdf0e10cSrcweir :m_rReportController(_rController)
72cdf0e10cSrcweir ,m_nLocks(0)
73cdf0e10cSrcweir ,m_bReadOnly(sal_False)
74cdf0e10cSrcweir {
75cdf0e10cSrcweir }
76cdf0e10cSrcweir
~OXReportControllerObserverImpl()77cdf0e10cSrcweir OXReportControllerObserverImpl::~OXReportControllerObserverImpl()
78cdf0e10cSrcweir {
79cdf0e10cSrcweir }
80cdf0e10cSrcweir
81cdf0e10cSrcweir // -----------------------------------------------------------------------------
82cdf0e10cSrcweir // -----------------------------------------------------------------------------
83cdf0e10cSrcweir // -----------------------------------------------------------------------------
84cdf0e10cSrcweir
DBG_NAME(rpt_OXReportControllerObserver)85cdf0e10cSrcweir DBG_NAME(rpt_OXReportControllerObserver)
86cdf0e10cSrcweir
87cdf0e10cSrcweir OXReportControllerObserver::OXReportControllerObserver(const OReportController& _rController)
88cdf0e10cSrcweir :m_pImpl(new OXReportControllerObserverImpl(_rController) )
89cdf0e10cSrcweir ,m_aFormattedFieldBeautifier(_rController)
90cdf0e10cSrcweir ,m_aFixedTextColor(_rController)
91cdf0e10cSrcweir {
92cdf0e10cSrcweir DBG_CTOR( rpt_OXReportControllerObserver,NULL);
93cdf0e10cSrcweir
94cdf0e10cSrcweir Application::AddEventListener(LINK( this, OXReportControllerObserver, SettingsChanged ) );
95cdf0e10cSrcweir }
96cdf0e10cSrcweir
~OXReportControllerObserver()97cdf0e10cSrcweir OXReportControllerObserver::~OXReportControllerObserver()
98cdf0e10cSrcweir {
99cdf0e10cSrcweir DBG_CTOR( rpt_OXReportControllerObserver,NULL);
100cdf0e10cSrcweir Application::RemoveEventListener(LINK( this, OXReportControllerObserver, SettingsChanged ) );
101cdf0e10cSrcweir }
102cdf0e10cSrcweir
103cdf0e10cSrcweir // -----------------------------------------------------------------------------
IMPL_LINK(OXReportControllerObserver,SettingsChanged,VclWindowEvent *,_pEvt)104cdf0e10cSrcweir IMPL_LINK(OXReportControllerObserver, SettingsChanged, VclWindowEvent*, _pEvt)
105cdf0e10cSrcweir {
106cdf0e10cSrcweir if ( _pEvt )
107cdf0e10cSrcweir {
108cdf0e10cSrcweir sal_Int32 nEvent = _pEvt->GetId();
109cdf0e10cSrcweir /*
110cdf0e10cSrcweir // just for debug
111cdf0e10cSrcweir if (nEvent == VCLEVENT_WINDOW_CHILDCREATED ||
112cdf0e10cSrcweir nEvent == VCLEVENT_WINDOW_PAINT ||
113cdf0e10cSrcweir nEvent == VCLEVENT_WINDOW_MOVE ||
114cdf0e10cSrcweir nEvent == VCLEVENT_WINDOW_RESIZE ||
115cdf0e10cSrcweir nEvent == VCLEVENT_WINDOW_SHOW ||
116cdf0e10cSrcweir nEvent == VCLEVENT_WINDOW_MOUSEMOVE ||
117cdf0e10cSrcweir nEvent == VCLEVENT_WINDOW_FRAMETITLECHANGED ||
118cdf0e10cSrcweir nEvent == VCLEVENT_WINDOW_HIDE ||
119cdf0e10cSrcweir nEvent == VCLEVENT_EDIT_MODIFY ||
120cdf0e10cSrcweir nEvent == VCLEVENT_SCROLLBAR_ENDSCROLL ||
121cdf0e10cSrcweir nEvent == VCLEVENT_EDIT_SELECTIONCHANGED ||
122cdf0e10cSrcweir nEvent == VCLEVENT_TABPAGE_INSERTED ||
123cdf0e10cSrcweir nEvent == VCLEVENT_TABPAGE_REMOVED ||
124cdf0e10cSrcweir nEvent == VCLEVENT_TOOLBOX_FORMATCHANGED ||
125cdf0e10cSrcweir nEvent == VCLEVENT_TOOLBOX_ITEMADDED ||
126cdf0e10cSrcweir nEvent == VCLEVENT_TOOLBOX_ALLITEMCHANGED ||
127cdf0e10cSrcweir nEvent == VCLEVENT_MENUBARADDED ||
128cdf0e10cSrcweir nEvent == 1
129cdf0e10cSrcweir )
130cdf0e10cSrcweir {
131cdf0e10cSrcweir return 0L;
132cdf0e10cSrcweir }
133cdf0e10cSrcweir */
134cdf0e10cSrcweir
135cdf0e10cSrcweir if (nEvent == VCLEVENT_APPLICATION_DATACHANGED )
136cdf0e10cSrcweir {
137cdf0e10cSrcweir DataChangedEvent* pData = reinterpret_cast<DataChangedEvent*>(_pEvt->GetData());
138cdf0e10cSrcweir if ( pData && ((( pData->GetType() == DATACHANGED_SETTINGS ) ||
139cdf0e10cSrcweir ( pData->GetType() == DATACHANGED_DISPLAY )) &&
140cdf0e10cSrcweir ( pData->GetFlags() & SETTINGS_STYLE )))
141cdf0e10cSrcweir {
142cdf0e10cSrcweir OEnvLock aLock(*this);
143cdf0e10cSrcweir
144cdf0e10cSrcweir // sal_uInt32 nCount = m_pImpl->m_aSections.size();
145cdf0e10cSrcweir
146cdf0e10cSrcweir // send all Section Objects a 'tingle'
147cdf0e10cSrcweir // maybe they need a change in format, color, etc
148cdf0e10cSrcweir ::std::vector< uno::Reference< container::XChild > >::const_iterator aIter = m_pImpl->m_aSections.begin();
149cdf0e10cSrcweir ::std::vector< uno::Reference< container::XChild > >::const_iterator aEnd = m_pImpl->m_aSections.end();
150cdf0e10cSrcweir for (;aIter != aEnd; aIter++)
151cdf0e10cSrcweir {
152cdf0e10cSrcweir const uno::Reference<container::XChild> xChild (*aIter);
153cdf0e10cSrcweir if (xChild.is())
154cdf0e10cSrcweir {
155cdf0e10cSrcweir uno::Reference<report::XSection> xSection(xChild, uno::UNO_QUERY);
156cdf0e10cSrcweir if (xSection.is())
157cdf0e10cSrcweir {
158cdf0e10cSrcweir const sal_Int32 nCount = xSection->getCount();
159cdf0e10cSrcweir for (sal_Int32 i = 0; i < nCount; ++i)
160cdf0e10cSrcweir {
161cdf0e10cSrcweir const uno::Any aObj = xSection->getByIndex(i);
162cdf0e10cSrcweir uno::Reference < report::XReportComponent > xReportComponent(aObj, uno::UNO_QUERY);
163cdf0e10cSrcweir if (xReportComponent.is())
164cdf0e10cSrcweir {
165cdf0e10cSrcweir m_aFormattedFieldBeautifier.handle(xReportComponent);
166cdf0e10cSrcweir m_aFixedTextColor.handle(xReportComponent);
167cdf0e10cSrcweir }
168cdf0e10cSrcweir }
169cdf0e10cSrcweir }
170cdf0e10cSrcweir }
171cdf0e10cSrcweir }
172cdf0e10cSrcweir }
173cdf0e10cSrcweir }
174cdf0e10cSrcweir }
175cdf0e10cSrcweir
176cdf0e10cSrcweir return 0L;
177cdf0e10cSrcweir }
178cdf0e10cSrcweir
179cdf0e10cSrcweir // XEventListener
disposing(const lang::EventObject & e)180cdf0e10cSrcweir void SAL_CALL OXReportControllerObserver::disposing(const lang::EventObject& e) throw( uno::RuntimeException )
181cdf0e10cSrcweir {
182cdf0e10cSrcweir (void) e;
183cdf0e10cSrcweir // check if it's an object we have cached informations about
184cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xSourceSet(e.Source, uno::UNO_QUERY);
185cdf0e10cSrcweir if ( xSourceSet.is() )
186cdf0e10cSrcweir {
187cdf0e10cSrcweir uno::Reference< report::XSection> xSection(xSourceSet,uno::UNO_QUERY);
188cdf0e10cSrcweir if ( xSection.is() )
189cdf0e10cSrcweir RemoveSection(xSection);
190cdf0e10cSrcweir else
191cdf0e10cSrcweir RemoveElement(xSourceSet);
192cdf0e10cSrcweir }
193cdf0e10cSrcweir }
194cdf0e10cSrcweir
Clear()195cdf0e10cSrcweir void OXReportControllerObserver::Clear()
196cdf0e10cSrcweir {
197cdf0e10cSrcweir OEnvLock aLock(*this);
198cdf0e10cSrcweir // sal_uInt32 nDebugValue = m_pImpl->m_aSections.size();
199cdf0e10cSrcweir m_pImpl->m_aSections.clear();
200cdf0e10cSrcweir }
201cdf0e10cSrcweir
202cdf0e10cSrcweir // XPropertyChangeListener
propertyChange(const beans::PropertyChangeEvent & _rEvent)203cdf0e10cSrcweir void SAL_CALL OXReportControllerObserver::propertyChange(const beans::PropertyChangeEvent& _rEvent) throw(uno::RuntimeException)
204cdf0e10cSrcweir {
205cdf0e10cSrcweir (void) _rEvent;
206cdf0e10cSrcweir ::osl::ClearableMutexGuard aGuard( m_pImpl->m_aMutex );
207cdf0e10cSrcweir
208cdf0e10cSrcweir if ( IsLocked() )
209cdf0e10cSrcweir return;
210cdf0e10cSrcweir
211cdf0e10cSrcweir m_aFormattedFieldBeautifier.notifyPropertyChange(_rEvent);
212cdf0e10cSrcweir m_aFixedTextColor.notifyPropertyChange(_rEvent);
213cdf0e10cSrcweir }
214cdf0e10cSrcweir
215cdf0e10cSrcweir // -----------------------------------------------------------------------------
Lock()216cdf0e10cSrcweir void OXReportControllerObserver::Lock()
217cdf0e10cSrcweir {
218cdf0e10cSrcweir OSL_ENSURE(m_refCount,"Illegal call to dead object!");
219cdf0e10cSrcweir osl_incrementInterlockedCount( &m_pImpl->m_nLocks );
220cdf0e10cSrcweir }
UnLock()221cdf0e10cSrcweir void OXReportControllerObserver::UnLock()
222cdf0e10cSrcweir {
223cdf0e10cSrcweir OSL_ENSURE(m_refCount,"Illegal call to dead object!");
224cdf0e10cSrcweir
225cdf0e10cSrcweir osl_decrementInterlockedCount( &m_pImpl->m_nLocks );
226cdf0e10cSrcweir }
IsLocked() const227cdf0e10cSrcweir sal_Bool OXReportControllerObserver::IsLocked() const { return m_pImpl->m_nLocks != 0; }
228cdf0e10cSrcweir
229cdf0e10cSrcweir //------------------------------------------------------------------------------
AddSection(const uno::Reference<report::XSection> & _xSection)230cdf0e10cSrcweir void OXReportControllerObserver::AddSection(const uno::Reference< report::XSection > & _xSection)
231cdf0e10cSrcweir {
232cdf0e10cSrcweir OEnvLock aLock(*this);
233cdf0e10cSrcweir try
234cdf0e10cSrcweir {
235cdf0e10cSrcweir uno::Reference<container::XChild> xChild = _xSection.get();
236cdf0e10cSrcweir m_pImpl->m_aSections.push_back(xChild);
237cdf0e10cSrcweir uno::Reference< uno::XInterface > xInt(_xSection);
238cdf0e10cSrcweir AddElement(xInt);
239cdf0e10cSrcweir }
240cdf0e10cSrcweir catch(const uno::Exception&)
241cdf0e10cSrcweir {
242cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION();
243cdf0e10cSrcweir }
244cdf0e10cSrcweir }
245cdf0e10cSrcweir
246cdf0e10cSrcweir //------------------------------------------------------------------------------
RemoveSection(const uno::Reference<report::XSection> & _xSection)247cdf0e10cSrcweir void OXReportControllerObserver::RemoveSection(const uno::Reference< report::XSection > & _xSection)
248cdf0e10cSrcweir {
249cdf0e10cSrcweir OEnvLock aLock(*this);
250cdf0e10cSrcweir try
251cdf0e10cSrcweir {
252cdf0e10cSrcweir uno::Reference<container::XChild> xChild(_xSection.get());
253cdf0e10cSrcweir m_pImpl->m_aSections.erase(::std::remove(m_pImpl->m_aSections.begin(),m_pImpl->m_aSections.end(),
254cdf0e10cSrcweir xChild), m_pImpl->m_aSections.end());
255cdf0e10cSrcweir uno::Reference< uno::XInterface > xInt(_xSection);
256cdf0e10cSrcweir RemoveElement(xInt);
257cdf0e10cSrcweir }
258cdf0e10cSrcweir catch(uno::Exception&)
259cdf0e10cSrcweir {
260cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION();
261cdf0e10cSrcweir }
262cdf0e10cSrcweir }
263cdf0e10cSrcweir
264cdf0e10cSrcweir //------------------------------------------------------------------------------
TogglePropertyListening(const uno::Reference<uno::XInterface> & Element)265cdf0e10cSrcweir void OXReportControllerObserver::TogglePropertyListening(const uno::Reference< uno::XInterface > & Element)
266cdf0e10cSrcweir {
267cdf0e10cSrcweir // listen at Container
268cdf0e10cSrcweir uno::Reference< container::XIndexAccess > xContainer(Element, uno::UNO_QUERY);
269cdf0e10cSrcweir if (xContainer.is())
270cdf0e10cSrcweir {
271cdf0e10cSrcweir uno::Reference< uno::XInterface > xInterface;
272cdf0e10cSrcweir sal_Int32 nCount = xContainer->getCount();
273cdf0e10cSrcweir for(sal_Int32 i = 0;i != nCount;++i)
274cdf0e10cSrcweir {
275cdf0e10cSrcweir xInterface.set(xContainer->getByIndex( i ),uno::UNO_QUERY);
276cdf0e10cSrcweir TogglePropertyListening(xInterface);
277cdf0e10cSrcweir }
278cdf0e10cSrcweir }
279cdf0e10cSrcweir
280cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xSet(Element, uno::UNO_QUERY);
281cdf0e10cSrcweir if (xSet.is())
282cdf0e10cSrcweir {
283cdf0e10cSrcweir if (!m_pImpl->m_bReadOnly)
284cdf0e10cSrcweir xSet->addPropertyChangeListener( ::rtl::OUString(), this );
285cdf0e10cSrcweir else
286cdf0e10cSrcweir xSet->removePropertyChangeListener( ::rtl::OUString(), this );
287cdf0e10cSrcweir }
288cdf0e10cSrcweir }
289cdf0e10cSrcweir
290cdf0e10cSrcweir
291cdf0e10cSrcweir //------------------------------------------------------------------------------
switchListening(const uno::Reference<container::XIndexAccess> & _rxContainer,bool _bStartListening)292cdf0e10cSrcweir void OXReportControllerObserver::switchListening( const uno::Reference< container::XIndexAccess >& _rxContainer, bool _bStartListening ) SAL_THROW(())
293cdf0e10cSrcweir {
294cdf0e10cSrcweir OSL_PRECOND( _rxContainer.is(), "OXReportControllerObserver::switchListening: invalid container!" );
295cdf0e10cSrcweir if ( !_rxContainer.is() )
296cdf0e10cSrcweir return;
297cdf0e10cSrcweir
298cdf0e10cSrcweir try
299cdf0e10cSrcweir {
300cdf0e10cSrcweir // also handle all children of this element
301cdf0e10cSrcweir uno::Reference< uno::XInterface > xInterface;
302cdf0e10cSrcweir sal_Int32 nCount = _rxContainer->getCount();
303cdf0e10cSrcweir for(sal_Int32 i = 0;i != nCount;++i)
304cdf0e10cSrcweir {
305cdf0e10cSrcweir xInterface.set(_rxContainer->getByIndex( i ),uno::UNO_QUERY);
306cdf0e10cSrcweir if ( _bStartListening )
307cdf0e10cSrcweir AddElement( xInterface );
308cdf0e10cSrcweir else
309cdf0e10cSrcweir RemoveElement( xInterface );
310cdf0e10cSrcweir }
311cdf0e10cSrcweir
312cdf0e10cSrcweir // be notified of any changes in the container elements
313cdf0e10cSrcweir uno::Reference< container::XContainer > xSimpleContainer( _rxContainer, uno::UNO_QUERY );
314cdf0e10cSrcweir // OSL_ENSURE( xSimpleContainer.is(), "OXReportControllerObserver::switchListening: how are we expected to be notified of changes in the container?" );
315cdf0e10cSrcweir if ( xSimpleContainer.is() )
316cdf0e10cSrcweir {
317cdf0e10cSrcweir if ( _bStartListening )
318cdf0e10cSrcweir xSimpleContainer->addContainerListener( this );
319cdf0e10cSrcweir else
320cdf0e10cSrcweir xSimpleContainer->removeContainerListener( this );
321cdf0e10cSrcweir }
322cdf0e10cSrcweir }
323cdf0e10cSrcweir catch( const uno::Exception& )
324cdf0e10cSrcweir {
325cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION();
326cdf0e10cSrcweir }
327cdf0e10cSrcweir }
328cdf0e10cSrcweir
329cdf0e10cSrcweir //------------------------------------------------------------------------------
switchListening(const uno::Reference<uno::XInterface> & _rxObject,bool _bStartListening)330cdf0e10cSrcweir void OXReportControllerObserver::switchListening( const uno::Reference< uno::XInterface >& _rxObject, bool _bStartListening ) SAL_THROW(())
331cdf0e10cSrcweir {
332cdf0e10cSrcweir OSL_PRECOND( _rxObject.is(), "OXReportControllerObserver::switchListening: how should I listen at a NULL object?" );
333cdf0e10cSrcweir
334cdf0e10cSrcweir try
335cdf0e10cSrcweir {
336cdf0e10cSrcweir if ( !m_pImpl->m_bReadOnly )
337cdf0e10cSrcweir {
338cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProps( _rxObject, uno::UNO_QUERY );
339cdf0e10cSrcweir if ( xProps.is() )
340cdf0e10cSrcweir {
341cdf0e10cSrcweir if ( _bStartListening )
342cdf0e10cSrcweir xProps->addPropertyChangeListener( ::rtl::OUString(), this );
343cdf0e10cSrcweir else
344cdf0e10cSrcweir xProps->removePropertyChangeListener( ::rtl::OUString(), this );
345cdf0e10cSrcweir }
346cdf0e10cSrcweir }
347cdf0e10cSrcweir
348cdf0e10cSrcweir uno::Reference< util::XModifyBroadcaster > xBroadcaster( _rxObject, uno::UNO_QUERY );
349cdf0e10cSrcweir if ( xBroadcaster.is() )
350cdf0e10cSrcweir {
351cdf0e10cSrcweir if ( _bStartListening )
352cdf0e10cSrcweir xBroadcaster->addModifyListener( this );
353cdf0e10cSrcweir else
354cdf0e10cSrcweir xBroadcaster->removeModifyListener( this );
355cdf0e10cSrcweir }
356cdf0e10cSrcweir }
357cdf0e10cSrcweir catch( const uno::Exception& )
358cdf0e10cSrcweir {
359cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION();
360cdf0e10cSrcweir }
361cdf0e10cSrcweir }
362cdf0e10cSrcweir
363cdf0e10cSrcweir //------------------------------------------------------------------------------
modified(const lang::EventObject &)364cdf0e10cSrcweir void SAL_CALL OXReportControllerObserver::modified( const lang::EventObject& /*aEvent*/ ) throw (uno::RuntimeException)
365cdf0e10cSrcweir {
366cdf0e10cSrcweir // implSetModified();
367cdf0e10cSrcweir }
368cdf0e10cSrcweir
369cdf0e10cSrcweir //------------------------------------------------------------------------------
AddElement(const uno::Reference<uno::XInterface> & _rxElement)370cdf0e10cSrcweir void OXReportControllerObserver::AddElement(const uno::Reference< uno::XInterface >& _rxElement )
371cdf0e10cSrcweir {
372cdf0e10cSrcweir // if ( !IsLocked() )
373cdf0e10cSrcweir // {
374cdf0e10cSrcweir m_aFormattedFieldBeautifier.notifyElementInserted(_rxElement);
375cdf0e10cSrcweir m_aFixedTextColor.notifyElementInserted(_rxElement);
376cdf0e10cSrcweir // }
377cdf0e10cSrcweir
378cdf0e10cSrcweir // if it's a container, start listening at all elements
379cdf0e10cSrcweir uno::Reference< container::XIndexAccess > xContainer( _rxElement, uno::UNO_QUERY );
380cdf0e10cSrcweir if ( xContainer.is() )
381cdf0e10cSrcweir switchListening( xContainer, true );
382cdf0e10cSrcweir
383cdf0e10cSrcweir switchListening( _rxElement, true );
384cdf0e10cSrcweir }
385cdf0e10cSrcweir
386cdf0e10cSrcweir //------------------------------------------------------------------------------
RemoveElement(const uno::Reference<uno::XInterface> & _rxElement)387cdf0e10cSrcweir void OXReportControllerObserver::RemoveElement(const uno::Reference< uno::XInterface >& _rxElement)
388cdf0e10cSrcweir {
389cdf0e10cSrcweir switchListening( _rxElement, false );
390cdf0e10cSrcweir
391cdf0e10cSrcweir uno::Reference< container::XIndexAccess > xContainer( _rxElement, uno::UNO_QUERY );
392cdf0e10cSrcweir if ( xContainer.is() )
393cdf0e10cSrcweir switchListening( xContainer, false );
394cdf0e10cSrcweir }
395cdf0e10cSrcweir
396cdf0e10cSrcweir // -----------------------------------------------------------------------------
getSection(const uno::Reference<container::XChild> & _xContainer) const397cdf0e10cSrcweir ::std::vector< uno::Reference< container::XChild> >::const_iterator OXReportControllerObserver::getSection(const uno::Reference<container::XChild>& _xContainer) const
398cdf0e10cSrcweir {
399cdf0e10cSrcweir ::std::vector< uno::Reference< container::XChild> >::const_iterator aFind = m_pImpl->m_aSections.end();
400cdf0e10cSrcweir if ( _xContainer.is() )
401cdf0e10cSrcweir {
402cdf0e10cSrcweir aFind = ::std::find(m_pImpl->m_aSections.begin(),m_pImpl->m_aSections.end(),_xContainer);
403cdf0e10cSrcweir
404cdf0e10cSrcweir if ( aFind == m_pImpl->m_aSections.end() )
405cdf0e10cSrcweir {
406cdf0e10cSrcweir uno::Reference<container::XChild> xParent(_xContainer->getParent(),uno::UNO_QUERY);
407cdf0e10cSrcweir aFind = getSection(xParent);
408cdf0e10cSrcweir }
409cdf0e10cSrcweir }
410cdf0e10cSrcweir return aFind;
411cdf0e10cSrcweir }
412cdf0e10cSrcweir // XContainerListener
413cdf0e10cSrcweir //------------------------------------------------------------------------------
elementInserted(const container::ContainerEvent & evt)414cdf0e10cSrcweir void SAL_CALL OXReportControllerObserver::elementInserted(const container::ContainerEvent& evt) throw(uno::RuntimeException)
415cdf0e10cSrcweir {
416cdf0e10cSrcweir ::vos::OClearableGuard aSolarGuard( Application::GetSolarMutex() );
417cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_pImpl->m_aMutex );
418cdf0e10cSrcweir
419cdf0e10cSrcweir // neues Object zum lauschen
420cdf0e10cSrcweir uno::Reference< uno::XInterface > xIface( evt.Element, uno::UNO_QUERY );
421cdf0e10cSrcweir if ( xIface.is() )
422cdf0e10cSrcweir {
423cdf0e10cSrcweir AddElement(xIface);
424cdf0e10cSrcweir }
425cdf0e10cSrcweir }
426cdf0e10cSrcweir
427cdf0e10cSrcweir //------------------------------------------------------------------------------
elementReplaced(const container::ContainerEvent & evt)428cdf0e10cSrcweir void SAL_CALL OXReportControllerObserver::elementReplaced(const container::ContainerEvent& evt) throw(uno::RuntimeException)
429cdf0e10cSrcweir {
430cdf0e10cSrcweir ::vos::OClearableGuard aSolarGuard( Application::GetSolarMutex() );
431cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_pImpl->m_aMutex );
432cdf0e10cSrcweir
433cdf0e10cSrcweir uno::Reference< uno::XInterface > xIface(evt.ReplacedElement,uno::UNO_QUERY);
434cdf0e10cSrcweir OSL_ENSURE(xIface.is(), "OXReportControllerObserver::elementReplaced: invalid container notification!");
435cdf0e10cSrcweir RemoveElement(xIface);
436cdf0e10cSrcweir
437cdf0e10cSrcweir xIface.set(evt.Element,uno::UNO_QUERY);
438cdf0e10cSrcweir AddElement(xIface);
439cdf0e10cSrcweir }
440cdf0e10cSrcweir
441cdf0e10cSrcweir //------------------------------------------------------------------------------
elementRemoved(const container::ContainerEvent & evt)442cdf0e10cSrcweir void SAL_CALL OXReportControllerObserver::elementRemoved(const container::ContainerEvent& evt) throw(uno::RuntimeException)
443cdf0e10cSrcweir {
444cdf0e10cSrcweir ::vos::OClearableGuard aSolarGuard( Application::GetSolarMutex() );
445cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_pImpl->m_aMutex );
446cdf0e10cSrcweir
447cdf0e10cSrcweir uno::Reference< uno::XInterface > xIface( evt.Element, uno::UNO_QUERY );
448cdf0e10cSrcweir if ( xIface.is() )
449cdf0e10cSrcweir {
450cdf0e10cSrcweir RemoveElement(xIface);
451cdf0e10cSrcweir }
452cdf0e10cSrcweir }
453cdf0e10cSrcweir
454cdf0e10cSrcweir
455cdf0e10cSrcweir } // namespace rptui
456cdf0e10cSrcweir
457cdf0e10cSrcweir
458cdf0e10cSrcweir
459