LibreOffice Module sd (master) 1
undoback.cxx
Go to the documentation of this file.
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 <memory>
21#include <undoback.hxx>
22
23#include <sdpage.hxx>
24#include <sdresid.hxx>
25#include <strings.hrc>
26
27#include <com/sun/star/drawing/FillStyle.hpp>
28
29#include <svl/itemset.hxx>
30
31#include <svx/xdef.hxx>
32#include <svx/xfillit0.hxx>
33#include <svx/xbtmpit.hxx>
34
36 SdDrawDocument& rDoc,
37 SdPage& rPage,
38 const SfxItemSet& rItemSet)
39: SdUndoAction(&rDoc),
40 mrPage(rPage),
41 mpItemSet(std::make_unique<SfxItemSet>(rItemSet)),
42 mbHasFillBitmap(false)
43{
44 OUString aString( SdResId( STR_UNDO_CHANGE_PAGEFORMAT ) );
45 SetComment( aString );
47}
48
50{
51 std::unique_ptr<SfxItemSet> pNew = std::make_unique<SfxItemSet>(mrPage.getSdrPageProperties().GetItemSet());
53 if (bool(mpFillBitmapItem))
55 mpFillBitmapItem.reset();
56 mbHasFillBitmap = false;
58 mpItemSet = std::move(pNew);
60
61 // tell the page that it's visualization has changed
63}
64
66{
68}
69
71{
73}
74
76{
77 std::unique_ptr<SdBackgroundObjUndoAction> pCopy = std::make_unique<SdBackgroundObjUndoAction>(*mpDoc, mrPage, *mpItemSet);
79 pCopy->mpFillBitmapItem.reset(mpFillBitmapItem->Clone());
80 pCopy->mbHasFillBitmap = mbHasFillBitmap;
81 return pCopy.release();
82}
83
85{
86 if (const XFillBitmapItem *pItem = rItemSet.GetItemIfSet(XATTR_FILLBITMAP, false))
87 mpFillBitmapItem.reset(pItem->Clone());
88 if (bool(mpFillBitmapItem))
89 {
90 if (const XFillStyleItem* pItem = rItemSet.GetItemIfSet(XATTR_FILLSTYLE, false))
91 mbHasFillBitmap = pItem->GetValue() == css::drawing::FillStyle_BITMAP;
94 rItemSet.ClearItem(XATTR_FILLSTYLE);
95 }
96}
97
99{
100 rItemSet.Put(*mpFillBitmapItem);
101 if (mbHasFillBitmap)
102 rItemSet.Put(XFillStyleItem(css::drawing::FillStyle_BITMAP));
103}
104
105/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void Redo() override
Definition: undoback.cxx:70
virtual SdUndoAction * Clone() const override
Definition: undoback.cxx:75
std::unique_ptr< SfxItemSet > mpItemSet
Definition: undoback.hxx:38
void restoreFillBitmap(SfxItemSet &rItemSet)
Definition: undoback.cxx:98
virtual void Undo() override
Definition: undoback.cxx:65
std::unique_ptr< SfxPoolItem > mpFillBitmapItem
Definition: undoback.hxx:39
void saveFillBitmap(SfxItemSet &rItemSet)
Definition: undoback.cxx:84
SdBackgroundObjUndoAction(SdDrawDocument &rDoc, SdPage &rPage, const SfxItemSet &rItemSet)
Definition: undoback.cxx:35
void SetComment(const OUString &rStr)
Definition: sdundo.hxx:32
SdDrawDocument * mpDoc
Definition: sdundo.hxx:39
const SfxItemSet & GetItemSet() const
void PutItemSet(const SfxItemSet &rSet)
void ClearItem(const sal_uInt16 nWhich=0)
void ActionChanged()
SdrPageProperties & getSdrPageProperties()
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
OUString SdResId(TranslateId aId)
Definition: sdmod.cxx:83
constexpr TypedWhichId< XFillBitmapItem > XATTR_FILLBITMAP(XATTR_FILL_FIRST+4)
constexpr TypedWhichId< XFillStyleItem > XATTR_FILLSTYLE(XATTR_FILL_FIRST)