LCOV - code coverage report
Current view: top level - dbaccess/source/ui/control - curledit.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 56 0.0 %
Date: 2012-08-25 Functions: 0 9 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 110 0.0 %

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

Generated by: LCOV version 1.10