summaryrefslogtreecommitdiff
path: root/sw/source/filter/writer/writer.cxx
blob: 88661c4c645102d5f6fea1da6176ca99c59b1dc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
/*************************************************************************
 *
 *  $RCSfile: writer.cxx,v $
 *
 *  $Revision: 1.5 $
 *
 *  last change: $Author: mib $ $Date: 2000-11-20 11:15:52 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

#ifdef PRECOMPILED
#include "filt_pch.hxx"
#endif

#pragma hdrstop

#ifndef _HINTIDS_HXX
#include <hintids.hxx>
#endif

#define _SVSTDARR_STRINGSSORTDTOR
#include <svtools/svstdarr.hxx>

#ifndef _STREAM_HXX //autogen
#include <tools/stream.hxx>
#endif
#ifndef _SFXDOCFILE_HXX //autogen
#include <sfx2/docfile.hxx>
#endif
#ifndef SVTOOLS_URIHELPER_HXX
#include <svtools/urihelper.hxx>
#endif
#ifndef _FILTER_HXX //autogen
#include <svtools/filter.hxx>
#endif
#ifndef _SVX_IMPGRF_HXX //autogen
#include <svx/impgrf.hxx>
#endif
#ifndef _SVX_FONTITEM_HXX //autogen
#include <svx/fontitem.hxx>
#endif
#ifndef _EEITEM_HXX
#include <svx/eeitem.hxx>
#endif

#ifndef _SHELLIO_HXX
#include <shellio.hxx>
#endif
#ifndef _PAM_HXX
#include <pam.hxx>
#endif
#ifndef _DOC_HXX
#include <doc.hxx>
#endif
#ifndef _DOCARY_HXX
#include <docary.hxx>
#endif
#ifndef _NODE_HXX
#include <node.hxx>
#endif
#ifndef _FORMAT_HXX
#include <format.hxx>
#endif
#ifndef _BOOKMRK_HXX
#include <bookmrk.hxx>          // fuer SwBookmark ...
#endif
#ifndef _NUMRULE_HXX //autogen
#include <numrule.hxx>
#endif

#ifndef _SWSWERROR_H
#include <swerror.h>
#endif

// Stringbuffer fuer die umgewandelten Zahlen
static sal_Char aNToABuf[] = "0000000000000000000000000";
#define NTOABUFLEN (sizeof(aNToABuf))

DECLARE_TABLE( SwBookmarkNodeTable, SvPtrarr* )

struct Writer_Impl
{
    SvStringsSortDtor *pSrcArr, *pDestArr;
    SvPtrarr* pFontRemoveLst, *pBkmkArr;
    SwBookmarkNodeTable* pBkmkNodePos;

    Writer_Impl( const SwDoc& rDoc );
    ~Writer_Impl();

    void RemoveFontList( SwDoc& rDoc );
    void InsertBkmk( const SwBookmark& rBkmk );
};

Writer_Impl::Writer_Impl( const SwDoc& rDoc )
    : pSrcArr( 0 ), pDestArr( 0 ), pFontRemoveLst( 0 ), pBkmkNodePos( 0 )
{
}

Writer_Impl::~Writer_Impl()
{
    delete pSrcArr;
    delete pDestArr;
    delete pFontRemoveLst;

    if( pBkmkNodePos )
    {
        for( SvPtrarr* p = pBkmkNodePos->First(); p; p = pBkmkNodePos->Next() )
            delete p;
        delete pBkmkNodePos;
    }
}

void Writer_Impl::RemoveFontList( SwDoc& rDoc )
{
    ASSERT( pFontRemoveLst, "wo ist die FontListe?" );
    for( USHORT i = pFontRemoveLst->Count(); i; )
    {
        SvxFontItem* pItem = (SvxFontItem*)(*pFontRemoveLst)[ --i ];
        rDoc.GetAttrPool().Remove( *pItem );
    }
}

void Writer_Impl::InsertBkmk( const SwBookmark& rBkmk )
{
    if( !pBkmkNodePos )
        pBkmkNodePos = new SwBookmarkNodeTable;

    ULONG nNd = rBkmk.GetPos().nNode.GetIndex();
    SvPtrarr* pArr = pBkmkNodePos->Get( nNd );
    if( !pArr )
    {
        pArr = new SvPtrarr( 1, 4 );
        pBkmkNodePos->Insert( nNd, pArr );
    }

    void* p = (void*)&rBkmk;
    pArr->Insert( p, pArr->Count() );

    if( rBkmk.GetOtherPos() && rBkmk.GetOtherPos()->nNode != nNd )
    {
        nNd = rBkmk.GetOtherPos()->nNode.GetIndex();
        pArr = pBkmkNodePos->Get( nNd );
        if( !pArr )
        {
            pArr = new SvPtrarr( 1, 4 );
            pBkmkNodePos->Insert( nNd, pArr );
        }
        pArr->Insert( p, pArr->Count() );
    }
}

/*
 * Dieses Modul ist die Zentrale-Sammelstelle fuer alle Write-Filter
 * und ist eine DLL !
 *
 * Damit der Writer mit den unterschiedlichen Writern arbeiten kann,
 * muessen fuer diese die Ausgabe-Funktionen der Inhalts tragenden
 * Objecte auf die verschiedenen Ausgabe-Funktionen gemappt werden.
 *
 * Dazu kann fuer jedes Object ueber den Which-Wert in einen Tabelle ge-
 * griffen werden, um seine Ausgabe-Funktion zu erfragen.
 * Diese Funktionen stehen in den entsprechenden Writer-DLL's.
 */

