File Removed.

git-svn-id: svn://10.0.0.236/trunk@27273 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
sfraser%netscape.com 1999-04-13 01:18:25 +00:00
parent 2bda5a5f00
commit 1cfc44f4fe
8 changed files with 0 additions and 694 deletions

View File

@ -1,103 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsSelection.h"
#include "nsISelection.h"
NS_LAYOUT nsresult
NS_NewSelection(nsISelection** aInstancePtrResult)
{
static NS_DEFINE_IID(kISelectionIID, NS_ISELECTION_IID);
nsSelection * sel = new nsSelection();
return sel->QueryInterface(kISelectionIID, (void**) aInstancePtrResult);
}
nsresult nsSelection::QueryInterface(const nsIID& aIID,
void** aInstancePtrResult)
{
static NS_DEFINE_IID(kISelectionIID, NS_ISELECTION_IID);
NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer");
if (nsnull == aInstancePtrResult) {
return NS_ERROR_NULL_POINTER;
}
if (aIID.Equals(kISelectionIID)) {
nsISelection* tmp = this;
*aInstancePtrResult = (void*) tmp;
NS_ADDREF_THIS();
return NS_OK;
}
return !NS_OK;
}
nsSelection::nsSelection() {
NS_INIT_REFCNT();
mRange = new nsSelectionRange();
}
nsSelection::~nsSelection() {
delete mRange;
}
NS_IMPL_ADDREF(nsSelection)
NS_IMPL_RELEASE(nsSelection)
/**
* Returns whether there is a valid selection
*/
PRBool nsSelection::IsValidSelection() {
return (PRBool)(mRange->GetStartContent() == nsnull ||
mRange->GetEndContent() == nsnull);
}
/**
* Clears the current selection (invalidates the selection)
*/
void nsSelection::ClearSelection() {
mRange->GetStartPoint()->SetPoint(nsnull, -1, PR_TRUE);
mRange->GetEndPoint()->SetPoint(nsnull, -1, PR_TRUE);
}
/**
* Copies the data from one nsSelectionPoint in the range to another,
* it does NOT just assign the pointers
*/
void nsSelection::SetRange(nsSelectionRange * aSelectionRange) {
mRange->SetRange(aSelectionRange->GetStartPoint(),
aSelectionRange->GetEndPoint());
}
/**
* Copies the data from one nsSelectionPoint in the range to another,
* it does NOT just assign the pointers
*/
void nsSelection::GetRange(nsSelectionRange * aSelectionRange) {
mRange->SetRange(aSelectionRange->GetStartPoint(),
aSelectionRange->GetEndPoint());
}
/**
* For debug only, it potentially leaks memory
*/
char * nsSelection::ToString() {
return mRange->ToString();;
}

View File

@ -1,103 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsSelection.h"
#include "nsISelection.h"
NS_LAYOUT nsresult
NS_NewSelection(nsISelection** aInstancePtrResult)
{
static NS_DEFINE_IID(kISelectionIID, NS_ISELECTION_IID);
nsSelection * sel = new nsSelection();
return sel->QueryInterface(kISelectionIID, (void**) aInstancePtrResult);
}
nsresult nsSelection::QueryInterface(const nsIID& aIID,
void** aInstancePtrResult)
{
static NS_DEFINE_IID(kISelectionIID, NS_ISELECTION_IID);
NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer");
if (nsnull == aInstancePtrResult) {
return NS_ERROR_NULL_POINTER;
}
if (aIID.Equals(kISelectionIID)) {
nsISelection* tmp = this;
*aInstancePtrResult = (void*) tmp;
NS_ADDREF_THIS();
return NS_OK;
}
return !NS_OK;
}
nsSelection::nsSelection() {
NS_INIT_REFCNT();
mRange = new nsSelectionRange();
}
nsSelection::~nsSelection() {
delete mRange;
}
NS_IMPL_ADDREF(nsSelection)
NS_IMPL_RELEASE(nsSelection)
/**
* Returns whether there is a valid selection
*/
PRBool nsSelection::IsValidSelection() {
return (PRBool)(mRange->GetStartContent() == nsnull ||
mRange->GetEndContent() == nsnull);
}
/**
* Clears the current selection (invalidates the selection)
*/
void nsSelection::ClearSelection() {
mRange->GetStartPoint()->SetPoint(nsnull, -1, PR_TRUE);
mRange->GetEndPoint()->SetPoint(nsnull, -1, PR_TRUE);
}
/**
* Copies the data from one nsSelectionPoint in the range to another,
* it does NOT just assign the pointers
*/
void nsSelection::SetRange(nsSelectionRange * aSelectionRange) {
mRange->SetRange(aSelectionRange->GetStartPoint(),
aSelectionRange->GetEndPoint());
}
/**
* Copies the data from one nsSelectionPoint in the range to another,
* it does NOT just assign the pointers
*/
void nsSelection::GetRange(nsSelectionRange * aSelectionRange) {
mRange->SetRange(aSelectionRange->GetStartPoint(),
aSelectionRange->GetEndPoint());
}
/**
* For debug only, it potentially leaks memory
*/
char * nsSelection::ToString() {
return mRange->ToString();;
}

