filter/inc/filter/msfilter/util.hxx            |    4 +
 filter/source/msfilter/rtfutil.cxx             |    1 
 filter/source/msfilter/util.cxx                |   19 +++++++
 oox/Package_inc.mk                             |    1 
 oox/inc/oox/helper/modelobjecthelper.hxx       |    5 +-
 oox/inc/oox/vml/vmlformatting.hxx              |    2 
 sw/source/filter/ww8/docxattributeoutput.cxx   |   41 ++++------------
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |    7 ++
 writerfilter/source/rtftok/rtfdocumentimpl.hxx |    1 
 writerfilter/source/rtftok/rtfsdrimport.cxx    |   61 ++++++++++++++++++++-----
 writerfilter/source/rtftok/rtfsdrimport.hxx    |    8 ++-
 11 files changed, 101 insertions(+), 49 deletions(-)

New commits:
commit 1bdc4768e277ada3d227516b6d9a00a411a1294f
Author: Miklos Vajna <vmik...@suse.cz>
Date:   Wed Apr 10 18:43:50 2013 +0200

    fix new-style RTF frame default internal margin values
    
    Change-Id: I1a4819905f0fc2e8dbbcf7d9570785ad4384dc39

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx 
b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index ed142bd..f1268f5 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -2561,7 +2561,7 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
                         case RTF_DPTXBX:
                             {
                                 
m_aStates.top().aDrawingObject.xShape.set(getModelFactory()->createInstance("com.sun.star.text.TextFrame"),
 uno::UNO_QUERY);
-                                std::vector<beans::PropertyValue> aDefaults = 
m_pSdrImport->getTextFrameDefaults();
+                                std::vector<beans::PropertyValue> aDefaults = 
m_pSdrImport->getTextFrameDefaults(false);
                                 for (size_t i = 0; i < aDefaults.size(); ++i)
                                     
m_aStates.top().aDrawingObject.aPendingProperties.push_back(aDefaults[i]);
                             }
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx 
b/writerfilter/source/rtftok/rtfsdrimport.cxx
index b0399f6..9fbd3c2 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -75,7 +75,7 @@ void RTFSdrImport::createShape(OUString aStr, 
uno::Reference<drawing::XShape>& x
     xPropertySet.set(xShape, uno::UNO_QUERY);
 }
 
-std::vector<beans::PropertyValue> RTFSdrImport::getTextFrameDefaults()
+std::vector<beans::PropertyValue> RTFSdrImport::getTextFrameDefaults(bool bNew)
 {
     std::vector<beans::PropertyValue> aRet;
     beans::PropertyValue aPropertyValue;
@@ -86,20 +86,24 @@ std::vector<beans::PropertyValue> 
RTFSdrImport::getTextFrameDefaults()
     aPropertyValue.Name = "VertOrient";
     aPropertyValue.Value <<= text::VertOrientation::NONE;
     aRet.push_back(aPropertyValue);
-    aPropertyValue.Name = "BackColorTransparency";
-    aPropertyValue.Value <<= sal_Int32(100);
-    aRet.push_back(aPropertyValue);
+    if (!bNew)
+    {
+        aPropertyValue.Name = "BackColorTransparency";
+        aPropertyValue.Value <<= sal_Int32(100);
+        aRet.push_back(aPropertyValue);
+    }
+    // See the spec, new-style frame default margins are specified in EMUs.
     aPropertyValue.Name = "LeftBorderDistance";
-    aPropertyValue.Value <<= sal_Int32(0);
+    aPropertyValue.Value <<= sal_Int32(bNew ? (91440 / 360) : 0);
     aRet.push_back(aPropertyValue);
     aPropertyValue.Name = "RightBorderDistance";
-    aPropertyValue.Value <<= sal_Int32(0);
+    aPropertyValue.Value <<= sal_Int32(bNew ? (91440 / 360) : 0);
     aRet.push_back(aPropertyValue);
     aPropertyValue.Name = "TopBorderDistance";
-    aPropertyValue.Value <<= sal_Int32(0);
+    aPropertyValue.Value <<= sal_Int32(bNew ? (45720 / 360) : 0);
     aRet.push_back(aPropertyValue);
     aPropertyValue.Name = "BottomBorderDistance";
-    aPropertyValue.Value <<= sal_Int32(0);
+    aPropertyValue.Value <<= sal_Int32(bNew ? (45720 / 360) : 0);
     aRet.push_back(aPropertyValue);
     aPropertyValue.Name = "SizeType";
     aPropertyValue.Value <<= text::SizeType::FIX;
@@ -161,7 +165,7 @@ void RTFSdrImport::resolve(RTFShape& rShape)
                     {
                         createShape("com.sun.star.text.TextFrame", xShape, 
xPropertySet);
                         bTextFrame = true;
-                        std::vector<beans::PropertyValue> aDefaults = 
getTextFrameDefaults();
+                        std::vector<beans::PropertyValue> aDefaults = 
getTextFrameDefaults(true);
                         for (size_t j = 0; j < aDefaults.size(); ++j)
                             xPropertySet->setPropertyValue(aDefaults[j].Name, 
aDefaults[j].Value);
                     }
@@ -205,8 +209,6 @@ void RTFSdrImport::resolve(RTFShape& rShape)
 
             // fillType will decide, possible it'll be the start color of a 
gradient.
             aFillModel.moColor.set(OUString("#") + 
OStringToOUString(msfilter::util::ConvertColor(aAny.get<sal_Int32>()), 
RTL_TEXTENCODING_UTF8));
-
-            xPropertySet->setPropertyValue("BackColorTransparency", 
uno::makeAny(sal_Int32(0)));
         }
         else if ( i->first == "fillBackColor" )
             // fillType will decide, possible it'll be the end color of a 
