[Libreoffice-commits] .: offapi/com sw/inc sw/source

Miklos Vajna vmiklos at kemper.freedesktop.org
Mon Jul 2 06:41:28 PDT 2012


 offapi/com/sun/star/text/TextPageStyle.idl |   20 +++++
 sw/inc/cmdid.h                             |    2 
 sw/inc/unoprnms.hxx                        |    4 -
 sw/source/core/doc/docdesc.cxx             |  101 ++++++++++++++++++++++++++++-
 sw/source/core/doc/docfmt.cxx              |    8 ++
 sw/source/core/layout/pagedesc.cxx         |    8 ++
 sw/source/core/unocore/unomap.cxx          |    2 
 sw/source/core/unocore/unoprnms.cxx        |    2 
 sw/source/core/unocore/unostyle.cxx        |   13 +++
 9 files changed, 157 insertions(+), 3 deletions(-)

New commits:
commit dba6a280968eb7ecca2f74d343ca8fccde1560bc
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Mon Jul 2 15:14:07 2012 +0200

    sw: initial HeaderTextFirst / FooterTextFirst
    
    The header/footer text for the first page can now be written (document
    model ready), but layout doesn't take it into account yet.  Also,
    SwDoc::ChgPageDesc() has some copy&paste, will fix that soon.
    
    Change-Id: Ic28659f028e7db4aa1b6eefc76a4e672127e2c98

diff --git a/offapi/com/sun/star/text/TextPageStyle.idl b/offapi/com/sun/star/text/TextPageStyle.idl
index cd98587..d05c3f3 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).
 
         <p>If set to zero, the height of the current page is used as limit.</p>
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index faf4862..91c8158 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 44b7f5c..6bf1256 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 2aa2b20..52934cd 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 b18f21f..bb8a40f 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 5bbee57..ae71cc8 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<SwFrm,SwFmt> aIter( GetFirst() );
+        for( SwFrm* pLast = aIter.First(); pLast; pLast = aIter.Next() )
+        {
+            if( pLast->IsPageFrm() )
+                ((SwPageFrm*)pLast)->PrepareRegisterChg();
+        }
+    }
 }
 
 /*************************************************************************
diff --git a/sw/source/core/unocore/unomap.cxx b/sw/source/core/unocore/unomap.cxx
index 365d9ce..6ae3387 100644
--- a/sw/source/core/unocore/unomap.cxx
+++ b/sw/source/core/unocore/unomap.cxx
@@ -834,9 +834,11 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s
                     { SW_PROP_NMID(UNO_NAME_HEADER_TEXT), FN_UNO_HEADER,        CPPU_E2T(CPPUTYPE_REFTEXT),         PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY, 0},
                     { SW_PROP_NMID(UNO_NAME_HEADER_TEXT_LEFT), FN_UNO_HEADER_LEFT,     CPPU_E2T(CPPUTYPE_REFTEXT),          PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY, 0},
                     { SW_PROP_NMID(UNO_NAME_HEADER_TEXT_RIGHT), FN_UNO_HEADER_RIGHT,    CPPU_E2T(CPPUTYPE_REFTEXT),         PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY, 0},
+                    { SW_PROP_NMID(UNO_NAME_HEADER_TEXT_FIRST), FN_UNO_HEADER_FIRST,    CPPU_E2T(CPPUTYPE_REFTEXT),         PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY, 0},
                     { SW_PROP_NMID(UNO_NAME_FOOTER_TEXT), FN_UNO_FOOTER,        CPPU_E2T(CPPUTYPE_REFTEXT),         PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY, 0},
                     { SW_PROP_NMID(UNO_NAME_FOOTER_TEXT_LEFT), FN_UNO_FOOTER_LEFT,  CPPU_E2T(CPPUTYPE_REFTEXT),         PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY, 0},
                     { SW_PROP_NMID(UNO_NAME_FOOTER_TEXT_RIGHT), FN_UNO_FOOTER_RIGHT,    CPPU_E2T(CPPUTYPE_REFTEXT),         PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY, 0},
+                    { SW_PROP_NMID(UNO_NAME_FOOTER_TEXT_FIRST), FN_UNO_FOOTER_FIRST,    CPPU_E2T(CPPUTYPE_REFTEXT),         PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY, 0},
                     { SW_PROP_NMID(UNO_NAME_FOLLOW_STYLE), FN_UNO_FOLLOW_STYLE,     CPPU_E2T(CPPUTYPE_OUSTRING),        PROPERTY_NONE, 0},
                     { SW_PROP_NMID(UNO_NAME_USER_DEFINED_ATTRIBUTES), RES_UNKNOWNATR_CONTAINER, CPPU_E2T(CPPUTYPE_REFNAMECNT), PropertyAttribute::MAYBEVOID, 0 },
                     { SW_PROP_NMID(UNO_NAME_IS_PHYSICAL), FN_UNO_IS_PHYSICAL,     CPPU_E2T(CPPUTYPE_BOOLEAN), PropertyAttribute::READONLY, 0},
diff --git a/sw/source/core/unocore/unoprnms.cxx b/sw/source/core/unocore/unoprnms.cxx
index 50497c9..dec2b5d 100644
--- a/sw/source/core/unocore/unoprnms.cxx
+++ b/sw/source/core/unocore/unoprnms.cxx
@@ -791,6 +791,8 @@ const SwPropNameTab aPropNameTab = {
 /* 0750 PARAGRAPH_STYLE_NAME */           {MAP_CHAR_LEN("ParagraphStyleName")},
 /* 0751 HEADER_IS_SHARED_FIRST */             {MAP_CHAR_LEN("HeaderIsSharedFirst")},
 /* 0752 FOOTER_IS_SHARED_FIRST */             {MAP_CHAR_LEN("FooterIsSharedFirst")},
