Bump version to 4.1-6
[LibreOffice.git] / sfx2 / source / doc / frmdescr.cxx
blob6fb6a10caef6b2c123a24fcf724d27a49fd3704f
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 .
21 #include <sot/object.hxx>
22 #include <tools/stream.hxx>
23 #include <vcl/splitwin.hxx>
24 #include <svl/itemset.hxx>
26 #include <sfx2/frmdescr.hxx>
27 #include <sfx2/app.hxx>
29 DBG_NAME(SfxFrameDescriptor);
31 struct SfxFrameDescriptor_Impl
33 Wallpaper* pWallpaper;
34 SfxItemSet* pArgs;
35 sal_Bool bEditable;
37 SfxFrameDescriptor_Impl() : pWallpaper( NULL ), pArgs( NULL ), bEditable( sal_True ) {}
38 ~SfxFrameDescriptor_Impl()
40 delete pWallpaper;
41 delete pArgs;
45 SfxFrameDescriptor::SfxFrameDescriptor() :
46 aMargin( -1, -1 ),
47 nWidth( 0L ),
48 eScroll( ScrollingAuto ),
49 eSizeSelector( SIZE_ABS ),
50 nHasBorder( BORDER_YES ),
51 nItemId( 0 ),
52 bResizeHorizontal( sal_True ),
53 bResizeVertical( sal_True ),
54 bHasUI( sal_True ),
55 bReadOnly( sal_False )
57 DBG_CTOR(SfxFrameDescriptor, 0);
59 pImp = new SfxFrameDescriptor_Impl;
62 SfxFrameDescriptor::~SfxFrameDescriptor()
64 DBG_DTOR(SfxFrameDescriptor, 0);
65 delete pImp;
68 SfxItemSet* SfxFrameDescriptor::GetArgs()
70 if( !pImp->pArgs )
71 pImp->pArgs = new SfxAllItemSet( SFX_APP()->GetPool() );
72 return pImp->pArgs;
75 void SfxFrameDescriptor::SetURL( const String& rURL )
77 aURL = INetURLObject(rURL);
78 SetActualURL( aURL );
81 void SfxFrameDescriptor::SetActualURL( const String& rURL )
83 aActualURL = INetURLObject(rURL);
84 if ( pImp->pArgs )
85 pImp->pArgs->ClearItem();
88 void SfxFrameDescriptor::SetActualURL( const INetURLObject& rURL )
90 SetActualURL(String(rURL.GetMainURL( INetURLObject::DECODE_TO_IURI )));
93 void SfxFrameDescriptor::SetEditable( sal_Bool bSet )
95 pImp->bEditable = bSet;
98 sal_Bool SfxFrameDescriptor::IsEditable() const
100 return pImp->bEditable;
103 SfxFrameDescriptor* SfxFrameDescriptor::Clone( sal_Bool bWithIds ) const
105 SfxFrameDescriptor *pFrame = new SfxFrameDescriptor;
107 pFrame->aURL = aURL;
108 pFrame->aActualURL = aActualURL;
109 pFrame->aName = aName;
110 pFrame->aMargin = aMargin;
111 pFrame->nWidth = nWidth;
112 pFrame->eSizeSelector = eSizeSelector;
113 pFrame->eScroll = eScroll;
114 pFrame->bResizeHorizontal = bResizeHorizontal;
115 pFrame->bResizeVertical = bResizeVertical;
116 pFrame->nHasBorder = nHasBorder;
117 pFrame->bHasUI = bHasUI;
118 pFrame->SetReadOnly( IsReadOnly() );
119 pFrame->SetEditable( IsEditable() );
120 if ( pImp->pWallpaper )
121 pFrame->pImp->pWallpaper = new Wallpaper( *pImp->pWallpaper );
122 if( pImp->pArgs )
124 // Currently in the clone of SfxAllItemSets there is still a bug ...
125 pFrame->pImp->pArgs = new SfxAllItemSet( SFX_APP()->GetPool() );
126 pFrame->pImp->pArgs->Put(*pImp->pArgs);
129 if ( bWithIds )
130 pFrame->nItemId = nItemId;
131 else
132 pFrame->nItemId = 0;
134 return pFrame;
137 sal_Bool SfxFrameDescriptor::HasFrameBorder() const
139 return (nHasBorder & BORDER_YES) != 0;
142 void SfxFrameDescriptor::SetWallpaper( const Wallpaper& rWallpaper )
144 DELETEZ( pImp->pWallpaper );
146 if ( rWallpaper.GetStyle() != WALLPAPER_NULL )
147 pImp->pWallpaper = new Wallpaper( rWallpaper );
150 SfxFrameProperties& SfxFrameProperties::operator =(
151 const SfxFrameProperties &rProp )
153 aURL = rProp.aURL;
154 aName = rProp.aName;
155 lMarginWidth = rProp.lMarginWidth;
156 lMarginHeight = rProp.lMarginHeight;
157 lSize = rProp.lSize;
158 lSetSize = rProp.lSetSize;
159 lFrameSpacing = rProp.lFrameSpacing;
160 lInheritedFrameSpacing = rProp.lInheritedFrameSpacing;
161 eScroll = rProp.eScroll;
162 eSizeSelector = rProp.eSizeSelector;
163 eSetSizeSelector = rProp.eSetSizeSelector;
164 bHasBorder = rProp.bHasBorder;
165 bBorderSet = rProp.bBorderSet;
166 bResizable = rProp.bResizable;
167 bSetResizable = rProp.bSetResizable;
168 bIsRootSet = rProp.bIsRootSet;
169 bIsInColSet = rProp.bIsInColSet;
170 bHasBorderInherited = rProp.bHasBorderInherited;
171 pFrame = rProp.pFrame->Clone();
172 return *this;
175 int SfxFrameProperties::operator ==( const SfxFrameProperties& rProp ) const
177 return aURL == rProp.aURL && aName == rProp.aName && lMarginWidth == rProp.lMarginWidth && lMarginHeight == rProp.lMarginHeight &&
178 lSize == rProp.lSize && eScroll == rProp.eScroll && eSizeSelector == rProp.eSizeSelector &&
179 lSetSize == rProp.lSetSize && lFrameSpacing == rProp.lFrameSpacing && eSetSizeSelector == rProp.eSetSizeSelector &&
180 bHasBorder == rProp.bHasBorder && bBorderSet == rProp.bBorderSet &&
181 bResizable == rProp.bResizable && bSetResizable == rProp.bSetResizable;
184 TYPEINIT1(SfxFrameDescriptorItem, SfxPoolItem);
186 SfxFrameDescriptorItem::~SfxFrameDescriptorItem()
189 int SfxFrameDescriptorItem::operator==( const SfxPoolItem& rAttr ) const
191 DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
193 return aProperties == ((SfxFrameDescriptorItem&)rAttr).aProperties;
196 // -----------------------------------------------------------------------
198 SfxPoolItem* SfxFrameDescriptorItem::Clone( SfxItemPool* ) const
200 return new SfxFrameDescriptorItem( *this );
203 //------------------------------------------------------------------------
205 SfxItemPresentation SfxFrameDescriptorItem::GetPresentation
207 SfxItemPresentation /*ePres*/,
208 SfxMapUnit /*eCoreUnit*/,
209 SfxMapUnit /*ePresUnit*/,
210 OUString& rText,
211 const IntlWrapper *
212 ) const
214 rText = OUString();
215 return SFX_ITEM_PRESENTATION_NONE;
219 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */