LCOV - code coverage report
Current view: top level - starmath/source - view.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 307 1031 29.8 %
Date: 2012-08-25 Functions: 63 103 61.2 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 245 1887 13.0 %

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

Generated by: LCOV version 1.10