basctl/sdi/baside.sdi | 5 basctl/source/basicide/basides1.cxx | 42 +++++++ basctl/source/basicide/linenumberwindow.cxx | 58 ++++++++++ basctl/source/basicide/linenumberwindow.hxx | 26 ++++ basctl/source/inc/basidesh.hxx | 1 basctl/uiconfig/basicide/menubar/menubar.xml | 1 officecfg/registry/data/org/openoffice/Office/UI/BasicIDECommands.xcu | 5 sfx2/inc/sfx2/sfxsids.hrc | 3 sfx2/sdi/sfx.sdi | 24 ++++ 9 files changed, 164 insertions(+), 1 deletion(-)
New commits: commit ea1ed6be3ec63e639db9e1ec310f9f923c1e132c Author: August Sodora <[email protected]> Date: Wed Nov 16 14:50:26 2011 -0500 Preparing to add option for line numbers in the basic ide diff --git a/basctl/sdi/baside.sdi b/basctl/sdi/baside.sdi index f40e239..d297663 100644 --- a/basctl/sdi/baside.sdi +++ b/basctl/sdi/baside.sdi @@ -39,6 +39,11 @@ shell BasicIDEShell // ======================================================== // Current, je nach aktuellem Fenster: // ======================================================== + SID_SHOWLINES + [ + StateMethod = GetState; + ExecMethod = ExecuteCurrent; + ] SID_BASICIDE_HIDECURPAGE [ ExecMethod = ExecuteCurrent; diff --git a/basctl/source/basicide/basides1.cxx b/basctl/source/basicide/basides1.cxx index 6a5cd13..c10ff6d 100644 --- a/basctl/source/basicide/basides1.cxx +++ b/basctl/source/basicide/basides1.cxx @@ -34,6 +34,7 @@ #include <basic/sbx.hxx> #define _SVSTDARR_STRINGS #include <svl/svstdarr.hxx> +#include <svl/visitem.hxx> #include <ide_pch.hxx> #define _SOLAR__PRIVATE 1 @@ -83,6 +84,19 @@ using namespace ::com::sun::star::frame; class SvxSearchItem; +// until we have some configuration lets just keep +// persist this value for the process lifetime +bool& lcl_GetSourceLinesEnabledValue() +{ + static bool bSourceLinesEnabled(false); + return bSourceLinesEnabled; +} + +bool BasicIDEShell::SourceLinesDisplayed() +{ + return lcl_GetSourceLinesEnabledValue(); +} + void BasicIDEShell::ExecuteCurrent( SfxRequest& rReq ) { if ( !pCurWin ) @@ -90,6 +104,20 @@ void BasicIDEShell::ExecuteCurrent( SfxRequest& rReq ) switch ( rReq.GetSlot() ) { + case SID_SHOWLINES: + { + SFX_REQUEST_ARG(rReq, pItem, SfxBoolItem, rReq.GetSlot(), sal_False); + bool bValue = false; + if ( pItem ) + bValue = pItem->GetValue(); + lcl_GetSourceLinesEnabledValue() = bValue; + if ( pCurWin && pCurWin->IsA( TYPE( ModulWindow ) ) ) + { +// (ModuleWindow*)(pCurWin)->SetLineNumberDisplay( bValue ); + } + } + break; + case SID_BASICIDE_HIDECURPAGE: { pCurWin->StoreData(); @@ -779,6 +807,20 @@ void BasicIDEShell::GetState(SfxItemSet &rSet) { switch ( nWh ) { + case SID_SHOWLINES: + { + // 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)); + } + else + rSet.Put( SfxBoolItem( nWh, lcl_GetSourceLinesEnabledValue() ) ); + break; + } case SID_DOCINFO: { rSet.DisableItem( nWh ); diff --git a/basctl/source/inc/basidesh.hxx b/basctl/source/inc/basidesh.hxx index 15fd8f2..9d66a6d 100644 --- a/basctl/source/inc/basidesh.hxx +++ b/basctl/source/inc/basidesh.hxx @@ -227,6 +227,7 @@ public: virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > GetCurrentDocument() const; + bool SourceLinesDisplayed(); }; diff --git a/basctl/uiconfig/basicide/menubar/menubar.xml b/basctl/uiconfig/basicide/menubar/menubar.xml index 4583ca2..fa99e98 100644 --- a/basctl/uiconfig/basicide/menubar/menubar.xml +++ b/basctl/uiconfig/basicide/menubar/menubar.xml @@ -48,6 +48,7 @@ <menu:menuitem menu:id=".uno:AvailableToolbars"/> <menu:menuitem menu:id=".uno:StatusBarVisible"/> <menu:menuitem menu:id=".uno:ShowImeStatusWindow"/> + <menu:menuitem menu:id=".uno:ShowLines"/> <menu:menuseparator/> <menu:menuitem menu:id=".uno:FullScreen"/> </menu:menupopup> diff --git a/officecfg/registry/data/org/openoffice/Office/UI/BasicIDECommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/BasicIDECommands.xcu index 6750028..c6e7aa2 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 @@ <oor:component-data oor:name="BasicIDECommands" oor:package="org.openoffice.Office.UI" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <node oor:name="UserInterface"> <node oor:name="Commands"> + <node oor:name=".uno:ShowLines" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Display Source Line Numbers</value> + </prop> + </node> </node> <node oor:name="Popups"> </node> diff --git a/sfx2/inc/sfx2/sfxsids.hrc b/sfx2/inc/sfx2/sfxsids.hrc index baf4b56..3a5e375 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_SHOWLINES (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 b5b432f..bd165e7 100755 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -3593,6 +3593,30 @@ SfxBoolItem ReccomendReadonly SID_RECOMMENDREADONLY GroupId = ; ] +//----------------------------------------------------FALSE +SfxBoolItem ShowLines SID_SHOWLINES + +[ + /* 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 RunMacro SID_RUNMACRO commit 2a44bd05b1f7bd36bec8b20c85d8fee6458c6c1b Author: August Sodora <[email protected]> Date: Wed Nov 16 14:48:49 2011 -0500 Added missing files diff --git a/basctl/source/basicide/linenumberwindow.cxx b/basctl/source/basicide/linenumberwindow.cxx new file mode 100644 index 0000000..5168da1 --- /dev/null +++ b/basctl/source/basicide/linenumberwindow.cxx @@ -0,0 +1,58 @@ +#include "baside2.hxx" +#include "linenumberwindow.hxx" + +#include <svtools/xtextedt.hxx> +#include <svtools/textview.hxx> + +LineNumberWindow::LineNumberWindow( Window* pParent, ModulWindow* pModulWin ) : + Window( pParent, WB_BORDER ), + pModulWindow(pModulWin), + nWidth(1) +{ + SetBackground(Wallpaper(GetSettings().GetStyleSettings().GetFieldColor())); +} + +LineNumberWindow::~LineNumberWindow() { } + +void LineNumberWindow::Paint( const Rectangle& ) +{ + ExtTextEngine* txtEngine = pModulWindow->GetEditEngine(); + if(!txtEngine) + return; + + TextView* txtView = pModulWindow->GetEditView(); + if(!txtView) + return; + + GetParent()->Resize(); + + ulong windowHeight = GetOutputSize().Height(); + ulong startY = txtView->GetStartDocPos().Y(); + ulong nLineHeight = GetTextHeight(); + + ulong nStartLine = startY / nLineHeight + 1; + ulong nEndLine = (startY + windowHeight) / nLineHeight + 1; + + if(txtEngine->GetParagraphCount() + 1 < nEndLine) + nEndLine = txtEngine->GetParagraphCount() + 1; + + nWidth = String::CreateFromInt64(nEndLine).Len() * 10; + + for(ulong i = nStartLine, y = 0; i < nEndLine; ++i, y += nLineHeight) + DrawText(Point(0, y), String::CreateFromInt64(i)); +} + +void LineNumberWindow::DataChanged(DataChangedEvent const & rDCEvt) +{ + Window::DataChanged(rDCEvt); + if (rDCEvt.GetType() == DATACHANGED_SETTINGS + && (rDCEvt.GetFlags() & SETTINGS_STYLE) != 0) + { + Color aColor(GetSettings().GetStyleSettings().GetFieldColor()); + if (aColor != rDCEvt.GetOldSettings()->GetStyleSettings().GetFieldColor()) + { + SetBackground(Wallpaper(aColor)); + Invalidate(); + } + } +} diff --git a/basctl/source/basicide/linenumberwindow.hxx b/basctl/source/basicide/linenumberwindow.hxx new file mode 100644 index 0000000..885ea14 --- /dev/null +++ b/basctl/source/basicide/linenumberwindow.hxx @@ -0,0 +1,26 @@ +#ifndef BASICIDE_LINENUMBERWINDOW_HXX +#define BASICIDE_LINENUMBERWINDOW_HXX + +#include <vcl/window.hxx> + +class ModulWindow; + +class LineNumberWindow : public Window +{ +private: + ModulWindow* pModulWindow; + ulong nWidth; + + virtual void DataChanged(DataChangedEvent const & rDCEvt); + +protected: + virtual void Paint( const Rectangle& ); + +public: + LineNumberWindow( Window* pParent, ModulWindow* pModulWin ); + ~LineNumberWindow(); + + ulong GetWidth() { return (nWidth < 20 ? 20 : nWidth); } +}; + +#endif // BASICIDE_LINENUMBERWINDOW_HXX _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
