Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "fulinend.hxx"
30 : : #include <svx/xtable.hxx>
31 : : #include <svx/svxdlg.hxx>
32 : : #include <svx/dialogs.hrc>
33 : : #include <svx/svdobj.hxx>
34 : : #include <svx/svdopath.hxx>
35 : : #include <vcl/msgbox.hxx>
36 : :
37 : : #include "strings.hrc"
38 : : #include "ViewShell.hxx"
39 : : #include "helpids.h"
40 : : #include "sdresid.hxx"
41 : : #include "drawdoc.hxx"
42 : : #include "View.hxx"
43 : : #include "Window.hxx"
44 : :
45 : : namespace sd {
46 : :
47 : : #define BITMAP_WIDTH 32
48 : : #define BITMAP_HEIGHT 12
49 : :
50 [ # # ][ # # ]: 0 : TYPEINIT1( FuLineEnd, FuPoor );
51 : :
52 : : /*************************************************************************
53 : : |*
54 : : |* Konstruktor
55 : : |*
56 : : \************************************************************************/
57 : :
58 : 0 : FuLineEnd::FuLineEnd(ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView,
59 : : SdDrawDocument* pDoc, SfxRequest& rReq)
60 : 0 : : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
61 : : {
62 : 0 : }
63 : :
64 : 0 : FunctionReference FuLineEnd::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
65 : : {
66 [ # # ][ # # ]: 0 : FunctionReference xFunc( new FuLineEnd( pViewSh, pWin, pView, pDoc, rReq ) );
67 [ # # ]: 0 : xFunc->DoExecute(rReq);
68 : 0 : return xFunc;
69 : : }
70 : :
71 : 0 : void FuLineEnd::DoExecute( SfxRequest& )
72 : : {
73 : 0 : const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
74 : :
75 [ # # ]: 0 : if( rMarkList.GetMarkCount() == 1 )
76 : : {
77 [ # # ][ # # ]: 0 : const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
78 : : const SdrObject* pNewObj;
79 : 0 : SdrObject* pConvPolyObj = NULL;
80 : :
81 [ # # ][ # # ]: 0 : if( pObj->ISA( SdrPathObj ) )
[ # # ]
82 : : {
83 : 0 : pNewObj = pObj;
84 : : }
85 : : else
86 : : {
87 [ # # ]: 0 : SdrObjTransformInfoRec aInfoRec;
88 [ # # ]: 0 : pObj->TakeObjInfo( aInfoRec );
89 : :
90 [ # # ][ # # ]: 0 : if( aInfoRec.bCanConvToPath &&
[ # # ][ # # ]
91 [ # # ]: 0 : pObj->GetObjInventor() == SdrInventor &&
92 [ # # ]: 0 : pObj->GetObjIdentifier() != OBJ_GRUP )
93 : : // bCanConvToPath ist bei Gruppenobjekten sal_True,
94 : : // stuerzt aber bei ConvertToPathObj() ab !
95 : : {
96 [ # # ]: 0 : pNewObj = pConvPolyObj = pObj->ConvertToPolyObj( sal_True, sal_False );
97 : :
98 [ # # ][ # # ]: 0 : if( !pNewObj || !pNewObj->ISA( SdrPathObj ) )
[ # # ][ # # ]
[ # # ]
99 : : return; // Abbruch, zusaetzliche Sicherheit, die bei
100 : : // Gruppenobjekten aber nichts bringt.
101 : : }
102 : : else return; // Abbruch
103 : : }
104 : :
105 [ # # ]: 0 : const ::basegfx::B2DPolyPolygon aPolyPolygon = ( (SdrPathObj*) pNewObj )->GetPathPoly();
106 : :
107 : : // Loeschen des angelegten PolyObjektes
108 [ # # ]: 0 : SdrObject::Free( pConvPolyObj );
109 : :
110 [ # # ]: 0 : XLineEndListRef pLineEndList = mpDoc->GetLineEndList();
111 : : XLineEndEntry* pEntry;
112 : :
113 [ # # ][ # # ]: 0 : String aNewName( SdResId( STR_LINEEND ) );
114 [ # # ][ # # ]: 0 : String aDesc( SdResId( STR_DESC_LINEEND ) );
115 [ # # ]: 0 : String aName;
116 : :
117 [ # # ]: 0 : long nCount = pLineEndList->Count();
118 : 0 : long j = 1;
119 : 0 : sal_Bool bDifferent = sal_False;
120 : :
121 [ # # ]: 0 : while( !bDifferent )
122 : : {
123 [ # # ]: 0 : aName = aNewName;
124 [ # # ]: 0 : aName.Append( sal_Unicode(' ') );
125 [ # # ][ # # ]: 0 : aName.Append( UniString::CreateFromInt32( j++ ) );
[ # # ]
126 : 0 : bDifferent = sal_True;
127 [ # # ][ # # ]: 0 : for( long i = 0; i < nCount && bDifferent; i++ )
[ # # ]
128 : : {
129 [ # # ][ # # ]: 0 : if( aName == pLineEndList->GetLineEnd( i )->GetName() )
[ # # ]
130 : 0 : bDifferent = sal_False;
131 : : }
132 : : }
133 : :
134 [ # # ]: 0 : SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
135 [ # # ][ # # ]: 0 : AbstractSvxNameDialog* pDlg = pFact ? pFact->CreateSvxNameDialog( NULL, aName, aDesc ) : 0;
136 : :
137 [ # # ]: 0 : if( pDlg )
138 : : {
139 [ # # ]: 0 : pDlg->SetEditHelpId( HID_SD_NAMEDIALOG_LINEEND );
140 : :
141 [ # # ][ # # ]: 0 : if( pDlg->Execute() == RET_OK )
142 : : {
143 [ # # ]: 0 : pDlg->GetName( aName );
144 : 0 : bDifferent = sal_True;
145 : :
146 [ # # ][ # # ]: 0 : for( long i = 0; i < nCount && bDifferent; i++ )
[ # # ]
147 : : {
148 [ # # ][ # # ]: 0 : if( aName == pLineEndList->GetLineEnd( i )->GetName() )
[ # # ]
149 : 0 : bDifferent = sal_False;
150 : : }
151 : :
152 [ # # ]: 0 : if( bDifferent )
153 : : {
154 [ # # ][ # # ]: 0 : pEntry = new XLineEndEntry( aPolyPolygon, aName );
155 [ # # ]: 0 : pLineEndList->Insert( pEntry, LIST_APPEND);
156 : : }
157 : : else
158 : : {
159 [ # # ][ # # ]: 0 : String aStr(SdResId( STR_WARN_NAME_DUPLICATE ));
160 : : WarningBox aWarningBox( mpWindow, WinBits( WB_OK ),
161 [ # # ]: 0 : aStr );
162 [ # # ][ # # ]: 0 : aWarningBox.Execute();
[ # # ]
163 : : }
164 : : }
165 : : }
166 [ # # ][ # # ]: 0 : delete pDlg;
[ # # ][ # # ]
[ # # ][ # # ]
167 : : }
168 : : }
169 : :
170 : 0 : void FuLineEnd::Activate()
171 : : {
172 : 0 : }
173 : :
174 : 0 : void FuLineEnd::Deactivate()
175 : : {
176 : 0 : }
177 : :
178 : : } // end of namespace sd
179 : :
180 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|