LCOV - code coverage report
Current view: top level - dbaccess/source/ui/control - curledit.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 55 0.0 %
Date: 2014-04-14 Functions: 0 9 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 "curledit.hxx"
      21             : #include <vcl/svapp.hxx>
      22             : #include <vcl/settings.hxx>
      23             : #include <osl/diagnose.h>
      24             : 
      25             : namespace dbaui
      26             : {
      27             : // OConnectionURLEdit
      28           0 : OConnectionURLEdit::OConnectionURLEdit(Window* _pParent, const ResId& _rResId,sal_Bool _bShowPrefix)
      29             :     :Edit(_pParent, _rResId)
      30             :     ,m_pTypeCollection(NULL)
      31             :     ,m_pForcedPrefix(NULL)
      32           0 :     ,m_bShowPrefix(_bShowPrefix)
      33             : {
      34           0 : }
      35             : 
      36           0 : OConnectionURLEdit::~OConnectionURLEdit()
      37             : {
      38             :     // delete my sub controls
      39           0 :     Edit* pSubEdit = GetSubEdit();
      40           0 :     SetSubEdit(NULL);
      41           0 :     delete pSubEdit;
      42           0 :     delete m_pForcedPrefix;
      43           0 : }
      44             : 
      45           0 : void OConnectionURLEdit::SetTextNoPrefix(const OUString& _rText)
      46             : {
      47             :     OSL_ENSURE(GetSubEdit(), "OConnectionURLEdit::SetTextNoPrefix: have no current type, not changing the text!");
      48           0 :     if (GetSubEdit())
      49           0 :         GetSubEdit()->SetText(_rText);
      50           0 : }
      51             : 
      52           0 : OUString OConnectionURLEdit::GetTextNoPrefix() const
      53             : {
      54           0 :     if (GetSubEdit())
      55           0 :         return GetSubEdit()->GetText();
      56           0 :     return GetText();
      57             : }
      58             : 
      59           0 : void OConnectionURLEdit::SetText(const OUString& _rStr)
      60             : {
      61           0 :     Selection aNoSelection(0,0);
      62           0 :     SetText(_rStr, aNoSelection);
      63           0 : }
      64             : 
      65           0 : void OConnectionURLEdit::SetText(const OUString& _rStr, const Selection& /*_rNewSelection*/)
      66             : {
      67             :     // create new sub controls, if necessary
      68           0 :     if (!GetSubEdit())
      69           0 :         SetSubEdit(new Edit(this, 0));
      70           0 :     if ( !m_pForcedPrefix )
      71             :     {
      72           0 :         m_pForcedPrefix = new FixedText(this, WB_VCENTER);
      73             : 
      74             :         // we use a gray background for the fixed text
      75           0 :         StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings();
      76           0 :         m_pForcedPrefix->SetBackground(Wallpaper(aSystemStyle.GetDialogColor()));
      77             :     }
      78             : 
      79           0 :     m_pForcedPrefix->Show(m_bShowPrefix);
      80             : 
      81           0 :     sal_Bool bIsEmpty = _rStr.isEmpty();
      82             :     // calc the prefix
      83           0 :     OUString sPrefix;
      84           0 :     if (!bIsEmpty)
      85             :     {
      86             :         // determine the type of the new URL described by the new text
      87           0 :         sPrefix = m_pTypeCollection->getPrefix(_rStr);
      88             :     }
      89             : 
      90             :     // the fixed text gets the prefix
      91           0 :     m_pForcedPrefix->SetText(sPrefix);
      92             : 
      93             :     // both subs have to be resized according to the text len of the prefix
      94           0 :     Size aMySize = GetSizePixel();
      95           0 :     sal_Int32 nTextWidth = 0;
      96           0 :     if ( m_pForcedPrefix && m_bShowPrefix)
      97             :     {
      98           0 :         nTextWidth = m_pForcedPrefix->GetTextWidth(sPrefix) + 2;
      99           0 :         m_pForcedPrefix->SetPosSizePixel(Point(0, -2), Size(nTextWidth, aMySize.Height()));
     100             :     }
     101           0 :     GetSubEdit()->SetPosSizePixel(Point(nTextWidth, -2), Size(aMySize.Width() - nTextWidth - 4, aMySize.Height()));
     102             :         // -2 because the edit has a frame which is 2 pixel wide ... should not be necessary, but I don't fully understand this ....
     103             : 
     104             :     // show the sub controls (in case they were just created)
     105           0 :     GetSubEdit()->Show();
     106             : 
     107             :     // do the real SetTex
     108             : //  Edit::SetText(bIsEmpty ? _rStr : m_pTypeCollection->cutPrefix(_rStr), _rNewSelection);
     109           0 :     OUString sNewText( _rStr );
     110           0 :     if ( !bIsEmpty )
     111           0 :         sNewText  = m_pTypeCollection->cutPrefix( _rStr );
     112           0 :     Edit::SetText( sNewText );
     113           0 : }
     114             : 
     115           0 : OUString OConnectionURLEdit::GetText() const
     116             : {
     117           0 :     if ( m_pForcedPrefix )
     118           0 :         return m_pForcedPrefix->GetText() += Edit::GetText();
     119           0 :     return Edit::GetText();
     120             : }
     121             : 
     122           0 : void OConnectionURLEdit::ShowPrefix(sal_Bool _bShowPrefix)
     123             : {
     124           0 :     m_bShowPrefix = _bShowPrefix;
     125           0 :     if ( m_pForcedPrefix )
     126           0 :         m_pForcedPrefix->Show(m_bShowPrefix);
     127           0 : }
     128             : 
     129             : }   // namespace dbaui
     130             : 
     131             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10