Writer::Writer()
    : pImpl( 0 ), pStrm( 0 ), pOrigPam( 0 ), pOrigFileName( 0 ),
    pCurPam(0), pDoc( 0 )
{
    bWriteAll = bShowProgress = bUCS2_WithStartChar = TRUE;
    bASCII_NoLastLineEnd = bASCII_ParaAsBlanc = bASCII_ParaAsCR =
        bWriteClipboardDoc = bWriteOnlyFirstTable = FALSE;
}

Writer::~Writer()
{
}

void Writer::ResetWriter()
{
    if( pImpl && pImpl->pFontRemoveLst )
        pImpl->RemoveFontList( *pDoc );
    delete pImpl, pImpl = 0;

    if( pCurPam )
    {
        while( pCurPam->GetNext() != pCurPam )
            delete pCurPam->GetNext();
        delete pCurPam;
    }
    pCurPam = 0;
    pOrigFileName = 0;
    pDoc = 0;
    pStrm = 0;

    bShowProgress = bUCS2_WithStartChar = TRUE;
    bASCII_NoLastLineEnd = bASCII_ParaAsBlanc = bASCII_ParaAsCR =
        bWriteClipboardDoc = bWriteOnlyFirstTable = FALSE;
}

BOOL Writer::CopyNextPam( SwPaM ** ppPam )
{
    if( (*ppPam)->GetNext() == pOrigPam )
    {
        *ppPam = pOrigPam;          // wieder auf den Anfangs-Pam setzen
        return FALSE;               // Ende vom Ring
    }

    // ansonsten kopiere den die Werte aus dem naechsten Pam
    *ppPam = ((SwPaM*)(*ppPam)->GetNext() );

    *pCurPam->GetPoint() = *(*ppPam)->Start();
    *pCurPam->GetMark() = *(*ppPam)->End();

    return TRUE;
}

// suche die naechste Bookmark-Position aus der Bookmark-Tabelle

USHORT Writer::FindPos_Bkmk( const SwPosition& rPos ) const
{
    USHORT nRet = USHRT_MAX;
    const SwBookmarks& rBkmks = pDoc->GetBookmarks();

    if( rBkmks.Count() )
    {
        SwBookmark aBkmk( rPos );
        USHORT nPos;
        if( rBkmks.Seek_Entry( &aBkmk, &nPos ))
        {
            // suche abwaerts nach weiteren Bookmarks auf der Cursor-Position
            while( 0 < nPos &&
                rBkmks[ nPos-1 ]->IsEqualPos( aBkmk ))
                --nPos;
        }
        else if( nPos < rBkmks.Count() )
            nRet = nPos;
    }
    return nRet;
}


