ooo-build r13305 - in trunk: . patches/test



Author: kyoshida
Date: Sat Jul 19 01:49:00 2008
New Revision: 13305
URL: http://svn.gnome.org/viewvc/ooo-build?rev=13305&view=rev

Log:
2008-07-18  Kohei Yoshida  <kyoshida novell com>

	* patches/test/calc-external-defined-names.diff: more progress on Excel
	export.


Modified:
   trunk/ChangeLog
   trunk/patches/test/calc-external-defined-names.diff

Modified: trunk/patches/test/calc-external-defined-names.diff
==============================================================================
--- trunk/patches/test/calc-external-defined-names.diff	(original)
+++ trunk/patches/test/calc-external-defined-names.diff	Sat Jul 19 01:49:00 2008
@@ -1158,7 +1158,7 @@
  
  
 diff --git sc/source/filter/excel/xeformula.cxx sc/source/filter/excel/xeformula.cxx
-index c85aad1..ca36c38 100644
+index c85aad1..0315b6b 100644
 --- sc/source/filter/excel/xeformula.cxx
 +++ sc/source/filter/excel/xeformula.cxx
 @@ -42,6 +42,12 @@
@@ -1182,13 +1182,7 @@
  
      void                ProcessFunction( const XclExpTokenData& rTokData, sal_uInt8 nExpClass );
      void                PrepareFunction( XclExpFuncData& rFuncData );
