LCOV - code coverage report
Current view: top level - sd/source/ui/dlg - unchss.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 54 1.9 %
Date: 2014-11-03 Functions: 2 13 15.4 %
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 <svl/itemset.hxx>
      21             : #include <svl/style.hxx>
      22             : #include <svl/smplhint.hxx>
      23             : #include <svx/svdobj.hxx>
      24             : 
      25             : #include "unchss.hxx"
      26             : 
      27             : #include "strings.hrc"
      28             : #include "glob.hxx"
      29             : #include "sdresid.hxx"
      30             : #include "drawdoc.hxx"
      31             : #include "stlsheet.hxx"
      32             : #include "glob.hrc"
      33             : 
      34           0 : TYPEINIT1(StyleSheetUndoAction, SdUndoAction);
      35             : 
      36           0 : StyleSheetUndoAction::StyleSheetUndoAction(SdDrawDocument* pTheDoc,
      37             :                                            SfxStyleSheet* pTheStyleSheet,
      38             :                                            const SfxItemSet* pTheNewItemSet) :
      39           0 :                       SdUndoAction(pTheDoc)
      40             : {
      41             :     DBG_ASSERT(pTheStyleSheet, "Undo without StyleSheet ???");
      42           0 :     pStyleSheet = pTheStyleSheet;
      43             : 
      44             :     // Create ItemSets; Attention, it is possible that the new one is from a,
      45             :     // different pool. Therefore we clone it with its items.
      46           0 :     pNewSet = new SfxItemSet((SfxItemPool&)SdrObject::GetGlobalDrawObjectItemPool(), pTheNewItemSet->GetRanges());
      47           0 :     SdrModel::MigrateItemSet( pTheNewItemSet, pNewSet, pTheDoc );
      48             : 
      49           0 :     pOldSet = new SfxItemSet((SfxItemPool&)SdrObject::GetGlobalDrawObjectItemPool(),pStyleSheet->GetItemSet().GetRanges());
      50           0 :     SdrModel::MigrateItemSet( &pStyleSheet->GetItemSet(), pOldSet, pTheDoc );
      51             : 
      52           0 :     aComment = SD_RESSTR(STR_UNDO_CHANGE_PRES_OBJECT);
      53           0 :     OUString aName(pStyleSheet->GetName());
      54             : 
      55             :     // delete layout name and separator
      56           0 :     sal_Int32 nPos = aName.indexOf(SD_LT_SEPARATOR);
      57           0 :     if (nPos != -1)
      58           0 :         aName = aName.copy(nPos + strlen(SD_LT_SEPARATOR));
      59             : 
      60           0 :     if (aName == SD_RESSTR(STR_LAYOUT_TITLE))
      61             :     {
      62           0 :         aName = SD_RESSTR(STR_PSEUDOSHEET_TITLE);
      63             :     }
      64           0 :     else if (aName == SD_RESSTR(STR_LAYOUT_SUBTITLE))
      65             :     {
      66           0 :         aName = SD_RESSTR(STR_PSEUDOSHEET_SUBTITLE);
      67             :     }
      68           0 :     else if (aName == SD_RESSTR(STR_LAYOUT_BACKGROUND))
      69             :     {
      70           0 :         aName = SD_RESSTR(STR_PSEUDOSHEET_BACKGROUND);
      71             :     }
      72           0 :     else if (aName == SD_RESSTR(STR_LAYOUT_BACKGROUNDOBJECTS))
      73             :     {
      74           0 :         aName = SD_RESSTR(STR_PSEUDOSHEET_BACKGROUNDOBJECTS);
      75             :     }
      76           0 :     else if (aName == SD_RESSTR(STR_LAYOUT_NOTES))
      77             :     {
      78           0 :         aName = SD_RESSTR(STR_PSEUDOSHEET_NOTES);
      79             :     }
      80             :     else
      81             :     {
      82           0 :         OUString aOutlineStr(SD_RESSTR(STR_PSEUDOSHEET_OUTLINE));
      83           0 :         nPos = aName.indexOf(aOutlineStr);
      84           0 :         if (nPos != -1)
      85             :         {
      86           0 :             OUString aNumStr(aName.copy(aOutlineStr.getLength()));
      87           0 :             aName = SD_RESSTR(STR_LAYOUT_OUTLINE) + aNumStr;
      88           0 :         }
      89             :     }
      90             : 
      91             :     // replace placeholder with template name
      92           0 :     aComment = aComment.replaceFirst("$", aName);
      93           0 : }
      94             : 
      95           0 : void StyleSheetUndoAction::Undo()
      96             : {
      97           0 :     SfxItemSet aNewSet( mpDoc->GetItemPool(), pOldSet->GetRanges() );
      98           0 :     SdrModel::MigrateItemSet( pOldSet, &aNewSet, mpDoc );
      99             : 
     100           0 :     pStyleSheet->GetItemSet().Set(aNewSet);
     101           0 :     if( pStyleSheet->GetFamily() == SD_STYLE_FAMILY_PSEUDO )
     102           0 :         ( (SdStyleSheet*)pStyleSheet )->GetRealStyleSheet()->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
     103             :     else
     104           0 :         pStyleSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
     105           0 : }
     106             : 
     107           0 : void StyleSheetUndoAction::Redo()
     108             : {
     109           0 :     SfxItemSet aNewSet( mpDoc->GetItemPool(), pOldSet->GetRanges() );
     110           0 :     SdrModel::MigrateItemSet( pNewSet, &aNewSet, mpDoc );
     111             : 
     112           0 :     pStyleSheet->GetItemSet().Set(aNewSet);
     113           0 :     if( pStyleSheet->GetFamily() == SD_STYLE_FAMILY_PSEUDO )
     114           0 :         ( (SdStyleSheet*)pStyleSheet )->GetRealStyleSheet()->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
     115             :     else
     116           0 :         pStyleSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
     117           0 : }
     118             : 
     119           0 : StyleSheetUndoAction::~StyleSheetUndoAction()
     120             : {
     121           0 :     delete pNewSet;
     122           0 :     delete pOldSet;
     123           0 : }
     124             : 
     125           0 : OUString StyleSheetUndoAction::GetComment() const
     126             : {
     127           0 :     return aComment;
     128         114 : }
     129             : 
     130             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10