SwPaM* Writer::NewSwPaM( SwDoc & rDoc, ULONG nStartIdx, ULONG nEndIdx,
                        BOOL bNodesArray ) const
{
    SwNodes* pNds = bNodesArray ? &rDoc.GetNodes() : (SwNodes*)rDoc.GetUndoNds();

    SwNodeIndex aStt( *pNds, nStartIdx );
    SwCntntNode* pCNode = aStt.GetNode().GetCntntNode();
    if( !pCNode && 0 == ( pCNode = pNds->GoNext( &aStt )) )
        ASSERT( !this, "An StartPos kein ContentNode mehr" );

    SwPaM* pNew = new SwPaM( aStt );
    pNew->SetMark();
    aStt = nEndIdx;
    if( 0 == (pCNode = aStt.GetNode().GetCntntNode()) &&
        0 == (pCNode = pNds->GoPrevious( &aStt )) )
        ASSERT( !this, "An StartPos kein ContentNode mehr" );
    pCNode->MakeEndIndex( &pNew->GetPoint()->nContent );
    pNew->GetPoint()->nNode = aStt;
    return pNew;
}

/////////////////////////////////////////////////////////////////////////////

// Stream-spezifisches
#ifndef PRODUCT
SvStream& Writer::Strm()
{
    ASSERT( pStrm, "Oh-oh. Dies ist ein Storage-Writer. Gleich knallts!" );
    return *pStrm;
}
#endif


SvStream& Writer::OutHex( SvStream& rStrm, ULONG nHex, BYTE nLen )
{                                                  // in einen Stream aus
    // Pointer an das Bufferende setzen
    sal_Char* pStr = aNToABuf + (NTOABUFLEN-1);
    for( BYTE n = 0; n < nLen; ++n )
    {
        *(--pStr) = (sal_Char)(nHex & 0xf ) + 48;
        if( *pStr > '9' )
            *pStr += 39;
        nHex >>= 4;
    }
    return rStrm << pStr;
}

SvStream& Writer::OutLong( SvStream& rStrm, long nVal )
{
    // Pointer an das Bufferende setzen
    sal_Char* pStr = aNToABuf + (NTOABUFLEN-1);

    int bNeg = nVal < 0;
    if( bNeg )
        nVal = -nVal;

    do {
        *(--pStr) = (sal_Char)(nVal % 10 ) + 48;
        nVal /= 10;
    } while( nVal );

    // Ist Zahl negativ, dann noch -
    if( bNeg )
        *(--pStr) = '-';

    return rStrm << pStr;
}

SvStream& Writer::OutULong( SvStream& rStrm, ULONG nVal )
{
    // Pointer an das Bufferende setzen
    sal_Char* pStr = aNToABuf + (NTOABUFLEN-1);

    do {
        *(--pStr) = (sal_Char)(nVal % 10 ) + 48;
        nVal /= 10;
    } while ( nVal );
    return rStrm << pStr;
}


ULONG Writer::Write( SwPaM& rPaM, SvStream& rStrm, const String* pFName )
{
    pStrm = &rStrm;
    pDoc = rPaM.GetDoc();
    pOrigFileName = pFName;
    pImpl = new Writer_Impl( *pDoc );

    // PaM kopieren, damit er veraendert werden kann
    pCurPam = new SwPaM( *rPaM.End(), *rPaM.Start() );
    // zum Vergleich auf den akt. Pam sichern
    pOrigPam = &rPaM;

    ULONG nRet = WriteStream();

    ResetWriter();

    return nRet;
}

ULONG Writer::Write( SwPaM& rPam, SfxMedium& rMed, const String* pFileName )
{
    return IsStgWriter()
                ? Write( rPam, *rMed.GetStorage(), pFileName )
                : Write( rPam, *rMed.GetOutStream(), pFileName );
}

ULONG Writer::Write( SwPaM& rPam, SvStorage&, const String* )
{
    ASSERT( !this, "Schreiben in Storages auf einem Stream?" );
    return ERR_SWG_WRITE_ERROR;
}


