LCOV - code coverage report
Current view: top level - libreoffice/svtools/source/hatchwindow - hatchwindow.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 92 0.0 %
Date: 2012-12-27 Functions: 0 20 0.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 <osl/mutex.hxx>
      27             : #include <vcl/svapp.hxx>
      28             : 
      29             : using namespace ::com::sun::star;
      30             : 
      31           0 : VCLXHatchWindow::VCLXHatchWindow()
      32             : : VCLXWindow()
      33           0 : , pHatchWindow(0)
      34             : {
      35           0 : }
      36             : 
      37           0 : VCLXHatchWindow::~VCLXHatchWindow()
      38             : {
      39           0 : }
      40             : 
      41           0 : void VCLXHatchWindow::initializeWindow( const uno::Reference< awt::XWindowPeer >& xParent,
      42             :                 const awt::Rectangle& aBounds,
      43             :                 const awt::Size& aSize )
      44             : {
      45           0 :     SolarMutexGuard aGuard;
      46             : 
      47           0 :     Window* pParent = NULL;
      48           0 :     VCLXWindow* pParentComponent = VCLXWindow::GetImplementation( xParent );
      49             : 
      50           0 :     if ( pParentComponent )
      51           0 :         pParent = pParentComponent->GetWindow();
      52             : 
      53             :     OSL_ENSURE( pParent, "No parent window is provided!\n" );
      54           0 :     if ( !pParent )
      55           0 :         throw lang::IllegalArgumentException(); // TODO
      56             : 
      57           0 :     pHatchWindow = new SvResizeWindow( pParent, this );
      58           0 :     pHatchWindow->setPosSizePixel( aBounds.X, aBounds.Y, aBounds.Width, aBounds.Height );
      59           0 :     aHatchBorderSize = aSize;
      60           0 :     pHatchWindow->SetHatchBorderPixel( Size( aSize.Width, aSize.Height ) );
      61             : 
      62           0 :     SetWindow( pHatchWindow );
      63           0 :     pHatchWindow->SetComponentInterface( this );
      64             : 
      65             :     //pHatchWindow->Show();
      66           0 : }
      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           0 : uno::Any SAL_CALL VCLXHatchWindow::queryInterface( const uno::Type & rType )
     111             :     throw( uno::RuntimeException )
     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           0 :                                            static_cast< embed::XHatchWindow* >( this ) ) );
     118             : 
     119           0 :     if ( aReturn.hasValue() == sal_True )
     120             :     {
     121           0 :         return aReturn ;
     122             :     }
     123             : 
     124           0 :     return VCLXWindow::queryInterface( rType ) ;
     125             : }
     126             : 
     127           0 : void SAL_CALL VCLXHatchWindow::acquire()
     128             :     throw()
     129             : {
     130           0 :     VCLXWindow::acquire();
     131           0 : }
     132             : 
     133           0 : void SAL_CALL VCLXHatchWindow::release()
     134             :     throw()
     135             : {
     136           0 :     VCLXWindow::release();
     137           0 : }
     138             : 
     139           0 : uno::Sequence< uno::Type > SAL_CALL VCLXHatchWindow::getTypes()
     140             :     throw( uno::RuntimeException )
     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 :                     ::getCppuType(( const uno::Reference< embed::XHatchWindow >* )NULL ),
     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 )
     163             : {
     164             :     static ::cppu::OImplementationId* pID = NULL ;
     165             : 
     166           0 :     if ( pID == NULL )
     167             :     {
     168           0 :         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ) ;
     169             : 
     170           0 :         if ( pID == NULL )
     171             :         {
     172           0 :             static ::cppu::OImplementationId aID( sal_False ) ;
     173           0 :             pID = &aID ;
     174           0 :         }
     175             :     }
     176             : 
     177           0 :     return pID->getImplementationId() ;
     178             : }
     179             : 
     180           0 : ::com::sun::star::awt::Size SAL_CALL VCLXHatchWindow::getHatchBorderSize() throw (::com::sun::star::uno::RuntimeException)
     181             : {
     182           0 :     return aHatchBorderSize;
     183             : }
     184             : 
     185           0 : void SAL_CALL VCLXHatchWindow::setHatchBorderSize( const ::com::sun::star::awt::Size& _hatchbordersize ) throw (::com::sun::star::uno::RuntimeException)
     186             : {
     187           0 :     if ( pHatchWindow )
     188             :     {
     189           0 :         aHatchBorderSize = _hatchbordersize;
     190           0 :         pHatchWindow->SetHatchBorderPixel( Size( aHatchBorderSize.Width, aHatchBorderSize.Height ) );
     191             :     }
     192           0 : }
     193             : 
     194           0 : void SAL_CALL VCLXHatchWindow::setController( const uno::Reference< embed::XHatchWindowController >& xController )
     195             :     throw (uno::RuntimeException)
     196             : {
     197           0 :     m_xController = xController;
     198           0 : }
     199             : 
     200           0 : void SAL_CALL VCLXHatchWindow::dispose()
     201             :     throw (uno::RuntimeException)
     202             : {
     203           0 :     pHatchWindow = 0;
     204           0 :     VCLXWindow::dispose();
     205           0 : }
     206             : 
     207           0 : void SAL_CALL VCLXHatchWindow::addEventListener( const uno::Reference< lang::XEventListener >& xListener )
     208             :     throw (uno::RuntimeException)
     209             : {
     210           0 :     VCLXWindow::addEventListener( xListener );
     211           0 : }
     212             : 
     213           0 : void SAL_CALL VCLXHatchWindow::removeEventListener( const uno::Reference< lang::XEventListener >& xListener )
     214             :     throw (uno::RuntimeException)
     215             : {
     216           0 :     VCLXWindow::removeEventListener( xListener );
     217           0 : }
     218             : 
     219           0 : void VCLXHatchWindow::Activated()
     220             : {
     221           0 :     if ( m_xController.is() )
     222           0 :         m_xController->activated();
     223           0 : }
     224             : 
     225           0 : void VCLXHatchWindow::Deactivated()
     226             : {
     227           0 :     if ( m_xController.is() )
     228           0 :         m_xController->deactivated();
     229           0 : }
     230             : 
     231             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10