[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 195 commits - accessibility/bridge android/experimental basctl/source basegfx/source basic/source bin/moveglobalheaders.sh bridges/source canvas/source chart2/source comphelper/source config_host.mk.in configure.ac connectivity/source connectivity/workben cppuhelper/test cpputools/source cui/source dbaccess/inc dbaccess/source desktop/source download.lst dtrans/source editeng/source embeddedobj/source embedserv/source extensions/source external/Module_external.mk external/Package_msvc_dlls_debug.mk extras/CustomTarget_autocorr.mk extras/Package_autocorr.mk extras/source fileaccess/source filter/inc filter/source filter/uiconfig filter/UIConfig_xsltdlg.mk forms/source fpicker/source framework/source helpcontent2 i18nlangtag/source i18npool/source icon-themes/README include/canvas include/comphelper include/connectivity include/editeng include/i18nlangtag include/linguistic include/oox include/sfx2 include/sot include/sv l include/svtools include/svx include/test include/toolkit include/tools include/unotools include/vbahelper include/vcl include/xmloff io/source io/test jvmfwk/plugins l10ntools/source lotuswordpro/source mysqlc/source odk/examples offapi/com oox/source package/source padmin/source pyuno/source readlicense_oo/odt registry/test remotebridges/examples remotebridges/source reportdesign/source rsc/inc rsc/source sal/textenc sax/qa sax/source sax/test scaddins/source sc/inc sc/Library_sc.mk sc/Module_sc.mk sc/qa scripting/source sc/source sdext/source sd/inc sd/qa sd/source sfx2/sdi sfx2/source sfx2/uiconfig shell/Package_scripts.mk shell/source slideshow/source solenv/gbuild sot/source starmath/inc starmath/source starmath/uiconfig stoc/source stoc/test svl/README svl/source svtools/inc svtools/source svx/inc svx/Library_svxcore.mk svx/sdi svx/source svx/uiconfig svx/UIConfig_svx.mk svx/workben sw/inc sw/qa sw/README sw/source sw/uiconfig sw/UIConfig_swriter.mk test/source testt ools/source tomcat/ExternalProject_tomcat.mk tomcat/Package_tomcat.mk tomcat/UnpackedTarball_tomcat.mk toolkit/source tools/inc tools/qa tools/source translations ucbhelper/source ucb/source ucb/workben udkapi/com unotest/source unotools/source unusedcode.easy uui/source vbahelper/source vcl/android vcl/aqua vcl/coretext vcl/generic vcl/inc vcl/source vcl/test vcl/unx vcl/win vigra/UnpackedTarball_vigra.mk vigra/vigra1.4.0-enumwarn.patch vigra/vigra1.4.0.patch vigra/vigra1.4.0-unused-parameters.patch vigra/vigra1.6.0.patch vigra/vigra1.6.0-unused-parameters.patch wizards/com writerfilter/source xmlhelp/source xmloff/source xmlsecurity/qa xmlsecurity/source

Kohei Yoshida kohei.yoshida at gmail.com
Mon Jul 1 15:02:41 PDT 2013


Rebased ref, commits from common ancestor:
commit 2cad9051bc44db1b4d67298a82d2435119170ea4
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Jul 1 16:04:35 2013 -0400

    Reduce dependency on the matrix header.
    
    Change-Id: Iade09d108aec78f8cbe92f9103f206d0c99fab8e

diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index 836f87f..5815fd0 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -225,6 +225,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
 	sc/source/core/tool/interpr5 \
 	sc/source/core/tool/interpr6 \
 	sc/source/core/tool/interpr7 \
+	sc/source/core/tool/jumpmatrix \
 	sc/source/core/tool/lookupcache \
 	sc/source/core/tool/navicfg \
 	sc/source/core/tool/odffmap \
diff --git a/sc/inc/addincol.hxx b/sc/inc/addincol.hxx
index 15abd4c..4b440a2 100644
--- a/sc/inc/addincol.hxx
+++ b/sc/inc/addincol.hxx
@@ -32,7 +32,7 @@
 #include "scdllapi.h"
 #include <rtl/ustring.hxx>
 
-#include "scmatrix.hxx"
+#include "types.hxx"
 
 #include <boost/unordered_map.hpp>
 
@@ -233,7 +233,7 @@ public:
     bool                HasVarRes() const       { return ( xVarRes.is() ); }
     double              GetValue() const        { return fValue; }
     const OUString&     GetString() const       { return aString; }
-    ScMatrixRef         GetMatrix() const       { return xMatrix; }
+    ScMatrixRef         GetMatrix() const;
     com::sun::star::uno::Reference<com::sun::star::sheet::XVolatileResult>
                         GetVarRes() const       { return xVarRes; }
 };
diff --git a/sc/inc/externalrefmgr.hxx b/sc/inc/externalrefmgr.hxx
index 0a115c0..4e39a5d 100644
--- a/sc/inc/externalrefmgr.hxx
+++ b/sc/inc/externalrefmgr.hxx
@@ -29,7 +29,7 @@
 #include "vcl/timer.hxx"
 #include "svl/zforlist.hxx"
 #include "svl/lstner.hxx"
-#include "scmatrix.hxx"
+#include "types.hxx"
 #include "rangelst.hxx"
 #include "formula/token.hxx"
 
diff --git a/sc/inc/queryparam.hxx b/sc/inc/queryparam.hxx
index 26d2d1b..0d814cd 100644
--- a/sc/inc/queryparam.hxx
+++ b/sc/inc/queryparam.hxx
@@ -21,7 +21,7 @@
 #define SC_QUERYPARAM_HXX
 
 #include "global.hxx"
-#include "scmatrix.hxx"
+#include "types.hxx"
 
 #include <boost/ptr_container/ptr_vector.hpp>
 
diff --git a/sc/inc/rangeseq.hxx b/sc/inc/rangeseq.hxx
index bd8a900..b13233d 100644
--- a/sc/inc/rangeseq.hxx
+++ b/sc/inc/rangeseq.hxx
@@ -22,7 +22,7 @@
 
 #include <tools/solar.h>
 #include <com/sun/star/uno/Any.h>
-#include "scmatrix.hxx"
+#include "types.hxx"
 
 class SvNumberFormatter;
 class ScDocument;
diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index ccb989f..47231b3 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -34,14 +34,6 @@ class ScInterpreter;
 class SvNumberFormatter;
 class ScMatrixImpl;
 
-typedef sal_uInt8 ScMatValType;
-const ScMatValType SC_MATVAL_VALUE     = 0x00;
-const ScMatValType SC_MATVAL_BOOLEAN   = 0x01;
-const ScMatValType SC_MATVAL_STRING    = 0x02;
-const ScMatValType SC_MATVAL_EMPTY     = SC_MATVAL_STRING | 0x04; // STRING plus flag
-const ScMatValType SC_MATVAL_EMPTYPATH = SC_MATVAL_EMPTY | 0x08;  // EMPTY plus flag
-const ScMatValType SC_MATVAL_NONVALUE  = SC_MATVAL_EMPTYPATH;     // mask of all non-value bits
-
 /**
  * Try NOT to use this struct.  This struct should go away in a hopefully
  * not so distant futture.
diff --git a/sc/inc/token.hxx b/sc/inc/token.hxx
index 109980f..116022a 100644
--- a/sc/inc/token.hxx
+++ b/sc/inc/token.hxx
@@ -26,7 +26,6 @@
 
 #include "formula/opcode.hxx"
 #include "refdata.hxx"
-#include "scmatrix.hxx"
 #include <tools/mempool.hxx>
 #include "scdllapi.h"
 #include "formula/IFunctionDescription.hxx"
@@ -163,10 +162,9 @@ class ScMatrixToken : public ScToken
 private:
             ScMatrixRef         pMatrix;
 public:
-                                ScMatrixToken( ScMatrixRef p ) :
-                                    ScToken( formula::svMatrix ), pMatrix( p ) {}
-                                ScMatrixToken( const ScMatrixToken& r ) :
-                                    ScToken( r ), pMatrix( r.pMatrix ) {}
+    ScMatrixToken( const ScMatrixRef& p );
+    ScMatrixToken( const ScMatrixToken& r );
+
     virtual const ScMatrix*     GetMatrix() const;
     virtual ScMatrix*           GetMatrix();
     virtual bool                operator==( const formula::FormulaToken& rToken ) const;
@@ -311,15 +309,11 @@ class SC_DLLPUBLIC ScMatrixCellResultToken : public ScToken
     virtual ScMatrix*           GetMatrix();
 
 protected:
-            ScConstMatrixRef    xMatrix;
-            formula::FormulaConstTokenRef     xUpperLeft;
+    ScConstMatrixRef xMatrix;
+    formula::FormulaConstTokenRef     xUpperLeft;
 public:
-                                ScMatrixCellResultToken( const ScConstMatrixRef& pMat, formula::FormulaToken* pUL ) :
-                                    ScToken( formula::svMatrixCell ),
-                                    xMatrix( pMat), xUpperLeft( pUL) {}
-                                ScMatrixCellResultToken( const ScMatrixCellResultToken& r ) :
-                                    ScToken( r ), xMatrix( r.xMatrix ),
-                                    xUpperLeft( r.xUpperLeft ) {}
+    ScMatrixCellResultToken( const ScConstMatrixRef& pMat, formula::FormulaToken* pUL );
+    ScMatrixCellResultToken( const ScMatrixCellResultToken& r );
     virtual double              GetDouble() const;
     virtual const String &      GetString() const;
     virtual const ScMatrix*     GetMatrix() const;
@@ -332,11 +326,7 @@ public:
                                             static_cast<formula::StackVar>(formula::svUnknown);
                                     }
     inline formula::FormulaConstTokenRef     GetUpperLeftToken() const   { return xUpperLeft; }
-            void                Assign( const ScMatrixCellResultToken & r )
-                                    {
-                                        xMatrix = r.xMatrix;
-                                        xUpperLeft = r.xUpperLeft;
-                                    }
+    void Assign( const ScMatrixCellResultToken & r );
 };
 
 
@@ -348,22 +338,10 @@ private:
             SCROW               nRows;
             SCCOL               nCols;
 public:
-    ScMatrixFormulaCellToken( SCCOL nC, SCROW nR, const ScConstMatrixRef& pMat, formula::FormulaToken* pUL ) :
-        ScMatrixCellResultToken(pMat, pUL),
-        nRows(nR), nCols(nC) {}
-
-                                ScMatrixFormulaCellToken( SCCOL nC, SCROW nR ) :
-                                    ScMatrixCellResultToken( NULL, NULL ),
-                                    nRows( nR ), nCols( nC ) {}
-                                ScMatrixFormulaCellToken( const ScMatrixFormulaCellToken& r ) :
-                                    ScMatrixCellResultToken( r ),
-                                    nRows( r.nRows ), nCols( r.nCols )
-                                    {
-                                        // xUpperLeft is modifiable through
-                                        // SetUpperLeftDouble(), so clone it.
-                                        if (xUpperLeft)
-                                            xUpperLeft = xUpperLeft->Clone();
-                                    }
+    ScMatrixFormulaCellToken( SCCOL nC, SCROW nR, const ScConstMatrixRef& pMat, formula::FormulaToken* pUL );
+    ScMatrixFormulaCellToken( SCCOL nC, SCROW nR );
+    ScMatrixFormulaCellToken( const ScMatrixFormulaCellToken& r );
+
     virtual bool                operator==( const formula::FormulaToken& rToken ) const;
     virtual FormulaToken*       Clone() const { return new ScMatrixFormulaCellToken(*this); }
             void                SetMatColsRows( SCCOL nC, SCROW nR )
@@ -399,13 +377,9 @@ public:
                                     nothing if xUpperLeft is of different type! */
             void                SetUpperLeftDouble( double f);
 
-                                /** Reset matrix and upper left, keep matrix
-                                    formula dimension. */
-            void                ResetResult()
-                                    {
-                                        xMatrix = NULL;
-                                        xUpperLeft = NULL;
-                                    }
+    /** Reset matrix and upper left, keep matrix
+        formula dimension. */
+    void ResetResult();
 };
 
 
diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx
index 32a266d..4582c96 100644
--- a/sc/inc/tokenarray.hxx
+++ b/sc/inc/tokenarray.hxx
@@ -21,7 +21,6 @@
 #define SC_TOKENARRAY_HXX
 
 #include "formula/token.hxx"
-#include "scmatrix.hxx"
 #include <tools/solar.h>
 #include "scdllapi.h"
 #include "types.hxx"
diff --git a/sc/inc/types.hxx b/sc/inc/types.hxx
index 629ab72..487afcd 100644
--- a/sc/inc/types.hxx
+++ b/sc/inc/types.hxx
@@ -20,6 +20,14 @@ typedef ::boost::intrusive_ptr<const ScMatrix>  ScConstMatrixRef;
 class ScToken;
 typedef ::boost::intrusive_ptr<ScToken> ScTokenRef;
 
+typedef sal_uInt8 ScMatValType;
+const ScMatValType SC_MATVAL_VALUE     = 0x00;
+const ScMatValType SC_MATVAL_BOOLEAN   = 0x01;
+const ScMatValType SC_MATVAL_STRING    = 0x02;
+const ScMatValType SC_MATVAL_EMPTY     = SC_MATVAL_STRING | 0x04; // STRING plus flag
+const ScMatValType SC_MATVAL_EMPTYPATH = SC_MATVAL_EMPTY | 0x08;  // EMPTY plus flag
+const ScMatValType SC_MATVAL_NONVALUE  = SC_MATVAL_EMPTYPATH;     // mask of all non-value bits
+
 struct ScFormulaCellGroup;
 typedef ::boost::intrusive_ptr<ScFormulaCellGroup> ScFormulaCellGroupRef;
 
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index ae20e44..abe2806 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -42,6 +42,7 @@
 #include "formulagroup.hxx"
 #include "listenercontext.hxx"
 #include "mtvcellfunc.hxx"
