merge the formfield patch from ooo-build
[ooovba.git] / sw / source / core / fields / scrptfld.cxx
bloba1bc1952bceaeea459804787c2470235b33678b5
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: scrptfld.cxx,v $
10 * $Revision: 1.12 $
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_sw.hxx"
35 #include <docufld.hxx>
36 #ifndef _UNOFLDMID_H
37 #include <unofldmid.h>
38 #endif
39 #ifndef _COMCORE_HRC
40 #include <comcore.hrc>
41 #endif
42 #include <tools/resid.hxx>
44 using namespace ::com::sun::star;
45 using ::rtl::OUString;
46 /*--------------------------------------------------------------------
47 Beschreibung: ScriptField
48 --------------------------------------------------------------------*/
50 SwScriptFieldType::SwScriptFieldType( SwDoc* pD )
51 : SwFieldType( RES_SCRIPTFLD ), pDoc( pD )
54 SwFieldType* SwScriptFieldType::Copy() const
56 return new SwScriptFieldType( pDoc );
60 /*--------------------------------------------------------------------
61 Beschreibung: SwScriptField
62 --------------------------------------------------------------------*/
64 SwScriptField::SwScriptField( SwScriptFieldType* pInitType,
65 const String& rType, const String& rCode,
66 BOOL bURL )
67 : SwField( pInitType ), sType( rType ), sCode( rCode ), bCodeURL( bURL )
71 String SwScriptField::GetDescription() const
73 return SW_RES(STR_SCRIPT);
76 String SwScriptField::Expand() const
78 return aEmptyStr;
81 SwField* SwScriptField::Copy() const
83 return new SwScriptField( (SwScriptFieldType*)GetTyp(), sType, sCode, bCodeURL );
86 /*--------------------------------------------------------------------
87 Beschreibung: Type setzen
88 --------------------------------------------------------------------*/
90 void SwScriptField::SetPar1( const String& rStr )
92 sType = rStr;
95 const String& SwScriptField::GetPar1() const
97 return sType;
100 /*--------------------------------------------------------------------
101 Beschreibung: Code setzen
102 --------------------------------------------------------------------*/
104 void SwScriptField::SetPar2( const String& rStr )
106 sCode = rStr;
110 String SwScriptField::GetPar2() const
112 return sCode;
114 /*-----------------05.03.98 15:00-------------------
116 --------------------------------------------------*/
117 BOOL SwScriptField::QueryValue( uno::Any& rAny, USHORT nWhichId ) const
119 switch( nWhichId )
121 case FIELD_PROP_PAR1:
122 rAny <<= OUString( sType );
123 break;
124 case FIELD_PROP_PAR2:
125 rAny <<= OUString( sCode );
126 break;
127 case FIELD_PROP_BOOL1:
128 rAny.setValue(&bCodeURL, ::getBooleanCppuType());
129 break;
130 default:
131 DBG_ERROR("illegal property");
133 return TRUE;
135 /*-----------------05.03.98 15:00-------------------
137 --------------------------------------------------*/
138 BOOL SwScriptField::PutValue( const uno::Any& rAny, USHORT nWhichId )
140 switch( nWhichId )
142 case FIELD_PROP_PAR1:
143 ::GetString( rAny, sType );
144 break;
145 case FIELD_PROP_PAR2:
146 ::GetString( rAny, sCode );
147 break;
148 case FIELD_PROP_BOOL1:
149 bCodeURL = *(sal_Bool*)rAny.getValue();
150 break;
151 default:
152 DBG_ERROR("illegal property");
154 return TRUE;