Anonymous avatar Anonymous committed 0cb8f41 Merge

CWS-TOOLING: integrate CWS calc58

Comments (0)

Files changed (7)

chart2/source/controller/main/ChartController_Tools.cxx

     else
     {
         //remove additional shape
-        uno::Reference< drawing::XShape > xShape( m_aSelection.getSelectedAdditionalShape() );
-        if( xShape.is() )
+        impl_ClearSelection();
         {
-            impl_ClearSelection();
+            ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+            if ( m_pDrawViewWrapper )
             {
-                ::vos::OGuard aSolarGuard( Application::GetSolarMutex());
-                if( m_pDrawViewWrapper )
-                    m_pDrawViewWrapper->UnmarkAll();
+                m_pDrawViewWrapper->DeleteMarked();
+                bReturn = true;
             }
-            bReturn = DrawModelWrapper::removeShape( xShape );
         }
     }
     return bReturn;

chart2/source/model/main/ChartModel.cxx

 {
     if( nAspect == embed::Aspects::MSOLE_CONTENT )
     {
+        ControllerLockGuard aLockGuard( this );
         bool bChanged =
             (m_aVisualAreaSize.Width != aSize.Width ||
              m_aVisualAreaSize.Height != aSize.Height);

sc/inc/scmatrix.hxx

     mutable ULONG   nRefCnt;    // reference count
     SCSIZE          nColCount;
     SCSIZE          nRowCount;
+    bool            mbCloneIfConst;     // Whether the matrix is cloned with a CloneIfConst() call.
 
     void ResetIsString();
     void DeleteIsString();
     /** If nC*nR results in more than GetElementsMax() entries, a 1x1 matrix is
         created instead and a double error value (errStackOverflow) is set.
         Compare nC and nR with a GetDimensions() call to check. */
-    ScMatrix( SCSIZE nC, SCSIZE nR) : nRefCnt(0) { CreateMatrix( nC, nR); }
+    ScMatrix( SCSIZE nC, SCSIZE nR) : nRefCnt(0), mbCloneIfConst(true) { CreateMatrix( nC, nR); }
 
     /** Clone the matrix. */
     ScMatrix* Clone() const;
 
+    /** Clone the matrix if mbCloneIfConst (immutable) is set, otherwise 
+        return _this_ matrix, to be assigned to a ScMatrixRef. */
+    ScMatrix* CloneIfConst();
+
+    /** Set the matrix to (im)mutable for CloneIfConst(), only the interpreter 
+        should do this and know the consequences. */
+    inline void SetImmutable( bool bVal ) { mbCloneIfConst = bVal; }
+
     /** 
      * Resize the matrix to specified new dimension.  Note that this operation
      * clears all stored values. 

sc/source/core/tool/interpr1.cxx

     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScN" );
     USHORT nErr = nGlobalError;
     nGlobalError = 0;
-    double fVal;
-    if ( GetRawStackType() == svString )
-    {
-        fVal = 0.0;
-        Pop();
-    }
-    else
-    {
-        // Temporarily override the ConvertStringToValue() error for 
-        // GetCellValue() / GetCellValueOrZero()
-        USHORT nSErr = mnStringNoValueError;
-        mnStringNoValueError = errCellNoValue;
-        fVal = GetDouble();
-        mnStringNoValueError = nSErr;
-    }
-    if ( nGlobalError == NOTAVAILABLE || nGlobalError == errIllegalArgument )
+    // Temporarily override the ConvertStringToValue() error for 
+    // GetCellValue() / GetCellValueOrZero()
+    USHORT nSErr = mnStringNoValueError;
+    mnStringNoValueError = errCellNoValue;
+    double fVal = GetDouble();
+    mnStringNoValueError = nSErr;
+    if ( nGlobalError == NOTAVAILABLE || nGlobalError == errCellNoValue )
         nGlobalError = 0;       // N(#NA) and N("text") are ok
     if ( !nGlobalError && nErr != NOTAVAILABLE )
         nGlobalError = nErr;
             case svDouble:
                 fVal = PopDouble();
                 break;
-            case svString:
-                aStr = PopString();
-                bString = true;
-                break;
             default:
                 {
                     FormulaTokenRef xTok( PopToken());

sc/source/core/tool/interpr4.cxx

 {
     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ConvertStringToValue" );
     double fValue = 0.0;
+    if (mnStringNoValueError == errCellNoValue)
+    {
+        // Requested that all strings result in 0, error handled by caller.
+        SetError( mnStringNoValueError);
+        return fValue;
+    }
     ::rtl::OUString aStr( rStr);
     rtl_math_ConversionStatus eStatus;
     sal_Int32 nParseEnd;
     while( maxsp-- )
         (*p++)->DecRef();
 
-    return xResult->GetType();
+    StackVar eType = xResult->GetType();
+    if (eType == svMatrix)
+        // Results are immutable in case they would be reused as input for new 
+        // interpreters.
+        static_cast<ScToken*>(xResult.operator->())->GetMatrix()->SetImmutable( true);
+    return eType;
 }

sc/source/core/tool/interpr5.cxx

     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::GetNewMat" );
     ScMatrix* pMat = new ScMatrix( nC, nR);
     pMat->SetErrorInterpreter( this);
+    // A temporary matrix is mutable and ScMatrix::CloneIfConst() returns the 
+    // very matrix.
+    pMat->SetImmutable( false);
     SCSIZE nCols, nRows;
     pMat->GetDimensions( nCols, nRows);
     if ( nCols != nC || nRows != nR )
         {
             PushIllegalArgument();
             return false;
-        } // if (!pMatY->IsValue(i))
-    } // for ( SCSIZE i = 0; i < nCountY; i++ )
+        }
+    }
+
     if ( _bLOG )
     {
+        ScMatrixRef pNewY = pMatY->CloneIfConst();
         for (SCSIZE nElem = 0; nElem < nCountY; nElem++)
         {
-            const double fVal = pMatY->GetDouble(nElem);
+            const double fVal = pNewY->GetDouble(nElem);
             if (fVal <= 0.0)
             {
                 PushIllegalArgument();
                 return false;
             }
             else
-                pMatY->PutDouble(log(fVal), nElem);
-        } // for (nElem = 0; nElem < nCountY; nElem++)
-    } // if ( _bRKP )
-    
-    
+                pNewY->PutDouble(log(fVal), nElem);
+        }
+        pMatY = pNewY;
+    }
+
     if (pMatX)
     {
         pMatX->GetDimensions(nCX, nRX);

sc/source/core/tool/scmatrix.cxx

 	return pScMat;
 }
 
+ScMatrix* ScMatrix::CloneIfConst()
+{
+    return (mbCloneIfConst || IsEternalRef()) ? Clone() : this;
+}
+
 void ScMatrix::Resize( SCSIZE nC, SCSIZE nR)
 {
     Clear();
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.