Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <vcl/waitobj.hxx>
30 : : #include <cppuhelper/interfacecontainer.hxx>
31 : : #include <com/sun/star/util/URL.hpp>
32 : : #include <vcl/msgbox.hxx>
33 : : #include <tools/debug.hxx>
34 : : #include <vcl/stdtext.hxx>
35 : : #include <comphelper/types.hxx>
36 : : #include <comphelper/sequence.hxx>
37 : : #include "framectr.hxx"
38 : : #include "datman.hxx"
39 : : #include "bibresid.hxx"
40 : : #include "bib.hrc"
41 : : #include <toolkit/helper/vclunohelper.hxx>
42 : : #include "bibconfig.hxx"
43 : : #include <cppuhelper/implbase1.hxx> // helper for implementations
44 : : #include <vcl/svapp.hxx>
45 : : #include "bibliography.hrc"
46 : : #include <comphelper/processfactory.hxx>
47 : : #include <com/sun/star/form/XConfirmDeleteListener.hpp>
48 : : #include <com/sun/star/form/runtime/XFormController.hpp>
49 : : #include <com/sun/star/beans/PropertyState.hpp>
50 : : #include <com/sun/star/beans/PropertyValue.hpp>
51 : : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
52 : : #include <com/sun/star/sdbcx/Privilege.hpp>
53 : : #include <com/sun/star/sdbc/XResultSetUpdate.hpp>
54 : : #include <com/sun/star/sdb/RowChangeAction.hpp>
55 : : #include <com/sun/star/frame/CommandGroup.hpp>
56 : : #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
57 : : #include <sot/exchange.hxx>
58 : : #include <sot/formats.hxx>
59 : : #include <vcl/edit.hxx>
60 : : #include <osl/mutex.hxx>
61 : :
62 : : #include <boost/unordered_map.hpp>
63 : :
64 : : using namespace osl;
65 : : using namespace cppu;
66 : : using namespace com::sun::star::sdbc;
67 : : using namespace com::sun::star::frame;
68 : : using namespace com::sun::star::uno;
69 : : using namespace com::sun::star;
70 : :
71 : : using ::rtl::OUString;
72 : :
73 : : #define C2U(cChar) OUString::createFromAscii(cChar)
74 : :
75 : : struct DispatchInfo
76 : : {
77 : : const char* pCommand;
78 : : sal_Int16 nGroupId;
79 : : sal_Bool bActiveConnection;
80 : : };
81 : :
82 : : struct CacheDispatchInfo
83 : : {
84 : : sal_Int16 nGroupId;
85 : : sal_Bool bActiveConnection;
86 : : };
87 : :
88 : : // Attention: commands must be sorted by command groups. Implementation is dependent
89 : : // on this!!
90 : : static DispatchInfo SupportedCommandsArray[] =
91 : : {
92 : : { ".uno:Undo" , frame::CommandGroup::EDIT , sal_False },
93 : : { ".uno:Cut" , frame::CommandGroup::EDIT , sal_False },
94 : : { ".uno:Copy" , frame::CommandGroup::EDIT , sal_False },
95 : : { ".uno:Paste" , frame::CommandGroup::EDIT , sal_False },
96 : : { ".uno:SelectAll" , frame::CommandGroup::EDIT , sal_False },
97 : : { ".uno:CloseDoc" , frame::CommandGroup::DOCUMENT , sal_False },
98 : : { ".uno:StatusBarVisible" , frame::CommandGroup::VIEW , sal_False },
99 : : { ".uno:AvailableToolbars" , frame::CommandGroup::VIEW , sal_False },
100 : : { ".uno:Bib/standardFilter" , frame::CommandGroup::DATA , sal_True },
101 : : { ".uno:Bib/DeleteRecord" , frame::CommandGroup::DATA , sal_True },
102 : : { ".uno:Bib/InsertRecord" , frame::CommandGroup::DATA , sal_True },
103 : : { ".uno:Bib/query" , frame::CommandGroup::DATA , sal_True },
104 : : { ".uno:Bib/autoFilter" , frame::CommandGroup::DATA , sal_True },
105 : : { ".uno:Bib/source" , frame::CommandGroup::DATA , sal_True },
106 : : { ".uno:Bib/removeFilter" , frame::CommandGroup::DATA , sal_True },
107 : : { ".uno:Bib/sdbsource" , frame::CommandGroup::DATA , sal_True },
108 : : { ".uno:Bib/Mapping" , frame::CommandGroup::DATA , sal_True },
109 : : { 0 , 0 , sal_False }
110 : : };
111 : :
112 : : typedef ::boost::unordered_map< ::rtl::OUString, CacheDispatchInfo, rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > CmdToInfoCache;
113 : :
114 : 0 : const CmdToInfoCache& GetCommandToInfoCache()
115 : : {
116 : : static sal_Bool bCacheInitialized = sal_False;
117 [ # # ][ # # ]: 0 : static CmdToInfoCache aCmdToInfoCache;
[ # # ][ # # ]
118 : :
119 [ # # ]: 0 : if ( !bCacheInitialized )
120 : : {
121 [ # # ][ # # ]: 0 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
122 [ # # ]: 0 : if ( !bCacheInitialized )
123 : : {
124 : 0 : sal_Int32 i( 0 );
125 [ # # ]: 0 : while ( SupportedCommandsArray[i].pCommand != 0 )
126 : : {
127 : 0 : rtl::OUString aCommand( rtl::OUString::createFromAscii( SupportedCommandsArray[i].pCommand ));
128 : :
129 : : CacheDispatchInfo aDispatchInfo;
130 : 0 : aDispatchInfo.nGroupId = SupportedCommandsArray[i].nGroupId;
131 : 0 : aDispatchInfo.bActiveConnection = SupportedCommandsArray[i].bActiveConnection;
132 [ # # ]: 0 : aCmdToInfoCache.insert( CmdToInfoCache::value_type( aCommand, aDispatchInfo ));
133 : 0 : ++i;
134 : 0 : }
135 : 0 : bCacheInitialized = sal_True;
136 [ # # ]: 0 : }
137 : : }
138 : :
139 : 0 : return aCmdToInfoCache;
140 : : }
141 : :
142 : :
143 : : class BibFrameCtrl_Impl : public cppu::WeakImplHelper1 < XFrameActionListener >
144 : : {
145 : : public:
146 : : Mutex aMutex;
147 : : OMultiTypeInterfaceContainerHelper aLC;
148 : :
149 : : BibFrameController_Impl* pController;
150 : :
151 : 0 : BibFrameCtrl_Impl()
152 : : : aLC( aMutex )
153 [ # # ][ # # ]: 0 : , pController(0)
154 : 0 : {}
155 : :
156 : : ~BibFrameCtrl_Impl();
157 : :
158 : : virtual void SAL_CALL frameAction(const FrameActionEvent& aEvent) throw( RuntimeException );
159 : : virtual void SAL_CALL disposing( const lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
160 : : };
161 : :
162 : :
163 [ # # ][ # # ]: 0 : BibFrameCtrl_Impl::~BibFrameCtrl_Impl()
164 : : {
165 [ # # ]: 0 : }
166 : :
167 : 0 : void BibFrameCtrl_Impl::frameAction(const FrameActionEvent& aEvent) throw( uno::RuntimeException )
168 : : {
169 [ # # ][ # # ]: 0 : if ( pController && aEvent.Frame == pController->getFrame())
[ # # ][ # # ]
[ # # ]
[ # # # # ]
170 : : {
171 [ # # ]: 0 : if(aEvent.Action == FrameAction_FRAME_ACTIVATED)
172 : : {
173 : 0 : pController->activate();
174 : : }
175 [ # # ]: 0 : else if(aEvent.Action == FrameAction_FRAME_DEACTIVATING)
176 : : {
177 : 0 : pController->deactivate();
178 : : }
179 : : }
180 : 0 : }
181 : :
182 : 0 : void BibFrameCtrl_Impl::disposing( const lang::EventObject& /*Source*/ )
183 : : throw (::com::sun::star::uno::RuntimeException)
184 : : {
185 [ # # ]: 0 : ::SolarMutexGuard aGuard;
186 [ # # ]: 0 : if ( pController )
187 [ # # ][ # # ]: 0 : pController->getFrame()->removeFrameActionListener( this );
[ # # ][ # # ]
[ # # ]
188 : 0 : }
189 : :
190 : 0 : BibFrameController_Impl::BibFrameController_Impl( const uno::Reference< awt::XWindow > & xComponent,
191 : : BibDataManager* pDataManager)
192 : : :xWindow( xComponent )
193 : : ,m_xDatMan( pDataManager )
194 : : ,pDatMan( pDataManager )
195 [ # # ][ # # ]: 0 : ,pBibMod(NULL)
[ # # ]
196 : : {
197 [ # # ]: 0 : Window* pParent = VCLUnoHelper::GetWindow( xWindow );
198 [ # # ]: 0 : pParent->SetUniqueId(UID_BIB_FRAME_WINDOW);
199 : 0 : bDisposing=sal_False;
200 : 0 : bHierarchical=sal_True;
201 [ # # ]: 0 : pImp = new BibFrameCtrl_Impl;
202 : 0 : pImp->pController = this;
203 : 0 : pImp->acquire();
204 : 0 : }
205 : :
206 [ # # ]: 0 : BibFrameController_Impl::~BibFrameController_Impl()
207 : : {
208 : 0 : pImp->pController = NULL;
209 : 0 : pImp->release();
210 [ # # ][ # # ]: 0 : delete pDatMan;
211 [ # # ]: 0 : if(pBibMod)
212 [ # # ]: 0 : CloseBibModul(pBibMod);
213 [ # # ]: 0 : }
214 : :
215 : 0 : ::rtl::OUString SAL_CALL BibFrameController_Impl::getImplementationName() throw (::com::sun::star::uno::RuntimeException)
216 : : {
217 : 0 : return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.extensions.Bibliography"));
218 : : }
219 : :
220 : 0 : sal_Bool SAL_CALL BibFrameController_Impl::supportsService( const ::rtl::OUString& sServiceName ) throw (::com::sun::star::uno::RuntimeException)
221 : : {
222 [ # # ][ # # ]: 0 : return ( sServiceName == "com.sun.star.frame.Bibliography" || sServiceName == "com.sun.star.frame.Controller" );
223 : : }
224 : :
225 : 0 : ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL BibFrameController_Impl::getSupportedServiceNames() throw (::com::sun::star::uno::RuntimeException)
226 : : {
227 : : // return only top level services ...
228 : : // base services are included there and should be asked by uno-rtti.
229 : 0 : ::com::sun::star::uno::Sequence< ::rtl::OUString > lNames(1);
230 [ # # ][ # # ]: 0 : lNames[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Bibliography"));
231 : 0 : return lNames;
232 : : }
233 : :
234 : 0 : void BibFrameController_Impl::attachFrame( const uno::Reference< XFrame > & xArg ) throw (::com::sun::star::uno::RuntimeException)
235 : : {
236 : 0 : xFrame = xArg;
237 [ # # ][ # # ]: 0 : xFrame->addFrameActionListener( pImp );
238 : 0 : }
239 : :
240 : 0 : sal_Bool BibFrameController_Impl::attachModel( const uno::Reference< XModel > & /*xModel*/ ) throw (::com::sun::star::uno::RuntimeException)
241 : : {
242 : 0 : return sal_False;
243 : : }
244 : :
245 : 0 : sal_Bool BibFrameController_Impl::suspend( sal_Bool bSuspend ) throw (::com::sun::star::uno::RuntimeException)
246 : : {
247 [ # # ]: 0 : if ( bSuspend )
248 [ # # ][ # # ]: 0 : getFrame()->removeFrameActionListener( pImp );
[ # # ][ # # ]
249 : : else
250 [ # # ][ # # ]: 0 : getFrame()->addFrameActionListener( pImp );
[ # # ][ # # ]
251 : 0 : return sal_True;
252 : : }
253 : :
254 : 0 : uno::Any BibFrameController_Impl::getViewData() throw (::com::sun::star::uno::RuntimeException)
255 : : {
256 : 0 : return uno::Any();
257 : : }
258 : :
259 : 0 : void BibFrameController_Impl::restoreViewData( const uno::Any& /*Value*/ ) throw (::com::sun::star::uno::RuntimeException)
260 : : {
261 : 0 : }
262 : :
263 : 0 : uno::Reference< XFrame > BibFrameController_Impl::getFrame() throw (::com::sun::star::uno::RuntimeException)
264 : : {
265 : 0 : return xFrame;
266 : : }
267 : :
268 : 0 : uno::Reference< XModel > BibFrameController_Impl::getModel() throw (::com::sun::star::uno::RuntimeException)
269 : : {
270 : 0 : return uno::Reference< XModel > ();
271 : : }
272 : :
273 : 0 : void BibFrameController_Impl::dispose() throw (::com::sun::star::uno::RuntimeException)
274 : : {
275 : 0 : bDisposing = sal_True;
276 [ # # ]: 0 : lang::EventObject aObject;
277 [ # # ]: 0 : aObject.Source = (XController*)this;
278 [ # # ]: 0 : pImp->aLC.disposeAndClear(aObject);
279 [ # # ]: 0 : m_xDatMan = 0;
280 : 0 : pDatMan = 0;
281 [ # # ][ # # ]: 0 : aStatusListeners.clear();
282 : 0 : }
283 : :
284 : 0 : void BibFrameController_Impl::addEventListener( const uno::Reference< lang::XEventListener > & aListener ) throw (::com::sun::star::uno::RuntimeException)
285 : : {
286 : 0 : pImp->aLC.addInterface( ::getCppuType((const Reference< lang::XEventListener >*)0), aListener );
287 : 0 : }
288 : :
289 : 0 : void BibFrameController_Impl::removeEventListener( const uno::Reference< lang::XEventListener > & aListener ) throw (::com::sun::star::uno::RuntimeException)
290 : : {
291 : 0 : pImp->aLC.removeInterface( ::getCppuType((const Reference< lang::XEventListener >*)0), aListener );
292 : 0 : }
293 : :
294 : 0 : uno::Reference< frame::XDispatch > BibFrameController_Impl::queryDispatch( const util::URL& aURL, const rtl::OUString& /*aTarget*/, sal_Int32 /*nSearchFlags*/ ) throw (::com::sun::star::uno::RuntimeException)
295 : : {
296 [ # # ]: 0 : if ( !bDisposing )
297 : : {
298 [ # # ]: 0 : const CmdToInfoCache& rCmdCache = GetCommandToInfoCache();
299 [ # # ]: 0 : CmdToInfoCache::const_iterator pIter = rCmdCache.find( aURL.Complete );
300 [ # # ][ # # ]: 0 : if ( pIter != rCmdCache.end() )
301 : : {
302 [ # # ][ # # ]: 0 : if (( pDatMan->HasActiveConnection() ) ||
[ # # ][ # # ]
303 [ # # ]: 0 : ( !pIter->second.bActiveConnection ))
304 [ # # ]: 0 : return (frame::XDispatch*) this;
305 : : }
306 : : }
307 : :
308 : 0 : return uno::Reference< frame::XDispatch > ();
309 : : }
310 : :
311 : 0 : uno::Sequence<uno::Reference< XDispatch > > BibFrameController_Impl::queryDispatches( const uno::Sequence<DispatchDescriptor>& aDescripts ) throw (::com::sun::star::uno::RuntimeException)
312 : : {
313 : 0 : uno::Sequence< uno::Reference< XDispatch > > aDispatches( aDescripts.getLength() );
314 [ # # ]: 0 : for ( sal_Int32 i=0; i<aDescripts.getLength(); ++i )
315 [ # # ][ # # ]: 0 : aDispatches[i] = queryDispatch( aDescripts[i].FeatureURL, aDescripts[i].FrameName, aDescripts[i].SearchFlags );
[ # # ]
316 : 0 : return aDispatches;
317 : : }
318 : :
319 : 0 : uno::Sequence< ::sal_Int16 > SAL_CALL BibFrameController_Impl::getSupportedCommandGroups()
320 : : throw (::com::sun::star::uno::RuntimeException)
321 : : {
322 : 0 : uno::Sequence< ::sal_Int16 > aDispatchInfo( 4 );
323 : :
324 [ # # ]: 0 : aDispatchInfo[0] = frame::CommandGroup::EDIT;
325 [ # # ]: 0 : aDispatchInfo[1] = frame::CommandGroup::DOCUMENT;
326 [ # # ]: 0 : aDispatchInfo[2] = frame::CommandGroup::DATA;
327 [ # # ]: 0 : aDispatchInfo[3] = frame::CommandGroup::VIEW;
328 : :
329 : 0 : return aDispatchInfo;
330 : : }
331 : :
332 : 0 : uno::Sequence< frame::DispatchInformation > SAL_CALL BibFrameController_Impl::getConfigurableDispatchInformation( ::sal_Int16 nCommandGroup )
333 : : throw (::com::sun::star::uno::RuntimeException)
334 : : {
335 [ # # ]: 0 : const CmdToInfoCache& rCmdCache = GetCommandToInfoCache();
336 : :
337 : 0 : sal_Bool bGroupFound( sal_False );
338 : 0 : frame::DispatchInformation aDispatchInfo;
339 [ # # ]: 0 : std::list< frame::DispatchInformation > aDispatchInfoList;
340 : :
341 [ # # ][ # # ]: 0 : if (( nCommandGroup == frame::CommandGroup::EDIT ) ||
[ # # ][ # # ]
342 : : ( nCommandGroup == frame::CommandGroup::DOCUMENT ) ||
343 : : ( nCommandGroup == frame::CommandGroup::DATA ) ||
344 : : ( nCommandGroup == frame::CommandGroup::VIEW ))
345 : : {
346 [ # # ]: 0 : CmdToInfoCache::const_iterator pIter = rCmdCache.begin();
347 [ # # ][ # # ]: 0 : while ( pIter != rCmdCache.end() )
348 : : {
349 [ # # ][ # # ]: 0 : if ( pIter->second.nGroupId == nCommandGroup )
350 : : {
351 : 0 : bGroupFound = sal_True;
352 [ # # ]: 0 : aDispatchInfo.Command = pIter->first;
353 [ # # ]: 0 : aDispatchInfo.GroupId = pIter->second.nGroupId;
354 [ # # ]: 0 : aDispatchInfoList.push_back( aDispatchInfo );
355 : : }
356 [ # # ]: 0 : else if ( bGroupFound )
357 : 0 : break;
358 : :
359 : 0 : ++pIter;
360 : : }
361 : : }
362 : :
363 : : ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchInformation > aSeq =
364 [ # # ]: 0 : comphelper::containerToSequence< ::com::sun::star::frame::DispatchInformation, std::list< ::com::sun::star::frame::DispatchInformation > >( aDispatchInfoList );
365 : :
366 : 0 : return aSeq;
367 : : }
368 : :
369 : 0 : sal_Bool canInsertRecords(const Reference< beans::XPropertySet>& _rxCursorSet)
370 : : {
371 : 0 : sal_Int32 nPriv = 0;
372 [ # # ][ # # ]: 0 : _rxCursorSet->getPropertyValue(C2U("Privileges")) >>= nPriv;
373 [ # # ][ # # ]: 0 : return ((_rxCursorSet.is() && (nPriv & sdbcx::Privilege::INSERT) != 0));
374 : : }
375 : :
376 : 0 : sal_Bool BibFrameController_Impl::SaveModified(const Reference< form::runtime::XFormController>& xController)
377 : : {
378 [ # # ]: 0 : if (!xController.is())
379 : 0 : return sal_False;
380 : :
381 [ # # ][ # # ]: 0 : Reference< XResultSetUpdate> _xCursor = Reference< XResultSetUpdate>(xController->getModel(), UNO_QUERY);
[ # # ]
382 : :
383 [ # # ]: 0 : if (!_xCursor.is())
384 : 0 : return sal_False;
385 : :
386 [ # # ]: 0 : Reference< beans::XPropertySet> _xSet = Reference< beans::XPropertySet>(_xCursor, UNO_QUERY);
387 [ # # ]: 0 : if (!_xSet.is())
388 : 0 : return sal_False;
389 : :
390 : : // need to save?
391 [ # # ][ # # ]: 0 : sal_Bool bIsNew = ::comphelper::getBOOL(_xSet->getPropertyValue(C2U("IsNew")));
[ # # ]
392 [ # # ][ # # ]: 0 : sal_Bool bIsModified = ::comphelper::getBOOL(_xSet->getPropertyValue(C2U("IsModified")));
[ # # ][ # # ]
393 : 0 : sal_Bool bResult = !bIsModified;
394 [ # # ]: 0 : if (bIsModified)
395 : : {
396 : : try
397 : : {
398 [ # # ]: 0 : if (bIsNew)
399 [ # # ][ # # ]: 0 : _xCursor->insertRow();
400 : : else
401 [ # # ][ # # ]: 0 : _xCursor->updateRow();
402 : 0 : bResult = sal_True;
403 : : }
404 [ # # ]: 0 : catch(const Exception&)
405 : : {
406 : : OSL_FAIL("SaveModified: Exception occurred!");
407 : : }
408 : : }
409 : 0 : return bResult;
410 : : }
411 : :
412 : 0 : Window* lcl_GetFocusChild( Window* pParent )
413 : : {
414 : 0 : sal_uInt16 nChildren = pParent->GetChildCount();
415 [ # # ]: 0 : for( sal_uInt16 nChild = 0; nChild < nChildren; ++nChild)
416 : : {
417 : 0 : Window* pChild = pParent->GetChild( nChild );
418 [ # # ]: 0 : if(pChild->HasFocus())
419 : 0 : return pChild;
420 : 0 : Window* pSubChild = lcl_GetFocusChild( pChild );
421 [ # # ]: 0 : if(pSubChild)
422 : 0 : return pSubChild;
423 : : }
424 : 0 : return 0;
425 : : }
426 : :
427 : : //class XDispatch
428 : 0 : void BibFrameController_Impl::dispatch(const util::URL& _rURL, const uno::Sequence< beans::PropertyValue >& aArgs) throw (::com::sun::star::uno::RuntimeException)
429 : : {
430 [ # # ]: 0 : if ( !bDisposing )
431 : : {
432 [ # # ]: 0 : ::SolarMutexGuard aGuard;
433 [ # # ]: 0 : Window* pParent = VCLUnoHelper::GetWindow( xWindow );
434 [ # # ]: 0 : WaitObject aWaitObject( pParent );
435 : :
436 [ # # ]: 0 : String aCommand( _rURL.Path);
437 [ # # ][ # # ]: 0 : if(aCommand.EqualsAscii("Bib/Mapping"))
438 : : {
439 [ # # ]: 0 : pDatMan->CreateMappingDialog(pParent);
440 : : }
441 [ # # ][ # # ]: 0 : else if(aCommand.EqualsAscii("Bib/source"))
442 : : {
443 [ # # ]: 0 : ChangeDataSource(aArgs);
444 : : }
445 [ # # ][ # # ]: 0 : else if(aCommand.EqualsAscii("Bib/sdbsource"))
446 : : {
447 [ # # ]: 0 : rtl::OUString aURL = pDatMan->CreateDBChangeDialog(pParent);
448 [ # # ]: 0 : if(!aURL.isEmpty())
449 : : {
450 : : try
451 : : {
452 [ # # ]: 0 : uno::Sequence< beans::PropertyValue > aNewDataSource(2);
453 [ # # ]: 0 : beans::PropertyValue* pProps = aNewDataSource.getArray();
454 [ # # ]: 0 : pProps[0].Value <<= rtl::OUString();
455 [ # # ]: 0 : pProps[1].Value <<= aURL;
456 [ # # ][ # # ]: 0 : ChangeDataSource(aNewDataSource);
[ # # ]
457 : : }
458 [ # # ]: 0 : catch(const Exception&)
459 : : {
460 : : OSL_FAIL("Exception catched while changing the data source");
461 : : }
462 : 0 : }
463 : : }
464 [ # # ][ # # ]: 0 : else if(aCommand.EqualsAscii("Bib/autoFilter"))
465 : : {
466 : 0 : sal_uInt16 nCount = aStatusListeners.size();
467 [ # # ]: 0 : for ( sal_uInt16 n=0; n<nCount; n++ )
468 : : {
469 [ # # ]: 0 : BibStatusDispatch *pObj = &aStatusListeners[n];
470 [ # # ]: 0 : if ( pObj->aURL.Path == C2U("Bib/removeFilter") )
471 : : {
472 [ # # ]: 0 : FeatureStateEvent aEvent;
473 : 0 : aEvent.FeatureURL = pObj->aURL;
474 : 0 : aEvent.IsEnabled = sal_True;
475 : 0 : aEvent.Requery = sal_False;
476 [ # # ]: 0 : aEvent.Source = (XDispatch *) this;
477 [ # # ][ # # ]: 0 : pObj->xListener->statusChanged( aEvent );
[ # # ]
478 : : //break; because there are more than one
479 : : }
480 : : }
481 : :
482 : 0 : const beans::PropertyValue* pPropertyValue = aArgs.getConstArray();
483 : 0 : uno::Any aValue=pPropertyValue[0].Value;
484 : 0 : rtl::OUString aQuery;
485 : 0 : aValue >>= aQuery;
486 : :
487 : 0 : aValue=pPropertyValue[1].Value;
488 : 0 : rtl::OUString aQueryField;
489 : 0 : aValue >>= aQueryField;
490 [ # # ]: 0 : BibConfig* pConfig = BibModul::GetConfig();
491 [ # # ]: 0 : pConfig->setQueryField(aQueryField);
492 [ # # ]: 0 : pDatMan->startQueryWith(aQuery);
493 : : }
494 [ # # ][ # # ]: 0 : else if(aCommand.EqualsAscii("Bib/standardFilter"))
495 : : {
496 : : try
497 : : {
498 [ # # ]: 0 : uno::Reference< lang::XMultiServiceFactory > xORB = ::comphelper::getProcessServiceFactory();
499 : :
500 : : // build the arguments for the filter dialog to be created
501 [ # # ]: 0 : Sequence< Any > aDialogCreationArgs( 3 );
502 [ # # ]: 0 : Any* pDialogCreationArgs = aDialogCreationArgs.getArray();
503 : : // the query composer
504 : : *pDialogCreationArgs++ <<= beans::PropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "QueryComposer" )),
505 : : -1,
506 : 0 : makeAny( pDatMan->getParser() ),
507 : : beans::PropertyState_DIRECT_VALUE
508 [ # # ][ # # ]: 0 : );
[ # # ]
509 : :
510 : : // the rowset
511 : : *pDialogCreationArgs++ <<= beans::PropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "RowSet" )),
512 : : -1,
513 : 0 : makeAny( pDatMan->getForm() ),
514 : : beans::PropertyState_DIRECT_VALUE
515 [ # # ][ # # ]: 0 : );
[ # # ]
516 : : // the parent window for the dialog
517 : : *pDialogCreationArgs++ <<= beans::PropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ParentWindow" )),
518 : : -1,
519 : : makeAny( xWindow ),
520 : : beans::PropertyState_DIRECT_VALUE
521 [ # # ][ # # ]: 0 : );
[ # # ]
522 : :
523 : : // create the dialog object
524 [ # # ]: 0 : const ::rtl::OUString sDialogServiceName(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.FilterDialog" ));
525 [ # # ]: 0 : uno::Reference< uno::XInterface > xDialog = xORB->createInstanceWithArguments(
526 : : sDialogServiceName,
527 : : aDialogCreationArgs
528 [ # # ]: 0 : );
529 [ # # ]: 0 : if ( !xDialog.is() )
530 : : {
531 [ # # ][ # # ]: 0 : ShowServiceNotAvailableError( VCLUnoHelper::GetWindow( xWindow ), sDialogServiceName, sal_True );
[ # # ][ # # ]
532 : : }
533 : : else
534 : : {
535 : : // execute it
536 [ # # ]: 0 : uno::Reference< ui::dialogs::XExecutableDialog > xExec( xDialog, UNO_QUERY );
537 : : DBG_ASSERT( xExec.is(), "BibFrameController_Impl::dispatch: missing an interface on the dialog!" );
538 [ # # ]: 0 : if ( xExec.is() )
539 [ # # ][ # # ]: 0 : if ( xExec->execute( ) )
[ # # ]
540 : : {
541 : : // the dialog has been executed successfully, and the filter on the query composer
542 : : // has been changed
543 [ # # ][ # # ]: 0 : ::rtl::OUString sNewFilter = pDatMan->getParser()->getFilter();
544 [ # # ]: 0 : pDatMan->setFilter( sNewFilter );
545 : 0 : }
546 [ # # ][ # # ]: 0 : }
547 : : }
548 [ # # ]: 0 : catch( const uno::Exception& )
549 : : {
550 : : OSL_FAIL( "BibFrameController_Impl::dispatch: caught an exception!" );
551 : : }
552 : :
553 : 0 : sal_uInt16 nCount = aStatusListeners.size();
554 [ # # ]: 0 : for ( sal_uInt16 n=0; n<nCount; n++ )
555 : : {
556 [ # # ]: 0 : BibStatusDispatch *pObj = &aStatusListeners[n];
557 [ # # ][ # # ]: 0 : if ( pObj->aURL.Path == C2U("Bib/removeFilter") && pDatMan->getParser().is())
[ # # ][ # # ]
558 : : {
559 [ # # ]: 0 : FeatureStateEvent aEvent;
560 : 0 : aEvent.FeatureURL = pObj->aURL;
561 [ # # ][ # # ]: 0 : aEvent.IsEnabled = !pDatMan->getParser()->getFilter().isEmpty();
562 : 0 : aEvent.Requery = sal_False;
563 [ # # ]: 0 : aEvent.Source = (XDispatch *) this;
564 [ # # ][ # # ]: 0 : pObj->xListener->statusChanged( aEvent );
[ # # ]
565 : : }
566 : : }
567 : : }
568 [ # # ][ # # ]: 0 : else if(aCommand.EqualsAscii("Bib/removeFilter"))
569 : : {
570 [ # # ]: 0 : RemoveFilter();
571 : : }
572 [ # # ][ # # ]: 0 : else if( _rURL.Complete == "slot:5503" || aCommand.EqualsAscii("CloseDoc") )
[ # # ][ # # ]
573 : : {
574 : : Application::PostUserEvent( STATIC_LINK( this, BibFrameController_Impl,
575 [ # # ][ # # ]: 0 : DisposeHdl ), 0 );
576 : :
577 : : }
578 [ # # ][ # # ]: 0 : else if(aCommand.EqualsAscii("Bib/InsertRecord"))
579 : : {
580 [ # # ]: 0 : Reference<form::runtime::XFormController > xFormCtrl = pDatMan->GetFormController();
581 [ # # ][ # # ]: 0 : if(SaveModified(xFormCtrl))
582 : : {
583 : : try
584 : : {
585 [ # # ]: 0 : Reference< sdbc::XResultSet > xCursor( pDatMan->getForm(), UNO_QUERY );
586 [ # # ][ # # ]: 0 : xCursor->last();
587 : :
588 [ # # ]: 0 : Reference< XResultSetUpdate > xUpdateCursor( pDatMan->getForm(), UNO_QUERY );
589 [ # # ][ # # ]: 0 : xUpdateCursor->moveToInsertRow();
[ # # ]
590 : : }
591 [ # # ]: 0 : catch(const Exception&)
592 : : {
593 : : OSL_FAIL("Exception in last() or moveToInsertRow()");
594 : : }
595 : 0 : }
596 : : }
597 [ # # ][ # # ]: 0 : else if(aCommand.EqualsAscii("Bib/DeleteRecord"))
598 : : {
599 [ # # ]: 0 : Reference< ::com::sun::star::sdbc::XResultSet > xCursor(pDatMan->getForm(), UNO_QUERY);
600 [ # # ]: 0 : Reference< XResultSetUpdate > xUpdateCursor(xCursor, UNO_QUERY);
601 [ # # ]: 0 : Reference< beans::XPropertySet > xSet(pDatMan->getForm(), UNO_QUERY);
602 [ # # ][ # # ]: 0 : sal_Bool bIsNew = ::comphelper::getBOOL(xSet->getPropertyValue(C2U("IsNew")));
[ # # ]
603 [ # # ]: 0 : if(!bIsNew)
604 : : {
605 : 0 : sal_uInt32 nCount = 0;
606 [ # # ][ # # ]: 0 : xSet->getPropertyValue(C2U("RowCount")) >>= nCount;
607 : : // naechste position festellen
608 : 0 : sal_Bool bSuccess = sal_False;
609 : 0 : sal_Bool bLeft = sal_False;
610 : 0 : sal_Bool bRight = sal_False;
611 : : try
612 : : {
613 [ # # ][ # # ]: 0 : bLeft = xCursor->isLast() && nCount > 1;
[ # # ][ # # ]
614 [ # # ][ # # ]: 0 : bRight= !xCursor->isLast();
615 : : // ask for confirmation
616 [ # # ][ # # ]: 0 : Reference< frame::XController > xCtrl = pImp->pController;
617 [ # # ][ # # ]: 0 : Reference< form::XConfirmDeleteListener > xConfirm(pDatMan->GetFormController(),UNO_QUERY);
618 [ # # ]: 0 : if (xConfirm.is())
619 : : {
620 [ # # ]: 0 : sdb::RowChangeEvent aEvent;
621 [ # # ][ # # ]: 0 : aEvent.Source = Reference< XInterface > (xCursor, UNO_QUERY);
622 : 0 : aEvent.Action = sdb::RowChangeAction::DELETE;
623 : 0 : aEvent.Rows = 1;
624 [ # # ][ # # ]: 0 : bSuccess = xConfirm->confirmDelete(aEvent);
[ # # ]
625 : : }
626 : :
627 : : // das Ding loeschen
628 [ # # ]: 0 : if (bSuccess)
629 [ # # ][ # # ]: 0 : xUpdateCursor->deleteRow();
[ # # ]
630 : : }
631 [ # # # # ]: 0 : catch(const Exception&)
632 : : {
633 : 0 : bSuccess = sal_False;
634 : : }
635 [ # # ]: 0 : if (bSuccess)
636 : : {
637 [ # # ][ # # ]: 0 : if (bLeft || bRight)
638 [ # # ][ # # ]: 0 : xCursor->relative(bRight ? 1 : -1);
[ # # ]
639 : : else
640 : : {
641 [ # # ]: 0 : sal_Bool bCanInsert = canInsertRecords(xSet);
642 : : // kann noch ein Datensatz eingefuegt weden
643 : : try
644 : : {
645 [ # # ]: 0 : if (bCanInsert)
646 [ # # ][ # # ]: 0 : xUpdateCursor->moveToInsertRow();
647 : : else
648 : : // Datensatz bewegen um Stati neu zu setzen
649 [ # # ][ # # ]: 0 : xCursor->first();
650 : : }
651 [ # # ]: 0 : catch(const Exception&)
652 : : {
653 : : OSL_FAIL("DeleteRecord : exception caught !");
654 : : }
655 : : }
656 : : }
657 : 0 : }
658 : : }
659 [ # # ][ # # ]: 0 : else if(aCommand.EqualsAscii("Cut"))
660 : : {
661 [ # # ][ # # ]: 0 : Window* pChild = lcl_GetFocusChild( VCLUnoHelper::GetWindow( xWindow ) );
662 [ # # ]: 0 : if(pChild)
663 : : {
664 [ # # ][ # # ]: 0 : KeyEvent aEvent( 0, KEYFUNC_CUT );
665 [ # # ]: 0 : pChild->KeyInput( aEvent );
666 : : }
667 : : }
668 [ # # ][ # # ]: 0 : else if(aCommand.EqualsAscii("Copy"))
669 : : {
670 [ # # ][ # # ]: 0 : Window* pChild = lcl_GetFocusChild( VCLUnoHelper::GetWindow( xWindow ) );
671 [ # # ]: 0 : if(pChild)
672 : : {
673 [ # # ][ # # ]: 0 : KeyEvent aEvent( 0, KEYFUNC_COPY );
674 [ # # ]: 0 : pChild->KeyInput( aEvent );
675 : : }
676 : : }
677 [ # # ][ # # ]: 0 : else if(aCommand.EqualsAscii("Paste"))
678 : : {
679 [ # # ][ # # ]: 0 : Window* pChild = lcl_GetFocusChild( VCLUnoHelper::GetWindow( xWindow ) );
680 [ # # ]: 0 : if(pChild)
681 : : {
682 [ # # ][ # # ]: 0 : KeyEvent aEvent( 0, KEYFUNC_PASTE );
683 [ # # ]: 0 : pChild->KeyInput( aEvent );
684 : : }
685 [ # # ][ # # ]: 0 : }
[ # # ]
686 : : }
687 : 0 : }
688 : 0 : IMPL_STATIC_LINK( BibFrameController_Impl, DisposeHdl, void*, EMPTYARG )
689 : : {
690 : 0 : pThis->xFrame->dispose();
691 : 0 : return 0;
692 : : };
693 : :
694 : : //-----------------------------------------------------------------------------
695 : 0 : void BibFrameController_Impl::addStatusListener(
696 : : const uno::Reference< frame::XStatusListener > & aListener,
697 : : const util::URL& aURL)
698 : : throw (::com::sun::star::uno::RuntimeException)
699 : : {
700 [ # # ]: 0 : BibConfig* pConfig = BibModul::GetConfig();
701 : : // create a new Reference and insert into listener array
702 [ # # ][ # # ]: 0 : aStatusListeners.push_back( new BibStatusDispatch( aURL, aListener ) );
[ # # ]
703 : :
704 : : // den ersten Status synchron zusenden
705 [ # # ]: 0 : FeatureStateEvent aEvent;
706 : 0 : aEvent.FeatureURL = aURL;
707 : 0 : aEvent.Requery = sal_False;
708 [ # # ]: 0 : aEvent.Source = (XDispatch *) this;
709 [ # # ]: 0 : if ( aURL.Path == C2U("StatusBarVisible") )
710 : : {
711 : 0 : aEvent.IsEnabled = sal_False;
712 [ # # ]: 0 : aEvent.State <<= sal_Bool( sal_False );
713 : : }
714 [ # # ]: 0 : else if ( aURL.Path == C2U("Bib/hierarchical") )
715 : : {
716 : 0 : aEvent.IsEnabled = sal_True;
717 [ # # ]: 0 : const char* pHier = bHierarchical? "" : "*" ;
718 [ # # ]: 0 : aEvent.State <<= rtl::OUString::createFromAscii(pHier);
719 : : }
720 [ # # ]: 0 : else if(aURL.Path == C2U("Bib/MenuFilter"))
721 : : {
722 : 0 : aEvent.IsEnabled = sal_True;
723 [ # # ]: 0 : aEvent.FeatureDescriptor=pDatMan->getQueryField();
724 : :
725 [ # # ]: 0 : uno::Sequence<rtl::OUString> aStringSeq=pDatMan->getQueryFields();
726 [ # # ][ # # ]: 0 : aEvent.State.setValue(&aStringSeq,::getCppuType((uno::Sequence<rtl::OUString>*)0));
727 : :
728 : : }
729 [ # # ]: 0 : else if ( aURL.Path == C2U("Bib/source"))
730 : : {
731 : 0 : aEvent.IsEnabled = sal_True;
732 [ # # ]: 0 : aEvent.FeatureDescriptor=pDatMan->getActiveDataTable();
733 : :
734 [ # # ]: 0 : uno::Sequence<rtl::OUString> aStringSeq=pDatMan->getDataSources();
735 [ # # ][ # # ]: 0 : aEvent.State.setValue(&aStringSeq,::getCppuType((uno::Sequence<rtl::OUString>*)0));
736 : : }
737 [ # # # # : 0 : else if( aURL.Path == "Bib/sdbsource" ||
# # # # ]
[ # # ]
738 : 0 : aURL.Path == "Bib/Mapping" ||
739 : 0 : aURL.Path == "Bib/autoFilter" ||
740 : 0 : aURL.Path == "Bib/standardFilter" )
741 : : {
742 : 0 : aEvent.IsEnabled = sal_True;
743 : : }
744 [ # # ]: 0 : else if(aURL.Path == C2U("Bib/query"))
745 : : {
746 : 0 : aEvent.IsEnabled = sal_True;
747 [ # # ]: 0 : aEvent.State <<= pConfig->getQueryText();
748 : : }
749 [ # # ]: 0 : else if (aURL.Path == C2U("Bib/removeFilter") )
750 : : {
751 [ # # ]: 0 : rtl::OUString aFilterStr=pDatMan->getFilter();
752 : 0 : aEvent.IsEnabled = !aFilterStr.isEmpty();
753 : : }
754 [ # # ]: 0 : else if(aURL.Path == C2U("Cut"))
755 : : {
756 [ # # ][ # # ]: 0 : Window* pChild = lcl_GetFocusChild( VCLUnoHelper::GetWindow( xWindow ) );
757 [ # # ]: 0 : Edit* pEdit = dynamic_cast<Edit*>( pChild );
758 [ # # ]: 0 : if( pEdit )
759 [ # # ][ # # ]: 0 : aEvent.IsEnabled = !pEdit->IsReadOnly() && pEdit->GetSelection().Len();
[ # # ][ # # ]
760 : : }
761 [ # # ]: 0 : if(aURL.Path == C2U("Copy"))
762 : : {
763 [ # # ][ # # ]: 0 : Window* pChild = lcl_GetFocusChild( VCLUnoHelper::GetWindow( xWindow ) );
764 [ # # ]: 0 : Edit* pEdit = dynamic_cast<Edit*>( pChild );
765 [ # # ]: 0 : if( pEdit )
766 [ # # ]: 0 : aEvent.IsEnabled = pEdit->GetSelection().Len() > 0;
767 : : }
768 [ # # ]: 0 : else if(aURL.Path == C2U("Paste") )
769 : : {
770 : 0 : aEvent.IsEnabled = sal_False;
771 [ # # ][ # # ]: 0 : Window* pChild = lcl_GetFocusChild( VCLUnoHelper::GetWindow( xWindow ) );
772 [ # # ]: 0 : if(pChild)
773 : : {
774 [ # # ]: 0 : uno::Reference< datatransfer::clipboard::XClipboard > xClip = pChild->GetClipboard();
775 [ # # ]: 0 : if(xClip.is())
776 : : {
777 : 0 : uno::Reference< datatransfer::XTransferable > xDataObj;
778 [ # # ]: 0 : const sal_uInt32 nRef = Application::ReleaseSolarMutex();
779 : : try
780 : : {
781 [ # # ][ # # ]: 0 : xDataObj = xClip->getContents();
[ # # ][ # # ]
782 : : }
783 [ # # # # ]: 0 : catch( const uno::Exception& )
784 : : {
785 : : }
786 [ # # ]: 0 : Application::AcquireSolarMutex( nRef );
787 : :
788 [ # # ]: 0 : if ( xDataObj.is() )
789 : : {
790 : 0 : datatransfer::DataFlavor aFlavor;
791 [ # # ]: 0 : SotExchange::GetFormatDataFlavor( SOT_FORMAT_STRING, aFlavor );
792 : : try
793 : : {
794 [ # # ][ # # ]: 0 : uno::Any aData = xDataObj->getTransferData( aFlavor );
795 : 0 : ::rtl::OUString aText;
796 : 0 : aData >>= aText;
797 : 0 : aEvent.IsEnabled = !aText.isEmpty();
798 : : }
799 [ # # ]: 0 : catch( const uno::Exception& )
800 : : {
801 : 0 : }
802 : 0 : }
803 : : }
804 [ # # ][ # # ]: 0 : uno::Reference< datatransfer::XTransferable > xContents = xClip->getContents( );
805 : : }
806 : : }
807 [ # # ]: 0 : else if(aURL.Path == C2U("Bib/DeleteRecord"))
808 : : {
809 [ # # ]: 0 : Reference< ::com::sun::star::sdbc::XResultSet > xCursor(pDatMan->getForm(), UNO_QUERY);
810 [ # # ]: 0 : Reference< XResultSetUpdate > xUpdateCursor(xCursor, UNO_QUERY);
811 [ # # ]: 0 : Reference< beans::XPropertySet > xSet(pDatMan->getForm(), UNO_QUERY);
812 [ # # ][ # # ]: 0 : sal_Bool bIsNew = ::comphelper::getBOOL(xSet->getPropertyValue(C2U("IsNew")));
[ # # ]
813 [ # # ]: 0 : if(!bIsNew)
814 : : {
815 : 0 : sal_uInt32 nCount = 0;
816 [ # # ][ # # ]: 0 : xSet->getPropertyValue(C2U("RowCount")) >>= nCount;
817 : 0 : aEvent.IsEnabled = nCount > 0;
818 : 0 : }
819 : : }
820 [ # # ]: 0 : else if (aURL.Path == C2U("Bib/InsertRecord"))
821 : : {
822 [ # # ]: 0 : Reference< beans::XPropertySet > xSet(pDatMan->getForm(), UNO_QUERY);
823 [ # # ]: 0 : aEvent.IsEnabled = canInsertRecords(xSet);
824 : : }
825 [ # # ][ # # ]: 0 : aListener->statusChanged( aEvent );
[ # # ]
826 : 0 : }
827 : : //-----------------------------------------------------------------------------
828 : 0 : void BibFrameController_Impl::removeStatusListener(
829 : : const uno::Reference< frame::XStatusListener > & aObject, const util::URL& aURL)
830 : : throw (::com::sun::star::uno::RuntimeException)
831 : : {
832 : : // search listener array for given listener
833 : : // for checking equality always "cast" to XInterface
834 [ # # ]: 0 : if ( !bDisposing )
835 : : {
836 : 0 : sal_uInt16 nCount = aStatusListeners.size();
837 [ # # ]: 0 : for ( sal_uInt16 n=0; n<nCount; n++ )
838 : : {
839 : 0 : BibStatusDispatch *pObj = &aStatusListeners[n];
840 : 0 : sal_Bool bFlag=pObj->xListener.is();
841 [ # # # # : 0 : if (!bFlag || (pObj->xListener == aObject &&
# # ][ # # ]
[ # # ]
842 : 0 : ( aURL.Complete.isEmpty() || pObj->aURL.Path == aURL.Path )))
843 : : {
844 : 0 : aStatusListeners.erase( aStatusListeners.begin() + n );
845 : 0 : break;
846 : : }
847 : : }
848 : : }
849 : 0 : }
850 : : //-----------------------------------------------------------------------------
851 : 0 : void BibFrameController_Impl::RemoveFilter()
852 : : {
853 : 0 : rtl::OUString aQuery;
854 [ # # ]: 0 : pDatMan->startQueryWith(aQuery);
855 : :
856 : 0 : sal_uInt16 nCount = aStatusListeners.size();
857 : :
858 : 0 : sal_Bool bRemoveFilter=sal_False;
859 : 0 : sal_Bool bQueryText=sal_False;
860 : :
861 [ # # ]: 0 : for ( sal_uInt16 n=0; n<nCount; n++ )
862 : : {
863 [ # # ]: 0 : BibStatusDispatch *pObj = &aStatusListeners[n];
864 [ # # ]: 0 : if ( pObj->aURL.Path == C2U("Bib/removeFilter") )
865 : : {
866 [ # # ]: 0 : FeatureStateEvent aEvent;
867 : 0 : aEvent.FeatureURL = pObj->aURL;
868 : 0 : aEvent.IsEnabled = sal_False;
869 : 0 : aEvent.Requery = sal_False;
870 [ # # ]: 0 : aEvent.Source = (XDispatch *) this;
871 [ # # ][ # # ]: 0 : pObj->xListener->statusChanged( aEvent );
872 [ # # ]: 0 : bRemoveFilter=sal_True;
873 : : }
874 [ # # ]: 0 : else if(pObj->aURL.Path == C2U("Bib/query"))
875 : : {
876 [ # # ]: 0 : FeatureStateEvent aEvent;
877 : 0 : aEvent.FeatureURL = pObj->aURL;
878 : 0 : aEvent.IsEnabled = sal_True;
879 : 0 : aEvent.Requery = sal_False;
880 [ # # ]: 0 : aEvent.Source = (XDispatch *) this;
881 [ # # ]: 0 : aEvent.State <<= aQuery;
882 [ # # ][ # # ]: 0 : pObj->xListener->statusChanged( aEvent );
883 [ # # ]: 0 : bQueryText=sal_True;
884 : : }
885 : :
886 [ # # ][ # # ]: 0 : if(bRemoveFilter && bQueryText)
887 : 0 : break;
888 : :
889 : 0 : }
890 : 0 : }
891 : : //-----------------------------------------------------------------------------
892 : 0 : void BibFrameController_Impl::ChangeDataSource(const uno::Sequence< beans::PropertyValue >& aArgs)
893 : : {
894 : 0 : const beans::PropertyValue* pPropertyValue = aArgs.getConstArray();
895 : 0 : uno::Any aValue=pPropertyValue[0].Value;
896 : 0 : rtl::OUString aDBTableName;
897 : 0 : aValue >>= aDBTableName;
898 : :
899 : :
900 [ # # ]: 0 : if(aArgs.getLength() > 1)
901 : : {
902 : 0 : uno::Any aDB = pPropertyValue[1].Value;
903 : 0 : rtl::OUString aURL;
904 : 0 : aDB >>= aURL;
905 [ # # ]: 0 : pDatMan->setActiveDataSource(aURL);
906 [ # # ]: 0 : aDBTableName = pDatMan->getActiveDataTable();
907 : : }
908 : : else
909 : : {
910 [ # # ][ # # ]: 0 : m_xDatMan->unload();
911 [ # # ]: 0 : pDatMan->setActiveDataTable(aDBTableName);
912 [ # # ]: 0 : pDatMan->updateGridModel();
913 [ # # ][ # # ]: 0 : m_xDatMan->load();
914 : : }
915 : :
916 : :
917 : 0 : sal_uInt16 nCount = aStatusListeners.size();
918 : :
919 : 0 : sal_Bool bMenuFilter=sal_False;
920 : 0 : sal_Bool bQueryText=sal_False;
921 [ # # ]: 0 : for ( sal_uInt16 n=0; n<nCount; n++ )
922 : : {
923 [ # # ]: 0 : BibStatusDispatch *pObj = &aStatusListeners[n];
924 [ # # ]: 0 : if(COMPARE_EQUAL == pObj->aURL.Path.compareToAscii("Bib/MenuFilter"))
925 : : {
926 [ # # ]: 0 : FeatureStateEvent aEvent;
927 : 0 : aEvent.FeatureURL = pObj->aURL;
928 : 0 : aEvent.IsEnabled = sal_True;
929 : 0 : aEvent.Requery = sal_False;
930 [ # # ]: 0 : aEvent.Source = (XDispatch *) this;
931 [ # # ]: 0 : aEvent.FeatureDescriptor=pDatMan->getQueryField();
932 : :
933 [ # # ]: 0 : uno::Sequence<rtl::OUString> aStringSeq=pDatMan->getQueryFields();
934 [ # # ]: 0 : aEvent.State = makeAny( aStringSeq );
935 : :
936 [ # # ][ # # ]: 0 : pObj->xListener->statusChanged( aEvent );
937 [ # # ][ # # ]: 0 : bMenuFilter=sal_True;
938 : : }
939 [ # # ]: 0 : else if(COMPARE_EQUAL == pObj->aURL.Path.compareToAscii("Bib/query"))
940 : : {
941 [ # # ]: 0 : FeatureStateEvent aEvent;
942 : 0 : aEvent.FeatureURL = pObj->aURL;
943 : 0 : aEvent.IsEnabled = sal_True;
944 : 0 : aEvent.Requery = sal_False;
945 [ # # ]: 0 : aEvent.Source = (XDispatch *) this;
946 [ # # ]: 0 : BibConfig* pConfig = BibModul::GetConfig();
947 [ # # ]: 0 : aEvent.State <<= pConfig->getQueryText();
948 [ # # ][ # # ]: 0 : pObj->xListener->statusChanged( aEvent );
949 [ # # ]: 0 : bQueryText=sal_True;
950 : : }
951 : :
952 [ # # ][ # # ]: 0 : if (bMenuFilter && bQueryText)
953 : 0 : break;
954 : :
955 : 0 : }
956 : 0 : }
957 : :
958 : 0 : void BibFrameController_Impl::activate()
959 : : {
960 : 0 : }
961 : 0 : void BibFrameController_Impl::deactivate()
962 : : {
963 : 0 : }
964 : :
965 : :
966 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|