summaryrefslogtreecommitdiff
path: root/sw/source/uibase/uiview/viewling.cxx
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2015-11-25 17:33:45 +0200
committerMaxim Monastirsky <momonasmon@gmail.com>2015-11-26 08:19:23 +0000
commitff35d252ff247c55c1004cce6676af8f881a2e68 (patch)
tree70ba1c6055b0689132e230533236d9553baf4f64 /sw/source/uibase/uiview/viewling.cxx
parent8d6136206f26dbee773ffaea18a0f37c17e55024 (diff)
tdf#93837 Add UNO-based SmartTag menu controller
... and use it for the standalone context menu. The sfx2 controller (SvxSmartTagsControl) is still used for the submenu variation, and is due to be removed after the new context menu implementation is in place. Change-Id: I2f889428eb777149f43d74cf3d081e19ab0ebb4a Reviewed-on: https://gerrit.libreoffice.org/20169 Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com> Tested-by: Maxim Monastirsky <momonasmon@gmail.com>
Diffstat (limited to 'sw/source/uibase/uiview/viewling.cxx')
-rw-r--r--sw/source/uibase/uiview/viewling.cxx42
1 files changed, 25 insertions, 17 deletions
diff --git a/sw/source/uibase/uiview/viewling.cxx b/sw/source/uibase/uiview/viewling.cxx
index 4b4c2a230a3d..f72e370256cc 100644
--- a/sw/source/uibase/uiview/viewling.cxx
+++ b/sw/source/uibase/uiview/viewling.cxx
@@ -25,10 +25,12 @@
#include <com/sun/star/i18n/TextConversionOption.hpp>
#include <linguistic/lngprops.hxx>
#include <comphelper/processfactory.hxx>
+#include <comphelper/propertyvalue.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <vcl/msgbox.hxx>
#include <svtools/ehdl.hxx>
#include <svl/stritem.hxx>
+#include <sfx2/dispatch.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/request.hxx>
#include <svx/dlgutil.hxx>
@@ -68,6 +70,8 @@
#include <com/sun/star/frame/XDispatch.hpp>
#include <com/sun/star/frame/XDispatchProvider.hpp>
#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/XPopupMenuController.hpp>
+#include <com/sun/star/awt/PopupMenuDirection.hpp>
#include <com/sun/star/util/URL.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/util/URLTransformer.hpp>
@@ -77,7 +81,6 @@
#include <rtl/ustring.hxx>
#include <cppuhelper/bootstrap.hxx>
-#include "stmenu.hxx"
#include <svx/dialogs.hrc>
#include <svtools/langtab.hxx>
#include <unomid.h>
@@ -93,7 +96,6 @@ using namespace ::com::sun::star;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::linguistic2;
-using namespace ::com::sun::star::smarttags;
// Lingu-Dispatcher
@@ -788,33 +790,39 @@ bool SwView::ExecSpellPopup(const Point& rPt)
This function shows the popup menu for smarttag
actions.
*/
-bool SwView::ExecSmartTagPopup( const Point& rPt )
+void SwView::ExecSmartTagPopup( const Point& rPt )
{
- bool bRet = false;
const bool bOldViewLock = m_pWrtShell->IsViewLocked();
m_pWrtShell->LockView( true );
m_pWrtShell->Push();
- // get word that was clicked on
- // This data structure maps a smart tag type string to the property bag
- SwRect aToFill;
- Sequence< OUString > aSmartTagTypes;
- Sequence< Reference< container::XStringKeyMap > > aStringKeyMaps;
- Reference<text::XTextRange> xRange;
+ css::uno::Sequence< css::uno::Any > aArgs( 2 );
+ aArgs[0] <<= comphelper::makePropertyValue( "Frame", GetDispatcher().GetFrame()->GetFrame().GetFrameInterface() );
+ aArgs[1] <<= comphelper::makePropertyValue( "CommandURL", OUString( ".uno:OpenSmartTagMenuOnCursor" ) );
+
+ css::uno::Reference< css::uno::XComponentContext > xContext = comphelper::getProcessComponentContext();
+ css::uno::Reference< css::frame::XPopupMenuController > xPopupController(
+ xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
+ "com.sun.star.comp.svx.SmartTagMenuController", aArgs, xContext ), css::uno::UNO_QUERY );
- m_pWrtShell->GetSmartTagTerm( rPt, aToFill, aSmartTagTypes, aStringKeyMaps, xRange);
- if ( xRange.is() && aSmartTagTypes.getLength() )
+ css::uno::Reference< css::awt::XPopupMenu > xPopupMenu( xContext->getServiceManager()->createInstanceWithContext(
+ "com.sun.star.awt.PopupMenu", xContext ), css::uno::UNO_QUERY );
+
+ if ( xPopupController.is() && xPopupMenu.is() )
{
- bRet = true;
+ xPopupController->setPopupMenu( xPopupMenu );
+
+ SwRect aToFill;
+ m_pWrtShell->GetSmartTagRect( rPt, aToFill );
m_pWrtShell->SttSelect();
- SwSmartTagPopup aPopup( this, aSmartTagTypes, aStringKeyMaps, xRange );
- aPopup.Execute( aToFill.SVRect(), m_pEditWin );
+
+ if ( aToFill.HasArea() )
+ xPopupMenu->execute( m_pEditWin->GetComponentInterface(),
+ VCLUnoHelper::ConvertToAWTRect( m_pEditWin->LogicToPixel( aToFill.SVRect() ) ), css::awt::PopupMenuDirection::EXECUTE_DOWN );
}
m_pWrtShell->Pop( false );
m_pWrtShell->LockView( bOldViewLock );
-
- return bRet;
}
class SwFieldDialog : public FloatingWindow