Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 :
21 : #include <sot/object.hxx>
22 : #include <tools/stream.hxx>
23 : #include <vcl/splitwin.hxx>
24 : #include <svl/itemset.hxx>
25 :
26 : #include <sfx2/frmdescr.hxx>
27 : #include <sfx2/app.hxx>
28 :
29 : struct SfxFrameDescriptor_Impl
30 : {
31 : Wallpaper* pWallpaper;
32 : SfxItemSet* pArgs;
33 : bool bEditable;
34 :
35 0 : SfxFrameDescriptor_Impl() : pWallpaper( NULL ), pArgs( NULL ), bEditable( true ) {}
36 0 : ~SfxFrameDescriptor_Impl()
37 : {
38 0 : delete pWallpaper;
39 0 : delete pArgs;
40 0 : }
41 : };
42 :
43 0 : SfxFrameDescriptor::SfxFrameDescriptor() :
44 : aMargin( -1, -1 ),
45 : nWidth( 0L ),
46 : eScroll( ScrollingAuto ),
47 : eSizeSelector( SIZE_ABS ),
48 : nHasBorder( BORDER_YES ),
49 : nItemId( 0 ),
50 : bResizeHorizontal( true ),
51 : bResizeVertical( true ),
52 : bHasUI( true ),
53 0 : bReadOnly( false )
54 : {
55 :
56 0 : pImp = new SfxFrameDescriptor_Impl;
57 0 : }
58 :
59 0 : SfxFrameDescriptor::~SfxFrameDescriptor()
60 : {
61 0 : delete pImp;
62 0 : }
63 :
64 0 : SfxItemSet* SfxFrameDescriptor::GetArgs()
65 : {
66 0 : if( !pImp->pArgs )
67 0 : pImp->pArgs = new SfxAllItemSet( SFX_APP()->GetPool() );
68 0 : return pImp->pArgs;
69 : }
70 :
71 0 : void SfxFrameDescriptor::SetURL( const OUString& rURL )
72 : {
73 0 : aURL = INetURLObject(rURL);
74 0 : SetActualURL( aURL );
75 0 : }
76 :
77 0 : void SfxFrameDescriptor::SetActualURL( const OUString& rURL )
78 : {
79 0 : aActualURL = INetURLObject(rURL);
80 0 : if ( pImp->pArgs )
81 0 : pImp->pArgs->ClearItem();
82 0 : }
83 :
84 0 : void SfxFrameDescriptor::SetActualURL( const INetURLObject& rURL )
85 : {
86 0 : SetActualURL(rURL.GetMainURL( INetURLObject::DECODE_TO_IURI ));
87 0 : }
88 :
89 0 : void SfxFrameDescriptor::SetEditable( bool bSet )
90 : {
91 0 : pImp->bEditable = bSet;
92 0 : }
93 :
94 0 : bool SfxFrameDescriptor::IsEditable() const
95 : {
96 0 : return pImp->bEditable;
97 : }
98 :
99 0 : SfxFrameDescriptor* SfxFrameDescriptor::Clone( bool bWithIds ) const
100 : {
101 0 : SfxFrameDescriptor *pFrame = new SfxFrameDescriptor;
102 :
103 0 : pFrame->aURL = aURL;
104 0 : pFrame->aActualURL = aActualURL;
105 0 : pFrame->aName = aName;
106 0 : pFrame->aMargin = aMargin;
107 0 : pFrame->nWidth = nWidth;
108 0 : pFrame->eSizeSelector = eSizeSelector;
109 0 : pFrame->eScroll = eScroll;
110 0 : pFrame->bResizeHorizontal = bResizeHorizontal;
111 0 : pFrame->bResizeVertical = bResizeVertical;
112 0 : pFrame->nHasBorder = nHasBorder;
113 0 : pFrame->bHasUI = bHasUI;
114 0 : pFrame->SetReadOnly( IsReadOnly() );
115 0 : pFrame->SetEditable( IsEditable() );
116 0 : if ( pImp->pWallpaper )
117 0 : pFrame->pImp->pWallpaper = new Wallpaper( *pImp->pWallpaper );
118 0 : if( pImp->pArgs )
119 : {
120 : // Currently in the clone of SfxAllItemSets there is still a bug ...
121 0 : pFrame->pImp->pArgs = new SfxAllItemSet( SFX_APP()->GetPool() );
122 0 : pFrame->pImp->pArgs->Put(*pImp->pArgs);
123 : }
124 :
125 0 : if ( bWithIds )
126 0 : pFrame->nItemId = nItemId;
127 : else
128 0 : pFrame->nItemId = 0;
129 :
130 0 : return pFrame;
131 : }
132 :
133 0 : bool SfxFrameDescriptor::HasFrameBorder() const
134 : {
135 0 : return (nHasBorder & BORDER_YES) != 0;
136 : }
137 :
138 0 : void SfxFrameDescriptor::SetWallpaper( const Wallpaper& rWallpaper )
139 : {
140 0 : DELETEZ( pImp->pWallpaper );
141 :
142 0 : if ( rWallpaper.GetStyle() != WALLPAPER_NULL )
143 0 : pImp->pWallpaper = new Wallpaper( rWallpaper );
144 0 : }
145 :
146 0 : SfxFrameProperties& SfxFrameProperties::operator =(
147 : const SfxFrameProperties &rProp )
148 : {
149 0 : aURL = rProp.aURL;
150 0 : aName = rProp.aName;
151 0 : lMarginWidth = rProp.lMarginWidth;
152 0 : lMarginHeight = rProp.lMarginHeight;
153 0 : lSize = rProp.lSize;
154 0 : lSetSize = rProp.lSetSize;
155 0 : lFrameSpacing = rProp.lFrameSpacing;
156 0 : lInheritedFrameSpacing = rProp.lInheritedFrameSpacing;
157 0 : eScroll = rProp.eScroll;
158 0 : eSizeSelector = rProp.eSizeSelector;
159 0 : eSetSizeSelector = rProp.eSetSizeSelector;
160 0 : bHasBorder = rProp.bHasBorder;
161 0 : bBorderSet = rProp.bBorderSet;
162 0 : bResizable = rProp.bResizable;
163 0 : bSetResizable = rProp.bSetResizable;
164 0 : bIsRootSet = rProp.bIsRootSet;
165 0 : bIsInColSet = rProp.bIsInColSet;
166 0 : bHasBorderInherited = rProp.bHasBorderInherited;
167 0 : pFrame = rProp.pFrame->Clone();
168 0 : return *this;
169 : }
170 :
171 0 : bool SfxFrameProperties::operator ==( const SfxFrameProperties& rProp ) const
172 : {
173 0 : return aURL == rProp.aURL && aName == rProp.aName && lMarginWidth == rProp.lMarginWidth && lMarginHeight == rProp.lMarginHeight &&
174 0 : lSize == rProp.lSize && eScroll == rProp.eScroll && eSizeSelector == rProp.eSizeSelector &&
175 0 : lSetSize == rProp.lSetSize && lFrameSpacing == rProp.lFrameSpacing && eSetSizeSelector == rProp.eSetSizeSelector &&
176 0 : bHasBorder == rProp.bHasBorder && bBorderSet == rProp.bBorderSet &&
177 0 : bResizable == rProp.bResizable && bSetResizable == rProp.bSetResizable;
178 : }
179 :
180 0 : TYPEINIT1(SfxFrameDescriptorItem, SfxPoolItem);
181 :
182 0 : SfxFrameDescriptorItem::~SfxFrameDescriptorItem()
183 0 : {}
184 :
185 0 : bool SfxFrameDescriptorItem::operator==( const SfxPoolItem& rAttr ) const
186 : {
187 : DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
188 :
189 0 : return aProperties == ((SfxFrameDescriptorItem&)rAttr).aProperties;
190 : }
191 :
192 :
193 :
194 0 : SfxPoolItem* SfxFrameDescriptorItem::Clone( SfxItemPool* ) const
195 : {
196 0 : return new SfxFrameDescriptorItem( *this );
197 : }
198 :
199 :
200 :
201 0 : SfxItemPresentation SfxFrameDescriptorItem::GetPresentation
202 : (
203 : SfxItemPresentation /*ePres*/,
204 : SfxMapUnit /*eCoreUnit*/,
205 : SfxMapUnit /*ePresUnit*/,
206 : OUString& rText,
207 : const IntlWrapper *
208 : ) const
209 : {
210 0 : rText = OUString();
211 0 : return SFX_ITEM_PRESENTATION_NONE;
212 : }
213 :
214 :
215 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|