Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include <sfx2/msg.hxx>
22 : #include <sfx2/app.hxx>
23 : #include <sfx2/sfxsids.hrc>
24 : #include <sfx2/request.hxx>
25 : #include <sfx2/objface.hxx>
26 : #include <sfx2/viewfrm.hxx>
27 : #include <sfx2/dispatch.hxx>
28 : #include <sfx2/msgpool.hxx>
29 : #include <sfx2/sidebar/EnumContext.hxx>
30 : #include <svl/whiter.hxx>
31 : #include <svl/itempool.hxx>
32 : #include <svx/svdomedia.hxx>
33 : #include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
34 : #include <svx/svxdlg.hxx>
35 : #include <svx/dialogs.hrc>
36 : #include <svx/svxids.hrc>
37 :
38 : #include "app.hrc"
39 : #include "res_bmp.hrc"
40 : #include "glob.hrc"
41 : #include "strings.hrc"
42 : #include "DrawDocShell.hxx"
43 : #include "ViewShell.hxx"
44 : #include "Window.hxx"
45 : #include "drawview.hxx"
46 : #include "sdresid.hxx"
47 : #include "drawdoc.hxx"
48 : #include "DrawViewShell.hxx"
49 :
50 : #include "tableobjectbar.hxx"
51 :
52 : using namespace sd;
53 : using namespace sd::ui::table;
54 :
55 : #define TableObjectBar
56 : #include "sdslots.hxx"
57 :
58 :
59 : namespace sd { namespace ui { namespace table {
60 :
61 : /** creates a table object bar for the given ViewShell */
62 0 : SfxShell* CreateTableObjectBar( ViewShell& rShell, ::sd::View* pView )
63 : {
64 0 : return new TableObjectBar( &rShell, pView );
65 : }
66 :
67 :
68 : /** registers the interfaces from the table ui */
69 11 : void RegisterInterfaces(SfxModule* pMod)
70 : {
71 11 : TableObjectBar::RegisterInterface(pMod);
72 11 : }
73 :
74 : // ------------------
75 : // - TableObjectBar -
76 : // ------------------
77 :
78 0 : TYPEINIT1( TableObjectBar, SfxShell );
79 :
80 : // -----------------------------------------------------------------------------
81 :
82 33 : SFX_IMPL_INTERFACE( TableObjectBar, SfxShell, SdResId( STR_TABLEOBJECTBARSHELL ) )
83 : {
84 11 : }
85 :
86 : // -----------------------------------------------------------------------------
87 :
88 0 : TableObjectBar::TableObjectBar( ViewShell* pSdViewShell, ::sd::View* pSdView )
89 : : SfxShell( pSdViewShell->GetViewShell() )
90 : , mpView( pSdView )
91 0 : , mpViewSh( pSdViewShell )
92 : {
93 0 : DrawDocShell* pDocShell = mpViewSh->GetDocSh();
94 0 : if( pDocShell )
95 : {
96 0 : SetPool( &pDocShell->GetPool() );
97 0 : SetUndoManager( pDocShell->GetUndoManager() );
98 : }
99 0 : SetRepeatTarget( mpView );
100 0 : SetHelpId( SD_IF_SDDRAWTABLEOBJECTBAR );
101 0 : SetName( String( SdResId( RID_DRAW_TABLE_TOOLBOX ) ) );
102 0 : SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Table));
103 0 : }
104 :
105 : // -----------------------------------------------------------------------------
106 :
107 0 : TableObjectBar::~TableObjectBar()
108 : {
109 0 : SetRepeatTarget( NULL );
110 0 : }
111 :
112 : // -----------------------------------------------------------------------------
113 :
114 0 : void TableObjectBar::GetState( SfxItemSet& rSet )
115 : {
116 0 : bool bReadOnly = false;
117 :
118 0 : if( bReadOnly )
119 : {
120 0 : rSet.DisableItem (SID_INSERT_TABLE );
121 : }
122 :
123 0 : if( mpView )
124 : {
125 0 : rtl::Reference< sdr::SelectionController > xController( mpView->getSelectionController() );
126 0 : if( xController.is() )
127 : {
128 0 : xController->GetState( rSet );
129 0 : }
130 : }
131 0 : }
132 :
133 : // -----------------------------------------------------------------------------
134 :
135 0 : void TableObjectBar::GetAttrState( SfxItemSet& rSet )
136 : {
137 0 : DrawViewShell* pDrawViewShell = dynamic_cast< DrawViewShell* >( mpViewSh );
138 0 : if( pDrawViewShell )
139 0 : pDrawViewShell->GetAttrState( rSet );
140 0 : }
141 :
142 : // -----------------------------------------------------------------------------
143 :
144 0 : void TableObjectBar::Execute( SfxRequest& rReq )
145 : {
146 0 : if( mpView )
147 : {
148 0 : SdrView* pView = mpView;
149 0 : SfxBindings* pBindings = &mpViewSh->GetViewFrame()->GetBindings();
150 :
151 0 : rtl::Reference< sdr::SelectionController > xController( mpView->getSelectionController() );
152 0 : sal_uLong nSlotId = rReq.GetSlot();
153 0 : if( xController.is() )
154 : {
155 0 : switch( nSlotId )
156 : {
157 : case SID_TABLE_INSERT_ROW_DLG:
158 : case SID_TABLE_INSERT_COL_DLG:
159 : {
160 0 : SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
161 0 : ::std::auto_ptr<SvxAbstractInsRowColDlg> pDlg( pFact ? pFact->CreateSvxInsRowColDlg( mpView->GetViewShell()->GetParentWindow(), nSlotId == SID_TABLE_INSERT_COL_DLG, SD_MOD()->GetSlotPool()->GetSlot(nSlotId)->GetCommand()) : 0);
162 :
163 0 : if( pDlg.get() && (pDlg->Execute() == 1) )
164 : {
165 0 : if( nSlotId == SID_TABLE_INSERT_ROW_DLG )
166 0 : nSlotId = SID_TABLE_INSERT_ROW;
167 : else
168 0 : nSlotId = SID_TABLE_INSERT_COL;
169 :
170 0 : rReq.AppendItem( SfxInt16Item( (sal_uInt16)nSlotId, (sal_uInt16)pDlg->getInsertCount() ) );
171 0 : rReq.AppendItem( SfxBoolItem( SID_TABLE_PARAM_INSERT_AFTER, !pDlg->isInsertBefore() ) );
172 :
173 0 : rReq.SetSlot( (sal_uInt16)nSlotId );
174 0 : }
175 : }
176 : }
177 :
178 0 : xController->Execute( rReq );
179 : }
180 :
181 : // note: we may be deleted at this point, no more member access possible
182 :
183 0 : switch( rReq.GetSlot() )
184 : {
185 : case SID_ATTR_BORDER:
186 : case SID_TABLE_MERGE_CELLS:
187 : case SID_TABLE_SPLIT_CELLS:
188 : case SID_OPTIMIZE_TABLE:
189 : case SID_TABLE_DELETE_ROW:
190 : case SID_TABLE_DELETE_COL:
191 : case SID_FORMAT_TABLE_DLG:
192 : case SID_TABLE_INSERT_ROW:
193 : case SID_TABLE_INSERT_COL:
194 : {
195 0 : pView->AdjustMarkHdl();
196 0 : pBindings->Invalidate( SID_TABLE_DELETE_ROW );
197 0 : pBindings->Invalidate( SID_TABLE_DELETE_COL );
198 0 : pBindings->Invalidate( SID_FRAME_LINESTYLE );
199 0 : pBindings->Invalidate( SID_FRAME_LINECOLOR );
200 0 : pBindings->Invalidate( SID_ATTR_BORDER );
201 0 : pBindings->Invalidate( SID_ATTR_FILL_STYLE );
202 0 : pBindings->Invalidate( SID_ATTR_FILL_TRANSPARENCE );
203 0 : pBindings->Invalidate( SID_ATTR_FILL_FLOATTRANSPARENCE );
204 0 : pBindings->Invalidate( SID_TABLE_MERGE_CELLS );
205 0 : pBindings->Invalidate( SID_TABLE_SPLIT_CELLS );
206 0 : pBindings->Invalidate( SID_OPTIMIZE_TABLE );
207 0 : pBindings->Invalidate( SID_TABLE_VERT_BOTTOM );
208 0 : pBindings->Invalidate( SID_TABLE_VERT_CENTER );
209 0 : pBindings->Invalidate( SID_TABLE_VERT_NONE );
210 0 : break;
211 : }
212 : case SID_TABLE_VERT_BOTTOM:
213 : case SID_TABLE_VERT_CENTER:
214 : case SID_TABLE_VERT_NONE:
215 : {
216 0 : pBindings->Invalidate( SID_TABLE_VERT_BOTTOM );
217 0 : pBindings->Invalidate( SID_TABLE_VERT_CENTER );
218 0 : pBindings->Invalidate( SID_TABLE_VERT_NONE );
219 0 : break;
220 : }
221 : }
222 :
223 0 : pBindings->Invalidate( SID_UNDO );
224 0 : pBindings->Invalidate( SID_REDO );
225 : }
226 0 : }
227 :
228 33 : } } }
229 :
230 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|