xref: /AOO41X/main/sw/source/ui/inc/frmmgr.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir #ifndef _FRMMGR_HXX
28*cdf0e10cSrcweir #define _FRMMGR_HXX
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include "swtypes.hxx"
31*cdf0e10cSrcweir #include "frmatr.hxx"
32*cdf0e10cSrcweir #include <editeng/svxenum.hxx>
33*cdf0e10cSrcweir #include <tools/gen.hxx>
34*cdf0e10cSrcweir #include <fmtfsize.hxx>
35*cdf0e10cSrcweir #include <fmtsrnd.hxx>
36*cdf0e10cSrcweir #include <fmtornt.hxx>
37*cdf0e10cSrcweir #include <fmtanchr.hxx>
38*cdf0e10cSrcweir #include "swdllapi.h"
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir class	SwWrtShell;
41*cdf0e10cSrcweir struct  SvxSwFrameValidation;
42*cdf0e10cSrcweir struct  SwPosition;
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir class	SwFmt;
45*cdf0e10cSrcweir class	SwFmtCol;
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir const SwTwips	DFLT_WIDTH		= MM50 * 4;
48*cdf0e10cSrcweir const SwTwips	DFLT_HEIGHT 	= MM50;
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir #define FULL_ATTRSET	0xffff
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir #define FRMMGR_TYPE_NONE	0x00
53*cdf0e10cSrcweir #define FRMMGR_TYPE_TEXT 	0x01
54*cdf0e10cSrcweir #define FRMMGR_TYPE_GRF  	0x02
55*cdf0e10cSrcweir #define FRMMGR_TYPE_OLE  	0x04
56*cdf0e10cSrcweir #define FRMMGR_TYPE_LABEL   0x08
57*cdf0e10cSrcweir #define FRMMGR_TYPE_ENVELP	0x10
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir class SW_DLLPUBLIC SwFlyFrmAttrMgr
60*cdf0e10cSrcweir {
61*cdf0e10cSrcweir 	SfxItemSet	aSet;
62*cdf0e10cSrcweir 	Point		aAbsPos;
63*cdf0e10cSrcweir 	SwWrtShell	*pOwnSh;
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir 	sal_Bool		bAbsPos,
66*cdf0e10cSrcweir 				bNewFrm;
67*cdf0e10cSrcweir     sal_Bool        bIsInVertical;
68*cdf0e10cSrcweir     // --> OD 2009-09-01 #mongolianlayout#
69*cdf0e10cSrcweir     sal_Bool        bIsInVerticalL2R;
70*cdf0e10cSrcweir     // <--
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir 	// interne Verrechnung fuer Umrandung
73*cdf0e10cSrcweir 	SW_DLLPRIVATE SwTwips 			CalcTopSpace();
74*cdf0e10cSrcweir 	SW_DLLPRIVATE SwTwips 			CalcBottomSpace();
75*cdf0e10cSrcweir 	SW_DLLPRIVATE SwTwips 			CalcLeftSpace();
76*cdf0e10cSrcweir 	SW_DLLPRIVATE SwTwips 			CalcRightSpace();
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir 	SW_DLLPRIVATE void _UpdateFlyFrm();	//Nacharbeit nach Einfuegen oder Update
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir public:
81*cdf0e10cSrcweir 	SwFlyFrmAttrMgr( sal_Bool bNew, SwWrtShell* pSh, sal_uInt8 nType );
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir 	//CopyCtor fuer die Dialoge, zum Pruefen der Metrics
84*cdf0e10cSrcweir 	SwFlyFrmAttrMgr( sal_Bool bNew, SwWrtShell *pSh, const SfxItemSet &rSet );
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir 	inline SwWrtShell*	GetShell() { return pOwnSh; }
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir 	void				SetAnchor(RndStdIds eId);
89*cdf0e10cSrcweir 	inline RndStdIds	GetAnchor()  const;
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir     void                SetHorzOrientation(sal_Int16 eOrient);
92*cdf0e10cSrcweir     void                SetVertOrientation(sal_Int16 eOrient);
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir 	// Absolute Position
95*cdf0e10cSrcweir 	void				SetAbsPos(const Point& rLPoint);
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir 	// Relative Position vom Anker
98*cdf0e10cSrcweir 	void				SetPos(const Point& rLPoint);
99*cdf0e10cSrcweir 	inline Point		GetPos() const;
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir 	// Groesse
102*cdf0e10cSrcweir 	void				SetSize(const Size& rLSize);
103*cdf0e10cSrcweir 	inline const Size&	GetSize() const;
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir 	inline sal_uInt16		GetHeightPercent() const;
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir     void                SetHeightSizeType(SwFrmSize eType);
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir 	// Abstand zum Inhalt
110*cdf0e10cSrcweir 	void				SetLRSpace( long nLeft	= LONG_MAX,
111*cdf0e10cSrcweir 									long nRight = LONG_MAX );
112*cdf0e10cSrcweir 	void				SetULSpace( long nTop	= LONG_MAX,
113*cdf0e10cSrcweir 									long nBottom= LONG_MAX );
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir 	void				SetCol( const SwFmtCol &rCol);
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir 	// Attribute aendern und erfragen
118*cdf0e10cSrcweir 	void				UpdateAttrMgr();
119*cdf0e10cSrcweir 	void				UpdateFlyFrm();
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir 	// neuen Rahmen erzeugen
122*cdf0e10cSrcweir 	sal_Bool				InsertFlyFrm();
123*cdf0e10cSrcweir 	void				InsertFlyFrm(RndStdIds		eAnchorType,
124*cdf0e10cSrcweir 								   const Point	  &rPos,
125*cdf0e10cSrcweir 								   const Size	  &rSize,
126*cdf0e10cSrcweir 								   sal_Bool 		  bAbsPos = sal_False);
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir 	// Metriken pruefen und  aendern
129*cdf0e10cSrcweir     void                ValidateMetrics(SvxSwFrameValidation& rVal,
130*cdf0e10cSrcweir                             const SwPosition* pToCharCntntPos,
131*cdf0e10cSrcweir                             sal_Bool bOnlyPercentRefValue = sal_False);
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir 	void				DelAttr(sal_uInt16 nId);
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir 	// Set rausreichen
136*cdf0e10cSrcweir 	inline const SfxItemSet &GetAttrSet() const { return aSet; }
137*cdf0e10cSrcweir 	inline 		 SfxItemSet &GetAttrSet() 		{ return aSet; }
138*cdf0e10cSrcweir 	void					 SetAttrSet(const SfxItemSet& rSet);
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir 	inline const SwFmtVertOrient &GetVertOrient() const;
141*cdf0e10cSrcweir 	inline const SwFmtHoriOrient &GetHoriOrient() const;
142*cdf0e10cSrcweir 	inline const SvxShadowItem   &GetShadow() const;
143*cdf0e10cSrcweir 	inline const SvxBoxItem		 &GetBox() const;
144*cdf0e10cSrcweir 	inline const SwFmtSurround	 &GetSurround() const;
145*cdf0e10cSrcweir 	inline const SwFmtFrmSize    &GetFrmSize() const;
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir 	long CalcWidthBorder()  { return CalcLeftSpace()+CalcRightSpace(); }
148*cdf0e10cSrcweir 	long CalcHeightBorder() { return CalcTopSpace()+CalcBottomSpace(); }
149*cdf0e10cSrcweir };
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir inline const Size& SwFlyFrmAttrMgr::GetSize() const
152*cdf0e10cSrcweir {
153*cdf0e10cSrcweir 	return ((SwFmtFrmSize&)aSet.Get(RES_FRM_SIZE)).GetSize();
154*cdf0e10cSrcweir }
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir inline const SwFmtVertOrient &SwFlyFrmAttrMgr::GetVertOrient() const
157*cdf0e10cSrcweir {
158*cdf0e10cSrcweir 	return ((SwFmtVertOrient&)aSet.Get(RES_VERT_ORIENT));
159*cdf0e10cSrcweir }
160*cdf0e10cSrcweir inline const SwFmtHoriOrient &SwFlyFrmAttrMgr::GetHoriOrient() const
161*cdf0e10cSrcweir {
162*cdf0e10cSrcweir 	return ((SwFmtHoriOrient &)aSet.Get(RES_HORI_ORIENT));
163*cdf0e10cSrcweir }
164*cdf0e10cSrcweir inline const SwFmtFrmSize& SwFlyFrmAttrMgr::GetFrmSize() const
165*cdf0e10cSrcweir {
166*cdf0e10cSrcweir 	return ((SwFmtFrmSize&)aSet.Get(RES_FRM_SIZE));
167*cdf0e10cSrcweir }
168*cdf0e10cSrcweir inline const SvxShadowItem &SwFlyFrmAttrMgr::GetShadow() const
169*cdf0e10cSrcweir {
170*cdf0e10cSrcweir 	return ((SvxShadowItem&)aSet.Get(RES_SHADOW));
171*cdf0e10cSrcweir }
172*cdf0e10cSrcweir inline const SvxBoxItem	&SwFlyFrmAttrMgr::GetBox() const
173*cdf0e10cSrcweir {
174*cdf0e10cSrcweir 	return ((SvxBoxItem&)aSet.Get(RES_BOX));
175*cdf0e10cSrcweir }
176*cdf0e10cSrcweir inline const SwFmtSurround &SwFlyFrmAttrMgr::GetSurround() const
177*cdf0e10cSrcweir {
178*cdf0e10cSrcweir 	return ((SwFmtSurround&)aSet.Get(RES_SURROUND));
179*cdf0e10cSrcweir }
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir inline Point SwFlyFrmAttrMgr::GetPos() const
182*cdf0e10cSrcweir {
183*cdf0e10cSrcweir 	return Point( GetHoriOrient().GetPos(), GetVertOrient().GetPos() );
184*cdf0e10cSrcweir }
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir inline RndStdIds SwFlyFrmAttrMgr::GetAnchor()  const
187*cdf0e10cSrcweir {
188*cdf0e10cSrcweir 	return ((SwFmtAnchor&)aSet.Get(RES_ANCHOR)).GetAnchorId();
189*cdf0e10cSrcweir }
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir inline sal_uInt16 SwFlyFrmAttrMgr::GetHeightPercent() const
192*cdf0e10cSrcweir {
193*cdf0e10cSrcweir 	return GetFrmSize().GetHeightPercent();
194*cdf0e10cSrcweir }
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir #endif
197