1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_automation.hxx"
26 
27 #if OSL_DEBUG_LEVEL > 1
28 #include <vcl/svapp.hxx>
29 #include "editwin.hxx"
30 
31 
32 class ImpWorkWindow : public WorkWindow
33 {
34 public:
35 	MultiLineEdit	m_aInhalt;
36 	ImpWorkWindow( WorkWindow *pParent, const UniString &rName, WinBits );
37 	~ImpWorkWindow();
38 	void Resize();
39 };
40 
ImpWorkWindow(WorkWindow * pParent,const String & rName,WinBits iWstyle)41 ImpWorkWindow::ImpWorkWindow( WorkWindow *pParent, const String &rName, WinBits iWstyle )
42 : WorkWindow( pParent , WB_SIZEMOVE )
43 , m_aInhalt( this, iWstyle )
44 {
45 	m_aInhalt.Show();
46 	SetText(rName);
47 	SetPosSizePixel( Point( 1,40 ), Size(500,150) );
48 	Resize();
49 }
50 
~ImpWorkWindow()51 ImpWorkWindow::~ImpWorkWindow()
52 {
53 	Hide();
54 }
55 
Resize()56 void ImpWorkWindow::Resize()
57 {
58 	m_aInhalt.SetPosSizePixel( Point(), GetOutputSizePixel() );
59 }
60 
Close()61 sal_Bool EditWindow::Close()
62 {
63 	if ( pImpWorkWindow )
64 	{
65 		delete pImpWorkWindow;
66 		pImpWorkWindow = NULL;
67 	}
68 	return sal_True;
69 }
70 
Show()71 void EditWindow::Show()
72 {
73 	if ( Check() )
74 		pImpWorkWindow->Show();
75 	else
76 		bShowWin = sal_True;
77 }
78 
Hide()79 void EditWindow::Hide()
80 {
81 	if ( Check() )
82 		pImpWorkWindow->Hide();
83 	else
84 		bShowWin = sal_False;
85 }
86 
EditWindow(WorkWindow * pParent,const String & rName,WinBits iWstyle)87 EditWindow::EditWindow( WorkWindow *pParent, const String &rName, WinBits iWstyle )
88 : pImpWorkWindow(NULL)
89 , pMemParent(pParent)
90 , aMemName(rName)
91 , iMemWstyle(iWstyle)
92 , nTextLen(0)
93 , bQuiet(sal_False)
94 {
95 }
96 
~EditWindow()97 EditWindow::~EditWindow()
98 {
99 	Close();
100 }
101 
Check()102 sal_Bool EditWindow::Check()
103 {
104 	if ( ! pImpWorkWindow && Application::IsInExecute() )
105 	{
106 		pImpWorkWindow = new ImpWorkWindow( pMemParent, aMemName, iMemWstyle  );
107 		pImpWorkWindow->m_aInhalt.SetText( aMemPreWinText );
108 		nTextLen = aMemPreWinText.Len();
109 		aMemPreWinText.Erase();
110 		if ( bShowWin )
111 			pImpWorkWindow->Show();
112 		return sal_True;
113 	}
114 	return pImpWorkWindow != NULL;
115 }
116 
Clear()117 void EditWindow::Clear()
118 {
119 	if ( Check() )
120 	{
121 		pImpWorkWindow->m_aInhalt.SetText( String() );
122 		nTextLen = 0;
123 	}
124 	aMemPreWinText.Erase();
125 }
126 
AddText(const sal_Char * rNew)127 void EditWindow::AddText( const sal_Char* rNew )
128 {
129 	AddText( UniString::CreateFromAscii( rNew ) );
130 }
131 
AddText(const String & rNew)132 void EditWindow::AddText( const String &rNew )
133 {
134 	if ( bQuiet ) return;
135 
136 	String aText = rNew;
137 	aText.ConvertLineEnd();
138 
139 	if ( Check() )
140 	{
141 		if ( nTextLen > 5000 )
142 		{
143 			pImpWorkWindow->m_aInhalt.SetText( pImpWorkWindow->m_aInhalt.GetText().Erase(0,1000) );
144 			nTextLen = pImpWorkWindow->m_aInhalt.GetText().Len();		// Absolut, um Fehler sonstwo auszub�geln
145 		}
146 
147 
148 		pImpWorkWindow->m_aInhalt.SetSelection( Selection( SELECTION_MAX, SELECTION_MAX ) );
149 		pImpWorkWindow->m_aInhalt.ReplaceSelected( aText );
150 		nTextLen = nTextLen + aText.Len();
151 		pImpWorkWindow->m_aInhalt.SetSelection( Selection( SELECTION_MAX, SELECTION_MAX ) );
152 	}
153 	else
154 	{
155 		aMemPreWinText += aText;
156 	}
157 }
158 
159 #endif
160 
161