android: Update app-specific/MIME type icons
[LibreOffice.git] / sd / source / ui / func / futransf.cxx
blob8c565a3b84e84a1e445d54901c8e579e0973e468
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <futransf.hxx>
22 #include <svx/svxids.hrc>
23 #include <sfx2/request.hxx>
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>
33 #include <memory>
35 using namespace sd;
37 FuTransform::FuTransform(ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView,
38 SdDrawDocument* pDoc, SfxRequest& rReq)
39 : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
43 rtl::Reference<FuPoor> FuTransform::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
45 rtl::Reference<FuPoor> xFunc( new FuTransform( pViewSh, pWin, pView, pDoc, rReq ) );
46 xFunc->DoExecute(rReq);
47 return xFunc;
50 namespace {
52 void setUndo(::sd::View* pView, const SfxItemSet* pArgs, bool addPageMargin)
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();
65 void FuTransform::DoExecute( SfxRequest& rReq )
67 if (!mpView->AreObjectsMarked())
68 return;
70 const SfxItemSet* pArgs = rReq.GetArgs();
72 if (pArgs)
74 // If this comes from LOK, that means the shape is moved by mouse
75 // only then pArgs is pre-set.
76 setUndo(mpView, pArgs, comphelper::LibreOfficeKit::isActive());
77 return;
80 // --------- itemset for size and position --------
81 SfxItemSet aSet( mpView->GetGeoAttrFromMarked() );
82 VclPtr<SfxAbstractTabDialog> pDlg;
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 )
91 // --------- itemset for caption --------
92 SfxItemSet aNewAttr( mpDoc->GetPool() );
93 mpView->GetAttributes( aNewAttr );
95 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
96 pDlg.reset(pFact->CreateCaptionDialog(mpViewShell->GetFrameWeld(), mpView));
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 );
104 else
106 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
107 pDlg.reset(pFact->CreateSvxTransformTabDialog(mpViewShell->GetFrameWeld(), &aSet, mpView));
108 bWelded = true;
111 assert(pDlg && "there must be a dialog at this point");
113 auto pRequest = std::make_shared<SfxRequest>(rReq);
114 rReq.Ignore(); // the 'old' request is not relevant any more
116 pDlg->StartExecuteAsync([bWelded, pDlg, pRequest, this](sal_Int32 nResult){
117 if (nResult == RET_OK)
119 pRequest->Done(*(pDlg->GetOutputItemSet()));
120 // Page margin is already calculated at this point.
121 setUndo(mpView, pRequest->GetArgs(), false);
124 // deferred until the dialog ends
125 mpViewShell->Invalidate(SID_RULER_OBJECT);
126 mpViewShell->Cancel();
127 if (bWelded)
128 pDlg->disposeOnce();
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */