Commits

rt  committed 4136ae4

INTEGRATION: CWS swenhancedfields2 (1.136.28); FILE MERGED
2008/08/12 12:09:46 b_michaelsen 1.136.28.3: explicit casts to prevent win32 warnings
2008/08/04 14:16:12 b_michaelsen 1.136.28.2: RESYNC: (1.136-1.139); FILE MERGED
2008/04/23 14:29:22 ama 1.136.28.1: #i33737#: Enhanced fields

  • Participants
  • Parent commits 8042ff9

Comments (0)

Files changed (1)

File sw/source/filter/ww8/ww8scan.cxx

  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: ww8scan.cxx,v $
- * $Revision: 1.141 $
+ * $Revision: 1.142 $
  *
  * This file is part of OpenOffice.org.
  *
 }
 
 WW8PLCFx_Book::WW8PLCFx_Book(SvStream* pTblSt, const WW8Fib& rFib)
-    : WW8PLCFx(rFib.GetFIBVersion(), false), pStatus(0), nIsEnd(0)
+    : WW8PLCFx(rFib.GetFIBVersion(), false), pStatus(0), nIsEnd(0), nBookmarkId(1)
 {
     if( !rFib.fcPlcfbkf || !rFib.lcbPlcfbkf || !rFib.fcPlcfbkl ||
         !rFib.lcbPlcfbkl || !rFib.fcSttbfbkmk || !rFib.lcbSttbfbkmk )
     return bFound ? aBookNames[i] : aEmptyStr;
 }
 
+String WW8PLCFx_Book::GetUniqueBookmarkName(String &suggestedName)
+{
+	String aRet=(suggestedName.Len()==0?String::CreateFromAscii("Unnamed"):suggestedName);
+	unsigned int i=0;
+	while(i<aBookNames.size()) {
+		String &s=aBookNames[i];
+		if (aRet.CompareTo(s)==0) {
+			int len=aRet.Len();
+			int p=len-1;
+			while(p>0 && aRet.GetChar(static_cast<USHORT>(p))>='0' && aRet.GetChar(static_cast<USHORT>(p))<='9')
+                p--;
+			aRet=String(aRet, 0, static_cast<USHORT>(p+1));
+			aRet += String::CreateFromInt32( nBookmarkId++ );
+			i=0; // start search from beginning
+		} else {
+			i++;
+		}
+	}
+	return aRet;
+}
+
 bool WW8PLCFx_Book::MapName(String& rName)
 {
     if( !pBook[0] || !pBook[1] )