View File

@ -1,65 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsSelection_h___
#define nsSelection_h___
#include "nsSelectionRange.h"
#include "nsISelection.h"
class nsSelection : public nsISelection {
nsSelectionRange * mRange;
public:
NS_DECL_ISUPPORTS
nsSelection();
virtual ~nsSelection();
/**
* Returns whether there is a valid selection
*/
PRBool IsValidSelection();
/**
* Clears the current selection (invalidates the selection)
*/
void ClearSelection();
/**
* Copies the data from the param into the internal Range
*/
void SetRange(nsSelectionRange * aRange);
/**
* Copies the param's (aRange) contents with the Range's data
*/
void GetRange(nsSelectionRange * aRange);
/**
* Copies the param's (aRange) contents with the Range's data
*/
nsSelectionRange * GetRange() { return mRange; }
char * ToString();
};
extern NS_LAYOUT nsresult
NS_NewSelection(nsISelection** aInstancePtrResult);
#endif /* nsSelection_h___ */

View File

@ -1,74 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsSelectionPoint.h"
nsSelectionPoint::nsSelectionPoint(nsIContent * aContent,
PRInt32 aOffset,
PRBool aIsAnchor)
{
fContent = aContent;
fOffset = aOffset;
fIsAnchor = aIsAnchor;
fEntireContent = PR_FALSE;
if (fContent != nsnull)
NS_ADDREF(fContent);
}
nsSelectionPoint::~nsSelectionPoint()
{
NS_IF_RELEASE(fContent);
}
nsIContent * nsSelectionPoint::GetContent()
{
if (fContent != nsnull)
NS_ADDREF(fContent);
return fContent;
}
void nsSelectionPoint::SetContent(nsIContent * aValue)
{
NS_IF_RELEASE(fContent);
fContent = aValue;
if (fContent != nsnull)
NS_ADDREF(fContent);
}
void nsSelectionPoint::SetPoint(nsIContent * aContent,
PRInt32 aOffset,
PRBool aIsAnchor)
{
NS_IF_RELEASE(fContent);
fContent = aContent;
fOffset = aOffset;
fIsAnchor = aIsAnchor;
if (fContent != nsnull)
NS_ADDREF(fContent);
}
/**
* For debug only, it leaks memory
*/
char * nsSelectionPoint::ToString() {
char * str = new char[256];
sprintf(str, "TextPoint[0x%X, offset=%d, isAnchor=%s]", fContent, fOffset, (fIsAnchor?"PR_TRUE":"PR_FALSE"));
return str;
}

View File

