26 #include <svx/strings.hrc>
33 #include <com/sun/star/util/URLTransformer.hpp>
34 #include <com/sun/star/frame/XDispatchProvider.hpp>
86 std::unique_ptr<weld::Button> mxTableButton;
87 std::unique_ptr<TableWidget> mxTableWidget;
88 std::unique_ptr<weld::CustomWeld> mxTableWidgetWin;
95 const OUString& rCmd);
98 mxTableWidget->GrabFocus();
104 const tools::Long TableWidget::TABLE_CELLS_HORIZ = 10;
105 const tools::Long TableWidget::TABLE_CELLS_VERT = 15;
109 mxControl->CloseAndShowTableDialog();
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)
119 mxTableButton->set_label(
SvxResId( RID_SVXSTR_MORE ) );
120 mxTableButton->connect_clicked(
LINK(
this, TableWindow, SelectHdl ) );
121 mxTableButton->show();
125 : mxControl(pControl)
126 , maCommand(rCommand)
129 , mnTableCellWidth(0)
130 , mnTableCellHeight(0)
147 mnTableCellWidth = 15 * fScaleFactor;
148 mnTableCellHeight = 15 * fScaleFactor;
150 mnTableWidth = TABLE_CELLS_HORIZ*mnTableCellWidth;
151 mnTableHeight = TABLE_CELLS_VERT*mnTableCellHeight;
154 Size aSize(mnTableWidth + 1, mnTableHeight + 1);
156 CustomWidgetController::SetDrawingArea(pDrawingArea);
157 SetOutputSizePixel(aSize);
160 bool TableWidget::MouseMove(
const MouseEvent& rMEvt)
163 Point aMousePos( aPos );
165 tools::Long nNewCol = ( aMousePos.X() + mnTableCellWidth ) / mnTableCellWidth;
166 tools::Long nNewLine = ( aMousePos.Y() + mnTableCellHeight ) / mnTableCellHeight;
168 Update( nNewCol, nNewLine );
173 bool TableWidget::KeyInput(
const KeyEvent& rKEvt)
175 bool bHandled =
false;
189 mxControl->EndPopupMode();
192 if ( nNewLine < TABLE_CELLS_VERT )
199 mxControl->CloseAndShowTableDialog();
205 mxControl->EndPopupMode();
208 if ( nNewCol < TABLE_CELLS_HORIZ )
215 mxControl->CloseAndShowTableDialog();
218 mxControl->EndPopupMode();
222 mxControl->EndPopupMode();
229 Update( nNewCol, nNewLine );
232 else if (KEY_MOD1 == nModifier && KEY_RETURN == nKey)
235 mxControl->EndPopupMode();
242 bool TableWidget::MouseButtonUp(
const MouseEvent&)
245 mxControl->EndPopupMode();
249 bool TableWidget::MouseButtonDown(
const MouseEvent&)
263 rRenderContext.
SetFont( aFont );
265 const tools::Long nSelectionWidth = nCol * mnTableCellWidth;
266 const tools::Long nSelectionHeight = nLine * mnTableCellHeight;
276 if (nCol > 0 && nLine > 0)
287 Point(mnTableWidth, i*mnTableCellHeight));
293 Point( i*mnTableCellWidth, mnTableHeight));
299 rRenderContext.
Pop();
303 OUString aText = OUString::number( nCol ) +
" x " + OUString::number( nLine );
304 if (maCommand ==
".uno:ShowMultiplePages")
306 aText +=
" " +
SvxResId(RID_SVXSTR_PAGES);
311 tools::Long nTextX = nSelectionWidth + mnTableCellWidth;
312 tools::Long nTextY = nSelectionHeight + mnTableCellHeight;
315 if (aTextSize.Width() + mnTableCellWidth + 2 * nTipBorder < nSelectionWidth)
316 nTextX = nSelectionWidth - mnTableCellWidth - aTextSize.
Width();
318 if (aTextSize.Height() + mnTableCellHeight + 2 * nTipBorder < nSelectionHeight)
319 nTextY = nSelectionHeight - mnTableCellHeight - aTextSize.Height();
324 nTextY - 2 * nTipBorder,
325 nTextX + aTextSize.Width() + nTipBorder,
326 nTextY + aTextSize.Height() + nTipBorder));
330 aText = u
"\u202D" + aText;
334 rRenderContext.
Pop();
337 void TableWidget::InsertTable()
344 mxControl->TableDialog( aArgs );
350 if ( nNewCol < 0 || nNewCol > TABLE_CELLS_HORIZ )
353 if ( nNewLine < 0 || nNewLine > TABLE_CELLS_VERT )
356 if ( nNewCol != nCol || nNewLine != nLine )
366 Reference< XDispatchProvider > xDispatchProvider(
m_xFrame, UNO_QUERY );
367 if ( xDispatchProvider.is() )
371 aTargetURL.Complete = m_aCommandURL;
372 xTrans->parseStrict( aTargetURL );
374 Reference< XDispatch >
xDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 );
375 if ( xDispatch.is() )
376 xDispatch->dispatch( aTargetURL, rArgs );
411 void InsertColumns();
429 std::unique_ptr<weld::SpinButton> mxSpinButton;
430 std::unique_ptr<ColumnsWidget> mxColumnsWidget;
431 std::unique_ptr<weld::CustomWeld> mxColumnsWidgetWin;
439 mxColumnsWidget->GrabFocus();
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)
455 : mxControl(pControl)
456 , mrSpinButton(rSpinButton)
461 mrSpinButton.connect_value_changed(
LINK(
this, ColumnsWidget, ValueChangedHdl));
462 mrSpinButton.connect_activate(
LINK(
this, ColumnsWidget, ActivateHdl));
475 UpdateSize_Impl(mrSpinButton.get_value());
481 mxControl->EndPopupMode();
489 nMX = aLogicSize.
Width();
492 CustomWidgetController::SetDrawingArea(pDrawingArea);
493 SetOutputSizePixel(aSize);
496 bool ColumnsWidget::MouseMove(
const MouseEvent& rMEvt)
502 nNewCol = aPos.X() / nMX + 1;
505 UpdateSize_Impl( nNewCol );
510 void ColumnsWidget::UpdateSize_Impl(
tools::Long nNewCol )
512 if ( nNewCol == nCol )
515 Size aWinSize = GetOutputSizePixel();
522 if ( nNewCol < nCol )
534 nMaxCol*nMX+1, aWinSize.
Height() - 2 ) );
536 mrSpinButton.set_value(nCol);
539 bool ColumnsWidget::MouseButtonDown(
const MouseEvent&)
544 bool ColumnsWidget::KeyInput(
const KeyEvent& rKEvt)
546 bool bHandled =
false;
551 if( KEY_LEFT == nKey || KEY_RIGHT == nKey ||
552 KEY_RETURN == nKey ||KEY_ESCAPE == nKey ||
568 mxControl->EndPopupMode();
572 mxControl->EndPopupMode();
575 UpdateSize_Impl( nNewCol );
578 else if(KEY_MOD1 == nModifier && KEY_RETURN == nKey)
582 mxControl->EndPopupMode();
587 bool ColumnsWidget::MouseButtonUp(
const MouseEvent&)
590 mxControl->EndPopupMode();
603 rRenderContext.
SetFont( aFont );
607 Size aSize(GetOutputSizePixel());
609 for (i = 0; i <
WIDTH; i++)
625 while (j < aSize.Height() - 4)
631 rRenderContext.
DrawLine(
Point(i * nMX + 4, j),
Point(i * nMX + nMX - nLineWidth - 4, j));
641 aSize.Width() / 2 - 1,
653 rRenderContext.
Pop();
658 Reference< XDispatchProvider > xDispatchProvider(
m_xFrame, UNO_QUERY );
659 if ( xDispatchProvider.is() )
663 aTargetURL.Complete = m_aCommandURL;
664 xTrans->parseStrict( aTargetURL );
666 Reference< XDispatch >
xDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 );
667 if ( xDispatch.is() )
668 xDispatch->dispatch( aTargetURL, rArgs );
672 void ColumnsWidget::InsertColumns()
676 Sequence< PropertyValue > aArgs{
680 mxControl->InsertColumns(aArgs);
685 : PopupWindowController(rContext, nullptr, OUString())
691 PopupWindowController::initialize(rArguments);
695 if (getToolboxId(nId, &pToolBox))
705 return std::make_unique<TableWindow>(
this, m_pToolbar, m_aCommandURL);
712 bool bToolBox = getToolboxId(nId, &pToolBox);
715 std::make_unique<TableWindow>(
this, pParent->
GetFrameWeld(), m_aCommandURL));
726 return "com.sun.star.comp.svx.TableToolBoxControl";
731 return {
"com.sun.star.frame.ToolbarController" };
734 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
736 css::uno::XComponentContext* rContext,
737 css::uno::Sequence<css::uno::Any>
const & )
743 : PopupWindowController(rContext, nullptr, OUString())
749 PopupWindowController::initialize(rArguments);
753 if (getToolboxId(nId, &pToolBox))
763 return std::make_unique<ColumnsWindow>(
this, m_pToolbar);
770 bool bToolBox = getToolboxId(nId, &pToolBox);
773 std::make_unique<ColumnsWindow>(
this, pParent->
GetFrameWeld()));
784 return "com.sun.star.comp.svx.ColumnsToolBoxControl";
789 return {
"com.sun.star.frame.ToolbarController" };
792 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
794 css::uno::XComponentContext* rContext,
795 css::uno::Sequence<css::uno::Any>
const & )
#define LINK(Instance, Class, Member)
const Color & GetShadowColor() const
DECL_LINK(CheckNameHdl, SvxNameDialog &, bool)
void SetFillColor(const Color &)
const Color & GetHighlightTextColor() const
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 &)
css::uno::Reference< css::lang::XComponent > m_xFrame
sal_uInt16 GetCode() const
constexpr sal_uInt16 KEY_UP
const Color & GetHighlightColor() const
constexpr tools::Long Width() const
weld::Window * GetFrameWeld() const
const vcl::Font & GetFont() const
OUString SvxResId(TranslateId aId)
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
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
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 &)
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
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
const vcl::KeyCode & GetKeyCode() const
Reference< XDispatch > xDispatch
constexpr tools::Long Height() const
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)
Reference< XComponentContext > getProcessComponentContext()
const Color & GetWindowColor() const
const Point & GetPosPixel() const
constexpr sal_uInt16 KEY_LEFT
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)
bool m_bDetectedRangeSegmentation false