LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/dlg - unchss.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 57 0.0 %
Date: 2012-12-17 Functions: 0 11 0.0 %
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             : 
      35           0 : TYPEINIT1(StyleSheetUndoAction, SdUndoAction);
      36             : 
      37             : 
      38             : 
      39             : /*************************************************************************
      40             : |*
      41             : |* Konstruktor
      42             : |*
      43             : \************************************************************************/
      44             : 
      45           0 : StyleSheetUndoAction::StyleSheetUndoAction(SdDrawDocument* pTheDoc,
      46             :                                            SfxStyleSheet* pTheStyleSheet,
      47             :                                            const SfxItemSet* pTheNewItemSet) :
      48           0 :                       SdUndoAction(pTheDoc)
      49             : {
      50             :     DBG_ASSERT(pTheStyleSheet, "Undo ohne StyleSheet ???");
      51           0 :     pStyleSheet = pTheStyleSheet;
      52             : 
      53             :     // ItemSets anlegen; Vorsicht, das neue koennte aus einem anderen Pool
      54             :     // stammen, also mitsamt seinen Items clonen
      55           0 :     pNewSet = new SfxItemSet((SfxItemPool&)SdrObject::GetGlobalDrawObjectItemPool(), pTheNewItemSet->GetRanges());
      56           0 :     pTheDoc->MigrateItemSet( pTheNewItemSet, pNewSet, pTheDoc );
      57             : 
      58           0 :     pOldSet = new SfxItemSet((SfxItemPool&)SdrObject::GetGlobalDrawObjectItemPool(),pStyleSheet->GetItemSet().GetRanges());
      59           0 :     pTheDoc->MigrateItemSet( &pStyleSheet->GetItemSet(), pOldSet, pTheDoc );
      60             : 
      61           0 :     aComment = String(SdResId(STR_UNDO_CHANGE_PRES_OBJECT));
      62           0 :     String aName(pStyleSheet->GetName());
      63             : 
      64             :     // Layoutnamen und Separator loeschen
      65           0 :     String aSep( RTL_CONSTASCII_USTRINGPARAM( SD_LT_SEPARATOR ) );
      66           0 :     sal_uInt16 nPos = aName.Search(aSep);
      67           0 :     if( nPos != STRING_NOTFOUND )
      68           0 :         aName.Erase(0, nPos + aSep.Len());
      69             : 
      70           0 :     if (aName == String(SdResId(STR_LAYOUT_TITLE)))
      71             :     {
      72           0 :         aName = String(SdResId(STR_PSEUDOSHEET_TITLE));
      73             :     }
      74           0 :     else if (aName == String(SdResId(STR_LAYOUT_SUBTITLE)))
      75             :     {
      76           0 :         aName = String(SdResId(STR_PSEUDOSHEET_SUBTITLE));
      77             :     }
      78           0 :     else if (aName == String(SdResId(STR_LAYOUT_BACKGROUND)))
      79             :     {
      80           0 :         aName = String(SdResId(STR_PSEUDOSHEET_BACKGROUND));
      81             :     }
      82           0 :     else if (aName == String(SdResId(STR_LAYOUT_BACKGROUNDOBJECTS)))
      83             :     {
      84           0 :         aName = String(SdResId(STR_PSEUDOSHEET_BACKGROUNDOBJECTS));
      85             :     }
      86           0 :     else if (aName == String(SdResId(STR_LAYOUT_NOTES)))
      87             :     {
      88           0 :         aName = String(SdResId(STR_PSEUDOSHEET_NOTES));
      89             :     }
      90             :     else
      91             :     {
      92           0 :         String aOutlineStr(SdResId(STR_PSEUDOSHEET_OUTLINE));
      93           0 :         nPos = aName.Search(aOutlineStr);
      94           0 :         if (nPos != STRING_NOTFOUND)
      95             :         {
      96           0 :             String aNumStr(aName.Copy(aOutlineStr.Len()));
      97           0 :             aName = String(SdResId(STR_LAYOUT_OUTLINE));
      98           0 :             aName += aNumStr;
      99           0 :         }
     100             :     }
     101             : 
     102             :     // Platzhalter durch Vorlagennamen ersetzen
     103           0 :     nPos = aComment.Search(sal_Unicode('$'));
     104           0 :     aComment.Erase(nPos, 1);
     105           0 :     aComment.Insert(aName, nPos);
     106           0 : }
     107             : 
     108             : 
     109             : /*************************************************************************
     110             : |*
     111             : |* Undo()
     112             : |*
     113             : \************************************************************************/
     114             : 
     115           0 : void StyleSheetUndoAction::Undo()
     116             : {
     117           0 :     SfxItemSet aNewSet( mpDoc->GetItemPool(), pOldSet->GetRanges() );
     118           0 :     mpDoc->MigrateItemSet( pOldSet, &aNewSet, mpDoc );
     119             : 
     120           0 :     pStyleSheet->GetItemSet().Set(aNewSet);
     121           0 :     if( pStyleSheet->GetFamily() == SD_STYLE_FAMILY_PSEUDO )
     122           0 :         ( (SdStyleSheet*)pStyleSheet )->GetRealStyleSheet()->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
     123             :     else
     124           0 :         pStyleSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
     125           0 : }
     126             : 
     127             : /*************************************************************************
     128             : |*
     129             : |* Redo()
     130             : |*
     131             : \************************************************************************/
     132             : 
     133           0 : void StyleSheetUndoAction::Redo()
     134             : {
     135           0 :     SfxItemSet aNewSet( mpDoc->GetItemPool(), pOldSet->GetRanges() );
     136           0 :     mpDoc->MigrateItemSet( pNewSet, &aNewSet, mpDoc );
     137             : 
     138           0 :     pStyleSheet->GetItemSet().Set(aNewSet);
     139           0 :     if( pStyleSheet->GetFamily() == SD_STYLE_FAMILY_PSEUDO )
     140           0 :         ( (SdStyleSheet*)pStyleSheet )->GetRealStyleSheet()->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
     141             :     else
     142           0 :         pStyleSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
     143           0 : }
     144             : 
     145             : /*************************************************************************
     146             : |*
     147             : |* Destruktor
     148             : |*
     149             : \************************************************************************/
     150             : 
     151           0 : StyleSheetUndoAction::~StyleSheetUndoAction()
     152             : {
     153           0 :     delete pNewSet;
     154           0 :     delete pOldSet;
     155           0 : }
     156             : 
     157             : /*************************************************************************
     158             : |*
     159             : |* Kommentar liefern
     160             : |*
     161             : \************************************************************************/
     162             : 
     163           0 : rtl::OUString StyleSheetUndoAction::GetComment() const
     164             : {
     165           0 :     return aComment;
     166             : }
     167             : 
     168             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10