void LogDebug(const wchar_t *fmt, ...) { CAutoLock logLock(&m_logLock); if (!m_hLogger) { m_bLoggerRunning = true; StartLogger(); } wchar_t buffer[2000]; int tmp; va_list ap; va_start(ap,fmt); tmp = vswprintf_s(buffer, fmt, ap); va_end(ap); SYSTEMTIME systemTime; GetLocalTime(&systemTime); wchar_t msg[5000]; swprintf_s(msg, 5000,L"[%04.4d-%02.2d-%02.2d %02.2d:%02.2d:%02.2d,%03.3d] [%x] [%x] - %s\n", systemTime.wYear, systemTime.wMonth, systemTime.wDay, systemTime.wHour, systemTime.wMinute, systemTime.wSecond, systemTime.wMilliseconds, (unsigned int)instanceID, GetCurrentThreadId(), buffer); CAutoLock l(&m_qLock); if (m_logQueue.size() < 2000) { m_logQueue.push((wstring)msg); } };
NS_IMETHODIMP nsHTMLEditorLog::RemoveInlineProperty(nsIAtom *aProperty, const nsAString &aAttribute) { nsAutoHTMLEditorLogLock logLock(this); if (!mLocked && mFileStream) { nsAutoString propStr; aProperty->ToString(propStr); PrintSelection(); Write("atomService = Components.classes[\"@mozilla.org/atom-service;1\"].getService(Components.interfaces.nsIAtomService);\n"); Write("propAtom = atomService.getAtom(\""); PrintUnicode(propStr); Write("\");\n"); Write("GetCurrentEditor().removeInlineProperty(propAtom, \""); if (aAttribute.Length()) PrintUnicode(aAttribute); Write("\");\n"); Flush(); } return nsHTMLEditor::RemoveInlineProperty(aProperty, aAttribute); }
NS_IMETHODIMP nsHTMLEditorLog::EndOfDocument() { nsAutoHTMLEditorLogLock logLock(this); if (!mLocked && mFileStream) { Write("GetCurrentEditor().endOfDocument();\n"); Flush(); } return nsHTMLEditor::EndOfDocument(); }
NS_IMETHODIMP nsHTMLEditorLog::BeginTransaction() { nsAutoHTMLEditorLogLock logLock(this); if (!mLocked && mFileStream) { Write("GetCurrentEditor().beginTransaction();\n"); Flush(); } return nsHTMLEditor::BeginTransaction(); }
NS_IMETHODIMP nsHTMLEditorLog:: SplitTableCell() { nsAutoHTMLEditorLogLock logLock(this); if (!mLocked && mFileStream) { Write("GetCurrentEditor().splitTableCell();\n"); Flush(); } return nsHTMLEditor::SplitTableCell(); }
NS_IMETHODIMP nsHTMLEditorLog::Copy() { nsAutoHTMLEditorLogLock logLock(this); if (!mLocked && mFileStream) { PrintSelection(); Write("GetCurrentEditor().copy();\n"); Flush(); } return nsHTMLEditor::Copy(); }
NS_IMETHODIMP nsHTMLEditorLog::SetBackgroundColor(const nsAString& aColor) { nsAutoHTMLEditorLogLock logLock(this); if (!mLocked && mFileStream) { Write("GetCurrentEditor().setBackgroundColor(\""); PrintUnicode(aColor); Write("\");\n"); Flush(); } return nsHTMLEditor::SetBackgroundColor(aColor); }
NS_IMETHODIMP nsHTMLEditorLog:: DeleteTableRow(int32_t aNumber) { nsAutoHTMLEditorLogLock logLock(this); if (!mLocked && mFileStream) { Write("GetCurrentEditor().deleteTableRow("); WriteInt(aNumber); Write(");\n"); Flush(); } return nsHTMLEditor::DeleteTableRow(aNumber); }
NS_IMETHODIMP nsHTMLEditorLog::Redo(uint32_t aCount) { nsAutoHTMLEditorLogLock logLock(this); if (!mLocked && mFileStream) { Write("GetCurrentEditor().redo("); WriteInt(aCount); Write(");\n"); Flush(); } return nsHTMLEditor::Redo(aCount); }
NS_IMETHODIMP nsHTMLEditorLog:: JoinTableCells(bool aMergeNonContiguousContents) { nsAutoHTMLEditorLogLock logLock(this); if (!mLocked && mFileStream) { Write("GetCurrentEditor().joinTableCells("); Write(aMergeNonContiguousContents ? "true" : "false"); Write(");\n"); Flush(); } return nsHTMLEditor::JoinTableCells(aMergeNonContiguousContents); }
NS_IMETHODIMP nsHTMLEditorLog::PasteAsPlaintextQuotation(int32_t aClipboardType) { nsAutoHTMLEditorLogLock logLock(this); if (!mLocked && mFileStream) { PrintSelection(); Write("GetCurrentEditor().pasteAsQuotation("); WriteInt(aClipboardType); Write(");\n"); Flush(); } return nsHTMLEditor::PasteAsPlaintextQuotation(aClipboardType); }
NS_IMETHODIMP nsHTMLEditorLog::SetBodyAttribute(const nsAString& aAttr, const nsAString& aValue) { nsAutoHTMLEditorLogLock logLock(this); if (!mLocked && mFileStream) { Write("GetCurrentEditor().setBodyAttribute(\""); PrintUnicode(aAttr); Write("\", \""); PrintUnicode(aValue); Write("\");\n"); Flush(); } return nsHTMLEditor::SetBodyAttribute(aAttr, aValue); }
NS_IMETHODIMP nsHTMLEditorLog::InsertAsQuotation(const nsAString& aQuotedText, nsIDOMNode **aNodeInserted) { nsAutoHTMLEditorLogLock logLock(this); if (!mLocked && mFileStream) { PrintSelection(); Write("GetCurrentEditor().insertAsQuotation(\""); PrintUnicode(aQuotedText); Write("\");\n"); Flush(); } return nsHTMLEditor::InsertAsQuotation(aQuotedText, aNodeInserted); }
NS_IMETHODIMP nsHTMLEditorLog:: InsertTableRow(int32_t aNumber, bool aAfter) { nsAutoHTMLEditorLogLock logLock(this); if (!mLocked && mFileStream) { Write("GetCurrentEditor().insertTableRow("); WriteInt(aNumber); Write(", "); Write(aAfter ? "true" : "false"); Write(");\n"); Flush(); } return nsHTMLEditor::InsertTableRow(aNumber, aAfter); }
NS_IMETHODIMP nsHTMLEditorLog::Align(const nsAString& aAlign) { nsAutoHTMLEditorLogLock logLock(this); if (!mLocked && mFileStream) { PrintSelection(); Write("GetCurrentEditor().align(\""); PrintUnicode(aAlign); Write("\");\n"); Flush(); } return nsHTMLEditor::Align(aAlign); }
NS_IMETHODIMP nsHTMLEditorLog::SwitchTableCellHeaderType(nsIDOMElement *aSourceCell, nsIDOMElement **aNewCell) { nsAutoHTMLEditorLogLock logLock(this); if (!mLocked && mFileStream) { nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aSourceCell); NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER); PrintNode(node, 0); Write("GetCurrentEditor().switchTableCellHeaderType(n0);\n"); Flush(); } return nsHTMLEditor::SwitchTableCellHeaderType(aSourceCell, aNewCell); }
NS_IMETHODIMP nsHTMLEditorLog::SetParagraphFormat(const nsAString& aParagraphFormat) { nsAutoHTMLEditorLogLock logLock(this); if (!mLocked && mFileStream) { PrintSelection(); Write("GetCurrentEditor().setParagraphFormat(\""); PrintUnicode(aParagraphFormat); Write("\");\n"); Flush(); } return nsHTMLEditor::SetParagraphFormat(aParagraphFormat); }
NS_IMETHODIMP nsHTMLEditorLog:: NormalizeTable(nsIDOMElement *aTable) { nsAutoHTMLEditorLogLock logLock(this); if (!mLocked && mFileStream) { nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aTable); NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER); PrintNode(node, 0); Write("GetCurrentEditor().normalizeTable(n0);\n"); Flush(); } return nsHTMLEditor::NormalizeTable(aTable); }
void StopLogger() { CAutoLock logLock(&m_logLock); if (m_hLogger) { //Make sure the thread runs soon so it can finish processing SetThreadPriority(m_hLogger, THREAD_PRIORITY_NORMAL); m_bLoggerRunning = FALSE; m_EndLoggingEvent.Set(); WaitForSingleObject(m_hLogger, INFINITE); m_EndLoggingEvent.Reset(); CloseHandle(m_hLogger); m_hLogger = NULL; logFileParsed = -1; logFileDate = -1; instanceID = 0; } }
NS_IMETHODIMP nsHTMLEditorLog::SetDocumentTitle(const nsAString& aTitle) { nsAutoHTMLEditorLogLock logLock(this); if (!mLocked && mFileStream) { PrintSelection(); Write("GetCurrentEditor().setDocumentTitle(\""); nsAutoString str(aTitle); PrintUnicode(str); Write("\");\n"); Flush(); } return nsHTMLEditor::SetDocumentTitle(aTitle); }
NS_IMETHODIMP nsHTMLEditorLog::DeleteSelection(nsIEditor::EDirection aAction, nsIEditor::EStripWrappers aStripWrappers) { nsAutoHTMLEditorLogLock logLock(this); if (!mLocked && mFileStream) { PrintSelection(); Write("GetCurrentEditor().deleteSelection("); WriteInt(aAction); Write(");\n"); Flush(); } return nsHTMLEditor::DeleteSelection(aAction, aStripWrappers); }
NS_IMETHODIMP nsHTMLEditorLog::InsertText(const nsAString& aStringToInsert) { nsAutoHTMLEditorLogLock logLock(this); if (!mLocked && mFileStream) { PrintSelection(); Write("GetCurrentEditor().insertText(\""); nsAutoString str(aStringToInsert); PrintUnicode(str); Write("\");\n"); Flush(); } return nsHTMLEditor::InsertText(aStringToInsert); }
NS_IMETHODIMP nsHTMLEditorLog::PasteAsCitedQuotation(const nsAString& aCitation, int32_t aClipboardType) { nsAutoHTMLEditorLogLock logLock(this); if (!mLocked && mFileStream) { PrintSelection(); Write("GetCurrentEditor().pasteAsCitedQuotation(\""); PrintUnicode(aCitation); Write("\", "); WriteInt(aClipboardType); Write(");\n"); Flush(); } return nsHTMLEditor::PasteAsCitedQuotation(aCitation, aClipboardType); }
NS_IMETHODIMP nsHTMLEditorLog::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement) { nsAutoHTMLEditorLogLock logLock(this); if (!mLocked && mFileStream) { NS_ENSURE_TRUE(aAnchorElement, NS_ERROR_NULL_POINTER); nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aAnchorElement); NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER); PrintSelection(); PrintNode(node, 0); Write("GetCurrentEditor().insertLinkAroundSelection(n0);\n"); Flush(); } return nsHTMLEditor::InsertLinkAroundSelection(aAnchorElement); }
NS_IMETHODIMP nsHTMLEditorLog::MakeOrChangeList(const nsAString& aListType, bool entireList, const nsAString& aBulletType) { nsAutoHTMLEditorLogLock logLock(this); if (!mLocked && mFileStream) { PrintSelection(); Write("GetCurrentEditor().makeOrChangeList(\""); PrintUnicode(aListType); Write("\", "); Write(entireList ? "true" : "false"); Write(", \""); PrintUnicode(aBulletType); Write("\");\n"); Flush(); } return nsHTMLEditor::MakeOrChangeList(aListType, entireList, aBulletType); }
NS_IMETHODIMP nsHTMLEditorLog::InsertElementAtSelection(nsIDOMElement* aElement, bool aDeleteSelection) { nsAutoHTMLEditorLogLock logLock(this); if (!mLocked && mFileStream) { NS_ENSURE_TRUE(aElement, NS_ERROR_NULL_POINTER); nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aElement); NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER); PrintSelection(); PrintNode(node, 0); Write("GetCurrentEditor().insertElementAtSelection(n0, "); Write(aDeleteSelection ? "true" : "false"); Write(");\n"); Flush(); } return nsHTMLEditor::InsertElementAtSelection(aElement, aDeleteSelection); }