-@@ -1110,11 +1117,18 @@ XclExpTokenData XclExpFmlaCompImpl::RangeTerm( XclExpTokenData aTokData, sal_uIn
- 
- XclExpTokenData XclExpFmlaCompImpl::Factor( XclExpTokenData aTokData, sal_uInt8 nExpClass )
- {
-+    fprintf(stdout, "XclExpFmlaCompImpl::Factor: --begin\n");
-     if( !mbOk || !aTokData.Is() ) return XclExpTokenData();
- 
+@@ -1115,6 +1122,12 @@ XclExpTokenData XclExpFmlaCompImpl::Factor( XclExpTokenData aTokData, sal_uInt8
      StackVar eTokType = aTokData.GetType();
      OpCode eOpCode = aTokData.GetOpCode();
  
@@ -1201,21 +1195,12 @@
      switch( eTokType )
      {
          case svUnknown:     mbOk = false;                           break;
-@@ -1146,6 +1160,7 @@ XclExpTokenData XclExpFmlaCompImpl::Factor( XclExpTokenData aTokData, sal_uInt8
-         }
-     }
- 
-+    fprintf(stdout, "XclExpFmlaCompImpl::Factor: --end\n");
-     return GetNextToken();
- }
- 
-@@ -1249,6 +1264,72 @@ void XclExpFmlaCompImpl::ProcessExternal( const XclExpTokenData& rTokData, sal_u
+@@ -1249,6 +1262,66 @@ void XclExpFmlaCompImpl::ProcessExternal( const XclExpTokenData& rTokData, sal_u
          ProcessFunction( rTokData, nExpClass );
  }
  
 +void XclExpFmlaCompImpl::ProcessExternalName( const XclExpTokenData& rTokData, sal_uInt8 nExpClass )
 +{
-+    fprintf(stdout, "XclExpFmlaCompImpl::ProcessExternalName: --begin\n");
 +    StackVar eType = rTokData.GetType();
 +
 +    ScExternalRefManager* pRefMgr = GetDoc().GetExternalRefManager();
@@ -1235,14 +1220,8 @@
 +        case svExternalName:
 +        {
 +            fprintf(stdout, "XclExpFmlaCompImpl::ProcessExternalName:   svExternalName\n");
-+            const String& aName = rTokData.mpScToken->GetString();
-+            fprintf(stdout, "XclExpFmlaCompImpl::ProcessExternalName:   file id = %d; name = '%s'\n",
-+                    nFileId, rtl::OUStringToOString(aName, RTL_TEXTENCODING_UTF8).getStr());
-+
-+            const String* pFile = pRefMgr->getExternalFileName(nFileId);
-+            fprintf(stdout, "XclExpFmlaCompImpl::ProcessExternalName:   file name = '%s'\n",
-+                    rtl::OUStringToOString(*pFile, RTL_TEXTENCODING_UTF8).getStr());
 +
++            const String& aName = rTokData.mpScToken->GetString();
 +            ScTokenArray* pArray = pRefMgr->getRangeNameTokens(nFileId, aName);
 +            if (!pArray || !mpScBasePos)
 +            {    
@@ -1250,8 +1229,7 @@
 +                break;
 +            }
 +
-+            ::std::auto_ptr<ScTokenArray> pNew(pArray->Clone());
-+            for (ScToken* p = pNew->First(); p; p = pNew->Next())
++            for (ScToken* p = pArray->First(); p; p = pArray->Next())
 +            {
 +                if (p->GetOpCode() == ocExternalName)
 +                {
@@ -1260,59 +1238,32 @@
 +                        SingleRefData aData(p->GetSingleRef());
 +                        aData.CalcAbsIfRel(*mpScBasePos);
 +                        mpLinkMgr->StoreCell(nFileId, aData);
-+//                      mpLinkMgr->FindExtSheet(nFileId);
 +                    }
 +                    else if (p->GetType() == svDoubleRef)
 +                    {
 +                        ComplRefData aData(p->GetDoubleRef());
 +                        aData.CalcAbsIfRel(*mpScBasePos);
 +                        mpLinkMgr->StoreCellRange(nFileId, aData);
-+//                      mpLinkMgr->FindExtSheet(nFileId);
 +                    }
 +                }
 +            }
 +
++            const String* pFile = pRefMgr->getExternalFileName(nFileId);
++            sal_uInt16 nExtSheet, nExtName;
++            if (mpLinkMgr->InsertExtName(nExtSheet, nExtName, *pFile, aName, pArray))
++                AppendNameXToken(nExtSheet, nExtName, nExpClass, rTokData.mnSpaces);
++            else
++                AppendErrorToken(EXC_ERR_REF, rTokData.mnSpaces);
 +        }
 +        break;
 +    }
-+
-+    fprintf(stdout, "XclExpFmlaCompImpl::ProcessExternalName: --end\n");
 +}
 +
  void XclExpFmlaCompImpl::ProcessFunction( const XclExpTokenData& rTokData, sal_uInt8 nExpClass )
  {
      OpCode eOpCode = rTokData.GetOpCode();
-@@ -1751,6 +1832,9 @@ XclExpRefLogEntry* XclExpFmlaCompImpl::GetNewRefLogEntry()
- 
- void XclExpFmlaCompImpl::ProcessCellRef( const XclExpTokenData& rTokData, sal_uInt8 nExpClass )
- {
-+    fprintf(stdout, "XclExpFmlaCompImpl::ProcessCellRef: --begin (type = %d; opcode = %d)\n", 
-+            rTokData.GetType(), rTokData.GetOpCode());
-+
-     // get the Excel address components, adjust internal data in aRefData
-     bool bNatLangRef = (meBiff == EXC_BIFF8) && mpScBasePos && (rTokData.GetOpCode() == ocColRowName);
-     SingleRefData aRefData( rTokData.mpScToken->GetSingleRef() );
-@@ -1771,7 +1855,10 @@ void XclExpFmlaCompImpl::ProcessCellRef( const XclExpTokenData& rTokData, sal_uI
-     {
-         // store external cell contents in CRN records
-         if( maCfg.mbFromCell && mpLinkMgr && mpScBasePos )
-+        {
-+            fprintf(stdout, "XclExpFmlaCompImpl::ProcessCellRef:   store external cell contents in CRN records\n");
-             mpLinkMgr->StoreCell( aRefData );
-+        }
- 
-         // create the tRef, tRefErr, tRefN, tRef3d, or tRefErr3d token
-         if( !maCfg.mb3DRefOnly && IsRef2D( aRefData ) )
-@@ -1805,6 +1892,7 @@ void XclExpFmlaCompImpl::ProcessCellRef( const XclExpTokenData& rTokData, sal_uI
-             AppendErrorToken( EXC_ERR_REF, rTokData.mnSpaces );
-         }
-     }
-+    fprintf(stdout, "XclExpFmlaCompImpl::ProcessCellRef: --end\n");
- }
- 
- void XclExpFmlaCompImpl::ProcessRangeRef( const XclExpTokenData& rTokData, sal_uInt8 nExpClass )
 diff --git sc/source/filter/excel/xelink.cxx sc/source/filter/excel/xelink.cxx
-index b1bacad..660f944 100644
+index b1bacad..ba64325 100644
 --- sc/source/filter/excel/xelink.cxx
 +++ sc/source/filter/excel/xelink.cxx
 @@ -38,6 +38,15 @@
@@ -1331,7 +1282,39 @@
  
  // ============================================================================
  // *** Helper classes ***
-@@ -220,6 +229,9 @@ public:
+@@ -102,6 +111,22 @@ private:
+     XclExpCachedMatRef  mxMatrix;       /// Cached results of the DDE link.
+ };
+ 
++// ----------------------------------------------------------------------------
++
++class XclExpExtName : public XclExpExtNameBase
++{
++public:
++    explicit            XclExpExtName( const XclExpRoot& rRoot, const String& rName,
++                                       const ScTokenArray* pArray );
++
++private:
++    /** Writes additional record contents. */
++    virtual void        WriteAddData( XclExpStream& rStrm );
++
++private:
++    auto_ptr<ScTokenArray>  mpArray;
++};
++
+ // List of external names =====================================================
+ 
+ /** List of all external names of a sheet. */
+@@ -117,6 +142,8 @@ public:
+         @return  The 1-based (Excel-like) list index of the DDE link. */
+     sal_uInt16          InsertDde( const String& rApplic, const String& rTopic, const String& rItem );
+ 
++    sal_uInt16          InsertExtName( const String& rName, const ScTokenArray* pArray );
++
+     /** Writes the EXTERNNAME record list. */
+     virtual void        Save( XclExpStream& rStrm );
+ 
+@@ -220,6 +247,9 @@ public:
      /** Stores all cells in the given range in the CRN list. */
      void                StoreCellRange( const XclExpRoot& rRoot, const ScRange& rRange );
  
@@ -1341,7 +1324,7 @@
      /** Writes the XCT and all CRN records. */
      virtual void        Save( XclExpStream& rStrm );
  
-@@ -319,6 +331,11 @@ public:
+@@ -319,6 +349,11 @@ public:
      /** Stores all cells in the given range in the CRN list of the specified SUPBOOK sheet. */
      void                StoreCellRange( const ScRange& rRange, sal_uInt16 nSBTab );
  
@@ -1353,7 +1336,16 @@
      /** Inserts a new sheet name into the SUPBOOK and returns the SUPBOOK internal sheet index. */
      sal_uInt16          InsertTabName( const String& rTabName );
      /** Finds or inserts an EXTERNNAME record for add-ins.
-@@ -394,6 +411,9 @@ public:
+@@ -328,6 +363,8 @@ public:
+         @return  The 1-based EXTERNNAME record index; or 0, if the record list is full. */
+     sal_uInt16          InsertDde( const String& rItem );
+ 
++    sal_uInt16          InsertExtName( const String& rName, const ScTokenArray* pArray );
++
+     /** Writes the SUPBOOK and all EXTERNNAME, XCT and CRN records. */
+     virtual void        Save( XclExpStream& rStrm );
+ 
+@@ -394,6 +431,9 @@ public:
      /** Stores all cells in the given range in a CRN record list. */
      void                StoreCellRange( const ScRange& rRange );
  
@@ -1363,7 +1355,14 @@
      /** Finds or inserts an EXTERNNAME record for an add-in function name.
          @param rnSupbook  Returns the index of the SUPBOOK record which contains the add-in function name.
          @param rnExtName  Returns the 1-based EXTERNNAME record index. */
-@@ -410,6 +430,15 @@ public:
+@@ -407,9 +447,22 @@ public:
+                             sal_uInt16& rnSupbook, sal_uInt16& rnExtName,
+                             const String& rApplic, const String& rTopic, const String& rItem );
+ 
++    bool                InsertExtName(
++                            sal_uInt16& rnSupbook, sal_uInt16& rnExtName, const String& rUrl,
++                            const String& rName, const ScTokenArray* pArray );
++
      /** Writes all SUPBOOK records with their sub records. */
      virtual void        Save( XclExpStream& rStrm );
  
@@ -1379,7 +1378,7 @@
  private:
      typedef XclExpRecordList< XclExpSupbook >   XclExpSupbookList;
      typedef XclExpSupbookList::RecordRefType    XclExpSupbookRef;
-@@ -435,15 +464,6 @@ private:
+@@ -435,15 +488,6 @@ private:
      void                AddExtSupbook( SCTAB nScTab );
  
  private:
@@ -1395,7 +1394,7 @@
      XclExpSupbookList   maSupbookList;      /// List of all SUPBOOK records.
      XclExpSBIndexVec    maSBIndexVec;       /// SUPBOOK and sheet name index for each Excel sheet.
      sal_uInt16          mnOwnDocSB;         /// Index to SUPBOOK for own document.
-@@ -467,6 +487,9 @@ public:
+@@ -467,6 +511,9 @@ public:
      /** Derived classes store all cells in the given range in a CRN record list. */
      virtual void        StoreCellRange( const SingleRefData& rRef1, const SingleRefData& rRef2 ) = 0;
  
@@ -1405,7 +1404,18 @@
      /** Derived classes find or insert an EXTERNNAME record for an add-in function name. */
      virtual bool        InsertAddIn(
                              sal_uInt16& rnExtSheet, sal_uInt16& rnExtName,
-@@ -499,6 +522,9 @@ public:
+@@ -476,6 +523,10 @@ public:
+                             sal_uInt16& rnExtSheet, sal_uInt16& rnExtName,
+                             const String& rApplic, const String& rTopic, const String& rItem ) = 0;
+ 
++    virtual bool        InsertExtName(
++                            sal_uInt16& rnExtSheet, sal_uInt16& rnExtName, const String& rUrl,
++                            const String& rName, const ScTokenArray* pArray ) = 0;
++
+     /** Derived classes write the entire link table to the passed stream. */
+     virtual void        Save( XclExpStream& rStrm ) = 0;
+ 
+@@ -499,13 +550,21 @@ public:
  
      virtual void        StoreCellRange( const SingleRefData& rRef1, const SingleRefData& rRef2 );
  
@@ -1415,7 +1425,19 @@
      virtual bool        InsertAddIn(
                              sal_uInt16& rnExtSheet, sal_uInt16& rnExtName,
                              const String& rName );
-@@ -552,6 +578,9 @@ public:
++
+     virtual bool        InsertDde(
+                             sal_uInt16& rnExtSheet, sal_uInt16& rnExtName,
+                             const String& rApplic, const String& rTopic, const String& rItem );
+ 
++    virtual bool        InsertExtName(
++                            sal_uInt16& rnExtSheet, sal_uInt16& rnExtName, const String& rUrl,
++                            const String& rName, const ScTokenArray* pArray );
++
+     virtual void        Save( XclExpStream& rStrm );
+ 
+ private:
+@@ -552,13 +611,21 @@ public:
  
      virtual void        StoreCellRange( const SingleRefData& rRef1, const SingleRefData& rRef2 );
  
@@ -1425,22 +1447,67 @@
      virtual bool        InsertAddIn(
                              sal_uInt16& rnExtSheet, sal_uInt16& rnExtName,
                              const String& rName );
-@@ -1013,6 +1042,8 @@ XclExpXct::XclExpXct( const String& rTabName, sal_uInt16 nSBTab ) :
-     maTabName( rTabName ),
-     mnSBTab( nSBTab )
- {
-+    fprintf(stdout, "XclExpXct::XclExpXct:   sheet name = '%s'; supbook sheet index = %d\n",
-+            rtl::OUStringToOString(rTabName, RTL_TEXTENCODING_UTF8).getStr(), nSBTab);
++
+     virtual bool        InsertDde(
+                             sal_uInt16& rnExtSheet, sal_uInt16& rnExtName,
+                             const String& rApplic, const String& rTopic, const String& rItem );
+ 
++    virtual bool        InsertExtName(
++                            sal_uInt16& rnExtSheet, sal_uInt16& rnExtName, const String& rUrl,
++                            const String& rName, const ScTokenArray* pArray );
++
+     virtual void        Save( XclExpStream& rStrm );
+ 
+ private:
+@@ -885,6 +952,29 @@ void XclExpExtNameDde::WriteAddData( XclExpStream& rStrm )
+         mxMatrix->Save( rStrm );
  }
  
- void XclExpXct::StoreCellRange( const XclExpRoot& rRoot, const ScRange& rRange )
-@@ -1066,6 +1097,83 @@ void XclExpXct::StoreCellRange( const XclExpRoot& rRoot, const ScRange& rRange )
++// ----------------------------------------------------------------------------
++
++XclExpExtName::XclExpExtName( const XclExpRoot& rRoot, const String& rName, const ScTokenArray* pArray ) :
++    XclExpExtNameBase( rRoot, rName ),
++    mpArray(pArray->Clone())
++{
++}
++
++void XclExpExtName::WriteAddData( XclExpStream& rStrm )
++{
++    rStrm << static_cast<sal_uInt8>(0x09);
++    rStrm << static_cast<sal_uInt8>(0x00);
++    rStrm << static_cast<sal_uInt8>(0x3A);
++    rStrm << static_cast<sal_uInt8>(0x01);
++    rStrm << static_cast<sal_uInt8>(0x00);
++    rStrm << static_cast<sal_uInt8>(0x01);
++    rStrm << static_cast<sal_uInt8>(0x00);
++    rStrm << static_cast<sal_uInt8>(0x08);
++    rStrm << static_cast<sal_uInt8>(0x00);
++    rStrm << static_cast<sal_uInt8>(0x02);
++    rStrm << static_cast<sal_uInt8>(0x00);
++}
++
+ // List of external names =====================================================
+ 
+ XclExpExtNameBuffer::XclExpExtNameBuffer( const XclExpRoot& rRoot ) :
+@@ -920,6 +1010,12 @@ sal_uInt16 XclExpExtNameBuffer::InsertDde(
+     return nIndex;
+ }
+ 
++sal_uInt16 XclExpExtNameBuffer::InsertExtName( const String& rName, const ScTokenArray* pArray )
++{
++    sal_uInt16 nIndex = GetIndex( rName );
++    return nIndex ? nIndex : AppendNew( new XclExpExtName( GetRoot(), rName, pArray ) );
++}
++
+ void XclExpExtNameBuffer::Save( XclExpStream& rStrm )
+ {
+     maNameList.Save( rStrm );
+@@ -1066,6 +1162,77 @@ void XclExpXct::StoreCellRange( const XclExpRoot& rRoot, const ScRange& rRange )
      maUsedCells.SetMultiMarkArea( rRange );
  }
  
-+void XclExpXct::StoreCell( const XclExpRoot& rRoot, const ScAddress& rCell, const ScToken& rToken )
++void XclExpXct::StoreCell( const XclExpRoot& /*rRoot*/, const ScAddress& rCell, const ScToken& rToken )
 +{
-+    fprintf(stdout, "XclExpXct::StoreCell: --begin\n");
 +    switch (rToken.GetType())
 +    {
 +        case svString:
@@ -1465,16 +1532,15 @@
 +        }
 +        break;
 +    }
-+    fprintf(stdout, "XclExpXct::StoreCell: --end\n");
 +}
 +
