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

Generated by: LCOV version 1.11