xref: /aoo42x/main/sc/source/ui/styleui/styledlg.cxx (revision a479921a)
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 //CHINA001 #include <svx/align.hxx>
34 //CHINA001 #include <svx/backgrnd.hxx>
35 //CHINA001 #include <svx/border.hxx>
36 //CHINA001 #include <svx/chardlg.hxx>
37 //CHINA001 #include <svx/numfmt.hxx>
38 #include <svx/numinf.hxx> //CHINA001
39 //CHINA001 #include <svx/page.hxx>
40 //CHINA001 #include <svx/paragrph.hxx>
41 #include <sfx2/objsh.hxx>
42 #include <svl/style.hxx>
43 #include <svl/cjkoptions.hxx>
44 
45 #include "styledlg.hxx"
46 #include "tabpages.hxx"		// Zellvorlagen
47 #include "tphf.hxx"			// Seitenvorlage: Kopf-/Fusszeilen
48 #include "tptable.hxx"		// Seitenvorlage: Tabelle
49 #include "scresid.hxx"
50 #include "sc.hrc"
51 #include "styledlg.hrc"
52 #include <svx/svxdlg.hxx> //CHINA001
53 #include <svx/svxids.hrc> //CHINA001
54 #include <svx/dialogs.hrc> //CHINA001
55 #include <svl/intitem.hxx> //CHINA001
56 #include <editeng/flstitem.hxx> //CHINA001
57 #include <svl/aeitem.hxx> //CHINA001
58 #include <svx/flagsdef.hxx> //CHINA001
59 //==================================================================
60 
ScStyleDlg(Window * pParent,SfxStyleSheetBase & rStyleBase,sal_uInt16 nRscId)61 ScStyleDlg::ScStyleDlg( Window*				pParent,
62 						SfxStyleSheetBase&	rStyleBase,
63 						sal_uInt16				nRscId )
64 
65 	:	SfxStyleDialog	( pParent,
66 						  ScResId( nRscId ),
67 						  rStyleBase,
68 						  sal_False ),
69 		nDlgRsc			( nRscId )
70 {
71 	SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); //CHINA001
72 	DBG_ASSERT(pFact, "Dialogdiet fail!");//CHINA001
73 	switch ( nRscId )
74 	{
75 		case RID_SCDLG_STYLES_PAR:	// Zellformatvorlagen
76 			{
77 				SvtCJKOptions aCJKOptions;
78 				DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_NUMBERFORMAT ), "GetTabPageCreatorFunc fail!");//CHINA001
79 				DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_NUMBERFORMAT ), "GetTabPageRangesFunc fail!");//CHINA001
80 				AddTabPage( TP_NUMBER, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_NUMBERFORMAT ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_NUMBERFORMAT ) );  //CHINA001 AddTabPage( TP_NUMBER, &SvxNumberFormatTabPage::Create, &SvxNumberFormatTabPage::GetRanges );
81 				DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_NAME ), "GetTabPageCreatorFunc fail!");//CHINA001
82 				DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_NAME ), "GetTabPageRangesFunc fail!");//CHINA001
83 				AddTabPage( TP_FONT, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_NAME ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_NAME ) ); //CHINA001 AddTabPage( TP_FONT, &SvxCharNamePage::Create,		    &SvxCharNamePage::GetRanges );
84 				DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_EFFECTS ), "GetTabPageCreatorFunc fail!");//CHINA001
85 				DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_EFFECTS ), "GetTabPageRangesFunc fail!");//CHINA001
86 				AddTabPage( TP_FONTEFF, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_EFFECTS ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_EFFECTS ) ); //CHINA001 AddTabPage( TP_FONTEFF, &SvxCharEffectsPage::Create,		    &SvxCharEffectsPage::GetRanges );
87 				DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_ALIGNMENT ), "GetTabPageCreatorFunc fail!");//CHINA001
88 				DBG_ASSERT( pFact->GetTabPageRangesFunc( RID_SVXPAGE_ALIGNMENT ), "GetTabPageRangesFunc fail!");//CHINA001
89 				AddTabPage( TP_ALIGNMENT, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_ALIGNMENT ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_ALIGNMENT ) ); //CHINA001 AddTabPage( TP_ALIGNMENT, &SvxAlignmentTabPage::Create,	&SvxAlignmentTabPage::GetRanges );
90 				if ( aCJKOptions.IsAsianTypographyEnabled() )
91 				{
92 				//CHINA001 	AddTabPage( TP_ASIAN, &SvxAsianTabPage::Create,		&SvxAsianTabPage::GetRanges );
93 
94 					DBG_ASSERT(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN), "GetTabPageCreatorFunc fail!");//CHINA001
95 					DBG_ASSERT(pFact->GetTabPageRangesFunc(RID_SVXPAGE_PARA_ASIAN), "GetTabPageRangesFunc fail!");//CHINA001
96 					AddTabPage( TP_ASIAN,	pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN),		pFact->GetTabPageRangesFunc(RID_SVXPAGE_PARA_ASIAN) );
97 				}
98 				else
99 					RemoveTabPage( TP_ASIAN );
100 				DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), "GetTabPageCreatorFunc fail!");//CHINA001
101 				DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ), "GetTabPageRangesFunc fail!");//CHINA001
102 				AddTabPage( TP_BORDER, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ) ); //CHINA001 AddTabPage( TP_BORDER, &SvxBorderTabPage::Create,		&SvxBorderTabPage::GetRanges );
103 				DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageCreatorFunc fail!");//CHINA001
104 				DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageRangesFunc fail!");//CHINA001
105 				AddTabPage( TP_BACKGROUND, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ) ); //CHINA001 AddTabPage( TP_BACKGROUND, &SvxBackgroundTabPage::Create,	&SvxBackgroundTabPage::GetRanges );
106 				AddTabPage( TP_PROTECTION, &ScTabPageProtection::Create,	&ScTabPageProtection::GetRanges );
107 			}
108 			break;
109 
110 		case RID_SCDLG_STYLES_PAGE:	// Seitenvorlagen
111 			{
112 				DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_PAGE ), "GetTabPageCreatorFunc fail!");//CHINA001
113 				DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_PAGE ), "GetTabPageRangesFunc fail!");//CHINA001
114 				AddTabPage( TP_PAGE_STD, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_PAGE ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_PAGE ) ); //CHINA001 AddTabPage( TP_PAGE_STD, &SvxPageDescPage::Create,	&SvxPageDescPage::GetRanges );
115 				DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), "GetTabPageCreatorFunc fail!");//CHINA001
116 				DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ), "GetTabPageRangesFunc fail!");//CHINA001
117 				AddTabPage( TP_BORDER, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ) ); //CHINA001 AddTabPage( TP_BORDER, &SvxBorderTabPage::Create,	&SvxBorderTabPage::GetRanges );
118 				DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageCreatorFunc fail!");//CHINA001
119 				DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageRangesFunc fail!");//CHINA001
120 				AddTabPage( TP_BACKGROUND, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ) ); //CHINA001 AddTabPage( TP_BACKGROUND, &SvxBackgroundTabPage::Create,	&SvxBackgroundTabPage::GetRanges );
121 				AddTabPage( TP_PAGE_HEADER, &ScHeaderPage::Create,	  	&ScHeaderPage::GetRanges );
122 				AddTabPage( TP_PAGE_FOOTER, &ScFooterPage::Create,	 	&ScFooterPage::GetRanges );
123 				AddTabPage( TP_TABLE, &ScTablePage::Create,		&ScTablePage::GetRanges );
124 			}
125 			break;
126 
127 		default:
128 			DBG_ERROR( "Family not supported" );
129 	}
130 
131 	//--------------------------------------------------------------------
132 	FreeResource();
133 }
134 
135 // -----------------------------------------------------------------------
136 
~ScStyleDlg()137 __EXPORT ScStyleDlg::~ScStyleDlg()
138 {
139 }
140 
141 // -----------------------------------------------------------------------
142 
PageCreated(sal_uInt16 nPageId,SfxTabPage & rTabPage)143 void __EXPORT ScStyleDlg::PageCreated( sal_uInt16 nPageId, SfxTabPage& rTabPage )
144 {
145 	if ( nDlgRsc == RID_SCDLG_STYLES_PAR )
146 	{
147 		SfxObjectShell* pDocSh = SfxObjectShell::Current();
148 		SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool())); //CHINA001
149 		switch ( nPageId )
150 		{
151 			case TP_NUMBER:
152 				{
153 					const SfxPoolItem* pInfoItem
154 						= pDocSh->GetItem( SID_ATTR_NUMBERFORMAT_INFO );
155 
156 					DBG_ASSERT( pInfoItem, "NumberInfoItem nicht gefunden!" );
157 
158 					//CHINA001 ((SvxNumberFormatTabPage&)rTabPage).
159 						//CHINA001 SetNumberFormatList(
160 							//CHINA001 (const SvxNumberInfoItem&)*pInfoItem ) ;
161 					aSet.Put (SvxNumberInfoItem( (const SvxNumberInfoItem&)*pInfoItem ) );
162 					rTabPage.PageCreated(aSet);
163 				}
164 				break;
165 
166 			case TP_FONT:
167 				{
168 					const SfxPoolItem* pInfoItem
169 						= pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST );
170 
171 					DBG_ASSERT( pInfoItem, "FontListItem nicht gefunden!" );
172 
173 					//CHINA001 ((SvxCharNamePage&)rTabPage).
174 						//CHINA001 SetFontList(
175 							//CHINA001 (const SvxFontListItem&)*pInfoItem );
176 					aSet.Put (SvxFontListItem(((const SvxFontListItem&)*pInfoItem).GetFontList(), SID_ATTR_CHAR_FONTLIST));
177 					rTabPage.PageCreated(aSet);
178 				}
179 				break;
180 
181 			default:
182 			break;
183 		}
184 	}
185 	else if ( nDlgRsc == RID_SCDLG_STYLES_PAGE )
186 	{
187 		SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));//CHINA001
188 		switch ( nPageId )
189 		{
190 			case TP_PAGE_STD:
191 				//CHINA001 ((SvxPageDescPage&)rTabPage).SetMode( SVX_PAGE_MODE_CENTER );
192 				aSet.Put (SfxAllEnumItem((const sal_uInt16)SID_ENUM_PAGE_MODE, SVX_PAGE_MODE_CENTER)); //CHINA001
193 				rTabPage.PageCreated(aSet); //CHINA001
194 				break;
195 
196 			case TP_PAGE_HEADER:
197 			case TP_PAGE_FOOTER:
198 				((ScHFPage&)rTabPage).SetStyleDlg( this );
199 				((ScHFPage&)rTabPage).SetPageStyle( GetStyleSheet().GetName() );
200 				((ScHFPage&)rTabPage).DisableDeleteQueryBox();
201 				break;
202 			case TP_BACKGROUND:
203 					if( nDlgRsc == RID_SCDLG_STYLES_PAGE)
204 						//CHINA001 ((SvxBackgroundTabPage&)rTabPage).ShowSelector();
205 					{	//add CHINA001
206 						aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, SVX_SHOW_SELECTOR));
207 						rTabPage.PageCreated(aSet);
208 					}
209 				break;
210 
211 			default:
212 				break;
213 		}
214 	}
215 }
216 
217 
218 // -----------------------------------------------------------------------
219 
GetRefreshedSet()220 const SfxItemSet* __EXPORT ScStyleDlg::GetRefreshedSet()
221 {
222     SfxItemSet* pItemSet = GetInputSetImpl();
223     pItemSet->ClearItem();
224     pItemSet->SetParent( GetStyleSheet().GetItemSet().GetParent() );
225     return pItemSet;
226 }
227 
228 
229 
230