1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 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. 14 * 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). 20 * 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. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_automation.hxx" 30 31 #if OSL_DEBUG_LEVEL > 1 32 #include <vcl/svapp.hxx> 33 #include "editwin.hxx" 34 35 36 class ImpWorkWindow : public WorkWindow 37 { 38 public: 39 MultiLineEdit m_aInhalt; 40 ImpWorkWindow( WorkWindow *pParent, const UniString &rName, WinBits ); 41 ~ImpWorkWindow(); 42 void Resize(); 43 }; 44 45 ImpWorkWindow::ImpWorkWindow( WorkWindow *pParent, const String &rName, WinBits iWstyle ) 46 : WorkWindow( pParent , WB_SIZEMOVE ) 47 , m_aInhalt( this, iWstyle ) 48 { 49 m_aInhalt.Show(); 50 SetText(rName); 51 SetPosSizePixel( Point( 1,40 ), Size(500,150) ); 52 Resize(); 53 } 54 55 ImpWorkWindow::~ImpWorkWindow() 56 { 57 Hide(); 58 } 59 60 void ImpWorkWindow::Resize() 61 { 62 m_aInhalt.SetPosSizePixel( Point(), GetOutputSizePixel() ); 63 } 64 65 sal_Bool EditWindow::Close() 66 { 67 if ( pImpWorkWindow ) 68 { 69 delete pImpWorkWindow; 70 pImpWorkWindow = NULL; 71 } 72 return sal_True; 73 } 74 75 void EditWindow::Show() 76 { 77 if ( Check() ) 78 pImpWorkWindow->Show(); 79 else 80 bShowWin = sal_True; 81 } 82 83 void EditWindow::Hide() 84 { 85 if ( Check() ) 86 pImpWorkWindow->Hide(); 87 else 88 bShowWin = sal_False; 89 } 90 91 EditWindow::EditWindow( WorkWindow *pParent, const String &rName, WinBits iWstyle ) 92 : pImpWorkWindow(NULL) 93 , pMemParent(pParent) 94 , aMemName(rName) 95 , iMemWstyle(iWstyle) 96 , nTextLen(0) 97 , bQuiet(sal_False) 98 { 99 } 100 101 EditWindow::~EditWindow() 102 { 103 Close(); 104 } 105 106 sal_Bool EditWindow::Check() 107 { 108 if ( ! pImpWorkWindow && Application::IsInExecute() ) 109 { 110 pImpWorkWindow = new ImpWorkWindow( pMemParent, aMemName, iMemWstyle ); 111 pImpWorkWindow->m_aInhalt.SetText( aMemPreWinText ); 112 nTextLen = aMemPreWinText.Len(); 113 aMemPreWinText.Erase(); 114 if ( bShowWin ) 115 pImpWorkWindow->Show(); 116 return sal_True; 117 } 118 return pImpWorkWindow != NULL; 119 } 120 121 void EditWindow::Clear() 122 { 123 if ( Check() ) 124 { 125 pImpWorkWindow->m_aInhalt.SetText( String() ); 126 nTextLen = 0; 127 } 128 aMemPreWinText.Erase(); 129 } 130 131 void EditWindow::AddText( const sal_Char* rNew ) 132 { 133 AddText( UniString::CreateFromAscii( rNew ) ); 134 } 135 136 void EditWindow::AddText( const String &rNew ) 137 { 138 if ( bQuiet ) return; 139 140 String aText = rNew; 141 aText.ConvertLineEnd(); 142 143 if ( Check() ) 144 { 145 if ( nTextLen > 5000 ) 146 { 147 pImpWorkWindow->m_aInhalt.SetText( pImpWorkWindow->m_aInhalt.GetText().Erase(0,1000) ); 148 nTextLen = pImpWorkWindow->m_aInhalt.GetText().Len(); // Absolut, um Fehler sonstwo auszub�geln 149 } 150 151 152 pImpWorkWindow->m_aInhalt.SetSelection( Selection( SELECTION_MAX, SELECTION_MAX ) ); 153 pImpWorkWindow->m_aInhalt.ReplaceSelected( aText ); 154 nTextLen = nTextLen + aText.Len(); 155 pImpWorkWindow->m_aInhalt.SetSelection( Selection( SELECTION_MAX, SELECTION_MAX ) ); 156 } 157 else 158 { 159 aMemPreWinText += aText; 160 } 161 } 162 163 #endif 164 165