SdrLayer* pLayer;
SdrLayerAdmin& rAdmin = GetModel().GetLayerAdmin();
pLayer = rAdmin.GetLayerPerID(SC_LAYER_BACK); if (pLayer)
SetLayerLocked( pLayer->GetName(), bProt || !bEx );
pLayer = rAdmin.GetLayerPerID(SC_LAYER_INTERN); if (pLayer)
SetLayerLocked( pLayer->GetName() );
pLayer = rAdmin.GetLayerPerID(SC_LAYER_FRONT); if (pLayer)
{
SetLayerLocked( pLayer->GetName(), bProt );
SetActiveLayer( pLayer->GetName() ); // set active layer to FRONT
}
pLayer = rAdmin.GetLayerPerID(SC_LAYER_CONTROLS); if (pLayer)
SetLayerLocked( pLayer->GetName(), bProt );
pLayer = rAdmin.GetLayerPerID(SC_LAYER_HIDDEN); if (pLayer)
{
SetLayerLocked( pLayer->GetName(), bProt );
SetLayerVisible( pLayer->GetName(), false);
}
// #i11702# use SdrUndoObjectLayerChange for undo // STR_UNDO_SELATTR is "Attributes" - should use a different text later
BegUndo( ScResId( STR_UNDO_SELATTR ) );
// #i110829# remove the cell selection only if drawing objects are selected if ( !bInConstruct && rMarkList.GetMarkCount() )
{
pViewSh->Unmark(); // remove cell selection
// end cell edit mode if drawing objects are selected
pScMod->InputEnterHandler();
}
ScClient* pClient = static_cast<ScClient*>( pViewSh->GetIPClient() ); if ( pClient && pClient->IsObjectInPlaceActive() && !bUnoRefDialog )
{ // do not display the handles for ViewShell::Activate from the Reset2Open
pClient->DeactivateObject(); // replacing image ole graphics is now done in ScClient::UIActivate
}
if ( nMarkCount == 0 && !rViewData.GetViewShell()->IsDrawSelMode() && !bInConstruct )
{ // relock layers that may have been unlocked before
LockBackgroundLayer(true);
LockInternalLayer();
}
bool bSubShellSet = false; if (nMarkCount == 1)
{
SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
SdrObjKind nSdrObjKind = pObj->GetObjIdentifier(); if (nSdrObjKind == SdrObjKind::OLE2)
{
pOle2Obj = static_cast<SdrOle2Obj*>(pObj); if (!ScDocument::IsChart(pObj) )
pViewSh->SetOleObjectShell(true); else
pViewSh->SetChartShell(true);
bSubShellSet = true;
} elseif (nSdrObjKind == SdrObjKind::Graphic)
{
pGrafObj = static_cast<SdrGrafObj*>(pObj);
pViewSh->SetGraphicShell(true);
bSubShellSet = true;
} elseif (nSdrObjKind == SdrObjKind::Media)
{
pViewSh->SetMediaShell(true);
bSubShellSet = true;
} elseif (nSdrObjKind == SdrObjKind::Text)
{ // prevent switching to the drawing shell if (!pViewSh->IsDrawTextShell()) // when creating a text object @#70206#
pViewSh->SetDrawShell(true);
} elseif (!pViewSh->IsDrawTextShell())
{ // tdf#166481: we only need to switch to draw shell if we have not // already created a text shell for text edit mode
pViewSh->SetDrawShell(true);
}
}
if ( nMarkCount && !bSubShellSet )
{ bool bOnlyControls = true; bool bOnlyGraf = true; for (size_t i=0; i<nMarkCount; ++i)
{
SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj(); if ( auto pObjGroup = dynamic_cast<const SdrObjGroup*>( pObj) )
{ const SdrObjList *pLst = pObjGroup->GetSubList(); const size_t nListCount = pLst->GetObjCount(); if ( nListCount == 0 )
{ // An empty group (may occur during Undo) is no control or graphics object. // Creating the form shell during undo would lead to problems with the undo manager.
bOnlyControls = false;
bOnlyGraf = false;
} for ( size_t j = 0; j < nListCount; ++j )
{
SdrObject *pSubObj = pLst->GetObj( j );
assert(pSubObj);
if (dynamic_cast<const SdrUnoObj*>( pSubObj) == nullptr)
bOnlyControls = false; if (pSubObj->GetObjIdentifier() != SdrObjKind::Graphic)
bOnlyGraf = false;
if ( !bOnlyControls && !bOnlyGraf ) break;
}
} else
{ if (dynamic_cast<const SdrUnoObj*>( pObj) == nullptr)
bOnlyControls = false; if (pObj->GetObjIdentifier() != SdrObjKind::Graphic)
bOnlyGraf = false;
}
if ( !bOnlyControls && !bOnlyGraf ) break;
}
if(bOnlyControls)
{
pViewSh->SetDrawFormShell(true); // now UNO controls
} elseif(bOnlyGraf)
{
pViewSh->SetGraphicShell(true);
} elseif(nMarkCount>1)
{
pViewSh->SetDrawShell(true);
}
}
void ScDrawView::ModelHasChanged()
{
SdrObject* pEditObj = GetTextEditObject(); if ( pEditObj && !pEditObj->IsInserted() )
{ // SdrObjEditView::ModelHasChanged will end text edit in this case, // so make sure the EditEngine's undo manager is no longer used.
rViewData.GetViewShell()->SetDrawTextUndo(nullptr);
SetCreateMode(); // don't leave FuText in a funny state
}
OSL_ENSURE( nTab == nObjectTab, "Switching sheets did not work" );
pView->ScrollToObject( pFound );
/* To select an object on the background layer, the layer has to beunlockedevenifexclusivedrawingselectionmodeisnotactive
(this is reversed in MarkListHasChanged when nothing is selected) */ if ( pFound->GetLayer() == SC_LAYER_BACK &&
!rViewData.GetViewShell()->IsDrawSelMode() &&
!rDoc.IsTabProtected( nTab ) &&
!rViewData.GetSfxDocShell().IsReadOnly() )
{
LockBackgroundLayer(false);
}
bool ScDrawView::InsertObjectSafe(SdrObject* pObj, SdrPageView& rPV)
{
SdrInsertFlags nOptions=SdrInsertFlags::NONE; // Do not change marks when the ole object is active // (for Drop from ole object would otherwise be deactivated in the middle of ExecuteDrag!)
void ScDrawView::DeleteMarked()
{ // try to delete a note caption object with its cell note in the Calc document
ScDrawObjData* pCaptData = nullptr; if( SdrObject* pCaptObj = GetMarkedNoteCaption( &pCaptData ) )
{
ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer();
ScDocShell& rDocShell = rViewData.GetDocShell();
SfxUndoManager* pUndoMgr = rDocShell.GetUndoManager(); bool bUndo = pDrawLayer && pUndoMgr && rDoc.IsUndoEnabled();
// remove the cell note from document, we are its owner now
std::unique_ptr<ScPostIt> pNote = rDoc.ReleaseNote( pCaptData->maStart );
OSL_ENSURE( pNote, "ScDrawView::DeleteMarked - cell note missing in document" ); if( pNote )
{ // rescue note data for undo (with pointer to caption object)
ScNoteData aNoteData = pNote->GetNoteData();
OSL_ENSURE( aNoteData.mxCaption.get() == pCaptObj, "ScDrawView::DeleteMarked - caption object does not match" ); // collect the drawing undo action created while deleting the note if( bUndo )
pDrawLayer->BeginCalcUndo(false); // delete the note (already removed from document above)
pNote.reset(); // add the undo action for the note if( bUndo )
pUndoMgr->AddUndoAction( std::make_unique<ScUndoReplaceNote>( rDocShell, pCaptData->maStart, aNoteData, false, pDrawLayer->GetCalcUndo() ) ); // repaint the cell to get rid of the note marker
rDocShell.PostPaintCell( pCaptData->maStart ); // done, return now to skip call of FmFormView::DeleteMarked() return;
}
}
if(pDropMarkObj)
{
pDropMarker.reset( new SdrDropMarkerOverlay(*this, *pDropMarkObj) );
}
}
}
// In order to counteract the effects of rounding due to the nature of how the // grid positions are calculated and drawn we calculate the offset needed at the // current zoom to be applied to an SrdObject when it is drawn in order to make // sure that it's position relative to the nearest cell anchor doesn't change. // Of course not all shape(s)/control(s) are cell anchored, if the // object doesn't have a cell anchor we synthesise a temporary anchor. void ScDrawView::SyncForGrid( SdrObject* pObj )
{ // process members of a group shape separately if ( auto pObjGroup = dynamic_cast<const SdrObjGroup*>( pObj) )
{
SdrObjList *pLst = pObjGroup->GetSubList(); for (const rtl::Reference<SdrObject>& pChild : *pLst)
SyncForGrid( pChild.get() );
}
if(nullptr != pData && pData->maStart.IsValid())
{
aOldStt = pData->maStart;
} else
{ // Page anchored object so... // synthesise an anchor ( but don't attach it to // the object as we want to maintain page anchoring )
ScDrawObjData aAnchor; const tools::Rectangle aObjRect(rSdrObject.GetLogicRect());
ScDrawLayer::GetCellAnchorFromPosition(
aObjRect,
aAnchor,
rDoc,
GetTab());
aOldStt = aAnchor.maStart;
}
MapMode aDrawMode = pGridWin->GetDrawMapMode();
// find pos anchor position
Point aOldPos(rDoc.GetColOffset(aOldStt.Col(), aOldStt.Tab()), rDoc.GetRowOffset(aOldStt.Row(), aOldStt.Tab()));
aOldPos = convertTwipToMm100(aOldPos);
// find position of same point on the screen ( e.g. grid )
ScSplitPos eWhich(rViewData.GetActivePart());
Point aCurPos(rViewData.GetScrPos(aOldStt.Col(), aOldStt.Row(), eWhich, true));
Point aCurPosHmm(pGridWin->PixelToLogic(aCurPos, aDrawMode));
Point aGridOff(aCurPosHmm - aOldPos);
// No SdrObject, so synthesise an anchor ( but don't attach it to // the object as we want to maintain page anchoring )
ScDrawObjData aAnchor; const tools::Rectangle aRectangle(
basegfx::fround<tools::Long>(rB2DRange.getMinX()), basegfx::fround<tools::Long>(rB2DRange.getMinY()),
basegfx::fround<tools::Long>(rB2DRange.getMaxX()), basegfx::fround<tools::Long>(rB2DRange.getMaxY()));
ScDrawLayer::GetCellAnchorFromPosition(
aRectangle,
aAnchor,
rDoc,
GetTab());
ScAddress aOldStt(aAnchor.maStart);
MapMode aDrawMode = pGridWin->GetDrawMapMode();
// find pos anchor position
Point aOldPos(rDoc.GetColOffset(aOldStt.Col(), aOldStt.Tab()), rDoc.GetRowOffset(aOldStt.Row(), aOldStt.Tab()));
aOldPos = convertTwipToMm100(aOldPos);
// find position of same point on the screen ( e.g. grid )
ScSplitPos eWhich(rViewData.GetActivePart());
Point aCurPos(rViewData.GetScrPos(aOldStt.Col(), aOldStt.Row(), eWhich, true));
Point aCurPosHmm(pGridWin->PixelToLogic(aCurPos, aDrawMode));
Point aGridOff(aCurPosHmm - aOldPos);
// Own derivation of ObjectContact to allow on-demand calculation of // GridOffset for non-linear ViewToDevice transformation (calc) namespace sdr::contact
{ namespace {
class ObjectContactOfScDrawView final : public ObjectContactOfPageView
{ private: // The ScDrawView to work on const ScDrawView& mrScDrawView;
bool ObjectContactOfScDrawView::supportsGridOffsets() const
{ // Except when scPrintTwipsMsgs flag is active, // Calc in LOK mode directly sets pixel-aligned logical coordinates for draw-objects. if (comphelper::LibreOfficeKit::isActive() &&
!comphelper::LibreOfficeKit::isCompatFlagSet(
comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs)) returnfalse;
// no GridOffset support for printer if(isOutputToPrinter())
{ returnfalse;
}
// no GridOffset support for PDF export if(isOutputToPDFFile())
{ returnfalse;
}
// yes - we support it returntrue;
}
void ObjectContactOfScDrawView::calculateGridOffsetForViewObjectContact(
basegfx::B2DVector& rTarget, const ViewObjectContact& rClient) const
{ // Here the on-demand calculation happens. Try to access the SdrObject involved
SdrObject* pTargetSdrObject(rClient.GetViewContact().TryToGetSdrObject());
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.