[Libreoffice-commits] core.git: 4 commits - extras/source sc/inc sc/Library_sc.mk sc/source sc/uiconfig sc/UIConfig_scalc.mk vcl/source

Tomaž Vajngerl tomaz.vajngerl at collabora.com
Mon Mar 31 00:45:23 PDT 2014


 extras/source/glade/libreoffice-catalog.xml.in  |    9 
 sc/Library_sc.mk                                |    5 
 sc/UIConfig_scalc.mk                            |    1 
 sc/inc/address.hxx                              |  567 ++++++++++-------
 sc/inc/pivot.hxx                                |   93 +-
 sc/source/core/data/pivot2.cxx                  |  169 ++---
 sc/source/core/tool/address.cxx                 |  332 ++++------
 sc/source/ui/dbgui/PivotLayoutDialog.cxx        |  643 +++++++++++++++++++
 sc/source/ui/dbgui/PivotLayoutTreeList.cxx      |  125 +++
 sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx  |  151 ++++
 sc/source/ui/dbgui/PivotLayoutTreeListData.cxx  |  204 ++++++
 sc/source/ui/dbgui/PivotLayoutTreeListLabel.cxx |   90 ++
 sc/source/ui/inc/PivotLayoutDialog.hxx          |  136 ++++
 sc/source/ui/inc/PivotLayoutTreeList.hxx        |   36 +
 sc/source/ui/inc/PivotLayoutTreeListBase.hxx    |   76 ++
 sc/source/ui/inc/PivotLayoutTreeListData.hxx    |   37 +
 sc/source/ui/inc/PivotLayoutTreeListLabel.hxx   |   37 +
 sc/source/ui/view/tabvwshc.cxx                  |   12 
 sc/uiconfig/scalc/ui/pivottablelayoutdialog.ui  |  789 ++++++++++++++++++++++++
 vcl/source/window/window2.cxx                   |    6 
 20 files changed, 2998 insertions(+), 520 deletions(-)

New commits:
commit 6f455018b4b4a52314c837b50a40e653866628ce
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date:   Mon Mar 31 09:43:49 2014 +0200

    sc: clean-up address.hxx/cxx
    
    Change-Id: Iea3d90fb22631b48b25836b73a8dad7bd979a58e

diff --git a/sc/inc/address.hxx b/sc/inc/address.hxx
index 3c08c60..1c03aa3 100644
--- a/sc/inc/address.hxx
+++ b/sc/inc/address.hxx
@@ -202,14 +202,12 @@ inline SCTAB SanitizeTab( SCTAB nTab, SCTAB nMaxTab )
 #define SCA_VALID_TAB2      0x4000
 #define SCA_VALID           0x8000
 
-#define SCA_ABS               SCA_VALID \
-                            | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE
+#define SCA_ABS    SCA_VALID | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE
 
-#define SCR_ABS               SCA_ABS \
-                            | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE | SCA_TAB2_ABSOLUTE
+#define SCR_ABS    SCA_ABS | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE | SCA_TAB2_ABSOLUTE
 
-#define SCA_ABS_3D          SCA_ABS | SCA_TAB_3D
-#define SCR_ABS_3D          SCR_ABS | SCA_TAB_3D
+#define SCA_ABS_3D SCA_ABS | SCA_TAB_3D
+#define SCR_ABS_3D SCR_ABS | SCA_TAB_3D
 
 //  ScAddress
 class ScAddress
@@ -224,19 +222,21 @@ public:
     enum Uninitialized      { UNINITIALIZED };
     enum InitializeInvalid  { INITIALIZE_INVALID };
 
-    struct Details {
+    struct Details
+    {
         formula::FormulaGrammar::AddressConvention  eConv;
         SCROW       nRow;
         SCCOL       nCol;
-        inline Details( formula::FormulaGrammar::AddressConvention eConvP, SCROW nRowP, SCCOL nColP )
-            : eConv( eConvP ), nRow( nRowP ), nCol( nColP )
-            {}
-        inline Details( formula::FormulaGrammar::AddressConvention eConvP, ScAddress const & rAddr )
-            : eConv( eConvP ), nRow( rAddr.Row() ), nCol( rAddr.Col() )
-            {}
-        inline Details( formula::FormulaGrammar::AddressConvention eConvP)
-            : eConv( eConvP ), nRow( 0 ), nCol( 0 )
-            {}
+
+        inline Details( formula::FormulaGrammar::AddressConvention eConvP, SCROW nRowP, SCCOL nColP ) :
+            eConv(eConvP), nRow(nRowP), nCol(nColP)
+        {}
+        inline Details( formula::FormulaGrammar::AddressConvention eConvP, ScAddress const & rAddr ) :
+            eConv(eConvP), nRow(rAddr.Row()),  nCol(rAddr.Col())
+        {}
+        inline Details( formula::FormulaGrammar::AddressConvention eConvP) :
+            eConv(eConvP), nRow(0), nCol(0)
+        {}
         /* Use the formula::FormulaGrammar::AddressConvention associated with rAddr::Tab() */
         Details( const ScDocument* pDoc, const ScAddress & rAddr );
     };
@@ -244,86 +244,138 @@ public:
 
     struct ExternalInfo
     {
-        OUString maTabName;
+        OUString    maTabName;
         sal_uInt16  mnFileId;
         bool        mbExternal;
 
-        inline ExternalInfo() : mnFileId(0), mbExternal(false) {}
+        inline ExternalInfo() :
+            mnFileId(0), mbExternal(false)
+        {}
     };
 
-    inline ScAddress() : nRow(0), nCol(0), nTab(0) {}
-    inline ScAddress( SCCOL nColP, SCROW nRowP, SCTAB nTabP )
-        : nRow(nRowP), nCol(nColP), nTab(nTabP)
-        {}
+    inline ScAddress() :
+        nRow(0), nCol(0), nTab(0)
+    {}
+    inline ScAddress( SCCOL nColP, SCROW nRowP, SCTAB nTabP ) :
+        nRow(nRowP), nCol(nColP), nTab(nTabP)
+    {}
     /** Yes, it is what it seems to be: Uninitialized. May be used for
         performance reasons if it is initialized by other means. */
-    inline ScAddress( Uninitialized ) {}
-    inline ScAddress( InitializeInvalid )
-        : nRow(-1), nCol(-1), nTab(-1) {}
-    inline ScAddress( const ScAddress& r )
-        : nRow(r.nRow), nCol(r.nCol), nTab(r.nTab)
-        {}
-    inline ScAddress& operator=( const ScAddress& r );
+    inline ScAddress( Uninitialized )
+    {}
+    inline ScAddress( InitializeInvalid ) :
+        nRow(-1), nCol(-1), nTab(-1)
+    {}
+    inline ScAddress( const ScAddress& rAddress ) :
+        nRow(rAddress.nRow), nCol(rAddress.nCol), nTab(rAddress.nTab)
+    {}
+    inline ScAddress& operator=( const ScAddress& rAddress );
 
     inline void Set( SCCOL nCol, SCROW nRow, SCTAB nTab );
-    inline SCROW Row() const { return nRow; }
-    inline SCCOL Col() const { return nCol; }
-    inline SCTAB Tab() const { return nTab; }
-    inline void SetRow( SCROW nRowP ) { nRow = nRowP; }
-    inline void SetCol( SCCOL nColP ) { nCol = nColP; }
-    inline void SetTab( SCTAB nTabP ) { nTab = nTabP; }
-    inline void SetInvalid() { nRow = -1; nCol = -1; nTab = -1; }
-    inline bool IsValid() const { return (nRow >= 0) && (nCol >= 0) && (nTab >= 0); }
-    inline void PutInOrder( ScAddress& r );
-    inline void IncRow( SCsROW n=1 ) { nRow = sal::static_int_cast<SCROW>(nRow + n); }
-    inline void IncCol( SCsCOL n=1 ) { nCol = sal::static_int_cast<SCCOL>(nCol + n); }
-    inline void IncTab( SCsTAB n=1 ) { nTab = sal::static_int_cast<SCTAB>(nTab + n); }
+
+    inline SCROW Row() const
+    {
+        return nRow;
+    }
+
+    inline SCCOL Col() const
+    {
+        return nCol;
+    }
+    inline SCTAB Tab() const
+    {
+        return nTab;
+    }
+    inline void SetRow( SCROW nRowP )
+    {
+        nRow = nRowP;
+    }
+    inline void SetCol( SCCOL nColP )
+    {
+        nCol = nColP;
+    }
+    inline void SetTab( SCTAB nTabP )
+    {
+        nTab = nTabP;
+    }
+    inline void SetInvalid()
+    {
+        nRow = -1;
+        nCol = -1;
+        nTab = -1;
+    }
+    inline bool IsValid() const
+    {
+        return (nRow >= 0) && (nCol >= 0) && (nTab >= 0);
+    }
+
+    inline void PutInOrder( ScAddress& rAddress );
+
+    inline void IncRow( SCsROW nDelta = 1 )
+    {
+        nRow = sal::static_int_cast<SCROW>(nRow + nDelta);
+    }
+    inline void IncCol( SCsCOL nDelta = 1 )
+    {
+        nCol = sal::static_int_cast<SCCOL>(nCol + nDelta);
+    }
+    inline void IncTab( SCsTAB nDelta = 1 )
+    {
+        nTab = sal::static_int_cast<SCTAB>(nTab + nDelta);
+    }
     inline void GetVars( SCCOL& nColP, SCROW& nRowP, SCTAB& nTabP ) const
-    { nColP = nCol; nRowP = nRow; nTabP = nTab; }
+    {
+        nColP = nCol;
+        nRowP = nRow;
+        nTabP = nTab;
+    }
 
-    SC_DLLPUBLIC sal_uInt16 Parse( const OUString&, ScDocument* = NULL,
-                  const Details& rDetails = detailsOOOa1,
-                  ExternalInfo* pExtInfo = NULL,
-                  const ::com::sun::star::uno::Sequence<
-                    com::sun::star::sheet::ExternalLinkInfo>* pExternalLinks = NULL );
+    SC_DLLPUBLIC sal_uInt16 Parse(
+                    const OUString&, ScDocument* = NULL,
+                    const Details& rDetails = detailsOOOa1,
+                    ExternalInfo* pExtInfo = NULL,
+                    const css::uno::Sequence<css::sheet::ExternalLinkInfo>* pExternalLinks = NULL );
 
-    SC_DLLPUBLIC OUString Format( sal_uInt16 = 0, const ScDocument* = NULL,
-                 const Details& rDetails = detailsOOOa1) const;
+    SC_DLLPUBLIC OUString Format( sal_uInt16 nFlags = 0,
+                                  const ScDocument* pDocument = NULL,
+                                  const Details& rDetails = detailsOOOa1) const;
 
     // The document for the maximum defined sheet number
-    SC_DLLPUBLIC bool Move( SCsCOL dx, SCsROW dy, SCsTAB dz, ScDocument* =NULL );
-    inline bool operator==( const ScAddress& r ) const;
-    inline bool operator!=( const ScAddress& r ) const;
-    inline bool operator<( const ScAddress& r ) const;
-    inline bool operator<=( const ScAddress& r ) const;
-    inline bool operator>( const ScAddress& r ) const;
-    inline bool operator>=( const ScAddress& r ) const;
+    SC_DLLPUBLIC bool Move( SCsCOL nDeltaX, SCsROW nDeltaY, SCsTAB nDeltaZ,
+                            ScDocument* pDocument = NULL );
+
+    inline bool operator==( const ScAddress& rAddress ) const;
+    inline bool operator!=( const ScAddress& rAddress ) const;
+    inline bool operator<( const ScAddress& rAddress ) const;
+    inline bool operator<=( const ScAddress& rAddress ) const;
+    inline bool operator>( const ScAddress& rAddress ) const;
+    inline bool operator>=( const ScAddress& rAddress ) const;
 
     inline size_t hash() const;
 
     /// "A1" or "$A$1" or R1C1 or R[1]C[1]
     OUString GetColRowString( bool bAbsolute = false,
-                            const Details& rDetails = detailsOOOa1) const;
+                              const Details& rDetails = detailsOOOa1) const;
 };
 
-inline void ScAddress::PutInOrder( ScAddress& r )
+inline void ScAddress::PutInOrder( ScAddress& rAddress )
 {
-    if ( r.Col() < Col() )
+    if ( rAddress.Col() < Col() )
     {
-        SCCOL nTmp = r.Col();
-        r.SetCol( Col() );
+        SCCOL nTmp = rAddress.Col();
+        rAddress.SetCol( Col() );
         SetCol( nTmp );
     }
-    if ( r.Row() < Row() )
+    if ( rAddress.Row() < Row() )
     {
-        SCROW nTmp = r.Row();
-        r.SetRow( Row() );
+        SCROW nTmp = rAddress.Row();
+        rAddress.SetRow( Row() );
         SetRow( nTmp );
     }
-    if ( r.Tab() < Tab() )
+    if ( rAddress.Tab() < Tab() )
     {
-        SCTAB nTmp = r.Tab();
-        r.SetTab( Tab() );
+        SCTAB nTmp = rAddress.Tab();
+        rAddress.SetTab( Tab() );
         SetTab( nTmp );
     }
 }
@@ -335,52 +387,52 @@ inline void ScAddress::Set( SCCOL nColP, SCROW nRowP, SCTAB nTabP )
     nTab = nTabP;
 }
 
-inline ScAddress& ScAddress::operator=( const ScAddress& r )
+inline ScAddress& ScAddress::operator=( const ScAddress& rAddress )
 {
-    nCol = r.nCol;
-    nRow = r.nRow;
-    nTab = r.nTab;
+    nCol = rAddress.nCol;
+    nRow = rAddress.nRow;
+    nTab = rAddress.nTab;
     return *this;
 }
 
-inline bool ScAddress::operator==( const ScAddress& r ) const
+inline bool ScAddress::operator==( const ScAddress& rAddress ) const
 {
-    return nRow == r.nRow && nCol == r.nCol && nTab == r.nTab;
+    return nRow == rAddress.nRow && nCol == rAddress.nCol && nTab == rAddress.nTab;
 }
 
-inline bool ScAddress::operator!=( const ScAddress& r ) const
+inline bool ScAddress::operator!=( const ScAddress& rAddress ) const
 {
-    return !operator==( r );
+    return !operator==( rAddress );
 }
 
 /** Same behavior as the old sal_uInt32 nAddress < r.nAddress with encoded
     tab|col|row bit fields. */
-inline bool ScAddress::operator<( const ScAddress& r ) const
+inline bool ScAddress::operator<( const ScAddress& rAddress ) const
 {
-    if (nTab == r.nTab)
+    if (nTab == rAddress.nTab)
     {
-        if (nCol == r.nCol)
-            return nRow < r.nRow;
+        if (nCol == rAddress.nCol)
+            return nRow < rAddress.nRow;
         else
-            return nCol < r.nCol;
+            return nCol < rAddress.nCol;
     }
     else
-        return nTab < r.nTab;
+        return nTab < rAddress.nTab;
 }
 
