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