LCOV - code coverage report
Current view: top level - sc/source/core/data - stlpool.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 172 239 72.0 %
Date: 2014-11-03 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        2258 : ScStyleSheetPool::ScStyleSheetPool( SfxItemPool&    rPoolP,
      59             :                                     ScDocument*     pDocument )
      60             :     :   SfxStyleSheetPool( rPoolP ),
      61             :         pActualStyleSheet( NULL ),
      62             :         pDoc( pDocument ),
      63        2258 :         pForceStdName( NULL )
      64             : {
      65        2258 : }
      66             : 
      67        4416 : ScStyleSheetPool::~ScStyleSheetPool()
      68             : {
      69        4416 : }
      70             : 
      71        4060 : void ScStyleSheetPool::SetDocument( ScDocument* pDocument )
      72             : {
      73        4060 :     pDoc = pDocument;
      74        4060 : }
      75             : 
      76        9054 : 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             :     //! only when loading?
      84             : 
      85        9054 :     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        9054 :     return SfxStyleSheetPool::Make(rName, eFam, mask);
      98             : }
      99             : 
     100        9054 : SfxStyleSheetBase* ScStyleSheetPool::Create( const OUString&   rName,
     101             :                                              SfxStyleFamily  eFamily,
     102             :                                              sal_uInt16          nMaskP )
     103             : {
     104        9054 :     ScStyleSheet* pSheet = new ScStyleSheet( rName, *this, eFamily, nMaskP );
     105        9054 :     if ( eFamily == SFX_STYLE_FAMILY_PARA && ScGlobal::GetRscString(STR_STYLENAME_STANDARD) != rName )
     106        5320 :         pSheet->SetParent( ScGlobal::GetRscString(STR_STYLENAME_STANDARD) );
     107             : 
     108        9054 :     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           2 : void ScStyleSheetPool::Remove( SfxStyleSheetBase* pStyle )
     118             : {
     119           2 :     if ( pStyle )
     120             :     {
     121             :         OSL_ENSURE( IS_SET( SFXSTYLEBIT_USERDEF, pStyle->GetMask() ),
     122             :                     "SFXSTYLEBIT_USERDEF not set!" );
     123             : 
     124           2 :         static_cast<ScDocumentPool&>(rPool).StyleDeleted(static_cast<ScStyleSheet*>(pStyle));
     125           2 :         SfxStyleSheetPool::Remove(pStyle);
     126             :     }
     127           2 : }
     128             : 
     129           6 : void ScStyleSheetPool::CopyStyleFrom( ScStyleSheetPool* pSrcPool,
     130             :                                       const OUString& rName, SfxStyleFamily eFamily )
     131             : {
     132             :     //  this ist Dest-Pool
     133             : 
     134           6 :     SfxStyleSheetBase* pStyleSheet = pSrcPool->Find( rName, eFamily );
     135           6 :     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           6 : }
     182             : 
     183             : //                      Standard-Vorlagen
     184             : 
     185             : #define SCSTR(id)   ScGlobal::GetRscString(id)
     186             : 
     187           0 : void ScStyleSheetPool::CopyStdStylesFrom( ScStyleSheetPool* pSrcPool )
     188             : {
     189             :     //  Default-Styles kopieren
     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        2856 : static void lcl_CheckFont( SfxItemSet& rSet, LanguageType eLang, sal_uInt16 nFontType, sal_uInt16 nItemId )
     201             : {
     202        2856 :     if ( eLang != LANGUAGE_NONE && eLang != LANGUAGE_DONTKNOW && eLang != LANGUAGE_SYSTEM )
     203             :     {
     204        2856 :         vcl::Font aDefFont = OutputDevice::GetDefaultFont( nFontType, eLang, DEFAULTFONT_FLAGS_ONLYONE );
     205        2856 :         SvxFontItem aNewItem( aDefFont.GetFamily(), aDefFont.GetName(), aDefFont.GetStyleName(),
     206        8568 :                               aDefFont.GetPitch(), aDefFont.GetCharSet(), nItemId );
     207        2856 :         if ( aNewItem != rSet.Get( nItemId ) )
     208             :         {
     209             :             // put item into style's ItemSet only if different from (static) default
     210           0 :             rSet.Put( aNewItem );
     211        2856 :         }
     212             :     }
     213        2856 : }
     214             : 
     215         952 : void ScStyleSheetPool::CreateStandardStyles()
     216             : {
     217             :     //  neue Eintraege auch bei CopyStdStylesFrom eintragen
     218             : 
     219         952 :     Color           aColBlack   ( COL_BLACK );
     220         952 :     Color           aColGrey    ( COL_LIGHTGRAY );
     221         952 :     OUString        aStr;
     222             :     sal_Int32       nStrLen;
     223        1904 :     OUString        aHelpFile;//XXX JN welcher Text???
     224         952 :     SfxItemSet*     pSet            = NULL;
     225         952 :     SfxItemSet*     pHFSet          = NULL;
     226         952 :     SvxSetItem*     pHFSetItem      = NULL;
     227         952 :     ScEditEngineDefaulter*  pEdEngine   = new ScEditEngineDefaulter( EditEngine::CreatePool(), true );
     228         952 :     pEdEngine->SetUpdateMode( false );
     229         952 :     EditTextObject* pEmptyTxtObj    = pEdEngine->CreateTextObject();
     230         952 :     EditTextObject* pTxtObj         = NULL;
     231         952 :     ScPageHFItem*   pHeaderItem     = new ScPageHFItem( ATTR_PAGE_HEADERRIGHT );
     232         952 :     ScPageHFItem*   pFooterItem     = new ScPageHFItem( ATTR_PAGE_FOOTERRIGHT );
     233         952 :     ScStyleSheet*   pSheet          = NULL;
     234         952 :     ::editeng::SvxBorderLine    aBorderLine     ( &aColBlack, DEF_LINE_WIDTH_2 );
     235        1904 :     SvxBoxItem      aBoxItem        ( ATTR_BORDER );
     236        1904 :     SvxBoxInfoItem  aBoxInfoItem    ( ATTR_BORDER_INNER );
     237             : 
     238        1904 :     OUString  aStrStandard = ScGlobal::GetRscString(STR_STYLENAME_STANDARD);
     239             : 
     240             :     // Zellformatvorlagen:
     241             : 
     242             :     // 1. Standard
     243             : 
     244         952 :     pSheet = static_cast<ScStyleSheet*>( &Make( aStrStandard, SFX_STYLE_FAMILY_PARA, SCSTYLEBIT_STANDARD ) );
     245         952 :     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         952 :     pSet = &pSheet->GetItemSet();
     253             :     LanguageType eLatin, eCjk, eCtl;
     254         952 :     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         952 :     LanguageType eUiLanguage = Application::GetSettings().GetUILanguageTag().getLanguageType();
     260         952 :     if (MsLangId::isKorean(eUiLanguage))
     261           0 :         eLatin = eUiLanguage;
     262             : 
     263         952 :     lcl_CheckFont( *pSet, eLatin, DEFAULTFONT_LATIN_SPREADSHEET, ATTR_FONT );
     264         952 :     lcl_CheckFont( *pSet, eCjk, DEFAULTFONT_CJK_SPREADSHEET, ATTR_CJK_FONT );
     265         952 :     lcl_CheckFont( *pSet, eCtl, DEFAULTFONT_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. Ergebnis
     274             : 
     275         952 :     pSheet = static_cast<ScStyleSheet*>( &Make( SCSTR( STR_STYLENAME_RESULT ),
     276             :                                     SFX_STYLE_FAMILY_PARA,
     277        1904 :                                     SCSTYLEBIT_STANDARD ) );
     278         952 :     pSheet->SetParent( aStrStandard );
     279         952 :     pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_CELL_ERG );
     280         952 :     pSet = &pSheet->GetItemSet();
     281         952 :     pSet->Put( SvxWeightItem( WEIGHT_BOLD, ATTR_FONT_WEIGHT ) );
     282         952 :     pSet->Put( SvxPostureItem( ITALIC_NORMAL, ATTR_FONT_POSTURE ) );
     283         952 :     pSet->Put( SvxUnderlineItem( UNDERLINE_SINGLE, ATTR_FONT_UNDERLINE ) );
     284             : 
     285             :     // 3. Ergebnis1
     286             : 
     287         952 :     pSheet = static_cast<ScStyleSheet*>( &Make( SCSTR( STR_STYLENAME_RESULT1 ),
     288             :                                     SFX_STYLE_FAMILY_PARA,
     289        1904 :                                     SCSTYLEBIT_STANDARD ) );
     290             : 
     291         952 :     pSheet->SetParent( SCSTR( STR_STYLENAME_RESULT ) );
     292         952 :     pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_CELL_ERG1 );
     293             : 
     294             :     // 4. Ueberschrift
     295             : 
     296         952 :     pSheet = static_cast<ScStyleSheet*>( &Make( SCSTR( STR_STYLENAME_HEADLINE ),
     297             :                                     SFX_STYLE_FAMILY_PARA,
     298        1904 :                                     SCSTYLEBIT_STANDARD ) );
     299             : 
     300         952 :     pSheet->SetParent( aStrStandard );
     301         952 :     pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_CELL_UEB );
     302         952 :     pSet = &pSheet->GetItemSet();
     303         952 :     pSet->Put( SvxFontHeightItem( 320, 100, ATTR_FONT_HEIGHT ) ); // 16pt
     304         952 :     pSet->Put( SvxWeightItem( WEIGHT_BOLD, ATTR_FONT_WEIGHT ) );
     305         952 :     pSet->Put( SvxPostureItem( ITALIC_NORMAL, ATTR_FONT_POSTURE ) );
     306         952 :     pSet->Put( SvxHorJustifyItem( SVX_HOR_JUSTIFY_CENTER, ATTR_HOR_JUSTIFY ) );
     307             : 
     308             :     // 5. Ueberschrift1
     309             : 
     310         952 :     pSheet = static_cast<ScStyleSheet*>( &Make( SCSTR( STR_STYLENAME_HEADLINE1 ),
     311             :                                     SFX_STYLE_FAMILY_PARA,
     312        1904 :                                     SCSTYLEBIT_STANDARD ) );
     313             : 
     314         952 :     pSheet->SetParent( SCSTR( STR_STYLENAME_HEADLINE ) );
     315         952 :     pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_CELL_UEB1 );
     316         952 :     pSet = &pSheet->GetItemSet();
     317         952 :     pSet->Put( SfxInt32Item( ATTR_ROTATE_VALUE, 9000 ) );
     318             : 
     319             :     // Seitenformat-Vorlagen:
     320             : 
     321             :     // 1. Standard
     322             : 
     323             :     pSheet = static_cast<ScStyleSheet*>( &Make( aStrStandard,
     324             :                                     SFX_STYLE_FAMILY_PAGE,
     325         952 :                                     SCSTYLEBIT_STANDARD ) );
     326             : 
     327         952 :     pSet = &pSheet->GetItemSet();
     328         952 :     pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_PAGE_STD );
     329             : 
     330             :     // Abstand der Kopf-/Fusszeilen von der Tabelle
     331         952 :     pHFSetItem = new SvxSetItem( static_cast<const SvxSetItem&>(pSet->Get( ATTR_PAGE_HEADERSET ) ) );
     332         952 :     pSet->Put( *pHFSetItem, ATTR_PAGE_HEADERSET );
     333         952 :     pSet->Put( *pHFSetItem, ATTR_PAGE_FOOTERSET );
     334         952 :     DELETEZ( pHFSetItem );
     335             : 
     336             :     // Kopfzeile:
     337             :     // [leer][\TABELLE\][leer]
     338             : 
     339         952 :     pEdEngine->SetText(EMPTY_OUSTRING);
     340         952 :     pEdEngine->QuickInsertField( SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD), ESelection() );
     341         952 :     pTxtObj = pEdEngine->CreateTextObject();
     342         952 :     pHeaderItem->SetLeftArea  ( *pEmptyTxtObj );
     343         952 :     pHeaderItem->SetCenterArea( *pTxtObj );
     344         952 :     pHeaderItem->SetRightArea ( *pEmptyTxtObj );
     345         952 :     pSet->Put( *pHeaderItem );
     346         952 :     DELETEZ( pTxtObj );
     347             : 
     348             :     // Fusszeile:
     349             :     // [leer][Seite \SEITE\][leer]
     350             : 
     351         952 :     aStr = SCSTR( STR_PAGE ) + " ";
     352         952 :     pEdEngine->SetText( aStr );
     353         952 :     nStrLen = aStr.getLength();
     354         952 :     pEdEngine->QuickInsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), ESelection(0,nStrLen,0,nStrLen) );
     355         952 :     pTxtObj = pEdEngine->CreateTextObject();
     356         952 :     pFooterItem->SetLeftArea  ( *pEmptyTxtObj );
     357         952 :     pFooterItem->SetCenterArea( *pTxtObj );
     358         952 :     pFooterItem->SetRightArea ( *pEmptyTxtObj );
     359         952 :     pSet->Put( *pFooterItem );
     360         952 :     DELETEZ( pTxtObj );
     361             : 
     362             :     // 2. Report
     363             : 
     364         952 :     pSheet = static_cast<ScStyleSheet*>( &Make( SCSTR( STR_STYLENAME_REPORT ),
     365             :                                     SFX_STYLE_FAMILY_PAGE,
     366        1904 :                                     SCSTYLEBIT_STANDARD ) );
     367         952 :     pSet = &pSheet->GetItemSet();
     368         952 :     pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_PAGE_REP );
     369             : 
     370             :     // Hintergrund und Umrandung
     371         952 :     aBoxItem.SetLine( &aBorderLine, BOX_LINE_TOP );
     372         952 :     aBoxItem.SetLine( &aBorderLine, BOX_LINE_BOTTOM );
     373         952 :     aBoxItem.SetLine( &aBorderLine, BOX_LINE_LEFT );
     374         952 :     aBoxItem.SetLine( &aBorderLine, BOX_LINE_RIGHT );
     375         952 :     aBoxItem.SetDistance( 10 ); // 0.2mm
     376         952 :     aBoxInfoItem.SetValid( VALID_TOP, true );
     377         952 :     aBoxInfoItem.SetValid( VALID_BOTTOM, true );
     378         952 :     aBoxInfoItem.SetValid( VALID_LEFT, true );
     379         952 :     aBoxInfoItem.SetValid( VALID_RIGHT, true );
     380         952 :     aBoxInfoItem.SetValid( VALID_DISTANCE, true );
     381         952 :     aBoxInfoItem.SetTable( false );
     382         952 :     aBoxInfoItem.SetDist ( true );
     383             : 
     384         952 :     pHFSetItem = new SvxSetItem( static_cast<const SvxSetItem&>(pSet->Get( ATTR_PAGE_HEADERSET ) ) );
     385         952 :     pHFSet = &(pHFSetItem->GetItemSet());
     386             : 
     387         952 :     pHFSet->Put( SvxBrushItem( aColGrey, ATTR_BACKGROUND ) );
     388         952 :     pHFSet->Put( aBoxItem );
     389         952 :     pHFSet->Put( aBoxInfoItem );
     390         952 :     pSet->Put( *pHFSetItem, ATTR_PAGE_HEADERSET );
     391         952 :     pSet->Put( *pHFSetItem, ATTR_PAGE_FOOTERSET );
     392         952 :     DELETEZ( pHFSetItem );
     393             : 
     394             :     // Kopfzeile:
     395             :     // [\TABELLE\ (\DATEI\)][leer][\DATUM\, \ZEIT\]
     396             : 
     397         952 :     aStr = " ()";
     398         952 :     pEdEngine->SetText( aStr );
     399         952 :     pEdEngine->QuickInsertField( SvxFieldItem(SvxFileField(), EE_FEATURE_FIELD), ESelection(0,2,0,2) );
     400         952 :     pEdEngine->QuickInsertField( SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD), ESelection() );
     401         952 :     pTxtObj = pEdEngine->CreateTextObject();
     402         952 :     pHeaderItem->SetLeftArea( *pTxtObj );
     403         952 :     pHeaderItem->SetCenterArea( *pEmptyTxtObj );
     404         952 :     DELETEZ( pTxtObj );
     405         952 :     aStr = ", ";
     406         952 :     pEdEngine->SetText( aStr );
     407         952 :     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         952 :                                     ESelection() );
     410         952 :     pTxtObj = pEdEngine->CreateTextObject();
     411         952 :     pHeaderItem->SetRightArea( *pTxtObj );
     412         952 :     DELETEZ( pTxtObj );
     413         952 :     pSet->Put( *pHeaderItem );
     414             : 
     415             :     // Fusszeile:
     416             :     // [leer][Seite: \SEITE\ / \SEITEN\][leer]
     417             : 
     418         952 :     aStr = SCSTR( STR_PAGE ) + " ";
     419         952 :     nStrLen = aStr.getLength();
     420         952 :     aStr += " / ";
     421         952 :     sal_Int32 nStrLen2 = aStr.getLength();
     422         952 :     pEdEngine->SetText( aStr );
     423         952 :     pEdEngine->QuickInsertField( SvxFieldItem(SvxPagesField(), EE_FEATURE_FIELD), ESelection(0,nStrLen2,0,nStrLen2) );
     424         952 :     pEdEngine->QuickInsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), ESelection(0,nStrLen,0,nStrLen) );
     425         952 :     pTxtObj = pEdEngine->CreateTextObject();
     426         952 :     pFooterItem->SetLeftArea  ( *pEmptyTxtObj );
     427         952 :     pFooterItem->SetCenterArea( *pTxtObj );
     428         952 :     pFooterItem->SetRightArea ( *pEmptyTxtObj );
     429         952 :     pSet->Put( *pFooterItem );
     430         952 :     DELETEZ( pTxtObj );
     431             : 
     432         952 :     DELETEZ( pEmptyTxtObj );
     433         952 :     DELETEZ( pHeaderItem );
     434         952 :     DELETEZ( pFooterItem );
     435        1904 :     DELETEZ( pEdEngine );
     436         952 : }
     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         228 : }
     488             : 
     489             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10