-inline bool ScAddress::operator<=( const ScAddress& r ) const
+inline bool ScAddress::operator<=( const ScAddress& rAddress ) const
 {
-    return operator<( r ) || operator==( r );
+    return operator<( rAddress ) || operator==( rAddress );
 }
 
-inline bool ScAddress::operator>( const ScAddress& r ) const
+inline bool ScAddress::operator>( const ScAddress& rAddress ) const
 {
-    return !operator<=( r );
+    return !operator<=( rAddress );
 }
 
-inline bool ScAddress::operator>=( const ScAddress& r ) const
+inline bool ScAddress::operator>=( const ScAddress& rAddress ) const
 {
-    return !operator<( r );
+    return !operator<( rAddress );
 }
 
 inline size_t ScAddress::hash() const
@@ -397,9 +449,9 @@ inline size_t ScAddress::hash() const
 
 struct ScAddressHashFunctor
 {
-    size_t operator()( const ScAddress & rAdr ) const
+    size_t operator()( const ScAddress & rAddress ) const
     {
-        return rAdr.hash();
+        return rAddress.hash();
     }
 };
 
@@ -411,52 +463,80 @@ struct ScAddressEqualFunctor
     }
 };
 
-inline bool ValidAddress( const ScAddress& rAddr )
+inline bool ValidAddress( const ScAddress& rAddress )
 {
-    return ValidCol(rAddr.Col()) && ValidRow(rAddr.Row()) && ValidTab(rAddr.Tab());
+    return ValidCol(rAddress.Col()) && ValidRow(rAddress.Row()) && ValidTab(rAddress.Tab());
 }
 
 //  ScRange
 class ScRange
 {
 public:
-    ScAddress aStart, aEnd;
-    inline ScRange() : aStart(), aEnd() {}
-    inline ScRange( ScAddress::Uninitialized e )
-        : aStart( e ), aEnd( e ) {}
-    inline ScRange( ScAddress::InitializeInvalid e )
-        : aStart( e ), aEnd( e ) {}
-    inline ScRange( const ScAddress& s, const ScAddress& e )
-        : aStart( s ), aEnd( e ) { aStart.PutInOrder( aEnd ); }
-    inline ScRange( const ScRange& r ) : aStart( r.aStart ), aEnd( r.aEnd ) {}
-    inline ScRange( const ScAddress& r ) : aStart( r ), aEnd( r ) {}
-    inline ScRange( SCCOL nCol, SCROW nRow, SCTAB nTab )
-        : aStart( nCol, nRow, nTab ), aEnd( aStart ) {}
-    inline ScRange( SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
-             SCCOL nCol2, SCROW nRow2, SCTAB nTab2 )
-        : aStart( nCol1, nRow1, nTab1 ), aEnd( nCol2, nRow2, nTab2 ) {}
-
-    inline ScRange& operator=( const ScRange& r )
-    { aStart = r.aStart; aEnd = r.aEnd; return *this; }
+    ScAddress aStart;
+    ScAddress aEnd;
+
+    inline ScRange() :
+        aStart(), aEnd()
+    {}
+
+    inline ScRange( ScAddress::Uninitialized eUninitialized ) :
+        aStart( eUninitialized ), aEnd( eUninitialized )
+    {}
+    inline ScRange( ScAddress::InitializeInvalid eInvalid ) :
+        aStart( eInvalid ), aEnd( eInvalid )
+    {}
+    inline ScRange( const ScAddress& aInputStart, const ScAddress& aInputEnd ) :
+        aStart( aInputStart ), aEnd( aInputEnd )
+    {
+        aStart.PutInOrder( aEnd );
+    }
+    inline ScRange( const ScRange& rRange ) :
+        aStart( rRange.aStart ), aEnd( rRange.aEnd )
+    {}
+    inline ScRange( const ScAddress& rRange ) :
+        aStart( rRange ), aEnd( rRange )
+    {}
+    inline ScRange( SCCOL nCol, SCROW nRow, SCTAB nTab ) :
+        aStart( nCol, nRow, nTab ), aEnd( aStart )
+    {}
+    inline ScRange( SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2 ) :
+        aStart( nCol1, nRow1, nTab1 ), aEnd( nCol2, nRow2, nTab2 )
+    {}
+
+    inline ScRange& operator=( const ScRange& rRange )
+    {
+        aStart = rRange.aStart;
+        aEnd = rRange.aEnd;
+        return *this;
+    }
     inline ScRange& operator=( const ScAddress& rPos )
-    { aStart = aEnd = rPos; return *this; }
-    inline void SetInvalid() { aStart.SetInvalid(); aEnd.SetInvalid(); }
-    inline bool IsValid() const { return aStart.IsValid() && aEnd.IsValid(); }
+    {
+        aStart = aEnd = rPos;
+        return *this;
+    }
+    inline void SetInvalid()
+    {
+        aStart.SetInvalid();
+        aEnd.SetInvalid();
+    }
+    inline bool IsValid() const
+    {
+        return aStart.IsValid() && aEnd.IsValid();
+    }
     inline bool In( const ScAddress& ) const;   ///< is Address& in Range?
     inline bool In( const ScRange& ) const;     ///< is Range& in Range?
 
     SC_DLLPUBLIC sal_uInt16 Parse( const OUString&, ScDocument* = NULL,
-                  const ScAddress::Details& rDetails = ScAddress::detailsOOOa1,
-                  ScAddress::ExternalInfo* pExtInfo = NULL,
-                  const ::com::sun::star::uno::Sequence<
-                    com::sun::star::sheet::ExternalLinkInfo>* pExternalLinks = NULL );
+                                   const ScAddress::Details& rDetails = ScAddress::detailsOOOa1,
+                                   ScAddress::ExternalInfo* pExtInfo = NULL,
+                                   const css::uno::Sequence<css::sheet::ExternalLinkInfo>* pExternalLinks = NULL );
 
     SC_DLLPUBLIC sal_uInt16 ParseAny( const OUString&, ScDocument* = NULL,
-                     const ScAddress::Details& rDetails = ScAddress::detailsOOOa1 );
+                                      const ScAddress::Details& rDetails = ScAddress::detailsOOOa1 );
     SC_DLLPUBLIC sal_uInt16 ParseCols( const OUString&, ScDocument* = NULL,
-                     const ScAddress::Details& rDetails = ScAddress::detailsOOOa1 );
+                                       const ScAddress::Details& rDetails = ScAddress::detailsOOOa1 );
     SC_DLLPUBLIC sal_uInt16 ParseRows( const OUString&, ScDocument* = NULL,
-                     const ScAddress::Details& rDetails = ScAddress::detailsOOOa1 );
+                                       const ScAddress::Details& rDetails = ScAddress::detailsOOOa1 );
 
     /** Parse an Excel style reference up to and including the sheet name
         separator '!', including detection of external documents and sheet
@@ -478,29 +558,29 @@ public:
             Or NULL if a 3D sheet header could be parsed but
             bOnlyAcceptSingle==true was given.
      */
-    const sal_Unicode* Parse_XL_Header( const sal_Unicode* pString, const ScDocument* pDoc,
-            OUString& rExternDocName, OUString& rStartTabName, OUString& rEndTabName, sal_uInt16& nFlags,
-            bool bOnlyAcceptSingle,
-            const ::com::sun::star::uno::Sequence<
-                com::sun::star::sheet::ExternalLinkInfo>* pExternalLinks = NULL );
+    const sal_Unicode* Parse_XL_Header( const sal_Unicode* pString, const ScDocument* pDocument,
+                                        OUString& rExternDocName, OUString& rStartTabName,
+                                        OUString& rEndTabName, sal_uInt16& nFlags,
+                                        bool bOnlyAcceptSingle,
+                                        const css::uno::Sequence<css::sheet::ExternalLinkInfo>* pExternalLinks = NULL );
 
-    SC_DLLPUBLIC OUString Format(sal_uInt16 = 0, const ScDocument* = NULL,
-                 const ScAddress::Details& rDetails = ScAddress::detailsOOOa1) const;
+    SC_DLLPUBLIC OUString Format(sal_uInt16 nFlags= 0, const ScDocument* pDocument = NULL,
+                                 const ScAddress::Details& rDetails = ScAddress::detailsOOOa1) const;
 
     inline void GetVars( SCCOL& nCol1, SCROW& nRow1, SCTAB& nTab1,
-        SCCOL& nCol2, SCROW& nRow2, SCTAB& nTab2 ) const;
+                         SCCOL& nCol2, SCROW& nRow2, SCTAB& nTab2 ) const;
     // The document for the maximum defined sheet number
-    SC_DLLPUBLIC bool Move( SCsCOL dx, SCsROW dy, SCsTAB dz, ScDocument* =NULL );
+    SC_DLLPUBLIC bool Move( SCsCOL aDeltaX, SCsROW aDeltaY, SCsTAB aDeltaZ, ScDocument* pDocument = NULL );
     SC_DLLPUBLIC void Justify();
     SC_DLLPUBLIC void ExtendTo( const ScRange& rRange );
-    SC_DLLPUBLIC bool Intersects( const ScRange& ) const;    // do two ranges intersect?
+    SC_DLLPUBLIC bool Intersects( const ScRange& rRange ) const;    // do two ranges intersect?
     void PutInOrder();
-    inline bool operator==( const ScRange& r ) const;
-    inline bool operator!=( const ScRange& r ) const;
-    inline bool operator<( const ScRange& r ) const;
-    inline bool operator<=( const ScRange& r ) const;
-    inline bool operator>( const ScRange& r ) const;
-    inline bool operator>=( const ScRange& r ) const;
+    inline bool operator==( const ScRange& rRange ) const;
+    inline bool operator!=( const ScRange& rRange ) const;
+    inline bool operator<( const ScRange& rRange ) const;
+    inline bool operator<=( const ScRange& rRange ) const;
+    inline bool operator>( const ScRange& rRange ) const;
+    inline bool operator>=( const ScRange& rRange ) const;
 
     /// Hash 2D area ignoring table number.
     inline size_t hashArea() const;
@@ -509,20 +589,20 @@ public:
 };
 
 inline void ScRange::GetVars( SCCOL& nCol1, SCROW& nRow1, SCTAB& nTab1,
-        SCCOL& nCol2, SCROW& nRow2, SCTAB& nTab2 ) const
+                              SCCOL& nCol2, SCROW& nRow2, SCTAB& nTab2 ) const
 {
     aStart.GetVars( nCol1, nRow1, nTab1 );
     aEnd.GetVars( nCol2, nRow2, nTab2 );
 }
 
-inline bool ScRange::operator==( const ScRange& r ) const
+inline bool ScRange::operator==( const ScRange& rRange ) const
 {
-    return ( (aStart == r.aStart) && (aEnd == r.aEnd) );
+    return ( (aStart == rRange.aStart) && (aEnd == rRange.aEnd) );
 }
 
-inline bool ScRange::operator!=( const ScRange& r ) const
+inline bool ScRange::operator!=( const ScRange& rRange ) const
 {
-    return !operator==( r );
+    return !operator==( rRange );
 }
 
 /// Sort on upper left corner, if equal then use lower right too.
@@ -531,35 +611,35 @@ inline bool ScRange::operator<( const ScRange& r ) const
     return aStart < r.aStart || (aStart == r.aStart && aEnd < r.aEnd) ;
 }
 
-inline bool ScRange::operator<=( const ScRange& r ) const
+inline bool ScRange::operator<=( const ScRange& rRange ) const
 {
-    return operator<( r ) || operator==( r );
+    return operator<( rRange ) || operator==( rRange );
 }
 
-inline bool ScRange::operator>( const ScRange& r ) const
+inline bool ScRange::operator>( const ScRange& rRange ) const
 {
-    return !operator<=( r );
+    return !operator<=( rRange );
 }
 
-inline bool ScRange::operator>=( const ScRange& r ) const
+inline bool ScRange::operator>=( const ScRange& rRange ) const
 {
-    return !operator<( r );
+    return !operator<( rRange );
 }
 
-inline bool ScRange::In( const ScAddress& rAddr ) const
+inline bool ScRange::In( const ScAddress& rAddress ) const
 {
     return
-        aStart.Col() <= rAddr.Col() && rAddr.Col() <= aEnd.Col() &&
-        aStart.Row() <= rAddr.Row() && rAddr.Row() <= aEnd.Row() &&
-        aStart.Tab() <= rAddr.Tab() && rAddr.Tab() <= aEnd.Tab();
+        aStart.Col() <= rAddress.Col() && rAddress.Col() <= aEnd.Col() &&
+        aStart.Row() <= rAddress.Row() && rAddress.Row() <= aEnd.Row() &&
+        aStart.Tab() <= rAddress.Tab() && rAddress.Tab() <= aEnd.Tab();
 }
 
-inline bool ScRange::In( const ScRange& r ) const
+inline bool ScRange::In( const ScRange& rRange ) const
 {
     return
-        aStart.Col() <= r.aStart.Col() && r.aEnd.Col() <= aEnd.Col() &&
-        aStart.Row() <= r.aStart.Row() && r.aEnd.Row() <= aEnd.Row() &&
-        aStart.Tab() <= r.aStart.Tab() && r.aEnd.Tab() <= aEnd.Tab();
+        aStart.Col() <= rRange.aStart.Col() && rRange.aEnd.Col() <= aEnd.Col() &&
+        aStart.Row() <= rRange.aStart.Row() && rRange.aEnd.Row() <= aEnd.Row() &&
+        aStart.Tab() <= rRange.aStart.Tab() && rRange.aEnd.Tab() <= aEnd.Tab();
 }
 
 inline size_t ScRange::hashArea() const
@@ -574,8 +654,8 @@ inline size_t ScRange::hashArea() const
     return
         (static_cast<size_t>(aStart.Row()) << 26) ^ // start row <= 2^6
         (static_cast<size_t>(aStart.Col()) << 21) ^ // start column <= 2^5
-        (static_cast<size_t>(aEnd.Col()) << 15) ^   // end column <= 2^6
-        static_cast<size_t>(aEnd.Row());            // end row <= 2^15
+        (static_cast<size_t>(aEnd.Col())   << 15) ^ // end column <= 2^6
+         static_cast<size_t>(aEnd.Row());           // end row <= 2^15
 }
 
 inline size_t ScRange::hashStartColumn() const
@@ -586,7 +666,7 @@ inline size_t ScRange::hashStartColumn() const
     return
         (static_cast<size_t>(aStart.Col()) << 24) ^ // start column <= 2^8
         (static_cast<size_t>(aStart.Row()) << 16) ^ // start row <= 2^8
-        static_cast<size_t>(aEnd.Row());
+         static_cast<size_t>(aEnd.Row());
 }
 
 struct ScRangeHashAreaFunctor
@@ -617,87 +697,136 @@ private:
     ScRange aRange[2];
 
 public:
