LibreOffice Module sw (master)  1
frmmgr.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_FRMMGR_HXX
20 #define INCLUDED_SW_SOURCE_UIBASE_INC_FRMMGR_HXX
21 
22 #include <swtypes.hxx>
23 #include <editeng/boxitem.hxx>
24 #include <editeng/shaditem.hxx>
25 #include <tools/gen.hxx>
26 #include <fmtfsize.hxx>
27 #include <fmtornt.hxx>
28 #include <fmtanchr.hxx>
29 #include <swdllapi.h>
30 
31 class SwWrtShell;
33 struct SwPosition;
34 
35 class SwFormatCol;
36 
37 const SwTwips DFLT_WIDTH = MM50 * 4;
39 
40 enum class Frmmgr_Type
41 {
42  NONE = 0x00,
43  TEXT = 0x01,
44  GRF = 0x02,
45  OLE = 0x04,
46  ENVELP = 0x10
47 };
48 
50 {
54 
55  bool m_bAbsPos,
58  // #mongolianlayout#
60 
61  // internal calculation for borders
62  SAL_DLLPRIVATE SwTwips CalcTopSpace();
63  SAL_DLLPRIVATE SwTwips CalcBottomSpace();
64  SAL_DLLPRIVATE SwTwips CalcLeftSpace();
65  SAL_DLLPRIVATE SwTwips CalcRightSpace();
66 
67  SAL_DLLPRIVATE void UpdateFlyFrame_(); // post-treatment after insert or update
68 
69 public:
70  SwFlyFrameAttrMgr( bool bNew, SwWrtShell* pSh, Frmmgr_Type nType );
71 
72  //CopyCtor for dialogs to check the metrics
73  SwFlyFrameAttrMgr( bool bNew, SwWrtShell *pSh, const SfxItemSet &rSet );
74 
75  void SetAnchor(RndStdIds eId);
76  inline RndStdIds GetAnchor() const;
77 
78  void SetHorzOrientation(sal_Int16 eOrient);
79  void SetVertOrientation(sal_Int16 eOrient);
80 
81  // absolute position
82  void SetAbsPos(const Point& rLPoint);
83 
84  // anchor's relative position
85  void SetPos(const Point& rLPoint);
86  inline Point GetPos() const;
87 
88  // size
89  void SetSize(const Size& rLSize);
90  inline const Size& GetSize() const;
91 
92  void SetHeightSizeType(SwFrameSize eType);
93 
94  // rotation
95  void SetRotation(sal_uInt16 nOld, sal_uInt16 nNew, const Size& rUnrotatedSize);
96 
97  // space to content
98  void SetLRSpace( long nLeft,
99  long nRight );
100  void SetULSpace( long nTop,
101  long nBottom );
102 
103  void SetCol( const SwFormatCol &rCol);
104 
105  // change and query attributes
106  void UpdateAttrMgr();
107  void UpdateFlyFrame();
108 
109  // create new frame
110  void InsertFlyFrame();
111  void InsertFlyFrame(RndStdIds eAnchorType,
112  const Point &rPos,
113  const Size &rSize);
114 
115  // check and change metrics
116  void ValidateMetrics(SvxSwFrameValidation& rVal,
117  const SwPosition* pToCharContentPos,
118  bool bOnlyPercentRefValue = false);
119 
120  void DelAttr(sal_uInt16 nId);
121 
122  // reach out the set
123  const SfxItemSet &GetAttrSet() const { return m_aSet; }
124  SfxItemSet &GetAttrSet() { return m_aSet; }
125  void SetAttrSet(const SfxItemSet& rSet);
126 
127  inline const SwFormatVertOrient &GetVertOrient() const;
128  inline const SwFormatHoriOrient &GetHoriOrient() const;
129  inline const SvxShadowItem &GetShadow() const;
130  inline const SvxBoxItem &GetBox() const;
131  inline const SwFormatFrameSize &GetFrameSize() const;
132 
133  long CalcWidthBorder() { return CalcLeftSpace()+CalcRightSpace(); }
134  long CalcHeightBorder() { return CalcTopSpace()+CalcBottomSpace(); }
135 };
136 
137 inline const Size& SwFlyFrameAttrMgr::GetSize() const
138 {
139  return m_aSet.Get(RES_FRM_SIZE).GetSize();
140 }
141 
143 {
144  return m_aSet.Get(RES_VERT_ORIENT);
145 }
147 {
148  return m_aSet.Get(RES_HORI_ORIENT);
149 }
151 {
152  return m_aSet.Get(RES_FRM_SIZE);
153 }
155 {
156  return m_aSet.Get(RES_SHADOW);
157 }
159 {
160  return m_aSet.Get(RES_BOX);
161 }
163 {
164  return Point( GetHoriOrient().GetPos(), GetVertOrient().GetPos() );
165 }
167 {
168  return m_aSet.Get(RES_ANCHOR).GetAnchorId();
169 }
170 
171 #endif
172 
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const SwFormatFrameSize & GetFrameSize() const
Definition: frmmgr.hxx:150
#define RES_FRM_SIZE
Definition: hintids.hxx:196
Marks a position in the document model.
Definition: pam.hxx:35
#define RES_HORI_ORIENT
Definition: hintids.hxx:210
#define RES_SHADOW
Definition: hintids.hxx:214
bool m_bIsInVerticalL2R
Definition: frmmgr.hxx:59
long SwTwips
Definition: swtypes.hxx:49
SwWrtShell * m_pOwnSh
Definition: frmmgr.hxx:53
RndStdIds GetAnchor() const
Definition: frmmgr.hxx:166
Point GetPos() const
Definition: frmmgr.hxx:162
Used by the UI to modify the document model.
Definition: wrtsh.hxx:90
const SwTwips DFLT_HEIGHT
Definition: frmmgr.hxx:38
const SfxItemSet & GetAttrSet() const
Definition: frmmgr.hxx:123
#define RES_ANCHOR
Definition: hintids.hxx:211
SfxItemSet m_aSet
Definition: frmmgr.hxx:51
#define RES_VERT_ORIENT
Definition: hintids.hxx:209
SfxItemSet & GetAttrSet()
Definition: frmmgr.hxx:124
SwFrameSize
Definition: fmtfsize.hxx:35
Frmmgr_Type
Definition: frmmgr.hxx:40
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
long CalcWidthBorder()
Definition: frmmgr.hxx:133
#define MM50
Definition: swtypes.hxx:59
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
const SwFormatVertOrient & GetVertOrient() const
Definition: frmmgr.hxx:142
#define RES_BOX
Definition: hintids.hxx:213
bool m_bIsInVertical
Definition: frmmgr.hxx:57
RndStdIds
const SvxShadowItem & GetShadow() const
Definition: frmmgr.hxx:154
const Size & GetSize() const
Definition: frmmgr.hxx:137
long CalcHeightBorder()
Definition: frmmgr.hxx:134
const SwTwips DFLT_WIDTH
Definition: frmmgr.hxx:37
const SwFormatHoriOrient & GetHoriOrient() const
Definition: frmmgr.hxx:146
const SvxBoxItem & GetBox() const
Definition: frmmgr.hxx:158