Update of /cvsroot/cpptool/rfta/src/rftavc7addin
In directory sc8-pr-cvs1:/tmp/cvs-serv3871/src/rftavc7addin
Modified Files:
AddIn.rc Connect.cpp Connect.h Resource.h rftavc7addin.vcproj
stdafx.h
Added Files:
RenameLocaleVariableDialog.cpp RenameLocaleVariableDialog.h
RftaInlineLocalVarDialog.cpp RftaInlineLocalVarDialog.h
SplitLocaleVariableDialog.cpp SplitLocaleVariableDialog.h
TextDocumentHelper.cpp TextDocumentHelper.h
TextSelectionHelper.cpp TextSelectionHelper.h
VC7TextDocument.cpp VC7TextDocument.h
Log Message:
* started implementing wrapper for VC7 object model. TextSelection seems to be working. Still need to test VC7TextDocument.
--- NEW FILE: RenameLocaleVariableDialog.cpp ---
// RenameLocaleVariableDialog.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "RenameLocaleVariableDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// RenameLocaleVariableDialog dialog
RenameLocaleVariableDialog::RenameLocaleVariableDialog(CWnd* pParent /*=NULL*/)
: CDialog(RenameLocaleVariableDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(RenameLocaleVariableDialog)
oldName_ = _T("");
newName_ = _T("");
//}}AFX_DATA_INIT
}
void RenameLocaleVariableDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(RenameLocaleVariableDialog)
DDX_Text(pDX, IDC_OLD_NAME, oldName_);
DDX_Text(pDX, IDC_NEW_NAME, newName_);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(RenameLocaleVariableDialog, CDialog)
//{{AFX_MSG_MAP(RenameLocaleVariableDialog)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// RenameLocaleVariableDialog message handlers
--- NEW FILE: RenameLocaleVariableDialog.h ---
#if !defined(AFX_RENAMELOCALEVARIABLEDIALOG_H__A77A8155_05B0_450B_9928_F2EE5FF040D9__INCLUDED_)
#define AFX_RENAMELOCALEVARIABLEDIALOG_H__A77A8155_05B0_450B_9928_F2EE5FF040D9__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// RenameLocaleVariableDialog.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// RenameLocaleVariableDialog dialog
class RenameLocaleVariableDialog : public CDialog
{
// Construction
public:
RenameLocaleVariableDialog(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(RenameLocaleVariableDialog)
enum { IDD = IDD_RENAME_LOCALE_VARIABLE };
CString oldName_;
CString newName_;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(RenameLocaleVariableDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(RenameLocaleVariableDialog)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_RENAMELOCALEVARIABLEDIALOG_H__A77A8155_05B0_450B_9928_F2EE5FF040D9__INCLUDED_)
--- NEW FILE: RftaInlineLocalVarDialog.cpp ---
// RftaInlineLocalVarDialog.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "RftaInlineLocalVarDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// RftaInlineLocalVarDialog dialog
RftaInlineLocalVarDialog::RftaInlineLocalVarDialog(CWnd* pParent /*=NULL*/)
: CDialog(RftaInlineLocalVarDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(RftaInlineLocalVarDialog)
m_VariableName = _T("");
m_AddBraces = FALSE;
//}}AFX_DATA_INIT
}
void RftaInlineLocalVarDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(RftaInlineLocalVarDialog)
DDX_Text(pDX, IDC_OLD_NAME, m_VariableName);
DDX_Check(pDX, IDC_CHECK1, m_AddBraces);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(RftaInlineLocalVarDialog, CDialog)
//{{AFX_MSG_MAP(RftaInlineLocalVarDialog)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// RftaInlineLocalVarDialog message handlers
--- NEW FILE: RftaInlineLocalVarDialog.h ---
#if !defined(AFX_RFTAINLINELOCALVARDIALOG_H__529FC0DC_6793_483D_B8D5_55D22A5AF808__INCLUDED_)
#define AFX_RFTAINLINELOCALVARDIALOG_H__529FC0DC_6793_483D_B8D5_55D22A5AF808__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// RftaInlineLocalVarDialog.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// RftaInlineLocalVarDialog dialog
class RftaInlineLocalVarDialog : public CDialog
{
// Construction
public:
RftaInlineLocalVarDialog(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(RftaInlineLocalVarDialog)
enum { IDD = IDD_INLINE_LOCAL_VARIABLE };
CString m_VariableName;
BOOL m_AddBraces;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(RftaInlineLocalVarDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(RftaInlineLocalVarDialog)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_RFTAINLINELOCALVARDIALOG_H__529FC0DC_6793_483D_B8D5_55D22A5AF808__INCLUDED_)
--- NEW FILE: SplitLocaleVariableDialog.cpp ---
// SplitLocaleVariableDialog.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "SplitLocaleVariableDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// SplitLocaleVariableDialog dialog
SplitLocaleVariableDialog::SplitLocaleVariableDialog(CWnd* pParent /*=NULL*/)
: CDialog(SplitLocaleVariableDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(SplitLocaleVariableDialog)
m_NewVariableName = _T("");
//}}AFX_DATA_INIT
}
void SplitLocaleVariableDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(SplitLocaleVariableDialog)
DDX_Text(pDX, IDC_NEW_NAME, m_NewVariableName);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(SplitLocaleVariableDialog, CDialog)
//{{AFX_MSG_MAP(SplitLocaleVariableDialog)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// SplitLocaleVariableDialog message handlers
--- NEW FILE: SplitLocaleVariableDialog.h ---
#if !defined(AFX_SPLITLOCALEVARIABLEDIALOG_H__3CE35443_0DDD_40CB_A445_ED1B50A946FA__INCLUDED_)
#define AFX_SPLITLOCALEVARIABLEDIALOG_H__3CE35443_0DDD_40CB_A445_ED1B50A946FA__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// SplitLocaleVariableDialog.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// SplitLocaleVariableDialog dialog
class SplitLocaleVariableDialog : public CDialog
{
// Construction
public:
SplitLocaleVariableDialog(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(SplitLocaleVariableDialog)
enum { IDD = IDD_SPLIT_LOCAL_VAR };
CString m_NewVariableName;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(SplitLocaleVariableDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(SplitLocaleVariableDialog)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_SPLITLOCALEVARIABLEDIALOG_H__3CE35443_0DDD_40CB_A445_ED1B50A946FA__INCLUDED_)
--- NEW FILE: TextDocumentHelper.cpp ---
// //////////////////////////////////////////////////////////////////////////
// Implementation file ./TextDocumentHelper.cpp for class TextDocumentHelper
// (c)Copyright 2000, Baptiste Lepilleur.
// Created: 2001/10/14
// //////////////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "TextDocumentHelper.h"
#include "TextSelectionHelper.h"
TextDocumentHelper::TextDocumentHelper( CComPtr<EnvDTE::TextDocument> document ) :
_document( document )
{
}
TextDocumentHelper::~TextDocumentHelper()
{
}
bool
TextDocumentHelper::isValid() const
{
return !!_document;
}
TextSelectionHelper
TextDocumentHelper::selection() const
{
CComPtr<EnvDTE::TextSelection> selectionInterface;
_document->get_Selection( &selectionInterface );
return TextSelectionHelper( selectionInterface );
}
void
TextDocumentHelper::discardingClose()
{
CComPtr<EnvDTE::Document> document;
_document->get_Parent( &document );
document->Close( EnvDTE::vsSaveChangesNo );
}
int
TextDocumentHelper::getTabSize() const
{
long tabSize;
_document->get_TabSize( &tabSize );
return tabSize;
}
/*
bool
TextDocumentHelper::redo() const
{
VARIANT_BOOL success;
_document->Redo( &success );
return success != 0;
}
bool
TextDocumentHelper::undo() const
{
VARIANT_BOOL success;
_document->Undo( &success );
return success != 0;
}
*/
--- NEW FILE: TextDocumentHelper.h ---
// //////////////////////////////////////////////////////////////////////////
// Header file ./TextDocumentHelper.h for class TextDocumentHelper
// (c)Copyright 2000, Baptiste Lepilleur.
// Created: 2001/10/14
// //////////////////////////////////////////////////////////////////////////
#ifndef RFTAVC7ADDIN_TEXTDOCUMENTHELPER_H_INCLUDED
#define RFTAVC7ADDIN_TEXTDOCUMENTHELPER_H_INCLUDED
class TextSelectionHelper;
/*! \class TextDocumentHelper
* \brief This class represents an helper to use ITextDocument.
*/
class TextDocumentHelper
{
public:
/*! Constructs a TextDocumentHelper object.
*/
TextDocumentHelper( CComPtr<EnvDTE::TextDocument> document );
/// Destructor.
virtual ~TextDocumentHelper();
bool isValid() const;
TextSelectionHelper selection() const;
// EditPointHelper createEditPoint() const;
void discardingClose();
int getTabSize() const;
/*
bool undo() const;
bool redo() const;
*/
private:
CComPtr<EnvDTE::TextDocument> _document;
};
#endif // RFTAVC7ADDIN_TEXTDOCUMENTHELPER_H_INCLUDED
--- NEW FILE: TextSelectionHelper.cpp ---
// //////////////////////////////////////////////////////////////////////////
// Implementation file ./TextSelectionHelper.cpp for class TextSelectionHelper
// (c)Copyright 2000, Baptiste Lepilleur.
// Created: 2001/10/14
// //////////////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "AddIn.h"
#include "TextSelectionHelper.h"
TextSelectionHelper::TextSelectionHelper( CComPtr<EnvDTE::TextSelection> selectionInterface )
: _selection( selectionInterface )
{
}
TextSelectionHelper::~TextSelectionHelper()
{
}
bool
TextSelectionHelper::isValid()
{
return !!_selection;
}
int
TextSelectionHelper::currentColumn()
{
long column;
_selection->get_CurrentColumn( &column );
return column;
}
int
TextSelectionHelper::currentLine()
{
long line;
_selection->get_CurrentLine( &line );
return line;
}
int
TextSelectionHelper::selectionTopLine()
{
long beginLine;
_selection->get_TopLine( &beginLine );
return beginLine;
}
int
TextSelectionHelper::selectionBottomLine()
{
long endLine;
_selection->get_BottomLine( &endLine );
return endLine;
}
CString
TextSelectionHelper::text()
{
CComBSTR text;
_selection->get_Text( &text );
CString toNormalize( text );
return toNormalize;
/*
CString normalized;
for ( int index = 0; index < toNormalize.GetLength(); ++index )
{
if ( toNormalize.GetAt( index ) != '\r' )
normalized += toNormalize.GetAt( index );
}
return normalized;
*/
}
void
TextSelectionHelper::setText( const CString &newText )
{
/*
CString normalizedText;
for ( int index =0; index < newText.GetLength(); ++index )
{
if ( newText.GetAt( index ) == '\n' )
normalizedText += '\r';
normalizedText += newText.GetAt( index );
}
CComBSTR unicodeText( normalizedText );
*/
CComBSTR unicodeText( newText );
// if ( newText.GetLength() > 0 )
// _selection->Delete( CComVariant(1) );
_selection->put_Text( unicodeText );
}
void
TextSelectionHelper::selectAll()
{
_selection->SelectAll();
}
void
TextSelectionHelper::cancelSelection()
{
_selection->Cancel();
}
/*
void
TextSelectionHelper::goToLine( int lineNumber,
bool selectLine )
{
_selection->GoToLine( lineNumber, selectLine ? CComVariant(1) :
CComVariant(0) );
}
void
TextSelectionHelper::moveTo( int lineNumber,
int columnNumber,
bool extendSelection )
{
_selection->MoveTo( lineNumber,
columnNumber,
CComVariant(extendSelection ? dsExtend : dsMove) );
}
*/
int
TextSelectionHelper::selectionStartCharOffset()
{
CComPtr<EnvDTE::VirtualPoint> point;
_selection->get_TopPoint( &point );
long startIndex = -1;
point->get_AbsoluteCharOffset( &startIndex );
return startIndex -1;
}
int
TextSelectionHelper::selectionEndCharOffset()
{
/*
{
CComPtr<EnvDTE::VirtualPoint> point;
CComPtr<EnvDTE::VirtualPoint> point1;
CComPtr<EnvDTE::VirtualPoint> point2;
CComPtr<EnvDTE::VirtualPoint> point3;
long bottom;
long active;
long anchor;
long top;
_selection->get_BottomPoint( &point );
point->get_AbsoluteCharOffset( &bottom );
_selection->get_ActivePoint( &point1 );
point1->get_AbsoluteCharOffset( &active );
_selection->get_AnchorPoint( &point2 );
point2->get_AbsoluteCharOffset( &anchor );
_selection->get_TopPoint( &point3 );
point3->get_AbsoluteCharOffset( &top );
}
*/
CComPtr<EnvDTE::VirtualPoint> point;
_selection->get_BottomPoint( &point );
long endIndex = -1;
point->get_AbsoluteCharOffset( &endIndex );
return endIndex -1;
}
--- NEW FILE: TextSelectionHelper.h ---
// //////////////////////////////////////////////////////////////////////////
// Header file ./TextSelectionHelper.h for class TextSelectionHelper
// (c)Copyright 2000, Baptiste Lepilleur.
// Created: 2001/10/14
// //////////////////////////////////////////////////////////////////////////
#ifndef RFTAVC7ADDIN__TEXTSELECTIONHELPER_H_INCLUDED
#define RFTAVC7ADDIN__TEXTSELECTIONHELPER_H_INCLUDED
/*! \class TextSelectionHelper
* \brief This class represents a helper to use ITextSelection.
*/
class TextSelectionHelper
{
public:
TextSelectionHelper( CComPtr<EnvDTE::TextSelection> selectionInterface );
/// Destructor.
virtual ~TextSelectionHelper();
bool isValid();
// End of selection column
int currentColumn();
// End of selection line
int currentLine();
// Start of selection line.
int selectionTopLine();
// End of selection line.
int selectionBottomLine();
/*! Returns selected text.
* Returns selected text as contains in the file. \r\n for EOL of
* DOS file, \n for EOL of Unix file, and \r for EOL of Mac file.
*/
CString text();
void setText( const CString &text );
void selectAll();
void cancelSelection();
/*
void goToLine( int lineNumber,
bool selectLine = true );
void moveTo( int lineNumber,
int columnNumber,
bool extendSelection =false );
*/
/// zero based index
int selectionStartCharOffset();
/// zero based index
int selectionEndCharOffset();
private:
CComPtr<EnvDTE::TextSelection> _selection;
};
// Inlines methods for TextSelectionHelper:
// ----------------------------------------
#endif // RFTAVC7ADDIN__TEXTSELECTIONHELPER_H_INCLUDED
--- NEW FILE: VC7TextDocument.cpp ---
#include "StdAfx.h"
#include "vc7textdocument.h"
VC7TextDocument::VC7TextDocument( CComPtr<EnvDTE::TextDocument> document )
: document_( document )
{
}
VC7TextDocument::~VC7TextDocument()
{
}
const std::string
VC7TextDocument::getAllText() const
{
CComPtr<EnvDTE::TextPoint> startPoint;
document_->get_StartPoint( &startPoint );
CComPtr<EnvDTE::TextPoint> endPoint;
document_->get_EndPoint( &endPoint );
CComPtr<EnvDTE::EditPoint> editPoint;
startPoint->CreateEditPoint( &editPoint );
CComBSTR text;
editPoint->GetText( CComVariant( &*endPoint), &text );
CString ctext( text );
return std::string( ctext );
}
const std::string
VC7TextDocument::getSelection() const
{
if ( !startPoint_ || !endPoint_ )
return "";
CComBSTR text;
startPoint_->GetText( CComVariant( &*endPoint_), &text );
CString ctext( text );
return std::string( ctext );
}
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, endIndex );
}
void
VC7TextDocument::setSelectionRange( const Refactoring::SourceRange &selection )
{
if ( !startPoint_ || !endPoint_ )
{
CComPtr<EnvDTE::TextPoint> textPoint;
document_->get_StartPoint( &textPoint );
textPoint->CreateEditPoint( &startPoint_ );
textPoint->CreateEditPoint( &endPoint_ );
}
startPoint_->MoveToAbsoluteOffset( selection.getStartIndex() );
startPoint_->MoveToAbsoluteOffset( selection.getEndIndex() );
}
--- NEW FILE: VC7TextDocument.h ---
#ifndef RFTAVC7ADDIN_VC7TEXTDOCUMENT_H_INCLUDED
#define RFTAVC7ADDIN_VC7TEXTDOCUMENT_H_INCLUDED
#include <rfta/refactoring/TextDocument.h>
class VC7TextDocument : public Refactoring::TextDocument
{
public:
VC7TextDocument( CComPtr<EnvDTE::TextDocument> document );
~VC7TextDocument();
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 );
private:
CComPtr<EnvDTE::TextDocument> document_;
CComPtr<EnvDTE::EditPoint> startPoint_;
CComPtr<EnvDTE::EditPoint> endPoint_;
};
#endif RFTAVC7ADDIN_VC7TEXTDOCUMENT_H_INCLUDED
Index: AddIn.rc
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftavc7addin/AddIn.rc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** AddIn.rc 11 May 2003 17:53:09 -0000 1.1
--- AddIn.rc 14 May 2003 18:55:50 -0000 1.2
***************
*** 14,17 ****
--- 14,137 ----
/////////////////////////////////////////////////////////////////////////////
+ // Neutral resources
+
+ #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
+ #ifdef _WIN32
+ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
+ #pragma code_page(1252)
+ #endif //_WIN32
+
+ /////////////////////////////////////////////////////////////////////////////
+ //
+ // Dialog
+ //
+
+ IDD_SPLIT_LOCAL_VAR DIALOG 0, 0, 215, 50
+ STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+ CAPTION "Split Temporary: Enter name of new variable"
+ FONT 8, "MS Sans Serif"
+ BEGIN
+ DEFPUSHBUTTON "OK",IDOK,36,29,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,127,29,50,14
+ LTEXT "New name:",IDC_STATIC,7,10,37,8
+ EDITTEXT IDC_NEW_NAME,46,8,162,12,ES_AUTOHSCROLL
+ END
+
+ IDD_RENAME_LOCALE_VARIABLE DIALOG 0, 0, 248, 57
+ STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+ CAPTION "Rename locale variable refactoring"
+ FONT 8, "MS Sans Serif"
+ BEGIN
+ LTEXT "Old name:",IDC_STATIC,7,7,33,8
+ LTEXT "Static",IDC_OLD_NAME,48,7,193,8
+ LTEXT "New name:",IDC_STATIC,7,21,37,8
+ EDITTEXT IDC_NEW_NAME,46,17,195,12,ES_AUTOHSCROLL
+ DEFPUSHBUTTON "OK",IDOK,65,35,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,129,35,50,14
+ END
+
+
+ /////////////////////////////////////////////////////////////////////////////
+ //
+ // DESIGNINFO
+ //
+
+ #ifdef APSTUDIO_INVOKED
+ GUIDELINES DESIGNINFO
+ BEGIN
+ IDD_SPLIT_LOCAL_VAR, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 208
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 43
+ END
+
+ IDD_RENAME_LOCALE_VARIABLE, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 241
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 50
+ END
+ END
+ #endif // APSTUDIO_INVOKED
+
+ #endif // Neutral resources
+ /////////////////////////////////////////////////////////////////////////////
+
+
+ /////////////////////////////////////////////////////////////////////////////
+ // Neutral (Default) resources
+
+ #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEUD)
+ #ifdef _WIN32
+ LANGUAGE LANG_NEUTRAL, SUBLANG_DEFAULT
+ #pragma code_page(1252)
+ #endif //_WIN32
+
+ /////////////////////////////////////////////////////////////////////////////
+ //
+ // Dialog
+ //
+
+ IDD_INLINE_LOCAL_VARIABLE DIALOG 0, 0, 315, 53
+ STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+ CAPTION "Dialog"
+ FONT 8, "MS Sans Serif"
+ BEGIN
+ DEFPUSHBUTTON "OK",IDOK,258,5,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,258,24,50,14
+ LTEXT "Variable that will be inlined:",IDC_STATIC,7,5,86,8
+ LTEXT "Static",IDC_OLD_NAME,96,5,145,8
+ CONTROL "Arrange braces arround inlined value:",IDC_CHECK1,
+ "Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,7,16,
+ 133,10
+ END
+
+
+ /////////////////////////////////////////////////////////////////////////////
+ //
+ // DESIGNINFO
+ //
+
+ #ifdef APSTUDIO_INVOKED
+ GUIDELINES DESIGNINFO
+ BEGIN
+ IDD_INLINE_LOCAL_VARIABLE, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 308
+ TOPMARGIN, 5
+ BOTTOMMARGIN, 46
+ END
+ END
+ #endif // APSTUDIO_INVOKED
+
+ #endif // Neutral (Default) resources
+ /////////////////////////////////////////////////////////////////////////////
+
+
+ /////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
Index: Connect.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftavc7addin/Connect.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Connect.cpp 12 May 2003 07:21:44 -0000 1.2
--- Connect.cpp 14 May 2003 18:55:50 -0000 1.3
***************
*** 3,6 ****
--- 3,9 ----
#include "AddIn.h"
#include "Connect.h"
+ #include "RenameLocaleVariableDialog.h"
+ #include "TextSelectionHelper.h"
+ #include "VC7TextDocument.h"
extern CAddInModule _AtlModule;
***************
*** 13,45 ****
// you will need to re-register the Add-in by building the MyAddin21Setup project
// by right clicking the project in the Solution Explorer, then choosing install.
- /*
- CComBSTR("rftavc7addin"),
- CComBSTR("rftavc7addin"),
- CComBSTR("Executes the command for rftavc7addin"),
- VARIANT_TRUE,
- 59,
- NULL,
- EnvDTE::vsCommandStatusSupported+EnvDTE::vsCommandStatusEnabled,
- &pCreatedCommand)) && (pCreatedCommand))
-
- class NamedCommand
- {
- public:
-
- CComPtr<EnvDTE::Command> add( const CComPtr<EnvDTE::AddIn> &addIn )
- {
- CComPtr<EnvDTE::Command> command;
- HRESULT hr =
- }
-
- CComBSTR name_;
- CComBSTR buttonText_;
- CComBSTR toolTip_;
- VARIANT_BOOL msOfficeButton_;
- long bitmapId_;
- bool disableFlags_;
- };
- */
-
#include <stdexcept>
--- 16,19 ----
***************
*** 351,369 ****
*pvbHandled = VARIANT_FALSE;
! if(ExecuteOption == EnvDTE::vsCommandExecOptionDoDefault)
! {
! CComBSTR commandName = bstrCmdName;
! AfxMessageBox( "Hello from MFC: " + CString(commandName) );
! // ::MessageBoxW( 0, commandName, commandName, MB_OK );
! *pvbHandled = VARIANT_TRUE;
! //if(!_wcsicmp(bstrCmdName, L"RFTA.RenameLocaleVariable"))
! //{
! // *pvbHandled = VARIANT_TRUE;
! // return S_OK;
! //}
! }
return S_OK;
! }
\ No newline at end of file
--- 325,403 ----
*pvbHandled = VARIANT_FALSE;
! if ( ExecuteOption != EnvDTE::vsCommandExecOptionDoDefault )
! return S_OK;
! // _asm int 3;
! CComPtr<EnvDTE::Document> activeDocument;
! m_pDTE->get_ActiveDocument( &activeDocument );
! if ( !activeDocument )
! return S_OK;
! CComPtr<IDispatch> textDocumentBase;
! activeDocument->Object( CComBSTR(L"TextDocument"), &textDocumentBase );
! CComQIPtr<EnvDTE::TextDocument> textDocument = textDocumentBase;
! if ( !textDocument )
! return S_OK;
!
! CComPtr<EnvDTE::TextSelection> selection;
! textDocument->get_Selection( &selection );
! TextSelectionHelper selectionHelper( selection );
! int selectionStart = selectionHelper.selectionStartCharOffset();
! int selectionEnd = selectionHelper.selectionEndCharOffset();
! if ( selectionEnd < selectionStart )
! selectionEnd = selectionStart;
! Refactoring::SourceRange selectedRange( selectionStart, selectionEnd - selectionStart );
! VC7TextDocument document( textDocument );
!
! CComBSTR commandName = bstrCmdName;
! if ( commandName == L"RFTA.RenameLocaleVariable" )
! applyRenameLocaleVariable( document, selectedRange );
! else if ( commandName == L"RFTA.InlineLocaleVariable" )
! applyInlineLocaleVariable( document, selectedRange );
! else if ( commandName == L"RFTA.SplitLocaleVariable" )
! applySplitLocaleVariable( document, selectedRange );
! else if ( commandName == L"RFTA.ReduceLocaleVariableScope" )
! applyReduceLocaleVariableScope( document, selectedRange );
!
! *pvbHandled = VARIANT_TRUE;
return S_OK;
! }
!
! void
! CConnect::applyRenameLocaleVariable( VC7TextDocument &document,
! const Refactoring::SourceRange &selectedRange )
! {
! AfxMessageBox( "11Selected range: " + CString(selectedRange.toString().c_str() ) );
! /*
! RenameLocaleVariableDialog dialog;
! dialog.oldName_ = "OldVariableName";
! dialog.newName_ = "NewVariableName";
!
! if ( dialog.DoModal() == IDOK )
! dialog.newName_;
! */
!
! }
!
! void
! CConnect::applyInlineLocaleVariable( VC7TextDocument &document,
! const Refactoring::SourceRange &selectedRange )
! {
! AfxMessageBox( "Selected range: " + CString(selectedRange.toString().c_str() ) );
! }
!
! void
! CConnect::applySplitLocaleVariable( VC7TextDocument &document,
! const Refactoring::SourceRange &selectedRange )
! {
! AfxMessageBox( "Selected range: " + CString(selectedRange.toString().c_str() ) );
! }
!
! void
! CConnect::applyReduceLocaleVariableScope( VC7TextDocument &document,
! const Refactoring::SourceRange &selectedRange )
! {
! AfxMessageBox( "Selected range: " + CString(selectedRange.toString().c_str() ) );
! }
!
Index: Connect.h
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftavc7addin/Connect.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Connect.h 11 May 2003 21:45:09 -0000 1.2
--- Connect.h 14 May 2003 18:55:50 -0000 1.3
***************
*** 4,11 ****
#include "resource.h" // main symbols
! #pragma warning( disable : 4278 )
! //The following #import imports DTE based on it's LIBID
! #import "libid:80cc9f66-e7d8-4ddd-85b6-d9e6cd0e93e2" version("7.0") lcid("0") raw_interfaces_only named_guids
! #pragma warning( default : 4278 )
// CConnect
--- 4,10 ----
#include "resource.h" // main symbols
! #include <rfta/parser/SourceRange.h>
!
! class VC7TextDocument;
// CConnect
***************
*** 91,94 ****
--- 90,105 ----
const CComPtr<Office::CommandBar> &pMenuBar,
int index );
+
+ void applyRenameLocaleVariable( VC7TextDocument &document,
+ const Refactoring::SourceRange &selectedRange );
+
+ void applyInlineLocaleVariable( VC7TextDocument &document,
+ const Refactoring::SourceRange &selectedRange );
+
+ void applySplitLocaleVariable( VC7TextDocument &document,
+ const Refactoring::SourceRange &selectedRange );
+
+ void applyReduceLocaleVariableScope( VC7TextDocument &document,
+ const Refactoring::SourceRange &selectedRange );
};
Index: Resource.h
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftavc7addin/Resource.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Resource.h 11 May 2003 17:53:09 -0000 1.1
--- Resource.h 14 May 2003 18:55:50 -0000 1.2
***************
*** 6,9 ****
--- 6,12 ----
#define IDR_ADDIN 101
#define IDR_CONNECT 102
+ #define IDD_RENAME_LOCALE_VARIABLE 130
+ #define IDD_INLINE_LOCAL_VARIABLE 132
+ #define IDD_SPLIT_LOCAL_VAR 137
#define IDB_RENAMELOCALEVARIABLE 201
#define IDB_INLINELOCALEVARIABLE 202
***************
*** 11,14 ****
--- 14,20 ----
#define IDB_INLINELOCALEVARIABLE1 204
#define IDB_REDUCELOCALEVARIABLESCOPE 204
+ #define IDC_NEW_NAME 1000
+ #define IDC_OLD_NAME 1001
+ #define IDC_CHECK1 1002
// Next default values for new objects
Index: rftavc7addin.vcproj
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftavc7addin/rftavc7addin.vcproj,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** rftavc7addin.vcproj 11 May 2003 17:53:09 -0000 1.1
--- rftavc7addin.vcproj 14 May 2003 18:55:50 -0000 1.2
***************
*** 23,26 ****
--- 23,27 ----
Name="VCCLCompilerTool"
Optimization="0"
+ AdditionalIncludeDirectories="../../deplib/boost-compatibility,../../include,../../deplib/cppunit/include,../../deplib/boostcvs"
PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG;_USRDLL"
MinimalRebuild="TRUE"
***************
*** 39,42 ****
--- 40,44 ----
OutputFile="$(OutDir)/$(ProjectName).dll"
LinkIncremental="2"
+ AdditionalLibraryDirectories="../../deplib/cppunit/lib,../../lib"
ModuleDefinitionFile=".\AddIn.def"
GenerateDebugInformation="TRUE"
***************
*** 58,62 ****
Name="VCPostBuildEventTool"
Description="Performing registration"
! CommandLine="regsvr32 /s /c "$(TargetPath)""/>
<Tool
Name="VCPreBuildEventTool"/>
--- 60,64 ----
Name="VCPostBuildEventTool"
Description="Performing registration"
! CommandLine="rem regsvr32 /s /c "$(TargetPath)""/>
<Tool
Name="VCPreBuildEventTool"/>
***************
*** 85,88 ****
--- 87,91 ----
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
+ AdditionalIncludeDirectories="../../deplib/boost-compatibility,../../include,../../deplib/cppunit/include,../../deplib/boostcvs"
PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG;_USRDLL"
StringPooling="TRUE"
***************
*** 104,107 ****
--- 107,111 ----
OutputFile="$(OutDir)/$(ProjectName).dll"
LinkIncremental="2"
+ AdditionalLibraryDirectories="../../deplib/cppunit/lib,../../lib"
ModuleDefinitionFile=".\AddIn.def"
GenerateDebugInformation="TRUE"
***************
*** 123,127 ****
Name="VCPostBuildEventTool"
Description="Performing registration"
! CommandLine="regsvr32 /s /c "$(TargetPath)""/>
<Tool
Name="VCPreBuildEventTool"/>
--- 127,131 ----
Name="VCPostBuildEventTool"
Description="Performing registration"
! CommandLine="rem regsvr32 /s /c "$(TargetPath)""/>
<Tool
Name="VCPreBuildEventTool"/>
***************
*** 141,146 ****
<Files>
<Filter
! Name="Source Files"
! Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm">
<File
RelativePath="AddIn.cpp">
--- 145,150 ----
<Files>
<Filter
! Name="AddIns"
! Filter="">
<File
RelativePath="AddIn.cpp">
***************
*** 150,153 ****
--- 154,160 ----
</File>
<File
+ RelativePath="AddIn.h">
+ </File>
+ <File
RelativePath="AddIn.idl">
</File>
***************
*** 156,159 ****
--- 163,172 ----
</File>
<File
+ RelativePath="Connect.h">
+ </File>
+ <File
+ RelativePath="Resource.h">
+ </File>
+ <File
RelativePath="stdafx.cpp">
<FileConfiguration
***************
*** 170,185 ****
</FileConfiguration>
</File>
</Filter>
<Filter
! Name="Header Files"
! Filter="h;hpp;hxx;hm;inl;inc">
<File
! RelativePath="Connect.h">
</File>
<File
! RelativePath="Resource.h">
</File>
<File
! RelativePath="stdafx.h">
</File>
</Filter>
--- 183,210 ----
</FileConfiguration>
</File>
+ <File
+ RelativePath="stdafx.h">
+ </File>
</Filter>
<Filter
! Name="Refactoring"
! Filter="">
<File
! RelativePath="RenameLocaleVariableDialog.cpp">
</File>
<File
! RelativePath="RenameLocaleVariableDialog.h">
</File>
<File
! RelativePath="RftaInlineLocalVarDialog.cpp">
! </File>
! <File
! RelativePath="RftaInlineLocalVarDialog.h">
! </File>
! <File
! RelativePath="SplitLocaleVariableDialog.cpp">
! </File>
! <File
! RelativePath="SplitLocaleVariableDialog.h">
</File>
</Filter>
***************
*** 206,209 ****
--- 231,252 ----
</File>
</Filter>
+ <File
+ RelativePath="TextDocumentHelper.cpp">
+ </File>
+ <File
+ RelativePath="TextDocumentHelper.h">
+ </File>
+ <File
+ RelativePath="TextSelectionHelper.cpp">
+ </File>
+ <File
+ RelativePath="TextSelectionHelper.h">
+ </File>
+ <File
+ RelativePath="VC7TextDocument.cpp">
+ </File>
+ <File
+ RelativePath="VC7TextDocument.h">
+ </File>
</Files>
<Globals>
Index: stdafx.h
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftavc7addin/stdafx.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** stdafx.h 12 May 2003 07:21:44 -0000 1.2
--- stdafx.h 14 May 2003 18:55:50 -0000 1.3
***************
*** 58,63 ****
#pragma warning( default : 4278 )
! #define IfFailGo(x) { hr=(x); if (FAILED(hr)) goto Error; }
! #define IfFailGoCheck(x, p) { hr=(x); if (FAILED(hr)) goto Error; if(!p) {hr = E_FAIL; goto Error; } }
class DECLSPEC_UUID("9D079750-4251-4722-8E52-E8296A611AE8") rftavc7addinLib;
--- 58,70 ----
#pragma warning( default : 4278 )
! #pragma warning( disable : 4278 )
! //The following #import imports DTE based on it's LIBID
! #import "libid:80cc9f66-e7d8-4ddd-85b6-d9e6cd0e93e2" version("7.0") lcid("0") raw_interfaces_only named_guids
! #pragma warning( default : 4278 )
!
!
!
! //#define IfFailGo(x) { hr=(x); if (FAILED(hr)) goto Error; }
! //#define IfFailGoCheck(x, p) { hr=(x); if (FAILED(hr)) goto Error; if(!p) {hr = E_FAIL; goto Error; } }
class DECLSPEC_UUID("9D079750-4251-4722-8E52-E8296A611AE8") rftavc7addinLib;
|