summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2013-08-05 17:08:20 +0200
committerBosdonnat Cedric <cedric.bosdonnat@free.fr>2013-08-07 07:31:30 +0000
commit0fabc1154c962e8f2884f9afaa37b666b08cf833 (patch)
tree29b3b607925353840d0917a1c5c49f82d856cf07 /writerfilter
parent57de36c208a2a745bd40fad452d7a62871829d71 (diff)
fdo#67498 RTF import: fix missing margins vs continuous section breaks
The document had 3 sections, separated by continuous section breaks. Previously only margins from the last section were imported, this way the first page had default margins. Now margins are also applied when we hit continuous section breaks. This way margin values from the last section break affecting the page wins. A later commit could improve this further by setting the minimum of these and setting a section margin for each non-minimal sections. (cherry picked from commit c7884509a84d46a9d99b2950159d949589862f3a) Conflicts: writerfilter/source/dmapper/PropertyMap.cxx Change-Id: I4d9a4585e795220533909bd1d467d933caaa0d71 Reviewed-on: https://gerrit.libreoffice.org/5286 Reviewed-by: Bosdonnat Cedric <cedric.bosdonnat@free.fr> Tested-by: Bosdonnat Cedric <cedric.bosdonnat@free.fr>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/PropertyMap.cxx47
-rw-r--r--writerfilter/source/dmapper/PropertyMap.hxx2
2 files changed, 30 insertions, 19 deletions
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index 9de69fce6568..623c20c87c3f 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -820,6 +820,29 @@ uno::Reference<beans::XPropertySet> lcl_GetRangeProperties(bool bIsFirstSection,
return xRangeProperties;
}
+void SectionPropertyMap::HandleMarginsHeaderFooter(DomainMapper_Impl& rDM_Impl)
+{
+ if( m_nDzaGutter > 0 )
+ {
+ //todo: iGutterPos from DocProperties are missing
+ if( m_bGutterRTL )
+ m_nRightMargin += m_nDzaGutter;
+ else
+ m_nLeftMargin += m_nDzaGutter;
+ }
+ operator[]( PropertyDefinition( PROP_LEFT_MARGIN, false )) = uno::makeAny( m_nLeftMargin );
+ operator[]( PropertyDefinition( PROP_RIGHT_MARGIN, false )) = uno::makeAny( m_nRightMargin );
+
+ if (rDM_Impl.m_oBackgroundColor)
+ operator[](PropertyDefinition(PROP_BACK_COLOR, false)) = uno::makeAny(*rDM_Impl.m_oBackgroundColor);
+
+ /*** if headers/footers are available then the top/bottom margins of the
+ header/footer are copied to the top/bottom margin of the page
+ */
+ CopyLastHeaderFooter( false, rDM_Impl );
+ PrepareHeaderFooterProperties( false );
+}
+
void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
{
PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
@@ -868,6 +891,10 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
try
{
xRangeProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_PAGE_DESC_NAME), uno::makeAny(aName));
+ uno::Reference<beans::XPropertySet> xPageStyle (rDM_Impl.GetPageStyles()->getByName(aName), uno::UNO_QUERY_THROW);
+ HandleMarginsHeaderFooter(rDM_Impl);
+ if (rDM_Impl.IsNewDoc())
+ _ApplyProperties(xPageStyle);
}
catch( const uno::Exception& )
{
@@ -899,25 +926,7 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
//get the properties and create appropriate page styles
uno::Reference< beans::XPropertySet > xFollowPageStyle = GetPageStyle( rDM_Impl.GetPageStyles(), rDM_Impl.GetTextFactory(), false );
- if( m_nDzaGutter > 0 )
- {
- //todo: iGutterPos from DocProperties are missing
- if( m_bGutterRTL )
- m_nRightMargin += m_nDzaGutter;
- else
- m_nLeftMargin += m_nDzaGutter;
- }
- operator[]( PropertyDefinition( PROP_LEFT_MARGIN, false )) = uno::makeAny( m_nLeftMargin );
- operator[]( PropertyDefinition( PROP_RIGHT_MARGIN, false )) = uno::makeAny( m_nRightMargin );
-
- if (rDM_Impl.m_oBackgroundColor)
- operator[](PropertyDefinition(PROP_BACK_COLOR, false)) = uno::makeAny(*rDM_Impl.m_oBackgroundColor);
-
- /*** if headers/footers are available then the top/bottom margins of the
- header/footer are copied to the top/bottom margin of the page
- */
- CopyLastHeaderFooter( false, rDM_Impl );
- PrepareHeaderFooterProperties( false );
+ HandleMarginsHeaderFooter(rDM_Impl);
const OUString sTrayIndex = rPropNameSupplier.GetName( PROP_PRINTER_PAPER_TRAY_INDEX );
if( m_nPaperBin >= 0 )
diff --git a/writerfilter/source/dmapper/PropertyMap.hxx b/writerfilter/source/dmapper/PropertyMap.hxx
index e48c5c564020..a79c2c23f3bb 100644
--- a/writerfilter/source/dmapper/PropertyMap.hxx
+++ b/writerfilter/source/dmapper/PropertyMap.hxx
@@ -266,6 +266,8 @@ public:
sal_Int32 nValue );
void CloseSectionGroup( DomainMapper_Impl& rDM_Impl );
+ /// Handling of margins, header and footer for any kind of sections breaks.
+ void HandleMarginsHeaderFooter(DomainMapper_Impl& rDM_Impl);
};
typedef boost::shared_ptr<SectionPropertyMap> SectionPropertyMapPtr;