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