xref: /trunk/main/sd/source/ui/func/fuchar.cxx (revision da72173f)
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_sd.hxx"
26 
27 
28 #include "fuchar.hxx"
29 
30 #include <sfx2/viewfrm.hxx>
31 
32 #include <editeng/editdata.hxx>
33 #include <svx/svxids.hrc>
34 #include <editeng/eeitem.hxx>
35 #include <vcl/msgbox.hxx>
36 #include <sfx2/bindings.hxx>
37 #include <sfx2/request.hxx>
38 #include "View.hxx"
39 #include "drawview.hxx"
40 #include "drawdoc.hxx"
41 #include "DrawViewShell.hxx"
42 #include "ViewShell.hxx"
43 #include "DrawDocShell.hxx"
44 #include "sdabstdlg.hxx"
45 
46 namespace sd {
47 
48 TYPEINIT1( FuChar, FuPoor );
49 
50 /*************************************************************************
51 |*
52 |* Konstruktor
53 |*
54 \************************************************************************/
55 
56 FuChar::FuChar (
57     ViewShell* pViewSh,
58     ::sd::Window* pWin,
59     ::sd::View* pView,
60     SdDrawDocument* pDoc,
61     SfxRequest& rReq)
62     : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
63 {
64 }
65 
66 FunctionReference FuChar::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
67 {
68 	FunctionReference xFunc( new FuChar( pViewSh, pWin, pView, pDoc, rReq ) );
69 	xFunc->DoExecute(rReq);
70 	return xFunc;
71 }
72 
73 void FuChar::DoExecute( SfxRequest& rReq )
74 {
75 	const SfxItemSet* pArgs = rReq.GetArgs();
76 
77 	if( !pArgs )
78 	{
79 		SfxItemSet aEditAttr( mpDoc->GetPool() );
80 		mpView->GetAttributes( aEditAttr );
81 
82 		SfxItemSet aNewAttr( mpViewShell->GetPool(),
83 								EE_ITEMS_START, EE_ITEMS_END );
84 		aNewAttr.Put( aEditAttr, sal_False );
85 
86 		SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
87 		SfxAbstractTabDialog* pDlg = pFact ? pFact->CreateSdTabCharDialog( NULL, &aNewAttr, mpDoc->GetDocSh() ) : 0;
88 		if( pDlg )
89 		{
90 			sal_uInt16 nResult = pDlg->Execute();
91 
92 			if( nResult == RET_OK )
93 			{
94 				rReq.Done( *( pDlg->GetOutputItemSet() ) );
95 				pArgs = rReq.GetArgs();
96 			}
97 
98 			delete pDlg;
99 
100 			if( nResult != RET_OK )
101 			{
102 				return;
103 			}
104 		}
105 	}
106 	mpView->SetAttributes(*pArgs);
107 
108 	// invalidieren der Slots, die in der DrTxtObjBar auftauchen
109 	static sal_uInt16 SidArray[] = {
110 					SID_ATTR_CHAR_FONT,
111 					SID_ATTR_CHAR_POSTURE,
112 					SID_ATTR_CHAR_WEIGHT,
113 					SID_ATTR_CHAR_UNDERLINE,
114 					SID_ATTR_CHAR_FONTHEIGHT,
115 					SID_ATTR_CHAR_COLOR,
116 					SID_SET_SUPER_SCRIPT,
117 					SID_SET_SUB_SCRIPT,
118 					0 };
119 
120 	mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
121 
122 	if( mpDoc->GetOnlineSpell() )
123 	{
124 		const SfxPoolItem* pItem;
125 		if( SFX_ITEM_SET == pArgs->GetItemState(EE_CHAR_LANGUAGE, sal_False, &pItem ) ||
126 			SFX_ITEM_SET == pArgs->GetItemState(EE_CHAR_LANGUAGE_CJK, sal_False, &pItem ) ||
127 			SFX_ITEM_SET == pArgs->GetItemState(EE_CHAR_LANGUAGE_CTL, sal_False, &pItem ) )
128 		{
129 			mpDoc->StopOnlineSpelling();
130 			mpDoc->StartOnlineSpelling();
131 		}
132 	}
133 }
134 
135 void FuChar::Activate()
136 {
137 }
138 
139 void FuChar::Deactivate()
140 {
141 }
142 
143 } // end of namespace sd
144