fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / svx / source / items / viewlayoutitem.cxx
blobc45635eb137c07c118f159b2ae7c81bd26bba234
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <tools/stream.hxx>
22 #include <svx/viewlayoutitem.hxx>
23 #include <com/sun/star/uno/Sequence.hxx>
24 #include <com/sun/star/beans/PropertyValue.hpp>
26 // -----------------------------------------------------------------------
28 TYPEINIT1_FACTORY(SvxViewLayoutItem,SfxUInt16Item, new SvxViewLayoutItem);
30 #define VIEWLAYOUT_PARAM_COLUMNS "Columns"
31 #define VIEWLAYOUT_PARAM_BOOKMODE "BookMode"
32 #define VIEWLAYOUT_PARAMS 2
34 // -----------------------------------------------------------------------
36 SvxViewLayoutItem::SvxViewLayoutItem
38 sal_uInt16 nColumns,
39 bool bBookMode,
40 sal_uInt16 _nWhich
42 : SfxUInt16Item( _nWhich, nColumns ),
43 mbBookMode( bBookMode )
47 // -----------------------------------------------------------------------
49 SvxViewLayoutItem::SvxViewLayoutItem( const SvxViewLayoutItem& rOrig )
50 : SfxUInt16Item( rOrig.Which(), rOrig.GetValue() ),
51 mbBookMode( rOrig.IsBookMode() )
55 // -----------------------------------------------------------------------
57 SvxViewLayoutItem::~SvxViewLayoutItem()
61 // -----------------------------------------------------------------------
63 SfxPoolItem* SvxViewLayoutItem::Clone( SfxItemPool * /*pPool*/ ) const
65 return new SvxViewLayoutItem( *this );
68 // -----------------------------------------------------------------------
70 SfxPoolItem* SvxViewLayoutItem::Create( SvStream& /*rStrm*/, sal_uInt16 /*nVersion*/ ) const
72 return 0;
75 // -----------------------------------------------------------------------
77 SvStream& SvxViewLayoutItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) const
79 return rStrm;
82 // -----------------------------------------------------------------------
84 int SvxViewLayoutItem::operator==( const SfxPoolItem& rAttr ) const
86 DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
88 SvxViewLayoutItem& rItem = (SvxViewLayoutItem&)rAttr;
90 return ( GetValue() == rItem.GetValue() &&
91 mbBookMode == rItem.IsBookMode() );
94 bool SvxViewLayoutItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId ) const
96 nMemberId &= ~CONVERT_TWIPS;
97 switch ( nMemberId )
99 case 0 :
101 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aSeq( VIEWLAYOUT_PARAMS );
102 aSeq[0].Name = OUString( VIEWLAYOUT_PARAM_COLUMNS );
103 aSeq[0].Value <<= sal_Int32( GetValue() );
104 aSeq[1].Name = OUString( VIEWLAYOUT_PARAM_BOOKMODE );
105 aSeq[1].Value <<= sal_Bool( mbBookMode );
106 rVal <<= aSeq;
108 break;
110 case MID_VIEWLAYOUT_COLUMNS : rVal <<= (sal_Int32) GetValue(); break;
111 case MID_VIEWLAYOUT_BOOKMODE: rVal <<= (sal_Bool) mbBookMode; break;
112 default:
113 OSL_FAIL("svx::SvxViewLayoutItem::QueryValue(), Wrong MemberId!");
114 return false;
117 return true;
120 bool SvxViewLayoutItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId )
122 nMemberId &= ~CONVERT_TWIPS;
123 switch ( nMemberId )
125 case 0 :
127 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aSeq;
128 if (( rVal >>= aSeq ) && ( aSeq.getLength() == VIEWLAYOUT_PARAMS ))
130 sal_Int32 nColumns( 0 );
131 sal_Bool bBookMode = sal_False;
132 sal_Bool bAllConverted( sal_True );
133 sal_Int16 nConvertedCount( 0 );
134 for ( sal_Int32 i = 0; i < aSeq.getLength(); i++ )
136 if ( aSeq[i].Name.equalsAscii( VIEWLAYOUT_PARAM_COLUMNS ))
138 bAllConverted &= ( aSeq[i].Value >>= nColumns );
139 ++nConvertedCount;
141 else if ( aSeq[i].Name.equalsAscii( VIEWLAYOUT_PARAM_BOOKMODE ))
143 bAllConverted &= ( aSeq[i].Value >>= bBookMode );
144 ++nConvertedCount;
148 if ( bAllConverted && nConvertedCount == VIEWLAYOUT_PARAMS )
150 SetValue( (sal_uInt16)nColumns );
151 mbBookMode = bBookMode;
152 return true;
156 return false;
159 case MID_VIEWLAYOUT_COLUMNS:
161 sal_Int32 nVal = 0;
162 if ( rVal >>= nVal )
164 SetValue( (sal_uInt16)nVal );
165 return true;
167 else
168 return false;
171 case MID_VIEWLAYOUT_BOOKMODE:
173 sal_Bool bBookMode = sal_False;
174 if ( rVal >>= bBookMode )
176 mbBookMode = bBookMode;
177 return true;
179 else
180 return false;
183 default:
184 OSL_FAIL("svx::SvxViewLayoutItem::PutValue(), Wrong MemberId!");
185 return false;
189 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */