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