[Libreoffice-commits] core.git: 2 commits - sw/qa sw/source
Miklos Vajna
vmiklos at suse.cz
Mon Apr 15 07:06:18 PDT 2013
sw/qa/extras/rtfexport/data/textframe-gradient.rtf | 161 +++++++++++++++++++++
sw/qa/extras/rtfexport/rtfexport.cxx | 25 +++
sw/source/filter/ww8/rtfattributeoutput.cxx | 29 +++
sw/source/filter/ww8/rtfattributeoutput.hxx | 5
4 files changed, 218 insertions(+), 2 deletions(-)
New commits:
commit 92da8fc4ebad92a3667e3534db173ab7232c8048
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Mon Apr 15 15:49:35 2013 +0200
sw: add textframe gradient RTF roundtrip testcase
Change-Id: I8e4f6b926123c79ad1a62ddd4c5feebf5fe06cf0
diff --git a/sw/qa/extras/rtfexport/data/textframe-gradient.rtf b/sw/qa/extras/rtfexport/data/textframe-gradient.rtf
new file mode 100644
index 0000000..67001da
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/textframe-gradient.rtf
@@ -0,0 +1,161 @@
+{\rtf1
+{\shp
+{\*\shpinst\shpleft-540\shptop152\shpright9900\shpbottom1592\shpfhdr0\shpbxcolumn\shpbxignore\shpbypara\shpbyignore\shpwr3\shpwrk0\shpfblwtxt0\shpz0\shplid1026
+{\sp
+{\sn shapeType}
+{\sv 1}
+}
+{\sp
+{\sn fFlipH}
+{\sv 0}
+}
+{\sp
+{\sn fFlipV}
+{\sv 0}
+}
+{\sp
+{\sn lTxid}
+{\sv 65536}
+}
+{\sp
+{\sn hspNext}
+{\sv 1026}
+}
+{\sp
+{\sn fillType}
+{\sv 7}
+}
+{\sp
+{\sn fillColor}
+{\sv 9737689}
+}
+{\sp
+{\sn fillBackColor}
+{\sv 5066944}
+}
+{\sp
+{\sn fillFocus}
+{\sv 50}
+}
+{\sp
+{\sn lineColor}
+{\sv 5066944}
+}
+{\sp
+{\sn lineWidth}
+{\sv 12700}
+}
+{\sp
+{\sn shadowType}
+{\sv 2}
+}
+{\sp
+{\sn shadowColor}
+{\sv 2303074}
+}
+{\sp
+{\sn shadowOffsetX}
+{\sv 12700}
+}
+{\sp
+{\sn shadowSecondOffsetX}
+{\sv -38100}
+}
+{\sp
+{\sn fShadow}
+{\sv 1}
+}
+{\sp
+{\sn dhgt}
+{\sv 251660288}
+}
+{\sp
+{\sn fLayoutInCell}
+{\sv 1}
+}
+{\shptxt foo
+\par
+}
+}
+}
+\par
+{\shp
+{\*\shpinst\shpleft5760\shptop90\shpright9840\shpbottom1170\shpfhdr0\shpbxcolumn\shpbxignore\shpbypara\shpbyignore\shpwr2\shpwrk0\shpfblwtxt0\shpz1\shplid1027
+{\sp
+{\sn shapeType}
+{\sv 202}
+}
+{\sp
+{\sn fFlipH}
+{\sv 0}
+}
+{\sp
+{\sn fFlipV}
+{\sv 0}
+}
+{\sp
+{\sn lTxid}
+{\sv 131072}
+}
+{\sp
+{\sn hspNext}
+{\sv 1027}
+}
+{\sp
+{\sn fillType}
+{\sv 7}
+}
+{\sp
+{\sn fillColor}
+{\sv 6710886}
+}
+{\sp
+{\sn fillBackColor}
+{\sv 0}
+}
+{\sp
+{\sn fillFocus}
+{\sv 50}
+}
+{\sp
+{\sn lineColor}
+{\sv 0}
+}
+{\sp
+{\sn lineWidth}
+{\sv 12700}
+}
+{\sp
+{\sn shadowType}
+{\sv 2}
+}
+{\sp
+{\sn shadowColor}
+{\sv 8355711}
+}
+{\sp
+{\sn shadowOffsetX}
+{\sv 12700}
+}
+{\sp
+{\sn shadowSecondOffsetX}
+{\sv -38100}
+}
+{\sp
+{\sn fShadow}
+{\sv 1}
+}
+{\sp
+{\sn dhgt}
+{\sv 251661312}
+}
+{\sp
+{\sn fLayoutInCell}
+{\sv 1}
+}
+{\shptxt bar
+\par }
+}
+}
+\par
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index f9ca432..a9889b7 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -25,8 +25,10 @@
* instead of those above.
*/
+#include <com/sun/star/awt/Gradient.hpp>
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
#include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
+#include <com/sun/star/drawing/FillStyle.hpp>
#include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/table/BorderLine2.hpp>
#include <com/sun/star/table/ShadowFormat.hpp>
@@ -80,6 +82,7 @@ public:
void testBookmark();
void testHyperlink();
void testTextFrameBorders();
+ void testTextframeGradient();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -132,6 +135,7 @@ void Test::run()
{"bookmark.rtf", &Test::testBookmark},
{"hyperlink.rtf", &Test::testHyperlink},
{"textframe-borders.rtf", &Test::testTextFrameBorders},
+ {"textframe-gradient.rtf", &Test::testTextframeGradient},
};
// Don't test the first import of these, for some reason those tests fail
const char* aBlacklist[] = {
@@ -578,6 +582,27 @@ void Test::testTextFrameBorders()
CPPUNIT_ASSERT_EQUAL(sal_Int32(0x622423), aShadowFormat.Color);
}
+void Test::testTextframeGradient()
+{
+ uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount());
+
+ uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame, "FillStyle"));
+ awt::Gradient aGradient = getProperty<awt::Gradient>(xFrame, "FillGradient");
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0xC0504D), aGradient.StartColor);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0xD99594), aGradient.EndColor);
+ CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL, aGradient.Style);
+
+ xFrame.set(xIndexAccess->getByIndex(1), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame, "FillStyle"));
+ aGradient = getProperty<awt::Gradient>(xFrame, "FillGradient");
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0x000000), aGradient.StartColor);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0x666666), aGradient.EndColor);
+ CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL, aGradient.Style);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
commit d3f7925ccc962eb9adc31fb2174fa18de4b31c0a
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Mon Apr 15 15:20:14 2013 +0200
initial RTF export of Writer textframe gradients
Change-Id: Ida9774a41964dbeb8840e79425811993a28588af
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index f645c87..6277676 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -72,6 +72,7 @@
#include <filter/msfilter/rtfutil.hxx>
#include <svtools/miscopt.hxx>
#include <sfx2/sfxbasemodel.hxx>
+#include <svx/xflgrit.hxx>
#include <docufld.hxx>
#include <fmtclds.hxx>
@@ -2963,12 +2964,36 @@ void RtfAttributeOutput::FormatBackground( const SvxBrushItem& rBrush )
}
}
-void RtfAttributeOutput::FormatFillStyle( const XFillStyleItem& /*rFillStyle*/ )
+void RtfAttributeOutput::FormatFillStyle( const XFillStyleItem& rFillStyle )
{
+ m_oFillStyle.reset(rFillStyle.GetValue());
}
-void RtfAttributeOutput::FormatFillGradient( const XFillGradientItem& /*rFillGradient*/ )
+void RtfAttributeOutput::FormatFillGradient( const XFillGradientItem& rFillGradient )
{
+ if (*m_oFillStyle == XFILL_GRADIENT)
+ {
+ m_aFlyProperties.push_back(std::make_pair<OString, OString>("fillType", OString::number(7))); // Shade using the fillAngle
+
+ const XGradient& rGradient = rFillGradient.GetGradientValue();
+ const Color& rStartColor = rGradient.GetStartColor();
+ m_aFlyProperties.push_back(std::make_pair<OString, OString>("fillBackColor", OString::number(msfilter::util::BGRToRGB(rStartColor.GetColor()))));
+
+ const Color& rEndColor = rGradient.GetEndColor();
+ m_aFlyProperties.push_back(std::make_pair<OString, OString>("fillColor", OString::number(msfilter::util::BGRToRGB(rEndColor.GetColor()))));
+
+ switch (rGradient.GetGradientStyle())
+ {
+ case XGRAD_LINEAR: break;
+ case XGRAD_AXIAL:
+ m_aFlyProperties.push_back(std::make_pair<OString, OString>("fillFocus", OString::number(50)));
+ break;
+ case XGRAD_RADIAL: break;
+ case XGRAD_ELLIPTICAL: break;
+ case XGRAD_SQUARE: break;
+ case XGRAD_RECT: break;
+ }
+ }
}
void RtfAttributeOutput::FormatBox( const SvxBoxItem& rBox )
diff --git a/sw/source/filter/ww8/rtfattributeoutput.hxx b/sw/source/filter/ww8/rtfattributeoutput.hxx
index 9035b55..b13be12 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.hxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.hxx
@@ -25,6 +25,9 @@
#include "rtfstringbuffer.hxx"
#include <rtl/strbuf.hxx>
+#include <svx/xenum.hxx>
+
+#include <boost/optional.hpp>
class SwGrfNode;
class SwOLENode;
@@ -557,6 +560,8 @@ private:
std::vector< std::pair<OString, OString> > m_aFlyProperties;
+ boost::optional<XFillStyle> m_oFillStyle;
+
public:
RtfAttributeOutput( RtfExport &rExport );
More information about the Libreoffice-commits
mailing list