-    ScRangePair() {}
+    ScRangePair()
+    {}
     ScRangePair( const ScRangePair& r )
-        { aRange[0] = r.aRange[0]; aRange[1] = r.aRange[1]; }
-    ScRangePair( const ScRange& r1, const ScRange& r2 )
-        {  aRange[0] = r1; aRange[1] = r2; }
+    {
+        aRange[0] = r.aRange[0];
+        aRange[1] = r.aRange[1];
+    }
+    ScRangePair( const ScRange& rRange1, const ScRange& rRange2 )
+    {
+        aRange[0] = rRange1;
+        aRange[1] = rRange2;
+    }
 
-    inline ScRangePair& operator= ( const ScRangePair& r );
-    const ScRange&      GetRange( sal_uInt16 n ) const { return aRange[n]; }
-    ScRange&            GetRange( sal_uInt16 n ) { return aRange[n]; }
+    inline ScRangePair& operator= ( const ScRangePair& rRange );
+    const ScRange& GetRange( sal_uInt16 n ) const
+    {
+        return aRange[n];
+    }
+    ScRange& GetRange( sal_uInt16 n )
+    {
+        return aRange[n];
+    }
     inline bool operator==( const ScRangePair& ) const;
     inline bool operator!=( const ScRangePair& ) const;
 };
 
-inline ScRangePair& ScRangePair::operator= ( const ScRangePair& r )
+inline ScRangePair& ScRangePair::operator= ( const ScRangePair& rRange )
 {
-    aRange[0] = r.aRange[0];
-    aRange[1] = r.aRange[1];
+    aRange[0] = rRange.aRange[0];
+    aRange[1] = rRange.aRange[1];
     return *this;
 }
 
-inline bool ScRangePair::operator==( const ScRangePair& r ) const
+inline bool ScRangePair::operator==( const ScRangePair& rRange ) const
 {
-    return ( (aRange[0] == r.aRange[0]) && (aRange[1] == r.aRange[1]) );
+    return (aRange[0] == rRange.aRange[0]) &&
+           (aRange[1] == rRange.aRange[1]);
 }
 
-inline bool ScRangePair::operator!=( const ScRangePair& r ) const
+inline bool ScRangePair::operator!=( const ScRangePair& rRange ) const
 {
-    return !operator==( r );
+    return !operator==( rRange );
 }
 
 //  ScRefAddress
 class ScRefAddress
 {
-            ScAddress           aAdr;
-            bool                bRelCol;
-            bool                bRelRow;
-            bool                bRelTab;
+private:
+    ScAddress           aAdr;
+    bool                bRelCol;
+    bool                bRelRow;
+    bool                bRelTab;
 public:
-    inline ScRefAddress() : bRelCol(false), bRelRow(false), bRelTab(false)
-        {}
+    inline ScRefAddress() :
+        bRelCol(false), bRelRow(false), bRelTab(false)
+    {}
     inline ScRefAddress( SCCOL nCol, SCROW nRow, SCTAB nTab,
-            bool bRelColP, bool bRelRowP, bool bRelTabP ) :
+                         bool bRelColP, bool bRelRowP, bool bRelTabP ) :
         aAdr(nCol, nRow, nTab),
         bRelCol(bRelColP), bRelRow(bRelRowP), bRelTab(bRelTabP)
-        {}
+    {}
     inline ScRefAddress( const ScAddress& rAdr,
-            bool bRelColP, bool bRelRowP, bool bRelTabP ) :
+                         bool bRelColP, bool bRelRowP, bool bRelTabP ) :
         aAdr(rAdr),
         bRelCol(bRelColP), bRelRow(bRelRowP), bRelTab(bRelTabP)
-        {}
+    {}
     inline ScRefAddress( const ScRefAddress& rRef ) :
-            aAdr(rRef.aAdr), bRelCol(rRef.bRelCol), bRelRow(rRef.bRelRow),
-            bRelTab(rRef.bRelTab)
-            {}
+        aAdr(rRef.aAdr), bRelCol(rRef.bRelCol), bRelRow(rRef.bRelRow),
+        bRelTab(rRef.bRelTab)
+    {}
 
-    inline  ScRefAddress&   operator=( const ScRefAddress& );
+    inline ScRefAddress& operator=( const ScRefAddress& );
 
-    inline  bool    IsRelCol() const { return bRelCol; }
-    inline  bool    IsRelRow() const { return bRelRow; }
-    inline  bool    IsRelTab() const { return bRelTab; }
+    inline bool IsRelCol() const
+    {
+        return bRelCol;
+    }
+    inline bool IsRelRow() const
+    {
+        return bRelRow;
+    }
+    inline bool IsRelTab() const
+    {
+        return bRelTab;
+    }
+
+    inline void SetRelCol(bool bNewRelCol)
+    {
+        bRelCol = bNewRelCol;
+    }
+    inline void SetRelRow(bool bNewRelRow)
+    {
+        bRelRow = bNewRelRow;
+    }
+    inline void SetRelTab(bool bNewRelTab)
+    {
+        bRelTab = bNewRelTab;
+    }
 
-    inline  void    SetRelCol(bool bNewRelCol) { bRelCol = bNewRelCol; }
-    inline  void    SetRelRow(bool bNewRelRow) { bRelRow = bNewRelRow; }
-    inline  void    SetRelTab(bool bNewRelTab) { bRelTab = bNewRelTab; }
+    inline void Set( const ScAddress& rAdr,
+                     bool bNewRelCol, bool bNewRelRow, bool bNewRelTab );
+    inline void Set( SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
+                     bool bNewRelCol, bool bNewRelRow, bool bNewRelTab );
 
-    inline  void    Set( const ScAddress& rAdr,
-                        bool bNewRelCol, bool bNewRelRow, bool bNewRelTab );
-    inline  void    Set( SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
-                        bool bNewRelCol, bool bNewRelRow, bool bNewRelTab );
+    inline const ScAddress& GetAddress() const
+    {
+        return aAdr;
+    }
 
-    inline  const ScAddress&    GetAddress() const { return aAdr; }
-    inline  SCCOL   Col() const { return aAdr.Col(); }
-    inline  SCROW   Row() const { return aAdr.Row(); }
-    inline  SCTAB   Tab() const { return aAdr.Tab(); }
+    inline SCCOL Col() const
+    {
+        return aAdr.Col();
+    }
+    inline SCROW Row() const
+    {
+        return aAdr.Row();
+    }
+    inline SCTAB Tab() const
+    {
+        return aAdr.Tab();
+    }
 
-    inline  bool    operator == ( const ScRefAddress& r ) const;
-    inline  bool    operator != ( const ScRefAddress& r ) const
-                    { return !(operator==(r)); }
+    inline bool operator == ( const ScRefAddress& r ) const;
+    inline bool operator != ( const ScRefAddress& r ) const
+    {
+        return !(operator==(r));
+    }
 
-            OUString  GetRefString( ScDocument* pDoc, SCTAB nActTab,
-                                  const ScAddress::Details& rDetails = ScAddress::detailsOOOa1) const;
+    OUString  GetRefString( ScDocument* pDocument, SCTAB nActTab,
+                            const ScAddress::Details& rDetails = ScAddress::detailsOOOa1) const;
 };
 
 inline ScRefAddress& ScRefAddress::operator=( const ScRefAddress& rRef )
@@ -710,7 +839,7 @@ inline ScRefAddress& ScRefAddress::operator=( const ScRefAddress& rRef )
 }
 
 inline void ScRefAddress::Set( const ScAddress& rAdr,
-        bool bNewRelCol, bool bNewRelRow, bool bNewRelTab )
+                               bool bNewRelCol, bool bNewRelRow, bool bNewRelTab )
 {
     aAdr = rAdr;
     bRelCol = bNewRelCol;
@@ -719,7 +848,7 @@ inline void ScRefAddress::Set( const ScAddress& rAdr,
 }
 
 inline void ScRefAddress::Set( SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
-        bool bNewRelCol, bool bNewRelRow, bool bNewRelTab )
+                               bool bNewRelCol, bool bNewRelRow, bool bNewRelTab )
 {
     aAdr.Set( nNewCol, nNewRow, nNewTab);
     bRelCol = bNewRelCol;
@@ -727,10 +856,12 @@ inline void ScRefAddress::Set( SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
     bRelTab = bNewRelTab;
 }
 
-inline bool ScRefAddress::operator==( const ScRefAddress& r ) const
+inline bool ScRefAddress::operator==( const ScRefAddress& rRefAddress ) const
 {
-    return aAdr == r.aAdr && bRelCol == r.bRelCol && bRelRow == r.bRelRow &&
-        bRelTab == r.bRelTab;
+    return aAdr == rRefAddress.aAdr &&
+           bRelCol == rRefAddress.bRelCol &&
+           bRelRow == rRefAddress.bRelRow &&
+           bRelTab == rRefAddress.bRelTab;
 }
 
 // Global functions
@@ -751,16 +882,16 @@ template< typename T > void PutInOrder( T& nStart, T& nEnd )
     }
 }
 
-bool ConvertSingleRef( ScDocument* pDoc, const OUString& rRefString,
-        SCTAB nDefTab, ScRefAddress& rRefAddress,
-        const ScAddress::Details& rDetails = ScAddress::detailsOOOa1,
-        ScAddress::ExternalInfo* pExtInfo = NULL );
+bool ConvertSingleRef( ScDocument* pDocument, const OUString& rRefString,
+                       SCTAB nDefTab, ScRefAddress& rRefAddress,
+                       const ScAddress::Details& rDetails = ScAddress::detailsOOOa1,
+                       ScAddress::ExternalInfo* pExtInfo = NULL );
 
-bool ConvertDoubleRef(ScDocument* pDoc, const OUString& rRefString,
-        SCTAB nDefTab, ScRefAddress& rStartRefAddress,
-        ScRefAddress& rEndRefAddress,
-        const ScAddress::Details& rDetails = ScAddress::detailsOOOa1,
-        ScAddress::ExternalInfo* pExtInfo = NULL );
+bool ConvertDoubleRef( ScDocument* pDocument, const OUString& rRefString,
+                       SCTAB nDefTab, ScRefAddress& rStartRefAddress,
+                       ScRefAddress& rEndRefAddress,
+                       const ScAddress::Details& rDetails = ScAddress::detailsOOOa1,
+                       ScAddress::ExternalInfo* pExtInfo = NULL );
 
 /// append alpha representation of column to buffer
 SC_DLLPUBLIC void ScColToAlpha( OUStringBuffer& rBuffer, SCCOL nCol);
diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx
index 3cdd2fe..825daae 100644
--- a/sc/source/core/tool/address.cxx
+++ b/sc/source/core/tool/address.cxx
@@ -34,7 +34,7 @@
 #include <sfx2/objsh.hxx>
 #include <tools/urlobj.hxx>
 
-using namespace ::com::sun::star;
+using namespace css;
 
 const ScAddress::Details ScAddress::detailsOOOa1( formula::FormulaGrammar::CONV_OOO, 0, 0 );
 
