Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <string>
30 : : #include <comphelper/string.hxx>
31 : : #include <svl/eitem.hxx>
32 : : #include <svx/htmlmode.hxx>
33 : : #include <sfx2/dispatch.hxx>
34 : : #include <sfx2/bindings.hxx>
35 : : #include <sfx2/imagemgr.hxx>
36 : : #include <swmodule.hxx>
37 : : #include <view.hxx>
38 : : #include <initui.hxx>
39 : : #include <viewopt.hxx>
40 : : #include <docsh.hxx>
41 : : #include <gloshdl.hxx>
42 : : #include <glosdoc.hxx>
43 : : #include <gloslst.hxx>
44 : : #include <workctrl.hxx>
45 : : #include <workctrl.hrc>
46 : : #include <cmdid.h>
47 : : #include <helpid.h>
48 : : #include <wrtsh.hxx>
49 : : #include <svl/imageitm.hxx>
50 : : #include <vcl/lstbox.hxx>
51 : : #include <rtl/ustring.hxx>
52 : : #include "swabstdlg.hxx"
53 : : #include <misc.hrc>
54 : :
55 : : #include <vcl/svapp.hxx>
56 : :
57 : : // Size Abpruefung
58 : : #define NAVI_ENTRIES 20
59 : : #if NAVI_ENTRIES != NID_COUNT
60 : : #error SwScrollNaviPopup-CTOR static Array falsche Size. Wurden neue IDs zugefuegt ??
61 : : #endif
62 : :
63 : : using ::rtl::OUString;
64 : : using namespace ::com::sun::star;
65 : : using namespace ::com::sun::star::uno;
66 : : using namespace ::com::sun::star::beans;
67 : : using namespace ::com::sun::star::frame;
68 : :
69 [ # # ]: 146 : SFX_IMPL_TOOLBOX_CONTROL( SwTbxInsertCtrl, SfxImageItem);
70 [ # # ]: 146 : SFX_IMPL_TOOLBOX_CONTROL( SwTbxAutoTextCtrl, SfxBoolItem );
71 : :
72 : 0 : SwTbxInsertCtrl::SwTbxInsertCtrl(
73 : : sal_uInt16 nSlotId,
74 : : sal_uInt16 nId,
75 : : ToolBox& rTbx ) :
76 : : SfxToolBoxControl( nSlotId, nId, rTbx ),
77 [ # # ]: 0 : nLastSlotId(FN_INSERT_CTRL == nSlotId ? FN_INSERT_TABLE : SID_INSERT_DIAGRAM)
78 : : {
79 [ # # ][ # # ]: 0 : rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
80 : 0 : }
81 : :
82 : 0 : SwTbxInsertCtrl::~SwTbxInsertCtrl()
83 : : {
84 [ # # ]: 0 : }
85 : :
86 : 0 : void SAL_CALL SwTbxInsertCtrl::update() throw (uno::RuntimeException)
87 : : {
88 [ # # ]: 0 : ToolBox& rTbx = GetToolBox();
89 [ # # ]: 0 : rtl::OUString aSlotURL( RTL_CONSTASCII_USTRINGPARAM( "slot:" ));
90 : 0 : aSlotURL += rtl::OUString::valueOf( sal_Int32( nLastSlotId ));
91 [ # # ][ # # ]: 0 : Image aImage = GetImage( m_xFrame, aSlotURL, hasBigImages() );
92 : :
93 [ # # ][ # # ]: 0 : rTbx.SetItemImage(GetId(), aImage);
94 [ # # ]: 0 : rTbx.Invalidate();
95 : :
96 [ # # ][ # # ]: 0 : SfxToolBoxControl::update();
97 : 0 : }
98 : :
99 : 0 : void SwTbxInsertCtrl::StateChanged( sal_uInt16 /*nSID*/,
100 : : SfxItemState eState,
101 : : const SfxPoolItem* pState )
102 : : {
103 : 0 : sal_uInt16 nId = GetId();
104 : 0 : GetToolBox().EnableItem( nId, (GetItemState(pState) != SFX_ITEM_DISABLED) );
105 : :
106 [ # # ]: 0 : if( eState == SFX_ITEM_AVAILABLE )
107 : : {
108 [ # # ][ # # ]: 0 : const SfxImageItem* pItem = PTR_CAST( SfxImageItem, pState );
109 [ # # ]: 0 : if(pItem)
110 : : {
111 : 0 : nLastSlotId = pItem->GetValue();
112 [ # # ]: 0 : if( nLastSlotId )
113 : 0 : nId = nLastSlotId;
114 : :
115 [ # # ]: 0 : rtl::OUString aSlotURL( RTL_CONSTASCII_USTRINGPARAM( "slot:" ));
116 : 0 : aSlotURL += rtl::OUString::valueOf( sal_Int32( nId ));
117 [ # # ]: 0 : ToolBox& rBox = GetToolBox();
118 [ # # ][ # # ]: 0 : Image aImage = GetImage( m_xFrame, aSlotURL, hasBigImages() );
119 [ # # ][ # # ]: 0 : rBox.SetItemImage(GetId(), aImage);
120 [ # # ][ # # ]: 0 : rBox.SetItemImageMirrorMode( GetId(), sal_False );
121 [ # # ][ # # ]: 0 : rBox.SetItemImageAngle( GetId(), pItem->GetRotation() );
[ # # ]
122 [ # # ][ # # ]: 0 : rBox.SetItemImageMirrorMode( GetId(), pItem->IsMirrored() );
[ # # ][ # # ]
123 : : }
124 : : }
125 : :
126 : 0 : }
127 : :
128 : 0 : SfxPopupWindow* SwTbxInsertCtrl::CreatePopupWindow()
129 : : {
130 [ # # ]: 0 : if(GetSlotId() == FN_INSERT_CTRL)
131 : : {
132 [ # # ]: 0 : OUString aToolBarResStr( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/insertbar" ));
133 [ # # ]: 0 : createAndPositionSubToolBar( aToolBarResStr );
134 : : }
135 : : else /* FN_INSERT_OBJ_CTRL */
136 : : {
137 [ # # ]: 0 : OUString aToolBarResStr( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/insertobjectbar" ));
138 [ # # ]: 0 : createAndPositionSubToolBar( aToolBarResStr );
139 : : }
140 : 0 : return NULL;
141 : : }
142 : :
143 : 0 : SfxPopupWindowType SwTbxInsertCtrl::GetPopupWindowType() const
144 : : {
145 [ # # ]: 0 : return nLastSlotId ? SFX_POPUPWINDOW_ONTIMEOUT : SFX_POPUPWINDOW_ONCLICK;
146 : : }
147 : :
148 : :
149 : 0 : void SwTbxInsertCtrl::Select( sal_Bool /*bMod1*/ )
150 : : {
151 [ # # ]: 0 : if( nLastSlotId )
152 : : {
153 : 0 : SfxViewShell* pCurSh( SfxViewShell::Current() );
154 : 0 : SfxDispatcher* pDispatch( 0 );
155 : :
156 [ # # ]: 0 : if ( pCurSh )
157 : : {
158 : 0 : SfxViewFrame* pViewFrame = pCurSh->GetViewFrame();
159 [ # # ]: 0 : if ( pViewFrame )
160 : 0 : pDispatch = pViewFrame->GetDispatcher();
161 : : }
162 : :
163 [ # # ]: 0 : if ( pDispatch )
164 : 0 : pDispatch->Execute(nLastSlotId);
165 : : }
166 : 0 : }
167 : :
168 : 0 : SwTbxAutoTextCtrl::SwTbxAutoTextCtrl(
169 : : sal_uInt16 nSlotId,
170 : : sal_uInt16 nId,
171 : : ToolBox& rTbx ) :
172 : : SfxToolBoxControl( nSlotId, nId, rTbx ),
173 : : pPopup(0),
174 : 0 : pView(0)
175 : : {
176 [ # # ][ # # ]: 0 : rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
177 : 0 : }
178 : :
179 : 0 : SwTbxAutoTextCtrl::~SwTbxAutoTextCtrl()
180 : : {
181 [ # # ]: 0 : DelPopup();
182 [ # # ]: 0 : }
183 : :
184 : 0 : SfxPopupWindow* SwTbxAutoTextCtrl::CreatePopupWindow()
185 : : {
186 : 0 : pView = ::GetActiveView();
187 [ # # # # ]: 0 : if(pView && !pView->GetDocShell()->IsReadOnly() &&
[ # # ][ # # ]
188 : 0 : !pView->GetWrtShell().HasReadonlySel() )
189 : : {
190 [ # # ]: 0 : ToolBox& rBox = GetToolBox();
191 : :
192 [ # # ][ # # ]: 0 : Rectangle aItemRect( rBox.GetItemRect( GetId() ) );
193 [ # # ]: 0 : Point aPt(rBox.OutputToScreenPixel(aItemRect.TopLeft()));
194 [ # # ]: 0 : aPt.X() += aItemRect.GetWidth()/2;
195 [ # # ]: 0 : aPt.Y() += aItemRect.GetHeight()/2;
196 [ # # ]: 0 : if(pView)
197 : : {
198 [ # # ]: 0 : Link aLnk = LINK(this, SwTbxAutoTextCtrl, PopupHdl);
199 : :
200 [ # # ][ # # ]: 0 : if (GetSlotId() == FN_INSERT_FIELD_CTRL)
201 : : {
202 [ # # ][ # # ]: 0 : pPopup = new PopupMenu(SW_RES(RID_INSERT_FIELD_CTRL));
203 : 0 : pPopup->SetSelectHdl(aLnk);
204 : :
205 [ # # ][ # # ]: 0 : if (::GetHtmlMode(pView->GetDocShell()) & HTMLMODE_ON)
[ # # ]
206 : : {
207 [ # # ][ # # ]: 0 : pPopup->RemoveItem(pPopup->GetItemPos(FN_INSERT_FLD_PGCOUNT));
208 [ # # ][ # # ]: 0 : pPopup->RemoveItem(pPopup->GetItemPos(FN_INSERT_FLD_TOPIC));
209 : : }
210 : : }
211 : : else
212 : : {
213 [ # # ][ # # ]: 0 : pPopup = new PopupMenu;
214 [ # # ]: 0 : SwGlossaryList* pGlossaryList = ::GetGlossaryList();
215 [ # # ]: 0 : sal_uInt16 nGroupCount = pGlossaryList->GetGroupCount();
216 [ # # ]: 0 : for(sal_uInt16 i = 1; i <= nGroupCount; i++)
217 : : {
218 : : // Gruppenname mit Pfad-Extension besorgen
219 [ # # ]: 0 : String sTitle;
220 [ # # ]: 0 : String sGroupName = pGlossaryList->GetGroupName(i - 1, sal_False, &sTitle);
221 [ # # ]: 0 : sal_uInt16 nBlockCount = pGlossaryList->GetBlockCount(i -1);
222 [ # # ]: 0 : if(nBlockCount)
223 : : {
224 : 0 : sal_uInt16 nIndex = 100 * (i);
225 : : // aber ohne extension einfuegen
226 [ # # ]: 0 : pPopup->InsertItem( i, sTitle);//sGroupName.GetToken(0, GLOS_DELIM));
227 [ # # ][ # # ]: 0 : PopupMenu* pSub = new PopupMenu;
228 : 0 : pSub->SetSelectHdl(aLnk);
229 [ # # ]: 0 : pPopup->SetPopupMenu(i, pSub);
230 [ # # ]: 0 : for(sal_uInt16 j = 0; j < nBlockCount; j++)
231 : : {
232 [ # # ]: 0 : String sEntry;
233 [ # # ]: 0 : String sLongName(pGlossaryList->GetBlockName(i - 1, j, sEntry));
234 [ # # ]: 0 : sEntry.AppendAscii(" - ");
235 [ # # ]: 0 : sEntry += sLongName;
236 [ # # ]: 0 : pSub->InsertItem(++nIndex, sEntry);
237 [ # # ][ # # ]: 0 : }
238 : : }
239 [ # # ][ # # ]: 0 : }
240 : : }
241 : : }
242 [ # # ]: 0 : ToolBox* pToolBox = &GetToolBox();
243 [ # # ]: 0 : sal_uInt16 nId = GetId();
244 [ # # ]: 0 : pToolBox->SetItemDown( nId, sal_True );
245 : :
246 : 0 : pPopup->Execute( pToolBox, pToolBox->GetItemRect( nId ),
247 : 0 : (pToolBox->GetAlign() == WINDOWALIGN_TOP || pToolBox->GetAlign() == WINDOWALIGN_BOTTOM) ?
248 [ # # ][ # # ]: 0 : POPUPMENU_EXECUTE_DOWN : POPUPMENU_EXECUTE_RIGHT );
[ # # # # ]
249 : :
250 [ # # ]: 0 : pToolBox->SetItemDown( nId, sal_False );
251 : : }
252 : 0 : GetToolBox().EndSelection();
253 : 0 : DelPopup();
254 : 0 : return 0;
255 : :
256 : : }
257 : :
258 : :
259 : 0 : SfxPopupWindowType SwTbxAutoTextCtrl::GetPopupWindowType() const
260 : : {
261 : 0 : return SFX_POPUPWINDOW_ONTIMEOUT;
262 : : }
263 : :
264 : 0 : void SwTbxAutoTextCtrl::StateChanged( sal_uInt16 nSID,
265 : : SfxItemState eState,
266 : : const SfxPoolItem* pState )
267 : : {
268 : 0 : GetToolBox().EnableItem( GetId(), (GetItemState(pState) != SFX_ITEM_DISABLED) );
269 [ # # ][ # # ]: 0 : if(FN_INSERT_FIELD_CTRL == nSID && eState >= SFX_ITEM_DEFAULT)
270 : : {
271 : 0 : GetToolBox().CheckItem( GetId(), ((SfxBoolItem*)pState)->GetValue() );
272 : : }
273 : 0 : }
274 : :
275 : 0 : IMPL_LINK(SwTbxAutoTextCtrl, PopupHdl, PopupMenu*, pMenu)
276 : : {
277 : 0 : sal_uInt16 nId = pMenu->GetCurItemId();
278 : :
279 [ # # ]: 0 : if ( GetSlotId() == FN_INSERT_FIELD_CTRL)
280 : : {
281 [ # # ]: 0 : Sequence< PropertyValue > aArgs;
282 : 0 : const char* pChar = 0;
283 [ # # # # : 0 : switch(nId)
# # # # ]
284 : : {
285 : : case FN_INSERT_FLD_DATE:
286 : 0 : pChar = ".uno:InsertDateField";
287 : 0 : break;
288 : : case FN_INSERT_FLD_TIME:
289 : 0 : pChar = ".uno:InsertTimeField";
290 : 0 : break;
291 : : case FN_INSERT_FLD_PGNUMBER:
292 : 0 : pChar = ".uno:InsertPageNumberField";
293 : 0 : break;
294 : : case FN_INSERT_FLD_PGCOUNT:
295 : 0 : pChar = ".uno:InsertPageCountField";
296 : 0 : break;
297 : : case FN_INSERT_FLD_TOPIC:
298 : 0 : pChar = ".uno:InsertTopicField";
299 : 0 : break;
300 : : case FN_INSERT_FLD_TITLE:
301 : 0 : pChar = ".uno:InsertTitleField";
302 : 0 : break;
303 : : case FN_INSERT_FLD_AUTHOR:
304 : 0 : pChar = ".uno:InsertAuthorField";
305 : 0 : break;
306 : : default:
307 : 0 : pChar = ".uno:InsertFieldCtrl";
308 : : }
309 [ # # ][ # # ]: 0 : Dispatch( rtl::OUString::createFromAscii( pChar ),aArgs );
310 : : }
311 : : else
312 : : {
313 : 0 : sal_uInt16 nBlock = nId / 100;
314 : :
315 [ # # ]: 0 : SwGlossaryList* pGlossaryList = ::GetGlossaryList();
316 [ # # ]: 0 : String sShortName;
317 [ # # ]: 0 : String sGroup = pGlossaryList->GetGroupName(nBlock - 1, sal_False);
318 [ # # ]: 0 : String sLongName(pGlossaryList->GetBlockName(nBlock - 1, nId - (100 * nBlock) - 1, sShortName));
319 : :
320 [ # # ]: 0 : SwGlossaryHdl* pGlosHdl = pView->GetGlosHdl();
321 [ # # ]: 0 : SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
322 : : OSL_ENSURE(pFact, "Dialogdiet fail!");
323 [ # # ]: 0 : ::GlossarySetActGroup fnSetActGroup = pFact->SetGlossaryActGroupFunc( DLG_RENAME_GLOS );
324 [ # # ]: 0 : if ( fnSetActGroup )
325 [ # # ]: 0 : (*fnSetActGroup)( sGroup );
326 [ # # ]: 0 : pGlosHdl->SetCurGroup(sGroup, sal_True);
327 [ # # ][ # # ]: 0 : pGlosHdl->InsertGlossary(sShortName);
[ # # ][ # # ]
328 : : }
329 : 0 : return 0;
330 : : }
331 : :
332 : 0 : void SwTbxAutoTextCtrl::DelPopup()
333 : : {
334 [ # # ]: 0 : if(pPopup)
335 : : {
336 [ # # ]: 0 : if (GetSlotId() != FN_INSERT_FIELD_CTRL)
337 : : {
338 [ # # ]: 0 : for( sal_uInt16 i = 0; i < pPopup->GetItemCount(); i ++ )
339 : : {
340 : 0 : PopupMenu* pSubPopup = pPopup->GetPopupMenu(pPopup->GetItemId(i));
341 [ # # ]: 0 : delete pSubPopup;
342 : : }
343 : : }
344 [ # # ]: 0 : delete pPopup;
345 : 0 : pPopup = 0;
346 : : }
347 : 0 : }
348 : :
349 : : /* Navigations-Popup */
350 : : // determine the order of the toolbox items
351 : : static sal_uInt16 aNavigationInsertIds[ NAVI_ENTRIES ] =
352 : : {
353 : : // -- first line
354 : : NID_TBL,
355 : : NID_FRM,
356 : : NID_GRF,
357 : : NID_OLE,
358 : : NID_PGE,
359 : : NID_OUTL,
360 : : NID_MARK,
361 : : NID_DRW,
362 : : NID_CTRL,
363 : : NID_PREV,
364 : : // -- second line
365 : : NID_REG,
366 : : NID_BKM,
367 : : NID_SEL,
368 : : NID_FTN,
369 : : NID_POSTIT,
370 : : NID_SRCH_REP,
371 : : NID_INDEX_ENTRY,
372 : : NID_TABLE_FORMULA,
373 : : NID_TABLE_FORMULA_ERROR,
374 : : NID_NEXT
375 : : };
376 : : static const char* aNavigationHelpIds[ NAVI_ENTRIES ] =
377 : : {
378 : : // -- first line
379 : : HID_NID_TBL,
380 : : HID_NID_FRM,
381 : : HID_NID_GRF,
382 : : HID_NID_OLE,
383 : : HID_NID_PGE,
384 : : HID_NID_OUTL,
385 : : HID_NID_MARK,
386 : : HID_NID_DRW,
387 : : HID_NID_CTRL,
388 : : HID_NID_PREV,
389 : : // -- second line
390 : : HID_NID_REG,
391 : : HID_NID_BKM,
392 : : HID_NID_SEL,
393 : : HID_NID_FTN,
394 : : HID_NID_POSTIT,
395 : : HID_NID_SRCH_REP,
396 : : HID_NID_INDEX_ENTRY,
397 : : HID_NID_TABLE_FORMULA,
398 : : HID_NID_TABLE_FORMULA_ERROR,
399 : : HID_NID_NEXT
400 : : };
401 : :
402 : 0 : SwScrollNaviPopup::SwScrollNaviPopup( sal_uInt16 nId, const Reference< XFrame >& rFrame )
403 : : : SfxPopupWindow(nId, rFrame, SW_RES(RID_SCROLL_NAVIGATION_WIN) ),
404 : : aToolBox(this, 0),
405 : : aSeparator(this, SW_RES(FL_SEP)),
406 : : aInfoField(this, SW_RES(FI_INFO)),
407 : : aIList(SW_RES(IL_VALUES)),
408 : : nFwdId(FN_START_OF_NEXT_PAGE),
409 [ # # ][ # # ]: 0 : nBackId(FN_START_OF_PREV_PAGE)
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # #
# # ]
410 : : {
411 : : sal_uInt16 i;
412 : :
413 [ # # ]: 0 : aToolBox.SetHelpId(HID_NAVI_VS);
414 [ # # ]: 0 : aToolBox.SetLineCount( 2 );
415 [ # # ]: 0 : aToolBox.SetOutStyle(TOOLBOX_STYLE_FLAT);
416 [ # # ]: 0 : for( i = 0; i < NID_COUNT; i++)
417 : : {
418 : 0 : sal_uInt16 nNaviId = aNavigationInsertIds[i];
419 [ # # ]: 0 : String sText;
420 : 0 : ToolBoxItemBits nTbxBits = 0;
421 [ # # ][ # # ]: 0 : if((NID_PREV != nNaviId) && (NID_NEXT != nNaviId))
422 : : {
423 : : // -2, there's no string for Next/Prev
424 : 0 : sal_uInt16 nResStr = ST_TBL - 2 + nNaviId - NID_START;
425 [ # # ][ # # ]: 0 : sText = String(SW_RES(nResStr));
[ # # ]
426 : 0 : nTbxBits = TIB_CHECKABLE;
427 : : }
428 [ # # ]: 0 : aToolBox.InsertItem(nNaviId, sText, nTbxBits);
429 [ # # ]: 0 : aToolBox.SetHelpId( nNaviId, aNavigationHelpIds[i] );
430 [ # # ]: 0 : }
431 [ # # ]: 0 : ApplyImageList();
432 [ # # ]: 0 : aToolBox.InsertBreak(NID_COUNT/2);
433 : : // don't call it before!
434 [ # # ]: 0 : FreeResource();
435 : :
436 : : // these are global strings
437 [ # # ]: 0 : for( i = 0; i < 2 * NID_COUNT; i++)
438 : : {
439 [ # # ][ # # ]: 0 : sQuickHelp[i] = String(SW_RES(STR_IMGBTN_START + i));
[ # # ]
440 : : }
441 : :
442 [ # # ]: 0 : Size aImgSize = aIList.GetImageSize();
443 : 0 : aImgSize.Width() += 5;
444 : 0 : aImgSize.Height() += 5;
445 [ # # ]: 0 : Size aSz = aToolBox.CalcWindowSizePixel(2);
446 [ # # ]: 0 : aToolBox.SetPosSizePixel( Point(), aSz );
447 [ # # ]: 0 : sal_uInt16 nItemId = SwView::GetMoveType();
448 [ # # ][ # # ]: 0 : aInfoField.SetText(aToolBox.GetItemText(nItemId));
449 [ # # ]: 0 : aToolBox.CheckItem( nItemId, sal_True );
450 [ # # ]: 0 : Size aFTSize(aInfoField.GetSizePixel());
451 [ # # ]: 0 : Size aSepSize(aSeparator.GetSizePixel());
452 : 0 : aSepSize.Width() = aSz.Width();
453 : :
454 : 0 : aSz.Height() += aFTSize.Height() + aSepSize.Height();
455 : : aInfoField.SetPosSizePixel(
456 [ # # ]: 0 : Point(0, aSz.Height() - aFTSize.Height()), Size(aSz.Width(), aFTSize.Height()));
457 : :
458 [ # # ]: 0 : aSeparator.SetSizePixel(aSepSize);
459 [ # # ]: 0 : aSeparator.SetPosPixel(Point(0, aSz.Height() - aFTSize.Height() - aSepSize.Height()));
460 : :
461 [ # # ]: 0 : SetOutputSizePixel(aSz);
462 [ # # ]: 0 : aToolBox.SetSelectHdl(LINK(this, SwScrollNaviPopup, SelectHdl));
463 [ # # ]: 0 : aToolBox.StartSelection();
464 [ # # ]: 0 : aToolBox.Show();
465 [ # # # # ]: 0 : }
466 : :
467 [ # # ][ # # ]: 0 : SwScrollNaviPopup::~SwScrollNaviPopup()
[ # # ][ # # ]
[ # # ]
468 : : {
469 [ # # ][ # # ]: 0 : }
[ # # ]
470 : :
471 : 0 : void SwScrollNaviPopup::DataChanged( const DataChangedEvent& rDCEvt )
472 : : {
473 [ # # # # ]: 0 : if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
[ # # ]
474 : 0 : (rDCEvt.GetFlags() & SETTINGS_STYLE) )
475 : 0 : ApplyImageList();
476 : :
477 : 0 : Window::DataChanged( rDCEvt );
478 : 0 : }
479 : :
480 : 0 : void SwScrollNaviPopup::ApplyImageList()
481 : : {
482 : 0 : ImageList& rImgLst = aIList;
483 [ # # ]: 0 : for(sal_uInt16 i = 0; i < NID_COUNT; i++)
484 : : {
485 : 0 : sal_uInt16 nNaviId = aNavigationInsertIds[i];
486 [ # # ]: 0 : aToolBox.SetItemImage(nNaviId, rImgLst.GetImage(nNaviId));
487 : : }
488 : 0 : }
489 : :
490 : 0 : SfxPopupWindow* SwScrollNaviPopup::Clone() const
491 : : {
492 [ # # ]: 0 : return new SwScrollNaviPopup( GetId(), GetFrame() );
493 : : }
494 : :
495 : 0 : IMPL_LINK(SwScrollNaviPopup, SelectHdl, ToolBox*, pSet)
496 : : {
497 : 0 : sal_uInt16 nSet = pSet->GetCurItemId();
498 [ # # ][ # # ]: 0 : if( nSet != NID_PREV && nSet != NID_NEXT )
499 : : {
500 : 0 : SwView::SetMoveType(nSet);
501 : 0 : aToolBox.SetItemText(NID_NEXT, sQuickHelp[nSet - NID_START]);
502 : 0 : aToolBox.SetItemText(NID_PREV, sQuickHelp[nSet - NID_START + NID_COUNT]);
503 : 0 : aInfoField.SetText(aToolBox.GetItemText(nSet));
504 : : //check the current button only
505 [ # # ]: 0 : for(sal_uInt16 i = 0; i < NID_COUNT; i++)
506 : : {
507 : 0 : sal_uInt16 nItemId = aToolBox.GetItemId( i );
508 : 0 : aToolBox.CheckItem( nItemId, nItemId == nSet );
509 : 0 : }
510 : : }
511 : : else
512 : : {
513 [ # # ]: 0 : SfxBoolItem aNext(FN_SCROLL_NEXT_PREV, NID_NEXT == nSet);
514 : 0 : Any a;
515 [ # # ]: 0 : Sequence< PropertyValue > aArgs( 1 );
516 [ # # ][ # # ]: 0 : aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ScrollNextPrev" ));
517 [ # # ]: 0 : aNext.QueryValue( a );
518 [ # # ]: 0 : aArgs[0].Value = a;
519 [ # # ]: 0 : SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( GetFrame()->getController(), UNO_QUERY ),
520 : : rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ScrollNextPrev" )),
521 [ # # ][ # # ]: 0 : aArgs );
[ # # ][ # # ]
[ # # ][ # # ]
522 : : }
523 : 0 : return 0;
524 : : }
525 : :
526 : 0 : void SwScrollNaviToolBox::MouseButtonUp( const MouseEvent& rMEvt )
527 : : {
528 : 0 : ToolBox::MouseButtonUp(rMEvt);
529 [ # # ]: 0 : if ( ((SwScrollNaviPopup*)GetParent())->IsInPopupMode() )
530 : 0 : ((SwScrollNaviPopup*)GetParent())->EndPopupMode( FLOATWIN_POPUPMODEEND_CLOSEALL );
531 : 0 : }
532 : :
533 : 0 : void SwScrollNaviToolBox::RequestHelp( const HelpEvent& rHEvt )
534 : : {
535 [ # # ]: 0 : SetItemText(NID_NEXT, SwScrollNaviPopup::GetQuickHelpText(sal_True));
536 [ # # ]: 0 : SetItemText(NID_PREV, SwScrollNaviPopup::GetQuickHelpText(sal_False));
537 : 0 : ToolBox::RequestHelp( rHEvt );
538 : :
539 : 0 : }
540 : :
541 : 0 : String SwScrollNaviPopup::GetQuickHelpText(sal_Bool bNext)
542 : : {
543 : 0 : sal_uInt16 nResId = STR_IMGBTN_START;
544 : 0 : nResId += SwView::GetMoveType() - NID_START;
545 [ # # ]: 0 : if(!bNext)
546 : 0 : nResId += NID_COUNT;
547 [ # # ]: 0 : return String(SW_RES(nResId));
548 : : }
549 : :
550 : 0 : void SwNaviImageButton::Click()
551 : : {
552 : : pPopup = new
553 : : SwScrollNaviPopup( FN_SCROLL_NAVIGATION,
554 [ # # ][ # # ]: 0 : m_xFrame );
555 [ # # ]: 0 : Point aPos = OutputToScreenPixel(Point(0,0));
556 [ # # ][ # # ]: 0 : Rectangle aRect(aPos, GetSizePixel());
557 [ # # ]: 0 : SetPopupWindow( pPopup );
558 [ # # ]: 0 : pPopup->StartPopupMode(aRect, FLOATWIN_POPUPMODE_LEFT|FLOATWIN_POPUPMODE_ALLOWTEAROFF);
559 : 0 : }
560 : :
561 : : //--------------------------------------------------------------------
562 : :
563 : 0 : void SwNaviImageButton::SetPopupWindow( SfxPopupWindow* pWindow )
564 : : {
565 : 0 : pPopupWindow = pWindow;
566 : 0 : pPopupWindow->SetPopupModeEndHdl( LINK( this, SwNaviImageButton, PopupModeEndHdl ));
567 : 0 : pPopupWindow->SetDeleteLink_Impl( LINK( this, SwNaviImageButton, ClosePopupWindow ));
568 : 0 : }
569 : :
570 : : //--------------------------------------------------------------------
571 : :
572 : 0 : IMPL_LINK_NOARG(SwNaviImageButton, PopupModeEndHdl)
573 : : {
574 [ # # ]: 0 : if ( pPopupWindow->IsVisible() )
575 : : {
576 : : // Replace floating window with popup window and destroy
577 : : // floating window instance.
578 [ # # ]: 0 : delete pFloatingWindow;
579 : 0 : pFloatingWindow = pPopupWindow;
580 : 0 : pPopupWindow = 0;
581 : : }
582 : : else
583 : : {
584 : : // Popup window has been closed by the user. No replacement, instance
585 : : // will destroy itself.
586 : 0 : pPopupWindow = 0;
587 : : }
588 : :
589 : 0 : return 1;
590 : : }
591 : :
592 : : //--------------------------------------------------------------------
593 : 0 : IMPL_LINK( SwNaviImageButton, ClosePopupWindow, SfxPopupWindow *, pWindow )
594 : : {
595 [ # # ]: 0 : if ( pWindow == pFloatingWindow )
596 : 0 : pFloatingWindow = 0;
597 : : else
598 : 0 : pPopupWindow = 0;
599 : :
600 : 0 : return 1;
601 : : }
602 : :
603 : 0 : void SwHlpImageButton::RequestHelp( const HelpEvent& rHEvt )
604 : : {
605 : :
606 [ # # ]: 0 : SetQuickHelpText(SwScrollNaviPopup::GetQuickHelpText(!bUp));
607 : :
608 : 0 : ImageButton::RequestHelp(rHEvt);
609 : 0 : }
610 : :
611 : 1318 : SwNaviImageButton::SwNaviImageButton(
612 : : Window* pParent,
613 : : const Reference< XFrame >& rFrame ) :
614 : : ImageButton(pParent, SW_RES(BTN_NAVI)),
615 : : pPopup(0),
616 : : aImage(SW_RES(IMG_BTN)),
617 : : sQuickText(SW_RES(ST_QUICK)),
618 : : pPopupWindow(0),
619 : : pFloatingWindow(0),
620 [ + - ][ + - ]: 1318 : m_xFrame( rFrame )
[ + - ]
621 : : {
622 [ + - ]: 1318 : FreeResource();
623 [ + - ][ + - ]: 1318 : SetStyle(GetStyle()|WB_NOPOINTERFOCUS);
624 [ + - ]: 1318 : SetQuickHelpText(sQuickText);
625 [ + - ]: 1318 : SetModeImage( aImage );
626 : 1318 : }
627 : :
628 : 6 : void SwNaviImageButton::DataChanged( const DataChangedEvent& rDCEvt )
629 : : {
630 [ + - - + ]: 12 : if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
[ - + ]
631 : 6 : (rDCEvt.GetFlags() & SETTINGS_STYLE) )
632 : 0 : SetModeImage( aImage );
633 : :
634 : 6 : Window::DataChanged( rDCEvt );
635 : 6 : }
636 : :
637 : : class SwZoomBox_Impl : public ComboBox
638 : : {
639 : : sal_uInt16 nSlotId;
640 : : sal_Bool bRelease;
641 : : uno::Reference< frame::XDispatchProvider > m_xDispatchProvider;
642 : :
643 : : public:
644 : : SwZoomBox_Impl(
645 : : Window* pParent,
646 : : sal_uInt16 nSlot,
647 : : const Reference< XDispatchProvider >& rDispatchProvider );
648 : : ~SwZoomBox_Impl();
649 : :
650 : : protected:
651 : : virtual void Select();
652 : : virtual long Notify( NotifyEvent& rNEvt );
653 : :
654 : : void ReleaseFocus();
655 : :
656 : : };
657 : :
658 : 0 : SwZoomBox_Impl::SwZoomBox_Impl(
659 : : Window* pParent,
660 : : sal_uInt16 nSlot,
661 : : const Reference< XDispatchProvider >& rDispatchProvider ):
662 : : ComboBox( pParent, SW_RES(RID_PVIEW_ZOOM_LB)),
663 : : nSlotId(nSlot),
664 : : bRelease(sal_True),
665 [ # # ]: 0 : m_xDispatchProvider( rDispatchProvider )
666 : : {
667 [ # # ]: 0 : EnableAutocomplete( sal_False );
668 : : sal_uInt16 aZoomValues[] =
669 : 0 : { 25, 50, 75, 100, 150, 200 };
670 [ # # ]: 0 : for(sal_uInt16 i = 0; i < sizeof(aZoomValues)/sizeof(sal_uInt16); i++)
671 : : {
672 [ # # ]: 0 : String sEntry = String::CreateFromInt32(aZoomValues[i]);
673 [ # # ]: 0 : sEntry += '%';
674 [ # # ]: 0 : InsertEntry(sEntry);
675 [ # # ]: 0 : }
676 : 0 : }
677 : :
678 : 0 : SwZoomBox_Impl::~SwZoomBox_Impl()
679 [ # # ]: 0 : {}
680 : :
681 : 0 : void SwZoomBox_Impl::Select()
682 : : {
683 [ # # ]: 0 : if ( !IsTravelSelect() )
684 : : {
685 [ # # ][ # # ]: 0 : String sEntry(comphelper::string::remove(GetText(), '%'));
[ # # ][ # # ]
686 [ # # ]: 0 : sal_uInt16 nZoom = (sal_uInt16)sEntry.ToInt32();
687 [ # # ]: 0 : if(nZoom < MINZOOM)
688 : 0 : nZoom = MINZOOM;
689 [ # # ]: 0 : if(nZoom > MAXZOOM)
690 : 0 : nZoom = MAXZOOM;
691 : :
692 [ # # ]: 0 : SfxUInt16Item aItem( nSlotId, nZoom );
693 [ # # ]: 0 : if ( FN_PREVIEW_ZOOM == nSlotId )
694 : : {
695 : 0 : Any a;
696 [ # # ]: 0 : Sequence< PropertyValue > aArgs( 1 );
697 [ # # ][ # # ]: 0 : aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PreviewZoom" ));
698 [ # # ]: 0 : aItem.QueryValue( a );
699 [ # # ]: 0 : aArgs[0].Value = a;
700 : : SfxToolBoxControl::Dispatch(
701 : : m_xDispatchProvider,
702 : : rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:PreviewZoom" )),
703 [ # # ][ # # ]: 0 : aArgs );
[ # # ]
704 : : }
705 : :
706 [ # # ][ # # ]: 0 : ReleaseFocus();
[ # # ]
707 : : }
708 : 0 : }
709 : :
710 : 0 : long SwZoomBox_Impl::Notify( NotifyEvent& rNEvt )
711 : : {
712 : 0 : long nHandled = 0;
713 : :
714 [ # # ]: 0 : if ( rNEvt.GetType() == EVENT_KEYINPUT )
715 : : {
716 : 0 : sal_uInt16 nCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode();
717 : :
718 [ # # # ]: 0 : switch ( nCode )
719 : : {
720 : : case KEY_RETURN:
721 : : case KEY_TAB:
722 : : {
723 [ # # ]: 0 : if ( KEY_TAB == nCode )
724 : 0 : bRelease = sal_False;
725 : : else
726 : 0 : nHandled = 1;
727 : 0 : Select();
728 : 0 : break;
729 : : }
730 : :
731 : : case KEY_ESCAPE:
732 : 0 : SetText( GetSavedValue() );
733 : 0 : ReleaseFocus();
734 : 0 : break;
735 : : }
736 : : }
737 [ # # ]: 0 : else if ( EVENT_LOSEFOCUS == rNEvt.GetType() )
738 : : {
739 : 0 : Window* pFocusWin = Application::GetFocusWindow();
740 [ # # ][ # # ]: 0 : if ( !HasFocus() && GetSubEdit() != pFocusWin )
[ # # ]
741 : 0 : SetText( GetSavedValue() );
742 : : }
743 : :
744 [ # # ]: 0 : return nHandled ? nHandled : ComboBox::Notify( rNEvt );
745 : : }
746 : :
747 : 0 : void SwZoomBox_Impl::ReleaseFocus()
748 : : {
749 [ # # ]: 0 : if ( !bRelease )
750 : : {
751 : 0 : bRelease = sal_True;
752 : 0 : return;
753 : : }
754 : 0 : SfxViewShell* pCurSh = SfxViewShell::Current();
755 : :
756 [ # # ]: 0 : if ( pCurSh )
757 : : {
758 : 0 : Window* pShellWnd = pCurSh->GetWindow();
759 : :
760 [ # # ]: 0 : if ( pShellWnd )
761 : 0 : pShellWnd->GrabFocus();
762 : : }
763 : : }
764 : :
765 [ # # ]: 73 : SFX_IMPL_TOOLBOX_CONTROL( SwPreviewZoomControl, SfxUInt16Item);
766 : :
767 : 0 : SwPreviewZoomControl::SwPreviewZoomControl(
768 : : sal_uInt16 nSlotId,
769 : : sal_uInt16 nId,
770 : : ToolBox& rTbx) :
771 : 0 : SfxToolBoxControl( nSlotId, nId, rTbx )
772 : : {
773 : 0 : }
774 : :
775 : 0 : SwPreviewZoomControl::~SwPreviewZoomControl()
776 : : {
777 [ # # ]: 0 : }
778 : :
779 : 0 : void SwPreviewZoomControl::StateChanged( sal_uInt16 /*nSID*/,
780 : : SfxItemState eState,
781 : : const SfxPoolItem* pState )
782 : : {
783 : 0 : sal_uInt16 nId = GetId();
784 : 0 : GetToolBox().EnableItem( nId, (GetItemState(pState) != SFX_ITEM_DISABLED) );
785 : 0 : SwZoomBox_Impl* pBox = (SwZoomBox_Impl*)GetToolBox().GetItemWindow( GetId() );
786 [ # # ]: 0 : if(SFX_ITEM_AVAILABLE <= eState)
787 : : {
788 [ # # ]: 0 : String sZoom(String::CreateFromInt32(((const SfxUInt16Item*)pState)->GetValue()));
789 [ # # ]: 0 : sZoom += '%';
790 [ # # ]: 0 : pBox->SetText(sZoom);
791 [ # # ][ # # ]: 0 : pBox->SaveValue();
792 : : }
793 : 0 : }
794 : :
795 : 0 : Window* SwPreviewZoomControl::CreateItemWindow( Window *pParent )
796 : : {
797 [ # # ][ # # ]: 0 : SwZoomBox_Impl* pRet = new SwZoomBox_Impl( pParent, GetSlotId(), Reference< XDispatchProvider >( m_xFrame->getController(), UNO_QUERY ));
[ # # ]
798 : 0 : return pRet;
799 : : }
800 : :
801 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|