-+void XclExpXct::StoreCellRange( const XclExpRoot& rRoot, const ScRange& rRange, const ScToken& rToken )
++void XclExpXct::StoreCellRange( const XclExpRoot& /*rRoot*/, const ScRange& rRange, const ScToken& rToken )
 +{
-+    fprintf(stdout, "XclExpXct::StoreCellRange: --begin\n");
 +    if (rToken.GetType() != svMatrix)
 +        return;
 +
 +    if (rRange.aStart.Tab() != rRange.aEnd.Tab())
++        // multi-table range is not supported here.
 +        return;
 +
 +    const ScMatrix* pMtx = rToken.GetMatrix();
@@ -1483,13 +1549,11 @@
 +
 +    SCSIZE nCols, nRows;
 +    pMtx->GetDimensions(nCols, nRows);
-+    fprintf(stdout, "XclExpXct::StoreCellRange:   cols = %d; rows = %d\n", nCols, nRows);
 +    const ScAddress& s = rRange.aStart;
 +    const ScAddress& e = rRange.aEnd;
 +    if (nCols != e.Col() - s.Col() + 1 || nRows != e.Row() - s.Row() + 1)
 +    {
 +        // size mis-match!
-+        fprintf(stdout, "XclExpXct::StoreCellRange:   matrix and range sizes differ!\n");
 +        return;
 +    }
 +
@@ -1511,14 +1575,12 @@
 +            }
 +        }
 +    }
