1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: frmmgr.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 #include "swtypes.hxx"
35 #include <svx/svxenum.hxx>
36 #include <tools/gen.hxx>
37 #include <fmtfsize.hxx>
38 #include <fmtsrnd.hxx>
39 #include <fmtornt.hxx>
40 #include <fmtanchr.hxx>
44 struct SvxSwFrameValidation
;
50 const SwTwips DFLT_WIDTH
= MM50
* 4;
51 const SwTwips DFLT_HEIGHT
= MM50
;
53 #define FULL_ATTRSET 0xffff
55 #define FRMMGR_TYPE_NONE 0x00
56 #define FRMMGR_TYPE_TEXT 0x01
57 #define FRMMGR_TYPE_GRF 0x02
58 #define FRMMGR_TYPE_OLE 0x04
59 #define FRMMGR_TYPE_LABEL 0x08
60 #define FRMMGR_TYPE_ENVELP 0x10
62 class SW_DLLPUBLIC SwFlyFrmAttrMgr
72 // interne Verrechnung fuer Umrandung
73 SW_DLLPRIVATE SwTwips
CalcTopSpace();
74 SW_DLLPRIVATE SwTwips
CalcBottomSpace();
75 SW_DLLPRIVATE SwTwips
CalcLeftSpace();
76 SW_DLLPRIVATE SwTwips
CalcRightSpace();
78 SW_DLLPRIVATE
void _UpdateFlyFrm(); //Nacharbeit nach Einfuegen oder Update
81 SwFlyFrmAttrMgr( BOOL bNew
, SwWrtShell
* pSh
, BYTE nType
);
83 //CopyCtor fuer die Dialoge, zum Pruefen der Metrics
84 SwFlyFrmAttrMgr( BOOL bNew
, SwWrtShell
*pSh
, const SfxItemSet
&rSet
);
86 inline SwWrtShell
* GetShell() { return pOwnSh
; }
88 void SetAnchor(RndStdIds eId
);
89 inline RndStdIds
GetAnchor() const;
91 void SetHorzOrientation(sal_Int16 eOrient
);
92 void SetVertOrientation(sal_Int16 eOrient
);
95 void SetAbsPos(const Point
& rLPoint
);
97 // Relative Position vom Anker
98 void SetPos(const Point
& rLPoint
);
99 inline Point
GetPos() const;
102 void SetSize(const Size
& rLSize
);
103 inline const Size
& GetSize() const;
105 inline USHORT
GetHeightPercent() const;
107 void SetHeightSizeType(SwFrmSize eType
);
109 // Abstand zum Inhalt
110 void SetLRSpace( long nLeft
= LONG_MAX
,
111 long nRight
= LONG_MAX
);
112 void SetULSpace( long nTop
= LONG_MAX
,
113 long nBottom
= LONG_MAX
);
115 void SetCol( const SwFmtCol
&rCol
);
117 // Attribute aendern und erfragen
118 void UpdateAttrMgr();
121 // neuen Rahmen erzeugen
123 void InsertFlyFrm(RndStdIds eAnchorType
,
126 BOOL bAbsPos
= FALSE
);
128 // Metriken pruefen und aendern
129 void ValidateMetrics(SvxSwFrameValidation
& rVal
,
130 const SwPosition
* pToCharCntntPos
,
131 BOOL bOnlyPercentRefValue
= FALSE
);
133 void DelAttr(USHORT nId
);
136 inline const SfxItemSet
&GetAttrSet() const { return aSet
; }
137 inline SfxItemSet
&GetAttrSet() { return aSet
; }
138 void SetAttrSet(const SfxItemSet
& rSet
);
140 inline const SwFmtVertOrient
&GetVertOrient() const;
141 inline const SwFmtHoriOrient
&GetHoriOrient() const;
142 inline const SvxShadowItem
&GetShadow() const;
143 inline const SvxBoxItem
&GetBox() const;
144 inline const SwFmtSurround
&GetSurround() const;
145 inline const SwFmtFrmSize
&GetFrmSize() const;
147 long CalcWidthBorder() { return CalcLeftSpace()+CalcRightSpace(); }
148 long CalcHeightBorder() { return CalcTopSpace()+CalcBottomSpace(); }
151 inline const Size
& SwFlyFrmAttrMgr::GetSize() const
153 return ((SwFmtFrmSize
&)aSet
.Get(RES_FRM_SIZE
)).GetSize();
156 inline const SwFmtVertOrient
&SwFlyFrmAttrMgr::GetVertOrient() const
158 return ((SwFmtVertOrient
&)aSet
.Get(RES_VERT_ORIENT
));
160 inline const SwFmtHoriOrient
&SwFlyFrmAttrMgr::GetHoriOrient() const
162 return ((SwFmtHoriOrient
&)aSet
.Get(RES_HORI_ORIENT
));
164 inline const SwFmtFrmSize
& SwFlyFrmAttrMgr::GetFrmSize() const
166 return ((SwFmtFrmSize
&)aSet
.Get(RES_FRM_SIZE
));
168 inline const SvxShadowItem
&SwFlyFrmAttrMgr::GetShadow() const
170 return ((SvxShadowItem
&)aSet
.Get(RES_SHADOW
));
172 inline const SvxBoxItem
&SwFlyFrmAttrMgr::GetBox() const
174 return ((SvxBoxItem
&)aSet
.Get(RES_BOX
));
176 inline const SwFmtSurround
&SwFlyFrmAttrMgr::GetSurround() const
178 return ((SwFmtSurround
&)aSet
.Get(RES_SURROUND
));
181 inline Point
SwFlyFrmAttrMgr::GetPos() const
183 return Point( GetHoriOrient().GetPos(), GetVertOrient().GetPos() );
186 inline RndStdIds
SwFlyFrmAttrMgr::GetAnchor() const
188 return ((SwFmtAnchor
&)aSet
.Get(RES_ANCHOR
)).GetAnchorId();
191 inline USHORT
SwFlyFrmAttrMgr::GetHeightPercent() const
193 return GetFrmSize().GetHeightPercent();