+/* 0753 HEADER_TEXT_FIRST */            {MAP_CHAR_LEN("HeaderTextFirst")},
+/* 0754 FOOTER_TEXT_FIRST */            {MAP_CHAR_LEN("FooterTextFirst")},
 
 // new items in this array must match enum SwPropNameIds
 };
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 1795c16..021735c 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -3145,9 +3145,11 @@ void SAL_CALL SwXPageStyle::SetPropertyValues_Impl(
                 case  FN_UNO_HEADER       :
                 case  FN_UNO_HEADER_LEFT  :
                 case  FN_UNO_HEADER_RIGHT :
+                case  FN_UNO_HEADER_FIRST :
                 case  FN_UNO_FOOTER       :
                 case  FN_UNO_FOOTER_LEFT  :
                 case  FN_UNO_FOOTER_RIGHT :
+                case  FN_UNO_FOOTER_FIRST :
                     throw lang::IllegalArgumentException();
                 //break;
                 default:
@@ -3254,6 +3256,7 @@ uno::Sequence< uno::Any > SAL_CALL SwXPageStyle::GetPropertyValues_Impl(
             sal_uInt16 nRes = 0;
             bool bHeader = false;
             sal_Bool bLeft = sal_False;
+            bool bFirst = false;
             switch(pEntry->nWID)
             {
                 case FN_UNO_HEADER_ON:
@@ -3362,6 +3365,8 @@ uno::Sequence< uno::Any > SAL_CALL SwXPageStyle::GetPropertyValues_Impl(
                     goto Header;
                 case  FN_UNO_HEADER_LEFT  :
                     bLeft = sal_True; goto Header;
+                case  FN_UNO_HEADER_FIRST  :
+                    bFirst = true; goto Header;
                 case  FN_UNO_HEADER_RIGHT :
                     goto Header;
 Header:
@@ -3371,6 +3376,8 @@ Header:
                     goto Footer;
                 case  FN_UNO_FOOTER_LEFT  :
                     bLeft = sal_True; goto Footer;
+                case  FN_UNO_FOOTER_FIRST  :
+                    bFirst = sal_True; goto Footer;
                 case  FN_UNO_FOOTER_RIGHT :
 Footer:
                     nRes = RES_FOOTER;
@@ -3380,6 +3387,8 @@ MakeObject:
                     const SwFrmFmt* pFrmFmt = 0;
                     sal_Bool bShare = (bHeader && rDesc.IsHeaderShared())||
                                     (!bHeader && rDesc.IsFooterShared());
+                    bool bShareFirst = (bHeader && rDesc.IsHeaderSharedFirst())||
+                                    (!bHeader && rDesc.IsFooterSharedFirst());
                     // TextLeft returns the left content if there is one,
                     // Text and TextRight return the master content.
                     // TextRight does the same as Text and is for
@@ -3388,6 +3397,10 @@ MakeObject:
                     {
                         pFrmFmt = &rDesc.GetLeft();
                     }
+                    else if (bFirst && !bShareFirst)
+                    {
+                        pFrmFmt = &rDesc.GetFirst();
+                    }
                     else
                     {
                         pFrmFmt = &rDesc.GetMaster();


More information about the Libreoffice-commits mailing list