зеркало из https://github.com/mozilla/pjs.git
Fixed bug in HLine code. Replaced itoa with PR_snprintf
This commit is contained in:
Родитель
920ec7a2f0
Коммит
68843366e1
|
@ -48,6 +48,7 @@
|
|||
#include "nsIPref.h"
|
||||
#include "nsIDOMDocumentFragment.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "prprf.h"
|
||||
|
||||
#ifdef ENABLE_JS_EDITOR_LOG
|
||||
#include "nsJSEditorLog.h"
|
||||
|
@ -2159,22 +2160,24 @@ nsHTMLEditor::CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement*
|
|||
{
|
||||
char buf[16];
|
||||
PRInt32 iAlign;
|
||||
// Currently using 0=left, 1=center, and 2=right
|
||||
if( NS_SUCCEEDED(mPrefs->GetIntPref("editor.hrule.align", &iAlign)))
|
||||
{
|
||||
switch (iAlign) {
|
||||
case 1:
|
||||
case 0:
|
||||
align = "left";
|
||||
break;
|
||||
case 3:
|
||||
case 2:
|
||||
align = "right";
|
||||
break;
|
||||
}
|
||||
}
|
||||
PRInt32 iHeight;
|
||||
PRUint32 count;
|
||||
if( NS_SUCCEEDED(mPrefs->GetIntPref("editor.hrule.height", &iHeight)))
|
||||
{
|
||||
itoa(iHeight, buf, 16);
|
||||
if (buf)
|
||||
count = PR_snprintf(buf, 16, "%d", iHeight);
|
||||
if (count > 0)
|
||||
{
|
||||
height = buf;
|
||||
}
|
||||
|
@ -2184,8 +2187,8 @@ nsHTMLEditor::CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement*
|
|||
if( NS_SUCCEEDED(mPrefs->GetIntPref("editor.hrule.width", &iWidth)) &&
|
||||
NS_SUCCEEDED(mPrefs->GetBoolPref("editor.hrule.width_percent", &bPercent)))
|
||||
{
|
||||
itoa(iWidth, buf, 16);
|
||||
if (buf)
|
||||
count = PR_snprintf(buf, 16, "%d", iWidth);
|
||||
if (count > 0)
|
||||
{
|
||||
width = buf;
|
||||
if (bPercent)
|
||||
|
@ -2287,7 +2290,7 @@ nsHTMLEditor::SaveHLineSettings(nsIDOMElement* aElement)
|
|||
char widthChar[32] = {""};
|
||||
PRInt32 iWidth = atoi(width.ToCString(widthChar, 32));
|
||||
if (iWidth > 0) {
|
||||
mPrefs->SetIntPref("editor.hrule.height", iWidth);
|
||||
mPrefs->SetIntPref("editor.hrule.width", iWidth);
|
||||
mPrefs->SetBoolPref("editor.hrule.width_percent", (width.Find("%") > 0));
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "nsIPref.h"
|
||||
#include "nsIDOMDocumentFragment.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "prprf.h"
|
||||
|
||||
#ifdef ENABLE_JS_EDITOR_LOG
|
||||
#include "nsJSEditorLog.h"
|
||||
|
@ -2159,22 +2160,24 @@ nsHTMLEditor::CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement*
|
|||
{
|
||||
char buf[16];
|
||||
PRInt32 iAlign;
|
||||
// Currently using 0=left, 1=center, and 2=right
|
||||
if( NS_SUCCEEDED(mPrefs->GetIntPref("editor.hrule.align", &iAlign)))
|
||||
{
|
||||
switch (iAlign) {
|
||||
case 1:
|
||||
case 0:
|
||||
align = "left";
|
||||
break;
|
||||
case 3:
|
||||
case 2:
|
||||
align = "right";
|
||||
break;
|
||||
}
|
||||
}
|
||||
PRInt32 iHeight;
|
||||
PRUint32 count;
|
||||
if( NS_SUCCEEDED(mPrefs->GetIntPref("editor.hrule.height", &iHeight)))
|
||||
{
|
||||
itoa(iHeight, buf, 16);
|
||||
if (buf)
|
||||
count = PR_snprintf(buf, 16, "%d", iHeight);
|
||||
if (count > 0)
|
||||
{
|
||||
height = buf;
|
||||
}
|
||||
|
@ -2184,8 +2187,8 @@ nsHTMLEditor::CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement*
|
|||
if( NS_SUCCEEDED(mPrefs->GetIntPref("editor.hrule.width", &iWidth)) &&
|
||||
NS_SUCCEEDED(mPrefs->GetBoolPref("editor.hrule.width_percent", &bPercent)))
|
||||
{
|
||||
itoa(iWidth, buf, 16);
|
||||
if (buf)
|
||||
count = PR_snprintf(buf, 16, "%d", iWidth);
|
||||
if (count > 0)
|
||||
{
|
||||
width = buf;
|
||||
if (bPercent)
|
||||
|
@ -2287,7 +2290,7 @@ nsHTMLEditor::SaveHLineSettings(nsIDOMElement* aElement)
|
|||
char widthChar[32] = {""};
|
||||
PRInt32 iWidth = atoi(width.ToCString(widthChar, 32));
|
||||
if (iWidth > 0) {
|
||||
mPrefs->SetIntPref("editor.hrule.height", iWidth);
|
||||
mPrefs->SetIntPref("editor.hrule.width", iWidth);
|
||||
mPrefs->SetBoolPref("editor.hrule.width_percent", (width.Find("%") > 0));
|
||||
}
|
||||
|
||||
|
|
|
@ -9,8 +9,6 @@ var shading = true;
|
|||
// dialog initialization code
|
||||
function Startup()
|
||||
{
|
||||
dump("Doing Startup...\n");
|
||||
|
||||
// get the editor shell from the parent window
|
||||
editorShell = window.opener.editorShell;
|
||||
editorShell = editorShell.QueryInterface(Components.interfaces.nsIEditorShell);
|
||||
|
@ -19,15 +17,21 @@ function Startup()
|
|||
window.close();
|
||||
return;
|
||||
}
|
||||
|
||||
dump("HLINE PROPS 1\n");
|
||||
|
||||
// Get the selected horizontal line
|
||||
hLineElement = window.editorShell.GetSelectedElement(tagName);
|
||||
|
||||
dump("HLINE PROPS 2\n");
|
||||
|
||||
if (!hLineElement) {
|
||||
// We should never be here if not editing an existing HLine
|
||||
dump("HLine is not selected! Shouldn't be here!\n");
|
||||
window.close();
|
||||
return;
|
||||
}
|
||||
dump("HLINE PROPS 3\n");
|
||||
|
||||
// Create dialog object to store controls for easy access
|
||||
dialog = new Object;
|
||||
|
@ -39,10 +43,7 @@ function Startup()
|
|||
dialog.shading = document.getElementById("3dShading");
|
||||
dialog.pixelOrPercentButton = document.getElementById("pixelOrPercentButton");
|
||||
|
||||
dump(dialog.heightInput+dialog.widthInput+dialog.shading+dialog.pixelOrPercentButton+"\n");
|
||||
//dump("PixelOrPercent value="+dialog.pixelOrPercentButton.value+"\n");
|
||||
//dump("PixelOrPercent name="+dialog.pixelOrPercentButton.name+"\n");
|
||||
|
||||
dump("HLINE PROPS 4\n");
|
||||
// Initialize control values based on existing attributes
|
||||
|
||||
dialog.heightInput.value = hLineElement.getAttribute("height");
|
||||
|
@ -50,12 +51,16 @@ function Startup()
|
|||
// Use convert to number, then back to string to strip of "%"
|
||||
dialog.widthInput.value = (width - 0) + "";
|
||||
|
||||
dump("HLINE PROPS 5\n");
|
||||
|
||||
// This assumes initial button text is "pixels"
|
||||
if (width.search(/%/) > 0) {
|
||||
dialog.pixelOrPercentButton.value = "percent";
|
||||
percentChar = "%";
|
||||
}
|
||||
|
||||
dump("HLINE PROPS 6\n");
|
||||
|
||||
align = hLineElement.getAttribute("align");
|
||||
if (align == "center") {
|
||||
dialog.centerAlign.checked = true;
|
||||
|
@ -68,6 +73,7 @@ function Startup()
|
|||
dump("Width ="+width+" Align ="+align+" NoShade="+noshade+"\n");
|
||||
dialog.shading.checked = (noshade == "");
|
||||
|
||||
dump("HLINE PROPS 3\n");
|
||||
// SET FOCUS TO FIRST CONTROL
|
||||
dialog.heightInput.focus();
|
||||
}
|
||||
|
@ -150,5 +156,6 @@ function OnOK()
|
|||
{
|
||||
if (ValidateData()) {
|
||||
window.close();
|
||||
dump("CLOSING EdHLineProps\n");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,11 +59,14 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" align="right">
|
||||
<td colspan="2">
|
||||
<hr width="100%"/>
|
||||
<button class="spaced" id="Advanced" onclick="onAdvanced()">Advanced Attributes</button>
|
||||
<button class="spaced" id="OK" onclick="onOK()">OK</button>
|
||||
<button class="spaced" id="Cancel" onclick="onCancel()" width="50">Cancel</button>
|
||||
<xul:box align="horizontal" id="status-bar">
|
||||
<button class="spaced" id="Advanced" onclick="onAdvanced()">Advanced Attributes</button>
|
||||
<xul:spring flex="100%"/>
|
||||
<button class="spaced" id="OK" onclick="onOK()">OK</button>
|
||||
<button class="spaced" id="Cancel" onclick="onCancel()" width="50">Cancel</button>
|
||||
</xul:box>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
Загрузка…
Ссылка в новой задаче