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 <utility>
21#include <vcl/customweld.hxx>
22#include <vcl/event.hxx>
23#include <vcl/settings.hxx>
24#include <vcl/svapp.hxx>
25#include <vcl/toolbox.hxx>
26
27#include <svx/strings.hrc>
28#include <layctrl.hxx>
29#include <svx/dialmgr.hxx>
32#include <svtools/colorcfg.hxx>
34#include <com/sun/star/util/URLTransformer.hpp>
35#include <com/sun/star/frame/XDispatchProvider.hpp>
36
37// namespaces
38using namespace ::com::sun::star::uno;
39using namespace ::com::sun::star::beans;
40using namespace ::com::sun::star::util;
41using namespace ::com::sun::star::frame;
42
43namespace {
44
45class TableWidget final : public weld::CustomWidgetController
46{
47private:
49 OUString maCommand;
50
51 tools::Long nCol;
52 tools::Long nLine;
53
54 static const tools::Long TABLE_CELLS_HORIZ;
55 static const tools::Long TABLE_CELLS_VERT;
56
57 tools::Long mnTableCellWidth;
58 tools::Long mnTableCellHeight;
59
60 tools::Long mnTableWidth;
61 tools::Long mnTableHeight;
62
63 ::Color aFontColor;
64 ::Color aLineColor;
65 ::Color aFillColor;
66 ::Color aHighlightFillColor;
67 ::Color aBackgroundColor;
68
69 void Update(tools::Long nNewCol, tools::Long nNewLine);
70 void InsertTable();
71
72public:
73 TableWidget(SvxTableToolBoxControl* pControl, OUString aCommand);
74
75 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
76
77 virtual bool KeyInput(const KeyEvent&) override;
78 virtual bool MouseButtonDown(const MouseEvent&) override;
79 virtual bool MouseMove(const MouseEvent&) override;
80 virtual bool MouseButtonUp(const MouseEvent&) override;
81 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
82};
83
84class TableWindow final : public WeldToolbarPopup
85{
86private:
87 std::unique_ptr<weld::Button> mxTableButton;
88 std::unique_ptr<TableWidget> mxTableWidget;
89 std::unique_ptr<weld::CustomWeld> mxTableWidgetWin;
91
92 DECL_LINK(SelectHdl, weld::Button&, void);
93
94public:
95 TableWindow( SvxTableToolBoxControl* pControl, weld::Widget* pParent,
96 const OUString& rCmd);
97 virtual void GrabFocus() override
98 {
99 mxTableWidget->GrabFocus();
100 }
101};
102
103}
104
105const tools::Long TableWidget::TABLE_CELLS_HORIZ = 10;
106const tools::Long TableWidget::TABLE_CELLS_VERT = 15;
107
108IMPL_LINK_NOARG(TableWindow, SelectHdl, weld::Button&, void)
109{
110 mxControl->CloseAndShowTableDialog();
111}
112
113TableWindow::TableWindow(SvxTableToolBoxControl* pControl, weld::Widget* pParent, const OUString& rCmd)
114 : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/tablewindow.ui", "TableWindow")
115 , mxTableButton(m_xBuilder->weld_button("moreoptions"))
116 , mxTableWidget(new TableWidget(pControl, rCmd))
117 , mxTableWidgetWin(new weld::CustomWeld(*m_xBuilder, "table", *mxTableWidget))
118 , mxControl(pControl)
119{
120 mxTableButton->set_label( SvxResId( RID_SVXSTR_MORE ) );
121 mxTableButton->connect_clicked( LINK( this, TableWindow, SelectHdl ) );
122 mxTableButton->show();
123}
124
125TableWidget::TableWidget(SvxTableToolBoxControl* pControl, OUString aCommand)
126 : mxControl(pControl)
127 , maCommand(std::move(aCommand))
128 , nCol(0)
129 , nLine(0)
130 , mnTableCellWidth(0)
131 , mnTableCellHeight(0)
132 , mnTableWidth(0)
133 , mnTableHeight(0)
134{
136 aFontColor = rStyles.GetLabelTextColor();
137 aLineColor = rStyles.GetShadowColor();
138 aFillColor = rStyles.GetWindowColor();
139 aHighlightFillColor = rStyles.GetHighlightColor();
140 aBackgroundColor = rStyles.GetFaceColor();
141}
142
143void 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
160bool 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
173bool 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
242bool TableWidget::MouseButtonUp(const MouseEvent&)
243{
244 InsertTable();
245 mxControl->EndPopupMode();
246 return true;
247}
248
249bool TableWidget::MouseButtonDown(const MouseEvent&)
250{
251 return true;
252}
253
254void 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
337void 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
348void 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
364void 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
389namespace {
390
391class ColumnsWidget final : public weld::CustomWidgetController
392{
393private:
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 );
413public:
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
426class ColumnsWindow final : public WeldToolbarPopup
427{
428private:
429 std::unique_ptr<weld::SpinButton> mxSpinButton;
430 std::unique_ptr<ColumnsWidget> mxColumnsWidget;
431 std::unique_ptr<weld::CustomWeld> mxColumnsWidgetWin;
433
434public:
435 ColumnsWindow(SvxColumnsToolBoxControl* pControl, weld::Widget* pParent);
436
437 virtual void GrabFocus() override
438 {
439 mxColumnsWidget->GrabFocus();
440 }
441};
442
443}
444
445ColumnsWindow::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
454ColumnsWidget::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 aLineColor = rStyles.GetLabelTextColor();
466 aHighlightLineColor = rStyles.GetHighlightTextColor();
467 aFillColor = rStyles.GetWindowColor();
468 aHighlightFillColor = rStyles.GetHighlightColor();
469 aFaceColor = rStyles.GetFaceColor();
470}
471
472IMPL_LINK_NOARG(ColumnsWidget, ValueChangedHdl, weld::SpinButton&, void)
473{
474 UpdateSize_Impl(mrSpinButton.get_value());
475}
476
477IMPL_LINK_NOARG(ColumnsWidget, ActivateHdl, weld::Entry&, bool)
478{
479 InsertColumns();
480 mxControl->EndPopupMode();
481 return true;
482}
483
484void ColumnsWidget::SetDrawingArea(weld::DrawingArea* pDrawingArea)
485{
486 OutputDevice& rDevice = pDrawingArea->get_ref_device();
487 Size aLogicSize = rDevice.LogicToPixel( Size( 95, 155 ), MapMode( MapUnit::Map10thMM ) );
488 nMX = aLogicSize.Width();
489 Size aSize(nMX*WIDTH-1, aLogicSize.Height());
490 pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
491 CustomWidgetController::SetDrawingArea(pDrawingArea);
492 SetOutputSizePixel(aSize);
493}
494
495bool ColumnsWidget::MouseMove(const MouseEvent& rMEvt)
496{
497 Point aPos = rMEvt.GetPosPixel();
498
499 tools::Long nNewCol = 1;
500 if ( aPos.X() > 0 )
501 nNewCol = aPos.X() / nMX + 1;
502 if ( nNewCol > 20 )
503 nNewCol = 20;
504 UpdateSize_Impl( nNewCol );
505
506 return true;
507}
508
509void ColumnsWidget::UpdateSize_Impl( tools::Long nNewCol )
510{
511 if ( nNewCol == nCol )
512 return;
513
514 Size aWinSize = GetOutputSizePixel();
515
516 Invalidate( tools::Rectangle( 0, aWinSize.Height() - 2,
517 aWinSize.Width(), aWinSize.Height() ) );
518
519 tools::Long nMinCol = 0, nMaxCol = 0;
520
521 if ( nNewCol < nCol )
522 {
523 nMinCol = nNewCol;
524 nMaxCol = nCol;
525 }
526 else
527 {
528 nMinCol = nCol;
529 nMaxCol = nNewCol;
530 }
531
532 Invalidate( tools::Rectangle( nMinCol*nMX-1, 0,
533 nMaxCol*nMX+1, aWinSize.Height() - 2 ) );
534 nCol = nNewCol;
535 mrSpinButton.set_value(nCol);
536}
537
538bool ColumnsWidget::MouseButtonDown(const MouseEvent&)
539{
540 return true;
541}
542
543bool ColumnsWidget::KeyInput(const KeyEvent& rKEvt)
544{
545 bool bHandled = false;
546 sal_uInt16 nModifier = rKEvt.GetKeyCode().GetModifier();
547 sal_uInt16 nKey = rKEvt.GetKeyCode().GetCode();
548 if(!nModifier)
549 {
550 if( KEY_LEFT == nKey || KEY_RIGHT == nKey ||
551 KEY_RETURN == nKey ||KEY_ESCAPE == nKey ||
552 KEY_UP == nKey)
553 {
554 bHandled = true;
555 tools::Long nNewCol = nCol;
556 switch(nKey)
557 {
558 case KEY_LEFT :
559 if(nNewCol)
560 nNewCol--;
561 break;
562 case KEY_RIGHT :
563 nNewCol++;
564 break;
565 case KEY_RETURN :
566 InsertColumns();
567 mxControl->EndPopupMode();
568 break;
569 case KEY_ESCAPE :
570 case KEY_UP :
571 mxControl->EndPopupMode();
572 break;
573 }
574 UpdateSize_Impl( nNewCol );
575 }
576 }
577 else if(KEY_MOD1 == nModifier && KEY_RETURN == nKey)
578 {
579 m_bMod1 = true;
580 InsertColumns();
581 mxControl->EndPopupMode();
582 }
583 return bHandled;
584}
585
586bool ColumnsWidget::MouseButtonUp(const MouseEvent&)
587{
588 InsertColumns();
589 mxControl->EndPopupMode();
590 return true;
591}
592
593void ColumnsWidget::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&)
594{
595 rRenderContext.Push(vcl::PushFlags::FONT);
596
597 rRenderContext.SetBackground();
598 vcl::Font aFont( rRenderContext.GetFont() );
599 aFont.SetColor( aLineColor );
600 aFont.SetFillColor( aFaceColor );
601 aFont.SetTransparent( false );
602 rRenderContext.SetFont( aFont );
603
606 Size aSize(GetOutputSizePixel());
607
608 for (i = 0; i < WIDTH; i++)
609 {
610 if (i < nCol)
611 {
612 rRenderContext.SetLineColor(aHighlightLineColor);
613 rRenderContext.SetFillColor(aHighlightFillColor);
614 }
615 else
616 {
617 rRenderContext.SetLineColor(aLineColor);
618 rRenderContext.SetFillColor(aFillColor);
619 }
620
621 rRenderContext.DrawRect(tools::Rectangle(i * nMX - 1, -1, i * nMX + nMX, aSize.Height() - 1));
622
623 tools::Long j = 4;
624 while (j < aSize.Height() - 4)
625 {
626 if (!(j % 16))
627 nLineWidth = 10;
628 else
629 nLineWidth = 4;
630 rRenderContext.DrawLine(Point(i * nMX + 4, j), Point(i * nMX + nMX - nLineWidth - 4, j));
631 j += 4;
632 }
633 }
634
635 rRenderContext.SetLineColor();
636 rRenderContext.SetFillColor(aFaceColor);
637
638 rRenderContext.DrawRect(tools::Rectangle(0,
639 aSize.Height() - 2,
640 aSize.Width() / 2 - 1,
641 aSize.Height()));
642
643 rRenderContext.DrawRect(tools::Rectangle(aSize.Width() / 2,
644 aSize.Height() - 2,
645 aSize.Width(),
646 aSize.Height()));
647
648 rRenderContext.SetLineColor(aLineColor);
649 rRenderContext.SetFillColor();
650 rRenderContext.DrawRect(tools::Rectangle( 0, 0, aSize.Width() - 1, aSize.Height() - 1));
651
652 rRenderContext.Pop();
653}
654
655void SvxColumnsToolBoxControl::InsertColumns(const Sequence< PropertyValue >& rArgs)
656{
657 Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
658 if ( xDispatchProvider.is() )
659 {
660 css::util::URL aTargetURL;
661 Reference < XURLTransformer > xTrans( URLTransformer::create(::comphelper::getProcessComponentContext()) );
662 aTargetURL.Complete = m_aCommandURL;
663 xTrans->parseStrict( aTargetURL );
664
665 Reference< XDispatch > xDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 );
666 if ( xDispatch.is() )
667 xDispatch->dispatch( aTargetURL, rArgs );
668 }
669}
670
671void ColumnsWidget::InsertColumns()
672{
673 if (nCol)
674 {
675 Sequence< PropertyValue > aArgs{
676 comphelper::makePropertyValue("Columns", sal_Int16( nCol )),
677 comphelper::makePropertyValue("Modifier", sal_Int16( m_bMod1 ? KEY_MOD1 : 0 ))
678 };
679 mxControl->InsertColumns(aArgs);
680 }
681}
682
683SvxTableToolBoxControl::SvxTableToolBoxControl(const css::uno::Reference<css::uno::XComponentContext>& rContext)
684 : PopupWindowController(rContext, nullptr, OUString())
685{
686}
687
688void SvxTableToolBoxControl::initialize( const css::uno::Sequence< css::uno::Any >& rArguments )
689{
690 PopupWindowController::initialize(rArguments);
691
692 ToolBox* pToolBox = nullptr;
694 if (getToolboxId(nId, &pToolBox))
695 pToolBox->SetItemBits(nId, ToolBoxItemBits::DROPDOWNONLY | pToolBox->GetItemBits(nId));
696}
697
699{
700}
701
702std::unique_ptr<WeldToolbarPopup> SvxTableToolBoxControl::weldPopupWindow()
703{
704 return std::make_unique<TableWindow>(this, m_pToolbar, m_aCommandURL);
705}
706
708{
709 ToolBox* pToolBox = nullptr;
711 bool bToolBox = getToolboxId(nId, &pToolBox);
712
713 mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
714 std::make_unique<TableWindow>(this, pParent->GetFrameWeld(), m_aCommandURL));
715
716 mxInterimPopover->SetText(bToolBox ? pToolBox->GetItemText(nId) : OUString());
717
718 mxInterimPopover->Show();
719
720 return mxInterimPopover;
721}
722
724{
725 return "com.sun.star.comp.svx.TableToolBoxControl";
726}
727
729{
730 return { "com.sun.star.frame.ToolbarController" };
731}
732
733extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
735 css::uno::XComponentContext* rContext,
736 css::uno::Sequence<css::uno::Any> const & )
737{
738 return cppu::acquire(new SvxTableToolBoxControl(rContext));
739}
740
741SvxColumnsToolBoxControl::SvxColumnsToolBoxControl(const css::uno::Reference<css::uno::XComponentContext>& rContext)
742 : PopupWindowController(rContext, nullptr, OUString())
743{
744}
745
746void SvxColumnsToolBoxControl::initialize( const css::uno::Sequence< css::uno::Any >& rArguments )
747{
748 PopupWindowController::initialize(rArguments);
749
750 ToolBox* pToolBox = nullptr;
752 if (getToolboxId(nId, &pToolBox))
753 pToolBox->SetItemBits(nId, ToolBoxItemBits::DROPDOWNONLY | pToolBox->GetItemBits(nId));
754}
755
757{
758}
759
760std::unique_ptr<WeldToolbarPopup> SvxColumnsToolBoxControl::weldPopupWindow()
761{
762 return std::make_unique<ColumnsWindow>(this, m_pToolbar);
763}
764
766{
767 ToolBox* pToolBox = nullptr;
769 bool bToolBox = getToolboxId(nId, &pToolBox);
770
771 mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
772 std::make_unique<ColumnsWindow>(this, pParent->GetFrameWeld()));
773
774 mxInterimPopover->SetText(bToolBox ? pToolBox->GetItemText(nId) : OUString());
775
776 mxInterimPopover->Show();
777
778 return mxInterimPopover;
779}
780
782{
783 return "com.sun.star.comp.svx.ColumnsToolBoxControl";
784}
785
787{
788 return { "com.sun.star.frame.ToolbarController" };
789}
790
791extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
793 css::uno::XComponentContext* rContext,
794 css::uno::Sequence<css::uno::Any> const & )
795{
796 return cppu::acquire(new SvxColumnsToolBoxControl(rContext));
797}
798
799/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 nLineWidth
css::uno::Reference< css::lang::XComponent > m_xFrame
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
const vcl::KeyCode & GetKeyCode() const
const Point & GetPosPixel() const
const vcl::Font & GetFont() const
float GetDPIScaleFactor() const
void SetFont(const vcl::Font &rNewFont)
void DrawRect(const tools::Rectangle &rRect)
void DrawLine(const Point &rStartPt, const Point &rEndPt)
void SetLineColor()
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
void SetFillColor()
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
tools::Long GetTextHeight() const
void SetBackground()
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)
constexpr tools::Long X() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
const Color & GetWindowColor() const
const Color & GetShadowColor() const
const Color & GetLabelTextColor() const
const Color & GetHighlightColor() const
const Color & GetFaceColor() const
const Color & GetHighlightTextColor() const
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: layctrl.cxx:786
virtual VclPtr< vcl::Window > createVclPopupWindow(vcl::Window *pParent) override
Definition: layctrl.cxx:765
void InsertColumns(const css::uno::Sequence< css::beans::PropertyValue > &rArgs)
Definition: layctrl.cxx:655
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &rArguments) override
Definition: layctrl.cxx:746
virtual ~SvxColumnsToolBoxControl() override
Definition: layctrl.cxx:756
virtual std::unique_ptr< WeldToolbarPopup > weldPopupWindow() override
Definition: layctrl.cxx:760
virtual OUString SAL_CALL getImplementationName() override
Definition: layctrl.cxx:781
SvxColumnsToolBoxControl(const css::uno::Reference< css::uno::XComponentContext > &rContext)
Definition: layctrl.cxx:741
virtual std::unique_ptr< WeldToolbarPopup > weldPopupWindow() override
Definition: layctrl.cxx:702
virtual VclPtr< vcl::Window > createVclPopupWindow(vcl::Window *pParent) override
Definition: layctrl.cxx:707
virtual ~SvxTableToolBoxControl() override
Definition: layctrl.cxx:698
virtual OUString SAL_CALL getImplementationName() override
Definition: layctrl.cxx:723
void CloseAndShowTableDialog()
Definition: layctrl.cxx:380
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: layctrl.cxx:728
void TableDialog(const css::uno::Sequence< css::beans::PropertyValue > &rArgs)
Definition: layctrl.cxx:364
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &rArguments) override
Definition: layctrl.cxx:688
SvxTableToolBoxControl(const css::uno::Reference< css::uno::XComponentContext > &rContext)
Definition: layctrl.cxx:683
const OUString & GetItemText(ToolBoxItemId nItemId) const
ToolBoxItemBits GetItemBits(ToolBoxItemId nItemId) const
void SetItemBits(ToolBoxItemId nItemId, ToolBoxItemBits nBits)
static VclPtr< reference_type > Create(Arg &&... arg)
virtual void GrabFocus()=0
VclPtr< InterimToolbarPopup > mxInterimPopover
void SetTransparent(bool bTransparent)
void SetFillColor(const Color &)
void SetColor(const Color &)
sal_uInt16 GetCode() const
sal_uInt16 GetModifier() const
weld::Window * GetFrameWeld() const
virtual bool KeyInput(const KeyEvent &)
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea)
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)=0
virtual bool MouseMove(const MouseEvent &)
virtual bool MouseButtonDown(const MouseEvent &)
virtual bool MouseButtonUp(const MouseEvent &)
DECL_LINK(DragBeginHdl, weld::DrawingArea &, bool)
virtual OutputDevice & get_ref_device()=0
virtual void set_size_request(int nWidth, int nHeight)=0
OUString SvxResId(TranslateId aId)
Definition: dialmgr.cxx:24
Reference< XDispatch > xDispatch
DECL_LINK(CheckNameHdl, SvxNameDialog &, bool)
float u
constexpr sal_uInt16 KEY_RETURN
constexpr sal_uInt16 KEY_ESCAPE
constexpr sal_uInt16 KEY_LEFT
constexpr sal_uInt16 KEY_UP
constexpr sal_uInt16 KEY_RIGHT
constexpr sal_uInt16 KEY_DOWN
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:734
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:792
IMPL_LINK_NOARG(TableWindow, SelectHdl, weld::Button &, void)
Definition: layctrl.cxx:108
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
const sal_uInt16 WIDTH
int i
long Long
sal_Int16 nId
OUString aCommand
OUString aTargetURL