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