[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.2' - oox/source sd/qa

2014-12-22 Thread Zolnai Tamás
 oox/source/drawingml/shape.cxx|   13 ++-
 sd/qa/unit/data/pptx/bnc862510_6.pptx |binary
 sd/qa/unit/import-tests.cxx   |   40 ++
 3 files changed, 48 insertions(+), 5 deletions(-)

New commits:
commit 28099820d2eca510f946e38e7d0973aec829e850
Author: Zolnai Tamás tamas.zol...@collabora.com
Date:   Mon Dec 22 17:58:23 2014 +0100

bnc#862510: PPTX import: Wrong text color inside shape

When theme index is 0, it means it's unset so we should not
apply that.

(cherry picked from commit 89206c472ecf18bfde6824cea8004921cd404365)

Conflicts:
sd/qa/unit/import-tests.cxx

Change-Id: I62a9cd2a9b4c19f5acffc334d5e8263fe24fc8fd

diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 28b93b1..8710435 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -647,11 +647,14 @@ Reference XShape  Shape::createAndInsert(
 TextCharacterProperties aCharStyleProperties;
 if( const ShapeStyleRef* pFontRef = getShapeStyleRef( 
XML_fontRef ) )
 {
-if( pTheme )
-if( const TextCharacterProperties* pCharProps = 
pTheme-getFontStyle( pFontRef-mnThemedIdx ) )
-aCharStyleProperties.assignUsed( *pCharProps );
-SAL_INFO(oox.drawingml, OSL_THIS_FUNC  use font 
color);
-aCharStyleProperties.maCharColor.assignIfUsed( 
pFontRef-maPhClr );
+if( pFontRef-mnThemedIdx != 0 )
+{
+if( pTheme )
+if( const TextCharacterProperties* pCharProps = 
pTheme-getFontStyle( pFontRef-mnThemedIdx ) )
+aCharStyleProperties.assignUsed( *pCharProps );
+SAL_INFO(oox.drawingml, OSL_THIS_FUNC  use font 
color);
+aCharStyleProperties.maCharColor.assignIfUsed( 
pFontRef-maPhClr );
+}
 }
 
 Reference  XTextCursor  xAt = xText-createTextCursor();
diff --git a/sd/qa/unit/data/pptx/bnc862510_6.pptx 
b/sd/qa/unit/data/pptx/bnc862510_6.pptx
new file mode 100644
index 000..fc5f008
Binary files /dev/null and b/sd/qa/unit/data/pptx/bnc862510_6.pptx differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 70be8e5..d652a1f 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -74,6 +74,7 @@ public:
 void testBnc584721_4();
 void testBnc904423();
 void testShapeLineStyle();
+void testBnc862510_6();
 
 CPPUNIT_TEST_SUITE(SdFiltersTest);
 CPPUNIT_TEST(testDocumentLayout);
@@ -95,6 +96,7 @@ public:
 CPPUNIT_TEST(testBnc584721_4);
 CPPUNIT_TEST(testBnc904423);
 CPPUNIT_TEST(testShapeLineStyle);
+CPPUNIT_TEST(testBnc862510_6);
 
 CPPUNIT_TEST_SUITE_END();
 };
@@ -860,6 +862,44 @@ void SdFiltersTest::testShapeLineStyle()
 xDocShRef-DoClose();
 }
 
