merge the formfield patch from ooo-build
[ooovba.git] / automation / source / server / editwin.cxx
blob3b2c54d01661d3bfd6a2dc360dda03f9fed0f7e1
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: editwin.cxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_automation.hxx"
34 #if OSL_DEBUG_LEVEL > 1
35 #include <vcl/svapp.hxx>
36 #include "editwin.hxx"
39 class ImpWorkWindow : public WorkWindow
41 public:
42 MultiLineEdit m_aInhalt;
43 ImpWorkWindow( WorkWindow *pParent, const UniString &rName, WinBits );
44 ~ImpWorkWindow();
45 void Resize();
48 ImpWorkWindow::ImpWorkWindow( WorkWindow *pParent, const String &rName, WinBits iWstyle )
49 : WorkWindow( pParent , WB_SIZEMOVE )
50 , m_aInhalt( this, iWstyle )
52 m_aInhalt.Show();
53 SetText(rName);
54 SetPosSizePixel( Point( 1,40 ), Size(500,150) );
55 Resize();
58 ImpWorkWindow::~ImpWorkWindow()
60 Hide();
63 void ImpWorkWindow::Resize()
65 m_aInhalt.SetPosSizePixel( Point(), GetOutputSizePixel() );
68 BOOL EditWindow::Close()
70 if ( pImpWorkWindow )
72 delete pImpWorkWindow;
73 pImpWorkWindow = NULL;
75 return TRUE;
78 void EditWindow::Show()
80 if ( Check() )
81 pImpWorkWindow->Show();
82 else
83 bShowWin = TRUE;
86 void EditWindow::Hide()
88 if ( Check() )
89 pImpWorkWindow->Hide();
90 else
91 bShowWin = FALSE;
94 EditWindow::EditWindow( WorkWindow *pParent, const String &rName, WinBits iWstyle )
95 : pImpWorkWindow(NULL)
96 , pMemParent(pParent)
97 , aMemName(rName)
98 , iMemWstyle(iWstyle)
99 , nTextLen(0)
100 , bQuiet(FALSE)
104 EditWindow::~EditWindow()
106 Close();
109 BOOL EditWindow::Check()
111 if ( ! pImpWorkWindow && Application::IsInExecute() )
113 pImpWorkWindow = new ImpWorkWindow( pMemParent, aMemName, iMemWstyle );
114 pImpWorkWindow->m_aInhalt.SetText( aMemPreWinText );
115 nTextLen = aMemPreWinText.Len();
116 aMemPreWinText.Erase();
117 if ( bShowWin )
118 pImpWorkWindow->Show();
119 return TRUE;
121 return pImpWorkWindow != NULL;
124 void EditWindow::Clear()
126 if ( Check() )
128 pImpWorkWindow->m_aInhalt.SetText( String() );
129 nTextLen = 0;
131 aMemPreWinText.Erase();
134 void EditWindow::AddText( const sal_Char* rNew )
136 AddText( UniString::CreateFromAscii( rNew ) );
139 void EditWindow::AddText( const String &rNew )
141 if ( bQuiet ) return;
143 String aText = rNew;
144 aText.ConvertLineEnd();
146 if ( Check() )
148 if ( nTextLen > 5000 )
150 pImpWorkWindow->m_aInhalt.SetText( pImpWorkWindow->m_aInhalt.GetText().Erase(0,1000) );
151 nTextLen = pImpWorkWindow->m_aInhalt.GetText().Len(); // Absolut, um Fehler sonstwo auszubügeln
155 pImpWorkWindow->m_aInhalt.SetSelection( Selection( SELECTION_MAX, SELECTION_MAX ) );
156 pImpWorkWindow->m_aInhalt.ReplaceSelected( aText );
157 nTextLen = nTextLen + aText.Len();
158 pImpWorkWindow->m_aInhalt.SetSelection( Selection( SELECTION_MAX, SELECTION_MAX ) );
160 else
162 aMemPreWinText += aText;
166 #endif