diff options
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/AllLangResTarget_vcl.mk | 1 | ||||
-rw-r--r-- | vcl/source/edit/textund2.hxx | 15 | ||||
-rw-r--r-- | vcl/source/edit/textundo.cxx | 104 | ||||
-rw-r--r-- | vcl/source/edit/textundo.hrc | 28 | ||||
-rw-r--r-- | vcl/source/edit/textundo.hxx | 5 | ||||
-rw-r--r-- | vcl/source/edit/textundo.src | 41 | ||||
-rw-r--r-- | vcl/source/window/keycod.cxx | 4 |
7 files changed, 191 insertions, 7 deletions
diff --git a/vcl/AllLangResTarget_vcl.mk b/vcl/AllLangResTarget_vcl.mk index 6fd8c1ac3dec..b6c557bedfa0 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 c5ce90cc9e54..153e3db8c323 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 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: */ diff --git a/vcl/source/edit/textundo.hrc b/vcl/source/edit/textundo.hrc new file mode 100644 index 000000000000..3359de81cf87 --- /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 f86f87763097..be05af402355 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 000000000000..b48ed0bff478 --- /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 c831beac3ce7..5c22b82633ad 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 |