@@ -43,8 +43,7 @@ ScAddress::Details::Details ( const ScDocument* pDoc,
     eConv( pDoc->GetAddressConvention() ),
     nRow( rAddr.Row() ),
     nCol( rAddr.Col() )
-{
-}
+{}
 
 namespace {
 
@@ -130,9 +129,7 @@ const sal_Unicode* parseQuotedName( const sal_Unicode* p, OUString& rName )
 
 }
 
-static long int
-sal_Unicode_strtol ( const sal_Unicode*  p,
-                     const sal_Unicode** pEnd )
+static long int sal_Unicode_strtol ( const sal_Unicode*  p, const sal_Unicode** pEnd )
 {
     long int accum = 0, prev = 0;
     bool is_neg = false;
@@ -180,13 +177,13 @@ static const sal_Unicode* lcl_eatWhiteSpace( const sal_Unicode* p )
              result in the identical file ID. Else <TRUE/>.
  */
 static bool lcl_ScRange_External_TabSpan(
-        ScRange & rRange,
-        sal_uInt16 & rFlags,
-        ScAddress::ExternalInfo* pExtInfo,
-        const OUString & rExternDocName,
-        const OUString & rStartTabName,
-        const OUString & rEndTabName,
-        ScDocument* pDoc )
+                            ScRange & rRange,
+                            sal_uInt16 & rFlags,
+                            ScAddress::ExternalInfo* pExtInfo,
+                            const OUString & rExternDocName,
+                            const OUString & rStartTabName,
+                            const OUString & rEndTabName,
+                            ScDocument* pDoc )
 {
     if (rExternDocName.isEmpty())
         return !pExtInfo || !pExtInfo->mbExternal;
@@ -258,11 +255,10 @@ static bool lcl_ScRange_External_TabSpan(
         Starting _within_ a quoted name, but still may be 3D; quoted name stops
         at pMsoxlQuoteStop
  */
-static const sal_Unicode *
-lcl_XL_ParseSheetRef( const sal_Unicode* start,
-                      OUString& rExternTabName,
-                      bool allow_3d,
-                      const sal_Unicode* pMsoxlQuoteStop )
+static const sal_Unicode * lcl_XL_ParseSheetRef( const sal_Unicode* start,
+                                                 OUString& rExternTabName,
+                                                 bool bAllow3D,
+                                                 const sal_Unicode* pMsoxlQuoteStop )
 {
     OUString aTabName;
     const sal_Unicode *p = start;
@@ -296,8 +292,8 @@ lcl_XL_ParseSheetRef( const sal_Unicode* start,
             return NULL;
         if (p == pMsoxlQuoteStop)
             ++p;    // position on ! of ...'!...
-        if( *p != '!' && ( !allow_3d || *p != ':' ) )
-            return (!allow_3d && *p == ':') ? p : start;
+        if( *p != '!' && ( !bAllow3D || *p != ':' ) )
+            return (!bAllow3D && *p == ':') ? p : start;
     }
     else if( *p == '\'')
     {
@@ -360,8 +356,8 @@ lcl_XL_ParseSheetRef( const sal_Unicode* start,
                 break;
         }
 
-        if( *p != '!' && ( !allow_3d || *p != ':' ) )
-            return (!allow_3d && *p == ':') ? p : start;
+        if( *p != '!' && ( !bAllow3D || *p != ':' ) )
+            return (!bAllow3D && *p == ':') ? p : start;
 
         aTabName += OUString( start, sal::static_int_cast<sal_Int32>( p - start ) );
     }
@@ -383,7 +379,7 @@ lcl_XL_ParseSheetRef( const sal_Unicode* start,
     name is not numeric.
  */
 static bool lcl_XL_getExternalDoc( const sal_Unicode** ppErrRet, OUString& rExternDocName,
-        const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks )
+                                   const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks )
 {
     // 1-based, sequence starts with an empty element.
     if (pExternalLinks && pExternalLinks->hasElements())
@@ -427,14 +423,14 @@ static bool lcl_XL_getExternalDoc( const sal_Unicode** ppErrRet, OUString& rExte
 }
 
 const sal_Unicode* ScRange::Parse_XL_Header(
-        const sal_Unicode* p,
-        const ScDocument* pDoc,
-        OUString& rExternDocName,
-        OUString& rStartTabName,
-        OUString& rEndTabName,
-        sal_uInt16& nFlags,
-        bool bOnlyAcceptSingle,
-        const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks )
+                                const sal_Unicode* p,
+                                const ScDocument* pDoc,
+                                OUString& rExternDocName,
+                                OUString& rStartTabName,
+                                OUString& rEndTabName,
+                                sal_uInt16& nFlags,
+                                bool bOnlyAcceptSingle,
+                                const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks )
 {
     const sal_Unicode* startTabs, *start = p;
     sal_uInt16 nSaveFlags = nFlags;
@@ -607,10 +603,9 @@ const sal_Unicode* ScRange::Parse_XL_Header(
     return p;
 }
 
-static const sal_Unicode*
-lcl_r1c1_get_col( const sal_Unicode* p,
-                  const ScAddress::Details& rDetails,
-                  ScAddress* pAddr, sal_uInt16* nFlags )
+static const sal_Unicode* lcl_r1c1_get_col( const sal_Unicode* p,
+                                            const ScAddress::Details& rDetails,
+                                            ScAddress* pAddr, sal_uInt16* nFlags )
 {
     const sal_Unicode *pEnd;
     long int n;
@@ -652,10 +647,11 @@ lcl_r1c1_get_col( const sal_Unicode* p,
 
     return pEnd;
 }
-static inline const sal_Unicode*
-lcl_r1c1_get_row( const sal_Unicode* p,
-                  const ScAddress::Details& rDetails,
-                  ScAddress* pAddr, sal_uInt16* nFlags )
+
+static inline const sal_Unicode* lcl_r1c1_get_row(
+                                    const sal_Unicode* p,
+                                    const ScAddress::Details& rDetails,
+                                    ScAddress* pAddr, sal_uInt16* nFlags )
 {
     const sal_Unicode *pEnd;
     long int n;
@@ -698,13 +694,12 @@ lcl_r1c1_get_row( const sal_Unicode* p,
     return pEnd;
 }
 
-static sal_uInt16
-lcl_ScRange_Parse_XL_R1C1( ScRange& r,
-                           const sal_Unicode* p,
-                           ScDocument* pDoc,
-                           const ScAddress::Details& rDetails,
-                           bool bOnlyAcceptSingle,
-                           ScAddress::ExternalInfo* pExtInfo )
+static sal_uInt16 lcl_ScRange_Parse_XL_R1C1( ScRange& r,
+                                             const sal_Unicode* p,
+                                             ScDocument* pDoc,
+                                             const ScAddress::Details& rDetails,
+                                             bool bOnlyAcceptSingle,
+                                             ScAddress::ExternalInfo* pExtInfo )
 {
     const sal_Unicode* pTmp = NULL;
     OUString aExternDocName, aStartTabName, aEndTabName;
@@ -725,7 +720,7 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
     if( *p == 'R' || *p == 'r' )
     {
         if( NULL == (p = lcl_r1c1_get_row( p, rDetails, &r.aStart, &nFlags )) )
-            goto failed;
+            return 0;
 
         if( *p != 'C' && *p != 'c' )    // full row R#
         {
@@ -761,7 +756,9 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
             return bOnlyAcceptSingle ? 0 : nFlags;
         }
         else if( NULL == (p = lcl_r1c1_get_col( p, rDetails, &r.aStart, &nFlags )))
-            goto failed;
+        {
+            return 0;
+        }
 
         if( p[0] != ':' ||
             (p[1] != 'R' && p[1] != 'r') ||
@@ -798,7 +795,7 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
     else if( *p == 'C' || *p == 'c' )   // full col C#
     {
         if( NULL == (p = lcl_r1c1_get_col( p, rDetails, &r.aStart, &nFlags )))
-            goto failed;
+            return 0;
 
         if( p[0] != ':' || (p[1] != 'C' && p[1] != 'c') ||
             NULL == (pTmp = lcl_r1c1_get_col( p+1, rDetails, &r.aEnd, &nFlags2 )))
@@ -829,12 +826,12 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
         return bOnlyAcceptSingle ? 0 : nFlags;
     }
 
-failed :
     return 0;
 }
 
-static inline const sal_Unicode*
-lcl_a1_get_col( const sal_Unicode* p, ScAddress* pAddr, sal_uInt16* nFlags )
+static inline const sal_Unicode* lcl_a1_get_col( const sal_Unicode* p,
+                                                 ScAddress* pAddr,
+                                                 sal_uInt16* nFlags )
 {
     SCCOL nCol;
 
@@ -856,8 +853,9 @@ lcl_a1_get_col( const sal_Unicode* p, ScAddress* pAddr, sal_uInt16* nFlags )
     return p;
 }
 
-static inline const sal_Unicode*
-lcl_a1_get_row( const sal_Unicode* p, ScAddress* pAddr, sal_uInt16* nFlags )
+static inline const sal_Unicode* lcl_a1_get_row( const sal_Unicode* p,
+                                                 ScAddress* pAddr,
+                                                 sal_uInt16* nFlags )
 {
     const sal_Unicode *pEnd;
     long int n;
@@ -875,13 +873,12 @@ lcl_a1_get_row( const sal_Unicode* p, ScAddress* pAddr, sal_uInt16* nFlags )
     return pEnd;
 }
 
-static sal_uInt16
-lcl_ScRange_Parse_XL_A1( ScRange& r,
-                         const sal_Unicode* p,
-                         ScDocument* pDoc,
-                         bool bOnlyAcceptSingle,
-                         ScAddress::ExternalInfo* pExtInfo,
-                         const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks )
+static sal_uInt16 lcl_ScRange_Parse_XL_A1( ScRange& r,
+                                           const sal_Unicode* p,
+                                           ScDocument* pDoc,
+                                           bool bOnlyAcceptSingle,
+                                           ScAddress::ExternalInfo* pExtInfo,
+                                           const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks )
 {
     const sal_Unicode* tmp1, *tmp2;
     OUString aExternDocName, aStartTabName, aEndTabName; // for external link table
@@ -1022,9 +1019,8 @@ lcl_ScRange_Parse_XL_A1( ScRange& r,
                     used in conjunction with pExtInfo to determine the tab span
                     of a 3D reference.
  */
-static sal_uInt16
-lcl_ScAddress_Parse_OOo( const sal_Unicode* p, ScDocument* pDoc, ScAddress& rAddr,
-                         ScAddress::ExternalInfo* pExtInfo = NULL, ScRange* pRange = NULL )
+static sal_uInt16 lcl_ScAddress_Parse_OOo( const sal_Unicode* p, ScDocument* pDoc, ScAddress& rAddr,
+                                           ScAddress::ExternalInfo* pExtInfo = NULL, ScRange* pRange = NULL )
 {
     sal_uInt16  nRes = 0;
     OUString aDocName;       // der pure Dokumentenname
@@ -1266,38 +1262,37 @@ lcl_ScAddress_Parse_OOo( const sal_Unicode* p, ScDocument* pDoc, ScAddress& rAdd
     return nRes;
 }
 
-static sal_uInt16
-lcl_ScAddress_Parse ( const sal_Unicode* p, ScDocument* pDoc, ScAddress& rAddr,
-                      const ScAddress::Details& rDetails,
-                      ScAddress::ExternalInfo* pExtInfo = NULL,
-                      const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks = NULL )
+static sal_uInt16 lcl_ScAddress_Parse ( const sal_Unicode* p, ScDocument* pDoc, ScAddress& rAddr,
+                                        const ScAddress::Details& rDetails,
+                                        ScAddress::ExternalInfo* pExtInfo = NULL,
+                                        const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks = NULL )
 {
     if( !*p )
         return 0;
 
     switch (rDetails.eConv)
     {
-    default :
-    case formula::FormulaGrammar::CONV_OOO:
+        case formula::FormulaGrammar::CONV_XL_A1:
+        case formula::FormulaGrammar::CONV_XL_OOX:
         {
-            return lcl_ScAddress_Parse_OOo( p, pDoc, rAddr, pExtInfo, NULL );
+            ScRange rRange = rAddr;
+            sal_uInt16 nFlags = lcl_ScRange_Parse_XL_A1(
+                                    rRange, p, pDoc, true, pExtInfo,
+                                    (rDetails.eConv == formula::FormulaGrammar::CONV_XL_OOX ? pExternalLinks : NULL) );
+            rAddr = rRange.aStart;
+            return nFlags;
         }
-
-    case formula::FormulaGrammar::CONV_XL_A1:
-    case formula::FormulaGrammar::CONV_XL_OOX:
+        case formula::FormulaGrammar::CONV_XL_R1C1:
         {
-            ScRange r = rAddr;
-            sal_uInt16 nFlags = lcl_ScRange_Parse_XL_A1( r, p, pDoc, true, pExtInfo,
-                    (rDetails.eConv == formula::FormulaGrammar::CONV_XL_OOX ? pExternalLinks : NULL) );
-            rAddr = r.aStart;
+            ScRange rRange = rAddr;
+            sal_uInt16 nFlags = lcl_ScRange_Parse_XL_R1C1( rRange, p, pDoc, rDetails, true, pExtInfo );
+            rAddr = rRange.aStart;
             return nFlags;
         }
-    case formula::FormulaGrammar::CONV_XL_R1C1:
+        default :
+        case formula::FormulaGrammar::CONV_OOO:
         {
-            ScRange r = rAddr;
-            sal_uInt16 nFlags = lcl_ScRange_Parse_XL_R1C1( r, p, pDoc, rDetails, true, pExtInfo );
-            rAddr = r.aStart;
-            return nFlags;
+            return lcl_ScAddress_Parse_OOo( p, pDoc, rAddr, pExtInfo, NULL );
         }
     }
 }
@@ -1351,19 +1346,19 @@ bool ConvertDoubleRef( ScDocument* pDoc, const OUString& rRefString, SCTAB nDefT
 }
 
 sal_uInt16 ScAddress::Parse( const OUString& r, ScDocument* pDoc,
-                         const Details& rDetails,
-                         ExternalInfo* pExtInfo,
-                         const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks )
+                             const Details& rDetails,
+                             ExternalInfo* pExtInfo,
+                             const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks )
 {
     return lcl_ScAddress_Parse( r.getStr(), pDoc, *this, rDetails, pExtInfo, pExternalLinks );
 }
 
-bool ScRange::Intersects( const ScRange& r ) const
+bool ScRange::Intersects( const ScRange& rRange ) const
 {
     return !(
-        std::min( aEnd.Col(), r.aEnd.Col() ) < std::max( aStart.Col(), r.aStart.Col() )
-     || std::min( aEnd.Row(), r.aEnd.Row() ) < std::max( aStart.Row(), r.aStart.Row() )
-     || std::min( aEnd.Tab(), r.aEnd.Tab() ) < std::max( aStart.Tab(), r.aStart.Tab() )
+        std::min( aEnd.Col(), rRange.aEnd.Col() ) < std::max( aStart.Col(), rRange.aStart.Col() )
+     || std::min( aEnd.Row(), rRange.aEnd.Row() ) < std::max( aStart.Row(), rRange.aStart.Row() )
+     || std::min( aEnd.Tab(), rRange.aEnd.Tab() ) < std::max( aStart.Tab(), rRange.aStart.Tab() )
         );
 }
 
@@ -1410,19 +1405,21 @@ void ScRange::ExtendTo( const ScRange& rRange )
     OSL_ENSURE( rRange.IsValid(), "ScRange::ExtendTo - cannot extend to invalid range" );
     if( IsValid() )
     {
-        aStart.SetCol( ::std::min( aStart.Col(), rRange.aStart.Col() ) );
-        aStart.SetRow( ::std::min( aStart.Row(), rRange.aStart.Row() ) );
-        aStart.SetTab( ::std::min( aStart.Tab(), rRange.aStart.Tab() ) );
-        aEnd.SetCol(   ::std::max( aEnd.Col(),   rRange.aEnd.Col() ) );
-        aEnd.SetRow(   ::std::max( aEnd.Row(),   rRange.aEnd.Row() ) );
-        aEnd.SetTab(   ::std::max( aEnd.Tab(),   rRange.aEnd.Tab() ) );
+        aStart.SetCol( std::min( aStart.Col(), rRange.aStart.Col() ) );
+        aStart.SetRow( std::min( aStart.Row(), rRange.aStart.Row() ) );
+        aStart.SetTab( std::min( aStart.Tab(), rRange.aStart.Tab() ) );
+        aEnd.SetCol(   std::max( aEnd.Col(),   rRange.aEnd.Col() ) );
+        aEnd.SetRow(   std::max( aEnd.Row(),   rRange.aEnd.Row() ) );
+        aEnd.SetTab(   std::max( aEnd.Tab(),   rRange.aEnd.Tab() ) );
     }
     else
         *this = rRange;
 }
 
-static sal_uInt16
-lcl_ScRange_Parse_OOo( ScRange &aRange, const OUString& r, ScDocument* pDoc, ScAddress::ExternalInfo* pExtInfo = NULL )
+static sal_uInt16 lcl_ScRange_Parse_OOo( ScRange& rRange,
+                                         const OUString& r,
+                                         ScDocument* pDoc,
+                                         ScAddress::ExternalInfo* pExtInfo = NULL )
 {
     sal_uInt16 nRes1 = 0, nRes2 = 0;
     sal_Int32 nPos = ScGlobal::FindUnquoted( r, ':');
@@ -1431,17 +1428,17 @@ lcl_ScRange_Parse_OOo( ScRange &aRange, const OUString& r, ScDocument* pDoc, ScA
         OUStringBuffer aTmp(r);
         aTmp[nPos] = 0;
         const sal_Unicode* p = aTmp.getStr();
-        if( (nRes1 = lcl_ScAddress_Parse_OOo( p, pDoc, aRange.aStart, pExtInfo, NULL ) ) != 0 )
+        if( (nRes1 = lcl_ScAddress_Parse_OOo( p, pDoc, rRange.aStart, pExtInfo, NULL ) ) != 0 )
         {
-            aRange.aEnd = aRange.aStart;  // sheet must be initialized identical to first sheet
-            if ( (nRes2 = lcl_ScAddress_Parse_OOo( p + nPos+ 1, pDoc, aRange.aEnd, pExtInfo, &aRange ) ) != 0 )
+            rRange.aEnd = rRange.aStart;  // sheet must be initialized identical to first sheet
+            if ( (nRes2 = lcl_ScAddress_Parse_OOo( p + nPos+ 1, pDoc, rRange.aEnd, pExtInfo, &rRange ) ) != 0 )
             {
                 // PutInOrder / Justify
                 sal_uInt16 nMask, nBits1, nBits2;
                 SCCOL nTempCol;
-                if ( aRange.aEnd.Col() < (nTempCol = aRange.aStart.Col()) )
+                if ( rRange.aEnd.Col() < (nTempCol = rRange.aStart.Col()) )
                 {
-                    aRange.aStart.SetCol(aRange.aEnd.Col()); aRange.aEnd.SetCol(nTempCol);
+                    rRange.aStart.SetCol(rRange.aEnd.Col()); rRange.aEnd.SetCol(nTempCol);
                     nMask = (SCA_VALID_COL | SCA_COL_ABSOLUTE);
                     nBits1 = nRes1 & nMask;
                     nBits2 = nRes2 & nMask;
@@ -1449,9 +1446,9 @@ lcl_ScRange_Parse_OOo( ScRange &aRange, const OUString& r, ScDocument* pDoc, ScA
                     nRes2 = (nRes2 & ~nMask) | nBits1;
                 }
                 SCROW nTempRow;
-                if ( aRange.aEnd.Row() < (nTempRow = aRange.aStart.Row()) )
+                if ( rRange.aEnd.Row() < (nTempRow = rRange.aStart.Row()) )
                 {
-                    aRange.aStart.SetRow(aRange.aEnd.Row()); aRange.aEnd.SetRow(nTempRow);
+                    rRange.aStart.SetRow(rRange.aEnd.Row()); rRange.aEnd.SetRow(nTempRow);
                     nMask = (SCA_VALID_ROW | SCA_ROW_ABSOLUTE);
                     nBits1 = nRes1 & nMask;
                     nBits2 = nRes2 & nMask;
@@ -1459,9 +1456,9 @@ lcl_ScRange_Parse_OOo( ScRange &aRange, const OUString& r, ScDocument* pDoc, ScA
                     nRes2 = (nRes2 & ~nMask) | nBits1;
                 }
                 SCTAB nTempTab;
-                if ( aRange.aEnd.Tab() < (nTempTab = aRange.aStart.Tab()) )
+                if ( rRange.aEnd.Tab() < (nTempTab = rRange.aStart.Tab()) )
                 {
-                    aRange.aStart.SetTab(aRange.aEnd.Tab()); aRange.aEnd.SetTab(nTempTab);
+                    rRange.aStart.SetTab(rRange.aEnd.Tab()); rRange.aEnd.SetTab(nTempTab);
                     nMask = (SCA_VALID_TAB | SCA_TAB_ABSOLUTE | SCA_TAB_3D);
                     nBits1 = nRes1 & nMask;
                     nBits2 = nRes2 & nMask;
@@ -1483,42 +1480,47 @@ lcl_ScRange_Parse_OOo( ScRange &aRange, const OUString& r, ScDocument* pDoc, ScA
     return nRes1;
 }
 
-sal_uInt16 ScRange::Parse( const OUString& r, ScDocument* pDoc,
-                       const ScAddress::Details& rDetails,
-                       ScAddress::ExternalInfo* pExtInfo,
-                       const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks )
+sal_uInt16 ScRange::Parse( const OUString& rString, ScDocument* pDoc,
+                           const ScAddress::Details& rDetails,
+                           ScAddress::ExternalInfo* pExtInfo,
+                           const uno::Sequence<sheet::ExternalLinkInfo>* pExternalLinks )
 {
-    if (r.isEmpty())
+    if (rString.isEmpty())
         return 0;
 
     switch (rDetails.eConv)
     {
-    default :
-    case formula::FormulaGrammar::CONV_OOO:
-        return lcl_ScRange_Parse_OOo( *this, r, pDoc, pExtInfo );
+        case formula::FormulaGrammar::CONV_XL_A1:
+        case formula::FormulaGrammar::CONV_XL_OOX:
+        {
+            return lcl_ScRange_Parse_XL_A1( *this, rString.getStr(), pDoc, false, pExtInfo,
+                    (rDetails.eConv == formula::FormulaGrammar::CONV_XL_OOX ? pExternalLinks : NULL) );
+        }
 
-    case formula::FormulaGrammar::CONV_XL_A1:
-    case formula::FormulaGrammar::CONV_XL_OOX:
-        return lcl_ScRange_Parse_XL_A1( *this, r.getStr(), pDoc, false, pExtInfo,
-                (rDetails.eConv == formula::FormulaGrammar::CONV_XL_OOX ? pExternalLinks : NULL) );
+        case formula::FormulaGrammar::CONV_XL_R1C1:
+        {
+            return lcl_ScRange_Parse_XL_R1C1( *this, rString.getStr(), pDoc, rDetails, false, pExtInfo );
+        }
 
-    case formula::FormulaGrammar::CONV_XL_R1C1:
-        return lcl_ScRange_Parse_XL_R1C1( *this, r.getStr(), pDoc, rDetails, false, pExtInfo );
+        default:
+        case formula::FormulaGrammar::CONV_OOO:
+        {
+            return lcl_ScRange_Parse_OOo( *this, rString, pDoc, pExtInfo );
+        }
     }
 }
 
 // Accept a full range, or an address
-sal_uInt16 ScRange::ParseAny( const OUString& r, ScDocument* pDoc,
-                          const ScAddress::Details& rDetails )
+sal_uInt16 ScRange::ParseAny( const OUString& rString, ScDocument* pDoc,
+                              const ScAddress::Details& rDetails )
 {
-    sal_uInt16 nRet = Parse( r, pDoc, rDetails );
-    const sal_uInt16 nValid = SCA_VALID | SCA_VALID_COL2 | SCA_VALID_ROW2 |
-        SCA_VALID_TAB2;
+    sal_uInt16 nRet = Parse( rString, pDoc, rDetails );
+    const sal_uInt16 nValid = SCA_VALID | SCA_VALID_COL2 | SCA_VALID_ROW2 | SCA_VALID_TAB2;
 
     if ( (nRet & nValid) != nValid )
     {
         ScAddress aAdr(aStart);//initialize with currentPos as fallback for table number
-        nRet = aAdr.Parse( r, pDoc, rDetails );
+        nRet = aAdr.Parse( rString, pDoc, rDetails );
         if ( nRet & SCA_VALID )
             aStart = aEnd = aAdr;
     }
@@ -1527,7 +1529,7 @@ sal_uInt16 ScRange::ParseAny( const OUString& r, ScDocument* pDoc,
 
 // Parse only full row references
 sal_uInt16 ScRange::ParseCols( const OUString& rStr, ScDocument* pDoc,
-                           const ScAddress::Details& rDetails )
+                               const ScAddress::Details& rDetails )
 {
     if (rStr.isEmpty())
         return 0;
@@ -1586,7 +1588,7 @@ sal_uInt16 ScRange::ParseCols( const OUString& rStr, ScDocument* pDoc,
 
 // Parse only full row references
 sal_uInt16 ScRange::ParseRows( const OUString& rStr, ScDocument* pDoc,
-                           const ScAddress::Details& rDetails )
+                               const ScAddress::Details& rDetails )
 {
     if (rStr.isEmpty())
         return 0;
@@ -1643,59 +1645,55 @@ sal_uInt16 ScRange::ParseRows( const OUString& rStr, ScDocument* pDoc,
     return (p != NULL && *p == '\0') ? nRes : 0;
 }
 
-static inline void
-lcl_a1_append_c ( OUString &r, int nCol, bool bIsAbs )
+static inline void lcl_a1_append_c ( OUString &rString, int nCol, bool bIsAbs )
 {
     if( bIsAbs )
-        r += "$";
-    ScColToAlpha( r, sal::static_int_cast<SCCOL>(nCol) );
+        rString += "$";
+    ScColToAlpha( rString, sal::static_int_cast<SCCOL>(nCol) );
 }
 
-static inline void
-lcl_a1_append_r ( OUString &r, int nRow, bool bIsAbs )
+static inline void lcl_a1_append_r ( OUString &rString, int nRow, bool bIsAbs )
 {
     if ( bIsAbs )
-        r += "$";
-    r += OUString::number( nRow+1 );
+        rString += "$";
+    rString += OUString::number( nRow+1 );
 }
 
-static inline void
-lcl_r1c1_append_c ( OUString &r, int nCol, bool bIsAbs,
-                    const ScAddress::Details& rDetails )
+static inline void lcl_r1c1_append_c ( OUString &rString, int nCol, bool bIsAbs,
+                                       const ScAddress::Details& rDetails )
 {
-    r += "C";
+    rString += "C";
     if (bIsAbs)
     {
-        r += OUString::number( nCol + 1 );
+        rString += OUString::number( nCol + 1 );
     }
     else
     {
         nCol -= rDetails.nCol;
         if (nCol != 0) {
-            r += "[" + OUString::number( nCol ) + "]";
+            rString += "[" + OUString::number( nCol ) + "]";
         }
     }
 }
-static inline void
-lcl_r1c1_append_r ( OUString &r, int nRow, bool bIsAbs,
-                    const ScAddress::Details& rDetails )
+
+static inline void lcl_r1c1_append_r ( OUString &rString, int nRow, bool bIsAbs,
+                                       const ScAddress::Details& rDetails )
 {
-    r += "R";
+    rString += "R";
     if (bIsAbs)
     {
-        r += OUString::number( nRow + 1 );
+        rString += OUString::number( nRow + 1 );
     }
     else
     {
         nRow -= rDetails.nRow;
         if (nRow != 0) {
-            r += "[" + OUString::number( nRow ) + "]";
+            rString += "[" + OUString::number( nRow ) + "]";
         }
     }
 }
 
-static OUString
-getFileNameFromDoc( const ScDocument* pDoc )
+static OUString getFileNameFromDoc( const ScDocument* pDoc )
 {
     // TODO : er points at ScGlobal::GetAbsDocName()
     // as a better template.  Look into it
@@ -1721,7 +1719,7 @@ getFileNameFromDoc( const ScDocument* pDoc )
 }
 
 OUString ScAddress::Format(sal_uInt16 nFlags, const ScDocument* pDoc,
-                        const Details& rDetails) const
+                           const Details& rDetails) const
 {
     OUString r;
     if( nFlags & SCA_VALID )
@@ -1805,11 +1803,10 @@ OUString ScAddress::Format(sal_uInt16 nFlags, const ScDocument* pDoc,
     return r;
 }
 
-static void
-lcl_Split_DocTab( const ScDocument* pDoc,  SCTAB nTab,
-                  const ScAddress::Details& rDetails,
-                  sal_uInt16 nFlags,
-                  OUString& rTabName, OUString& rDocName )
+static void lcl_Split_DocTab( const ScDocument* pDoc,  SCTAB nTab,
+                              const ScAddress::Details& rDetails,
+                              sal_uInt16 nFlags,
+                              OUString& rTabName, OUString& rDocName )
 {
     pDoc->GetName(nTab, rTabName);
     rDocName = "";
@@ -1835,10 +1832,9 @@ lcl_Split_DocTab( const ScDocument* pDoc,  SCTAB nTab,
     ScCompiler::CheckTabQuotes( rTabName, rDetails.eConv);
 }
 
-static void
-lcl_ScRange_Format_XL_Header( OUString& r, const ScRange& rRange,
-                              sal_uInt16 nFlags, const ScDocument* pDoc,
-                              const ScAddress::Details& rDetails )
+static void lcl_ScRange_Format_XL_Header( OUString& rString, const ScRange& rRange,
+                                          sal_uInt16 nFlags, const ScDocument* pDoc,
+                                          const ScAddress::Details& rDetails )
 {
     if( nFlags & SCA_TAB_3D )
     {
@@ -1847,23 +1843,23 @@ lcl_ScRange_Format_XL_Header( OUString& r, const ScRange& rRange,
                           aTabName, aDocName );
         if( !aDocName.isEmpty() )
         {
-            r += "[" + aDocName + "]";
+            rString += "[" + aDocName + "]";
         }
-        r += aTabName;
+        rString += aTabName;
 
         if( nFlags & SCA_TAB2_3D )
         {
             lcl_Split_DocTab( pDoc, rRange.aEnd.Tab(), rDetails, nFlags,
                               aTabName, aDocName );
-            r += ":";
-            r += aTabName;
+            rString += ":";
+            rString += aTabName;
         }
-        r += "!";
+        rString += "!";
     }
 }
 
 OUString ScRange::Format( sal_uInt16 nFlags, const ScDocument* pDoc,
-                      const ScAddress::Details& rDetails ) const
+                          const ScAddress::Details& rDetails ) const
 {
     if( !( nFlags & SCA_VALID ) )
     {
commit e75f8d8e059bc293625dfa34e15b68eb6d820ac4
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date:   Mon Mar 31 09:43:17 2014 +0200

    sc: clean-up pivot.hxx/pivot2.cxx
    
    Change-Id: I88ed4da8dd2ca026eeea4a3fb267f4f9954c180a

diff --git a/sc/inc/pivot.hxx b/sc/inc/pivot.hxx
index cd74a99..37bca61 100644
--- a/sc/inc/pivot.hxx
+++ b/sc/inc/pivot.hxx
@@ -63,18 +63,18 @@ struct SC_DLLPUBLIC ScDPName
 
 struct ScDPLabelData
 {
-    OUString       maName;              ///< Original name of the dimension.
-    OUString       maLayoutName;        ///< Layout name (display name)
-    OUString       maSubtotalName;
-    SCCOL               mnCol;          ///< 0-based field index (not the source column index)
-    long                mnOriginalDim;  ///< original dimension index (>= 0 for duplicated dimension)
-    sal_uInt16          mnFuncMask;     ///< Page/Column/Row subtotal function.
-    sal_Int32           mnUsedHier;     ///< Used hierarchy.
-    sal_Int32           mnFlags;        ///< Flags from the DataPilotSource dimension
-    sal_uInt8           mnDupCount;
-    bool                mbShowAll:1;    ///< true = Show all (also empty) results.
-    bool                mbIsValue:1;    ///< true = Sum or count in data field.
-    bool                mbDataLayout:1;
+    OUString   maName;         ///< Original name of the dimension.
+    OUString   maLayoutName;   ///< Layout name (display name)
+    OUString   maSubtotalName;
+    SCCOL      mnCol;          ///< 0-based field index (not the source column index)
+    long       mnOriginalDim;  ///< original dimension index (>= 0 for duplicated dimension)
+    sal_uInt16 mnFuncMask;     ///< Page/Column/Row subtotal function.
+    sal_Int32  mnUsedHier;     ///< Used hierarchy.
+    sal_Int32  mnFlags;        ///< Flags from the DataPilotSource dimension
+    sal_uInt8  mnDupCount;
+    bool       mbShowAll:1;    ///< true = Show all (also empty) results.
+    bool       mbIsValue:1;    ///< true = Sum or count in data field.
+    bool       mbDataLayout:1;
 
     struct Member
     {
@@ -92,11 +92,11 @@ struct ScDPLabelData
          */
         OUString SC_DLLPUBLIC getDisplayName() const;
     };
-    ::std::vector<Member>                               maMembers;
-    ::com::sun::star::uno::Sequence< OUString >  maHiers;               ///< Hierarchies.
-    ::com::sun::star::sheet::DataPilotFieldSortInfo     maSortInfo;     ///< Sorting info.
-    ::com::sun::star::sheet::DataPilotFieldLayoutInfo   maLayoutInfo;   ///< Layout info.
-    ::com::sun::star::sheet::DataPilotFieldAutoShowInfo maShowInfo;     ///< AutoShow info.
+    std::vector<Member>                    maMembers;
+    css::uno::Sequence<OUString>           maHiers;        ///< Hierarchies.
+    css::sheet::DataPilotFieldSortInfo     maSortInfo;     ///< Sorting info.
+    css::sheet::DataPilotFieldLayoutInfo   maLayoutInfo;   ///< Layout info.
+    css::sheet::DataPilotFieldAutoShowInfo maShowInfo;     ///< AutoShow info.
 
     ScDPLabelData();
 
@@ -111,11 +111,12 @@ typedef boost::ptr_vector<ScDPLabelData> ScDPLabelDataVector;
 
 struct ScPivotField
 {
-    SCCOL               nCol;          ///< 0-based dimension index (not source column index)
-    long                mnOriginalDim; ///< >= 0 for duplicated field.
-    sal_uInt16          nFuncMask;
-    sal_uInt8           mnDupCount;
-    ::com::sun::star::sheet::DataPilotFieldReference maFieldRef;
+    SCCOL       nCol;          ///< 0-based dimension index (not source column index)
+    long        mnOriginalDim; ///< >= 0 for duplicated field.
+    sal_uInt16  nFuncMask;
+    sal_uInt8   mnDupCount;
+
+    css::sheet::DataPilotFieldReference maFieldRef;
 
     explicit ScPivotField( SCCOL nNewCol = 0, sal_uInt16 nNewFuncMask = PIVOT_FUNC_NONE );
     ScPivotField( const ScPivotField& r );
@@ -124,44 +125,46 @@ struct ScPivotField
     bool                operator==( const ScPivotField& r ) const;
 };
 
-typedef ::std::vector< ScPivotField > ScPivotFieldVector;
+typedef std::vector< ScPivotField > ScPivotFieldVector;
 
 struct ScPivotParam
 {
-    SCCOL           nCol;           ///< Cursor Position /
-    SCROW           nRow;           ///< or start of destination area
-    SCTAB           nTab;
+    SCCOL nCol;           ///< Cursor Position /
+    SCROW nRow;           ///< or start of destination area
+    SCTAB nTab;
+
     ScDPLabelDataVector maLabelArray;
-    ScPivotFieldVector maPageFields;
-    ScPivotFieldVector maColFields;
-    ScPivotFieldVector maRowFields;
-    ScPivotFieldVector maDataFields;
-    bool            bIgnoreEmptyRows;
-    bool            bDetectCategories;
-    bool            bMakeTotalCol;
-    bool            bMakeTotalRow;
+    ScPivotFieldVector  maPageFields;
+    ScPivotFieldVector  maColFields;
+    ScPivotFieldVector  maRowFields;
+    ScPivotFieldVector  maDataFields;
+
+    bool bIgnoreEmptyRows;
+    bool bDetectCategories;
+    bool bMakeTotalCol;
+    bool bMakeTotalRow;
 
     ScPivotParam();
     ScPivotParam( const ScPivotParam& r );
     ~ScPivotParam();
 
-    ScPivotParam&   operator=       ( const ScPivotParam& r );
-    bool            operator==      ( const ScPivotParam& r ) const;
+    ScPivotParam&   operator=  ( const ScPivotParam& r );
+    bool            operator== ( const ScPivotParam& r ) const;
     void SetLabelData(const ScDPLabelDataVector& r);
 };
 
 struct ScPivotFuncData
 {
-    SCCOL               mnCol;
-    long                mnOriginalDim;
-    sal_uInt16          mnFuncMask;
-    sal_uInt8           mnDupCount;
-    ::com::sun::star::sheet::DataPilotFieldReference maFieldRef;
+    SCCOL      mnCol;
+    long       mnOriginalDim;
+    sal_uInt16 mnFuncMask;
+    sal_uInt8  mnDupCount;
+
+    css::sheet::DataPilotFieldReference maFieldRef;
 
     explicit ScPivotFuncData( SCCOL nCol, sal_uInt16 nFuncMask );
-    explicit ScPivotFuncData(
-        SCCOL nCol, long nOriginalDim, sal_uInt16 nFuncMask, sal_uInt8 nDupCount,
-        const ::com::sun::star::sheet::DataPilotFieldReference& rFieldRef );
+    explicit ScPivotFuncData( SCCOL nCol, long nOriginalDim, sal_uInt16 nFuncMask, sal_uInt8 nDupCount,
+                              const css::sheet::DataPilotFieldReference& rFieldRef );
 
     bool operator== (const ScPivotFuncData& r) const;
 
@@ -170,7 +173,7 @@ struct ScPivotFuncData
 #endif
 };
 
-typedef ::std::vector< ScPivotFuncData > ScPivotFuncDataVector;
+typedef std::vector<ScPivotFuncData> ScPivotFuncDataVector;
 typedef std::vector<ScDPName> ScDPNameVec;
 
 #endif
diff --git a/sc/source/core/data/pivot2.cxx b/sc/source/core/data/pivot2.cxx
index c740fea..24e46cd 100644
--- a/sc/source/core/data/pivot2.cxx
+++ b/sc/source/core/data/pivot2.cxx
@@ -43,10 +43,11 @@ using std::cout;
 using std::endl;
 #endif
 
-using ::com::sun::star::sheet::DataPilotFieldReference;
-using ::std::vector;
+using css::sheet::DataPilotFieldReference;
+using std::vector;
 
-namespace {
+namespace
+{
 
 bool equals(const DataPilotFieldReference& left, const DataPilotFieldReference& right)
 {
@@ -56,20 +57,23 @@ bool equals(const DataPilotFieldReference& left, const DataPilotFieldReference&
         && (left.ReferenceItemName == right.ReferenceItemName);
 }
 
-}
+} // namespace
 
-ScDPName::ScDPName() : mnDupCount(0) {}
+// ScDPName
 
-ScDPName::ScDPName(const OUString& rName, const OUString& rLayoutName, sal_uInt8 nDupCount) :
-    maName(rName), maLayoutName(rLayoutName), mnDupCount(nDupCount) {}
+ScDPName::ScDPName() : mnDupCount(0)
+{}
 
+ScDPName::ScDPName(const OUString& rName, const OUString& rLayoutName, sal_uInt8 nDupCount) :
+    maName(rName), maLayoutName(rLayoutName), mnDupCount(nDupCount)
+{}
 
+// ScDPLabelData
 
 ScDPLabelData::Member::Member() :
     mbVisible(true),
     mbShowDetails(true)
-{
-}
+{}
 
 OUString ScDPLabelData::Member::getDisplayName() const
 {
@@ -89,8 +93,7 @@ ScDPLabelData::ScDPLabelData() :
     mbShowAll(false),
     mbIsValue(false),
     mbDataLayout(false)
-{
-}
+{}
 
 OUString ScDPLabelData::getDisplayName() const
 {
@@ -100,20 +103,22 @@ OUString ScDPLabelData::getDisplayName() const
     return maName;
 }
 
+// ScPivotField
+
 ScPivotField::ScPivotField(SCCOL nNewCol, sal_uInt16 nNewFuncMask) :
-    nCol( nNewCol ),
+    nCol(nNewCol),
     mnOriginalDim(-1),
-    nFuncMask( nNewFuncMask ),
+    nFuncMask(nNewFuncMask),
     mnDupCount(0)
-{
-}
+{}
 
-ScPivotField::ScPivotField( const ScPivotField& r ) :
-    nCol(r.nCol),
-    mnOriginalDim(r.mnOriginalDim),
-    nFuncMask(r.nFuncMask),
-    mnDupCount(r.mnDupCount),
-    maFieldRef(r.maFieldRef) {}
+ScPivotField::ScPivotField( const ScPivotField& rPivotField ) :
+    nCol(rPivotField.nCol),
+    mnOriginalDim(rPivotField.mnOriginalDim),
+    nFuncMask(rPivotField.nFuncMask),
+    mnDupCount(rPivotField.mnDupCount),
+    maFieldRef(rPivotField.maFieldRef)
+{}
 
 long ScPivotField::getOriginalDim() const
 {
@@ -128,12 +133,13 @@ bool ScPivotField::operator==( const ScPivotField& r ) const
         && equals(maFieldRef, r.maFieldRef);
 }
 
-ScPivotParam::ScPivotParam()
-    :   nCol(0), nRow(0), nTab(0),
-        bIgnoreEmptyRows(false), bDetectCategories(false),
-        bMakeTotalCol(true), bMakeTotalRow(true)
-{
-}
+// ScPivotParam
+
+ScPivotParam::ScPivotParam() :
+    nCol(0), nRow(0), nTab(0),
+    bIgnoreEmptyRows(false), bDetectCategories(false),
+    bMakeTotalCol(true), bMakeTotalRow(true)
+{}
 
 ScPivotParam::ScPivotParam( const ScPivotParam& r )
     :   nCol( r.nCol ), nRow( r.nRow ), nTab( r.nTab ),
@@ -150,83 +156,84 @@ ScPivotParam::ScPivotParam( const ScPivotParam& r )
 }
 
 ScPivotParam::~ScPivotParam()
-{
-}
+{}
 
-void ScPivotParam::SetLabelData(const ScDPLabelDataVector& r)
+void ScPivotParam::SetLabelData(const ScDPLabelDataVector& rVector)
 {
     ScDPLabelDataVector aNewArray;
-    aNewArray.reserve(r.size());
-    for (ScDPLabelDataVector::const_iterator itr = r.begin(), itrEnd = r.end();
-         itr != itrEnd; ++itr)
-        aNewArray.push_back(new ScDPLabelData(*itr));
-
+    aNewArray.reserve(rVector.size());
+    ScDPLabelDataVector::const_iterator it;
+    for (it = rVector.begin(); it != rVector.end(); ++it)
+    {
+        aNewArray.push_back(new ScDPLabelData(*it));
+    }
     maLabelArray.swap(aNewArray);
 }
 
-ScPivotParam& ScPivotParam::operator=( const ScPivotParam& r )
+ScPivotParam& ScPivotParam::operator=( const ScPivotParam& rPivotParam )
 {
-    nCol              = r.nCol;
-    nRow              = r.nRow;
-    nTab              = r.nTab;
-    bIgnoreEmptyRows  = r.bIgnoreEmptyRows;
-    bDetectCategories = r.bDetectCategories;
-    bMakeTotalCol     = r.bMakeTotalCol;
-    bMakeTotalRow     = r.bMakeTotalRow;
-
-    maPageFields = r.maPageFields;
-    maColFields  = r.maColFields;
-    maRowFields  = r.maRowFields;
-    maDataFields = r.maDataFields;
-    SetLabelData(r.maLabelArray);
+    nCol              = rPivotParam.nCol;
+    nRow              = rPivotParam.nRow;
+    nTab              = rPivotParam.nTab;
+    bIgnoreEmptyRows  = rPivotParam.bIgnoreEmptyRows;
+    bDetectCategories = rPivotParam.bDetectCategories;
+    bMakeTotalCol     = rPivotParam.bMakeTotalCol;
+    bMakeTotalRow     = rPivotParam.bMakeTotalRow;
+
+    maPageFields = rPivotParam.maPageFields;
+    maColFields  = rPivotParam.maColFields;
+    maRowFields  = rPivotParam.maRowFields;
+    maDataFields = rPivotParam.maDataFields;
+
+    SetLabelData(rPivotParam.maLabelArray);
     return *this;
 }
 
-bool ScPivotParam::operator==( const ScPivotParam& r ) const
-{
-    bool bEqual = (nCol == r.nCol)
-                 && (nRow == r.nRow)
-                 && (nTab == r.nTab)
-                 && (bIgnoreEmptyRows  == r.bIgnoreEmptyRows)
-                 && (bDetectCategories == r.bDetectCategories)
-                 && (bMakeTotalCol == r.bMakeTotalCol)
-                 && (bMakeTotalRow == r.bMakeTotalRow)
-                 && (maLabelArray.size() == r.maLabelArray.size())
-                 && maPageFields == r.maPageFields
-                 && maColFields == r.maColFields
-                 && maRowFields == r.maRowFields
-                 && maDataFields == r.maDataFields;
-
+bool ScPivotParam::operator==( const ScPivotParam& rPivotParam ) const
+{
+    bool bEqual = (nCol == rPivotParam.nCol &&
+                  nRow == rPivotParam.nRow &&
+                  nTab == rPivotParam.nTab &&
+                  bIgnoreEmptyRows  == rPivotParam.bIgnoreEmptyRows &&
+                  bDetectCategories == rPivotParam.bDetectCategories &&
+                  bMakeTotalCol == rPivotParam.bMakeTotalCol &&
+                  bMakeTotalRow == rPivotParam.bMakeTotalRow &&
+                  maLabelArray.size() == rPivotParam.maLabelArray.size() &&
+                  maPageFields == rPivotParam.maPageFields &&
+                  maColFields == rPivotParam.maColFields &&
+                  maRowFields == rPivotParam.maRowFields &&
+                  maDataFields == rPivotParam.maDataFields);
     return bEqual;
 }
 
-
+// ScPivotFuncData
 
 ScPivotFuncData::ScPivotFuncData( SCCOL nCol, sal_uInt16 nFuncMask ) :
     mnCol( nCol ),
     mnOriginalDim(-1),
-    mnFuncMask( nFuncMask ),
+    mnFuncMask(nFuncMask),
     mnDupCount(0)
-{
-}
+{}
 
-ScPivotFuncData::ScPivotFuncData(
-    SCCOL nCol, long nOriginalDim, sal_uInt16 nFuncMask, sal_uInt8 nDupCount,
-    const DataPilotFieldReference& rFieldRef) :
-    mnCol( nCol ),
+ScPivotFuncData::ScPivotFuncData(SCCOL nCol, long nOriginalDim, sal_uInt16 nFuncMask,
+                                 sal_uInt8 nDupCount, const DataPilotFieldReference& rFieldRef) :
+    mnCol(nCol),
     mnOriginalDim(nOriginalDim),
-    mnFuncMask( nFuncMask ),
+    mnFuncMask(nFuncMask),
     mnDupCount(nDupCount),
-    maFieldRef( rFieldRef )
-{
-}
+    maFieldRef(rFieldRef)
+{}
 
-bool ScPivotFuncData::operator== (const ScPivotFuncData& r) const
+bool ScPivotFuncData::operator== (const ScPivotFuncData& rFuncData) const
 {
-    if (mnCol != r.mnCol || mnOriginalDim != r.mnOriginalDim || mnFuncMask != r.mnFuncMask || mnDupCount != r.mnDupCount)
+    if (mnCol != rFuncData.mnCol ||
+        mnOriginalDim != rFuncData.mnOriginalDim ||
+        mnFuncMask != rFuncData.mnFuncMask ||
+        mnDupCount != rFuncData.mnDupCount)
+    {
         return false;
-
-    return equals(maFieldRef, r.maFieldRef);
+    }
+    return equals(maFieldRef, rFuncData.maFieldRef);
 }
 
 #if DEBUG_PIVOT_TABLE
@@ -238,6 +245,4 @@ void ScPivotFuncData::Dump() const
 }
 #endif
 
-
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 4f1f8b8e993b98095bf50c9e432fb0400d318b1f
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date:   Sun Mar 30 21:12:27 2014 +0200

    pivot: new pivot table layout dialog
    
    This commit adds a new pivot table layout dialog which was implemented
    from scratch. Instead of custom controls this one uses list boxes
    for field entries which greatly reduces the code. It also fixes
    some visual and behaviour bugs and adds the possibility to edit the
    "Data" field.
    
    Change-Id: I6c01252acee5a2e8910e40e65904504d00e03057

diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in
index 45a1678..aae2260 100644
--- a/extras/source/glade/libreoffice-catalog.xml.in
+++ b/extras/source/glade/libreoffice-catalog.xml.in
@@ -523,6 +523,15 @@
     <glade-widget-class title="Glossary Tree List" name="swuilo-SwGlTreeListBox"
                         generic-name="Glossary Tree List" parent="GtkTreeView"
                         icon-name="widget-gtk-treeview"/>
+    <glade-widget-class title="Pivot Table List" name="scuilo-ScPivotLayoutTreeList"
+                        generic-name="Pivot Table List" parent="GtkTreeView"
+                        icon-name="widget-gtk-treeview"/>
+    <glade-widget-class title="Pivot Table Label List" name="scuilo-ScPivotLayoutTreeListLabel"
+                        generic-name="Pivot Table Label List" parent="GtkTreeView"
+                        icon-name="widget-gtk-treeview"/>
+    <glade-widget-class title="Pivot Table Data List" name="scuilo-ScPivotLayoutTreeListData"
+                        generic-name="Pivot Table Data List" parent="GtkTreeView"
+                        icon-name="widget-gtk-treeview"/>
     <glade-widget-class title="Dial Control" name="svxlo-DialControl"
                         generic-name="Dial Control" parent="GtkSpinner"
                         icon-name="widget-gtk-spinner"/>
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index 9aebd45..5c38013 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -397,6 +397,11 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
     sc/source/ui/dbgui/imoptdlg \
     $(if $(filter TRUE,$(MPL_SUBSET)),, \
         sc/source/ui/dbgui/pvlaydlg) \
+    sc/source/ui/dbgui/PivotLayoutDialog \
+    sc/source/ui/dbgui/PivotLayoutTreeListBase \
+    sc/source/ui/dbgui/PivotLayoutTreeListData \
+    sc/source/ui/dbgui/PivotLayoutTreeListLabel \
+    sc/source/ui/dbgui/PivotLayoutTreeList \
     sc/source/ui/dbgui/sfiltdlg \
     sc/source/ui/dialogs/searchresults \
     sc/source/ui/docshell/arealink \
diff --git a/sc/UIConfig_scalc.mk b/sc/UIConfig_scalc.mk
index 37ce106..534b21b 100644
--- a/sc/UIConfig_scalc.mk
+++ b/sc/UIConfig_scalc.mk
@@ -129,6 +129,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\
 	sc/uiconfig/scalc/ui/pivotfielddialog \
 	sc/uiconfig/scalc/ui/pivotfilterdialog \
 	sc/uiconfig/scalc/ui/pivottablelayout \
+	sc/uiconfig/scalc/ui/pivottablelayoutdialog \
 	sc/uiconfig/scalc/ui/printareasdialog \
 	sc/uiconfig/scalc/ui/printeroptions \
 	sc/uiconfig/scalc/ui/protectsheetdlg \
diff --git a/sc/source/ui/dbgui/PivotLayoutDialog.cxx b/sc/source/ui/dbgui/PivotLayoutDialog.cxx
new file mode 100644
index 0000000..267b7f5
--- /dev/null
+++ b/sc/source/ui/dbgui/PivotLayoutDialog.cxx
@@ -0,0 +1,643 @@
+/* -*- 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:
+ */
+
+#include "PivotLayoutTreeList.hxx"
+#include "PivotLayoutDialog.hxx"
+#include <reffact.hxx>
+#include <svtools/treelistentry.hxx>
+
+#include "rangeutl.hxx"
+#include "uiitems.hxx"
+
+#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
+
+using namespace css::uno;
+using namespace css::sheet;
+
+ScItemValue::ScItemValue(OUString aName, SCCOL nColumn, sal_uInt16 nFunctionMask) :
+    maName(aName),
+    maFunctionData(nColumn, nFunctionMask),
+    mpOriginalItemValue(this)
+{}
+
+ScItemValue::ScItemValue(ScItemValue* pInputItemValue) :
+    maName(pInputItemValue->maName),
+    maFunctionData(pInputItemValue->maFunctionData),
+    mpOriginalItemValue(this)
+{}
+
+ScItemValue::~ScItemValue()
+{}
+
+namespace
+{
+
+OUString lclGetNameForNamedRange(ScRange aRange, ScDocument* pDocument)
+{
+    OUString aName;
+
+    ScRangeName* pRangeName = pDocument->GetRangeName();
+    if (pRangeName == NULL)
+        return aName;
+
+    const ScRangeData* pData = pRangeName->findByRange(aRange);
+    if (pData == NULL)
+        return aName;
+
+    return pData->GetName();
+}
+
+ScRange lclGetRangeForNamedRange(OUString aName, ScDocument* pDocument)
+{
+    ScRange aInvalidRange(ScAddress::INITIALIZE_INVALID);
+    ScRangeName* pRangeName = pDocument->GetRangeName();
+    if (pRangeName == NULL)
+        return aInvalidRange;
+
+    const ScRangeData* pData = pRangeName->findByUpperName(aName.toAsciiUpperCase());
+    if (pData == NULL)
+        return aInvalidRange;
+
+    ScRange aRange;
+    if (pData->IsReference(aRange))
+        return aRange;
+
+    return aInvalidRange;
+}
+
+}
+
+ScPivotLayoutDialog::ScPivotLayoutDialog(
+                            SfxBindings* pSfxBindings, SfxChildWindow* pChildWindow, Window* pParent,
+                            ScViewData* pViewData, const ScDPObject* pPivotTableObject, bool bNewPivotTable) :
+    ScAnyRefDlg           (pSfxBindings, pChildWindow, pParent, "PivotTableLayout", "modules/scalc/ui/pivottablelayoutdialog.ui"),
+    maPivotTableObject    (*pPivotTableObject),
+    mpViewData            (pViewData),
+    mpDocument            (pViewData->GetDocument()),
+    mbNewPivotTable       (bNewPivotTable),
+    maAddressDetails      (mpDocument->GetAddressConvention(), 0, 0),
+    mbDialogLostFocus     (false)
+{
+    Link aLink;
+
+    get(mpListBoxField,    "listbox-fields");
+    get(mpListBoxPage,     "listbox-page");
+    get(mpListBoxColumn,   "listbox-column");
+    get(mpListBoxRow,      "listbox-row");
+    get(mpListBoxData,     "listbox-data");
+
+    get(mpCheckIgnoreEmptyRows,     "check-ignore-empty-rows");
+    get(mpCheckTotalColumns,        "check-total-columns");
+    get(mpCheckAddFilter,           "check-add-filter");
+    get(mpCheckIdentifyCategories,  "check-identify-categories");
+    get(mpCheckTotalRows,           "check-total-rows");
+    get(mpCheckDrillToDetail,       "check-drill-to-details");
+
+    get(mpButtonOk,     "ok");
+    get(mpButtonApply,  "apply");
+    get(mpButtonClose,  "close");
+
+    get(mpSourceRadioNamedRange, "source-radio-named-range");
+    get(mpSourceRadioSelection,  "source-radio-selection");
+    get(mpSourceListBox,         "source-list");
+    get(mpSourceEdit,            "source-edit");
+    get(mpSourceButton,          "source-button");
+
+    get(mpDestinationRadioNewSheet,   "destination-radio-new-sheet");
+    get(mpDestinationRadioNamedRange, "destination-radio-named-range");
+    get(mpDestinationRadioSelection,  "destination-radio-selection");
+    get(mpDestinationListBox,         "destination-list");
+    get(mpDestinationEdit,            "destination-edit");
+    get(mpDestinationButton,          "destination-button");
+
+    // Source UI
+    aLink = LINK(this, ScPivotLayoutDialog, ToggleSource);
+    mpSourceRadioNamedRange->SetToggleHdl(aLink);
+    mpSourceRadioSelection->SetToggleHdl(aLink);
+
+    mpSourceEdit->SetReferences(this, mpSourceRadioSelection);
+    mpSourceButton->SetReferences(this, mpSourceEdit);
+
+    aLink = LINK(this, ScPivotLayoutDialog, GetFocusHandler);
+    mpSourceEdit->SetGetFocusHdl(aLink);
+    mpSourceButton->SetGetFocusHdl(aLink);
+
+    aLink = LINK(this, ScPivotLayoutDialog, LoseFocusHandler);
+    mpSourceEdit->SetLoseFocusHdl(aLink);
+    mpSourceButton->SetLoseFocusHdl(aLink);
+
+    mpSourceEdit->SetModifyHdl(LINK(this, ScPivotLayoutDialog, SourceEditModified));
+    mpSourceListBox->SetSelectHdl(LINK(this, ScPivotLayoutDialog, SourceEditModified));
+
+    // Destination UI
+    aLink = LINK(this, ScPivotLayoutDialog, ToggleDestination);
+    mpDestinationRadioNewSheet->SetToggleHdl(aLink);
+    mpDestinationRadioNamedRange->SetToggleHdl(aLink);
+    mpDestinationRadioSelection->SetToggleHdl(aLink);
+
+    mpDestinationEdit->SetReferences(this, mpDestinationRadioNewSheet);
+    mpDestinationButton->SetReferences(this, mpDestinationEdit);
+
+    aLink = LINK(this, ScPivotLayoutDialog, GetFocusHandler);
+    mpDestinationEdit->SetGetFocusHdl(aLink);
+    mpDestinationButton->SetGetFocusHdl(aLink);
+
+    aLink = LINK(this, ScPivotLayoutDialog, LoseFocusHandler);
+    mpDestinationEdit->SetLoseFocusHdl(aLink);
+    mpDestinationButton->SetLoseFocusHdl(aLink);
+
+    // Buttons
+    mpButtonOk->SetClickHdl(   LINK(this, ScPivotLayoutDialog, OkClicked));
+    mpButtonClose->SetClickHdl(LINK(this, ScPivotLayoutDialog, CloseClicked));
+    mpButtonApply->SetClickHdl(LINK(this, ScPivotLayoutDialog, ApplyClicked));
+
+    // Initialize Data
+    maPivotTableObject.FillOldParam(maPivotParameters);
+    maPivotTableObject.FillLabelData(maPivotParameters);
+
+    mpListBoxField->Setup (this);
+    mpListBoxPage->Setup  (this, ScPivotLayoutTreeList::PAGE_LIST);
+    mpListBoxColumn->Setup(this, ScPivotLayoutTreeList::COLUMN_LIST);
+    mpListBoxRow->Setup   (this, ScPivotLayoutTreeList::ROW_LIST);
+    mpListBoxData->Setup  (this);
+
+    FillValuesToListBoxes();
+
+    const ScDPSaveData* pSaveData = maPivotTableObject.GetSaveData();
+    if (pSaveData == NULL)
+    {
+        mpCheckAddFilter->Check(false);
+        mpCheckDrillToDetail->Check(false);
+    }
+    else
+    {
+        mpCheckAddFilter->Check(pSaveData->GetFilterButton());
+        mpCheckDrillToDetail->Check(pSaveData->GetDrillDown());
+    }
+
+    mpCheckIgnoreEmptyRows->Check(maPivotParameters.bIgnoreEmptyRows);
+    mpCheckIdentifyCategories->Check(maPivotParameters.bDetectCategories);
+    mpCheckTotalColumns->Check(maPivotParameters.bMakeTotalCol);
+    mpCheckTotalRows->Check(maPivotParameters.bMakeTotalRow);
+
+    SetupSource();
+    SetupDestination();
+}
+
+ScPivotLayoutDialog::~ScPivotLayoutDialog()
+{}
+
+void ScPivotLayoutDialog::SetupSource()
+{
+    mpSourceListBox->Clear();
+
+    ScRange aSourceRange;
+    OUString sSourceNamedRangeName;
+
+    if (maPivotTableObject.GetSheetDesc())
+    {
+        const ScSheetSourceDesc* pSheetSourceDesc = maPivotTableObject.GetSheetDesc();
+        aSourceRange = pSheetSourceDesc->GetSourceRange();
+
+        if(!aSourceRange.IsValid())
+        {
+            // Source is probably a DB Range
+            mpSourceRadioNamedRange->Disable();
+            mpSourceRadioSelection->Disable();
+            ToggleSource(NULL);
+            return;
+        }
+        else
+        {
+            OUString aSourceRangeName = aSourceRange.Format(SCR_ABS_3D, mpDocument, maAddressDetails);
+            mpSourceEdit->SetText(aSourceRangeName);
+        }
+    }
+    else
+    {
+        mpSourceRadioNamedRange->Disable();
+        mpSourceRadioSelection->Disable();
+        ToggleSource(NULL);
+        return;
+    }
+
+    // Setup Named Ranges
+    bool bIsNamedRange = false;
+
+    ScAreaNameIterator aIterator(mpDocument);
+    OUString aEachName;
+    ScRange aEachRange;
+
+    while (aIterator.Next(aEachName, aEachRange))
+    {
+        if (!aIterator.WasDBName())
+        {
+            mpSourceListBox->InsertEntry(aEachName);
+            if (aEachRange == aSourceRange)
+            {
+                sSourceNamedRangeName = aEachName;
+                bIsNamedRange = true;
+            }
+        }
+    }
+
+    if (bIsNamedRange)
+    {
+        mpSourceListBox->SelectEntry(sSourceNamedRangeName, true);
+        mpSourceRadioNamedRange->Check(true);
+    }
+    else
+    {
+        mpSourceListBox->SelectEntryPos(0, true);
+        mpSourceRadioSelection->Check(true);
+    }
+
+    // If entries - select first entry, otherwise disable the radio button.
+    if (mpSourceListBox->GetEntryCount() <= 0)
+        mpSourceRadioNamedRange->Disable();
+
+    ToggleSource(NULL);
+}
+
+void ScPivotLayoutDialog::SetupDestination()
+{
+    mpDestinationListBox->Clear();
+
+    // Fill up named ranges
+    ScAreaNameIterator aIterator(mpDocument);
+    OUString aName;
+    ScRange aRange;
+
+    while (aIterator.Next(aName, aRange))
+    {
+        if (!aIterator.WasDBName())
+        {
+            mpDestinationListBox->InsertEntry(aName);
+        }
+    }
+
+    // If entries - select first entry, otherwise disable the radio button.
+    if (mpDestinationListBox->GetEntryCount() > 0)
+        mpDestinationListBox->SelectEntryPos(0, true);
+    else
+        mpDestinationRadioNamedRange->Disable();
+
+    //
+    if (mbNewPivotTable)
+    {
+        mpDestinationRadioNewSheet->Check(true);
+    }
+    else
+    {
+        if (maPivotParameters.nTab != MAXTAB + 1)
+        {
+            ScAddress aAddress(maPivotParameters.nCol, maPivotParameters.nRow, maPivotParameters.nTab);
+            OUString aAddressString = aAddress.Format(SCA_VALID | SCA_TAB_3D | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE, mpDocument, maAddressDetails);
+            mpDestinationEdit->SetText(aAddressString);
+            mpDestinationRadioSelection->Check(true);
+        }
+    }
+
+    ToggleDestination(NULL);
+}
+
+void ScPivotLayoutDialog::FillValuesToListBoxes()
+{
+    mpListBoxField->FillLabelFields(maPivotParameters.maLabelArray);
+    mpListBoxData->FillDataField(maPivotParameters.maDataFields);
+    mpListBoxColumn->FillFields(maPivotParameters.maColFields);
+    mpListBoxRow->FillFields(maPivotParameters.maRowFields);
+    mpListBoxPage->FillFields(maPivotParameters.maPageFields);
+}
+
+void ScPivotLayoutDialog::SetActive()
+{
+    if (mbDialogLostFocus)
+    {
+        mbDialogLostFocus = false;
+        if(mpActiveEdit != NULL)
+        {
+            mpActiveEdit->GrabFocus();
+            if (mpActiveEdit == mpSourceEdit)
+                UpdateSourceRange();
+        }
+    }
+    else
+    {
+        GrabFocus();
+    }
+
+    RefInputDone();
+}
+
+void ScPivotLayoutDialog::SetReference(const ScRange& rReferenceRange, ScDocument* pDocument)
+{
+    if (!mbDialogLostFocus)
+        return;
+
+    if (mpActiveEdit == NULL)
+        return;
+
+    if (rReferenceRange.aStart != rReferenceRange.aEnd)
+        RefInputStart(mpActiveEdit);
+
+    OUString aReferenceString = rReferenceRange.Format(SCR_ABS_3D, pDocument, maAddressDetails);
+
+    if (mpActiveEdit == mpSourceEdit)
+    {
+        mpSourceEdit->SetRefString(aReferenceString);
+    }
+    else if (mpActiveEdit == mpDestinationEdit)
+    {
+        mpDestinationEdit->SetRefString(aReferenceString);
+    }
+}
+
+bool ScPivotLayoutDialog::IsRefInputMode() const
+{
+    return mbDialogLostFocus;
+}
+
+void ScPivotLayoutDialog::ItemInserted(ScItemValue* pItemValue, ScPivotLayoutTreeList::SvPivotTreeListType eType)
+{
+    if (pItemValue == NULL)
+        return;
+
+    switch (eType)
+    {
+        case ScPivotLayoutTreeList::ROW_LIST:
+        case ScPivotLayoutTreeList::COLUMN_LIST:
+        case ScPivotLayoutTreeList::PAGE_LIST:
+        {
+            mpListBoxRow->RemoveEntryForItem(pItemValue);
+            mpListBoxColumn->RemoveEntryForItem(pItemValue);
+            mpListBoxPage->RemoveEntryForItem(pItemValue);
+        }
+        case ScPivotLayoutTreeList::LABEL_LIST:
+        {
+            mpListBoxRow->RemoveEntryForItem(pItemValue);
+            mpListBoxColumn->RemoveEntryForItem(pItemValue);
+            mpListBoxPage->RemoveEntryForItem(pItemValue);
+            mpListBoxData->RemoveEntryForItem(pItemValue);
+        }
+        break;
+        default:
+            break;
+    }
+}
+
+void ScPivotLayoutDialog::UpdateSourceRange()
+{
+    ScSheetSourceDesc aSourceSheet = *maPivotTableObject.GetSheetDesc();
+
+    if (mpSourceRadioNamedRange->IsChecked())
+    {
+        OUString aEntryString = mpSourceListBox->GetSelectEntry();
+        ScRange aSourceRange = lclGetRangeForNamedRange(aEntryString, mpDocument);
+        if (!aSourceRange.IsValid() || aSourceSheet.GetSourceRange() == aSourceRange)
+            return;
+        aSourceSheet.SetRangeName(aEntryString);
+    }
+    else if (mpSourceRadioSelection->IsChecked())
+    {
+        OUString aSourceString = mpSourceEdit->GetText();
+        ScRange aSourceRange;
+        sal_uInt16 nResult = aSourceRange.Parse(aSourceString, mpDocument, maAddressDetails);
+
+        bool bIsValid = (nResult & SCA_VALID) == SCA_VALID; // aSourceString is valid
+
+        mpSourceEdit->SetRefValid(true);
+
+        if (bIsValid)
+        {
+            ScRefAddress aStart;
+            ScRefAddress aEnd;
+
+            ConvertDoubleRef(mpDocument, aSourceString, 1, aStart, aEnd, maAddressDetails);
+            aSourceRange.aStart = aStart.GetAddress();
+            aSourceRange.aEnd = aEnd.GetAddress();
+        }
+        else
+        {
+            aSourceRange = lclGetRangeForNamedRange(aSourceString, mpDocument);
+        }
+
+        if (!aSourceRange.IsValid())
+        {
+            mpSourceEdit->SetRefValid(false);
+            return;
+        }
+
+        if (aSourceSheet.GetSourceRange() == aSourceRange)
+                return;
+
+        aSourceSheet.SetSourceRange(aSourceRange);
+        if (aSourceSheet.CheckSourceRange() != 0)
+        {
+            mpSourceEdit->SetRefValid(false);
+            return;
+        }
+    }
+    else
+    {
+        return;
+    }
+
+    maPivotTableObject.SetSheetDesc(aSourceSheet);
+    maPivotTableObject.FillOldParam(maPivotParameters);
+    maPivotTableObject.FillLabelData(maPivotParameters);
+
+    FillValuesToListBoxes();
+}
+
+bool ScPivotLayoutDialog::ApplyChanges()
+{
+    ScDPSaveData aSaveData;
+    aSaveData.SetIgnoreEmptyRows(mpCheckIgnoreEmptyRows->IsChecked());
+    aSaveData.SetRepeatIfEmpty(mpCheckIdentifyCategories->IsChecked());
+    aSaveData.SetColumnGrand(mpCheckTotalColumns->IsChecked());
+    aSaveData.SetRowGrand(mpCheckTotalRows->IsChecked());
+    aSaveData.SetFilterButton(mpCheckAddFilter->IsChecked());
+    aSaveData.SetDrillDown(mpCheckDrillToDetail->IsChecked());
+
+    Reference<XDimensionsSupplier> xSource = maPivotTableObject.GetSource();
+
+    ScPivotFieldVector aPageFieldVector;
+    mpListBoxPage->PushEntriesToPivotFieldVector(aPageFieldVector);
+    ScDPObject::ConvertOrientation(aSaveData, aPageFieldVector, DataPilotFieldOrientation_PAGE,
+                                   xSource, maPivotParameters.maLabelArray);
+
+    ScPivotFieldVector aColFieldVector;
+    mpListBoxColumn->PushEntriesToPivotFieldVector(aColFieldVector);
+    ScDPObject::ConvertOrientation(aSaveData, aColFieldVector, DataPilotFieldOrientation_COLUMN,
+                                   xSource, maPivotParameters.maLabelArray);
+
+    ScPivotFieldVector aRowFieldVector;
+    mpListBoxRow->PushEntriesToPivotFieldVector(aRowFieldVector);
+    ScDPObject::ConvertOrientation(aSaveData, aRowFieldVector, DataPilotFieldOrientation_ROW,
+                                   xSource, maPivotParameters.maLabelArray);
+
+    ScPivotFieldVector aDataFieldVector;
+    mpListBoxData->PushEntriesToPivotFieldVector(aDataFieldVector);
+    ScDPObject::ConvertOrientation(aSaveData, aDataFieldVector, DataPilotFieldOrientation_DATA,
+                                   xSource, maPivotParameters.maLabelArray,
+                                   &aColFieldVector, &aRowFieldVector, &aPageFieldVector);
+
+
+    ScRange aDestinationRange;
+    bool bToNewSheet = false;
+
+    if (!GetDestination(aDestinationRange, bToNewSheet))
+        return false;
+
+    SetDispatcherLock(false);
+    SwitchToDocument();
+
+    sal_uInt16 nWhichPivot = SC_MOD()->GetPool().GetWhich(SID_PIVOT_TABLE);
+    ScPivotItem aPivotItem(nWhichPivot, &aSaveData, &aDestinationRange, bToNewSheet);
+    mpViewData->GetViewShell()->SetDialogDPObject(new ScDPObject(maPivotTableObject));
+
+    SfxDispatcher* pDispatcher = GetBindings().GetDispatcher();
+    SfxCallMode nCallMode = SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD;
+    const SfxPoolItem* pResult = pDispatcher->Execute(SID_PIVOT_TABLE, nCallMode, &aPivotItem, NULL, 0);
+
+    if (pResult != NULL)
+    {
+        const SfxBoolItem* pItem = reinterpret_cast<const SfxBoolItem*>(pResult);
+        if (pItem)
+        {
+            return pItem->GetValue();
+        }
+    }
+
+    SetDispatcherLock(true);
+    return true;
+}
+
+bool ScPivotLayoutDialog::GetDestination(ScRange& aDestinationRange, bool& bToNewSheet)
+{
+    bToNewSheet = false;
+
+    if (mpDestinationRadioNamedRange->IsChecked())
+    {
+        OUString aName = mpDestinationListBox->GetSelectEntry();
+        aDestinationRange = lclGetRangeForNamedRange(aName, mpDocument);
+        if (!aDestinationRange.IsValid())
+            return false;
+    }
+    else if (mpDestinationRadioSelection->IsChecked())
+    {
+        ScAddress aAddress;
+        aAddress.Parse(mpDestinationEdit->GetText(), mpDocument, maAddressDetails);
+        aDestinationRange = ScRange(aAddress);
+    }
+    else
+    {
+        bToNewSheet = true;
+        aDestinationRange = ScRange(maPivotParameters.nCol, maPivotParameters.nRow, maPivotParameters.nTab);
+    }
+    return true;
+}
+
+ScItemValue* ScPivotLayoutDialog::GetItem(SCCOL nColumn)
+{
+    return mpListBoxField->GetItem(nColumn);
+}
+
+bool ScPivotLayoutDialog::IsDataItem(SCCOL nColumn)
+{
+    return mpListBoxField->IsDataItem(nColumn);
+}
+
+ScDPLabelData* ScPivotLayoutDialog::GetLabelData(SCCOL nColumn)
+{
+    return &maPivotParameters.maLabelArray[nColumn];
+}
+
+ScDPLabelDataVector& ScPivotLayoutDialog::GetLabelDataVector()
+{
+    return maPivotParameters.maLabelArray;
+}
+
+IMPL_LINK( ScPivotLayoutDialog, OkClicked, PushButton*, /*pButton*/ )
+{
+    if (ApplyChanges())
+        CloseClicked(NULL);
+    return 0;
+}
+
+IMPL_LINK( ScPivotLayoutDialog, ApplyClicked, PushButton*, /*pButton*/ )
+{
+    ApplyChanges();
+    return 0;
+}
+
+IMPL_LINK( ScPivotLayoutDialog, CloseClicked, PushButton*, /*pButton*/ )
+{
+    DoClose( ScPivotLayoutWrapper::GetChildWindowId() );
+    return 0;
+}
+
+IMPL_LINK(ScPivotLayoutDialog, GetFocusHandler, Control*, pCtrl)
+{
+    mpActiveEdit = NULL;
+
+    if (pCtrl == (Control*) mpSourceEdit  ||
+        pCtrl == (Control*) mpSourceButton)
+    {
+        mpActiveEdit = mpSourceEdit;
+    }
+    else if (pCtrl == (Control*) mpDestinationEdit  ||
+             pCtrl == (Control*) mpDestinationButton)
+    {
+        mpActiveEdit = mpDestinationEdit;
+    }
+
+    if (mpActiveEdit)
+        mpActiveEdit->SetSelection(Selection(0, SELECTION_MAX));
+
+    return 0;
+}
+
+IMPL_LINK_NOARG(ScPivotLayoutDialog, LoseFocusHandler)
+{
+    mbDialogLostFocus = !IsActive();
+    return 0;
+}
+
+IMPL_LINK_NOARG(ScPivotLayoutDialog, SourceEditModified)
+{
+    UpdateSourceRange();
+    return 0;
+}
+
+IMPL_LINK_NOARG(ScPivotLayoutDialog, ToggleSource)
+{
+    bool bNamedRange = mpSourceRadioNamedRange->IsChecked();
+    bool bSelection = mpSourceRadioSelection->IsChecked();
+    mpSourceListBox->Enable(bNamedRange);
+    mpSourceButton->Enable(bSelection);
+    mpSourceEdit->Enable(bSelection);
+    UpdateSourceRange();
+    return 0;
+}
+
+IMPL_LINK_NOARG(ScPivotLayoutDialog, ToggleDestination)
+{
+    bool bNamedRange = mpDestinationRadioNamedRange->IsChecked();
+    bool bSelection = mpDestinationRadioSelection->IsChecked();
+    mpDestinationListBox->Enable(bNamedRange);
+    mpDestinationButton->Enable(bSelection);
+    mpDestinationEdit->Enable(bSelection);
+    return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/PivotLayoutTreeList.cxx b/sc/source/ui/dbgui/PivotLayoutTreeList.cxx
new file mode 100644
index 0000000..8c76aff
--- /dev/null
+++ b/sc/source/ui/dbgui/PivotLayoutTreeList.cxx
@@ -0,0 +1,125 @@
+/* -*- 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:
+ */
+
+#include "PivotLayoutTreeList.hxx"
+#include "PivotLayoutDialog.hxx"
+
+#include <svtools/treelistentry.hxx>
+#include "pivot.hxx"
+#include "scabstdlg.hxx"
+
+using namespace std;
+
+extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeScPivotLayoutTreeList(Window *pParent, VclBuilder::stringmap& )
+{
+    return new ScPivotLayoutTreeList(pParent, WB_BORDER | WB_TABSTOP | WB_CLIPCHILDREN | WB_FORCE_MAKEVISIBLE);
+}
+
+ScPivotLayoutTreeList::ScPivotLayoutTreeList(Window* pParent, WinBits nBits) :

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list