File bsc1178943.diff of Package libreoffice
From f261ab4ce9434c3b75472bbab4fa4e0805376123 Mon Sep 17 00:00:00 2001
From: Miklos Vajna <vmiklos@collabora.com>
Date: Mon, 14 Dec 2020 12:15:09 +0100
Subject: [PATCH 2/2] 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
oox/source/export/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 | 3 +-
oox/source/export/shapes.cxx | 4 +-
svx/source/table/tablecontroller.cxx | 45 ++++++++++++++++++++-
7 files changed, 107 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<SvxBorderTabPage&>(rPage);
rBorderPage.SetTableMode();
}
+ else if (rId == "shadow")
+ {
+ static_cast<SvxShadowTabPage&>(rPage).SetColorList( mpColorTab );
+ static_cast<SvxShadowTabPage&>(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 <sfx2/tabdlg.hxx>
#include <svx/xtable.hxx>
+#include <svx/tabarea.hxx>
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 @@
<property name="tab_fill">False</property>
</packing>
</child>
+ <child>
+ <!-- n-columns=1 n-rows=1 -->
+ <object class="GtkGrid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="shadow">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" context="formatcellsdialog|shadow">Shadow</property>
+ </object>
+ <packing>
+ <property name="position">5</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
diff --git a/include/svx/sdr/table/tablecontroller.hxx b/include/svx/sdr/table/tablecontroller.hxx
index 8359a15c4dbe..7e438015e907 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 91744eab165b..68f8509d1c36 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -3808,7 +3808,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),
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 8e3305800c78..60b88181b5dc 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -1639,7 +1639,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 a153c2b6db62..fed6dc624ecf 100644
--- a/svx/source/table/tablecontroller.cxx
+++ b/svx/source/table/tablecontroller.cxx
@@ -909,6 +909,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<SfxAbstractTabDialog> xDlg( pFact->CreateSvxFormatCellsDialog(
rReq.GetFrameWeld(),
@@ -948,7 +960,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.get());
+ 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();
+ }
+ }
}
}
}
@@ -2662,6 +2693,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<SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST>{});
+ 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