From 73d3c9504a479e62126d1e7a1766173370603aa1 Mon Sep 17 00:00:00 2001 From: Noel Power Date: Wed, 16 Nov 2011 14:53:38 +0000 Subject: add new 'Goto Line' menu item to Basic IDE --- basctl/inc/basidesh.hrc | 6 ++++ basctl/sdi/baside.sdi | 6 ++++ basctl/source/basicide/basides1.cxx | 30 +++++++++++++++++ basctl/source/basicide/basidesh.src | 4 +++ basctl/source/basicide/moduldl2.cxx | 35 ++++++++++++++++++++ basctl/source/basicide/moduldlg.hxx | 12 +++++++ basctl/source/basicide/moduldlg.src | 38 ++++++++++++++++++++++ basctl/uiconfig/basicide/menubar/menubar.xml | 1 + .../data/org/openoffice/Office/Accelerators.xcu | 5 +++ .../org/openoffice/Office/UI/BasicIDECommands.xcu | 5 +++ sfx2/inc/sfx2/sfxsids.hrc | 3 +- sfx2/sdi/sfx.sdi | 24 ++++++++++++++ 12 files changed, 168 insertions(+), 1 deletion(-) diff --git a/basctl/inc/basidesh.hrc b/basctl/inc/basidesh.hrc index f3a1e641b8bb..9e5ccb2b9398 100644 --- a/basctl/inc/basidesh.hrc +++ b/basctl/inc/basidesh.hrc @@ -169,6 +169,12 @@ #define RID_STR_NORMAL_MODULES ( RID_BASICIDE_START + 120 ) #define RID_STR_CLASS_MODULES ( RID_BASICIDE_START + 121 ) + +#define RID_DLG_GOTOLINE ( RID_BASICIDE_START + 122 ) +#define RID_FT_LINE ( RID_BASICIDE_START + 123 ) +#define RID_ED_LINE ( RID_BASICIDE_START + 124 ) +#define RID_STR_GETLINE ( RID_BASICIDE_START + 125 ) + #endif // _SVX_NOIDERESIDS #endif // _BASIDESH_HRC diff --git a/basctl/sdi/baside.sdi b/basctl/sdi/baside.sdi index f40e239b01bf..37b2f08daf37 100644 --- a/basctl/sdi/baside.sdi +++ b/basctl/sdi/baside.sdi @@ -116,6 +116,12 @@ shell BasicIDEShell StateMethod = GetState; ] + SID_GOTOLINE + [ + ExecMethod = ExecuteCurrent; + StateMethod = GetState; + ] + FID_SEARCH_NOW [ ExecMethod = ExecuteCurrent; diff --git a/basctl/source/basicide/basides1.cxx b/basctl/source/basicide/basides1.cxx index 6a5cd1332c10..234fad7fe7d2 100644 --- a/basctl/source/basicide/basides1.cxx +++ b/basctl/source/basicide/basides1.cxx @@ -34,6 +34,7 @@ #include #define _SVSTDARR_STRINGS #include +#include #include #define _SOLAR__PRIVATE 1 @@ -57,6 +58,7 @@ #include #include #include +#include #include #include @@ -251,6 +253,22 @@ void BasicIDEShell::ExecuteCurrent( SfxRequest& rReq ) } } break; + case SID_GOTOLINE: + { + if ( pCurWin && pCurWin->IsA( TYPE( ModulWindow ) ) ) + { + std::auto_ptr< GotoLineDialog > xGotoDlg( new GotoLineDialog( pCurWin ) ); + if ( xGotoDlg->Execute() ) + { + rtl::OUString sText = xGotoDlg->GetText(); + + sal_Int32 nLine = xGotoDlg->GetLineNumber(); + + if ( nLine ) + ((ModulWindow*)pCurWin)->GetEditView()->SetSelection( TextSelection( TextPaM( nLine - 1 , 0 ), TextPaM( nLine - 1, 0 ) ) ); + } + } + } default: { pCurWin->ExecuteCommand( rReq ); @@ -1017,6 +1035,18 @@ void BasicIDEShell::GetState(SfxItemSet &rSet) rSet.DisableItem( nWh ); } break; + case SID_GOTOLINE: + { + // if this is not a module window hide the + // setting, doesn't make sense for example if the + // dialog editor is open + if( pCurWin && !pCurWin->IsA( TYPE( ModulWindow ) ) ) + { + rSet.DisableItem( nWh ); + rSet.Put(SfxVisibilityItem(nWh, sal_False)); + } + break; + } } } if ( pCurWin ) diff --git a/basctl/source/basicide/basidesh.src b/basctl/source/basicide/basidesh.src index 368bad4244de..c0ca7b413877 100644 --- a/basctl/source/basicide/basidesh.src +++ b/basctl/source/basicide/basidesh.src @@ -615,6 +615,10 @@ String RID_STR_DLGIMP_MISMATCH_TEXT Text [ en-US ] = "The dialog to be imported supports other languages than the target library.\n\nAdd these languages to the library to keep additional language resources provided by the dialog or omit them to stay with the current library languages.\n\nNote: For languages not supported by the dialog the resources of the dialog's default language will be used.\n " ; }; +String RID_STR_GETLINE +{ + Text [ en-US ] = "Goto Line"; +}; #define MN_EDIT 20 #define MN_VIEW 21 diff --git a/basctl/source/basicide/moduldl2.cxx b/basctl/source/basicide/moduldl2.cxx index 81413a838282..0e5b380bbf9c 100644 --- a/basctl/source/basicide/moduldl2.cxx +++ b/basctl/source/basicide/moduldl2.cxx @@ -439,6 +439,41 @@ NewObjectDialog::~NewObjectDialog() { } + +//---------------------------------------------------------------------------- +// GotoLineDialog +//---------------------------------------------------------------------------- + +GotoLineDialog::GotoLineDialog(Window * pParent ) + : ModalDialog( pParent, IDEResId( RID_DLG_GOTOLINE ) ), + aText( this, IDEResId( RID_FT_LINE ) ), + aEdit( this, IDEResId( RID_ED_LINE ) ), + aOKButton( this, IDEResId( RID_PB_OK ) ), + aCancelButton( this, IDEResId( RID_PB_CANCEL ) ) +{ + FreeResource(); + aEdit.GrabFocus(); + + SetText( String( IDEResId( RID_STR_GETLINE ) ) ); + aOKButton.SetClickHdl(LINK(this, GotoLineDialog, OkButtonHandler)); + +} + +sal_Int32 GotoLineDialog::GetLineNumber() +{ + return rtl::OUString( aEdit.GetText() ).toInt32(); +} + +IMPL_LINK(GotoLineDialog, OkButtonHandler, Button *, EMPTYARG) +{ + if ( GetLineNumber() ) + EndDialog(1); + else + aEdit.SetText( aEdit.GetText(), Selection(0, aEdit.GetText().Len() )); + return 0; +} + + //---------------------------------------------------------------------------- // ExportDialog //---------------------------------------------------------------------------- diff --git a/basctl/source/basicide/moduldlg.hxx b/basctl/source/basicide/moduldlg.hxx index b75e88a53d31..f61f64c60534 100644 --- a/basctl/source/basicide/moduldlg.hxx +++ b/basctl/source/basicide/moduldlg.hxx @@ -70,6 +70,18 @@ public: void SetObjectName( const String& rName ) { aEdit.SetText( rName ); aEdit.SetSelection( Selection( 0, rName.Len() ) );} }; +class GotoLineDialog : public ModalDialog +{ + FixedText aText; + Edit aEdit; + OKButton aOKButton; + CancelButton aCancelButton; + DECL_LINK(OkButtonHandler, Button *); +public: + GotoLineDialog( Window * pParent ); + sal_Int32 GetLineNumber(); +}; + class ExportDialog : public ModalDialog { private: diff --git a/basctl/source/basicide/moduldlg.src b/basctl/source/basicide/moduldlg.src index e2e6690581bc..fa80b0f8c44f 100644 --- a/basctl/source/basicide/moduldlg.src +++ b/basctl/source/basicide/moduldlg.src @@ -331,6 +331,44 @@ ModalDialog RID_DLG_LIBS Text [ en-US ] = "Replace existing libraries" ; }; }; + +ModalDialog RID_DLG_GOTOLINE +{ + HelpID = "basctl:ModalDialog:RID_DLG_GOTOLINE"; + OutputSize = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 160 , 55 ) ; + Moveable = TRUE ; + Closeable = TRUE ; + OKButton RID_PB_OK + { + Pos = MAP_APPFONT ( 104 , 6 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + DefButton = TRUE ; + }; + CancelButton RID_PB_CANCEL + { + Pos = MAP_APPFONT ( 104 , 23 ) ; + Size = MAP_APPFONT ( 50 , 14 ) ; + TabStop = TRUE ; + }; + FixedText RID_FT_LINE + { + Pos = MAP_APPFONT ( 6 , 6 ) ; + Size = MAP_APPFONT ( 96 , 10 ) ; + Text [ en-US ] = "~Line Number:" ; + }; + Edit RID_ED_LINE + { + HelpID = "basctl:Edit:RID_DLG_GOTOLINE:RID_ED_LINE"; + Border = TRUE ; + Pos = MAP_APPFONT ( 6 , 19 ) ; + Size = MAP_APPFONT ( 62 , 12 ) ; + TabStop = TRUE ; + }; +}; + ModalDialog RID_DLG_NEWLIB { HelpID = "basctl:ModalDialog:RID_DLG_NEWLIB"; diff --git a/basctl/uiconfig/basicide/menubar/menubar.xml b/basctl/uiconfig/basicide/menubar/menubar.xml index 4583ca294dc0..d9174bf9218c 100644 --- a/basctl/uiconfig/basicide/menubar/menubar.xml +++ b/basctl/uiconfig/basicide/menubar/menubar.xml @@ -48,6 +48,7 @@ + diff --git a/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu b/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu index fc6edaf0b7a5..507cf5c18a5f 100644 --- a/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu +++ b/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu @@ -198,6 +198,11 @@ .uno:ToggleBreakPointEnabled + + I10N SHORTCUTS - NO TRANSLATE + .uno:GotoLine + + diff --git a/officecfg/registry/data/org/openoffice/Office/UI/BasicIDECommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/BasicIDECommands.xcu index 675002857ab4..e512d3c537b0 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/BasicIDECommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/BasicIDECommands.xcu @@ -3,6 +3,11 @@ + + + Goto Line Number... + + diff --git a/sfx2/inc/sfx2/sfxsids.hrc b/sfx2/inc/sfx2/sfxsids.hrc index baf4b5615d3b..568b21b94c10 100755 --- a/sfx2/inc/sfx2/sfxsids.hrc +++ b/sfx2/inc/sfx2/sfxsids.hrc @@ -314,7 +314,8 @@ #define SID_SUGGESTEDSAVEASNAME (SID_SFX_START + 1721) #define SID_ENCRYPTIONDATA (SID_SFX_START + 1722) #define SID_PASSWORDINTERACTION (SID_SFX_START + 1723) -#define SID_SFX_free_START (SID_SFX_START + 1724) +#define SID_GOTOLINE (SID_SFX_START + 1724) +#define SID_SFX_free_START (SID_SFX_START + 1725) #define SID_SFX_free_END (SID_SFX_START + 3999) #define SID_OPEN_NEW_VIEW (SID_SFX_START + 520) diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index b5b432fa39db..b73f17a06a0b 100755 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -3619,6 +3619,30 @@ SfxVoidItem RunMacro SID_RUNMACRO GroupId = GID_MACRO; ] +SfxVoidItem GotoLine SID_GOTOLINE + +[ + /* flags: */ + AutoUpdate = TRUE, + Cachable = Cachable, + FastCall = FALSE, + HasCoreId = FALSE, + HasDialog = FALSE, + ReadOnlyDoc = TRUE, + Toggle = TRUE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + Synchron; + + /* config: */ + AccelConfig = TRUE, + MenuConfig = TRUE, + StatusBarConfig = FALSE, + ToolBoxConfig = TRUE, + GroupId = GID_MACRO; +] + //-------------------------------------------------------------------------- SfxVoidItem MacroDialog SID_BASICCHOOSER () -- cgit