xref: /aoo41x/main/sw/source/core/fields/scrptfld.cxx (revision cdf0e10c)
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_sw.hxx"
30 
31 
32 #include <docufld.hxx>
33 #ifndef _UNOFLDMID_H
34 #include <unofldmid.h>
35 #endif
36 #ifndef _COMCORE_HRC
37 #include <comcore.hrc>
38 #endif
39 #include <tools/resid.hxx>
40 
41 using namespace ::com::sun::star;
42 using ::rtl::OUString;
43 /*--------------------------------------------------------------------
44 	Beschreibung: ScriptField
45  --------------------------------------------------------------------*/
46 
47 SwScriptFieldType::SwScriptFieldType( SwDoc* pD )
48 	: SwFieldType( RES_SCRIPTFLD ), pDoc( pD )
49 {}
50 
51 SwFieldType* SwScriptFieldType::Copy() const
52 {
53 	return new SwScriptFieldType( pDoc );
54 }
55 
56 
57 /*--------------------------------------------------------------------
58 	Beschreibung: SwScriptField
59  --------------------------------------------------------------------*/
60 
61 SwScriptField::SwScriptField( SwScriptFieldType* pInitType,
62 								const String& rType, const String& rCode,
63 								sal_Bool bURL )
64 	: SwField( pInitType ), sType( rType ), sCode( rCode ), bCodeURL( bURL )
65 {
66 }
67 
68 String SwScriptField::GetDescription() const
69 {
70     return SW_RES(STR_SCRIPT);
71 }
72 
73 String SwScriptField::Expand() const
74 {
75 	return aEmptyStr;
76 }
77 
78 SwField* SwScriptField::Copy() const
79 {
80 	return new SwScriptField( (SwScriptFieldType*)GetTyp(), sType, sCode, bCodeURL );
81 }
82 
83 /*--------------------------------------------------------------------
84 	Beschreibung: Type setzen
85  --------------------------------------------------------------------*/
86 
87 void SwScriptField::SetPar1( const String& rStr )
88 {
89 	sType = rStr;
90 }
91 
92 const String& SwScriptField::GetPar1() const
93 {
94 	return sType;
95 }
96 
97 /*--------------------------------------------------------------------
98 	Beschreibung: Code setzen
99  --------------------------------------------------------------------*/
100 
101 void SwScriptField::SetPar2( const String& rStr )
102 {
103 	sCode = rStr;
104 }
105 
106 
107 String SwScriptField::GetPar2() const
108 {
109 	return sCode;
110 }
111 /*-----------------05.03.98 15:00-------------------
112 
113 --------------------------------------------------*/
114 sal_Bool SwScriptField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
115 {
116     switch( nWhichId )
117 	{
118 	case FIELD_PROP_PAR1:
119 		rAny <<= OUString( sType );
120 		break;
121 	case FIELD_PROP_PAR2:
122 		rAny <<= OUString( sCode );
123 		break;
124 	case FIELD_PROP_BOOL1:
125 		rAny.setValue(&bCodeURL, ::getBooleanCppuType());
126 		break;
127 	default:
128 		DBG_ERROR("illegal property");
129 	}
130 	return sal_True;
131 }
132 /*-----------------05.03.98 15:00-------------------
133 
134 --------------------------------------------------*/
135 sal_Bool SwScriptField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
136 {
137     switch( nWhichId )
138 	{
139 	case FIELD_PROP_PAR1:
140 		::GetString( rAny, sType );
141 		break;
142 	case FIELD_PROP_PAR2:
143 		::GetString( rAny, sCode );
144 		break;
145 	case FIELD_PROP_BOOL1:
146 		bCodeURL = *(sal_Bool*)rAny.getValue();
147 		break;
148 	default:
149 		DBG_ERROR("illegal property");
150 	}
151 	return sal_True;
152 }
153 
154