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