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

Generated by: LCOV version 1.10