1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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 .
*/
#include <svx/svdobj.hxx>
#include <init.hxx>
#include <fesh.hxx>
#include <pagefrm.hxx>
#include <rootfrm.hxx>
#include <cntfrm.hxx>
#include <doc.hxx>
#include <frmtool.hxx>
#include <swtable.hxx>
#include <viewimp.hxx>
#include <dview.hxx>
#include <flyfrm.hxx>
#include <node.hxx>
#include <pam.hxx>
#include <sectfrm.hxx>
#include <fmtpdsc.hxx>
#include <fmtsrnd.hxx>
#include <fmtcntnt.hxx>
#include <fmtfsize.hxx>
#include <tabfrm.hxx>
#include <cellfrm.hxx>
#include <flyfrms.hxx>
#include <txtfrm.hxx>
#include <mdiexp.hxx>
#include <edimp.hxx>
#include <pagedesc.hxx>
#include <fmtanchr.hxx>
#include <environmentofanchoredobject.hxx>
#include <ndtxt.hxx>
#include <dflyobj.hxx>
#include <dcontact.hxx>
#include <UndoInsert.hxx>
using namespace com::sun::star;
void SwFEShell::EndAllActionAndCall()
{
for(SwViewShell& rCurrentShell : GetRingContainer())
{
if( dynamic_cast<const SwCursorShell*>( &rCurrentShell) != nullptr )
{
static_cast<SwFEShell*>(&rCurrentShell)->EndAction();
static_cast<SwFEShell*>(&rCurrentShell)->CallChgLnk();
}
else
rCurrentShell.EndAction();
}
}
// Determine the Content's nearest to the point
Point SwFEShell::GetContentPos( const Point& rPoint, bool bNext ) const
{
SET_CURR_SHELL( const_cast<SwViewShell*>(static_cast<SwViewShell const *>(this)) );
return GetLayout()->GetNextPrevContentPos( rPoint, bNext );
}
const SwRect& SwFEShell::GetAnyCurRect( CurRectType eType, const Point* pPt,
const uno::Reference < embed::XEmbeddedObject >& xObj ) const
{
const SwFrame *pFrame = Imp()->HasDrawView()
? ::GetFlyFromMarked( &Imp()->GetDrawView()->GetMarkedObjectList(),
const_cast<SwViewShell*>(static_cast<SwViewShell const *>(this)))
: nullptr;
if( !pFrame )
{
if( pPt )
{
SwPosition aPos( *GetCursor()->GetPoint() );
Point aPt( *pPt );
GetLayout()->GetCursorOfst( &aPos, aPt );
SwContentNode *pNd = aPos.nNode.GetNode().GetContentNode();
pFrame = pNd->getLayoutFrame( GetLayout(), pPt );
}
else
{
const bool bOldCallbackActionEnabled = GetLayout()->IsCallbackActionEnabled();
if( bOldCallbackActionEnabled )
GetLayout()->SetCallbackActionEnabled( false );
pFrame = GetCurrFrame();
if( bOldCallbackActionEnabled )
GetLayout()->SetCallbackActionEnabled( true );
}
}
if( !pFrame )
return GetLayout()->Frame();
bool bFrame = true;
switch ( eType )
{
case RECT_PAGE_PRT: bFrame = false;
SAL_FALLTHROUGH;
case RECT_PAGE : pFrame = pFrame->FindPageFrame();
break;
case RECT_PAGE_CALC: pFrame->Calc(Imp()->GetShell()->GetOut());
pFrame = pFrame->FindPageFrame();
pFrame->Calc(Imp()->GetShell()->GetOut());
break;
case RECT_FLY_PRT_EMBEDDED: bFrame = false;
SAL_FALLTHROUGH;
case RECT_FLY_EMBEDDED:
{
const SwFrame *pFlyFrame = xObj.is() ? FindFlyFrame(xObj) : nullptr;
pFrame = pFlyFrame ? pFlyFrame
: pFrame->IsFlyFrame()
? pFrame
: pFrame->FindFlyFrame();
break;
}
case RECT_OUTTABSECTION_PRT:
case RECT_OUTTABSECTION : if( pFrame->IsInTab() )
pFrame = pFrame->FindTabFrame();
else {
OSL_FAIL( "Missing Table" );
}
SAL_FALLTHROUGH;
case RECT_SECTION_PRT:
case RECT_SECTION: if( pFrame->IsInSct() )
pFrame = pFrame->FindSctFrame();
else {
OSL_FAIL( "Missing section" );
}
if( RECT_OUTTABSECTION_PRT == eType ||
RECT_SECTION_PRT == eType )
bFrame = false;
break;
case RECT_HEADERFOOTER_PRT: bFrame = false;
SAL_FALLTHROUGH;
case RECT_HEADERFOOTER: if( nullptr == (pFrame = pFrame->FindFooterOrHeader()) )
return GetLayout()->Frame();
break;
case RECT_PAGES_AREA: return GetLayout()->GetPagesArea();
default: break;
}
return bFrame ? pFrame->Frame() : pFrame->Prt();
}
sal_uInt16 SwFEShell::GetPageNumber( const Point &rPoint ) const
{
const SwFrame *pPage = GetLayout()->Lower();
while ( pPage && !pPage->Frame().IsInside( rPoint ) )
pPage = pPage->GetNext();
if ( pPage )
return static_cast<const SwPageFrame*>(pPage)->GetPhyPageNum();
else
return 0;
}
bool SwFEShell::GetPageNumber( long nYPos, bool bAtCursorPos, sal_uInt16& rPhyNum, sal_uInt16& rVirtNum, OUString &rDisplay) const
{
const SwFrame *pPage;
if ( bAtCursorPos ) // get page of Cursor
{
pPage = GetCurrFrame( false );
if ( pPage )
pPage = pPage->FindPageFrame();
}
else if ( nYPos > -1 ) // determine page via the position
{
pPage = GetLayout()->Lower();
while( pPage && (pPage->Frame().Bottom() < nYPos ||
nYPos < pPage->Frame().Top() ) )
pPage = pPage->GetNext();
}
else // first visible page
{
pPage = Imp()->GetFirstVisPage(GetOut());
if ( pPage && static_cast<const SwPageFrame*>(pPage)->IsEmptyPage() )
pPage = pPage->GetNext();
}
if( pPage )
{
rPhyNum = static_cast<const SwPageFrame*>(pPage)->GetPhyPageNum();
rVirtNum = static_cast<const SwPageFrame*>(pPage)->GetVirtPageNum();
const SvxNumberType& rNum = static_cast<const SwPageFrame*>(pPage)->GetPageDesc()->GetNumType();
rDisplay = rNum.GetNumStr( rVirtNum );
}
return nullptr != pPage;
}
bool SwFEShell::IsDirectlyInSection() const
{
SwFrame* pFrame = GetCurrFrame( false );
return pFrame && pFrame->GetUpper() && pFrame->GetUpper()->IsSctFrame();
}
FrameTypeFlags SwFEShell::GetFrameType( const Point *pPt, bool bStopAtFly ) const
{
FrameTypeFlags nReturn = FrameTypeFlags::NONE;
const SwFrame *pFrame;
if ( pPt )
{
SwPosition aPos( *GetCursor()->GetPoint() );
Point aPt( *pPt );
GetLayout()->GetCursorOfst( &aPos, aPt );
SwContentNode *pNd = aPos.nNode.GetNode().GetContentNode();
pFrame = pNd->getLayoutFrame( GetLayout(), pPt );
}
else
pFrame = GetCurrFrame( false );
while ( pFrame )
{
switch ( pFrame->GetType() )
{
case SwFrameType::Column: if( pFrame->GetUpper()->IsSctFrame() )
{
// Check, if isn't not only a single column
// from a section with footnotes at the end.
if( pFrame->GetNext() || pFrame->GetPrev() )
// Sectioncolumns
nReturn |= ( nReturn & FrameTypeFlags::TABLE ) ?
FrameTypeFlags::COLSECTOUTTAB : FrameTypeFlags::COLSECT;
}
else // only pages and frame columns
nReturn |= FrameTypeFlags::COLUMN;
break;
case SwFrameType::Page: nReturn |= FrameTypeFlags::PAGE;
if( static_cast<const SwPageFrame*>(pFrame)->IsFootnotePage() )
nReturn |= FrameTypeFlags::FTNPAGE;
break;
case SwFrameType::Header: nReturn |= FrameTypeFlags::HEADER; break;
case SwFrameType::Footer: nReturn |= FrameTypeFlags::FOOTER; break;
case SwFrameType::Body: if( pFrame->GetUpper()->IsPageFrame() ) // not for ColumnFrames
nReturn |= FrameTypeFlags::BODY;
break;
case SwFrameType::Ftn: nReturn |= FrameTypeFlags::FOOTNOTE; break;
case SwFrameType::Fly: if( static_cast<const SwFlyFrame*>(pFrame)->IsFlyLayFrame() )
nReturn |= FrameTypeFlags::FLY_FREE;
else if ( static_cast<const SwFlyFrame*>(pFrame)->IsFlyAtContentFrame() )
nReturn |= FrameTypeFlags::FLY_ATCNT;
else
{
OSL_ENSURE( static_cast<const SwFlyFrame*>(pFrame)->IsFlyInContentFrame(),
"New frametype?" );
nReturn |= FrameTypeFlags::FLY_INCNT;
}
nReturn |= FrameTypeFlags::FLY_ANY;
if( bStopAtFly )
return nReturn;
break;
case SwFrameType::Tab:
case SwFrameType::Row:
case SwFrameType::Cell: nReturn |= FrameTypeFlags::TABLE; break;
default: /* do nothing */ break;
}
if ( pFrame->IsFlyFrame() )
pFrame = static_cast<const SwFlyFrame*>(pFrame)->GetAnchorFrame();
else
pFrame = pFrame->GetUpper();
}
return nReturn;
}
void SwFEShell::ShellGetFocus()
{
::SetShell( this );
SwCursorShell::ShellGetFocus();
if ( HasDrawView() )
{
Imp()->GetDrawView()->showMarkHandles();
if ( Imp()->GetDrawView()->AreObjectsMarked() )
FrameNotify( this, FLY_DRAG_START );
}
}
void SwFEShell::ShellLoseFocus()
{
SwCursorShell::ShellLoseFocus();
if ( HasDrawView() && Imp()->GetDrawView()->AreObjectsMarked() )
{
Imp()->GetDrawView()->hideMarkHandles();
FrameNotify( this, FLY_DRAG_END );
}
}
sal_uInt16 SwFEShell::GetPhyPageNum()
{
SwFrame *pFrame = GetCurrFrame();
if ( pFrame )
return pFrame->GetPhyPageNum();
return 0;
}
sal_uInt16 SwFEShell::GetVirtPageNum()
{
SwFrame *pFrame = GetCurrFrame();
if ( pFrame )
return pFrame->GetVirtPageNum();
return 0;
}
static void lcl_SetAPageOffset( sal_uInt16 nOffset, SwPageFrame* pPage, SwFEShell* pThis )
{
pThis->StartAllAction();
OSL_ENSURE( pPage->FindFirstBodyContent(),
"SwFEShell _SetAPageOffset() without ContentFrame" );
SwFormatPageDesc aDesc( pPage->GetPageDesc() );
aDesc.SetNumOffset( nOffset );
SwFrame *pFrame = pThis->GetCurrFrame( false );
if ( pFrame->IsInTab() )
pThis->GetDoc()->SetAttr( aDesc, *pFrame->FindTabFrame()->GetFormat() );
else
{
pThis->GetDoc()->getIDocumentContentOperations().InsertPoolItem( *pThis->GetCursor(), aDesc );
}
pThis->EndAllAction();
}
void SwFEShell::SetNewPageOffset( sal_uInt16 nOffset )
{
GetLayout()->SetVirtPageNum( true );
const SwPageFrame *pPage = GetCurrFrame( false )->FindPageFrame();
lcl_SetAPageOffset( nOffset, const_cast<SwPageFrame*>(pPage), this );
}
void SwFEShell::SetPageOffset( sal_uInt16 nOffset )
{
const SwPageFrame *pPage = GetCurrFrame( false )->FindPageFrame();
const SwRootFrame* pDocLayout = GetLayout();
while ( pPage )
{
const SwFrame *pFlow = pPage->FindFirstBodyContent();
if ( pFlow )
{
if ( pFlow->IsInTab() )
pFlow = pFlow->FindTabFrame();
const SwFormatPageDesc& rPgDesc = pFlow->GetAttrSet()->GetPageDesc();
if ( rPgDesc.GetNumOffset() )
{
pDocLayout->SetVirtPageNum( true );
lcl_SetAPageOffset( nOffset, const_cast<SwPageFrame*>(pPage), this );
break;
}
}
pPage = static_cast<const SwPageFrame*>(pPage->GetPrev());
}
}
sal_uInt16 SwFEShell::GetPageOffset() const
{
const SwPageFrame *pPage = GetCurrFrame()->FindPageFrame();
while ( pPage )
{
const SwFrame *pFlow = pPage->FindFirstBodyContent();
if ( pFlow )
{
if ( pFlow->IsInTab() )
pFlow = pFlow->FindTabFrame();
::boost::optional<sal_uInt16> oNumOffset = pFlow->GetAttrSet()->GetPageDesc().GetNumOffset();
if ( oNumOffset )
return oNumOffset.get();
}
pPage = static_cast<const SwPageFrame*>(pPage->GetPrev());
}
return 0;
}
void SwFEShell::InsertLabel( const SwLabelType eType, const OUString &rText, const OUString& rSeparator,
const OUString& rNumberSeparator,
const bool bBefore, const sal_uInt16 nId,
const OUString& rCharacterStyle,
const bool bCpyBrd )
{
// get node index of cursor position, SwDoc can do everything else itself
SwContentFrame *pCnt = LTYPE_DRAW==eType ? nullptr : GetCurrFrame( false );
if( LTYPE_DRAW==eType || pCnt )
{
StartAllAction();
SwRewriter aRewriter(SwUndoInsertLabel::CreateRewriter(rText));
StartUndo(UNDO_INSERTLABEL, &aRewriter);
sal_uLong nIdx = 0;
bool bInnerCntIsFly = false;
SwFlyFrameFormat* pFlyFormat = nullptr;
switch( eType )
{
case LTYPE_OBJECT:
case LTYPE_FLY:
bInnerCntIsFly = pCnt->IsInFly();
if (bInnerCntIsFly)
{
// pass down index to the startnode for flys
nIdx = pCnt->FindFlyFrame()->
GetFormat()->GetContent().GetContentIdx()->GetIndex();
}
break;
case LTYPE_TABLE:
if( pCnt->IsInTab() )
{
// pass down index to the TableNode for tables
const SwTable& rTable = *pCnt->FindTabFrame()->GetTable();
nIdx = rTable.GetTabSortBoxes()[ 0 ]
->GetSttNd()->FindTableNode()->GetIndex();
}
break;
case LTYPE_DRAW:
if( Imp()->GetDrawView() )
{
SwDrawView *pDView = Imp()->GetDrawView();
const SdrMarkList& rMrkList = pDView->GetMarkedObjectList();
// copy marked drawing objects to
// local list to perform the corresponding action for each object
std::vector<SdrObject*> aDrawObjs;
{
for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
{
SdrObject* pDrawObj = rMrkList.GetMark(i)->GetMarkedSdrObj();
if( pDrawObj )
aDrawObjs.push_back( pDrawObj );
}
}
// loop on marked drawing objects
while ( !aDrawObjs.empty() )
{
SdrObject* pDrawObj = aDrawObjs.back();
if ( dynamic_cast<const SwVirtFlyDrawObj*>( pDrawObj) == nullptr &&
dynamic_cast<const SwFlyDrawObj*>( pDrawObj) == nullptr )
{
SwFlyFrameFormat *pFormat =
GetDoc()->InsertDrawLabel( rText, rSeparator, rNumberSeparator, nId, rCharacterStyle, *pDrawObj );
if( !pFlyFormat )
pFlyFormat = pFormat;
}
aDrawObjs.pop_back();
}
}
break;
default:
OSL_ENSURE( false, "Cursor neither in table nor in fly." );
}
if( nIdx )
{
pFlyFormat = GetDoc()->InsertLabel(eType, rText, rSeparator,
rNumberSeparator, bBefore, nId,
nIdx, rCharacterStyle, bCpyBrd);
//if we succeeded in putting a caption on the content, and the
//content was a frame/graphic, then set the contained element
//to as-char anchoring because that's all msword is able to
//do when inside a frame, and in writer for freshly captioned
//elements it's largely irrelevant what the anchor of the contained
//type is but making it as-char by default results in very
//good roundtripping
if (pFlyFormat && bInnerCntIsFly)
{
SwNodeIndex aAnchIdx(*pFlyFormat->GetContent().GetContentIdx(), 1);
SwTextNode *pTextNode = aAnchIdx.GetNode().GetTextNode();
SwFormatAnchor aAnc(FLY_AS_CHAR);
sal_Int32 nInsertPos = bBefore ? pTextNode->Len() : 0;
SwPosition aPos(*pTextNode, nInsertPos);
aAnc.SetAnchor(&aPos);
SfxItemSet aSet(makeItemSetFromFormatAnchor(GetDoc()->GetAttrPool(), aAnc));
SwFlyFrame *pFly = GetSelectedOrCurrFlyFrame();
SwFlyFrameFormat* pInnerFlyFormat = pFly->GetFormat();
GetDoc()->SetFlyFrameAttr(*pInnerFlyFormat, aSet);
//put a hard-break after the graphic to keep it separated
//from the caption text if the outer frame is resized
SwIndex aIdx(pTextNode, bBefore ? nInsertPos : 1);
pTextNode->InsertText("\n", aIdx);
}
}
if (pFlyFormat)
{
const Point aPt(GetCursorDocPos());
if (SwFlyFrame* pFrame = pFlyFormat->GetFrame(&aPt))
SelectFlyFrame(*pFrame);
}
EndUndo();
EndAllActionAndCall();
}
}
bool SwFEShell::Sort(const SwSortOptions& rOpt)
{
if( !HasSelection() )
return false;
SET_CURR_SHELL( this );
bool bRet = false;
StartAllAction();
if(IsTableMode())
{
// Sort table
// check if Point/Mark of current Cursor are in one table
SwFrame *pFrame = GetCurrFrame( false );
OSL_ENSURE( pFrame->FindTabFrame(), "Cursor not in table." );
// search boxes via the layout
SwSelBoxes aBoxes;
GetTableSel(*this, aBoxes);
// The Cursor should be removed from the deletion area.
// Always put them behind/on the table; via the
// document position they will always be set to the old position
while( !pFrame->IsCellFrame() )
pFrame = pFrame->GetUpper();
{
/* ParkCursor->ParkCursorTab */
ParkCursorInTab();
}
// call sorting on document
bRet = mpDoc->SortTable(aBoxes, rOpt);
}
else
{
// Sort text nothing else
for(SwPaM& rPaM : GetCursor()->GetRingContainer())
{
SwPaM* pPam = &rPaM;
SwPosition* pStart = pPam->Start();
SwPosition* pEnd = pPam->End();
SwNodeIndex aPrevIdx( pStart->nNode, -1 );
sal_uLong nOffset = pEnd->nNode.GetIndex() - pStart->nNode.GetIndex();
const sal_Int32 nCntStt = pStart->nContent.GetIndex();
// Sorting
bRet = mpDoc->SortText(*pPam, rOpt);
// put selection again
pPam->DeleteMark();
pPam->GetPoint()->nNode.Assign( aPrevIdx.GetNode(), +1 );
SwContentNode* pCNd = pPam->GetContentNode();
sal_Int32 nLen = pCNd->Len();
if( nLen > nCntStt )
nLen = nCntStt;
pPam->GetPoint()->nContent.Assign(pCNd, nLen );
pPam->SetMark();
pPam->GetPoint()->nNode += nOffset;
pCNd = pPam->GetContentNode();
pPam->GetPoint()->nContent.Assign( pCNd, pCNd->Len() );
}
}
EndAllAction();
return bRet;
}
bool SwFEShell::IsColRightToLeft() const
{
SwFrame* pFrame = GetCurrFrame();
while (pFrame)
{
pFrame = pFrame->GetUpper();
if (pFrame && pFrame->IsColumnFrame())
{
return pFrame->IsRightToLeft();
}
}
return false;
}
sal_uInt16 SwFEShell::GetCurColNum_( const SwFrame *pFrame,
SwGetCurColNumPara* pPara ) const
{
sal_uInt16 nRet = 0;
while ( pFrame )
{
pFrame = pFrame->GetUpper();
if( pFrame && pFrame->IsColumnFrame() )
{
const SwFrame *pCurFrame = pFrame;
do {
++nRet;
pFrame = pFrame->GetPrev();
} while ( pFrame );
if( pPara )
{
// now search the format, determining the columness
pFrame = pCurFrame->GetUpper();
while( pFrame )
{
if( ( SwFrameType::Page | SwFrameType::Fly | SwFrameType::Section ) & pFrame->GetType() )
{
pPara->pFrameFormat = static_cast<const SwLayoutFrame*>(pFrame)->GetFormat();
pPara->pPrtRect = &pFrame->Prt();
pPara->pFrameRect = &pFrame->Frame();
break;
}
pFrame = pFrame->GetUpper();
}
if( !pFrame )
{
pPara->pFrameFormat = nullptr;
pPara->pPrtRect = nullptr;
pPara->pFrameRect = nullptr;
}
}
break;
}
}
return nRet;
}
sal_uInt16 SwFEShell::GetCurColNum( SwGetCurColNumPara* pPara ) const
{
OSL_ENSURE( GetCurrFrame(), "Cursor parked?" );
return GetCurColNum_( GetCurrFrame(), pPara );
}
sal_uInt16 SwFEShell::GetCurOutColNum() const
{
sal_uInt16 nRet = 0;
SwFrame* pFrame = GetCurrFrame();
OSL_ENSURE( pFrame, "Cursor parked?" );
if( pFrame )
{
pFrame = pFrame->IsInTab() ? static_cast<SwFrame*>(pFrame->FindTabFrame())
: static_cast<SwFrame*>(pFrame->FindSctFrame());
OSL_ENSURE( pFrame, "No Tab, no Sect" );
if( pFrame )
nRet = GetCurColNum_( pFrame, nullptr );
}
return nRet;
}
SwFEShell::SwFEShell( SwDoc& rDoc, vcl::Window *pWindow, const SwViewOption *pOptions )
: SwEditShell( rDoc, pWindow, pOptions )
, m_bCheckForOLEInCaption(false)
{
}
SwFEShell::SwFEShell( SwEditShell& rShell, vcl::Window *pWindow )
: SwEditShell( rShell, pWindow )
, m_bCheckForOLEInCaption(false)
{
}
SwFEShell::~SwFEShell()
{
}
// #i17567# - adjustments for allowing
// negative vertical positions for fly frames anchored to paragraph/to character.
// #i22305# - adjustments for option 'Follow text flow'
// for to frame anchored objects.
// #i22341# - adjustments for vertical alignment at top of line
// for to character anchored objects.
void SwFEShell::CalcBoundRect( SwRect& _orRect,
const RndStdIds _nAnchorId,
const sal_Int16 _eHoriRelOrient,
const sal_Int16 _eVertRelOrient,
const SwPosition* _pToCharContentPos,
const bool _bFollowTextFlow,
bool _bMirror,
Point* _opRef,
Size* _opPercent,
const SwFormatFrameSize* pFormatFrameSize) const
{
const SwFrame* pFrame;
const SwFlyFrame* pFly;
if( _opRef )
{
pFrame = GetCurrFrame();
if( nullptr != ( pFly = pFrame->FindFlyFrame() ) )
pFrame = pFly->GetAnchorFrame();
}
else
{
pFly = GetSelectedFlyFrame();
pFrame = pFly ? pFly->GetAnchorFrame() : GetCurrFrame();
}
bool bWrapThrough = false;
if ( pFly )
{
SwFlyFrameFormat* pFormat = const_cast<SwFlyFrameFormat*>(pFly->GetFormat());
const SwFormatSurround& rSurround = pFormat->GetSurround();
bWrapThrough = rSurround.GetSurround() == SURROUND_THROUGHT;
}
const SwPageFrame* pPage = pFrame->FindPageFrame();
_bMirror = _bMirror && !pPage->OnRightPage();
Point aPos;
bool bVertic = false;
bool bRTL = false;
bool bVerticalL2R = false;
if ((FLY_AT_PAGE == _nAnchorId) || (FLY_AT_FLY == _nAnchorId)) // LAYER_IMPL
{
const SwFrame* pTmp = pFrame;
// #i22305#
if ((FLY_AT_PAGE == _nAnchorId) ||
((FLY_AT_FLY == _nAnchorId) && !_bFollowTextFlow))
{
pFrame = pPage;
}
else
{
pFrame = pFrame->FindFlyFrame();
}
if ( !pFrame )
pFrame = pTmp;
_orRect = pFrame->Frame();
SWRECTFN( pFrame )
bRTL = pFrame->IsRightToLeft();
if ( bRTL )
aPos = pFrame->Frame().TopRight();
else
aPos = (pFrame->Frame().*fnRect->fnGetPos)();
if( bVert || bVertL2R )
{
bVertic = bVert;
bVerticalL2R = bVertL2R;
_bMirror = false; // no mirroring in vertical environment
switch ( _eHoriRelOrient )
{
case text::RelOrientation::PAGE_RIGHT:
case text::RelOrientation::FRAME_RIGHT: aPos.Y() += pFrame->Prt().Height();
SAL_FALLTHROUGH;
case text::RelOrientation::PRINT_AREA:
case text::RelOrientation::PAGE_PRINT_AREA: aPos.Y() += pFrame->Prt().Top(); break;
default: break;
}
}
else if ( _bMirror )
{
switch ( _eHoriRelOrient )
{
case text::RelOrientation::PRINT_AREA:
case text::RelOrientation::PAGE_PRINT_AREA: aPos.X() += pFrame->Prt().Width();
SAL_FALLTHROUGH;
case text::RelOrientation::PAGE_RIGHT:
case text::RelOrientation::FRAME_RIGHT: aPos.X() += pFrame->Prt().Left(); break;
default: aPos.X() += pFrame->Frame().Width();
}
}
else if ( bRTL )
{
switch ( _eHoriRelOrient )
{
case text::RelOrientation::PRINT_AREA:
case text::RelOrientation::PAGE_PRINT_AREA: aPos.X() += pFrame->Prt().Width();
SAL_FALLTHROUGH;
case text::RelOrientation::PAGE_LEFT:
case text::RelOrientation::FRAME_LEFT: aPos.X() += pFrame->Prt().Left() -
pFrame->Frame().Width(); break;
default: break;
}
}
else
{
switch ( _eHoriRelOrient )
{
case text::RelOrientation::PAGE_RIGHT:
case text::RelOrientation::FRAME_RIGHT: aPos.X() += pFrame->Prt().Width();
SAL_FALLTHROUGH;
case text::RelOrientation::PRINT_AREA:
case text::RelOrientation::PAGE_PRINT_AREA: aPos.X() += pFrame->Prt().Left(); break;
default:break;
}
}
if ( bVert && !bVertL2R )
{
switch ( _eVertRelOrient )
{
case text::RelOrientation::PRINT_AREA:
case text::RelOrientation::PAGE_PRINT_AREA:
{
aPos.X() -= pFrame->GetRightMargin();
}
break;
}
}
else if ( bVertL2R )
{
switch ( _eVertRelOrient )
{
case text::RelOrientation::PRINT_AREA:
case text::RelOrientation::PAGE_PRINT_AREA:
{
aPos.X() += pFrame->GetLeftMargin();
}
break;
}
}
else
{
switch ( _eVertRelOrient )
{
case text::RelOrientation::PRINT_AREA:
case text::RelOrientation::PAGE_PRINT_AREA:
{
if ( pFrame->IsPageFrame() )
{
aPos.Y() =
static_cast<const SwPageFrame*>(pFrame)->PrtWithoutHeaderAndFooter().Top();
}
else
{
aPos.Y() += pFrame->Prt().Top();
}
}
break;
}
}
if ( _opPercent )
*_opPercent = pFrame->Prt().SSize();
}
else
{
const SwFrame* pUpper = ( pFrame->IsPageFrame() || pFrame->IsFlyFrame() ) ?
pFrame : pFrame->GetUpper();
SWRECTFN( pUpper );
if ( _opPercent )
{
// If the size is relative from page, then full size should be counted from the page frame.
if (pFormatFrameSize && pFormatFrameSize->GetWidthPercentRelation() == text::RelOrientation::PAGE_FRAME)
_opPercent->setWidth(pPage->Frame().Width());
else
_opPercent->setWidth(pUpper->Prt().Width());
if (pFormatFrameSize && pFormatFrameSize->GetHeightPercentRelation() == text::RelOrientation::PAGE_FRAME)
// If the size is relative from page, then full size should be counted from the page frame.
_opPercent->setHeight(pPage->Frame().Height());
else
_opPercent->setHeight(pUpper->Prt().Height());
}
bRTL = pFrame->IsRightToLeft();
if ( bRTL )
aPos = pFrame->Frame().TopRight();
else
aPos = (pFrame->Frame().*fnRect->fnGetPos)();
// #i17567# - allow negative positions
// for fly frames anchor to paragraph/to character.
if ((_nAnchorId == FLY_AT_PARA) || (_nAnchorId == FLY_AT_CHAR))
{
// The rectangle, the fly frame can be positioned in, is determined
// horizontally by the frame area of the horizontal environment
// and vertically by the printing area of the vertical environment,
// if the object follows the text flow, or by the frame area of the
// vertical environment, if the object doesn't follow the text flow.
// new class <SwEnvironmentOfAnchoredObject>
objectpositioning::SwEnvironmentOfAnchoredObject aEnvOfObj(
_bFollowTextFlow );
const SwLayoutFrame& rHoriEnvironLayFrame =
aEnvOfObj.GetHoriEnvironmentLayoutFrame( *pFrame );
const SwLayoutFrame& rVertEnvironLayFrame =
aEnvOfObj.GetVertEnvironmentLayoutFrame( *pFrame );
const SwRect& aHoriEnvironRect( rHoriEnvironLayFrame.Frame() );
SwRect aVertEnvironRect;
if ( _bFollowTextFlow )
{
aVertEnvironRect = rVertEnvironLayFrame.Prt();
aVertEnvironRect.Pos() += rVertEnvironLayFrame.Frame().Pos();
// #i18732# - adjust vertical 'virtual' anchor position
// (<aPos.Y()> respectively <aPos.X()>), if object is vertical aligned
// to page areas.
if ( _eVertRelOrient == text::RelOrientation::PAGE_FRAME || _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
{
if ( bVert && !bVertL2R )
{
aPos.X() = aVertEnvironRect.Right();
}
else if ( bVertL2R )
{
aPos.X() = aVertEnvironRect.Left();
}
else
{
aPos.Y() = aVertEnvironRect.Top();
}
}
}
else
{
OSL_ENSURE( rVertEnvironLayFrame.IsPageFrame(),
"<SwFEShell::CalcBoundRect(..)> - not following text flow, but vertical environment *not* page!" );
aVertEnvironRect = rVertEnvironLayFrame.Frame();
// #i18732# - adjustment vertical 'virtual' anchor position
// (<aPos.Y()> respectively <aPos.X()>), if object is vertical aligned
// to page areas.
if ( _eVertRelOrient == text::RelOrientation::PAGE_FRAME || _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
{
if ( bVert && !bVertL2R )
{
aPos.X() = aVertEnvironRect.Right();
if ( _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
{
aPos.setX(aPos.getX() - rVertEnvironLayFrame.GetRightMargin());
}
}
else if ( bVertL2R )
{
aPos.X() = aVertEnvironRect.Left();
if ( _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
{
aPos.setX(aPos.getX() + rVertEnvironLayFrame.GetLeftMargin());
}
}
else
{
aPos.Y() = aVertEnvironRect.Top();
if ( _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
{
aPos.setY(aPos.getY() + rVertEnvironLayFrame.GetTopMargin());
// add height of page header
const SwFrame* pTmpFrame = rVertEnvironLayFrame.Lower();
if ( pTmpFrame->IsHeaderFrame() )
{
aPos.setY(aPos.getY() + pTmpFrame->Frame().Height());
}
}
}
}
}
// #i22341# - adjust vertical 'virtual' anchor position
// (<aPos.Y()> respectively <aPos.X()>), if object is anchored to
// character and vertical aligned at character or top of line
// <pFrame>, which is the anchor frame or the proposed anchor frame,
// doesn't have to be a text frame (e.g. edit a to-page anchored
// fly frame). Thus, assure this.
const SwTextFrame* pTextFrame( dynamic_cast<const SwTextFrame*>(pFrame) );
if ( pTextFrame &&
(_nAnchorId == FLY_AT_CHAR) &&
( _eVertRelOrient == text::RelOrientation::CHAR ||
_eVertRelOrient == text::RelOrientation::TEXT_LINE ) )
{
SwTwips nTop = 0L;
if ( _eVertRelOrient == text::RelOrientation::CHAR )
{
SwRect aChRect;
if ( _pToCharContentPos )
{
pTextFrame->GetAutoPos( aChRect, *_pToCharContentPos );
}
else
{
// No content position provided. Thus, use a default one.
SwPosition aDefaultContentPos( *(pTextFrame->GetTextNode()) );
pTextFrame->GetAutoPos( aChRect, aDefaultContentPos );
}
nTop = (aChRect.*fnRect->fnGetBottom)();
}
else
{
if ( _pToCharContentPos )
{
pTextFrame->GetTopOfLine( nTop, *_pToCharContentPos );
}
else
{
// No content position provided. Thus, use a default one.
SwPosition aDefaultContentPos( *(pTextFrame->GetTextNode()) );
pTextFrame->GetTopOfLine( nTop, aDefaultContentPos );
}
}
if ( bVert || bVertL2R )
{
aPos.setX(nTop);
}
else
{
aPos.setY(nTop);
}
}
// #i26945# - adjust horizontal 'virtual' anchor
// position (<aPos.X()> respectively <aPos.Y()>), if object is
// anchored to character and horizontal aligned at character.
if ( pTextFrame &&
(_nAnchorId == FLY_AT_CHAR) &&
_eHoriRelOrient == text::RelOrientation::CHAR )
{
SwTwips nLeft = 0L;
SwRect aChRect;
if ( _pToCharContentPos )
{
pTextFrame->GetAutoPos( aChRect, *_pToCharContentPos );
}
else
{
// No content position provided. Thus, use a default one.
SwPosition aDefaultContentPos( *(pTextFrame->GetTextNode()) );
pTextFrame->GetAutoPos( aChRect, aDefaultContentPos );
}
nLeft = (aChRect.*fnRect->fnGetLeft)();
if ( bVert || bVertL2R )
{
aPos.setY(nLeft);
}
else
{
aPos.setX(nLeft);
}
}
if ( bVert || bVertL2R )
{
_orRect = SwRect( aVertEnvironRect.Left(),
aHoriEnvironRect.Top(),
aVertEnvironRect.Width(),
aHoriEnvironRect.Height() );
}
else
{
_orRect = SwRect( aHoriEnvironRect.Left(),
aVertEnvironRect.Top(),
aHoriEnvironRect.Width(),
aVertEnvironRect.Height() );
}
}
else
{
if( _opRef && pFly && pFly->IsFlyInContentFrame() )
*_opRef = static_cast<const SwFlyInContentFrame*>( pFly )->GetRefPoint();
_orRect = pUpper->Frame();
if( !pUpper->IsBodyFrame() )
{
_orRect += pUpper->Prt().Pos();
_orRect.SSize( pUpper->Prt().SSize() );
if ( pUpper->IsCellFrame() )//MA_FLY_HEIGHT
{
const SwFrame* pTab = pUpper->FindTabFrame();
long nBottom = (pTab->GetUpper()->*fnRect->fnGetPrtBottom)();
(_orRect.*fnRect->fnSetBottom)( nBottom );
}
}
// only use 90% of height for character bound
{
if( bVert || bVertL2R )
_orRect.Width( (_orRect.Width()*9)/10 );
else
_orRect.Height( (_orRect.Height()*9)/10 );
}
}
const SwTwips nBaseOfstForFly = ( pFrame->IsTextFrame() && pFly ) ?
static_cast<const SwTextFrame*>(pFrame)->GetBaseOfstForFly( !bWrapThrough ) :
0;
if( bVert || bVertL2R )
{
bVertic = bVert;
bVerticalL2R = bVertL2R;
_bMirror = false;
switch ( _eHoriRelOrient )
{
case text::RelOrientation::FRAME_RIGHT:
{
aPos.setY(aPos.getY() + pFrame->Prt().Height());
aPos += (pFrame->Prt().*fnRect->fnGetPos)();
break;
}
case text::RelOrientation::PRINT_AREA:
{
aPos += (pFrame->Prt().*fnRect->fnGetPos)();
aPos.setY(aPos.getY() + nBaseOfstForFly);
break;
}
case text::RelOrientation::PAGE_RIGHT:
{
aPos.setY(pPage->Frame().Top() + pPage->Prt().Bottom());
break;
}
case text::RelOrientation::PAGE_PRINT_AREA:
{
aPos.setY(pPage->Frame().Top() + pPage->Prt().Top());
break;
}
case text::RelOrientation::PAGE_LEFT:
case text::RelOrientation::PAGE_FRAME:
{
aPos.setY(pPage->Frame().Top());
break;
}
case text::RelOrientation::FRAME:
{
aPos.setY(aPos.getY() + nBaseOfstForFly);
break;
}
default: break;
}
}
else if( _bMirror )
{
switch ( _eHoriRelOrient )
{
case text::RelOrientation::FRAME_RIGHT: aPos.setX(aPos.getX() + pFrame->Prt().Left()); break;
case text::RelOrientation::FRAME:
case text::RelOrientation::FRAME_LEFT: aPos.setX(aPos.getX() + pFrame->Frame().Width()); break;
case text::RelOrientation::PRINT_AREA: aPos.setX(aPos.getX() + pFrame->Prt().Right()); break;
case text::RelOrientation::PAGE_LEFT:
case text::RelOrientation::PAGE_FRAME: aPos.setX(pPage->Frame().Right()); break;
case text::RelOrientation::PAGE_PRINT_AREA: aPos.setX(pPage->Frame().Left()
+ pPage->Prt().Left()); break;
default: break;
}
}
else if ( bRTL )
{
switch ( _eHoriRelOrient )
{
case text::RelOrientation::FRAME_LEFT:
aPos.setX(pFrame->Frame().Left() +
pFrame->Prt().Left());
break;
case text::RelOrientation::PRINT_AREA:
aPos.setX(pFrame->Frame().Left() + pFrame->Prt().Left() +
pFrame->Prt().Width());
aPos.setX(aPos.getX() + nBaseOfstForFly);
break;
case text::RelOrientation::PAGE_LEFT:
aPos.setX(pPage->Frame().Left() + pPage->Prt().Left());
break;
case text::RelOrientation::PAGE_PRINT_AREA:
aPos.setX(pPage->Frame().Left() + pPage->Prt().Left() +
pPage->Prt().Width());
break;
case text::RelOrientation::PAGE_RIGHT:
case text::RelOrientation::PAGE_FRAME:
aPos.setX(pPage->Frame().Right());
break;
case text::RelOrientation::FRAME:
aPos.setX(aPos.getX() + nBaseOfstForFly);
break;
default: break;
}
}
else
{
switch ( _eHoriRelOrient )
{
case text::RelOrientation::FRAME_RIGHT:
aPos.X() += pFrame->Prt().Width();
aPos += pFrame->Prt().Pos();
break;
case text::RelOrientation::PRINT_AREA:
aPos += pFrame->Prt().Pos();
aPos.setX(aPos.getX() + nBaseOfstForFly);
break;
case text::RelOrientation::PAGE_RIGHT:
aPos.setX(pPage->Frame().Left() + pPage->Prt().Right());
break;
case text::RelOrientation::PAGE_PRINT_AREA:
aPos.setX(pPage->Frame().Left() + pPage->Prt().Left());
break;
case text::RelOrientation::PAGE_LEFT:
case text::RelOrientation::PAGE_FRAME:
aPos.setX(pPage->Frame().Left());
break;
case text::RelOrientation::FRAME:
aPos.setX(aPos.getX() + nBaseOfstForFly);
break;
default: break;
}
}
}
if( !_opRef )
{
if( bVertic && !bVerticalL2R )
_orRect.Pos( aPos.getX() - _orRect.Width() - _orRect.Left(), _orRect.Top() - aPos.getY() );
else if( bVerticalL2R )
_orRect.Pos( _orRect.Left() - aPos.getX(), _orRect.Top() - aPos.getY() );
else if ( bRTL )
_orRect.Pos( - ( _orRect.Right() - aPos.getX() ), _orRect.Top() - aPos.getY() );
else
_orRect.Pos( _orRect.Left() - aPos.getX(), _orRect.Top() - aPos.getY() );
if( _bMirror )
_orRect.Pos( -_orRect.Right(), _orRect.Top() );
}
}
Size SwFEShell::GetGraphicDefaultSize() const
{
Size aRet;
SwFlyFrame *pFly = GetSelectedFlyFrame();
if ( pFly )
{
// #i32951# - due to issue #i28701# no format of a
// newly inserted Writer fly frame or its anchor frame is performed
// any more. Thus, it could be possible (e.g. on insert of a horizontal
// line) that the anchor frame isn't formatted and its printing area
// size is (0,0). If this is the case the printing area of the upper
// of the anchor frame is taken.
const SwFrame* pAnchorFrame = pFly->GetAnchorFrame();
aRet = pAnchorFrame->Prt().SSize();
if ( aRet.Width() == 0 && aRet.Height() == 0 &&
pAnchorFrame->GetUpper() )
{
aRet = pAnchorFrame->GetUpper()->Prt().SSize();
}
SwRect aBound;
CalcBoundRect( aBound, pFly->GetFormat()->GetAnchor().GetAnchorId());
if ( pFly->GetAnchorFrame()->IsVertical() )
aRet.Width() = aBound.Width();
else
aRet.Height() = aBound.Height();
}
return aRet;
}
bool SwFEShell::IsFrameVertical(const bool bEnvironment, bool& bRTL, bool& bVertL2R) const
{
bool bVert = false;
bRTL = false;
bVertL2R = false;
if ( Imp()->HasDrawView() )
{
const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
if( rMrkList.GetMarkCount() != 1 )
return bVert;
SdrObject* pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
if ( !pObj )
{
OSL_FAIL( "<SwFEShell::IsFrameVertical(..)> - missing SdrObject instance in marked object list -> This is a serious situation" );
return bVert;
}
// #i26791#
SwContact* pContact = static_cast<SwContact*>(GetUserCall( pObj ));
if ( !pContact )
{
OSL_FAIL( "<SwFEShell::IsFrameVertical(..)> - missing SwContact instance at marked object -> This is a serious situation" );
return bVert;
}
const SwFrame* pRef = pContact->GetAnchoredObj( pObj )->GetAnchorFrame();
if ( !pRef )
{
OSL_FAIL( "<SwFEShell::IsFrameVertical(..)> - missing anchor frame at marked object -> This is a serious situation" );
return bVert;
}
if ( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) != nullptr && !bEnvironment )
pRef = static_cast<const SwVirtFlyDrawObj*>(pObj)->GetFlyFrame();
bVert = pRef->IsVertical();
bRTL = pRef->IsRightToLeft();
bVertL2R = pRef->IsVertLR();
}
return bVert;
}
void SwFEShell::MoveObjectIfActive( svt::EmbeddedObjectRef&, const Point& )
{
// does not do anything, only avoids crash if the method is used for wrong shell
}
void SwFEShell::ToggleHeaderFooterEdit()
{
// Clear objects selection
if ( Imp()->GetDrawView()->AreObjectsMarked() )
{
Imp()->GetDrawView()->UnmarkAll();
ClearMark();
}
SwCursorShell::ToggleHeaderFooterEdit();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|