summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>2022-06-13 08:53:22 +0200
committerSamuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>2022-06-16 15:44:53 +0200
commitc4cf2e82e8d0aaef9b1daedc033d6edf647e5284 (patch)
tree86baca7fce89d0527d8177a7c4bb9a0e804cfc64 /oox
parent3d2e26d8b7a99d0a622741ef4327e8cbc93bbe02 (diff)
tdf#128150 Add OOXML import/export for "use background fill"
and allow editing this fill property in area dlg Change-Id: Ic63ba11e9d499d4a0fb22f6739587e3e25140b8f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134406 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>
Diffstat (limited to 'oox')
-rw-r--r--oox/inc/drawingml/fillproperties.hxx1
-rw-r--r--oox/source/drawingml/fillproperties.cxx4
-rw-r--r--oox/source/drawingml/shape.cxx3
-rw-r--r--oox/source/drawingml/shapepropertymap.cxx1
-rw-r--r--oox/source/export/drawingml.cxx7
-rw-r--r--oox/source/ppt/pptshapegroupcontext.cxx27
-rw-r--r--oox/source/token/properties.txt1
7 files changed, 16 insertions, 28 deletions
diff --git a/oox/inc/drawingml/fillproperties.hxx b/oox/inc/drawingml/fillproperties.hxx
index 532cb0ec3975..b4f3d00fabc6 100644
--- a/oox/inc/drawingml/fillproperties.hxx
+++ b/oox/inc/drawingml/fillproperties.hxx
@@ -128,6 +128,7 @@ struct FillProperties
{
OptValue< sal_Int32 > moFillType; /// Fill type (OOXML token).
Color maFillColor; /// Solid fill color and transparence.
+ OptValue< bool > moUseBgFill; /// Whether the background is used as fill type
GradientFillProperties maGradientProps; /// Properties for gradient fills.
PatternFillProperties maPatternProps; /// Properties for pattern fills.
BlipFillProperties maBlipProps; /// Properties for bitmap fills.
diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx
index 7d6c41a81fc6..93fea51194ef 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -348,6 +348,7 @@ void FillProperties::assignUsed( const FillProperties& rSourceProps )
{
moFillType.assignIfUsed( rSourceProps.moFillType );
maFillColor.assignIfUsed( rSourceProps.maFillColor );
+ moUseBgFill.assignIfUsed( rSourceProps.moUseBgFill );
maGradientProps.assignUsed( rSourceProps.maGradientProps );
maPatternProps.assignUsed( rSourceProps.maPatternProps );
maBlipProps.assignUsed( rSourceProps.maBlipProps );
@@ -390,7 +391,10 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
switch( moFillType.get() )
{
case XML_noFill:
+ {
eFillStyle = FillStyle_NONE;
+ rPropMap.setProperty(ShapeProperty::FillUseSlideBackground, moUseBgFill.get(false));
+ }
break;
case XML_solidFill:
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 8ef86298fd8b..cff9a5018c6a 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -191,7 +191,6 @@ Shape::Shape( const ShapePtr& pSourceShape )
, mnZOrderOff(pSourceShape->mnZOrderOff)
, mnDataNodeType(pSourceShape->mnDataNodeType)
, mfAspectRatio(pSourceShape->mfAspectRatio)
-, mbUseBgFill(pSourceShape->mbUseBgFill)
, mpDiagramHelper( nullptr )
, msDiagramDataModelID(pSourceShape->msDiagramDataModelID)
{}
@@ -1197,7 +1196,7 @@ Reference< XShape > const & Shape::createAndInsert(
}
if( const ShapeStyleRef* pFillRef = getShapeStyleRef( XML_fillRef ) )
{
- if (!mbUseBgFill)
+ if (!getFillProperties().moUseBgFill.get(false))
{
nFillPhClr = pFillRef->maPhClr.getColor(rGraphicHelper);
nFillPhClrTheme = pFillRef->maPhClr.getSchemeColorIndex();
diff --git a/oox/source/drawingml/shapepropertymap.cxx b/oox/source/drawingml/shapepropertymap.cxx
index 59413ba1dc98..57014b4780a6 100644
--- a/oox/source/drawingml/shapepropertymap.cxx
+++ b/oox/source/drawingml/shapepropertymap.cxx
@@ -47,6 +47,7 @@ const ShapePropertyIds spnDefaultShapeIds =
PROP_FillBitmapPositionOffsetX, PROP_FillBitmapPositionOffsetY, PROP_FillBitmapRectanglePoint,
PROP_FillHatch,
PROP_FillBackground,
+ PROP_FillUseSlideBackground,
PROP_FillBitmapName,
PROP_ShadowXDistance,
PROP_ShadowSizeX,
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index dad1ce7a5c44..8d16911311ec 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -4766,6 +4766,10 @@ void DrawingML::WriteFill( const Reference< XPropertySet >& xPropSet )
aFillStyle = FillStyle_NONE;
}
+ bool bUseBackground(false);
+ if (GetProperty(xPropSet, "FillUseSlideBackground"))
+ xPropSet->getPropertyValue("FillUseSlideBackground") >>= bUseBackground;
+
switch( aFillStyle )
{
case FillStyle_SOLID :
@@ -4781,7 +4785,8 @@ void DrawingML::WriteFill( const Reference< XPropertySet >& xPropSet )
WritePattFill( xPropSet );
break;
case FillStyle_NONE:
- mpFS->singleElementNS(XML_a, XML_noFill);
+ if (!bUseBackground) // attribute `useBgFill` will be written at parent p:sp shape
+ mpFS->singleElementNS(XML_a, XML_noFill);
break;
default:
;
diff --git a/oox/source/ppt/pptshapegroupcontext.cxx b/oox/source/ppt/pptshapegroupcontext.cxx
index 4ca58a383af8..17d3e6c5815e 100644
--- a/oox/source/ppt/pptshapegroupcontext.cxx
+++ b/oox/source/ppt/pptshapegroupcontext.cxx
@@ -101,33 +101,10 @@ ContextHandlerRef PPTShapeGroupContext::onCreateContext( sal_Int32 aElementToken
{
auto pShape = std::make_shared<PPTShape>( meShapeLocation, "com.sun.star.drawing.CustomShape" );
bool bUseBgFill = rAttribs.getBool(XML_useBgFill, false);
- pShape->setUseBgFill(bUseBgFill);
if (bUseBgFill)
{
- oox::drawingml::FillPropertiesPtr pBackgroundPropertiesPtr = mpSlidePersistPtr->getBackgroundProperties();
- if (!pBackgroundPropertiesPtr)
- {
- // The shape wants a background, but the slide doesn't have one.
- SlidePersistPtr pMaster = mpSlidePersistPtr->getMasterPersist();
- if (pMaster)
- {
- oox::drawingml::FillPropertiesPtr pMasterBackground
- = pMaster->getBackgroundProperties();
- if (pMasterBackground)
- {
- if (pMasterBackground->moFillType.has()
- && pMasterBackground->moFillType.get() == XML_solidFill)
- {
- // Master has a solid background, use that.
- pBackgroundPropertiesPtr = pMasterBackground;
- }
- }
- }
- }
- if (pBackgroundPropertiesPtr)
- {
- pShape->getFillProperties().assignUsed(*pBackgroundPropertiesPtr);
- }
+ pShape->getFillProperties().moFillType = XML_noFill;
+ pShape->getFillProperties().moUseBgFill = true;
}
pShape->setModelId(rAttribs.getString( XML_modelId ).get());
return new PPTShapeContext( *this, mpSlidePersistPtr, mpGroupShapePtr, pShape );
diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt
index 8467d3683875..8f17d34dbe49 100644
--- a/oox/source/token/properties.txt
+++ b/oox/source/token/properties.txt
@@ -187,6 +187,7 @@ FillStyle
FillTransparence
FillTransparenceGradient
FillTransparenceGradientName
+FillUseSlideBackground
Filter
FilterCriteriaSource
FilterOptions