+#include "scmatrix.hxx"
 
 #include <math.h>
 
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 60696df..02cb39b 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -37,6 +37,7 @@
 #include "globstr.hrc"
 #include "editutil.hxx"
 #include "cellvalue.hxx"
+#include "scmatrix.hxx"
 
 #include "tools/fract.hxx"
 #include "editeng/editobj.hxx"
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index f59c119..9211db8 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -43,6 +43,7 @@
 #include "attrib.hxx"
 #include "formulacell.hxx"
 #include "tokenarray.hxx"
+#include "scmatrix.hxx"
 
 using namespace formula;
 
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 02c8952..9b1ea3d 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -46,6 +46,7 @@
 #include "conditio.hxx"
 #include "globalnames.hxx"
 #include "cellvalue.hxx"
+#include "scmatrix.hxx"
 
 #include <vector>
 
diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
index f910083..175c3db 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -17,7 +17,8 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include "scitems.hxx"
+#include "validat.hxx"
+
 #include <sfx2/app.hxx>
 #include <sfx2/docfile.hxx>
 #include <sfx2/objsh.hxx>
@@ -31,7 +32,7 @@
 #include <vcl/msgbox.hxx>
 #include <rtl/math.hxx>
 
-#include "validat.hxx"
+#include "scitems.hxx"
 #include "document.hxx"
 #include "formulacell.hxx"
 #include "patattr.hxx"
@@ -43,6 +44,7 @@
 #include "dociter.hxx"
 #include "editutil.hxx"
 #include "tokenarray.hxx"
+#include "scmatrix.hxx"
 
 #include <math.h>
 #include <memory>
diff --git a/sc/source/core/inc/ddelink.hxx b/sc/source/core/inc/ddelink.hxx
index 967daae..f6ceba3 100644
--- a/sc/source/core/inc/ddelink.hxx
+++ b/sc/source/core/inc/ddelink.hxx
@@ -23,7 +23,7 @@
 #include "address.hxx"
 #include <sfx2/lnkbase.hxx>
 #include <svl/broadcast.hxx>
-#include "scmatrix.hxx"
+#include "types.hxx"
 
 class ScDocument;
 class ScMultipleReadHeader;
@@ -67,11 +67,11 @@ public:
 
                     // for interpreter:
 
-    const ScMatrix* GetResult() const           { return pResult.get(); }
-    void            SetResult( ScMatrixRef pRes ) { pResult = pRes; }
+    const ScMatrix* GetResult() const;
+    void            SetResult( const ScMatrixRef& pRes );
 
                     // XML and Excel import after NewData()
-    ScMatrixRef     GetModifiableResult()   { return pResult; }
+    ScMatrixRef     GetModifiableResult();
 
     const String&   GetAppl() const     { return aAppl; }
     const String&   GetTopic() const    { return aTopic; }
diff --git a/sc/source/core/inc/doubleref.hxx b/sc/source/core/inc/doubleref.hxx
index 1782f44..5de9c97 100644
--- a/sc/source/core/inc/doubleref.hxx
+++ b/sc/source/core/inc/doubleref.hxx
@@ -21,7 +21,7 @@
 #define SC_DOUBLEREF_HXX
 
 #include "address.hxx"
-#include "scmatrix.hxx"
+#include "types.hxx"
 
 class ScDocument;
 struct ScDBQueryParamBase;
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index 75947d6..3792383 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -26,7 +26,7 @@
 #include "formula/errorcodes.hxx"
 #include "formula/tokenarray.hxx"
 #include "scdll.hxx"
-#include "scmatrix.hxx"
+#include "types.hxx"
 #include "externalrefmgr.hxx"
 #include "calcconfig.hxx"
 #include "token.hxx"
diff --git a/sc/source/core/inc/jumpmatrix.hxx b/sc/source/core/inc/jumpmatrix.hxx
index ccd0b66..30391f9 100644
--- a/sc/source/core/inc/jumpmatrix.hxx
+++ b/sc/source/core/inc/jumpmatrix.hxx
@@ -24,7 +24,8 @@
 #include "formula/errorcodes.hxx"
 #include <tools/solar.h>
 #include <vector>
-#include "scmatrix.hxx"
+#include "types.hxx"
+#include "address.hxx"
 
 typedef ::std::vector< formula::FormulaToken*> ScTokenVec;
 
@@ -55,159 +56,35 @@ struct ScJumpMatrixEntry
 
 class ScJumpMatrix
 {
-            ScJumpMatrixEntry*  pJump;      // the jumps
-            ScMatrixRef         pMat;       // the results
-            ScTokenVec*         pParams;    // parameter stack
-            SCSIZE              nCols;
-            SCSIZE              nRows;
-            SCSIZE              nCurCol;
-            SCSIZE              nCurRow;
-            SCSIZE              nResMatCols;
-            SCSIZE              nResMatRows;
-            bool                bStarted;
+    ScJumpMatrixEntry*  pJump;      // the jumps
+    ScMatrixRef         pMat;       // the results
+    ScTokenVec*         pParams;    // parameter stack
+    SCSIZE              nCols;
+    SCSIZE              nRows;
+    SCSIZE              nCurCol;
+    SCSIZE              nCurRow;
+    SCSIZE              nResMatCols;
+    SCSIZE              nResMatRows;
+    bool                bStarted;
 
-                                // not implemented, prevent usage
-                                ScJumpMatrix( const ScJumpMatrix& );
-            ScJumpMatrix&       operator=( const ScJumpMatrix& );
+    // not implemented, prevent usage
+    ScJumpMatrix( const ScJumpMatrix& );
+    ScJumpMatrix& operator=( const ScJumpMatrix& );
 
 public:
-                                ScJumpMatrix( SCSIZE nColsP, SCSIZE nRowsP )
-                                        : pJump( new ScJumpMatrixEntry[ nColsP * nRowsP ] )
-                                        , pMat( new ScMatrix( nColsP, nRowsP) )
-                                        , pParams( NULL )
-                                        , nCols( nColsP )
-                                        , nRows( nRowsP )
-                                        , nCurCol( 0 )
-                                        , nCurRow( 0 )
-                                        , nResMatCols( nColsP )
-                                        , nResMatRows( nRowsP )
-                                        , bStarted( false )
-                                    {
-                                        // Initialize result matrix in case of
-                                        // a premature end of the interpreter
-                                        // due to errors.
-                                        pMat->FillDouble( CreateDoubleError(
-                                                NOTAVAILABLE), 0, 0, nCols-1,
-                                                nRows-1);
-                                        /*! pJump not initialized */
-                                    }
-                                ~ScJumpMatrix()
-                                    {
-                                        if ( pParams )
-                                        {
-                                            for ( ScTokenVec::iterator i =
-                                                    pParams->begin(); i !=
-                                                    pParams->end(); ++i )
-                                            {
-                                                (*i)->DecRef();
-                                            }
-                                            delete pParams;
-                                        }
-                                        delete [] pJump;
-                                    }
-            void                GetDimensions( SCSIZE& rCols, SCSIZE& rRows ) const
-                                    {
-                                        rCols = nCols;
-                                        rRows = nRows;
-                                    }
-            void                SetJump( SCSIZE nCol, SCSIZE nRow, double fBool,
-                                            short nStart, short nNext,
-                                            short nStop = SHRT_MAX )
-                                    {
-                                        pJump[ (sal_uLong)nCol * nRows + nRow ].
-                                            SetJump( fBool, nStart, nNext, nStop);
-                                    }
-            void                GetJump( SCSIZE nCol, SCSIZE nRow, double& rBool,
-                                            short& rStart, short& rNext,
-                                            short& rStop ) const
-                                    {
-                                        if (nCols == 1 && nRows == 1)
-                                        {
-                                            nCol = 0;
-                                            nRow = 0;
-                                        }
-                                        else if (nCols == 1 && nRow < nRows)
-                                            nCol = 0;
-                                        else if (nRows == 1 && nCol < nCols)
-                                            nRow = 0;
-                                        else if (nCols <= nCol || nRows <= nRow)
-                                        {
-                                            OSL_FAIL("ScJumpMatrix::GetJump: dimension error");
-                                            nCol = 0;
-                                            nRow = 0;
-                                        }
-                                        pJump[ (sal_uLong)nCol * nRows + nRow ].
-                                            GetJump( rBool, rStart, rNext, rStop);
-                                    }
-            void                SetAllJumps( double fBool,
-                                            short nStart, short nNext,
-                                            short nStop = SHRT_MAX )
-                                    {
-                                        sal_uLong n = (sal_uLong)nCols * nRows;
-                                        for ( sal_uLong j=0; j<n; ++j )
-                                        {
-                                            pJump[ j ].SetJump( fBool, nStart,
-                                                    nNext, nStop);
-                                        }
-                                    }
-            void                SetJumpParameters( ScTokenVec* p )
-                                    { pParams = p; }
-            const ScTokenVec*   GetJumpParameters() const { return pParams; }
-            ScMatrix*           GetResultMatrix() const { return pMat.get(); }
-            void                GetPos( SCSIZE& rCol, SCSIZE& rRow ) const
-                                    {
-                                        rCol = nCurCol;
-                                        rRow = nCurRow;
-                                    }
-            bool                Next( SCSIZE& rCol, SCSIZE& rRow )
-                                    {
-                                        if ( !bStarted )
-                                        {
-                                            bStarted = true;
-                                            nCurCol = nCurRow = 0;
-                                        }
-                                        else
-                                        {
-                                            if ( ++nCurRow >= nResMatRows )
-                                            {
-                                                nCurRow = 0;
-                                                ++nCurCol;
-                                            }
-                                        }
-                                        GetPos( rCol, rRow );
-                                        return nCurCol < nResMatCols;
-                                    }
-            void                GetResMatDimensions( SCSIZE& rCols, SCSIZE& rRows )
-                                    {
-                                        rCols = nResMatCols;
-                                        rRows = nResMatRows;
-                                    }
-            void                SetNewResMat( SCSIZE nNewCols, SCSIZE nNewRows )
-                                    {
-                                        if ( nNewCols > nResMatCols || nNewRows > nResMatRows )
-                                        {
-                                            pMat = pMat->CloneAndExtend(nNewCols, nNewRows);
-                                            if ( nResMatCols < nNewCols )
-                                            {
-                                                pMat->FillDouble( CreateDoubleError(
-                                                    NOTAVAILABLE), nResMatCols, 0, nNewCols-1,
-                                                    nResMatRows-1);
-                                            }
-                                            if ( nResMatRows < nNewRows )
-                                            {
-                                                pMat->FillDouble( CreateDoubleError(
-                                                    NOTAVAILABLE), 0, nResMatRows, nNewCols-1,
-                                                    nNewRows-1);
-                                            }
-                                            if ( nRows == 1 && nCurCol != 0 )
-                                            {
-                                                nCurCol = 0;
-                                                nCurRow = nResMatRows - 1;
-                                            }
-                                            nResMatCols = nNewCols;
-                                            nResMatRows = nNewRows;
-                                        }
-                                    }
+    ScJumpMatrix( SCSIZE nColsP, SCSIZE nRowsP );
+    ~ScJumpMatrix();
+    void GetDimensions( SCSIZE& rCols, SCSIZE& rRows ) const;
+    void SetJump( SCSIZE nCol, SCSIZE nRow, double fBool, short nStart, short nNext, short nStop = SHRT_MAX );
+    void GetJump( SCSIZE nCol, SCSIZE nRow, double& rBool, short& rStart, short& rNext, short& rStop ) const;
+    void SetAllJumps( double fBool, short nStart, short nNext, short nStop = SHRT_MAX );
+    void SetJumpParameters( ScTokenVec* p );
+    const ScTokenVec* GetJumpParameters() const;
+    ScMatrix* GetResultMatrix() const;
+    void GetPos( SCSIZE& rCol, SCSIZE& rRow ) const;
+    bool Next( SCSIZE& rCol, SCSIZE& rRow );
+    void GetResMatDimensions( SCSIZE& rCols, SCSIZE& rRows );
+    void SetNewResMat( SCSIZE nNewCols, SCSIZE nNewRows );
 };
 
 #endif // SC_JUMPMATRIX_HXX
diff --git a/sc/source/core/tool/addincol.cxx b/sc/source/core/tool/addincol.cxx
index d5c5401..20ab937 100644
--- a/sc/source/core/tool/addincol.cxx
+++ b/sc/source/core/tool/addincol.cxx
@@ -1700,9 +1700,9 @@ void ScUnoAddInCall::SetResult( const uno::Any& rNewRes )
     }
 }
 
-
-
-//------------------------------------------------------------------------
-
+ScMatrixRef ScUnoAddInCall::GetMatrix() const
+{
+    return xMatrix;
+}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 3d6806c..9b4c4d1 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -63,6 +63,7 @@
 #include "tokenuno.hxx"
 #include "formulaparserpool.hxx"
 #include "tokenarray.hxx"
+#include "scmatrix.hxx"
 
 using namespace formula;
 using namespace ::com::sun::star;
diff --git a/sc/source/core/tool/ddelink.cxx b/sc/source/core/tool/ddelink.cxx
index bd6eb92..76e7616 100644
--- a/sc/source/core/tool/ddelink.cxx
+++ b/sc/source/core/tool/ddelink.cxx
@@ -239,6 +239,21 @@ void ScDdeLink::ListenersGone()
     bIsInUpdate = bWas;
 }
 
