1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fltini.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
33 #define _SVSTDARR_STRINGS
36 #include <stdio.h> // sscanf
37 #include <hintids.hxx>
38 #include <i18npool/lang.h>
39 #include <i18npool/mslangid.hxx>
40 #include <vcl/msgbox.hxx>
41 #include <svtools/parhtml.hxx>
42 #include <svtools/svstdarr.hxx>
43 #include <sot/storage.hxx>
44 #include <sot/clsids.hxx>
45 #include <sfx2/app.hxx>
46 #include <sfx2/docfilt.hxx>
47 #include <sfx2/fcontnr.hxx>
48 #include <sfx2/docfile.hxx>
49 #include <svx/lrspitem.hxx>
50 #include <svx/tstpitem.hxx>
54 #include <shellio.hxx>
61 #include <fmtfsize.hxx>
62 #include <swtable.hxx>
63 #include <fmtcntnt.hxx>
64 #include <svx/boxitem.hxx>
67 #include <numrule.hxx>
69 #include <swfltopt.hxx>
71 #include <osl/module.hxx>
75 using namespace com::sun::star::uno
;
77 SwRead ReadAscii
= 0, /*ReadSwg = 0, ReadSw3 = 0,*/
78 ReadHTML
= 0, ReadXML
= 0;
80 Reader
* GetRTFReader();
81 Reader
* GetWW8Reader();
83 // Note: if editing, please don't forget to modify also the enum
84 // ReaderWriterEnum and aFilterDetect in shellio.hxx
85 SwReaderWriterEntry aReaderWriter
[] =
87 SwReaderWriterEntry( &::GetRTFReader
, &::GetRTFWriter
, TRUE
),
88 SwReaderWriterEntry( 0, &::GetASCWriter
, FALSE
),
89 SwReaderWriterEntry( &::GetWW8Reader
, &::GetWW8Writer
, TRUE
),
90 SwReaderWriterEntry( &::GetWW8Reader
, &::GetWW8Writer
, TRUE
),
91 SwReaderWriterEntry( &::GetRTFReader
, &::GetRTFWriter
, TRUE
),
92 SwReaderWriterEntry( 0, &::GetHTMLWriter
, TRUE
),
93 SwReaderWriterEntry( 0, 0, TRUE
),
94 SwReaderWriterEntry( &::GetWW8Reader
, 0, TRUE
),
95 SwReaderWriterEntry( 0, &::GetXMLWriter
, TRUE
),
96 SwReaderWriterEntry( 0, &::GetASCWriter
, TRUE
),
97 SwReaderWriterEntry( 0, &::GetASCWriter
, TRUE
)
100 Reader
* SwReaderWriterEntry::GetReader()
104 else if ( fnGetReader
)
106 pReader
= (*fnGetReader
)();
112 void SwReaderWriterEntry::GetWriter( const String
& rNm
, const String
& rBaseURL
, WriterRef
& xWrt
) const
115 (*fnGetWriter
)( rNm
, rBaseURL
, xWrt
);
120 /*SwRead SwGetReaderSw3() // SW_DLLPUBLIC
125 SwRead
SwGetReaderXML() // SW_DLLPUBLIC
130 bool IsDocShellRegistered()
132 return 0 != SwDocShell::_GetInterface();
135 inline void _SetFltPtr( USHORT rPos
, SwRead pReader
)
137 aReaderWriter
[ rPos
].pReader
= pReader
;
142 _SetFltPtr( READER_WRITER_BAS
, (ReadAscii
= new AsciiReader
) );
143 _SetFltPtr( READER_WRITER_HTML
, (ReadHTML
= new HTMLReader
) );
144 _SetFltPtr( READER_WRITER_WW1
, new WW1Reader
);
145 _SetFltPtr( READER_WRITER_XML
, (ReadXML
= new XMLReader
) );
147 #ifdef NEW_WW97_EXPORT
148 aReaderWriter
[ READER_WRITER_WW1
].fnGetWriter
= &::GetWW8Writer
;
149 aReaderWriter
[ READER_WRITER_WW5
].fnGetWriter
= &::GetWW8Writer
;
152 _SetFltPtr( READER_WRITER_TEXT_DLG
, ReadAscii
);
153 _SetFltPtr( READER_WRITER_TEXT
, ReadAscii
);
158 // die Reader vernichten
159 for( USHORT n
= 0; n
< MAXFILTER
; ++n
)
161 SwReaderWriterEntry
& rEntry
= aReaderWriter
[n
];
162 if( rEntry
.bDelReader
&& rEntry
.pReader
)
163 delete rEntry
.pReader
, rEntry
.pReader
= NULL
;
170 namespace SwReaderWriter
{
172 Reader
* GetReader( ReaderWriterEnum eReader
)
174 return aReaderWriter
[eReader
].GetReader();
177 void GetWriter( const String
& rFltName
, const String
& rBaseURL
, WriterRef
& xRet
)
179 for( USHORT n
= 0; n
< MAXFILTER
; ++n
)
180 if( aFilterDetect
[n
].IsFilter( rFltName
) )
182 aReaderWriter
[n
].GetWriter( rFltName
, rBaseURL
, xRet
);
187 SwRead
GetReader( const String
& rFltName
)
190 for( USHORT n
= 0; n
< MAXFILTER
; ++n
)
191 if( aFilterDetect
[n
].IsFilter( rFltName
) )
193 pRead
= aReaderWriter
[n
].GetReader();
194 // fuer einige Reader noch eine Sonderbehandlung:
196 pRead
->SetFltName( rFltName
);
202 } // namespace SwReaderWriter
206 /////////////// die Storage Reader/Writer ////////////////////////////////
208 /*void GetSw3Writer( const String&, const String& rBaseURL, WriterRef& xRet )
210 DBG_ERROR( "Shouldn't happen!");
211 xRet = new Sw3Writer;
215 ULONG
StgReader::OpenMainStream( SvStorageStreamRef
& rRef
, USHORT
& rBuffSize
)
217 ULONG nRet
= ERR_SWG_READ_ERROR
;
218 ASSERT( pStg
, "wo ist mein Storage?" );
219 const SfxFilter
* pFltr
= SwIoSystem::GetFilterOfFormat( aFltName
);
222 rRef
= pStg
->OpenSotStream( SwIoSystem::GetSubStorageName( *pFltr
),
223 STREAM_READ
| STREAM_SHARE_DENYALL
);
227 if( SVSTREAM_OK
== rRef
->GetError() )
229 USHORT nOld
= rRef
->GetBufferSize();
230 rRef
->SetBufferSize( rBuffSize
);
235 nRet
= rRef
->GetError();
243 ULONG Sw3Reader::Read( SwDoc &rDoc, SwPaM &rPam, const String & )
248 // TRUE: Vorlagen ueberschreiben
249 pIO->SetReadOptions( aOpt,TRUE );
252 // Im Laden-Modus darf der PaM-Content-Teil nicht
253 // in den Textbereich zeigen (Nodes koennen geloescht werden)
254 rPam.GetBound( TRUE ).nContent.Assign( 0, 0 );
255 rPam.GetBound( FALSE ).nContent.Assign( 0, 0 );
257 nRet = pIO->Load( pStg, bInsertMode ? &rPam : 0 );
258 aOpt.ResetAllFmtsOnly();
259 pIO->SetReadOptions( aOpt, TRUE );
263 ASSERT( !this, "Sw3-Read ohne Storage und/oder IO-System" );
264 nRet = ERR_SWG_READ_ERROR;
269 // read the sections of the document, which is equal to the medium.
270 // returns the count of it
271 USHORT Sw3Reader::GetSectionList( SfxMedium& rMedium,
272 SvStrings& rStrings ) const
274 SvStorageRef aStg( rMedium.GetStorage() );
275 const SfxFilter* pFlt = rMedium.GetFilter();
276 ASSERT( pFlt && pFlt->GetVersion(),
277 "Kein Filter oder Filter ohne FF-Version" );
278 if( pFlt && pFlt->GetVersion() )
279 aStg->SetVersion( (long)pFlt->GetVersion() );
282 pIO->GetSectionList( &aStg, rStrings );
283 return rStrings.Count();
288 /*ULONG Sw3Writer::WriteStorage()
293 // der gleiche Storage -> Save, sonst SaveAs aufrufen
295 nRet = pIO->Save( pOrigPam, bWriteAll );
297 nRet = pIO->SaveAs( pStg, pOrigPam, bWriteAll );
299 pIO = 0; // nach dem Schreiben ist der Pointer ungueltig !!
303 ASSERT( !this, "Sw3-Writer ohne IO-System" )
304 nRet = ERR_SWG_WRITE_ERROR;
309 ULONG Sw3Writer::WriteMedium( SfxMedium& )
311 DBG_ERROR( "Shouldn't be used currently!");
312 return WriteStorage();
315 BOOL Sw3Writer::IsSw3Writer() const { return TRUE; }
318 void Writer::SetPasswd( const String
& ) {}
321 void Writer::SetVersion( const String
&, long ) {}
324 BOOL
Writer::IsStgWriter() const { return FALSE
; }
325 //BOOL Writer::IsSw3Writer() const { return FALSE; }
327 BOOL
StgWriter::IsStgWriter() const { return TRUE
; }
333 BOOL
SwReader::NeedsPasswd( const Reader
& /*rOptions*/ )
340 BOOL
SwReader::CheckPasswd( const String
& /*rPasswd*/, const Reader
& /*rOptions*/ )
348 //-----------------------------------------------------------------------
349 // Filter Flags lesen, wird von WW8 / W4W / EXCEL / LOTUS benutzt.
350 //-----------------------------------------------------------------------
355 <MinRow cfg:type="long">0</MinRow>
356 <MaxRow cfg:type="long">0</MaxRow>
357 <MinCol cfg:type="long">0</MinCol>
358 <MaxCol cfg:type="long">0</MaxCol>
361 <W4WHD cfg:type="long">0</W4WHD>
362 <W4WFT cfg:type="long">0</W4WFT>
363 <W4W000 cfg:type="long">0</W4W000>
366 <WW1F cfg:type="long">0</WW1F>
367 <WW cfg:type="long">0</WW>
368 <WW8 cfg:type="long">0</WW8>
369 <WWF cfg:type="long">0</WWF>
370 <WWFA0 cfg:type="long">0</WWFA0>
371 <WWFA1 cfg:type="long">0</WWFA1>
372 <WWFA2 cfg:type="long">0</WWFA2>
373 <WWFB0 cfg:type="long">0</WWFB0>
374 <WWFB1 cfg:type="long">0</WWFB1>
375 <WWFB2 cfg:type="long">0</WWFB2>
376 <WWFLX cfg:type="long">0</WWFLX>
377 <WWFLY cfg:type="long">0</WWFLY>
378 <WWFT cfg:type="long">0</WWFT>
379 <WWWR cfg:type="long">0</WWWR>
382 <SW3Imp cfg:type="long">0</SW3Imp>
387 #define FILTER_OPTION_ROOT String::CreateFromAscii( \
388 RTL_CONSTASCII_STRINGPARAM( "Office.Writer/FilterFlags" ) )
390 SwFilterOptions::SwFilterOptions( sal_uInt16 nCnt
, const sal_Char
** ppNames
,
391 sal_uInt32
* pValues
)
392 : ConfigItem( FILTER_OPTION_ROOT
)
394 GetValues( nCnt
, ppNames
, pValues
);
397 void SwFilterOptions::GetValues( sal_uInt16 nCnt
, const sal_Char
** ppNames
,
398 sal_uInt32
* pValues
)
400 Sequence
<OUString
> aNames( nCnt
);
401 OUString
* pNames
= aNames
.getArray();
404 for( n
= 0; n
< nCnt
; ++n
)
405 pNames
[ n
] = OUString::createFromAscii( ppNames
[ n
] );
406 Sequence
<Any
> aValues
= GetProperties( aNames
);
408 if( nCnt
== aValues
.getLength() )
410 const Any
* pAnyValues
= aValues
.getConstArray();
411 for( n
= 0; n
< nCnt
; ++n
)
412 pValues
[ n
] = pAnyValues
[ n
].hasValue()
413 ? *(sal_uInt32
*)pAnyValues
[ n
].getValue()
417 for( n
= 0; n
< nCnt
; ++n
)
424 void StgReader::SetFltName( const String
& rFltNm
)
426 if( SW_STORAGE_READER
& GetReaderType() )
433 SwRelNumRuleSpaces::SwRelNumRuleSpaces( SwDoc
& rDoc
, BOOL bNDoc
)
436 pNumRuleTbl
= new SwNumRuleTbl( 8, 8 );
438 pNumRuleTbl
->Insert( &rDoc
.GetNumRuleTbl(), 0 );
441 SwRelNumRuleSpaces::~SwRelNumRuleSpaces()
445 pNumRuleTbl
->Remove( 0, pNumRuleTbl
->Count() );
450 void SwRelNumRuleSpaces::SetNumRelSpaces( SwDoc
& rDoc
)
452 const SwNumRuleTbl
* pRuleTbl
= NULL
;
456 // jetzt alle schon vorhanden NumRules aus dem Array entfernen,
457 // damit nur die neuen angepasst werden
458 SwNumRuleTbl aNumRuleTbl
;
459 aNumRuleTbl
.Insert( pNumRuleTbl
, 0 );
460 pNumRuleTbl
->Remove( 0, pNumRuleTbl
->Count() );
461 const SwNumRuleTbl
& rRuleTbl
= rDoc
.GetNumRuleTbl();
464 for( USHORT n
= 0; n
< rRuleTbl
.Count(); ++n
)
465 if( USHRT_MAX
== aNumRuleTbl
.GetPos( ( pRule
= rRuleTbl
[ n
] )))
466 // war noch nicht vorhanden, also neu
467 pNumRuleTbl
->Insert( pRule
, pNumRuleTbl
->Count() );
469 aNumRuleTbl
.Remove( 0, aNumRuleTbl
.Count() );
471 pRuleTbl
= pNumRuleTbl
;
475 pRuleTbl
= &rDoc
.GetNumRuleTbl();
480 for( USHORT n
= pRuleTbl
->Count(); n
; )
482 SwNumRule
* pRule
= (*pRuleTbl
)[ --n
];
483 // Rule noch gueltig und am Doc vorhanden?
484 if( USHRT_MAX
!= rDoc
.GetNumRuleTbl().GetPos( pRule
))
486 // --> OD 2008-02-19 #refactorlists#
487 // SwNumRuleInfo aUpd( pRule->GetName() );
488 // aUpd.MakeList( rDoc );
490 // // bei allen nmumerierten Absaetzen vom linken Rand
491 // // den absoluten Wert des NumFormates abziehen
492 // for( ULONG nUpdPos = 0; nUpdPos < aUpd.GetList().Count();
495 // SwTxtNode* pNd = aUpd.GetList().GetObject( nUpdPos );
496 // SetNumLSpace( *pNd, *pRule );
498 SwNumRule::tTxtNodeList aTxtNodeList
;
499 pRule
->GetTxtNodeList( aTxtNodeList
);
500 for ( SwNumRule::tTxtNodeList::iterator aIter
= aTxtNodeList
.begin();
501 aIter
!= aTxtNodeList
.end(); ++aIter
)
503 SwTxtNode
* pNd
= *aIter
;
504 SetNumLSpace( *pNd
, *pRule
);
513 pNumRuleTbl
->Remove( 0, pNumRuleTbl
->Count() );
514 delete pNumRuleTbl
, pNumRuleTbl
= 0;
519 SetOultineRelSpaces( SwNodeIndex( rDoc
.GetNodes() ),
520 SwNodeIndex( rDoc
.GetNodes().GetEndOfContent()));
524 void SwRelNumRuleSpaces::SetOultineRelSpaces( const SwNodeIndex
& rStt
,
525 const SwNodeIndex
& rEnd
)
527 SwDoc
* pDoc
= rStt
.GetNode().GetDoc();
528 const SwOutlineNodes
& rOutlNds
= pDoc
->GetNodes().GetOutLineNds();
529 if( rOutlNds
.Count() )
532 rOutlNds
.Seek_Entry( &rStt
.GetNode(), &nPos
);
533 for( ; nPos
< rOutlNds
.Count() &&
534 rOutlNds
[ nPos
]->GetIndex() < rEnd
.GetIndex(); ++nPos
)
536 SwTxtNode
* pNd
= rOutlNds
[ nPos
]->GetTxtNode();
537 if( pNd
->IsOutline() && !pNd
->GetNumRule() )
538 SetNumLSpace( *pNd
, *pDoc
->GetOutlineNumRule() );
543 void SwRelNumRuleSpaces::SetNumLSpace( SwTxtNode
& rNd
, const SwNumRule
& rRule
)
545 BOOL bOutlineRule
= OUTLINE_RULE
== rRule
.GetRuleType();
546 // --> OD 2005-11-18 #128056#
547 // correction of refactoring done by cws swnumtree:
548 // - assure a correct level for retrieving numbering format.
549 // BYTE nLvl = rNd.GetLevel();
551 if ( rNd
.GetActualListLevel() >= 0 && rNd
.GetActualListLevel() < MAXLEVEL
)
553 nLvl
= static_cast< BYTE
>(rNd
.GetActualListLevel());
556 const SwNumFmt
& rFmt
= rRule
.Get( nLvl
);
557 const SvxLRSpaceItem
& rLR
= rNd
.GetSwAttrSet().GetLRSpace();
559 SvxLRSpaceItem
aLR( rLR
);
560 aLR
.SetTxtFirstLineOfst( 0 );
562 // sagt der Node, das die Numerierung den Wert vorgibt?
563 if( !bOutlineRule
&& rNd
.IsSetNumLSpace() )
567 long nLeft
= rFmt
.GetAbsLSpace(), nParaLeft
= rLR
.GetTxtLeft();
568 if( 0 < rLR
.GetTxtFirstLineOfst() )
569 nParaLeft
+= rLR
.GetTxtFirstLineOfst();
570 else if( nParaLeft
>= nLeft
)
571 // #82963#/#82962#: set correct paragraph indent
574 //#83154#, Don't think any of the older #80856# bugfix code is
576 nParaLeft
= rLR
.GetTxtLeft()+rLR
.GetTxtFirstLineOfst();
577 aLR
.SetTxtLeft( nParaLeft
);
580 if( aLR
.GetTxtLeft() != rLR
.GetTxtLeft() )
582 //bevor rLR geloescht wird!
583 long nOffset
= rLR
.GetTxtLeft() - aLR
.GetTxtLeft();
587 const SfxPoolItem
* pItem
;
588 if( SFX_ITEM_SET
== rNd
.GetSwAttrSet().GetItemState(
589 RES_PARATR_TABSTOP
, TRUE
, &pItem
))
591 SvxTabStopItem
aTStop( *(SvxTabStopItem
*)pItem
);
592 for( USHORT n
= 0; n
< aTStop
.Count(); ++n
)
594 SvxTabStop
& rTab
= (SvxTabStop
&)aTStop
[ n
];
595 if( SVX_TAB_ADJUST_DEFAULT
!= rTab
.GetAdjustment() )
597 if( !rTab
.GetTabPos() )
603 rTab
.GetTabPos() += nOffset
;
606 rNd
.SetAttr( aTStop
);
614 void CalculateFlySize(SfxItemSet
& rFlySet
, const SwNodeIndex
& rAnchor
,
617 const SfxPoolItem
* pItem
= 0;
618 if( SFX_ITEM_SET
!= rFlySet
.GetItemState( RES_FRM_SIZE
, TRUE
, &pItem
) ||
619 MINFLY
> ((SwFmtFrmSize
*)pItem
)->GetWidth() )
621 SwFmtFrmSize
aSz((SwFmtFrmSize
&)rFlySet
.Get(RES_FRM_SIZE
, TRUE
));
623 aSz
= (SwFmtFrmSize
&)(*pItem
);
626 // dann die Breite des Flys selbst bestimmen. Ist eine Tabelle
627 // defininiert, dann benutze deren Breite, sonst die Breite der
629 const SwTableNode
* pTblNd
= rAnchor
.GetNode().FindTableNode();
631 nWidth
= pTblNd
->GetTable().GetFrmFmt()->GetFrmSize().GetWidth();
635 const SwNodeIndex
* pSttNd
= ((SwFmtCntnt
&)rFlySet
.Get( RES_CNTNT
)).
639 BOOL bOnlyOneNode
= TRUE
;
642 SwTxtNode
* pFirstTxtNd
= 0;
643 SwNodeIndex
aIdx( *pSttNd
, 1 );
644 SwNodeIndex
aEnd( *pSttNd
->GetNode().EndOfSectionNode() );
647 SwTxtNode
*pTxtNd
= aIdx
.GetNode().GetTxtNode();
651 pFirstTxtNd
= pTxtNd
;
652 else if( pFirstTxtNd
!= pTxtNd
)
655 bOnlyOneNode
= FALSE
;
660 pTxtNd
->GetMinMaxSize( aIdx
.GetIndex(), nMinFrm
,
661 nMaxFrm
, nAbsMinCnts
);
668 if( nMinFrm
< MINLAY
&& pFirstTxtNd
)
670 // if the first node dont contained any content, then
671 // insert one char in it calc again and delete once again
672 SwIndex
aNdIdx( pFirstTxtNd
);
673 pFirstTxtNd
->Insert( String::CreateFromAscii(
674 RTL_CONSTASCII_STRINGPARAM( "MM" )), aNdIdx
);
676 pFirstTxtNd
->GetMinMaxSize( pFirstTxtNd
->GetIndex(),
677 nMinFrm
, nMaxFrm
, nAbsMinCnts
);
679 pFirstTxtNd
->Erase( aNdIdx
, 2 );
682 // Umrandung und Abstand zum Inhalt beachten
683 const SvxBoxItem
& rBoxItem
= (SvxBoxItem
&)rFlySet
.Get( RES_BOX
);
684 USHORT nLine
= BOX_LINE_LEFT
;
685 for( int i
= 0; i
< 2; ++i
)
687 const SvxBorderLine
* pLn
= rBoxItem
.GetLine( nLine
);
690 USHORT nWidthTmp
= pLn
->GetOutWidth() + pLn
->GetInWidth();
691 nWidthTmp
= nWidthTmp
+ rBoxItem
.GetDistance( nLine
);
692 nMinFrm
+= nWidthTmp
;
693 nMaxFrm
+= nWidthTmp
;
695 nLine
= BOX_LINE_RIGHT
;
698 // Mindestbreite fuer Inhalt einhalten
699 if( nMinFrm
< MINLAY
)
701 if( nMaxFrm
< MINLAY
)
704 if( nWidth
> (USHORT
)nMaxFrm
)
706 else if( nWidth
> (USHORT
)nMinFrm
)
711 if( MINFLY
> nWidth
)
714 aSz
.SetWidth( nWidth
);
715 if( MINFLY
> aSz
.GetHeight() )
716 aSz
.SetHeight( MINFLY
);
719 else if( MINFLY
> ((SwFmtFrmSize
*)pItem
)->GetHeight() )
721 SwFmtFrmSize
aSz( *(SwFmtFrmSize
*)pItem
);
722 aSz
.SetHeight( MINFLY
);
728 struct CharSetNameMap
730 rtl_TextEncoding eCode
;
731 const sal_Char
* pName
;
734 const CharSetNameMap
*GetCharSetNameMap()
736 static const CharSetNameMap aMapArr
[] =
738 # define IMPLENTRY(X) { RTL_TEXTENCODING_##X, "" #X "" }
741 IMPLENTRY(APPLE_ROMAN
),
750 IMPLENTRY(ISO_8859_1
),
751 IMPLENTRY(ISO_8859_2
),
752 IMPLENTRY(ISO_8859_3
),
753 IMPLENTRY(ISO_8859_4
),
754 IMPLENTRY(ISO_8859_5
),
755 IMPLENTRY(ISO_8859_6
),
756 IMPLENTRY(ISO_8859_7
),
757 IMPLENTRY(ISO_8859_8
),
758 IMPLENTRY(ISO_8859_9
),
759 IMPLENTRY(ISO_8859_14
),
760 IMPLENTRY(ISO_8859_15
),
779 IMPLENTRY(APPLE_ARABIC
),
780 IMPLENTRY(APPLE_CENTEURO
),
781 IMPLENTRY(APPLE_CROATIAN
),
782 IMPLENTRY(APPLE_CYRILLIC
),
783 IMPLENTRY(APPLE_DEVANAGARI
),
784 IMPLENTRY(APPLE_FARSI
),
785 IMPLENTRY(APPLE_GREEK
),
786 IMPLENTRY(APPLE_GUJARATI
),
787 IMPLENTRY(APPLE_GURMUKHI
),
788 IMPLENTRY(APPLE_HEBREW
),
789 IMPLENTRY(APPLE_ICELAND
),
790 IMPLENTRY(APPLE_ROMANIAN
),
791 IMPLENTRY(APPLE_THAI
),
792 IMPLENTRY(APPLE_TURKISH
),
793 IMPLENTRY(APPLE_UKRAINIAN
),
794 IMPLENTRY(APPLE_CHINSIMP
),
795 IMPLENTRY(APPLE_CHINTRAD
),
796 IMPLENTRY(APPLE_JAPANESE
),
797 IMPLENTRY(APPLE_KOREAN
),
802 IMPLENTRY(SHIFT_JIS
),
804 IMPLENTRY(GBT_12345
),
810 IMPLENTRY(ISO_2022_JP
),
811 IMPLENTRY(ISO_2022_CN
),
816 IMPLENTRY(ISO_8859_10
),
817 IMPLENTRY(ISO_8859_13
),
819 IMPLENTRY(ISO_2022_KR
),
820 IMPLENTRY(JIS_X_0201
),
821 IMPLENTRY(JIS_X_0208
),
822 IMPLENTRY(JIS_X_0212
),
825 IMPLENTRY(BIG5_HKSCS
),
836 Get a rtl_TextEncoding from its name
838 rtl_TextEncoding
CharSetFromName(const String
& rChrSetStr
)
840 const CharSetNameMap
*pStart
= GetCharSetNameMap();
841 rtl_TextEncoding nRet
= pStart
->eCode
;
843 for(const CharSetNameMap
*pMap
= pStart
; pMap
->pName
; ++pMap
)
845 if(rChrSetStr
.EqualsIgnoreCaseAscii(pMap
->pName
))
852 ASSERT(nRet
!= pStart
->eCode
, "TXT: That was an unknown language!");
859 Get the String name of an rtl_TextEncoding
861 String
NameFromCharSet(rtl_TextEncoding nChrSet
)
863 const CharSetNameMap
*pStart
= GetCharSetNameMap();
864 const char *pRet
= pStart
->pName
;
866 for(const CharSetNameMap
*pMap
= pStart
; pMap
->pName
; ++pMap
)
868 if (nChrSet
== pMap
->eCode
)
875 ASSERT(pRet
!= pStart
->pName
, "TXT: That was an unknown language!");
877 return String::CreateFromAscii(pRet
);
880 // for the automatic conversion (mail/news/...)
881 // The user data contains the options for the ascii import/export filter.
883 // 1. CharSet - as ascii chars
884 // 2. LineEnd - as CR/LR/CRLF
887 // the delimetercharacter is ","
890 void SwAsciiOptions::ReadUserData( const String
& rStr
)
892 xub_StrLen nToken
= 0;
896 if( 0 != (sToken
= rStr
.GetToken( 0, ',', nToken
)).Len() )
901 eCharSet
= CharSetFromName(sToken
);
904 if( sToken
.EqualsIgnoreCaseAscii( "CRLF" ))
905 eCRLF_Flag
= LINEEND_CRLF
;
906 else if( sToken
.EqualsIgnoreCaseAscii( "LF" ))
907 eCRLF_Flag
= LINEEND_LF
;
909 eCRLF_Flag
= LINEEND_CR
;
915 nLanguage
= MsLangId::convertIsoStringToLanguage( sToken
);
920 } while( STRING_NOTFOUND
!= nToken
);
923 void SwAsciiOptions::WriteUserData( String
& rStr
)
926 rStr
= NameFromCharSet(eCharSet
);
933 rStr
.AppendAscii( "CRLF" );
936 rStr
.AppendAscii( "CR" );
939 rStr
.AppendAscii( "LF" );
951 rtl::OUString sTmp
= MsLangId::convertLanguageToIsoString( nLanguage
);
952 rStr
+= (String
)sTmp
;
957 extern "C" { static void SAL_CALL
thisModule() {} }
959 static oslGenericFunction
GetMswordLibSymbol( const char *pSymbol
)
961 static ::osl::Module aModule
;
963 aModule
.loadRelative( &thisModule
,
964 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SVLIBRARY( "msword" ) ) ) ) )
966 return aModule
.getFunctionSymbol( ::rtl::OUString::createFromAscii( pSymbol
) );
972 Reader
* GetRTFReader()
974 FnGetReader pFunction
= reinterpret_cast<FnGetReader
>( GetMswordLibSymbol( "ImportRTF" ) );
977 return (*pFunction
)();
982 void GetRTFWriter( const String
& rFltName
, const String
& rBaseURL
, WriterRef
& xRet
)
984 FnGetWriter pFunction
= reinterpret_cast<FnGetWriter
>( GetMswordLibSymbol( "ExportRTF" ) );
987 (*pFunction
)( rFltName
, rBaseURL
, xRet
);
992 Reader
* GetWW8Reader()
994 FnGetReader pFunction
= reinterpret_cast<FnGetReader
>( GetMswordLibSymbol( "ImportDOC" ) );
997 return (*pFunction
)();
1002 void GetWW8Writer( const String
& rFltName
, const String
& rBaseURL
, WriterRef
& xRet
)
1004 FnGetWriter pFunction
= reinterpret_cast<FnGetWriter
>( GetMswordLibSymbol( "ExportDOC" ) );
1007 (*pFunction
)( rFltName
, rBaseURL
, xRet
);
1009 xRet
= WriterRef(0);