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