CWS-TOOLING: integrate CWS os150
[LibreOffice.git] / sd / source / ui / notes / TextLogger.cxx
blobdfbce2daa22118e9d65892eb42c4971469d882ed
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sd.hxx"
31 #include "TextLogger.hxx"
33 #include "EditWindow.hxx"
34 #include <vos/mutex.hxx>
35 #include <vcl/svapp.hxx>
37 namespace sd { namespace notes {
39 TextLogger* TextLogger::spInstance = NULL;
41 TextLogger& TextLogger::Instance (void)
43 if (spInstance == NULL)
45 ::vos::OGuard aGuard (::Application::GetSolarMutex());
46 if (spInstance == NULL)
47 spInstance = new TextLogger ();
49 return *spInstance;
55 TextLogger::TextLogger (void)
56 : mpEditWindow (NULL)
63 void TextLogger::AppendText (const char* sText)
65 OSL_TRACE (sText);
66 if (mpEditWindow != NULL)
67 mpEditWindow->InsertText (UniString::CreateFromAscii(sText));
73 void TextLogger::AppendText (const String& sText)
75 ByteString s(sText, RTL_TEXTENCODING_ISO_8859_1);
76 OSL_TRACE (s.GetBuffer());
77 if (mpEditWindow != NULL)
78 mpEditWindow->InsertText (sText);
84 void TextLogger::AppendNumber (long int nValue)
86 AppendText (String::CreateFromInt32(nValue));
92 void TextLogger::ConnectToEditWindow (EditWindow* pEditWindow)
94 if (mpEditWindow != pEditWindow)
96 if (pEditWindow != NULL)
97 pEditWindow->AddEventListener(
98 LINK(this, TextLogger, WindowEventHandler));
99 else
100 mpEditWindow->RemoveEventListener(
101 LINK(this, TextLogger, WindowEventHandler));
103 mpEditWindow = pEditWindow;
110 IMPL_LINK(TextLogger, WindowEventHandler, VclWindowEvent*, pEvent)
112 if (pEvent != NULL)
114 DBG_ASSERT(static_cast<VclWindowEvent*>(pEvent)->GetWindow()
115 == mpEditWindow,
116 "TextLogger: received event from unknown window");
117 switch (pEvent->GetId())
119 case VCLEVENT_WINDOW_CLOSE:
120 case VCLEVENT_OBJECT_DYING:
121 mpEditWindow = NULL;
122 break;
125 return sal_True;
129 } } // end of namespace ::sd::notes