1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: editwin.cxx,v $
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 #include "editwin.hxx"
35 #include <tools/stream.hxx>
36 #ifndef _MSGBOX_HXX //autogen
37 #include <vcl/msgbox.hxx>
41 BOOL
GHEditWindow::Close()
43 if (aInhalt
.IsModified())
50 void GHEditWindow::Resize()
52 aInhalt
.SetPosSizePixel(Point(1,1),GetOutputSizePixel());
55 GHEditWindow::GHEditWindow(Window
* pParent
, String aName
, WinBits iWstyle
)
56 : FloatingWindow(pParent
)
57 , aInhalt(this,iWstyle
)
59 SetOutputSizePixel( Size( 120,80 ) );
66 void GHEditWindow::Clear()
68 aInhalt
.SetText(String());
71 void GHEditWindow::AddText( String aNew
, BOOL bMoveToEnd
)
73 String aOld
= aInhalt
.GetText();
76 aOld
.ConvertLineEnd();
77 aInhalt
.SetText(aOld
);
79 aInhalt
.SetSelection(Selection(SELECTION_MAX
,SELECTION_MAX
));
83 EditFileWindow::EditFileWindow(Window
* pParent
, String aName
, WinBits iWstyle
)
84 : GHEditWindow(pParent
, aName
, iWstyle
)
90 void EditFileWindow::LoadFile()
96 Stream
.Open(aFileName
, STREAM_STD_READ
);
100 AddText(CUniString("could not open ").Append(aFileName
).AppendAscii("\n"));
105 while (!Stream
.IsEof())
108 Stream
.ReadByteStringLine( Line
, RTL_TEXTENCODING_UTF8
);
115 All
.ConvertLineEnd();
121 BOOL
EditFileWindow::Close()
124 if (aInhalt
.IsModified() && QueryBox(this,WB_DEF_YES
| WB_YES_NO_CANCEL
, String(aFileName
).AppendAscii("\nhas been changed.\n\nSave file?")).Execute())
128 return GHEditWindow::Close();