Yan Wu wrote:
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):
Hi Yan,
1)Define the command 'SearchText' and the corresponding slotID in sdi
files and handle them via shells in swriter/scalc/simpress.
This is not an option as we need to support this command in the future
for all application modules (e.g. database).
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().
I am sorry, but I don't like this idea either. This is clearly a hack as
we add special code in a generic implementation. Best way would be to
implement a ProtocolHandler in svx for the find bar. That's something we
can extend as we like and we don't need to change generic code. You can
find more information about ProtocolHandler in the Developer's Guide.
It's also possible to use the skeleton-maker from the OpenOfficr.org SDK.
- 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,
Carsten
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@framework.openoffice.org
For additional commands, e-mail: dev-h...@framework.openoffice.org