diff --git a/mozilla/editor/base/Makefile.in b/mozilla/editor/base/Makefile.in index ae0cf28baa8..6e70574115d 100644 --- a/mozilla/editor/base/Makefile.in +++ b/mozilla/editor/base/Makefile.in @@ -67,8 +67,6 @@ CPPSRCS = \ MODULE = editor -REQUIRES = xpcom raptor dom base netlib - include $(topsrcdir)/config/config.mk include $(topsrcdir)/config/rules.mk diff --git a/mozilla/editor/base/makefile.win b/mozilla/editor/base/makefile.win index fcfa878016d..8de4cd3e51d 100644 --- a/mozilla/editor/base/makefile.win +++ b/mozilla/editor/base/makefile.win @@ -102,18 +102,6 @@ CPP_OBJS = \ MODULE=editor -REQUIRES=xpcom raptor dom base netlib pref - -LINCS=-I$(PUBLIC)\editor \ - -I$(PUBLIC)\xpcom \ - -I$(PUBLIC)\raptor \ - -I$(PUBLIC)\js \ - -I$(PUBLIC)\pref \ - -I$(PUBLIC)\txmgr \ - -I$(PUBLIC)\netlib \ - -I$(PUBLIC)\pref \ - -I$(PUBLIC)\dom - MAKE_OBJ_TYPE = DLL DLLNAME = ender DLL=.\$(OBJDIR)\$(DLLNAME).dll @@ -129,6 +117,7 @@ LLIBS= \ $(DIST)\lib\plc3.lib \ $(DIST)\lib\raptorhtmlpars.lib \ $(DIST)\lib\raptorwidget_s.lib \ + $(DIST)\lib\netlib.lib \ $(LIBNSPR) !if "$(MOZ_BITS)"=="32" && defined(MOZ_DEBUG) && defined(GLOWCODE) LLIBS=$(LLIBS) $(GLOWDIR)\glowcode.lib diff --git a/mozilla/editor/base/nsEditor.cpp b/mozilla/editor/base/nsEditor.cpp index 0a6aa6bddc7..d0e698cc72f 100644 --- a/mozilla/editor/base/nsEditor.cpp +++ b/mozilla/editor/base/nsEditor.cpp @@ -18,6 +18,8 @@ #include "nsIDOMDocument.h" +#include "nsIPref.h" +#include "nsILocale.h" #include "nsEditor.h" #include "nsIEditProperty.h" // to be removed XXX #include "nsIDOMText.h" @@ -46,7 +48,6 @@ #include "nsISupportsArray.h" #include "nsICaret.h" #include "nsIStyleContext.h" - #include "nsIEditActionListener.h" #include "nsIContent.h" @@ -111,13 +112,14 @@ static NS_DEFINE_IID(kJoinElementTxnIID, JOIN_ELEMENT_TXN_IID); static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); static NS_DEFINE_CID(kCDOMRangeCID, NS_RANGE_CID); +static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID); +static NS_DEFINE_CID(kPrefCID, NS_PREF_CID); // factory classes static NS_DEFINE_IID(kIEditFactoryIID, NS_IEDITORFACTORY_IID); static NS_DEFINE_IID(kIHTMLEditFactoryIID, NS_IHTMLEDITORFACTORY_IID); static NS_DEFINE_IID(kITextEditFactoryIID, NS_ITEXTEDITORFACTORY_IID); - #ifdef XP_PC #define TRANSACTION_MANAGER_DLL "txmgr.dll" #else @@ -131,6 +133,8 @@ static NS_DEFINE_IID(kITextEditFactoryIID, NS_ITEXTEDITORFACTORY_IID); #define NS_ERROR_EDITOR_NO_SELECTION NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_EDITOR,1) #define NS_ERROR_EDITOR_NO_TEXTNODE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_EDITOR,2) +#define EDITOR_BUNDLE_URL "resource:/res/editor.properties" + const char* nsEditor::kMOZEditorBogusNodeAttr="MOZ_EDITOR_BOGUS_NODE"; const char* nsEditor::kMOZEditorBogusNodeValue="TRUE"; @@ -294,7 +298,7 @@ nsEditor::nsEditor() gInstanceCount++; mActionListeners = 0; PR_ExitMonitor(getEditorMonitor()); - + mPrefs = 0; } @@ -315,6 +319,10 @@ nsEditor::~nsEditor() delete mActionListeners; mActionListeners = 0; } + + // Release service pointers + if (mPrefs) + nsServiceManager::ReleaseService(kPrefCID, mPrefs); } @@ -456,6 +464,51 @@ nsEditor::Init(nsIDOMDocument *aDoc, nsIPresShell* aPresShell) caret->SetCaretVisible(PR_TRUE); caret->SetCaretReadOnly(PR_FALSE); } + // NOTE: We don't fail if we can't get prefs or string bundles + // since we could still be used as the text edit widget without prefs + + // Get the prefs service (Note: can't use nsCOMPtr for service pointers) + nsresult result = nsServiceManager::GetService(kPrefCID, + nsIPref::GetIID(), + (nsISupports**)&mPrefs); + if (NS_FAILED(result) || !mPrefs) + { + printf("ERROR: Failed to get Prefs Service instance.\n"); + } + // TODO: Cache basic preferences? + // Register callbacks for preferences that we need to + // respond to while running + + nsIStringBundleService* service; + result = nsServiceManager::GetService(kStringBundleServiceCID, + nsIStringBundleService::GetIID(), + (nsISupports**)&service); + + if (NS_SUCCEEDED(result) && service) + { + nsCOMPtr url; + result = NS_NewURL(getter_AddRefs(url), nsString(EDITOR_BUNDLE_URL)); + + if (NS_SUCCEEDED(result) && url) + { + nsILocale* locale = nsnull; + result = service->CreateBundle(url, locale, getter_AddRefs(mStringBundle)); + if (NS_FAILED(result)) + printf("ERROR: Failed to get Create StringBundle\n"); + + } else { + printf("ERROR: Failed to get create URL for StringBundle\n"); + } + // We don't need to keep service around once we created the bundle + nsServiceManager::ReleaseService(kStringBundleServiceCID, service); + } else { + printf("ERROR: Failed to get StringBundle Service instance.\n"); + } +/* + Example of getting a string: + nsString value; + ret = mStringBundle->GetStringFromName("editor.foo", value); +*/ mPresShell->SetCaretEnabled(PR_TRUE); @@ -3748,6 +3801,18 @@ nsEditor::JoinNodeDeep(nsIDOMNode *aLeftNode, return res; } +// Get a string from the localized string resources +nsresult nsEditor::GetString(const nsString& name, nsString& value) +{ + nsresult result = NS_ERROR_NOT_INITIALIZED; + value = ""; + if (mStringBundle && (name != "")) + { + result = mStringBundle->GetStringFromName(name, value); + } + return result; +} + /****************************************************************************** * nsAutoSelectionReset *****************************************************************************/ @@ -3776,6 +3841,3 @@ nsAutoSelectionReset::~nsAutoSelectionReset() } } - - - diff --git a/mozilla/editor/base/nsEditor.h b/mozilla/editor/base/nsEditor.h index d66f2e57a57..603969a5c2b 100644 --- a/mozilla/editor/base/nsEditor.h +++ b/mozilla/editor/base/nsEditor.h @@ -27,10 +27,10 @@ #include "nsIDOMEventListener.h" #include "nsIDOMRange.h" #include "nsCOMPtr.h" +#include "nsIStringBundle.h" #include "nsITransactionManager.h" #include "TransactionFactory.h" #include "nsIComponentManager.h" -#include "nsCOMPtr.h" class nsIEditActionListener; class nsIDOMCharacterData; @@ -48,6 +48,10 @@ class JoinElementTxn; class EditAggregateTxn; class nsVoidArray; class nsISupportsArray; +class nsIPref; +class nsIStringBundleService; +class nsIStringBundle; +class nsILocale; //This is the monitor for the editor. PRMonitor *getEditorMonitor(); @@ -72,9 +76,12 @@ private: static PRInt32 gInstanceCount; nsVoidArray *mActionListeners; + nsCOMPtr mStringBundle; protected: nsIDOMDocument * mDoc; + // Services are not nsCOMPtr friendly + nsIPref* mPrefs; public: @@ -494,7 +501,7 @@ public: static nsCOMPtr NextNodeInBlock(nsIDOMNode *aNode, IterDirection aDir); static nsresult GetStartNodeAndOffset(nsIDOMSelection *aSelection, nsCOMPtr *outStartNode, PRInt32 *outStartOffset); static nsresult GetEndNodeAndOffset(nsIDOMSelection *aSelection, nsCOMPtr *outEndNode, PRInt32 *outEndOffset); - + nsresult IsPreformatted(nsIDOMNode *aNode, PRBool *aResult); nsresult IsNextCharWhitespace(nsIDOMNode *aParentNode, PRInt32 aOffset, PRBool *aResult); nsresult IsPrevCharWhitespace(nsIDOMNode *aParentNode, PRInt32 aOffset, PRBool *aResult); @@ -502,6 +509,7 @@ public: nsresult SplitNodeDeep(nsIDOMNode *aNode, nsIDOMNode *aSplitPointParent, PRInt32 aSplitPointOffset); nsresult JoinNodeDeep(nsIDOMNode *aLeftNode, nsIDOMNode *aRightNode, nsIDOMSelection *aSelection); + nsresult GetString(const nsString& name, nsString& value); }; diff --git a/mozilla/editor/base/nsHTMLEditor.cpp b/mozilla/editor/base/nsHTMLEditor.cpp index 73a23773c3e..d1a984a2115 100644 --- a/mozilla/editor/base/nsHTMLEditor.cpp +++ b/mozilla/editor/base/nsHTMLEditor.cpp @@ -1809,13 +1809,13 @@ nsHTMLEditor::CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement* if (aTagName == "" || !aReturn) return NS_ERROR_NULL_POINTER; - + nsAutoString TagName = aTagName; TagName.ToLowerCase(); nsAutoString realTagName; - PRBool isHREF = (TagName == "href"); - PRBool isAnchor = (TagName == "anchor"); + PRBool isHREF = (TagName.Equals("href")); + PRBool isAnchor = (TagName.Equals("anchor")); if (isHREF || isAnchor) { realTagName = "a"; @@ -1836,16 +1836,20 @@ nsHTMLEditor::CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement* // ATTRIBUTES SAVED IN PREFS? if (isAnchor) { + // TODO: Get the text of the selection and build a suggested Name // Replace spaces with "_" + } else if (TagName.Equals("hr")) + { + } + // ADD OTHER DEFAULT ATTRIBUTES HERE if (NS_SUCCEEDED(res)) { *aReturn = newElement; } - return res; } @@ -1876,15 +1880,12 @@ nsHTMLEditor::InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection, ns } } - DeleteSelectionAndPrepareToCreateNode(parentSelectedNode, offsetOfNewNode); + res = DeleteSelectionAndPrepareToCreateNode(parentSelectedNode, offsetOfNewNode); if (NS_SUCCEEDED(res)) { nsCOMPtr newNode = do_QueryInterface(aElement); - res = InsertNode(aElement, parentSelectedNode, offsetOfNewNode); - } - return res; } @@ -2164,8 +2165,19 @@ NS_IMETHODIMP nsHTMLEditor::GetLocalFileURL(nsIDOMWindow* aParent, const nsStrin nsCOMPtr fileWidget; - // TODO: WHERE TO WE PUT GLOBAL STRINGS TO BE LOCALIZED? - nsString title(htmlFilter ? "Open HTML file" : "Select Image File"); + nsAutoString title(""); + + // Get strings from editor resource bundle + nsString name; + if (htmlFilter) + { + name = "OpenHTMLFile"; + } else if (imgFilter) + { + name = "SelectImageFile"; + } + GetString(name, title); + nsFileSpec fileSpec; // TODO: GET THE DEFAULT DIRECTORY FOR DIFFERENT TYPES FROM PREFERENCES nsFileSpec aDisplayDirectory; diff --git a/mozilla/editor/libeditor/base/nsEditor.cpp b/mozilla/editor/libeditor/base/nsEditor.cpp index 0a6aa6bddc7..d0e698cc72f 100644 --- a/mozilla/editor/libeditor/base/nsEditor.cpp +++ b/mozilla/editor/libeditor/base/nsEditor.cpp @@ -18,6 +18,8 @@ #include "nsIDOMDocument.h" +#include "nsIPref.h" +#include "nsILocale.h" #include "nsEditor.h" #include "nsIEditProperty.h" // to be removed XXX #include "nsIDOMText.h" @@ -46,7 +48,6 @@ #include "nsISupportsArray.h" #include "nsICaret.h" #include "nsIStyleContext.h" - #include "nsIEditActionListener.h" #include "nsIContent.h" @@ -111,13 +112,14 @@ static NS_DEFINE_IID(kJoinElementTxnIID, JOIN_ELEMENT_TXN_IID); static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); static NS_DEFINE_CID(kCDOMRangeCID, NS_RANGE_CID); +static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID); +static NS_DEFINE_CID(kPrefCID, NS_PREF_CID); // factory classes static NS_DEFINE_IID(kIEditFactoryIID, NS_IEDITORFACTORY_IID); static NS_DEFINE_IID(kIHTMLEditFactoryIID, NS_IHTMLEDITORFACTORY_IID); static NS_DEFINE_IID(kITextEditFactoryIID, NS_ITEXTEDITORFACTORY_IID); - #ifdef XP_PC #define TRANSACTION_MANAGER_DLL "txmgr.dll" #else @@ -131,6 +133,8 @@ static NS_DEFINE_IID(kITextEditFactoryIID, NS_ITEXTEDITORFACTORY_IID); #define NS_ERROR_EDITOR_NO_SELECTION NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_EDITOR,1) #define NS_ERROR_EDITOR_NO_TEXTNODE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_EDITOR,2) +#define EDITOR_BUNDLE_URL "resource:/res/editor.properties" + const char* nsEditor::kMOZEditorBogusNodeAttr="MOZ_EDITOR_BOGUS_NODE"; const char* nsEditor::kMOZEditorBogusNodeValue="TRUE"; @@ -294,7 +298,7 @@ nsEditor::nsEditor() gInstanceCount++; mActionListeners = 0; PR_ExitMonitor(getEditorMonitor()); - + mPrefs = 0; } @@ -315,6 +319,10 @@ nsEditor::~nsEditor() delete mActionListeners; mActionListeners = 0; } + + // Release service pointers + if (mPrefs) + nsServiceManager::ReleaseService(kPrefCID, mPrefs); } @@ -456,6 +464,51 @@ nsEditor::Init(nsIDOMDocument *aDoc, nsIPresShell* aPresShell) caret->SetCaretVisible(PR_TRUE); caret->SetCaretReadOnly(PR_FALSE); } + // NOTE: We don't fail if we can't get prefs or string bundles + // since we could still be used as the text edit widget without prefs + + // Get the prefs service (Note: can't use nsCOMPtr for service pointers) + nsresult result = nsServiceManager::GetService(kPrefCID, + nsIPref::GetIID(), + (nsISupports**)&mPrefs); + if (NS_FAILED(result) || !mPrefs) + { + printf("ERROR: Failed to get Prefs Service instance.\n"); + } + // TODO: Cache basic preferences? + // Register callbacks for preferences that we need to + // respond to while running + + nsIStringBundleService* service; + result = nsServiceManager::GetService(kStringBundleServiceCID, + nsIStringBundleService::GetIID(), + (nsISupports**)&service); + + if (NS_SUCCEEDED(result) && service) + { + nsCOMPtr url; + result = NS_NewURL(getter_AddRefs(url), nsString(EDITOR_BUNDLE_URL)); + + if (NS_SUCCEEDED(result) && url) + { + nsILocale* locale = nsnull; + result = service->CreateBundle(url, locale, getter_AddRefs(mStringBundle)); + if (NS_FAILED(result)) + printf("ERROR: Failed to get Create StringBundle\n"); + + } else { + printf("ERROR: Failed to get create URL for StringBundle\n"); + } + // We don't need to keep service around once we created the bundle + nsServiceManager::ReleaseService(kStringBundleServiceCID, service); + } else { + printf("ERROR: Failed to get StringBundle Service instance.\n"); + } +/* + Example of getting a string: + nsString value; + ret = mStringBundle->GetStringFromName("editor.foo", value); +*/ mPresShell->SetCaretEnabled(PR_TRUE); @@ -3748,6 +3801,18 @@ nsEditor::JoinNodeDeep(nsIDOMNode *aLeftNode, return res; } +// Get a string from the localized string resources +nsresult nsEditor::GetString(const nsString& name, nsString& value) +{ + nsresult result = NS_ERROR_NOT_INITIALIZED; + value = ""; + if (mStringBundle && (name != "")) + { + result = mStringBundle->GetStringFromName(name, value); + } + return result; +} + /****************************************************************************** * nsAutoSelectionReset *****************************************************************************/ @@ -3776,6 +3841,3 @@ nsAutoSelectionReset::~nsAutoSelectionReset() } } - - - diff --git a/mozilla/editor/libeditor/base/nsEditor.h b/mozilla/editor/libeditor/base/nsEditor.h index d66f2e57a57..603969a5c2b 100644 --- a/mozilla/editor/libeditor/base/nsEditor.h +++ b/mozilla/editor/libeditor/base/nsEditor.h @@ -27,10 +27,10 @@ #include "nsIDOMEventListener.h" #include "nsIDOMRange.h" #include "nsCOMPtr.h" +#include "nsIStringBundle.h" #include "nsITransactionManager.h" #include "TransactionFactory.h" #include "nsIComponentManager.h" -#include "nsCOMPtr.h" class nsIEditActionListener; class nsIDOMCharacterData; @@ -48,6 +48,10 @@ class JoinElementTxn; class EditAggregateTxn; class nsVoidArray; class nsISupportsArray; +class nsIPref; +class nsIStringBundleService; +class nsIStringBundle; +class nsILocale; //This is the monitor for the editor. PRMonitor *getEditorMonitor(); @@ -72,9 +76,12 @@ private: static PRInt32 gInstanceCount; nsVoidArray *mActionListeners; + nsCOMPtr mStringBundle; protected: nsIDOMDocument * mDoc; + // Services are not nsCOMPtr friendly + nsIPref* mPrefs; public: @@ -494,7 +501,7 @@ public: static nsCOMPtr NextNodeInBlock(nsIDOMNode *aNode, IterDirection aDir); static nsresult GetStartNodeAndOffset(nsIDOMSelection *aSelection, nsCOMPtr *outStartNode, PRInt32 *outStartOffset); static nsresult GetEndNodeAndOffset(nsIDOMSelection *aSelection, nsCOMPtr *outEndNode, PRInt32 *outEndOffset); - + nsresult IsPreformatted(nsIDOMNode *aNode, PRBool *aResult); nsresult IsNextCharWhitespace(nsIDOMNode *aParentNode, PRInt32 aOffset, PRBool *aResult); nsresult IsPrevCharWhitespace(nsIDOMNode *aParentNode, PRInt32 aOffset, PRBool *aResult); @@ -502,6 +509,7 @@ public: nsresult SplitNodeDeep(nsIDOMNode *aNode, nsIDOMNode *aSplitPointParent, PRInt32 aSplitPointOffset); nsresult JoinNodeDeep(nsIDOMNode *aLeftNode, nsIDOMNode *aRightNode, nsIDOMSelection *aSelection); + nsresult GetString(const nsString& name, nsString& value); }; diff --git a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp index 73a23773c3e..d1a984a2115 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp @@ -1809,13 +1809,13 @@ nsHTMLEditor::CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement* if (aTagName == "" || !aReturn) return NS_ERROR_NULL_POINTER; - + nsAutoString TagName = aTagName; TagName.ToLowerCase(); nsAutoString realTagName; - PRBool isHREF = (TagName == "href"); - PRBool isAnchor = (TagName == "anchor"); + PRBool isHREF = (TagName.Equals("href")); + PRBool isAnchor = (TagName.Equals("anchor")); if (isHREF || isAnchor) { realTagName = "a"; @@ -1836,16 +1836,20 @@ nsHTMLEditor::CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement* // ATTRIBUTES SAVED IN PREFS? if (isAnchor) { + // TODO: Get the text of the selection and build a suggested Name // Replace spaces with "_" + } else if (TagName.Equals("hr")) + { + } + // ADD OTHER DEFAULT ATTRIBUTES HERE if (NS_SUCCEEDED(res)) { *aReturn = newElement; } - return res; } @@ -1876,15 +1880,12 @@ nsHTMLEditor::InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection, ns } } - DeleteSelectionAndPrepareToCreateNode(parentSelectedNode, offsetOfNewNode); + res = DeleteSelectionAndPrepareToCreateNode(parentSelectedNode, offsetOfNewNode); if (NS_SUCCEEDED(res)) { nsCOMPtr newNode = do_QueryInterface(aElement); - res = InsertNode(aElement, parentSelectedNode, offsetOfNewNode); - } - return res; } @@ -2164,8 +2165,19 @@ NS_IMETHODIMP nsHTMLEditor::GetLocalFileURL(nsIDOMWindow* aParent, const nsStrin nsCOMPtr fileWidget; - // TODO: WHERE TO WE PUT GLOBAL STRINGS TO BE LOCALIZED? - nsString title(htmlFilter ? "Open HTML file" : "Select Image File"); + nsAutoString title(""); + + // Get strings from editor resource bundle + nsString name; + if (htmlFilter) + { + name = "OpenHTMLFile"; + } else if (imgFilter) + { + name = "SelectImageFile"; + } + GetString(name, title); + nsFileSpec fileSpec; // TODO: GET THE DEFAULT DIRECTORY FOR DIFFERENT TYPES FROM PREFERENCES nsFileSpec aDisplayDirectory; diff --git a/mozilla/editor/ui/composer/content/EditorAppShell.xul b/mozilla/editor/ui/composer/content/EditorAppShell.xul index 7dc83f15b62..fd70a369f86 100644 --- a/mozilla/editor/ui/composer/content/EditorAppShell.xul +++ b/mozilla/editor/ui/composer/content/EditorAppShell.xul @@ -73,7 +73,7 @@ - + @@ -90,10 +90,12 @@ + + - - - + + + @@ -108,10 +110,34 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -119,10 +145,14 @@ - - - - + + + + + + + + @@ -168,11 +198,12 @@ - + + @@ -224,13 +255,15 @@ - - - - - - - + + + + + + + + + diff --git a/mozilla/editor/ui/composer/content/EditorCommands.js b/mozilla/editor/ui/composer/content/EditorCommands.js index b73efbc9f7f..fbc5546d998 100644 --- a/mozilla/editor/ui/composer/content/EditorCommands.js +++ b/mozilla/editor/ui/composer/content/EditorCommands.js @@ -5,11 +5,12 @@ var editorName = "EditorAppCore" + ( new Date() ).getTime().toString(); var appCore = null; var toolbar; +var contentWindow; function EditorStartup(editorType) { dump("Doing Startup...\n"); - + contentWindow = window.frames[0]; /* Get the global Editor AppCore and the XPFE toolkit core into globals here */ appCore = XPAppCoresManager.Find(editorName); dump("Looking up EditorAppCore...\n"); @@ -25,7 +26,7 @@ function EditorStartup(editorType) appCore.setToolbarWindow(window) appCore.setEditorType(editorType); - appCore.setContentWindow( window.frames[0] ); + appCore.setContentWindow(contentWindow); // Get url for editor content var url = document.getElementById("args").getAttribute("value"); @@ -39,8 +40,9 @@ function EditorStartup(editorType) } EditorSetup(editorName, appCore); - // Set focus to the edit window - window.focus(); + // Set focus to the editor content window + dump("Setting focus to content window\n"); + contentWindow.focus(); } function EditorSetup(p_editorName, p_appCore) @@ -87,6 +89,7 @@ function EditorOpen() { appCore.open(); } + contentWindow.focus(); } function EditorNewPlaintext() @@ -134,6 +137,7 @@ function EditorSave() { appCore.save(); } + contentWindow.focus(); } function EditorSaveAs() @@ -145,6 +149,7 @@ function EditorSaveAs() { appCore.saveAs(); } + contentWindow.focus(); } @@ -157,6 +162,7 @@ function EditorPrint() { appCore.print(); } + contentWindow.focus(); } function EditorClose() @@ -236,6 +242,7 @@ function EditorFind() if (appCore) { appCore.find(); } + contentWindow.focus(); } function EditorFindNext() @@ -243,6 +250,7 @@ function EditorFindNext() if (appCore) { appCore.findNext(); } + contentWindow.focus(); } function EditorShowClipboard() @@ -262,9 +270,8 @@ function EditorSetTextProperty(property, attribute, value) { if (appCore) { appCore.setTextProperty(property, attribute, value); - } - dump("Set text property -- calling focus()\n"); - window.focus(); + } + contentWindow.focus(); } function EditorSetParagraphFormat(paraFormat) @@ -272,15 +279,22 @@ function EditorSetParagraphFormat(paraFormat) if (appCore) { appCore.setParagraphFormat(paraFormat); } - window.focus(); + contentWindow.focus(); } function EditorSetFontSize(size) { if (appCore) { - appCore.setTextProperty("font", "size", size); + if( size == "0" || size == "normal" || + size === "+0" ) + { + appCore.removeTextProperty("font", size); + dump("Removing font size\n"); + } else { + dump("Setting font size\n"); + appCore.setTextProperty("font", "size", size); + } } - window.focus(); } function EditorSetFontFace(fontFace) @@ -294,7 +308,7 @@ function EditorSetFontFace(fontFace) } appCore.setTextProperty("font", "face", fontFace); } - window.focus(); + contentWindow.focus(); } function EditorSetFontColor(color) @@ -302,13 +316,13 @@ function EditorSetFontColor(color) if (appCore) { appCore.setTextProperty("font", "color", color); } - window.focus(); + contentWindow.focus(); } function EditorSetBackgroundColor(color) { appCore.setBackgroundColor(color); - window.focus(); + contentWindow.focus(); } function EditorApplyStyle(styleName) @@ -316,8 +330,9 @@ function EditorApplyStyle(styleName) if (appCore) { dump("Applying Style\n"); appCore.setTextProperty(styleName, null, null); + dump("Restore focus to editor window: "+window.frames[0]+"\n"); } - window.focus(); + contentWindow.focus(); } function EditorRemoveStyle(styleName) @@ -326,7 +341,11 @@ function EditorRemoveStyle(styleName) dump("Removing Style\n"); appCore.removeTextProperty(styleName, null); } - window.focus(); + contentWindow.focus(); +} +function EditorRemoveLinks() +{ + dump("NOT IMPLEMENTED YET\n"); } // --------------------------- Output --------------------------- @@ -359,11 +378,43 @@ function EditorInsertText() function EditorInsertLink() { - dump("Starting Insert Link...\n"); if (appCore) { - dump("Link Properties Dialog starting...\n"); window.openDialog("chrome://editordlgs/content/EdLinkProps.xul", "LinkDlg", "chrome", editorName); } + contentWindow.focus(); +} + +function EditorInsertImage() +{ + if (appCore) { + window.openDialog("chrome://editordlgs/content/EdImageProps.xul", "dlg", "chrome", editorName); + } + contentWindow.focus(); +} + +function EditorInsertHLine() +{ + if (appCore) { + window.openDialog("chrome://editordlgs/content/EdHLineProps.xul", "dlg", "chrome", editorName); + } + contentWindow.focus(); +} + +function EditorInsertNamedAnchor() +{ + if (appCore) { + window.openDialog("chrome://editordlgs/content/EdNamedAnchorProps.xul", "dlg", "chrome", editorName); + } + contentWindow.focus(); +} + +function EditorIndent(indent) +{ + dump("indenting\n"); + if (appCore) { + appCore.indent(indent); + } + contentWindow.focus(); } @@ -374,22 +425,7 @@ function EditorInsertList(listType) appCore.insertList(listType); dump("\n"); } -} - -function EditorInsertImage() -{ - if (appCore) { - dump("Image Properties Dialog starting. Editor Name="+editorName+"\n"); - window.openDialog("chrome://editordlgs/content/EdImageProps.xul", "dlg", "chrome", editorName); - } -} - -function EditorIndent(indent) -{ - dump("indenting\n"); - if (appCore) { - appCore.indent(indent); - } + contentWindow.focus(); } function EditorAlign(align) @@ -398,6 +434,7 @@ function EditorAlign(align) if (appCore) { appCore.align(align); } + contentWindow.focus(); } @@ -506,7 +543,6 @@ function OpenFile(url) } else { dump("Error; can't create toolkitCore\n"); } - window.focus(); } // --------------------------- Status calls --------------------------- diff --git a/mozilla/editor/ui/composer/content/Makefile.in b/mozilla/editor/ui/composer/content/Makefile.in index a17ba8007d0..9436ae23e36 100644 --- a/mozilla/editor/ui/composer/content/Makefile.in +++ b/mozilla/editor/ui/composer/content/Makefile.in @@ -34,6 +34,10 @@ EXPORT_RESOURCE_CONTENT = \ $(srcdir)/EditorInitPagePlain.html \ $(NULL) +EXPORT_STRING_CONTENT = \ + $(srcdir)/editor.properties \ + $(NULL) + install:: $(INSTALL) $(EXPORT_RESOURCE_CONTENT) $(DIST)/bin/chrome/editor/composer/content/default - + $(INSTALL) $(EXPORT_STRING_CONTENT) $(DIST)/bin/res diff --git a/mozilla/editor/ui/composer/content/makefile.win b/mozilla/editor/ui/composer/content/makefile.win index 5ca7fadf83f..191d15b6b94 100644 --- a/mozilla/editor/ui/composer/content/makefile.win +++ b/mozilla/editor/ui/composer/content/makefile.win @@ -24,9 +24,11 @@ install:: $(MAKE_INSTALL) EditorCommands.js $(DIST)\bin\chrome\editor\composer\content\default $(MAKE_INSTALL) EditorInitPage.html $(DIST)\bin\chrome\editor\composer\content\default $(MAKE_INSTALL) EditorInitPagePlain.html $(DIST)\bin\chrome\editor\composer\content\default + $(MAKE_INSTALL) editor.properties $(DIST)\bin\res clobber:: rm -f $(DIST)\bin\chrome\editor\composer\content\default\EditorAppShell.xul rm -f $(DIST)\bin\chrome\editor\composer\content\default\EditorCommands.js rm -f $(DIST)\bin\chrome\editor\composer\content\default\EditorInitPage.html rm -f $(DIST)\bin\chrome\editor\composer\content\default\EditorInitPagePlain.html + rm -f $(DIST)\bin\res\editor.properties diff --git a/mozilla/editor/ui/composer/skin/Editor.css b/mozilla/editor/ui/composer/skin/Editor.css index 02485f4eaeb..425b26e88be 100644 --- a/mozilla/editor/ui/composer/skin/Editor.css +++ b/mozilla/editor/ui/composer/skin/Editor.css @@ -1,9 +1,3 @@ -/* These are critical - should be in xul.css */ -window#main-window { - width: 100%; - height: 100%; -} - box#outer-box { width: 100%; height: 100%; @@ -28,31 +22,10 @@ select.combobox { //background: silver; } -select[pseudoclass~="hover"] { -/* NOT WORKING */ - background: red; -} - -/* Make the buttons butt up against each other - Bug: When hover over, width decreases by 1 pixel, - causing horizontal jump for rest of controls in toolbar -*/ titledbutton#TextColorPopup { margin-right: -2px; - border-right: 0px; } + titledbutton#BackColorPopup { margin-left: -2px; - border-left: 0px; -} - -/* trying to fix hover width problem, but hover detection not working */ -titledbutton#TextColorPopup[pseudoclass~="hover"] { - margin-right: -1px; - border-right: 0px; -} - -titledbutton#BackColorPopup[pseudoclass~="hover"] { - margin-left: -1px; - border-left: 0px; } diff --git a/mozilla/editor/ui/composer/skin/images/ED_BackColor.gif b/mozilla/editor/ui/composer/skin/images/ED_BackColor.gif index 6166016dec4..c468297585d 100644 Binary files a/mozilla/editor/ui/composer/skin/images/ED_BackColor.gif and b/mozilla/editor/ui/composer/skin/images/ED_BackColor.gif differ diff --git a/mozilla/editor/ui/composer/skin/images/ED_TextColor.gif b/mozilla/editor/ui/composer/skin/images/ED_TextColor.gif index bc41f041330..c67f00eda36 100644 Binary files a/mozilla/editor/ui/composer/skin/images/ED_TextColor.gif and b/mozilla/editor/ui/composer/skin/images/ED_TextColor.gif differ diff --git a/mozilla/editor/ui/dialogs/content/EdDialogCommon.js b/mozilla/editor/ui/dialogs/content/EdDialogCommon.js index 6eb105c4dda..fd17c6d7f76 100644 --- a/mozilla/editor/ui/dialogs/content/EdDialogCommon.js +++ b/mozilla/editor/ui/dialogs/content/EdDialogCommon.js @@ -21,3 +21,9 @@ function AppendStringToList(list, string) dump("Failed to create OPTION node. String content="+string+"\n"); } } + +// All dialogs share this simple method +function onCancel() +{ + window.close(); +} diff --git a/mozilla/editor/ui/dialogs/content/EdHLineProps.js b/mozilla/editor/ui/dialogs/content/EdHLineProps.js new file mode 100644 index 00000000000..8e209389e6b --- /dev/null +++ b/mozilla/editor/ui/dialogs/content/EdHLineProps.js @@ -0,0 +1,38 @@ +var appCore; +var toolkitCore; +var insertNew = true; + +// dialog initialization code +function Startup() +{ + dump("Doing Startup...\n"); + // New method: parameters passed via window.openDialog, which puts + // arguments in the array "arguments" + var editorName = window.arguments[0]; + dump("Got editorAppCore called " + editorName + "\n"); + + // NEVER create an appcore here - we must find parent editor's + appCore = XPAppCoresManager.Find(editorName); + if(!appCore) { + dump("EditorAppCore not found!!!\n"); + window.close(); + return; + } + dump("EditorAppCore found for HRule Properties dialog\n"); + + // Create dialog object to store controls for easy access + dialog = new Object; + // GET EACH CONTROL -- E.G.: + //dialog.editBox = document.getElementById("editBox"); + // Can we get at just the edit field? + dialog.AltText = document.getElementById("image.AltText"); + + //initDialog(); + + // SET FOCUS TO FIRST CONTROL + //dialog.editBox.focus(); +} + +function OnOK() +{ +} diff --git a/mozilla/editor/ui/dialogs/content/EdHLineProps.xul b/mozilla/editor/ui/dialogs/content/EdHLineProps.xul new file mode 100644 index 00000000000..985e8c292b9 --- /dev/null +++ b/mozilla/editor/ui/dialogs/content/EdHLineProps.xul @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + +
+
Dimensions + + + + + + + + + + +
+ Height: + + +
+ Width: + + + + +
+
+
+
Alignment + + + +
+
+ + + +
+ + +
+
diff --git a/mozilla/editor/ui/dialogs/content/EdImageProps.js b/mozilla/editor/ui/dialogs/content/EdImageProps.js index e5386bfa846..1b28b51eac9 100644 --- a/mozilla/editor/ui/dialogs/content/EdImageProps.js +++ b/mozilla/editor/ui/dialogs/content/EdImageProps.js @@ -1,20 +1,16 @@ -// OnOK(), Undo(), and Cancel() are in EdDialogCommon.js -// applyChanges() must be implemented here - var appCore; var insertNew = true; var imageWasInserted = false; -var undoCount = 0; var imageElement; var tagName = "img" -var advanced = false; +var advanced = true; // dialog initialization code function Startup() { dump("Doing Startup...\n"); - // New metho: parameters passed via window.openDialog, which puts + // New method: parameters passed via window.openDialog, which puts // arguments in the array "arguments" var editorName = window.arguments[0]; dump("Got editorAppCore called " + editorName + "\n"); @@ -37,9 +33,14 @@ function Startup() dialog.AdvancedButton = document.getElementById("AdvancedButton"); dialog.AdvancedRow = document.getElementById("AdvancedRow"); - // Start in "basic" mode - dialog.AdvancedRow.style.display = "none"; - + // Start in the mode initialized in the "advanced" var above + // THIS IS NOT WORKING NOW - After switching to "basic" mode, + // then back to + if (advanced) { + dialog.AdvancedRow.style.visibility = "visible"; + } else { + dialog.AdvancedRow.style.visibility = "collapse"; + } if (null == dialog.srcInput || null == dialog.altTextInput ) @@ -91,48 +92,38 @@ function chooseFile() function onAdvanced() { - if (dialog.AdvancedRow) { - dump("AdvancedRow still exists ****\n"); - } - if (advanced) { dump("Changing to BASIC mode\n"); advanced = false; // BUG: This works to hide the row, but // setting visibility to "show" doesn't bring it back - //dialog.AdvancedRow.style.visibility = "collapse"; - dialog.AdvancedRow.style.display = "none"; + dialog.AdvancedRow.style.visibility = "collapse"; + //dialog.AdvancedRow.style.display = "none"; } else { dump("Changing to ADVANCED mode\n"); advanced = true; - dialog.AdvancedRow.style.display = "table-row"; + //dialog.AdvancedRow.style.display = "table-row"; + dialog.AdvancedRow.style.visibility = "visible"; } } -function onOK() { - if (applyChanges()) { - if (imageWasInserted) { - // We selected the object, undo it by - // setting caret to just after the inserted element - appCore.setCaretAfterElement(imageElement); - } - window.close(); - } +function SelectWidthUnits() +{ + list = document.getElementByID("WidthUnits"); + value = list.options[list.selectedIndex].value; + dump("Selected item: "+value+"\n"); } -function onCancel() { - // Undo all actions performed within the dialog - // TODO: We need to suppress reflow/redraw untill all levels are undone - while (undoCount > 0) { - onUndo(); - } - window.close(); +function OnChangeSrc() +{ + dump("*** Changed SRC field\n"); } -function applyChanges() +function onOK() { // TODO: BE SURE Src AND AltText are completed! + imageElement.setAttribute("src",dialog.srcInput.value); // We must convert to "file:///" format else image doesn't load! imageElement.setAttribute("alt",dialog.altTextInput.value); @@ -145,9 +136,10 @@ function applyChanges() // when dialog closes imageWasInserted = true; } - // Reinitialize dialog data - initDialog(); - - // TODO: Return false if any data validation tests fail - return true; -} \ No newline at end of file + if (imageWasInserted) { + // We selected the object, undo it by + // setting caret to just after the inserted element + appCore.setCaretAfterElement(imageElement); + } + window.close(); +} diff --git a/mozilla/editor/ui/dialogs/content/EdImageProps.xul b/mozilla/editor/ui/dialogs/content/EdImageProps.xul index 5631beba261..6f10371fcbe 100644 --- a/mozilla/editor/ui/dialogs/content/EdImageProps.xul +++ b/mozilla/editor/ui/dialogs/content/EdImageProps.xul @@ -22,11 +22,11 @@
Image Information

