summaryrefslogtreecommitdiff
path: root/vcl/source/edit/textundo.cxx
diff options
context:
space:
mode:
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: */