summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorAriel Constenla-Haile <arielch@apache.org>2012-12-06 12:29:55 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-05-21 14:01:18 +0100
commit819840979b82a7b19329eda63db0d5f8a291b9de (patch)
treeb7ba46505423f3b4e7a87f13300f139d665d788e /framework
parent25ec90bfa85ab829e47f442742c63dd41960b973 (diff)
Related: #i121442# - Refactor UNO StatusbarControllers
(cherry picked from commit 3f1dd0f6b392c104e0a7c7c2623d5d688f8622c0) Conflicts: framework/source/uielement/langselectionstatusbarcontroller.cxx Change-Id: I1e8f87d1fbd12bab98b38282cedc730ac23694c3
Diffstat (limited to 'framework')
-rw-r--r--framework/inc/uielement/langselectionstatusbarcontroller.hxx22
-rw-r--r--framework/source/uielement/langselectionstatusbarcontroller.cxx176
2 files changed, 45 insertions, 153 deletions
diff --git a/framework/inc/uielement/langselectionstatusbarcontroller.hxx b/framework/inc/uielement/langselectionstatusbarcontroller.hxx
index 560e627c8e8e..71896ef18a4b 100644
--- a/framework/inc/uielement/langselectionstatusbarcontroller.hxx
+++ b/framework/inc/uielement/langselectionstatusbarcontroller.hxx
@@ -47,36 +47,18 @@ class LangSelectionStatusbarController : public svt::StatusbarController
// XServiceInfo
DECLARE_XSERVICEINFO
- // XInterface
- virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL acquire() throw ();
- virtual void SAL_CALL release() throw ();
-
// XInitialization
virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
- // XComponent
- virtual void SAL_CALL dispose() throw ( ::com::sun::star::uno::RuntimeException );
-
- // XEventListener
- virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& Source ) throw ( ::com::sun::star::uno::RuntimeException );
-
// XStatusListener
virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException );
// XStatusbarController
- virtual ::sal_Bool SAL_CALL mouseButtonDown( const ::com::sun::star::awt::MouseEvent& aMouseEvent ) throw (::com::sun::star::uno::RuntimeException);
- virtual ::sal_Bool SAL_CALL mouseMove( const ::com::sun::star::awt::MouseEvent& aMouseEvent ) throw (::com::sun::star::uno::RuntimeException);
- virtual ::sal_Bool SAL_CALL mouseButtonUp( const ::com::sun::star::awt::MouseEvent& aMouseEvent ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL command( const ::com::sun::star::awt::Point& aPos,
::sal_Int32 nCommand,
::sal_Bool bMouseEvent,
const ::com::sun::star::uno::Any& aData ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL paint( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics >& xGraphics,
- const ::com::sun::star::awt::Rectangle& rOutputRectangle,
- ::sal_Int32 nItemId, ::sal_Int32 nStyle ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL click() throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL doubleClick() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL click( const ::com::sun::star::awt::Point& aPos ) throw (::com::sun::star::uno::RuntimeException);
private:
virtual ~LangSelectionStatusbarController() {}
@@ -91,7 +73,7 @@ class LangSelectionStatusbarController : public svt::StatusbarController
OUString m_aGuessedTextLang; // the 'guessed' language for the selection, "" if none could be guessed
LanguageGuessingHelper m_aLangGuessHelper;
- void LangMenu() throw (::com::sun::star::uno::RuntimeException);
+ void LangMenu( const ::com::sun::star::awt::Point& aPos ) throw (::com::sun::star::uno::RuntimeException);
};
} // framework namespace
diff --git a/framework/source/uielement/langselectionstatusbarcontroller.cxx b/framework/source/uielement/langselectionstatusbarcontroller.cxx
index d8d5451bce02..09c0a3d02dae 100644
--- a/framework/source/uielement/langselectionstatusbarcontroller.cxx
+++ b/framework/source/uielement/langselectionstatusbarcontroller.cxx
@@ -26,7 +26,6 @@
#include <vcl/svapp.hxx>
#include <vcl/window.hxx>
#include <vcl/status.hxx>
-#include <toolkit/unohlp.hxx>
#include <toolkit/helper/convert.hxx>
#include <com/sun/star/frame/XPopupMenuController.hpp>
@@ -49,6 +48,7 @@
#include <com/sun/star/util/XURLTransformer.hpp>
#include <comphelper/processfactory.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
#include <tools/gen.hxx>
#include <com/sun/star/awt/Command.hpp>
#include <svl/languageoptions.hxx>
@@ -56,6 +56,8 @@
#include "helper/mischelper.hxx"
+#include <rtl/ustrbuf.hxx>
+
#include <map>
#include <set>
@@ -67,12 +69,12 @@ using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::i18n;
using namespace ::com::sun::star::document;
+using ::rtl::OUStringBuffer;
namespace framework
{
-
DEFINE_XSERVICEINFO_MULTISERVICE ( LangSelectionStatusbarController ,
OWeakObject ,
SERVICENAME_STATUSBARCONTROLLER ,
@@ -89,23 +91,6 @@ LangSelectionStatusbarController::LangSelectionStatusbarController( const uno::R
{
}
-// XInterface
-Any SAL_CALL LangSelectionStatusbarController::queryInterface( const Type& rType )
-throw ( RuntimeException )
-{
- return svt::StatusbarController::queryInterface( rType );
-}
-
-void SAL_CALL LangSelectionStatusbarController::acquire() throw ()
-{
- svt::StatusbarController::acquire();
-}
-
-void SAL_CALL LangSelectionStatusbarController::release() throw ()
-{
- svt::StatusbarController::release();
-}
-
void SAL_CALL LangSelectionStatusbarController::initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
{
@@ -114,59 +99,14 @@ throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException
svt::StatusbarController::initialize( aArguments );
- if ( m_xParentWindow.is() && m_nID > 0 )
+ if ( m_xStatusbarItem.is() )
{
- Window* pWindow = VCLUnoHelper::GetWindow( m_xParentWindow );
- if ( pWindow && ( pWindow->GetType() == WINDOW_STATUSBAR ))
- {
- StatusBar* pStatusBar = (StatusBar *)pWindow;
- pStatusBar->SetItemText( m_nID, FwkResId( STR_LANGSTATUS_MULTIPLE_LANGUAGES ) );
- }
+ m_xStatusbarItem->setText( String( FwkResId( STR_LANGSTATUS_MULTIPLE_LANGUAGES ) ) );
}
}
-// XComponent
-void SAL_CALL LangSelectionStatusbarController::dispose()
-throw (::com::sun::star::uno::RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::dispose" );
- svt::StatusbarController::dispose();
-}
-
-// XEventListener
-void SAL_CALL LangSelectionStatusbarController::disposing( const com::sun::star::lang::EventObject& Source )
-throw ( RuntimeException )
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::disposing" );
- svt::StatusbarController::disposing( Source );
-}
-
-// XStatusbarController
-::sal_Bool SAL_CALL LangSelectionStatusbarController::mouseButtonDown(
- const ::com::sun::star::awt::MouseEvent& )
-throw (::com::sun::star::uno::RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::mouseButtonDown" );
- return sal_False;
-}
-
-::sal_Bool SAL_CALL LangSelectionStatusbarController::mouseMove(
- const ::com::sun::star::awt::MouseEvent& )
-throw (::com::sun::star::uno::RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::mouseMove" );
- return sal_False;
-}
-
-::sal_Bool SAL_CALL LangSelectionStatusbarController::mouseButtonUp(
- const ::com::sun::star::awt::MouseEvent& )
-throw (::com::sun::star::uno::RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::mouseButtonUp" );
- return sal_False;
-}
-
-void LangSelectionStatusbarController::LangMenu()
+void LangSelectionStatusbarController::LangMenu(
+ const ::com::sun::star::awt::Point& aPos )
throw (::com::sun::star::uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::LangMenu" );
@@ -200,7 +140,7 @@ throw (::com::sun::star::uno::RuntimeException)
{
DBG_ASSERT( MID_LANG_SEL_1 <= nItemId && nItemId <= MID_LANG_SEL_9,
"nItemId outside of expected range!" );
- xPopupMenu->insertItem( nItemId, rStr, css::awt::MenuItemStyle::RADIOCHECK, nItemId );
+ xPopupMenu->insertItem( nItemId, rStr, 0, nItemId );
if ( rStr == m_aCurLang )
{
//make a sign for the current language
@@ -210,10 +150,10 @@ throw (::com::sun::star::uno::RuntimeException)
++nItemId;
}
}
- xPopupMenu->insertItem( MID_LANG_SEL_NONE, String( FwkResId( STR_LANGSTATUS_NONE )), css::awt::MenuItemStyle::RADIOCHECK, MID_LANG_SEL_NONE );
+
+ xPopupMenu->insertItem( MID_LANG_SEL_NONE, String( FwkResId( STR_LANGSTATUS_NONE )), 0, MID_LANG_SEL_NONE );
if ( aLanguageTable.GetString( LANGUAGE_NONE ) == m_aCurLang )
xPopupMenu->checkItem( MID_LANG_SEL_NONE, sal_True );
-
xPopupMenu->insertItem( MID_LANG_SEL_RESET, String( FwkResId( STR_RESET_TO_DEFAULT_LANGUAGE )), 0, MID_LANG_SEL_RESET );
xPopupMenu->insertItem( MID_LANG_SEL_MORE, String( FwkResId( STR_LANGSTATUS_MORE )), 0, MID_LANG_SEL_MORE );
@@ -246,77 +186,65 @@ throw (::com::sun::star::uno::RuntimeException)
// now display the popup menu and execute every command ...
Reference< awt::XWindowPeer > xParent( m_xParentWindow, UNO_QUERY );
-
com::sun::star::awt::Rectangle aRectangle;
- Window* pWindow = VCLUnoHelper::GetWindow( m_xParentWindow );
- const Point mMousePos = pWindow->GetPointerPosPixel();
- aRectangle.X = mMousePos.X();
- aRectangle.Y = mMousePos.Y();
+ aRectangle.X = aPos.X;
+ aRectangle.Y = aPos.Y;
sal_Int16 nId = xPopupMenu->execute( xParent, aRectangle, com::sun::star::awt::PopupMenuDirection::EXECUTE_UP+16 );
//click "More..."
if ( nId && m_xFrame.is() )
{
- uno::Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
- util::URL aURL;
+ OUStringBuffer aBuff;
+ //set selected language as current language for selection
+ const OUString aSelectedLang = aLangMap[nId];
if (MID_LANG_SEL_1 <= nId && nId <= MID_LANG_SEL_9)
{
- //set selected language as current language for selection
- String aSelectedLang = aLangMap[nId];
- aURL.Complete += ".uno:LanguageStatus?Language:string=Current_";
- aURL.Complete += aSelectedLang;
+ aBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( (".uno:LanguageStatus?Language:string=Current_") ));
+ aBuff.append( aSelectedLang );
}
else if (nId == MID_LANG_SEL_NONE)
{
//set None as current language for selection
- aURL.Complete += ".uno:LanguageStatus?Language:string=Current_LANGUAGE_NONE";
+ aBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( (".uno:LanguageStatus?Language:string=Current_LANGUAGE_NONE") ));
}
else if (nId == MID_LANG_SEL_RESET)
{
// reset language attributes for selection
- aURL.Complete += ".uno:LanguageStatus?Language:string=Current_RESET_LANGUAGES";
+ aBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( (".uno:LanguageStatus?Language:string=Current_RESET_LANGUAGES") ));
}
else if (nId == MID_LANG_SEL_MORE)
{
//open the dialog "format/character" for current selection
- aURL.Complete += ".uno:FontDialog?Language:string=*";
+ aBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( (".uno:FontDialog?Language:string=*") ));
}
else if (MID_LANG_PARA_1 <= nId && nId <= MID_LANG_PARA_9)
{
- //set selected language for current paragraph
- String aSelectedLang = aLangMap[nId];
- aURL.Complete += ".uno:LanguageStatus?Language:string=Paragraph_";
- aURL.Complete += aSelectedLang;
+ aBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( (".uno:LanguageStatus?Language:string=Paragraph_") ));
+ aBuff.append( aSelectedLang );
}
else if (nId == MID_LANG_PARA_NONE)
{
//set None as language for current paragraph
- aURL.Complete += ".uno:LanguageStatus?Language:string=Paragraph_LANGUAGE_NONE";
+ aBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( (".uno:LanguageStatus?Language:string=Paragraph_LANGUAGE_NONE") ));
}
else if (nId == MID_LANG_PARA_RESET)
{
// reset language attributes for paragraph
- aURL.Complete += ".uno:LanguageStatus?Language:string=Paragraph_RESET_LANGUAGES";
+ aBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( (".uno:LanguageStatus?Language:string=Paragraph_RESET_LANGUAGES") ));
}
else if (nId == MID_LANG_PARA_MORE)
{
//open the dialog "format/character" for current paragraph
- aURL.Complete += ".uno:FontDialogForParagraph";
+ aBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( (".uno:FontDialogForParagraph") ));
}
- uno::Reference< util::XURLTransformer > xURLTransformer( util::URLTransformer::create(::comphelper::getComponentContext(m_xServiceManager)) );
- xURLTransformer->parseStrict( aURL );
- uno::Reference< XDispatch > xDispatch = xDispatchProvider->queryDispatch(aURL, OUString(), 0);
- if( xDispatch.is() )
- {
- uno::Sequence< beans::PropertyValue > aPV;
- xDispatch->dispatch( aURL, aPV);
- }
+ const Sequence< beans::PropertyValue > aDummyArgs;
+ execute( aBuff.makeStringAndClear(), aDummyArgs );
}
}
void SAL_CALL LangSelectionStatusbarController::command(
- const ::com::sun::star::awt::Point& /*aPos*/,
+ const ::com::sun::star::awt::Point& aPos,
::sal_Int32 nCommand,
::sal_Bool /*bMouseEvent*/,
const ::com::sun::star::uno::Any& /*aData*/ )
@@ -325,33 +253,16 @@ throw (::com::sun::star::uno::RuntimeException)
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::command" );
if ( nCommand & ::awt::Command::CONTEXTMENU )
{
- LangMenu();
+ LangMenu( aPos );
}
}
-void SAL_CALL LangSelectionStatusbarController::paint(
- const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics >& xGraphics,
- const ::com::sun::star::awt::Rectangle& rOutputRectangle,
- ::sal_Int32 nItemId,
- ::sal_Int32 nStyle )
-throw (::com::sun::star::uno::RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::paint" );
- svt::StatusbarController::paint( xGraphics, rOutputRectangle, nItemId, nStyle );
-}
-
-void SAL_CALL LangSelectionStatusbarController::click()
+void SAL_CALL LangSelectionStatusbarController::click(
+ const ::com::sun::star::awt::Point& aPos )
throw (::com::sun::star::uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::click" );
- LangMenu();
-}
-
-void SAL_CALL LangSelectionStatusbarController::doubleClick()
-throw (::com::sun::star::uno::RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::doubleClick" );
- svt::StatusbarController::doubleClick();
+ LangMenu( aPos );
}
// XStatusListener
@@ -372,26 +283,25 @@ throw ( RuntimeException )
return;
m_bShowMenu = sal_True;
-
m_nScriptType = LS_SCRIPT_LATIN | LS_SCRIPT_ASIAN | LS_SCRIPT_COMPLEX; //set the default value
- Window* pWindow = VCLUnoHelper::GetWindow( m_xParentWindow );
- if ( pWindow && pWindow->GetType() == WINDOW_STATUSBAR && m_nID != 0 )
+
+ if ( m_xStatusbarItem.is() )
{
- OUString aStrValue;
+ OUString aStrValue;
Sequence< OUString > aSeq;
- StatusBar* pStatusBar = (StatusBar *)pWindow;
if ( Event.State >>= aStrValue )
- pStatusBar->SetItemText( m_nID, aStrValue );
+ m_xStatusbarItem->setText( aStrValue );
else if ( Event.State >>= aSeq )
{
if ( aSeq.getLength() == 4 )
{
- const String aMultipleLangText( FwkResId( STR_LANGSTATUS_MULTIPLE_LANGUAGES ) );
OUString aStatusText = aSeq[0];
- if ( 0 == aStatusText.compareToAscii( "*" ))
- aStatusText = aMultipleLangText;
- pStatusBar->SetItemText( m_nID, aStatusText );
+ if (aStatusText == "*")
+ {
+ aStatusText = String( FwkResId( STR_LANGSTATUS_MULTIPLE_LANGUAGES ) );
+ }
+ m_xStatusbarItem->setText( aStatusText );
// Retrieve all other values from the sequence and
// store it members!
@@ -403,7 +313,7 @@ throw ( RuntimeException )
}
else if ( !Event.State.hasValue() )
{
- pStatusBar->SetItemText( m_nID, String() );
+ m_xStatusbarItem->setText( OUString() );
m_bShowMenu = sal_False; // no language -> no menu
}
}