Enter a remote URL or local file:

- +

Alternative Text

- +
@@ -40,19 +40,24 @@
Dimensions - Put size controls here +
Spacing - Put spacing controls here + Put spacing controls here
+ + Radio button + Checkbox
- diff --git a/mozilla/editor/ui/dialogs/content/EdLinkProps.js b/mozilla/editor/ui/dialogs/content/EdLinkProps.js index e708913d6f5..61c1b8c3921 100644 --- a/mozilla/editor/ui/dialogs/content/EdLinkProps.js +++ b/mozilla/editor/ui/dialogs/content/EdLinkProps.js @@ -1,12 +1,8 @@ -// OnOK(), Undo(), and Cancel() are in EdDialogCommon.js -// applyChanges() must be implemented here - var appCore; var anchorElement = null; var insertNew = true; var needLinkText = false; var selection; -var undoCount = 0; var insertLinkAroundSelection = false; // NOTE: Use "HREF" instead of "A" to distinguish from Named Anchor @@ -127,23 +123,10 @@ function chooseFile() dialog.hrefInput.focus(); } -function onOK() { - if (applyChanges()) { - window.close(); - } -} - -function onCancel() { - // Undo all actions performed within the dialog - // TODO: We need to suppress reflow/redraw untill all levels are undone - while (undoCount > 0) { - onUndo(); - } - window.close(); -} - -function applyChanges() +function onOK() { + // TODO: VALIDATE FIELDS BEFORE COMMITING CHANGES + // Coalesce into one undo transaction appCore.beginBatchChanges(); @@ -167,12 +150,8 @@ function applyChanges() dump("Setting link around selected text\n"); appCore.insertLinkAroundSelection(anchorElement); } - undoCount = undoCount + 1; appCore.endBatchChanges(); - // Reinitialize dialog data - initDialog(); - - // TODO: Return false if any data validation tests fail - return true; + window.close(); } + diff --git a/mozilla/editor/ui/dialogs/content/EdLinkProps.xul b/mozilla/editor/ui/dialogs/content/EdLinkProps.xul index 6ca5324107a..5f5af31a200 100644 --- a/mozilla/editor/ui/dialogs/content/EdLinkProps.xul +++ b/mozilla/editor/ui/dialogs/content/EdLinkProps.xul @@ -37,7 +37,6 @@ - diff --git a/mozilla/editor/ui/dialogs/content/EdSpellCheck.js b/mozilla/editor/ui/dialogs/content/EdSpellCheck.js index 043a6788c9e..2632270aaaa 100644 --- a/mozilla/editor/ui/dialogs/content/EdSpellCheck.js +++ b/mozilla/editor/ui/dialogs/content/EdSpellCheck.js @@ -152,11 +152,6 @@ function Close() window.close(); } -function Help() -{ - dump("SpellCheck: Help me Rhonda, help, help me Rhonda\n"); -} - function FillSuggestedList(firstWord) { list = dialog.suggestedList; diff --git a/mozilla/editor/ui/dialogs/content/EdSpellCheck.xul b/mozilla/editor/ui/dialogs/content/EdSpellCheck.xul index bbb386d5605..6e15c08dc3c 100644 --- a/mozilla/editor/ui/dialogs/content/EdSpellCheck.xul +++ b/mozilla/editor/ui/dialogs/content/EdSpellCheck.xul @@ -83,7 +83,7 @@ - +