LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/ui/view - tabvwsha.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 149 376 39.6 %
Date: 2013-07-09 Functions: 8 13 61.5 %
Legend: Lines: hit not hit

          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 "scitems.hxx"
      21             : #include <svl/stritem.hxx>
      22             : #include <svl/whiter.hxx>
      23             : #include <svl/zformat.hxx>
      24             : #include <editeng/boxitem.hxx>
      25             : #include <svx/numinf.hxx>
      26             : #include <svl/srchitem.hxx>
      27             : #include <svx/zoomslideritem.hxx>
      28             : #include <sfx2/bindings.hxx>
      29             : #include <sfx2/viewfrm.hxx>
      30             : #include <sfx2/dispatch.hxx>
      31             : #include <sfx2/request.hxx>
      32             : #include <vcl/msgbox.hxx>
      33             : 
      34             : #include "global.hxx"
      35             : #include "attrib.hxx"
      36             : #include "patattr.hxx"
      37             : #include "document.hxx"
      38             : #include "formulacell.hxx"             // Input Status Edit-Zellen
      39             : #include "globstr.hrc"
      40             : #include "scmod.hxx"
      41             : #include "inputhdl.hxx"
      42             : #include "inputwin.hxx"
      43             : #include "docsh.hxx"
      44             : #include "viewdata.hxx"
      45             : #include "appoptio.hxx"
      46             : #include "sc.hrc"
      47             : #include "stlpool.hxx"
      48             : #include "tabvwsh.hxx"
      49             : #include "dwfunctr.hxx"
      50             : #include "scabstdlg.hxx"
      51             : #include "compiler.hxx"
      52             : #include "markdata.hxx"
      53             : #include "cellvalue.hxx"
      54             : #include "tokenarray.hxx"
      55             : 
      56         187 : sal_Bool ScTabViewShell::GetFunction( String& rFuncStr, sal_uInt16 nErrCode )
      57             : {
      58         187 :     String aStr;
      59             : 
      60         187 :     ScSubTotalFunc eFunc = (ScSubTotalFunc) SC_MOD()->GetAppOptions().GetStatusFunc();
      61         187 :     ScViewData* pViewData   = GetViewData();
      62         187 :     ScMarkData& rMark       = pViewData->GetMarkData();
      63         187 :     bool bIgnoreError = (rMark.IsMarked() || rMark.IsMultiMarked());
      64             : 
      65         187 :     if (bIgnoreError && (eFunc == SUBTOTAL_FUNC_CNT || eFunc == SUBTOTAL_FUNC_CNT2))
      66           0 :         nErrCode = 0;
      67             : 
      68         187 :     if (nErrCode)
      69             :     {
      70           0 :         rFuncStr = ScGlobal::GetLongErrorString(nErrCode);
      71           0 :         return true;
      72             :     }
      73             : 
      74         187 :     sal_uInt16 nGlobStrId = 0;
      75         187 :     switch (eFunc)
      76             :     {
      77           0 :         case SUBTOTAL_FUNC_AVE:  nGlobStrId = STR_FUN_TEXT_AVG; break;
      78           0 :         case SUBTOTAL_FUNC_CNT:  nGlobStrId = STR_FUN_TEXT_COUNT; break;
      79           0 :         case SUBTOTAL_FUNC_CNT2: nGlobStrId = STR_FUN_TEXT_COUNT2; break;
      80           0 :         case SUBTOTAL_FUNC_MAX:  nGlobStrId = STR_FUN_TEXT_MAX; break;
      81           0 :         case SUBTOTAL_FUNC_MIN:  nGlobStrId = STR_FUN_TEXT_MIN; break;
      82         161 :         case SUBTOTAL_FUNC_SUM:  nGlobStrId = STR_FUN_TEXT_SUM; break;
      83          26 :         case SUBTOTAL_FUNC_SELECTION_COUNT: nGlobStrId = STR_FUN_TEXT_SELECTION_COUNT; break;
      84             : 
      85             :         default:
      86             :         {
      87             :             // added to avoid warnings
      88             :         }
      89             :     }
      90         187 :     if (nGlobStrId)
      91             :     {
      92         187 :         ScDocument* pDoc        = pViewData->GetDocument();
      93         187 :         SCCOL       nPosX       = pViewData->GetCurX();
      94         187 :         SCROW       nPosY       = pViewData->GetCurY();
      95         187 :         SCTAB       nTab        = pViewData->GetTabNo();
      96             : 
      97         187 :         aStr = ScGlobal::GetRscString(nGlobStrId);
      98         187 :         aStr += '=';
      99             : 
     100         187 :         ScAddress aCursor( nPosX, nPosY, nTab );
     101             :         double nVal;
     102         187 :         if ( pDoc->GetSelectionFunction( eFunc, aCursor, rMark, nVal ) )
     103             :         {
     104         187 :             if ( nVal == 0.0 )
     105         161 :                 aStr += '0';
     106             :             else
     107             :             {
     108             :                 // Number in the standard format, the other on the cursor position
     109          26 :                 SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
     110          26 :                 sal_uInt32 nNumFmt = 0;
     111          26 :                 if ( eFunc != SUBTOTAL_FUNC_CNT && eFunc != SUBTOTAL_FUNC_CNT2 && eFunc != SUBTOTAL_FUNC_SELECTION_COUNT)
     112             :                 {
     113             :                     //  Zahlformat aus Attributen oder Formel
     114           0 :                     pDoc->GetNumberFormat( nPosX, nPosY, nTab, nNumFmt );
     115             :                 }
     116             : 
     117          26 :                 OUString aValStr;
     118             :                 Color* pDummy;
     119          26 :                 pFormatter->GetOutputString( nVal, nNumFmt, aValStr, &pDummy );
     120          26 :                 aStr += aValStr;
     121             :             }
     122             :         }
     123             : 
     124         187 :         rFuncStr = aStr;
     125         187 :         return sal_True;
     126             :     }
     127             : 
     128           0 :     return false;
     129             : }
     130             : 
     131             : 
     132             : 
     133             : //  Functions that are disabled, depending on the selection
     134             : //  Default:
     135             : //      SID_DELETE,
     136             : //      SID_DELETE_CONTENTS,
     137             : //      FID_DELETE_CELL
     138             : //      FID_VALIDATION
     139             : 
     140             : 
     141         847 : void ScTabViewShell::GetState( SfxItemSet& rSet )
     142             : {
     143         847 :     ScViewData* pViewData   = GetViewData();
     144         847 :     ScDocument* pDoc        = pViewData->GetDocument();
     145         847 :     ScDocShell* pDocShell   = pViewData->GetDocShell();
     146         847 :     ScMarkData& rMark       = pViewData->GetMarkData();
     147         847 :     SCCOL       nPosX       = pViewData->GetCurX();
     148         847 :     SCROW       nPosY       = pViewData->GetCurY();
     149         847 :     SCTAB       nTab        = pViewData->GetTabNo();
     150         847 :     sal_uInt16      nMyId       = 0;
     151             : 
     152         847 :     SfxViewFrame* pThisFrame = GetViewFrame();
     153         847 :     sal_Bool bOle = GetViewFrame()->GetFrame().IsInPlace();
     154             : 
     155         847 :     SCTAB nTabCount = pDoc->GetTableCount();
     156         847 :     SCTAB nTabSelCount = rMark.GetSelectCount();
     157             : 
     158         847 :     SfxWhichIter    aIter(rSet);
     159         847 :     sal_uInt16          nWhich = aIter.FirstWhich();
     160             : 
     161        2714 :     while ( nWhich )
     162             :     {
     163        1020 :         switch ( nWhich )
     164             :         {
     165             :             case FID_CHG_COMMENT:
     166             :                 {
     167           0 :                     ScDocShell* pDocSh = GetViewData()->GetDocShell();
     168           0 :                     ScAddress aPos( nPosX, nPosY, nTab );
     169           0 :                     if ( pDocSh->IsReadOnly() || !pDocSh->GetChangeAction(aPos) || pDocSh->IsDocShared() )
     170           0 :                         rSet.DisableItem( nWhich );
     171             :                 }
     172           0 :                 break;
     173             : 
     174             :             case SID_OPENDLG_EDIT_PRINTAREA:
     175             :             case SID_ADD_PRINTAREA:
     176             :             case SID_DEFINE_PRINTAREA:
     177             :                 {
     178           0 :                     if ( pDocShell && pDocShell->IsDocShared() )
     179             :                     {
     180           0 :                         rSet.DisableItem( nWhich );
     181             :                     }
     182             :                 }
     183           0 :                 break;
     184             : 
     185             :             case SID_DELETE_PRINTAREA:
     186           0 :                 if ( nTabSelCount > 1 )
     187             :                 {
     188             :                     // #i22589# also take "Print Entire Sheet" into account here
     189           0 :                     sal_Bool bHas = false;
     190           0 :                     for (SCTAB i=0; !bHas && i<nTabCount; i++)
     191           0 :                         bHas = rMark.GetTableSelect(i) && (pDoc->GetPrintRangeCount(i) || pDoc->IsPrintEntireSheet(i));
     192           0 :                     if (!bHas)
     193           0 :                         rSet.DisableItem( nWhich );
     194             :                 }
     195           0 :                 else if ( !pDoc->GetPrintRangeCount( nTab ) && !pDoc->IsPrintEntireSheet( nTab ) )
     196           0 :                     rSet.DisableItem( nWhich );
     197           0 :                 if ( pDocShell && pDocShell->IsDocShared() )
     198             :                 {
     199           0 :                     rSet.DisableItem( nWhich );
     200             :                 }
     201           0 :                 break;
     202             : 
     203             :             case SID_STATUS_PAGESTYLE:
     204             :             case SID_HFEDIT:
     205         213 :                 GetViewData()->GetDocShell()->GetStatePageStyle( *this, rSet, nTab );
     206         213 :                 break;
     207             : 
     208             :             case SID_SEARCH_ITEM:
     209             :             {
     210           0 :                 SvxSearchItem aItem(ScGlobal::GetSearchItem()); // make a copy.
     211             :                 // Search on current selection if a range is marked.
     212           0 :                 aItem.SetSelection(rMark.IsMarked());
     213           0 :                 rSet.Put(aItem);
     214           0 :                 break;
     215             :             }
     216             : 
     217             :             case SID_SEARCH_OPTIONS:
     218             :                 {
     219             :                     // Anything goes
     220           0 :                     sal_uInt16 nOptions = 0xffff;
     221             : 
     222             :                     // No replacement if ReadOnly
     223           0 :                     if (GetViewData()->GetDocShell()->IsReadOnly())
     224           0 :                         nOptions &= ~( SEARCH_OPTIONS_REPLACE | SEARCH_OPTIONS_REPLACE_ALL );
     225           0 :                     rSet.Put( SfxUInt16Item( nWhich, nOptions ) );
     226             :                 }
     227           0 :                 break;
     228             : 
     229             :             case SID_CURRENTCELL:
     230             :                 {
     231           1 :                     ScAddress aScAddress( GetViewData()->GetCurX(), GetViewData()->GetCurY(), 0 );
     232           1 :                     String  aAddr;
     233           1 :                     aScAddress.Format( aAddr, SCA_ABS, NULL, pDoc->GetAddressConvention() );
     234           2 :                     SfxStringItem   aPosItem( SID_CURRENTCELL, aAddr );
     235             : 
     236           2 :                     rSet.Put( aPosItem );
     237             :                 }
     238           1 :                 break;
     239             : 
     240             :             case SID_CURRENTTAB:
     241             :                 // Table for Basic is 1-based
     242           0 :                 rSet.Put( SfxUInt16Item( nWhich, static_cast<sal_uInt16>(GetViewData()->GetTabNo()) + 1 ) );
     243           0 :                 break;
     244             : 
     245             :             case SID_CURRENTDOC:
     246           0 :                 rSet.Put( SfxStringItem( nWhich, GetViewData()->GetDocShell()->GetTitle() ) );
     247           0 :                 break;
     248             : 
     249             :             case FID_TOGGLEINPUTLINE:
     250             :                 {
     251           0 :                     sal_uInt16 nId = ScInputWindowWrapper::GetChildWindowId();
     252             : 
     253           0 :                     if ( pThisFrame->KnowsChildWindow( nId ) )
     254             :                     {
     255           0 :                         SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId );
     256           0 :                         rSet.Put( SfxBoolItem( nWhich, pWnd ? sal_True : false ) );
     257             :                     }
     258             :                     else
     259           0 :                         rSet.DisableItem( nWhich );
     260             :                 }
     261           0 :                 break;
     262             : 
     263             :             case FID_DEL_MANUALBREAKS:
     264           0 :                 if (!pDoc->HasManualBreaks(nTab))
     265           0 :                     rSet.DisableItem( nWhich );
     266           0 :                 break;
     267             : 
     268             :             case FID_RESET_PRINTZOOM:
     269             :                 {
     270             :                     // disable if already set to default
     271             : 
     272           0 :                     String aStyleName = pDoc->GetPageStyle( nTab );
     273           0 :                     ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
     274             :                     SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aStyleName,
     275           0 :                                                     SFX_STYLE_FAMILY_PAGE );
     276             :                     OSL_ENSURE( pStyleSheet, "PageStyle not found" );
     277           0 :                     if ( pStyleSheet )
     278             :                     {
     279           0 :                         SfxItemSet& rStyleSet = pStyleSheet->GetItemSet();
     280             :                         sal_uInt16 nScale = ((const SfxUInt16Item&)
     281           0 :                                             rStyleSet.Get(ATTR_PAGE_SCALE)).GetValue();
     282             :                         sal_uInt16 nPages = ((const SfxUInt16Item&)
     283           0 :                                             rStyleSet.Get(ATTR_PAGE_SCALETOPAGES)).GetValue();
     284           0 :                         if ( nScale == 100 && nPages == 0 )
     285           0 :                             rSet.DisableItem( nWhich );
     286           0 :                     }
     287             :                 }
     288           0 :                 break;
     289             : 
     290             :             case FID_SCALE:
     291             :             case SID_ATTR_ZOOM:
     292         363 :                 if ( bOle )
     293           0 :                     rSet.DisableItem( nWhich );
     294             :                 else
     295             :                 {
     296         363 :                     const Fraction& rOldY = GetViewData()->GetZoomY();
     297         363 :                     sal_uInt16 nZoom = (sal_uInt16)(( rOldY.GetNumerator() * 100 )
     298         363 :                                                 / rOldY.GetDenominator());
     299         363 :                     rSet.Put( SvxZoomItem( SVX_ZOOM_PERCENT, nZoom, nWhich ) );
     300             :                 }
     301         363 :                 break;
     302             : 
     303             :             case SID_ATTR_ZOOMSLIDER:
     304             :                 {
     305         213 :                     if ( bOle )
     306           0 :                         rSet.DisableItem( nWhich );
     307             :                     else
     308             :                     {
     309         213 :                         const Fraction& rOldY = GetViewData()->GetZoomY();
     310         213 :                         sal_uInt16 nCurrentZoom = (sal_uInt16)(( rOldY.GetNumerator() * 100 ) / rOldY.GetDenominator());
     311             : 
     312         213 :                         if( nCurrentZoom )
     313             :                         {
     314         213 :                             SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM, MAXZOOM, SID_ATTR_ZOOMSLIDER );
     315         213 :                             aZoomSliderItem.AddSnappingPoint( 100 );
     316         213 :                             rSet.Put( aZoomSliderItem );
     317             :                         }
     318             :                     }
     319             :                 }
     320         213 :                 break;
     321             : 
     322             :             case FID_TOGGLESYNTAX:
     323           0 :                 rSet.Put(SfxBoolItem(nWhich, GetViewData()->IsSyntaxMode()));
     324           0 :                 break;
     325             : 
     326             :             case FID_TOGGLEHEADERS:
     327           0 :                 rSet.Put(SfxBoolItem(nWhich, GetViewData()->IsHeaderMode()));
     328           0 :                 break;
     329             : 
     330             :             case FID_TOGGLEFORMULA:
     331             :                 {
     332           0 :                     const ScViewOptions& rOpts = pViewData->GetOptions();
     333           0 :                     sal_Bool bFormulaMode = rOpts.GetOption( VOPT_FORMULAS );
     334           0 :                     rSet.Put(SfxBoolItem(nWhich, bFormulaMode ));
     335             :                 }
     336           0 :                 break;
     337             : 
     338             :             case FID_NORMALVIEWMODE:
     339             :             case FID_PAGEBREAKMODE:
     340             :                 // always handle both slots - they exclude each other
     341           2 :                 if ( bOle )
     342             :                 {
     343           0 :                     rSet.DisableItem( FID_NORMALVIEWMODE );
     344           0 :                     rSet.DisableItem( FID_PAGEBREAKMODE );
     345             :                 }
     346             :                 else
     347             :                 {
     348           2 :                     rSet.Put(SfxBoolItem(FID_NORMALVIEWMODE, !GetViewData()->IsPagebreakMode()));
     349           2 :                     rSet.Put(SfxBoolItem(FID_PAGEBREAKMODE, GetViewData()->IsPagebreakMode()));
     350             :                 }
     351           2 :                 break;
     352             : 
     353             :             case FID_FUNCTION_BOX:
     354           0 :                 nMyId = ScFunctionChildWindow::GetChildWindowId();
     355           0 :                 rSet.Put(SfxBoolItem(FID_FUNCTION_BOX, pThisFrame->HasChildWindow(nMyId)));
     356           0 :                 break;
     357             : 
     358             :             case FID_PROTECT_DOC:
     359             :                 {
     360           0 :                     if ( pDocShell && pDocShell->IsDocShared() )
     361             :                     {
     362           0 :                         rSet.DisableItem( nWhich );
     363             :                     }
     364             :                     else
     365             :                     {
     366           0 :                         rSet.Put( SfxBoolItem( nWhich, pDoc->IsDocProtected() ) );
     367             :                     }
     368             :                 }
     369           0 :                 break;
     370             : 
     371             :             case FID_PROTECT_TABLE:
     372             :                 {
     373           0 :                     if ( pDocShell && pDocShell->IsDocShared() )
     374             :                     {
     375           0 :                         rSet.DisableItem( nWhich );
     376             :                     }
     377             :                     else
     378             :                     {
     379           0 :                         rSet.Put( SfxBoolItem( nWhich, pDoc->IsTabProtected( nTab ) ) );
     380             :                     }
     381             :                 }
     382           0 :                 break;
     383             : 
     384             :             case SID_AUTO_OUTLINE:
     385             :                 {
     386           0 :                     if (pDoc->GetChangeTrack()!=NULL || GetViewData()->IsMultiMarked())
     387             :                     {
     388           0 :                         rSet.DisableItem( nWhich );
     389             :                     }
     390             :                 }
     391           0 :                 break;
     392             : 
     393             :             case SID_OUTLINE_DELETEALL:
     394             :                 {
     395           0 :                     SCTAB nOlTab = GetViewData()->GetTabNo();
     396           0 :                     ScOutlineTable* pOlTable = pDoc->GetOutlineTable( nOlTab );
     397           0 :                     if (pOlTable == NULL)
     398           0 :                         rSet.DisableItem( nWhich );
     399             :                 }
     400           0 :                 break;
     401             : 
     402             :             case SID_WINDOW_SPLIT:
     403             :                 rSet.Put(SfxBoolItem(nWhich,
     404           8 :                             pViewData->GetHSplitMode() == SC_SPLIT_NORMAL ||
     405           8 :                             pViewData->GetVSplitMode() == SC_SPLIT_NORMAL ));
     406           4 :                 break;
     407             : 
     408             :             case SID_WINDOW_FIX:
     409             :                 rSet.Put(SfxBoolItem(nWhich,
     410           0 :                             pViewData->GetHSplitMode() == SC_SPLIT_FIX ||
     411           0 :                             pViewData->GetVSplitMode() == SC_SPLIT_FIX ));
     412           0 :                 break;
     413             : 
     414             :             case FID_CHG_SHOW:
     415             :                 {
     416           0 :                     if ( pDoc->GetChangeTrack() == NULL || ( pDocShell && pDocShell->IsDocShared() ) )
     417           0 :                         rSet.DisableItem( nWhich );
     418             :                 }
     419           0 :                 break;
     420             :             case FID_CHG_ACCEPT:
     421             :                 {
     422             :                     rSet.Put(SfxBoolItem(FID_CHG_ACCEPT,
     423           0 :                             pThisFrame->HasChildWindow(FID_CHG_ACCEPT)));
     424           0 :                     if(pDoc->GetChangeTrack()==NULL)
     425             :                     {
     426           0 :                         if ( !pThisFrame->HasChildWindow(FID_CHG_ACCEPT) )
     427             :                         {
     428           0 :                             rSet.DisableItem( nWhich);
     429             :                         }
     430             :                     }
     431           0 :                     if ( pDocShell && pDocShell->IsDocShared() )
     432             :                     {
     433           0 :                         rSet.DisableItem( nWhich );
     434             :                     }
     435             :                 }
     436           0 :                 break;
     437             : 
     438             :             case SID_FORMATPAGE:
     439             :                 // in protected tables
     440           0 :                 if ( pDocShell && ( pDocShell->IsReadOnly() || pDocShell->IsDocShared() ) )
     441           0 :                     rSet.DisableItem( nWhich );
     442           0 :                 break;
     443             : 
     444             :             case SID_PRINTPREVIEW:
     445             :                 // Toggle slot needs a State
     446         224 :                 rSet.Put( SfxBoolItem( nWhich, false ) );
     447         224 :                 break;
     448             : 
     449             :             case SID_READONLY_MODE:
     450           0 :                 rSet.Put( SfxBoolItem( nWhich, GetViewData()->GetDocShell()->IsReadOnly() ) );
     451           0 :                 break;
     452             : 
     453             :             case FID_TAB_DESELECTALL:
     454           0 :                 if ( nTabSelCount == 1 )
     455           0 :                     rSet.DisableItem( nWhich );     // enabled only if several sheets are selected
     456           0 :                 break;
     457             : 
     458             :         } // switch ( nWitch )
     459        1020 :         nWhich = aIter.NextWhich();
     460         847 :     } // while ( nWitch )
     461         847 : }
     462             : 
     463             : //------------------------------------------------------------------
     464           0 : void ScTabViewShell::ExecuteCellFormatDlg(SfxRequest& rReq, const OString &rName)
     465             : {
     466           0 :     SfxAbstractTabDialog * pDlg = NULL;
     467           0 :     ScDocument*             pDoc    = GetViewData()->GetDocument();
     468             : 
     469           0 :     SvxBoxItem              aLineOuter( ATTR_BORDER );
     470           0 :     SvxBoxInfoItem          aLineInner( ATTR_BORDER_INNER );
     471             : 
     472           0 :     SvxNumberInfoItem*      pNumberInfoItem = NULL;
     473           0 :     const ScPatternAttr*    pOldAttrs       = GetSelectionPattern();
     474             :     SfxItemSet*             pOldSet         = new SfxItemSet(
     475           0 :                                                     pOldAttrs->GetItemSet() );
     476             : 
     477             : 
     478             :     // Get border items and put them in the set:
     479           0 :     GetSelectionFrame( aLineOuter, aLineInner );
     480             :     //Fix border incorrect for RTL fdo#62399
     481           0 :     if( pDoc->IsLayoutRTL( GetViewData()->GetTabNo() ) )
     482             :     {
     483           0 :         SvxBoxItem     aNewFrame( aLineOuter );
     484           0 :         SvxBoxInfoItem aTempInfo( aLineInner );
     485             : 
     486           0 :         if ( aLineInner.IsValid(VALID_LEFT) )
     487           0 :             aNewFrame.SetLine( aLineOuter.GetLeft(), BOX_LINE_RIGHT );
     488           0 :         if ( aLineInner.IsValid(VALID_RIGHT) )
     489           0 :             aNewFrame.SetLine( aLineOuter.GetRight(), BOX_LINE_LEFT );
     490             : 
     491           0 :         aLineInner.SetValid( VALID_LEFT, aTempInfo.IsValid(VALID_RIGHT));
     492           0 :         aLineInner.SetValid( VALID_RIGHT, aTempInfo.IsValid(VALID_LEFT));
     493             : 
     494           0 :         pOldSet->Put( aNewFrame );
     495             :     }
     496             :     else
     497           0 :         pOldSet->Put( aLineOuter );
     498             : 
     499           0 :     pOldSet->Put( aLineInner );
     500             : 
     501             :     // Generate NumberFormat Value from Value and Language and box it.
     502             :     pOldSet->Put( SfxUInt32Item( ATTR_VALUE_FORMAT,
     503           0 :         pOldAttrs->GetNumberFormat( pDoc->GetFormatTable() ) ) );
     504             : 
     505           0 :     MakeNumberInfoItem( pDoc, GetViewData(), &pNumberInfoItem );
     506             : 
     507           0 :     pOldSet->MergeRange( SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_INFO );
     508           0 :     pOldSet->Put(*pNumberInfoItem );
     509             : 
     510           0 :     bInFormatDialog = true;
     511           0 :     ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
     512             :     OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
     513             : 
     514           0 :     pDlg = pFact->CreateScAttrDlg(GetViewFrame(), GetDialogParent(), pOldSet);
     515             :     OSL_ENSURE(pDlg, "Dialog create fail!");
     516           0 :     if (!rName.isEmpty())
     517           0 :         pDlg->SetCurPageId(rName);
     518           0 :     short nResult = pDlg->Execute();
     519           0 :     bInFormatDialog = false;
     520             : 
     521           0 :     if ( nResult == RET_OK )
     522             :     {
     523           0 :         const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
     524             : 
     525           0 :         const SfxPoolItem* pItem=NULL;
     526           0 :         if(pOutSet->GetItemState(SID_ATTR_NUMBERFORMAT_INFO,sal_True,&pItem)==SFX_ITEM_SET)
     527             :         {
     528             : 
     529           0 :             UpdateNumberFormatter((const SvxNumberInfoItem&)*pItem);
     530             :         }
     531             : 
     532           0 :         ApplyAttributes( pOutSet, pOldSet );
     533             : 
     534           0 :         rReq.Done( *pOutSet );
     535             :     }
     536           0 :     delete pOldSet;
     537           0 :     delete pNumberInfoItem;
     538           0 :     delete pDlg;
     539           0 : }
     540             : 
     541             : //------------------------------------------------------------------
     542             : 
     543         391 : bool ScTabViewShell::IsRefInputMode() const
     544             : {
     545         391 :     ScModule* pScMod = SC_MOD();
     546         391 :     if ( pScMod )
     547             :     {
     548         391 :         if( pScMod->IsRefDialogOpen() )
     549           0 :             return pScMod->IsFormulaMode();
     550         391 :         if( pScMod->IsFormulaMode() )
     551             :         {
     552           0 :             ScInputHandler* pHdl = pScMod->GetInputHdl();
     553           0 :             if ( pHdl )
     554             :             {
     555           0 :                 String aString = pHdl->GetEditString();
     556           0 :                 if ( !pHdl->GetSelIsRef() && aString.Len() > 1 &&
     557           0 :                      ( aString.GetChar(0) == '+' || aString.GetChar(0) == '-' ) )
     558             :                 {
     559           0 :                     const ScViewData* pViewData = GetViewData();
     560           0 :                     if ( pViewData )
     561             :                     {
     562           0 :                         ScDocument* pDoc = pViewData->GetDocument();
     563           0 :                         if ( pDoc )
     564             :                         {
     565           0 :                             const ScAddress aPos( pViewData->GetCurPos() );
     566           0 :                             ScCompiler aComp( pDoc, aPos );
     567           0 :                             aComp.SetGrammar(pDoc->GetGrammar());
     568           0 :                             aComp.SetCloseBrackets( false );
     569           0 :                             ScTokenArray* pArr = aComp.CompileString( aString );
     570           0 :                             if ( pArr && pArr->MayReferenceFollow() )
     571             :                             {
     572           0 :                                 return true;
     573           0 :                             }
     574             :                         }
     575             :                     }
     576             :                 }
     577             :                 else
     578             :                 {
     579           0 :                     return true;
     580           0 :                 }
     581             :             }
     582             :         }
     583             :     }
     584             : 
     585         391 :     return false;
     586             : }
     587             : 
     588             : //------------------------------------------------------------------
     589             : 
     590          11 : void ScTabViewShell::ExecuteInputDirect()
     591             : {
     592          11 :     if ( !IsRefInputMode() )
     593             :     {
     594          11 :         ScModule* pScMod = SC_MOD();
     595          11 :         if ( pScMod )
     596             :         {
     597          11 :             pScMod->InputEnterHandler();
     598             :         }
     599             :     }
     600          11 : }
     601             : 
     602             : //------------------------------------------------------------------
     603             : 
     604        1759 : void ScTabViewShell::UpdateInputHandler( sal_Bool bForce /* = sal_False */, sal_Bool bStopEditing /* = sal_True */ )
     605             : {
     606        1759 :     ScInputHandler* pHdl = pInputHandler ? pInputHandler : SC_MOD()->GetInputHdl();
     607             : 
     608        1759 :     if ( pHdl )
     609             :     {
     610        1759 :         String                  aString;
     611        1759 :         const EditTextObject*   pObject     = NULL;
     612        1759 :         ScViewData*             pViewData   = GetViewData();
     613        1759 :         ScDocument*             pDoc        = pViewData->GetDocument();
     614             :         CellType                eType;
     615        1759 :         SCCOL                   nPosX       = pViewData->GetCurX();
     616        1759 :         SCROW                   nPosY       = pViewData->GetCurY();
     617        1759 :         SCTAB                   nTab        = pViewData->GetTabNo();
     618        1759 :         SCTAB                   nStartTab   = 0;
     619        1759 :         SCTAB                   nEndTab     = 0;
     620        1759 :         SCCOL                   nStartCol   = 0;
     621        1759 :         SCROW                   nStartRow   = 0;
     622        1759 :         SCCOL                   nEndCol     = 0;
     623        1759 :         SCROW                   nEndRow     = 0;
     624        1759 :         ScAddress aPos = pViewData->GetCurPos();
     625             : 
     626             :         pViewData->GetSimpleArea( nStartCol, nStartRow, nStartTab,
     627        1759 :                                   nEndCol,   nEndRow,   nEndTab );
     628             : 
     629        1759 :         PutInOrder( nStartCol, nEndCol );
     630        1759 :         PutInOrder( nStartRow, nEndRow );
     631        1759 :         PutInOrder( nStartTab, nEndTab );
     632             : 
     633        1759 :         bool bHideFormula = false;
     634        1759 :         bool bHideAll     = false;
     635             : 
     636        1759 :         if (pDoc->IsTabProtected(nTab))
     637             :         {
     638             :             const ScProtectionAttr* pProt = (const ScProtectionAttr*)
     639             :                                             pDoc->GetAttr( nPosX,nPosY,nTab,
     640           0 :                                                            ATTR_PROTECTION);
     641           0 :             bHideFormula = pProt->GetHideFormula();
     642           0 :             bHideAll     = pProt->GetHideCell();
     643             :         }
     644             : 
     645        1759 :         if (!bHideAll)
     646             :         {
     647        1759 :             eType = pDoc->GetCellType(aPos);
     648        1759 :             if (eType == CELLTYPE_FORMULA)
     649             :             {
     650          25 :                 if (!bHideFormula)
     651          25 :                     pDoc->GetFormula( nPosX, nPosY, nTab, aString );
     652             :             }
     653        1734 :             else if (eType == CELLTYPE_EDIT)
     654             :             {
     655          15 :                 pObject = pDoc->GetEditText(aPos);
     656             :             }
     657             :             else
     658             :             {
     659        1719 :                 pDoc->GetInputString( nPosX, nPosY, nTab, aString );
     660        1719 :                 if (eType == CELLTYPE_STRING)
     661             :                 {
     662             :                     //  Bei Bedarf ein ' vorneweg, damit der String nicht ungewollt
     663             :                     //  als Zahl interpretiert wird, und um dem Benutzer zu zeigen,
     664             :                     //  dass es ein String ist (#35060#).
     665             :                     //! Auch bei Zahlformat "Text"? -> dann beim Editieren wegnehmen
     666             : 
     667         145 :                     SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
     668             :                     sal_uInt32 nNumFmt;
     669         145 :                     pDoc->GetNumberFormat( nPosX, nPosY, nTab, nNumFmt );
     670             :                     double fDummy;
     671         145 :                     if ( pFormatter->IsNumberFormat(aString, nNumFmt, fDummy) )
     672           0 :                         aString.Insert('\'',0);
     673             :                 }
     674             :             }
     675             :         }
     676             : 
     677             :         ScInputHdlState aState( ScAddress( nPosX,     nPosY,     nTab ),
     678             :                                 ScAddress( nStartCol, nStartRow, nTab ),
     679             :                                 ScAddress( nEndCol,   nEndRow,   nTab ),
     680             :                                 aString,
     681        3518 :                                 pObject );
     682             : 
     683             :         //  if using the view's local input handler, this view can always be set
     684             :         //  as current view inside NotifyChange.
     685        1759 :         ScTabViewShell* pSourceSh = pInputHandler ? this : NULL;
     686             : 
     687        3518 :         pHdl->NotifyChange( &aState, bForce, pSourceSh, bStopEditing );
     688             :     }
     689             : 
     690        1759 :     SfxBindings& rBindings = GetViewFrame()->GetBindings();
     691        1759 :     rBindings.Invalidate( SID_STATUS_SUM );         // immer zusammen mit Eingabezeile
     692        1759 :     rBindings.Invalidate( SID_ATTR_SIZE );
     693        1759 :     rBindings.Invalidate( SID_TABLE_CELL );
     694        1759 : }
     695             : 
     696           0 : void ScTabViewShell::UpdateInputHandlerCellAdjust( SvxCellHorJustify eJust )
     697             : {
     698           0 :     if( ScInputHandler* pHdl = pInputHandler ? pInputHandler : SC_MOD()->GetInputHdl() )
     699           0 :         pHdl->UpdateCellAdjust( eJust );
     700           0 : }
     701             : 
     702             : //------------------------------------------------------------------
     703             : 
     704           0 : void ScTabViewShell::ExecuteSave( SfxRequest& rReq )
     705             : {
     706             :     // only SID_SAVEDOC / SID_SAVEASDOC
     707             : 
     708             :     // Finish entering in any case, even if a formula is being processed
     709           0 :     SC_MOD()->InputEnterHandler();
     710             : 
     711           0 :     if ( GetViewData()->GetDocShell()->IsDocShared() )
     712             :     {
     713           0 :         GetViewData()->GetDocShell()->SetDocumentModified();
     714             :     }
     715             : 
     716             :     // otherwise as normal
     717           0 :     GetViewData()->GetDocShell()->ExecuteSlot( rReq );
     718           0 : }
     719             : 
     720         360 : void ScTabViewShell::GetSaveState( SfxItemSet& rSet )
     721             : {
     722         360 :     SfxShell* pDocSh = GetViewData()->GetDocShell();
     723             : 
     724         360 :     SfxWhichIter aIter(rSet);
     725         360 :     sal_uInt16 nWhich = aIter.FirstWhich();
     726        1138 :     while( nWhich )
     727             :     {
     728         418 :         if ( nWhich != SID_SAVEDOC || !GetViewData()->GetDocShell()->IsDocShared() )
     729             :         {
     730             :             // get state from DocShell
     731         418 :             pDocSh->GetSlotState( nWhich, NULL, &rSet );
     732             :         }
     733         418 :         nWhich = aIter.NextWhich();
     734         360 :     }
     735         360 : }
     736             : 
     737           0 : void ScTabViewShell::ExecDrawOpt( SfxRequest& rReq )
     738             : {
     739           0 :     ScViewOptions aViewOptions = GetViewData()->GetOptions();
     740           0 :     ScGridOptions aGridOptions = aViewOptions.GetGridOptions();
     741             : 
     742           0 :     SfxBindings& rBindings = GetViewFrame()->GetBindings();
     743           0 :     const SfxItemSet* pArgs = rReq.GetArgs();
     744             :     const SfxPoolItem* pItem;
     745           0 :     sal_uInt16 nSlotId = rReq.GetSlot();
     746           0 :     switch (nSlotId)
     747             :     {
     748             :         case SID_GRID_VISIBLE:
     749           0 :             if ( pArgs && pArgs->GetItemState(nSlotId,sal_True,&pItem) == SFX_ITEM_SET )
     750             :             {
     751           0 :                 aGridOptions.SetGridVisible( ((const SfxBoolItem*)pItem)->GetValue() );
     752           0 :                 aViewOptions.SetGridOptions(aGridOptions);
     753           0 :                 rBindings.Invalidate(SID_GRID_VISIBLE);
     754             :             }
     755           0 :             break;
     756             : 
     757             :         case SID_GRID_USE:
     758           0 :             if ( pArgs && pArgs->GetItemState(nSlotId,sal_True,&pItem) == SFX_ITEM_SET )
     759             :             {
     760           0 :                 aGridOptions.SetUseGridSnap( ((const SfxBoolItem*)pItem)->GetValue() );
     761           0 :                 aViewOptions.SetGridOptions(aGridOptions);
     762           0 :                 rBindings.Invalidate(SID_GRID_USE);
     763             :             }
     764           0 :             break;
     765             : 
     766             :         case SID_HELPLINES_MOVE:
     767           0 :             if ( pArgs && pArgs->GetItemState(nSlotId,sal_True,&pItem) == SFX_ITEM_SET )
     768             :             {
     769           0 :                 aViewOptions.SetOption( VOPT_HELPLINES, ((const SfxBoolItem*)pItem)->GetValue() );
     770           0 :                 rBindings.Invalidate(SID_HELPLINES_MOVE);
     771             :             }
     772           0 :             break;
     773             :     }
     774             : 
     775           0 :     GetViewData()->SetOptions(aViewOptions);
     776           0 : }
     777             : 
     778           0 : void ScTabViewShell::GetDrawOptState( SfxItemSet& rSet )
     779             : {
     780           0 :     SfxBoolItem aBool;
     781             : 
     782           0 :     const ScViewOptions& rViewOptions = GetViewData()->GetOptions();
     783           0 :     const ScGridOptions& rGridOptions = rViewOptions.GetGridOptions();
     784             : 
     785           0 :     aBool.SetValue(rGridOptions.GetGridVisible());
     786           0 :     aBool.SetWhich( SID_GRID_VISIBLE );
     787           0 :     rSet.Put( aBool );
     788             : 
     789           0 :     aBool.SetValue(rGridOptions.GetUseGridSnap());
     790           0 :     aBool.SetWhich( SID_GRID_USE );
     791           0 :     rSet.Put( aBool );
     792             : 
     793           0 :     aBool.SetValue(rViewOptions.GetOption( VOPT_HELPLINES ));
     794           0 :     aBool.SetWhich( SID_HELPLINES_MOVE );
     795           0 :     rSet.Put( aBool );
     796          93 : }
     797             : 
     798             : 
     799             : 
     800             : 
     801             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10