@ -1,55 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsSelectionPoint_h___
#define nsSelectionPoint_h___
#include "nsIContent.h"
class nsSelectionPoint {
nsIContent * fContent;
PRInt32 fOffset;
PRBool fIsAnchor;
PRBool fEntireContent;
public:
nsSelectionPoint(nsIContent * aContent,
PRInt32 aOffset,
PRBool aIsAnchor);
virtual ~nsSelectionPoint();
nsIContent * GetContent();
PRInt32 GetOffset() { return fOffset; }
PRBool IsAnchor() { return fIsAnchor;}
PRBool IsEntireContentSelected() { return fEntireContent; }
void setEntireContentSelected(PRBool aState) { fEntireContent = aState; }
void SetContent(nsIContent * aValue);
void SetOffset(PRInt32 aValue) { fOffset = aValue; }
void SetAnchor(PRBool aValue) { fIsAnchor = aValue; }
void SetPoint(nsIContent * aContent,
PRInt32 aOffset,
PRBool aIsAnchor);
char * ToString();
};
#endif /* nsSelectionPoint_h___ */

View File

@ -1,102 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsSelectionRange.h"
nsSelectionRange::nsSelectionRange() {
mStart = new nsSelectionPoint(nsnull, -1, PR_TRUE);
mEnd = new nsSelectionPoint(nsnull, -1, PR_TRUE);
}
nsSelectionRange::nsSelectionRange(nsIContent * aStartContent,
PRInt32 aStartOffset,
PRBool aStartIsAnchor,
nsIContent * aEndContent,
PRInt32 aEndOffset,
PRBool aEndIsAnchor) {
mStart = new nsSelectionPoint(aStartContent, aStartOffset, aStartIsAnchor);
mEnd = new nsSelectionPoint(aEndContent, aEndOffset, aEndIsAnchor);
}
nsSelectionRange::~nsSelectionRange() {
delete mStart;
delete mEnd;
}
void nsSelectionRange::SetRange(nsIContent * aStartContent,
PRInt32 aStartOffset,
PRBool aStartIsAnchor,
nsIContent * aEndContent,
PRInt32 aEndOffset,
PRBool aEndIsAnchor) {
mStart->SetPoint(aStartContent, aStartOffset, aStartIsAnchor);
mEnd->SetPoint(aEndContent, aEndOffset, aEndIsAnchor);
}
void nsSelectionRange::SetRange(nsSelectionPoint * aStartPoint,
nsSelectionPoint * aEndPoint) {
SetStartPoint(aStartPoint);
SetEndPoint(aEndPoint);
}
void nsSelectionRange::SetRange(nsSelectionRange * aRange) {
SetStartPoint(aRange->GetStartPoint());
SetEndPoint(aRange->GetEndPoint());
}
void nsSelectionRange::SetStartPoint(nsSelectionPoint * aPoint) {
nsIContent * content = aPoint->GetContent();
mStart->SetPoint(content, aPoint->GetOffset(), aPoint->IsAnchor());
NS_IF_RELEASE(content);
}
void nsSelectionRange::SetEndPoint(nsSelectionPoint * aPoint) {
nsIContent * content = aPoint->GetContent();
mEnd->SetPoint(content, aPoint->GetOffset(), aPoint->IsAnchor());
NS_IF_RELEASE(content);
}
void nsSelectionRange::GetStartPoint(nsSelectionPoint * aPoint) {
nsIContent * content = mStart->GetContent();
aPoint->SetPoint(content, mStart->GetOffset(), mStart->IsAnchor());
NS_IF_RELEASE(content);
}
void nsSelectionRange::GetEndPoint(nsSelectionPoint * aPoint) {
nsIContent * content = mEnd->GetContent();
aPoint->SetPoint(content, mEnd->GetOffset(), mEnd->IsAnchor());
NS_IF_RELEASE(content);
}
void nsSelectionRange::GetRange(nsSelectionRange * aRange) {
aRange->SetStartPoint(mStart);
aRange->SetEndPoint(mEnd);
}
/**
* For debug only, it potentially leaks memory
*/
char * nsSelectionRange::ToString() {
static char str[1024];
char * startStr = mStart->ToString();
char * endStr = mEnd->ToString();
sprintf(str, "nsSelectionRange[\nStart=%s,\nEnd =%s\n]", startStr, endStr);
delete startStr;
delete endStr;
return str;
}

View File

