LCOV - code coverage report
Current view: top level - sw/source/filter/html - htmldrawwriter.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 130 0.0 %
Date: 2014-04-11 Functions: 0 3 0.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 "hintids.hxx"
      21             : #include <vcl/svapp.hxx>
      22             : #include <vcl/wrkwin.hxx>
      23             : #include <svx/svdmodel.hxx>
      24             : #include <svx/svdpage.hxx>
      25             : #include <svx/svdobj.hxx>
      26             : #include <svx/svdotext.hxx>
      27             : #include <editeng/eeitem.hxx>
      28             : #include <editeng/outliner.hxx>
      29             : #include <svx/xfillit.hxx>
      30             : #include <editeng/colritem.hxx>
      31             : #include <editeng/brushitem.hxx>
      32             : #include <editeng/lrspitem.hxx>
      33             : #include <editeng/ulspitem.hxx>
      34             : #include <svl/itemiter.hxx>
      35             : #include <svl/whiter.hxx>
      36             : #include <svtools/htmlout.hxx>
      37             : #include <svtools/htmltokn.h>
      38             : #include <svtools/htmlkywd.hxx>
      39             : #include <svx/svdpool.hxx>
      40             : 
      41             : #include <rtl/strbuf.hxx>
      42             : 
      43             : #include "charatr.hxx"
      44             : #include <frmfmt.hxx>
      45             : #include <fmtanchr.hxx>
      46             : #include <fmtsrnd.hxx>
      47             : #include "ndtxt.hxx"
      48             : #include "doc.hxx"
      49             : #include "dcontact.hxx"
      50             : #include "poolfmt.hxx"
      51             : 
      52             : #include "wrthtml.hxx"
      53             : 
      54             : 
      55             : using namespace css;
      56             : 
      57             : const sal_uInt32 HTML_FRMOPTS_MARQUEE   =
      58             :     HTML_FRMOPT_ALIGN |
      59             :     HTML_FRMOPT_SPACE;
      60             : 
      61             : const sal_uInt32 HTML_FRMOPTS_MARQUEE_CSS1  =
      62             :     HTML_FRMOPT_S_ALIGN |
      63             :     HTML_FRMOPT_S_SPACE;
      64             : 
      65           0 : const SdrObject *SwHTMLWriter::GetMarqueeTextObj( const SwDrawFrmFmt& rFmt )
      66             : {
      67           0 :     const SdrObject* pObj = rFmt.FindSdrObject();
      68           0 :     return (pObj && ::IsMarqueeTextObj( *pObj )) ? pObj : 0;
      69             : }
      70             : 
      71           0 : void SwHTMLWriter::GetEEAttrsFromDrwObj( SfxItemSet& rItemSet,
      72             :                                          const SdrObject *pObj,
      73             :                                          sal_Bool bSetDefaults )
      74             : {
      75             :     // die Edit script::Engine-Attribute aus dem Objekt holen
      76           0 :     SfxItemSet rObjItemSet = pObj->GetMergedItemSet();
      77             : 
      78             :     // ueber die Edit script::Engine-Attribute iterieren und die Attribute
      79             :     // in SW-Attrs wandeln bzw. default setzen
      80           0 :     SfxWhichIter aIter( rObjItemSet );
      81           0 :     sal_uInt16 nEEWhich = aIter.FirstWhich();
      82           0 :     while( nEEWhich )
      83             :     {
      84             :         const SfxPoolItem *pEEItem;
      85           0 :         sal_Bool bSet = SFX_ITEM_SET == rObjItemSet.GetItemState( nEEWhich, false,
      86           0 :                                                               &pEEItem );
      87             : 
      88           0 :         if( bSet || bSetDefaults )
      89             :         {
      90           0 :             sal_uInt16 nSwWhich = 0;
      91           0 :             switch( nEEWhich )
      92             :             {
      93           0 :             case EE_CHAR_COLOR:         nSwWhich = RES_CHRATR_COLOR;        break;
      94           0 :             case EE_CHAR_STRIKEOUT:     nSwWhich = RES_CHRATR_CROSSEDOUT;   break;
      95           0 :             case EE_CHAR_ESCAPEMENT:    nSwWhich = RES_CHRATR_ESCAPEMENT;   break;
      96           0 :             case EE_CHAR_FONTINFO:      nSwWhich = RES_CHRATR_FONT;         break;
      97           0 :             case EE_CHAR_FONTINFO_CJK:  nSwWhich = RES_CHRATR_CJK_FONT;     break;
      98           0 :             case EE_CHAR_FONTINFO_CTL:  nSwWhich = RES_CHRATR_CTL_FONT;     break;
      99           0 :             case EE_CHAR_FONTHEIGHT:    nSwWhich = RES_CHRATR_FONTSIZE;     break;
     100           0 :             case EE_CHAR_FONTHEIGHT_CJK:nSwWhich = RES_CHRATR_CJK_FONTSIZE; break;
     101           0 :             case EE_CHAR_FONTHEIGHT_CTL:nSwWhich = RES_CHRATR_CTL_FONTSIZE; break;
     102           0 :             case EE_CHAR_KERNING:       nSwWhich = RES_CHRATR_KERNING;      break;
     103           0 :             case EE_CHAR_ITALIC:        nSwWhich = RES_CHRATR_POSTURE;      break;
     104           0 :             case EE_CHAR_ITALIC_CJK:    nSwWhich = RES_CHRATR_CJK_POSTURE;  break;
     105           0 :             case EE_CHAR_ITALIC_CTL:    nSwWhich = RES_CHRATR_CTL_POSTURE;  break;
     106           0 :             case EE_CHAR_UNDERLINE:     nSwWhich = RES_CHRATR_UNDERLINE;    break;
     107           0 :             case EE_CHAR_WEIGHT:        nSwWhich = RES_CHRATR_WEIGHT;       break;
     108           0 :             case EE_CHAR_WEIGHT_CJK:    nSwWhich = RES_CHRATR_CJK_WEIGHT;   break;
     109           0 :             case EE_CHAR_WEIGHT_CTL:    nSwWhich = RES_CHRATR_CTL_WEIGHT;   break;
     110             :             }
     111             : 
     112           0 :             if( nSwWhich )
     113             :             {
     114             :                 // wenn das Item nicht gesetzt ist nehmen wir ggf. das
     115             :                 // Default-Item
     116           0 :                 if( !bSet )
     117           0 :                     pEEItem = &rObjItemSet.GetPool()->GetDefaultItem(nEEWhich);
     118             : 
     119             :                 // jetzt Clonen wir das Item mit der Which-Id des Writers
     120           0 :                 SfxPoolItem *pSwItem = pEEItem->Clone();
     121           0 :                 pSwItem->SetWhich( nSwWhich );
     122           0 :                 rItemSet.Put( *pSwItem );
     123           0 :                 delete pSwItem;
     124             :             }
     125             :         }
     126             : 
     127           0 :         nEEWhich = aIter.NextWhich();
     128           0 :     }
     129           0 : }
     130             : 
     131           0 : Writer& OutHTML_DrawFrmFmtAsMarquee( Writer& rWrt,
     132             :                                      const SwDrawFrmFmt& rFmt,
     133             :                                      const SdrObject& rSdrObject )
     134             : {
     135           0 :     SwHTMLWriter & rHTMLWrt = (SwHTMLWriter&)rWrt;
     136             : 
     137             :     OSL_ENSURE( rWrt.pDoc->GetDrawModel(), "Da gibt's ein Draw-Obj ohne ein Draw-Model zu haben?" );
     138           0 :     const SdrTextObj *pTextObj = (const SdrTextObj *)&rSdrObject;
     139             : 
     140             :     // Gibt es ueberhaupt auszugebenden Text
     141             :     const OutlinerParaObject *pOutlinerParaObj =
     142           0 :         pTextObj->GetOutlinerParaObject();
     143           0 :     if( !pOutlinerParaObj )
     144           0 :         return rWrt;
     145             : 
     146           0 :     OStringBuffer sOut;
     147           0 :     sOut.append('<').append(OOO_STRING_SVTOOLS_HTML_marquee);
     148             : 
     149             :     // Die Attribute des Objektd holen
     150           0 :     const SfxItemSet& rItemSet = pTextObj->GetMergedItemSet();
     151             : 
     152             :     // BEHAVIOUR
     153           0 :     SdrTextAniKind eAniKind = pTextObj->GetTextAniKind();
     154             :     OSL_ENSURE( SDRTEXTANI_SCROLL==eAniKind ||
     155             :             SDRTEXTANI_ALTERNATE==eAniKind ||
     156             :             SDRTEXTANI_SLIDE==eAniKind,
     157             :             "Text-Draw-Objekt nicht fuer Marquee geeignet" );
     158             : 
     159           0 :     const sal_Char *pStr = 0;
     160           0 :     switch( eAniKind )
     161             :     {
     162           0 :     case SDRTEXTANI_SCROLL:     pStr = OOO_STRING_SVTOOLS_HTML_BEHAV_scroll;        break;
     163           0 :     case SDRTEXTANI_SLIDE:      pStr = OOO_STRING_SVTOOLS_HTML_BEHAV_slide;     break;
     164           0 :     case SDRTEXTANI_ALTERNATE:  pStr = OOO_STRING_SVTOOLS_HTML_BEHAV_alternate; break;
     165             :     default:
     166             :         ;
     167             :     }
     168             : 
     169           0 :     if( pStr )
     170             :     {
     171           0 :         sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_behavior).
     172           0 :             append("=\"").append(pStr).append("\"");
     173             :     }
     174             : 
     175             :     // DIRECTION
     176           0 :     pStr = 0;
     177           0 :     SdrTextAniDirection eAniDir = pTextObj->GetTextAniDirection();
     178           0 :     switch( eAniDir )
     179             :     {
     180           0 :     case SDRTEXTANI_LEFT:       pStr = OOO_STRING_SVTOOLS_HTML_AL_left;     break;
     181           0 :     case SDRTEXTANI_RIGHT:      pStr = OOO_STRING_SVTOOLS_HTML_AL_right;        break;
     182             :     default:
     183             :         ;
     184             :     }
     185             : 
     186           0 :     if( pStr )
     187             :     {
     188           0 :         sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_direction).
     189           0 :             append("=\"").append(pStr).append("\"");
     190             :     }
     191             : 
     192             :     // LOOP
     193             :     sal_Int32 nCount =
     194           0 :         ((const SdrTextAniCountItem&)rItemSet.Get( SDRATTR_TEXT_ANICOUNT ))
     195           0 :                                              .GetValue();
     196           0 :     if( 0==nCount )
     197           0 :         nCount = SDRTEXTANI_SLIDE==eAniKind ? 1 : -1;
     198           0 :     sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_loop).append("=\"").
     199           0 :         append(nCount).append("\"");
     200             : 
     201             :     // SCROLLDELAY
     202             :     sal_uInt16 nDelay =
     203           0 :         ((const SdrTextAniDelayItem&)rItemSet.Get( SDRATTR_TEXT_ANIDELAY ))
     204           0 :                                             .GetValue();
     205           0 :     sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_scrolldelay).
     206           0 :         append("=\"").append(static_cast<sal_Int32>(nDelay)).append("\"");
     207             : 
     208             :     // SCROLLAMOUNT
     209             :     sal_Int16 nAmount =
     210           0 :         ((const SdrTextAniAmountItem&)rItemSet.Get( SDRATTR_TEXT_ANIAMOUNT ))
     211           0 :                                              .GetValue();
     212           0 :     if( nAmount < 0 )
     213             :     {
     214           0 :         nAmount = -nAmount;
     215             :     }
     216           0 :     else if( nAmount && Application::GetDefaultDevice() )
     217             :     {
     218             :         nAmount = (sal_uInt16)(Application::GetDefaultDevice()
     219             :                             ->LogicToPixel( Size(nAmount,0),
     220           0 :                                             MapMode(MAP_TWIP) ).Width());
     221             :     }
     222           0 :     if( nAmount )
     223             :     {
     224           0 :         sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_scrollamount).
     225           0 :             append("=\"").append(static_cast<sal_Int32>(nAmount)).append("\"");
     226             :     }
     227             : 
     228           0 :     Size aTwipSz( pTextObj->GetLogicRect().GetSize() );
     229           0 :     if( pTextObj->IsAutoGrowWidth() )
     230           0 :         aTwipSz.Width() = 0;
     231             :     // Die Hoehe ist bei MS eine Mindesthoehe, also geben wir auch die
     232             :     // Mindestheoehe aus, wenn es sie gibt. Da eine Mindesthoehe MINFLY
     233             :     // mit hoher Wahrscheinlichkeit vom Import kommt, wird sie nicht mit
     234             :     // ausgegeben. Falsch machen kann man da nichst, denn jeder Font ist
     235             :     // hoeher.
     236           0 :     if( pTextObj->IsAutoGrowHeight() )
     237             :     {
     238           0 :         aTwipSz.Height() = pTextObj->GetMinTextFrameHeight();
     239           0 :         if( MINFLY==aTwipSz.Height() )
     240           0 :             aTwipSz.Height() = 0;
     241             :     }
     242             : 
     243           0 :     if( (aTwipSz.Width() || aTwipSz.Height()) &&
     244           0 :         Application::GetDefaultDevice() )
     245             :     {
     246             :         Size aPixelSz =
     247             :             Application::GetDefaultDevice()->LogicToPixel( aTwipSz,
     248           0 :                                                 MapMode(MAP_TWIP) );
     249           0 :         if( !aPixelSz.Width() && aTwipSz.Width() )
     250           0 :             aPixelSz.Width() = 1;
     251           0 :         if( !aPixelSz.Height() && aTwipSz.Height() )
     252           0 :             aPixelSz.Height() = 1;
     253             : 
     254           0 :         if( aPixelSz.Width() )
     255             :         {
     256           0 :             sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_width).
     257           0 :                 append("=\"").append(static_cast<sal_Int32>(aPixelSz.Width())).append("\"");
     258             :         }
     259             : 
     260           0 :         if( aPixelSz.Height() )
     261             :         {
     262           0 :             sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_height).
     263           0 :                 append("=\"").append(static_cast<sal_Int32>(aPixelSz.Height())).append("\"");
     264             :         }
     265             :     }
     266             : 
     267             :     // BGCOLOR
     268             :     XFillStyle eFillStyle =
     269           0 :         ((const XFillStyleItem&)rItemSet.Get(XATTR_FILLSTYLE)).GetValue();
     270           0 :     if( XFILL_SOLID==eFillStyle )
     271             :     {
     272             :         const Color& rFillColor =
     273           0 :             ((const XFillColorItem&)rItemSet.Get(XATTR_FILLCOLOR)).GetColorValue();
     274             : 
     275           0 :         sOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_bgcolor).append("=");
     276           0 :         rWrt.Strm().WriteCharPtr( sOut.makeStringAndClear().getStr() );
     277           0 :         HTMLOutFuncs::Out_Color( rWrt.Strm(), rFillColor, rHTMLWrt.eDestEnc );
     278             :     }
     279             : 
     280           0 :     if (!sOut.isEmpty())
     281           0 :         rWrt.Strm().WriteCharPtr( sOut.makeStringAndClear().getStr() );
     282             : 
     283             :     // und nun noch ALIGN, HSPACE und VSPACE
     284           0 :     sal_uInt32 nFrmFlags = HTML_FRMOPTS_MARQUEE;
     285           0 :     if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_DRAW ) )
     286           0 :         nFrmFlags |= HTML_FRMOPTS_MARQUEE_CSS1;
     287           0 :     OString aEndTags = rHTMLWrt.OutFrmFmtOptions( rFmt, aEmptyOUStr, nFrmFlags );
     288           0 :     if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_DRAW ) )
     289           0 :         rHTMLWrt.OutCSS1_FrmFmtOptions( rFmt, nFrmFlags, &rSdrObject );
     290             : 
     291           0 :     rWrt.Strm().WriteChar( '>' );
     292             : 
     293             :     // Was jetzt kommt ist das Gegenstueck zu SdrTextObjectt::SetText()
     294           0 :     Outliner aOutliner(0, OUTLINERMODE_TEXTOBJECT);
     295           0 :     aOutliner.SetUpdateMode( false );
     296           0 :     aOutliner.SetText( *pOutlinerParaObj );
     297             :     OUString aText( aOutliner.GetText( aOutliner.GetParagraph(0),
     298           0 :                                      aOutliner.GetParagraphCount() ) );
     299           0 :     HTMLOutFuncs::Out_String( rWrt.Strm(), aText,
     300           0 :                                 rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
     301             : 
     302           0 :     HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OOO_STRING_SVTOOLS_HTML_marquee, false );
     303             : 
     304           0 :     if( !aEndTags.isEmpty() )
     305           0 :         rWrt.Strm().WriteCharPtr( aEndTags.getStr() );
     306             : 
     307           0 :     return rWrt;
     308             : }
     309             : 
     310             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10