[Libreoffice-commits] core.git: 2 commits - oox/source sw/qa writerfilter/source
Miklos Vajna
vmiklos at collabora.co.uk
Wed Oct 1 04:03:57 PDT 2014
oox/source/drawingml/shape.cxx | 12 +++++++++++-
oox/source/shape/WpsContext.cxx | 13 +++++++++++++
sw/qa/extras/ooxmlexport/data/wps-char-color.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 7 +++++++
writerfilter/source/dmapper/PropertyMap.cxx | 1 -
writerfilter/source/dmapper/PropertyMap.hxx | 9 ---------
6 files changed, 31 insertions(+), 11 deletions(-)
New commits:
commit 5bab5aae165158621dcf740be9bee9fca808aa9d
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Oct 1 12:53:27 2014 +0200
DOCX drawingML import: handle char color from theme for shape text
When we import table styles, we apply that as direct formatting, in case
there is no real direct formatting, see lcl_ApplyCellProperties() in the
sw UNO implementation.
We can do the same here: in case there is no other formatting, then
apply the char color from the WPS theme, that will give us the expected
result.
Change-Id: Ic8e6afc09167f7924a11ab0b445351075f16738e
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 96b9129..1aa23f7 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -1013,10 +1013,10 @@ Reference< XShape > Shape::createAndInsert(
else if( getTextBody() )
getTextBody()->getTextProperties().pushVertSimulation();
+ PropertySet aPropertySet(mxShape);
if ( !bUseRotationTransform && mnRotation != 0 )
{
// use the same logic for rotation from VML exporter (SimpleShape::implConvertAndInsert at vmlshape.cxx)
- PropertySet aPropertySet( mxShape );
aPropertySet.setAnyProperty( PROP_RotateAngle, makeAny( sal_Int32( NormAngle360( mnRotation / -600 ) ) ) );
aPropertySet.setAnyProperty( PROP_HoriOrientPosition, makeAny( maPosition.X ) );
aPropertySet.setAnyProperty( PROP_VertOrientPosition, makeAny( maPosition.Y ) );
@@ -1042,6 +1042,16 @@ Reference< XShape > Shape::createAndInsert(
getTextBody()->insertAt( rFilterBase, xText, xAt, aCharStyleProperties, mpMasterTextListStyle );
}
}
+ else if (mbTextBox)
+ {
+ // No drawingML text, but WPS text is expected: save the theme
+ // character color on the shape, then.
+ if(const ShapeStyleRef* pFontRef = getShapeStyleRef(XML_fontRef))
+ {
+ sal_Int32 nCharColor = pFontRef->maPhClr.getColor(rGraphicHelper);
+ aPropertySet.setAnyProperty(PROP_CharColor, uno::makeAny(nCharColor));
+ }
+ }
}
if( mxShape.is() )
diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx
index 4d58638..9e3218e 100644
--- a/oox/source/shape/WpsContext.cxx
+++ b/oox/source/shape/WpsContext.cxx
@@ -111,6 +111,19 @@ oox::core::ContextHandlerRef WpsContext::onCreateContext(sal_Int32 nElementToken
drawing::TextVerticalAdjust eAdjust = drawingml::GetTextVerticalAdjust(rAttribs.getToken(XML_anchor, XML_t));
xPropertySet->setPropertyValue("TextVerticalAdjust", uno::makeAny(eAdjust));
}
+
+ // Apply character color of the shape to the shape's textbox.
+ uno::Reference<text::XText> xText(mxShape, uno::UNO_QUERY);
+ uno::Reference<text::XTextCursor> xTextCursor = xText->createTextCursor();
+ xTextCursor->gotoStart(false);
+ xTextCursor->gotoEnd(true);
+ const uno::Reference<beans::XPropertyState> xPropertyState(xTextCursor, uno::UNO_QUERY);
+ const beans::PropertyState ePropertyState = xPropertyState->getPropertyState("CharColor");
+ if (ePropertyState == beans::PropertyState_DEFAULT_VALUE)
+ {
+ uno::Reference<beans::XPropertySet> xTextBoxPropertySet(xTextCursor, uno::UNO_QUERY);
+ xTextBoxPropertySet->setPropertyValue("CharColor", xPropertySet->getPropertyValue("CharColor"));
+ }
return this;
}
break;
diff --git a/sw/qa/extras/ooxmlexport/data/wps-char-color.docx b/sw/qa/extras/ooxmlexport/data/wps-char-color.docx
new file mode 100644
index 0000000..a027e92
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/wps-char-color.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index d136875..c5cfe79 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -360,6 +360,13 @@ DECLARE_OOXMLEXPORT_TEST(testMsoPosition, "bnc884615-mso-position.docx")
}
}
+DECLARE_OOXMLEXPORT_TEST(testWpsCharColor, "wps-char-color.docx")
+{
+ uno::Reference<text::XTextRange> xShape(getShape(1), uno::UNO_QUERY);
+ // This was -1, i.e. the character color was default (-1), not white.
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffffff), getProperty<sal_Int32>(xShape->getStart(), "CharColor"));
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 66df16469a56e0cae78ce768b2d4873f33223cec
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Oct 1 10:00:48 2014 +0200
Unused writerfilter::dmapper::StyleSheetPropertyMap::mnCT_TcPrBase_vAlign
Change-Id: I64a7c56da33d3d093fc63168671b157c44847b72
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index 105f69a..6283553 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -1417,7 +1417,6 @@ StyleSheetPropertyMap::StyleSheetPropertyMap() :
mnCT_Spacing_lineRule( 0 ),
mbCT_TrPrBase_tblHeader( false ),
mnCT_TrPrBase_jc( 0 ),
- mnCT_TcPrBase_vAlign( 0 ),
mnCT_TblWidth_w( 0 ),
mnCT_TblWidth_type( 0 ),
mbCT_Spacing_lineSet( false ),
diff --git a/writerfilter/source/dmapper/PropertyMap.hxx b/writerfilter/source/dmapper/PropertyMap.hxx
index 5f16df6..24ffe1b 100644
--- a/writerfilter/source/dmapper/PropertyMap.hxx
+++ b/writerfilter/source/dmapper/PropertyMap.hxx
@@ -430,7 +430,6 @@ class StyleSheetPropertyMap : public PropertyMap, public ParagraphProperties
OUString msCT_Fonts_ascii;
bool mbCT_TrPrBase_tblHeader;
sal_Int32 mnCT_TrPrBase_jc;
- sal_Int32 mnCT_TcPrBase_vAlign;
sal_Int32 mnCT_TblWidth_w;
sal_Int32 mnCT_TblWidth_type;
@@ -466,8 +465,6 @@ public:
{mbCT_TrPrBase_tblHeader = bSet; mbCT_TrPrBase_tblHeaderSet = true; }
void SetCT_TrPrBase_jc( sal_Int32 nSet )
{mnCT_TrPrBase_jc = nSet; mbCT_TrPrBase_jcSet = true; }
- void SetCT_TcPrBase_vAlign( sal_Int32 nSet )
- {mnCT_TcPrBase_vAlign = nSet; mbCT_TcPrBase_vAlignSet = true; }
void SetCT_TblWidth_w( sal_Int32 nSet )
{ mnCT_TblWidth_w = nSet; mbCT_TblWidth_wSet = true; }
@@ -505,12 +502,6 @@ public:
rToFill = mnCT_TrPrBase_jc;
return mbCT_TrPrBase_jcSet;
}
- bool GetCT_TcPrBase_vAlign( sal_Int32& rToFill)const
- {
- if( mbCT_TcPrBase_vAlignSet )
- rToFill = mnCT_TcPrBase_vAlign;
- return mbCT_TcPrBase_vAlignSet;
- }
sal_Int32 GetListId() const { return mnListId; }
void SetListId(sal_Int32 nId) { mnListId = nId; }
More information about the Libreoffice-commits
mailing list