@ -1,89 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsSelectionRange_h___
#define nsSelectionRange_h___
#include "nsSelectionPoint.h"
class nsSelectionRange {
nsSelectionPoint * mStart;
nsSelectionPoint * mEnd;
public:
nsSelectionRange();
nsSelectionRange(nsIContent * aStartContent,
PRInt32 aStartOffset,
PRBool aStartIsAnchor,
nsIContent * aEndContent,
PRInt32 aEndOffset,
PRBool aEndIsAnchor);
virtual ~nsSelectionRange();
void SetRange(nsIContent * aStartContent,
PRInt32 aStartOffset,
PRBool aStartIsAnchor,
nsIContent * aEndContent,
PRInt32 aEndOffset,
PRBool aEndIsAnchor);
void SetRange(nsSelectionPoint * aStartPoint,
nsSelectionPoint * aEndPoint);
/**
* Copies the data from the param into the internal Range
*/
void SetRange(nsSelectionRange * aRange);
nsIContent * GetStartContent() { return mStart->GetContent();}
nsIContent * GetEndContent() { return mEnd->GetContent(); }
nsSelectionPoint * GetStartPoint() { return mStart; }
nsSelectionPoint * GetEndPoint() { return mEnd; }
/**
* Copies the data from the param into the Start Point
*/
void SetStartPoint(nsSelectionPoint * aPoint);
/**
* Copies the data from the param into the End Point
*/
void SetEndPoint(nsSelectionPoint * aPoint);
/**
* Copies the param's (aPoint) contents with the Range's Point data
*/
void GetStartPoint(nsSelectionPoint * aPoint);
/**
* Copies the param's (aPoint) contents with the Range's Point data
*/
void GetEndPoint(nsSelectionPoint * aPoint);
/**
* Copies the param's (aRange) contents with the Range's data
*/
void GetRange(nsSelectionRange * aRange);
char * ToString();
};
#endif /* nsSelectionRange_h___ */

View File

@ -1,103 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsSelection.h"
#include "nsISelection.h"
NS_LAYOUT nsresult
NS_NewSelection(nsISelection** aInstancePtrResult)
{
static NS_DEFINE_IID(kISelectionIID, NS_ISELECTION_IID);
nsSelection * sel = new nsSelection();
return sel->QueryInterface(kISelectionIID, (void**) aInstancePtrResult);
}
nsresult nsSelection::QueryInterface(const nsIID& aIID,
void** aInstancePtrResult)
{
static NS_DEFINE_IID(kISelectionIID, NS_ISELECTION_IID);
NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer");
if (nsnull == aInstancePtrResult) {
return NS_ERROR_NULL_POINTER;
}
if (aIID.Equals(kISelectionIID)) {
nsISelection* tmp = this;
*aInstancePtrResult = (void*) tmp;
NS_ADDREF_THIS();
return NS_OK;
}
return !NS_OK;
}
nsSelection::nsSelection() {
NS_INIT_REFCNT();
mRange = new nsSelectionRange();
}
nsSelection::~nsSelection() {
delete mRange;
}
NS_IMPL_ADDREF(nsSelection)
NS_IMPL_RELEASE(nsSelection)
/**
* Returns whether there is a valid selection
*/
PRBool nsSelection::IsValidSelection() {
return (PRBool)(mRange->GetStartContent() == nsnull ||
mRange->GetEndContent() == nsnull);
}
/**
* Clears the current selection (invalidates the selection)
*/
void nsSelection::ClearSelection() {
mRange->GetStartPoint()->SetPoint(nsnull, -1, PR_TRUE);
mRange->GetEndPoint()->SetPoint(nsnull, -1, PR_TRUE);
}
/**
* Copies the data from one nsSelectionPoint in the range to another,
* it does NOT just assign the pointers
*/
void nsSelection::SetRange(nsSelectionRange * aSelectionRange) {
mRange->SetRange(aSelectionRange->GetStartPoint(),
aSelectionRange->GetEndPoint());
}
/**
* Copies the data from one nsSelectionPoint in the range to another,
* it does NOT just assign the pointers
*/
void nsSelection::GetRange(nsSelectionRange * aSelectionRange) {
mRange->SetRange(aSelectionRange->GetStartPoint(),
aSelectionRange->GetEndPoint());
}
/**
* For debug only, it potentially leaks memory
*/
char * nsSelection::ToString() {
return mRange->ToString();;
}