1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fulinend.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
35 #include "fulinend.hxx"
36 #include <svx/xtable.hxx>
37 #include <svx/svxdlg.hxx>
38 #include <svx/dialogs.hrc>
39 #include <svx/svdobj.hxx>
40 #include <svx/svdopath.hxx>
41 #include <vcl/msgbox.hxx>
43 #include "strings.hrc"
44 #include "ViewShell.hxx"
46 #include "sdresid.hxx"
47 #include "drawdoc.hxx"
49 #ifndef SD_WINDOW_SHELL_HXX
55 #define BITMAP_WIDTH 32
56 #define BITMAP_HEIGHT 12
58 TYPEINIT1( FuLineEnd
, FuPoor
);
60 /*************************************************************************
64 \************************************************************************/
66 FuLineEnd::FuLineEnd(ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
,
67 SdDrawDocument
* pDoc
, SfxRequest
& rReq
)
68 : FuPoor(pViewSh
, pWin
, pView
, pDoc
, rReq
)
72 FunctionReference
FuLineEnd::Create( ViewShell
* pViewSh
, ::sd::Window
* pWin
, ::sd::View
* pView
, SdDrawDocument
* pDoc
, SfxRequest
& rReq
)
74 FunctionReference
xFunc( new FuLineEnd( pViewSh
, pWin
, pView
, pDoc
, rReq
) );
75 xFunc
->DoExecute(rReq
);
79 void FuLineEnd::DoExecute( SfxRequest
& )
81 const SdrMarkList
& rMarkList
= mpView
->GetMarkedObjectList();
83 if( rMarkList
.GetMarkCount() == 1 )
85 const SdrObject
* pObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
86 const SdrObject
* pNewObj
;
87 SdrObject
* pConvPolyObj
= NULL
;
89 if( pObj
->ISA( SdrPathObj
) )
95 SdrObjTransformInfoRec aInfoRec
;
96 pObj
->TakeObjInfo( aInfoRec
);
98 if( aInfoRec
.bCanConvToPath
&&
99 pObj
->GetObjInventor() == SdrInventor
&&
100 pObj
->GetObjIdentifier() != OBJ_GRUP
)
101 // bCanConvToPath ist bei Gruppenobjekten TRUE,
102 // stuerzt aber bei ConvertToPathObj() ab !
104 pNewObj
= pConvPolyObj
= pObj
->ConvertToPolyObj( TRUE
, FALSE
);
106 if( !pNewObj
|| !pNewObj
->ISA( SdrPathObj
) )
107 return; // Abbruch, zusaetzliche Sicherheit, die bei
108 // Gruppenobjekten aber nichts bringt.
110 else return; // Abbruch
113 const ::basegfx::B2DPolyPolygon aPolyPolygon
= ( (SdrPathObj
*) pNewObj
)->GetPathPoly();
115 // Loeschen des angelegten PolyObjektes
116 SdrObject::Free( pConvPolyObj
);
118 XLineEndList
* pLineEndList
= mpDoc
->GetLineEndList();
119 XLineEndEntry
* pEntry
;
121 String
aNewName( SdResId( STR_LINEEND
) );
122 String
aDesc( SdResId( STR_DESC_LINEEND
) );
125 long nCount
= pLineEndList
->Count();
127 BOOL bDifferent
= FALSE
;
132 aName
.Append( sal_Unicode(' ') );
133 aName
.Append( UniString::CreateFromInt32( j
++ ) );
135 for( long i
= 0; i
< nCount
&& bDifferent
; i
++ )
137 if( aName
== pLineEndList
->GetLineEnd( i
)->GetName() )
142 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
143 AbstractSvxNameDialog
* pDlg
= pFact
? pFact
->CreateSvxNameDialog( NULL
, aName
, aDesc
, RID_SVXDLG_NAME
) : 0;
147 pDlg
->SetEditHelpId( HID_SD_NAMEDIALOG_LINEEND
);
149 if( pDlg
->Execute() == RET_OK
)
151 pDlg
->GetName( aName
);
154 for( long i
= 0; i
< nCount
&& bDifferent
; i
++ )
156 if( aName
== pLineEndList
->GetLineEnd( i
)->GetName() )
162 pEntry
= new XLineEndEntry( aPolyPolygon
, aName
);
163 pLineEndList
->Insert( pEntry
, LIST_APPEND
);
167 String
aStr(SdResId( STR_WARN_NAME_DUPLICATE
));
168 WarningBox
aWarningBox( mpWindow
, WinBits( WB_OK
),
170 aWarningBox
.Execute();
178 void FuLineEnd::Activate()
182 void FuLineEnd::Deactivate()
186 } // end of namespace sd