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

Generated by: LCOV version 1.10