xref: /aoo42x/main/sc/source/core/data/stlpool.cxx (revision b3f79822)
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_sc.hxx"
26 
27 
28 //------------------------------------------------------------------------
29 
30 #include "scitems.hxx"
31 #include <editeng/eeitem.hxx>
32 #include <svx/algitem.hxx>
33 #include <editeng/boxitem.hxx>
34 #include <editeng/brshitem.hxx>
35 #include <editeng/editdata.hxx>
36 #include <editeng/editeng.hxx>
37 #include <editeng/editobj.hxx>
38 #include <editeng/fhgtitem.hxx>
39 #include <editeng/flditem.hxx>
40 #include <editeng/fontitem.hxx>
41 #include <svx/pageitem.hxx>
42 #include <editeng/postitem.hxx>
43 #include <editeng/udlnitem.hxx>
44 #include <editeng/wghtitem.hxx>
45 #include <svl/itemset.hxx>
46 #include <svl/zforlist.hxx>
47 #include <unotools/charclass.hxx>
48 #include <unotools/fontcvt.hxx>
49 #include <vcl/outdev.hxx>
50 #include <vcl/svapp.hxx>
51 
52 #include "sc.hrc"
53 #include "attrib.hxx"
54 #include "global.hxx"
55 #include "globstr.hrc"
56 #include "document.hxx"
57 #include "docpool.hxx"
58 #include "stlpool.hxx"
59 #include "stlsheet.hxx"
60 #include "rechead.hxx"
61 #include "editutil.hxx"
62 #include "patattr.hxx"
63 
64 
65 //========================================================================
66 
ScStyleSheetPool(SfxItemPool & rPoolP,ScDocument * pDocument)67 ScStyleSheetPool::ScStyleSheetPool( SfxItemPool&    rPoolP,
68 									ScDocument*		pDocument )
69     :   SfxStyleSheetPool( rPoolP ),
70 		pActualStyleSheet( NULL ),
71 		pDoc( pDocument ),
72 		pForceStdName( NULL )
73 {
74 }
75 
76 //------------------------------------------------------------------------
77 
~ScStyleSheetPool()78 __EXPORT ScStyleSheetPool::~ScStyleSheetPool()
79 {
80 }
81 
82 //------------------------------------------------------------------------
83 
SetDocument(ScDocument * pDocument)84 void ScStyleSheetPool::SetDocument( ScDocument* pDocument )
85 {
86 	pDoc = pDocument;
87 }
88 
89 //------------------------------------------------------------------------
90 
91 //UNUSED2009-05 void ScStyleSheetPool::SetForceStdName( const String* pSet )
92 //UNUSED2009-05 {
93 //UNUSED2009-05     pForceStdName = pSet;
94 //UNUSED2009-05 }
95 
96 //------------------------------------------------------------------------
97 
Make(const String & rName,SfxStyleFamily eFam,sal_uInt16 mask,sal_uInt16 nPos)98 SfxStyleSheetBase& ScStyleSheetPool::Make( const String& rName,
99 							SfxStyleFamily eFam, sal_uInt16 mask, sal_uInt16 nPos )
100 {
101 	//	When updating styles from a template, Office 5.1 sometimes created
102 	//	files with multiple default styles.
103 	//	Create new styles in that case:
104 
105 	//!	only when loading?
106 
107 	if ( rName.EqualsAscii(STRING_STANDARD) && Find( rName, eFam ) != NULL )
108 	{
109 		DBG_ERROR("renaming additional default style");
110 		sal_uInt32 nCount = aStyles.size();
111 		for ( sal_uInt32 nAdd = 1; nAdd <= nCount; nAdd++ )
112 		{
113 			String aNewName = ScGlobal::GetRscString(STR_STYLENAME_STANDARD);
114 			aNewName += String::CreateFromInt32( nAdd );
115 			if ( Find( aNewName, eFam ) == NULL )
116 				return SfxStyleSheetPool::Make( aNewName, eFam, mask, nPos );
117 		}
118 	}
119 
120 	return SfxStyleSheetPool::Make( rName, eFam, mask, nPos );
121 }
122 
123 //------------------------------------------------------------------------
124 
Create(const String & rName,SfxStyleFamily eFamily,sal_uInt16 nMaskP)125 SfxStyleSheetBase* __EXPORT ScStyleSheetPool::Create(
126 											const String&	rName,
127 											SfxStyleFamily	eFamily,
128                                             sal_uInt16          nMaskP )
129 {
130     ScStyleSheet* pSheet = new ScStyleSheet( rName, *this, eFamily, nMaskP );
131 	if ( eFamily == SFX_STYLE_FAMILY_PARA && ScGlobal::GetRscString(STR_STYLENAME_STANDARD) != rName )
132 		pSheet->SetParent( ScGlobal::GetRscString(STR_STYLENAME_STANDARD) );
133 
134 	return pSheet;
135 }
136 
137 //------------------------------------------------------------------------
138 
Create(const SfxStyleSheetBase & rStyle)139 SfxStyleSheetBase* __EXPORT ScStyleSheetPool::Create( const SfxStyleSheetBase& rStyle )
140 {
141 	DBG_ASSERT( rStyle.ISA(ScStyleSheet), "Invalid StyleSheet-class! :-/" );
142 	return new ScStyleSheet( (const ScStyleSheet&) rStyle );
143 }
144 
145 //------------------------------------------------------------------------
146 
Remove(SfxStyleSheetBase * pStyle)147 void __EXPORT ScStyleSheetPool::Remove( SfxStyleSheetBase* pStyle )
148 {
149 	if ( pStyle )
150 	{
151 		DBG_ASSERT( IS_SET( SFXSTYLEBIT_USERDEF, pStyle->GetMask() ),
152 					"SFXSTYLEBIT_USERDEF not set!" );
153 
154 		((ScDocumentPool&)rPool).StyleDeleted((ScStyleSheet*)pStyle);
155 		SfxStyleSheetPool::Remove(pStyle);
156 	}
157 }
158 
159 //------------------------------------------------------------------------
160 
CopyStyleFrom(ScStyleSheetPool * pSrcPool,const String & rName,SfxStyleFamily eFamily)161 void ScStyleSheetPool::CopyStyleFrom( ScStyleSheetPool* pSrcPool,
162 										const String& rName, SfxStyleFamily eFamily )
163 {
164 	//	this ist Dest-Pool
165 
166 	SfxStyleSheetBase* pStyleSheet = pSrcPool->Find( rName, eFamily );
167 	if (pStyleSheet)
168 	{
169 		const SfxItemSet& rSourceSet = pStyleSheet->GetItemSet();
170 		SfxStyleSheetBase* pDestSheet = Find( rName, eFamily );
171 		if (!pDestSheet)
172 			pDestSheet = &Make( rName, eFamily );
173 		SfxItemSet& rDestSet = pDestSheet->GetItemSet();
174 		rDestSet.PutExtended( rSourceSet, SFX_ITEM_DONTCARE, SFX_ITEM_DEFAULT );
175 
176         const SfxPoolItem* pItem;
177 		if ( eFamily == SFX_STYLE_FAMILY_PAGE )
178 		{
179 			//	Set-Items
180 
181 			if ( rSourceSet.GetItemState( ATTR_PAGE_HEADERSET, sal_False, &pItem ) == SFX_ITEM_SET )
182 			{
183 				const SfxItemSet& rSrcSub = ((const SvxSetItem*) pItem)->GetItemSet();
184 				SfxItemSet aDestSub( *rDestSet.GetPool(), rSrcSub.GetRanges() );
185 				aDestSub.PutExtended( rSrcSub, SFX_ITEM_DONTCARE, SFX_ITEM_DEFAULT );
186 				rDestSet.Put( SvxSetItem( ATTR_PAGE_HEADERSET, aDestSub ) );
187 			}
188 			if ( rSourceSet.GetItemState( ATTR_PAGE_FOOTERSET, sal_False, &pItem ) == SFX_ITEM_SET )
189 			{
190 				const SfxItemSet& rSrcSub = ((const SvxSetItem*) pItem)->GetItemSet();
191 				SfxItemSet aDestSub( *rDestSet.GetPool(), rSrcSub.GetRanges() );
192 				aDestSub.PutExtended( rSrcSub, SFX_ITEM_DONTCARE, SFX_ITEM_DEFAULT );
193 				rDestSet.Put( SvxSetItem( ATTR_PAGE_FOOTERSET, aDestSub ) );
194 			}
195 		}
196         else    // cell styles
197         {
198             // #b5017505# number format exchange list has to be handled here, too
199 
200             if ( pDoc && pDoc->GetFormatExchangeList() &&
201                  rSourceSet.GetItemState( ATTR_VALUE_FORMAT, sal_False, &pItem ) == SFX_ITEM_SET )
202             {
203                 sal_uLong nOldFormat = static_cast<const SfxUInt32Item*>(pItem)->GetValue();
204                 sal_uInt32* pNewFormat = static_cast<sal_uInt32*>(pDoc->GetFormatExchangeList()->Get( nOldFormat ));
205                 if (pNewFormat)
206                     rDestSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, *pNewFormat ) );
207             }
208         }
209 	}
210 }
211 
212 //------------------------------------------------------------------------
213 //
214 //						Standard-Vorlagen
215 //
216 //------------------------------------------------------------------------
217 
218 #define SCSTR(id)	ScGlobal::GetRscString(id)
219 
CopyStdStylesFrom(ScStyleSheetPool * pSrcPool)220 void ScStyleSheetPool::CopyStdStylesFrom( ScStyleSheetPool* pSrcPool )
221 {
222 	//	Default-Styles kopieren
223 
224 	CopyStyleFrom( pSrcPool, SCSTR(STR_STYLENAME_STANDARD),		SFX_STYLE_FAMILY_PARA );
225 	CopyStyleFrom( pSrcPool, SCSTR(STR_STYLENAME_RESULT),		SFX_STYLE_FAMILY_PARA );
226 	CopyStyleFrom( pSrcPool, SCSTR(STR_STYLENAME_RESULT1),		SFX_STYLE_FAMILY_PARA );
227 	CopyStyleFrom( pSrcPool, SCSTR(STR_STYLENAME_HEADLINE),		SFX_STYLE_FAMILY_PARA );
228 	CopyStyleFrom( pSrcPool, SCSTR(STR_STYLENAME_HEADLINE1),	SFX_STYLE_FAMILY_PARA );
229 	CopyStyleFrom( pSrcPool, SCSTR(STR_STYLENAME_STANDARD),		SFX_STYLE_FAMILY_PAGE );
230 	CopyStyleFrom( pSrcPool, SCSTR(STR_STYLENAME_REPORT),		SFX_STYLE_FAMILY_PAGE );
231 }
232 
233 //------------------------------------------------------------------------
234 
lcl_CheckFont(SfxItemSet & rSet,LanguageType eLang,sal_uInt16 nFontType,sal_uInt16 nItemId)235 void lcl_CheckFont( SfxItemSet& rSet, LanguageType eLang, sal_uInt16 nFontType, sal_uInt16 nItemId )
236 {
237 	if ( eLang != LANGUAGE_NONE && eLang != LANGUAGE_DONTKNOW && eLang != LANGUAGE_SYSTEM )
238 	{
239 		Font aDefFont = OutputDevice::GetDefaultFont( nFontType, eLang, DEFAULTFONT_FLAGS_ONLYONE );
240 		SvxFontItem aNewItem( aDefFont.GetFamily(), aDefFont.GetName(), aDefFont.GetStyleName(),
241 							  aDefFont.GetPitch(), aDefFont.GetCharSet(), nItemId );
242 		if ( aNewItem != rSet.Get( nItemId ) )
243 		{
244 			// put item into style's ItemSet only if different from (static) default
245 			rSet.Put( aNewItem );
246 		}
247 	}
248 }
249 
CreateStandardStyles()250 void ScStyleSheetPool::CreateStandardStyles()
251 {
252 	//	neue Eintraege auch bei CopyStdStylesFrom eintragen
253 
254 	Color			aColBlack	( COL_BLACK );
255 	Color			aColGrey	( COL_LIGHTGRAY );
256 	String			aStr;
257 	xub_StrLen		nStrLen;
258 	String			aHelpFile;//XXX JN welcher Text???
259 	//sal_uLong			nNumFmt			= 0L;
260 	SfxItemSet*		pSet			= NULL;
261 	SfxItemSet*		pHFSet			= NULL;
262 	SvxSetItem*		pHFSetItem		= NULL;
263 	ScEditEngineDefaulter*	pEdEngine	= new ScEditEngineDefaulter( EditEngine::CreatePool(), sal_True );
264 	pEdEngine->SetUpdateMode( sal_False );
265 	EditTextObject* pEmptyTxtObj	= pEdEngine->CreateTextObject();
266 	EditTextObject* pTxtObj			= NULL;
267 	ScPageHFItem*	pHeaderItem		= new ScPageHFItem( ATTR_PAGE_HEADERRIGHT );
268 	ScPageHFItem*	pFooterItem		= new ScPageHFItem( ATTR_PAGE_FOOTERRIGHT );
269 	ScStyleSheet*	pSheet			= NULL;
270 	SvxBorderLine	aBorderLine		( &aColBlack, DEF_LINE_WIDTH_2 );
271 	SvxBoxItem		aBoxItem		( ATTR_BORDER );
272 	SvxBoxInfoItem	aBoxInfoItem	( ATTR_BORDER_INNER );
273 
274 	String aStrStandard = ScGlobal::GetRscString(STR_STYLENAME_STANDARD);
275 
276 	//==========================================================
277 	// Zellformatvorlagen:
278 	//==========================================================
279 
280 	//------------
281 	// 1. Standard
282 	//------------
283 	pSheet = (ScStyleSheet*) &Make( aStrStandard, SFX_STYLE_FAMILY_PARA, SCSTYLEBIT_STANDARD );
284 	pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_CELL_STD );
285 
286 	//	if default fonts for the document's languages are different from the pool default,
287 	//	put them into the default style
288 	//	(not as pool defaults, because pool defaults can't be changed by the user)
289 	//	the document languages must be set before creating the default styles!
290 
291 	pSet = &pSheet->GetItemSet();
292 	LanguageType eLatin, eCjk, eCtl;
293 	pDoc->GetLanguage( eLatin, eCjk, eCtl );
294 
295 	//	#108374# / #107782#: If the UI language is Korean, the default Latin font has to
296 	//	be queried for Korean, too (the Latin language from the document can't be Korean).
297 	//	This is the same logic as in SwDocShell::InitNew.
298 	LanguageType eUiLanguage = Application::GetSettings().GetUILanguage();
299 	switch( eUiLanguage )
300 	{
301 		case LANGUAGE_KOREAN:
302 		case LANGUAGE_KOREAN_JOHAB:
303 			eLatin = eUiLanguage;
304 		break;
305 	}
306 
307 	lcl_CheckFont( *pSet, eLatin, DEFAULTFONT_LATIN_SPREADSHEET, ATTR_FONT );
308 	lcl_CheckFont( *pSet, eCjk, DEFAULTFONT_CJK_SPREADSHEET, ATTR_CJK_FONT );
309 	lcl_CheckFont( *pSet, eCtl, DEFAULTFONT_CTL_SPREADSHEET, ATTR_CTL_FONT );
310 
311     // #i55300# default CTL font size for Thai has to be larger
312     // #i59408# The 15 point size causes problems with row heights, so no different
313     // size is used for Thai in Calc for now.
314 //    if ( eCtl == LANGUAGE_THAI )
315 //        pSet->Put( SvxFontHeightItem( 300, 100, ATTR_CTL_FONT_HEIGHT ) );   // 15 pt
316 
317 	//------------
318 	// 2. Ergebnis
319 	//------------
320 
321 	pSheet = (ScStyleSheet*) &Make( SCSTR( STR_STYLENAME_RESULT ),
322 									SFX_STYLE_FAMILY_PARA,
323 									SCSTYLEBIT_STANDARD );
324 	pSheet->SetParent( aStrStandard );
325 	pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_CELL_ERG );
326 	pSet = &pSheet->GetItemSet();
327 	pSet->Put( SvxWeightItem( WEIGHT_BOLD, ATTR_FONT_WEIGHT ) );
328 	pSet->Put( SvxPostureItem( ITALIC_NORMAL, ATTR_FONT_POSTURE ) );
329 	pSet->Put( SvxUnderlineItem( UNDERLINE_SINGLE, ATTR_FONT_UNDERLINE ) );
330 
331 	//-------------
332 	// 3. Ergebnis1
333 	//-------------
334 
335 	pSheet = (ScStyleSheet*) &Make( SCSTR( STR_STYLENAME_RESULT1 ),
336 									SFX_STYLE_FAMILY_PARA,
337 									SCSTYLEBIT_STANDARD );
338 
339 	pSheet->SetParent( SCSTR( STR_STYLENAME_RESULT ) );
340 	pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_CELL_ERG1 );
341     // will now be done in GetItemSet();
342     // pSet = &pSheet->GetItemSet();
343     // nNumFmt = pDoc->GetFormatTable()->GetStandardFormat( NUMBERFORMAT_CURRENCY,
344 			//										    ScGlobal::eLnge );
345     // pSet->Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNumFmt ) );
346 
347 	//----------------
348 	// 4. Ueberschrift
349 	//----------------
350 
351 	pSheet = (ScStyleSheet*) &Make( SCSTR( STR_STYLENAME_HEADLINE ),
352 									SFX_STYLE_FAMILY_PARA,
353 									SCSTYLEBIT_STANDARD );
354 
355 	pSheet->SetParent( aStrStandard );
356 	pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_CELL_UEB );
357 	pSet = &pSheet->GetItemSet();
358 	pSet->Put( SvxFontHeightItem( 320, 100, ATTR_FONT_HEIGHT ) ); // 16pt
359 	pSet->Put( SvxWeightItem( WEIGHT_BOLD, ATTR_FONT_WEIGHT ) );
360 	pSet->Put( SvxPostureItem( ITALIC_NORMAL, ATTR_FONT_POSTURE ) );
361 	pSet->Put( SvxHorJustifyItem( SVX_HOR_JUSTIFY_CENTER, ATTR_HOR_JUSTIFY ) );
362 
363 	//-----------------
364 	// 5. Ueberschrift1
365 	//-----------------
366 
367 	pSheet = (ScStyleSheet*) &Make( SCSTR( STR_STYLENAME_HEADLINE1 ),
368 									SFX_STYLE_FAMILY_PARA,
369 									SCSTYLEBIT_STANDARD );
370 
371 	pSheet->SetParent( SCSTR( STR_STYLENAME_HEADLINE ) );
372 	pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_CELL_UEB1 );
373 	pSet = &pSheet->GetItemSet();
374     pSet->Put( SfxInt32Item( ATTR_ROTATE_VALUE, 9000 ) );
375 
376 	//==========================================================
377 	// Seitenformat-Vorlagen:
378 	//==========================================================
379 
380 	//------------
381 	// 1. Standard
382 	//------------
383 
384 	pSheet = (ScStyleSheet*) &Make( aStrStandard,
385 									SFX_STYLE_FAMILY_PAGE,
386 									SCSTYLEBIT_STANDARD );
387 
388 	pSet = &pSheet->GetItemSet();
389 	pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_PAGE_STD );
390 
391 	// Abstand der Kopf-/Fusszeilen von der Tabelle
392 	pHFSetItem = new SvxSetItem( ((SvxSetItem&)pSet->Get( ATTR_PAGE_HEADERSET ) ) );
393 	pSet->Put( *pHFSetItem, ATTR_PAGE_HEADERSET );
394 	pSet->Put( *pHFSetItem, ATTR_PAGE_FOOTERSET );
395 	DELETEZ( pHFSetItem );
396 
397 	//----------------------------------------
398 	// Kopfzeile:
399 	// [leer][\TABELLE\][leer]
400 	//----------------------------------------
401 	pEdEngine->SetText(EMPTY_STRING);
402     pEdEngine->QuickInsertField( SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD), ESelection() );
403 	pTxtObj = pEdEngine->CreateTextObject();
404 	pHeaderItem->SetLeftArea  ( *pEmptyTxtObj );
405 	pHeaderItem->SetCenterArea( *pTxtObj );
406 	pHeaderItem->SetRightArea ( *pEmptyTxtObj );
407 	pSet->Put( *pHeaderItem );
408 	DELETEZ( pTxtObj );
409 
410 	//----------------------------------------
411 	// Fusszeile:
412 	// [leer][Seite \SEITE\][leer]
413 	//----------------------------------------
414 	aStr = SCSTR( STR_PAGE ); aStr += ' ';
415 	pEdEngine->SetText( aStr );
416 	nStrLen = aStr.Len();
417     pEdEngine->QuickInsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), ESelection(0,nStrLen,0,nStrLen) );
418 	pTxtObj = pEdEngine->CreateTextObject();
419 	pFooterItem->SetLeftArea  ( *pEmptyTxtObj );
420 	pFooterItem->SetCenterArea( *pTxtObj );
421 	pFooterItem->SetRightArea ( *pEmptyTxtObj );
422 	pSet->Put( *pFooterItem );
423 	DELETEZ( pTxtObj );
424 
425 	//----------
426 	// 2. Report
427 	//----------
428 
429 	pSheet = (ScStyleSheet*) &Make( SCSTR( STR_STYLENAME_REPORT ),
430 									SFX_STYLE_FAMILY_PAGE,
431 									SCSTYLEBIT_STANDARD );
432 	pSet = &pSheet->GetItemSet();
433 	pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_PAGE_REP );
434 
435 	// Hintergrund und Umrandung
436 	aBoxItem.SetLine( &aBorderLine, BOX_LINE_TOP );
437 	aBoxItem.SetLine( &aBorderLine, BOX_LINE_BOTTOM );
438 	aBoxItem.SetLine( &aBorderLine, BOX_LINE_LEFT );
439 	aBoxItem.SetLine( &aBorderLine, BOX_LINE_RIGHT );
440 	aBoxItem.SetDistance( 10 ); // 0.2mm
441 	aBoxInfoItem.SetValid( VALID_TOP, sal_True );
442 	aBoxInfoItem.SetValid( VALID_BOTTOM, sal_True );
443 	aBoxInfoItem.SetValid( VALID_LEFT, sal_True );
444 	aBoxInfoItem.SetValid( VALID_RIGHT, sal_True );
445 	aBoxInfoItem.SetValid( VALID_DISTANCE, sal_True );
446 	aBoxInfoItem.SetTable( sal_False );
447 	aBoxInfoItem.SetDist ( sal_True );
448 
449 	pHFSetItem = new SvxSetItem( ((SvxSetItem&)pSet->Get( ATTR_PAGE_HEADERSET ) ) );
450 	pHFSet = &(pHFSetItem->GetItemSet());
451 
452 	pHFSet->Put( SvxBrushItem( aColGrey, ATTR_BACKGROUND ) );
453 	pHFSet->Put( aBoxItem );
454 	pHFSet->Put( aBoxInfoItem );
455 	pSet->Put( *pHFSetItem, ATTR_PAGE_HEADERSET );
456 	pSet->Put( *pHFSetItem, ATTR_PAGE_FOOTERSET );
457 	DELETEZ( pHFSetItem );
458 
459 	//----------------------------------------
460 	// Kopfzeile:
461 	// [\TABELLE\ (\DATEI\)][leer][\DATUM\, \ZEIT\]
462 	//----------------------------------------
463 	aStr = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(" ()"));
464 	pEdEngine->SetText( aStr );
465     pEdEngine->QuickInsertField( SvxFieldItem(SvxFileField(), EE_FEATURE_FIELD), ESelection(0,2,0,2) );
466     pEdEngine->QuickInsertField( SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD), ESelection() );
467 	pTxtObj = pEdEngine->CreateTextObject();
468 	pHeaderItem->SetLeftArea( *pTxtObj );
469 	pHeaderItem->SetCenterArea( *pEmptyTxtObj );
470 	DELETEZ( pTxtObj );
471 	aStr = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(", "));
472 	pEdEngine->SetText( aStr );
473     pEdEngine->QuickInsertField( SvxFieldItem(SvxTimeField(), EE_FEATURE_FIELD), ESelection(0,2,0,2) );
474     pEdEngine->QuickInsertField( SvxFieldItem(SvxDateField(Date(),SVXDATETYPE_VAR), EE_FEATURE_FIELD),
475 									ESelection() );
476 	pTxtObj = pEdEngine->CreateTextObject();
477 	pHeaderItem->SetRightArea( *pTxtObj );
478 	DELETEZ( pTxtObj );
479 	pSet->Put( *pHeaderItem );
480 
481 	//----------------------------------------
482 	// Fusszeile:
483 	// [leer][Seite: \SEITE\ / \SEITEN\][leer]
484 	//----------------------------------------
485 	aStr = SCSTR( STR_PAGE ); aStr += ' ';
486 	nStrLen = aStr.Len();
487 	aStr.AppendAscii(RTL_CONSTASCII_STRINGPARAM(" / "));
488 	xub_StrLen nStrLen2 = aStr.Len();
489 	pEdEngine->SetText( aStr );
490     pEdEngine->QuickInsertField( SvxFieldItem(SvxPagesField(), EE_FEATURE_FIELD), ESelection(0,nStrLen2,0,nStrLen2) );
491     pEdEngine->QuickInsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), ESelection(0,nStrLen,0,nStrLen) );
492 	pTxtObj = pEdEngine->CreateTextObject();
493 	pFooterItem->SetLeftArea  ( *pEmptyTxtObj );
494 	pFooterItem->SetCenterArea( *pTxtObj );
495 	pFooterItem->SetRightArea ( *pEmptyTxtObj );
496 	pSet->Put( *pFooterItem );
497 	DELETEZ( pTxtObj );
498 
499 	//----------------------------------------------------
500 	DELETEZ( pEmptyTxtObj );
501 	DELETEZ( pHeaderItem );
502 	DELETEZ( pFooterItem );
503 	DELETEZ( pEdEngine );
504 }
505 
506 //------------------------------------------------------------------------
507 
508 //UNUSED2008-05  void ScStyleSheetPool::UpdateStdNames()
509 //UNUSED2008-05  {
510 //UNUSED2008-05      //  Standard-Styles den richtigen Namen in der Programm-Sprache geben
511 //UNUSED2008-05
512 //UNUSED2008-05      String aHelpFile;
513 //UNUSED2008-05      sal_uInt32 nCount = aStyles.size();
514 //UNUSED2008-05      for (sal_uInt32 n=0; n<nCount; n++)
515 //UNUSED2008-05      {
516 //UNUSED2008-05          SfxStyleSheetBase* pStyle = aStyles[n].get();
517 //UNUSED2008-05          if (!pStyle->IsUserDefined())
518 //UNUSED2008-05          {
519 //UNUSED2008-05              String aOldName     = pStyle->GetName();
520 //UNUSED2008-05              sal_uLong nHelpId       = pStyle->GetHelpId( aHelpFile );
521 //UNUSED2008-05              SfxStyleFamily eFam = pStyle->GetFamily();
522 //UNUSED2008-05
523 //UNUSED2008-05              sal_Bool bHelpKnown = sal_True;
524 //UNUSED2008-05              String aNewName;
525 //UNUSED2008-05              sal_uInt16 nNameId = 0;
526 //UNUSED2008-05              switch( nHelpId )
527 //UNUSED2008-05              {
528 //UNUSED2008-05                  case HID_SC_SHEET_CELL_STD:
529 //UNUSED2008-05                  case HID_SC_SHEET_PAGE_STD:  nNameId = STR_STYLENAME_STANDARD;  break;
530 //UNUSED2008-05                  case HID_SC_SHEET_CELL_ERG:  nNameId = STR_STYLENAME_RESULT;    break;
531 //UNUSED2008-05                  case HID_SC_SHEET_CELL_ERG1: nNameId = STR_STYLENAME_RESULT1;   break;
532 //UNUSED2008-05                  case HID_SC_SHEET_CELL_UEB:  nNameId = STR_STYLENAME_HEADLINE;  break;
533 //UNUSED2008-05                  case HID_SC_SHEET_CELL_UEB1: nNameId = STR_STYLENAME_HEADLINE1; break;
534 //UNUSED2008-05                  case HID_SC_SHEET_PAGE_REP:  nNameId = STR_STYLENAME_REPORT;    break;
535 //UNUSED2008-05                  default:
536 //UNUSED2008-05                      // 0 oder falsche (alte) HelpId
537 //UNUSED2008-05                      bHelpKnown = sal_False;
538 //UNUSED2008-05              }
539 //UNUSED2008-05              if (bHelpKnown)
540 //UNUSED2008-05              {
541 //UNUSED2008-05                  if ( nNameId )
542 //UNUSED2008-05                      aNewName = SCSTR( nNameId );
543 //UNUSED2008-05
544 //UNUSED2008-05                  if ( aNewName.Len() && aNewName != aOldName && !Find( aNewName, eFam ) )
545 //UNUSED2008-05                  {
546 //UNUSED2008-05                      DBG_TRACE( "Renaming style..." );
547 //UNUSED2008-05
548 //UNUSED2008-05                      pStyle->SetName( aNewName );    // setzt auch Parents um
549 //UNUSED2008-05
550 //UNUSED2008-05                      //  Styles in Patterns sind schon auf Pointer umgesetzt
551 //UNUSED2008-05                      if (eFam == SFX_STYLE_FAMILY_PAGE)
552 //UNUSED2008-05                      {
553 //UNUSED2008-05                          //  Page-Styles umsetzen
554 //UNUSED2008-05                          //  TableCount am Doc ist noch nicht initialisiert
555 //UNUSED2008-05                          for (SCTAB nTab=0; nTab<=MAXTAB && pDoc->HasTable(nTab); nTab++)
556 //UNUSED2008-05                              if (pDoc->GetPageStyle(nTab) == aOldName)
557 //UNUSED2008-05                                  pDoc->SetPageStyle(nTab, aNewName);
558 //UNUSED2008-05                      }
559 //UNUSED2008-05                  }
560 //UNUSED2008-05              }
561 //UNUSED2008-05              else
562 //UNUSED2008-05              {
563 //UNUSED2008-05                  //  wrong or no HelpId -> set new HelpId
564 //UNUSED2008-05
565 //UNUSED2008-05                  //  no assertion for wrong HelpIds because this happens
566 //UNUSED2008-05                  //  with old files (#67218#) or with old files that were
567 //UNUSED2008-05                  //  saved again with a new version in a different language
568 //UNUSED2008-05                  //  (so SrcVersion doesn't help)
569 //UNUSED2008-05
570 //UNUSED2008-05                  sal_uInt16 nNewId = 0;
571 //UNUSED2008-05                  if ( eFam == SFX_STYLE_FAMILY_PARA )
572 //UNUSED2008-05                  {
573 //UNUSED2008-05                      if ( aOldName == SCSTR( STR_STYLENAME_STANDARD ) )
574 //UNUSED2008-05                          nNewId = HID_SC_SHEET_CELL_STD;
575 //UNUSED2008-05                      else if ( aOldName == SCSTR( STR_STYLENAME_RESULT ) )
576 //UNUSED2008-05                          nNewId = HID_SC_SHEET_CELL_ERG;
577 //UNUSED2008-05                      else if ( aOldName == SCSTR( STR_STYLENAME_RESULT1 ) )
578 //UNUSED2008-05                          nNewId = HID_SC_SHEET_CELL_ERG1;
579 //UNUSED2008-05                      else if ( aOldName == SCSTR( STR_STYLENAME_HEADLINE ) )
580 //UNUSED2008-05                          nNewId = HID_SC_SHEET_CELL_UEB;
581 //UNUSED2008-05                      else if ( aOldName == SCSTR( STR_STYLENAME_HEADLINE1 ) )
582 //UNUSED2008-05                          nNewId = HID_SC_SHEET_CELL_UEB1;
583 //UNUSED2008-05                  }
584 //UNUSED2008-05                  else        // PAGE
585 //UNUSED2008-05                  {
586 //UNUSED2008-05                      if ( aOldName == SCSTR( STR_STYLENAME_STANDARD ) )
587 //UNUSED2008-05                          nNewId = HID_SC_SHEET_PAGE_STD;
588 //UNUSED2008-05                      else if ( aOldName == SCSTR( STR_STYLENAME_REPORT ) )
589 //UNUSED2008-05                          nNewId = HID_SC_SHEET_PAGE_REP;
590 //UNUSED2008-05                  }
591 //UNUSED2008-05
592 //UNUSED2008-05                  if ( nNewId )               // new ID found from name -> set ID
593 //UNUSED2008-05                  {
594 //UNUSED2008-05                      pStyle->SetHelpId( aHelpFile, nNewId );
595 //UNUSED2008-05                  }
596 //UNUSED2008-05                  else if ( nHelpId == 0 )    // no old and no new ID
597 //UNUSED2008-05                  {
598 //UNUSED2008-05                      //  #71471# probably user defined style without SFXSTYLEBIT_USERDEF set
599 //UNUSED2008-05                      //  (from StarCalc 1.0 import), fixed in src563 and above
600 //UNUSED2008-05                      //! may also be default style from a different language
601 //UNUSED2008-05                      //! test if name was generated from StarCalc 1.0 import?
602 //UNUSED2008-05                      DBG_ASSERT(pDoc->GetSrcVersion() <= SC_SUBTOTAL_BUGFIX,
603 //UNUSED2008-05                                  "user defined style without SFXSTYLEBIT_USERDEF");
604 //UNUSED2008-05                      pStyle->SetMask( pStyle->GetMask() | SFXSTYLEBIT_USERDEF );
605 //UNUSED2008-05                  }
606 //UNUSED2008-05                  // else: wrong old ID and no new ID found:
607 //UNUSED2008-05                  //  probably default style from a different language
608 //UNUSED2008-05                  //  -> leave unchanged (HelpId will be set if loaded with matching
609 //UNUSED2008-05                  //  language version later)
610 //UNUSED2008-05              }
611 //UNUSED2008-05          }
612 //UNUSED2008-05      }
613 //UNUSED2008-05  }
614 
615 //------------------------------------------------------------------------
616 
FindCaseIns(const String & rName,SfxStyleFamily eFam)617 ScStyleSheet* ScStyleSheetPool::FindCaseIns( const String& rName, SfxStyleFamily eFam )
618 {
619 	String aUpSearch = rName;
620 	ScGlobal::pCharClass->toUpper(aUpSearch);
621 
622 	sal_uInt32 nCount = aStyles.size();
623 	for (sal_uInt32 n=0; n<nCount; n++)
624 	{
625 		SfxStyleSheetBase* pStyle = aStyles[n].get();
626 		if ( pStyle->GetFamily() == eFam )
627 		{
628 			String aUpName = pStyle->GetName();
629 			ScGlobal::pCharClass->toUpper(aUpName);
630 			if (aUpName == aUpSearch)
631 				return (ScStyleSheet*)pStyle;
632 		}
633 	}
634 
635 	return NULL;
636 }
637 
638