merge the formfield patch from ooo-build
[ooovba.git] / sc / source / ui / pagedlg / hfedtdlg.cxx
blob537c9e1a416048852e444be365f33d48ac4d2316
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: hfedtdlg.cxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 #undef SC_DLLIMPLEMENTATION
38 //------------------------------------------------------------------
40 #include "scitems.hxx"
41 #include <svtools/eitem.hxx>
43 #include "hfedtdlg.hxx"
44 #include "global.hxx"
45 #include "globstr.hrc"
46 //CHINA001 #include "tphfedit.hxx"
47 #include "scresid.hxx"
48 #include "hfedtdlg.hrc"
49 #include "scuitphfedit.hxx" //CHINA001
50 //------------------------------------------------------------------
52 // macros from docsh4.cxx
53 //! use SIDs?
55 #define IS_SHARE_HEADER(set) \
56 ((SfxBoolItem&) \
57 ((SvxSetItem&)(set).Get(ATTR_PAGE_HEADERSET)).GetItemSet(). \
58 Get(ATTR_PAGE_SHARED)).GetValue()
60 #define IS_SHARE_FOOTER(set) \
61 ((SfxBoolItem&) \
62 ((SvxSetItem&)(set).Get(ATTR_PAGE_FOOTERSET)).GetItemSet(). \
63 Get(ATTR_PAGE_SHARED)).GetValue()
65 //==================================================================
67 ScHFEditDlg::ScHFEditDlg( SfxViewFrame* pFrameP,
68 Window* pParent,
69 const SfxItemSet& rCoreSet,
70 const String& rPageStyle,
71 USHORT nResIdP )
72 : SfxTabDialog( pFrameP, pParent, ScResId( nResIdP ), &rCoreSet )
74 eNumType = ((const SvxPageItem&)rCoreSet.Get(ATTR_PAGE)).GetNumType();
76 String aTmp = GetText();
78 aTmp.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
79 aTmp += ScGlobal::GetRscString( STR_PAGESTYLE );
80 aTmp.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ": " ));
81 aTmp += rPageStyle;
82 aTmp += ')';
83 SetText( aTmp );
85 switch ( nResIdP )
87 case RID_SCDLG_HFED_HEADER:
88 case RID_SCDLG_HFEDIT_HEADER:
89 AddTabPage( 1, ScRightHeaderEditPage::Create, NULL );
90 AddTabPage( 2, ScLeftHeaderEditPage::Create, NULL );
91 break;
93 case RID_SCDLG_HFED_FOOTER:
94 case RID_SCDLG_HFEDIT_FOOTER:
95 AddTabPage( 1, ScRightFooterEditPage::Create, NULL );
96 AddTabPage( 2, ScLeftFooterEditPage::Create, NULL );
97 break;
99 case RID_SCDLG_HFEDIT_LEFTHEADER:
100 AddTabPage( 1, ScLeftHeaderEditPage::Create, NULL );
101 break;
103 case RID_SCDLG_HFEDIT_RIGHTHEADER:
104 AddTabPage( 1, ScRightHeaderEditPage::Create, NULL );
105 break;
107 case RID_SCDLG_HFEDIT_LEFTFOOTER:
108 AddTabPage( 1, ScLeftFooterEditPage::Create, NULL );
109 break;
111 case RID_SCDLG_HFEDIT_RIGHTFOOTER:
112 AddTabPage( 1, ScRightFooterEditPage::Create, NULL );
113 break;
115 case RID_SCDLG_HFEDIT_SHDR:
116 AddTabPage( 1, ScRightHeaderEditPage::Create, NULL );
117 AddTabPage( 2, ScRightFooterEditPage::Create, NULL );
118 AddTabPage( 3, ScLeftFooterEditPage::Create, NULL );
119 break;
121 case RID_SCDLG_HFEDIT_SFTR:
122 AddTabPage( 1, ScRightHeaderEditPage::Create, NULL );
123 AddTabPage( 2, ScLeftHeaderEditPage::Create, NULL );
124 AddTabPage( 3, ScRightFooterEditPage::Create, NULL );
125 break;
127 case RID_SCDLG_HFEDIT_ALL:
128 AddTabPage( 1, ScRightHeaderEditPage::Create, NULL );
129 AddTabPage( 2, ScLeftHeaderEditPage::Create, NULL );
130 AddTabPage( 3, ScRightFooterEditPage::Create, NULL );
131 AddTabPage( 4, ScLeftFooterEditPage::Create, NULL );
132 break;
134 default:
135 case RID_SCDLG_HFEDIT:
137 const SvxPageItem& rPageItem = (const SvxPageItem&)
138 rCoreSet.Get(
139 rCoreSet.GetPool()->GetWhich(SID_ATTR_PAGE) );
141 BOOL bRightPage = ( SVX_PAGE_LEFT !=
142 SvxPageUsage(rPageItem.GetPageUsage()) );
144 if ( bRightPage )
146 AddTabPage( 1, ScRightHeaderEditPage::Create, NULL );
147 AddTabPage( 2, ScRightFooterEditPage::Create, NULL );
149 else
151 // #69193a# respect "shared" setting
153 BOOL bShareHeader = IS_SHARE_HEADER(rCoreSet);
154 if ( bShareHeader )
155 AddTabPage( 1, ScRightHeaderEditPage::Create, NULL );
156 else
157 AddTabPage( 1, ScLeftHeaderEditPage::Create, NULL );
159 BOOL bShareFooter = IS_SHARE_FOOTER(rCoreSet);
160 if ( bShareFooter )
161 AddTabPage( 2, ScRightFooterEditPage::Create, NULL );
162 else
163 AddTabPage( 2, ScLeftFooterEditPage::Create, NULL );
166 break;
169 FreeResource();
172 // -----------------------------------------------------------------------
174 __EXPORT ScHFEditDlg::~ScHFEditDlg()
178 // -----------------------------------------------------------------------
180 void __EXPORT ScHFEditDlg::PageCreated( USHORT /* nId */, SfxTabPage& rPage )
182 // kann ja nur ne ScHFEditPage sein...
184 ((ScHFEditPage&)rPage).SetNumType(eNumType);