+const ScMatrix* ScDdeLink::GetResult() const
+{
+    return pResult.get();
+}
+
+void ScDdeLink::SetResult( const ScMatrixRef& pRes )
+{
+    pResult = pRes;
+}
+
+ScMatrixRef ScDdeLink::GetModifiableResult()
+{
+    return pResult;
+}
+
 void ScDdeLink::TryUpdate()
 {
     if (bIsInUpdate)
diff --git a/sc/source/core/tool/doubleref.cxx b/sc/source/core/tool/doubleref.cxx
index f7d873c..5b0920a 100644
--- a/sc/source/core/tool/doubleref.cxx
+++ b/sc/source/core/tool/doubleref.cxx
@@ -24,6 +24,7 @@
 #include "queryparam.hxx"
 #include "queryentry.hxx"
 #include "globstr.hrc"
+#include "scmatrix.hxx"
 
 #include <memory>
 #include <vector>
diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx
index f9d251b..4a04f79 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -14,6 +14,8 @@
 #include "tokenarray.hxx"
 #include "compiler.hxx"
 #include "interpre.hxx"
+#include "scmatrix.hxx"
+
 #include "formula/vectortoken.hxx"
 
 namespace sc {
diff --git a/sc/source/core/tool/formularesult.cxx b/sc/source/core/tool/formularesult.cxx
index a106e5f..a20963b 100644
--- a/sc/source/core/tool/formularesult.cxx
+++ b/sc/source/core/tool/formularesult.cxx
@@ -11,6 +11,7 @@
  */
 
 #include "formularesult.hxx"
+#include "scmatrix.hxx"
 
 ScFormulaResult::ScFormulaResult() :
     mpToken(NULL), mnError(0), mbToken(true),
diff --git a/sc/source/core/tool/jumpmatrix.cxx b/sc/source/core/tool/jumpmatrix.cxx
new file mode 100644
index 0000000..6a8b4a7
--- /dev/null
+++ b/sc/source/core/tool/jumpmatrix.cxx
@@ -0,0 +1,173 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "jumpmatrix.hxx"
+#include "scmatrix.hxx"
+
+ScJumpMatrix::ScJumpMatrix(SCSIZE nColsP, SCSIZE nRowsP)
+    : pJump(new ScJumpMatrixEntry[nColsP * nRowsP])
+    , pMat(new ScMatrix(nColsP, nRowsP))
+    , pParams(NULL)
+    , nCols(nColsP)
+    , nRows(nRowsP)
+    , nCurCol(0)
+    , nCurRow(0)
+    , nResMatCols(nColsP)
+    , nResMatRows(nRowsP)
+    , bStarted(false)
+{
+    // Initialize result matrix in case of
+    // a premature end of the interpreter
+    // due to errors.
+    pMat->FillDouble(CreateDoubleError(NOTAVAILABLE), 0, 0, nCols - 1, nRows - 1);
+    /*! pJump not initialized */
+}
+
+ScJumpMatrix::~ScJumpMatrix()
+{
+    if (pParams)
+    {
+        for (ScTokenVec::iterator i =
+             pParams->begin(); i !=
+                 pParams->end(); ++i)
+        {
+            (*i)->DecRef();
+        }
+        delete pParams;
+    }
+    delete[] pJump;
+}
+
+void ScJumpMatrix::GetDimensions(SCSIZE& rCols, SCSIZE& rRows) const
+{
+    rCols = nCols;
+    rRows = nRows;
+}
+
+void ScJumpMatrix::SetJump(SCSIZE nCol, SCSIZE nRow, double fBool,
+                           short nStart, short nNext, short nStop)
+{
+    pJump[(sal_uLong)nCol * nRows + nRow].SetJump(fBool, nStart, nNext, nStop);
+}
+
+void ScJumpMatrix::GetJump(
+    SCSIZE nCol, SCSIZE nRow, double& rBool, short& rStart, short& rNext, short& rStop) const
+{
+    if (nCols == 1 && nRows == 1)
+    {
+        nCol = 0;
+        nRow = 0;
+    }
+    else if (nCols == 1 && nRow < nRows) nCol = 0;
+    else if (nRows == 1 && nCol < nCols) nRow = 0;
+    else if (nCols <= nCol || nRows <= nRow)
+    {
+        OSL_FAIL("ScJumpMatrix::GetJump: dimension error");
+        nCol = 0;
+        nRow = 0;
+    }
+    pJump[(sal_uLong)nCol * nRows + nRow].
+        GetJump(rBool, rStart, rNext, rStop);
+}
+
+void ScJumpMatrix::SetAllJumps(double fBool, short nStart, short nNext, short nStop)
+{
+    sal_uLong n = (sal_uLong)nCols * nRows;
+    for (sal_uLong j = 0; j < n; ++j)
+    {
+        pJump[j].SetJump(fBool, nStart,
+                         nNext, nStop);
+    }
+}
+
+void ScJumpMatrix::SetJumpParameters(ScTokenVec* p)
+{
+    pParams = p;
+}
+
+const ScTokenVec* ScJumpMatrix::GetJumpParameters() const
+{
+    return pParams;
+}
+
+ScMatrix* ScJumpMatrix::GetResultMatrix() const
+{
+    return pMat.get();
+}
+
+void ScJumpMatrix::GetPos(SCSIZE& rCol, SCSIZE& rRow) const
+{
+    rCol = nCurCol;
+    rRow = nCurRow;
+}
+
+bool ScJumpMatrix::Next(SCSIZE& rCol, SCSIZE& rRow)
+{
+    if (!bStarted)
+    {
+        bStarted = true;
+        nCurCol = nCurRow = 0;
+    }
+    else
+    {
+        if (++nCurRow >= nResMatRows)
+        {
+            nCurRow = 0;
+            ++nCurCol;
+        }
+    }
+    GetPos(rCol, rRow);
+    return nCurCol < nResMatCols;
+}
+
+void ScJumpMatrix::GetResMatDimensions(SCSIZE& rCols, SCSIZE& rRows)
+{
+    rCols = nResMatCols;
+    rRows = nResMatRows;
+}
+
+void ScJumpMatrix::SetNewResMat(SCSIZE nNewCols, SCSIZE nNewRows)
+{
+    if (nNewCols > nResMatCols || nNewRows > nResMatRows)
+    {
+        pMat = pMat->CloneAndExtend(nNewCols, nNewRows);
+        if (nResMatCols < nNewCols)
+        {
+            pMat->FillDouble(CreateDoubleError(
+                                 NOTAVAILABLE), nResMatCols, 0, nNewCols - 1,
+                             nResMatRows - 1);
+        }
+        if (nResMatRows < nNewRows)
+        {
+            pMat->FillDouble(CreateDoubleError(
+                                 NOTAVAILABLE), 0, nResMatRows, nNewCols - 1,
+                             nNewRows - 1);
+        }
+        if (nRows == 1 && nCurCol != 0)
+        {
+            nCurCol = 0;
+            nCurRow = nResMatRows - 1;
+        }
+        nResMatCols = nNewCols;
+        nResMatRows = nNewRows;
+    }
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/tool/queryparam.cxx b/sc/source/core/tool/queryparam.cxx
index 826ea3e..b202432 100644
--- a/sc/source/core/tool/queryparam.cxx
+++ b/sc/source/core/tool/queryparam.cxx
@@ -19,6 +19,7 @@
 
 #include "queryparam.hxx"
 #include "queryentry.hxx"
+#include "scmatrix.hxx"
 
 namespace {
 
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index b833fec..4d81099 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -34,6 +34,8 @@
 #include "refupdat.hxx"
 #include "document.hxx"
 
+#include "formula/errorcodes.hxx"
+
 using namespace formula;
 using ::std::pair;
 using ::std::unary_function;
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 2b56456..3f40fa7 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -37,6 +37,7 @@
 #include "rangeseq.hxx"
 #include "externalrefmgr.hxx"
 #include "document.hxx"
+#include "scmatrix.hxx"
 
 using ::std::vector;
 
@@ -795,6 +796,11 @@ bool ScRefListToken::operator==( const FormulaToken& r ) const
     return FormulaToken::operator==( r ) && &aRefList == static_cast<const ScToken&>(r).GetRefList();
 }
 
+ScMatrixToken::ScMatrixToken( const ScMatrixRef& p ) :
+    ScToken(formula::svMatrix), pMatrix(p) {}
+
+ScMatrixToken::ScMatrixToken( const ScMatrixToken& r ) :
+    ScToken(r), pMatrix(r.pMatrix) {}
 
 const ScMatrix* ScMatrixToken::GetMatrix() const        { return pMatrix.get(); }
 ScMatrix*       ScMatrixToken::GetMatrix()              { return pMatrix.get(); }
@@ -1031,6 +1037,11 @@ bool ScEmptyCellToken::operator==( const FormulaToken& r ) const
         bDisplayedAsString == static_cast< const ScEmptyCellToken & >(r).IsDisplayedAsString();
 }
 
+ScMatrixCellResultToken::ScMatrixCellResultToken( const ScConstMatrixRef& pMat, formula::FormulaToken* pUL ) :
+    ScToken(formula::svMatrixCell), xMatrix(pMat), xUpperLeft(pUL) {}
+
+ScMatrixCellResultToken::ScMatrixCellResultToken( const ScMatrixCellResultToken& r ) :
+    ScToken(r), xMatrix(r.xMatrix), xUpperLeft(r.xUpperLeft) {}
 
 double          ScMatrixCellResultToken::GetDouble() const  { return xUpperLeft->GetDouble(); }
 const String &  ScMatrixCellResultToken::GetString() const  { return xUpperLeft->GetString(); }
@@ -1041,6 +1052,7 @@ ScMatrix* ScMatrixCellResultToken::GetMatrix()
 {
     return const_cast<ScMatrix*>(xMatrix.get());
 }
+
 bool ScMatrixCellResultToken::operator==( const FormulaToken& r ) const
 {
     return FormulaToken::operator==( r ) &&
@@ -1048,6 +1060,27 @@ bool ScMatrixCellResultToken::operator==( const FormulaToken& r ) const
         xMatrix == static_cast<const ScMatrixCellResultToken &>(r).xMatrix;
 }
 
+void ScMatrixCellResultToken::Assign( const ScMatrixCellResultToken & r )
+{
+    xMatrix = r.xMatrix;
+    xUpperLeft = r.xUpperLeft;
+}
+
+ScMatrixFormulaCellToken::ScMatrixFormulaCellToken(
+    SCCOL nC, SCROW nR, const ScConstMatrixRef& pMat, formula::FormulaToken* pUL ) :
+    ScMatrixCellResultToken(pMat, pUL), nRows(nR), nCols(nC) {}
+
+ScMatrixFormulaCellToken::ScMatrixFormulaCellToken( SCCOL nC, SCROW nR ) :
+    ScMatrixCellResultToken(NULL, NULL), nRows(nR), nCols(nC) {}
+
+ScMatrixFormulaCellToken::ScMatrixFormulaCellToken( const ScMatrixFormulaCellToken& r ) :
+    ScMatrixCellResultToken(r), nRows(r.nRows), nCols(r.nCols)
+{
+    // xUpperLeft is modifiable through
+    // SetUpperLeftDouble(), so clone it.
+    if (xUpperLeft)
+        xUpperLeft = xUpperLeft->Clone();
+}
 
 bool ScMatrixFormulaCellToken::operator==( const FormulaToken& r ) const
 {
@@ -1077,6 +1110,7 @@ void ScMatrixFormulaCellToken::Assign( const formula::FormulaToken& r )
         }
     }
 }
+
 void ScMatrixFormulaCellToken::SetUpperLeftDouble( double f )
 {
     switch (GetUpperLeftType())
@@ -1098,6 +1132,12 @@ void ScMatrixFormulaCellToken::SetUpperLeftDouble( double f )
     }
 }
 
+void ScMatrixFormulaCellToken::ResetResult()
+{
+    xMatrix = NULL;
+    xUpperLeft = NULL;
+}
+
 
 double ScHybridCellToken::GetDouble() const { return mfDouble; }
 const String& ScHybridCellToken::GetString() const { return maString; }
diff --git a/sc/source/filter/excel/excform.cxx b/sc/source/filter/excel/excform.cxx
index 10b95f7..269c66f 100644
--- a/sc/source/filter/excel/excform.cxx
+++ b/sc/source/filter/excel/excform.cxx
@@ -24,6 +24,8 @@
 #include "document.hxx"
 #include "rangenam.hxx"
 #include "global.hxx"
+#include "scmatrix.hxx"
+
 #include "formula/errorcodes.hxx"
 
 #include "imp_op.hxx"
diff --git a/sc/source/filter/excel/xeformula.cxx b/sc/source/filter/excel/xeformula.cxx
index 5265bd1..7065d10 100644
--- a/sc/source/filter/excel/xeformula.cxx
+++ b/sc/source/filter/excel/xeformula.cxx
@@ -27,6 +27,7 @@
 #include "rangelst.hxx"
 #include "token.hxx"
 #include "tokenarray.hxx"
+#include "scmatrix.hxx"
 #include "xeformula.hxx"
 #include "xehelper.hxx"
 #include "xelink.hxx"
diff --git a/sc/source/filter/excel/xehelper.cxx b/sc/source/filter/excel/xehelper.cxx
index a13b7fe..2a2e2dc 100644
--- a/sc/source/filter/excel/xehelper.cxx
+++ b/sc/source/filter/excel/xehelper.cxx
@@ -40,6 +40,7 @@
 #include "formulacell.hxx"
 #include "editutil.hxx"
 #include "patattr.hxx"
+#include "scmatrix.hxx"
 #include "xestyle.hxx"
 #include "fprogressbar.hxx"
 #include "xltracer.hxx"
diff --git a/sc/source/filter/excel/xihelper.cxx b/sc/source/filter/excel/xihelper.cxx
index c002ae9..824f4c4 100644
--- a/sc/source/filter/excel/xihelper.cxx
+++ b/sc/source/filter/excel/xihelper.cxx
@@ -33,6 +33,7 @@
 #include "xistyle.hxx"
 #include "excform.hxx"
 #include "stringutil.hxx"
