LCOV - code coverage report
Current view: top level - svtools/source/hatchwindow - hatchwindow.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 46 86 53.5 %
Date: 2015-06-13 12:38:46 Functions: 11 20 55.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 <com/sun/star/embed/XHatchWindowController.hpp>
      21             : 
      22             : #include "hatchwindow.hxx"
      23             : #include "ipwin.hxx"
      24             : 
      25             : #include <toolkit/helper/convert.hxx>
      26             : #include <cppuhelper/queryinterface.hxx>
      27             : #include <osl/mutex.hxx>
      28             : #include <vcl/svapp.hxx>
      29             : 
      30             : using namespace ::com::sun::star;
      31             : 
      32           1 : VCLXHatchWindow::VCLXHatchWindow()
      33             : : VCLXWindow()
      34           1 : , pHatchWindow(0)
      35             : {
      36           1 : }
      37             : 
      38           2 : VCLXHatchWindow::~VCLXHatchWindow()
      39             : {
      40           2 : }
      41             : 
      42           1 : void VCLXHatchWindow::initializeWindow( const uno::Reference< awt::XWindowPeer >& xParent,
      43             :                 const awt::Rectangle& aBounds,
      44             :                 const awt::Size& aSize )
      45             : {
      46           1 :     SolarMutexGuard aGuard;
      47             : 
      48           1 :     vcl::Window* pParent = NULL;
      49           1 :     VCLXWindow* pParentComponent = VCLXWindow::GetImplementation( xParent );
      50             : 
      51           1 :     if ( pParentComponent )
      52           1 :         pParent = pParentComponent->GetWindow();
      53             : 
      54             :     OSL_ENSURE( pParent, "No parent window is provided!\n" );
      55           1 :     if ( !pParent )
      56           0 :         throw lang::IllegalArgumentException(); // TODO
      57             : 
      58           1 :     pHatchWindow = VclPtr<SvResizeWindow>::Create( pParent, this );
      59           1 :     pHatchWindow->setPosSizePixel( aBounds.X, aBounds.Y, aBounds.Width, aBounds.Height );
      60           1 :     aHatchBorderSize = aSize;
      61           1 :     pHatchWindow->SetHatchBorderPixel( Size( aSize.Width, aSize.Height ) );
      62             : 
      63           1 :     SetWindow( pHatchWindow );
      64           1 :     pHatchWindow->SetComponentInterface( this );
      65             : 
      66             :     //pHatchWindow->Show();
      67           1 : }
      68             : 
      69           0 : void VCLXHatchWindow::QueryObjAreaPixel( Rectangle & aRect )
      70             : {
      71           0 :     if ( m_xController.is() )
      72             :     {
      73           0 :         awt::Rectangle aUnoRequestRect = AWTRectangle( aRect );
      74             : 
      75             :         try {
      76           0 :             awt::Rectangle aUnoResultRect = m_xController->calcAdjustedRectangle( aUnoRequestRect );
      77           0 :             aRect = VCLRectangle( aUnoResultRect );
      78             :         }
      79           0 :         catch( uno::Exception& )
      80             :         {
      81             :             OSL_FAIL( "Can't adjust rectangle size!\n" );
      82             :         }
      83             :     }
      84           0 : }
      85             : 
      86           0 : void VCLXHatchWindow::RequestObjAreaPixel( const Rectangle & aRect )
      87             : {
      88           0 :     if ( m_xController.is() )
      89             :     {
      90           0 :         awt::Rectangle aUnoRequestRect = AWTRectangle( aRect );
      91             : 
      92             :         try {
      93           0 :             m_xController->requestPositioning( aUnoRequestRect );
      94             :         }
      95           0 :         catch( uno::Exception& )
      96             :         {
      97             :             OSL_FAIL( "Can't request resizing!\n" );
      98             :         }
      99             :     }
     100           0 : }
     101             : 
     102           0 : void VCLXHatchWindow::InplaceDeactivate()
     103             : {
     104           0 :     if ( m_xController.is() )
     105             :     {
     106             :         // TODO: communicate with controller
     107             :     }
     108           0 : }
     109             : 
     110             : 
     111           8 : uno::Any SAL_CALL VCLXHatchWindow::queryInterface( const uno::Type & rType )
     112             :     throw( uno::RuntimeException, std::exception )
     113             : {
     114             :     // Attention:
     115             :     //    Don't use mutex or guard in this method!!! Is a method of XInterface.
     116             : 
     117             :     uno::Any aReturn( ::cppu::queryInterface( rType,
     118           8 :                                            static_cast< embed::XHatchWindow* >( this ) ) );
     119             : 
     120           8 :     if ( aReturn.hasValue() )
     121             :     {
     122           2 :         return aReturn ;
     123             :     }
     124             : 
     125           6 :     return VCLXWindow::queryInterface( rType ) ;
     126             : }
     127             : 
     128          35 : void SAL_CALL VCLXHatchWindow::acquire()
     129             :     throw()
     130             : {
     131          35 :     VCLXWindow::acquire();
     132          35 : }
     133             : 
     134          35 : void SAL_CALL VCLXHatchWindow::release()
     135             :     throw()
     136             : {
     137          35 :     VCLXWindow::release();
     138          35 : }
     139             : 
     140           0 : uno::Sequence< uno::Type > SAL_CALL VCLXHatchWindow::getTypes()
     141             :     throw( uno::RuntimeException, std::exception )
     142             : {
     143             :     static ::cppu::OTypeCollection* pTypeCollection = NULL ;
     144             : 
     145           0 :     if ( pTypeCollection == NULL )
     146             :     {
     147           0 :         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ) ;
     148             : 
     149           0 :         if ( pTypeCollection == NULL )
     150             :         {
     151             :             static ::cppu::OTypeCollection aTypeCollection(
     152           0 :                     cppu::UnoType<embed::XHatchWindow>::get(),
     153           0 :                     VCLXHatchWindow::getTypes() );
     154             : 
     155           0 :             pTypeCollection = &aTypeCollection ;
     156           0 :         }
     157             :     }
     158             : 
     159           0 :     return pTypeCollection->getTypes() ;
     160             : }
     161             : 
     162           0 : uno::Sequence< sal_Int8 > SAL_CALL VCLXHatchWindow::getImplementationId()
     163             :     throw( uno::RuntimeException, std::exception )
     164             : {
     165           0 :     return css::uno::Sequence<sal_Int8>();
     166             : }
     167             : 
     168           0 : ::com::sun::star::awt::Size SAL_CALL VCLXHatchWindow::getHatchBorderSize() throw (::com::sun::star::uno::RuntimeException, std::exception)
     169             : {
     170           0 :     return aHatchBorderSize;
     171             : }
     172             : 
     173           2 : void SAL_CALL VCLXHatchWindow::setHatchBorderSize( const ::com::sun::star::awt::Size& _hatchbordersize ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     174             : {
     175           2 :     if ( pHatchWindow )
     176             :     {
     177           2 :         aHatchBorderSize = _hatchbordersize;
     178           2 :         pHatchWindow->SetHatchBorderPixel( Size( aHatchBorderSize.Width, aHatchBorderSize.Height ) );
     179             :     }
     180           2 : }
     181             : 
     182           1 : void SAL_CALL VCLXHatchWindow::setController( const uno::Reference< embed::XHatchWindowController >& xController )
     183             :     throw (uno::RuntimeException, std::exception)
     184             : {
     185           1 :     m_xController = xController;
     186           1 : }
     187             : 
     188           2 : void SAL_CALL VCLXHatchWindow::dispose()
     189             :     throw (uno::RuntimeException, std::exception)
     190             : {
     191           2 :     pHatchWindow.clear();
     192           2 :     VCLXWindow::dispose();
     193           2 : }
     194             : 
     195           0 : void SAL_CALL VCLXHatchWindow::addEventListener( const uno::Reference< lang::XEventListener >& xListener )
     196             :     throw (uno::RuntimeException, std::exception)
     197             : {
     198           0 :     VCLXWindow::addEventListener( xListener );
     199           0 : }
     200             : 
     201           0 : void SAL_CALL VCLXHatchWindow::removeEventListener( const uno::Reference< lang::XEventListener >& xListener )
     202             :     throw (uno::RuntimeException, std::exception)
     203             : {
     204           0 :     VCLXWindow::removeEventListener( xListener );
     205           0 : }
     206             : 
     207           1 : void VCLXHatchWindow::Activated()
     208             : {
     209           1 :     if ( m_xController.is() )
     210           1 :         m_xController->activated();
     211           1 : }
     212             : 
     213           0 : void VCLXHatchWindow::Deactivated()
     214             : {
     215           0 :     if ( m_xController.is() )
     216           0 :         m_xController->deactivated();
     217           0 : }
     218             : 
     219             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11