xref: /aoo41x/main/sfx2/source/control/sorgitm.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_sfx2.hxx"
30 
31 #include <sfx2/sfxsids.hrc>
32 #include "sorgitm.hxx"
33 // STATIC DATA -----------------------------------------------------------
34 
35 TYPEINIT1_AUTOFACTORY(SfxScriptOrganizerItem, SfxStringItem);
36 
37 //------------------------------------------------------------------------
38 
39 SfxScriptOrganizerItem::SfxScriptOrganizerItem() :
40 
41 	SfxStringItem()
42 
43 {
44 }
45 
46 //------------------------------------------------------------------------
47 
48 SfxScriptOrganizerItem::SfxScriptOrganizerItem( const String& rLanguage ) :
49 
50 	 SfxStringItem( SID_SCRIPTORGANIZER, rLanguage ),
51 
52 	 aLanguage( rLanguage )
53 
54 {
55 }
56 
57 //------------------------------------------------------------------------
58 
59 SfxScriptOrganizerItem::SfxScriptOrganizerItem( const SfxScriptOrganizerItem& rItem ) :
60 
61 	SfxStringItem( rItem ),
62 
63 	aLanguage( rItem.aLanguage )
64 
65 {
66 }
67 
68 //------------------------------------------------------------------------
69 
70 SfxScriptOrganizerItem::~SfxScriptOrganizerItem()
71 {
72 }
73 
74 //------------------------------------------------------------------------
75 
76 SfxPoolItem* SfxScriptOrganizerItem::Clone( SfxItemPool * ) const
77 {
78 	return new SfxScriptOrganizerItem( *this );
79 }
80 
81 //------------------------------------------------------------------------
82 
83 int SfxScriptOrganizerItem::operator==( const SfxPoolItem& rItem) const
84 {
85 	 return rItem.Type() == Type() &&
86 		 SfxStringItem::operator==(rItem) &&
87 		 aLanguage == ((const SfxScriptOrganizerItem &)rItem).aLanguage;
88 }
89 
90 
91 sal_Bool SfxScriptOrganizerItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId ) const
92 {
93     String aValue;
94     sal_Bool bIsString = sal_False;
95 	sal_Bool bValue = sal_False;
96     nMemberId &= ~CONVERT_TWIPS;
97     switch ( nMemberId )
98     {
99         case 0:
100         case MID_SCRIPT_ORGANIZER_LANGUAGE:
101 			bIsString = sal_True;
102 			aValue = aLanguage;
103 			break;
104         default:
105 			DBG_ERROR("Wrong MemberId!");
106            	return sal_False;
107 	 }
108 
109 	if ( bIsString )
110 		rVal <<= ::rtl::OUString( aValue );
111 	else
112 		rVal <<= bValue;
113     return sal_True;
114 }
115 
116 sal_Bool SfxScriptOrganizerItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId )
117 {
118     ::rtl::OUString aValue;
119 	sal_Bool bRet = sal_False;
120     nMemberId &= ~CONVERT_TWIPS;
121     switch ( nMemberId )
122     {
123         case 0:
124 		case MID_SCRIPT_ORGANIZER_LANGUAGE:
125 			bRet = (rVal >>= aValue);
126 			if ( bRet )
127             	aLanguage = aValue;
128             break;
129         default:
130 			DBG_ERROR("Wrong MemberId!");
131             return sal_False;
132     }
133 
134     return bRet;
135 }
136 
137