diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2007-09-26 14:03:03 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2007-09-26 14:03:03 +0000 |
commit | 5f4307e8ea4f28220d07e5925e2845bde27f93c6 (patch) | |
tree | f321feae05052c867ab7462cd9750fa96545522d /svtools | |
parent | INTEGRATION: CWS vcl82 (1.27.26); FILE MERGED (diff) | |
download | core-5f4307e8ea4f28220d07e5925e2845bde27f93c6.tar.gz core-5f4307e8ea4f28220d07e5925e2845bde27f93c6.zip |
INTEGRATION: CWS vcl82 (1.55.44); FILE MERGED
2007/09/07 14:04:52 pl 1.55.44.2: #i81283# protext maStartDocPos against initialization problems
2007/08/06 14:13:07 pl 1.55.44.1: #i80073# #i73360# show warning if text is truncated due to maximum length
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/edit/textview.cxx | 51 |
1 files changed, 43 insertions, 8 deletions
diff --git a/svtools/source/edit/textview.cxx b/svtools/source/edit/textview.cxx index 1e47a5343e0f..77d45712010d 100644 --- a/svtools/source/edit/textview.cxx +++ b/svtools/source/edit/textview.cxx @@ -4,9 +4,9 @@ * * $RCSfile: textview.cxx,v $ * - * $Revision: 1.55 $ + * $Revision: 1.56 $ * - * last change: $Author: rt $ $Date: 2007-07-06 10:05:46 $ + * last change: $Author: hr $ $Date: 2007-09-26 15:03:03 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -117,6 +117,8 @@ #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp> #endif +#include <vcl/edit.hxx> + #include <sot/exchange.hxx> #include <sot/formats.hxx> @@ -1207,14 +1209,16 @@ void TextView::Paste( uno::Reference< datatransfer::clipboard::XClipboard >& rxC ::rtl::OUString aText; aData >>= aText; + bool bWasTruncated = ImplTruncateNewText( aText ); + String aStr( aText ); aStr.ConvertLineEnd( LINEEND_LF ); - if ( !mpImpl->mpTextEngine->GetMaxTextLen() || ImplCheckTextLen( aStr ) ) - { - InsertText( aText, FALSE ); - mpImpl->mpTextEngine->Broadcast( TextHint( TEXT_HINT_MODIFIED ) ); - } + InsertText( aText, FALSE ); + mpImpl->mpTextEngine->Broadcast( TextHint( TEXT_HINT_MODIFIED ) ); + + if( bWasTruncated ) + Edit::ShowTruncationWarning( mpImpl->mpWindow ); } catch( const ::com::sun::star::datatransfer::UnsupportedFlavorException& ) { @@ -1739,7 +1743,10 @@ void TextView::ImpShowCursor( BOOL bGotoCursor, BOOL bForceVisCursor, BOOL bSpec aEditCursor.Left() -= 1; - if ( bGotoCursor ) + if ( bGotoCursor + // #i81283# protext maStartDocPos against initialization problems + && aOutSz.Width() && aOutSz.Height() + ) { long nVisStartY = mpImpl->maStartDocPos.Y(); long nVisEndY = mpImpl->maStartDocPos.Y() + aOutSz.Height(); @@ -1939,6 +1946,34 @@ BOOL TextView::Write( SvStream& rOutput ) return mpImpl->mpTextEngine->Read( rOutput, &mpImpl->maSelection ); } +bool TextView::ImplTruncateNewText( rtl::OUString& rNewText ) const +{ + bool bTruncated = false; + + if( rNewText.getLength() > 65534 ) // limit to String API + { + rNewText = rNewText.copy( 0, 65534 ); + bTruncated = true; + } + + ULONG nMaxLen = mpImpl->mpTextEngine->GetMaxTextLen(); + ULONG nCurLen = mpImpl->mpTextEngine->GetTextLen(); + + sal_uInt32 nNewLen = rNewText.getLength(); + if ( nCurLen + nNewLen > nMaxLen ) + { + // see how much text will be replaced + ULONG nSelLen = mpImpl->mpTextEngine->GetTextLen( mpImpl->maSelection ); + if ( nCurLen + nNewLen - nSelLen > nMaxLen ) + { + sal_uInt32 nTruncatedLen = static_cast<sal_uInt32>(nMaxLen - (nCurLen - nSelLen)); + rNewText = rNewText.copy( 0, nTruncatedLen ); + bTruncated = true; + } + } + return bTruncated; +} + BOOL TextView::ImplCheckTextLen( const String& rNewText ) { BOOL bOK = TRUE; |