27#include <svx/strings.hrc>
34#include <com/sun/star/util/URLTransformer.hpp>
35#include <com/sun/star/frame/XDispatchProvider.hpp>
87 std::unique_ptr<weld::Button> mxTableButton;
88 std::unique_ptr<TableWidget> mxTableWidget;
89 std::unique_ptr<weld::CustomWeld> mxTableWidgetWin;
96 const OUString& rCmd);
99 mxTableWidget->GrabFocus();
105const tools::Long TableWidget::TABLE_CELLS_HORIZ = 10;
106const tools::Long TableWidget::TABLE_CELLS_VERT = 15;
110 mxControl->CloseAndShowTableDialog();
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)
120 mxTableButton->set_label(
SvxResId( RID_SVXSTR_MORE ) );
121 mxTableButton->connect_clicked(
LINK(
this, TableWindow, SelectHdl ) );
122 mxTableButton->show();
126 : mxControl(pControl)
130 , mnTableCellWidth(0)
131 , 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);
160bool 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 );
173bool 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();
242bool TableWidget::MouseButtonUp(
const MouseEvent&)
245 mxControl->EndPopupMode();
249bool 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();
337void 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() )
370 Reference < XURLTransformer > xTrans( URLTransformer::create(::comphelper::getProcessComponentContext()) );
374 Reference< XDispatch >
xDispatch = xDispatchProvider->queryDispatch(
aTargetURL, OUString(), 0 );
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));
474 UpdateSize_Impl(mrSpinButton.get_value());
480 mxControl->EndPopupMode();
488 nMX = aLogicSize.
Width();
491 CustomWidgetController::SetDrawingArea(pDrawingArea);
492 SetOutputSizePixel(aSize);
495bool ColumnsWidget::MouseMove(
const MouseEvent& rMEvt)
501 nNewCol = aPos.
X() / nMX + 1;
504 UpdateSize_Impl( nNewCol );
509void ColumnsWidget::UpdateSize_Impl(
tools::Long nNewCol )
511 if ( nNewCol == nCol )
514 Size aWinSize = GetOutputSizePixel();
521 if ( nNewCol < nCol )
533 nMaxCol*nMX+1, aWinSize.
Height() - 2 ) );
535 mrSpinButton.set_value(nCol);
538bool ColumnsWidget::MouseButtonDown(
const MouseEvent&)
543bool ColumnsWidget::KeyInput(
const KeyEvent& rKEvt)
545 bool bHandled =
false;
550 if( KEY_LEFT == nKey || KEY_RIGHT == nKey ||
551 KEY_RETURN == nKey ||KEY_ESCAPE == nKey ||
567 mxControl->EndPopupMode();
571 mxControl->EndPopupMode();
574 UpdateSize_Impl( nNewCol );
577 else if(KEY_MOD1 == nModifier && KEY_RETURN == nKey)
581 mxControl->EndPopupMode();
586bool ColumnsWidget::MouseButtonUp(
const MouseEvent&)
589 mxControl->EndPopupMode();
602 rRenderContext.
SetFont( aFont );
606 Size aSize(GetOutputSizePixel());
624 while (j < aSize.Height() - 4)
630 rRenderContext.
DrawLine(
Point(i * nMX + 4, j),
Point(i * nMX + nMX - nLineWidth - 4, j));
640 aSize.Width() / 2 - 1,
652 rRenderContext.
Pop();
657 Reference< XDispatchProvider > xDispatchProvider(
m_xFrame, UNO_QUERY );
658 if ( xDispatchProvider.is() )
661 Reference < XURLTransformer > xTrans( URLTransformer::create(::comphelper::getProcessComponentContext()) );
665 Reference< XDispatch >
xDispatch = xDispatchProvider->queryDispatch(
aTargetURL, OUString(), 0 );
671void ColumnsWidget::InsertColumns()
675 Sequence< PropertyValue > aArgs{
679 mxControl->InsertColumns(aArgs);
684 : PopupWindowController(rContext, nullptr, OUString())
690 PopupWindowController::initialize(rArguments);
694 if (getToolboxId(
nId, &pToolBox))
704 return std::make_unique<TableWindow>(
this, m_pToolbar, m_aCommandURL);
711 bool bToolBox = getToolboxId(
nId, &pToolBox);
714 std::make_unique<TableWindow>(
this, pParent->
GetFrameWeld(), m_aCommandURL));
725 return "com.sun.star.comp.svx.TableToolBoxControl";
730 return {
"com.sun.star.frame.ToolbarController" };
733extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
735 css::uno::XComponentContext* rContext,
736 css::uno::Sequence<css::uno::Any>
const & )
742 : PopupWindowController(rContext, nullptr, OUString())
748 PopupWindowController::initialize(rArguments);
752 if (getToolboxId(
nId, &pToolBox))
762 return std::make_unique<ColumnsWindow>(
this, m_pToolbar);
769 bool bToolBox = getToolboxId(
nId, &pToolBox);
772 std::make_unique<ColumnsWindow>(
this, pParent->
GetFrameWeld()));
783 return "com.sun.star.comp.svx.ColumnsToolBoxControl";
788 return {
"com.sun.star.frame.ToolbarController" };
791extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
793 css::uno::XComponentContext* rContext,
794 css::uno::Sequence<css::uno::Any>
const & )
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)
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_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
tools::Long GetTextHeight() const
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
static VclPtr< reference_type > Create(Arg &&... arg)
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 OutputDevice & get_ref_device()=0
OUString SvxResId(TranslateId aId)
Reference< XDispatch > xDispatch
DECL_LINK(CheckNameHdl, SvxNameDialog &, bool)
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 &)
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 &)
IMPL_LINK_NOARG(TableWindow, SelectHdl, weld::Button &, void)
#define LINK(Instance, Class, Member)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)