diff --git a/offapi/com/sun/star/text/TextPageStyle.idl b/offapi/com/sun/star/text/TextPageStyle.idl index cd98587fe106..d05c3f3111af 100644 --- a/offapi/com/sun/star/text/TextPageStyle.idl +++ b/offapi/com/sun/star/text/TextPageStyle.idl @@ -98,6 +98,16 @@ published service TextPageStyle //------------------------------------------------------------------------- + /** contains the interface to the text of the header of first pages. + + @see com::sun::star::text::Text + + @since LibreOffice 3.7 + */ + [optional, property] com::sun::star::text::XText HeaderTextFirst; + + //------------------------------------------------------------------------- + /** contains the interface to the text of the footer. @see com::sun::star::text::Text @@ -122,6 +132,16 @@ published service TextPageStyle //------------------------------------------------------------------------- + /** contains the interface to the text of the footer of a first page. + + @see com::sun::star::text::Text + + @since LibreOffice 3.7 + */ + [optional, property] com::sun::star::text::XText FooterTextFirst; + + //------------------------------------------------------------------------- + /** contains the maximum height of the footnote area (in 1/100 mm).
If set to zero, the height of the current page is used as limit.
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h index faf4862b66a6..91c8158ce036 100644 --- a/sw/inc/cmdid.h +++ b/sw/inc/cmdid.h @@ -725,6 +725,8 @@ included in c-context files, so c++ style stuff will cause problems. #define FN_EMBEDDED_OBJECT (FN_EXTRA2 + 116) #define FN_UNO_HEADER_SHARE_FIRST_CONTENT (FN_EXTRA2 + 117) #define FN_UNO_FOOTER_SHARE_FIRST_CONTENT (FN_EXTRA2 + 118) +#define FN_UNO_HEADER_FIRST (FN_EXTRA2 + 119) +#define FN_UNO_FOOTER_FIRST (FN_EXTRA2 + 120) /*------------------------------------------------ -------------------- Area: Help diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx index 44b7f5c8d945..6bf125612d8d 100644 --- a/sw/inc/unoprnms.hxx +++ b/sw/inc/unoprnms.hxx @@ -818,8 +818,10 @@ enum SwPropNameIds /* 0750 */ UNO_NAME_HEADER_IS_SHARED_FIRST, /* 0751 */ UNO_NAME_FOOTER_IS_SHARED_FIRST, +/* 0752 */ UNO_NAME_HEADER_TEXT_FIRST, +/* 0753 */ UNO_NAME_FOOTER_TEXT_FIRST, -/* 0752 */ SW_PROPNAME_END +/* 0754 */ SW_PROPNAME_END // new items in this array must match SwPropNameTab aPropNameTab }; diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx index 2aa2b20c68b4..52934cdb41b7 100644 --- a/sw/source/core/doc/docdesc.cxx +++ b/sw/source/core/doc/docdesc.cxx @@ -241,7 +241,8 @@ void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged ) const SwFmtHeader &rOldHead = pDesc->GetMaster().GetHeader(); bHeaderFooterChanged |= ( rHead.IsActive() != rOldHead.IsActive() || - rChged.IsHeaderShared() != pDesc->IsHeaderShared() ); + rChged.IsHeaderShared() != pDesc->IsHeaderShared() || + rChged.IsHeaderSharedFirst() != pDesc->IsHeaderSharedFirst() ); } pDesc->GetMaster().SetFmtAttr( rHead ); if ( rChged.IsHeaderShared() || !rHead.IsActive() ) @@ -293,6 +294,55 @@ void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged ) } } + if ( rChged.IsHeaderSharedFirst() || !rHead.IsActive() ) + { + // First shares the header with the Master. + pDesc->GetFirst().SetFmtAttr( pDesc->GetMaster().GetHeader() ); + } + else if ( rHead.IsActive() ) + { // First gets its own header if the Format doesn't alrady have one. + // If it already has one and it points to the same Section as the + // Right one, it needs to get an own Header. + // The content is evidently copied. + const SwFmtHeader &rFirstHead = pDesc->GetFirst().GetHeader(); + if ( !rFirstHead.IsActive() ) + { + SwFmtHeader aHead( MakeLayoutFmt( RND_STD_HEADERL, 0 ) ); + pDesc->GetFirst().SetFmtAttr( aHead ); + // take over additional attributes (margins, borders ...) + ::lcl_DescSetAttr( *rHead.GetHeaderFmt(), *aHead.GetHeaderFmt(), sal_False); + } + else + { + const SwFrmFmt *pRight = rHead.GetHeaderFmt(); + const SwFmtCntnt &aRCnt = pRight->GetCntnt(); + const SwFmtCntnt &aLCnt = rFirstHead.GetHeaderFmt()->GetCntnt(); + if( !aLCnt.GetCntntIdx() ) + pDesc->GetFirst().SetFmtAttr( rChged.GetFirst().GetHeader() ); + else if( (*aRCnt.GetCntntIdx()) == (*aLCnt.GetCntntIdx()) ) + { + SwFrmFmt *pFmt = new SwFrmFmt( GetAttrPool(), "Header", + GetDfltFrmFmt() ); + ::lcl_DescSetAttr( *pRight, *pFmt, sal_False ); + // The section which the right header attribute is pointing + // is copied, and the Index to the StartNode is set to + // the left header attribute. + SwNodeIndex aTmp( GetNodes().GetEndOfAutotext() ); + SwStartNode* pSttNd = GetNodes().MakeEmptySection( aTmp, SwHeaderStartNode ); + SwNodeRange aRange( aRCnt.GetCntntIdx()->GetNode(), 0, + *aRCnt.GetCntntIdx()->GetNode().EndOfSectionNode() ); + aTmp = *pSttNd->EndOfSectionNode(); + GetNodes()._Copy( aRange, aTmp, sal_False ); + + pFmt->SetFmtAttr( SwFmtCntnt( pSttNd ) ); + pDesc->GetFirst().SetFmtAttr( SwFmtHeader( pFmt ) ); + } + else + ::lcl_DescSetAttr( *pRight, + *(SwFrmFmt*)rFirstHead.GetHeaderFmt(), sal_False ); + + } + } pDesc->ChgHeaderShare( rChged.IsHeaderShared() ); pDesc->ChgHeaderShareFirst( rChged.IsHeaderSharedFirst() ); @@ -305,7 +355,8 @@ void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged ) const SwFmtFooter &rOldFoot = pDesc->GetMaster().GetFooter(); bHeaderFooterChanged |= ( rFoot.IsActive() != rOldFoot.IsActive() || - rChged.IsFooterShared() != pDesc->IsFooterShared() ); + rChged.IsFooterShared() != pDesc->IsFooterShared() || + rChged.IsFooterSharedFirst() != pDesc->IsFooterSharedFirst() ); } pDesc->GetMaster().SetFmtAttr( rFoot ); if ( rChged.IsFooterShared() || !rFoot.IsActive() ) @@ -354,6 +405,52 @@ void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged ) *(SwFrmFmt*)rLeftFoot.GetFooterFmt(), sal_False ); } } + if ( rChged.IsFooterSharedFirst() || !rFoot.IsActive() ) + // First shares the Header with the Master. + pDesc->GetFirst().SetFmtAttr( pDesc->GetMaster().GetFooter() ); + else if ( rFoot.IsActive() ) + { // First gets its own Footer if the Format does not already have one. + // If the Format already has a Footer and it points to the same section as the Right one, + // it needs to get an own one. + // The content is evidently copied. + const SwFmtFooter &rFirstFoot = pDesc->GetFirst().GetFooter(); + if ( !rFirstFoot.IsActive() ) + { + SwFmtFooter aFoot( MakeLayoutFmt( RND_STD_FOOTER, 0 ) ); + pDesc->GetFirst().SetFmtAttr( aFoot ); + // Take over additional attributes (margins, borders ...). + ::lcl_DescSetAttr( *rFoot.GetFooterFmt(), *aFoot.GetFooterFmt(), sal_False); + } + else + { + const SwFrmFmt *pRight = rFoot.GetFooterFmt(); + const SwFmtCntnt &aRCnt = pRight->GetCntnt(); + const SwFmtCntnt &aLCnt = rFirstFoot.GetFooterFmt()->GetCntnt(); + if( !aLCnt.GetCntntIdx() ) + pDesc->GetFirst().SetFmtAttr( rChged.GetFirst().GetFooter() ); + else if( (*aRCnt.GetCntntIdx()) == (*aLCnt.GetCntntIdx()) ) + { + SwFrmFmt *pFmt = new SwFrmFmt( GetAttrPool(), "Footer", + GetDfltFrmFmt() ); + ::lcl_DescSetAttr( *pRight, *pFmt, sal_False ); + // The section to which the right footer attribute is pointing + // is copied, and the Index to the StartNode is set to + // the first footer attribute. + SwNodeIndex aTmp( GetNodes().GetEndOfAutotext() ); + SwStartNode* pSttNd = GetNodes().MakeEmptySection( aTmp, SwFooterStartNode ); + SwNodeRange aRange( aRCnt.GetCntntIdx()->GetNode(), 0, + *aRCnt.GetCntntIdx()->GetNode().EndOfSectionNode() ); + aTmp = *pSttNd->EndOfSectionNode(); + GetNodes()._Copy( aRange, aTmp, sal_False ); + + pFmt->SetFmtAttr( SwFmtCntnt( pSttNd ) ); + pDesc->GetFirst().SetFmtAttr( SwFmtFooter( pFmt ) ); + } + else + ::lcl_DescSetAttr( *pRight, + *(SwFrmFmt*)rFirstFoot.GetFooterFmt(), sal_False ); + } + } pDesc->ChgFooterShare( rChged.IsFooterShared() ); pDesc->ChgFooterShareFirst( rChged.IsFooterSharedFirst() ); diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index b18f21f014f7..bb8a40f6c3e7 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -2100,11 +2100,19 @@ void SwDoc::CopyPageDesc( const SwPageDesc& rSrcDesc, SwPageDesc& rDstDesc, CopyHeader( rSrcDesc.GetLeft(), rDstDesc.GetLeft() ); else rDstDesc.GetLeft().SetFmtAttr( rDstDesc.GetMaster().GetHeader() ); + if( !rDstDesc.IsHeaderSharedFirst() ) + CopyHeader( rSrcDesc.GetFirst(), rDstDesc.GetFirst() ); + else + rDstDesc.GetFirst().SetFmtAttr( rDstDesc.GetMaster().GetHeader() ); if( !rDstDesc.IsFooterShared() ) CopyFooter( rSrcDesc.GetLeft(), rDstDesc.GetLeft() ); else rDstDesc.GetLeft().SetFmtAttr( rDstDesc.GetMaster().GetFooter() ); + if( !rDstDesc.IsFooterSharedFirst() ) + CopyFooter( rSrcDesc.GetFirst(), rDstDesc.GetFirst() ); + else + rDstDesc.GetFirst().SetFmtAttr( rDstDesc.GetMaster().GetFooter() ); if( bNotifyLayout && pTmpRoot ) { diff --git a/sw/source/core/layout/pagedesc.cxx b/sw/source/core/layout/pagedesc.cxx index 5bbee57546cd..ae71cc8da7fb 100644 --- a/sw/source/core/layout/pagedesc.cxx +++ b/sw/source/core/layout/pagedesc.cxx @@ -246,6 +246,14 @@ void SwPageDesc::RegisterChange() ((SwPageFrm*)pLast)->PrepareRegisterChg(); } } + { + SwIterator