-+
-+    fprintf(stdout, "XclExpXct::StoreCellRange: --end\n");
 +}
 +
  void XclExpXct::Save( XclExpStream& rStrm )
  {
      XclExpRecord::Save( rStrm );
-@@ -1206,13 +1314,60 @@ void XclExpSupbook::StoreCellRange( const ScRange& rRange, sal_uInt16 nSBTab )
+@@ -1206,6 +1373,41 @@ void XclExpSupbook::StoreCellRange( const ScRange& rRange, sal_uInt16 nSBTab )
          xXct->StoreCellRange( GetRoot(), rRange );
  }
  
@@ -1533,23 +1595,15 @@
 +
 +void XclExpSupbook::StoreCellRange( sal_uInt16 nSBTab, const ScRange& rRange, const ScToken& rToken )
 +{
-+    fprintf(stdout, "XclExpSupbook::StoreCellRange: --begin\n");
 +    if (rRange.aStart.Tab() != rRange.aEnd.Tab())
-+    {
 +        // multi-table range is not allowed!
-+        fprintf(stdout, "XclExpSupbook::StoreCellRange:   multi-table range is not allowed\n");
 +        return;
-+    }
 +
 +    XclExpXctRef xXct = maXctList.GetRecord(nSBTab);
 +    if (!xXct.is())
-+    {
-+        fprintf(stdout, "XclExpSupbook::StoreCellRange:   no xct instance\n");
 +        return;
-+    }
 +
 +    xXct->StoreCellRange(GetRoot(), rRange, rToken);
-+    fprintf(stdout, "XclExpSupbook::StoreCellRange: --end\n");
 +}
 +
 +sal_uInt16 XclExpSupbook::GetTabIndex( const String& rTabName )
