LibreOffice Module starmath (master) 1
view.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 <sal/config.h>
21
22#include <com/sun/star/accessibility/AccessibleEventId.hpp>
23#include <com/sun/star/accessibility/AccessibleStateType.hpp>
24#include <com/sun/star/frame/Desktop.hpp>
25#include <com/sun/star/frame/XFramesSupplier.hpp>
26#include <com/sun/star/frame/XModel.hpp>
27#include <com/sun/star/container/XChild.hpp>
28
29#include <comphelper/lok.hxx>
33#include <comphelper/string.hxx>
34#include <i18nutil/unicode.hxx>
35#include <LibreOfficeKit/LibreOfficeKitEnums.h>
36#include <officecfg/Office/Common.hxx>
37#include <sfx2/dispatch.hxx>
38#include <sfx2/docfile.hxx>
39#include <sfx2/docfilt.hxx>
40#include <sfx2/docinsert.hxx>
42#include <sfx2/infobar.hxx>
44#include <sfx2/lokhelper.hxx>
45#include <sfx2/msg.hxx>
46#include <sfx2/objface.hxx>
47#include <sfx2/printer.hxx>
48#include <sfx2/request.hxx>
53#include <sfx2/viewfac.hxx>
54#include <svl/eitem.hxx>
55#include <svl/itemset.hxx>
56#include <svl/poolitem.hxx>
57#include <svl/stritem.hxx>
58#include <vcl/transfer.hxx>
59#include <svtools/colorcfg.hxx>
60#include <svl/whiter.hxx>
63#include <editeng/editeng.hxx>
64#include <editeng/editview.hxx>
65#include <svx/svxdlg.hxx>
66#include <sfx2/zoomitem.hxx>
67#include <vcl/commandevent.hxx>
68#include <vcl/event.hxx>
69#include <vcl/help.hxx>
70#include <vcl/settings.hxx>
71#include <vcl/virdev.hxx>
72#include <sal/log.hxx>
73#include <tools/svborder.hxx>
74#include <o3tl/string_view.hxx>
75#include <o3tl/temporary.hxx>
76
78
79#include <unomodel.hxx>
80#include <view.hxx>
81#include <cfgitem.hxx>
82#include <dialog.hxx>
83#include <document.hxx>
84#include <starmath.hrc>
85#include <strings.hrc>
86#include <smmod.hxx>
87#include <mathmlimport.hxx>
88#include <cursor.hxx>
89#include "accessibility.hxx"
91#include <helpids.h>
92
93#define MINZOOM sal_uInt16(25)
94#define MAXZOOM sal_uInt16(800)
95
96// space around the edit window, in pixels
97// fdo#69111: Increased border on the top so that the window is
98// easier to tear off.
99#define CMD_BOX_PADDING 3
100#define CMD_BOX_PADDING_TOP 11
101
102#define ShellClass_SmViewShell
103#include <smslots.hxx>
104
105using namespace css;
106using namespace css::accessibility;
107using namespace css::uno;
108
110 : InterimItemWindow(&rShell.GetViewFrame().GetWindow(), "modules/smath/ui/mathwindow.ui", "MathWindow")
111 , nLinePixH(GetSettings().GetStyleSettings().GetScrollBarSize())
112 , nColumnPixW(nLinePixH)
113 , nZoom(100)
114 // continue to use user-scrolling to make this work equivalent to how it 'always' worked
115 , mxScrolledWindow(m_xBuilder->weld_scrolled_window("scrolledwindow", true))
116 , mxGraphic(new SmGraphicWidget(rShell, *this))
117 , mxGraphicWin(new weld::CustomWeld(*m_xBuilder, "mathview", *mxGraphic))
118{
119 InitControlBase(mxGraphic->GetDrawingArea());
120
121 mxScrolledWindow->connect_hadjustment_changed(LINK(this, SmGraphicWindow, ScrollHdl));
122 mxScrolledWindow->connect_vadjustment_changed(LINK(this, SmGraphicWindow, ScrollHdl));
123
124 // docking windows are usually hidden (often already done in the
125 // resource) and will be shown by the sfx framework.
126 Hide();
127}
128
130{
131 InitControlBase(nullptr);
132 mxGraphicWin.reset();
133 mxGraphic.reset();
134 mxScrolledWindow.reset();
136}
137
139{
140 disposeOnce();
141}
142
144{
146
147 // get the new output-size in pixel
148 Size aOutPixSz = GetOutputSizePixel();
149
150 // determine the size of the output-area and if we need scrollbars
151 const auto nScrSize = mxScrolledWindow->get_scroll_thickness();
152 bool bVVisible = false; // by default no vertical-ScrollBar
153 bool bHVisible = false; // by default no horizontal-ScrollBar
154 bool bChanged; // determines if a visibility was changed
155 do
156 {
157 bChanged = false;
158
159 // does we need a vertical ScrollBar
160 if ( aOutPixSz.Width() < aTotPixSz.Width() && !bHVisible )
161 {
162 bHVisible = true;
163 aOutPixSz.AdjustHeight( -nScrSize );
164 bChanged = true;
165 }
166
167 // does we need a horizontal ScrollBar
168 if ( aOutPixSz.Height() < aTotPixSz.Height() && !bVVisible )
169 {
170 bVVisible = true;
171 aOutPixSz.AdjustWidth( -nScrSize );
172 bChanged = true;
173 }
174
175 }
176 while ( bChanged ); // until no visibility has changed
177
178 // store the old offset and map-mode
180 Point aOldPixOffset(aPixOffset);
181
182 // justify (right/bottom borders should never exceed the virtual window)
183 Size aPixDelta;
184 if ( aPixOffset.X() < 0 &&
185 aPixOffset.X() + aTotPixSz.Width() < aOutPixSz.Width() )
186 aPixDelta.setWidth(
187 aOutPixSz.Width() - ( aPixOffset.X() + aTotPixSz.Width() ) );
188 if ( aPixOffset.Y() < 0 &&
189 aPixOffset.Y() + aTotPixSz.Height() < aOutPixSz.Height() )
190 aPixDelta.setHeight(
191 aOutPixSz.Height() - ( aPixOffset.Y() + aTotPixSz.Height() ) );
192 if ( aPixDelta.Width() || aPixDelta.Height() )
193 {
194 aPixOffset.AdjustX(aPixDelta.Width() );
195 aPixOffset.AdjustY(aPixDelta.Height() );
196 }
197
198 // for axis without scrollbar restore the origin
199 if ( !bVVisible || !bHVisible )
200 {
202 bHVisible
203 ? aPixOffset.X()
204 : (aOutPixSz.Width()-aTotPixSz.Width()) / 2,
205 bVVisible
206 ? aPixOffset.Y()
207 : (aOutPixSz.Height()-aTotPixSz.Height()) / 2 );
208 }
209 if (bHVisible && mxScrolledWindow->get_hpolicy() == VclPolicyType::NEVER)
210 aPixOffset.setX( 0 );
211 if (bVVisible && mxScrolledWindow->get_vpolicy() == VclPolicyType::NEVER)
212 aPixOffset.setY( 0 );
213
214 // select the shifted map-mode
215 if (aPixOffset != aOldPixOffset)
217
218 // show or hide scrollbars
219 mxScrolledWindow->set_vpolicy(bVVisible ? VclPolicyType::ALWAYS : VclPolicyType::NEVER);
220 mxScrolledWindow->set_hpolicy(bHVisible ? VclPolicyType::ALWAYS : VclPolicyType::NEVER);
221
222 // resize scrollbars and set their ranges
223 if ( bHVisible )
224 {
225 mxScrolledWindow->hadjustment_configure(-aPixOffset.X(), 0, aTotPixSz.Width(), nColumnPixW,
226 aOutPixSz.Width(), aOutPixSz.Width());
227 }
228 if ( bVVisible )
229 {
230 mxScrolledWindow->vadjustment_configure(-aPixOffset.Y(), 0, aTotPixSz.Height(), nLinePixH,
231 aOutPixSz.Height(), aOutPixSz.Height());
232 }
233}
234
236{
237 MapMode aMap(GetGraphicMapMode());
238 Point aNewPixOffset(aPixOffset);
239
240 // scrolling horizontally?
241 if (mxScrolledWindow->get_hpolicy() == VclPolicyType::ALWAYS)
242 aNewPixOffset.setX(-mxScrolledWindow->hadjustment_get_value());
243
244 // scrolling vertically?
245 if (mxScrolledWindow->get_vpolicy() == VclPolicyType::ALWAYS)
246 aNewPixOffset.setY(-mxScrolledWindow->vadjustment_get_value());
247
248 // scrolling?
249 if (aPixOffset == aNewPixOffset)
250 return;
251
252 // recompute the logical scroll units
253 aPixOffset = aNewPixOffset;
254
255 SetGraphicMapMode(aMap);
256}
257
259{
260 OutputDevice& rDevice = mxGraphic->GetOutputDevice();
261 MapMode aMap( rNewMapMode );
262 aMap.SetOrigin( aMap.GetOrigin() + rDevice.PixelToLogic( aPixOffset, aMap ) );
263 rDevice.SetMapMode( aMap );
264 mxGraphic->Invalidate();
265}
266
268{
269 OutputDevice& rDevice = mxGraphic->GetOutputDevice();
270 MapMode aMap(rDevice.GetMapMode());
271 aMap.SetOrigin( aMap.GetOrigin() - rDevice.PixelToLogic( aPixOffset ) );
272 return aMap;
273}
274
275void SmGraphicWindow::SetTotalSize( const Size& rNewSize )
276{
277 aTotPixSz = mxGraphic->GetOutputDevice().LogicToPixel(rNewSize);
278 Resize();
279}
280
282{
283 return mxGraphic->GetOutputDevice().PixelToLogic(aTotPixSz);
284}
285
287{
288 GetParent()->ToTop();
289 Point aPos(5, 5);
290 if (rCEvt.IsMouseEvent())
291 aPos = rCEvt.GetMousePosPixel();
292
293 // added for replaceability of context menus
294 SfxDispatcher::ExecutePopup( this, &aPos );
295}
296
298 : mrGraphicWindow(rGraphicWindow)
299 , bIsCursorVisible(false)
300 , bIsLineVisible(false)
301 , aCaretBlinkTimer("SmGraphicWidget aCaretBlinkTimer")
302 , mrViewShell(rShell)
303{
304}
305
307{
309
310 OutputDevice& rDevice = GetOutputDevice();
311
312 rDevice.SetBackground(SM_MOD()->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor);
313
315 {
316 // Disable map mode, so that it's possible to send mouse event coordinates
317 // directly in twips.
318 rDevice.EnableMapMode(false);
319 }
320 else
321 {
322 const Fraction aFraction(1, 1);
323 rDevice.SetMapMode(MapMode(SmMapUnit(), Point(), aFraction, aFraction));
324 }
325
326 SetTotalSize();
327
329
330 ShowLine(false);
332}
333
335{
336 if (mxAccessible.is())
337 mxAccessible->ClearWin(); // make Accessible nonfunctional
338 mxAccessible.clear();
340}
341
343
345{
346 assert(GetDoc());
347 return GetDoc()->GetCursor();
348}
349
351{
352 GrabFocus();
353
354 // set formula-cursor and selection of edit window according to the
355 // position clicked at
356
357 SAL_WARN_IF( rMEvt.GetClicks() == 0, "starmath", "0 clicks" );
358 if ( !rMEvt.IsLeft() )
359 return true;
360
361 OutputDevice& rDevice = GetOutputDevice();
362 // get click position relative to formula
363 Point aPos(rDevice.PixelToLogic(rMEvt.GetPosPixel()) - GetFormulaDrawPos());
364
365 const SmNode *pTree = GetDoc()->GetFormulaTree();
366 if (!pTree)
367 return true;
368
370 GetCursor().MoveTo(&rDevice, aPos, !rMEvt.IsShift());
371 // 'on grab' window events are missing in lok, do it explicitly
373 SetIsCursorVisible(true);
374 return true;
375 }
376 const SmNode *pNode = nullptr;
377 // if it was clicked inside the formula then get the appropriate node
378 if (pTree->OrientedDist(aPos) <= 0)
379 pNode = pTree->FindRectClosestTo(aPos);
380
381 if (!pNode)
382 return true;
383
385 if (!pEdit)
386 return true;
387
388 // set selection to the beginning of the token
389 pEdit->SetSelection(pNode->GetSelection());
390 SetCursor(pNode);
391
392 // allow for immediate editing and
394 pEdit->GrabFocus();
395
396 return true;
397}
398
400{
402 {
403 OutputDevice& rDevice = GetOutputDevice();
404 Point aPos(rDevice.PixelToLogic(rMEvt.GetPosPixel()) - GetFormulaDrawPos());
405 GetCursor().MoveTo(&rDevice, aPos, false);
406
408 SetIsCursorVisible(true);
411 }
412 return true;
413}
414
416{
418 return;
419 if (SmEditWindow* pEdit = GetView().GetEditWindow())
420 pEdit->Flush();
421 //Let view shell know what insertions should be done in visual editor
423 SetIsCursorVisible(true);
424 ShowLine(true);
427}
428
430{
431 if (mxAccessible.is())
432 {
433 uno::Any aOldValue, aNewValue;
434 aOldValue <<= AccessibleStateType::FOCUSED;
435 // aNewValue remains empty
436 mxAccessible->LaunchEvent( AccessibleEventId::STATE_CHANGED,
437 aOldValue, aNewValue );
438 }
440 return;
441 SetIsCursorVisible(false);
442 ShowLine(false);
445}
446
448{
449 if (SmDocShell* pDoc = GetDoc())
450 pDoc->Repaint();
451}
452
453IMPL_LINK_NOARG(SmGraphicWidget, CaretBlinkTimerHdl, Timer *, void)
454{
455 if (IsCursorVisible())
456 SetIsCursorVisible(false);
457 else
458 SetIsCursorVisible(true);
459
460 RepaintViewShellDoc();
461}
462
464{
466 return; // No blinking in lok case
467 aCaretBlinkTimer.SetInvokeHandler(LINK(this, SmGraphicWidget, CaretBlinkTimerHdl));
468 aCaretBlinkTimer.SetTimeout(Application::GetSettings().GetStyleSettings().GetCursorBlinkTime());
469}
470
472{
474 return;
477}
478
480{
482 return;
484}
485
486// shows or hides the formula-cursor depending on 'bShow' is true or not
488{
490 return;
491
492 bool bInvert = bShow != IsCursorVisible();
493 if (bInvert)
495
496 SetIsCursorVisible(bShow);
497}
498
500{
502 return;
503
504 bIsLineVisible = bShow;
505}
506
508{
509 bIsCursorVisible = bVis;
511 {
513 mrViewShell.libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE,
514 OString::boolean(bVis));
515 }
516}
517
519{
521 return;
522
523 const SmNode *pTree = GetDoc()->GetFormulaTree();
524
525 // get appropriate rectangle
526 Point aOffset (pNode->GetTopLeft() - pTree->GetTopLeft()),
527 aTLPos (GetFormulaDrawPos() + aOffset);
528 aTLPos.AdjustX( -(pNode->GetItalicLeftSpace()) );
529 Size aSize (pNode->GetItalicSize());
530
531 SetCursor(tools::Rectangle(aTLPos, aSize));
532}
533
535 // sets cursor to new position (rectangle) 'rRect'.
536 // The old cursor will be removed, and the new one will be shown if
537 // that is activated in the ConfigItem
538{
540 return;
541
542 SmModule *pp = SM_MOD();
543
544 if (IsCursorVisible())
545 ShowCursor(false); // clean up remainings of old cursor
546 aCursorRect = rRect;
547 if (pp->GetConfig()->IsShowFormulaCursor())
548 ShowCursor(true); // draw new cursor
549}
550
551const SmNode * SmGraphicWidget::SetCursorPos(sal_uInt16 nRow, sal_uInt16 nCol)
552 // looks for a VISIBLE node in the formula tree with its token at
553 // (or around) the position 'nRow', 'nCol' in the edit window
554 // (row and column numbering starts with 1 there!).
555 // If there is such a node the formula-cursor is set to cover that nodes
556 // rectangle. If not the formula-cursor will be hidden.
557 // In any case the search result is being returned.
558{
560 return nullptr;
561
562 // find visible node with token at nRow, nCol
563 const SmNode *pTree = GetDoc()->GetFormulaTree(),
564 *pNode = nullptr;
565 if (pTree)
566 pNode = pTree->FindTokenAt(nRow, nCol);
567
568 if (pNode)
569 SetCursor(pNode);
570 else
571 ShowCursor(false);
572
573 return pNode;
574}
575
577{
578 assert(GetDoc());
579 SmDocShell& rDoc = *GetDoc();
580 Point aPoint;
581
582 rDoc.DrawFormula(rRenderContext, aPoint, true);
584 aFormulaDrawPos = aPoint;
586 {
587 //Draw cursor if any...
588 if (rDoc.HasCursor() && IsLineVisible())
589 rDoc.GetCursor().Draw(rRenderContext, aPoint, IsCursorVisible());
590 }
591 else
592 {
593 SetIsCursorVisible(false); // (old) cursor must be drawn again
594
595 if (const SmEditWindow* pEdit = GetView().GetEditWindow())
596 { // get new position for formula-cursor (for possible altered formula)
597 sal_Int32 nRow;
598 sal_uInt16 nCol;
599 SmGetLeftSelectionPart(pEdit->GetSelection(), nRow, nCol);
600 const SmNode *pFound = SetCursorPos(static_cast<sal_uInt16>(nRow), nCol);
601
602 SmModule *pp = SM_MOD();
603 if (pFound && pp->GetConfig()->IsShowFormulaCursor())
604 ShowCursor(true);
605 }
606 }
607}
608
610{
611 assert(GetDoc());
612 OutputDevice& rDevice = GetOutputDevice();
613 const Size aTmp(rDevice.PixelToLogic(rDevice.LogicToPixel(GetDoc()->GetSize())));
614 if (aTmp != mrGraphicWindow.GetTotalSize())
616}
617
618namespace
619{
620SmBracketType BracketTypeOf(sal_uInt32 c)
621{
622 switch (c)
623 {
624 case '(':
625 case ')':
627 case '[':
628 case ']':
630 case '{':
631 case '}':
633 }
634 assert(false); // Unreachable
636}
637
638bool CharInput(sal_uInt32 c, SmCursor& rCursor, OutputDevice& rDevice)
639{
640 switch (c)
641 {
642 case 0:
643 return false;
644 case ' ':
646 break;
647 case '!':
649 break;
650 case '%':
652 break;
653 case '*':
654 rCursor.InsertElement(CDotElement);
655 break;
656 case '+':
657 rCursor.InsertElement(PlusElement);
658 break;
659 case '-':
661 break;
662 case '<':
664 break;
665 case '=':
667 break;
668 case '>':
670 break;
671 case '^':
672 rCursor.InsertSubSup(RSUP);
673 break;
674 case '_':
675 rCursor.InsertSubSup(RSUB);
676 break;
677 case '/':
678 rCursor.InsertFraction();
679 break;
680 case '(':
681 case '[':
682 case '{':
683 rCursor.InsertBrackets(BracketTypeOf(c));
684 break;
685 case ')':
686 case ']':
687 case '}':
688 if (rCursor.IsAtTailOfBracket(BracketTypeOf(c)))
689 {
690 rCursor.Move(&rDevice, MoveRight);
691 break;
692 }
693 [[fallthrough]];
694 default:
695 rCursor.InsertText(OUString(&c, 1));
696 break;
697 }
698 return true;
699}
700}
701
703{
704 if (rKEvt.GetKeyCode().GetCode() == KEY_F1)
705 {
707 return true;
708 }
709
711 return GetView().KeyInput(rKEvt);
712
713 bool bConsumed = true;
714
715 SmCursor& rCursor = GetCursor();
716 switch (rKEvt.GetKeyCode().GetFunction())
717 {
718 case KeyFuncType::COPY:
719 rCursor.Copy();
720 break;
721 case KeyFuncType::CUT:
722 rCursor.Cut();
723 break;
724 case KeyFuncType::PASTE:
725 rCursor.Paste();
726 break;
727 case KeyFuncType::UNDO:
728 GetDoc()->Execute(o3tl::temporary(SfxRequest(*GetView().GetFrame(), SID_UNDO)));
729 break;
730 case KeyFuncType::REDO:
731 GetDoc()->Execute(o3tl::temporary(SfxRequest(*GetView().GetFrame(), SID_REDO)));
732 break;
733 default:
734 switch (rKEvt.GetKeyCode().GetCode())
735 {
736 case KEY_LEFT:
737 rCursor.Move(&GetOutputDevice(), MoveLeft, !rKEvt.GetKeyCode().IsShift());
738 break;
739 case KEY_RIGHT:
740 rCursor.Move(&GetOutputDevice(), MoveRight, !rKEvt.GetKeyCode().IsShift());
741 break;
742 case KEY_UP:
743 rCursor.Move(&GetOutputDevice(), MoveUp, !rKEvt.GetKeyCode().IsShift());
744 break;
745 case KEY_DOWN:
746 rCursor.Move(&GetOutputDevice(), MoveDown, !rKEvt.GetKeyCode().IsShift());
747 break;
748 case KEY_RETURN:
749 if (!rKEvt.GetKeyCode().IsShift())
750 rCursor.InsertRow();
751 break;
752 case KEY_DELETE:
753 if (!rCursor.HasSelection())
754 {
755 rCursor.Move(&GetOutputDevice(), MoveRight, false);
756 if (rCursor.HasComplexSelection())
757 break;
758 }
759 rCursor.Delete();
760 break;
761 case KEY_BACKSPACE:
762 rCursor.DeletePrev(&GetOutputDevice());
763 break;
764 default:
765 if (!CharInput(rKEvt.GetCharCode(), rCursor, GetOutputDevice()))
766 bConsumed = GetView().KeyInput(rKEvt);
767 }
768 }
771 SetIsCursorVisible(true);
773
774 return bConsumed;
775}
776
778{
779 bool bCallBase = true;
780 if (!GetView().GetViewFrame().GetFrame().IsInPlace())
781 {
782 switch ( rCEvt.GetCommand() )
783 {
784 case CommandEventId::ContextMenu:
785 // purely for "ExecutePopup" taking a vcl::Window and
786 // we assume SmGraphicWindow 0,0 is at SmEditWindow 0,0
788 bCallBase = false;
789 break;
790
791 case CommandEventId::Wheel:
792 {
793 const CommandWheelData* pWData = rCEvt.GetWheelData();
794 if ( pWData && CommandWheelMode::ZOOM == pWData->GetMode() )
795 {
796 sal_uInt16 nTmpZoom = mrGraphicWindow.GetZoom();
797 if( 0 > pWData->GetDelta() )
798 nTmpZoom -= 10;
799 else
800 nTmpZoom += 10;
801 mrGraphicWindow.SetZoom(nTmpZoom);
802 bCallBase = false;
803 }
804 break;
805 }
806 case CommandEventId::GestureZoom:
807 {
809 if (pData)
810 {
811 if (pData->meEventType == GestureEventZoomType::Begin)
812 {
813 mfLastZoomScale = pData->mfScaleDelta;
814 }
815 else if (pData->meEventType == GestureEventZoomType::Update)
816 {
817 double deltaBetweenEvents = (pData->mfScaleDelta - mfLastZoomScale) / mfLastZoomScale;
818 mfLastZoomScale = pData->mfScaleDelta;
819
820 // Accumulate fractional zoom to avoid small zoom changes from being ignored
821 mfAccumulatedZoom += deltaBetweenEvents;
822 int nZoomChangePercent = mfAccumulatedZoom * 100;
823 mfAccumulatedZoom -= nZoomChangePercent / 100.0;
824
825 sal_uInt16 nZoom = mrGraphicWindow.GetZoom();
826 nZoom += nZoomChangePercent;
828 }
829 bCallBase = false;
830 }
831 break;
832 }
833
834 default: break;
835 }
836 }
837 else
838 {
839 switch (rCEvt.GetCommand())
840 {
841 case CommandEventId::ExtTextInput:
843 {
845 assert(pData);
846 const OUString& rText = pData->GetText();
847 SmCursor& rCursor = GetCursor();
848 OutputDevice& rDevice = GetOutputDevice();
849 for (sal_Int32 i = 0; i < rText.getLength();)
850 CharInput(rText.iterateCodePoints(&i), rCursor, rDevice);
851 bCallBase = false;
852 }
853 break;
854 default:
855 break;
856 }
857 }
858 return !bCallBase;
859}
860
861void SmGraphicWindow::SetZoom(sal_uInt16 Factor)
862{
864 return;
865 nZoom = std::clamp(Factor, MINZOOM, MAXZOOM);
866 Fraction aFraction(nZoom, 100);
867 SetGraphicMapMode(MapMode(SmMapUnit(), Point(), aFraction, aFraction));
868 mxGraphic->SetTotalSize();
869 SmViewShell& rViewSh = mxGraphic->GetView();
870 rViewSh.GetViewFrame().GetBindings().Invalidate(SID_ATTR_ZOOM);
871 rViewSh.GetViewFrame().GetBindings().Invalidate(SID_ATTR_ZOOMSLIDER);
872}
873
875{
876 // set defined mapmode before calling 'LogicToPixel' below
878
879 assert(mxGraphic->GetDoc());
880 Size aSize(mxGraphic->GetOutputDevice().LogicToPixel(mxGraphic->GetDoc()->GetSize()));
881 Size aWindowSize(GetSizePixel());
882
883 if (!aSize.IsEmpty())
884 {
885 tools::Long nVal = std::min ((85 * aWindowSize.Width()) / aSize.Width(),
886 (85 * aWindowSize.Height()) / aSize.Height());
887 SetZoom ( sal::static_int_cast< sal_uInt16 >(nVal) );
888 }
889}
890
891uno::Reference< XAccessible > SmGraphicWidget::CreateAccessible()
892{
893 if (!mxAccessible.is())
894 {
895 mxAccessible = new SmGraphicAccessible( this );
896 }
897 return mxAccessible;
898}
899
900/**************************************************************************/
902 sal_uInt16 nId_,
903 SfxBindings &rBindings) :
904 SfxControllerItem(nId_, rBindings),
905 rGraphic(rSmGraphic)
906{
907}
908
910{
914}
915
916/**************************************************************************/
918 sal_uInt16 nId_,
919 SfxBindings &rBindings) :
920 SfxControllerItem(nId_, rBindings),
921 rEdit(rSmEdit)
922{
923}
924
926{
927 const SfxStringItem *pItem = dynamic_cast<const SfxStringItem*>( pState);
928
929 if ((pItem != nullptr) && (rEdit.GetText() != pItem->GetValue()))
930 rEdit.SetText(pItem->GetValue());
932}
933
934/**************************************************************************/
936 vcl::Window *pParent)
937 : SfxDockingWindow(pBindings_, pChildWindow, pParent, "EditWindow", "modules/smath/ui/editwindow.ui")
938 , m_xEdit(new SmEditWindow(*this, *m_xBuilder))
939 , aController(*m_xEdit, SID_TEXT, *pBindings_)
940 , bExiting(false)
941 , aInitialFocusTimer("SmCmdBoxWindow aInitialFocusTimer")
942{
943 set_id("math_edit");
944
946 SetSizePixel(LogicToPixel(Size(292 , 94), MapMode(MapUnit::MapAppFont)));
947 SetText(SmResId(STR_CMDBOXWINDOW));
948
949 Hide();
950
951 // Don't try to grab focus in LOK inline edit mode
953 {
954 aInitialFocusTimer.SetInvokeHandler(LINK(this, SmCmdBoxWindow, InitialFocusTimerHdl));
956 }
957}
958
960{
961 Point aRet(rPos);
962 int x(0), y(0), width(0), height(0);
963 rWidget.get_extents_relative_to(*m_xContainer, x, y, width, height);
964 aRet.Move(x, y);
965 aRet.Move(m_xBox->GetPosPixel().X(), m_xBox->GetPosPixel().Y());
966 return aRet;
967}
968
970{
971 ToTop();
972 SmViewShell *pViewSh = GetView();
973 if (pViewSh)
974 pViewSh->GetViewFrame().GetDispatcher()->ExecutePopup("edit", this, &rPos);
975}
976
978{
979 if (rCEvt.GetCommand() == CommandEventId::ContextMenu)
980 {
982 return;
983 }
984
985 SfxDockingWindow::Command(rCEvt);
986}
987
989{
990 disposeOnce();
991}
992
994{
996 bExiting = true;
998 m_xEdit.reset();
1000}
1001
1003{
1004 SfxDispatcher *pDispatcher = GetBindings().GetDispatcher();
1005 SfxViewShell *pView = pDispatcher ? pDispatcher->GetFrame()->GetViewShell() : nullptr;
1006 return dynamic_cast<SmViewShell*>( pView);
1007}
1008
1010{
1011 switch (eAlign)
1012 {
1013 case SfxChildAlignment::LEFT:
1014 case SfxChildAlignment::RIGHT:
1015 return Size();
1016 default:
1017 break;
1018 }
1019 return SfxDockingWindow::CalcDockingSize(eAlign);
1020}
1021
1023 SfxChildAlignment eWish)
1024{
1025 switch (eWish)
1026 {
1027 case SfxChildAlignment::TOP:
1028 case SfxChildAlignment::BOTTOM:
1029 case SfxChildAlignment::NOALIGNMENT:
1030 return eWish;
1031 default:
1032 break;
1033 }
1034
1035 return eActual;
1036}
1037
1039{
1040 if (StateChangedType::InitShow == nStateChange)
1041 {
1042 Resize(); // avoid SmEditWindow not being painted correctly
1043
1044 // set initial position of window in floating mode
1045 if (IsFloatingMode())
1046 AdjustPosition();
1047
1049 }
1050
1051 SfxDockingWindow::StateChanged( nStateChange );
1052}
1053
1054IMPL_LINK_NOARG( SmCmdBoxWindow, InitialFocusTimerHdl, Timer *, void )
1055{
1056 // We want to have the focus in the edit window once Math has been opened
1057 // to allow for immediate typing.
1058 // Problem: There is no proper way to do this
1059 // Thus: this timer based solution has been implemented (see GrabFocus below)
1060
1061 // Follow-up problem (#i114910): grabbing the focus may bust the help system since
1062 // it relies on getting the current frame which conflicts with grabbing the focus.
1063 // Thus aside from the 'GrabFocus' call everything else is to get the
1064 // help reliably working despite using 'GrabFocus'.
1065
1066 try
1067 {
1068 uno::Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create( comphelper::getProcessComponentContext() );
1069
1070 m_xEdit->GrabFocus();
1071
1072 SmViewShell* pView = GetView();
1073 assert(pView);
1074 bool bInPlace = pView->GetViewFrame().GetFrame().IsInPlace();
1075 uno::Reference< frame::XFrame > xFrame( GetBindings().GetDispatcher()->GetFrame()->GetFrame().GetFrameInterface());
1076 if ( bInPlace )
1077 {
1078 uno::Reference<container::XChild> xModel(pView->GetDoc()->GetModel(),
1079 uno::UNO_QUERY_THROW);
1080 uno::Reference< frame::XModel > xParent( xModel->getParent(), uno::UNO_QUERY_THROW );
1081 uno::Reference< frame::XController > xParentCtrler( xParent->getCurrentController() );
1082 uno::Reference< frame::XFramesSupplier > xParentFrame( xParentCtrler->getFrame(), uno::UNO_QUERY_THROW );
1083 xParentFrame->setActiveFrame( xFrame );
1084 }
1085 else
1086 {
1087 xDesktop->setActiveFrame( xFrame );
1088 }
1089 }
1090 catch (uno::Exception &)
1091 {
1092 SAL_WARN( "starmath", "failed to properly set initial focus to edit window" );
1093 }
1094}
1095
1097{
1098 const tools::Rectangle aRect( Point(), GetParent()->GetOutputSizePixel() );
1099 Point aTopLeft( Point( aRect.Left(),
1100 aRect.Bottom() - GetSizePixel().Height() ) );
1101 Point aPos( GetParent()->OutputToScreenPixel( aTopLeft ) );
1102 if (aPos.X() < 0)
1103 aPos.setX( 0 );
1104 if (aPos.Y() < 0)
1105 aPos.setY( 0 );
1106 SetPosPixel( aPos );
1107}
1108
1110{
1112
1113 if (GetFloatingWindow())
1114 GetFloatingWindow()->SetMinOutputSizePixel(Size (200, 50));
1115}
1116
1118{
1119 if (!bExiting)
1120 m_xEdit->GrabFocus();
1121}
1122
1124
1125SmCmdBoxWrapper::SmCmdBoxWrapper(vcl::Window *pParentWindow, sal_uInt16 nId,
1126 SfxBindings *pBindings,
1127 SfxChildWinInfo *pInfo) :
1128 SfxChildWindow(pParentWindow, nId)
1129{
1130 VclPtrInstance<SmCmdBoxWindow> pDialog(pBindings, this, pParentWindow);
1131 SetWindow(pDialog);
1132 // make window docked to the bottom initially (after first start)
1133 SetAlignment(SfxChildAlignment::BOTTOM);
1134 pDialog->setDeferredProperties();
1135 pDialog->set_border_width(CMD_BOX_PADDING);
1136 pDialog->set_margin_top(CMD_BOX_PADDING_TOP);
1137 pDialog->Initialize(pInfo);
1138}
1139
1141
1142void SmViewShell::InitInterface_Impl()
1143{
1144 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_TOOLS,
1145 SfxVisibilityFlags::Standard | SfxVisibilityFlags::FullScreen | SfxVisibilityFlags::Server,
1146 ToolbarId::Math_Toolbox);
1147 //Dummy-Objectbar, to avoid quiver while activating
1148
1149 GetStaticInterface()->RegisterChildWindow(SmCmdBoxWrapper::GetChildWindowId());
1150 GetStaticInterface()->RegisterChildWindow(SfxInfoBarContainerChild::GetChildWindowId());
1151
1152 GetStaticInterface()->RegisterChildWindow(::sfx2::sidebar::SidebarChildWindow::GetChildWindowId());
1153}
1154
1156{
1158}
1159
1160void SmViewShell::InnerResizePixel(const Point &rOfs, const Size &rSize, bool)
1161{
1162 Size aObjSize = GetObjectShell()->GetVisArea().GetSize();
1163 if ( !aObjSize.IsEmpty() )
1164 {
1165 Size aProvidedSize = GetWindow()->PixelToLogic(rSize, MapMode(SmMapUnit()));
1166 Fraction aZoomX(aProvidedSize.Width(), aObjSize.Width());
1167 Fraction aZoomY(aProvidedSize.Height(), aObjSize.Height());
1168 MapMode aMap(mxGraphicWindow->GetGraphicMapMode());
1169 aMap.SetScaleX(aZoomX);
1170 aMap.SetScaleY(aZoomY);
1171 mxGraphicWindow->SetGraphicMapMode(aMap);
1172 }
1173
1175 mxGraphicWindow->SetPosSizePixel(rOfs, rSize);
1177}
1178
1179void SmViewShell::OuterResizePixel(const Point &rOfs, const Size &rSize)
1180{
1181 mxGraphicWindow->SetPosSizePixel(rOfs, rSize);
1182 if (GetDoc()->IsPreview())
1183 mxGraphicWindow->ZoomToFitInWindow();
1184}
1185
1187{
1188 rRect.SetSize(mxGraphicWindow->GetSizePixel());
1189}
1190
1192{
1193 const Fraction &rFrac = std::min(rX, rY);
1194 mxGraphicWindow->SetZoom(sal::static_int_cast<sal_uInt16>(tools::Long(rFrac * Fraction( 100, 1 ))));
1195
1196 //To avoid rounding errors base class regulates crooked values too
1197 //if necessary
1199}
1200
1201Size SmViewShell::GetTextLineSize(OutputDevice const & rDevice, const OUString& rLine)
1202{
1203 Size aSize(rDevice.GetTextWidth(rLine), rDevice.GetTextHeight());
1204 const tools::Long nTabPos = rLine.isEmpty() ? 0 : rDevice.approximate_digit_width() * 8;
1205
1206 if (nTabPos)
1207 {
1208 aSize.setWidth( 0 );
1209 sal_Int32 nPos = 0;
1210 do
1211 {
1212 if (nPos > 0)
1213 aSize.setWidth( ((aSize.Width() / nTabPos) + 1) * nTabPos );
1214
1215 const OUString aText = rLine.getToken(0, '\t', nPos);
1216 aSize.AdjustWidth(rDevice.GetTextWidth(aText) );
1217 }
1218 while (nPos >= 0);
1219 }
1220
1221 return aSize;
1222}
1223
1224Size SmViewShell::GetTextSize(OutputDevice const & rDevice, std::u16string_view rText, tools::Long MaxWidth)
1225{
1226 Size aSize;
1227 Size aTextSize;
1228 if (rText.empty())
1229 return aTextSize;
1230
1231 sal_Int32 nPos = 0;
1232 do
1233 {
1234 OUString aLine( o3tl::getToken(rText, 0, '\n', nPos) );
1235 aLine = aLine.replaceAll("\r", "");
1236
1237 aSize = GetTextLineSize(rDevice, aLine);
1238
1239 if (aSize.Width() > MaxWidth)
1240 {
1241 do
1242 {
1243 OUString aText;
1244 sal_Int32 m = aLine.getLength();
1245 sal_Int32 nLen = m;
1246
1247 for (sal_Int32 n = 0; n < nLen; n++)
1248 {
1249 sal_Unicode cLineChar = aLine[n];
1250 if ((cLineChar == ' ') || (cLineChar == '\t'))
1251 {
1252 aText = aLine.copy(0, n);
1253 if (GetTextLineSize(rDevice, aText).Width() < MaxWidth)
1254 m = n;
1255 else
1256 break;
1257 }
1258 }
1259
1260 aText = aLine.copy(0, m);
1261 aLine = aLine.replaceAt(0, m, u"");
1262 aSize = GetTextLineSize(rDevice, aText);
1263 aTextSize.AdjustHeight(aSize.Height() );
1264 aTextSize.setWidth( std::clamp(aSize.Width(), aTextSize.Width(), MaxWidth) );
1265
1266 aLine = comphelper::string::stripStart(aLine, ' ');
1267 aLine = comphelper::string::stripStart(aLine, '\t');
1268 aLine = comphelper::string::stripStart(aLine, ' ');
1269 }
1270 while (!aLine.isEmpty());
1271 }
1272 else
1273 {
1274 aTextSize.AdjustHeight(aSize.Height() );
1275 aTextSize.setWidth( std::max(aTextSize.Width(), aSize.Width()) );
1276 }
1277 }
1278 while (nPos >= 0);
1279
1280 return aTextSize;
1281}
1282
1283void SmViewShell::DrawTextLine(OutputDevice& rDevice, const Point& rPosition, const OUString& rLine)
1284{
1285 Point aPoint(rPosition);
1286 const tools::Long nTabPos = rLine.isEmpty() ? 0 : rDevice.approximate_digit_width() * 8;
1287
1288 if (nTabPos)
1289 {
1290 sal_Int32 nPos = 0;
1291 do
1292 {
1293 if (nPos > 0)
1294 aPoint.setX( ((aPoint.X() / nTabPos) + 1) * nTabPos );
1295
1296 OUString aText = rLine.getToken(0, '\t', nPos);
1297 rDevice.DrawText(aPoint, aText);
1298 aPoint.AdjustX(rDevice.GetTextWidth(aText) );
1299 }
1300 while ( nPos >= 0 );
1301 }
1302 else
1303 rDevice.DrawText(aPoint, rLine);
1304}
1305
1306void SmViewShell::DrawText(OutputDevice& rDevice, const Point& rPosition, std::u16string_view rText, sal_uInt16 MaxWidth)
1307{
1308 if (rText.empty())
1309 return;
1310
1311 Point aPoint(rPosition);
1312 Size aSize;
1313
1314 sal_Int32 nPos = 0;
1315 do
1316 {
1317 OUString aLine( o3tl::getToken(rText, 0, '\n', nPos) );
1318 aLine = aLine.replaceAll("\r", "");
1319 aSize = GetTextLineSize(rDevice, aLine);
1320 if (aSize.Width() > MaxWidth)
1321 {
1322 do
1323 {
1324 OUString aText;
1325 sal_Int32 m = aLine.getLength();
1326 sal_Int32 nLen = m;
1327
1328 for (sal_Int32 n = 0; n < nLen; n++)
1329 {
1330 sal_Unicode cLineChar = aLine[n];
1331 if ((cLineChar == ' ') || (cLineChar == '\t'))
1332 {
1333 aText = aLine.copy(0, n);
1334 if (GetTextLineSize(rDevice, aText).Width() < MaxWidth)
1335 m = n;
1336 else
1337 break;
1338 }
1339 }
1340 aText = aLine.copy(0, m);
1341 aLine = aLine.replaceAt(0, m, u"");
1342
1343 DrawTextLine(rDevice, aPoint, aText);
1344 aPoint.AdjustY(aSize.Height() );
1345
1346 aLine = comphelper::string::stripStart(aLine, ' ');
1347 aLine = comphelper::string::stripStart(aLine, '\t');
1348 aLine = comphelper::string::stripStart(aLine, ' ');
1349 }
1350 while (GetTextLineSize(rDevice, aLine).Width() > MaxWidth);
1351
1352 // print the remaining text
1353 if (!aLine.isEmpty())
1354 {
1355 DrawTextLine(rDevice, aPoint, aLine);
1356 aPoint.AdjustY(aSize.Height() );
1357 }
1358 }
1359 else
1360 {
1361 DrawTextLine(rDevice, aPoint, aLine);
1362 aPoint.AdjustY(aSize.Height() );
1363 }
1364 }
1365 while ( nPos >= 0 );
1366}
1367
1368void SmViewShell::Impl_Print(OutputDevice &rOutDev, const SmPrintUIOptions &rPrintUIOptions, tools::Rectangle aOutRect )
1369{
1370 const bool bIsPrintTitle = rPrintUIOptions.getBoolValue( PRTUIOPT_TITLE_ROW, true );
1371 const bool bIsPrintFrame = rPrintUIOptions.getBoolValue( PRTUIOPT_BORDER, true );
1372 const bool bIsPrintFormulaText = rPrintUIOptions.getBoolValue( PRTUIOPT_FORMULA_TEXT, true );
1373 SmPrintSize ePrintSize( static_cast< SmPrintSize >( rPrintUIOptions.getIntValue( PRTUIOPT_PRINT_FORMAT, PRINT_SIZE_NORMAL ) ));
1374 const sal_uInt16 nZoomFactor = static_cast< sal_uInt16 >(rPrintUIOptions.getIntValue( PRTUIOPT_PRINT_SCALE, 100 ));
1375
1376 rOutDev.Push();
1377 rOutDev.SetLineColor( COL_BLACK );
1378
1379 // output text on top
1380 if (bIsPrintTitle)
1381 {
1382 Size aSize600 (0, 600);
1383 Size aSize650 (0, 650);
1384 vcl::Font aFont(FAMILY_DONTKNOW, aSize600);
1385
1386 aFont.SetAlignment(ALIGN_TOP);
1387 aFont.SetWeight(WEIGHT_BOLD);
1388 aFont.SetFontSize(aSize650);
1389 aFont.SetColor( COL_BLACK );
1390 rOutDev.SetFont(aFont);
1391
1392 Size aTitleSize (GetTextSize(rOutDev, GetDoc()->GetTitle(), aOutRect.GetWidth() - 200));
1393
1394 aFont.SetWeight(WEIGHT_NORMAL);
1395 aFont.SetFontSize(aSize600);
1396 rOutDev.SetFont(aFont);
1397
1398 Size aDescSize (GetTextSize(rOutDev, GetDoc()->GetComment(), aOutRect.GetWidth() - 200));
1399
1400 if (bIsPrintFrame)
1401 rOutDev.DrawRect(tools::Rectangle(aOutRect.TopLeft(),
1402 Size(aOutRect.GetWidth(), 100 + aTitleSize.Height() + 200 + aDescSize.Height() + 100)));
1403 aOutRect.AdjustTop(200 );
1404
1405 // output title
1406 aFont.SetWeight(WEIGHT_BOLD);
1407 aFont.SetFontSize(aSize650);
1408 rOutDev.SetFont(aFont);
1409 Point aPoint(aOutRect.Left() + (aOutRect.GetWidth() - aTitleSize.Width()) / 2,
1410 aOutRect.Top());
1411 DrawText(rOutDev, aPoint, GetDoc()->GetTitle(),
1412 sal::static_int_cast< sal_uInt16 >(aOutRect.GetWidth() - 200));
1413 aOutRect.AdjustTop(aTitleSize.Height() + 200 );
1414
1415 // output description
1416 aFont.SetWeight(WEIGHT_NORMAL);
1417 aFont.SetFontSize(aSize600);
1418 rOutDev.SetFont(aFont);
1419 aPoint.setX( aOutRect.Left() + (aOutRect.GetWidth() - aDescSize.Width()) / 2 );
1420 aPoint.setY( aOutRect.Top() );
1421 DrawText(rOutDev, aPoint, GetDoc()->GetComment(),
1422 sal::static_int_cast< sal_uInt16 >(aOutRect.GetWidth() - 200));
1423 aOutRect.AdjustTop(aDescSize.Height() + 300 );
1424 }
1425
1426 // output text on bottom
1427 if (bIsPrintFormulaText)
1428 {
1429 vcl::Font aFont(FAMILY_DONTKNOW, Size(0, 600));
1430 aFont.SetAlignment(ALIGN_TOP);
1431 aFont.SetColor( COL_BLACK );
1432
1433 // get size
1434 rOutDev.SetFont(aFont);
1435
1436 Size aSize (GetTextSize(rOutDev, GetDoc()->GetText(), aOutRect.GetWidth() - 200));
1437
1438 aOutRect.AdjustBottom( -(aSize.Height() + 600) );
1439
1440 if (bIsPrintFrame)
1441 rOutDev.DrawRect(tools::Rectangle(aOutRect.BottomLeft(),
1442 Size(aOutRect.GetWidth(), 200 + aSize.Height() + 200)));
1443
1444 Point aPoint (aOutRect.Left() + (aOutRect.GetWidth() - aSize.Width()) / 2,
1445 aOutRect.Bottom() + 300);
1446 DrawText(rOutDev, aPoint, GetDoc()->GetText(),
1447 sal::static_int_cast< sal_uInt16 >(aOutRect.GetWidth() - 200));
1448 aOutRect.AdjustBottom( -200 );
1449 }
1450
1451 if (bIsPrintFrame)
1452 rOutDev.DrawRect(aOutRect);
1453
1454 aOutRect.AdjustTop(100 );
1455 aOutRect.AdjustLeft(100 );
1456 aOutRect.AdjustBottom( -100 );
1457 aOutRect.AdjustRight( -100 );
1458
1459 Size aSize (GetDoc()->GetSize());
1460
1461 MapMode OutputMapMode;
1462 // PDF export should always use PRINT_SIZE_NORMAL ...
1463 if (!rPrintUIOptions.getBoolValue( "IsPrinter" ) )
1464 ePrintSize = PRINT_SIZE_NORMAL;
1465 switch (ePrintSize)
1466 {
1467 case PRINT_SIZE_NORMAL:
1468 OutputMapMode = MapMode(SmMapUnit());
1469 break;
1470
1471 case PRINT_SIZE_SCALED:
1472 if (!aSize.IsEmpty())
1473 {
1474 Size OutputSize(rOutDev.LogicToPixel(aOutRect.GetSize(), MapMode(SmMapUnit())));
1475 Size GraphicSize(rOutDev.LogicToPixel(aSize, MapMode(SmMapUnit())));
1476 sal_uInt16 nZ = std::min(o3tl::convert(OutputSize.Width(), 100, GraphicSize.Width()),
1477 o3tl::convert(OutputSize.Height(), 100, GraphicSize.Height()));
1478 nZ -= 10;
1479 Fraction aFraction(std::clamp(nZ, MINZOOM, sal_uInt16(100)), 1);
1480
1481 OutputMapMode = MapMode(SmMapUnit(), Point(), aFraction, aFraction);
1482 }
1483 else
1484 OutputMapMode = MapMode(SmMapUnit());
1485 break;
1486
1487 case PRINT_SIZE_ZOOMED:
1488 {
1489 Fraction aFraction( nZoomFactor, 100 );
1490
1491 OutputMapMode = MapMode(SmMapUnit(), Point(), aFraction, aFraction);
1492 break;
1493 }
1494 }
1495
1496 aSize = rOutDev.PixelToLogic(rOutDev.LogicToPixel(aSize, OutputMapMode),
1497 MapMode(SmMapUnit()));
1498
1499 Point aPos (aOutRect.Left() + (aOutRect.GetWidth() - aSize.Width()) / 2,
1500 aOutRect.Top() + (aOutRect.GetHeight() - aSize.Height()) / 2);
1501
1502 aPos = rOutDev.PixelToLogic(rOutDev.LogicToPixel(aPos, MapMode(SmMapUnit())),
1503 OutputMapMode);
1504 aOutRect = rOutDev.PixelToLogic(rOutDev.LogicToPixel(aOutRect, MapMode(SmMapUnit())),
1505 OutputMapMode);
1506
1507 rOutDev.SetMapMode(OutputMapMode);
1508 rOutDev.SetClipRegion(vcl::Region(aOutRect));
1509 GetDoc()->DrawFormula(rOutDev, aPos);
1510 rOutDev.SetClipRegion();
1511
1512 rOutDev.Pop();
1513}
1514
1516{
1517 SmDocShell* pDoc = GetDoc();
1518 if (pDoc->HasPrinter() || bCreate)
1519 return pDoc->GetPrinter();
1520 return nullptr;
1521}
1522
1523sal_uInt16 SmViewShell::SetPrinter(SfxPrinter *pNewPrinter, SfxPrinterChangeFlags nDiffFlags )
1524{
1525 SfxPrinter *pOld = GetDoc()->GetPrinter();
1526 if ( pOld && pOld->IsPrinting() )
1527 return SFX_PRINTERROR_BUSY;
1528
1529 if ((nDiffFlags & SfxPrinterChangeFlags::PRINTER) == SfxPrinterChangeFlags::PRINTER)
1530 GetDoc()->SetPrinter( pNewPrinter );
1531
1532 if ((nDiffFlags & SfxPrinterChangeFlags::OPTIONS) == SfxPrinterChangeFlags::OPTIONS)
1533 {
1534 SmModule *pp = SM_MOD();
1535 pp->GetConfig()->ItemSetToConfig(pNewPrinter->GetOptions());
1536 }
1537 return 0;
1538}
1539
1541{
1542 return true;
1543}
1544
1545std::unique_ptr<SfxTabPage> SmViewShell::CreatePrintOptionsPage(weld::Container* pPage, weld::DialogController* pController,
1546 const SfxItemSet &rOptions)
1547{
1548 return SmPrintOptionsTabPage::Create(pPage, pController, rOptions);
1549}
1550
1552{
1553 SmCmdBoxWrapper* pWrapper = static_cast<SmCmdBoxWrapper*>(
1554 GetViewFrame().GetChildWindow(SmCmdBoxWrapper::GetChildWindowId()));
1555
1556 if (pWrapper != nullptr)
1557 {
1558 SmEditWindow& rEditWin = pWrapper->GetEditWindow();
1559 return &rEditWin;
1560 }
1561
1562 return nullptr;
1563}
1564
1565void SmViewShell::SetStatusText(const OUString& rText)
1566{
1567 maStatusText = rText;
1568 GetViewFrame().GetBindings().Invalidate(SID_TEXTSTATUS);
1569}
1570
1572{
1573 assert(GetDoc());
1574 if (pErrorDesc || nullptr != (pErrorDesc = GetDoc()->GetParser()->GetError()) )
1575 {
1576 SetStatusText( pErrorDesc->m_aText );
1577 if (SmEditWindow* pEdit = GetEditWindow())
1578 pEdit->MarkError( Point( pErrorDesc->m_pNode->GetColumn(),
1579 pErrorDesc->m_pNode->GetRow()));
1580 }
1581}
1582
1584{
1585 assert(GetDoc());
1586 const SmErrorDesc *pErrorDesc = GetDoc()->GetParser()->NextError();
1587
1588 if (pErrorDesc)
1589 ShowError( pErrorDesc );
1590}
1591
1593{
1594 assert(GetDoc());
1595 const SmErrorDesc *pErrorDesc = GetDoc()->GetParser()->PrevError();
1596
1597 if (pErrorDesc)
1598 ShowError( pErrorDesc );
1599}
1600
1602{
1603 SmDocShell *pDoc = GetDoc();
1604 bool bRet = false;
1605
1606 uno::Reference <embed::XStorage> xStorage = rMedium.GetStorage();
1607 if (xStorage.is() && xStorage->getElementNames().hasElements())
1608 {
1609 if (xStorage->hasByName("content.xml"))
1610 {
1611 // is this a fabulous math package ?
1612 rtl::Reference<SmModel> xModel(dynamic_cast<SmModel*>(pDoc->GetModel().get()));
1613 SmXMLImportWrapper aEquation(xModel);
1614 bRet = ERRCODE_NONE == aEquation.Import(rMedium);
1615 }
1616 }
1617
1618 if (!bRet)
1619 return;
1620
1621 OUString aText = pDoc->GetText();
1622 if (SmEditWindow *pEditWin = GetEditWindow())
1623 pEditWin->InsertText( aText );
1624 else
1625 {
1626 SAL_WARN( "starmath", "EditWindow missing" );
1627 }
1628
1629 pDoc->Parse();
1630 pDoc->SetModified();
1631
1633 rBnd.Invalidate(SID_GRAPHIC_SM);
1634 rBnd.Invalidate(SID_TEXT);
1635}
1636
1638{
1639 bool bSuccess = false;
1640 SmDocShell* pDoc = GetDoc();
1641 SvStream* pStream = rMedium.GetInStream();
1642
1643 if (pStream)
1644 {
1645 const OUString& rFltName = rMedium.GetFilter()->GetFilterName();
1646 if ( rFltName == MATHML_XML )
1647 {
1648 rtl::Reference<SmModel> xModel(dynamic_cast<SmModel*>(pDoc->GetModel().get()));
1649 SmXMLImportWrapper aEquation(xModel);
1650 bSuccess = ERRCODE_NONE == aEquation.Import(rMedium);
1651 }
1652 }
1653
1654 if (!bSuccess)
1655 return;
1656
1657 OUString aText = pDoc->GetText();
1658 if (SmEditWindow *pEditWin = GetEditWindow())
1659 pEditWin->InsertText(aText);
1660 else
1661 SAL_WARN( "starmath", "EditWindow missing" );
1662
1663 pDoc->Parse();
1664 pDoc->SetModified();
1665
1667 rBnd.Invalidate(SID_GRAPHIC_SM);
1668 rBnd.Invalidate(SID_TEXT);
1669}
1670
1672{
1673 SmEditWindow *pWin = GetEditWindow();
1674
1675 switch (rReq.GetSlot())
1676 {
1677 case SID_FORMULACURSOR:
1678 {
1679 SmModule *pp = SM_MOD();
1680
1681 const SfxItemSet *pArgs = rReq.GetArgs();
1682 const SfxPoolItem *pItem;
1683
1684 bool bVal;
1685 if ( pArgs &&
1686 SfxItemState::SET == pArgs->GetItemState( SID_FORMULACURSOR, false, &pItem))
1687 bVal = static_cast<const SfxBoolItem *>(pItem)->GetValue();
1688 else
1689 bVal = !pp->GetConfig()->IsShowFormulaCursor();
1690
1691 pp->GetConfig()->SetShowFormulaCursor(bVal);
1692 if (!IsInlineEditEnabled())
1694 break;
1695 }
1696 case SID_DRAW:
1697 if (pWin)
1698 {
1699 GetDoc()->SetText( pWin->GetText() );
1700 SetStatusText(OUString());
1701 ShowError( nullptr );
1702 GetDoc()->Repaint();
1703 }
1704 break;
1705
1706 case SID_ZOOM_OPTIMAL:
1707 mxGraphicWindow->ZoomToFitInWindow();
1708 break;
1709
1710 case SID_ZOOMIN:
1711 mxGraphicWindow->SetZoom(mxGraphicWindow->GetZoom() + 25);
1712 break;
1713
1714 case SID_ZOOMOUT:
1715 SAL_WARN_IF( mxGraphicWindow->GetZoom() < 25, "starmath", "incorrect sal_uInt16 argument" );
1716 mxGraphicWindow->SetZoom(mxGraphicWindow->GetZoom() - 25);
1717 break;
1718
1719 case SID_COPYOBJECT:
1720 {
1721 //TODO/LATER: does not work because of UNO Tunneling - will be fixed later
1722 Reference< datatransfer::XTransferable > xTrans( GetDoc()->GetModel(), uno::UNO_QUERY );
1723 if( xTrans.is() )
1724 {
1725 auto pTrans = dynamic_cast<TransferableHelper*>(xTrans.get());
1726 if (pTrans)
1727 {
1728 if (pWin)
1729 pTrans->CopyToClipboard(pWin->GetClipboard());
1730 }
1731 }
1732 }
1733 break;
1734
1735 case SID_PASTEOBJECT:
1736 {
1737 uno::Reference < io::XInputStream > xStrm;
1738 if (pWin)
1739 {
1742 if( aData.GetTransferable().is() &&
1743 ( aData.HasFormat( nId = SotClipboardFormatId::EMBEDDED_OBJ ) ||
1744 (aData.HasFormat( SotClipboardFormatId::OBJECTDESCRIPTOR ) &&
1745 aData.HasFormat( nId = SotClipboardFormatId::EMBED_SOURCE ))))
1746 xStrm = aData.GetInputStream(nId, OUString());
1747 }
1748
1749 if (xStrm.is())
1750 {
1751 try
1752 {
1753 uno::Reference < embed::XStorage > xStorage =
1754 ::comphelper::OStorageHelper::GetStorageFromInputStream( xStrm, ::comphelper::getProcessComponentContext() );
1755 SfxMedium aMedium( xStorage, OUString() );
1756 Insert( aMedium );
1757 GetDoc()->UpdateText();
1758 }
1759 catch (uno::Exception &)
1760 {
1761 SAL_WARN( "starmath", "SmViewShell::Execute (SID_PASTEOBJECT): failed to get storage from input stream" );
1762 }
1763 }
1764 }
1765 break;
1766
1767
1768 case SID_CUT:
1769 if (pWin)
1770 pWin->Cut();
1771 break;
1772
1773 case SID_COPY:
1774 if (pWin)
1775 {
1776 if (pWin->IsAllSelected())
1777 {
1779 SID_COPYOBJECT, SfxCallMode::RECORD,
1780 { new SfxVoidItem(SID_COPYOBJECT) });
1781 }
1782 else
1783 pWin->Copy();
1784 }
1785 break;
1786
1787 case SID_PASTE:
1788 {
1789 bool bCallExec = nullptr == pWin;
1790 if( !bCallExec )
1791 {
1792 if (pWin)
1793 {
1794 TransferableDataHelper aDataHelper(
1796 pWin->GetClipboard()));
1797
1798 if( aDataHelper.GetTransferable().is() &&
1799 aDataHelper.HasFormat( SotClipboardFormatId::STRING ))
1800 pWin->Paste();
1801 else
1802 bCallExec = true;
1803 }
1804 }
1805 if( bCallExec )
1806 {
1808 SID_PASTEOBJECT, SfxCallMode::RECORD,
1809 { new SfxVoidItem(SID_PASTEOBJECT) });
1810 }
1811 }
1812 break;
1813
1814 case SID_DELETE:
1815 if (pWin)
1816 pWin->Delete();
1817 break;
1818
1819 case SID_SELECT:
1820 if (pWin)
1821 pWin->SelectAll();
1822 break;
1823
1824 case SID_INSERTCOMMANDTEXT:
1825 {
1826 const SfxStringItem& rItem = rReq.GetArgs()->Get(SID_INSERTCOMMANDTEXT);
1827
1828 if (pWin && (mbInsertIntoEditWindow || !IsInlineEditEnabled()))
1829 {
1830 pWin->InsertText(rItem.GetValue());
1831 }
1833 {
1836 }
1837 break;
1838
1839 }
1840
1841 case SID_INSERTSPECIAL:
1842 {
1843 const SfxStringItem& rItem = rReq.GetArgs()->Get(SID_INSERTSPECIAL);
1844
1845 if (pWin && (mbInsertIntoEditWindow || !IsInlineEditEnabled()))
1846 pWin->InsertText(rItem.GetValue());
1848 GetDoc()->GetCursor().InsertSpecial(rItem.GetValue());
1849 break;
1850 }
1851
1852 case SID_IMPORT_FORMULA:
1853 {
1854 mpRequest.reset(new SfxRequest( rReq ));
1855 mpDocInserter.reset(new ::sfx2::DocumentInserter(pWin ? pWin->GetFrameWeld() : nullptr,
1856 GetDoc()->GetFactory().GetFactoryName()));
1857 mpDocInserter->StartExecuteModal( LINK( this, SmViewShell, DialogClosedHdl ) );
1858 break;
1859 }
1860
1861 case SID_IMPORT_MATHML_CLIPBOARD:
1862 {
1863 if (pWin)
1864 {
1866 uno::Reference < io::XInputStream > xStrm;
1867 if ( aDataHelper.GetTransferable().is() )
1868 {
1869 SotClipboardFormatId nId = SotClipboardFormatId::MATHML;
1870 if (aDataHelper.HasFormat(nId))
1871 {
1872 xStrm = aDataHelper.GetInputStream(nId, "");
1873 if (xStrm.is())
1874 {
1875 SfxMedium aClipboardMedium;
1876 aClipboardMedium.GetItemSet(); //generate initial itemset, not sure if necessary
1877 std::shared_ptr<const SfxFilter> pMathFilter =
1879 aClipboardMedium.SetFilter(pMathFilter);
1880 aClipboardMedium.setStreamToLoadFrom(xStrm, true /*bIsReadOnly*/);
1881 InsertFrom(aClipboardMedium);
1882 GetDoc()->UpdateText();
1883 }
1884 }
1885 else
1886 {
1887 nId = SotClipboardFormatId::STRING;
1888 if (aDataHelper.HasFormat(nId))
1889 {
1890 // In case of FORMAT_STRING no stream exists, need to generate one
1891 OUString aString;
1892 if (aDataHelper.GetString( nId, aString))
1893 {
1894 // tdf#117091 force xml declaration to exist
1895 if (!aString.startsWith("<?xml"))
1896 aString = "<?xml version=\"1.0\"?>\n" + aString;
1897
1898 SfxMedium aClipboardMedium;
1899 aClipboardMedium.GetItemSet(); //generates initial itemset, not sure if necessary
1900 std::shared_ptr<const SfxFilter> pMathFilter =
1902 aClipboardMedium.SetFilter(pMathFilter);
1903
1904 SvMemoryStream aStrm( const_cast<sal_Unicode *>(aString.getStr()), aString.getLength() * sizeof(sal_Unicode), StreamMode::READ);
1905 uno::Reference<io::XInputStream> xStrm2( new ::utl::OInputStreamWrapper(aStrm) );
1906 aClipboardMedium.setStreamToLoadFrom(xStrm2, true /*bIsReadOnly*/);
1907 InsertFrom(aClipboardMedium);
1908 GetDoc()->UpdateText();
1909 }
1910 }
1911 }
1912 }
1913 }
1914 break;
1915 }
1916
1917 case SID_NEXTERR:
1918 NextError();
1919 if (pWin)
1920 pWin->GrabFocus();
1921 break;
1922
1923 case SID_PREVERR:
1924 PrevError();
1925 if (pWin)
1926 pWin->GrabFocus();
1927 break;
1928
1929 case SID_NEXTMARK:
1930 if (pWin)
1931 {
1932 pWin->SelNextMark();
1933 pWin->GrabFocus();
1934 }
1935 break;
1936
1937 case SID_PREVMARK:
1938 if (pWin)
1939 {
1940 pWin->SelPrevMark();
1941 pWin->GrabFocus();
1942 }
1943 break;
1944
1945 case SID_TEXTSTATUS:
1946 {
1947 if (rReq.GetArgs() != nullptr)
1948 {
1949 const SfxStringItem& rItem = rReq.GetArgs()->Get(SID_TEXTSTATUS);
1950
1951 SetStatusText(rItem.GetValue());
1952 }
1953
1954 break;
1955 }
1956
1957 case SID_GETEDITTEXT:
1958 if (pWin && !pWin->GetText().isEmpty())
1959 GetDoc()->SetText( pWin->GetText() );
1960 break;
1961
1962 case SID_ATTR_ZOOM:
1963 {
1964 if ( !GetViewFrame().GetFrame().IsInPlace() )
1965 {
1966 const SfxItemSet *pSet = rReq.GetArgs();
1967 if ( pSet )
1968 {
1969 ZoomByItemSet(pSet);
1970 }
1971 else
1972 {
1974 aSet.Put( SvxZoomItem( SvxZoomType::PERCENT, mxGraphicWindow->GetZoom()));
1977 xDlg->SetLimits( MINZOOM, MAXZOOM );
1978 if (xDlg->Execute() != RET_CANCEL)
1979 ZoomByItemSet(xDlg->GetOutputItemSet());
1980 }
1981 }
1982 }
1983 break;
1984
1985 case SID_ATTR_ZOOMSLIDER:
1986 {
1987 const SfxItemSet *pArgs = rReq.GetArgs();
1988 const SfxPoolItem* pItem;
1989
1990 if ( pArgs && SfxItemState::SET == pArgs->GetItemState(SID_ATTR_ZOOMSLIDER, true, &pItem ) )
1991 {
1992 const sal_uInt16 nCurrentZoom = static_cast<const SvxZoomSliderItem *>(pItem)->GetValue();
1993 mxGraphicWindow->SetZoom(nCurrentZoom);
1994 }
1995 }
1996 break;
1997
1998 case SID_ELEMENTSDOCKINGWINDOW:
1999 {
2000 // First make sure that the sidebar is visible
2001 GetViewFrame().ShowChildWindow(SID_SIDEBAR);
2002
2003 sfx2::sidebar::Sidebar::TogglePanel(u"MathElementsPanel",
2004 GetViewFrame().GetFrame().GetFrameInterface());
2005 GetViewFrame().GetBindings().Invalidate( SID_ELEMENTSDOCKINGWINDOW );
2006
2007 rReq.Ignore ();
2008 }
2009 break;
2010
2011 case SID_UNICODE_NOTATION_TOGGLE:
2012 {
2013 EditEngine* pEditEngine = nullptr;
2014 if( pWin )
2015 pEditEngine = pWin->GetEditEngine();
2016
2017 EditView* pEditView = nullptr;
2018 if( pEditEngine )
2019 pEditView = pEditEngine->GetView();
2020
2021 if( pEditView )
2022 {
2023 const OUString sInput = pEditView->GetSurroundingText();
2024 ESelection aSel( pWin->GetSelection() );
2025
2026 if ( aSel.nStartPos > aSel.nEndPos )
2027 aSel.nEndPos = aSel.nStartPos;
2028
2029 //calculate a valid end-position by reading logical characters
2030 sal_Int32 nUtf16Pos=0;
2031 while( (nUtf16Pos < sInput.getLength()) && (nUtf16Pos < aSel.nEndPos) )
2032 {
2033 sInput.iterateCodePoints(&nUtf16Pos);
2034 if( nUtf16Pos > aSel.nEndPos )
2035 aSel.nEndPos = nUtf16Pos;
2036 }
2037
2038 ToggleUnicodeCodepoint aToggle;
2039 while( nUtf16Pos && aToggle.AllowMoreInput( sInput[nUtf16Pos-1]) )
2040 --nUtf16Pos;
2041 const OUString sReplacement = aToggle.ReplacementString();
2042 if( !sReplacement.isEmpty() )
2043 {
2044 pEditView->SetSelection( aSel );
2046 aSel.nStartPos = aSel.nEndPos - aToggle.StringToReplace().getLength();
2047 pWin->SetSelection( aSel );
2048 pEditView->InsertText( sReplacement, true );
2049 pEditEngine->UndoActionEnd();
2050 pWin->Flush();
2051 }
2052 }
2053 }
2054 break;
2055
2056 case SID_SYMBOLS_CATALOGUE:
2057 {
2058
2059 // get device used to retrieve the FontList
2060 SmDocShell *pDoc = GetDoc();
2061 OutputDevice *pDev = pDoc->GetPrinter();
2062 if (!pDev || pDev->GetFontFaceCollectionCount() == 0)
2063 pDev = &SM_MOD()->GetDefaultVirtualDev();
2064 SAL_WARN_IF( !pDev, "starmath", "device for font list missing" );
2065
2066 SmModule *pp = SM_MOD();
2067 SmSymbolDialog aDialog(pWin ? pWin->GetFrameWeld() : nullptr, pDev, pp->GetSymbolManager(), *this);
2068 aDialog.run();
2069 }
2070 break;
2071 }
2072 rReq.Done();
2073}
2074
2075
2077{
2078 SfxWhichIter aIter(rSet);
2079
2080 SmEditWindow *pEditWin = GetEditWindow();
2081 for (sal_uInt16 nWh = aIter.FirstWhich(); nWh != 0; nWh = aIter.NextWhich())
2082 {
2083 switch (nWh)
2084 {
2085 case SID_CUT:
2086 case SID_COPY:
2087 case SID_DELETE:
2088 if (! pEditWin || ! pEditWin->IsSelected())
2089 rSet.DisableItem(nWh);
2090 break;
2091
2092 case SID_PASTE:
2093 if (pEditWin)
2094 {
2095 TransferableDataHelper aDataHelper(
2097 pEditWin->GetClipboard()) );
2098
2099 mbPasteState = aDataHelper.GetTransferable().is() &&
2100 ( aDataHelper.HasFormat( SotClipboardFormatId::STRING ) ||
2101 aDataHelper.HasFormat( SotClipboardFormatId::EMBEDDED_OBJ ) ||
2102 (aDataHelper.HasFormat( SotClipboardFormatId::OBJECTDESCRIPTOR )
2103 && aDataHelper.HasFormat( SotClipboardFormatId::EMBED_SOURCE )));
2104 }
2105 if( !mbPasteState )
2106 rSet.DisableItem( nWh );
2107 break;
2108
2109 case SID_ATTR_ZOOM:
2110 rSet.Put(SvxZoomItem( SvxZoomType::PERCENT, mxGraphicWindow->GetZoom()));
2111 [[fallthrough]];
2112 case SID_ZOOMIN:
2113 case SID_ZOOMOUT:
2114 case SID_ZOOM_OPTIMAL:
2115 if ( GetViewFrame().GetFrame().IsInPlace() )
2116 rSet.DisableItem( nWh );
2117 break;
2118
2119 case SID_ATTR_ZOOMSLIDER :
2120 {
2121 const sal_uInt16 nCurrentZoom = mxGraphicWindow->GetZoom();
2122 SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM, MAXZOOM );
2123 aZoomSliderItem.AddSnappingPoint( 100 );
2124 rSet.Put( aZoomSliderItem );
2125 }
2126 break;
2127
2128 case SID_NEXTERR:
2129 case SID_PREVERR:
2130 case SID_NEXTMARK:
2131 case SID_PREVMARK:
2132 case SID_DRAW:
2133 case SID_SELECT:
2134 if (! pEditWin || pEditWin->IsEmpty())
2135 rSet.DisableItem(nWh);
2136 break;
2137
2138 case SID_TEXTSTATUS:
2139 {
2141 }
2142 break;
2143
2144 case SID_FORMULACURSOR:
2145 {
2146 SmModule *pp = SM_MOD();
2148 }
2149 break;
2150 case SID_ELEMENTSDOCKINGWINDOW:
2151 {
2152 const bool bState = sfx2::sidebar::Sidebar::IsPanelVisible(
2153 u"MathElementsPanel", GetViewFrame().GetFrame().GetFrameInterface());
2154 rSet.Put(SfxBoolItem(SID_ELEMENTSDOCKINGWINDOW, bState));
2155 }
2156 break;
2157 }
2158 }
2159}
2160
2161namespace
2162{
2163css::uno::Reference<css::ui::XSidebar>
2164getSidebarFromModel(const css::uno::Reference<css::frame::XModel>& xModel)
2165{
2166 css::uno::Reference<css::container::XChild> xChild(xModel, css::uno::UNO_QUERY);
2167 if (!xChild.is())
2168 return nullptr;
2169 css::uno::Reference<css::frame::XModel> xParent(xChild->getParent(), css::uno::UNO_QUERY);
2170 if (!xParent.is())
2171 return nullptr;
2172 css::uno::Reference<css::frame::XController2> xController(xParent->getCurrentController(),
2173 css::uno::UNO_QUERY);
2174 if (!xController.is())
2175 return nullptr;
2176 css::uno::Reference<css::ui::XSidebarProvider> xSidebarProvider = xController->getSidebar();
2177 if (!xSidebarProvider.is())
2178 return nullptr;
2179 return xSidebarProvider->getSidebar();
2180}
2181class SmController : public SfxBaseController
2182{
2183public:
2184 SmController(SfxViewShell& rViewShell)
2185 : SfxBaseController(&rViewShell)
2186 , mpSelectionChangeHandler(new svx::sidebar::SelectionChangeHandler(
2187 GetContextName, this, vcl::EnumContext::Context::Math))
2188 {
2189 rViewShell.SetContextName(GetContextName());
2190 }
2191 // No need to call mpSelectionChangeHandler->Disconnect() unless SmController implements XSelectionSupplier
2192 // ~SmController() { mpSelectionChangeHandler->Disconnect(); }
2193
2194 // css::frame::XController
2195 void SAL_CALL attachFrame(const css::uno::Reference<css::frame::XFrame>& xFrame) override
2196 {
2198
2200 {
2202 // In lok mode, DocumentHolder::ShowUI is not called on OLE in-place activation,
2203 // because respective code is skipped in OCommonEmbeddedObject::SwitchStateTo_Impl,
2204 // so sidebar controller does not get registered properly; do it here
2205 if (auto xSidebar = getSidebarFromModel(getModel()))
2206 {
2207 auto pSidebar = dynamic_cast<sfx2::sidebar::SidebarController*>(xSidebar.get());
2208 assert(pSidebar);
2209 pSidebar->registerSidebarForFrame(this);
2210 pSidebar->updateModel(getModel());
2211 }
2212 }
2213
2214 // No need to call mpSelectionChangeHandler->Connect() unless SmController implements XSelectionSupplier
2215 mpSelectionChangeHandler->selectionChanged({}); // Installs the correct context
2216 }
2217
2218 virtual void SAL_CALL dispose() override
2219 {
2221 if (auto pViewShell = GetViewShell_Impl())
2222 pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CURSOR_VISIBLE,
2223 OString::boolean(false));
2224
2226 }
2227
2228private:
2229 static OUString GetContextName() { return "Math"; } // Static constant for now
2230
2232};
2233}
2234
2237 , mxGraphicWindow(VclPtr<SmGraphicWindow>::Create(*this))
2238 , maGraphicController(mxGraphicWindow->GetGraphicWidget(), SID_GRAPHIC_SM, rFrame_.GetBindings())
2239 , mbPasteState(false)
2240 , mbInsertIntoEditWindow(false)
2241{
2242 SetStatusText(OUString());
2244 SfxShell::SetName("SmView");
2245 SfxShell::SetUndoManager( &GetDoc()->GetEditEngine().GetUndoManager() );
2246 SetController(new SmController(*this));
2247}
2248
2250{
2252 // Thus 'SmGetActiveView' will give a 0 pointer.
2253 // Thus we need to supply this view as argument
2254 if (SmEditWindow *pEditWin = GetEditWindow())
2255 pEditWin->DeleteEditView();
2257}
2258
2259void SmViewShell::Deactivate( bool bIsMDIActivate )
2260{
2261 if (SmEditWindow *pEdit = GetEditWindow())
2262 pEdit->Flush();
2263
2264 SfxViewShell::Deactivate( bIsMDIActivate );
2265}
2266
2267void SmViewShell::Activate( bool bIsMDIActivate )
2268{
2269 SfxViewShell::Activate( bIsMDIActivate );
2270
2272 {
2273 // In LOK, activate in-place editing
2275 }
2276 else if (SmEditWindow *pEdit = GetEditWindow())
2277 {
2282 SmDocShell *pDoc = GetDoc();
2283 pDoc->SetText( pDoc->GetEditEngine().GetText() );
2284
2285 if ( bIsMDIActivate )
2286 pEdit->GrabFocus();
2287 }
2288}
2289
2290IMPL_LINK( SmViewShell, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg, void )
2291{
2292 assert(_pFileDlg && "SmViewShell::DialogClosedHdl(): no file dialog");
2293 assert(mpDocInserter && "ScDocShell::DialogClosedHdl(): no document inserter");
2294
2295 if ( ERRCODE_NONE == _pFileDlg->GetError() )
2296 {
2297 std::unique_ptr<SfxMedium> pMedium = mpDocInserter->CreateMedium();
2298
2299 if ( pMedium )
2300 {
2301 if ( pMedium->IsStorage() )
2302 Insert( *pMedium );
2303 else
2304 InsertFrom( *pMedium );
2305 pMedium.reset();
2306
2307 SmDocShell* pDoc = GetDoc();
2308 pDoc->UpdateText();
2309 pDoc->ArrangeFormula();
2310 pDoc->Repaint();
2311 // adjust window, repaint, increment ModifyCount,...
2312 GetViewFrame().GetBindings().Invalidate(SID_GRAPHIC_SM);
2313 }
2314 }
2315
2316 mpRequest->SetReturnValue( SfxBoolItem( mpRequest->GetSlot(), true ) );
2317 mpRequest->Done();
2318}
2319
2321{
2322 switch( rHint.GetId() )
2323 {
2324 case SfxHintId::ModeChanged:
2325 case SfxHintId::DocChanged:
2327 break;
2328 default:
2329 break;
2330 }
2331}
2332
2334{
2336 || officecfg::Office::Common::Misc::ExperimentalMode::get();
2337}
2338
2340{
2341 Help* pHelp = Application::GetHelp();
2342 if (pHelp)
2344}
2345
2347{
2348 assert(pSet);
2349 const SvxZoomItem &rZoom = pSet->Get(SID_ATTR_ZOOM);
2350 switch( rZoom.GetType() )
2351 {
2352 case SvxZoomType::PERCENT:
2353 mxGraphicWindow->SetZoom(sal::static_int_cast<sal_uInt16>(rZoom.GetValue ()));
2354 break;
2355
2356 case SvxZoomType::OPTIMAL:
2357 mxGraphicWindow->ZoomToFitInWindow();
2358 break;
2359
2360 case SvxZoomType::PAGEWIDTH:
2361 case SvxZoomType::WHOLEPAGE:
2362 {
2363 const MapMode aMap( SmMapUnit() );
2364 SfxPrinter *pPrinter = GetPrinter( true );
2365 tools::Rectangle OutputRect(Point(), pPrinter->GetOutputSize());
2366 Size OutputSize(pPrinter->LogicToPixel(Size(OutputRect.GetWidth(),
2367 OutputRect.GetHeight()), aMap));
2368 Size GraphicSize(pPrinter->LogicToPixel(GetDoc()->GetSize(), aMap));
2369 if (GraphicSize.Width() <= 0 || GraphicSize.Height() <= 0)
2370 break;
2371 sal_uInt16 nZ = std::min(o3tl::convert(OutputSize.Width(), 100, GraphicSize.Width()),
2372 o3tl::convert(OutputSize.Height(), 100, GraphicSize.Height()));
2373 mxGraphicWindow->SetZoom(nZ);
2374 break;
2375 }
2376 default:
2377 break;
2378 }
2379}
2380
2381std::optional<OString> SmViewShell::getLOKPayload(int nType, int nViewId) const
2382{
2383 switch (nType)
2384 {
2385 case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR:
2386 {
2387 OString sRectangle;
2388 if (const SmGraphicWidget& widget = GetGraphicWidget(); widget.IsCursorVisible())
2389 {
2390 SmCursor& rCursor = GetDoc()->GetCursor();
2391 OutputDevice& rOutDev = const_cast<SmGraphicWidget&>(widget).GetOutputDevice();
2392 tools::Rectangle aCaret = rCursor.GetCaretRectangle(rOutDev);
2393 Point aFormulaDrawPos = widget.GetFormulaDrawPos();
2394 aCaret.Move(aFormulaDrawPos.X(), aFormulaDrawPos.Y());
2396 tools::Rectangle aBounds = helper.GetBoundingBox();
2397 aCaret.Move(aBounds.Left(), aBounds.Top());
2398 sRectangle = aCaret.toString();
2399 }
2400 return SfxLokHelper::makeVisCursorInvalidation(nViewId, sRectangle, false, {});
2401 }
2402 case LOK_CALLBACK_TEXT_SELECTION:
2403 {
2404 OString sRectangle;
2405 if (const SmGraphicWidget& widget = GetGraphicWidget(); widget.IsCursorVisible())
2406 {
2407 SmCursor& rCursor = GetDoc()->GetCursor();
2408 OutputDevice& rOutDev = const_cast<SmGraphicWidget&>(widget).GetOutputDevice();
2409 tools::Rectangle aSelection = rCursor.GetSelectionRectangle(rOutDev);
2410 if (!aSelection.IsEmpty())
2411 {
2412 Point aFormulaDrawPos = widget.GetFormulaDrawPos();
2413 aSelection.Move(aFormulaDrawPos.X(), aFormulaDrawPos.Y());
2415 tools::Rectangle aBounds = helper.GetBoundingBox();
2416
2417 aSelection.Move(aBounds.Left(), aBounds.Top());
2418 sRectangle = aSelection.toString();
2419 }
2420 }
2421 return sRectangle;
2422 }
2423 case LOK_CALLBACK_TEXT_SELECTION_START:
2424 case LOK_CALLBACK_TEXT_SELECTION_END:
2425 case LOK_CALLBACK_INVALIDATE_VIEW_CURSOR:
2426 case LOK_CALLBACK_TEXT_VIEW_SELECTION:
2427 return {};
2428 }
2429 return SfxViewShell::getLOKPayload(nType, nViewId); // aborts
2430}
2431
2433{
2434 const int nViewId = sal_Int32(GetViewShellId());
2435 if (const auto& payload = getLOKPayload(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, nViewId))
2436 {
2437 libreOfficeKitViewCallbackWithViewId(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR,
2438 *payload, nViewId);
2439 }
2440 if (const auto& payload = getLOKPayload(LOK_CALLBACK_TEXT_SELECTION, nViewId))
2441 {
2442 libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, *payload);
2443 }
2444}
2445
2446/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwViewShell & mrViewShell
SfxChildAlignment
virtual const SmErrorDesc * NextError()=0
virtual const SmErrorDesc * PrevError()=0
static const AllSettings & GetSettings()
static Help * GetHelp()
const OUString & GetValue() const
const CommandGestureZoomData * GetGestureZoomData() const
CommandEventId GetCommand() const
const CommandWheelData * GetWheelData() const
const Point & GetMousePosPixel() const
const CommandExtTextInputData * GetExtTextInputData() const
bool IsMouseEvent() const
tools::Long GetDelta() const
CommandWheelMode GetMode() const
OUString GetText(LineEnd eEnd=LINEEND_LF) const
EditView * GetView(size_t nIndex=0) const
void UndoActionStart(sal_uInt16 nId)
void UndoActionEnd()
OUString GetSurroundingText() const
void SetSelection(const ESelection &rNewSel)
void InsertText(const OUString &rNew, bool bSelect=false, bool bLOKShowSelect=true)
virtual bool Start(const OUString &rHelpId, weld::Widget *pWidget=nullptr)
virtual void Resize() override
virtual void dispose() override
void InitControlBase(weld::Widget *pWidget)
sal_Unicode GetCharCode() const
const vcl::KeyCode & GetKeyCode() const
sal_uInt16 GetClicks() const
const Point & GetPosPixel() const
bool IsLeft() const
bool IsShift() const
float approximate_digit_width() const
void EnableMapMode(bool bEnable=true)
void SetFont(const vcl::Font &rNewFont)
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
void DrawRect(const tools::Rectangle &rRect)
void SetLineColor()
void SetMapMode()
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 SetClipRegion()
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
int GetFontFaceCollectionCount() const
const MapMode & GetMapMode() 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 Y() const
void setX(tools::Long nX)
void Move(tools::Long nHorzMove, tools::Long nVertMove)
void setY(tools::Long nY)
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
void CopyLokViewCallbackFromFrameCreator()
css::uno::Reference< css::frame::XModel > SAL_CALL getModel() override
SfxViewShell * GetViewShell_Impl() const
virtual void SAL_CALL attachFrame(const css::uno::Reference< css::frame::XFrame > &xFrame) override
virtual void SAL_CALL dispose() override
SfxDispatcher * GetDispatcher() const
void Invalidate(sal_uInt16 nId)
void InvalidateAll(bool bWithMsg)
void SetAlignment(SfxChildAlignment eAlign)
void SetWindow(const VclPtr< vcl::Window > &p)
virtual void StateChangedAtToolBoxControl(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState)
virtual void dispose()
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
SfxViewFrame * GetFrame() const
void ExecutePopup(const OUString &rResName, vcl::Window *pWin=nullptr, const Point *pPos=nullptr)
std::unique_ptr< weld::Box > m_xContainer
virtual void Resize() override
SfxBindings & GetBindings() const
virtual void StateChanged(StateChangedType nStateChange) override
virtual Size CalcDockingSize(SfxChildAlignment)
virtual void ToggleFloatingMode() override
virtual void dispose() override
static std::shared_ptr< const SfxFilter > GetFilterByName(const OUString &rName)
bool IsInPlace() const
SfxHintId GetId() const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void DisableItem(sal_uInt16 nWhich)
static OString makeVisCursorInvalidation(int nViewId, const OString &rRectangle, bool bMispelledWord=false, const OString &rHyperlink="")
const std::shared_ptr< const SfxFilter > & GetFilter() const
void setStreamToLoadFrom(const css::uno::Reference< css::io::XInputStream > &xInputStream, bool bIsReadOnly)
SfxItemSet & GetItemSet() const
void SetFilter(const std::shared_ptr< const SfxFilter > &pFilter)
css::uno::Reference< css::embed::XStorage > GetStorage(bool bCreateTempFile=true)
SvStream * GetInStream()
css::uno::Reference< css::frame::XModel3 > GetModel() const
virtual tools::Rectangle GetVisArea(sal_uInt16 nAspect) const
const SfxItemSet & GetOptions() const
sal_uInt16 GetSlot() const
void Ignore()
const SfxItemSet * GetArgs() const
void Done(bool bRemove=false)
void SetUndoManager(SfxUndoManager *pNewUndoMgr)
void SetContextName(const OUString &rsContextName)
SfxViewFrame * GetFrame() const
virtual SfxUndoManager * GetUndoManager()
SfxViewShell * GetViewShell() const
void SetName(const OUString &rName)
SfxBindings & GetBindings()
SfxDispatcher * GetDispatcher()
SfxChildWindow * GetChildWindow(sal_uInt16)
SfxFrame & GetFrame() const
void ShowChildWindow(sal_uInt16, bool bVisible=true)
weld::Window * GetFrameWeld() const
virtual void Activate(bool IsMDIActivate) override
virtual void libreOfficeKitViewCallback(int nType, const OString &pPayload) const override
void SetBorderPixel(const SvBorder &rBorder)
ViewShellId GetViewShellId() const override
virtual void SetZoomFactor(const Fraction &rZoomX, const Fraction &rZoomY)
SfxViewFrame & GetViewFrame() const
virtual void Deactivate(bool IsMDIActivate) override
void SetController(SfxBaseController *pController)
virtual std::optional< OString > getLOKPayload(int nType, int nViewId) const
virtual SfxObjectShell * GetObjectShell() override
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
virtual bool KeyInput(const KeyEvent &rKeyEvent)
void SetWindow(vcl::Window *pViewPort)
vcl::Window * GetWindow() const
virtual void libreOfficeKitViewCallbackWithViewId(int nType, const OString &pPayload, int nViewId) const override
sal_uInt16 FirstWhich()
sal_uInt16 NextWhich()
bool IsEmpty() const
constexpr tools::Long Height() const
tools::Long AdjustHeight(tools::Long n)
void setWidth(tools::Long nWidth)
tools::Long AdjustWidth(tools::Long n)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
SmViewShell * GetView()
Definition: view.cxx:1002
virtual void StateChanged(StateChangedType nStateChange) override
Definition: view.cxx:1038
virtual void dispose() override
Definition: view.cxx:993
virtual ~SmCmdBoxWindow() override
Definition: view.cxx:988
SmEditController aController
Definition: view.hxx:189
std::unique_ptr< SmEditWindow, o3tl::default_delete< SmEditWindow > > m_xEdit
Definition: view.hxx:188
Point WidgetToWindowPos(const weld::Widget &rWidget, const Point &rPos)
Definition: view.cxx:959
virtual void Command(const CommandEvent &rCEvt) override
Definition: view.cxx:977
void ShowContextMenu(const Point &rPos)
Definition: view.cxx:969
virtual Size CalcDockingSize(SfxChildAlignment eAlign) override
Definition: view.cxx:1009
SmCmdBoxWindow(SfxBindings *pBindings, SfxChildWindow *pChildWindow, Window *pParent)
Definition: view.cxx:935
bool bExiting
Definition: view.hxx:190
virtual void ToggleFloatingMode() override
Definition: view.cxx:1109
virtual void GetFocus() override
Definition: view.cxx:1117
virtual SfxChildAlignment CheckAlignment(SfxChildAlignment eActual, SfxChildAlignment eWish) override
Definition: view.cxx:1022
void AdjustPosition()
Definition: view.cxx:1096
Timer aInitialFocusTimer
Definition: view.hxx:192
SmCmdBoxWrapper(vcl::Window *pParentWindow, sal_uInt16 nId, SfxBindings *pBindings, SfxChildWinInfo *pInfo)
Definition: view.cxx:1125
SmEditWindow & GetEditWindow()
Definition: view.hxx:236
Formula cursor.
Definition: cursor.hxx:69
void Delete()
Delete the current selection or do nothing.
Definition: cursor.cxx:266
void InsertElement(SmFormulaElement element)
Insert an element into the formula.
Definition: cursor.cxx:898
void InsertFraction()
Insert a fraction, use selection as numerator.
Definition: cursor.cxx:818
void InsertBrackets(SmBracketType eBracketType)
Create brackets around current selection, or new SmPlaceNode.
Definition: cursor.cxx:601
void Copy()
Copy the current selection.
Definition: cursor.cxx:1050
void DeletePrev(OutputDevice *pDev)
Delete selection, previous element or merge lines.
Definition: cursor.cxx:188
void Draw(OutputDevice &pDev, Point Offset, bool isCaretVisible)
Draw the caret.
Definition: cursor.cxx:173
bool HasSelection() const
True, if the cursor has a selection.
Definition: cursor.hxx:87
bool IsAtTailOfBracket(SmBracketType eBracketType) const
Definition: cursor.cxx:1348
void MoveTo(OutputDevice *pDev, const Point &pos, bool bMoveAnchor)
Move to the caret position closest to a given point.
Definition: cursor.cxx:83
void Cut()
Cut the current selection.
Definition: cursor.hxx:163
void Paste()
Paste the clipboard.
Definition: cursor.cxx:1087
bool HasComplexSelection()
Returns true if more than one node is selected.
Definition: cursor.cxx:1222
tools::Rectangle GetCaretRectangle(OutputDevice &rOutDev) const
Definition: cursor.cxx:177
void InsertSubSup(SmSubSup eSubSup)
Create sub-/super script.
Definition: cursor.cxx:498
void InsertCommandText(const OUString &aCommandText)
Insert command text translated into line entries at position.
Definition: cursor.cxx:1027
bool InsertRow()
Insert a new row or newline.
Definition: cursor.cxx:697
void InsertText(const OUString &aString)
Insert text at the current position.
Definition: cursor.cxx:873
void Move(OutputDevice *pDev, SmMovementDirection direction, bool bMoveAnchor=true)
Move the position of this cursor.
Definition: cursor.cxx:20
tools::Rectangle GetSelectionRectangle(OutputDevice &rOutDev) const
Definition: cursor.cxx:182
void InsertSpecial(std::u16string_view aString)
Insert a special node created from aString.
Definition: cursor.cxx:1000
void UpdateText()
Definition: document.cxx:723
void SetText(const OUString &rBuffer)
Definition: document.cxx:138
EditEngine & GetEditEngine()
Definition: document.cxx:287
const SmTableNode * GetFormulaTree() const
Definition: document.hxx:176
SfxPrinter * GetPrinter()
Definition: document.hxx:160
bool HasCursor() const
True, if cursor have previously been requested and thus has some sort of position.
Definition: document.cxx:401
void Repaint()
Definition: document.cxx:525
void SetPrinter(SfxPrinter *)
Definition: document.cxx:505
SmCursor & GetCursor()
Get a cursor for modifying this document.
Definition: document.cxx:395
static SfxItemPool & GetPool()
Definition: document.cxx:1148
const OUString & GetText() const
Definition: document.hxx:170
void Parse()
Definition: document.cxx:223
void ArrangeFormula()
Definition: document.cxx:235
void Execute(SfxRequest &rReq)
Definition: document.cxx:822
bool HasPrinter() const
Definition: document.hxx:159
void DrawFormula(OutputDevice &rDev, Point &rPosition, bool bDrawSelection=false)
Definition: document.cxx:310
virtual void SetModified(bool bModified=true) override
Definition: document.cxx:1210
AbstractSmParser * GetParser()
Definition: document.hxx:175
SmEditWindow & rEdit
Definition: view.hxx:178
virtual void StateChangedAtToolBoxControl(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
Definition: view.cxx:925
SmEditController(SmEditWindow &, sal_uInt16, SfxBindings &)
Definition: view.cxx:917
void SetText(const OUString &rText)
Definition: edit.cxx:509
void InsertText(const OUString &rText)
Definition: edit.cxx:773
void Flush()
Definition: edit.cxx:516
weld::Window * GetFrameWeld() const
Definition: edit.cxx:150
void GrabFocus()
Definition: edit.cxx:523
EditEngine * GetEditEngine()
Definition: edit.cxx:185
css::uno::Reference< css::datatransfer::clipboard::XClipboard > GetClipboard() const
Definition: edit.hxx:108
void Paste()
Definition: edit.cxx:755
void Delete()
Definition: edit.cxx:764
void Cut()
Definition: edit.cxx:740
bool IsSelected() const
Definition: edit.cxx:717
bool IsAllSelected() const
Definition: edit.cxx:574
ESelection GetSelection() const
Definition: edit.cxx:687
bool IsEmpty() const
Definition: edit.cxx:710
void SelPrevMark()
Definition: edit.cxx:655
void SelectAll()
Definition: edit.cxx:597
OUString GetText() const
Definition: edit.cxx:499
void SetSelection(const ESelection &rSel)
Definition: edit.cxx:703
void Copy()
Definition: edit.cxx:749
void SelNextMark()
Definition: edit.cxx:618
SmGraphicController(SmGraphicWidget &, sal_uInt16, SfxBindings &)
Definition: view.cxx:901
SmGraphicWidget & rGraphic
Definition: view.hxx:168
virtual void StateChangedAtToolBoxControl(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
Definition: view.cxx:909
virtual bool Command(const CommandEvent &rCEvt) override
Definition: view.cxx:777
void CaretBlinkInit()
Definition: view.cxx:463
const Point & GetFormulaDrawPos() const
Definition: view.hxx:119
SmGraphicWindow & mrGraphicWindow
Definition: view.hxx:152
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
Definition: view.cxx:306
virtual void GetFocus() override
Definition: view.cxx:415
void ShowCursor(bool bShow)
Definition: view.cxx:487
SmViewShell & GetView()
Definition: view.hxx:115
virtual bool KeyInput(const KeyEvent &rKEvt) override
Definition: view.cxx:702
SmGraphicWidget(SmViewShell &rShell, SmGraphicWindow &rGraphicWindow)
Definition: view.cxx:297
const SmNode * SetCursorPos(sal_uInt16 nRow, sal_uInt16 nCol)
Definition: view.cxx:551
virtual bool MouseMove(const MouseEvent &rMEvt) override
Definition: view.cxx:399
tools::Rectangle aCursorRect
Definition: view.hxx:156
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override
Definition: view.cxx:891
SmViewShell & mrViewShell
Definition: view.hxx:161
OutputDevice & GetOutputDevice()
Definition: view.hxx:132
virtual ~SmGraphicWidget() override
Definition: view.cxx:334
void SetTotalSize()
Definition: view.cxx:609
double mfLastZoomScale
Definition: view.hxx:162
void CaretBlinkStart()
Definition: view.cxx:471
bool bIsCursorVisible
Definition: view.hxx:157
bool bIsLineVisible
Definition: view.hxx:158
void SetIsCursorVisible(bool bVis)
Definition: view.cxx:507
virtual void LoseFocus() override
Definition: view.cxx:429
void SetCursor(const SmNode *pNode)
Definition: view.cxx:518
bool IsCursorVisible() const
Definition: view.hxx:90
SmCursor & GetCursor()
Definition: view.cxx:344
bool IsLineVisible() const
Definition: view.hxx:95
rtl::Reference< SmGraphicAccessible > mxAccessible
Definition: view.hxx:160
void CaretBlinkStop()
Definition: view.cxx:479
Point aFormulaDrawPos
Definition: view.hxx:154
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
Definition: view.cxx:350
AutoTimer aCaretBlinkTimer
Definition: view.hxx:159
SmDocShell * GetDoc()
Definition: view.cxx:342
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &) override
Definition: view.cxx:576
double mfAccumulatedZoom
Definition: view.hxx:163
void ShowLine(bool bShow)
Definition: view.cxx:499
void RepaintViewShellDoc()
Definition: view.cxx:447
void SetZoom(sal_uInt16 Factor)
Definition: view.cxx:861
Size aTotPixSz
Definition: view.hxx:44
tools::Long nLinePixH
Definition: view.hxx:45
virtual ~SmGraphicWindow() override
Definition: view.cxx:138
tools::Long nColumnPixW
Definition: view.hxx:46
sal_uInt16 GetZoom() const
Definition: view.hxx:66
virtual void Resize() override
Definition: view.cxx:143
void ZoomToFitInWindow()
Definition: view.cxx:874
MapMode GetGraphicMapMode() const
Definition: view.cxx:267
void SetTotalSize(const Size &rNewSize)
Definition: view.cxx:275
std::unique_ptr< weld::CustomWeld > mxGraphicWin
Definition: view.hxx:51
std::unique_ptr< weld::ScrolledWindow > mxScrolledWindow
Definition: view.hxx:49
Point aPixOffset
Definition: view.hxx:43
sal_uInt16 nZoom
Definition: view.hxx:47
Size GetTotalSize() const
Definition: view.cxx:281
void SetGraphicMapMode(const MapMode &rNewMapMode)
Definition: view.cxx:258
SmGraphicWindow(SmViewShell &rShell)
Definition: view.cxx:109
void ShowContextMenu(const CommandEvent &rCEvt)
Definition: view.cxx:286
std::unique_ptr< SmGraphicWidget > mxGraphic
Definition: view.hxx:50
virtual void dispose() override
Definition: view.cxx:129
void ItemSetToConfig(const SfxItemSet &rSet)
Definition: cfgitem.cxx:1358
bool IsShowFormulaCursor() const
Definition: cfgitem.cxx:1335
void SetShowFormulaCursor(bool bVal)
Definition: cfgitem.cxx:1343
SmMathConfig * GetConfig()
Definition: smmod.cxx:162
SmSymbolManager & GetSymbolManager()
Definition: smmod.cxx:169
Definition: node.hxx:125
const SmNode * FindRectClosestTo(const Point &rPoint) const
Finds the closest rectangle in the screen.
Definition: node.cxx:280
sal_uInt16 GetRow() const
Gets the line in the text where the node is located.
Definition: node.hxx:349
const SmNode * FindTokenAt(sal_uInt16 nRow, sal_uInt16 nCol) const
Finds the node from the position in the text.
Definition: node.cxx:251
const ESelection & GetSelection() const
Gets node position in input text.
Definition: node.hxx:394
sal_uInt16 GetColumn() const
Gets the column of the line in the text where the node is located.
Definition: node.hxx:356
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: dialog.cxx:237
tools::Long GetItalicLeftSpace() const
Definition: rect.hxx:134
const Point & GetTopLeft() const
Definition: rect.hxx:124
Size GetItalicSize() const
Definition: rect.hxx:155
tools::Long OrientedDist(const Point &rPoint) const
Definition: rect.cxx:552
virtual void QueryObjAreaPixel(tools::Rectangle &rRect) const override
Definition: view.cxx:1186
void SetInsertIntoEditWindow(bool bEditWindowHadFocusLast)
Set bInsertIntoEditWindow so we know where to insert.
Definition: view.hxx:346
bool mbInsertIntoEditWindow
Used to determine whether insertions using SID_INSERTSPECIAL and SID_INSERTCOMMANDTEXT should be inse...
Definition: view.hxx:256
void ZoomByItemSet(const SfxItemSet *pSet)
Definition: view.cxx:2346
void Execute(SfxRequest &rReq)
Definition: view.cxx:1671
bool mbPasteState
Definition: view.hxx:251
virtual sal_uInt16 SetPrinter(SfxPrinter *pNewPrinter, SfxPrinterChangeFlags nDiffFlags=SFX_PRINTER_ALL) override
Definition: view.cxx:1523
void InsertFrom(SfxMedium &rMedium)
Definition: view.cxx:1637
virtual SfxPrinter * GetPrinter(bool bCreate=false) override
Definition: view.cxx:1515
static bool IsInlineEditEnabled()
Definition: view.cxx:2333
SmEditWindow * GetEditWindow()
Definition: view.cxx:1551
VclPtr< SmGraphicWindow > mxGraphicWindow
Definition: view.hxx:248
virtual void Deactivate(bool IsMDIActivate) override
Definition: view.cxx:2259
void SendCaretToLOK() const
Definition: view.cxx:2432
void Impl_Print(OutputDevice &rOutDev, const SmPrintUIOptions &rPrintUIOptions, tools::Rectangle aOutRect)
Definition: view.cxx:1368
OUString maStatusText
Definition: view.hxx:250
SmDocShell * GetDoc() const
Definition: view.hxx:297
SmViewShell(SfxViewFrame &rFrame, SfxViewShell *pOldSh)
Definition: view.cxx:2235
void SetStatusText(const OUString &rText)
Definition: view.cxx:1565
void ShowError(const SmErrorDesc *pErrorDesc)
Definition: view.cxx:1571
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: view.cxx:2320
void PrevError()
Definition: view.cxx:1592
virtual void SetZoomFactor(const Fraction &rX, const Fraction &rY) override
Definition: view.cxx:1191
std::unique_ptr< sfx2::DocumentInserter > mpDocInserter
Definition: view.hxx:246
void NextError()
Definition: view.cxx:1583
SmGraphicWidget & GetGraphicWidget()
Definition: view.hxx:304
void GetState(SfxItemSet &)
Definition: view.cxx:2076
virtual ~SmViewShell() override
Definition: view.cxx:2249
virtual bool HasPrintOptionsPage() const override
Definition: view.cxx:1540
virtual void InnerResizePixel(const Point &rOfs, const Size &rSize, bool inplaceEditModeChange) override
Definition: view.cxx:1160
static void DrawTextLine(OutputDevice &rDevice, const Point &rPosition, const OUString &rLine)
Definition: view.cxx:1283
std::unique_ptr< SfxRequest > mpRequest
Definition: view.hxx:247
void Insert(SfxMedium &rMedium)
Definition: view.cxx:1601
static void DrawText(OutputDevice &rDevice, const Point &rPosition, std::u16string_view rText, sal_uInt16 MaxWidth)
Definition: view.cxx:1306
static Size GetTextSize(OutputDevice const &rDevice, std::u16string_view rText, tools::Long MaxWidth)
Definition: view.cxx:1224
virtual std::optional< OString > getLOKPayload(int nType, int nViewId) const override
Definition: view.cxx:2381
static Size GetTextLineSize(OutputDevice const &rDevice, const OUString &rLine)
Definition: view.cxx:1201
virtual std::unique_ptr< SfxTabPage > CreatePrintOptionsPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rOptions) override
Definition: view.cxx:1545
virtual void OuterResizePixel(const Point &rOfs, const Size &rSize) override
Definition: view.cxx:1179
virtual void Activate(bool IsMDIActivate) override
Definition: view.cxx:2267
void StartMainHelp()
Definition: view.cxx:2339
ErrCode Import(SfxMedium &rMedium)
virtual VclPtr< AbstractSvxZoomDialog > CreateSvxZoomDialog(weld::Window *pParent, const SfxItemSet &rCoreSet)=0
static SvxAbstractDialogFactory * Create()
SvxZoomType GetType() const
void AddSnappingPoint(sal_Int32 nNew)
void Stop()
void SetTimeout(sal_uInt64 nTimeoutMs)
void SetInvokeHandler(const Link< Timer *, void > &rLink)
virtual void Start(bool bStartTimer=true) override
sal_uInt64 GetTimeout() const
OUString ReplacementString()
bool AllowMoreInput(sal_Unicode uChar)
OUString StringToReplace()
static TransferableDataHelper CreateFromClipboard(const css::uno::Reference< css::datatransfer::clipboard::XClipboard > &rClipboard)
bool GetString(SotClipboardFormatId nFormat, OUString &rStr) const
css::uno::Reference< css::io::XInputStream > GetInputStream(SotClipboardFormatId nFormat, const OUString &rDestDoc) const
bool HasFormat(SotClipboardFormatId nFormat) const
const css::uno::Reference< css::datatransfer::XTransferable > & GetTransferable() const
void disposeAndClear()
reference_type * get() const
static css::uno::Reference< css::embed::XStorage > GetStorageFromInputStream(const css::uno::Reference< css::io::XInputStream > &xStream, const css::uno::Reference< css::uno::XComponentContext > &rxContext=css::uno::Reference< css::uno::XComponentContext >())
static bool IsPanelVisible(std::u16string_view rsPanelId, const css::uno::Reference< css::frame::XFrame > &rxFrame)
static void TogglePanel(std::u16string_view rsPanelId, const css::uno::Reference< css::frame::XFrame > &rxFrame)
constexpr tools::Long GetWidth() const
constexpr tools::Long Top() const
void SetSize(const Size &)
constexpr Point TopLeft() const
constexpr Size GetSize() const
void Move(tools::Long nHorzMoveDelta, tools::Long nVertMoveDelta)
tools::Long AdjustTop(tools::Long nVertMoveDelta)
tools::Long AdjustRight(tools::Long nHorzMoveDelta)
constexpr tools::Long GetHeight() const
tools::Long AdjustBottom(tools::Long nVertMoveDelta)
tools::Long AdjustLeft(tools::Long nHorzMoveDelta)
constexpr tools::Long Left() const
constexpr tools::Long Bottom() const
constexpr bool IsEmpty() const
rtl::OString toString() const
constexpr Point BottomLeft() const
void SetFontSize(const Size &)
void SetColor(const Color &)
void SetWeight(FontWeight)
void SetAlignment(TextAlign)
sal_uInt16 GetCode() const
KeyFuncType GetFunction() const
bool IsShift() const
bool getBoolValue(const OUString &i_rPropertyName, bool i_bDefault) const
sal_Int64 getIntValue(const OUString &i_rPropertyName, sal_Int64 i_nDefault) const
vcl::Window * GetParent() const
void ToTop(ToTopFlags nFlags=ToTopFlags::NONE)
Point PixelToLogic(const Point &rDevicePt) const
virtual Size GetSizePixel() const
Size GetOutputSizePixel() const
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea)
void SetHelpId(const OUString &rHelpId)
virtual short run()
virtual bool get_extents_relative_to(const Widget &rRelative, int &x, int &y, int &width, int &height) const=0
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
@ FactorialElement
Definition: cursor.hxx:34
@ CDotElement
Definition: cursor.hxx:37
@ MinusElement
Definition: cursor.hxx:36
@ BlankElement
Definition: cursor.hxx:33
@ GreaterThanElement
Definition: cursor.hxx:40
@ EqualElement
Definition: cursor.hxx:38
@ PlusElement
Definition: cursor.hxx:35
@ LessThanElement
Definition: cursor.hxx:39
@ PercentElement
Definition: cursor.hxx:41
SmBracketType
Bracket types that can be inserted.
Definition: cursor.hxx:46
@ Round
Round brackets, left command "(".
@ Square
Square brackets, left command "[".
@ Curly
Curly brackets, left command "lbrace".
@ MoveDown
Definition: cursor.hxx:25
@ MoveRight
Definition: cursor.hxx:27
@ MoveUp
Definition: cursor.hxx:24
@ MoveLeft
Definition: cursor.hxx:26
virtual void Insert(SotClipboardFormatId nFormat, const OUString &rFormatName) override
virtual void SetText(const OUString &rStr) override
virtual SfxBindings & GetBindings() override
virtual void SetHelpId(const OUString &) override
SFX_IMPL_SUPERCLASS_INTERFACE(DrawDocShell, SfxObjectShell)
constexpr OUStringLiteral MATHML_XML
Definition: document.hxx:45
float u
float y
float x
void SmGetLeftSelectionPart(const ESelection &rSel, sal_Int32 &nPara, sal_uInt16 &nPos)
Definition: edit.cxx:48
#define EDITUNDO_REPLACEALL
#define ERRCODE_NONE
ALIGN_TOP
FAMILY_DONTKNOW
WEIGHT_BOLD
WEIGHT_NORMAL
SotClipboardFormatId
uno::Reference< graphic::XGraphic > mxGraphic
constexpr OUStringLiteral HID_SMA_WIN_DOCUMENT
Definition: helpids.h:25
constexpr OUStringLiteral HID_SMA_MAIN_HELP
Definition: helpids.h:24
constexpr OUStringLiteral HID_SMA_COMMAND_WIN
Definition: helpids.h:28
sal_Int64 n
constexpr sal_uInt16 KEY_RETURN
constexpr sal_uInt16 KEY_LEFT
constexpr sal_uInt16 KEY_UP
constexpr sal_uInt16 KEY_F1
constexpr sal_uInt16 KEY_RIGHT
constexpr sal_uInt16 KEY_DELETE
constexpr sal_uInt16 KEY_DOWN
constexpr sal_uInt16 KEY_BACKSPACE
sal_uInt16 nPos
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
std::unique_ptr< sal_Int32[]> pData
constexpr OUStringLiteral aData
SfxDispatcher * GetDispatcher()
OString stripStart(const OString &rIn, char c)
Reference< XComponentContext > getProcessComponentContext()
int i
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
m
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
constexpr T & temporary(T &&x)
SwAbstractDialogFactory & GetFactory()
long Long
UNOTOOLS_DLLPUBLIC bool GetTitle(OUString const &url, OUString *title)
HashMap_OWString_Interface aMap
@ RSUP
Definition: node.hxx:1536
@ RSUB
Definition: node.hxx:1536
#define SFX_OBJECTBAR_TOOLS
sal_Int16 nId
const char GetValue[]
VCL_DLLPUBLIC void InvertFocusRect(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
SfxItemState
QPRO_FUNC_TYPE nType
#define STYLE_CURSOR_NOBLINKTIME
static SfxItemSet & rSet
OUString SmResId(TranslateId aId)
Definition: smmod.cxx:42
#define SM_MOD()
Definition: smmod.hxx:98
sal_Int32 nEndPos
sal_Int32 nStartPos
OUString m_aText
Definition: parsebase.hxx:60
SmNode * m_pNode
Definition: parsebase.hxx:59
Reference< XController > xController
Reference< XFrame > xFrame
Reference< XModel > xModel
sal_uInt16 sal_Unicode
SmPrintSize
Definition: types.hxx:28
@ PRINT_SIZE_NORMAL
Definition: types.hxx:29
@ PRINT_SIZE_ZOOMED
Definition: types.hxx:31
@ PRINT_SIZE_SCALED
Definition: types.hxx:30
constexpr OUStringLiteral PRTUIOPT_TITLE_ROW
Definition: unomodel.hxx:30
constexpr OUStringLiteral PRTUIOPT_BORDER
Definition: unomodel.hxx:32
constexpr OUStringLiteral PRTUIOPT_PRINT_SCALE
Definition: unomodel.hxx:34
constexpr OUStringLiteral PRTUIOPT_PRINT_FORMAT
Definition: unomodel.hxx:33
constexpr OUStringLiteral PRTUIOPT_FORMULA_TEXT
Definition: unomodel.hxx:31
MapUnit SmMapUnit()
Definition: utility.hxx:121
RET_CANCEL
IMPL_LINK_NOARG(SmGraphicWindow, ScrollHdl, weld::ScrolledWindow &, void)
Definition: view.cxx:235
SFX_IMPL_NAMED_VIEWFACTORY(SmViewShell, "Default")
Definition: view.cxx:1155
#define MINZOOM
Definition: view.cxx:93
IMPL_LINK(SmViewShell, DialogClosedHdl, sfx2::FileDialogHelper *, _pFileDlg, void)
Definition: view.cxx:2290
#define CMD_BOX_PADDING_TOP
Definition: view.cxx:100
#define MAXZOOM
Definition: view.cxx:94
#define CMD_BOX_PADDING
Definition: view.cxx:99
SFX_IMPL_DOCKINGWINDOW_WITHID(SmCmdBoxWrapper, SID_CMDBOXWINDOW)
#define SFX_PRINTERROR_BUSY
SfxPrinterChangeFlags
#define SFX_VIEW_REGISTRATION(DocClass)
SfxViewShellFlags
StateChangedType
int GetError()