xref: /trunk/main/sc/source/ui/pagedlg/hfedtdlg.cxx (revision 67f7bfb15893aaa2f3b1ee7ec6b966aaaad422fc)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_scui.hxx"
26 
27 
28 
29 
30 //------------------------------------------------------------------
31 
32 #include "scitems.hxx"
33 #include <svl/eitem.hxx>
34 
35 #include "hfedtdlg.hxx"
36 #include "global.hxx"
37 #include "globstr.hrc"
38 //CHINA001 #include "tphfedit.hxx"
39 #include "scresid.hxx"
40 #include "hfedtdlg.hrc"
41 #include "scuitphfedit.hxx" //CHINA001
42 //------------------------------------------------------------------
43 
44 //  macros from docsh4.cxx
45 //! use SIDs?
46 
47 #define IS_SHARE_HEADER(set) \
48     ((SfxBoolItem&) \
49         ((SvxSetItem&)(set).Get(ATTR_PAGE_HEADERSET)).GetItemSet(). \
50             Get(ATTR_PAGE_SHARED)).GetValue()
51 
52 #define IS_SHARE_FOOTER(set) \
53     ((SfxBoolItem&) \
54         ((SvxSetItem&)(set).Get(ATTR_PAGE_FOOTERSET)).GetItemSet(). \
55             Get(ATTR_PAGE_SHARED)).GetValue()
56 
57 //==================================================================
58 
59 ScHFEditDlg::ScHFEditDlg( SfxViewFrame*     pFrameP,
60                           Window*           pParent,
61                           const SfxItemSet& rCoreSet,
62                           const String&     rPageStyle,
63                           sal_uInt16            nResIdP )
64     :   SfxTabDialog( pFrameP, pParent, ScResId( nResIdP ), &rCoreSet )
65 {
66     eNumType = ((const SvxPageItem&)rCoreSet.Get(ATTR_PAGE)).GetNumType();
67 
68     String aTmp = GetText();
69 
70     aTmp.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
71     aTmp += ScGlobal::GetRscString( STR_PAGESTYLE );
72     aTmp.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ": " ));
73     aTmp += rPageStyle;
74     aTmp += ')';
75     SetText( aTmp );
76 
77     switch ( nResIdP )
78     {
79         case RID_SCDLG_HFED_HEADER:
80         case RID_SCDLG_HFEDIT_HEADER:
81             AddTabPage( 1, ScRightHeaderEditPage::Create, NULL );
82             AddTabPage( 2, ScLeftHeaderEditPage::Create, NULL );
83             break;
84 
85         case RID_SCDLG_HFED_FOOTER:
86         case RID_SCDLG_HFEDIT_FOOTER:
87             AddTabPage( 1, ScRightFooterEditPage::Create, NULL );
88             AddTabPage( 2, ScLeftFooterEditPage::Create, NULL );
89             break;
90 
91         case RID_SCDLG_HFEDIT_LEFTHEADER:
92             AddTabPage( 1, ScLeftHeaderEditPage::Create, NULL );
93             break;
94 
95         case RID_SCDLG_HFEDIT_RIGHTHEADER:
96             AddTabPage( 1, ScRightHeaderEditPage::Create, NULL );
97             break;
98 
99         case RID_SCDLG_HFEDIT_LEFTFOOTER:
100             AddTabPage( 1, ScLeftFooterEditPage::Create, NULL );
101             break;
102 
103         case RID_SCDLG_HFEDIT_RIGHTFOOTER:
104             AddTabPage( 1, ScRightFooterEditPage::Create, NULL );
105             break;
106 
107         case RID_SCDLG_HFEDIT_SHDR:
108             AddTabPage( 1, ScRightHeaderEditPage::Create, NULL );
109             AddTabPage( 2, ScRightFooterEditPage::Create, NULL );
110             AddTabPage( 3, ScLeftFooterEditPage::Create,  NULL );
111             break;
112 
113         case RID_SCDLG_HFEDIT_SFTR:
114             AddTabPage( 1, ScRightHeaderEditPage::Create, NULL );
115             AddTabPage( 2, ScLeftHeaderEditPage::Create, NULL );
116             AddTabPage( 3, ScRightFooterEditPage::Create, NULL );
117             break;
118 
119         case RID_SCDLG_HFEDIT_ALL:
120             AddTabPage( 1, ScRightHeaderEditPage::Create, NULL );
121             AddTabPage( 2, ScLeftHeaderEditPage::Create, NULL );
122             AddTabPage( 3, ScRightFooterEditPage::Create, NULL );
123             AddTabPage( 4, ScLeftFooterEditPage::Create, NULL );
124             break;
125 
126         default:
127         case RID_SCDLG_HFEDIT:
128             {
129                 const SvxPageItem&  rPageItem = (const SvxPageItem&)
130                             rCoreSet.Get(
131                                 rCoreSet.GetPool()->GetWhich(SID_ATTR_PAGE) );
132 
133                 sal_Bool bRightPage = ( SVX_PAGE_LEFT !=
134                                     SvxPageUsage(rPageItem.GetPageUsage()) );
135 
136                 if ( bRightPage )
137                 {
138                     AddTabPage( 1, ScRightHeaderEditPage::Create, NULL );
139                     AddTabPage( 2, ScRightFooterEditPage::Create, NULL );
140                 }
141                 else
142                 {
143                     //  #69193a# respect "shared" setting
144 
145                     sal_Bool bShareHeader = IS_SHARE_HEADER(rCoreSet);
146                     if ( bShareHeader )
147                         AddTabPage( 1, ScRightHeaderEditPage::Create, NULL );
148                     else
149                         AddTabPage( 1, ScLeftHeaderEditPage::Create, NULL );
150 
151                     sal_Bool bShareFooter = IS_SHARE_FOOTER(rCoreSet);
152                     if ( bShareFooter )
153                         AddTabPage( 2, ScRightFooterEditPage::Create, NULL );
154                     else
155                         AddTabPage( 2, ScLeftFooterEditPage::Create, NULL );
156                 }
157             }
158             break;
159     }
160 
161     FreeResource();
162 }
163 
164 // -----------------------------------------------------------------------
165 
166 __EXPORT ScHFEditDlg::~ScHFEditDlg()
167 {
168 }
169 
170 // -----------------------------------------------------------------------
171 
172 void __EXPORT ScHFEditDlg::PageCreated( sal_uInt16 /* nId */, SfxTabPage& rPage )
173 {
174     // kann ja nur ne ScHFEditPage sein...
175 
176     ((ScHFEditPage&)rPage).SetNumType(eNumType);
177 }
178