LibreOffice Module sd (master) 1
GraphicObjectBar.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 <GraphicObjectBar.hxx>
21
22#include <sfx2/shell.hxx>
23#include <svx/svxids.hrc>
24#include <sfx2/request.hxx>
25#include <svx/svdograf.hxx>
26#include <svx/grfflt.hxx>
27#include <svx/grafctrl.hxx>
28
29#include <sfx2/objface.hxx>
30
31#include <strings.hrc>
32#include <DrawDocShell.hxx>
33#include <ViewShell.hxx>
34#include <sdresid.hxx>
35
36using namespace sd;
37#define ShellClass_GraphicObjectBar
38#include <sdslots.hxx>
39
40namespace sd {
41
42
44
45void GraphicObjectBar::InitInterface_Impl()
46{
47}
48
49
51 const ViewShell* pSdViewShell,
52 ::sd::View* pSdView )
53 : SfxShell (pSdViewShell->GetViewShell()),
54 mpView ( pSdView )
55{
56 DrawDocShell* pDocShell = pSdViewShell->GetDocSh();
57
58 SetPool( &pDocShell->GetPool() );
59 SetUndoManager( pDocShell->GetUndoManager() );
61 SetName( "Graphic objectbar");
62}
63
65{
66 SetRepeatTarget( nullptr );
67}
68
70{
71 if( mpView )
73}
74
76{
77 if( mpView )
78 {
80 Invalidate();
81 }
82}
83
85{
86 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
87 bool bEnable = false;
88
89 if( rMarkList.GetMarkCount() == 1 )
90 {
91 SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
92
93 if( auto pGrafObj = dynamic_cast< SdrGrafObj *>( pObj ) )
94 if( pGrafObj->GetGraphicType() == GraphicType::Bitmap )
95 bEnable = true;
96 }
97
98 if( !bEnable )
100}
101
103{
104 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
105
106 if( rMarkList.GetMarkCount() == 1 )
107 {
108 SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
109
110 if( auto pGrafObj = dynamic_cast< SdrGrafObj *>( pObj ) )
111 if( pGrafObj->GetGraphicType() == GraphicType::Bitmap )
112 {
113 GraphicObject aFilterObj( pGrafObj->GetGraphicObject() );
114
115 if( SvxGraphicFilterResult::NONE ==
116 SvxGraphicFilter::ExecuteGrfFilterSlot( rReq, aFilterObj ) )
117 {
118 SdrPageView* pPageView = mpView->GetSdrPageView();
119
120 if( pPageView )
121 {
122 rtl::Reference<SdrGrafObj> pFilteredObj = SdrObject::Clone(static_cast<SdrGrafObj&>(*pObj), pObj->getSdrModelFromSdrObject());
124 " " + SdResId(STR_UNDO_GRAFFILTER);
125 mpView->BegUndo( aStr );
126 pFilteredObj->SetGraphicObject( aFilterObj );
127 ::sd::View* const pView = mpView;
128 pView->ReplaceObjectAtView( pObj, *pPageView, pFilteredObj.get() );
129 pView->EndUndo();
130 return;
131 }
132 }
133 }
134 }
135
136 Invalidate();
137}
138
139} // end of namespace sd
140
141/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void ReplaceObjectAtView(SdrObject *pOldObj, SdrPageView &rPV, SdrObject *pNewObj, bool bMark=true)
void BegUndo()
void EndUndo()
size_t GetMarkCount() const
SdrMark * GetMark(size_t nNum) const
const SdrMarkList & GetMarkedObjectList() const
OUString const & GetDescriptionOfMarkedObjects() const
SdrObject * GetMarkedSdrObj() const
static rtl::Reference< T > Clone(T const &rObj, SdrModel &rTargetModel)
SdrModel & getSdrModelFromSdrObject() const
SdrPageView * GetSdrPageView() const
void SetUndoManager(SfxUndoManager *pNewUndoMgr)
SfxItemPool & GetPool() const
void SetRepeatTarget(SfxRepeatTarget *pTarget)
virtual void Invalidate(sal_uInt16 nId=0)
void SetPool(SfxItemPool *pNewPool)
void SetName(const OUString &rName)
static void ExecuteGrafAttr(SfxRequest &rReq, SdrView &rView)
static void GetGrafAttrState(SfxItemSet &rSet, SdrView const &rView)
static SvxGraphicFilterResult ExecuteGrfFilterSlot(SfxRequest const &rReq, GraphicObject &rFilterObject)
static void DisableGraphicFilterSlots(SfxItemSet &rSet)
virtual SfxUndoManager * GetUndoManager() override
Definition: docshell.cxx:363
void GetAttrState(SfxItemSet &rSet)
void ExecuteFilter(SfxRequest const &rReq)
GraphicObjectBar(const ViewShell *pSdViewShell, ::sd::View *pSdView)
virtual ~GraphicObjectBar() override
void GetFilterState(SfxItemSet &rSet)
void Execute(SfxRequest &rReq)
Base class of the stacked shell hierarchy.
Definition: ViewShell.hxx:92
SD_DLLPUBLIC DrawDocShell * GetDocSh() const
Definition: viewshel.cxx:1407
aStr
OUString SdResId(TranslateId aId)
Definition: sdmod.cxx:83
static SfxItemSet & rSet
#define SFX_IMPL_INTERFACE(Class, SuperClass)
UnoViewSharedPtr mpView