DOCX import: fix vertical position of inline images

(regression of commit ab81e3bff2)

Change-Id: Ie78f8be059b18cdd81c83a8d01f2d865ac3fec2b
This commit is contained in:
László Németh
2015-05-26 12:07:31 +02:00
parent 0394b69cf0
commit 2cc3adf3a5

View File

@@ -1220,69 +1220,71 @@ uno::Reference< text::XTextContent > GraphicImport::createGraphicObject( const b
uno::makeAny(true)); uno::makeAny(true));
sal_Int32 nWidth = m_pImpl->nRightPosition - m_pImpl->nLeftPosition; sal_Int32 nWidth = m_pImpl->nRightPosition - m_pImpl->nLeftPosition;
//adjust margins if (m_pImpl->eGraphicImportType == IMPORT_AS_DETECTED_ANCHOR)
if( (m_pImpl->nHoriOrient == text::HoriOrientation::LEFT && {
(m_pImpl->nHoriRelation == text::RelOrientation::PAGE_PRINT_AREA || //adjust margins
m_pImpl->nHoriRelation == text::RelOrientation::FRAME) ) || if( (m_pImpl->nHoriOrient == text::HoriOrientation::LEFT &&
(m_pImpl->nHoriOrient == text::HoriOrientation::INSIDE &&
m_pImpl->nHoriRelation == text::RelOrientation::PAGE_PRINT_AREA ))
m_pImpl->nLeftMargin = 0;
if((m_pImpl->nHoriOrient == text::HoriOrientation::RIGHT &&
(m_pImpl->nHoriRelation == text::RelOrientation::PAGE_PRINT_AREA || (m_pImpl->nHoriRelation == text::RelOrientation::PAGE_PRINT_AREA ||
m_pImpl->nHoriRelation == text::RelOrientation::FRAME) ) || m_pImpl->nHoriRelation == text::RelOrientation::FRAME) ) ||
(m_pImpl->nHoriOrient == text::HoriOrientation::INSIDE && (m_pImpl->nHoriOrient == text::HoriOrientation::INSIDE &&
m_pImpl->nHoriRelation == text::RelOrientation::PAGE_PRINT_AREA )) m_pImpl->nHoriRelation == text::RelOrientation::PAGE_PRINT_AREA ))
m_pImpl->nRightMargin = 0; m_pImpl->nLeftMargin = 0;
// adjust top/bottom margins if((m_pImpl->nHoriOrient == text::HoriOrientation::RIGHT &&
if( m_pImpl->nVertOrient == text::VertOrientation::TOP && (m_pImpl->nHoriRelation == text::RelOrientation::PAGE_PRINT_AREA ||
m_pImpl->nHoriRelation == text::RelOrientation::FRAME) ) ||
(m_pImpl->nHoriOrient == text::HoriOrientation::INSIDE &&
m_pImpl->nHoriRelation == text::RelOrientation::PAGE_PRINT_AREA ))
m_pImpl->nRightMargin = 0;
// adjust top/bottom margins
if( m_pImpl->nVertOrient == text::VertOrientation::TOP &&
( m_pImpl->nVertRelation == text::RelOrientation::PAGE_PRINT_AREA || ( m_pImpl->nVertRelation == text::RelOrientation::PAGE_PRINT_AREA ||
m_pImpl->nVertRelation == text::RelOrientation::PAGE_FRAME)) m_pImpl->nVertRelation == text::RelOrientation::PAGE_FRAME))
m_pImpl->nTopMargin = 0; m_pImpl->nTopMargin = 0;
if( m_pImpl->nVertOrient == text::VertOrientation::BOTTOM && if( m_pImpl->nVertOrient == text::VertOrientation::BOTTOM &&
( m_pImpl->nVertRelation == text::RelOrientation::PAGE_PRINT_AREA || ( m_pImpl->nVertRelation == text::RelOrientation::PAGE_PRINT_AREA ||
m_pImpl->nVertRelation == text::RelOrientation::PAGE_FRAME)) m_pImpl->nVertRelation == text::RelOrientation::PAGE_FRAME))
m_pImpl->nBottomMargin = 0; m_pImpl->nBottomMargin = 0;
if( m_pImpl->nVertOrient == text::VertOrientation::BOTTOM && if( m_pImpl->nVertOrient == text::VertOrientation::BOTTOM &&
m_pImpl->nVertRelation == text::RelOrientation::PAGE_PRINT_AREA ) m_pImpl->nVertRelation == text::RelOrientation::PAGE_PRINT_AREA )
m_pImpl->nBottomMargin = 0; m_pImpl->nBottomMargin = 0;
//adjust alignment
//adjust alignment if( m_pImpl->nHoriOrient == text::HoriOrientation::INSIDE &&
if( m_pImpl->nHoriOrient == text::HoriOrientation::INSIDE &&
m_pImpl->nHoriRelation == text::RelOrientation::PAGE_FRAME ) m_pImpl->nHoriRelation == text::RelOrientation::PAGE_FRAME )
{ {
// convert 'left to page' to 'from left -<width> to page text area' // convert 'left to page' to 'from left -<width> to page text area'
m_pImpl->nHoriOrient = text::HoriOrientation::NONE; m_pImpl->nHoriOrient = text::HoriOrientation::NONE;
m_pImpl->nHoriRelation = text::RelOrientation::PAGE_PRINT_AREA; m_pImpl->nHoriRelation = text::RelOrientation::PAGE_PRINT_AREA;
m_pImpl->nLeftPosition = - nWidth; m_pImpl->nLeftPosition = - nWidth;
} }
else if( m_pImpl->nHoriOrient == text::HoriOrientation::OUTSIDE && else if( m_pImpl->nHoriOrient == text::HoriOrientation::OUTSIDE &&
m_pImpl->nHoriRelation == text::RelOrientation::PAGE_FRAME ) m_pImpl->nHoriRelation == text::RelOrientation::PAGE_FRAME )
{ {
// convert 'right to page' to 'from left 0 to right page border' // convert 'right to page' to 'from left 0 to right page border'
m_pImpl->nHoriOrient = text::HoriOrientation::NONE; m_pImpl->nHoriOrient = text::HoriOrientation::NONE;
m_pImpl->nHoriRelation = text::RelOrientation::PAGE_RIGHT; m_pImpl->nHoriRelation = text::RelOrientation::PAGE_RIGHT;
m_pImpl->nLeftPosition = 0; m_pImpl->nLeftPosition = 0;
} }
m_pImpl->applyPosition(xGraphicObjectProperties); m_pImpl->applyPosition(xGraphicObjectProperties);
m_pImpl->applyRelativePosition(xGraphicObjectProperties); m_pImpl->applyRelativePosition(xGraphicObjectProperties);
bool bOpaque = m_pImpl->bOpaque && !m_pImpl->rDomainMapper.IsInHeaderFooter( ); bool bOpaque = m_pImpl->bOpaque && !m_pImpl->rDomainMapper.IsInHeaderFooter( );
if( !bOpaque ) if( !bOpaque )
{ {
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_OPAQUE ), xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_OPAQUE ),
uno::makeAny(bOpaque)); uno::makeAny(bOpaque));
} }
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_SURROUND ), xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_SURROUND ),
uno::makeAny(m_pImpl->nWrap)); uno::makeAny(m_pImpl->nWrap));
if( m_pImpl->bLayoutInCell && m_pImpl->nWrap != text::WrapTextMode_THROUGHT ) if( m_pImpl->bLayoutInCell && m_pImpl->nWrap != text::WrapTextMode_THROUGHT )
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_FOLLOW_TEXT_FLOW ), xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_FOLLOW_TEXT_FLOW ),
uno::makeAny(true)); uno::makeAny(true));
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_SURROUND_CONTOUR ), xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_SURROUND_CONTOUR ),
uno::makeAny(m_pImpl->bContour)); uno::makeAny(m_pImpl->bContour));
xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_CONTOUR_OUTSIDE ), xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_CONTOUR_OUTSIDE ),
uno::makeAny(m_pImpl->bContourOutside)); uno::makeAny(m_pImpl->bContourOutside));
m_pImpl->applyMargins(xGraphicObjectProperties); m_pImpl->applyMargins(xGraphicObjectProperties);
}
if( m_pImpl->eColorMode == drawing::ColorMode_STANDARD && if( m_pImpl->eColorMode == drawing::ColorMode_STANDARD &&
m_pImpl->nContrast == -70 && m_pImpl->nContrast == -70 &&