Kaydet (Commit) edc4861a authored tarafından Miklos Vajna's avatar Miklos Vajna

n#775899 initial docx import of w:vertAnchor inside w:tblpPr

Change-Id: I5c848a8d4c860a83d6729b8db40f744afad906d5
üst 25ef6ea6
......@@ -122,6 +122,7 @@ $(eval $(call gb_Library_add_exception_objects,writerfilter,\
writerfilter/source/dmapper/SettingsTable \
writerfilter/source/dmapper/StyleSheetTable \
writerfilter/source/dmapper/TDefTableHandler \
writerfilter/source/dmapper/TablePositionHandler \
writerfilter/source/dmapper/TablePropertiesHandler \
writerfilter/source/dmapper/TblStylePrHandler \
writerfilter/source/dmapper/ThemeTable \
......
......@@ -23,6 +23,7 @@
#include <com/sun/star/table/TableBorder.hpp>
#include <com/sun/star/table/BorderLine2.hpp>
#include <com/sun/star/text/HoriOrientation.hpp>
#include <com/sun/star/text/RelOrientation.hpp>
#include <dmapperLoggers.hxx>
#ifdef DEBUG_DMAPPER_TABLE_HANDLER
......@@ -691,11 +692,24 @@ void DomainMapperTableHandler::endTable()
if (m_pTableSeq->getLength() > 0)
{
uno::Reference<text::XTextRange> xStart;
uno::Reference<text::XTextRange> xEnd;
// If we want to make this table a floating one.
bool bFloating = !m_rDMapper_Impl.getTableManager().getTableVertAnchor().isEmpty();
// Additional checks: if we can do this.
if (bFloating && (*m_pTableSeq)[0].getLength() > 0 && (*m_pTableSeq)[0][0].getLength() > 0)
{
xStart = (*m_pTableSeq)[0][0][0];
uno::Sequence< uno::Sequence< uno::Reference<text::XTextRange> > >& rLastRow = (*m_pTableSeq)[m_pTableSeq->getLength() - 1];
uno::Sequence< uno::Reference<text::XTextRange> >& rLastCell = rLastRow[rLastRow.getLength() - 1];
xEnd = rLastCell[1];
}
uno::Reference<text::XTextTable> xTable;
try
{
if (m_xText.is())
{
uno::Reference<text::XTextTable> xTable = m_xText->convertToTable(*m_pTableSeq,
xTable = m_xText->convertToTable(*m_pTableSeq,
aCellProperties,
aRowProperties,
aTableInfo.aTableProperties);
......@@ -723,6 +737,55 @@ void DomainMapperTableHandler::endTable()
(void) e;
#endif
}
// If we have a table with a start and an end position, we should make it a floating one.
if (xTable.is() && xStart.is() && xEnd.is())
{
uno::Reference<beans::XPropertySet> xTableProperties(xTable, uno::UNO_QUERY);
uno::Sequence< beans::PropertyValue > aFrameProperties(16);
beans::PropertyValue* pFrameProperties = aFrameProperties.getArray();
pFrameProperties[0].Name = "Width";
pFrameProperties[0].Value = xTableProperties->getPropertyValue("Width");
pFrameProperties[1].Name = "LeftBorderDistance";
pFrameProperties[1].Value <<= sal_Int32(0);
pFrameProperties[2].Name = "RightBorderDistance";
pFrameProperties[2].Value <<= sal_Int32(0);
pFrameProperties[3].Name = "TopBorderDistance";
pFrameProperties[3].Value <<= sal_Int32(0);
pFrameProperties[4].Name = "BottomBorderDistance";
pFrameProperties[4].Value <<= sal_Int32(0);
pFrameProperties[5].Name = "LeftMargin";
pFrameProperties[5].Value <<= sal_Int32(0);
pFrameProperties[6].Name = "RightMargin";
pFrameProperties[6].Value <<= sal_Int32(0);
pFrameProperties[7].Name = "TopMargin";
pFrameProperties[7].Value <<= sal_Int32(0);
pFrameProperties[8].Name = "BottomMargin";
pFrameProperties[8].Value <<= sal_Int32(0);
table::BorderLine2 aEmptyBorder;
pFrameProperties[9].Name = "TopBorder";
pFrameProperties[9].Value <<= aEmptyBorder;
pFrameProperties[10].Name = "BottomBorder";
pFrameProperties[10].Value <<= aEmptyBorder;
pFrameProperties[11].Name = "LeftBorder";
pFrameProperties[11].Value <<= aEmptyBorder;
pFrameProperties[12].Name = "RightBorder";
pFrameProperties[12].Value <<= aEmptyBorder;
pFrameProperties[13].Name = "HoriOrient";
pFrameProperties[13].Value <<= text::HoriOrientation::NONE;
pFrameProperties[14].Name = "HoriOrientRelation";
pFrameProperties[14].Value <<= text::RelOrientation::FRAME;
// A non-zero left margin would move the table out of the frame, move the frame itself instead.
pFrameProperties[15].Name = "HoriOrientPosition";
pFrameProperties[15].Value <<= xTableProperties->getPropertyValue("LeftMargin");
xTableProperties->setPropertyValue("LeftMargin", uno::makeAny(sal_Int32(0)));
uno::Reference< text::XTextContent > xFrame = m_xText->convertToTextFrame(xStart, xEnd, aFrameProperties);
}
}
m_aTableProperties.reset();
......
......@@ -23,6 +23,7 @@
#include <CellMarginHandler.hxx>
#include <ConversionHelper.hxx>
#include <MeasureHandler.hxx>
#include <TablePositionHandler.hxx>
#include <TDefTableHandler.hxx>
#include <com/sun/star/text/HoriOrientation.hpp>
#include <com/sun/star/text/SizeType.hpp>
......@@ -297,6 +298,17 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm)
cellProps( pProps );
}
break;
case NS_ooxml::LN_CT_TblPrBase_tblpPr:
{
writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
if (pProperties.get())
{
TablePositionHandlerPtr pHandler( new TablePositionHandler );
pProperties->resolve(*pHandler);
m_sTableVertAnchor = pHandler->getVertAnchor();
}
}
break;
default:
bRet = false;
......@@ -318,6 +330,11 @@ boost::shared_ptr< vector< sal_Int32 > > DomainMapperTableManager::getCurrentSpa
return m_aGridSpans.back( );
}
const OUString& DomainMapperTableManager::getTableVertAnchor() const
{
return m_sTableVertAnchor;
}
void DomainMapperTableManager::startLevel( )
{
DomainMapperTableManager_Base_t::startLevel( );
......@@ -512,6 +529,7 @@ void DomainMapperTableManager::clearData()
{
m_nRow = m_nCell = m_nCellBorderIndex = m_nHeaderRepeat = m_nTableWidth = 0;
m_sTableStyleName = OUString();
m_sTableVertAnchor = OUString();
m_pTableStyleTextProperies.reset();
}
......
......@@ -43,6 +43,7 @@ class DomainMapperTableManager : public DomainMapperTableManager_Base_t
bool m_bOOXML;
bool m_bImplicitMerges;
OUString m_sTableStyleName;
OUString m_sTableVertAnchor;
PropertyMapPtr m_pTableStyleTextProperies;
::std::vector< IntVectorPtr > m_aTableGrid;
......@@ -74,6 +75,7 @@ public:
IntVectorPtr getCurrentSpans( );
const OUString& getTableStyleName() const { return m_sTableStyleName; }
const OUString& getTableVertAnchor() const;
/// copy the text properties of the table style and its parent into pContext
void CopyTextProperties(PropertyMapPtr pContext, StyleSheetTablePtr pStyleSheetTable);
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <TablePositionHandler.hxx>
#include <PropertyMap.hxx>
#include <doctok/resourceids.hxx>
#include <ConversionHelper.hxx>
#include <ooxml/resourceids.hxx>
#include <com/sun/star/text/SizeType.hpp>
#include "dmapperLoggers.hxx"
namespace writerfilter {
namespace dmapper {
using namespace ::com::sun::star;
TablePositionHandler::TablePositionHandler() :
LoggedProperties(dmapper_logger, "TablePositionHandler")
{
}
TablePositionHandler::~TablePositionHandler()
{
}
void TablePositionHandler::lcl_attribute(Id rName, Value& rVal)
{
switch (rName)
{
case NS_ooxml::LN_CT_TblPPr_vertAnchor:
m_aVertAnchor = rVal.getString();
break;
default:
#ifdef DEBUG_DOMAINMAPPER
dmapper_logger->element("unhandled");
#endif
break;
}
}
void TablePositionHandler::lcl_sprm(Sprm& /*rSprm*/)
{
}
OUString TablePositionHandler::getVertAnchor() const
{
return m_aVertAnchor;
}
} // namespace dmapper
} // namespace writerfilter
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_POSITIONHANDLER_HXX
#define INCLUDED_POSITIONHANDLER_HXX
#include <WriterFilterDllApi.hxx>
#include <resourcemodel/LoggedResources.hxx>
#include <boost/shared_ptr.hpp>
namespace writerfilter {
namespace dmapper {
/// Handler for floating table positioning
class WRITERFILTER_DLLPRIVATE TablePositionHandler
: public LoggedProperties
{
OUString m_aVertAnchor;
// Properties
virtual void lcl_attribute(Id Name, Value & val);
virtual void lcl_sprm(Sprm & sprm);
public:
TablePositionHandler();
virtual ~TablePositionHandler();
OUString getVertAnchor() const;
};
typedef boost::shared_ptr<TablePositionHandler> TablePositionHandlerPtr;
} // namespace dmapper
} // namespace writerfilter
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -22825,6 +22825,9 @@
<attribute name="w" tokenid="ooxml:CT_TblWidth_w"/>
<attribute name="type" tokenid="ooxml:CT_TblWidth_type"/>
</resource>
<resource name="CT_TblPPr" resource="Properties" tag="table">
<attribute name="vertAnchor" tokenid="ooxml:CT_TblPPr_vertAnchor"/>
</resource>
<resource name="CT_TblGridCol" resource="Value" tag="table">
<attribute name="w" tokenid="ooxml:CT_TblGridCol_w" action="setValue"/>
<action name="start" action="setDefaultIntegerValue"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment