diff --git a/mozilla/editor/base/nsEditorShell.cpp b/mozilla/editor/base/nsEditorShell.cpp
index afaf45ee412..8c83e431f37 100644
--- a/mozilla/editor/base/nsEditorShell.cpp
+++ b/mozilla/editor/base/nsEditorShell.cpp
@@ -1738,7 +1738,7 @@ nsEditorShell::SetDocumentTitle(const PRUnichar *title)
if (NS_SUCCEEDED(res) && textNode)
{
// Go through the editor API so action is undoable
- res = editor->InsertNode(textNode, headNode, 0);
+ res = editor->InsertNode(textNode, titleNode, 0);
// This is the non-undoable code:
//res = titleNode->AppendChild(textNode,getter_AddRefs(resultNode));
}
diff --git a/mozilla/editor/base/nsInterfaceState.cpp b/mozilla/editor/base/nsInterfaceState.cpp
index 62ac77d7d99..ea9b8aa9262 100644
--- a/mozilla/editor/base/nsInterfaceState.cpp
+++ b/mozilla/editor/base/nsInterfaceState.cpp
@@ -143,12 +143,14 @@ nsInterfaceState::ForceUpdate()
// update underline
rv = UpdateTextState("u", "Editor:Underline", "underline", mUnderlineState);
+ // update the paragraph format popup
+ rv = UpdateParagraphState("Editor:Paragraph:Format", "format", mParagraphFormat);
+
// udpate the font face
rv = UpdateFontFace("Editor:Font:Face", "font", mFontString);
- // update the paragraph format popup
- rv = UpdateParagraphState("Editor:Paragraph:Format", "format", mParagraphFormat);
-
+ // TODO: FINISH FONT FACE AND ADD FONT SIZE ("Editor:Font:Size", "size", mFontSize)
+
// update the list buttons
rv = UpdateListState("Editor:Paragraph:ListType");
@@ -183,18 +185,33 @@ nsInterfaceState::UpdateParagraphState(const char* observerName, const char* att
mEditor->GetParagraphTags(&tagList);
PRInt32 numTags = tagList.Count();
+ nsAutoString thisTag;
+ //Note: If numTags == 0, we probably have a text node not in a container
+ // (directly under
). Consider it normal
if (numTags > 0)
{
- nsAutoString thisTag;
+#ifdef DEBUG_cmanske
+ if (thisTag.Length() > 0)
+ printf (thisTag.ToNewCString());
+ else
+ printf("[emtpy string]");
+ printf(",");
+ if (mParagraphFormat.Length() > 0)
+ printf (mParagraphFormat.ToNewCString());
+ else
+ printf("[mParagraph is empty]");
+ printf(" = ParagraphTag,mParagraphFormat in nsInterfaceState::UpdateParagraphState()\n");
+#endif
+ // This will never show the "mixed state"
+ // TODO: Scan list of tags and if any are different, set to "mixed"
tagList.StringAt(0, thisTag);
- if (thisTag != mParagraphFormat)
- {
- nsresult rv = SetNodeAttribute(observerName, attributeName, thisTag);
- if (NS_FAILED(rv)) return rv;
- mParagraphFormat = thisTag;
- }
}
-
+ if (thisTag != mParagraphFormat)
+ {
+ nsresult rv = SetNodeAttribute(observerName, attributeName, thisTag);
+ if (NS_FAILED(rv)) return rv;
+ mParagraphFormat = thisTag;
+ }
return NS_OK;
}
@@ -252,16 +269,47 @@ nsInterfaceState::UpdateFontFace(const char* observerName, const char* attribute
nsCOMPtr styleAtom = getter_AddRefs(NS_NewAtom("font"));
nsAutoString faceStr("face");
+ nsAutoString thisFace;
+
+ // Use to test for "Default Fixed Width"
+ nsCOMPtr fixedStyleAtom = getter_AddRefs(NS_NewAtom("tt"));
+
+ PRBool testBoolean;
if (SelectionIsCollapsed())
{
rv = mEditor->GetTypingStateValue(styleAtom, ioFontString);
+ if (ioFontString.Length() == 0)
+ {
+ // We don't have a font set, so check for "tt" (= "Default Fixed Width")
+ PRBool stateHasProp = PR_FALSE;
+ rv = mEditor->GetTypingState(fixedStyleAtom, testBoolean);
+ testBoolean = stateHasProp;
+ if (stateHasProp)
+ thisFace = faceStr;
+ }
+ else
+ testBoolean = PR_TRUE;
}
else
{
rv = mEditor->GetInlineProperty(styleAtom, &faceStr, nsnull, firstOfSelectionHasProp, anyOfSelectionHasProp, allOfSelectionHasProp);
+ if( !anyOfSelectionHasProp )
+ {
+ // No font face set -- check for "tt"
+ rv = mEditor->GetInlineProperty(fixedStyleAtom, nsnull, nsnull, firstOfSelectionHasProp, anyOfSelectionHasProp, allOfSelectionHasProp);
+ testBoolean = anyOfSelectionHasProp;
+ thisFace = faceStr;
+ }
+ }
+ // TODO: HANDLE "MIXED" STATE
+ if (thisFace != mFontString)
+ {
+ nsresult rv = SetNodeAttribute(observerName, faceStr.GetBuffer(), thisFace);
+ if (NS_FAILED(rv)) return rv;
+
+ mFontString = thisFace;
}
- // XXX this needs finishing.
return rv;
}
diff --git a/mozilla/editor/composer/src/nsEditorShell.cpp b/mozilla/editor/composer/src/nsEditorShell.cpp
index afaf45ee412..8c83e431f37 100644
--- a/mozilla/editor/composer/src/nsEditorShell.cpp
+++ b/mozilla/editor/composer/src/nsEditorShell.cpp
@@ -1738,7 +1738,7 @@ nsEditorShell::SetDocumentTitle(const PRUnichar *title)
if (NS_SUCCEEDED(res) && textNode)
{
// Go through the editor API so action is undoable
- res = editor->InsertNode(textNode, headNode, 0);
+ res = editor->InsertNode(textNode, titleNode, 0);
// This is the non-undoable code:
//res = titleNode->AppendChild(textNode,getter_AddRefs(resultNode));
}
diff --git a/mozilla/editor/composer/src/nsInterfaceState.cpp b/mozilla/editor/composer/src/nsInterfaceState.cpp
index 62ac77d7d99..ea9b8aa9262 100644
--- a/mozilla/editor/composer/src/nsInterfaceState.cpp
+++ b/mozilla/editor/composer/src/nsInterfaceState.cpp
@@ -143,12 +143,14 @@ nsInterfaceState::ForceUpdate()
// update underline
rv = UpdateTextState("u", "Editor:Underline", "underline", mUnderlineState);
+ // update the paragraph format popup
+ rv = UpdateParagraphState("Editor:Paragraph:Format", "format", mParagraphFormat);
+
// udpate the font face
rv = UpdateFontFace("Editor:Font:Face", "font", mFontString);
- // update the paragraph format popup
- rv = UpdateParagraphState("Editor:Paragraph:Format", "format", mParagraphFormat);
-
+ // TODO: FINISH FONT FACE AND ADD FONT SIZE ("Editor:Font:Size", "size", mFontSize)
+
// update the list buttons
rv = UpdateListState("Editor:Paragraph:ListType");
@@ -183,18 +185,33 @@ nsInterfaceState::UpdateParagraphState(const char* observerName, const char* att
mEditor->GetParagraphTags(&tagList);
PRInt32 numTags = tagList.Count();
+ nsAutoString thisTag;
+ //Note: If numTags == 0, we probably have a text node not in a container
+ // (directly under ). Consider it normal
if (numTags > 0)
{
- nsAutoString thisTag;
+#ifdef DEBUG_cmanske
+ if (thisTag.Length() > 0)
+ printf (thisTag.ToNewCString());
+ else
+ printf("[emtpy string]");
+ printf(",");
+ if (mParagraphFormat.Length() > 0)
+ printf (mParagraphFormat.ToNewCString());
+ else
+ printf("[mParagraph is empty]");
+ printf(" = ParagraphTag,mParagraphFormat in nsInterfaceState::UpdateParagraphState()\n");
+#endif
+ // This will never show the "mixed state"
+ // TODO: Scan list of tags and if any are different, set to "mixed"
tagList.StringAt(0, thisTag);
- if (thisTag != mParagraphFormat)
- {
- nsresult rv = SetNodeAttribute(observerName, attributeName, thisTag);
- if (NS_FAILED(rv)) return rv;
- mParagraphFormat = thisTag;
- }
}
-
+ if (thisTag != mParagraphFormat)
+ {
+ nsresult rv = SetNodeAttribute(observerName, attributeName, thisTag);
+ if (NS_FAILED(rv)) return rv;
+ mParagraphFormat = thisTag;
+ }
return NS_OK;
}
@@ -252,16 +269,47 @@ nsInterfaceState::UpdateFontFace(const char* observerName, const char* attribute
nsCOMPtr styleAtom = getter_AddRefs(NS_NewAtom("font"));
nsAutoString faceStr("face");
+ nsAutoString thisFace;
+
+ // Use to test for "Default Fixed Width"
+ nsCOMPtr fixedStyleAtom = getter_AddRefs(NS_NewAtom("tt"));
+
+ PRBool testBoolean;
if (SelectionIsCollapsed())
{
rv = mEditor->GetTypingStateValue(styleAtom, ioFontString);
+ if (ioFontString.Length() == 0)
+ {
+ // We don't have a font set, so check for "tt" (= "Default Fixed Width")
+ PRBool stateHasProp = PR_FALSE;
+ rv = mEditor->GetTypingState(fixedStyleAtom, testBoolean);
+ testBoolean = stateHasProp;
+ if (stateHasProp)
+ thisFace = faceStr;
+ }
+ else
+ testBoolean = PR_TRUE;
}
else
{
rv = mEditor->GetInlineProperty(styleAtom, &faceStr, nsnull, firstOfSelectionHasProp, anyOfSelectionHasProp, allOfSelectionHasProp);
+ if( !anyOfSelectionHasProp )
+ {
+ // No font face set -- check for "tt"
+ rv = mEditor->GetInlineProperty(fixedStyleAtom, nsnull, nsnull, firstOfSelectionHasProp, anyOfSelectionHasProp, allOfSelectionHasProp);
+ testBoolean = anyOfSelectionHasProp;
+ thisFace = faceStr;
+ }
+ }
+ // TODO: HANDLE "MIXED" STATE
+ if (thisFace != mFontString)
+ {
+ nsresult rv = SetNodeAttribute(observerName, faceStr.GetBuffer(), thisFace);
+ if (NS_FAILED(rv)) return rv;
+
+ mFontString = thisFace;
}
- // XXX this needs finishing.
return rv;
}
diff --git a/mozilla/editor/ui/composer/content/EditorCommands.js b/mozilla/editor/ui/composer/content/EditorCommands.js
index 06e9001bec2..5df51766271 100644
--- a/mozilla/editor/ui/composer/content/EditorCommands.js
+++ b/mozilla/editor/ui/composer/content/EditorCommands.js
@@ -27,22 +27,10 @@ var toolbar;
var documentModified;
var EditorDisplayMode = 0; // Normal Editor mode
-var gTagToFormat = {
- "P" : "Normal", // these should really be entities. Not sure how to do that from JS
- "H1" : "Heading 1",
- "H2" : "Heading 2",
- "H3" : "Heading 3",
- "H4" : "Heading 4",
- "H5" : "Heading 5",
- "H6" : "Heading 6",
- "BLOCKQUOTE" : "Blockquote",
- "ADDRESS" : "Address",
- "PRE" : "Preformatted",
- "LI" : "List Item",
- "DT" : "Definition Term",
- "DD" : "Definition Description"
- };
-
+// These must be kept in synch with the XUL lists
+var gParagraphTagNames = new Array("P","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","ADDRESS","PRE","DT","DD");
+var gFontFaceNames = new Array("","tt","Arial, Helvetica","Times","Courier");
+var gFontSizeNames = new Array("-2","-1","0","+1","+2","+3","+4");
var gStyleTags = {
"bold" : "b",
@@ -83,18 +71,7 @@ function EditorStartup(editorType, editorElement)
window.addEventListener("load", EditorDocumentLoaded, true, false);
dump("Trying to make an Editor Shell through the component manager...\n");
-/* var editorShell = Components.classes["component://netscape/editor/editorshell"].createInstance();
- if (editorShell)
- editorShell = editorShell.QueryInterface(Components.interfaces.nsIEditorShell);
- if (!editorShell)
- {
- dump("Failed to create editor shell\n");
- // 7/12/99 THIS DOESN'T WORK YET!
- window.close();
- return;
- }
-*/
// store the editor shell in the window, so that child windows can get to it.
var editorShell = window.editorShell = editorElement.editorShell;
@@ -110,6 +87,7 @@ function EditorStartup(editorType, editorElement)
editorShell.LoadUrl(url);
dump("EditorAppCore windows have been set.\n");
+
SetupToolbarElements();
// Set focus to the edit window
@@ -138,7 +116,7 @@ function TestMenuCreation()
dump("Failed to find new menu item\n");
}
-
+// NOT USED?
function GenerateFormatToolbar()
{
var toolbarButtons = [
@@ -208,7 +186,6 @@ function GenerateFormatToolbar()
}
-
function SetupToolbarElements()
{
// Create an object to store controls for easy access
@@ -372,41 +349,96 @@ function EditorSetTextProperty(property, attribute, value)
contentWindow.focus();
}
+function EditorSelectParagraphFormat()
+{
+ var select = document.getElementById("ParagraphSelect");
+ if (select)
+ {
+ if (select.selectedIndex == -1)
+ return;
+ editorShell.SetParagraphFormat(gParagraphTagNames[select.selectedIndex]);
+ }
+}
+
+function onParagraphFormatChange()
+{
+ var select = document.getElementById("ParagraphSelect");
+ if (select)
+ {
+ // If we don't match anything, set to "normal"
+ var newIndex = 0;
+ var format = select.getAttribute("format");
+ if ( format == "mixed")
+ {
+ // No single type selected
+ newIndex = -1;
+ }
+ else
+ {
+ for( var i = 0; i < gParagraphTagNames.length; i++)
+ {
+ if( gParagraphTagNames[i] == format )
+ {
+ newIndex = i;
+ break;
+ }
+ }
+ }
+ if (select.selectedIndex != newIndex)
+ select.selectedIndex = newIndex;
+ }
+}
+
function EditorSetParagraphFormat(paraFormat)
{
editorShell.SetParagraphFormat(paraFormat);
contentWindow.focus();
}
-function EditorListProperties()
+function EditorSelectFontFace()
{
- window.openDialog("chrome://editor/content/EdListProps.xul","_blank", "chrome,close,titlebar,modal");
- contentWindow.focus();
+ var select = document.getElementById("FontFaceSelect");
+dump("EditorSelectFontFace: "+gFontFaceNames[select.selectedIndex]+"\n");
+ if (select)
+ {
+ if (select.selectedIndex == -1)
+ return;
+
+ EditorSetFontFace(gFontFaceNames[select.selectedIndex]);
+ }
}
-function EditorSetFontSize(size)
+function onFontFaceChange()
{
- if( size == "0" || size == "normal" ||
- size == "+0" )
- {
- editorShell.RemoveTextProperty("font", size);
- dump("Removing font size\n");
- } else {
- dump("Setting font size\n");
- editorShell.SetTextProperty("font", "size", size);
+ var select = document.getElementById("FontFaceSelect");
+ if (select)
+ {
+ // Default selects "Variable Width"
+ var newIndex = 0;
+ var face = select.getAttribute("face");
+ if ( face == "mixed")
+ {
+ // No single type selected
+ newIndex = -1;
+ }
+ else
+ {
+ for( var i = 0; i < gFontFaceNames.length; i++)
+ {
+ if( gFontFaceNames[i] == face )
+ {
+ newIndex = i;
+ break;
+ }
+ }
+ }
+ if (select.selectedIndex != newIndex)
+ select.selectedIndex = newIndex;
}
- contentWindow.focus();
}
function EditorSetFontFace(fontFace)
{
-/* Testing returning out params
- var first = new Object();
- var all = new Object();
- var any = new Object();
- editorShell.GetTextProperty("tt", "", "", first, any, all);
- dump("GetTextProperty: first: "+first.value+", any: "+any.value+", all: "+all.value+"\n");
-*/
if( fontFace == "tt") {
// The old "teletype" attribute
editorShell.SetTextProperty("tt", "", "");
@@ -425,6 +457,62 @@ function EditorSetFontFace(fontFace)
contentWindow.focus();
}
+function EditorSelectFontSize()
+{
+ var select = document.getElementById("FontSizeSelect");
+dump("EditorSelectFontSize: "+gFontSizeNames[select.selectedIndex]+"\n");
+ if (select)
+ {
+ if (select.selectedIndex == -1)
+ return;
+
+ EditorSetFontSize(gFontSizeNames[select.selectedIndex]);
+ }
+}
+
+function onFontSizeChange()
+{
+ var select = document.getElementById("FontFaceSelect");
+ if (select)
+ {
+ // If we don't match anything, set to "0 (normal)"
+ var newIndex = 2;
+ var size = select.getAttribute("size");
+ if ( size == "mixed")
+ {
+ // No single type selected
+ newIndex = -1;
+ }
+ else
+ {
+ for( var i = 0; i < gFontSizeNames.length; i++)
+ {
+ if( gFontSizeNames[i] == size )
+ {
+ newIndex = i;
+ break;
+ }
+ }
+ }
+ if (select.selectedIndex != newIndex)
+ select.selectedIndex = newIndex;
+ }
+}
+
+function EditorSetFontSize(size)
+{
+ if( size == "0" || size == "normal" ||
+ size == "+0" )
+ {
+ editorShell.RemoveTextProperty("font", size);
+ dump("Removing font size\n");
+ } else {
+ dump("Setting font size\n");
+ editorShell.SetTextProperty("font", "size", size);
+ }
+ contentWindow.focus();
+}
+
function EditorSetFontColor(color)
{
editorShell.SetTextProperty("font", "color", color);
@@ -481,6 +569,12 @@ function EditorRemoveLinks()
contentWindow.focus();
}
+function EditorListProperties()
+{
+ window.openDialog("chrome://editor/content/EdListProps.xul","_blank", "chrome,close,titlebar,modal");
+ contentWindow.focus();
+}
+
function EditorApplyStyleSheet(styleSheetURL)
{
// Second param is true for "override" type of sheet
@@ -1203,26 +1297,15 @@ function onDirtyChange()
var theButton = document.getElementById("saveButton");
if (theButton)
{
- var isDirty = theButton.getAttribute("dirty");
+ var isDirty = theButton.getAttribute("dirty");
if (isDirty == "true") {
- theButton.setAttribute("src", "chrome://editor/skin/images/ED_SaveMod.gif");
+ theButton.setAttribute("src", "chrome://editor/skin/images/savemod.gif");
} else {
- theButton.setAttribute("src", "chrome://editor/skin/images/ED_SaveFile.gif");
+ theButton.setAttribute("src", "chrome://editor/skin/images/savefile.gif");
}
}
}
-function onParagraphFormatChange()
-{
- var theButton = document.getElementById("ParagraphPopupButton");
- if (theButton)
- {
- var theFormat = theButton.getAttribute("format");
- theButton.setAttribute("value", gTagToFormat[theFormat]);
- dump("Setting value\n");
- }
-}
-
function onListFormatChange(listType)
{
var theButton = document.getElementById(listType + "Button");
diff --git a/mozilla/editor/ui/composer/content/editor.xul b/mozilla/editor/ui/composer/content/editor.xul
index 588e3ed584c..49790023737 100644
--- a/mozilla/editor/ui/composer/content/editor.xul
+++ b/mozilla/editor/ui/composer/content/editor.xul
@@ -38,7 +38,7 @@
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="EditorOnLoad()"
onunload="EditorShutdown()"
- titlemodifier="&textEditorWindow.titlemodifier;"
+ titlemodifier="&editorWindow.titlemodifier;"
titlemenuseparator="&editorWindow.titlemodifiermenuseparator;"
align="vertical"
width="640" height="480">
@@ -157,19 +157,13 @@
-
-
-
-
+
+
+
+
+
+
+