Update ooo320-m1
[ooovba.git] / sfx2 / source / doc / frmdescr.cxx
blob3db8bf61edaf27041c4e56dec6be8233fc4f767b
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: frmdescr.cxx,v $
10 * $Revision: 1.14 $
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_sfx2.hxx"
34 #include <sot/object.hxx>
35 #include <tools/stream.hxx>
36 #include <vcl/splitwin.hxx>
37 #include <svtools/itemset.hxx>
38 #ifndef GCC
39 #endif
41 #include <sfx2/frmdescr.hxx>
42 #include <sfx2/app.hxx>
44 DBG_NAME(SfxFrameDescriptor);
46 #define VERSION (USHORT) 3
48 struct SfxFrameDescriptor_Impl
50 Wallpaper* pWallpaper;
51 SfxItemSet* pArgs;
52 BOOL bEditable;
54 SfxFrameDescriptor_Impl() : pWallpaper( NULL ), pArgs( NULL ), bEditable( TRUE ) {}
55 ~SfxFrameDescriptor_Impl()
57 delete pWallpaper;
58 delete pArgs;
62 SfxFrameDescriptor::SfxFrameDescriptor() :
63 aMargin( -1, -1 ),
64 nWidth( 0L ),
65 eScroll( ScrollingAuto ),
66 eSizeSelector( SIZE_ABS ),
67 nHasBorder( BORDER_YES ),
68 nItemId( 0 ),
69 bResizeHorizontal( TRUE ),
70 bResizeVertical( TRUE ),
71 bHasUI( TRUE ),
72 bReadOnly( FALSE )
74 DBG_CTOR(SfxFrameDescriptor, 0);
76 pImp = new SfxFrameDescriptor_Impl;
79 SfxFrameDescriptor::~SfxFrameDescriptor()
81 DBG_DTOR(SfxFrameDescriptor, 0);
82 delete pImp;
85 SfxItemSet* SfxFrameDescriptor::GetArgs()
87 if( !pImp->pArgs )
88 pImp->pArgs = new SfxAllItemSet( SFX_APP()->GetPool() );
89 return pImp->pArgs;
92 void SfxFrameDescriptor::SetURL( const String& rURL )
94 aURL = INetURLObject(rURL);
95 SetActualURL( aURL );
98 void SfxFrameDescriptor::SetURL( const INetURLObject& rURL )
100 aURL = rURL.GetMainURL( INetURLObject::DECODE_TO_IURI );
101 SetActualURL( aURL );
104 void SfxFrameDescriptor::SetActualURL( const String& rURL )
106 aActualURL = INetURLObject(rURL);
107 if ( pImp->pArgs )
108 pImp->pArgs->ClearItem();
111 void SfxFrameDescriptor::SetActualURL( const INetURLObject& rURL )
113 SetActualURL(String(rURL.GetMainURL( INetURLObject::DECODE_TO_IURI )));
116 void SfxFrameDescriptor::SetEditable( BOOL bSet )
118 pImp->bEditable = bSet;
121 BOOL SfxFrameDescriptor::IsEditable() const
123 return pImp->bEditable;
126 BOOL SfxFrameDescriptor::CompareOriginal( SfxFrameDescriptor& rDescr ) const
128 if( aURL != rDescr.aURL )
129 return FALSE;
130 else
131 return TRUE;
134 BOOL SfxFrameDescriptor::CheckContent() const
136 BOOL bRet = !( aURL == aActualURL );
137 return bRet;
140 void SfxFrameDescriptor::UnifyContent( BOOL bTakeActual )
142 if ( bTakeActual )
143 aURL = aActualURL;
144 else
145 aActualURL = aURL;
148 SfxFrameDescriptor* SfxFrameDescriptor::Clone( BOOL bWithIds ) const
150 SfxFrameDescriptor *pFrame = new SfxFrameDescriptor;
152 pFrame->aURL = aURL;
153 pFrame->aActualURL = aActualURL;
154 pFrame->aName = aName;
155 pFrame->aMargin = aMargin;
156 pFrame->nWidth = nWidth;
157 pFrame->eSizeSelector = eSizeSelector;
158 pFrame->eScroll = eScroll;
159 pFrame->bResizeHorizontal = bResizeHorizontal;
160 pFrame->bResizeVertical = bResizeVertical;
161 pFrame->nHasBorder = nHasBorder;
162 pFrame->bHasUI = bHasUI;
163 pFrame->SetReadOnly( IsReadOnly() );
164 pFrame->SetEditable( IsEditable() );
165 if ( pImp->pWallpaper )
166 pFrame->pImp->pWallpaper = new Wallpaper( *pImp->pWallpaper );
167 if( pImp->pArgs )
169 // Aktuell ist im Clone von SfxAllItemSets noch ein Bug...
170 pFrame->pImp->pArgs = new SfxAllItemSet( SFX_APP()->GetPool() );
171 pFrame->pImp->pArgs->Put(*pImp->pArgs);
174 if ( bWithIds )
175 pFrame->nItemId = nItemId;
176 else
177 pFrame->nItemId = 0;
179 return pFrame;
182 USHORT SfxFrameDescriptor::GetWinBits() const
184 USHORT nBits = 0;
185 if ( eSizeSelector == SIZE_REL )
186 nBits |= SWIB_RELATIVESIZE;
187 if ( eSizeSelector == SIZE_PERCENT )
188 nBits |= SWIB_PERCENTSIZE;
189 if ( !IsResizable() )
190 nBits |= SWIB_FIXED;
191 if ( !nWidth )
192 nBits |= SWIB_INVISIBLE;
193 return nBits;
196 BOOL SfxFrameDescriptor::HasFrameBorder() const
198 return (nHasBorder & BORDER_YES) != 0;
201 long SfxFrameDescriptor::GetSize() const
203 return nWidth;
206 void SfxFrameDescriptor::TakeProperties( const SfxFrameProperties& rProp )
208 aURL = aActualURL = INetURLObject(rProp.aURL);
209 aName = rProp.aName;
210 aMargin.Width() = rProp.lMarginWidth;
211 aMargin.Height() = rProp.lMarginHeight;
212 nWidth = rProp.lSize;
213 eScroll = rProp.eScroll;
214 eSizeSelector = rProp.eSizeSelector;
215 nHasBorder = rProp.bHasBorder ? BORDER_YES : BORDER_NO;
216 if ( rProp.bBorderSet )
217 nHasBorder |= BORDER_SET;
218 bResizeHorizontal = bResizeVertical = rProp.bResizable;
221 void SfxFrameDescriptor::SetWallpaper( const Wallpaper& rWallpaper )
223 DELETEZ( pImp->pWallpaper );
225 if ( rWallpaper.GetStyle() != WALLPAPER_NULL )
226 pImp->pWallpaper = new Wallpaper( rWallpaper );
229 const Wallpaper* SfxFrameDescriptor::GetWallpaper() const
231 return pImp->pWallpaper;
234 USHORT SfxFrameDescriptor::GetItemPos() const
236 return USHRT_MAX;
240 SfxFrameProperties::SfxFrameProperties( const SfxFrameDescriptor *pD )
241 : aURL( pD->GetURL().GetMainURL( INetURLObject::DECODE_TO_IURI ) )
242 , aName( pD->GetName() )
243 , lMarginWidth( pD->GetMargin().Width() )
244 , lMarginHeight( pD->GetMargin().Height() )
245 , lSize( pD->GetWidth() )
246 , lSetSize( SIZE_NOT_SET )
247 , lFrameSpacing( SPACING_NOT_SET )
248 , lInheritedFrameSpacing( SPACING_NOT_SET )
249 , eScroll( pD->GetScrollingMode() )
250 , eSizeSelector( pD->GetSizeSelector() )
251 , eSetSizeSelector( SIZE_REL )
252 , bHasBorder( pD->HasFrameBorder() )
253 , bBorderSet( pD->IsFrameBorderSet() )
254 , bResizable( pD->IsResizable() )
255 , bSetResizable( FALSE )
256 , bIsRootSet( FALSE )
257 , bIsInColSet( FALSE )
258 , bHasBorderInherited( FALSE )
259 , pFrame( pD->Clone() )
261 bBorderSet = TRUE;
264 SfxFrameProperties& SfxFrameProperties::operator =(
265 const SfxFrameProperties &rProp )
267 aURL = rProp.aURL;
268 aName = rProp.aName;
269 lMarginWidth = rProp.lMarginWidth;
270 lMarginHeight = rProp.lMarginHeight;
271 lSize = rProp.lSize;
272 lSetSize = rProp.lSetSize;
273 lFrameSpacing = rProp.lFrameSpacing;
274 lInheritedFrameSpacing = rProp.lInheritedFrameSpacing;
275 eScroll = rProp.eScroll;
276 eSizeSelector = rProp.eSizeSelector;
277 eSetSizeSelector = rProp.eSetSizeSelector;
278 bHasBorder = rProp.bHasBorder;
279 bBorderSet = rProp.bBorderSet;
280 bResizable = rProp.bResizable;
281 bSetResizable = rProp.bSetResizable;
282 bIsRootSet = rProp.bIsRootSet;
283 bIsInColSet = rProp.bIsInColSet;
284 bHasBorderInherited = rProp.bHasBorderInherited;
285 pFrame = rProp.pFrame->Clone();
286 return *this;
289 int SfxFrameProperties::operator ==( const SfxFrameProperties& rProp ) const
291 return aURL == rProp.aURL && aName == rProp.aName && lMarginWidth == rProp.lMarginWidth && lMarginHeight == rProp.lMarginHeight &&
292 lSize == rProp.lSize && eScroll == rProp.eScroll && eSizeSelector == rProp.eSizeSelector &&
293 lSetSize == rProp.lSetSize && lFrameSpacing == rProp.lFrameSpacing && eSetSizeSelector == rProp.eSetSizeSelector &&
294 bHasBorder == rProp.bHasBorder && bBorderSet == rProp.bBorderSet &&
295 bResizable == rProp.bResizable && bSetResizable == rProp.bSetResizable;
298 TYPEINIT1(SfxFrameDescriptorItem, SfxPoolItem);
300 SfxFrameDescriptorItem::~SfxFrameDescriptorItem()
303 int SfxFrameDescriptorItem::operator==( const SfxPoolItem& rAttr ) const
305 DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
307 return aProperties == ((SfxFrameDescriptorItem&)rAttr).aProperties;
310 // -----------------------------------------------------------------------
312 SfxPoolItem* SfxFrameDescriptorItem::Clone( SfxItemPool* ) const
314 return new SfxFrameDescriptorItem( *this );
317 //------------------------------------------------------------------------
319 SfxItemPresentation SfxFrameDescriptorItem::GetPresentation
321 SfxItemPresentation /*ePres*/,
322 SfxMapUnit /*eCoreUnit*/,
323 SfxMapUnit /*ePresUnit*/,
324 XubString& rText,
325 const IntlWrapper *
326 ) const
328 rText.Erase();
329 return SFX_ITEM_PRESENTATION_NONE;