summaryrefslogtreecommitdiff
path: root/vcl/source/edit/textundo.cxx
diff options
context:
space:
mode:
authorUray M. János <uray.janos@gmail.com>2012-08-30 10:18:14 +0200
committerAndras Timar <atimar@suse.com>2012-08-30 12:50:52 +0000
commit1191f4e432d3cb49662e6133411af3a2faf10a7a (patch)
tree3ea66c29bac661a2755376f8df8991b44e8b50fe /vcl/source/edit/textundo.cxx
parent9ec0a3ec629a05809852728482fdb3f3d997edef (diff)
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 <atimar@suse.com> Tested-by: Andras Timar <atimar@suse.com>
Diffstat (limited to 'vcl/source/edit/textundo.cxx')
-rw-r--r--vcl/source/edit/textundo.cxx104
1 files changed, 100 insertions, 4 deletions
diff --git a/vcl/source/edit/textundo.cxx b/vcl/source/edit/textundo.cxx
index 807abf232ad8..bc7f8585f389 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: */