LCOV - code coverage report
Current view: top level - libreoffice/sw/source/filter/basflt - fltini.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 169 257 65.8 %
Date: 2012-12-27 Functions: 23 38 60.5 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <string.h>
      21             : #include <stdio.h>                      // sscanf
      22             : #include <hintids.hxx>
      23             : #include <i18npool/lang.h>
      24             : #include <i18npool/languagetag.hxx>
      25             : #include <vcl/msgbox.hxx>
      26             : #include <svtools/parhtml.hxx>
      27             : #include <sot/storage.hxx>
      28             : #include <sot/clsids.hxx>
      29             : #include <sfx2/app.hxx>
      30             : #include <sfx2/docfilt.hxx>
      31             : #include <sfx2/fcontnr.hxx>
      32             : #include <sfx2/docfile.hxx>
      33             : #include <editeng/lrspitem.hxx>
      34             : #include <editeng/tstpitem.hxx>
      35             : #include <doc.hxx>
      36             : #include <docary.hxx>
      37             : #include <pam.hxx>
      38             : #include <shellio.hxx>
      39             : #include <docsh.hxx>
      40             : #include <wdocsh.hxx>
      41             : #include <fltini.hxx>
      42             : #include <hints.hxx>
      43             : #include <init.hxx>
      44             : #include <frmatr.hxx>
      45             : #include <fmtfsize.hxx>
      46             : #include <swtable.hxx>
      47             : #include <fmtcntnt.hxx>
      48             : #include <editeng/boxitem.hxx>
      49             : #include <frmfmt.hxx>
      50             : #include <numrule.hxx>
      51             : #include <ndtxt.hxx>
      52             : #include <swfltopt.hxx>
      53             : #include <swerror.h>
      54             : #include <osl/module.hxx>
      55             : #include <comphelper/processfactory.hxx>
      56             : #include <comphelper/componentcontext.hxx>
      57             : #include <com/sun/star/beans/XPropertySet.hpp>
      58             : #include <com/sun/star/util/XMacroExpander.hpp>
      59             : #include <rtl/uri.hxx>
      60             : 
      61             : using namespace utl;
      62             : using rtl::OUString;
      63             : using namespace com::sun::star::uno;
      64             : using namespace com::sun::star;
      65             : 
      66             : SwRead ReadAscii = 0, ReadHTML = 0, ReadXML = 0;
      67             : 
      68             : Reader* GetRTFReader();
      69             : Reader* GetWW8Reader();
      70             : 
      71             : // Note: if editing, please don't forget to modify also the enum
      72             : // ReaderWriterEnum and aFilterDetect in shellio.hxx
      73             : SwReaderWriterEntry aReaderWriter[] =
      74             : {
      75             :     SwReaderWriterEntry( &::GetRTFReader, &::GetRTFWriter,  sal_True  ),
      76             :     SwReaderWriterEntry( 0,               &::GetASCWriter,  sal_False ),
      77             :     SwReaderWriterEntry( &::GetWW8Reader, &::GetWW8Writer,  sal_True  ),
      78             :     SwReaderWriterEntry( &::GetWW8Reader, &::GetWW8Writer,  sal_True  ),
      79             :     SwReaderWriterEntry( &::GetRTFReader, &::GetRTFWriter,  sal_True  ),
      80             :     SwReaderWriterEntry( 0,               &::GetHTMLWriter, sal_True  ),
      81             :     SwReaderWriterEntry( 0,               0,                sal_True  ),
      82             :     SwReaderWriterEntry( &::GetWW8Reader, 0,                sal_True  ),
      83             :     SwReaderWriterEntry( 0,               &::GetXMLWriter,  sal_True  ),
      84             :     SwReaderWriterEntry( 0,               &::GetASCWriter,  sal_False ),
      85             :     SwReaderWriterEntry( 0,               &::GetASCWriter,  sal_True  )
      86          10 : };
      87             : 
      88          37 : Reader* SwReaderWriterEntry::GetReader()
      89             : {
      90          37 :     if ( pReader )
      91          34 :         return pReader;
      92           3 :     else if ( fnGetReader )
      93             :     {
      94           3 :         pReader = (*fnGetReader)();
      95           3 :         return pReader;
      96             :     }
      97           0 :     return NULL;
      98             : }
      99             : 
     100          21 : void SwReaderWriterEntry::GetWriter( const String& rNm, const String& rBaseURL, WriterRef& xWrt ) const
     101             : {
     102          21 :     if ( fnGetWriter )
     103          21 :         (*fnGetWriter)( rNm, rBaseURL, xWrt );
     104             :     else
     105           0 :         xWrt = WriterRef(0);
     106          21 : }
     107             : 
     108           0 : SwRead SwGetReaderXML() // SW_DLLPUBLIC
     109             : {
     110           0 :         return ReadXML;
     111             : }
     112             : 
     113          60 : inline void _SetFltPtr( sal_uInt16 rPos, SwRead pReader )
     114             : {
     115          60 :         aReaderWriter[ rPos ].pReader = pReader;
     116          60 : }
     117             : 
     118             : namespace {
     119             : 
     120             : #ifndef DISABLE_DYNLOADING
     121             : 
     122           0 : extern "C" { static void SAL_CALL thisModule() {} }
     123             : 
     124             : #endif
     125             : 
     126             : }
     127             : 
     128             : namespace sw {
     129             : 
     130          10 : Filters::Filters()
     131             : {
     132          10 :     _SetFltPtr( READER_WRITER_BAS, (ReadAscii = new AsciiReader) );
     133          10 :     _SetFltPtr( READER_WRITER_HTML, (ReadHTML = new HTMLReader) );
     134          10 :     _SetFltPtr( READER_WRITER_WW1, new WW1Reader );
     135          10 :     _SetFltPtr( READER_WRITER_XML, (ReadXML = new XMLReader)  );
     136          10 :     _SetFltPtr( READER_WRITER_TEXT_DLG, ReadAscii );
     137          10 :     _SetFltPtr( READER_WRITER_TEXT, ReadAscii );
     138          10 : }
     139             : 
     140          20 : Filters::~Filters()
     141             : {
     142             :     // die Reader vernichten
     143         120 :     for( sal_uInt16 n = 0; n < MAXFILTER; ++n )
     144             :     {
     145         110 :         SwReaderWriterEntry& rEntry = aReaderWriter[n];
     146         110 :         if( rEntry.bDelReader && rEntry.pReader )
     147          43 :             delete rEntry.pReader, rEntry.pReader = NULL;
     148             :     }
     149          10 : }
     150             : 
     151             : #ifndef DISABLE_DYNLOADING
     152             : 
     153           3 : oslGenericFunction Filters::GetMswordLibSymbol( const char *pSymbol )
     154             : {
     155           3 :     if (!msword_.is())
     156             :     {
     157           3 :         bool ok = msword_.loadRelative( &thisModule, SVLIBRARY( "msword" ), SAL_LOADMODULE_GLOBAL | SAL_LOADMODULE_LAZY );
     158             :         SAL_WARN_IF(!ok, "sw", "failed to load msword library");
     159             :     }
     160           3 :     if (msword_.is())
     161           3 :         return msword_.getFunctionSymbol( ::rtl::OUString::createFromAscii( pSymbol ) );
     162           0 :     return NULL;
     163             : }
     164             : 
     165             : #endif
     166             : 
     167             : }
     168             : 
     169             : namespace SwReaderWriter {
     170             : 
     171           0 : Reader* GetReader( ReaderWriterEnum eReader )
     172             : {
     173           0 :     return aReaderWriter[eReader].GetReader();
     174             : }
     175             : 
     176          21 : void GetWriter( const String& rFltName, const String& rBaseURL, WriterRef& xRet )
     177             : {
     178         211 :         for( sal_uInt16 n = 0; n < MAXFILTER; ++n )
     179         211 :                 if( aFilterDetect[n].IsFilter( rFltName ) )
     180             :                 {
     181          21 :             aReaderWriter[n].GetWriter( rFltName, rBaseURL, xRet );
     182          21 :                         break;
     183             :                 }
     184          21 : }
     185             : 
     186          37 : SwRead GetReader( const String& rFltName )
     187             : {
     188          37 :         SwRead pRead = 0;
     189         166 :         for( sal_uInt16 n = 0; n < MAXFILTER; ++n )
     190         166 :                 if( aFilterDetect[n].IsFilter( rFltName ) )
     191             :                 {
     192          37 :                         pRead = aReaderWriter[n].GetReader();
     193             :                         // fuer einige Reader noch eine Sonderbehandlung:
     194          37 :                         if ( pRead )
     195          37 :                                 pRead->SetFltName( rFltName );
     196          37 :                         break;
     197             :                 }
     198          37 :         return pRead;
     199             : }
     200             : 
     201             : } // namespace SwReaderWriter
     202             : 
     203           0 : void Writer::SetPasswd( const String& ) {}
     204             : 
     205             : 
     206           0 : void Writer::SetVersion( const String&, long ) {}
     207             : 
     208             : 
     209          22 : sal_Bool Writer::IsStgWriter() const { return sal_False; }
     210             : 
     211           2 : sal_Bool StgWriter::IsStgWriter() const { return sal_True; }
     212             : 
     213             : 
     214             : 
     215             : 
     216          37 : sal_Bool SwReader::NeedsPasswd( const Reader& /*rOptions*/ )
     217             : {
     218          37 :     return sal_False;
     219             : }
     220             : 
     221             : 
     222           0 : sal_Bool SwReader::CheckPasswd( const String& /*rPasswd*/, const Reader& /*rOptions*/ )
     223             : {
     224           0 :     return sal_True;
     225             : }
     226             : 
     227             : 
     228             : 
     229             : //-----------------------------------------------------------------------
     230             : // Filter Flags lesen, wird von WW8 / W4W / EXCEL / LOTUS benutzt.
     231             : //-----------------------------------------------------------------------
     232             : 
     233             : /*
     234             : <FilterFlags>
     235             :         <Excel_Lotus>
     236             :                 <MinRow cfg:type="long">0</MinRow>
     237             :                 <MaxRow cfg:type="long">0</MaxRow>
     238             :                 <MinCol cfg:type="long">0</MinCol>
     239             :                 <MaxCol cfg:type="long">0</MaxCol>
     240             :         </Excel_Lotus>
     241             :         <W4W>
     242             :                 <W4WHD cfg:type="long">0</W4WHD>
     243             :                 <W4WFT cfg:type="long">0</W4WFT>
     244             :                 <W4W000 cfg:type="long">0</W4W000>
     245             :         </W4W>
     246             :         <WinWord>
     247             :                 <WW1F cfg:type="long">0</WW1F>
     248             :                 <WW cfg:type="long">0</WW>
     249             :                 <WW8 cfg:type="long">0</WW8>
     250             :                 <WWF cfg:type="long">0</WWF>
     251             :                 <WWFA0 cfg:type="long">0</WWFA0>
     252             :                 <WWFA1 cfg:type="long">0</WWFA1>
     253             :                 <WWFA2 cfg:type="long">0</WWFA2>
     254             :                 <WWFB0 cfg:type="long">0</WWFB0>
     255             :                 <WWFB1 cfg:type="long">0</WWFB1>
     256             :                 <WWFB2 cfg:type="long">0</WWFB2>
     257             :                 <WWFLX cfg:type="long">0</WWFLX>
     258             :                 <WWFLY cfg:type="long">0</WWFLY>
     259             :                 <WWFT cfg:type="long">0</WWFT>
     260             :                 <WWWR cfg:type="long">0</WWWR>
     261             :         </WinWord>
     262             :         <Writer>
     263             :                 <SW3Imp cfg:type="long">0</SW3Imp>
     264             :         </Writer>
     265             : </FilterFlags>
     266             : */
     267             : 
     268             : #define FILTER_OPTION_ROOT      rtl::OUString("Office.Writer/FilterFlags")
     269             : 
     270          33 : SwFilterOptions::SwFilterOptions( sal_uInt16 nCnt, const sal_Char** ppNames,
     271             :                                                                 sal_uInt32* pValues )
     272          33 :         : ConfigItem( FILTER_OPTION_ROOT )
     273             : {
     274          33 :         GetValues( nCnt, ppNames, pValues );
     275          33 : }
     276             : 
     277          33 : void SwFilterOptions::GetValues( sal_uInt16 nCnt, const sal_Char** ppNames,
     278             :                                                                         sal_uInt32* pValues )
     279             : {
     280          33 :         Sequence<OUString> aNames( nCnt );
     281          33 :         OUString* pNames = aNames.getArray();
     282             :         sal_uInt16 n;
     283             : 
     284         462 :         for( n = 0; n < nCnt; ++n )
     285         429 :                 pNames[ n ] = OUString::createFromAscii( ppNames[ n ] );
     286          33 :         Sequence<Any> aValues = GetProperties( aNames );
     287             : 
     288          33 :         if( nCnt == aValues.getLength() )
     289             :         {
     290          33 :                 const Any* pAnyValues = aValues.getConstArray();
     291         462 :                 for( n = 0; n < nCnt; ++n )
     292         429 :                         pValues[ n ] = pAnyValues[ n ].hasValue()
     293         429 :                                                         ? *(sal_uInt32*)pAnyValues[ n ].getValue()
     294         858 :                                                         : 0;
     295             :         }
     296             :         else
     297           0 :                 for( n = 0; n < nCnt; ++n )
     298          33 :                         pValues[ n ] = 0;
     299          33 : }
     300             : 
     301           0 : void SwFilterOptions::Commit() {}
     302           0 : void SwFilterOptions::Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& ) {}
     303             : 
     304             : 
     305             : 
     306          34 : void StgReader::SetFltName( const String& rFltNm )
     307             : {
     308          34 :         if( SW_STORAGE_READER & GetReaderType() )
     309          34 :                 aFltName = rFltNm;
     310          34 : }
     311             : 
     312             : 
     313             : 
     314          31 : SwRelNumRuleSpaces::SwRelNumRuleSpaces( SwDoc& rDoc, sal_Bool bNDoc )
     315             : {
     316          31 :         pNumRuleTbl = new SwNumRuleTbl();
     317          31 :         pNumRuleTbl->reserve(8);
     318          31 :         if( !bNDoc )
     319             :                 pNumRuleTbl->insert( pNumRuleTbl->begin(),
     320           0 :                     rDoc.GetNumRuleTbl().begin(), rDoc.GetNumRuleTbl().end() );
     321          31 : }
     322             : 
     323          31 : SwRelNumRuleSpaces::~SwRelNumRuleSpaces()
     324             : {
     325          31 :         if( pNumRuleTbl )
     326             :         {
     327          31 :                 pNumRuleTbl->clear();
     328          31 :                 delete pNumRuleTbl;
     329             :         }
     330          31 : }
     331             : 
     332           4 : void CalculateFlySize(SfxItemSet& rFlySet, const SwNodeIndex& rAnchor,
     333             :         SwTwips nPageWidth)
     334             : {
     335           4 :         const SfxPoolItem* pItem = 0;
     336           4 :         if( SFX_ITEM_SET != rFlySet.GetItemState( RES_FRM_SIZE, sal_True, &pItem ) ||
     337           0 :                 MINFLY > ((SwFmtFrmSize*)pItem)->GetWidth() )
     338             :         {
     339           4 :                 SwFmtFrmSize aSz((SwFmtFrmSize&)rFlySet.Get(RES_FRM_SIZE, sal_True));
     340           4 :                 if (pItem)
     341           0 :                         aSz = (SwFmtFrmSize&)(*pItem);
     342             : 
     343             :                 SwTwips nWidth;
     344             :                 // dann die Breite des Flys selbst bestimmen. Ist eine Tabelle
     345             :                 // defininiert, dann benutze deren Breite, sonst die Breite der
     346             :                 // Seite
     347           4 :                 const SwTableNode* pTblNd = rAnchor.GetNode().FindTableNode();
     348           4 :                 if( pTblNd )
     349           0 :                         nWidth = pTblNd->GetTable().GetFrmFmt()->GetFrmSize().GetWidth();
     350             :                 else
     351           4 :                         nWidth = nPageWidth;
     352             : 
     353           4 :                 const SwNodeIndex* pSttNd = ((SwFmtCntnt&)rFlySet.Get( RES_CNTNT )).
     354           4 :                                                                         GetCntntIdx();
     355           4 :                 if( pSttNd )
     356             :                 {
     357           4 :                         bool bOnlyOneNode = true;
     358           4 :                         sal_uLong nMinFrm = 0;
     359           4 :                         sal_uLong nMaxFrm = 0;
     360           4 :                         SwTxtNode* pFirstTxtNd = 0;
     361           4 :                         SwNodeIndex aIdx( *pSttNd, 1 );
     362           4 :                         SwNodeIndex aEnd( *pSttNd->GetNode().EndOfSectionNode() );
     363          16 :                         while( aIdx < aEnd )
     364             :                         {
     365           9 :                                 SwTxtNode *pTxtNd = aIdx.GetNode().GetTxtNode();
     366           9 :                                 if( pTxtNd )
     367             :                                 {
     368           5 :                                         if( !pFirstTxtNd )
     369           4 :                                                 pFirstTxtNd = pTxtNd;
     370           1 :                                         else if( pFirstTxtNd != pTxtNd )
     371             :                                         {
     372             :                                                 // forget it
     373           1 :                                                 bOnlyOneNode = false;
     374             :                                                 break;
     375             :                                         }
     376             : 
     377             :                                         sal_uLong nAbsMinCnts;
     378             :                                         pTxtNd->GetMinMaxSize( aIdx.GetIndex(), nMinFrm,
     379           4 :                                                                                         nMaxFrm, nAbsMinCnts );
     380             :                                 }
     381           8 :                                 ++aIdx;
     382             :                         }
     383             : 
     384           4 :                         if( bOnlyOneNode )
     385             :                         {
     386           3 :                                 if( nMinFrm < MINLAY && pFirstTxtNd )
     387             :                                 {
     388             :                                         // if the first node dont contained any content, then
     389             :                                         // insert one char in it calc again and delete once again
     390           3 :                                         SwIndex aNdIdx( pFirstTxtNd );
     391           3 :                                         pFirstTxtNd->InsertText(rtl::OUString("MM"), aNdIdx);
     392             :                                         sal_uLong nAbsMinCnts;
     393             :                                         pFirstTxtNd->GetMinMaxSize( pFirstTxtNd->GetIndex(),
     394           3 :                                                                                         nMinFrm, nMaxFrm, nAbsMinCnts );
     395           3 :                                         aNdIdx -= 2;
     396           3 :                     pFirstTxtNd->EraseText( aNdIdx, 2 );
     397             :                 }
     398             : 
     399             :                                 // Umrandung und Abstand zum Inhalt beachten
     400           3 :                                 const SvxBoxItem& rBoxItem = (SvxBoxItem&)rFlySet.Get( RES_BOX );
     401           3 :                                 sal_uInt16 nLine = BOX_LINE_LEFT;
     402           9 :                                 for( int i = 0; i < 2; ++i )
     403             :                                 {
     404           6 :                                         const editeng::SvxBorderLine* pLn = rBoxItem.GetLine( nLine );
     405           6 :                                         if( pLn )
     406             :                                         {
     407           0 :                                                 sal_uInt16 nWidthTmp = pLn->GetOutWidth() + pLn->GetInWidth();
     408           0 :                         nWidthTmp = nWidthTmp + rBoxItem.GetDistance( nLine );
     409           0 :                                                 nMinFrm += nWidthTmp;
     410           0 :                                                 nMaxFrm += nWidthTmp;
     411             :                                         }
     412           6 :                                         nLine = BOX_LINE_RIGHT;
     413             :                                 }
     414             : 
     415             :                                 // Mindestbreite fuer Inhalt einhalten
     416           3 :                                 if( nMinFrm < MINLAY )
     417           0 :                                         nMinFrm = MINLAY;
     418           3 :                                 if( nMaxFrm < MINLAY )
     419           0 :                                         nMaxFrm = MINLAY;
     420             : 
     421           3 :                                 if( nWidth > (sal_uInt16)nMaxFrm )
     422           3 :                                         nWidth = nMaxFrm;
     423           0 :                                 else if( nWidth > (sal_uInt16)nMinFrm )
     424           0 :                                         nWidth = nMinFrm;
     425           4 :                         }
     426             :                 }
     427             : 
     428           4 :                 if( MINFLY > nWidth )
     429           0 :                         nWidth = MINFLY;
     430             : 
     431           4 :                 aSz.SetWidth( nWidth );
     432           4 :                 if( MINFLY > aSz.GetHeight() )
     433           4 :                         aSz.SetHeight( MINFLY );
     434           4 :                 rFlySet.Put( aSz );
     435             :         }
     436           0 :         else if( MINFLY > ((SwFmtFrmSize*)pItem)->GetHeight() )
     437             :         {
     438           0 :                 SwFmtFrmSize aSz( *(SwFmtFrmSize*)pItem );
     439           0 :                 aSz.SetHeight( MINFLY );
     440           0 :                 rFlySet.Put( aSz );
     441             :         }
     442           4 : }
     443             : 
     444             : struct CharSetNameMap
     445             : {
     446             :     rtl_TextEncoding eCode;
     447             :     const sal_Char* pName;
     448             : };
     449             : 
     450           3 : const CharSetNameMap *GetCharSetNameMap()
     451             : {
     452             :     static const CharSetNameMap aMapArr[] =
     453             :     {
     454             : #   define IMPLENTRY(X) { RTL_TEXTENCODING_##X, "" #X "" }
     455             :         IMPLENTRY(DONTKNOW),
     456             :         IMPLENTRY(MS_1252),
     457             :         IMPLENTRY(APPLE_ROMAN),
     458             :         IMPLENTRY(IBM_437),
     459             :         IMPLENTRY(IBM_850),
     460             :         IMPLENTRY(IBM_860),
     461             :         IMPLENTRY(IBM_861),
     462             :         IMPLENTRY(IBM_863),
     463             :         IMPLENTRY(IBM_865),
     464             :         IMPLENTRY(SYMBOL),
     465             :         IMPLENTRY(ASCII_US),
     466             :         IMPLENTRY(ISO_8859_1),
     467             :         IMPLENTRY(ISO_8859_2),
     468             :         IMPLENTRY(ISO_8859_3),
     469             :         IMPLENTRY(ISO_8859_4),
     470             :         IMPLENTRY(ISO_8859_5),
     471             :         IMPLENTRY(ISO_8859_6),
     472             :         IMPLENTRY(ISO_8859_7),
     473             :         IMPLENTRY(ISO_8859_8),
     474             :         IMPLENTRY(ISO_8859_9),
     475             :         IMPLENTRY(ISO_8859_14),
     476             :         IMPLENTRY(ISO_8859_15),
     477             :         IMPLENTRY(IBM_737),
     478             :         IMPLENTRY(IBM_775),
     479             :         IMPLENTRY(IBM_852),
     480             :         IMPLENTRY(IBM_855),
     481             :         IMPLENTRY(IBM_857),
     482             :         IMPLENTRY(IBM_862),
     483             :         IMPLENTRY(IBM_864),
     484             :         IMPLENTRY(IBM_866),
     485             :         IMPLENTRY(IBM_869),
     486             :         IMPLENTRY(MS_874),
     487             :         IMPLENTRY(MS_1250),
     488             :         IMPLENTRY(MS_1251),
     489             :         IMPLENTRY(MS_1253),
     490             :         IMPLENTRY(MS_1254),
     491             :         IMPLENTRY(MS_1255),
     492             :         IMPLENTRY(MS_1256),
     493             :         IMPLENTRY(MS_1257),
     494             :         IMPLENTRY(MS_1258),
     495             :         IMPLENTRY(APPLE_ARABIC),
     496             :         IMPLENTRY(APPLE_CENTEURO),
     497             :         IMPLENTRY(APPLE_CROATIAN),
     498             :         IMPLENTRY(APPLE_CYRILLIC),
     499             :         IMPLENTRY(APPLE_DEVANAGARI),
     500             :         IMPLENTRY(APPLE_FARSI),
     501             :         IMPLENTRY(APPLE_GREEK),
     502             :         IMPLENTRY(APPLE_GUJARATI),
     503             :         IMPLENTRY(APPLE_GURMUKHI),
     504             :         IMPLENTRY(APPLE_HEBREW),
     505             :         IMPLENTRY(APPLE_ICELAND),
     506             :         IMPLENTRY(APPLE_ROMANIAN),
     507             :         IMPLENTRY(APPLE_THAI),
     508             :         IMPLENTRY(APPLE_TURKISH),
     509             :         IMPLENTRY(APPLE_UKRAINIAN),
     510             :         IMPLENTRY(APPLE_CHINSIMP),
     511             :         IMPLENTRY(APPLE_CHINTRAD),
     512             :         IMPLENTRY(APPLE_JAPANESE),
     513             :         IMPLENTRY(APPLE_KOREAN),
     514             :         IMPLENTRY(MS_932),
     515             :         IMPLENTRY(MS_936),
     516             :         IMPLENTRY(MS_949),
     517             :         IMPLENTRY(MS_950),
     518             :         IMPLENTRY(SHIFT_JIS),
     519             :         IMPLENTRY(GB_2312),
     520             :         IMPLENTRY(GBT_12345),
     521             :         IMPLENTRY(GBK),
     522             :         IMPLENTRY(BIG5),
     523             :         IMPLENTRY(EUC_JP),
     524             :         IMPLENTRY(EUC_CN),
     525             :         IMPLENTRY(EUC_TW),
     526             :         IMPLENTRY(ISO_2022_JP),
     527             :         IMPLENTRY(ISO_2022_CN),
     528             :         IMPLENTRY(KOI8_R),
     529             :         IMPLENTRY(KOI8_U),
     530             :         IMPLENTRY(UTF7),
     531             :         IMPLENTRY(UTF8),
     532             :         IMPLENTRY(ISO_8859_10),
     533             :         IMPLENTRY(ISO_8859_13),
     534             :         IMPLENTRY(EUC_KR),
     535             :         IMPLENTRY(ISO_2022_KR),
     536             :         IMPLENTRY(JIS_X_0201),
     537             :         IMPLENTRY(JIS_X_0208),
     538             :         IMPLENTRY(JIS_X_0212),
     539             :         IMPLENTRY(MS_1361),
     540             :         IMPLENTRY(GB_18030),
     541             :         IMPLENTRY(BIG5_HKSCS),
     542             :         IMPLENTRY(TIS_620),
     543             :         IMPLENTRY(PT154),
     544             :         IMPLENTRY(UCS4),
     545             :         IMPLENTRY(UCS2),
     546             :         IMPLENTRY(UNICODE),
     547             :         {0,0}       //Last
     548             :     };
     549           3 :     return &aMapArr[0];
     550             : }
     551             : /*
     552             :  Get a rtl_TextEncoding from its name
     553             :  */
     554           3 : rtl_TextEncoding CharSetFromName(const String& rChrSetStr)
     555             : {
     556           3 :     const CharSetNameMap *pStart = GetCharSetNameMap();
     557           3 :     rtl_TextEncoding nRet = pStart->eCode;
     558             : 
     559         231 :     for(const CharSetNameMap *pMap = pStart; pMap->pName; ++pMap)
     560             :     {
     561         231 :         if(rChrSetStr.EqualsIgnoreCaseAscii(pMap->pName))
     562             :         {
     563           3 :             nRet = pMap->eCode;
     564           3 :             break;
     565             :         }
     566             :     }
     567             : 
     568             :     OSL_ENSURE(nRet != pStart->eCode, "TXT: That was an unknown language!");
     569             : 
     570           3 :         return nRet;
     571             : }
     572             : 
     573             : 
     574             : /*
     575             :  Get the String name of an rtl_TextEncoding
     576             :  */
     577           0 : String NameFromCharSet(rtl_TextEncoding nChrSet)
     578             : {
     579           0 :     const CharSetNameMap *pStart = GetCharSetNameMap();
     580           0 :     const char *pRet = pStart->pName;
     581             : 
     582           0 :     for(const CharSetNameMap *pMap = pStart; pMap->pName; ++pMap)
     583             :     {
     584           0 :         if (nChrSet == pMap->eCode)
     585             :         {
     586           0 :             pRet = pMap->pName;
     587           0 :             break;
     588             :         }
     589             :     }
     590             : 
     591             :     OSL_ENSURE(pRet != pStart->pName, "TXT: That was an unknown language!");
     592             : 
     593           0 :     return rtl::OUString::createFromAscii(pRet);
     594             : }
     595             : 
     596             : // for the automatic conversion (mail/news/...)
     597             : // The user data contains the options for the ascii import/export filter.
     598             : // The format is:
     599             : //      1. CharSet - as ascii chars
     600             : //      2. LineEnd - as CR/LR/CRLF
     601             : //      3. Fontname
     602             : //      4. Language
     603             : // the delimetercharacter is ","
     604             : //
     605             : 
     606           3 : void SwAsciiOptions::ReadUserData( const String& rStr )
     607             : {
     608           3 :         xub_StrLen nToken = 0;
     609           3 :         sal_uInt16 nCnt = 0;
     610           3 :         String sToken;
     611          12 :         do {
     612          12 :                 if( 0 != (sToken = rStr.GetToken( 0, ',', nToken )).Len() )
     613             :                 {
     614          12 :                         switch( nCnt )
     615             :                         {
     616             :                         case 0:         // CharSet
     617           3 :                 eCharSet = CharSetFromName(sToken);
     618           3 :                                 break;
     619             :                         case 1:         // LineEnd
     620           3 :                                 if( sToken.EqualsIgnoreCaseAscii( "CRLF" ))
     621           0 :                                         eCRLF_Flag = LINEEND_CRLF;
     622           3 :                                 else if( sToken.EqualsIgnoreCaseAscii( "LF" ))
     623           3 :                                         eCRLF_Flag = LINEEND_LF;
     624             :                                 else
     625           0 :                                         eCRLF_Flag = LINEEND_CR;
     626           3 :                                 break;
     627             :                         case 2:         // fontname
     628           3 :                                 sFont = sToken;
     629           3 :                                 break;
     630             :                         case 3:         // Language
     631           3 :                 nLanguage = LanguageTag( sToken ).getLanguageType();
     632           3 :                                 break;
     633             :                         }
     634             :                 }
     635          12 :                 ++nCnt;
     636           3 :         } while( STRING_NOTFOUND != nToken );
     637           3 : }
     638             : 
     639           0 : void SwAsciiOptions::WriteUserData( String& rStr )
     640             : {
     641             :         // 1. charset
     642           0 :         rStr = NameFromCharSet(eCharSet);
     643           0 :         rStr += ',';
     644             : 
     645             :         // 2. LineEnd
     646           0 :         switch(eCRLF_Flag)
     647             :         {
     648             :         case LINEEND_CRLF:
     649           0 :             rStr.AppendAscii( "CRLF" );
     650           0 :             break;
     651             :         case LINEEND_CR:
     652           0 :             rStr.AppendAscii(  "CR" );
     653           0 :             break;
     654             :         case LINEEND_LF:
     655           0 :             rStr.AppendAscii(  "LF" );
     656           0 :             break;
     657             :         }
     658           0 :         rStr += ',';
     659             : 
     660             :         // 3. Fontname
     661           0 :         rStr += sFont;
     662           0 :         rStr += ',';
     663             : 
     664             :         // 4. Language
     665           0 :         if (nLanguage)
     666             :         {
     667           0 :         rtl::OUString sTmp = LanguageTag( nLanguage ).getBcp47();
     668           0 :         rStr += (String)sTmp;
     669             :         }
     670           0 :         rStr += ',';
     671           0 : }
     672             : 
     673             : #ifdef DISABLE_DYNLOADING
     674             : 
     675             : extern "C" {
     676             :     Reader *ImportRTF();
     677             :     void ExportRTF( const String&, const String& rBaseURL, WriterRef& );
     678             :     Reader *ImportDOC();
     679             :     void ExportDOC( const String&, const String& rBaseURL, WriterRef& );
     680             :     sal_uLong SaveOrDelMSVBAStorage_ww8( SfxObjectShell&, SotStorage&, sal_Bool, const String& );
     681             :     sal_uLong GetSaveWarningOfMSVBAStorage_ww8( SfxObjectShell& );
     682             : }
     683             : 
     684             : #endif
     685             : 
     686           0 : Reader* GetRTFReader()
     687             : {
     688             : #ifndef DISABLE_DYNLOADING
     689             : 
     690           0 :     FnGetReader pFunction = reinterpret_cast<FnGetReader>( SwGlobals::getFilters().GetMswordLibSymbol( "ImportRTF" ) );
     691             : 
     692           0 :     if ( pFunction )
     693           0 :         return (*pFunction)();
     694             : 
     695           0 :     return NULL;
     696             : #else
     697             :     return ImportRTF();
     698             : #endif
     699             : 
     700             : }
     701             : 
     702           0 : void GetRTFWriter( const String& rFltName, const String& rBaseURL, WriterRef& xRet )
     703             : {
     704             : #ifndef DISABLE_DYNLOADING
     705           0 :     FnGetWriter pFunction = reinterpret_cast<FnGetWriter>( SwGlobals::getFilters().GetMswordLibSymbol( "ExportRTF" ) );
     706             : 
     707           0 :     if ( pFunction )
     708           0 :         (*pFunction)( rFltName, rBaseURL, xRet );
     709             :     else
     710           0 :         xRet = WriterRef(0);
     711             : #else
     712             :     ExportRTF( rFltName, rBaseURL, xRet );
     713             : #endif
     714           0 : }
     715             : 
     716           3 : Reader* GetWW8Reader()
     717             : {
     718             : #ifndef DISABLE_DYNLOADING
     719           3 :     FnGetReader pFunction = reinterpret_cast<FnGetReader>( SwGlobals::getFilters().GetMswordLibSymbol( "ImportDOC" ) );
     720             : 
     721           3 :     if ( pFunction )
     722           3 :         return (*pFunction)();
     723             : 
     724           0 :     return NULL;
     725             : #else
     726             :     return ImportDOC();
     727             : #endif
     728             : }
     729             : 
     730           0 : void GetWW8Writer( const String& rFltName, const String& rBaseURL, WriterRef& xRet )
     731             : {
     732             : #ifndef DISABLE_DYNLOADING
     733           0 :     FnGetWriter pFunction = reinterpret_cast<FnGetWriter>( SwGlobals::getFilters().GetMswordLibSymbol( "ExportDOC" ) );
     734             : 
     735           0 :     if ( pFunction )
     736           0 :         (*pFunction)( rFltName, rBaseURL, xRet );
     737             :     else
     738           0 :         xRet = WriterRef(0);
     739             : #else
     740             :     ExportDOC( rFltName, rBaseURL, xRet );
     741             : #endif
     742           0 : }
     743             : 
     744             : typedef sal_uLong ( SAL_CALL *SaveOrDel )( SfxObjectShell&, SotStorage&, sal_Bool, const String& );
     745             : typedef sal_uLong ( SAL_CALL *GetSaveWarning )( SfxObjectShell& );
     746             : 
     747           0 : sal_uLong SaveOrDelMSVBAStorage( SfxObjectShell& rDoc, SotStorage& rStor, sal_Bool bSaveInto, const String& rStorageName )
     748             : {
     749             : #ifndef DISABLE_DYNLOADING
     750           0 :     SaveOrDel pFunction = reinterpret_cast<SaveOrDel>( SwGlobals::getFilters().GetMswordLibSymbol( "SaveOrDelMSVBAStorage_ww8" ) );
     751           0 :     if( pFunction )
     752           0 :         return pFunction( rDoc, rStor, bSaveInto, rStorageName );
     753           0 :     return ERRCODE_NONE;
     754             : #else
     755             :     return SaveOrDelMSVBAStorage_ww8( rDoc, rStor, bSaveInto, rStorageName );
     756             : #endif
     757             : }
     758             : 
     759           0 : sal_uLong GetSaveWarningOfMSVBAStorage( SfxObjectShell &rDocS )
     760             : {
     761             : #ifndef DISABLE_DYNLOADING
     762           0 :     GetSaveWarning pFunction = reinterpret_cast<GetSaveWarning>( SwGlobals::getFilters().GetMswordLibSymbol( "GetSaveWarningOfMSVBAStorage_ww8" ) );
     763           0 :     if( pFunction )
     764           0 :         return pFunction( rDocS );
     765           0 :     return ERRCODE_NONE;
     766             : #else
     767             :     return GetSaveWarningOfMSVBAStorage_ww8( rDocS );
     768             : #endif
     769          30 : }
     770             : 
     771             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10