LibreOffice Module svx (master)  1
properties.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 <libxml/xmlwriter.h>
21 
24 #include <svl/itemset.hxx>
25 #include <svx/svdogrp.hxx>
26 #include <svx/svditer.hxx>
27 #include <svx/xdef.hxx>
28 #include <svx/xfillit0.hxx>
29 #include <svx/svdmodel.hxx>
30 
31 using namespace com::sun::star;
32 
33 namespace sdr::properties
34 {
35  BaseProperties::BaseProperties(SdrObject& rObj)
36  : mrObject(rObj)
37  {
38  }
39 
41  {
42  }
43 
45  {
46  return mrObject;
47  }
48 
50  {
51  return mrObject;
52  }
53 
55  {
56  // default implementation falls back to GetObjectItemSet()
57  return GetObjectItemSet();
58  }
59 
60  void BaseProperties::SetMergedItemSet(const SfxItemSet& rSet, bool bClearAllItems)
61  {
62  // clear items if requested
63  if(bClearAllItems)
64  {
66  }
67 
68  // default implementation falls back to SetObjectItemSet()
69  SetObjectItemSet(rSet);
70  }
71 
73  {
74  // default implementation falls back to SetObjectItem()
75  SetObjectItem(rItem);
76  }
77 
78  void BaseProperties::ClearMergedItem(const sal_uInt16 nWhich)
79  {
80  // default implementation falls back to ClearObjectItem()
81  ClearObjectItem(nWhich);
82  }
83 
85  {
86  // force all attributes which come from styles to hard attributes
87  // to be able to live without the style. Default implementation does nothing.
88  // Override where an ItemSet is implemented.
89  }
90 
91  void BaseProperties::SetMergedItemSetAndBroadcast(const SfxItemSet& rSet, bool bClearAllItems)
92  {
94 
95  if(bClearAllItems)
96  {
98  }
99 
100  SetMergedItemSet(rSet);
102  }
103 
104  const SfxPoolItem& BaseProperties::GetItem(const sal_uInt16 nWhich) const
105  {
106  return GetObjectItemSet().Get(nWhich);
107  }
108 
110  {
111  const sal_uInt32 nCount(rChange.GetRectangleCount());
112 
113  // invalidate all new rectangles
114  if(auto pObjGroup = dynamic_cast<SdrObjGroup*>( &GetSdrObject() ))
115  {
116  SdrObjListIter aIter(pObjGroup, SdrIterMode::DeepNoGroups);
117 
118  while(aIter.IsMore())
119  {
120  SdrObject* pObj = aIter.Next();
121  pObj->BroadcastObjectChange();
122  }
123  }
124  else
125  {
127  }
128 
129  // also send the user calls
130  for(sal_uInt32 a(0); a < nCount; a++)
131  {
133  }
134  }
135 
136  sal_uInt32 BaseProperties::getVersion() const
137  {
138  return 0;
139  }
140 
142  {
143  (void)xmlTextWriterStartElement(pWriter, BAD_CAST("BaseProperties"));
144  (void)xmlTextWriterEndElement(pWriter);
145  }
146 
148  {
149  const bool bFillBitmap = rItemSet.GetItemState(XATTR_FILLBITMAP, false) == SfxItemState::SET;
150  const bool bFillGradient = rItemSet.GetItemState(XATTR_FILLGRADIENT, false) == SfxItemState::SET;
151  const bool bFillHatch = rItemSet.GetItemState(XATTR_FILLHATCH, false) == SfxItemState::SET;
152  if( !(bFillBitmap || bFillGradient || bFillHatch) )
153  return;
154 
155  const XFillStyleItem* pFillStyleItem = rItemSet.GetItem(XATTR_FILLSTYLE);
156  if( !pFillStyleItem )
157  return;
158 
159  if( bFillBitmap && (pFillStyleItem->GetValue() != drawing::FillStyle_BITMAP) )
160  {
161  rItemSet.ClearItem( XATTR_FILLBITMAP );
162  }
163 
164  if( bFillGradient && (pFillStyleItem->GetValue() != drawing::FillStyle_GRADIENT) )
165  {
166  rItemSet.ClearItem( XATTR_FILLGRADIENT );
167  }
168 
169  if( bFillHatch && (pFillStyleItem->GetValue() != drawing::FillStyle_HATCH) )
170  {
171  rItemSet.ClearItem( XATTR_FILLHATCH );
172  }
173  }
174 
175 } // end of namespace
176 
177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual const SfxItemSet & GetObjectItemSet() const =0
const SfxPoolItem & GetItem(const sal_uInt16 nWhich) const
Definition: properties.cxx:104
const tools::Rectangle & GetRectangle(sal_uInt32 nIndex) const
struct _xmlTextWriter * xmlTextWriterPtr
constexpr TypedWhichId< XFillStyleItem > XATTR_FILLSTYLE(XATTR_FILL_FIRST)
constexpr TypedWhichId< XFillHatchItem > XATTR_FILLHATCH(XATTR_FILL_FIRST+3)
virtual const SfxItemSet & GetMergedItemSet() const
Definition: properties.cxx:54
virtual void ForceStyleToHardAttributes()
Definition: properties.cxx:84
virtual void SetMergedItemSet(const SfxItemSet &rSet, bool bClearAllItems=false)
Definition: properties.cxx:60
virtual void ClearObjectItem(const sal_uInt16 nWhich=0)=0
bool IsMore() const
Definition: svditer.hxx:62
int nCount
void BroadcastItemChange(const ItemChangeBroadcaster &rChange)
Definition: properties.cxx:109
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
virtual void SetObjectItem(const SfxPoolItem &rItem)=0
constexpr TypedWhichId< XFillGradientItem > XATTR_FILLGRADIENT(XATTR_FILL_FIRST+2)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
void SetMergedItemSetAndBroadcast(const SfxItemSet &rSet, bool bClearAllItems=false)
Definition: properties.cxx:91
void CleanupFillProperties(SfxItemSet &rItemSet)
Definition: properties.cxx:147
uno_Any a
constexpr TypedWhichId< XFillBitmapItem > XATTR_FILLBITMAP(XATTR_FILL_FIRST+4)
void BroadcastObjectChange() const
Definition: svdobj.cxx:1010
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: properties.cxx:141
Abstract DrawObject.
Definition: svdobj.hxx:260
SdrObject * Next()
Definition: svditer.hxx:63
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
virtual void SetMergedItem(const SfxPoolItem &rItem)
Definition: properties.cxx:72
const SdrObject & GetSdrObject() const
Definition: properties.cxx:44
virtual sal_uInt32 getVersion() const
Definition: properties.cxx:136
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
virtual void ClearMergedItem(const sal_uInt16 nWhich)
Definition: properties.cxx:78
void SendUserCall(SdrUserCallType eUserCall, const tools::Rectangle &rBoundRect) const
Definition: svdobj.cxx:2743
virtual void SetObjectItemSet(const SfxItemSet &rSet)=0
EnumT GetValue() const
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo