LCOV - code coverage report
Current view: top level - reportdesign/source/ui/report - StartMarker.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 165 0.0 %
Date: 2012-08-25 Functions: 0 17 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : #include "StartMarker.hxx"
      29                 :            : #include <vcl/image.hxx>
      30                 :            : #include <vcl/svapp.hxx>
      31                 :            : #include "RptResId.hrc"
      32                 :            : #include "ModuleHelper.hxx"
      33                 :            : #include "ColorChanger.hxx"
      34                 :            : #include "ReportDefines.hxx"
      35                 :            : #include "SectionWindow.hxx"
      36                 :            : #include "helpids.hrc"
      37                 :            : #include <vcl/help.hxx>
      38                 :            : #include <vcl/gradient.hxx>
      39                 :            : #include <vcl/lineinfo.hxx>
      40                 :            : #include <toolkit/helper/vclunohelper.hxx>
      41                 :            : #include <unotools/syslocale.hxx>
      42                 :            : #include <svl/smplhint.hxx>
      43                 :            : 
      44                 :            : #define CORNER_SPACE     5
      45                 :            : 
      46                 :            : //=====================================================================
      47                 :            : namespace rptui
      48                 :            : {
      49                 :            : //=====================================================================
      50                 :            : 
      51                 :            : Image*  OStartMarker::s_pDefCollapsed       = NULL;
      52                 :            : Image*  OStartMarker::s_pDefExpanded        = NULL;
      53                 :            : oslInterlockedCount OStartMarker::s_nImageRefCount  = 0;
      54                 :            : 
      55                 :            : DBG_NAME( rpt_OStartMarker )
      56                 :            : // -----------------------------------------------------------------------------
      57                 :          0 : OStartMarker::OStartMarker(OSectionWindow* _pParent,const ::rtl::OUString& _sColorEntry)
      58                 :            : : OColorListener(_pParent,_sColorEntry)
      59                 :            : ,m_aVRuler(this,WB_VERT)
      60                 :            : ,m_aText(this,WB_HYPHENATION)
      61                 :            : ,m_aImage(this,WB_LEFT|WB_TOP|WB_SCALE)
      62                 :            : ,m_pParent(_pParent)
      63                 :          0 : ,m_bShowRuler(sal_True)
      64                 :            : {
      65                 :            :     DBG_CTOR( rpt_OStartMarker,NULL);
      66                 :          0 :     SetUniqueId(HID_RPT_STARTMARKER);
      67                 :            : 
      68                 :          0 :     osl_incrementInterlockedCount(&s_nImageRefCount);
      69                 :          0 :     initDefaultNodeImages();
      70                 :          0 :     ImplInitSettings();
      71                 :          0 :     m_aText.SetHelpId(HID_RPT_START_TITLE);
      72                 :          0 :     m_aText.SetPaintTransparent(sal_True);
      73                 :          0 :     m_aImage.SetHelpId(HID_RPT_START_IMAGE);
      74                 :          0 :     m_aText.Show();
      75                 :          0 :     m_aImage.Show();
      76                 :          0 :     m_aVRuler.Show();
      77                 :          0 :     m_aVRuler.Activate();
      78                 :          0 :     m_aVRuler.SetPagePos(0);
      79                 :          0 :     m_aVRuler.SetBorders();
      80                 :          0 :     m_aVRuler.SetIndents();
      81                 :          0 :     m_aVRuler.SetMargin1();
      82                 :          0 :     m_aVRuler.SetMargin2();
      83                 :          0 :     const MeasurementSystem eSystem = SvtSysLocale().GetLocaleData().getMeasurementSystemEnum();
      84                 :          0 :     m_aVRuler.SetUnit(MEASURE_METRIC == eSystem ? FUNIT_CM : FUNIT_INCH);
      85                 :          0 :     EnableChildTransparentMode( sal_True );
      86                 :          0 :     SetParentClipMode( PARENTCLIPMODE_NOCLIP );
      87                 :          0 :     SetPaintTransparent( sal_True );
      88                 :          0 : }
      89                 :            : // -----------------------------------------------------------------------------
      90                 :          0 : OStartMarker::~OStartMarker()
      91                 :            : {
      92                 :            :     DBG_DTOR( rpt_OStartMarker,NULL);
      93                 :          0 :     if ( osl_decrementInterlockedCount(&s_nImageRefCount) == 0 )
      94                 :            :     {
      95                 :          0 :         DELETEZ(s_pDefCollapsed);
      96                 :          0 :         DELETEZ(s_pDefExpanded);
      97                 :            :     }
      98                 :          0 : }
      99                 :            : // -----------------------------------------------------------------------------
     100                 :          0 : sal_Int32 OStartMarker::getMinHeight() const
     101                 :            : {
     102                 :          0 :     Fraction aExtraWidth(long(2*REPORT_EXTRA_SPACE));
     103                 :          0 :     aExtraWidth *= GetMapMode().GetScaleX();
     104                 :          0 :     return LogicToPixel(Size(0,m_aText.GetTextHeight())).Height() + (long)aExtraWidth;
     105                 :            : }
     106                 :            : // -----------------------------------------------------------------------------
     107                 :          0 : void OStartMarker::Paint( const Rectangle& rRect )
     108                 :            : {
     109                 :            :     (void)rRect;
     110                 :          0 :     Size aSize = GetOutputSizePixel();
     111                 :          0 :     long nSize = aSize.Width();
     112                 :          0 :     const long nCornerWidth = long(CORNER_SPACE * (double)GetMapMode().GetScaleX());
     113                 :            : 
     114                 :          0 :     if ( isCollapsed() )
     115                 :            :     {
     116                 :          0 :         SetClipRegion();
     117                 :            :     }
     118                 :            :     else
     119                 :            :     {
     120                 :          0 :         const long nVRulerWidth = m_aVRuler.GetSizePixel().Width();
     121                 :          0 :         nSize = aSize.Width() - nVRulerWidth;
     122                 :          0 :         aSize.Width() += nCornerWidth;
     123                 :          0 :         SetClipRegion(Region(PixelToLogic(Rectangle(Point(),Size(nSize,aSize.Height())))));
     124                 :            :     }
     125                 :            : 
     126                 :          0 :     const Point aGcc3WorkaroundTemporary;
     127                 :          0 :     Rectangle aWholeRect(aGcc3WorkaroundTemporary,aSize);
     128                 :            :     {
     129                 :          0 :         const ColorChanger aColors( this, m_nTextBoundaries, m_nColor );
     130                 :          0 :         PolyPolygon aPoly;
     131                 :          0 :         aPoly.Insert(Polygon(aWholeRect,nCornerWidth,nCornerWidth));
     132                 :            : 
     133                 :          0 :         Color aStartColor(m_nColor);
     134                 :          0 :         aStartColor.IncreaseLuminance(10);
     135                 :          0 :         sal_uInt16 nHue = 0;
     136                 :          0 :         sal_uInt16 nSat = 0;
     137                 :          0 :         sal_uInt16 nBri = 0;
     138                 :          0 :         aStartColor.RGBtoHSB(nHue, nSat, nBri);
     139                 :          0 :         nSat += 40;
     140                 :          0 :         Color aEndColor(Color::HSBtoRGB(nHue, nSat, nBri));
     141                 :          0 :         Gradient aGradient(GradientStyle_LINEAR,aStartColor,aEndColor);
     142                 :          0 :         aGradient.SetSteps(static_cast<sal_uInt16>(aSize.Height()));
     143                 :            : 
     144                 :          0 :         DrawGradient(PixelToLogic(aPoly) ,aGradient);
     145                 :            :     }
     146                 :          0 :     if ( m_bMarked )
     147                 :            :     {
     148                 :          0 :         const long nCornerHeight = long(CORNER_SPACE * (double)GetMapMode().GetScaleY());
     149                 :            :         Rectangle aRect( Point(nCornerWidth,nCornerHeight),
     150                 :          0 :                          Size(aSize.Width() - nCornerWidth - nCornerWidth,aSize.Height() - nCornerHeight - nCornerHeight));
     151                 :          0 :         ColorChanger aColors( this, COL_WHITE, COL_WHITE );
     152                 :          0 :         DrawPolyLine(Polygon(PixelToLogic(aRect)),LineInfo(LINE_SOLID,2 ));
     153                 :            :     }
     154                 :          0 : }
     155                 :            : // -----------------------------------------------------------------------------
     156                 :          0 : void OStartMarker::setColor()
     157                 :            : {
     158                 :          0 :     const Color aColor(m_nColor);
     159                 :          0 :     Color aTextColor = GetTextColor();
     160                 :          0 :     if ( aColor.GetLuminance() < 128 )
     161                 :          0 :         aTextColor = COL_WHITE;
     162                 :          0 :     m_aText.SetTextColor(aTextColor);
     163                 :          0 :     m_aText.SetLineColor(m_nColor);
     164                 :          0 : }
     165                 :            : // -----------------------------------------------------------------------
     166                 :          0 : void OStartMarker::MouseButtonUp( const MouseEvent& rMEvt )
     167                 :            : {
     168                 :          0 :     if ( !rMEvt.IsLeft() )
     169                 :            :         return;
     170                 :            : 
     171                 :          0 :     Point aPos( rMEvt.GetPosPixel());
     172                 :            : 
     173                 :          0 :     const Size aOutputSize = GetOutputSizePixel();
     174                 :          0 :     if( aPos.X() > aOutputSize.Width() || aPos.Y() > aOutputSize.Height() )
     175                 :            :         return;
     176                 :          0 :     Rectangle aRect(m_aImage.GetPosPixel(),m_aImage.GetSizePixel());
     177                 :          0 :     if ( rMEvt.GetClicks() == 2 || aRect.IsInside( aPos ) )
     178                 :            :     {
     179                 :          0 :         m_bCollapsed = !m_bCollapsed;
     180                 :            : 
     181                 :          0 :         changeImage();
     182                 :            : 
     183                 :          0 :         m_aVRuler.Show(!m_bCollapsed && m_bShowRuler);
     184                 :          0 :         if ( m_aCollapsedLink.IsSet() )
     185                 :          0 :             m_aCollapsedLink.Call(this);
     186                 :            :     }
     187                 :            : 
     188                 :          0 :     m_pParent->showProperties();
     189                 :            : }
     190                 :            : // -----------------------------------------------------------------------------
     191                 :          0 : void OStartMarker::changeImage()
     192                 :            : {
     193                 :          0 :     Image* pImage = m_bCollapsed ? s_pDefCollapsed : s_pDefExpanded;
     194                 :          0 :     m_aImage.SetImage(*pImage);
     195                 :          0 : }
     196                 :            : // -----------------------------------------------------------------------
     197                 :          0 : void OStartMarker::initDefaultNodeImages()
     198                 :            : {
     199                 :          0 :     if ( !s_pDefCollapsed )
     200                 :            :     {
     201                 :          0 :         s_pDefCollapsed     = new Image( ModuleRes( RID_IMG_TREENODE_COLLAPSED      ) );
     202                 :          0 :         s_pDefExpanded      = new Image( ModuleRes( RID_IMG_TREENODE_EXPANDED       ) );
     203                 :            :     }
     204                 :            : 
     205                 :          0 :     Image* pImage = m_bCollapsed ? s_pDefCollapsed : s_pDefExpanded;
     206                 :          0 :     m_aImage.SetImage(*pImage);
     207                 :          0 :     m_aImage.SetMouseTransparent(sal_True);
     208                 :          0 :     m_aImage.SetBackground();
     209                 :          0 :     m_aText.SetBackground();
     210                 :          0 :     m_aText.SetMouseTransparent(sal_True);
     211                 :          0 : }
     212                 :            : // -----------------------------------------------------------------------
     213                 :          0 : void OStartMarker::ImplInitSettings()
     214                 :            : {
     215                 :          0 :     SetBackground( );
     216                 :          0 :     SetFillColor( Application::GetSettings().GetStyleSettings().GetDialogColor() );
     217                 :          0 :     setColor();
     218                 :          0 : }
     219                 :            : //------------------------------------------------------------------------------
     220                 :          0 : void OStartMarker::Resize()
     221                 :            : {
     222                 :          0 :     const Size aOutputSize( GetOutputSizePixel() );
     223                 :          0 :     const long nOutputWidth  = aOutputSize.Width();
     224                 :          0 :     const long nOutputHeight = aOutputSize.Height();
     225                 :            : 
     226                 :          0 :     const long nVRulerWidth = m_aVRuler.GetSizePixel().Width();
     227                 :          0 :     const Point aRulerPos(nOutputWidth - nVRulerWidth,0);
     228                 :          0 :     m_aVRuler.SetPosSizePixel(aRulerPos,Size(nVRulerWidth,nOutputHeight));
     229                 :            : 
     230                 :          0 :     Size aImageSize = m_aImage.GetImage().GetSizePixel();
     231                 :          0 :     const MapMode& rMapMode = GetMapMode();
     232                 :          0 :     aImageSize.Width() = long(aImageSize.Width() * (double)rMapMode.GetScaleX());
     233                 :          0 :     aImageSize.Height() = long(aImageSize.Height() * (double)rMapMode.GetScaleY());
     234                 :            : 
     235                 :          0 :     Fraction aExtraWidth(long(REPORT_EXTRA_SPACE));
     236                 :          0 :     aExtraWidth *= rMapMode.GetScaleX();
     237                 :            : 
     238                 :          0 :     Point aPos(aImageSize.Width() + (long)(aExtraWidth + aExtraWidth), aExtraWidth);
     239                 :          0 :     const long nHeight = ::std::max<sal_Int32>(nOutputHeight - 2*aPos.Y(),LogicToPixel(Size(0,m_aText.GetTextHeight())).Height());
     240                 :          0 :     m_aText.SetPosSizePixel(aPos,Size(aRulerPos.X() - aPos.X(),nHeight));
     241                 :            : 
     242                 :          0 :     aPos.X() = aExtraWidth;
     243                 :          0 :     aPos.Y() += static_cast<sal_Int32>((LogicToPixel(Size(0,m_aText.GetTextHeight())).Height() - aImageSize.Height()) * 0.5) ;
     244                 :          0 :     m_aImage.SetPosSizePixel(aPos,aImageSize);
     245                 :          0 : }
     246                 :            : // -----------------------------------------------------------------------------
     247                 :          0 : void OStartMarker::setTitle(const String& _sTitle)
     248                 :            : {
     249                 :          0 :     m_aText.SetText(_sTitle);
     250                 :          0 : }
     251                 :            : // -----------------------------------------------------------------------------
     252                 :          0 : void OStartMarker::Notify(SfxBroadcaster & rBc, SfxHint const & rHint)
     253                 :            : {
     254                 :          0 :     OColorListener::Notify(rBc, rHint);
     255                 :          0 :     if (rHint.ISA(SfxSimpleHint)
     256                 :          0 :         && (static_cast< SfxSimpleHint const & >(rHint).GetId()
     257                 :            :             == SFX_HINT_COLORS_CHANGED))
     258                 :            :     {
     259                 :          0 :         setColor();
     260                 :          0 :         Invalidate(INVALIDATE_CHILDREN);
     261                 :            :     }
     262                 :          0 : }
     263                 :            : //----------------------------------------------------------------------------
     264                 :          0 : void OStartMarker::showRuler(sal_Bool _bShow)
     265                 :            : {
     266                 :          0 :     m_bShowRuler = _bShow;
     267                 :          0 :     m_aVRuler.Show(!m_bCollapsed && m_bShowRuler);
     268                 :          0 : }
     269                 :            : //------------------------------------------------------------------------------
     270                 :          0 : void OStartMarker::RequestHelp( const HelpEvent& rHEvt )
     271                 :            : {
     272                 :          0 :     if( m_aText.GetText().Len())
     273                 :            :     {
     274                 :            :         // Hilfe anzeigen
     275                 :          0 :         Rectangle aItemRect(rHEvt.GetMousePosPixel(),Size(GetSizePixel().Width(),getMinHeight()));
     276                 :          0 :         Point aPt = OutputToScreenPixel( aItemRect.TopLeft() );
     277                 :          0 :         aItemRect.Left()   = aPt.X();
     278                 :          0 :         aItemRect.Top()    = aPt.Y();
     279                 :          0 :         aPt = OutputToScreenPixel( aItemRect.BottomRight() );
     280                 :          0 :         aItemRect.Right()  = aPt.X();
     281                 :          0 :         aItemRect.Bottom() = aPt.Y();
     282                 :          0 :         if( rHEvt.GetMode() == HELPMODE_BALLOON )
     283                 :          0 :             Help::ShowBalloon( this, aItemRect.Center(), aItemRect, m_aText.GetText());
     284                 :            :         else
     285                 :          0 :             Help::ShowQuickHelp( this, aItemRect, m_aText.GetText() );
     286                 :            :     }
     287                 :          0 : }
     288                 :            : // -----------------------------------------------------------------------------
     289                 :          0 : void OStartMarker::setCollapsed(sal_Bool _bCollapsed)
     290                 :            : {
     291                 :          0 :     OColorListener::setCollapsed(_bCollapsed);
     292                 :          0 :     showRuler(_bCollapsed);
     293                 :          0 :     changeImage();
     294                 :          0 : }
     295                 :            : // -----------------------------------------------------------------------
     296                 :          0 : void OStartMarker::zoom(const Fraction& _aZoom)
     297                 :            : {
     298                 :          0 :     setZoomFactor(_aZoom,*this);
     299                 :          0 :     m_aVRuler.SetZoom(_aZoom);
     300                 :          0 :     setZoomFactor(_aZoom,m_aText);
     301                 :          0 :     Resize();
     302                 :          0 :     Invalidate();
     303                 :          0 : }
     304                 :            : // -----------------------------------------------------------------------
     305                 :            : // =======================================================================
     306                 :            : }
     307                 :            : // =======================================================================
     308                 :            : 
     309                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10