Files
libreoffice/sc/source/ui/drawfunc/fuconuno.cxx

187 lines
5.6 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
re-base on ALv2 code. Includes: Patches contributed by Herbert Duerr i#118735 prevent endless loop if vlookup/hlookup doesn't find anything http://svn.apache.org/viewvc?view=revision&revision=1239673 Patches contributed by Andre Fischer remove lp_solver http://svn.apache.org/viewvc?view=revision&revision=1199180 i#118160: Added external CoinMP library. http://svn.apache.org/viewvc?view=revision&revision=1233909 Patches contributed by Armin Le-Grand i#118485 - Styles for OLEs are not saved. http://svn.apache.org/viewvc?view=revision&revision=1182166 i#118524: apply patch, followup fixes to 118485 http://svn.apache.org/viewvc?view=revision&revision=1186077 Patches contributed by lihuiibm i#108860 - Fix range validation. http://svn.apache.org/viewvc?view=revision&revision=1242846 i#118954 Chart data will lost after copy to different file http://svn.apache.org/viewvc?view=revision&revision=1301345 Patches contributed by Ariel Constenla-Haile Fix Linux build breaker: extra qualification on member http://svn.apache.org/viewvc?view=revision&revision=1301591 i#118696 - i#118697 - Fix some Sheet Tab Color API issues http://svn.apache.org/viewvc?view=revision&revision=1225428 i#118697 - Fix uninitialized variable http://svn.apache.org/viewvc?view=revision&revision=1225859 i#118771 - ScUndoImportTab should preserve tab background color http://svn.apache.org/viewvc?view=revision&revision=1230356 i#118921 - Repaint linked sheet tab background color after updating link http://svn.apache.org/viewvc?view=revision&revision=1245177 i#118927 - Undo/Redo "Update Link" does not reset sheet tab color http://svn.apache.org/viewvc?view=revision&revision=1245241 i#118747 - Copy tab color when transferring sheets across documents http://svn.apache.org/viewvc?view=revision&revision=1230355 Patch contributed by Oliver Rainer-Wittman i#118012 - methods <ScBroadcastAreaSlot::AreaBroadcast(..)> and <ScBroadcastAreaSlot::AreaBroadcastInRange(..)> adapt stl-container iteration in order to avoid destroyed iterators during iteration. http://svn.apache.org/viewvc?view=revision&revision=1297916 Patches contributed by Mathias Bauer gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 http://svn.apache.org/viewvc?view=revision&revision=1396797 http://svn.apache.org/viewvc?view=revision&revision=1397315 Patch contributed by Daniel Rentz calc69: #i116936# fix VBA symbol Cells http://svn.apache.org/viewvc?view=revision&revision=1172135 Patches contributed by leiw: i#118546 CPU 100% on switched off AutoCalculate with Conditional Formatting on date values http://svn.apache.org/viewvc?view=revision&revision=1301380 Re-add new function documentation. Many various cleanups. Add missing calc66: #o11817313# also look at formula result number format, remove redundant binaries.
2012-11-30 12:23:25 +00:00
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
*/
2000-09-18 16:07:07 +00:00
#include "fuconuno.hxx"
#include "tabvwsh.hxx"
#include "sc.hrc"
#include "drawview.hxx"
2000-09-18 16:07:07 +00:00
/*************************************************************************
|*
|* Konstruktor
|*
\************************************************************************/
FuConstUnoControl::FuConstUnoControl(ScTabViewShell* pViewSh, vcl::Window* pWin, ScDrawView* pViewP,
2000-09-18 16:07:07 +00:00
SdrModel* pDoc, SfxRequest& rReq)
: FuConstruct(pViewSh, pWin, pViewP, pDoc, rReq)
, nInventor(0)
, nIdentifier(0)
2000-09-18 16:07:07 +00:00
{
SFX_REQUEST_ARG( rReq, pInventorItem, SfxUInt32Item, SID_FM_CONTROL_INVENTOR, false );
SFX_REQUEST_ARG( rReq, pIdentifierItem, SfxUInt16Item, SID_FM_CONTROL_IDENTIFIER, false );
2000-09-18 16:07:07 +00:00
if( pInventorItem )
nInventor = pInventorItem->GetValue();
if( pIdentifierItem )
nIdentifier = pIdentifierItem->GetValue();
}
/*************************************************************************
|*
|* Destruktor
|*
\************************************************************************/
FuConstUnoControl::~FuConstUnoControl()
{
}
/*************************************************************************
|*
|* MouseButtonDown-event
|*
\************************************************************************/
bool FuConstUnoControl::MouseButtonDown(const MouseEvent& rMEvt)
2000-09-18 16:07:07 +00:00
{
2011-03-01 14:29:24 +01:00
// remember button state for creation of own MouseEvents
SetMouseButtonCode(rMEvt.GetButtons());
bool bReturn = FuConstruct::MouseButtonDown(rMEvt);
2000-09-18 16:07:07 +00:00
if ( rMEvt.IsLeft() && !pView->IsAction() )
{
Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
Sync draw object to calc grid for better alignment when zooming There can be some serious rounding errors involved when calculating where to draw the grid lines for the various row heights in a document. This can be especially true for a document that has many different row heights. This results in draw objects appearing to move relative to the grid line at different zoom levels. This patch attempts to fix this problem adjusting the position of the shapes as they are drawn to ensure their position relative to grid appears to be stable. We do this by translating the position of the shape to the corrosponding position of it's cell anchor. Of course not all shapes are cell anchored and in this case we position the shape relative a temporary synthesized cell anchor. The patch essentially does the following a) calculates the offset to be applied for each shape at the current zoom level to ensure that the shape will be drawn relative to the correct cell grid see drwlayer.cxx, drawview.cxx & gridwin3.cxx, svdobj.[ch]xx b) apply the offset in the drawing layer for each of the different drawing primitives see svx/source/sdr/contact/* c) making sure the position and size of the newly created shape ( at any zoom level ) are still as expected when zoom level is changed. see. sc/source/ui/drawfunc/fuco*.cxx & d) making sure that overlays and handles are displayed at the correct position see svx/source/svdraw/* it could also be that a full blown transform might be needed to additionally scale the object ( to ensure that the edges of the object stay stable relative to ajacent grid lines ) If necessary we could do that in a later step. Change-Id: I02232f8ba192d58dbf96b80adf66c281cd0f65e8
2012-11-27 17:56:33 +00:00
// Hack to align object to nearest grid position where object
// would be anchored ( if it were cell anchored )
// Get grid offset for current position ( note: aPnt is
// also adjusted )
Point aGridOff = CurrentGridSyncOffsetAndPos( aPnt );
2000-09-18 16:07:07 +00:00
pWindow->CaptureMouse();
pView->BegCreateObj(aPnt);
Sync draw object to calc grid for better alignment when zooming There can be some serious rounding errors involved when calculating where to draw the grid lines for the various row heights in a document. This can be especially true for a document that has many different row heights. This results in draw objects appearing to move relative to the grid line at different zoom levels. This patch attempts to fix this problem adjusting the position of the shapes as they are drawn to ensure their position relative to grid appears to be stable. We do this by translating the position of the shape to the corrosponding position of it's cell anchor. Of course not all shapes are cell anchored and in this case we position the shape relative a temporary synthesized cell anchor. The patch essentially does the following a) calculates the offset to be applied for each shape at the current zoom level to ensure that the shape will be drawn relative to the correct cell grid see drwlayer.cxx, drawview.cxx & gridwin3.cxx, svdobj.[ch]xx b) apply the offset in the drawing layer for each of the different drawing primitives see svx/source/sdr/contact/* c) making sure the position and size of the newly created shape ( at any zoom level ) are still as expected when zoom level is changed. see. sc/source/ui/drawfunc/fuco*.cxx & d) making sure that overlays and handles are displayed at the correct position see svx/source/svdraw/* it could also be that a full blown transform might be needed to additionally scale the object ( to ensure that the edges of the object stay stable relative to ajacent grid lines ) If necessary we could do that in a later step. Change-Id: I02232f8ba192d58dbf96b80adf66c281cd0f65e8
2012-11-27 17:56:33 +00:00
pView->GetCreateObj()->SetGridOffset( aGridOff );
bReturn = true;
2000-09-18 16:07:07 +00:00
}
return bReturn;
}
/*************************************************************************
|*
|* MouseMove-event
|*
\************************************************************************/
bool FuConstUnoControl::MouseMove(const MouseEvent& rMEvt)
2000-09-18 16:07:07 +00:00
{
return FuConstruct::MouseMove(rMEvt);
}
/*************************************************************************
|*
|* MouseButtonUp-event
|*
\************************************************************************/
bool FuConstUnoControl::MouseButtonUp(const MouseEvent& rMEvt)
2000-09-18 16:07:07 +00:00
{
2011-03-01 14:29:24 +01:00
// remember button state for creation of own MouseEvents
SetMouseButtonCode(rMEvt.GetButtons());
bool bReturn = false;
2000-09-18 16:07:07 +00:00
if ( pView->IsCreateObj() && rMEvt.IsLeft() )
{
pView->EndCreateObj(SDRCREATE_FORCEEND);
bReturn = true;
2000-09-18 16:07:07 +00:00
}
return (FuConstruct::MouseButtonUp(rMEvt) || bReturn);
}
/*************************************************************************
|*
|* Tastaturereignisse bearbeiten
|*
|* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
2000-09-18 16:07:07 +00:00
|* FALSE.
|*
\************************************************************************/
bool FuConstUnoControl::KeyInput(const KeyEvent& rKEvt)
2000-09-18 16:07:07 +00:00
{
return FuConstruct::KeyInput(rKEvt);
2000-09-18 16:07:07 +00:00
}
/*************************************************************************
|*
|* Function aktivieren
|*
\************************************************************************/
void FuConstUnoControl::Activate()
{
pView->SetCurrentObj( nIdentifier, nInventor );
aNewPointer = Pointer( PointerStyle::DrawRect );
2000-09-18 16:07:07 +00:00
aOldPointer = pWindow->GetPointer();
pViewShell->SetActivePointer( aNewPointer );
SdrLayer* pLayer = pView->GetModel()->GetLayerAdmin().GetLayerPerID(SC_LAYER_CONTROLS);
if (pLayer)
pView->SetActiveLayer( pLayer->GetName() );
FuConstruct::Activate();
}
/*************************************************************************
|*
|* Function deaktivieren
|*
\************************************************************************/
void FuConstUnoControl::Deactivate()
{
FuConstruct::Deactivate();
SdrLayer* pLayer = pView->GetModel()->GetLayerAdmin().GetLayerPerID(SC_LAYER_FRONT);
if (pLayer)
pView->SetActiveLayer( pLayer->GetName() );
pViewShell->SetActivePointer( aOldPointer );
}
2011-03-01 14:29:24 +01:00
// Create default drawing objects via keyboard
SdrObject* FuConstUnoControl::CreateDefaultObject(const sal_uInt16 /* nID */, const Rectangle& rRectangle)
{
// case SID_FM_CREATE_CONTROL:
SdrObject* pObj = SdrObjFactory::MakeNewObject(
pView->GetCurrentObjInventor(), pView->GetCurrentObjIdentifier(),
0L, pDrDoc);
if(pObj)
{
pObj->SetLogicRect(rRectangle);
}
return pObj;
}
2000-09-18 16:07:07 +00:00
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */