[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - include/oox oox/source

2014-07-30 Thread Kohei Yoshida
 include/oox/export/chartexport.hxx |4 
 include/oox/export/utils.hxx   |1 
 oox/source/drawingml/chart/seriesconverter.cxx |   28 +++
 oox/source/export/chartexport.cxx  |  219 +
 oox/source/token/properties.txt|3 
 5 files changed, 115 insertions(+), 140 deletions(-)

New commits:
commit a7e5fc1485fc3a44a05168910430a57aee2b211e
Author: Kohei Yoshida 
Date:   Wed Jul 23 15:49:11 2014 -0400

bnc#885825: OOXML import and export of data label borders.

(cherry picked from commit 48f31a924280a418046f0c816f8a7d20b672dac6)

Conflicts:
oox/source/export/chartexport.cxx

Change-Id: I0fd808145aaeb0aa36d3ec30d7b977890642dcff
Reviewed-on: https://gerrit.libreoffice.org/10562
Reviewed-by: Markus Mohrhard 
Tested-by: Markus Mohrhard 

diff --git a/include/oox/export/chartexport.hxx 
b/include/oox/export/chartexport.hxx
index 4252135..8d570ec 100644
--- a/include/oox/export/chartexport.hxx
+++ b/include/oox/export/chartexport.hxx
@@ -157,9 +157,7 @@ private:
 void exportDataPoints(
 const ::com::sun::star::uno::Reference< 
::com::sun::star::beans::XPropertySet >& xSeriesProperties,
 sal_Int32 nSeriesLength );
-void exportDataLabels(
-const ::com::sun::star::uno::Reference< 
::com::sun::star::beans::XPropertySet >& xSeriesProperties,
-sal_Int32 nSeriesLength );
+void exportDataLabels( const 
css::uno::Reference& xSeries, sal_Int32 nSeriesLength 
);
 void exportGrouping( bool isBar = false );
 void exportTrendlines( ::com::sun::star::uno::Reference< 
::com::sun::star::chart2::XDataSeries > xSeries );
 void exportMarker( ::com::sun::star::uno::Reference< 
::com::sun::star::chart2::XDataSeries > xSeries );
diff --git a/include/oox/export/utils.hxx b/include/oox/export/utils.hxx
index 06ddfe3..588d231 100644
--- a/include/oox/export/utils.hxx
+++ b/include/oox/export/utils.hxx
@@ -23,6 +23,7 @@
 #define I32S(x) OString::number( (sal_Int32) x ).getStr()
 #define I64S(x) OString::number( (sal_Int64) x ).getStr()
 #define IS(x) OString::number( x ).getStr()
+#define BS(x) (x ? "1":"0")
 #define USS(x) OUStringToOString( x, RTL_TEXTENCODING_UTF8 ).getStr()
 
 #ifndef DBG
diff --git a/oox/source/drawingml/chart/seriesconverter.cxx 
b/oox/source/drawingml/chart/seriesconverter.cxx
index 0357114..bcb8d60 100644
--- a/oox/source/drawingml/chart/seriesconverter.cxx
+++ b/oox/source/drawingml/chart/seriesconverter.cxx
@@ -34,11 +34,13 @@
 #include "oox/drawingml/chart/typegroupconverter.hxx"
 #include "oox/drawingml/chart/typegroupmodel.hxx"
 #include "oox/helper/containerhelper.hxx"
+#include 
 
 namespace oox {
 namespace drawingml {
 namespace chart {
 
+using namespace com::sun::star;
 using namespace ::com::sun::star::beans;
 using namespace ::com::sun::star::chart2;
 using namespace ::com::sun::star::chart2::data;
@@ -162,6 +164,20 @@ void lclConvertLabelFormatting( PropertySet& rPropSet, 
ObjectFormatter& rFormatt
 }
 }
 
+void importBorderProperties( PropertySet& rPropSet, Shape& rShape, const 
GraphicHelper& rGraphicHelper )
+{
+LineProperties& rLP = rShape.getLineProperties();
+if (rLP.moLineWidth.has())
+{
+sal_Int32 nWidth = convertEmuToHmm(rLP.moLineWidth.get());
+rPropSet.setProperty(PROP_LabelBorderWidth, uno::makeAny(nWidth));
+rPropSet.setProperty(PROP_LabelBorderStyle, 
uno::makeAny(drawing::LineStyle_SOLID));
+}
+const Color& aColor = rLP.maLineFill.maFillColor;
+sal_Int32 nColor = aColor.getColor(rGraphicHelper);
+rPropSet.setProperty(PROP_LabelBorderColor, uno::makeAny(nColor));
+}
+
 } // namespace
 
 DataLabelConverter::DataLabelConverter( const ConverterRoot& rParent, 
DataLabelModel& rModel ) :
@@ -175,7 +191,10 @@ DataLabelConverter::~DataLabelConverter()
 
 void DataLabelConverter::convertFromModel( const Reference< XDataSeries >& 
rxDataSeries, const TypeGroupConverter& rTypeGroup )
 {
-if( rxDataSeries.is() ) try
+if (!rxDataSeries.is())
+return;
+
+try
 {
 PropertySet aPropSet( rxDataSeries->getDataPointByIndex( 
mrModel.mnIndex ) );
 lclConvertLabelFormatting( aPropSet, getFormatter(), mrModel, 
rTypeGroup, false );
@@ -201,6 +220,9 @@ void DataLabelConverter::convertFromModel( const Reference< 
XDataSeries >& rxDat
 aPropSet.setProperty( PROP_LabelPlacement,
   aPositionsLookupTable[ simplifiedX+1 + 
3*(simplifiedY+1) ] );
 }
+
+if (mrModel.mxShapeProp)
+importBorderProperties(aPropSet, *mrModel.mxShapeProp, 
getFilter().getGraphicHelper());
 }
 catch( Exception& )
 {
@@ -222,6 +244,10 @@ void DataLabelsConverter::convertFromModel( const 
Reference< XDataSeries >& rxDa
 {
 PropertySet aPropSet( rxDataSeries );
 lclConvertLabelFormatting( aPropSet, getFormatter(), mrModel, 
rTypeGroup, true );
+
+if (mrMode

[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - include/oox oox/source

2014-08-06 Thread Kohei Yoshida
 include/oox/helper/graphichelper.hxx   |3 +++
 oox/source/drawingml/chart/chartspaceconverter.cxx |8 +++-
 oox/source/helper/graphichelper.cxx|5 +
 oox/source/ppt/pptimport.cxx   |6 ++
 4 files changed, 21 insertions(+), 1 deletion(-)

New commits:
commit e9f77854e20433287ca32569af01eb1508ca51a5
Author: Kohei Yoshida 
Date:   Fri Aug 1 21:39:49 2014 -0400

bnc#886540: Default chart background for pptx docs should be transparent.

Charts in docx and xlsx OTOH use solid white as the default fill style.

(cherry picked from commit 4a8f2431718f99de6fd9ee3461d703d007261c03)
(cherry picked from commit 013744a5b475e151ca0918565fb369e22dfbc1db)

Conflicts:
oox/source/drawingml/chart/chartspaceconverter.cxx

Change-Id: Ic4351fe65cabc12d60214b67c7026a317841f2c7
Reviewed-on: https://gerrit.libreoffice.org/10736
Reviewed-by: Matúš Kukan 
Tested-by: Matúš Kukan 

diff --git a/include/oox/helper/graphichelper.hxx 
b/include/oox/helper/graphichelper.hxx
index f74963c..5981445 100644
--- a/include/oox/helper/graphichelper.hxx
+++ b/include/oox/helper/graphichelper.hxx
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -75,6 +76,8 @@ public:
 /** Derived classes may implement to resolve a palette index to an RGB 
color. */
 virtual sal_Int32   getPaletteColor( sal_Int32 nPaletteIdx ) const;
 
+virtual css::drawing::FillStyle getDefaultChartAreaFillStyle() const;
+
 // Device info and device dependent unit conversion ---
 
 /** Returns information about the output device. */
diff --git a/oox/source/drawingml/chart/chartspaceconverter.cxx 
b/oox/source/drawingml/chart/chartspaceconverter.cxx
index 2238fe2..b63bfe9 100644
--- a/oox/source/drawingml/chart/chartspaceconverter.cxx
+++ b/oox/source/drawingml/chart/chartspaceconverter.cxx
@@ -25,12 +25,14 @@
 #include 
 #include 
 #include 
+#include 
 #include "oox/core/xmlfilterbase.hxx"
 #include "oox/drawingml/chart/chartconverter.hxx"
 #include "oox/drawingml/chart/chartdrawingfragment.hxx"
 #include "oox/drawingml/chart/chartspacemodel.hxx"
 #include "oox/drawingml/chart/plotareaconverter.hxx"
 #include "oox/drawingml/chart/titleconverter.hxx"
+#include 
 
 using namespace ::com::sun::star;
 using ::com::sun::star::uno::Reference;
@@ -90,8 +92,12 @@ void ChartSpaceConverter::convertFromModel( const Reference< 
XShapes >& rxExtern
 {
 }
 
-// formatting of the chart background
+// formatting of the chart background.  The default fill style varies with 
applications.
 PropertySet aBackPropSet( getChartDocument()->getPageBackground() );
+aBackPropSet.setProperty(
+PROP_FillStyle,
+
uno::makeAny(getFilter().getGraphicHelper().getDefaultChartAreaFillStyle()));
+
 if( mrModel.mxShapeProp.is() )
 {
 getFormatter().convertFrameFormatting( aBackPropSet, 
mrModel.mxShapeProp, OBJECTTYPE_CHARTSPACE );
diff --git a/oox/source/helper/graphichelper.cxx 
b/oox/source/helper/graphichelper.cxx
index 135a91c..5281da2 100644
--- a/oox/source/helper/graphichelper.cxx
+++ b/oox/source/helper/graphichelper.cxx
@@ -158,6 +158,11 @@ sal_Int32 GraphicHelper::getPaletteColor( sal_Int32 
/*nPaletteIdx*/ ) const
 return API_RGB_TRANSPARENT;
 }
 
+drawing::FillStyle GraphicHelper::getDefaultChartAreaFillStyle() const
+{
+return drawing::FillStyle_SOLID;
+}
+
 // Device info and device dependent unit conversion ---
 
 const awt::DeviceInfo& GraphicHelper::getDeviceInfo() const
diff --git a/oox/source/ppt/pptimport.cxx b/oox/source/ppt/pptimport.cxx
index c3aa2208..df15d77 100644
--- a/oox/source/ppt/pptimport.cxx
+++ b/oox/source/ppt/pptimport.cxx
@@ -190,6 +190,7 @@ class PptGraphicHelper : public GraphicHelper
 public:
 explicitPptGraphicHelper( const PowerPointImport& rFilter );
 virtual sal_Int32   getSchemeColor( sal_Int32 nToken ) const SAL_OVERRIDE;
+virtual drawing::FillStyle getDefaultChartAreaFillStyle() const 
SAL_OVERRIDE;
 private:
 const PowerPointImport& mrFilter;
 };
@@ -205,6 +206,11 @@ sal_Int32 PptGraphicHelper::getSchemeColor( sal_Int32 
nToken ) const
 return mrFilter.getSchemeColor( nToken );
 }
 
+drawing::FillStyle PptGraphicHelper::getDefaultChartAreaFillStyle() const
+{
+return drawing::FillStyle_NONE;
+}
+
 } // namespace
 
 GraphicHelper* PowerPointImport::implCreateGraphicHelper() const
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - include/oox oox/source

2014-07-07 Thread Caolán McNamara
 include/oox/drawingml/shapepropertymap.hxx |8 
 oox/source/drawingml/chart/objectformatter.cxx |5 +++--
 2 files changed, 7 insertions(+), 6 deletions(-)

New commits:
commit 9afdc6c3b4eb077b3e4279c5eec1e3dd9a4a8512
Author: Caolán McNamara 
Date:   Mon Jul 7 11:44:23 2014 +0100

fix crash loading ooo100546-1.xls

regressions around inserted extra enum values
into ShapePropertyId

(cherry picked from commit aacfd5038d05a02f8b1eade3a5896d3d7e959f3d)

Conflicts:
oox/source/drawingml/chart/objectformatter.cxx

Change-Id: I06696c8cfe4acc3836723c31d5e714bd7d8439b3
Reviewed-on: https://gerrit.libreoffice.org/10108
Reviewed-by: Matúš Kukan 
Tested-by: Matúš Kukan 

diff --git a/include/oox/drawingml/shapepropertymap.hxx 
b/include/oox/drawingml/shapepropertymap.hxx
index f451cc0..13e8e50 100644
--- a/include/oox/drawingml/shapepropertymap.hxx
+++ b/include/oox/drawingml/shapepropertymap.hxx
@@ -30,12 +30,14 @@ namespace oox { class ModelObjectHelper; }
 namespace oox {
 namespace drawingml {
 
-
-
 /** Enumeration for various properties related to drawing shape formatting.
 
 This is an abstraction for shape formatting properties that have different
 names in various implementations, e.g. drawing shapes vs. chart objects.
+
+If you *insert* ids into this list, then update spnCommonPropIds, 
spnLinearPropIds
+and spnFilledPropIds of oox/source/drawingml/chart/objectformatter.cxx if
+the newly inserted enum is inside the range they cover
  */
 enum ShapePropertyId
 {
@@ -69,8 +71,6 @@ enum ShapePropertyId
 SHAPEPROP_END
 };
 
-
-
 struct OOX_DLLPUBLIC ShapePropertyInfo
 {
 std::vector maPropertyIds;
diff --git a/oox/source/drawingml/chart/objectformatter.cxx 
b/oox/source/drawingml/chart/objectformatter.cxx
index adcc3f3..54ef18a 100644
--- a/oox/source/drawingml/chart/objectformatter.cxx
+++ b/oox/source/drawingml/chart/objectformatter.cxx
@@ -460,7 +460,7 @@ const AutoTextEntry* lclGetAutoTextEntry( const 
AutoTextEntry* pEntries, sal_Int
 return 0;
 }
 
-
+// These PropIds arrays will be indexed into using a ShapePropertyId enum 
(include/oox/drawingml/shapepropertymap.hxx)
 
 /** Property identifiers for common chart objects, to be used in 
ShapePropertyInfo. */
 static const sal_Int32 spnCommonPropIds[] =
@@ -478,7 +478,7 @@ static const sal_Int32 spnLinearPropIds[] =
 {
 PROP_LineStyle, PROP_LineWidth, PROP_Color, PROP_Transparency, 
PROP_LineDashName,
 PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, 
PROP_INVALID, PROP_INVALID,
-PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID,
+PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID,
 PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID,
 PROP_INVALID, PROP_INVALID, PROP_INVALID,
 PROP_END_LIST
@@ -502,6 +502,7 @@ static const sal_Int32 spnFilledPropIds[] =
 PROP_FillStyle,
 PROP_Color,
 PROP_Transparency,
+PROP_INVALID,
 PROP_GradientName,
 PROP_FillBitmapName,
 PROP_FillBitmapMode,
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - include/oox oox/source

2014-07-09 Thread Kohei Yoshida
 include/oox/drawingml/chart/axisconverter.hxx|   10 ++
 oox/source/drawingml/chart/axisconverter.cxx |   38 ++-
 oox/source/drawingml/chart/plotareaconverter.cxx |6 +--
 3 files changed, 38 insertions(+), 16 deletions(-)

New commits:
commit 4656a2635a7b6032b955e1223bbe81df8b05f436
Author: Kohei Yoshida 
Date:   Mon Jul 7 16:38:29 2014 -0400

bnc#881025: Mark axis a percent axis only when all data series are percent.

(cherry picked from commit b8c444a46b2f41dae673c6118d84276be0e6c87d)

Conflicts:
oox/inc/drawingml/chart/axisconverter.hxx

Change-Id: I302cc1e5b164b2ce087293b034ec930951af
Reviewed-on: https://gerrit.libreoffice.org/10124
Reviewed-by: Matúš Kukan 
Tested-by: Matúš Kukan 

diff --git a/include/oox/drawingml/chart/axisconverter.hxx 
b/include/oox/drawingml/chart/axisconverter.hxx
index 3b7a587..15feb26 100644
--- a/include/oox/drawingml/chart/axisconverter.hxx
+++ b/include/oox/drawingml/chart/axisconverter.hxx
@@ -60,12 +60,10 @@ public:
 virtual ~AxisConverter();
 
 /** Creates a chart2 axis and inserts it into the passed coordinate 
system. */
-voidconvertFromModel(
-const ::com::sun::star::uno::Reference< 
::com::sun::star::chart2::XCoordinateSystem >& rxCoordSystem,
-TypeGroupConverter& rTypeGroup,
-const AxisModel* pCrossingAxis,
-sal_Int32 nAxesSetIdx,
-sal_Int32 nAxisIdx );
+void convertFromModel(
+const css::uno::Reference& 
rxCoordSystem,
+RefVector& rTypeGroups, const AxisModel* 
pCrossingAxis,
+sal_Int32 nAxesSetIdx, sal_Int32 nAxisIdx );
 };
 
 
diff --git a/oox/source/drawingml/chart/axisconverter.cxx 
b/oox/source/drawingml/chart/axisconverter.cxx
index a15c23e..4133ae1 100644
--- a/oox/source/drawingml/chart/axisconverter.cxx
+++ b/oox/source/drawingml/chart/axisconverter.cxx
@@ -107,6 +107,26 @@ sal_Int32 lclGetTickMark( sal_Int32 nToken )
 return NONE;
 }
 
+/**
+ * The groups is of percent type only when all of its members are of percent
+ * type.
+ */
+bool isPercent( const RefVector& rTypeGroups )
+{
+if (rTypeGroups.empty())
+return false;
+
+RefVector::const_iterator it = rTypeGroups.begin(), 
itEnd = rTypeGroups.end();
+for (; it != itEnd; ++it)
+{
+TypeGroupConverter& rConv = **it;
+if (!rConv.isPercent())
+return false;
+}
+
+return true;
+}
+
 } // namespace
 
 
@@ -120,16 +140,20 @@ AxisConverter::~AxisConverter()
 {
 }
 
-void AxisConverter::convertFromModel( const Reference< XCoordinateSystem >& 
rxCoordSystem,
-TypeGroupConverter& rTypeGroup, const AxisModel* pCrossingAxis, 
sal_Int32 nAxesSetIdx, sal_Int32 nAxisIdx )
+void AxisConverter::convertFromModel(
+const Reference< XCoordinateSystem >& rxCoordSystem,
+RefVector& rTypeGroups, const AxisModel* 
pCrossingAxis, sal_Int32 nAxesSetIdx, sal_Int32 nAxisIdx )
 {
+if (rTypeGroups.empty())
+return;
+
 Reference< XAxis > xAxis;
 try
 {
 namespace cssc = ::com::sun::star::chart;
 namespace cssc2 = ::com::sun::star::chart2;
 
-const TypeGroupInfo& rTypeInfo = rTypeGroup.getTypeInfo();
+const TypeGroupInfo& rTypeInfo = rTypeGroups.front()->getTypeInfo();
 ObjectFormatter& rFormatter = getFormatter();
 
 // create the axis object (always)
@@ -189,7 +213,7 @@ void AxisConverter::convertFromModel( const Reference< 
XCoordinateSystem >& rxCo
 currently). */
 aScaleData.AxisType = (bDateAxis && !mrModel.mbAuto) ? 
cssc2::AxisType::DATE : cssc2::AxisType::CATEGORY;
 aScaleData.AutoDateAxis = mrModel.mbAuto;
-aScaleData.Categories = 
rTypeGroup.createCategorySequence();
+aScaleData.Categories = 
rTypeGroups.front()->createCategorySequence();
 }
 else
 {
@@ -199,11 +223,11 @@ void AxisConverter::convertFromModel( const Reference< 
XCoordinateSystem >& rxCo
 break;
 case API_Y_AXIS:
 OSL_ENSURE( mrModel.mnTypeId == C_TOKEN( valAx ), 
"AxisConverter::convertFromModel - unexpected axis model type (must: c:valAx)" 
);
-aScaleData.AxisType = rTypeGroup.isPercent() ? 
cssc2::AxisType::PERCENT : cssc2::AxisType::REALNUMBER;
+aScaleData.AxisType = isPercent(rTypeGroups) ? 
cssc2::AxisType::PERCENT : cssc2::AxisType::REALNUMBER;
 break;
 case API_Z_AXIS:
 OSL_ENSURE( mrModel.mnTypeId == C_TOKEN( serAx ), 
"AxisConverter::convertFromModel - unexpected axis model type (must: c:serAx)" 
);
-OSL_ENSURE( rTypeGroup.isDeep3dChart(), 
"AxisConverter::convertFromModel - series axis not supported by this chart 
type" );
+

[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - include/oox oox/source

2014-08-11 Thread Matúš Kukan
 include/oox/ppt/pptshape.hxx  |7 ++
 oox/source/ppt/pptgraphicshapecontext.cxx |   13 +
 oox/source/ppt/pptshape.cxx   |   72 +-
 oox/source/ppt/pptshapecontext.cxx|   60 ++---
 4 files changed, 76 insertions(+), 76 deletions(-)

New commits:
commit 64157c4598606b094f5783804b38cfb4c901a88a
Author: Matúš Kukan 
Date:   Thu Aug 7 13:25:51 2014 +0200

bnc#821916: Better algorithm to find placeholder shape.

Placeholder type seems to be more relevant than index.

Change-Id: I9d6c6cad8e0a51b2385801f65d7d1c697ad7998e
Reviewed-on: https://gerrit.libreoffice.org/10844
Reviewed-by: David Tardon 
Tested-by: David Tardon 

diff --git a/include/oox/ppt/pptshape.hxx b/include/oox/ppt/pptshape.hxx
index 41941fd..18126d3 100644
--- a/include/oox/ppt/pptshape.hxx
+++ b/include/oox/ppt/pptshape.hxx
@@ -58,8 +58,11 @@ public:
 void setPlaceholder( oox::drawingml::ShapePtr pPlaceholder ) { 
mpPlaceholder = pPlaceholder; }
 void setModelId( const OUString& rId ) { msModelId = rId; }
 
-static oox::drawingml::ShapePtr findPlaceholder( const sal_Int32 
nMasterPlaceholder, std::vector< oox::drawingml::ShapePtr >& rShapes, bool 
bMasterOnly = false );
-static oox::drawingml::ShapePtr findPlaceholderByIndex( const sal_Int32 
nIdx, std::vector< oox::drawingml::ShapePtr >& rShapes, bool bMasterOnly = 
false );
+static oox::drawingml::ShapePtr findPlaceholder( const sal_Int32 
nFirstSubType,
+const sal_Int32 nSecondSubType, const OptValue< sal_Int32 >& 
oSubTypeIndex,
+std::vector< oox::drawingml::ShapePtr >& rShapes, bool bMasterOnly 
= false );
+static oox::drawingml::ShapePtr findPlaceholderByIndex( const sal_Int32 
nIdx,
+std::vector< oox::drawingml::ShapePtr >& rShapes, bool bMasterOnly 
= false );
 
 static oox::drawingml::TextListStylePtr getSubTypeTextListStyle( const 
SlidePersist& rSlidePersist, sal_Int32 nSubType );
 
diff --git a/oox/source/ppt/pptgraphicshapecontext.cxx 
b/oox/source/ppt/pptgraphicshapecontext.cxx
index b0772a8..47a808d 100644
--- a/oox/source/ppt/pptgraphicshapecontext.cxx
+++ b/oox/source/ppt/pptgraphicshapecontext.cxx
@@ -53,13 +53,6 @@ PPTGraphicShapeContext::PPTGraphicShapeContext( 
ContextHandler2Helper& rParent,
 {
 }
 
-// if nFirstPlaceholder can't be found, it will be searched for 
nSecondPlaceholder
-static oox::drawingml::ShapePtr findPlaceholder( sal_Int32 nFirstPlaceholder, 
sal_Int32 nSecondPlaceholder, std::vector< oox::drawingml::ShapePtr >& rShapes )
-{
-oox::drawingml::ShapePtr pPlaceholder = PPTShape::findPlaceholder( 
nFirstPlaceholder, rShapes );
-return !nSecondPlaceholder || pPlaceholder.get() ? pPlaceholder : 
PPTShape::findPlaceholder( nSecondPlaceholder, rShapes );
-}
-
 ContextHandlerRef PPTGraphicShapeContext::onCreateContext( sal_Int32 
aElementToken, const AttributeList& rAttribs )
 {
 switch( aElementToken )
@@ -135,12 +128,14 @@ ContextHandlerRef 
PPTGraphicShapeContext::onCreateContext( sal_Int32 aElementTok
 if ( nFirstPlaceholder )
 {
 if ( eShapeLocation == Layout ) // for layout 
objects the referenced object can be found within the same shape tree
-pPlaceholder = findPlaceholder( nFirstPlaceholder, 
nSecondPlaceholder, mpSlidePersistPtr->getShapes()->getChildren() );
+pPlaceholder = PPTShape::findPlaceholder( 
nFirstPlaceholder, nSecondPlaceholder,
+pPPTShapePtr->getSubTypeIndex(), 
mpSlidePersistPtr->getShapes()->getChildren(), true );
 else if ( eShapeLocation == Slide ) // normal slide 
shapes have to search within the corresponding master tree for referenced 
objects
 {
 SlidePersistPtr pMasterPersist( 
mpSlidePersistPtr->getMasterPersist() );
 if ( pMasterPersist.get() )
-pPlaceholder = findPlaceholder( 
nFirstPlaceholder, nSecondPlaceholder, 
pMasterPersist->getShapes()->getChildren() );
+pPlaceholder = PPTShape::findPlaceholder( 
nFirstPlaceholder, nSecondPlaceholder,
+pPPTShapePtr->getSubTypeIndex(), 
pMasterPersist->getShapes()->getChildren() );
 }
 }
 }
diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx
index 0c5ebe0..70b2d79 100644
--- a/oox/source/ppt/pptshape.cxx
+++ b/oox/source/ppt/pptshape.cxx
@@ -228,7 +228,7 @@ void PPTShape::addShape(
 if( mnSubType && getSubTypeIndex().has() && meShapeLocation == 
Layout ) {
 oox::drawingml::ShapePtr pPlaceholder = 
PPTShape::findPlaceholderByIndex( getSubTypeIndex().get(), 
rSlidePersist.getShapes()->getChildren(), true );
 if (!pPlac

[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - include/oox oox/source sd/qa

2014-06-06 Thread Zolnai Tamás
 include/oox/drawingml/graphicshapecontext.hxx |2 +
 include/oox/ppt/pptshapegroupcontext.hxx  |3 --
 oox/source/drawingml/graphicshapecontext.cxx  |   14 +--
 oox/source/ppt/pptshapegroupcontext.cxx   |7 -
 sd/qa/unit/data/pptx/bnc880763.pptx   |binary
 sd/qa/unit/data/xml/n819614_0.xml |   16 ++---
 sd/qa/unit/import-tests.cxx   |   32 +++---
 7 files changed, 52 insertions(+), 22 deletions(-)

New commits:
commit 7c7c7dc785750769d661df1dc36201b9f5566ea1
Author: Zolnai Tamás 
Date:   Fri Jun 6 15:57:43 2014 +0200

bnc#880763: PPTX import: wrong z-order becuause of wrong import order

importExtDrawings() must be called as soon as possible,
before parser starts to parse the next shape.
Call it when graphicFrame tag is closed. This tag include
the reference to the SmartArt.

Plus fix up import tests.

Change-Id: I9e8d54c2b1afeb78a1122390dc4982d580c152ae
(cherry picked from commit 46d682eec92bb241f4604a4b6ab42a3859cd0d48)

diff --git a/include/oox/drawingml/graphicshapecontext.hxx 
b/include/oox/drawingml/graphicshapecontext.hxx
index 72881fe..fe4b216 100644
--- a/include/oox/drawingml/graphicshapecontext.hxx
+++ b/include/oox/drawingml/graphicshapecontext.hxx
@@ -44,9 +44,11 @@ public:
 GraphicalObjectFrameContext( ::oox::core::ContextHandler2Helper& rParent, 
ShapePtr pMasterShapePtr, ShapePtr pShapePtr, bool bEmbedShapesInChart );
 
 virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 
Element, const ::oox::AttributeList& rAttribs ) SAL_OVERRIDE;
+virtual void onEndElement() SAL_OVERRIDE;
 
 private:
 boolmbEmbedShapesInChart;
+::oox::core::ContextHandler2Helper* mpParent;
 };
 
 
diff --git a/include/oox/ppt/pptshapegroupcontext.hxx 
b/include/oox/ppt/pptshapegroupcontext.hxx
index 847d9b6..5cae54d 100644
--- a/include/oox/ppt/pptshapegroupcontext.hxx
+++ b/include/oox/ppt/pptshapegroupcontext.hxx
@@ -32,7 +32,6 @@ class PPTShapeGroupContext : public 
::oox::drawingml::ShapeGroupContext
 ShapeLocation   meShapeLocation;
 oox::drawingml::ShapePtrpGraphicShape;
 
-voidimportExtDrawings();
 voidapplyFontRefColor(oox::drawingml::ShapePtr pShape, 
const oox::drawingml::Color& rFontRefColor);
 
 public:
@@ -46,7 +45,7 @@ public:
 virtual ::oox::core::ContextHandlerRef
 onCreateContext( ::sal_Int32 Element, const ::oox::AttributeList& 
rAttribs ) SAL_OVERRIDE;
 
-virtual void onEndElement() SAL_OVERRIDE;
+void importExtDrawings();
 
 protected:
 
diff --git a/oox/source/drawingml/graphicshapecontext.cxx 
b/oox/source/drawingml/graphicshapecontext.cxx
index ebd2028..db04d5c 100644
--- a/oox/source/drawingml/graphicshapecontext.cxx
+++ b/oox/source/drawingml/graphicshapecontext.cxx
@@ -36,6 +36,7 @@
 #include "oox/drawingml/transform2dcontext.hxx"
 #include "oox/helper/binaryinputstream.hxx"
 #include "oox/helper/binaryoutputstream.hxx"
+#include "oox/ppt/pptshapegroupcontext.hxx"
 #include 
 
 using namespace ::com::sun::star;
@@ -103,7 +104,8 @@ ContextHandlerRef GraphicShapeContext::onCreateContext( 
sal_Int32 aElementToken,
 
 GraphicalObjectFrameContext::GraphicalObjectFrameContext( 
ContextHandler2Helper& rParent, ShapePtr pMasterShapePtr, ShapePtr pShapePtr, 
bool bEmbedShapesInChart ) :
 ShapeContext( rParent, pMasterShapePtr, pShapePtr ),
-mbEmbedShapesInChart( bEmbedShapesInChart )
+mbEmbedShapesInChart( bEmbedShapesInChart ),
+mpParent(&rParent)
 {
 }
 
@@ -146,7 +148,15 @@ ContextHandlerRef 
GraphicalObjectFrameContext::onCreateContext( sal_Int32 aEleme
 return ShapeContext::onCreateContext( aElementToken, rAttribs );
 }
 
-
+void GraphicalObjectFrameContext::onEndElement()
+{
+if( getCurrentElement() == PPT_TOKEN( graphicFrame ) && mpParent )
+{
+oox::ppt::PPTShapeGroupContext* pParent = 
dynamic_cast(mpParent);
+if( pParent )
+pParent->importExtDrawings();
+}
+}
 
 OleObjectGraphicDataContext::OleObjectGraphicDataContext( 
ContextHandler2Helper& rParent, ShapePtr xShape ) :
 ShapeContext( rParent, ShapePtr(), xShape ),
diff --git a/oox/source/ppt/pptshapegroupcontext.cxx 
b/oox/source/ppt/pptshapegroupcontext.cxx
index 0fd517f..9bf3d2b 100644
--- a/oox/source/ppt/pptshapegroupcontext.cxx
+++ b/oox/source/ppt/pptshapegroupcontext.cxx
@@ -109,8 +109,6 @@ ContextHandlerRef PPTShapeGroupContext::onCreateContext( 
sal_Int32 aElementToken
 return new PPTGraphicShapeContext( *this, mpSlidePersistPtr, 
mpGroupShapePtr,  oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, 
"com.sun.star.drawing.GraphicObjectShape" ) ) );
 case PPT_TOKEN( graphicFrame ): // CT_GraphicalObjectFrame
 {
-if( pGraphicShape )
-importExtDrawings();
 pGraphicShape = oox::drawingml::ShapePtr( new PPTShape( 
meShapeLocation, "com.sun.star.drawi

[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - include/oox oox/source sw/qa

2014-09-09 Thread Adam Co
 include/oox/export/utils.hxx  |
4 
 oox/source/drawingml/lineproperties.cxx   |   
15 +-
 oox/source/drawingml/linepropertiescontext.cxx|   
46 +++
 oox/source/export/drawingml.cxx   |   
49 +--
 sw/qa/extras/ooxmlexport/data/dashed_line_custdash_1000th_of_percent.docx 
|binary
 sw/qa/extras/ooxmlexport/data/dashed_line_custdash_percentage.docx
|binary
 sw/qa/extras/ooxmlexport/data/dashed_line_preset.docx 
|binary
 sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx   |   
62 ++
 8 files changed, 156 insertions(+), 20 deletions(-)

New commits:
commit 1af3d8a211852da5a1f130aa22e00ab329301ee7
Author: Adam Co 
Date:   Sun Jun 8 16:35:32 2014 +0300

Rewrite import and export of custom dashes in ooxml filter (fix)

The import mechanism of custom-dash (a:custDash) was wrong, and imported
wrong values, which causes that if you would import-export-import-export -
you would get inflated values, which might cause a corruption.

The attributes for custom-dash nodes (a:ds) are of type 
'PositivePercentage'.
Office will read percentages formatted with a trailing percent sign or
formatted as 1000th of a percent without a trailing percent sign, but only
write percentages as 1000th's of a percent without a trailing percent sign.

During import - LO did not check if it was in '%' format or in
'1000th of a percent' format. So that was fixed. Also - when exporting -
it always exports now in '1000th of a percent' format.

Reviewed-on: https://gerrit.libreoffice.org/9681
Reviewed-by: Miklos Vajna 
Tested-by: Miklos Vajna 
(cherry picked from commit 2211a67cc5e577f8abdcc96c9c63865be5fb988d)

Conflicts:
oox/source/export/drawingml.cxx

Change-Id: I6bd74df26951974f85173227c832386c70034afb

diff --git a/include/oox/export/utils.hxx b/include/oox/export/utils.hxx
index 588d231..2c4fcec 100644
--- a/include/oox/export/utils.hxx
+++ b/include/oox/export/utils.hxx
@@ -50,9 +50,9 @@ static inline sal_Int64 TwipsToEMU( sal_Int32 nTwips )
 }
 
 template 
-OString writePercentage(T number)
+OString write1000thOfAPercent(T number)
 {
-return OString::number(number) + "%";
+return OString::number( number * 1000 );
 }
 
 #endif
diff --git a/oox/source/drawingml/lineproperties.cxx 
b/oox/source/drawingml/lineproperties.cxx
index 2044095..372740b 100644
--- a/oox/source/drawingml/lineproperties.cxx
+++ b/oox/source/drawingml/lineproperties.cxx
@@ -107,19 +107,26 @@ void lclConvertCustomDash( LineDash& orLineDash, const 
LineProperties::DashStopV
 sal_Int16 nDashes = 0;
 sal_Int32 nDashLen = 0;
 sal_Int32 nDistance = 0;
+sal_Int32 nConvertedLen = 0;
+sal_Int32 nConvertedDistance = 0;
 for( LineProperties::DashStopVector::const_iterator aIt = 
rCustomDash.begin(), aEnd = rCustomDash.end(); aIt != aEnd; ++aIt )
 {
-if( aIt->first <= 2 )
+// Get from "1000th of percent" ==> percent ==> multiplier
+nConvertedLen  = aIt->first  / 1000 / 100;
+nConvertedDistance = aIt->second / 1000 / 100;
+
+// Check if it is a dot (100% = dot)
+if( nConvertedLen == 1 )
 {
 ++nDots;
-nDotLen += aIt->first;
+nDotLen += nConvertedLen;
 }
 else
 {
 ++nDashes;
-nDashLen += aIt->first;
+nDashLen += nConvertedLen;
 }
-nDistance += aIt->second;
+nDistance += nConvertedDistance;
 }
 orLineDash.DotLen = (nDots > 0) ? ::std::max< sal_Int32 >( nDotLen / 
nDots, 1 ) : 0;
 orLineDash.Dots = nDots;
diff --git a/oox/source/drawingml/linepropertiescontext.cxx 
b/oox/source/drawingml/linepropertiescontext.cxx
index 3195e56..ee49fba 100644
--- a/oox/source/drawingml/linepropertiescontext.cxx
+++ b/oox/source/drawingml/linepropertiescontext.cxx
@@ -66,8 +66,50 @@ ContextHandlerRef LinePropertiesContext::onCreateContext( 
sal_Int32 nElement, co
 return this;
 break;
 case A_TOKEN( ds ):
-mrLineProperties.maCustomDash.push_back( LineProperties::DashStop(
-rAttribs.getInteger( XML_d, 0 ), rAttribs.getInteger( XML_sp, 
0 ) ) );
+{
+// 'a:ds' has 2 attributes : 'd' and 'sp'
+// both are of type 'a:ST_PositivePercentage'
+// according to the specs Office will read percentages formatted 
with a trailing percent sign
+// or formatted as 1000th of a percent without a trailing percent 
sign, but only write percentages
+// as 1000th's of a percent without a trailing percent sign.
+// The code below takes care of both scenarios by converting to 
'1000th of a percent' always
+OUString aStr;
+sal_Int32 nDash 

[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - include/oox oox/source sd/qa

2014-09-10 Thread Matúš Kukan
 include/oox/drawingml/shape.hxx  |1 
 oox/source/drawingml/fillproperties.cxx  |8 -
 oox/source/drawingml/table/tablecell.cxx |   36 +++---
 sd/qa/unit/data/pptx/bnc480256.pptx  |binary
 sd/qa/unit/import-tests.cxx  |   49 +++
 5 files changed, 88 insertions(+), 6 deletions(-)

New commits:
commit aa653d4e34e2b982caffe4cb9a5f2da3aaa52ed7
Author: Matúš Kukan 
Date:   Tue Sep 9 10:37:23 2014 +0200

bnc#480256: OOXML import: Respect table background properties a bit more

Only getBackgroundFillProperties() (fill) was used.
Use also getBackgroundFillStyleRef() (fillRef).
Also, do not replace table background color value with cell color,
we have to interpolate the two colors (if cell color is transparent).

Unfortunately, we don't use background table property in LibreOffice, so
this seems to be a best workaround.

(cherry picked from commit 43efd9b40d40b791a2c2deedcac36b99f7efb2cf)

And add unit test.
(cherry picked from commit 5681725f1a2535a13b86104d8b8a33f750f34efc)

Change-Id: I21bcc87a149c9f6d865ebee4012132ccc3a54af2
Reviewed-on: https://gerrit.libreoffice.org/11353
Reviewed-by: Miklos Vajna 
Tested-by: Miklos Vajna 

diff --git a/include/oox/drawingml/shape.hxx b/include/oox/drawingml/shape.hxx
index f8e1b7c..1f0411a 100644
--- a/include/oox/drawingml/shape.hxx
+++ b/include/oox/drawingml/shape.hxx
@@ -50,6 +50,7 @@ struct ShapeStyleRef
 {
 Color   maPhClr;
 sal_Int32   mnThemedIdx;
+ShapeStyleRef() : mnThemedIdx(0) {}
 };
 
 typedef ::std::map< sal_Int32, ShapeStyleRef > ShapeStyleRefMap;
diff --git a/oox/source/drawingml/fillproperties.cxx 
b/oox/source/drawingml/fillproperties.cxx
index 330054d..5fc0dd9 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -233,7 +233,13 @@ Color FillProperties::getBestSolidColor() const
 break;
 case XML_gradFill:
 if( !maGradientProps.maGradientStops.empty() )
-aSolidColor = maGradientProps.maGradientStops.begin()->second;
+{
+GradientFillProperties::GradientStopMap::const_iterator 
aGradientStop =
+maGradientProps.maGradientStops.begin();
+if (maGradientProps.maGradientStops.size() > 2)
+++aGradientStop;
+aSolidColor = aGradientStop->second;
+}
 break;
 case XML_pattFill:
 aSolidColor = maPatternProps.maPattBgColor.isUsed() ? 
maPatternProps.maPattBgColor : maPatternProps.maPattFgColor;
diff --git a/oox/source/drawingml/table/tablecell.cxx 
b/oox/source/drawingml/table/tablecell.cxx
index baa1556..2c1fa3c 100644
--- a/oox/source/drawingml/table/tablecell.cxx
+++ b/oox/source/drawingml/table/tablecell.cxx
@@ -21,8 +21,11 @@
 #include "oox/drawingml/table/tableproperties.hxx"
 #include "oox/drawingml/shapepropertymap.hxx"
 #include "oox/drawingml/textbody.hxx"
+#include "oox/drawingml/theme.hxx"
 #include "oox/core/xmlfilterbase.hxx"
 #include "oox/helper/propertyset.hxx"
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -99,7 +102,7 @@ void applyTableStylePart( oox::drawingml::FillProperties& 
rFillProperties,
   oox::drawingml::LineProperties& 
rBottomLeftToTopRightBorder,
   TableStylePart& rTableStylePart )
 {
-boost::shared_ptr< ::oox::drawingml::FillProperties >& 
rPartFillPropertiesPtr( rTableStylePart.getFillProperties() );
+::oox::drawingml::FillPropertiesPtr& rPartFillPropertiesPtr( 
rTableStylePart.getFillProperties() );
 if ( rPartFillPropertiesPtr.get() )
 rFillProperties.assignUsed( *rPartFillPropertiesPtr );
 
@@ -168,10 +171,6 @@ void TableCell::pushToXCell( const 
::oox::core::XmlFilterBase& rFilterBase, ::oo
 oox::drawingml::LineProperties aLinePropertiesTopLeftToBottomRight;
 oox::drawingml::LineProperties aLinePropertiesBottomLeftToTopRight;
 
-boost::shared_ptr< ::oox::drawingml::FillProperties >& 
rBackgroundFillPropertiesPtr( rTable.getBackgroundFillProperties() );
-if ( rBackgroundFillPropertiesPtr.get() )
-aFillProperties.assignUsed( *rBackgroundFillPropertiesPtr );
-
 applyTableStylePart( aFillProperties, aTextStyleProps,
 aLinePropertiesLeft,
 aLinePropertiesRight,
@@ -352,6 +351,33 @@ void TableCell::pushToXCell( const 
::oox::core::XmlFilterBase& rFilterBase, ::oo
 
 aFillProperties.assignUsed( maFillProperties );
 ShapePropertyMap aPropMap( rFilterBase.getModelObjectHelper() );
+
+Color aBgColor;
+sal_Int32 nPhClr = API_RGB_TRANSPARENT;
+boost::shared_ptr< ::oox::drawingml::FillProperties >& 
rBackgroundFillPropertiesPtr( rTable.getBackgroundFillProperties() );
+::oox::drawingml::ShapeStyleRef& rBackgroundFillStyle( 
rTable.getBackgroundFillStyleRef() );
+if (rBackgroundFillPro