diff options
author | Cédric Bosdonnat <cedric.bosdonnat.ooo@free.fr> | 2011-11-28 15:06:28 +0100 |
---|---|---|
committer | Cédric Bosdonnat <cedric.bosdonnat.ooo@free.fr> | 2011-12-05 18:09:43 +0100 |
commit | 91ae8f6c068c636a5600406da3d8829442a2af78 (patch) | |
tree | c11a3fa468f93c0f6f958f1d51c9d5cf4037be64 /writerfilter | |
parent | b8b1b45cb4c9f1fb31a6e107d0131affeb99fce5 (diff) |
docx: actually import the last frame of a section.
When there is no paragraph outside the frame before the section end, the
paragraphs weren't transformed to a frame.
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper.cxx | 1 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 233 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.hxx | 1 |
3 files changed, 120 insertions, 115 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 91a1aca11bf2..b6c5c19511b2 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -3233,6 +3233,7 @@ void DomainMapper::lcl_startParagraphGroup() void DomainMapper::lcl_endParagraphGroup() { + m_pImpl->CheckUnregisteredFrameConversion(); m_pImpl->PopProperties(CONTEXT_PARAGRAPH); m_pImpl->getTableManager().endParagraphGroup(); //frame conversion has to be executed after table conversion diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index be6435134451..835e2e6dcfd3 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -691,6 +691,123 @@ void lcl_AddRangeAndStyle( //define some default frame width - 0cm ATM: this allow the frame to be wrapped around the text #define DEFAULT_FRAME_MIN_WIDTH 0 +void DomainMapper_Impl::CheckUnregisteredFrameConversion( ) +{ + PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier(); + TextAppendContext& rAppendContext = m_aTextAppendStack.top(); + if( rAppendContext.pLastParagraphProperties.get() ) + { + try + { + StyleSheetEntryPtr pParaStyle = + m_pStyleSheetTable->FindStyleSheetByConvertedStyleName(rAppendContext.pLastParagraphProperties->GetParaStyleName()); + + uno::Sequence< beans::PropertyValue > aFrameProperties(pParaStyle ? 15: 0); + if ( pParaStyle.get( ) ) + { + const ParagraphProperties* pStyleProperties = dynamic_cast<const ParagraphProperties*>( pParaStyle->pProperties.get() ); + beans::PropertyValue* pFrameProperties = aFrameProperties.getArray(); + pFrameProperties[0].Name = rPropNameSupplier.GetName(PROP_WIDTH); + pFrameProperties[1].Name = rPropNameSupplier.GetName(PROP_HEIGHT); + pFrameProperties[2].Name = rPropNameSupplier.GetName(PROP_SIZE_TYPE); + pFrameProperties[3].Name = rPropNameSupplier.GetName(PROP_WIDTH_TYPE); + pFrameProperties[4].Name = rPropNameSupplier.GetName(PROP_HORI_ORIENT); + pFrameProperties[5].Name = rPropNameSupplier.GetName(PROP_HORI_ORIENT_POSITION); + pFrameProperties[6].Name = rPropNameSupplier.GetName(PROP_HORI_ORIENT_RELATION); + pFrameProperties[7].Name = rPropNameSupplier.GetName(PROP_VERT_ORIENT); + pFrameProperties[8].Name = rPropNameSupplier.GetName(PROP_VERT_ORIENT_POSITION); + pFrameProperties[9].Name = rPropNameSupplier.GetName(PROP_VERT_ORIENT_RELATION); + pFrameProperties[10].Name = rPropNameSupplier.GetName(PROP_SURROUND); + pFrameProperties[11].Name = rPropNameSupplier.GetName(PROP_LEFT_MARGIN); + pFrameProperties[12].Name = rPropNameSupplier.GetName(PROP_RIGHT_MARGIN); + pFrameProperties[13].Name = rPropNameSupplier.GetName(PROP_TOP_MARGIN); + pFrameProperties[14].Name = rPropNameSupplier.GetName(PROP_BOTTOM_MARGIN); + sal_Int32 nWidth = + rAppendContext.pLastParagraphProperties->Getw() > 0 ? + rAppendContext.pLastParagraphProperties->Getw() : + pStyleProperties->Getw(); + bool bAutoWidth = nWidth < 1; + if( bAutoWidth ) + nWidth = DEFAULT_FRAME_MIN_WIDTH; + pFrameProperties[0].Value <<= nWidth; + pFrameProperties[1].Value <<= + rAppendContext.pLastParagraphProperties->Geth() > 0 ? + rAppendContext.pLastParagraphProperties->Geth() : + pStyleProperties->Geth(); + pFrameProperties[2].Value <<= sal_Int16( + rAppendContext.pLastParagraphProperties->GethRule() >= 0 ? + rAppendContext.pLastParagraphProperties->GethRule() : + pStyleProperties->GethRule() >=0 ? pStyleProperties->GethRule() : text::SizeType::VARIABLE); + + pFrameProperties[3].Value <<= bAutoWidth ? text::SizeType::MIN : text::SizeType::FIX; + + sal_Int16 nHoriOrient = sal_Int16( + rAppendContext.pLastParagraphProperties->GetxAlign() >= 0 ? + rAppendContext.pLastParagraphProperties->GetxAlign() : + pStyleProperties->GetxAlign() >= 0 ? pStyleProperties->GetxAlign() : text::HoriOrientation::NONE ); + pFrameProperties[4].Value <<= nHoriOrient; + + pFrameProperties[5].Value <<= + rAppendContext.pLastParagraphProperties->IsxValid() ? + rAppendContext.pLastParagraphProperties->Getx() : pStyleProperties->Getx(); + pFrameProperties[6].Value <<= sal_Int16( + rAppendContext.pLastParagraphProperties->GethAnchor() >= 0 ? + rAppendContext.pLastParagraphProperties->GethAnchor() : + pStyleProperties->GethAnchor() ); + + sal_Int16 nVertOrient = sal_Int16( + rAppendContext.pLastParagraphProperties->GetyAlign() >= 0 ? + rAppendContext.pLastParagraphProperties->GetyAlign() : + pStyleProperties->GetyAlign() >= 0 ? pStyleProperties->GetyAlign() : text::VertOrientation::NONE ); + pFrameProperties[7].Value <<= nVertOrient; + + pFrameProperties[8].Value <<= + rAppendContext.pLastParagraphProperties->IsyValid() ? + rAppendContext.pLastParagraphProperties->Gety() : pStyleProperties->Gety(); + pFrameProperties[9].Value <<= sal_Int16( + rAppendContext.pLastParagraphProperties->GetvAnchor() >= 0 ? + rAppendContext.pLastParagraphProperties->GetvAnchor() : + pStyleProperties->GetvAnchor() ); + + pFrameProperties[10].Value <<= text::WrapTextMode( + rAppendContext.pLastParagraphProperties->GetWrap() >= 0 ? + rAppendContext.pLastParagraphProperties->GetWrap() : + pStyleProperties->GetWrap()); + + sal_Int32 nBottomDist; + sal_Int32 nTopDist = nBottomDist = + rAppendContext.pLastParagraphProperties->GethSpace() >= 0 ? + rAppendContext.pLastParagraphProperties->GethSpace() : + pStyleProperties->GethSpace(); + + pFrameProperties[11].Value <<= nVertOrient == text::VertOrientation::TOP ? 0 : nTopDist; + pFrameProperties[12].Value <<= nVertOrient == text::VertOrientation::BOTTOM ? 0 : nBottomDist; + + sal_Int32 nRightDist; + sal_Int32 nLeftDist = nRightDist = + rAppendContext.pLastParagraphProperties->GetvSpace() >= 0 ? + rAppendContext.pLastParagraphProperties->GetvSpace() : + pStyleProperties->GetvSpace() >= 0 ? pStyleProperties->GetvSpace() : 0; + pFrameProperties[13].Value <<= nHoriOrient == text::HoriOrientation::LEFT ? 0 : nLeftDist; + pFrameProperties[14].Value <<= nHoriOrient == text::HoriOrientation::RIGHT ? 0 : nRightDist; + + lcl_MoveBorderPropertiesToFrame(aFrameProperties, + rAppendContext.pLastParagraphProperties->GetStartingRange(), + rAppendContext.pLastParagraphProperties->GetEndingRange()); + } + //frame conversion has to be executed after table conversion + RegisterFrameConversion( + rAppendContext.pLastParagraphProperties->GetStartingRange(), + rAppendContext.pLastParagraphProperties->GetEndingRange(), + aFrameProperties ); + } + catch( const uno::Exception& rEx ) + { + (void)rEx; + } + } +} + void DomainMapper_Impl::finishParagraph( PropertyMapPtr pPropertyMap ) { #ifdef DEBUG_DOMAINMAPPER @@ -771,121 +888,7 @@ void DomainMapper_Impl::finishParagraph( PropertyMapPtr pPropertyMap ) else { //handles (8)(9) and completes (6) - try - { - // - StyleSheetEntryPtr pParaStyle = - m_pStyleSheetTable->FindStyleSheetByConvertedStyleName(rAppendContext.pLastParagraphProperties->GetParaStyleName()); - - uno::Sequence< beans::PropertyValue > aFrameProperties(pParaStyle ? 15: 0); - if ( pParaStyle.get( ) ) - { - const ParagraphProperties* pStyleProperties = dynamic_cast<const ParagraphProperties*>( pParaStyle->pProperties.get() ); - beans::PropertyValue* pFrameProperties = aFrameProperties.getArray(); - pFrameProperties[0].Name = rPropNameSupplier.GetName(PROP_WIDTH); - pFrameProperties[1].Name = rPropNameSupplier.GetName(PROP_HEIGHT); - pFrameProperties[2].Name = rPropNameSupplier.GetName(PROP_SIZE_TYPE); - pFrameProperties[3].Name = rPropNameSupplier.GetName(PROP_WIDTH_TYPE); - pFrameProperties[4].Name = rPropNameSupplier.GetName(PROP_HORI_ORIENT); - pFrameProperties[5].Name = rPropNameSupplier.GetName(PROP_HORI_ORIENT_POSITION); - pFrameProperties[6].Name = rPropNameSupplier.GetName(PROP_HORI_ORIENT_RELATION); - pFrameProperties[7].Name = rPropNameSupplier.GetName(PROP_VERT_ORIENT); - pFrameProperties[8].Name = rPropNameSupplier.GetName(PROP_VERT_ORIENT_POSITION); - pFrameProperties[9].Name = rPropNameSupplier.GetName(PROP_VERT_ORIENT_RELATION); - pFrameProperties[10].Name = rPropNameSupplier.GetName(PROP_SURROUND); - pFrameProperties[11].Name = rPropNameSupplier.GetName(PROP_LEFT_MARGIN); - pFrameProperties[12].Name = rPropNameSupplier.GetName(PROP_RIGHT_MARGIN); - pFrameProperties[13].Name = rPropNameSupplier.GetName(PROP_TOP_MARGIN); - pFrameProperties[14].Name = rPropNameSupplier.GetName(PROP_BOTTOM_MARGIN); - sal_Int32 nWidth = - rAppendContext.pLastParagraphProperties->Getw() > 0 ? - rAppendContext.pLastParagraphProperties->Getw() : - pStyleProperties->Getw(); - bool bAutoWidth = nWidth < 1; - if( bAutoWidth ) - nWidth = DEFAULT_FRAME_MIN_WIDTH; - pFrameProperties[0].Value <<= nWidth; - pFrameProperties[1].Value <<= - rAppendContext.pLastParagraphProperties->Geth() > 0 ? - rAppendContext.pLastParagraphProperties->Geth() : - pStyleProperties->Geth(); - pFrameProperties[2].Value <<= sal_Int16( - rAppendContext.pLastParagraphProperties->GethRule() >= 0 ? - rAppendContext.pLastParagraphProperties->GethRule() : - pStyleProperties->GethRule() >=0 ? pStyleProperties->GethRule() : text::SizeType::VARIABLE); - - pFrameProperties[3].Value <<= bAutoWidth ? text::SizeType::MIN : text::SizeType::FIX; - - sal_Int16 nHoriOrient = sal_Int16( - rAppendContext.pLastParagraphProperties->GetxAlign() >= 0 ? - rAppendContext.pLastParagraphProperties->GetxAlign() : - pStyleProperties->GetxAlign() >= 0 ? pStyleProperties->GetxAlign() : text::HoriOrientation::NONE ); - pFrameProperties[4].Value <<= nHoriOrient; - - pFrameProperties[5].Value <<= - rAppendContext.pLastParagraphProperties->IsxValid() ? - rAppendContext.pLastParagraphProperties->Getx() : pStyleProperties->Getx(); - pFrameProperties[6].Value <<= sal_Int16( - rAppendContext.pLastParagraphProperties->GethAnchor() >= 0 ? - rAppendContext.pLastParagraphProperties->GethAnchor() : - pStyleProperties->GethAnchor() ); - - sal_Int16 nVertOrient = sal_Int16( - rAppendContext.pLastParagraphProperties->GetyAlign() >= 0 ? - rAppendContext.pLastParagraphProperties->GetyAlign() : - pStyleProperties->GetyAlign() >= 0 ? pStyleProperties->GetyAlign() : text::VertOrientation::NONE ); - pFrameProperties[7].Value <<= nVertOrient; - - pFrameProperties[8].Value <<= - rAppendContext.pLastParagraphProperties->IsyValid() ? - rAppendContext.pLastParagraphProperties->Gety() : pStyleProperties->Gety(); - pFrameProperties[9].Value <<= sal_Int16( - rAppendContext.pLastParagraphProperties->GetvAnchor() >= 0 ? - rAppendContext.pLastParagraphProperties->GetvAnchor() : - pStyleProperties->GetvAnchor() ); - - pFrameProperties[10].Value <<= text::WrapTextMode( - rAppendContext.pLastParagraphProperties->GetWrap() >= 0 ? - rAppendContext.pLastParagraphProperties->GetWrap() : - pStyleProperties->GetWrap()); - - sal_Int32 nBottomDist; - sal_Int32 nTopDist = nBottomDist = - rAppendContext.pLastParagraphProperties->GethSpace() >= 0 ? - rAppendContext.pLastParagraphProperties->GethSpace() : - pStyleProperties->GethSpace(); - - pFrameProperties[11].Value <<= nVertOrient == text::VertOrientation::TOP ? 0 : nTopDist; - pFrameProperties[12].Value <<= nVertOrient == text::VertOrientation::BOTTOM ? 0 : nBottomDist; - - sal_Int32 nRightDist; - sal_Int32 nLeftDist = nRightDist = - rAppendContext.pLastParagraphProperties->GetvSpace() >= 0 ? - rAppendContext.pLastParagraphProperties->GetvSpace() : - pStyleProperties->GetvSpace() >= 0 ? pStyleProperties->GetvSpace() : 0; - pFrameProperties[13].Value <<= nHoriOrient == text::HoriOrientation::LEFT ? 0 : nLeftDist; - pFrameProperties[14].Value <<= nHoriOrient == text::HoriOrientation::RIGHT ? 0 : nRightDist; - - lcl_MoveBorderPropertiesToFrame(aFrameProperties, - rAppendContext.pLastParagraphProperties->GetStartingRange(), - rAppendContext.pLastParagraphProperties->GetEndingRange()); - } - //frame conversion has to be executed after table conversion - RegisterFrameConversion( - rAppendContext.pLastParagraphProperties->GetStartingRange(), - rAppendContext.pLastParagraphProperties->GetEndingRange(), - aFrameProperties ); - // next frame follows directly - if( pParaContext->IsFrameMode() ) - { - pToBeSavedProperties.reset( new ParagraphProperties(*pParaContext) ); - lcl_AddRangeAndStyle(pToBeSavedProperties, xTextAppend, pPropertyMap); - } - } - catch( const uno::Exception& rEx ) - { - (void)rEx; - } + CheckUnregisteredFrameConversion( ); } } diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index 926caeacebcc..d7d05462f7b1 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -578,6 +578,7 @@ public: void SetCustomFtnMark(bool bSet) { m_bIsCustomFtnMark = bSet; } bool IsCustomFtnMark() const { return m_bIsCustomFtnMark; } + void CheckUnregisteredFrameConversion( ); void RegisterFrameConversion( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > xFrameStartRange, ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > xFrameEndRange, |