1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_svx.hxx" 26 27 28 #include <tools/poly.hxx> 29 #include <vcl/metric.hxx> 30 #include <vcl/svapp.hxx> 31 #include <svtools/colorcfg.hxx> 32 #include <svx/swframeexample.hxx> 33 #include <com/sun/star/text/TextContentAnchorType.hpp> 34 #include <com/sun/star/text/HoriOrientation.hpp> 35 #include <com/sun/star/text/VertOrientation.hpp> 36 #include <com/sun/star/text/RelOrientation.hpp> 37 #include <com/sun/star/text/WrapTextMode.hpp> 38 39 using namespace ::com::sun::star::text; 40 41 #define FLYINFLY_BORDER 3 42 #define DEMOTEXT "Ij" 43 #define C2S(cChar) UniString::CreateFromAscii(cChar) 44 45 46 SvxSwFrameExample::SvxSwFrameExample( Window *pParent, const ResId& rResID ) : 47 48 Window(pParent, rResID), 49 50 nHAlign (HoriOrientation::CENTER), 51 nHRel (RelOrientation::FRAME), 52 nVAlign (VertOrientation::TOP), 53 nVRel (RelOrientation::PRINT_AREA), 54 nWrap (WrapTextMode_NONE), 55 nAnchor (TextContentAnchorType_AT_PAGE), 56 bTrans (sal_False), 57 aRelPos (Point(0,0)) 58 { 59 InitColors_Impl(); 60 SetMapMode(MAP_PIXEL); 61 } 62 63 SvxSwFrameExample::~SvxSwFrameExample() 64 { 65 } 66 67 void SvxSwFrameExample::InitColors_Impl( void ) 68 { 69 const StyleSettings& rSettings = GetSettings().GetStyleSettings(); 70 m_aBgCol = Color( rSettings.GetWindowColor() ); // old: COL_WHITE 71 72 sal_Bool bHC = rSettings.GetHighContrastMode(); 73 74 m_aFrameColor = Color( COL_LIGHTGREEN ); 75 m_aAlignColor = Color( COL_LIGHTRED ); 76 m_aTransColor = Color( COL_TRANSPARENT ); 77 78 m_aTxtCol = bHC? 79 svtools::ColorConfig().GetColorValue(svtools::FONTCOLOR).nColor : 80 Color( COL_GRAY ); // old: COL_GRAY 81 m_aPrintAreaCol = bHC? m_aTxtCol : Color( COL_GRAY ); 82 m_aBorderCol = m_aTxtCol; // old: COL_BLACK; 83 m_aBlankCol = bHC? m_aTxtCol : Color( COL_LIGHTGRAY ); 84 m_aBlankFrameCol = bHC? m_aTxtCol : Color( COL_GRAY ); 85 } 86 87 void SvxSwFrameExample::DataChanged( const DataChangedEvent& rDCEvt ) 88 { 89 Window::DataChanged( rDCEvt ); 90 91 if( rDCEvt.GetType() == DATACHANGED_SETTINGS && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) ) 92 InitColors_Impl(); 93 } 94 95 void SvxSwFrameExample::InitAllRects_Impl() 96 { 97 // const Size aSz(GetOutputSizePixel()); 98 99 // Seite 100 // aPage.SetSize(Size(aSz.Width() - 3, aSz.Height() - 3)); 101 aPage.SetSize( GetOutputSizePixel() ); 102 103 sal_uIntPtr nOutWPix = aPage.GetWidth(); 104 sal_uIntPtr nOutHPix = aPage.GetHeight(); 105 106 // PrintArea 107 sal_uIntPtr nLBorder; 108 sal_uIntPtr nRBorder; 109 sal_uIntPtr nTBorder; 110 sal_uIntPtr nBBorder; 111 112 sal_uIntPtr nLTxtBorder; 113 sal_uIntPtr nRTxtBorder; 114 sal_uIntPtr nTTxtBorder; 115 sal_uIntPtr nBTxtBorder; 116 117 if (nAnchor != TextContentAnchorType_AS_CHARACTER) 118 { 119 nLBorder = 14; 120 nRBorder = 10; 121 nTBorder = 10; 122 nBBorder = 15; 123 124 nLTxtBorder = 8; 125 nRTxtBorder = 4; 126 nTTxtBorder = 2; 127 nBTxtBorder = 2; 128 } 129 else 130 { 131 nLBorder = 2; 132 nRBorder = 2; 133 nTBorder = 2; 134 nBBorder = 2; 135 136 nLTxtBorder = 2; 137 nRTxtBorder = 2; 138 nTTxtBorder = 2; 139 nBTxtBorder = 2; 140 } 141 aPagePrtArea = Rectangle(Point(nLBorder, nTBorder), Point((nOutWPix - 1) - nRBorder, (nOutHPix - 1) - nBBorder)); 142 143 // Beispiel-Text: Vorbereiten fuer die Textausgabe 144 // Eine Textzeile 145 aTextLine = aPagePrtArea; 146 aTextLine.SetSize(Size(aTextLine.GetWidth(), 2)); 147 aTextLine.Left() += nLTxtBorder; 148 aTextLine.Right() -= nRTxtBorder; 149 aTextLine.Move(0, nTTxtBorder); 150 151 // Rechteck um Absatz incl. Raender 152 sal_uInt16 nLines = (sal_uInt16)((aPagePrtArea.GetHeight() / 2 - nTTxtBorder - nBTxtBorder) 153 / (aTextLine.GetHeight() + 2)); 154 aPara = aPagePrtArea; 155 aPara.SetSize(Size(aPara.GetWidth(), 156 (aTextLine.GetHeight() + 2) * nLines + nTTxtBorder + nBTxtBorder)); 157 158 // Rechteck um Absatz ohne Raender 159 aParaPrtArea = aPara; 160 aParaPrtArea.Left() += nLTxtBorder; 161 aParaPrtArea.Right() -= nRTxtBorder; 162 aParaPrtArea.Top() += nTTxtBorder; 163 aParaPrtArea.Bottom() -= nBTxtBorder; 164 165 if (nAnchor == TextContentAnchorType_AS_CHARACTER || nAnchor == TextContentAnchorType_AT_CHARACTER) 166 { 167 Font aFont = OutputDevice::GetDefaultFont( 168 DEFAULTFONT_LATIN_TEXT, Application::GetSettings().GetLanguage(), 169 DEFAULTFONT_FLAGS_ONLYONE, this ); 170 aFont.SetColor( m_aTxtCol ); 171 aFont.SetFillColor( m_aBgCol ); 172 aFont.SetWeight(WEIGHT_NORMAL); 173 174 if (nAnchor == TextContentAnchorType_AS_CHARACTER) 175 { 176 aFont.SetSize(Size(0, aParaPrtArea.GetHeight() - 2)); 177 SetFont(aFont); 178 aParaPrtArea.SetSize(Size(GetTextWidth(C2S(DEMOTEXT)), GetTextHeight())); 179 } 180 else 181 { 182 aFont.SetSize(Size(0, aParaPrtArea.GetHeight() / 2)); 183 SetFont(aFont); 184 aAutoCharFrame.SetSize(Size(GetTextWidth('A'), GetTextHeight())); 185 aAutoCharFrame.SetPos(Point(aParaPrtArea.Left() + (aParaPrtArea.GetWidth() - aAutoCharFrame.GetWidth()) / 2, 186 aParaPrtArea.Top() + (aParaPrtArea.GetHeight() - aAutoCharFrame.GetHeight()) / 2)); 187 } 188 } 189 190 // Innerer Frame fuer am Frame verankerte Rahmen 191 aFrameAtFrame = aPara; 192 aFrameAtFrame.Left() += 9; 193 aFrameAtFrame.Right() -= 5; 194 aFrameAtFrame.Bottom() += 5; 195 aFrameAtFrame.SetPos(Point(aFrameAtFrame.Left() + 2, (aPagePrtArea.Bottom() - aFrameAtFrame.GetHeight()) / 2 + 5)); 196 197 // Groesse des zu positionierenden Rahmens 198 if (nAnchor != TextContentAnchorType_AS_CHARACTER) 199 { 200 sal_uIntPtr nLFBorder = nAnchor == TextContentAnchorType_AT_PAGE ? nLBorder : nLTxtBorder; 201 sal_uIntPtr nRFBorder = nAnchor == TextContentAnchorType_AT_PAGE ? nRBorder : nRTxtBorder; 202 203 switch (nHRel) 204 { 205 case RelOrientation::PAGE_LEFT: 206 case RelOrientation::FRAME_LEFT: 207 aFrmSize = Size(nLFBorder - 4, (aTextLine.GetHeight() + 2) * 3); 208 break; 209 210 case RelOrientation::PAGE_RIGHT: 211 case RelOrientation::FRAME_RIGHT: 212 aFrmSize = Size(nRFBorder - 4, (aTextLine.GetHeight() + 2) * 3); 213 break; 214 215 default: 216 aFrmSize = Size(nLBorder - 3, (aTextLine.GetHeight() + 2) * 3); 217 break; 218 } 219 aFrmSize.Width() = Max(5L, aFrmSize.Width()); 220 aFrmSize.Height() = Max(5L, aFrmSize.Height()); 221 } 222 else 223 { 224 sal_uIntPtr nFreeWidth = aPagePrtArea.GetWidth() - GetTextWidth(C2S(DEMOTEXT)); 225 226 aFrmSize = Size(nFreeWidth / 2, (aTextLine.GetHeight() + 2) * 3); 227 aDrawObj.SetSize(Size(Max(5L, (long)nFreeWidth / 3L), Max(5L, aFrmSize.Height() * 3L))); 228 aDrawObj.SetPos(Point(aParaPrtArea.Right() + 1, aParaPrtArea.Bottom() / 2)); 229 aParaPrtArea.Right() = aDrawObj.Right(); 230 } 231 } 232 233 void SvxSwFrameExample::CalcBoundRect_Impl(Rectangle &rRect) 234 { 235 switch (nAnchor) 236 { 237 case TextContentAnchorType_AT_PAGE: 238 { 239 switch (nHRel) 240 { 241 case RelOrientation::FRAME: 242 case RelOrientation::PAGE_FRAME: 243 rRect.Left() = aPage.Left(); 244 rRect.Right() = aPage.Right(); 245 break; 246 247 case RelOrientation::PRINT_AREA: 248 case RelOrientation::PAGE_PRINT_AREA: 249 rRect.Left() = aPagePrtArea.Left(); 250 rRect.Right() = aPagePrtArea.Right(); 251 break; 252 253 case RelOrientation::PAGE_LEFT: 254 rRect.Left() = aPage.Left(); 255 rRect.Right() = aPagePrtArea.Left(); 256 break; 257 258 case RelOrientation::PAGE_RIGHT: 259 rRect.Left() = aPagePrtArea.Right(); 260 rRect.Right() = aPage.Right(); 261 break; 262 } 263 264 switch (nVRel) 265 { 266 case RelOrientation::PRINT_AREA: 267 case RelOrientation::PAGE_PRINT_AREA: 268 rRect.Top() = aPagePrtArea.Top(); 269 rRect.Bottom() = aPagePrtArea.Bottom(); 270 break; 271 272 case RelOrientation::FRAME: 273 case RelOrientation::PAGE_FRAME: 274 rRect.Top() = aPage.Top(); 275 rRect.Bottom() = aPage.Bottom(); 276 break; 277 } 278 } 279 break; 280 281 case TextContentAnchorType_AT_FRAME: 282 { 283 switch (nHRel) 284 { 285 case RelOrientation::FRAME: 286 case RelOrientation::PAGE_FRAME: 287 rRect.Left() = aFrameAtFrame.Left(); 288 rRect.Right() = aFrameAtFrame.Right(); 289 break; 290 291 case RelOrientation::PRINT_AREA: 292 case RelOrientation::PAGE_PRINT_AREA: 293 rRect.Left() = aFrameAtFrame.Left() + FLYINFLY_BORDER; 294 rRect.Right() = aFrameAtFrame.Right() - FLYINFLY_BORDER; 295 break; 296 297 case RelOrientation::PAGE_RIGHT: 298 rRect.Left() = aFrameAtFrame.Left(); 299 rRect.Right() = aFrameAtFrame.Left() + FLYINFLY_BORDER; 300 break; 301 302 case RelOrientation::PAGE_LEFT: 303 rRect.Left() = aFrameAtFrame.Right(); 304 rRect.Right() = aFrameAtFrame.Right() - FLYINFLY_BORDER; 305 break; 306 } 307 308 switch (nVRel) 309 { 310 case RelOrientation::FRAME: 311 case RelOrientation::PAGE_FRAME: 312 rRect.Top() = aFrameAtFrame.Top(); 313 rRect.Bottom() = aFrameAtFrame.Bottom(); 314 break; 315 316 case RelOrientation::PRINT_AREA: 317 case RelOrientation::PAGE_PRINT_AREA: 318 rRect.Top() = aFrameAtFrame.Top() + FLYINFLY_BORDER; 319 rRect.Bottom() = aFrameAtFrame.Bottom() - FLYINFLY_BORDER; 320 break; 321 } 322 } 323 break; 324 case TextContentAnchorType_AT_PARAGRAPH: 325 case TextContentAnchorType_AT_CHARACTER: 326 { 327 switch (nHRel) 328 { 329 case RelOrientation::FRAME: 330 rRect.Left() = aPara.Left(); 331 rRect.Right() = aPara.Right(); 332 break; 333 334 case RelOrientation::PRINT_AREA: 335 rRect.Left() = aParaPrtArea.Left(); 336 rRect.Right() = aParaPrtArea.Right(); 337 break; 338 339 case RelOrientation::PAGE_LEFT: 340 rRect.Left() = aPage.Left(); 341 rRect.Right() = aPagePrtArea.Left(); 342 break; 343 344 case RelOrientation::PAGE_RIGHT: 345 rRect.Left() = aPagePrtArea.Right(); 346 rRect.Right() = aPage.Right(); 347 break; 348 349 case RelOrientation::PAGE_FRAME: 350 rRect.Left() = aPage.Left(); 351 rRect.Right() = aPage.Right(); 352 break; 353 354 case RelOrientation::PAGE_PRINT_AREA: 355 rRect.Left() = aPagePrtArea.Left(); 356 rRect.Right() = aPagePrtArea.Right(); 357 break; 358 359 case RelOrientation::FRAME_LEFT: 360 rRect.Left() = aPara.Left(); 361 rRect.Right() = aParaPrtArea.Left(); 362 break; 363 364 case RelOrientation::FRAME_RIGHT: 365 rRect.Left() = aParaPrtArea.Right(); 366 rRect.Right() = aPara.Right(); 367 break; 368 369 case RelOrientation::CHAR: 370 rRect.Left() = aAutoCharFrame.Left(); 371 rRect.Right() = aAutoCharFrame.Left(); 372 break; 373 } 374 375 switch (nVRel) 376 { 377 case RelOrientation::FRAME: 378 rRect.Top() = aPara.Top(); 379 rRect.Bottom() = aPara.Bottom(); 380 break; 381 382 case RelOrientation::PRINT_AREA: 383 rRect.Top() = aParaPrtArea.Top(); 384 rRect.Bottom() = aParaPrtArea.Bottom(); 385 break; 386 387 case RelOrientation::CHAR: 388 if (nVAlign != VertOrientation::NONE && 389 nVAlign != VertOrientation::CHAR_BOTTOM) 390 rRect.Top() = aAutoCharFrame.Top(); 391 else 392 rRect.Top() = aAutoCharFrame.Bottom(); 393 rRect.Bottom() = aAutoCharFrame.Bottom(); 394 break; 395 // OD 12.11.2003 #i22341# 396 case RelOrientation::TEXT_LINE: 397 rRect.Top() = aAutoCharFrame.Top(); 398 rRect.Bottom() = aAutoCharFrame.Top(); 399 break; 400 } 401 } 402 break; 403 404 case TextContentAnchorType_AS_CHARACTER: 405 rRect.Left() = aParaPrtArea.Left(); 406 rRect.Right() = aParaPrtArea.Right(); 407 408 switch (nVAlign) 409 { 410 case VertOrientation::NONE: 411 case VertOrientation::TOP: 412 case VertOrientation::CENTER: 413 case VertOrientation::BOTTOM: 414 { 415 FontMetric aMetric(GetFontMetric()); 416 417 rRect.Top() = aParaPrtArea.Bottom() - aMetric.GetDescent(); 418 rRect.Bottom() = rRect.Top(); 419 } 420 break; 421 422 default: 423 424 case VertOrientation::LINE_TOP: 425 case VertOrientation::LINE_CENTER: 426 case VertOrientation::LINE_BOTTOM: 427 rRect.Top() = aParaPrtArea.Top(); 428 rRect.Bottom() = aDrawObj.Bottom(); 429 break; 430 431 case VertOrientation::CHAR_TOP: 432 case VertOrientation::CHAR_CENTER: 433 case VertOrientation::CHAR_BOTTOM: 434 rRect.Top() = aParaPrtArea.Top(); 435 rRect.Bottom() = aParaPrtArea.Bottom(); 436 break; 437 } 438 break; 439 440 default: 441 break; 442 } 443 } 444 445 Rectangle SvxSwFrameExample::DrawInnerFrame_Impl(const Rectangle &rRect, const Color &rFillColor, const Color &rBorderColor) 446 { 447 DrawRect_Impl(rRect, rFillColor, rBorderColor); 448 449 // Bereich, zu dem relativ positioniert wird, bestimmen 450 Rectangle aRect(rRect); // aPagePrtArea = Default 451 CalcBoundRect_Impl(aRect); 452 453 if (nAnchor == TextContentAnchorType_AT_FRAME && &rRect == &aPagePrtArea) 454 { 455 // Testabsatz zeichnen 456 Rectangle aTxt(aTextLine); 457 sal_Int32 nStep = aTxt.GetHeight() + 2; 458 sal_uInt16 nLines = (sal_uInt16)(aParaPrtArea.GetHeight() / (aTextLine.GetHeight() + 2)); 459 460 for (sal_uInt16 i = 0; i < nLines; i++) 461 { 462 if (i == nLines - 1) 463 aTxt.SetSize(Size(aTxt.GetWidth() / 2, aTxt.GetHeight())); 464 DrawRect_Impl(aTxt, m_aTxtCol, m_aTransColor); 465 aTxt.Move(0, nStep); 466 } 467 } 468 469 return aRect; 470 } 471 472 void SvxSwFrameExample::Paint(const Rectangle&) 473 { 474 InitAllRects_Impl(); 475 476 // Schatten zeichnen 477 // Rectangle aShadow(aPage); 478 // aShadow += Point(3, 3); 479 // DrawRect_Impl(aShadow, Color(COL_GRAY), aTransColor); 480 481 // Seite zeichnen 482 DrawRect_Impl( aPage, m_aBgCol, m_aBorderCol ); 483 484 // PrintArea zeichnen 485 Rectangle aRect = DrawInnerFrame_Impl( aPagePrtArea, m_aTransColor, m_aPrintAreaCol ); 486 487 if (nAnchor == TextContentAnchorType_AT_FRAME) 488 aRect = DrawInnerFrame_Impl( aFrameAtFrame, m_aBgCol, m_aBorderCol ); 489 490 long lXPos = 0; 491 long lYPos = 0; 492 493 // Horizontale Ausrichtung 494 // 495 if (nAnchor != TextContentAnchorType_AS_CHARACTER) 496 { 497 switch (nHAlign) 498 { 499 case HoriOrientation::RIGHT: 500 { 501 lXPos = aRect.Right() - aFrmSize.Width() + 1; 502 break; 503 } 504 case HoriOrientation::CENTER: 505 { 506 lXPos = aRect.Left() + (aRect.GetWidth() - aFrmSize.Width()) / 2; 507 break; 508 } 509 case HoriOrientation::NONE: 510 { 511 lXPos = aRect.Left() + aRelPos.X(); 512 break; 513 } 514 515 default: // HoriOrientation::LEFT 516 lXPos = aRect.Left(); 517 break; 518 } 519 } 520 else 521 lXPos = aRect.Right() + 2; 522 523 // Vertikale Ausrichtung 524 // 525 if (nAnchor != TextContentAnchorType_AS_CHARACTER) 526 { 527 switch (nVAlign) 528 { 529 case VertOrientation::BOTTOM: 530 case VertOrientation::LINE_BOTTOM: 531 { 532 // OD 12.11.2003 #i22341# 533 if ( nVRel != RelOrientation::TEXT_LINE ) 534 { 535 lYPos = aRect.Bottom() - aFrmSize.Height() + 1; 536 } 537 else 538 { 539 lYPos = aRect.Top(); 540 } 541 break; 542 } 543 case VertOrientation::CENTER: 544 case VertOrientation::LINE_CENTER: 545 { 546 lYPos = aRect.Top() + (aRect.GetHeight() - aFrmSize.Height()) / 2; 547 break; 548 } 549 case VertOrientation::NONE: 550 { 551 // OD 12.11.2003 #i22341# 552 if ( nVRel != RelOrientation::CHAR && nVRel != RelOrientation::TEXT_LINE ) 553 lYPos = aRect.Top() + aRelPos.Y(); 554 else 555 lYPos = aRect.Top() - aRelPos.Y(); 556 break; 557 } 558 default: 559 // OD 12.11.2003 #i22341# 560 if ( nVRel != RelOrientation::TEXT_LINE ) 561 { 562 lYPos = aRect.Top(); 563 } 564 else 565 { 566 lYPos = aRect.Bottom() - aFrmSize.Height() + 1; 567 } 568 break; 569 } 570 } 571 else 572 { 573 switch(nVAlign) 574 { 575 case VertOrientation::CENTER: 576 case VertOrientation::CHAR_CENTER: 577 case VertOrientation::LINE_CENTER: 578 lYPos = aRect.Top() + (aRect.GetHeight() - aFrmSize.Height()) / 2; 579 break; 580 581 case VertOrientation::TOP: 582 case VertOrientation::CHAR_BOTTOM: 583 case VertOrientation::LINE_BOTTOM: 584 lYPos = aRect.Bottom() - aFrmSize.Height() + 1; 585 break; 586 587 /* case VertOrientation::NONE: 588 case VertOrientation::BOTTOM: 589 case VertOrientation::CHAR_TOP: 590 case VertOrientation::LINE_TOP:*/ 591 default: 592 lYPos = aRect.Top() - aRelPos.Y(); 593 break; 594 } 595 } 596 597 Rectangle aFrmRect(Point(lXPos, lYPos), aFrmSize); 598 599 Rectangle *pOuterFrame = &aPage; 600 601 if (nAnchor == TextContentAnchorType_AT_FRAME) 602 pOuterFrame = &aFrameAtFrame; 603 604 if (aFrmRect.Left() < pOuterFrame->Left()) 605 aFrmRect.Move(pOuterFrame->Left() - aFrmRect.Left(), 0); 606 if (aFrmRect.Right() > pOuterFrame->Right()) 607 aFrmRect.Move(pOuterFrame->Right() - aFrmRect.Right(), 0); 608 609 if (aFrmRect.Top() < pOuterFrame->Top()) 610 aFrmRect.Move(0, pOuterFrame->Top() - aFrmRect.Top()); 611 if (aFrmRect.Bottom() > pOuterFrame->Bottom()) 612 aFrmRect.Move(0, pOuterFrame->Bottom() - aFrmRect.Bottom()); 613 614 // Testabsatz zeichnen 615 const long nTxtLineHeight = aTextLine.GetHeight(); 616 Rectangle aTxt(aTextLine); 617 sal_Int32 nStep; 618 sal_uInt16 nLines; 619 620 if (nAnchor == TextContentAnchorType_AT_FRAME) 621 { 622 aTxt.Left() = aFrameAtFrame.Left() + FLYINFLY_BORDER; 623 aTxt.Right() = aFrameAtFrame.Right() - FLYINFLY_BORDER; 624 aTxt.Top() = aFrameAtFrame.Top() + FLYINFLY_BORDER; 625 aTxt.Bottom() = aTxt.Top() + aTextLine.GetHeight() - 1; 626 627 nStep = aTxt.GetHeight() + 2; 628 nLines = (sal_uInt16)(((aFrameAtFrame.GetHeight() - 2 * FLYINFLY_BORDER) * 2 / 3) 629 / (aTxt.GetHeight() + 2)); 630 } 631 else 632 { 633 nStep = aTxt.GetHeight() + 2; 634 nLines = (sal_uInt16)(aParaPrtArea.GetHeight() / (aTextLine.GetHeight() + 2)); 635 } 636 637 if (nAnchor != TextContentAnchorType_AS_CHARACTER) 638 { 639 // Text simulieren 640 // 641 const long nOldR = aTxt.Right(); 642 const long nOldL = aTxt.Left(); 643 644 // OD 12.11.2003 #i22341# 645 const bool bIgnoreWrap = nAnchor == TextContentAnchorType_AT_CHARACTER && 646 ( nHRel == RelOrientation::CHAR || nVRel == RelOrientation::CHAR || 647 nVRel == RelOrientation::TEXT_LINE ); 648 649 for (sal_uInt16 i = 0; i < nLines; ++i) 650 { 651 if (i == (nLines - 1)) 652 aTxt.SetSize(Size(aTxt.GetWidth() / 2, aTxt.GetHeight())); 653 654 if (aTxt.IsOver(aFrmRect) && nAnchor != TextContentAnchorType_AS_CHARACTER && !bIgnoreWrap) 655 { 656 switch(nWrap) 657 { 658 case WrapTextMode_NONE: 659 aTxt.Top() = aFrmRect.Bottom() + nTxtLineHeight; 660 aTxt.Bottom() = aTxt.Top() + nTxtLineHeight - 1; 661 break; 662 663 case WrapTextMode_LEFT: 664 aTxt.Right() = aFrmRect.Left(); 665 break; 666 667 case WrapTextMode_RIGHT: 668 aTxt.Left() = aFrmRect.Right(); 669 break; 670 } 671 } 672 if (pOuterFrame->IsInside(aTxt)) 673 DrawRect_Impl( aTxt, m_aTxtCol, m_aTransColor ); 674 675 aTxt.Move(0, nStep); 676 aTxt.Right() = nOldR; 677 aTxt.Left() = nOldL; 678 } 679 aTxt.Move(0, -nStep); 680 681 if (nAnchor != TextContentAnchorType_AT_FRAME && aTxt.Bottom() > aParaPrtArea.Bottom()) 682 { 683 // Text wurde durch Rahmen verdraengt, daher Para-Hoehe anpassen 684 sal_uIntPtr nDiff = aTxt.Bottom() - aParaPrtArea.Bottom(); 685 aParaPrtArea.Bottom() += nDiff; 686 aPara.Bottom() += nDiff; 687 688 CalcBoundRect_Impl(aRect); 689 690 aParaPrtArea.Bottom() -= nDiff; 691 aPara.Bottom() -= nDiff; 692 } 693 if (nAnchor == TextContentAnchorType_AT_CHARACTER && bIgnoreWrap) 694 DrawText(aAutoCharFrame, 'A'); 695 } 696 else 697 { 698 DrawText(aParaPrtArea, C2S(DEMOTEXT)); 699 DrawRect_Impl(aDrawObj, m_aBlankCol, m_aBlankFrameCol ); 700 } 701 702 // Rechteck zeichnen, zu dem der Rahmen ausgerichtet wird: 703 DrawRect_Impl(aRect, m_aTransColor, m_aAlignColor); 704 705 // Frame anzeigen 706 sal_Bool bDontFill = (nAnchor == TextContentAnchorType_AT_CHARACTER && aFrmRect.IsOver(aAutoCharFrame)) ? sal_True : bTrans; 707 DrawRect_Impl( aFrmRect, bDontFill? m_aTransColor : m_aBgCol, m_aFrameColor ); 708 } 709 710 void SvxSwFrameExample::SetRelPos(const Point& rP) 711 { 712 aRelPos = rP; 713 714 if (aRelPos.X() > 0) 715 aRelPos.X() = 5; 716 if (aRelPos.X() < 0) 717 aRelPos.X() = -5; 718 719 if (aRelPos.Y() > 0) 720 aRelPos.Y() = 5; 721 if (aRelPos.Y() < 0) 722 aRelPos.Y() = -5; 723 } 724 725 void SvxSwFrameExample::DrawRect_Impl(const Rectangle &rRect, const Color &rFillColor, const Color &rLineColor) 726 { 727 SetFillColor(rFillColor); 728 SetLineColor(rLineColor); 729 Window::DrawRect(rRect); 730 } 731 732 733 734