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