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

Generated by: LCOV version 1.11