LibreOffice Module sw (master)  1
docdraw.cxx
Go to the documentation of this file.
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  * This file incorporates work covered by the following license notice:
9  *
10  * Licensed to the Apache Software Foundation (ASF) under one or more
11  * contributor license agreements. See the NOTICE file distributed
12  * with this work for additional information regarding copyright
13  * ownership. The ASF licenses this file to you under the Apache
14  * License, Version 2.0 (the "License"); you may not use this file
15  * except in compliance with the License. You may obtain a copy of
16  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
17  */
18 
19 #include <hintids.hxx>
20 #include <editeng/flditem.hxx>
21 #include <editeng/editeng.hxx>
22 #include <editeng/colritem.hxx>
23 #include <svx/svdpage.hxx>
24 #include <svx/svdogrp.hxx>
25 #include <editeng/measfld.hxx>
26 #include <sal/log.hxx>
27 #include <osl/diagnose.h>
28 #include <fmtanchr.hxx>
29 #include <charatr.hxx>
30 #include <frmfmt.hxx>
31 #include <charfmt.hxx>
32 #include <viewimp.hxx>
33 #include <doc.hxx>
34 #include <docfunc.hxx>
35 #include <IDocumentUndoRedo.hxx>
37 #include <IDocumentState.hxx>
40 #include <poolfmt.hxx>
41 #include <drawdoc.hxx>
42 #include <UndoDraw.hxx>
43 #include <swundo.hxx>
44 #include <dcontact.hxx>
45 #include <dview.hxx>
46 #include <mvsave.hxx>
47 #include <flyfrm.hxx>
48 #include <dflyobj.hxx>
49 #include <txtfrm.hxx>
50 #include <editeng/frmdiritem.hxx>
51 #include <fmtornt.hxx>
52 #include <svx/svditer.hxx>
53 
54 #include <vector>
55 
56 using namespace ::com::sun::star;
57 using namespace ::com::sun::star::linguistic2;
58 
65 static void lcl_AdjustPositioningAttr( SwDrawFrameFormat* _pFrameFormat,
66  const SdrObject& _rSdrObj )
67 {
68  const SwContact* pContact = GetUserCall( &_rSdrObj );
69  OSL_ENSURE( pContact, "<lcl_AdjustPositioningAttr(..)> - missing contact object." );
70 
71  // determine position of new group object relative to its anchor frame position
72  SwTwips nHoriRelPos = 0;
73  SwTwips nVertRelPos = 0;
74  {
75  const SwFrame* pAnchorFrame = pContact->GetAnchoredObj( &_rSdrObj )->GetAnchorFrame();
76  OSL_ENSURE( !pAnchorFrame ||
77  !pAnchorFrame->IsTextFrame() ||
78  !static_cast<const SwTextFrame*>(pAnchorFrame)->IsFollow(),
79  "<lcl_AdjustPositioningAttr(..)> - anchor frame is a follow." );
80  bool bVert = false;
81  bool bR2L = false;
82  // #i45952# - use anchor position of anchor frame, if it exist.
83  Point aAnchorPos;
84  if ( pAnchorFrame )
85  {
86  // #i45952#
87  aAnchorPos = pAnchorFrame->GetFrameAnchorPos( ::HasWrap( &_rSdrObj ) );
88  bVert = pAnchorFrame->IsVertical();
89  bR2L = pAnchorFrame->IsRightToLeft();
90  }
91  else
92  {
93  // #i45952#
94  aAnchorPos = _rSdrObj.GetAnchorPos();
95  // If no anchor frame exist - e.g. because no layout exists - the
96  // default layout direction is taken.
97  const SvxFrameDirectionItem& rDirItem =
98  _pFrameFormat->GetAttrSet().GetPool()->GetDefaultItem( RES_FRAMEDIR );
99  switch ( rDirItem.GetValue() )
100  {
101  case SvxFrameDirection::Vertical_LR_TB:
102  {
103  // vertical from left-to-right
104  bVert = true;
105  bR2L = true;
106  OSL_FAIL( "<lcl_AdjustPositioningAttr(..)> - vertical from left-to-right not supported." );
107  }
108  break;
109  case SvxFrameDirection::Vertical_RL_TB:
110  {
111  // vertical from right-to-left
112  bVert = true;
113  bR2L = false;
114  }
115  break;
116  case SvxFrameDirection::Horizontal_RL_TB:
117  {
118  // horizontal from right-to-left
119  bVert = false;
120  bR2L = true;
121  }
122  break;
123  case SvxFrameDirection::Horizontal_LR_TB:
124  {
125  // horizontal from left-to-right
126  bVert = false;
127  bR2L = false;
128  }
129  break;
130  case SvxFrameDirection::Environment:
131  SAL_WARN("sw.core", "lcl_AdjustPositioningAttr(..) SvxFrameDirection::Environment not supported");
132  break;
133  default: break;
134  }
135 
136  }
137  // use geometry of drawing object
138  const tools::Rectangle aObjRect = _rSdrObj.GetSnapRect();
139 
140  if ( bVert )
141  {
142  if ( bR2L ) {
143  //SvxFrameDirection::Vertical_LR_TB
144  nHoriRelPos = aObjRect.Left() - aAnchorPos.getX();
145  nVertRelPos = aObjRect.Top() - aAnchorPos.getY();
146  } else {
147  //SvxFrameDirection::Vertical_RL_TB
148  nHoriRelPos = aObjRect.Top() - aAnchorPos.getY();
149  nVertRelPos = aAnchorPos.getX() - aObjRect.Right();
150  }
151  }
152  else if ( bR2L )
153  {
154  nHoriRelPos = aAnchorPos.getX() - aObjRect.Right();
155  nVertRelPos = aObjRect.Top() - aAnchorPos.getY();
156  }
157  else
158  {
159  nHoriRelPos = aObjRect.Left() - aAnchorPos.getX();
160  nVertRelPos = aObjRect.Top() - aAnchorPos.getY();
161  }
162  }
163 
164  _pFrameFormat->SetFormatAttr( SwFormatHoriOrient( nHoriRelPos, text::HoriOrientation::NONE, text::RelOrientation::FRAME ) );
165  _pFrameFormat->SetFormatAttr( SwFormatVertOrient( nVertRelPos, text::VertOrientation::NONE, text::RelOrientation::FRAME ) );
166  // #i44334#, #i44681# - positioning attributes already set
167  _pFrameFormat->PosAttrSet();
168  // #i34750# - keep current object rectangle for drawing
169  // objects. The object rectangle is used on events from the drawing layer
170  // to adjust the positioning attributes - see <SwDrawContact::Changed_(..)>.
171  {
172  const SwAnchoredObject* pAnchoredObj = pContact->GetAnchoredObj( &_rSdrObj );
173  if ( auto pAnchoredDrawObj = dynamic_cast<const SwAnchoredDrawObject*>( pAnchoredObj) )
174  {
175  const tools::Rectangle aObjRect = _rSdrObj.GetSnapRect();
176  const_cast<SwAnchoredDrawObject*>(pAnchoredDrawObj)
177  ->SetLastObjRect( aObjRect );
178  }
179  }
180 }
181 
183 {
184  // replace marked 'virtual' drawing objects by the corresponding 'master'
185  // drawing objects.
187 
188  const SdrMarkList &rMrkList = rDrawView.GetMarkedObjectList();
189  SdrObject *pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
190  bool bNoGroup = ( nullptr == pObj->getParentSdrObjectFromSdrObject() );
191  SwDrawContact* pNewContact = nullptr;
192  if( bNoGroup )
193  {
194  SwDrawFrameFormat *pFormat = nullptr;
195 
196  // Revoke anchor attribute.
197  SwDrawContact *pMyContact = static_cast<SwDrawContact*>(GetUserCall(pObj));
198  const SwFormatAnchor aAnch( pMyContact->GetFormat()->GetAnchor() );
199 
200  std::unique_ptr<SwUndoDrawGroup> pUndo;
202  pUndo.reset(new SwUndoDrawGroup( o3tl::narrowing<sal_uInt16>(rMrkList.GetMarkCount()), *this));
203 
204  // #i53320#
205  bool bGroupMembersNotPositioned( false );
206  {
207  SwAnchoredDrawObject* pAnchoredDrawObj =
208  static_cast<SwAnchoredDrawObject*>(pMyContact->GetAnchoredObj( pObj ));
209  bGroupMembersNotPositioned = pAnchoredDrawObj->NotYetPositioned();
210  }
211 
212  std::vector<std::pair<SwFrameFormat*, SdrObject*>> vSavedTextBoxes;
213  // Destroy ContactObjects and formats.
214  for( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
215  {
216  pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
217  SwDrawContact *pContact = static_cast<SwDrawContact*>(GetUserCall(pObj));
218 
219  // #i53320#
220 #if OSL_DEBUG_LEVEL > 0
221  SwAnchoredDrawObject* pAnchoredDrawObj =
222  static_cast<SwAnchoredDrawObject*>(pContact->GetAnchoredObj( pObj ));
223  OSL_ENSURE( bGroupMembersNotPositioned == pAnchoredDrawObj->NotYetPositioned(),
224  "<SwDoc::GroupSelection(..)> - group members have different positioning status!" );
225 #endif
226  // Before the format will be killed, save its textbox for later use.
227  if (auto pTextBox = SwTextBoxHelper::getOtherTextBoxFormat(pContact->GetFormat(), RES_DRAWFRMFMT, pObj))
228  vSavedTextBoxes.push_back(std::pair<SwFrameFormat*, SdrObject*>(pTextBox, pObj));
229 
230  pFormat = static_cast<SwDrawFrameFormat*>(pContact->GetFormat());
231  // Deletes itself!
232  pContact->Changed(*pObj, SdrUserCallType::Delete, pObj->GetLastBoundRect() );
233  pObj->SetUserCall( nullptr );
234 
235  if( pUndo )
236  pUndo->AddObj( i, pFormat, pObj );
237  else
238  DelFrameFormat( pFormat );
239 
240  // #i45952# - re-introduce position normalization of group member
241  // objects, because its anchor position is cleared, when they are
242  // grouped.
243  Point aAnchorPos( pObj->GetAnchorPos() );
244  pObj->NbcSetAnchorPos( Point( 0, 0 ) );
245  pObj->NbcMove( Size( aAnchorPos.getX(), aAnchorPos.getY() ) );
246  }
247 
249  GetDfltFrameFormat() );
250  pFormat->SetFormatAttr( aAnch );
251  // #i36010# - set layout direction of the position
252  pFormat->SetPositionLayoutDir(
253  text::PositionLayoutDir::PositionInLayoutDirOfAnchor );
254 
255  // Add the saved textboxes to the new format.
256  auto pTextBoxNode = new SwTextBoxNode(pFormat);
257  for (auto& pTextBoxEntry : vSavedTextBoxes)
258  {
259  pTextBoxNode->AddTextBox(pTextBoxEntry.second, pTextBoxEntry.first);
260  pTextBoxEntry.first->SetOtherTextBoxFormat(pTextBoxNode);
261  }
262  pFormat->SetOtherTextBoxFormat(pTextBoxNode);
263  vSavedTextBoxes.clear();
264 
265  rDrawView.GroupMarked();
266  OSL_ENSURE( rMrkList.GetMarkCount() == 1, "GroupMarked more or none groups." );
267 
268  SdrObject* pNewGroupObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
269  pNewGroupObj->SetName(pFormat->GetName());
270  pNewContact = new SwDrawContact( pFormat, pNewGroupObj );
271  // #i35635#
272  pNewContact->MoveObjToVisibleLayer( pNewGroupObj );
273  pNewContact->ConnectToLayout();
274  // #i53320# - No adjustment of the positioning and alignment
275  // attributes, if group members aren't positioned yet.
276  if ( !bGroupMembersNotPositioned )
277  {
278  // #i26791# - Adjust positioning and alignment attributes.
279  lcl_AdjustPositioningAttr( pFormat, *pNewGroupObj );
280  }
281 
282  if( pUndo )
283  {
284  pUndo->SetGroupFormat( pFormat );
285  GetIDocumentUndoRedo().AppendUndo( std::move(pUndo) );
286  }
287  }
288  else
289  {
290  if (GetIDocumentUndoRedo().DoesUndo())
291  {
293  }
294 
295  rDrawView.GroupMarked();
296  OSL_ENSURE( rMrkList.GetMarkCount() == 1, "GroupMarked more or none groups." );
297  }
298 
299  return pNewContact;
300 }
301 
303 {
304  bool const bUndo = GetIDocumentUndoRedo().DoesUndo();
305  if( bUndo )
306  {
308  }
309 
310  // replace marked 'virtual' drawing objects by the corresponding 'master'
311  // drawing objects.
313 
314  const SdrMarkList &rMrkList = rDrawView.GetMarkedObjectList();
315  std::unique_ptr<std::vector< std::pair< SwDrawFrameFormat*, SdrObject* > >[]> pFormatsAndObjs;
316  const size_t nMarkCount( rMrkList.GetMarkCount() );
317  if ( nMarkCount )
318  {
319  pFormatsAndObjs.reset( new std::vector< std::pair< SwDrawFrameFormat*, SdrObject* > >[nMarkCount] );
320  SdrObject *pMyObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
321  if( !pMyObj->getParentSdrObjectFromSdrObject() )
322  {
323  for ( size_t i = 0; i < nMarkCount; ++i )
324  {
325  SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
326  if ( auto pObjGroup = dynamic_cast<SdrObjGroup*>(pObj) )
327  {
328  SwDrawContact *pContact = static_cast<SwDrawContact*>(GetUserCall(pObj));
329 
330  SwTextBoxNode* pTextBoxNode = nullptr;
331  if (auto pGroupFormat = pContact->GetFormat())
332  pTextBoxNode = pGroupFormat->GetOtherTextBoxFormat();
333 
334  SwFormatAnchor aAnch( pContact->GetFormat()->GetAnchor() );
335  SdrObjList *pLst = pObjGroup->GetSubList();
336 
337  SwUndoDrawUnGroup* pUndo = nullptr;
338  if( bUndo )
339  {
340  pUndo = new SwUndoDrawUnGroup( pObjGroup, *this );
341  GetIDocumentUndoRedo().AppendUndo(std::unique_ptr<SwUndo>(pUndo));
342  }
343 
344  for ( size_t i2 = 0; i2 < pLst->GetObjCount(); ++i2 )
345  {
346  SdrObject* pSubObj = pLst->GetObj( i2 );
348  GetDfltFrameFormat() );
349  pFormat->SetFormatAttr( aAnch );
350 
351  if (pTextBoxNode)
352  if (auto pTextBoxFormat = pTextBoxNode->GetTextBox(pSubObj))
353  {
354  auto pNewTextBoxNode = new SwTextBoxNode(pFormat);
355  pNewTextBoxNode->AddTextBox(pSubObj, pTextBoxFormat);
356  pFormat->SetOtherTextBoxFormat(pNewTextBoxNode);
357  pTextBoxFormat->SetOtherTextBoxFormat(pNewTextBoxNode);
358  }
359 
360  // #i36010# - set layout direction of the position
361  pFormat->SetPositionLayoutDir(
362  text::PositionLayoutDir::PositionInLayoutDirOfAnchor );
363  if (pSubObj->GetName().isEmpty())
364  pSubObj->SetName(pFormat->GetName());
365  pFormatsAndObjs[i].emplace_back( pFormat, pSubObj );
366 
367  if( bUndo )
368  pUndo->AddObj( o3tl::narrowing<sal_uInt16>(i2), pFormat );
369  }
370  }
371  }
372  }
373  }
374  rDrawView.UnGroupMarked();
375  // creation of <SwDrawContact> instances for the former group members and
376  // its connection to the Writer layout.
377  for ( size_t i = 0; i < nMarkCount; ++i )
378  {
379  SwUndoDrawUnGroupConnectToLayout* pUndo = nullptr;
380  if( bUndo )
381  {
382  pUndo = new SwUndoDrawUnGroupConnectToLayout(*this);
383  GetIDocumentUndoRedo().AppendUndo(std::unique_ptr<SwUndo>(pUndo));
384  }
385 
386  while ( !pFormatsAndObjs[i].empty() )
387  {
388  SwDrawFrameFormat* pFormat( pFormatsAndObjs[i].back().first );
389  SdrObject* pObj( pFormatsAndObjs[i].back().second );
390  pFormatsAndObjs[i].pop_back();
391 
392  SwDrawContact* pContact = new SwDrawContact( pFormat, pObj );
393  pContact->MoveObjToVisibleLayer( pObj );
394  pContact->ConnectToLayout();
395  lcl_AdjustPositioningAttr( pFormat, *pObj );
396 
397  if ( bUndo )
398  {
399  pUndo->AddFormatAndObj( pFormat, pObj );
400  }
401  }
402  }
403 }
404 
406 {
407  bool bCallBase = false;
408  const SdrMarkList &rMrkList = rDrawView.GetMarkedObjectList();
409  if( rMrkList.GetMarkCount() )
410  {
412  bool bDelMarked = true;
413 
414  if( 1 == rMrkList.GetMarkCount() )
415  {
416  SdrObject *pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
417  if( auto pDrawObj = dynamic_cast<SwVirtFlyDrawObj*>( pObj) )
418  {
419  SwFlyFrameFormat* pFrameFormat = pDrawObj->GetFlyFrame()->GetFormat();
420  if( pFrameFormat )
421  {
422  getIDocumentLayoutAccess().DelLayoutFormat( pFrameFormat );
423  bDelMarked = false;
424  }
425  }
426  }
427 
428  for( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
429  {
430  SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
431  if( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) == nullptr )
432  {
433  SwDrawContact *pC = static_cast<SwDrawContact*>(GetUserCall(pObj));
434  SwDrawFrameFormat *pFrameFormat = static_cast<SwDrawFrameFormat*>(pC->GetFormat());
435  if( pFrameFormat &&
436  RndStdIds::FLY_AS_CHAR == pFrameFormat->GetAnchor().GetAnchorId() )
437  {
438  rDrawView.MarkObj( pObj, rDrawView.Imp().GetPageView(), true );
439  --i;
440  getIDocumentLayoutAccess().DelLayoutFormat( pFrameFormat );
441  }
442  }
443  }
444 
445  if( rMrkList.GetMarkCount() && bDelMarked )
446  {
447  SdrObject *pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
448  if( !pObj->getParentSdrObjectFromSdrObject() )
449  {
450  std::unique_ptr<SwUndoDrawDelete> pUndo;
452  pUndo.reset(new SwUndoDrawDelete( o3tl::narrowing<sal_uInt16>(rMrkList.GetMarkCount()), *this ));
453 
454  // Destroy ContactObjects, save formats.
455  for( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
456  {
457  const SdrMark& rMark = *rMrkList.GetMark( i );
458  pObj = rMark.GetMarkedSdrObj();
459  SwDrawContact *pContact = static_cast<SwDrawContact*>(pObj->GetUserCall());
460  if( pContact ) // of course not for grouped objects
461  {
462  SwDrawFrameFormat *pFormat = static_cast<SwDrawFrameFormat*>(pContact->GetFormat());
463  // before delete of selection is performed, marked
464  // <SwDrawVirtObj>-objects have to be replaced by its
465  // reference objects. Thus, assert, if a
466  // <SwDrawVirt>-object is found in the mark list.
467  if ( dynamic_cast<const SwDrawVirtObj*>( pObj) != nullptr )
468  {
469  OSL_FAIL( "<SwDrawVirtObj> is still marked for delete. application will crash!" );
470  }
471  // Deletes itself!
472  pContact->Changed(*pObj, SdrUserCallType::Delete, pObj->GetLastBoundRect() );
473  pObj->SetUserCall( nullptr );
474 
475  if( pUndo )
476  pUndo->AddObj( pFormat, rMark );
477  else
478  DelFrameFormat( pFormat );
479  }
480  }
481 
482  if( pUndo )
483  {
484  GetIDocumentUndoRedo().AppendUndo( std::move(pUndo) );
485  }
486  }
487  bCallBase = true;
488  }
490 
492  }
493 
494  return bCallBase;
495 }
496 
497 ZSortFly::ZSortFly(const SwFrameFormat* pFrameFormat, const SwFormatAnchor* pFlyAn, sal_uInt32 nArrOrdNum)
498  : m_pFormat(pFrameFormat)
499  , m_pAnchor(pFlyAn)
500  , m_nOrdNum(nArrOrdNum)
501 {
502  SAL_WARN_IF(m_pFormat->Which() != RES_FLYFRMFMT && m_pFormat->Which() != RES_DRAWFRMFMT, "sw.core", "What kind of format is this?");
504 }
505 
508 {
509  pOutliner->SetCalcFieldValueHdl(LINK(this, SwDoc, CalcFieldValueHdl));
510 }
511 
513 IMPL_LINK(SwDoc, CalcFieldValueHdl, EditFieldInfo*, pInfo, void)
514 {
515  if (!pInfo)
516  return;
517 
518  const SvxFieldItem& rField = pInfo->GetField();
519  const SvxFieldData* pField = rField.GetField();
520 
521  if (auto pDateField = dynamic_cast<const SvxDateField*>( pField))
522  {
523  // Date field
524  pInfo->SetRepresentation(
525  pDateField->GetFormatted(
526  *GetNumberFormatter(), LANGUAGE_SYSTEM) );
527  }
528  else if (auto pURLField = dynamic_cast<const SvxURLField*>( pField))
529  {
530  // URL field
531  switch ( pURLField->GetFormat() )
532  {
533  case SvxURLFormat::AppDefault:
534  case SvxURLFormat::Repr:
535  pInfo->SetRepresentation(pURLField->GetRepresentation());
536  break;
537 
538  case SvxURLFormat::Url:
539  pInfo->SetRepresentation(pURLField->GetURL());
540  break;
541  }
542 
543  sal_uInt16 nChrFormat;
544 
545  if (IsVisitedURL(pURLField->GetURL()))
546  nChrFormat = RES_POOLCHR_INET_VISIT;
547  else
548  nChrFormat = RES_POOLCHR_INET_NORMAL;
549 
550  SwFormat *pFormat = getIDocumentStylePoolAccess().GetCharFormatFromPool(nChrFormat);
551 
552  Color aColor(COL_LIGHTBLUE);
553  if (pFormat)
554  aColor = pFormat->GetColor().GetValue();
555 
556  pInfo->SetTextColor(aColor);
557  }
558  else if (dynamic_cast<const SdrMeasureField*>( pField))
559  {
560  // Clear measure field
561  pInfo->SetFieldColor(std::optional<Color>());
562  }
563  else if ( auto pTimeField = dynamic_cast<const SvxExtTimeField*>( pField) )
564  {
565  // Time field
566  pInfo->SetRepresentation(
567  pTimeField->GetFormatted(*GetNumberFormatter(), LANGUAGE_SYSTEM) );
568  }
569  else
570  {
571  OSL_FAIL("unknown field command");
572  pInfo->SetRepresentation( OUString( '?' ) );
573  }
574 }
575 
576 // #i62875#
577 namespace docfunc
578 {
579  bool ExistsDrawObjs( SwDoc& p_rDoc )
580  {
581  bool bExistsDrawObjs( false );
582 
583  if ( p_rDoc.getIDocumentDrawModelAccess().GetDrawModel() &&
585  {
586  const SdrPage& rSdrPage( *(p_rDoc.getIDocumentDrawModelAccess().GetDrawModel()->GetPage( 0 )) );
587 
588  SdrObjListIter aIter( &rSdrPage, SdrIterMode::Flat );
589  while( aIter.IsMore() )
590  {
591  SdrObject* pObj( aIter.Next() );
592  if ( !dynamic_cast<SwVirtFlyDrawObj*>(pObj) &&
593  !dynamic_cast<SwFlyDrawObj*>(pObj) )
594  {
595  bExistsDrawObjs = true;
596  break;
597  }
598  }
599  }
600 
601  return bExistsDrawObjs;
602  }
603 
604  bool AllDrawObjsOnPage( SwDoc& p_rDoc )
605  {
606  bool bAllDrawObjsOnPage( true );
607 
608  if ( p_rDoc.getIDocumentDrawModelAccess().GetDrawModel() &&
610  {
611  const SdrPage& rSdrPage( *(p_rDoc.getIDocumentDrawModelAccess().GetDrawModel()->GetPage( 0 )) );
612 
613  SdrObjListIter aIter( &rSdrPage, SdrIterMode::Flat );
614  while( aIter.IsMore() )
615  {
616  SdrObject* pObj( aIter.Next() );
617  if ( !dynamic_cast<SwVirtFlyDrawObj*>(pObj) &&
618  !dynamic_cast<SwFlyDrawObj*>(pObj) )
619  {
620  SwDrawContact* pDrawContact =
621  dynamic_cast<SwDrawContact*>(::GetUserCall( pObj ));
622  if ( pDrawContact )
623  {
624  SwAnchoredDrawObject* pAnchoredDrawObj =
625  dynamic_cast<SwAnchoredDrawObject*>(pDrawContact->GetAnchoredObj( pObj ));
626 
627  // error handling
628  {
629  if ( !pAnchoredDrawObj )
630  {
631  OSL_FAIL( "<docfunc::AllDrawObjsOnPage() - missing anchored draw object" );
632  bAllDrawObjsOnPage = false;
633  break;
634  }
635  }
636 
637  if ( pAnchoredDrawObj->NotYetPositioned() )
638  {
639  // The drawing object isn't yet layouted.
640  // Thus, it isn't known, if all drawing objects are on page.
641  bAllDrawObjsOnPage = false;
642  break;
643  }
644  else if ( pAnchoredDrawObj->IsOutsidePage() )
645  {
646  bAllDrawObjsOnPage = false;
647  break;
648  }
649  }
650  else
651  {
652  // contact object of drawing object doesn't exists.
653  // Thus, the drawing object isn't yet positioned.
654  // Thus, it isn't known, if all drawing objects are on page.
655  bAllDrawObjsOnPage = false;
656  break;
657  }
658  }
659  }
660  }
661 
662  return bAllDrawObjsOnPage;
663  }
664 }
665 
666 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static SwFrameFormat * getOtherTextBoxFormat(const SwFrameFormat *pFormat, sal_uInt16 nType, const SdrObject *pObject=nullptr)
If we have an associated TextFrame, then return that.
bool ExistsDrawObjs(SwDoc &p_rDoc)
method to check, if given Writer document contains at least one drawing object
Definition: docdraw.cxx:579
Base class for the following contact objects (frame + draw objects).
Definition: dcontact.hxx:66
Base class of the Writer layout elements.
Definition: frame.hxx:315
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:159
constexpr TypedWhichId< SvxFrameDirectionItem > RES_FRAMEDIR(120)
const SvxColorItem & GetColor(bool=true) const
Definition: charatr.hxx:128
static void lcl_AdjustPositioningAttr(SwDrawFrameFormat *_pFrameFormat, const SdrObject &_rSdrObj)
local method to determine positioning and alignment attributes for a drawing object, which is newly connected to the layout.
Definition: docdraw.cxx:65
SwFrameFormat * GetTextBox(const SdrObject *pDrawObject) const
size_t GetMarkCount() const
class for the positioning of drawing objects
OUString GetUniqueDrawObjectName() const
Definition: doclay.cxx:1389
const SwFrameFormat * m_pFormat
Definition: mvsave.hxx:163
ZSortFly(const SwFrameFormat *pFrameFormat, const SwFormatAnchor *pFlyAnchor, sal_uInt32 nArrOrdNum)
Definition: docdraw.cxx:497
void SetName(const OUString &rStr, const bool bSetChanged=true)
constexpr tools::Long Left() const
virtual void SetModified()=0
Must be called manually at changes of format.
virtual SwUndoId EndUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Closes undo block.
Definition: doc.hxx:188
Textboxes are basically textframe + shape pairs.
void PosAttrSet()
Definition: frmfmt.hxx:401
void AddFormatAndObj(SwDrawFrameFormat *pDrawFrameFormat, SdrObject *pDrawObject)
Definition: undraw.cxx:565
void SetCalcFieldValueHdl(Outliner *pOutliner)
In the Outliner, set a link to the method for field display in edit objects.
Definition: docdraw.cxx:507
bool DeleteSelection(SwDrawView &)
Definition: docdraw.cxx:405
void SetOtherTextBoxFormat(SwTextBoxNode *pNew)
Definition: frmfmt.hxx:106
SdrMark * GetMark(size_t nNum) const
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:144
SwDrawFrameFormat * MakeDrawFrameFormat(const OUString &rFormatName, SwFrameFormat *pDerivedFrom)
Definition: docfmt.cxx:762
SwContact * GetUserCall(const SdrObject *pObj)
Returns the UserCall if applicable from the group object.
Definition: dcontact.cxx:171
const SwViewShellImp & Imp() const
Definition: dview.hxx:102
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(156)
sal_uInt32 m_nOrdNum
Definition: mvsave.hxx:165
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
Definition: doc.cxx:155
virtual const tools::Rectangle & GetSnapRect() const
wrapper class for the positioning of Writer fly frames and drawing objects
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(159)
bool IsMore() const
const OUString & GetName() const
Definition: format.hxx:115
virtual void DelLayoutFormat(SwFrameFormat *pFormat)=0
bool IsTextFrame() const
Definition: frame.hxx:1235
virtual void SetPositionLayoutDir(const sal_Int16 _nPositionLayoutDir) override
Definition: atrfrm.cxx:3479
virtual bool DoesUndo() const =0
Is Undo enabled?
SwAttrPool * GetPool() const
Definition: swatrset.hxx:183
virtual void MoveObjToVisibleLayer(SdrObject *_pDrawObj)
method to move drawing object to corresponding visible layer
Definition: dcontact.cxx:209
Base class for various Writer styles.
Definition: format.hxx:46
SwDrawContact * GroupSelection(SdrView &)
Definition: docdraw.cxx:182
SdrObject * GetMarkedSdrObj() const
bool HasWrap(const SdrObject *pObj)
Definition: dcontact.cxx:139
virtual void AppendUndo(std::unique_ptr< SwUndo > pUndo)=0
Add new Undo action.
virtual void ClearRedo()=0
Delete all Redo actions.
Style of a layout element.
Definition: frmfmt.hxx:59
virtual SwUndoId StartUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Opens undo block.
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
Internet visited.
Definition: poolfmt.hxx:121
int i
SwFrameFormat * GetFormat()
Definition: dcontact.hxx:112
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
#define LANGUAGE_SYSTEM
const SdrMarkList & GetMarkedObjectList() const
FlyAnchors.
Definition: fmtanchr.hxx:34
const SdrPage * GetPage(sal_uInt16 nPgNum) const
virtual const SwDrawModel * GetDrawModel() const =0
Draw Model and id accessors.
constexpr tools::Long Right() const
void SetCalcFieldValueHdl(const Link< EditFieldInfo *, void > &rLink)
Internet normal.
Definition: poolfmt.hxx:120
void UnGroupSelection(SdrView &)
Definition: docdraw.cxx:302
IDocumentState const & getIDocumentState() const
Definition: doc.cxx:394
constexpr tools::Long Top() const
void SetUserCall(SdrObjUserCall *pUser)
virtual const SwAnchoredObject * GetAnchoredObj(const SdrObject *_pSdrObj) const =0
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
tools::Long SwTwips
Definition: swtypes.hxx:52
void UnGroupMarked()
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:405
OUString GetName() const
OUString GetUniqueShapeName() const
Definition: doclay.cxx:1384
const SwFrameFormat * GetDfltFrameFormat() const
Definition: doc.hxx:747
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:450
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:82
virtual const tools::Rectangle & GetLastBoundRect() const
SdrObject * Next()
bool AllDrawObjsOnPage(SwDoc &p_rDoc)
method to check, if given Writer document contains only drawing objects, which are completely on its ...
Definition: docdraw.cxx:604
static void ReplaceMarkedDrawVirtObjs(SdrMarkView &_rMarkView)
replace marked -objects by its reference object for delete marked objects.
Definition: dview.cxx:903
void AddObj(sal_uInt16 nPos, SwDrawFrameFormat *)
Definition: undraw.cxx:517
#define SAL_WARN_IF(condition, area, stream)
void GroupMarked()
virtual const SwAnchoredObject * GetAnchoredObj(const SdrObject *_pSdrObj) const override
Definition: dcontact.cxx:761
virtual void NbcMove(const Size &rSiz)
void ConnectToLayout(const SwFormatAnchor *pAnch=nullptr)
Inserts SdrObject in the arrays of the layout ((SwPageFrame and SwFrame).
Definition: dcontact.cxx:1781
virtual void Changed(const SdrObject &rObj, SdrUserCallType eType, const tools::Rectangle &rOldBoundRect) override
Virtual methods of SdrObjUserCall.
Definition: dcontact.cxx:965
bool IsRightToLeft() const
Definition: frame.hxx:988
const Point & GetAnchorPos() const
SdrObject * getParentSdrObjectFromSdrObject() const
virtual void CallSwClientNotify(const SfxHint &rHint) const override
Definition: calbck.cxx:326
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_LIGHTBLUE
void DelFrameFormat(SwFrameFormat *pFormat, bool bBroadcast=false)
Definition: docfmt.cxx:699
bool IsVertical() const
Definition: frame.hxx:974
#define SAL_WARN(area, stream)
virtual void NbcSetAnchorPos(const Point &rPnt)
bool MarkObj(const Point &rPnt, short nTol=-2, bool bToggle=false, bool bDeep=false)
const SwFrame * GetAnchorFrame() const
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:120
constexpr OUStringLiteral first
Point GetFrameAnchorPos(bool bIgnoreFlysAnchoredAtThisFrame) const
returns the position for anchors based on frame direction
Definition: ssfrm.cxx:291
SdrObjUserCall * GetUserCall() const
IMPL_LINK(SwDoc, CalcFieldValueHdl, EditFieldInfo *, pInfo, void)
Recognise fields/URLs in the Outliner and set how they are displayed.
Definition: docdraw.cxx:513
const Color & GetValue() const
SdrPageView * GetPageView()
Definition: viewimp.hxx:163
const SvxFieldData * GetField() const