summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2013-08-15 17:06:57 +0200
committerMiklos Vajna <vmiklos@suse.cz>2013-08-15 17:09:11 +0200
commit66b4bfe302e248fc1503c5c74b83f4fb5fee4026 (patch)
tree3928503e3cefd23c6315380bbca1280f55534b1a /writerfilter
parent26d9efd36a16d2095d8fb885290c6816082ec814 (diff)
DOCX import: handle custom left cell margin for float table position
Change-Id: I5bc51b739c663d3e123c9d7fb4c2a70f01f8c841
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableHandler.cxx37
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableHandler.hxx2
-rw-r--r--writerfilter/source/dmapper/TablePositionHandler.cxx5
-rw-r--r--writerfilter/source/dmapper/TablePositionHandler.hxx1
4 files changed, 24 insertions, 21 deletions
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index 72d7c744946d..3d99fa25050e 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -38,6 +38,8 @@ namespace dmapper {
using namespace ::com::sun::star;
using namespace ::std;
+#define DEF_BORDER_DIST 190 //0,19cm
+
#ifdef DEBUG_DMAPPER_TABLE_HANDLER
static void lcl_printProperties( PropertyMapPtr pProps )
{
@@ -306,6 +308,22 @@ bool lcl_extractTableBorderProperty(PropertyMapPtr pTableProperties, const Prope
}
+void lcl_DecrementHoriOrientPosition(uno::Sequence<beans::PropertyValue>& rFrameProperties, sal_Int32 nAmount)
+{
+ // Shifts the frame left by the given value.
+ for (sal_Int32 i = 0; i < rFrameProperties.getLength(); ++i)
+ {
+ beans::PropertyValue& rPropertyValue = rFrameProperties[i];
+ if (rPropertyValue.Name == "HoriOrientPosition")
+ {
+ sal_Int32 nValue = rPropertyValue.Value.get<sal_Int32>();
+ nValue -= nAmount;
+ rPropertyValue.Value <<= nValue;
+ return;
+ }
+ }
+}
+
TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo & rInfo, uno::Sequence<beans::PropertyValue>& rFrameProperties)
{
// will receive the table style if any
@@ -401,8 +419,10 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
m_aTableProperties->Insert( PROP_TABLE_BORDER_DISTANCES, uno::makeAny( aDistances ) );
+ if (rFrameProperties.hasElements())
+ lcl_DecrementHoriOrientPosition(rFrameProperties, rInfo.nLeftBorderDistance);
+
// Set table above/bottom spacing to 0.
- // TODO: handle 'Around' text wrapping mode
m_aTableProperties->Insert( PROP_TOP_MARGIN, uno::makeAny( sal_Int32( 0 ) ) );
m_aTableProperties->Insert( PROP_BOTTOM_MARGIN, uno::makeAny( sal_Int32( 0 ) ) );
@@ -430,20 +450,7 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
if (!rFrameProperties.hasElements())
rInfo.nLeftBorderDistance += aLeftBorder.LineWidth * 0.5;
else
- {
- // If this is a floating table, then the position of the frame should be adjusted, instead.
- for (sal_Int32 i = 0; i < rFrameProperties.getLength(); ++i)
- {
- beans::PropertyValue& rPropertyValue = rFrameProperties[i];
- if (rPropertyValue.Name == "HoriOrientPosition")
- {
- sal_Int32 nValue = rPropertyValue.Value.get<sal_Int32>();
- nValue -= aLeftBorder.LineWidth * 0.5;
- rPropertyValue.Value <<= nValue;
- break;
- }
- }
- }
+ lcl_DecrementHoriOrientPosition(rFrameProperties, aLeftBorder.LineWidth * 0.5);
}
}
if (lcl_extractTableBorderProperty(m_aTableProperties, PROP_RIGHT_BORDER, rInfo, aBorderLine))
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.hxx b/writerfilter/source/dmapper/DomainMapperTableHandler.hxx
index 792b978b46c0..3dc75af12b1c 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.hxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.hxx
@@ -45,8 +45,6 @@ typedef ::com::sun::star::uno::Sequence< RowPropertyValuesSeq_t> CellProperty
typedef std::vector<PropertyMapPtr> PropertyMapVector1;
typedef std::vector<PropertyMapVector1> PropertyMapVector2;
-#define DEF_BORDER_DIST 190 //0,19cm
-
class DomainMapper_Impl;
class TableStyleSheetEntry;
struct TableInfo;
diff --git a/writerfilter/source/dmapper/TablePositionHandler.cxx b/writerfilter/source/dmapper/TablePositionHandler.cxx
index 1ecf6c6d9344..e584a2ee0451 100644
--- a/writerfilter/source/dmapper/TablePositionHandler.cxx
+++ b/writerfilter/source/dmapper/TablePositionHandler.cxx
@@ -33,8 +33,7 @@ TablePositionHandler::TablePositionHandler() :
m_nLeftFromText(0),
m_nRightFromText(0),
m_nTopFromText(0),
- m_nBottomFromText(0),
- m_nLeftBorderDistance(DEF_BORDER_DIST)
+ m_nBottomFromText(0)
{
}
@@ -150,7 +149,7 @@ uno::Sequence<beans::PropertyValue> TablePositionHandler::getTablePosition() con
pFrameProperties[13].Name = "HoriOrientRelation";
pFrameProperties[13].Value <<= nHoriOrientRelation;
pFrameProperties[14].Name = "HoriOrientPosition";
- pFrameProperties[14].Value <<= m_nX - m_nLeftBorderDistance;
+ pFrameProperties[14].Value <<= m_nX;
// Vertical positioning
diff --git a/writerfilter/source/dmapper/TablePositionHandler.hxx b/writerfilter/source/dmapper/TablePositionHandler.hxx
index d68800c51e9a..a264dff03882 100644
--- a/writerfilter/source/dmapper/TablePositionHandler.hxx
+++ b/writerfilter/source/dmapper/TablePositionHandler.hxx
@@ -31,7 +31,6 @@ namespace writerfilter {
sal_Int32 m_nRightFromText;
sal_Int32 m_nTopFromText;
sal_Int32 m_nBottomFromText;
- sal_Int32 m_nLeftBorderDistance;
// Properties
virtual void lcl_attribute(Id Name, Value & val);