xref: /aoo42x/main/sw/source/ui/inc/frmmgr.hxx (revision 1d2dbeb0)
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 _FRMMGR_HXX
24 #define _FRMMGR_HXX
25 
26 #include "swtypes.hxx"
27 #include "frmatr.hxx"
28 #include <editeng/svxenum.hxx>
29 #include <tools/gen.hxx>
30 #include <fmtfsize.hxx>
31 #include <fmtsrnd.hxx>
32 #include <fmtornt.hxx>
33 #include <fmtanchr.hxx>
34 #include "swdllapi.h"
35 
36 class	SwWrtShell;
37 struct  SvxSwFrameValidation;
38 struct  SwPosition;
39 
40 class	SwFmt;
41 class	SwFmtCol;
42 
43 const SwTwips	DFLT_WIDTH		= MM50 * 4;
44 const SwTwips	DFLT_HEIGHT 	= MM50;
45 
46 #define FULL_ATTRSET	0xffff
47 
48 #define FRMMGR_TYPE_NONE	0x00
49 #define FRMMGR_TYPE_TEXT 	0x01
50 #define FRMMGR_TYPE_GRF  	0x02
51 #define FRMMGR_TYPE_OLE  	0x04
52 #define FRMMGR_TYPE_LABEL   0x08
53 #define FRMMGR_TYPE_ENVELP	0x10
54 
55 class SW_DLLPUBLIC SwFlyFrmAttrMgr
56 {
57 	SfxItemSet	aSet;
58 	Point		aAbsPos;
59 	SwWrtShell	*pOwnSh;
60 
61 	sal_Bool		bAbsPos,
62 				bNewFrm;
63     sal_Bool        bIsInVertical;
64     // --> OD 2009-09-01 #mongolianlayout#
65     sal_Bool        bIsInVerticalL2R;
66     // <--
67 
68 	// interne Verrechnung fuer Umrandung
69 	SW_DLLPRIVATE SwTwips 			CalcTopSpace();
70 	SW_DLLPRIVATE SwTwips 			CalcBottomSpace();
71 	SW_DLLPRIVATE SwTwips 			CalcLeftSpace();
72 	SW_DLLPRIVATE SwTwips 			CalcRightSpace();
73 
74 	SW_DLLPRIVATE void _UpdateFlyFrm();	//Nacharbeit nach Einfuegen oder Update
75 
76 public:
77 	SwFlyFrmAttrMgr( sal_Bool bNew, SwWrtShell* pSh, sal_uInt8 nType );
78 
79 	//CopyCtor fuer die Dialoge, zum Pruefen der Metrics
80 	SwFlyFrmAttrMgr( sal_Bool bNew, SwWrtShell *pSh, const SfxItemSet &rSet );
81 
GetShell()82 	inline SwWrtShell*	GetShell() { return pOwnSh; }
83 
84 	void				SetAnchor(RndStdIds eId);
85 	inline RndStdIds	GetAnchor()  const;
86 
87     void                SetHorzOrientation(sal_Int16 eOrient);
88     void                SetVertOrientation(sal_Int16 eOrient);
89 
90 	// Absolute Position
91 	void				SetAbsPos(const Point& rLPoint);
92 
93 	// Relative Position vom Anker
94 	void				SetPos(const Point& rLPoint);
95 	inline Point		GetPos() const;
96 
97 	// Groesse
98 	void				SetSize(const Size& rLSize);
99 	inline const Size&	GetSize() const;
100 
101 	inline sal_uInt16		GetHeightPercent() const;
102 
103     void                SetHeightSizeType(SwFrmSize eType);
104 
105 	// Abstand zum Inhalt
106 	void				SetLRSpace( long nLeft	= LONG_MAX,
107 									long nRight = LONG_MAX );
108 	void				SetULSpace( long nTop	= LONG_MAX,
109 									long nBottom= LONG_MAX );
110 
111 	void				SetCol( const SwFmtCol &rCol);
112 
113 	// Attribute aendern und erfragen
114 	void				UpdateAttrMgr();
115 	void				UpdateFlyFrm();
116 
117 	// neuen Rahmen erzeugen
118 	sal_Bool				InsertFlyFrm();
119 	void				InsertFlyFrm(RndStdIds		eAnchorType,
120 								   const Point	  &rPos,
121 								   const Size	  &rSize,
122 								   sal_Bool 		  bAbsPos = sal_False);
123 
124 	// Metriken pruefen und  aendern
125     void                ValidateMetrics(SvxSwFrameValidation& rVal,
126                             const SwPosition* pToCharCntntPos,
127                             sal_Bool bOnlyPercentRefValue = sal_False);
128 
129 	void				DelAttr(sal_uInt16 nId);
130 
131 	// Set rausreichen
GetAttrSet() const132 	inline const SfxItemSet &GetAttrSet() const { return aSet; }
GetAttrSet()133 	inline 		 SfxItemSet &GetAttrSet() 		{ return aSet; }
134 	void					 SetAttrSet(const SfxItemSet& rSet);
135 
136 	inline const SwFmtVertOrient &GetVertOrient() const;
137 	inline const SwFmtHoriOrient &GetHoriOrient() const;
138 	inline const SvxShadowItem   &GetShadow() const;
139 	inline const SvxBoxItem		 &GetBox() const;
140 	inline const SwFmtSurround	 &GetSurround() const;
141 	inline const SwFmtFrmSize    &GetFrmSize() const;
142 
CalcWidthBorder()143 	long CalcWidthBorder()  { return CalcLeftSpace()+CalcRightSpace(); }
CalcHeightBorder()144 	long CalcHeightBorder() { return CalcTopSpace()+CalcBottomSpace(); }
145 };
146 
GetSize() const147 inline const Size& SwFlyFrmAttrMgr::GetSize() const
148 {
149 	return ((SwFmtFrmSize&)aSet.Get(RES_FRM_SIZE)).GetSize();
150 }
151 
GetVertOrient() const152 inline const SwFmtVertOrient &SwFlyFrmAttrMgr::GetVertOrient() const
153 {
154 	return ((SwFmtVertOrient&)aSet.Get(RES_VERT_ORIENT));
155 }
GetHoriOrient() const156 inline const SwFmtHoriOrient &SwFlyFrmAttrMgr::GetHoriOrient() const
157 {
158 	return ((SwFmtHoriOrient &)aSet.Get(RES_HORI_ORIENT));
159 }
GetFrmSize() const160 inline const SwFmtFrmSize& SwFlyFrmAttrMgr::GetFrmSize() const
161 {
162 	return ((SwFmtFrmSize&)aSet.Get(RES_FRM_SIZE));
163 }
GetShadow() const164 inline const SvxShadowItem &SwFlyFrmAttrMgr::GetShadow() const
165 {
166 	return ((SvxShadowItem&)aSet.Get(RES_SHADOW));
167 }
GetBox() const168 inline const SvxBoxItem	&SwFlyFrmAttrMgr::GetBox() const
169 {
170 	return ((SvxBoxItem&)aSet.Get(RES_BOX));
171 }
GetSurround() const172 inline const SwFmtSurround &SwFlyFrmAttrMgr::GetSurround() const
173 {
174 	return ((SwFmtSurround&)aSet.Get(RES_SURROUND));
175 }
176 
GetPos() const177 inline Point SwFlyFrmAttrMgr::GetPos() const
178 {
179 	return Point( GetHoriOrient().GetPos(), GetVertOrient().GetPos() );
180 }
181 
GetAnchor() const182 inline RndStdIds SwFlyFrmAttrMgr::GetAnchor()  const
183 {
184 	return ((SwFmtAnchor&)aSet.Get(RES_ANCHOR)).GetAnchorId();
185 }
186 
GetHeightPercent() const187 inline sal_uInt16 SwFlyFrmAttrMgr::GetHeightPercent() const
188 {
189 	return GetFrmSize().GetHeightPercent();
190 }
191 
192 #endif
193