@@ -1567,69 +1621,20 @@
 +
  sal_uInt16 XclExpSupbook::InsertTabName( const String& rTabName )
  {
-+    fprintf(stdout, "XclExpSupbook::InsertTabName: --begin (sheet name = '%s')\n", 
-+            rtl::OUStringToOString(rTabName, RTL_TEXTENCODING_UTF8).getStr());
-+
      DBG_ASSERT( meType == EXC_SBTYPE_EXTERN, "XclExpSupbook::InsertTabName - don't insert sheet names here" );
-     sal_uInt16 nSBTab = ulimit_cast< sal_uInt16 >( maXctList.GetSize() );
-     XclExpXctRef xXct( new XclExpXct( rTabName, nSBTab ) );
-     AddRecSize( xXct->GetTabName().GetSize() );
-     maXctList.AppendRecord( xXct );
-+    fprintf(stdout, "XclExpSupbook::InsertTabName: --end (sheet index = %d)\n", nSBTab);
-     return nSBTab;
+@@ -1226,6 +1428,11 @@ sal_uInt16 XclExpSupbook::InsertDde( const String& rItem )
+     return GetExtNameBuffer().InsertDde( maUrl, maDdeTopic, rItem );
  }
  
-@@ -1244,6 +1399,13 @@ const XclExpString* XclExpSupbook::GetTabName( sal_uInt16 nSBTab ) const
- 
- void XclExpSupbook::WriteBody( XclExpStream& rStrm )
- {
-+    fprintf(stdout, "XclExpSupbook::WriteBody: --begin\n");
-+
-+    fprintf(stdout, "XclExpSupbook::WriteBody:   url = '%s'\n",
-+            rtl::OUStringToOString(maUrl, RTL_TEXTENCODING_UTF8).getStr());
-+
-+    fprintf(stdout, "XclExpSupbook::WriteBody:   sheet count = %d\n", mnXclTabCount);
++sal_uInt16 XclExpSupbook::InsertExtName( const String& rName, const ScTokenArray* pArray )
++{
++    return GetExtNameBuffer().InsertExtName(rName, pArray);
++}
 +
-     switch( meType )
-     {
-         case EXC_SBTYPE_SELF:
-@@ -1265,6 +1427,7 @@ void XclExpSupbook::WriteBody( XclExpStream& rStrm )
-         default:
-             DBG_ERRORFILE( "XclExpSupbook::WriteBody - unknown SUPBOOK type" );
-     }
-+    fprintf(stdout, "XclExpSupbook::WriteBody: --end\n");
- }
- 
- // All SUPBOOKS in a document =================================================
-@@ -1274,11 +1437,15 @@ XclExpSupbookBuffer::XclExpSupbookBuffer( const XclExpRoot& rRoot ) :
-     mnOwnDocSB( SAL_MAX_UINT16 ),
-     mnAddInSB( SAL_MAX_UINT16 )
+ void XclExpSupbook::Save( XclExpStream& rStrm )
  {
-+    fprintf(stdout, "XclExpSupbookBuffer::XclExpSupbookBuffer: --begin ctor\n");
-+
-     XclExpTabInfo& rTabInfo = GetTabInfo();
-     sal_uInt16 nXclCnt = rTabInfo.GetXclTabCount();
-     sal_uInt16 nCodeCnt = static_cast< sal_uInt16 >( GetExtDocOptions().GetCodeNameCount() );
-     size_t nCount = nXclCnt + rTabInfo.GetXclExtTabCount();
- 
-+    fprintf(stdout, "XclExpSupbookBuffer::XclExpSupbookBuffer:   external tab count = %d\n", nCount);
-+
-     DBG_ASSERT( nCount > 0, "XclExpSupbookBuffer::XclExpSupbookBuffer - no sheets to export" );
-     if( nCount )
-     {
-@@ -1288,7 +1455,11 @@ XclExpSupbookBuffer::XclExpSupbookBuffer( const XclExpRoot& rRoot ) :
-         XclExpSupbookRef xSupbook( new XclExpSupbook( GetRoot(), ::std::max( nXclCnt, nCodeCnt ) ) );
-         mnOwnDocSB = Append( xSupbook );
-         for( sal_uInt16 nXclTab = 0; nXclTab < nXclCnt; ++nXclTab )
-+        {
-+            fprintf(stdout, "XclExpSupbookBuffer::XclExpSupbookBuffer:   supbook index = %d; sheet index = %d (internal)\n",
-+                    mnOwnDocSB, nXclTab);
-             maSBIndexVec[ nXclTab ].Set( mnOwnDocSB, nXclTab );
-+        }
- 
-         // add SUPBOOKs with external references
-         for( SCTAB nScTab = 0, nScCnt = rTabInfo.GetScTabCount(); nScTab < nScCnt; ++nScTab )
-@@ -1352,6 +1523,147 @@ void XclExpSupbookBuffer::StoreCellRange( const ScRange& rRange )
+     // SUPBOOK record
+@@ -1352,6 +1559,131 @@ void XclExpSupbookBuffer::StoreCellRange( const ScRange& rRange )
      }
  }
  
@@ -1660,14 +1665,10 @@
 +    if (!pUrl)
 +        return;
 +
