tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / svx / source / sdr / properties / properties.cxx
blob612813bb1aac2fa21c1efcb4b5427689f34f0374
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <libxml/xmlwriter.h>
22 #include <svx/sdr/properties/properties.hxx>
23 #include <sdr/properties/itemsettools.hxx>
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>
30 using namespace com::sun::star;
32 namespace sdr::properties
34 BaseProperties::BaseProperties(SdrObject& rObj)
35 : mrObject(rObj)
39 BaseProperties::~BaseProperties()
43 const SdrObject& BaseProperties::GetSdrObject() const
45 return mrObject;
48 SdrObject& BaseProperties::GetSdrObject()
50 return mrObject;
53 const SfxItemSet& BaseProperties::GetMergedItemSet() const
55 // default implementation falls back to GetObjectItemSet()
56 return GetObjectItemSet();
59 void BaseProperties::SetMergedItemSet(const SfxItemSet& rSet, bool bClearAllItems, bool bAdjustTextFrameWidthAndHeight)
61 // clear items if requested
62 if(bClearAllItems)
64 ClearObjectItem();
67 // default implementation falls back to SetObjectItemSet()
68 SetObjectItemSet(rSet, bAdjustTextFrameWidthAndHeight);
71 void BaseProperties::SetMergedItem(const SfxPoolItem& rItem)
73 // default implementation falls back to SetObjectItem()
74 SetObjectItem(rItem);
77 void BaseProperties::ClearMergedItem(const sal_uInt16 nWhich)
79 // default implementation falls back to ClearObjectItem()
80 ClearObjectItem(nWhich);
83 void BaseProperties::ForceStyleToHardAttributes()
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.
90 void BaseProperties::SetMergedItemSetAndBroadcast(const SfxItemSet& rSet, bool bClearAllItems)
92 ItemChangeBroadcaster aC(GetSdrObject());
94 if(bClearAllItems)
96 ClearObjectItem();
99 SetMergedItemSet(rSet);
100 BroadcastItemChange(aC);
103 const SfxPoolItem& BaseProperties::GetItem(const sal_uInt16 nWhich) const
105 return GetObjectItemSet().Get(nWhich);
108 void BaseProperties::BroadcastItemChange(const ItemChangeBroadcaster& rChange)
110 const sal_uInt32 nCount(rChange.GetRectangleCount());
112 // invalidate all new rectangles
113 SdrObject* pObj = &GetSdrObject();
114 if (pObj->GetObjIdentifier() == SdrObjKind::Group)
116 SdrObjGroup* pObjGroup = static_cast<SdrObjGroup*>(pObj);
117 SdrObjListIter aIter(pObjGroup, SdrIterMode::DeepNoGroups);
119 while(aIter.IsMore())
121 SdrObject* pChildObj = aIter.Next();
122 pChildObj->BroadcastObjectChange();
125 else
127 pObj->BroadcastObjectChange();
130 // also send the user calls
131 for(sal_uInt32 a(0); a < nCount; a++)
133 pObj->SendUserCall(SdrUserCallType::ChangeAttr, rChange.GetRectangle(a));
137 sal_uInt32 BaseProperties::getVersion() const
139 return 0;
142 void BaseProperties::dumpAsXml(xmlTextWriterPtr pWriter) const
144 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("BaseProperties"));
145 (void)xmlTextWriterEndElement(pWriter);
148 void CleanupFillProperties( SfxItemSet& rItemSet )
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;
156 const XFillStyleItem* pFillStyleItem = rItemSet.GetItem(XATTR_FILLSTYLE);
157 if( !pFillStyleItem )
158 return;
160 if( bFillBitmap && (pFillStyleItem->GetValue() != drawing::FillStyle_BITMAP) )
162 rItemSet.ClearItem( XATTR_FILLBITMAP );
165 if( bFillGradient && (pFillStyleItem->GetValue() != drawing::FillStyle_GRADIENT) )
167 rItemSet.ClearItem( XATTR_FILLGRADIENT );
170 if( bFillHatch && (pFillStyleItem->GetValue() != drawing::FillStyle_HATCH) )
172 rItemSet.ClearItem( XATTR_FILLHATCH );
176 } // end of namespace
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */