LibreOffice Module sd (master) 1
futransf.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 <futransf.hxx>
21
22#include <svx/svxids.hrc>
23#include <sfx2/request.hxx>
24
25#include <strings.hrc>
26#include <ViewShell.hxx>
27#include <View.hxx>
28#include <sdresid.hxx>
29#include <drawdoc.hxx>
30#include <svx/svxdlg.hxx>
31#include <comphelper/lok.hxx>
32
33#include <memory>
34
35using namespace sd;
36
37FuTransform::FuTransform(ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView,
38 SdDrawDocument* pDoc, SfxRequest& rReq)
39 : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
40{
41}
42
44{
45 rtl::Reference<FuPoor> xFunc( new FuTransform( pViewSh, pWin, pView, pDoc, rReq ) );
46 xFunc->DoExecute(rReq);
47 return xFunc;
48}
49
50namespace {
51
52void setUndo(::sd::View* pView, const SfxItemSet* pArgs, bool addPageMargin)
53{
54 // Undo
55 OUString aString = pView->GetDescriptionOfMarkedObjects() +
56 " " + SdResId(STR_TRANSFORM);
57 pView->BegUndo(aString);
58 pView->SetGeoAttrToMarked(*pArgs, addPageMargin);
59 pView->SetAttributes(*pArgs);
60 pView->EndUndo();
61}
62
63}
64
66{
68 return;
69
70 const SfxItemSet* pArgs = rReq.GetArgs();
71
72 if (pArgs)
73 {
74 // If this comes from LOK, that means the shape is moved by mouse
75 // only then pArgs is pre-set.
77 return;
78 }
79
80 // --------- itemset for size and position --------
83
84 bool bWelded = false;
85 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
86 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
87 if( rMarkList.GetMarkCount() == 1 &&
88 pObj->GetObjInventor() == SdrInventor::Default &&
89 pObj->GetObjIdentifier() == SdrObjKind::Caption )
90 {
91 // --------- itemset for caption --------
92 SfxItemSet aNewAttr( mpDoc->GetPool() );
93 mpView->GetAttributes( aNewAttr );
94
97
98 const WhichRangesContainer& pRange = pDlg->GetInputRanges( *aNewAttr.GetPool() );
99 SfxItemSet aCombSet( *aNewAttr.GetPool(), pRange );
100 aCombSet.Put( aNewAttr );
101 aCombSet.Put( aSet );
102 pDlg->SetInputSet( &aCombSet );
103 }
104 else
105 {
108 bWelded = true;
109 }
110
111 assert(pDlg && "there must be a dialog at this point");
112
113 auto pRequest = std::make_shared<SfxRequest>(rReq);
114 rReq.Ignore(); // the 'old' request is not relevant any more
115
116 pDlg->StartExecuteAsync([bWelded, pDlg, pRequest, this](sal_Int32 nResult){
117 if (nResult == RET_OK)
118 {
119 pRequest->Done(*(pDlg->GetOutputItemSet()));
120 // Page margin is already calculated at this point.
121 setUndo(mpView, pRequest->GetArgs(), false);
122 }
123
124 // deferred until the dialog ends
125 mpViewShell->Invalidate(SID_RULER_OBJECT);
127 if (bWelded)
128 pDlg->disposeOnce();
129 });
130}
131
132/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPRIVATE SfxItemPool & GetPool()
Definition: drawdoc.hxx:237
void BegUndo()
void SetGeoAttrToMarked(const SfxItemSet &rAttr, bool addPageMargin=false)
SfxItemSet GetGeoAttrFromMarked() const
void EndUndo()
size_t GetMarkCount() const
SdrMark * GetMark(size_t nNum) const
const SdrMarkList & GetMarkedObjectList() const
bool AreObjectsMarked() const
OUString const & GetDescriptionOfMarkedObjects() const
SdrObject * GetMarkedSdrObj() const
virtual SdrInventor GetObjInventor() const
virtual SdrObjKind GetObjIdentifier() const
SfxItemPool * GetPool() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void Ignore()
const SfxItemSet * GetArgs() const
virtual void Invalidate(sal_uInt16 nId=0)
virtual VclPtr< AbstractSvxTransformTabDialog > CreateSvxTransformTabDialog(weld::Window *pParent, const SfxItemSet *pAttr, const SdrView *pView, SvxAnchorIds nAnchorTypes=SvxAnchorIds::NONE)=0
virtual VclPtr< AbstractSvxCaptionDialog > CreateCaptionDialog(weld::Window *pParent, const SdrView *pView, SvxAnchorIds nAnchorTypes=SvxAnchorIds::NONE)=0
static SvxAbstractDialogFactory * Create()
void reset(reference_type *pBody)
Base class for all functions.
Definition: fupoor.hxx:48
SdDrawDocument * mpDoc
Definition: fupoor.hxx:148
ViewShell * mpViewShell
Definition: fupoor.hxx:145
::sd::View * mpView
Definition: fupoor.hxx:144
FuTransform(ViewShell *pViewSh, ::sd::Window *pWin, ::sd::View *pView, SdDrawDocument *pDoc, SfxRequest &rReq)
Definition: futransf.cxx:37
static rtl::Reference< FuPoor > Create(ViewShell *pViewSh, ::sd::Window *pWin, ::sd::View *pView, SdDrawDocument *pDoc, SfxRequest &rReq)
Definition: futransf.cxx:43
virtual void DoExecute(SfxRequest &rReq) override
Definition: futransf.cxx:65
Base class of the stacked shell hierarchy.
Definition: ViewShell.hxx:92
SD_DLLPUBLIC weld::Window * GetFrameWeld() const
Definition: viewshel.cxx:1582
void Cancel()
this method deactivates the current function.
Definition: viewshel.cxx:1442
virtual bool SetAttributes(const SfxItemSet &rSet, bool bReplaceAll=false, bool bSlide=false, bool bMaster=false)
Definition: sdview.cxx:509
virtual void GetAttributes(SfxItemSet &rTargetSet, bool bOnlyHardAttr=false) const
Definition: sdview.cxx:515
An SdWindow contains the actual working area of ViewShell.
Definition: Window.hxx:45
OUString SdResId(TranslateId aId)
Definition: sdmod.cxx:83
RET_OK