LCOV - code coverage report
Current view: top level - sd/source/ui/dlg - dlgsnap.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 90 0.0 %
Date: 2012-08-25 Functions: 0 6 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                 :            : 
      29                 :            : 
      30                 :            : #ifdef SD_DLLIMPLEMENTATION
      31                 :            : #undef SD_DLLIMPLEMENTATION
      32                 :            : #endif
      33                 :            : 
      34                 :            : 
      35                 :            : #include <svx/svxids.hrc>
      36                 :            : #include <svx/dlgutil.hxx>
      37                 :            : #include <svl/itempool.hxx>
      38                 :            : #include <svl/aeitem.hxx>
      39                 :            : 
      40                 :            : #include "dlgsnap.hrc"
      41                 :            : #include "sdattr.hxx"
      42                 :            : #include "View.hxx"
      43                 :            : #include "sdresid.hxx"
      44                 :            : #include "drawdoc.hxx"
      45                 :            : #include "dlgsnap.hxx"
      46                 :            : 
      47                 :            : 
      48                 :            : /*************************************************************************
      49                 :            : |*
      50                 :            : |* Dialog zum Einstellen des Rasters (wohl kaum ESO!)
      51                 :            : |*
      52                 :            : \************************************************************************/
      53                 :            : 
      54                 :          0 : SdSnapLineDlg::SdSnapLineDlg(
      55                 :            :     ::Window* pWindow,
      56                 :            :     const SfxItemSet& rInAttrs,
      57                 :            :     ::sd::View* pView)
      58                 :            :     : ModalDialog (pWindow, SdResId(DLG_SNAPLINE)),
      59                 :            :       aFlPos      (this, SdResId(FL_POSITION)),
      60                 :            :       aFtX        (this, SdResId(FT_X)),
      61                 :            :       aMtrFldX    (this, SdResId(MTR_FLD_X)),
      62                 :            :       aFtY        (this, SdResId(FT_Y)),
      63                 :            :       aMtrFldY    (this, SdResId(MTR_FLD_Y)),
      64                 :            :       aFlDir      (this, SdResId(FL_DIRECTION)),
      65                 :            :       aRbPoint    (this, SdResId(RB_POINT)),
      66                 :            :       aRbVert     (this, SdResId(RB_VERTICAL)),
      67                 :            :       aRbHorz     (this, SdResId(RB_HORIZONTAL)),
      68                 :            :       aBtnOK      (this, SdResId(BTN_OK)),
      69                 :            :       aBtnCancel  (this, SdResId(BTN_CANCEL)),
      70                 :            :       aBtnHelp    (this, SdResId(BTN_HELP)),
      71                 :            :       aBtnDelete  (this, SdResId(BTN_DELETE)),
      72                 :          0 :       eUIUnit(pView->GetDoc().GetUIUnit()),
      73                 :          0 :       aUIScale(pView->GetDoc().GetUIScale())
      74                 :            : {
      75                 :          0 :     FreeResource();
      76                 :            : 
      77                 :          0 :     aRbHorz.SetClickHdl(LINK(this, SdSnapLineDlg, ClickHdl));
      78                 :          0 :     aRbVert.SetClickHdl(LINK(this, SdSnapLineDlg, ClickHdl));
      79                 :          0 :     aRbPoint.SetClickHdl(LINK(this, SdSnapLineDlg, ClickHdl));
      80                 :            : 
      81                 :          0 :     aBtnDelete.SetClickHdl(LINK(this, SdSnapLineDlg, ClickHdl));
      82                 :            : 
      83                 :          0 :     SetFieldUnit( aMtrFldX, eUIUnit, sal_True );
      84                 :          0 :     SetFieldUnit( aMtrFldY, eUIUnit, sal_True );
      85                 :            : 
      86                 :            :     // WorkArea holen
      87                 :          0 :     Rectangle aWorkArea = pView->GetWorkArea();
      88                 :            : 
      89                 :            :     // PoolUnit ermitteln
      90                 :          0 :     SfxItemPool* pPool = rInAttrs.GetPool();
      91                 :            :     DBG_ASSERT( pPool, "Wo ist der Pool?" );
      92                 :          0 :     SfxMapUnit ePoolUnit = pPool->GetMetric( SID_ATTR_FILL_HATCH );
      93                 :            : 
      94                 :            :     // #i48497# Consider page origin
      95                 :          0 :     SdrPageView* pPV = pView->GetSdrPageView();
      96                 :          0 :     Point aLeftTop(aWorkArea.Left()+1, aWorkArea.Top()+1);
      97                 :          0 :     pPV->LogicToPagePos(aLeftTop);
      98                 :          0 :     Point aRightBottom(aWorkArea.Right()-2, aWorkArea.Bottom()-2);
      99                 :          0 :     pPV->LogicToPagePos(aRightBottom);
     100                 :            : 
     101                 :            :     // Hier werden die Max- und MinWerte in Abhaengigkeit von der
     102                 :            :     // WorkArea, PoolUnit und der FieldUnit:
     103                 :          0 :     SetMetricValue( aMtrFldX, aLeftTop.X(), ePoolUnit );
     104                 :            : 
     105                 :          0 :     long nValue = static_cast<long>(aMtrFldX.GetValue());
     106                 :          0 :     nValue = Fraction( nValue ) / aUIScale;
     107                 :          0 :     aMtrFldX.SetMin( nValue );
     108                 :          0 :     aMtrFldX.SetFirst( nValue );
     109                 :            : 
     110                 :          0 :     SetMetricValue( aMtrFldX, aRightBottom.X(), ePoolUnit );
     111                 :          0 :     nValue = static_cast<long>(aMtrFldX.GetValue());
     112                 :          0 :     nValue = Fraction( nValue ) / aUIScale;
     113                 :          0 :     aMtrFldX.SetMax( nValue );
     114                 :          0 :     aMtrFldX.SetLast( nValue );
     115                 :            : 
     116                 :          0 :     SetMetricValue( aMtrFldY, aLeftTop.Y(), ePoolUnit );
     117                 :          0 :     nValue = static_cast<long>(aMtrFldY.GetValue());
     118                 :          0 :     nValue = Fraction( nValue ) / aUIScale;
     119                 :          0 :     aMtrFldY.SetMin( nValue );
     120                 :          0 :     aMtrFldY.SetFirst( nValue );
     121                 :            : 
     122                 :          0 :     SetMetricValue( aMtrFldY, aRightBottom.Y(), ePoolUnit );
     123                 :          0 :     nValue = static_cast<long>(aMtrFldY.GetValue());
     124                 :          0 :     nValue = Fraction( nValue ) / aUIScale;
     125                 :          0 :     aMtrFldY.SetMax( nValue );
     126                 :          0 :     aMtrFldY.SetLast( nValue );
     127                 :            : 
     128                 :            :     // Setzen der Werte
     129                 :          0 :     nXValue = ((const SfxUInt32Item&) rInAttrs.Get(ATTR_SNAPLINE_X)).GetValue();
     130                 :          0 :     nYValue = ((const SfxUInt32Item&) rInAttrs.Get(ATTR_SNAPLINE_Y)).GetValue();
     131                 :          0 :     nXValue = Fraction(nXValue) / aUIScale;
     132                 :          0 :     nYValue = Fraction(nYValue) / aUIScale;
     133                 :          0 :     SetMetricValue( aMtrFldX, nXValue, SFX_MAPUNIT_100TH_MM);
     134                 :          0 :     SetMetricValue( aMtrFldY, nYValue, SFX_MAPUNIT_100TH_MM);
     135                 :            : 
     136                 :          0 :     aRbPoint.Check();
     137                 :          0 : }
     138                 :            : 
     139                 :            : /*************************************************************************
     140                 :            : |*
     141                 :            : |* Fuellt uebergebenes Item-Set mit Dialogbox-Attributen
     142                 :            : |*
     143                 :            : \************************************************************************/
     144                 :            : 
     145                 :          0 : IMPL_LINK( SdSnapLineDlg, ClickHdl, Button *, pBtn )
     146                 :            : {
     147                 :          0 :     if ( pBtn == &aRbPoint )        SetInputFields(sal_True, sal_True);
     148                 :          0 :     else if ( pBtn == &aRbHorz )    SetInputFields(sal_False, sal_True);
     149                 :          0 :     else if ( pBtn == &aRbVert )    SetInputFields(sal_True, sal_False);
     150                 :          0 :     else if ( pBtn == &aBtnDelete ) EndDialog(RET_SNAP_DELETE);
     151                 :            : 
     152                 :          0 :     return 0;
     153                 :            : }
     154                 :            : 
     155                 :            : /*************************************************************************
     156                 :            : |*
     157                 :            : |* Fuellt uebergebenes Item-Set mit Dialogbox-Attributen
     158                 :            : |*
     159                 :            : \************************************************************************/
     160                 :            : 
     161                 :          0 : void SdSnapLineDlg::GetAttr(SfxItemSet& rOutAttrs)
     162                 :            : {
     163                 :            :     SnapKind eKind;
     164                 :            : 
     165                 :          0 :     if ( aRbHorz.IsChecked() )      eKind = SK_HORIZONTAL;
     166                 :          0 :     else if ( aRbVert.IsChecked() ) eKind = SK_VERTICAL;
     167                 :          0 :     else                            eKind = SK_POINT;
     168                 :            : 
     169                 :          0 :     nXValue = Fraction( GetCoreValue( aMtrFldX, SFX_MAPUNIT_100TH_MM) ) * aUIScale;
     170                 :          0 :     nYValue = Fraction( GetCoreValue( aMtrFldY, SFX_MAPUNIT_100TH_MM) ) * aUIScale;
     171                 :            : 
     172                 :          0 :     rOutAttrs.Put(SfxAllEnumItem(ATTR_SNAPLINE_KIND, (sal_uInt16)eKind));
     173                 :          0 :     rOutAttrs.Put(SfxUInt32Item(ATTR_SNAPLINE_X, nXValue));
     174                 :          0 :     rOutAttrs.Put(SfxUInt32Item(ATTR_SNAPLINE_Y, nYValue));
     175                 :          0 : }
     176                 :            : 
     177                 :            : /*************************************************************************
     178                 :            : |*
     179                 :            : |* Gruppe mit Radiobutton verstecken
     180                 :            : |*
     181                 :            : \************************************************************************/
     182                 :            : 
     183                 :          0 : void SdSnapLineDlg::HideRadioGroup()
     184                 :            : {
     185                 :          0 :     aFlDir.Hide();
     186                 :          0 :     aRbHorz.Hide();
     187                 :          0 :     aRbVert.Hide();
     188                 :          0 :     aRbPoint.Hide();
     189                 :          0 : }
     190                 :            : 
     191                 :            : /*************************************************************************
     192                 :            : |*
     193                 :            : |* X- bzw. Y-Inputfeld disablen
     194                 :            : |*
     195                 :            : \************************************************************************/
     196                 :            : 
     197                 :          0 : void SdSnapLineDlg::SetInputFields(sal_Bool bEnableX, sal_Bool bEnableY)
     198                 :            : {
     199                 :          0 :     if ( bEnableX )
     200                 :            :     {
     201                 :          0 :         if ( !aMtrFldX.IsEnabled() )
     202                 :          0 :             aMtrFldX.SetValue(nXValue);
     203                 :          0 :         aMtrFldX.Enable();
     204                 :          0 :         aFtX.Enable();
     205                 :            :     }
     206                 :          0 :     else if ( aMtrFldX.IsEnabled() )
     207                 :            :     {
     208                 :          0 :         nXValue = static_cast<long>(aMtrFldX.GetValue());
     209                 :          0 :         aMtrFldX.SetText(String());
     210                 :          0 :         aMtrFldX.Disable();
     211                 :          0 :         aFtX.Disable();
     212                 :            :     }
     213                 :          0 :     if ( bEnableY )
     214                 :            :     {
     215                 :          0 :         if ( !aMtrFldY.IsEnabled() )
     216                 :          0 :             aMtrFldY.SetValue(nYValue);
     217                 :          0 :         aMtrFldY.Enable();
     218                 :          0 :         aFtY.Enable();
     219                 :            :     }
     220                 :          0 :     else if ( aMtrFldY.IsEnabled() )
     221                 :            :     {
     222                 :          0 :         nYValue = static_cast<long>(aMtrFldY.GetValue());
     223                 :          0 :         aMtrFldY.SetText(String());
     224                 :          0 :         aMtrFldY.Disable();
     225                 :          0 :         aFtY.Disable();
     226                 :            :     }
     227                 :          0 : }
     228                 :            : 
     229                 :            : 
     230                 :            : 
     231                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10