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

Generated by: LCOV version 1.10