xref: /AOO41X/main/sfx2/inc/sfx2/frmdescr.hxx (revision 353d8f4d17010cd2d0ea815067cad67e477f2bee)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _SFX_FRMDESCRHXX
24 #define _SFX_FRMDESCRHXX
25 
26 #include "sal/config.h"
27 #include "sfx2/dllapi.h"
28 
29 #include <sfx2/sfxsids.hrc>
30 #include <svl/poolitem.hxx>
31 #include <tools/urlobj.hxx>
32 #include <tools/string.hxx>
33 #include <svl/svarray.hxx>
34 #include <tools/gen.hxx>
35 
36 class SvStream;
37 struct SfxFrameDescriptor_Impl;
38 class SvStrings;
39 class SfxFrameDescriptor;
40 class Wallpaper;
41 typedef SfxFrameDescriptor* SfxFrameDescriptorPtr;
42 SV_DECL_PTRARR(SfxFramesArr, SfxFrameDescriptorPtr, 4, 2)
43 
44 //===========================================================================
45 // Die SfxFrame...descriptoren bauen eine rekursive Struktur auf, die
46 // s"amtliche zur Anzeige des Frame-Dokuments erforderlichen Daten umfa\st.
47 // "Uber einen SfxFrameSetDescriptor hat man Zugriff auf die gesamte darunter
48 // liegende Struktur.
49 // Aufgrund der besonderen Eigenschaften des SfxFrames-Dokuments ist ein
50 // SfxFramesSetDescriptor nicht nur der Inhalt dieses Dokuments, sondern
51 // beschreibt auch die View darauf.
52 // Das FrameSet wird aus Zeilen aufgebaut, die wiederum die eigentlichen
53 // Fenster enthalten. Eine Zeile kann horizontal oder vertikal ausgerichtet
54 // sein, woraus sich auch das Alignment des FrameSets ergibt.
55 //===========================================================================
56 
57 enum ScrollingMode
58 {
59     ScrollingYes,
60     ScrollingNo,
61     ScrollingAuto
62 };
63 
64 enum SizeSelector
65 {
66     SIZE_ABS,
67     SIZE_PERCENT,
68     SIZE_REL
69 };
70 
71 #define BORDER_SET          2
72 #define BORDER_YES          1
73 #define BORDER_NO           0
74 #define SPACING_NOT_SET     -1L
75 #define SIZE_NOT_SET        -1L
76 
77 class SfxItemSet;
78 struct SfxFrameProperties;
79 
80 class SFX2_DLLPUBLIC SfxFrameDescriptor
81 {
82     INetURLObject           aURL;
83     INetURLObject           aActualURL;
84     String                  aName;
85     Size                    aMargin;
86     long                    nWidth;
87     ScrollingMode           eScroll;
88     SizeSelector            eSizeSelector;
89     sal_uInt16                  nHasBorder;
90     sal_uInt16                  nItemId;
91     sal_Bool                    bResizeHorizontal;
92     sal_Bool                    bResizeVertical;
93     sal_Bool                    bHasUI;
94     sal_Bool                    bReadOnly;
95     SfxFrameDescriptor_Impl* pImp;
96     SvStrings*              pScripts;
97     SvStrings*              pComments;
98 
99 public:
100                             SfxFrameDescriptor();
101                             ~SfxFrameDescriptor();
102 
103                             // Eigenschaften
104     void                    TakeProperties( const SfxFrameProperties& rProp );
105 
106                             // FileName/URL
107     SfxItemSet*             GetArgs();
GetURL() const108     const INetURLObject&    GetURL() const
109                             { return aURL; }
110     void                    SetURL( const INetURLObject& rURL );
111     void                    SetURL( const String& rURL );
GetActualURL() const112     const INetURLObject&    GetActualURL() const
113                             { return aActualURL; }
114     void                    SetActualURL( const INetURLObject& rURL );
115     void                    SetActualURL( const String& rURL );
116     sal_Bool                    CheckContent() const;
117     sal_Bool                    CompareOriginal( SfxFrameDescriptor& rSet ) const;
118     void                    UnifyContent( sal_Bool );
SetReadOnly(sal_Bool bSet)119     void                    SetReadOnly( sal_Bool bSet ) { bReadOnly = bSet;}
IsReadOnly() const120     sal_Bool                    IsReadOnly(  ) const { return bReadOnly;}
121     void                    SetEditable( sal_Bool bSet );
122     sal_Bool                    IsEditable() const;
123 
124                             // Size
SetWidth(long n)125     void                    SetWidth( long n )
126                             { nWidth = n; }
SetWidthPercent(long n)127     void                    SetWidthPercent( long n )
128                             { nWidth = n; eSizeSelector = SIZE_PERCENT; }
SetWidthRel(long n)129     void                    SetWidthRel( long n )
130                             { nWidth = n; eSizeSelector = SIZE_REL; }
SetWidthAbs(long n)131     void                    SetWidthAbs( long n )
132                             { nWidth = n; eSizeSelector = SIZE_ABS; }
GetWidth() const133     long                    GetWidth() const
134                             { return nWidth; }
GetSizeSelector() const135     SizeSelector            GetSizeSelector() const
136                             { return eSizeSelector; }
IsResizable() const137     sal_Bool                    IsResizable() const
138                             { return bResizeHorizontal && bResizeVertical; }
SetResizable(sal_Bool bRes)139     void                    SetResizable( sal_Bool bRes )
140                             { bResizeHorizontal = bResizeVertical = bRes; }
141 
142                             // FrameName
GetName() const143     const String&           GetName() const
144                             { return aName; }
SetName(const String & rName)145     void                    SetName( const String& rName )
146                             { aName = rName; }
147 
148                             // Margin, Scrolling
GetMargin() const149     const Size&             GetMargin() const
150                             { return aMargin; }
SetMargin(const Size & rMargin)151     void                    SetMargin( const Size& rMargin )
152                             { aMargin = rMargin; }
GetScrollingMode() const153     ScrollingMode           GetScrollingMode() const
154                             { return eScroll; }
SetScrollingMode(ScrollingMode eMode)155     void                    SetScrollingMode( ScrollingMode eMode )
156                             { eScroll = eMode; }
157 
158                             // FrameBorder
159     void                    SetWallpaper( const Wallpaper& rWallpaper );
160     const Wallpaper*        GetWallpaper() const;
161     sal_Bool                    HasFrameBorder() const;
162 
IsFrameBorderOn() const163     sal_Bool                    IsFrameBorderOn() const
164                             { return ( nHasBorder & BORDER_YES ) != 0; }
165 
SetFrameBorder(sal_Bool bBorder)166     void                    SetFrameBorder( sal_Bool bBorder )
167                             {
168                                 nHasBorder = bBorder ?
169                                             BORDER_YES | BORDER_SET :
170                                             BORDER_NO | BORDER_SET;
171                             }
IsFrameBorderSet() const172     sal_Bool                    IsFrameBorderSet() const
173                             { return (nHasBorder & BORDER_SET) != 0; }
ResetBorder()174     void                    ResetBorder()
175                             { nHasBorder = 0; }
176 
HasUI() const177     sal_Bool                    HasUI() const
178                             { return bHasUI; }
SetHasUI(sal_Bool bOn)179     void                    SetHasUI( sal_Bool bOn )
180                             { bHasUI = bOn; }
181 
182                             // Attribute f"ur das Splitwindow
GetItemId() const183     sal_uInt16                  GetItemId() const
184                             { return nItemId; }
SetItemId(sal_uInt16 nId)185     void                    SetItemId( sal_uInt16 nId )
186                             { nItemId = nId; }
187     sal_uInt16                  GetWinBits() const;
188     long                    GetSize() const;
189     sal_uInt16                  GetItemPos() const;
190 
191                             // Kopie z.B. f"ur die Views
192     SfxFrameDescriptor*     Clone( sal_Bool bWithIds = sal_True ) const;
193 };
194 
195 // Kein Bock, einen operator= zu implementieren...
196 struct SfxFrameProperties
197 {
198     String                              aURL;
199     String                              aName;
200     long                                lMarginWidth;
201     long                                lMarginHeight;
202     long                                lSize;
203     long                                lSetSize;
204     long                                lFrameSpacing;
205     long                                lInheritedFrameSpacing;
206     ScrollingMode                       eScroll;
207     SizeSelector                        eSizeSelector;
208     SizeSelector                        eSetSizeSelector;
209     sal_Bool                                bHasBorder;
210     sal_Bool                                bBorderSet;
211     sal_Bool                                bResizable;
212     sal_Bool                                bSetResizable;
213     sal_Bool                                bIsRootSet;
214     sal_Bool                                bIsInColSet;
215     sal_Bool                                bHasBorderInherited;
216     SfxFrameDescriptor*                 pFrame;
217 
218 private:
SfxFramePropertiesSfxFrameProperties219     SfxFrameProperties( SfxFrameProperties& ) {}
220 public:
SfxFramePropertiesSfxFrameProperties221                                         SfxFrameProperties()
222                                             : lMarginWidth( SIZE_NOT_SET ),
223                                               lMarginHeight( SIZE_NOT_SET ),
224                                               lSize( 1L ),
225                                               lSetSize( 1L ),
226                                               lFrameSpacing( SPACING_NOT_SET ),
227                                               lInheritedFrameSpacing( SPACING_NOT_SET ),
228                                               eScroll( ScrollingAuto ),
229                                               eSizeSelector( SIZE_REL ),
230                                               eSetSizeSelector( SIZE_REL ),
231                                               bHasBorder( sal_True ),
232                                               bBorderSet( sal_True ),
233                                               bResizable( sal_True ),
234                                               bSetResizable( sal_True ),
235                                               bIsRootSet( sal_False ),
236                                               bIsInColSet( sal_False ),
237                                               bHasBorderInherited( sal_True ),
238                                               pFrame( 0 ) {}
239 
240                                         SfxFrameProperties( const SfxFrameDescriptor *pD );
~SfxFramePropertiesSfxFrameProperties241                                         ~SfxFrameProperties() { delete pFrame; }
242 
243     int                                 operator ==( const SfxFrameProperties& ) const;
244     SfxFrameProperties&                 operator =( const SfxFrameProperties &rProp );
245 };
246 
247 class SfxFrameDescriptorItem : public SfxPoolItem
248 {
249     SfxFrameProperties                  aProperties;
250 public:
251                                         TYPEINFO();
252 
SfxFrameDescriptorItem(const SfxFrameDescriptor * pD,const sal_uInt16 nId=SID_FRAMEDESCRIPTOR)253                                         SfxFrameDescriptorItem ( const SfxFrameDescriptor *pD, const sal_uInt16 nId = SID_FRAMEDESCRIPTOR )
254                                             : SfxPoolItem( nId )
255                                             , aProperties( pD )
256                                         {}
257 
SfxFrameDescriptorItem(const sal_uInt16 nId=SID_FRAMEDESCRIPTOR)258                                         SfxFrameDescriptorItem ( const sal_uInt16 nId = SID_FRAMEDESCRIPTOR )
259                                             : SfxPoolItem( nId )
260                                         {}
261 
SfxFrameDescriptorItem(const SfxFrameDescriptorItem & rCpy)262                                         SfxFrameDescriptorItem( const SfxFrameDescriptorItem& rCpy )
263                                             : SfxPoolItem( rCpy )
264                                         {
265                                             aProperties = rCpy.aProperties;
266                                         }
267 
268     virtual                             ~SfxFrameDescriptorItem();
269 
270     virtual int                         operator ==( const SfxPoolItem& ) const;
271     SfxFrameDescriptorItem&             operator =( const SfxFrameDescriptorItem & );
272 
273     virtual SfxItemPresentation         GetPresentation( SfxItemPresentation ePres,
274                                             SfxMapUnit eCoreMetric,
275                                             SfxMapUnit ePresMetric,
276                                             UniString &rText, const IntlWrapper * = 0 ) const;
277 
278     virtual SfxPoolItem*                Clone( SfxItemPool *pPool = 0 ) const;
279     //virtual SfxPoolItem*              Create(SvStream &, sal_uInt16) const;
280     //virtual SvStream&                 Store(SvStream &, sal_uInt16 nItemVersion ) const;
281     //virtual sal_uInt16                        GetVersion( sal_uInt16 nFileFormatVersion ) const;
282 
GetProperties() const283     const SfxFrameProperties&           GetProperties() const
284                                         { return aProperties; }
SetProperties(const SfxFrameProperties & rProp)285     void                                SetProperties( const SfxFrameProperties& rProp )
286                                         { aProperties = rProp; }
287 };
288 
289 #endif // #ifndef _SFX_FRMDESCRHXX
290 
291