basctl/source/basicide/baside2b.cxx | 31 ++++------ vcl/AllLangResTarget_vcl.mk | 1 vcl/source/edit/textund2.hxx | 15 ++++- vcl/source/edit/textundo.cxx | 104 ++++++++++++++++++++++++++++++++++-- vcl/source/edit/textundo.hrc | 28 +++++++++ vcl/source/edit/textundo.hxx | 5 + vcl/source/edit/textundo.src | 41 ++++++++++++++ vcl/source/window/keycod.cxx | 4 - 8 files changed, 204 insertions(+), 25 deletions(-)
New commits: commit 1191f4e432d3cb49662e6133411af3a2faf10a7a Author: Uray M. János <uray.ja...@gmail.com> Date: Thu Aug 30 10:18:14 2012 +0200 Undo/Redo description+shortcut in Basic IDE This solves an issue about Edit > Redo in BasicIDE (Hungarian site): http://bug.openscope.org/browse/OOO-269 1. Redo should have a shortcut (Ctrl+Y), like in other parts of LibreOffice. (Undo has the usual Ctrl+Z.) 2. In the Edit menu, Undo and Redo should print something after the colon (what is to be undone, redone). This patch fixes both. Unfortunately the shortcut isn't shown in the menu (it's in vcl/source/window/keycod.cxx like Undo, and not in officecfg/registry/data/org/openoffice/Office/Accelerators.xcu). Change-Id: I2cfbfeb7d57309a27676e48943633cdb194288bc Reviewed-on: https://gerrit.libreoffice.org/514 Reviewed-by: Andras Timar <ati...@suse.com> Tested-by: Andras Timar <ati...@suse.com> diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index 41e31c7..a184d06 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -464,28 +464,23 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt ) if ( !bDone && ( !TextEngine::DoesKeyChangeText( rKEvt ) || ImpCanModify() ) ) { - if ( ( rKEvt.GetKeyCode().GetCode() == KEY_Y ) && rKEvt.GetKeyCode().IsMod1() ) - bDone = true; - else + if ( ( rKEvt.GetKeyCode().GetCode() == KEY_TAB ) && !rKEvt.GetKeyCode().IsMod1() && + !rKEvt.GetKeyCode().IsMod2() && !GetEditView()->IsReadOnly() ) { - if ( ( rKEvt.GetKeyCode().GetCode() == KEY_TAB ) && !rKEvt.GetKeyCode().IsMod1() && - !rKEvt.GetKeyCode().IsMod2() && !GetEditView()->IsReadOnly() ) + TextSelection aSel( pEditView->GetSelection() ); + if ( aSel.GetStart().GetPara() != aSel.GetEnd().GetPara() ) { - TextSelection aSel( pEditView->GetSelection() ); - if ( aSel.GetStart().GetPara() != aSel.GetEnd().GetPara() ) - { - bDelayHighlight = false; - if ( !rKEvt.GetKeyCode().IsShift() ) - pEditView->IndentBlock(); - else - pEditView->UnindentBlock(); - bDelayHighlight = true; - bDone = true; - } + bDelayHighlight = false; + if ( !rKEvt.GetKeyCode().IsShift() ) + pEditView->IndentBlock(); + else + pEditView->UnindentBlock(); + bDelayHighlight = true; + bDone = true; } - if ( !bDone ) - bDone = pEditView->KeyInput( rKEvt ); } + if ( !bDone ) + bDone = pEditView->KeyInput( rKEvt ); } if ( !bDone ) { diff --git a/vcl/AllLangResTarget_vcl.mk b/vcl/AllLangResTarget_vcl.mk index 6fd8c1a..b6c557b 100644 --- a/vcl/AllLangResTarget_vcl.mk +++ b/vcl/AllLangResTarget_vcl.mk @@ -54,6 +54,7 @@ $(eval $(call gb_SrsTarget_add_files,vcl/source/src,\ vcl/source/src/stdtext.src \ vcl/source/src/units.src \ vcl/source/src/fpicker.src \ + vcl/source/edit/textundo.src \ )) diff --git a/vcl/source/edit/textund2.hxx b/vcl/source/edit/textund2.hxx index c5ce90c..153e3db 100644 --- a/vcl/source/edit/textund2.hxx +++ b/vcl/source/edit/textund2.hxx @@ -19,7 +19,8 @@ #ifndef _TEXTUND2_HXX #define _TEXTUND2_HXX -#include <textundo.hxx> +#include "textundo.hxx" +#include <vcl/textdata.hxx> class TextUndoDelPara : public TextUndo @@ -36,6 +37,8 @@ public: virtual void Undo(); virtual void Redo(); + + virtual rtl::OUString GetComment () const; }; @@ -52,6 +55,8 @@ public: virtual void Undo(); virtual void Redo(); + + virtual rtl::OUString GetComment () const; }; @@ -68,6 +73,8 @@ public: virtual void Undo(); virtual void Redo(); + + virtual rtl::OUString GetComment () const; }; @@ -85,6 +92,8 @@ public: virtual void Redo(); virtual sal_Bool Merge( SfxUndoAction *pNextAction ); + + virtual rtl::OUString GetComment () const; }; @@ -100,6 +109,8 @@ public: virtual void Undo(); virtual void Redo(); + + virtual rtl::OUString GetComment () const; }; @@ -115,6 +126,8 @@ public: virtual void Undo(); virtual void Redo(); + + virtual rtl::OUString GetComment () const; }; #endif // _TEXTUND2_HXX diff --git a/vcl/source/edit/textundo.cxx b/vcl/source/edit/textundo.cxx index 807abf2..bc7f858 100644 --- a/vcl/source/edit/textundo.cxx +++ b/vcl/source/edit/textundo.cxx @@ -26,14 +26,17 @@ * ************************************************************************/ +#include "textundo.hxx" +#include "textund2.hxx" +#include "textundo.hrc" #include <vcl/texteng.hxx> #include <vcl/textview.hxx> -#include <textundo.hxx> -#include <textund2.hxx> #include <vcl/textdata.hxx> #include <textdoc.hxx> #include <textdat2.hxx> +#include <svdata.hxx> // ImplGetResMgr() +#include <tools/resid.hxx> TYPEINIT1( TextUndo, SfxUndoAction ); TYPEINIT1( TextUndoDelPara, TextUndo ); @@ -43,6 +46,39 @@ TYPEINIT1( TextUndoInsertChars, TextUndo ); TYPEINIT1( TextUndoRemoveChars, TextUndo ); +namespace +{ + +// Shorten() -- inserts ellipsis (...) in the middle of a long text +void Shorten (rtl::OUString& rString) +{ + unsigned nLen = rString.getLength(); + if (nLen > 48) + { + // If possible, we don't break a word, hence first we look for a space. + // Space before the ellipsis: + int iFirst = rString.lastIndexOf(' ', 32); + if (iFirst == -1 || unsigned(iFirst) < 16) + iFirst = 24; // not possible + // Space after the ellipsis: + int iLast = rString.indexOf(' ', nLen - 16); + if (iLast == -1 || unsigned(iLast) > nLen - 4) + iLast = nLen - 8; // not possible + // finally: + rString = + rString.copy(0, iFirst + 1) + + "..." + + rString.copy(iLast); + } +} + +} // namespace + +// +// TextUndoManager +// =============== +// + TextUndoManager::TextUndoManager( TextEngine* p ) { mpTextEngine = p; @@ -108,6 +144,11 @@ void TextUndoManager::UndoRedoEnd() } +// +// TextUndo +// ======== +// + TextUndo::TextUndo( TextEngine* p ) { mpTextEngine = p; @@ -129,6 +170,11 @@ void TextUndo::SetSelection( const TextSelection& rSel ) } +// +// TextUndoDelPara +// =============== +// + TextUndoDelPara::TextUndoDelPara( TextEngine* pTextEngine, TextNode* pNode, sal_uLong nPara ) : TextUndo( pTextEngine ) { @@ -177,9 +223,17 @@ void TextUndoDelPara::Redo() SetSelection( aPaM ); } -// ----------------------------------------------------------------------- +rtl::OUString TextUndoDelPara::GetComment () const +{ + return ResId(STR_TEXTUNDO_DELPARA, *ImplGetResMgr()); +} + + +// // TextUndoConnectParas -// ------------------------------------------------------------------------ +// ==================== +// + TextUndoConnectParas::TextUndoConnectParas( TextEngine* pTextEngine, sal_uLong nPara, sal_uInt16 nPos ) : TextUndo( pTextEngine ) { @@ -203,6 +257,16 @@ void TextUndoConnectParas::Redo() SetSelection( aPaM ); } +rtl::OUString TextUndoConnectParas::GetComment () const +{ + return ResId(STR_TEXTUNDO_CONNECTPARAS, *ImplGetResMgr()); +} + + +// +// TextUndoSplitPara +// ================= +// TextUndoSplitPara::TextUndoSplitPara( TextEngine* pTextEngine, sal_uLong nPara, sal_uInt16 nPos ) : TextUndo( pTextEngine ) @@ -227,6 +291,16 @@ void TextUndoSplitPara::Redo() SetSelection( aPaM ); } +rtl::OUString TextUndoSplitPara::GetComment () const +{ + return ResId(STR_TEXTUNDO_SPLITPARA, *ImplGetResMgr()); +} + + +// +// TextUndoInsertChars +// =================== +// TextUndoInsertChars::TextUndoInsertChars( TextEngine* pTextEngine, const TextPaM& rTextPaM, const XubString& rStr ) : TextUndo( pTextEngine ), @@ -269,6 +343,20 @@ sal_Bool TextUndoInsertChars::Merge( SfxUndoAction* pNextAction ) return sal_False; } +rtl::OUString TextUndoInsertChars::GetComment () const +{ + // multiple lines? + rtl::OUString sText(maText); + Shorten(sText); + return rtl::OUString(ResId(STR_TEXTUNDO_INSERTCHARS, *ImplGetResMgr())).replaceAll("$1", sText); +} + + + +// +// TextUndoRemoveChars +// =================== +// TextUndoRemoveChars::TextUndoRemoveChars( TextEngine* pTextEngine, const TextPaM& rTextPaM, const XubString& rStr ) : TextUndo( pTextEngine ), @@ -292,4 +380,12 @@ void TextUndoRemoveChars::Redo() SetSelection( aPaM ); } +rtl::OUString TextUndoRemoveChars::GetComment () const +{ + // multiple lines? + rtl::OUString sText(maText); + Shorten(sText); + return rtl::OUString(ResId(STR_TEXTUNDO_REMOVECHARS, *ImplGetResMgr())).replaceAll("$1", sText); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/edit/textundo.hrc b/vcl/source/edit/textundo.hrc new file mode 100644 index 0000000..3359de8 --- /dev/null +++ b/vcl/source/edit/textundo.hrc @@ -0,0 +1,28 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef VCL_TEXTUNDO_HRC +#define VCL_TEXTUNDO_HRC + +#define STR_TEXTUNDO_DELPARA 3000 +#define STR_TEXTUNDO_CONNECTPARAS 3001 +#define STR_TEXTUNDO_SPLITPARA 3002 +#define STR_TEXTUNDO_INSERTCHARS 3003 +#define STR_TEXTUNDO_REMOVECHARS 3004 + +#endif // VCL_TEXTUNDO_HRC diff --git a/vcl/source/edit/textundo.hxx b/vcl/source/edit/textundo.hxx index f86f877..be05af4 100644 --- a/vcl/source/edit/textundo.hxx +++ b/vcl/source/edit/textundo.hxx @@ -29,8 +29,13 @@ #define _TEXTUNDO_HXX #include <svl/undo.hxx> +#include <vcl/texteng.hxx> class TextEngine; +class TextView; +class TextSelection; +class TextDoc; +class TEParaPortions; class TextUndoManager : public SfxUndoManager { diff --git a/vcl/source/edit/textundo.src b/vcl/source/edit/textundo.src new file mode 100644 index 0000000..b48ed0b --- /dev/null +++ b/vcl/source/edit/textundo.src @@ -0,0 +1,41 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "textundo.hrc" + +String STR_TEXTUNDO_DELPARA +{ + Text [en-US] = "delete line"; +}; +String STR_TEXTUNDO_CONNECTPARAS +{ + Text [en-US] = "delete multiple lines"; +}; +String STR_TEXTUNDO_SPLITPARA +{ + Text [en-US] = "insert multiple lines"; +}; +String STR_TEXTUNDO_INSERTCHARS +{ + Text [en-US] = "insert '$1'"; +}; +String STR_TEXTUNDO_REMOVECHARS +{ + Text [en-US] = "delete '$1'"; +}; + diff --git a/vcl/source/window/keycod.cxx b/vcl/source/window/keycod.cxx index c831bea..5c22b82 100644 --- a/vcl/source/window/keycod.cxx +++ b/vcl/source/window/keycod.cxx @@ -44,7 +44,7 @@ static sal_uInt16 aImplKeyFuncTab[(KEYFUNC_FRONT+1)*4] = KEY_N | KEY_MOD1, 0, 0, 0, // KEYFUNC_NEW KEY_O | KEY_MOD1, KEY_OPEN, 0, 0, // KEYFUNC_OPEN KEY_S | KEY_MOD1, 0, 0, 0, // KEYFUNC_SAVE - 0, 0, 0, 0, // KEYFUNC_SAVEAS + KEY_S | KEY_SHIFT | KEY_MOD1, 0, 0, 0, // KEYFUNC_SAVEAS KEY_P | KEY_MOD1, 0, 0, 0, // KEYFUNC_PRINT KEY_W | KEY_MOD1, KEY_F4 | KEY_MOD1, 0, 0, // KEYFUNC_CLOSE KEY_Q | KEY_MOD1, KEY_F4 | KEY_MOD2, 0, 0, // KEYFUNC_QUIT @@ -52,7 +52,7 @@ static sal_uInt16 aImplKeyFuncTab[(KEYFUNC_FRONT+1)*4] = KEY_C | KEY_MOD1, KEY_INSERT | KEY_MOD1, KEY_COPY, 0, // KEYFUNC_COPY KEY_V | KEY_MOD1, KEY_INSERT | KEY_SHIFT, KEY_PASTE, 0, // KEYFUNC_PASTE KEY_Z | KEY_MOD1, KEY_BACKSPACE | KEY_MOD2, KEY_UNDO, 0, // KEYFUNC_UNDO - 0, 0, 0, 0, // KEYFUNC_REDO + KEY_Y | KEY_MOD1, KEY_UNDO | KEY_SHIFT, 0, 0, // KEYFUNC_REDO KEY_DELETE, 0, 0, 0, // KEYFUNC_DELETE KEY_REPEAT, 0, 0, 0, // KEYFUNC_REPEAT KEY_F | KEY_MOD1, KEY_FIND, 0, 0, // KEYFUNC_FIND
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits