LibreOffice Module svx (master)  1
layctrl.cxx
Go to the documentation of this file.
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 #include <vcl/customweld.hxx>
21 #include <vcl/event.hxx>
22 #include <vcl/settings.hxx>
23 #include <vcl/svapp.hxx>
24 #include <vcl/toolbox.hxx>
25 
26 #include <svx/strings.hrc>
27 #include <svx/layctrl.hxx>
28 #include <svx/dialmgr.hxx>
30 #include <svtools/colorcfg.hxx>
31 #include <svtools/toolbarmenu.hxx>
32 #include <com/sun/star/util/URLTransformer.hpp>
33 #include <com/sun/star/frame/XDispatchProvider.hpp>
34 
35 // namespaces
36 using namespace ::com::sun::star::uno;
37 using namespace ::com::sun::star::beans;
38 using namespace ::com::sun::star::util;
39 using namespace ::com::sun::star::frame;
40 
41 namespace {
42 
43 class TableWidget final : public weld::CustomWidgetController
44 {
45 private:
47  OUString maCommand;
48 
49  long nCol;
50  long nLine;
51 
52  static const long TABLE_CELLS_HORIZ;
53  static const long TABLE_CELLS_VERT;
54 
55  long mnTableCellWidth;
56  long mnTableCellHeight;
57 
58  long mnTableWidth;
59  long mnTableHeight;
60 
61  ::Color aFontColor;
62  ::Color aLineColor;
63  ::Color aFillColor;
64  ::Color aHighlightFillColor;
65  ::Color aBackgroundColor;
66 
67  void Update(long nNewCol, long nNewLine);
68  void InsertTable();
69 
70 public:
71  TableWidget(SvxTableToolBoxControl* pControl, const OUString& rCommand);
72 
73  virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
74 
75  virtual bool KeyInput(const KeyEvent&) override;
76  virtual bool MouseButtonDown(const MouseEvent&) override;
77  virtual bool MouseMove(const MouseEvent&) override;
78  virtual bool MouseButtonUp(const MouseEvent&) override;
79  virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
80 };
81 
82 class TableWindow final : public WeldToolbarPopup
83 {
84 private:
85  std::unique_ptr<weld::Button> mxTableButton;
86  std::unique_ptr<TableWidget> mxTableWidget;
87  std::unique_ptr<weld::CustomWeld> mxTableWidgetWin;
89 
90  DECL_LINK(SelectHdl, weld::Button&, void);
91 
92 public:
93  TableWindow( SvxTableToolBoxControl* pControl, weld::Widget* pParent,
94  const OUString& rCmd);
95  virtual void GrabFocus() override
96  {
97  mxTableWidget->GrabFocus();
98  }
99 };
100 
101 }
102 
103 const long TableWidget::TABLE_CELLS_HORIZ = 10;
104 const long TableWidget::TABLE_CELLS_VERT = 15;
105 
106 IMPL_LINK_NOARG(TableWindow, SelectHdl, weld::Button&, void)
107 {
108  mxControl->CloseAndShowTableDialog();
109 }
110 
111 TableWindow::TableWindow(SvxTableToolBoxControl* pControl, weld::Widget* pParent, const OUString& rCmd)
112  : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/tablewindow.ui", "TableWindow")
113  , mxTableButton(m_xBuilder->weld_button("moreoptions"))
114  , mxTableWidget(new TableWidget(pControl, rCmd))
115  , mxTableWidgetWin(new weld::CustomWeld(*m_xBuilder, "table", *mxTableWidget))
116  , mxControl(pControl)
117 {
118  mxTableButton->set_label( SvxResId( RID_SVXSTR_MORE ) );
119  mxTableButton->connect_clicked( LINK( this, TableWindow, SelectHdl ) );
120  mxTableButton->show();
121 }
122 
123 TableWidget::TableWidget(SvxTableToolBoxControl* pControl, const OUString& rCommand)
124  : mxControl(pControl)
125  , maCommand(rCommand)
126  , nCol(0)
127  , nLine(0)
128  , mnTableCellWidth(0)
129  , mnTableCellHeight(0)
130  , mnTableWidth(0)
131  , mnTableHeight(0)
132 {
134  svtools::ColorConfig aColorConfig;
135  aFontColor = aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor;
136  aLineColor = rStyles.GetShadowColor();
137  aFillColor = rStyles.GetWindowColor();
138  aHighlightFillColor = rStyles.GetHighlightColor();
139  aBackgroundColor = rStyles.GetFaceColor();
140 }
141 
142 void TableWidget::SetDrawingArea(weld::DrawingArea* pDrawingArea)
143 {
144  float fScaleFactor = pDrawingArea->get_ref_device().GetDPIScaleFactor();
145 
146  mnTableCellWidth = 15 * fScaleFactor;
147  mnTableCellHeight = 15 * fScaleFactor;
148 
149  mnTableWidth = TABLE_CELLS_HORIZ*mnTableCellWidth;
150  mnTableHeight = TABLE_CELLS_VERT*mnTableCellHeight;
151 
152  // + 1 to leave space to draw the right/bottom borders
153  Size aSize(mnTableWidth + 1, mnTableHeight + 1);
154  pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
155  CustomWidgetController::SetDrawingArea(pDrawingArea);
156  SetOutputSizePixel(aSize);
157 }
158 
159 bool TableWidget::MouseMove(const MouseEvent& rMEvt)
160 {
161  Point aPos = rMEvt.GetPosPixel();
162  Point aMousePos( aPos );
163 
164  long nNewCol = ( aMousePos.X() + mnTableCellWidth ) / mnTableCellWidth;
165  long nNewLine = ( aMousePos.Y() + mnTableCellHeight ) / mnTableCellHeight;
166 
167  Update( nNewCol, nNewLine );
168 
169  return true;
170 }
171 
172 bool TableWidget::KeyInput(const KeyEvent& rKEvt)
173 {
174  bool bHandled = false;
175  sal_uInt16 nModifier = rKEvt.GetKeyCode().GetModifier();
176  sal_uInt16 nKey = rKEvt.GetKeyCode().GetCode();
177  if ( !nModifier )
178  {
179  bHandled = true;
180  long nNewCol = nCol;
181  long nNewLine = nLine;
182  switch(nKey)
183  {
184  case KEY_UP:
185  if ( nNewLine > 1 )
186  nNewLine--;
187  else
188  mxControl->EndPopupMode();
189  break;
190  case KEY_DOWN:
191  if ( nNewLine < TABLE_CELLS_VERT )
192  {
193  nNewLine++;
194  if ( nNewCol == 0 )
195  nNewCol = 1;
196  }
197  else
198  mxControl->CloseAndShowTableDialog();
199  break;
200  case KEY_LEFT:
201  if ( nNewCol > 1 )
202  nNewCol--;
203  else
204  mxControl->EndPopupMode();
205  break;
206  case KEY_RIGHT:
207  if ( nNewCol < TABLE_CELLS_HORIZ )
208  {
209  nNewCol++;
210  if ( nNewLine == 0 )
211  nNewLine = 1;
212  }
213  else
214  mxControl->CloseAndShowTableDialog();
215  break;
216  case KEY_ESCAPE:
217  mxControl->EndPopupMode();
218  break;
219  case KEY_RETURN:
220  InsertTable();
221  mxControl->EndPopupMode();
222  return true;
223  default:
224  bHandled = false;
225  }
226  if ( bHandled )
227  {
228  Update( nNewCol, nNewLine );
229  }
230  }
231  else if (KEY_MOD1 == nModifier && KEY_RETURN == nKey)
232  {
233  InsertTable();
234  mxControl->EndPopupMode();
235  return true;
236  }
237 
238  return bHandled;
239 }
240 
241 bool TableWidget::MouseButtonUp(const MouseEvent&)
242 {
243  InsertTable();
244  mxControl->EndPopupMode();
245  return true;
246 }
247 
248 bool TableWidget::MouseButtonDown(const MouseEvent&)
249 {
250  return true;
251 }
252 
253 void TableWidget::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&)
254 {
255  rRenderContext.Push(PushFlags::FONT);
256 
257  rRenderContext.SetBackground( aBackgroundColor );
258  vcl::Font aFont = rRenderContext.GetFont();
259  aFont.SetColor( aFontColor );
260  aFont.SetFillColor( aBackgroundColor );
261  aFont.SetTransparent( false );
262  rRenderContext.SetFont( aFont );
263 
264  const long nSelectionWidth = nCol * mnTableCellWidth;
265  const long nSelectionHeight = nLine * mnTableCellHeight;
266 
267  // the non-selected parts of the table
268  rRenderContext.SetLineColor(aLineColor);
269  rRenderContext.SetFillColor(aFillColor);
270  rRenderContext.DrawRect(tools::Rectangle(nSelectionWidth, 0, mnTableWidth, nSelectionHeight));
271  rRenderContext.DrawRect(tools::Rectangle(0, nSelectionHeight, nSelectionWidth, mnTableHeight));
272  rRenderContext.DrawRect(tools::Rectangle(nSelectionWidth, nSelectionHeight, mnTableWidth, mnTableHeight));
273 
274  // the selection
275  if (nCol > 0 && nLine > 0)
276  {
277  rRenderContext.SetFillColor(aHighlightFillColor);
278  rRenderContext.DrawRect(tools::Rectangle(0, 0, nSelectionWidth, nSelectionHeight));
279  }
280 
281  // lines inside of the table
282  rRenderContext.SetLineColor(aLineColor);
283  for (long i = 1; i < TABLE_CELLS_VERT; ++i)
284  {
285  rRenderContext.DrawLine(Point(0, i*mnTableCellHeight),
286  Point(mnTableWidth, i*mnTableCellHeight));
287  }
288 
289  for (long i = 1; i < TABLE_CELLS_HORIZ; ++i)
290  {
291  rRenderContext.DrawLine(Point( i*mnTableCellWidth, 0),
292  Point( i*mnTableCellWidth, mnTableHeight));
293  }
294 
295  // the text near the mouse cursor telling the table dimensions
296  if (!nCol || !nLine)
297  {
298  rRenderContext.Pop();
299  return;
300  }
301 
302  OUString aText = OUString::number( nCol ) + " x " + OUString::number( nLine );
303  if (maCommand == ".uno:ShowMultiplePages")
304  {
305  aText += " " + SvxResId(RID_SVXSTR_PAGES);
306  }
307 
308  Size aTextSize(rRenderContext.GetTextWidth(aText), rRenderContext.GetTextHeight());
309 
310  long nTextX = nSelectionWidth + mnTableCellWidth;
311  long nTextY = nSelectionHeight + mnTableCellHeight;
312  const long nTipBorder = 2;
313 
314  if (aTextSize.Width() + mnTableCellWidth + 2 * nTipBorder < nSelectionWidth)
315  nTextX = nSelectionWidth - mnTableCellWidth - aTextSize.Width();
316 
317  if (aTextSize.Height() + mnTableCellHeight + 2 * nTipBorder < nSelectionHeight)
318  nTextY = nSelectionHeight - mnTableCellHeight - aTextSize.Height();
319 
320  rRenderContext.SetLineColor(aLineColor);
321  rRenderContext.SetFillColor(aBackgroundColor);
322  rRenderContext.DrawRect(tools::Rectangle(nTextX - 2 * nTipBorder,
323  nTextY - 2 * nTipBorder,
324  nTextX + aTextSize.Width() + nTipBorder,
325  nTextY + aTextSize.Height() + nTipBorder));
326 
327  // #i95350# force RTL output
328  if (IsRTLEnabled())
329  aText = u"\u202D" + aText;
330 
331  rRenderContext.DrawText(Point(nTextX, nTextY), aText);
332 
333  rRenderContext.Pop();
334 }
335 
336 void TableWidget::InsertTable()
337 {
338  if (nCol && nLine)
339  {
340  Sequence< PropertyValue > aArgs( 2 );
341  aArgs[0].Name = "Columns";
342  aArgs[0].Value <<= sal_Int16( nCol );
343  aArgs[1].Name = "Rows";
344  aArgs[1].Value <<= sal_Int16( nLine );
345 
346  mxControl->TableDialog( aArgs );
347  }
348 }
349 
350 void TableWidget::Update( long nNewCol, long nNewLine )
351 {
352  if ( nNewCol < 0 || nNewCol > TABLE_CELLS_HORIZ )
353  nNewCol = 0;
354 
355  if ( nNewLine < 0 || nNewLine > TABLE_CELLS_VERT )
356  nNewLine = 0;
357 
358  if ( nNewCol != nCol || nNewLine != nLine )
359  {
360  nCol = nNewCol;
361  nLine = nNewLine;
362  Invalidate(tools::Rectangle(0, 0, mnTableWidth, mnTableHeight));
363  }
364 }
365 
366 void SvxTableToolBoxControl::TableDialog( const Sequence< PropertyValue >& rArgs )
367 {
368  Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
369  if ( xDispatchProvider.is() )
370  {
371  css::util::URL aTargetURL;
372  Reference < XURLTransformer > xTrans( URLTransformer::create(::comphelper::getProcessComponentContext()) );
373  aTargetURL.Complete = m_aCommandURL;
374  xTrans->parseStrict( aTargetURL );
375 
376  Reference< XDispatch > xDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 );
377  if ( xDispatch.is() )
378  xDispatch->dispatch( aTargetURL, rArgs );
379  }
380 }
381 
383 {
384  // close the toolbar tool
385  EndPopupMode();
386 
387  // and open the table dialog instead
388  TableDialog( Sequence< PropertyValue >() );
389 }
390 
391 namespace {
392 
393 class ColumnsWidget final : public weld::CustomWidgetController
394 {
395 private:
396  static constexpr long WIDTH = 5;
397 
399  weld::SpinButton& mrSpinButton;
400 
401  ::Color aLineColor;
402  ::Color aHighlightLineColor;
403  ::Color aFillColor;
404  ::Color aHighlightFillColor;
405  ::Color aFaceColor;
406  long nCol;
407  long nMX;
408  bool m_bMod1;
409 
410  DECL_LINK(ValueChangedHdl, weld::SpinButton&, void);
411  DECL_LINK(ActivateHdl, weld::Entry&, bool);
412 
413  void InsertColumns();
414  void UpdateSize_Impl( long nNewCol );
415 public:
416  ColumnsWidget(SvxColumnsToolBoxControl* pControl, weld::SpinButton& rSpinButton);
417 
418  virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
419 
420  virtual bool KeyInput(const KeyEvent&) override;
421  virtual bool MouseButtonDown(const MouseEvent&) override;
422  virtual bool MouseMove(const MouseEvent&) override;
423  virtual bool MouseButtonUp(const MouseEvent&) override;
424  virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
425 };
426 
427 
428 class ColumnsWindow final : public WeldToolbarPopup
429 {
430 private:
431  std::unique_ptr<weld::SpinButton> mxSpinButton;
432  std::unique_ptr<ColumnsWidget> mxColumnsWidget;
433  std::unique_ptr<weld::CustomWeld> mxColumnsWidgetWin;
435 
436 public:
437  ColumnsWindow(SvxColumnsToolBoxControl* pControl, weld::Widget* pParent);
438 
439  virtual void GrabFocus() override
440  {
441  mxColumnsWidget->GrabFocus();
442  }
443 };
444 
445 }
446 
447 ColumnsWindow::ColumnsWindow(SvxColumnsToolBoxControl* pControl, weld::Widget* pParent)
448  : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/columnswindow.ui", "ColumnsWindow")
449  , mxSpinButton(m_xBuilder->weld_spin_button("spinbutton"))
450  , mxColumnsWidget(new ColumnsWidget(pControl, *mxSpinButton))
451  , mxColumnsWidgetWin(new weld::CustomWeld(*m_xBuilder, "columns", *mxColumnsWidget))
452  , mxControl(pControl)
453 {
454 }
455 
456 ColumnsWidget::ColumnsWidget(SvxColumnsToolBoxControl* pControl, weld::SpinButton& rSpinButton)
457  : mxControl(pControl)
458  , mrSpinButton(rSpinButton)
459  , nCol(1)
460  , nMX(0)
461  , m_bMod1(false)
462 {
463  mrSpinButton.connect_value_changed(LINK(this, ColumnsWidget, ValueChangedHdl));
464  mrSpinButton.connect_activate(LINK(this, ColumnsWidget, ActivateHdl));
465 
467  svtools::ColorConfig aColorConfig;
468  aLineColor = aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor;
469  aHighlightLineColor = rStyles.GetHighlightTextColor();
470  aFillColor = rStyles.GetWindowColor();
471  aHighlightFillColor = rStyles.GetHighlightColor();
472  aFaceColor = rStyles.GetFaceColor();
473 }
474 
475 IMPL_LINK_NOARG(ColumnsWidget, ValueChangedHdl, weld::SpinButton&, void)
476 {
477  UpdateSize_Impl(mrSpinButton.get_value());
478 }
479 
480 IMPL_LINK_NOARG(ColumnsWidget, ActivateHdl, weld::Entry&, bool)
481 {
482  InsertColumns();
483  mxControl->EndPopupMode();
484  return true;
485 }
486 
487 void ColumnsWidget::SetDrawingArea(weld::DrawingArea* pDrawingArea)
488 {
489  OutputDevice& rDevice = pDrawingArea->get_ref_device();
490  Size aLogicSize = rDevice.LogicToPixel( Size( 95, 155 ), MapMode( MapUnit::Map10thMM ) );
491  nMX = aLogicSize.Width();
492  Size aSize(nMX*WIDTH-1, aLogicSize.Height());
493  pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
494  CustomWidgetController::SetDrawingArea(pDrawingArea);
495  SetOutputSizePixel(aSize);
496 }
497 
498 bool ColumnsWidget::MouseMove(const MouseEvent& rMEvt)
499 {
500  Point aPos = rMEvt.GetPosPixel();
501 
502  long nNewCol = 1;
503  if ( aPos.X() > 0 )
504  nNewCol = aPos.X() / nMX + 1;
505  if ( nNewCol > 20 )
506  nNewCol = 20;
507  UpdateSize_Impl( nNewCol );
508 
509  return true;
510 }
511 
512 void ColumnsWidget::UpdateSize_Impl( long nNewCol )
513 {
514  if ( nNewCol != nCol )
515  {
516  Size aWinSize = GetOutputSizePixel();
517 
518  Invalidate( tools::Rectangle( 0, aWinSize.Height() - 2,
519  aWinSize.Width(), aWinSize.Height() ) );
520 
521  long nMinCol = 0, nMaxCol = 0;
522 
523  if ( nNewCol < nCol )
524  {
525  nMinCol = nNewCol;
526  nMaxCol = nCol;
527  }
528  else
529  {
530  nMinCol = nCol;
531  nMaxCol = nNewCol;
532  }
533 
534  Invalidate( tools::Rectangle( nMinCol*nMX-1, 0,
535  nMaxCol*nMX+1, aWinSize.Height() - 2 ) );
536  nCol = nNewCol;
537  mrSpinButton.set_value(nCol);
538  }
539 }
540 
541 bool ColumnsWidget::MouseButtonDown(const MouseEvent&)
542 {
543  return true;
544 }
545 
546 bool ColumnsWidget::KeyInput(const KeyEvent& rKEvt)
547 {
548  bool bHandled = false;
549  sal_uInt16 nModifier = rKEvt.GetKeyCode().GetModifier();
550  sal_uInt16 nKey = rKEvt.GetKeyCode().GetCode();
551  if(!nModifier)
552  {
553  if( KEY_LEFT == nKey || KEY_RIGHT == nKey ||
554  KEY_RETURN == nKey ||KEY_ESCAPE == nKey ||
555  KEY_UP == nKey)
556  {
557  bHandled = true;
558  long nNewCol = nCol;
559  switch(nKey)
560  {
561  case KEY_LEFT :
562  if(nNewCol)
563  nNewCol--;
564  break;
565  case KEY_RIGHT :
566  nNewCol++;
567  break;
568  case KEY_RETURN :
569  InsertColumns();
570  mxControl->EndPopupMode();
571  break;
572  case KEY_ESCAPE :
573  case KEY_UP :
574  mxControl->EndPopupMode();
575  break;
576  }
577  UpdateSize_Impl( nNewCol );
578  }
579  }
580  else if(KEY_MOD1 == nModifier && KEY_RETURN == nKey)
581  {
582  m_bMod1 = true;
583  InsertColumns();
584  mxControl->EndPopupMode();
585  }
586  return bHandled;
587 }
588 
589 bool ColumnsWidget::MouseButtonUp(const MouseEvent&)
590 {
591  InsertColumns();
592  mxControl->EndPopupMode();
593  return true;
594 }
595 
596 void ColumnsWidget::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&)
597 {
598  rRenderContext.Push(PushFlags::FONT);
599 
600  rRenderContext.SetBackground();
601  vcl::Font aFont( rRenderContext.GetFont() );
602  aFont.SetColor( aLineColor );
603  aFont.SetFillColor( aFaceColor );
604  aFont.SetTransparent( false );
605  rRenderContext.SetFont( aFont );
606 
607  long i;
608  long nLineWidth;
609  Size aSize(GetOutputSizePixel());
610 
611  for (i = 0; i < WIDTH; i++)
612  {
613  if (i < nCol)
614  {
615  rRenderContext.SetLineColor(aHighlightLineColor);
616  rRenderContext.SetFillColor(aHighlightFillColor);
617  }
618  else
619  {
620  rRenderContext.SetLineColor(aLineColor);
621  rRenderContext.SetFillColor(aFillColor);
622  }
623 
624  rRenderContext.DrawRect(tools::Rectangle(i * nMX - 1, -1, i * nMX + nMX, aSize.Height() - 1));
625 
626  long j = 4;
627  while (j < aSize.Height() - 4)
628  {
629  if (!(j % 16))
630  nLineWidth = 10;
631  else
632  nLineWidth = 4;
633  rRenderContext.DrawLine(Point(i * nMX + 4, j), Point(i * nMX + nMX - nLineWidth - 4, j));
634  j += 4;
635  }
636  }
637 
638  rRenderContext.SetLineColor();
639  rRenderContext.SetFillColor(aFaceColor);
640 
641  rRenderContext.DrawRect(tools::Rectangle(0,
642  aSize.Height() - 2,
643  aSize.Width() / 2 - 1,
644  aSize.Height()));
645 
646  rRenderContext.DrawRect(tools::Rectangle(aSize.Width() / 2,
647  aSize.Height() - 2,
648  aSize.Width(),
649  aSize.Height()));
650 
651  rRenderContext.SetLineColor(aLineColor);
652  rRenderContext.SetFillColor();
653  rRenderContext.DrawRect(tools::Rectangle( 0, 0, aSize.Width() - 1, aSize.Height() - 1));
654 
655  rRenderContext.Pop();
656 }
657 
658 void SvxColumnsToolBoxControl::InsertColumns(const Sequence< PropertyValue >& rArgs)
659 {
660  Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
661  if ( xDispatchProvider.is() )
662  {
663  css::util::URL aTargetURL;
664  Reference < XURLTransformer > xTrans( URLTransformer::create(::comphelper::getProcessComponentContext()) );
665  aTargetURL.Complete = m_aCommandURL;
666  xTrans->parseStrict( aTargetURL );
667 
668  Reference< XDispatch > xDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 );
669  if ( xDispatch.is() )
670  xDispatch->dispatch( aTargetURL, rArgs );
671  }
672 }
673 
674 void ColumnsWidget::InsertColumns()
675 {
676  if (nCol)
677  {
678  Sequence< PropertyValue > aArgs( 2 );
679  aArgs[0].Name = "Columns";
680  aArgs[0].Value <<= sal_Int16( nCol );
681  aArgs[1].Name = "Modifier";
682  aArgs[1].Value <<= sal_Int16( m_bMod1 ? KEY_MOD1 : 0 );
683  mxControl->InsertColumns(aArgs);
684  }
685 }
686 
687 SvxTableToolBoxControl::SvxTableToolBoxControl(const css::uno::Reference<css::uno::XComponentContext>& rContext)
688  : PopupWindowController(rContext, nullptr, OUString())
689 {
690 }
691 
692 void SvxTableToolBoxControl::initialize( const css::uno::Sequence< css::uno::Any >& rArguments )
693 {
694  PopupWindowController::initialize(rArguments);
695 
696  ToolBox* pToolBox = nullptr;
697  sal_uInt16 nId = 0;
698  if (getToolboxId(nId, &pToolBox) && pToolBox->GetItemCommand(nId) == m_aCommandURL)
699  pToolBox->SetItemBits(nId, ToolBoxItemBits::DROPDOWNONLY | pToolBox->GetItemBits(nId));
700 }
701 
703 {
704 }
705 
706 std::unique_ptr<WeldToolbarPopup> SvxTableToolBoxControl::weldPopupWindow()
707 {
708  return std::make_unique<TableWindow>(this, m_pToolbar, m_aCommandURL);
709 }
710 
712 {
713  ToolBox* pToolBox = nullptr;
714  sal_uInt16 nId = 0;
715  bool bToolBox = getToolboxId(nId, &pToolBox);
716 
717  mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
718  std::make_unique<TableWindow>(this, pParent->GetFrameWeld(), m_aCommandURL));
719 
720  mxInterimPopover->SetText(bToolBox ? pToolBox->GetItemText(nId) : OUString());
721 
722  mxInterimPopover->Show();
723 
724  return mxInterimPopover;
725 }
726 
728 {
729  return "com.sun.star.comp.svx.TableToolBoxControl";
730 }
731 
733 {
734  return { "com.sun.star.frame.ToolbarController" };
735 }
736 
737 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
739  css::uno::XComponentContext* rContext,
740  css::uno::Sequence<css::uno::Any> const & )
741 {
742  return cppu::acquire(new SvxTableToolBoxControl(rContext));
743 }
744 
745 SvxColumnsToolBoxControl::SvxColumnsToolBoxControl(const css::uno::Reference<css::uno::XComponentContext>& rContext)
746  : PopupWindowController(rContext, nullptr, OUString())
747 {
748 }
749 
750 void SvxColumnsToolBoxControl::initialize( const css::uno::Sequence< css::uno::Any >& rArguments )
751 {
752  PopupWindowController::initialize(rArguments);
753 
754  ToolBox* pToolBox = nullptr;
755  sal_uInt16 nId = 0;
756  if (getToolboxId(nId, &pToolBox) && pToolBox->GetItemCommand(nId) == m_aCommandURL)
757  pToolBox->SetItemBits(nId, ToolBoxItemBits::DROPDOWNONLY | pToolBox->GetItemBits(nId));
758 }
759 
761 {
762 }
763 
764 std::unique_ptr<WeldToolbarPopup> SvxColumnsToolBoxControl::weldPopupWindow()
765 {
766  return std::make_unique<ColumnsWindow>(this, m_pToolbar);
767 }
768 
770 {
771  ToolBox* pToolBox = nullptr;
772  sal_uInt16 nId = 0;
773  bool bToolBox = getToolboxId(nId, &pToolBox);
774 
775  mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
776  std::make_unique<ColumnsWindow>(this, pParent->GetFrameWeld()));
777 
778  mxInterimPopover->SetText(bToolBox ? pToolBox->GetItemText(nId) : OUString());
779 
780  mxInterimPopover->Show();
781 
782  return mxInterimPopover;
783 }
784 
786 {
787  return "com.sun.star.comp.svx.ColumnsToolBoxControl";
788 }
789 
791 {
792  return { "com.sun.star.frame.ToolbarController" };
793 }
794 
795 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
797  css::uno::XComponentContext* rContext,
798  css::uno::Sequence<css::uno::Any> const & )
799 {
800  return cppu::acquire(new SvxColumnsToolBoxControl(rContext));
801 }
802 
803 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
long Width() const
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, MetricVector *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
const Color & GetShadowColor() const
void SetFillColor(const Color &)
void CloseAndShowTableDialog()
Definition: layctrl.cxx:382
const Color & GetHighlightTextColor() const
long Height() const
const OUString & GetItemText(sal_uInt16 nItemId) const
void InsertColumns(const css::uno::Sequence< css::beans::PropertyValue > &rArgs)
Definition: layctrl.cxx:658
ToolBoxItemBits GetItemBits(sal_uInt16 nItemId) const
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
const Color & GetFaceColor() const
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_svx_ColumnsToolBoxControl_get_implementation(css::uno::XComponentContext *rContext, css::uno::Sequence< css::uno::Any > const &)
Definition: layctrl.cxx:796
virtual VclPtr< vcl::Window > createVclPopupWindow(vcl::Window *pParent) override
Definition: layctrl.cxx:769
virtual bool MouseButtonUp(const MouseEvent &)
css::uno::Reference< css::lang::XComponent > m_xFrame
sal_Int16 nId
sal_uInt16 GetCode() const
virtual bool MouseMove(const MouseEvent &)
virtual std::unique_ptr< WeldToolbarPopup > weldPopupWindow() override
Definition: layctrl.cxx:706
constexpr sal_uInt16 KEY_UP
const Color & GetHighlightColor() const
weld::Window * GetFrameWeld() const
void SetBackground()
OUString SvxResId(const char *pId)
Definition: dialmgr.cxx:28
const vcl::Font & GetFont() const
virtual ~SvxTableToolBoxControl() override
Definition: layctrl.cxx:702
sal_uInt16 GetModifier() const
virtual OutputDevice & get_ref_device()=0
void DrawLine(const Point &rStartPt, const Point &rEndPt)
void DrawRect(const tools::Rectangle &rRect)
constexpr sal_uInt16 KEY_DOWN
SvxColumnsToolBoxControl(const css::uno::Reference< css::uno::XComponentContext > &rContext)
Definition: layctrl.cxx:745
void SetLineColor()
virtual OUString SAL_CALL getImplementationName() override
Definition: layctrl.cxx:727
int i
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: layctrl.cxx:732
virtual ~SvxColumnsToolBoxControl() override
Definition: layctrl.cxx:760
void SetItemBits(sal_uInt16 nItemId, ToolBoxItemBits nBits)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_svx_TableToolBoxControl_get_implementation(css::uno::XComponentContext *rContext, css::uno::Sequence< css::uno::Any > const &)
Definition: layctrl.cxx:738
void SetFillColor()
DECL_LINK(FocusHdl, weld::Widget &, void)
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &rArguments) override
Definition: layctrl.cxx:750
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: layctrl.cxx:790
IMPL_LINK_NOARG(TableWindow, SelectHdl, weld::Button &, void)
Definition: layctrl.cxx:106
virtual bool KeyInput(const KeyEvent &)
virtual std::unique_ptr< WeldToolbarPopup > weldPopupWindow() override
Definition: layctrl.cxx:764
VclPtr< InterimToolbarPopup > mxInterimPopover
long GetTextHeight() const
sal_Int32 nLineWidth
float GetDPIScaleFactor() const
constexpr sal_uInt16 KEY_RETURN
void SetColor(const Color &)
virtual VclPtr< vcl::Window > createVclPopupWindow(vcl::Window *pParent) override
Definition: layctrl.cxx:711
constexpr sal_uInt16 KEY_RIGHT
Point LogicToPixel(const Point &rLogicPt) const
const vcl::KeyCode & GetKeyCode() const
OUString GetItemCommand(sal_uInt16 nItemId) const
Reference< XDispatch > xDispatch
DECL_LINK(DragBeginHdl, weld::DrawingArea &, bool)
ColorConfigValue GetColorValue(ColorConfigEntry eEntry, bool bSmart=true) const
constexpr sal_uInt16 KEY_ESCAPE
void SetFont(const vcl::Font &rNewFont)
virtual bool MouseButtonDown(const MouseEvent &)
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &rArguments) override
Definition: layctrl.cxx:692
void SetTransparent(bool bTransparent)
void TableDialog(const css::uno::Sequence< css::beans::PropertyValue > &rArgs)
Definition: layctrl.cxx:366
static VclPtr< reference_type > Create(Arg &&...arg)
const sal_uInt16 WIDTH
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea)
Reference< XComponentContext > getProcessComponentContext()
const Color & GetWindowColor() const
const Point & GetPosPixel() const
virtual OUString SAL_CALL getImplementationName() override
Definition: layctrl.cxx:785
long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
SvxTableToolBoxControl(const css::uno::Reference< css::uno::XComponentContext > &rContext)
Definition: layctrl.cxx:687
OUString aTargetURL
constexpr sal_uInt16 KEY_LEFT
virtual void set_size_request(int nWidth, int nHeight)=0
void Push(PushFlags nFlags=PushFlags::ALL)
virtual void GrabFocus()=0
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)=0