Update of /cvsroot/cpptool/rfta/src/rftavc7addin
In directory sc8-pr-cvs1:/tmp/cvs-serv2227/src/rftavc7addin
Modified Files:
VC7TextDocument.cpp VC7TextDocument.h
Log Message:
* Made the interface of TextDocument simpler. It now has only 3 methods: getAllText(), getTextRange() and replaceTextRange().
Index: VC7TextDocument.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftavc7addin/VC7TextDocument.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** VC7TextDocument.cpp 15 May 2003 07:06:46 -0000 1.3
--- VC7TextDocument.cpp 16 May 2003 21:13:56 -0000 1.4
***************
*** 34,42 ****
! const std::string
! VC7TextDocument::getSelection() const
{
! if ( !startPoint_ || !endPoint_ )
! return "";
CComBSTR text;
--- 34,41 ----
! std::string
! VC7TextDocument::getTextRange( const Refactoring::SourceRange &range )
{
! setEditedRange( range );
CComBSTR text;
***************
*** 49,77 ****
void
! VC7TextDocument::replaceSelection( const std::string &text )
! {
! if ( startPoint_ && endPoint_ )
{
startPoint_->Delete( CComVariant( &*endPoint_) );
startPoint_->Insert( CComBSTR( text.c_str() ) );
}
- }
-
-
- Refactoring::SourceRange
- VC7TextDocument::getSelectionRange() const
- {
- if ( !startPoint_ || !endPoint_ )
- return Refactoring::SourceRange();
- long startIndex = 0;
- long endIndex = 0;
- startPoint_->get_AbsoluteCharOffset( &startIndex );
- endPoint_->get_AbsoluteCharOffset( &endIndex );
- return Refactoring::SourceRange( startIndex-1, endIndex-startIndex );
- }
void
! VC7TextDocument::setSelectionRange( const Refactoring::SourceRange &selection )
{
if ( !startPoint_ || !endPoint_ )
--- 48,63 ----
void
! VC7TextDocument::replaceTextRange( const Refactoring::SourceRange &range,
! const std::string &text )
{
+ setEditedRange( range );
+
startPoint_->Delete( CComVariant( &*endPoint_) );
startPoint_->Insert( CComBSTR( text.c_str() ) );
}
void
! VC7TextDocument::setEditedRange( const Refactoring::SourceRange &selection )
{
if ( !startPoint_ || !endPoint_ )
***************
*** 85,105 ****
startPoint_->MoveToAbsoluteOffset( selection.getStartIndex()+1 );
endPoint_->MoveToAbsoluteOffset( selection.getEndIndex()+1 );
- }
-
-
- std::string
- VC7TextDocument::getTextRange( const Refactoring::SourceRange &range )
- {
- setSelectionRange( range );
- return getSelection();
- }
-
-
- void
- VC7TextDocument::replaceTextRange( const Refactoring::SourceRange &range,
- const std::string &text )
- {
- setSelectionRange( range );
- return replaceSelection( text );
}
--- 71,74 ----
Index: VC7TextDocument.h
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftavc7addin/VC7TextDocument.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** VC7TextDocument.h 15 May 2003 07:06:46 -0000 1.3
--- VC7TextDocument.h 16 May 2003 21:13:56 -0000 1.4
***************
*** 14,42 ****
const std::string getAllText() const;
- /*! Gets the selected text.
- * \return Selected text. EOL are in the original text format.
- */
- const std::string getSelection() const;
-
- /*! Replace current selection text with the specified text.
- * \param text The selection is replaced with that text. If no
- * text is selected, then the specified text is
- * inserted at the selection location.
- */
- void replaceSelection( const std::string &text );
-
- /*! Gets the selected range.
- * \return The location range of the selection.
- * \warning Discard current selection.
- */
- Refactoring::SourceRange getSelectionRange() const;
-
- /*! Select a specified range of text.
- * Line and column are zero-based.
- * \param from Location the selection begins at.
- * \param to Location the selection ends (not included).
- */
- void setSelectionRange( const Refactoring::SourceRange &selection );
-
std::string getTextRange( const Refactoring::SourceRange &range );
--- 14,17 ----
***************
*** 45,48 ****
--- 20,25 ----
private:
+ void setEditedRange( const Refactoring::SourceRange &selection );
+
std::string stripCR( const std::string &text ) const;
|