1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: frmdescr.cxx,v $
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>
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
;
54 SfxFrameDescriptor_Impl() : pWallpaper( NULL
), pArgs( NULL
), bEditable( TRUE
) {}
55 ~SfxFrameDescriptor_Impl()
62 SfxFrameDescriptor::SfxFrameDescriptor() :
65 eScroll( ScrollingAuto
),
66 eSizeSelector( SIZE_ABS
),
67 nHasBorder( BORDER_YES
),
69 bResizeHorizontal( TRUE
),
70 bResizeVertical( TRUE
),
74 DBG_CTOR(SfxFrameDescriptor
, 0);
76 pImp
= new SfxFrameDescriptor_Impl
;
79 SfxFrameDescriptor::~SfxFrameDescriptor()
81 DBG_DTOR(SfxFrameDescriptor
, 0);
85 SfxItemSet
* SfxFrameDescriptor::GetArgs()
88 pImp
->pArgs
= new SfxAllItemSet( SFX_APP()->GetPool() );
92 void SfxFrameDescriptor::SetURL( const String
& rURL
)
94 aURL
= INetURLObject(rURL
);
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
);
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
)
134 BOOL
SfxFrameDescriptor::CheckContent() const
136 BOOL bRet
= !( aURL
== aActualURL
);
140 void SfxFrameDescriptor::UnifyContent( BOOL bTakeActual
)
148 SfxFrameDescriptor
* SfxFrameDescriptor::Clone( BOOL bWithIds
) const
150 SfxFrameDescriptor
*pFrame
= new SfxFrameDescriptor
;
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
);
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
);
175 pFrame
->nItemId
= nItemId
;
182 USHORT
SfxFrameDescriptor::GetWinBits() const
185 if ( eSizeSelector
== SIZE_REL
)
186 nBits
|= SWIB_RELATIVESIZE
;
187 if ( eSizeSelector
== SIZE_PERCENT
)
188 nBits
|= SWIB_PERCENTSIZE
;
189 if ( !IsResizable() )
192 nBits
|= SWIB_INVISIBLE
;
196 BOOL
SfxFrameDescriptor::HasFrameBorder() const
198 return (nHasBorder
& BORDER_YES
) != 0;
201 long SfxFrameDescriptor::GetSize() const
206 void SfxFrameDescriptor::TakeProperties( const SfxFrameProperties
& rProp
)
208 aURL
= aActualURL
= INetURLObject(rProp
.aURL
);
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
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() )
264 SfxFrameProperties
& SfxFrameProperties::operator =(
265 const SfxFrameProperties
&rProp
)
269 lMarginWidth
= rProp
.lMarginWidth
;
270 lMarginHeight
= rProp
.lMarginHeight
;
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();
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*/,
329 return SFX_ITEM_PRESENTATION_NONE
;