summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2012-12-19 22:35:38 +0100
committerMiklos Vajna <vmiklos@suse.cz>2012-12-19 22:45:56 +0100
commitbee957fc48867aa1b98b8672b02a187a461f4e38 (patch)
tree6368b1d84059370710125e1956d7ad0553fa2c2c
parent54b6b5ddaf6b36717eeb44d8dc6f3957056a1938 (diff)
fdo#57881 sw: make UseOnPage independent from SvxPageUsage
UseOnPage got changed in commit fa0f42bafbf24e9141ddee728b160b5ab47077f2, but SvxPageUsage got unchanged. Given that right now other applications don't support first page headers / footers, leave SvxPageUsage unchanged and provide conversion methods between the two types.
-rw-r--r--sw/qa/extras/odfimport/odfimport.cxx9
-rw-r--r--sw/source/ui/utlui/uitool.cxx34
2 files changed, 41 insertions, 2 deletions
diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx
index 78531b439c91..885413c8623d 100644
--- a/sw/qa/extras/odfimport/odfimport.cxx
+++ b/sw/qa/extras/odfimport/odfimport.cxx
@@ -40,6 +40,7 @@ public:
void testEmptySvgFamilyName();
void testHideAllSections();
void testOdtBorders();
+ void testPageStyleLayoutDefault();
void testPageStyleLayoutRight();
CPPUNIT_TEST_SUITE(Test);
@@ -58,6 +59,7 @@ void Test::run()
{"empty-svg-family-name.odt", &Test::testEmptySvgFamilyName},
{"fdo53210.odt", &Test::testHideAllSections},
{"borders_ooo33.odt", &Test::testOdtBorders},
+ {"hello.odt", &Test::testPageStyleLayoutDefault},
{"hello.odt", &Test::testPageStyleLayoutRight},
};
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -273,6 +275,13 @@ void Test::testOdtBorders()
} while(xParaEnum->hasMoreElements());
}
+void Test::testPageStyleLayoutDefault()
+{
+ uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName("Default Style"), uno::UNO_QUERY);
+ // This was style::PageStyleLayout_MIRRORED.
+ CPPUNIT_ASSERT_EQUAL(style::PageStyleLayout_ALL, getProperty<style::PageStyleLayout>(xPropertySet, "PageStyleLayout"));
+}
+
void Test::testPageStyleLayoutRight()
{
uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName("Default Style"), uno::UNO_QUERY);
diff --git a/sw/source/ui/utlui/uitool.cxx b/sw/source/ui/utlui/uitool.cxx
index 6cd7c8b9cbbf..1db6d3817c58 100644
--- a/sw/source/ui/utlui/uitool.cxx
+++ b/sw/source/ui/utlui/uitool.cxx
@@ -147,6 +147,36 @@ void FillHdFt(SwFrmFmt* pFmt, const SfxItemSet& rSet)
pFmt->SetFmtAttr(aSet);
}
+/// Convert from UseOnPage to SvxPageUsage.
+UseOnPage lcl_convertUseToSvx(UseOnPage nUse)
+{
+ UseOnPage nRet = nsUseOnPage::PD_NONE;
+ if ((nUse & nsUseOnPage::PD_LEFT) == nsUseOnPage::PD_LEFT)
+ nRet |= SVX_PAGE_LEFT;
+ if ((nUse & nsUseOnPage::PD_RIGHT) == nsUseOnPage::PD_RIGHT)
+ nRet |= SVX_PAGE_RIGHT;
+ if ((nUse & nsUseOnPage::PD_ALL) == nsUseOnPage::PD_ALL)
+ nRet |= SVX_PAGE_ALL;
+ if ((nUse & nsUseOnPage::PD_MIRROR) == nsUseOnPage::PD_MIRROR)
+ nRet |= SVX_PAGE_MIRROR;
+ return nRet;
+}
+
+/// Convert from SvxPageUsage to UseOnPage.
+UseOnPage lcl_convertUseFromSvx(UseOnPage nUse)
+{
+ UseOnPage nRet = nsUseOnPage::PD_NONE;
+ if ((nUse & SVX_PAGE_LEFT) == SVX_PAGE_LEFT)
+ nRet |= nsUseOnPage::PD_LEFT;
+ if ((nUse & SVX_PAGE_RIGHT) == SVX_PAGE_RIGHT)
+ nRet |= nsUseOnPage::PD_RIGHT;
+ if ((nUse & SVX_PAGE_ALL) == SVX_PAGE_ALL)
+ nRet |= nsUseOnPage::PD_ALL;
+ if ((nUse & SVX_PAGE_MIRROR) == SVX_PAGE_MIRROR)
+ nRet |= nsUseOnPage::PD_MIRROR;
+ return nRet;
+}
+
/*--------------------------------------------------------------------
Beschreibung: PageDesc <-> in Sets wandeln und zurueck
--------------------------------------------------------------------*/
@@ -171,7 +201,7 @@ void ItemSetToPageDesc( const SfxItemSet& rSet, SwPageDesc& rPageDesc )
if(nUse & 0x04)
nUse |= 0x03;
if(nUse)
- rPageDesc.SetUseOn( (UseOnPage) nUse );
+ rPageDesc.SetUseOn( lcl_convertUseFromSvx((UseOnPage) nUse) );
rPageDesc.SetLandscape(rPageItem.IsLandscape());
SvxNumberType aNumType;
aNumType.SetNumberingType( static_cast< sal_Int16 >(rPageItem.GetNumType()) );
@@ -320,7 +350,7 @@ void PageDescToItemSet( const SwPageDesc& rPageDesc, SfxItemSet& rSet)
//
SvxPageItem aPageItem(SID_ATTR_PAGE);
aPageItem.SetDescName(rPageDesc.GetName());
- aPageItem.SetPageUsage(rPageDesc.GetUseOn());
+ aPageItem.SetPageUsage(lcl_convertUseToSvx(rPageDesc.GetUseOn()));
aPageItem.SetLandscape(rPageDesc.GetLandscape());
aPageItem.SetNumType((SvxNumType)rPageDesc.GetNumType().GetNumberingType());
rSet.Put(aPageItem);