gradient.
diff --git a/writerfilter/source/rtftok/rtfsdrimport.hxx 
b/writerfilter/source/rtftok/rtfsdrimport.hxx
index 6c39fbc..984f287 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.hxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.hxx
@@ -43,8 +43,12 @@ namespace writerfilter {
                 void resolve(RTFShape& rShape);
                 void resolveDhgt(uno::Reference<beans::XPropertySet> 
xPropertySet, sal_Int32 nZOrder);
                 void resolveFLine(uno::Reference<beans::XPropertySet> 
xPropertySet, sal_Int32 nFLine);
-                /// These are the default in Word, but not in Writer.
-                std::vector<beans::PropertyValue> getTextFrameDefaults();
+                /**
+                 * These are the default in Word, but not in Writer.
+                 *
+                 * @param bNew if the frame is new-style or old-style.
+                 */
+                std::vector<beans::PropertyValue> getTextFrameDefaults(bool 
bNew);
             private:
                 void createShape(OUString aService, 
uno::Reference<drawing::XShape>& xShape, uno::Reference<beans::XPropertySet>& 
xPropertySet);
 
commit 55131d409d903496b9d6ec5dee39e33983bf1043
Author: Miklos Vajna <vmik...@suse.cz>
Date:   Wed Apr 10 18:17:00 2013 +0200

    add msfilter::util::ConvertColor to avoid copy&paste
    
    Change-Id: Ia5507f8d1ec18a45d3128c809d03f8f41849f93c

diff --git a/filter/inc/filter/msfilter/util.hxx 
b/filter/inc/filter/msfilter/util.hxx
index 1104295..c3b5688 100644
--- a/filter/inc/filter/msfilter/util.hxx
+++ b/filter/inc/filter/msfilter/util.hxx
@@ -31,6 +31,7 @@
 
 #include <rtl/textenc.h>
 #include <tools/datetime.hxx>
+#include <tools/color.hxx>
 #include <com/sun/star/lang/Locale.hpp>
 #include "filter/msfilter/msfilterdllapi.h"
 
@@ -88,6 +89,9 @@ enum TextCategory
 */
 MSFILTER_DLLPUBLIC TextCategory categorizeCodePoint(sal_uInt32 codePoint, 
const OUString &rBcp47LanguageTag);
 
+/// Converts tools Color to HTML color (without leading hashmark).
+MSFILTER_DLLPUBLIC OString ConvertColor( const Color &rColor );
+
 }
 }
 
