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

Generated by: LCOV version 1.11