BOOL Writer::CopyLocalFileToINet( String& rFileNm )
{
    BOOL bRet = FALSE;
    INetURLObject aFileUrl( rFileNm ), aTargetUrl( *pOrigFileName );

// JP 01.11.00: what is the correct question for the portal??
//  if( aFileUrl.GetProtocol() == aFileUrl.GetProtocol() )
//      return bRet;
// this is our old without the Mail-Export
    if( ! ( INET_PROT_FILE == aFileUrl.GetProtocol() &&
            INET_PROT_FILE != aTargetUrl.GetProtocol() &&
            INET_PROT_FTP <= aTargetUrl.GetProtocol() &&
            INET_PROT_NEWS >= aTargetUrl.GetProtocol() ) )
        return bRet;

    if( pImpl->pSrcArr )
    {
        // wurde die Datei schon verschoben
        USHORT nPos;
        if( pImpl->pSrcArr->Seek_Entry( &rFileNm, &nPos ))
        {
            rFileNm = *(*pImpl->pDestArr)[ nPos ];
            return TRUE;
        }
    }
    else
    {
        pImpl->pSrcArr = new SvStringsSortDtor( 4, 4 );
        pImpl->pDestArr = new SvStringsSortDtor( 4, 4 );
    }

    String *pSrc = new String( rFileNm );
    String *pDest = new String( aTargetUrl.GetPartBeforeLastName() );
    *pDest += aFileUrl.GetName();

    SfxMedium aSrcFile( *pSrc, STREAM_READ, FALSE );
    SfxMedium aDstFile( *pDest, STREAM_WRITE | STREAM_SHARE_DENYNONE, FALSE );

    *aDstFile.GetOutStream() << *aSrcFile.GetInStream();

    aSrcFile.Close();
    aDstFile.Commit();

    bRet = 0 == aDstFile.GetError();

    if( bRet )
    {
        pImpl->pSrcArr->Insert( pSrc );
        pImpl->pDestArr->Insert( pDest );
        rFileNm = *pDest;
    }
    else
    {
        delete pSrc;
        delete pDest;
    }

    return bRet;
}

void Writer::PutNumFmtFontsInAttrPool()
{
    if( !pImpl )
        pImpl = new Writer_Impl( *pDoc );

    // dann gibt es noch in den NumRules ein paar Fonts
    // Diese in den Pool putten. Haben sie danach einen RefCount > 1
    // kann es wieder entfernt werden - ist schon im Pool
    SfxItemPool& rPool = pDoc->GetAttrPool();
    const SwNumRuleTbl& rListTbl = pDoc->GetNumRuleTbl();
    const SwNumRule* pRule;
    const SwNumFmt* pFmt;
    const Font *pFont, *pDefFont = &SwNumRule::GetDefBulletFont();
    BOOL bCheck = FALSE;

    for( USHORT nGet = rListTbl.Count(); nGet; )
        if( pDoc->IsUsed( *(pRule = rListTbl[ --nGet ] )))
            for( BYTE nLvl = 0; nLvl < MAXLEVEL; ++nLvl )
                if( SVX_NUM_CHAR_SPECIAL == (pFmt = &pRule->Get( nLvl ))->eType ||
                    SVX_NUM_BITMAP == pFmt->eType )
                {
                    if( 0 == ( pFont = pFmt->GetBulletFont() ) )
                        pFont = pDefFont;

                    if( bCheck )
                    {
                        if( *pFont == *pDefFont )
                            continue;
                    }
                    else if( *pFont == *pDefFont )
                        bCheck = TRUE;

                    _AddFontItem( rPool, SvxFontItem( pFont->GetFamily(),
                                pFont->GetName(), pFont->GetStyleName(),
                                pFont->GetPitch(), pFont->GetCharSet() ));
                }
}

void Writer::PutEditEngFontsInAttrPool( BOOL bIncl_CJK_CTL )
{
    if( !pImpl )
        pImpl = new Writer_Impl( *pDoc );

    SfxItemPool* pPool = pDoc->GetAttrPool().GetSecondaryPool();
    if( pPool )
    {
        _AddFontItems( *pPool, EE_CHAR_FONTINFO );
        if( bIncl_CJK_CTL )
        {
            _AddFontItems( *pPool, EE_CHAR_FONTINFO_CJK );
            _AddFontItems( *pPool, EE_CHAR_FONTINFO_CTL );
        }
    }
}