diff --git a/filter/source/msfilter/rtfutil.cxx 
b/filter/source/msfilter/rtfutil.cxx
index 3e2dfb0..050a2f2 100644
--- a/filter/source/msfilter/rtfutil.cxx
+++ b/filter/source/msfilter/rtfutil.cxx
@@ -181,7 +181,6 @@ OString OutStringUpr(const sal_Char *pToken, const String 
&rStr, rtl_TextEncodin
     aRet.append("}}}");
     return aRet.makeStringAndClear();
 }
-
 }
 }
 
diff --git a/filter/source/msfilter/util.cxx b/filter/source/msfilter/util.cxx
index ca11120..3fec6da 100644
--- a/filter/source/msfilter/util.cxx
+++ b/filter/source/msfilter/util.cxx
@@ -306,6 +306,25 @@ TextCategory categorizeCodePoint(sal_uInt32 codePoint, 
const OUString &rBcp47Lan
     return eRet;
 }
 
+OString ConvertColor( const Color &rColor )
+{
+    OString color( "auto" );
+    if ( rColor.GetColor() != COL_AUTO )
+    {
+        const char pHexDigits[] = "0123456789ABCDEF";
+        char pBuffer[] = "000000";
+
+        pBuffer[0] = pHexDigits[ ( rColor.GetRed()   >> 4 ) & 0x0F ];
+        pBuffer[1] = pHexDigits[   rColor.GetRed()          & 0x0F ];
+        pBuffer[2] = pHexDigits[ ( rColor.GetGreen() >> 4 ) & 0x0F ];
+        pBuffer[3] = pHexDigits[   rColor.GetGreen()        & 0x0F ];
+        pBuffer[4] = pHexDigits[ ( rColor.GetBlue()  >> 4 ) & 0x0F ];
+        pBuffer[5] = pHexDigits[   rColor.GetBlue()         & 0x0F ];
+
+        color = OString( pBuffer );
+    }
+    return color;
+}
 }
 }
 
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 5f5934f..86058dd 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -191,7 +191,6 @@ class FieldMarkParamsHelper
         return bResult;
     }
 };
