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

Generated by: LCOV version 1.10