LCOV - code coverage report
Current view: top level - libreoffice/editeng/source/editeng - eerdll.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 89 98 90.8 %
Date: 2012-12-27 Functions: 9 10 90.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             : 
      21             : #include <vcl/wrkwin.hxx>
      22             : #include <vcl/dialog.hxx>
      23             : #include <vcl/msgbox.hxx>
      24             : #include <vcl/svapp.hxx>
      25             : #include <com/sun/star/linguistic2/XLanguageGuessing.hpp>
      26             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      27             : #include <comphelper/processfactory.hxx>
      28             : 
      29             : #include <svl/solar.hrc>
      30             : #include <editeng/eerdll.hxx>
      31             : #include <eerdll2.hxx>
      32             : #include <editeng/lspcitem.hxx>
      33             : #include <editeng/adjitem.hxx>
      34             : #include <editeng/tstpitem.hxx>
      35             : #include <editeng/bulitem.hxx>
      36             : #include <editeng/flditem.hxx>
      37             : #include <editeng/emphitem.hxx>
      38             : #include <editeng/scriptspaceitem.hxx>
      39             : #include <svl/itempool.hxx>
      40             : #include <vcl/virdev.hxx>
      41             : 
      42             : #include <editeng/akrnitem.hxx>
      43             : #include <editeng/cntritem.hxx>
      44             : #include <editeng/colritem.hxx>
      45             : #include <editeng/crsditem.hxx>
      46             : #include <editeng/cscoitem.hxx>
      47             : #include <editeng/escpitem.hxx>
      48             : #include <editeng/fhgtitem.hxx>
      49             : #include <editeng/fontitem.hxx>
      50             : #include <editeng/kernitem.hxx>
      51             : #include <editeng/lrspitem.hxx>
      52             : #include <editeng/postitem.hxx>
      53             : #include <editeng/shdditem.hxx>
      54             : #include <editeng/udlnitem.hxx>
      55             : #include <editeng/ulspitem.hxx>
      56             : #include <editeng/wghtitem.hxx>
      57             : #include <editeng/wrlmitem.hxx>
      58             : #include <editeng/numitem.hxx>
      59             : #include <editeng/langitem.hxx>
      60             : #include <editeng/charscaleitem.hxx>
      61             : #include <editeng/charreliefitem.hxx>
      62             : #include <editeng/frmdiritem.hxx>
      63             : #include <editeng/xmlcnitm.hxx>
      64             : #include <editeng/forbiddencharacterstable.hxx>
      65             : #include <editeng/justifyitem.hxx>
      66             : #include <rtl/instance.hxx>
      67             : 
      68             : using namespace ::com::sun::star;
      69             : 
      70             : namespace
      71             : {
      72             :     class theEditDLL : public rtl::Static<EditDLL, theEditDLL> {};
      73             : }
      74             : 
      75       91907 : EditDLL& EditDLL::Get()
      76             : {
      77       91907 :     return theEditDLL::get();
      78             : }
      79             : 
      80          18 : GlobalEditData::GlobalEditData()
      81          18 :     : m_aStdRefDevice(::com::sun::star::uno::Reference<com::sun::star::lang::XComponent>(::comphelper::getProcessComponentContext(), ::com::sun::star::uno::UNO_QUERY_THROW))
      82             : {
      83          18 :     ppDefItems = NULL;
      84          18 : }
      85             : 
      86          36 : GlobalEditData::~GlobalEditData()
      87             : {
      88             :     // Destroy DefItems...
      89             :     // Or simply keep them, since at end of excecution?!
      90          18 :     if ( ppDefItems )
      91          18 :         SfxItemPool::ReleaseDefaults( ppDefItems, EDITITEMCOUNT, sal_True );
      92          18 : }
      93             : 
      94        6264 : SfxPoolItem** GlobalEditData::GetDefItems()
      95             : {
      96        6264 :     if ( !ppDefItems )
      97             :     {
      98          18 :         ppDefItems = new SfxPoolItem*[EDITITEMCOUNT];
      99             : 
     100             :         // Paragraph attributes:
     101          18 :         SvxNumRule aTmpNumRule( 0, 0, sal_False );
     102             : 
     103          18 :         ppDefItems[0]  = new SvxFrameDirectionItem( FRMDIR_HORI_LEFT_TOP, EE_PARA_WRITINGDIR );
     104          18 :         ppDefItems[1]  = new SvXMLAttrContainerItem( EE_PARA_XMLATTRIBS );
     105          18 :         ppDefItems[2]  = new SfxBoolItem( EE_PARA_HANGINGPUNCTUATION, sal_False );
     106          18 :         ppDefItems[3]  = new SfxBoolItem( EE_PARA_FORBIDDENRULES, sal_True );
     107          18 :         ppDefItems[4]  = new SvxScriptSpaceItem( sal_True, EE_PARA_ASIANCJKSPACING );
     108          18 :         ppDefItems[5]  = new SvxNumBulletItem( aTmpNumRule, EE_PARA_NUMBULLET );
     109          18 :         ppDefItems[6]  = new SfxBoolItem( EE_PARA_HYPHENATE, sal_False );
     110          18 :         ppDefItems[7]  = new SfxBoolItem( EE_PARA_BULLETSTATE, sal_True );
     111          18 :         ppDefItems[8]  = new SvxLRSpaceItem( EE_PARA_OUTLLRSPACE );
     112          18 :         ppDefItems[9]  = new SfxInt16Item( EE_PARA_OUTLLEVEL, -1 );
     113          18 :         ppDefItems[10] = new SvxBulletItem( EE_PARA_BULLET );
     114          18 :         ppDefItems[11] = new SvxLRSpaceItem( EE_PARA_LRSPACE );
     115          18 :         ppDefItems[12] = new SvxULSpaceItem( EE_PARA_ULSPACE );
     116          18 :         ppDefItems[13] = new SvxLineSpacingItem( 0, EE_PARA_SBL );
     117          18 :         ppDefItems[14] = new SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST );
     118          18 :         ppDefItems[15] = new SvxTabStopItem( 0, 0, SVX_TAB_ADJUST_LEFT, EE_PARA_TABS );
     119          18 :         ppDefItems[16] = new SvxJustifyMethodItem( SVX_JUSTIFY_METHOD_AUTO, EE_PARA_JUST_METHOD );
     120          18 :         ppDefItems[17] = new SvxVerJustifyItem( SVX_VER_JUSTIFY_STANDARD, EE_PARA_VER_JUST );
     121             : 
     122             :         // Character attributes:
     123          18 :         ppDefItems[18] = new SvxColorItem( Color( COL_AUTO ), EE_CHAR_COLOR );
     124          18 :         ppDefItems[19] = new SvxFontItem( EE_CHAR_FONTINFO );
     125          18 :         ppDefItems[20] = new SvxFontHeightItem( 240, 100, EE_CHAR_FONTHEIGHT );
     126          18 :         ppDefItems[21] = new SvxCharScaleWidthItem( 100, EE_CHAR_FONTWIDTH );
     127          18 :         ppDefItems[22] = new SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT );
     128          18 :         ppDefItems[23] = new SvxUnderlineItem( UNDERLINE_NONE, EE_CHAR_UNDERLINE );
     129          18 :         ppDefItems[24] = new SvxCrossedOutItem( STRIKEOUT_NONE, EE_CHAR_STRIKEOUT );
     130          18 :         ppDefItems[25] = new SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC );
     131          18 :         ppDefItems[26] = new SvxContourItem( sal_False, EE_CHAR_OUTLINE );
     132          18 :         ppDefItems[27] = new SvxShadowedItem( sal_False, EE_CHAR_SHADOW );
     133          18 :         ppDefItems[28] = new SvxEscapementItem( 0, 100, EE_CHAR_ESCAPEMENT );
     134          18 :         ppDefItems[29] = new SvxAutoKernItem( sal_False, EE_CHAR_PAIRKERNING );
     135          18 :         ppDefItems[30] = new SvxKerningItem( 0, EE_CHAR_KERNING );
     136          18 :         ppDefItems[31] = new SvxWordLineModeItem( sal_False, EE_CHAR_WLM );
     137          18 :         ppDefItems[32] = new SvxLanguageItem( LANGUAGE_DONTKNOW, EE_CHAR_LANGUAGE );
     138          18 :         ppDefItems[33] = new SvxLanguageItem( LANGUAGE_DONTKNOW, EE_CHAR_LANGUAGE_CJK );
     139          18 :         ppDefItems[34] = new SvxLanguageItem( LANGUAGE_DONTKNOW, EE_CHAR_LANGUAGE_CTL );
     140          18 :         ppDefItems[35] = new SvxFontItem( EE_CHAR_FONTINFO_CJK );
     141          18 :         ppDefItems[36] = new SvxFontItem( EE_CHAR_FONTINFO_CTL );
     142          18 :         ppDefItems[37] = new SvxFontHeightItem( 240, 100, EE_CHAR_FONTHEIGHT_CJK );
     143          18 :         ppDefItems[38] = new SvxFontHeightItem( 240, 100, EE_CHAR_FONTHEIGHT_CTL );
     144          18 :         ppDefItems[39] = new SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CJK );
     145          18 :         ppDefItems[40] = new SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CTL );
     146          18 :         ppDefItems[41] = new SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CJK );
     147          18 :         ppDefItems[42] = new SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CTL );
     148          18 :         ppDefItems[43] = new SvxEmphasisMarkItem( EMPHASISMARK_NONE, EE_CHAR_EMPHASISMARK );
     149          18 :         ppDefItems[44] = new SvxCharReliefItem( RELIEF_NONE, EE_CHAR_RELIEF );
     150          18 :         ppDefItems[45] = new SfxVoidItem( EE_CHAR_RUBI_DUMMY );
     151          18 :         ppDefItems[46] = new SvXMLAttrContainerItem( EE_CHAR_XMLATTRIBS );
     152          18 :         ppDefItems[47] = new SvxOverlineItem( UNDERLINE_NONE, EE_CHAR_OVERLINE );
     153             : 
     154             :         // Features
     155          18 :         ppDefItems[48] = new SfxVoidItem( EE_FEATURE_TAB );
     156          18 :         ppDefItems[49] = new SfxVoidItem( EE_FEATURE_LINEBR );
     157          18 :         ppDefItems[50] = new SvxCharSetColorItem( Color( COL_RED ), RTL_TEXTENCODING_DONTKNOW, EE_FEATURE_NOTCONV );
     158          18 :         ppDefItems[51] = new SvxFieldItem( SvxFieldData(), EE_FEATURE_FIELD );
     159             : 
     160             :         DBG_ASSERT( EDITITEMCOUNT == 52, "ITEMCOUNT geaendert, DefItems nicht angepasst!" );
     161             : 
     162             :         // Init DefFonts:
     163          18 :         GetDefaultFonts( *(SvxFontItem*)ppDefItems[EE_CHAR_FONTINFO - EE_ITEMS_START],
     164          18 :                          *(SvxFontItem*)ppDefItems[EE_CHAR_FONTINFO_CJK - EE_ITEMS_START],
     165          54 :                          *(SvxFontItem*)ppDefItems[EE_CHAR_FONTINFO_CTL - EE_ITEMS_START] );
     166             :     }
     167             : 
     168        6264 :     return ppDefItems;
     169             : }
     170             : 
     171        4271 : rtl::Reference<SvxForbiddenCharactersTable> GlobalEditData::GetForbiddenCharsTable()
     172             : {
     173        4271 :     if ( !xForbiddenCharsTable.is() )
     174             :     {
     175         779 :         xForbiddenCharsTable = new SvxForbiddenCharactersTable( ::comphelper::getProcessComponentContext() );
     176             :     }
     177        4271 :     return xForbiddenCharsTable;
     178             : }
     179             : 
     180           0 : uno::Reference< linguistic2::XLanguageGuessing > GlobalEditData::GetLanguageGuesser()
     181             : {
     182           0 :     if (!xLanguageGuesser.is())
     183             :     {
     184           0 :         uno::Reference< lang::XMultiServiceFactory > xMgr ( comphelper::getProcessServiceFactory() );
     185           0 :         if (xMgr.is())
     186             :         {
     187             :             xLanguageGuesser = uno::Reference< linguistic2::XLanguageGuessing >(
     188           0 :                     xMgr->createInstance(
     189           0 :                         rtl::OUString( "com.sun.star.linguistic2.LanguageGuessing" ) ),
     190           0 :                         uno::UNO_QUERY );
     191           0 :         }
     192             :     }
     193           0 :     return xLanguageGuesser;
     194             : }
     195             : 
     196        7439 : OutputDevice* GlobalEditData::GetStdRefDevice()
     197             : {
     198        7439 :     if ( !m_aStdRefDevice )
     199             :     {
     200          18 :         m_aStdRefDevice.reset(new VirtualDevice);
     201          18 :         m_aStdRefDevice->SetMapMode( MAP_TWIP );
     202             :     }
     203        7439 :     return m_aStdRefDevice.get();
     204             : }
     205             : 
     206       67458 : EditResId::EditResId( sal_uInt16 nId ):
     207       67458 :     ResId( nId, *EE_DLL().GetResMgr() )
     208             : {
     209       67458 : }
     210             : 
     211          18 : EditDLL::EditDLL()
     212             : {
     213          18 :     pGlobalData = new GlobalEditData;
     214          18 :     pResMgr = ResMgr::CreateResMgr( "editeng", Application::GetSettings().GetUILanguageTag().getLocale() );
     215          18 : }
     216             : 
     217          18 : EditDLL::~EditDLL()
     218             : {
     219          18 :     delete pGlobalData;
     220          18 : }
     221             : 
     222             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10