merge the formfield patch from ooo-build
[ooovba.git] / svtools / source / items1 / tfrmitem.cxx
blobfe9130dd4446f44bc1e23860816ab8b26b398998
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tfrmitem.cxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
33 #include <com/sun/star/uno/Any.hxx>
35 #include <tools/stream.hxx>
36 #include <tools/debug.hxx>
37 #include <tools/string.hxx>
39 #include <svtools/tfrmitem.hxx>
41 DBG_NAME( SfxTargetFrameItem )
42 TYPEINIT1( SfxTargetFrameItem, SfxPoolItem );
44 // -----------------------------------------------------------------------
46 SfxTargetFrameItem::SfxTargetFrameItem( USHORT which ) :
47 SfxPoolItem( which )
49 DBG_CTOR( SfxTargetFrameItem, 0 );
52 // -----------------------------------------------------------------------
54 SfxTargetFrameItem::SfxTargetFrameItem( const SfxTargetFrameItem& rItem ) :
55 SfxPoolItem( rItem )
57 DBG_CTOR( SfxTargetFrameItem, 0 );
58 for( USHORT nCur = 0; nCur <= (USHORT)SfxOpenModeLast; nCur++ )
59 _aFrames[nCur] = rItem._aFrames[nCur];
62 // -----------------------------------------------------------------------
64 SfxTargetFrameItem::SfxTargetFrameItem( USHORT which,
65 const String& rOpenSelectFrame, const String& rOpenOpenFrame,
66 const String& rOpenAddTaskFrame ) : SfxPoolItem( which )
68 DBG_CTOR( SfxTargetFrameItem, 0 );
69 _aFrames[ (USHORT)SfxOpenSelect ] = rOpenSelectFrame;
70 _aFrames[ (USHORT)SfxOpenOpen ] = rOpenOpenFrame;
71 _aFrames[ (USHORT)SfxOpenAddTask ] = rOpenAddTaskFrame;
74 // -----------------------------------------------------------------------
76 SfxTargetFrameItem::~SfxTargetFrameItem()
78 DBG_DTOR(SfxTargetFrameItem, 0);
81 // -----------------------------------------------------------------------
83 String SfxTargetFrameItem::GetTargetFrame( SfxOpenMode eMode ) const
85 DBG_CHKTHIS( SfxTargetFrameItem, 0 );
86 if( eMode <= SfxOpenModeLast )
87 return _aFrames[ (USHORT)eMode ];
88 String aResult;
89 return aResult;
92 // -----------------------------------------------------------------------
94 int SfxTargetFrameItem::operator==( const SfxPoolItem& rItem ) const
96 DBG_CHKTHIS( SfxTargetFrameItem, 0 );
97 DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
99 for( USHORT nCur = 0; nCur <= (USHORT)SfxOpenModeLast; nCur++ )
101 if( _aFrames[nCur] != ((const SfxTargetFrameItem&)rItem)._aFrames[nCur] )
102 return 0;
104 return 1;
107 // -----------------------------------------------------------------------
109 SfxPoolItem* SfxTargetFrameItem::Create( SvStream& rStream, USHORT ) const
111 DBG_CHKTHIS(SfxTargetFrameItem, 0);
112 SfxTargetFrameItem* pItem = new SfxTargetFrameItem( Which() );
113 USHORT nCount = 0;
114 rStream >> nCount;
115 for(USHORT nCur=0; nCur<= (USHORT)SfxOpenModeLast && nCount; nCur++,nCount--)
117 readByteString(rStream, pItem->_aFrames[ nCur ]);
119 // die uebriggebliebenen ueberspringen
120 String aTemp;
121 while( nCount )
123 readByteString(rStream, aTemp);
124 nCount--;
126 return pItem;
129 // -----------------------------------------------------------------------
131 SvStream& SfxTargetFrameItem::Store( SvStream& rStream, USHORT ) const
133 DBG_CHKTHIS( SfxTargetFrameItem, 0 );
134 USHORT nCount = (USHORT)(SfxOpenModeLast+1);
135 rStream << nCount;
136 for( USHORT nCur = 0; nCur <= (USHORT)SfxOpenModeLast; nCur++ )
138 writeByteString(rStream, _aFrames[ nCur ]);
140 return rStream;
143 // -----------------------------------------------------------------------
145 SfxPoolItem* SfxTargetFrameItem::Clone( SfxItemPool* ) const
147 DBG_CHKTHIS( SfxTargetFrameItem, 0 );
148 return new SfxTargetFrameItem( *this );
151 // -----------------------------------------------------------------------
152 // virtual
153 BOOL SfxTargetFrameItem::QueryValue( com::sun::star::uno::Any& rVal,BYTE ) const
155 String aVal;
156 for ( int i = 0; i <= SfxOpenModeLast; i++ )
158 aVal += _aFrames[ i ];
159 aVal += ';' ;
162 rVal <<= rtl::OUString( aVal );
163 return TRUE;
166 // -----------------------------------------------------------------------
167 // virtual
168 BOOL SfxTargetFrameItem::PutValue( const com::sun::star::uno::Any& rVal,BYTE )
170 rtl::OUString aValue;
171 if ( rVal >>= aValue )
173 const String aVal( aValue );
175 for ( USHORT i = 0; i <= SfxOpenModeLast; i++ )
176 _aFrames[ i ] = aVal.GetToken( i );
178 return TRUE;
181 DBG_ERROR( "SfxTargetFrameItem::PutValue - Wrong type!" );
182 return FALSE;