1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <comphelper/scopeguard.hxx>
23 #include <svx/dialogs.hrc>
24 #include <sfx2/request.hxx>
26 #include <strings.hrc>
27 #include <ViewShell.hxx>
30 #include <sdresid.hxx>
31 #include <drawdoc.hxx>
32 #include <svx/svxdlg.hxx>
38 FuTransform::FuTransform(ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
,
39 SdDrawDocument
* pDoc
, SfxRequest
& rReq
)
40 : FuPoor(pViewSh
, pWin
, pView
, pDoc
, rReq
)
44 rtl::Reference
<FuPoor
> FuTransform::Create( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, SfxRequest
& rReq
)
46 rtl::Reference
<FuPoor
> xFunc( new FuTransform( pViewSh
, pWin
, pView
, pDoc
, rReq
) );
47 xFunc
->DoExecute(rReq
);
53 void setUndo(::sd::View
* pView
, const SfxItemSet
* pArgs
)
56 OUString
aString(pView
->GetDescriptionOfMarkedObjects());
57 aString
+= " " + SdResId(STR_TRANSFORM
);
58 pView
->BegUndo(aString
);
60 pView
->SetGeoAttrToMarked(*pArgs
);
61 pView
->SetAttributes(*pArgs
);
67 void FuTransform::DoExecute( SfxRequest
& rReq
)
69 if (!mpView
->AreObjectsMarked())
72 const SfxItemSet
* pArgs
= rReq
.GetArgs();
76 setUndo(mpView
, pArgs
);
80 // --------- itemset for size and position --------
81 SfxItemSet
aSet( mpView
->GetGeoAttrFromMarked() );
82 VclPtr
<SfxAbstractTabDialog
> pDlg
;
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() == OBJ_CAPTION
)
91 // --------- itemset for caption --------
92 SfxItemSet
aNewAttr( mpDoc
->GetPool() );
93 mpView
->GetAttributes( aNewAttr
);
95 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
99 pDlg
.reset(pFact
->CreateCaptionDialog(mpViewShell
->GetActiveWindow(), mpView
));
101 const sal_uInt16
* pRange
= pDlg
->GetInputRanges( *aNewAttr
.GetPool() );
102 SfxItemSet
aCombSet( *aNewAttr
.GetPool(), pRange
);
103 aCombSet
.Put( aNewAttr
);
104 aCombSet
.Put( aSet
);
105 pDlg
->SetInputSet( &aCombSet
);
109 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
113 pDlg
.reset(pFact
->CreateSvxTransformTabDialog(mpViewShell
->GetFrameWeld(), &aSet
, mpView
));
120 std::shared_ptr
<SfxRequest
> pRequest(new SfxRequest(rReq
));
121 rReq
.Ignore(); // the 'old' request is not relevant any more
123 pDlg
->StartExecuteAsync([=](sal_Int32 nResult
){
124 if (nResult
== RET_OK
)
126 pRequest
->Done(*(pDlg
->GetOutputItemSet()));
127 setUndo(mpView
, pRequest
->GetArgs());
130 // deferred until the dialog ends
131 mpViewShell
->Invalidate(SID_RULER_OBJECT
);
132 mpViewShell
->Cancel();
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */