xref: /aoo41x/main/sc/source/ui/drawfunc/drawsh4.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sc.hxx"
30 
31 
32 
33 //------------------------------------------------------------------
34 
35 #include "scitems.hxx"
36 #include <svx/drawitem.hxx>
37 #include <svx/fontwork.hxx>
38 #include <svx/svdotext.hxx>
39 #include <svx/xdef.hxx>
40 #include <sfx2/objsh.hxx>
41 #include <sfx2/viewfrm.hxx>
42 
43 #include "drawsh.hxx"
44 #include "drawview.hxx"
45 #include "viewdata.hxx"
46 #include "tabvwsh.hxx"
47 #include "sc.hrc"
48 
49 
50 //------------------------------------------------------------------
51 
52 void ScDrawShell::GetFormTextState(SfxItemSet& rSet)
53 {
54 	const SdrObject*	pObj		= NULL;
55 	SvxFontWorkDialog*	pDlg		= NULL;
56 	ScDrawView* 		pDrView 	= pViewData->GetScDrawView();
57 	const SdrMarkList&	rMarkList	= pDrView->GetMarkedObjectList();
58 	sal_uInt16				nId = SvxFontWorkChildWindow::GetChildWindowId();
59 
60 	SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
61 	if ( pViewFrm->HasChildWindow(nId) )
62 		pDlg = (SvxFontWorkDialog*)(pViewFrm->GetChildWindow(nId)->GetWindow());
63 
64 	if ( rMarkList.GetMarkCount() == 1 )
65 		pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
66 
67 	if ( pObj == NULL || !pObj->ISA(SdrTextObj) ||
68 		!((SdrTextObj*) pObj)->HasText() )
69 	{
70 		if ( pDlg )
71 			pDlg->SetActive(sal_False);
72 
73 		rSet.DisableItem(XATTR_FORMTXTSTYLE);
74 		rSet.DisableItem(XATTR_FORMTXTADJUST);
75 		rSet.DisableItem(XATTR_FORMTXTDISTANCE);
76 		rSet.DisableItem(XATTR_FORMTXTSTART);
77 		rSet.DisableItem(XATTR_FORMTXTMIRROR);
78 		rSet.DisableItem(XATTR_FORMTXTSTDFORM);
79 		rSet.DisableItem(XATTR_FORMTXTHIDEFORM);
80 		rSet.DisableItem(XATTR_FORMTXTOUTLINE);
81 		rSet.DisableItem(XATTR_FORMTXTSHADOW);
82 		rSet.DisableItem(XATTR_FORMTXTSHDWCOLOR);
83 		rSet.DisableItem(XATTR_FORMTXTSHDWXVAL);
84 		rSet.DisableItem(XATTR_FORMTXTSHDWYVAL);
85 	}
86 	else
87 	{
88 		if ( pDlg )
89 		{
90 			SfxObjectShell* pDocSh = SfxObjectShell::Current();
91 
92 			if ( pDocSh )
93 			{
94                 const SfxPoolItem*  pItem = pDocSh->GetItem( SID_COLOR_TABLE );
95 				XColorTable*		pColorTable = NULL;
96 
97 				if ( pItem )
98 					pColorTable = ((SvxColorTableItem*)pItem)->GetColorTable();
99 
100 				pDlg->SetActive();
101 
102 				if ( pColorTable )
103 					pDlg->SetColorTable( pColorTable );
104 				else
105 					{ DBG_ERROR( "ColorList not found :-/" ); }
106 			}
107 		}
108 		SfxItemSet aViewAttr(pDrView->GetModel()->GetItemPool());
109 		pDrView->GetAttributes(aViewAttr);
110 		rSet.Set(aViewAttr);
111 	}
112 }
113 
114 
115 
116