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_sfx2.hxx"
26
27 // INCLUDE ---------------------------------------------------------------
28
29 #include "sfx2/tplpitem.hxx"
30 #include <com/sun/star/frame/status/Template.hpp>
31
32
33 // STATIC DATA -----------------------------------------------------------
34
35 TYPEINIT1_AUTOFACTORY(SfxTemplateItem, SfxFlagItem);
36
37 //=========================================================================
38
SfxTemplateItem()39 SfxTemplateItem::SfxTemplateItem() :
40 SfxFlagItem()
41 {
42 }
43
SfxTemplateItem(sal_uInt16 nWhichId,const String & rStyle,sal_uInt16 nValue)44 SfxTemplateItem::SfxTemplateItem
45 (
46 sal_uInt16 nWhichId, // Slot-ID
47 const String& rStyle, // Name des aktuellen Styles
48 sal_uInt16 nValue // Flags f"ur das Filtern bei automatischer Anzeige
49 ) : SfxFlagItem( nWhichId, nValue ),
50 aStyle( rStyle )
51 {
52 }
53
54 //-------------------------------------------------------------------------
55
56 // copy ctor
SfxTemplateItem(const SfxTemplateItem & rCopy)57 SfxTemplateItem::SfxTemplateItem( const SfxTemplateItem& rCopy ) :
58
59 SfxFlagItem( rCopy ),
60
61 aStyle( rCopy.aStyle )
62 {
63 }
64
65 //-------------------------------------------------------------------------
66
67 // op ==
68
operator ==(const SfxPoolItem & rCmp) const69 int SfxTemplateItem::operator==( const SfxPoolItem& rCmp ) const
70 {
71 return ( SfxFlagItem::operator==( rCmp ) &&
72 aStyle == ( (const SfxTemplateItem&)rCmp ).aStyle );
73 }
74
75 //-------------------------------------------------------------------------
76
Clone(SfxItemPool *) const77 SfxPoolItem* SfxTemplateItem::Clone( SfxItemPool *) const
78 {
79 return new SfxTemplateItem(*this);
80 }
81
82 //-------------------------------------------------------------------------
QueryValue(com::sun::star::uno::Any & rVal,sal_uInt8) const83 sal_Bool SfxTemplateItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
84 {
85 ::com::sun::star::frame::status::Template aTemplate;
86
87 aTemplate.Value = GetValue();
88 aTemplate.StyleName = aStyle;
89 rVal <<= aTemplate;
90
91 return sal_True;
92 }
93
94 //-------------------------------------------------------------------------
PutValue(const com::sun::star::uno::Any & rVal,sal_uInt8)95 sal_Bool SfxTemplateItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
96 {
97 ::com::sun::star::frame::status::Template aTemplate;
98
99 if ( rVal >>= aTemplate )
100 {
101 SetValue( sal::static_int_cast< sal_uInt16 >( aTemplate.Value ) );
102 aStyle = aTemplate.StyleName;
103 return sal_True;
104 }
105
106 return sal_False;
107 }
108
109 //-------------------------------------------------------------------------
110
GetFlagCount() const111 sal_uInt8 SfxTemplateItem::GetFlagCount() const
112 {
113 return sizeof(sal_uInt16) * 8;
114 }
115
116
117