1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26
27
28 #include <docufld.hxx>
29 #ifndef _UNOFLDMID_H
30 #include <unofldmid.h>
31 #endif
32 #ifndef _COMCORE_HRC
33 #include <comcore.hrc>
34 #endif
35 #include <tools/resid.hxx>
36
37 using namespace ::com::sun::star;
38 using ::rtl::OUString;
39 /*--------------------------------------------------------------------
40 Beschreibung: ScriptField
41 --------------------------------------------------------------------*/
42
SwScriptFieldType(SwDoc * pD)43 SwScriptFieldType::SwScriptFieldType( SwDoc* pD )
44 : SwFieldType( RES_SCRIPTFLD ), pDoc( pD )
45 {}
46
Copy() const47 SwFieldType* SwScriptFieldType::Copy() const
48 {
49 return new SwScriptFieldType( pDoc );
50 }
51
52
53 /*--------------------------------------------------------------------
54 Beschreibung: SwScriptField
55 --------------------------------------------------------------------*/
56
SwScriptField(SwScriptFieldType * pInitType,const String & rType,const String & rCode,sal_Bool bURL)57 SwScriptField::SwScriptField( SwScriptFieldType* pInitType,
58 const String& rType, const String& rCode,
59 sal_Bool bURL )
60 : SwField( pInitType ), sType( rType ), sCode( rCode ), bCodeURL( bURL )
61 {
62 }
63
GetDescription() const64 String SwScriptField::GetDescription() const
65 {
66 return SW_RES(STR_SCRIPT);
67 }
68
Expand() const69 String SwScriptField::Expand() const
70 {
71 return aEmptyStr;
72 }
73
Copy() const74 SwField* SwScriptField::Copy() const
75 {
76 return new SwScriptField( (SwScriptFieldType*)GetTyp(), sType, sCode, bCodeURL );
77 }
78
79 /*--------------------------------------------------------------------
80 Beschreibung: Type setzen
81 --------------------------------------------------------------------*/
82
SetPar1(const String & rStr)83 void SwScriptField::SetPar1( const String& rStr )
84 {
85 sType = rStr;
86 }
87
GetPar1() const88 const String& SwScriptField::GetPar1() const
89 {
90 return sType;
91 }
92
93 /*--------------------------------------------------------------------
94 Beschreibung: Code setzen
95 --------------------------------------------------------------------*/
96
SetPar2(const String & rStr)97 void SwScriptField::SetPar2( const String& rStr )
98 {
99 sCode = rStr;
100 }
101
102
GetPar2() const103 String SwScriptField::GetPar2() const
104 {
105 return sCode;
106 }
107 /*-----------------05.03.98 15:00-------------------
108
109 --------------------------------------------------*/
QueryValue(uno::Any & rAny,sal_uInt16 nWhichId) const110 sal_Bool SwScriptField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
111 {
112 switch( nWhichId )
113 {
114 case FIELD_PROP_PAR1:
115 rAny <<= OUString( sType );
116 break;
117 case FIELD_PROP_PAR2:
118 rAny <<= OUString( sCode );
119 break;
120 case FIELD_PROP_BOOL1:
121 rAny.setValue(&bCodeURL, ::getBooleanCppuType());
122 break;
123 default:
124 DBG_ERROR("illegal property");
125 }
126 return sal_True;
127 }
128 /*-----------------05.03.98 15:00-------------------
129
130 --------------------------------------------------*/
PutValue(const uno::Any & rAny,sal_uInt16 nWhichId)131 sal_Bool SwScriptField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
132 {
133 switch( nWhichId )
134 {
135 case FIELD_PROP_PAR1:
136 ::GetString( rAny, sType );
137 break;
138 case FIELD_PROP_PAR2:
139 ::GetString( rAny, sCode );
140 break;
141 case FIELD_PROP_BOOL1:
142 bCodeURL = *(sal_Bool*)rAny.getValue();
143 break;
144 default:
145 DBG_ERROR("illegal property");
146 }
147 return sal_True;
148 }
149
150