LCOV - code coverage report
Current view: top level - sc/source/core/data - stlpool.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 173 239 72.4 %
Date: 2015-06-13 12:38:46 Functions: 12 19 63.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "scitems.hxx"
      21             : #include <editeng/eeitem.hxx>
      22             : #include <i18nlangtag/mslangid.hxx>
      23             : #include <svx/algitem.hxx>
      24             : #include <editeng/boxitem.hxx>
      25             : #include <editeng/brushitem.hxx>
      26             : #include <editeng/editdata.hxx>
      27             : #include <editeng/editeng.hxx>
      28             : #include <editeng/editobj.hxx>
      29             : #include <editeng/fhgtitem.hxx>
      30             : #include <editeng/flditem.hxx>
      31             : #include <editeng/fontitem.hxx>
      32             : #include <svx/pageitem.hxx>
      33             : #include <editeng/postitem.hxx>
      34             : #include <editeng/udlnitem.hxx>
      35             : #include <editeng/wghtitem.hxx>
      36             : #include <editeng/justifyitem.hxx>
      37             : #include <svl/itemset.hxx>
      38             : #include <svl/zforlist.hxx>
      39             : #include <svl/IndexedStyleSheets.hxx>
      40             : #include <unotools/charclass.hxx>
      41             : #include <unotools/fontcvt.hxx>
      42             : #include <vcl/outdev.hxx>
      43             : #include <vcl/svapp.hxx>
      44             : #include <vcl/settings.hxx>
      45             : 
      46             : #include "sc.hrc"
      47             : #include "attrib.hxx"
      48             : #include "global.hxx"
      49             : #include "globstr.hrc"
      50             : #include "document.hxx"
      51             : #include "docpool.hxx"
      52             : #include "stlpool.hxx"
      53             : #include "stlsheet.hxx"
      54             : #include "rechead.hxx"
      55             : #include "editutil.hxx"
      56             : #include "patattr.hxx"
      57             : 
      58        1325 : ScStyleSheetPool::ScStyleSheetPool( SfxItemPool&    rPoolP,
      59             :                                     ScDocument*     pDocument )
      60             :     :   SfxStyleSheetPool( rPoolP ),
      61             :         pActualStyleSheet( NULL ),
      62             :         pDoc( pDocument ),
      63        1325 :         pForceStdName( NULL )
      64             : {
      65        1325 : }
      66             : 
      67        2584 : ScStyleSheetPool::~ScStyleSheetPool()
      68             : {
      69        2584 : }
      70             : 
      71        2217 : void ScStyleSheetPool::SetDocument( ScDocument* pDocument )
      72             : {
      73        2217 :     pDoc = pDocument;
      74        2217 : }
      75             : 
      76        5644 : SfxStyleSheetBase& ScStyleSheetPool::Make( const OUString& rName,
      77             :                                            SfxStyleFamily eFam, sal_uInt16 mask)
      78             : {
      79             :     //  When updating styles from a template, Office 5.1 sometimes created
      80             :     //  files with multiple default styles.
      81             :     //  Create new styles in that case:
      82             : 
      83             :     //TODO: only when loading?
      84             : 
      85        5644 :     if ( rName == STRING_STANDARD && Find( rName, eFam ) != NULL )
      86             :     {
      87             :         OSL_FAIL("renaming additional default style");
      88           0 :         sal_uInt32 nCount = GetIndexedStyleSheets().GetNumberOfStyleSheets();
      89           0 :         for ( sal_uInt32 nAdd = 1; nAdd <= nCount; nAdd++ )
      90             :         {
      91           0 :             OUString aNewName = ScGlobal::GetRscString(STR_STYLENAME_STANDARD);
      92           0 :             aNewName += OUString::number( nAdd );
      93           0 :             if ( Find( aNewName, eFam ) == NULL )
      94           0 :                 return SfxStyleSheetPool::Make(aNewName, eFam, mask);
      95           0 :         }
      96             :     }
      97        5644 :     return SfxStyleSheetPool::Make(rName, eFam, mask);
      98             : }
      99             : 
     100        5644 : SfxStyleSheetBase* ScStyleSheetPool::Create( const OUString&   rName,
     101             :                                              SfxStyleFamily  eFamily,
     102             :                                              sal_uInt16          nMaskP )
     103             : {
     104        5644 :     ScStyleSheet* pSheet = new ScStyleSheet( rName, *this, eFamily, nMaskP );
     105        5644 :     if ( eFamily == SFX_STYLE_FAMILY_PARA && ScGlobal::GetRscString(STR_STYLENAME_STANDARD) != rName )
     106        3219 :         pSheet->SetParent( ScGlobal::GetRscString(STR_STYLENAME_STANDARD) );
     107             : 
     108        5644 :     return pSheet;
     109             : }
     110             : 
     111           0 : SfxStyleSheetBase* ScStyleSheetPool::Create( const SfxStyleSheetBase& rStyle )
     112             : {
     113             :     OSL_ENSURE( rStyle.ISA(ScStyleSheet), "Invalid StyleSheet-class! :-/" );
     114           0 :     return new ScStyleSheet( static_cast<const ScStyleSheet&>(rStyle) );
     115             : }
     116             : 
     117           1 : void ScStyleSheetPool::Remove( SfxStyleSheetBase* pStyle )
     118             : {
     119           1 :     if ( pStyle )
     120             :     {
     121             :         OSL_ENSURE( IS_SET( SFXSTYLEBIT_USERDEF, pStyle->GetMask() ),
     122             :                     "SFXSTYLEBIT_USERDEF not set!" );
     123             : 
     124           1 :         static_cast<ScDocumentPool&>(rPool).StyleDeleted(static_cast<ScStyleSheet*>(pStyle));
     125           1 :         SfxStyleSheetPool::Remove(pStyle);
     126             :     }
     127           1 : }
     128             : 
     129           8 : void ScStyleSheetPool::CopyStyleFrom( ScStyleSheetPool* pSrcPool,
     130             :                                       const OUString& rName, SfxStyleFamily eFamily )
     131             : {
     132             :     //  this is the Dest-Pool
     133             : 
     134           8 :     SfxStyleSheetBase* pStyleSheet = pSrcPool->Find( rName, eFamily );
     135           8 :     if (pStyleSheet)
     136             :     {
     137           0 :         const SfxItemSet& rSourceSet = pStyleSheet->GetItemSet();
     138           0 :         SfxStyleSheetBase* pDestSheet = Find( rName, eFamily );
     139           0 :         if (!pDestSheet)
     140           0 :             pDestSheet = &Make( rName, eFamily );
     141           0 :         SfxItemSet& rDestSet = pDestSheet->GetItemSet();
     142           0 :         rDestSet.PutExtended( rSourceSet, SfxItemState::DONTCARE, SfxItemState::DEFAULT );
     143             : 
     144             :         const SfxPoolItem* pItem;
     145           0 :         if ( eFamily == SFX_STYLE_FAMILY_PAGE )
     146             :         {
     147             :             //  Set-Items
     148             : 
     149           0 :             if ( rSourceSet.GetItemState( ATTR_PAGE_HEADERSET, false, &pItem ) == SfxItemState::SET )
     150             :             {
     151           0 :                 const SfxItemSet& rSrcSub = static_cast<const SvxSetItem*>(pItem)->GetItemSet();
     152           0 :                 SfxItemSet aDestSub( *rDestSet.GetPool(), rSrcSub.GetRanges() );
     153           0 :                 aDestSub.PutExtended( rSrcSub, SfxItemState::DONTCARE, SfxItemState::DEFAULT );
     154           0 :                 rDestSet.Put( SvxSetItem( ATTR_PAGE_HEADERSET, aDestSub ) );
     155             :             }
     156           0 :             if ( rSourceSet.GetItemState( ATTR_PAGE_FOOTERSET, false, &pItem ) == SfxItemState::SET )
     157             :             {
     158           0 :                 const SfxItemSet& rSrcSub = static_cast<const SvxSetItem*>(pItem)->GetItemSet();
     159           0 :                 SfxItemSet aDestSub( *rDestSet.GetPool(), rSrcSub.GetRanges() );
     160           0 :                 aDestSub.PutExtended( rSrcSub, SfxItemState::DONTCARE, SfxItemState::DEFAULT );
     161           0 :                 rDestSet.Put( SvxSetItem( ATTR_PAGE_FOOTERSET, aDestSub ) );
     162             :             }
     163             :         }
     164             :         else    // cell styles
     165             :         {
     166             :             // number format exchange list has to be handled here, too
     167             : 
     168           0 :             if ( pDoc && pDoc->GetFormatExchangeList() &&
     169           0 :                  rSourceSet.GetItemState( ATTR_VALUE_FORMAT, false, &pItem ) == SfxItemState::SET )
     170             :             {
     171           0 :                 sal_uLong nOldFormat = static_cast<const SfxUInt32Item*>(pItem)->GetValue();
     172           0 :                 SvNumberFormatterIndexTable::const_iterator it = pDoc->GetFormatExchangeList()->find(nOldFormat);
     173           0 :                 if (it != pDoc->GetFormatExchangeList()->end())
     174             :                 {
     175           0 :                     sal_uInt32 nNewFormat = it->second;
     176           0 :                     rDestSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) );
     177             :                 }
     178             :             }
     179             :         }
     180             :     }
     181           8 : }
     182             : 
     183             : //                      Standard templates
     184             : 
     185             : #define SCSTR(id)   ScGlobal::GetRscString(id)
     186             : 
     187           0 : void ScStyleSheetPool::CopyStdStylesFrom( ScStyleSheetPool* pSrcPool )
     188             : {
     189             :     //  Copy Default styles
     190             : 
     191           0 :     CopyStyleFrom( pSrcPool, SCSTR(STR_STYLENAME_STANDARD),     SFX_STYLE_FAMILY_PARA );
     192           0 :     CopyStyleFrom( pSrcPool, SCSTR(STR_STYLENAME_RESULT),       SFX_STYLE_FAMILY_PARA );
     193           0 :     CopyStyleFrom( pSrcPool, SCSTR(STR_STYLENAME_RESULT1),      SFX_STYLE_FAMILY_PARA );
     194           0 :     CopyStyleFrom( pSrcPool, SCSTR(STR_STYLENAME_HEADLINE),     SFX_STYLE_FAMILY_PARA );
     195           0 :     CopyStyleFrom( pSrcPool, SCSTR(STR_STYLENAME_HEADLINE1),    SFX_STYLE_FAMILY_PARA );
     196           0 :     CopyStyleFrom( pSrcPool, SCSTR(STR_STYLENAME_STANDARD),     SFX_STYLE_FAMILY_PAGE );
     197           0 :     CopyStyleFrom( pSrcPool, SCSTR(STR_STYLENAME_REPORT),       SFX_STYLE_FAMILY_PAGE );
     198           0 : }
     199             : 
     200        1827 : static void lcl_CheckFont( SfxItemSet& rSet, LanguageType eLang, DefaultFontType nFontType, sal_uInt16 nItemId )
     201             : {
     202        1827 :     if ( eLang != LANGUAGE_NONE && eLang != LANGUAGE_DONTKNOW && eLang != LANGUAGE_SYSTEM )
     203             :     {
     204        1827 :         vcl::Font aDefFont = OutputDevice::GetDefaultFont( nFontType, eLang, GetDefaultFontFlags::OnlyOne );
     205        1827 :         SvxFontItem aNewItem( aDefFont.GetFamily(), aDefFont.GetName(), aDefFont.GetStyleName(),
     206        5481 :                               aDefFont.GetPitch(), aDefFont.GetCharSet(), nItemId );
     207        1827 :         if ( aNewItem != rSet.Get( nItemId ) )
     208             :         {
     209             :             // put item into style's ItemSet only if different from (static) default
     210         609 :             rSet.Put( aNewItem );
     211        1827 :         }
     212             :     }
     213        1827 : }
     214             : 
     215         609 : void ScStyleSheetPool::CreateStandardStyles()
     216             : {
     217             :     //  Add new entries even for CopyStdStylesFrom
     218             : 
     219         609 :     Color           aColBlack   ( COL_BLACK );
     220         609 :     Color           aColGrey    ( COL_LIGHTGRAY );
     221         609 :     OUString        aStr;
     222             :     sal_Int32       nStrLen;
     223        1218 :     OUString        aHelpFile;//which text???
     224         609 :     SfxItemSet*     pSet            = NULL;
     225         609 :     SfxItemSet*     pHFSet          = NULL;
     226         609 :     SvxSetItem*     pHFSetItem      = NULL;
     227         609 :     ScEditEngineDefaulter*  pEdEngine   = new ScEditEngineDefaulter( EditEngine::CreatePool(), true );
     228         609 :     pEdEngine->SetUpdateMode( false );
     229         609 :     EditTextObject* pEmptyTxtObj    = pEdEngine->CreateTextObject();
     230         609 :     EditTextObject* pTxtObj         = NULL;
     231         609 :     ScPageHFItem*   pHeaderItem     = new ScPageHFItem( ATTR_PAGE_HEADERRIGHT );
     232         609 :     ScPageHFItem*   pFooterItem     = new ScPageHFItem( ATTR_PAGE_FOOTERRIGHT );
     233         609 :     ScStyleSheet*   pSheet          = NULL;
     234         609 :     ::editeng::SvxBorderLine    aBorderLine     ( &aColBlack, DEF_LINE_WIDTH_2 );
     235        1218 :     SvxBoxItem      aBoxItem        ( ATTR_BORDER );
     236        1218 :     SvxBoxInfoItem  aBoxInfoItem    ( ATTR_BORDER_INNER );
     237             : 
     238        1218 :     OUString  aStrStandard = ScGlobal::GetRscString(STR_STYLENAME_STANDARD);
     239             : 
     240             :     // Cell format templates:
     241             : 
     242             :     // 1. Standard
     243             : 
     244         609 :     pSheet = static_cast<ScStyleSheet*>( &Make( aStrStandard, SFX_STYLE_FAMILY_PARA, SCSTYLEBIT_STANDARD ) );
     245         609 :     pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_CELL_STD );
     246             : 
     247             :     //  if default fonts for the document's languages are different from the pool default,
     248             :     //  put them into the default style
     249             :     //  (not as pool defaults, because pool defaults can't be changed by the user)
     250             :     //  the document languages must be set before creating the default styles!
     251             : 
     252         609 :     pSet = &pSheet->GetItemSet();
     253             :     LanguageType eLatin, eCjk, eCtl;
     254         609 :     pDoc->GetLanguage( eLatin, eCjk, eCtl );
     255             : 
     256             :     //  If the UI language is Korean, the default Latin font has to
     257             :     //  be queried for Korean, too (the Latin language from the document can't be Korean).
     258             :     //  This is the same logic as in SwDocShell::InitNew.
     259         609 :     LanguageType eUiLanguage = Application::GetSettings().GetUILanguageTag().getLanguageType();
     260         609 :     if (MsLangId::isKorean(eUiLanguage))
     261           0 :         eLatin = eUiLanguage;
     262             : 
     263         609 :     lcl_CheckFont( *pSet, eLatin, DefaultFontType::LATIN_SPREADSHEET, ATTR_FONT );
     264         609 :     lcl_CheckFont( *pSet, eCjk, DefaultFontType::CJK_SPREADSHEET, ATTR_CJK_FONT );
     265         609 :     lcl_CheckFont( *pSet, eCtl, DefaultFontType::CTL_SPREADSHEET, ATTR_CTL_FONT );
     266             : 
     267             :     // #i55300# default CTL font size for Thai has to be larger
     268             :     // #i59408# The 15 point size causes problems with row heights, so no different
     269             :     // size is used for Thai in Calc for now.
     270             : //    if ( eCtl == LANGUAGE_THAI )
     271             : //        pSet->Put( SvxFontHeightItem( 300, 100, ATTR_CTL_FONT_HEIGHT ) );   // 15 pt
     272             : 
     273             :     // 2. Result
     274             : 
     275         609 :     pSheet = static_cast<ScStyleSheet*>( &Make( SCSTR( STR_STYLENAME_RESULT ),
     276             :                                     SFX_STYLE_FAMILY_PARA,
     277        1218 :                                     SCSTYLEBIT_STANDARD ) );
     278         609 :     pSheet->SetParent( aStrStandard );
     279         609 :     pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_CELL_ERG );
     280         609 :     pSet = &pSheet->GetItemSet();
     281         609 :     pSet->Put( SvxWeightItem( WEIGHT_BOLD, ATTR_FONT_WEIGHT ) );
     282         609 :     pSet->Put( SvxPostureItem( ITALIC_NORMAL, ATTR_FONT_POSTURE ) );
     283         609 :     pSet->Put( SvxUnderlineItem( UNDERLINE_SINGLE, ATTR_FONT_UNDERLINE ) );
     284             : 
     285             :     // 3. Result1
     286             : 
     287         609 :     pSheet = static_cast<ScStyleSheet*>( &Make( SCSTR( STR_STYLENAME_RESULT1 ),
     288             :                                     SFX_STYLE_FAMILY_PARA,
     289        1218 :                                     SCSTYLEBIT_STANDARD ) );
     290             : 
     291         609 :     pSheet->SetParent( SCSTR( STR_STYLENAME_RESULT ) );
     292         609 :     pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_CELL_ERG1 );
     293             : 
     294             :     // 4. headline
     295             : 
     296         609 :     pSheet = static_cast<ScStyleSheet*>( &Make( SCSTR( STR_STYLENAME_HEADLINE ),
     297             :                                     SFX_STYLE_FAMILY_PARA,
     298        1218 :                                     SCSTYLEBIT_STANDARD ) );
     299             : 
     300         609 :     pSheet->SetParent( aStrStandard );
     301         609 :     pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_CELL_UEB );
     302         609 :     pSet = &pSheet->GetItemSet();
     303         609 :     pSet->Put( SvxFontHeightItem( 320, 100, ATTR_FONT_HEIGHT ) ); // 16pt
     304         609 :     pSet->Put( SvxWeightItem( WEIGHT_BOLD, ATTR_FONT_WEIGHT ) );
     305         609 :     pSet->Put( SvxPostureItem( ITALIC_NORMAL, ATTR_FONT_POSTURE ) );
     306         609 :     pSet->Put( SvxHorJustifyItem( SVX_HOR_JUSTIFY_CENTER, ATTR_HOR_JUSTIFY ) );
     307             : 
     308             :     // 5. Ueberschrift1
     309             : 
     310         609 :     pSheet = static_cast<ScStyleSheet*>( &Make( SCSTR( STR_STYLENAME_HEADLINE1 ),
     311             :                                     SFX_STYLE_FAMILY_PARA,
     312        1218 :                                     SCSTYLEBIT_STANDARD ) );
     313             : 
     314         609 :     pSheet->SetParent( SCSTR( STR_STYLENAME_HEADLINE ) );
     315         609 :     pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_CELL_UEB1 );
     316         609 :     pSet = &pSheet->GetItemSet();
     317         609 :     pSet->Put( SfxInt32Item( ATTR_ROTATE_VALUE, 9000 ) );
     318             : 
     319             :     // Page format template:
     320             : 
     321             :     // 1. Standard
     322             : 
     323             :     pSheet = static_cast<ScStyleSheet*>( &Make( aStrStandard,
     324             :                                     SFX_STYLE_FAMILY_PAGE,
     325         609 :                                     SCSTYLEBIT_STANDARD ) );
     326             : 
     327         609 :     pSet = &pSheet->GetItemSet();
     328         609 :     pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_PAGE_STD );
     329             : 
     330             :     // distance to header/footer for the sheet
     331         609 :     pHFSetItem = new SvxSetItem( static_cast<const SvxSetItem&>(pSet->Get( ATTR_PAGE_HEADERSET ) ) );
     332         609 :     pSet->Put( *pHFSetItem, ATTR_PAGE_HEADERSET );
     333         609 :     pSet->Put( *pHFSetItem, ATTR_PAGE_FOOTERSET );
     334         609 :     DELETEZ( pHFSetItem );
     335             : 
     336             :     // Header:
     337             :     // [empty][\sheet\][empty]
     338             : 
     339         609 :     pEdEngine->SetText(EMPTY_OUSTRING);
     340         609 :     pEdEngine->QuickInsertField( SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD), ESelection() );
     341         609 :     pTxtObj = pEdEngine->CreateTextObject();
     342         609 :     pHeaderItem->SetLeftArea  ( *pEmptyTxtObj );
     343         609 :     pHeaderItem->SetCenterArea( *pTxtObj );
     344         609 :     pHeaderItem->SetRightArea ( *pEmptyTxtObj );
     345         609 :     pSet->Put( *pHeaderItem );
     346         609 :     DELETEZ( pTxtObj );
     347             : 
     348             :     // Footer:
     349             :     // [empty][Page \STR_PAGE\][empty]
     350             : 
     351         609 :     aStr = SCSTR( STR_PAGE ) + " ";
     352         609 :     pEdEngine->SetText( aStr );
     353         609 :     nStrLen = aStr.getLength();
     354         609 :     pEdEngine->QuickInsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), ESelection(0,nStrLen,0,nStrLen) );
     355         609 :     pTxtObj = pEdEngine->CreateTextObject();
     356         609 :     pFooterItem->SetLeftArea  ( *pEmptyTxtObj );
     357         609 :     pFooterItem->SetCenterArea( *pTxtObj );
     358         609 :     pFooterItem->SetRightArea ( *pEmptyTxtObj );
     359         609 :     pSet->Put( *pFooterItem );
     360         609 :     DELETEZ( pTxtObj );
     361             : 
     362             :     // 2. Report
     363             : 
     364         609 :     pSheet = static_cast<ScStyleSheet*>( &Make( SCSTR( STR_STYLENAME_REPORT ),
     365             :                                     SFX_STYLE_FAMILY_PAGE,
     366        1218 :                                     SCSTYLEBIT_STANDARD ) );
     367         609 :     pSet = &pSheet->GetItemSet();
     368         609 :     pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_PAGE_REP );
     369             : 
     370             :     // Background and border
     371         609 :     aBoxItem.SetLine( &aBorderLine, SvxBoxItemLine::TOP );
     372         609 :     aBoxItem.SetLine( &aBorderLine, SvxBoxItemLine::BOTTOM );
     373         609 :     aBoxItem.SetLine( &aBorderLine, SvxBoxItemLine::LEFT );
     374         609 :     aBoxItem.SetLine( &aBorderLine, SvxBoxItemLine::RIGHT );
     375         609 :     aBoxItem.SetDistance( 10 ); // 0.2mm
     376         609 :     aBoxInfoItem.SetValid( SvxBoxInfoItemValidFlags::TOP, true );
     377         609 :     aBoxInfoItem.SetValid( SvxBoxInfoItemValidFlags::BOTTOM, true );
     378         609 :     aBoxInfoItem.SetValid( SvxBoxInfoItemValidFlags::LEFT, true );
     379         609 :     aBoxInfoItem.SetValid( SvxBoxInfoItemValidFlags::RIGHT, true );
     380         609 :     aBoxInfoItem.SetValid( SvxBoxInfoItemValidFlags::DISTANCE, true );
     381         609 :     aBoxInfoItem.SetTable( false );
     382         609 :     aBoxInfoItem.SetDist ( true );
     383             : 
     384         609 :     pHFSetItem = new SvxSetItem( static_cast<const SvxSetItem&>(pSet->Get( ATTR_PAGE_HEADERSET ) ) );
     385         609 :     pHFSet = &(pHFSetItem->GetItemSet());
     386             : 
     387         609 :     pHFSet->Put( SvxBrushItem( aColGrey, ATTR_BACKGROUND ) );
     388         609 :     pHFSet->Put( aBoxItem );
     389         609 :     pHFSet->Put( aBoxInfoItem );
     390         609 :     pSet->Put( *pHFSetItem, ATTR_PAGE_HEADERSET );
     391         609 :     pSet->Put( *pHFSetItem, ATTR_PAGE_FOOTERSET );
     392         609 :     DELETEZ( pHFSetItem );
     393             : 
     394             :     // Footer:
     395             :     // [\TABLE\ (\DATA\)][empty][\DATE\, \TIME\]
     396             : 
     397         609 :     aStr = " ()";
     398         609 :     pEdEngine->SetText( aStr );
     399         609 :     pEdEngine->QuickInsertField( SvxFieldItem(SvxFileField(), EE_FEATURE_FIELD), ESelection(0,2,0,2) );
     400         609 :     pEdEngine->QuickInsertField( SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD), ESelection() );
     401         609 :     pTxtObj = pEdEngine->CreateTextObject();
     402         609 :     pHeaderItem->SetLeftArea( *pTxtObj );
     403         609 :     pHeaderItem->SetCenterArea( *pEmptyTxtObj );
     404         609 :     DELETEZ( pTxtObj );
     405         609 :     aStr = ", ";
     406         609 :     pEdEngine->SetText( aStr );
     407         609 :     pEdEngine->QuickInsertField( SvxFieldItem(SvxTimeField(), EE_FEATURE_FIELD), ESelection(0,2,0,2) );
     408             :     pEdEngine->QuickInsertField( SvxFieldItem(SvxDateField(Date( Date::SYSTEM ),SVXDATETYPE_VAR), EE_FEATURE_FIELD),
     409         609 :                                     ESelection() );
     410         609 :     pTxtObj = pEdEngine->CreateTextObject();
     411         609 :     pHeaderItem->SetRightArea( *pTxtObj );
     412         609 :     DELETEZ( pTxtObj );
     413         609 :     pSet->Put( *pHeaderItem );
     414             : 
     415             :     // Footer:
     416             :     // [empty][Page: \PAGE\ / \PAGE\][empty]
     417             : 
     418         609 :     aStr = SCSTR( STR_PAGE ) + " ";
     419         609 :     nStrLen = aStr.getLength();
     420         609 :     aStr += " / ";
     421         609 :     sal_Int32 nStrLen2 = aStr.getLength();
     422         609 :     pEdEngine->SetText( aStr );
     423         609 :     pEdEngine->QuickInsertField( SvxFieldItem(SvxPagesField(), EE_FEATURE_FIELD), ESelection(0,nStrLen2,0,nStrLen2) );
     424         609 :     pEdEngine->QuickInsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), ESelection(0,nStrLen,0,nStrLen) );
     425         609 :     pTxtObj = pEdEngine->CreateTextObject();
     426         609 :     pFooterItem->SetLeftArea  ( *pEmptyTxtObj );
     427         609 :     pFooterItem->SetCenterArea( *pTxtObj );
     428         609 :     pFooterItem->SetRightArea ( *pEmptyTxtObj );
     429         609 :     pSet->Put( *pFooterItem );
     430         609 :     DELETEZ( pTxtObj );
     431             : 
     432         609 :     DELETEZ( pEmptyTxtObj );
     433         609 :     DELETEZ( pHeaderItem );
     434         609 :     DELETEZ( pFooterItem );
     435        1218 :     DELETEZ( pEdEngine );
     436         609 : }
     437             : 
     438             : namespace {
     439             : 
     440           0 : struct CaseInsensitiveNamePredicate : svl::StyleSheetPredicate
     441             : {
     442           0 :     CaseInsensitiveNamePredicate(const rtl::OUString& rName, SfxStyleFamily eFam)
     443           0 :     : mFamily(eFam)
     444             :     {
     445           0 :         mUppercaseName = ScGlobal::pCharClass->uppercase(rName);
     446           0 :     }
     447             : 
     448             :     bool
     449           0 :     Check(const SfxStyleSheetBase& rStyleSheet) SAL_OVERRIDE
     450             :     {
     451           0 :         if (rStyleSheet.GetFamily() == mFamily)
     452             :         {
     453           0 :             rtl::OUString aUpName = ScGlobal::pCharClass->uppercase(rStyleSheet.GetName());
     454           0 :             if (mUppercaseName == aUpName)
     455             :             {
     456           0 :                 return true;
     457           0 :             }
     458             :         }
     459           0 :         return false;
     460             :     }
     461             : 
     462             :     rtl::OUString mUppercaseName;
     463             :     SfxStyleFamily mFamily;
     464             : };
     465             : 
     466             : }
     467             : 
     468             : // Functor object to find all style sheets of a family which match a given name caseinsensitively
     469           0 : ScStyleSheet* ScStyleSheetPool::FindCaseIns( const OUString& rName, SfxStyleFamily eFam )
     470             : {
     471           0 :     CaseInsensitiveNamePredicate aPredicate(rName, eFam);
     472           0 :     std::vector<unsigned> aFoundPositions = GetIndexedStyleSheets().FindPositionsByPredicate(aPredicate);
     473           0 :     std::vector<unsigned>::const_iterator it = aFoundPositions.begin();
     474             : 
     475           0 :     for (/**/;it != aFoundPositions.end(); ++it)
     476             :     {
     477           0 :         SfxStyleSheetBase *pFound = GetStyleSheetByPositionInIndex(*it).get();
     478           0 :         ScStyleSheet* pSheet = NULL;
     479             :         // we do not know what kind of sheets we have.
     480           0 :         pSheet = dynamic_cast<ScStyleSheet*>(pFound);
     481           0 :         if (pSheet != NULL)
     482             :         {
     483           0 :             return pSheet;
     484             :         }
     485             :     }
     486           0 :     return NULL;
     487         156 : }
     488             : 
     489             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11