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