[Libreoffice-commits] .: 4 commits - sw/qa sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Jan 22 07:10:37 PST 2013
sw/qa/extras/ooxmlexport/data/textframe-borders.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 20 ++++++
sw/source/filter/ww8/docxattributeoutput.cxx | 59 ++++++++++++++++++-
3 files changed, 76 insertions(+), 3 deletions(-)
New commits:
commit 77479d619b3d22fc521be87a98587f031382b156
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Tue Jan 22 16:04:29 2013 +0100
sw: DOCX export of TextFrame border/shadow testcase
Change-Id: I26be6fbd5f0cd95218cdd7235e1fc10eeafb6704
diff --git a/sw/qa/extras/ooxmlexport/data/textframe-borders.docx b/sw/qa/extras/ooxmlexport/data/textframe-borders.docx
new file mode 100755
index 0000000..424ed2a
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/textframe-borders.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index c1fd412..4ff3f98 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -35,6 +35,7 @@
#include <com/sun/star/style/ParagraphAdjust.hpp>
#include <com/sun/star/view/XSelectionSupplier.hpp>
#include <com/sun/star/table/BorderLine2.hpp>
+#include <com/sun/star/table/ShadowFormat.hpp>
#include <com/sun/star/text/XPageCursor.hpp>
#include <unotools/tempfile.hxx>
@@ -69,6 +70,7 @@ public:
void testN789482();
void test1Table1Page();
void testTextFrames();
+ void testTextFrameBorders();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -109,6 +111,7 @@ void Test::run()
{"n789482.docx", &Test::testN789482},
// {"1-table-1-page.docx", &Test::test1Table1Page}, // doesn't work on openSUSE12.2 at least
{"textframes.odt", &Test::testTextFrames},
+ {"textframe-borders.docx", &Test::testTextFrameBorders}
};
// Don't test the first import of these, for some reason those tests fail
const char* aBlacklist[] = {
@@ -519,6 +522,23 @@ void Test::testTextFrames()
CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xIndexAccess->getCount());
}
+void Test::testTextFrameBorders()
+{
+ uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0xD99594), getProperty<sal_Int32>(xFrame, "BackColor"));
+
+ table::BorderLine2 aBorder = getProperty<table::BorderLine2>(xFrame, "TopBorder");
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0xC0504D), aBorder.Color);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), aBorder.LineWidth);
+
+ table::ShadowFormat aShadowFormat = getProperty<table::ShadowFormat>(xFrame, "ShadowFormat");
+ CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadowFormat.Location);
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(48), aShadowFormat.ShadowWidth);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0x622423), aShadowFormat.Color);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
commit d0fcf8340d5319524dd0f9d8fb24666229d5fd92
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Tue Jan 22 13:20:57 2013 +0100
sw: DOCX export of TextFrame shadow
Change-Id: Ia095a3adee271cf7235fb7c13824d7f265658897
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 9cb2c33..0e82f7f 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -188,6 +188,7 @@ class FieldMarkParamsHelper
return bResult;
}
};
+static OString impl_ConvertColor( const Color &rColor );
void DocxAttributeOutput::RTLAndCJKState( bool bIsRTL, sal_uInt16 /*nScript*/ )
{
if (bIsRTL)
@@ -251,6 +252,35 @@ void DocxAttributeOutput::StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pText
m_bParagraphOpened = true;
}
+void lcl_TextFrameShadow(FSHelperPtr pSerializer, const SwFrmFmt& rFrmFmt)
+{
+ SvxShadowItem aShadowItem = rFrmFmt.GetShadow();
+ if (aShadowItem.GetLocation() == SVX_SHADOW_NONE)
+ return;
+
+ OString aShadowWidth( OString::valueOf( double( aShadowItem.GetWidth() ) / 20) + "pt");
+ OString aOffset;
+ switch (aShadowItem.GetLocation())
+ {
+ case SVX_SHADOW_TOPLEFT: aOffset = "-" + aShadowWidth + ",-" + aShadowWidth; break;
+ case SVX_SHADOW_TOPRIGHT: aOffset = aShadowWidth + ",-" + aShadowWidth; break;
+ case SVX_SHADOW_BOTTOMLEFT: aOffset = "-" + aShadowWidth + "," + aShadowWidth; break;
+ case SVX_SHADOW_BOTTOMRIGHT: aOffset = aShadowWidth + "," + aShadowWidth; break;
+ case SVX_SHADOW_NONE:
+ case SVX_SHADOW_END:
+ break;
+ }
+ if (aOffset.isEmpty())
+ return;
+
+ OString aShadowColor = impl_ConvertColor(aShadowItem.GetColor());
+ pSerializer->singleElementNS(XML_v, XML_shadow,
+ XML_on, "t",
+ XML_color, "#" + aShadowColor,
+ XML_offset, aOffset,
+ FSEND);
+}
+
void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner )
{
// write the paragraph properties + the run, already in the correct order
@@ -284,6 +314,7 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT
m_pSerializer->startElementNS( XML_w, XML_r, FSEND );
m_pSerializer->startElementNS( XML_w, XML_pict, FSEND );
m_pSerializer->startElementNS( XML_v, XML_rect, xFlyAttrList );
+ lcl_TextFrameShadow(m_pSerializer, rFrmFmt);
m_pSerializer->startElementNS( XML_v, XML_textbox, FSEND );
m_pSerializer->startElementNS( XML_w, XML_txbxContent, FSEND );
m_rExport.WriteText( );
commit f04bcdc4681e76b26b2f5e78232ccfb2d3cb891e
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Tue Jan 22 12:06:54 2013 +0100
sw: DOCX export of TextFrame border width / color
Change-Id: If88abe20eeec478d340f913973d4f4815dc0e510
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index a6b7dff..9cb2c33 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -4512,7 +4512,23 @@ void DocxAttributeOutput::FormatBackground( const SvxBrushItem& rBrush )
void DocxAttributeOutput::FormatBox( const SvxBoxItem& rBox )
{
if (m_bTextFrameSyntax)
+ {
+ const SvxBorderLine* pLeft = rBox.GetLine(BOX_LINE_LEFT);
+ const SvxBorderLine* pRight = rBox.GetLine(BOX_LINE_RIGHT);
+ const SvxBorderLine* pTop = rBox.GetLine(BOX_LINE_TOP);
+ const SvxBorderLine* pBottom = rBox.GetLine(BOX_LINE_BOTTOM);
+ if (pLeft && pRight && pTop && pBottom &&
+ *pLeft == *pRight && *pLeft == *pTop && *pLeft == *pBottom)
+ {
+ OString sColor("#" + impl_ConvertColor(pTop->GetColor()));
+ m_pFlyAttrList->add(XML_strokecolor, sColor);
+
+ double const fConverted(editeng::ConvertBorderWidthToWord(pTop->GetBorderLineStyle(), pTop->GetWidth()));
+ sal_Int32 nWidth = sal_Int32(fConverted / 20);
+ m_pFlyAttrList->add(XML_strokeweight, OString::valueOf(nWidth) + "pt");
+ }
return;
+ }
if ( !m_bOpenedSectPr )
{
commit 6eb6fc826e54d4464ecc56911a9cb192382319ea
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Tue Jan 22 11:03:36 2013 +0100
sw: DOCX export of TextFrame background color
Change-Id: If488129c8b563b82932b58e16328922cc2653da8
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 416063a..a6b7dff 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -273,13 +273,17 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT
m_rExport.mpParentFrame = pParentFrame;
m_bTextFrameSyntax = true;
+ m_pFlyAttrList = m_pSerializer->createAttrList( );
m_aTextFrameStyle = "position:absolute";
m_rExport.OutputFormat( pParentFrame->GetFrmFmt(), false, false, true );
+ m_pFlyAttrList->add(XML_style, m_aTextFrameStyle.makeStringAndClear());
+ XFastAttributeListRef xFlyAttrList( m_pFlyAttrList );
+ m_pFlyAttrList = NULL;
m_bTextFrameSyntax = false;
m_pSerializer->startElementNS( XML_w, XML_r, FSEND );
m_pSerializer->startElementNS( XML_w, XML_pict, FSEND );
- m_pSerializer->startElementNS( XML_v, XML_rect, XML_style, m_aTextFrameStyle.makeStringAndClear(), FSEND );
+ m_pSerializer->startElementNS( XML_v, XML_rect, xFlyAttrList );
m_pSerializer->startElementNS( XML_v, XML_textbox, FSEND );
m_pSerializer->startElementNS( XML_w, XML_txbxContent, FSEND );
m_rExport.WriteText( );
@@ -4493,9 +4497,11 @@ void DocxAttributeOutput::FormatAnchor( const SwFmtAnchor& )
void DocxAttributeOutput::FormatBackground( const SvxBrushItem& rBrush )
{
- if ( !m_rExport.bOutPageDescs )
+ OString sColor = impl_ConvertColor( rBrush.GetColor( ) );
+ if (m_bTextFrameSyntax)
+ m_pFlyAttrList->add(XML_fillcolor, "#" + sColor);
+ else if ( !m_rExport.bOutPageDescs )
{
- OString sColor = impl_ConvertColor( rBrush.GetColor( ) );
m_pSerializer->singleElementNS( XML_w, XML_shd,
FSNS( XML_w, XML_fill ), sColor.getStr( ),
FSNS( XML_w, XML_val ), "clear",
More information about the Libreoffice-commits
mailing list