1d107581fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3d107581fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4d107581fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5d107581fSAndrew Rist * distributed with this work for additional information
6d107581fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7d107581fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8d107581fSAndrew Rist * "License"); you may not use this file except in compliance
9d107581fSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11d107581fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13d107581fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14d107581fSAndrew Rist * software distributed under the License is distributed on an
15d107581fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16d107581fSAndrew Rist * KIND, either express or implied. See the License for the
17d107581fSAndrew Rist * specific language governing permissions and limitations
18d107581fSAndrew Rist * under the License.
19cdf0e10cSrcweir *
20d107581fSAndrew Rist *************************************************************/
21d107581fSAndrew Rist
22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
23cdf0e10cSrcweir #include "precompiled_starmath.hxx"
24cdf0e10cSrcweir
25cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp>
26cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventObject.hpp>
27cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp>
28cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessible.hpp>
29cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
30cdf0e10cSrcweir #include <com/sun/star/frame/XDesktop.hpp>
31cdf0e10cSrcweir #include <com/sun/star/frame/XFramesSupplier.hpp>
32cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp>
33cdf0e10cSrcweir
34cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
35cdf0e10cSrcweir #include <comphelper/storagehelper.hxx>
36cdf0e10cSrcweir #include <rtl/logfile.hxx>
37cdf0e10cSrcweir #include <sfx2/app.hxx>
38cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
39cdf0e10cSrcweir #include <sfx2/docfile.hxx>
40cdf0e10cSrcweir #include <sfx2/docfilt.hxx>
41cdf0e10cSrcweir #include <sfx2/docinsert.hxx>
42cdf0e10cSrcweir #include <sfx2/filedlghelper.hxx>
43cdf0e10cSrcweir #include <sfx2/msg.hxx>
44cdf0e10cSrcweir #include <sfx2/objface.hxx>
45cdf0e10cSrcweir #include <sfx2/printer.hxx>
46cdf0e10cSrcweir #include <sfx2/request.hxx>
47cdf0e10cSrcweir #include <svl/eitem.hxx>
48cdf0e10cSrcweir #include <svl/intitem.hxx>
49cdf0e10cSrcweir #include <svl/itemset.hxx>
50cdf0e10cSrcweir #include <svl/poolitem.hxx>
51cdf0e10cSrcweir #include <svl/ptitem.hxx>
52cdf0e10cSrcweir #include <svl/stritem.hxx>
53cdf0e10cSrcweir #include <svtools/transfer.hxx>
54cdf0e10cSrcweir #include <svl/undo.hxx>
55cdf0e10cSrcweir #include <svl/whiter.hxx>
56cdf0e10cSrcweir #include <svx/dialogs.hrc>
57cdf0e10cSrcweir #include <editeng/editeng.hxx>
58cdf0e10cSrcweir #include <svx/svxdlg.hxx>
59cdf0e10cSrcweir #include <svx/zoomitem.hxx>
60cdf0e10cSrcweir #include <vcl/decoview.hxx>
61cdf0e10cSrcweir #include <vcl/menu.hxx>
62cdf0e10cSrcweir #include <vcl/msgbox.hxx>
63cdf0e10cSrcweir #include <vcl/wrkwin.hxx>
64cdf0e10cSrcweir
65cdf0e10cSrcweir #include "unomodel.hxx"
66cdf0e10cSrcweir #include "view.hxx"
67cdf0e10cSrcweir #include "config.hxx"
68cdf0e10cSrcweir #include "dialog.hxx"
69cdf0e10cSrcweir #include "document.hxx"
70cdf0e10cSrcweir #include "starmath.hrc"
71cdf0e10cSrcweir #include "toolbox.hxx"
72cdf0e10cSrcweir #include "mathmlimport.hxx"
73cdf0e10cSrcweir
74cdf0e10cSrcweir #define MINWIDTH 200
75cdf0e10cSrcweir #define MINHEIGHT 200
76cdf0e10cSrcweir #define MINSPLIT 40
77cdf0e10cSrcweir #define SPLITTERWIDTH 2
78cdf0e10cSrcweir
79cdf0e10cSrcweir #define MINZOOM 25
80cdf0e10cSrcweir #define MAXZOOM 800
81cdf0e10cSrcweir
82cdf0e10cSrcweir #define SmViewShell
83cdf0e10cSrcweir #include "smslots.hxx"
84cdf0e10cSrcweir
85cdf0e10cSrcweir using namespace com::sun::star;
86cdf0e10cSrcweir using namespace com::sun::star::accessibility;
87cdf0e10cSrcweir using namespace com::sun::star::uno;
88cdf0e10cSrcweir
89cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
90cdf0e10cSrcweir
SmGraphicWindow(SmViewShell * pShell)91cdf0e10cSrcweir SmGraphicWindow::SmGraphicWindow(SmViewShell* pShell):
92cdf0e10cSrcweir ScrollableWindow(&pShell->GetViewFrame()->GetWindow(), 0),
93cdf0e10cSrcweir pAccessible(0),
94cdf0e10cSrcweir pViewShell(pShell),
95cdf0e10cSrcweir nZoom(100),
96cdf0e10cSrcweir bIsCursorVisible(sal_False)
97cdf0e10cSrcweir {
98cdf0e10cSrcweir // docking windows are usually hidden (often already done in the
99cdf0e10cSrcweir // resource) and will be shown by the sfx framework.
100cdf0e10cSrcweir Hide();
101cdf0e10cSrcweir
102cdf0e10cSrcweir const Fraction aFraction (1,1);
103cdf0e10cSrcweir SetMapMode( MapMode(MAP_100TH_MM, Point(), aFraction, aFraction));
104cdf0e10cSrcweir
105cdf0e10cSrcweir ApplyColorConfigValues( SM_MOD()->GetColorConfig() );
106cdf0e10cSrcweir
107cdf0e10cSrcweir SetTotalSize();
108cdf0e10cSrcweir
109cdf0e10cSrcweir SetHelpId(HID_SMA_WIN_DOCUMENT);
110cdf0e10cSrcweir SetUniqueId(HID_SMA_WIN_DOCUMENT);
111cdf0e10cSrcweir }
112cdf0e10cSrcweir
~SmGraphicWindow()113cdf0e10cSrcweir SmGraphicWindow::~SmGraphicWindow()
114cdf0e10cSrcweir {
115cdf0e10cSrcweir if (pAccessible)
116cdf0e10cSrcweir pAccessible->ClearWin(); // make Accessible defunctional
117cdf0e10cSrcweir // Note: memory for pAccessible will be freed when the reference
118cdf0e10cSrcweir // xAccessible is released.
119cdf0e10cSrcweir }
120cdf0e10cSrcweir
StateChanged(StateChangedType eType)121cdf0e10cSrcweir void SmGraphicWindow::StateChanged( StateChangedType eType )
122cdf0e10cSrcweir {
123cdf0e10cSrcweir if ( eType == STATE_CHANGE_INITSHOW )
124cdf0e10cSrcweir Show();
125cdf0e10cSrcweir ScrollableWindow::StateChanged( eType );
126cdf0e10cSrcweir }
127cdf0e10cSrcweir
128cdf0e10cSrcweir
ApplyColorConfigValues(const svtools::ColorConfig & rColorCfg)129cdf0e10cSrcweir void SmGraphicWindow::ApplyColorConfigValues( const svtools::ColorConfig &rColorCfg )
130cdf0e10cSrcweir {
131cdf0e10cSrcweir // Note: SetTextColor not necessary since the nodes that
132cdf0e10cSrcweir // get painted have the color information.
133cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
134cdf0e10cSrcweir // ColorData nVal = rColorCfg.GetColorValue(svtools::DOCCOLOR).nColor;
135cdf0e10cSrcweir #endif
136cdf0e10cSrcweir SetBackground( Color( (ColorData) rColorCfg.GetColorValue(svtools::DOCCOLOR).nColor ) );
137cdf0e10cSrcweir Invalidate();
138cdf0e10cSrcweir }
139cdf0e10cSrcweir
140cdf0e10cSrcweir
DataChanged(const DataChangedEvent & rEvt)141cdf0e10cSrcweir void SmGraphicWindow::DataChanged( const DataChangedEvent& rEvt )
142cdf0e10cSrcweir {
143cdf0e10cSrcweir ApplyColorConfigValues( SM_MOD()->GetColorConfig() );
144cdf0e10cSrcweir
145cdf0e10cSrcweir ScrollableWindow::DataChanged( rEvt );
146cdf0e10cSrcweir }
147cdf0e10cSrcweir
148cdf0e10cSrcweir
MouseButtonDown(const MouseEvent & rMEvt)149cdf0e10cSrcweir void SmGraphicWindow::MouseButtonDown(const MouseEvent& rMEvt)
150cdf0e10cSrcweir {
151cdf0e10cSrcweir ScrollableWindow::MouseButtonDown(rMEvt);
152cdf0e10cSrcweir
153cdf0e10cSrcweir //
154cdf0e10cSrcweir // set formula-cursor and selection of edit window according to the
155cdf0e10cSrcweir // position clicked at
156cdf0e10cSrcweir //
157cdf0e10cSrcweir DBG_ASSERT(rMEvt.GetClicks() > 0, "Sm : 0 clicks");
158cdf0e10cSrcweir if ( rMEvt.IsLeft() && pViewShell->GetEditWindow() )
159cdf0e10cSrcweir {
160cdf0e10cSrcweir const SmNode *pTree = pViewShell->GetDoc()->GetFormulaTree();
161a1f1a12aSmseidel //! kann NULL sein! Z.B. wenn bereits beim laden des Dokuments (bevor der
162cdf0e10cSrcweir //! Parser angeworfen wurde) ins Fenster geklickt wird.
163cdf0e10cSrcweir if (!pTree)
164cdf0e10cSrcweir return;
165cdf0e10cSrcweir
166cdf0e10cSrcweir // get click position relativ to formula
167cdf0e10cSrcweir Point aPos (PixelToLogic(rMEvt.GetPosPixel())
168cdf0e10cSrcweir - GetFormulaDrawPos());
169cdf0e10cSrcweir
170cdf0e10cSrcweir // if it was clicked inside the formula then get the appropriate node
171cdf0e10cSrcweir const SmNode *pNode = 0;
172cdf0e10cSrcweir if (pTree->OrientedDist(aPos) <= 0)
173cdf0e10cSrcweir pNode = pTree->FindRectClosestTo(aPos);
174cdf0e10cSrcweir
175cdf0e10cSrcweir if (pNode)
176cdf0e10cSrcweir { SmEditWindow *pEdit = pViewShell->GetEditWindow();
177cdf0e10cSrcweir const SmToken aToken (pNode->GetToken());
178cdf0e10cSrcweir
179cdf0e10cSrcweir #ifdef notnow
180cdf0e10cSrcweir // include introducing symbols of special char and text
181a1f1a12aSmseidel // (i.e. '%' and '"')
182cdf0e10cSrcweir sal_uInt16 nExtra = (aToken.eType == TSPECIAL || aToken.eType == TTEXT) ? 1 : 0;
183cdf0e10cSrcweir
184cdf0e10cSrcweir // set selection to the beginning of the token
185cdf0e10cSrcweir ESelection aSel (aToken.nRow - 1, aToken.nCol - 1 - nExtra);
186cdf0e10cSrcweir
187cdf0e10cSrcweir if (rMEvt.GetClicks() != 1)
188cdf0e10cSrcweir { // select whole token
189*74ad9c3aSmseidel // for text include terminating symbol (i.e. '"')
190cdf0e10cSrcweir aSel.nEndPos += aToken.aText.Len() + nExtra
191cdf0e10cSrcweir + (aToken.eType == TTEXT ? 1 : 0);
192cdf0e10cSrcweir }
193cdf0e10cSrcweir #endif
194cdf0e10cSrcweir // set selection to the beginning of the token
195cdf0e10cSrcweir ESelection aSel (aToken.nRow - 1, aToken.nCol - 1);
196cdf0e10cSrcweir
197cdf0e10cSrcweir if (rMEvt.GetClicks() != 1 || aToken.eType == TPLACE)
198cdf0e10cSrcweir aSel.nEndPos = aSel.nEndPos + sal::static_int_cast< sal_uInt16 >(aToken.aText.Len());
199cdf0e10cSrcweir
200cdf0e10cSrcweir pEdit->SetSelection(aSel);
201cdf0e10cSrcweir SetCursor(pNode);
202cdf0e10cSrcweir
203cdf0e10cSrcweir // allow for immediate editing and
204cdf0e10cSrcweir //! implicitly synchronize the cursor position mark in this window
205cdf0e10cSrcweir pEdit->GrabFocus();
206cdf0e10cSrcweir }
207cdf0e10cSrcweir }
208cdf0e10cSrcweir }
209cdf0e10cSrcweir
GetFocus()210cdf0e10cSrcweir void SmGraphicWindow::GetFocus()
211cdf0e10cSrcweir {
212cdf0e10cSrcweir /*
213cdf0e10cSrcweir if (xAccessible.is())
214cdf0e10cSrcweir {
215cdf0e10cSrcweir uno::Any aOldValue, aNewValue;
216cdf0e10cSrcweir // aOldValue remains empty
217cdf0e10cSrcweir aNewValue <<= AccessibleStateType::FOCUSED;
218cdf0e10cSrcweir pAccessible->LaunchEvent( AccessibleEventId::STATE_CHANGED,
219cdf0e10cSrcweir aOldValue, aNewValue );
220cdf0e10cSrcweir }
221cdf0e10cSrcweir */
222cdf0e10cSrcweir }
223cdf0e10cSrcweir
LoseFocus()224cdf0e10cSrcweir void SmGraphicWindow::LoseFocus()
225cdf0e10cSrcweir {
226cdf0e10cSrcweir ScrollableWindow::LoseFocus();
227cdf0e10cSrcweir if (xAccessible.is())
228cdf0e10cSrcweir {
229cdf0e10cSrcweir uno::Any aOldValue, aNewValue;
230cdf0e10cSrcweir aOldValue <<= AccessibleStateType::FOCUSED;
231cdf0e10cSrcweir // aNewValue remains empty
232cdf0e10cSrcweir pAccessible->LaunchEvent( AccessibleEventId::STATE_CHANGED,
233cdf0e10cSrcweir aOldValue, aNewValue );
234cdf0e10cSrcweir }
235cdf0e10cSrcweir }
236cdf0e10cSrcweir
ShowCursor(sal_Bool bShow)237cdf0e10cSrcweir void SmGraphicWindow::ShowCursor(sal_Bool bShow)
238cdf0e10cSrcweir // shows or hides the formula-cursor depending on 'bShow' is sal_True or not
239cdf0e10cSrcweir {
240cdf0e10cSrcweir sal_Bool bInvert = bShow != IsCursorVisible();
241cdf0e10cSrcweir
242cdf0e10cSrcweir if (bInvert)
243cdf0e10cSrcweir InvertTracking(aCursorRect, SHOWTRACK_SMALL | SHOWTRACK_WINDOW);
244cdf0e10cSrcweir
245cdf0e10cSrcweir SetIsCursorVisible(bShow);
246cdf0e10cSrcweir }
247cdf0e10cSrcweir
248cdf0e10cSrcweir
SetCursor(const SmNode * pNode)249cdf0e10cSrcweir void SmGraphicWindow::SetCursor(const SmNode *pNode)
250cdf0e10cSrcweir {
251cdf0e10cSrcweir const SmNode *pTree = pViewShell->GetDoc()->GetFormulaTree();
252cdf0e10cSrcweir
253cdf0e10cSrcweir // get appropriate rectangle
254cdf0e10cSrcweir Point aOffset (pNode->GetTopLeft() - pTree->GetTopLeft()),
255cdf0e10cSrcweir aTLPos (GetFormulaDrawPos() + aOffset);
256cdf0e10cSrcweir aTLPos.X() -= pNode->GetItalicLeftSpace();
257cdf0e10cSrcweir Size aSize (pNode->GetItalicSize());
258cdf0e10cSrcweir Point aBRPos (aTLPos.X() + aSize.Width(), aTLPos.Y() + aSize.Height());
259cdf0e10cSrcweir
260cdf0e10cSrcweir SetCursor(Rectangle(aTLPos, aSize));
261cdf0e10cSrcweir }
262cdf0e10cSrcweir
SetCursor(const Rectangle & rRect)263cdf0e10cSrcweir void SmGraphicWindow::SetCursor(const Rectangle &rRect)
264cdf0e10cSrcweir // sets cursor to new position (rectangle) 'rRect'.
265cdf0e10cSrcweir // The old cursor will be removed, and the new one will be shown if
266cdf0e10cSrcweir // that is activated in the ConfigItem
267cdf0e10cSrcweir {
268cdf0e10cSrcweir SmModule *pp = SM_MOD();
269cdf0e10cSrcweir
270cdf0e10cSrcweir if (IsCursorVisible())
271cdf0e10cSrcweir ShowCursor(sal_False); // clean up remainings of old cursor
272cdf0e10cSrcweir aCursorRect = rRect;
273cdf0e10cSrcweir if (pp->GetConfig()->IsShowFormulaCursor())
274cdf0e10cSrcweir ShowCursor(sal_True); // draw new cursor
275cdf0e10cSrcweir }
276cdf0e10cSrcweir
SetCursorPos(sal_uInt16 nRow,sal_uInt16 nCol)277cdf0e10cSrcweir const SmNode * SmGraphicWindow::SetCursorPos(sal_uInt16 nRow, sal_uInt16 nCol)
278a1f1a12aSmseidel // looks for a VISIBLE node in the formula tree with its token at
279cdf0e10cSrcweir // (or around) the position 'nRow', 'nCol' in the edit window
280cdf0e10cSrcweir // (row and column numbering starts with 1 there!).
281cdf0e10cSrcweir // If there is such a node the formula-cursor is set to cover that nodes
282cdf0e10cSrcweir // rectangle. If not the formula-cursor will be hidden.
283cdf0e10cSrcweir // In any case the search result is being returned.
284cdf0e10cSrcweir {
285cdf0e10cSrcweir // find visible node with token at nRow, nCol
286cdf0e10cSrcweir const SmNode *pTree = pViewShell->GetDoc()->GetFormulaTree(),
287cdf0e10cSrcweir *pNode = 0;
288cdf0e10cSrcweir if (pTree)
289cdf0e10cSrcweir pNode = pTree->FindTokenAt(nRow, nCol);
290cdf0e10cSrcweir
291cdf0e10cSrcweir if (pNode)
292cdf0e10cSrcweir SetCursor(pNode);
293cdf0e10cSrcweir else
294cdf0e10cSrcweir ShowCursor(sal_False);
295cdf0e10cSrcweir
296cdf0e10cSrcweir return pNode;
297cdf0e10cSrcweir }
298cdf0e10cSrcweir
299cdf0e10cSrcweir
Paint(const Rectangle &)300cdf0e10cSrcweir void SmGraphicWindow::Paint(const Rectangle&)
301cdf0e10cSrcweir {
302cdf0e10cSrcweir DBG_ASSERT(pViewShell, "Sm : NULL pointer");
303cdf0e10cSrcweir
304cdf0e10cSrcweir SmDocShell &rDoc = *pViewShell->GetDoc();
305cdf0e10cSrcweir Point aPoint;
306cdf0e10cSrcweir
307cdf0e10cSrcweir rDoc.Draw(*this, aPoint); //! modifies aPoint to be the topleft
308cdf0e10cSrcweir //! corner of the formula
309cdf0e10cSrcweir SetFormulaDrawPos(aPoint);
310cdf0e10cSrcweir
311cdf0e10cSrcweir SetIsCursorVisible(sal_False); // (old) cursor must be drawn again
312cdf0e10cSrcweir
313cdf0e10cSrcweir const SmEditWindow *pEdit = pViewShell->GetEditWindow();
314cdf0e10cSrcweir if (pEdit)
315cdf0e10cSrcweir { // get new position for formula-cursor (for possible altered formula)
316cdf0e10cSrcweir sal_uInt16 nRow, nCol;
317cdf0e10cSrcweir SmGetLeftSelectionPart(pEdit->GetSelection(), nRow, nCol);
318cdf0e10cSrcweir nRow++;
319cdf0e10cSrcweir nCol++;
320cdf0e10cSrcweir const SmNode *pFound = SetCursorPos(nRow, nCol);
321cdf0e10cSrcweir
322cdf0e10cSrcweir SmModule *pp = SM_MOD();
323cdf0e10cSrcweir if (pFound && pp->GetConfig()->IsShowFormulaCursor())
324cdf0e10cSrcweir ShowCursor(sal_True);
325cdf0e10cSrcweir }
326cdf0e10cSrcweir }
327cdf0e10cSrcweir
328cdf0e10cSrcweir
SetTotalSize()329cdf0e10cSrcweir void SmGraphicWindow::SetTotalSize ()
330cdf0e10cSrcweir {
331cdf0e10cSrcweir SmDocShell &rDoc = *pViewShell->GetDoc();
332cdf0e10cSrcweir const Size aTmp( PixelToLogic( LogicToPixel( rDoc.GetSize() )));
333cdf0e10cSrcweir if ( aTmp != ScrollableWindow::GetTotalSize() )
334cdf0e10cSrcweir ScrollableWindow::SetTotalSize( aTmp );
335cdf0e10cSrcweir }
336cdf0e10cSrcweir
337cdf0e10cSrcweir
KeyInput(const KeyEvent & rKEvt)338cdf0e10cSrcweir void SmGraphicWindow::KeyInput(const KeyEvent& rKEvt)
339cdf0e10cSrcweir {
340cdf0e10cSrcweir if (! (GetView() && GetView()->KeyInput(rKEvt)) )
341cdf0e10cSrcweir ScrollableWindow::KeyInput(rKEvt);
342cdf0e10cSrcweir }
343cdf0e10cSrcweir
344cdf0e10cSrcweir
Command(const CommandEvent & rCEvt)345cdf0e10cSrcweir void SmGraphicWindow::Command(const CommandEvent& rCEvt)
346cdf0e10cSrcweir {
347cdf0e10cSrcweir sal_Bool bCallBase = sal_True;
348cdf0e10cSrcweir if ( !pViewShell->GetViewFrame()->GetFrame().IsInPlace() )
349cdf0e10cSrcweir {
350cdf0e10cSrcweir switch ( rCEvt.GetCommand() )
351cdf0e10cSrcweir {
352cdf0e10cSrcweir case COMMAND_CONTEXTMENU:
353cdf0e10cSrcweir {
354cdf0e10cSrcweir GetParent()->ToTop();
355cdf0e10cSrcweir SmResId aResId( RID_VIEWMENU );
356cdf0e10cSrcweir PopupMenu* pPopupMenu = new PopupMenu(aResId);
357cdf0e10cSrcweir pPopupMenu->SetSelectHdl(LINK(this, SmGraphicWindow, MenuSelectHdl));
358cdf0e10cSrcweir Point aPos(5, 5);
359cdf0e10cSrcweir if (rCEvt.IsMouseEvent())
360cdf0e10cSrcweir aPos = rCEvt.GetMousePosPixel();
361cdf0e10cSrcweir DBG_ASSERT( pViewShell, "view shell missing" );
362cdf0e10cSrcweir
363cdf0e10cSrcweir // added for replaceability of context menus #96085, #93782
364cdf0e10cSrcweir pViewShell->GetViewFrame()->GetBindings().GetDispatcher()
365cdf0e10cSrcweir ->ExecutePopup( aResId, this, &aPos );
366cdf0e10cSrcweir //pPopupMenu->Execute( this, aPos );
367cdf0e10cSrcweir
368cdf0e10cSrcweir delete pPopupMenu;
369cdf0e10cSrcweir bCallBase = sal_False;
370cdf0e10cSrcweir }
371cdf0e10cSrcweir break;
372cdf0e10cSrcweir
373cdf0e10cSrcweir case COMMAND_WHEEL:
374cdf0e10cSrcweir {
375cdf0e10cSrcweir const CommandWheelData* pWData = rCEvt.GetWheelData();
376cdf0e10cSrcweir if ( pWData && COMMAND_WHEEL_ZOOM == pWData->GetMode() )
377cdf0e10cSrcweir {
378cdf0e10cSrcweir sal_uInt16 nTmpZoom = GetZoom();
379cdf0e10cSrcweir if( 0L > pWData->GetDelta() )
380cdf0e10cSrcweir nTmpZoom -= 10;
381cdf0e10cSrcweir else
382cdf0e10cSrcweir nTmpZoom += 10;
383cdf0e10cSrcweir SetZoom( nTmpZoom );
384cdf0e10cSrcweir bCallBase = sal_False;
385cdf0e10cSrcweir }
386cdf0e10cSrcweir }
387cdf0e10cSrcweir break;
388cdf0e10cSrcweir }
389cdf0e10cSrcweir }
390cdf0e10cSrcweir if ( bCallBase )
391cdf0e10cSrcweir ScrollableWindow::Command (rCEvt);
392cdf0e10cSrcweir }
393cdf0e10cSrcweir
394cdf0e10cSrcweir
IMPL_LINK_INLINE_START(SmGraphicWindow,MenuSelectHdl,Menu *,pMenu)395cdf0e10cSrcweir IMPL_LINK_INLINE_START( SmGraphicWindow, MenuSelectHdl, Menu *, pMenu )
396cdf0e10cSrcweir {
397cdf0e10cSrcweir SmViewShell *pViewSh = GetView();
398cdf0e10cSrcweir if (pViewSh)
399cdf0e10cSrcweir pViewSh->GetViewFrame()->GetDispatcher()->Execute( pMenu->GetCurItemId() );
400cdf0e10cSrcweir return 0;
401cdf0e10cSrcweir }
IMPL_LINK_INLINE_END(SmGraphicWindow,MenuSelectHdl,Menu *,pMenu)402cdf0e10cSrcweir IMPL_LINK_INLINE_END( SmGraphicWindow, MenuSelectHdl, Menu *, pMenu )
403cdf0e10cSrcweir
404cdf0e10cSrcweir
405cdf0e10cSrcweir void SmGraphicWindow::SetZoom(sal_uInt16 Factor)
406cdf0e10cSrcweir {
407cdf0e10cSrcweir nZoom = Min(Max((sal_uInt16) Factor, (sal_uInt16) MINZOOM), (sal_uInt16) MAXZOOM);
408cdf0e10cSrcweir Fraction aFraction (nZoom, 100);
409cdf0e10cSrcweir SetMapMode( MapMode(MAP_100TH_MM, Point(), aFraction, aFraction) );
410cdf0e10cSrcweir SetTotalSize();
411cdf0e10cSrcweir SmViewShell *pViewSh = GetView();
412cdf0e10cSrcweir if (pViewSh)
413cdf0e10cSrcweir pViewSh->GetViewFrame()->GetBindings().Invalidate(SID_ATTR_ZOOM);
414cdf0e10cSrcweir Invalidate();
415cdf0e10cSrcweir }
416cdf0e10cSrcweir
417cdf0e10cSrcweir
ZoomToFitInWindow()418cdf0e10cSrcweir void SmGraphicWindow::ZoomToFitInWindow()
419cdf0e10cSrcweir {
420cdf0e10cSrcweir SmDocShell &rDoc = *pViewShell->GetDoc();
421cdf0e10cSrcweir
422cdf0e10cSrcweir // set defined mapmode before calling 'LogicToPixel' below
423cdf0e10cSrcweir SetMapMode(MapMode(MAP_100TH_MM));
424cdf0e10cSrcweir
425cdf0e10cSrcweir Size aSize (LogicToPixel(rDoc.GetSize()));
426cdf0e10cSrcweir Size aWindowSize (GetSizePixel());
427cdf0e10cSrcweir
428cdf0e10cSrcweir if (aSize.Width() > 0 && aSize.Height() > 0)
429cdf0e10cSrcweir {
430cdf0e10cSrcweir long nVal = Min ((85 * aWindowSize.Width()) / aSize.Width(),
431cdf0e10cSrcweir (85 * aWindowSize.Height()) / aSize.Height());
432cdf0e10cSrcweir SetZoom ( sal::static_int_cast< sal_uInt16 >(nVal) );
433cdf0e10cSrcweir }
434cdf0e10cSrcweir }
435cdf0e10cSrcweir
CreateAccessible()436cdf0e10cSrcweir uno::Reference< XAccessible > SmGraphicWindow::CreateAccessible()
437cdf0e10cSrcweir {
438cdf0e10cSrcweir if (!pAccessible)
439cdf0e10cSrcweir {
440cdf0e10cSrcweir pAccessible = new SmGraphicAccessible( this );
441cdf0e10cSrcweir xAccessible = pAccessible;
442cdf0e10cSrcweir }
443cdf0e10cSrcweir return xAccessible;
444cdf0e10cSrcweir }
445cdf0e10cSrcweir
446cdf0e10cSrcweir /**************************************************************************/
447cdf0e10cSrcweir
448cdf0e10cSrcweir
SmGraphicController(SmGraphicWindow & rSmGraphic,sal_uInt16 nId_,SfxBindings & rBindings)449cdf0e10cSrcweir SmGraphicController::SmGraphicController(SmGraphicWindow &rSmGraphic,
450cdf0e10cSrcweir sal_uInt16 nId_,
451cdf0e10cSrcweir SfxBindings &rBindings) :
452cdf0e10cSrcweir SfxControllerItem(nId_, rBindings),
453cdf0e10cSrcweir rGraphic(rSmGraphic)
454cdf0e10cSrcweir {
455cdf0e10cSrcweir }
456cdf0e10cSrcweir
457cdf0e10cSrcweir
StateChanged(sal_uInt16 nSID,SfxItemState eState,const SfxPoolItem * pState)458cdf0e10cSrcweir void SmGraphicController::StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState)
459cdf0e10cSrcweir {
460cdf0e10cSrcweir rGraphic.SetTotalSize();
461cdf0e10cSrcweir rGraphic.Invalidate();
462cdf0e10cSrcweir SfxControllerItem::StateChanged (nSID, eState, pState);
463cdf0e10cSrcweir }
464cdf0e10cSrcweir
465cdf0e10cSrcweir
466cdf0e10cSrcweir /**************************************************************************/
467cdf0e10cSrcweir
468cdf0e10cSrcweir
SmEditController(SmEditWindow & rSmEdit,sal_uInt16 nId_,SfxBindings & rBindings)469cdf0e10cSrcweir SmEditController::SmEditController(SmEditWindow &rSmEdit,
470cdf0e10cSrcweir sal_uInt16 nId_,
471cdf0e10cSrcweir SfxBindings &rBindings) :
472cdf0e10cSrcweir SfxControllerItem(nId_, rBindings),
473cdf0e10cSrcweir rEdit(rSmEdit)
474cdf0e10cSrcweir {
475cdf0e10cSrcweir }
476cdf0e10cSrcweir
477cdf0e10cSrcweir
478cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
~SmEditController()479cdf0e10cSrcweir SmEditController::~SmEditController()
480cdf0e10cSrcweir {
481cdf0e10cSrcweir }
482cdf0e10cSrcweir #endif
483cdf0e10cSrcweir
484cdf0e10cSrcweir
StateChanged(sal_uInt16 nSID,SfxItemState eState,const SfxPoolItem * pState)485cdf0e10cSrcweir void SmEditController::StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState)
486cdf0e10cSrcweir {
487cdf0e10cSrcweir const SfxStringItem *pItem = PTR_CAST(SfxStringItem, pState);
488cdf0e10cSrcweir
489cdf0e10cSrcweir if ((pItem != NULL) && (rEdit.GetText() != pItem->GetValue()))
490cdf0e10cSrcweir rEdit.SetText(pItem->GetValue());
491cdf0e10cSrcweir SfxControllerItem::StateChanged (nSID, eState, pState);
492cdf0e10cSrcweir }
493cdf0e10cSrcweir
494cdf0e10cSrcweir
495cdf0e10cSrcweir /**************************************************************************/
496cdf0e10cSrcweir
SmCmdBoxWindow(SfxBindings * pBindings_,SfxChildWindow * pChildWindow,Window * pParent)497cdf0e10cSrcweir SmCmdBoxWindow::SmCmdBoxWindow(SfxBindings *pBindings_, SfxChildWindow *pChildWindow,
498cdf0e10cSrcweir Window *pParent) :
499cdf0e10cSrcweir SfxDockingWindow(pBindings_, pChildWindow, pParent, SmResId(RID_CMDBOXWINDOW)),
500cdf0e10cSrcweir aEdit (*this),
501cdf0e10cSrcweir aController (aEdit, SID_TEXT, *pBindings_),
502cdf0e10cSrcweir bExiting (sal_False)
503cdf0e10cSrcweir {
504cdf0e10cSrcweir Hide ();
505cdf0e10cSrcweir
506cdf0e10cSrcweir aInitialFocusTimer.SetTimeoutHdl(LINK(this, SmCmdBoxWindow, InitialFocusTimerHdl));
507cdf0e10cSrcweir aInitialFocusTimer.SetTimeout(100);
508cdf0e10cSrcweir }
509cdf0e10cSrcweir
510cdf0e10cSrcweir
~SmCmdBoxWindow()511cdf0e10cSrcweir SmCmdBoxWindow::~SmCmdBoxWindow ()
512cdf0e10cSrcweir {
513cdf0e10cSrcweir aInitialFocusTimer.Stop();
514cdf0e10cSrcweir bExiting = sal_True;
515cdf0e10cSrcweir }
516cdf0e10cSrcweir
517cdf0e10cSrcweir
GetView()518cdf0e10cSrcweir SmViewShell * SmCmdBoxWindow::GetView()
519cdf0e10cSrcweir {
520cdf0e10cSrcweir SfxViewShell *pView = GetBindings().GetDispatcher()->GetFrame()->GetViewShell();
521cdf0e10cSrcweir return PTR_CAST(SmViewShell, pView);
522cdf0e10cSrcweir }
523cdf0e10cSrcweir
Resize()524cdf0e10cSrcweir void SmCmdBoxWindow::Resize()
525cdf0e10cSrcweir {
526cdf0e10cSrcweir Rectangle aRect = Rectangle(Point(0, 0), GetOutputSizePixel());
527cdf0e10cSrcweir
528cdf0e10cSrcweir if (! IsFloatingMode())
529cdf0e10cSrcweir {
530cdf0e10cSrcweir switch (GetAlignment())
531cdf0e10cSrcweir {
532cdf0e10cSrcweir case SFX_ALIGN_TOP: aRect.Bottom()--; break;
533cdf0e10cSrcweir case SFX_ALIGN_BOTTOM: aRect.Top()++; break;
534cdf0e10cSrcweir case SFX_ALIGN_LEFT: aRect.Right()--; break;
535cdf0e10cSrcweir case SFX_ALIGN_RIGHT: aRect.Left()++; break;
536cdf0e10cSrcweir default:
537cdf0e10cSrcweir break;
538cdf0e10cSrcweir }
539cdf0e10cSrcweir }
540cdf0e10cSrcweir
541cdf0e10cSrcweir DecorationView aView(this);
542a1f1a12aSmseidel aRect.Left() += 6; aRect.Top() += 6;
543a1f1a12aSmseidel aRect.Right()-= 6; aRect.Bottom()-= 6;
544a1f1a12aSmseidel aRect = aView.DrawFrame( aRect, FRAME_DRAW_IN );
545cdf0e10cSrcweir
546cdf0e10cSrcweir aEdit.SetPosSizePixel(aRect.TopLeft(), aRect.GetSize());
547cdf0e10cSrcweir SfxDockingWindow::Resize();
548cdf0e10cSrcweir Invalidate();
549cdf0e10cSrcweir }
550cdf0e10cSrcweir
551cdf0e10cSrcweir
Paint(const Rectangle &)552cdf0e10cSrcweir void SmCmdBoxWindow::Paint(const Rectangle& /*rRect*/)
553cdf0e10cSrcweir {
554cdf0e10cSrcweir Rectangle aRect = Rectangle(Point(0, 0), GetOutputSizePixel());
555cdf0e10cSrcweir DecorationView aView(this);
556cdf0e10cSrcweir
557cdf0e10cSrcweir if (! IsFloatingMode())
558cdf0e10cSrcweir {
559cdf0e10cSrcweir Point aFrom, aTo;
560cdf0e10cSrcweir switch (GetAlignment())
561cdf0e10cSrcweir {
562cdf0e10cSrcweir case SFX_ALIGN_TOP:
563cdf0e10cSrcweir aFrom = aRect.BottomLeft(); aTo = aRect.BottomRight();
564cdf0e10cSrcweir aRect.Bottom()--;
565cdf0e10cSrcweir break;
566cdf0e10cSrcweir
567cdf0e10cSrcweir case SFX_ALIGN_BOTTOM:
568cdf0e10cSrcweir aFrom = aRect.TopLeft(); aTo = aRect.TopRight();
569cdf0e10cSrcweir aRect.Top()++;
570cdf0e10cSrcweir break;
571cdf0e10cSrcweir
572cdf0e10cSrcweir case SFX_ALIGN_LEFT:
573cdf0e10cSrcweir aFrom = aRect.TopRight(); aTo = aRect.BottomRight();
574cdf0e10cSrcweir aRect.Right()--;
575cdf0e10cSrcweir break;
576cdf0e10cSrcweir
577cdf0e10cSrcweir case SFX_ALIGN_RIGHT:
578cdf0e10cSrcweir aFrom = aRect.TopLeft(); aTo = aRect.BottomLeft();
579cdf0e10cSrcweir aRect.Left()++;
580cdf0e10cSrcweir break;
581cdf0e10cSrcweir
582cdf0e10cSrcweir default:
583cdf0e10cSrcweir break;
584cdf0e10cSrcweir }
585cdf0e10cSrcweir DrawLine( aFrom, aTo );
586cdf0e10cSrcweir aView.DrawFrame(aRect, FRAME_DRAW_OUT);
587cdf0e10cSrcweir }
588a1f1a12aSmseidel aRect.Left() += 6; aRect.Top() += 6;
589a1f1a12aSmseidel aRect.Right()-= 6; aRect.Bottom()-= 6;
590a1f1a12aSmseidel aRect = aView.DrawFrame( aRect, FRAME_DRAW_IN );
591cdf0e10cSrcweir }
592cdf0e10cSrcweir
593cdf0e10cSrcweir
CalcDockingSize(SfxChildAlignment eAlign)594cdf0e10cSrcweir Size SmCmdBoxWindow::CalcDockingSize(SfxChildAlignment eAlign)
595cdf0e10cSrcweir {
596cdf0e10cSrcweir switch (eAlign)
597cdf0e10cSrcweir {
598cdf0e10cSrcweir case SFX_ALIGN_LEFT:
599cdf0e10cSrcweir case SFX_ALIGN_RIGHT:
600cdf0e10cSrcweir return Size();
601cdf0e10cSrcweir default:
602cdf0e10cSrcweir break;
603cdf0e10cSrcweir }
604cdf0e10cSrcweir return SfxDockingWindow::CalcDockingSize(eAlign);
605cdf0e10cSrcweir }
606cdf0e10cSrcweir
607cdf0e10cSrcweir
CheckAlignment(SfxChildAlignment eActual,SfxChildAlignment eWish)608cdf0e10cSrcweir SfxChildAlignment SmCmdBoxWindow::CheckAlignment(SfxChildAlignment eActual,
609cdf0e10cSrcweir SfxChildAlignment eWish)
610cdf0e10cSrcweir {
611cdf0e10cSrcweir switch (eWish)
612cdf0e10cSrcweir {
613cdf0e10cSrcweir case SFX_ALIGN_TOP:
614cdf0e10cSrcweir case SFX_ALIGN_BOTTOM:
615cdf0e10cSrcweir case SFX_ALIGN_NOALIGNMENT:
616cdf0e10cSrcweir return eWish;
617cdf0e10cSrcweir default:
618cdf0e10cSrcweir break;
619cdf0e10cSrcweir }
620cdf0e10cSrcweir
621cdf0e10cSrcweir return eActual;
622cdf0e10cSrcweir }
623cdf0e10cSrcweir
624cdf0e10cSrcweir
StateChanged(StateChangedType nStateChange)625cdf0e10cSrcweir void SmCmdBoxWindow::StateChanged( StateChangedType nStateChange )
626cdf0e10cSrcweir {
627cdf0e10cSrcweir if (STATE_CHANGE_INITSHOW == nStateChange)
628cdf0e10cSrcweir {
629cdf0e10cSrcweir Resize(); // #98848# avoid SmEditWindow not being painted correctly
630cdf0e10cSrcweir
631cdf0e10cSrcweir // set initial position of window in floating mode
632cdf0e10cSrcweir if (sal_True == IsFloatingMode())
633cdf0e10cSrcweir AdjustPosition(); //! don't change pos in docking-mode !
634cdf0e10cSrcweir
635cdf0e10cSrcweir // // make sure the formula can be edited right away
636cdf0e10cSrcweir // aEdit.GrabFocus();
637cdf0e10cSrcweir
638cdf0e10cSrcweir // grab focus as above does not work...
639cdf0e10cSrcweir // Thus we implement a timer based solution to get the inital
640cdf0e10cSrcweir // focus in the Edit window.
641cdf0e10cSrcweir aInitialFocusTimer.Start();
642cdf0e10cSrcweir }
643cdf0e10cSrcweir
644cdf0e10cSrcweir SfxDockingWindow::StateChanged( nStateChange );
645cdf0e10cSrcweir }
646cdf0e10cSrcweir
647cdf0e10cSrcweir
IMPL_LINK(SmCmdBoxWindow,InitialFocusTimerHdl,Timer *,EMPTYARG)648cdf0e10cSrcweir IMPL_LINK( SmCmdBoxWindow, InitialFocusTimerHdl, Timer *, EMPTYARG /*pTimer*/ )
649cdf0e10cSrcweir {
650cdf0e10cSrcweir // We want to have the focus in the edit window once Math has been opened
651cdf0e10cSrcweir // to allow for immediate typing.
652cdf0e10cSrcweir // Problem: There is no proper way to do this
653a1f1a12aSmseidel // Thus: this timer based solution has been implemented (see GrabFocus below)
654cdf0e10cSrcweir //
655a1f1a12aSmseidel // Follow-up problem (#i114910): grabbing the focus may bust the help system since
656cdf0e10cSrcweir // it relies on getting the current frame which conflicts with grabbing the focus.
657cdf0e10cSrcweir // Thus aside from the 'GrabFocus' call everything else is to get the
658cdf0e10cSrcweir // help reliably working despite using 'GrabFocus'.
659cdf0e10cSrcweir
660cdf0e10cSrcweir try
661cdf0e10cSrcweir {
662cdf0e10cSrcweir uno::Reference< frame::XDesktop > xDesktop;
663cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xSMGR( comphelper::getProcessServiceFactory() );
664cdf0e10cSrcweir if (xSMGR.is())
665cdf0e10cSrcweir {
666cdf0e10cSrcweir xDesktop = uno::Reference< frame::XDesktop >(
667cdf0e10cSrcweir xSMGR->createInstance( rtl::OUString::createFromAscii( "com.sun.star.frame.Desktop" )), uno::UNO_QUERY_THROW );
668cdf0e10cSrcweir }
669cdf0e10cSrcweir
670cdf0e10cSrcweir aEdit.GrabFocus();
671cdf0e10cSrcweir
672cdf0e10cSrcweir if (xDesktop.is())
673cdf0e10cSrcweir {
674cdf0e10cSrcweir bool bInPlace = GetView()->GetViewFrame()->GetFrame().IsInPlace();
675cdf0e10cSrcweir uno::Reference< frame::XFrame > xFrame( GetBindings().GetDispatcher()->GetFrame()->GetFrame().GetFrameInterface());
676cdf0e10cSrcweir if ( bInPlace )
677cdf0e10cSrcweir {
678cdf0e10cSrcweir uno::Reference< container::XChild > xModel( GetView()->GetDoc()->GetModel(), uno::UNO_QUERY_THROW );
679cdf0e10cSrcweir uno::Reference< frame::XModel > xParent( xModel->getParent(), uno::UNO_QUERY_THROW );
680cdf0e10cSrcweir uno::Reference< frame::XController > xParentCtrler( xParent->getCurrentController() );
681cdf0e10cSrcweir uno::Reference< frame::XFramesSupplier > xParentFrame( xParentCtrler->getFrame(), uno::UNO_QUERY_THROW );
682cdf0e10cSrcweir xParentFrame->setActiveFrame( xFrame );
683cdf0e10cSrcweir }
684cdf0e10cSrcweir else
685cdf0e10cSrcweir {
686cdf0e10cSrcweir uno::Reference< frame::XFramesSupplier > xFramesSupplier( xDesktop, uno::UNO_QUERY );
687cdf0e10cSrcweir xFramesSupplier->setActiveFrame( xFrame );
688cdf0e10cSrcweir }
689cdf0e10cSrcweir }
690cdf0e10cSrcweir }
691cdf0e10cSrcweir catch (uno::Exception &)
692cdf0e10cSrcweir {
693cdf0e10cSrcweir DBG_ASSERT( 0, "failed to properly set initial focus to edit window" );
694cdf0e10cSrcweir }
695cdf0e10cSrcweir return 0;
696cdf0e10cSrcweir }
697cdf0e10cSrcweir
698cdf0e10cSrcweir
AdjustPosition()699cdf0e10cSrcweir void SmCmdBoxWindow::AdjustPosition()
700cdf0e10cSrcweir {
701cdf0e10cSrcweir Point aPt;
702cdf0e10cSrcweir const Rectangle aRect( aPt, GetParent()->GetOutputSizePixel() );
703cdf0e10cSrcweir Point aTopLeft( Point( aRect.Left(),
704cdf0e10cSrcweir aRect.Bottom() - GetSizePixel().Height() ) );
705cdf0e10cSrcweir Point aPos( GetParent()->OutputToScreenPixel( aTopLeft ) );
706cdf0e10cSrcweir if (aPos.X() < 0)
707cdf0e10cSrcweir aPos.X() = 0;
708cdf0e10cSrcweir if (aPos.Y() < 0)
709cdf0e10cSrcweir aPos.Y() = 0;
710cdf0e10cSrcweir SetPosPixel( aPos );
711cdf0e10cSrcweir }
712cdf0e10cSrcweir
713cdf0e10cSrcweir
ToggleFloatingMode()714cdf0e10cSrcweir void SmCmdBoxWindow::ToggleFloatingMode()
715cdf0e10cSrcweir {
716cdf0e10cSrcweir SfxDockingWindow::ToggleFloatingMode();
717cdf0e10cSrcweir
718cdf0e10cSrcweir if (GetFloatingWindow())
719cdf0e10cSrcweir GetFloatingWindow()->SetMinOutputSizePixel(Size (200, 50));
720cdf0e10cSrcweir }
721cdf0e10cSrcweir
722cdf0e10cSrcweir
GetFocus()723cdf0e10cSrcweir void SmCmdBoxWindow::GetFocus()
724cdf0e10cSrcweir {
725cdf0e10cSrcweir if (!bExiting)
726cdf0e10cSrcweir aEdit.GrabFocus();
727cdf0e10cSrcweir }
728cdf0e10cSrcweir
729cdf0e10cSrcweir /**************************************************************************/
730cdf0e10cSrcweir
731cdf0e10cSrcweir
732cdf0e10cSrcweir SFX_IMPL_DOCKINGWINDOW(SmCmdBoxWrapper, SID_CMDBOXWINDOW);
733cdf0e10cSrcweir
SmCmdBoxWrapper(Window * pParentWindow,sal_uInt16 nId,SfxBindings * pBindings,SfxChildWinInfo * pInfo)734cdf0e10cSrcweir SmCmdBoxWrapper::SmCmdBoxWrapper(Window *pParentWindow, sal_uInt16 nId,
735cdf0e10cSrcweir SfxBindings *pBindings,
736cdf0e10cSrcweir SfxChildWinInfo *pInfo) :
737cdf0e10cSrcweir SfxChildWindow(pParentWindow, nId)
738cdf0e10cSrcweir {
739cdf0e10cSrcweir pWindow = new SmCmdBoxWindow(pBindings, this, pParentWindow);
740cdf0e10cSrcweir
741cdf0e10cSrcweir // make window docked to the bottom initially (after first start)
742cdf0e10cSrcweir eChildAlignment = SFX_ALIGN_BOTTOM;
743cdf0e10cSrcweir ((SfxDockingWindow *)pWindow)->Initialize(pInfo);
744cdf0e10cSrcweir }
745cdf0e10cSrcweir
746cdf0e10cSrcweir
747cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
~SmCmdBoxWrapper()748cdf0e10cSrcweir SmCmdBoxWrapper::~SmCmdBoxWrapper()
749cdf0e10cSrcweir {
750cdf0e10cSrcweir }
751cdf0e10cSrcweir #endif
752cdf0e10cSrcweir
753cdf0e10cSrcweir
754cdf0e10cSrcweir /**************************************************************************/
755cdf0e10cSrcweir
756cdf0e10cSrcweir struct SmViewShell_Impl
757cdf0e10cSrcweir {
758cdf0e10cSrcweir sfx2::DocumentInserter* pDocInserter;
759cdf0e10cSrcweir SfxRequest* pRequest;
760cdf0e10cSrcweir
SmViewShell_ImplSmViewShell_Impl761cdf0e10cSrcweir SmViewShell_Impl() :
762cdf0e10cSrcweir pDocInserter( NULL )
763cdf0e10cSrcweir , pRequest( NULL )
764cdf0e10cSrcweir {}
765cdf0e10cSrcweir
~SmViewShell_ImplSmViewShell_Impl766cdf0e10cSrcweir ~SmViewShell_Impl()
767cdf0e10cSrcweir {
768cdf0e10cSrcweir delete pDocInserter;
769cdf0e10cSrcweir delete pRequest;
770cdf0e10cSrcweir }
771cdf0e10cSrcweir };
772cdf0e10cSrcweir
773cdf0e10cSrcweir TYPEINIT1( SmViewShell, SfxViewShell );
774cdf0e10cSrcweir
775cdf0e10cSrcweir SFX_IMPL_INTERFACE(SmViewShell, SfxViewShell, SmResId(0))
776cdf0e10cSrcweir {
777cdf0e10cSrcweir SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_TOOLS | SFX_VISIBILITY_STANDARD |
778cdf0e10cSrcweir SFX_VISIBILITY_FULLSCREEN | SFX_VISIBILITY_SERVER,
779cdf0e10cSrcweir SmResId(RID_MATH_TOOLBOX ));
780cdf0e10cSrcweir
781cdf0e10cSrcweir SFX_CHILDWINDOW_REGISTRATION(SmToolBoxWrapper::GetChildWindowId());
782cdf0e10cSrcweir SFX_CHILDWINDOW_REGISTRATION(SmCmdBoxWrapper::GetChildWindowId());
783cdf0e10cSrcweir }
784cdf0e10cSrcweir
785cdf0e10cSrcweir
786cdf0e10cSrcweir SFX_IMPL_NAMED_VIEWFACTORY(SmViewShell, "Default")
787cdf0e10cSrcweir {
788cdf0e10cSrcweir SFX_VIEW_REGISTRATION(SmDocShell);
789cdf0e10cSrcweir }
790cdf0e10cSrcweir
791cdf0e10cSrcweir
GetOptimalSizePixel() const792cdf0e10cSrcweir Size SmViewShell::GetOptimalSizePixel() const
793cdf0e10cSrcweir {
794cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::GetOptimalSizePixel" );
795cdf0e10cSrcweir
796cdf0e10cSrcweir return aGraphic.LogicToPixel( ((SmViewShell*)this)->GetDoc()->GetSize() );
797cdf0e10cSrcweir }
798cdf0e10cSrcweir
799cdf0e10cSrcweir
AdjustPosSizePixel(const Point & rPos,const Size & rSize)800cdf0e10cSrcweir void SmViewShell::AdjustPosSizePixel(const Point &rPos, const Size &rSize)
801cdf0e10cSrcweir {
802cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::AdjustPosSizePixel" );
803cdf0e10cSrcweir
804cdf0e10cSrcweir aGraphic.SetPosSizePixel(rPos, rSize);
805cdf0e10cSrcweir }
806cdf0e10cSrcweir
807cdf0e10cSrcweir
InnerResizePixel(const Point & rOfs,const Size & rSize)808cdf0e10cSrcweir void SmViewShell::InnerResizePixel(const Point &rOfs, const Size &rSize)
809cdf0e10cSrcweir {
810cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::InnerResizePixel" );
811cdf0e10cSrcweir
812cdf0e10cSrcweir Size aObjSize = GetObjectShell()->GetVisArea().GetSize();
813cdf0e10cSrcweir if ( aObjSize.Width() > 0 && aObjSize.Height() > 0 )
814cdf0e10cSrcweir {
815cdf0e10cSrcweir Size aProvidedSize = GetWindow()->PixelToLogic( rSize, MAP_100TH_MM );
816cdf0e10cSrcweir SfxViewShell::SetZoomFactor( Fraction( aProvidedSize.Width(), aObjSize.Width() ),
817cdf0e10cSrcweir Fraction( aProvidedSize.Height(), aObjSize.Height() ) );
818cdf0e10cSrcweir }
819cdf0e10cSrcweir
820cdf0e10cSrcweir SetBorderPixel( SvBorder() );
821cdf0e10cSrcweir GetGraphicWindow().SetPosSizePixel(rOfs, rSize);
822cdf0e10cSrcweir GetGraphicWindow().SetTotalSize();
823cdf0e10cSrcweir }
824cdf0e10cSrcweir
825cdf0e10cSrcweir
OuterResizePixel(const Point & rOfs,const Size & rSize)826cdf0e10cSrcweir void SmViewShell::OuterResizePixel(const Point &rOfs, const Size &rSize)
827cdf0e10cSrcweir {
828cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::OuterResizePixel" );
829cdf0e10cSrcweir
830cdf0e10cSrcweir SmGraphicWindow &rWin = GetGraphicWindow();
831cdf0e10cSrcweir rWin.SetPosSizePixel(rOfs, rSize);
832cdf0e10cSrcweir if (GetDoc()->IsPreview())
833cdf0e10cSrcweir rWin.ZoomToFitInWindow();
834cdf0e10cSrcweir rWin.Update();
835cdf0e10cSrcweir }
836cdf0e10cSrcweir
837cdf0e10cSrcweir
QueryObjAreaPixel(Rectangle & rRect) const838cdf0e10cSrcweir void SmViewShell::QueryObjAreaPixel( Rectangle& rRect ) const
839cdf0e10cSrcweir {
840cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::QueryObjAreaPixel" );
841cdf0e10cSrcweir
842cdf0e10cSrcweir rRect.SetSize( GetGraphicWindow().GetSizePixel() );
843cdf0e10cSrcweir }
844cdf0e10cSrcweir
845cdf0e10cSrcweir
SetZoomFactor(const Fraction & rX,const Fraction & rY)846cdf0e10cSrcweir void SmViewShell::SetZoomFactor( const Fraction &rX, const Fraction &rY )
847cdf0e10cSrcweir {
848cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::SetZoomFactor" );
849cdf0e10cSrcweir
850cdf0e10cSrcweir const Fraction &rFrac = rX < rY ? rX : rY;
851cdf0e10cSrcweir GetGraphicWindow().SetZoom( (sal_uInt16) long(rFrac * Fraction( 100, 1 )) );
852cdf0e10cSrcweir
853cdf0e10cSrcweir //Um Rundungsfehler zu minimieren lassen wir von der Basisklasse ggf.
854cdf0e10cSrcweir //auch die krummen Werte einstellen
855cdf0e10cSrcweir SfxViewShell::SetZoomFactor( rX, rY );
856cdf0e10cSrcweir }
857cdf0e10cSrcweir
858cdf0e10cSrcweir
GetTextLineSize(OutputDevice & rDevice,const String & rLine)859cdf0e10cSrcweir Size SmViewShell::GetTextLineSize(OutputDevice& rDevice, const String& rLine)
860cdf0e10cSrcweir {
861cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::GetTextLineSize" );
862cdf0e10cSrcweir
863cdf0e10cSrcweir String aText;
864cdf0e10cSrcweir Size aSize(rDevice.GetTextWidth(rLine), rDevice.GetTextHeight());
865cdf0e10cSrcweir sal_uInt16 nTabs = rLine.GetTokenCount('\t');
866cdf0e10cSrcweir
867cdf0e10cSrcweir if (nTabs > 0)
868cdf0e10cSrcweir {
869cdf0e10cSrcweir long TabPos = rDevice.GetTextWidth('n') * 8;
870cdf0e10cSrcweir
871cdf0e10cSrcweir aSize.Width() = 0;
872cdf0e10cSrcweir
873cdf0e10cSrcweir for (sal_uInt16 i = 0; i < nTabs; i++)
874cdf0e10cSrcweir {
875cdf0e10cSrcweir if (i > 0)
876cdf0e10cSrcweir aSize.Width() = ((aSize.Width() / TabPos) + 1) * TabPos;
877cdf0e10cSrcweir
878cdf0e10cSrcweir aText = rLine.GetToken(i, '\t');
879cdf0e10cSrcweir aText.EraseLeadingChars('\t');
880cdf0e10cSrcweir aText.EraseTrailingChars('\t');
881cdf0e10cSrcweir aSize.Width() += rDevice.GetTextWidth(aText);
882cdf0e10cSrcweir }
883cdf0e10cSrcweir }
884cdf0e10cSrcweir
885cdf0e10cSrcweir return aSize;
886cdf0e10cSrcweir }
887cdf0e10cSrcweir
888cdf0e10cSrcweir
GetTextSize(OutputDevice & rDevice,const String & rText,long MaxWidth)889cdf0e10cSrcweir Size SmViewShell::GetTextSize(OutputDevice& rDevice, const String& rText, long MaxWidth)
890cdf0e10cSrcweir {
891cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::GetTextSize" );
892cdf0e10cSrcweir
893cdf0e10cSrcweir Size aSize;
894cdf0e10cSrcweir String aLine;
895cdf0e10cSrcweir Size TextSize;
896cdf0e10cSrcweir String aText;
897cdf0e10cSrcweir sal_uInt16 nLines = rText.GetTokenCount('\n');
898cdf0e10cSrcweir
899cdf0e10cSrcweir for (sal_uInt16 i = 0; i < nLines; i++)
900cdf0e10cSrcweir {
901cdf0e10cSrcweir aLine = rText.GetToken(i, '\n');
902cdf0e10cSrcweir aLine.EraseAllChars('\r');
903cdf0e10cSrcweir aLine.EraseLeadingChars('\n');
904cdf0e10cSrcweir aLine.EraseTrailingChars('\n');
905cdf0e10cSrcweir
906cdf0e10cSrcweir aSize = GetTextLineSize(rDevice, aLine);
907cdf0e10cSrcweir
908cdf0e10cSrcweir if (aSize.Width() > MaxWidth)
909cdf0e10cSrcweir {
910cdf0e10cSrcweir do
911cdf0e10cSrcweir {
912cdf0e10cSrcweir xub_StrLen m = aLine.Len();
913cdf0e10cSrcweir xub_StrLen nLen = m;
914cdf0e10cSrcweir
915cdf0e10cSrcweir for (xub_StrLen n = 0; n < nLen; n++)
916cdf0e10cSrcweir {
917cdf0e10cSrcweir sal_Unicode cLineChar = aLine.GetChar(n);
918cdf0e10cSrcweir if ((cLineChar == ' ') || (cLineChar == '\t'))
919cdf0e10cSrcweir {
920cdf0e10cSrcweir aText = aLine.Copy(0, n);
921cdf0e10cSrcweir if (GetTextLineSize(rDevice, aText).Width() < MaxWidth)
922cdf0e10cSrcweir m = n;
923cdf0e10cSrcweir else
924cdf0e10cSrcweir break;
925cdf0e10cSrcweir }
926cdf0e10cSrcweir }
927cdf0e10cSrcweir
928cdf0e10cSrcweir aText = aLine.Copy(0, m);
929cdf0e10cSrcweir aLine.Erase(0, m);
930cdf0e10cSrcweir aSize = GetTextLineSize(rDevice, aText);
931cdf0e10cSrcweir TextSize.Height() += aSize.Height();
932cdf0e10cSrcweir TextSize.Width() = Max(TextSize.Width(), Min(aSize.Width(), MaxWidth));
933cdf0e10cSrcweir
934cdf0e10cSrcweir aLine.EraseLeadingChars(' ');
935cdf0e10cSrcweir aLine.EraseLeadingChars('\t');
936cdf0e10cSrcweir aLine.EraseLeadingChars(' ');
937cdf0e10cSrcweir }
938cdf0e10cSrcweir while (aLine.Len() > 0);
939cdf0e10cSrcweir }
940cdf0e10cSrcweir else
941cdf0e10cSrcweir {
942cdf0e10cSrcweir TextSize.Height() += aSize.Height();
943cdf0e10cSrcweir TextSize.Width() = Max(TextSize.Width(), aSize.Width());
944cdf0e10cSrcweir }
945cdf0e10cSrcweir }
946cdf0e10cSrcweir
947cdf0e10cSrcweir return TextSize;
948cdf0e10cSrcweir }
949cdf0e10cSrcweir
950cdf0e10cSrcweir
DrawTextLine(OutputDevice & rDevice,const Point & rPosition,const String & rLine)951cdf0e10cSrcweir void SmViewShell::DrawTextLine(OutputDevice& rDevice, const Point& rPosition, const String& rLine)
952cdf0e10cSrcweir {
953cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::DrawTextLine" );
954cdf0e10cSrcweir
955cdf0e10cSrcweir String aText;
956cdf0e10cSrcweir Point aPoint (rPosition);
957cdf0e10cSrcweir sal_uInt16 nTabs = rLine.GetTokenCount('\t');
958cdf0e10cSrcweir
959cdf0e10cSrcweir if (nTabs > 0)
960cdf0e10cSrcweir {
961cdf0e10cSrcweir long TabPos = rDevice.GetTextWidth('n') * 8;
962cdf0e10cSrcweir
963cdf0e10cSrcweir for (sal_uInt16 i = 0; i < nTabs; i++)
964cdf0e10cSrcweir {
965cdf0e10cSrcweir if (i > 0)
966cdf0e10cSrcweir aPoint.X() = ((aPoint.X() / TabPos) + 1) * TabPos;
967cdf0e10cSrcweir
968cdf0e10cSrcweir aText = rLine.GetToken(i, '\t');
969cdf0e10cSrcweir aText.EraseLeadingChars('\t');
970cdf0e10cSrcweir aText.EraseTrailingChars('\t');
971cdf0e10cSrcweir rDevice.DrawText(aPoint, aText);
972cdf0e10cSrcweir aPoint.X() += rDevice.GetTextWidth(aText);
973cdf0e10cSrcweir }
974cdf0e10cSrcweir }
975cdf0e10cSrcweir else
976cdf0e10cSrcweir rDevice.DrawText(aPoint, rLine);
977cdf0e10cSrcweir }
978cdf0e10cSrcweir
979cdf0e10cSrcweir
DrawText(OutputDevice & rDevice,const Point & rPosition,const String & rText,sal_uInt16 MaxWidth)980cdf0e10cSrcweir void SmViewShell::DrawText(OutputDevice& rDevice, const Point& rPosition, const String& rText, sal_uInt16 MaxWidth)
981cdf0e10cSrcweir {
982cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::DrawText" );
983cdf0e10cSrcweir
984cdf0e10cSrcweir sal_uInt16 nLines = rText.GetTokenCount('\n');
985cdf0e10cSrcweir Point aPoint (rPosition);
986cdf0e10cSrcweir Size aSize;
987cdf0e10cSrcweir String aLine;
988cdf0e10cSrcweir String aText;
989cdf0e10cSrcweir
990cdf0e10cSrcweir for (sal_uInt16 i = 0; i < nLines; i++)
991cdf0e10cSrcweir {
992cdf0e10cSrcweir aLine = rText.GetToken(i, '\n');
993cdf0e10cSrcweir aLine.EraseAllChars('\r');
994cdf0e10cSrcweir aLine.EraseLeadingChars('\n');
995cdf0e10cSrcweir aLine.EraseTrailingChars('\n');
996cdf0e10cSrcweir aSize = GetTextLineSize(rDevice, aLine);
997cdf0e10cSrcweir if (aSize.Width() > MaxWidth)
998cdf0e10cSrcweir {
999cdf0e10cSrcweir do
1000cdf0e10cSrcweir {
1001cdf0e10cSrcweir xub_StrLen m = aLine.Len();
1002cdf0e10cSrcweir xub_StrLen nLen = m;
1003cdf0e10cSrcweir
1004cdf0e10cSrcweir for (xub_StrLen n = 0; n < nLen; n++)
1005cdf0e10cSrcweir {
1006cdf0e10cSrcweir sal_Unicode cLineChar = aLine.GetChar(n);
1007cdf0e10cSrcweir if ((cLineChar == ' ') || (cLineChar == '\t'))
1008cdf0e10cSrcweir {
1009cdf0e10cSrcweir aText = aLine.Copy(0, n);
1010cdf0e10cSrcweir if (GetTextLineSize(rDevice, aText).Width() < MaxWidth)
1011cdf0e10cSrcweir m = n;
1012cdf0e10cSrcweir else
1013cdf0e10cSrcweir break;
1014cdf0e10cSrcweir }
1015cdf0e10cSrcweir }
1016cdf0e10cSrcweir aText = aLine.Copy(0, m);
1017cdf0e10cSrcweir aLine.Erase(0, m);
1018cdf0e10cSrcweir
1019cdf0e10cSrcweir DrawTextLine(rDevice, aPoint, aText);
1020cdf0e10cSrcweir aPoint.Y() += aSize.Height();
1021cdf0e10cSrcweir
1022cdf0e10cSrcweir aLine.EraseLeadingChars(' ');
1023cdf0e10cSrcweir aLine.EraseLeadingChars('\t');
1024cdf0e10cSrcweir aLine.EraseLeadingChars(' ');
1025cdf0e10cSrcweir }
1026cdf0e10cSrcweir while (GetTextLineSize(rDevice, aLine).Width() > MaxWidth);
1027cdf0e10cSrcweir
1028cdf0e10cSrcweir // print the remaining text
1029cdf0e10cSrcweir if (aLine.Len() > 0)
1030cdf0e10cSrcweir {
1031cdf0e10cSrcweir DrawTextLine(rDevice, aPoint, aLine);
1032cdf0e10cSrcweir aPoint.Y() += aSize.Height();
1033cdf0e10cSrcweir }
1034cdf0e10cSrcweir }
1035cdf0e10cSrcweir else
1036cdf0e10cSrcweir {
1037cdf0e10cSrcweir DrawTextLine(rDevice, aPoint, aLine);
1038cdf0e10cSrcweir aPoint.Y() += aSize.Height();
1039cdf0e10cSrcweir }
1040cdf0e10cSrcweir }
1041cdf0e10cSrcweir }
1042cdf0e10cSrcweir
Impl_Print(OutputDevice & rOutDev,const SmPrintUIOptions & rPrintUIOptions,Rectangle aOutRect,Point aZeroPoint)1043cdf0e10cSrcweir void SmViewShell::Impl_Print(
1044cdf0e10cSrcweir OutputDevice &rOutDev,
1045cdf0e10cSrcweir const SmPrintUIOptions &rPrintUIOptions,
1046cdf0e10cSrcweir Rectangle aOutRect, Point aZeroPoint )
1047cdf0e10cSrcweir {
1048cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::Impl_Print" );
1049cdf0e10cSrcweir
1050cdf0e10cSrcweir const bool bIsPrintTitle = rPrintUIOptions.getBoolValue( PRTUIOPT_TITLE_ROW, sal_True );
1051cdf0e10cSrcweir const bool bIsPrintFrame = rPrintUIOptions.getBoolValue( PRTUIOPT_BORDER, sal_True );
1052cdf0e10cSrcweir const bool bIsPrintFormulaText = rPrintUIOptions.getBoolValue( PRTUIOPT_FORMULA_TEXT, sal_True );
1053cdf0e10cSrcweir SmPrintSize ePrintSize( static_cast< SmPrintSize >( rPrintUIOptions.getIntValue( PRTUIOPT_PRINT_FORMAT, PRINT_SIZE_NORMAL ) ));
1054cdf0e10cSrcweir const sal_uInt16 nZoomFactor = static_cast< sal_uInt16 >(rPrintUIOptions.getIntValue( PRTUIOPT_PRINT_SCALE, 100 ));
1055cdf0e10cSrcweir // IsIgnoreSpacesRight is a parser option! Thus it does not get evaluated here anymore (too late).
1056cdf0e10cSrcweir // const bool bNoRightSpaces = rPrintUIOptions.getBoolValue( PRTUIOPT_NO_RIGHT_SPACE, sal_True );
1057cdf0e10cSrcweir
1058cdf0e10cSrcweir rOutDev.Push();
1059cdf0e10cSrcweir rOutDev.SetLineColor( Color(COL_BLACK) );
1060cdf0e10cSrcweir
1061cdf0e10cSrcweir // output text on top
1062cdf0e10cSrcweir if (bIsPrintTitle)
1063cdf0e10cSrcweir {
1064cdf0e10cSrcweir Size aSize600 (0, 600);
1065cdf0e10cSrcweir Size aSize650 (0, 650);
1066cdf0e10cSrcweir Font aFont(FAMILY_DONTKNOW, aSize600);
1067cdf0e10cSrcweir
1068cdf0e10cSrcweir aFont.SetAlign(ALIGN_TOP);
1069cdf0e10cSrcweir aFont.SetWeight(WEIGHT_BOLD);
1070cdf0e10cSrcweir aFont.SetSize(aSize650);
1071cdf0e10cSrcweir aFont.SetColor( Color(COL_BLACK) );
1072cdf0e10cSrcweir rOutDev.SetFont(aFont);
1073cdf0e10cSrcweir
1074cdf0e10cSrcweir Size aTitleSize (GetTextSize(rOutDev, GetDoc()->GetTitle(), aOutRect.GetWidth() - 200));
1075cdf0e10cSrcweir
1076cdf0e10cSrcweir aFont.SetWeight(WEIGHT_NORMAL);
1077cdf0e10cSrcweir aFont.SetSize(aSize600);
1078cdf0e10cSrcweir rOutDev.SetFont(aFont);
1079cdf0e10cSrcweir
1080cdf0e10cSrcweir Size aDescSize (GetTextSize(rOutDev, GetDoc()->GetComment(), aOutRect.GetWidth() - 200));
1081cdf0e10cSrcweir
1082cdf0e10cSrcweir if (bIsPrintFrame)
1083cdf0e10cSrcweir rOutDev.DrawRect(Rectangle(aOutRect.TopLeft(),
1084cdf0e10cSrcweir Size(aOutRect.GetWidth(), 100 + aTitleSize.Height() + 200 + aDescSize.Height() + 100)));
1085cdf0e10cSrcweir aOutRect.Top() += 200;
1086cdf0e10cSrcweir
1087cdf0e10cSrcweir // output title
1088cdf0e10cSrcweir aFont.SetWeight(WEIGHT_BOLD);
1089cdf0e10cSrcweir aFont.SetSize(aSize650);
1090cdf0e10cSrcweir rOutDev.SetFont(aFont);
1091cdf0e10cSrcweir Point aPoint(aOutRect.Left() + (aOutRect.GetWidth() - aTitleSize.Width()) / 2,
1092cdf0e10cSrcweir aOutRect.Top());
1093cdf0e10cSrcweir DrawText(rOutDev, aPoint, GetDoc()->GetTitle(),
1094cdf0e10cSrcweir sal::static_int_cast< sal_uInt16 >(aOutRect.GetWidth() - 200));
1095cdf0e10cSrcweir aOutRect.Top() += aTitleSize.Height() + 200;
1096cdf0e10cSrcweir
1097cdf0e10cSrcweir // output description
1098cdf0e10cSrcweir aFont.SetWeight(WEIGHT_NORMAL);
1099cdf0e10cSrcweir aFont.SetSize(aSize600);
1100cdf0e10cSrcweir rOutDev.SetFont(aFont);
1101cdf0e10cSrcweir aPoint.X() = aOutRect.Left() + (aOutRect.GetWidth() - aDescSize.Width()) / 2;
1102cdf0e10cSrcweir aPoint.Y() = aOutRect.Top();
1103cdf0e10cSrcweir DrawText(rOutDev, aPoint, GetDoc()->GetComment(),
1104cdf0e10cSrcweir sal::static_int_cast< sal_uInt16 >(aOutRect.GetWidth() - 200));
1105cdf0e10cSrcweir aOutRect.Top() += aDescSize.Height() + 300;
1106cdf0e10cSrcweir }
1107cdf0e10cSrcweir
1108cdf0e10cSrcweir // output text on bottom
1109cdf0e10cSrcweir if (bIsPrintFormulaText)
1110cdf0e10cSrcweir {
1111cdf0e10cSrcweir Font aFont(FAMILY_DONTKNOW, Size(0, 600));
1112cdf0e10cSrcweir aFont.SetAlign(ALIGN_TOP);
1113cdf0e10cSrcweir aFont.SetColor( Color(COL_BLACK) );
1114cdf0e10cSrcweir
1115cdf0e10cSrcweir // get size
1116cdf0e10cSrcweir rOutDev.SetFont(aFont);
1117cdf0e10cSrcweir
1118cdf0e10cSrcweir Size aSize (GetTextSize(rOutDev, GetDoc()->GetText(), aOutRect.GetWidth() - 200));
1119cdf0e10cSrcweir
1120cdf0e10cSrcweir aOutRect.Bottom() -= aSize.Height() + 600;
1121cdf0e10cSrcweir
1122cdf0e10cSrcweir if (bIsPrintFrame)
1123cdf0e10cSrcweir rOutDev.DrawRect(Rectangle(aOutRect.BottomLeft(),
1124cdf0e10cSrcweir Size(aOutRect.GetWidth(), 200 + aSize.Height() + 200)));
1125cdf0e10cSrcweir
1126cdf0e10cSrcweir Point aPoint (aOutRect.Left() + (aOutRect.GetWidth() - aSize.Width()) / 2,
1127cdf0e10cSrcweir aOutRect.Bottom() + 300);
1128cdf0e10cSrcweir DrawText(rOutDev, aPoint, GetDoc()->GetText(),
1129cdf0e10cSrcweir sal::static_int_cast< sal_uInt16 >(aOutRect.GetWidth() - 200));
1130cdf0e10cSrcweir aOutRect.Bottom() -= 200;
1131cdf0e10cSrcweir }
1132cdf0e10cSrcweir
1133cdf0e10cSrcweir if (bIsPrintFrame)
1134cdf0e10cSrcweir rOutDev.DrawRect(aOutRect);
1135cdf0e10cSrcweir
1136cdf0e10cSrcweir aOutRect.Top() += 100;
1137cdf0e10cSrcweir aOutRect.Left() += 100;
1138cdf0e10cSrcweir aOutRect.Bottom() -= 100;
1139cdf0e10cSrcweir aOutRect.Right() -= 100;
1140cdf0e10cSrcweir
1141cdf0e10cSrcweir Size aSize (GetDoc()->GetSize());
1142cdf0e10cSrcweir
1143cdf0e10cSrcweir MapMode OutputMapMode;
1144cdf0e10cSrcweir // PDF export should always use PRINT_SIZE_NORMAL ...
1145cdf0e10cSrcweir if (!rPrintUIOptions.getBoolValue( "IsPrinter", sal_False ) )
1146cdf0e10cSrcweir ePrintSize = PRINT_SIZE_NORMAL;
1147cdf0e10cSrcweir switch (ePrintSize)
1148cdf0e10cSrcweir {
1149cdf0e10cSrcweir case PRINT_SIZE_NORMAL:
1150cdf0e10cSrcweir OutputMapMode = MapMode(MAP_100TH_MM);
1151cdf0e10cSrcweir break;
1152cdf0e10cSrcweir
1153cdf0e10cSrcweir case PRINT_SIZE_SCALED:
1154cdf0e10cSrcweir if ((aSize.Width() > 0) && (aSize.Height() > 0))
1155cdf0e10cSrcweir {
1156cdf0e10cSrcweir Size OutputSize (rOutDev.LogicToPixel(Size(aOutRect.GetWidth(),
1157cdf0e10cSrcweir aOutRect.GetHeight()), MapMode(MAP_100TH_MM)));
1158cdf0e10cSrcweir Size GraphicSize (rOutDev.LogicToPixel(aSize, MapMode(MAP_100TH_MM)));
1159cdf0e10cSrcweir sal_uInt16 nZ = (sal_uInt16) Min((long)Fraction(OutputSize.Width() * 100L, GraphicSize.Width()),
1160cdf0e10cSrcweir (long)Fraction(OutputSize.Height() * 100L, GraphicSize.Height()));
1161cdf0e10cSrcweir Fraction aFraction ((sal_uInt16) Max ((sal_uInt16) MINZOOM, Min((sal_uInt16) MAXZOOM, (sal_uInt16) (nZ - 10))), (sal_uInt16) 100);
1162cdf0e10cSrcweir
1163cdf0e10cSrcweir OutputMapMode = MapMode(MAP_100TH_MM, aZeroPoint, aFraction, aFraction);
1164cdf0e10cSrcweir }
1165cdf0e10cSrcweir else
1166cdf0e10cSrcweir OutputMapMode = MapMode(MAP_100TH_MM);
1167cdf0e10cSrcweir break;
1168cdf0e10cSrcweir
1169cdf0e10cSrcweir case PRINT_SIZE_ZOOMED:
1170cdf0e10cSrcweir {
1171cdf0e10cSrcweir Fraction aFraction( nZoomFactor, 100 );
1172cdf0e10cSrcweir
1173cdf0e10cSrcweir OutputMapMode = MapMode(MAP_100TH_MM, aZeroPoint, aFraction, aFraction);
1174cdf0e10cSrcweir break;
1175cdf0e10cSrcweir }
1176cdf0e10cSrcweir }
1177cdf0e10cSrcweir
1178cdf0e10cSrcweir aSize = rOutDev.PixelToLogic(rOutDev.LogicToPixel(aSize, OutputMapMode),
1179cdf0e10cSrcweir MapMode(MAP_100TH_MM));
1180cdf0e10cSrcweir
1181cdf0e10cSrcweir Point aPos (aOutRect.Left() + (aOutRect.GetWidth() - aSize.Width()) / 2,
1182cdf0e10cSrcweir aOutRect.Top() + (aOutRect.GetHeight() - aSize.Height()) / 2);
1183cdf0e10cSrcweir
1184cdf0e10cSrcweir aPos = rOutDev.PixelToLogic(rOutDev.LogicToPixel(aPos, MapMode(MAP_100TH_MM)),
1185cdf0e10cSrcweir OutputMapMode);
1186cdf0e10cSrcweir aOutRect = rOutDev.PixelToLogic(rOutDev.LogicToPixel(aOutRect, MapMode(MAP_100TH_MM)),
1187cdf0e10cSrcweir OutputMapMode);
1188cdf0e10cSrcweir
1189cdf0e10cSrcweir rOutDev.SetMapMode(OutputMapMode);
1190cdf0e10cSrcweir rOutDev.SetClipRegion(Region(aOutRect));
1191cdf0e10cSrcweir GetDoc()->Draw(rOutDev, aPos);
1192cdf0e10cSrcweir rOutDev.SetClipRegion();
1193cdf0e10cSrcweir
1194cdf0e10cSrcweir rOutDev.Pop();
1195cdf0e10cSrcweir }
1196cdf0e10cSrcweir
Print(SfxProgress &,sal_Bool)1197cdf0e10cSrcweir sal_uInt16 SmViewShell::Print(SfxProgress & /*rProgress*/, sal_Bool /*bIsAPI*/)
1198cdf0e10cSrcweir {
1199cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::Print" );
1200cdf0e10cSrcweir DBG_ASSERT( 0, "SmViewShell::Print: no longer used with new UI print dialog. Should be removed!!" );
1201cdf0e10cSrcweir return 0;
1202cdf0e10cSrcweir }
1203cdf0e10cSrcweir
1204cdf0e10cSrcweir
GetPrinter(sal_Bool bCreate)1205cdf0e10cSrcweir SfxPrinter* SmViewShell::GetPrinter(sal_Bool bCreate)
1206cdf0e10cSrcweir {
1207cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::GetPrinter" );
1208cdf0e10cSrcweir
1209cdf0e10cSrcweir SmDocShell *pDoc = GetDoc();
1210cdf0e10cSrcweir if ( pDoc->HasPrinter() || bCreate )
1211cdf0e10cSrcweir return pDoc->GetPrinter();
1212cdf0e10cSrcweir return 0;
1213cdf0e10cSrcweir }
1214cdf0e10cSrcweir
1215cdf0e10cSrcweir
SetPrinter(SfxPrinter * pNewPrinter,sal_uInt16 nDiffFlags,bool)1216cdf0e10cSrcweir sal_uInt16 SmViewShell::SetPrinter(SfxPrinter *pNewPrinter, sal_uInt16 nDiffFlags, bool )
1217cdf0e10cSrcweir {
1218cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::SetPrinter" );
1219cdf0e10cSrcweir SfxPrinter *pOld = GetDoc()->GetPrinter();
1220cdf0e10cSrcweir if ( pOld && pOld->IsPrinting() )
1221cdf0e10cSrcweir return SFX_PRINTERROR_BUSY;
1222cdf0e10cSrcweir
1223cdf0e10cSrcweir if ((nDiffFlags & SFX_PRINTER_PRINTER) == SFX_PRINTER_PRINTER)
1224cdf0e10cSrcweir GetDoc()->SetPrinter( pNewPrinter );
1225cdf0e10cSrcweir
1226cdf0e10cSrcweir if ((nDiffFlags & SFX_PRINTER_OPTIONS) == SFX_PRINTER_OPTIONS)
1227cdf0e10cSrcweir {
1228cdf0e10cSrcweir SmModule *pp = SM_MOD();
1229cdf0e10cSrcweir pp->GetConfig()->ItemSetToConfig(pNewPrinter->GetOptions());
1230cdf0e10cSrcweir }
1231cdf0e10cSrcweir return 0;
1232cdf0e10cSrcweir }
1233cdf0e10cSrcweir
1234cdf0e10cSrcweir
CreatePrintOptionsPage(Window * pParent,const SfxItemSet & rOptions)1235cdf0e10cSrcweir SfxTabPage* SmViewShell::CreatePrintOptionsPage(Window *pParent,
1236cdf0e10cSrcweir const SfxItemSet &rOptions)
1237cdf0e10cSrcweir {
1238cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::CreatePrintOptionsPage" );
1239cdf0e10cSrcweir
1240cdf0e10cSrcweir return SmPrintOptionsTabPage::Create(pParent, rOptions);
1241cdf0e10cSrcweir }
1242cdf0e10cSrcweir
1243cdf0e10cSrcweir
GetEditWindow()1244cdf0e10cSrcweir SmEditWindow *SmViewShell::GetEditWindow()
1245cdf0e10cSrcweir {
1246cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::GetEditWindow" );
1247cdf0e10cSrcweir
1248cdf0e10cSrcweir SmCmdBoxWrapper *pWrapper = (SmCmdBoxWrapper *) GetViewFrame()->
1249cdf0e10cSrcweir GetChildWindow( SmCmdBoxWrapper::GetChildWindowId() );
1250cdf0e10cSrcweir
1251cdf0e10cSrcweir if (pWrapper != NULL)
1252cdf0e10cSrcweir {
1253cdf0e10cSrcweir SmEditWindow *pEditWin = pWrapper->GetEditWindow();
1254cdf0e10cSrcweir DBG_ASSERT( pEditWin, "SmEditWindow missing" );
1255cdf0e10cSrcweir return pEditWin;
1256cdf0e10cSrcweir }
1257cdf0e10cSrcweir
1258cdf0e10cSrcweir return NULL;
1259cdf0e10cSrcweir }
1260cdf0e10cSrcweir
1261cdf0e10cSrcweir
SetStatusText(const String & Text)1262cdf0e10cSrcweir void SmViewShell::SetStatusText(const String& Text)
1263cdf0e10cSrcweir {
1264cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::SetStatusText" );
1265cdf0e10cSrcweir
1266cdf0e10cSrcweir StatusText = Text;
1267cdf0e10cSrcweir GetViewFrame()->GetBindings().Invalidate(SID_TEXTSTATUS);
1268cdf0e10cSrcweir }
1269cdf0e10cSrcweir
1270cdf0e10cSrcweir
ShowError(const SmErrorDesc * pErrorDesc)1271cdf0e10cSrcweir void SmViewShell::ShowError( const SmErrorDesc *pErrorDesc )
1272cdf0e10cSrcweir {
1273cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::ShowError" );
1274cdf0e10cSrcweir
1275cdf0e10cSrcweir DBG_ASSERT(GetDoc(), "Sm : Document missing");
1276cdf0e10cSrcweir if (pErrorDesc || 0 != (pErrorDesc = GetDoc()->GetParser().GetError(0)) )
1277cdf0e10cSrcweir {
1278cdf0e10cSrcweir SetStatusText( pErrorDesc->Text );
1279cdf0e10cSrcweir GetEditWindow()->MarkError( Point( pErrorDesc->pNode->GetColumn(),
1280cdf0e10cSrcweir pErrorDesc->pNode->GetRow()));
1281cdf0e10cSrcweir }
1282cdf0e10cSrcweir }
1283cdf0e10cSrcweir
1284cdf0e10cSrcweir
NextError()1285cdf0e10cSrcweir void SmViewShell::NextError()
1286cdf0e10cSrcweir {
1287cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::NextError" );
1288cdf0e10cSrcweir
1289cdf0e10cSrcweir DBG_ASSERT(GetDoc(), "Sm : Document missing");
1290cdf0e10cSrcweir const SmErrorDesc *pErrorDesc = GetDoc()->GetParser().NextError();
1291cdf0e10cSrcweir
1292cdf0e10cSrcweir if (pErrorDesc)
1293cdf0e10cSrcweir ShowError( pErrorDesc );
1294cdf0e10cSrcweir }
1295cdf0e10cSrcweir
1296cdf0e10cSrcweir
PrevError()1297cdf0e10cSrcweir void SmViewShell::PrevError()
1298cdf0e10cSrcweir {
1299cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::PrevError" );
1300cdf0e10cSrcweir
1301cdf0e10cSrcweir DBG_ASSERT(GetDoc(), "Sm : Document missing");
1302cdf0e10cSrcweir const SmErrorDesc *pErrorDesc = GetDoc()->GetParser().PrevError();
1303cdf0e10cSrcweir
1304cdf0e10cSrcweir if (pErrorDesc)
1305cdf0e10cSrcweir ShowError( pErrorDesc );
1306cdf0e10cSrcweir }
1307cdf0e10cSrcweir
1308cdf0e10cSrcweir
Insert(SfxMedium & rMedium)1309cdf0e10cSrcweir sal_Bool SmViewShell::Insert( SfxMedium& rMedium )
1310cdf0e10cSrcweir {
1311cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::Insert" );
1312cdf0e10cSrcweir
1313cdf0e10cSrcweir SmDocShell *pDoc = GetDoc();
1314cdf0e10cSrcweir String aText( pDoc->GetText() );
1315cdf0e10cSrcweir String aTemp = aText;
1316cdf0e10cSrcweir sal_Bool bRet = sal_False, bChkOldVersion = sal_True;
1317cdf0e10cSrcweir
1318cdf0e10cSrcweir uno::Reference < embed::XStorage > xStorage = rMedium.GetStorage();
1319cdf0e10cSrcweir uno::Reference< container::XNameAccess > xNameAccess( xStorage, uno::UNO_QUERY );
1320cdf0e10cSrcweir if ( xNameAccess.is() && xNameAccess->getElementNames().getLength() )
1321cdf0e10cSrcweir {
1322cdf0e10cSrcweir if ( xNameAccess->hasByName( C2S( "content.xml" ) ) || xNameAccess->hasByName( C2S( "Content.xml" ) ))
1323cdf0e10cSrcweir {
1324cdf0e10cSrcweir bChkOldVersion = sal_False;
1325cdf0e10cSrcweir // is this a fabulous math package ?
1326cdf0e10cSrcweir Reference<com::sun::star::frame::XModel> xModel(pDoc->GetModel());
1327cdf0e10cSrcweir SmXMLImportWrapper aEquation(xModel); //!! modifies the result of pDoc->GetText() !!
1328cdf0e10cSrcweir bRet = 0 == aEquation.Import(rMedium);
1329cdf0e10cSrcweir }
1330cdf0e10cSrcweir }
1331cdf0e10cSrcweir
1332cdf0e10cSrcweir if( bRet )
1333cdf0e10cSrcweir {
1334cdf0e10cSrcweir aText = pDoc->GetText();
1335cdf0e10cSrcweir SmEditWindow *pEditWin = GetEditWindow();
1336cdf0e10cSrcweir if (pEditWin)
1337cdf0e10cSrcweir pEditWin->InsertText( aText );
1338cdf0e10cSrcweir else
1339cdf0e10cSrcweir {
1340cdf0e10cSrcweir DBG_ERROR( "EditWindow missing" );
1341cdf0e10cSrcweir aTemp += aText;
1342cdf0e10cSrcweir aText = aTemp;
1343cdf0e10cSrcweir }
1344cdf0e10cSrcweir
1345cdf0e10cSrcweir pDoc->Parse();
1346cdf0e10cSrcweir pDoc->SetModified(sal_True);
1347cdf0e10cSrcweir
1348cdf0e10cSrcweir SfxBindings &rBnd = GetViewFrame()->GetBindings();
1349cdf0e10cSrcweir rBnd.Invalidate(SID_GAPHIC_SM);
1350cdf0e10cSrcweir rBnd.Invalidate(SID_TEXT);
1351cdf0e10cSrcweir }
1352cdf0e10cSrcweir return bRet;
1353cdf0e10cSrcweir }
1354cdf0e10cSrcweir
1355cdf0e10cSrcweir
InsertFrom(SfxMedium & rMedium)1356cdf0e10cSrcweir sal_Bool SmViewShell::InsertFrom(SfxMedium &rMedium)
1357cdf0e10cSrcweir {
1358cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::InsertFrom" );
1359cdf0e10cSrcweir
1360cdf0e10cSrcweir sal_Bool bSuccess = sal_False;
1361cdf0e10cSrcweir SmDocShell *pDoc = GetDoc();
1362cdf0e10cSrcweir SvStream *pStream = rMedium.GetInStream();
1363cdf0e10cSrcweir String aText( pDoc->GetText() );
1364cdf0e10cSrcweir String aTemp = aText;
1365cdf0e10cSrcweir
1366cdf0e10cSrcweir if (pStream)
1367cdf0e10cSrcweir {
1368cdf0e10cSrcweir const String& rFltName = rMedium.GetFilter()->GetFilterName();
1369cdf0e10cSrcweir if ( rFltName.EqualsAscii(MATHML_XML) )
1370cdf0e10cSrcweir {
1371cdf0e10cSrcweir Reference<com::sun::star::frame::XModel> xModel( pDoc->GetModel() );
1372cdf0e10cSrcweir SmXMLImportWrapper aEquation(xModel); //!! modifies the result of pDoc->GetText() !!
1373cdf0e10cSrcweir bSuccess = 0 == aEquation.Import(rMedium);
1374cdf0e10cSrcweir }
1375cdf0e10cSrcweir else
1376cdf0e10cSrcweir {
1377cdf0e10cSrcweir //bSuccess = ImportSM20File( pStream );
1378cdf0e10cSrcweir }
1379cdf0e10cSrcweir }
1380cdf0e10cSrcweir
1381cdf0e10cSrcweir if( bSuccess )
1382cdf0e10cSrcweir {
1383cdf0e10cSrcweir aText = pDoc->GetText();
1384cdf0e10cSrcweir SmEditWindow *pEditWin = GetEditWindow();
1385cdf0e10cSrcweir if (pEditWin)
1386cdf0e10cSrcweir pEditWin->InsertText( aText );
1387cdf0e10cSrcweir else
1388cdf0e10cSrcweir {
1389cdf0e10cSrcweir DBG_ERROR( "EditWindow missing" );
1390cdf0e10cSrcweir aTemp += aText;
1391cdf0e10cSrcweir aText = aTemp;
1392cdf0e10cSrcweir }
1393cdf0e10cSrcweir
1394cdf0e10cSrcweir pDoc->Parse();
1395cdf0e10cSrcweir pDoc->SetModified(sal_True);
1396cdf0e10cSrcweir
1397cdf0e10cSrcweir SfxBindings &rBnd = GetViewFrame()->GetBindings();
1398cdf0e10cSrcweir rBnd.Invalidate(SID_GAPHIC_SM);
1399cdf0e10cSrcweir rBnd.Invalidate(SID_TEXT);
1400cdf0e10cSrcweir }
1401cdf0e10cSrcweir
1402cdf0e10cSrcweir return bSuccess;
1403cdf0e10cSrcweir }
1404cdf0e10cSrcweir
1405cdf0e10cSrcweir
Execute(SfxRequest & rReq)1406cdf0e10cSrcweir void SmViewShell::Execute(SfxRequest& rReq)
1407cdf0e10cSrcweir {
1408cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::Execute" );
1409cdf0e10cSrcweir
1410cdf0e10cSrcweir SmEditWindow *pWin = GetEditWindow();
1411cdf0e10cSrcweir
1412cdf0e10cSrcweir switch (rReq.GetSlot())
1413cdf0e10cSrcweir {
1414cdf0e10cSrcweir case SID_FORMULACURSOR:
1415cdf0e10cSrcweir {
1416cdf0e10cSrcweir SmModule *pp = SM_MOD();
1417cdf0e10cSrcweir
1418cdf0e10cSrcweir const SfxItemSet *pArgs = rReq.GetArgs();
1419cdf0e10cSrcweir const SfxPoolItem *pItem;
1420cdf0e10cSrcweir
1421cdf0e10cSrcweir sal_Bool bVal;
1422cdf0e10cSrcweir if ( pArgs &&
1423cdf0e10cSrcweir SFX_ITEM_SET == pArgs->GetItemState( SID_FORMULACURSOR, sal_False, &pItem))
1424cdf0e10cSrcweir bVal = ((SfxBoolItem *) pItem)->GetValue();
1425cdf0e10cSrcweir else
1426cdf0e10cSrcweir bVal = !pp->GetConfig()->IsShowFormulaCursor();
1427cdf0e10cSrcweir
1428cdf0e10cSrcweir pp->GetConfig()->SetShowFormulaCursor(bVal);
1429cdf0e10cSrcweir GetGraphicWindow().ShowCursor(bVal);
1430cdf0e10cSrcweir break;
1431cdf0e10cSrcweir }
1432cdf0e10cSrcweir case SID_DRAW:
1433cdf0e10cSrcweir if (pWin)
1434cdf0e10cSrcweir {
1435cdf0e10cSrcweir GetDoc()->SetText( pWin->GetText() );
1436cdf0e10cSrcweir SetStatusText(String());
1437cdf0e10cSrcweir ShowError( 0 );
1438cdf0e10cSrcweir GetDoc()->Repaint();
1439cdf0e10cSrcweir }
1440cdf0e10cSrcweir break;
1441cdf0e10cSrcweir
1442cdf0e10cSrcweir case SID_ADJUST:
1443cdf0e10cSrcweir case SID_FITINWINDOW:
1444cdf0e10cSrcweir aGraphic.ZoomToFitInWindow();
1445cdf0e10cSrcweir break;
1446cdf0e10cSrcweir
1447cdf0e10cSrcweir case SID_VIEW050:
1448cdf0e10cSrcweir aGraphic.SetZoom(50);
1449cdf0e10cSrcweir break;
1450cdf0e10cSrcweir
1451cdf0e10cSrcweir case SID_VIEW100:
1452cdf0e10cSrcweir aGraphic.SetZoom(100);
1453cdf0e10cSrcweir break;
1454cdf0e10cSrcweir
1455cdf0e10cSrcweir case SID_VIEW200:
1456cdf0e10cSrcweir aGraphic.SetZoom(200);
1457cdf0e10cSrcweir break;
1458cdf0e10cSrcweir
1459cdf0e10cSrcweir case SID_ZOOMIN:
1460cdf0e10cSrcweir aGraphic.SetZoom(aGraphic.GetZoom() + 25);
1461cdf0e10cSrcweir break;
1462cdf0e10cSrcweir
1463cdf0e10cSrcweir case SID_ZOOMOUT:
1464cdf0e10cSrcweir DBG_ASSERT(aGraphic.GetZoom() >= 25, "Sm: falsches sal_uInt16 Argument");
1465cdf0e10cSrcweir aGraphic.SetZoom(aGraphic.GetZoom() - 25);
1466cdf0e10cSrcweir break;
1467cdf0e10cSrcweir
1468cdf0e10cSrcweir case SID_COPYOBJECT:
1469cdf0e10cSrcweir {
1470cdf0e10cSrcweir //TODO/LATER: does not work because of UNO Tunneling - will be fixed later
1471cdf0e10cSrcweir Reference< datatransfer::XTransferable > xTrans( GetDoc()->GetModel(), uno::UNO_QUERY );
1472cdf0e10cSrcweir if( xTrans.is() )
1473cdf0e10cSrcweir {
1474cdf0e10cSrcweir Reference< lang::XUnoTunnel> xTnnl( xTrans, uno::UNO_QUERY);
1475cdf0e10cSrcweir if( xTnnl.is() )
1476cdf0e10cSrcweir {
1477cdf0e10cSrcweir TransferableHelper* pTrans = reinterpret_cast< TransferableHelper * >(
1478cdf0e10cSrcweir sal::static_int_cast< sal_uIntPtr >(
1479cdf0e10cSrcweir xTnnl->getSomething( TransferableHelper::getUnoTunnelId() )));
1480cdf0e10cSrcweir if( pTrans )
1481cdf0e10cSrcweir pTrans->CopyToClipboard( this ? GetEditWindow() : 0 );
1482cdf0e10cSrcweir }
1483cdf0e10cSrcweir }
1484cdf0e10cSrcweir }
1485cdf0e10cSrcweir break;
1486cdf0e10cSrcweir
1487cdf0e10cSrcweir case SID_PASTEOBJECT:
1488cdf0e10cSrcweir {
1489cdf0e10cSrcweir TransferableDataHelper aData( TransferableDataHelper::CreateFromSystemClipboard(this ? GetEditWindow(): 0) );
1490cdf0e10cSrcweir uno::Reference < io::XInputStream > xStrm;
1491cdf0e10cSrcweir SotFormatStringId nId;
1492cdf0e10cSrcweir if( aData.GetTransferable().is() &&
1493cdf0e10cSrcweir ( aData.HasFormat( nId = SOT_FORMATSTR_ID_EMBEDDED_OBJ ) ||
1494cdf0e10cSrcweir (aData.HasFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ) &&
1495cdf0e10cSrcweir aData.HasFormat( nId = SOT_FORMATSTR_ID_EMBED_SOURCE ))) &&
1496cdf0e10cSrcweir aData.GetInputStream( nId, xStrm ) && xStrm.is() )
1497cdf0e10cSrcweir {
1498cdf0e10cSrcweir try
1499cdf0e10cSrcweir {
1500cdf0e10cSrcweir uno::Reference < embed::XStorage > xStorage =
1501cdf0e10cSrcweir ::comphelper::OStorageHelper::GetStorageFromInputStream( xStrm, ::comphelper::getProcessServiceFactory() );
1502cdf0e10cSrcweir uno::Reference < beans::XPropertySet > xProps( xStorage, uno::UNO_QUERY );
1503cdf0e10cSrcweir SfxMedium aMedium( xStorage, String() );
1504cdf0e10cSrcweir Insert( aMedium );
1505cdf0e10cSrcweir GetDoc()->UpdateText();
1506cdf0e10cSrcweir }
1507cdf0e10cSrcweir catch (uno::Exception &)
1508cdf0e10cSrcweir {
1509cdf0e10cSrcweir DBG_ERROR( "SmViewShell::Execute (SID_PASTEOBJECT): failed to get storage from input stream" );
1510cdf0e10cSrcweir }
1511cdf0e10cSrcweir }
1512cdf0e10cSrcweir }
1513cdf0e10cSrcweir break;
1514cdf0e10cSrcweir
1515cdf0e10cSrcweir
1516cdf0e10cSrcweir case SID_CUT:
1517cdf0e10cSrcweir if (pWin)
1518cdf0e10cSrcweir pWin->Cut();
1519cdf0e10cSrcweir break;
1520cdf0e10cSrcweir
1521cdf0e10cSrcweir case SID_COPY:
1522cdf0e10cSrcweir if (pWin)
1523cdf0e10cSrcweir {
1524cdf0e10cSrcweir if (pWin->IsAllSelected())
1525cdf0e10cSrcweir {
1526cdf0e10cSrcweir GetViewFrame()->GetDispatcher()->Execute(
1527cdf0e10cSrcweir SID_COPYOBJECT, SFX_CALLMODE_STANDARD,
1528cdf0e10cSrcweir new SfxVoidItem(SID_COPYOBJECT), 0L);
1529cdf0e10cSrcweir }
1530cdf0e10cSrcweir else
1531cdf0e10cSrcweir pWin->Copy();
1532cdf0e10cSrcweir }
1533cdf0e10cSrcweir break;
1534cdf0e10cSrcweir
1535cdf0e10cSrcweir case SID_PASTE:
1536cdf0e10cSrcweir {
1537cdf0e10cSrcweir sal_Bool bCallExec = 0 == pWin;
1538cdf0e10cSrcweir if( !bCallExec )
1539cdf0e10cSrcweir {
1540cdf0e10cSrcweir TransferableDataHelper aDataHelper(
1541cdf0e10cSrcweir TransferableDataHelper::CreateFromSystemClipboard(
1542cdf0e10cSrcweir GetEditWindow()) );
1543cdf0e10cSrcweir
1544cdf0e10cSrcweir if( aDataHelper.GetTransferable().is() &&
1545cdf0e10cSrcweir aDataHelper.HasFormat( FORMAT_STRING ))
1546cdf0e10cSrcweir pWin->Paste();
1547cdf0e10cSrcweir else
1548cdf0e10cSrcweir bCallExec = sal_True;
1549cdf0e10cSrcweir }
1550cdf0e10cSrcweir if( bCallExec )
1551cdf0e10cSrcweir {
1552cdf0e10cSrcweir GetViewFrame()->GetDispatcher()->Execute(
1553cdf0e10cSrcweir SID_PASTEOBJECT, SFX_CALLMODE_STANDARD,
1554cdf0e10cSrcweir new SfxVoidItem(SID_PASTEOBJECT), 0L);
1555cdf0e10cSrcweir }
1556cdf0e10cSrcweir }
1557cdf0e10cSrcweir break;
1558cdf0e10cSrcweir
1559cdf0e10cSrcweir case SID_DELETE:
1560cdf0e10cSrcweir if (pWin)
1561cdf0e10cSrcweir pWin->Delete();
1562cdf0e10cSrcweir break;
1563cdf0e10cSrcweir
1564cdf0e10cSrcweir case SID_SELECT:
1565cdf0e10cSrcweir if (pWin)
1566cdf0e10cSrcweir pWin->SelectAll();
1567cdf0e10cSrcweir break;
1568cdf0e10cSrcweir
1569cdf0e10cSrcweir case SID_INSERTCOMMAND:
1570cdf0e10cSrcweir {
1571cdf0e10cSrcweir const SfxInt16Item& rItem =
1572cdf0e10cSrcweir (const SfxInt16Item&)rReq.GetArgs()->Get(SID_INSERTCOMMAND);
1573cdf0e10cSrcweir
1574cdf0e10cSrcweir if (pWin)
1575cdf0e10cSrcweir pWin->InsertCommand(rItem.GetValue());
1576cdf0e10cSrcweir break;
1577cdf0e10cSrcweir }
1578cdf0e10cSrcweir
1579cdf0e10cSrcweir case SID_INSERTTEXT:
1580cdf0e10cSrcweir {
1581cdf0e10cSrcweir const SfxStringItem& rItem =
1582cdf0e10cSrcweir (const SfxStringItem&)rReq.GetArgs()->Get(SID_INSERTTEXT);
1583cdf0e10cSrcweir if (pWin)
1584cdf0e10cSrcweir pWin->InsertText(rItem.GetValue());
1585cdf0e10cSrcweir break;
1586cdf0e10cSrcweir }
1587cdf0e10cSrcweir
1588cdf0e10cSrcweir case SID_IMPORT_FORMULA:
1589cdf0e10cSrcweir {
1590cdf0e10cSrcweir delete pImpl->pRequest;
1591cdf0e10cSrcweir pImpl->pRequest = new SfxRequest( rReq );
1592cdf0e10cSrcweir delete pImpl->pDocInserter;
1593cdf0e10cSrcweir pImpl->pDocInserter =
1594cdf0e10cSrcweir new ::sfx2::DocumentInserter( 0, GetDoc()->GetFactory().GetFactoryName(), 0 );
1595cdf0e10cSrcweir pImpl->pDocInserter->StartExecuteModal( LINK( this, SmViewShell, DialogClosedHdl ) );
1596cdf0e10cSrcweir break;
1597cdf0e10cSrcweir }
1598cdf0e10cSrcweir
1599cdf0e10cSrcweir case SID_NEXTERR:
1600cdf0e10cSrcweir NextError();
1601cdf0e10cSrcweir if (pWin)
1602cdf0e10cSrcweir pWin->GrabFocus();
1603cdf0e10cSrcweir break;
1604cdf0e10cSrcweir
1605cdf0e10cSrcweir case SID_PREVERR:
1606cdf0e10cSrcweir PrevError();
1607cdf0e10cSrcweir if (pWin)
1608cdf0e10cSrcweir pWin->GrabFocus();
1609cdf0e10cSrcweir break;
1610cdf0e10cSrcweir
1611cdf0e10cSrcweir case SID_NEXTMARK:
1612cdf0e10cSrcweir if (pWin)
1613cdf0e10cSrcweir {
1614cdf0e10cSrcweir pWin->SelNextMark();
1615cdf0e10cSrcweir pWin->GrabFocus();
1616cdf0e10cSrcweir }
1617cdf0e10cSrcweir break;
1618cdf0e10cSrcweir
1619cdf0e10cSrcweir case SID_PREVMARK:
1620cdf0e10cSrcweir if (pWin)
1621cdf0e10cSrcweir {
1622cdf0e10cSrcweir pWin->SelPrevMark();
1623cdf0e10cSrcweir pWin->GrabFocus();
1624cdf0e10cSrcweir }
1625cdf0e10cSrcweir break;
1626cdf0e10cSrcweir
1627cdf0e10cSrcweir case SID_TEXTSTATUS:
1628cdf0e10cSrcweir {
1629cdf0e10cSrcweir if (rReq.GetArgs() != NULL)
1630cdf0e10cSrcweir {
1631cdf0e10cSrcweir const SfxStringItem& rItem =
1632cdf0e10cSrcweir (const SfxStringItem&)rReq.GetArgs()->Get(SID_TEXTSTATUS);
1633cdf0e10cSrcweir
1634cdf0e10cSrcweir SetStatusText(rItem.GetValue());
1635cdf0e10cSrcweir }
1636cdf0e10cSrcweir
1637cdf0e10cSrcweir break;
1638cdf0e10cSrcweir }
1639cdf0e10cSrcweir
1640cdf0e10cSrcweir case SID_GETEDITTEXT:
1641cdf0e10cSrcweir if (pWin)
1642cdf0e10cSrcweir if (pWin->GetText ().Len ()) GetDoc()->SetText( pWin->GetText() );
1643cdf0e10cSrcweir break;
1644cdf0e10cSrcweir
1645cdf0e10cSrcweir case SID_ATTR_ZOOM:
1646cdf0e10cSrcweir {
1647cdf0e10cSrcweir if ( !GetViewFrame()->GetFrame().IsInPlace() )
1648cdf0e10cSrcweir {
1649cdf0e10cSrcweir //CHINA001 SvxZoomDialog *pDlg = 0;
1650cdf0e10cSrcweir AbstractSvxZoomDialog *pDlg = 0;
1651cdf0e10cSrcweir const SfxItemSet *pSet = rReq.GetArgs();
1652cdf0e10cSrcweir if ( !pSet )
1653cdf0e10cSrcweir {
1654cdf0e10cSrcweir SfxItemSet aSet( GetDoc()->GetPool(), SID_ATTR_ZOOM, SID_ATTR_ZOOM);
1655cdf0e10cSrcweir aSet.Put( SvxZoomItem( SVX_ZOOM_PERCENT, aGraphic.GetZoom()));
1656cdf0e10cSrcweir //CHINA001 pDlg = new SvxZoomDialog( &GetViewFrame()->GetWindow(), aSet);
1657cdf0e10cSrcweir SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1658cdf0e10cSrcweir if(pFact)
1659cdf0e10cSrcweir {
1660cdf0e10cSrcweir pDlg = pFact->CreateSvxZoomDialog(&GetViewFrame()->GetWindow(), aSet);
1661cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
1662cdf0e10cSrcweir }
1663cdf0e10cSrcweir pDlg->SetLimits( MINZOOM, MAXZOOM );
1664cdf0e10cSrcweir if( pDlg->Execute() != RET_CANCEL )
1665cdf0e10cSrcweir pSet = pDlg->GetOutputItemSet();
1666cdf0e10cSrcweir }
1667cdf0e10cSrcweir if ( pSet )
1668cdf0e10cSrcweir {
1669cdf0e10cSrcweir const SvxZoomItem &rZoom = (const SvxZoomItem &)pSet->Get(SID_ATTR_ZOOM);
1670cdf0e10cSrcweir switch( rZoom.GetType() )
1671cdf0e10cSrcweir {
1672cdf0e10cSrcweir case SVX_ZOOM_PERCENT:
1673cdf0e10cSrcweir aGraphic.SetZoom((sal_uInt16)rZoom.GetValue ());
1674cdf0e10cSrcweir break;
1675cdf0e10cSrcweir
1676cdf0e10cSrcweir case SVX_ZOOM_OPTIMAL:
1677cdf0e10cSrcweir aGraphic.ZoomToFitInWindow();
1678cdf0e10cSrcweir break;
1679cdf0e10cSrcweir
1680cdf0e10cSrcweir case SVX_ZOOM_PAGEWIDTH:
1681cdf0e10cSrcweir case SVX_ZOOM_WHOLEPAGE:
1682cdf0e10cSrcweir {
1683cdf0e10cSrcweir const MapMode aMap( MAP_100TH_MM );
1684cdf0e10cSrcweir SfxPrinter *pPrinter = GetPrinter( sal_True );
1685cdf0e10cSrcweir Point aPoint;
1686cdf0e10cSrcweir Rectangle OutputRect(aPoint, pPrinter->GetOutputSize());
1687cdf0e10cSrcweir Size OutputSize(pPrinter->LogicToPixel(Size(OutputRect.GetWidth(),
1688cdf0e10cSrcweir OutputRect.GetHeight()), aMap));
1689cdf0e10cSrcweir Size GraphicSize(pPrinter->LogicToPixel(GetDoc()->GetSize(), aMap));
1690cdf0e10cSrcweir sal_uInt16 nZ = (sal_uInt16) Min((long)Fraction(OutputSize.Width() * 100L, GraphicSize.Width()),
1691cdf0e10cSrcweir (long)Fraction(OutputSize.Height() * 100L, GraphicSize.Height()));
1692cdf0e10cSrcweir aGraphic.SetZoom (nZ);
1693cdf0e10cSrcweir break;
1694cdf0e10cSrcweir }
1695cdf0e10cSrcweir default:
1696cdf0e10cSrcweir break;
1697cdf0e10cSrcweir }
1698cdf0e10cSrcweir }
1699cdf0e10cSrcweir delete pDlg;
1700cdf0e10cSrcweir }
1701cdf0e10cSrcweir }
1702cdf0e10cSrcweir break;
1703cdf0e10cSrcweir
1704cdf0e10cSrcweir case SID_TOOLBOX:
1705cdf0e10cSrcweir {
1706cdf0e10cSrcweir GetViewFrame()->ToggleChildWindow( SmToolBoxWrapper::GetChildWindowId() );
1707cdf0e10cSrcweir }
1708cdf0e10cSrcweir break;
1709cdf0e10cSrcweir
1710cdf0e10cSrcweir case SID_SYMBOLS_CATALOGUE:
1711cdf0e10cSrcweir {
1712cdf0e10cSrcweir
1713cdf0e10cSrcweir // get device used to retrieve the FontList
1714cdf0e10cSrcweir SmDocShell *pDoc = GetDoc();
1715cdf0e10cSrcweir OutputDevice *pDev = pDoc->GetPrinter();
1716cdf0e10cSrcweir if (!pDev || pDev->GetDevFontCount() == 0)
1717cdf0e10cSrcweir pDev = &SM_MOD()->GetDefaultVirtualDev();
1718cdf0e10cSrcweir DBG_ASSERT (pDev, "device for font list missing" );
1719cdf0e10cSrcweir
1720cdf0e10cSrcweir SmModule *pp = SM_MOD();
1721cdf0e10cSrcweir SmSymbolDialog( NULL, pDev, pp->GetSymbolManager(), *this ).Execute();
1722cdf0e10cSrcweir }
1723cdf0e10cSrcweir break;
1724cdf0e10cSrcweir }
1725cdf0e10cSrcweir rReq.Done();
1726cdf0e10cSrcweir }
1727cdf0e10cSrcweir
1728cdf0e10cSrcweir
GetState(SfxItemSet & rSet)1729cdf0e10cSrcweir void SmViewShell::GetState(SfxItemSet &rSet)
1730cdf0e10cSrcweir {
1731cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::GetState" );
1732cdf0e10cSrcweir
1733cdf0e10cSrcweir SfxWhichIter aIter(rSet);
1734cdf0e10cSrcweir
1735cdf0e10cSrcweir SmEditWindow *pEditWin = GetEditWindow();
1736cdf0e10cSrcweir for (sal_uInt16 nWh = aIter.FirstWhich(); nWh != 0; nWh = aIter.NextWhich())
1737cdf0e10cSrcweir {
1738cdf0e10cSrcweir switch (nWh)
1739cdf0e10cSrcweir {
1740cdf0e10cSrcweir case SID_CUT:
1741cdf0e10cSrcweir case SID_COPY:
1742cdf0e10cSrcweir case SID_DELETE:
1743cdf0e10cSrcweir if (! pEditWin || ! pEditWin->IsSelected())
1744cdf0e10cSrcweir rSet.DisableItem(nWh);
1745cdf0e10cSrcweir break;
1746cdf0e10cSrcweir
1747cdf0e10cSrcweir case SID_PASTE:
1748cdf0e10cSrcweir if( !xClipEvtLstnr.is() && pEditWin)
1749cdf0e10cSrcweir {
1750cdf0e10cSrcweir TransferableDataHelper aDataHelper(
1751cdf0e10cSrcweir TransferableDataHelper::CreateFromSystemClipboard(
1752cdf0e10cSrcweir pEditWin) );
1753cdf0e10cSrcweir
1754cdf0e10cSrcweir bPasteState = aDataHelper.GetTransferable().is() &&
1755cdf0e10cSrcweir ( aDataHelper.HasFormat( FORMAT_STRING ) ||
1756cdf0e10cSrcweir aDataHelper.HasFormat( SOT_FORMATSTR_ID_EMBEDDED_OBJ ) ||
1757cdf0e10cSrcweir (aDataHelper.HasFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR )
1758cdf0e10cSrcweir && aDataHelper.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE )));
1759cdf0e10cSrcweir }
1760cdf0e10cSrcweir if( !bPasteState )
1761cdf0e10cSrcweir rSet.DisableItem( nWh );
1762cdf0e10cSrcweir break;
1763cdf0e10cSrcweir
1764cdf0e10cSrcweir case SID_ATTR_ZOOM:
1765cdf0e10cSrcweir rSet.Put(SvxZoomItem( SVX_ZOOM_PERCENT, aGraphic.GetZoom()));
1766cdf0e10cSrcweir /* no break here */
1767cdf0e10cSrcweir case SID_VIEW050:
1768cdf0e10cSrcweir case SID_VIEW100:
1769cdf0e10cSrcweir case SID_VIEW200:
1770cdf0e10cSrcweir case SID_ADJUST:
1771cdf0e10cSrcweir case SID_ZOOMIN:
1772cdf0e10cSrcweir case SID_ZOOMOUT:
1773cdf0e10cSrcweir case SID_FITINWINDOW:
1774cdf0e10cSrcweir if ( GetViewFrame()->GetFrame().IsInPlace() )
1775cdf0e10cSrcweir rSet.DisableItem( nWh );
1776cdf0e10cSrcweir break;
1777cdf0e10cSrcweir
1778cdf0e10cSrcweir case SID_NEXTERR:
1779cdf0e10cSrcweir case SID_PREVERR:
1780cdf0e10cSrcweir case SID_NEXTMARK:
1781cdf0e10cSrcweir case SID_PREVMARK:
1782cdf0e10cSrcweir case SID_DRAW:
1783cdf0e10cSrcweir case SID_SELECT:
1784cdf0e10cSrcweir if (! pEditWin || pEditWin->IsEmpty())
1785cdf0e10cSrcweir rSet.DisableItem(nWh);
1786cdf0e10cSrcweir break;
1787cdf0e10cSrcweir
1788cdf0e10cSrcweir case SID_TEXTSTATUS:
1789cdf0e10cSrcweir {
1790cdf0e10cSrcweir rSet.Put(SfxStringItem(nWh, StatusText));
1791cdf0e10cSrcweir }
1792cdf0e10cSrcweir break;
1793cdf0e10cSrcweir
1794cdf0e10cSrcweir case SID_FORMULACURSOR:
1795cdf0e10cSrcweir {
1796cdf0e10cSrcweir SmModule *pp = SM_MOD();
1797cdf0e10cSrcweir rSet.Put(SfxBoolItem(nWh, pp->GetConfig()->IsShowFormulaCursor()));
1798cdf0e10cSrcweir }
1799cdf0e10cSrcweir break;
1800cdf0e10cSrcweir
1801cdf0e10cSrcweir case SID_TOOLBOX:
1802cdf0e10cSrcweir {
1803cdf0e10cSrcweir sal_Bool bState = sal_False;
1804cdf0e10cSrcweir SfxChildWindow *pChildWnd = GetViewFrame()->
1805cdf0e10cSrcweir GetChildWindow( SmToolBoxWrapper::GetChildWindowId() );
1806cdf0e10cSrcweir if (pChildWnd && pChildWnd->GetWindow()->IsVisible())
1807cdf0e10cSrcweir bState = sal_True;
1808cdf0e10cSrcweir rSet.Put(SfxBoolItem(SID_TOOLBOX, bState));
1809cdf0e10cSrcweir }
1810cdf0e10cSrcweir break;
1811cdf0e10cSrcweir
1812cdf0e10cSrcweir }
1813cdf0e10cSrcweir }
1814cdf0e10cSrcweir }
1815cdf0e10cSrcweir
1816cdf0e10cSrcweir
SmViewShell(SfxViewFrame * pFrame_,SfxViewShell *)1817cdf0e10cSrcweir SmViewShell::SmViewShell(SfxViewFrame *pFrame_, SfxViewShell *):
1818cdf0e10cSrcweir SfxViewShell(pFrame_, SFX_VIEW_HAS_PRINTOPTIONS | SFX_VIEW_CAN_PRINT),
1819cdf0e10cSrcweir aGraphic(this),
1820cdf0e10cSrcweir aGraphicController(aGraphic, SID_GAPHIC_SM, pFrame_->GetBindings()),
1821cdf0e10cSrcweir pImpl( new SmViewShell_Impl )
1822cdf0e10cSrcweir {
1823cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::SmViewShell" );
1824cdf0e10cSrcweir
1825cdf0e10cSrcweir // pViewFrame = &pFrame_->GetWindow();
1826cdf0e10cSrcweir
1827cdf0e10cSrcweir SetStatusText(String());
1828cdf0e10cSrcweir SetWindow(&aGraphic);
1829cdf0e10cSrcweir SfxShell::SetName(C2S("SmView"));
1830cdf0e10cSrcweir SfxShell::SetUndoManager( &GetDoc()->GetEditEngine().GetUndoManager() );
1831cdf0e10cSrcweir SetHelpId( HID_SMA_VIEWSHELL_DOCUMENT );
1832cdf0e10cSrcweir }
1833cdf0e10cSrcweir
1834cdf0e10cSrcweir
~SmViewShell()1835cdf0e10cSrcweir SmViewShell::~SmViewShell()
1836cdf0e10cSrcweir {
1837cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::~SmViewShell" );
1838cdf0e10cSrcweir
1839cdf0e10cSrcweir //!! this view shell is not active anymore !!
1840cdf0e10cSrcweir // Thus 'SmGetActiveView' will give a 0 pointer.
1841cdf0e10cSrcweir // Thus we need to supply this view as argument
1842cdf0e10cSrcweir SmEditWindow *pEditWin = GetEditWindow();
1843cdf0e10cSrcweir if (pEditWin)
1844cdf0e10cSrcweir pEditWin->DeleteEditView( *this );
1845cdf0e10cSrcweir delete pImpl;
1846cdf0e10cSrcweir }
1847cdf0e10cSrcweir
Deactivate(sal_Bool bIsMDIActivate)1848cdf0e10cSrcweir void SmViewShell::Deactivate( sal_Bool bIsMDIActivate )
1849cdf0e10cSrcweir {
1850cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::Deactivate" );
1851cdf0e10cSrcweir
1852cdf0e10cSrcweir SmEditWindow *pEdit = GetEditWindow();
1853cdf0e10cSrcweir if ( pEdit )
1854cdf0e10cSrcweir pEdit->Flush();
1855cdf0e10cSrcweir
1856cdf0e10cSrcweir SfxViewShell::Deactivate( bIsMDIActivate );
1857cdf0e10cSrcweir }
1858cdf0e10cSrcweir
1859cdf0e10cSrcweir
Activate(sal_Bool bIsMDIActivate)1860cdf0e10cSrcweir void SmViewShell::Activate( sal_Bool bIsMDIActivate )
1861cdf0e10cSrcweir {
1862cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::Activate" );
1863cdf0e10cSrcweir
1864cdf0e10cSrcweir SfxViewShell::Activate( bIsMDIActivate );
1865cdf0e10cSrcweir
1866cdf0e10cSrcweir SmEditWindow *pEdit = GetEditWindow();
1867cdf0e10cSrcweir if ( pEdit )
1868cdf0e10cSrcweir {
1869cdf0e10cSrcweir //! Since there is no way to be informed if a "drag and drop"
1870cdf0e10cSrcweir //! event has taken place, we call SetText here in order to
1871cdf0e10cSrcweir //! syncronize the GraphicWindow display with the text in the
1872cdf0e10cSrcweir //! EditEngine.
1873cdf0e10cSrcweir SmDocShell *pDoc = GetDoc();
1874cdf0e10cSrcweir pDoc->SetText( pDoc->GetEditEngine().GetText( LINEEND_LF ) );
1875cdf0e10cSrcweir
1876cdf0e10cSrcweir if ( bIsMDIActivate )
1877cdf0e10cSrcweir pEdit->GrabFocus();
1878cdf0e10cSrcweir }
1879cdf0e10cSrcweir }
1880cdf0e10cSrcweir
1881cdf0e10cSrcweir //------------------------------------------------------------------
1882cdf0e10cSrcweir
IMPL_LINK(SmViewShell,DialogClosedHdl,sfx2::FileDialogHelper *,_pFileDlg)1883cdf0e10cSrcweir IMPL_LINK( SmViewShell, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg )
1884cdf0e10cSrcweir {
1885cdf0e10cSrcweir DBG_ASSERT( _pFileDlg, "SmViewShell::DialogClosedHdl(): no file dialog" );
1886cdf0e10cSrcweir DBG_ASSERT( pImpl->pDocInserter, "ScDocShell::DialogClosedHdl(): no document inserter" );
1887cdf0e10cSrcweir
1888cdf0e10cSrcweir if ( ERRCODE_NONE == _pFileDlg->GetError() )
1889cdf0e10cSrcweir {
1890cdf0e10cSrcweir //sal_uInt16 nSlot = pImpl->pRequest->GetSlot();
1891cdf0e10cSrcweir SfxMedium* pMedium = pImpl->pDocInserter->CreateMedium();
1892cdf0e10cSrcweir
1893cdf0e10cSrcweir if ( pMedium != NULL )
1894cdf0e10cSrcweir {
1895cdf0e10cSrcweir if ( pMedium->IsStorage() )
1896cdf0e10cSrcweir Insert( *pMedium );
1897cdf0e10cSrcweir else
1898cdf0e10cSrcweir InsertFrom( *pMedium );
1899cdf0e10cSrcweir delete pMedium;
1900cdf0e10cSrcweir
1901cdf0e10cSrcweir SmDocShell* pDoc = GetDoc();
1902cdf0e10cSrcweir pDoc->UpdateText();
1903cdf0e10cSrcweir pDoc->ArrangeFormula();
1904cdf0e10cSrcweir pDoc->Repaint();
1905cdf0e10cSrcweir // adjust window, repaint, increment ModifyCount,...
1906cdf0e10cSrcweir GetViewFrame()->GetBindings().Invalidate(SID_GAPHIC_SM);
1907cdf0e10cSrcweir }
1908cdf0e10cSrcweir }
1909cdf0e10cSrcweir
1910cdf0e10cSrcweir pImpl->pRequest->SetReturnValue( SfxBoolItem( pImpl->pRequest->GetSlot(), sal_True ) );
1911cdf0e10cSrcweir pImpl->pRequest->Done();
1912cdf0e10cSrcweir return 0;
1913cdf0e10cSrcweir }
1914cdf0e10cSrcweir
Notify(SfxBroadcaster &,const SfxHint & rHint)1915cdf0e10cSrcweir void SmViewShell::Notify( SfxBroadcaster& , const SfxHint& rHint )
1916cdf0e10cSrcweir {
1917cdf0e10cSrcweir if ( rHint.IsA(TYPE(SfxSimpleHint)) )
1918cdf0e10cSrcweir {
1919cdf0e10cSrcweir switch( ( (SfxSimpleHint&) rHint ).GetId() )
1920cdf0e10cSrcweir {
1921cdf0e10cSrcweir case SFX_HINT_MODECHANGED:
1922cdf0e10cSrcweir case SFX_HINT_DOCCHANGED:
1923cdf0e10cSrcweir GetViewFrame()->GetBindings().InvalidateAll(sal_False);
1924cdf0e10cSrcweir break;
1925cdf0e10cSrcweir default:
1926cdf0e10cSrcweir break;
1927cdf0e10cSrcweir }
1928cdf0e10cSrcweir }
1929cdf0e10cSrcweir }
1930*74ad9c3aSmseidel
1931*74ad9c3aSmseidel /* vim: set noet sw=4 ts=4: */
1932