-+    fprintf(stdout, "XclExpSupbookBuffer::StoreCell: --begin (file url = '%s')\n",
-+            rtl::OUStringToOString(*pUrl, RTL_TEXTENCODING_UTF8).getStr());
-+
 +    XclExpSupbookRef xSupbook;
 +    sal_uInt16 nSupbookId;
 +    if (!GetSupbookUrl(xSupbook, nSupbookId, *pUrl))
 +    {
-+        fprintf(stdout, "XclExpSupbookBuffer::StoreCellRange:   supbook for given url does not exist\n");
 +        xSupbook.reset(new XclExpSupbook(GetRoot(), *pUrl));
 +        nSupbookId = Append(xSupbook);
 +    }
@@ -1680,9 +1681,6 @@
 +    if (!pTabName)
 +        return;
 +
-+    fprintf(stdout, "XclExpSupbookBuffer::StoreCell:   tab name = '%s'\n", 
-+            rtl::OUStringToOString(*pTabName, RTL_TEXTENCODING_UTF8).getStr());
-+
 +    sal_uInt16 nSheetId = xSupbook->GetTabIndex(*pTabName);
 +    FindSBIndexEntry f(nSupbookId, nSheetId);
 +    XclExpSBIndexVec::iterator itrEnd = maSBIndexVec.end();
@@ -1705,14 +1703,10 @@
 +    if (!pUrl)
 +        return;
 +
-+    fprintf(stdout, "XclExpSupbookBuffer::StoreCellRange: --begin (file url = '%s')\n",
-+            rtl::OUStringToOString(*pUrl, RTL_TEXTENCODING_UTF8).getStr());
-+
 +    XclExpSupbookRef xSupbook;
 +    sal_uInt16 nSupbookId;
 +    if (!GetSupbookUrl(xSupbook, nSupbookId, *pUrl))
 +    {
-+        fprintf(stdout, "XclExpSupbookBuffer::StoreCellRange:   supbook for given url does not exist\n");
 +        xSupbook.reset(new XclExpSupbook(GetRoot(), *pUrl));
 +        nSupbookId = Append(xSupbook);
 +    }
@@ -1740,7 +1734,7 @@
 +
 +    if (aMatrixList.size() != nTab2 - nTab1 + 1)
 +    {
-+        fprintf(stdout, "XclExpSupbookBuffer::StoreCellRange:   matrix size mismatch!\n");
++        // matrix size mis-match !
 +        return;
 +    }
 +
@@ -1753,9 +1747,6 @@
 +        if (!pTabName)
 +            continue;
 +
-+        fprintf(stdout, "XclExpSupbookBuffer::StoreCellRange:   tab name = '%s'\n", 
-+                rtl::OUStringToOString(*pTabName, RTL_TEXTENCODING_UTF8).getStr());
-+
 +        sal_uInt16 nSheetId = xSupbook->GetTabIndex(*pTabName);
 +        FindSBIndexEntry f(nSupbookId, nSheetId);
 +        XclExpSBIndexVec::iterator itrEnd = maSBIndexVec.end();
@@ -1770,58 +1761,33 @@
 +
 +        xSupbook->StoreCellRange(nSheetId, aRange, *aMatrixList[nTab-nTab1]);
 +    }
