LibreOffice Module svx (master)  1
svdoattr.cxx
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 
20 #include <svx/svdoattr.hxx>
21 #include <svx/svdmodel.hxx>
22 #include <svl/hint.hxx>
23 #include <svl/itemset.hxx>
24 #include <svx/xdef.hxx>
25 #include <svx/xlineit0.hxx>
26 #include <svx/xfillit0.hxx>
27 #include <svx/xlnwtit.hxx>
29 
30 using namespace com::sun::star;
31 
32 std::unique_ptr<sdr::properties::BaseProperties> SdrAttrObj::CreateObjectSpecificProperties()
33 {
34  return std::make_unique<sdr::properties::AttributeProperties>(*this);
35 }
36 
38  : SdrObject(rSdrModel)
39 {
40 }
41 
42 SdrAttrObj::SdrAttrObj(SdrModel& rSdrModel, SdrAttrObj const& rSource)
43  : SdrObject(rSdrModel, rSource)
44 {
45 }
46 
48 
50 {
51  if (m_bSnapRectDirty)
52  {
53  const_cast<SdrAttrObj*>(this)->RecalcSnapRect();
54  const_cast<SdrAttrObj*>(this)->m_bSnapRectDirty = false;
55  }
56 
57  return maSnapRect;
58 }
59 
60 // syntactical sugar for ItemSet accesses
61 void SdrAttrObj::Notify(SfxBroadcaster& /*rBC*/, const SfxHint& rHint)
62 {
63  bool bDataChg(SfxHintId::DataChanged == rHint.GetId());
64 
65  if (bDataChg)
66  {
67  tools::Rectangle aBoundRect = GetLastBoundRect();
69  SetRectsDirty(true);
70 
71  // This may have led to object change
72  SetChanged();
75  }
76 }
77 
78 sal_Int32 SdrAttrObj::ImpGetLineWdt() const
79 {
80  sal_Int32 nRetval(0);
81 
82  if (drawing::LineStyle_NONE != GetObjectItem(XATTR_LINESTYLE).GetValue())
83  {
84  nRetval = GetObjectItem(XATTR_LINEWIDTH).GetValue();
85  }
86 
87  return nRetval;
88 }
89 
90 bool SdrAttrObj::HasFill() const
91 {
92  return m_bClosedObj
94  != drawing::FillStyle_NONE;
95 }
96 
97 bool SdrAttrObj::HasLine() const
98 {
99  return GetProperties().GetObjectItemSet().Get(XATTR_LINESTYLE).GetValue()
100  != drawing::LineStyle_NONE;
101 }
102 
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual const SfxItemSet & GetObjectItemSet() const =0
std::string GetValue
bool m_bClosedObj
Definition: svdobj.hxx:895
sal_Int32 ImpGetLineWdt() const
Detects the width of the line. No line ->0.
Definition: svdoattr.cxx:78
constexpr TypedWhichId< XFillStyleItem > XATTR_FILLSTYLE(XATTR_FILL_FIRST)
constexpr TypedWhichId< XLineWidthItem > XATTR_LINEWIDTH(XATTR_LINE_FIRST+2)
SdrAttrObj(SdrModel &rSdrModel)
Definition: svdoattr.cxx:37
virtual void SetBoundRectDirty()
Definition: svdobj.cxx:316
constexpr TypedWhichId< XLineStyleItem > XATTR_LINESTYLE(XATTR_LINE_FIRST)
virtual sdr::properties::BaseProperties & GetProperties() const
Definition: svdobj.cxx:210
virtual const tools::Rectangle & GetSnapRect() const override
Definition: svdoattr.cxx:49
SfxHintId GetId() const
virtual void RecalcSnapRect()
Snap is not done on the BoundRect but if possible on logic coordinates (i.e.
Definition: svdobj.cxx:1665
tools::Rectangle maSnapRect
Definition: svdoattr.hxx:41
const SfxPoolItem & GetObjectItem(const sal_uInt16 nWhich) const
Definition: svdobj.cxx:2011
void BroadcastObjectChange() const
Definition: svdobj.cxx:1011
virtual std::unique_ptr< sdr::properties::BaseProperties > CreateObjectSpecificProperties() override
Definition: svdoattr.cxx:32
Abstract DrawObject.
Definition: svdobj.hxx:258
virtual const tools::Rectangle & GetLastBoundRect() const
Definition: svdobj.cxx:974
bool HasFill() const
Definition: svdoattr.cxx:90
bool HasLine() const
Definition: svdoattr.cxx:97
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Detects when a stylesheet is changed.
Definition: svdoattr.cxx:61
virtual ~SdrAttrObj() override
Definition: svdoattr.cxx:47
virtual void SetRectsDirty(bool bNotMyself=false, bool bRecursive=true)
Definition: svdobj.cxx:512
bool m_bSnapRectDirty
Definition: svdobj.hxx:882
virtual void SetChanged()
Definition: svdobj.cxx:1035
void SendUserCall(SdrUserCallType eUserCall, const tools::Rectangle &rBoundRect) const
Definition: svdobj.cxx:2742