Hi Carsten,
For the findbar feature, a shortcut key(e.g.: Ctrl+G) is defined to
set the current cursor to the EditControl of the findbar, here are two
methods to dispatch the command(e.g.: .uno:SearchText, which can be
got by the Accelerators configuration):
1)Define the command 'SearchText' and the corresponding slotID in sdi
files and handle them via shells in swriter/scalc/simpress.
2)Implement a DispatchProvider for command .uno:SearchText, here are
the ideas how to implement this:
- add a new unocommandsdispatcher.hxx/cxx in
framework/source/dispatch/, implement a new UNO component
UnoCommandsDispatcher, which implements interfaces XDispatchProvider
and XDispatch. In the dispatch call we can set the cursor to the
EditControl of the findbar by such way:
getLayoutManager(m_xFrame)->getElement("private:resource/toolbar/findbar")->GetWindow()->GetItemWindow(nId)->GrabFocus().
- make some changes for
framework/source/dispatch/dispatchprovider.cxx, below is part of the
patch:
--- dispatchprovider.old.cxx 2010-02-04 03:22:12.000000000 +0800
+++ dispatchprovider.new.cxx 2010-02-07 15:51:26.750000000 +0800
@@ -509,6 +509,14 @@
xDispatcher = xController->queryDispatch(aURL,
SPECIALTARGET_SELF, 0);
}
+ if ( ! xDispatcher.is() )
+ {
+ if ( aURL.Complete.equalsAscii(".uno:SearchText") )
+ {
+ xDispatcher = implts_getOrCreateDispatchHelper(
E_UNOCOMMANDSDISPATCHER, xFrame);
+ }
+ }
+
// If controller has no fun to dispatch these URL - we must
search
another right dispatcher.
// Search for any registered protocol handler first.
if (!xDispatcher.is())
@@ -769,6 +777,13 @@
xDispatchHelper = css::uno::Reference<
css::frame::XDispatch >( static_cast< ::cppu::OWeakObject*
>(pDispatcher), css::uno::UNO_QUERY );
}
break;
+
+ case E_UNOCOMMANDSDISPATCHER:
+ {
+ UnoCommandsDispatcher* pDispatcher = new
UnoCommandsDispatcher(xFactory, xOwner);
+ xDispatchHelper = css::uno::Reference<
css::frame::XDispatch >( static_cast< ::cppu::OWeakObject*
>(pDispatcher), css::uno::UNO_QUERY );
+ }
+ break;
}
return xDispatchHelper;
Method 2) should be better than 1), do you think above implementation
of the DispatchProvider is all right, and is there any other better
way to do this?
Regards,
Yan
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]