Line data Source code
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/dialogs.hrc>
23 : #include <svx/polysc3d.hxx>
24 : #include <vcl/msgbox.hxx>
25 : #include <sfx2/request.hxx>
26 :
27 : #include "strings.hrc"
28 : #include "ViewShell.hxx"
29 : #include "View.hxx"
30 : #include "sdresid.hxx"
31 : #include "drawdoc.hxx"
32 : #include <svx/svxdlg.hxx>
33 :
34 : #include <boost/scoped_ptr.hpp>
35 :
36 : namespace sd {
37 :
38 0 : TYPEINIT1( FuTransform, FuPoor );
39 :
40 0 : FuTransform::FuTransform(ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView,
41 : SdDrawDocument* pDoc, SfxRequest& rReq)
42 0 : : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
43 : {
44 0 : }
45 :
46 0 : rtl::Reference<FuPoor> FuTransform::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
47 : {
48 0 : rtl::Reference<FuPoor> xFunc( new FuTransform( pViewSh, pWin, pView, pDoc, rReq ) );
49 0 : xFunc->DoExecute(rReq);
50 0 : return xFunc;
51 : }
52 :
53 0 : void FuTransform::DoExecute( SfxRequest& rReq )
54 : {
55 0 : if( mpView->AreObjectsMarked() )
56 : {
57 0 : const SfxItemSet* pArgs = rReq.GetArgs();
58 :
59 0 : if( !pArgs )
60 : {
61 : // --------- itemset for size and position --------
62 0 : SfxItemSet aSet( mpView->GetGeoAttrFromMarked() );
63 :
64 0 : const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
65 0 : SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
66 0 : if( rMarkList.GetMarkCount() == 1 &&
67 0 : pObj->GetObjInventor() == SdrInventor &&
68 0 : pObj->GetObjIdentifier() == OBJ_CAPTION )
69 : {
70 : // --------- itemset for caption --------
71 0 : SfxItemSet aNewAttr( mpDoc->GetPool() );
72 0 : mpView->GetAttributes( aNewAttr );
73 :
74 0 : SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
75 0 : if ( pFact )
76 : {
77 0 : boost::scoped_ptr< SfxAbstractTabDialog > pDlg( pFact->CreateCaptionDialog( NULL, mpView ) );
78 :
79 0 : const sal_uInt16* pRange = pDlg->GetInputRanges( *aNewAttr.GetPool() );
80 0 : SfxItemSet aCombSet( *aNewAttr.GetPool(), pRange );
81 0 : aCombSet.Put( aNewAttr );
82 0 : aCombSet.Put( aSet );
83 0 : pDlg->SetInputSet( &aCombSet );
84 :
85 0 : if( pDlg.get() && (pDlg->Execute() == RET_OK) )
86 : {
87 0 : rReq.Done( *( pDlg->GetOutputItemSet() ) );
88 0 : pArgs = rReq.GetArgs();
89 0 : }
90 0 : }
91 : }
92 : else
93 : {
94 0 : SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
95 0 : if(pFact)
96 : {
97 0 : boost::scoped_ptr< SfxAbstractTabDialog > pDlg( pFact->CreateSvxTransformTabDialog( NULL, &aSet, mpView ) );
98 0 : if( pDlg.get() && (pDlg->Execute() == RET_OK) )
99 : {
100 0 : rReq.Done( *( pDlg->GetOutputItemSet() ) );
101 0 : pArgs = rReq.GetArgs();
102 0 : }
103 : }
104 0 : }
105 : }
106 :
107 0 : if( pArgs )
108 : {
109 : // Undo
110 0 : OUString aString( mpView->GetDescriptionOfMarkedObjects() );
111 0 : aString += " " + SD_RESSTR( STR_TRANSFORM );
112 0 : mpView->BegUndo( aString );
113 :
114 0 : mpView->SetGeoAttrToMarked( *pArgs );
115 0 : mpView->SetAttributes( *pArgs );
116 0 : mpView->EndUndo();
117 : }
118 : }
119 0 : }
120 :
121 0 : } // end of namespace sd
122 :
123 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|