-static OString impl_ConvertColor( const Color &rColor );
 void DocxAttributeOutput::RTLAndCJKState( bool bIsRTL, sal_uInt16 /*nScript*/ )
 {
     if (bIsRTL)
@@ -276,7 +275,7 @@ void lcl_TextFrameShadow(FSHelperPtr pSerializer, const 
SwFrmFmt& rFrmFmt)
     if (aOffset.isEmpty())
         return;
 
-    OString aShadowColor = impl_ConvertColor(aShadowItem.GetColor());
+    OString aShadowColor = 
msfilter::util::ConvertColor(aShadowItem.GetColor());
     pSerializer->singleElementNS(XML_v, XML_shadow,
             XML_on, "t",
             XML_color, "#" + aShadowColor,
@@ -1400,26 +1399,6 @@ void DocxAttributeOutput::ParagraphStyle( sal_uInt16 
nStyle )
     m_pSerializer->singleElementNS( XML_w, XML_pStyle, FSNS( XML_w, XML_val ), 
aStyleId.getStr(), FSEND );
 }
 
-static OString impl_ConvertColor( const Color &rColor )
-{
-    OString color( "auto" );
-    if ( rColor.GetColor() != COL_AUTO )
-    {
-        const char pHexDigits[] = "0123456789ABCDEF";
-        char pBuffer[] = "000000";
-
-        pBuffer[0] = pHexDigits[ ( rColor.GetRed()   >> 4 ) & 0x0F ];
-        pBuffer[1] = pHexDigits[   rColor.GetRed()          & 0x0F ];
-        pBuffer[2] = pHexDigits[ ( rColor.GetGreen() >> 4 ) & 0x0F ];
-        pBuffer[3] = pHexDigits[   rColor.GetGreen()        & 0x0F ];
-        pBuffer[4] = pHexDigits[ ( rColor.GetBlue()  >> 4 ) & 0x0F ];
-        pBuffer[5] = pHexDigits[   rColor.GetBlue()         & 0x0F ];
-
-        color = OString( pBuffer );
-    }
-    return color;
-}
-
 static void impl_borderLine( FSHelperPtr pSerializer, sal_Int32 elementToken, 
const SvxBorderLine* pBorderLine, sal_uInt16 nDist )
 {
     FastAttributeList* pAttr = pSerializer->createAttrList();
@@ -1512,7 +1491,7 @@ static void impl_borderLine( FSHelperPtr pSerializer, 
sal_Int32 elementToken, co
         pAttr->add( FSNS( XML_w, XML_space ), OString::valueOf( sal_Int32( 
nDist / 20 ) ) );
 
         // Get the color code as an RRGGBB hex value
-        OString sColor( impl_ConvertColor( pBorderLine->GetColor( ) ) );
+        OString sColor( msfilter::util::ConvertColor( pBorderLine->GetColor( ) 
) );
         pAttr->add( FSNS( XML_w, XML_color ), sColor );
     }
 
@@ -1932,7 +1911,7 @@ void DocxAttributeOutput::TableBackgrounds( 
ww8::WW8TableNodeInfoInner::Pointer_
     else
         aColor = COL_AUTO;
 
-    OString sColor = impl_ConvertColor( aColor );
+    OString sColor = msfilter::util::ConvertColor( aColor );
     m_pSerializer->singleElementNS( XML_w, XML_shd,
             FSNS( XML_w, XML_fill ), sColor.getStr( ),
             FSNS( XML_w, XML_val ), "clear",
@@ -2397,7 +2376,7 @@ void DocxAttributeOutput::FlyFrameGraphic( const 
SwGrfNode* pGrfNode, const Size
         // Distance is measured diagonally from corner
         double nShadowDist = 
sqrt((aShadowItem.GetWidth()*aShadowItem.GetWidth())*2.0);
         OString aShadowDist( OString::valueOf( TwipsToEMU( nShadowDist ) ) );
-        OString aShadowColor = impl_ConvertColor( aShadowItem.GetColor() );
+        OString aShadowColor = msfilter::util::ConvertColor( 
aShadowItem.GetColor() );
         sal_uInt32 nShadowDir = 0;
         switch ( aShadowItem.GetLocation() )
         {
@@ -3356,7 +3335,7 @@ void DocxAttributeOutput::CharColor( const SvxColorItem& 
rColor )
     const Color aColor( rColor.GetValue() );
     OString aColorString;
 
-    aColorString = impl_ConvertColor( aColor );
+    aColorString = msfilter::util::ConvertColor( aColor );
 
     m_pSerializer->singleElementNS( XML_w, XML_color,
             FSNS( XML_w, XML_val ), aColorString.getStr(), FSEND );
@@ -3553,7 +3532,7 @@ void DocxAttributeOutput::CharAnimatedText( const 
SvxBlinkItem& rBlink )
 void DocxAttributeOutput::CharBackground( const SvxBrushItem& rBrush )
 {
     m_pSerializer->singleElementNS( XML_w, XML_shd,
-            FSNS( XML_w, XML_fill ), impl_ConvertColor( rBrush.GetColor() 
).getStr(),
+            FSNS( XML_w, XML_fill ), msfilter::util::ConvertColor( 
rBrush.GetColor() ).getStr(),
             FSNS( XML_w, XML_val ), "clear",
             FSEND );
 }
@@ -4623,7 +4602,7 @@ void DocxAttributeOutput::FormatAnchor( const 
SwFmtAnchor& )
 
 void DocxAttributeOutput::FormatBackground( const SvxBrushItem& rBrush )
 {
-    OString sColor = impl_ConvertColor( rBrush.GetColor( ) );
+    OString sColor = msfilter::util::ConvertColor( rBrush.GetColor( ) );
     if (m_bTextFrameSyntax)
         m_pFlyAttrList->add(XML_fillcolor, "#" + sColor);
     else if ( !m_rExport.bOutPageDescs )
@@ -4648,9 +4627,9 @@ void DocxAttributeOutput::FormatFillGradient( const 
XFillGradientItem& rFillGrad
         m_pFlyFillAttrList->add(XML_type, "gradient");
 
         const XGradient& rGradient = rFillGradient.GetGradientValue();
-        OString sStartColor = impl_ConvertColor(rGradient.GetStartColor());
+        OString sStartColor = 
msfilter::util::ConvertColor(rGradient.GetStartColor());
         m_pFlyFillAttrList->add(XML_color2, "#" + sStartColor);
-        OString sEndColor = impl_ConvertColor(rGradient.GetEndColor());
+        OString sEndColor = 
msfilter::util::ConvertColor(rGradient.GetEndColor());
         m_pFlyAttrList->add(XML_fillcolor, "#" + sEndColor);
 
         switch (rGradient.GetGradientStyle())
@@ -4679,7 +4658,7 @@ void DocxAttributeOutput::FormatBox( const SvxBoxItem& 
rBox )
         if (pLeft && pRight && pTop && pBottom &&
                 *pLeft == *pRight && *pLeft == *pTop && *pLeft == *pBottom)
         {
-            OString sColor("#" + impl_ConvertColor(pTop->GetColor()));
+            OString sColor("#" + 
msfilter::util::ConvertColor(pTop->GetColor()));
             m_pFlyAttrList->add(XML_strokecolor, sColor);
 
             double const 
fConverted(editeng::ConvertBorderWidthToWord(pTop->GetBorderLineStyle(), 
pTop->GetWidth()));
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx 
b/writerfilter/source/rtftok/rtfsdrimport.cxx
index a85cb50..b0399f6 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -121,26 +121,6 @@ void 
RTFSdrImport::resolveFLine(uno::Reference<beans::XPropertySet> xPropertySet
         xPropertySet->setPropertyValue("LineStyle", 
uno::makeAny(drawing::LineStyle_NONE));
 }
 
-static OString impl_ConvertColor( const Color &rColor )
-{
-    OString color( "auto" );
-    if ( rColor.GetColor() != COL_AUTO )
-    {
-        const char pHexDigits[] = "0123456789ABCDEF";
-        char pBuffer[] = "000000";
-
-        pBuffer[0] = pHexDigits[ ( rColor.GetRed()   >> 4 ) & 0x0F ];
-        pBuffer[1] = pHexDigits[   rColor.GetRed()          & 0x0F ];
-        pBuffer[2] = pHexDigits[ ( rColor.GetGreen() >> 4 ) & 0x0F ];
-        pBuffer[3] = pHexDigits[   rColor.GetGreen()        & 0x0F ];
-        pBuffer[4] = pHexDigits[ ( rColor.GetBlue()  >> 4 ) & 0x0F ];
-        pBuffer[5] = pHexDigits[   rColor.GetBlue()         & 0x0F ];
-
-        color = OString( pBuffer );
-    }
-    return color;
-}
-
 void RTFSdrImport::resolve(RTFShape& rShape)
 {
     int nType = -1;
@@ -224,13 +204,13 @@ void RTFSdrImport::resolve(RTFShape& rShape)
                 xPropertySet->setPropertyValue("FillColor", aAny);
 
             // fillType will decide, possible it'll be the start color of a 
gradient.
-            aFillModel.moColor.set(OUString("#") + 
OStringToOUString(impl_ConvertColor(aAny.get<sal_Int32>()), 
RTL_TEXTENCODING_UTF8));
+            aFillModel.moColor.set(OUString("#") + 
OStringToOUString(msfilter::util::ConvertColor(aAny.get<sal_Int32>()), 
RTL_TEXTENCODING_UTF8));
 
             xPropertySet->setPropertyValue("BackColorTransparency", 
uno::makeAny(sal_Int32(0)));
         }
         else if ( i->first == "fillBackColor" )
             // fillType will decide, possible it'll be the end color of a 
gradient.
-            aFillModel.moColor2.set(OUString("#") + 
OStringToOUString(impl_ConvertColor(msfilter::util::BGRToRGB(i->second.toInt32())),
 RTL_TEXTENCODING_UTF8));
+            aFillModel.moColor2.set(OUString("#") + 
OStringToOUString(msfilter::util::ConvertColor(msfilter::util::BGRToRGB(i->second.toInt32())),
 RTL_TEXTENCODING_UTF8));
         else if (i->first == "lineColor")
             aLineColor <<= msfilter::util::BGRToRGB(i->second.toInt32());
         else if ( i->first == "lineBackColor" )
commit 24ee3df385cf2aa95cd888581c84fdf90cc682dc
Author: Miklos Vajna <vmik...@suse.cz>
Date:   Wed Apr 10 17:55:22 2013 +0200

    RTF import: fix priority handling of shpz vs dhgt
    
    \shpz is the older markup, dhgt shape property is the newer one. When
    having both, dhgt should have priority.
    
    Change-Id: I11904315d13fa23999badad26be26852719dbb3b

diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx 
b/writerfilter/source/rtftok/rtfsdrimport.cxx
index 9af90c4..a85cb50 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -373,7 +373,11 @@ void RTFSdrImport::resolve(RTFShape& rShape)
         else if ( i->first == "geoBottom" )
             aViewBox.Height = i->second.toInt32();
         else if ( i->first == "dhgt" )
+        {
             resolveDhgt(xPropertySet, i->second.toInt32());
+            // dhgt is Word 2007, \shpz is Word 97-2003, the previous has 
priority.
+            rShape.oZ.reset();
+        }
         // These are in EMU, convert to mm100.
         else if (i->first == "dxTextLeft")
             xPropertySet->setPropertyValue("LeftBorderDistance", 
uno::makeAny(i->second.toInt32() / 360));
commit 36be517a07fe0f18490c6c81b74463364bad9416
Author: Miklos Vajna <vmik...@suse.cz>
Date:   Wed Apr 10 16:19:34 2013 +0200

    RTF import of fillType and fillFocus shape properties
    
    Change-Id: I2043477aebbe2e4f9afc48a68dcf7d2b18fa6613

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx 
b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 1df9d61..ed142bd 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -617,6 +617,11 @@ RTFBuffer_t RTFDocumentImpl::getShapetextBuffer()
     return m_aShapetextBuffer;
 }
 
+oox::GraphicHelper& RTFDocumentImpl::getGraphicHelper()
+{
+    return *m_pGraphicHelper;
+}
+
 void RTFDocumentImpl::resolve(Stream & rMapper)
 {
     m_pMapperStream = &rMapper;
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx 
b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 8ebf601..d3937d2 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -480,6 +480,7 @@ namespace writerfilter {
                 RTFParserState& getDefaultState();
                 /// Get the shape text buffer;
                 RTFBuffer_t getShapetextBuffer();
+                oox::GraphicHelper& getGraphicHelper();
 
             private:
                 SvStream& Strm();
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx 
b/writerfilter/source/rtftok/rtfsdrimport.cxx
index 15f54f4..9af90c4 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -47,6 +47,10 @@
 #include "../dmapper/GraphicHelpers.hxx"
 #include <rtfsdrimport.hxx>
 
+#include <oox/vml/vmlformatting.hxx>
+#include <oox/helper/modelobjecthelper.hxx>
+#include <oox/drawingml/shapepropertymap.hxx>
+#include <oox/helper/propertyset.hxx>
 
 namespace writerfilter {
 namespace rtftok {
@@ -117,6 +121,26 @@ void 
RTFSdrImport::resolveFLine(uno::Reference<beans::XPropertySet> xPropertySet
         xPropertySet->setPropertyValue("LineStyle", 
uno::makeAny(drawing::LineStyle_NONE));
 }
 
+static OString impl_ConvertColor( const Color &rColor )
+{
+    OString color( "auto" );
+    if ( rColor.GetColor() != COL_AUTO )
+    {
+        const char pHexDigits[] = "0123456789ABCDEF";
+        char pBuffer[] = "000000";
+
+        pBuffer[0] = pHexDigits[ ( rColor.GetRed()   >> 4 ) & 0x0F ];
+        pBuffer[1] = pHexDigits[   rColor.GetRed()          & 0x0F ];
+        pBuffer[2] = pHexDigits[ ( rColor.GetGreen() >> 4 ) & 0x0F ];
+        pBuffer[3] = pHexDigits[   rColor.GetGreen()        & 0x0F ];
+        pBuffer[4] = pHexDigits[ ( rColor.GetBlue()  >> 4 ) & 0x0F ];
+        pBuffer[5] = pHexDigits[   rColor.GetBlue()         & 0x0F ];
+
+        color = OString( pBuffer );
+    }
+    return color;
+}
+
 void RTFSdrImport::resolve(RTFShape& rShape)
 {
     int nType = -1;
@@ -137,6 +161,8 @@ void RTFSdrImport::resolve(RTFShape& rShape)
     // Default line width is 0.75 pt (26 mm100) in Word, 0 in Writer.
     uno::Any aLineWidth = uno::makeAny(sal_Int32(26));
     text::WritingMode eWritingMode = text::WritingMode_LR_TB;
+    // Used for gradients, let the VML import do the hard work.
+    oox::vml::FillModel aFillModel;
 
     for (std::vector< std::pair<OUString, OUString> >::iterator i = 
rShape.aProperties.begin();
             i != rShape.aProperties.end(); ++i)
@@ -196,10 +222,15 @@ void RTFSdrImport::resolve(RTFShape& rShape)
                 xPropertySet->setPropertyValue("BackColor", aAny);
             else
                 xPropertySet->setPropertyValue("FillColor", aAny);
+
+            // fillType will decide, possible it'll be the start color of a 
gradient.
+            aFillModel.moColor.set(OUString("#") + 
OStringToOUString(impl_ConvertColor(aAny.get<sal_Int32>()), 
RTL_TEXTENCODING_UTF8));
+
             xPropertySet->setPropertyValue("BackColorTransparency", 
uno::makeAny(sal_Int32(0)));
         }
         else if ( i->first == "fillBackColor" )
-            ; // Ignore: complementer of fillColor
+            // fillType will decide, possible it'll be the end color of a 
gradient.
+            aFillModel.moColor2.set(OUString("#") + 
OStringToOUString(impl_ConvertColor(msfilter::util::BGRToRGB(i->second.toInt32())),
 RTL_TEXTENCODING_UTF8));
         else if (i->first == "lineColor")
             aLineColor <<= msfilter::util::BGRToRGB(i->second.toInt32());
         else if ( i->first == "lineBackColor" )
@@ -360,6 +391,20 @@ void RTFSdrImport::resolve(RTFShape& rShape)
             xPropertySet->setPropertyValue("RightMargin", 
uno::makeAny(i->second.toInt32() / 360));
         else if (i->first == "dyWrapDistBottom")
             xPropertySet->setPropertyValue("BottomMargin", 
uno::makeAny(i->second.toInt32() / 360));
+        else if (i->first == "fillType")
+        {
+            switch (i->second.toInt32())
+            {
+                case 7: // Shade using the fillAngle
+                    aFillModel.moType.set(oox::XML_gradient);
+                break;
+                default:
+                    SAL_INFO("writerfilter", "TODO handle fillType value '" << 
i->second << "'");
+                break;
+            }
+        }
+        else if (i->first == "fillFocus")
+            aFillModel.moFocus.set(i->second.toDouble() / 100); // percent
         else
             SAL_INFO("writerfilter", "TODO handle shape property '" << 
i->first << "':'" << i->second << "'");
     }
@@ -439,6 +484,14 @@ void RTFSdrImport::resolve(RTFShape& rShape)
             xPropertySet->setPropertyValue("VertOrientRelation", 
uno::makeAny(rShape.nVertOrientRelation));
         if (rShape.nWrap != -1)
             xPropertySet->setPropertyValue("Surround", 
uno::makeAny(text::WrapTextMode(rShape.nWrap)));
+        if (aFillModel.moType.has())
+        {
+            oox::ModelObjectHelper 
aModelObjectHelper(m_rImport.getModelFactory());
+            oox::drawingml::ShapePropertyMap aPropMap(aModelObjectHelper);
+            aFillModel.pushToPropMap(aPropMap, m_rImport.getGraphicHelper());
+            // Sets the FillStyle and FillGradient UNO properties.
+            oox::PropertySet(xShape).setProperties(aPropMap);
+        }
     }
 
     // Send it to dmapper
commit 1c2bae45d39aa75e6387ed652d911ff778e517ce
Author: Miklos Vajna <vmik...@suse.cz>
Date:   Wed Apr 10 15:14:20 2013 +0200

    oox: make these classes public
    
    They were already declared in oox/inc/oox/*, but one header wasn't
    delivered, the rest wasn't visible outside the library. Having them
    public makes it possible to re-use them from writerfilter, e.g. in the
    RTF gradient import code.
    
    Change-Id: I13d8c860b2582489d216fd68295f230d5c98f31b

diff --git a/oox/Package_inc.mk b/oox/Package_inc.mk
index 517cc83..b6bd76a 100644
--- a/oox/Package_inc.mk
+++ b/oox/Package_inc.mk
@@ -84,6 +84,7 @@ $(eval $(call 
gb_Package_add_file,oox_inc,inc/oox/helper/propertymap.hxx,oox/hel
 $(eval $(call 
gb_Package_add_file,oox_inc,inc/oox/helper/propertyset.hxx,oox/helper/propertyset.hxx))
 $(eval $(call 
gb_Package_add_file,oox_inc,inc/oox/helper/attributelist.hxx,oox/helper/attributelist.hxx))
 $(eval $(call 
gb_Package_add_file,oox_inc,inc/oox/helper/progressbar.hxx,oox/helper/progressbar.hxx))
+$(eval $(call 
gb_Package_add_file,oox_inc,inc/oox/helper/modelobjecthelper.hxx,oox/helper/modelobjecthelper.hxx))
 $(eval $(call 
gb_Package_add_file,oox_inc,inc/oox/mathml/export.hxx,oox/mathml/export.hxx))
 $(eval $(call 
gb_Package_add_file,oox_inc,inc/oox/mathml/import.hxx,oox/mathml/import.hxx))
 $(eval $(call 
gb_Package_add_file,oox_inc,inc/oox/mathml/importutils.hxx,oox/mathml/importutils.hxx))
diff --git a/oox/inc/oox/helper/modelobjecthelper.hxx 
b/oox/inc/oox/helper/modelobjecthelper.hxx
index 98b34aa..253279a 100644
--- a/oox/inc/oox/helper/modelobjecthelper.hxx
+++ b/oox/inc/oox/helper/modelobjecthelper.hxx
@@ -21,6 +21,7 @@
 #define OOX_HELPER_MODELOBJECTHELPER_HXX
 
 #include <com/sun/star/uno/Reference.hxx>
+#include "oox/dllapi.h"
 
 namespace com { namespace sun { namespace star {
     namespace awt { struct Gradient; }
@@ -36,7 +37,7 @@ namespace oox {
 
 /** This helper manages named objects in a container, which is created on 
demand.
  */
-class ObjectContainer
+class OOX_DLLPUBLIC ObjectContainer
 {
 public:
     explicit            ObjectContainer(
@@ -74,7 +75,7 @@ private:
     in the same filter (e.g. embedded charts) which carry their own drawing
     object tables.
  */
-class ModelObjectHelper
+class OOX_DLLPUBLIC ModelObjectHelper
 {
 public:
     explicit            ModelObjectHelper(
diff --git a/oox/inc/oox/vml/vmlformatting.hxx 
b/oox/inc/oox/vml/vmlformatting.hxx
index 91356e3..b7b9e6a 100644
--- a/oox/inc/oox/vml/vmlformatting.hxx
+++ b/oox/inc/oox/vml/vmlformatting.hxx
@@ -200,7 +200,7 @@ struct StrokeModel
 // ============================================================================
 
 /** The fill model structure contains all shape fill properties. */
-struct FillModel
+struct OOX_DLLPUBLIC FillModel
 {
     OptValue< bool >    moFilled;               ///< Shape fill on/off.
     OptValue< OUString > moColor;        ///< Solid fill color.
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to