LCOV - code coverage report
Current view: top level - sc/source/ui/Accessibility - AccessibleCell.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 309 0.0 %
Date: 2014-04-14 Functions: 0 39 0.0 %
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 "AccessibleCell.hxx"
      21             : #include "scitems.hxx"
      22             : #include <editeng/eeitem.hxx>
      23             : 
      24             : 
      25             : #include "AccessibleText.hxx"
      26             : #include "AccessibleDocument.hxx"
      27             : #include "tabvwsh.hxx"
      28             : #include "document.hxx"
      29             : #include "attrib.hxx"
      30             : #include "miscuno.hxx"
      31             : #include "editsrc.hxx"
      32             : #include "dociter.hxx"
      33             : #include "markdata.hxx"
      34             : #include "cellvalue.hxx"
      35             : #include "formulaiter.hxx"
      36             : #include "validat.hxx"
      37             : 
      38             : #include <unotools/accessiblestatesethelper.hxx>
      39             : #include <com/sun/star/accessibility/AccessibleRole.hpp>
      40             : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      41             : #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
      42             : #include <com/sun/star/accessibility/XAccessibleTable.hpp>
      43             : #include <editeng/brushitem.hxx>
      44             : #include <comphelper/sequence.hxx>
      45             : #include <float.h>
      46             : #include <vcl/svapp.hxx>
      47             : 
      48             : #include "AccessibleSpreadsheet.hxx"
      49             : 
      50             : using namespace ::com::sun::star;
      51             : using namespace ::com::sun::star::accessibility;
      52             : 
      53           0 : rtl::Reference<ScAccessibleCell> ScAccessibleCell::create(
      54             :         const uno::Reference<XAccessible>& rxParent,
      55             :         ScTabViewShell* pViewShell,
      56             :         ScAddress& rCellAddress,
      57             :         sal_Int32 nIndex,
      58             :         ScSplitPos eSplitPos,
      59             :         ScAccessibleDocument* pAccDoc)
      60             : {
      61             :     rtl::Reference<ScAccessibleCell> x(new ScAccessibleCell(
      62           0 :         rxParent, pViewShell, rCellAddress, nIndex, eSplitPos, pAccDoc));
      63           0 :     x->Init();
      64           0 :     return x;
      65             : }
      66             : 
      67           0 : ScAccessibleCell::ScAccessibleCell(
      68             :         const uno::Reference<XAccessible>& rxParent,
      69             :         ScTabViewShell* pViewShell,
      70             :         ScAddress& rCellAddress,
      71             :         sal_Int32 nIndex,
      72             :         ScSplitPos eSplitPos,
      73             :         ScAccessibleDocument* pAccDoc)
      74             :     :
      75             :     ScAccessibleCellBase(rxParent, GetDocument(pViewShell), rCellAddress, nIndex),
      76             :         ::accessibility::AccessibleStaticTextBase(CreateEditSource(pViewShell, rCellAddress, eSplitPos)),
      77             :     mpViewShell(pViewShell),
      78             :     mpAccDoc(pAccDoc),
      79           0 :     meSplitPos(eSplitPos)
      80             : {
      81           0 :     if (pViewShell)
      82           0 :         pViewShell->AddAccessibilityObject(*this);
      83           0 : }
      84             : 
      85           0 : ScAccessibleCell::~ScAccessibleCell()
      86             : {
      87           0 :     if (!ScAccessibleContextBase::IsDefunc() && !rBHelper.bInDispose)
      88             :     {
      89             :         // increment refcount to prevent double call off dtor
      90           0 :         osl_atomic_increment( &m_refCount );
      91             :         // call dispose to inform object which have a weak reference to this object
      92           0 :         dispose();
      93             :     }
      94           0 : }
      95             : 
      96           0 : void ScAccessibleCell::Init()
      97             : {
      98           0 :     ScAccessibleCellBase::Init();
      99             : 
     100           0 :     SetEventSource(this);
     101           0 : }
     102             : 
     103           0 : void SAL_CALL ScAccessibleCell::disposing()
     104             : {
     105           0 :     SolarMutexGuard aGuard;
     106             :     // dispose in AccessibleStaticTextBase
     107           0 :     Dispose();
     108             : 
     109           0 :     if (mpViewShell)
     110             :     {
     111           0 :         mpViewShell->RemoveAccessibilityObject(*this);
     112           0 :         mpViewShell = NULL;
     113             :     }
     114           0 :     mpAccDoc = NULL;
     115             : 
     116           0 :     ScAccessibleCellBase::disposing();
     117           0 : }
     118             : 
     119             :     //=====  XInterface  =====================================================
     120             : 
     121           0 : IMPLEMENT_FORWARD_XINTERFACE3( ScAccessibleCell, ScAccessibleCellBase, AccessibleStaticTextBase, ScAccessibleCellAttributeImpl )
     122             : 
     123             :     //=====  XTypeProvider  ===================================================
     124             : 
     125           0 : IMPLEMENT_FORWARD_XTYPEPROVIDER3( ScAccessibleCell, ScAccessibleCellBase, AccessibleStaticTextBase, ScAccessibleCellAttributeImpl )
     126             : 
     127             :     //=====  XAccessibleComponent  ============================================
     128             : 
     129           0 : uno::Reference< XAccessible > SAL_CALL ScAccessibleCell::getAccessibleAtPoint(
     130             :         const awt::Point& rPoint )
     131             :         throw (uno::RuntimeException, std::exception)
     132             : {
     133           0 :     return AccessibleStaticTextBase::getAccessibleAtPoint(rPoint);
     134             : }
     135             : 
     136           0 : void SAL_CALL ScAccessibleCell::grabFocus(  )
     137             :         throw (uno::RuntimeException, std::exception)
     138             : {
     139           0 :      SolarMutexGuard aGuard;
     140           0 :     IsObjectValid();
     141           0 :     if (getAccessibleParent().is() && mpViewShell)
     142             :     {
     143           0 :         uno::Reference<XAccessibleComponent> xAccessibleComponent(getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY);
     144           0 :         if (xAccessibleComponent.is())
     145             :         {
     146           0 :             xAccessibleComponent->grabFocus();
     147           0 :             mpViewShell->SetCursor(maCellAddress.Col(), maCellAddress.Row());
     148           0 :         }
     149           0 :     }
     150           0 : }
     151             : 
     152           0 : Rectangle ScAccessibleCell::GetBoundingBoxOnScreen(void) const
     153             :         throw (uno::RuntimeException, std::exception)
     154             : {
     155           0 :     Rectangle aCellRect(GetBoundingBox());
     156           0 :     if (mpViewShell)
     157             :     {
     158           0 :         Window* pWindow = mpViewShell->GetWindowByPos(meSplitPos);
     159           0 :         if (pWindow)
     160             :         {
     161           0 :             Rectangle aRect = pWindow->GetWindowExtentsRelative(NULL);
     162           0 :             aCellRect.setX(aCellRect.getX() + aRect.getX());
     163           0 :             aCellRect.setY(aCellRect.getY() + aRect.getY());
     164             :         }
     165             :     }
     166           0 :     return aCellRect;
     167             : }
     168             : 
     169           0 : Rectangle ScAccessibleCell::GetBoundingBox() const
     170             :         throw (uno::RuntimeException, std::exception)
     171             : {
     172           0 :     Rectangle aCellRect;
     173           0 :     if (mpViewShell)
     174             :     {
     175             :         long nSizeX, nSizeY;
     176             :         mpViewShell->GetViewData()->GetMergeSizePixel(
     177           0 :             maCellAddress.Col(), maCellAddress.Row(), nSizeX, nSizeY);
     178           0 :         aCellRect.SetSize(Size(nSizeX, nSizeY));
     179           0 :         aCellRect.SetPos(mpViewShell->GetViewData()->GetScrPos(maCellAddress.Col(), maCellAddress.Row(), meSplitPos, true));
     180             : 
     181           0 :         Window* pWindow = mpViewShell->GetWindowByPos(meSplitPos);
     182           0 :         if (pWindow)
     183             :         {
     184           0 :             Rectangle aRect(pWindow->GetWindowExtentsRelative(pWindow->GetAccessibleParentWindow()));
     185           0 :             aRect.Move(-aRect.Left(), -aRect.Top());
     186           0 :             aCellRect = aRect.Intersection(aCellRect);
     187             :         }
     188             : 
     189             :         /*  #i19430# Gnopernicus reads text partly if it sticks out of the cell
     190             :             boundaries. This leads to wrong results in cases where the cell
     191             :             text is rotated, because rotation is not taken into account when
     192             :             calculating the visible part of the text. In these cases we will
     193             :             simply expand the cell size to the width of the unrotated text. */
     194           0 :         if (mpDoc)
     195             :         {
     196             :             const SfxInt32Item* pItem = static_cast< const SfxInt32Item* >(
     197           0 :                 mpDoc->GetAttr( maCellAddress.Col(), maCellAddress.Row(), maCellAddress.Tab(), ATTR_ROTATE_VALUE ) );
     198           0 :             if( pItem && (pItem->GetValue() != 0) )
     199             :             {
     200           0 :                 Rectangle aParaRect = GetParagraphBoundingBox();
     201           0 :                 if( !aParaRect.IsEmpty() && (aCellRect.GetWidth() < aParaRect.GetWidth()) )
     202           0 :                     aCellRect.SetSize( Size( aParaRect.GetWidth(), aCellRect.GetHeight() ) );
     203             :             }
     204             :         }
     205             :     }
     206           0 :     if (aCellRect.IsEmpty())
     207           0 :         aCellRect.SetPos(Point(-1, -1));
     208           0 :     return aCellRect;
     209             : }
     210             : 
     211             :     //=====  XAccessibleContext  ==============================================
     212             : 
     213             : sal_Int32 SAL_CALL
     214           0 :     ScAccessibleCell::getAccessibleChildCount(void)
     215             :                     throw (uno::RuntimeException, std::exception)
     216             : {
     217           0 :     return AccessibleStaticTextBase::getAccessibleChildCount();
     218             : }
     219             : 
     220             : uno::Reference< XAccessible > SAL_CALL
     221           0 :     ScAccessibleCell::getAccessibleChild(sal_Int32 nIndex)
     222             :         throw (uno::RuntimeException,
     223             :         lang::IndexOutOfBoundsException, std::exception)
     224             : {
     225           0 :     return AccessibleStaticTextBase::getAccessibleChild(nIndex);
     226             : }
     227             : 
     228             : uno::Reference<XAccessibleStateSet> SAL_CALL
     229           0 :     ScAccessibleCell::getAccessibleStateSet(void)
     230             :     throw (uno::RuntimeException, std::exception)
     231             : {
     232           0 :     SolarMutexGuard aGuard;
     233           0 :     uno::Reference<XAccessibleStateSet> xParentStates;
     234           0 :     if (getAccessibleParent().is())
     235             :     {
     236           0 :         uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext();
     237           0 :         xParentStates = xParentContext->getAccessibleStateSet();
     238             :     }
     239           0 :     utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper();
     240           0 :     if (IsDefunc(xParentStates))
     241           0 :         pStateSet->AddState(AccessibleStateType::DEFUNC);
     242             :     else
     243             :     {
     244           0 :         if (IsFormulaMode())
     245             :         {
     246           0 :             pStateSet->AddState(AccessibleStateType::ENABLED);
     247           0 :             pStateSet->AddState(AccessibleStateType::MULTI_LINE);
     248           0 :             pStateSet->AddState(AccessibleStateType::MULTI_SELECTABLE);
     249           0 :             if (IsOpaque(xParentStates))
     250           0 :                 pStateSet->AddState(AccessibleStateType::OPAQUE);
     251           0 :             pStateSet->AddState(AccessibleStateType::SELECTABLE);
     252           0 :             if (IsSelected())
     253           0 :                 pStateSet->AddState(AccessibleStateType::SELECTED);
     254           0 :             if (isShowing())
     255           0 :                 pStateSet->AddState(AccessibleStateType::SHOWING);
     256           0 :             pStateSet->AddState(AccessibleStateType::TRANSIENT);
     257           0 :             if (isVisible())
     258           0 :                 pStateSet->AddState(AccessibleStateType::VISIBLE);
     259           0 :             return pStateSet;
     260             :         }
     261           0 :         if (IsEditable(xParentStates))
     262             :         {
     263           0 :             pStateSet->AddState(AccessibleStateType::EDITABLE);
     264           0 :             pStateSet->AddState(AccessibleStateType::RESIZABLE);
     265             :         }
     266           0 :         pStateSet->AddState(AccessibleStateType::ENABLED);
     267           0 :         pStateSet->AddState(AccessibleStateType::MULTI_LINE);
     268           0 :         pStateSet->AddState(AccessibleStateType::MULTI_SELECTABLE);
     269           0 :         pStateSet->AddState(AccessibleStateType::FOCUSABLE);
     270           0 :         if (IsOpaque(xParentStates))
     271           0 :             pStateSet->AddState(AccessibleStateType::OPAQUE);
     272           0 :         pStateSet->AddState(AccessibleStateType::SELECTABLE);
     273           0 :         if (IsSelected())
     274           0 :             pStateSet->AddState(AccessibleStateType::SELECTED);
     275           0 :         if (isShowing())
     276           0 :             pStateSet->AddState(AccessibleStateType::SHOWING);
     277           0 :         pStateSet->AddState(AccessibleStateType::TRANSIENT);
     278           0 :         if (isVisible())
     279           0 :             pStateSet->AddState(AccessibleStateType::VISIBLE);
     280             :     }
     281           0 :     return pStateSet;
     282             : }
     283             : 
     284             : uno::Reference<XAccessibleRelationSet> SAL_CALL
     285           0 :        ScAccessibleCell::getAccessibleRelationSet()
     286             :     throw (uno::RuntimeException, std::exception)
     287             : {
     288           0 :     SolarMutexGuard aGuard;
     289           0 :     IsObjectValid();
     290           0 :     utl::AccessibleRelationSetHelper* pRelationSet = NULL;
     291           0 :     if (mpAccDoc)
     292           0 :         pRelationSet = mpAccDoc->GetRelationSet(&maCellAddress);
     293           0 :     if (!pRelationSet)
     294           0 :         pRelationSet = new utl::AccessibleRelationSetHelper();
     295           0 :     FillDependends(pRelationSet);
     296           0 :     FillPrecedents(pRelationSet);
     297           0 :     return pRelationSet;
     298             : }
     299             : 
     300             :     //=====  XServiceInfo  ====================================================
     301             : 
     302           0 : OUString SAL_CALL ScAccessibleCell::getImplementationName(void)
     303             :         throw (uno::RuntimeException, std::exception)
     304             : {
     305           0 :     return OUString("ScAccessibleCell");
     306             : }
     307             : 
     308             : uno::Sequence< OUString> SAL_CALL
     309           0 :     ScAccessibleCell::getSupportedServiceNames(void)
     310             :         throw (uno::RuntimeException, std::exception)
     311             : {
     312           0 :     uno::Sequence< OUString > aSequence = ScAccessibleContextBase::getSupportedServiceNames();
     313           0 :     sal_Int32 nOldSize(aSequence.getLength());
     314           0 :     aSequence.realloc(nOldSize + 1);
     315             : 
     316           0 :     aSequence[nOldSize] = "com.sun.star.sheet.AccessibleCell";
     317             : 
     318           0 :     return aSequence;
     319             : }
     320             : 
     321             :     //====  internal  =========================================================
     322             : 
     323           0 : bool ScAccessibleCell::IsDefunc(
     324             :     const uno::Reference<XAccessibleStateSet>& rxParentStates)
     325             : {
     326           0 :     return ScAccessibleContextBase::IsDefunc() || (mpDoc == NULL) || (mpViewShell == NULL) || !getAccessibleParent().is() ||
     327           0 :          (rxParentStates.is() && rxParentStates->contains(AccessibleStateType::DEFUNC));
     328             : }
     329             : 
     330           0 : bool ScAccessibleCell::IsEditable(
     331             :     const uno::Reference<XAccessibleStateSet>& rxParentStates)
     332             : {
     333           0 :     bool bEditable(true);
     334           0 :     if (rxParentStates.is() && !rxParentStates->contains(AccessibleStateType::EDITABLE) &&
     335             :         mpDoc)
     336             :     {
     337             :         // here I have to test whether the protection of the table should influence this cell.
     338             :         const ScProtectionAttr* pItem = (const ScProtectionAttr*)mpDoc->GetAttr(
     339           0 :             maCellAddress.Col(), maCellAddress.Row(),
     340           0 :             maCellAddress.Tab(), ATTR_PROTECTION);
     341           0 :         if (pItem)
     342           0 :             bEditable = !pItem->GetProtection();
     343             :     }
     344           0 :     return bEditable;
     345             : }
     346             : 
     347           0 : bool ScAccessibleCell::IsOpaque(
     348             :     const uno::Reference<XAccessibleStateSet>& /* rxParentStates */)
     349             : {
     350             :     // test whether there is a background color
     351           0 :     bool bOpaque(true);
     352           0 :     if (mpDoc)
     353             :     {
     354             :         const SvxBrushItem* pItem = (const SvxBrushItem*)mpDoc->GetAttr(
     355           0 :             maCellAddress.Col(), maCellAddress.Row(),
     356           0 :             maCellAddress.Tab(), ATTR_BACKGROUND);
     357           0 :         if (pItem)
     358           0 :             bOpaque = pItem->GetColor() != COL_TRANSPARENT;
     359             :     }
     360           0 :     return bOpaque;
     361             : }
     362             : 
     363           0 : bool ScAccessibleCell::IsSelected()
     364             : {
     365           0 :     if (IsFormulaMode())
     366             :     {
     367           0 :         const ScAccessibleSpreadsheet *pSheet =static_cast<const ScAccessibleSpreadsheet*>(mxParent.get());
     368           0 :         if (pSheet)
     369             :         {
     370           0 :             return pSheet->IsScAddrFormulaSel(maCellAddress);
     371             :         }
     372           0 :         return false;
     373             :     }
     374             : 
     375           0 :     bool bResult(false);
     376           0 :     if (mpViewShell && mpViewShell->GetViewData())
     377             :     {
     378           0 :         const ScMarkData& rMarkdata = mpViewShell->GetViewData()->GetMarkData();
     379           0 :         bResult = rMarkdata.IsCellMarked(maCellAddress.Col(), maCellAddress.Row());
     380             :     }
     381           0 :     return bResult;
     382             : }
     383             : 
     384           0 : ScDocument* ScAccessibleCell::GetDocument(ScTabViewShell* pViewShell)
     385             : {
     386           0 :     ScDocument* pDoc = NULL;
     387           0 :     if (pViewShell && pViewShell->GetViewData())
     388           0 :         pDoc = pViewShell->GetViewData()->GetDocument();
     389           0 :     return pDoc;
     390             : }
     391             : 
     392             : SAL_WNODEPRECATED_DECLARATIONS_PUSH
     393           0 : ::std::auto_ptr< SvxEditSource > ScAccessibleCell::CreateEditSource(ScTabViewShell* pViewShell, ScAddress aCell, ScSplitPos eSplitPos)
     394             : {
     395           0 :     if (IsFormulaMode())
     396             :     {
     397           0 :         return ::std::auto_ptr< SvxEditSource >();
     398             :     }
     399             :     ::std::auto_ptr < ScAccessibleTextData > pAccessibleCellTextData
     400           0 :         ( new ScAccessibleCellTextData( pViewShell, aCell, eSplitPos, this ) );
     401           0 :     ::std::auto_ptr< SvxEditSource > pEditSource (new ScAccessibilityEditSource(pAccessibleCellTextData));
     402             : 
     403           0 :     return pEditSource;
     404             : }
     405             : SAL_WNODEPRECATED_DECLARATIONS_POP
     406             : 
     407           0 : void ScAccessibleCell::FillDependends(utl::AccessibleRelationSetHelper* pRelationSet)
     408             : {
     409           0 :     if (mpDoc)
     410             :     {
     411           0 :         ScRange aRange(0, 0, maCellAddress.Tab(), MAXCOL, MAXROW, maCellAddress.Tab());
     412           0 :         ScCellIterator aCellIter(mpDoc, aRange);
     413             : 
     414           0 :         for (bool bHasCell = aCellIter.first(); bHasCell; bHasCell = aCellIter.next())
     415             :         {
     416           0 :             if (aCellIter.getType() == CELLTYPE_FORMULA)
     417             :             {
     418           0 :                 bool bFound = false;
     419           0 :                 ScDetectiveRefIter aIter(aCellIter.getFormulaCell());
     420           0 :                 ScRange aRef;
     421           0 :                 while ( !bFound && aIter.GetNextRef( aRef ) )
     422             :                 {
     423           0 :                     if (aRef.In(maCellAddress))
     424           0 :                         bFound = true;
     425             :                 }
     426           0 :                 if (bFound)
     427           0 :                     AddRelation(aCellIter.GetPos(), AccessibleRelationType::CONTROLLER_FOR, pRelationSet);
     428             :             }
     429           0 :         }
     430             :     }
     431           0 : }
     432             : 
     433           0 : void ScAccessibleCell::FillPrecedents(utl::AccessibleRelationSetHelper* pRelationSet)
     434             : {
     435           0 :     if (mpDoc && mpDoc->GetCellType(maCellAddress) == CELLTYPE_FORMULA)
     436             :     {
     437           0 :         ScFormulaCell* pCell = mpDoc->GetFormulaCell(maCellAddress);
     438           0 :         if (!pCell)
     439           0 :             return;
     440           0 :         ScDetectiveRefIter aIter(pCell);
     441           0 :         ScRange aRef;
     442           0 :         while ( aIter.GetNextRef( aRef ) )
     443             :         {
     444           0 :             AddRelation( aRef, AccessibleRelationType::CONTROLLED_BY, pRelationSet);
     445             :         }
     446             :     }
     447             : }
     448             : 
     449           0 : void ScAccessibleCell::AddRelation(const ScAddress& rCell,
     450             :     const sal_uInt16 aRelationType,
     451             :     utl::AccessibleRelationSetHelper* pRelationSet)
     452             : {
     453           0 :     AddRelation(ScRange(rCell, rCell), aRelationType, pRelationSet);
     454           0 : }
     455             : 
     456           0 : void ScAccessibleCell::AddRelation(const ScRange& rRange,
     457             :     const sal_uInt16 aRelationType,
     458             :     utl::AccessibleRelationSetHelper* pRelationSet)
     459             : {
     460           0 :     uno::Reference < XAccessibleTable > xTable ( getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY );
     461           0 :     if (xTable.is())
     462             :     {
     463           0 :         sal_uInt32 nCount(static_cast<sal_uInt32>(rRange.aEnd.Col() -
     464           0 :                     rRange.aStart.Col() + 1) * (rRange.aEnd.Row() -
     465           0 :                     rRange.aStart.Row() + 1));
     466           0 :         uno::Sequence < uno::Reference < uno::XInterface > > aTargetSet( nCount );
     467           0 :         uno::Reference < uno::XInterface >* pTargetSet = aTargetSet.getArray();
     468           0 :         if (pTargetSet)
     469             :         {
     470           0 :             sal_uInt32 nPos(0);
     471           0 :             for (sal_uInt32 nRow = rRange.aStart.Row(); nRow <= sal::static_int_cast<sal_uInt32>(rRange.aEnd.Row()); ++nRow)
     472             :             {
     473           0 :                 for (sal_uInt32 nCol = rRange.aStart.Col(); nCol <= sal::static_int_cast<sal_uInt32>(rRange.aEnd.Col()); ++nCol)
     474             :                 {
     475           0 :                     pTargetSet[nPos] = xTable->getAccessibleCellAt(nRow, nCol);
     476           0 :                     ++nPos;
     477             :                 }
     478             :             }
     479             :             OSL_ENSURE(nCount == nPos, "something wents wrong");
     480             :         }
     481           0 :         AccessibleRelation aRelation;
     482           0 :         aRelation.RelationType = aRelationType;
     483           0 :         aRelation.TargetSet = aTargetSet;
     484           0 :         pRelationSet->AddRelation(aRelation);
     485           0 :     }
     486           0 : }
     487             : 
     488           0 : static OUString ReplaceOneChar(const OUString& oldOUString, const OUString& replacedChar, const OUString& replaceStr)
     489             : {
     490           0 :     int iReplace = oldOUString.lastIndexOf(replacedChar);
     491           0 :     OUString aRet = oldOUString;
     492           0 :     while(iReplace > -1)
     493             :     {
     494           0 :         aRet = aRet.replaceAt(iReplace, 1, replaceStr);
     495           0 :         iReplace = aRet.lastIndexOf(replacedChar, iReplace);
     496             :     }
     497           0 :     return aRet;
     498             : }
     499             : 
     500           0 : static OUString ReplaceFourChar(const OUString& oldOUString)
     501             : {
     502           0 :     OUString aRet = ReplaceOneChar(oldOUString, "\\", "\\\\");
     503           0 :     aRet = ReplaceOneChar(aRet, ";", "\\;");
     504           0 :     aRet = ReplaceOneChar(aRet, "=", "\\=");
     505           0 :     aRet = ReplaceOneChar(aRet, ",", "\\,");
     506           0 :     aRet = ReplaceOneChar(aRet, ":", "\\:");
     507           0 :     return aRet;
     508             : }
     509             : 
     510           0 : uno::Any SAL_CALL ScAccessibleCell::getExtendedAttributes()
     511             :     throw (::com::sun::star::lang::IndexOutOfBoundsException,
     512             :            ::com::sun::star::uno::RuntimeException,
     513             :            std::exception)
     514             : {
     515           0 :     SolarMutexGuard aGuard;
     516             : 
     517           0 :     uno::Any strRet;
     518           0 :     if (mpViewShell)
     519             :     {
     520           0 :         OUString strFor = mpViewShell->GetFormula(maCellAddress) ;
     521           0 :         strFor = strFor.replaceAt(0,1,"");
     522           0 :         strFor = ReplaceFourChar(strFor);
     523           0 :         strFor = "Formula:" + strFor;
     524           0 :         strFor += ";Note:";
     525           0 :         strFor += ReplaceFourChar(GetAllDisplayNote());
     526           0 :         strFor += ";";
     527           0 :         strFor += getShadowAttrs();//the string returned contains the spliter ";"
     528           0 :         strFor += getBorderAttrs();//the string returned contains the spliter ";"
     529             :         //end of cell attributes
     530           0 :         if( mpDoc )
     531             :         {
     532           0 :             strFor += "isdropdown:";
     533           0 :             if( IsDropdown() )
     534           0 :                 strFor += "true";
     535             :             else
     536           0 :                 strFor += "false";
     537           0 :             strFor += ";";
     538             :         }
     539           0 :         strRet <<= strFor ;
     540             :     }
     541           0 :     return strRet;
     542             : }
     543             : 
     544             : // cell has its own ParaIndent property, so when calling character attributes on cell, the ParaIndent should replace the ParaLeftMargin if its value is not zero.
     545           0 : uno::Sequence< beans::PropertyValue > SAL_CALL ScAccessibleCell::getCharacterAttributes( sal_Int32 nIndex, const ::com::sun::star::uno::Sequence< OUString >& aRequestedAttributes ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
     546             : {
     547           0 :     SolarMutexGuard aGuard;
     548             : 
     549           0 :     uno::Sequence< beans::PropertyValue > aAttribs = AccessibleStaticTextBase::getCharacterAttributes( nIndex, aRequestedAttributes );
     550           0 :     beans::PropertyValue *pAttribs = aAttribs.getArray();
     551             : 
     552           0 :     sal_uInt16 nParaIndent = static_cast< const SfxUInt16Item* >( mpDoc->GetAttr( maCellAddress.Col(), maCellAddress.Row(), maCellAddress.Tab(), ATTR_INDENT ) )->GetValue();
     553           0 :     if (nParaIndent > 0)
     554             :     {
     555           0 :         OUString sLeftMarginName ("ParaLeftMargin");
     556           0 :         for (int i = 0; i < aAttribs.getLength(); ++i)
     557             :         {
     558           0 :             if (sLeftMarginName == pAttribs[i].Name)
     559             :             {
     560           0 :                 pAttribs[i].Value = uno::makeAny( nParaIndent );
     561           0 :                 break;
     562             :             }
     563           0 :         }
     564             :     }
     565           0 :     return aAttribs;
     566             : }
     567             : 
     568           0 : bool ScAccessibleCell::IsFormulaMode()
     569             : {
     570           0 :     ScAccessibleSpreadsheet* pSheet = static_cast<ScAccessibleSpreadsheet*>(mxParent.get());
     571           0 :     if (pSheet)
     572             :     {
     573           0 :         return pSheet->IsFormulaMode();
     574             :     }
     575           0 :     return false;
     576             : }
     577             : 
     578           0 : bool ScAccessibleCell::IsDropdown()
     579             : {
     580           0 :     sal_uInt16 nPosX = maCellAddress.Col();
     581           0 :     sal_uInt16 nPosY = sal_uInt16(maCellAddress.Row());
     582           0 :     sal_uInt16 nTab = maCellAddress.Tab();
     583           0 :     sal_uInt32 nValidation = static_cast< const SfxUInt32Item* >( mpDoc->GetAttr( nPosX, nPosY, nTab, ATTR_VALIDDATA ) )->GetValue();
     584           0 :     if( nValidation )
     585             :     {
     586           0 :         const ScValidationData* pData = mpDoc->GetValidationEntry( nValidation );
     587           0 :         if( pData && pData->HasSelectionList() )
     588           0 :             return true;
     589             :     }
     590             :     ScMergeFlagAttr* pAttr;
     591           0 :     pAttr = (ScMergeFlagAttr*)mpDoc->GetAttr( nPosX, nPosY, nTab, ATTR_MERGE_FLAG );
     592           0 :     if( pAttr->HasAutoFilter() )
     593             :     {
     594           0 :         return true;
     595             :     }
     596             :     else
     597             :     {
     598           0 :         sal_uInt16 nTabCount = mpDoc->GetTableCount();
     599           0 :         if ( nTab+1<nTabCount && mpDoc->IsScenario(nTab+1) && !mpDoc->IsScenario(nTab) )
     600             :         {
     601             :             SCTAB i;
     602           0 :             ScMarkData aMarks;
     603           0 :             for (i=nTab+1; i<nTabCount && mpDoc->IsScenario(i); i++)
     604           0 :                 mpDoc->MarkScenario( i, nTab, aMarks, false, SC_SCENARIO_SHOWFRAME );
     605           0 :             ScRangeList aRanges;
     606           0 :             aMarks.FillRangeListWithMarks( &aRanges, false );
     607             :             sal_Bool bHasScenario;
     608           0 :             SCTAB nRangeCount = aRanges.size();
     609           0 :             for (i=0; i<nRangeCount; i++)
     610             :             {
     611           0 :                 ScRange aRange = *aRanges[i];
     612           0 :                 mpDoc->ExtendTotalMerge( aRange );
     613           0 :                 sal_Bool bTextBelow = ( aRange.aStart.Row() == 0 );
     614             :                 // MT IA2: Not used: sal_Bool bIsInScen = sal_False;
     615           0 :                 if ( bTextBelow )
     616             :                 {
     617           0 :                     bHasScenario = (aRange.aStart.Col() == nPosX && aRange.aEnd.Row() == nPosY-1);
     618             :                 }
     619             :                 else
     620             :                 {
     621           0 :                     bHasScenario = (aRange.aStart.Col() == nPosX && aRange.aStart.Row() == nPosY+1);
     622             :                 }
     623           0 :                 if( bHasScenario ) return true;
     624           0 :             }
     625             :         }
     626             :     }
     627           0 :     return false;
     628           0 : }
     629             : 
     630             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10