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>
51#include <fmtornt.hxx>
52#include <svx/svditer.hxx>
53
54#include <vector>
55
56using namespace ::com::sun::star;
57using namespace ::com::sun::star::linguistic2;
58
65static 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;
201 if (GetIDocumentUndoRedo().DoesUndo())
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::map<const SdrObject*, SwFrameFormat*> 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 pShapeFormat = pContact->GetFormat())
228 if (auto pTextBoxNode = pShapeFormat->GetOtherTextBoxFormats())
229 for (const auto& rTextBoxElement : pTextBoxNode->GetAllTextBoxes())
230 vSavedTextBoxes.emplace(rTextBoxElement);
231
232 pFormat = static_cast<SwDrawFrameFormat*>(pContact->GetFormat());
233 // Deletes itself!
234 pContact->Changed(*pObj, SdrUserCallType::Delete, pObj->GetLastBoundRect() );
235 pObj->SetUserCall( nullptr );
236
237 if( pUndo )
238 pUndo->AddObj( i, pFormat, pObj );
239 else
240 DelFrameFormat( pFormat );
241
242 // #i45952# - re-introduce position normalization of group member
243 // objects, because its anchor position is cleared, when they are
244 // grouped.
245 Point aAnchorPos( pObj->GetAnchorPos() );
246 pObj->NbcSetAnchorPos( Point( 0, 0 ) );
247 pObj->NbcMove( Size( aAnchorPos.getX(), aAnchorPos.getY() ) );
248 }
249
252 pFormat->SetFormatAttr( aAnch );
253 // #i36010# - set layout direction of the position
254 pFormat->SetPositionLayoutDir(
255 text::PositionLayoutDir::PositionInLayoutDirOfAnchor );
256
257 // Add the saved textboxes to the new format.
258 auto pTextBoxNode = std::make_shared<SwTextBoxNode>(
259 SwTextBoxNode(static_cast<SwFrameFormat*>(pFormat)));
260 for (const auto& pTextBoxEntry : vSavedTextBoxes)
261 {
262 pTextBoxNode->AddTextBox(const_cast<SdrObject*>(pTextBoxEntry.first),
263 pTextBoxEntry.second);
264 pTextBoxEntry.second->SetOtherTextBoxFormats(pTextBoxNode);
265 }
266 pFormat->SetOtherTextBoxFormats(pTextBoxNode);
267 vSavedTextBoxes.clear();
268
269 rDrawView.GroupMarked();
270 OSL_ENSURE( rMrkList.GetMarkCount() == 1, "GroupMarked more or none groups." );
271
272 SdrObject* pNewGroupObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
273 pNewGroupObj->SetName(pFormat->GetName());
274 pNewContact = new SwDrawContact( pFormat, pNewGroupObj );
275 // #i35635#
276 pNewContact->MoveObjToVisibleLayer( pNewGroupObj );
277 pNewContact->ConnectToLayout();
278 // #i53320# - No adjustment of the positioning and alignment
279 // attributes, if group members aren't positioned yet.
280 if ( !bGroupMembersNotPositioned )
281 {
282 // #i26791# - Adjust positioning and alignment attributes.
283 lcl_AdjustPositioningAttr( pFormat, *pNewGroupObj );
284 }
285
286 if( pUndo )
287 {
288 pUndo->SetGroupFormat( pFormat );
289 GetIDocumentUndoRedo().AppendUndo( std::move(pUndo) );
290 }
291 }
292 else
293 {
294 if (GetIDocumentUndoRedo().DoesUndo())
295 {
296 GetIDocumentUndoRedo().ClearRedo();
297 }
298
299 rDrawView.GroupMarked();
300 OSL_ENSURE( rMrkList.GetMarkCount() == 1, "GroupMarked more or none groups." );
301 }
302
303 return pNewContact;
304}
305
306static void lcl_CollectTextBoxesForSubGroupObj(SwFrameFormat* pTargetFormat, std::shared_ptr<SwTextBoxNode> pTextBoxNode,
307 SdrObject* pSourceObjs)
308{
309 if (auto pChildrenObjs = pSourceObjs->getChildrenOfSdrObject())
310 for (size_t i = 0; i < pChildrenObjs->GetObjCount(); ++i)
311 lcl_CollectTextBoxesForSubGroupObj(pTargetFormat, pTextBoxNode, pChildrenObjs->GetObj(i));
312 else
313 {
314 if (auto pTextBox = pTextBoxNode->GetTextBox(pSourceObjs))
315 {
316 if (!pTargetFormat->GetOtherTextBoxFormats())
317 {
318 pTargetFormat->SetOtherTextBoxFormats(std::make_shared<SwTextBoxNode>(SwTextBoxNode(pTargetFormat)));
319 }
320 pTargetFormat->GetOtherTextBoxFormats()->AddTextBox(pSourceObjs, pTextBox);
321 pTextBox->SetOtherTextBoxFormats(pTargetFormat->GetOtherTextBoxFormats());
322 }
323 }
324}
325
326
328{
329 bool const bUndo = GetIDocumentUndoRedo().DoesUndo();
330 if( bUndo )
331 {
332 GetIDocumentUndoRedo().ClearRedo();
333 }
334
335 // replace marked 'virtual' drawing objects by the corresponding 'master'
336 // drawing objects.
338
339 const SdrMarkList &rMrkList = rDrawView.GetMarkedObjectList();
340 std::unique_ptr<std::vector< std::pair< SwDrawFrameFormat*, SdrObject* > >[]> pFormatsAndObjs;
341 const size_t nMarkCount( rMrkList.GetMarkCount() );
342 if ( nMarkCount )
343 {
344 pFormatsAndObjs.reset( new std::vector< std::pair< SwDrawFrameFormat*, SdrObject* > >[nMarkCount] );
345 SdrObject *pMyObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
346 if( !pMyObj->getParentSdrObjectFromSdrObject() )
347 {
348 for ( size_t i = 0; i < nMarkCount; ++i )
349 {
350 SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
351 if ( auto pObjGroup = dynamic_cast<SdrObjGroup*>(pObj) )
352 {
353 SwDrawContact *pContact = static_cast<SwDrawContact*>(GetUserCall(pObj));
354
355 std::shared_ptr<SwTextBoxNode> pTextBoxNode;
356 if (auto pGroupFormat = pContact->GetFormat())
357 pTextBoxNode = pGroupFormat->GetOtherTextBoxFormats();
358
359 SwFormatAnchor aAnch( pContact->GetFormat()->GetAnchor() );
360 SdrObjList *pLst = pObjGroup->GetSubList();
361
362 SwUndoDrawUnGroup* pUndo = nullptr;
363 if( bUndo )
364 {
365 pUndo = new SwUndoDrawUnGroup( pObjGroup, *this );
366 GetIDocumentUndoRedo().AppendUndo(std::unique_ptr<SwUndo>(pUndo));
367 }
368
369 for ( size_t i2 = 0; i2 < pLst->GetObjCount(); ++i2 )
370 {
371 SdrObject* pSubObj = pLst->GetObj( i2 );
374 pFormat->SetFormatAttr( aAnch );
375
376 if (pTextBoxNode)
377 {
378 if (!pObj->getChildrenOfSdrObject())
379 {
380 if (auto pTextBoxFormat = pTextBoxNode->GetTextBox(pSubObj))
381 {
382 auto pNewTextBoxNode =std::make_shared<SwTextBoxNode>(SwTextBoxNode(pFormat));
383 pNewTextBoxNode->AddTextBox(pSubObj, pTextBoxFormat);
384 pFormat->SetOtherTextBoxFormats(pNewTextBoxNode);
385 pTextBoxFormat->SetOtherTextBoxFormats(pNewTextBoxNode);
386 }
387 }
388 else
389 {
390 lcl_CollectTextBoxesForSubGroupObj(pFormat, pTextBoxNode, pSubObj);
391 }
392 }
393 // #i36010# - set layout direction of the position
394 pFormat->SetPositionLayoutDir(
395 text::PositionLayoutDir::PositionInLayoutDirOfAnchor );
396 if (pSubObj->GetName().isEmpty())
397 pSubObj->SetName(pFormat->GetName());
398 pFormatsAndObjs[i].emplace_back( pFormat, pSubObj );
399
400 if( bUndo )
401 pUndo->AddObj( o3tl::narrowing<sal_uInt16>(i2), pFormat );
402 }
403 }
404 }
405 }
406 }
407 rDrawView.UnGroupMarked();
408 // creation of <SwDrawContact> instances for the former group members and
409 // its connection to the Writer layout.
410 for ( size_t i = 0; i < nMarkCount; ++i )
411 {
412 SwUndoDrawUnGroupConnectToLayout* pUndo = nullptr;
413 if( bUndo )
414 {
415 pUndo = new SwUndoDrawUnGroupConnectToLayout(*this);
416 GetIDocumentUndoRedo().AppendUndo(std::unique_ptr<SwUndo>(pUndo));
417 }
418
419 while ( !pFormatsAndObjs[i].empty() )
420 {
421 SwDrawFrameFormat* pFormat( pFormatsAndObjs[i].back().first );
422 SdrObject* pObj( pFormatsAndObjs[i].back().second );
423 pFormatsAndObjs[i].pop_back();
424
425 SwDrawContact* pContact = new SwDrawContact( pFormat, pObj );
426 pContact->MoveObjToVisibleLayer( pObj );
427 pContact->ConnectToLayout();
428 lcl_AdjustPositioningAttr( pFormat, *pObj );
429
430 if ( bUndo )
431 {
432 pUndo->AddFormatAndObj( pFormat, pObj );
433 }
434 }
435 }
436}
437
439{
440 bool bCallBase = false;
441 const SdrMarkList &rMrkList = rDrawView.GetMarkedObjectList();
442 if( rMrkList.GetMarkCount() )
443 {
444 GetIDocumentUndoRedo().StartUndo(SwUndoId::EMPTY, nullptr);
445 bool bDelMarked = true;
446
447 if( 1 == rMrkList.GetMarkCount() )
448 {
449 SdrObject *pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
450 if( auto pDrawObj = dynamic_cast<SwVirtFlyDrawObj*>( pObj) )
451 {
452 SwFlyFrameFormat* pFrameFormat = pDrawObj->GetFlyFrame()->GetFormat();
453 if( pFrameFormat )
454 {
456 bDelMarked = false;
457 }
458 }
459 }
460
461 for( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
462 {
463 SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
464 if( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) == nullptr )
465 {
466 SwDrawContact *pC = static_cast<SwDrawContact*>(GetUserCall(pObj));
467 SwDrawFrameFormat *pFrameFormat = static_cast<SwDrawFrameFormat*>(pC->GetFormat());
468 if( pFrameFormat &&
469 RndStdIds::FLY_AS_CHAR == pFrameFormat->GetAnchor().GetAnchorId() )
470 {
471 rDrawView.MarkObj( pObj, rDrawView.Imp().GetPageView(), true );
472 --i;
474 }
475 }
476 }
477
478 if( rMrkList.GetMarkCount() && bDelMarked )
479 {
480 SdrObject *pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
482 {
483 std::unique_ptr<SwUndoDrawDelete> pUndo;
484 if (GetIDocumentUndoRedo().DoesUndo())
485 pUndo.reset(new SwUndoDrawDelete( o3tl::narrowing<sal_uInt16>(rMrkList.GetMarkCount()), *this ));
486
487 // Destroy ContactObjects, save formats.
488 for( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
489 {
490 const SdrMark& rMark = *rMrkList.GetMark( i );
491 pObj = rMark.GetMarkedSdrObj();
492 SwDrawContact *pContact = static_cast<SwDrawContact*>(pObj->GetUserCall());
493 if( pContact ) // of course not for grouped objects
494 {
495 SwDrawFrameFormat *pFormat = static_cast<SwDrawFrameFormat*>(pContact->GetFormat());
496 // before delete of selection is performed, marked
497 // <SwDrawVirtObj>-objects have to be replaced by its
498 // reference objects. Thus, assert, if a
499 // <SwDrawVirt>-object is found in the mark list.
500 if ( dynamic_cast<const SwDrawVirtObj*>( pObj) != nullptr )
501 {
502 OSL_FAIL( "<SwDrawVirtObj> is still marked for delete. application will crash!" );
503 }
504 // Deletes itself!
505 pContact->Changed(*pObj, SdrUserCallType::Delete, pObj->GetLastBoundRect() );
506 pObj->SetUserCall( nullptr );
507
508 if( pUndo )
509 pUndo->AddObj( pFormat, rMark );
510 else
511 DelFrameFormat( pFormat );
512 }
513 }
514
515 if( pUndo )
516 {
517 GetIDocumentUndoRedo().AppendUndo( std::move(pUndo) );
518 }
519 }
520 bCallBase = true;
521 }
523
524 GetIDocumentUndoRedo().EndUndo(SwUndoId::EMPTY, nullptr);
525 }
526
527 return bCallBase;
528}
529
530ZSortFly::ZSortFly(const SwFrameFormat* pFrameFormat, const SwFormatAnchor* pFlyAn, sal_uInt32 nArrOrdNum)
531 : m_pFormat(pFrameFormat)
532 , m_pAnchor(pFlyAn)
533 , m_nOrdNum(nArrOrdNum)
534{
535 SAL_WARN_IF(m_pFormat->Which() != RES_FLYFRMFMT && m_pFormat->Which() != RES_DRAWFRMFMT, "sw.core", "What kind of format is this?");
536 m_pFormat->CallSwClientNotify(sw::GetZOrderHint(m_nOrdNum));
537}
538
541{
542 pOutliner->SetCalcFieldValueHdl(LINK(this, SwDoc, CalcFieldValueHdl));
543}
544
546IMPL_LINK(SwDoc, CalcFieldValueHdl, EditFieldInfo*, pInfo, void)
547{
548 if (!pInfo)
549 return;
550
551 const SvxFieldItem& rField = pInfo->GetField();
552 const SvxFieldData* pField = rField.GetField();
553
554 if (auto pDateField = dynamic_cast<const SvxDateField*>( pField))
555 {
556 // Date field
557 pInfo->SetRepresentation(
558 pDateField->GetFormatted(
559 *GetNumberFormatter(), LANGUAGE_SYSTEM) );
560 }
561 else if (auto pURLField = dynamic_cast<const SvxURLField*>( pField))
562 {
563 // URL field
564 switch ( pURLField->GetFormat() )
565 {
566 case SvxURLFormat::AppDefault:
567 case SvxURLFormat::Repr:
568 pInfo->SetRepresentation(pURLField->GetRepresentation());
569 break;
570
571 case SvxURLFormat::Url:
572 pInfo->SetRepresentation(pURLField->GetURL());
573 break;
574 }
575
576 sal_uInt16 nChrFormat;
577
578 if (IsVisitedURL(pURLField->GetURL()))
579 nChrFormat = RES_POOLCHR_INET_VISIT;
580 else
581 nChrFormat = RES_POOLCHR_INET_NORMAL;
582
583 SwFormat *pFormat = getIDocumentStylePoolAccess().GetCharFormatFromPool(nChrFormat);
584
585 Color aColor(COL_LIGHTBLUE);
586 if (pFormat)
587 aColor = pFormat->GetColor().GetValue();
588
589 pInfo->SetTextColor(aColor);
590 }
591 else if (dynamic_cast<const SdrMeasureField*>( pField))
592 {
593 // Clear measure field
594 pInfo->SetFieldColor(std::optional<Color>());
595 }
596 else if ( auto pTimeField = dynamic_cast<const SvxExtTimeField*>( pField) )
597 {
598 // Time field
599 pInfo->SetRepresentation(
600 pTimeField->GetFormatted(*GetNumberFormatter(), LANGUAGE_SYSTEM) );
601 }
602 else
603 {
604 OSL_FAIL("unknown field command");
605 pInfo->SetRepresentation( OUString( '?' ) );
606 }
607}
608
609// #i62875#
610namespace docfunc
611{
612 bool ExistsDrawObjs( SwDoc& p_rDoc )
613 {
614 bool bExistsDrawObjs( false );
615
618 {
619 const SdrPage& rSdrPage( *(p_rDoc.getIDocumentDrawModelAccess().GetDrawModel()->GetPage( 0 )) );
620
621 SdrObjListIter aIter( &rSdrPage, SdrIterMode::Flat );
622 while( aIter.IsMore() )
623 {
624 SdrObject* pObj( aIter.Next() );
625 if ( !dynamic_cast<SwVirtFlyDrawObj*>(pObj) &&
626 !dynamic_cast<SwFlyDrawObj*>(pObj) )
627 {
628 bExistsDrawObjs = true;
629 break;
630 }
631 }
632 }
633
634 return bExistsDrawObjs;
635 }
636
637 bool AllDrawObjsOnPage( SwDoc& p_rDoc )
638 {
639 bool bAllDrawObjsOnPage( true );
640
643 {
644 const SdrPage& rSdrPage( *(p_rDoc.getIDocumentDrawModelAccess().GetDrawModel()->GetPage( 0 )) );
645
646 SdrObjListIter aIter( &rSdrPage, SdrIterMode::Flat );
647 while( aIter.IsMore() )
648 {
649 SdrObject* pObj( aIter.Next() );
650 if ( !dynamic_cast<SwVirtFlyDrawObj*>(pObj) &&
651 !dynamic_cast<SwFlyDrawObj*>(pObj) )
652 {
653 SwDrawContact* pDrawContact =
654 dynamic_cast<SwDrawContact*>(::GetUserCall( pObj ));
655 if ( pDrawContact )
656 {
657 SwAnchoredDrawObject* pAnchoredDrawObj =
658 dynamic_cast<SwAnchoredDrawObject*>(pDrawContact->GetAnchoredObj( pObj ));
659
660 // error handling
661 {
662 if ( !pAnchoredDrawObj )
663 {
664 OSL_FAIL( "<docfunc::AllDrawObjsOnPage() - missing anchored draw object" );
665 bAllDrawObjsOnPage = false;
666 break;
667 }
668 }
669
670 if ( pAnchoredDrawObj->NotYetPositioned() )
671 {
672 // The drawing object isn't yet layouted.
673 // Thus, it isn't known, if all drawing objects are on page.
674 bAllDrawObjsOnPage = false;
675 break;
676 }
677 else if ( pAnchoredDrawObj->IsOutsidePage() )
678 {
679 bAllDrawObjsOnPage = false;
680 break;
681 }
682 }
683 else
684 {
685 // contact object of drawing object doesn't exists.
686 // Thus, the drawing object isn't yet positioned.
687 // Thus, it isn't known, if all drawing objects are on page.
688 bAllDrawObjsOnPage = false;
689 break;
690 }
691 }
692 }
693 }
694
695 return bAllDrawObjsOnPage;
696 }
697}
698
699/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual const SwDrawModel * GetDrawModel() const =0
Draw Model and id accessors.
virtual void DelLayoutFormat(SwFrameFormat *pFormat)=0
virtual void SetModified()=0
Must be called manually at changes of format.
void SetCalcFieldValueHdl(const Link< EditFieldInfo *, void > &rLink)
constexpr tools::Long getX() const
constexpr tools::Long getY() const
void UnGroupMarked()
void GroupMarked()
size_t GetMarkCount() const
SdrMark * GetMark(size_t nNum) const
const SdrMarkList & GetMarkedObjectList() const
bool MarkObj(const Point &rPnt, short nTol=-2, bool bToggle=false, bool bDeep=false)
SdrObject * GetMarkedSdrObj() const
const SdrPage * GetPage(sal_uInt16 nPgNum) const
SdrObject * Next()
bool IsMore() const
SdrObject * GetObj(size_t nNum) const
size_t GetObjCount() const
virtual void NbcSetAnchorPos(const Point &rPnt)
SdrObjUserCall * GetUserCall() const
const Point & GetAnchorPos() const
void SetUserCall(SdrObjUserCall *pUser)
virtual const tools::Rectangle & GetSnapRect() const
virtual const OUString & GetName() const
virtual SdrObjList * getChildrenOfSdrObject() const
virtual const tools::Rectangle & GetLastBoundRect() const
SdrObject * getParentSdrObjectFromSdrObject() const
virtual void SetName(const OUString &rStr, const bool bSetChanged=true)
virtual void NbcMove(const Size &rSiz)
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
const Color & GetValue() const
const SvxFieldData * GetField() const
class for the positioning of drawing objects
wrapper class for the positioning of Writer fly frames and drawing objects
const SwFrame * GetAnchorFrame() const
SwAttrPool * GetPool() const
Definition: swatrset.hxx:190
Base class for the following contact objects (frame + draw objects).
Definition: dcontact.hxx:67
virtual const SwAnchoredObject * GetAnchoredObj(const SdrObject *_pSdrObj) const =0
virtual void MoveObjToVisibleLayer(SdrObject *_pDrawObj)
method to move drawing object to corresponding visible layer
Definition: dcontact.cxx:210
SwFrameFormat * GetFormat()
Definition: dcontact.hxx:112
Definition: doc.hxx:197
IDocumentState const & getIDocumentState() const
Definition: doc.cxx:408
bool DeleteSelection(SwDrawView &)
Definition: docdraw.cxx:438
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:158
OUString GetUniqueShapeName() const
Definition: doclay.cxx:1410
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:419
OUString GetUniqueDrawObjectName() const
Definition: doclay.cxx:1415
SwDrawContact * GroupSelection(SdrView &)
Definition: docdraw.cxx:182
void UnGroupSelection(SdrView &)
Definition: docdraw.cxx:327
void DelFrameFormat(SwFrameFormat *pFormat, bool bBroadcast=false)
Definition: docfmt.cxx:705
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
Definition: doc.cxx:169
const SwFrameFormat * GetDfltFrameFormat() const
Definition: doc.hxx:762
SwDrawFrameFormat * MakeDrawFrameFormat(const OUString &rFormatName, SwFrameFormat *pDerivedFrom)
Definition: docfmt.cxx:769
void SetCalcFieldValueHdl(Outliner *pOutliner)
In the Outliner, set a link to the method for field display in edit objects.
Definition: docdraw.cxx:540
ContactObject for connection of formats as representatives of draw objects in SwClient and the object...
Definition: dcontact.hxx:305
void ConnectToLayout(const SwFormatAnchor *pAnch=nullptr)
Inserts SdrObject in the arrays of the layout ((SwPageFrame and SwFrame).
Definition: dcontact.cxx:1796
virtual const SwAnchoredObject * GetAnchoredObj(const SdrObject *_pSdrObj) const override
Definition: dcontact.cxx:762
virtual void Changed(const SdrObject &rObj, SdrUserCallType eType, const tools::Rectangle &rOldBoundRect) override
Virtual methods of SdrObjUserCall.
Definition: dcontact.cxx:967
virtual void SetPositionLayoutDir(const sal_Int16 _nPositionLayoutDir) override
Definition: atrfrm.cxx:3501
void PosAttrSet()
Definition: frmfmt.hxx:452
const SwViewShellImp & Imp() const
Definition: dview.hxx:102
static void ReplaceMarkedDrawVirtObjs(SdrMarkView &_rMarkView)
replace marked <SwDrawVirtObj>-objects by its reference object for delete marked objects.
Definition: dview.cxx:914
new class for re-direct methods calls at a 'virtual' drawing object to its referenced object.
Definition: dcontact.hxx:212
FlyAnchors.
Definition: fmtanchr.hxx:37
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:67
Defines the horizontal position of a fly frame.
Definition: fmtornt.hxx:73
Defines the vertical position of a fly frame.
Definition: fmtornt.hxx:37
Base class for various Writer styles.
Definition: format.hxx:47
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:82
const OUString & GetName() const
Definition: format.hxx:131
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:88
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:136
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:447
const SvxColorItem & GetColor(bool=true) const
Definition: charatr.hxx:128
Style of a layout element.
Definition: frmfmt.hxx:72
void SetOtherTextBoxFormats(const std::shared_ptr< SwTextBoxNode > &rNew)
Definition: frmfmt.hxx:119
const std::shared_ptr< SwTextBoxNode > & GetOtherTextBoxFormats() const
Definition: frmfmt.hxx:118
Base class of the Writer layout elements.
Definition: frame.hxx:315
bool IsTextFrame() const
Definition: frame.hxx:1240
Point GetFrameAnchorPos(bool bIgnoreFlysAnchoredAtThisFrame) const
returns the position for anchors based on frame direction
Definition: ssfrm.cxx:294
bool IsRightToLeft() const
Definition: frame.hxx:993
bool IsVertical() const
Definition: frame.hxx:979
Textboxes are basically textframe + shape pairs.
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:168
void AddFormatAndObj(SwDrawFrameFormat *pDrawFrameFormat, SdrObject *pDrawObject)
Definition: undraw.cxx:565
void AddObj(sal_uInt16 nPos, SwDrawFrameFormat *)
Definition: undraw.cxx:517
SdrPageView * GetPageView()
Definition: viewimp.hxx:166
sal_uInt32 m_nOrdNum
Definition: mvsave.hxx:166
ZSortFly(const SwFrameFormat *pFrameFormat, const SwFormatAnchor *pFlyAnchor, sal_uInt32 nArrOrdNum)
Definition: docdraw.cxx:530
const SwFrameFormat * m_pFormat
Definition: mvsave.hxx:164
constexpr tools::Long Top() const
constexpr tools::Long Right() const
constexpr tools::Long Left() const
constexpr ::Color COL_LIGHTBLUE(0x00, 0x00, 0xFF)
SwContact * GetUserCall(const SdrObject *pObj)
Returns the UserCall if applicable from the group object.
Definition: dcontact.cxx:172
bool HasWrap(const SdrObject *pObj)
Definition: dcontact.cxx:140
IMPL_LINK(SwDoc, CalcFieldValueHdl, EditFieldInfo *, pInfo, void)
Recognise fields/URLs in the Outliner and set how they are displayed.
Definition: docdraw.cxx:546
static void lcl_CollectTextBoxesForSubGroupObj(SwFrameFormat *pTargetFormat, std::shared_ptr< SwTextBoxNode > pTextBoxNode, SdrObject *pSourceObjs)
Definition: docdraw.cxx:306
static void lcl_AdjustPositioningAttr(SwDrawFrameFormat *_pFrameFormat, const SdrObject &_rSdrObj)
local method to determine positioning and alignment attributes for a drawing object,...
Definition: docdraw.cxx:65
constexpr TypedWhichId< SvxFrameDirectionItem > RES_FRAMEDIR(126)
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(162)
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(165)
#define LANGUAGE_SYSTEM
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
bool ExistsDrawObjs(SwDoc &p_rDoc)
method to check, if given Writer document contains at least one drawing object
Definition: docdraw.cxx:612
bool AllDrawObjsOnPage(SwDoc &p_rDoc)
method to check, if given Writer document contains only drawing objects, which are completely on its ...
Definition: docdraw.cxx:637
int i
constexpr OUStringLiteral first
@ RES_POOLCHR_INET_VISIT
Internet visited.
Definition: poolfmt.hxx:121
@ RES_POOLCHR_INET_NORMAL
Internet normal.
Definition: poolfmt.hxx:120
tools::Long SwTwips
Definition: swtypes.hxx:51