xref: /AOO41X/main/sfx2/source/dialog/tplpitem.cxx (revision d119d52d53d0b2180f2ae51341d882123be2af2b)
1*d119d52dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*d119d52dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*d119d52dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*d119d52dSAndrew Rist  * distributed with this work for additional information
6*d119d52dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*d119d52dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*d119d52dSAndrew Rist  * "License"); you may not use this file except in compliance
9*d119d52dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*d119d52dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*d119d52dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*d119d52dSAndrew Rist  * software distributed under the License is distributed on an
15*d119d52dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*d119d52dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*d119d52dSAndrew Rist  * specific language governing permissions and limitations
18*d119d52dSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*d119d52dSAndrew Rist  *************************************************************/
21*d119d52dSAndrew Rist 
22*d119d52dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sfx2.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir // INCLUDE ---------------------------------------------------------------
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include "sfx2/tplpitem.hxx"
30cdf0e10cSrcweir #include <com/sun/star/frame/status/Template.hpp>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir 
33cdf0e10cSrcweir // STATIC DATA -----------------------------------------------------------
34cdf0e10cSrcweir 
35cdf0e10cSrcweir TYPEINIT1_AUTOFACTORY(SfxTemplateItem, SfxFlagItem);
36cdf0e10cSrcweir 
37cdf0e10cSrcweir //=========================================================================
38cdf0e10cSrcweir 
SfxTemplateItem()39cdf0e10cSrcweir SfxTemplateItem::SfxTemplateItem() :
40cdf0e10cSrcweir     SfxFlagItem()
41cdf0e10cSrcweir {
42cdf0e10cSrcweir }
43cdf0e10cSrcweir 
SfxTemplateItem(sal_uInt16 nWhichId,const String & rStyle,sal_uInt16 nValue)44cdf0e10cSrcweir SfxTemplateItem::SfxTemplateItem
45cdf0e10cSrcweir (
46cdf0e10cSrcweir 	sal_uInt16 nWhichId,      // Slot-ID
47cdf0e10cSrcweir 	const String& rStyle, // Name des aktuellen Styles
48cdf0e10cSrcweir 	sal_uInt16 nValue         // Flags f"ur das Filtern bei automatischer Anzeige
49cdf0e10cSrcweir ) :	SfxFlagItem( nWhichId, nValue ),
50cdf0e10cSrcweir 	aStyle( rStyle )
51cdf0e10cSrcweir {
52cdf0e10cSrcweir }
53cdf0e10cSrcweir 
54cdf0e10cSrcweir //-------------------------------------------------------------------------
55cdf0e10cSrcweir 
56cdf0e10cSrcweir // copy ctor
SfxTemplateItem(const SfxTemplateItem & rCopy)57cdf0e10cSrcweir SfxTemplateItem::SfxTemplateItem( const SfxTemplateItem& rCopy ) :
58cdf0e10cSrcweir 
59cdf0e10cSrcweir 	SfxFlagItem( rCopy ),
60cdf0e10cSrcweir 
61cdf0e10cSrcweir 	aStyle( rCopy.aStyle )
62cdf0e10cSrcweir {
63cdf0e10cSrcweir }
64cdf0e10cSrcweir 
65cdf0e10cSrcweir //-------------------------------------------------------------------------
66cdf0e10cSrcweir 
67cdf0e10cSrcweir // op ==
68cdf0e10cSrcweir 
operator ==(const SfxPoolItem & rCmp) const69cdf0e10cSrcweir int SfxTemplateItem::operator==( const SfxPoolItem& rCmp ) const
70cdf0e10cSrcweir {
71cdf0e10cSrcweir 	return ( SfxFlagItem::operator==( rCmp ) &&
72cdf0e10cSrcweir 			 aStyle == ( (const SfxTemplateItem&)rCmp ).aStyle );
73cdf0e10cSrcweir }
74cdf0e10cSrcweir 
75cdf0e10cSrcweir //-------------------------------------------------------------------------
76cdf0e10cSrcweir 
Clone(SfxItemPool *) const77cdf0e10cSrcweir SfxPoolItem* SfxTemplateItem::Clone( SfxItemPool *) const
78cdf0e10cSrcweir {
79cdf0e10cSrcweir 	return new SfxTemplateItem(*this);
80cdf0e10cSrcweir }
81cdf0e10cSrcweir 
82cdf0e10cSrcweir //-------------------------------------------------------------------------
QueryValue(com::sun::star::uno::Any & rVal,sal_uInt8) const83cdf0e10cSrcweir sal_Bool SfxTemplateItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
84cdf0e10cSrcweir {
85cdf0e10cSrcweir     ::com::sun::star::frame::status::Template aTemplate;
86cdf0e10cSrcweir 
87cdf0e10cSrcweir     aTemplate.Value = GetValue();
88cdf0e10cSrcweir     aTemplate.StyleName = aStyle;
89cdf0e10cSrcweir     rVal <<= aTemplate;
90cdf0e10cSrcweir 
91cdf0e10cSrcweir     return sal_True;
92cdf0e10cSrcweir }
93cdf0e10cSrcweir 
94cdf0e10cSrcweir //-------------------------------------------------------------------------
PutValue(const com::sun::star::uno::Any & rVal,sal_uInt8)95cdf0e10cSrcweir sal_Bool SfxTemplateItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
96cdf0e10cSrcweir {
97cdf0e10cSrcweir     ::com::sun::star::frame::status::Template aTemplate;
98cdf0e10cSrcweir 
99cdf0e10cSrcweir     if ( rVal >>= aTemplate )
100cdf0e10cSrcweir     {
101cdf0e10cSrcweir         SetValue( sal::static_int_cast< sal_uInt16 >( aTemplate.Value ) );
102cdf0e10cSrcweir         aStyle = aTemplate.StyleName;
103cdf0e10cSrcweir         return sal_True;
104cdf0e10cSrcweir     }
105cdf0e10cSrcweir 
106cdf0e10cSrcweir     return sal_False;
107cdf0e10cSrcweir }
108cdf0e10cSrcweir 
109cdf0e10cSrcweir //-------------------------------------------------------------------------
110cdf0e10cSrcweir 
GetFlagCount() const111cdf0e10cSrcweir sal_uInt8 SfxTemplateItem::GetFlagCount() const
112cdf0e10cSrcweir {
113cdf0e10cSrcweir 	return sizeof(sal_uInt16) * 8;
114cdf0e10cSrcweir }
115cdf0e10cSrcweir 
116cdf0e10cSrcweir 
117