-+
-+    fprintf(stdout, "XclExpSupbookBuffer::StoreCellRange: --end\n");
 +}
 +
  bool XclExpSupbookBuffer::InsertAddIn(
          sal_uInt16& rnSupbook, sal_uInt16& rnExtName, const String& rName )
  {
-@@ -1385,7 +1697,9 @@ bool XclExpSupbookBuffer::InsertDde(
+@@ -1383,6 +1715,20 @@ bool XclExpSupbookBuffer::InsertDde(
+     return rnExtName > 0;
+ }
  
++bool XclExpSupbookBuffer::InsertExtName(
++        sal_uInt16& rnSupbook, sal_uInt16& rnExtName, const String& rUrl,
++        const String& rName, const ScTokenArray* pArray )
++{
++    XclExpSupbookRef xSupbook;
++    if (!GetSupbookUrl(xSupbook, rnSupbook, rUrl))
++    {
++        xSupbook.reset( new XclExpSupbook(GetRoot(), rUrl) );
++        rnSupbook = Append(xSupbook);
++    }
++    rnExtName = xSupbook->InsertExtName(rName, pArray);
++    return rnExtName > 0;
++}
++
  void XclExpSupbookBuffer::Save( XclExpStream& rStrm )
  {
-+    fprintf(stdout, "XclExpSupbookBuffer::Save: --begin\n");
      maSupbookList.Save( rStrm );
-+    fprintf(stdout, "XclExpSupbookBuffer::Save: --end\n");
- }
- 
- bool XclExpSupbookBuffer::GetSupbookUrl(
-@@ -1426,11 +1740,17 @@ sal_uInt16 XclExpSupbookBuffer::Append( XclExpSupbookRef xSupbook )
- 
- void XclExpSupbookBuffer::AddExtSupbook( SCTAB nScTab )
- {
-+    fprintf(stdout, "XclExpSupbookBuffer::AddExtSupbook: --begin (sctab = %d)\n", nScTab);
-+
-     sal_uInt16 nXclTab = GetTabInfo().GetXclTab( nScTab );
-+    fprintf(stdout, "XclExpSupbookBuffer::AddExtSupbook:   xlstab = %d\n", nXclTab);
-     DBG_ASSERT( nXclTab < maSBIndexVec.size(), "XclExpSupbookBuffer::AddExtSupbook - out of range" );
- 
-     // find ext doc name or append new one, save position in maSBIndexBuffer
-     const String& rUrl = GetDoc().GetLinkDoc( nScTab );
-+    fprintf(stdout, "XclExpSupbookBuffer::AddExtSupbook:   url = '%s'\n",
-+            rtl::OUStringToOString(rUrl, RTL_TEXTENCODING_UTF8).getStr());
-+
-     DBG_ASSERT( rUrl.Len(), "XclExpSupbookBuffer::AddExtSupbook - missing external linked sheet" );
-     sal_uInt16 nSupbook;
-     XclExpSupbookRef xSupbook;
-@@ -1439,10 +1759,15 @@ void XclExpSupbookBuffer::AddExtSupbook( SCTAB nScTab )
-         xSupbook.reset( new XclExpSupbook( GetRoot(), rUrl ) );
-         nSupbook = Append( xSupbook );
-     }
-+    fprintf(stdout, "XclExpSupbookBuffer::AddExtSupbook:   nSupbook = %d\n", nSupbook);
- 
-     // append new sheet name, save SUPBOOK and sheet position in maSBIndexVec
-     maSBIndexVec[ nXclTab ].mnSupbook = nSupbook;
-     maSBIndexVec[ nXclTab ].mnSBTab = xSupbook->InsertTabName( GetDoc().GetLinkTab( nScTab ) );
-+
-+    fprintf(stdout, "XclExpSupbookBuffer::AddExtSupbook:   supbook = %d; sheet index = %d; sheet name = '%s'\n", 
-+            nSupbook, maSBIndexVec[nXclTab].mnSBTab,
-+            rtl::OUStringToOString(GetDoc().GetLinkTab(nScTab), RTL_TEXTENCODING_UTF8).getStr());
- }
- 
- // Export link manager ========================================================
-@@ -1490,6 +1815,16 @@ void XclExpLinkManagerImpl5::StoreCellRange( const SingleRefData& /*rRef1*/, con
+@@ -1490,6 +1836,16 @@ void XclExpLinkManagerImpl5::StoreCellRange( const SingleRefData& /*rRef1*/, con
      // not implemented
  }
  
@@ -1838,23 +1804,22 @@
  bool XclExpLinkManagerImpl5::InsertAddIn(
          sal_uInt16& rnExtSheet, sal_uInt16& rnExtName, const String& rName )
  {
-@@ -1640,10 +1975,15 @@ void XclExpLinkManagerImpl8::StoreCellRange( const SingleRefData& rRef1, const S
-         ScRange aRange(
-             static_cast< SCCOL >( rRef1.nCol ), static_cast< SCROW >( rRef1.nRow ), 0,
-             static_cast< SCCOL >( rRef2.nCol ), static_cast< SCROW >( rRef2.nRow ), 0 );
-+        String aStr;
-+        aRange.Format(aStr, SCR_ABS_3D, &GetDoc());
-+        fprintf(stdout, "XclExpLinkManagerImpl8::StoreCellRange:   range = '%s'\n", 
-+                rtl::OUStringToOString(aStr, RTL_TEXTENCODING_UTF8).getStr());
-         for( SCTAB nScTab = nFirstScTab; nScTab <= nLastScTab; ++nScTab )
-         {
-             if( rTabInfo.IsExternalTab( nScTab ) )
-             {
-+                fprintf(stdout, "XclExpLinkManagerImpl8::StoreCellRange:   %d is an external sheet\n", nScTab);
-                 aRange.aStart.SetTab( nScTab );
-                 aRange.aEnd.SetTab( nScTab );
-                 maSBBuffer.StoreCellRange( aRange );
-@@ -1652,6 +1992,36 @@ void XclExpLinkManagerImpl8::StoreCellRange( const SingleRefData& rRef1, const S
+@@ -1510,6 +1866,14 @@ bool XclExpLinkManagerImpl5::InsertDde(
+     return false;
+ }
+ 
++bool XclExpLinkManagerImpl5::InsertExtName(
++        sal_uInt16& /*rnExtSheet*/, sal_uInt16& /*rnExtName*/, const String& /*rUrl*/,
++        const String& /*rName*/, const ScTokenArray* /*pArray*/ )
++{
++    // not implemented
++    return false;
++}
++
+ void XclExpLinkManagerImpl5::Save( XclExpStream& rStrm )
+ {
+     if( sal_uInt16 nExtSheetCount = GetExtSheetCount() )
+@@ -1652,6 +2016,19 @@ void XclExpLinkManagerImpl8::StoreCellRange( const SingleRefData& rRef1, const S
      }
  }
  
@@ -1866,55 +1831,34 @@
 +
 +void XclExpLinkManagerImpl8::StoreCellRange( sal_uInt16 nFileId, const SingleRefData& rRef1, const SingleRefData& rRef2 )
 +{
-+    fprintf(stdout, "XclExpLinkManagerImpl8::StoreCellRange: --begin (file id = %d)\n", nFileId);
-+
-+    // XclExpXti -- stores supbook ID and first and last sheet IDs for EXTERNSHEET.
-+    // 
-+    // XclExpSupbookBuffer -- stores
-+
-+    // 1) Insert into supbook buffer first, and get the supbook ID.
-+    SCTAB nFirstScTab = static_cast<SCTAB>(rRef1.nTab);
-+    SCTAB nLastScTab  = static_cast<SCTAB>(rRef2.nTab);
 +    ScRange aRange(static_cast<SCCOL>(rRef1.nCol), static_cast<SCROW>(rRef1.nRow), static_cast<SCTAB>(rRef1.nTab),
 +                   static_cast<SCCOL>(rRef2.nCol), static_cast<SCROW>(rRef2.nRow), static_cast<SCTAB>(rRef2.nTab));
 +    maSBBuffer.StoreCellRange(nFileId, aRange);
-+//  for (SCTAB nScTab = nFirstScTab; nScTab <= nLastScTab; ++nScTab)
-+//  {
-+//      aRange.aStart.SetTab(nScTab);
-+//      aRange.aEnd.SetTab(nScTab);
-+//      maSBBuffer.StoreCellRange(nFileId, aRange);
-+//  }
-+    
-+    fprintf(stdout, "XclExpLinkManagerImpl8::StoreCellRange: --end\n");
 +}
 +
  bool XclExpLinkManagerImpl8::InsertAddIn(
          sal_uInt16& rnExtSheet, sal_uInt16& rnExtName, const String& rName )
  {
-@@ -1693,13 +2063,20 @@ void XclExpLinkManagerImpl8::Save( XclExpStream& rStrm )
-             aIt->Save( rStrm );
-         rStrm.EndRecord();
-     }
-+    else
-+    {
-+        fprintf(stdout, "XclExpLinkManagerImpl8::Save:   xti (external table index) list is empty - nothing to save\n");
-+        maSBBuffer.Save(rStrm);
-+    }
+@@ -1677,6 +2054,18 @@ bool XclExpLinkManagerImpl8::InsertDde(
+     return false;
  }
  
- sal_uInt16 XclExpLinkManagerImpl8::InsertXti( const XclExpXti& rXti )
++bool XclExpLinkManagerImpl8::InsertExtName(
++    sal_uInt16& rnExtSheet, sal_uInt16& rnExtName, const String& rName, const String& rUrl, const ScTokenArray* pArray )
++{
++    sal_uInt16 nSupbook;
++    if( maSBBuffer.InsertExtName( nSupbook, rnExtName, rUrl, rName, pArray ) )
++    {
++        rnExtSheet = InsertXti( XclExpXti( nSupbook, EXC_TAB_EXTERNAL, EXC_TAB_EXTERNAL ) );
++        return true;
++    }
++    return false;
++}
++
+ void XclExpLinkManagerImpl8::Save( XclExpStream& rStrm )
  {
--    for( XclExpXtiVec::const_iterator aIt = maXtiVec.begin(), aEnd = maXtiVec.end(); aIt != aEnd; ++aIt )
-+    using ::std::distance;
-+    for( XclExpXtiVec::const_iterator aIt = maXtiVec.begin(), aBeg = maXtiVec.begin(), aEnd = maXtiVec.end(); 
-+         aIt != aEnd; ++aIt )
-         if( *aIt == rXti )
--            return ulimit_cast< sal_uInt16 >( aIt - maXtiVec.begin() );
-+            return ulimit_cast< sal_uInt16 >( distance(aBeg, aIt) );
-     maXtiVec.push_back( rXti );
-     return ulimit_cast< sal_uInt16 >( maXtiVec.size() - 1 );
- }
-@@ -1755,6 +2132,16 @@ void XclExpLinkManager::StoreCellRange( const ComplRefData& rRef )
+     if( !maXtiVec.empty() )
+@@ -1755,6 +2144,16 @@ void XclExpLinkManager::StoreCellRange( const ComplRefData& rRef )
      mxImpl->StoreCellRange( rRef.Ref1, rRef.Ref2 );
  }
  
@@ -1931,16 +1875,20 @@
  bool XclExpLinkManager::InsertAddIn(
          sal_uInt16& rnExtSheet, sal_uInt16& rnExtName, const String& rName )
  {
-@@ -1770,7 +2157,9 @@ bool XclExpLinkManager::InsertDde(
+@@ -1768,6 +2167,13 @@ bool XclExpLinkManager::InsertDde(
+     return mxImpl->InsertDde( rnExtSheet, rnExtName, rApplic, rTopic, rItem );
+ }
  
++bool XclExpLinkManager::InsertExtName(
++    sal_uInt16& rnExtSheet, sal_uInt16& rnExtName, const String& rName, const String& rUrl,
++    const ScTokenArray* pArray )
++{
++    return mxImpl->InsertExtName( rnExtSheet, rnExtName, rUrl, rName, pArray );
++}
++
  void XclExpLinkManager::Save( XclExpStream& rStrm )
  {
-+    fprintf(stdout, "XclExpLinkManager::Save: --begin\n");
      mxImpl->Save( rStrm );
-+    fprintf(stdout, "XclExpLinkManager::Save: --end\n");
- }
- 
- // ============================================================================
 diff --git sc/source/filter/excel/xilink.cxx sc/source/filter/excel/xilink.cxx
 index e351863..b58f6ec 100644
 --- sc/source/filter/excel/xilink.cxx
@@ -2029,7 +1977,7 @@
  		inline const TokenId		LastId( void ) const;
  		inline const ScTokenArray*	operator []( const TokenId nId );
 diff --git sc/source/filter/inc/xelink.hxx sc/source/filter/inc/xelink.hxx
-index 795219c..37f1457 100644
+index 795219c..2d528d9 100644
 --- sc/source/filter/inc/xelink.hxx
 +++ sc/source/filter/inc/xelink.hxx
 @@ -178,6 +178,10 @@ public:
@@ -2043,6 +1991,17 @@
      /** Finds or inserts an EXTERNNAME record for an add-in function name.
          @param rnExtSheet  (out-param) Returns the index of the EXTSHEET structure for the add-in function name.
          @param rnExtName  (out-param) Returns the 1-based EXTERNNAME record index.
+@@ -193,6 +197,10 @@ public:
+                             sal_uInt16& rnExtSheet, sal_uInt16& rnExtName,
+                             const String& rApplic, const String& rTopic, const String& rItem );
+ 
++    bool                InsertExtName(
++                            sal_uInt16& rnExtSheet, sal_uInt16& rnExtName, const String& rUrl,
++                            const String& rName, const ScTokenArray* pArray );
++
+     /** Writes the entire Link table. */
+     virtual void        Save( XclExpStream& rStrm );
+ 
 diff --git sc/source/filter/inc/xilink.hxx sc/source/filter/inc/xilink.hxx
 index 0d547fe..3c2d0d9 100644
 --- sc/source/filter/inc/xilink.hxx



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]