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