diff options
author | Jacobo Aragunde Pérez <jaragunde@igalia.com> | 2014-01-27 19:46:37 +0100 |
---|---|---|
committer | Jacobo Aragunde Pérez <jaragunde@igalia.com> | 2014-01-28 11:00:37 +0100 |
commit | 5391d4872e71d1edba7acc4ad2d2e3b5b97e1723 (patch) | |
tree | 494d32ae4520eafa5137bd5b03a0b45afe5332c3 /oox/source/drawingml | |
parent | 007f260e0ba31b2449debd0329487679a851cb12 (diff) |
ooxml: Preserve shape style and theme attributes for line
Line style and color can be defined by the shape style attributes or
can be directly assigned by the user (and even using a theme color in
the case of color attribute). This patch aims to preserve the
relevant attributes of this feature after a roundtrip.
For style attributes (wps:style/a:lnRef), they are kept and preserved
in the "StyleLnRef" property of the shape InteropGrabBag. To be able
to access to some of them, the methods getLineStyle, getLineJoint and
getLineWidth were added to LineProperties object.
For the line theme color (a:ln/a:solidFill/a:schemeClr), the original
line color and the theme color name are preserved in the properties
"OriginalLnSolidFillClr" and "SpPrLnSolidFillSchemeClr"of the Shape
InteropGrabBag.
On export time, we must check if the user has changed any properties
of the shape line, this is done comparing the new shape attributes
with the original values coming from the style and theme definitions.
In case some of the attributes is different, the new attribute must
be saved overwriting the old one.
The data files for some /sd/qa/ unit tests were updated to reflect
the new properties inside the Shape InteropGrabBag. Besides, an
existing unit test in ooxmlexport was modified to include checks for
the preservation of line style, line theme color and custom line
style that override the style attributes.
Change-Id: Iabb0cef9e3cc433676c201bc296fb7b373839a3f
Diffstat (limited to 'oox/source/drawingml')
-rw-r--r-- | oox/source/drawingml/lineproperties.cxx | 25 | ||||
-rw-r--r-- | oox/source/drawingml/shape.cxx | 37 |
2 files changed, 55 insertions, 7 deletions
diff --git a/oox/source/drawingml/lineproperties.cxx b/oox/source/drawingml/lineproperties.cxx index df0ce89ac689..2fca061a8482 100644 --- a/oox/source/drawingml/lineproperties.cxx +++ b/oox/source/drawingml/lineproperties.cxx @@ -370,7 +370,7 @@ void LineProperties::pushToPropMap( ShapePropertyMap& rPropMap, drawing::LineStyle eLineStyle = (maLineFill.moFillType.get() == XML_noFill) ? drawing::LineStyle_NONE : drawing::LineStyle_SOLID; // convert line width from EMUs to 1/100mm - sal_Int32 nLineWidth = convertEmuToHmm( moLineWidth.get( 0 ) ); + sal_Int32 nLineWidth = getLineWidth(); // create line dash from preset dash token (not for invisible line) if( (eLineStyle != drawing::LineStyle_NONE) && (moPresetDash.differsFrom( XML_solid ) || !maCustomDash.empty()) ) @@ -419,6 +419,29 @@ void LineProperties::pushToPropMap( ShapePropertyMap& rPropMap, } } +drawing::LineStyle LineProperties::getLineStyle() const +{ + // rules to calculate the line style inferred from the code in LineProperties::pushToPropMap + return (maLineFill.moFillType.get() == XML_noFill) ? + drawing::LineStyle_NONE : + (moPresetDash.differsFrom( XML_solid ) || (!moPresetDash && !maCustomDash.empty())) ? + drawing::LineStyle_DASH : + drawing::LineStyle_SOLID; +} + +drawing::LineJoint LineProperties::getLineJoint() const +{ + if( moLineJoint.has() ) + return lclGetLineJoint( moLineJoint.get() ); + + return drawing::LineJoint_NONE; +} + +sal_Int32 LineProperties::getLineWidth() const +{ + return convertEmuToHmm( moLineWidth.get( 0 ) ); +} + // ============================================================================ } // namespace drawingml diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 47e84d9c8527..41fe7fd429d2 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -79,6 +79,10 @@ using namespace ::com::sun::star::style; namespace oox { namespace drawingml { +#define PUT_PROP( aProperties, nPos, sPropName, aPropValue ) \ + aProperties[nPos].Name = sPropName; \ + aProperties[nPos].Value = Any( aPropValue ); + Shape::Shape( const sal_Char* pServiceName, bool bDefaultHeight ) : mbIsChild( false ) , mpLinePropertiesPtr( new LineProperties ) @@ -555,6 +559,20 @@ Reference< XShape > Shape::createAndInsert( if( const LineProperties* pLineProps = pTheme->getLineStyle( pLineRef->mnThemedIdx ) ) aLineProperties.assignUsed( *pLineProps ); nLinePhClr = pLineRef->maPhClr.getColor( rGraphicHelper ); + + // Store style-related properties to InteropGrabBag to be able to export them back + Sequence< PropertyValue > aProperties( 7 ); + PUT_PROP( aProperties, 0, "SchemeClr", pLineRef->maPhClr.getSchemeName() ); + PUT_PROP( aProperties, 1, "Idx", pLineRef->mnThemedIdx ); + PUT_PROP( aProperties, 2, "Color", nLinePhClr ); + PUT_PROP( aProperties, 3, "LineStyle", aLineProperties.getLineStyle() ); + PUT_PROP( aProperties, 4, "LineJoint", aLineProperties.getLineJoint() ); + PUT_PROP( aProperties, 5, "LineWidth", aLineProperties.getLineWidth() ); + PUT_PROP( aProperties, 6, "Transformations", pLineRef->maPhClr.getTransformations() ); + PropertyValue pStyleFillRef; + pStyleFillRef.Name = "StyleLnRef"; + pStyleFillRef.Value = Any( aProperties ); + putPropertyToGrabBag( pStyleFillRef ); } if( const ShapeStyleRef* pFillRef = getShapeStyleRef( XML_fillRef ) ) { @@ -766,15 +784,22 @@ Reference< XShape > Shape::createAndInsert( mxShape->setSize(awt::Size(aShapeRectHmm.Width, aShapeRectHmm.Height)); } - Sequence< PropertyValue > aProperties( 1 ); - aProperties[0].Name = "OriginalSolidFillClr"; - aProperties[0].Value = aShapeProps[PROP_FillColor]; + // Store original fill and line colors of the shape and the theme color name to InteropGrabBag + sal_Int32 nSize = 2; + Sequence< PropertyValue > aProperties( nSize ); + PUT_PROP( aProperties, 0, "OriginalSolidFillClr", aShapeProps[PROP_FillColor] ); + PUT_PROP( aProperties, 1, "OriginalLnSolidFillClr", aShapeProps[PROP_LineColor] ); OUString sColorFillScheme = aFillProperties.maFillColor.getSchemeName(); if( !aFillProperties.maFillColor.isPlaceHolder() && !sColorFillScheme.isEmpty() ) { - aProperties.realloc( 2 ); - aProperties[1].Name = "SpPrSolidFillSchemeClr"; - aProperties[1].Value = Any( sColorFillScheme ); + aProperties.realloc( ++nSize ); + PUT_PROP( aProperties, nSize - 1, "SpPrSolidFillSchemeClr", sColorFillScheme ); + } + OUString sLnColorFillScheme = aLineProperties.maLineFill.maFillColor.getSchemeName(); + if( !aLineProperties.maLineFill.maFillColor.isPlaceHolder() && !sLnColorFillScheme.isEmpty() ) + { + aProperties.realloc( ++nSize ); + PUT_PROP( aProperties, nSize - 1, "SpPrLnSolidFillSchemeClr", sLnColorFillScheme ); } putPropertiesToGrabBag( aProperties ); } |