xref: /aoo42x/main/sc/source/ui/pagedlg/hfedtdlg.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sc.hxx"
30 
31 #undef SC_DLLIMPLEMENTATION
32 
33 
34 
35 //------------------------------------------------------------------
36 
37 #include "scitems.hxx"
38 #include <svl/eitem.hxx>
39 
40 #include "hfedtdlg.hxx"
41 #include "global.hxx"
42 #include "globstr.hrc"
43 //CHINA001 #include "tphfedit.hxx"
44 #include "scresid.hxx"
45 #include "hfedtdlg.hrc"
46 #include "scuitphfedit.hxx" //CHINA001
47 //------------------------------------------------------------------
48 
49 //	macros from docsh4.cxx
50 //!	use SIDs?
51 
52 #define IS_SHARE_HEADER(set) \
53 	((SfxBoolItem&) \
54 		((SvxSetItem&)(set).Get(ATTR_PAGE_HEADERSET)).GetItemSet(). \
55 			Get(ATTR_PAGE_SHARED)).GetValue()
56 
57 #define IS_SHARE_FOOTER(set) \
58 	((SfxBoolItem&) \
59 		((SvxSetItem&)(set).Get(ATTR_PAGE_FOOTERSET)).GetItemSet(). \
60 			Get(ATTR_PAGE_SHARED)).GetValue()
61 
62 //==================================================================
63 
64 ScHFEditDlg::ScHFEditDlg( SfxViewFrame*     pFrameP,
65 						  Window*			pParent,
66 						  const SfxItemSet& rCoreSet,
67 						  const String&		rPageStyle,
68                           sal_uInt16            nResIdP )
69     :   SfxTabDialog( pFrameP, pParent, ScResId( nResIdP ), &rCoreSet )
70 {
71 	eNumType = ((const SvxPageItem&)rCoreSet.Get(ATTR_PAGE)).GetNumType();
72 
73 	String aTmp = GetText();
74 
75 	aTmp.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
76 	aTmp += ScGlobal::GetRscString( STR_PAGESTYLE );
77 	aTmp.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ": " ));
78 	aTmp += rPageStyle;
79 	aTmp += ')';
80 	SetText( aTmp );
81 
82     switch ( nResIdP )
83 	{
84 		case RID_SCDLG_HFED_HEADER:
85 		case RID_SCDLG_HFEDIT_HEADER:
86 			AddTabPage( 1, ScRightHeaderEditPage::Create, NULL );
87 			AddTabPage( 2, ScLeftHeaderEditPage::Create, NULL );
88 			break;
89 
90 		case RID_SCDLG_HFED_FOOTER:
91 		case RID_SCDLG_HFEDIT_FOOTER:
92 			AddTabPage( 1, ScRightFooterEditPage::Create, NULL );
93 			AddTabPage( 2, ScLeftFooterEditPage::Create, NULL );
94 			break;
95 
96 		case RID_SCDLG_HFEDIT_LEFTHEADER:
97 			AddTabPage( 1, ScLeftHeaderEditPage::Create, NULL );
98 			break;
99 
100 		case RID_SCDLG_HFEDIT_RIGHTHEADER:
101 			AddTabPage( 1, ScRightHeaderEditPage::Create, NULL );
102 			break;
103 
104 		case RID_SCDLG_HFEDIT_LEFTFOOTER:
105 			AddTabPage( 1, ScLeftFooterEditPage::Create, NULL );
106 			break;
107 
108 		case RID_SCDLG_HFEDIT_RIGHTFOOTER:
109 			AddTabPage( 1, ScRightFooterEditPage::Create, NULL );
110 			break;
111 
112 		case RID_SCDLG_HFEDIT_SHDR:
113 			AddTabPage( 1, ScRightHeaderEditPage::Create, NULL );
114 			AddTabPage( 2, ScRightFooterEditPage::Create, NULL );
115 			AddTabPage( 3, ScLeftFooterEditPage::Create,  NULL );
116 			break;
117 
118 		case RID_SCDLG_HFEDIT_SFTR:
119 			AddTabPage( 1, ScRightHeaderEditPage::Create, NULL );
120 			AddTabPage( 2, ScLeftHeaderEditPage::Create, NULL );
121 			AddTabPage( 3, ScRightFooterEditPage::Create, NULL );
122 			break;
123 
124 		case RID_SCDLG_HFEDIT_ALL:
125 			AddTabPage( 1, ScRightHeaderEditPage::Create, NULL );
126 			AddTabPage( 2, ScLeftHeaderEditPage::Create, NULL );
127 			AddTabPage( 3, ScRightFooterEditPage::Create, NULL );
128 			AddTabPage( 4, ScLeftFooterEditPage::Create, NULL );
129 			break;
130 
131 		default:
132 		case RID_SCDLG_HFEDIT:
133 			{
134 				const SvxPageItem&	rPageItem = (const SvxPageItem&)
135 							rCoreSet.Get(
136 								rCoreSet.GetPool()->GetWhich(SID_ATTR_PAGE) );
137 
138 				sal_Bool bRightPage = ( SVX_PAGE_LEFT !=
139 									SvxPageUsage(rPageItem.GetPageUsage()) );
140 
141 				if ( bRightPage )
142 				{
143 					AddTabPage( 1, ScRightHeaderEditPage::Create, NULL );
144 					AddTabPage( 2, ScRightFooterEditPage::Create, NULL );
145 				}
146 				else
147 				{
148 					//	#69193a# respect "shared" setting
149 
150 					sal_Bool bShareHeader = IS_SHARE_HEADER(rCoreSet);
151 					if ( bShareHeader )
152 						AddTabPage( 1, ScRightHeaderEditPage::Create, NULL );
153 					else
154 						AddTabPage( 1, ScLeftHeaderEditPage::Create, NULL );
155 
156 					sal_Bool bShareFooter = IS_SHARE_FOOTER(rCoreSet);
157 					if ( bShareFooter )
158 						AddTabPage( 2, ScRightFooterEditPage::Create, NULL );
159 					else
160 						AddTabPage( 2, ScLeftFooterEditPage::Create, NULL );
161 				}
162 			}
163 			break;
164 	}
165 
166 	FreeResource();
167 }
168 
169 // -----------------------------------------------------------------------
170 
171 __EXPORT ScHFEditDlg::~ScHFEditDlg()
172 {
173 }
174 
175 // -----------------------------------------------------------------------
176 
177 void __EXPORT ScHFEditDlg::PageCreated( sal_uInt16 /* nId */, SfxTabPage& rPage )
178 {
179 	// kann ja nur ne ScHFEditPage sein...
180 
181 	((ScHFEditPage&)rPage).SetNumType(eNumType);
182 }
183 
184 
185 
186 
187