<commit_before>/*************************************************************************
 *
 *  $RCSfile: XMLTableShapeResizer.cxx,v $
 *
 *  $Revision: 1.20 $
 *
 *  last change: $Author: sab $ $Date: 2002-09-11 12:09:00 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

#ifndef _SC_XMLTABLESHAPERESIZER_HXX
#include "XMLTableShapeResizer.hxx"
#endif
#ifndef SC_UNONAMES_HXX
#include "unonames.hxx"
#endif
#ifndef SC_DOCUMENT_HXX
#include "document.hxx"
#endif
#ifndef SC_XMLIMPRT_HXX
#include "xmlimprt.hxx"
#endif
#ifndef SC_CHARTLIS_HXX
#include "chartlis.hxx"
#endif
#ifndef _SC_XMLCONVERTER_HXX
#include "XMLConverter.hxx"
#endif

#ifndef _TOOLS_DEBUG_HXX
#include <tools/debug.hxx>
#endif

#ifndef _COM_SUN_STAR_SHEET_XSPREADSHEETDOCUMENT_HPP_
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
#endif
#ifndef _COM_SUN_STAR_TABLE_XCOLUMNROWRANGE_HPP_
#include <com/sun/star/table/XColumnRowRange.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
#include <com/sun/star/beans/XPropertySet.hpp>
#endif

using namespace ::com::sun::star;

ScMyShapeResizer::ScMyShapeResizer(ScXMLImport& rTempImport)
    : aShapes(),
    rImport(rTempImport),
    pCollection(NULL)
{
}

ScMyShapeResizer::~ScMyShapeResizer()
{
}

sal_Bool ScMyShapeResizer::IsOLE(uno::Reference< drawing::XShape >& rShape) const
{
    return rShape->getShapeType().equals(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.OLE2Shape")));
}

void ScMyShapeResizer::CreateChartListener(ScDocument* pDoc,
    const rtl::OUString& rName,
    const rtl::OUString* pRangeList)
{
    if(pDoc)
    {
        if (pRangeList)
        {
            if (pRangeList->getLength())
            {
                if (!pCollection)
                    pCollection = pDoc->GetChartListenerCollection();//new ScChartListenerCollection(pDoc);
                if (pCollection)
                {
                    ScRangeListRef aRangeListRef = new ScRangeList();
                    ScXMLConverter::GetRangeListFromString(*aRangeListRef, *pRangeList, pDoc);
                    if (aRangeListRef->Count())
                    {
                        ScChartListener* pCL = new ScChartListener(
                                            rName, pDoc, aRangeListRef );
                        pCollection->Insert( pCL );
                        pCL->StartListeningTo();
                    }
                }
            }
            else
            {
                pDoc->AddOLEObjectToCollection(rName);
            }
        }
    }
}

void ScMyShapeResizer::AddShape(uno::Reference <drawing::XShape>& rShape,
    rtl::OUString* pRangeList,
    table::CellAddress& rStartAddress, table::CellAddress& rEndAddress,
    sal_Int32 nEndX, sal_Int32 nEndY)
{
    ScMyToResizeShape aShape;
    aShape.xShape = rShape;
    aShape.pRangeList = pRangeList;
    aShape.aEndCell = rEndAddress;
    aShape.aStartCell = rStartAddress;
    aShape.nEndY = nEndY;
    aShape.nEndX = nEndX;
    aShapes.push_back(aShape);
}

void ScMyShapeResizer::GetNewShapeSizePos(ScDocument* pDoc, const Rectangle& rStartRect,
                                          const table::CellAddress& rEndCell,
                                          awt::Point& rPoint, awt::Size& rSize,
                                          sal_Int32& rEndX, sal_Int32& rEndY) const
{
    awt::Point aRefPoint;
    aRefPoint.X = rStartRect.Left();
    aRefPoint.Y = rStartRect.Top();
    Rectangle* pRect = new Rectangle(pDoc->GetMMRect(
        static_cast<USHORT>(rEndCell.Column), static_cast<USHORT>(rEndCell.Row),
        static_cast<USHORT>(rEndCell.Column), static_cast<USHORT>(rEndCell.Row), rEndCell.Sheet ));
    rEndX += pRect->Left();
    rEndY += pRect->Top();
    rPoint.X += aRefPoint.X;
    if (rPoint.X > rStartRect.Right())
        rPoint.X = rStartRect.Right() - 2; // decrement by 2 100th_mm because the cellheight is internal in twips
    rPoint.Y += aRefPoint.Y;
    if (rPoint.Y > rStartRect.Bottom())
        rPoint.Y = rStartRect.Bottom() - 2; // decrement by 2 100th_mm because the cellheight is internal in twips
    rSize.Width = rEndX - rPoint.X;
    rSize.Height = rEndY - rPoint.Y;
    delete pRect;
}

void ScMyShapeResizer::ResizeShapes()
{
    if (!aShapes.empty() && rImport.GetModel().is())
    {
        rtl::OUString sRowHeight(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_CELLHGT));
        rtl::OUString sPersistName (RTL_CONSTASCII_USTRINGPARAM("PersistName"));
        rtl::OUString sCaptionPoint( RTL_CONSTASCII_USTRINGPARAM( "CaptionPoint" ));
        rtl::OUString sConnectorShape( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ConnectorShape") );
        rtl::OUString sCaptionShape( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.CaptionShape") );
        rtl::OUString sStartShape(RTL_CONSTASCII_USTRINGPARAM("StartShape"));
        rtl::OUString sEndShape(RTL_CONSTASCII_USTRINGPARAM("EndShape"));
        uno::Reference<table::XCellRange> xTableRow;
        uno::Reference<sheet::XSpreadsheet> xSheet;
        uno::Reference<table::XTableRows> xTableRows;
        sal_Int32 nOldRow(-1);
        sal_Int32 nOldSheet(-1);
        ScMyToResizeShapes::iterator aItr = aShapes.begin();
        uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( rImport.GetModel(), uno::UNO_QUERY );
        if ( xSpreadDoc.is() )
        {
            uno::Reference<sheet::XSpreadsheets> xSheets = xSpreadDoc->getSheets();
            uno::Reference<container::XIndexAccess> xIndex( xSheets, uno::UNO_QUERY );
            ScDocument* pDoc = rImport.GetDocument();
            if ( pDoc && xIndex.is() )
            {
                rImport.LockSolarMutex();
                while (aItr != aShapes.end())
                {
                    if ((nOldSheet != aItr->aEndCell.Sheet) || !xSheet.is())
                    {
                        nOldSheet = aItr->aEndCell.Sheet;
                        uno::Any aTable = xIndex->getByIndex(nOldSheet);
                        if (aTable>>=xSheet)
                        {
                            uno::Reference<table::XColumnRowRange> xColumnRowRange (xSheet, uno::UNO_QUERY);
                            if (xColumnRowRange.is())
                                xTableRows = xColumnRowRange->getRows();
                        }
                    }
                    if (xTableRows.is())
                    {
                        if (nOldRow != aItr->aEndCell.Row || !xTableRow.is())
                        {
                            nOldRow = aItr->aEndCell.Row;
                            uno::Any aRow = xTableRows->getByIndex(nOldRow);
                            aRow >>= xTableRow;
                        }
                        if (xTableRow.is())
                        {
                            uno::Reference <beans::XPropertySet> xRowProperties(xTableRow, uno::UNO_QUERY);
                            if (xRowProperties.is())
                            {
                                uno::Any aAny = xRowProperties->getPropertyValue(sRowHeight);
                                sal_Int32 nHeight;
                                if (aAny >>= nHeight)
                                {
                                    Rectangle aRec = pDoc->GetMMRect(static_cast<USHORT>(aItr->aStartCell.Column), static_cast<USHORT>(aItr->aStartCell.Row),
                                        static_cast<USHORT>(aItr->aStartCell.Column), static_cast<USHORT>(aItr->aStartCell.Row), aItr->aStartCell.Sheet);
                                    awt::Point aPoint(aItr->xShape->getPosition());
                                    awt::Size aSize(aItr->xShape->getSize());
                                    if (aItr->nEndY >= 0 && aItr->nEndX >= 0)
                                    {
                                        if (aItr->xShape->getShapeType().equals(sConnectorShape))
                                        {
                                            //#103122#; handle connected Connectorshapes
                                            uno::Reference<beans::XPropertySet> xShapeProps (aItr->xShape, uno::UNO_QUERY);
                                            if(xShapeProps.is())
                                            {
                                                uno::Any aAny = xShapeProps->getPropertyValue(  sStartShape );
                                                uno::Reference<drawing::XShape> xStartShape;
                                                aAny >>= xStartShape;
                                                aAny = xShapeProps->getPropertyValue( sEndShape );
                                                uno::Reference<drawing::XShape> xEndShape;
                                                aAny >>= xEndShape;
                                                if (!xStartShape.is() && !xEndShape.is())
                                                {
                                                    awt::Size aOldSize(aSize);
                                                    GetNewShapeSizePos(pDoc, aRec, aItr->aEndCell, aPoint, aSize, aItr->nEndX, aItr->nEndY);
                                                    aItr->xShape->setPosition(aPoint);
                                                    if( (aSize.Width != aOldSize.Width) ||
                                                        (aSize.Height != aOldSize.Height) )
                                                        aItr->xShape->setSize(aSize);
                                                }
                                                else if (xStartShape.is() && xEndShape.is())
                                                {
                                                    // do nothing, because they are connected
                                                }
                                                else
                                                {
                                                    // only one point is connected, the other should be removed
                                                }
                                            }
                                        }
                                        else
                                        {
                                            awt::Size aOldSize(aSize);
                                            GetNewShapeSizePos(pDoc, aRec, aItr->aEndCell, aPoint, aSize, aItr->nEndX, aItr->nEndY);
                                            aItr->xShape->setPosition(aPoint);
                                            if( (aSize.Width != aOldSize.Width) ||
                                                (aSize.Height != aOldSize.Height) )
                                                aItr->xShape->setSize(aSize);
                                        }
                                    }
                                    else<commit_msg>#103122#; handle connector shapes which are only connected in one point<commit_after>/*************************************************************************
 *
 *  $RCSfile: XMLTableShapeResizer.cxx,v $
 *
 *  $Revision: 1.21 $
 *
 *  last change: $Author: sab $ $Date: 2002-11-01 14:01:29 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

#ifndef _SC_XMLTABLESHAPERESIZER_HXX
#include "XMLTableShapeResizer.hxx"
#endif
#ifndef SC_UNONAMES_HXX
#include "unonames.hxx"
#endif
#ifndef SC_DOCUMENT_HXX
#include "document.hxx"
#endif
#ifndef SC_XMLIMPRT_HXX
#include "xmlimprt.hxx"
#endif
#ifndef SC_CHARTLIS_HXX
#include "chartlis.hxx"
#endif
#ifndef _SC_XMLCONVERTER_HXX
#include "XMLConverter.hxx"
#endif

#ifndef _TOOLS_DEBUG_HXX
#include <tools/debug.hxx>
#endif

#ifndef _COM_SUN_STAR_SHEET_XSPREADSHEETDOCUMENT_HPP_
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
#endif
#ifndef _COM_SUN_STAR_TABLE_XCOLUMNROWRANGE_HPP_
#include <com/sun/star/table/XColumnRowRange.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
#include <com/sun/star/beans/XPropertySet.hpp>
#endif

using namespace ::com::sun::star;

ScMyShapeResizer::ScMyShapeResizer(ScXMLImport& rTempImport)
    : aShapes(),
    rImport(rTempImport),
    pCollection(NULL)
{
}

ScMyShapeResizer::~ScMyShapeResizer()
{
}

sal_Bool ScMyShapeResizer::IsOLE(uno::Reference< drawing::XShape >& rShape) const
{
    return rShape->getShapeType().equals(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.OLE2Shape")));
}

void ScMyShapeResizer::CreateChartListener(ScDocument* pDoc,
    const rtl::OUString& rName,
    const rtl::OUString* pRangeList)
{
    if(pDoc)
    {
        if (pRangeList)
        {
            if (pRangeList->getLength())
            {
                if (!pCollection)
                    pCollection = pDoc->GetChartListenerCollection();//new ScChartListenerCollection(pDoc);
                if (pCollection)
                {
                    ScRangeListRef aRangeListRef = new ScRangeList();
                    ScXMLConverter::GetRangeListFromString(*aRangeListRef, *pRangeList, pDoc);
                    if (aRangeListRef->Count())
                    {
                        ScChartListener* pCL = new ScChartListener(
                                            rName, pDoc, aRangeListRef );
                        pCollection->Insert( pCL );
                        pCL->StartListeningTo();
                    }
                }
            }
            else
            {
                pDoc->AddOLEObjectToCollection(rName);
            }
        }
    }
}

void ScMyShapeResizer::AddShape(uno::Reference <drawing::XShape>& rShape,
    rtl::OUString* pRangeList,
    table::CellAddress& rStartAddress, table::CellAddress& rEndAddress,
    sal_Int32 nEndX, sal_Int32 nEndY)
{
    ScMyToResizeShape aShape;
    aShape.xShape = rShape;
    aShape.pRangeList = pRangeList;
    aShape.aEndCell = rEndAddress;
    aShape.aStartCell = rStartAddress;
    aShape.nEndY = nEndY;
    aShape.nEndX = nEndX;
    aShapes.push_back(aShape);
}

void ScMyShapeResizer::GetNewShapeSizePos(ScDocument* pDoc, const Rectangle& rStartRect,
                                          const table::CellAddress& rEndCell,
                                          awt::Point& rPoint, awt::Size& rSize,
                                          sal_Int32& rEndX, sal_Int32& rEndY) const
{
    awt::Point aRefPoint;
    aRefPoint.X = rStartRect.Left();
    aRefPoint.Y = rStartRect.Top();
    Rectangle* pRect = new Rectangle(pDoc->GetMMRect(
        static_cast<USHORT>(rEndCell.Column), static_cast<USHORT>(rEndCell.Row),
        static_cast<USHORT>(rEndCell.Column), static_cast<USHORT>(rEndCell.Row), rEndCell.Sheet ));
    rEndX += pRect->Left();
    rEndY += pRect->Top();
    rPoint.X += aRefPoint.X;
    if (rPoint.X > rStartRect.Right())
        rPoint.X = rStartRect.Right() - 2; // decrement by 2 100th_mm because the cellheight is internal in twips
    rPoint.Y += aRefPoint.Y;
    if (rPoint.Y > rStartRect.Bottom())
        rPoint.Y = rStartRect.Bottom() - 2; // decrement by 2 100th_mm because the cellheight is internal in twips
    rSize.Width = rEndX - rPoint.X;
    rSize.Height = rEndY - rPoint.Y;
    delete pRect;
}

void ScMyShapeResizer::ResizeShapes()
{
    if (!aShapes.empty() && rImport.GetModel().is())
    {
        rtl::OUString sRowHeight(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_CELLHGT));
        rtl::OUString sPersistName (RTL_CONSTASCII_USTRINGPARAM("PersistName"));
        rtl::OUString sCaptionPoint( RTL_CONSTASCII_USTRINGPARAM( "CaptionPoint" ));
        rtl::OUString sConnectorShape( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ConnectorShape") );
        rtl::OUString sCaptionShape( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.CaptionShape") );
        rtl::OUString sStartShape(RTL_CONSTASCII_USTRINGPARAM("StartShape"));
        rtl::OUString sEndShape(RTL_CONSTASCII_USTRINGPARAM("EndShape"));
        rtl::OUString sStartPosition(RTL_CONSTASCII_USTRINGPARAM("StartPosition"));
        rtl::OUString sEndPosition(RTL_CONSTASCII_USTRINGPARAM("EndPosition"));
        uno::Reference<table::XCellRange> xTableRow;
        uno::Reference<sheet::XSpreadsheet> xSheet;
        uno::Reference<table::XTableRows> xTableRows;
        sal_Int32 nOldRow(-1);
        sal_Int32 nOldSheet(-1);
        ScMyToResizeShapes::iterator aItr = aShapes.begin();
        uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( rImport.GetModel(), uno::UNO_QUERY );
        if ( xSpreadDoc.is() )
        {
            uno::Reference<sheet::XSpreadsheets> xSheets = xSpreadDoc->getSheets();
            uno::Reference<container::XIndexAccess> xIndex( xSheets, uno::UNO_QUERY );
            ScDocument* pDoc = rImport.GetDocument();
            if ( pDoc && xIndex.is() )
            {
                rImport.LockSolarMutex();
                while (aItr != aShapes.end())
                {
                    if ((nOldSheet != aItr->aEndCell.Sheet) || !xSheet.is())
                    {
                        nOldSheet = aItr->aEndCell.Sheet;
                        uno::Any aTable = xIndex->getByIndex(nOldSheet);
                        if (aTable>>=xSheet)
                        {
                            uno::Reference<table::XColumnRowRange> xColumnRowRange (xSheet, uno::UNO_QUERY);
                            if (xColumnRowRange.is())
                                xTableRows = xColumnRowRange->getRows();
                        }
                    }
                    if (xTableRows.is())
                    {
                        if (nOldRow != aItr->aEndCell.Row || !xTableRow.is())
                        {
                            nOldRow = aItr->aEndCell.Row;
                            uno::Any aRow = xTableRows->getByIndex(nOldRow);
                            aRow >>= xTableRow;
                        }
                        if (xTableRow.is())
                        {
                            uno::Reference <beans::XPropertySet> xRowProperties(xTableRow, uno::UNO_QUERY);
                            if (xRowProperties.is())
                            {
                                uno::Any aAny = xRowProperties->getPropertyValue(sRowHeight);
                                sal_Int32 nHeight;
                                if (aAny >>= nHeight)
                                {
                                    Rectangle aRec = pDoc->GetMMRect(static_cast<USHORT>(aItr->aStartCell.Column), static_cast<USHORT>(aItr->aStartCell.Row),
                                        static_cast<USHORT>(aItr->aStartCell.Column), static_cast<USHORT>(aItr->aStartCell.Row), aItr->aStartCell.Sheet);
                                    awt::Point aPoint(aItr->xShape->getPosition());
                                    awt::Size aSize(aItr->xShape->getSize());
                                    if (aItr->nEndY >= 0 && aItr->nEndX >= 0)
                                    {
                                        if (aItr->xShape->getShapeType().equals(sConnectorShape))
                                        {
                                            //#103122#; handle connected Connectorshapes
                                            uno::Reference<beans::XPropertySet> xShapeProps (aItr->xShape, uno::UNO_QUERY);
                                            if(xShapeProps.is())
                                            {
                                                uno::Any aAny = xShapeProps->getPropertyValue(  sStartShape );
                                                uno::Reference<drawing::XShape> xStartShape;
                                                aAny >>= xStartShape;
                                                aAny = xShapeProps->getPropertyValue( sEndShape );
                                                uno::Reference<drawing::XShape> xEndShape;
                                                aAny >>= xEndShape;
                                                if (!xStartShape.is() && !xEndShape.is())
                                                {
                                                    awt::Size aOldSize(aSize);
                                                    GetNewShapeSizePos(pDoc, aRec, aItr->aEndCell, aPoint, aSize, aItr->nEndX, aItr->nEndY);
                                                    aItr->xShape->setPosition(aPoint);
                                                    if( (aSize.Width != aOldSize.Width) ||
                                                        (aSize.Height != aOldSize.Height) )
                                                        aItr->xShape->setSize(aSize);
                                                }
                                                else if (xStartShape.is() && xEndShape.is())
                                                {
                                                    // do nothing, because they are connected
                                                }
                                                else
                                                {
                                                    // only one point is connected, the other should be moved

                                                    rtl::OUString sProperty;
                                                    if (xStartShape.is())
                                                    {
                                                        awt::Point aEndPoint;
                                                        uno::Any aAny = xShapeProps->getPropertyValue(sEndPosition);
                                                        aAny >>= aEndPoint;
                                                        aPoint.X = aRec.Left() + aEndPoint.X;
                                                        aPoint.Y = aRec.Top() + aEndPoint.Y;
                                                        sProperty = sEndPosition;
                                                    }
                                                    else
                                                    {
                                                        awt::Point aStartPoint;
                                                        uno::Any aAny = xShapeProps->getPropertyValue(sStartPosition);
                                                        aAny >>= aStartPoint;
                                                        aPoint.X = aRec.Left() + aStartPoint.X;
                                                        aPoint.Y = aRec.Top() + aStartPoint.Y;
                                                        sProperty = sStartPosition;
                                                    }
                                                    uno::Any aAny;
                                                    aAny <<= aPoint;
                                                    xShapeProps->setPropertyValue(sProperty, aAny);
                                                }
                                            }
                                        }
                                        else
                                        {
                                            awt::Size aOldSize(aSize);
                                            GetNewShapeSizePos(pDoc, aRec, aItr->aEndCell, aPoint, aSize, aItr->nEndX, aItr->nEndY);
                                            aItr->xShape->setPosition(aPoint);
                                            if( (aSize.Width != aOldSize.Width) ||
                                                (aSize.Height != aOldSize.Height) )
                                                aItr->xShape->setSize(aSize);
                                        }
                                    }
                                    else
{'fraction_non_alphanumeric': 0.10571499521089787, 'fraction_numerical': 0.0071659157827521375, 'mean_word_length': 1.448749131341209, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 188, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 230, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2131389', 'n_tokens_mistral': 7382, 'n_tokens_neox': 7066, 'n_words': 1510}