diff options
Diffstat (limited to 'svx/source/sdr/properties')
22 files changed, 3856 insertions, 0 deletions
diff --git a/svx/source/sdr/properties/attributeproperties.cxx b/svx/source/sdr/properties/attributeproperties.cxx new file mode 100644 index 000000000..dbed60b8a --- /dev/null +++ b/svx/source/sdr/properties/attributeproperties.cxx @@ -0,0 +1,526 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <sal/config.h> + +#include <sdr/properties/attributeproperties.hxx> +#include <tools/debug.hxx> +#include <svl/itemset.hxx> +#include <svl/style.hxx> +#include <svl/whiter.hxx> +#include <svl/poolitem.hxx> +#include <svx/svdobj.hxx> +#include <svx/svddef.hxx> +#include <svx/xbtmpit.hxx> +#include <svx/xlndsit.hxx> +#include <svx/xlnstit.hxx> +#include <svx/xlnedit.hxx> +#include <svx/xflgrit.hxx> +#include <svx/xflftrit.hxx> +#include <svx/xflhtit.hxx> +#include <svx/svdmodel.hxx> +#include <svx/svdpage.hxx> + +namespace sdr::properties +{ + void AttributeProperties::ImpSetParentAtSfxItemSet(bool bDontRemoveHardAttr) + { + if(HasSfxItemSet() && mpStyleSheet) + { + // Delete hard attributes where items are set in the style sheet + if(!bDontRemoveHardAttr) + { + const SfxItemSet& rStyle = mpStyleSheet->GetItemSet(); + SfxWhichIter aIter(rStyle); + sal_uInt16 nWhich = aIter.FirstWhich(); + + while(nWhich) + { + if(SfxItemState::SET == rStyle.GetItemState(nWhich)) + { + mpItemSet->ClearItem(nWhich); + } + + nWhich = aIter.NextWhich(); + } + } + + // set new stylesheet as parent + mpItemSet->SetParent(&mpStyleSheet->GetItemSet()); + } + else + { + OSL_ENSURE(false, "ImpSetParentAtSfxItemSet called without SfxItemSet/SfxStyleSheet (!)"); + } + } + + void AttributeProperties::ImpAddStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr) + { + // test if old StyleSheet is cleared, else it would be lost + // after this method -> memory leak (!) + DBG_ASSERT(!mpStyleSheet, "Old style sheet not deleted before setting new one (!)"); + + if(pNewStyleSheet) + { + // local remember + mpStyleSheet = pNewStyleSheet; + + if(HasSfxItemSet()) + { + // register as listener + StartListening(*pNewStyleSheet->GetPool()); + StartListening(*pNewStyleSheet); + + // only apply the following when we have an SfxItemSet already, else + if(GetStyleSheet()) + { + ImpSetParentAtSfxItemSet(bDontRemoveHardAttr); + } + } + } + } + + void AttributeProperties::ImpRemoveStyleSheet() + { + // Check type since it is destroyed when the type is deleted + if(GetStyleSheet() && dynamic_cast<const SfxStyleSheet *>(mpStyleSheet) != nullptr) + { + EndListening(*mpStyleSheet); + if (auto const pool = mpStyleSheet->GetPool()) { // TTTT + EndListening(*pool); + } + + // reset parent of ItemSet + if(HasSfxItemSet()) + { + mpItemSet->SetParent(nullptr); + } + + SdrObject& rObj = GetSdrObject(); + rObj.SetBoundRectDirty(); + rObj.SetRectsDirty(true); + } + + mpStyleSheet = nullptr; + } + + // create a new itemset + std::unique_ptr<SfxItemSet> AttributeProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool) + { + return std::make_unique<SfxItemSet>(rPool, + + // ranges from SdrAttrObj + svl::Items<SDRATTR_START, SDRATTR_SHADOW_LAST, + SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST, + SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION>{}); + } + + AttributeProperties::AttributeProperties(SdrObject& rObj) + : DefaultProperties(rObj), + mpStyleSheet(nullptr) + { + // Do nothing else, esp. do *not* try to get and set + // a default SfxStyle sheet. Nothing is allowed to be done + // that may lead to calls to virtual functions like + // CreateObjectSpecificItemSet - these would go *wrong*. + // Thus the rest is lazy-init from here. + } + + AttributeProperties::AttributeProperties(const AttributeProperties& rProps, SdrObject& rObj) + : DefaultProperties(rProps, rObj), + mpStyleSheet(nullptr) + { + SfxStyleSheet* pTargetStyleSheet(rProps.GetStyleSheet()); + + if(pTargetStyleSheet) + { + const bool bModelChange(&rObj.getSdrModelFromSdrObject() != &rProps.GetSdrObject().getSdrModelFromSdrObject()); + + if(bModelChange) + { + // tdf#117506 + // The error shows that it is definitely necessary to solve this problem. + // Interestingly I already had a note here for 'work needed'. + // Checked in libreoffice-6-0 what happened there. In principle, the whole + // ::Clone of SdrPage and SdrObject happened in the same SdrModel, only + // afterwards a ::SetModel was used at the cloned SdrPage which went through + // all layers. The StyleSheet-problem was solved in + // AttributeProperties::MoveToItemPool at the end. There, a StyleSheet with the + // same name was searched for in the target-SdrModel. + // Start by resetting the current TargetStyleSheet so that nothing goes wrong + // when we do not find a fitting TargetStyleSheet. + // Note: The test for SdrModelChange above was wrong (compared the already set + // new SdrObject), so this never triggered and pTargetStyleSheet was never set to + // nullptr before. This means that a StyleSheet from another SdrModel was used + // what of course is very dangerous. Interestingly did not crash since when that + // other SdrModel was destroyed the ::Notify mechanism still worked reliably + // and de-connected this Properties successfully from the alien-StyleSheet. + pTargetStyleSheet = nullptr; + + // Check if we have a TargetStyleSheetPool at the target-SdrModel. This *should* + // be the case already (SdrModel::Merge and SdDrawDocument::InsertBookmarkAsPage + // have already cloned the StyleSheets to the target-SdrModel when used in Draw/impress). + // If none is found, ImpGetDefaultStyleSheet will be used to set a 'default' + // StyleSheet as StyleSheet implicitly later (that's what happened in the task, + // thus the FillStyle changed to the 'default' Blue). + // Note: It *may* be necessary to do more for StyleSheets, e.g. clone/copy the + // StyleSheet Hierarchy from the source SdrModel and/or add the Items from there + // as hard attributes. If needed, have a look at the older AttributeProperties::SetModel + // implementation from e.g. libreoffice-6-0. + SfxStyleSheetBasePool* pTargetStyleSheetPool(rObj.getSdrModelFromSdrObject().GetStyleSheetPool()); + + if(nullptr != pTargetStyleSheetPool) + { + // If we have a TargetStyleSheetPool, search for the used StyleSheet + // in the target SdrModel using the Name from the original StyleSheet + // in the source-SdrModel. + pTargetStyleSheet = dynamic_cast< SfxStyleSheet* >( + pTargetStyleSheetPool->Find( + rProps.GetStyleSheet()->GetName(), + SfxStyleFamily::All)); + } + } + } + + if(pTargetStyleSheet) + { + if(HasSfxItemSet()) + { + // The SfxItemSet has been cloned and exists, + // we can directly set the SfxStyleSheet at it + ImpAddStyleSheet(pTargetStyleSheet, true); + } + else + { + // No SfxItemSet exists yet (there is none in + // the source, so none was cloned). Remember the + // SfxStyleSheet to set it when the SfxItemSet + // got constructed on-demand + mpStyleSheet = pTargetStyleSheet; + } + } + } + + AttributeProperties::~AttributeProperties() + { + ImpRemoveStyleSheet(); + } + + std::unique_ptr<BaseProperties> AttributeProperties::Clone(SdrObject& rObj) const + { + return std::unique_ptr<BaseProperties>(new AttributeProperties(*this, rObj)); + } + + const SfxItemSet& AttributeProperties::GetObjectItemSet() const + { + // remember if we had a SfxItemSet already + const bool bHadSfxItemSet(HasSfxItemSet()); + + // call parent - this will guarantee SfxItemSet existence + DefaultProperties::GetObjectItemSet(); + + if(!bHadSfxItemSet) + { + // need to take care for SfxStyleSheet for newly + // created SfxItemSet + if(nullptr == mpStyleSheet) + { + // Set missing defaults without removal of hard attributes. + // This is more complicated historically than I first thought: + // Originally for GetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj + // SetStyleSheet(..., false) was used, while for GetDefaultStyleSheet + // SetStyleSheet(..., true) was used. Thus, for SdrGrafObj and SdrOle2Obj + // bDontRemoveHardAttr == false -> *do* delete hard attributes was used. + // This was probably not done by purpose, adding the method + // GetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj additionally to + // GetDefaultStyleSheet was an enhancement to allow for SdrGrafObj/SdrOle2Obj + // with full AttributeSet (adding e.g. FillAttributes). To stay as compatible + // as possible these SdrObjects got a new default-StyleSheet. + // There is no reason to delete the HardAttributes and it anyways has only + // AFAIK effects on a single Item - the SdrTextHorzAdjustItem. To get things + // unified I will stay with not deleting the HardAttributes and adapt the + // UnitTests in CppunitTest_sd_import_tests accordingly. + const_cast< AttributeProperties* >(this)->applyDefaultStyleSheetFromSdrModel(); + } + else + { + // Late-Init of setting parent to SfxStyleSheet after + // it's creation. Can only happen from copy-constructor + // (where creation of SfxItemSet is avoided due to the + // problem with constructors and virtual functions in C++), + // thus DontRemoveHardAttr is not needed. + const_cast< AttributeProperties* >(this)->SetStyleSheet( + mpStyleSheet, + true); + } + } + + return *mpItemSet; + } + + void AttributeProperties::ItemSetChanged(const SfxItemSet& /*rSet*/) + { + // own modifications + SdrObject& rObj = GetSdrObject(); + + rObj.SetBoundRectDirty(); + rObj.SetRectsDirty(true); + rObj.SetChanged(); + } + + void AttributeProperties::ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem) + { + if(pNewItem) + { + std::unique_ptr<SfxPoolItem> pResultItem; + SdrModel& rModel(GetSdrObject().getSdrModelFromSdrObject()); + + switch( nWhich ) + { + case XATTR_FILLBITMAP: + { + // TTTT checkForUniqueItem should use SdrModel& + pResultItem = static_cast<const XFillBitmapItem*>(pNewItem)->checkForUniqueItem( &rModel ); + break; + } + case XATTR_LINEDASH: + { + pResultItem = static_cast<const XLineDashItem*>(pNewItem)->checkForUniqueItem( &rModel ); + break; + } + case XATTR_LINESTART: + { + pResultItem = static_cast<const XLineStartItem*>(pNewItem)->checkForUniqueItem( &rModel ); + break; + } + case XATTR_LINEEND: + { + pResultItem = static_cast<const XLineEndItem*>(pNewItem)->checkForUniqueItem( &rModel ); + break; + } + case XATTR_FILLGRADIENT: + { + pResultItem = static_cast<const XFillGradientItem*>(pNewItem)->checkForUniqueItem( &rModel ); + break; + } + case XATTR_FILLFLOATTRANSPARENCE: + { + // #85953# allow all kinds of XFillFloatTransparenceItem to be set + pResultItem = static_cast<const XFillFloatTransparenceItem*>(pNewItem)->checkForUniqueItem( &rModel ); + break; + } + case XATTR_FILLHATCH: + { + pResultItem = static_cast<const XFillHatchItem*>(pNewItem)->checkForUniqueItem( &rModel ); + break; + } + } + + // guarantee SfxItemSet existence + GetObjectItemSet(); + + if(pResultItem) + { + // force ItemSet + mpItemSet->Put(*pResultItem); + + // delete item if it was a generated one + pResultItem.reset(); + } + else + { + mpItemSet->Put(*pNewItem); + } + } + else + { + // clear item if ItemSet exists + if(HasSfxItemSet()) + { + mpItemSet->ClearItem(nWhich); + } + } + } + + void AttributeProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr) + { + // guarantee SfxItemSet existence + GetObjectItemSet(); + + ImpRemoveStyleSheet(); + ImpAddStyleSheet(pNewStyleSheet, bDontRemoveHardAttr); + + SdrObject& rObj = GetSdrObject(); + rObj.SetBoundRectDirty(); + rObj.SetRectsDirty(true); + } + + SfxStyleSheet* AttributeProperties::GetStyleSheet() const + { + return mpStyleSheet; + } + + void AttributeProperties::ForceStyleToHardAttributes() + { + if(!GetStyleSheet() || dynamic_cast<const SfxStyleSheet *>(mpStyleSheet) == nullptr) + return; + + // guarantee SfxItemSet existence + GetObjectItemSet(); + + // prepare copied, new itemset, but WITHOUT parent + SfxItemSet* pDestItemSet = new SfxItemSet(*mpItemSet); + pDestItemSet->SetParent(nullptr); + + // prepare forgetting the current stylesheet like in RemoveStyleSheet() + EndListening(*mpStyleSheet); + EndListening(*mpStyleSheet->GetPool()); + + // prepare the iter; use the mpObjectItemSet which may have less + // WhichIDs than the style. + SfxWhichIter aIter(*pDestItemSet); + sal_uInt16 nWhich(aIter.FirstWhich()); + const SfxPoolItem *pItem = nullptr; + + // now set all hard attributes of the current at the new itemset + while(nWhich) + { + // #i61284# use mpItemSet with parents, makes things easier and reduces to + // one loop + if(SfxItemState::SET == mpItemSet->GetItemState(nWhich, true, &pItem)) + { + pDestItemSet->Put(*pItem); + } + + nWhich = aIter.NextWhich(); + } + + // replace itemsets + mpItemSet.reset(pDestItemSet); + + // set necessary changes like in RemoveStyleSheet() + GetSdrObject().SetBoundRectDirty(); + GetSdrObject().SetRectsDirty(true); + + mpStyleSheet = nullptr; + } + + void AttributeProperties::Notify(SfxBroadcaster& rBC, const SfxHint& rHint) + { + bool bHintUsed(false); + + const SfxStyleSheetHint* pStyleHint = dynamic_cast<const SfxStyleSheetHint*>(&rHint); + + if(pStyleHint && pStyleHint->GetStyleSheet() == GetStyleSheet()) + { + SdrObject& rObj = GetSdrObject(); + //SdrPage* pPage = rObj.GetPage(); + + switch(pStyleHint->GetId()) + { + case SfxHintId::StyleSheetCreated : + { + // cannot happen, nothing to do + break; + } + case SfxHintId::StyleSheetModified : + case SfxHintId::StyleSheetChanged : + { + // notify change + break; + } + case SfxHintId::StyleSheetErased : + case SfxHintId::StyleSheetInDestruction : + { + // Style needs to be exchanged + SfxStyleSheet* pNewStSh = nullptr; + SdrModel& rModel(rObj.getSdrModelFromSdrObject()); + + // Do nothing if object is in destruction, else a StyleSheet may be found from + // a StyleSheetPool which is just being deleted itself. and thus it would be fatal + // to register as listener to that new StyleSheet. + if(!rObj.IsInDestruction()) + { + if(dynamic_cast<const SfxStyleSheet *>(GetStyleSheet()) != nullptr) + { + pNewStSh = static_cast<SfxStyleSheet*>(rModel.GetStyleSheetPool()->Find( + GetStyleSheet()->GetParent(), GetStyleSheet()->GetFamily())); + } + + if(!pNewStSh) + { + pNewStSh = rModel.GetDefaultStyleSheet(); + } + } + + // remove used style, it's erased or in destruction + ImpRemoveStyleSheet(); + + if(pNewStSh) + { + ImpAddStyleSheet(pNewStSh, true); + } + + break; + } + default: break; + } + + // Get old BoundRect. Do this after the style change is handled + // in the ItemSet parts because GetBoundRect() may calculate a new + tools::Rectangle aBoundRect = rObj.GetLastBoundRect(); + + rObj.SetRectsDirty(true); + + // tell the object about the change + rObj.SetChanged(); + rObj.BroadcastObjectChange(); + + //if(pPage && pPage->IsInserted()) + //{ + // rObj.BroadcastObjectChange(); + //} + + rObj.SendUserCall(SdrUserCallType::ChangeAttr, aBoundRect); + + bHintUsed = true; + } + + if(!bHintUsed) + { + // forward to SdrObject ATM. Not sure if this will be necessary + // in the future. + GetSdrObject().Notify(rBC, rHint); + } + } + + bool AttributeProperties::isUsedByModel() const + { + const SdrObject& rObj(GetSdrObject()); + if (rObj.IsInserted()) + { + const SdrPage* const pPage(rObj.getSdrPageFromSdrObject()); + if (pPage && pPage->IsInserted()) + return true; + } + return false; + } +} // end of namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sdr/properties/captionproperties.cxx b/svx/source/sdr/properties/captionproperties.cxx new file mode 100644 index 000000000..0afd70af5 --- /dev/null +++ b/svx/source/sdr/properties/captionproperties.cxx @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <sal/config.h> + +#include <sdr/properties/captionproperties.hxx> +#include <svl/itemset.hxx> +#include <svl/style.hxx> +#include <svx/svddef.hxx> +#include <editeng/eeitem.hxx> +#include <svx/svdocapt.hxx> + + +namespace sdr::properties +{ + // create a new itemset + std::unique_ptr<SfxItemSet> CaptionProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool) + { + return std::make_unique<SfxItemSet>( + rPool, + svl::Items< + // Ranges from SdrAttrObj, SdrCaptionObj: + SDRATTR_START, SDRATTR_MISC_LAST, + SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION, + // Range from SdrTextObj: + EE_ITEMS_START, EE_ITEMS_END>{}); + } + + CaptionProperties::CaptionProperties(SdrObject& rObj) + : RectangleProperties(rObj) + { + } + + CaptionProperties::CaptionProperties(const CaptionProperties& rProps, SdrObject& rObj) + : RectangleProperties(rProps, rObj) + { + } + + CaptionProperties::~CaptionProperties() + { + } + + std::unique_ptr<BaseProperties> CaptionProperties::Clone(SdrObject& rObj) const + { + return std::unique_ptr<BaseProperties>(new CaptionProperties(*this, rObj)); + } + + void CaptionProperties::ItemSetChanged(const SfxItemSet& rSet) + { + SdrCaptionObj& rObj = static_cast<SdrCaptionObj&>(GetSdrObject()); + + // local changes + rObj.ImpRecalcTail(); + + // call parent + RectangleProperties::ItemSetChanged(rSet); + } + + void CaptionProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr) + { + // call parent (always first thing to do, may create the SfxItemSet) + RectangleProperties::SetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr); + + // local changes + SdrCaptionObj& rObj = static_cast<SdrCaptionObj&>(GetSdrObject()); + rObj.ImpRecalcTail(); + } + + void CaptionProperties::ForceDefaultAttributes() + { + // call parent + RectangleProperties::ForceDefaultAttributes(); + + // force ItemSet + GetObjectItemSet(); + + // this was set by TextProperties::ForceDefaultAttributes(), + // reset to default + mpItemSet->ClearItem(XATTR_LINESTYLE); + } +} // end of namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sdr/properties/circleproperties.cxx b/svx/source/sdr/properties/circleproperties.cxx new file mode 100644 index 000000000..895029ca7 --- /dev/null +++ b/svx/source/sdr/properties/circleproperties.cxx @@ -0,0 +1,123 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <sal/config.h> + +#include <sdr/properties/circleproperties.hxx> +#include <svl/itemset.hxx> +#include <svl/style.hxx> +#include <svx/svddef.hxx> +#include <editeng/eeitem.hxx> +#include <svx/svdocirc.hxx> +#include <sxcikitm.hxx> +#include <svx/sxciaitm.hxx> + + +namespace sdr::properties +{ + // create a new itemset + std::unique_ptr<SfxItemSet> CircleProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool) + { + return std::make_unique<SfxItemSet>( + rPool, + svl::Items< + // Ranges from SdrAttrObj, SdrCircObj + SDRATTR_START, SDRATTR_SHADOW_LAST, + SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST, + SDRATTR_CIRC_FIRST, SDRATTR_CIRC_LAST, + SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION, + // Range from SdrTextObj: + EE_ITEMS_START, EE_ITEMS_END>{}); + } + + CircleProperties::CircleProperties(SdrObject& rObj) + : RectangleProperties(rObj) + { + } + + CircleProperties::CircleProperties(const CircleProperties& rProps, SdrObject& rObj) + : RectangleProperties(rProps, rObj) + { + } + + CircleProperties::~CircleProperties() + { + } + + std::unique_ptr<BaseProperties> CircleProperties::Clone(SdrObject& rObj) const + { + return std::unique_ptr<BaseProperties>(new CircleProperties(*this, rObj)); + } + + void CircleProperties::ItemSetChanged(const SfxItemSet& rSet) + { + SdrCircObj& rObj = static_cast<SdrCircObj&>(GetSdrObject()); + + // call parent + RectangleProperties::ItemSetChanged(rSet); + + // local changes + rObj.ImpSetAttrToCircInfo(); + } + + void CircleProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr) + { + // call parent (always first thing to do, may create the SfxItemSet) + RectangleProperties::SetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr); + + // local changes + SdrCircObj& rObj = static_cast<SdrCircObj&>(GetSdrObject()); + rObj.SetXPolyDirty(); + + // local changes + rObj.ImpSetAttrToCircInfo(); + } + + void CircleProperties::ForceDefaultAttributes() + { + SdrCircObj& rObj = static_cast<SdrCircObj&>(GetSdrObject()); + SdrCircKind eKind = rObj.GetCircleKind(); + + if(eKind != SdrCircKind::Full) + { + // force ItemSet + GetObjectItemSet(); + + mpItemSet->Put(SdrCircKindItem(eKind)); + + if(rObj.GetStartAngle()) + { + mpItemSet->Put(makeSdrCircStartAngleItem(rObj.GetStartAngle())); + } + + if(rObj.GetEndAngle() != 36000) + { + mpItemSet->Put(makeSdrCircEndAngleItem(rObj.GetEndAngle())); + } + } + + // call parent after SetObjectItem(SdrCircKindItem()) + // because ForceDefaultAttr() will call + // ImpSetAttrToCircInfo() which needs a correct + // SdrCircKindItem + RectangleProperties::ForceDefaultAttributes(); + } +} // end of namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sdr/properties/connectorproperties.cxx b/svx/source/sdr/properties/connectorproperties.cxx new file mode 100644 index 000000000..29a2b7ede --- /dev/null +++ b/svx/source/sdr/properties/connectorproperties.cxx @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <sal/config.h> + +#include <sdr/properties/connectorproperties.hxx> +#include <svl/itemset.hxx> +#include <svl/style.hxx> +#include <svx/svddef.hxx> +#include <editeng/eeitem.hxx> +#include <svx/svdoedge.hxx> + + +namespace sdr::properties +{ + // create a new itemset + std::unique_ptr<SfxItemSet> ConnectorProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool) + { + return std::make_unique<SfxItemSet>( + rPool, + svl::Items< + // Ranges from SdrAttrObj, SdrEdgeObj: + SDRATTR_START, SDRATTR_SHADOW_LAST, + SDRATTR_MISC_FIRST, SDRATTR_EDGE_LAST, + SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION, + // Range from SdrTextObj: + EE_ITEMS_START, EE_ITEMS_END>{}); + } + + ConnectorProperties::ConnectorProperties(SdrObject& rObj) + : TextProperties(rObj) + { + } + + ConnectorProperties::ConnectorProperties(const ConnectorProperties& rProps, SdrObject& rObj) + : TextProperties(rProps, rObj) + { + } + + ConnectorProperties::~ConnectorProperties() + { + } + + std::unique_ptr<BaseProperties> ConnectorProperties::Clone(SdrObject& rObj) const + { + return std::unique_ptr<BaseProperties>(new ConnectorProperties(*this, rObj)); + } + + void ConnectorProperties::ItemSetChanged(const SfxItemSet& rSet) + { + SdrEdgeObj& rObj = static_cast<SdrEdgeObj&>(GetSdrObject()); + + // call parent + TextProperties::ItemSetChanged(rSet); + + // local changes + rObj.ImpSetAttrToEdgeInfo(); + } + + void ConnectorProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr) + { + // call parent (always first thing to do, may create the SfxItemSet) + TextProperties::SetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr); + + // local changes + SdrEdgeObj& rObj = static_cast<SdrEdgeObj&>(GetSdrObject()); + rObj.ImpSetAttrToEdgeInfo(); + } +} // end of namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sdr/properties/customshapeproperties.cxx b/svx/source/sdr/properties/customshapeproperties.cxx new file mode 100644 index 000000000..0d1443081 --- /dev/null +++ b/svx/source/sdr/properties/customshapeproperties.cxx @@ -0,0 +1,231 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <sal/config.h> + +#include <sdr/properties/customshapeproperties.hxx> +#include <svl/itemset.hxx> +#include <svl/style.hxx> +#include <svx/svdoashp.hxx> +#include <svx/sdooitm.hxx> +#include <editeng/eeitem.hxx> +#include <svl/whiter.hxx> +#include <svl/hint.hxx> + +#include <sal/log.hxx> + + +namespace sdr::properties +{ + void CustomShapeProperties::UpdateTextFrameStatus(bool bInvalidateRenderGeometry) + { + SdrObjCustomShape& rObj = static_cast< SdrObjCustomShape& >(GetSdrObject()); + const bool bOld(rObj.bTextFrame); + + // change TextFrame flag when bResizeShapeToFitText changes (which is mapped + // on the item SDRATTR_TEXT_AUTOGROWHEIGHT for custom shapes, argh) + rObj.bTextFrame = GetObjectItemSet().Get(SDRATTR_TEXT_AUTOGROWHEIGHT).GetValue(); + + // check if it did change + if(rObj.bTextFrame != bOld) + { + // on change also invalidate render geometry + bInvalidateRenderGeometry = true; + + // #115391# Potential recursion, since it calls SetObjectItemSet again, but rObj.bTextFrame + // will not change again. Thus it will be only one level and terminate safely + rObj.AdaptTextMinSize(); + } + + if(bInvalidateRenderGeometry) + { + // if asked for or bResizeShapeToFitText changed, make sure that + // the render geometry is reconstructed using changed parameters + rObj.InvalidateRenderGeometry(); + } + } + + std::unique_ptr<SfxItemSet> CustomShapeProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool) + { + return std::make_unique<SfxItemSet>( + rPool, + svl::Items< + // Ranges from SdrAttrObj: + SDRATTR_START, SDRATTR_SHADOW_LAST, + SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST, + SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION, + // Graphic attributes, 3D properties, CustomShape + // properties: + SDRATTR_GRAF_FIRST, SDRATTR_CUSTOMSHAPE_LAST, + SDRATTR_GLOW_FIRST, SDRATTR_SOFTEDGE_LAST, + // Range from SdrTextObj: + EE_ITEMS_START, EE_ITEMS_END>{}); + } + + bool CustomShapeProperties::AllowItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem ) const + { + bool bAllowItemChange = true; + if ( !pNewItem ) + { + if ( ( nWhich >= SDRATTR_CUSTOMSHAPE_FIRST ) && ( nWhich <= SDRATTR_CUSTOMSHAPE_LAST ) ) + bAllowItemChange = false; + } + if ( bAllowItemChange ) + bAllowItemChange = TextProperties::AllowItemChange( nWhich, pNewItem ); + return bAllowItemChange; + } + + void CustomShapeProperties::ClearObjectItem(const sal_uInt16 nWhich) + { + if ( !nWhich ) + { + SfxWhichIter aIter( *mpItemSet ); + sal_uInt16 nWhich2 = aIter.FirstWhich(); + while( nWhich2 ) + { + TextProperties::ClearObjectItemDirect( nWhich2 ); + nWhich2 = aIter.NextWhich(); + } + SfxItemSet aSet(GetSdrObject().GetObjectItemPool()); + ItemSetChanged(aSet); + } + else + TextProperties::ClearObjectItem( nWhich ); + } + + void CustomShapeProperties::ClearObjectItemDirect(const sal_uInt16 nWhich) + { + if ( !nWhich ) + { + SfxWhichIter aIter( *mpItemSet ); + sal_uInt16 nWhich2 = aIter.FirstWhich(); + while( nWhich2 ) + { + TextProperties::ClearObjectItemDirect( nWhich2 ); + nWhich2 = aIter.NextWhich(); + } + } + else + TextProperties::ClearObjectItemDirect( nWhich ); + } + + void CustomShapeProperties::ItemSetChanged(const SfxItemSet& rSet) + { + // call parent + TextProperties::ItemSetChanged(rSet); + + // update bTextFrame and RenderGeometry + UpdateTextFrameStatus(true); + } + + void CustomShapeProperties::PostItemChange(const sal_uInt16 nWhich) + { + switch(nWhich) + { + case SDRATTR_TEXT_AUTOGROWHEIGHT: + { + // #115391# update bTextFrame and RenderGeometry using AdaptTextMinSize() + UpdateTextFrameStatus(false); + break; + } + default: + { + break; + } + } + + // call parent + TextProperties::PostItemChange(nWhich); + } + + void CustomShapeProperties::ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem) + { + // call parent + TextProperties::ItemChange( nWhich, pNewItem ); + + // update bTextFrame and RenderGeometry + UpdateTextFrameStatus(true); + } + + void CustomShapeProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr) + { + // call parent (always first thing to do, may create the SfxItemSet) + TextProperties::SetStyleSheet( pNewStyleSheet, bDontRemoveHardAttr ); + + // update bTextFrame and RenderGeometry + UpdateTextFrameStatus(true); + } + + void CustomShapeProperties::ForceDefaultAttributes() + { + // update bTextFrame and RenderGeometry + UpdateTextFrameStatus(true); + + // SJ: Following is no good if creating customshapes, leading to objects that are white after loading via xml + // This means: Do *not* call parent here is by purpose... + } + + CustomShapeProperties::CustomShapeProperties(SdrObject& rObj) + : TextProperties(rObj) + { + } + + CustomShapeProperties::CustomShapeProperties(const CustomShapeProperties& rProps, SdrObject& rObj) + : TextProperties(rProps, rObj) + { + } + + CustomShapeProperties::~CustomShapeProperties() + { + } + + std::unique_ptr<BaseProperties> CustomShapeProperties::Clone(SdrObject& rObj) const + { + return std::unique_ptr<BaseProperties>(new CustomShapeProperties(*this, rObj)); + } + + void CustomShapeProperties::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) + { + TextProperties::Notify( rBC, rHint ); + + bool bRemoveRenderGeometry = false; + const SfxStyleSheetHint* pStyleHint = dynamic_cast<const SfxStyleSheetHint*>(&rHint); + + if ( pStyleHint && pStyleHint->GetStyleSheet() == GetStyleSheet() ) + { + switch( pStyleHint->GetId() ) + { + case SfxHintId::StyleSheetModified : + case SfxHintId::StyleSheetChanged : + bRemoveRenderGeometry = true; + break; + default: break; + } + } + else if ( rHint.GetId() == SfxHintId::DataChanged ) + { + bRemoveRenderGeometry = true; + } + + // update bTextFrame and RenderGeometry + UpdateTextFrameStatus(bRemoveRenderGeometry); + } +} // end of namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sdr/properties/defaultproperties.cxx b/svx/source/sdr/properties/defaultproperties.cxx new file mode 100644 index 000000000..587e9a652 --- /dev/null +++ b/svx/source/sdr/properties/defaultproperties.cxx @@ -0,0 +1,254 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <sal/config.h> + +#include <svx/sdr/properties/defaultproperties.hxx> +#include <sdr/properties/itemsettools.hxx> +#include <svl/itemset.hxx> +#include <svl/whiter.hxx> +#include <vector> +#include <svx/svdobj.hxx> +#include <svx/svddef.hxx> +#include <editeng/eeitem.hxx> +#include <libxml/xmlwriter.h> +#include <svx/svdmodel.hxx> +#include <svx/svdtrans.hxx> +#include <svx/xbtmpit.hxx> + +namespace sdr::properties +{ + std::unique_ptr<SfxItemSet> DefaultProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool) + { + // Basic implementation; Basic object has NO attributes + return std::make_unique<SfxItemSet>(rPool); + } + + DefaultProperties::DefaultProperties(SdrObject& rObj) + : BaseProperties(rObj) + { + } + + DefaultProperties::DefaultProperties(const DefaultProperties& rProps, SdrObject& rObj) + : BaseProperties(rObj) + { + if(rProps.mpItemSet) + { + // Clone may be to another model and thus another ItemPool. + // SfxItemSet supports that thus we are able to Clone all + // SfxItemState::SET items to the target pool. + mpItemSet = rProps.mpItemSet->Clone( + true, + &rObj.getSdrModelFromSdrObject().GetItemPool()); + + // React on ModelChange: If metric has changed, scale items. + // As seen above, clone is supported, but scale is not included, + // thus: TTTT maybe add scale to SfxItemSet::Clone() (?) + // tdf#117707 correct ModelChange detection + const bool bModelChange(&rObj.getSdrModelFromSdrObject() != &rProps.GetSdrObject().getSdrModelFromSdrObject()); + + if(bModelChange) + { + const MapUnit aOldUnit(rProps.GetSdrObject().getSdrModelFromSdrObject().GetScaleUnit()); + const MapUnit aNewUnit(rObj.getSdrModelFromSdrObject().GetScaleUnit()); + const bool bScaleUnitChanged(aNewUnit != aOldUnit); + + if(bScaleUnitChanged) + { + const Fraction aMetricFactor(GetMapFactor(aOldUnit, aNewUnit).X()); + + ScaleItemSet(*mpItemSet, aMetricFactor); + } + } + + // do not keep parent info, this may be changed by later constructors. + // This class just copies the ItemSet, ignore parent. + if(mpItemSet && mpItemSet->GetParent()) + { + mpItemSet->SetParent(nullptr); + } + } + } + + std::unique_ptr<BaseProperties> DefaultProperties::Clone(SdrObject& rObj) const + { + return std::unique_ptr<BaseProperties>(new DefaultProperties(*this, rObj)); + } + + DefaultProperties::~DefaultProperties() {} + + const SfxItemSet& DefaultProperties::GetObjectItemSet() const + { + if(!mpItemSet) + { + const_cast<DefaultProperties*>(this)->mpItemSet = const_cast<DefaultProperties*>(this)->CreateObjectSpecificItemSet(GetSdrObject().GetObjectItemPool()); + const_cast<DefaultProperties*>(this)->ForceDefaultAttributes(); + } + + assert(mpItemSet && "Could not create an SfxItemSet(!)"); + + return *mpItemSet; + } + + void DefaultProperties::SetObjectItem(const SfxPoolItem& rItem) + { + const sal_uInt16 nWhichID(rItem.Which()); + + if(AllowItemChange(nWhichID, &rItem)) + { + ItemChange(nWhichID, &rItem); + PostItemChange(nWhichID); + + SfxItemSet aSet(GetSdrObject().GetObjectItemPool(), {{nWhichID, nWhichID}}); + aSet.Put(rItem); + ItemSetChanged(aSet); + } + } + + void DefaultProperties::SetObjectItemDirect(const SfxPoolItem& rItem) + { + const sal_uInt16 nWhichID(rItem.Which()); + + if(AllowItemChange(nWhichID, &rItem)) + { + ItemChange(nWhichID, &rItem); + } + } + + void DefaultProperties::ClearObjectItem(const sal_uInt16 nWhich) + { + if(AllowItemChange(nWhich)) + { + ItemChange(nWhich); + PostItemChange(nWhich); + + if(nWhich) + { + SfxItemSet aSet(GetSdrObject().GetObjectItemPool(), {{nWhich, nWhich}}); + ItemSetChanged(aSet); + } + } + } + + void DefaultProperties::ClearObjectItemDirect(const sal_uInt16 nWhich) + { + if(AllowItemChange(nWhich)) + { + ItemChange(nWhich); + } + } + + void DefaultProperties::SetObjectItemSet(const SfxItemSet& rSet) + { + if (rSet.HasItem(XATTR_FILLBITMAP)) + { + const XFillBitmapItem* pItem = rSet.GetItem(XATTR_FILLBITMAP); + const std::shared_ptr<VectorGraphicData>& pVectorData + = pItem->GetGraphicObject().GetGraphic().getVectorGraphicData(); + if (pVectorData) + { + // Shape is filled by a vector graphic: tell it our size as a hint. + basegfx::B2DTuple aSizeHint; + aSizeHint.setX(GetSdrObject().GetSnapRect().getWidth()); + aSizeHint.setY(GetSdrObject().GetSnapRect().getHeight()); + pVectorData->setSizeHint(aSizeHint); + } + } + + SfxWhichIter aWhichIter(rSet); + sal_uInt16 nWhich(aWhichIter.FirstWhich()); + const SfxPoolItem *pPoolItem; + std::vector< sal_uInt16 > aPostItemChangeList; + bool bDidChange(false); + SfxItemSet aSet(GetSdrObject().GetObjectItemPool(), svl::Items<SDRATTR_START, EE_ITEMS_END>{}); + + // give a hint to STL_Vector + aPostItemChangeList.reserve(rSet.Count()); + + while(nWhich) + { + if(SfxItemState::SET == rSet.GetItemState(nWhich, false, &pPoolItem)) + { + if(AllowItemChange(nWhich, pPoolItem)) + { + bDidChange = true; + ItemChange(nWhich, pPoolItem); + aPostItemChangeList.push_back( nWhich ); + aSet.Put(*pPoolItem); + } + } + + nWhich = aWhichIter.NextWhich(); + } + + if(bDidChange) + { + for (const auto& rItem : aPostItemChangeList) + { + PostItemChange(rItem); + } + + ItemSetChanged(aSet); + } + } + + void DefaultProperties::ItemSetChanged(const SfxItemSet& /*rSet*/) + { + } + + bool DefaultProperties::AllowItemChange(const sal_uInt16 /*nWhich*/, const SfxPoolItem* /*pNewItem*/) const + { + return true; + } + + void DefaultProperties::ItemChange(const sal_uInt16 /*nWhich*/, const SfxPoolItem* /*pNewItem*/) + { + } + + void DefaultProperties::PostItemChange(const sal_uInt16 nWhich ) + { + if( (nWhich == XATTR_FILLSTYLE) && (mpItemSet != nullptr) ) + CleanupFillProperties(*mpItemSet); + } + + void DefaultProperties::SetStyleSheet(SfxStyleSheet* /*pNewStyleSheet*/, bool /*bDontRemoveHardAttr*/) + { + // no StyleSheet in DefaultProperties + } + + SfxStyleSheet* DefaultProperties::GetStyleSheet() const + { + // no StyleSheet in DefaultProperties + return nullptr; + } + + void DefaultProperties::ForceDefaultAttributes() + { + } + + void DefaultProperties::dumpAsXml(xmlTextWriterPtr pWriter) const + { + xmlTextWriterStartElement(pWriter, BAD_CAST("DefaultProperties")); + BaseProperties::dumpAsXml(pWriter); + mpItemSet->dumpAsXml(pWriter); + xmlTextWriterEndElement(pWriter); + } +} // end of namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sdr/properties/e3dcompoundproperties.cxx b/svx/source/sdr/properties/e3dcompoundproperties.cxx new file mode 100644 index 000000000..8d023d033 --- /dev/null +++ b/svx/source/sdr/properties/e3dcompoundproperties.cxx @@ -0,0 +1,144 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <sdr/properties/e3dcompoundproperties.hxx> +#include <svl/itemset.hxx> +#include <svx/obj3d.hxx> +#include <svx/scene3d.hxx> + + +namespace sdr::properties +{ + E3dCompoundProperties::E3dCompoundProperties(SdrObject& rObj) + : E3dProperties(rObj) + { + } + + E3dCompoundProperties::E3dCompoundProperties(const E3dCompoundProperties& rProps, SdrObject& rObj) + : E3dProperties(rProps, rObj) + { + } + + E3dCompoundProperties::~E3dCompoundProperties() + { + } + + std::unique_ptr<BaseProperties> E3dCompoundProperties::Clone(SdrObject& rObj) const + { + return std::unique_ptr<BaseProperties>(new E3dCompoundProperties(*this, rObj)); + } + + const SfxItemSet& E3dCompoundProperties::GetMergedItemSet() const + { + // include Items of scene this object belongs to + const E3dCompoundObject& rObj = static_cast<const E3dCompoundObject&>(GetSdrObject()); + E3dScene* pScene(rObj.getRootE3dSceneFromE3dObject()); + + if(nullptr != pScene) + { + // force ItemSet + GetObjectItemSet(); + + // add filtered scene properties (SDRATTR_3DSCENE_) to local itemset + SfxItemSet aSet(*mpItemSet->GetPool(), svl::Items<SDRATTR_3DSCENE_FIRST, SDRATTR_3DSCENE_LAST>{}); + aSet.Put(pScene->GetProperties().GetObjectItemSet()); + mpItemSet->Put(aSet); + } + + // call parent + return E3dProperties::GetMergedItemSet(); + } + + void E3dCompoundProperties::SetMergedItemSet(const SfxItemSet& rSet, bool bClearAllItems) + { + // Set scene specific items at scene + E3dCompoundObject& rObj = static_cast<E3dCompoundObject&>(GetSdrObject()); + E3dScene* pScene(rObj.getRootE3dSceneFromE3dObject()); + + if(nullptr != pScene) + { + // force ItemSet + GetObjectItemSet(); + + // Generate filtered scene properties (SDRATTR_3DSCENE_) itemset + SfxItemSet aSet(*mpItemSet->GetPool(), svl::Items<SDRATTR_3DSCENE_FIRST, SDRATTR_3DSCENE_LAST>{}); + aSet.Put(rSet); + + if(bClearAllItems) + { + pScene->GetProperties().ClearObjectItem(); + } + + if(aSet.Count()) + { + pScene->GetProperties().SetObjectItemSet(aSet); + } + } + + // call parent. This will set items on local object, too. + E3dProperties::SetMergedItemSet(rSet, bClearAllItems); + } + + void E3dCompoundProperties::PostItemChange(const sal_uInt16 nWhich) + { + // call parent + E3dProperties::PostItemChange(nWhich); + + // handle value change + E3dCompoundObject& rObj = static_cast<E3dCompoundObject&>(GetSdrObject()); + + switch(nWhich) + { + // #i28528# + // Added extra Item (Bool) for chart2 to be able to show reduced line geometry + case SDRATTR_3DOBJ_REDUCED_LINE_GEOMETRY: + { + rObj.ActionChanged(); + break; + } + case SDRATTR_3DOBJ_DOUBLE_SIDED: + { + rObj.ActionChanged(); + break; + } + case SDRATTR_3DOBJ_NORMALS_KIND: + { + rObj.ActionChanged(); + break; + } + case SDRATTR_3DOBJ_NORMALS_INVERT: + { + rObj.ActionChanged(); + break; + } + case SDRATTR_3DOBJ_TEXTURE_PROJ_X: + { + rObj.ActionChanged(); + break; + } + case SDRATTR_3DOBJ_TEXTURE_PROJ_Y: + { + rObj.ActionChanged(); + break; + } + } + } +} // end of namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sdr/properties/e3dextrudeproperties.cxx b/svx/source/sdr/properties/e3dextrudeproperties.cxx new file mode 100644 index 000000000..9b9ffd8be --- /dev/null +++ b/svx/source/sdr/properties/e3dextrudeproperties.cxx @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <sdr/properties/e3dextrudeproperties.hxx> +#include <extrud3d.hxx> + + +namespace sdr::properties +{ + E3dExtrudeProperties::E3dExtrudeProperties(SdrObject& rObj) + : E3dCompoundProperties(rObj) + { + } + + E3dExtrudeProperties::E3dExtrudeProperties(const E3dExtrudeProperties& rProps, SdrObject& rObj) + : E3dCompoundProperties(rProps, rObj) + { + } + + E3dExtrudeProperties::~E3dExtrudeProperties() + { + } + + std::unique_ptr<BaseProperties> E3dExtrudeProperties::Clone(SdrObject& rObj) const + { + return std::unique_ptr<BaseProperties>(new E3dExtrudeProperties(*this, rObj)); + } + + void E3dExtrudeProperties::PostItemChange(const sal_uInt16 nWhich) + { + // call parent + E3dCompoundProperties::PostItemChange(nWhich); + + // handle value change + E3dExtrudeObj& rObj = static_cast<E3dExtrudeObj&>(GetSdrObject()); + + switch(nWhich) + { + case SDRATTR_3DOBJ_PERCENT_DIAGONAL: + { + rObj.ActionChanged(); + break; + } + case SDRATTR_3DOBJ_BACKSCALE: + { + rObj.ActionChanged(); + break; + } + case SDRATTR_3DOBJ_DEPTH: + { + rObj.ActionChanged(); + break; + } + } + } +} // end of namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sdr/properties/e3dlatheproperties.cxx b/svx/source/sdr/properties/e3dlatheproperties.cxx new file mode 100644 index 000000000..feb546534 --- /dev/null +++ b/svx/source/sdr/properties/e3dlatheproperties.cxx @@ -0,0 +1,84 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <sdr/properties/e3dlatheproperties.hxx> +#include <svx/lathe3d.hxx> + + +namespace sdr::properties +{ + E3dLatheProperties::E3dLatheProperties(SdrObject& rObj) + : E3dCompoundProperties(rObj) + { + } + + E3dLatheProperties::E3dLatheProperties(const E3dLatheProperties& rProps, SdrObject& rObj) + : E3dCompoundProperties(rProps, rObj) + { + } + + E3dLatheProperties::~E3dLatheProperties() + { + } + + std::unique_ptr<BaseProperties> E3dLatheProperties::Clone(SdrObject& rObj) const + { + return std::unique_ptr<BaseProperties>(new E3dLatheProperties(*this, rObj)); + } + + void E3dLatheProperties::PostItemChange(const sal_uInt16 nWhich) + { + // call parent + E3dCompoundProperties::PostItemChange(nWhich); + + // handle value change + E3dLatheObj& rObj = static_cast<E3dLatheObj&>(GetSdrObject()); + + switch(nWhich) + { + case SDRATTR_3DOBJ_HORZ_SEGS: + { + rObj.ActionChanged(); + break; + } + case SDRATTR_3DOBJ_VERT_SEGS: + { + rObj.ActionChanged(); + break; + } + case SDRATTR_3DOBJ_PERCENT_DIAGONAL: + { + rObj.ActionChanged(); + break; + } + case SDRATTR_3DOBJ_BACKSCALE: + { + rObj.ActionChanged(); + break; + } + case SDRATTR_3DOBJ_END_ANGLE: + { + rObj.ActionChanged(); + break; + } + } + } +} // end of namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sdr/properties/e3dproperties.cxx b/svx/source/sdr/properties/e3dproperties.cxx new file mode 100644 index 000000000..0f435fd99 --- /dev/null +++ b/svx/source/sdr/properties/e3dproperties.cxx @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <sal/config.h> + +#include <sdr/properties/e3dproperties.hxx> +#include <svl/itemset.hxx> +#include <svx/svddef.hxx> +#include <svx/obj3d.hxx> + + +namespace sdr::properties +{ + // create a new itemset + std::unique_ptr<SfxItemSet> E3dProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool) + { + return std::make_unique<SfxItemSet>(rPool, + + // ranges from SdrAttrObj + svl::Items<SDRATTR_START, SDRATTR_SHADOW_LAST, + SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST, + SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION, + + // ranges from E3dObject, contains object and scene because of GetMergedItemSet() + SDRATTR_3D_FIRST, SDRATTR_3D_LAST>{}); + } + + E3dProperties::E3dProperties(SdrObject& rObj) + : AttributeProperties(rObj) + { + } + + E3dProperties::E3dProperties(const E3dProperties& rProps, SdrObject& rObj) + : AttributeProperties(rProps, rObj) + { + } + + E3dProperties::~E3dProperties() + { + } + + std::unique_ptr<BaseProperties> E3dProperties::Clone(SdrObject& rObj) const + { + return std::unique_ptr<BaseProperties>(new E3dProperties(*this, rObj)); + } + + void E3dProperties::ItemSetChanged(const SfxItemSet& rSet) + { + E3dObject& rObj = static_cast<E3dObject&>(GetSdrObject()); + + // call parent + AttributeProperties::ItemSetChanged(rSet); + + // local changes + rObj.StructureChanged(); + } +} // end of namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sdr/properties/e3dsceneproperties.cxx b/svx/source/sdr/properties/e3dsceneproperties.cxx new file mode 100644 index 000000000..de99a1835 --- /dev/null +++ b/svx/source/sdr/properties/e3dsceneproperties.cxx @@ -0,0 +1,292 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <sdr/properties/e3dsceneproperties.hxx> +#include <svl/itemset.hxx> +#include <svl/whiter.hxx> +#include <svx/svddef.hxx> +#include <svx/scene3d.hxx> +#include <memory> + + +namespace sdr::properties +{ + E3dSceneProperties::E3dSceneProperties(SdrObject& rObj) + : E3dProperties(rObj) + { + } + + E3dSceneProperties::E3dSceneProperties(const E3dSceneProperties& rProps, SdrObject& rObj) + : E3dProperties(rProps, rObj) + { + } + + E3dSceneProperties::~E3dSceneProperties() + { + } + + std::unique_ptr<BaseProperties> E3dSceneProperties::Clone(SdrObject& rObj) const + { + return std::unique_ptr<BaseProperties>(new E3dSceneProperties(*this, rObj)); + } + + const SfxItemSet& E3dSceneProperties::GetMergedItemSet() const + { + // prepare ItemSet + if(mpItemSet) + { + // filter for SDRATTR_3DSCENE_ items, only keep those items + SfxItemSet aNew(*mpItemSet->GetPool(), svl::Items<SDRATTR_3DSCENE_FIRST, SDRATTR_3DSCENE_LAST>{}); + aNew.Put(*mpItemSet); + mpItemSet->ClearItem(); + mpItemSet->Put(aNew); + } + else + { + // No ItemSet yet, force local ItemSet + GetObjectItemSet(); + } + + // collect all ItemSets of contained 3d objects + const SdrObjList* pSub(static_cast<const E3dScene&>(GetSdrObject()).GetSubList()); + OSL_ENSURE(nullptr != pSub, "Children of SdrObject expected (!)"); + const size_t nCount(nullptr == pSub ? 0 : pSub->GetObjCount()); + + for(size_t a = 0; a < nCount; ++a) + { + SdrObject* pObj = pSub->GetObj(a); + + if(dynamic_cast<const E3dCompoundObject* >(pObj)) + { + const SfxItemSet& rSet = pObj->GetMergedItemSet(); + SfxWhichIter aIter(rSet); + sal_uInt16 nWhich(aIter.FirstWhich()); + + while(nWhich) + { + // Leave out the SDRATTR_3DSCENE_ range, this would only be double + // and always equal. + if(nWhich <= SDRATTR_3DSCENE_FIRST || nWhich >= SDRATTR_3DSCENE_LAST) + { + if(SfxItemState::DONTCARE == rSet.GetItemState(nWhich, false)) + { + mpItemSet->InvalidateItem(nWhich); + } + else + { + mpItemSet->MergeValue(rSet.Get(nWhich), true); + } + } + + nWhich = aIter.NextWhich(); + } + } + } + + // call parent + return E3dProperties::GetMergedItemSet(); + } + + void E3dSceneProperties::SetMergedItemSet(const SfxItemSet& rSet, bool bClearAllItems) + { + // Set SDRATTR_3DOBJ_ range at contained objects. + const SdrObjList* pSub(static_cast<const E3dScene&>(GetSdrObject()).GetSubList()); + OSL_ENSURE(nullptr != pSub, "Children of SdrObject expected (!)"); + const size_t nCount(nullptr == pSub ? 0 : pSub->GetObjCount()); + + if(nCount) + { + // Generate filtered ItemSet which contains all but the SDRATTR_3DSCENE items. + // #i50808# Leak fix, Clone produces a new instance and we get ownership here + std::unique_ptr<SfxItemSet> pNewSet(rSet.Clone()); + DBG_ASSERT(pNewSet, "E3dSceneProperties::SetMergedItemSet(): Could not clone ItemSet (!)"); + + for(sal_uInt16 b(SDRATTR_3DSCENE_FIRST); b <= SDRATTR_3DSCENE_LAST; b++) + { + pNewSet->ClearItem(b); + } + + if(pNewSet->Count()) + { + for(size_t a = 0; a < nCount; ++a) + { + SdrObject* pObj = pSub->GetObj(a); + + if(dynamic_cast<const E3dCompoundObject* >(pObj)) + { + // set merged ItemSet at contained 3d object. + pObj->SetMergedItemSet(*pNewSet, bClearAllItems); + } + } + } + } + + // call parent. This will set items on local object, too. + E3dProperties::SetMergedItemSet(rSet, bClearAllItems); + } + + void E3dSceneProperties::SetMergedItem(const SfxPoolItem& rItem) + { + const SdrObjList* pSub(static_cast<const E3dScene&>(GetSdrObject()).GetSubList()); + OSL_ENSURE(nullptr != pSub, "Children of SdrObject expected (!)"); + const size_t nCount(nullptr == pSub ? 0 : pSub->GetObjCount()); + + for(size_t a = 0; a < nCount; ++a) + { + pSub->GetObj(a)->SetMergedItem(rItem); + } + + // #i43809# call parent. This will set items on local object, too. + E3dProperties::SetMergedItem(rItem); + } + + void E3dSceneProperties::ClearMergedItem(const sal_uInt16 nWhich) + { + const SdrObjList* pSub(static_cast<const E3dScene&>(GetSdrObject()).GetSubList()); + OSL_ENSURE(nullptr != pSub, "Children of SdrObject expected (!)"); + const size_t nCount(nullptr == pSub ? 0 : pSub->GetObjCount()); + + for(size_t a = 0; a < nCount; ++a) + { + pSub->GetObj(a)->ClearMergedItem(nWhich); + } + + // #i43809# call parent. This will clear items on local object, too. + E3dProperties::ClearMergedItem(nWhich); + } + + void E3dSceneProperties::PostItemChange(const sal_uInt16 nWhich) + { + // call parent + E3dProperties::PostItemChange(nWhich); + + // local changes + E3dScene& rObj = static_cast<E3dScene&>(GetSdrObject()); + rObj.StructureChanged(); + + switch(nWhich) + { + case SDRATTR_3DSCENE_PERSPECTIVE : + case SDRATTR_3DSCENE_DISTANCE : + case SDRATTR_3DSCENE_FOCAL_LENGTH : + { + // #83387#, #83391# + // one common function for the camera attributes + // since SetCamera() sets all three back to the ItemSet + Camera3D aSceneCam(rObj.GetCamera()); + bool bChange(false); + + // for SDRATTR_3DSCENE_PERSPECTIVE: + if(aSceneCam.GetProjection() != rObj.GetPerspective()) + { + aSceneCam.SetProjection(rObj.GetPerspective()); + bChange = true; + } + + // for SDRATTR_3DSCENE_DISTANCE: + basegfx::B3DPoint aActualPosition(aSceneCam.GetPosition()); + double fNew = rObj.GetDistance(); + + if(fNew != aActualPosition.getZ()) + { + aSceneCam.SetPosition(basegfx::B3DPoint(aActualPosition.getX(), aActualPosition.getY(), fNew)); + bChange = true; + } + + // for SDRATTR_3DSCENE_FOCAL_LENGTH: + fNew = rObj.GetFocalLength() / 100.0; + + if(aSceneCam.GetFocalLength() != fNew) + { + aSceneCam.SetFocalLength(fNew); + bChange = true; + } + + // for all + if(bChange) + { + rObj.SetCamera(aSceneCam); + } + + break; + } + } + } + + void E3dSceneProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr) + { + const SdrObjList* pSub(static_cast<const E3dScene&>(GetSdrObject()).GetSubList()); + OSL_ENSURE(nullptr != pSub, "Children of SdrObject expected (!)"); + const size_t nCount(nullptr == pSub ? 0 : pSub->GetObjCount()); + + for(size_t a = 0; a < nCount; ++a) + { + pSub->GetObj(a)->SetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr); + } + } + + SfxStyleSheet* E3dSceneProperties::GetStyleSheet() const + { + SfxStyleSheet* pRetval = nullptr; + + const SdrObjList* pSub(static_cast<const E3dScene&>(GetSdrObject()).GetSubList()); + OSL_ENSURE(nullptr != pSub, "Children of SdrObject expected (!)"); + const size_t nCount(nullptr == pSub ? 0 : pSub->GetObjCount()); + + for(size_t a = 0; a < nCount; ++a) + { + SfxStyleSheet* pCandidate = pSub->GetObj(a)->GetStyleSheet(); + + if(pRetval) + { + if(pCandidate != pRetval) + { + // different StyleSheelts, return none + return nullptr; + } + } + else + { + pRetval = pCandidate; + } + } + + return pRetval; + } + + void E3dSceneProperties::SetSceneItemsFromCamera() + { + // force ItemSet + GetObjectItemSet(); + + E3dScene& rObj = static_cast<E3dScene&>(GetSdrObject()); + const Camera3D& aSceneCam(rObj.GetCamera()); + + // ProjectionType + mpItemSet->Put(Svx3DPerspectiveItem(aSceneCam.GetProjection())); + + // CamPos + mpItemSet->Put(makeSvx3DDistanceItem(static_cast<sal_uInt32>(aSceneCam.GetPosition().getZ() + 0.5))); + + // FocalLength + mpItemSet->Put(makeSvx3DFocalLengthItem(static_cast<sal_uInt32>((aSceneCam.GetFocalLength() * 100.0) + 0.5))); + } +} // end of namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sdr/properties/e3dsphereproperties.cxx b/svx/source/sdr/properties/e3dsphereproperties.cxx new file mode 100644 index 000000000..66f01748f --- /dev/null +++ b/svx/source/sdr/properties/e3dsphereproperties.cxx @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <sdr/properties/e3dsphereproperties.hxx> +#include <svx/sphere3d.hxx> + + +namespace sdr::properties +{ + E3dSphereProperties::E3dSphereProperties(SdrObject& rObj) + : E3dCompoundProperties(rObj) + { + } + + E3dSphereProperties::E3dSphereProperties(const E3dSphereProperties& rProps, SdrObject& rObj) + : E3dCompoundProperties(rProps, rObj) + { + } + + E3dSphereProperties::~E3dSphereProperties() + { + } + + std::unique_ptr<BaseProperties> E3dSphereProperties::Clone(SdrObject& rObj) const + { + return std::unique_ptr<BaseProperties>(new E3dSphereProperties(*this, rObj)); + } + + void E3dSphereProperties::PostItemChange(const sal_uInt16 nWhich) + { + // call parent + E3dCompoundProperties::PostItemChange(nWhich); + + // handle value change + E3dSphereObj& rObj = static_cast<E3dSphereObj&>(GetSdrObject()); + + switch(nWhich) + { + case SDRATTR_3DOBJ_HORZ_SEGS: + { + rObj.ActionChanged(); + break; + } + case SDRATTR_3DOBJ_VERT_SEGS: + { + rObj.ActionChanged(); + break; + } + } + } +} // end of namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sdr/properties/emptyproperties.cxx b/svx/source/sdr/properties/emptyproperties.cxx new file mode 100644 index 000000000..502fe2702 --- /dev/null +++ b/svx/source/sdr/properties/emptyproperties.cxx @@ -0,0 +1,118 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <sal/config.h> + +#include <sdr/properties/emptyproperties.hxx> +#include <svl/itemset.hxx> +#include <svx/svdobj.hxx> + + +namespace sdr::properties +{ + // create a new itemset + std::unique_ptr<SfxItemSet> EmptyProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool) + { + // Basic implementation; Basic object has NO attributes + assert(!"EmptyProperties::CreateObjectSpecificItemSet() should never be called"); + return std::make_unique<SfxItemSet>(rPool); + } + + EmptyProperties::EmptyProperties(SdrObject& rObj) + : BaseProperties(rObj) + { + } + + std::unique_ptr<BaseProperties> EmptyProperties::Clone(SdrObject& rObj) const + { + return std::unique_ptr<BaseProperties>(new EmptyProperties(rObj)); + } + + const SfxItemSet& EmptyProperties::GetObjectItemSet() const + { + if(!mpEmptyItemSet) + { + const_cast<EmptyProperties*>(this)->mpEmptyItemSet = const_cast<EmptyProperties*>(this)->CreateObjectSpecificItemSet(GetSdrObject().GetObjectItemPool()); + } + + assert(mpEmptyItemSet); + assert(!"EmptyProperties::GetObjectItemSet() should never be called"); + + return *mpEmptyItemSet; + } + + void EmptyProperties::SetObjectItem(const SfxPoolItem& /*rItem*/) + { + assert(!"EmptyProperties::SetObjectItem() should never be called"); + } + + void EmptyProperties::SetObjectItemDirect(const SfxPoolItem& /*rItem*/) + { + assert(!"EmptyProperties::SetObjectItemDirect() should never be called"); + } + + void EmptyProperties::ClearObjectItem(const sal_uInt16 /*nWhich*/) + { + assert(!"EmptyProperties::ClearObjectItem() should never be called"); + } + + void EmptyProperties::ClearObjectItemDirect(const sal_uInt16 /*nWhich*/) + { + assert(!"EmptyProperties::ClearObjectItemDirect() should never be called"); + } + + void EmptyProperties::SetObjectItemSet(const SfxItemSet& /*rSet*/) + { + assert(!"EmptyProperties::SetObjectItemSet() should never be called"); + } + + void EmptyProperties::ItemSetChanged(const SfxItemSet& /*rSet*/) + { + assert(!"EmptyProperties::ItemSetChanged() should never be called"); + } + + bool EmptyProperties::AllowItemChange(const sal_uInt16 /*nWhich*/, const SfxPoolItem* /*pNewItem*/) const + { + assert(!"EmptyProperties::AllowItemChange() should never be called"); + return true; + } + + void EmptyProperties::ItemChange(const sal_uInt16 /*nWhich*/, const SfxPoolItem* /*pNewItem*/) + { + assert(!"EmptyProperties::ItemChange() should never be called"); + } + + void EmptyProperties::PostItemChange(const sal_uInt16 /*nWhich*/) + { + assert(!"EmptyProperties::PostItemChange() should never be called"); + } + + void EmptyProperties::SetStyleSheet(SfxStyleSheet* /*pNewStyleSheet*/, bool /*bDontRemoveHardAttr*/) + { + assert(!"EmptyProperties::SetStyleSheet() should never be called"); + } + + SfxStyleSheet* EmptyProperties::GetStyleSheet() const + { + assert(!"EmptyProperties::GetStyleSheet() should never be called"); + return nullptr; + } +} // end of namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sdr/properties/graphicproperties.cxx b/svx/source/sdr/properties/graphicproperties.cxx new file mode 100644 index 000000000..2819826ca --- /dev/null +++ b/svx/source/sdr/properties/graphicproperties.cxx @@ -0,0 +1,148 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <sal/config.h> + +#include <sdr/properties/graphicproperties.hxx> +#include <svl/itemset.hxx> +#include <svl/style.hxx> +#include <svx/svddef.hxx> +#include <editeng/eeitem.hxx> +#include <svx/svdograf.hxx> +#include <svx/sdgcpitm.hxx> +#include <svx/svdmodel.hxx> +#include <svx/sdgluitm.hxx> +#include <sdgcoitm.hxx> +#include <svx/sdggaitm.hxx> +#include <sdgtritm.hxx> +#include <sdginitm.hxx> +#include <svx/sdgmoitm.hxx> +#include <svx/xfillit0.hxx> +#include <svx/xlineit0.hxx> + +namespace sdr::properties +{ + void GraphicProperties::applyDefaultStyleSheetFromSdrModel() + { + SfxStyleSheet* pStyleSheet(GetSdrObject().getSdrModelFromSdrObject().GetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj()); + + if(pStyleSheet) + { + // do not delete hard attributes when setting dsefault Style + SetStyleSheet(pStyleSheet, true); + } + else + { + SetMergedItem(XFillStyleItem(com::sun::star::drawing::FillStyle_NONE)); + SetMergedItem(XLineStyleItem(com::sun::star::drawing::LineStyle_NONE)); + } + } + + // create a new itemset + std::unique_ptr<SfxItemSet> GraphicProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool) + { + return std::make_unique<SfxItemSet>(rPool, + + // range from SdrAttrObj + svl::Items<SDRATTR_START, SDRATTR_SHADOW_LAST, + SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST, + SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION, + + // range from SdrGrafObj + SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST, + + SDRATTR_GLOW_FIRST, SDRATTR_SOFTEDGE_LAST, + + // range from SdrTextObj + EE_ITEMS_START, EE_ITEMS_END>{}); + } + + GraphicProperties::GraphicProperties(SdrObject& rObj) + : RectangleProperties(rObj) + { + } + + GraphicProperties::GraphicProperties(const GraphicProperties& rProps, SdrObject& rObj) + : RectangleProperties(rProps, rObj) + { + } + + GraphicProperties::~GraphicProperties() + { + } + + std::unique_ptr<BaseProperties> GraphicProperties::Clone(SdrObject& rObj) const + { + return std::unique_ptr<BaseProperties>(new GraphicProperties(*this, rObj)); + } + + void GraphicProperties::ItemSetChanged(const SfxItemSet& rSet) + { + SdrGrafObj& rObj = static_cast<SdrGrafObj&>(GetSdrObject()); + + // local changes + rObj.SetXPolyDirty(); + + // #i29367# Update GraphicAttr, too. This was formerly + // triggered by SdrGrafObj::Notify, which is no longer + // called nowadays. BTW: strictly speaking, the whole + // ImpSetAttrToGrafInfostuff could + // be dumped, when SdrGrafObj::aGrafInfo is removed and + // always created on the fly for repaint. + rObj.ImpSetAttrToGrafInfo(); + + // call parent + RectangleProperties::ItemSetChanged(rSet); + } + + void GraphicProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr) + { + // call parent (always first thing to do, may create the SfxItemSet) + RectangleProperties::SetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr); + + // local changes + SdrGrafObj& rObj = static_cast<SdrGrafObj&>(GetSdrObject()); + rObj.SetXPolyDirty(); + + // local changes + rObj.ImpSetAttrToGrafInfo(); + } + + void GraphicProperties::ForceDefaultAttributes() + { + // call parent + RectangleProperties::ForceDefaultAttributes(); + + // force ItemSet + GetObjectItemSet(); + + mpItemSet->Put( SdrGrafLuminanceItem( 0 ) ); + mpItemSet->Put( SdrGrafContrastItem( 0 ) ); + mpItemSet->Put( SdrGrafRedItem( 0 ) ); + mpItemSet->Put( SdrGrafGreenItem( 0 ) ); + mpItemSet->Put( SdrGrafBlueItem( 0 ) ); + mpItemSet->Put( SdrGrafGamma100Item( 100 ) ); + mpItemSet->Put( SdrGrafTransparenceItem( 0 ) ); + mpItemSet->Put( SdrGrafInvertItem( false ) ); + mpItemSet->Put( SdrGrafModeItem( GraphicDrawMode::Standard ) ); + mpItemSet->Put( SdrGrafCropItem( 0, 0, 0, 0 ) ); + } +} // end of namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sdr/properties/groupproperties.cxx b/svx/source/sdr/properties/groupproperties.cxx new file mode 100644 index 000000000..4ccd517f4 --- /dev/null +++ b/svx/source/sdr/properties/groupproperties.cxx @@ -0,0 +1,275 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <sal/config.h> + +#include <sdr/properties/groupproperties.hxx> +#include <svl/itemset.hxx> +#include <svl/whiter.hxx> +#include <svx/svdogrp.hxx> +#include <svx/svdpage.hxx> + + +namespace sdr::properties +{ + // create a new itemset + std::unique_ptr<SfxItemSet> GroupProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool) + { + // Groups have in principle no ItemSet. To support methods like + // GetMergedItemSet() the local one is used. Thus, all items in the pool + // may be used and a pool itemset is created. + return std::make_unique<SfxItemSet>(rPool); + } + + GroupProperties::GroupProperties(SdrObject& rObj) + : DefaultProperties(rObj) + { + } + + GroupProperties::GroupProperties(const GroupProperties& rProps, SdrObject& rObj) + : DefaultProperties(rProps, rObj) + { + } + + GroupProperties::~GroupProperties() + { + } + + std::unique_ptr<BaseProperties> GroupProperties::Clone(SdrObject& rObj) const + { + return std::unique_ptr<BaseProperties>(new GroupProperties(*this, rObj)); + } + + const SfxItemSet& GroupProperties::GetObjectItemSet() const + { + assert(!"GroupProperties::GetObjectItemSet() should never be called"); + return DefaultProperties::GetObjectItemSet(); + } + + const SfxItemSet& GroupProperties::GetMergedItemSet() const + { + // prepare ItemSet + if(mpItemSet) + { + // clear local itemset for merge + mpItemSet->ClearItem(); + } + else + { + // force local itemset + DefaultProperties::GetObjectItemSet(); + } + + // collect all ItemSets in mpItemSet + const SdrObjList* pSub(static_cast<const SdrObjGroup&>(GetSdrObject()).GetSubList()); + OSL_ENSURE(nullptr != pSub, "Children of SdrObject expected (!)"); + const size_t nCount(nullptr == pSub ? 0 : pSub->GetObjCount()); + + for(size_t a = 0; a < nCount; ++a) + { + const SfxItemSet& rSet = pSub->GetObj(a)->GetMergedItemSet(); + SfxWhichIter aIter(rSet); + sal_uInt16 nWhich(aIter.FirstWhich()); + + while(nWhich) + { + if(SfxItemState::DONTCARE == rSet.GetItemState(nWhich, false)) + { + mpItemSet->InvalidateItem(nWhich); + } + else + { + mpItemSet->MergeValue(rSet.Get(nWhich), true); + } + + nWhich = aIter.NextWhich(); + } + } + + // For group properties, do not call parent since groups do + // not have local ItemSets. + return *mpItemSet; + } + + void GroupProperties::SetMergedItemSet(const SfxItemSet& rSet, bool bClearAllItems) + { + // iterate over contained SdrObjects + const SdrObjList* pSub(static_cast<const SdrObjGroup&>(GetSdrObject()).GetSubList()); + OSL_ENSURE(nullptr != pSub, "Children of SdrObject expected (!)"); + const size_t nCount(nullptr == pSub ? 0 : pSub->GetObjCount()); + + for(size_t a = 0; a < nCount; ++a) + { + SdrObject* pObj = pSub->GetObj(a); + + if(pObj) + { + // Set merged ItemSet at contained object + pObj->SetMergedItemSet(rSet, bClearAllItems); + } + } + + // Do not call parent here. Group objects do not have local ItemSets + // where items need to be set. + // DefaultProperties::SetMergedItemSet(rSet, bClearAllItems); + } + + void GroupProperties::SetObjectItem(const SfxPoolItem& /*rItem*/) + { + assert(!"GroupProperties::SetObjectItem() should never be called"); + } + + void GroupProperties::SetObjectItemDirect(const SfxPoolItem& /*rItem*/) + { + assert(!"GroupProperties::SetObjectItemDirect() should never be called"); + } + + void GroupProperties::ClearObjectItem(const sal_uInt16 nWhich) + { + // iterate over contained SdrObjects + const SdrObjList* pSub(static_cast<const SdrObjGroup&>(GetSdrObject()).GetSubList()); + OSL_ENSURE(nullptr != pSub, "Children of SdrObject expected (!)"); + const size_t nCount(nullptr == pSub ? 0 : pSub->GetObjCount()); + + for(size_t a = 0; a < nCount; ++a) + { + SdrObject* pObj = pSub->GetObj(a); + + if(pObj) + { + pObj->GetProperties().ClearObjectItem(nWhich); + } + } + } + + void GroupProperties::ClearObjectItemDirect(const sal_uInt16 /*nWhich*/) + { + assert(!"GroupProperties::ClearObjectItemDirect() should never be called"); + } + + void GroupProperties::SetMergedItem(const SfxPoolItem& rItem) + { + const SdrObjList* pSub(static_cast<const SdrObjGroup&>(GetSdrObject()).GetSubList()); + OSL_ENSURE(nullptr != pSub, "Children of SdrObject expected (!)"); + const size_t nCount(nullptr == pSub ? 0 : pSub->GetObjCount()); + + for(size_t a = 0; a < nCount; ++a) + { + pSub->GetObj(a)->GetProperties().SetMergedItem(rItem); + } + } + + void GroupProperties::ClearMergedItem(const sal_uInt16 nWhich) + { + const SdrObjList* pSub(static_cast<const SdrObjGroup&>(GetSdrObject()).GetSubList()); + OSL_ENSURE(nullptr != pSub, "Children of SdrObject expected (!)"); + const size_t nCount(nullptr == pSub ? 0 : pSub->GetObjCount()); + + for(size_t a = 0; a < nCount; ++a) + { + pSub->GetObj(a)->GetProperties().ClearMergedItem(nWhich); + } + } + + void GroupProperties::SetObjectItemSet(const SfxItemSet& /*rSet*/) + { + assert(!"GroupProperties::SetObjectItemSet() should never be called"); + } + + void GroupProperties::ItemSetChanged(const SfxItemSet& /*rSet*/) + { + assert(!"GroupProperties::ItemSetChanged() should never be called"); + } + + bool GroupProperties::AllowItemChange(const sal_uInt16 /*nWhich*/, const SfxPoolItem* /*pNewItem*/) const + { + assert(!"GroupProperties::AllowItemChange() should never be called"); + return false; + } + + void GroupProperties::ItemChange(const sal_uInt16 /*nWhich*/, const SfxPoolItem* /*pNewItem*/) + { + assert(!"GroupProperties::ItemChange() should never be called"); + } + + void GroupProperties::PostItemChange(const sal_uInt16 /*nWhich*/) + { + assert(!"GroupProperties::PostItemChange() should never be called"); + } + + SfxStyleSheet* GroupProperties::GetStyleSheet() const + { + SfxStyleSheet* pRetval = nullptr; + + const SdrObjList* pSub(static_cast<const SdrObjGroup&>(GetSdrObject()).GetSubList()); + OSL_ENSURE(nullptr != pSub, "Children of SdrObject expected (!)"); + const size_t nCount(nullptr == pSub ? 0 : pSub->GetObjCount()); + + for(size_t a = 0; a < nCount; ++a) + { + SfxStyleSheet* pCandidate = pSub->GetObj(a)->GetStyleSheet(); + + if(pRetval) + { + if(pCandidate != pRetval) + { + // different StyleSheelts, return none + return nullptr; + } + } + else + { + pRetval = pCandidate; + } + } + + return pRetval; + } + + void GroupProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr) + { + const SdrObjList* pSub(static_cast<const SdrObjGroup&>(GetSdrObject()).GetSubList()); + OSL_ENSURE(nullptr != pSub, "Children of SdrObject expected (!)"); + const size_t nCount(nullptr == pSub ? 0 : pSub->GetObjCount()); + + for(size_t a = 0; a < nCount; ++a) + { + pSub->GetObj(a)->SetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr); + } + } + + void GroupProperties::ForceDefaultAttributes() + { + // nothing to do here, groups have no items and thus no default items, too. + } + + void GroupProperties::ForceStyleToHardAttributes() + { + const SdrObjList* pSub(static_cast<const SdrObjGroup&>(GetSdrObject()).GetSubList()); + OSL_ENSURE(nullptr != pSub, "Children of SdrObject expected (!)"); + const size_t nCount(nullptr == pSub ? 0 : pSub->GetObjCount()); + + for(size_t a = 0; a < nCount; ++a) + { + pSub->GetObj(a)->GetProperties().ForceStyleToHardAttributes(); + } + } +} // end of namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sdr/properties/itemsettools.cxx b/svx/source/sdr/properties/itemsettools.cxx new file mode 100644 index 000000000..b8be77812 --- /dev/null +++ b/svx/source/sdr/properties/itemsettools.cxx @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <sdr/properties/itemsettools.hxx> +#include <tools/fract.hxx> +#include <svl/itemset.hxx> +#include <svl/whiter.hxx> +#include <svx/svdogrp.hxx> +#include <svx/svditer.hxx> +#include <memory> + +// class to remember broadcast start positions + +namespace sdr::properties +{ + ItemChangeBroadcaster::ItemChangeBroadcaster(const SdrObject& rObj) + { + if (const SdrObjGroup* pGroupObj = dynamic_cast<const SdrObjGroup*>(&rObj)) + { + SdrObjListIter aIter(pGroupObj->GetSubList(), SdrIterMode::DeepNoGroups); + maRectangles.reserve(aIter.Count()); + + while(aIter.IsMore()) + { + SdrObject* pObj = aIter.Next(); + + if(pObj) + { + maRectangles.push_back(pObj->GetLastBoundRect()); + } + } + } + else + { + maRectangles.push_back(rObj.GetLastBoundRect()); + } + } + + + void ScaleItemSet(SfxItemSet& rSet, const Fraction& rScale) + { + sal_Int32 nMul(rScale.GetNumerator()); + sal_Int32 nDiv(rScale.GetDenominator()); + + if(!rScale.IsValid() || !nDiv) + { + return; + } + + SfxWhichIter aIter(rSet); + sal_uInt16 nWhich(aIter.FirstWhich()); + const SfxPoolItem *pItem = nullptr; + + while(nWhich) + { + if(SfxItemState::SET == rSet.GetItemState(nWhich, false, &pItem)) + { + if(pItem->HasMetrics()) + { + std::unique_ptr<SfxPoolItem> pNewItem(pItem->Clone()); + pNewItem->ScaleMetrics(nMul, nDiv); + rSet.Put(std::move(pNewItem)); + } + } + nWhich = aIter.NextWhich(); + } + } +} // end of namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sdr/properties/measureproperties.cxx b/svx/source/sdr/properties/measureproperties.cxx new file mode 100644 index 000000000..5519930e3 --- /dev/null +++ b/svx/source/sdr/properties/measureproperties.cxx @@ -0,0 +1,128 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <sal/config.h> + +#include <sdr/properties/measureproperties.hxx> +#include <svl/itemset.hxx> +#include <svl/style.hxx> +#include <svx/svddef.hxx> +#include <editeng/eeitem.hxx> +#include <svx/svdomeas.hxx> +#include <svx/xlineit0.hxx> +#include <svx/xlnstit.hxx> +#include <svx/xlnstwit.hxx> +#include <svx/xlnedit.hxx> +#include <svx/xlnedwit.hxx> +#include <svx/sdynitm.hxx> +#include <basegfx/point/b2dpoint.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> + + +namespace sdr::properties +{ + // create a new itemset + std::unique_ptr<SfxItemSet> MeasureProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool) + { + return std::make_unique<SfxItemSet>( + rPool, + svl::Items< + // Ranges from SdrAttrObj, SdrMeasureObj: + SDRATTR_START, SDRATTR_SHADOW_LAST, + SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST, + SDRATTR_MEASURE_FIRST, SDRATTR_MEASURE_LAST, + SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION, + // Range from SdrTextObj: + EE_ITEMS_START, EE_ITEMS_END>{}); + } + + MeasureProperties::MeasureProperties(SdrObject& rObj) + : TextProperties(rObj) + { + } + + MeasureProperties::MeasureProperties(const MeasureProperties& rProps, SdrObject& rObj) + : TextProperties(rProps, rObj) + { + } + + MeasureProperties::~MeasureProperties() + { + } + + std::unique_ptr<BaseProperties> MeasureProperties::Clone(SdrObject& rObj) const + { + return std::unique_ptr<BaseProperties>(new MeasureProperties(*this, rObj)); + } + + void MeasureProperties::ItemSetChanged(const SfxItemSet& rSet) + { + SdrMeasureObj& rObj = static_cast<SdrMeasureObj&>(GetSdrObject()); + + // call parent + TextProperties::ItemSetChanged(rSet); + + // local changes + rObj.SetTextDirty(); + } + + void MeasureProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr) + { + // call parent (always first thing to do, may create the SfxItemSet) + TextProperties::SetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr); + + // local changes + // get access to dimension line object + SdrMeasureObj& rObj = static_cast<SdrMeasureObj&>(GetSdrObject()); + + // mark dimension line text as changed (dirty) in the dimension line object + rObj.SetTextDirty(); + + // tdf#98525 ask the dimension line object to redraw the changed text + rObj.UndirtyText(); + } + + void MeasureProperties::ForceDefaultAttributes() + { + // call parent + TextProperties::ForceDefaultAttributes(); + + // force ItemSet + GetObjectItemSet(); + + //#71958# by default, the show units Bool-Item is set as hard + // attribute to sal_True to avoid confusion when copying SdrMeasureObj's + // from one application to another + mpItemSet->Put(SdrYesNoItem(SDRATTR_MEASURESHOWUNIT, true)); + + basegfx::B2DPolygon aNewPolygon; + aNewPolygon.append(basegfx::B2DPoint(100.0, 0.0)); + aNewPolygon.append(basegfx::B2DPoint(200.0, 400.0)); + aNewPolygon.append(basegfx::B2DPoint(0.0, 400.0)); + aNewPolygon.setClosed(true); + + mpItemSet->Put(XLineStartItem(OUString(), basegfx::B2DPolyPolygon(aNewPolygon))); + mpItemSet->Put(XLineStartWidthItem(200)); + mpItemSet->Put(XLineEndItem(OUString(), basegfx::B2DPolyPolygon(aNewPolygon))); + mpItemSet->Put(XLineEndWidthItem(200)); + mpItemSet->Put(XLineStyleItem(css::drawing::LineStyle_SOLID)); + } +} // end of namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sdr/properties/oleproperties.cxx b/svx/source/sdr/properties/oleproperties.cxx new file mode 100644 index 000000000..2cdb55b70 --- /dev/null +++ b/svx/source/sdr/properties/oleproperties.cxx @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <sdr/properties/oleproperties.hxx> +#include <svx/xfillit0.hxx> +#include <svx/xlineit0.hxx> +#include <svx/svdobj.hxx> +#include <svx/svdmodel.hxx> + +namespace sdr::properties +{ + void OleProperties::applyDefaultStyleSheetFromSdrModel() + { + SfxStyleSheet* pStyleSheet(GetSdrObject().getSdrModelFromSdrObject().GetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj()); + + if(pStyleSheet) + { + // do not delete hard attributes when setting dsefault Style + SetStyleSheet(pStyleSheet, true); + } + else + { + SetMergedItem(XFillStyleItem(com::sun::star::drawing::FillStyle_NONE)); + SetMergedItem(XLineStyleItem(com::sun::star::drawing::LineStyle_NONE)); + } + } + + OleProperties::OleProperties(SdrObject& rObj) + : RectangleProperties(rObj) + { + } + + OleProperties::OleProperties(const OleProperties& rProps, SdrObject& rObj) + : RectangleProperties(rProps, rObj) + { + } + + OleProperties::~OleProperties() + { + } + + std::unique_ptr<BaseProperties> OleProperties::Clone(SdrObject& rObj) const + { + return std::unique_ptr<BaseProperties>(new OleProperties(*this, rObj)); + } + + void OleProperties::ForceDefaultAttributes() + { + // call parent + RectangleProperties::ForceDefaultAttributes(); + + // force ItemSet + GetObjectItemSet(); + } +} // end of namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sdr/properties/pageproperties.cxx b/svx/source/sdr/properties/pageproperties.cxx new file mode 100644 index 000000000..feca40ac7 --- /dev/null +++ b/svx/source/sdr/properties/pageproperties.cxx @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <sal/config.h> + +#include <sdr/properties/pageproperties.hxx> +#include <svl/itemset.hxx> +#include <svx/svdobj.hxx> +#include <svx/xdef.hxx> +#include <tools/debug.hxx> + + +namespace sdr::properties +{ + // create a new itemset + std::unique_ptr<SfxItemSet> PageProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool) + { + // override to legally return a valid ItemSet + return std::make_unique<SfxItemSet>(rPool); + } + + PageProperties::PageProperties(SdrObject& rObj) + : EmptyProperties(rObj) + { + } + + PageProperties::PageProperties(const PageProperties& /*rProps*/, SdrObject& rObj) + : EmptyProperties(rObj) + { + } + + PageProperties::~PageProperties() + { + } + + std::unique_ptr<BaseProperties> PageProperties::Clone(SdrObject& rObj) const + { + return std::unique_ptr<BaseProperties>(new PageProperties(*this, rObj)); + } + + // get itemset. Override here to allow creating the empty itemset + // without asserting + const SfxItemSet& PageProperties::GetObjectItemSet() const + { + if(!mpEmptyItemSet) + { + const_cast<PageProperties*>(this)->mpEmptyItemSet = const_cast<PageProperties*>(this)->CreateObjectSpecificItemSet(GetSdrObject().GetObjectItemPool()); + } + + DBG_ASSERT(mpEmptyItemSet, "Could not create an SfxItemSet(!)"); + + return *mpEmptyItemSet; + } + + void PageProperties::ItemChange(const sal_uInt16 /*nWhich*/, const SfxPoolItem* /*pNewItem*/) + { + // #86481# simply ignore item setting on page objects + } + + SfxStyleSheet* PageProperties::GetStyleSheet() const + { + // override to legally return a 0L pointer here + return nullptr; + } + + void PageProperties::SetStyleSheet(SfxStyleSheet* /*pStyleSheet*/, bool /*bDontRemoveHardAttr*/) + { + // override to legally ignore the StyleSheet here + } + + void PageProperties::PostItemChange(const sal_uInt16 nWhich ) + { + if( (nWhich == XATTR_FILLSTYLE) && (mpEmptyItemSet != nullptr) ) + CleanupFillProperties(*mpEmptyItemSet); + } + + void PageProperties::ClearObjectItem(const sal_uInt16 /*nWhich*/) + { + // simply ignore item clearing on page objects + } +} // end of namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sdr/properties/properties.cxx b/svx/source/sdr/properties/properties.cxx new file mode 100644 index 000000000..baf3a48d3 --- /dev/null +++ b/svx/source/sdr/properties/properties.cxx @@ -0,0 +1,192 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <libxml/xmlwriter.h> + +#include <svx/sdr/properties/properties.hxx> +#include <sdr/properties/itemsettools.hxx> +#include <svl/itemset.hxx> +#include <svx/svdogrp.hxx> +#include <svx/svditer.hxx> +#include <svx/xdef.hxx> +#include <svx/xfillit0.hxx> +#include <svx/svdmodel.hxx> + +using namespace com::sun::star; + +namespace sdr::properties +{ + BaseProperties::BaseProperties(SdrObject& rObj) + : mrObject(rObj) + { + } + + BaseProperties::~BaseProperties() + { + } + + void BaseProperties::applyDefaultStyleSheetFromSdrModel() + { + SfxStyleSheet* pDefaultStyleSheet(GetSdrObject().getSdrModelFromSdrObject().GetDefaultStyleSheet()); + + // tdf#118139 Only do this when StyleSheet really differs. It may e.g. + // be the case that nullptr == pDefaultStyleSheet and there is none set yet, + // so indeed no need to set it (needed for some strange old MSWord2003 + // documents with CustomShape-'Group' and added Text-Frames, see task description) + if(pDefaultStyleSheet != GetStyleSheet()) + { + // do not delete hard attributes when setting dsefault Style + SetStyleSheet(pDefaultStyleSheet, true); + } + } + + const SdrObject& BaseProperties::GetSdrObject() const + { + return mrObject; + } + + SdrObject& BaseProperties::GetSdrObject() + { + return mrObject; + } + + const SfxItemSet& BaseProperties::GetMergedItemSet() const + { + // default implementation falls back to GetObjectItemSet() + return GetObjectItemSet(); + } + + void BaseProperties::SetMergedItemSet(const SfxItemSet& rSet, bool bClearAllItems) + { + // clear items if requested + if(bClearAllItems) + { + ClearObjectItem(); + } + + // default implementation falls back to SetObjectItemSet() + SetObjectItemSet(rSet); + } + + void BaseProperties::SetMergedItem(const SfxPoolItem& rItem) + { + // default implementation falls back to SetObjectItem() + SetObjectItem(rItem); + } + + void BaseProperties::ClearMergedItem(const sal_uInt16 nWhich) + { + // default implementation falls back to ClearObjectItem() + ClearObjectItem(nWhich); + } + + void BaseProperties::ForceStyleToHardAttributes() + { + // force all attributes which come from styles to hard attributes + // to be able to live without the style. Default implementation does nothing. + // Override where an ItemSet is implemented. + } + + void BaseProperties::SetMergedItemSetAndBroadcast(const SfxItemSet& rSet, bool bClearAllItems) + { + ItemChangeBroadcaster aC(GetSdrObject()); + + if(bClearAllItems) + { + ClearObjectItem(); + } + + SetMergedItemSet(rSet); + BroadcastItemChange(aC); + } + + const SfxPoolItem& BaseProperties::GetItem(const sal_uInt16 nWhich) const + { + return GetObjectItemSet().Get(nWhich); + } + + void BaseProperties::BroadcastItemChange(const ItemChangeBroadcaster& rChange) + { + const sal_uInt32 nCount(rChange.GetRectangleCount()); + + // invalidate all new rectangles + if(dynamic_cast<const SdrObjGroup*>( &GetSdrObject() ) != nullptr) + { + SdrObjListIter aIter(static_cast<SdrObjGroup&>(GetSdrObject()), SdrIterMode::DeepNoGroups); + + while(aIter.IsMore()) + { + SdrObject* pObj = aIter.Next(); + pObj->BroadcastObjectChange(); + } + } + else + { + GetSdrObject().BroadcastObjectChange(); + } + + // also send the user calls + for(sal_uInt32 a(0); a < nCount; a++) + { + GetSdrObject().SendUserCall(SdrUserCallType::ChangeAttr, rChange.GetRectangle(a)); + } + } + + sal_uInt32 BaseProperties::getVersion() const + { + return 0; + } + + void BaseProperties::dumpAsXml(xmlTextWriterPtr pWriter) const + { + xmlTextWriterStartElement(pWriter, BAD_CAST("BaseProperties")); + xmlTextWriterEndElement(pWriter); + } + + void CleanupFillProperties( SfxItemSet& rItemSet ) + { + const bool bFillBitmap = rItemSet.GetItemState(XATTR_FILLBITMAP, false) == SfxItemState::SET; + const bool bFillGradient = rItemSet.GetItemState(XATTR_FILLGRADIENT, false) == SfxItemState::SET; + const bool bFillHatch = rItemSet.GetItemState(XATTR_FILLHATCH, false) == SfxItemState::SET; + if( bFillBitmap || bFillGradient || bFillHatch ) + { + const XFillStyleItem* pFillStyleItem = rItemSet.GetItem(XATTR_FILLSTYLE); + if( pFillStyleItem ) + { + if( bFillBitmap && (pFillStyleItem->GetValue() != drawing::FillStyle_BITMAP) ) + { + rItemSet.ClearItem( XATTR_FILLBITMAP ); + } + + if( bFillGradient && (pFillStyleItem->GetValue() != drawing::FillStyle_GRADIENT) ) + { + rItemSet.ClearItem( XATTR_FILLGRADIENT ); + } + + if( bFillHatch && (pFillStyleItem->GetValue() != drawing::FillStyle_HATCH) ) + { + rItemSet.ClearItem( XATTR_FILLHATCH ); + } + } + } + } + +} // end of namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sdr/properties/rectangleproperties.cxx b/svx/source/sdr/properties/rectangleproperties.cxx new file mode 100644 index 000000000..84b4fc17e --- /dev/null +++ b/svx/source/sdr/properties/rectangleproperties.cxx @@ -0,0 +1,68 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <sdr/properties/rectangleproperties.hxx> +#include <svx/svdorect.hxx> + + +namespace sdr::properties +{ + RectangleProperties::RectangleProperties(SdrObject& rObj) + : TextProperties(rObj) + { + } + + RectangleProperties::RectangleProperties(const RectangleProperties& rProps, SdrObject& rObj) + : TextProperties(rProps, rObj) + { + } + + RectangleProperties::~RectangleProperties() + { + } + + std::unique_ptr<BaseProperties> RectangleProperties::Clone(SdrObject& rObj) const + { + return std::unique_ptr<BaseProperties>(new RectangleProperties(*this, rObj)); + } + + void RectangleProperties::ItemSetChanged(const SfxItemSet& rSet) + { + SdrRectObj& rObj = static_cast<SdrRectObj&>(GetSdrObject()); + + // call parent + TextProperties::ItemSetChanged(rSet); + + // local changes + rObj.SetXPolyDirty(); + } + + // set a new StyleSheet and broadcast + void RectangleProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr) + { + // call parent (always first thing to do, may create the SfxItemSet) + TextProperties::SetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr); + + // local changes + SdrRectObj& rObj = static_cast<SdrRectObj&>(GetSdrObject()); + rObj.SetXPolyDirty(); + } +} // end of namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sdr/properties/textproperties.cxx b/svx/source/sdr/properties/textproperties.cxx new file mode 100644 index 000000000..e2cedd10f --- /dev/null +++ b/svx/source/sdr/properties/textproperties.cxx @@ -0,0 +1,611 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <sal/config.h> + +#include <sdr/properties/textproperties.hxx> +#include <svl/itemset.hxx> +#include <svl/style.hxx> +#include <svl/itemiter.hxx> +#include <svl/hint.hxx> +#include <svx/svddef.hxx> +#include <svx/svdotext.hxx> +#include <svx/svdoutl.hxx> +#include <svx/sdmetitm.hxx> +#include <svx/sdtditm.hxx> +#include <editeng/writingmodeitem.hxx> +#include <svx/svdmodel.hxx> +#include <editeng/eeitem.hxx> +#include <editeng/outlobj.hxx> +#include <svx/xfillit0.hxx> +#include <svx/xflclit.hxx> +#include <editeng/adjustitem.hxx> +#include <svx/svdetc.hxx> +#include <editeng/editeng.hxx> +#include <editeng/flditem.hxx> +#include <svx/xlineit0.hxx> +#include <svx/xlnwtit.hxx> + +using namespace com::sun::star; + +namespace sdr::properties +{ + std::unique_ptr<SfxItemSet> TextProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool) + { + return std::make_unique<SfxItemSet>(rPool, + + // range from SdrAttrObj + svl::Items<SDRATTR_START, SDRATTR_SHADOW_LAST, + SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST, + SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION, + + // range from SdrTextObj + EE_ITEMS_START, EE_ITEMS_END>{}); + } + + TextProperties::TextProperties(SdrObject& rObj) + : AttributeProperties(rObj), + maVersion(0) + { + } + + TextProperties::TextProperties(const TextProperties& rProps, SdrObject& rObj) + : AttributeProperties(rProps, rObj), + maVersion(rProps.getVersion()) + { + } + + TextProperties::~TextProperties() + { + } + + std::unique_ptr<BaseProperties> TextProperties::Clone(SdrObject& rObj) const + { + return std::unique_ptr<BaseProperties>(new TextProperties(*this, rObj)); + } + + void TextProperties::ItemSetChanged(const SfxItemSet& rSet) + { + SdrTextObj& rObj = static_cast<SdrTextObj&>(GetSdrObject()); + + // #i101556# ItemSet has changed -> new version + maVersion++; + + const svx::ITextProvider& rTextProvider(getTextProvider()); + sal_Int32 nText = rTextProvider.getTextCount(); + while (nText--) + { + SdrText* pText = rTextProvider.getText( nText ); + + OutlinerParaObject* pParaObj = pText ? pText->GetOutlinerParaObject() : nullptr; + + if(pParaObj) + { + const bool bTextEdit = rObj.IsTextEditActive() && (rObj.getActiveText() == pText); + + // handle outliner attributes + GetObjectItemSet(); + Outliner* pOutliner = rObj.GetTextEditOutliner(); + + if(!bTextEdit) + { + pOutliner = &rObj.ImpGetDrawOutliner(); + pOutliner->SetText(*pParaObj); + } + + sal_Int32 nParaCount(pOutliner->GetParagraphCount()); + + for(sal_Int32 nPara = 0; nPara < nParaCount; nPara++) + { + SfxItemSet aSet(pOutliner->GetParaAttribs(nPara)); + aSet.Put(rSet); + pOutliner->SetParaAttribs(nPara, aSet); + } + + if(!bTextEdit) + { + if(nParaCount) + { + // force ItemSet + GetObjectItemSet(); + + SfxItemSet aNewSet(pOutliner->GetParaAttribs(0)); + mpItemSet->Put(aNewSet); + } + + std::unique_ptr<OutlinerParaObject> pTemp = pOutliner->CreateParaObject(0, nParaCount); + pOutliner->Clear(); + + rObj.NbcSetOutlinerParaObjectForText(std::move(pTemp),pText); + } + } + } + + // Extra-Repaint for radical layout changes (#43139#) + if(SfxItemState::SET == rSet.GetItemState(SDRATTR_TEXT_CONTOURFRAME)) + { + // Here only repaint wanted + rObj.ActionChanged(); + //rObj.BroadcastObjectChange(); + } + + // call parent + AttributeProperties::ItemSetChanged(rSet); + } + + void TextProperties::ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem) + { + SdrTextObj& rObj = static_cast<SdrTextObj&>(GetSdrObject()); + + // #i25616# + sal_Int32 nOldLineWidth(0); + + if(XATTR_LINEWIDTH == nWhich && rObj.DoesSupportTextIndentingOnLineWidthChange()) + { + nOldLineWidth = GetItem(XATTR_LINEWIDTH).GetValue(); + } + + if(pNewItem && (SDRATTR_TEXTDIRECTION == nWhich)) + { + bool bVertical(css::text::WritingMode_TB_RL == static_cast<const SvxWritingModeItem*>(pNewItem)->GetValue()); + rObj.SetVerticalWriting(bVertical); + } + + // #95501# reset to default + if(!pNewItem && !nWhich && rObj.HasText() ) + { + SdrOutliner& rOutliner = rObj.ImpGetDrawOutliner(); + + const svx::ITextProvider& rTextProvider(getTextProvider()); + sal_Int32 nCount = rTextProvider.getTextCount(); + while (nCount--) + { + SdrText* pText = rTextProvider.getText( nCount ); + OutlinerParaObject* pParaObj = pText->GetOutlinerParaObject(); + if( pParaObj ) + { + rOutliner.SetText(*pParaObj); + sal_Int32 nParaCount(rOutliner.GetParagraphCount()); + + if(nParaCount) + { + ESelection aSelection( 0, 0, EE_PARA_ALL, EE_TEXTPOS_ALL); + rOutliner.RemoveAttribs(aSelection, true, 0); + + std::unique_ptr<OutlinerParaObject> pTemp = rOutliner.CreateParaObject(0, nParaCount); + rOutliner.Clear(); + + rObj.NbcSetOutlinerParaObjectForText( std::move(pTemp), pText ); + } + } + } + } + + // call parent + AttributeProperties::ItemChange( nWhich, pNewItem ); + + // #i25616# + if(XATTR_LINEWIDTH == nWhich && rObj.DoesSupportTextIndentingOnLineWidthChange()) + { + const sal_Int32 nNewLineWidth(GetItem(XATTR_LINEWIDTH).GetValue()); + const sal_Int32 nDifference((nNewLineWidth - nOldLineWidth) / 2); + + if(nDifference) + { + const bool bLineVisible(drawing::LineStyle_NONE != GetItem(XATTR_LINESTYLE).GetValue()); + + if(bLineVisible) + { + const sal_Int32 nLeftDist(GetItem(SDRATTR_TEXT_LEFTDIST).GetValue()); + const sal_Int32 nRightDist(GetItem(SDRATTR_TEXT_RIGHTDIST).GetValue()); + const sal_Int32 nUpperDist(GetItem(SDRATTR_TEXT_UPPERDIST).GetValue()); + const sal_Int32 nLowerDist(GetItem(SDRATTR_TEXT_LOWERDIST).GetValue()); + + SetObjectItemDirect(makeSdrTextLeftDistItem(nLeftDist + nDifference)); + SetObjectItemDirect(makeSdrTextRightDistItem(nRightDist + nDifference)); + SetObjectItemDirect(makeSdrTextUpperDistItem(nUpperDist + nDifference)); + SetObjectItemDirect(makeSdrTextLowerDistItem(nLowerDist + nDifference)); + } + } + } + } + + const svx::ITextProvider& TextProperties::getTextProvider() const + { + return static_cast<const SdrTextObj&>(GetSdrObject()); + } + + void TextProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr) + { + // call parent (always first thing to do, may create the SfxItemSet) + AttributeProperties::SetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr); + + // #i101556# StyleSheet has changed -> new version + SdrTextObj& rObj = static_cast<SdrTextObj&>(GetSdrObject()); + maVersion++; + + if(!rObj.IsLinkedText() ) + { + SdrOutliner& rOutliner = rObj.ImpGetDrawOutliner(); + + const svx::ITextProvider& rTextProvider(getTextProvider()); + sal_Int32 nText = rTextProvider.getTextCount(); + while (nText--) + { + SdrText* pText = rTextProvider.getText( nText ); + + OutlinerParaObject* pParaObj = pText ? pText->GetOutlinerParaObject() : nullptr; + if( !pParaObj ) + continue; + + // apply StyleSheet to all paragraphs + rOutliner.SetText(*pParaObj); + sal_Int32 nParaCount(rOutliner.GetParagraphCount()); + + if(nParaCount) + { + for(sal_Int32 nPara = 0; nPara < nParaCount; nPara++) + { + std::unique_ptr<SfxItemSet> pTempSet; + + // since setting the stylesheet removes all para attributes + if(bDontRemoveHardAttr) + { + // we need to remember them if we want to keep them + pTempSet.reset(new SfxItemSet(rOutliner.GetParaAttribs(nPara))); + } + + if(GetStyleSheet()) + { + if((OBJ_OUTLINETEXT == rObj.GetTextKind()) && (SdrInventor::Default == rObj.GetObjInventor())) + { + OUString aNewStyleSheetName(GetStyleSheet()->GetName()); + aNewStyleSheetName = aNewStyleSheetName.copy(0, aNewStyleSheetName.getLength() - 1); + sal_Int16 nDepth = rOutliner.GetDepth(nPara); + aNewStyleSheetName += OUString::number( nDepth <= 0 ? 1 : nDepth + 1); + SfxStyleSheetBasePool* pStylePool(rObj.getSdrModelFromSdrObject().GetStyleSheetPool()); + SfxStyleSheet* pNewStyle = nullptr; + if(pStylePool) + pNewStyle = static_cast<SfxStyleSheet*>(pStylePool->Find(aNewStyleSheetName, GetStyleSheet()->GetFamily())); + DBG_ASSERT( pNewStyle, "AutoStyleSheetName - Style not found!" ); + + if(pNewStyle) + { + rOutliner.SetStyleSheet(nPara, pNewStyle); + } + } + else + { + rOutliner.SetStyleSheet(nPara, GetStyleSheet()); + } + } + else + { + // remove StyleSheet + rOutliner.SetStyleSheet(nPara, nullptr); + } + + if(bDontRemoveHardAttr) + { + if(pTempSet) + { + // restore para attributes + rOutliner.SetParaAttribs(nPara, *pTempSet); + } + } + else + { + if(pNewStyleSheet) + { + // remove all hard paragraph attributes + // which occur in StyleSheet, take care of + // parents (!) + SfxItemIter aIter(pNewStyleSheet->GetItemSet()); + + for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; + pItem = aIter.NextItem()) + { + if(!IsInvalidItem(pItem)) + { + sal_uInt16 nW(pItem->Which()); + + if(nW >= EE_ITEMS_START && nW <= EE_ITEMS_END) + { + rOutliner.RemoveCharAttribs(nPara, nW); + } + } + } + } + } + } + + std::unique_ptr<OutlinerParaObject> pTemp = rOutliner.CreateParaObject(0, nParaCount); + rOutliner.Clear(); + rObj.NbcSetOutlinerParaObjectForText(std::move(pTemp), pText); + } + } + } + + if(rObj.IsTextFrame()) + { + rObj.NbcAdjustTextFrameWidthAndHeight(); + } + } + + void TextProperties::ForceDefaultAttributes() + { + SdrTextObj& rObj = static_cast<SdrTextObj&>(GetSdrObject()); + + if( rObj.GetObjInventor() == SdrInventor::Default ) + { + const sal_uInt16 nSdrObjKind = rObj.GetObjIdentifier(); + + if( nSdrObjKind == OBJ_TITLETEXT || nSdrObjKind == OBJ_OUTLINETEXT ) + return; // no defaults for presentation objects + } + + bool bTextFrame(rObj.IsTextFrame()); + + // force ItemSet + GetObjectItemSet(); + + if(bTextFrame) + { + mpItemSet->Put(XLineStyleItem(drawing::LineStyle_NONE)); + mpItemSet->Put(XFillColorItem(OUString(), COL_WHITE)); + mpItemSet->Put(XFillStyleItem(drawing::FillStyle_NONE)); + } + else + { + mpItemSet->Put(SvxAdjustItem(SvxAdjust::Center, EE_PARA_JUST)); + mpItemSet->Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_CENTER)); + mpItemSet->Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_CENTER)); + } + } + + void TextProperties::ForceStyleToHardAttributes() + { + // #i61284# call parent first to get the hard ObjectItemSet + AttributeProperties::ForceStyleToHardAttributes(); + + // #i61284# push hard ObjectItemSet to OutlinerParaObject attributes + // using existing functionality + GetObjectItemSet(); // force ItemSet + ItemSetChanged(*mpItemSet); + + // now the standard TextProperties stuff + SdrTextObj& rObj = static_cast<SdrTextObj&>(GetSdrObject()); + + if(!rObj.IsTextEditActive() && !rObj.IsLinkedText()) + { + std::unique_ptr<Outliner> pOutliner = SdrMakeOutliner(OutlinerMode::OutlineObject, rObj.getSdrModelFromSdrObject()); + const svx::ITextProvider& rTextProvider(getTextProvider()); + sal_Int32 nText = rTextProvider.getTextCount(); + while (nText--) + { + SdrText* pText = rTextProvider.getText( nText ); + + OutlinerParaObject* pParaObj = pText ? pText->GetOutlinerParaObject() : nullptr; + if( !pParaObj ) + continue; + + pOutliner->SetText(*pParaObj); + + sal_Int32 nParaCount(pOutliner->GetParagraphCount()); + + if(nParaCount) + { + bool bBurnIn(false); + + for(sal_Int32 nPara = 0; nPara < nParaCount; nPara++) + { + SfxStyleSheet* pSheet = pOutliner->GetStyleSheet(nPara); + + if(pSheet) + { + SfxItemSet aParaSet(pOutliner->GetParaAttribs(nPara)); + SfxItemSet aSet(*aParaSet.GetPool()); + aSet.Put(pSheet->GetItemSet()); + + /** the next code handles a special case for paragraphs that contain a + url field. The color for URL fields is either the system color for + urls or the char color attribute that formats the portion in which the + url field is contained. + When we set a char color attribute to the paragraphs item set from the + styles item set, we would have this char color attribute as an attribute + that is spanned over the complete paragraph after xml import due to some + problems in the xml import (using a XCursor on import so it does not know + the paragraphs and can't set char attributes to paragraphs ). + + To avoid this, as soon as we try to set a char color attribute from the style + we + 1. check if we have at least one url field in this paragraph + 2. if we found at least one url field, we span the char color attribute over + all portions that are not url fields and remove the char color attribute + from the paragraphs item set + */ + + bool bHasURL(false); + + if(aSet.GetItemState(EE_CHAR_COLOR) == SfxItemState::SET) + { + EditEngine* pEditEngine = const_cast<EditEngine*>(&(pOutliner->GetEditEngine())); + std::vector<EECharAttrib> aAttribs; + pEditEngine->GetCharAttribs(nPara, aAttribs); + + for(const auto& rAttrib : aAttribs) + { + if(rAttrib.pAttr && EE_FEATURE_FIELD == rAttrib.pAttr->Which()) + { + const SvxFieldItem* pFieldItem = static_cast<const SvxFieldItem*>(rAttrib.pAttr); + + if(pFieldItem) + { + const SvxFieldData* pData = pFieldItem->GetField(); + + if(dynamic_cast<const SvxURLField*>( pData)) + { + bHasURL = true; + break; + } + } + } + } + + if(bHasURL) + { + SfxItemSet aColorSet(*aSet.GetPool(), svl::Items<EE_CHAR_COLOR, EE_CHAR_COLOR>{} ); + aColorSet.Put(aSet, false); + + ESelection aSel(nPara, 0); + + for(const auto& rAttrib : aAttribs) + { + if(EE_FEATURE_FIELD == rAttrib.pAttr->Which()) + { + aSel.nEndPos = rAttrib.nStart; + + if(aSel.nStartPos != aSel.nEndPos) + pEditEngine->QuickSetAttribs(aColorSet, aSel); + + aSel.nStartPos = rAttrib.nEnd; + } + } + + aSel.nEndPos = pEditEngine->GetTextLen(nPara); + + if(aSel.nStartPos != aSel.nEndPos) + { + pEditEngine->QuickSetAttribs( aColorSet, aSel ); + } + } + + } + + aSet.Put(aParaSet, false); + + if(bHasURL) + { + aSet.ClearItem(EE_CHAR_COLOR); + } + + pOutliner->SetParaAttribs(nPara, aSet); + bBurnIn = true; // #i51163# Flag was set wrong + } + } + + if(bBurnIn) + { + std::unique_ptr<OutlinerParaObject> pTemp = pOutliner->CreateParaObject(0, nParaCount); + rObj.NbcSetOutlinerParaObjectForText(std::move(pTemp),pText); + } + } + + pOutliner->Clear(); + } + } + } + + void TextProperties::SetObjectItemNoBroadcast(const SfxPoolItem& rItem) + { + GetObjectItemSet(); + mpItemSet->Put(rItem); + } + + + void TextProperties::Notify(SfxBroadcaster& rBC, const SfxHint& rHint) + { + // call parent + AttributeProperties::Notify(rBC, rHint); + + SdrTextObj& rObj = static_cast<SdrTextObj&>(GetSdrObject()); + if(rObj.HasText()) + { + const svx::ITextProvider& rTextProvider(getTextProvider()); + if(dynamic_cast<const SfxStyleSheet *>(&rBC) != nullptr) + { + SfxHintId nId(rHint.GetId()); + + if(SfxHintId::DataChanged == nId) + { + sal_Int32 nText = rTextProvider.getTextCount(); + while (nText--) + { + OutlinerParaObject* pParaObj = rTextProvider.getText( nText )->GetOutlinerParaObject(); + if( pParaObj ) + pParaObj->ClearPortionInfo(); + } + rObj.SetTextSizeDirty(); + + if(rObj.IsTextFrame() && rObj.NbcAdjustTextFrameWidthAndHeight()) + { + // here only repaint wanted + rObj.ActionChanged(); + //rObj.BroadcastObjectChange(); + } + + // #i101556# content of StyleSheet has changed -> new version + maVersion++; + } + + if(SfxHintId::Dying == nId) + { + sal_Int32 nText = rTextProvider.getTextCount(); + while (nText--) + { + OutlinerParaObject* pParaObj = rTextProvider.getText( nText )->GetOutlinerParaObject(); + if( pParaObj ) + pParaObj->ClearPortionInfo(); + } + } + } + else if(dynamic_cast<const SfxStyleSheetBasePool *>(&rBC) != nullptr) + { + const SfxStyleSheetModifiedHint* pExtendedHint = dynamic_cast<const SfxStyleSheetModifiedHint*>(&rHint); + + if(pExtendedHint + && SfxHintId::StyleSheetModified == pExtendedHint->GetId()) + { + const OUString& aOldName(pExtendedHint->GetOldName()); + OUString aNewName(pExtendedHint->GetStyleSheet()->GetName()); + SfxStyleFamily eFamily = pExtendedHint->GetStyleSheet()->GetFamily(); + + if(aOldName != aNewName) + { + sal_Int32 nText = rTextProvider.getTextCount(); + while (nText--) + { + OutlinerParaObject* pParaObj = rTextProvider.getText( nText )->GetOutlinerParaObject(); + if( pParaObj ) + pParaObj->ChangeStyleSheetName(eFamily, aOldName, aNewName); + } + } + } + } + } + } + + // #i101556# Handout version information + sal_uInt32 TextProperties::getVersion() const + { + return maVersion; + } +} // end of namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |