LCOV - code coverage report
Current view: top level - sd/source/ui/dlg - dlgsnap.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 95 0.0 %
Date: 2014-11-03 Functions: 0 8 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 <svx/svxids.hrc>
      21             : #include <svx/dlgutil.hxx>
      22             : #include <svl/itempool.hxx>
      23             : #include <svl/aeitem.hxx>
      24             : 
      25             : #include "sdattr.hxx"
      26             : #include "View.hxx"
      27             : #include "sdresid.hxx"
      28             : #include "drawdoc.hxx"
      29             : #include "dlgsnap.hxx"
      30             : 
      31             : /**
      32             :  * dialog to adjust grid (scarcely ESO!)
      33             :  */
      34           0 : SdSnapLineDlg::SdSnapLineDlg(
      35             :     vcl::Window* pWindow,
      36             :     const SfxItemSet& rInAttrs,
      37             :     ::sd::View* pView)
      38             :     : ModalDialog(pWindow, "SnapObjectDialog", "modules/sdraw/ui/dlgsnap.ui")
      39           0 :     , eUIUnit(pView->GetDoc().GetUIUnit())
      40           0 :     , aUIScale(pView->GetDoc().GetUIScale())
      41             : {
      42           0 :     get(m_pFtX, "xlabel");
      43           0 :     get(m_pMtrFldX, "x");
      44           0 :     get(m_pFtY, "ylabel");
      45           0 :     get(m_pMtrFldY, "y");
      46           0 :     get(m_pRadioGroup, "radiogroup");
      47           0 :     get(m_pRbPoint, "point");
      48           0 :     get(m_pRbVert, "vert");
      49           0 :     get(m_pRbHorz, "horz");
      50           0 :     get(m_pBtnDelete, "delete");
      51             : 
      52           0 :     m_pRbHorz->SetClickHdl(LINK(this, SdSnapLineDlg, ClickHdl));
      53           0 :     m_pRbVert->SetClickHdl(LINK(this, SdSnapLineDlg, ClickHdl));
      54           0 :     m_pRbPoint->SetClickHdl(LINK(this, SdSnapLineDlg, ClickHdl));
      55             : 
      56           0 :     m_pBtnDelete->SetClickHdl(LINK(this, SdSnapLineDlg, ClickHdl));
      57             : 
      58           0 :     SetFieldUnit( *m_pMtrFldX, eUIUnit, true );
      59           0 :     SetFieldUnit( *m_pMtrFldY, eUIUnit, true );
      60             : 
      61             :     // get WorkArea
      62           0 :     Rectangle aWorkArea = pView->GetWorkArea();
      63             : 
      64             :     // determine PoolUnit
      65           0 :     SfxItemPool* pPool = rInAttrs.GetPool();
      66             :     DBG_ASSERT( pPool, "Where's the Pool?" );
      67           0 :     SfxMapUnit ePoolUnit = pPool->GetMetric( SID_ATTR_FILL_HATCH );
      68             : 
      69             :     // #i48497# Consider page origin
      70           0 :     SdrPageView* pPV = pView->GetSdrPageView();
      71           0 :     Point aLeftTop(aWorkArea.Left()+1, aWorkArea.Top()+1);
      72           0 :     pPV->LogicToPagePos(aLeftTop);
      73           0 :     Point aRightBottom(aWorkArea.Right()-2, aWorkArea.Bottom()-2);
      74           0 :     pPV->LogicToPagePos(aRightBottom);
      75             : 
      76             :     // determine max and min values depending on
      77             :     // WorkArea, PoolUnit and FieldUnit:
      78           0 :     SetMetricValue( *m_pMtrFldX, aLeftTop.X(), ePoolUnit );
      79             : 
      80           0 :     long nValue = static_cast<long>(m_pMtrFldX->GetValue());
      81           0 :     nValue = Fraction( nValue ) / aUIScale;
      82           0 :     m_pMtrFldX->SetMin( nValue );
      83           0 :     m_pMtrFldX->SetFirst( nValue );
      84             : 
      85           0 :     SetMetricValue( *m_pMtrFldX, aRightBottom.X(), ePoolUnit );
      86           0 :     nValue = static_cast<long>(m_pMtrFldX->GetValue());
      87           0 :     nValue = Fraction( nValue ) / aUIScale;
      88           0 :     m_pMtrFldX->SetMax( nValue );
      89           0 :     m_pMtrFldX->SetLast( nValue );
      90             : 
      91           0 :     SetMetricValue( *m_pMtrFldY, aLeftTop.Y(), ePoolUnit );
      92           0 :     nValue = static_cast<long>(m_pMtrFldY->GetValue());
      93           0 :     nValue = Fraction( nValue ) / aUIScale;
      94           0 :     m_pMtrFldY->SetMin( nValue );
      95           0 :     m_pMtrFldY->SetFirst( nValue );
      96             : 
      97           0 :     SetMetricValue( *m_pMtrFldY, aRightBottom.Y(), ePoolUnit );
      98           0 :     nValue = static_cast<long>(m_pMtrFldY->GetValue());
      99           0 :     nValue = Fraction( nValue ) / aUIScale;
     100           0 :     m_pMtrFldY->SetMax( nValue );
     101           0 :     m_pMtrFldY->SetLast( nValue );
     102             : 
     103             :     // set values
     104           0 :     nXValue = ((const SfxInt32Item&) rInAttrs.Get(ATTR_SNAPLINE_X)).GetValue();
     105           0 :     nYValue = ((const SfxInt32Item&) rInAttrs.Get(ATTR_SNAPLINE_Y)).GetValue();
     106           0 :     nXValue = Fraction(nXValue) / aUIScale;
     107           0 :     nYValue = Fraction(nYValue) / aUIScale;
     108           0 :     SetMetricValue( *m_pMtrFldX, nXValue, SFX_MAPUNIT_100TH_MM);
     109           0 :     SetMetricValue( *m_pMtrFldY, nYValue, SFX_MAPUNIT_100TH_MM);
     110             : 
     111           0 :     m_pRbPoint->Check();
     112           0 : }
     113             : 
     114             : /**
     115             :  * fills provided item sets with dialog box attributes
     116             :  */
     117           0 : IMPL_LINK( SdSnapLineDlg, ClickHdl, Button *, pBtn )
     118             : {
     119           0 :     if ( pBtn == m_pRbPoint )        SetInputFields(true, true);
     120           0 :     else if ( pBtn == m_pRbHorz )    SetInputFields(false, true);
     121           0 :     else if ( pBtn == m_pRbVert )    SetInputFields(true, false);
     122           0 :     else if ( pBtn == m_pBtnDelete ) EndDialog(RET_SNAP_DELETE);
     123             : 
     124           0 :     return 0;
     125             : }
     126             : 
     127             : /**
     128             :  * fills provided item sets with dialog box attributes
     129             :  */
     130           0 : void SdSnapLineDlg::GetAttr(SfxItemSet& rOutAttrs)
     131             : {
     132             :     SnapKind eKind;
     133             : 
     134           0 :     if ( m_pRbHorz->IsChecked() )      eKind = SK_HORIZONTAL;
     135           0 :     else if ( m_pRbVert->IsChecked() ) eKind = SK_VERTICAL;
     136           0 :     else                            eKind = SK_POINT;
     137             : 
     138           0 :     nXValue = Fraction( GetCoreValue( *m_pMtrFldX, SFX_MAPUNIT_100TH_MM) ) * aUIScale;
     139           0 :     nYValue = Fraction( GetCoreValue( *m_pMtrFldY, SFX_MAPUNIT_100TH_MM) ) * aUIScale;
     140             : 
     141           0 :     rOutAttrs.Put(SfxAllEnumItem(ATTR_SNAPLINE_KIND, (sal_uInt16)eKind));
     142           0 :     rOutAttrs.Put(SfxUInt32Item(ATTR_SNAPLINE_X, nXValue));
     143           0 :     rOutAttrs.Put(SfxUInt32Item(ATTR_SNAPLINE_Y, nYValue));
     144           0 : }
     145             : 
     146           0 : void SdSnapLineDlg::HideRadioGroup()
     147             : {
     148           0 :     m_pRadioGroup->Hide();
     149           0 : }
     150             : 
     151             : /**
     152             :  * disable X or Y input fields
     153             :  */
     154           0 : void SdSnapLineDlg::SetInputFields(bool bEnableX, bool bEnableY)
     155             : {
     156           0 :     if ( bEnableX )
     157             :     {
     158           0 :         if ( !m_pMtrFldX->IsEnabled() )
     159           0 :             m_pMtrFldX->SetValue(nXValue);
     160           0 :         m_pMtrFldX->Enable();
     161           0 :         m_pFtX->Enable();
     162             :     }
     163           0 :     else if ( m_pMtrFldX->IsEnabled() )
     164             :     {
     165           0 :         nXValue = static_cast<long>(m_pMtrFldX->GetValue());
     166           0 :         m_pMtrFldX->SetText(OUString());
     167           0 :         m_pMtrFldX->Disable();
     168           0 :         m_pFtX->Disable();
     169             :     }
     170           0 :     if ( bEnableY )
     171             :     {
     172           0 :         if ( !m_pMtrFldY->IsEnabled() )
     173           0 :             m_pMtrFldY->SetValue(nYValue);
     174           0 :         m_pMtrFldY->Enable();
     175           0 :         m_pFtY->Enable();
     176             :     }
     177           0 :     else if ( m_pMtrFldY->IsEnabled() )
     178             :     {
     179           0 :         nYValue = static_cast<long>(m_pMtrFldY->GetValue());
     180           0 :         m_pMtrFldY->SetText(OUString());
     181           0 :         m_pMtrFldY->Disable();
     182           0 :         m_pFtY->Disable();
     183             :     }
     184           0 : }
     185             : 
     186             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10