xref: /trunk/main/vcl/source/window/cmdevt.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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_vcl.hxx"
30 
31 #ifndef _STRING_H
32 #include <string.h>
33 #endif
34 
35 #ifndef _SV_CMDEVT_HXX
36 #include <vcl/cmdevt.hxx>
37 #endif
38 
39 // =======================================================================
40 
41 CommandExtTextInputData::CommandExtTextInputData()
42 {
43     mpTextAttr      = NULL;
44     mnCursorPos     = 0;
45     mnDeltaStart    = 0;
46     mnOldTextLen    = 0;
47     mnCursorFlags   = 0;
48     mbOnlyCursor    = sal_False;
49 }
50 
51 // -----------------------------------------------------------------------
52 
53 CommandExtTextInputData::CommandExtTextInputData( const XubString& rText,
54                                                   const sal_uInt16* pTextAttr,
55                                                   xub_StrLen nCursorPos,
56                                                   sal_uInt16 nCursorFlags,
57                                                   xub_StrLen nDeltaStart,
58                                                   xub_StrLen nOldTextLen,
59                                                   sal_Bool bOnlyCursor ) :
60     maText( rText )
61 {
62     if ( pTextAttr && maText.Len() )
63     {
64         mpTextAttr = new sal_uInt16[maText.Len()];
65         memcpy( mpTextAttr, pTextAttr, maText.Len()*sizeof(sal_uInt16) );
66     }
67     else
68         mpTextAttr = NULL;
69     mnCursorPos     = nCursorPos;
70     mnDeltaStart    = nDeltaStart;
71     mnOldTextLen    = nOldTextLen;
72     mnCursorFlags   = nCursorFlags;
73     mbOnlyCursor    = bOnlyCursor;
74 }
75 
76 // -----------------------------------------------------------------------
77 
78 CommandExtTextInputData::CommandExtTextInputData( const CommandExtTextInputData& rData ) :
79     maText( rData.maText )
80 {
81     if ( rData.mpTextAttr && maText.Len() )
82     {
83         mpTextAttr = new sal_uInt16[maText.Len()];
84         memcpy( mpTextAttr, rData.mpTextAttr, maText.Len()*sizeof(sal_uInt16) );
85     }
86     else
87         mpTextAttr = NULL;
88     mnCursorPos     = rData.mnCursorPos;
89     mnDeltaStart    = rData.mnDeltaStart;
90     mnOldTextLen    = rData.mnOldTextLen;
91     mnCursorFlags   = rData.mnCursorFlags;
92     mbOnlyCursor    = rData.mbOnlyCursor;
93 }
94 
95 // -----------------------------------------------------------------------
96 
97 CommandExtTextInputData::~CommandExtTextInputData()
98 {
99     if ( mpTextAttr )
100         delete [] mpTextAttr;
101 }
102