1*d119d52dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*d119d52dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*d119d52dSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*d119d52dSAndrew Rist * distributed with this work for additional information
6*d119d52dSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*d119d52dSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*d119d52dSAndrew Rist * "License"); you may not use this file except in compliance
9*d119d52dSAndrew Rist * with the License. You may obtain a copy of the License at
10*d119d52dSAndrew Rist *
11*d119d52dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*d119d52dSAndrew Rist *
13*d119d52dSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*d119d52dSAndrew Rist * software distributed under the License is distributed on an
15*d119d52dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*d119d52dSAndrew Rist * KIND, either express or implied. See the License for the
17*d119d52dSAndrew Rist * specific language governing permissions and limitations
18*d119d52dSAndrew Rist * under the License.
19*d119d52dSAndrew Rist *
20*d119d52dSAndrew Rist *************************************************************/
21*d119d52dSAndrew Rist
22*d119d52dSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sfx2.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <sot/object.hxx>
28cdf0e10cSrcweir #include <tools/stream.hxx>
29cdf0e10cSrcweir #include <vcl/splitwin.hxx>
30cdf0e10cSrcweir #include <svl/itemset.hxx>
31cdf0e10cSrcweir #ifndef GCC
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir
34cdf0e10cSrcweir #include <sfx2/frmdescr.hxx>
35cdf0e10cSrcweir #include <sfx2/app.hxx>
36cdf0e10cSrcweir
37cdf0e10cSrcweir DBG_NAME(SfxFrameDescriptor);
38cdf0e10cSrcweir
39cdf0e10cSrcweir #define VERSION (sal_uInt16) 3
40cdf0e10cSrcweir
41cdf0e10cSrcweir struct SfxFrameDescriptor_Impl
42cdf0e10cSrcweir {
43cdf0e10cSrcweir Wallpaper* pWallpaper;
44cdf0e10cSrcweir SfxItemSet* pArgs;
45cdf0e10cSrcweir sal_Bool bEditable;
46cdf0e10cSrcweir
SfxFrameDescriptor_ImplSfxFrameDescriptor_Impl47cdf0e10cSrcweir SfxFrameDescriptor_Impl() : pWallpaper( NULL ), pArgs( NULL ), bEditable( sal_True ) {}
~SfxFrameDescriptor_ImplSfxFrameDescriptor_Impl48cdf0e10cSrcweir ~SfxFrameDescriptor_Impl()
49cdf0e10cSrcweir {
50cdf0e10cSrcweir delete pWallpaper;
51cdf0e10cSrcweir delete pArgs;
52cdf0e10cSrcweir }
53cdf0e10cSrcweir };
54cdf0e10cSrcweir
SfxFrameDescriptor()55cdf0e10cSrcweir SfxFrameDescriptor::SfxFrameDescriptor() :
56cdf0e10cSrcweir aMargin( -1, -1 ),
57cdf0e10cSrcweir nWidth( 0L ),
58cdf0e10cSrcweir eScroll( ScrollingAuto ),
59cdf0e10cSrcweir eSizeSelector( SIZE_ABS ),
60cdf0e10cSrcweir nHasBorder( BORDER_YES ),
61cdf0e10cSrcweir nItemId( 0 ),
62cdf0e10cSrcweir bResizeHorizontal( sal_True ),
63cdf0e10cSrcweir bResizeVertical( sal_True ),
64cdf0e10cSrcweir bHasUI( sal_True ),
65cdf0e10cSrcweir bReadOnly( sal_False )
66cdf0e10cSrcweir {
67cdf0e10cSrcweir DBG_CTOR(SfxFrameDescriptor, 0);
68cdf0e10cSrcweir
69cdf0e10cSrcweir pImp = new SfxFrameDescriptor_Impl;
70cdf0e10cSrcweir }
71cdf0e10cSrcweir
~SfxFrameDescriptor()72cdf0e10cSrcweir SfxFrameDescriptor::~SfxFrameDescriptor()
73cdf0e10cSrcweir {
74cdf0e10cSrcweir DBG_DTOR(SfxFrameDescriptor, 0);
75cdf0e10cSrcweir delete pImp;
76cdf0e10cSrcweir }
77cdf0e10cSrcweir
GetArgs()78cdf0e10cSrcweir SfxItemSet* SfxFrameDescriptor::GetArgs()
79cdf0e10cSrcweir {
80cdf0e10cSrcweir if( !pImp->pArgs )
81cdf0e10cSrcweir pImp->pArgs = new SfxAllItemSet( SFX_APP()->GetPool() );
82cdf0e10cSrcweir return pImp->pArgs;
83cdf0e10cSrcweir }
84cdf0e10cSrcweir
SetURL(const String & rURL)85cdf0e10cSrcweir void SfxFrameDescriptor::SetURL( const String& rURL )
86cdf0e10cSrcweir {
87cdf0e10cSrcweir aURL = INetURLObject(rURL);
88cdf0e10cSrcweir SetActualURL( aURL );
89cdf0e10cSrcweir }
90cdf0e10cSrcweir
SetURL(const INetURLObject & rURL)91cdf0e10cSrcweir void SfxFrameDescriptor::SetURL( const INetURLObject& rURL )
92cdf0e10cSrcweir {
93cdf0e10cSrcweir aURL = rURL.GetMainURL( INetURLObject::DECODE_TO_IURI );
94cdf0e10cSrcweir SetActualURL( aURL );
95cdf0e10cSrcweir }
96cdf0e10cSrcweir
SetActualURL(const String & rURL)97cdf0e10cSrcweir void SfxFrameDescriptor::SetActualURL( const String& rURL )
98cdf0e10cSrcweir {
99cdf0e10cSrcweir aActualURL = INetURLObject(rURL);
100cdf0e10cSrcweir if ( pImp->pArgs )
101cdf0e10cSrcweir pImp->pArgs->ClearItem();
102cdf0e10cSrcweir }
103cdf0e10cSrcweir
SetActualURL(const INetURLObject & rURL)104cdf0e10cSrcweir void SfxFrameDescriptor::SetActualURL( const INetURLObject& rURL )
105cdf0e10cSrcweir {
106cdf0e10cSrcweir SetActualURL(String(rURL.GetMainURL( INetURLObject::DECODE_TO_IURI )));
107cdf0e10cSrcweir }
108cdf0e10cSrcweir
SetEditable(sal_Bool bSet)109cdf0e10cSrcweir void SfxFrameDescriptor::SetEditable( sal_Bool bSet )
110cdf0e10cSrcweir {
111cdf0e10cSrcweir pImp->bEditable = bSet;
112cdf0e10cSrcweir }
113cdf0e10cSrcweir
IsEditable() const114cdf0e10cSrcweir sal_Bool SfxFrameDescriptor::IsEditable() const
115cdf0e10cSrcweir {
116cdf0e10cSrcweir return pImp->bEditable;
117cdf0e10cSrcweir }
118cdf0e10cSrcweir
CompareOriginal(SfxFrameDescriptor & rDescr) const119cdf0e10cSrcweir sal_Bool SfxFrameDescriptor::CompareOriginal( SfxFrameDescriptor& rDescr ) const
120cdf0e10cSrcweir {
121cdf0e10cSrcweir if( aURL != rDescr.aURL )
122cdf0e10cSrcweir return sal_False;
123cdf0e10cSrcweir else
124cdf0e10cSrcweir return sal_True;
125cdf0e10cSrcweir }
126cdf0e10cSrcweir
CheckContent() const127cdf0e10cSrcweir sal_Bool SfxFrameDescriptor::CheckContent() const
128cdf0e10cSrcweir {
129cdf0e10cSrcweir sal_Bool bRet = !( aURL == aActualURL );
130cdf0e10cSrcweir return bRet;
131cdf0e10cSrcweir }
132cdf0e10cSrcweir
UnifyContent(sal_Bool bTakeActual)133cdf0e10cSrcweir void SfxFrameDescriptor::UnifyContent( sal_Bool bTakeActual )
134cdf0e10cSrcweir {
135cdf0e10cSrcweir if ( bTakeActual )
136cdf0e10cSrcweir aURL = aActualURL;
137cdf0e10cSrcweir else
138cdf0e10cSrcweir aActualURL = aURL;
139cdf0e10cSrcweir }
140cdf0e10cSrcweir
Clone(sal_Bool bWithIds) const141cdf0e10cSrcweir SfxFrameDescriptor* SfxFrameDescriptor::Clone( sal_Bool bWithIds ) const
142cdf0e10cSrcweir {
143cdf0e10cSrcweir SfxFrameDescriptor *pFrame = new SfxFrameDescriptor;
144cdf0e10cSrcweir
145cdf0e10cSrcweir pFrame->aURL = aURL;
146cdf0e10cSrcweir pFrame->aActualURL = aActualURL;
147cdf0e10cSrcweir pFrame->aName = aName;
148cdf0e10cSrcweir pFrame->aMargin = aMargin;
149cdf0e10cSrcweir pFrame->nWidth = nWidth;
150cdf0e10cSrcweir pFrame->eSizeSelector = eSizeSelector;
151cdf0e10cSrcweir pFrame->eScroll = eScroll;
152cdf0e10cSrcweir pFrame->bResizeHorizontal = bResizeHorizontal;
153cdf0e10cSrcweir pFrame->bResizeVertical = bResizeVertical;
154cdf0e10cSrcweir pFrame->nHasBorder = nHasBorder;
155cdf0e10cSrcweir pFrame->bHasUI = bHasUI;
156cdf0e10cSrcweir pFrame->SetReadOnly( IsReadOnly() );
157cdf0e10cSrcweir pFrame->SetEditable( IsEditable() );
158cdf0e10cSrcweir if ( pImp->pWallpaper )
159cdf0e10cSrcweir pFrame->pImp->pWallpaper = new Wallpaper( *pImp->pWallpaper );
160cdf0e10cSrcweir if( pImp->pArgs )
161cdf0e10cSrcweir {
162cdf0e10cSrcweir // Aktuell ist im Clone von SfxAllItemSets noch ein Bug...
163cdf0e10cSrcweir pFrame->pImp->pArgs = new SfxAllItemSet( SFX_APP()->GetPool() );
164cdf0e10cSrcweir pFrame->pImp->pArgs->Put(*pImp->pArgs);
165cdf0e10cSrcweir }
166cdf0e10cSrcweir
167cdf0e10cSrcweir if ( bWithIds )
168cdf0e10cSrcweir pFrame->nItemId = nItemId;
169cdf0e10cSrcweir else
170cdf0e10cSrcweir pFrame->nItemId = 0;
171cdf0e10cSrcweir
172cdf0e10cSrcweir return pFrame;
173cdf0e10cSrcweir }
174cdf0e10cSrcweir
GetWinBits() const175cdf0e10cSrcweir sal_uInt16 SfxFrameDescriptor::GetWinBits() const
176cdf0e10cSrcweir {
177cdf0e10cSrcweir sal_uInt16 nBits = 0;
178cdf0e10cSrcweir if ( eSizeSelector == SIZE_REL )
179cdf0e10cSrcweir nBits |= SWIB_RELATIVESIZE;
180cdf0e10cSrcweir if ( eSizeSelector == SIZE_PERCENT )
181cdf0e10cSrcweir nBits |= SWIB_PERCENTSIZE;
182cdf0e10cSrcweir if ( !IsResizable() )
183cdf0e10cSrcweir nBits |= SWIB_FIXED;
184cdf0e10cSrcweir if ( !nWidth )
185cdf0e10cSrcweir nBits |= SWIB_INVISIBLE;
186cdf0e10cSrcweir return nBits;
187cdf0e10cSrcweir }
188cdf0e10cSrcweir
HasFrameBorder() const189cdf0e10cSrcweir sal_Bool SfxFrameDescriptor::HasFrameBorder() const
190cdf0e10cSrcweir {
191cdf0e10cSrcweir return (nHasBorder & BORDER_YES) != 0;
192cdf0e10cSrcweir }
193cdf0e10cSrcweir
GetSize() const194cdf0e10cSrcweir long SfxFrameDescriptor::GetSize() const
195cdf0e10cSrcweir {
196cdf0e10cSrcweir return nWidth;
197cdf0e10cSrcweir }
198cdf0e10cSrcweir
TakeProperties(const SfxFrameProperties & rProp)199cdf0e10cSrcweir void SfxFrameDescriptor::TakeProperties( const SfxFrameProperties& rProp )
200cdf0e10cSrcweir {
201cdf0e10cSrcweir aURL = aActualURL = INetURLObject(rProp.aURL);
202cdf0e10cSrcweir aName = rProp.aName;
203cdf0e10cSrcweir aMargin.Width() = rProp.lMarginWidth;
204cdf0e10cSrcweir aMargin.Height() = rProp.lMarginHeight;
205cdf0e10cSrcweir nWidth = rProp.lSize;
206cdf0e10cSrcweir eScroll = rProp.eScroll;
207cdf0e10cSrcweir eSizeSelector = rProp.eSizeSelector;
208cdf0e10cSrcweir nHasBorder = rProp.bHasBorder ? BORDER_YES : BORDER_NO;
209cdf0e10cSrcweir if ( rProp.bBorderSet )
210cdf0e10cSrcweir nHasBorder |= BORDER_SET;
211cdf0e10cSrcweir bResizeHorizontal = bResizeVertical = rProp.bResizable;
212cdf0e10cSrcweir }
213cdf0e10cSrcweir
SetWallpaper(const Wallpaper & rWallpaper)214cdf0e10cSrcweir void SfxFrameDescriptor::SetWallpaper( const Wallpaper& rWallpaper )
215cdf0e10cSrcweir {
216cdf0e10cSrcweir DELETEZ( pImp->pWallpaper );
217cdf0e10cSrcweir
218cdf0e10cSrcweir if ( rWallpaper.GetStyle() != WALLPAPER_NULL )
219cdf0e10cSrcweir pImp->pWallpaper = new Wallpaper( rWallpaper );
220cdf0e10cSrcweir }
221cdf0e10cSrcweir
GetWallpaper() const222cdf0e10cSrcweir const Wallpaper* SfxFrameDescriptor::GetWallpaper() const
223cdf0e10cSrcweir {
224cdf0e10cSrcweir return pImp->pWallpaper;
225cdf0e10cSrcweir }
226cdf0e10cSrcweir
GetItemPos() const227cdf0e10cSrcweir sal_uInt16 SfxFrameDescriptor::GetItemPos() const
228cdf0e10cSrcweir {
229cdf0e10cSrcweir return USHRT_MAX;
230cdf0e10cSrcweir }
231cdf0e10cSrcweir
232cdf0e10cSrcweir
SfxFrameProperties(const SfxFrameDescriptor * pD)233cdf0e10cSrcweir SfxFrameProperties::SfxFrameProperties( const SfxFrameDescriptor *pD )
234cdf0e10cSrcweir : aURL( pD->GetURL().GetMainURL( INetURLObject::DECODE_TO_IURI ) )
235cdf0e10cSrcweir , aName( pD->GetName() )
236cdf0e10cSrcweir , lMarginWidth( pD->GetMargin().Width() )
237cdf0e10cSrcweir , lMarginHeight( pD->GetMargin().Height() )
238cdf0e10cSrcweir , lSize( pD->GetWidth() )
239cdf0e10cSrcweir , lSetSize( SIZE_NOT_SET )
240cdf0e10cSrcweir , lFrameSpacing( SPACING_NOT_SET )
241cdf0e10cSrcweir , lInheritedFrameSpacing( SPACING_NOT_SET )
242cdf0e10cSrcweir , eScroll( pD->GetScrollingMode() )
243cdf0e10cSrcweir , eSizeSelector( pD->GetSizeSelector() )
244cdf0e10cSrcweir , eSetSizeSelector( SIZE_REL )
245cdf0e10cSrcweir , bHasBorder( pD->HasFrameBorder() )
246cdf0e10cSrcweir , bBorderSet( pD->IsFrameBorderSet() )
247cdf0e10cSrcweir , bResizable( pD->IsResizable() )
248cdf0e10cSrcweir , bSetResizable( sal_False )
249cdf0e10cSrcweir , bIsRootSet( sal_False )
250cdf0e10cSrcweir , bIsInColSet( sal_False )
251cdf0e10cSrcweir , bHasBorderInherited( sal_False )
252cdf0e10cSrcweir , pFrame( pD->Clone() )
253cdf0e10cSrcweir {
254cdf0e10cSrcweir bBorderSet = sal_True;
255cdf0e10cSrcweir }
256cdf0e10cSrcweir
operator =(const SfxFrameProperties & rProp)257cdf0e10cSrcweir SfxFrameProperties& SfxFrameProperties::operator =(
258cdf0e10cSrcweir const SfxFrameProperties &rProp )
259cdf0e10cSrcweir {
260cdf0e10cSrcweir aURL = rProp.aURL;
261cdf0e10cSrcweir aName = rProp.aName;
262cdf0e10cSrcweir lMarginWidth = rProp.lMarginWidth;
263cdf0e10cSrcweir lMarginHeight = rProp.lMarginHeight;
264cdf0e10cSrcweir lSize = rProp.lSize;
265cdf0e10cSrcweir lSetSize = rProp.lSetSize;
266cdf0e10cSrcweir lFrameSpacing = rProp.lFrameSpacing;
267cdf0e10cSrcweir lInheritedFrameSpacing = rProp.lInheritedFrameSpacing;
268cdf0e10cSrcweir eScroll = rProp.eScroll;
269cdf0e10cSrcweir eSizeSelector = rProp.eSizeSelector;
270cdf0e10cSrcweir eSetSizeSelector = rProp.eSetSizeSelector;
271cdf0e10cSrcweir bHasBorder = rProp.bHasBorder;
272cdf0e10cSrcweir bBorderSet = rProp.bBorderSet;
273cdf0e10cSrcweir bResizable = rProp.bResizable;
274cdf0e10cSrcweir bSetResizable = rProp.bSetResizable;
275cdf0e10cSrcweir bIsRootSet = rProp.bIsRootSet;
276cdf0e10cSrcweir bIsInColSet = rProp.bIsInColSet;
277cdf0e10cSrcweir bHasBorderInherited = rProp.bHasBorderInherited;
278cdf0e10cSrcweir pFrame = rProp.pFrame->Clone();
279cdf0e10cSrcweir return *this;
280cdf0e10cSrcweir }
281cdf0e10cSrcweir
operator ==(const SfxFrameProperties & rProp) const282cdf0e10cSrcweir int SfxFrameProperties::operator ==( const SfxFrameProperties& rProp ) const
283cdf0e10cSrcweir {
284cdf0e10cSrcweir return aURL == rProp.aURL && aName == rProp.aName && lMarginWidth == rProp.lMarginWidth && lMarginHeight == rProp.lMarginHeight &&
285cdf0e10cSrcweir lSize == rProp.lSize && eScroll == rProp.eScroll && eSizeSelector == rProp.eSizeSelector &&
286cdf0e10cSrcweir lSetSize == rProp.lSetSize && lFrameSpacing == rProp.lFrameSpacing && eSetSizeSelector == rProp.eSetSizeSelector &&
287cdf0e10cSrcweir bHasBorder == rProp.bHasBorder && bBorderSet == rProp.bBorderSet &&
288cdf0e10cSrcweir bResizable == rProp.bResizable && bSetResizable == rProp.bSetResizable;
289cdf0e10cSrcweir }
290cdf0e10cSrcweir
291cdf0e10cSrcweir TYPEINIT1(SfxFrameDescriptorItem, SfxPoolItem);
292cdf0e10cSrcweir
~SfxFrameDescriptorItem()293cdf0e10cSrcweir SfxFrameDescriptorItem::~SfxFrameDescriptorItem()
294cdf0e10cSrcweir {}
295cdf0e10cSrcweir
operator ==(const SfxPoolItem & rAttr) const296cdf0e10cSrcweir int SfxFrameDescriptorItem::operator==( const SfxPoolItem& rAttr ) const
297cdf0e10cSrcweir {
298cdf0e10cSrcweir DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
299cdf0e10cSrcweir
300cdf0e10cSrcweir return aProperties == ((SfxFrameDescriptorItem&)rAttr).aProperties;
301cdf0e10cSrcweir }
302cdf0e10cSrcweir
303cdf0e10cSrcweir // -----------------------------------------------------------------------
304cdf0e10cSrcweir
Clone(SfxItemPool *) const305cdf0e10cSrcweir SfxPoolItem* SfxFrameDescriptorItem::Clone( SfxItemPool* ) const
306cdf0e10cSrcweir {
307cdf0e10cSrcweir return new SfxFrameDescriptorItem( *this );
308cdf0e10cSrcweir }
309cdf0e10cSrcweir
310cdf0e10cSrcweir //------------------------------------------------------------------------
311cdf0e10cSrcweir
GetPresentation(SfxItemPresentation,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const312cdf0e10cSrcweir SfxItemPresentation SfxFrameDescriptorItem::GetPresentation
313cdf0e10cSrcweir (
314cdf0e10cSrcweir SfxItemPresentation /*ePres*/,
315cdf0e10cSrcweir SfxMapUnit /*eCoreUnit*/,
316cdf0e10cSrcweir SfxMapUnit /*ePresUnit*/,
317cdf0e10cSrcweir XubString& rText,
318cdf0e10cSrcweir const IntlWrapper *
319cdf0e10cSrcweir ) const
320cdf0e10cSrcweir {
321cdf0e10cSrcweir rText.Erase();
322cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NONE;
323cdf0e10cSrcweir }
324cdf0e10cSrcweir
325cdf0e10cSrcweir
326