+void SdFiltersTest::testBnc862510_6()
+{
+// Black text was imported instead of gray
+::sd::DrawDocShellRef xDocShRef = 
loadURL(getURLFromSrc(/sd/qa/unit/data/pptx/bnc862510_6.pptx));
+
+uno::Reference drawing::XDrawPagesSupplier  xDoc(
+xDocShRef-GetDoc()-getUnoModel(), uno::UNO_QUERY_THROW );
+
+uno::Reference drawing::XDrawPage  xPage(
+xDoc-getDrawPages()-getByIndex(0), uno::UNO_QUERY_THROW );
+
+uno::Reference beans::XPropertySet  xShape(
+xPage-getByIndex(0), uno::UNO_QUERY );
+CPPUNIT_ASSERT_MESSAGE( no shape, xShape.is() );
+
+// Get first paragraph of the text
+uno::Referencetext::XText xText = 
uno::Referencetext::XTextRange(xShape, uno::UNO_QUERY)-getText();
+CPPUNIT_ASSERT_MESSAGE( not a text shape, xText.is() );
+uno::Referencecontainer::XEnumerationAccess paraEnumAccess;
+paraEnumAccess.set(xText, uno::UNO_QUERY);
+uno::Referencecontainer::XEnumeration paraEnum = 
paraEnumAccess-createEnumeration();
+uno::Referencetext::XTextRange const xParagraph(paraEnum-nextElement(),
+uno::UNO_QUERY_THROW);
+
+// Get first run of the paragraph
+uno::Referencecontainer::XEnumerationAccess xRunEnumAccess(xParagraph, 
uno::UNO_QUERY);
+uno::Referencecontainer::XEnumeration xRunEnum = 
xRunEnumAccess-createEnumeration();
+uno::Referencetext::XTextRange xRun(xRunEnum-nextElement(), 
uno::UNO_QUERY);
+uno::Reference beans::XPropertySet  xPropSet( xRun, uno::UNO_QUERY_THROW 
);
+sal_Int32 nCharColor;
+xPropSet-getPropertyValue( CharColor ) = nCharColor;
+
+// Color should be gray
+CPPUNIT_ASSERT_EQUAL( sal_Int32(0x8B8B8B), nCharColor );
+
+xDocShRef-DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdFiltersTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.2' - oox/source sd/qa

2014-06-11 Thread Zolnai Tamás
 oox/source/drawingml/textbodyproperties.cxx |6 +--
 oox/source/drawingml/transform2dcontext.cxx |   56 +++-
 sd/qa/unit/data/pptx/bnc862510_5.pptx   |binary
 sd/qa/unit/import-tests.cxx |   23 +++
 4 files changed, 57 insertions(+), 28 deletions(-)

New commits:
commit f80101a095a4311af711c631de4aec9e989a778d
Author: Zolnai Tamás tamas.zol...@collabora.com
Date:   Tue Jun 10 18:19:30 2014 +0200

Related bnc#862510: extend handling of txXfrm

We don't actually need to check mbAnchorCtr to change
text spacing. This txXfrm workaround works only with rectangles,
because other shapes' text area can be smaller then the shape
size. So add some condition to avoid using it for
other shapes.

Plus fix typos cause regression introduced in:
53c376d35b7223d53e8c9403390afe53d1f69089

(cherry picked from commit 98dd0f2bb5801f974374ef341037e094e4275cbb)

Conflicts:
sd/qa/unit/import-tests.cxx

Change-Id: I87917b8e0b2bb97ae1bba773e7dda7f81682736f

diff --git a/oox/source/drawingml/textbodyproperties.cxx 
b/oox/source/drawingml/textbodyproperties.cxx
index 3861ebe..93a2f5f 100644
--- a/oox/source/drawingml/textbodyproperties.cxx
+++ b/oox/source/drawingml/textbodyproperties.cxx
@@ -80,9 +80,9 @@ void TextBodyProperties::pushRotationAdjustments( sal_Int32 
nRotation )
 // Hack for n#760986
 // TODO: Preferred method would be to have a textbox on top
 // of the shape and the place it according to the (off,ext)
-if( nOff == 0  moTextOffLeft  mbAnchorCtr ) nVal = *moTextOffLeft;
-if( nOff == 1  moTextOffUpper ) nVal = *moTextOffLeft;
-if( nOff == 2  moTextOffRight  mbAnchorCtr ) nVal = 
*moTextOffRight;
+if( nOff == 0  moTextOffLeft  ) nVal = *moTextOffLeft;
+if( nOff == 1  moTextOffUpper ) nVal = *moTextOffUpper;
+if( nOff == 2  moTextOffRight ) nVal = *moTextOffRight;
 if( nOff == 3  moTextOffLower ) nVal = *moTextOffLower;
 if( nVal  0 ) nVal = 0;
 
diff --git a/oox/source/drawingml/transform2dcontext.cxx 
b/oox/source/drawingml/transform2dcontext.cxx
index 92166c4..0064780 100644
--- a/oox/source/drawingml/transform2dcontext.cxx
+++ b/oox/source/drawingml/transform2dcontext.cxx
@@ -55,37 +55,43 @@ ContextHandlerRef Transform2DContext::onCreateContext( 
sal_Int32 aElementToken,
 {
 if( mbtxXfrm )
 {
-switch( aElementToken )
+// Workaround: only for rectangles
+const sal_Int32 nType = 
mrShape.getCustomShapeProperties()-getShapePresetType();
+if( nType == XML_rect || nType == XML_roundRect )
 {
-case A_TOKEN( off ):
-{
-OUString sXValue = rAttribs.getString( XML_x ).get();
-OUString sYValue = rAttribs.getString( XML_y ).get();
-if( !sXValue.isEmpty() )
-
mrShape.getTextBody()-getTextProperties().moTextOffUpper = GetCoordinate( 
sXValue.toInt32() - mrShape.getPosition().X );
-if( !sYValue.isEmpty() )
-
mrShape.getTextBody()-getTextProperties().moTextOffLeft = GetCoordinate( 
sYValue.toInt32() - mrShape.getPosition().Y );
-}
-break;
-case A_TOKEN( ext ):
-{
-const OUString sXValue = rAttribs.getString( XML_cx 
).get();
-const OUString sYValue = rAttribs.getString( XML_cy 
).get();
-if( !sXValue.isEmpty() )
+switch( aElementToken )
+{
+case A_TOKEN( off ):
 {
-
mrShape.getTextBody()-getTextProperties().moTextOffRight = 
GetCoordinate(mrShape.getSize().Width - sXValue.toInt32());
-if( 
mrShape.getTextBody()-getTextProperties().moTextOffLeft )
-   
*mrShape.getTextBody()-getTextProperties().moTextOffRight -=  
*mrShape.getTextBody()-getTextProperties().moTextOffLeft;
+const OUString sXValue = rAttribs.getString( XML_x 
).get();
+const OUString sYValue = rAttribs.getString( XML_y 
).get();
+if( !sXValue.isEmpty()  nType == XML_rect )
+
mrShape.getTextBody()-getTextProperties().moTextOffLeft = GetCoordinate( 
sXValue.toInt32() - mrShape.getPosition().X );
+if( !sYValue.isEmpty() )
+
mrShape.getTextBody()-getTextProperties().moTextOffUpper = GetCoordinate( 
sYValue.toInt32() - mrShape.getPosition().Y );
 }
-if( !sYValue.isEmpty() )
+break;
+case A_TOKEN( ext ):
 {
-
mrShape.getTextBody()-getTextProperties().moTextOffLower = 
GetCoordinate(mrShape.getSize().Height - sYValue.toInt32());
-