From 39a94b9b25ff886ff058e333cb24687cfb4442f1 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 14 Dec 2020 12:15:09 +0100 Subject: [PATCH] bsc1178943.diff This is a combination of 3 commits. This is the 1st commit message: tdf#129961 cui: start UI for table shadow as direct format It reads from the doc model and shows it, but doesn't write it back yet. (cherry picked from commit 74ba28fe238b7f15d1fb7d119e4cef3a7b544e0b) This is the commit message #2: tdf#129961 svx: finish UI for table shadow as direct format Normally properties on an SdrObject is set using SetAttributes(), but that would take the selection controller into account, so we would call SvxTableController::SetAttributes(), which sets the item set on the selected cells instead. So use SetAttrToMarked() instead, which works on the shape's item set, even in the table case. Don't replace all existing items because we only have shadow properties here and also a disabled shadow is still a (set) SdrOnOffItem (with value=false), so no old SdrOnOffItem will be forgotten in the shape's item set. Also add an outer undo grouping, so once the user presses OK in the table properties dialog, we only create a single user-visible undo action, not two. (cherry picked from commit fdeb04f7c59cf8032fe17072ed779e70505cc6ab) Conflicts: svx/source/table/tablecontroller.cxx This is the commit message #3: tdf#129961 oox: add PPTX export for table shadow as direct format Custom shapes export shadow as part of WriteShapeEffects(), so use the same for table shapes as well. This needs fixing the effect export up a bit, because table shapes have no interop grab-bag, glow or soft edge properties, but the rest of the code can be shared. (cherry picked from commit 252cdd5f43d65095543e317d37e1a0ea4fd839e0) Conflicts: oox/qa/unit/drawingml.cxx Change-Id: Icf0b90c5b44e3d9c4115c9f3b0d56ba0852ab640 --- cui/source/dialogs/sdrcelldlg.cxx | 7 ++++ cui/source/inc/sdrcelldlg.hxx | 2 + cui/uiconfig/ui/formatcellsdialog.ui | 48 +++++++++++++++++++++++ include/svx/sdr/table/tablecontroller.hxx | 1 + oox/source/export/drawingml.cxx | 13 +++++- oox/source/export/shapes.cxx | 4 +- svx/source/table/tablecontroller.cxx | 45 ++++++++++++++++++++- 7 files changed, 117 insertions(+), 3 deletions(-) diff --git a/cui/source/dialogs/sdrcelldlg.cxx b/cui/source/dialogs/sdrcelldlg.cxx index 3c745692f7ea..fda8b4ce1385 100644 --- a/cui/source/dialogs/sdrcelldlg.cxx +++ b/cui/source/dialogs/sdrcelldlg.cxx @@ -27,6 +27,7 @@ SvxFormatCellsDialog::SvxFormatCellsDialog(weld::Window* pParent, const SfxItemS : SfxTabDialogController(pParent, "cui/ui/formatcellsdialog.ui", "FormatCellsDialog", pAttr) , mrOutAttrs(*pAttr) , mpColorTab(rModel.GetColorList()) + , mnColorTabState ( ChangeType::NONE ) , mpGradientList(rModel.GetGradientList()) , mpHatchingList(rModel.GetHatchList()) , mpBitmapList(rModel.GetBitmapList()) @@ -36,6 +37,7 @@ SvxFormatCellsDialog::SvxFormatCellsDialog(weld::Window* pParent, const SfxItemS AddTabPage("effects", RID_SVXPAGE_CHAR_EFFECTS); AddTabPage("border", RID_SVXPAGE_BORDER ); AddTabPage("area", RID_SVXPAGE_AREA); + AddTabPage("shadow", SvxShadowTabPage::Create, nullptr); } void SvxFormatCellsDialog::PageCreated(const OString& rId, SfxTabPage &rPage) @@ -55,6 +57,11 @@ void SvxFormatCellsDialog::PageCreated(const OString& rId, SfxTabPage &rPage) SvxBorderTabPage& rBorderPage = static_cast(rPage); rBorderPage.SetTableMode(); } + else if (rId == "shadow") + { + static_cast(rPage).SetColorList( mpColorTab ); + static_cast(rPage).SetColorChgd( &mnColorTabState ); + } else SfxTabDialogController::PageCreated(rId, rPage); } diff --git a/cui/source/inc/sdrcelldlg.hxx b/cui/source/inc/sdrcelldlg.hxx index 50ab4b39ac70..9f068d552393 100644 --- a/cui/source/inc/sdrcelldlg.hxx +++ b/cui/source/inc/sdrcelldlg.hxx @@ -23,6 +23,7 @@ #include #include +#include class SdrModel; class SvxFormatCellsDialog : public SfxTabDialogController @@ -31,6 +32,7 @@ private: const SfxItemSet& mrOutAttrs; XColorListRef mpColorTab; + ChangeType mnColorTabState; XGradientListRef mpGradientList; XHatchListRef mpHatchingList; XBitmapListRef mpBitmapList; diff --git a/cui/uiconfig/ui/formatcellsdialog.ui b/cui/uiconfig/ui/formatcellsdialog.ui index 82243f0bad10..49dfc705483c 100644 --- a/cui/uiconfig/ui/formatcellsdialog.ui +++ b/cui/uiconfig/ui/formatcellsdialog.ui @@ -281,6 +281,54 @@ False + + + + True + False + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 4 + + + + + True + False + Shadow + + + 5 + False + + False diff --git a/include/svx/sdr/table/tablecontroller.hxx b/include/svx/sdr/table/tablecontroller.hxx index f34499a05991..3d94dcfb08b7 100644 --- a/include/svx/sdr/table/tablecontroller.hxx +++ b/include/svx/sdr/table/tablecontroller.hxx @@ -85,6 +85,7 @@ public: SVX_DLLPRIVATE void MergeAttrFromSelectedCells(SfxItemSet& rAttr, bool bOnlyHardAttr) const; SVX_DLLPRIVATE void SetAttrToSelectedCells(const SfxItemSet& rAttr, bool bReplaceAll); + void SetAttrToSelectedShape(const SfxItemSet& rAttr); /** Fill the values that are common for all selected cells. * * This lets the Borders dialog to display the line arrangement diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index de2d34979471..177cb010d180 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -3773,7 +3773,8 @@ static sal_Int32 lcl_CalculateDir(const double dX, const double dY) void DrawingML::WriteShapeEffects( const Reference< XPropertySet >& rXPropSet ) { Sequence< PropertyValue > aGrabBag, aEffects, aOuterShdwProps; - if( GetProperty( rXPropSet, "InteropGrabBag" ) ) + bool bHasInteropGrabBag = rXPropSet->getPropertySetInfo()->hasPropertyByName("InteropGrabBag"); + if (bHasInteropGrabBag && GetProperty(rXPropSet, "InteropGrabBag")) { mAny >>= aGrabBag; auto pProp = std::find_if(std::cbegin(aGrabBag), std::cend(aGrabBag), @@ -3912,6 +3913,11 @@ void DrawingML::WriteShapeEffects( const Reference< XPropertySet >& rXPropSet ) void DrawingML::WriteGlowEffect(const Reference< XPropertySet >& rXPropSet) { + if (!rXPropSet->getPropertySetInfo()->hasPropertyByName("GlowEffectRadius")) + { + return; + } + sal_Int32 nRad = 0; rXPropSet->getPropertyValue("GlowEffectRadius") >>= nRad; if (!nRad) @@ -3934,6 +3940,11 @@ void DrawingML::WriteGlowEffect(const Reference< XPropertySet >& rXPropSet) void DrawingML::WriteSoftEdgeEffect(const css::uno::Reference& rXPropSet) { + if (!rXPropSet->getPropertySetInfo()->hasPropertyByName("SoftEdgeRadius")) + { + return; + } + sal_Int32 nRad = 0; rXPropSet->getPropertyValue("SoftEdgeRadius") >>= nRad; if (!nRad) diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx index 6828bc629152..255d7ea55b44 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -1609,7 +1609,9 @@ void ShapeExport::WriteTable( const Reference< XShape >& rXShape ) if ( xPropSet.is() && ( xPropSet->getPropertyValue( "Model" ) >>= xTable ) ) { mpFS->startElementNS(XML_a, XML_tbl); - mpFS->singleElementNS(XML_a, XML_tblPr); + mpFS->startElementNS(XML_a, XML_tblPr); + WriteShapeEffects(xPropSet); + mpFS->endElementNS(XML_a, XML_tblPr); Reference< container::XIndexAccess > xColumns( xTable->getColumns(), UNO_QUERY_THROW ); Reference< container::XIndexAccess > xRows( xTable->getRows(), UNO_QUERY_THROW ); diff --git a/svx/source/table/tablecontroller.cxx b/svx/source/table/tablecontroller.cxx index 9fa0c057565e..003cbd852b20 100644 --- a/svx/source/table/tablecontroller.cxx +++ b/svx/source/table/tablecontroller.cxx @@ -911,6 +911,18 @@ void SvxTableController::onFormatTable(const SfxRequest& rReq) aNewAttr.Put( aBoxItem ); aNewAttr.Put( aBoxInfoItem ); + // Fill in shadow properties. + const SfxItemSet& rTableItemSet = rTableObj.GetMergedItemSet(); + for (sal_uInt16 nWhich = SDRATTR_SHADOW_FIRST; nWhich <= SDRATTR_SHADOW_LAST; ++nWhich) + { + if (rTableItemSet.GetItemState(nWhich, false) != SfxItemState::SET) + { + continue; + } + + aNewAttr.Put(rTableItemSet.Get(nWhich)); + } + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); ScopedVclPtr xDlg( pFact->CreateSvxFormatCellsDialog( rReq.GetFrameWeld(), @@ -950,7 +962,26 @@ void SvxTableController::onFormatTable(const SfxRequest& rReq) if( aNewBoxItem.GetDistance( SvxBoxItemLine::BOTTOM ) != aBoxItem.GetDistance( SvxBoxItemLine::BOTTOM ) ) aNewSet.Put(makeSdrTextLowerDistItem( aNewBoxItem.GetDistance( SvxBoxItemLine::BOTTOM ) ) ); - SetAttrToSelectedCells(aNewSet, false); + if (checkTableObject() && mxTable.is()) + { + // Create a single undo action when applying the result of the dialog. + SdrTableObj& rTableObject(*mxTableObj); + SdrModel& rSdrModel(rTableObject.getSdrModelFromSdrObject()); + bool bUndo = rSdrModel.IsUndoEnabled(); + if (bUndo) + { + rSdrModel.BegUndo(SvxResId(STR_TABLE_NUMFORMAT)); + } + + SetAttrToSelectedCells(aNewSet, false); + + SetAttrToSelectedShape(aNewSet); + + if (bUndo) + { + rSdrModel.EndUndo(); + } + } } } } @@ -2664,6 +2695,18 @@ void SvxTableController::SetAttrToSelectedCells(const SfxItemSet& rAttr, bool bR rModel.EndUndo(); } +void SvxTableController::SetAttrToSelectedShape(const SfxItemSet& rAttr) +{ + if (!checkTableObject() || !mxTable.is()) + return; + + // Filter out non-shadow items from rAttr. + SfxItemSet aSet(*rAttr.GetPool(), svl::Items{}); + aSet.Put(rAttr); + + // Set shadow items on the marked shape. + mrView.SetAttrToMarked(aSet, /*bReplaceAll=*/false); +} bool SvxTableController::GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr) const { -- 2.26.2