summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2013-08-05 17:08:20 +0200
committerMiklos Vajna <vmiklos@suse.cz>2013-08-05 17:38:20 +0200
commitc7884509a84d46a9d99b2950159d949589862f3a (patch)
tree606086d68d1fe5f1ea6fd277e0e29852ddd5d26d
parent808350a697a79ebcc1708f18de407294576a793e (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. Change-Id: I4d9a4585e795220533909bd1d467d933caaa0d71
-rw-r--r--sw/qa/extras/rtfimport/data/fdo67498.rtf5
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx8
-rw-r--r--writerfilter/source/dmapper/PropertyMap.cxx47
-rw-r--r--writerfilter/source/dmapper/PropertyMap.hxx2
4 files changed, 43 insertions, 19 deletions
diff --git a/sw/qa/extras/rtfimport/data/fdo67498.rtf b/sw/qa/extras/rtfimport/data/fdo67498.rtf
new file mode 100644
index 000000000000..f1058c0ae9c2
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo67498.rtf
@@ -0,0 +1,5 @@
+{\rtf1\paperw11906\paperh16838\margl5954\margr454\margt567\margb8505\sectd\sbknone
+a\sect\sectd\sbknone
+b\sect\sectd
+c\par
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index f1e12ba6a9c3..44cdbdfc84ae 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -158,6 +158,7 @@ public:
void testFdo64637();
void testN820504();
void testFdo67365();
+ void testFdo67498();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -301,6 +302,7 @@ void Test::run()
{"fdo64637.rtf", &Test::testFdo64637},
{"n820504.rtf", &Test::testN820504},
{"fdo67365.rtf", &Test::testFdo67365},
+ {"fdo67498.rtf", &Test::testFdo67498},
};
header();
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -1470,6 +1472,12 @@ void Test::testFdo67365()
CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_LEFT, static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(getParagraphOfText(1, xCell->getText()), "ParaAdjust")));
}
+void Test::testFdo67498()
+{
+ // Left margin of the default page style wasn't set (was 2000).
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(5954)), getProperty<sal_Int32>(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "LeftMargin"));
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index 12380f7698c1..257ec94d9e51 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -843,6 +843,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 )) = uno::makeAny( m_nLeftMargin );
+ operator[]( PropertyDefinition( PROP_RIGHT_MARGIN )) = uno::makeAny( m_nRightMargin );
+
+ if (rDM_Impl.m_oBackgroundColor)
+ operator[](PropertyDefinition(PROP_BACK_COLOR )) = 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();
@@ -891,6 +914,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& )
{
@@ -922,25 +949,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 )) = uno::makeAny( m_nLeftMargin );
- operator[]( PropertyDefinition( PROP_RIGHT_MARGIN )) = uno::makeAny( m_nRightMargin );
-
- if (rDM_Impl.m_oBackgroundColor)
- operator[](PropertyDefinition(PROP_BACK_COLOR )) = 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 d5d70d71823e..ed0f6cb47485 100644
--- a/writerfilter/source/dmapper/PropertyMap.hxx
+++ b/writerfilter/source/dmapper/PropertyMap.hxx
@@ -265,6 +265,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;