void Writer::PutCJKandCTLFontsInAttrPool()
{
    if( !pImpl )
        pImpl = new Writer_Impl( *pDoc );

    SfxItemPool& rPool = pDoc->GetAttrPool();
    _AddFontItems( rPool, RES_CHRATR_CJK_FONT );
    _AddFontItems( rPool, RES_CHRATR_CTL_FONT );
}


void Writer::_AddFontItems( SfxItemPool& rPool, USHORT nW )
{
    const SvxFontItem* pFont = (const SvxFontItem*)&rPool.GetDefaultItem( nW );
    _AddFontItem( rPool, *pFont );

    if( 0 != ( pFont = (const SvxFontItem*)rPool.GetPoolDefaultItem( nW )) )
        _AddFontItem( rPool, *pFont );

    USHORT nMaxItem = rPool.GetItemCount( nW );
    for( USHORT nGet = 0; nGet < nMaxItem; ++nGet )
        if( 0 != (pFont = (const SvxFontItem*)rPool.GetItem( nW, nGet )) )
            _AddFontItem( rPool, *pFont );
}

void Writer::_AddFontItem( SfxItemPool& rPool, const SvxFontItem& rFont )
{
    const SvxFontItem* pItem;
    if( RES_CHRATR_FONT != rFont.Which() )
    {
        SvxFontItem aFont( rFont );
        aFont.SetWhich( RES_CHRATR_FONT );
        pItem = (SvxFontItem*)&rPool.Put( aFont );
    }
    else
        pItem = (SvxFontItem*)&rPool.Put( rFont );

    if( 1 < pItem->GetRef() )
        rPool.Remove( *pItem );
    else
    {
        if( !pImpl->pFontRemoveLst )
            pImpl->pFontRemoveLst = new SvPtrarr( 0, 10 );

        void* p = (void*)pItem;
        pImpl->pFontRemoveLst->Insert( p, pImpl->pFontRemoveLst->Count() );
    }
}

// build a bookmark table, which is sort by the node position. The
// OtherPos of the bookmarks also inserted.
void Writer::CreateBookmarkTbl()
{
    const SwBookmarks& rBkmks = pDoc->GetBookmarks();
    for( USHORT n = rBkmks.Count(); n; )
    {
        const SwBookmark& rBkmk = *rBkmks[ --n ];
        if( rBkmk.IsBookMark() )
            pImpl->InsertBkmk( rBkmk );
    }
}


// search alle Bookmarks in the range and return it in the Array
USHORT Writer::GetBookmarks( const SwCntntNode& rNd, xub_StrLen nStt,
                             xub_StrLen nEnd, SvPtrarr& rArr )
{
    ASSERT( !rArr.Count(), "es sind noch Eintraege vorhanden" );

    ULONG nNd = rNd.GetIndex();
    SvPtrarr* pArr = pImpl->pBkmkNodePos ? pImpl->pBkmkNodePos->Get( nNd ) : 0;
    if( pArr )
    {
        // there exist some bookmarks, search now all which is in the range
        if( !nStt && nEnd == rNd.Len() )
            // all
            rArr.Insert( pArr, 0 );
        else
        {
            USHORT n;
            xub_StrLen nCntnt;
            for( n = 0; n < pArr->Count(); ++n )
            {
                void* p = (*pArr)[ n ];
                const SwBookmark& rBkmk = *(SwBookmark*)p;
                if( rBkmk.GetPos().nNode == nNd &&
                    (nCntnt = rBkmk.GetPos().nContent.GetIndex() ) >= nStt &&
                    nCntnt < nEnd )
                {
                    rArr.Insert( p, rArr.Count() );
                }
                else if( rBkmk.GetOtherPos() && nNd ==
                        rBkmk.GetOtherPos()->nNode.GetIndex() && (nCntnt =
                        rBkmk.GetOtherPos()->nContent.GetIndex() ) >= nStt &&
                        nCntnt < nEnd )
                {
                    rArr.Insert( p, rArr.Count() );
                }
            }
        }
    }
    return rArr.Count();
}

////////////////////////////////////////////////////////////////////////////

// Storage-spezifisches

ULONG StgWriter::WriteStream()
{
    ASSERT( !this, "Schreiben in Streams auf einem Storage?" );
    return ERR_SWG_WRITE_ERROR;
}

