xref: /aoo41x/main/sw/source/core/doc/docdde.cxx (revision 12ad4c42)
1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5efeef26fSAndrew Rist  * distributed with this work for additional information
6efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10efeef26fSAndrew Rist  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist  *
13efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17efeef26fSAndrew Rist  * specific language governing permissions and limitations
18efeef26fSAndrew Rist  * under the License.
19efeef26fSAndrew Rist  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <stdlib.h>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #ifndef _APP_HXX
32cdf0e10cSrcweir #include <vcl/svapp.hxx>
33cdf0e10cSrcweir #endif
34cdf0e10cSrcweir #include <tools/urlobj.hxx>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #define _SVSTDARR_STRINGS
37cdf0e10cSrcweir #include <svl/svstdarr.hxx>
38cdf0e10cSrcweir #include <sfx2/linkmgr.hxx>			// LinkManager
39cdf0e10cSrcweir #include <unotools/charclass.hxx>
40cdf0e10cSrcweir #include <fmtcntnt.hxx>
41cdf0e10cSrcweir #include <doc.hxx>
42cdf0e10cSrcweir #include <swserv.hxx>			// fuer Server-Funktionalitaet
43cdf0e10cSrcweir #include <IMark.hxx>
44cdf0e10cSrcweir #include <bookmrk.hxx>
45cdf0e10cSrcweir #include <section.hxx>			// fuer SwSectionFmt
46cdf0e10cSrcweir #include <swtable.hxx>			// fuer SwTable
47cdf0e10cSrcweir #include <node.hxx>
48cdf0e10cSrcweir #include <ndtxt.hxx>
49cdf0e10cSrcweir #include <pam.hxx>
50cdf0e10cSrcweir #include <docary.hxx>
51cdf0e10cSrcweir #include <MarkManager.hxx>
52cdf0e10cSrcweir 
53cdf0e10cSrcweir using namespace ::com::sun::star;
54cdf0e10cSrcweir 
55cdf0e10cSrcweir namespace
56cdf0e10cSrcweir {
57cdf0e10cSrcweir 
lcl_FindDdeBookmark(const IDocumentMarkAccess & rMarkAccess,const String & rName,const bool bCaseSensitive)58dec99bbdSOliver-Rainer Wittmann     static ::sw::mark::DdeBookmark* lcl_FindDdeBookmark(
59dec99bbdSOliver-Rainer Wittmann         const IDocumentMarkAccess& rMarkAccess,
60dec99bbdSOliver-Rainer Wittmann         const String& rName,
61dec99bbdSOliver-Rainer Wittmann         const bool bCaseSensitive )
62cdf0e10cSrcweir     {
63cdf0e10cSrcweir         //Iterating over all bookmarks, checking DdeBookmarks
64cdf0e10cSrcweir         const ::rtl::OUString sNameLc = bCaseSensitive ? rName : GetAppCharClass().lower(rName);
65*12ad4c42SOliver-Rainer Wittmann         for(IDocumentMarkAccess::const_iterator_t ppMark = rMarkAccess.getAllMarksBegin();
66*12ad4c42SOliver-Rainer Wittmann             ppMark != rMarkAccess.getAllMarksEnd();
67cdf0e10cSrcweir             ppMark++)
68cdf0e10cSrcweir         {
69dec99bbdSOliver-Rainer Wittmann             if ( IDocumentMarkAccess::GetType( *(ppMark->get()) ) == IDocumentMarkAccess::DDE_BOOKMARK)
70cdf0e10cSrcweir             {
71dec99bbdSOliver-Rainer Wittmann                 ::sw::mark::DdeBookmark* const pBkmk = dynamic_cast< ::sw::mark::DdeBookmark*>(ppMark->get());
72cdf0e10cSrcweir                 if (
73cdf0e10cSrcweir                     (bCaseSensitive && (pBkmk->GetName() == sNameLc)) ||
74cdf0e10cSrcweir                     (!bCaseSensitive && GetAppCharClass().lower(pBkmk->GetName()) == String(sNameLc))
75cdf0e10cSrcweir                    )
76cdf0e10cSrcweir                 {
77cdf0e10cSrcweir                     return pBkmk;
78cdf0e10cSrcweir                 }
79cdf0e10cSrcweir             }
80cdf0e10cSrcweir         }
81cdf0e10cSrcweir         return NULL;
82cdf0e10cSrcweir     }
83cdf0e10cSrcweir }
84cdf0e10cSrcweir 
85cdf0e10cSrcweir struct _FindItem
86cdf0e10cSrcweir {
87cdf0e10cSrcweir     const String m_Item;
88cdf0e10cSrcweir     SwTableNode* pTblNd;
89cdf0e10cSrcweir     SwSectionNode* pSectNd;
90cdf0e10cSrcweir 
_FindItem_FindItem91cdf0e10cSrcweir     _FindItem(const String& rS)
92cdf0e10cSrcweir         : m_Item(rS), pTblNd(0), pSectNd(0)
93cdf0e10cSrcweir     {}
94cdf0e10cSrcweir };
95cdf0e10cSrcweir 
lcl_FindSection(const SwSectionFmtPtr & rpSectFmt,void * pArgs,bool bCaseSensitive)96cdf0e10cSrcweir sal_Bool lcl_FindSection( const SwSectionFmtPtr& rpSectFmt, void* pArgs, bool bCaseSensitive )
97cdf0e10cSrcweir {
98cdf0e10cSrcweir     _FindItem * const pItem( static_cast<_FindItem*>(pArgs) );
99cdf0e10cSrcweir 	SwSection* pSect = rpSectFmt->GetSection();
100cdf0e10cSrcweir 	if( pSect )
101cdf0e10cSrcweir 	{
102cdf0e10cSrcweir         String sNm( (bCaseSensitive)
103cdf0e10cSrcweir                 ? pSect->GetSectionName()
104cdf0e10cSrcweir                 : GetAppCharClass().lower( pSect->GetSectionName() ));
105cdf0e10cSrcweir         String sCompare( (bCaseSensitive)
106cdf0e10cSrcweir                 ? pItem->m_Item
107cdf0e10cSrcweir                 : GetAppCharClass().lower( pItem->m_Item ) );
108cdf0e10cSrcweir         if( sNm == sCompare )
109cdf0e10cSrcweir 		{
110cdf0e10cSrcweir 			// gefunden, als erfrage die Daten
111cdf0e10cSrcweir 			const SwNodeIndex* pIdx;
112cdf0e10cSrcweir 			if( 0 != (pIdx = rpSectFmt->GetCntnt().GetCntntIdx() ) &&
113cdf0e10cSrcweir 				&rpSectFmt->GetDoc()->GetNodes() == &pIdx->GetNodes() )
114cdf0e10cSrcweir 			{
115cdf0e10cSrcweir 				// eine Tabelle im normalen NodesArr
116cdf0e10cSrcweir                 pItem->pSectNd = pIdx->GetNode().GetSectionNode();
117cdf0e10cSrcweir 				return sal_False;
118cdf0e10cSrcweir 			}
119cdf0e10cSrcweir //nein!!			// sollte der Namen schon passen, der Rest aber nicht, dann haben wir
120cdf0e10cSrcweir 			// sie nicht. Die Namen sind immer eindeutig.
121cdf0e10cSrcweir 		}
122cdf0e10cSrcweir 	}
123cdf0e10cSrcweir 	return sal_True;		// dann weiter
124cdf0e10cSrcweir }
lcl_FindSectionCaseSensitive(const SwSectionFmtPtr & rpSectFmt,void * pArgs)125cdf0e10cSrcweir sal_Bool lcl_FindSectionCaseSensitive( const SwSectionFmtPtr& rpSectFmt, void* pArgs )
126cdf0e10cSrcweir {
127cdf0e10cSrcweir     return lcl_FindSection( rpSectFmt, pArgs, true );
128cdf0e10cSrcweir }
lcl_FindSectionCaseInsensitive(const SwSectionFmtPtr & rpSectFmt,void * pArgs)129cdf0e10cSrcweir sal_Bool lcl_FindSectionCaseInsensitive( const SwSectionFmtPtr& rpSectFmt, void* pArgs )
130cdf0e10cSrcweir {
131cdf0e10cSrcweir     return lcl_FindSection( rpSectFmt, pArgs, false );
132cdf0e10cSrcweir }
133cdf0e10cSrcweir 
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 
lcl_FindTable(const SwFrmFmtPtr & rpTableFmt,void * pArgs)136cdf0e10cSrcweir sal_Bool lcl_FindTable( const SwFrmFmtPtr& rpTableFmt, void* pArgs )
137cdf0e10cSrcweir {
138cdf0e10cSrcweir     _FindItem * const pItem( static_cast<_FindItem*>(pArgs) );
139cdf0e10cSrcweir 	String sNm( GetAppCharClass().lower( rpTableFmt->GetName() ));
140cdf0e10cSrcweir     if (sNm.Equals( pItem->m_Item ))
141cdf0e10cSrcweir 	{
142cdf0e10cSrcweir 		SwTable* pTmpTbl;
143cdf0e10cSrcweir 		SwTableBox* pFBox;
144cdf0e10cSrcweir 		if( 0 != ( pTmpTbl = SwTable::FindTable( rpTableFmt ) ) &&
145cdf0e10cSrcweir 			0 != ( pFBox = pTmpTbl->GetTabSortBoxes()[0] ) &&
146cdf0e10cSrcweir 			pFBox->GetSttNd() &&
147cdf0e10cSrcweir 			&rpTableFmt->GetDoc()->GetNodes() == &pFBox->GetSttNd()->GetNodes() )
148cdf0e10cSrcweir 		{
149cdf0e10cSrcweir 			// eine Tabelle im normalen NodesArr
150cdf0e10cSrcweir             pItem->pTblNd = (SwTableNode*)
151cdf0e10cSrcweir 										pFBox->GetSttNd()->FindTableNode();
152cdf0e10cSrcweir 			return sal_False;
153cdf0e10cSrcweir 		}
154cdf0e10cSrcweir //nein!		// sollte der Namen schon passen, der Rest aber nicht, dann haben wir
155cdf0e10cSrcweir 		// sie nicht. Die Namen sind immer eindeutig.
156cdf0e10cSrcweir 	}
157cdf0e10cSrcweir 	return sal_True;		// dann weiter
158cdf0e10cSrcweir }
159cdf0e10cSrcweir 
160cdf0e10cSrcweir 
161cdf0e10cSrcweir 
GetData(const String & rItem,const String & rMimeType,uno::Any & rValue) const162cdf0e10cSrcweir bool SwDoc::GetData( const String& rItem, const String& rMimeType,
163cdf0e10cSrcweir                      uno::Any & rValue ) const
164cdf0e10cSrcweir {
165cdf0e10cSrcweir     //search for bookmarks and sections case senstive at first. If nothing is found then try again case insensitive
166cdf0e10cSrcweir     bool bCaseSensitive = true;
167cdf0e10cSrcweir     while( true )
168cdf0e10cSrcweir     {
169cdf0e10cSrcweir         ::sw::mark::DdeBookmark* const pBkmk = lcl_FindDdeBookmark(*pMarkManager, rItem, bCaseSensitive);
170cdf0e10cSrcweir         if(pBkmk)
171cdf0e10cSrcweir             return SwServerObject(*pBkmk).GetData(rValue, rMimeType);
172cdf0e10cSrcweir 
173cdf0e10cSrcweir         // haben wir ueberhaupt das Item vorraetig?
174cdf0e10cSrcweir         String sItem( bCaseSensitive ? rItem : GetAppCharClass().lower(rItem));
175cdf0e10cSrcweir         _FindItem aPara( sItem );
176cdf0e10cSrcweir         ((SwSectionFmts&)*pSectionFmtTbl).ForEach( 0, pSectionFmtTbl->Count(),
177cdf0e10cSrcweir                                                     bCaseSensitive ? lcl_FindSectionCaseSensitive : lcl_FindSectionCaseInsensitive, &aPara );
178cdf0e10cSrcweir         if( aPara.pSectNd )
179cdf0e10cSrcweir         {
180cdf0e10cSrcweir             // gefunden, als erfrage die Daten
181cdf0e10cSrcweir             return SwServerObject( *aPara.pSectNd ).GetData( rValue, rMimeType );
182cdf0e10cSrcweir         }
183cdf0e10cSrcweir         if( !bCaseSensitive )
184cdf0e10cSrcweir             break;
185cdf0e10cSrcweir         bCaseSensitive = false;
186cdf0e10cSrcweir     }
187cdf0e10cSrcweir 
188cdf0e10cSrcweir     _FindItem aPara( GetAppCharClass().lower( rItem ));
189cdf0e10cSrcweir 	((SwFrmFmts*)pTblFrmFmtTbl)->ForEach( 0, pTblFrmFmtTbl->Count(),
190cdf0e10cSrcweir 											lcl_FindTable, &aPara );
191cdf0e10cSrcweir 	if( aPara.pTblNd )
192cdf0e10cSrcweir 	{
193cdf0e10cSrcweir 		return SwServerObject( *aPara.pTblNd ).GetData( rValue, rMimeType );
194cdf0e10cSrcweir 	}
195cdf0e10cSrcweir 
196cdf0e10cSrcweir 	return sal_False;
197cdf0e10cSrcweir }
198cdf0e10cSrcweir 
199cdf0e10cSrcweir 
200cdf0e10cSrcweir 
SetData(const String & rItem,const String & rMimeType,const uno::Any & rValue)201cdf0e10cSrcweir bool SwDoc::SetData( const String& rItem, const String& rMimeType,
202cdf0e10cSrcweir                      const uno::Any & rValue )
203cdf0e10cSrcweir {
204cdf0e10cSrcweir     //search for bookmarks and sections case senstive at first. If nothing is found then try again case insensitive
205cdf0e10cSrcweir     bool bCaseSensitive = true;
206cdf0e10cSrcweir     while( true )
207cdf0e10cSrcweir     {
208cdf0e10cSrcweir         ::sw::mark::DdeBookmark* const pBkmk = lcl_FindDdeBookmark(*pMarkManager, rItem, bCaseSensitive);
209cdf0e10cSrcweir         if(pBkmk)
210cdf0e10cSrcweir             return SwServerObject(*pBkmk).SetData(rMimeType, rValue);
211cdf0e10cSrcweir 
212cdf0e10cSrcweir         // haben wir ueberhaupt das Item vorraetig?
213cdf0e10cSrcweir         String sItem( bCaseSensitive ? rItem : GetAppCharClass().lower(rItem));
214cdf0e10cSrcweir         _FindItem aPara( sItem );
215cdf0e10cSrcweir         pSectionFmtTbl->ForEach( 0, pSectionFmtTbl->Count(), bCaseSensitive ? lcl_FindSectionCaseSensitive : lcl_FindSectionCaseInsensitive, &aPara );
216cdf0e10cSrcweir         if( aPara.pSectNd )
217cdf0e10cSrcweir         {
218cdf0e10cSrcweir             // gefunden, als erfrage die Daten
219cdf0e10cSrcweir             return SwServerObject( *aPara.pSectNd ).SetData( rMimeType, rValue );
220cdf0e10cSrcweir         }
221cdf0e10cSrcweir         if( !bCaseSensitive )
222cdf0e10cSrcweir             break;
223cdf0e10cSrcweir         bCaseSensitive = false;
224cdf0e10cSrcweir     }
225cdf0e10cSrcweir 
226cdf0e10cSrcweir     String sItem(GetAppCharClass().lower(rItem));
227cdf0e10cSrcweir     _FindItem aPara( sItem );
228cdf0e10cSrcweir 	pTblFrmFmtTbl->ForEach( 0, pTblFrmFmtTbl->Count(), lcl_FindTable, &aPara );
229cdf0e10cSrcweir 	if( aPara.pTblNd )
230cdf0e10cSrcweir 	{
231cdf0e10cSrcweir 		return SwServerObject( *aPara.pTblNd ).SetData( rMimeType, rValue );
232cdf0e10cSrcweir 	}
233cdf0e10cSrcweir 
234cdf0e10cSrcweir 	return sal_False;
235cdf0e10cSrcweir }
236cdf0e10cSrcweir 
237cdf0e10cSrcweir 
238cdf0e10cSrcweir 
CreateLinkSource(const String & rItem)239cdf0e10cSrcweir ::sfx2::SvLinkSource* SwDoc::CreateLinkSource(const String& rItem)
240cdf0e10cSrcweir {
241cdf0e10cSrcweir     SwServerObject* pObj = NULL;
242cdf0e10cSrcweir 
243cdf0e10cSrcweir     //search for bookmarks and sections case senstive at first. If nothing is found then try again case insensitive
244cdf0e10cSrcweir     bool bCaseSensitive = true;
245cdf0e10cSrcweir     while( true )
246cdf0e10cSrcweir     {
247cdf0e10cSrcweir         // bookmarks
248cdf0e10cSrcweir         ::sw::mark::DdeBookmark* const pBkmk = lcl_FindDdeBookmark(*pMarkManager, rItem, bCaseSensitive);
249cdf0e10cSrcweir         if(pBkmk && pBkmk->IsExpanded()
250cdf0e10cSrcweir             && (0 == (pObj = pBkmk->GetRefObject())))
251cdf0e10cSrcweir         {
252cdf0e10cSrcweir             // mark found, but no link yet -> create hotlink
253cdf0e10cSrcweir             pObj = new SwServerObject(*pBkmk);
254cdf0e10cSrcweir             pBkmk->SetRefObject(pObj);
255cdf0e10cSrcweir             GetLinkManager().InsertServer(pObj);
256cdf0e10cSrcweir         }
257cdf0e10cSrcweir         if(pObj)
258cdf0e10cSrcweir             return pObj;
259cdf0e10cSrcweir 
260cdf0e10cSrcweir         _FindItem aPara(bCaseSensitive ? rItem : GetAppCharClass().lower(rItem));
261cdf0e10cSrcweir         // sections
262cdf0e10cSrcweir         ((SwSectionFmts&)*pSectionFmtTbl).ForEach(0, pSectionFmtTbl->Count(), bCaseSensitive ? lcl_FindSectionCaseSensitive : lcl_FindSectionCaseInsensitive, &aPara);
263cdf0e10cSrcweir         if(aPara.pSectNd
264cdf0e10cSrcweir             && (0 == (pObj = aPara.pSectNd->GetSection().GetObject())))
265cdf0e10cSrcweir         {
266cdf0e10cSrcweir             // section found, but no link yet -> create hotlink
267cdf0e10cSrcweir             pObj = new SwServerObject( *aPara.pSectNd );
268cdf0e10cSrcweir             aPara.pSectNd->GetSection().SetRefObject( pObj );
269cdf0e10cSrcweir             GetLinkManager().InsertServer(pObj);
270cdf0e10cSrcweir         }
271cdf0e10cSrcweir         if(pObj)
272cdf0e10cSrcweir             return pObj;
273cdf0e10cSrcweir         if( !bCaseSensitive )
274cdf0e10cSrcweir             break;
275cdf0e10cSrcweir         bCaseSensitive = false;
276cdf0e10cSrcweir     }
277cdf0e10cSrcweir 
278cdf0e10cSrcweir     _FindItem aPara( GetAppCharClass().lower(rItem) );
279cdf0e10cSrcweir     // tables
280cdf0e10cSrcweir     ((SwFrmFmts*)pTblFrmFmtTbl)->ForEach(0, pTblFrmFmtTbl->Count(), lcl_FindTable, &aPara);
281cdf0e10cSrcweir     if(aPara.pTblNd
282cdf0e10cSrcweir         && (0 == (pObj = aPara.pTblNd->GetTable().GetObject())))
283cdf0e10cSrcweir     {
284cdf0e10cSrcweir         // table found, but no link yet -> create hotlink
285cdf0e10cSrcweir         pObj = new SwServerObject(*aPara.pTblNd);
286cdf0e10cSrcweir         aPara.pTblNd->GetTable().SetRefObject(pObj);
287cdf0e10cSrcweir         GetLinkManager().InsertServer(pObj);
288cdf0e10cSrcweir     }
289cdf0e10cSrcweir     return pObj;
290cdf0e10cSrcweir }
291cdf0e10cSrcweir 
SelectServerObj(const String & rStr,SwPaM * & rpPam,SwNodeRange * & rpRange) const292cdf0e10cSrcweir sal_Bool SwDoc::SelectServerObj( const String& rStr, SwPaM*& rpPam,
293cdf0e10cSrcweir 							SwNodeRange*& rpRange ) const
294cdf0e10cSrcweir {
295cdf0e10cSrcweir 	// haben wir ueberhaupt das Item vorraetig?
296cdf0e10cSrcweir 	rpPam = 0;
297cdf0e10cSrcweir 	rpRange = 0;
298cdf0e10cSrcweir 
299cdf0e10cSrcweir 	String sItem( INetURLObject::decode( rStr, INET_HEX_ESCAPE,
300cdf0e10cSrcweir 						 				INetURLObject::DECODE_WITH_CHARSET,
301cdf0e10cSrcweir 										RTL_TEXTENCODING_UTF8 ));
302cdf0e10cSrcweir 
303cdf0e10cSrcweir 	xub_StrLen nPos = sItem.Search( cMarkSeperator );
304cdf0e10cSrcweir 
305cdf0e10cSrcweir 	const CharClass& rCC = GetAppCharClass();
306cdf0e10cSrcweir 
307cdf0e10cSrcweir 	// Erweiterung fuer die Bereiche, nicht nur Bookmarks/Bereiche linken,
308cdf0e10cSrcweir 	// sondern auch Rahmen(Text!), Tabellen, Gliederungen:
309cdf0e10cSrcweir 	if( STRING_NOTFOUND != nPos )
310cdf0e10cSrcweir 	{
311cdf0e10cSrcweir 		sal_Bool bWeiter = sal_False;
312cdf0e10cSrcweir 		String sName( sItem.Copy( 0, nPos ) );
313cdf0e10cSrcweir 		String sCmp( sItem.Copy( nPos + 1 ));
314cdf0e10cSrcweir 		rCC.toLower( sItem );
315cdf0e10cSrcweir 
316cdf0e10cSrcweir 		_FindItem aPara( sName );
317cdf0e10cSrcweir 
318cdf0e10cSrcweir 		if( sCmp.EqualsAscii( pMarkToTable ) )
319cdf0e10cSrcweir 		{
320cdf0e10cSrcweir 			rCC.toLower( sName );
321cdf0e10cSrcweir 			((SwFrmFmts*)pTblFrmFmtTbl)->ForEach( 0, pTblFrmFmtTbl->Count(),
322cdf0e10cSrcweir 													lcl_FindTable, &aPara );
323cdf0e10cSrcweir 			if( aPara.pTblNd )
324cdf0e10cSrcweir 			{
325cdf0e10cSrcweir 				rpRange = new SwNodeRange( *aPara.pTblNd, 0,
326cdf0e10cSrcweir 								*aPara.pTblNd->EndOfSectionNode(), 1 );
327cdf0e10cSrcweir 				return sal_True;
328cdf0e10cSrcweir 			}
329cdf0e10cSrcweir 		}
330cdf0e10cSrcweir 		else if( sCmp.EqualsAscii( pMarkToFrame ) )
331cdf0e10cSrcweir 		{
332cdf0e10cSrcweir 			SwNodeIndex* pIdx;
333cdf0e10cSrcweir 			SwNode* pNd;
334cdf0e10cSrcweir 			const SwFlyFrmFmt* pFlyFmt = FindFlyByName( sName );
335cdf0e10cSrcweir 			if( pFlyFmt &&
336cdf0e10cSrcweir 				0 != ( pIdx = (SwNodeIndex*)pFlyFmt->GetCntnt().GetCntntIdx() ) &&
337cdf0e10cSrcweir 				!( pNd = &pIdx->GetNode())->IsNoTxtNode() )
338cdf0e10cSrcweir 			{
339cdf0e10cSrcweir 				rpRange = new SwNodeRange( *pNd, 1, *pNd->EndOfSectionNode() );
340cdf0e10cSrcweir 				return sal_True;
341cdf0e10cSrcweir 			}
342cdf0e10cSrcweir 		}
343cdf0e10cSrcweir 		else if( sCmp.EqualsAscii( pMarkToRegion ) )
344cdf0e10cSrcweir 		{
345cdf0e10cSrcweir 			sItem = sName;				// wird unten behandelt	!
346cdf0e10cSrcweir 			bWeiter = sal_True;
347cdf0e10cSrcweir 		}
348cdf0e10cSrcweir 		else if( sCmp.EqualsAscii( pMarkToOutline ) )
349cdf0e10cSrcweir 		{
350cdf0e10cSrcweir 			SwPosition aPos( SwNodeIndex( (SwNodes&)GetNodes() ));
351cdf0e10cSrcweir 			if( GotoOutline( aPos, sName ))
352cdf0e10cSrcweir 			{
353cdf0e10cSrcweir 				SwNode* pNd = &aPos.nNode.GetNode();
354cdf0e10cSrcweir 				//sal_uInt8 nLvl = pNd->GetTxtNode()->GetTxtColl()->GetOutlineLevel();//#outline level,zhaojianwei
355cdf0e10cSrcweir                 const int nLvl = pNd->GetTxtNode()->GetAttrOutlineLevel()-1;//<-end,zhaojianwei
356cdf0e10cSrcweir 
357cdf0e10cSrcweir 				const SwOutlineNodes& rOutlNds = GetNodes().GetOutLineNds();
358cdf0e10cSrcweir 				sal_uInt16 nTmpPos;
359cdf0e10cSrcweir 				rOutlNds.Seek_Entry( pNd, &nTmpPos );
360cdf0e10cSrcweir 				rpRange = new SwNodeRange( aPos.nNode, 0, aPos.nNode );
361cdf0e10cSrcweir 
362cdf0e10cSrcweir 				// dann suche jetzt noch das Ende vom Bereich
363cdf0e10cSrcweir 				for( ++nTmpPos;
364cdf0e10cSrcweir 						nTmpPos < rOutlNds.Count() &&
365cdf0e10cSrcweir 						nLvl < rOutlNds[ nTmpPos ]->GetTxtNode()->
366cdf0e10cSrcweir 								//GetTxtColl()->GetOutlineLevel();//#outline level,zhaojianwei
367cdf0e10cSrcweir 								GetAttrOutlineLevel()-1;//<-end,zhaojianwei
368cdf0e10cSrcweir 					++nTmpPos )
369cdf0e10cSrcweir 					;		// es gibt keinen Block
370cdf0e10cSrcweir 
371cdf0e10cSrcweir 				if( nTmpPos < rOutlNds.Count() )
372cdf0e10cSrcweir 					rpRange->aEnd = *rOutlNds[ nTmpPos ];
373cdf0e10cSrcweir 				else
374cdf0e10cSrcweir 					rpRange->aEnd = GetNodes().GetEndOfContent();
375cdf0e10cSrcweir 				return sal_True;
376cdf0e10cSrcweir 			}
377cdf0e10cSrcweir 		}
378cdf0e10cSrcweir 
379cdf0e10cSrcweir 		if( !bWeiter )
380cdf0e10cSrcweir 			return sal_False;
381cdf0e10cSrcweir 	}
382cdf0e10cSrcweir 
383cdf0e10cSrcweir     //search for bookmarks and sections case senstive at first. If nothing is found then try again case insensitive
384cdf0e10cSrcweir     bool bCaseSensitive = true;
385cdf0e10cSrcweir     while( true )
386cdf0e10cSrcweir     {
387cdf0e10cSrcweir         ::sw::mark::DdeBookmark* const pBkmk = lcl_FindDdeBookmark(*pMarkManager, sItem, bCaseSensitive);
388cdf0e10cSrcweir         if(pBkmk)
389cdf0e10cSrcweir         {
390cdf0e10cSrcweir             if(pBkmk->IsExpanded())
391cdf0e10cSrcweir                 rpPam = new SwPaM(
392cdf0e10cSrcweir                     pBkmk->GetMarkPos(),
393cdf0e10cSrcweir                     pBkmk->GetOtherMarkPos());
394cdf0e10cSrcweir             return static_cast<bool>(rpPam);
395cdf0e10cSrcweir         }
396cdf0e10cSrcweir 
397cdf0e10cSrcweir         //
398cdf0e10cSrcweir         _FindItem aPara( bCaseSensitive ? sItem : rCC.lower( sItem ) );
399cdf0e10cSrcweir 
400cdf0e10cSrcweir         if( pSectionFmtTbl->Count() )
401cdf0e10cSrcweir         {
402cdf0e10cSrcweir             ((SwSectionFmts&)*pSectionFmtTbl).ForEach( 0, pSectionFmtTbl->Count(),
403cdf0e10cSrcweir                                                     bCaseSensitive ? lcl_FindSectionCaseSensitive : lcl_FindSectionCaseInsensitive, &aPara );
404cdf0e10cSrcweir             if( aPara.pSectNd )
405cdf0e10cSrcweir             {
406cdf0e10cSrcweir                 rpRange = new SwNodeRange( *aPara.pSectNd, 1,
407cdf0e10cSrcweir                                         *aPara.pSectNd->EndOfSectionNode() );
408cdf0e10cSrcweir                 return sal_True;
409cdf0e10cSrcweir 
410cdf0e10cSrcweir             }
411cdf0e10cSrcweir         }
412cdf0e10cSrcweir         if( !bCaseSensitive )
413cdf0e10cSrcweir             break;
414cdf0e10cSrcweir         bCaseSensitive = false;
415cdf0e10cSrcweir     }
416cdf0e10cSrcweir 	return sal_False;
417cdf0e10cSrcweir }
418cdf0e10cSrcweir 
419