26 #include <svx/strings.hrc>
32 #include <com/sun/star/util/URLTransformer.hpp>
33 #include <com/sun/star/frame/XDispatchProvider.hpp>
85 std::unique_ptr<weld::Button> mxTableButton;
86 std::unique_ptr<TableWidget> mxTableWidget;
87 std::unique_ptr<weld::CustomWeld> mxTableWidgetWin;
94 const OUString& rCmd);
97 mxTableWidget->GrabFocus();
103 const tools::Long TableWidget::TABLE_CELLS_HORIZ = 10;
104 const tools::Long TableWidget::TABLE_CELLS_VERT = 15;
108 mxControl->CloseAndShowTableDialog();
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)
118 mxTableButton->set_label(
SvxResId( RID_SVXSTR_MORE ) );
119 mxTableButton->connect_clicked(
LINK(
this, TableWindow, SelectHdl ) );
120 mxTableButton->show();
124 : mxControl(pControl)
125 , maCommand(rCommand)
128 , mnTableCellWidth(0)
129 , mnTableCellHeight(0)
146 mnTableCellWidth = 15 * fScaleFactor;
147 mnTableCellHeight = 15 * fScaleFactor;
149 mnTableWidth = TABLE_CELLS_HORIZ*mnTableCellWidth;
150 mnTableHeight = TABLE_CELLS_VERT*mnTableCellHeight;
153 Size aSize(mnTableWidth + 1, mnTableHeight + 1);
155 CustomWidgetController::SetDrawingArea(pDrawingArea);
156 SetOutputSizePixel(aSize);
159 bool TableWidget::MouseMove(
const MouseEvent& rMEvt)
162 Point aMousePos( aPos );
164 tools::Long nNewCol = ( aMousePos.X() + mnTableCellWidth ) / mnTableCellWidth;
165 tools::Long nNewLine = ( aMousePos.Y() + mnTableCellHeight ) / mnTableCellHeight;
167 Update( nNewCol, nNewLine );
172 bool TableWidget::KeyInput(
const KeyEvent& rKEvt)
174 bool bHandled =
false;
188 mxControl->EndPopupMode();
191 if ( nNewLine < TABLE_CELLS_VERT )
198 mxControl->CloseAndShowTableDialog();
204 mxControl->EndPopupMode();
207 if ( nNewCol < TABLE_CELLS_HORIZ )
214 mxControl->CloseAndShowTableDialog();
217 mxControl->EndPopupMode();
221 mxControl->EndPopupMode();
228 Update( nNewCol, nNewLine );
231 else if (KEY_MOD1 == nModifier && KEY_RETURN == nKey)
234 mxControl->EndPopupMode();
241 bool TableWidget::MouseButtonUp(
const MouseEvent&)
244 mxControl->EndPopupMode();
248 bool TableWidget::MouseButtonDown(
const MouseEvent&)
255 rRenderContext.
Push(PushFlags::FONT);
262 rRenderContext.
SetFont( aFont );
264 const tools::Long nSelectionWidth = nCol * mnTableCellWidth;
265 const tools::Long nSelectionHeight = nLine * mnTableCellHeight;
275 if (nCol > 0 && nLine > 0)
286 Point(mnTableWidth, i*mnTableCellHeight));
292 Point( i*mnTableCellWidth, mnTableHeight));
298 rRenderContext.
Pop();
302 OUString aText = OUString::number( nCol ) +
" x " + OUString::number( nLine );
303 if (maCommand ==
".uno:ShowMultiplePages")
305 aText +=
" " +
SvxResId(RID_SVXSTR_PAGES);
310 tools::Long nTextX = nSelectionWidth + mnTableCellWidth;
311 tools::Long nTextY = nSelectionHeight + mnTableCellHeight;
314 if (aTextSize.Width() + mnTableCellWidth + 2 * nTipBorder < nSelectionWidth)
315 nTextX = nSelectionWidth - mnTableCellWidth - aTextSize.
Width();
317 if (aTextSize.Height() + mnTableCellHeight + 2 * nTipBorder < nSelectionHeight)
318 nTextY = nSelectionHeight - mnTableCellHeight - aTextSize.Height();
323 nTextY - 2 * nTipBorder,
324 nTextX + aTextSize.Width() + nTipBorder,
325 nTextY + aTextSize.Height() + nTipBorder));
329 aText = u
"\u202D" + aText;
333 rRenderContext.
Pop();
336 void TableWidget::InsertTable()
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 );
346 mxControl->TableDialog( aArgs );
352 if ( nNewCol < 0 || nNewCol > TABLE_CELLS_HORIZ )
355 if ( nNewLine < 0 || nNewLine > TABLE_CELLS_VERT )
358 if ( nNewCol != nCol || nNewLine != nLine )
368 Reference< XDispatchProvider > xDispatchProvider(
m_xFrame, UNO_QUERY );
369 if ( xDispatchProvider.is() )
373 aTargetURL.Complete = m_aCommandURL;
374 xTrans->parseStrict( aTargetURL );
376 Reference< XDispatch >
xDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 );
377 if ( xDispatch.is() )
378 xDispatch->dispatch( aTargetURL, rArgs );
413 void InsertColumns();
431 std::unique_ptr<weld::SpinButton> mxSpinButton;
432 std::unique_ptr<ColumnsWidget> mxColumnsWidget;
433 std::unique_ptr<weld::CustomWeld> mxColumnsWidgetWin;
441 mxColumnsWidget->GrabFocus();
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)
457 : mxControl(pControl)
458 , mrSpinButton(rSpinButton)
463 mrSpinButton.connect_value_changed(
LINK(
this, ColumnsWidget, ValueChangedHdl));
464 mrSpinButton.connect_activate(
LINK(
this, ColumnsWidget, ActivateHdl));
477 UpdateSize_Impl(mrSpinButton.get_value());
483 mxControl->EndPopupMode();
491 nMX = aLogicSize.
Width();
494 CustomWidgetController::SetDrawingArea(pDrawingArea);
495 SetOutputSizePixel(aSize);
498 bool ColumnsWidget::MouseMove(
const MouseEvent& rMEvt)
504 nNewCol = aPos.X() / nMX + 1;
507 UpdateSize_Impl( nNewCol );
512 void ColumnsWidget::UpdateSize_Impl(
tools::Long nNewCol )
514 if ( nNewCol == nCol )
517 Size aWinSize = GetOutputSizePixel();
524 if ( nNewCol < nCol )
536 nMaxCol*nMX+1, aWinSize.
Height() - 2 ) );
538 mrSpinButton.set_value(nCol);
541 bool ColumnsWidget::MouseButtonDown(
const MouseEvent&)
546 bool ColumnsWidget::KeyInput(
const KeyEvent& rKEvt)
548 bool bHandled =
false;
553 if( KEY_LEFT == nKey || KEY_RIGHT == nKey ||
554 KEY_RETURN == nKey ||KEY_ESCAPE == nKey ||
570 mxControl->EndPopupMode();
574 mxControl->EndPopupMode();
577 UpdateSize_Impl( nNewCol );
580 else if(KEY_MOD1 == nModifier && KEY_RETURN == nKey)
584 mxControl->EndPopupMode();
589 bool ColumnsWidget::MouseButtonUp(
const MouseEvent&)
592 mxControl->EndPopupMode();
598 rRenderContext.
Push(PushFlags::FONT);
605 rRenderContext.
SetFont( aFont );
609 Size aSize(GetOutputSizePixel());
611 for (i = 0; i <
WIDTH; i++)
627 while (j < aSize.Height() - 4)
633 rRenderContext.
DrawLine(
Point(i * nMX + 4, j),
Point(i * nMX + nMX - nLineWidth - 4, j));
643 aSize.Width() / 2 - 1,
655 rRenderContext.
Pop();
660 Reference< XDispatchProvider > xDispatchProvider(
m_xFrame, UNO_QUERY );
661 if ( xDispatchProvider.is() )
665 aTargetURL.Complete = m_aCommandURL;
666 xTrans->parseStrict( aTargetURL );
668 Reference< XDispatch >
xDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 );
669 if ( xDispatch.is() )
670 xDispatch->dispatch( aTargetURL, rArgs );
674 void ColumnsWidget::InsertColumns()
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);
688 : PopupWindowController(rContext, nullptr, OUString())
694 PopupWindowController::initialize(rArguments);
698 if (getToolboxId(nId, &pToolBox))
708 return std::make_unique<TableWindow>(
this, m_pToolbar, m_aCommandURL);
715 bool bToolBox = getToolboxId(nId, &pToolBox);
718 std::make_unique<TableWindow>(
this, pParent->
GetFrameWeld(), m_aCommandURL));
729 return "com.sun.star.comp.svx.TableToolBoxControl";
734 return {
"com.sun.star.frame.ToolbarController" };
737 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
739 css::uno::XComponentContext* rContext,
740 css::uno::Sequence<css::uno::Any>
const & )
746 : PopupWindowController(rContext, nullptr, OUString())
752 PopupWindowController::initialize(rArguments);
756 if (getToolboxId(nId, &pToolBox))
766 return std::make_unique<ColumnsWindow>(
this, m_pToolbar);
773 bool bToolBox = getToolboxId(nId, &pToolBox);
776 std::make_unique<ColumnsWindow>(
this, pParent->
GetFrameWeld()));
787 return "com.sun.star.comp.svx.ColumnsToolBoxControl";
792 return {
"com.sun.star.frame.ToolbarController" };
795 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
797 css::uno::XComponentContext* rContext,
798 css::uno::Sequence<css::uno::Any>
const & )
#define LINK(Instance, Class, Member)
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 &)
const Color & GetHighlightTextColor() 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 &)
css::uno::Reference< css::lang::XComponent > m_xFrame
sal_uInt16 GetCode() const
constexpr sal_uInt16 KEY_UP
const Color & GetHighlightColor() const
weld::Window * GetFrameWeld() const
OUString SvxResId(const char *pId)
const vcl::Font & GetFont() const
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
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 &)
tools::Long Width() const
IMPL_LINK_NOARG(TableWindow, SelectHdl, weld::Button &, void)
float GetDPIScaleFactor() const
constexpr sal_uInt16 KEY_RETURN
void SetColor(const Color &)
constexpr sal_uInt16 KEY_RIGHT
Point LogicToPixel(const Point &rLogicPt) const
const vcl::KeyCode & GetKeyCode() const
Reference< XDispatch > xDispatch
constexpr sal_uInt16 KEY_ESCAPE
void SetFont(const vcl::Font &rNewFont)
void SetTransparent(bool bTransparent)
tools::Long GetTextHeight() const
static VclPtr< reference_type > Create(Arg &&...arg)
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
tools::Long Height() const
Reference< XComponentContext > getProcessComponentContext()
const Color & GetWindowColor() const
const Point & GetPosPixel() const
constexpr sal_uInt16 KEY_LEFT
void Push(PushFlags nFlags=PushFlags::ALL)