ULONG StgWriter::Write( SwPaM& rPaM, SvStorage& rStg, const String* pFName )
{
    pStrm = 0;
    pStg = &rStg;
    pDoc = rPaM.GetDoc();
    pOrigFileName = pFName;
    pImpl = new Writer_Impl( *pDoc );

    // PaM kopieren, damit er veraendert werden kann
    pCurPam = new SwPaM( *rPaM.End(), *rPaM.Start() );
    // zum Vergleich auf den akt. Pam sichern
    pOrigPam = &rPaM;

    ULONG nRet = WriteStorage();

    pStg = NULL;
    ResetWriter();

    return nRet;
}

/*************************************************************************

      Source Code Control System - Header

      $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/sw/source/filter/writer/writer.cxx,v 1.5 2000-11-20 11:15:52 mib Exp $

      Source Code Control System - Update

      $Log: not supported by cvs2svn $
      Revision 1.4  2000/11/13 17:26:24  jp
      new method PutCJKandCTLFontsInAttrPool

      Revision 1.3  2000/11/01 19:31:51  jp
      Writer:CopyLocalFileToINet: export of mail graphics removed and SvFileStream access removed

      Revision 1.2  2000/10/17 15:13:50  os
      Change: SfxMedium Ctor

      Revision 1.1.1.1  2000/09/18 17:14:57  hr
      initial import

      Revision 1.103  2000/09/18 16:04:55  willem.vandorp
      OpenOffice header added.

      Revision 1.102  2000/08/04 16:25:50  jp
      read/write unicode ascii files

      Revision 1.101  2000/06/26 13:01:26  os
      INetURLObject::SmartRelToAbs removed

      Revision 1.100  2000/06/13 09:43:46  os
      using UCB

      Revision 1.99  2000/05/08 16:51:53  jp
      Changes for Unicode

      Revision 1.98  1999/10/13 10:38:29  jp
      PutEditEngFontsInAtrPool - check if the editenginepool exist

      Revision 1.97  1999/10/12 20:04:37  jp
      Writer: put EditEngine fonts into the writer pool

      Revision 1.96  1999/08/12 10:19:56  MIB
      Don\'t delete impl if it hasn\'t been set (for XML filter)


      Rev 1.95   12 Aug 1999 12:19:56   MIB
   Don't delete impl if it hasn't been set (for XML filter)

      Rev 1.94   30 Jun 1999 18:53:20   JP
   dtor for impl class

      Rev 1.93   24 Jun 1999 22:51:34   JP
   new: Writer with internal Impl-structur, build Bookmark table sortet by nodes

      Rev 1.92   23 Jun 1999 19:13:40   JP
   interface of Writer::FindPos_Bkmk has changed

      Rev 1.91   16 Jun 1999 19:52:14   JP
   Change interface of base class Writer

      Rev 1.90   28 Jan 1999 14:21:28   JP
   GraphicFilter-SS hat sich geaendert - Task #59174#

      Rev 1.89   30 Oct 1998 18:30:02   JP
   Task #58596#: neues Flag an der Writerklasse -> schreibe nur die 1. Tabelle

      Rev 1.88   27 Jun 1998 16:02:08   JP
   Writer mit neuen Flags; fuer den ASCII-Writer, etwas aufgeraeumt

      Rev 1.87   23 Apr 1998 19:07:44   MIB
   fix #49729#: Stream beim kopieren von Grafiken ins INet schliessen

      Rev 1.86   22 Jan 1998 20:02:56   JP
   CTOR des SwPaM umgestellt

      Rev 1.85   26 Nov 1997 14:29:14   MA
   headerfiles

      Rev 1.84   03 Nov 1997 14:12:48   MA
   precomp entfernt

      Rev 1.83   13 Oct 1997 16:06:34   JP
   pNext vom Ring wurde privat; zugriff ueber GetNext()

      Rev 1.82   09 Oct 1997 14:26:24   JP
   Umstellung NodeIndex/-Array/BigPtrArray

      Rev 1.81   03 Sep 1997 11:59:44   JP
   zusaetzliches include von docary

*************************************************************************/