LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sd/source/ui/func - futempl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 301 0.3 %
Date: 2013-07-09 Functions: 2 12 16.7 %
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 <com/sun/star/style/XStyleFamiliesSupplier.hpp>
      21             : #include <com/sun/star/beans/XPropertySet.hpp>
      22             : #include <com/sun/star/container/XNameAccess.hpp>
      23             : 
      24             : #include "futempl.hxx"
      25             : 
      26             : #include <editeng/editdata.hxx>
      27             : #include <editeng/bulletitem.hxx>
      28             : #include <svx/svxids.hrc>   // fuer SID_OBJECT_SELECT
      29             : #include <sfx2/bindings.hxx>
      30             : #include <svl/aeitem.hxx>
      31             : #include <sfx2/dispatch.hxx>
      32             : #include <vcl/msgbox.hxx>
      33             : #include <editeng/eeitem.hxx>
      34             : #include <sfx2/request.hxx>
      35             : #include <editeng/numitem.hxx>
      36             : #include <editeng/editeng.hxx>
      37             : #include <editeng/lrspitem.hxx>
      38             : #include <svx/svdopage.hxx>
      39             : #include <svx/svditer.hxx>
      40             : #include <svx/sdr/properties/properties.hxx>
      41             : 
      42             : #include <sfx2/viewfrm.hxx>
      43             : #include <svx/xlndsit.hxx>
      44             : #include <svx/xlnstit.hxx>
      45             : #include <svx/xlnedit.hxx>
      46             : #include "app.hrc"
      47             : #include "stlsheet.hxx"
      48             : #include "sdpage.hxx"
      49             : #include "stlpool.hxx"
      50             : #include "sdmod.hxx"
      51             : #include "View.hxx"
      52             : #include "Window.hxx"
      53             : #include "drawview.hxx"
      54             : #include "drawdoc.hxx"
      55             : #include "DrawDocShell.hxx"
      56             : #include "DrawViewShell.hxx"
      57             : #include "ViewShell.hxx"
      58             : #include "res_bmp.hrc"
      59             : #include "glob.hrc"
      60             : #include "prlayout.hxx"         // enum PresentationObjects
      61             : #include "prltempl.hrc"         // TAB_PRES_LAYOUT_TEMPLATE_x
      62             : #include <svx/xfillit.hxx>
      63             : #include "sdresid.hxx"
      64             : #include "OutlineViewShell.hxx"
      65             : #include "strings.hrc"
      66             : #include "helpids.h"
      67             : #include "sdabstdlg.hxx"
      68             : 
      69             : using namespace com::sun::star::uno;
      70             : using namespace com::sun::star::container;
      71             : using namespace com::sun::star::beans;
      72             : using namespace com::sun::star::style;
      73             : 
      74             : namespace sd
      75             : {
      76             : 
      77           0 : TYPEINIT1( FuTemplate, FuPoor );
      78             : 
      79           0 : FuTemplate::FuTemplate (
      80             :     ViewShell* pViewSh,
      81             :     ::sd::Window* pWin,
      82             :     ::sd::View* pView,
      83             :     SdDrawDocument* pDoc,
      84             :     SfxRequest& rReq )
      85           0 :     : FuPoor( pViewSh, pWin, pView, pDoc, rReq )
      86             : {
      87           0 : }
      88             : 
      89           0 : FunctionReference FuTemplate::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
      90             : {
      91           0 :     FunctionReference xFunc( new FuTemplate( pViewSh, pWin, pView, pDoc, rReq ) );
      92           0 :     xFunc->DoExecute(rReq);
      93           0 :     return xFunc;
      94             : }
      95             : 
      96           0 : void FuTemplate::DoExecute( SfxRequest& rReq )
      97             : {
      98           0 :     const SfxItemSet* pArgs = rReq.GetArgs();
      99           0 :     sal_uInt16 nSId = rReq.GetSlot();
     100             : 
     101             :     // get StyleSheet parameter
     102           0 :     SfxStyleSheetBasePool* pSSPool = mpDoc->GetDocSh()->GetStyleSheetPool();
     103           0 :     SfxStyleSheetBase* pStyleSheet = NULL;
     104             : 
     105             :     const SfxPoolItem* pItem;
     106           0 :     sal_uInt16 nFamily = USHRT_MAX;
     107           0 :     if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_FAMILY,
     108           0 :         sal_False, &pItem ))
     109             :     {
     110           0 :         nFamily = ( (const SfxUInt16Item &) pArgs->Get( SID_STYLE_FAMILY ) ).GetValue();
     111             :     }
     112           0 :     else if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_FAMILYNAME,
     113           0 :         sal_False, &pItem ))
     114             :     {
     115           0 :         String sFamily = ( (const SfxStringItem &) pArgs->Get( SID_STYLE_FAMILYNAME ) ).GetValue();
     116           0 :         if (sFamily.CompareToAscii("graphics") == COMPARE_EQUAL)
     117           0 :             nFamily = SD_STYLE_FAMILY_GRAPHICS;
     118             :         else
     119           0 :             nFamily = SD_STYLE_FAMILY_PSEUDO;
     120             :     }
     121             : 
     122           0 :     OUString aStyleName;
     123           0 :     sal_uInt16 nRetMask = SFXSTYLEBIT_ALL;
     124             : 
     125           0 :     switch( nSId )
     126             :     {
     127             :         case SID_STYLE_APPLY:
     128             :         case SID_STYLE_EDIT:
     129             :         case SID_STYLE_DELETE:
     130             :         case SID_STYLE_HIDE:
     131             :         case SID_STYLE_SHOW:
     132             :         case SID_STYLE_FAMILY:
     133             :         case SID_STYLE_NEW_BY_EXAMPLE:
     134             :         {
     135           0 :             SFX_REQUEST_ARG( rReq, pNameItem, SfxStringItem, SID_APPLY_STYLE, sal_False );
     136           0 :             SFX_REQUEST_ARG( rReq, pFamilyItem, SfxStringItem, SID_STYLE_FAMILYNAME, sal_False );
     137           0 :             if ( pFamilyItem && pNameItem )
     138             :             {
     139             :                 try
     140             :                 {
     141           0 :                     Reference< XStyleFamiliesSupplier > xModel(mpDoc->GetDocSh()->GetModel(), UNO_QUERY_THROW );
     142           0 :                     Reference< XNameAccess > xCont( xModel->getStyleFamilies() );
     143           0 :                     Reference< XNameAccess > xStyles( xCont->getByName(pFamilyItem->GetValue()), UNO_QUERY_THROW );
     144           0 :                     Reference< XPropertySet > xInfo( xStyles->getByName( pNameItem->GetValue() ), UNO_QUERY_THROW );
     145             : 
     146           0 :                     OUString aUIName;
     147           0 :                     xInfo->getPropertyValue( "DisplayName" ) >>= aUIName;
     148           0 :                     if ( !aUIName.isEmpty() )
     149           0 :                         rReq.AppendItem( SfxStringItem( nSId, aUIName ) );
     150             :                 }
     151           0 :                 catch( Exception& )
     152             :                 {
     153             :                 }
     154             :             }
     155             : 
     156           0 :             if (pArgs->GetItemState(nSId) == SFX_ITEM_SET)
     157           0 :                 aStyleName = ( ( (const SfxStringItem &) pArgs->Get( nSId ) ).GetValue() );
     158             :         }
     159             :     }
     160             : 
     161           0 :     switch( nSId )
     162             :     {
     163             :         case SID_STYLE_NEW:
     164             :         {
     165           0 :             SfxStyleSheetBase *p = pSSPool->Find(aStyleName, (SfxStyleFamily) nFamily, SFXSTYLEBIT_ALL );
     166           0 :             if(p)
     167             :             {
     168           0 :                 pSSPool->Remove(p);
     169           0 :                 p = 0;
     170             :             }
     171           0 :             pStyleSheet = &pSSPool->Make( aStyleName, (SfxStyleFamily) nFamily, SFXSTYLEBIT_USERDEF );
     172             : 
     173           0 :             if (pArgs->GetItemState(SID_STYLE_REFERENCE) == SFX_ITEM_ON)
     174             :             {
     175           0 :                 String aParentName(((const SfxStringItem&) pArgs->Get(SID_STYLE_REFERENCE)).GetValue());
     176           0 :                 pStyleSheet->SetParent(aParentName);
     177             :             }
     178             :             else
     179             :             {
     180           0 :                 pStyleSheet->SetParent(String(SdResId(STR_STANDARD_STYLESHEET_NAME)));
     181             :             }
     182             :         }
     183           0 :         break;
     184             : 
     185             :         case SID_STYLE_NEW_BY_EXAMPLE:
     186             :         {
     187             :             // at the moment, the dialog to enter the name of the template is still opened
     188           0 :             mpView->AreObjectsMarked();
     189           0 :                 SfxStyleSheetBase *p = pSSPool->Find(aStyleName, (SfxStyleFamily) nFamily, SFXSTYLEBIT_ALL );
     190           0 :                 if(p)
     191             :                 {
     192           0 :                     pSSPool->Remove(p);
     193           0 :                     p = 0;
     194             :                 }
     195           0 :                 pStyleSheet = &pSSPool->Make( aStyleName, (SfxStyleFamily) nFamily, SFXSTYLEBIT_USERDEF );
     196           0 :                 pStyleSheet->SetParent(String(SdResId(STR_STANDARD_STYLESHEET_NAME)));
     197             :         }
     198           0 :         break;
     199             : 
     200             :         case SID_STYLE_EDIT:
     201           0 :             pStyleSheet = pSSPool->Find( aStyleName, (SfxStyleFamily) nFamily);
     202           0 :         break;
     203             : 
     204             :         case SID_STYLE_DELETE:
     205           0 :             pStyleSheet = pSSPool->Find( aStyleName, (SfxStyleFamily) nFamily);
     206           0 :             if( pStyleSheet )
     207             :             {
     208           0 :                 pSSPool->Remove( pStyleSheet );
     209           0 :                 nRetMask = sal_True;
     210           0 :                 mpDoc->SetChanged(sal_True);
     211             :             }
     212             :             else
     213             :             {
     214           0 :                 nRetMask = sal_False;
     215             :             }
     216           0 :         break;
     217             : 
     218             :         case SID_STYLE_HIDE:
     219             :         case SID_STYLE_SHOW:
     220           0 :             pStyleSheet = pSSPool->Find( aStyleName, (SfxStyleFamily) nFamily);
     221           0 :             pStyleSheet->SetHidden( nSId == SID_STYLE_HIDE );
     222           0 :             nRetMask = sal_True;
     223           0 :         break;
     224             : 
     225             :         case SID_STYLE_APPLY:
     226             :             // apply the template to the document
     227           0 :             pStyleSheet = pSSPool->Find( aStyleName, (SfxStyleFamily) nFamily);
     228             : 
     229             :             // do not set presentation styles, they will be set implicit
     230           0 :             if ( pStyleSheet && pStyleSheet->GetFamily() != SD_STYLE_FAMILY_PSEUDO )
     231             :             {
     232           0 :                 SfxStyleSheet* pOldStyleSheet = mpView->GetStyleSheet();
     233           0 :                 OUString aStr;
     234             : 
     235           0 :                 if( // if the object had no style sheet, allow all
     236           0 :                     !pOldStyleSheet ||
     237             : 
     238             :                     // allow if old and new style sheet has same family
     239           0 :                     pStyleSheet->GetFamily() == pOldStyleSheet->GetFamily() ||
     240             : 
     241             :                     // allow if old was background objects and new is graphics
     242           0 :                     pStyleSheet->GetFamily() == (SD_STYLE_FAMILY_GRAPHICS && pOldStyleSheet->GetHelpId( aStr ) == HID_PSEUDOSHEET_BACKGROUNDOBJECTS) ||
     243             : 
     244             :                     // allow if old was presentation and we are a drawing document
     245           0 :                     (pOldStyleSheet->GetFamily() == SD_STYLE_FAMILY_MASTERPAGE && mpDoc->GetDocumentType() == DOCUMENT_TYPE_DRAW) )
     246             :                 {
     247           0 :                     mpView->SetStyleSheet( (SfxStyleSheet*) pStyleSheet);
     248           0 :                     mpDoc->SetChanged(sal_True);
     249           0 :                     mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_STYLE_FAMILY2 );
     250           0 :                 }
     251             :             }
     252           0 :         break;
     253             : 
     254             :         case SID_STYLE_WATERCAN:
     255             :         {
     256           0 :             if( !SD_MOD()->GetWaterCan() )
     257             :             {
     258           0 :                 if( pArgs->GetItemState( nSId ) == SFX_ITEM_SET )
     259             :                 {
     260           0 :                     aStyleName = ( ( (const SfxStringItem &) pArgs->Get( nSId ) ).GetValue() );
     261           0 :                     SD_MOD()->SetWaterCan( sal_True );
     262           0 :                     pStyleSheet = pSSPool->Find( aStyleName, (SfxStyleFamily) nFamily);
     263             :                 }
     264             :                 // no presentation object templates, they are only allowed implicitly
     265           0 :                 if( pStyleSheet && pStyleSheet->GetFamily() != SD_STYLE_FAMILY_PSEUDO )
     266             :                 {
     267           0 :                     ( (SdStyleSheetPool*) pSSPool )->SetActualStyleSheet( pStyleSheet );
     268             : 
     269             :                     // we switch explicitly into selection mode
     270             :                     mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_OBJECT_SELECT,
     271           0 :                                         SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
     272             : 
     273             :                 }
     274             :                 else
     275           0 :                     SD_MOD()->SetWaterCan( sal_False );
     276             :             }
     277             :             else
     278             :             {
     279           0 :                 SD_MOD()->SetWaterCan( sal_False );
     280             :                 // we have to re-enable to tools-bar
     281           0 :                 mpViewShell->Invalidate();
     282             :             }
     283             :         }
     284           0 :         break;
     285             : 
     286             :         default:
     287           0 :         break;
     288             :     }
     289             : 
     290           0 :     switch( nSId )
     291             :     {
     292             :         case SID_STYLE_NEW:
     293             :         case SID_STYLE_EDIT:
     294             :         {
     295           0 :             PresentationObjects ePO = PO_OUTLINE_1;
     296             : 
     297           0 :             if( pStyleSheet )
     298             :             {
     299           0 :                 SfxAbstractTabDialog*  pStdDlg  = NULL;
     300           0 :                 SfxAbstractTabDialog*  pPresDlg = NULL;
     301           0 :                 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
     302           0 :                 sal_Bool bOldDocInOtherLanguage = sal_False;
     303           0 :                 SfxItemSet aOriSet( pStyleSheet->GetItemSet() );
     304             : 
     305           0 :                 SfxStyleFamily eFamily = pStyleSheet->GetFamily();
     306             : 
     307           0 :                 if (eFamily == SD_STYLE_FAMILY_GRAPHICS)
     308             :                 {
     309           0 :                     pStdDlg = pFact ? pFact->CreateSdTabTemplateDlg( 0, mpDoc->GetDocSh(), *pStyleSheet, mpDoc, mpView ) : 0;
     310             :                 }
     311           0 :                 else if (eFamily == SD_STYLE_FAMILY_PSEUDO)
     312             :                 {
     313           0 :                     String aName(pStyleSheet->GetName());
     314           0 :                     sal_uInt16 nDlgId = 0;
     315             : 
     316           0 :                     if (aName == String(SdResId(STR_PSEUDOSHEET_TITLE)))
     317             :                     {
     318           0 :                         nDlgId = TAB_PRES_LAYOUT_TEMPLATE;
     319           0 :                         ePO    = PO_TITLE;
     320             :                     }
     321           0 :                     else if (aName == String(SdResId(STR_PSEUDOSHEET_SUBTITLE)))
     322             :                     {
     323           0 :                         nDlgId = TAB_PRES_LAYOUT_TEMPLATE;
     324           0 :                         ePO    = PO_SUBTITLE;
     325             :                     }
     326           0 :                     else if (aName ==
     327             :                              String(SdResId(STR_PSEUDOSHEET_BACKGROUND)))
     328             :                     {
     329           0 :                         nDlgId = TAB_PRES_LAYOUT_TEMPLATE_BACKGROUND;
     330           0 :                         ePO    = PO_BACKGROUND;
     331             :                     }
     332           0 :                     else if (aName ==
     333             :                              String(SdResId(STR_PSEUDOSHEET_BACKGROUNDOBJECTS)))
     334             :                     {
     335           0 :                         nDlgId = TAB_PRES_LAYOUT_TEMPLATE;
     336           0 :                         ePO    = PO_BACKGROUNDOBJECTS;
     337             :                     }
     338           0 :                     else if (aName ==
     339             :                              String(SdResId(STR_PSEUDOSHEET_NOTES)))
     340             :                     {
     341           0 :                         nDlgId = TAB_PRES_LAYOUT_TEMPLATE;
     342           0 :                         ePO    = PO_NOTES;
     343             :                     }
     344           0 :                     else if(aName.Search(String(SdResId(STR_PSEUDOSHEET_OUTLINE))) !=
     345             :                             STRING_NOTFOUND)
     346             :                     {
     347           0 :                         nDlgId = TAB_PRES_LAYOUT_TEMPLATE;
     348             : 
     349           0 :                         String aOutlineStr((SdResId(STR_PSEUDOSHEET_OUTLINE)));
     350             :                         // determine number, mind the blank between name and number
     351           0 :                         String aNumStr(aName.Copy(aOutlineStr.Len() + 1));
     352           0 :                         sal_uInt16 nLevel = (sal_uInt16)aNumStr.ToInt32();
     353           0 :                         switch (nLevel)
     354             :                         {
     355           0 :                             case 1: ePO = PO_OUTLINE_1; break;
     356           0 :                             case 2: ePO = PO_OUTLINE_2; break;
     357           0 :                             case 3: ePO = PO_OUTLINE_3; break;
     358           0 :                             case 4: ePO = PO_OUTLINE_4; break;
     359           0 :                             case 5: ePO = PO_OUTLINE_5; break;
     360           0 :                             case 6: ePO = PO_OUTLINE_6; break;
     361           0 :                             case 7: ePO = PO_OUTLINE_7; break;
     362           0 :                             case 8: ePO = PO_OUTLINE_8; break;
     363           0 :                             case 9: ePO = PO_OUTLINE_9; break;
     364           0 :                         }
     365             :                     }
     366             :                     else
     367             :                     {
     368             :                         OSL_FAIL("StyleSheet from older version with different language");
     369           0 :                         bOldDocInOtherLanguage = sal_True;
     370             :                     }
     371             : 
     372           0 :                     if( !bOldDocInOtherLanguage )
     373             :                     {
     374           0 :                         pPresDlg = pFact ? pFact->CreateSdPresLayoutTemplateDlg( mpDocSh, NULL, SdResId(nDlgId), *pStyleSheet, ePO, pSSPool ) : 0;
     375           0 :                     }
     376             :                 }
     377             :                 else if (eFamily == SD_STYLE_FAMILY_CELL)
     378             :                 {
     379             :                 }
     380             : 
     381           0 :                 sal_uInt16 nResult = RET_CANCEL;
     382           0 :                 const SfxItemSet* pOutSet = NULL;
     383           0 :                 if (pStdDlg)
     384             :                 {
     385           0 :                     nResult = pStdDlg->Execute();
     386           0 :                     pOutSet = pStdDlg->GetOutputItemSet();
     387             :                 }
     388           0 :                 else if( pPresDlg )
     389             :                 {
     390           0 :                     nResult = pPresDlg->Execute();
     391           0 :                     pOutSet = pPresDlg->GetOutputItemSet();
     392             :                 }
     393             : 
     394           0 :                 switch( nResult )
     395             :                 {
     396             :                     case RET_OK:
     397             :                     {
     398           0 :                         nRetMask = pStyleSheet->GetMask();
     399             : 
     400           0 :                         if (eFamily == SD_STYLE_FAMILY_PSEUDO)
     401             :                         {
     402           0 :                             SfxItemSet aTempSet(*pOutSet);
     403           0 :                             ((SdStyleSheet*)pStyleSheet)->AdjustToFontHeight(aTempSet);
     404             : 
     405             :                             /* Special treatment: reset the INVALIDS to
     406             :                                NULL-Pointer (otherwise INVALIDs or pointer point
     407             :                                to DefaultItems in the template; both would
     408             :                                prevent the attribute inheritance) */
     409           0 :                             aTempSet.ClearInvalidItems();
     410             : 
     411             :                             // EE_PARA_NUMBULLET item is only valid in first outline template
     412           0 :                             if( (ePO >= PO_OUTLINE_2) && (ePO <= PO_OUTLINE_9) )
     413             :                             {
     414           0 :                                 if (aTempSet.GetItemState(EE_PARA_NUMBULLET) == SFX_ITEM_SET)
     415             :                                 {
     416           0 :                                     SvxNumRule aRule(*((SvxNumBulletItem*)aTempSet.GetItem(EE_PARA_NUMBULLET))->GetNumRule());
     417             : 
     418           0 :                                     String sStyleName((SdResId(STR_PSEUDOSHEET_OUTLINE)));
     419           0 :                                     sStyleName.AppendAscii( " 1" );
     420           0 :                                     SfxStyleSheetBase* pFirstStyleSheet = pSSPool->Find( sStyleName, SD_STYLE_FAMILY_PSEUDO);
     421             : 
     422           0 :                                     if(pFirstStyleSheet)
     423             :                                     {
     424           0 :                                         pFirstStyleSheet->GetItemSet().Put( SvxNumBulletItem( aRule, EE_PARA_NUMBULLET ));
     425           0 :                                         SdStyleSheet* pRealSheet = ((SdStyleSheet*)pFirstStyleSheet)->GetRealStyleSheet();
     426           0 :                                         pRealSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
     427             :                                     }
     428             : 
     429           0 :                                     aTempSet.ClearItem( EE_PARA_NUMBULLET );
     430             :                                 }
     431             :                             }
     432             : 
     433           0 :                             String sStyleName((SdResId(STR_PSEUDOSHEET_OUTLINE)));
     434           0 :                             sStyleName.Append( sal_Unicode( ' ' ));
     435             : 
     436           0 :                             pStyleSheet->GetItemSet().Put(aTempSet);
     437           0 :                             SdStyleSheet* pRealSheet =((SdStyleSheet*)pStyleSheet)->GetRealStyleSheet();
     438           0 :                             pRealSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
     439             : 
     440           0 :                             if( (ePO >= PO_OUTLINE_1) && (ePO <= PO_OUTLINE_8) )
     441             :                             {
     442           0 :                                 for( sal_uInt16 n = (sal_uInt16)(ePO - PO_OUTLINE_1 + 2); n < 10; n++ )
     443             :                                 {
     444           0 :                                     String aName( sStyleName );
     445           0 :                                     aName.Append( OUString::number( (sal_Int32) n ));
     446             : 
     447           0 :                                     SfxStyleSheetBase* pSheet = pSSPool->Find( aName, SD_STYLE_FAMILY_PSEUDO);
     448             : 
     449           0 :                                     if(pSheet)
     450             :                                     {
     451           0 :                                         SdStyleSheet* pRealStyleSheet = ((SdStyleSheet*)pSheet)->GetRealStyleSheet();
     452           0 :                                         pRealStyleSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
     453             :                                     }
     454           0 :                                 }
     455           0 :                             }
     456             :                         }
     457             : 
     458           0 :                         SfxItemSet& rAttr = pStyleSheet->GetItemSet();
     459             : 
     460           0 :                         sdr::properties::CleanupFillProperties( rAttr );
     461             : 
     462             :                         // check for unique names of named items for xml
     463           0 :                         if( rAttr.GetItemState( XATTR_FILLBITMAP ) == SFX_ITEM_SET )
     464             :                         {
     465           0 :                             const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_FILLBITMAP );
     466           0 :                             SfxPoolItem* pNewItem = ((XFillBitmapItem*)pOldItem)->checkForUniqueItem( mpDoc );
     467           0 :                             if( pOldItem != pNewItem )
     468             :                             {
     469           0 :                                 rAttr.Put( *pNewItem );
     470           0 :                                 delete pNewItem;
     471             :                             }
     472             :                         }
     473           0 :                         if( rAttr.GetItemState( XATTR_LINEDASH ) == SFX_ITEM_SET )
     474             :                         {
     475           0 :                             const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_LINEDASH );
     476           0 :                             SfxPoolItem* pNewItem = ((XLineDashItem*)pOldItem)->checkForUniqueItem( mpDoc );
     477           0 :                             if( pOldItem != pNewItem )
     478             :                             {
     479           0 :                                 rAttr.Put( *pNewItem );
     480           0 :                                 delete pNewItem;
     481             :                             }
     482             :                         }
     483           0 :                         if( rAttr.GetItemState( XATTR_LINESTART ) == SFX_ITEM_SET )
     484             :                         {
     485           0 :                             const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_LINESTART );
     486           0 :                             SfxPoolItem* pNewItem = ((XLineStartItem*)pOldItem)->checkForUniqueItem( mpDoc );
     487           0 :                             if( pOldItem != pNewItem )
     488             :                             {
     489           0 :                                 rAttr.Put( *pNewItem );
     490           0 :                                 delete pNewItem;
     491             :                             }
     492             :                         }
     493           0 :                         if( rAttr.GetItemState( XATTR_LINEEND ) == SFX_ITEM_SET )
     494             :                         {
     495           0 :                             const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_LINEEND );
     496           0 :                             SfxPoolItem* pNewItem = ((XLineEndItem*)pOldItem)->checkForUniqueItem( mpDoc );
     497           0 :                             if( pOldItem != pNewItem )
     498             :                             {
     499           0 :                                 rAttr.Put( *pNewItem );
     500           0 :                                 delete pNewItem;
     501             :                             }
     502             :                         }
     503           0 :                         if( rAttr.GetItemState( XATTR_FILLGRADIENT ) == SFX_ITEM_SET )
     504             :                         {
     505           0 :                             const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_FILLGRADIENT );
     506           0 :                             SfxPoolItem* pNewItem = ((XFillGradientItem*)pOldItem)->checkForUniqueItem( mpDoc );
     507           0 :                             if( pOldItem != pNewItem )
     508             :                             {
     509           0 :                                 rAttr.Put( *pNewItem );
     510           0 :                                 delete pNewItem;
     511             :                             }
     512             :                         }
     513           0 :                         if( rAttr.GetItemState( XATTR_FILLFLOATTRANSPARENCE ) == SFX_ITEM_SET )
     514             :                         {
     515           0 :                             const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_FILLFLOATTRANSPARENCE );
     516           0 :                             SfxPoolItem* pNewItem = ((XFillFloatTransparenceItem*)pOldItem)->checkForUniqueItem( mpDoc );
     517           0 :                             if( pOldItem != pNewItem )
     518             :                             {
     519           0 :                                 rAttr.Put( *pNewItem );
     520           0 :                                 delete pNewItem;
     521             :                             }
     522             :                         }
     523           0 :                         if( rAttr.GetItemState( XATTR_FILLHATCH ) == SFX_ITEM_SET )
     524             :                         {
     525           0 :                             const SfxPoolItem* pOldItem = rAttr.GetItem( XATTR_FILLHATCH );
     526           0 :                             SfxPoolItem* pNewItem = ((XFillHatchItem*)pOldItem)->checkForUniqueItem( mpDoc );
     527           0 :                             if( pOldItem != pNewItem )
     528             :                             {
     529           0 :                                 rAttr.Put( *pNewItem );
     530           0 :                                 delete pNewItem;
     531             :                             }
     532             :                         }
     533             : 
     534           0 :                         ( (SfxStyleSheet*) pStyleSheet )->Broadcast( SfxSimpleHint( SFX_HINT_DATACHANGED ) );
     535             : 
     536           0 :                         DrawViewShell* pDrawViewShell = dynamic_cast< DrawViewShell* >( mpViewShell );
     537           0 :                         if( pDrawViewShell )
     538             :                         {
     539           0 :                             PageKind ePageKind = pDrawViewShell->GetPageKind();
     540           0 :                             if( ePageKind == PK_NOTES || ePageKind == PK_HANDOUT )
     541             :                             {
     542           0 :                                 SdPage* pPage = mpViewShell->GetActualPage();
     543             : 
     544           0 :                                 if(pDrawViewShell->GetEditMode() == EM_MASTERPAGE)
     545             :                                 {
     546           0 :                                     pPage = static_cast<SdPage*>((&(pPage->TRG_GetMasterPage())));
     547             :                                 }
     548             : 
     549           0 :                                 if( pPage )
     550             :                                 {
     551           0 :                                     SdrObjListIter aIter( *pPage );
     552           0 :                                     while( aIter.IsMore() )
     553             :                                     {
     554           0 :                                         SdrObject* pObj = aIter.Next();
     555           0 :                                         if( pObj->ISA(SdrPageObj) )
     556             :                                         {
     557             :                                             // repaint only
     558           0 :                                             pObj->ActionChanged();
     559             :                                             // pObj->SendRepaintBroadcast();
     560             :                                         }
     561           0 :                                     }
     562             :                                 }
     563             :                             }
     564             :                         }
     565             : 
     566           0 :                         if( mpDoc->GetOnlineSpell() )
     567             :                         {
     568             :                             const SfxPoolItem* pTempItem;
     569           0 :                             if( SFX_ITEM_SET == rAttr.GetItemState(EE_CHAR_LANGUAGE, sal_False, &pTempItem ) ||
     570           0 :                                 SFX_ITEM_SET == rAttr.GetItemState(EE_CHAR_LANGUAGE_CJK, sal_False, &pTempItem ) ||
     571           0 :                                 SFX_ITEM_SET == rAttr.GetItemState(EE_CHAR_LANGUAGE_CTL, sal_False, &pTempItem ) )
     572             :                             {
     573           0 :                                 mpDoc->StopOnlineSpelling();
     574           0 :                                 mpDoc->StartOnlineSpelling();
     575             :                             }
     576             :                         }
     577             : 
     578           0 :                         mpDoc->SetChanged(sal_True);
     579             :                     }
     580           0 :                     break;
     581             : 
     582             :                     default:
     583             :                     {
     584           0 :                         if( nSId == SID_STYLE_NEW )
     585           0 :                             pSSPool->Remove( pStyleSheet );
     586           0 :                         delete pStdDlg;
     587           0 :                         delete pPresDlg;
     588             :                     }
     589           0 :                     return; // Cancel
     590             :                 }
     591           0 :                 delete pStdDlg;
     592           0 :                 delete pPresDlg;
     593             :             }
     594             :         }
     595           0 :         break;
     596             : 
     597             :         case SID_STYLE_NEW_BY_EXAMPLE:
     598             :         {
     599           0 :             if( pStyleSheet )
     600             :             {
     601           0 :                 nRetMask = pStyleSheet->GetMask();
     602           0 :                 SfxItemSet aCoreSet( mpDoc->GetPool() );
     603           0 :                 mpView->GetAttributes( aCoreSet, sal_True );
     604             : 
     605             :                 // if the object had a template, this becomes parent of the new template
     606           0 :                 SfxStyleSheet* pOldStyle = mpView->GetStyleSheet();
     607             : 
     608             :                 // if pOldStyle == pStyleSheet -> recursion
     609           0 :                 if( pOldStyle != pStyleSheet )
     610             :                 {
     611           0 :                     if (pOldStyle)
     612             :                     {
     613           0 :                         pStyleSheet->SetParent(pOldStyle->GetName());
     614             :                     }
     615             : 
     616           0 :                     SfxItemSet* pStyleSet = &pStyleSheet->GetItemSet();
     617           0 :                     pStyleSet->Put(aCoreSet);
     618             : 
     619             :                     /* apply template (but not when somebody is editing a text.
     620             :                        To do this, the edit engine had to be capable to use
     621             :                        templates on a character level. */
     622           0 :                     if (!mpView->GetTextEditObject())
     623             :                     {
     624           0 :                         mpView->SetStyleSheet( (SfxStyleSheet*) pStyleSheet);
     625             :                     }
     626             : 
     627           0 :                     ( (SfxStyleSheet*) pStyleSheet )->Broadcast( SfxSimpleHint( SFX_HINT_DATACHANGED ) );
     628           0 :                     mpDoc->SetChanged(sal_True);
     629             : 
     630           0 :                     mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_STYLE_FAMILY2 );
     631           0 :                 }
     632             :             }
     633             :         }
     634           0 :         break;
     635             : 
     636             :         case SID_STYLE_UPDATE_BY_EXAMPLE:
     637             :         {
     638           0 :             if ((mpView->AreObjectsMarked() && mpView->GetMarkedObjectList().GetMarkCount() == 1) ||
     639           0 :                  mpView->ISA(OutlineView))
     640             :             {
     641           0 :                 pStyleSheet = mpView->GetStyleSheet();
     642             : 
     643           0 :                 if( pStyleSheet )
     644             :                 {
     645           0 :                     nRetMask = pStyleSheet->GetMask();
     646           0 :                     SfxItemSet aCoreSet( mpDoc->GetPool() );
     647           0 :                     mpView->GetAttributes( aCoreSet );
     648             : 
     649           0 :                     SfxItemSet* pStyleSet = &pStyleSheet->GetItemSet();
     650           0 :                     pStyleSet->Put( aCoreSet );
     651             : 
     652           0 :                     mpView->SetStyleSheet( (SfxStyleSheet*) pStyleSheet);
     653             : 
     654           0 :                     ( (SfxStyleSheet*) pStyleSheet )->Broadcast( SfxSimpleHint( SFX_HINT_DATACHANGED ) );
     655           0 :                     mpDoc->SetChanged(sal_True);
     656           0 :                     mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_STYLE_FAMILY2 );
     657             :                 }
     658             :             }
     659             :         }
     660           0 :         break;
     661             : 
     662             :     }
     663           0 :     if( nRetMask != SFXSTYLEBIT_ALL )
     664           0 :         rReq.SetReturnValue( SfxUInt16Item( nSId, nRetMask ) );
     665             : }
     666             : 
     667           0 : void FuTemplate::Activate()
     668             : {
     669           0 : }
     670             : 
     671           0 : void FuTemplate::Deactivate()
     672             : {
     673           0 : }
     674             : 
     675          33 : } // end of namespace sd
     676             : 
     677             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10