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 <frmatr.hxx>
24 #include <editeng/svxenum.hxx>
25 #include <tools/gen.hxx>
26 #include <fmtfsize.hxx>
27 #include <fmtsrnd.hxx>
28 #include <fmtornt.hxx>
29 #include <fmtanchr.hxx>
30 #include <swdllapi.h>
31 
32 class SwWrtShell;
34 struct SwPosition;
35 
36 class SwFormatCol;
37 
38 const SwTwips DFLT_WIDTH = MM50 * 4;
40 
41 enum class Frmmgr_Type
42 {
43  NONE = 0x00,
44  TEXT = 0x01,
45  GRF = 0x02,
46  OLE = 0x04,
47  ENVELP = 0x10
48 };
49 
51 {
55 
56  bool m_bAbsPos,
59  // #mongolianlayout#
61 
62  // internal calculation for borders
63  SAL_DLLPRIVATE SwTwips CalcTopSpace();
64  SAL_DLLPRIVATE SwTwips CalcBottomSpace();
65  SAL_DLLPRIVATE SwTwips CalcLeftSpace();
66  SAL_DLLPRIVATE SwTwips CalcRightSpace();
67 
68  SAL_DLLPRIVATE void UpdateFlyFrame_(); // post-treatment after insert or update
69 
70 public:
71  SwFlyFrameAttrMgr( bool bNew, SwWrtShell* pSh, Frmmgr_Type nType );
72 
73  //CopyCtor for dialogs to check the metrics
74  SwFlyFrameAttrMgr( bool bNew, SwWrtShell *pSh, const SfxItemSet &rSet );
75 
76  void SetAnchor(RndStdIds eId);
77  inline RndStdIds GetAnchor() const;
78 
79  void SetHorzOrientation(sal_Int16 eOrient);
80  void SetVertOrientation(sal_Int16 eOrient);
81 
82  // absolute position
83  void SetAbsPos(const Point& rLPoint);
84 
85  // anchor's relative position
86  void SetPos(const Point& rLPoint);
87  inline Point GetPos() const;
88 
89  // size
90  void SetSize(const Size& rLSize);
91  inline const Size& GetSize() const;
92 
93  void SetHeightSizeType(SwFrameSize eType);
94 
95  // rotation
96  void SetRotation(sal_uInt16 nOld, sal_uInt16 nNew, const Size& rUnrotatedSize);
97 
98  // space to content
99  void SetLRSpace( long nLeft,
100  long nRight );
101  void SetULSpace( long nTop,
102  long nBottom );
103 
104  void SetCol( const SwFormatCol &rCol);
105 
106  // change and query attributes
107  void UpdateAttrMgr();
108  void UpdateFlyFrame();
109 
110  // create new frame
111  void InsertFlyFrame();
112  void InsertFlyFrame(RndStdIds eAnchorType,
113  const Point &rPos,
114  const Size &rSize);
115 
116  // check and change metrics
117  void ValidateMetrics(SvxSwFrameValidation& rVal,
118  const SwPosition* pToCharContentPos,
119  bool bOnlyPercentRefValue = false);
120 
121  void DelAttr(sal_uInt16 nId);
122 
123  // reach out the set
124  const SfxItemSet &GetAttrSet() const { return m_aSet; }
125  SfxItemSet &GetAttrSet() { return m_aSet; }
126  void SetAttrSet(const SfxItemSet& rSet);
127 
128  inline const SwFormatVertOrient &GetVertOrient() const;
129  inline const SwFormatHoriOrient &GetHoriOrient() const;
130  inline const SvxShadowItem &GetShadow() const;
131  inline const SvxBoxItem &GetBox() const;
132  inline const SwFormatFrameSize &GetFrameSize() const;
133 
134  long CalcWidthBorder() { return CalcLeftSpace()+CalcRightSpace(); }
135  long CalcHeightBorder() { return CalcTopSpace()+CalcBottomSpace(); }
136 };
137 
138 inline const Size& SwFlyFrameAttrMgr::GetSize() const
139 {
140  return m_aSet.Get(RES_FRM_SIZE).GetSize();
141 }
142 
144 {
145  return m_aSet.Get(RES_VERT_ORIENT);
146 }
148 {
149  return m_aSet.Get(RES_HORI_ORIENT);
150 }
152 {
153  return m_aSet.Get(RES_FRM_SIZE);
154 }
156 {
157  return m_aSet.Get(RES_SHADOW);
158 }
160 {
161  return m_aSet.Get(RES_BOX);
162 }
164 {
165  return Point( GetHoriOrient().GetPos(), GetVertOrient().GetPos() );
166 }
168 {
169  return m_aSet.Get(RES_ANCHOR).GetAnchorId();
170 }
171 
172 #endif
173 
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const SwFormatFrameSize & GetFrameSize() const
Definition: frmmgr.hxx:151
#define RES_FRM_SIZE
Definition: hintids.hxx:194
Marks a position in the document model.
Definition: pam.hxx:35
#define RES_HORI_ORIENT
Definition: hintids.hxx:208
#define RES_SHADOW
Definition: hintids.hxx:212
bool m_bIsInVerticalL2R
Definition: frmmgr.hxx:60
long SwTwips
Definition: swtypes.hxx:49
SwWrtShell * m_pOwnSh
Definition: frmmgr.hxx:54
RndStdIds GetAnchor() const
Definition: frmmgr.hxx:167
Point GetPos() const
Definition: frmmgr.hxx:163
Used by the UI to modify the document model.
Definition: wrtsh.hxx:86
const SwTwips DFLT_HEIGHT
Definition: frmmgr.hxx:39
const SfxItemSet & GetAttrSet() const
Definition: frmmgr.hxx:124
#define RES_ANCHOR
Definition: hintids.hxx:209
SfxItemSet m_aSet
Definition: frmmgr.hxx:52
#define RES_VERT_ORIENT
Definition: hintids.hxx:207
SfxItemSet & GetAttrSet()
Definition: frmmgr.hxx:125
SwFrameSize
Definition: fmtfsize.hxx:35
Frmmgr_Type
Definition: frmmgr.hxx:41
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
long CalcWidthBorder()
Definition: frmmgr.hxx:134
#define MM50
Definition: swtypes.hxx:59
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
const SwFormatVertOrient & GetVertOrient() const
Definition: frmmgr.hxx:143
#define RES_BOX
Definition: hintids.hxx:211
bool m_bIsInVertical
Definition: frmmgr.hxx:58
RndStdIds
const SvxShadowItem & GetShadow() const
Definition: frmmgr.hxx:155
const Size & GetSize() const
Definition: frmmgr.hxx:138
long CalcHeightBorder()
Definition: frmmgr.hxx:135
const SwTwips DFLT_WIDTH
Definition: frmmgr.hxx:38
const SwFormatHoriOrient & GetHoriOrient() const
Definition: frmmgr.hxx:147
const SvxBoxItem & GetBox() const
Definition: frmmgr.hxx:159