LCOV - code coverage report
Current view: top level - sc/source/core/data - stlpool.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 172 238 72.3 %
Date: 2014-04-11 Functions: 10 17 58.8 %
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             : 
      59         970 : ScStyleSheetPool::ScStyleSheetPool( SfxItemPool&    rPoolP,
      60             :                                     ScDocument*     pDocument )
      61             :     :   SfxStyleSheetPool( rPoolP ),
      62             :         pActualStyleSheet( NULL ),
      63             :         pDoc( pDocument ),
      64         970 :         pForceStdName( NULL )
      65             : {
      66         970 : }
      67             : 
      68        1598 : ScStyleSheetPool::~ScStyleSheetPool()
      69             : {
      70        1598 : }
      71             : 
      72        1657 : void ScStyleSheetPool::SetDocument( ScDocument* pDocument )
      73             : {
      74        1657 :     pDoc = pDocument;
      75        1657 : }
      76             : 
      77        3676 : SfxStyleSheetBase& ScStyleSheetPool::Make( const OUString& rName,
      78             :                                            SfxStyleFamily eFam, sal_uInt16 mask)
      79             : {
      80             :     //  When updating styles from a template, Office 5.1 sometimes created
      81             :     //  files with multiple default styles.
      82             :     //  Create new styles in that case:
      83             : 
      84             :     //! only when loading?
      85             : 
      86        3676 :     if ( rName == STRING_STANDARD && Find( rName, eFam ) != NULL )
      87             :     {
      88             :         OSL_FAIL("renaming additional default style");
      89           0 :         sal_uInt32 nCount = GetIndexedStyleSheets().GetNumberOfStyleSheets();
      90           0 :         for ( sal_uInt32 nAdd = 1; nAdd <= nCount; nAdd++ )
      91             :         {
      92           0 :             OUString aNewName = ScGlobal::GetRscString(STR_STYLENAME_STANDARD);
      93           0 :             aNewName += OUString::number( nAdd );
      94           0 :             if ( Find( aNewName, eFam ) == NULL )
      95           0 :                 return SfxStyleSheetPool::Make(aNewName, eFam, mask);
      96           0 :         }
      97             :     }
      98        3676 :     return SfxStyleSheetPool::Make(rName, eFam, mask);
      99             : }
     100             : 
     101        3676 : SfxStyleSheetBase* ScStyleSheetPool::Create( const OUString&   rName,
     102             :                                              SfxStyleFamily  eFamily,
     103             :                                              sal_uInt16          nMaskP )
     104             : {
     105        3676 :     ScStyleSheet* pSheet = new ScStyleSheet( rName, *this, eFamily, nMaskP );
     106        3676 :     if ( eFamily == SFX_STYLE_FAMILY_PARA && ScGlobal::GetRscString(STR_STYLENAME_STANDARD) != rName )
     107        2227 :         pSheet->SetParent( ScGlobal::GetRscString(STR_STYLENAME_STANDARD) );
     108             : 
     109        3676 :     return pSheet;
     110             : }
     111             : 
     112           0 : SfxStyleSheetBase* ScStyleSheetPool::Create( const SfxStyleSheetBase& rStyle )
     113             : {
     114             :     OSL_ENSURE( rStyle.ISA(ScStyleSheet), "Invalid StyleSheet-class! :-/" );
     115           0 :     return new ScStyleSheet( (const ScStyleSheet&) rStyle );
     116             : }
     117             : 
     118           1 : void ScStyleSheetPool::Remove( SfxStyleSheetBase* pStyle )
     119             : {
     120           1 :     if ( pStyle )
     121             :     {
     122             :         OSL_ENSURE( IS_SET( SFXSTYLEBIT_USERDEF, pStyle->GetMask() ),
     123             :                     "SFXSTYLEBIT_USERDEF not set!" );
     124             : 
     125           1 :         ((ScDocumentPool&)rPool).StyleDeleted((ScStyleSheet*)pStyle);
     126           1 :         SfxStyleSheetPool::Remove(pStyle);
     127             :     }
     128           1 : }
     129             : 
     130           1 : void ScStyleSheetPool::CopyStyleFrom( ScStyleSheetPool* pSrcPool,
     131             :                                       const OUString& rName, SfxStyleFamily eFamily )
     132             : {
     133             :     //  this ist Dest-Pool
     134             : 
     135           1 :     SfxStyleSheetBase* pStyleSheet = pSrcPool->Find( rName, eFamily );
     136           1 :     if (pStyleSheet)
     137             :     {
     138           0 :         const SfxItemSet& rSourceSet = pStyleSheet->GetItemSet();
     139           0 :         SfxStyleSheetBase* pDestSheet = Find( rName, eFamily );
     140           0 :         if (!pDestSheet)
     141           0 :             pDestSheet = &Make( rName, eFamily );
     142           0 :         SfxItemSet& rDestSet = pDestSheet->GetItemSet();
     143           0 :         rDestSet.PutExtended( rSourceSet, SFX_ITEM_DONTCARE, SFX_ITEM_DEFAULT );
     144             : 
     145             :         const SfxPoolItem* pItem;
     146           0 :         if ( eFamily == SFX_STYLE_FAMILY_PAGE )
     147             :         {
     148             :             //  Set-Items
     149             : 
     150           0 :             if ( rSourceSet.GetItemState( ATTR_PAGE_HEADERSET, false, &pItem ) == SFX_ITEM_SET )
     151             :             {
     152           0 :                 const SfxItemSet& rSrcSub = ((const SvxSetItem*) pItem)->GetItemSet();
     153           0 :                 SfxItemSet aDestSub( *rDestSet.GetPool(), rSrcSub.GetRanges() );
     154           0 :                 aDestSub.PutExtended( rSrcSub, SFX_ITEM_DONTCARE, SFX_ITEM_DEFAULT );
     155           0 :                 rDestSet.Put( SvxSetItem( ATTR_PAGE_HEADERSET, aDestSub ) );
     156             :             }
     157           0 :             if ( rSourceSet.GetItemState( ATTR_PAGE_FOOTERSET, false, &pItem ) == SFX_ITEM_SET )
     158             :             {
     159           0 :                 const SfxItemSet& rSrcSub = ((const SvxSetItem*) pItem)->GetItemSet();
     160           0 :                 SfxItemSet aDestSub( *rDestSet.GetPool(), rSrcSub.GetRanges() );
     161           0 :                 aDestSub.PutExtended( rSrcSub, SFX_ITEM_DONTCARE, SFX_ITEM_DEFAULT );
     162           0 :                 rDestSet.Put( SvxSetItem( ATTR_PAGE_FOOTERSET, aDestSub ) );
     163             :             }
     164             :         }
     165             :         else    // cell styles
     166             :         {
     167             :             // number format exchange list has to be handled here, too
     168             : 
     169           0 :             if ( pDoc && pDoc->GetFormatExchangeList() &&
     170           0 :                  rSourceSet.GetItemState( ATTR_VALUE_FORMAT, false, &pItem ) == SFX_ITEM_SET )
     171             :             {
     172           0 :                 sal_uLong nOldFormat = static_cast<const SfxUInt32Item*>(pItem)->GetValue();
     173           0 :                 SvNumberFormatterIndexTable::const_iterator it = pDoc->GetFormatExchangeList()->find(nOldFormat);
     174           0 :                 if (it != pDoc->GetFormatExchangeList()->end())
     175             :                 {
     176           0 :                     sal_uInt32 nNewFormat = it->second;
     177           0 :                     rDestSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) );
     178             :                 }
     179             :             }
     180             :         }
     181             :     }
     182           1 : }
     183             : 
     184             : //                      Standard-Vorlagen
     185             : 
     186             : #define SCSTR(id)   ScGlobal::GetRscString(id)
     187             : 
     188           0 : void ScStyleSheetPool::CopyStdStylesFrom( ScStyleSheetPool* pSrcPool )
     189             : {
     190             :     //  Default-Styles kopieren
     191             : 
     192           0 :     CopyStyleFrom( pSrcPool, SCSTR(STR_STYLENAME_STANDARD),     SFX_STYLE_FAMILY_PARA );
     193           0 :     CopyStyleFrom( pSrcPool, SCSTR(STR_STYLENAME_RESULT),       SFX_STYLE_FAMILY_PARA );
     194           0 :     CopyStyleFrom( pSrcPool, SCSTR(STR_STYLENAME_RESULT1),      SFX_STYLE_FAMILY_PARA );
     195           0 :     CopyStyleFrom( pSrcPool, SCSTR(STR_STYLENAME_HEADLINE),     SFX_STYLE_FAMILY_PARA );
     196           0 :     CopyStyleFrom( pSrcPool, SCSTR(STR_STYLENAME_HEADLINE1),    SFX_STYLE_FAMILY_PARA );
     197           0 :     CopyStyleFrom( pSrcPool, SCSTR(STR_STYLENAME_STANDARD),     SFX_STYLE_FAMILY_PAGE );
     198           0 :     CopyStyleFrom( pSrcPool, SCSTR(STR_STYLENAME_REPORT),       SFX_STYLE_FAMILY_PAGE );
     199           0 : }
     200             : 
     201        1161 : static void lcl_CheckFont( SfxItemSet& rSet, LanguageType eLang, sal_uInt16 nFontType, sal_uInt16 nItemId )
     202             : {
     203        1161 :     if ( eLang != LANGUAGE_NONE && eLang != LANGUAGE_DONTKNOW && eLang != LANGUAGE_SYSTEM )
     204             :     {
     205        1161 :         Font aDefFont = OutputDevice::GetDefaultFont( nFontType, eLang, DEFAULTFONT_FLAGS_ONLYONE );
     206        1161 :         SvxFontItem aNewItem( aDefFont.GetFamily(), aDefFont.GetName(), aDefFont.GetStyleName(),
     207        3483 :                               aDefFont.GetPitch(), aDefFont.GetCharSet(), nItemId );
     208        1161 :         if ( aNewItem != rSet.Get( nItemId ) )
     209             :         {
     210             :             // put item into style's ItemSet only if different from (static) default
     211         774 :             rSet.Put( aNewItem );
     212        1161 :         }
     213             :     }
     214        1161 : }
     215             : 
     216         387 : void ScStyleSheetPool::CreateStandardStyles()
     217             : {
     218             :     //  neue Eintraege auch bei CopyStdStylesFrom eintragen
     219             : 
     220         387 :     Color           aColBlack   ( COL_BLACK );
     221         387 :     Color           aColGrey    ( COL_LIGHTGRAY );
     222         387 :     OUString        aStr;
     223             :     sal_Int32       nStrLen;
     224         774 :     OUString        aHelpFile;//XXX JN welcher Text???
     225         387 :     SfxItemSet*     pSet            = NULL;
     226         387 :     SfxItemSet*     pHFSet          = NULL;
     227         387 :     SvxSetItem*     pHFSetItem      = NULL;
     228         387 :     ScEditEngineDefaulter*  pEdEngine   = new ScEditEngineDefaulter( EditEngine::CreatePool(), true );
     229         387 :     pEdEngine->SetUpdateMode( false );
     230         387 :     EditTextObject* pEmptyTxtObj    = pEdEngine->CreateTextObject();
     231         387 :     EditTextObject* pTxtObj         = NULL;
     232         387 :     ScPageHFItem*   pHeaderItem     = new ScPageHFItem( ATTR_PAGE_HEADERRIGHT );
     233         387 :     ScPageHFItem*   pFooterItem     = new ScPageHFItem( ATTR_PAGE_FOOTERRIGHT );
     234         387 :     ScStyleSheet*   pSheet          = NULL;
     235         387 :     ::editeng::SvxBorderLine    aBorderLine     ( &aColBlack, DEF_LINE_WIDTH_2 );
     236         774 :     SvxBoxItem      aBoxItem        ( ATTR_BORDER );
     237         774 :     SvxBoxInfoItem  aBoxInfoItem    ( ATTR_BORDER_INNER );
     238             : 
     239         774 :     OUString  aStrStandard = ScGlobal::GetRscString(STR_STYLENAME_STANDARD);
     240             : 
     241             : 
     242             :     // Zellformatvorlagen:
     243             : 
     244             :     // 1. Standard
     245             : 
     246         387 :     pSheet = (ScStyleSheet*) &Make( aStrStandard, SFX_STYLE_FAMILY_PARA, SCSTYLEBIT_STANDARD );
     247         387 :     pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_CELL_STD );
     248             : 
     249             :     //  if default fonts for the document's languages are different from the pool default,
     250             :     //  put them into the default style
     251             :     //  (not as pool defaults, because pool defaults can't be changed by the user)
     252             :     //  the document languages must be set before creating the default styles!
     253             : 
     254         387 :     pSet = &pSheet->GetItemSet();
     255             :     LanguageType eLatin, eCjk, eCtl;
     256         387 :     pDoc->GetLanguage( eLatin, eCjk, eCtl );
     257             : 
     258             :     //  If the UI language is Korean, the default Latin font has to
     259             :     //  be queried for Korean, too (the Latin language from the document can't be Korean).
     260             :     //  This is the same logic as in SwDocShell::InitNew.
     261         387 :     LanguageType eUiLanguage = Application::GetSettings().GetUILanguageTag().getLanguageType();
     262         387 :     if (MsLangId::isKorean(eUiLanguage))
     263           0 :         eLatin = eUiLanguage;
     264             : 
     265         387 :     lcl_CheckFont( *pSet, eLatin, DEFAULTFONT_LATIN_SPREADSHEET, ATTR_FONT );
     266         387 :     lcl_CheckFont( *pSet, eCjk, DEFAULTFONT_CJK_SPREADSHEET, ATTR_CJK_FONT );
     267         387 :     lcl_CheckFont( *pSet, eCtl, DEFAULTFONT_CTL_SPREADSHEET, ATTR_CTL_FONT );
     268             : 
     269             :     // #i55300# default CTL font size for Thai has to be larger
     270             :     // #i59408# The 15 point size causes problems with row heights, so no different
     271             :     // size is used for Thai in Calc for now.
     272             : //    if ( eCtl == LANGUAGE_THAI )
     273             : //        pSet->Put( SvxFontHeightItem( 300, 100, ATTR_CTL_FONT_HEIGHT ) );   // 15 pt
     274             : 
     275             : 
     276             :     // 2. Ergebnis
     277             : 
     278             : 
     279         387 :     pSheet = (ScStyleSheet*) &Make( SCSTR( STR_STYLENAME_RESULT ),
     280             :                                     SFX_STYLE_FAMILY_PARA,
     281         774 :                                     SCSTYLEBIT_STANDARD );
     282         387 :     pSheet->SetParent( aStrStandard );
     283         387 :     pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_CELL_ERG );
     284         387 :     pSet = &pSheet->GetItemSet();
     285         387 :     pSet->Put( SvxWeightItem( WEIGHT_BOLD, ATTR_FONT_WEIGHT ) );
     286         387 :     pSet->Put( SvxPostureItem( ITALIC_NORMAL, ATTR_FONT_POSTURE ) );
     287         387 :     pSet->Put( SvxUnderlineItem( UNDERLINE_SINGLE, ATTR_FONT_UNDERLINE ) );
     288             : 
     289             : 
     290             :     // 3. Ergebnis1
     291             : 
     292             : 
     293         387 :     pSheet = (ScStyleSheet*) &Make( SCSTR( STR_STYLENAME_RESULT1 ),
     294             :                                     SFX_STYLE_FAMILY_PARA,
     295         774 :                                     SCSTYLEBIT_STANDARD );
     296             : 
     297         387 :     pSheet->SetParent( SCSTR( STR_STYLENAME_RESULT ) );
     298         387 :     pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_CELL_ERG1 );
     299             : 
     300             : 
     301             :     // 4. Ueberschrift
     302             : 
     303             : 
     304         387 :     pSheet = (ScStyleSheet*) &Make( SCSTR( STR_STYLENAME_HEADLINE ),
     305             :                                     SFX_STYLE_FAMILY_PARA,
     306         774 :                                     SCSTYLEBIT_STANDARD );
     307             : 
     308         387 :     pSheet->SetParent( aStrStandard );
     309         387 :     pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_CELL_UEB );
     310         387 :     pSet = &pSheet->GetItemSet();
     311         387 :     pSet->Put( SvxFontHeightItem( 320, 100, ATTR_FONT_HEIGHT ) ); // 16pt
     312         387 :     pSet->Put( SvxWeightItem( WEIGHT_BOLD, ATTR_FONT_WEIGHT ) );
     313         387 :     pSet->Put( SvxPostureItem( ITALIC_NORMAL, ATTR_FONT_POSTURE ) );
     314         387 :     pSet->Put( SvxHorJustifyItem( SVX_HOR_JUSTIFY_CENTER, ATTR_HOR_JUSTIFY ) );
     315             : 
     316             : 
     317             :     // 5. Ueberschrift1
     318             : 
     319             : 
     320         387 :     pSheet = (ScStyleSheet*) &Make( SCSTR( STR_STYLENAME_HEADLINE1 ),
     321             :                                     SFX_STYLE_FAMILY_PARA,
     322         774 :                                     SCSTYLEBIT_STANDARD );
     323             : 
     324         387 :     pSheet->SetParent( SCSTR( STR_STYLENAME_HEADLINE ) );
     325         387 :     pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_CELL_UEB1 );
     326         387 :     pSet = &pSheet->GetItemSet();
     327         387 :     pSet->Put( SfxInt32Item( ATTR_ROTATE_VALUE, 9000 ) );
     328             : 
     329             : 
     330             :     // Seitenformat-Vorlagen:
     331             : 
     332             :     // 1. Standard
     333             : 
     334             : 
     335             :     pSheet = (ScStyleSheet*) &Make( aStrStandard,
     336             :                                     SFX_STYLE_FAMILY_PAGE,
     337         387 :                                     SCSTYLEBIT_STANDARD );
     338             : 
     339         387 :     pSet = &pSheet->GetItemSet();
     340         387 :     pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_PAGE_STD );
     341             : 
     342             :     // Abstand der Kopf-/Fusszeilen von der Tabelle
     343         387 :     pHFSetItem = new SvxSetItem( ((SvxSetItem&)pSet->Get( ATTR_PAGE_HEADERSET ) ) );
     344         387 :     pSet->Put( *pHFSetItem, ATTR_PAGE_HEADERSET );
     345         387 :     pSet->Put( *pHFSetItem, ATTR_PAGE_FOOTERSET );
     346         387 :     DELETEZ( pHFSetItem );
     347             : 
     348             : 
     349             :     // Kopfzeile:
     350             :     // [leer][\TABELLE\][leer]
     351             : 
     352         387 :     pEdEngine->SetText(EMPTY_OUSTRING);
     353         387 :     pEdEngine->QuickInsertField( SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD), ESelection() );
     354         387 :     pTxtObj = pEdEngine->CreateTextObject();
     355         387 :     pHeaderItem->SetLeftArea  ( *pEmptyTxtObj );
     356         387 :     pHeaderItem->SetCenterArea( *pTxtObj );
     357         387 :     pHeaderItem->SetRightArea ( *pEmptyTxtObj );
     358         387 :     pSet->Put( *pHeaderItem );
     359         387 :     DELETEZ( pTxtObj );
     360             : 
     361             : 
     362             :     // Fusszeile:
     363             :     // [leer][Seite \SEITE\][leer]
     364             : 
     365         387 :     aStr = SCSTR( STR_PAGE ) + " ";
     366         387 :     pEdEngine->SetText( aStr );
     367         387 :     nStrLen = aStr.getLength();
     368         387 :     pEdEngine->QuickInsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), ESelection(0,nStrLen,0,nStrLen) );
     369         387 :     pTxtObj = pEdEngine->CreateTextObject();
     370         387 :     pFooterItem->SetLeftArea  ( *pEmptyTxtObj );
     371         387 :     pFooterItem->SetCenterArea( *pTxtObj );
     372         387 :     pFooterItem->SetRightArea ( *pEmptyTxtObj );
     373         387 :     pSet->Put( *pFooterItem );
     374         387 :     DELETEZ( pTxtObj );
     375             : 
     376             : 
     377             :     // 2. Report
     378             : 
     379             : 
     380         387 :     pSheet = (ScStyleSheet*) &Make( SCSTR( STR_STYLENAME_REPORT ),
     381             :                                     SFX_STYLE_FAMILY_PAGE,
     382         774 :                                     SCSTYLEBIT_STANDARD );
     383         387 :     pSet = &pSheet->GetItemSet();
     384         387 :     pSheet->SetHelpId( aHelpFile, HID_SC_SHEET_PAGE_REP );
     385             : 
     386             :     // Hintergrund und Umrandung
     387         387 :     aBoxItem.SetLine( &aBorderLine, BOX_LINE_TOP );
     388         387 :     aBoxItem.SetLine( &aBorderLine, BOX_LINE_BOTTOM );
     389         387 :     aBoxItem.SetLine( &aBorderLine, BOX_LINE_LEFT );
     390         387 :     aBoxItem.SetLine( &aBorderLine, BOX_LINE_RIGHT );
     391         387 :     aBoxItem.SetDistance( 10 ); // 0.2mm
     392         387 :     aBoxInfoItem.SetValid( VALID_TOP, true );
     393         387 :     aBoxInfoItem.SetValid( VALID_BOTTOM, true );
     394         387 :     aBoxInfoItem.SetValid( VALID_LEFT, true );
     395         387 :     aBoxInfoItem.SetValid( VALID_RIGHT, true );
     396         387 :     aBoxInfoItem.SetValid( VALID_DISTANCE, true );
     397         387 :     aBoxInfoItem.SetTable( false );
     398         387 :     aBoxInfoItem.SetDist ( true );
     399             : 
     400         387 :     pHFSetItem = new SvxSetItem( ((SvxSetItem&)pSet->Get( ATTR_PAGE_HEADERSET ) ) );
     401         387 :     pHFSet = &(pHFSetItem->GetItemSet());
     402             : 
     403         387 :     pHFSet->Put( SvxBrushItem( aColGrey, ATTR_BACKGROUND ) );
     404         387 :     pHFSet->Put( aBoxItem );
     405         387 :     pHFSet->Put( aBoxInfoItem );
     406         387 :     pSet->Put( *pHFSetItem, ATTR_PAGE_HEADERSET );
     407         387 :     pSet->Put( *pHFSetItem, ATTR_PAGE_FOOTERSET );
     408         387 :     DELETEZ( pHFSetItem );
     409             : 
     410             : 
     411             :     // Kopfzeile:
     412             :     // [\TABELLE\ (\DATEI\)][leer][\DATUM\, \ZEIT\]
     413             : 
     414         387 :     aStr = " ()";
     415         387 :     pEdEngine->SetText( aStr );
     416         387 :     pEdEngine->QuickInsertField( SvxFieldItem(SvxFileField(), EE_FEATURE_FIELD), ESelection(0,2,0,2) );
     417         387 :     pEdEngine->QuickInsertField( SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD), ESelection() );
     418         387 :     pTxtObj = pEdEngine->CreateTextObject();
     419         387 :     pHeaderItem->SetLeftArea( *pTxtObj );
     420         387 :     pHeaderItem->SetCenterArea( *pEmptyTxtObj );
     421         387 :     DELETEZ( pTxtObj );
     422         387 :     aStr = ", ";
     423         387 :     pEdEngine->SetText( aStr );
     424         387 :     pEdEngine->QuickInsertField( SvxFieldItem(SvxTimeField(), EE_FEATURE_FIELD), ESelection(0,2,0,2) );
     425             :     pEdEngine->QuickInsertField( SvxFieldItem(SvxDateField(Date( Date::SYSTEM ),SVXDATETYPE_VAR), EE_FEATURE_FIELD),
     426         387 :                                     ESelection() );
     427         387 :     pTxtObj = pEdEngine->CreateTextObject();
     428         387 :     pHeaderItem->SetRightArea( *pTxtObj );
     429         387 :     DELETEZ( pTxtObj );
     430         387 :     pSet->Put( *pHeaderItem );
     431             : 
     432             : 
     433             :     // Fusszeile:
     434             :     // [leer][Seite: \SEITE\ / \SEITEN\][leer]
     435             : 
     436         387 :     aStr = SCSTR( STR_PAGE ) + " ";
     437         387 :     nStrLen = aStr.getLength();
     438         387 :     aStr += " / ";
     439         387 :     sal_Int32 nStrLen2 = aStr.getLength();
     440         387 :     pEdEngine->SetText( aStr );
     441         387 :     pEdEngine->QuickInsertField( SvxFieldItem(SvxPagesField(), EE_FEATURE_FIELD), ESelection(0,nStrLen2,0,nStrLen2) );
     442         387 :     pEdEngine->QuickInsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), ESelection(0,nStrLen,0,nStrLen) );
     443         387 :     pTxtObj = pEdEngine->CreateTextObject();
     444         387 :     pFooterItem->SetLeftArea  ( *pEmptyTxtObj );
     445         387 :     pFooterItem->SetCenterArea( *pTxtObj );
     446         387 :     pFooterItem->SetRightArea ( *pEmptyTxtObj );
     447         387 :     pSet->Put( *pFooterItem );
     448         387 :     DELETEZ( pTxtObj );
     449             : 
     450             : 
     451         387 :     DELETEZ( pEmptyTxtObj );
     452         387 :     DELETEZ( pHeaderItem );
     453         387 :     DELETEZ( pFooterItem );
     454         774 :     DELETEZ( pEdEngine );
     455         387 : }
     456             : 
     457             : namespace {
     458             : 
     459           0 : struct CaseInsensitiveNamePredicate : svl::StyleSheetPredicate
     460             : {
     461           0 :     CaseInsensitiveNamePredicate(const rtl::OUString& rName, SfxStyleFamily eFam)
     462           0 :     : mFamily(eFam)
     463             :     {
     464           0 :         mUppercaseName = ScGlobal::pCharClass->uppercase(rName);
     465           0 :     }
     466             : 
     467             :     bool
     468           0 :     Check(const SfxStyleSheetBase& rStyleSheet) SAL_OVERRIDE
     469             :     {
     470           0 :         if (rStyleSheet.GetFamily() == mFamily)
     471             :         {
     472           0 :             rtl::OUString aUpName = ScGlobal::pCharClass->uppercase(rStyleSheet.GetName());
     473           0 :             if (mUppercaseName == aUpName)
     474             :             {
     475           0 :                 return true;
     476           0 :             }
     477             :         }
     478           0 :         return false;
     479             :     }
     480             : 
     481             :     rtl::OUString mUppercaseName;
     482             :     SfxStyleFamily mFamily;
     483             : };
     484             : 
     485             : }
     486             : 
     487             : // Functor object to find all style sheets of a family which match a given name caseinsensitively
     488           0 : ScStyleSheet* ScStyleSheetPool::FindCaseIns( const OUString& rName, SfxStyleFamily eFam )
     489             : {
     490           0 :     CaseInsensitiveNamePredicate aPredicate(rName, eFam);
     491           0 :     std::vector<unsigned> aFoundPositions = GetIndexedStyleSheets().FindPositionsByPredicate(aPredicate);
     492           0 :     std::vector<unsigned>::const_iterator it = aFoundPositions.begin();
     493             : 
     494           0 :     for (/**/;it != aFoundPositions.end(); ++it)
     495             :     {
     496           0 :         SfxStyleSheetBase *pFound = GetStyleSheetByPositionInIndex(*it).get();
     497           0 :         ScStyleSheet* pSheet = NULL;
     498             :         // we do not know what kind of sheets we have.
     499           0 :         pSheet = dynamic_cast<ScStyleSheet*>(pFound);
     500           0 :         if (pSheet != NULL)
     501             :         {
     502           0 :             return pSheet;
     503             :         }
     504             :     }
     505           0 :     return NULL;
     506             : }
     507             : 
     508             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10