+#include "scmatrix.hxx"
 
 // Excel->Calc cell address/range conversion ==================================
 
@@ -798,7 +799,7 @@ XclImpCachedValue::XclImpCachedValue( XclImpStream& rStrm ) :
             rStrm >> mfValue;
         break;
         case EXC_CACHEDVAL_STRING:
-            mxStr.reset( new String( rStrm.ReadUniString() ) );
+            maStr = rStrm.ReadUniString();
         break;
         case EXC_CACHEDVAL_BOOL:
         case EXC_CACHEDVAL_ERROR:
@@ -822,6 +823,11 @@ XclImpCachedValue::~XclImpCachedValue()
 {
 }
 
+const OUString& XclImpCachedValue::GetString() const
+{
+    return maStr;
+}
+
 sal_uInt16 XclImpCachedValue::GetScError() const
 {
     return (mnType == EXC_CACHEDVAL_ERROR) ? XclTools::GetScErrorCode( mnBoolErr ) : 0;
diff --git a/sc/source/filter/excel/xilink.cxx b/sc/source/filter/excel/xilink.cxx
index a89d366..7ccc4ae 100644
--- a/sc/source/filter/excel/xilink.cxx
+++ b/sc/source/filter/excel/xilink.cxx
@@ -28,6 +28,7 @@
 #include "excform.hxx"
 #include "tokenarray.hxx"
 #include "externalrefmgr.hxx"
+#include "scmatrix.hxx"
 
 #include <vector>
 #include <boost/ptr_container/ptr_vector.hpp>
@@ -599,7 +600,7 @@ void XclImpSupbookTab::LoadCachedValues(ScExternalRefCache::TableTypeRef pCacheT
             break;
             case EXC_CACHEDVAL_STRING:
             {
-                const String& rStr = pCrn->GetString();
+                const OUString& rStr = pCrn->GetString();
                 ScExternalRefCache::TokenRef pToken(new formula::FormulaStringToken(rStr));
                 pCacheTable->setCell(rAddr.mnCol, rAddr.mnRow, pToken, 0, false);
             }
diff --git a/sc/source/filter/inc/xihelper.hxx b/sc/source/filter/inc/xihelper.hxx
index 52f7d25..ed6426d 100644
--- a/sc/source/filter/inc/xihelper.hxx
+++ b/sc/source/filter/inc/xihelper.hxx
@@ -24,7 +24,7 @@
 #include <boost/noncopyable.hpp>
 #include <boost/shared_ptr.hpp>
 #include <boost/ptr_container/ptr_vector.hpp>
-#include "scmatrix.hxx"
+#include "types.hxx"
 #include "xladdress.hxx"
 #include "xiroot.hxx"
 #include "xistring.hxx"
@@ -301,7 +301,7 @@ public:
     /** Returns the type of the cached value (EXC_CACHEDVAL_*). */
     inline sal_uInt8    GetType() const     { return mnType; }
     /** Returns the cached string value, if this value is a string, else an empty string. */
-    inline const String& GetString() const  { return mxStr.get() ? *mxStr : EMPTY_STRING; }
+    const OUString& GetString() const;
     /** Returns the cached number, if this value has number type, else 0.0. */
     inline double       GetValue() const    { return mfValue; }
     /** Returns the cached Boolean value, if this value has Boolean type, else false. */
@@ -312,10 +312,9 @@ public:
     sal_uInt16              GetScError() const;
 
 protected:
-    typedef ::std::auto_ptr< String >               StringPtr;
     typedef ::std::auto_ptr< const ScTokenArray >   ScTokenArrayPtr;
 
-    StringPtr           mxStr;      /// Cached value is a string.
+    OUString            maStr;      /// Cached value is a string.
     double              mfValue;    /// Cached value is a double.
     ScTokenArrayPtr     mxTokArr;   /// Cached value is a formula or error code or Boolean.
     sal_uInt8           mnBoolErr;  /// Boolean value or Excel error code.
diff --git a/sc/source/filter/inc/xilink.hxx b/sc/source/filter/inc/xilink.hxx
index 09b0098..985e6ee 100644
--- a/sc/source/filter/inc/xilink.hxx
+++ b/sc/source/filter/inc/xilink.hxx
@@ -23,7 +23,7 @@
 #include <map>
 #include "xllink.hxx"
 #include "xiroot.hxx"
-#include "scmatrix.hxx"
+#include "types.hxx"
 
 /* ============================================================================
 Classes for import of different kinds of internal/external references.
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index 4ab9d98..445766e 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -50,6 +50,7 @@
 #include "editattributemap.hxx"
 #include "stringutil.hxx"
 #include "tokenarray.hxx"
+#include "scmatrix.hxx"
 
 #include <xmloff/xmltkmap.hxx>
 #include <xmloff/xmltoken.hxx>
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index b6f847b..87a9b16 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -51,6 +51,7 @@
 #include "unotools/localfilehelper.hxx"
 #include "vcl/msgbox.hxx"
 #include "stringutil.hxx"
+#include "scmatrix.hxx"
 
 #include <memory>
 #include <algorithm>
diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx
index 81e4953..6ec562d 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -37,6 +37,7 @@
 #include "docsh.hxx"
 #include "cellvalue.hxx"
 #include "tokenarray.hxx"
+#include "scmatrix.hxx"
 
 #include "formula/opcode.hxx"
 
diff --git a/sc/source/ui/unoobj/linkuno.cxx b/sc/source/ui/unoobj/linkuno.cxx
index 897d4aa..0531ff9 100644
--- a/sc/source/ui/unoobj/linkuno.cxx
+++ b/sc/source/ui/unoobj/linkuno.cxx
@@ -32,6 +32,7 @@
 #include "unonames.hxx"
 #include "rangeseq.hxx"
 #include "token.hxx"
+#include "scmatrix.hxx"
 
 #include <vector>
 #include <climits>
commit 83418814e026c120d04960d7a56bc2191837747d
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Jul 1 15:47:41 2013 -0400

    Rework SUMPRODUCT to reduce the number of block position lookups.
    
    Change-Id: I22b843142b76df1c51597a8138b1674286f78792

diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index d6ac279..ccb989f 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -119,6 +119,8 @@ class SC_DLLPUBLIC ScMatrix
     ScMatrix& operator=( const ScMatrix&);
 
 public:
+    enum Op { Add, Sub, Mul, Div };
+
     /**
      * When adding all numerical matrix elements for a scalar result such as
      * summation, the interpreter wants to separate the first non-zero value
@@ -352,8 +354,8 @@ public:
     double GetMaxValue( bool bTextAsZero ) const;
     double GetMinValue( bool bTextAsZero ) const;
 
-    // All other matrix functions  MatMult, MInv, ...  are in ScInterpreter
-    // to be numerically safe.
+    void GetDoubleArray( std::vector<double>& rArray ) const;
+    void MergeDoubleArray( std::vector<double>& rArray, Op eOp ) const;
 
 #if DEBUG_MATRIX
     void Dump() const;
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index c6fc44a..79a038d 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -1595,6 +1595,49 @@ void ScInterpreter::ScPow()
         PushDouble(pow(fVal1,fVal2));
 }
 
+namespace {
+
+bool mergeArray( std::vector<double>& rRes, const std::vector<double>& rOther )
+{
+    if (rRes.size() != rOther.size())
+        return false;
+
+    double fNan;
+    rtl::math::setNan(&fNan);
+
+    std::vector<double>::iterator it = rRes.begin(), itEnd = rRes.end();
+    std::vector<double>::const_iterator itOther = rOther.begin();
+    for (; it != itEnd; ++it, ++itOther)
+    {
+        if (rtl::math::isNan(*it) || rtl::math::isNan(*itOther))
+        {
+            *it = fNan;
+            continue;
+        }
+
+        *it *= *itOther;
+    }
+
+    return true;
+}
+
+class SumValues : std::unary_function<double, void>
+{
+    double mfSum;
+public:
+    SumValues() : mfSum(0.0) {}
+
+    void operator() (double f)
+    {
+        if (!rtl::math::isNan(f))
+            mfSum += f;
+    }
+
+    double getValue() const { return mfSum; }
+};
+
+}
+
 void ScInterpreter::ScSumProduct()
 {
     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScSumProduct" );
@@ -1602,49 +1645,40 @@ void ScInterpreter::ScSumProduct()
     if ( !MustHaveParamCount( nParamCount, 1, 30 ) )
         return;
 
-    ScMatrixRef pMat1 = NULL;
-    ScMatrixRef pMat2 = NULL;
-    ScMatrixRef pMat  = NULL;
-    pMat2 = GetMatrix();
-    if (!pMat2)
+    ScMatrixRef pMatLast;
+    ScMatrixRef pMat;
+
+    pMatLast = GetMatrix();
+    if (!pMatLast)
     {
         PushIllegalParameter();
         return;
     }
-    SCSIZE nC, nC1;
-    SCSIZE nR, nR1;
-    pMat2->GetDimensions(nC, nR);
-    pMat = pMat2;
-    for (sal_uInt16 i = 1; i < nParamCount; i++)
+
+    SCSIZE nC, nCLast, nR, nRLast;
+    pMatLast->GetDimensions(nCLast, nRLast);
+    std::vector<double> aResArray;
+    pMatLast->GetDoubleArray(aResArray);
+
+    for (sal_uInt16 i = 1; i < nParamCount; ++i)
     {
-        pMat1 = GetMatrix();
-        if (!pMat1)
+        pMat = GetMatrix();
+        if (!pMat)
         {
             PushIllegalParameter();
             return;
         }
-        pMat1->GetDimensions(nC1, nR1);
-        if (nC1 != nC || nR1 != nR)
-        {
-            PushNoValue();
-            return;
-        }
-        ScMatrixRef pResMat = lcl_MatrixCalculation<MatrixMul>(*pMat1, *pMat, this);
-        if (!pResMat)
+        pMat->GetDimensions(nC, nR);
+        if (nC != nCLast || nR != nRLast)
         {
             PushNoValue();
             return;
         }
-        else
-            pMat = pResMat;
-    }
-    double fSum = 0.0;
-    SCSIZE nCount = pMat->GetElementCount();
-    for (SCSIZE j = 0; j < nCount; j++)
-    {
-        if (!pMat->IsString(j))
-            fSum += pMat->GetDouble(j);
+
+        pMat->MergeDoubleArray(aResArray, ScMatrix::Mul);
     }
+
+    double fSum = std::for_each(aResArray.begin(), aResArray.end(), SumValues()).getValue();
     PushDouble(fSum);
 }
 
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index b0bef2e..ffc3382 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -225,6 +225,8 @@ public:
 
     double GetMaxValue( bool bTextAsZero ) const;
     double GetMinValue( bool bTextAsZero ) const;
+    void GetDoubleArray( std::vector<double>& rArray ) const;
+    void MergeDoubleArray( std::vector<double>& rArray, ScMatrix::Op eOp ) const;
 
 #if DEBUG_MATRIX
     void Dump() const;
@@ -1022,6 +1024,121 @@ public:
     }
 };
 
+class ToDoubleArray : std::unary_function<MatrixImplType::element_block_type, void>
+{
+    std::vector<double> maArray;
+    std::vector<double>::iterator miPos;
+    double mfNaN;
+public:
+    ToDoubleArray(size_t nSize) : maArray(nSize, 0.0), miPos(maArray.begin())
+    {
+        rtl::math::setNan(&mfNaN);
+    }
+
+    void operator() (const MatrixImplType::element_block_node_type& node)
+    {
+        using namespace mdds::mtv;
+
+        switch (node.type)
+        {
+            case mdds::mtm::element_numeric:
+            {
+                numeric_element_block::const_iterator it = numeric_element_block::begin(*node.data);
+                numeric_element_block::const_iterator itEnd = numeric_element_block::end(*node.data);
+                for (; it != itEnd; ++it, ++miPos)
+                    *miPos = *it;
+            }
+            break;
+            case mdds::mtm::element_boolean:
+            {
+                boolean_element_block::const_iterator it = boolean_element_block::begin(*node.data);
+                boolean_element_block::const_iterator itEnd = boolean_element_block::end(*node.data);
+                for (; it != itEnd; ++it, ++miPos)
+                    *miPos = *it ? 1.0 : 0.0;
+            }
+            break;
+            case mdds::mtm::element_string:
+            {
+                for (size_t i = 0; i < node.size; ++i, ++miPos)
+                    *miPos = mfNaN;
+            }
+            break;
+            default:
+                ;
+        }
+    }
+
+    void swap(std::vector<double>& rOther)
+    {
+        maArray.swap(rOther);
+    }
+};
+
+struct ArrayMul : public std::binary_function<double, double, double>
+{
+    double operator() (const double& lhs, const double& rhs) const
+    {
+        return lhs * rhs;
+    }
+};
+
+template<typename _Op>
+class MergeDoubleArrayFunc : std::unary_function<MatrixImplType::element_block_type, void>
+{
+    std::vector<double>& mrArray;
+    std::vector<double>::iterator miPos;
+    double mfNaN;
+public:
+    MergeDoubleArrayFunc(std::vector<double>& rArray) : mrArray(rArray), miPos(mrArray.begin())
+    {
+        rtl::math::setNan(&mfNaN);
+    }
+
+    void operator() (const MatrixImplType::element_block_node_type& node)
+    {
+        using namespace mdds::mtv;
+        static _Op op;
+
+        switch (node.type)
+        {
+            case mdds::mtm::element_numeric:
+            {
+                numeric_element_block::const_iterator it = numeric_element_block::begin(*node.data);
+                numeric_element_block::const_iterator itEnd = numeric_element_block::end(*node.data);
+                for (; it != itEnd; ++it, ++miPos)
+                {
+                    if (rtl::math::isNan(*miPos))
+                        continue;
+
+                    *miPos = op(*miPos, *it);
+                }
+            }
+            break;
+            case mdds::mtm::element_boolean:
+            {
+                boolean_element_block::const_iterator it = boolean_element_block::begin(*node.data);
+                boolean_element_block::const_iterator itEnd = boolean_element_block::end(*node.data);
+                for (; it != itEnd; ++it, ++miPos)
+                {
+                    if (rtl::math::isNan(*miPos))
+                        continue;
+
+                    *miPos = op(*miPos, *it ? 1.0 : 0.0);
+                }
+            }
+            break;
+            case mdds::mtm::element_string:
+            {
+                for (size_t i = 0; i < node.size; ++i, ++miPos)
+                    *miPos = mfNaN;
+            }
+            break;
+            default:
+                ;
+        }
+    }
+};
+
 }
 
 ScMatrix::IterateResult ScMatrixImpl::Sum(bool bTextAsZero) const
@@ -1067,6 +1184,34 @@ double ScMatrixImpl::GetMinValue( bool bTextAsZero ) const
     return aFunc.getValue();
 }
 
+void ScMatrixImpl::GetDoubleArray( std::vector<double>& rArray ) const
+{
+    MatrixImplType::size_pair_type aSize = maMat.size();
+    ToDoubleArray aFunc(aSize.row*aSize.column);
+    maMat.walk(aFunc);
+    aFunc.swap(rArray);
+}
+
+void ScMatrixImpl::MergeDoubleArray( std::vector<double>& rArray, ScMatrix::Op eOp ) const
+{
+    MatrixImplType::size_pair_type aSize = maMat.size();
+    size_t nSize = aSize.row*aSize.column;
+    if (nSize != rArray.size())
+        return;
+
+    switch (eOp)
+    {
+        case ScMatrix::Mul:
+        {
+            MergeDoubleArrayFunc<ArrayMul> aFunc(rArray);
+            maMat.walk(aFunc);
+        }
+        break;
+        default:
+            ;
+    }
+}
+
 #if DEBUG_MATRIX
 void ScMatrixImpl::Dump() const
 {
@@ -1419,6 +1564,16 @@ double ScMatrix::GetMinValue( bool bTextAsZero ) const
     return pImpl->GetMinValue(bTextAsZero);
 }
 
+void ScMatrix::GetDoubleArray( std::vector<double>& rArray ) const
+{
+    pImpl->GetDoubleArray(rArray);
+}
+
+void ScMatrix::MergeDoubleArray( std::vector<double>& rArray, Op eOp ) const
+{
+    pImpl->MergeDoubleArray(rArray, eOp);
+}
+
 #if DEBUG_MATRIX
 void ScMatrix::Dump() const
 {
@@ -1427,3 +1582,4 @@ void ScMatrix::Dump() const
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+
commit f74e6dd07e971d25a610edbe0197b98984dbf353
Author: Michael Meeks <michael.meeks at suse.com>
Date:   Mon Jul 1 21:55:24 2013 +0100

    get quoting right.
    
    Change-Id: I3b1508a3309ad4df9e095b1cb6c3091df4adff4a

diff --git a/configure.ac b/configure.ac
index aa440fb..66733ea 100644
--- a/configure.ac
+++ b/configure.ac
@@ -9838,7 +9838,7 @@ if test \( -z "$with_opencl_sdk" -o "$with_opencl_sdk" = yes \) -a $_os = Darwin
 elif test "z$with_opencl_sdk" = "z"; then
     AC_MSG_RESULT([no])
 else
-    if test -d $with_opencl_sdk/include; then
+    if test -d "$with_opencl_sdk/include"; then
         ENABLE_OPENCL=TRUE
         OPENCL_CFLAGS="-I$with_opencl_sdk/include"
         OPENCL_LIBS="-L$with_opencl_sdk/lib/x86 -lOpenCL"
commit 7c7ca0d0028cacad15a4fdc3dc02bc5f038c9f3c
Author: Ivan Timofeev <timofeev.i.s at gmail.com>
Date:   Mon Jul 1 22:10:45 2013 +0400

    WaE: pOldRanges may be used uninitialized
    
    Change-Id: I22ff60e30b8c5697f648fcd6b7b22a302c6a2135

diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 1d0a8e8..3a8f7cd 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -7503,7 +7503,7 @@ void SAL_CALL ScTableSheetObj::setPrintAreas(
                                                 throw(uno::RuntimeException)
 {
     SolarMutexGuard aGuard;
-    ScPrintRangeSaver* pOldRanges;
+    ScPrintRangeSaver* pOldRanges = NULL;
     ScDocShell* pDocSh = GetDocShell();
     if ( pDocSh )
     {
commit cc06e7b6b8b73ae68a2eea72d94c6f45c9fbf497
Author: Ivan Timofeev <timofeev.i.s at gmail.com>
Date:   Mon Jul 1 21:29:29 2013 +0400

    gtk3: for checkbox map BUTTONVALUE_MIXED to GTK_STATE_FLAG_INCONSISTENT
    
    Change-Id: I5f5810a1e2dc56afb0fba7fde20a383980e3ba51

diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
index 1821cbe..350d1e9 100644
--- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
@@ -853,7 +853,9 @@ sal_Bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart
         break;
     case CTRL_CHECKBOX:
         flags = (GtkStateFlags)(flags |
-                ( (aValue.getTristateVal() == BUTTONVALUE_ON) ? GTK_STATE_FLAG_ACTIVE : GTK_STATE_FLAG_NORMAL));
+                ( (aValue.getTristateVal() == BUTTONVALUE_ON) ? GTK_STATE_FLAG_ACTIVE :
+                  (aValue.getTristateVal() == BUTTONVALUE_MIXED) ? GTK_STATE_FLAG_INCONSISTENT :
+                  GTK_STATE_FLAG_NORMAL));
         context = mpCheckButtonStyle;
         styleClass = GTK_STYLE_CLASS_CHECK;
         renderType = RENDER_CHECK;
commit 76c9d45ccf8480f8b73815607ff8701a3d41a649
Author: Ivan Timofeev <timofeev.i.s at gmail.com>
Date:   Mon Jul 1 21:24:25 2013 +0400

    gtk3: add indicator-spacing to size of checkbox/radiobutton
    
    Change-Id: Ifea43607c8cd5a8047796b7d2efdf14289b029e2

diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx
index 4d5ff7c..912e27e 100644
--- a/vcl/inc/unx/gtk/gtkgdi.hxx
+++ b/vcl/inc/unx/gtk/gtkgdi.hxx
@@ -103,6 +103,10 @@ private:
                         ControlType nType,
                         ControlPart nPart,
                         const ImplControlValue& aValue );
+    void PaintCheckOrRadio(GtkStyleContext *context,
+                           cairo_t *cr,
+                           const Rectangle& rControlRectangle,
+                           ControlType nType);
 
     static bool style_loaded;
 };
diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
index 3448615..1821cbe 100644
--- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
@@ -751,6 +751,24 @@ void GtkSalGraphics::PaintCombobox( GtkStyleContext *context,
                      arrowRect.GetWidth() );
 }
 
+void GtkSalGraphics::PaintCheckOrRadio(GtkStyleContext *context,
+                                       cairo_t *cr,
+                                       const Rectangle& rControlRectangle,
+                                       ControlType nType)
+{
+    gint x, y, indicator_size;
+    gtk_style_context_get_style(mpCheckButtonStyle,
+                                "indicator-size", &indicator_size,
+                                NULL );
+
+    x = (rControlRectangle.GetWidth() - indicator_size) / 2;
+    y = (rControlRectangle.GetHeight() - indicator_size) / 2;
+    if (nType == CTRL_CHECKBOX)
+        gtk_render_check(context, cr, x, y, indicator_size, indicator_size);
+    else if (nType == CTRL_RADIOBUTTON)
+        gtk_render_option(context, cr, x, y, indicator_size, indicator_size);
+}
+
 sal_Bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion,
                                             ControlState nState, const ImplControlValue& aValue,
                                             const OUString& )
@@ -891,14 +909,8 @@ sal_Bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart
                              rControlRegion.GetWidth(), rControlRegion.GetHeight());
         break;
     case RENDER_CHECK:
-        gtk_render_check(context, cr,
-                         0, 0,
-                         rControlRegion.GetWidth(), rControlRegion.GetHeight());
-        break;
     case RENDER_RADIO:
-        gtk_render_option(context, cr,
-                          0, 0,
-                          rControlRegion.GetWidth(), rControlRegion.GetHeight());
+        PaintCheckOrRadio(context, cr, rControlRegion, nType);
         break;
     case RENDER_LINE:
         gtk_render_line(context, cr,
@@ -982,18 +994,21 @@ sal_Bool GtkSalGraphics::getNativeControlRegion( ControlType nType, ControlPart
 {
     /* TODO: all this funcions needs improvements */
     Rectangle aEditRect = rControlRegion;
-    gint indicator_size, point;
+    gint indicator_size, indicator_spacing, point;
 
     if(((nType == CTRL_CHECKBOX) || (nType == CTRL_RADIOBUTTON)) &&
        nPart == PART_ENTIRE_CONTROL)
     {
         gtk_style_context_get_style( mpCheckButtonStyle,
                                      "indicator-size", &indicator_size,
+                                     "indicator-spacing", &indicator_spacing,
                                      (char *)NULL );
 
-        point = MAX(0, rControlRegion.GetHeight() - indicator_size);
+        gint size = indicator_size + indicator_spacing*2;
+
+        point = MAX(0, rControlRegion.GetHeight() - size);
         aEditRect = Rectangle( Point( 0, point / 2),
-                               Size( indicator_size, indicator_size ) );
+                               Size( size, size ) );
     }
     else if( nType == CTRL_MENU_POPUP)
     {
commit a201ae63ce798438057a1328dc644dc8b64fe4e8
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Jul 1 19:04:38 2013 +0200

    fdo#66165: WW8 export: fix duplicated paragraph breaks
    
    MSWordExportBase::OutputTextNode(): in commit
    8f2a21eac4a904db3cc4c448179e2d2cf5878ef4
    (which is not merged) a "WriteCR( pTextNodeInfoInner );" was moved up
    a few lines, so it shows up as context in the other commit, and
    the bug is that the cherry-pick 83ba821c10392c08334f7d8d3775fe3e8d08f8fd
    erroneously adds this context line so now there are 2 WriteCR().
    
    Change-Id: I08434b284f3d8d8426fa997623be352c37d6c7c2

diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index 85d6b11..62b43a5 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -2023,7 +2023,6 @@ void MSWordExportBase::OutputTextNode( const SwTxtNode& rNode )
                 aAttrIter.OutFlys( nEnd );
                 // insert final bookmarks if any before CR and after flys
                 AppendBookmarks( rNode, nEnd, 1 );
-                WriteCR( pTextNodeInfoInner );
                 // #i120928 - position of the bullet's graphic is at end of doc
                 if (bLastCR && (!bExported))
                 {
commit 92c7eca78e6ac84ef2b1be5dca102ecfaee9766b
Author: Laurent Godard <lgodard.libre at laposte.net>
Date:   Mon Jul 1 15:43:46 2013 +0200

    simplify AddPrintRanges calls at import time
    
      - at import time, use directly core functions
      - honor IsUndoEnabled in uno calls
    
    Change-Id: If1e762df0ca9cfa22fa2c0e75518fe892be602b6
    Reviewed-on: https://gerrit.libreoffice.org/4656
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sc/source/filter/xml/xmltabi.cxx b/sc/source/filter/xml/xmltabi.cxx
index 1069f47..1701529 100644
--- a/sc/source/filter/xml/xmltabi.cxx
+++ b/sc/source/filter/xml/xmltabi.cxx
@@ -359,14 +359,12 @@ void ScXMLTableContext::EndElement()
     SCTAB nCurTab = rTables.GetCurrentSheet();
     if (!sPrintRanges.isEmpty())
     {
-        Reference< sheet::XPrintAreas > xPrintAreas(
-            rTables.GetCurrentXSheet(), UNO_QUERY);
-
-        if( xPrintAreas.is() )
+         ScRangeList aRangeList;
+        ScRangeStringConverter::GetRangeListFromString( aRangeList, sPrintRanges, pDoc, ::formula::FormulaGrammar::CONV_OOO );
+        size_t nCount = aRangeList.size();
+        for (size_t i=0; i< nCount; i++ )
         {
-            Sequence< table::CellRangeAddress > aRangeList;
-            ScRangeStringConverter::GetRangeListFromString( aRangeList, sPrintRanges, pDoc, ::formula::FormulaGrammar::CONV_OOO );
-            xPrintAreas->setPrintAreas( aRangeList );
+            pDoc->AddPrintRange( nCurTab, *aRangeList[i] );
         }
     }
     else if (!bPrintEntireSheet)
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 763bf67..1d0a8e8 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -7503,13 +7503,15 @@ void SAL_CALL ScTableSheetObj::setPrintAreas(
                                                 throw(uno::RuntimeException)
 {
     SolarMutexGuard aGuard;
+    ScPrintRangeSaver* pOldRanges;
     ScDocShell* pDocSh = GetDocShell();
     if ( pDocSh )
     {
         ScDocument* pDoc = pDocSh->GetDocument();
         SCTAB nTab = GetTab_Impl();
 
-        ScPrintRangeSaver* pOldRanges = pDoc->CreatePrintRangeSaver();
+        if ( pDoc->IsUndoEnabled() )
+            pOldRanges = pDoc->CreatePrintRangeSaver();
 
         sal_uInt16 nCount = (sal_uInt16) aPrintAreas.getLength();
         pDoc->ClearPrintRanges( nTab );
@@ -7524,7 +7526,8 @@ void SAL_CALL ScTableSheetObj::setPrintAreas(
             }
         }
 
-        PrintAreaUndo_Impl( pOldRanges );   // Undo, Umbrueche, Modified etc.
+        if ( pDoc->IsUndoEnabled() )
+            PrintAreaUndo_Impl( pOldRanges );   // Undo, Umbrueche, Modified etc.
     }
 }
 
commit cb44db2fe78b43424491d25f0c9e34f16aba5c24
Author: Eike Rathke <erack at redhat.com>
Date:   Mon Jul 1 19:02:32 2013 +0200

    sorted by formatindex for better comparability
    
    Change-Id: I38f238878141b9ce7d479e66340ef3e78dc83843

diff --git a/i18npool/source/localedata/data/hr_HR.xml b/i18npool/source/localedata/data/hr_HR.xml
index f484830..f95dd02 100644
--- a/i18npool/source/localedata/data/hr_HR.xml
+++ b/i18npool/source/localedata/data/hr_HR.xml
@@ -56,55 +56,84 @@
     <DateAcceptancePattern>D.M.Y.</DateAcceptancePattern>
     <DateAcceptancePattern>D/M/Y</DateAcceptancePattern>
     <DateAcceptancePattern>D/M</DateAcceptancePattern>
-    <FormatElement msgid="DateFormatskey1" default="false" type="medium" usage="DATE" formatindex="34">
-      <FormatCode>MM.YY</FormatCode>
+    <FormatElement msgid="FixedFormatskey1" default="true" type="medium" usage="FIXED_NUMBER" formatindex="0">
+      <FormatCode>General</FormatCode>
     </FormatElement>
-    <FormatElement msgid="DateFormatskey2" default="false" type="medium" usage="DATE" formatindex="35">
-      <FormatCode>MMM.DD</FormatCode>
+    <FormatElement msgid="FixedFormatskey2" default="true" type="short" usage="FIXED_NUMBER" formatindex="1">
+      <FormatCode>0</FormatCode>
     </FormatElement>
-    <FormatElement msgid="DateFormatskey3" default="false" type="medium" usage="DATE" formatindex="36">
-      <FormatCode>MMMM</FormatCode>
+    <FormatElement msgid="FixedFormatskey3" default="false" type="medium" usage="FIXED_NUMBER" formatindex="2">
+      <FormatCode>0,00</FormatCode>
     </FormatElement>
-    <FormatElement msgid="DateFormatskey4" default="false" type="medium" usage="DATE" formatindex="37">
-      <FormatCode>QQ YY</FormatCode>
+    <FormatElement msgid="FixedFormatskey4" default="false" type="short" usage="FIXED_NUMBER" formatindex="3">
+      <FormatCode>#.##0</FormatCode>
     </FormatElement>
-    <FormatElement msgid="DateFormatskey5" default="false" type="medium" usage="DATE" formatindex="21">
-      <FormatCode>DD.MM.YYYY</FormatCode>
+    <FormatElement msgid="FixedFormatskey5" default="false" type="medium" usage="FIXED_NUMBER" formatindex="4">
+      <FormatCode>#.##0,00</FormatCode>
     </FormatElement>
-    <FormatElement msgid="DateFormatskey6" default="true" type="medium" usage="DATE" formatindex="20">
-      <FormatCode>DD.MM.YY</FormatCode>
+    <FormatElement msgid="FixedFormatskey6" default="false" type="medium" usage="FIXED_NUMBER" formatindex="5">
+      <FormatCode>#.###,00</FormatCode>
     </FormatElement>
-    <FormatElement msgid="DateFormatskey7" default="false" type="medium" usage="DATE" formatindex="32">
-      <FormatCode>YY-MM-DD</FormatCode>
+    <FormatElement msgid="ScientificFormatskey1" default="true" type="medium" usage="SCIENTIFIC_NUMBER" formatindex="6">
+      <FormatCode>0,00E+00</FormatCode>
     </FormatElement>
-    <FormatElement msgid="DateFormatskey8" default="false" type="medium" usage="DATE" formatindex="33">
-      <FormatCode>YYYY-MM-DD</FormatCode>
-      <DefaultName>ISO 8601</DefaultName>
+    <FormatElement msgid="ScientificFormatskey2" default="false" type="medium" usage="SCIENTIFIC_NUMBER" formatindex="7">
+      <FormatCode>0,00E+000</FormatCode>
     </FormatElement>
-    <FormatElement msgid="DateFormatskey9" default="false" type="medium" usage="DATE" formatindex="38">
-      <FormatCode>WW</FormatCode>
+    <FormatElement msgid="PercentFormatskey1" default="true" type="short" usage="PERCENT_NUMBER" formatindex="8">
+      <FormatCode>0%</FormatCode>
     </FormatElement>
-    <FormatElement msgid="DateFormatskey10" default="false" type="medium" usage="DATE" formatindex="27">
-      <FormatCode>NN, DD.MMM.YY</FormatCode>
+    <FormatElement msgid="PercentFormatskey2" default="true" type="long" usage="PERCENT_NUMBER" formatindex="9">
+      <FormatCode>0,00%</FormatCode>
+    </FormatElement>
+    <FormatElement msgid="CurrencyFormatskey1" default="true" type="short" usage="CURRENCY"  formatindex="12">
+      <FormatCode>#.##0 [CURRENCY];-#.##0 [CURRENCY]</FormatCode>
+    </FormatElement>
+    <FormatElement msgid="CurrencyFormatskey2" default="false" type="medium" usage="CURRENCY"  formatindex="13">
+      <FormatCode>#.##0,00 [CURRENCY];-#.##0,00 [CURRENCY]</FormatCode>
+    </FormatElement>
+    <FormatElement msgid="CurrencyFormatskey3" default="false" type="medium" usage="CURRENCY"  formatindex="14">
+      <FormatCode>#.##0 [CURRENCY];[RED]-#.##0 [CURRENCY]</FormatCode>
+    </FormatElement>
+    <FormatElement msgid="CurrencyFormatskey4" default="true" type="medium" usage="CURRENCY"  formatindex="15">
+      <FormatCode>#.##0,00 [CURRENCY];[RED]-#.##0,00 [CURRENCY]</FormatCode>
+    </FormatElement>
+    <FormatElement msgid="CurrencyFormatskey5" default="false" type="medium" usage="CURRENCY"  formatindex="16">
+      <FormatCode>#.##0,00 CCC</FormatCode>
+    </FormatElement>
+    <FormatElement msgid="CurrencyFormatskey6" default="false" type="medium" usage="CURRENCY"  formatindex="17">
+      <FormatCode>#.##0,-- [CURRENCY];[RED]-#.##0,-- [CURRENCY]</FormatCode>
     </FormatElement>
     <FormatElement msgid="DateFormatskey11" default="true" type="short" usage="DATE" formatindex="18">
       <FormatCode>D.MM.YY</FormatCode>
     </FormatElement>
-    <FormatElement msgid="DateFormatskey12" default="false" type="short" usage="DATE" formatindex="31">
-      <FormatCode>MM.DD</FormatCode>
-    </FormatElement>
     <FormatElement msgid="DateFormatskey14" default="true" type="long" usage="DATE" formatindex="19">
       <FormatCode>NNNNDD, MMMM YYYY</FormatCode>
     </FormatElement>
+    <FormatElement msgid="DateFormatskey6" default="true" type="medium" usage="DATE" formatindex="20">
+      <FormatCode>DD.MM.YY</FormatCode>
+    </FormatElement>
+    <FormatElement msgid="DateFormatskey5" default="false" type="medium" usage="DATE" formatindex="21">
+      <FormatCode>DD.MM.YYYY</FormatCode>
+    </FormatElement>
     <FormatElement msgid="DateFormatskey15" default="false" type="long" usage="DATE" formatindex="22">
       <FormatCode>D, MMM YY</FormatCode>
     </FormatElement>
     <FormatElement msgid="DateFormatskey16" default="false" type="long" usage="DATE" formatindex="23">
       <FormatCode>D, MMM YYYY</FormatCode>
     </FormatElement>
+    <FormatElement msgid="DateFormatskey21" default="false" type="long" usage="DATE" formatindex="24">
+      <FormatCode>D, MMM YYYY</FormatCode>
+    </FormatElement>
     <FormatElement msgid="DateFormatskey17" default="false" type="long" usage="DATE" formatindex="25">
       <FormatCode>D, MMMM YYYY</FormatCode>
     </FormatElement>
+    <FormatElement msgid="DateFormatskey22" default="false" type="long" usage="DATE" formatindex="26">
+      <FormatCode>D, MMMM YY</FormatCode>
+    </FormatElement>
+    <FormatElement msgid="DateFormatskey10" default="false" type="medium" usage="DATE" formatindex="27">
+      <FormatCode>NN, DD.MMM.YY</FormatCode>
+    </FormatElement>
     <FormatElement msgid="DateFormatskey18" default="false" type="long" usage="DATE" formatindex="28">
       <FormatCode>NN, D, MMM YY</FormatCode>
     </FormatElement>
@@ -114,41 +143,30 @@
     <FormatElement msgid="DateFormatskey20" default="false" type="long" usage="DATE" formatindex="30">
       <FormatCode>NNNND, MMMM YYYY</FormatCode>
     </FormatElement>
-    <FormatElement msgid="DateFormatskey21" default="false" type="long" usage="DATE" formatindex="24">
-      <FormatCode>D, MMM YYYY</FormatCode>
-    </FormatElement>
-    <FormatElement msgid="DateFormatskey22" default="false" type="long" usage="DATE" formatindex="26">
-      <FormatCode>D, MMMM YY</FormatCode>
-    </FormatElement>
-    <FormatElement msgid="FixedFormatskey1" default="true" type="medium" usage="FIXED_NUMBER" formatindex="0">
-      <FormatCode>General</FormatCode>
-    </FormatElement>
-    <FormatElement msgid="FixedFormatskey2" default="true" type="short" usage="FIXED_NUMBER" formatindex="1">
-      <FormatCode>0</FormatCode>
-    </FormatElement>
-    <FormatElement msgid="FixedFormatskey3" default="false" type="medium" usage="FIXED_NUMBER" formatindex="2">
-      <FormatCode>0,00</FormatCode>
+    <FormatElement msgid="DateFormatskey12" default="false" type="short" usage="DATE" formatindex="31">
+      <FormatCode>MM.DD</FormatCode>
     </FormatElement>
-    <FormatElement msgid="FixedFormatskey4" default="false" type="short" usage="FIXED_NUMBER" formatindex="3">
-      <FormatCode>#.##0</FormatCode>
+    <FormatElement msgid="DateFormatskey7" default="false" type="medium" usage="DATE" formatindex="32">
+      <FormatCode>YY-MM-DD</FormatCode>
     </FormatElement>
-    <FormatElement msgid="FixedFormatskey5" default="false" type="medium" usage="FIXED_NUMBER" formatindex="4">
-      <FormatCode>#.##0,00</FormatCode>
+    <FormatElement msgid="DateFormatskey8" default="false" type="medium" usage="DATE" formatindex="33">
+      <FormatCode>YYYY-MM-DD</FormatCode>
+      <DefaultName>ISO 8601</DefaultName>
     </FormatElement>
-    <FormatElement msgid="FixedFormatskey6" default="false" type="medium" usage="FIXED_NUMBER" formatindex="5">
-      <FormatCode>#.###,00</FormatCode>
+    <FormatElement msgid="DateFormatskey1" default="false" type="medium" usage="DATE" formatindex="34">
+      <FormatCode>MM.YY</FormatCode>
     </FormatElement>
-    <FormatElement msgid="ScientificFormatskey1" default="true" type="medium" usage="SCIENTIFIC_NUMBER" formatindex="6">
-      <FormatCode>0,00E+00</FormatCode>
+    <FormatElement msgid="DateFormatskey2" default="false" type="medium" usage="DATE" formatindex="35">
+      <FormatCode>MMM.DD</FormatCode>
     </FormatElement>
-    <FormatElement msgid="ScientificFormatskey2" default="false" type="medium" usage="SCIENTIFIC_NUMBER" formatindex="7">
-      <FormatCode>0,00E+000</FormatCode>
+    <FormatElement msgid="DateFormatskey3" default="false" type="medium" usage="DATE" formatindex="36">
+      <FormatCode>MMMM</FormatCode>
     </FormatElement>
-    <FormatElement msgid="PercentFormatskey1" default="true" type="short" usage="PERCENT_NUMBER" formatindex="8">
-      <FormatCode>0%</FormatCode>
+    <FormatElement msgid="DateFormatskey4" default="false" type="medium" usage="DATE" formatindex="37">
+      <FormatCode>QQ YY</FormatCode>
     </FormatElement>
-    <FormatElement msgid="PercentFormatskey2" default="true" type="long" usage="PERCENT_NUMBER" formatindex="9">
-      <FormatCode>0,00%</FormatCode>
+    <FormatElement msgid="DateFormatskey9" default="false" type="medium" usage="DATE" formatindex="38">
+      <FormatCode>WW</FormatCode>
     </FormatElement>
     <FormatElement msgid="TimeFormatskey1" default="false" type="short" usage="TIME" formatindex="39">
       <FormatCode>HH:MM</FormatCode>
@@ -177,24 +195,6 @@
     <FormatElement msgid="DateTimeFormatskey2" default="false" type="medium" usage="DATE_TIME" formatindex="47">
       <FormatCode>DD.MM.YYYY HH:MM:SS AM/PM</FormatCode>
     </FormatElement>
-    <FormatElement msgid="CurrencyFormatskey1" default="true" type="short" usage="CURRENCY"  formatindex="12">
-      <FormatCode>#.##0 [CURRENCY];-#.##0 [CURRENCY]</FormatCode>
-    </FormatElement>
-    <FormatElement msgid="CurrencyFormatskey2" default="false" type="medium" usage="CURRENCY"  formatindex="13">
-      <FormatCode>#.##0,00 [CURRENCY];-#.##0,00 [CURRENCY]</FormatCode>
-    </FormatElement>
-    <FormatElement msgid="CurrencyFormatskey3" default="false" type="medium" usage="CURRENCY"  formatindex="14">
-      <FormatCode>#.##0 [CURRENCY];[RED]-#.##0 [CURRENCY]</FormatCode>
-    </FormatElement>
-    <FormatElement msgid="CurrencyFormatskey4" default="true" type="medium" usage="CURRENCY"  formatindex="15">
-      <FormatCode>#.##0,00 [CURRENCY];[RED]-#.##0,00 [CURRENCY]</FormatCode>
-    </FormatElement>
-    <FormatElement msgid="CurrencyFormatskey5" default="false" type="medium" usage="CURRENCY"  formatindex="16">
-      <FormatCode>#.##0,00 CCC</FormatCode>
-    </FormatElement>
-    <FormatElement msgid="CurrencyFormatskey6" default="false" type="medium" usage="CURRENCY"  formatindex="17">
-      <FormatCode>#.##0,-- [CURRENCY];[RED]-#.##0,-- [CURRENCY]</FormatCode>
-    </FormatElement>
   </LC_FORMAT>
   <LC_COLLATION ref="sh_RS"/>
   <LC_SEARCH>
commit 0fe4a70f26107a47765348802290adef0b265997
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Mon Jul 1 16:31:52 2013 +0200

    typo in comment
    
    Change-Id: Id81813365a36ce03a60f051994da8d8951c92054

diff --git a/include/svtools/roadmapwizard.hxx b/include/svtools/roadmapwizard.hxx
index 35067f1..27ad86b 100644
--- a/include/svtools/roadmapwizard.hxx
+++ b/include/svtools/roadmapwizard.hxx
@@ -42,7 +42,7 @@ namespace svt
     //====================================================================
     //= RoadmapWizard
     //====================================================================
-    /** is - no, not a wizard for a raodmap, but the base class for wizards
+    /** is - no, not a wizard for a roadmap, but the base class for wizards
         <em>supporting</em> a roadmap.
 
         The basic new concept introduced is a <em>path</em>:<br/>
commit a1df1de6ec140cfe49160fe08cc9eee7c0a60ba9
Author: Andras Timar <atimar at suse.com>
Date:   Mon Jul 1 17:55:35 2013 +0200

    Updated core
    Project: help  a804914de5db3aef91f8c244db6acf59a1da0f78

diff --git a/helpcontent2 b/helpcontent2
index e26aa35..a804914 160000
--- a/helpcontent2
+++ b/helpcontent2
@@ -1 +1 @@
-Subproject commit e26aa35eb646a5f0e1256c72af000595c4845016
+Subproject commit a804914de5db3aef91f8c244db6acf59a1da0f78
commit b9ebdadf5a6ebf22b4df7589d86dd8fdfb675b1e
Author: Ariel Constenla-Haile <arielch at apache.org>
Date:   Tue May 7 05:39:15 2013 +0000

    Resolves: fdo#66027 #i122116# Remove GalleryExplorer member functions
    
    (cherry picked from commit e94681fb47e3c5bdba486cd8feca92705d44840d)
    
    Conflicts:
    	sc/source/ui/app/typemap.cxx
    	sc/source/ui/view/galwrap.cxx
    	sc/source/ui/view/makefile.mk
    	sc/source/ui/view/tabvwsh9.cxx
    	sd/source/ui/view/drviews9.cxx
    	svx/Package_inc.mk
    	svx/inc/GalleryControl.hxx
    	svx/inc/galbrws2.hxx
    	svx/inc/svx/galbrws.hxx
    	svx/inc/svx/gallery.hxx
    	svx/source/gallery2/GalleryControl.cxx
    	svx/source/gallery2/galbrws.cxx
    	svx/source/gallery2/galbrws2.cxx
    	svx/source/gallery2/galexpl.cxx
    	sw/source/ui/shells/basesh.cxx
    
    Change-Id: I49c2b99ca551f058b852c0e5e28cc2fe8c205031

diff --git a/include/sfx2/sfxcommands.h b/include/sfx2/sfxcommands.h
index 3f4df5c..78cbd7a 100644
--- a/include/sfx2/sfxcommands.h
+++ b/include/sfx2/sfxcommands.h
@@ -41,6 +41,7 @@
 #define CMD_SID_OBJECT                              ".uno:ObjectMenue"
 #define CMD_SID_OPENDOC                             ".uno:Open"
 #define CMD_SID_WEBHTML                             ".uno:WebHtml"
+#define CMD_SID_GALLERY_BG_BRUSH                    ".uno:BackgroundImage"
 #define CMD_SID_OPENHYPERLINK                       ".uno:OpenHyperlink"
 #define CMD_SID_DOCINFO_TITLE                       ".uno:DocInfoTitle"
 #define CMD_SID_OPENTEMPLATE                        ".uno:OpenTemplate"
diff --git a/include/svx/galbrws.hxx b/include/svx/galbrws.hxx
index 3eebaf6..2dffc16 100644
--- a/include/svx/galbrws.hxx
+++ b/include/svx/galbrws.hxx
@@ -26,8 +26,6 @@
 #include <tools/urlobj.hxx>
 #include "svx/svxdllapi.h"
 
-#define GALLERYBROWSER() ((GalleryBrowser*)( SfxViewFrame::Current()->GetChildWindow(GalleryChildWindow::GetChildWindowId())->GetWindow()))
-
 class SVX_DLLPUBLIC GalleryChildWindow : public SfxChildWindow
 {
 public:
@@ -76,12 +74,7 @@ public:
                                             Window* pParent, const ResId& rResId );
                             ~GalleryBrowser();
 
-    INetURLObject           GetURL() const;
-    String                  GetFilterName() const;
-    Graphic                 GetGraphic() const;
-    sal_Bool                    IsLinkage() const;
-
-    sal_Bool                    KeyInput( const KeyEvent& rKEvt, Window* pWindow );
+    sal_Bool                KeyInput( const KeyEvent& rKEvt, Window* pWindow );
 };
 
 #endif // _SVX_GALBRWS_HXX_
diff --git a/include/svx/gallery.hxx b/include/svx/gallery.hxx
index 778474b..1fbec79 100644
--- a/include/svx/gallery.hxx
+++ b/include/svx/gallery.hxx
@@ -26,16 +26,6 @@
 #include <vector>
 #include "svx/svxdllapi.h"
 
-#define SGA_FORMAT_NONE     0x00000000L
-#define SGA_FORMAT_STRING   0x00000001L
-#define SGA_FORMAT_GRAPHIC  0x00000010L
-#define SGA_FORMAT_SOUND    0x00000100L
-#define SGA_FORMAT_OLE          0x00001000L
-#define SGA_FORMAT_SVDRAW   0x00010000L
-#define SGA_FORMAT_ALL      0xFFFFFFFFL
-
-#define SVX_GALLERY() (GalleryExplorer::GetGallery())
-
 // Defines for preinstalled themes
 // Has to be in sync with svx/inc/galtheme.hrc
 #define GALLERY_THEME_3D                1
@@ -60,21 +50,8 @@ class OutputDevice;
 
 class SVX_DLLPUBLIC GalleryExplorer
 {
-private:
-
-    SVX_DLLPRIVATE static Gallery*              ImplGetGallery();
-
 public:
 
-    static GalleryExplorer*     GetGallery();
-
-public:
-
-    INetURLObject               GetURL() const;
-    String                      GetFilterName() const;
-    Graphic                     GetGraphic() const;
-    sal_Bool                        IsLinkage() const;
-
     static bool                 FillThemeList( std::vector<String>& rThemeList );
 
                                 // FillObjList is filling rObjList with Strings of the internal Gallery Object URL
@@ -88,11 +65,6 @@ public:
     static sal_Bool                 InsertURL( const String& rThemeName, const String& rURL );
     static sal_Bool                 InsertURL( sal_uIntPtr nThemeId, const String& rURL );
 
-    static sal_Bool                 InsertURL( const String& rThemeName, const String& rURL,
-                                           const sal_uIntPtr nSgaFormat /* = SGA_FORMAT_ALL */ );
-    static sal_Bool                 InsertURL( sal_uIntPtr nThemeId, const String& rURL,
-                                           const sal_uIntPtr nSgaFormat /* = SGA_FORMAT_ALL */ );
-
     static sal_Bool                 GetGraphicObj( const String& rThemeName, sal_uIntPtr nPos,
                                                Graphic* pGraphic = NULL, BitmapEx* pThumb = NULL,
                                                sal_Bool bProgess = sal_False );
diff --git a/include/svx/galleryitem.hxx b/include/svx/galleryitem.hxx
new file mode 100644
index 0000000..738eede
--- /dev/null
+++ b/include/svx/galleryitem.hxx
@@ -0,0 +1,76 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef _SVX_GALLERYITEMITEM_HXX
+#define _SVX_GALLERYITEMITEM_HXX
+
+#include <svx/svxdllapi.h>
+#include <svl/poolitem.hxx>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/graphic/XGraphic.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+
+// property names map those from css::gallery::GalleryItem
+// with exception of "AsLink" and "FilterName"
+#define SVXGALLERYITEM_TYPE     "GalleryItemType"
+#define SVXGALLERYITEM_LINK     "AsLink"
+#define SVXGALLERYITEM_URL      "URL"
+#define SVXGALLERYITEM_FILTER   "FilterName"
+#define SVXGALLERYITEM_DRAWING  "Drawing"
+#define SVXGALLERYITEM_GRAPHIC  "Graphic"
+#define SVXGALLERYITEM_PARAMS   6
+#define SVXGALLERYITEM_ARGNAME  "GalleryItem"
+
+DBG_NAMEEX_VISIBILITY( SvxGalleryItem, SVX_DLLPUBLIC )
+
+class SVX_DLLPUBLIC SvxGalleryItem : public SfxPoolItem
+{
+    sal_Int8 m_nType;
+    sal_Bool m_bIsLink;
+    rtl::OUString m_aURL;
+    rtl::OUString m_aFilterName;
+    com::sun::star::uno::Reference< com::sun::star::lang::XComponent > m_xDrawing;
+    com::sun::star::uno::Reference< com::sun::star::graphic::XGraphic > m_xGraphic;
+
+public:
+    TYPEINFO();
+
+    SvxGalleryItem();
+    SvxGalleryItem( const SvxGalleryItem& );
+    SvxGalleryItem( const sal_uInt16 nId );
+    ~SvxGalleryItem();
+
+    sal_Int8 GetType() const { return m_nType; }
+    sal_Bool IsLink() const { return m_bIsLink; }
+    const rtl::OUString GetURL() const { return m_aURL; }
+    const rtl::OUString GetFilterName() const { return m_aFilterName; }
+    const com::sun::star::uno::Reference< com::sun::star::lang::XComponent > GetDrawing() const { return m_xDrawing; }
+    const com::sun::star::uno::Reference< com::sun::star::graphic::XGraphic > GetGraphic() const { return m_xGraphic; }
+
+    // pure virtual methods from SfxPoolItem
+    virtual int          operator==( const SfxPoolItem& ) const;
+    virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
+    // bridge to UNO
+    virtual bool         QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
+    virtual bool         PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
+    // not implemented
+    virtual SfxPoolItem* Create(SvStream &, sal_uInt16) const;
+    virtual SvStream&    Store(SvStream &, sal_uInt16 nItemVersion) const;
+};
+
+#endif
diff --git a/include/svx/svxcommands.h b/include/svx/svxcommands.h
index 266d3d6..61cbd2c 100644
--- a/include/svx/svxcommands.h
+++ b/include/svx/svxcommands.h
@@ -80,6 +80,8 @@
 #define CMD_SID_ATTRIBUTES_LINE                     ".uno:FormatLine"
 #define CMD_SID_FM_FORMATTEDFIELD                   ".uno:FormattedField"
 #define CMD_SID_UNGROUP                             ".uno:FormatUngroup"
+#define CMD_SID_GALLERY_ENABLE_ADDCOPY              ".uno:GalleryEnableAddCopy"
+#define CMD_SID_GALLERY_FORMATS                     ".uno:InsertGalleryPic"
 #define CMD_SID_ATTR_GRAF_CROP                      ".uno:GrafAttrCrop"
 #define CMD_SID_GRFFILTER_MOSAIC                    ".uno:GraphicFilterMosaic"
 #define CMD_SID_GRFFILTER_POSTER                    ".uno:GraphicFilterPoster"
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index c1d12a2..836f87f 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -549,7 +549,6 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
 	sc/source/ui/view/drawview \
 	sc/source/ui/view/editsh \
 	sc/source/ui/view/formatsh \
-	sc/source/ui/view/galwrap \
 	sc/source/ui/view/gridmerg \
 	sc/source/ui/view/gridwin \
 	sc/source/ui/view/gridwin2 \
diff --git a/sc/source/ui/app/typemap.cxx b/sc/source/ui/app/typemap.cxx
index b5e1d96..1972d52 100644
--- a/sc/source/ui/app/typemap.cxx
+++ b/sc/source/ui/app/typemap.cxx
@@ -88,6 +88,7 @@
 #include <svx/xlncapit.hxx>
 #include <svx/xlinjoit.hxx>
 #include <svx/AffineMatrixItem.hxx>
+#include <svx/galleryitem.hxx>
 
 // #i25616#
 #include <svx/sdshitm.hxx>
diff --git a/sc/source/ui/view/galwrap.cxx b/sc/source/ui/view/galwrap.cxx
deleted file mode 100644
index 5c9deba..0000000
--- a/sc/source/ui/view/galwrap.cxx
+++ /dev/null
@@ -1,64 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <vcl/graph.hxx>
-#include <svx/gallery.hxx>
-#include <sfx2/app.hxx>
-
-// -----------------------------------------------------------------------
-
-Graphic GalleryGetGraphic()
-{
-    GalleryExplorer* pGal = SVX_GALLERY();
-    OSL_ENSURE( pGal, "Wo ist die Gallery?" );
-    return pGal->GetGraphic();
-}
-
-sal_uInt16 GallerySGA_FORMAT_GRAPHIC()
-{
-    return SGA_FORMAT_GRAPHIC;
-}
-
-sal_Bool GalleryIsLinkage()
-{
-    GalleryExplorer* pGal = SVX_GALLERY();
-    OSL_ENSURE( pGal, "Wo ist die Gallery?" );
-    return pGal->IsLinkage();
-}
-
-String GalleryGetFullPath()
-{
-    GalleryExplorer* pGal = SVX_GALLERY();
-    OSL_ENSURE( pGal, "Wo ist die Gallery?" );
-
-    return pGal->GetURL().GetMainURL(INetURLObject::NO_DECODE);
-    // URL as stored in GraphicLink must be encoded
-}
-
-String GalleryGetFilterName()
-{
-    GalleryExplorer* pGal = SVX_GALLERY();
-    OSL_ENSURE( pGal, "Wo ist die Gallery?" );
-    return pGal->GetFilterName();
-}
-
-
-
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabvwsh9.cxx b/sc/source/ui/view/tabvwsh9.cxx
index 66a6000..b573b98 100644
--- a/sc/source/ui/view/tabvwsh9.cxx
+++ b/sc/source/ui/view/tabvwsh9.cxx
@@ -35,13 +35,8 @@
 #include "userdat.hxx"
 #include "docsh.hxx"
 
-// forwards (apparently because of ancient compiler limits not in headers!?)
-
-sal_uInt16  GallerySGA_FORMAT_GRAPHIC();
-Graphic GalleryGetGraphic       ();
-sal_Bool    GalleryIsLinkage        ();
-String  GalleryGetFullPath      ();
-String  GalleryGetFilterName    ();
+#include <svx/galleryitem.hxx>
+#include <com/sun/star/gallery/GalleryItemType.hpp>
 
 class SvxIMapDlg;
 
@@ -83,46 +78,33 @@ void ScTabViewShell::ExecGallery( SfxRequest& rReq )
 {
     const SfxItemSet* pArgs = rReq.GetArgs();
 
-    if ( pArgs )
-    {
-        const SfxPoolItem* pItem = NULL;
-        SfxItemState eState = pArgs->GetItemState(SID_GALLERY_FORMATS, sal_True, &pItem);
-        if ( eState == SFX_ITEM_SET )
-        {
-            sal_uInt32 nFormats = ((const SfxUInt32Item*)pItem)->GetValue();
-
-            /******************************************************************
-            * Graphik einfuegen
-            ******************************************************************/
-            if ( nFormats & GallerySGA_FORMAT_GRAPHIC() )
-            {
-                MakeDrawLayer();
+    SFX_ITEMSET_ARG( pArgs, pGalleryItem, SvxGalleryItem, SID_GALLERY_FORMATS, sal_False );
+    if ( !pGalleryItem )
+        return;
 
-                Graphic aGraphic = GalleryGetGraphic();
-                Point   aPos     = GetInsertPos();
-
-                String aPath, aFilter;
-                if ( GalleryIsLinkage() )           // als Link einfuegen?
-                {
-                    aPath = GalleryGetFullPath();
-                    aFilter = GalleryGetFilterName();
-                }
+    sal_Int8 nType( pGalleryItem->GetType() );
+    if ( nType == com::sun::star::gallery::GalleryItemType::GRAPHIC )
+    {
+        MakeDrawLayer();
 
-                PasteGraphic( aPos, aGraphic, aPath, aFilter );
-            }
-            else if ( nFormats & SGA_FORMAT_SOUND )
-            {
-                //  for sounds (linked or not), insert a hyperlink button,
-                //  like in Impress and Writer
+        Graphic aGraphic( pGalleryItem->GetGraphic() );
+        Point   aPos     = GetInsertPos();
 
-                GalleryExplorer* pGal = SVX_GALLERY();
-                if ( pGal )
-                {
-                    const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, pGal->GetURL().GetMainURL( INetURLObject::NO_DECODE ) );
-                       GetViewFrame()->GetDispatcher()->Execute( SID_INSERT_AVMEDIA, SFX_CALLMODE_SYNCHRON, &aMediaURLItem, 0L );
-                }
-            }
+        String aPath, aFilter;
+        if ( pGalleryItem->IsLink() ) // als Link einfuegen?
+        {
+            aPath = pGalleryItem->GetURL();
+            aFilter = pGalleryItem->GetFilterName();
         }
+
+        PasteGraphic( aPos, aGraphic, aPath, aFilter );
+    }
+    else if ( nType == com::sun::star::gallery::GalleryItemType::MEDIA )
+    {
+        //  for sounds (linked or not), insert a hyperlink button,
+        //  like in Impress and Writer
+        const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, pGalleryItem->GetURL() );
+        GetViewFrame()->GetDispatcher()->Execute( SID_INSERT_AVMEDIA, SFX_CALLMODE_SYNCHRON, &aMediaURLItem, 0L );
     }
 }
 
diff --git a/sd/source/core/typemap.cxx b/sd/source/core/typemap.cxx
index cc029fc..0eabb41 100644
--- a/sd/source/core/typemap.cxx
+++ b/sd/source/core/typemap.cxx
@@ -98,6 +98,7 @@
 #include <svx/xflftrit.hxx>
 #include <svx/xlinjoit.hxx>
 #include <svx/AffineMatrixItem.hxx>
+#include <svx/galleryitem.hxx>
 
 #define SFX_TYPEMAP
 #include "sdslots.hxx"
diff --git a/sd/source/ui/animations/CustomAnimationDialog.cxx b/sd/source/ui/animations/CustomAnimationDialog.cxx
index 8a861c2..6f1ca05 100644
--- a/sd/source/ui/animations/CustomAnimationDialog.cxx
+++ b/sd/source/ui/animations/CustomAnimationDialog.cxx
@@ -1751,7 +1751,7 @@ void CustomAnimationEffectTabPage::openSoundFileDialog()
         if( nPos < 0 ) // not in Soundliste
         {
             // try to insert in Gallery
-            if( GalleryExplorer::InsertURL( GALLERY_THEME_USERSOUNDS, aFile, SGA_FORMAT_SOUND ) )
+            if( GalleryExplorer::InsertURL( GALLERY_THEME_USERSOUNDS, aFile ) )
             {
                 clearSoundListBox();
                 fillSoundListBox();
diff --git a/sd/source/ui/animations/SlideTransitionPane.cxx b/sd/source/ui/animations/SlideTransitionPane.cxx
index bcb4af2..eb638b7 100644
--- a/sd/source/ui/animations/SlideTransitionPane.cxx
+++ b/sd/source/ui/animations/SlideTransitionPane.cxx
@@ -964,7 +964,7 @@ void SlideTransitionPane::openSoundFileDialog()
         else // not in sound list
         {
             // try to insert into gallery
-            if( GalleryExplorer::InsertURL( GALLERY_THEME_USERSOUNDS, aFile, SGA_FORMAT_SOUND ) )
+            if( GalleryExplorer::InsertURL( GALLERY_THEME_USERSOUNDS, aFile ) )
             {
                 updateSoundList();
                 bValidSoundFile = lcl_findSoundInList( maSoundList, aFile, nPos );
diff --git a/sd/source/ui/view/drviews9.cxx b/sd/source/ui/view/drviews9.cxx
index b69db95..b6ccd5e 100644
--- a/sd/source/ui/view/drviews9.cxx
+++ b/sd/source/ui/view/drviews9.cxx
@@ -57,6 +57,9 @@
 #include "sdresid.hxx"
 #include "fupoor.hxx"
 
+#include <svx/galleryitem.hxx>
+#include <com/sun/star/gallery/GalleryItemType.hpp>
+
 namespace sd {
 
 
@@ -68,125 +71,121 @@ void DrawViewShell::ExecGallery(SfxRequest& rReq)
 
     const SfxItemSet* pArgs = rReq.GetArgs();
 
-    if ( pArgs )
-    {
-        const sal_uInt32        nFormats = ( (SfxUInt32Item&) pArgs->Get( SID_GALLERY_FORMATS ) ).GetValue();
-        GalleryExplorer*    pGal = SVX_GALLERY();
+    SFX_ITEMSET_ARG( pArgs, pGalleryItem, SvxGalleryItem, SID_GALLERY_FORMATS, sal_False );
+    if ( !pGalleryItem )
+        return;
 
-        if ( pGal )
+    GetDocSh()->SetWaitCursor( sal_True );
+
+    sal_Int8 nType( pGalleryItem->GetType() );
+    // insert graphic
+    if (nType == com::sun::star::gallery::GalleryItemType::GRAPHIC)
+    {
+        Graphic aGraphic( pGalleryItem->GetGraphic() );
+
+        // reduce size if necessary
+        Window aWindow (GetActiveWindow());
+        aWindow.SetMapMode(aGraphic.GetPrefMapMode());
+        Size aSizePix = aWindow.LogicToPixel(aGraphic.GetPrefSize());
+        aWindow.SetMapMode( MapMode(MAP_100TH_MM) );
+        Size aSize = aWindow.PixelToLogic(aSizePix);
+
+        // constrain size to page size if necessary
+        SdrPage* pPage = mpDrawView->GetSdrPageView()->GetPage();
+        Size aPageSize = pPage->GetSize();
+        aPageSize.Width() -= pPage->GetLftBorder() + pPage->GetRgtBorder();
+        aPageSize.Height() -= pPage->GetUppBorder() + pPage->GetLwrBorder();
+
+
+        // Falls Grafik zu gross, wird die Grafik
+        // in die Seite eingepasst
+        if ( ( ( aSize.Height() > aPageSize.Height() ) || ( aSize.Width()   > aPageSize.Width() ) ) &&
+            aSize.Height() && aPageSize.Height() )
         {
-            GetDocSh()->SetWaitCursor( sal_True );
+            float fGrfWH =  (float)aSize.Width() /
+                            (float)aSize.Height();
+            float fWinWH =  (float)aPageSize.Width() /
+                            (float)aPageSize.Height();
 
-            // insert graphic
-            if (nFormats & SGA_FORMAT_GRAPHIC)
+            // constrain size to page size if necessary
+            if ((fGrfWH != 0.F) && (fGrfWH < fWinWH))
             {
-                Graphic aGraphic = pGal->GetGraphic();
-
-                // reduce size if necessary
-                Window aWindow (GetActiveWindow());
-                aWindow.SetMapMode(aGraphic.GetPrefMapMode());
-                Size aSizePix = aWindow.LogicToPixel(aGraphic.GetPrefSize());
-                aWindow.SetMapMode( MapMode(MAP_100TH_MM) );
-                Size aSize = aWindow.PixelToLogic(aSizePix);
-
-                // constrain size to page size if necessary
-                SdrPage* pPage = mpDrawView->GetSdrPageView()->GetPage();
-                Size aPageSize = pPage->GetSize();
-                aPageSize.Width() -= pPage->GetLftBorder() + pPage->GetRgtBorder();
-                aPageSize.Height() -= pPage->GetUppBorder() + pPage->GetLwrBorder();
-
-
-                // if the graphic is to big, we fit it into the page
-                if ( ( ( aSize.Height() > aPageSize.Height() ) || ( aSize.Width()   > aPageSize.Width() ) ) &&
-                    aSize.Height() && aPageSize.Height() )
-                {
-                    float fGrfWH =  (float)aSize.Width() /
-                                    (float)aSize.Height();
-                    float fWinWH =  (float)aPageSize.Width() /
-                                    (float)aPageSize.Height();
+                aSize.Width() = (long)(aPageSize.Height() * fGrfWH);
+                aSize.Height()= aPageSize.Height();
+            }
+            else
+            {
+                aSize.Width() = aPageSize.Width();
+                aSize.Height()= (long)(aPageSize.Width() / fGrfWH);
+            }
+        }
 
-                    // adjust graphic to page size (scales)
-                    if ((fGrfWH != 0.F) && (fGrfWH < fWinWH))
-                    {
-                        aSize.Width() = (long)(aPageSize.Height() * fGrfWH);
-                        aSize.Height()= aPageSize.Height();
-                    }
-                    else
-                    {
-                        aSize.Width() = aPageSize.Width();
-                        aSize.Height()= (long)(aPageSize.Width() / fGrfWH);
-                    }
-                }
+        // set output rectangle for graphic
+        Point aPnt ((aPageSize.Width()  - aSize.Width())  / 2,
+                    (aPageSize.Height() - aSize.Height()) / 2);
+        aPnt += Point(pPage->GetLftBorder(), pPage->GetUppBorder());
+        Rectangle aRect (aPnt, aSize);
 
+        SdrGrafObj* pGrafObj = NULL;
 
-                // set output rectangle for graphic
-                Point aPnt ((aPageSize.Width()  - aSize.Width())  / 2,
-                            (aPageSize.Height() - aSize.Height()) / 2);
-                aPnt += Point(pPage->GetLftBorder(), pPage->GetUppBorder());
-                Rectangle aRect (aPnt, aSize);
+        sal_Bool bInsertNewObject = sal_True;
 
-                SdrGrafObj* pGrafObj = NULL;
+        if ( mpDrawView->AreObjectsMarked() )
+        {
+            // is there a empty graphic object?
+            const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
 
-                sal_Bool bInsertNewObject = sal_True;
+            if (rMarkList.GetMarkCount() == 1)
+            {

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list