xref: /aoo4110/main/sc/source/ui/drawfunc/drawsh4.cxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sc.hxx"
26 
27 
28 
29 //------------------------------------------------------------------
30 
31 #include "scitems.hxx"
32 #include <svx/drawitem.hxx>
33 #include <svx/fontwork.hxx>
34 #include <svx/svdotext.hxx>
35 #include <svx/xdef.hxx>
36 #include <sfx2/objsh.hxx>
37 #include <sfx2/viewfrm.hxx>
38 #include <svx/svdoashp.hxx>
39 #include "drawsh.hxx"
40 #include "drawview.hxx"
41 #include "viewdata.hxx"
42 #include "tabvwsh.hxx"
43 #include "sc.hrc"
44 
45 
46 //------------------------------------------------------------------
47 
GetFormTextState(SfxItemSet & rSet)48 void ScDrawShell::GetFormTextState(SfxItemSet& rSet)
49 {
50 	const SdrObject*	pObj		= NULL;
51 	SvxFontWorkDialog*	pDlg		= NULL;
52 	ScDrawView* 		pDrView 	= pViewData->GetScDrawView();
53 	const SdrMarkList&	rMarkList	= pDrView->GetMarkedObjectList();
54 	sal_uInt16				nId = SvxFontWorkChildWindow::GetChildWindowId();
55 
56 	SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
57 	if ( pViewFrm->HasChildWindow(nId) )
58 		pDlg = (SvxFontWorkDialog*)(pViewFrm->GetChildWindow(nId)->GetWindow());
59 
60 	if ( rMarkList.GetMarkCount() == 1 )
61 		pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
62 
63     const SdrTextObj* pTextObj = dynamic_cast< const SdrTextObj* >(pObj);
64     const bool bDeactivate(
65         !pObj ||
66         !pTextObj ||
67         !pTextObj->HasText() ||
68         dynamic_cast< const SdrObjCustomShape* >(pObj)); // #121538# no FontWork for CustomShapes
69 
70     if(bDeactivate)
71 	{
72 		if ( pDlg )
73 			pDlg->SetActive(sal_False);
74 
75 		rSet.DisableItem(XATTR_FORMTXTSTYLE);
76 		rSet.DisableItem(XATTR_FORMTXTADJUST);
77 		rSet.DisableItem(XATTR_FORMTXTDISTANCE);
78 		rSet.DisableItem(XATTR_FORMTXTSTART);
79 		rSet.DisableItem(XATTR_FORMTXTMIRROR);
80 		rSet.DisableItem(XATTR_FORMTXTHIDEFORM);
81 		rSet.DisableItem(XATTR_FORMTXTOUTLINE);
82 		rSet.DisableItem(XATTR_FORMTXTSHADOW);
83 		rSet.DisableItem(XATTR_FORMTXTSHDWCOLOR);
84 		rSet.DisableItem(XATTR_FORMTXTSHDWXVAL);
85 		rSet.DisableItem(XATTR_FORMTXTSHDWYVAL);
86 	}
87 	else
88 	{
89 		if ( pDlg )
90 		{
91 			SfxObjectShell* pDocSh = SfxObjectShell::Current();
92 
93 			if ( pDocSh )
94 			{
95                 const SfxPoolItem*  pItem = pDocSh->GetItem( SID_COLOR_TABLE );
96 				XColorListSharedPtr aColorTable;
97 
98 				if ( pItem )
99 					aColorTable = static_cast< const SvxColorTableItem* >(pItem)->GetColorTable();
100 
101 				pDlg->SetActive();
102 
103 				if ( aColorTable.get() )
104 					pDlg->SetColorTable( aColorTable );
105 				else
106 					{ DBG_ERROR( "ColorList not found :-/" ); }
107 			}
108 		}
109 		SfxItemSet aViewAttr(pDrView->GetModel()->GetItemPool());
110 		pDrView->GetAttributes(aViewAttr);
111 		rSet.Set(aViewAttr);
112 	}
113 }
114 
115 
116 
117