LCOV - code coverage report
Current view: top level - sd/source/ui/dlg - dlgsnap.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 110 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 11 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 = static_cast<const SfxInt32Item&>( rInAttrs.Get(ATTR_SNAPLINE_X)).GetValue();
     105           0 :     nYValue = static_cast<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           0 : SdSnapLineDlg::~SdSnapLineDlg()
     115             : {
     116           0 :     disposeOnce();
     117           0 : }
     118             : 
     119           0 : void SdSnapLineDlg::dispose()
     120             : {
     121           0 :     m_pFtX.clear();
     122           0 :     m_pMtrFldX.clear();
     123           0 :     m_pFtY.clear();
     124           0 :     m_pMtrFldY.clear();
     125           0 :     m_pRadioGroup.clear();
     126           0 :     m_pRbPoint.clear();
     127           0 :     m_pRbVert.clear();
     128           0 :     m_pRbHorz.clear();
     129           0 :     m_pBtnDelete.clear();
     130           0 :     ModalDialog::dispose();
     131           0 : }
     132             : 
     133             : /**
     134             :  * fills provided item sets with dialog box attributes
     135             :  */
     136           0 : IMPL_LINK( SdSnapLineDlg, ClickHdl, Button *, pBtn )
     137             : {
     138           0 :     if ( pBtn == m_pRbPoint )        SetInputFields(true, true);
     139           0 :     else if ( pBtn == m_pRbHorz )    SetInputFields(false, true);
     140           0 :     else if ( pBtn == m_pRbVert )    SetInputFields(true, false);
     141           0 :     else if ( pBtn == m_pBtnDelete ) EndDialog(RET_SNAP_DELETE);
     142             : 
     143           0 :     return 0;
     144             : }
     145             : 
     146             : /**
     147             :  * fills provided item sets with dialog box attributes
     148             :  */
     149           0 : void SdSnapLineDlg::GetAttr(SfxItemSet& rOutAttrs)
     150             : {
     151             :     SnapKind eKind;
     152             : 
     153           0 :     if ( m_pRbHorz->IsChecked() )      eKind = SK_HORIZONTAL;
     154           0 :     else if ( m_pRbVert->IsChecked() ) eKind = SK_VERTICAL;
     155           0 :     else                            eKind = SK_POINT;
     156             : 
     157           0 :     nXValue = Fraction( GetCoreValue( *m_pMtrFldX, SFX_MAPUNIT_100TH_MM) ) * aUIScale;
     158           0 :     nYValue = Fraction( GetCoreValue( *m_pMtrFldY, SFX_MAPUNIT_100TH_MM) ) * aUIScale;
     159             : 
     160           0 :     rOutAttrs.Put(SfxAllEnumItem(ATTR_SNAPLINE_KIND, (sal_uInt16)eKind));
     161           0 :     rOutAttrs.Put(SfxUInt32Item(ATTR_SNAPLINE_X, nXValue));
     162           0 :     rOutAttrs.Put(SfxUInt32Item(ATTR_SNAPLINE_Y, nYValue));
     163           0 : }
     164             : 
     165           0 : void SdSnapLineDlg::HideRadioGroup()
     166             : {
     167           0 :     m_pRadioGroup->Hide();
     168           0 : }
     169             : 
     170             : /**
     171             :  * disable X or Y input fields
     172             :  */
     173           0 : void SdSnapLineDlg::SetInputFields(bool bEnableX, bool bEnableY)
     174             : {
     175           0 :     if ( bEnableX )
     176             :     {
     177           0 :         if ( !m_pMtrFldX->IsEnabled() )
     178           0 :             m_pMtrFldX->SetValue(nXValue);
     179           0 :         m_pMtrFldX->Enable();
     180           0 :         m_pFtX->Enable();
     181             :     }
     182           0 :     else if ( m_pMtrFldX->IsEnabled() )
     183             :     {
     184           0 :         nXValue = static_cast<long>(m_pMtrFldX->GetValue());
     185           0 :         m_pMtrFldX->SetText(OUString());
     186           0 :         m_pMtrFldX->Disable();
     187           0 :         m_pFtX->Disable();
     188             :     }
     189           0 :     if ( bEnableY )
     190             :     {
     191           0 :         if ( !m_pMtrFldY->IsEnabled() )
     192           0 :             m_pMtrFldY->SetValue(nYValue);
     193           0 :         m_pMtrFldY->Enable();
     194           0 :         m_pFtY->Enable();
     195             :     }
     196           0 :     else if ( m_pMtrFldY->IsEnabled() )
     197             :     {
     198           0 :         nYValue = static_cast<long>(m_pMtrFldY->GetValue());
     199           0 :         m_pMtrFldY->SetText(OUString());
     200           0 :         m_pMtrFldY->Disable();
     201           0 :         m_pFtY->Disable();
     202             :     }
     203           0 : }
     204             : 
     205             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11