LCOV - code coverage report
Current view: top level - reportdesign/source/core/inc - Tools.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 59 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 31 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             : #ifndef INCLUDED_REPORTDESIGN_SOURCE_CORE_INC_TOOLS_HXX
      20             : #define INCLUDED_REPORTDESIGN_SOURCE_CORE_INC_TOOLS_HXX
      21             : 
      22             : #include <com/sun/star/report/XReportDefinition.hpp>
      23             : #include <com/sun/star/report/XSection.hpp>
      24             : #include <com/sun/star/awt/Point.hpp>
      25             : #include <com/sun/star/awt/Size.hpp>
      26             : #include <com/sun/star/container/XChild.hpp>
      27             : #include <com/sun/star/uno/XComponentContext.hpp>
      28             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      29             : #include <com/sun/star/report/XFixedText.hpp>
      30             : #include <com/sun/star/report/XFormattedField.hpp>
      31             : 
      32             : 
      33             : #include "Section.hxx"
      34             : #include "corestrings.hrc"
      35             : 
      36             : namespace reportdesign
      37             : {
      38           0 :     template <class T> void lcl_createSectionIfNeeded(bool _bOn,const T& _xParent,::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection/*in/out*/,bool _bPageSection = false)
      39             :     {
      40           0 :         if ( _bOn && !_xSection.is() )
      41           0 :             _xSection = OSection::createOSection(_xParent,_xParent->getContext(),_bPageSection);
      42           0 :         else if ( !_bOn )
      43           0 :             ::comphelper::disposeComponent(_xSection);
      44           0 :     }
      45             : 
      46             :     /** gets the properties which should be removed form the property set implementation.
      47             :      *
      48             :      * \return A sequence of all properties which should be removed for none char able implementations.
      49             :      */
      50             :     ::com::sun::star::uno::Sequence< OUString > lcl_getCharOptionals();
      51             : 
      52             :     /** uses the XChild interface to get the section from any child of it.
      53             :      *
      54             :      * \param _xReportComponent A report component which is a child of the section.
      55             :      * \return The sectin where this report component resists in.
      56             :      */
      57             :     ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection> lcl_getSection(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _xReportComponent);
      58             : 
      59             :     /** throws an illegal argument exception. The message text is the resource RID_STR_ERROR_WRONG_ARGUMENT + the type as reference.
      60             :      *
      61             :      * \param _sTypeName The reference where to look for the correct values.
      62             :      * \param ExceptionContext_ The exception context.
      63             :      * \param ArgumentPosition_ The argument position.
      64             :      * \param Context_ The context to get the factory service.
      65             :      */
      66             :     void throwIllegallArgumentException(const OUString& _sTypeName
      67             :                                         ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& ExceptionContext_
      68             :                                         ,const ::sal_Int16& ArgumentPosition_
      69             :                                         ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& Context_);
      70             : 
      71             :     /** clones the given object
      72             :     *
      73             :     * \param _xReportComponent the object to be cloned
      74             :     * \param _xFactory  the factory to create the clone
      75             :     * \param _sServiceName the service of the to be cloned object
      76             :     * \return the clone
      77             :     */
      78             :     ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > cloneObject(
      79             :                                         const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xReportComponent
      80             :                                         ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _xFactory
      81             :                                         ,const OUString& _sServiceName);
      82             : 
      83             :     class OShapeHelper
      84             :     {
      85             :     public:
      86           0 :         template<typename T> static void setSize(const ::com::sun::star::awt::Size& aSize,T* _pShape)
      87             :         {
      88             :             OSL_ENSURE(aSize.Width >= 0 && aSize.Height >= 0,"Illegal width or height!");
      89             : 
      90           0 :             ::osl::MutexGuard aGuard(_pShape->m_aMutex);
      91           0 :             if ( _pShape->m_aProps.aComponent.m_xShape.is() )
      92             :             {
      93           0 :                 ::com::sun::star::awt::Size aOldSize = _pShape->m_aProps.aComponent.m_xShape->getSize();
      94           0 :                 if ( aOldSize.Height != aSize.Height || aOldSize.Width != aSize.Width )
      95             :                 {
      96           0 :                     _pShape->m_aProps.aComponent.m_nWidth = aOldSize.Width;
      97           0 :                     _pShape->m_aProps.aComponent.m_nHeight = aOldSize.Height;
      98           0 :                     _pShape->m_aProps.aComponent.m_xShape->setSize(aSize);
      99             :                 }
     100             :             }
     101           0 :             _pShape->set(PROPERTY_WIDTH,aSize.Width,_pShape->m_aProps.aComponent.m_nWidth);
     102           0 :             _pShape->set(PROPERTY_HEIGHT,aSize.Height,_pShape->m_aProps.aComponent.m_nHeight);
     103           0 :         }
     104           0 :         template<typename T> static ::com::sun::star::awt::Size getSize( T* _pShape )
     105             :         {
     106           0 :             ::osl::MutexGuard aGuard(_pShape->m_aMutex);
     107           0 :             if ( _pShape->m_aProps.aComponent.m_xShape.is() )
     108             :             {
     109           0 :                 ::com::sun::star::awt::Size aSize = _pShape->m_aProps.aComponent.m_xShape->getSize();
     110             :                 OSL_ENSURE(aSize.Width >= 0 && aSize.Height >= 0,"Illegal width or height!");
     111           0 :                 return aSize;
     112             :             }
     113           0 :             return ::com::sun::star::awt::Size(_pShape->m_aProps.aComponent.m_nWidth,_pShape->m_aProps.aComponent.m_nHeight);
     114             :         }
     115             : 
     116           0 :         template<typename T> static void setPosition( const ::com::sun::star::awt::Point& _aPosition ,T* _pShape)
     117             :         {
     118             :             // we know it is not allowed that the position in smaller 0, but in NbcMove() it will handled right.
     119             :             // only at 'Undo' it is possible to short set the position smaller 0
     120             :             // OSL_ENSURE(_aPosition.X >= 0 && _aPosition.Y >= 0,"set to Illegal position!");
     121           0 :             ::osl::MutexGuard aGuard(_pShape->m_aMutex);
     122           0 :             ::com::sun::star::awt::Point aOldPos;
     123           0 :             aOldPos.X = _pShape->m_aProps.aComponent.m_nPosX;
     124           0 :             aOldPos.Y = _pShape->m_aProps.aComponent.m_nPosY;
     125             : 
     126           0 :             ::com::sun::star::awt::Point aPosition(_aPosition);
     127           0 :             if ( _pShape->m_aProps.aComponent.m_xShape.is() )
     128             :             {
     129           0 :                 aOldPos = _pShape->m_aProps.aComponent.m_xShape->getPosition();
     130           0 :                 if ( aOldPos.X != aPosition.X || aOldPos.Y != aPosition.Y )
     131             :                 {
     132           0 :                     _pShape->m_aProps.aComponent.m_nPosX = aOldPos.X;
     133           0 :                     _pShape->m_aProps.aComponent.m_nPosY = aOldPos.Y;
     134           0 :                     _pShape->m_aProps.aComponent.m_xShape->setPosition(aPosition);
     135             :                 }
     136             :             }
     137           0 :             _pShape->set(PROPERTY_POSITIONX,aPosition.X,aOldPos.X);
     138           0 :             _pShape->set(PROPERTY_POSITIONY,aPosition.Y,aOldPos.Y);
     139           0 :         }
     140           0 :         template<typename T> static ::com::sun::star::awt::Point getPosition(T* _pShape)
     141             :         {
     142           0 :             ::osl::MutexGuard aGuard(_pShape->m_aMutex);
     143           0 :             if ( _pShape->m_aProps.aComponent.m_xShape.is() )
     144             :             {
     145           0 :                 ::com::sun::star::awt::Point aPosition = _pShape->m_aProps.aComponent.m_xShape->getPosition();
     146           0 :                 return aPosition;
     147             :             }
     148           0 :             return ::com::sun::star::awt::Point(_pShape->m_aProps.aComponent.m_nPosX,_pShape->m_aProps.aComponent.m_nPosY);
     149             :         }
     150           0 :         template<typename T> static void setParent( const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& Parent, T* _pShape)
     151             :         {
     152           0 :             ::osl::MutexGuard aGuard(_pShape->m_aMutex);
     153           0 :             _pShape->m_aProps.aComponent.m_xParent = ::com::sun::star::uno::Reference< ::com::sun::star::container::XChild >(Parent,::com::sun::star::uno::UNO_QUERY);
     154           0 :             ::com::sun::star::uno::Reference< ::com::sun::star::container::XChild > xChild;
     155           0 :             comphelper::query_aggregation(_pShape->m_aProps.aComponent.m_xProxy,xChild);
     156           0 :             if ( xChild.is() )
     157           0 :                 xChild->setParent(Parent);
     158           0 :         }
     159           0 :         template<typename T> static com::sun::star::uno::Reference< com::sun::star::uno::XInterface > getParent( T* _pShape )
     160             :         {
     161           0 :             ::osl::MutexGuard aGuard(_pShape->m_aMutex);
     162           0 :             ::com::sun::star::uno::Reference< ::com::sun::star::container::XChild > xChild;
     163           0 :             comphelper::query_aggregation(_pShape->m_aProps.aComponent.m_xProxy,xChild);
     164           0 :             if ( xChild.is() )
     165           0 :                     return xChild->getParent();
     166           0 :             return _pShape->m_aProps.aComponent.m_xParent;
     167             :         }
     168             :     };
     169             : 
     170             : } // namespace reportdesign
     171             : 
     172             : #endif // INCLUDED_REPORTDESIGN_SOURCE_CORE_INC_TOOLS_HXX
     173             : 
     174             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11