summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZolnai Tamás <tamas.zolnai@collabora.com>2014-02-08 01:50:55 +0100
committerZolnai Tamás <tamas.zolnai@collabora.com>2014-02-08 02:59:50 +0100
commitfeae30c4ce1a1aa303500371b858f871d4ef88fc (patch)
tree114b264463bac0cb391df8c0c6af7611c91de6a2
parent718203e37025fc1cc1e28f9e52f05bee79684811 (diff)
ODF export/import: text vertical adjustment attribute of text frames
ODF standard handle 'textarea-vertical-align' as a 'graphic-property' which "specifies formatting properties for chart, draw, graphic, and frame elements". So this change fit to the standard. Change-Id: I956f512953380983c2c882e943178335fd4dbfeb
-rw-r--r--include/xmloff/xmltypes.hxx1
-rw-r--r--sw/qa/extras/odfexport/data/textframe-vertadjust.odtbin0 -> 12850 bytes
-rw-r--r--sw/qa/extras/odfexport/odfexport.cxx15
-rw-r--r--xmloff/source/text/txtprhdl.cxx17
-rw-r--r--xmloff/source/text/txtprmap.cxx1
5 files changed, 32 insertions, 2 deletions
diff --git a/include/xmloff/xmltypes.hxx b/include/xmloff/xmltypes.hxx
index 55cac8348135..3c8d7376db92 100644
--- a/include/xmloff/xmltypes.hxx
+++ b/include/xmloff/xmltypes.hxx
@@ -276,6 +276,7 @@
#define XML_TYPE_CHAR_SCRIPT (XML_TEXT_TYPES_START + 116)
#define XML_TYPE_CHAR_RFC_LANGUAGE_TAG (XML_TEXT_TYPES_START + 117)
+#define XML_TYPE_VERTICAL_ALIGN (XML_TEXT_TYPES_START + 118)
#define XML_SCH_TYPES_START (0x4 << XML_TYPE_APP_SHIFT)
#define XML_PM_TYPES_START (0x5 << XML_TYPE_APP_SHIFT) // page master
diff --git a/sw/qa/extras/odfexport/data/textframe-vertadjust.odt b/sw/qa/extras/odfexport/data/textframe-vertadjust.odt
new file mode 100644
index 000000000000..bbf3416c09e1
--- /dev/null
+++ b/sw/qa/extras/odfexport/data/textframe-vertadjust.odt
Binary files differ
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index c2e5c0cbbdf3..db752040e4a9 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -14,6 +14,7 @@
#include <com/sun/star/drawing/FillStyle.hpp>
#include <com/sun/star/table/ShadowFormat.hpp>
#include <com/sun/star/text/RelOrientation.hpp>
+#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
class Test : public SwModelTestBase
{
@@ -335,6 +336,20 @@ DECLARE_ODFEXPORT_TEST(testRelwPage, "relw-page.odt")
CPPUNIT_ASSERT_EQUAL(sal_Int32(4896), parseDump("/root/page/body/txt/anchored/fly/infos/bounds", "width").toInt32());
}
+DECLARE_ODFEXPORT_TEST(testTextFrameVertAdjust, "textframe-vertadjust.odt")
+{
+ // Test import/export of new frame attribute called TextVerticalAdjust
+
+ // 1st frame's context is adjusted to the top
+ uno::Reference<beans::XPropertySet> xFrame(getTextFrameByName("Rectangle 1"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_TOP, getProperty<drawing::TextVerticalAdjust>(xFrame, "TextVerticalAdjust"));
+ // 2nd frame's context is adjusted to the center
+ xFrame.set(getTextFrameByName("Rectangle 2"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_CENTER, getProperty<drawing::TextVerticalAdjust>(xFrame, "TextVerticalAdjust"));
+ // 3rd frame's context is adjusted to the bottom
+ xFrame.set(getTextFrameByName("Rectangle 3"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_BOTTOM, getProperty<drawing::TextVerticalAdjust>(xFrame, "TextVerticalAdjust"));
+}
#endif
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/xmloff/source/text/txtprhdl.cxx b/xmloff/source/text/txtprhdl.cxx
index 951fa1f6fd01..032a055dac84 100644
--- a/xmloff/source/text/txtprhdl.cxx
+++ b/xmloff/source/text/txtprhdl.cxx
@@ -45,6 +45,7 @@
#include "txtprhdl.hxx"
// OD 2004-05-05 #i28701#
#include <com/sun/star/text/WrapInfluenceOnPosition.hpp>
+#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -211,7 +212,7 @@ static SvXMLEnumMapEntry const pXML_FontRelief_Enum[] =
{ XML_TOKEN_INVALID, 0 }
};
-static SvXMLEnumMapEntry const pXML_VerticalAlign_Enum[] =
+static SvXMLEnumMapEntry const pXML_ParaVerticalAlign_Enum[] =
{
{ XML_TOP, ParagraphVertAlign::TOP },
{ XML_MIDDLE, ParagraphVertAlign::CENTER },
@@ -231,6 +232,15 @@ static SvXMLEnumMapEntry const pXML_WrapInfluenceOnPosition_Enum[] =
{ XML_TOKEN_INVALID, 0 }
};
+static SvXMLEnumMapEntry const pXML_VerticalAlign_Enum[] =
+{
+ { XML_TOP, drawing::TextVerticalAdjust_TOP },
+ { XML_MIDDLE, drawing::TextVerticalAdjust_CENTER },
+ { XML_BOTTOM, drawing::TextVerticalAdjust_BOTTOM },
+ { XML_JUSTIFY, drawing::TextVerticalAdjust_BLOCK },
+ { XML_TOKEN_INVALID, 0 }
+};
+
static SvXMLEnumMapEntry const pXML_FillStyle_Enum[] =
{
{ XML_NONE, drawing::FillStyle_NONE },
@@ -1347,7 +1357,7 @@ const XMLPropertyHandler *XMLTextPropertyHandlerFactory_Impl::GetPropertyHandler
GetXMLToken( XML_LINE_HEIGHT ) );
break;
case XML_TYPE_TEXT_VERTICAL_ALIGN:
- pHdl = new XMLConstantsPropertyHandler( pXML_VerticalAlign_Enum, XML_TOKEN_INVALID );
+ pHdl = new XMLConstantsPropertyHandler( pXML_ParaVerticalAlign_Enum, XML_TOKEN_INVALID );
break;
case XML_TYPE_TEXT_RUBY_POSITION:
pHdl = new XMLNamedBoolPropertyHdl( ::xmloff::token::XML_ABOVE,
@@ -1383,6 +1393,9 @@ const XMLPropertyHandler *XMLTextPropertyHandlerFactory_Impl::GetPropertyHandler
case XML_TYPE_FILLSTYLE:
pHdl = new XMLConstantsPropertyHandler( pXML_FillStyle_Enum, XML_TOKEN_INVALID );
break;
+ case XML_TYPE_VERTICAL_ALIGN:
+ pHdl = new XMLConstantsPropertyHandler( pXML_VerticalAlign_Enum, XML_TOKEN_INVALID );
+ break;
}
return pHdl;
diff --git a/xmloff/source/text/txtprmap.cxx b/xmloff/source/text/txtprmap.cxx
index a1f9898f2f91..90cb26e56869 100644
--- a/xmloff/source/text/txtprmap.cxx
+++ b/xmloff/source/text/txtprmap.cxx
@@ -786,6 +786,7 @@ XMLPropertyMapEntry aXMLFramePropMap[] =
MG_E( "UserDefinedAttributes", TEXT, XMLNS, XML_TYPE_ATTRIBUTE_CONTAINER | MID_FLAG_SPECIAL_ITEM, 0 ),
MAP_EXT("RelativeWidthRelation", XML_NAMESPACE_LO_EXT, XML_REL_WIDTH_REL, XML_TYPE_TEXT_HORIZONTAL_REL|XML_TYPE_PROP_GRAPHIC, CTF_RELWIDTHREL),
MAP_EXT("RelativeHeightRelation", XML_NAMESPACE_LO_EXT, XML_REL_HEIGHT_REL, XML_TYPE_TEXT_VERTICAL_REL|XML_TYPE_PROP_GRAPHIC, CTF_RELHEIGHTREL),
+ MG_E("TextVerticalAdjust", DRAW, TEXTAREA_VERTICAL_ALIGN, XML_TYPE_VERTICAL_ALIGN, 0),
M_END()
};